@interest-protocol/vortex-sdk 0.0.1-alpha.0 → 1.1.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/.eslingignore +1 -0
- package/dist/__tests__/entities/keypair.spec.d.ts +2 -0
- package/dist/__tests__/entities/keypair.spec.d.ts.map +1 -0
- package/dist/__tests__/test-utils.d.ts +25 -0
- package/dist/__tests__/test-utils.d.ts.map +1 -0
- package/dist/__tests__/types.d.ts +3 -0
- package/dist/__tests__/types.d.ts.map +1 -0
- package/dist/__tests__/vortex.test.d.ts +2 -0
- package/dist/__tests__/vortex.test.d.ts.map +1 -0
- package/dist/constants.d.ts +44 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/crypto/ff/f1field.d.ts +76 -0
- package/dist/crypto/ff/f1field.d.ts.map +1 -0
- package/dist/crypto/ff/index.d.ts +6 -0
- package/dist/crypto/ff/index.d.ts.map +1 -0
- package/dist/crypto/ff/random.d.ts +2 -0
- package/dist/crypto/ff/random.d.ts.map +1 -0
- package/dist/crypto/ff/scalar.d.ts +45 -0
- package/dist/crypto/ff/scalar.d.ts.map +1 -0
- package/dist/crypto/ff/utils.d.ts +6 -0
- package/dist/crypto/ff/utils.d.ts.map +1 -0
- package/dist/crypto/index.d.ts +6 -0
- package/dist/crypto/index.d.ts.map +1 -0
- package/dist/crypto/poseidon/index.d.ts +2 -0
- package/dist/crypto/poseidon/index.d.ts.map +1 -0
- package/dist/crypto/poseidon/poseidon-constants-opt.d.ts +7 -0
- package/dist/crypto/poseidon/poseidon-constants-opt.d.ts.map +1 -0
- package/dist/crypto/poseidon/poseidon-opt.d.ts +16 -0
- package/dist/crypto/poseidon/poseidon-opt.d.ts.map +1 -0
- package/dist/deposit.d.ts +4 -0
- package/dist/deposit.d.ts.map +1 -0
- package/dist/entities/index.d.ts +4 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/keypair.d.ts +29 -0
- package/dist/entities/keypair.d.ts.map +1 -0
- package/dist/entities/merkle-tree.d.ts +81 -0
- package/dist/entities/merkle-tree.d.ts.map +1 -0
- package/dist/entities/utxo.d.ts +24 -0
- package/dist/entities/utxo.d.ts.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38280 -4459
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38244 -4453
- package/dist/index.mjs.map +1 -1
- package/dist/jest-setup.d.ts +2 -0
- package/dist/jest-setup.d.ts.map +1 -0
- package/dist/keys/index.d.ts +3 -0
- package/dist/keys/index.d.ts.map +1 -0
- package/dist/pkg/nodejs/vortex.d.ts +11 -0
- package/dist/pkg/nodejs/vortex.d.ts.map +1 -0
- package/dist/pkg/web/vortex.d.ts +44 -0
- package/dist/pkg/web/vortex.d.ts.map +1 -0
- package/dist/utils/decrypt.d.ts +12 -0
- package/dist/utils/decrypt.d.ts.map +1 -0
- package/dist/utils/env.d.ts +2 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/events.d.ts +7 -0
- package/dist/utils/events.d.ts.map +1 -0
- package/dist/utils/ext-data.d.ts +3 -0
- package/dist/utils/ext-data.d.ts.map +1 -0
- package/dist/utils/index.d.ts +50 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/prove.d.ts +3 -0
- package/dist/utils/prove.d.ts.map +1 -0
- package/dist/vortex.d.ts +51 -21
- package/dist/vortex.d.ts.map +1 -1
- package/dist/vortex.types.d.ts +74 -50
- package/dist/vortex.types.d.ts.map +1 -1
- package/dist/vortex_bg.wasm +0 -0
- package/dist/withdraw.d.ts +4 -0
- package/dist/withdraw.d.ts.map +1 -0
- package/jest.config.js +31 -0
- package/package.json +22 -7
- package/src/__tests__/entities/keypair.spec.ts +191 -0
- package/src/__tests__/test-utils.ts +76 -0
- package/src/__tests__/types.ts +3 -0
- package/src/__tests__/vortex.test.ts +25 -0
- package/src/constants.ts +104 -0
- package/src/crypto/ff/f1field.ts +464 -0
- package/src/crypto/ff/index.ts +6 -0
- package/src/crypto/ff/random.ts +32 -0
- package/src/crypto/ff/readme.md +8 -0
- package/src/crypto/ff/scalar.ts +264 -0
- package/src/crypto/ff/utils.ts +121 -0
- package/src/crypto/index.ts +8 -0
- package/src/crypto/poseidon/index.ts +1 -0
- package/src/crypto/poseidon/poseidon-constants-opt.ts +24806 -0
- package/src/crypto/poseidon/poseidon-opt.ts +184 -0
- package/src/deposit.ts +168 -0
- package/src/entities/index.ts +3 -0
- package/src/entities/keypair.ts +262 -0
- package/src/entities/merkle-tree.ts +256 -0
- package/src/entities/utxo.ts +52 -0
- package/src/index.ts +6 -2
- package/src/jest-setup.ts +2 -0
- package/src/keys/index.ts +5 -0
- package/src/pkg/nodejs/vortex.d.ts +36 -0
- package/src/pkg/nodejs/vortex.js +332 -0
- package/src/pkg/nodejs/vortex_bg.wasm +0 -0
- package/src/pkg/nodejs/vortex_bg.wasm.d.ts +12 -0
- package/src/pkg/web/vortex.d.ts +72 -0
- package/src/pkg/web/vortex.js +442 -0
- package/src/pkg/web/vortex_bg.wasm +0 -0
- package/src/pkg/web/vortex_bg.wasm.d.ts +12 -0
- package/src/utils/decrypt.ts +46 -0
- package/src/utils/env.ts +18 -0
- package/src/utils/events.ts +16 -0
- package/src/utils/ext-data.ts +43 -0
- package/src/utils/index.ts +152 -0
- package/src/utils/prove.ts +18 -0
- package/src/vortex.ts +235 -111
- package/src/vortex.types.ts +74 -54
- package/src/withdraw.ts +159 -0
- package/tsconfig.json +4 -2
- package/dist/admin.d.ts +0 -17
- package/dist/admin.d.ts.map +0 -1
- package/dist/utils.d.ts +0 -11
- package/dist/utils.d.ts.map +0 -1
- package/src/admin.ts +0 -124
- package/src/utils.ts +0 -66
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest-setup.d.ts","sourceRoot":"","sources":["../src/jest-setup.ts"],"names":[],"mappings":"AACA,OAAO,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/keys/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,QACm5xxO,CAAC;AAE56xxO,eAAO,MAAM,aAAa,QACi8B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function main(): void;
|
|
2
|
+
export function prove(input_json: string, proving_key_hex: string): string;
|
|
3
|
+
export function verify(proof_json: string, verifying_key_hex: string): boolean;
|
|
4
|
+
export function __wbg___wbindgen_debug_string_df47ffb5e35e6763(arg0: any, arg1: any): void;
|
|
5
|
+
export function __wbg_error_7534b8e9a36f1ab4(arg0: any, arg1: any): void;
|
|
6
|
+
export function __wbg_new_8a6f238a6ece86ea(): Error;
|
|
7
|
+
export function __wbg_stack_0ed75d68575b0f3c(arg0: any, arg1: any): void;
|
|
8
|
+
export function __wbindgen_cast_2241b6af4c4b2941(arg0: any, arg1: any): string;
|
|
9
|
+
export function __wbindgen_init_externref_table(): void;
|
|
10
|
+
export const __wasm: WebAssembly.Exports;
|
|
11
|
+
//# sourceMappingURL=vortex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vortex.d.ts","sourceRoot":"","sources":["../../../src/pkg/nodejs/vortex.js"],"names":[],"mappings":"AAwKe,6BAEd;AA+Be,kCAJL,MAAM,mBACN,MAAM,GACJ,MAAM,CAgClB;AAegB,mCAJN,MAAM,qBACN,MAAM,GACJ,OAAO,CAoBnB;AAEwD,2FAUxD;AAEsC,yEAUtC;AAEoC,oDAGpC;AAEsC,yEAUtC;AAE0C,+EAI1C;AAEyC,wDAQzC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export function main(): void;
|
|
2
|
+
/**
|
|
3
|
+
* Generates a zero-knowledge proof for a privacy-preserving transaction
|
|
4
|
+
*
|
|
5
|
+
* # Arguments
|
|
6
|
+
* * `input_json` - JSON string containing all circuit inputs
|
|
7
|
+
* * `proving_key_hex` - Hex-encoded proving key (generated during setup)
|
|
8
|
+
*
|
|
9
|
+
* # Returns
|
|
10
|
+
* JSON string containing the proof and public inputs
|
|
11
|
+
*
|
|
12
|
+
* # Example
|
|
13
|
+
* ```javascript
|
|
14
|
+
* const input = {
|
|
15
|
+
* root: "12345...",
|
|
16
|
+
* publicAmount: "1000",
|
|
17
|
+
* // ... other inputs
|
|
18
|
+
* };
|
|
19
|
+
* const proof = prove(JSON.stringify(input), provingKeyHex);
|
|
20
|
+
* const { proofA, proofB, proofC, publicInputs } = JSON.parse(proof);
|
|
21
|
+
* ```
|
|
22
|
+
* @param {string} input_json
|
|
23
|
+
* @param {string} proving_key_hex
|
|
24
|
+
* @returns {string}
|
|
25
|
+
*/
|
|
26
|
+
export function prove(input_json: string, proving_key_hex: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Verifies a proof (useful for testing before submitting to chain)
|
|
29
|
+
*
|
|
30
|
+
* # Arguments
|
|
31
|
+
* * `proof_json` - JSON string containing proof output from `prove()`
|
|
32
|
+
* * `verifying_key_hex` - Hex-encoded verifying key
|
|
33
|
+
*
|
|
34
|
+
* # Returns
|
|
35
|
+
* "true" if proof is valid, "false" otherwise
|
|
36
|
+
* @param {string} proof_json
|
|
37
|
+
* @param {string} verifying_key_hex
|
|
38
|
+
* @returns {boolean}
|
|
39
|
+
*/
|
|
40
|
+
export function verify(proof_json: string, verifying_key_hex: string): boolean;
|
|
41
|
+
export default __wbg_init;
|
|
42
|
+
export function initSync(module: any): any;
|
|
43
|
+
declare function __wbg_init(module_or_path: any): Promise<any>;
|
|
44
|
+
//# sourceMappingURL=vortex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vortex.d.ts","sourceRoot":"","sources":["../../../src/pkg/web/vortex.js"],"names":[],"mappings":"AAkLA,6BAEC;AAOD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,kCAJW,MAAM,mBACN,MAAM,GACJ,MAAM,CAgClB;AAED;;;;;;;;;;;;GAYG;AACH,mCAJW,MAAM,qBACN,MAAM,GACJ,OAAO,CAoBnB;;AA+GD,2CAsBC;AAED,+DA6BC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PaginatedEvents } from '@mysten/sui/client';
|
|
2
|
+
import { VortexKeypair } from '../entities/keypair';
|
|
3
|
+
import { Utxo } from '../entities/utxo';
|
|
4
|
+
import { Vortex } from '../vortex';
|
|
5
|
+
interface GetUnspentUtxosArgs {
|
|
6
|
+
commitmentEvents: PaginatedEvents;
|
|
7
|
+
vortexKeypair: VortexKeypair;
|
|
8
|
+
vortex: Vortex;
|
|
9
|
+
}
|
|
10
|
+
export declare const getUnspentUtxos: ({ commitmentEvents, vortexKeypair, vortex, }: GetUnspentUtxosArgs) => Promise<Utxo[]>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=decrypt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decrypt.d.ts","sourceRoot":"","sources":["../../src/utils/decrypt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,UAAU,mBAAmB;IAC3B,gBAAgB,EAAE,eAAe,CAAC;IAClC,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,eAAe,GAAU,8CAInC,mBAAmB,oBA2BrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/utils/env.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,MAAM,sBAMlB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/utils/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIrD,eAAO,MAAM,uBAAuB,GAAI,QAAQ,eAAe;;;;GAW3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ext-data.d.ts","sourceRoot":"","sources":["../../src/utils/ext-data.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,EACT,KAAK,EACL,SAAS,EACT,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,gBAAgB,GACjB,EAAE,eAAe,GAAG,UAAU,CA4B9B"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { MerkleTree } from '../entities/merkle-tree';
|
|
2
|
+
import { Utxo } from '../entities/utxo';
|
|
3
|
+
import { VortexKeypair } from '../entities/keypair';
|
|
4
|
+
export declare const reverseBytes: (bytes: Uint8Array) => Uint8Array;
|
|
5
|
+
export declare const bytesToBigInt: (bytes: Uint8Array) => bigint;
|
|
6
|
+
export declare function getMerklePath(merkleTree: MerkleTree, utxo: Utxo | null): [string, string][];
|
|
7
|
+
interface ToProveInputArgs {
|
|
8
|
+
merkleTree: MerkleTree;
|
|
9
|
+
publicAmount: bigint;
|
|
10
|
+
extDataHash: bigint;
|
|
11
|
+
nullifier0: bigint;
|
|
12
|
+
nullifier1: bigint;
|
|
13
|
+
commitment0: bigint;
|
|
14
|
+
commitment1: bigint;
|
|
15
|
+
vortexKeypair: VortexKeypair;
|
|
16
|
+
inputUtxo0: Utxo;
|
|
17
|
+
inputUtxo1: Utxo;
|
|
18
|
+
outputUtxo0: Utxo;
|
|
19
|
+
outputUtxo1: Utxo;
|
|
20
|
+
}
|
|
21
|
+
export declare const toProveInput: ({ merkleTree, publicAmount, extDataHash, nullifier0, nullifier1, commitment0, commitment1, vortexKeypair, inputUtxo0, inputUtxo1, outputUtxo0, outputUtxo1, }: ToProveInputArgs) => {
|
|
22
|
+
root: bigint;
|
|
23
|
+
publicAmount: bigint;
|
|
24
|
+
extDataHash: bigint;
|
|
25
|
+
inputNullifier0: bigint;
|
|
26
|
+
inputNullifier1: bigint;
|
|
27
|
+
outputCommitment0: bigint;
|
|
28
|
+
outputCommitment1: bigint;
|
|
29
|
+
inPrivateKey0: bigint;
|
|
30
|
+
inPrivateKey1: bigint;
|
|
31
|
+
inAmount0: bigint;
|
|
32
|
+
inAmount1: bigint;
|
|
33
|
+
inBlinding0: bigint;
|
|
34
|
+
inBlinding1: bigint;
|
|
35
|
+
inPathIndex0: bigint;
|
|
36
|
+
inPathIndex1: bigint;
|
|
37
|
+
merklePath0: [string, string][];
|
|
38
|
+
merklePath1: [string, string][];
|
|
39
|
+
outPublicKey0: string;
|
|
40
|
+
outPublicKey1: string;
|
|
41
|
+
outAmount0: bigint;
|
|
42
|
+
outAmount1: bigint;
|
|
43
|
+
outBlinding0: bigint;
|
|
44
|
+
outBlinding1: bigint;
|
|
45
|
+
};
|
|
46
|
+
export * from './ext-data';
|
|
47
|
+
export * from './events';
|
|
48
|
+
export * from './prove';
|
|
49
|
+
export * from './decrypt';
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,eAAO,MAAM,YAAY,GAAI,OAAO,UAAU,KAAG,UAMhD,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAO,UAAU,KAAG,MAEjD,CAAC;AAEF,wBAAgB,aAAa,CAC3B,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,GAAG,IAAI,GAChB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAkEpB;AAED,UAAU,gBAAgB;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,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;CACnB;AAED,eAAO,MAAM,YAAY,GAAI,+JAa1B,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;CA2BlB,CAAC;AAEF,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prove.d.ts","sourceRoot":"","sources":["../../src/utils/prove.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,WAKlC,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,YAKnC,CAAC"}
|
package/dist/vortex.d.ts
CHANGED
|
@@ -1,24 +1,54 @@
|
|
|
1
|
-
import { SdkConstructorArgs, DepositArgs, Pool, WithdrawArgs } from './vortex.types';
|
|
2
1
|
import { Transaction } from '@mysten/sui/transactions';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
private
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
import { ConstructorArgs, RegisterArgs, SharedObjectData, NewExtDataArgs, NewProofArgs, TransactArgs } from './vortex.types';
|
|
3
|
+
export declare class Vortex {
|
|
4
|
+
#private;
|
|
5
|
+
packageId: string;
|
|
6
|
+
registry: SharedObjectData;
|
|
7
|
+
vortex: SharedObjectData;
|
|
8
|
+
newCommitmentEventType: string;
|
|
9
|
+
nullifierSpentEventType: string;
|
|
10
|
+
newEncryptionKeyEventType: string;
|
|
11
|
+
constructor({ registry, packageId, vortex, fullNodeUrl, }: ConstructorArgs);
|
|
12
|
+
register({ tx, encryptionKey }: RegisterArgs): {
|
|
13
|
+
tx: Transaction;
|
|
14
|
+
};
|
|
15
|
+
encryptionKey(user: string): Promise<string>;
|
|
16
|
+
newExtData({ tx, recipient, value, action, relayer, relayerFee, encryptedOutput1, encryptedOutput0, }: NewExtDataArgs): {
|
|
17
|
+
tx: Transaction;
|
|
18
|
+
extData: import("@mysten/sui/dist/cjs/transactions").TransactionResult;
|
|
19
|
+
};
|
|
20
|
+
newProof({ tx, proofPoints, root, publicValue, action, extDataHash, inputNullifier0, inputNullifier1, outputCommitment0, outputCommitment1, }: NewProofArgs): {
|
|
21
|
+
tx: Transaction;
|
|
22
|
+
proof: import("@mysten/sui/dist/cjs/transactions").TransactionResult;
|
|
23
|
+
};
|
|
24
|
+
transact({ tx, proof, extData, deposit }: TransactArgs): {
|
|
25
|
+
tx: Transaction;
|
|
26
|
+
};
|
|
27
|
+
tvl(): Promise<bigint>;
|
|
28
|
+
root(): Promise<bigint>;
|
|
29
|
+
nextIndex(): Promise<bigint>;
|
|
30
|
+
isNullifierSpent(nullifier: bigint): Promise<boolean>;
|
|
31
|
+
areNullifiersSpent(nullifiers: bigint[]): Promise<boolean[]>;
|
|
32
|
+
immutableVortexRef(tx: Transaction): {
|
|
33
|
+
$kind: "Input";
|
|
34
|
+
Input: number;
|
|
35
|
+
type?: "object";
|
|
36
|
+
};
|
|
37
|
+
immutableRegistryRef(tx: Transaction): {
|
|
38
|
+
$kind: "Input";
|
|
39
|
+
Input: number;
|
|
40
|
+
type?: "object";
|
|
41
|
+
};
|
|
42
|
+
mutableVortexRef(tx: Transaction): {
|
|
43
|
+
$kind: "Input";
|
|
44
|
+
Input: number;
|
|
45
|
+
type?: "object";
|
|
46
|
+
};
|
|
47
|
+
mutableRegistryRef(tx: Transaction): {
|
|
48
|
+
$kind: "Input";
|
|
49
|
+
Input: number;
|
|
50
|
+
type?: "object";
|
|
51
|
+
};
|
|
23
52
|
}
|
|
53
|
+
export declare const vortexSDK: Vortex;
|
|
24
54
|
//# sourceMappingURL=vortex.d.ts.map
|
package/dist/vortex.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vortex.d.ts","sourceRoot":"","sources":["../src/vortex.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vortex.d.ts","sourceRoot":"","sources":["../src/vortex.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EACL,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,cAAc,EAEd,YAAY,EACZ,YAAY,EACb,MAAM,gBAAgB,CAAC;AAaxB,qBAAa,MAAM;;IAGjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,MAAM,EAAE,gBAAgB,CAAC;IAEzB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,uBAAuB,EAAE,MAAM,CAAC;IAChC,yBAAyB,EAAE,MAAM,CAAC;gBAEtB,EACV,QAAQ,EACR,SAAS,EACT,MAAM,EACN,WAAsC,GACvC,EAAE,eAAe;IAclB,QAAQ,CAAC,EAAE,EAAsB,EAAE,aAAa,EAAE,EAAE,YAAY;;;IAS1D,aAAa,CAAC,IAAI,EAAE,MAAM;IAiBhC,UAAU,CAAC,EACT,EAAsB,EACtB,SAAS,EACT,KAAK,EACL,MAAM,EACN,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,gBAAgB,GACjB,EAAE,cAAc;;;;IAiBjB,QAAQ,CAAC,EACP,EAAsB,EACtB,WAAW,EACX,IAAI,EACJ,WAAW,EACX,MAAM,EACN,WAAW,EACX,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAClB,EAAE,YAAY;;;;IAuBf,QAAQ,CAAC,EAAE,EAAsB,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,YAAY;;;IASpE,GAAG;IAeH,IAAI;IAiBJ,SAAS;IAiBT,gBAAgB,CAAC,SAAS,EAAE,MAAM;IAoBlC,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE;IAwB7C,kBAAkB,CAAC,EAAE,EAAE,WAAW;;;;;IAQlC,oBAAoB,CAAC,EAAE,EAAE,WAAW;;;;;IAQpC,gBAAgB,CAAC,EAAE,EAAE,WAAW;;;;;IAQhC,kBAAkB,CAAC,EAAE,EAAE,WAAW;;;;;CAOnC;AAED,eAAO,MAAM,SAAS,QAWpB,CAAC"}
|
package/dist/vortex.types.d.ts
CHANGED
|
@@ -1,69 +1,93 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { MaybeTx } from '@interest-protocol/sui-core-sdk';
|
|
2
|
+
import { TransactionResult } from '@mysten/sui/transactions';
|
|
3
|
+
import { Vortex } from './vortex';
|
|
4
|
+
import { VortexKeypair } from './entities/keypair';
|
|
5
|
+
import { MerkleTree } from './entities/merkle-tree';
|
|
6
|
+
import { Utxo } from './entities/utxo';
|
|
7
|
+
export declare enum Action {
|
|
8
|
+
Deposit = 0,
|
|
9
|
+
Withdraw = 1
|
|
7
10
|
}
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
proof = "vortex_proof",
|
|
11
|
-
merkleTree = "vortex_merkle_tree"
|
|
11
|
+
export interface RegisterArgs extends MaybeTx {
|
|
12
|
+
encryptionKey: string;
|
|
12
13
|
}
|
|
13
|
-
export interface
|
|
14
|
+
export interface SharedObjectData {
|
|
14
15
|
objectId: string;
|
|
15
16
|
initialSharedVersion: string;
|
|
16
17
|
}
|
|
17
|
-
export interface
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
export interface SdkConstructorArgs {
|
|
23
|
-
client: SuiClient;
|
|
18
|
+
export interface ConstructorArgs {
|
|
19
|
+
registry: SharedObjectData;
|
|
20
|
+
vortex: SharedObjectData;
|
|
21
|
+
fullNodeUrl?: string;
|
|
24
22
|
packageId: string;
|
|
25
|
-
pools: VortexPools;
|
|
26
23
|
}
|
|
27
|
-
export interface
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
export interface ExtDataHashArgs {
|
|
25
|
+
recipient: string;
|
|
26
|
+
value: bigint;
|
|
27
|
+
valueSign: boolean;
|
|
28
|
+
relayer: string;
|
|
29
|
+
relayerFee: bigint;
|
|
30
|
+
encryptedOutput0: Uint8Array;
|
|
31
|
+
encryptedOutput1: Uint8Array;
|
|
30
32
|
}
|
|
31
|
-
export interface
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
export interface Proof {
|
|
34
|
+
proofA: number[];
|
|
35
|
+
proofB: number[];
|
|
36
|
+
proofC: number[];
|
|
37
|
+
publicInputs: [string, string, string, string, string, string, string];
|
|
38
|
+
proofSerializedHex: string;
|
|
39
|
+
publicInputsHex: string;
|
|
35
40
|
}
|
|
36
|
-
export interface
|
|
37
|
-
tx?: Transaction;
|
|
38
|
-
pool: Pool;
|
|
39
|
-
proofPointsHex: string;
|
|
40
|
-
root: bigint;
|
|
41
|
-
nullifier: bigint;
|
|
41
|
+
export interface NewExtDataArgs extends MaybeTx {
|
|
42
42
|
recipient: string;
|
|
43
|
+
value: bigint;
|
|
43
44
|
relayer: string;
|
|
44
45
|
relayerFee: bigint;
|
|
46
|
+
encryptedOutput0: Uint8Array;
|
|
47
|
+
encryptedOutput1: Uint8Array;
|
|
48
|
+
action: Action;
|
|
45
49
|
}
|
|
46
|
-
export interface
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
export interface NewProofArgs extends MaybeTx {
|
|
51
|
+
proofPoints: Uint8Array;
|
|
52
|
+
root: bigint;
|
|
53
|
+
publicValue: bigint;
|
|
54
|
+
action: Action;
|
|
55
|
+
extDataHash: bigint;
|
|
56
|
+
inputNullifier0: bigint;
|
|
57
|
+
inputNullifier1: bigint;
|
|
58
|
+
outputCommitment0: bigint;
|
|
59
|
+
outputCommitment1: bigint;
|
|
60
|
+
}
|
|
61
|
+
interface NestedResult {
|
|
62
|
+
$kind: 'NestedResult';
|
|
63
|
+
NestedResult: [number, number];
|
|
49
64
|
}
|
|
50
|
-
export interface
|
|
51
|
-
|
|
52
|
-
|
|
65
|
+
export interface TransactArgs extends MaybeTx {
|
|
66
|
+
proof: TransactionResult;
|
|
67
|
+
extData: TransactionResult;
|
|
68
|
+
deposit: TransactionResult | NestedResult;
|
|
53
69
|
}
|
|
54
|
-
export interface
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
export interface DepositArgs extends MaybeTx {
|
|
71
|
+
amount: bigint;
|
|
72
|
+
vortex: Vortex;
|
|
73
|
+
vortexKeypair: VortexKeypair;
|
|
74
|
+
merkleTree: MerkleTree;
|
|
75
|
+
unspentUtxos?: Utxo[];
|
|
58
76
|
}
|
|
59
|
-
export interface
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
77
|
+
export interface WithdrawArgs extends MaybeTx {
|
|
78
|
+
amount: bigint;
|
|
79
|
+
unspentUtxos: Utxo[];
|
|
80
|
+
vortex: Vortex;
|
|
81
|
+
vortexKeypair: VortexKeypair;
|
|
82
|
+
merkleTree: MerkleTree;
|
|
83
|
+
recipient: string;
|
|
84
|
+
relayer: string;
|
|
85
|
+
relayerFee: bigint;
|
|
63
86
|
}
|
|
64
|
-
export interface
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
87
|
+
export interface ParsedCommitmentEvent {
|
|
88
|
+
commitment: bigint;
|
|
89
|
+
index: bigint;
|
|
90
|
+
encryptedOutput: string;
|
|
68
91
|
}
|
|
92
|
+
export {};
|
|
69
93
|
//# sourceMappingURL=vortex.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vortex.types.d.ts","sourceRoot":"","sources":["../src/vortex.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"vortex.types.d.ts","sourceRoot":"","sources":["../src/vortex.types.ts"],"names":[],"mappings":"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"}
|
|
Binary file
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
+
import { WithdrawArgs } from './vortex.types';
|
|
3
|
+
export declare const withdraw: ({ tx, amount, unspentUtxos, vortex, vortexKeypair, merkleTree, recipient, relayer, relayerFee, }: WithdrawArgs) => Promise<Transaction>;
|
|
4
|
+
//# sourceMappingURL=withdraw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withdraw.d.ts","sourceRoot":"","sources":["../src/withdraw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAgBvD,OAAO,EAAiB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE7D,eAAO,MAAM,QAAQ,GAAU,kGAU5B,YAAY,yBAkId,CAAC"}
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** @type {import('jest').Config} */
|
|
2
|
+
const config = {
|
|
3
|
+
preset: 'ts-jest',
|
|
4
|
+
testEnvironment: 'node',
|
|
5
|
+
watchman: false,
|
|
6
|
+
testMatch: ['<rootDir>/src/**/*.(test|spec).(ts|tsx)'],
|
|
7
|
+
transform: {
|
|
8
|
+
'^.+\.tsx?$': [
|
|
9
|
+
'ts-jest',
|
|
10
|
+
{
|
|
11
|
+
tsconfig: '<rootDir>/tsconfig.json',
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
'^.+\\.js$': [
|
|
15
|
+
'ts-jest',
|
|
16
|
+
{
|
|
17
|
+
tsconfig: '<rootDir>/tsconfig.json',
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
|
|
22
|
+
collectCoverageFrom: ['<rootDir>/src/**/*.ts', '!<rootDir>/src/**/*.test.ts'],
|
|
23
|
+
moduleNameMapper: {
|
|
24
|
+
'^@/(.*)$': '<rootDir>/src/$1',
|
|
25
|
+
},
|
|
26
|
+
transformIgnorePatterns: [
|
|
27
|
+
'node_modules/(?!.*@noble)',
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
module.exports = config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interest-protocol/vortex-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -18,24 +18,38 @@
|
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@mysten/sui": "^1.36.2",
|
|
21
|
+
"@noble/ciphers": "^2.0.1",
|
|
22
|
+
"@noble/curves": "^2.0.1",
|
|
23
|
+
"@noble/hashes": "^2.0.1",
|
|
21
24
|
"@polymedia/suitcase-core": "^0.0.67",
|
|
22
|
-
"
|
|
23
|
-
"poseidon-lite": "^0.3.0",
|
|
25
|
+
"bn.js": "^5.2.2",
|
|
24
26
|
"ramda": "^0.30.1",
|
|
25
|
-
"tiny-invariant": "^1.3.3"
|
|
27
|
+
"tiny-invariant": "^1.3.3",
|
|
28
|
+
"@interest-protocol/sui-core-sdk": "1.0.0"
|
|
26
29
|
},
|
|
27
30
|
"devDependencies": {
|
|
31
|
+
"@types/bn.js": "^5.1.6",
|
|
32
|
+
"@types/jest": "^29.5.5",
|
|
33
|
+
"@types/ramda": "^0.30.2",
|
|
34
|
+
"jest": "^29.7.0",
|
|
35
|
+
"jest-environment-node": "^29.7.0",
|
|
28
36
|
"rimraf": "^6.0.1",
|
|
37
|
+
"ts-jest": "^29.1.1",
|
|
29
38
|
"tsup": "^8.3.5",
|
|
30
|
-
"@interest-protocol/
|
|
31
|
-
"@interest-protocol/
|
|
39
|
+
"@interest-protocol/typescript-config": "1.0.0",
|
|
40
|
+
"@interest-protocol/prettier-config": "1.0.0"
|
|
32
41
|
},
|
|
33
42
|
"publishConfig": {
|
|
34
43
|
"access": "public",
|
|
35
44
|
"dependencies": {
|
|
45
|
+
"@interest-protocol/sui-core-sdk": "1.0.0",
|
|
36
46
|
"@mysten/sui": "^1.36.2",
|
|
47
|
+
"@noble/ciphers": "^2.0.1",
|
|
48
|
+
"@noble/curves": "^2.0.1",
|
|
49
|
+
"@noble/hashes": "^2.0.1",
|
|
37
50
|
"@polymedia/suitcase-core": "^0.0.67",
|
|
38
|
-
"
|
|
51
|
+
"bn.js": "^5.2.2",
|
|
52
|
+
"pnpm": "^10.22.0",
|
|
39
53
|
"poseidon-lite": "^0.3.0",
|
|
40
54
|
"ramda": "^0.30.1",
|
|
41
55
|
"tiny-invariant": "^1.3.3"
|
|
@@ -44,6 +58,7 @@
|
|
|
44
58
|
"scripts": {
|
|
45
59
|
"prebuild": "rimraf dist",
|
|
46
60
|
"build": "rollup -c rollup.config.js",
|
|
61
|
+
"postbuild": "mkdir -p dist && cp src/pkg/nodejs/vortex_bg.wasm dist/vortex_bg.wasm",
|
|
47
62
|
"build:types": "tsc --emitDeclarationOnly"
|
|
48
63
|
}
|
|
49
64
|
}
|