Skip to content

Commit e187ee7

Browse files
committed
chore: fix the build from raw sol transaction
Ticket: WIN-5679
1 parent 1a3c85e commit e187ee7

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

modules/sdk-coin-sol/src/lib/tokenTransferBuilder.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ export class TokenTransferBuilder extends TransactionBuilder {
5050
address: transferInstruction.params.toAddress,
5151
amount: transferInstruction.params.amount,
5252
tokenName: transferInstruction.params.tokenName,
53+
tokenAddress: transferInstruction.params.tokenAddress,
54+
programId: transferInstruction.params.programId,
55+
decimalPlaces: transferInstruction.params.decimalPlaces,
5356
});
5457
}
5558
if (instruction.type === InstructionBuilderTypes.CreateAssociatedTokenAccount) {
@@ -58,6 +61,8 @@ export class TokenTransferBuilder extends TransactionBuilder {
5861
ownerAddress: ataInitInstruction.params.ownerAddress,
5962
tokenName: ataInitInstruction.params.tokenName,
6063
ataAddress: ataInitInstruction.params.ataAddress,
64+
tokenAddress: ataInitInstruction.params.mintAddress,
65+
programId: ataInitInstruction.params.programId,
6166
});
6267
}
6368
}

modules/sdk-coin-sol/test/unit/transactionBuilder/ataInitBuilder.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { KeyPair, Utils, AtaInitializationBuilder } from '../../../src';
1+
import { KeyPair, Utils, AtaInitializationBuilder, TokenTransferBuilder } from '../../../src';
22
import should from 'should';
33
import * as testData from '../../resources/sol';
44
import { BaseTransaction } from '@bitgo/sdk-core';
@@ -499,6 +499,23 @@ describe('Sol Associated Token Account Builder', () => {
499499
should.equal(rawTx, testData.MULTI_ATA_INIT_SIGNED_TX_WITH_MEMO_OPTIONAL_PARAM1);
500500
});
501501

502+
it('build from a unsigned raw token transfer with optinal param', async () => {
503+
const txBuilder = factory.from(
504+
testData.TOKEN_TRANSFER_UNSIGNED_WITH_CREATE_ATA_AND_MEMO_AND_DURABLE_NONCE_WITH_OPTIONAL_PARAMS
505+
) as TokenTransferBuilder;
506+
507+
(txBuilder as any)._sendParams[0].tokenName = 'tsol:ams';
508+
(txBuilder as any)._createAtaParams[0].tokenName = 'tsol:ams';
509+
510+
const tx = await txBuilder.build();
511+
const rawTx = tx.toBroadcastFormat();
512+
513+
should.equal(
514+
rawTx,
515+
testData.TOKEN_TRANSFER_UNSIGNED_WITH_CREATE_ATA_AND_MEMO_AND_DURABLE_NONCE_WITH_OPTIONAL_PARAMS
516+
);
517+
});
518+
502519
it('build from an unsigned ATA init with durable nonce and sign it', async () => {
503520
const txBuilder = factory.from(testData.ATA_INIT_UNSIGNED_TX_DURABLE_NONCE);
504521
txBuilder.sign({ key: account.prv });

0 commit comments

Comments
 (0)