@interest-protocol/vortex-sdk 7.0.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 +166 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +165 -3
- 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/dist/vortex-api.d.ts.map +1 -1
- package/dist/vortex-api.types.d.ts +1 -0
- package/dist/vortex-api.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/validate.ts +228 -0
- package/src/vortex-api.ts +5 -2
- package/src/vortex-api.types.ts +1 -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) {
|
|
@@ -39746,7 +39907,7 @@ class VortexAPI {
|
|
|
39746
39907
|
async executeTransaction(args) {
|
|
39747
39908
|
const response = await __classPrivateFieldGet(this, _VortexAPI_instances, "m", _VortexAPI_post).call(this, '/api/v1/transactions', {
|
|
39748
39909
|
txBytes: args.txBytes,
|
|
39749
|
-
});
|
|
39910
|
+
}, args.apiKey);
|
|
39750
39911
|
__classPrivateFieldGet(this, _VortexAPI_instances, "m", _VortexAPI_assertSuccess).call(this, response);
|
|
39751
39912
|
return response;
|
|
39752
39913
|
}
|
|
@@ -39764,11 +39925,12 @@ _VortexAPI_apiUrl = new WeakMap(), _VortexAPI_instances = new WeakSet(), _Vortex
|
|
|
39764
39925
|
},
|
|
39765
39926
|
});
|
|
39766
39927
|
return response.json();
|
|
39767
|
-
}, _VortexAPI_post = async function _VortexAPI_post(path, body) {
|
|
39928
|
+
}, _VortexAPI_post = async function _VortexAPI_post(path, body, apiKey) {
|
|
39768
39929
|
const response = await fetch(`${__classPrivateFieldGet(this, _VortexAPI_apiUrl, "f")}${path}`, {
|
|
39769
39930
|
method: 'POST',
|
|
39770
39931
|
headers: {
|
|
39771
39932
|
'Content-Type': 'application/json',
|
|
39933
|
+
'x-api-key': apiKey ?? '',
|
|
39772
39934
|
},
|
|
39773
39935
|
body: JSON.stringify(body),
|
|
39774
39936
|
});
|
|
@@ -40140,5 +40302,5 @@ const finishSwap = async ({ tx = new Transaction(), amount, vortexSdk, vortexPoo
|
|
|
40140
40302
|
});
|
|
40141
40303
|
};
|
|
40142
40304
|
|
|
40143
|
-
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 };
|
|
40144
40306
|
//# sourceMappingURL=index.mjs.map
|