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
18 changes: 13 additions & 5 deletions modules/sdk-coin-sol/src/lib/v1CustomInstructionBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@ import { V1TransactionBuilder } from './v1TransactionBuilder';
/**
* Transaction builder for Solana v1 (SIMD-0296/0385) custom instructions.
*
* Concrete subclass of the abstract {@link V1TransactionBuilder} for `customTx`
* intents — the surface Wallet Platform instantiates to assemble v1 transactions
* from a client-supplied envelope: feed each envelope instruction as a web3.js
* `TransactionInstruction` via {@link V1TransactionBuilder.addInstruction}, set the
* fee payer via {@link V1TransactionBuilder.sender}, optional durable nonce via
* Concrete subclass of the abstract {@link V1TransactionBuilder} for locally-built
* `customTx` transactions: feed each instruction as a web3.js `TransactionInstruction`
* via {@link V1TransactionBuilder.addInstruction}, set the fee payer via
* {@link V1TransactionBuilder.sender}, optional durable nonce via
* {@link V1TransactionBuilder.nonce}, and the v1 config via
* {@link V1TransactionBuilder.transactionConfig}. The builder owns the
* `AdvanceNonceAccount` injection, the message compile, and the message-signer-order
* signature assembly.
*
* @remarks NOT reachable through Wallet Platform. Platform-mediated sends reject
* client-supplied v1 envelopes fail-closed (`solVersionedTransactionData.version === 1`
* → 400 "v1 customTx envelopes are not supported"), and the platform never built a v1
* customTx wire: even before that rejection the route validated the envelope and threw
* "v1 transaction build/submit not yet supported". For platform sends, put `version: 1`
* on a structured payment / confidentialTransfer intent — the platform builds v1
* server-side via {@link V1PaymentBuilder} / `ConfidentialTransferBuilder`. This builder
* is only for direct-SDK callers that sign and broadcast themselves.
*/
export class V1CustomInstructionBuilder extends V1TransactionBuilder {
constructor(_coinConfig: Readonly<CoinConfig>) {
Expand Down
6 changes: 6 additions & 0 deletions modules/sdk-coin-sol/src/sol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2255,5 +2255,11 @@ export class Sol extends BaseCoin {
if (params.solVersionedTransactionData) {
intent.solVersionedTransactionData = params.solVersionedTransactionData;
}

// Wire-version marker for structured intents (SIMD-0296/0385). Wallet Platform
// selects the v1 server-side builder when the payment intent carries version: 1.
if (params.version !== undefined) {
intent.version = params.version;
}
}
}
27 changes: 27 additions & 0 deletions modules/sdk-coin-sol/test/unit/solIntentVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as should from 'should';
import { BitGoAPI } from '@bitgo/sdk-api';
import { Tsol } from '../../src';

describe('Sol.setCoinSpecificFieldsInIntent — SIMD-0296/0385 wire version', function () {
const bitgo = new BitGoAPI({ env: 'test' });
bitgo.register('tsol', Tsol.createInstance);
const sol = bitgo.coin('tsol') as any;

it('forwards version: 1 onto the intent', function () {
const intent: any = { intentType: 'payment' };
sol.setCoinSpecificFieldsInIntent(intent, { intentType: 'payment', version: 1 } as any);
should.equal(intent.version, 1);
});

it('forwards version: 0 explicitly (v0 stays selectable)', function () {
const intent: any = { intentType: 'payment' };
sol.setCoinSpecificFieldsInIntent(intent, { intentType: 'payment', version: 0 } as any);
should.equal(intent.version, 0);
});

it('leaves the intent without a version key when the option is absent', function () {
const intent: any = { intentType: 'payment' };
sol.setCoinSpecificFieldsInIntent(intent, { intentType: 'payment' } as any);
should.equal('version' in intent, false);
});
});
9 changes: 9 additions & 0 deletions modules/sdk-core/src/bitgo/utils/tss/baseTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,11 @@ export interface PrebuildTransactionWithIntentOptions extends IntentOptionsBase
* Contains compiled instructions, Address Lookup Tables, and static account keys.
*/
solVersionedTransactionData?: SolVersionedTransactionData;
/**
* Solana wire-version marker for structured intents (SIMD-0296/0385): 1 selects the
* v1 envelope. Forwarded to the intent as `version`.
*/
version?: 0 | 1;
/**
* Custom transaction parameters for Aptos entry function calls.
* Used with the customTx intent type for Aptos smart contract interactions.
Expand Down Expand Up @@ -507,6 +512,10 @@ export interface PopulatedIntent extends PopulatedIntentBase, DefiIntentFields {
* Contains compiled instructions, Address Lookup Tables, and static account keys.
*/
solVersionedTransactionData?: SolVersionedTransactionData;
/**
* Solana wire-version marker for structured intents (SIMD-0296/0385): 1 = v1 envelope.
*/
version?: 0 | 1;
/**
* Custom Aptos transaction for use with the customTx intent type.
*/
Expand Down
6 changes: 6 additions & 0 deletions modules/sdk-core/src/bitgo/wallet/iWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ export interface PrebuildTransactionOptions {
* This feature is supported only for specific coins, like ADA.
*/
senderAddress?: string;
/**
* Solana wire-version marker for structured intents (SIMD-0296/0385): 1 builds the
* v1 envelope server-side, 0/absent keeps the v0 path. Forwarded to the intent as
* `version`; only the SOL coin consumes it.
*/
version?: 0 | 1;

/**
* User IDs of the Video ID approvers selected for this withdrawal. Each must be in the enterprise's
Expand Down
2 changes: 2 additions & 0 deletions modules/sdk-core/src/bitgo/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4540,6 +4540,8 @@ export class Wallet implements IWallet {
feeOptions,
feeToken: params.feeToken,
custodianTransactionId: params.custodianTransactionId,
// SIMD-0296/0385 wire version for structured intents (SOL only).
version: params.version,
unspents: params.unspents,
senderAddress: params.senderAddress,
isTestTransaction: params.isTestTransaction,
Expand Down
Loading