Skip to content

Commit d171bdc

Browse files
committed
Forgot ReceivePaymentsPublicly intent handler
1 parent 950afce commit d171bdc

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

pkg/code/server/transaction/intent_handler.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ func (h *SendPublicPaymentIntentHandler) AllowCreation(ctx context.Context, inte
469469
if err != nil {
470470
return err
471471
}
472+
472473
intentMintAccount, err := common.GetBackwardsCompatMint(typedMetadata.Mint)
473474
if err != nil {
474475
return err
@@ -870,9 +871,6 @@ func (h *ReceivePaymentsPubliclyIntentHandler) PopulateMetadata(ctx context.Cont
870871
if err != nil {
871872
return err
872873
}
873-
if !common.IsCoreMint(mint) {
874-
return NewIntentValidationError("only the core mint is supported")
875-
}
876874

877875
giftCardVault, err := common.NewAccountFromPublicKeyBytes(typedProtoMetadata.Source.Value)
878876
if err != nil {
@@ -962,6 +960,11 @@ func (h *ReceivePaymentsPubliclyIntentHandler) AllowCreation(ctx context.Context
962960
return err
963961
}
964962

963+
intentMintAccount, err := common.GetBackwardsCompatMint(typedMetadata.Mint)
964+
if err != nil {
965+
return err
966+
}
967+
965968
giftCardVaultAccount, err := common.NewAccountFromPublicKeyString(intentRecord.ReceivePaymentsPubliclyMetadata.Source)
966969
if err != nil {
967970
return err
@@ -971,9 +974,9 @@ func (h *ReceivePaymentsPubliclyIntentHandler) AllowCreation(ctx context.Context
971974
if err != nil {
972975
return err
973976
}
974-
initiatorAccountsByType, ok := initiatorAccountsByMintAndType[common.CoreMintAccount.PublicKey().ToBase58()]
977+
initiatorAccountsByType, ok := initiatorAccountsByMintAndType[intentMintAccount.PublicKey().ToBase58()]
975978
if !ok {
976-
return errors.New("initiator core mint accounts don't exist")
979+
return errors.New("initiator mint accounts don't exist")
977980
}
978981

979982
initiatorAccounts := make([]*common.AccountRecords, 0)
@@ -1095,12 +1098,15 @@ func (h *ReceivePaymentsPubliclyIntentHandler) validateActions(
10951098
return err
10961099
}
10971100

1098-
// The destination account must be the primary
1101+
// The destination account must be the primary account of the same mint
10991102
destinationAccountInfo := initiatorAccountsByType[commonpb.AccountType_PRIMARY][0].General
11001103
destinationSimulation, ok := simResult.SimulationsByAccount[destinationAccountInfo.TokenAccount]
11011104
if !ok {
11021105
return NewActionValidationError(actions[0], "must send payment to primary account")
11031106
}
1107+
if destinationAccountInfo.MintAccount != intentMint.PublicKey().ToBase58() {
1108+
return NewIntentValidationErrorf("destination account is not of %s mint", intentMint.PublicKey().ToBase58())
1109+
}
11041110

11051111
//
11061112
// Part 3: Validate actions match intent

0 commit comments

Comments
 (0)