Skip to content

Commit 4fd4c0a

Browse files
fix(sdk-coin-ton): parse token transactions correctly
TICKET: COIN-5916
1 parent 49e9906 commit 4fd4c0a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

modules/sdk-coin-ton/src/lib/transaction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ export class Transaction extends BaseTransaction {
317317
payload = WITHDRAW_OPCODE + queryId.toString(16).padStart(16, '0') + withdrawAmount;
318318
this.transactionType = TransactionType.SingleNominatorWithdraw;
319319
} else if (opcode === JETTON_TRANSFER_OPCODE) {
320+
this.transactionType = TransactionType.SendToken;
320321
const queryId = order.loadUint(64).toNumber();
321322
if (queryId !== 0) throw new Error('invalid queryId for jetton transfer');
322323

modules/sdk-coin-ton/src/lib/transactionBuilderFactory.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,18 @@ export class TransactionBuilderFactory extends BaseTransactionBuilderFactory {
1515
from(raw: string): TransactionBuilder {
1616
let builder: TransactionBuilder;
1717
try {
18-
const tx = this._coinConfig.isToken ? new TokenTransaction(this._coinConfig) : new Transaction(this._coinConfig);
19-
tx.fromRawTransaction(raw);
18+
const checkTx = new Transaction(this._coinConfig);
19+
checkTx.fromRawTransaction(raw);
20+
21+
let tx: Transaction;
22+
if (checkTx.type === TransactionType.SendToken) {
23+
// It's a token transaction, so use TokenTransaction for proper parsing
24+
tx = new TokenTransaction(this._coinConfig);
25+
tx.fromRawTransaction(raw);
26+
} else {
27+
// It's a regular transaction, use the already parsed one
28+
tx = checkTx;
29+
}
2030
switch (tx.type) {
2131
case TransactionType.Send:
2232
builder = this.getTransferBuilder();

0 commit comments

Comments
 (0)