@orbinum/sdk 0.1.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.d.mts +1674 -0
- package/dist/index.d.ts +1674 -0
- package/dist/index.js +2397 -0
- package/dist/index.mjs +2324 -0
- package/package.json +66 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1674 @@
|
|
|
1
|
+
import * as polkadot_api from 'polkadot-api';
|
|
2
|
+
import { PolkadotClient, TxFinalizedPayload, PolkadotSigner } from 'polkadot-api';
|
|
3
|
+
export { PolkadotSigner } from 'polkadot-api';
|
|
4
|
+
export { getPolkadotSigner } from 'polkadot-api/signer';
|
|
5
|
+
export { getPolkadotSignerFromPjs } from 'polkadot-api/pjs-signer';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Thin wrapper over polkadot-api (PAPI) that provides:
|
|
9
|
+
* - Raw JSON-RPC calls (custom Orbinum RPCs)
|
|
10
|
+
* - Unsafe transaction building from call data
|
|
11
|
+
* - Transaction submission with or without watching
|
|
12
|
+
*/
|
|
13
|
+
declare class SubstrateClient {
|
|
14
|
+
private readonly _papi;
|
|
15
|
+
private constructor();
|
|
16
|
+
/**
|
|
17
|
+
* Connects to the Orbinum node via WebSocket.
|
|
18
|
+
* Throws if the node does not respond within `timeoutMs`.
|
|
19
|
+
*/
|
|
20
|
+
static connect(wsUrl: string, timeoutMs?: number): Promise<SubstrateClient>;
|
|
21
|
+
/**
|
|
22
|
+
* Performs a raw JSON-RPC request. Use this for custom Orbinum RPCs
|
|
23
|
+
* (shieldedPool_*, accountMapping_*, privacy_*, etc.).
|
|
24
|
+
*/
|
|
25
|
+
request<T>(method: string, params?: unknown[]): Promise<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the underlying PolkadotClient instance.
|
|
28
|
+
* Use for block subscriptions (`blocks$`), raw metadata access, and advanced SCALE operations.
|
|
29
|
+
*/
|
|
30
|
+
get polkadotClient(): PolkadotClient;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the PAPI UnsafeApi for dynamic, metadata-driven transaction building.
|
|
33
|
+
* The first access triggers a metadata fetch from the node.
|
|
34
|
+
*
|
|
35
|
+
* Usage:
|
|
36
|
+
* ```ts
|
|
37
|
+
* const tx = client.unsafe.tx.shieldedPool.shield(...);
|
|
38
|
+
* const result = await tx.signAndSubmit(signer);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
get unsafe(): polkadot_api.UnsafeApi<unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* Wraps pre-built SCALE call bytes (from protocol-core TransactionBuilder)
|
|
44
|
+
* into a PAPI UnsafeTransaction that can be signed and submitted.
|
|
45
|
+
*/
|
|
46
|
+
txFromCallData(callData: Uint8Array): Promise<polkadot_api.UnsafeTransaction<any, string, string, any, Record<string, {
|
|
47
|
+
value: any;
|
|
48
|
+
additionalSigned: any;
|
|
49
|
+
} | {
|
|
50
|
+
value: any;
|
|
51
|
+
} | {
|
|
52
|
+
additionalSigned: any;
|
|
53
|
+
}>>>;
|
|
54
|
+
/**
|
|
55
|
+
* Submits a pre-signed extrinsic (hex string) and waits for finalization.
|
|
56
|
+
*/
|
|
57
|
+
submit(signedHex: string): Promise<TxFinalizedPayload>;
|
|
58
|
+
/**
|
|
59
|
+
* Submits a pre-signed extrinsic and returns an Observable of tx lifecycle events.
|
|
60
|
+
* Events: TxSigned → TxBroadcasted → TxBestBlocksState → TxFinalized
|
|
61
|
+
*/
|
|
62
|
+
submitAndWatch(signedHex: string): ReturnType<PolkadotClient['submitAndWatch']>;
|
|
63
|
+
/**
|
|
64
|
+
* Convenience: wrap raw call bytes and sign+submit in one step.
|
|
65
|
+
*/
|
|
66
|
+
signAndSubmit(callData: Uint8Array, signer: PolkadotSigner): Promise<TxFinalizedPayload>;
|
|
67
|
+
/** Closes the WebSocket connection. */
|
|
68
|
+
destroy(): void;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Stateless HTTP JSON-RPC client for the Orbinum EVM endpoint.
|
|
73
|
+
* Follows the standard Ethereum JSON-RPC specification.
|
|
74
|
+
*/
|
|
75
|
+
declare class EvmClient {
|
|
76
|
+
private readonly rpcUrl;
|
|
77
|
+
constructor(rpcUrl: string);
|
|
78
|
+
/**
|
|
79
|
+
* Performs a single JSON-RPC call.
|
|
80
|
+
*/
|
|
81
|
+
request<T>(method: string, params?: unknown[]): Promise<T>;
|
|
82
|
+
/**
|
|
83
|
+
* Performs multiple JSON-RPC calls in a single HTTP request (batch).
|
|
84
|
+
*/
|
|
85
|
+
batchRequest<T extends unknown[]>(calls: Array<{
|
|
86
|
+
method: string;
|
|
87
|
+
params?: unknown[];
|
|
88
|
+
}>): Promise<T>;
|
|
89
|
+
/** Returns the native token balance (in wei) for an EVM address. */
|
|
90
|
+
getBalance(address: string): Promise<bigint>;
|
|
91
|
+
/** Returns the latest block number. */
|
|
92
|
+
getBlockNumber(): Promise<number>;
|
|
93
|
+
/** Returns the current chain ID. */
|
|
94
|
+
getChainId(): Promise<number>;
|
|
95
|
+
/** Returns the transaction count (nonce) for an EVM address. */
|
|
96
|
+
getTransactionCount(address: string): Promise<number>;
|
|
97
|
+
/** Returns the current gas price in wei. */
|
|
98
|
+
getGasPrice(): Promise<bigint>;
|
|
99
|
+
/**
|
|
100
|
+
* Submits a signed raw transaction. Returns the transaction hash.
|
|
101
|
+
*/
|
|
102
|
+
sendRawTransaction(signedHex: string): Promise<string>;
|
|
103
|
+
/**
|
|
104
|
+
* Executes a read-only call without creating a transaction.
|
|
105
|
+
*/
|
|
106
|
+
call(to: string, data: string, from?: string): Promise<string>;
|
|
107
|
+
/**
|
|
108
|
+
* Estimates the gas for a transaction.
|
|
109
|
+
*/
|
|
110
|
+
estimateGas(params: {
|
|
111
|
+
from?: string;
|
|
112
|
+
to: string;
|
|
113
|
+
data?: string;
|
|
114
|
+
value?: string;
|
|
115
|
+
}): Promise<bigint>;
|
|
116
|
+
/**
|
|
117
|
+
* Returns a transaction receipt by hash, or null if not yet mined.
|
|
118
|
+
*/
|
|
119
|
+
getTransactionReceipt(txHash: string): Promise<Record<string, unknown> | null>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
type OrbinumClientConfig = {
|
|
123
|
+
/** WebSocket URL of the Orbinum node (e.g. "ws://localhost:9944") */
|
|
124
|
+
substrateWs: string;
|
|
125
|
+
/** HTTP URL of the EVM JSON-RPC endpoint (e.g. "http://localhost:9933") */
|
|
126
|
+
evmRpc?: string;
|
|
127
|
+
/** Connection timeout in ms. Default: 15_000 */
|
|
128
|
+
connectTimeoutMs?: number;
|
|
129
|
+
};
|
|
130
|
+
type TxResult = {
|
|
131
|
+
txHash: string;
|
|
132
|
+
blockHash: string;
|
|
133
|
+
blockNumber: number;
|
|
134
|
+
/** Whether the extrinsic succeeded (no ExtrinsicFailed event). */
|
|
135
|
+
ok: boolean;
|
|
136
|
+
/** Dispatch error type string when ok = false. */
|
|
137
|
+
error?: string;
|
|
138
|
+
};
|
|
139
|
+
type MerkleTreeInfo = {
|
|
140
|
+
root: string;
|
|
141
|
+
treeSize: number;
|
|
142
|
+
depth: number;
|
|
143
|
+
};
|
|
144
|
+
/** Aggregate shielded pool statistics (merkle tree + total locked balance). */
|
|
145
|
+
type PoolStats = {
|
|
146
|
+
merkleRoot: string;
|
|
147
|
+
commitmentCount: number;
|
|
148
|
+
/** Total native balance locked in the pool (u128 as decimal string). */
|
|
149
|
+
totalBalance: string;
|
|
150
|
+
treeDepth: number;
|
|
151
|
+
};
|
|
152
|
+
type MerkleProof = {
|
|
153
|
+
root: string;
|
|
154
|
+
leafIndex: number;
|
|
155
|
+
siblings: string[];
|
|
156
|
+
};
|
|
157
|
+
type CommitmentMerkleProof = MerkleProof;
|
|
158
|
+
type NullifierStatus = {
|
|
159
|
+
nullifier: string;
|
|
160
|
+
isSpent: boolean;
|
|
161
|
+
};
|
|
162
|
+
type PoolBalance = {
|
|
163
|
+
assetId: number;
|
|
164
|
+
balance: bigint;
|
|
165
|
+
};
|
|
166
|
+
type ShieldParams = {
|
|
167
|
+
assetId: number;
|
|
168
|
+
amount: bigint;
|
|
169
|
+
/** 0x-prefixed 32-byte commitment hex */
|
|
170
|
+
commitment: string;
|
|
171
|
+
/** Optional encrypted memo bytes. Auto-generates a dummy memo if absent. */
|
|
172
|
+
encryptedMemo?: Uint8Array;
|
|
173
|
+
};
|
|
174
|
+
type UnshieldParams = {
|
|
175
|
+
/** ZK proof bytes */
|
|
176
|
+
proof: Uint8Array;
|
|
177
|
+
/** 0x-prefixed merkle root hex */
|
|
178
|
+
merkleRoot: string;
|
|
179
|
+
/** 0x-prefixed nullifier hex */
|
|
180
|
+
nullifier: string;
|
|
181
|
+
assetId: number;
|
|
182
|
+
amount: bigint;
|
|
183
|
+
/** SS58 or 0x-prefixed 32-byte address */
|
|
184
|
+
recipientAddress: string;
|
|
185
|
+
};
|
|
186
|
+
type TransferInput = {
|
|
187
|
+
/** 0x-prefixed nullifier hex */
|
|
188
|
+
nullifier: string;
|
|
189
|
+
/** 0x-prefixed commitment hex */
|
|
190
|
+
commitment: string;
|
|
191
|
+
};
|
|
192
|
+
type TransferOutput = {
|
|
193
|
+
/** 0x-prefixed commitment hex */
|
|
194
|
+
commitment: string;
|
|
195
|
+
encryptedMemo?: Uint8Array;
|
|
196
|
+
};
|
|
197
|
+
type PrivateTransferParams = {
|
|
198
|
+
inputs: TransferInput[];
|
|
199
|
+
outputs: TransferOutput[];
|
|
200
|
+
/** ZK proof bytes */
|
|
201
|
+
proof: Uint8Array;
|
|
202
|
+
/** 0x-prefixed merkle root hex */
|
|
203
|
+
merkleRoot: string;
|
|
204
|
+
};
|
|
205
|
+
/** Input params for NoteBuilder.build(). All fields except value have defaults. */
|
|
206
|
+
type NoteInput = {
|
|
207
|
+
/** Amount in planck (required). */
|
|
208
|
+
value: bigint;
|
|
209
|
+
/** Asset ID — default 0 (native ORB-Privacy). */
|
|
210
|
+
assetId?: bigint;
|
|
211
|
+
/** BabyJubJub Ax coordinate (owner public key x). Default 0n. */
|
|
212
|
+
ownerPk?: bigint;
|
|
213
|
+
/** Random blinding scalar. Defaults to BigInt(Date.now()). */
|
|
214
|
+
blinding?: bigint;
|
|
215
|
+
/** Secret spending key used to derive the nullifier. Default 0n. */
|
|
216
|
+
spendingKey?: bigint;
|
|
217
|
+
/**
|
|
218
|
+
* 32-byte recipient viewing key used to encrypt the memo (ChaCha20-Poly1305).
|
|
219
|
+
* When provided, NoteBuilder.build() will auto-generate the 104-byte encrypted memo.
|
|
220
|
+
* Omit to skip memo generation (use buildMemo() separately if needed).
|
|
221
|
+
*/
|
|
222
|
+
viewingKey?: Uint8Array;
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Computed ZK note (commitment + nullifier). Built entirely off-chain.
|
|
226
|
+
*
|
|
227
|
+
* commitment = Poseidon(value, assetId, ownerPk, blinding)
|
|
228
|
+
* nullifier = Poseidon(commitment, spendingKey)
|
|
229
|
+
*/
|
|
230
|
+
type ZkNote = {
|
|
231
|
+
value: bigint;
|
|
232
|
+
assetId: bigint;
|
|
233
|
+
ownerPk: bigint;
|
|
234
|
+
blinding: bigint;
|
|
235
|
+
spendingKey: bigint;
|
|
236
|
+
/** Whether the note has been spent/nullified on-chain. */
|
|
237
|
+
spent: boolean;
|
|
238
|
+
/** Local timestamp when this note was marked spent, or null if still active/unknown. */
|
|
239
|
+
spentAt: number | null;
|
|
240
|
+
/** Poseidon commitment scalar. */
|
|
241
|
+
commitment: bigint;
|
|
242
|
+
/** Poseidon nullifier scalar. */
|
|
243
|
+
nullifier: bigint;
|
|
244
|
+
/** 0x-prefixed 32-byte little-endian hex commitment. */
|
|
245
|
+
commitmentHex: string;
|
|
246
|
+
/** 0x-prefixed 32-byte little-endian hex nullifier. */
|
|
247
|
+
nullifierHex: string;
|
|
248
|
+
/**
|
|
249
|
+
* 104-byte encrypted memo (ChaCha20-Poly1305) as number[] for SCALE encoding.
|
|
250
|
+
* Always populated: uses a dummy memo when no viewingKey is provided.
|
|
251
|
+
*/
|
|
252
|
+
memo: number[];
|
|
253
|
+
};
|
|
254
|
+
/** Result of buildAndShield: the submitted tx and the note to keep safe. */
|
|
255
|
+
type ShieldResult = {
|
|
256
|
+
txResult: TxResult;
|
|
257
|
+
note: ZkNote;
|
|
258
|
+
};
|
|
259
|
+
type ChainInfo = {
|
|
260
|
+
name: string;
|
|
261
|
+
version: string;
|
|
262
|
+
ss58Prefix: number;
|
|
263
|
+
};
|
|
264
|
+
type FullIdentityInfo = {
|
|
265
|
+
substrateAddress: string | null;
|
|
266
|
+
evmAddress: string | null;
|
|
267
|
+
alias: string | null;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Signature verification scheme for cross-chain links.
|
|
271
|
+
* Mirrors `SignatureScheme` in pallet-account-mapping.
|
|
272
|
+
*/
|
|
273
|
+
type SignatureScheme = 'Eip191' | 'Ed25519';
|
|
274
|
+
/** A verified public link to an external chain wallet. */
|
|
275
|
+
type ChainLink = {
|
|
276
|
+
chainId: number;
|
|
277
|
+
address: string;
|
|
278
|
+
};
|
|
279
|
+
/** A private link: only the Poseidon commitment is stored on-chain. */
|
|
280
|
+
type PrivateLink = {
|
|
281
|
+
chainId: number;
|
|
282
|
+
commitment: string;
|
|
283
|
+
};
|
|
284
|
+
/** Public profile metadata set by the account owner. */
|
|
285
|
+
type AccountMetadata = {
|
|
286
|
+
displayName: string | null;
|
|
287
|
+
bio: string | null;
|
|
288
|
+
avatar: string | null;
|
|
289
|
+
};
|
|
290
|
+
/** Identity info by alias: owner, optional EVM address, link count. */
|
|
291
|
+
type AliasInfo = {
|
|
292
|
+
/** 0x-prefixed 32-byte AccountId32 hex. */
|
|
293
|
+
owner: string;
|
|
294
|
+
/** Normalized EVM address (0x + 40 hex chars), or null. */
|
|
295
|
+
evmAddress: string | null;
|
|
296
|
+
chainLinksCount: number;
|
|
297
|
+
};
|
|
298
|
+
/**
|
|
299
|
+
* Full identity for an alias: owner, EVM address, all public chain links, metadata.
|
|
300
|
+
* Returned by `accountMapping_getFullIdentity` (alias-based lookup).
|
|
301
|
+
*/
|
|
302
|
+
type AliasFullIdentity = {
|
|
303
|
+
owner: string;
|
|
304
|
+
evmAddress: string | null;
|
|
305
|
+
chainLinks: ChainLink[];
|
|
306
|
+
metadata: AccountMetadata | null;
|
|
307
|
+
};
|
|
308
|
+
/** Sale listing info for an alias on the marketplace. */
|
|
309
|
+
type ListingInfo = {
|
|
310
|
+
price: bigint;
|
|
311
|
+
/** True if sale is private (whitelist-only). */
|
|
312
|
+
private: boolean;
|
|
313
|
+
whitelistCount: number;
|
|
314
|
+
};
|
|
315
|
+
/** An alias actively listed for sale with its full info. */
|
|
316
|
+
type AccountListing = {
|
|
317
|
+
alias: string;
|
|
318
|
+
listing: ListingInfo;
|
|
319
|
+
};
|
|
320
|
+
/** A supported chain and its signature verification scheme. */
|
|
321
|
+
type SupportedChain = {
|
|
322
|
+
chainId: number;
|
|
323
|
+
scheme: SignatureScheme;
|
|
324
|
+
};
|
|
325
|
+
/**
|
|
326
|
+
* Bitmask to convert a SLIP-0044 coin type into an Orbinum ChainId.
|
|
327
|
+
* Example: `SLIP0044_NAMESPACE | 501` = Solana.
|
|
328
|
+
*/
|
|
329
|
+
declare const SLIP0044_NAMESPACE = 2147483648;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Queries the Orbinum shielded-pool Merkle tree via custom RPC methods.
|
|
333
|
+
*/
|
|
334
|
+
declare class MerkleModule {
|
|
335
|
+
private readonly substrate;
|
|
336
|
+
constructor(substrate: SubstrateClient);
|
|
337
|
+
/**
|
|
338
|
+
* Returns the current Merkle tree state: root, number of leaves, and depth.
|
|
339
|
+
*/
|
|
340
|
+
getTreeInfo(): Promise<MerkleTreeInfo>;
|
|
341
|
+
/**
|
|
342
|
+
* Returns the Merkle inclusion proof for a leaf at `leafIndex`.
|
|
343
|
+
*/
|
|
344
|
+
getProof(leafIndex: number): Promise<MerkleProof>;
|
|
345
|
+
/**
|
|
346
|
+
* Returns the Merkle inclusion proof for a given commitment (0x-prefixed hex).
|
|
347
|
+
* Searches the tree for the commitment and returns its proof.
|
|
348
|
+
*/
|
|
349
|
+
getProofByCommitment(commitmentHex: string): Promise<MerkleProof>;
|
|
350
|
+
/**
|
|
351
|
+
* Returns the current Merkle root without fetching the full tree info.
|
|
352
|
+
*/
|
|
353
|
+
getRoot(): Promise<string>;
|
|
354
|
+
/**
|
|
355
|
+
* Returns an array of commitment leaves from index `from` to `to` (inclusive).
|
|
356
|
+
* Defaults to returning all leaves.
|
|
357
|
+
*/
|
|
358
|
+
getLeaves(from?: number, to?: number): Promise<string[]>;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* High-level module for Orbinum shielded-pool operations.
|
|
363
|
+
*
|
|
364
|
+
* Transactions are built via polkadot-api's UnsafeApi (metadata-driven),
|
|
365
|
+
* which means the Orbinum node must be reachable on first use.
|
|
366
|
+
* Signing is delegated to a PolkadotSigner (see polkadot-api/signer).
|
|
367
|
+
*
|
|
368
|
+
* Parameter order matches the Orbinum runtime extrinsics exactly.
|
|
369
|
+
*/
|
|
370
|
+
declare class ShieldedPoolModule {
|
|
371
|
+
private readonly substrate;
|
|
372
|
+
readonly merkle: MerkleModule;
|
|
373
|
+
constructor(substrate: SubstrateClient, merkle: MerkleModule);
|
|
374
|
+
/**
|
|
375
|
+
* Deposits tokens into the shielded pool.
|
|
376
|
+
* Extrinsic: shieldedPool.shield(assetId, amount, commitment, encryptedMemo)
|
|
377
|
+
*/
|
|
378
|
+
shield(params: ShieldParams, signer: PolkadotSigner): Promise<TxResult>;
|
|
379
|
+
/**
|
|
380
|
+
* Build a ZkNote locally and submit shieldedPool.shield in one call.
|
|
381
|
+
*
|
|
382
|
+
* Returns both the on-chain result and the note — **save the note locally**,
|
|
383
|
+
* it cannot be recovered after the fact.
|
|
384
|
+
*
|
|
385
|
+
* @param params.value Amount in planck (required).
|
|
386
|
+
* @param params.assetId Asset ID — default 0 (native ORB-Privacy).
|
|
387
|
+
* @param params.ownerPk BabyJubJub Ax (default 0n).
|
|
388
|
+
* @param params.blinding Random blinding scalar (default BigInt(Date.now())).
|
|
389
|
+
* @param params.spendingKey Secret spending key (default 0n).
|
|
390
|
+
*/
|
|
391
|
+
buildAndShield(params: {
|
|
392
|
+
value: bigint;
|
|
393
|
+
assetId?: number;
|
|
394
|
+
ownerPk?: bigint;
|
|
395
|
+
blinding?: bigint;
|
|
396
|
+
spendingKey?: bigint;
|
|
397
|
+
}, signer: PolkadotSigner): Promise<ShieldResult>;
|
|
398
|
+
/**
|
|
399
|
+
* Withdraws tokens from the shielded pool to a public address.
|
|
400
|
+
* Extrinsic: shieldedPool.unshield(proof, merkleRoot, nullifier, assetId, amount, recipient)
|
|
401
|
+
*/
|
|
402
|
+
unshield(params: UnshieldParams, signer: PolkadotSigner): Promise<TxResult>;
|
|
403
|
+
/**
|
|
404
|
+
* Performs a private (shielded) transfer between two notes.
|
|
405
|
+
* Extrinsic: shieldedPool.privateTransfer(inputs, outputs, proof, merkleRoot)
|
|
406
|
+
*/
|
|
407
|
+
privateTransfer(params: PrivateTransferParams, signer: PolkadotSigner): Promise<TxResult>;
|
|
408
|
+
/** Returns whether a nullifier has already been spent. */
|
|
409
|
+
isNullifierSpent(nullifierHex: string): Promise<boolean>;
|
|
410
|
+
/** Returns the full nullifier status object. */
|
|
411
|
+
getNullifierStatus(nullifierHex: string): Promise<NullifierStatus>;
|
|
412
|
+
/** Returns the total locked balance in the pool for a given asset. */
|
|
413
|
+
getPoolBalance(assetId: number): Promise<PoolBalance>;
|
|
414
|
+
/**
|
|
415
|
+
* Returns Merkle tree info and pool balance for a given asset in a single call.
|
|
416
|
+
* Convenience wrapper used by both `app` and `privacy-explorer`.
|
|
417
|
+
*/
|
|
418
|
+
getPoolStats(assetId?: number): Promise<{
|
|
419
|
+
merkle: MerkleTreeInfo;
|
|
420
|
+
balance: PoolBalance;
|
|
421
|
+
}>;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
type RawSystemHealth = {
|
|
425
|
+
peers: number;
|
|
426
|
+
isSyncing: boolean;
|
|
427
|
+
shouldHavePeers: boolean;
|
|
428
|
+
};
|
|
429
|
+
/**
|
|
430
|
+
* Provides general chain queries: node info, account mapping, address resolution.
|
|
431
|
+
*/
|
|
432
|
+
declare class ChainModule {
|
|
433
|
+
private readonly substrate;
|
|
434
|
+
private readonly evm;
|
|
435
|
+
constructor(substrate: SubstrateClient, evm: EvmClient | null);
|
|
436
|
+
/**
|
|
437
|
+
* Returns basic chain information from the node.
|
|
438
|
+
*/
|
|
439
|
+
getChainInfo(): Promise<ChainInfo>;
|
|
440
|
+
/**
|
|
441
|
+
* Returns the node's peer count and sync status.
|
|
442
|
+
*/
|
|
443
|
+
getHealth(): Promise<RawSystemHealth>;
|
|
444
|
+
/**
|
|
445
|
+
* Returns the node's software version string.
|
|
446
|
+
*/
|
|
447
|
+
getNodeVersion(): Promise<string>;
|
|
448
|
+
/**
|
|
449
|
+
* Returns the genesis hash hex.
|
|
450
|
+
*/
|
|
451
|
+
getGenesisHash(): Promise<string>;
|
|
452
|
+
/**
|
|
453
|
+
* Resolves the full identity (Substrate + EVM addresses, alias) for an account.
|
|
454
|
+
* Accepts an EVM address (0x...) or a Substrate account hex (0x...32bytes).
|
|
455
|
+
*/
|
|
456
|
+
getFullIdentity(address: string): Promise<FullIdentityInfo | null>;
|
|
457
|
+
/**
|
|
458
|
+
* Returns the mapped Substrate account hex for a given EVM address, or null.
|
|
459
|
+
*/
|
|
460
|
+
getMappedAccountByEvm(evmAddress: string): Promise<string | null>;
|
|
461
|
+
/**
|
|
462
|
+
* Returns the alias registered for a Substrate account, or null.
|
|
463
|
+
*/
|
|
464
|
+
getAliasOf(accountHex: string): Promise<string | null>;
|
|
465
|
+
/**
|
|
466
|
+
* Returns estimated EVM chain ID from the EVM RPC endpoint. Requires evmRpc
|
|
467
|
+
* to have been provided in `OrbinumClientConfig`.
|
|
468
|
+
*/
|
|
469
|
+
getEvmChainId(): Promise<number>;
|
|
470
|
+
/**
|
|
471
|
+
* Returns the current EVM block number.
|
|
472
|
+
*/
|
|
473
|
+
getEvmBlockNumber(): Promise<number>;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
type AddChainLinkParams = {
|
|
477
|
+
/** External chain ID. Use SLIP0044_NAMESPACE | coinType for SLIP-0044 chains. */
|
|
478
|
+
chainId: number;
|
|
479
|
+
/** The external address bytes (e.g. 20 bytes for EVM, 32 for Solana). */
|
|
480
|
+
address: Uint8Array;
|
|
481
|
+
/** Signature over the caller's AccountId32 (64 bytes for Ed25519, 65 for EIP-191). */
|
|
482
|
+
signature: Uint8Array;
|
|
483
|
+
};
|
|
484
|
+
type SetMetadataParams = {
|
|
485
|
+
displayName?: string | null;
|
|
486
|
+
bio?: string | null;
|
|
487
|
+
avatar?: string | null;
|
|
488
|
+
};
|
|
489
|
+
type PutOnSaleParams = {
|
|
490
|
+
price: bigint;
|
|
491
|
+
/** If true the sale becomes OTC (whitelist required). */
|
|
492
|
+
isPrivate: boolean;
|
|
493
|
+
};
|
|
494
|
+
type DispatchAsLinkedParams = {
|
|
495
|
+
/** Owner AccountId32 hex (0x-prefixed 64 chars). */
|
|
496
|
+
owner: string;
|
|
497
|
+
chainId: number;
|
|
498
|
+
address: Uint8Array;
|
|
499
|
+
/** Signature over the encoded call payload. */
|
|
500
|
+
signature: Uint8Array;
|
|
501
|
+
/** Encoded call bytes (SCALE). */
|
|
502
|
+
callData: Uint8Array;
|
|
503
|
+
};
|
|
504
|
+
/**
|
|
505
|
+
* Module for Orbinum pallet-account-mapping:
|
|
506
|
+
* - Query on-chain identity data (aliases, chain links, metadata, marketplace)
|
|
507
|
+
* - Submit identity management extrinsics
|
|
508
|
+
*
|
|
509
|
+
* All query methods return null/false on not-found or network errors.
|
|
510
|
+
*/
|
|
511
|
+
declare class AccountMappingModule {
|
|
512
|
+
private readonly substrate;
|
|
513
|
+
constructor(substrate: SubstrateClient);
|
|
514
|
+
/**
|
|
515
|
+
* Returns the explicitly mapped (or fallback) Substrate AccountId32 hex for
|
|
516
|
+
* an EVM address. `mapped` is set only when `map_account` was called.
|
|
517
|
+
* `fallback` is always the EeSuffix rule: `H160 ++ [0x00; 12]`.
|
|
518
|
+
*/
|
|
519
|
+
getAccountAddresses(accountId: string): Promise<{
|
|
520
|
+
mapped: string | null;
|
|
521
|
+
fallback: string | null;
|
|
522
|
+
}>;
|
|
523
|
+
/**
|
|
524
|
+
* Returns the explicitly mapped Substrate AccountId32 hex for a given EVM
|
|
525
|
+
* address, or null if no explicit mapping exists.
|
|
526
|
+
*/
|
|
527
|
+
getMappedAccount(evmAddress: string): Promise<string | null>;
|
|
528
|
+
/**
|
|
529
|
+
* Resolves "@alias" to basic info (owner, optional EVM address, link count).
|
|
530
|
+
* Accepts the alias with or without the leading "@".
|
|
531
|
+
*/
|
|
532
|
+
resolveAlias(alias: string): Promise<AliasInfo | null>;
|
|
533
|
+
/**
|
|
534
|
+
* Returns the alias registered for the given Substrate AccountId32 hex, or null.
|
|
535
|
+
*/
|
|
536
|
+
getAliasOf(accountId: string): Promise<string | null>;
|
|
537
|
+
/**
|
|
538
|
+
* Resolves "@alias" to its full identity: owner, EVM address, all public
|
|
539
|
+
* chain links, and profile metadata.
|
|
540
|
+
*/
|
|
541
|
+
resolveFullIdentity(alias: string): Promise<AliasFullIdentity | null>;
|
|
542
|
+
/**
|
|
543
|
+
* Returns the profile metadata for a given Substrate AccountId32 hex, or null.
|
|
544
|
+
*/
|
|
545
|
+
getAccountMetadata(accountId: string): Promise<AccountMetadata | null>;
|
|
546
|
+
/**
|
|
547
|
+
* Returns the owner AccountId32 hex of a verified multichain link, or null.
|
|
548
|
+
*/
|
|
549
|
+
getLinkOwner(chainId: number, address: string): Promise<string | null>;
|
|
550
|
+
/**
|
|
551
|
+
* Returns all blockchain networks supported for verified cross-chain links.
|
|
552
|
+
*/
|
|
553
|
+
getSupportedChains(): Promise<SupportedChain[]>;
|
|
554
|
+
/**
|
|
555
|
+
* Returns the private link commitments registered for an alias.
|
|
556
|
+
* Real addresses are never exposed. Returns null if the alias does not exist.
|
|
557
|
+
*/
|
|
558
|
+
getPrivateLinks(alias: string): Promise<PrivateLink[] | null>;
|
|
559
|
+
/**
|
|
560
|
+
* Returns true if the given commitment is registered as a private link for the alias.
|
|
561
|
+
*/
|
|
562
|
+
hasPrivateLink(alias: string, commitment: string): Promise<boolean>;
|
|
563
|
+
/**
|
|
564
|
+
* Returns listing info if the alias is currently for sale, or null.
|
|
565
|
+
*/
|
|
566
|
+
getListingInfo(alias: string): Promise<ListingInfo | null>;
|
|
567
|
+
/**
|
|
568
|
+
* Returns the alias and its listing if the given account currently has an
|
|
569
|
+
* alias listed for sale. Returns null otherwise.
|
|
570
|
+
*/
|
|
571
|
+
getAccountListing(accountId: string): Promise<AccountListing | null>;
|
|
572
|
+
/**
|
|
573
|
+
* Returns whether a specific buyer can purchase the given alias right now.
|
|
574
|
+
*/
|
|
575
|
+
canBuy(alias: string, buyerAccountId: string): Promise<boolean>;
|
|
576
|
+
/**
|
|
577
|
+
* Creates an explicit EVM → Substrate account mapping.
|
|
578
|
+
* Stores an explicit `MappedAccounts` entry for the caller's H160.
|
|
579
|
+
* Extrinsic: accountMapping.mapAccount()
|
|
580
|
+
*/
|
|
581
|
+
mapAccount(signer: PolkadotSigner): Promise<TxResult>;
|
|
582
|
+
/**
|
|
583
|
+
* Removes the EVM → Substrate mapping for the caller.
|
|
584
|
+
* Extrinsic: accountMapping.unmapAccount()
|
|
585
|
+
*/
|
|
586
|
+
unmapAccount(signer: PolkadotSigner): Promise<TxResult>;
|
|
587
|
+
/**
|
|
588
|
+
* Registers a unique @alias for the caller.
|
|
589
|
+
* Requires a deposit. The alias must be 3–32 ASCII lowercase alphanumeric chars + hyphens.
|
|
590
|
+
* Extrinsic: accountMapping.registerAlias(alias)
|
|
591
|
+
*/
|
|
592
|
+
registerAlias(alias: string, signer: PolkadotSigner): Promise<TxResult>;
|
|
593
|
+
/**
|
|
594
|
+
* Releases the caller's alias and recovers the deposit.
|
|
595
|
+
* Extrinsic: accountMapping.releaseAlias()
|
|
596
|
+
*/
|
|
597
|
+
releaseAlias(signer: PolkadotSigner): Promise<TxResult>;
|
|
598
|
+
/**
|
|
599
|
+
* Transfers the caller's alias to another account.
|
|
600
|
+
* Extrinsic: accountMapping.transferAlias(newOwner)
|
|
601
|
+
*/
|
|
602
|
+
transferAlias(newOwnerHex: string, signer: PolkadotSigner): Promise<TxResult>;
|
|
603
|
+
/**
|
|
604
|
+
* Adds a verified public link to an external-chain wallet.
|
|
605
|
+
*
|
|
606
|
+
* `params.signature` must be produced by the external wallet over the caller's
|
|
607
|
+
* AccountId32 bytes:
|
|
608
|
+
* - EIP-191 (EVM): sign(keccak256("\x19Ethereum Signed Message:\n32" + accountId32))
|
|
609
|
+
* - Ed25519 (Solana): sign(accountId32 bytes)
|
|
610
|
+
*
|
|
611
|
+
* Extrinsic: accountMapping.addChainLink(chainId, address, signature)
|
|
612
|
+
*/
|
|
613
|
+
addChainLink(params: AddChainLinkParams, signer: PolkadotSigner): Promise<TxResult>;
|
|
614
|
+
/**
|
|
615
|
+
* Removes the external-chain link for the given chain ID.
|
|
616
|
+
* Extrinsic: accountMapping.removeChainLink(chainId)
|
|
617
|
+
*/
|
|
618
|
+
removeChainLink(chainId: number, signer: PolkadotSigner): Promise<TxResult>;
|
|
619
|
+
/**
|
|
620
|
+
* Updates the caller's public profile metadata.
|
|
621
|
+
* Extrinsic: accountMapping.setAccountMetadata(displayName, bio, avatar)
|
|
622
|
+
*/
|
|
623
|
+
setAccountMetadata(params: SetMetadataParams, signer: PolkadotSigner): Promise<TxResult>;
|
|
624
|
+
/**
|
|
625
|
+
* Lists the caller's alias for sale on the alias marketplace.
|
|
626
|
+
* Extrinsic: accountMapping.putAliasOnSale(price, isPrivate)
|
|
627
|
+
*/
|
|
628
|
+
putAliasOnSale(params: PutOnSaleParams, signer: PolkadotSigner): Promise<TxResult>;
|
|
629
|
+
/**
|
|
630
|
+
* Cancels an active alias sale listing.
|
|
631
|
+
* Extrinsic: accountMapping.cancelSale()
|
|
632
|
+
*/
|
|
633
|
+
cancelSale(signer: PolkadotSigner): Promise<TxResult>;
|
|
634
|
+
/**
|
|
635
|
+
* Purchases an alias listed for sale.
|
|
636
|
+
* Extrinsic: accountMapping.buyAlias(alias)
|
|
637
|
+
*/
|
|
638
|
+
buyAlias(alias: string, signer: PolkadotSigner): Promise<TxResult>;
|
|
639
|
+
/**
|
|
640
|
+
* Dispatches an arbitrary call on behalf of a linked external-chain wallet.
|
|
641
|
+
*
|
|
642
|
+
* This is the "Universal Proxy" feature that allows EVM/Solana wallets to
|
|
643
|
+
* authorize on-chain actions without holding a Substrate private key.
|
|
644
|
+
*
|
|
645
|
+
* The relayer (who pays gas) calls this with the external wallet's signature
|
|
646
|
+
* over the encoded call payload and the owner's AccountId32.
|
|
647
|
+
*
|
|
648
|
+
* Extrinsic: accountMapping.dispatchAsLinkedAccount(owner, chainId, address, signature, call)
|
|
649
|
+
*/
|
|
650
|
+
dispatchAsLinkedAccount(params: DispatchAsLinkedParams, signer: PolkadotSigner): Promise<TxResult>;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Converts a Uint8Array or number[] to a 0x-prefixed lowercase hex string.
|
|
655
|
+
*/
|
|
656
|
+
declare function toHex(bytes: Uint8Array | number[]): string;
|
|
657
|
+
/**
|
|
658
|
+
* Decodes a hex string (with or without 0x prefix) to Uint8Array.
|
|
659
|
+
*/
|
|
660
|
+
declare function fromHex(hex: string): Uint8Array;
|
|
661
|
+
/**
|
|
662
|
+
* Ensures a hex string has the 0x prefix.
|
|
663
|
+
*/
|
|
664
|
+
declare function ensureHexPrefix(hex: string): string;
|
|
665
|
+
|
|
666
|
+
/** EVM transaction request passed to an `EvmSigner` callback. */
|
|
667
|
+
type EvmTxRequest = {
|
|
668
|
+
to: string;
|
|
669
|
+
data: string;
|
|
670
|
+
value?: bigint;
|
|
671
|
+
};
|
|
672
|
+
/**
|
|
673
|
+
* Callback that signs and submits an EVM transaction, returning the tx hash.
|
|
674
|
+
*
|
|
675
|
+
* MetaMask: `(tx) => window.ethereum.request({ method: 'eth_sendTransaction', params: [{ ...tx, from: account }] })`
|
|
676
|
+
* ethers: `(tx) => (await signer.sendTransaction({ to: tx.to, data: tx.data })).hash`
|
|
677
|
+
* viem: `(tx) => walletClient.sendTransaction({ to: tx.to, data: tx.data })`
|
|
678
|
+
*/
|
|
679
|
+
type EvmSigner = (tx: EvmTxRequest) => Promise<string>;
|
|
680
|
+
/**
|
|
681
|
+
* Bindings for the `ShieldedPoolPrecompile` at address `0x...0801`.
|
|
682
|
+
*
|
|
683
|
+
* This precompile wraps `pallet-shielded-pool` extrinsics and dispatches them
|
|
684
|
+
* on behalf of the EVM caller (resolved to an AccountId32 via
|
|
685
|
+
* `EeSuffixAddressMapping`). No Substrate signer is required — an EVM wallet
|
|
686
|
+
* is sufficient.
|
|
687
|
+
*
|
|
688
|
+
* ### Key benefit for apps
|
|
689
|
+
* EVM-only users (MetaMask, Phantom bridge via chain links, etc.) can shield,
|
|
690
|
+
* transfer, and unshield without ever needing a Polkadot extension.
|
|
691
|
+
*
|
|
692
|
+
* All write methods accept an `EvmSigner` callback so the module stays
|
|
693
|
+
* transport-agnostic. See `buildShieldCalldata` etc. if you only need the
|
|
694
|
+
* raw calldata for custom signing flows.
|
|
695
|
+
*/
|
|
696
|
+
declare class ShieldedPoolPrecompile {
|
|
697
|
+
private readonly evm;
|
|
698
|
+
private readonly addr;
|
|
699
|
+
constructor(evm: EvmClient);
|
|
700
|
+
/**
|
|
701
|
+
* Returns the ABI-encoded calldata for `shield(uint32, uint256, bytes32, bytes)`.
|
|
702
|
+
* Useful when you need to inspect or batch the calldata before sending.
|
|
703
|
+
*/
|
|
704
|
+
buildShieldCalldata(params: ShieldParams): string;
|
|
705
|
+
/**
|
|
706
|
+
* Deposits tokens into the shielded pool from an EVM transaction.
|
|
707
|
+
*
|
|
708
|
+
* The EVM caller's address is deterministically mapped to a Substrate
|
|
709
|
+
* AccountId32 (`H160 ++ [0x00; 12]`). The pool deducts from that account.
|
|
710
|
+
*
|
|
711
|
+
* Extrinsic: `shieldedPool.shield(assetId, amount, commitment, encryptedMemo)`
|
|
712
|
+
*/
|
|
713
|
+
shield(params: ShieldParams, signer: EvmSigner): Promise<string>;
|
|
714
|
+
/**
|
|
715
|
+
* Returns the ABI-encoded calldata for
|
|
716
|
+
* `privateTransfer(bytes, bytes32, bytes32[], bytes32[], bytes[])`.
|
|
717
|
+
*/
|
|
718
|
+
buildPrivateTransferCalldata(params: PrivateTransferParams): string;
|
|
719
|
+
/**
|
|
720
|
+
* Submits a private transfer within the shielded pool from an EVM transaction.
|
|
721
|
+
*
|
|
722
|
+
* The EVM caller identity is **irrelevant to the ZK proof** — the sender is
|
|
723
|
+
* hidden by design. Any EVM address (including a relayer) can submit a valid proof.
|
|
724
|
+
*
|
|
725
|
+
* Extrinsic: `shieldedPool.privateTransfer(proof, merkleRoot, nullifiers, commitments, memos)`
|
|
726
|
+
*/
|
|
727
|
+
privateTransfer(params: PrivateTransferParams, signer: EvmSigner): Promise<string>;
|
|
728
|
+
/**
|
|
729
|
+
* Params for an `unshield` call via the EVM precompile.
|
|
730
|
+
* The `recipient` is a full 32-byte AccountId32 (Substrate account or
|
|
731
|
+
* EeSuffix-derived: `H160 ++ [0x00; 12]`).
|
|
732
|
+
*/
|
|
733
|
+
buildUnshieldCalldata(params: UnshieldParams): string;
|
|
734
|
+
/**
|
|
735
|
+
* Withdraws tokens from the shielded pool to a recipient account.
|
|
736
|
+
*
|
|
737
|
+
* `params.recipientAddress` must be a 0x-prefixed 64-hex-char AccountId32.
|
|
738
|
+
* To send to an EVM address, use `evmToImplicitSubstrate(evmAddr)` from
|
|
739
|
+
* `@orbinum/sdk` to derive the AccountId32 first.
|
|
740
|
+
*
|
|
741
|
+
* Extrinsic: `shieldedPool.unshield(proof, merkleRoot, nullifier, assetId, amount, recipient)`
|
|
742
|
+
*/
|
|
743
|
+
unshield(params: UnshieldParams, signer: EvmSigner): Promise<string>;
|
|
744
|
+
/**
|
|
745
|
+
* Estimates the EVM gas for a `shield` call without submitting.
|
|
746
|
+
* Requires `from` to be set to the actual sender address.
|
|
747
|
+
*/
|
|
748
|
+
estimateShieldGas(params: ShieldParams, from: string): Promise<bigint>;
|
|
749
|
+
/**
|
|
750
|
+
* Estimates the EVM gas for a `privateTransfer` call.
|
|
751
|
+
*/
|
|
752
|
+
estimatePrivateTransferGas(params: PrivateTransferParams, from: string): Promise<bigint>;
|
|
753
|
+
/**
|
|
754
|
+
* Estimates the EVM gas for an `unshield` call.
|
|
755
|
+
*/
|
|
756
|
+
estimateUnshieldGas(params: UnshieldParams, from: string): Promise<bigint>;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
type ResolvedAlias = {
|
|
760
|
+
/** AccountId32 hex of the alias owner (as 0x-prefixed 20-byte EVM address). */
|
|
761
|
+
owner: string;
|
|
762
|
+
/** EVM address of the owner, or null if unset. */
|
|
763
|
+
evmAddress: string | null;
|
|
764
|
+
};
|
|
765
|
+
/**
|
|
766
|
+
* EVM bindings for `AccountMappingPrecompile` at address `0x...0800`.
|
|
767
|
+
*
|
|
768
|
+
* This precompile wraps `pallet-account-mapping` extrinsics and queries,
|
|
769
|
+
* allowing **EVM wallets** to manage their on-chain identity (aliases, chain
|
|
770
|
+
* links, metadata, marketplace) without a Substrate signer.
|
|
771
|
+
*
|
|
772
|
+
* ### Read-only calls
|
|
773
|
+
* Use `resolveAlias`, `getAliasOf`, `hasPrivateLink` to query state via
|
|
774
|
+
* `eth_call` — no signer required.
|
|
775
|
+
*
|
|
776
|
+
* ### Write calls
|
|
777
|
+
* Provide an `EvmSigner` callback. The EVM caller's address is mapped to its
|
|
778
|
+
* Substrate AccountId32 via `AddressMapping`.
|
|
779
|
+
*/
|
|
780
|
+
declare class AccountMappingPrecompile {
|
|
781
|
+
private readonly evm;
|
|
782
|
+
private readonly addr;
|
|
783
|
+
constructor(evm: EvmClient);
|
|
784
|
+
/**
|
|
785
|
+
* Resolves `@alias` to its owner EVM address (and optionally a secondary EVM address).
|
|
786
|
+
*
|
|
787
|
+
* Returns `(address owner, address evmAddress)` — two 32-byte ABI-encoded slots.
|
|
788
|
+
* `evmAddress` is zero-address (`0x000...0`) if the owner has no explicit EVM address.
|
|
789
|
+
*/
|
|
790
|
+
resolveAlias(alias: string): Promise<ResolvedAlias | null>;
|
|
791
|
+
/**
|
|
792
|
+
* Returns the alias registered for the given EVM address, or null.
|
|
793
|
+
* The precompile ABI encodes the alias as `bytes` (UTF-8).
|
|
794
|
+
*/
|
|
795
|
+
getAliasOf(evmAddress: string): Promise<string | null>;
|
|
796
|
+
/**
|
|
797
|
+
* Returns true if the given Poseidon commitment is registered as a private
|
|
798
|
+
* link for the given alias.
|
|
799
|
+
*/
|
|
800
|
+
hasPrivateLink(alias: string, commitment: string): Promise<boolean>;
|
|
801
|
+
/**
|
|
802
|
+
* Creates an explicit EVM → Substrate account mapping for the signer's address.
|
|
803
|
+
* Extrinsic: `accountMapping.mapAccount()`
|
|
804
|
+
*/
|
|
805
|
+
mapAccount(signer: EvmSigner): Promise<string>;
|
|
806
|
+
/**
|
|
807
|
+
* Removes the EVM → Substrate mapping for the signer's address.
|
|
808
|
+
* Extrinsic: `accountMapping.unmapAccount()`
|
|
809
|
+
*/
|
|
810
|
+
unmapAccount(signer: EvmSigner): Promise<string>;
|
|
811
|
+
/**
|
|
812
|
+
* Releases the signer's registered alias, recovering the deposit.
|
|
813
|
+
* Extrinsic: `accountMapping.releaseAlias()`
|
|
814
|
+
*/
|
|
815
|
+
releaseAlias(signer: EvmSigner): Promise<string>;
|
|
816
|
+
/**
|
|
817
|
+
* Cancels an active alias sale listing.
|
|
818
|
+
* Extrinsic: `accountMapping.cancelSale()`
|
|
819
|
+
*/
|
|
820
|
+
cancelSale(signer: EvmSigner): Promise<string>;
|
|
821
|
+
/**
|
|
822
|
+
* Registers a unique @alias for the signer's account.
|
|
823
|
+
* Requires a deposit. The alias must be 3–32 ASCII lowercase alphanumeric chars + hyphens.
|
|
824
|
+
* Extrinsic: `accountMapping.registerAlias(alias)`
|
|
825
|
+
*/
|
|
826
|
+
registerAlias(alias: string, signer: EvmSigner): Promise<string>;
|
|
827
|
+
/**
|
|
828
|
+
* Transfers the signer's alias to a new EVM `owner` address.
|
|
829
|
+
* Extrinsic: `accountMapping.transferAlias(newOwner)`
|
|
830
|
+
*/
|
|
831
|
+
transferAlias(newOwnerEvmAddress: string, signer: EvmSigner): Promise<string>;
|
|
832
|
+
/**
|
|
833
|
+
* Purchases an alias currently listed for sale.
|
|
834
|
+
* Extrinsic: `accountMapping.buyAlias(alias)`
|
|
835
|
+
*/
|
|
836
|
+
buyAlias(alias: string, signer: EvmSigner): Promise<string>;
|
|
837
|
+
/**
|
|
838
|
+
* Lists the signer's alias for sale on the alias marketplace.
|
|
839
|
+
*
|
|
840
|
+
* @param price Asking price in planck (ORB).
|
|
841
|
+
* @param allowedBuyers Whitelist of EVM addresses allowed to buy.
|
|
842
|
+
* Pass an empty array for a public (open) listing.
|
|
843
|
+
* Extrinsic: `accountMapping.putAliasOnSale(price, allowedBuyers)`
|
|
844
|
+
*/
|
|
845
|
+
putAliasOnSale(price: bigint, allowedBuyers: string[], signer: EvmSigner): Promise<string>;
|
|
846
|
+
/**
|
|
847
|
+
* Removes the external-chain link for the given chain ID.
|
|
848
|
+
* Extrinsic: `accountMapping.removeChainLink(chainId)`
|
|
849
|
+
*/
|
|
850
|
+
removeChainLink(chainId: number, signer: EvmSigner): Promise<string>;
|
|
851
|
+
/**
|
|
852
|
+
* Adds a verified public link to an external-chain wallet.
|
|
853
|
+
*
|
|
854
|
+
* @param chainId Orbinum chain ID (use `SLIP0044_NAMESPACE | coinType` for SLIP-0044).
|
|
855
|
+
* @param externalAddr External wallet address bytes (20 bytes for EVM, 32 for Solana).
|
|
856
|
+
* @param signature Signature over the caller's AccountId32:
|
|
857
|
+
* - EIP-191 (EVM): 65 bytes over keccak256("\x19Ethereum Signed Message:\n32" + accountId32)
|
|
858
|
+
* - Ed25519 (Solana): 64 bytes over the raw accountId32 bytes
|
|
859
|
+
*
|
|
860
|
+
* Extrinsic: `accountMapping.addChainLink(chainId, address, signature)`
|
|
861
|
+
*/
|
|
862
|
+
addChainLink(chainId: number, externalAddr: Uint8Array, signature: Uint8Array, signer: EvmSigner): Promise<string>;
|
|
863
|
+
/**
|
|
864
|
+
* Registers a private chain link — only the Poseidon commitment is stored.
|
|
865
|
+
* The real external address is never revealed on-chain.
|
|
866
|
+
*
|
|
867
|
+
* @param chainId External chain ID.
|
|
868
|
+
* @param commitment 0x-prefixed 32-byte Poseidon commitment hex.
|
|
869
|
+
*
|
|
870
|
+
* Extrinsic: `accountMapping.registerPrivateLink(chainId, commitment)`
|
|
871
|
+
*/
|
|
872
|
+
registerPrivateLink(chainId: number, commitment: string, signer: EvmSigner): Promise<string>;
|
|
873
|
+
/**
|
|
874
|
+
* Removes a private link by its commitment.
|
|
875
|
+
* Extrinsic: `accountMapping.removePrivateLink(commitment)`
|
|
876
|
+
*/
|
|
877
|
+
removePrivateLink(commitment: string, signer: EvmSigner): Promise<string>;
|
|
878
|
+
/**
|
|
879
|
+
* Reveals a private link publicly by providing the real address and blinding.
|
|
880
|
+
* After this call the link becomes a public chain link.
|
|
881
|
+
*
|
|
882
|
+
* @param commitment 32-byte commitment hex.
|
|
883
|
+
* @param address External address bytes (the actual wallet address).
|
|
884
|
+
* @param blinding 32-byte blinding factor used when computing the commitment.
|
|
885
|
+
* @param signature Signature over the AccountId32 bytes (same rules as `addChainLink`).
|
|
886
|
+
*
|
|
887
|
+
* Extrinsic: `accountMapping.revealPrivateLink(commitment, address, blinding, signature)`
|
|
888
|
+
*/
|
|
889
|
+
revealPrivateLink(commitment: string, address: Uint8Array, blinding: string, signature: Uint8Array, signer: EvmSigner): Promise<string>;
|
|
890
|
+
/**
|
|
891
|
+
* Updates the signer's public profile metadata.
|
|
892
|
+
* Pass `null` for any field to leave it unchanged.
|
|
893
|
+
*
|
|
894
|
+
* Extrinsic: `accountMapping.setAccountMetadata(displayName, bio, avatar)`
|
|
895
|
+
*/
|
|
896
|
+
setAccountMetadata(displayName: string | null, bio: string | null, avatar: string | null, signer: EvmSigner): Promise<string>;
|
|
897
|
+
/** Returns the raw ABI-encoded calldata for `registerAlias`. */
|
|
898
|
+
buildRegisterAliasCalldata(alias: string): string;
|
|
899
|
+
/** Returns the raw ABI-encoded calldata for `mapAccount`. */
|
|
900
|
+
buildMapAccountCalldata(): string;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Low-level bindings for cryptographic EVM precompiles.
|
|
905
|
+
*
|
|
906
|
+
* These precompiles use **raw input** (no ABI selector) and are called via
|
|
907
|
+
* `eth_call`. They are useful for on-chain-verified cryptographic operations,
|
|
908
|
+
* particularly `curve25519Add` and `curve25519ScalarMul` for Ristretto ZK math.
|
|
909
|
+
*
|
|
910
|
+
* Gas costs are deterministic but metered by the EVM; for off-chain operations
|
|
911
|
+
* prefer the `@noble/*` libraries directly.
|
|
912
|
+
*/
|
|
913
|
+
declare class CryptoPrecompiles {
|
|
914
|
+
private readonly evm;
|
|
915
|
+
constructor(evm: EvmClient);
|
|
916
|
+
/**
|
|
917
|
+
* Recovers the Ethereum address from an ECDSA signature.
|
|
918
|
+
*
|
|
919
|
+
* Classic Ethereum ECRecover (EIP-spec): input is always 128 bytes:
|
|
920
|
+
* hash(32) + v_padded(32, v=27 or 28) + r(32) + s(32)
|
|
921
|
+
*
|
|
922
|
+
* Returns a 0x-prefixed lowercase 20-byte EVM address.
|
|
923
|
+
*/
|
|
924
|
+
ecRecover(hash: Uint8Array, v: 27 | 28, r: Uint8Array, s: Uint8Array): Promise<string>;
|
|
925
|
+
/**
|
|
926
|
+
* Recovers the **full uncompressed public key** (64 bytes, no 0x04 prefix)
|
|
927
|
+
* from an ECDSA signature.
|
|
928
|
+
*
|
|
929
|
+
* Same input format as `ecRecover`. Output is 64 bytes (32-byte X + 32-byte Y).
|
|
930
|
+
*/
|
|
931
|
+
ecRecoverPublicKey(hash: Uint8Array, v: 27 | 28, r: Uint8Array, s: Uint8Array): Promise<Uint8Array>;
|
|
932
|
+
/**
|
|
933
|
+
* Computes SHA-256 of arbitrary bytes via EVM precompile.
|
|
934
|
+
* Returns a 32-byte digest.
|
|
935
|
+
*/
|
|
936
|
+
sha256(data: Uint8Array): Promise<Uint8Array>;
|
|
937
|
+
/**
|
|
938
|
+
* Computes RIPEMD-160 of arbitrary bytes via EVM precompile.
|
|
939
|
+
* Returns the 20-byte digest right-padded to 32 bytes (standard ABI output).
|
|
940
|
+
*/
|
|
941
|
+
ripemd160(data: Uint8Array): Promise<Uint8Array>;
|
|
942
|
+
/**
|
|
943
|
+
* Data copy via EVM precompile (identity). Returns the input unchanged.
|
|
944
|
+
* Mainly useful for gas benchmarking.
|
|
945
|
+
*/
|
|
946
|
+
identity(data: Uint8Array): Promise<Uint8Array>;
|
|
947
|
+
/**
|
|
948
|
+
* Computes Keccak-256 (= SHA3-FIPS-256 as used by Ethereum) of arbitrary bytes.
|
|
949
|
+
* Returns a 32-byte digest.
|
|
950
|
+
*/
|
|
951
|
+
keccak256(data: Uint8Array): Promise<Uint8Array>;
|
|
952
|
+
/**
|
|
953
|
+
* Adds up to 10 Ristretto (Curve25519) compressed points via EVM precompile.
|
|
954
|
+
*
|
|
955
|
+
* Input: N × 32-byte CompressedRistretto points concatenated (N ≤ 10).
|
|
956
|
+
* Output: 32-byte CompressedRistretto sum.
|
|
957
|
+
*
|
|
958
|
+
* Useful for ZK protocols that require verifiable Pedersen commitments.
|
|
959
|
+
*/
|
|
960
|
+
curve25519Add(points: Uint8Array[]): Promise<Uint8Array>;
|
|
961
|
+
/**
|
|
962
|
+
* Multiplies a Ristretto compressed point by a scalar via EVM precompile.
|
|
963
|
+
*
|
|
964
|
+
* Input: 32-byte scalar (little-endian) + 32-byte CompressedRistretto point.
|
|
965
|
+
* Output: 32-byte CompressedRistretto result.
|
|
966
|
+
*
|
|
967
|
+
* Useful for computing key images and Pedersen commitments in ZK protocols.
|
|
968
|
+
*/
|
|
969
|
+
curve25519ScalarMul(scalar: Uint8Array, point: Uint8Array): Promise<Uint8Array>;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* Main entry point for the Orbinum TypeScript SDK.
|
|
974
|
+
*
|
|
975
|
+
* Connects to an Orbinum node and exposes all protocol modules.
|
|
976
|
+
*
|
|
977
|
+
* @example
|
|
978
|
+
* ```ts
|
|
979
|
+
* import { OrbinumClient } from '@orbinum/sdk';
|
|
980
|
+
*
|
|
981
|
+
* const client = await OrbinumClient.connect({
|
|
982
|
+
* substrateWs: 'ws://localhost:9944',
|
|
983
|
+
* evmRpc: 'http://localhost:9933',
|
|
984
|
+
* });
|
|
985
|
+
*
|
|
986
|
+
* // Query Merkle tree
|
|
987
|
+
* const info = await client.shieldedPool.merkle.getTreeInfo();
|
|
988
|
+
* console.log('root:', info.root, 'nodes:', info.treeSize);
|
|
989
|
+
*
|
|
990
|
+
* // Shield tokens (with a PolkadotSigner)
|
|
991
|
+
* const result = await client.shieldedPool.shield(
|
|
992
|
+
* { assetId: 1, amount: 1000n, commitment: '0xabc...' },
|
|
993
|
+
* signer,
|
|
994
|
+
* );
|
|
995
|
+
* console.log('tx ok:', result.ok, 'block:', result.blockHash);
|
|
996
|
+
*
|
|
997
|
+
* client.destroy();
|
|
998
|
+
* ```
|
|
999
|
+
*/
|
|
1000
|
+
declare class OrbinumClient {
|
|
1001
|
+
/** Raw access to the Substrate WebSocket connection and RPC. */
|
|
1002
|
+
readonly substrate: SubstrateClient;
|
|
1003
|
+
/** Raw access to the EVM HTTP JSON-RPC endpoint (if configured). */
|
|
1004
|
+
readonly evm: EvmClient | null;
|
|
1005
|
+
/** Shielded-pool operations: shield, unshield, privateTransfer, and merkle queries. */
|
|
1006
|
+
readonly shieldedPool: ShieldedPoolModule;
|
|
1007
|
+
/** General chain queries: node info, identity resolution. */
|
|
1008
|
+
readonly chain: ChainModule;
|
|
1009
|
+
/** Account mapping: aliases, chain links, metadata, marketplace, and identity extrinsics. */
|
|
1010
|
+
readonly accountMapping: AccountMappingModule;
|
|
1011
|
+
/**
|
|
1012
|
+
* EVM precompiles: shielded pool + account mapping callable from an EVM wallet.
|
|
1013
|
+
* Only available when `evmRpc` is configured. Methods throw if `evm` is null.
|
|
1014
|
+
*/
|
|
1015
|
+
readonly precompiles: {
|
|
1016
|
+
/** `ShieldedPoolPrecompile` (0x0801): shield/unshield/transfer via EVM wallet. */
|
|
1017
|
+
shieldedPool: ShieldedPoolPrecompile;
|
|
1018
|
+
/** `AccountMappingPrecompile` (0x0800): identity management via EVM wallet. */
|
|
1019
|
+
accountMapping: AccountMappingPrecompile;
|
|
1020
|
+
/** Cryptographic precompiles: ECRecover, Keccak-256, Curve25519. */
|
|
1021
|
+
crypto: CryptoPrecompiles;
|
|
1022
|
+
} | null;
|
|
1023
|
+
private constructor();
|
|
1024
|
+
/**
|
|
1025
|
+
* Connects to an Orbinum node and returns a ready-to-use `OrbinumClient`.
|
|
1026
|
+
* Throws if the Substrate node is unreachable within `connectTimeoutMs`.
|
|
1027
|
+
*/
|
|
1028
|
+
static connect(config: OrbinumClientConfig): Promise<OrbinumClient>;
|
|
1029
|
+
/**
|
|
1030
|
+
* Convenience getter for the Merkle module (shortcut for `shieldedPool.merkle`).
|
|
1031
|
+
*/
|
|
1032
|
+
get merkle(): MerkleModule;
|
|
1033
|
+
/** Closes the WebSocket connection to the Substrate node. */
|
|
1034
|
+
destroy(): void;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* Builds ZK notes (commitment + nullifier) and encrypted memos locally.
|
|
1039
|
+
*
|
|
1040
|
+
* All computation is off-chain — no network calls are made.
|
|
1041
|
+
*
|
|
1042
|
+
* Hash scheme (Poseidon, circomlibjs):
|
|
1043
|
+
* commitment = Poseidon(value, assetId, ownerPk, blinding)
|
|
1044
|
+
* nullifier = Poseidon(commitment, spendingKey)
|
|
1045
|
+
*
|
|
1046
|
+
* Memo scheme (EncryptedMemo — native TypeScript, no WASM):
|
|
1047
|
+
* ChaCha20-Poly1305 with key = SHA256(recipientVk || commitment || domain)
|
|
1048
|
+
* Result: nonce(12) || ciphertext(76 + 16 MAC) = 104 bytes
|
|
1049
|
+
*/
|
|
1050
|
+
declare class NoteBuilder {
|
|
1051
|
+
/**
|
|
1052
|
+
* Build a ZkNote from the given inputs.
|
|
1053
|
+
*
|
|
1054
|
+
* @param input.value Amount in planck (required).
|
|
1055
|
+
* @param input.assetId Asset ID — default 0n (native ORB-Privacy).
|
|
1056
|
+
* @param input.ownerPk BabyJubJub Ax — default 0n.
|
|
1057
|
+
* @param input.blinding Random scalar — defaults to BigInt(Date.now()).
|
|
1058
|
+
* @param input.spendingKey Secret key for nullifier — default 0n.
|
|
1059
|
+
*/
|
|
1060
|
+
static build(input: NoteInput): Promise<ZkNote>;
|
|
1061
|
+
/**
|
|
1062
|
+
* Build the 104-byte encrypted memo for a note.
|
|
1063
|
+
*
|
|
1064
|
+
* Pure TypeScript implementation — no WASM dependency.
|
|
1065
|
+
* Uses ChaCha20-Poly1305 with SHA-256 key derivation.
|
|
1066
|
+
*
|
|
1067
|
+
* @param note The ZkNote whose fields populate the plaintext.
|
|
1068
|
+
* @param recipientVk 32-byte recipient viewing key.
|
|
1069
|
+
* Pass `new Uint8Array(32)` (default) for a public/dummy memo.
|
|
1070
|
+
*/
|
|
1071
|
+
static buildMemo(note: ZkNote, recipientVk?: Uint8Array): Uint8Array;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* EncryptedMemo — TypeScript implementation of Orbinum's encrypted note memo.
|
|
1076
|
+
*
|
|
1077
|
+
* Mirrors primitives/encrypted-memo in the node repository; no WASM required.
|
|
1078
|
+
*
|
|
1079
|
+
* Layout (104 bytes):
|
|
1080
|
+
* nonce(12) || ciphertext(76 + 16 MAC) = 104
|
|
1081
|
+
*
|
|
1082
|
+
* Plaintext layout (76 bytes):
|
|
1083
|
+
* value(8 LE) || owner_pk(32) || blinding(32) || asset_id(4 LE)
|
|
1084
|
+
*
|
|
1085
|
+
* Key derivation:
|
|
1086
|
+
* key = SHA256(viewing_key || commitment || "orbinum-note-encryption-v1")
|
|
1087
|
+
*
|
|
1088
|
+
* Cipher: ChaCha20-Poly1305 (IETF, 96-bit nonce)
|
|
1089
|
+
*/
|
|
1090
|
+
/** Fields recovered from a successfully decrypted EncryptedMemo. */
|
|
1091
|
+
type DecryptedMemo = {
|
|
1092
|
+
value: bigint;
|
|
1093
|
+
ownerPk: bigint;
|
|
1094
|
+
blinding: bigint;
|
|
1095
|
+
assetId: bigint;
|
|
1096
|
+
};
|
|
1097
|
+
declare const EncryptedMemo: {
|
|
1098
|
+
/**
|
|
1099
|
+
* Build and encrypt a memo for a note.
|
|
1100
|
+
*
|
|
1101
|
+
* @param value Note value in planck.
|
|
1102
|
+
* @param ownerPk 32-byte owner public key (little-endian).
|
|
1103
|
+
* @param blinding 32-byte blinding scalar (little-endian).
|
|
1104
|
+
* @param assetId Asset identifier.
|
|
1105
|
+
* @param commitment 32-byte commitment bytes (little-endian).
|
|
1106
|
+
* @param recipientVk 32-byte recipient viewing key — pass `new Uint8Array(32)`
|
|
1107
|
+
* for a publicly-readable (dummy) memo.
|
|
1108
|
+
* @returns 104-byte encrypted memo (nonce || ciphertext).
|
|
1109
|
+
*/
|
|
1110
|
+
encrypt(value: bigint, ownerPk: Uint8Array, blinding: Uint8Array, assetId: number, commitment: Uint8Array, recipientVk: Uint8Array): Uint8Array;
|
|
1111
|
+
/**
|
|
1112
|
+
* Returns a 104-byte public memo with a zero recipient viewing key.
|
|
1113
|
+
* The memo is still readable by anyone who holds the viewing key (zeros).
|
|
1114
|
+
*/
|
|
1115
|
+
encryptPublic(value: bigint, ownerPk: Uint8Array, blinding: Uint8Array, assetId: number, commitment: Uint8Array): Uint8Array;
|
|
1116
|
+
/**
|
|
1117
|
+
* Returns a 104-byte zeroed dummy memo (no information, always valid on-chain).
|
|
1118
|
+
*/
|
|
1119
|
+
dummy(): Uint8Array;
|
|
1120
|
+
/**
|
|
1121
|
+
* Decrypt an on-chain EncryptedMemo.
|
|
1122
|
+
*
|
|
1123
|
+
* Returns `null` if decryption fails — wrong key, bad MAC, or malformed memo.
|
|
1124
|
+
* Never throws; safe for scan loops.
|
|
1125
|
+
*
|
|
1126
|
+
* @param memoBytes 104-byte encrypted memo.
|
|
1127
|
+
* @param commitment 32-byte note commitment (little-endian).
|
|
1128
|
+
* @param recipientVk 32-byte recipient viewing key.
|
|
1129
|
+
*/
|
|
1130
|
+
decrypt(memoBytes: Uint8Array, commitment: Uint8Array, recipientVk: Uint8Array): DecryptedMemo | null;
|
|
1131
|
+
};
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* NoteDecryptor
|
|
1135
|
+
*
|
|
1136
|
+
* Core logic for decrypting on-chain commitments during a shielded pool scan.
|
|
1137
|
+
* For each commitment, attempts to decrypt the encryptedMemo with the viewer's
|
|
1138
|
+
* viewing key, then verifies the recomputed commitment matches the on-chain value.
|
|
1139
|
+
*
|
|
1140
|
+
* This is protocol-level logic — independent of indexer, storage, or UI.
|
|
1141
|
+
* Consume via scan loops in application code.
|
|
1142
|
+
*
|
|
1143
|
+
* Hash scheme (Poseidon BN254, poseidon-lite):
|
|
1144
|
+
* commitment = Poseidon4(value, assetId, ownerPk, blinding)
|
|
1145
|
+
* nullifier = Poseidon2(commitment, spendingKey)
|
|
1146
|
+
*/
|
|
1147
|
+
|
|
1148
|
+
/** A single commitment record as returned by the indexer. */
|
|
1149
|
+
interface ScanCommitment {
|
|
1150
|
+
commitmentHex: string;
|
|
1151
|
+
leafIndex: number;
|
|
1152
|
+
encryptedMemo: string | null;
|
|
1153
|
+
}
|
|
1154
|
+
/**
|
|
1155
|
+
* Attempt to decrypt an on-chain commitment using a viewing key.
|
|
1156
|
+
*
|
|
1157
|
+
* Returns a fully populated ZkNote if the memo decrypts correctly and the
|
|
1158
|
+
* recomputed commitment matches the on-chain value.
|
|
1159
|
+
* Returns null when the note does not belong to this viewer (wrong key, no memo,
|
|
1160
|
+
* or commitment mismatch).
|
|
1161
|
+
*
|
|
1162
|
+
* @param commitment On-chain commitment record from the indexer.
|
|
1163
|
+
* @param viewingKey 32-byte viewing key (from deriveViewingKey).
|
|
1164
|
+
* @param spendingKey Spending key bigint (for nullifier computation).
|
|
1165
|
+
*/
|
|
1166
|
+
declare function tryDecryptNote(commitment: ScanCommitment, viewingKey: Uint8Array, spendingKey: bigint): ZkNote | null;
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* PrivacyKeys
|
|
1170
|
+
*
|
|
1171
|
+
* Pure cryptographic derivation functions for the Orbinum shielded pool identity.
|
|
1172
|
+
* These are protocol-level operations — independent of storage, UI, or session.
|
|
1173
|
+
*
|
|
1174
|
+
* Derivation scheme:
|
|
1175
|
+
* viewingKey = HKDF-SHA256(ikm=spendingKey_bytes, info="orbinum-ivk-v1") → 32 bytes
|
|
1176
|
+
* ownerPk = BabyJubJub Ax from (spendingKey * Base8) → bigint
|
|
1177
|
+
*
|
|
1178
|
+
* Spending key derivation (from wallet signature):
|
|
1179
|
+
* message = "orbinum-spending-key-v1\n${chainId}\n${address.toLowerCase()}"
|
|
1180
|
+
* skBytes = HKDF-SHA256(ikm=sig_bytes, salt=empty, info="orbinum-sk-v1:${chainId}:${address}")
|
|
1181
|
+
* spendingKey = BigInt(skBytes_as_big_endian) % BN254_R (if 0 → 1)
|
|
1182
|
+
*
|
|
1183
|
+
* The viewingKey is the symmetric key used by EncryptedMemo (ChaCha20-Poly1305).
|
|
1184
|
+
* The ownerPk (x-coordinate) is included in note commitments.
|
|
1185
|
+
*/
|
|
1186
|
+
/**
|
|
1187
|
+
* Returns the message string the user must sign with their wallet to derive
|
|
1188
|
+
* a deterministic Orbinum spending key.
|
|
1189
|
+
*/
|
|
1190
|
+
declare function deriveSpendingKeyMessage(chainId: number, address: string): string;
|
|
1191
|
+
/**
|
|
1192
|
+
* Derives an Orbinum spending key from a wallet signature.
|
|
1193
|
+
*
|
|
1194
|
+
* Uses HKDF-SHA256(ikm=sigBytes, salt=empty, info="orbinum-sk-v1:{chainId}:{address}")
|
|
1195
|
+
* and reduces the resulting 32-byte value modulo BN254_R.
|
|
1196
|
+
*
|
|
1197
|
+
* @param signatureHex 0x-prefixed or bare hex of the wallet signature.
|
|
1198
|
+
* @param chainId Chain ID used when building the signing message.
|
|
1199
|
+
* @param address Signer address (EVM or SS58) used in the signing message.
|
|
1200
|
+
* @returns bigint in [1, BN254_R)
|
|
1201
|
+
*/
|
|
1202
|
+
declare function deriveSpendingKeyFromSignature(signatureHex: string, chainId: number, address: string): Promise<bigint>;
|
|
1203
|
+
/**
|
|
1204
|
+
* Derive a 32-byte viewing key from a spending key.
|
|
1205
|
+
* viewingKey = HKDF-SHA256(ikm=spendingKey_bytes, info="orbinum-ivk-v1")
|
|
1206
|
+
*/
|
|
1207
|
+
declare function deriveViewingKey(spendingKey: bigint): Uint8Array;
|
|
1208
|
+
/**
|
|
1209
|
+
* Derive the BabyJubJub Ax (x-coordinate of the public key) from a spending key.
|
|
1210
|
+
* ownerPk = (spendingKey * BabyJubJub.Base8)[0]
|
|
1211
|
+
*
|
|
1212
|
+
* Returns 0n if BabyJubJub computation fails (e.g. invalid scalar).
|
|
1213
|
+
*/
|
|
1214
|
+
declare function deriveOwnerPk(spendingKey: bigint): bigint;
|
|
1215
|
+
|
|
1216
|
+
/**
|
|
1217
|
+
* PrivacyKeyManager
|
|
1218
|
+
*
|
|
1219
|
+
* In-memory manager for the user's Orbinum shielded-pool identity.
|
|
1220
|
+
* Protocol-level module — no UI, no localStorage, no sessionStorage dependencies.
|
|
1221
|
+
*
|
|
1222
|
+
* Call `PrivacyKeyManager.load(spendingKey)` after deriving the key from a wallet
|
|
1223
|
+
* signature (see `deriveSpendingKeyFromSignature`). The caller (application layer)
|
|
1224
|
+
* is responsible for key persistence and session caching.
|
|
1225
|
+
*
|
|
1226
|
+
* Derivation scheme:
|
|
1227
|
+
* spendingKey (bigint, BN254 scalar)
|
|
1228
|
+
* └── viewingKey = HKDF-SHA256(spendingKey_bytes, info="orbinum-ivk-v1") → 32 bytes
|
|
1229
|
+
* └── ownerPk = BabyJubJub Ax from (spendingKey * Base8) → bigint
|
|
1230
|
+
*/
|
|
1231
|
+
declare const PrivacyKeyManager: {
|
|
1232
|
+
/**
|
|
1233
|
+
* Load a spending key into the in-memory session.
|
|
1234
|
+
* Derives viewingKey and ownerPk immediately.
|
|
1235
|
+
* Replaces any previously loaded key.
|
|
1236
|
+
*/
|
|
1237
|
+
load(spendingKey: bigint): Promise<void>;
|
|
1238
|
+
/** Clear all key material from memory. Call on vault lock / sign-out. */
|
|
1239
|
+
clear(): void;
|
|
1240
|
+
/** Returns true if a spending key has been loaded. */
|
|
1241
|
+
isLoaded(): boolean;
|
|
1242
|
+
/** Returns the spending key. Throws if not loaded. */
|
|
1243
|
+
getSpendingKey(): bigint;
|
|
1244
|
+
/** Returns the 32-byte viewing key. Throws if not loaded. */
|
|
1245
|
+
getViewingKey(): Uint8Array;
|
|
1246
|
+
/** Returns the BabyJubJub owner public key (x-coordinate). Throws if not loaded. */
|
|
1247
|
+
getOwnerPk(): bigint;
|
|
1248
|
+
/** Returns the spending key as a 32-byte little-endian Uint8Array. Throws if not loaded. */
|
|
1249
|
+
getSpendingKeyBytes(): Uint8Array;
|
|
1250
|
+
/** Exports the spending key as a 0x-prefixed 64-char hex string. Throws if not loaded. */
|
|
1251
|
+
exportHex(): string;
|
|
1252
|
+
/**
|
|
1253
|
+
* Load a spending key from a 0x-prefixed or bare hex string.
|
|
1254
|
+
* Validates the key is in the valid range [1, BN254_R).
|
|
1255
|
+
*/
|
|
1256
|
+
importFromHex(hex: string): Promise<void>;
|
|
1257
|
+
};
|
|
1258
|
+
|
|
1259
|
+
/**
|
|
1260
|
+
* VaultCrypto
|
|
1261
|
+
*
|
|
1262
|
+
* WebCrypto-based encryption utilities for protecting Orbinum vault data.
|
|
1263
|
+
* Works in browser and Node.js 18+ (both expose the WebCrypto API as `crypto`).
|
|
1264
|
+
* Pure functions — no state, no side effects.
|
|
1265
|
+
*
|
|
1266
|
+
* Key derivation: HKDF-SHA-256(ikm=spendingKeyBytes, salt=empty, info="orbinum-vault-key-v1")
|
|
1267
|
+
* Cipher: AES-GCM 256
|
|
1268
|
+
*
|
|
1269
|
+
* BigInt serialisation uses `{ __bigint: "<decimal string>" }` so plain
|
|
1270
|
+
* `JSON.stringify` never receives a bigint. Use `vaultReplacer` / `vaultReviver`
|
|
1271
|
+
* for all vault payloads.
|
|
1272
|
+
*/
|
|
1273
|
+
/**
|
|
1274
|
+
* `JSON.stringify` replacer that serialises bigint values as
|
|
1275
|
+
* `{ __bigint: "<decimal string>" }` (JSON-safe).
|
|
1276
|
+
*/
|
|
1277
|
+
declare function vaultReplacer(_key: string, value: unknown): unknown;
|
|
1278
|
+
/**
|
|
1279
|
+
* `JSON.parse` reviver that deserialises `{ __bigint: "<decimal string>" }`
|
|
1280
|
+
* back into native bigint values.
|
|
1281
|
+
*/
|
|
1282
|
+
declare function vaultReviver(_key: string, value: unknown): unknown;
|
|
1283
|
+
/**
|
|
1284
|
+
* Derives an AES-GCM-256 CryptoKey from spending key bytes using HKDF-SHA-256.
|
|
1285
|
+
* The spending key carries ≥256 bits of entropy so no salt / iteration
|
|
1286
|
+
* stretching is required.
|
|
1287
|
+
*
|
|
1288
|
+
* @param spendingKeyBytes 32-byte spending key (little-endian bigint representation).
|
|
1289
|
+
*/
|
|
1290
|
+
declare function deriveVaultKey(spendingKeyBytes: Uint8Array): Promise<CryptoKey>;
|
|
1291
|
+
/**
|
|
1292
|
+
* Serialises `payload` to JSON (bigint-safe) and encrypts it with AES-GCM.
|
|
1293
|
+
* Returns base64-encoded `iv` and `ciphertext`.
|
|
1294
|
+
*/
|
|
1295
|
+
declare function encryptJson(key: CryptoKey, payload: unknown): Promise<{
|
|
1296
|
+
iv: string;
|
|
1297
|
+
ciphertext: string;
|
|
1298
|
+
}>;
|
|
1299
|
+
/**
|
|
1300
|
+
* Decrypts AES-GCM ciphertext and parses the JSON payload (bigint-safe).
|
|
1301
|
+
* Throws `DOMException` on authentication failure (wrong key or corrupted data).
|
|
1302
|
+
*/
|
|
1303
|
+
declare function decryptJson(key: CryptoKey, iv: string, ciphertext: string): Promise<unknown>;
|
|
1304
|
+
|
|
1305
|
+
/**
|
|
1306
|
+
* Contract addresses and function selectors for all Orbinum EVM precompiles.
|
|
1307
|
+
*
|
|
1308
|
+
* Selectors are verified against the Rust source in frame/evm/precompile and
|
|
1309
|
+
* computed as `bytes4(keccak256("<functionName>(<argTypes>)"))`.
|
|
1310
|
+
*/
|
|
1311
|
+
/** All precompile contract addresses. */
|
|
1312
|
+
declare const PRECOMPILE_ADDR: {
|
|
1313
|
+
readonly EC_RECOVER: "0x0000000000000000000000000000000000000001";
|
|
1314
|
+
readonly SHA256: "0x0000000000000000000000000000000000000002";
|
|
1315
|
+
readonly RIPEMD160: "0x0000000000000000000000000000000000000003";
|
|
1316
|
+
readonly IDENTITY: "0x0000000000000000000000000000000000000004";
|
|
1317
|
+
readonly MODEXP: "0x0000000000000000000000000000000000000005";
|
|
1318
|
+
readonly SHA3_FIPS256: "0x0000000000000000000000000000000000000400";
|
|
1319
|
+
readonly EC_RECOVER_PUBKEY: "0x0000000000000000000000000000000000000401";
|
|
1320
|
+
readonly CURVE25519_ADD: "0x0000000000000000000000000000000000000402";
|
|
1321
|
+
readonly CURVE25519_SCALAR_MUL: "0x0000000000000000000000000000000000000403";
|
|
1322
|
+
readonly ACCOUNT_MAPPING: "0x0000000000000000000000000000000000000800";
|
|
1323
|
+
readonly SHIELDED_POOL: "0x0000000000000000000000000000000000000801";
|
|
1324
|
+
};
|
|
1325
|
+
|
|
1326
|
+
/**
|
|
1327
|
+
* Serialises a bigint as a 32-byte little-endian Uint8Array.
|
|
1328
|
+
*/
|
|
1329
|
+
declare function bigintTo32Le(n: bigint): Uint8Array;
|
|
1330
|
+
/**
|
|
1331
|
+
* Deserialises a Uint8Array as a little-endian unsigned bigint.
|
|
1332
|
+
*/
|
|
1333
|
+
declare function bytesToBigintLE(bytes: Uint8Array): bigint;
|
|
1334
|
+
/**
|
|
1335
|
+
* Serialises a bigint as a 32-byte big-endian Uint8Array.
|
|
1336
|
+
*/
|
|
1337
|
+
declare function bigintTo32Be(n: bigint): Uint8Array;
|
|
1338
|
+
/**
|
|
1339
|
+
* Serialises a bigint as a 32-element little-endian number[].
|
|
1340
|
+
* Useful when building SCALE-encoded arguments via polkadot-api.
|
|
1341
|
+
*/
|
|
1342
|
+
declare function bigintTo32LeArr(n: bigint): number[];
|
|
1343
|
+
/**
|
|
1344
|
+
* Computes the Merkle path direction bits for a leaf at `leafIndex`
|
|
1345
|
+
* in a binary Merkle tree of `depth` levels.
|
|
1346
|
+
* bit 0 = bottom level (leaf), bit depth-1 = top level (root sibling).
|
|
1347
|
+
*/
|
|
1348
|
+
declare function computePathIndices(leafIndex: number, depth: number): number[];
|
|
1349
|
+
/**
|
|
1350
|
+
* Decodes a little-endian hex string (0x-prefixed or bare) to a bigint.
|
|
1351
|
+
* Equivalent to `bytesToBigintLE(fromHex(hex))`.
|
|
1352
|
+
*/
|
|
1353
|
+
declare function leHexToBigint(hex: string): bigint;
|
|
1354
|
+
|
|
1355
|
+
/**
|
|
1356
|
+
* Normalises an EVM address to lowercase with 0x prefix.
|
|
1357
|
+
*/
|
|
1358
|
+
declare function normalizeEvmAddress(addr: string): string;
|
|
1359
|
+
/**
|
|
1360
|
+
* Returns true if the string looks like an SS58 encoded address
|
|
1361
|
+
* (not a 0x-prefixed hex).
|
|
1362
|
+
*/
|
|
1363
|
+
declare function isSs58(addr: string): boolean;
|
|
1364
|
+
/**
|
|
1365
|
+
* Returns true if the string looks like a 20-byte EVM address.
|
|
1366
|
+
*/
|
|
1367
|
+
declare function isEvmAddress(addr: string): boolean;
|
|
1368
|
+
/**
|
|
1369
|
+
* Pads a 20-byte EVM address to a 32-byte account ID (H256)
|
|
1370
|
+
* by prepending 12 zero bytes (Ethereum-compatible mapping).
|
|
1371
|
+
*/
|
|
1372
|
+
declare function evmAddressToAccountId(evmAddr: string): Uint8Array;
|
|
1373
|
+
/**
|
|
1374
|
+
* Derives the implicit Substrate AccountId32 for an EVM address using the
|
|
1375
|
+
* EeSuffixAddressMapping rule: AccountId32 = H160 ++ [0x00; 12].
|
|
1376
|
+
*
|
|
1377
|
+
* This is the same rule applied by pallet-account-mapping's fallback when
|
|
1378
|
+
* there is no explicit `map_account` entry. Returns 0x-prefixed 64-char hex.
|
|
1379
|
+
*
|
|
1380
|
+
* @param evmAddr 0x-prefixed 20-byte EVM address.
|
|
1381
|
+
*/
|
|
1382
|
+
declare function evmToImplicitSubstrate(evmAddr: string): string;
|
|
1383
|
+
/**
|
|
1384
|
+
* Returns true if the given AccountId32 hex was derived from an EVM address
|
|
1385
|
+
* via the EeSuffixAddressMapping (last 12 bytes are zero).
|
|
1386
|
+
*
|
|
1387
|
+
* @param accountHex 0x-prefixed 64-char AccountId32 hex.
|
|
1388
|
+
*/
|
|
1389
|
+
declare function isImplicitEvmAccount(accountHex: string): boolean;
|
|
1390
|
+
/**
|
|
1391
|
+
* Extracts the EVM address (H160) from an implicit Substrate AccountId32
|
|
1392
|
+
* created by EeSuffixAddressMapping. Throws if the account is not EVM-derived.
|
|
1393
|
+
*
|
|
1394
|
+
* @param accountHex 0x-prefixed 64-char AccountId32 hex.
|
|
1395
|
+
*/
|
|
1396
|
+
declare function implicitSubstrateToEvm(accountHex: string): string;
|
|
1397
|
+
/**
|
|
1398
|
+
* Returns true if `addr` is a valid SS58 substrate address (not EVM).
|
|
1399
|
+
*/
|
|
1400
|
+
declare function isSubstrateAddress(addr: string): boolean;
|
|
1401
|
+
/**
|
|
1402
|
+
* Returns true if `addr` is a Substrate SS58 address derived from an EVM H160
|
|
1403
|
+
* via the EeSuffixAddressMapping rule (last 12 bytes of AccountId are zero).
|
|
1404
|
+
*/
|
|
1405
|
+
declare function isUnifiedAddress(addr: string): boolean;
|
|
1406
|
+
/**
|
|
1407
|
+
* Converts a unified (EVM-derived) Substrate SS58 address to its EVM H160.
|
|
1408
|
+
* Returns null for native Substrate accounts or invalid input.
|
|
1409
|
+
*/
|
|
1410
|
+
declare function substrateToEvm(addr: string): string | null;
|
|
1411
|
+
/**
|
|
1412
|
+
* Converts an EVM H160 address to its Substrate SS58 equivalent
|
|
1413
|
+
* using the EeSuffixAddressMapping rule: AccountId32 = H160 ++ [0x00; 12].
|
|
1414
|
+
* Returns null on invalid input.
|
|
1415
|
+
*/
|
|
1416
|
+
declare function evmToSubstrate(addr: string): string | null;
|
|
1417
|
+
/**
|
|
1418
|
+
* Converts a 32-byte AccountId hex (0x-prefixed or bare) to its SS58 string.
|
|
1419
|
+
* Returns null on invalid input.
|
|
1420
|
+
*/
|
|
1421
|
+
declare function accountIdHexToSs58(hex: string): string | null;
|
|
1422
|
+
/**
|
|
1423
|
+
* Converts a Substrate SS58 address to its AccountId32 as a 0x-prefixed 64-char hex.
|
|
1424
|
+
* Returns null on invalid input.
|
|
1425
|
+
*/
|
|
1426
|
+
declare function substrateSs58ToAccountIdHex(addr: string): string | null;
|
|
1427
|
+
/**
|
|
1428
|
+
* Universal converter: given any raw address string (SS58, 0x-prefixed 64-char
|
|
1429
|
+
* AccountId hex, or EVM H160), returns the AccountId32 hex (0x-prefixed).
|
|
1430
|
+
* Returns null on unrecognised input.
|
|
1431
|
+
*/
|
|
1432
|
+
declare function addressToAccountIdHex(addr: string): string | null;
|
|
1433
|
+
|
|
1434
|
+
/**
|
|
1435
|
+
* Types for the arguments passed to pallet-shielded-pool extrinsics.
|
|
1436
|
+
* Byte arrays are represented as `number[]` to match SCALE encoding.
|
|
1437
|
+
*/
|
|
1438
|
+
/** Arguments for the `shield` extrinsic. */
|
|
1439
|
+
type ShieldArgs = {
|
|
1440
|
+
assetId: number;
|
|
1441
|
+
amount: bigint;
|
|
1442
|
+
/** 32-byte Poseidon commitment (LE). */
|
|
1443
|
+
commitment: number[];
|
|
1444
|
+
/** 104-byte encrypted memo. */
|
|
1445
|
+
encryptedMemo: number[];
|
|
1446
|
+
};
|
|
1447
|
+
/** Arguments for the `unshield` extrinsic. */
|
|
1448
|
+
type UnshieldArgs = {
|
|
1449
|
+
/** Groth16 proof bytes. */
|
|
1450
|
+
proof: number[];
|
|
1451
|
+
/** 32-byte Merkle root (LE). */
|
|
1452
|
+
merkleRoot: number[];
|
|
1453
|
+
/** 32-byte Poseidon nullifier (LE). */
|
|
1454
|
+
nullifier: number[];
|
|
1455
|
+
assetId: number;
|
|
1456
|
+
amount: bigint;
|
|
1457
|
+
/** 32-byte recipient AccountId. */
|
|
1458
|
+
recipient: number[];
|
|
1459
|
+
};
|
|
1460
|
+
/** Single input note for a private transfer. */
|
|
1461
|
+
type PrivateTransferInput = {
|
|
1462
|
+
/** 32-byte Poseidon nullifier (LE). */
|
|
1463
|
+
nullifier: number[];
|
|
1464
|
+
/** 32-byte Poseidon commitment (LE). */
|
|
1465
|
+
commitment: number[];
|
|
1466
|
+
};
|
|
1467
|
+
/** Single output note for a private transfer. */
|
|
1468
|
+
type PrivateTransferOutput = {
|
|
1469
|
+
/** 32-byte Poseidon commitment (LE). */
|
|
1470
|
+
commitment: number[];
|
|
1471
|
+
/** 104-byte encrypted memo. */
|
|
1472
|
+
memo: number[];
|
|
1473
|
+
};
|
|
1474
|
+
/** Arguments for the `private_transfer` extrinsic. */
|
|
1475
|
+
type PrivateTransferArgs = {
|
|
1476
|
+
inputs: PrivateTransferInput[];
|
|
1477
|
+
outputs: PrivateTransferOutput[];
|
|
1478
|
+
/** Groth16 proof bytes. */
|
|
1479
|
+
proof: number[];
|
|
1480
|
+
/** 32-byte Merkle root (LE). */
|
|
1481
|
+
merkleRoot: number[];
|
|
1482
|
+
};
|
|
1483
|
+
|
|
1484
|
+
/**
|
|
1485
|
+
* Types for events emitted by pallet-shielded-pool.
|
|
1486
|
+
* Hex strings are 0x-prefixed 32-byte LE Poseidon values.
|
|
1487
|
+
*/
|
|
1488
|
+
/** Emitted by `shield()` when a note is deposited. */
|
|
1489
|
+
type ShieldedEvent = {
|
|
1490
|
+
/** SS58 or 0x-prefixed AccountId of the depositor. */
|
|
1491
|
+
depositor: string;
|
|
1492
|
+
amount: bigint;
|
|
1493
|
+
/** 0x-prefixed 32-byte commitment hex (LE). */
|
|
1494
|
+
commitment: string;
|
|
1495
|
+
/** 0x-prefixed encrypted memo hex. */
|
|
1496
|
+
encryptedMemo: string;
|
|
1497
|
+
/** Leaf index assigned in the Merkle tree. */
|
|
1498
|
+
leafIndex: number;
|
|
1499
|
+
};
|
|
1500
|
+
/** Emitted by `private_transfer()`. */
|
|
1501
|
+
type PrivateTransferEvent = {
|
|
1502
|
+
/** Input nullifiers (0x-prefixed 32-byte hex each). */
|
|
1503
|
+
nullifiers: string[];
|
|
1504
|
+
/** Output commitments (0x-prefixed 32-byte hex each). */
|
|
1505
|
+
commitments: string[];
|
|
1506
|
+
/** Encrypted memos for each output. */
|
|
1507
|
+
encryptedMemos: string[];
|
|
1508
|
+
/** Leaf indices assigned to output commitments. */
|
|
1509
|
+
leafIndices: number[];
|
|
1510
|
+
};
|
|
1511
|
+
/** Emitted by `unshield()` when a note is withdrawn. */
|
|
1512
|
+
type UnshieldedEvent = {
|
|
1513
|
+
/** 0x-prefixed 32-byte nullifier hex (LE). */
|
|
1514
|
+
nullifier: string;
|
|
1515
|
+
amount: bigint;
|
|
1516
|
+
/** SS58 or 0x-prefixed AccountId of the recipient. */
|
|
1517
|
+
recipient: string;
|
|
1518
|
+
};
|
|
1519
|
+
/** Emitted after every Merkle tree update. */
|
|
1520
|
+
type MerkleRootUpdatedEvent = {
|
|
1521
|
+
/** 0x-prefixed previous root hex. */
|
|
1522
|
+
oldRoot: string;
|
|
1523
|
+
/** 0x-prefixed new root hex. */
|
|
1524
|
+
newRoot: string;
|
|
1525
|
+
/** New total number of leaves. */
|
|
1526
|
+
treeSize: number;
|
|
1527
|
+
};
|
|
1528
|
+
/** Discriminated union of all shielded-pool events. */
|
|
1529
|
+
type ShieldedPoolEvent = {
|
|
1530
|
+
type: 'Shielded';
|
|
1531
|
+
data: ShieldedEvent;
|
|
1532
|
+
} | {
|
|
1533
|
+
type: 'PrivateTransfer';
|
|
1534
|
+
data: PrivateTransferEvent;
|
|
1535
|
+
} | {
|
|
1536
|
+
type: 'Unshielded';
|
|
1537
|
+
data: UnshieldedEvent;
|
|
1538
|
+
} | {
|
|
1539
|
+
type: 'MerkleRootUpdated';
|
|
1540
|
+
data: MerkleRootUpdatedEvent;
|
|
1541
|
+
};
|
|
1542
|
+
|
|
1543
|
+
/** Configuration for IndexerClient. */
|
|
1544
|
+
interface IndexerClientConfig {
|
|
1545
|
+
/** Base URL of the indexer REST API (no trailing slash). */
|
|
1546
|
+
baseUrl: string;
|
|
1547
|
+
/** Request timeout in ms. Default: 10_000. */
|
|
1548
|
+
timeoutMs?: number;
|
|
1549
|
+
}
|
|
1550
|
+
/** Generic paginated result returned by list endpoints. */
|
|
1551
|
+
interface PaginatedResult<T> {
|
|
1552
|
+
data: T[];
|
|
1553
|
+
pagination: {
|
|
1554
|
+
page: number;
|
|
1555
|
+
limit: number;
|
|
1556
|
+
total: number;
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
/** A shielded commitment (shield event) stored by the indexer. */
|
|
1560
|
+
interface ShieldedCommitment {
|
|
1561
|
+
commitmentHex: string;
|
|
1562
|
+
blockNumber: number;
|
|
1563
|
+
extrinsicIndex: number | null;
|
|
1564
|
+
leafIndex: number;
|
|
1565
|
+
/** Asset ID as decimal string (e.g. "0"). */
|
|
1566
|
+
assetId: string;
|
|
1567
|
+
/** SS58 or 0x-prefixed depositor address, null if not tracked. */
|
|
1568
|
+
sender: string | null;
|
|
1569
|
+
/** 0x-prefixed encrypted memo hex, null if not present. */
|
|
1570
|
+
encryptedMemo: string | null;
|
|
1571
|
+
timestampMs: number | null;
|
|
1572
|
+
}
|
|
1573
|
+
/** A spent nullifier stored by the indexer. */
|
|
1574
|
+
interface SpentNullifier {
|
|
1575
|
+
nullifierHex: string;
|
|
1576
|
+
blockNumber: number;
|
|
1577
|
+
extrinsicIndex: number | null;
|
|
1578
|
+
txType: 'unshield' | 'private_transfer';
|
|
1579
|
+
timestampMs: number | null;
|
|
1580
|
+
}
|
|
1581
|
+
/** A private transfer event stored by the indexer. */
|
|
1582
|
+
interface PrivateTransfer {
|
|
1583
|
+
/** "{blockNumber}-{extrinsicIndex}" */
|
|
1584
|
+
id: string;
|
|
1585
|
+
blockNumber: number;
|
|
1586
|
+
extrinsicIndex: number | null;
|
|
1587
|
+
/** JSON-encoded array of nullifier hex strings. */
|
|
1588
|
+
inputNullifiersJson: string;
|
|
1589
|
+
/** JSON-encoded array of commitment hex strings. */
|
|
1590
|
+
outputCommitmentsJson: string;
|
|
1591
|
+
/** JSON-encoded array of leaf index numbers. */
|
|
1592
|
+
leafIndicesJson: string;
|
|
1593
|
+
timestampMs: number | null;
|
|
1594
|
+
}
|
|
1595
|
+
/** An unshield event stored by the indexer. */
|
|
1596
|
+
interface Unshield {
|
|
1597
|
+
/** "{blockNumber}-{extrinsicIndex}" */
|
|
1598
|
+
id: string;
|
|
1599
|
+
blockNumber: number;
|
|
1600
|
+
extrinsicIndex: number | null;
|
|
1601
|
+
nullifierHex: string;
|
|
1602
|
+
/** Asset ID as decimal string. */
|
|
1603
|
+
assetId: string;
|
|
1604
|
+
/** Amount as decimal string (bigint-safe). */
|
|
1605
|
+
amount: string;
|
|
1606
|
+
recipient: string;
|
|
1607
|
+
timestampMs: number | null;
|
|
1608
|
+
}
|
|
1609
|
+
/** A Merkle root checkpoint stored by the indexer. */
|
|
1610
|
+
interface MerkleRoot {
|
|
1611
|
+
id: number;
|
|
1612
|
+
rootHex: string;
|
|
1613
|
+
blockNumber: number;
|
|
1614
|
+
oldRootHex: string | null;
|
|
1615
|
+
treeSize: number;
|
|
1616
|
+
timestampMs: number | null;
|
|
1617
|
+
}
|
|
1618
|
+
/** Response from the nullifier status endpoint. */
|
|
1619
|
+
interface NullifierStatusResult {
|
|
1620
|
+
nullifier: string;
|
|
1621
|
+
spent: boolean;
|
|
1622
|
+
txType?: 'unshield' | 'private_transfer';
|
|
1623
|
+
blockNumber?: number;
|
|
1624
|
+
}
|
|
1625
|
+
/**
|
|
1626
|
+
* HTTP client for the Orbinum indexer REST API.
|
|
1627
|
+
*
|
|
1628
|
+
* All methods throw on network errors.
|
|
1629
|
+
* Methods returning a single entity return `null` when the server responds 404.
|
|
1630
|
+
*/
|
|
1631
|
+
declare class IndexerClient {
|
|
1632
|
+
private readonly baseUrl;
|
|
1633
|
+
private readonly timeoutMs;
|
|
1634
|
+
constructor(config: IndexerClientConfig);
|
|
1635
|
+
private get;
|
|
1636
|
+
private getOrNull;
|
|
1637
|
+
private buildQuery;
|
|
1638
|
+
/** Returns the total count of shielded commitments. */
|
|
1639
|
+
getCommitmentsCount(): Promise<number>;
|
|
1640
|
+
/** Returns a paginated list of shielded commitments. */
|
|
1641
|
+
getCommitments(params?: {
|
|
1642
|
+
page?: number;
|
|
1643
|
+
limit?: number;
|
|
1644
|
+
sinceLeafIndex?: number;
|
|
1645
|
+
}): Promise<PaginatedResult<ShieldedCommitment>>;
|
|
1646
|
+
/** Returns a single commitment by its hex string, or null if not found. */
|
|
1647
|
+
getCommitmentByHex(hex: string): Promise<ShieldedCommitment | null>;
|
|
1648
|
+
/** Returns a paginated list of spent nullifiers. */
|
|
1649
|
+
getNullifiers(params?: {
|
|
1650
|
+
page?: number;
|
|
1651
|
+
limit?: number;
|
|
1652
|
+
}): Promise<PaginatedResult<SpentNullifier>>;
|
|
1653
|
+
/** Returns the spent/unspent status of a nullifier. */
|
|
1654
|
+
getNullifierStatus(hex: string): Promise<NullifierStatusResult>;
|
|
1655
|
+
/** Returns a paginated list of private transfer events. */
|
|
1656
|
+
getTransfers(params?: {
|
|
1657
|
+
page?: number;
|
|
1658
|
+
limit?: number;
|
|
1659
|
+
}): Promise<PaginatedResult<PrivateTransfer>>;
|
|
1660
|
+
/** Returns a paginated list of unshield events. */
|
|
1661
|
+
getUnshields(params?: {
|
|
1662
|
+
page?: number;
|
|
1663
|
+
limit?: number;
|
|
1664
|
+
}): Promise<PaginatedResult<Unshield>>;
|
|
1665
|
+
/** Returns a paginated list of Merkle root checkpoints. */
|
|
1666
|
+
getMerkleRoots(params?: {
|
|
1667
|
+
page?: number;
|
|
1668
|
+
limit?: number;
|
|
1669
|
+
}): Promise<PaginatedResult<MerkleRoot>>;
|
|
1670
|
+
/** Returns the latest Merkle root, or null if none exists. */
|
|
1671
|
+
getLatestMerkleRoot(): Promise<MerkleRoot | null>;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
export { type AccountListing, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AddChainLinkParams, type AliasFullIdentity, type AliasInfo, type ChainInfo, type ChainLink, ChainModule, type CommitmentMerkleProof, CryptoPrecompiles, type DecryptedMemo, type DispatchAsLinkedParams, EncryptedMemo, EvmClient, type EvmSigner, type EvmTxRequest, type FullIdentityInfo, IndexerClient, type IndexerClientConfig, type ListingInfo, MerkleModule, type MerkleProof, type MerkleRoot, type MerkleRootUpdatedEvent, type MerkleTreeInfo, NoteBuilder, type NoteInput, type NullifierStatus, type NullifierStatusResult, OrbinumClient, type OrbinumClientConfig, PRECOMPILE_ADDR, type PaginatedResult, type PoolBalance, type PoolStats, PrivacyKeyManager, type PrivateLink, type PrivateTransfer, type PrivateTransferArgs, type PrivateTransferEvent, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PutOnSaleParams, type ResolvedAlias, SLIP0044_NAMESPACE, type ScanCommitment, type SetMetadataParams, type ShieldArgs, type ShieldParams, type ShieldResult, type ShieldedCommitment, type ShieldedEvent, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, type SignatureScheme, type SpentNullifier, SubstrateClient, type SupportedChain, type TransferInput, type TransferOutput, type TxResult, type Unshield, type UnshieldArgs, type UnshieldParams, type UnshieldedEvent, type ZkNote, accountIdHexToSs58, addressToAccountIdHex, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, bytesToBigintLE, computePathIndices, decryptJson, deriveOwnerPk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessage, deriveVaultKey, deriveViewingKey, encryptJson, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToSubstrate, fromHex, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, normalizeEvmAddress, substrateSs58ToAccountIdHex, substrateToEvm, toHex, tryDecryptNote, vaultReplacer, vaultReviver };
|