@interest-protocol/vortex-sdk 6.1.0 → 6.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.
@@ -1,4 +1,6 @@
1
- import { Element, MerkleTree as FixedMerkleTree } from 'fixed-merkle-tree';
1
+ import { Element, MerkleTree as FixedMerkleTree, SerializedTreeState } from 'fixed-merkle-tree';
2
+ export declare const merkleTreeHashFunction: (left: Element, right: Element) => string;
2
3
  export declare const buildMerkleTree: (elements?: Element[]) => FixedMerkleTree;
4
+ export declare const deserializeMerkleTree: (data: SerializedTreeState) => FixedMerkleTree;
3
5
  export type MerkleTree = FixedMerkleTree;
4
6
  //# sourceMappingURL=merkle-tree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"merkle-tree.d.ts","sourceRoot":"","sources":["../../src/entities/merkle-tree.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE3E,eAAO,MAAM,eAAe,GAAI,WAAU,OAAO,EAAO,oBAKpD,CAAC;AAEL,MAAM,MAAM,UAAU,GAAG,eAAe,CAAC"}
1
+ {"version":3,"file":"merkle-tree.d.ts","sourceRoot":"","sources":["../../src/entities/merkle-tree.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,EACP,UAAU,IAAI,eAAe,EAC7B,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,sBAAsB,GAAI,MAAM,OAAO,EAAE,OAAO,OAAO,WACjB,CAAC;AAEpD,eAAO,MAAM,eAAe,GAAI,WAAU,OAAO,EAAO,oBAIpD,CAAC;AAEL,eAAO,MAAM,qBAAqB,GAAI,MAAM,mBAAmB,oBACJ,CAAC;AAE5D,MAAM,MAAM,UAAU,GAAG,eAAe,CAAC"}
@@ -6,6 +6,12 @@ interface UtxoConstructorArgs {
6
6
  index?: bigint;
7
7
  vortexPool: string;
8
8
  }
9
+ interface MakeCommitmentArgs {
10
+ amount: bigint;
11
+ publicKey: string;
12
+ blinding: bigint;
13
+ vortexPool: string;
14
+ }
9
15
  export declare class Utxo {
10
16
  amount: bigint;
11
17
  blinding: bigint;
@@ -13,6 +19,7 @@ export declare class Utxo {
13
19
  index: bigint;
14
20
  vortexPool: string;
15
21
  constructor({ amount, blinding, keypair, index, vortexPool, }: UtxoConstructorArgs);
22
+ static makeCommitment({ amount, publicKey, blinding, vortexPool, }: MakeCommitmentArgs): bigint;
16
23
  static blinding(): bigint;
17
24
  commitment(): bigint;
18
25
  nullifier(): bigint;
@@ -1 +1 @@
1
- {"version":3,"file":"utxo.d.ts","sourceRoot":"","sources":["../../src/entities/utxo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C,UAAU,mBAAmB;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,IAAI;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,aAAa,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;gBAEP,EACV,MAAM,EACN,QAAQ,EACR,OAAO,EACP,KAAK,EACL,UAAU,GACX,EAAE,mBAAmB;IAQtB,MAAM,CAAC,QAAQ;IAIf,UAAU;IAWV,SAAS;IAST,OAAO;;;;;;CAQR"}
1
+ {"version":3,"file":"utxo.d.ts","sourceRoot":"","sources":["../../src/entities/utxo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAI1C,UAAU,mBAAmB;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,IAAI;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,aAAa,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;gBAEP,EACV,MAAM,EACN,QAAQ,EACR,OAAO,EACP,KAAK,EACL,UAAU,GACX,EAAE,mBAAmB;IAQtB,MAAM,CAAC,cAAc,CAAC,EACpB,MAAM,EACN,SAAS,EACT,QAAQ,EACR,UAAU,GACX,EAAE,kBAAkB;IASrB,MAAM,CAAC,QAAQ;IAIf,UAAU;IASV,SAAS;IAST,OAAO;;;;;;CAQR"}
package/dist/index.js CHANGED
@@ -39186,11 +39186,19 @@ class Utxo {
39186
39186
  this.index = index ?? 0n;
39187
39187
  this.vortexPool = vortexPool;
39188
39188
  }
39189
+ static makeCommitment({ amount, publicKey, blinding, vortexPool, }) {
39190
+ return poseidon4(amount, BigInt(publicKey), blinding, BigInt(normalizeSuiAddress(vortexPool, !vortexPool.startsWith('0x'))));
39191
+ }
39189
39192
  static blinding() {
39190
39193
  return BigInt(Math.floor(Math.random() * 1000000000));
39191
39194
  }
39192
39195
  commitment() {
39193
- return poseidon4(this.amount, BigInt(this.keypair.publicKey), this.blinding, BigInt(normalizeSuiAddress(this.vortexPool, !this.vortexPool.startsWith('0x'))));
39196
+ return Utxo.makeCommitment({
39197
+ amount: this.amount,
39198
+ publicKey: this.keypair.publicKey,
39199
+ blinding: this.blinding,
39200
+ vortexPool: this.vortexPool,
39201
+ });
39194
39202
  }
39195
39203
  nullifier() {
39196
39204
  const commitment = this.commitment();
@@ -39636,10 +39644,12 @@ const vortexSDK = new Vortex({
39636
39644
  });
39637
39645
 
39638
39646
  // packages/vortex/src/entities/merkle-tree.ts
39647
+ const merkleTreeHashFunction = (left, right) => poseidon2(BigInt(left), BigInt(right)).toString();
39639
39648
  const buildMerkleTree = (elements = []) => new fixedMerkleTree.MerkleTree(MERKLE_TREE_HEIGHT, elements, {
39640
- hashFunction: (left, right) => poseidon2(BigInt(left), BigInt(right)).toString(),
39649
+ hashFunction: merkleTreeHashFunction,
39641
39650
  zeroElement: ZERO_VALUE.toString(),
39642
39651
  });
39652
+ const deserializeMerkleTree = (data) => fixedMerkleTree.MerkleTree.deserialize(data, merkleTreeHashFunction);
39643
39653
 
39644
39654
  const prepareDepositProof = async ({ tx, amount, accountSecret, unspentUtxos, vortexSdk, vortexKeypair, vortexPool, root, getMerklePathFn, relayer, relayerFee, }) => {
39645
39655
  const vortexObjectId = typeof vortexPool === 'string' ? vortexPool : vortexPool.objectId;
@@ -40022,9 +40032,11 @@ exports.ZERO_VALUE = ZERO_VALUE;
40022
40032
  exports.buildMerkleTree = buildMerkleTree;
40023
40033
  exports.deposit = deposit;
40024
40034
  exports.depositWithAccount = depositWithAccount;
40035
+ exports.deserializeMerkleTree = deserializeMerkleTree;
40025
40036
  exports.finishSwap = finishSwap;
40026
40037
  exports.getMerklePath = getMerklePath;
40027
40038
  exports.getUnspentUtxos = getUnspentUtxos;
40039
+ exports.merkleTreeHashFunction = merkleTreeHashFunction;
40028
40040
  exports.parseNewCommitmentEvent = parseNewCommitmentEvent;
40029
40041
  exports.parseVortexPool = parseVortexPool;
40030
40042
  exports.poseidon1 = poseidon1;