@bitgo/wasm-solana 1.4.2 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/js/index.d.ts +4 -2
- package/dist/cjs/js/index.js +3 -1
- package/dist/cjs/js/intentBuilder.d.ts +197 -0
- package/dist/cjs/js/intentBuilder.js +70 -0
- package/dist/cjs/js/keypair.d.ts +5 -0
- package/dist/cjs/js/keypair.js +8 -0
- package/dist/cjs/js/transaction.d.ts +19 -0
- package/dist/cjs/js/transaction.js +23 -0
- package/dist/cjs/js/versioned.d.ts +12 -0
- package/dist/cjs/js/versioned.js +16 -0
- package/dist/cjs/js/wasm/wasm_solana.d.ts +60 -0
- package/dist/cjs/js/wasm/wasm_solana.js +176 -0
- package/dist/cjs/js/wasm/wasm_solana_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_solana_bg.wasm.d.ts +28 -23
- package/dist/esm/js/index.d.ts +4 -2
- package/dist/esm/js/index.js +1 -0
- package/dist/esm/js/intentBuilder.d.ts +197 -0
- package/dist/esm/js/intentBuilder.js +67 -0
- package/dist/esm/js/keypair.d.ts +5 -0
- package/dist/esm/js/keypair.js +8 -0
- package/dist/esm/js/transaction.d.ts +19 -0
- package/dist/esm/js/transaction.js +23 -0
- package/dist/esm/js/versioned.d.ts +12 -0
- package/dist/esm/js/versioned.js +16 -0
- package/dist/esm/js/wasm/wasm_solana.d.ts +60 -0
- package/dist/esm/js/wasm/wasm_solana_bg.js +175 -0
- package/dist/esm/js/wasm/wasm_solana_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_solana_bg.wasm.d.ts +28 -23
- package/package.json +1 -1
|
@@ -334,6 +334,10 @@ const InstructionsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
334
334
|
? { register: () => {}, unregister: () => {} }
|
|
335
335
|
: new FinalizationRegistry(ptr => wasm.__wbg_instructions_free(ptr >>> 0, 1));
|
|
336
336
|
|
|
337
|
+
const IntentNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
338
|
+
? { register: () => {}, unregister: () => {} }
|
|
339
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_intentnamespace_free(ptr >>> 0, 1));
|
|
340
|
+
|
|
337
341
|
const KeypairFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
338
342
|
? { register: () => {}, unregister: () => {} }
|
|
339
343
|
: new FinalizationRegistry(ptr => wasm.__wbg_keypair_free(ptr >>> 0, 1));
|
|
@@ -2700,6 +2704,77 @@ class Instructions {
|
|
|
2700
2704
|
if (Symbol.dispose) Instructions.prototype[Symbol.dispose] = Instructions.prototype.free;
|
|
2701
2705
|
exports.Instructions = Instructions;
|
|
2702
2706
|
|
|
2707
|
+
/**
|
|
2708
|
+
* Namespace for intent-based building operations.
|
|
2709
|
+
*/
|
|
2710
|
+
class IntentNamespace {
|
|
2711
|
+
__destroy_into_raw() {
|
|
2712
|
+
const ptr = this.__wbg_ptr;
|
|
2713
|
+
this.__wbg_ptr = 0;
|
|
2714
|
+
IntentNamespaceFinalization.unregister(this);
|
|
2715
|
+
return ptr;
|
|
2716
|
+
}
|
|
2717
|
+
free() {
|
|
2718
|
+
const ptr = this.__destroy_into_raw();
|
|
2719
|
+
wasm.__wbg_intentnamespace_free(ptr, 0);
|
|
2720
|
+
}
|
|
2721
|
+
/**
|
|
2722
|
+
* Build a transaction directly from a BitGo intent.
|
|
2723
|
+
*
|
|
2724
|
+
* This function takes the full intent as-is and builds the transaction
|
|
2725
|
+
* without requiring the caller to construct instructions.
|
|
2726
|
+
*
|
|
2727
|
+
* # Arguments
|
|
2728
|
+
*
|
|
2729
|
+
* * `intent` - The full BitGo intent object (with intentType, etc.)
|
|
2730
|
+
* * `params` - Build parameters: { feePayer, nonce }
|
|
2731
|
+
*
|
|
2732
|
+
* # Returns
|
|
2733
|
+
*
|
|
2734
|
+
* An object with:
|
|
2735
|
+
* * `transaction` - WasmTransaction object
|
|
2736
|
+
* * `generatedKeypairs` - Array of keypairs generated (for stake accounts, etc.)
|
|
2737
|
+
*
|
|
2738
|
+
* # Example
|
|
2739
|
+
*
|
|
2740
|
+
* ```javascript
|
|
2741
|
+
* const result = IntentNamespace.build_from_intent(
|
|
2742
|
+
* {
|
|
2743
|
+
* intentType: 'stake',
|
|
2744
|
+
* validatorAddress: '...',
|
|
2745
|
+
* amount: { value: 1000000000n }
|
|
2746
|
+
* },
|
|
2747
|
+
* {
|
|
2748
|
+
* feePayer: 'DgT9...',
|
|
2749
|
+
* nonce: { type: 'blockhash', value: 'GWaQ...' }
|
|
2750
|
+
* }
|
|
2751
|
+
* );
|
|
2752
|
+
* // result.transaction - WasmTransaction object
|
|
2753
|
+
* // result.generatedKeypairs - [{ purpose, address, secretKey }]
|
|
2754
|
+
* ```
|
|
2755
|
+
* @param {any} intent
|
|
2756
|
+
* @param {any} params
|
|
2757
|
+
* @returns {any}
|
|
2758
|
+
*/
|
|
2759
|
+
static build_from_intent(intent, params) {
|
|
2760
|
+
try {
|
|
2761
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2762
|
+
wasm.intentnamespace_build_from_intent(retptr, addHeapObject(intent), addHeapObject(params));
|
|
2763
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2764
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2765
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2766
|
+
if (r2) {
|
|
2767
|
+
throw takeObject(r1);
|
|
2768
|
+
}
|
|
2769
|
+
return takeObject(r0);
|
|
2770
|
+
} finally {
|
|
2771
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
if (Symbol.dispose) IntentNamespace.prototype[Symbol.dispose] = IntentNamespace.prototype.free;
|
|
2776
|
+
exports.IntentNamespace = IntentNamespace;
|
|
2777
|
+
|
|
2703
2778
|
/**
|
|
2704
2779
|
* A vanilla Ed25519 key pair
|
|
2705
2780
|
*/
|
|
@@ -4640,6 +4715,14 @@ class WasmKeypair {
|
|
|
4640
4715
|
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
4641
4716
|
}
|
|
4642
4717
|
}
|
|
4718
|
+
/**
|
|
4719
|
+
* Generate a new random keypair.
|
|
4720
|
+
* @returns {WasmKeypair}
|
|
4721
|
+
*/
|
|
4722
|
+
static generate() {
|
|
4723
|
+
const ret = wasm.wasmkeypair_generate();
|
|
4724
|
+
return WasmKeypair.__wrap(ret);
|
|
4725
|
+
}
|
|
4643
4726
|
/**
|
|
4644
4727
|
* Get the public key as a base58 string.
|
|
4645
4728
|
* @returns {string}
|
|
@@ -4942,6 +5025,29 @@ class WasmTransaction {
|
|
|
4942
5025
|
const ret = wasm.wasmtransaction_signable_payload(this.__wbg_ptr);
|
|
4943
5026
|
return takeObject(ret);
|
|
4944
5027
|
}
|
|
5028
|
+
/**
|
|
5029
|
+
* Get the transaction ID (first signature as base58).
|
|
5030
|
+
*
|
|
5031
|
+
* For Solana, the transaction ID is the first signature.
|
|
5032
|
+
* Returns "UNSIGNED" if the first signature is all zeros (unsigned transaction).
|
|
5033
|
+
* @returns {string}
|
|
5034
|
+
*/
|
|
5035
|
+
get id() {
|
|
5036
|
+
let deferred1_0;
|
|
5037
|
+
let deferred1_1;
|
|
5038
|
+
try {
|
|
5039
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
5040
|
+
wasm.wasmtransaction_id(retptr, this.__wbg_ptr);
|
|
5041
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
5042
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
5043
|
+
deferred1_0 = r0;
|
|
5044
|
+
deferred1_1 = r1;
|
|
5045
|
+
return getStringFromWasm0(r0, r1);
|
|
5046
|
+
} finally {
|
|
5047
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
5048
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
5049
|
+
}
|
|
5050
|
+
}
|
|
4945
5051
|
/**
|
|
4946
5052
|
* Serialize the transaction to bytes.
|
|
4947
5053
|
* @returns {Uint8Array}
|
|
@@ -5173,6 +5279,29 @@ class WasmVersionedTransaction {
|
|
|
5173
5279
|
const ret = wasm.wasmversionedtransaction_address_lookup_tables(this.__wbg_ptr);
|
|
5174
5280
|
return takeObject(ret);
|
|
5175
5281
|
}
|
|
5282
|
+
/**
|
|
5283
|
+
* Get the transaction ID (first signature as base58).
|
|
5284
|
+
*
|
|
5285
|
+
* For Solana, the transaction ID is the first signature.
|
|
5286
|
+
* Returns "UNSIGNED" if the first signature is all zeros (unsigned transaction).
|
|
5287
|
+
* @returns {string}
|
|
5288
|
+
*/
|
|
5289
|
+
get id() {
|
|
5290
|
+
let deferred1_0;
|
|
5291
|
+
let deferred1_1;
|
|
5292
|
+
try {
|
|
5293
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
5294
|
+
wasm.wasmversionedtransaction_id(retptr, this.__wbg_ptr);
|
|
5295
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
5296
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
5297
|
+
deferred1_0 = r0;
|
|
5298
|
+
deferred1_1 = r1;
|
|
5299
|
+
return getStringFromWasm0(r0, r1);
|
|
5300
|
+
} finally {
|
|
5301
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
5302
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
5303
|
+
}
|
|
5304
|
+
}
|
|
5176
5305
|
/**
|
|
5177
5306
|
* Serialize the transaction to bytes.
|
|
5178
5307
|
* @returns {Uint8Array}
|
|
@@ -5892,6 +6021,11 @@ exports.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (
|
|
|
5892
6021
|
return addHeapObject(ret);
|
|
5893
6022
|
}, arguments) };
|
|
5894
6023
|
|
|
6024
|
+
exports.__wbg_crypto_038798f665f985e2 = function(arg0) {
|
|
6025
|
+
const ret = getObject(arg0).crypto;
|
|
6026
|
+
return addHeapObject(ret);
|
|
6027
|
+
};
|
|
6028
|
+
|
|
5895
6029
|
exports.__wbg_crypto_86f2631e91b51511 = function(arg0) {
|
|
5896
6030
|
const ret = getObject(arg0).crypto;
|
|
5897
6031
|
return addHeapObject(ret);
|
|
@@ -5927,6 +6061,15 @@ exports.__wbg_error_7bc7d576a6aaf855 = function(arg0) {
|
|
|
5927
6061
|
console.error(getObject(arg0));
|
|
5928
6062
|
};
|
|
5929
6063
|
|
|
6064
|
+
exports.__wbg_getRandomValues_371e7ade8bd92088 = function(arg0, arg1) {
|
|
6065
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
|
6066
|
+
};
|
|
6067
|
+
|
|
6068
|
+
exports.__wbg_getRandomValues_7dfe5bd1b67c9ca1 = function(arg0) {
|
|
6069
|
+
const ret = getObject(arg0).getRandomValues;
|
|
6070
|
+
return addHeapObject(ret);
|
|
6071
|
+
};
|
|
6072
|
+
|
|
5930
6073
|
exports.__wbg_getRandomValues_b3f15fcbfabb0f8b = function() { return handleError(function (arg0, arg1) {
|
|
5931
6074
|
getObject(arg0).getRandomValues(getObject(arg1));
|
|
5932
6075
|
}, arguments) };
|
|
@@ -6022,6 +6165,11 @@ exports.__wbg_msCrypto_d562bbe83e0d4b91 = function(arg0) {
|
|
|
6022
6165
|
return addHeapObject(ret);
|
|
6023
6166
|
};
|
|
6024
6167
|
|
|
6168
|
+
exports.__wbg_msCrypto_ff35fce085fab2a3 = function(arg0) {
|
|
6169
|
+
const ret = getObject(arg0).msCrypto;
|
|
6170
|
+
return addHeapObject(ret);
|
|
6171
|
+
};
|
|
6172
|
+
|
|
6025
6173
|
exports.__wbg_new_1ba21ce319a06297 = function() {
|
|
6026
6174
|
const ret = new Object();
|
|
6027
6175
|
return addHeapObject(ret);
|
|
@@ -6101,15 +6249,33 @@ exports.__wbg_push_7d9be8f38fc13975 = function(arg0, arg1) {
|
|
|
6101
6249
|
return ret;
|
|
6102
6250
|
};
|
|
6103
6251
|
|
|
6252
|
+
exports.__wbg_randomFillSync_994ac6d9ade7a695 = function(arg0, arg1, arg2) {
|
|
6253
|
+
getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
|
|
6254
|
+
};
|
|
6255
|
+
|
|
6104
6256
|
exports.__wbg_randomFillSync_f8c153b79f285817 = function() { return handleError(function (arg0, arg1) {
|
|
6105
6257
|
getObject(arg0).randomFillSync(takeObject(arg1));
|
|
6106
6258
|
}, arguments) };
|
|
6107
6259
|
|
|
6260
|
+
exports.__wbg_require_0d6aeaec3c042c88 = function(arg0, arg1, arg2) {
|
|
6261
|
+
const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
|
|
6262
|
+
return addHeapObject(ret);
|
|
6263
|
+
};
|
|
6264
|
+
|
|
6108
6265
|
exports.__wbg_require_b74f47fc2d022fd6 = function() { return handleError(function () {
|
|
6109
6266
|
const ret = module.require;
|
|
6110
6267
|
return addHeapObject(ret);
|
|
6111
6268
|
}, arguments) };
|
|
6112
6269
|
|
|
6270
|
+
exports.__wbg_self_25aabeb5a7b41685 = function() { return handleError(function () {
|
|
6271
|
+
const ret = self.self;
|
|
6272
|
+
return addHeapObject(ret);
|
|
6273
|
+
}, arguments) };
|
|
6274
|
+
|
|
6275
|
+
exports.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
6276
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
6277
|
+
};
|
|
6278
|
+
|
|
6113
6279
|
exports.__wbg_set_781438a03c0c3c81 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
6114
6280
|
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
|
6115
6281
|
return ret;
|
|
@@ -6137,6 +6303,11 @@ exports.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
|
|
|
6137
6303
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
6138
6304
|
};
|
|
6139
6305
|
|
|
6306
|
+
exports.__wbg_static_accessor_MODULE_ef3aa2eb251158a5 = function() {
|
|
6307
|
+
const ret = module;
|
|
6308
|
+
return addHeapObject(ret);
|
|
6309
|
+
};
|
|
6310
|
+
|
|
6140
6311
|
exports.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
|
|
6141
6312
|
const ret = typeof self === 'undefined' ? null : self;
|
|
6142
6313
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
@@ -6171,6 +6342,11 @@ exports.__wbg_warn_6e567d0d926ff881 = function(arg0) {
|
|
|
6171
6342
|
console.warn(getObject(arg0));
|
|
6172
6343
|
};
|
|
6173
6344
|
|
|
6345
|
+
exports.__wbg_wasmtransaction_new = function(arg0) {
|
|
6346
|
+
const ret = WasmTransaction.__wrap(arg0);
|
|
6347
|
+
return addHeapObject(ret);
|
|
6348
|
+
};
|
|
6349
|
+
|
|
6174
6350
|
exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
6175
6351
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
6176
6352
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
Binary file
|
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const
|
|
5
|
-
export const compute_budget_program_id: (a: number) => void;
|
|
6
|
-
export const find_withdraw_authority_program_address: (a: number, b: number, c: number) => void;
|
|
7
|
-
export const get_associated_token_address: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
8
|
-
export const memo_program_id: (a: number) => void;
|
|
9
|
-
export const nonce_account_space: () => bigint;
|
|
10
|
-
export const stake_account_space: () => bigint;
|
|
11
|
-
export const stake_pool_program_id: (a: number) => void;
|
|
12
|
-
export const stake_program_id: (a: number) => void;
|
|
13
|
-
export const system_program_id: (a: number) => void;
|
|
14
|
-
export const sysvar_recent_blockhashes: (a: number) => void;
|
|
15
|
-
export const token_2022_program_id: (a: number) => void;
|
|
16
|
-
export const token_program_id: (a: number) => void;
|
|
4
|
+
export const __wbg_buildernamespace_free: (a: number, b: number) => void;
|
|
17
5
|
export const __wbg_wasmkeypair_free: (a: number, b: number) => void;
|
|
18
|
-
export const
|
|
19
|
-
export const
|
|
20
|
-
export const __wbg_wasmversionedtransaction_free: (a: number, b: number) => void;
|
|
21
|
-
export const is_versioned_transaction: (a: number, b: number) => number;
|
|
6
|
+
export const buildernamespace_build_from_versioned_data: (a: number, b: number) => void;
|
|
7
|
+
export const buildernamespace_build_transaction: (a: number, b: number) => void;
|
|
22
8
|
export const wasmkeypair_address: (a: number, b: number) => void;
|
|
23
9
|
export const wasmkeypair_from_secret_key: (a: number, b: number, c: number) => void;
|
|
24
10
|
export const wasmkeypair_from_solana_secret_key: (a: number, b: number, c: number) => void;
|
|
11
|
+
export const wasmkeypair_generate: () => number;
|
|
25
12
|
export const wasmkeypair_public_key: (a: number) => number;
|
|
26
13
|
export const wasmkeypair_secret_key: (a: number) => number;
|
|
14
|
+
export const wasmkeypair_to_base58: (a: number, b: number) => void;
|
|
15
|
+
export const __wbg_intentnamespace_free: (a: number, b: number) => void;
|
|
16
|
+
export const __wbg_parsernamespace_free: (a: number, b: number) => void;
|
|
17
|
+
export const __wbg_wasmpubkey_free: (a: number, b: number) => void;
|
|
18
|
+
export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
|
|
19
|
+
export const __wbg_wasmversionedtransaction_free: (a: number, b: number) => void;
|
|
20
|
+
export const intentnamespace_build_from_intent: (a: number, b: number, c: number) => void;
|
|
21
|
+
export const is_versioned_transaction: (a: number, b: number) => number;
|
|
22
|
+
export const parsernamespace_parse_transaction: (a: number, b: number, c: number) => void;
|
|
27
23
|
export const wasmpubkey_equals: (a: number, b: number) => number;
|
|
28
24
|
export const wasmpubkey_from_base58: (a: number, b: number, c: number) => void;
|
|
29
25
|
export const wasmpubkey_from_bytes: (a: number, b: number, c: number) => void;
|
|
@@ -34,6 +30,7 @@ export const wasmtransaction_account_keys: (a: number) => number;
|
|
|
34
30
|
export const wasmtransaction_add_signature: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
35
31
|
export const wasmtransaction_fee_payer: (a: number, b: number) => void;
|
|
36
32
|
export const wasmtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
33
|
+
export const wasmtransaction_id: (a: number, b: number) => void;
|
|
37
34
|
export const wasmtransaction_instructions: (a: number) => number;
|
|
38
35
|
export const wasmtransaction_num_instructions: (a: number) => number;
|
|
39
36
|
export const wasmtransaction_num_signatures: (a: number) => number;
|
|
@@ -46,6 +43,7 @@ export const wasmversionedtransaction_add_signature: (a: number, b: number, c: n
|
|
|
46
43
|
export const wasmversionedtransaction_address_lookup_tables: (a: number) => number;
|
|
47
44
|
export const wasmversionedtransaction_fee_payer: (a: number, b: number) => void;
|
|
48
45
|
export const wasmversionedtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
46
|
+
export const wasmversionedtransaction_id: (a: number, b: number) => void;
|
|
49
47
|
export const wasmversionedtransaction_instructions: (a: number) => number;
|
|
50
48
|
export const wasmversionedtransaction_is_versioned: (a: number) => number;
|
|
51
49
|
export const wasmversionedtransaction_num_instructions: (a: number) => number;
|
|
@@ -55,13 +53,20 @@ export const wasmversionedtransaction_signatures: (a: number) => number;
|
|
|
55
53
|
export const wasmversionedtransaction_signer_index: (a: number, b: number, c: number) => number;
|
|
56
54
|
export const wasmversionedtransaction_static_account_keys: (a: number) => number;
|
|
57
55
|
export const wasmversionedtransaction_to_bytes: (a: number, b: number) => void;
|
|
58
|
-
export const wasmkeypair_to_base58: (a: number, b: number) => void;
|
|
59
56
|
export const wasmversionedtransaction_num_signatures: (a: number) => number;
|
|
60
|
-
export const
|
|
61
|
-
export const
|
|
62
|
-
export const
|
|
63
|
-
export const
|
|
64
|
-
export const
|
|
57
|
+
export const ata_program_id: (a: number) => void;
|
|
58
|
+
export const compute_budget_program_id: (a: number) => void;
|
|
59
|
+
export const find_withdraw_authority_program_address: (a: number, b: number, c: number) => void;
|
|
60
|
+
export const get_associated_token_address: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
61
|
+
export const memo_program_id: (a: number) => void;
|
|
62
|
+
export const nonce_account_space: () => bigint;
|
|
63
|
+
export const stake_account_space: () => bigint;
|
|
64
|
+
export const stake_pool_program_id: (a: number) => void;
|
|
65
|
+
export const stake_program_id: (a: number) => void;
|
|
66
|
+
export const system_program_id: (a: number) => void;
|
|
67
|
+
export const sysvar_recent_blockhashes: (a: number) => void;
|
|
68
|
+
export const token_2022_program_id: (a: number) => void;
|
|
69
|
+
export const token_program_id: (a: number) => void;
|
|
65
70
|
export const __wbg_keypair_free: (a: number, b: number) => void;
|
|
66
71
|
export const keypair_constructor: () => number;
|
|
67
72
|
export const keypair_fromBytes: (a: number, b: number, c: number) => void;
|
package/dist/esm/js/index.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ export { VersionedTransaction, isVersionedTransaction } from "./versioned.js";
|
|
|
10
10
|
export type { AddressLookupTableData } from "./versioned.js";
|
|
11
11
|
export { parseTransaction } from "./parser.js";
|
|
12
12
|
export { buildTransaction, buildFromVersionedData } from "./builder.js";
|
|
13
|
+
export { buildFromIntent } from "./intentBuilder.js";
|
|
14
|
+
export type { BaseIntent, PaymentIntent, StakeIntent, UnstakeIntent, ClaimIntent, DeactivateIntent, DelegateIntent, EnableTokenIntent, CloseAtaIntent, ConsolidateIntent, SolanaIntent, StakePoolConfig, BuildFromIntentParams, BuildFromIntentResult, GeneratedKeypair, NonceSource, BlockhashNonce, DurableNonce, } from "./intentBuilder.js";
|
|
13
15
|
export { system_program_id as systemProgramId, stake_program_id as stakeProgramId, compute_budget_program_id as computeBudgetProgramId, memo_program_id as memoProgramId, token_program_id as tokenProgramId, token_2022_program_id as token2022ProgramId, ata_program_id as ataProgramId, stake_pool_program_id as stakePoolProgramId, stake_account_space as stakeAccountSpace, nonce_account_space as nonceAccountSpace, sysvar_recent_blockhashes as sysvarRecentBlockhashes, get_associated_token_address as getAssociatedTokenAddress, find_withdraw_authority_program_address as findWithdrawAuthorityProgramAddress, } from "./wasm/wasm_solana.js";
|
|
14
16
|
export type { AccountMeta, Instruction } from "./transaction.js";
|
|
15
|
-
export type { TransactionInput, ParsedTransaction, DurableNonce, InstructionParams, TransferParams, CreateAccountParams, NonceAdvanceParams, CreateNonceAccountParams, NonceInitializeParams, StakeInitializeParams, StakingActivateParams, StakingDeactivateParams, StakingWithdrawParams, StakingDelegateParams, StakingAuthorizeParams, SetComputeUnitLimitParams, SetPriorityFeeParams, TokenTransferParams, CreateAtaParams, CloseAtaParams, MemoParams, StakePoolDepositSolParams, StakePoolWithdrawStakeParams, UnknownInstructionParams, } from "./parser.js";
|
|
16
|
-
export type { TransactionIntent, NonceSource, BlockhashNonceSource, DurableNonceSource, AddressLookupTable as BuilderAddressLookupTable, Instruction as BuilderInstruction, TransferInstruction, CreateAccountInstruction, NonceAdvanceInstruction, NonceInitializeInstruction, AllocateInstruction, AssignInstruction, MemoInstruction, ComputeBudgetInstruction, StakeInitializeInstruction, StakeDelegateInstruction, StakeDeactivateInstruction, StakeWithdrawInstruction, StakeAuthorizeInstruction, StakeSplitInstruction, TokenTransferInstruction, CreateAssociatedTokenAccountInstruction, CloseAssociatedTokenAccountInstruction, MintToInstruction, BurnInstruction, ApproveInstruction, StakePoolDepositSolInstruction, StakePoolWithdrawStakeInstruction, CustomInstruction as BuilderCustomInstruction, CustomAccountMeta, RawVersionedTransactionData, VersionedInstruction as BuilderVersionedInstruction, MessageHeader, } from "./builder.js";
|
|
17
|
+
export type { TransactionInput, ParsedTransaction, DurableNonce as ParsedDurableNonce, InstructionParams, TransferParams, CreateAccountParams, NonceAdvanceParams, CreateNonceAccountParams, NonceInitializeParams, StakeInitializeParams, StakingActivateParams, StakingDeactivateParams, StakingWithdrawParams, StakingDelegateParams, StakingAuthorizeParams, SetComputeUnitLimitParams, SetPriorityFeeParams, TokenTransferParams, CreateAtaParams, CloseAtaParams, MemoParams, StakePoolDepositSolParams, StakePoolWithdrawStakeParams, UnknownInstructionParams, } from "./parser.js";
|
|
18
|
+
export type { TransactionIntent, NonceSource as BuilderNonceSource, BlockhashNonceSource, DurableNonceSource, AddressLookupTable as BuilderAddressLookupTable, Instruction as BuilderInstruction, TransferInstruction, CreateAccountInstruction, NonceAdvanceInstruction, NonceInitializeInstruction, AllocateInstruction, AssignInstruction, MemoInstruction, ComputeBudgetInstruction, StakeInitializeInstruction, StakeDelegateInstruction, StakeDeactivateInstruction, StakeWithdrawInstruction, StakeAuthorizeInstruction, StakeSplitInstruction, TokenTransferInstruction, CreateAssociatedTokenAccountInstruction, CloseAssociatedTokenAccountInstruction, MintToInstruction, BurnInstruction, ApproveInstruction, StakePoolDepositSolInstruction, StakePoolWithdrawStakeInstruction, CustomInstruction as BuilderCustomInstruction, CustomAccountMeta, RawVersionedTransactionData, VersionedInstruction as BuilderVersionedInstruction, MessageHeader, } from "./builder.js";
|
package/dist/esm/js/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export { VersionedTransaction, isVersionedTransaction } from "./versioned.js";
|
|
|
16
16
|
// Top-level function exports
|
|
17
17
|
export { parseTransaction } from "./parser.js";
|
|
18
18
|
export { buildTransaction, buildFromVersionedData } from "./builder.js";
|
|
19
|
+
export { buildFromIntent } from "./intentBuilder.js";
|
|
19
20
|
// Program ID constants (from WASM)
|
|
20
21
|
export { system_program_id as systemProgramId, stake_program_id as stakeProgramId, compute_budget_program_id as computeBudgetProgramId, memo_program_id as memoProgramId, token_program_id as tokenProgramId, token_2022_program_id as token2022ProgramId, ata_program_id as ataProgramId, stake_pool_program_id as stakePoolProgramId, stake_account_space as stakeAccountSpace, nonce_account_space as nonceAccountSpace,
|
|
21
22
|
// Sysvar addresses
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level intent-based transaction building.
|
|
3
|
+
*
|
|
4
|
+
* This module provides `buildFromIntent()` which accepts BitGo intent objects
|
|
5
|
+
* directly and builds Solana transactions without requiring the caller to
|
|
6
|
+
* construct low-level instructions.
|
|
7
|
+
*
|
|
8
|
+
* The intent → transaction mapping happens entirely in Rust/WASM for simplicity.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { buildFromIntent } from '@bitgo/wasm-solana';
|
|
13
|
+
*
|
|
14
|
+
* const result = buildFromIntent(intent, {
|
|
15
|
+
* feePayer: walletRootAddress,
|
|
16
|
+
* nonce: { type: 'blockhash', value: recentBlockhash },
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // result.transaction - Transaction object
|
|
20
|
+
* // result.generatedKeypairs - any keypairs generated (e.g., stake accounts)
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import { Transaction } from "./transaction.js";
|
|
24
|
+
/** Nonce source - blockhash or durable nonce */
|
|
25
|
+
export type NonceSource = BlockhashNonce | DurableNonce;
|
|
26
|
+
export interface BlockhashNonce {
|
|
27
|
+
type: "blockhash";
|
|
28
|
+
value: string;
|
|
29
|
+
}
|
|
30
|
+
export interface DurableNonce {
|
|
31
|
+
type: "durable";
|
|
32
|
+
address: string;
|
|
33
|
+
authority: string;
|
|
34
|
+
value: string;
|
|
35
|
+
}
|
|
36
|
+
/** Parameters for building a transaction from intent */
|
|
37
|
+
export interface BuildFromIntentParams {
|
|
38
|
+
/** Fee payer address (wallet root) */
|
|
39
|
+
feePayer: string;
|
|
40
|
+
/** Nonce source - blockhash or durable nonce */
|
|
41
|
+
nonce: NonceSource;
|
|
42
|
+
}
|
|
43
|
+
/** A keypair generated during transaction building */
|
|
44
|
+
export interface GeneratedKeypair {
|
|
45
|
+
/** Purpose of this keypair */
|
|
46
|
+
purpose: "stakeAccount" | "unstakeAccount" | "transferAuthority";
|
|
47
|
+
/** Public address (base58) */
|
|
48
|
+
address: string;
|
|
49
|
+
/** Secret key (base58) */
|
|
50
|
+
secretKey: string;
|
|
51
|
+
}
|
|
52
|
+
/** Result from building a transaction from intent */
|
|
53
|
+
export interface BuildFromIntentResult {
|
|
54
|
+
/** The built transaction */
|
|
55
|
+
transaction: Transaction;
|
|
56
|
+
/** Generated keypairs (for stake accounts, etc.) */
|
|
57
|
+
generatedKeypairs: GeneratedKeypair[];
|
|
58
|
+
}
|
|
59
|
+
/** Base intent - all intents have intentType */
|
|
60
|
+
export interface BaseIntent {
|
|
61
|
+
intentType: string;
|
|
62
|
+
memo?: string;
|
|
63
|
+
}
|
|
64
|
+
/** Payment intent */
|
|
65
|
+
export interface PaymentIntent extends BaseIntent {
|
|
66
|
+
intentType: "payment";
|
|
67
|
+
recipients?: Array<{
|
|
68
|
+
address?: {
|
|
69
|
+
address: string;
|
|
70
|
+
};
|
|
71
|
+
amount?: {
|
|
72
|
+
value: bigint;
|
|
73
|
+
symbol?: string;
|
|
74
|
+
};
|
|
75
|
+
}>;
|
|
76
|
+
}
|
|
77
|
+
/** Stake intent */
|
|
78
|
+
export interface StakeIntent extends BaseIntent {
|
|
79
|
+
intentType: "stake";
|
|
80
|
+
validatorAddress: string;
|
|
81
|
+
amount?: {
|
|
82
|
+
value: bigint;
|
|
83
|
+
};
|
|
84
|
+
stakingType?: "NATIVE" | "JITO" | "MARINADE";
|
|
85
|
+
stakePoolConfig?: StakePoolConfig;
|
|
86
|
+
}
|
|
87
|
+
/** Stake pool configuration (for Jito) */
|
|
88
|
+
export interface StakePoolConfig {
|
|
89
|
+
stakePoolAddress: string;
|
|
90
|
+
withdrawAuthority: string;
|
|
91
|
+
reserveStake: string;
|
|
92
|
+
destinationPoolAccount: string;
|
|
93
|
+
managerFeeAccount: string;
|
|
94
|
+
referralPoolAccount?: string;
|
|
95
|
+
poolMint: string;
|
|
96
|
+
validatorList?: string;
|
|
97
|
+
sourcePoolAccount?: string;
|
|
98
|
+
}
|
|
99
|
+
/** Unstake intent */
|
|
100
|
+
export interface UnstakeIntent extends BaseIntent {
|
|
101
|
+
intentType: "unstake";
|
|
102
|
+
stakingAddress: string;
|
|
103
|
+
validatorAddress?: string;
|
|
104
|
+
amount?: {
|
|
105
|
+
value: bigint;
|
|
106
|
+
};
|
|
107
|
+
remainingStakingAmount?: {
|
|
108
|
+
value: bigint;
|
|
109
|
+
};
|
|
110
|
+
stakingType?: "NATIVE" | "JITO" | "MARINADE";
|
|
111
|
+
stakePoolConfig?: StakePoolConfig;
|
|
112
|
+
}
|
|
113
|
+
/** Claim intent (withdraw from deactivated stake) */
|
|
114
|
+
export interface ClaimIntent extends BaseIntent {
|
|
115
|
+
intentType: "claim";
|
|
116
|
+
stakingAddress: string;
|
|
117
|
+
amount?: {
|
|
118
|
+
value: bigint;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/** Deactivate intent */
|
|
122
|
+
export interface DeactivateIntent extends BaseIntent {
|
|
123
|
+
intentType: "deactivate";
|
|
124
|
+
stakingAddress?: string;
|
|
125
|
+
stakingAddresses?: string[];
|
|
126
|
+
}
|
|
127
|
+
/** Delegate intent */
|
|
128
|
+
export interface DelegateIntent extends BaseIntent {
|
|
129
|
+
intentType: "delegate";
|
|
130
|
+
validatorAddress: string;
|
|
131
|
+
stakingAddress?: string;
|
|
132
|
+
stakingAddresses?: string[];
|
|
133
|
+
}
|
|
134
|
+
/** Enable token intent (create ATA) */
|
|
135
|
+
export interface EnableTokenIntent extends BaseIntent {
|
|
136
|
+
intentType: "enableToken";
|
|
137
|
+
recipientAddress?: string;
|
|
138
|
+
tokenAddress?: string;
|
|
139
|
+
tokenProgramId?: string;
|
|
140
|
+
}
|
|
141
|
+
/** Close ATA intent */
|
|
142
|
+
export interface CloseAtaIntent extends BaseIntent {
|
|
143
|
+
intentType: "closeAssociatedTokenAccount";
|
|
144
|
+
tokenAccountAddress?: string;
|
|
145
|
+
tokenProgramId?: string;
|
|
146
|
+
}
|
|
147
|
+
/** Consolidate intent - transfer from child address to root */
|
|
148
|
+
export interface ConsolidateIntent extends BaseIntent {
|
|
149
|
+
intentType: "consolidate";
|
|
150
|
+
/** The child address to consolidate from (sender) */
|
|
151
|
+
receiveAddress: string;
|
|
152
|
+
/** Recipients (root address for SOL, ATAs for tokens) */
|
|
153
|
+
recipients?: Array<{
|
|
154
|
+
address?: {
|
|
155
|
+
address: string;
|
|
156
|
+
};
|
|
157
|
+
amount?: {
|
|
158
|
+
value: bigint;
|
|
159
|
+
};
|
|
160
|
+
}>;
|
|
161
|
+
}
|
|
162
|
+
/** Union of all supported intent types */
|
|
163
|
+
export type SolanaIntent = PaymentIntent | StakeIntent | UnstakeIntent | ClaimIntent | DeactivateIntent | DelegateIntent | EnableTokenIntent | CloseAtaIntent | ConsolidateIntent;
|
|
164
|
+
/**
|
|
165
|
+
* Build a Solana transaction from a BitGo intent.
|
|
166
|
+
*
|
|
167
|
+
* This function passes the intent directly to Rust/WASM which handles
|
|
168
|
+
* all the intent-to-transaction mapping internally.
|
|
169
|
+
*
|
|
170
|
+
* @param intent - The BitGo intent (with intentType, etc.)
|
|
171
|
+
* @param params - Build parameters (feePayer, nonce)
|
|
172
|
+
* @returns Transaction object and any generated keypairs
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* // Payment intent
|
|
177
|
+
* const result = buildFromIntent(
|
|
178
|
+
* {
|
|
179
|
+
* intentType: 'payment',
|
|
180
|
+
* recipients: [{ address: { address: recipient }, amount: { value: 1000000n } }]
|
|
181
|
+
* },
|
|
182
|
+
* { feePayer: walletRoot, nonce: { type: 'blockhash', value: blockhash } }
|
|
183
|
+
* );
|
|
184
|
+
*
|
|
185
|
+
* // Native staking - generates a new stake account keypair
|
|
186
|
+
* const result = buildFromIntent(
|
|
187
|
+
* {
|
|
188
|
+
* intentType: 'stake',
|
|
189
|
+
* validatorAddress: validator,
|
|
190
|
+
* amount: { value: 1000000000n }
|
|
191
|
+
* },
|
|
192
|
+
* { feePayer: walletRoot, nonce: { type: 'blockhash', value: blockhash } }
|
|
193
|
+
* );
|
|
194
|
+
* // result.generatedKeypairs[0] contains the stake account keypair
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
export declare function buildFromIntent(intent: BaseIntent, params: BuildFromIntentParams): BuildFromIntentResult;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level intent-based transaction building.
|
|
3
|
+
*
|
|
4
|
+
* This module provides `buildFromIntent()` which accepts BitGo intent objects
|
|
5
|
+
* directly and builds Solana transactions without requiring the caller to
|
|
6
|
+
* construct low-level instructions.
|
|
7
|
+
*
|
|
8
|
+
* The intent → transaction mapping happens entirely in Rust/WASM for simplicity.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { buildFromIntent } from '@bitgo/wasm-solana';
|
|
13
|
+
*
|
|
14
|
+
* const result = buildFromIntent(intent, {
|
|
15
|
+
* feePayer: walletRootAddress,
|
|
16
|
+
* nonce: { type: 'blockhash', value: recentBlockhash },
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // result.transaction - Transaction object
|
|
20
|
+
* // result.generatedKeypairs - any keypairs generated (e.g., stake accounts)
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import { IntentNamespace } from "./wasm/wasm_solana.js";
|
|
24
|
+
import { Transaction } from "./transaction.js";
|
|
25
|
+
// =============================================================================
|
|
26
|
+
// Main Function
|
|
27
|
+
// =============================================================================
|
|
28
|
+
/**
|
|
29
|
+
* Build a Solana transaction from a BitGo intent.
|
|
30
|
+
*
|
|
31
|
+
* This function passes the intent directly to Rust/WASM which handles
|
|
32
|
+
* all the intent-to-transaction mapping internally.
|
|
33
|
+
*
|
|
34
|
+
* @param intent - The BitGo intent (with intentType, etc.)
|
|
35
|
+
* @param params - Build parameters (feePayer, nonce)
|
|
36
|
+
* @returns Transaction object and any generated keypairs
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* // Payment intent
|
|
41
|
+
* const result = buildFromIntent(
|
|
42
|
+
* {
|
|
43
|
+
* intentType: 'payment',
|
|
44
|
+
* recipients: [{ address: { address: recipient }, amount: { value: 1000000n } }]
|
|
45
|
+
* },
|
|
46
|
+
* { feePayer: walletRoot, nonce: { type: 'blockhash', value: blockhash } }
|
|
47
|
+
* );
|
|
48
|
+
*
|
|
49
|
+
* // Native staking - generates a new stake account keypair
|
|
50
|
+
* const result = buildFromIntent(
|
|
51
|
+
* {
|
|
52
|
+
* intentType: 'stake',
|
|
53
|
+
* validatorAddress: validator,
|
|
54
|
+
* amount: { value: 1000000000n }
|
|
55
|
+
* },
|
|
56
|
+
* { feePayer: walletRoot, nonce: { type: 'blockhash', value: blockhash } }
|
|
57
|
+
* );
|
|
58
|
+
* // result.generatedKeypairs[0] contains the stake account keypair
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export function buildFromIntent(intent, params) {
|
|
62
|
+
const result = IntentNamespace.build_from_intent(intent, params);
|
|
63
|
+
return {
|
|
64
|
+
transaction: Transaction.fromWasm(result.transaction),
|
|
65
|
+
generatedKeypairs: result.generatedKeypairs,
|
|
66
|
+
};
|
|
67
|
+
}
|
package/dist/esm/js/keypair.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ import { WasmKeypair } from "./wasm/wasm_solana.js";
|
|
|
8
8
|
export declare class Keypair {
|
|
9
9
|
private _wasm;
|
|
10
10
|
private constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Generate a new random keypair
|
|
13
|
+
* @returns A new Keypair instance with randomly generated keys
|
|
14
|
+
*/
|
|
15
|
+
static generate(): Keypair;
|
|
11
16
|
/**
|
|
12
17
|
* Create a keypair from a 32-byte secret key
|
|
13
18
|
* @param secretKey - The 32-byte Ed25519 secret key
|
package/dist/esm/js/keypair.js
CHANGED
|
@@ -10,6 +10,14 @@ export class Keypair {
|
|
|
10
10
|
constructor(_wasm) {
|
|
11
11
|
this._wasm = _wasm;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Generate a new random keypair
|
|
15
|
+
* @returns A new Keypair instance with randomly generated keys
|
|
16
|
+
*/
|
|
17
|
+
static generate() {
|
|
18
|
+
const wasm = WasmKeypair.generate();
|
|
19
|
+
return new Keypair(wasm);
|
|
20
|
+
}
|
|
13
21
|
/**
|
|
14
22
|
* Create a keypair from a 32-byte secret key
|
|
15
23
|
* @param secretKey - The 32-byte Ed25519 secret key
|