Skip to content

Commit 59eb3fd

Browse files
committed
feat(sdk-coin-sol): add Solana v1 CT transaction support
express typedRoutes: accept SolV1TransactionConfig on the send, consolidate, accelerate, and enable-tokens routes (+ unit test). sdk-core: expose SolV1TransactionConfig types and wallet interface fields for the Solana v1 CT transaction path. Purely additive -- no manifest deps. Refs: CHALO-1602
1 parent 5b093c6 commit 59eb3fd

9 files changed

Lines changed: 125 additions & 1 deletion

File tree

‎modules/express/src/typedRoutes/api/v2/consolidateAccount.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ export const ConsolidateAccountRequestBody = {
195195
numReadonlyUnsignedAccounts: t.number,
196196
}),
197197
recentBlockhash: t.string,
198+
version: t.union([t.literal(0), t.literal(1)]),
199+
transactionConfig: t.partial({
200+
computeUnitLimit: t.union([t.number, t.null]),
201+
heapSize: t.union([t.number, t.null]),
202+
loadedAccountsDataSizeLimit: t.union([t.number, t.null]),
203+
priorityFee: t.union([t.number, t.null]),
204+
}),
198205
})
199206
),
200207
/** Aptos custom transaction parameters for entry function calls */

‎modules/express/src/typedRoutes/api/v2/prebuildAndSignTransaction.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,19 @@ export const SolVersionedTransactionData = t.partial({
164164
messageHeader: SolMessageHeader,
165165
/** Recent blockhash */
166166
recentBlockhash: t.string,
167+
/** Transaction version. Absent or 0 = v0 (existing), 1 = v1 */
168+
version: t.union([t.literal(0), t.literal(1)]),
169+
/** V1 transaction config. Required when version === 1 */
170+
transactionConfig: t.partial({
171+
/** Compute unit limit, or null if unset */
172+
computeUnitLimit: t.union([t.number, t.null]),
173+
/** Requested heap size, or null if unset */
174+
heapSize: t.union([t.number, t.null]),
175+
/** Loaded accounts data size limit, or null if unset */
176+
loadedAccountsDataSizeLimit: t.union([t.number, t.null]),
177+
/** Priority fee in total lamports, or null if unset */
178+
priorityFee: t.union([t.number, t.null]),
179+
}),
167180
});
168181

