@dexterai/vault 0.2.1 → 0.3.1

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.
@@ -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 TransactionInstruction3 } from "@solana/web3.js";
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 TransactionInstruction3({
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 TransactionInstruction4 } from "@solana/web3.js";
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 TransactionInstruction4({
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 TransactionInstruction5 } from "@solana/web3.js";
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 TransactionInstruction5({
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 TransactionInstruction7,
230
- SYSVAR_INSTRUCTIONS_PUBKEY as SYSVAR_INSTRUCTIONS_PUBKEY3
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 PublicKey7,
236
- TransactionInstruction as TransactionInstruction6,
237
- SYSVAR_INSTRUCTIONS_PUBKEY as SYSVAR_INSTRUCTIONS_PUBKEY2
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] = PublicKey7.findProgramAddressSync(
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 TransactionInstruction6({
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: SYSVAR_INSTRUCTIONS_PUBKEY2, isSigner: false, isWritable: false }
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 TransactionInstruction6({
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: SYSVAR_INSTRUCTIONS_PUBKEY2, isSigner: false, isWritable: false }
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 TransactionInstruction6({
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: SYSVAR_INSTRUCTIONS_PUBKEY2, isSigner: false, isWritable: false }
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 TransactionInstruction7({
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: SYSVAR_INSTRUCTIONS_PUBKEY3, isSigner: false, isWritable: false }
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 TransactionInstruction8,
361
- SYSVAR_INSTRUCTIONS_PUBKEY as SYSVAR_INSTRUCTIONS_PUBKEY4
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 TransactionInstruction8({
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: SYSVAR_INSTRUCTIONS_PUBKEY4, isSigner: false, isWritable: false }
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 TransactionInstruction8({
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 TransactionInstruction9,
412
- SYSVAR_INSTRUCTIONS_PUBKEY as SYSVAR_INSTRUCTIONS_PUBKEY5
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 TransactionInstruction9({
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: SYSVAR_INSTRUCTIONS_PUBKEY5, isSigner: false, isWritable: false }
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 PublicKey11 } from "@solana/web3.js";
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] = PublicKey11.findProgramAddressSync(
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.2.1",
3
+ "version": "0.3.1",
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",
@@ -16,7 +16,8 @@
16
16
  "./precompile": { "types": "./dist/precompile/index.d.ts", "import": "./dist/precompile/index.js", "require": "./dist/precompile/index.cjs" },
17
17
  "./signers": { "types": "./dist/signers/types.d.ts", "import": "./dist/signers/types.js", "require": "./dist/signers/types.cjs" },
18
18
  "./signers/node": { "types": "./dist/signers/node/index.d.ts", "import": "./dist/signers/node/index.js", "require": "./dist/signers/node/index.cjs" },
19
- "./signers/browser": { "types": "./dist/signers/browser/index.d.ts", "import": "./dist/signers/browser/index.js", "require": "./dist/signers/browser/index.cjs" }
19
+ "./signers/browser": { "types": "./dist/signers/browser/index.d.ts", "import": "./dist/signers/browser/index.js", "require": "./dist/signers/browser/index.cjs" },
20
+ "./idl/dexter_vault.json": "./dist/idl/dexter_vault.json"
20
21
  },
21
22
  "files": ["dist", "README.md", "LICENSE", "assets"],
22
23
  "scripts": {