Skip to content

Commit 5ac1eba

Browse files
committed
Fix mint for gift card exchange data in GetTokenAccountInfos
1 parent c7a6f82 commit 5ac1eba

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

pkg/code/server/account/server.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,12 +502,17 @@ func (s *server) getOriginalGiftCardExchangeData(ctx context.Context, records *c
502502
return nil, err
503503
}
504504

505+
mintAccount, err := common.NewAccountFromPublicKeyString(intentRecord.MintAccount)
506+
if err != nil {
507+
return nil, err
508+
}
509+
505510
return &transactionpb.ExchangeData{
506511
Currency: string(intentRecord.SendPublicPaymentMetadata.ExchangeCurrency),
507512
ExchangeRate: intentRecord.SendPublicPaymentMetadata.ExchangeRate,
508513
NativeAmount: intentRecord.SendPublicPaymentMetadata.NativeAmount,
509514
Quarks: intentRecord.SendPublicPaymentMetadata.Quantity,
510-
Mint: common.CoreMintAccount.ToProto(),
515+
Mint: mintAccount.ToProto(),
511516
}, nil
512517
}
513518

pkg/code/server/account/server_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ func TestGetTokenAccountInfos_RemoteSendGiftCard_HappyPath(t *testing.T) {
256256
env, cleanup := setup(t)
257257
defer cleanup()
258258

259-
coreVmConfig := testutil.NewRandomVmConfig(t, true)
259+
vmConfig := testutil.NewRandomVmConfig(t, false)
260260

261261
// Test cases represent main iterations of a gift card account's state throughout
262262
// its lifecycle. All states beyond claimed status are not fully tested here and
@@ -385,13 +385,13 @@ func TestGetTokenAccountInfos_RemoteSendGiftCard_HappyPath(t *testing.T) {
385385
giftCardIssuerOwnerAccount := testutil.NewRandomAccount(t)
386386
giftCardOwnerAccount := testutil.NewRandomAccount(t)
387387

388-
accountRecords := setupAccountRecords(t, env, giftCardOwnerAccount, giftCardOwnerAccount, coreVmConfig, 0, commonpb.AccountType_REMOTE_SEND_GIFT_CARD)
388+
accountRecords := setupAccountRecords(t, env, giftCardOwnerAccount, giftCardOwnerAccount, vmConfig, 0, commonpb.AccountType_REMOTE_SEND_GIFT_CARD)
389389

390390
giftCardIssuedIntentRecord := &intent.Record{
391391
IntentId: testutil.NewRandomAccount(t).PublicKey().ToBase58(),
392392
IntentType: intent.SendPublicPayment,
393393

394-
MintAccount: common.CoreMintAccount.PublicKey().ToBase58(),
394+
MintAccount: vmConfig.Mint.PublicKey().ToBase58(),
395395

396396
InitiatorOwnerAccount: giftCardIssuerOwnerAccount.PublicKey().ToBase58(),
397397

@@ -460,7 +460,7 @@ func TestGetTokenAccountInfos_RemoteSendGiftCard_HappyPath(t *testing.T) {
460460
testutil.NewRandomAccount(t),
461461
giftCardIssuerOwnerAccount,
462462
} {
463-
timelockAccounts, err := giftCardOwnerAccount.GetTimelockAccounts(coreVmConfig)
463+
timelockAccounts, err := giftCardOwnerAccount.GetTimelockAccounts(vmConfig)
464464
require.NoError(t, err)
465465

466466
req := &accountpb.GetTokenAccountInfosRequest{
@@ -495,7 +495,7 @@ func TestGetTokenAccountInfos_RemoteSendGiftCard_HappyPath(t *testing.T) {
495495
assert.Equal(t, giftCardOwnerAccount.PublicKey().ToBytes(), accountInfo.Owner.Value)
496496
assert.Equal(t, giftCardOwnerAccount.PublicKey().ToBytes(), accountInfo.Authority.Value)
497497
assert.Equal(t, timelockAccounts.Vault.PublicKey().ToBytes(), accountInfo.Address.Value)
498-
assert.Equal(t, common.CoreMintAccount.PublicKey().ToBytes(), accountInfo.Mint.Value)
498+
assert.Equal(t, vmConfig.Mint.PublicKey().ToBytes(), accountInfo.Mint.Value)
499499
assert.EqualValues(t, 0, accountInfo.Index)
500500

501501
assert.Equal(t, tc.expectedBalanceSource, accountInfo.BalanceSource)
@@ -516,12 +516,13 @@ func TestGetTokenAccountInfos_RemoteSendGiftCard_HappyPath(t *testing.T) {
516516
assert.Equal(t, giftCardIssuedIntentRecord.SendPublicPaymentMetadata.ExchangeRate, accountInfo.OriginalExchangeData.ExchangeRate)
517517
assert.Equal(t, giftCardIssuedIntentRecord.SendPublicPaymentMetadata.NativeAmount, accountInfo.OriginalExchangeData.NativeAmount)
518518
assert.Equal(t, giftCardIssuedIntentRecord.SendPublicPaymentMetadata.Quantity, accountInfo.OriginalExchangeData.Quarks)
519+
assert.Equal(t, vmConfig.Mint.PublicKey().ToBytes(), accountInfo.OriginalExchangeData.Mint.Value)
519520

520521
assert.Equal(t, requestingOwnerAccount != nil && requestingOwnerAccount == giftCardIssuerOwnerAccount, accountInfo.IsGiftCardIssuer)
521522

522523
accountInfoRecordsByMint, err := env.data.GetLatestAccountInfoByOwnerAddressAndType(env.ctx, giftCardOwnerAccount.PublicKey().ToBase58(), commonpb.AccountType_REMOTE_SEND_GIFT_CARD)
523524
require.NoError(t, err)
524-
assert.False(t, accountInfoRecordsByMint[common.CoreMintAccount.PublicKey().ToBase58()].RequiresDepositSync)
525+
assert.False(t, accountInfoRecordsByMint[vmConfig.Mint.PublicKey().ToBase58()].RequiresDepositSync)
525526
}
526527
}
527528
}

0 commit comments

Comments
 (0)