Skip to content

Commit d4ea4b2

Browse files
committed
feat: add customTx transactionType support for sol
- since we want to support custom instructions for sol, added customTx as a default transactionType if no other instruction combination matches. Ticket: TMS-1338
1 parent 2d836c5 commit d4ea4b2

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ export type ValidInstructionTypes =
187187
| 'TokenTransfer'
188188
| 'SetPriorityFee'
189189
| 'MintTo'
190-
| 'Burn';
190+
| 'Burn'
191+
| 'CustomInstruction';
191192

192193
export type StakingAuthorizeParams = {
193194
stakingAddress: string;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export class Transaction extends BaseTransaction {
239239
this.setTransactionType(TransactionType.CustomTx);
240240
break;
241241
}
242-
if (transactionType !== TransactionType.StakingAuthorizeRaw) {
242+
if (transactionType !== TransactionType.StakingAuthorizeRaw && transactionType !== TransactionType.CustomTx) {
243243
this.loadInputsAndOutputs();
244244
}
245245
} catch (e) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ export class TransactionBuilderFactory extends BaseTransactionBuilderFactory {
5959
return this.getStakingDelegateBuilder(tx);
6060
case TransactionType.CloseAssociatedTokenAccount:
6161
return this.getCloseAtaInitializationBuilder(tx);
62+
case TransactionType.CustomTx:
63+
return this.getCustomInstructionBuilder(tx);
6264
default:
6365
throw new InvalidTransactionError('Invalid transaction');
6466
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ export function getTransactionType(transaction: SolTransaction): TransactionType
346346
} else if (matchTransactionTypeByInstructionsOrder(instructions, ataCloseInstructionIndexes)) {
347347
return TransactionType.CloseAssociatedTokenAccount;
348348
} else {
349-
throw new NotSupported('Invalid transaction, transaction not supported or invalid');
349+
return TransactionType.CustomTx;
350350
}
351351
}
352352

@@ -433,9 +433,7 @@ export function getInstructionType(instruction: TransactionInstruction): ValidIn
433433
case COMPUTE_BUDGET:
434434
return 'SetPriorityFee';
435435
default:
436-
throw new NotSupported(
437-
'Invalid transaction, instruction program id not supported: ' + instruction.programId.toString()
438-
);
436+
return 'CustomInstruction';
439437
}
440438
}
441439

0 commit comments

Comments
 (0)