169182
/**

‎modules/express/src/typedRoutes/api/v2/sendCoins.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,13 @@ export const SendCoinsRequestBody = {
318318
numReadonlyUnsignedAccounts: t.number,
319319
}),
320320
recentBlockhash: t.string,
321+
version: t.union([t.literal(0), t.literal(1)]),
322+
transactionConfig: t.partial({
323+
computeUnitLimit: t.union([t.number, t.null]),
324+
heapSize: t.union([t.number, t.null]),
325+
loadedAccountsDataSizeLimit: t.union([t.number, t.null]),
326+
priorityFee: t.union([t.number, t.null]),
327+
}),
321328
})
322329
),
323330

‎modules/express/src/typedRoutes/api/v2/sendmany.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,13 @@ export const SendManyRequestBody = {
418418
numReadonlyUnsignedAccounts: t.number,
419419
}),
420420
recentBlockhash: t.string,
421+
version: t.union([t.literal(0), t.literal(1)]),
422+
transactionConfig: t.partial({
423+
computeUnitLimit: t.union([t.number, t.null]),
424+
heapSize: t.union([t.number, t.null]),
425+
loadedAccountsDataSizeLimit: t.union([t.number, t.null]),
426+
priorityFee: t.union([t.number, t.null]),
427+
}),
421428
})
422429
),
423430

‎modules/express/src/typedRoutes/api/v2/walletAccelerateTx.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,13 @@ export const AccelerateTxRequestBody = {
340340
numReadonlyUnsignedAccounts: t.number,
341341
}),
342342
recentBlockhash: t.string,
343+
version: t.union([t.literal(0), t.literal(1)]),
344+
transactionConfig: t.partial({
345+
computeUnitLimit: t.union([t.number, t.null]),
346+
heapSize: t.union([t.number, t.null]),
347+
loadedAccountsDataSizeLimit: t.union([t.number, t.null]),
348+
priorityFee: t.union([t.number, t.null]),
349+
}),
343350
})
344351
),
345352

‎modules/express/src/typedRoutes/api/v2/walletEnableTokens.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,13 @@ export const EnableTokensRequestBody = {
284284
numReadonlyUnsignedAccounts: t.number,
285285
}),
286286
recentBlockhash: t.string,
287+
version: t.union([t.literal(0), t.literal(1)]),
288+
transactionConfig: t.partial({
289+
computeUnitLimit: t.union([t.number, t.null]),
290+
heapSize: t.union([t.number, t.null]),
291+
loadedAccountsDataSizeLimit: t.union([t.number, t.null]),
292+
priorityFee: t.union([t.number, t.null]),
293+
}),
287294
})
288295
),
289296

‎modules/express/test/unit/typedRoutes/prebuildAndSignTransaction.ts‎

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import * as assert from 'assert';
22
import * as t from 'io-ts';
33
import { TransactionRequest as TxRequestResponse } from '@bitgo/public-types';
4-
import { PrebuildAndSignTransactionParams } from '../../../src/typedRoutes/api/v2/prebuildAndSignTransaction';
4+
import {
5+
PrebuildAndSignTransactionParams,
6+
SolVersionedTransactionData,
7+
} from '../../../src/typedRoutes/api/v2/prebuildAndSignTransaction';
58
import {
69
FullySignedTransactionResponse,
710
HalfSignedAccountTransactionResponse,
@@ -734,6 +737,59 @@ describe('PrebuildAndSignTransaction codec tests', function () {
734737
});
735738
});
736739

740+
describe('SolVersionedTransactionData codec validation', function () {
741+
it('should validate v1 data with version and transactionConfig', function () {
742+
const v1Data = {
743+
versionedInstructions: [],
744+
addressLookupTables: [],
745+
staticAccountKeys: ['test'],
746+
messageHeader: { numRequiredSignatures: 1, numReadonlySignedAccounts: 0, numReadonlyUnsignedAccounts: 0 },
747+
recentBlockhash: 'test',
748+
version: 1,
749+
transactionConfig: {
750+
computeUnitLimit: 200000,
751+
heapSize: 32768,
752+
loadedAccountsDataSizeLimit: 65536,
753+
priorityFee: 5000,
754+
},
755+
};
756+
const decoded = assertDecode(SolVersionedTransactionData, v1Data);
757+
assert.deepStrictEqual(decoded.version, 1);
758+
assert.deepStrictEqual(decoded.transactionConfig, v1Data.transactionConfig);
759+
});
760+
761+
it('should validate v1 data with null config fields', function () {
762+
const v1Data = {
763+
versionedInstructions: [],
764+
addressLookupTables: [],
765+
staticAccountKeys: ['test'],
766+
messageHeader: { numRequiredSignatures: 1, numReadonlySignedAccounts: 0, numReadonlyUnsignedAccounts: 0 },
767+
recentBlockhash: 'test',
768+
version: 1,
769+
transactionConfig: {
770+
computeUnitLimit: null,
771+
heapSize: null,
772+
loadedAccountsDataSizeLimit: null,
773+
priorityFee: null,
774+
},
775+
};
776+
const decoded = assertDecode(SolVersionedTransactionData, v1Data);
777+
assert.deepStrictEqual(decoded.version, 1);
778+
});
779+
780+
it('should validate existing v0 data without version fields', function () {
781+
const v0Data = {
782+
versionedInstructions: [],
783+
addressLookupTables: [],
784+
staticAccountKeys: ['test'],
785+
messageHeader: { numRequiredSignatures: 1, numReadonlySignedAccounts: 0, numReadonlyUnsignedAccounts: 0 },
786+
recentBlockhash: 'test',
787+
};
788+
const decoded = assertDecode(SolVersionedTransactionData, v0Data);
789+
assert.strictEqual(decoded.version, undefined);
790+
});
791+
});
792+
737793
describe('Response codec validation', function () {
738794
it('should validate FullySignedTransactionResponse', function () {
739795
const validResponse = {

‎modules/sdk-core/src/bitgo/utils/tss/baseTypes.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ export interface SolAddressLookupTable {
6161
readonlyIndexes: number[];
6262
}
6363

64+
export type SolTransactionVersion = 0 | 1;
65+
66+
export interface SolV1TransactionConfig {
67+
computeUnitLimit: number | null;
68+
heapSize: number | null;
69+
loadedAccountsDataSizeLimit: number | null;
70+
priorityFee: number | null; // lamports (total)
71+
}
72+
6473
export interface SolVersionedTransactionData {
6574
versionedInstructions: SolVersionedInstruction[];
6675
addressLookupTables: SolAddressLookupTable[];
@@ -71,6 +80,8 @@ export interface SolVersionedTransactionData {
7180
numReadonlyUnsignedAccounts: number;
7281
};
7382
recentBlockhash?: string;
83+
version?: SolTransactionVersion; // absent/0 = v0 (existing), 1 = v1
84+
transactionConfig?: SolV1TransactionConfig; // required when version === 1
7485
}
7586

7687
export interface aptosCustomTransactionParams {

‎modules/sdk-core/src/bitgo/wallet/iWallet.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,15 @@ export interface PrebuildTransactionOptions {
270270
numReadonlyUnsignedAccounts: number;
271271
};
272272
recentBlockhash?: string;
273+
/** Transaction version. Absent or 0 = v0 (existing), 1 = v1 */
274+
version?: 0 | 1;
275+
/** V1 transaction config. Required when version === 1 */
276+
transactionConfig?: {
277+
computeUnitLimit: number | null;
278+
heapSize: number | null;
279+
loadedAccountsDataSizeLimit: number | null;
280+
priorityFee: number | null;
281+
};
273282
};
274283
/**
275284
* Custom transaction parameters for Aptos entry function calls.

0 commit comments

Comments
 (0)