@interest-protocol/vortex-sdk 4.1.0 → 4.2.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/constants.d.ts +4 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/deposit-with-account.d.ts +1 -1
- package/dist/deposit-with-account.d.ts.map +1 -1
- package/dist/deposit.d.ts +1 -1
- package/dist/deposit.d.ts.map +1 -1
- package/dist/entities/keypair.d.ts +2 -0
- package/dist/entities/keypair.d.ts.map +1 -1
- package/dist/index.js +44 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -24
- package/dist/index.mjs.map +1 -1
- package/dist/utils/deposit.d.ts +4 -3
- package/dist/utils/deposit.d.ts.map +1 -1
- package/dist/utils/index.d.ts +8 -5
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/withdraw.d.ts +4 -3
- package/dist/utils/withdraw.d.ts.map +1 -1
- package/dist/vortex.types.d.ts +11 -6
- package/dist/vortex.types.d.ts.map +1 -1
- package/dist/withdraw-with-account.d.ts +1 -1
- package/dist/withdraw-with-account.d.ts.map +1 -1
- package/dist/withdraw.d.ts +1 -1
- package/dist/withdraw.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/constants.ts +5 -5
- package/src/deposit-with-account.ts +5 -3
- package/src/deposit.ts +4 -2
- package/src/entities/keypair.ts +17 -0
- package/src/utils/deposit.ts +10 -6
- package/src/utils/index.ts +13 -11
- package/src/utils/withdraw.ts +9 -6
- package/src/vortex.types.ts +13 -6
- package/src/withdraw-with-account.ts +4 -2
- package/src/withdraw.ts +4 -2
package/dist/constants.d.ts
CHANGED
|
@@ -26,10 +26,10 @@ export declare const ERROR_CODES: {
|
|
|
26
26
|
13: string;
|
|
27
27
|
14: string;
|
|
28
28
|
};
|
|
29
|
-
export declare const VORTEX_PACKAGE_ID = "
|
|
30
|
-
export declare const UPGRADE_CAP = "
|
|
31
|
-
export declare const REGISTRY_OBJECT_ID = "
|
|
32
|
-
export declare const INITIAL_SHARED_VERSION = "
|
|
29
|
+
export declare const VORTEX_PACKAGE_ID = "0x4d505443700db57e664f024b4cdfe315a6b80ddc4d6b9f1013c7b68682edd4ab";
|
|
30
|
+
export declare const UPGRADE_CAP = "0x6c4464ca68d4bcd0c0626dcbb7c2b7ec37cb65a6cc74ffb2c16cd8cff3184004";
|
|
31
|
+
export declare const REGISTRY_OBJECT_ID = "0x58bde5ffed343073d012d28c6955a8ee50caaefd085196e837150bc810e996c0";
|
|
32
|
+
export declare const INITIAL_SHARED_VERSION = "4";
|
|
33
33
|
export declare const LSK_FETCH_OFFSET = "fetch_offset";
|
|
34
34
|
export declare const LSK_ENCRYPTED_OUTPUTS = "encrypted_outputs";
|
|
35
35
|
export declare const VORTEX_SIGNATURE_DOMAIN = "VORTEXFI.XYZ";
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,iFACgD,CAAC;AAGjF,eAAO,MAAM,UAAU,iFACyD,CAAC;AAEjF,eAAO,MAAM,gBAAgB,iFAAa,CAAC;AAE3C,eAAO,MAAM,oBAAoB,UAiChC,CAAC;AAEF,oBAAY,OAAO;IACjB,OAAO,oBAAoB;IAC3B,KAAK,iBAAiB;IACtB,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;CAgBvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,uEACwC,CAAC;AAEvE,eAAO,MAAM,WAAW,uEAC8C,CAAC;AAEvE,eAAO,MAAM,kBAAkB,uEACuC,CAAC;AAEvE,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,iFACgD,CAAC;AAGjF,eAAO,MAAM,UAAU,iFACyD,CAAC;AAEjF,eAAO,MAAM,gBAAgB,iFAAa,CAAC;AAE3C,eAAO,MAAM,oBAAoB,UAiChC,CAAC;AAEF,oBAAY,OAAO;IACjB,OAAO,oBAAoB;IAC3B,KAAK,iBAAiB;IACtB,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;CAgBvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,uEACwC,CAAC;AAEvE,eAAO,MAAM,WAAW,uEAC8C,CAAC;AAEvE,eAAO,MAAM,kBAAkB,uEACuC,CAAC;AAEvE,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AAEtD,eAAO,MAAM,gBAAgB,uEACyC,CAAC;AAGvE,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C,eAAO,MAAM,YAAY,SAAU,CAAC;AAEpC,eAAO,MAAM,eAAe;;CAG3B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transaction } from '@mysten/sui/transactions';
|
|
2
2
|
import { DepositWithAccountArgs } from './vortex.types';
|
|
3
|
-
export declare const depositWithAccount: ({ tx, unspentUtxos, vortexSdk, vortexKeypair, vortexPool,
|
|
3
|
+
export declare const depositWithAccount: ({ tx, unspentUtxos, vortexSdk, vortexKeypair, vortexPool, root, getMerklePathFn, accountSecret, account, coinStructs, relayer, relayerFee, }: DepositWithAccountArgs) => Promise<{
|
|
4
4
|
tx: Transaction;
|
|
5
5
|
coin: import("@mysten/sui/dist/cjs/transactions").TransactionResult;
|
|
6
6
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deposit-with-account.d.ts","sourceRoot":"","sources":["../src/deposit-with-account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,eAAO,MAAM,kBAAkB,GAAU,
|
|
1
|
+
{"version":3,"file":"deposit-with-account.d.ts","sourceRoot":"","sources":["../src/deposit-with-account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,eAAO,MAAM,kBAAkB,GAAU,8IAatC,sBAAsB;;;EA4CxB,CAAC"}
|
package/dist/deposit.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transaction } from '@mysten/sui/transactions';
|
|
2
2
|
import { DepositArgs } from './vortex.types';
|
|
3
|
-
export declare const deposit: ({ tx, amount, unspentUtxos, vortexSdk, vortexKeypair, vortexPool,
|
|
3
|
+
export declare const deposit: ({ tx, amount, unspentUtxos, vortexSdk, vortexKeypair, vortexPool, root, getMerklePathFn, relayer, relayerFee, }: DepositArgs) => Promise<{
|
|
4
4
|
tx: Transaction;
|
|
5
5
|
coin: import("@mysten/sui/dist/cjs/transactions").TransactionResult;
|
|
6
6
|
}>;
|
package/dist/deposit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deposit.d.ts","sourceRoot":"","sources":["../src/deposit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAI7C,eAAO,MAAM,OAAO,GAAU,
|
|
1
|
+
{"version":3,"file":"deposit.d.ts","sourceRoot":"","sources":["../src/deposit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAI7C,eAAO,MAAM,OAAO,GAAU,iHAW3B,WAAW;;;EAoCb,CAAC"}
|
|
@@ -22,6 +22,8 @@ export declare class VortexKeypair {
|
|
|
22
22
|
static encryptFor(bytes: Buffer, recipientEncryptionKey: string): string;
|
|
23
23
|
static encryptUtxoFor(utxo: UtxoPayload, recipientEncryptionKey: string): string;
|
|
24
24
|
decryptUtxo(encryptedData: string): UtxoPayload;
|
|
25
|
+
static encryptBigIntFor(value: bigint, recipientEncryptionKey: string): string;
|
|
26
|
+
decryptBigInt(encryptedData: string): bigint;
|
|
25
27
|
sign(commitment: bigint, merklePath: bigint): bigint;
|
|
26
28
|
toString(): string;
|
|
27
29
|
address(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keypair.d.ts","sourceRoot":"","sources":["../../src/entities/keypair.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAUD,KAAK,aAAa,GAAG,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AAwCH,qBAAa,aAAa;;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,gBAAgB,CAAoB;gBAEhC,UAAU,EAAE,MAAM;IAgB9B,MAAM,CAAC,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa;IAM3D,MAAM,CAAC,QAAQ,IAAI,aAAa;IAUhC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa;WAkBhC,aAAa,CACxB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,aAAa,GACzB,OAAO,CAAC,aAAa,CAAC;IAgBzB,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,GAAG,MAAM;IA8BxE,MAAM,CAAC,cAAc,CACnB,IAAI,EAAE,WAAW,EACjB,sBAAsB,EAAE,MAAM,GAC7B,MAAM;IAMT,WAAW,CAAC,aAAa,EAAE,MAAM,GAAG,WAAW;IAe/C,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAKpD,QAAQ,IAAI,MAAM;IAMlB,OAAO,IAAI,MAAM;CAsDlB"}
|
|
1
|
+
{"version":3,"file":"keypair.d.ts","sourceRoot":"","sources":["../../src/entities/keypair.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAUD,KAAK,aAAa,GAAG,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AAwCH,qBAAa,aAAa;;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,gBAAgB,CAAoB;gBAEhC,UAAU,EAAE,MAAM;IAgB9B,MAAM,CAAC,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa;IAM3D,MAAM,CAAC,QAAQ,IAAI,aAAa;IAUhC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa;WAkBhC,aAAa,CACxB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,aAAa,GACzB,OAAO,CAAC,aAAa,CAAC;IAgBzB,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,GAAG,MAAM;IA8BxE,MAAM,CAAC,cAAc,CACnB,IAAI,EAAE,WAAW,EACjB,sBAAsB,EAAE,MAAM,GAC7B,MAAM;IAMT,WAAW,CAAC,aAAa,EAAE,MAAM,GAAG,WAAW;IAe/C,MAAM,CAAC,gBAAgB,CACrB,KAAK,EAAE,MAAM,EACb,sBAAsB,EAAE,MAAM,GAC7B,MAAM;IAQT,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;IAM5C,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAKpD,QAAQ,IAAI,MAAM;IAMlB,OAAO,IAAI,MAAM;CAsDlB"}
|
package/dist/index.js
CHANGED
|
@@ -3372,10 +3372,10 @@ const ERROR_CODES = {
|
|
|
3372
3372
|
13: 'Invalid relayer',
|
|
3373
3373
|
14: 'Invalid output flag',
|
|
3374
3374
|
};
|
|
3375
|
-
const VORTEX_PACKAGE_ID = '
|
|
3376
|
-
const UPGRADE_CAP = '
|
|
3377
|
-
const REGISTRY_OBJECT_ID = '
|
|
3378
|
-
const INITIAL_SHARED_VERSION = '
|
|
3375
|
+
const VORTEX_PACKAGE_ID = '0x4d505443700db57e664f024b4cdfe315a6b80ddc4d6b9f1013c7b68682edd4ab';
|
|
3376
|
+
const UPGRADE_CAP = '0x6c4464ca68d4bcd0c0626dcbb7c2b7ec37cb65a6cc74ffb2c16cd8cff3184004';
|
|
3377
|
+
const REGISTRY_OBJECT_ID = '0x58bde5ffed343073d012d28c6955a8ee50caaefd085196e837150bc810e996c0';
|
|
3378
|
+
const INITIAL_SHARED_VERSION = '4';
|
|
3379
3379
|
const LSK_FETCH_OFFSET = 'fetch_offset';
|
|
3380
3380
|
const LSK_ENCRYPTED_OUTPUTS = 'encrypted_outputs';
|
|
3381
3381
|
const VORTEX_SIGNATURE_DOMAIN = 'VORTEXFI.XYZ';
|
|
@@ -3384,7 +3384,7 @@ const TREASURY_ADDRESS = '0x894261575b948c035d002adc3ca4d73c683c01a1bfafac183870
|
|
|
3384
3384
|
const DEPOSIT_FEE_IN_BASIS_POINTS = 50n;
|
|
3385
3385
|
const BASIS_POINTS = 10000n;
|
|
3386
3386
|
const VORTEX_POOL_IDS = {
|
|
3387
|
-
[SUI_TYPE_ARG]: '
|
|
3387
|
+
[SUI_TYPE_ARG]: '0x1d8ddda4727146fd39f8181578ae71cd0f828039c68b4bfdba8a7499dda1d84d',
|
|
3388
3388
|
};
|
|
3389
3389
|
|
|
3390
3390
|
/******************************************************************************
|
|
@@ -39122,6 +39122,18 @@ class VortexKeypair {
|
|
|
39122
39122
|
vortexPool: normalizeSuiAddress(parts[3]),
|
|
39123
39123
|
};
|
|
39124
39124
|
}
|
|
39125
|
+
static encryptBigIntFor(value, recipientEncryptionKey) {
|
|
39126
|
+
// Convert BigInt to hex string, then to bytes
|
|
39127
|
+
const hex = value.toString(16);
|
|
39128
|
+
const hexPadded = hex.length % 2 === 0 ? hex : '0' + hex;
|
|
39129
|
+
const bytes = Buffer.from(hexPadded, 'hex');
|
|
39130
|
+
return VortexKeypair.encryptFor(bytes, recipientEncryptionKey);
|
|
39131
|
+
}
|
|
39132
|
+
decryptBigInt(encryptedData) {
|
|
39133
|
+
const decrypted = __classPrivateFieldGet(this, _VortexKeypair_instances, "m", _VortexKeypair_decrypt).call(this, encryptedData);
|
|
39134
|
+
const hex = decrypted.toString('hex');
|
|
39135
|
+
return BigInt('0x' + hex);
|
|
39136
|
+
}
|
|
39125
39137
|
sign(commitment, merklePath) {
|
|
39126
39138
|
invariant(this.privateKey !== null, 'Cannot sign without private key');
|
|
39127
39139
|
return poseidon3(this.privateKey, commitment, merklePath);
|
|
@@ -39258,10 +39270,10 @@ function getMerklePath(merkleTree, utxo) {
|
|
|
39258
39270
|
invariant(calculatedRoot === expectedRoot, `Root mismatch: calculated ${calculatedRoot}, expected ${expectedRoot}`);
|
|
39259
39271
|
return wasmPath;
|
|
39260
39272
|
}
|
|
39261
|
-
const toProveInput = ({
|
|
39273
|
+
const toProveInput = ({ root, merklePath0, merklePath1, publicAmount, nullifier0, nullifier1, commitment0, commitment1, vortexKeypair, inputUtxo0, inputUtxo1, outputUtxo0, outputUtxo1, vortexObjectId, accountSecret, }) => {
|
|
39262
39274
|
return {
|
|
39263
39275
|
vortex: BigInt(normalizeSuiAddress(vortexObjectId, !vortexObjectId.startsWith('0x'))) % BN254_FIELD_MODULUS,
|
|
39264
|
-
root
|
|
39276
|
+
root,
|
|
39265
39277
|
publicAmount,
|
|
39266
39278
|
inputNullifier0: nullifier0,
|
|
39267
39279
|
inputNullifier1: nullifier1,
|
|
@@ -39277,8 +39289,8 @@ const toProveInput = ({ merkleTree, publicAmount, nullifier0, nullifier1, commit
|
|
|
39277
39289
|
inBlinding1: inputUtxo1.blinding,
|
|
39278
39290
|
inPathIndex0: inputUtxo0.index,
|
|
39279
39291
|
inPathIndex1: inputUtxo1.index,
|
|
39280
|
-
merklePath0
|
|
39281
|
-
merklePath1
|
|
39292
|
+
merklePath0,
|
|
39293
|
+
merklePath1,
|
|
39282
39294
|
outPublicKey0: vortexKeypair.publicKey,
|
|
39283
39295
|
outPublicKey1: vortexKeypair.publicKey,
|
|
39284
39296
|
outAmount0: outputUtxo0.amount,
|
|
@@ -39596,7 +39608,7 @@ const buildMerkleTree = () => new fixedMerkleTree.MerkleTree(MERKLE_TREE_HEIGHT,
|
|
|
39596
39608
|
zeroElement: ZERO_VALUE.toString(),
|
|
39597
39609
|
});
|
|
39598
39610
|
|
|
39599
|
-
const prepareDepositProof = async ({ tx, amount, accountSecret, unspentUtxos, vortexSdk, vortexKeypair, vortexPool,
|
|
39611
|
+
const prepareDepositProof = async ({ tx, amount, accountSecret, unspentUtxos, vortexSdk, vortexKeypair, vortexPool, root, getMerklePathFn, relayer, relayerFee, }) => {
|
|
39600
39612
|
const vortexObjectId = typeof vortexPool === 'string' ? vortexPool : vortexPool.objectId;
|
|
39601
39613
|
// Deposits we do not need a recipient, so we use a random one.
|
|
39602
39614
|
const randomRecipient = normalizeSuiAddress(Ed25519Keypair.generate().toSuiAddress());
|
|
@@ -39644,7 +39656,9 @@ const prepareDepositProof = async ({ tx, amount, accountSecret, unspentUtxos, vo
|
|
|
39644
39656
|
const input = toProveInput({
|
|
39645
39657
|
vortexObjectId,
|
|
39646
39658
|
accountSecret,
|
|
39647
|
-
|
|
39659
|
+
root,
|
|
39660
|
+
merklePath0: await getMerklePathFn(inputUtxo0),
|
|
39661
|
+
merklePath1: await getMerklePathFn(inputUtxo1),
|
|
39648
39662
|
publicAmount: amount - relayerFee,
|
|
39649
39663
|
nullifier0,
|
|
39650
39664
|
nullifier1,
|
|
@@ -39673,7 +39687,7 @@ const prepareDepositProof = async ({ tx, amount, accountSecret, unspentUtxos, vo
|
|
|
39673
39687
|
tx: tx2,
|
|
39674
39688
|
vortexPool,
|
|
39675
39689
|
proofPoints: fromHex('0x' + proof.proofSerializedHex),
|
|
39676
|
-
root
|
|
39690
|
+
root,
|
|
39677
39691
|
publicValue: amount - relayerFee,
|
|
39678
39692
|
action: exports.Action.Deposit,
|
|
39679
39693
|
inputNullifier0: nullifier0,
|
|
@@ -39692,7 +39706,7 @@ const prepareDepositProof = async ({ tx, amount, accountSecret, unspentUtxos, vo
|
|
|
39692
39706
|
};
|
|
39693
39707
|
};
|
|
39694
39708
|
|
|
39695
|
-
const deposit = async ({ tx = new Transaction(), amount, unspentUtxos = [], vortexSdk, vortexKeypair, vortexPool,
|
|
39709
|
+
const deposit = async ({ tx = new Transaction(), amount, unspentUtxos = [], vortexSdk, vortexKeypair, vortexPool, root, getMerklePathFn, relayer = normalizeSuiAddress('0x0'), relayerFee = 0n, }) => {
|
|
39696
39710
|
invariant(unspentUtxos.length <= 2, 'Unspent UTXOs must be at most 2');
|
|
39697
39711
|
invariant(BN254_FIELD_MODULUS > amount, 'Amount must be less than field modulus');
|
|
39698
39712
|
const accountSecret = 0n;
|
|
@@ -39704,7 +39718,8 @@ const deposit = async ({ tx = new Transaction(), amount, unspentUtxos = [], vort
|
|
|
39704
39718
|
vortexSdk,
|
|
39705
39719
|
vortexKeypair,
|
|
39706
39720
|
vortexPool,
|
|
39707
|
-
|
|
39721
|
+
root,
|
|
39722
|
+
getMerklePathFn,
|
|
39708
39723
|
relayer,
|
|
39709
39724
|
relayerFee,
|
|
39710
39725
|
});
|
|
@@ -39718,7 +39733,7 @@ const deposit = async ({ tx = new Transaction(), amount, unspentUtxos = [], vort
|
|
|
39718
39733
|
});
|
|
39719
39734
|
};
|
|
39720
39735
|
|
|
39721
|
-
const prepareWithdraw = async ({ tx = new Transaction(), amount, unspentUtxos = [], vortexPool, vortexKeypair,
|
|
39736
|
+
const prepareWithdraw = async ({ tx = new Transaction(), amount, unspentUtxos = [], vortexPool, vortexKeypair, root, getMerklePathFn, recipient, relayer, relayerFee, vortexSdk, accountSecret, }) => {
|
|
39722
39737
|
invariant(unspentUtxos.length >= 1, 'Must have at least 1 unspent UTXO');
|
|
39723
39738
|
unspentUtxos.sort((a, b) => new bn_js.BN(b.amount).cmp(new bn_js.BN(a.amount)));
|
|
39724
39739
|
const totalUnspentUtxosAmount = unspentUtxos
|
|
@@ -39765,7 +39780,9 @@ const prepareWithdraw = async ({ tx = new Transaction(), amount, unspentUtxos =
|
|
|
39765
39780
|
const input = toProveInput({
|
|
39766
39781
|
vortexObjectId,
|
|
39767
39782
|
accountSecret,
|
|
39768
|
-
|
|
39783
|
+
root,
|
|
39784
|
+
merklePath0: await getMerklePathFn(inputUtxo0),
|
|
39785
|
+
merklePath1: await getMerklePathFn(inputUtxo1),
|
|
39769
39786
|
publicAmount: BN254_FIELD_MODULUS - amount,
|
|
39770
39787
|
nullifier0,
|
|
39771
39788
|
nullifier1,
|
|
@@ -39794,7 +39811,7 @@ const prepareWithdraw = async ({ tx = new Transaction(), amount, unspentUtxos =
|
|
|
39794
39811
|
vortexPool,
|
|
39795
39812
|
tx: tx2,
|
|
39796
39813
|
proofPoints: fromHex('0x' + proof.proofSerializedHex),
|
|
39797
|
-
root
|
|
39814
|
+
root,
|
|
39798
39815
|
publicValue: amount,
|
|
39799
39816
|
action: exports.Action.Withdraw,
|
|
39800
39817
|
inputNullifier0: nullifier0,
|
|
@@ -39810,14 +39827,15 @@ const prepareWithdraw = async ({ tx = new Transaction(), amount, unspentUtxos =
|
|
|
39810
39827
|
};
|
|
39811
39828
|
};
|
|
39812
39829
|
|
|
39813
|
-
const withdraw = async ({ tx = new Transaction(), amount, unspentUtxos = [], vortexPool, vortexKeypair,
|
|
39830
|
+
const withdraw = async ({ tx = new Transaction(), amount, unspentUtxos = [], vortexPool, vortexKeypair, root, getMerklePathFn, recipient, relayer, relayerFee, vortexSdk, }) => {
|
|
39814
39831
|
const { tx: tx3, moveProof, extData, vortexPool: pool, } = await prepareWithdraw({
|
|
39815
39832
|
tx,
|
|
39816
39833
|
amount,
|
|
39817
39834
|
unspentUtxos,
|
|
39818
39835
|
vortexPool,
|
|
39819
39836
|
vortexKeypair,
|
|
39820
|
-
|
|
39837
|
+
root,
|
|
39838
|
+
getMerklePathFn,
|
|
39821
39839
|
recipient,
|
|
39822
39840
|
relayer,
|
|
39823
39841
|
relayerFee,
|
|
@@ -39834,7 +39852,7 @@ const withdraw = async ({ tx = new Transaction(), amount, unspentUtxos = [], vor
|
|
|
39834
39852
|
});
|
|
39835
39853
|
};
|
|
39836
39854
|
|
|
39837
|
-
const depositWithAccount = async ({ tx = new Transaction(), unspentUtxos = [], vortexSdk, vortexKeypair, vortexPool,
|
|
39855
|
+
const depositWithAccount = async ({ tx = new Transaction(), unspentUtxos = [], vortexSdk, vortexKeypair, vortexPool, root, getMerklePathFn, accountSecret, account, coinStructs, relayer = normalizeSuiAddress('0x0'), relayerFee = 0n, }) => {
|
|
39838
39856
|
const coins = coinStructs.map((coin) => ({
|
|
39839
39857
|
objectId: coin.coinObjectId,
|
|
39840
39858
|
version: coin.version,
|
|
@@ -39842,7 +39860,7 @@ const depositWithAccount = async ({ tx = new Transaction(), unspentUtxos = [], v
|
|
|
39842
39860
|
}));
|
|
39843
39861
|
let amount = coinStructs.reduce((acc, coin) => acc + BigInt(coin.balance), 0n);
|
|
39844
39862
|
invariant(unspentUtxos.length <= 2, 'Unspent UTXOs must be at most 2');
|
|
39845
|
-
invariant(BN254_FIELD_MODULUS
|
|
39863
|
+
invariant(BN254_FIELD_MODULUS >= amount, 'Amount must be less than field modulus');
|
|
39846
39864
|
const { extData, moveProof, tx: tx3, } = await prepareDepositProof({
|
|
39847
39865
|
tx,
|
|
39848
39866
|
amount,
|
|
@@ -39851,7 +39869,8 @@ const depositWithAccount = async ({ tx = new Transaction(), unspentUtxos = [], v
|
|
|
39851
39869
|
vortexSdk,
|
|
39852
39870
|
vortexKeypair,
|
|
39853
39871
|
vortexPool,
|
|
39854
|
-
|
|
39872
|
+
root,
|
|
39873
|
+
getMerklePathFn,
|
|
39855
39874
|
relayer,
|
|
39856
39875
|
relayerFee,
|
|
39857
39876
|
});
|
|
@@ -39865,14 +39884,15 @@ const depositWithAccount = async ({ tx = new Transaction(), unspentUtxos = [], v
|
|
|
39865
39884
|
});
|
|
39866
39885
|
};
|
|
39867
39886
|
|
|
39868
|
-
const withdrawWithAccount = async ({ tx = new Transaction(), unspentUtxos = [], vortexPool, vortexKeypair,
|
|
39887
|
+
const withdrawWithAccount = async ({ tx = new Transaction(), unspentUtxos = [], vortexPool, vortexKeypair, root, getMerklePathFn, recipient, relayer, relayerFee, vortexSdk, account, accountSecret, amount, }) => {
|
|
39869
39888
|
const { tx: tx3, moveProof, extData, vortexPool: pool, } = await prepareWithdraw({
|
|
39870
39889
|
tx,
|
|
39871
39890
|
amount,
|
|
39872
39891
|
unspentUtxos,
|
|
39873
39892
|
vortexPool,
|
|
39874
39893
|
vortexKeypair,
|
|
39875
|
-
|
|
39894
|
+
root,
|
|
39895
|
+
getMerklePathFn,
|
|
39876
39896
|
recipient,
|
|
39877
39897
|
relayer,
|
|
39878
39898
|
relayerFee,
|