bulk-keychain-wasm 0.1.2 → 0.1.4
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/bulk_keychain_wasm.d.ts +140 -0
- package/bulk_keychain_wasm.js +350 -0
- package/bulk_keychain_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/bulk_keychain_wasm.d.ts
CHANGED
|
@@ -37,6 +37,64 @@ export class WasmKeypair {
|
|
|
37
37
|
readonly pubkey: string;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Prepared message for external wallet signing
|
|
42
|
+
*
|
|
43
|
+
* This contains everything needed to sign with an external wallet
|
|
44
|
+
* and then finalize into a SignedTransaction.
|
|
45
|
+
*/
|
|
46
|
+
export class WasmPreparedMessage {
|
|
47
|
+
private constructor();
|
|
48
|
+
free(): void;
|
|
49
|
+
[Symbol.dispose](): void;
|
|
50
|
+
/**
|
|
51
|
+
* Finalize with a signature (base58 string)
|
|
52
|
+
*
|
|
53
|
+
* Call this after your wallet signs the messageBytes.
|
|
54
|
+
*/
|
|
55
|
+
finalize(signature: string): any;
|
|
56
|
+
/**
|
|
57
|
+
* Finalize with signature bytes (Uint8Array)
|
|
58
|
+
*/
|
|
59
|
+
finalizeBytes(signature: Uint8Array): any;
|
|
60
|
+
/**
|
|
61
|
+
* Get the account public key (base58)
|
|
62
|
+
*/
|
|
63
|
+
readonly account: string;
|
|
64
|
+
/**
|
|
65
|
+
* Get the action JSON
|
|
66
|
+
*/
|
|
67
|
+
readonly action: any;
|
|
68
|
+
/**
|
|
69
|
+
* Get message as base58 string
|
|
70
|
+
*/
|
|
71
|
+
readonly messageBase58: string;
|
|
72
|
+
/**
|
|
73
|
+
* Get message as base64 string
|
|
74
|
+
*/
|
|
75
|
+
readonly messageBase64: string;
|
|
76
|
+
/**
|
|
77
|
+
* Get the raw message bytes to sign (Uint8Array)
|
|
78
|
+
*/
|
|
79
|
+
readonly messageBytes: Uint8Array;
|
|
80
|
+
/**
|
|
81
|
+
* Get message as hex string
|
|
82
|
+
*/
|
|
83
|
+
readonly messageHex: string;
|
|
84
|
+
/**
|
|
85
|
+
* Get the nonce
|
|
86
|
+
*/
|
|
87
|
+
readonly nonce: number;
|
|
88
|
+
/**
|
|
89
|
+
* Get the pre-computed order ID
|
|
90
|
+
*/
|
|
91
|
+
readonly orderId: string;
|
|
92
|
+
/**
|
|
93
|
+
* Get the signer public key (base58)
|
|
94
|
+
*/
|
|
95
|
+
readonly signer: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
40
98
|
/**
|
|
41
99
|
* WASM wrapper for Signer
|
|
42
100
|
*/
|
|
@@ -106,11 +164,74 @@ export function computeOrderId(wincode_bytes: Uint8Array): string;
|
|
|
106
164
|
*/
|
|
107
165
|
export function currentTimestamp(): number;
|
|
108
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Finalize a prepared message with a signature
|
|
169
|
+
*
|
|
170
|
+
* Alternative to calling prepared.finalize() - useful if you have
|
|
171
|
+
* the prepared message as a plain object.
|
|
172
|
+
*/
|
|
173
|
+
export function finalizeTransaction(prepared: any, signature: string): any;
|
|
174
|
+
|
|
109
175
|
/**
|
|
110
176
|
* Initialize the WASM module
|
|
111
177
|
*/
|
|
112
178
|
export function init(): void;
|
|
113
179
|
|
|
180
|
+
/**
|
|
181
|
+
* Prepare agent wallet creation for external signing
|
|
182
|
+
*
|
|
183
|
+
* @param agentPubkey - The agent wallet public key to authorize
|
|
184
|
+
* @param delete - Whether to delete (true) or add (false) the agent
|
|
185
|
+
* @param options - { account: string, signer?: string, nonce?: number }
|
|
186
|
+
*/
|
|
187
|
+
export function prepareAgentWallet(agent_pubkey: string, _delete: boolean, options: any): WasmPreparedMessage;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Prepare multiple orders - each becomes its own transaction (parallel)
|
|
191
|
+
*
|
|
192
|
+
* @param orders - Array of orders to prepare
|
|
193
|
+
* @param options - { account: string, signer?: string, nonce?: number }
|
|
194
|
+
* @returns Array of PreparedMessage
|
|
195
|
+
*/
|
|
196
|
+
export function prepareAll(orders: any, options: any): WasmPreparedMessage[];
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Prepare faucet request for external signing
|
|
200
|
+
*
|
|
201
|
+
* @param options - { account: string, signer?: string, nonce?: number }
|
|
202
|
+
*/
|
|
203
|
+
export function prepareFaucet(options: any): WasmPreparedMessage;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Prepare multiple orders as ONE atomic transaction
|
|
207
|
+
*
|
|
208
|
+
* Use for bracket orders (entry + stop loss + take profit).
|
|
209
|
+
*
|
|
210
|
+
* @param orders - Array of orders for the atomic transaction
|
|
211
|
+
* @param options - { account: string, signer?: string, nonce?: number }
|
|
212
|
+
* @returns Single PreparedMessage containing all orders
|
|
213
|
+
*/
|
|
214
|
+
export function prepareGroup(orders: any, options: any): WasmPreparedMessage;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Prepare a single order for external wallet signing
|
|
218
|
+
*
|
|
219
|
+
* Use this when you don't have access to the private key and need
|
|
220
|
+
* to sign with an external wallet (like Phantom, Privy, etc).
|
|
221
|
+
*
|
|
222
|
+
* @param order - The order to prepare
|
|
223
|
+
* @param options - { account: string, signer?: string, nonce?: number }
|
|
224
|
+
* @returns PreparedMessage with messageBytes to sign
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* const prepared = prepareOrder(order, { account: myPubkey });
|
|
229
|
+
* const signature = await wallet.signMessage(prepared.messageBytes);
|
|
230
|
+
* const signed = prepared.finalize(signature);
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
export function prepareOrder(order: any, options: any): WasmPreparedMessage;
|
|
234
|
+
|
|
114
235
|
/**
|
|
115
236
|
* Generate a random hash (for client order IDs)
|
|
116
237
|
*/
|
|
@@ -131,9 +252,16 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
131
252
|
export interface InitOutput {
|
|
132
253
|
readonly memory: WebAssembly.Memory;
|
|
133
254
|
readonly __wbg_wasmkeypair_free: (a: number, b: number) => void;
|
|
255
|
+
readonly __wbg_wasmpreparedmessage_free: (a: number, b: number) => void;
|
|
134
256
|
readonly __wbg_wasmsigner_free: (a: number, b: number) => void;
|
|
135
257
|
readonly computeOrderId: (a: number, b: number) => [number, number];
|
|
136
258
|
readonly currentTimestamp: () => number;
|
|
259
|
+
readonly finalizeTransaction: (a: any, b: number, c: number) => [number, number, number];
|
|
260
|
+
readonly prepareAgentWallet: (a: number, b: number, c: number, d: any) => [number, number, number];
|
|
261
|
+
readonly prepareAll: (a: any, b: any) => [number, number, number, number];
|
|
262
|
+
readonly prepareFaucet: (a: any) => [number, number, number];
|
|
263
|
+
readonly prepareGroup: (a: any, b: any) => [number, number, number];
|
|
264
|
+
readonly prepareOrder: (a: any, b: any) => [number, number, number];
|
|
137
265
|
readonly randomHash: () => [number, number];
|
|
138
266
|
readonly validateHash: (a: number, b: number) => number;
|
|
139
267
|
readonly validatePubkey: (a: number, b: number) => number;
|
|
@@ -144,6 +272,17 @@ export interface InitOutput {
|
|
|
144
272
|
readonly wasmkeypair_secretKey: (a: number) => [number, number];
|
|
145
273
|
readonly wasmkeypair_toBase58: (a: number) => [number, number];
|
|
146
274
|
readonly wasmkeypair_toBytes: (a: number) => [number, number];
|
|
275
|
+
readonly wasmpreparedmessage_account: (a: number) => [number, number];
|
|
276
|
+
readonly wasmpreparedmessage_action: (a: number) => any;
|
|
277
|
+
readonly wasmpreparedmessage_finalize: (a: number, b: number, c: number) => any;
|
|
278
|
+
readonly wasmpreparedmessage_finalizeBytes: (a: number, b: number, c: number) => any;
|
|
279
|
+
readonly wasmpreparedmessage_messageBase58: (a: number) => [number, number];
|
|
280
|
+
readonly wasmpreparedmessage_messageBase64: (a: number) => [number, number];
|
|
281
|
+
readonly wasmpreparedmessage_messageBytes: (a: number) => [number, number];
|
|
282
|
+
readonly wasmpreparedmessage_messageHex: (a: number) => [number, number];
|
|
283
|
+
readonly wasmpreparedmessage_nonce: (a: number) => number;
|
|
284
|
+
readonly wasmpreparedmessage_orderId: (a: number) => [number, number];
|
|
285
|
+
readonly wasmpreparedmessage_signer: (a: number) => [number, number];
|
|
147
286
|
readonly wasmsigner_fromBase58: (a: number, b: number) => [number, number, number];
|
|
148
287
|
readonly wasmsigner_new: (a: number) => number;
|
|
149
288
|
readonly wasmsigner_pubkey: (a: number) => [number, number];
|
|
@@ -164,6 +303,7 @@ export interface InitOutput {
|
|
|
164
303
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
165
304
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
166
305
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
306
|
+
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
167
307
|
readonly __wbindgen_start: () => void;
|
|
168
308
|
}
|
|
169
309
|
|
package/bulk_keychain_wasm.js
CHANGED
|
@@ -113,6 +113,179 @@ export class WasmKeypair {
|
|
|
113
113
|
}
|
|
114
114
|
if (Symbol.dispose) WasmKeypair.prototype[Symbol.dispose] = WasmKeypair.prototype.free;
|
|
115
115
|
|
|
116
|
+
/**
|
|
117
|
+
* Prepared message for external wallet signing
|
|
118
|
+
*
|
|
119
|
+
* This contains everything needed to sign with an external wallet
|
|
120
|
+
* and then finalize into a SignedTransaction.
|
|
121
|
+
*/
|
|
122
|
+
export class WasmPreparedMessage {
|
|
123
|
+
static __wrap(ptr) {
|
|
124
|
+
ptr = ptr >>> 0;
|
|
125
|
+
const obj = Object.create(WasmPreparedMessage.prototype);
|
|
126
|
+
obj.__wbg_ptr = ptr;
|
|
127
|
+
WasmPreparedMessageFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
128
|
+
return obj;
|
|
129
|
+
}
|
|
130
|
+
__destroy_into_raw() {
|
|
131
|
+
const ptr = this.__wbg_ptr;
|
|
132
|
+
this.__wbg_ptr = 0;
|
|
133
|
+
WasmPreparedMessageFinalization.unregister(this);
|
|
134
|
+
return ptr;
|
|
135
|
+
}
|
|
136
|
+
free() {
|
|
137
|
+
const ptr = this.__destroy_into_raw();
|
|
138
|
+
wasm.__wbg_wasmpreparedmessage_free(ptr, 0);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Get the account public key (base58)
|
|
142
|
+
* @returns {string}
|
|
143
|
+
*/
|
|
144
|
+
get account() {
|
|
145
|
+
let deferred1_0;
|
|
146
|
+
let deferred1_1;
|
|
147
|
+
try {
|
|
148
|
+
const ret = wasm.wasmpreparedmessage_account(this.__wbg_ptr);
|
|
149
|
+
deferred1_0 = ret[0];
|
|
150
|
+
deferred1_1 = ret[1];
|
|
151
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
152
|
+
} finally {
|
|
153
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Get the action JSON
|
|
158
|
+
* @returns {any}
|
|
159
|
+
*/
|
|
160
|
+
get action() {
|
|
161
|
+
const ret = wasm.wasmpreparedmessage_action(this.__wbg_ptr);
|
|
162
|
+
return ret;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Finalize with a signature (base58 string)
|
|
166
|
+
*
|
|
167
|
+
* Call this after your wallet signs the messageBytes.
|
|
168
|
+
* @param {string} signature
|
|
169
|
+
* @returns {any}
|
|
170
|
+
*/
|
|
171
|
+
finalize(signature) {
|
|
172
|
+
const ptr0 = passStringToWasm0(signature, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
173
|
+
const len0 = WASM_VECTOR_LEN;
|
|
174
|
+
const ret = wasm.wasmpreparedmessage_finalize(this.__wbg_ptr, ptr0, len0);
|
|
175
|
+
return ret;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Finalize with signature bytes (Uint8Array)
|
|
179
|
+
* @param {Uint8Array} signature
|
|
180
|
+
* @returns {any}
|
|
181
|
+
*/
|
|
182
|
+
finalizeBytes(signature) {
|
|
183
|
+
const ptr0 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
184
|
+
const len0 = WASM_VECTOR_LEN;
|
|
185
|
+
const ret = wasm.wasmpreparedmessage_finalizeBytes(this.__wbg_ptr, ptr0, len0);
|
|
186
|
+
return ret;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Get message as base58 string
|
|
190
|
+
* @returns {string}
|
|
191
|
+
*/
|
|
192
|
+
get messageBase58() {
|
|
193
|
+
let deferred1_0;
|
|
194
|
+
let deferred1_1;
|
|
195
|
+
try {
|
|
196
|
+
const ret = wasm.wasmpreparedmessage_messageBase58(this.__wbg_ptr);
|
|
197
|
+
deferred1_0 = ret[0];
|
|
198
|
+
deferred1_1 = ret[1];
|
|
199
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
200
|
+
} finally {
|
|
201
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Get message as base64 string
|
|
206
|
+
* @returns {string}
|
|
207
|
+
*/
|
|
208
|
+
get messageBase64() {
|
|
209
|
+
let deferred1_0;
|
|
210
|
+
let deferred1_1;
|
|
211
|
+
try {
|
|
212
|
+
const ret = wasm.wasmpreparedmessage_messageBase64(this.__wbg_ptr);
|
|
213
|
+
deferred1_0 = ret[0];
|
|
214
|
+
deferred1_1 = ret[1];
|
|
215
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
216
|
+
} finally {
|
|
217
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Get the raw message bytes to sign (Uint8Array)
|
|
222
|
+
* @returns {Uint8Array}
|
|
223
|
+
*/
|
|
224
|
+
get messageBytes() {
|
|
225
|
+
const ret = wasm.wasmpreparedmessage_messageBytes(this.__wbg_ptr);
|
|
226
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
227
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
228
|
+
return v1;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Get message as hex string
|
|
232
|
+
* @returns {string}
|
|
233
|
+
*/
|
|
234
|
+
get messageHex() {
|
|
235
|
+
let deferred1_0;
|
|
236
|
+
let deferred1_1;
|
|
237
|
+
try {
|
|
238
|
+
const ret = wasm.wasmpreparedmessage_messageHex(this.__wbg_ptr);
|
|
239
|
+
deferred1_0 = ret[0];
|
|
240
|
+
deferred1_1 = ret[1];
|
|
241
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
242
|
+
} finally {
|
|
243
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Get the nonce
|
|
248
|
+
* @returns {number}
|
|
249
|
+
*/
|
|
250
|
+
get nonce() {
|
|
251
|
+
const ret = wasm.wasmpreparedmessage_nonce(this.__wbg_ptr);
|
|
252
|
+
return ret;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Get the pre-computed order ID
|
|
256
|
+
* @returns {string}
|
|
257
|
+
*/
|
|
258
|
+
get orderId() {
|
|
259
|
+
let deferred1_0;
|
|
260
|
+
let deferred1_1;
|
|
261
|
+
try {
|
|
262
|
+
const ret = wasm.wasmpreparedmessage_orderId(this.__wbg_ptr);
|
|
263
|
+
deferred1_0 = ret[0];
|
|
264
|
+
deferred1_1 = ret[1];
|
|
265
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
266
|
+
} finally {
|
|
267
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Get the signer public key (base58)
|
|
272
|
+
* @returns {string}
|
|
273
|
+
*/
|
|
274
|
+
get signer() {
|
|
275
|
+
let deferred1_0;
|
|
276
|
+
let deferred1_1;
|
|
277
|
+
try {
|
|
278
|
+
const ret = wasm.wasmpreparedmessage_signer(this.__wbg_ptr);
|
|
279
|
+
deferred1_0 = ret[0];
|
|
280
|
+
deferred1_1 = ret[1];
|
|
281
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
282
|
+
} finally {
|
|
283
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (Symbol.dispose) WasmPreparedMessage.prototype[Symbol.dispose] = WasmPreparedMessage.prototype.free;
|
|
288
|
+
|
|
116
289
|
/**
|
|
117
290
|
* WASM wrapper for Signer
|
|
118
291
|
*/
|
|
@@ -332,6 +505,25 @@ export function currentTimestamp() {
|
|
|
332
505
|
return ret;
|
|
333
506
|
}
|
|
334
507
|
|
|
508
|
+
/**
|
|
509
|
+
* Finalize a prepared message with a signature
|
|
510
|
+
*
|
|
511
|
+
* Alternative to calling prepared.finalize() - useful if you have
|
|
512
|
+
* the prepared message as a plain object.
|
|
513
|
+
* @param {any} prepared
|
|
514
|
+
* @param {string} signature
|
|
515
|
+
* @returns {any}
|
|
516
|
+
*/
|
|
517
|
+
export function finalizeTransaction(prepared, signature) {
|
|
518
|
+
const ptr0 = passStringToWasm0(signature, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
519
|
+
const len0 = WASM_VECTOR_LEN;
|
|
520
|
+
const ret = wasm.finalizeTransaction(prepared, ptr0, len0);
|
|
521
|
+
if (ret[2]) {
|
|
522
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
523
|
+
}
|
|
524
|
+
return takeFromExternrefTable0(ret[0]);
|
|
525
|
+
}
|
|
526
|
+
|
|
335
527
|
/**
|
|
336
528
|
* Initialize the WASM module
|
|
337
529
|
*/
|
|
@@ -339,6 +531,110 @@ export function init() {
|
|
|
339
531
|
wasm.init();
|
|
340
532
|
}
|
|
341
533
|
|
|
534
|
+
/**
|
|
535
|
+
* Prepare agent wallet creation for external signing
|
|
536
|
+
*
|
|
537
|
+
* @param agentPubkey - The agent wallet public key to authorize
|
|
538
|
+
* @param delete - Whether to delete (true) or add (false) the agent
|
|
539
|
+
* @param options - { account: string, signer?: string, nonce?: number }
|
|
540
|
+
* @param {string} agent_pubkey
|
|
541
|
+
* @param {boolean} _delete
|
|
542
|
+
* @param {any} options
|
|
543
|
+
* @returns {WasmPreparedMessage}
|
|
544
|
+
*/
|
|
545
|
+
export function prepareAgentWallet(agent_pubkey, _delete, options) {
|
|
546
|
+
const ptr0 = passStringToWasm0(agent_pubkey, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
547
|
+
const len0 = WASM_VECTOR_LEN;
|
|
548
|
+
const ret = wasm.prepareAgentWallet(ptr0, len0, _delete, options);
|
|
549
|
+
if (ret[2]) {
|
|
550
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
551
|
+
}
|
|
552
|
+
return WasmPreparedMessage.__wrap(ret[0]);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Prepare multiple orders - each becomes its own transaction (parallel)
|
|
557
|
+
*
|
|
558
|
+
* @param orders - Array of orders to prepare
|
|
559
|
+
* @param options - { account: string, signer?: string, nonce?: number }
|
|
560
|
+
* @returns Array of PreparedMessage
|
|
561
|
+
* @param {any} orders
|
|
562
|
+
* @param {any} options
|
|
563
|
+
* @returns {WasmPreparedMessage[]}
|
|
564
|
+
*/
|
|
565
|
+
export function prepareAll(orders, options) {
|
|
566
|
+
const ret = wasm.prepareAll(orders, options);
|
|
567
|
+
if (ret[3]) {
|
|
568
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
569
|
+
}
|
|
570
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
571
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
572
|
+
return v1;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Prepare faucet request for external signing
|
|
577
|
+
*
|
|
578
|
+
* @param options - { account: string, signer?: string, nonce?: number }
|
|
579
|
+
* @param {any} options
|
|
580
|
+
* @returns {WasmPreparedMessage}
|
|
581
|
+
*/
|
|
582
|
+
export function prepareFaucet(options) {
|
|
583
|
+
const ret = wasm.prepareFaucet(options);
|
|
584
|
+
if (ret[2]) {
|
|
585
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
586
|
+
}
|
|
587
|
+
return WasmPreparedMessage.__wrap(ret[0]);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Prepare multiple orders as ONE atomic transaction
|
|
592
|
+
*
|
|
593
|
+
* Use for bracket orders (entry + stop loss + take profit).
|
|
594
|
+
*
|
|
595
|
+
* @param orders - Array of orders for the atomic transaction
|
|
596
|
+
* @param options - { account: string, signer?: string, nonce?: number }
|
|
597
|
+
* @returns Single PreparedMessage containing all orders
|
|
598
|
+
* @param {any} orders
|
|
599
|
+
* @param {any} options
|
|
600
|
+
* @returns {WasmPreparedMessage}
|
|
601
|
+
*/
|
|
602
|
+
export function prepareGroup(orders, options) {
|
|
603
|
+
const ret = wasm.prepareGroup(orders, options);
|
|
604
|
+
if (ret[2]) {
|
|
605
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
606
|
+
}
|
|
607
|
+
return WasmPreparedMessage.__wrap(ret[0]);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Prepare a single order for external wallet signing
|
|
612
|
+
*
|
|
613
|
+
* Use this when you don't have access to the private key and need
|
|
614
|
+
* to sign with an external wallet (like Phantom, Privy, etc).
|
|
615
|
+
*
|
|
616
|
+
* @param order - The order to prepare
|
|
617
|
+
* @param options - { account: string, signer?: string, nonce?: number }
|
|
618
|
+
* @returns PreparedMessage with messageBytes to sign
|
|
619
|
+
*
|
|
620
|
+
* @example
|
|
621
|
+
* ```typescript
|
|
622
|
+
* const prepared = prepareOrder(order, { account: myPubkey });
|
|
623
|
+
* const signature = await wallet.signMessage(prepared.messageBytes);
|
|
624
|
+
* const signed = prepared.finalize(signature);
|
|
625
|
+
* ```
|
|
626
|
+
* @param {any} order
|
|
627
|
+
* @param {any} options
|
|
628
|
+
* @returns {WasmPreparedMessage}
|
|
629
|
+
*/
|
|
630
|
+
export function prepareOrder(order, options) {
|
|
631
|
+
const ret = wasm.prepareOrder(order, options);
|
|
632
|
+
if (ret[2]) {
|
|
633
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
634
|
+
}
|
|
635
|
+
return WasmPreparedMessage.__wrap(ret[0]);
|
|
636
|
+
}
|
|
637
|
+
|
|
342
638
|
/**
|
|
343
639
|
* Generate a random hash (for client order IDs)
|
|
344
640
|
* @returns {string}
|
|
@@ -387,6 +683,10 @@ function __wbg_get_imports() {
|
|
|
387
683
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
388
684
|
return ret;
|
|
389
685
|
},
|
|
686
|
+
__wbg_Number_04624de7d0e8332d: function(arg0) {
|
|
687
|
+
const ret = Number(arg0);
|
|
688
|
+
return ret;
|
|
689
|
+
},
|
|
390
690
|
__wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
|
|
391
691
|
const ret = String(arg1);
|
|
392
692
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -394,6 +694,12 @@ function __wbg_get_imports() {
|
|
|
394
694
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
395
695
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
396
696
|
},
|
|
697
|
+
__wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {
|
|
698
|
+
const v = arg1;
|
|
699
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
700
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
701
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
702
|
+
},
|
|
397
703
|
__wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
|
|
398
704
|
const v = arg0;
|
|
399
705
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
@@ -410,6 +716,10 @@ function __wbg_get_imports() {
|
|
|
410
716
|
const ret = arg0 in arg1;
|
|
411
717
|
return ret;
|
|
412
718
|
},
|
|
719
|
+
__wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
|
|
720
|
+
const ret = typeof(arg0) === 'bigint';
|
|
721
|
+
return ret;
|
|
722
|
+
},
|
|
413
723
|
__wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
|
|
414
724
|
const ret = typeof(arg0) === 'function';
|
|
415
725
|
return ret;
|
|
@@ -427,6 +737,10 @@ function __wbg_get_imports() {
|
|
|
427
737
|
const ret = arg0 === undefined;
|
|
428
738
|
return ret;
|
|
429
739
|
},
|
|
740
|
+
__wbg___wbindgen_jsval_eq_11888390b0186270: function(arg0, arg1) {
|
|
741
|
+
const ret = arg0 === arg1;
|
|
742
|
+
return ret;
|
|
743
|
+
},
|
|
430
744
|
__wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
|
|
431
745
|
const ret = arg0 == arg1;
|
|
432
746
|
return ret;
|
|
@@ -464,6 +778,10 @@ function __wbg_get_imports() {
|
|
|
464
778
|
const ret = arg0.done;
|
|
465
779
|
return ret;
|
|
466
780
|
},
|
|
781
|
+
__wbg_entries_58c7934c745daac7: function(arg0) {
|
|
782
|
+
const ret = Object.entries(arg0);
|
|
783
|
+
return ret;
|
|
784
|
+
},
|
|
467
785
|
__wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
|
|
468
786
|
let deferred0_0;
|
|
469
787
|
let deferred0_1;
|
|
@@ -500,6 +818,16 @@ function __wbg_get_imports() {
|
|
|
500
818
|
const ret = result;
|
|
501
819
|
return ret;
|
|
502
820
|
},
|
|
821
|
+
__wbg_instanceof_Map_53af74335dec57f4: function(arg0) {
|
|
822
|
+
let result;
|
|
823
|
+
try {
|
|
824
|
+
result = arg0 instanceof Map;
|
|
825
|
+
} catch (_) {
|
|
826
|
+
result = false;
|
|
827
|
+
}
|
|
828
|
+
const ret = result;
|
|
829
|
+
return ret;
|
|
830
|
+
},
|
|
503
831
|
__wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
|
|
504
832
|
let result;
|
|
505
833
|
try {
|
|
@@ -514,6 +842,10 @@ function __wbg_get_imports() {
|
|
|
514
842
|
const ret = Array.isArray(arg0);
|
|
515
843
|
return ret;
|
|
516
844
|
},
|
|
845
|
+
__wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
|
|
846
|
+
const ret = Number.isSafeInteger(arg0);
|
|
847
|
+
return ret;
|
|
848
|
+
},
|
|
517
849
|
__wbg_iterator_6ff6560ca1568e55: function() {
|
|
518
850
|
const ret = Symbol.iterator;
|
|
519
851
|
return ret;
|
|
@@ -629,6 +961,10 @@ function __wbg_get_imports() {
|
|
|
629
961
|
const ret = arg0.versions;
|
|
630
962
|
return ret;
|
|
631
963
|
},
|
|
964
|
+
__wbg_wasmpreparedmessage_new: function(arg0) {
|
|
965
|
+
const ret = WasmPreparedMessage.__wrap(arg0);
|
|
966
|
+
return ret;
|
|
967
|
+
},
|
|
632
968
|
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
633
969
|
// Cast intrinsic for `F64 -> Externref`.
|
|
634
970
|
const ret = arg0;
|
|
@@ -673,6 +1009,9 @@ function __wbg_get_imports() {
|
|
|
673
1009
|
const WasmKeypairFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
674
1010
|
? { register: () => {}, unregister: () => {} }
|
|
675
1011
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmkeypair_free(ptr >>> 0, 1));
|
|
1012
|
+
const WasmPreparedMessageFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1013
|
+
? { register: () => {}, unregister: () => {} }
|
|
1014
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmpreparedmessage_free(ptr >>> 0, 1));
|
|
676
1015
|
const WasmSignerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
677
1016
|
? { register: () => {}, unregister: () => {} }
|
|
678
1017
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmsigner_free(ptr >>> 0, 1));
|
|
@@ -754,6 +1093,17 @@ function debugString(val) {
|
|
|
754
1093
|
return className;
|
|
755
1094
|
}
|
|
756
1095
|
|
|
1096
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
1097
|
+
ptr = ptr >>> 0;
|
|
1098
|
+
const mem = getDataViewMemory0();
|
|
1099
|
+
const result = [];
|
|
1100
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
1101
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
1102
|
+
}
|
|
1103
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
1104
|
+
return result;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
757
1107
|
function getArrayU8FromWasm0(ptr, len) {
|
|
758
1108
|
ptr = ptr >>> 0;
|
|
759
1109
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
Binary file
|
package/package.json
CHANGED