@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/README.md +0 -1
- package/dist/index.d.mts +10 -937
- package/dist/index.d.ts +10 -937
- package/dist/index.js +8 -932
- package/dist/index.mjs +4 -924
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21,8 +21,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
AccountId: () => import_substrate_bindings3.AccountId,
|
|
24
|
-
AccountMappingModule: () => AccountMappingModule,
|
|
25
|
-
AccountMappingPrecompile: () => AccountMappingPrecompile,
|
|
26
24
|
BABYJUB_SUBORDER: () => BABYJUB_SUBORDER,
|
|
27
25
|
BN254_R: () => BN254_R,
|
|
28
26
|
Blake2256: () => import_substrate_bindings3.Blake2256,
|
|
@@ -45,12 +43,10 @@ __export(index_exports, {
|
|
|
45
43
|
PrivacyKeyManager: () => PrivacyKeyManager,
|
|
46
44
|
PrivacyModule: () => PrivacyModule,
|
|
47
45
|
RelayerStatusModule: () => RelayerStatusModule,
|
|
48
|
-
SLIP0044_NAMESPACE: () => SLIP0044_NAMESPACE,
|
|
49
46
|
SPENDING_KEY_VERIFYING_CONTRACT: () => SPENDING_KEY_VERIFYING_CONTRACT,
|
|
50
47
|
SPENDING_KEY_WARNING: () => SPENDING_KEY_WARNING,
|
|
51
48
|
ShieldedPoolModule: () => ShieldedPoolModule,
|
|
52
49
|
ShieldedPoolPrecompile: () => ShieldedPoolPrecompile,
|
|
53
|
-
SignatureScheme: () => SignatureScheme,
|
|
54
50
|
Storage: () => import_substrate_bindings3.Storage,
|
|
55
51
|
SubstrateClient: () => SubstrateClient,
|
|
56
52
|
VaultLockedError: () => VaultLockedError,
|
|
@@ -107,7 +103,7 @@ __export(index_exports, {
|
|
|
107
103
|
getPolkadotSigner: () => import_signer.getPolkadotSigner,
|
|
108
104
|
getPolkadotSignerFromPjs: () => import_pjs_signer.getPolkadotSignerFromPjs,
|
|
109
105
|
getPrecompileLabel: () => getPrecompileLabel,
|
|
110
|
-
getSs58AddressInfo: () =>
|
|
106
|
+
getSs58AddressInfo: () => import_polkadot_api4.getSs58AddressInfo,
|
|
111
107
|
hexToBigint: () => hexToBigint,
|
|
112
108
|
hexToNumber: () => hexToNumber,
|
|
113
109
|
implicitSubstrateToEvm: () => implicitSubstrateToEvm,
|
|
@@ -283,7 +279,7 @@ var SubstrateClient = class _SubstrateClient {
|
|
|
283
279
|
}
|
|
284
280
|
/**
|
|
285
281
|
* Performs a raw JSON-RPC request. Use this for custom Orbinum RPCs
|
|
286
|
-
* (shieldedPool_*,
|
|
282
|
+
* (shieldedPool_*, privacy_*, etc.).
|
|
287
283
|
*/
|
|
288
284
|
async request(method, params = []) {
|
|
289
285
|
return this._papi._request(method, params);
|
|
@@ -1864,389 +1860,6 @@ var ShieldedPoolModule = class {
|
|
|
1864
1860
|
}
|
|
1865
1861
|
};
|
|
1866
1862
|
|
|
1867
|
-
// src/account-mapping/AccountMappingModule.ts
|
|
1868
|
-
var import_polkadot_api3 = require("polkadot-api");
|
|
1869
|
-
|
|
1870
|
-
// src/account-mapping/helpers.ts
|
|
1871
|
-
function mapRawScheme(raw) {
|
|
1872
|
-
if (raw === "Eip191" || raw === "eip191") return "Eip191";
|
|
1873
|
-
if (raw === "Ed25519" || raw === "ed25519") return "Ed25519";
|
|
1874
|
-
return raw;
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
|
-
// src/account-mapping/AccountMappingModule.ts
|
|
1878
|
-
var AccountMappingModule = class {
|
|
1879
|
-
constructor(substrate) {
|
|
1880
|
-
this.substrate = substrate;
|
|
1881
|
-
}
|
|
1882
|
-
substrate;
|
|
1883
|
-
// ─── Address resolution ─────────────────────────────────────────────────────
|
|
1884
|
-
/**
|
|
1885
|
-
* Returns the explicitly mapped (or fallback) Substrate AccountId32 hex for
|
|
1886
|
-
* an EVM address. `mapped` is set only when `map_account` was called.
|
|
1887
|
-
* `fallback` is always the EeSuffix rule: `H160 ++ [0x00; 12]`.
|
|
1888
|
-
*/
|
|
1889
|
-
async getAccountAddresses(accountId) {
|
|
1890
|
-
try {
|
|
1891
|
-
const raw = await this.substrate.request(
|
|
1892
|
-
"accountMapping_getAccountAddresses",
|
|
1893
|
-
[accountId]
|
|
1894
|
-
);
|
|
1895
|
-
return { mapped: raw.mapped ?? null, fallback: raw.fallback ?? null };
|
|
1896
|
-
} catch {
|
|
1897
|
-
return { mapped: null, fallback: null };
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1900
|
-
/**
|
|
1901
|
-
* Returns the explicitly mapped Substrate AccountId32 hex for a given EVM
|
|
1902
|
-
* address, or null if no explicit mapping exists.
|
|
1903
|
-
*/
|
|
1904
|
-
async getMappedAccount(evmAddress) {
|
|
1905
|
-
try {
|
|
1906
|
-
return await this.substrate.request("accountMapping_getMappedAccount", [
|
|
1907
|
-
normalizeEvmAddress(evmAddress)
|
|
1908
|
-
]);
|
|
1909
|
-
} catch {
|
|
1910
|
-
return null;
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
// ─── Alias queries ──────────────────────────────────────────────────────────
|
|
1914
|
-
/**
|
|
1915
|
-
* Resolves "@alias" to basic info (owner, optional EVM address, link count).
|
|
1916
|
-
* Accepts the alias with or without the leading "@".
|
|
1917
|
-
*/
|
|
1918
|
-
async resolveAlias(alias) {
|
|
1919
|
-
try {
|
|
1920
|
-
const raw = await this.substrate.request(
|
|
1921
|
-
"accountMapping_resolveAlias",
|
|
1922
|
-
[alias]
|
|
1923
|
-
);
|
|
1924
|
-
if (!raw) return null;
|
|
1925
|
-
return {
|
|
1926
|
-
owner: raw.substrate_account,
|
|
1927
|
-
evmAddress: raw.evm_address ? normalizeEvmAddress(raw.evm_address) : null,
|
|
1928
|
-
chainLinksCount: raw.chain_links_count
|
|
1929
|
-
};
|
|
1930
|
-
} catch {
|
|
1931
|
-
return null;
|
|
1932
|
-
}
|
|
1933
|
-
}
|
|
1934
|
-
/**
|
|
1935
|
-
* Returns the alias registered for the given Substrate AccountId32 hex, or null.
|
|
1936
|
-
*/
|
|
1937
|
-
async getAliasOf(accountId) {
|
|
1938
|
-
try {
|
|
1939
|
-
return await this.substrate.request("accountMapping_getAliasOf", [
|
|
1940
|
-
accountId
|
|
1941
|
-
]);
|
|
1942
|
-
} catch {
|
|
1943
|
-
return null;
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
// ─── Full identity ──────────────────────────────────────────────────────────
|
|
1947
|
-
/**
|
|
1948
|
-
* Resolves "@alias" to its full identity: owner, EVM address, all public
|
|
1949
|
-
* chain links, and profile metadata.
|
|
1950
|
-
*/
|
|
1951
|
-
async resolveFullIdentity(alias) {
|
|
1952
|
-
try {
|
|
1953
|
-
const raw = await this.substrate.request(
|
|
1954
|
-
"accountMapping_resolveFullIdentity",
|
|
1955
|
-
[alias]
|
|
1956
|
-
);
|
|
1957
|
-
if (!raw) return null;
|
|
1958
|
-
return {
|
|
1959
|
-
owner: raw.owner,
|
|
1960
|
-
evmAddress: raw.evm_address ? normalizeEvmAddress(raw.evm_address) : null,
|
|
1961
|
-
chainLinks: raw.chain_links.map((l) => ({
|
|
1962
|
-
chainId: l.chain_id,
|
|
1963
|
-
address: l.address
|
|
1964
|
-
})),
|
|
1965
|
-
metadata: raw.metadata ? {
|
|
1966
|
-
displayName: raw.metadata.display_name ?? null,
|
|
1967
|
-
bio: raw.metadata.bio ?? null,
|
|
1968
|
-
avatar: raw.metadata.avatar ?? null
|
|
1969
|
-
} : null
|
|
1970
|
-
};
|
|
1971
|
-
} catch {
|
|
1972
|
-
return null;
|
|
1973
|
-
}
|
|
1974
|
-
}
|
|
1975
|
-
/**
|
|
1976
|
-
* Returns the profile metadata for a given Substrate AccountId32 hex, or null.
|
|
1977
|
-
*/
|
|
1978
|
-
async getAccountMetadata(accountId) {
|
|
1979
|
-
try {
|
|
1980
|
-
const raw = await this.substrate.request(
|
|
1981
|
-
"accountMapping_getAccountMetadata",
|
|
1982
|
-
[accountId]
|
|
1983
|
-
);
|
|
1984
|
-
if (!raw) return null;
|
|
1985
|
-
return {
|
|
1986
|
-
displayName: raw.display_name ?? null,
|
|
1987
|
-
bio: raw.bio ?? null,
|
|
1988
|
-
avatar: raw.avatar ?? null
|
|
1989
|
-
};
|
|
1990
|
-
} catch {
|
|
1991
|
-
return null;
|
|
1992
|
-
}
|
|
1993
|
-
}
|
|
1994
|
-
// ─── Chain links ────────────────────────────────────────────────────────────
|
|
1995
|
-
/**
|
|
1996
|
-
* Returns the owner AccountId32 hex of a verified multichain link, or null.
|
|
1997
|
-
*/
|
|
1998
|
-
async getLinkOwner(chainId, address) {
|
|
1999
|
-
try {
|
|
2000
|
-
return await this.substrate.request("accountMapping_getLinkOwner", [
|
|
2001
|
-
chainId,
|
|
2002
|
-
address
|
|
2003
|
-
]);
|
|
2004
|
-
} catch {
|
|
2005
|
-
return null;
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2008
|
-
/**
|
|
2009
|
-
* Returns all blockchain networks supported for verified cross-chain links.
|
|
2010
|
-
*/
|
|
2011
|
-
async getSupportedChains() {
|
|
2012
|
-
try {
|
|
2013
|
-
const raw = await this.substrate.request(
|
|
2014
|
-
"accountMapping_getSupportedChains",
|
|
2015
|
-
[]
|
|
2016
|
-
);
|
|
2017
|
-
return raw.map(([chainId, scheme]) => ({
|
|
2018
|
-
chainId,
|
|
2019
|
-
scheme: mapRawScheme(scheme)
|
|
2020
|
-
}));
|
|
2021
|
-
} catch {
|
|
2022
|
-
return [];
|
|
2023
|
-
}
|
|
2024
|
-
}
|
|
2025
|
-
// ─── Private links ──────────────────────────────────────────────────────────
|
|
2026
|
-
/**
|
|
2027
|
-
* Returns the private link commitments registered for an alias.
|
|
2028
|
-
* Real addresses are never exposed. Returns null if the alias does not exist.
|
|
2029
|
-
*/
|
|
2030
|
-
async getPrivateLinks(alias) {
|
|
2031
|
-
try {
|
|
2032
|
-
const raw = await this.substrate.request(
|
|
2033
|
-
"accountMapping_getPrivateLinks",
|
|
2034
|
-
[alias]
|
|
2035
|
-
);
|
|
2036
|
-
if (!raw) return null;
|
|
2037
|
-
return raw.map((r) => ({ chainId: r.chain_id, commitment: r.commitment }));
|
|
2038
|
-
} catch {
|
|
2039
|
-
return null;
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
/**
|
|
2043
|
-
* Returns true if the given commitment is registered as a private link for the alias.
|
|
2044
|
-
*/
|
|
2045
|
-
async hasPrivateLink(alias, commitment) {
|
|
2046
|
-
try {
|
|
2047
|
-
return await this.substrate.request("accountMapping_hasPrivateLink", [
|
|
2048
|
-
alias,
|
|
2049
|
-
commitment
|
|
2050
|
-
]);
|
|
2051
|
-
} catch {
|
|
2052
|
-
return false;
|
|
2053
|
-
}
|
|
2054
|
-
}
|
|
2055
|
-
// ─── Marketplace ────────────────────────────────────────────────────────────
|
|
2056
|
-
/**
|
|
2057
|
-
* Returns listing info if the alias is currently for sale, or null.
|
|
2058
|
-
*/
|
|
2059
|
-
async getListingInfo(alias) {
|
|
2060
|
-
try {
|
|
2061
|
-
const raw = await this.substrate.request(
|
|
2062
|
-
"accountMapping_getListingInfo",
|
|
2063
|
-
[alias]
|
|
2064
|
-
);
|
|
2065
|
-
if (!raw) return null;
|
|
2066
|
-
return {
|
|
2067
|
-
price: BigInt(raw.price),
|
|
2068
|
-
private: raw.private,
|
|
2069
|
-
whitelistCount: raw.whitelist_count
|
|
2070
|
-
};
|
|
2071
|
-
} catch {
|
|
2072
|
-
return null;
|
|
2073
|
-
}
|
|
2074
|
-
}
|
|
2075
|
-
/**
|
|
2076
|
-
* Returns the alias and its listing if the given account currently has an
|
|
2077
|
-
* alias listed for sale. Returns null otherwise.
|
|
2078
|
-
*/
|
|
2079
|
-
async getAccountListing(accountId) {
|
|
2080
|
-
try {
|
|
2081
|
-
const raw = await this.substrate.request(
|
|
2082
|
-
"accountMapping_getAccountListing",
|
|
2083
|
-
[accountId]
|
|
2084
|
-
);
|
|
2085
|
-
if (!raw) return null;
|
|
2086
|
-
return {
|
|
2087
|
-
alias: raw.alias,
|
|
2088
|
-
listing: {
|
|
2089
|
-
price: BigInt(raw.price),
|
|
2090
|
-
private: raw.private,
|
|
2091
|
-
whitelistCount: raw.whitelist_count
|
|
2092
|
-
}
|
|
2093
|
-
};
|
|
2094
|
-
} catch {
|
|
2095
|
-
return null;
|
|
2096
|
-
}
|
|
2097
|
-
}
|
|
2098
|
-
/**
|
|
2099
|
-
* Returns whether a specific buyer can purchase the given alias right now.
|
|
2100
|
-
*/
|
|
2101
|
-
async canBuy(alias, buyerAccountId) {
|
|
2102
|
-
try {
|
|
2103
|
-
return await this.substrate.request("accountMapping_canBuy", [
|
|
2104
|
-
alias,
|
|
2105
|
-
buyerAccountId
|
|
2106
|
-
]);
|
|
2107
|
-
} catch {
|
|
2108
|
-
return false;
|
|
2109
|
-
}
|
|
2110
|
-
}
|
|
2111
|
-
// ─── Extrinsics ─────────────────────────────────────────────────────────────
|
|
2112
|
-
/**
|
|
2113
|
-
* Creates an explicit EVM → Substrate account mapping.
|
|
2114
|
-
* Stores an explicit `MappedAccounts` entry for the caller's H160.
|
|
2115
|
-
* Extrinsic: accountMapping.mapAccount()
|
|
2116
|
-
*/
|
|
2117
|
-
async mapAccount(signer) {
|
|
2118
|
-
const entry = resolveTx(this.substrate.unsafe, "accountMapping", "mapAccount");
|
|
2119
|
-
const tx = callUnsafeTx(entry);
|
|
2120
|
-
return toTxResult(await tx.signAndSubmit(signer));
|
|
2121
|
-
}
|
|
2122
|
-
/**
|
|
2123
|
-
* Removes the EVM → Substrate mapping for the caller.
|
|
2124
|
-
* Extrinsic: accountMapping.unmapAccount()
|
|
2125
|
-
*/
|
|
2126
|
-
async unmapAccount(signer) {
|
|
2127
|
-
const entry = resolveTx(this.substrate.unsafe, "accountMapping", "unmapAccount");
|
|
2128
|
-
const tx = callUnsafeTx(entry);
|
|
2129
|
-
return toTxResult(await tx.signAndSubmit(signer));
|
|
2130
|
-
}
|
|
2131
|
-
/**
|
|
2132
|
-
* Registers a unique @alias for the caller.
|
|
2133
|
-
* Requires a deposit. The alias must be 3–32 ASCII lowercase alphanumeric chars + hyphens.
|
|
2134
|
-
* Extrinsic: accountMapping.registerAlias(alias)
|
|
2135
|
-
*/
|
|
2136
|
-
async registerAlias(alias, signer) {
|
|
2137
|
-
const entry = resolveTx(this.substrate.unsafe, "accountMapping", "registerAlias");
|
|
2138
|
-
const tx = callUnsafeTx(entry, import_polkadot_api3.Binary.fromText(alias));
|
|
2139
|
-
return toTxResult(await tx.signAndSubmit(signer));
|
|
2140
|
-
}
|
|
2141
|
-
/**
|
|
2142
|
-
* Releases the caller's alias and recovers the deposit.
|
|
2143
|
-
* Extrinsic: accountMapping.releaseAlias()
|
|
2144
|
-
*/
|
|
2145
|
-
async releaseAlias(signer) {
|
|
2146
|
-
const entry = resolveTx(this.substrate.unsafe, "accountMapping", "releaseAlias");
|
|
2147
|
-
const tx = callUnsafeTx(entry);
|
|
2148
|
-
return toTxResult(await tx.signAndSubmit(signer));
|
|
2149
|
-
}
|
|
2150
|
-
/**
|
|
2151
|
-
* Transfers the caller's alias to another account.
|
|
2152
|
-
* Extrinsic: accountMapping.transferAlias(newOwner)
|
|
2153
|
-
*/
|
|
2154
|
-
async transferAlias(newOwnerHex, signer) {
|
|
2155
|
-
const entry = resolveTx(this.substrate.unsafe, "accountMapping", "transferAlias");
|
|
2156
|
-
const tx = callUnsafeTx(entry, newOwnerHex);
|
|
2157
|
-
return toTxResult(await tx.signAndSubmit(signer));
|
|
2158
|
-
}
|
|
2159
|
-
/**
|
|
2160
|
-
* Adds a verified public link to an external-chain wallet.
|
|
2161
|
-
*
|
|
2162
|
-
* `params.signature` must be produced by the external wallet over the caller's
|
|
2163
|
-
* AccountId32 bytes:
|
|
2164
|
-
* - EIP-191 (EVM): sign(keccak256("\x19Ethereum Signed Message:\n32" + accountId32))
|
|
2165
|
-
* - Ed25519 (Solana): sign(accountId32 bytes)
|
|
2166
|
-
*
|
|
2167
|
-
* Extrinsic: accountMapping.addChainLink(chainId, address, signature)
|
|
2168
|
-
*/
|
|
2169
|
-
async addChainLink(params, signer) {
|
|
2170
|
-
const entry = resolveTx(this.substrate.unsafe, "accountMapping", "addChainLink");
|
|
2171
|
-
const tx = callUnsafeTx(entry, params.chainId, params.address, params.signature);
|
|
2172
|
-
return toTxResult(await tx.signAndSubmit(signer));
|
|
2173
|
-
}
|
|
2174
|
-
/**
|
|
2175
|
-
* Removes the external-chain link for the given chain ID.
|
|
2176
|
-
* Extrinsic: accountMapping.removeChainLink(chainId)
|
|
2177
|
-
*/
|
|
2178
|
-
async removeChainLink(chainId, signer) {
|
|
2179
|
-
const entry = resolveTx(this.substrate.unsafe, "accountMapping", "removeChainLink");
|
|
2180
|
-
const tx = callUnsafeTx(entry, chainId);
|
|
2181
|
-
return toTxResult(await tx.signAndSubmit(signer));
|
|
2182
|
-
}
|
|
2183
|
-
/**
|
|
2184
|
-
* Updates the caller's public profile metadata.
|
|
2185
|
-
* Extrinsic: accountMapping.setAccountMetadata(displayName, bio, avatar)
|
|
2186
|
-
*/
|
|
2187
|
-
async setAccountMetadata(params, signer) {
|
|
2188
|
-
const entry = resolveTx(this.substrate.unsafe, "accountMapping", "setAccountMetadata");
|
|
2189
|
-
const encode2 = (v) => v != null ? import_polkadot_api3.Binary.fromText(v) : void 0;
|
|
2190
|
-
const tx = callUnsafeTx(
|
|
2191
|
-
entry,
|
|
2192
|
-
encode2(params.displayName),
|
|
2193
|
-
encode2(params.bio),
|
|
2194
|
-
encode2(params.avatar)
|
|
2195
|
-
);
|
|
2196
|
-
return toTxResult(await tx.signAndSubmit(signer));
|
|
2197
|
-
}
|
|
2198
|
-
/**
|
|
2199
|
-
* Lists the caller's alias for sale on the alias marketplace.
|
|
2200
|
-
* Extrinsic: accountMapping.putAliasOnSale(price, isPrivate)
|
|
2201
|
-
*/
|
|
2202
|
-
async putAliasOnSale(params, signer) {
|
|
2203
|
-
const entry = resolveTx(this.substrate.unsafe, "accountMapping", "putAliasOnSale");
|
|
2204
|
-
const tx = callUnsafeTx(entry, params.price.toString(), params.isPrivate);
|
|
2205
|
-
return toTxResult(await tx.signAndSubmit(signer));
|
|
2206
|
-
}
|
|
2207
|
-
/**
|
|
2208
|
-
* Cancels an active alias sale listing.
|
|
2209
|
-
* Extrinsic: accountMapping.cancelSale()
|
|
2210
|
-
*/
|
|
2211
|
-
async cancelSale(signer) {
|
|
2212
|
-
const entry = resolveTx(this.substrate.unsafe, "accountMapping", "cancelSale");
|
|
2213
|
-
const tx = callUnsafeTx(entry);
|
|
2214
|
-
return toTxResult(await tx.signAndSubmit(signer));
|
|
2215
|
-
}
|
|
2216
|
-
/**
|
|
2217
|
-
* Purchases an alias listed for sale.
|
|
2218
|
-
* Extrinsic: accountMapping.buyAlias(alias)
|
|
2219
|
-
*/
|
|
2220
|
-
async buyAlias(alias, signer) {
|
|
2221
|
-
const entry = resolveTx(this.substrate.unsafe, "accountMapping", "buyAlias");
|
|
2222
|
-
const tx = callUnsafeTx(entry, import_polkadot_api3.Binary.fromText(alias));
|
|
2223
|
-
return toTxResult(await tx.signAndSubmit(signer));
|
|
2224
|
-
}
|
|
2225
|
-
/**
|
|
2226
|
-
* Dispatches an arbitrary call on behalf of a linked external-chain wallet.
|
|
2227
|
-
*
|
|
2228
|
-
* This is the "Universal Proxy" feature that allows EVM/Solana wallets to
|
|
2229
|
-
* authorize on-chain actions without holding a Substrate private key.
|
|
2230
|
-
*
|
|
2231
|
-
* The relayer (who pays gas) calls this with the external wallet's signature
|
|
2232
|
-
* over the encoded call payload and the owner's AccountId32.
|
|
2233
|
-
*
|
|
2234
|
-
* Extrinsic: accountMapping.dispatchAsLinkedAccount(owner, chainId, address, signature, call)
|
|
2235
|
-
*/
|
|
2236
|
-
async dispatchAsLinkedAccount(params, signer) {
|
|
2237
|
-
const entry = resolveTx(this.substrate.unsafe, "accountMapping", "dispatchAsLinkedAccount");
|
|
2238
|
-
const tx = callUnsafeTx(
|
|
2239
|
-
entry,
|
|
2240
|
-
params.owner,
|
|
2241
|
-
params.chainId,
|
|
2242
|
-
params.address,
|
|
2243
|
-
params.signature,
|
|
2244
|
-
params.callData
|
|
2245
|
-
);
|
|
2246
|
-
return toTxResult(await tx.signAndSubmit(signer));
|
|
2247
|
-
}
|
|
2248
|
-
};
|
|
2249
|
-
|
|
2250
1863
|
// src/rpc-v2/ChainModule.ts
|
|
2251
1864
|
var ChainModule = class {
|
|
2252
1865
|
constructor(substrate) {
|
|
@@ -2289,7 +1902,8 @@ var PrivacyModule = class {
|
|
|
2289
1902
|
return {
|
|
2290
1903
|
path: raw.path,
|
|
2291
1904
|
leafIndex: raw.leaf_index,
|
|
2292
|
-
treeDepth: raw.tree_depth
|
|
1905
|
+
treeDepth: raw.tree_depth,
|
|
1906
|
+
treeId: raw.tree_id
|
|
2293
1907
|
};
|
|
2294
1908
|
}
|
|
2295
1909
|
/**
|
|
@@ -2309,6 +1923,7 @@ var PrivacyModule = class {
|
|
|
2309
1923
|
path: raw.path,
|
|
2310
1924
|
leafIndex: raw.leaf_index,
|
|
2311
1925
|
treeDepth: raw.tree_depth,
|
|
1926
|
+
treeId: raw.tree_id,
|
|
2312
1927
|
root: raw.root
|
|
2313
1928
|
};
|
|
2314
1929
|
}
|
|
@@ -2613,20 +2228,6 @@ function decodeUint(data, offset = 0) {
|
|
|
2613
2228
|
}
|
|
2614
2229
|
return result;
|
|
2615
2230
|
}
|
|
2616
|
-
function decodeAddress2(data, offset = 0) {
|
|
2617
|
-
return "0x" + toHex(data.slice(offset + 12, offset + 32)).slice(2);
|
|
2618
|
-
}
|
|
2619
|
-
function decodeBool(data, offset = 0) {
|
|
2620
|
-
return data[offset + 31] !== 0;
|
|
2621
|
-
}
|
|
2622
|
-
function decodeBytes(data, slotOffset = 0) {
|
|
2623
|
-
const dataOffset = Number(decodeUint(data, slotOffset));
|
|
2624
|
-
const length = Number(decodeUint(data, dataOffset));
|
|
2625
|
-
return data.slice(dataOffset + 32, dataOffset + 32 + length);
|
|
2626
|
-
}
|
|
2627
|
-
function decodeString(data, slotOffset = 0) {
|
|
2628
|
-
return new TextDecoder().decode(decodeBytes(data, slotOffset));
|
|
2629
|
-
}
|
|
2630
2231
|
|
|
2631
2232
|
// src/precompiles/addresses.ts
|
|
2632
2233
|
var PRECOMPILE_ADDR = {
|
|
@@ -2642,48 +2243,8 @@ var PRECOMPILE_ADDR = {
|
|
|
2642
2243
|
CURVE25519_ADD: "0x0000000000000000000000000000000000000402",
|
|
2643
2244
|
CURVE25519_SCALAR_MUL: "0x0000000000000000000000000000000000000403",
|
|
2644
2245
|
// ── Orbinum custom ───────────────────────────────────────────────────────
|
|
2645
|
-
ACCOUNT_MAPPING: "0x0000000000000000000000000000000000000800",
|
|
2646
2246
|
SHIELDED_POOL: "0x0000000000000000000000000000000000000801"
|
|
2647
2247
|
};
|
|
2648
|
-
var AM_SEL = {
|
|
2649
|
-
// ── Read-only ─────────────────────────────────────────────────────────────
|
|
2650
|
-
// resolveAlias(string) → 0xd03149ab
|
|
2651
|
-
RESOLVE_ALIAS: new Uint8Array([208, 49, 73, 171]),
|
|
2652
|
-
// getAliasOf(address) → 0x7a0ed62c
|
|
2653
|
-
GET_ALIAS_OF: new Uint8Array([122, 14, 214, 44]),
|
|
2654
|
-
// hasPrivateLink(string,bytes32) → 0x47e05c6c
|
|
2655
|
-
HAS_PRIVATE_LINK: new Uint8Array([71, 224, 92, 108]),
|
|
2656
|
-
// ── No-argument writes ────────────────────────────────────────────────────
|
|
2657
|
-
// mapAccount() → 0xdca49d0e
|
|
2658
|
-
MAP_ACCOUNT: new Uint8Array([220, 164, 157, 14]),
|
|
2659
|
-
// unmapAccount() → 0x08f57367
|
|
2660
|
-
UNMAP_ACCOUNT: new Uint8Array([8, 245, 115, 103]),
|
|
2661
|
-
// releaseAlias() → 0x7fac359e
|
|
2662
|
-
RELEASE_ALIAS: new Uint8Array([127, 172, 53, 158]),
|
|
2663
|
-
// cancelSale() → 0x4d023ab9
|
|
2664
|
-
CANCEL_SALE: new Uint8Array([77, 2, 58, 185]),
|
|
2665
|
-
// ── Writes with arguments ─────────────────────────────────────────────────
|
|
2666
|
-
// registerAlias(string) → 0x2f8839c3
|
|
2667
|
-
REGISTER_ALIAS: new Uint8Array([47, 136, 57, 195]),
|
|
2668
|
-
// transferAlias(address) → 0x5ac998e7
|
|
2669
|
-
TRANSFER_ALIAS: new Uint8Array([90, 201, 152, 231]),
|
|
2670
|
-
// buyAlias(string) → 0x1625df3a
|
|
2671
|
-
BUY_ALIAS: new Uint8Array([22, 37, 223, 58]),
|
|
2672
|
-
// putAliasOnSale(uint256,address[]) → 0x32091192
|
|
2673
|
-
PUT_ALIAS_ON_SALE: new Uint8Array([50, 9, 17, 146]),
|
|
2674
|
-
// removeChainLink(uint32) → 0x6f579c0c
|
|
2675
|
-
REMOVE_CHAIN_LINK: new Uint8Array([111, 87, 156, 12]),
|
|
2676
|
-
// addChainLink(uint32,bytes,bytes) → 0x5f3e837c
|
|
2677
|
-
ADD_CHAIN_LINK: new Uint8Array([95, 62, 131, 124]),
|
|
2678
|
-
// registerPrivateLink(uint32,bytes32) → 0xc04e98f4
|
|
2679
|
-
REGISTER_PRIVATE_LINK: new Uint8Array([192, 78, 152, 244]),
|
|
2680
|
-
// removePrivateLink(bytes32) → 0xdfd8b57e
|
|
2681
|
-
REMOVE_PRIVATE_LINK: new Uint8Array([223, 216, 181, 126]),
|
|
2682
|
-
// revealPrivateLink(bytes32,bytes,bytes32,bytes) → 0x4df1f33d
|
|
2683
|
-
REVEAL_PRIVATE_LINK: new Uint8Array([77, 241, 243, 61]),
|
|
2684
|
-
// setAccountMetadata(bytes,bytes,bytes) → 0x776cf9ff
|
|
2685
|
-
SET_ACCOUNT_METADATA: new Uint8Array([119, 108, 249, 255])
|
|
2686
|
-
};
|
|
2687
2248
|
var SP_SEL = {
|
|
2688
2249
|
// shield(uint32,bytes32,bytes) → 0x9feb22ea (payable, amount = msg.value)
|
|
2689
2250
|
SHIELD: new Uint8Array([159, 235, 34, 234]),
|
|
@@ -2710,28 +2271,6 @@ var KNOWN_PRECOMPILES = {
|
|
|
2710
2271
|
"0x0000000000000000000000000000000000000402": { name: "Curve25519Add", functions: {} },
|
|
2711
2272
|
"0x0000000000000000000000000000000000000403": { name: "Curve25519ScalarMul", functions: {} },
|
|
2712
2273
|
// ── Orbinum custom ───────────────────────────────────────────────────────
|
|
2713
|
-
"0x0000000000000000000000000000000000000800": {
|
|
2714
|
-
name: "AccountMapping",
|
|
2715
|
-
functions: {
|
|
2716
|
-
d03149ab: "resolveAlias(string)",
|
|
2717
|
-
"7a0ed62c": "getAliasOf(address)",
|
|
2718
|
-
"47e05c6c": "hasPrivateLink(string,bytes32)",
|
|
2719
|
-
dca49d0e: "mapAccount()",
|
|
2720
|
-
"08f57367": "unmapAccount()",
|
|
2721
|
-
"7fac359e": "releaseAlias()",
|
|
2722
|
-
"4d023ab9": "cancelSale()",
|
|
2723
|
-
"2f8839c3": "registerAlias(string)",
|
|
2724
|
-
"5ac998e7": "transferAlias(address)",
|
|
2725
|
-
"1625df3a": "buyAlias(string)",
|
|
2726
|
-
"32091192": "putAliasOnSale(uint256,address[])",
|
|
2727
|
-
"6f579c0c": "removeChainLink(uint32)",
|
|
2728
|
-
"5f3e837c": "addChainLink(uint32,bytes,bytes)",
|
|
2729
|
-
c04e98f4: "registerPrivateLink(uint32,bytes32)",
|
|
2730
|
-
dfd8b57e: "removePrivateLink(bytes32)",
|
|
2731
|
-
"4df1f33d": "revealPrivateLink(bytes32,bytes,bytes32,bytes)",
|
|
2732
|
-
"776cf9ff": "setAccountMetadata(bytes,bytes,bytes)"
|
|
2733
|
-
}
|
|
2734
|
-
},
|
|
2735
2274
|
"0x0000000000000000000000000000000000000801": {
|
|
2736
2275
|
name: "ShieldedPool",
|
|
2737
2276
|
functions: {
|
|
@@ -2980,266 +2519,6 @@ var ShieldedPoolPrecompile = class {
|
|
|
2980
2519
|
}
|
|
2981
2520
|
};
|
|
2982
2521
|
|
|
2983
|
-
// src/precompiles/AccountMappingPrecompile.ts
|
|
2984
|
-
var AccountMappingPrecompile = class {
|
|
2985
|
-
constructor(evm) {
|
|
2986
|
-
this.evm = evm;
|
|
2987
|
-
}
|
|
2988
|
-
evm;
|
|
2989
|
-
addr = PRECOMPILE_ADDR.ACCOUNT_MAPPING;
|
|
2990
|
-
// ─── Read-only ─────────────────────────────────────────────────────────────
|
|
2991
|
-
/**
|
|
2992
|
-
* Resolves `@alias` to its owner EVM address (and optionally a secondary EVM address).
|
|
2993
|
-
*
|
|
2994
|
-
* Returns `(address owner, address evmAddress)` — two 32-byte ABI-encoded slots.
|
|
2995
|
-
* `evmAddress` is zero-address (`0x000...0`) if the owner has no explicit EVM address.
|
|
2996
|
-
*/
|
|
2997
|
-
async resolveAlias(alias) {
|
|
2998
|
-
try {
|
|
2999
|
-
const data = encodeHex(AM_SEL.RESOLVE_ALIAS, { type: "string", value: alias });
|
|
3000
|
-
const raw = fromHex(await this.evm.call(this.addr, data));
|
|
3001
|
-
if (raw.length < 64) return null;
|
|
3002
|
-
const owner = decodeAddress2(raw, 0);
|
|
3003
|
-
const evm = decodeAddress2(raw, 32);
|
|
3004
|
-
const ZERO = "0x0000000000000000000000000000000000000000";
|
|
3005
|
-
return {
|
|
3006
|
-
owner,
|
|
3007
|
-
evmAddress: evm === ZERO ? null : normalizeEvmAddress(evm)
|
|
3008
|
-
};
|
|
3009
|
-
} catch {
|
|
3010
|
-
return null;
|
|
3011
|
-
}
|
|
3012
|
-
}
|
|
3013
|
-
/**
|
|
3014
|
-
* Returns the alias registered for the given EVM address, or null.
|
|
3015
|
-
* The precompile ABI encodes the alias as `bytes` (UTF-8).
|
|
3016
|
-
*/
|
|
3017
|
-
async getAliasOf(evmAddress) {
|
|
3018
|
-
try {
|
|
3019
|
-
const data = encodeHex(AM_SEL.GET_ALIAS_OF, {
|
|
3020
|
-
type: "address",
|
|
3021
|
-
value: normalizeEvmAddress(evmAddress)
|
|
3022
|
-
});
|
|
3023
|
-
const raw = fromHex(await this.evm.call(this.addr, data));
|
|
3024
|
-
if (raw.length === 0) return null;
|
|
3025
|
-
const alias = decodeString(raw, 0);
|
|
3026
|
-
return alias.length > 0 ? alias : null;
|
|
3027
|
-
} catch {
|
|
3028
|
-
return null;
|
|
3029
|
-
}
|
|
3030
|
-
}
|
|
3031
|
-
/**
|
|
3032
|
-
* Returns true if the given Poseidon commitment is registered as a private
|
|
3033
|
-
* link for the given alias.
|
|
3034
|
-
*/
|
|
3035
|
-
async hasPrivateLink(alias, commitment) {
|
|
3036
|
-
try {
|
|
3037
|
-
const commitmentBytes = fromHex(ensureHexPrefix(commitment));
|
|
3038
|
-
const data = encodeHex(
|
|
3039
|
-
AM_SEL.HAS_PRIVATE_LINK,
|
|
3040
|
-
{ type: "string", value: alias },
|
|
3041
|
-
{ type: "bytes32", value: commitmentBytes }
|
|
3042
|
-
);
|
|
3043
|
-
const raw = fromHex(await this.evm.call(this.addr, data));
|
|
3044
|
-
if (raw.length < 32) return false;
|
|
3045
|
-
return decodeBool(raw, 0);
|
|
3046
|
-
} catch {
|
|
3047
|
-
return false;
|
|
3048
|
-
}
|
|
3049
|
-
}
|
|
3050
|
-
// ─── No-arg writes ─────────────────────────────────────────────────────────
|
|
3051
|
-
/**
|
|
3052
|
-
* Creates an explicit EVM → Substrate account mapping for the signer's address.
|
|
3053
|
-
* Extrinsic: `accountMapping.mapAccount()`
|
|
3054
|
-
*/
|
|
3055
|
-
async mapAccount(signer) {
|
|
3056
|
-
return signer({ to: this.addr, data: encodeHex(AM_SEL.MAP_ACCOUNT) });
|
|
3057
|
-
}
|
|
3058
|
-
/**
|
|
3059
|
-
* Removes the EVM → Substrate mapping for the signer's address.
|
|
3060
|
-
* Extrinsic: `accountMapping.unmapAccount()`
|
|
3061
|
-
*/
|
|
3062
|
-
async unmapAccount(signer) {
|
|
3063
|
-
return signer({ to: this.addr, data: encodeHex(AM_SEL.UNMAP_ACCOUNT) });
|
|
3064
|
-
}
|
|
3065
|
-
/**
|
|
3066
|
-
* Releases the signer's registered alias, recovering the deposit.
|
|
3067
|
-
* Extrinsic: `accountMapping.releaseAlias()`
|
|
3068
|
-
*/
|
|
3069
|
-
async releaseAlias(signer) {
|
|
3070
|
-
return signer({ to: this.addr, data: encodeHex(AM_SEL.RELEASE_ALIAS) });
|
|
3071
|
-
}
|
|
3072
|
-
/**
|
|
3073
|
-
* Cancels an active alias sale listing.
|
|
3074
|
-
* Extrinsic: `accountMapping.cancelSale()`
|
|
3075
|
-
*/
|
|
3076
|
-
async cancelSale(signer) {
|
|
3077
|
-
return signer({ to: this.addr, data: encodeHex(AM_SEL.CANCEL_SALE) });
|
|
3078
|
-
}
|
|
3079
|
-
// ─── Writes with arguments ─────────────────────────────────────────────────
|
|
3080
|
-
/**
|
|
3081
|
-
* Registers a unique @alias for the signer's account.
|
|
3082
|
-
* Requires a deposit. The alias must be 3–32 ASCII lowercase alphanumeric chars + hyphens.
|
|
3083
|
-
* Extrinsic: `accountMapping.registerAlias(alias)`
|
|
3084
|
-
*/
|
|
3085
|
-
async registerAlias(alias, signer) {
|
|
3086
|
-
const data = encodeHex(AM_SEL.REGISTER_ALIAS, { type: "string", value: alias });
|
|
3087
|
-
return signer({ to: this.addr, data });
|
|
3088
|
-
}
|
|
3089
|
-
/**
|
|
3090
|
-
* Transfers the signer's alias to a new EVM `owner` address.
|
|
3091
|
-
* Extrinsic: `accountMapping.transferAlias(newOwner)`
|
|
3092
|
-
*/
|
|
3093
|
-
async transferAlias(newOwnerEvmAddress, signer) {
|
|
3094
|
-
const data = encodeHex(AM_SEL.TRANSFER_ALIAS, {
|
|
3095
|
-
type: "address",
|
|
3096
|
-
value: normalizeEvmAddress(newOwnerEvmAddress)
|
|
3097
|
-
});
|
|
3098
|
-
return signer({ to: this.addr, data });
|
|
3099
|
-
}
|
|
3100
|
-
/**
|
|
3101
|
-
* Purchases an alias currently listed for sale.
|
|
3102
|
-
* Extrinsic: `accountMapping.buyAlias(alias)`
|
|
3103
|
-
*/
|
|
3104
|
-
async buyAlias(alias, signer) {
|
|
3105
|
-
const data = encodeHex(AM_SEL.BUY_ALIAS, { type: "string", value: alias });
|
|
3106
|
-
return signer({ to: this.addr, data });
|
|
3107
|
-
}
|
|
3108
|
-
/**
|
|
3109
|
-
* Lists the signer's alias for sale on the alias marketplace.
|
|
3110
|
-
*
|
|
3111
|
-
* @param price Asking price in planck (ORB).
|
|
3112
|
-
* @param allowedBuyers Whitelist of EVM addresses allowed to buy.
|
|
3113
|
-
* Pass an empty array for a public (open) listing.
|
|
3114
|
-
* Extrinsic: `accountMapping.putAliasOnSale(price, allowedBuyers)`
|
|
3115
|
-
*/
|
|
3116
|
-
async putAliasOnSale(price, allowedBuyers, signer) {
|
|
3117
|
-
const data = encodeHex(
|
|
3118
|
-
AM_SEL.PUT_ALIAS_ON_SALE,
|
|
3119
|
-
{ type: "uint", value: price },
|
|
3120
|
-
{ type: "address[]", value: allowedBuyers.map(normalizeEvmAddress) }
|
|
3121
|
-
);
|
|
3122
|
-
return signer({ to: this.addr, data });
|
|
3123
|
-
}
|
|
3124
|
-
/**
|
|
3125
|
-
* Removes the external-chain link for the given chain ID.
|
|
3126
|
-
* Extrinsic: `accountMapping.removeChainLink(chainId)`
|
|
3127
|
-
*/
|
|
3128
|
-
async removeChainLink(chainId, signer) {
|
|
3129
|
-
const data = encodeHex(AM_SEL.REMOVE_CHAIN_LINK, { type: "uint", value: BigInt(chainId) });
|
|
3130
|
-
return signer({ to: this.addr, data });
|
|
3131
|
-
}
|
|
3132
|
-
/**
|
|
3133
|
-
* Adds a verified public link to an external-chain wallet.
|
|
3134
|
-
*
|
|
3135
|
-
* @param chainId Orbinum chain ID (use `SLIP0044_NAMESPACE | coinType` for SLIP-0044).
|
|
3136
|
-
* @param externalAddr External wallet address bytes (20 bytes for EVM, 32 for Solana).
|
|
3137
|
-
* @param signature Signature over the caller's AccountId32:
|
|
3138
|
-
* - EIP-191 (EVM): 65 bytes over keccak256("\x19Ethereum Signed Message:\n32" + accountId32)
|
|
3139
|
-
* - Ed25519 (Solana): 64 bytes over the raw accountId32 bytes
|
|
3140
|
-
*
|
|
3141
|
-
* Extrinsic: `accountMapping.addChainLink(chainId, address, signature)`
|
|
3142
|
-
*/
|
|
3143
|
-
async addChainLink(chainId, externalAddr, signature, signer) {
|
|
3144
|
-
const data = encodeHex(
|
|
3145
|
-
AM_SEL.ADD_CHAIN_LINK,
|
|
3146
|
-
{ type: "uint", value: BigInt(chainId) },
|
|
3147
|
-
{ type: "bytes", value: externalAddr },
|
|
3148
|
-
{ type: "bytes", value: signature }
|
|
3149
|
-
);
|
|
3150
|
-
return signer({ to: this.addr, data });
|
|
3151
|
-
}
|
|
3152
|
-
/**
|
|
3153
|
-
* Registers a private chain link — only the Poseidon commitment is stored.
|
|
3154
|
-
* The real external address is never revealed on-chain.
|
|
3155
|
-
*
|
|
3156
|
-
* @param chainId External chain ID.
|
|
3157
|
-
* @param commitment 0x-prefixed 32-byte Poseidon commitment hex.
|
|
3158
|
-
*
|
|
3159
|
-
* Extrinsic: `accountMapping.registerPrivateLink(chainId, commitment)`
|
|
3160
|
-
*/
|
|
3161
|
-
async registerPrivateLink(chainId, commitment, signer) {
|
|
3162
|
-
const commitmentBytes = fromHex(
|
|
3163
|
-
commitment.startsWith("0x") ? commitment : "0x" + commitment
|
|
3164
|
-
);
|
|
3165
|
-
const data = encodeHex(
|
|
3166
|
-
AM_SEL.REGISTER_PRIVATE_LINK,
|
|
3167
|
-
{ type: "uint", value: BigInt(chainId) },
|
|
3168
|
-
{ type: "bytes32", value: commitmentBytes }
|
|
3169
|
-
);
|
|
3170
|
-
return signer({ to: this.addr, data });
|
|
3171
|
-
}
|
|
3172
|
-
/**
|
|
3173
|
-
* Removes a private link by its commitment.
|
|
3174
|
-
* Extrinsic: `accountMapping.removePrivateLink(commitment)`
|
|
3175
|
-
*/
|
|
3176
|
-
async removePrivateLink(commitment, signer) {
|
|
3177
|
-
const commitmentBytes = fromHex(
|
|
3178
|
-
commitment.startsWith("0x") ? commitment : "0x" + commitment
|
|
3179
|
-
);
|
|
3180
|
-
const data = encodeHex(AM_SEL.REMOVE_PRIVATE_LINK, {
|
|
3181
|
-
type: "bytes32",
|
|
3182
|
-
value: commitmentBytes
|
|
3183
|
-
});
|
|
3184
|
-
return signer({ to: this.addr, data });
|
|
3185
|
-
}
|
|
3186
|
-
/**
|
|
3187
|
-
* Reveals a private link publicly by providing the real address and blinding.
|
|
3188
|
-
* After this call the link becomes a public chain link.
|
|
3189
|
-
*
|
|
3190
|
-
* @param commitment 32-byte commitment hex.
|
|
3191
|
-
* @param address External address bytes (the actual wallet address).
|
|
3192
|
-
* @param blinding 32-byte blinding factor used when computing the commitment.
|
|
3193
|
-
* @param signature Signature over the AccountId32 bytes (same rules as `addChainLink`).
|
|
3194
|
-
*
|
|
3195
|
-
* Extrinsic: `accountMapping.revealPrivateLink(commitment, address, blinding, signature)`
|
|
3196
|
-
*/
|
|
3197
|
-
async revealPrivateLink(commitment, address, blinding, signature, signer) {
|
|
3198
|
-
const commitmentBytes = fromHex(
|
|
3199
|
-
commitment.startsWith("0x") ? commitment : "0x" + commitment
|
|
3200
|
-
);
|
|
3201
|
-
const blindingBytes = fromHex(blinding.startsWith("0x") ? blinding : "0x" + blinding);
|
|
3202
|
-
const data = encodeHex(
|
|
3203
|
-
AM_SEL.REVEAL_PRIVATE_LINK,
|
|
3204
|
-
{ type: "bytes32", value: commitmentBytes },
|
|
3205
|
-
{ type: "bytes", value: address },
|
|
3206
|
-
{ type: "bytes32", value: blindingBytes },
|
|
3207
|
-
{ type: "bytes", value: signature }
|
|
3208
|
-
);
|
|
3209
|
-
return signer({ to: this.addr, data });
|
|
3210
|
-
}
|
|
3211
|
-
/**
|
|
3212
|
-
* Updates the signer's public profile metadata.
|
|
3213
|
-
* Pass `null` for any field to leave it unchanged.
|
|
3214
|
-
}
|
|
3215
|
-
displayName: string | null,
|
|
3216
|
-
bio: string | null,
|
|
3217
|
-
avatar: string | null,
|
|
3218
|
-
signer: EvmSigner
|
|
3219
|
-
): Promise<string> {
|
|
3220
|
-
const enc = (v: string | null): Uint8Array =>
|
|
3221
|
-
v != null ? new TextEncoder().encode(v) : new Uint8Array(0);
|
|
3222
|
-
const data = encodeHex(
|
|
3223
|
-
AM_SEL.SET_ACCOUNT_METADATA,
|
|
3224
|
-
{ type: 'bytes', value: enc(displayName) },
|
|
3225
|
-
{ type: 'bytes', value: enc(bio) },
|
|
3226
|
-
{ type: 'bytes', value: enc(avatar) }
|
|
3227
|
-
);
|
|
3228
|
-
return signer({ to: this.addr, data });
|
|
3229
|
-
}
|
|
3230
|
-
|
|
3231
|
-
// ─── Calldata builders (for custom signing / batching) ─────────────────────
|
|
3232
|
-
|
|
3233
|
-
/** Returns the raw ABI-encoded calldata for `registerAlias`. */
|
|
3234
|
-
buildRegisterAliasCalldata(alias) {
|
|
3235
|
-
return encodeHex(AM_SEL.REGISTER_ALIAS, { type: "string", value: alias });
|
|
3236
|
-
}
|
|
3237
|
-
/** Returns the raw ABI-encoded calldata for `mapAccount`. */
|
|
3238
|
-
buildMapAccountCalldata() {
|
|
3239
|
-
return encodeHex(AM_SEL.MAP_ACCOUNT);
|
|
3240
|
-
}
|
|
3241
|
-
};
|
|
3242
|
-
|
|
3243
2522
|
// src/precompiles/CryptoPrecompiles.ts
|
|
3244
2523
|
var CryptoPrecompiles = class {
|
|
3245
2524
|
constructor(evm) {
|
|
@@ -3367,8 +2646,6 @@ var OrbinumClient = class _OrbinumClient {
|
|
|
3367
2646
|
evmExplorer;
|
|
3368
2647
|
/** Shielded-pool extrinsics and Merkle tree queries (`shield`, `unshield`, `privateTransfer`, …). */
|
|
3369
2648
|
shieldedPool;
|
|
3370
|
-
/** Account-mapping extrinsics: aliases, chain links, metadata, marketplace, and identity. */
|
|
3371
|
-
accountMapping;
|
|
3372
2649
|
/** Typed access to `privacy_*` custom RPC endpoints. */
|
|
3373
2650
|
privacy;
|
|
3374
2651
|
/** Typed access to general chain state via `chain_*` custom RPC endpoints. */
|
|
@@ -3393,7 +2670,6 @@ var OrbinumClient = class _OrbinumClient {
|
|
|
3393
2670
|
this.evm = evm;
|
|
3394
2671
|
this.evmExplorer = evm ? new EvmExplorer(evm) : null;
|
|
3395
2672
|
this.shieldedPool = new ShieldedPoolModule(substrate);
|
|
3396
|
-
this.accountMapping = new AccountMappingModule(substrate);
|
|
3397
2673
|
this.privacy = new PrivacyModule(substrate);
|
|
3398
2674
|
this.chain = new ChainModule(substrate);
|
|
3399
2675
|
this.zkVerifier = new ZkVerifierModule(substrate);
|
|
@@ -3401,7 +2677,6 @@ var OrbinumClient = class _OrbinumClient {
|
|
|
3401
2677
|
this.relayerStatus = new RelayerStatusModule(substrate);
|
|
3402
2678
|
this.precompiles = evm ? {
|
|
3403
2679
|
shieldedPool: new ShieldedPoolPrecompile(evm),
|
|
3404
|
-
accountMapping: new AccountMappingPrecompile(evm),
|
|
3405
2680
|
crypto: new CryptoPrecompiles(evm)
|
|
3406
2681
|
} : null;
|
|
3407
2682
|
}
|
|
@@ -4224,9 +3499,9 @@ function randomBlinding() {
|
|
|
4224
3499
|
}
|
|
4225
3500
|
|
|
4226
3501
|
// src/privacy-keys/accountIdentity.ts
|
|
4227
|
-
var
|
|
3502
|
+
var import_polkadot_api3 = require("polkadot-api");
|
|
4228
3503
|
function canonicalAccountId(address) {
|
|
4229
|
-
const info = (0,
|
|
3504
|
+
const info = (0, import_polkadot_api3.getSs58AddressInfo)(address);
|
|
4230
3505
|
return info.isValid ? toHex(info.publicKey) : address.toLowerCase();
|
|
4231
3506
|
}
|
|
4232
3507
|
|
|
@@ -4722,13 +3997,6 @@ async function generateFeeClaimProof(inputs, options = {}) {
|
|
|
4722
3997
|
};
|
|
4723
3998
|
}
|
|
4724
3999
|
|
|
4725
|
-
// src/account-mapping/types/index.ts
|
|
4726
|
-
var SignatureScheme = {
|
|
4727
|
-
Eip191: "Eip191",
|
|
4728
|
-
Ed25519: "Ed25519"
|
|
4729
|
-
};
|
|
4730
|
-
var SLIP0044_NAMESPACE = 2147483648;
|
|
4731
|
-
|
|
4732
4000
|
// src/precompiles/decode.ts
|
|
4733
4001
|
function decodePrecompileCalldata(address, input) {
|
|
4734
4002
|
const info = KNOWN_PRECOMPILES[address.toLowerCase()];
|
|
@@ -4736,15 +4004,6 @@ function decodePrecompileCalldata(address, input) {
|
|
|
4736
4004
|
const selector = input.slice(2, 10).toLowerCase();
|
|
4737
4005
|
const fnSig = info.functions[selector];
|
|
4738
4006
|
if (!fnSig) return null;
|
|
4739
|
-
if (fnSig.startsWith("registerAlias")) {
|
|
4740
|
-
try {
|
|
4741
|
-
const data = fromHex(input.slice(10));
|
|
4742
|
-
const alias = decodeString(data, 0);
|
|
4743
|
-
return { fnSig, args: { alias } };
|
|
4744
|
-
} catch {
|
|
4745
|
-
return { fnSig, args: {} };
|
|
4746
|
-
}
|
|
4747
|
-
}
|
|
4748
4007
|
if (fnSig.startsWith("shield(")) {
|
|
4749
4008
|
try {
|
|
4750
4009
|
const data = fromHex(input.slice(10));
|
|
@@ -4818,7 +4077,6 @@ function decodePrecompileCalldata(address, input) {
|
|
|
4818
4077
|
var CircuitId = {
|
|
4819
4078
|
Transfer: 1,
|
|
4820
4079
|
Unshield: 2,
|
|
4821
|
-
PrivateLink: 5,
|
|
4822
4080
|
ValueProof: 6
|
|
4823
4081
|
};
|
|
4824
4082
|
|
|
@@ -5075,84 +4333,6 @@ function mapExtrinsicArgs(section, method, args) {
|
|
|
5075
4333
|
};
|
|
5076
4334
|
}
|
|
5077
4335
|
}
|
|
5078
|
-
if (s === "accountmapping") {
|
|
5079
|
-
const m_norm = m.replace(/_/g, "");
|
|
5080
|
-
if (m_norm === "registeralias") {
|
|
5081
|
-
return { alias: get(0, "alias") };
|
|
5082
|
-
}
|
|
5083
|
-
if (m_norm === "transferalias") {
|
|
5084
|
-
return { new_owner: get(0, "new_owner") };
|
|
5085
|
-
}
|
|
5086
|
-
if (m_norm === "putaliasonsale") {
|
|
5087
|
-
return {
|
|
5088
|
-
price: get(0, "price"),
|
|
5089
|
-
allowed_buyers: get(1, "allowed_buyers")
|
|
5090
|
-
};
|
|
5091
|
-
}
|
|
5092
|
-
if (m_norm === "buyalias") {
|
|
5093
|
-
return { alias: get(0, "alias") };
|
|
5094
|
-
}
|
|
5095
|
-
if (m_norm === "addchainlink") {
|
|
5096
|
-
return {
|
|
5097
|
-
chain_id: get(0, "chain_id"),
|
|
5098
|
-
address: get(1, "address"),
|
|
5099
|
-
signature: get(2, "signature")
|
|
5100
|
-
};
|
|
5101
|
-
}
|
|
5102
|
-
if (m_norm === "removechainlink") {
|
|
5103
|
-
return { chain_id: get(0, "chain_id") };
|
|
5104
|
-
}
|
|
5105
|
-
if (m_norm === "setaccountmetadata") {
|
|
5106
|
-
return {
|
|
5107
|
-
display_name: get(0, "display_name"),
|
|
5108
|
-
bio: get(1, "bio"),
|
|
5109
|
-
avatar: get(2, "avatar")
|
|
5110
|
-
};
|
|
5111
|
-
}
|
|
5112
|
-
if (m_norm === "addsupportedchain") {
|
|
5113
|
-
return {
|
|
5114
|
-
chain_id: get(0, "chain_id"),
|
|
5115
|
-
scheme: get(1, "scheme")
|
|
5116
|
-
};
|
|
5117
|
-
}
|
|
5118
|
-
if (m_norm === "removesupportedchain") {
|
|
5119
|
-
return { chain_id: get(0, "chain_id") };
|
|
5120
|
-
}
|
|
5121
|
-
if (m_norm === "dispatchaslinkedaccount") {
|
|
5122
|
-
return {
|
|
5123
|
-
owner: get(0, "owner"),
|
|
5124
|
-
chain_id: get(1, "chain_id"),
|
|
5125
|
-
address: get(2, "address"),
|
|
5126
|
-
signature: get(3, "signature"),
|
|
5127
|
-
call: get(4, "call")
|
|
5128
|
-
};
|
|
5129
|
-
}
|
|
5130
|
-
if (m_norm === "registerprivatelink") {
|
|
5131
|
-
return {
|
|
5132
|
-
chain_id: get(0, "chain_id"),
|
|
5133
|
-
commitment: get(1, "commitment")
|
|
5134
|
-
};
|
|
5135
|
-
}
|
|
5136
|
-
if (m_norm === "removeprivatelink") {
|
|
5137
|
-
return { commitment: get(0, "commitment") };
|
|
5138
|
-
}
|
|
5139
|
-
if (m_norm === "revealprivatelink") {
|
|
5140
|
-
return {
|
|
5141
|
-
commitment: get(0, "commitment"),
|
|
5142
|
-
address: get(1, "address"),
|
|
5143
|
-
blinding: get(2, "blinding"),
|
|
5144
|
-
signature: get(3, "signature")
|
|
5145
|
-
};
|
|
5146
|
-
}
|
|
5147
|
-
if (m_norm === "dispatchasprivatelink") {
|
|
5148
|
-
return {
|
|
5149
|
-
owner: get(0, "owner"),
|
|
5150
|
-
commitment: get(1, "commitment"),
|
|
5151
|
-
zk_proof: get(2, "zk_proof"),
|
|
5152
|
-
call: get(3, "call")
|
|
5153
|
-
};
|
|
5154
|
-
}
|
|
5155
|
-
}
|
|
5156
4336
|
if (s === "zkverifier") {
|
|
5157
4337
|
const m_norm = m.replace(/_/g, "");
|
|
5158
4338
|
if (m_norm === "batchregisterverificationkeys") {
|
|
@@ -5254,106 +4434,6 @@ function mapZkEventData(method, data) {
|
|
|
5254
4434
|
if (m_norm === "assetunverified") {
|
|
5255
4435
|
return { asset_id: get(0, "asset_id") };
|
|
5256
4436
|
}
|
|
5257
|
-
if (m_norm === "accountmapped" || m_norm === "accountunmapped") {
|
|
5258
|
-
return {
|
|
5259
|
-
account: get(0, "account"),
|
|
5260
|
-
address: get(1, "address")
|
|
5261
|
-
};
|
|
5262
|
-
}
|
|
5263
|
-
if (m_norm === "aliasregistered") {
|
|
5264
|
-
return {
|
|
5265
|
-
account: get(0, "account"),
|
|
5266
|
-
alias: get(1, "alias"),
|
|
5267
|
-
evm_address: get(2, "evm_address")
|
|
5268
|
-
};
|
|
5269
|
-
}
|
|
5270
|
-
if (m_norm === "aliasreleased") {
|
|
5271
|
-
return {
|
|
5272
|
-
account: get(0, "account"),
|
|
5273
|
-
alias: get(1, "alias")
|
|
5274
|
-
};
|
|
5275
|
-
}
|
|
5276
|
-
if (m_norm === "aliastransferred") {
|
|
5277
|
-
return {
|
|
5278
|
-
from: get(0, "from"),
|
|
5279
|
-
to: get(1, "to"),
|
|
5280
|
-
alias: get(2, "alias")
|
|
5281
|
-
};
|
|
5282
|
-
}
|
|
5283
|
-
if (m_norm === "aliaslistedforsale") {
|
|
5284
|
-
return {
|
|
5285
|
-
seller: get(0, "seller"),
|
|
5286
|
-
alias: get(1, "alias"),
|
|
5287
|
-
price: get(2, "price"),
|
|
5288
|
-
private: get(3, "private")
|
|
5289
|
-
};
|
|
5290
|
-
}
|
|
5291
|
-
if (m_norm === "aliassalecancelled") {
|
|
5292
|
-
return {
|
|
5293
|
-
seller: get(0, "seller"),
|
|
5294
|
-
alias: get(1, "alias")
|
|
5295
|
-
};
|
|
5296
|
-
}
|
|
5297
|
-
if (m_norm === "aliassold") {
|
|
5298
|
-
return {
|
|
5299
|
-
seller: get(0, "seller"),
|
|
5300
|
-
buyer: get(1, "buyer"),
|
|
5301
|
-
alias: get(2, "alias"),
|
|
5302
|
-
price: get(3, "price")
|
|
5303
|
-
};
|
|
5304
|
-
}
|
|
5305
|
-
if (m_norm === "chainlinkadded") {
|
|
5306
|
-
return {
|
|
5307
|
-
account: get(0, "account"),
|
|
5308
|
-
chain_id: get(1, "chain_id"),
|
|
5309
|
-
address: get(2, "address")
|
|
5310
|
-
};
|
|
5311
|
-
}
|
|
5312
|
-
if (m_norm === "chainlinkremoved") {
|
|
5313
|
-
return {
|
|
5314
|
-
account: get(0, "account"),
|
|
5315
|
-
chain_id: get(1, "chain_id")
|
|
5316
|
-
};
|
|
5317
|
-
}
|
|
5318
|
-
if (m_norm === "metadataupdated") {
|
|
5319
|
-
return { account: get(0, "account") };
|
|
5320
|
-
}
|
|
5321
|
-
if (m_norm === "supportedchainadded") {
|
|
5322
|
-
return {
|
|
5323
|
-
chain_id: get(0, "chain_id"),
|
|
5324
|
-
scheme: get(1, "scheme")
|
|
5325
|
-
};
|
|
5326
|
-
}
|
|
5327
|
-
if (m_norm === "supportedchainremoved") {
|
|
5328
|
-
return { chain_id: get(0, "chain_id") };
|
|
5329
|
-
}
|
|
5330
|
-
if (m_norm === "proxycallexecuted") {
|
|
5331
|
-
return {
|
|
5332
|
-
owner: get(0, "owner"),
|
|
5333
|
-
chain_id: get(1, "chain_id"),
|
|
5334
|
-
address: get(2, "address")
|
|
5335
|
-
};
|
|
5336
|
-
}
|
|
5337
|
-
if (m_norm === "privatechainlinkadded" || m_norm === "privatechainlinkremoved") {
|
|
5338
|
-
return {
|
|
5339
|
-
account: get(0, "account"),
|
|
5340
|
-
chain_id: get(1, "chain_id"),
|
|
5341
|
-
commitment: get(2, "commitment")
|
|
5342
|
-
};
|
|
5343
|
-
}
|
|
5344
|
-
if (m_norm === "privatechainlinkrevealed") {
|
|
5345
|
-
return {
|
|
5346
|
-
account: get(0, "account"),
|
|
5347
|
-
chain_id: get(1, "chain_id"),
|
|
5348
|
-
address: get(2, "address")
|
|
5349
|
-
};
|
|
5350
|
-
}
|
|
5351
|
-
if (m_norm === "privatelinkdispatchexecuted") {
|
|
5352
|
-
return {
|
|
5353
|
-
owner: get(0, "owner"),
|
|
5354
|
-
commitment: get(1, "commitment")
|
|
5355
|
-
};
|
|
5356
|
-
}
|
|
5357
4437
|
if (m_norm === "verificationkeyregistered" || m_norm === "activeversionset" || m_norm === "verificationkeyremoved" || m_norm === "proofverified" || m_norm === "proofverificationfailed") {
|
|
5358
4438
|
return {
|
|
5359
4439
|
circuit_id: get(0, "circuit_id"),
|
|
@@ -5482,12 +4562,10 @@ var import_substrate_bindings3 = require("@polkadot-api/substrate-bindings");
|
|
|
5482
4562
|
var import_base = require("@scure/base");
|
|
5483
4563
|
var import_signer = require("polkadot-api/signer");
|
|
5484
4564
|
var import_pjs_signer = require("polkadot-api/pjs-signer");
|
|
5485
|
-
var
|
|
4565
|
+
var import_polkadot_api4 = require("polkadot-api");
|
|
5486
4566
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5487
4567
|
0 && (module.exports = {
|
|
5488
4568
|
AccountId,
|
|
5489
|
-
AccountMappingModule,
|
|
5490
|
-
AccountMappingPrecompile,
|
|
5491
4569
|
BABYJUB_SUBORDER,
|
|
5492
4570
|
BN254_R,
|
|
5493
4571
|
Blake2256,
|
|
@@ -5510,12 +4588,10 @@ var import_polkadot_api5 = require("polkadot-api");
|
|
|
5510
4588
|
PrivacyKeyManager,
|
|
5511
4589
|
PrivacyModule,
|
|
5512
4590
|
RelayerStatusModule,
|
|
5513
|
-
SLIP0044_NAMESPACE,
|
|
5514
4591
|
SPENDING_KEY_VERIFYING_CONTRACT,
|
|
5515
4592
|
SPENDING_KEY_WARNING,
|
|
5516
4593
|
ShieldedPoolModule,
|
|
5517
4594
|
ShieldedPoolPrecompile,
|
|
5518
|
-
SignatureScheme,
|
|
5519
4595
|
Storage,
|
|
5520
4596
|
SubstrateClient,
|
|
5521
4597
|
VaultLockedError,
|