@unlink-xyz/core 0.1.2 → 0.1.3-canary.0877bfe
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/account/{zkAccount.d.ts → account.d.ts} +7 -5
- package/dist/account/account.d.ts.map +1 -0
- package/dist/account/{zkAccount.js → account.js} +57 -43
- package/dist/browser/index.js +108202 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/circuits.json +74 -0
- package/dist/clients/broadcaster.d.ts +7 -2
- package/dist/clients/broadcaster.d.ts.map +1 -1
- package/dist/clients/broadcaster.js +9 -1
- package/dist/clients/http.d.ts +6 -0
- package/dist/clients/http.d.ts.map +1 -1
- package/dist/clients/http.js +24 -9
- package/dist/clients/indexer.d.ts +11 -0
- package/dist/clients/indexer.d.ts.map +1 -1
- package/dist/clients/indexer.js +40 -11
- package/dist/config.d.ts +28 -9
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +33 -26
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +5 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +5 -2
- package/dist/crypto-adapters/auto-init.d.ts +2 -0
- package/dist/crypto-adapters/auto-init.d.ts.map +1 -0
- package/dist/crypto-adapters/auto-init.js +7 -0
- package/dist/crypto-adapters/index.d.ts +22 -0
- package/dist/crypto-adapters/index.d.ts.map +1 -0
- package/dist/crypto-adapters/index.js +47 -0
- package/dist/crypto-adapters/polyfills.d.ts +5 -0
- package/dist/crypto-adapters/polyfills.d.ts.map +1 -0
- package/dist/crypto-adapters/polyfills.js +8 -0
- package/dist/errors.d.ts +9 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +18 -0
- package/dist/history/index.d.ts +3 -0
- package/dist/history/index.d.ts.map +1 -0
- package/dist/history/index.js +2 -0
- package/dist/history/service.d.ts +46 -0
- package/dist/history/service.d.ts.map +1 -0
- package/dist/history/service.js +354 -0
- package/dist/history/types.d.ts +21 -0
- package/dist/history/types.d.ts.map +1 -0
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -4
- package/dist/keys/address.d.ts +13 -0
- package/dist/keys/address.d.ts.map +1 -0
- package/dist/keys/address.js +55 -0
- package/dist/keys/derive.d.ts +37 -0
- package/dist/keys/derive.d.ts.map +1 -0
- package/dist/keys/derive.js +112 -0
- package/dist/keys/hex.d.ts +17 -0
- package/dist/keys/hex.d.ts.map +1 -0
- package/dist/keys/hex.js +66 -0
- package/dist/keys/index.d.ts +5 -0
- package/dist/keys/index.d.ts.map +1 -0
- package/dist/keys/index.js +4 -0
- package/dist/keys/mnemonic.d.ts +8 -0
- package/dist/keys/mnemonic.d.ts.map +1 -0
- package/dist/keys/mnemonic.js +23 -0
- package/dist/keys.d.ts +4 -1
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js +4 -0
- package/dist/prover/config.d.ts +1 -15
- package/dist/prover/config.d.ts.map +1 -1
- package/dist/prover/config.js +1 -11
- package/dist/prover/prover.d.ts +15 -4
- package/dist/prover/prover.d.ts.map +1 -1
- package/dist/prover/prover.js +115 -98
- package/dist/prover/registry.d.ts +3 -30
- package/dist/prover/registry.d.ts.map +1 -1
- package/dist/prover/registry.js +12 -51
- package/dist/state/merkle/hydrator.d.ts.map +1 -1
- package/dist/state/merkle/hydrator.js +3 -2
- package/dist/state/merkle/index.d.ts +1 -1
- package/dist/state/merkle/index.d.ts.map +1 -1
- package/dist/state/merkle/index.js +1 -1
- package/dist/state/merkle/merkle-tree.d.ts +8 -0
- package/dist/state/merkle/merkle-tree.d.ts.map +1 -1
- package/dist/state/merkle/merkle-tree.js +16 -7
- package/dist/state/store/ciphertext-store.d.ts +4 -0
- package/dist/state/store/ciphertext-store.d.ts.map +1 -1
- package/dist/state/store/ciphertext-store.js +12 -0
- package/dist/state/store/history-store.d.ts +24 -0
- package/dist/state/store/history-store.d.ts.map +1 -0
- package/dist/state/store/history-store.js +53 -0
- package/dist/state/store/index.d.ts +3 -2
- package/dist/state/store/index.d.ts.map +1 -1
- package/dist/state/store/index.js +1 -0
- package/dist/state/store/job-store.d.ts +7 -7
- package/dist/state/store/job-store.d.ts.map +1 -1
- package/dist/state/store/job-store.js +65 -39
- package/dist/state/store/jobs.d.ts +65 -18
- package/dist/state/store/jobs.d.ts.map +1 -1
- package/dist/state/store/leaf-store.d.ts.map +1 -1
- package/dist/state/store/leaf-store.js +0 -3
- package/dist/state/store/note-store.d.ts +7 -7
- package/dist/state/store/note-store.d.ts.map +1 -1
- package/dist/state/store/note-store.js +38 -34
- package/dist/state/store/nullifier-store.d.ts +9 -0
- package/dist/state/store/nullifier-store.d.ts.map +1 -1
- package/dist/state/store/nullifier-store.js +32 -2
- package/dist/state/store/records.d.ts +31 -2
- package/dist/state/store/records.d.ts.map +1 -1
- package/dist/state/store/root-store.d.ts.map +1 -1
- package/dist/state/store/root-store.js +0 -4
- package/dist/state/store/store.d.ts +61 -27
- package/dist/state/store/store.d.ts.map +1 -1
- package/dist/state/store/store.js +92 -1
- package/dist/storage/indexeddb.js +1 -1
- package/dist/storage/memory.d.ts.map +1 -1
- package/dist/storage/memory.js +5 -1
- package/dist/transactions/deposit.d.ts +12 -15
- package/dist/transactions/deposit.d.ts.map +1 -1
- package/dist/transactions/deposit.js +203 -152
- package/dist/transactions/index.d.ts +7 -4
- package/dist/transactions/index.d.ts.map +1 -1
- package/dist/transactions/index.js +7 -2
- package/dist/transactions/note-selection.d.ts +17 -0
- package/dist/transactions/note-selection.d.ts.map +1 -0
- package/dist/transactions/note-selection.js +201 -0
- package/dist/transactions/note-sync.d.ts +5 -33
- package/dist/transactions/note-sync.d.ts.map +1 -1
- package/dist/transactions/note-sync.js +320 -155
- package/dist/transactions/reconcile.d.ts +10 -12
- package/dist/transactions/reconcile.d.ts.map +1 -1
- package/dist/transactions/reconcile.js +53 -7
- package/dist/transactions/transact.d.ts +13 -24
- package/dist/transactions/transact.d.ts.map +1 -1
- package/dist/transactions/transact.js +393 -507
- package/dist/transactions/transaction-planner.d.ts +34 -0
- package/dist/transactions/transaction-planner.d.ts.map +1 -0
- package/dist/transactions/transaction-planner.js +116 -0
- package/dist/transactions/transfer-planner.d.ts +36 -0
- package/dist/transactions/transfer-planner.d.ts.map +1 -0
- package/dist/transactions/transfer-planner.js +85 -0
- package/dist/transactions/types/deposit.d.ts +67 -0
- package/dist/transactions/types/deposit.d.ts.map +1 -0
- package/dist/transactions/types/domain.d.ts +67 -0
- package/dist/transactions/types/domain.d.ts.map +1 -0
- package/dist/transactions/types/domain.js +4 -0
- package/dist/transactions/types/index.d.ts +18 -0
- package/dist/transactions/types/index.d.ts.map +1 -0
- package/dist/transactions/types/index.js +17 -0
- package/dist/transactions/types/options.d.ts +45 -0
- package/dist/transactions/types/options.d.ts.map +1 -0
- package/dist/transactions/types/options.js +1 -0
- package/dist/transactions/types/planning.d.ts +80 -0
- package/dist/transactions/types/planning.d.ts.map +1 -0
- package/dist/transactions/types/planning.js +1 -0
- package/dist/transactions/types/state-stores.d.ts +103 -0
- package/dist/transactions/types/state-stores.d.ts.map +1 -0
- package/dist/transactions/types/state-stores.js +1 -0
- package/dist/transactions/types/transact.d.ts +76 -0
- package/dist/transactions/types/transact.d.ts.map +1 -0
- package/dist/transactions/types/transact.js +1 -0
- package/dist/transactions/withdrawal-planner.d.ts +58 -0
- package/dist/transactions/withdrawal-planner.d.ts.map +1 -0
- package/dist/transactions/withdrawal-planner.js +128 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/tsup.browser.config.d.ts +7 -0
- package/dist/tsup.browser.config.d.ts.map +1 -0
- package/dist/tsup.browser.config.js +34 -0
- package/dist/utils/amounts.d.ts +39 -0
- package/dist/utils/amounts.d.ts.map +1 -0
- package/dist/utils/amounts.js +89 -0
- package/dist/utils/async.d.ts +9 -0
- package/dist/utils/async.d.ts.map +1 -1
- package/dist/utils/async.js +24 -0
- package/dist/utils/bigint.js +7 -7
- package/dist/utils/crypto.d.ts +11 -5
- package/dist/utils/crypto.d.ts.map +1 -1
- package/dist/utils/crypto.js +12 -6
- package/dist/utils/format.d.ts +25 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +33 -0
- package/dist/utils/json-codec.js +1 -1
- package/dist/utils/notes.d.ts +15 -0
- package/dist/utils/notes.d.ts.map +1 -0
- package/dist/utils/notes.js +14 -0
- package/dist/utils/polling.d.ts +5 -0
- package/dist/utils/polling.d.ts.map +1 -1
- package/dist/utils/polling.js +5 -0
- package/dist/utils/random.d.ts +13 -0
- package/dist/utils/random.d.ts.map +1 -0
- package/dist/utils/random.js +27 -0
- package/dist/utils/secure-memory.d.ts +25 -0
- package/dist/utils/secure-memory.d.ts.map +1 -0
- package/dist/utils/secure-memory.js +28 -0
- package/dist/utils/signature.d.ts +6 -0
- package/dist/utils/signature.d.ts.map +1 -1
- package/dist/utils/signature.js +8 -6
- package/dist/utils/validators.d.ts +21 -10
- package/dist/utils/validators.d.ts.map +1 -1
- package/dist/utils/validators.js +37 -11
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/dist/vitest.config.js +13 -0
- package/package.json +28 -11
- package/.eslintrc.json +0 -4
- package/account/zkAccount.test.ts +0 -316
- package/account/zkAccount.ts +0 -222
- package/clients/broadcaster.ts +0 -67
- package/clients/http.ts +0 -94
- package/clients/indexer.ts +0 -150
- package/config.ts +0 -39
- package/core.ts +0 -17
- package/dist/account/railgun-imports-prototype.d.ts +0 -12
- package/dist/account/railgun-imports-prototype.d.ts.map +0 -1
- package/dist/account/railgun-imports-prototype.js +0 -30
- package/dist/account/zkAccount.d.ts.map +0 -1
- package/dist/key-derivation/babyjubjub.d.ts +0 -9
- package/dist/key-derivation/babyjubjub.d.ts.map +0 -1
- package/dist/key-derivation/babyjubjub.js +0 -9
- package/dist/key-derivation/bech32.d.ts +0 -22
- package/dist/key-derivation/bech32.d.ts.map +0 -1
- package/dist/key-derivation/bech32.js +0 -86
- package/dist/key-derivation/bip32.d.ts +0 -17
- package/dist/key-derivation/bip32.d.ts.map +0 -1
- package/dist/key-derivation/bip32.js +0 -41
- package/dist/key-derivation/bip39.d.ts +0 -22
- package/dist/key-derivation/bip39.d.ts.map +0 -1
- package/dist/key-derivation/bip39.js +0 -56
- package/dist/key-derivation/bytes.d.ts +0 -19
- package/dist/key-derivation/bytes.d.ts.map +0 -1
- package/dist/key-derivation/bytes.js +0 -92
- package/dist/key-derivation/hash.d.ts +0 -3
- package/dist/key-derivation/hash.d.ts.map +0 -1
- package/dist/key-derivation/hash.js +0 -10
- package/dist/key-derivation/index.d.ts +0 -8
- package/dist/key-derivation/index.d.ts.map +0 -1
- package/dist/key-derivation/index.js +0 -7
- package/dist/key-derivation/wallet-node.d.ts +0 -45
- package/dist/key-derivation/wallet-node.d.ts.map +0 -1
- package/dist/key-derivation/wallet-node.js +0 -109
- package/dist/state/ciphertext-store.d.ts +0 -12
- package/dist/state/ciphertext-store.d.ts.map +0 -1
- package/dist/state/ciphertext-store.js +0 -25
- package/dist/state/hydrator.d.ts +0 -16
- package/dist/state/hydrator.d.ts.map +0 -1
- package/dist/state/hydrator.js +0 -18
- package/dist/state/job-store.d.ts +0 -12
- package/dist/state/job-store.d.ts.map +0 -1
- package/dist/state/job-store.js +0 -118
- package/dist/state/jobs.d.ts +0 -50
- package/dist/state/jobs.d.ts.map +0 -1
- package/dist/state/jobs.js +0 -1
- package/dist/state/leaf-store.d.ts +0 -17
- package/dist/state/leaf-store.d.ts.map +0 -1
- package/dist/state/leaf-store.js +0 -35
- package/dist/state/merkle-tree.d.ts +0 -34
- package/dist/state/merkle-tree.d.ts.map +0 -1
- package/dist/state/merkle-tree.js +0 -104
- package/dist/state/note-store.d.ts +0 -37
- package/dist/state/note-store.d.ts.map +0 -1
- package/dist/state/note-store.js +0 -133
- package/dist/state/nullifier-store.d.ts +0 -13
- package/dist/state/nullifier-store.d.ts.map +0 -1
- package/dist/state/nullifier-store.js +0 -21
- package/dist/state/records.d.ts +0 -57
- package/dist/state/records.d.ts.map +0 -1
- package/dist/state/root-store.d.ts +0 -13
- package/dist/state/root-store.d.ts.map +0 -1
- package/dist/state/root-store.js +0 -30
- package/dist/state/store.d.ts +0 -26
- package/dist/state/store.d.ts.map +0 -1
- package/dist/state/store.js +0 -19
- package/dist/state.d.ts +0 -83
- package/dist/state.d.ts.map +0 -1
- package/dist/state.js +0 -171
- package/dist/transactions/shield.d.ts +0 -5
- package/dist/transactions/shield.d.ts.map +0 -1
- package/dist/transactions/shield.js +0 -93
- package/dist/transactions/types.d.ts +0 -114
- package/dist/transactions/types.d.ts.map +0 -1
- package/dist/transactions/utils.d.ts +0 -10
- package/dist/transactions/utils.d.ts.map +0 -1
- package/dist/transactions/utils.js +0 -17
- package/dist/utils/time.d.ts +0 -2
- package/dist/utils/time.d.ts.map +0 -1
- package/dist/utils/time.js +0 -3
- package/dist/utils/witness.d.ts +0 -11
- package/dist/utils/witness.d.ts.map +0 -1
- package/dist/utils/witness.js +0 -19
- package/errors.ts +0 -20
- package/index.ts +0 -17
- package/key-derivation/babyjubjub.ts +0 -11
- package/key-derivation/bech32.test.ts +0 -90
- package/key-derivation/bech32.ts +0 -124
- package/key-derivation/bip32.ts +0 -56
- package/key-derivation/bip39.ts +0 -76
- package/key-derivation/bytes.ts +0 -118
- package/key-derivation/hash.ts +0 -13
- package/key-derivation/index.ts +0 -7
- package/key-derivation/wallet-node.ts +0 -155
- package/keys.ts +0 -47
- package/prover/config.ts +0 -104
- package/prover/index.ts +0 -1
- package/prover/prover.integration.test.ts +0 -162
- package/prover/prover.test.ts +0 -309
- package/prover/prover.ts +0 -405
- package/prover/registry.test.ts +0 -90
- package/prover/registry.ts +0 -82
- package/schema.ts +0 -17
- package/setup-artifacts.sh +0 -57
- package/state/index.ts +0 -2
- package/state/merkle/hydrator.ts +0 -69
- package/state/merkle/index.ts +0 -12
- package/state/merkle/merkle-tree.test.ts +0 -50
- package/state/merkle/merkle-tree.ts +0 -163
- package/state/store/ciphertext-store.ts +0 -28
- package/state/store/index.ts +0 -24
- package/state/store/job-store.ts +0 -162
- package/state/store/jobs.ts +0 -64
- package/state/store/leaf-store.ts +0 -39
- package/state/store/note-store.ts +0 -177
- package/state/store/nullifier-store.ts +0 -39
- package/state/store/records.ts +0 -61
- package/state/store/root-store.ts +0 -34
- package/state/store/store.ts +0 -25
- package/state.test.ts +0 -235
- package/storage/index.ts +0 -3
- package/storage/indexeddb.test.ts +0 -99
- package/storage/indexeddb.ts +0 -235
- package/storage/memory.test.ts +0 -59
- package/storage/memory.ts +0 -93
- package/transactions/deposit.test.ts +0 -160
- package/transactions/deposit.ts +0 -227
- package/transactions/index.ts +0 -20
- package/transactions/note-sync.test.ts +0 -155
- package/transactions/note-sync.ts +0 -452
- package/transactions/reconcile.ts +0 -73
- package/transactions/transact.test.ts +0 -451
- package/transactions/transact.ts +0 -811
- package/transactions/types.ts +0 -141
- package/tsconfig.json +0 -14
- package/types/global.d.ts +0 -15
- package/types.ts +0 -24
- package/utils/async.ts +0 -15
- package/utils/bigint.ts +0 -34
- package/utils/crypto.test.ts +0 -69
- package/utils/crypto.ts +0 -58
- package/utils/json-codec.ts +0 -38
- package/utils/polling.ts +0 -6
- package/utils/signature.ts +0 -16
- package/utils/validators.test.ts +0 -64
- package/utils/validators.ts +0 -86
- /package/dist/{transactions → history}/types.js +0 -0
- /package/dist/{state/records.js → transactions/types/deposit.js} +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"joinsplit_1x1_16": {
|
|
3
|
+
"file": "joinsplit",
|
|
4
|
+
"template": "JoinSplit",
|
|
5
|
+
"pubs": ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
6
|
+
"params": [1, 1, 16]
|
|
7
|
+
},
|
|
8
|
+
"joinsplit_1x2_16": {
|
|
9
|
+
"file": "joinsplit",
|
|
10
|
+
"template": "JoinSplit",
|
|
11
|
+
"pubs": ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
12
|
+
"params": [1, 2, 16]
|
|
13
|
+
},
|
|
14
|
+
"joinsplit_2x1_16": {
|
|
15
|
+
"file": "joinsplit",
|
|
16
|
+
"template": "JoinSplit",
|
|
17
|
+
"pubs": ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
18
|
+
"params": [2, 1, 16]
|
|
19
|
+
},
|
|
20
|
+
"joinsplit_2x2_16": {
|
|
21
|
+
"file": "joinsplit",
|
|
22
|
+
"template": "JoinSplit",
|
|
23
|
+
"pubs": ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
24
|
+
"params": [2, 2, 16]
|
|
25
|
+
},
|
|
26
|
+
"joinsplit_2x3_16": {
|
|
27
|
+
"file": "joinsplit",
|
|
28
|
+
"template": "JoinSplit",
|
|
29
|
+
"pubs": ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
30
|
+
"params": [2, 3, 16]
|
|
31
|
+
},
|
|
32
|
+
"joinsplit_3x1_16": {
|
|
33
|
+
"file": "joinsplit",
|
|
34
|
+
"template": "JoinSplit",
|
|
35
|
+
"pubs": ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
36
|
+
"params": [3, 1, 16]
|
|
37
|
+
},
|
|
38
|
+
"joinsplit_3x2_16": {
|
|
39
|
+
"file": "joinsplit",
|
|
40
|
+
"template": "JoinSplit",
|
|
41
|
+
"pubs": ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
42
|
+
"params": [3, 2, 16]
|
|
43
|
+
},
|
|
44
|
+
"joinsplit_3x3_16": {
|
|
45
|
+
"file": "joinsplit",
|
|
46
|
+
"template": "JoinSplit",
|
|
47
|
+
"pubs": ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
48
|
+
"params": [3, 3, 16]
|
|
49
|
+
},
|
|
50
|
+
"joinsplit_4x1_16": {
|
|
51
|
+
"file": "joinsplit",
|
|
52
|
+
"template": "JoinSplit",
|
|
53
|
+
"pubs": ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
54
|
+
"params": [4, 1, 16]
|
|
55
|
+
},
|
|
56
|
+
"joinsplit_4x2_16": {
|
|
57
|
+
"file": "joinsplit",
|
|
58
|
+
"template": "JoinSplit",
|
|
59
|
+
"pubs": ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
60
|
+
"params": [4, 2, 16]
|
|
61
|
+
},
|
|
62
|
+
"joinsplit_5x1_16": {
|
|
63
|
+
"file": "joinsplit",
|
|
64
|
+
"template": "JoinSplit",
|
|
65
|
+
"pubs": ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
66
|
+
"params": [5, 1, 16]
|
|
67
|
+
},
|
|
68
|
+
"joinsplit_5x2_16": {
|
|
69
|
+
"file": "joinsplit",
|
|
70
|
+
"template": "JoinSplit",
|
|
71
|
+
"pubs": ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
72
|
+
"params": [5, 2, 16]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -14,12 +14,17 @@ export type SubmitRelayResponse = {
|
|
|
14
14
|
accepted: boolean;
|
|
15
15
|
message?: string | null;
|
|
16
16
|
};
|
|
17
|
-
export type RelayState = "pending" | "broadcasting" | "succeeded" | "failed" | "dead";
|
|
17
|
+
export type RelayState = "pending" | "broadcasting" | "submitted" | "succeeded" | "reverted" | "failed" | "dead";
|
|
18
|
+
export type TransactionReceipt = {
|
|
19
|
+
blockNumber?: number;
|
|
20
|
+
blockHash?: string;
|
|
21
|
+
transactionIndex?: number;
|
|
22
|
+
};
|
|
18
23
|
export type RelayStatusResponse = {
|
|
19
24
|
id: string;
|
|
20
25
|
state: RelayState;
|
|
21
26
|
txHash?: string | null;
|
|
22
|
-
receipt?:
|
|
27
|
+
receipt?: TransactionReceipt | null;
|
|
23
28
|
error?: string | null;
|
|
24
29
|
};
|
|
25
30
|
type BroadcasterClientDeps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcaster.d.ts","sourceRoot":"","sources":["../../clients/broadcaster.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,WAAW,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,uBAAuB,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,cAAc,GACd,WAAW,GACX,QAAQ,GACR,MAAM,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"broadcaster.d.ts","sourceRoot":"","sources":["../../clients/broadcaster.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,WAAW,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,uBAAuB,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,cAAc,GACd,WAAW,GACX,WAAW,GACX,UAAU,GACV,QAAQ,GACR,MAAM,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAWF,KAAK,qBAAqB,GAAG;IAC3B,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,qBAAqB;wBAKC,iBAAiB;4BAYb,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;EAetE"}
|
|
@@ -14,10 +14,18 @@ export function createBroadcasterClient(baseUrl, deps) {
|
|
|
14
14
|
});
|
|
15
15
|
},
|
|
16
16
|
async getRelayStatus(relayId) {
|
|
17
|
-
|
|
17
|
+
const raw = await http.request({
|
|
18
18
|
method: "GET",
|
|
19
19
|
path: `/relays/${relayId}`,
|
|
20
20
|
});
|
|
21
|
+
// Transform snake_case to camelCase for consistency
|
|
22
|
+
return {
|
|
23
|
+
id: raw.id,
|
|
24
|
+
state: raw.state,
|
|
25
|
+
txHash: raw.tx_hash,
|
|
26
|
+
receipt: raw.receipt,
|
|
27
|
+
error: raw.error,
|
|
28
|
+
};
|
|
21
29
|
},
|
|
22
30
|
};
|
|
23
31
|
}
|
package/dist/clients/http.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
2
|
+
/**
|
|
3
|
+
* Resolve fetch implementation from options or global.
|
|
4
|
+
* @param providedFetch - Optional fetch implementation
|
|
5
|
+
* @returns Fetch function or undefined if not available
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveFetch(providedFetch?: FetchLike): typeof fetch | undefined;
|
|
2
8
|
export type JsonHttpDeps = {
|
|
3
9
|
fetch: FetchLike;
|
|
4
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../clients/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../clients/http.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,SAAS,GAAG,CACtB,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,IAAI,CAAC,EAAE,WAAW,KACf,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,aAAa,CAAC,EAAE,SAAS,GACxB,OAAO,KAAK,GAAG,SAAS,CAE1B;AAED,MAAM,MAAM,YAAY,GAAG;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAEhD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IAC9D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAClD,CAAC;AAEF,qBAAa,SAAU,SAAQ,KAAK;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAK3D;AAWD,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,YAAY,GACjB,cAAc,CAqDhB"}
|
package/dist/clients/http.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import ky, {
|
|
1
|
+
import ky, { TimeoutError } from "ky";
|
|
2
|
+
import { InitializationError } from "../errors.js";
|
|
3
|
+
/**
|
|
4
|
+
* Resolve fetch implementation from options or global.
|
|
5
|
+
* @param providedFetch - Optional fetch implementation
|
|
6
|
+
* @returns Fetch function or undefined if not available
|
|
7
|
+
*/
|
|
8
|
+
export function resolveFetch(providedFetch) {
|
|
9
|
+
return providedFetch ?? (typeof fetch === "function" ? fetch : undefined);
|
|
10
|
+
}
|
|
2
11
|
export class HttpError extends Error {
|
|
3
12
|
status;
|
|
4
13
|
body;
|
|
@@ -19,20 +28,24 @@ async function readErrorBodySafe(res) {
|
|
|
19
28
|
}
|
|
20
29
|
export function createJsonHttpClient(baseUrl, deps) {
|
|
21
30
|
if (!baseUrl)
|
|
22
|
-
throw new
|
|
31
|
+
throw new InitializationError("baseUrl is required");
|
|
23
32
|
if (!deps?.fetch)
|
|
24
|
-
throw new
|
|
33
|
+
throw new InitializationError("deps.fetch is required");
|
|
25
34
|
// Ensure `fetch` is invoked with a global `this` to avoid "Illegal invocation"
|
|
26
35
|
// errors in some browser environments when the function is extracted. // TODO: can we fix this in another way?
|
|
27
36
|
const fetchImpl = (...args) => deps.fetch.apply(globalThis, args);
|
|
28
37
|
const api = ky.create({
|
|
29
38
|
prefixUrl: baseUrl.replace(/\/+$/, ""),
|
|
30
39
|
fetch: fetchImpl,
|
|
40
|
+
// Disable ky's automatic error throwing to prevent browser DevTools
|
|
41
|
+
// from logging expected 404s as network errors
|
|
42
|
+
throwHttpErrors: false,
|
|
31
43
|
});
|
|
32
44
|
return {
|
|
33
45
|
async request(opts) {
|
|
46
|
+
let res;
|
|
34
47
|
try {
|
|
35
|
-
|
|
48
|
+
res = await api(opts.path.replace(/^\//, ""), {
|
|
36
49
|
method: opts.method,
|
|
37
50
|
searchParams: opts.query,
|
|
38
51
|
json: opts.json,
|
|
@@ -40,18 +53,20 @@ export function createJsonHttpClient(baseUrl, deps) {
|
|
|
40
53
|
headers: opts.headers,
|
|
41
54
|
signal: opts.signal,
|
|
42
55
|
});
|
|
43
|
-
return await res.json();
|
|
44
56
|
}
|
|
45
57
|
catch (err) {
|
|
46
|
-
|
|
47
|
-
const body = await readErrorBodySafe(err.response);
|
|
48
|
-
throw new HttpError(`HTTP ${err.response.status} ${err.response.statusText}`.trim(), err.response.status, body);
|
|
49
|
-
}
|
|
58
|
+
// Only network-level errors reach here (timeout, connection refused, etc.)
|
|
50
59
|
if (err instanceof TimeoutError) {
|
|
51
60
|
throw new HttpError("HTTP timeout", 408, null);
|
|
52
61
|
}
|
|
53
62
|
throw new HttpError(err instanceof Error ? err.message : "Network error", 0, null);
|
|
54
63
|
}
|
|
64
|
+
// HTTP status errors handled outside try-catch - no redundant catch/rethrow
|
|
65
|
+
if (!res.ok) {
|
|
66
|
+
const body = await readErrorBodySafe(res);
|
|
67
|
+
throw new HttpError(`HTTP ${res.status} ${res.statusText}`.trim(), res.status, body);
|
|
68
|
+
}
|
|
69
|
+
return (await res.json());
|
|
55
70
|
},
|
|
56
71
|
};
|
|
57
72
|
}
|
|
@@ -6,6 +6,7 @@ export type CommitmentRecord = {
|
|
|
6
6
|
root: string;
|
|
7
7
|
txHash: string;
|
|
8
8
|
insertedAt: number;
|
|
9
|
+
eventType: string;
|
|
9
10
|
};
|
|
10
11
|
export type IndexerNullifierRecord = {
|
|
11
12
|
nullifier: string;
|
|
@@ -31,13 +32,23 @@ export type GetNullifierParams = {
|
|
|
31
32
|
chainId: number;
|
|
32
33
|
nullifier: string;
|
|
33
34
|
};
|
|
35
|
+
export type CheckNullifiersParams = {
|
|
36
|
+
chainId: number;
|
|
37
|
+
nullifiers: string[];
|
|
38
|
+
};
|
|
34
39
|
type IndexerClientDeps = {
|
|
35
40
|
fetch: FetchLike;
|
|
36
41
|
};
|
|
37
42
|
export declare function createIndexerClient(baseUrl: string, deps: IndexerClientDeps): {
|
|
38
43
|
fetchCommitmentBatch(params: FetchCommitmentsParams): Promise<CommitmentBatchResponse>;
|
|
39
44
|
getCommitment(params: GetCommitmentParams): Promise<CommitmentRecord>;
|
|
45
|
+
/**
|
|
46
|
+
* Like getCommitment but returns null when the commitment doesn't exist.
|
|
47
|
+
* Used for polling pending deposits without generating console errors.
|
|
48
|
+
*/
|
|
49
|
+
tryGetCommitment(params: GetCommitmentParams): Promise<CommitmentRecord | null>;
|
|
40
50
|
getNullifier(params: GetNullifierParams): Promise<IndexerNullifierRecord | null>;
|
|
51
|
+
checkNullifiers(params: CheckNullifiersParams): Promise<IndexerNullifierRecord[]>;
|
|
41
52
|
getNullifierCount(chainId: number): Promise<number>;
|
|
42
53
|
};
|
|
43
54
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../../clients/indexer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAe3C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../../clients/indexer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAe3C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AASF,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAQF,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAWF,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB;iCA0B9D,sBAAsB,GAC7B,OAAO,CAAC,uBAAuB,CAAC;0BAgBzB,mBAAmB,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IAU5B;;;OAGG;6BAEO,mBAAmB,GAC1B,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;yBAQzB,kBAAkB,GACzB,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;4BAQ/B,qBAAqB,GAC5B,OAAO,CAAC,sBAAsB,EAAE,CAAC;+BAwBH,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;EAQ5D"}
|
package/dist/clients/indexer.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { createJsonHttpClient } from "./http.js";
|
|
2
|
-
import { isNotFoundError } from "../utils/async.js";
|
|
1
|
+
import { createJsonHttpClient, HttpError } from "./http.js";
|
|
3
2
|
export function createIndexerClient(baseUrl, deps) {
|
|
4
3
|
const http = createJsonHttpClient(baseUrl, deps);
|
|
5
4
|
// Converts the snake_case record from the REST API into the camelCase shape
|
|
@@ -11,6 +10,7 @@ export function createIndexerClient(baseUrl, deps) {
|
|
|
11
10
|
root: record.root,
|
|
12
11
|
txHash: record.tx_hash,
|
|
13
12
|
insertedAt: record.inserted_at,
|
|
13
|
+
eventType: record.event_type ?? "unknown",
|
|
14
14
|
});
|
|
15
15
|
const normalizeNullifierRecord = (record) => ({
|
|
16
16
|
nullifier: record.nullifier,
|
|
@@ -39,22 +39,51 @@ export function createIndexerClient(baseUrl, deps) {
|
|
|
39
39
|
method: "GET",
|
|
40
40
|
path: `/chains/${params.chainId}/commitments/${params.commitment}`,
|
|
41
41
|
});
|
|
42
|
+
if (!raw) {
|
|
43
|
+
throw new HttpError("commitment not found", 404, null);
|
|
44
|
+
}
|
|
42
45
|
return normalizeRecord(raw);
|
|
43
46
|
},
|
|
47
|
+
/**
|
|
48
|
+
* Like getCommitment but returns null when the commitment doesn't exist.
|
|
49
|
+
* Used for polling pending deposits without generating console errors.
|
|
50
|
+
*/
|
|
51
|
+
async tryGetCommitment(params) {
|
|
52
|
+
const raw = await http.request({
|
|
53
|
+
method: "GET",
|
|
54
|
+
path: `/chains/${params.chainId}/commitments/${params.commitment}`,
|
|
55
|
+
});
|
|
56
|
+
return raw ? normalizeRecord(raw) : null;
|
|
57
|
+
},
|
|
44
58
|
async getNullifier(params) {
|
|
45
|
-
|
|
59
|
+
const raw = await http.request({
|
|
60
|
+
method: "GET",
|
|
61
|
+
path: `/chains/${params.chainId}/nullifiers/${params.nullifier}`,
|
|
62
|
+
});
|
|
63
|
+
return raw ? normalizeNullifierRecord(raw) : null;
|
|
64
|
+
},
|
|
65
|
+
async checkNullifiers(params) {
|
|
66
|
+
const CHUNK_SIZE = 1000;
|
|
67
|
+
if (params.nullifiers.length <= CHUNK_SIZE) {
|
|
46
68
|
const raw = await http.request({
|
|
47
|
-
method: "
|
|
48
|
-
path: `/chains/${params.chainId}/nullifiers
|
|
69
|
+
method: "POST",
|
|
70
|
+
path: `/chains/${params.chainId}/nullifiers/check`,
|
|
71
|
+
json: { nullifiers: params.nullifiers },
|
|
49
72
|
});
|
|
50
|
-
return normalizeNullifierRecord
|
|
73
|
+
return raw.found.map(normalizeNullifierRecord);
|
|
51
74
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
75
|
+
// Chunk into batches of 1000, run sequentially to avoid overwhelming server
|
|
76
|
+
const results = [];
|
|
77
|
+
for (let i = 0; i < params.nullifiers.length; i += CHUNK_SIZE) {
|
|
78
|
+
const chunk = params.nullifiers.slice(i, i + CHUNK_SIZE);
|
|
79
|
+
const raw = await http.request({
|
|
80
|
+
method: "POST",
|
|
81
|
+
path: `/chains/${params.chainId}/nullifiers/check`,
|
|
82
|
+
json: { nullifiers: chunk },
|
|
83
|
+
});
|
|
84
|
+
results.push(...raw.found.map(normalizeNullifierRecord));
|
|
57
85
|
}
|
|
86
|
+
return results;
|
|
58
87
|
},
|
|
59
88
|
async getNullifierCount(chainId) {
|
|
60
89
|
const raw = await http.request({
|
package/dist/config.d.ts
CHANGED
|
@@ -1,12 +1,31 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export type Environment = "mainnet" | "testnet" | "local";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for a specific environment.
|
|
4
|
+
*/
|
|
5
|
+
export interface EnvironmentConfig {
|
|
6
|
+
rpcUrl: string;
|
|
7
|
+
poolAddress: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Service configuration with broadcaster and indexer URLs.
|
|
11
|
+
*/
|
|
12
|
+
export interface ServiceConfig {
|
|
5
13
|
broadcasterBaseUrl: string;
|
|
6
|
-
/**
|
|
7
|
-
* Base URL for the Indexer HTTP API (default: http://localhost:8082).
|
|
8
|
-
*/
|
|
9
14
|
indexerBaseUrl: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Fetch environment configuration from the hosted config file.
|
|
18
|
+
*
|
|
19
|
+
* @param env - The environment to fetch config for
|
|
20
|
+
* @returns Promise resolving to the environment configuration
|
|
21
|
+
* @throws If fetch fails or environment is not found
|
|
22
|
+
*/
|
|
23
|
+
export declare function fetchEnvironmentConfig(env: Environment): Promise<EnvironmentConfig>;
|
|
24
|
+
/**
|
|
25
|
+
* Create service configuration from an RPC URL.
|
|
26
|
+
*
|
|
27
|
+
* @param rpcUrl - The base RPC URL
|
|
28
|
+
* @returns Service configuration with broadcaster and indexer URLs
|
|
29
|
+
*/
|
|
30
|
+
export declare function createServiceConfig(rpcUrl: string): ServiceConfig;
|
|
12
31
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;CACxB;AAKD;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,iBAAiB,CAAC,CAU5B;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAMjE"}
|
package/dist/config.js
CHANGED
|
@@ -1,29 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Environment types for SDK configuration.
|
|
3
|
+
*/
|
|
4
|
+
import { InitializationError } from "./errors.js";
|
|
5
|
+
const CONFIG_URL = "https://raw.githubusercontent.com/unlink-xyz/config/main/environments.json";
|
|
6
|
+
/**
|
|
7
|
+
* Fetch environment configuration from the hosted config file.
|
|
8
|
+
*
|
|
9
|
+
* @param env - The environment to fetch config for
|
|
10
|
+
* @returns Promise resolving to the environment configuration
|
|
11
|
+
* @throws If fetch fails or environment is not found
|
|
12
|
+
*/
|
|
13
|
+
export async function fetchEnvironmentConfig(env) {
|
|
14
|
+
const res = await fetch(CONFIG_URL);
|
|
15
|
+
if (!res.ok) {
|
|
16
|
+
throw new InitializationError(`Failed to fetch SDK config: ${res.status}`);
|
|
5
17
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
function readServiceUrl(envKey, fallback) {
|
|
11
|
-
const raw = readEnv(envKey);
|
|
12
|
-
if (!raw)
|
|
13
|
-
return fallback;
|
|
14
|
-
const trimmed = raw.trim();
|
|
15
|
-
if (!trimmed) {
|
|
16
|
-
throw new Error(`${envKey} must not be empty when set`);
|
|
18
|
+
const config = (await res.json());
|
|
19
|
+
if (!config[env]) {
|
|
20
|
+
throw new InitializationError(`Unknown environment: ${env}`);
|
|
17
21
|
}
|
|
18
|
-
return
|
|
22
|
+
return config[env];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create service configuration from an RPC URL.
|
|
26
|
+
*
|
|
27
|
+
* @param rpcUrl - The base RPC URL
|
|
28
|
+
* @returns Service configuration with broadcaster and indexer URLs
|
|
29
|
+
*/
|
|
30
|
+
export function createServiceConfig(rpcUrl) {
|
|
31
|
+
const baseUrl = rpcUrl.replace(/\/+$/, "");
|
|
32
|
+
return {
|
|
33
|
+
broadcasterBaseUrl: baseUrl + "/broadcaster",
|
|
34
|
+
indexerBaseUrl: baseUrl + "/indexer",
|
|
35
|
+
};
|
|
19
36
|
}
|
|
20
|
-
export const serviceConfig = {
|
|
21
|
-
/**
|
|
22
|
-
* Base URL for the Broadcaster HTTP API (default: http://localhost:8081).
|
|
23
|
-
*/
|
|
24
|
-
broadcasterBaseUrl: readServiceUrl("UNLINK_RPC_URL", DEFAULT_RPC_URL) + "/broadcaster",
|
|
25
|
-
/**
|
|
26
|
-
* Base URL for the Indexer HTTP API (default: http://localhost:8082).
|
|
27
|
-
*/
|
|
28
|
-
indexerBaseUrl: readServiceUrl("UNLINK_RPC_URL", DEFAULT_RPC_URL) + "/indexer",
|
|
29
|
-
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sentinel address for native ETH, matching the Solidity Constants.ETH_TOKEN.
|
|
3
|
+
* Used as the token address in notes to indicate a native ETH deposit/withdrawal.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ETH_TOKEN = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
6
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,SAAS,+CAA+C,CAAC"}
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../core.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../core.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,UAAU,CAAC;CAChC,CAAC;AAEF,wBAAsB,QAAQ,CAAC,IAAI,EAAE,QAAQ;;aAHlC,MAAM,KAAK,UAAU;GAa/B"}
|
package/dist/core.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { initCrypto } from "./crypto-adapters/index.js";
|
|
2
|
+
import { InitializationError } from "./errors.js";
|
|
1
3
|
import { migrate } from "./schema.js";
|
|
2
4
|
export async function initCore(deps) {
|
|
3
5
|
if (!deps?.storage)
|
|
4
|
-
throw new
|
|
6
|
+
throw new InitializationError("storage dep required");
|
|
5
7
|
if (!deps?.rng)
|
|
6
|
-
throw new
|
|
8
|
+
throw new InitializationError("rng dep required");
|
|
9
|
+
await initCrypto();
|
|
7
10
|
await migrate(deps.storage);
|
|
8
11
|
return {
|
|
9
12
|
storage: deps.storage,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-init.d.ts","sourceRoot":"","sources":["../../crypto-adapters/auto-init.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-initialization module for tests.
|
|
3
|
+
* Import this at the top of test files to automatically initialize crypto, not in production code.
|
|
4
|
+
*/
|
|
5
|
+
import { initCrypto } from "./index.js";
|
|
6
|
+
await initCrypto();
|
|
7
|
+
console.log("[crypto] Auto-initialized for tests");
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Crypto adapters for browser-compatible cryptographic operations.
|
|
3
|
+
*
|
|
4
|
+
* Exports:
|
|
5
|
+
* - poseidon: Poseidon hash from circomlibjs (iden3)
|
|
6
|
+
* - deriveSpendingPublicKey, signMessage, verifySignature: EdDSA from @zk-kit/eddsa-poseidon
|
|
7
|
+
* - initCrypto: Async function to initialize crypto primitives (must be called before using poseidon)
|
|
8
|
+
*/
|
|
9
|
+
import "./polyfills.js";
|
|
10
|
+
/**
|
|
11
|
+
* Initialize the crypto primitives (Poseidon hash function).
|
|
12
|
+
* This must be called before using the poseidon function.
|
|
13
|
+
* Safe to call multiple times - subsequent calls return the same promise.
|
|
14
|
+
*/
|
|
15
|
+
export declare function initCrypto(): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Poseidon hash function compatible with circomlib circuits.
|
|
18
|
+
* Wraps circomlibjs buildPoseidon to return bigint directly.
|
|
19
|
+
*/
|
|
20
|
+
export declare const poseidon: (inputs: (bigint | number)[]) => bigint;
|
|
21
|
+
export { derivePublicKey as deriveSpendingPublicKey, signMessage, verifySignature, } from "@zk-kit/eddsa-poseidon";
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../crypto-adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,gBAAgB,CAAC;AAWxB;;;;GAIG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAehD;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,GAAI,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,KAAG,MAQtD,CAAC;AAEF,OAAO,EACL,eAAe,IAAI,uBAAuB,EAC1C,WAAW,EACX,eAAe,GAChB,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Crypto adapters for browser-compatible cryptographic operations.
|
|
3
|
+
*
|
|
4
|
+
* Exports:
|
|
5
|
+
* - poseidon: Poseidon hash from circomlibjs (iden3)
|
|
6
|
+
* - deriveSpendingPublicKey, signMessage, verifySignature: EdDSA from @zk-kit/eddsa-poseidon
|
|
7
|
+
* - initCrypto: Async function to initialize crypto primitives (must be called before using poseidon)
|
|
8
|
+
*/
|
|
9
|
+
// Polyfill must be the first import
|
|
10
|
+
import "./polyfills.js";
|
|
11
|
+
import { InitializationError } from "../errors.js";
|
|
12
|
+
let _poseidon = null;
|
|
13
|
+
let _initPromise = null;
|
|
14
|
+
/**
|
|
15
|
+
* Initialize the crypto primitives (Poseidon hash function).
|
|
16
|
+
* This must be called before using the poseidon function.
|
|
17
|
+
* Safe to call multiple times - subsequent calls return the same promise.
|
|
18
|
+
*/
|
|
19
|
+
export async function initCrypto() {
|
|
20
|
+
if (_poseidon)
|
|
21
|
+
return; // Already initialized
|
|
22
|
+
if (_initPromise)
|
|
23
|
+
return _initPromise; // Initialization in progress
|
|
24
|
+
_initPromise = (async () => {
|
|
25
|
+
try {
|
|
26
|
+
const { buildPoseidon } = await import("circomlibjs");
|
|
27
|
+
_poseidon = await buildPoseidon();
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
_initPromise = null; // Reset to allow retry
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
})();
|
|
34
|
+
return _initPromise;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Poseidon hash function compatible with circomlib circuits.
|
|
38
|
+
* Wraps circomlibjs buildPoseidon to return bigint directly.
|
|
39
|
+
*/
|
|
40
|
+
export const poseidon = (inputs) => {
|
|
41
|
+
if (!_poseidon) {
|
|
42
|
+
throw new InitializationError("Crypto not initialized. Call initCrypto() before using poseidon().");
|
|
43
|
+
}
|
|
44
|
+
const hash = _poseidon(inputs);
|
|
45
|
+
return _poseidon.F.toObject(hash);
|
|
46
|
+
};
|
|
47
|
+
export { derivePublicKey as deriveSpendingPublicKey, signMessage, verifySignature, } from "@zk-kit/eddsa-poseidon";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polyfills.d.ts","sourceRoot":"","sources":["../../crypto-adapters/polyfills.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -7,4 +7,13 @@ export declare class KeyValidationError extends CoreError {
|
|
|
7
7
|
export declare class SchemaMismatchError extends CoreError {
|
|
8
8
|
constructor(current: number, expected: number);
|
|
9
9
|
}
|
|
10
|
+
export declare class ValidationError extends CoreError {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class ProofError extends CoreError {
|
|
14
|
+
constructor(message: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class InitializationError extends CoreError {
|
|
17
|
+
constructor(message: string);
|
|
18
|
+
}
|
|
10
19
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../errors.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,mBAAoB,SAAQ,SAAS;gBACpC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAI9C"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../errors.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,mBAAoB,SAAQ,SAAS;gBACpC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAI9C;AAED,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,UAAW,SAAQ,SAAS;gBAC3B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,mBAAoB,SAAQ,SAAS;gBACpC,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/errors.js
CHANGED
|
@@ -16,3 +16,21 @@ export class SchemaMismatchError extends CoreError {
|
|
|
16
16
|
this.name = "SchemaMismatchError";
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
+
export class ValidationError extends CoreError {
|
|
20
|
+
constructor(message) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = "ValidationError";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class ProofError extends CoreError {
|
|
26
|
+
constructor(message) {
|
|
27
|
+
super(message);
|
|
28
|
+
this.name = "ProofError";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class InitializationError extends CoreError {
|
|
32
|
+
constructor(message) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.name = "InitializationError";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../history/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|