@dexterai/vault 0.2.1 → 0.3.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/instructions/index.cjs +93 -26
- package/dist/instructions/index.d.cts +49 -1
- package/dist/instructions/index.d.ts +49 -1
- package/dist/instructions/index.js +100 -31
- package/package.json +1 -1
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/instructions/index.ts
|
|
31
31
|
var instructions_exports = {};
|
|
32
32
|
__export(instructions_exports, {
|
|
33
|
+
SET_SWIG_ATOMIC_DISCRIMINATOR: () => SET_SWIG_ATOMIC_DISCRIMINATOR,
|
|
33
34
|
SWIG_PROGRAM_EXEC_MARKERS: () => SWIG_PROGRAM_EXEC_MARKERS,
|
|
34
35
|
SWIG_PROGRAM_EXEC_PREFIX: () => SWIG_PROGRAM_EXEC_PREFIX,
|
|
35
36
|
SWIG_PROGRAM_EXEC_PREFIX_SETTLE_TAB: () => SWIG_PROGRAM_EXEC_PREFIX_SETTLE_TAB,
|
|
@@ -42,6 +43,7 @@ __export(instructions_exports, {
|
|
|
42
43
|
buildRevokeSessionKeyInstruction: () => buildRevokeSessionKeyInstruction,
|
|
43
44
|
buildRotateDexterAuthorityInstruction: () => buildRotateDexterAuthorityInstruction,
|
|
44
45
|
buildRotatePasskeyInstruction: () => buildRotatePasskeyInstruction,
|
|
46
|
+
buildSetSwigAtomicInstruction: () => buildSetSwigAtomicInstruction,
|
|
45
47
|
buildSetSwigInstruction: () => buildSetSwigInstruction,
|
|
46
48
|
buildSettleTabVoucherInstruction: () => buildSettleTabVoucherInstruction,
|
|
47
49
|
buildSettleVoucherInstruction: () => buildSettleVoucherInstruction,
|
|
@@ -159,8 +161,71 @@ function buildSetSwigInstruction(p) {
|
|
|
159
161
|
});
|
|
160
162
|
}
|
|
161
163
|
|
|
162
|
-
// src/instructions/
|
|
164
|
+
// src/instructions/setSwigAtomic.ts
|
|
163
165
|
var import_web34 = require("@solana/web3.js");
|
|
166
|
+
var SET_SWIG_ATOMIC_DISCRIMINATOR = new Uint8Array([
|
|
167
|
+
119,
|
|
168
|
+
111,
|
|
169
|
+
247,
|
|
170
|
+
215,
|
|
171
|
+
190,
|
|
172
|
+
3,
|
|
173
|
+
170,
|
|
174
|
+
23
|
|
175
|
+
]);
|
|
176
|
+
function buildSetSwigAtomicInstruction(params) {
|
|
177
|
+
if (params.swigId.length !== 32) {
|
|
178
|
+
throw new Error(`swigId must be 32 bytes, got ${params.swigId.length}`);
|
|
179
|
+
}
|
|
180
|
+
if (params.authenticatorData.length < 37) {
|
|
181
|
+
throw new Error(`authenticatorData must be at least 37 bytes`);
|
|
182
|
+
}
|
|
183
|
+
const cdj = params.clientDataJSON;
|
|
184
|
+
const ad = params.authenticatorData;
|
|
185
|
+
const dataLen = 8 + // discriminator
|
|
186
|
+
32 + // swig_id
|
|
187
|
+
1 + // swig_account_bump
|
|
188
|
+
1 + // swig_wallet_address_bump
|
|
189
|
+
32 + // dexter_master_pubkey
|
|
190
|
+
4 + cdj.length + // client_data_json (len-prefixed)
|
|
191
|
+
4 + ad.length;
|
|
192
|
+
const data = new Uint8Array(dataLen);
|
|
193
|
+
const view = new DataView(data.buffer);
|
|
194
|
+
let off = 0;
|
|
195
|
+
data.set(SET_SWIG_ATOMIC_DISCRIMINATOR, off);
|
|
196
|
+
off += 8;
|
|
197
|
+
data.set(params.swigId, off);
|
|
198
|
+
off += 32;
|
|
199
|
+
data[off++] = params.swigAccountBump;
|
|
200
|
+
data[off++] = params.swigWalletAddressBump;
|
|
201
|
+
data.set(params.dexterMasterPubkey.toBytes(), off);
|
|
202
|
+
off += 32;
|
|
203
|
+
view.setUint32(off, cdj.length, true);
|
|
204
|
+
off += 4;
|
|
205
|
+
data.set(cdj, off);
|
|
206
|
+
off += cdj.length;
|
|
207
|
+
view.setUint32(off, ad.length, true);
|
|
208
|
+
off += 4;
|
|
209
|
+
data.set(ad, off);
|
|
210
|
+
off += ad.length;
|
|
211
|
+
if (off !== dataLen) throw new Error(`internal: byte offset mismatch (${off} vs ${dataLen})`);
|
|
212
|
+
return new import_web34.TransactionInstruction({
|
|
213
|
+
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
214
|
+
keys: [
|
|
215
|
+
{ pubkey: params.vaultPda, isSigner: false, isWritable: true },
|
|
216
|
+
{ pubkey: params.feePayer, isSigner: true, isWritable: true },
|
|
217
|
+
{ pubkey: params.swigAddress, isSigner: false, isWritable: true },
|
|
218
|
+
{ pubkey: params.swigWalletAddress, isSigner: false, isWritable: true },
|
|
219
|
+
{ pubkey: SWIG_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
220
|
+
{ pubkey: import_web34.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
221
|
+
{ pubkey: import_web34.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false }
|
|
222
|
+
],
|
|
223
|
+
data: Buffer.from(data)
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// src/instructions/registerSession.ts
|
|
228
|
+
var import_web35 = require("@solana/web3.js");
|
|
164
229
|
function encodeU64LE(value) {
|
|
165
230
|
const buf = new Uint8Array(8);
|
|
166
231
|
new DataView(buf.buffer).setBigUint64(0, value, true);
|
|
@@ -206,7 +271,7 @@ function buildRegisterSessionKeyInstruction(args) {
|
|
|
206
271
|
encodeVecU8(args.clientDataJSON),
|
|
207
272
|
encodeVecU8(args.authenticatorData)
|
|
208
273
|
);
|
|
209
|
-
return new
|
|
274
|
+
return new import_web35.TransactionInstruction({
|
|
210
275
|
keys: [
|
|
211
276
|
{ pubkey: args.vaultPda, isSigner: false, isWritable: true },
|
|
212
277
|
{ pubkey: INSTRUCTIONS_SYSVAR_ID, isSigner: false, isWritable: false }
|
|
@@ -217,7 +282,7 @@ function buildRegisterSessionKeyInstruction(args) {
|
|
|
217
282
|
}
|
|
218
283
|
|
|
219
284
|
// src/instructions/revokeSession.ts
|
|
220
|
-
var
|
|
285
|
+
var import_web36 = require("@solana/web3.js");
|
|
221
286
|
function encodeVecU82(bytes) {
|
|
222
287
|
const out = new Uint8Array(4 + bytes.length);
|
|
223
288
|
new DataView(out.buffer).setUint32(0, bytes.length >>> 0, true);
|
|
@@ -240,7 +305,7 @@ function buildRevokeSessionKeyInstruction(args) {
|
|
|
240
305
|
encodeVecU82(args.clientDataJSON),
|
|
241
306
|
encodeVecU82(args.authenticatorData)
|
|
242
307
|
);
|
|
243
|
-
return new
|
|
308
|
+
return new import_web36.TransactionInstruction({
|
|
244
309
|
keys: [
|
|
245
310
|
{ pubkey: args.vaultPda, isSigner: false, isWritable: true },
|
|
246
311
|
{ pubkey: INSTRUCTIONS_SYSVAR_ID, isSigner: false, isWritable: false }
|
|
@@ -251,7 +316,7 @@ function buildRevokeSessionKeyInstruction(args) {
|
|
|
251
316
|
}
|
|
252
317
|
|
|
253
318
|
// src/instructions/settleVoucher.ts
|
|
254
|
-
var
|
|
319
|
+
var import_web37 = require("@solana/web3.js");
|
|
255
320
|
function encodeU64(value) {
|
|
256
321
|
const out = Buffer.alloc(8);
|
|
257
322
|
out.writeBigUInt64LE(value, 0);
|
|
@@ -263,7 +328,7 @@ function encodeBool(value) {
|
|
|
263
328
|
function buildSettleVoucherInstruction(p) {
|
|
264
329
|
const argsBuf = Buffer.concat([encodeU64(p.amount), encodeBool(p.increment)]);
|
|
265
330
|
const data = Buffer.concat([Buffer.from(DISCRIMINATORS.settle_voucher), argsBuf]);
|
|
266
|
-
return new
|
|
331
|
+
return new import_web37.TransactionInstruction({
|
|
267
332
|
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
268
333
|
keys: [
|
|
269
334
|
{ pubkey: p.vaultPda, isSigner: false, isWritable: true },
|
|
@@ -274,10 +339,10 @@ function buildSettleVoucherInstruction(p) {
|
|
|
274
339
|
}
|
|
275
340
|
|
|
276
341
|
// src/instructions/settleTabVoucher.ts
|
|
277
|
-
var
|
|
342
|
+
var import_web39 = require("@solana/web3.js");
|
|
278
343
|
|
|
279
344
|
// src/instructions/withdraw.ts
|
|
280
|
-
var
|
|
345
|
+
var import_web38 = require("@solana/web3.js");
|
|
281
346
|
function encodeBytesVec2(buf) {
|
|
282
347
|
const out = Buffer.alloc(4 + buf.length);
|
|
283
348
|
out.writeUInt32LE(buf.length, 0);
|
|
@@ -298,7 +363,7 @@ function encodePubkey2(key) {
|
|
|
298
363
|
return Buffer.from(key.toBytes());
|
|
299
364
|
}
|
|
300
365
|
function deriveSwigWalletAddress(swigAddress) {
|
|
301
|
-
const [pda] =
|
|
366
|
+
const [pda] = import_web38.PublicKey.findProgramAddressSync(
|
|
302
367
|
[Buffer.from("swig-wallet-address"), swigAddress.toBuffer()],
|
|
303
368
|
SWIG_PROGRAM_ID
|
|
304
369
|
);
|
|
@@ -313,11 +378,11 @@ function buildRequestWithdrawalInstruction(p) {
|
|
|
313
378
|
encodeBytesVec2(p.authenticatorData)
|
|
314
379
|
]);
|
|
315
380
|
const data = Buffer.concat([Buffer.from(DISCRIMINATORS.request_withdrawal), argsBuf]);
|
|
316
|
-
return new
|
|
381
|
+
return new import_web38.TransactionInstruction({
|
|
317
382
|
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
318
383
|
keys: [
|
|
319
384
|
{ pubkey: p.vaultPda, isSigner: false, isWritable: true },
|
|
320
|
-
{ pubkey:
|
|
385
|
+
{ pubkey: import_web38.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false }
|
|
321
386
|
],
|
|
322
387
|
data
|
|
323
388
|
});
|
|
@@ -329,13 +394,13 @@ function buildFinalizeWithdrawalInstruction(p) {
|
|
|
329
394
|
]);
|
|
330
395
|
const data = Buffer.concat([Buffer.from(DISCRIMINATORS.finalize_withdrawal), argsBuf]);
|
|
331
396
|
const swigWalletAddress = deriveSwigWalletAddress(p.swigAddress);
|
|
332
|
-
return new
|
|
397
|
+
return new import_web38.TransactionInstruction({
|
|
333
398
|
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
334
399
|
keys: [
|
|
335
400
|
{ pubkey: p.swigAddress, isSigner: false, isWritable: false },
|
|
336
401
|
{ pubkey: swigWalletAddress, isSigner: false, isWritable: false },
|
|
337
402
|
{ pubkey: p.vaultPda, isSigner: false, isWritable: true },
|
|
338
|
-
{ pubkey:
|
|
403
|
+
{ pubkey: import_web38.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false }
|
|
339
404
|
],
|
|
340
405
|
data
|
|
341
406
|
});
|
|
@@ -346,11 +411,11 @@ function buildForceReleaseInstruction(p) {
|
|
|
346
411
|
encodeBytesVec2(p.authenticatorData)
|
|
347
412
|
]);
|
|
348
413
|
const data = Buffer.concat([Buffer.from(DISCRIMINATORS.force_release), argsBuf]);
|
|
349
|
-
return new
|
|
414
|
+
return new import_web38.TransactionInstruction({
|
|
350
415
|
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
351
416
|
keys: [
|
|
352
417
|
{ pubkey: p.vaultPda, isSigner: false, isWritable: true },
|
|
353
|
-
{ pubkey:
|
|
418
|
+
{ pubkey: import_web38.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false }
|
|
354
419
|
],
|
|
355
420
|
data
|
|
356
421
|
});
|
|
@@ -384,21 +449,21 @@ function buildSettleTabVoucherInstruction(p) {
|
|
|
384
449
|
]);
|
|
385
450
|
const data = Buffer.concat([Buffer.from(DISCRIMINATORS.settle_tab_voucher), argsBuf]);
|
|
386
451
|
const swigWalletAddress = deriveSwigWalletAddress(p.swigAddress);
|
|
387
|
-
return new
|
|
452
|
+
return new import_web39.TransactionInstruction({
|
|
388
453
|
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
389
454
|
keys: [
|
|
390
455
|
{ pubkey: p.swigAddress, isSigner: false, isWritable: false },
|
|
391
456
|
{ pubkey: swigWalletAddress, isSigner: false, isWritable: false },
|
|
392
457
|
{ pubkey: p.vaultPda, isSigner: false, isWritable: true },
|
|
393
458
|
{ pubkey: p.dexterAuthority, isSigner: true, isWritable: false },
|
|
394
|
-
{ pubkey:
|
|
459
|
+
{ pubkey: import_web39.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false }
|
|
395
460
|
],
|
|
396
461
|
data
|
|
397
462
|
});
|
|
398
463
|
}
|
|
399
464
|
|
|
400
465
|
// src/instructions/rotate.ts
|
|
401
|
-
var
|
|
466
|
+
var import_web310 = require("@solana/web3.js");
|
|
402
467
|
function encodeBytesVec3(buf) {
|
|
403
468
|
const out = Buffer.alloc(4 + buf.length);
|
|
404
469
|
out.writeUInt32LE(buf.length, 0);
|
|
@@ -421,11 +486,11 @@ function buildRotatePasskeyInstruction(p) {
|
|
|
421
486
|
encodeBytesVec3(p.authenticatorData)
|
|
422
487
|
]);
|
|
423
488
|
const data = Buffer.concat([Buffer.from(DISCRIMINATORS.rotate_passkey), argsBuf]);
|
|
424
|
-
return new
|
|
489
|
+
return new import_web310.TransactionInstruction({
|
|
425
490
|
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
426
491
|
keys: [
|
|
427
492
|
{ pubkey: p.vaultPda, isSigner: false, isWritable: true },
|
|
428
|
-
{ pubkey:
|
|
493
|
+
{ pubkey: import_web310.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false }
|
|
429
494
|
],
|
|
430
495
|
data
|
|
431
496
|
});
|
|
@@ -435,7 +500,7 @@ function buildRotateDexterAuthorityInstruction(p) {
|
|
|
435
500
|
Buffer.from(DISCRIMINATORS.rotate_dexter_authority),
|
|
436
501
|
encodePubkey3(p.newDexterAuthority)
|
|
437
502
|
]);
|
|
438
|
-
return new
|
|
503
|
+
return new import_web310.TransactionInstruction({
|
|
439
504
|
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
440
505
|
keys: [
|
|
441
506
|
{ pubkey: p.vaultPda, isSigner: false, isWritable: true },
|
|
@@ -446,7 +511,7 @@ function buildRotateDexterAuthorityInstruction(p) {
|
|
|
446
511
|
}
|
|
447
512
|
|
|
448
513
|
// src/instructions/provePasskey.ts
|
|
449
|
-
var
|
|
514
|
+
var import_web311 = require("@solana/web3.js");
|
|
450
515
|
function encodeBytesVec4(buf) {
|
|
451
516
|
const out = Buffer.alloc(4 + buf.length);
|
|
452
517
|
out.writeUInt32LE(buf.length, 0);
|
|
@@ -466,11 +531,11 @@ function buildProvePasskeyInstruction(p) {
|
|
|
466
531
|
encodeBytesVec4(p.authenticatorData)
|
|
467
532
|
]);
|
|
468
533
|
const data = Buffer.concat([Buffer.from(DISCRIMINATORS.prove_passkey), argsBuf]);
|
|
469
|
-
return new
|
|
534
|
+
return new import_web311.TransactionInstruction({
|
|
470
535
|
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
471
536
|
keys: [
|
|
472
537
|
{ pubkey: p.vaultPda, isSigner: false, isWritable: false },
|
|
473
|
-
{ pubkey:
|
|
538
|
+
{ pubkey: import_web311.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false }
|
|
474
539
|
],
|
|
475
540
|
data
|
|
476
541
|
});
|
|
@@ -4870,7 +4935,7 @@ function createSolanaRpcFromTransport(transport) {
|
|
|
4870
4935
|
|
|
4871
4936
|
// src/instructions/swigBundle.ts
|
|
4872
4937
|
var bs58Module = __toESM(require("bs58"), 1);
|
|
4873
|
-
var
|
|
4938
|
+
var import_web312 = require("@solana/web3.js");
|
|
4874
4939
|
var bs58 = bs58Module.default ?? bs58Module;
|
|
4875
4940
|
var SWIG_ID_DOMAIN = "dexter-swig-id:v1:";
|
|
4876
4941
|
var DEFAULT_SESSION_TTL_SECONDS = BigInt(30 * 24 * 60 * 60);
|
|
@@ -4986,7 +5051,7 @@ function deriveVaultPda(supabaseUserId) {
|
|
|
4986
5051
|
if (supabaseUserId.length !== 16) {
|
|
4987
5052
|
throw new Error("supabaseUserId must be 16 bytes (UUID v4)");
|
|
4988
5053
|
}
|
|
4989
|
-
const [pda, bump] =
|
|
5054
|
+
const [pda, bump] = import_web312.PublicKey.findProgramAddressSync(
|
|
4990
5055
|
[Buffer.from("vault"), Buffer.from(supabaseUserId)],
|
|
4991
5056
|
DEXTER_VAULT_PROGRAM_ID
|
|
4992
5057
|
);
|
|
@@ -4994,6 +5059,7 @@ function deriveVaultPda(supabaseUserId) {
|
|
|
4994
5059
|
}
|
|
4995
5060
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4996
5061
|
0 && (module.exports = {
|
|
5062
|
+
SET_SWIG_ATOMIC_DISCRIMINATOR,
|
|
4997
5063
|
SWIG_PROGRAM_EXEC_MARKERS,
|
|
4998
5064
|
SWIG_PROGRAM_EXEC_PREFIX,
|
|
4999
5065
|
SWIG_PROGRAM_EXEC_PREFIX_SETTLE_TAB,
|
|
@@ -5006,6 +5072,7 @@ function deriveVaultPda(supabaseUserId) {
|
|
|
5006
5072
|
buildRevokeSessionKeyInstruction,
|
|
5007
5073
|
buildRotateDexterAuthorityInstruction,
|
|
5008
5074
|
buildRotatePasskeyInstruction,
|
|
5075
|
+
buildSetSwigAtomicInstruction,
|
|
5009
5076
|
buildSetSwigInstruction,
|
|
5010
5077
|
buildSettleTabVoucherInstruction,
|
|
5011
5078
|
buildSettleVoucherInstruction,
|
|
@@ -38,6 +38,54 @@ interface SetSwigParams {
|
|
|
38
38
|
}
|
|
39
39
|
declare function buildSetSwigInstruction(p: SetSwigParams): TransactionInstruction;
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* buildSetSwigAtomicInstruction — single-tx warmup builder.
|
|
43
|
+
*
|
|
44
|
+
* Companion of buildSetSwigInstruction. Where set_swig binds a pre-existing
|
|
45
|
+
* Swig to a vault, set_swig_atomic CREATES the Swig (with the 4-role layout
|
|
46
|
+
* buildSwigCreationBundle produces) AND binds it — all in one ix that the
|
|
47
|
+
* vault program executes via Swig CPIs.
|
|
48
|
+
*
|
|
49
|
+
* Wire format matches the on-chain Anchor handler's SetSwigAtomicArgs layout:
|
|
50
|
+
*
|
|
51
|
+
* discriminator (8)
|
|
52
|
+
* || swig_id (32)
|
|
53
|
+
* || swig_account_bump (1)
|
|
54
|
+
* || swig_wallet_address_bump (1)
|
|
55
|
+
* || dexter_master_pubkey (32)
|
|
56
|
+
* || client_data_json_len (4 LE) || client_data_json (variable)
|
|
57
|
+
* || authenticator_data_len (4 LE) || authenticator_data (variable)
|
|
58
|
+
*
|
|
59
|
+
* Discriminator (locked by Anchor's sha256("global:set_swig_atomic")[0..8]):
|
|
60
|
+
* 77 6f f7 d7 be 03 aa 17
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/** Anchor instruction discriminator = sha256("global:set_swig_atomic")[0..8].
|
|
64
|
+
* Captured from target/idl/dexter_vault.json after `anchor build` on commit 49aae30. */
|
|
65
|
+
declare const SET_SWIG_ATOMIC_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
|
|
66
|
+
interface BuildSetSwigAtomicParams {
|
|
67
|
+
/** dexter-vault PDA — written to (vault.swig_address is updated). */
|
|
68
|
+
vaultPda: PublicKey;
|
|
69
|
+
/** Swig state account PDA (derived from swig_id + Swig program). */
|
|
70
|
+
swigAddress: PublicKey;
|
|
71
|
+
/** Swig wallet PDA (different from swigAddress — it's the spending authority address). */
|
|
72
|
+
swigWalletAddress: PublicKey;
|
|
73
|
+
/** Outer-tx signer + role-0 bootstrap authority + rent payer for the new Swig. */
|
|
74
|
+
feePayer: PublicKey;
|
|
75
|
+
/** Becomes role-2 (Ed25519Session) authority. */
|
|
76
|
+
dexterMasterPubkey: PublicKey;
|
|
77
|
+
/** 32-byte Swig ID (the seed used to derive swigAddress). */
|
|
78
|
+
swigId: Uint8Array;
|
|
79
|
+
/** Bump for swigAddress = findProgramAddress(swig_account_seeds(swigId), SWIG_PROGRAM_ID). */
|
|
80
|
+
swigAccountBump: number;
|
|
81
|
+
/** Bump for swigWalletAddress PDA. */
|
|
82
|
+
swigWalletAddressBump: number;
|
|
83
|
+
/** WebAuthn ceremony output. */
|
|
84
|
+
clientDataJSON: Uint8Array;
|
|
85
|
+
authenticatorData: Uint8Array;
|
|
86
|
+
}
|
|
87
|
+
declare function buildSetSwigAtomicInstruction(params: BuildSetSwigAtomicParams): TransactionInstruction;
|
|
88
|
+
|
|
41
89
|
/**
|
|
42
90
|
* register_session_key — authorize a session ed25519 key under a vault.
|
|
43
91
|
*
|
|
@@ -287,4 +335,4 @@ declare function deriveVaultPda(supabaseUserId: Uint8Array): {
|
|
|
287
335
|
bump: number;
|
|
288
336
|
};
|
|
289
337
|
|
|
290
|
-
export { type BuildRegisterSessionKeyArgs, type BuildRevokeSessionKeyArgs, type BuildSwigCreationBundleParams, type FinalizeWithdrawalParams, type ForceReleaseParams, type InitializeVaultParams, type ProvePasskeyParams, type RequestWithdrawalParams, type RotateDexterAuthorityParams, type RotatePasskeyParams, SWIG_PROGRAM_EXEC_MARKERS, SWIG_PROGRAM_EXEC_PREFIX, SWIG_PROGRAM_EXEC_PREFIX_SETTLE_TAB, type SetSwigParams, type SettleTabVoucherParams, type SettleVoucherParams, type SwigCreationBundleOutput, type SwigOwnershipCheck, buildFinalizeWithdrawalInstruction, buildForceReleaseInstruction, buildInitializeVaultInstruction, buildProvePasskeyInstruction, buildRegisterSessionKeyInstruction, buildRequestWithdrawalInstruction, buildRevokeSessionKeyInstruction, buildRotateDexterAuthorityInstruction, buildRotatePasskeyInstruction, buildSetSwigInstruction, buildSettleTabVoucherInstruction, buildSettleVoucherInstruction, buildSwigCreationBundle, deriveSwigWalletAddress, deriveVaultPda, expectedSwigAddressFor, verifySwigIsOurs };
|
|
338
|
+
export { type BuildRegisterSessionKeyArgs, type BuildRevokeSessionKeyArgs, type BuildSetSwigAtomicParams, type BuildSwigCreationBundleParams, type FinalizeWithdrawalParams, type ForceReleaseParams, type InitializeVaultParams, type ProvePasskeyParams, type RequestWithdrawalParams, type RotateDexterAuthorityParams, type RotatePasskeyParams, SET_SWIG_ATOMIC_DISCRIMINATOR, SWIG_PROGRAM_EXEC_MARKERS, SWIG_PROGRAM_EXEC_PREFIX, SWIG_PROGRAM_EXEC_PREFIX_SETTLE_TAB, type SetSwigParams, type SettleTabVoucherParams, type SettleVoucherParams, type SwigCreationBundleOutput, type SwigOwnershipCheck, buildFinalizeWithdrawalInstruction, buildForceReleaseInstruction, buildInitializeVaultInstruction, buildProvePasskeyInstruction, buildRegisterSessionKeyInstruction, buildRequestWithdrawalInstruction, buildRevokeSessionKeyInstruction, buildRotateDexterAuthorityInstruction, buildRotatePasskeyInstruction, buildSetSwigAtomicInstruction, buildSetSwigInstruction, buildSettleTabVoucherInstruction, buildSettleVoucherInstruction, buildSwigCreationBundle, deriveSwigWalletAddress, deriveVaultPda, expectedSwigAddressFor, verifySwigIsOurs };
|
|
@@ -38,6 +38,54 @@ interface SetSwigParams {
|
|
|
38
38
|
}
|
|
39
39
|
declare function buildSetSwigInstruction(p: SetSwigParams): TransactionInstruction;
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* buildSetSwigAtomicInstruction — single-tx warmup builder.
|
|
43
|
+
*
|
|
44
|
+
* Companion of buildSetSwigInstruction. Where set_swig binds a pre-existing
|
|
45
|
+
* Swig to a vault, set_swig_atomic CREATES the Swig (with the 4-role layout
|
|
46
|
+
* buildSwigCreationBundle produces) AND binds it — all in one ix that the
|
|
47
|
+
* vault program executes via Swig CPIs.
|
|
48
|
+
*
|
|
49
|
+
* Wire format matches the on-chain Anchor handler's SetSwigAtomicArgs layout:
|
|
50
|
+
*
|
|
51
|
+
* discriminator (8)
|
|
52
|
+
* || swig_id (32)
|
|
53
|
+
* || swig_account_bump (1)
|
|
54
|
+
* || swig_wallet_address_bump (1)
|
|
55
|
+
* || dexter_master_pubkey (32)
|
|
56
|
+
* || client_data_json_len (4 LE) || client_data_json (variable)
|
|
57
|
+
* || authenticator_data_len (4 LE) || authenticator_data (variable)
|
|
58
|
+
*
|
|
59
|
+
* Discriminator (locked by Anchor's sha256("global:set_swig_atomic")[0..8]):
|
|
60
|
+
* 77 6f f7 d7 be 03 aa 17
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/** Anchor instruction discriminator = sha256("global:set_swig_atomic")[0..8].
|
|
64
|
+
* Captured from target/idl/dexter_vault.json after `anchor build` on commit 49aae30. */
|
|
65
|
+
declare const SET_SWIG_ATOMIC_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
|
|
66
|
+
interface BuildSetSwigAtomicParams {
|
|
67
|
+
/** dexter-vault PDA — written to (vault.swig_address is updated). */
|
|
68
|
+
vaultPda: PublicKey;
|
|
69
|
+
/** Swig state account PDA (derived from swig_id + Swig program). */
|
|
70
|
+
swigAddress: PublicKey;
|
|
71
|
+
/** Swig wallet PDA (different from swigAddress — it's the spending authority address). */
|
|
72
|
+
swigWalletAddress: PublicKey;
|
|
73
|
+
/** Outer-tx signer + role-0 bootstrap authority + rent payer for the new Swig. */
|
|
74
|
+
feePayer: PublicKey;
|
|
75
|
+
/** Becomes role-2 (Ed25519Session) authority. */
|
|
76
|
+
dexterMasterPubkey: PublicKey;
|
|
77
|
+
/** 32-byte Swig ID (the seed used to derive swigAddress). */
|
|
78
|
+
swigId: Uint8Array;
|
|
79
|
+
/** Bump for swigAddress = findProgramAddress(swig_account_seeds(swigId), SWIG_PROGRAM_ID). */
|
|
80
|
+
swigAccountBump: number;
|
|
81
|
+
/** Bump for swigWalletAddress PDA. */
|
|
82
|
+
swigWalletAddressBump: number;
|
|
83
|
+
/** WebAuthn ceremony output. */
|
|
84
|
+
clientDataJSON: Uint8Array;
|
|
85
|
+
authenticatorData: Uint8Array;
|
|
86
|
+
}
|
|
87
|
+
declare function buildSetSwigAtomicInstruction(params: BuildSetSwigAtomicParams): TransactionInstruction;
|
|
88
|
+
|
|
41
89
|
/**
|
|
42
90
|
* register_session_key — authorize a session ed25519 key under a vault.
|
|
43
91
|
*
|
|
@@ -287,4 +335,4 @@ declare function deriveVaultPda(supabaseUserId: Uint8Array): {
|
|
|
287
335
|
bump: number;
|
|
288
336
|
};
|
|
289
337
|
|
|
290
|
-
export { type BuildRegisterSessionKeyArgs, type BuildRevokeSessionKeyArgs, type BuildSwigCreationBundleParams, type FinalizeWithdrawalParams, type ForceReleaseParams, type InitializeVaultParams, type ProvePasskeyParams, type RequestWithdrawalParams, type RotateDexterAuthorityParams, type RotatePasskeyParams, SWIG_PROGRAM_EXEC_MARKERS, SWIG_PROGRAM_EXEC_PREFIX, SWIG_PROGRAM_EXEC_PREFIX_SETTLE_TAB, type SetSwigParams, type SettleTabVoucherParams, type SettleVoucherParams, type SwigCreationBundleOutput, type SwigOwnershipCheck, buildFinalizeWithdrawalInstruction, buildForceReleaseInstruction, buildInitializeVaultInstruction, buildProvePasskeyInstruction, buildRegisterSessionKeyInstruction, buildRequestWithdrawalInstruction, buildRevokeSessionKeyInstruction, buildRotateDexterAuthorityInstruction, buildRotatePasskeyInstruction, buildSetSwigInstruction, buildSettleTabVoucherInstruction, buildSettleVoucherInstruction, buildSwigCreationBundle, deriveSwigWalletAddress, deriveVaultPda, expectedSwigAddressFor, verifySwigIsOurs };
|
|
338
|
+
export { type BuildRegisterSessionKeyArgs, type BuildRevokeSessionKeyArgs, type BuildSetSwigAtomicParams, type BuildSwigCreationBundleParams, type FinalizeWithdrawalParams, type ForceReleaseParams, type InitializeVaultParams, type ProvePasskeyParams, type RequestWithdrawalParams, type RotateDexterAuthorityParams, type RotatePasskeyParams, SET_SWIG_ATOMIC_DISCRIMINATOR, SWIG_PROGRAM_EXEC_MARKERS, SWIG_PROGRAM_EXEC_PREFIX, SWIG_PROGRAM_EXEC_PREFIX_SETTLE_TAB, type SetSwigParams, type SettleTabVoucherParams, type SettleVoucherParams, type SwigCreationBundleOutput, type SwigOwnershipCheck, buildFinalizeWithdrawalInstruction, buildForceReleaseInstruction, buildInitializeVaultInstruction, buildProvePasskeyInstruction, buildRegisterSessionKeyInstruction, buildRequestWithdrawalInstruction, buildRevokeSessionKeyInstruction, buildRotateDexterAuthorityInstruction, buildRotatePasskeyInstruction, buildSetSwigAtomicInstruction, buildSetSwigInstruction, buildSettleTabVoucherInstruction, buildSettleVoucherInstruction, buildSwigCreationBundle, deriveSwigWalletAddress, deriveVaultPda, expectedSwigAddressFor, verifySwigIsOurs };
|
|
@@ -110,8 +110,75 @@ function buildSetSwigInstruction(p) {
|
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
// src/instructions/setSwigAtomic.ts
|
|
114
|
+
import {
|
|
115
|
+
TransactionInstruction as TransactionInstruction3,
|
|
116
|
+
SystemProgram as SystemProgram2,
|
|
117
|
+
SYSVAR_INSTRUCTIONS_PUBKEY as SYSVAR_INSTRUCTIONS_PUBKEY2
|
|
118
|
+
} from "@solana/web3.js";
|
|
119
|
+
var SET_SWIG_ATOMIC_DISCRIMINATOR = new Uint8Array([
|
|
120
|
+
119,
|
|
121
|
+
111,
|
|
122
|
+
247,
|
|
123
|
+
215,
|
|
124
|
+
190,
|
|
125
|
+
3,
|
|
126
|
+
170,
|
|
127
|
+
23
|
|
128
|
+
]);
|
|
129
|
+
function buildSetSwigAtomicInstruction(params) {
|
|
130
|
+
if (params.swigId.length !== 32) {
|
|
131
|
+
throw new Error(`swigId must be 32 bytes, got ${params.swigId.length}`);
|
|
132
|
+
}
|
|
133
|
+
if (params.authenticatorData.length < 37) {
|
|
134
|
+
throw new Error(`authenticatorData must be at least 37 bytes`);
|
|
135
|
+
}
|
|
136
|
+
const cdj = params.clientDataJSON;
|
|
137
|
+
const ad = params.authenticatorData;
|
|
138
|
+
const dataLen = 8 + // discriminator
|
|
139
|
+
32 + // swig_id
|
|
140
|
+
1 + // swig_account_bump
|
|
141
|
+
1 + // swig_wallet_address_bump
|
|
142
|
+
32 + // dexter_master_pubkey
|
|
143
|
+
4 + cdj.length + // client_data_json (len-prefixed)
|
|
144
|
+
4 + ad.length;
|
|
145
|
+
const data = new Uint8Array(dataLen);
|
|
146
|
+
const view = new DataView(data.buffer);
|
|
147
|
+
let off = 0;
|
|
148
|
+
data.set(SET_SWIG_ATOMIC_DISCRIMINATOR, off);
|
|
149
|
+
off += 8;
|
|
150
|
+
data.set(params.swigId, off);
|
|
151
|
+
off += 32;
|
|
152
|
+
data[off++] = params.swigAccountBump;
|
|
153
|
+
data[off++] = params.swigWalletAddressBump;
|
|
154
|
+
data.set(params.dexterMasterPubkey.toBytes(), off);
|
|
155
|
+
off += 32;
|
|
156
|
+
view.setUint32(off, cdj.length, true);
|
|
157
|
+
off += 4;
|
|
158
|
+
data.set(cdj, off);
|
|
159
|
+
off += cdj.length;
|
|
160
|
+
view.setUint32(off, ad.length, true);
|
|
161
|
+
off += 4;
|
|
162
|
+
data.set(ad, off);
|
|
163
|
+
off += ad.length;
|
|
164
|
+
if (off !== dataLen) throw new Error(`internal: byte offset mismatch (${off} vs ${dataLen})`);
|
|
165
|
+
return new TransactionInstruction3({
|
|
166
|
+
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
167
|
+
keys: [
|
|
168
|
+
{ pubkey: params.vaultPda, isSigner: false, isWritable: true },
|
|
169
|
+
{ pubkey: params.feePayer, isSigner: true, isWritable: true },
|
|
170
|
+
{ pubkey: params.swigAddress, isSigner: false, isWritable: true },
|
|
171
|
+
{ pubkey: params.swigWalletAddress, isSigner: false, isWritable: true },
|
|
172
|
+
{ pubkey: SWIG_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
173
|
+
{ pubkey: SystemProgram2.programId, isSigner: false, isWritable: false },
|
|
174
|
+
{ pubkey: SYSVAR_INSTRUCTIONS_PUBKEY2, isSigner: false, isWritable: false }
|
|
175
|
+
],
|
|
176
|
+
data: Buffer.from(data)
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
113
180
|
// src/instructions/registerSession.ts
|
|
114
|
-
import { TransactionInstruction as
|
|
181
|
+
import { TransactionInstruction as TransactionInstruction4 } from "@solana/web3.js";
|
|
115
182
|
function encodeU64LE(value) {
|
|
116
183
|
const buf = new Uint8Array(8);
|
|
117
184
|
new DataView(buf.buffer).setBigUint64(0, value, true);
|
|
@@ -157,7 +224,7 @@ function buildRegisterSessionKeyInstruction(args) {
|
|
|
157
224
|
encodeVecU8(args.clientDataJSON),
|
|
158
225
|
encodeVecU8(args.authenticatorData)
|
|
159
226
|
);
|
|
160
|
-
return new
|
|
227
|
+
return new TransactionInstruction4({
|
|
161
228
|
keys: [
|
|
162
229
|
{ pubkey: args.vaultPda, isSigner: false, isWritable: true },
|
|
163
230
|
{ pubkey: INSTRUCTIONS_SYSVAR_ID, isSigner: false, isWritable: false }
|
|
@@ -168,7 +235,7 @@ function buildRegisterSessionKeyInstruction(args) {
|
|
|
168
235
|
}
|
|
169
236
|
|
|
170
237
|
// src/instructions/revokeSession.ts
|
|
171
|
-
import { TransactionInstruction as
|
|
238
|
+
import { TransactionInstruction as TransactionInstruction5 } from "@solana/web3.js";
|
|
172
239
|
function encodeVecU82(bytes) {
|
|
173
240
|
const out = new Uint8Array(4 + bytes.length);
|
|
174
241
|
new DataView(out.buffer).setUint32(0, bytes.length >>> 0, true);
|
|
@@ -191,7 +258,7 @@ function buildRevokeSessionKeyInstruction(args) {
|
|
|
191
258
|
encodeVecU82(args.clientDataJSON),
|
|
192
259
|
encodeVecU82(args.authenticatorData)
|
|
193
260
|
);
|
|
194
|
-
return new
|
|
261
|
+
return new TransactionInstruction5({
|
|
195
262
|
keys: [
|
|
196
263
|
{ pubkey: args.vaultPda, isSigner: false, isWritable: true },
|
|
197
264
|
{ pubkey: INSTRUCTIONS_SYSVAR_ID, isSigner: false, isWritable: false }
|
|
@@ -202,7 +269,7 @@ function buildRevokeSessionKeyInstruction(args) {
|
|
|
202
269
|
}
|
|
203
270
|
|
|
204
271
|
// src/instructions/settleVoucher.ts
|
|
205
|
-
import { TransactionInstruction as
|
|
272
|
+
import { TransactionInstruction as TransactionInstruction6 } from "@solana/web3.js";
|
|
206
273
|
function encodeU64(value) {
|
|
207
274
|
const out = Buffer.alloc(8);
|
|
208
275
|
out.writeBigUInt64LE(value, 0);
|
|
@@ -214,7 +281,7 @@ function encodeBool(value) {
|
|
|
214
281
|
function buildSettleVoucherInstruction(p) {
|
|
215
282
|
const argsBuf = Buffer.concat([encodeU64(p.amount), encodeBool(p.increment)]);
|
|
216
283
|
const data = Buffer.concat([Buffer.from(DISCRIMINATORS.settle_voucher), argsBuf]);
|
|
217
|
-
return new
|
|
284
|
+
return new TransactionInstruction6({
|
|
218
285
|
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
219
286
|
keys: [
|
|
220
287
|
{ pubkey: p.vaultPda, isSigner: false, isWritable: true },
|
|
@@ -226,15 +293,15 @@ function buildSettleVoucherInstruction(p) {
|
|
|
226
293
|
|
|
227
294
|
// src/instructions/settleTabVoucher.ts
|
|
228
295
|
import {
|
|
229
|
-
TransactionInstruction as
|
|
230
|
-
SYSVAR_INSTRUCTIONS_PUBKEY as
|
|
296
|
+
TransactionInstruction as TransactionInstruction8,
|
|
297
|
+
SYSVAR_INSTRUCTIONS_PUBKEY as SYSVAR_INSTRUCTIONS_PUBKEY4
|
|
231
298
|
} from "@solana/web3.js";
|
|
232
299
|
|
|
233
300
|
// src/instructions/withdraw.ts
|
|
234
301
|
import {
|
|
235
|
-
PublicKey as
|
|
236
|
-
TransactionInstruction as
|
|
237
|
-
SYSVAR_INSTRUCTIONS_PUBKEY as
|
|
302
|
+
PublicKey as PublicKey8,
|
|
303
|
+
TransactionInstruction as TransactionInstruction7,
|
|
304
|
+
SYSVAR_INSTRUCTIONS_PUBKEY as SYSVAR_INSTRUCTIONS_PUBKEY3
|
|
238
305
|
} from "@solana/web3.js";
|
|
239
306
|
function encodeBytesVec2(buf) {
|
|
240
307
|
const out = Buffer.alloc(4 + buf.length);
|
|
@@ -256,7 +323,7 @@ function encodePubkey2(key) {
|
|
|
256
323
|
return Buffer.from(key.toBytes());
|
|
257
324
|
}
|
|
258
325
|
function deriveSwigWalletAddress(swigAddress) {
|
|
259
|
-
const [pda] =
|
|
326
|
+
const [pda] = PublicKey8.findProgramAddressSync(
|
|
260
327
|
[Buffer.from("swig-wallet-address"), swigAddress.toBuffer()],
|
|
261
328
|
SWIG_PROGRAM_ID
|
|
262
329
|
);
|
|
@@ -271,11 +338,11 @@ function buildRequestWithdrawalInstruction(p) {
|
|
|
271
338
|
encodeBytesVec2(p.authenticatorData)
|
|
272
339
|
]);
|
|
273
340
|
const data = Buffer.concat([Buffer.from(DISCRIMINATORS.request_withdrawal), argsBuf]);
|
|
274
|
-
return new
|
|
341
|
+
return new TransactionInstruction7({
|
|
275
342
|
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
276
343
|
keys: [
|
|
277
344
|
{ pubkey: p.vaultPda, isSigner: false, isWritable: true },
|
|
278
|
-
{ pubkey:
|
|
345
|
+
{ pubkey: SYSVAR_INSTRUCTIONS_PUBKEY3, isSigner: false, isWritable: false }
|
|
279
346
|
],
|
|
280
347
|
data
|
|
281
348
|
});
|
|
@@ -287,13 +354,13 @@ function buildFinalizeWithdrawalInstruction(p) {
|
|
|
287
354
|
]);
|
|
288
355
|
const data = Buffer.concat([Buffer.from(DISCRIMINATORS.finalize_withdrawal), argsBuf]);
|
|
289
356
|
const swigWalletAddress = deriveSwigWalletAddress(p.swigAddress);
|
|
290
|
-
return new
|
|
357
|
+
return new TransactionInstruction7({
|
|
291
358
|
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
292
359
|
keys: [
|
|
293
360
|
{ pubkey: p.swigAddress, isSigner: false, isWritable: false },
|
|
294
361
|
{ pubkey: swigWalletAddress, isSigner: false, isWritable: false },
|
|
295
362
|
{ pubkey: p.vaultPda, isSigner: false, isWritable: true },
|
|
296
|
-
{ pubkey:
|
|
363
|
+
{ pubkey: SYSVAR_INSTRUCTIONS_PUBKEY3, isSigner: false, isWritable: false }
|
|
297
364
|
],
|
|
298
365
|
data
|
|
299
366
|
});
|
|
@@ -304,11 +371,11 @@ function buildForceReleaseInstruction(p) {
|
|
|
304
371
|
encodeBytesVec2(p.authenticatorData)
|
|
305
372
|
]);
|
|
306
373
|
const data = Buffer.concat([Buffer.from(DISCRIMINATORS.force_release), argsBuf]);
|
|
307
|
-
return new
|
|
374
|
+
return new TransactionInstruction7({
|
|
308
375
|
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
309
376
|
keys: [
|
|
310
377
|
{ pubkey: p.vaultPda, isSigner: false, isWritable: true },
|
|
311
|
-
{ pubkey:
|
|
378
|
+
{ pubkey: SYSVAR_INSTRUCTIONS_PUBKEY3, isSigner: false, isWritable: false }
|
|
312
379
|
],
|
|
313
380
|
data
|
|
314
381
|
});
|
|
@@ -342,14 +409,14 @@ function buildSettleTabVoucherInstruction(p) {
|
|
|
342
409
|
]);
|
|
343
410
|
const data = Buffer.concat([Buffer.from(DISCRIMINATORS.settle_tab_voucher), argsBuf]);
|
|
344
411
|
const swigWalletAddress = deriveSwigWalletAddress(p.swigAddress);
|
|
345
|
-
return new
|
|
412
|
+
return new TransactionInstruction8({
|
|
346
413
|
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
347
414
|
keys: [
|
|
348
415
|
{ pubkey: p.swigAddress, isSigner: false, isWritable: false },
|
|
349
416
|
{ pubkey: swigWalletAddress, isSigner: false, isWritable: false },
|
|
350
417
|
{ pubkey: p.vaultPda, isSigner: false, isWritable: true },
|
|
351
418
|
{ pubkey: p.dexterAuthority, isSigner: true, isWritable: false },
|
|
352
|
-
{ pubkey:
|
|
419
|
+
{ pubkey: SYSVAR_INSTRUCTIONS_PUBKEY4, isSigner: false, isWritable: false }
|
|
353
420
|
],
|
|
354
421
|
data
|
|
355
422
|
});
|
|
@@ -357,8 +424,8 @@ function buildSettleTabVoucherInstruction(p) {
|
|
|
357
424
|
|
|
358
425
|
// src/instructions/rotate.ts
|
|
359
426
|
import {
|
|
360
|
-
TransactionInstruction as
|
|
361
|
-
SYSVAR_INSTRUCTIONS_PUBKEY as
|
|
427
|
+
TransactionInstruction as TransactionInstruction9,
|
|
428
|
+
SYSVAR_INSTRUCTIONS_PUBKEY as SYSVAR_INSTRUCTIONS_PUBKEY5
|
|
362
429
|
} from "@solana/web3.js";
|
|
363
430
|
function encodeBytesVec3(buf) {
|
|
364
431
|
const out = Buffer.alloc(4 + buf.length);
|
|
@@ -382,11 +449,11 @@ function buildRotatePasskeyInstruction(p) {
|
|
|
382
449
|
encodeBytesVec3(p.authenticatorData)
|
|
383
450
|
]);
|
|
384
451
|
const data = Buffer.concat([Buffer.from(DISCRIMINATORS.rotate_passkey), argsBuf]);
|
|
385
|
-
return new
|
|
452
|
+
return new TransactionInstruction9({
|
|
386
453
|
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
387
454
|
keys: [
|
|
388
455
|
{ pubkey: p.vaultPda, isSigner: false, isWritable: true },
|
|
389
|
-
{ pubkey:
|
|
456
|
+
{ pubkey: SYSVAR_INSTRUCTIONS_PUBKEY5, isSigner: false, isWritable: false }
|
|
390
457
|
],
|
|
391
458
|
data
|
|
392
459
|
});
|
|
@@ -396,7 +463,7 @@ function buildRotateDexterAuthorityInstruction(p) {
|
|
|
396
463
|
Buffer.from(DISCRIMINATORS.rotate_dexter_authority),
|
|
397
464
|
encodePubkey3(p.newDexterAuthority)
|
|
398
465
|
]);
|
|
399
|
-
return new
|
|
466
|
+
return new TransactionInstruction9({
|
|
400
467
|
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
401
468
|
keys: [
|
|
402
469
|
{ pubkey: p.vaultPda, isSigner: false, isWritable: true },
|
|
@@ -408,8 +475,8 @@ function buildRotateDexterAuthorityInstruction(p) {
|
|
|
408
475
|
|
|
409
476
|
// src/instructions/provePasskey.ts
|
|
410
477
|
import {
|
|
411
|
-
TransactionInstruction as
|
|
412
|
-
SYSVAR_INSTRUCTIONS_PUBKEY as
|
|
478
|
+
TransactionInstruction as TransactionInstruction10,
|
|
479
|
+
SYSVAR_INSTRUCTIONS_PUBKEY as SYSVAR_INSTRUCTIONS_PUBKEY6
|
|
413
480
|
} from "@solana/web3.js";
|
|
414
481
|
function encodeBytesVec4(buf) {
|
|
415
482
|
const out = Buffer.alloc(4 + buf.length);
|
|
@@ -430,11 +497,11 @@ function buildProvePasskeyInstruction(p) {
|
|
|
430
497
|
encodeBytesVec4(p.authenticatorData)
|
|
431
498
|
]);
|
|
432
499
|
const data = Buffer.concat([Buffer.from(DISCRIMINATORS.prove_passkey), argsBuf]);
|
|
433
|
-
return new
|
|
500
|
+
return new TransactionInstruction10({
|
|
434
501
|
programId: DEXTER_VAULT_PROGRAM_ID,
|
|
435
502
|
keys: [
|
|
436
503
|
{ pubkey: p.vaultPda, isSigner: false, isWritable: false },
|
|
437
|
-
{ pubkey:
|
|
504
|
+
{ pubkey: SYSVAR_INSTRUCTIONS_PUBKEY6, isSigner: false, isWritable: false }
|
|
438
505
|
],
|
|
439
506
|
data
|
|
440
507
|
});
|
|
@@ -4844,7 +4911,7 @@ function createSolanaRpcFromTransport(transport) {
|
|
|
4844
4911
|
|
|
4845
4912
|
// src/instructions/swigBundle.ts
|
|
4846
4913
|
import * as bs58Module from "bs58";
|
|
4847
|
-
import { PublicKey as
|
|
4914
|
+
import { PublicKey as PublicKey12 } from "@solana/web3.js";
|
|
4848
4915
|
var bs58 = bs58Module.default ?? bs58Module;
|
|
4849
4916
|
var SWIG_ID_DOMAIN = "dexter-swig-id:v1:";
|
|
4850
4917
|
var DEFAULT_SESSION_TTL_SECONDS = BigInt(30 * 24 * 60 * 60);
|
|
@@ -4960,13 +5027,14 @@ function deriveVaultPda(supabaseUserId) {
|
|
|
4960
5027
|
if (supabaseUserId.length !== 16) {
|
|
4961
5028
|
throw new Error("supabaseUserId must be 16 bytes (UUID v4)");
|
|
4962
5029
|
}
|
|
4963
|
-
const [pda, bump] =
|
|
5030
|
+
const [pda, bump] = PublicKey12.findProgramAddressSync(
|
|
4964
5031
|
[Buffer.from("vault"), Buffer.from(supabaseUserId)],
|
|
4965
5032
|
DEXTER_VAULT_PROGRAM_ID
|
|
4966
5033
|
);
|
|
4967
5034
|
return { pda, bump };
|
|
4968
5035
|
}
|
|
4969
5036
|
export {
|
|
5037
|
+
SET_SWIG_ATOMIC_DISCRIMINATOR,
|
|
4970
5038
|
SWIG_PROGRAM_EXEC_MARKERS,
|
|
4971
5039
|
SWIG_PROGRAM_EXEC_PREFIX,
|
|
4972
5040
|
SWIG_PROGRAM_EXEC_PREFIX_SETTLE_TAB,
|
|
@@ -4979,6 +5047,7 @@ export {
|
|
|
4979
5047
|
buildRevokeSessionKeyInstruction,
|
|
4980
5048
|
buildRotateDexterAuthorityInstruction,
|
|
4981
5049
|
buildRotatePasskeyInstruction,
|
|
5050
|
+
buildSetSwigAtomicInstruction,
|
|
4982
5051
|
buildSetSwigInstruction,
|
|
4983
5052
|
buildSettleTabVoucherInstruction,
|
|
4984
5053
|
buildSettleVoucherInstruction,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexterai/vault",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Canonical off-chain mirror of the dexter-vault Solana Anchor program — Solana instruction builders, byte-precise message encoders, account decoders, secp256r1/Ed25519 precompile helpers, counterfactual Swig derivation, and signer interfaces. The single source of truth for any TypeScript code that produces bytes the on-chain program will verify.",
|
|
5
5
|
"author": "Dexter",
|
|
6
6
|
"license": "MIT",
|