@interest-protocol/vortex-sdk 8.1.0 → 8.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.
@@ -17,10 +17,16 @@ interface GetUnspentUtxosWithApiArgs {
17
17
  vortexSdk: Vortex;
18
18
  vortexPool: string | VortexPool;
19
19
  }
20
+ interface GetUnspentUtxosWithApiAndCommitmentsArgs {
21
+ commitments: Pick<Commitment, 'coinType' | 'encryptedOutput'>[];
22
+ vortexKeypair: VortexKeypair;
23
+ vortexSdk: Vortex;
24
+ vortexPool: string | VortexPool;
25
+ }
20
26
  export declare const getUnspentUtxosWithApi: ({ commitments, vortexKeypair, vortexSdk, vortexPool, }: GetUnspentUtxosWithApiArgs) => Promise<Utxo[]>;
21
- export declare const getUnspentUtxosWithApiAndCommitments: ({ commitments, vortexKeypair, vortexSdk, vortexPool, }: GetUnspentUtxosWithApiArgs) => Promise<{
27
+ export declare const getUnspentUtxosWithApiAndCommitments: ({ commitments, vortexKeypair, vortexSdk, vortexPool, }: GetUnspentUtxosWithApiAndCommitmentsArgs) => Promise<{
22
28
  unspentUtxos: Utxo[];
23
- userCommitments: Commitment[];
29
+ userCommitments: Pick<Commitment, "coinType" | "encryptedOutput">[];
24
30
  }>;
25
31
  export {};
26
32
  //# sourceMappingURL=decrypt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decrypt.d.ts","sourceRoot":"","sources":["../../src/utils/decrypt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,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AAM,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC;CACjC;AAED,UAAU,wCAAwC;IAChD,WAAW,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,iBAAiB,CAAC,EAAE,CAAC;IAChE,aAAa,EAAE,aAAa,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC;CACjC;AAED,eAAO,MAAM,sBAAsB,GAAU,wDAK1C,0BAA0B,oBA2C5B,CAAC;AAEF,eAAO,MAAM,oCAAoC,GAAU,wDAKxD,wCAAwC;;;EAmD1C,CAAC"}
@@ -22,31 +22,31 @@ interface ToProveInputArgs {
22
22
  accountSecret: bigint;
23
23
  }
24
24
  export declare const toProveInput: ({ root, merklePath0, merklePath1, publicAmount, nullifier0, nullifier1, commitment0, commitment1, vortexKeypair, inputUtxo0, inputUtxo1, outputUtxo0, outputUtxo1, vortexObjectId, accountSecret, }: ToProveInputArgs) => {
25
- vortex: bigint;
26
- root: bigint;
27
- publicAmount: bigint;
28
- inputNullifier0: bigint;
29
- inputNullifier1: bigint;
30
- outputCommitment0: bigint;
31
- outputCommitment1: bigint;
32
- hashedAccountSecret: bigint;
33
- accountSecret: bigint;
25
+ vortex: string;
26
+ root: string;
27
+ publicAmount: string;
28
+ inputNullifier0: string;
29
+ inputNullifier1: string;
30
+ outputCommitment0: string;
31
+ outputCommitment1: string;
32
+ hashedAccountSecret: string;
33
+ accountSecret: string;
34
34
  inPrivateKey0: bigint;
35
35
  inPrivateKey1: bigint;
36
- inAmount0: bigint;
37
- inAmount1: bigint;
38
- inBlinding0: bigint;
39
- inBlinding1: bigint;
40
- inPathIndex0: bigint;
41
- inPathIndex1: bigint;
36
+ inAmount0: string;
37
+ inAmount1: string;
38
+ inBlinding0: string;
39
+ inBlinding1: string;
40
+ inPathIndex0: string;
41
+ inPathIndex1: string;
42
42
  merklePath0: MerklePath;
43
43
  merklePath1: MerklePath;
44
44
  outPublicKey0: string;
45
45
  outPublicKey1: string;
46
- outAmount0: bigint;
47
- outAmount1: bigint;
48
- outBlinding0: bigint;
49
- outBlinding1: bigint;
46
+ outAmount0: string;
47
+ outAmount1: string;
48
+ outBlinding0: string;
49
+ outBlinding1: string;
50
50
  };
51
51
  export declare const parseVortexPool: (data: SuiObjectData) => {
52
52
  objectId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;AAE5C,wBAAgB,aAAa,CAC3B,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,GAAG,IAAI,GAChB,UAAU,CAkEZ;AAED,UAAU,gBAAgB;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,UAAU,CAAC;IACxB,WAAW,EAAE,UAAU,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,IAAI,CAAC;IACjB,WAAW,EAAE,IAAI,CAAC;IAClB,WAAW,EAAE,IAAI,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,YAAY,GAAI,qMAgB1B,gBAAgB;;;;;;;;;;;;;;;;;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D,CAAC;AAEF,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"withdraw.d.ts","sourceRoot":"","sources":["../../src/utils/withdraw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAMpD,OAAO,EAAiB,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,UAAU,mBAAmB;IAC3B,EAAE,CAAC,EAAE,WAAW,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,IAAI,EAAE,CAAC;IACrB,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC;IAChC,aAAa,EAAE,aAAa,CAAC;IAC7B,eAAe,EAAE,eAAe,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,eAAe,GAAU,0HAWnC,mBAAmB;;;;;EAkIrB,CAAC"}
1
+ {"version":3,"file":"withdraw.d.ts","sourceRoot":"","sources":["../../src/utils/withdraw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAMpD,OAAO,EAAiB,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,UAAU,mBAAmB;IAC3B,EAAE,CAAC,EAAE,WAAW,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,IAAI,EAAE,CAAC;IACrB,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC;IAChC,aAAa,EAAE,aAAa,CAAC;IAC7B,eAAe,EAAE,eAAe,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,eAAe,GAAU,0HAWnC,mBAAmB;;;;;EAqIrB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interest-protocol/vortex-sdk",
3
- "version": "8.1.0",
3
+ "version": "8.3.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "./dist/index.mjs",
@@ -64,6 +64,13 @@ interface GetUnspentUtxosWithApiArgs {
64
64
  vortexPool: string | VortexPool;
65
65
  }
66
66
 
67
+ interface GetUnspentUtxosWithApiAndCommitmentsArgs {
68
+ commitments: Pick<Commitment, 'coinType' | 'encryptedOutput'>[];
69
+ vortexKeypair: VortexKeypair;
70
+ vortexSdk: Vortex;
71
+ vortexPool: string | VortexPool;
72
+ }
73
+
67
74
  export const getUnspentUtxosWithApi = async ({
68
75
  commitments,
69
76
  vortexKeypair,
@@ -119,9 +126,12 @@ export const getUnspentUtxosWithApiAndCommitments = async ({
119
126
  vortexKeypair,
120
127
  vortexSdk,
121
128
  vortexPool,
122
- }: GetUnspentUtxosWithApiArgs) => {
129
+ }: GetUnspentUtxosWithApiAndCommitmentsArgs) => {
123
130
  const allUtxos = [] as UtxoPayload[];
124
- const userCommitments = [] as Commitment[];
131
+ const userCommitments = [] as Pick<
132
+ Commitment,
133
+ 'coinType' | 'encryptedOutput'
134
+ >[];
125
135
 
126
136
  const vortexObject = await vortexSdk.resolveVortexPool(vortexPool);
127
137
 
@@ -136,7 +146,10 @@ export const getUnspentUtxosWithApiAndCommitments = async ({
136
146
  Uint8Array.from(commitment.encryptedOutput)
137
147
  );
138
148
  const utxo = vortexKeypair.decryptUtxo(encryptedOutputHex);
139
- userCommitments.push(commitment);
149
+ userCommitments.push({
150
+ coinType: commitment.coinType,
151
+ encryptedOutput: commitment.encryptedOutput,
152
+ });
140
153
  allUtxos.push(utxo);
141
154
  } catch {
142
155
  // Do nothing
@@ -119,36 +119,38 @@ export const toProveInput = ({
119
119
  accountSecret,
120
120
  }: ToProveInputArgs) => {
121
121
  return {
122
- vortex:
122
+ vortex: (
123
123
  BigInt(
124
124
  normalizeSuiAddress(vortexObjectId, !vortexObjectId.startsWith('0x'))
125
- ) % BN254_FIELD_MODULUS,
126
- root,
127
- publicAmount,
128
- inputNullifier0: nullifier0,
129
- inputNullifier1: nullifier1,
130
- outputCommitment0: commitment0,
131
- outputCommitment1: commitment1,
132
- hashedAccountSecret: accountSecret === 0n ? 0n : poseidon1(accountSecret),
133
-
134
- accountSecret: accountSecret === 0n ? 12345n : accountSecret,
125
+ ) % BN254_FIELD_MODULUS
126
+ ).toString(),
127
+ root: root.toString(),
128
+ publicAmount: publicAmount.toString(),
129
+ inputNullifier0: nullifier0.toString(),
130
+ inputNullifier1: nullifier1.toString(),
131
+ outputCommitment0: commitment0.toString(),
132
+ outputCommitment1: commitment1.toString(),
133
+ hashedAccountSecret:
134
+ accountSecret === 0n ? '0' : poseidon1(accountSecret).toString(),
135
+
136
+ accountSecret: accountSecret === 0n ? '12345' : accountSecret.toString(),
135
137
  inPrivateKey0: vortexKeypair.privateKey,
136
138
  inPrivateKey1: vortexKeypair.privateKey,
137
- inAmount0: inputUtxo0.amount,
138
- inAmount1: inputUtxo1.amount,
139
- inBlinding0: inputUtxo0.blinding,
140
- inBlinding1: inputUtxo1.blinding,
141
- inPathIndex0: inputUtxo0.index,
142
- inPathIndex1: inputUtxo1.index,
139
+ inAmount0: inputUtxo0.amount.toString(),
140
+ inAmount1: inputUtxo1.amount.toString(),
141
+ inBlinding0: inputUtxo0.blinding.toString(),
142
+ inBlinding1: inputUtxo1.blinding.toString(),
143
+ inPathIndex0: inputUtxo0.index.toString(),
144
+ inPathIndex1: inputUtxo1.index.toString(),
143
145
  merklePath0,
144
146
  merklePath1,
145
147
 
146
148
  outPublicKey0: vortexKeypair.publicKey,
147
149
  outPublicKey1: vortexKeypair.publicKey,
148
- outAmount0: outputUtxo0.amount,
149
- outAmount1: outputUtxo1.amount,
150
- outBlinding0: outputUtxo0.blinding,
151
- outBlinding1: outputUtxo1.blinding,
150
+ outAmount0: outputUtxo0.amount.toString(),
151
+ outAmount1: outputUtxo1.amount.toString(),
152
+ outBlinding0: outputUtxo0.blinding.toString(),
153
+ outBlinding1: outputUtxo1.blinding.toString(),
152
154
  };
153
155
  };
154
156
 
@@ -133,7 +133,10 @@ export const prepareWithdraw = async ({
133
133
 
134
134
  const proof: Proof = JSON.parse(proofJson);
135
135
 
136
- invariant(vortexSdk.verify(proofJson, VERIFYING_KEY), 'Proof verification failed');
136
+ invariant(
137
+ vortexSdk.verify(proofJson, VERIFYING_KEY),
138
+ 'Proof verification failed'
139
+ );
137
140
 
138
141
  const { extData, tx: tx2 } = vortexSdk.newExtData({
139
142
  tx,