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
5 changes: 4 additions & 1 deletion modules/sdk-coin-flrp/src/flrp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@ export class Flrp extends BaseCoin {
const explainedTx = tx.explainTransaction();

const type = params.txParams.type;
// 'stake' is the intent-type alias for AddPermissionlessDelegator; normalize it
// so the TransactionType enum lookup succeeds.
const normalizedType = type === 'stake' ? 'AddPermissionlessDelegator' : type;

if (!type || (type !== 'ImportToC' && explainedTx.type !== TransactionType[type])) {
if (!normalizedType || (normalizedType !== 'ImportToC' && explainedTx.type !== TransactionType[normalizedType])) {
throw new Error('Tx type does not match with expected txParams type');
}

Expand Down
20 changes: 20 additions & 0 deletions modules/sdk-coin-flrp/test/unit/flrp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { EXPORT_IN_C } from '../resources/transactionData/exportInC';
import { EXPORT_IN_P } from '../resources/transactionData/exportInP';
import { IMPORT_IN_P } from '../resources/transactionData/importInP';
import { IMPORT_IN_C } from '../resources/transactionData/importInC';
import {
MULTISIG_DELEGATION_FULLY_SIGNED_TX_HEX,
MULTISIG_DELEGATION_PARAMS,
} from '../resources/transactionData/multisigDelegationTx';
import { HalfSignedAccountTransaction, TransactionType, MPCAlgorithm } from '@bitgo/sdk-core';
import { secp256k1 } from '@flarenetwork/flarejs';
import { FlrpContext } from '@bitgo/public-types';
Expand Down Expand Up @@ -958,6 +962,22 @@ describe('Flrp test cases', function () {
const isVerified = await basecoin.verifyTransaction({ txParams, txPrebuild });
isVerified.should.equal(true);
});

it('should verify delegation transaction when txParams.type is the "stake" intent alias', async () => {
const txPrebuild = { txHex: MULTISIG_DELEGATION_FULLY_SIGNED_TX_HEX, txInfo: {} };
const txParams = {
type: 'stake', // intent-type alias used by wallet-platform; must normalise to AddPermissionlessDelegator
stakingOptions: {
nodeID: MULTISIG_DELEGATION_PARAMS.nodeID,
amount: MULTISIG_DELEGATION_PARAMS.stakeAmount,
durationSeconds: MULTISIG_DELEGATION_PARAMS.duration * 24 * 60 * 60,
rewardAddress: MULTISIG_DELEGATION_PARAMS.rewardAddress,
},
};

const isVerified = await basecoin.verifyTransaction({ txParams, txPrebuild });
isVerified.should.equal(true);
});
});

describe('verifyTransaction with TSS wallet (Avalanche atomic)', () => {
Expand Down
Loading