@orbinum/sdk 0.1.0 → 0.2.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/README.md +209 -0
- package/dist/index.d.mts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +55 -0
- package/dist/index.mjs +53 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# @orbinum/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for Orbinum — a privacy-focused blockchain built on Substrate with an EVM compatibility layer.
|
|
4
|
+
|
|
5
|
+
The SDK provides typed modules for interacting with the Orbinum protocol: shielded pool operations, account identity and mapping, chain queries, EVM JSON-RPC, and the indexer REST API.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @orbinum/sdk
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @orbinum/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
- Node.js 18 or later
|
|
18
|
+
- A running Orbinum node (Substrate WebSocket endpoint)
|
|
19
|
+
- An EVM JSON-RPC endpoint (optional, required for EVM and precompile operations)
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { OrbinumClient } from '@orbinum/sdk';
|
|
25
|
+
|
|
26
|
+
const client = await OrbinumClient.connect({
|
|
27
|
+
substrateWs: 'ws://localhost:9944',
|
|
28
|
+
evmRpc: 'http://localhost:9933',
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`OrbinumClient` wires together all modules and exposes them under a single interface. Each module can also be instantiated independently.
|
|
33
|
+
|
|
34
|
+
## Modules
|
|
35
|
+
|
|
36
|
+
### SubstrateClient
|
|
37
|
+
|
|
38
|
+
Thin wrapper over [polkadot-api](https://github.com/polkadot-api/polkadot-api) (PAPI) for Substrate WebSocket communication.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { SubstrateClient } from '@orbinum/sdk';
|
|
42
|
+
|
|
43
|
+
const substrate = await SubstrateClient.connect('ws://localhost:9944');
|
|
44
|
+
|
|
45
|
+
// Raw JSON-RPC call
|
|
46
|
+
const result = await substrate.request('system_name', []);
|
|
47
|
+
|
|
48
|
+
// Build a transaction from pre-encoded SCALE call bytes
|
|
49
|
+
const tx = await substrate.txFromCallData(callBytes);
|
|
50
|
+
const finalized = await tx.signAndSubmit(signer);
|
|
51
|
+
|
|
52
|
+
// Submit a pre-signed extrinsic
|
|
53
|
+
const finalized = await substrate.submit(signedHex);
|
|
54
|
+
|
|
55
|
+
// Submit and observe lifecycle events
|
|
56
|
+
substrate.submitAndWatch(signedHex).subscribe(event => console.log(event));
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### EvmClient
|
|
60
|
+
|
|
61
|
+
Stateless HTTP client following the Ethereum JSON-RPC specification.
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { EvmClient } from '@orbinum/sdk';
|
|
65
|
+
|
|
66
|
+
const evm = new EvmClient('http://localhost:9933');
|
|
67
|
+
|
|
68
|
+
const balance = await evm.getBalance('0xYourAddress');
|
|
69
|
+
const chainId = await evm.getChainId();
|
|
70
|
+
const txHash = await evm.sendRawTransaction(signedHex);
|
|
71
|
+
|
|
72
|
+
// Batch multiple calls in a single HTTP request
|
|
73
|
+
const [balance, nonce] = await evm.batchRequest([
|
|
74
|
+
{ method: 'eth_getBalance', params: ['0xAddr', 'latest'] },
|
|
75
|
+
{ method: 'eth_getTransactionCount', params: ['0xAddr', 'latest'] },
|
|
76
|
+
]);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### ShieldedPoolModule
|
|
80
|
+
|
|
81
|
+
High-level interface for shielded pool operations. Requires a loaded `PrivacyKeyManager` and ZK proofs for unshield and private transfer.
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
// Shield (deposit) tokens into the shielded pool
|
|
85
|
+
const { txResult, note } = await client.shieldedPool.buildAndShield({
|
|
86
|
+
amount: 1_000_000n,
|
|
87
|
+
tokenAddress: '0xTokenAddress',
|
|
88
|
+
}, signer);
|
|
89
|
+
|
|
90
|
+
// Private transfer between notes
|
|
91
|
+
await client.shieldedPool.privateTransfer({ ...params }, signer);
|
|
92
|
+
|
|
93
|
+
// Unshield (withdraw) tokens to a public address
|
|
94
|
+
await client.shieldedPool.unshield({ ...params }, signer);
|
|
95
|
+
|
|
96
|
+
// Check if a nullifier has been spent
|
|
97
|
+
const spent = await client.shieldedPool.isNullifierSpent('0xNullifier');
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Privacy Keys
|
|
101
|
+
|
|
102
|
+
Key derivation follows a deterministic chain from the user's wallet signature. No key material is ever stored by the SDK.
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import { PrivacyKeys, PrivacyKeyManager } from '@orbinum/sdk';
|
|
106
|
+
|
|
107
|
+
// 1. Get the message the user must sign
|
|
108
|
+
const message = PrivacyKeys.deriveSpendingKeyMessage(chainId, evmAddress);
|
|
109
|
+
|
|
110
|
+
// 2. Derive the spending key from the wallet signature
|
|
111
|
+
const spendingKey = PrivacyKeys.deriveSpendingKeyFromSignature(sigHex, chainId, evmAddress);
|
|
112
|
+
|
|
113
|
+
// 3. Load into the key manager
|
|
114
|
+
const keyManager = new PrivacyKeyManager();
|
|
115
|
+
keyManager.load(spendingKey);
|
|
116
|
+
|
|
117
|
+
// The manager derives the viewing key (ChaCha20 memo decryption)
|
|
118
|
+
// and owner public key (BabyJubJub, used in note commitments)
|
|
119
|
+
const viewingKey = keyManager.getViewingKey();
|
|
120
|
+
const ownerPk = keyManager.getOwnerPk();
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### AccountMappingModule
|
|
124
|
+
|
|
125
|
+
Manage on-chain identity by linking Substrate and EVM accounts, registering aliases, and interacting with the alias marketplace.
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
// Register an alias
|
|
129
|
+
await client.accountMapping.registerAlias({ alias: 'myalias' }, signer);
|
|
130
|
+
|
|
131
|
+
// Link an EVM address to a Substrate account
|
|
132
|
+
await client.accountMapping.addChainLink({ chainId: 1, address: '0xEvmAddr' }, signer);
|
|
133
|
+
|
|
134
|
+
// Query
|
|
135
|
+
const alias = await client.accountMapping.getAliasOf(substrateHex);
|
|
136
|
+
const linked = await client.accountMapping.getChainLinks(substrateHex);
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### ChainModule
|
|
140
|
+
|
|
141
|
+
Query chain information bridging Substrate and EVM endpoints.
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
const info = await client.chain.getChainInfo(); // name, spec, SS58 prefix
|
|
145
|
+
const identity = await client.chain.getFullIdentity(address);
|
|
146
|
+
const health = await client.chain.getHealth();
|
|
147
|
+
const evmBlock = await client.chain.getEvmBlockNumber();
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### IndexerClient
|
|
151
|
+
|
|
152
|
+
HTTP client for the Orbinum indexer REST API. The indexer runs as a separate service indexed from node events.
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import { IndexerClient } from '@orbinum/sdk';
|
|
156
|
+
|
|
157
|
+
const indexer = new IndexerClient('https://indexer.orbinum.io');
|
|
158
|
+
|
|
159
|
+
const commitments = await indexer.getCommitments({ page: 1, limit: 20 });
|
|
160
|
+
const status = await indexer.getNullifierStatus('0xNullifier');
|
|
161
|
+
const roots = await indexer.getMerkleRoots({ limit: 10 });
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Precompiles
|
|
165
|
+
|
|
166
|
+
Typed wrappers for Orbinum's EVM precompile contracts, callable from any EVM wallet or signer.
|
|
167
|
+
|
|
168
|
+
| Precompile | Address | Description |
|
|
169
|
+
|---|---|---|
|
|
170
|
+
| `ShieldedPoolPrecompile` | `0x0801` | Shield, unshield, and private transfer from EVM |
|
|
171
|
+
| `AccountMappingPrecompile` | `0x0800` | Identity and alias operations from EVM |
|
|
172
|
+
| `CryptoPrecompiles` | `0x0400–0x0403` | Frontier crypto utilities (SHA3, EC recover, Curve25519) |
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import { ShieldedPoolPrecompile } from '@orbinum/sdk';
|
|
176
|
+
|
|
177
|
+
const precompile = new ShieldedPoolPrecompile(evmClient);
|
|
178
|
+
await precompile.shield(amount, tokenAddress, commitment, walletSigner);
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Key Derivation Chain
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
wallet.sign(message)
|
|
185
|
+
|
|
|
186
|
+
v
|
|
187
|
+
deriveSpendingKeyFromSignature() -- HKDF-SHA256 over signature bytes, mod BN254_R
|
|
188
|
+
|
|
|
189
|
+
+-- deriveViewingKey() -- HKDF-SHA256 -> 32-byte ChaCha20 symmetric key
|
|
190
|
+
| (used to encrypt/decrypt note memos)
|
|
191
|
+
|
|
|
192
|
+
+-- deriveOwnerPk() -- BabyJubJub scalar multiplication -> Ax
|
|
193
|
+
(embedded in shielded note commitments)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Development
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
pnpm install
|
|
200
|
+
pnpm build # compile to dist/ (ESM + CJS + types)
|
|
201
|
+
pnpm test # run test suite
|
|
202
|
+
pnpm typecheck:all # typecheck src and tests
|
|
203
|
+
pnpm lint # eslint
|
|
204
|
+
pnpm format # prettier
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
ISC
|
package/dist/index.d.mts
CHANGED
|
@@ -1322,6 +1322,23 @@ declare const PRECOMPILE_ADDR: {
|
|
|
1322
1322
|
readonly ACCOUNT_MAPPING: "0x0000000000000000000000000000000000000800";
|
|
1323
1323
|
readonly SHIELDED_POOL: "0x0000000000000000000000000000000000000801";
|
|
1324
1324
|
};
|
|
1325
|
+
/** Metadata for a known precompile: display name and function selector map. */
|
|
1326
|
+
interface KnownPrecompileInfo {
|
|
1327
|
+
/** Human-readable name, e.g. "ShieldedPool". */
|
|
1328
|
+
name: string;
|
|
1329
|
+
/** Map from 4-byte hex selector (no 0x prefix) to function signature. */
|
|
1330
|
+
functions: Record<string, string>;
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* Registry of all known Orbinum EVM precompiles, keyed by lowercase address.
|
|
1334
|
+
* Covers Ethereum standard (EIP), Frontier non-standard, and Orbinum custom precompiles.
|
|
1335
|
+
*/
|
|
1336
|
+
declare const KNOWN_PRECOMPILES: Record<string, KnownPrecompileInfo>;
|
|
1337
|
+
/**
|
|
1338
|
+
* Returns the human-readable name for a known precompile address,
|
|
1339
|
+
* or null if the address is not a known precompile.
|
|
1340
|
+
*/
|
|
1341
|
+
declare function getPrecompileLabel(address: string | null | undefined): string | null;
|
|
1325
1342
|
|
|
1326
1343
|
/**
|
|
1327
1344
|
* Serialises a bigint as a 32-byte little-endian Uint8Array.
|
|
@@ -1671,4 +1688,4 @@ declare class IndexerClient {
|
|
|
1671
1688
|
getLatestMerkleRoot(): Promise<MerkleRoot | null>;
|
|
1672
1689
|
}
|
|
1673
1690
|
|
|
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 };
|
|
1691
|
+
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, KNOWN_PRECOMPILES, type KnownPrecompileInfo, 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, getPrecompileLabel, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, normalizeEvmAddress, substrateSs58ToAccountIdHex, substrateToEvm, toHex, tryDecryptNote, vaultReplacer, vaultReviver };
|
package/dist/index.d.ts
CHANGED
|
@@ -1322,6 +1322,23 @@ declare const PRECOMPILE_ADDR: {
|
|
|
1322
1322
|
readonly ACCOUNT_MAPPING: "0x0000000000000000000000000000000000000800";
|
|
1323
1323
|
readonly SHIELDED_POOL: "0x0000000000000000000000000000000000000801";
|
|
1324
1324
|
};
|
|
1325
|
+
/** Metadata for a known precompile: display name and function selector map. */
|
|
1326
|
+
interface KnownPrecompileInfo {
|
|
1327
|
+
/** Human-readable name, e.g. "ShieldedPool". */
|
|
1328
|
+
name: string;
|
|
1329
|
+
/** Map from 4-byte hex selector (no 0x prefix) to function signature. */
|
|
1330
|
+
functions: Record<string, string>;
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* Registry of all known Orbinum EVM precompiles, keyed by lowercase address.
|
|
1334
|
+
* Covers Ethereum standard (EIP), Frontier non-standard, and Orbinum custom precompiles.
|
|
1335
|
+
*/
|
|
1336
|
+
declare const KNOWN_PRECOMPILES: Record<string, KnownPrecompileInfo>;
|
|
1337
|
+
/**
|
|
1338
|
+
* Returns the human-readable name for a known precompile address,
|
|
1339
|
+
* or null if the address is not a known precompile.
|
|
1340
|
+
*/
|
|
1341
|
+
declare function getPrecompileLabel(address: string | null | undefined): string | null;
|
|
1325
1342
|
|
|
1326
1343
|
/**
|
|
1327
1344
|
* Serialises a bigint as a 32-byte little-endian Uint8Array.
|
|
@@ -1671,4 +1688,4 @@ declare class IndexerClient {
|
|
|
1671
1688
|
getLatestMerkleRoot(): Promise<MerkleRoot | null>;
|
|
1672
1689
|
}
|
|
1673
1690
|
|
|
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 };
|
|
1691
|
+
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, KNOWN_PRECOMPILES, type KnownPrecompileInfo, 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, getPrecompileLabel, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, normalizeEvmAddress, substrateSs58ToAccountIdHex, substrateToEvm, toHex, tryDecryptNote, vaultReplacer, vaultReviver };
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
CryptoPrecompiles: () => CryptoPrecompiles,
|
|
27
27
|
EncryptedMemo: () => EncryptedMemo,
|
|
28
28
|
EvmClient: () => EvmClient,
|
|
29
|
+
KNOWN_PRECOMPILES: () => KNOWN_PRECOMPILES,
|
|
29
30
|
MerkleModule: () => MerkleModule,
|
|
30
31
|
NoteBuilder: () => NoteBuilder,
|
|
31
32
|
OrbinumClient: () => OrbinumClient,
|
|
@@ -56,6 +57,7 @@ __export(index_exports, {
|
|
|
56
57
|
fromHex: () => fromHex,
|
|
57
58
|
getPolkadotSigner: () => import_signer.getPolkadotSigner,
|
|
58
59
|
getPolkadotSignerFromPjs: () => import_pjs_signer.getPolkadotSignerFromPjs,
|
|
60
|
+
getPrecompileLabel: () => getPrecompileLabel,
|
|
59
61
|
implicitSubstrateToEvm: () => implicitSubstrateToEvm,
|
|
60
62
|
isEvmAddress: () => isEvmAddress,
|
|
61
63
|
isImplicitEvmAccount: () => isImplicitEvmAccount,
|
|
@@ -1581,6 +1583,57 @@ var SP_SEL = {
|
|
|
1581
1583
|
// unshield(bytes,bytes32,bytes32,uint32,uint256,bytes32) → 0xdcf1bff2
|
|
1582
1584
|
UNSHIELD: new Uint8Array([220, 241, 191, 242])
|
|
1583
1585
|
};
|
|
1586
|
+
var KNOWN_PRECOMPILES = {
|
|
1587
|
+
// ── Ethereum standard (EIP) ─────────────────────────────────────────────
|
|
1588
|
+
"0x0000000000000000000000000000000000000001": {
|
|
1589
|
+
name: "ECRecover",
|
|
1590
|
+
functions: { "00000000": "ecrecover(bytes32,uint8,bytes32,bytes32)" }
|
|
1591
|
+
},
|
|
1592
|
+
"0x0000000000000000000000000000000000000002": { name: "SHA256", functions: {} },
|
|
1593
|
+
"0x0000000000000000000000000000000000000003": { name: "RIPEMD160", functions: {} },
|
|
1594
|
+
"0x0000000000000000000000000000000000000004": { name: "Identity", functions: {} },
|
|
1595
|
+
"0x0000000000000000000000000000000000000005": { name: "ModExp", functions: {} },
|
|
1596
|
+
// ── Frontier / non-standard ─────────────────────────────────────────────
|
|
1597
|
+
"0x0000000000000000000000000000000000000400": { name: "SHA3FIPS256", functions: {} },
|
|
1598
|
+
"0x0000000000000000000000000000000000000401": { name: "ECRecoverPublicKey", functions: {} },
|
|
1599
|
+
"0x0000000000000000000000000000000000000402": { name: "Curve25519Add", functions: {} },
|
|
1600
|
+
"0x0000000000000000000000000000000000000403": { name: "Curve25519ScalarMul", functions: {} },
|
|
1601
|
+
// ── Orbinum custom ───────────────────────────────────────────────────────
|
|
1602
|
+
"0x0000000000000000000000000000000000000800": {
|
|
1603
|
+
name: "AccountMapping",
|
|
1604
|
+
functions: {
|
|
1605
|
+
d03149ab: "resolveAlias(string)",
|
|
1606
|
+
"7a0ed62c": "getAliasOf(address)",
|
|
1607
|
+
"47e05c6c": "hasPrivateLink(string,bytes32)",
|
|
1608
|
+
dca49d0e: "mapAccount()",
|
|
1609
|
+
"08f57367": "unmapAccount()",
|
|
1610
|
+
"7fac359e": "releaseAlias()",
|
|
1611
|
+
"4d023ab9": "cancelSale()",
|
|
1612
|
+
"2f8839c3": "registerAlias(string)",
|
|
1613
|
+
"5ac998e7": "transferAlias(address)",
|
|
1614
|
+
"1625df3a": "buyAlias(string)",
|
|
1615
|
+
"32091192": "putAliasOnSale(uint256,address[])",
|
|
1616
|
+
"6f579c0c": "removeChainLink(uint32)",
|
|
1617
|
+
"5f3e837c": "addChainLink(uint32,bytes,bytes)",
|
|
1618
|
+
c04e98f4: "registerPrivateLink(uint32,bytes32)",
|
|
1619
|
+
dfd8b57e: "removePrivateLink(bytes32)",
|
|
1620
|
+
"4df1f33d": "revealPrivateLink(bytes32,bytes,bytes32,bytes)",
|
|
1621
|
+
"776cf9ff": "setAccountMetadata(bytes,bytes,bytes)"
|
|
1622
|
+
}
|
|
1623
|
+
},
|
|
1624
|
+
"0x0000000000000000000000000000000000000801": {
|
|
1625
|
+
name: "ShieldedPool",
|
|
1626
|
+
functions: {
|
|
1627
|
+
"781442b9": "shield(uint32,uint256,bytes32,bytes)",
|
|
1628
|
+
dcd5b898: "privateTransfer(bytes,bytes32,bytes32[],bytes32[],bytes[])",
|
|
1629
|
+
dcf1bff2: "unshield(bytes,bytes32,bytes32,uint32,uint256,bytes32)"
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1633
|
+
function getPrecompileLabel(address) {
|
|
1634
|
+
if (!address) return null;
|
|
1635
|
+
return KNOWN_PRECOMPILES[address.toLowerCase()]?.name ?? null;
|
|
1636
|
+
}
|
|
1584
1637
|
|
|
1585
1638
|
// src/precompiles/ShieldedPoolPrecompile.ts
|
|
1586
1639
|
var ShieldedPoolPrecompile = class {
|
|
@@ -2350,6 +2403,7 @@ var import_pjs_signer = require("polkadot-api/pjs-signer");
|
|
|
2350
2403
|
CryptoPrecompiles,
|
|
2351
2404
|
EncryptedMemo,
|
|
2352
2405
|
EvmClient,
|
|
2406
|
+
KNOWN_PRECOMPILES,
|
|
2353
2407
|
MerkleModule,
|
|
2354
2408
|
NoteBuilder,
|
|
2355
2409
|
OrbinumClient,
|
|
@@ -2380,6 +2434,7 @@ var import_pjs_signer = require("polkadot-api/pjs-signer");
|
|
|
2380
2434
|
fromHex,
|
|
2381
2435
|
getPolkadotSigner,
|
|
2382
2436
|
getPolkadotSignerFromPjs,
|
|
2437
|
+
getPrecompileLabel,
|
|
2383
2438
|
implicitSubstrateToEvm,
|
|
2384
2439
|
isEvmAddress,
|
|
2385
2440
|
isImplicitEvmAccount,
|
package/dist/index.mjs
CHANGED
|
@@ -1509,6 +1509,57 @@ var SP_SEL = {
|
|
|
1509
1509
|
// unshield(bytes,bytes32,bytes32,uint32,uint256,bytes32) → 0xdcf1bff2
|
|
1510
1510
|
UNSHIELD: new Uint8Array([220, 241, 191, 242])
|
|
1511
1511
|
};
|
|
1512
|
+
var KNOWN_PRECOMPILES = {
|
|
1513
|
+
// ── Ethereum standard (EIP) ─────────────────────────────────────────────
|
|
1514
|
+
"0x0000000000000000000000000000000000000001": {
|
|
1515
|
+
name: "ECRecover",
|
|
1516
|
+
functions: { "00000000": "ecrecover(bytes32,uint8,bytes32,bytes32)" }
|
|
1517
|
+
},
|
|
1518
|
+
"0x0000000000000000000000000000000000000002": { name: "SHA256", functions: {} },
|
|
1519
|
+
"0x0000000000000000000000000000000000000003": { name: "RIPEMD160", functions: {} },
|
|
1520
|
+
"0x0000000000000000000000000000000000000004": { name: "Identity", functions: {} },
|
|
1521
|
+
"0x0000000000000000000000000000000000000005": { name: "ModExp", functions: {} },
|
|
1522
|
+
// ── Frontier / non-standard ─────────────────────────────────────────────
|
|
1523
|
+
"0x0000000000000000000000000000000000000400": { name: "SHA3FIPS256", functions: {} },
|
|
1524
|
+
"0x0000000000000000000000000000000000000401": { name: "ECRecoverPublicKey", functions: {} },
|
|
1525
|
+
"0x0000000000000000000000000000000000000402": { name: "Curve25519Add", functions: {} },
|
|
1526
|
+
"0x0000000000000000000000000000000000000403": { name: "Curve25519ScalarMul", functions: {} },
|
|
1527
|
+
// ── Orbinum custom ───────────────────────────────────────────────────────
|
|
1528
|
+
"0x0000000000000000000000000000000000000800": {
|
|
1529
|
+
name: "AccountMapping",
|
|
1530
|
+
functions: {
|
|
1531
|
+
d03149ab: "resolveAlias(string)",
|
|
1532
|
+
"7a0ed62c": "getAliasOf(address)",
|
|
1533
|
+
"47e05c6c": "hasPrivateLink(string,bytes32)",
|
|
1534
|
+
dca49d0e: "mapAccount()",
|
|
1535
|
+
"08f57367": "unmapAccount()",
|
|
1536
|
+
"7fac359e": "releaseAlias()",
|
|
1537
|
+
"4d023ab9": "cancelSale()",
|
|
1538
|
+
"2f8839c3": "registerAlias(string)",
|
|
1539
|
+
"5ac998e7": "transferAlias(address)",
|
|
1540
|
+
"1625df3a": "buyAlias(string)",
|
|
1541
|
+
"32091192": "putAliasOnSale(uint256,address[])",
|
|
1542
|
+
"6f579c0c": "removeChainLink(uint32)",
|
|
1543
|
+
"5f3e837c": "addChainLink(uint32,bytes,bytes)",
|
|
1544
|
+
c04e98f4: "registerPrivateLink(uint32,bytes32)",
|
|
1545
|
+
dfd8b57e: "removePrivateLink(bytes32)",
|
|
1546
|
+
"4df1f33d": "revealPrivateLink(bytes32,bytes,bytes32,bytes)",
|
|
1547
|
+
"776cf9ff": "setAccountMetadata(bytes,bytes,bytes)"
|
|
1548
|
+
}
|
|
1549
|
+
},
|
|
1550
|
+
"0x0000000000000000000000000000000000000801": {
|
|
1551
|
+
name: "ShieldedPool",
|
|
1552
|
+
functions: {
|
|
1553
|
+
"781442b9": "shield(uint32,uint256,bytes32,bytes)",
|
|
1554
|
+
dcd5b898: "privateTransfer(bytes,bytes32,bytes32[],bytes32[],bytes[])",
|
|
1555
|
+
dcf1bff2: "unshield(bytes,bytes32,bytes32,uint32,uint256,bytes32)"
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
};
|
|
1559
|
+
function getPrecompileLabel(address) {
|
|
1560
|
+
if (!address) return null;
|
|
1561
|
+
return KNOWN_PRECOMPILES[address.toLowerCase()]?.name ?? null;
|
|
1562
|
+
}
|
|
1512
1563
|
|
|
1513
1564
|
// src/precompiles/ShieldedPoolPrecompile.ts
|
|
1514
1565
|
var ShieldedPoolPrecompile = class {
|
|
@@ -2277,6 +2328,7 @@ export {
|
|
|
2277
2328
|
CryptoPrecompiles,
|
|
2278
2329
|
EncryptedMemo,
|
|
2279
2330
|
EvmClient,
|
|
2331
|
+
KNOWN_PRECOMPILES,
|
|
2280
2332
|
MerkleModule,
|
|
2281
2333
|
NoteBuilder,
|
|
2282
2334
|
OrbinumClient,
|
|
@@ -2307,6 +2359,7 @@ export {
|
|
|
2307
2359
|
fromHex,
|
|
2308
2360
|
getPolkadotSigner,
|
|
2309
2361
|
getPolkadotSignerFromPjs,
|
|
2362
|
+
getPrecompileLabel,
|
|
2310
2363
|
implicitSubstrateToEvm,
|
|
2311
2364
|
isEvmAddress,
|
|
2312
2365
|
isImplicitEvmAccount,
|