@orbinum/sdk 0.21.0 → 0.22.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.mjs CHANGED
@@ -142,7 +142,7 @@ var SubstrateClient = class _SubstrateClient {
142
142
  }
143
143
  /**
144
144
  * Performs a raw JSON-RPC request. Use this for custom Orbinum RPCs
145
- * (shieldedPool_*, accountMapping_*, privacy_*, etc.).
145
+ * (shieldedPool_*, privacy_*, etc.).
146
146
  */
147
147
  async request(method, params = []) {
148
148
  return this._papi._request(method, params);
@@ -1723,389 +1723,6 @@ var ShieldedPoolModule = class {
1723
1723
  }
1724
1724
  };
1725
1725
 
1726
- // src/account-mapping/AccountMappingModule.ts
1727
- import { Binary as Binary2 } from "polkadot-api";
1728
-
1729
- // src/account-mapping/helpers.ts
1730
- function mapRawScheme(raw) {
1731
- if (raw === "Eip191" || raw === "eip191") return "Eip191";
1732
- if (raw === "Ed25519" || raw === "ed25519") return "Ed25519";
1733
- return raw;
1734
- }
1735
-
1736
- // src/account-mapping/AccountMappingModule.ts
1737
- var AccountMappingModule = class {
1738
- constructor(substrate) {
1739
- this.substrate = substrate;
1740
- }
1741
- substrate;
1742
- // ─── Address resolution ─────────────────────────────────────────────────────
1743
- /**
1744
- * Returns the explicitly mapped (or fallback) Substrate AccountId32 hex for
1745
- * an EVM address. `mapped` is set only when `map_account` was called.
1746
- * `fallback` is always the EeSuffix rule: `H160 ++ [0x00; 12]`.
1747
- */
1748
- async getAccountAddresses(accountId) {
1749
- try {
1750
- const raw = await this.substrate.request(
1751
- "accountMapping_getAccountAddresses",
1752
- [accountId]
1753
- );
1754
- return { mapped: raw.mapped ?? null, fallback: raw.fallback ?? null };
1755
- } catch {
1756
- return { mapped: null, fallback: null };
1757
- }
1758
- }
1759
- /**
1760
- * Returns the explicitly mapped Substrate AccountId32 hex for a given EVM
1761
- * address, or null if no explicit mapping exists.
1762
- */
1763
- async getMappedAccount(evmAddress) {
1764
- try {
1765
- return await this.substrate.request("accountMapping_getMappedAccount", [
1766
- normalizeEvmAddress(evmAddress)
1767
- ]);
1768
- } catch {
1769
- return null;
1770
- }
1771
- }
1772
- // ─── Alias queries ──────────────────────────────────────────────────────────
1773
- /**
1774
- * Resolves "@alias" to basic info (owner, optional EVM address, link count).
1775
- * Accepts the alias with or without the leading "@".
1776
- */
1777
- async resolveAlias(alias) {
1778
- try {
1779
- const raw = await this.substrate.request(
1780
- "accountMapping_resolveAlias",
1781
- [alias]
1782
- );
1783
- if (!raw) return null;
1784
- return {
1785
- owner: raw.substrate_account,
1786
- evmAddress: raw.evm_address ? normalizeEvmAddress(raw.evm_address) : null,
1787
- chainLinksCount: raw.chain_links_count
1788
- };
1789
- } catch {
1790
- return null;
1791
- }
1792
- }
1793
- /**
1794
- * Returns the alias registered for the given Substrate AccountId32 hex, or null.
1795
- */
1796
- async getAliasOf(accountId) {
1797
- try {
1798
- return await this.substrate.request("accountMapping_getAliasOf", [
1799
- accountId
1800
- ]);
1801
- } catch {
1802
- return null;
1803
- }
1804
- }
1805
- // ─── Full identity ──────────────────────────────────────────────────────────
1806
- /**
1807
- * Resolves "@alias" to its full identity: owner, EVM address, all public
1808
- * chain links, and profile metadata.
1809
- */
1810
- async resolveFullIdentity(alias) {
1811
- try {
1812
- const raw = await this.substrate.request(
1813
- "accountMapping_resolveFullIdentity",
1814
- [alias]
1815
- );
1816
- if (!raw) return null;
1817
- return {
1818
- owner: raw.owner,
1819
- evmAddress: raw.evm_address ? normalizeEvmAddress(raw.evm_address) : null,
1820
- chainLinks: raw.chain_links.map((l) => ({
1821
- chainId: l.chain_id,
1822
- address: l.address
1823
- })),
1824
- metadata: raw.metadata ? {
1825
- displayName: raw.metadata.display_name ?? null,
1826
- bio: raw.metadata.bio ?? null,
1827
- avatar: raw.metadata.avatar ?? null
1828
- } : null
1829
- };
1830
- } catch {
1831
- return null;
1832
- }
1833
- }
1834
- /**
1835
- * Returns the profile metadata for a given Substrate AccountId32 hex, or null.
1836
- */
1837
- async getAccountMetadata(accountId) {
1838
- try {
1839
- const raw = await this.substrate.request(
1840
- "accountMapping_getAccountMetadata",
1841
- [accountId]
1842
- );
1843
- if (!raw) return null;
1844
- return {
1845
- displayName: raw.display_name ?? null,
1846
- bio: raw.bio ?? null,
1847
- avatar: raw.avatar ?? null
1848
- };
1849
- } catch {
1850
- return null;
1851
- }
1852
- }
1853
- // ─── Chain links ────────────────────────────────────────────────────────────
1854
- /**
1855
- * Returns the owner AccountId32 hex of a verified multichain link, or null.
1856
- */
1857
- async getLinkOwner(chainId, address) {
1858
- try {
1859
- return await this.substrate.request("accountMapping_getLinkOwner", [
1860
- chainId,
1861
- address
1862
- ]);
1863
- } catch {
1864
- return null;
1865
- }
1866
- }
1867
- /**
1868
- * Returns all blockchain networks supported for verified cross-chain links.
1869
- */
1870
- async getSupportedChains() {
1871
- try {
1872
- const raw = await this.substrate.request(
1873
- "accountMapping_getSupportedChains",
1874
- []
1875
- );
1876
- return raw.map(([chainId, scheme]) => ({
1877
- chainId,
1878
- scheme: mapRawScheme(scheme)
1879
- }));
1880
- } catch {
1881
- return [];
1882
- }
1883
- }
1884
- // ─── Private links ──────────────────────────────────────────────────────────
1885
- /**
1886
- * Returns the private link commitments registered for an alias.
1887
- * Real addresses are never exposed. Returns null if the alias does not exist.
1888
- */
1889
- async getPrivateLinks(alias) {
1890
- try {
1891
- const raw = await this.substrate.request(
1892
- "accountMapping_getPrivateLinks",
1893
- [alias]
1894
- );
1895
- if (!raw) return null;
1896
- return raw.map((r) => ({ chainId: r.chain_id, commitment: r.commitment }));
1897
- } catch {
1898
- return null;
1899
- }
1900
- }
1901
- /**
1902
- * Returns true if the given commitment is registered as a private link for the alias.
1903
- */
1904
- async hasPrivateLink(alias, commitment) {
1905
- try {
1906
- return await this.substrate.request("accountMapping_hasPrivateLink", [
1907
- alias,
1908
- commitment
1909
- ]);
1910
- } catch {
1911
- return false;
1912
- }
1913
- }
1914
- // ─── Marketplace ────────────────────────────────────────────────────────────
1915
- /**
1916
- * Returns listing info if the alias is currently for sale, or null.
1917
- */
1918
- async getListingInfo(alias) {
1919
- try {
1920
- const raw = await this.substrate.request(
1921
- "accountMapping_getListingInfo",
1922
- [alias]
1923
- );
1924
- if (!raw) return null;
1925
- return {
1926
- price: BigInt(raw.price),
1927
- private: raw.private,
1928
- whitelistCount: raw.whitelist_count
1929
- };
1930
- } catch {
1931
- return null;
1932
- }
1933
- }
1934
- /**
1935
- * Returns the alias and its listing if the given account currently has an
1936
- * alias listed for sale. Returns null otherwise.
1937
- */
1938
- async getAccountListing(accountId) {
1939
- try {
1940
- const raw = await this.substrate.request(
1941
- "accountMapping_getAccountListing",
1942
- [accountId]
1943
- );
1944
- if (!raw) return null;
1945
- return {
1946
- alias: raw.alias,
1947
- listing: {
1948
- price: BigInt(raw.price),
1949
- private: raw.private,
1950
- whitelistCount: raw.whitelist_count
1951
- }
1952
- };
1953
- } catch {
1954
- return null;
1955
- }
1956
- }
1957
- /**
1958
- * Returns whether a specific buyer can purchase the given alias right now.
1959
- */
1960
- async canBuy(alias, buyerAccountId) {
1961
- try {
1962
- return await this.substrate.request("accountMapping_canBuy", [
1963
- alias,
1964
- buyerAccountId
1965
- ]);
1966
- } catch {
1967
- return false;
1968
- }
1969
- }
1970
- // ─── Extrinsics ─────────────────────────────────────────────────────────────
1971
- /**
1972
- * Creates an explicit EVM → Substrate account mapping.
1973
- * Stores an explicit `MappedAccounts` entry for the caller's H160.
1974
- * Extrinsic: accountMapping.mapAccount()
1975
- */
1976
- async mapAccount(signer) {
1977
- const entry = resolveTx(this.substrate.unsafe, "accountMapping", "mapAccount");
1978
- const tx = callUnsafeTx(entry);
1979
- return toTxResult(await tx.signAndSubmit(signer));
1980
- }
1981
- /**
1982
- * Removes the EVM → Substrate mapping for the caller.
1983
- * Extrinsic: accountMapping.unmapAccount()
1984
- */
1985
- async unmapAccount(signer) {
1986
- const entry = resolveTx(this.substrate.unsafe, "accountMapping", "unmapAccount");
1987
- const tx = callUnsafeTx(entry);
1988
- return toTxResult(await tx.signAndSubmit(signer));
1989
- }
1990
- /**
1991
- * Registers a unique @alias for the caller.
1992
- * Requires a deposit. The alias must be 3–32 ASCII lowercase alphanumeric chars + hyphens.
1993
- * Extrinsic: accountMapping.registerAlias(alias)
1994
- */
1995
- async registerAlias(alias, signer) {
1996
- const entry = resolveTx(this.substrate.unsafe, "accountMapping", "registerAlias");
1997
- const tx = callUnsafeTx(entry, Binary2.fromText(alias));
1998
- return toTxResult(await tx.signAndSubmit(signer));
1999
- }
2000
- /**
2001
- * Releases the caller's alias and recovers the deposit.
2002
- * Extrinsic: accountMapping.releaseAlias()
2003
- */
2004
- async releaseAlias(signer) {
2005
- const entry = resolveTx(this.substrate.unsafe, "accountMapping", "releaseAlias");
2006
- const tx = callUnsafeTx(entry);
2007
- return toTxResult(await tx.signAndSubmit(signer));
2008
- }
2009
- /**
2010
- * Transfers the caller's alias to another account.
2011
- * Extrinsic: accountMapping.transferAlias(newOwner)
2012
- */
2013
- async transferAlias(newOwnerHex, signer) {
2014
- const entry = resolveTx(this.substrate.unsafe, "accountMapping", "transferAlias");
2015
- const tx = callUnsafeTx(entry, newOwnerHex);
2016
- return toTxResult(await tx.signAndSubmit(signer));
2017
- }
2018
- /**
2019
- * Adds a verified public link to an external-chain wallet.
2020
- *
2021
- * `params.signature` must be produced by the external wallet over the caller's
2022
- * AccountId32 bytes:
2023
- * - EIP-191 (EVM): sign(keccak256("\x19Ethereum Signed Message:\n32" + accountId32))
2024
- * - Ed25519 (Solana): sign(accountId32 bytes)
2025
- *
2026
- * Extrinsic: accountMapping.addChainLink(chainId, address, signature)
2027
- */
2028
- async addChainLink(params, signer) {
2029
- const entry = resolveTx(this.substrate.unsafe, "accountMapping", "addChainLink");
2030
- const tx = callUnsafeTx(entry, params.chainId, params.address, params.signature);
2031
- return toTxResult(await tx.signAndSubmit(signer));
2032
- }
2033
- /**
2034
- * Removes the external-chain link for the given chain ID.
2035
- * Extrinsic: accountMapping.removeChainLink(chainId)
2036
- */
2037
- async removeChainLink(chainId, signer) {
2038
- const entry = resolveTx(this.substrate.unsafe, "accountMapping", "removeChainLink");
2039
- const tx = callUnsafeTx(entry, chainId);
2040
- return toTxResult(await tx.signAndSubmit(signer));
2041
- }
2042
- /**
2043
- * Updates the caller's public profile metadata.
2044
- * Extrinsic: accountMapping.setAccountMetadata(displayName, bio, avatar)
2045
- */
2046
- async setAccountMetadata(params, signer) {
2047
- const entry = resolveTx(this.substrate.unsafe, "accountMapping", "setAccountMetadata");
2048
- const encode2 = (v) => v != null ? Binary2.fromText(v) : void 0;
2049
- const tx = callUnsafeTx(
2050
- entry,
2051
- encode2(params.displayName),
2052
- encode2(params.bio),
2053
- encode2(params.avatar)
2054
- );
2055
- return toTxResult(await tx.signAndSubmit(signer));
2056
- }
2057
- /**
2058
- * Lists the caller's alias for sale on the alias marketplace.
2059
- * Extrinsic: accountMapping.putAliasOnSale(price, isPrivate)
2060
- */
2061
- async putAliasOnSale(params, signer) {
2062
- const entry = resolveTx(this.substrate.unsafe, "accountMapping", "putAliasOnSale");
2063
- const tx = callUnsafeTx(entry, params.price.toString(), params.isPrivate);
2064
- return toTxResult(await tx.signAndSubmit(signer));
2065
- }
2066
- /**
2067
- * Cancels an active alias sale listing.
2068
- * Extrinsic: accountMapping.cancelSale()
2069
- */
2070
- async cancelSale(signer) {
2071
- const entry = resolveTx(this.substrate.unsafe, "accountMapping", "cancelSale");
2072
- const tx = callUnsafeTx(entry);
2073
- return toTxResult(await tx.signAndSubmit(signer));
2074
- }
2075
- /**
2076
- * Purchases an alias listed for sale.
2077
- * Extrinsic: accountMapping.buyAlias(alias)
2078
- */
2079
- async buyAlias(alias, signer) {
2080
- const entry = resolveTx(this.substrate.unsafe, "accountMapping", "buyAlias");
2081
- const tx = callUnsafeTx(entry, Binary2.fromText(alias));
2082
- return toTxResult(await tx.signAndSubmit(signer));
2083
- }
2084
- /**
2085
- * Dispatches an arbitrary call on behalf of a linked external-chain wallet.
2086
- *
2087
- * This is the "Universal Proxy" feature that allows EVM/Solana wallets to
2088
- * authorize on-chain actions without holding a Substrate private key.
2089
- *
2090
- * The relayer (who pays gas) calls this with the external wallet's signature
2091
- * over the encoded call payload and the owner's AccountId32.
2092
- *
2093
- * Extrinsic: accountMapping.dispatchAsLinkedAccount(owner, chainId, address, signature, call)
2094
- */
2095
- async dispatchAsLinkedAccount(params, signer) {
2096
- const entry = resolveTx(this.substrate.unsafe, "accountMapping", "dispatchAsLinkedAccount");
2097
- const tx = callUnsafeTx(
2098
- entry,
2099
- params.owner,
2100
- params.chainId,
2101
- params.address,
2102
- params.signature,
2103
- params.callData
2104
- );
2105
- return toTxResult(await tx.signAndSubmit(signer));
2106
- }
2107
- };
2108
-
2109
1726
  // src/rpc-v2/ChainModule.ts
