@interest-protocol/vortex-sdk 7.1.0 → 7.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/index.js +163 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +162 -1
- package/dist/index.mjs.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/validate.d.ts +3 -0
- package/dist/utils/validate.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/utils/index.ts +1 -0
- package/src/utils/validate.ts +228 -0
package/dist/index.mjs
CHANGED
|
@@ -39262,6 +39262,167 @@ const getUnspentUtxosWithApi = async ({ commitments, vortexKeypair, vortexSdk, v
|
|
|
39262
39262
|
return unspentUtxos;
|
|
39263
39263
|
};
|
|
39264
39264
|
|
|
39265
|
+
const EXPECTED_DEPOSIT_WITH_ACCOUNT_COMMANDS = [
|
|
39266
|
+
{
|
|
39267
|
+
MoveCall: {
|
|
39268
|
+
package: VORTEX_PACKAGE_ID,
|
|
39269
|
+
module: 'vortex_ext_data',
|
|
39270
|
+
function: 'new',
|
|
39271
|
+
arguments: [
|
|
39272
|
+
{ Input: 0 },
|
|
39273
|
+
{ Input: 1 },
|
|
39274
|
+
{ Input: 2 },
|
|
39275
|
+
{ Input: 3 },
|
|
39276
|
+
{ Input: 4 },
|
|
39277
|
+
{ Input: 5 },
|
|
39278
|
+
],
|
|
39279
|
+
},
|
|
39280
|
+
},
|
|
39281
|
+
{
|
|
39282
|
+
MoveCall: {
|
|
39283
|
+
package: VORTEX_PACKAGE_ID,
|
|
39284
|
+
module: 'vortex_proof',
|
|
39285
|
+
function: 'new',
|
|
39286
|
+
arguments: [
|
|
39287
|
+
{ Input: 6 },
|
|
39288
|
+
{ Input: 7 },
|
|
39289
|
+
{ Input: 8 },
|
|
39290
|
+
{ Input: 9 },
|
|
39291
|
+
{ Input: 10 },
|
|
39292
|
+
{ Input: 11 },
|
|
39293
|
+
{ Input: 12 },
|
|
39294
|
+
{ Input: 13 },
|
|
39295
|
+
],
|
|
39296
|
+
},
|
|
39297
|
+
},
|
|
39298
|
+
{
|
|
39299
|
+
MakeMoveVec: {
|
|
39300
|
+
elements: [{ Input: 16 }],
|
|
39301
|
+
},
|
|
39302
|
+
},
|
|
39303
|
+
{
|
|
39304
|
+
MoveCall: {
|
|
39305
|
+
package: VORTEX_PACKAGE_ID,
|
|
39306
|
+
module: 'vortex',
|
|
39307
|
+
function: 'transact_with_account',
|
|
39308
|
+
arguments: [
|
|
39309
|
+
{ Input: 14 },
|
|
39310
|
+
{ Input: 15 },
|
|
39311
|
+
{ Result: 2 },
|
|
39312
|
+
{ Result: 1 },
|
|
39313
|
+
{ Result: 0 },
|
|
39314
|
+
],
|
|
39315
|
+
},
|
|
39316
|
+
},
|
|
39317
|
+
{
|
|
39318
|
+
TransferObjects: {
|
|
39319
|
+
objects: [{ Result: 3 }],
|
|
39320
|
+
address: { Input: 17 },
|
|
39321
|
+
},
|
|
39322
|
+
},
|
|
39323
|
+
];
|
|
39324
|
+
const EXPECTED_WITHDRAW_COMMANDS = [
|
|
39325
|
+
{
|
|
39326
|
+
MoveCall: {
|
|
39327
|
+
package: VORTEX_PACKAGE_ID,
|
|
39328
|
+
module: 'vortex_ext_data',
|
|
39329
|
+
function: 'new',
|
|
39330
|
+
arguments: [
|
|
39331
|
+
{ Input: 0 },
|
|
39332
|
+
{ Input: 1 },
|
|
39333
|
+
{ Input: 2 },
|
|
39334
|
+
{ Input: 3 },
|
|
39335
|
+
{ Input: 4 },
|
|
39336
|
+
{ Input: 5 },
|
|
39337
|
+
],
|
|
39338
|
+
},
|
|
39339
|
+
},
|
|
39340
|
+
{
|
|
39341
|
+
MoveCall: {
|
|
39342
|
+
package: VORTEX_PACKAGE_ID,
|
|
39343
|
+
module: 'vortex_proof',
|
|
39344
|
+
function: 'new',
|
|
39345
|
+
arguments: [
|
|
39346
|
+
{ Input: 6 },
|
|
39347
|
+
{ Input: 7 },
|
|
39348
|
+
{ Input: 8 },
|
|
39349
|
+
{ Input: 9 },
|
|
39350
|
+
{ Input: 10 },
|
|
39351
|
+
{ Input: 11 },
|
|
39352
|
+
{ Input: 12 },
|
|
39353
|
+
{ Input: 13 },
|
|
39354
|
+
],
|
|
39355
|
+
},
|
|
39356
|
+
},
|
|
39357
|
+
{
|
|
39358
|
+
MoveCall: {
|
|
39359
|
+
package: SUI_FRAMEWORK_ADDRESS,
|
|
39360
|
+
module: 'coin',
|
|
39361
|
+
function: 'zero',
|
|
39362
|
+
arguments: [],
|
|
39363
|
+
},
|
|
39364
|
+
},
|
|
39365
|
+
{
|
|
39366
|
+
MoveCall: {
|
|
39367
|
+
package: VORTEX_PACKAGE_ID,
|
|
39368
|
+
module: 'vortex',
|
|
39369
|
+
function: 'transact',
|
|
39370
|
+
arguments: [
|
|
39371
|
+
{ Input: 14 },
|
|
39372
|
+
{ Result: 2 },
|
|
39373
|
+
{ Result: 1 },
|
|
39374
|
+
{ Result: 0 },
|
|
39375
|
+
],
|
|
39376
|
+
},
|
|
39377
|
+
},
|
|
39378
|
+
{
|
|
39379
|
+
TransferObjects: {
|
|
39380
|
+
objects: [{ Result: 3 }],
|
|
39381
|
+
address: { Input: 15 },
|
|
39382
|
+
},
|
|
39383
|
+
},
|
|
39384
|
+
];
|
|
39385
|
+
function validateCommands(commands, expectedCommands) {
|
|
39386
|
+
invariant(commands.length === expectedCommands.length, `Expected ${expectedCommands.length} commands, got ${commands.length}`);
|
|
39387
|
+
for (let i = 0; i < commands.length; i++) {
|
|
39388
|
+
const actual = commands[i];
|
|
39389
|
+
const expected = expectedCommands[i];
|
|
39390
|
+
if ('MoveCall' in expected && expected.MoveCall) {
|
|
39391
|
+
invariant('MoveCall' in actual, `Command ${i}: Expected MoveCall`);
|
|
39392
|
+
const actualMoveCall = actual.MoveCall;
|
|
39393
|
+
const expectedMoveCall = expected.MoveCall;
|
|
39394
|
+
invariant(normalizeSuiAddress(actualMoveCall.package) ===
|
|
39395
|
+
normalizeSuiAddress(expectedMoveCall.package), `Command ${i}: Package mismatch. Expected ${expectedMoveCall.package}, got ${actualMoveCall.package}`);
|
|
39396
|
+
invariant(actualMoveCall.module === expectedMoveCall.module, `Command ${i}: Module mismatch. Expected ${expectedMoveCall.module}, got ${actualMoveCall.module}`);
|
|
39397
|
+
invariant(actualMoveCall.function === expectedMoveCall.function, `Command ${i}: Function mismatch. Expected ${expectedMoveCall.function}, got ${actualMoveCall.function}`);
|
|
39398
|
+
invariant(JSON.stringify(actualMoveCall.arguments) ===
|
|
39399
|
+
JSON.stringify(expectedMoveCall.arguments), `Command ${i}: Arguments mismatch`);
|
|
39400
|
+
}
|
|
39401
|
+
else if ('MakeMoveVec' in expected && expected.MakeMoveVec) {
|
|
39402
|
+
invariant('MakeMoveVec' in actual, `Command ${i}: Expected MakeMoveVec`);
|
|
39403
|
+
const actualMakeMoveVec = actual.MakeMoveVec;
|
|
39404
|
+
const expectedMakeMoveVec = expected.MakeMoveVec;
|
|
39405
|
+
invariant(JSON.stringify(actualMakeMoveVec.elements) ===
|
|
39406
|
+
JSON.stringify(expectedMakeMoveVec.elements), `Command ${i}: MakeMoveVec elements mismatch`);
|
|
39407
|
+
}
|
|
39408
|
+
else if ('TransferObjects' in expected && expected.TransferObjects) {
|
|
39409
|
+
invariant('TransferObjects' in actual, `Command ${i}: Expected TransferObjects`);
|
|
39410
|
+
const actualTransfer = actual.TransferObjects;
|
|
39411
|
+
const expectedTransfer = expected.TransferObjects;
|
|
39412
|
+
invariant(JSON.stringify(actualTransfer.objects) ===
|
|
39413
|
+
JSON.stringify(expectedTransfer.objects), `Command ${i}: TransferObjects objects mismatch`);
|
|
39414
|
+
invariant(JSON.stringify(actualTransfer.address) ===
|
|
39415
|
+
JSON.stringify(expectedTransfer.address), `Command ${i}: TransferObjects address mismatch`);
|
|
39416
|
+
}
|
|
39417
|
+
}
|
|
39418
|
+
}
|
|
39419
|
+
function validateDepositWithAccountCommands(commands) {
|
|
39420
|
+
validateCommands(commands, EXPECTED_DEPOSIT_WITH_ACCOUNT_COMMANDS);
|
|
39421
|
+
}
|
|
39422
|
+
function validateWithdrawCommands(commands) {
|
|
39423
|
+
validateCommands(commands, EXPECTED_WITHDRAW_COMMANDS);
|
|
39424
|
+
}
|
|
39425
|
+
|
|
39265
39426
|
function getMerklePath(merkleTree, utxo) {
|
|
39266
39427
|
// Handle zero-amount UTXOs
|
|
39267
39428
|
if (!utxo || utxo.amount === 0n) {
|
|
@@ -40141,5 +40302,5 @@ const finishSwap = async ({ tx = new Transaction(), amount, vortexSdk, vortexPoo
|
|
|
40141
40302
|
});
|
|
40142
40303
|
};
|
|
40143
40304
|
|
|
40144
|
-
export { Action, BASIS_POINTS, BN254_FIELD_MODULUS, DEPOSIT_FEE_IN_BASIS_POINTS, EMPTY_COMMITMENT, EMPTY_SUBTREE_HASHES, ERROR_CODES, INITIAL_SHARED_VERSION, LSK_ENCRYPTED_OUTPUTS, LSK_FETCH_OFFSET, MERKLE_TREE_HEIGHT, Modules, OPT, REGISTRY_OBJECT_ID, ROOT_HISTORY_SIZE, TREASURY_ADDRESS, Utxo, VORTEX_API_URL, VORTEX_PACKAGE_ID, VORTEX_POOL_IDS, VORTEX_SIGNATURE_DOMAIN, VORTEX_SWAP_PACKAGE_ID, VORTEX_SWAP_UPGRADE_CAP, VORTEX_UPGRADE_CAP, Vortex, VortexAPI, VortexKeypair, ZERO_VALUE, buildMerkleTree, deposit, depositWithAccount, deserializeMerkleTree, finishSwap, getMerklePath, getUnspentUtxos, getUnspentUtxosWithApi, merkleTreeHashFunction, parseNewCommitmentEvent, parseVortexPool, poseidon1, poseidon2, poseidon3, poseidon4, prove, startSwap, toProveInput, verify, vortexAPI, vortexSDK, withdraw, withdrawWithAccount };
|
|
40305
|
+
export { Action, BASIS_POINTS, BN254_FIELD_MODULUS, DEPOSIT_FEE_IN_BASIS_POINTS, EMPTY_COMMITMENT, EMPTY_SUBTREE_HASHES, ERROR_CODES, INITIAL_SHARED_VERSION, LSK_ENCRYPTED_OUTPUTS, LSK_FETCH_OFFSET, MERKLE_TREE_HEIGHT, Modules, OPT, REGISTRY_OBJECT_ID, ROOT_HISTORY_SIZE, TREASURY_ADDRESS, Utxo, VORTEX_API_URL, VORTEX_PACKAGE_ID, VORTEX_POOL_IDS, VORTEX_SIGNATURE_DOMAIN, VORTEX_SWAP_PACKAGE_ID, VORTEX_SWAP_UPGRADE_CAP, VORTEX_UPGRADE_CAP, Vortex, VortexAPI, VortexKeypair, ZERO_VALUE, buildMerkleTree, deposit, depositWithAccount, deserializeMerkleTree, finishSwap, getMerklePath, getUnspentUtxos, getUnspentUtxosWithApi, merkleTreeHashFunction, parseNewCommitmentEvent, parseVortexPool, poseidon1, poseidon2, poseidon3, poseidon4, prove, startSwap, toProveInput, validateDepositWithAccountCommands, validateWithdrawCommands, verify, vortexAPI, vortexSDK, withdraw, withdrawWithAccount };
|
|
40145
40306
|
//# sourceMappingURL=index.mjs.map
|