@interest-protocol/vortex-sdk 7.1.0 → 7.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.
- package/dist/index.js +155 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +154 -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 +213 -0
package/dist/index.mjs
CHANGED
|
@@ -39262,6 +39262,159 @@ 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
|
+
},
|
|
39301
|
+
{
|
|
39302
|
+
MoveCall: {
|
|
39303
|
+
package: VORTEX_PACKAGE_ID,
|
|
39304
|
+
module: 'vortex',
|
|
39305
|
+
function: 'transact_with_account',
|
|
39306
|
+
arguments: [
|
|
39307
|
+
{ Input: 14 },
|
|
39308
|
+
{ Input: 15 },
|
|
39309
|
+
{ Result: 2 },
|
|
39310
|
+
{ Result: 1 },
|
|
39311
|
+
{ Result: 0 },
|
|
39312
|
+
],
|
|
39313
|
+
},
|
|
39314
|
+
},
|
|
39315
|
+
{
|
|
39316
|
+
TransferObjects: {
|
|
39317
|
+
objects: [{ Result: 3 }],
|
|
39318
|
+
},
|
|
39319
|
+
},
|
|
39320
|
+
];
|
|
39321
|
+
const EXPECTED_WITHDRAW_COMMANDS = [
|
|
39322
|
+
{
|
|
39323
|
+
MoveCall: {
|
|
39324
|
+
package: VORTEX_PACKAGE_ID,
|
|
39325
|
+
module: 'vortex_ext_data',
|
|
39326
|
+
function: 'new',
|
|
39327
|
+
arguments: [
|
|
39328
|
+
{ Input: 0 },
|
|
39329
|
+
{ Input: 1 },
|
|
39330
|
+
{ Input: 2 },
|
|
39331
|
+
{ Input: 3 },
|
|
39332
|
+
{ Input: 4 },
|
|
39333
|
+
{ Input: 5 },
|
|
39334
|
+
],
|
|
39335
|
+
},
|
|
39336
|
+
},
|
|
39337
|
+
{
|
|
39338
|
+
MoveCall: {
|
|
39339
|
+
package: VORTEX_PACKAGE_ID,
|
|
39340
|
+
module: 'vortex_proof',
|
|
39341
|
+
function: 'new',
|
|
39342
|
+
arguments: [
|
|
39343
|
+
{ Input: 6 },
|
|
39344
|
+
{ Input: 7 },
|
|
39345
|
+
{ Input: 8 },
|
|
39346
|
+
{ Input: 9 },
|
|
39347
|
+
{ Input: 10 },
|
|
39348
|
+
{ Input: 11 },
|
|
39349
|
+
{ Input: 12 },
|
|
39350
|
+
{ Input: 13 },
|
|
39351
|
+
],
|
|
39352
|
+
},
|
|
39353
|
+
},
|
|
39354
|
+
{
|
|
39355
|
+
MoveCall: {
|
|
39356
|
+
package: SUI_FRAMEWORK_ADDRESS,
|
|
39357
|
+
module: 'coin',
|
|
39358
|
+
function: 'zero',
|
|
39359
|
+
arguments: [],
|
|
39360
|
+
},
|
|
39361
|
+
},
|
|
39362
|
+
{
|
|
39363
|
+
MoveCall: {
|
|
39364
|
+
package: VORTEX_PACKAGE_ID,
|
|
39365
|
+
module: 'vortex',
|
|
39366
|
+
function: 'transact',
|
|
39367
|
+
arguments: [
|
|
39368
|
+
{ Input: 14 },
|
|
39369
|
+
{ Result: 2 },
|
|
39370
|
+
{ Result: 1 },
|
|
39371
|
+
{ Result: 0 },
|
|
39372
|
+
],
|
|
39373
|
+
},
|
|
39374
|
+
},
|
|
39375
|
+
{
|
|
39376
|
+
TransferObjects: {
|
|
39377
|
+
objects: [{ Result: 3 }],
|
|
39378
|
+
},
|
|
39379
|
+
},
|
|
39380
|
+
];
|
|
39381
|
+
function validateCommands(commands, expectedCommands) {
|
|
39382
|
+
invariant(commands.length === expectedCommands.length, `Expected ${expectedCommands.length} commands, got ${commands.length}`);
|
|
39383
|
+
for (let i = 0; i < commands.length; i++) {
|
|
39384
|
+
const actual = commands[i];
|
|
39385
|
+
const expected = expectedCommands[i];
|
|
39386
|
+
if ('MoveCall' in expected && expected.MoveCall) {
|
|
39387
|
+
invariant('MoveCall' in actual, `Command ${i}: Expected MoveCall`);
|
|
39388
|
+
const actualMoveCall = actual.MoveCall;
|
|
39389
|
+
const expectedMoveCall = expected.MoveCall;
|
|
39390
|
+
invariant(normalizeSuiAddress(actualMoveCall.package) ===
|
|
39391
|
+
normalizeSuiAddress(expectedMoveCall.package), `Command ${i}: Package mismatch. Expected ${expectedMoveCall.package}, got ${actualMoveCall.package}`);
|
|
39392
|
+
invariant(actualMoveCall.module === expectedMoveCall.module, `Command ${i}: Module mismatch. Expected ${expectedMoveCall.module}, got ${actualMoveCall.module}`);
|
|
39393
|
+
invariant(actualMoveCall.function === expectedMoveCall.function, `Command ${i}: Function mismatch. Expected ${expectedMoveCall.function}, got ${actualMoveCall.function}`);
|
|
39394
|
+
invariant(JSON.stringify(actualMoveCall.arguments) ===
|
|
39395
|
+
JSON.stringify(expectedMoveCall.arguments), `Command ${i}: Arguments mismatch`);
|
|
39396
|
+
}
|
|
39397
|
+
else if ('MakeMoveVec' in expected && expected.MakeMoveVec) {
|
|
39398
|
+
invariant('MakeMoveVec' in actual, `Command ${i}: Expected MakeMoveVec`);
|
|
39399
|
+
// Skip detailed validation of MakeMoveVec elements as they vary based on coin count
|
|
39400
|
+
}
|
|
39401
|
+
else if ('TransferObjects' in expected && expected.TransferObjects) {
|
|
39402
|
+
invariant('TransferObjects' in actual, `Command ${i}: Expected TransferObjects`);
|
|
39403
|
+
const actualTransfer = actual.TransferObjects;
|
|
39404
|
+
const expectedTransfer = expected.TransferObjects;
|
|
39405
|
+
invariant(JSON.stringify(actualTransfer.objects) ===
|
|
39406
|
+
JSON.stringify(expectedTransfer.objects), `Command ${i}: TransferObjects objects mismatch`);
|
|
39407
|
+
// Skip address validation as input index varies based on coin count
|
|
39408
|
+
}
|
|
39409
|
+
}
|
|
39410
|
+
}
|
|
39411
|
+
function validateDepositWithAccountCommands(commands) {
|
|
39412
|
+
validateCommands(commands, EXPECTED_DEPOSIT_WITH_ACCOUNT_COMMANDS);
|
|
39413
|
+
}
|
|
39414
|
+
function validateWithdrawCommands(commands) {
|
|
39415
|
+
validateCommands(commands, EXPECTED_WITHDRAW_COMMANDS);
|
|
39416
|
+
}
|
|
39417
|
+
|
|
39265
39418
|
function getMerklePath(merkleTree, utxo) {
|
|
39266
39419
|
// Handle zero-amount UTXOs
|
|
39267
39420
|
if (!utxo || utxo.amount === 0n) {
|
|
@@ -40141,5 +40294,5 @@ const finishSwap = async ({ tx = new Transaction(), amount, vortexSdk, vortexPoo
|
|
|
40141
40294
|
});
|
|
40142
40295
|
};
|
|
40143
40296
|
|
|
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 };
|
|
40297
|
+
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
40298
|
//# sourceMappingURL=index.mjs.map
|