Skip to content

Commit c437137

Browse files
authored
Merge pull request #6719 from BitGo/harit/jito-raw-parse-fix
fix(sdk-coin-sol): set correct jito activate instruction indexes
2 parents a2eac5d + 3e113c0 commit c437137

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const marinadeStakingActivateInstructionsIndexes = {
115115

116116
/** Const to check the order of the Jito Staking Activate instructions when decode */
117117
export const jitoStakingActivateInstructionsIndexes = {
118-
AtaInit: 0,
118+
InitializeAssociatedTokenAccount: 0,
119119
DepositSol: 1,
120120
} as const;
121121

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,11 @@ export function matchTransactionTypeByInstructionsOrder(
282282

283283
// Check instructions by order using the index.
284284
for (const keyName of instructionsKeys) {
285-
const result = getInstructionType(instructionsCopy[instructionIndexes[keyName]]);
285+
const index = instructionIndexes[keyName];
286+
if (index >= instructionsCopy.length) {
287+
return false;
288+
}
289+
const result = getInstructionType(instructionsCopy[index]);
286290
if (result !== keyName) {
287291
return false;
288292
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,9 @@ describe('Sol Staking Activate Builder', () => {
156156
const rawTx = tx.toBroadcastFormat();
157157
should.equal(Utils.isValidRawTransaction(rawTx), true);
158158
should.equal(rawTx, testData.JITO_STAKING_ACTIVATE_SIGNED_TX);
159-
factory.from(testData.JITO_STAKING_ACTIVATE_SIGNED_TX);
160-
const coin = coins.get('tsol');
161-
const tx2 = new Transaction(coin);
162-
tx2.fromRawTransaction(rawTx);
159+
const builderFromRawTx = factory.from(rawTx);
160+
const rebuiltTx = await builderFromRawTx.build();
161+
rebuiltTx.toJson().instructionsData.should.deepEqual(txJson.instructionsData);
163162
});
164163

165164
it('build a create and delegate staking signed tx with memo', async () => {

0 commit comments

Comments
 (0)