2110
1727
  var ChainModule = class {
2111
1728
  constructor(substrate) {
@@ -2148,7 +1765,8 @@ var PrivacyModule = class {
2148
1765
  return {
2149
1766
  path: raw.path,
2150
1767
  leafIndex: raw.leaf_index,
2151
- treeDepth: raw.tree_depth
1768
+ treeDepth: raw.tree_depth,
1769
+ treeId: raw.tree_id
2152
1770
  };
2153
1771
  }
2154
1772
  /**
@@ -2168,6 +1786,7 @@ var PrivacyModule = class {
2168
1786
  path: raw.path,
2169
1787
  leafIndex: raw.leaf_index,
2170
1788
  treeDepth: raw.tree_depth,
1789
+ treeId: raw.tree_id,
2171
1790
  root: raw.root
2172
1791
  };
2173
1792
  }
@@ -2475,20 +2094,6 @@ function decodeUint(data, offset = 0) {
2475
2094
  }
2476
2095
  return result;
2477
2096
  }
2478
- function decodeAddress2(data, offset = 0) {
2479
- return "0x" + toHex(data.slice(offset + 12, offset + 32)).slice(2);
2480
- }
2481
- function decodeBool(data, offset = 0) {
2482
- return data[offset + 31] !== 0;
2483
- }
2484
- function decodeBytes(data, slotOffset = 0) {
2485
- const dataOffset = Number(decodeUint(data, slotOffset));
2486
- const length = Number(decodeUint(data, dataOffset));
2487
- return data.slice(dataOffset + 32, dataOffset + 32 + length);
2488
- }
2489
- function decodeString(data, slotOffset = 0) {
2490
- return new TextDecoder().decode(decodeBytes(data, slotOffset));
2491
- }
2492
2097
 
2493
2098
  // src/precompiles/addresses.ts
2494
2099
  var PRECOMPILE_ADDR = {
@@ -2504,48 +2109,8 @@ var PRECOMPILE_ADDR = {
2504
2109
  CURVE25519_ADD: "0x0000000000000000000000000000000000000402",
2505
2110
  CURVE25519_SCALAR_MUL: "0x0000000000000000000000000000000000000403",
2506
2111
  // ── Orbinum custom ───────────────────────────────────────────────────────
2507
- ACCOUNT_MAPPING: "0x0000000000000000000000000000000000000800",
2508
2112
  SHIELDED_POOL: "0x0000000000000000000000000000000000000801"
2509
2113
  };
2510
- var AM_SEL = {
2511
- // ── Read-only ─────────────────────────────────────────────────────────────
2512
- // resolveAlias(string) → 0xd03149ab
2513
- RESOLVE_ALIAS: new Uint8Array([208, 49, 73, 171]),
2514
- // getAliasOf(address) → 0x7a0ed62c
2515
- GET_ALIAS_OF: new Uint8Array([122, 14, 214, 44]),
2516
- // hasPrivateLink(string,bytes32) → 0x47e05c6c
2517
- HAS_PRIVATE_LINK: new Uint8Array([71, 224, 92, 108]),
2518
- // ── No-argument writes ────────────────────────────────────────────────────
2519
- // mapAccount() → 0xdca49d0e
2520
- MAP_ACCOUNT: new Uint8Array([220, 164, 157, 14]),
2521
- // unmapAccount() → 0x08f57367
2522
- UNMAP_ACCOUNT: new Uint8Array([8, 245, 115, 103]),
2523
- // releaseAlias() → 0x7fac359e
2524
- RELEASE_ALIAS: new Uint8Array([127, 172, 53, 158]),
2525
- // cancelSale() → 0x4d023ab9
2526
- CANCEL_SALE: new Uint8Array([77, 2, 58, 185]),
2527
- // ── Writes with arguments ─────────────────────────────────────────────────
2528
- // registerAlias(string) → 0x2f8839c3
2529
- REGISTER_ALIAS: new Uint8Array([47, 136, 57, 195]),
2530
- // transferAlias(address) → 0x5ac998e7
2531
- TRANSFER_ALIAS: new Uint8Array([90, 201, 152, 231]),
2532
- // buyAlias(string) → 0x1625df3a
2533
- BUY_ALIAS: new Uint8Array([22, 37, 223, 58]),
2534
- // putAliasOnSale(uint256,address[]) → 0x32091192
2535
- PUT_ALIAS_ON_SALE: new Uint8Array([50, 9, 17, 146]),
2536
- // removeChainLink(uint32) → 0x6f579c0c
2537
- REMOVE_CHAIN_LINK: new Uint8Array([111, 87, 156, 12]),
2538
- // addChainLink(uint32,bytes,bytes) → 0x5f3e837c
2539
- ADD_CHAIN_LINK: new Uint8Array([95, 62, 131, 124]),
2540
- // registerPrivateLink(uint32,bytes32) → 0xc04e98f4
2541
- REGISTER_PRIVATE_LINK: new Uint8Array([192, 78, 152, 244]),
2542
- // removePrivateLink(bytes32) → 0xdfd8b57e
2543
- REMOVE_PRIVATE_LINK: new Uint8Array([223, 216, 181, 126]),
2544
- // revealPrivateLink(bytes32,bytes,bytes32,bytes) → 0x4df1f33d
2545
- REVEAL_PRIVATE_LINK: new Uint8Array([77, 241, 243, 61]),
2546
- // setAccountMetadata(bytes,bytes,bytes) → 0x776cf9ff
2547
- SET_ACCOUNT_METADATA: new Uint8Array([119, 108, 249, 255])
2548
- };
2549
2114
  var SP_SEL = {
2550
2115
  // shield(uint32,bytes32,bytes) → 0x9feb22ea (payable, amount = msg.value)
2551
2116
  SHIELD: new Uint8Array([159, 235, 34, 234]),
@@ -2572,28 +2137,6 @@ var KNOWN_PRECOMPILES = {
2572
2137
  "0x0000000000000000000000000000000000000402": { name: "Curve25519Add", functions: {} },
2573
2138
  "0x0000000000000000000000000000000000000403": { name: "Curve25519ScalarMul", functions: {} },
2574
2139
  // ── Orbinum custom ───────────────────────────────────────────────────────
2575
- "0x0000000000000000000000000000000000000800": {
2576
- name: "AccountMapping",
2577
- functions: {
2578
- d03149ab: "resolveAlias(string)",
2579
- "7a0ed62c": "getAliasOf(address)",
2580
- "47e05c6c": "hasPrivateLink(string,bytes32)",
2581
- dca49d0e: "mapAccount()",
2582
- "08f57367": "unmapAccount()",
2583
- "7fac359e": "releaseAlias()",
2584
- "4d023ab9": "cancelSale()",
2585
- "2f8839c3": "registerAlias(string)",
2586
- "5ac998e7": "transferAlias(address)",
2587
- "1625df3a": "buyAlias(string)",
2588
- "32091192": "putAliasOnSale(uint256,address[])",
2589
- "6f579c0c": "removeChainLink(uint32)",
2590
- "5f3e837c": "addChainLink(uint32,bytes,bytes)",
2591
- c04e98f4: "registerPrivateLink(uint32,bytes32)",
2592
- dfd8b57e: "removePrivateLink(bytes32)",
2593
- "4df1f33d": "revealPrivateLink(bytes32,bytes,bytes32,bytes)",
2594
- "776cf9ff": "setAccountMetadata(bytes,bytes,bytes)"
2595
- }
2596
- },
2597
2140
  "0x0000000000000000000000000000000000000801": {
2598
2141
  name: "ShieldedPool",
2599
2142
  functions: {
@@ -2842,266 +2385,6 @@ var ShieldedPoolPrecompile = class {
2842
2385
  }
2843
2386
  };
2844
2387
 
2845
- // src/precompiles/AccountMappingPrecompile.ts
2846
- var AccountMappingPrecompile = class {
2847
- constructor(evm) {
2848
- this.evm = evm;
2849
- }
2850
- evm;
2851
- addr = PRECOMPILE_ADDR.ACCOUNT_MAPPING;
2852
- // ─── Read-only ─────────────────────────────────────────────────────────────
2853
- /**
2854
- * Resolves `@alias` to its owner EVM address (and optionally a secondary EVM address).
2855
- *
2856
- * Returns `(address owner, address evmAddress)` — two 32-byte ABI-encoded slots.
2857
- * `evmAddress` is zero-address (`0x000...0`) if the owner has no explicit EVM address.
2858
- */
2859
- async resolveAlias(alias) {
2860
- try {
2861
- const data = encodeHex(AM_SEL.RESOLVE_ALIAS, { type: "string", value: alias });
2862
- const raw = fromHex(await this.evm.call(this.addr, data));
2863
- if (raw.length < 64) return null;
2864
- const owner = decodeAddress2(raw, 0);
2865
- const evm = decodeAddress2(raw, 32);
2866
- const ZERO = "0x0000000000000000000000000000000000000000";
2867
- return {
2868
- owner,
2869
- evmAddress: evm === ZERO ? null : normalizeEvmAddress(evm)
2870
- };
2871
- } catch {
2872
- return null;
2873
- }
2874
- }
2875
- /**
2876
- * Returns the alias registered for the given EVM address, or null.
2877
- * The precompile ABI encodes the alias as `bytes` (UTF-8).
2878
- */
2879
- async getAliasOf(evmAddress) {
2880
- try {
2881
- const data = encodeHex(AM_SEL.GET_ALIAS_OF, {
2882
- type: "address",
2883
- value: normalizeEvmAddress(evmAddress)
2884
- });
2885
- const raw = fromHex(await this.evm.call(this.addr, data));
2886
- if (raw.length === 0) return null;
2887
- const alias = decodeString(raw, 0);
2888
- return alias.length > 0 ? alias : null;
2889
- } catch {
2890
- return null;
2891
- }
2892
- }
2893
- /**
2894
- * Returns true if the given Poseidon commitment is registered as a private
2895
- * link for the given alias.
2896
- */
2897
- async hasPrivateLink(alias, commitment) {
2898
- try {
2899
- const commitmentBytes = fromHex(ensureHexPrefix(commitment));
2900
- const data = encodeHex(
2901
- AM_SEL.HAS_PRIVATE_LINK,
2902
- { type: "string", value: alias },
2903
- { type: "bytes32", value: commitmentBytes }
2904
- );
2905
- const raw = fromHex(await this.evm.call(this.addr, data));
2906
- if (raw.length < 32) return false;
2907
- return decodeBool(raw, 0);
2908
- } catch {
2909
- return false;
2910
- }
2911
- }
2912
- // ─── No-arg writes ─────────────────────────────────────────────────────────
2913
- /**
2914
- * Creates an explicit EVM → Substrate account mapping for the signer's address.
2915
- * Extrinsic: `accountMapping.mapAccount()`
2916
- */
2917
- async mapAccount(signer) {
2918
- return signer({ to: this.addr, data: encodeHex(AM_SEL.MAP_ACCOUNT) });
2919
- }
2920
- /**
2921
- * Removes the EVM → Substrate mapping for the signer's address.
2922
- * Extrinsic: `accountMapping.unmapAccount()`
2923
- */
2924
- async unmapAccount(signer) {
2925
- return signer({ to: this.addr, data: encodeHex(AM_SEL.UNMAP_ACCOUNT) });
2926
- }
2927
- /**
2928
- * Releases the signer's registered alias, recovering the deposit.
2929
- * Extrinsic: `accountMapping.releaseAlias()`
2930
- */
2931
- async releaseAlias(signer) {
2932
- return signer({ to: this.addr, data: encodeHex(AM_SEL.RELEASE_ALIAS) });
2933
- }
2934
- /**
2935
- * Cancels an active alias sale listing.
2936
- * Extrinsic: `accountMapping.cancelSale()`
2937
- */
2938
- async cancelSale(signer) {
2939
- return signer({ to: this.addr, data: encodeHex(AM_SEL.CANCEL_SALE) });
2940
- }
2941
- // ─── Writes with arguments ─────────────────────────────────────────────────
2942
- /**
2943
- * Registers a unique @alias for the signer's account.
2944
- * Requires a deposit. The alias must be 3–32 ASCII lowercase alphanumeric chars + hyphens.
2945
- * Extrinsic: `accountMapping.registerAlias(alias)`
2946
- */
2947
- async registerAlias(alias, signer) {
2948
- const data = encodeHex(AM_SEL.REGISTER_ALIAS, { type: "string", value: alias });
2949
- return signer({ to: this.addr, data });
2950
- }
2951
- /**
2952
- * Transfers the signer's alias to a new EVM `owner` address.
2953
- * Extrinsic: `accountMapping.transferAlias(newOwner)`
2954
- */
2955
- async transferAlias(newOwnerEvmAddress, signer) {
2956
- const data = encodeHex(AM_SEL.TRANSFER_ALIAS, {
2957
- type: "address",
2958
- value: normalizeEvmAddress(newOwnerEvmAddress)
2959
- });
2960
- return signer({ to: this.addr, data });
2961
- }
2962
- /**
2963
- * Purchases an alias currently listed for sale.
2964
- * Extrinsic: `accountMapping.buyAlias(alias)`
2965
- */
2966
- async buyAlias(alias, signer) {
2967
- const data = encodeHex(AM_SEL.BUY_ALIAS, { type: "string", value: alias });
2968
- return signer({ to: this.addr, data });
2969
- }
2970
- /**
2971
- * Lists the signer's alias for sale on the alias marketplace.
2972
- *
2973
- * @param price Asking price in planck (ORB).
2974
- * @param allowedBuyers Whitelist of EVM addresses allowed to buy.
2975
- * Pass an empty array for a public (open) listing.
2976
- * Extrinsic: `accountMapping.putAliasOnSale(price, allowedBuyers)`
2977
- */
2978
- async putAliasOnSale(price, allowedBuyers, signer) {
2979
- const data = encodeHex(
2980
- AM_SEL.PUT_ALIAS_ON_SALE,
2981
- { type: "uint", value: price },
2982
- { type: "address[]", value: allowedBuyers.map(normalizeEvmAddress) }
2983
- );
2984
- return signer({ to: this.addr, data });
2985
- }
2986
- /**
2987
- * Removes the external-chain link for the given chain ID.
2988
- * Extrinsic: `accountMapping.removeChainLink(chainId)`
2989
- */
2990
- async removeChainLink(chainId, signer) {
2991
- const data = encodeHex(AM_SEL.REMOVE_CHAIN_LINK, { type: "uint", value: BigInt(chainId) });
2992
- return signer({ to: this.addr, data });
2993
- }
2994
- /**
2995
- * Adds a verified public link to an external-chain wallet.
2996
- *
2997
- * @param chainId Orbinum chain ID (use `SLIP0044_NAMESPACE | coinType` for SLIP-0044).
2998
- * @param externalAddr External wallet address bytes (20 bytes for EVM, 32 for Solana).
2999
- * @param signature Signature over the caller's AccountId32:
3000
- * - EIP-191 (EVM): 65 bytes over keccak256("\x19Ethereum Signed Message:\n32" + accountId32)
3001
- * - Ed25519 (Solana): 64 bytes over the raw accountId32 bytes
3002
- *
3003
- * Extrinsic: `accountMapping.addChainLink(chainId, address, signature)`
3004
- */
3005
- async addChainLink(chainId, externalAddr, signature, signer) {
3006
- const data = encodeHex(
3007
- AM_SEL.ADD_CHAIN_LINK,
3008
- { type: "uint", value: BigInt(chainId) },
3009
- { type: "bytes", value: externalAddr },
3010
- { type: "bytes", value: signature }
3011
- );
3012
- return signer({ to: this.addr, data });
3013
- }
3014
- /**
3015
- * Registers a private chain link — only the Poseidon commitment is stored.
3016
- * The real external address is never revealed on-chain.
3017
- *
3018
- * @param chainId External chain ID.
3019
- * @param commitment 0x-prefixed 32-byte Poseidon commitment hex.
3020
- *
3021
- * Extrinsic: `accountMapping.registerPrivateLink(chainId, commitment)`
3022
- */
3023
- async registerPrivateLink(chainId, commitment, signer) {
3024
- const commitmentBytes = fromHex(
3025
- commitment.startsWith("0x") ? commitment : "0x" + commitment
3026
- );
3027
- const data = encodeHex(
3028
- AM_SEL.REGISTER_PRIVATE_LINK,
3029
- { type: "uint", value: BigInt(chainId) },
3030
- { type: "bytes32", value: commitmentBytes }
3031
- );
3032
- return signer({ to: this.addr, data });
3033
- }
3034
- /**
3035
- * Removes a private link by its commitment.
3036
- * Extrinsic: `accountMapping.removePrivateLink(commitment)`
3037
- */
3038
- async removePrivateLink(commitment, signer) {
3039
- const commitmentBytes = fromHex(
3040
- commitment.startsWith("0x") ? commitment : "0x" + commitment
3041
- );
3042
- const data = encodeHex(AM_SEL.REMOVE_PRIVATE_LINK, {
3043
- type: "bytes32",
3044
- value: commitmentBytes
3045
- });
3046
- return signer({ to: this.addr, data });
3047
- }
3048
- /**
3049
- * Reveals a private link publicly by providing the real address and blinding.
3050
- * After this call the link becomes a public chain link.
3051
- *
3052
- * @param commitment 32-byte commitment hex.
3053
- * @param address External address bytes (the actual wallet address).
3054
- * @param blinding 32-byte blinding factor used when computing the commitment.
3055
- * @param signature Signature over the AccountId32 bytes (same rules as `addChainLink`).
3056
- *
3057
- * Extrinsic: `accountMapping.revealPrivateLink(commitment, address, blinding, signature)`
3058
- */
3059
- async revealPrivateLink(commitment, address, blinding, signature, signer) {
3060
- const commitmentBytes = fromHex(
3061
- commitment.startsWith("0x") ? commitment : "0x" + commitment
3062
- );
3063
- const blindingBytes = fromHex(blinding.startsWith("0x") ? blinding : "0x" + blinding);
3064
- const data = encodeHex(
3065
- AM_SEL.REVEAL_PRIVATE_LINK,
3066
- { type: "bytes32", value: commitmentBytes },
3067
- { type: "bytes", value: address },
3068
- { type: "bytes32", value: blindingBytes },
3069
- { type: "bytes", value: signature }
3070
- );
3071
- return signer({ to: this.addr, data });
3072
- }
3073
- /**
3074
- * Updates the signer's public profile metadata.
3075
- * Pass `null` for any field to leave it unchanged.
3076
- }
3077
- displayName: string | null,
3078
- bio: string | null,
3079
- avatar: string | null,
3080
- signer: EvmSigner
3081
- ): Promise<string> {
3082
- const enc = (v: string | null): Uint8Array =>
3083
- v != null ? new TextEncoder().encode(v) : new Uint8Array(0);
3084
- const data = encodeHex(
3085
- AM_SEL.SET_ACCOUNT_METADATA,
3086
- { type: 'bytes', value: enc(displayName) },
3087
- { type: 'bytes', value: enc(bio) },
3088
- { type: 'bytes', value: enc(avatar) }
3089
- );
3090
- return signer({ to: this.addr, data });
3091
- }
3092
-
3093
- // ─── Calldata builders (for custom signing / batching) ─────────────────────
3094
-
3095
- /** Returns the raw ABI-encoded calldata for `registerAlias`. */
3096
- buildRegisterAliasCalldata(alias) {
3097
- return encodeHex(AM_SEL.REGISTER_ALIAS, { type: "string", value: alias });
3098
- }
3099
- /** Returns the raw ABI-encoded calldata for `mapAccount`. */
3100
- buildMapAccountCalldata() {
3101
- return encodeHex(AM_SEL.MAP_ACCOUNT);
3102
- }
3103
- };
3104
-
3105
2388
  // src/precompiles/CryptoPrecompiles.ts
3106
2389
  var CryptoPrecompiles = class {
3107
2390
  constructor(evm) {
@@ -3229,8 +2512,6 @@ var OrbinumClient = class _OrbinumClient {
3229
2512
  evmExplorer;
3230
2513
  /** Shielded-pool extrinsics and Merkle tree queries (`shield`, `unshield`, `privateTransfer`, …). */
3231
2514
  shieldedPool;
3232
- /** Account-mapping extrinsics: aliases, chain links, metadata, marketplace, and identity. */
3233
- accountMapping;
3234
2515
  /** Typed access to `privacy_*` custom RPC endpoints. */
3235
2516
  privacy;
3236
2517
  /** Typed access to general chain state via `chain_*` custom RPC endpoints. */
@@ -3255,7 +2536,6 @@ var OrbinumClient = class _OrbinumClient {
3255
2536
  this.evm = evm;
3256
2537
  this.evmExplorer = evm ? new EvmExplorer(evm) : null;
3257
2538
  this.shieldedPool = new ShieldedPoolModule(substrate);
3258
- this.accountMapping = new AccountMappingModule(substrate);
3259
2539
  this.privacy = new PrivacyModule(substrate);
3260
2540
  this.chain = new ChainModule(substrate);
3261
2541
  this.zkVerifier = new ZkVerifierModule(substrate);
@@ -3263,7 +2543,6 @@ var OrbinumClient = class _OrbinumClient {
3263
2543
  this.relayerStatus = new RelayerStatusModule(substrate);
3264
2544
  this.precompiles = evm ? {
3265
2545
  shieldedPool: new ShieldedPoolPrecompile(evm),
3266
- accountMapping: new AccountMappingPrecompile(evm),
3267
2546
  crypto: new CryptoPrecompiles(evm)
3268
2547
  } : null;
3269
2548
  }
@@ -4596,13 +3875,6 @@ async function generateFeeClaimProof(inputs, options = {}) {
4596
3875
  };
4597
3876
  }
4598
3877
 
4599
- // src/account-mapping/types/index.ts
4600
- var SignatureScheme = {
4601
- Eip191: "Eip191",
4602
- Ed25519: "Ed25519"
4603
- };
4604
- var SLIP0044_NAMESPACE = 2147483648;
4605
-
4606
3878
  // src/precompiles/decode.ts
4607
3879
  function decodePrecompileCalldata(address, input) {
4608
3880
  const info = KNOWN_PRECOMPILES[address.toLowerCase()];
@@ -4610,15 +3882,6 @@ function decodePrecompileCalldata(address, input) {
4610
3882
  const selector = input.slice(2, 10).toLowerCase();
4611
3883
  const fnSig = info.functions[selector];
4612
3884
  if (!fnSig) return null;
4613
- if (fnSig.startsWith("registerAlias")) {
4614
- try {
4615
- const data = fromHex(input.slice(10));
4616
- const alias = decodeString(data, 0);
4617
- return { fnSig, args: { alias } };
4618
- } catch {
4619
- return { fnSig, args: {} };
4620
- }
4621
- }
4622
3885
  if (fnSig.startsWith("shield(")) {
4623
3886
  try {
4624
3887
  const data = fromHex(input.slice(10));
@@ -4692,7 +3955,6 @@ function decodePrecompileCalldata(address, input) {
4692
3955
  var CircuitId = {
4693
3956
  Transfer: 1,
4694
3957
  Unshield: 2,
4695
- PrivateLink: 5,
4696
3958
  ValueProof: 6
4697
3959
  };
4698
3960
 
@@ -4949,84 +4211,6 @@ function mapExtrinsicArgs(section, method, args) {
4949
4211
  };
4950
4212
  }
4951
4213
  }
4952
- if (s === "accountmapping") {
4953
- const m_norm = m.replace(/_/g, "");
4954
- if (m_norm === "registeralias") {
4955
- return { alias: get(0, "alias") };
4956
- }
4957
- if (m_norm === "transferalias") {
4958
- return { new_owner: get(0, "new_owner") };
4959
- }
4960
- if (m_norm === "putaliasonsale") {
4961
- return {
4962
- price: get(0, "price"),
4963
- allowed_buyers: get(1, "allowed_buyers")
4964
- };
4965
- }
4966
- if (m_norm === "buyalias") {
4967
- return { alias: get(0, "alias") };
4968
- }
4969
- if (m_norm === "addchainlink") {
4970
- return {
4971
- chain_id: get(0, "chain_id"),
4972
- address: get(1, "address"),
4973
- signature: get(2, "signature")
4974
- };
4975
- }
4976
- if (m_norm === "removechainlink") {
4977
- return { chain_id: get(0, "chain_id") };
4978
- }
4979
- if (m_norm === "setaccountmetadata") {
4980
- return {
4981
- display_name: get(0, "display_name"),
4982
- bio: get(1, "bio"),
4983
- avatar: get(2, "avatar")
4984
- };
4985
- }
4986
- if (m_norm === "addsupportedchain") {
4987
- return {
4988
- chain_id: get(0, "chain_id"),
4989
- scheme: get(1, "scheme")
4990
- };
4991
- }
4992
- if (m_norm === "removesupportedchain") {
4993
- return { chain_id: get(0, "chain_id") };
4994
- }
4995
- if (m_norm === "dispatchaslinkedaccount") {
4996
- return {
4997
- owner: get(0, "owner"),
4998
- chain_id: get(1, "chain_id"),
4999
- address: get(2, "address"),
5000
- signature: get(3, "signature"),
5001
- call: get(4, "call")
5002
- };
5003
- }
5004
- if (m_norm === "registerprivatelink") {
5005
- return {
5006
- chain_id: get(0, "chain_id"),
5007
- commitment: get(1, "commitment")
5008
- };
5009
- }
5010
- if (m_norm === "removeprivatelink") {
5011
- return { commitment: get(0, "commitment") };
5012
- }
5013
- if (m_norm === "revealprivatelink") {
5014
- return {
5015
- commitment: get(0, "commitment"),
5016
- address: get(1, "address"),
5017
- blinding: get(2, "blinding"),
5018
- signature: get(3, "signature")
5019
- };
5020
- }
5021
- if (m_norm === "dispatchasprivatelink") {
5022
- return {
5023
- owner: get(0, "owner"),
5024
- commitment: get(1, "commitment"),
5025
- zk_proof: get(2, "zk_proof"),
5026
- call: get(3, "call")
5027
- };
5028
- }
5029
- }
5030
4214
  if (s === "zkverifier") {
5031
4215
  const m_norm = m.replace(/_/g, "");
5032
4216
  if (m_norm === "batchregisterverificationkeys") {
@@ -5128,106 +4312,6 @@ function mapZkEventData(method, data) {
5128
4312
  if (m_norm === "assetunverified") {
5129
4313
  return { asset_id: get(0, "asset_id") };
5130
4314
  }
5131
- if (m_norm === "accountmapped" || m_norm === "accountunmapped") {
5132
- return {
5133
- account: get(0, "account"),
5134
- address: get(1, "address")
5135
- };
5136
- }
5137
- if (m_norm === "aliasregistered") {
5138
- return {
5139
- account: get(0, "account"),
5140
- alias: get(1, "alias"),
5141
- evm_address: get(2, "evm_address")
5142
- };
5143
- }
5144
- if (m_norm === "aliasreleased") {
5145
- return {
5146
- account: get(0, "account"),
5147
- alias: get(1, "alias")
5148
- };
5149
- }
5150
- if (m_norm === "aliastransferred") {
5151
- return {
5152
- from: get(0, "from"),
5153
- to: get(1, "to"),
5154
- alias: get(2, "alias")
5155
- };
5156
- }
5157
- if (m_norm === "aliaslistedforsale") {
5158
- return {
5159
- seller: get(0, "seller"),
5160
- alias: get(1, "alias"),
5161
- price: get(2, "price"),
5162
- private: get(3, "private")
5163
- };
5164
- }
5165
- if (m_norm === "aliassalecancelled") {
5166
- return {
5167
- seller: get(0, "seller"),
5168
- alias: get(1, "alias")
5169
- };
5170
- }
5171
- if (m_norm === "aliassold") {
5172
- return {
5173
- seller: get(0, "seller"),
5174
- buyer: get(1, "buyer"),
5175
- alias: get(2, "alias"),
5176
- price: get(3, "price")
5177
- };
5178
- }
5179
- if (m_norm === "chainlinkadded") {
5180
- return {
5181
- account: get(0, "account"),
5182
- chain_id: get(1, "chain_id"),
5183
- address: get(2, "address")
5184
- };
5185
- }
5186
- if (m_norm === "chainlinkremoved") {
5187
- return {
5188
- account: get(0, "account"),
5189
- chain_id: get(1, "chain_id")
5190
- };
5191
- }
5192
- if (m_norm === "metadataupdated") {
5193
- return { account: get(0, "account") };
5194
- }
5195
- if (m_norm === "supportedchainadded") {
5196
- return {
5197
- chain_id: get(0, "chain_id"),
5198
- scheme: get(1, "scheme")
5199
- };
5200
- }
5201
- if (m_norm === "supportedchainremoved") {
5202
- return { chain_id: get(0, "chain_id") };
5203
- }
5204
- if (m_norm === "proxycallexecuted") {
5205
- return {
5206
- owner: get(0, "owner"),
5207
- chain_id: get(1, "chain_id"),
5208
- address: get(2, "address")
5209
- };
5210
- }
5211
- if (m_norm === "privatechainlinkadded" || m_norm === "privatechainlinkremoved") {
5212
- return {
5213
- account: get(0, "account"),
5214
- chain_id: get(1, "chain_id"),
5215
- commitment: get(2, "commitment")
5216
- };
5217
- }
5218
- if (m_norm === "privatechainlinkrevealed") {
5219
- return {
5220
- account: get(0, "account"),
5221
- chain_id: get(1, "chain_id"),
5222
- address: get(2, "address")
5223
- };
5224
- }
5225
- if (m_norm === "privatelinkdispatchexecuted") {
5226
- return {
5227
- owner: get(0, "owner"),
5228
- commitment: get(1, "commitment")
5229
- };
5230
- }
5231
4315
  if (m_norm === "verificationkeyregistered" || m_norm === "activeversionset" || m_norm === "verificationkeyremoved" || m_norm === "proofverified" || m_norm === "proofverificationfailed") {
5232
4316
  return {
5233
4317
  circuit_id: get(0, "circuit_id"),
@@ -5370,8 +4454,6 @@ import {
5370
4454
  import { getSs58AddressInfo as getSs58AddressInfo2 } from "polkadot-api";
5371
4455
  export {
5372
4456
  AccountId2 as AccountId,
5373
- AccountMappingModule,
5374
- AccountMappingPrecompile,
5375
4457
  BABYJUB_SUBORDER,
5376
4458
  BN254_R,
5377
4459
  Blake2256,
@@ -5394,12 +4476,10 @@ export {
5394
4476
  PrivacyKeyManager,
5395
4477
  PrivacyModule,
5396
4478
  RelayerStatusModule,
5397
- SLIP0044_NAMESPACE,
5398
4479
  SPENDING_KEY_VERIFYING_CONTRACT,
5399
4480
  SPENDING_KEY_WARNING,
5400
4481
  ShieldedPoolModule,
5401
4482
  ShieldedPoolPrecompile,
5402
- SignatureScheme,
5403
4483
  Storage,
5404
4484
  SubstrateClient,
5405
4485
  VaultLockedError,