Skip to content

Commit 09d8686

Browse files
Merge pull request #8827 from BitGo/SI-658
fix(flrp): map stake intent type to add permissionless tx
2 parents c447baf + c41e100 commit 09d8686

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

modules/sdk-coin-flrp/src/flrp.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ export class Flrp extends BaseCoin {
9292
const explainedTx = tx.explainTransaction();
9393

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

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

modules/sdk-coin-flrp/test/unit/flrp.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import { EXPORT_IN_C } from '../resources/transactionData/exportInC';
99
import { EXPORT_IN_P } from '../resources/transactionData/exportInP';
1010
import { IMPORT_IN_P } from '../resources/transactionData/importInP';
1111
import { IMPORT_IN_C } from '../resources/transactionData/importInC';
12+
import {
13+
MULTISIG_DELEGATION_FULLY_SIGNED_TX_HEX,
14+
MULTISIG_DELEGATION_PARAMS,
15+
} from '../resources/transactionData/multisigDelegationTx';
1216
import { HalfSignedAccountTransaction, TransactionType, MPCAlgorithm } from '@bitgo/sdk-core';
1317
import { secp256k1 } from '@flarenetwork/flarejs';
1418
import { FlrpContext } from '@bitgo/public-types';
@@ -958,6 +962,22 @@ describe('Flrp test cases', function () {
958962
const isVerified = await basecoin.verifyTransaction({ txParams, txPrebuild });
959963
isVerified.should.equal(true);
960964
});
965+
966+
it('should verify delegation transaction when txParams.type is the "stake" intent alias', async () => {
967+
const txPrebuild = { txHex: MULTISIG_DELEGATION_FULLY_SIGNED_TX_HEX, txInfo: {} };
968+
const txParams = {
969+
type: 'stake', // intent-type alias used by wallet-platform; must normalise to AddPermissionlessDelegator
970+
stakingOptions: {
971+
nodeID: MULTISIG_DELEGATION_PARAMS.nodeID,
972+
amount: MULTISIG_DELEGATION_PARAMS.stakeAmount,
973+
durationSeconds: MULTISIG_DELEGATION_PARAMS.duration * 24 * 60 * 60,
974+
rewardAddress: MULTISIG_DELEGATION_PARAMS.rewardAddress,
975+
},
976+
};
977+
978+
const isVerified = await basecoin.verifyTransaction({ txParams, txPrebuild });
979+
isVerified.should.equal(true);
980+
});
961981
});
962982

963983
describe('verifyTransaction with TSS wallet (Avalanche atomic)', () => {

0 commit comments

Comments
 (0)