@dexterai/vault 0.4.1 → 0.4.2

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.
@@ -4776,7 +4776,90 @@ function buildSetSwigAtomicFromIdentity(params) {
4776
4776
  }
4777
4777
 
4778
4778
  // src/instructions/registerSession.ts
4779
+ var import_web37 = require("@solana/web3.js");
4780
+
4781
+ // src/instructions/withdraw.ts
4779
4782
  var import_web36 = require("@solana/web3.js");
4783
+ function encodeBytesVec2(buf) {
4784
+ const out = Buffer.alloc(4 + buf.length);
4785
+ out.writeUInt32LE(buf.length, 0);
4786
+ Buffer.from(buf).copy(out, 4);
4787
+ return out;
4788
+ }
4789
+ function encodeU64(value) {
4790
+ const out = Buffer.alloc(8);
4791
+ out.writeBigUInt64LE(value, 0);
4792
+ return out;
4793
+ }
4794
+ function encodeI64(value) {
4795
+ const out = Buffer.alloc(8);
4796
+ out.writeBigInt64LE(value, 0);
4797
+ return out;
4798
+ }
4799
+ function encodePubkey2(key) {
4800
+ return Buffer.from(key.toBytes());
4801
+ }
4802
+ function deriveSwigWalletAddress(swigAddress) {
4803
+ const [pda] = import_web36.PublicKey.findProgramAddressSync(
4804
+ [Buffer.from("swig-wallet-address"), swigAddress.toBuffer()],
4805
+ SWIG_PROGRAM_ID
4806
+ );
4807
+ return pda;
4808
+ }
4809
+ function buildRequestWithdrawalInstruction(p) {
4810
+ const argsBuf = Buffer.concat([
4811
+ encodeU64(p.amount),
4812
+ encodePubkey2(p.destination),
4813
+ encodeI64(p.signedAt),
4814
+ encodeBytesVec2(p.clientDataJSON),
4815
+ encodeBytesVec2(p.authenticatorData)
4816
+ ]);
4817
+ const data = Buffer.concat([Buffer.from(DISCRIMINATORS.request_withdrawal), argsBuf]);
4818
+ return new import_web36.TransactionInstruction({
4819
+ programId: DEXTER_VAULT_PROGRAM_ID,
4820
+ keys: [
4821
+ { pubkey: p.vaultPda, isSigner: false, isWritable: true },
4822
+ { pubkey: import_web36.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false }
4823
+ ],
4824
+ data
4825
+ });
4826
+ }
4827
+ function buildFinalizeWithdrawalInstruction(p) {
4828
+ const argsBuf = Buffer.concat([
4829
+ encodeBytesVec2(p.clientDataJSON),
4830
+ encodeBytesVec2(p.authenticatorData)
4831
+ ]);
4832
+ const data = Buffer.concat([Buffer.from(DISCRIMINATORS.finalize_withdrawal), argsBuf]);
4833
+ const swigWalletAddress = deriveSwigWalletAddress(p.swigAddress);
4834
+ return new import_web36.TransactionInstruction({
4835
+ programId: DEXTER_VAULT_PROGRAM_ID,
4836
+ keys: [
4837
+ { pubkey: p.swigAddress, isSigner: false, isWritable: false },
4838
+ { pubkey: swigWalletAddress, isSigner: false, isWritable: false },
4839
+ { pubkey: p.vaultPda, isSigner: false, isWritable: true },
4840
+ { pubkey: p.vaultUsdcAta, isSigner: false, isWritable: false },
4841
+ { pubkey: import_web36.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false }
4842
+ ],
4843
+ data
4844
+ });
4845
+ }
4846
+ function buildForceReleaseInstruction(p) {
4847
+ const argsBuf = Buffer.concat([
4848
+ encodeBytesVec2(p.clientDataJSON),
4849
+ encodeBytesVec2(p.authenticatorData)
4850
+ ]);
4851
+ const data = Buffer.concat([Buffer.from(DISCRIMINATORS.force_release), argsBuf]);
4852
+ return new import_web36.TransactionInstruction({
4853
+ programId: DEXTER_VAULT_PROGRAM_ID,
4854
+ keys: [
4855
+ { pubkey: p.vaultPda, isSigner: false, isWritable: true },
4856
+ { pubkey: import_web36.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false }
4857
+ ],
4858
+ data
4859
+ });
4860
+ }
4861
+
4862
+ // src/instructions/registerSession.ts
4780
4863
  function encodeU64LE(value) {
4781
4864
  const buf = new Uint8Array(8);
4782
4865
  new DataView(buf.buffer).setBigUint64(0, value, true);
@@ -4823,9 +4906,13 @@ function buildRegisterSessionKeyInstruction(args) {
4823
4906
  encodeVecU8(args.clientDataJSON),
4824
4907
  encodeVecU8(args.authenticatorData)
4825
4908
  );
4826
- return new import_web36.TransactionInstruction({
4909
+ const swigWalletAddress = deriveSwigWalletAddress(args.swigAddress);
4910
+ return new import_web37.TransactionInstruction({
4827
4911
  keys: [
4828
4912
  { pubkey: args.vaultPda, isSigner: false, isWritable: true },
4913
+ { pubkey: args.vaultUsdcAta, isSigner: false, isWritable: false },
4914
+ { pubkey: args.swigAddress, isSigner: false, isWritable: false },
4915
+ { pubkey: swigWalletAddress, isSigner: false, isWritable: false },
4829
4916
  { pubkey: INSTRUCTIONS_SYSVAR_ID, isSigner: false, isWritable: false }
4830
4917
  ],
4831
4918
  programId: DEXTER_VAULT_PROGRAM_ID,
@@ -4834,7 +4921,7 @@ function buildRegisterSessionKeyInstruction(args) {
4834
4921
  }
4835
4922
 
4836
4923
  // src/instructions/revokeSession.ts
4837
- var import_web37 = require("@solana/web3.js");
4924
+ var import_web38 = require("@solana/web3.js");
4838
4925
  function encodeVecU82(bytes) {
4839
4926
  const out = new Uint8Array(4 + bytes.length);
4840
4927
  new DataView(out.buffer).setUint32(0, bytes.length >>> 0, true);
@@ -4857,7 +4944,7 @@ function buildRevokeSessionKeyInstruction(args) {
4857
4944
  encodeVecU82(args.clientDataJSON),
4858
4945
  encodeVecU82(args.authenticatorData)
4859
4946
  );
4860
- return new import_web37.TransactionInstruction({
4947
+ return new import_web38.TransactionInstruction({
4861
4948
  keys: [
4862
4949
  { pubkey: args.vaultPda, isSigner: false, isWritable: true },
4863
4950
  { pubkey: INSTRUCTIONS_SYSVAR_ID, isSigner: false, isWritable: false }
@@ -4868,8 +4955,8 @@ function buildRevokeSessionKeyInstruction(args) {
4868
4955
  }
4869
4956
 
4870
4957
  // src/instructions/settleVoucher.ts
4871
- var import_web38 = require("@solana/web3.js");
4872
- function encodeU64(value) {
4958
+ var import_web39 = require("@solana/web3.js");
4959
+ function encodeU642(value) {
4873
4960
  const out = Buffer.alloc(8);
4874
4961
  out.writeBigUInt64LE(value, 0);
4875
4962
  return out;
@@ -4878,9 +4965,9 @@ function encodeBool(value) {
4878
4965
  return Buffer.from([value ? 1 : 0]);
4879
4966
  }
4880
4967
  function buildSettleVoucherInstruction(p) {
4881
- const argsBuf = Buffer.concat([encodeU64(p.amount), encodeBool(p.increment)]);
4968
+ const argsBuf = Buffer.concat([encodeU642(p.amount), encodeBool(p.increment)]);
4882
4969
  const data = Buffer.concat([Buffer.from(DISCRIMINATORS.settle_voucher), argsBuf]);
4883
- return new import_web38.TransactionInstruction({
4970
+ return new import_web39.TransactionInstruction({
4884
4971
  programId: DEXTER_VAULT_PROGRAM_ID,
4885
4972
  keys: [
4886
4973
  { pubkey: p.vaultPda, isSigner: false, isWritable: true },
@@ -4892,88 +4979,6 @@ function buildSettleVoucherInstruction(p) {
4892
4979
 
4893
4980
  // src/instructions/settleTabVoucher.ts
4894
4981
  var import_web310 = require("@solana/web3.js");
4895
-
4896
- // src/instructions/withdraw.ts
4897
- var import_web39 = require("@solana/web3.js");
4898
- function encodeBytesVec2(buf) {
4899
- const out = Buffer.alloc(4 + buf.length);
4900
- out.writeUInt32LE(buf.length, 0);
4901
- Buffer.from(buf).copy(out, 4);
4902
- return out;
4903
- }
4904
- function encodeU642(value) {
4905
- const out = Buffer.alloc(8);
4906
- out.writeBigUInt64LE(value, 0);
4907
- return out;
4908
- }
4909
- function encodeI64(value) {
4910
- const out = Buffer.alloc(8);
4911
- out.writeBigInt64LE(value, 0);
4912
- return out;
4913
- }
4914
- function encodePubkey2(key) {
4915
- return Buffer.from(key.toBytes());
4916
- }
4917
- function deriveSwigWalletAddress(swigAddress) {
4918
- const [pda] = import_web39.PublicKey.findProgramAddressSync(
4919
- [Buffer.from("swig-wallet-address"), swigAddress.toBuffer()],
4920
- SWIG_PROGRAM_ID
4921
- );
4922
- return pda;
4923
- }
4924
- function buildRequestWithdrawalInstruction(p) {
4925
- const argsBuf = Buffer.concat([
4926
- encodeU642(p.amount),
4927
- encodePubkey2(p.destination),
4928
- encodeI64(p.signedAt),
4929
- encodeBytesVec2(p.clientDataJSON),
4930
- encodeBytesVec2(p.authenticatorData)
4931
- ]);
4932
- const data = Buffer.concat([Buffer.from(DISCRIMINATORS.request_withdrawal), argsBuf]);
4933
- return new import_web39.TransactionInstruction({
4934
- programId: DEXTER_VAULT_PROGRAM_ID,
4935
- keys: [
4936
- { pubkey: p.vaultPda, isSigner: false, isWritable: true },
4937
- { pubkey: import_web39.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false }
4938
- ],
4939
- data
4940
- });
4941
- }
4942
- function buildFinalizeWithdrawalInstruction(p) {
4943
- const argsBuf = Buffer.concat([
4944
- encodeBytesVec2(p.clientDataJSON),
4945
- encodeBytesVec2(p.authenticatorData)
4946
- ]);
4947
- const data = Buffer.concat([Buffer.from(DISCRIMINATORS.finalize_withdrawal), argsBuf]);
4948
- const swigWalletAddress = deriveSwigWalletAddress(p.swigAddress);
4949
- return new import_web39.TransactionInstruction({
4950
- programId: DEXTER_VAULT_PROGRAM_ID,
4951
- keys: [
4952
- { pubkey: p.swigAddress, isSigner: false, isWritable: false },
4953
- { pubkey: swigWalletAddress, isSigner: false, isWritable: false },
4954
- { pubkey: p.vaultPda, isSigner: false, isWritable: true },
4955
- { pubkey: import_web39.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false }
4956
- ],
4957
- data
4958
- });
4959
- }
4960
- function buildForceReleaseInstruction(p) {
4961
- const argsBuf = Buffer.concat([
4962
- encodeBytesVec2(p.clientDataJSON),
4963
- encodeBytesVec2(p.authenticatorData)
4964
- ]);
4965
- const data = Buffer.concat([Buffer.from(DISCRIMINATORS.force_release), argsBuf]);
4966
- return new import_web39.TransactionInstruction({
4967
- programId: DEXTER_VAULT_PROGRAM_ID,
4968
- keys: [
4969
- { pubkey: p.vaultPda, isSigner: false, isWritable: true },
4970
- { pubkey: import_web39.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false }
4971
- ],
4972
- data
4973
- });
4974
- }
4975
-
4976
- // src/instructions/settleTabVoucher.ts
4977
4982
  function encodeFixedBytes2(buf, len) {
4978
4983
  if (buf.length !== len) {
4979
4984
  throw new Error(`expected ${len} bytes, got ${buf.length}`);
@@ -125,7 +125,11 @@ declare function buildSetSwigAtomicFromIdentity(params: BuildSetSwigAtomicFromId
125
125
  *
126
126
  * Accounts (in declaration order — Anchor is strict):
127
127
  * 0. [writable] vault — the Vault PDA being mutated
128
- * 1. [readonly] instructions_sysvar address-constrained
128
+ * 1. [readonly] vault_usdc_ata swig wallet's USDC ATA, read live
129
+ * for the Phase 1 overcommit gate
130
+ * 2. [readonly] swig — the vault's swig account (== vault.swig_address)
131
+ * 3. [readonly] swig_wallet_address — canonical PDA under the Swig program (derived)
132
+ * 4. [readonly] instructions_sysvar — address-constrained
129
133
  *
130
134
  * Args (Borsh-serialized after the 8-byte discriminator):
131
135
  * session_pubkey: [u8; 32]
@@ -146,6 +150,12 @@ interface BuildRegisterSessionKeyArgs {
146
150
  allowedCounterparty: PublicKey;
147
151
  nonce: number;
148
152
  maxRevolvingCapacity: bigint;
153
+ /** The vault's swig account (== vault.swig_address). The builder derives
154
+ * swig_wallet_address from this via deriveSwigWalletAddress(). */
155
+ swigAddress: PublicKey;
156
+ /** Swig wallet's USDC ATA — read live on-chain for the overcommit gate.
157
+ * Caller-supplied (the SDK cannot derive it without the USDC mint). */
158
+ vaultUsdcAta: PublicKey;
149
159
  clientDataJSON: Uint8Array;
150
160
  authenticatorData: Uint8Array;
151
161
  }
@@ -244,6 +254,11 @@ declare function buildRequestWithdrawalInstruction(p: RequestWithdrawalParams):
244
254
  interface FinalizeWithdrawalParams {
245
255
  vaultPda: PublicKey;
246
256
  swigAddress: PublicKey;
257
+ /**
258
+ * The swig wallet's USDC ATA — read live on-chain for the Phase 1 reservation
259
+ * gate (isWritable false; the transfer is the separate Swig::SignV2 ix).
260
+ */
261
+ vaultUsdcAta: PublicKey;
247
262
  clientDataJSON: Uint8Array;
248
263
  authenticatorData: Uint8Array;
249
264
  }
@@ -252,7 +267,8 @@ interface FinalizeWithdrawalParams {
252
267
  * [0] swig — required by Swig's ProgramExec validator + bound via Anchor `address`
253
268
  * [1] swig_wallet_address — canonical PDA under the Swig program
254
269
  * [2] vault — the vault PDA being mutated
255
- * [3] instructions_sysvar — for the secp256r1 precompile sibling lookup
270
+ * [3] vault_usdc_ata swig wallet's USDC ATA, read for the Phase 1 reservation gate (read-only)
271
+ * [4] instructions_sysvar — for the secp256r1 precompile sibling lookup
256
272
  */
257
273
  declare function buildFinalizeWithdrawalInstruction(p: FinalizeWithdrawalParams): TransactionInstruction;
258
274
  interface ForceReleaseParams {
@@ -125,7 +125,11 @@ declare function buildSetSwigAtomicFromIdentity(params: BuildSetSwigAtomicFromId
125
125
  *
126
126
  * Accounts (in declaration order — Anchor is strict):
127
127
  * 0. [writable] vault — the Vault PDA being mutated
128
- * 1. [readonly] instructions_sysvar address-constrained
128
+ * 1. [readonly] vault_usdc_ata swig wallet's USDC ATA, read live
129
+ * for the Phase 1 overcommit gate
130
+ * 2. [readonly] swig — the vault's swig account (== vault.swig_address)
131
+ * 3. [readonly] swig_wallet_address — canonical PDA under the Swig program (derived)
132
+ * 4. [readonly] instructions_sysvar — address-constrained
129
133
  *
130
134
  * Args (Borsh-serialized after the 8-byte discriminator):
131
135
  * session_pubkey: [u8; 32]
@@ -146,6 +150,12 @@ interface BuildRegisterSessionKeyArgs {
146
150
  allowedCounterparty: PublicKey;
147
151
  nonce: number;
148
152
  maxRevolvingCapacity: bigint;
153
+ /** The vault's swig account (== vault.swig_address). The builder derives
154
+ * swig_wallet_address from this via deriveSwigWalletAddress(). */
155
+ swigAddress: PublicKey;
156
+ /** Swig wallet's USDC ATA — read live on-chain for the overcommit gate.
157
+ * Caller-supplied (the SDK cannot derive it without the USDC mint). */
158
+ vaultUsdcAta: PublicKey;
149
159
  clientDataJSON: Uint8Array;
150
160
  authenticatorData: Uint8Array;
151
161
  }
@@ -244,6 +254,11 @@ declare function buildRequestWithdrawalInstruction(p: RequestWithdrawalParams):
244
254
  interface FinalizeWithdrawalParams {
245
255
  vaultPda: PublicKey;
246
256
  swigAddress: PublicKey;
257
+ /**
258
+ * The swig wallet's USDC ATA — read live on-chain for the Phase 1 reservation
259
+ * gate (isWritable false; the transfer is the separate Swig::SignV2 ix).
260
+ */
261
+ vaultUsdcAta: PublicKey;
247
262
  clientDataJSON: Uint8Array;
248
263
  authenticatorData: Uint8Array;
249
264
  }
@@ -252,7 +267,8 @@ interface FinalizeWithdrawalParams {
252
267
  * [0] swig — required by Swig's ProgramExec validator + bound via Anchor `address`
253
268
  * [1] swig_wallet_address — canonical PDA under the Swig program
254
269
  * [2] vault — the vault PDA being mutated
255
- * [3] instructions_sysvar — for the secp256r1 precompile sibling lookup
270
+ * [3] vault_usdc_ata swig wallet's USDC ATA, read for the Phase 1 reservation gate (read-only)
271
+ * [4] instructions_sysvar — for the secp256r1 precompile sibling lookup
256
272
  */
257
273
  declare function buildFinalizeWithdrawalInstruction(p: FinalizeWithdrawalParams): TransactionInstruction;
258
274
  interface ForceReleaseParams {
@@ -4738,7 +4738,94 @@ function buildSetSwigAtomicFromIdentity(params) {
4738
4738
  }
4739
4739
 
4740
4740
  // src/instructions/registerSession.ts
4741
- import { TransactionInstruction as TransactionInstruction4 } from "@solana/web3.js";
4741
+ import { TransactionInstruction as TransactionInstruction5 } from "@solana/web3.js";
4742
+
4743
+ // src/instructions/withdraw.ts
4744
+ import {
4745
+ PublicKey as PublicKey6,
4746
+ TransactionInstruction as TransactionInstruction4,
4747
+ SYSVAR_INSTRUCTIONS_PUBKEY as SYSVAR_INSTRUCTIONS_PUBKEY3
4748
+ } from "@solana/web3.js";
4749
+ function encodeBytesVec2(buf) {
4750
+ const out = Buffer.alloc(4 + buf.length);
4751
+ out.writeUInt32LE(buf.length, 0);
4752
+ Buffer.from(buf).copy(out, 4);
4753
+ return out;
4754
+ }
4755
+ function encodeU64(value) {
4756
+ const out = Buffer.alloc(8);
4757
+ out.writeBigUInt64LE(value, 0);
4758
+ return out;
4759
+ }
4760
+ function encodeI64(value) {
4761
+ const out = Buffer.alloc(8);
4762
+ out.writeBigInt64LE(value, 0);
4763
+ return out;
4764
+ }
4765
+ function encodePubkey2(key) {
4766
+ return Buffer.from(key.toBytes());
4767
+ }
4768
+ function deriveSwigWalletAddress(swigAddress) {
4769
+ const [pda] = PublicKey6.findProgramAddressSync(
4770
+ [Buffer.from("swig-wallet-address"), swigAddress.toBuffer()],
4771
+ SWIG_PROGRAM_ID
4772
+ );
4773
+ return pda;
4774
+ }
4775
+ function buildRequestWithdrawalInstruction(p) {
4776
+ const argsBuf = Buffer.concat([
4777
+ encodeU64(p.amount),
4778
+ encodePubkey2(p.destination),
4779
+ encodeI64(p.signedAt),
4780
+ encodeBytesVec2(p.clientDataJSON),
4781
+ encodeBytesVec2(p.authenticatorData)
4782
+ ]);
4783
+ const data = Buffer.concat([Buffer.from(DISCRIMINATORS.request_withdrawal), argsBuf]);
4784
+ return new TransactionInstruction4({
4785
+ programId: DEXTER_VAULT_PROGRAM_ID,
4786
+ keys: [
4787
+ { pubkey: p.vaultPda, isSigner: false, isWritable: true },
4788
+ { pubkey: SYSVAR_INSTRUCTIONS_PUBKEY3, isSigner: false, isWritable: false }
4789
+ ],
4790
+ data
4791
+ });
4792
+ }
4793
+ function buildFinalizeWithdrawalInstruction(p) {
4794
+ const argsBuf = Buffer.concat([
4795
+ encodeBytesVec2(p.clientDataJSON),
4796
+ encodeBytesVec2(p.authenticatorData)
4797
+ ]);
4798
+ const data = Buffer.concat([Buffer.from(DISCRIMINATORS.finalize_withdrawal), argsBuf]);
4799
+ const swigWalletAddress = deriveSwigWalletAddress(p.swigAddress);
4800
+ return new TransactionInstruction4({
4801
+ programId: DEXTER_VAULT_PROGRAM_ID,
4802
+ keys: [
4803
+ { pubkey: p.swigAddress, isSigner: false, isWritable: false },
4804
+ { pubkey: swigWalletAddress, isSigner: false, isWritable: false },
4805
+ { pubkey: p.vaultPda, isSigner: false, isWritable: true },
4806
+ { pubkey: p.vaultUsdcAta, isSigner: false, isWritable: false },
4807
+ { pubkey: SYSVAR_INSTRUCTIONS_PUBKEY3, isSigner: false, isWritable: false }
4808
+ ],
4809
+ data
4810
+ });
4811
+ }
4812
+ function buildForceReleaseInstruction(p) {
4813
+ const argsBuf = Buffer.concat([
4814
+ encodeBytesVec2(p.clientDataJSON),
4815
+ encodeBytesVec2(p.authenticatorData)
4816
+ ]);
4817
+ const data = Buffer.concat([Buffer.from(DISCRIMINATORS.force_release), argsBuf]);
4818
+ return new TransactionInstruction4({
4819
+ programId: DEXTER_VAULT_PROGRAM_ID,
4820
+ keys: [
4821
+ { pubkey: p.vaultPda, isSigner: false, isWritable: true },
4822
+ { pubkey: SYSVAR_INSTRUCTIONS_PUBKEY3, isSigner: false, isWritable: false }
4823
+ ],
4824
+ data
4825
+ });
4826
+ }
4827
+
4828
+ // src/instructions/registerSession.ts
4742
4829
  function encodeU64LE(value) {
4743
4830
  const buf = new Uint8Array(8);
4744
4831
  new DataView(buf.buffer).setBigUint64(0, value, true);
@@ -4785,9 +4872,13 @@ function buildRegisterSessionKeyInstruction(args) {
4785
4872
  encodeVecU8(args.clientDataJSON),
4786
4873
  encodeVecU8(args.authenticatorData)
4787
4874
  );
4788
- return new TransactionInstruction4({
4875
+ const swigWalletAddress = deriveSwigWalletAddress(args.swigAddress);
4876
+ return new TransactionInstruction5({
4789
4877
  keys: [
4790
4878
  { pubkey: args.vaultPda, isSigner: false, isWritable: true },
4879
+ { pubkey: args.vaultUsdcAta, isSigner: false, isWritable: false },
4880
+ { pubkey: args.swigAddress, isSigner: false, isWritable: false },
4881
+ { pubkey: swigWalletAddress, isSigner: false, isWritable: false },
4791
4882
  { pubkey: INSTRUCTIONS_SYSVAR_ID, isSigner: false, isWritable: false }
4792
4883
  ],
4793
4884
  programId: DEXTER_VAULT_PROGRAM_ID,
@@ -4796,7 +4887,7 @@ function buildRegisterSessionKeyInstruction(args) {
4796
4887
  }
4797
4888
 
4798
4889
  // src/instructions/revokeSession.ts
4799
- import { TransactionInstruction as TransactionInstruction5 } from "@solana/web3.js";
4890
+ import { TransactionInstruction as TransactionInstruction6 } from "@solana/web3.js";
4800
4891
  function encodeVecU82(bytes) {
4801
4892
  const out = new Uint8Array(4 + bytes.length);
4802
4893
  new DataView(out.buffer).setUint32(0, bytes.length >>> 0, true);
@@ -4819,7 +4910,7 @@ function buildRevokeSessionKeyInstruction(args) {
4819
4910
  encodeVecU82(args.clientDataJSON),
4820
4911
  encodeVecU82(args.authenticatorData)
4821
4912
  );
4822
- return new TransactionInstruction5({
4913
+ return new TransactionInstruction6({
4823
4914
  keys: [
4824
4915
  { pubkey: args.vaultPda, isSigner: false, isWritable: true },
4825
4916
  { pubkey: INSTRUCTIONS_SYSVAR_ID, isSigner: false, isWritable: false }
@@ -4830,8 +4921,8 @@ function buildRevokeSessionKeyInstruction(args) {
4830
4921
  }
4831
4922
 
4832
4923
  // src/instructions/settleVoucher.ts
4833
- import { TransactionInstruction as TransactionInstruction6 } from "@solana/web3.js";
4834
- function encodeU64(value) {
4924
+ import { TransactionInstruction as TransactionInstruction7 } from "@solana/web3.js";
4925
+ function encodeU642(value) {
4835
4926
  const out = Buffer.alloc(8);
4836
4927
  out.writeBigUInt64LE(value, 0);
4837
4928
  return out;
@@ -4840,9 +4931,9 @@ function encodeBool(value) {
4840
4931
  return Buffer.from([value ? 1 : 0]);
4841
4932
  }
4842
4933
  function buildSettleVoucherInstruction(p) {
4843
- const argsBuf = Buffer.concat([encodeU64(p.amount), encodeBool(p.increment)]);
4934
+ const argsBuf = Buffer.concat([encodeU642(p.amount), encodeBool(p.increment)]);
4844
4935
  const data = Buffer.concat([Buffer.from(DISCRIMINATORS.settle_voucher), argsBuf]);
4845
- return new TransactionInstruction6({
4936
+ return new TransactionInstruction7({
4846
4937
  programId: DEXTER_VAULT_PROGRAM_ID,
4847
4938
  keys: [
4848
4939
  { pubkey: p.vaultPda, isSigner: false, isWritable: true },
@@ -4857,92 +4948,6 @@ import {
4857
4948
  TransactionInstruction as TransactionInstruction8,
4858
4949
  SYSVAR_INSTRUCTIONS_PUBKEY as SYSVAR_INSTRUCTIONS_PUBKEY4
4859
4950
  } from "@solana/web3.js";
4860
-
4861
- // src/instructions/withdraw.ts
4862
- import {
4863
- PublicKey as PublicKey9,
4864
- TransactionInstruction as TransactionInstruction7,
4865
- SYSVAR_INSTRUCTIONS_PUBKEY as SYSVAR_INSTRUCTIONS_PUBKEY3
4866
- } from "@solana/web3.js";
4867
- function encodeBytesVec2(buf) {
4868
- const out = Buffer.alloc(4 + buf.length);
4869
- out.writeUInt32LE(buf.length, 0);
4870
- Buffer.from(buf).copy(out, 4);
4871
- return out;
4872
- }
4873
- function encodeU642(value) {
4874
- const out = Buffer.alloc(8);
4875
- out.writeBigUInt64LE(value, 0);
4876
- return out;
4877
- }
4878
- function encodeI64(value) {
4879
- const out = Buffer.alloc(8);
4880
- out.writeBigInt64LE(value, 0);
4881
- return out;
4882
- }
4883
- function encodePubkey2(key) {
4884
- return Buffer.from(key.toBytes());
4885
- }
4886
- function deriveSwigWalletAddress(swigAddress) {
4887
- const [pda] = PublicKey9.findProgramAddressSync(
4888
- [Buffer.from("swig-wallet-address"), swigAddress.toBuffer()],
4889
- SWIG_PROGRAM_ID
4890
- );
4891
- return pda;
4892
- }
4893
- function buildRequestWithdrawalInstruction(p) {
4894
- const argsBuf = Buffer.concat([
4895
- encodeU642(p.amount),
4896
- encodePubkey2(p.destination),
4897
- encodeI64(p.signedAt),
4898
- encodeBytesVec2(p.clientDataJSON),
4899
- encodeBytesVec2(p.authenticatorData)
4900
- ]);
4901
- const data = Buffer.concat([Buffer.from(DISCRIMINATORS.request_withdrawal), argsBuf]);
4902
- return new TransactionInstruction7({
4903
- programId: DEXTER_VAULT_PROGRAM_ID,
4904
- keys: [
4905
- { pubkey: p.vaultPda, isSigner: false, isWritable: true },
4906
- { pubkey: SYSVAR_INSTRUCTIONS_PUBKEY3, isSigner: false, isWritable: false }
4907
- ],
4908
- data
4909
- });
4910
- }
4911
- function buildFinalizeWithdrawalInstruction(p) {
4912
- const argsBuf = Buffer.concat([
4913
- encodeBytesVec2(p.clientDataJSON),
4914
- encodeBytesVec2(p.authenticatorData)
4915
- ]);
4916
- const data = Buffer.concat([Buffer.from(DISCRIMINATORS.finalize_withdrawal), argsBuf]);
4917
- const swigWalletAddress = deriveSwigWalletAddress(p.swigAddress);
4918
- return new TransactionInstruction7({
4919
- programId: DEXTER_VAULT_PROGRAM_ID,
4920
- keys: [
4921
- { pubkey: p.swigAddress, isSigner: false, isWritable: false },
4922
- { pubkey: swigWalletAddress, isSigner: false, isWritable: false },
4923
- { pubkey: p.vaultPda, isSigner: false, isWritable: true },
4924
- { pubkey: SYSVAR_INSTRUCTIONS_PUBKEY3, isSigner: false, isWritable: false }
4925
- ],
4926
- data
4927
- });
4928
- }
4929
- function buildForceReleaseInstruction(p) {
4930
- const argsBuf = Buffer.concat([
4931
- encodeBytesVec2(p.clientDataJSON),
4932
- encodeBytesVec2(p.authenticatorData)
4933
- ]);
4934
- const data = Buffer.concat([Buffer.from(DISCRIMINATORS.force_release), argsBuf]);
4935
- return new TransactionInstruction7({
4936
- programId: DEXTER_VAULT_PROGRAM_ID,
4937
- keys: [
4938
- { pubkey: p.vaultPda, isSigner: false, isWritable: true },
4939
- { pubkey: SYSVAR_INSTRUCTIONS_PUBKEY3, isSigner: false, isWritable: false }
4940
- ],
4941
- data
4942
- });
4943
- }
4944
-
4945
- // src/instructions/settleTabVoucher.ts
4946
4951
  function encodeFixedBytes2(buf, len) {
4947
4952
  if (buf.length !== len) {
4948
4953
  throw new Error(`expected ${len} bytes, got ${buf.length}`);
package/package.json CHANGED
@@ -1,25 +1,74 @@
1
1
  {
2
2
  "name": "@dexterai/vault",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
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",
7
7
  "type": "module",
8
8
  "exports": {
9
- ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" },
10
- "./types": { "types": "./dist/types.d.ts", "import": "./dist/types.js", "require": "./dist/types.cjs" },
11
- "./constants": { "types": "./dist/constants/index.d.ts", "import": "./dist/constants/index.js", "require": "./dist/constants/index.cjs" },
12
- "./counterfactual": { "types": "./dist/counterfactual.d.ts", "import": "./dist/counterfactual.js", "require": "./dist/counterfactual.cjs" },
13
- "./instructions": { "types": "./dist/instructions/index.d.ts", "import": "./dist/instructions/index.js", "require": "./dist/instructions/index.cjs" },
14
- "./messages": { "types": "./dist/messages/index.d.ts", "import": "./dist/messages/index.js", "require": "./dist/messages/index.cjs" },
15
- "./reader": { "types": "./dist/reader/index.d.ts", "import": "./dist/reader/index.js", "require": "./dist/reader/index.cjs" },
16
- "./precompile": { "types": "./dist/precompile/index.d.ts", "import": "./dist/precompile/index.js", "require": "./dist/precompile/index.cjs" },
17
- "./signers": { "types": "./dist/signers/types.d.ts", "import": "./dist/signers/types.js", "require": "./dist/signers/types.cjs" },
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" },
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ },
14
+ "./types": {
15
+ "types": "./dist/types.d.ts",
16
+ "import": "./dist/types.js",
17
+ "require": "./dist/types.cjs"
18
+ },
19
+ "./constants": {
20
+ "types": "./dist/constants/index.d.ts",
21
+ "import": "./dist/constants/index.js",
22
+ "require": "./dist/constants/index.cjs"
23
+ },
24
+ "./counterfactual": {
25
+ "types": "./dist/counterfactual.d.ts",
26
+ "import": "./dist/counterfactual.js",
27
+ "require": "./dist/counterfactual.cjs"
28
+ },
29
+ "./instructions": {
30
+ "types": "./dist/instructions/index.d.ts",
31
+ "import": "./dist/instructions/index.js",
32
+ "require": "./dist/instructions/index.cjs"
33
+ },
34
+ "./messages": {
35
+ "types": "./dist/messages/index.d.ts",
36
+ "import": "./dist/messages/index.js",
37
+ "require": "./dist/messages/index.cjs"
38
+ },
39
+ "./reader": {
40
+ "types": "./dist/reader/index.d.ts",
41
+ "import": "./dist/reader/index.js",
42
+ "require": "./dist/reader/index.cjs"
43
+ },
44
+ "./precompile": {
45
+ "types": "./dist/precompile/index.d.ts",
46
+ "import": "./dist/precompile/index.js",
47
+ "require": "./dist/precompile/index.cjs"
48
+ },
49
+ "./signers": {
50
+ "types": "./dist/signers/types.d.ts",
51
+ "import": "./dist/signers/types.js",
52
+ "require": "./dist/signers/types.cjs"
53
+ },
54
+ "./signers/node": {
55
+ "types": "./dist/signers/node/index.d.ts",
56
+ "import": "./dist/signers/node/index.js",
57
+ "require": "./dist/signers/node/index.cjs"
58
+ },
59
+ "./signers/browser": {
60
+ "types": "./dist/signers/browser/index.d.ts",
61
+ "import": "./dist/signers/browser/index.js",
62
+ "require": "./dist/signers/browser/index.cjs"
63
+ },
20
64
  "./idl/dexter_vault.json": "./dist/idl/dexter_vault.json"
21
65
  },
22
- "files": ["dist", "README.md", "LICENSE", "assets"],
66
+ "files": [
67
+ "dist",
68
+ "README.md",
69
+ "LICENSE",
70
+ "assets"
71
+ ],
23
72
  "scripts": {
24
73
  "build": "tsup",
25
74
  "dev": "tsup --watch",
@@ -47,9 +96,28 @@
47
96
  "typescript": "^5.7.2",
48
97
  "vitest": "^2.1.8"
49
98
  },
50
- "engines": { "node": ">=18" },
51
- "keywords": ["solana", "dexter", "vault", "passkey", "webauthn", "swig", "secp256r1", "ed25519", "ots", "tab", "x402"],
52
- "repository": { "type": "git", "url": "https://github.com/Dexter-DAO/dexter-vault-sdk" },
99
+ "engines": {
100
+ "node": ">=18"
101
+ },
102
+ "keywords": [
103
+ "solana",
104
+ "dexter",
105
+ "vault",
106
+ "passkey",
107
+ "webauthn",
108
+ "swig",
109
+ "secp256r1",
110
+ "ed25519",
111
+ "ots",
112
+ "tab",
113
+ "x402"
114
+ ],
115
+ "repository": {
116
+ "type": "git",
117
+ "url": "https://github.com/Dexter-DAO/dexter-vault-sdk"
118
+ },
53
119
  "homepage": "https://dexter.cash",
54
- "bugs": { "url": "https://github.com/Dexter-DAO/dexter-vault-sdk/issues" }
120
+ "bugs": {
121
+ "url": "https://github.com/Dexter-DAO/dexter-vault-sdk/issues"
122
+ }
55
123
  }