@interest-protocol/vortex-sdk 6.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interest-protocol/vortex-sdk",
3
- "version": "6.2.0",
3
+ "version": "6.3.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "./dist/index.mjs",
@@ -37,8 +37,8 @@
37
37
  "rimraf": "^6.0.1",
38
38
  "ts-jest": "^29.1.1",
39
39
  "tsup": "^8.3.5",
40
- "@interest-protocol/prettier-config": "1.0.0",
41
- "@interest-protocol/typescript-config": "1.0.0"
40
+ "@interest-protocol/typescript-config": "1.0.0",
41
+ "@interest-protocol/prettier-config": "1.0.0"
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public",
@@ -1,6 +1,7 @@
1
1
  import { VortexKeypair } from './keypair';
2
2
  import { poseidon3, poseidon4 } from '../crypto';
3
3
  import { normalizeSuiAddress } from '@mysten/sui/utils';
4
+
4
5
  interface UtxoConstructorArgs {
5
6
  amount: bigint;
6
7
  blinding?: bigint;
@@ -9,6 +10,13 @@ interface UtxoConstructorArgs {
9
10
  vortexPool: string;
10
11
  }
11
12
 
13
+ interface MakeCommitmentArgs {
14
+ amount: bigint;
15
+ publicKey: string;
16
+ blinding: bigint;
17
+ vortexPool: string;
18
+ }
19
+
12
20
  export class Utxo {
13
21
  amount: bigint;
14
22
  blinding: bigint;
@@ -30,19 +38,31 @@ export class Utxo {
30
38
  this.vortexPool = vortexPool;
31
39
  }
32
40
 
41
+ static makeCommitment({
42
+ amount,
43
+ publicKey,
44
+ blinding,
45
+ vortexPool,
46
+ }: MakeCommitmentArgs) {
47
+ return poseidon4(
48
+ amount,
49
+ BigInt(publicKey),
50
+ blinding,
51
+ BigInt(normalizeSuiAddress(vortexPool, !vortexPool.startsWith('0x')))
52
+ );
53
+ }
54
+
33
55
  static blinding() {
34
56
  return BigInt(Math.floor(Math.random() * 1_000_000_000));
35
57
  }
36
58
 
37
59
  commitment() {
38
- return poseidon4(
39
- this.amount,
40
- BigInt(this.keypair.publicKey),
41
- this.blinding,
42
- BigInt(
43
- normalizeSuiAddress(this.vortexPool, !this.vortexPool.startsWith('0x'))
44
- )
45
- );
60
+ return Utxo.makeCommitment({
61
+ amount: this.amount,
62
+ publicKey: this.keypair.publicKey,
63
+ blinding: this.blinding,
64
+ vortexPool: this.vortexPool,
65
+ });
46
66
  }
47
67
 
48
68
  nullifier() {