@orbinum/sdk 0.7.0 → 0.7.2
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/README.md +3 -1
- package/dist/index.d.mts +13 -10
- package/dist/index.d.ts +13 -10
- package/dist/index.js +30 -46
- package/dist/index.mjs +35 -51
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@ const client = await OrbinumClient.connect({
|
|
|
28
28
|
const info = await client.substrate.getChainInfo();
|
|
29
29
|
const root = await client.rpcV2.privacy.getMerkleRoot();
|
|
30
30
|
const block = await client.substrate.getBlock('best');
|
|
31
|
+
const isValidator = await client.rpcV2.chain.isValidator('5GrwvaEF...');
|
|
31
32
|
```
|
|
32
33
|
|
|
33
34
|
`OrbinumClient` exposes the following modules:
|
|
@@ -36,7 +37,8 @@ const block = await client.substrate.getBlock('best');
|
|
|
36
37
|
|---|---|
|
|
37
38
|
| `client.substrate` | Substrate RPC — blocks, events, transactions |
|
|
38
39
|
| `client.evm` | EVM JSON-RPC client (`null` if `evmRpc` not set) |
|
|
39
|
-
| `client.rpcV2` | Orbinum `rpc-v2` namespaces (`
|
|
40
|
+
| `client.rpcV2` | Orbinum `rpc-v2` namespaces (`chain_*`, `privacy_*`) |
|
|
41
|
+
| `client.rpcV2.chain` | Chain-level queries (`chain_isValidator`, etc.) |
|
|
40
42
|
| `client.shieldedPool` | Shielded pool extrinsics |
|
|
41
43
|
| `client.accountMapping` | Alias, chain-link, and identity operations |
|
|
42
44
|
| `client.precompiles` | EVM precompile wrappers (`null` if `evmRpc` not set) |
|
package/dist/index.d.mts
CHANGED
|
@@ -182,11 +182,11 @@ declare class SubstrateClient {
|
|
|
182
182
|
*/
|
|
183
183
|
submitAndWatch(signedHex: string): ReturnType<PolkadotClient['submitAndWatch']>;
|
|
184
184
|
/**
|
|
185
|
-
* Submits a bare (unsigned) extrinsic
|
|
185
|
+
* Submits a bare (unsigned) extrinsic and waits for finalization.
|
|
186
186
|
* Used for gasless private_transfer and unshield transactions.
|
|
187
|
-
* The bare tx
|
|
187
|
+
* The bare tx bytes are produced by `tx.getBareTx()` from polkadot-api.
|
|
188
188
|
*/
|
|
189
|
-
submitUnsignedAndWatch(
|
|
189
|
+
submitUnsignedAndWatch(bareTx: Uint8Array): Promise<TxFinalizedPayload>;
|
|
190
190
|
/**
|
|
191
191
|
* Convenience: wrap raw call bytes and sign+submit in one step.
|
|
192
192
|
*/
|
|
@@ -432,7 +432,7 @@ declare class EvmExplorer {
|
|
|
432
432
|
getTransactionsByAddress(address: string, maxBlocks?: number): Promise<EvmTxSummary[]>;
|
|
433
433
|
/**
|
|
434
434
|
* Returns aggregated on-chain data for an EVM address: balance, nonce,
|
|
435
|
-
* bytecode (truncated), and up to 50 recent logs from the last
|
|
435
|
+
* bytecode (truncated), and up to 50 recent logs from the last 1 000 blocks.
|
|
436
436
|
*/
|
|
437
437
|
getAddressInfo(address: string): Promise<EvmAddressInfo>;
|
|
438
438
|
/** Returns the native token balance of `address`, formatted as a decimal string (no symbol). */
|
|
@@ -447,7 +447,7 @@ declare class EvmExplorer {
|
|
|
447
447
|
*/
|
|
448
448
|
getTokenInfo(address: string): Promise<TokenInfo | null>;
|
|
449
449
|
/**
|
|
450
|
-
* Returns ERC-20 `Transfer` events for `address` from the last
|
|
450
|
+
* Returns ERC-20 `Transfer` events for `address` from the last 1 000 blocks.
|
|
451
451
|
* When `holderAddress` is provided, restricts results to transfers sent or received by that address.
|
|
452
452
|
*/
|
|
453
453
|
getTokenTransfers(address: string, holderAddress?: string): Promise<TokenTransfer[]>;
|
|
@@ -711,7 +711,6 @@ declare class IndexerClient {
|
|
|
711
711
|
constructor(config: IndexerClientConfig);
|
|
712
712
|
private _fetchResponse;
|
|
713
713
|
private get;
|
|
714
|
-
private post;
|
|
715
714
|
private getOrNull;
|
|
716
715
|
private buildQuery;
|
|
717
716
|
/** Returns the total count of shielded commitments. */
|
|
@@ -744,11 +743,15 @@ declare class IndexerClient {
|
|
|
744
743
|
/** Returns the spent/unspent status of a nullifier. */
|
|
745
744
|
getNullifierStatus(hex: string): Promise<NullifierStatusResult>;
|
|
746
745
|
/**
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
746
|
+
* Downloads the full spent nullifier set and returns it as a Set of lowercase hex strings.
|
|
747
|
+
*
|
|
748
|
+
* The server sees an identical GET request regardless of which notes the wallet holds —
|
|
749
|
+
* the intersection is computed locally (PIR-A privacy model).
|
|
750
|
+
*
|
|
751
|
+
* Suitable for wallets with up to ~1M spent nullifiers (~70 MB raw, <20 MB gzip).
|
|
752
|
+
* For the current Orbinum testnet/mainnet scale this is the recommended approach.
|
|
750
753
|
*/
|
|
751
|
-
|
|
754
|
+
getAllSpentNullifiers(): Promise<Set<string>>;
|
|
752
755
|
/**
|
|
753
756
|
* Returns temporal metadata for private transfers that spent any of the given nullifiers.
|
|
754
757
|
* Only blockNumber, extrinsicIndex, timestampMs, and hash are returned — no cross-link
|
package/dist/index.d.ts
CHANGED
|
@@ -182,11 +182,11 @@ declare class SubstrateClient {
|
|
|
182
182
|
*/
|
|
183
183
|
submitAndWatch(signedHex: string): ReturnType<PolkadotClient['submitAndWatch']>;
|
|
184
184
|
/**
|
|
185
|
-
* Submits a bare (unsigned) extrinsic
|
|
185
|
+
* Submits a bare (unsigned) extrinsic and waits for finalization.
|
|
186
186
|
* Used for gasless private_transfer and unshield transactions.
|
|
187
|
-
* The bare tx
|
|
187
|
+
* The bare tx bytes are produced by `tx.getBareTx()` from polkadot-api.
|
|
188
188
|
*/
|
|
189
|
-
submitUnsignedAndWatch(
|
|
189
|
+
submitUnsignedAndWatch(bareTx: Uint8Array): Promise<TxFinalizedPayload>;
|
|
190
190
|
/**
|
|
191
191
|
* Convenience: wrap raw call bytes and sign+submit in one step.
|
|
192
192
|
*/
|
|
@@ -432,7 +432,7 @@ declare class EvmExplorer {
|
|
|
432
432
|
getTransactionsByAddress(address: string, maxBlocks?: number): Promise<EvmTxSummary[]>;
|
|
433
433
|
/**
|
|
434
434
|
* Returns aggregated on-chain data for an EVM address: balance, nonce,
|
|
435
|
-
* bytecode (truncated), and up to 50 recent logs from the last
|
|
435
|
+
* bytecode (truncated), and up to 50 recent logs from the last 1 000 blocks.
|
|
436
436
|
*/
|
|
437
437
|
getAddressInfo(address: string): Promise<EvmAddressInfo>;
|
|
438
438
|
/** Returns the native token balance of `address`, formatted as a decimal string (no symbol). */
|
|
@@ -447,7 +447,7 @@ declare class EvmExplorer {
|
|
|
447
447
|
*/
|
|
448
448
|
getTokenInfo(address: string): Promise<TokenInfo | null>;
|
|
449
449
|
/**
|
|
450
|
-
* Returns ERC-20 `Transfer` events for `address` from the last
|
|
450
|
+
* Returns ERC-20 `Transfer` events for `address` from the last 1 000 blocks.
|
|
451
451
|
* When `holderAddress` is provided, restricts results to transfers sent or received by that address.
|
|
452
452
|
*/
|
|
453
453
|
getTokenTransfers(address: string, holderAddress?: string): Promise<TokenTransfer[]>;
|
|
@@ -711,7 +711,6 @@ declare class IndexerClient {
|
|
|
711
711
|
constructor(config: IndexerClientConfig);
|
|
712
712
|
private _fetchResponse;
|
|
713
713
|
private get;
|
|
714
|
-
private post;
|
|
715
714
|
private getOrNull;
|
|
716
715
|
private buildQuery;
|
|
717
716
|
/** Returns the total count of shielded commitments. */
|
|
@@ -744,11 +743,15 @@ declare class IndexerClient {
|
|
|
744
743
|
/** Returns the spent/unspent status of a nullifier. */
|
|
745
744
|
getNullifierStatus(hex: string): Promise<NullifierStatusResult>;
|
|
746
745
|
/**
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
746
|
+
* Downloads the full spent nullifier set and returns it as a Set of lowercase hex strings.
|
|
747
|
+
*
|
|
748
|
+
* The server sees an identical GET request regardless of which notes the wallet holds —
|
|
749
|
+
* the intersection is computed locally (PIR-A privacy model).
|
|
750
|
+
*
|
|
751
|
+
* Suitable for wallets with up to ~1M spent nullifiers (~70 MB raw, <20 MB gzip).
|
|
752
|
+
* For the current Orbinum testnet/mainnet scale this is the recommended approach.
|
|
750
753
|
*/
|
|
751
|
-
|
|
754
|
+
getAllSpentNullifiers(): Promise<Set<string>>;
|
|
752
755
|
/**
|
|
753
756
|
* Returns temporal metadata for private transfers that spent any of the given nullifiers.
|
|
754
757
|
* Only blockNumber, extrinsicIndex, timestampMs, and hash are returned — no cross-link
|
package/dist/index.js
CHANGED
|
@@ -369,12 +369,12 @@ var SubstrateClient = class _SubstrateClient {
|
|
|
369
369
|
return this._papi.submitAndWatch(import_polkadot_api.Binary.fromHex(signedHex));
|
|
370
370
|
}
|
|
371
371
|
/**
|
|
372
|
-
* Submits a bare (unsigned) extrinsic
|
|
372
|
+
* Submits a bare (unsigned) extrinsic and waits for finalization.
|
|
373
373
|
* Used for gasless private_transfer and unshield transactions.
|
|
374
|
-
* The bare tx
|
|
374
|
+
* The bare tx bytes are produced by `tx.getBareTx()` from polkadot-api.
|
|
375
375
|
*/
|
|
376
|
-
async submitUnsignedAndWatch(
|
|
377
|
-
return this._papi.submit(
|
|
376
|
+
async submitUnsignedAndWatch(bareTx) {
|
|
377
|
+
return this._papi.submit(bareTx);
|
|
378
378
|
}
|
|
379
379
|
/**
|
|
380
380
|
* Convenience: wrap raw call bytes and sign+submit in one step.
|
|
@@ -765,6 +765,7 @@ function formatORB(raw, precision = 6) {
|
|
|
765
765
|
}
|
|
766
766
|
|
|
767
767
|
// src/evm-explorer/EvmExplorer.ts
|
|
768
|
+
var MAX_LOG_BLOCK_RANGE = 1e3;
|
|
768
769
|
var EvmExplorer = class _EvmExplorer {
|
|
769
770
|
/** @param evm - Underlying `EvmClient` used for all RPC calls. */
|
|
770
771
|
constructor(evm) {
|
|
@@ -874,11 +875,11 @@ var EvmExplorer = class _EvmExplorer {
|
|
|
874
875
|
// --- Address ---
|
|
875
876
|
/**
|
|
876
877
|
* Returns aggregated on-chain data for an EVM address: balance, nonce,
|
|
877
|
-
* bytecode (truncated), and up to 50 recent logs from the last
|
|
878
|
+
* bytecode (truncated), and up to 50 recent logs from the last 1 000 blocks.
|
|
878
879
|
*/
|
|
879
880
|
async getAddressInfo(address) {
|
|
880
881
|
const latest = await this.evm.getBlockNumber().catch(() => 0);
|
|
881
|
-
const fromBlock = `0x${Math.max(0, latest -
|
|
882
|
+
const fromBlock = `0x${Math.max(0, latest - MAX_LOG_BLOCK_RANGE).toString(16)}`;
|
|
882
883
|
const [balance, nonce, code, logs] = await Promise.all([
|
|
883
884
|
this.evm.request("eth_getBalance", [address, "latest"]).catch(() => null),
|
|
884
885
|
this.evm.getTransactionCount(address).catch(() => 0),
|
|
@@ -957,13 +958,13 @@ var EvmExplorer = class _EvmExplorer {
|
|
|
957
958
|
};
|
|
958
959
|
}
|
|
959
960
|
/**
|
|
960
|
-
* Returns ERC-20 `Transfer` events for `address` from the last
|
|
961
|
+
* Returns ERC-20 `Transfer` events for `address` from the last 1 000 blocks.
|
|
961
962
|
* When `holderAddress` is provided, restricts results to transfers sent or received by that address.
|
|
962
963
|
*/
|
|
963
964
|
async getTokenTransfers(address, holderAddress) {
|
|
964
965
|
const TRANSFER = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";
|
|
965
966
|
const latest = await this.evm.getBlockNumber().catch(() => 0);
|
|
966
|
-
const fromBlock = `0x${Math.max(0, latest -
|
|
967
|
+
const fromBlock = `0x${Math.max(0, latest - MAX_LOG_BLOCK_RANGE).toString(16)}`;
|
|
967
968
|
let logs;
|
|
968
969
|
if (holderAddress) {
|
|
969
970
|
const padded = `0x${holderAddress.replace(/^0x/, "").toLowerCase().padStart(64, "0")}`;
|
|
@@ -1113,24 +1114,6 @@ var IndexerClient = class {
|
|
|
1113
1114
|
}
|
|
1114
1115
|
return res.json();
|
|
1115
1116
|
}
|
|
1116
|
-
async post(path, body) {
|
|
1117
|
-
const controller = new AbortController();
|
|
1118
|
-
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
1119
|
-
try {
|
|
1120
|
-
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
1121
|
-
method: "POST",
|
|
1122
|
-
headers: { "Content-Type": "application/json" },
|
|
1123
|
-
body: JSON.stringify(body),
|
|
1124
|
-
signal: controller.signal
|
|
1125
|
-
});
|
|
1126
|
-
if (!res.ok) {
|
|
1127
|
-
throw new Error(`IndexerClient: HTTP ${res.status} for POST ${path}`);
|
|
1128
|
-
}
|
|
1129
|
-
return res.json();
|
|
1130
|
-
} finally {
|
|
1131
|
-
clearTimeout(timer);
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
1117
|
async getOrNull(path) {
|
|
1135
1118
|
const res = await this._fetchResponse(path);
|
|
1136
1119
|
if (res.status === 404) return null;
|
|
@@ -1194,16 +1177,17 @@ var IndexerClient = class {
|
|
|
1194
1177
|
);
|
|
1195
1178
|
}
|
|
1196
1179
|
/**
|
|
1197
|
-
*
|
|
1198
|
-
*
|
|
1199
|
-
*
|
|
1180
|
+
* Downloads the full spent nullifier set and returns it as a Set of lowercase hex strings.
|
|
1181
|
+
*
|
|
1182
|
+
* The server sees an identical GET request regardless of which notes the wallet holds —
|
|
1183
|
+
* the intersection is computed locally (PIR-A privacy model).
|
|
1184
|
+
*
|
|
1185
|
+
* Suitable for wallets with up to ~1M spent nullifiers (~70 MB raw, <20 MB gzip).
|
|
1186
|
+
* For the current Orbinum testnet/mainnet scale this is the recommended approach.
|
|
1200
1187
|
*/
|
|
1201
|
-
async
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
nullifiers: nullifiers.map((n) => n.toLowerCase())
|
|
1205
|
-
});
|
|
1206
|
-
return res.data;
|
|
1188
|
+
async getAllSpentNullifiers() {
|
|
1189
|
+
const res = await this.get("/shielded/nullifiers/all");
|
|
1190
|
+
return new Set(res.data.map((h) => h.toLowerCase()));
|
|
1207
1191
|
}
|
|
1208
1192
|
// ─── Private transfers ─────────────────────────────────────────────────────
|
|
1209
1193
|
/**
|
|
@@ -1415,8 +1399,8 @@ function callUnsafeTx(txEntry, ...args) {
|
|
|
1415
1399
|
return txEntry(...args);
|
|
1416
1400
|
}
|
|
1417
1401
|
async function submitBareTx(tx, client) {
|
|
1418
|
-
const
|
|
1419
|
-
const payload = await client.submitUnsignedAndWatch(
|
|
1402
|
+
const bareTx = await tx.getBareTx();
|
|
1403
|
+
const payload = await client.submitUnsignedAndWatch(bareTx);
|
|
1420
1404
|
return toTxResult(payload);
|
|
1421
1405
|
}
|
|
1422
1406
|
function resolveTx(unsafe, pallet, call) {
|
|
@@ -1838,7 +1822,7 @@ var ShieldedPoolModule = class {
|
|
|
1838
1822
|
const tx = callUnsafeTx(entry, {
|
|
1839
1823
|
asset_id: params.assetId,
|
|
1840
1824
|
amount: params.amount,
|
|
1841
|
-
commitment:
|
|
1825
|
+
commitment: params.commitment,
|
|
1842
1826
|
encrypted_memo: params.encryptedMemo
|
|
1843
1827
|
});
|
|
1844
1828
|
return toTxResult(
|
|
@@ -1865,13 +1849,13 @@ var ShieldedPoolModule = class {
|
|
|
1865
1849
|
}
|
|
1866
1850
|
const tx = callUnsafeTx(entry, {
|
|
1867
1851
|
proof: params.proof,
|
|
1868
|
-
merkle_root:
|
|
1869
|
-
nullifier:
|
|
1852
|
+
merkle_root: params.merkleRoot,
|
|
1853
|
+
nullifier: params.nullifier,
|
|
1870
1854
|
asset_id: params.assetId,
|
|
1871
1855
|
amount: params.amount,
|
|
1872
1856
|
recipient: recipientSs58,
|
|
1873
1857
|
fee: params.fee ?? 0n,
|
|
1874
|
-
change_commitment:
|
|
1858
|
+
change_commitment: changeCommitment,
|
|
1875
1859
|
change_encrypted_memo: changeEncryptedMemo,
|
|
1876
1860
|
relayer: void 0
|
|
1877
1861
|
// Option<H160> — None for direct Substrate submissions
|
|
@@ -1890,8 +1874,8 @@ var ShieldedPoolModule = class {
|
|
|
1890
1874
|
* Extrinsic: shieldedPool.privateTransfer(proof, merkleRoot, nullifiers, commitments, memos, assetId, fee)
|
|
1891
1875
|
*/
|
|
1892
1876
|
async privateTransfer(params, signer, txOptions) {
|
|
1893
|
-
const nullifiers = params.inputs.map((inp) =>
|
|
1894
|
-
const commitments = params.outputs.map((out) =>
|
|
1877
|
+
const nullifiers = params.inputs.map((inp) => inp.nullifier);
|
|
1878
|
+
const commitments = params.outputs.map((out) => out.commitment);
|
|
1895
1879
|
const memos = params.outputs.map((out, i) => {
|
|
1896
1880
|
EncryptedMemo.validate(
|
|
1897
1881
|
out.encryptedMemo,
|
|
@@ -1902,7 +1886,7 @@ var ShieldedPoolModule = class {
|
|
|
1902
1886
|
const entry = resolveTx(this.substrate.unsafe, "ShieldedPool", "private_transfer");
|
|
1903
1887
|
const tx = callUnsafeTx(entry, {
|
|
1904
1888
|
proof: params.proof,
|
|
1905
|
-
merkle_root:
|
|
1889
|
+
merkle_root: params.merkleRoot,
|
|
1906
1890
|
nullifiers,
|
|
1907
1891
|
commitments,
|
|
1908
1892
|
encrypted_memos: memos,
|
|
@@ -1928,7 +1912,7 @@ var ShieldedPoolModule = class {
|
|
|
1928
1912
|
return {
|
|
1929
1913
|
assetId: item.assetId,
|
|
1930
1914
|
amount: item.amount.toString(),
|
|
1931
|
-
commitment:
|
|
1915
|
+
commitment: item.commitment,
|
|
1932
1916
|
encryptedMemo: item.encryptedMemo
|
|
1933
1917
|
};
|
|
1934
1918
|
});
|
|
@@ -1949,7 +1933,7 @@ var ShieldedPoolModule = class {
|
|
|
1949
1933
|
EncryptedMemo.validate(params.encryptedMemo, "claimShieldedFees.encryptedMemo");
|
|
1950
1934
|
const entry = resolveTx(this.substrate.unsafe, "ShieldedPool", "claim_shielded_fees");
|
|
1951
1935
|
const tx = callUnsafeTx(entry, {
|
|
1952
|
-
commitment:
|
|
1936
|
+
commitment: params.commitment,
|
|
1953
1937
|
amount: params.amount,
|
|
1954
1938
|
asset_id: params.assetId,
|
|
1955
1939
|
encrypted_memo: params.encryptedMemo,
|
package/dist/index.mjs
CHANGED
|
@@ -242,12 +242,12 @@ var SubstrateClient = class _SubstrateClient {
|
|
|
242
242
|
return this._papi.submitAndWatch(Binary.fromHex(signedHex));
|
|
243
243
|
}
|
|
244
244
|
/**
|
|
245
|
-
* Submits a bare (unsigned) extrinsic
|
|
245
|
+
* Submits a bare (unsigned) extrinsic and waits for finalization.
|
|
246
246
|
* Used for gasless private_transfer and unshield transactions.
|
|
247
|
-
* The bare tx
|
|
247
|
+
* The bare tx bytes are produced by `tx.getBareTx()` from polkadot-api.
|
|
248
248
|
*/
|
|
249
|
-
async submitUnsignedAndWatch(
|
|
250
|
-
return this._papi.submit(
|
|
249
|
+
async submitUnsignedAndWatch(bareTx) {
|
|
250
|
+
return this._papi.submit(bareTx);
|
|
251
251
|
}
|
|
252
252
|
/**
|
|
253
253
|
* Convenience: wrap raw call bytes and sign+submit in one step.
|
|
@@ -638,6 +638,7 @@ function formatORB(raw, precision = 6) {
|
|
|
638
638
|
}
|
|
639
639
|
|
|
640
640
|
// src/evm-explorer/EvmExplorer.ts
|
|
641
|
+
var MAX_LOG_BLOCK_RANGE = 1e3;
|
|
641
642
|
var EvmExplorer = class _EvmExplorer {
|
|
642
643
|
/** @param evm - Underlying `EvmClient` used for all RPC calls. */
|
|
643
644
|
constructor(evm) {
|
|
@@ -747,11 +748,11 @@ var EvmExplorer = class _EvmExplorer {
|
|
|
747
748
|
// --- Address ---
|
|
748
749
|
/**
|
|
749
750
|
* Returns aggregated on-chain data for an EVM address: balance, nonce,
|
|
750
|
-
* bytecode (truncated), and up to 50 recent logs from the last
|
|
751
|
+
* bytecode (truncated), and up to 50 recent logs from the last 1 000 blocks.
|
|
751
752
|
*/
|
|
752
753
|
async getAddressInfo(address) {
|
|
753
754
|
const latest = await this.evm.getBlockNumber().catch(() => 0);
|
|
754
|
-
const fromBlock = `0x${Math.max(0, latest -
|
|
755
|
+
const fromBlock = `0x${Math.max(0, latest - MAX_LOG_BLOCK_RANGE).toString(16)}`;
|
|
755
756
|
const [balance, nonce, code, logs] = await Promise.all([
|
|
756
757
|
this.evm.request("eth_getBalance", [address, "latest"]).catch(() => null),
|
|
757
758
|
this.evm.getTransactionCount(address).catch(() => 0),
|
|
@@ -830,13 +831,13 @@ var EvmExplorer = class _EvmExplorer {
|
|
|
830
831
|
};
|
|
831
832
|
}
|
|
832
833
|
/**
|
|
833
|
-
* Returns ERC-20 `Transfer` events for `address` from the last
|
|
834
|
+
* Returns ERC-20 `Transfer` events for `address` from the last 1 000 blocks.
|
|
834
835
|
* When `holderAddress` is provided, restricts results to transfers sent or received by that address.
|
|
835
836
|
*/
|
|
836
837
|
async getTokenTransfers(address, holderAddress) {
|
|
837
838
|
const TRANSFER = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";
|
|
838
839
|
const latest = await this.evm.getBlockNumber().catch(() => 0);
|
|
839
|
-
const fromBlock = `0x${Math.max(0, latest -
|
|
840
|
+
const fromBlock = `0x${Math.max(0, latest - MAX_LOG_BLOCK_RANGE).toString(16)}`;
|
|
840
841
|
let logs;
|
|
841
842
|
if (holderAddress) {
|
|
842
843
|
const padded = `0x${holderAddress.replace(/^0x/, "").toLowerCase().padStart(64, "0")}`;
|
|
@@ -986,24 +987,6 @@ var IndexerClient = class {
|
|
|
986
987
|
}
|
|
987
988
|
return res.json();
|
|
988
989
|
}
|
|
989
|
-
async post(path, body) {
|
|
990
|
-
const controller = new AbortController();
|
|
991
|
-
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
992
|
-
try {
|
|
993
|
-
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
994
|
-
method: "POST",
|
|
995
|
-
headers: { "Content-Type": "application/json" },
|
|
996
|
-
body: JSON.stringify(body),
|
|
997
|
-
signal: controller.signal
|
|
998
|
-
});
|
|
999
|
-
if (!res.ok) {
|
|
1000
|
-
throw new Error(`IndexerClient: HTTP ${res.status} for POST ${path}`);
|
|
1001
|
-
}
|
|
1002
|
-
return res.json();
|
|
1003
|
-
} finally {
|
|
1004
|
-
clearTimeout(timer);
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
990
|
async getOrNull(path) {
|
|
1008
991
|
const res = await this._fetchResponse(path);
|
|
1009
992
|
if (res.status === 404) return null;
|
|
@@ -1067,16 +1050,17 @@ var IndexerClient = class {
|
|
|
1067
1050
|
);
|
|
1068
1051
|
}
|
|
1069
1052
|
/**
|
|
1070
|
-
*
|
|
1071
|
-
*
|
|
1072
|
-
*
|
|
1053
|
+
* Downloads the full spent nullifier set and returns it as a Set of lowercase hex strings.
|
|
1054
|
+
*
|
|
1055
|
+
* The server sees an identical GET request regardless of which notes the wallet holds —
|
|
1056
|
+
* the intersection is computed locally (PIR-A privacy model).
|
|
1057
|
+
*
|
|
1058
|
+
* Suitable for wallets with up to ~1M spent nullifiers (~70 MB raw, <20 MB gzip).
|
|
1059
|
+
* For the current Orbinum testnet/mainnet scale this is the recommended approach.
|
|
1073
1060
|
*/
|
|
1074
|
-
async
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
nullifiers: nullifiers.map((n) => n.toLowerCase())
|
|
1078
|
-
});
|
|
1079
|
-
return res.data;
|
|
1061
|
+
async getAllSpentNullifiers() {
|
|
1062
|
+
const res = await this.get("/shielded/nullifiers/all");
|
|
1063
|
+
return new Set(res.data.map((h) => h.toLowerCase()));
|
|
1080
1064
|
}
|
|
1081
1065
|
// ─── Private transfers ─────────────────────────────────────────────────────
|
|
1082
1066
|
/**
|
|
@@ -1255,7 +1239,7 @@ var IndexerClient = class {
|
|
|
1255
1239
|
};
|
|
1256
1240
|
|
|
1257
1241
|
// src/shielded-pool/pallet/ShieldedPoolModule.ts
|
|
1258
|
-
import
|
|
1242
|
+
import "polkadot-api";
|
|
1259
1243
|
|
|
1260
1244
|
// src/utils/tx.ts
|
|
1261
1245
|
function formatDispatchError(err) {
|
|
@@ -1288,8 +1272,8 @@ function callUnsafeTx(txEntry, ...args) {
|
|
|
1288
1272
|
return txEntry(...args);
|
|
1289
1273
|
}
|
|
1290
1274
|
async function submitBareTx(tx, client) {
|
|
1291
|
-
const
|
|
1292
|
-
const payload = await client.submitUnsignedAndWatch(
|
|
1275
|
+
const bareTx = await tx.getBareTx();
|
|
1276
|
+
const payload = await client.submitUnsignedAndWatch(bareTx);
|
|
1293
1277
|
return toTxResult(payload);
|
|
1294
1278
|
}
|
|
1295
1279
|
function resolveTx(unsafe, pallet, call) {
|
|
@@ -1711,7 +1695,7 @@ var ShieldedPoolModule = class {
|
|
|
1711
1695
|
const tx = callUnsafeTx(entry, {
|
|
1712
1696
|
asset_id: params.assetId,
|
|
1713
1697
|
amount: params.amount,
|
|
1714
|
-
commitment:
|
|
1698
|
+
commitment: params.commitment,
|
|
1715
1699
|
encrypted_memo: params.encryptedMemo
|
|
1716
1700
|
});
|
|
1717
1701
|
return toTxResult(
|
|
@@ -1738,13 +1722,13 @@ var ShieldedPoolModule = class {
|
|
|
1738
1722
|
}
|
|
1739
1723
|
const tx = callUnsafeTx(entry, {
|
|
1740
1724
|
proof: params.proof,
|
|
1741
|
-
merkle_root:
|
|
1742
|
-
nullifier:
|
|
1725
|
+
merkle_root: params.merkleRoot,
|
|
1726
|
+
nullifier: params.nullifier,
|
|
1743
1727
|
asset_id: params.assetId,
|
|
1744
1728
|
amount: params.amount,
|
|
1745
1729
|
recipient: recipientSs58,
|
|
1746
1730
|
fee: params.fee ?? 0n,
|
|
1747
|
-
change_commitment:
|
|
1731
|
+
change_commitment: changeCommitment,
|
|
1748
1732
|
change_encrypted_memo: changeEncryptedMemo,
|
|
1749
1733
|
relayer: void 0
|
|
1750
1734
|
// Option<H160> — None for direct Substrate submissions
|
|
@@ -1763,8 +1747,8 @@ var ShieldedPoolModule = class {
|
|
|
1763
1747
|
* Extrinsic: shieldedPool.privateTransfer(proof, merkleRoot, nullifiers, commitments, memos, assetId, fee)
|
|
1764
1748
|
*/
|
|
1765
1749
|
async privateTransfer(params, signer, txOptions) {
|
|
1766
|
-
const nullifiers = params.inputs.map((inp) =>
|
|
1767
|
-
const commitments = params.outputs.map((out) =>
|
|
1750
|
+
const nullifiers = params.inputs.map((inp) => inp.nullifier);
|
|
1751
|
+
const commitments = params.outputs.map((out) => out.commitment);
|
|
1768
1752
|
const memos = params.outputs.map((out, i) => {
|
|
1769
1753
|
EncryptedMemo.validate(
|
|
1770
1754
|
out.encryptedMemo,
|
|
@@ -1775,7 +1759,7 @@ var ShieldedPoolModule = class {
|
|
|
1775
1759
|
const entry = resolveTx(this.substrate.unsafe, "ShieldedPool", "private_transfer");
|
|
1776
1760
|
const tx = callUnsafeTx(entry, {
|
|
1777
1761
|
proof: params.proof,
|
|
1778
|
-
merkle_root:
|
|
1762
|
+
merkle_root: params.merkleRoot,
|
|
1779
1763
|
nullifiers,
|
|
1780
1764
|
commitments,
|
|
1781
1765
|
encrypted_memos: memos,
|
|
@@ -1801,7 +1785,7 @@ var ShieldedPoolModule = class {
|
|
|
1801
1785
|
return {
|
|
1802
1786
|
assetId: item.assetId,
|
|
1803
1787
|
amount: item.amount.toString(),
|
|
1804
|
-
commitment:
|
|
1788
|
+
commitment: item.commitment,
|
|
1805
1789
|
encryptedMemo: item.encryptedMemo
|
|
1806
1790
|
};
|
|
1807
1791
|
});
|
|
@@ -1822,7 +1806,7 @@ var ShieldedPoolModule = class {
|
|
|
1822
1806
|
EncryptedMemo.validate(params.encryptedMemo, "claimShieldedFees.encryptedMemo");
|
|
1823
1807
|
const entry = resolveTx(this.substrate.unsafe, "ShieldedPool", "claim_shielded_fees");
|
|
1824
1808
|
const tx = callUnsafeTx(entry, {
|
|
1825
|
-
commitment:
|
|
1809
|
+
commitment: params.commitment,
|
|
1826
1810
|
amount: params.amount,
|
|
1827
1811
|
asset_id: params.assetId,
|
|
1828
1812
|
encrypted_memo: params.encryptedMemo,
|
|
@@ -1836,7 +1820,7 @@ var ShieldedPoolModule = class {
|
|
|
1836
1820
|
};
|
|
1837
1821
|
|
|
1838
1822
|
// src/account-mapping/AccountMappingModule.ts
|
|
1839
|
-
import { Binary as
|
|
1823
|
+
import { Binary as Binary2 } from "polkadot-api";
|
|
1840
1824
|
|
|
1841
1825
|
// src/account-mapping/helpers.ts
|
|
1842
1826
|
function mapRawScheme(raw) {
|
|
@@ -2106,7 +2090,7 @@ var AccountMappingModule = class {
|
|
|
2106
2090
|
*/
|
|
2107
2091
|
async registerAlias(alias, signer) {
|
|
2108
2092
|
const entry = resolveTx(this.substrate.unsafe, "accountMapping", "registerAlias");
|
|
2109
|
-
const tx = callUnsafeTx(entry,
|
|
2093
|
+
const tx = callUnsafeTx(entry, Binary2.fromText(alias));
|
|
2110
2094
|
return toTxResult(await tx.signAndSubmit(signer));
|
|
2111
2095
|
}
|
|
2112
2096
|
/**
|
|
@@ -2157,7 +2141,7 @@ var AccountMappingModule = class {
|
|
|
2157
2141
|
*/
|
|
2158
2142
|
async setAccountMetadata(params, signer) {
|
|
2159
2143
|
const entry = resolveTx(this.substrate.unsafe, "accountMapping", "setAccountMetadata");
|
|
2160
|
-
const encode2 = (v) => v != null ?
|
|
2144
|
+
const encode2 = (v) => v != null ? Binary2.fromText(v) : void 0;
|
|
2161
2145
|
const tx = callUnsafeTx(
|
|
2162
2146
|
entry,
|
|
2163
2147
|
encode2(params.displayName),
|
|
@@ -2190,7 +2174,7 @@ var AccountMappingModule = class {
|
|
|
2190
2174
|
*/
|
|
2191
2175
|
async buyAlias(alias, signer) {
|
|
2192
2176
|
const entry = resolveTx(this.substrate.unsafe, "accountMapping", "buyAlias");
|
|
2193
|
-
const tx = callUnsafeTx(entry,
|
|
2177
|
+
const tx = callUnsafeTx(entry, Binary2.fromText(alias));
|
|
2194
2178
|
return toTxResult(await tx.signAndSubmit(signer));
|
|
2195
2179
|
}
|
|
2196
2180
|
/**
|