Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/sdk-coin-tempo/src/lib/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class Tip20Transaction extends BaseTransaction {
callsTuples,
accessTuples,
'0x', // nonceKey (reserved for 2D nonce system)
ethers.utils.hexlify(this.txRequest.nonce),
this.txRequest.nonce ? this.bigintToHex(BigInt(this.txRequest.nonce)) : '0x',
'0x', // validBefore (reserved for time bounds)
'0x', // validAfter (reserved for time bounds)
this.txRequest.feeToken || '0x',
Expand Down
13 changes: 11 additions & 2 deletions modules/sdk-coin-tempo/src/tempo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from '@bitgo/sdk-core';
import { BaseCoin as StaticsBaseCoin, coins } from '@bitgo/statics';
import { Tip20Transaction, Tip20TransactionBuilder } from './lib';
import { amountToTip20Units, isValidMemoId as isValidMemoIdUtil } from './lib/utils';
import { amountToTip20Units, isTip20Transaction, isValidMemoId as isValidMemoIdUtil } from './lib/utils';
import * as url from 'url';
import * as querystring from 'querystring';

Expand Down Expand Up @@ -213,6 +213,9 @@ export class Tempo extends AbstractEthLikeNewCoins {
if (!txHex) {
return {};
}
if (!isTip20Transaction(txHex)) {
return {};
}
const txBuilder = this.getTransactionBuilder();
txBuilder.from(txHex);
const tx = (await txBuilder.build()) as Tip20Transaction;
Expand Down Expand Up @@ -241,8 +244,14 @@ export class Tempo extends AbstractEthLikeNewCoins {
return true;
}

// signableHex may arrive without the 0x prefix (e.g. from the TSS signing flow).
const txHex = txPrebuild.txHex.startsWith('0x') ? txPrebuild.txHex : '0x' + txPrebuild.txHex;
if (!isTip20Transaction(txHex)) {
throw new Error(`Invalid Tempo transaction hex: expected a 0x76 TIP-20 transaction`);
}

const txBuilder = this.getTransactionBuilder();
txBuilder.from(txPrebuild.txHex);
txBuilder.from(txHex);
const tx = (await txBuilder.build()) as Tip20Transaction;
const operations = tx.getOperations();

Expand Down