@qntx/wallet-engine 0.11.0 → 0.13.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/connect.d.mts +1 -1
- package/dist/connect.mjs +1 -1
- package/dist/{errors-Bglz0VYn.d.mts → errors-CQnlTc1i.d.mts} +301 -19
- package/dist/gateway-contract.d.mts +247 -1
- package/dist/gateway-contract.mjs +146 -2
- package/dist/gateway-contract.mjs.map +1 -1
- package/dist/index.d.mts +162 -59
- package/dist/index.mjs +6325 -3997
- package/dist/index.mjs.map +1 -1
- package/dist/{registry-Deo5WQe1.d.mts → registry-DwguKWvt.d.mts} +3 -1
- package/dist/{registry-wYrcuFNc.mjs → registry-oorLoGtz.mjs} +23 -2
- package/dist/registry-oorLoGtz.mjs.map +1 -0
- package/dist/{webln-BGKm12wd.mjs → webln-DKqCnqx1.mjs} +72 -33
- package/dist/webln-DKqCnqx1.mjs.map +1 -0
- package/package.json +10 -8
- package/dist/registry-wYrcuFNc.mjs.map +0 -1
- package/dist/webln-BGKm12wd.mjs.map +0 -1
|
@@ -16,10 +16,12 @@ type NetworkInfo = {
|
|
|
16
16
|
readonly testnet: boolean;
|
|
17
17
|
/** OP Stack chain: transactions also pay an L1 data fee and an operator fee. */
|
|
18
18
|
readonly opStack?: true;
|
|
19
|
+
/** Keccak256 of the delegator's runtime code on this chain; absent = EIP-7702 unsupported. */
|
|
20
|
+
readonly delegatorCodeHash?: string;
|
|
19
21
|
};
|
|
20
22
|
declare const NETWORKS: ReadonlyArray<NetworkInfo>;
|
|
21
23
|
declare const networkById: (id: string) => NetworkInfo | undefined;
|
|
22
24
|
declare const BITCOIN_NETWORKS: ReadonlyArray<NetworkInfo>;
|
|
23
25
|
declare const SOLANA_NETWORKS: ReadonlyArray<NetworkInfo>;
|
|
24
26
|
export { networkById as a, SOLANA_NETWORKS as i, NETWORKS as n, NetworkInfo as r, BITCOIN_NETWORKS as t };
|
|
25
|
-
//# sourceMappingURL=registry-
|
|
27
|
+
//# sourceMappingURL=registry-DwguKWvt.d.mts.map
|
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
// src/networks/registry.ts
|
|
2
|
+
/**
|
|
3
|
+
* Keccak256 of the EIP7702StatelessDeleGator v1.3.0 runtime code per chain, verified on-chain
|
|
4
|
+
* 2026-11-08. Differs per chain because OpenZeppelin's EIP712 stores the chain id and the domain
|
|
5
|
+
* separator as immutables. HyperEVM (999/998) has no deployment; Avalanche C-Chain (43114/43113)
|
|
6
|
+
* has not activated 7702.
|
|
7
|
+
*/
|
|
8
|
+
const DELEGATOR_CODE_HASHES = {
|
|
9
|
+
1: "0x0b77e469f5603ed1e9ff0e7ee56238b61a8cf7cb3185b33e53e2eeaad50109ab",
|
|
10
|
+
8453: "0x6af675ac126c441bec5d5013da3331a52e7465fc0d5a662a8708a9f33ce497ba",
|
|
11
|
+
42161: "0xa6603bc6f9f203be551ce8fcfe13b7802e3b6574828780b4c4fe05d1768d17de",
|
|
12
|
+
10: "0x076ce337739f2c16aff0d81341b32ec5826a0050060e54b1346f36c79d89b246",
|
|
13
|
+
137: "0x0a0b90e8b2bb4701283c0b44939f18a5292af9ab58e0f1f4a3413fdbdbebcc35",
|
|
14
|
+
56: "0x2f40923fc79da9330c663341d8a52823ea02372b7da66175a0a9bfc76270d55f",
|
|
15
|
+
11155111: "0x9270f73d98e7ed6978677bf0550038289efd510e67e700d024502d62510fc1e4",
|
|
16
|
+
84532: "0x83805f9ac7395294043b10c3b7c1839b7e4582a3e693028c36df84978b09d4e2",
|
|
17
|
+
421614: "0x7f8a570cc9ebfd8d4dd86c7cc482bb30e9c669cc281352b131c94291747a58c8",
|
|
18
|
+
11155420: "0x9d71e8749e123ade3310cbab813a837f7b2ffff8608aeddb0619a78f64a95663",
|
|
19
|
+
80002: "0xddc1c1b0583d57f3937d04c7bdacfaecb699d8aa27ee00040ab2c7b656ed239b",
|
|
20
|
+
97: "0x27d0d3e53805ac152f306986e91511b7c6c6804cba0dbe0e1420d19905e682e6"
|
|
21
|
+
};
|
|
2
22
|
const entry = (chainId, name, symbol, testnet, _source, opStack) => ({
|
|
3
23
|
id: `eip155:${chainId}`,
|
|
4
24
|
chainId,
|
|
@@ -8,7 +28,8 @@ const entry = (chainId, name, symbol, testnet, _source, opStack) => ({
|
|
|
8
28
|
testnet,
|
|
9
29
|
family: "evm",
|
|
10
30
|
multicall3: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
11
|
-
...opStack === true ? { opStack } : {}
|
|
31
|
+
...opStack === true ? { opStack } : {},
|
|
32
|
+
...DELEGATOR_CODE_HASHES[chainId] === void 0 ? {} : { delegatorCodeHash: DELEGATOR_CODE_HASHES[chainId] }
|
|
12
33
|
});
|
|
13
34
|
const NETWORKS = [
|
|
14
35
|
entry(1, "Ethereum", "ETH", false, "https://ethereum.org/en/developers/docs/networks/"),
|
|
@@ -96,4 +117,4 @@ const SOLANA_NETWORKS = [{
|
|
|
96
117
|
}];
|
|
97
118
|
export { networkById as i, NETWORKS as n, SOLANA_NETWORKS as r, BITCOIN_NETWORKS as t };
|
|
98
119
|
|
|
99
|
-
//# sourceMappingURL=registry-
|
|
120
|
+
//# sourceMappingURL=registry-oorLoGtz.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-oorLoGtz.mjs","names":[],"sources":["../src/networks/registry.ts"],"sourcesContent":["/**\n * Built-in EVM network registry: the 8 mainnets from chains.mdx plus their main testnets. Each\n * chain id was checked against the chain's official documentation (source URL per entry).\n * Signing-time chainId always comes from this table, never from an RPC endpoint.\n */\n\nexport type NetworkInfo = {\n readonly id: string; // CAIP-2 eip155:<chainId>\n readonly chainId: number;\n readonly name: string;\n readonly symbol: string;\n readonly multicall3?: string;\n /** CAIP-2 family — `solana:<ref>` networks are validated against genesis-hash, not chainId. */\n readonly family: \"evm\" | \"solana\" | \"bitcoin\";\n readonly genesisHash?: string;\n readonly decimals: number;\n readonly testnet: boolean;\n /** OP Stack chain: transactions also pay an L1 data fee and an operator fee. */\n readonly opStack?: true;\n /** Keccak256 of the delegator's runtime code on this chain; absent = EIP-7702 unsupported. */\n readonly delegatorCodeHash?: string;\n};\n\n/**\n * Keccak256 of the EIP7702StatelessDeleGator v1.3.0 runtime code per chain, verified on-chain\n * 2026-11-08. Differs per chain because OpenZeppelin's EIP712 stores the chain id and the domain\n * separator as immutables. HyperEVM (999/998) has no deployment; Avalanche C-Chain (43114/43113)\n * has not activated 7702.\n */\nconst DELEGATOR_CODE_HASHES: Readonly<Record<number, string>> = {\n 1: \"0x0b77e469f5603ed1e9ff0e7ee56238b61a8cf7cb3185b33e53e2eeaad50109ab\",\n 8453: \"0x6af675ac126c441bec5d5013da3331a52e7465fc0d5a662a8708a9f33ce497ba\",\n 42161: \"0xa6603bc6f9f203be551ce8fcfe13b7802e3b6574828780b4c4fe05d1768d17de\",\n 10: \"0x076ce337739f2c16aff0d81341b32ec5826a0050060e54b1346f36c79d89b246\",\n 137: \"0x0a0b90e8b2bb4701283c0b44939f18a5292af9ab58e0f1f4a3413fdbdbebcc35\",\n 56: \"0x2f40923fc79da9330c663341d8a52823ea02372b7da66175a0a9bfc76270d55f\",\n 11155111: \"0x9270f73d98e7ed6978677bf0550038289efd510e67e700d024502d62510fc1e4\",\n 84532: \"0x83805f9ac7395294043b10c3b7c1839b7e4582a3e693028c36df84978b09d4e2\",\n 421614: \"0x7f8a570cc9ebfd8d4dd86c7cc482bb30e9c669cc281352b131c94291747a58c8\",\n 11155420: \"0x9d71e8749e123ade3310cbab813a837f7b2ffff8608aeddb0619a78f64a95663\",\n 80002: \"0xddc1c1b0583d57f3937d04c7bdacfaecb699d8aa27ee00040ab2c7b656ed239b\",\n 97: \"0x27d0d3e53805ac152f306986e91511b7c6c6804cba0dbe0e1420d19905e682e6\",\n};\n\nconst entry = (\n chainId: number,\n name: string,\n symbol: string,\n testnet: boolean,\n _source: string,\n opStack?: true,\n): NetworkInfo => ({\n id: `eip155:${chainId}`,\n chainId,\n name,\n symbol,\n decimals: 18,\n testnet,\n family: \"evm\",\n // Canonical Multicall3 — https://github.com/mds1/multicall3 deployments (all entries below).\n multicall3: \"0xcA11bde05977b3631167028862bE2a173976CA11\",\n ...(opStack === true ? { opStack } : {}),\n ...(DELEGATOR_CODE_HASHES[chainId] === undefined\n ? {}\n : { delegatorCodeHash: DELEGATOR_CODE_HASHES[chainId] }),\n});\n\nexport const NETWORKS: ReadonlyArray<NetworkInfo> = [\n // https://chainlist.org + https://ethereum.org (Ethereum mainnet chainId 1)\n entry(1, \"Ethereum\", \"ETH\", false, \"https://ethereum.org/en/developers/docs/networks/\"),\n // https://docs.base.org — Base Sepolia 84532\n entry(8453, \"Base\", \"ETH\", false, \"https://docs.base.org/docs/network-information\", true),\n // https://docs.arbitrum.io — Arbitrum Sepolia 421614\n entry(\n 42161,\n \"Arbitrum One\",\n \"ETH\",\n false,\n \"https://docs.arbitrum.io/for-devs/dev-tools-and-resources/chain-info\",\n ),\n // https://docs.optimism.io — OP Sepolia 11155420\n entry(10, \"OP Mainnet\", \"ETH\", false, \"https://docs.optimism.io/chain/networks\", true),\n // https://docs.polygon.technology — Amoy 80002\n entry(\n 137,\n \"Polygon\",\n \"POL\",\n false,\n \"https://docs.polygon.technology/pos/reference/rpc-endpoints/\",\n ),\n // https://docs.bnbchain.org — BSC testnet 97\n entry(\n 56,\n \"BNB Smart Chain\",\n \"BNB\",\n false,\n \"https://docs.bnbchain.org/bnb-smart-chain/developers/json_rpc/\",\n ),\n // https://hyperliquid.gitbook.io — HyperEVM testnet 998\n entry(\n 999,\n \"HyperEVM\",\n \"HYPE\",\n false,\n \"https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm\",\n ),\n // https://build.avax.network — Fuji 43113\n entry(\n 43114,\n \"Avalanche C-Chain\",\n \"AVAX\",\n false,\n \"https://build.avax.network/docs/tooling/rpc-providers\",\n ),\n entry(11155111, \"Sepolia\", \"ETH\", true, \"https://ethereum.org/en/developers/docs/networks/\"),\n entry(84532, \"Base Sepolia\", \"ETH\", true, \"https://docs.base.org/docs/network-information\", true),\n entry(\n 421614,\n \"Arbitrum Sepolia\",\n \"ETH\",\n true,\n \"https://docs.arbitrum.io/for-devs/dev-tools-and-resources/chain-info\",\n ),\n entry(11155420, \"OP Sepolia\", \"ETH\", true, \"https://docs.optimism.io/chain/networks\", true),\n entry(\n 80002,\n \"Polygon Amoy\",\n \"POL\",\n true,\n \"https://docs.polygon.technology/pos/reference/rpc-endpoints/\",\n ),\n entry(\n 97,\n \"BNB Smart Chain Testnet\",\n \"tBNB\",\n true,\n \"https://docs.bnbchain.org/bnb-smart-chain/developers/json_rpc/\",\n ),\n entry(\n 998,\n \"HyperEVM Testnet\",\n \"HYPE\",\n true,\n \"https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm\",\n ),\n entry(\n 43113,\n \"Avalanche Fuji\",\n \"AVAX\",\n true,\n \"https://build.avax.network/docs/tooling/rpc-providers\",\n ),\n];\n\nexport const networkById = (id: string): NetworkInfo | undefined =>\n [...NETWORKS, ...SOLANA_NETWORKS, ...BITCOIN_NETWORKS].find((n) => n.id === id);\nexport const BITCOIN_NETWORKS: ReadonlyArray<NetworkInfo> = [\n {\n id: \"bip122:000000000019d6689c085ae165831e93\",\n chainId: 0,\n name: \"Bitcoin\",\n symbol: \"BTC\",\n decimals: 8,\n testnet: false,\n family: \"bitcoin\",\n genesisHash: \"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f\",\n },\n {\n id: \"bip122:00000000da84f2bafbbc53dee25a72ae\",\n chainId: 0,\n name: \"Bitcoin Testnet4\",\n symbol: \"tBTC\",\n decimals: 8,\n testnet: true,\n family: \"bitcoin\",\n genesisHash: \"00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043\",\n },\n {\n id: \"bip122:00000008819873e925422c1ff0f99f7c\",\n chainId: 0,\n name: \"Bitcoin Signet\",\n symbol: \"sBTC\",\n decimals: 8,\n testnet: true,\n family: \"bitcoin\",\n genesisHash: \"00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6\",\n },\n {\n id: \"bip122:0f9188f13cb7b2c71f2a335e3a4fc328\",\n chainId: 0,\n name: \"Bitcoin Regtest\",\n symbol: \"rBTC\",\n decimals: 8,\n testnet: true,\n family: \"bitcoin\",\n genesisHash: \"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206\",\n },\n];\n\nexport const SOLANA_NETWORKS: ReadonlyArray<NetworkInfo> = [\n {\n id: \"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp\",\n chainId: 0,\n name: \"Solana\",\n symbol: \"SOL\",\n decimals: 9,\n testnet: false,\n family: \"solana\",\n // https://solana.com/docs/references/clusters (mainnet genesis hash)\n genesisHash: \"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d\",\n },\n {\n id: \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\",\n chainId: 0,\n name: \"Solana Devnet\",\n symbol: \"SOL\",\n decimals: 9,\n testnet: true,\n family: \"solana\",\n genesisHash: \"EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG\",\n },\n];\n"],"mappings":";;;;;;;AA6BA,MAAM,wBAA0D;CAC9D,GAAG;CACH,MAAM;CACN,OAAO;CACP,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,UAAU;CACV,OAAO;CACP,QAAQ;CACR,UAAU;CACV,OAAO;CACP,IAAI;AACN;AAEA,MAAM,SACJ,SACA,MACA,QACA,SACA,SACA,aACiB;CACjB,IAAI,UAAU;CACd;CACA;CACA;CACA,UAAU;CACV;CACA,QAAQ;CAER,YAAY;CACZ,GAAI,YAAY,OAAO,EAAE,QAAQ,IAAI,CAAC;CACtC,GAAI,sBAAsB,aAAa,KAAA,IACnC,CAAC,IACD,EAAE,mBAAmB,sBAAsB,SAAS;AAC1D;AAEA,MAAa,WAAuC;CAElD,MAAM,GAAG,YAAY,OAAO,OAAO,mDAAmD;CAEtF,MAAM,MAAM,QAAQ,OAAO,OAAO,kDAAkD,IAAI;CAExF,MACE,OACA,gBACA,OACA,OACA,sEACF;CAEA,MAAM,IAAI,cAAc,OAAO,OAAO,2CAA2C,IAAI;CAErF,MACE,KACA,WACA,OACA,OACA,8DACF;CAEA,MACE,IACA,mBACA,OACA,OACA,gEACF;CAEA,MACE,KACA,YACA,QACA,OACA,yEACF;CAEA,MACE,OACA,qBACA,QACA,OACA,uDACF;CACA,MAAM,UAAU,WAAW,OAAO,MAAM,mDAAmD;CAC3F,MAAM,OAAO,gBAAgB,OAAO,MAAM,kDAAkD,IAAI;CAChG,MACE,QACA,oBACA,OACA,MACA,sEACF;CACA,MAAM,UAAU,cAAc,OAAO,MAAM,2CAA2C,IAAI;CAC1F,MACE,OACA,gBACA,OACA,MACA,8DACF;CACA,MACE,IACA,2BACA,QACA,MACA,gEACF;CACA,MACE,KACA,oBACA,QACA,MACA,yEACF;CACA,MACE,OACA,kBACA,QACA,MACA,uDACF;AACF;AAEA,MAAa,eAAe,OAC1B;CAAC,GAAG;CAAU,GAAG;CAAiB,GAAG;AAAgB,CAAC,CAAC,MAAM,MAAM,EAAE,OAAO,EAAE;AAChF,MAAa,mBAA+C;CAC1D;EACE,IAAI;EACJ,SAAS;EACT,MAAM;EACN,QAAQ;EACR,UAAU;EACV,SAAS;EACT,QAAQ;EACR,aAAa;CACf;CACA;EACE,IAAI;EACJ,SAAS;EACT,MAAM;EACN,QAAQ;EACR,UAAU;EACV,SAAS;EACT,QAAQ;EACR,aAAa;CACf;CACA;EACE,IAAI;EACJ,SAAS;EACT,MAAM;EACN,QAAQ;EACR,UAAU;EACV,SAAS;EACT,QAAQ;EACR,aAAa;CACf;CACA;EACE,IAAI;EACJ,SAAS;EACT,MAAM;EACN,QAAQ;EACR,UAAU;EACV,SAAS;EACT,QAAQ;EACR,aAAa;CACf;AACF;AAEA,MAAa,kBAA8C,CACzD;CACE,IAAI;CACJ,SAAS;CACT,MAAM;CACN,QAAQ;CACR,UAAU;CACV,SAAS;CACT,QAAQ;CAER,aAAa;AACf,GACA;CACE,IAAI;CACJ,SAAS;CACT,MAAM;CACN,QAAQ;CACR,UAAU;CACV,SAAS;CACT,QAAQ;CACR,aAAa;AACf,CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as SOLANA_NETWORKS, t as BITCOIN_NETWORKS$1 } from "./registry-
|
|
1
|
+
import { r as SOLANA_NETWORKS, t as BITCOIN_NETWORKS$1 } from "./registry-oorLoGtz.mjs";
|
|
2
2
|
import { createStore } from "zustand/vanilla";
|
|
3
3
|
import { bytesToHex, hexToBytes } from "@noble/hashes/utils.js";
|
|
4
4
|
import { ChainError, parseSignIn } from "@qntx/wallet-chains";
|
|
@@ -11,6 +11,7 @@ import { SparkInputError, bitcoinAddressScript, decodeBolt11, decodeSparkAddress
|
|
|
11
11
|
import { decodeLnurl, encodeLnurl, lightningAddressUrl, requestInvoice, resolveLnurl, submitWithdraw } from "@qntx/spark/lnurl";
|
|
12
12
|
import { signedMatchesUnsigned } from "@qntx/nostr";
|
|
13
13
|
import { makeZapRequest } from "@qntx/nostr/nips/nip57";
|
|
14
|
+
import { chains } from "@qntx/wallet/chains";
|
|
14
15
|
import { SiwxError, checkOrigin, createMessage, parseTimestamp } from "@qntx/siwx";
|
|
15
16
|
import { base58, base64, hex } from "@scure/base";
|
|
16
17
|
import { p2wpkh } from "@scure/btc-signer/payment.js";
|
|
@@ -75,7 +76,11 @@ const SESSION_METHODS = [
|
|
|
75
76
|
"eth_sendTransaction",
|
|
76
77
|
"personal_sign",
|
|
77
78
|
"eth_signTypedData_v4",
|
|
78
|
-
"wallet_watchAsset"
|
|
79
|
+
"wallet_watchAsset",
|
|
80
|
+
"wallet_getCapabilities",
|
|
81
|
+
"wallet_sendCalls",
|
|
82
|
+
"wallet_getCallsStatus",
|
|
83
|
+
"wallet_showCallsStatus"
|
|
79
84
|
];
|
|
80
85
|
const SESSION_NOTIFICATIONS = ["accountsChanged", "chainChanged"];
|
|
81
86
|
/** The `nostr` namespace scope's granted methods — the NIP-07 surface. */
|
|
@@ -993,7 +998,39 @@ const SPARK_L1_NETWORK = {
|
|
|
993
998
|
// src/transactions/route.ts
|
|
994
999
|
const hexId = (prefix, random) => `${prefix}-${[...random(8)].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
995
1000
|
const newId = (random) => hexId("tx", random);
|
|
1001
|
+
/** The account's address; signer-dependent checks fail closed when an account carries none. */
|
|
1002
|
+
const accountAddress = (account) => {
|
|
1003
|
+
const { address } = account;
|
|
1004
|
+
if (typeof address !== "string" || address === "") throw new Error("account carries no address");
|
|
1005
|
+
return address;
|
|
1006
|
+
};
|
|
996
1007
|
const newRequestId = (random) => hexId("req", random);
|
|
1008
|
+
const TEMPLATE_FAMILY = {
|
|
1009
|
+
"evm.bip44": "evm",
|
|
1010
|
+
"solana.bip44-change": "solana"
|
|
1011
|
+
};
|
|
1012
|
+
/**
|
|
1013
|
+
* The signer address for a send/sign account ref: HD refs derive through the chains proxy; an
|
|
1014
|
+
* imported ref resolves its stored address from `wallet.keys` — the ref's family and the key's
|
|
1015
|
+
* listed family must both match the network's family or the request is refused.
|
|
1016
|
+
*/
|
|
1017
|
+
const accountAddressOf = async (ctx, account, template, network) => {
|
|
1018
|
+
const family = TEMPLATE_FAMILY[template];
|
|
1019
|
+
if (account.kind === "imported") {
|
|
1020
|
+
if (account.family !== family) throw new ChainError("invalid-request", `an imported ${account.family} key cannot sign on a ${family} network`);
|
|
1021
|
+
const key = (await ctx.options.wallet.keys.list()).find((entry) => entry.keyId === account.keyId);
|
|
1022
|
+
if (key === void 0) throw new ChainError("invalid-request", "the imported key is not in the vault");
|
|
1023
|
+
if (key.family !== family) throw new ChainError("invalid-request", `the imported key is a ${key.family} key, not ${family}`);
|
|
1024
|
+
return key.address;
|
|
1025
|
+
}
|
|
1026
|
+
const apis = ctx.options.chains ?? chains(ctx.options.wallet);
|
|
1027
|
+
return accountAddress(await apis.account({
|
|
1028
|
+
walletId: account.walletId,
|
|
1029
|
+
groupIndex: account.groupIndex,
|
|
1030
|
+
template,
|
|
1031
|
+
network
|
|
1032
|
+
}));
|
|
1033
|
+
};
|
|
997
1034
|
const LIVE_REPLACEMENT_STATES = /* @__PURE__ */ new Set([
|
|
998
1035
|
"draft",
|
|
999
1036
|
"signed",
|
|
@@ -1407,7 +1444,11 @@ function assessApprovals(intent) {
|
|
|
1407
1444
|
code: "collection-approval",
|
|
1408
1445
|
level: "danger"
|
|
1409
1446
|
});
|
|
1410
|
-
} else if (change.
|
|
1447
|
+
} else if (change.kind === "stake-authority") found.set("stake-authority", {
|
|
1448
|
+
code: "stake-authority",
|
|
1449
|
+
level: "danger"
|
|
1450
|
+
});
|
|
1451
|
+
else if (change.change !== "decrease" && change.unlimited) found.set("unlimited-approval", {
|
|
1411
1452
|
code: "unlimited-approval",
|
|
1412
1453
|
level: "warning"
|
|
1413
1454
|
});
|
|
@@ -1632,6 +1673,13 @@ const METHODS = /* @__PURE__ */ new Set([
|
|
|
1632
1673
|
"speed-up",
|
|
1633
1674
|
"cancel",
|
|
1634
1675
|
"cpfp",
|
|
1676
|
+
"evm-delegation",
|
|
1677
|
+
"evm-batch",
|
|
1678
|
+
"evm-approve",
|
|
1679
|
+
"evm-swap",
|
|
1680
|
+
"evm-lido",
|
|
1681
|
+
"solana-stake",
|
|
1682
|
+
"solana-swap",
|
|
1635
1683
|
"pay",
|
|
1636
1684
|
"zap",
|
|
1637
1685
|
"evm-sign",
|
|
@@ -1660,8 +1708,7 @@ const isAccount = (value) => {
|
|
|
1660
1708
|
if (value["kind"] === "hd") return typeof value["walletId"] === "string" && typeof value["groupIndex"] === "number" && typeof value["template"] === "string";
|
|
1661
1709
|
if (value["kind"] === "imported") return typeof value["keyId"] === "string" && FAMILIES.has(value["family"]);
|
|
1662
1710
|
if (value["kind"] === "derived") return typeof value["walletId"] === "string" && typeof value["index"] === "number";
|
|
1663
|
-
|
|
1664
|
-
return value["kind"] === void 0 && typeof value["walletId"] === "string" && typeof value["groupIndex"] === "number" && typeof value["network"] === "string";
|
|
1711
|
+
return value["kind"] === void 0 && typeof value["walletId"] === "string" && typeof value["groupIndex"] === "number";
|
|
1665
1712
|
};
|
|
1666
1713
|
const isOrigin = (value) => isObject$2(value) && (value["kind"] === "internal" || value["kind"] === "browser" && typeof value["origin"] === "string");
|
|
1667
1714
|
const isEntry = (value) => isObject$2(value) && typeof value["id"] === "string" && typeof value["at"] === "number" && isOrigin(value["origin"]) && METHODS.has(value["method"]) && OUTCOMES.has(value["outcome"]) && isAccount(value["account"]);
|
|
@@ -2059,7 +2106,6 @@ var RequestController = class extends Controller {
|
|
|
2059
2106
|
const signInRisk = "signer" in prepared && prepared.intent.message?.kind === "text" ? this.signInRisk(prepared.intent.message.signIn, input.origin, prepared.signer, "evm") : [];
|
|
2060
2107
|
const blindRisk = prepared.intent.message?.kind === "bytes" ? this.blindRisk(input.account) : [];
|
|
2061
2108
|
const { message } = prepared.intent;
|
|
2062
|
-
if (message?.kind === "typed-data" && "signer" in prepared && message.domain.verifyingContract?.toLowerCase() === prepared.signer.toLowerCase()) throw new ChainError("invalid-request", "typed data addressed to your own account is refused");
|
|
2063
2109
|
const permitRisk = message?.kind === "typed-data" ? assessPermits(prepared.intent, this.options.now()) : [];
|
|
2064
2110
|
const orderRisk = message?.kind === "typed-data" && "signer" in prepared ? [...assessSeaport(message.seaport, prepared.signer), ...assessSafe(message.safe)] : [];
|
|
2065
2111
|
const built = {
|
|
@@ -2094,7 +2140,7 @@ var RequestController = class extends Controller {
|
|
|
2094
2140
|
...input.request.kind === "message" && input.request.signIn !== void 0 ? { signIn: input.request.signIn } : {}
|
|
2095
2141
|
},
|
|
2096
2142
|
checks: [],
|
|
2097
|
-
risk: mergeRisk(this.signInRisk(signIn, input.origin, input.account.address, "solana"), message?.kind === "bytes" ? this.blindRisk(input.account) : []),
|
|
2143
|
+
risk: mergeRisk(mergeRisk(this.signInRisk(signIn, input.origin, input.account.address, "solana"), message?.kind === "bytes" ? this.blindRisk(input.account) : []), intents.flatMap((intent) => "approvals" in intent ? assessApprovals(intent) : [])),
|
|
2098
2144
|
run: {
|
|
2099
2145
|
factor: "required",
|
|
2100
2146
|
staleReason: () => void 0,
|
|
@@ -2133,10 +2179,10 @@ var RequestController = class extends Controller {
|
|
|
2133
2179
|
};
|
|
2134
2180
|
}
|
|
2135
2181
|
if (input.method === "bitcoin-sign") {
|
|
2136
|
-
|
|
2137
|
-
|
|
2182
|
+
const { request, account } = input;
|
|
2183
|
+
if (request.kind !== "message" || !("address" in account)) throw new Error("unreachable bitcoin-sign request");
|
|
2138
2184
|
return {
|
|
2139
|
-
account
|
|
2185
|
+
account,
|
|
2140
2186
|
network: input.network,
|
|
2141
2187
|
display: {
|
|
2142
2188
|
kind: "bitcoin.sign",
|
|
@@ -2150,7 +2196,7 @@ var RequestController = class extends Controller {
|
|
|
2150
2196
|
run: {
|
|
2151
2197
|
factor: "required",
|
|
2152
2198
|
staleReason: () => void 0,
|
|
2153
|
-
submit: async (verify) => this.options.bitcoinSign(
|
|
2199
|
+
submit: async (verify) => this.options.bitcoinSign(account, input.network, request, verify),
|
|
2154
2200
|
release: () => void 0
|
|
2155
2201
|
}
|
|
2156
2202
|
};
|
|
@@ -2239,19 +2285,20 @@ var RequestController = class extends Controller {
|
|
|
2239
2285
|
release: () => void 0
|
|
2240
2286
|
}
|
|
2241
2287
|
};
|
|
2242
|
-
const
|
|
2288
|
+
const internal = input.method === "evm-delegation" || input.method === "evm-batch" || input.method === "evm-approve" || input.method === "evm-swap" || input.method === "evm-nft-send" || input.method === "evm-bridge" || input.method === "evm-lido" || input.method === "solana-stake" || input.method === "solana-swap" || input.method === "solana-core-send";
|
|
2289
|
+
const prepared = input.method === "send" ? await this.options.transactions.prepareSend(input, id) : input.method === "solana-stake" ? await this.options.transactions.prepareSolanaStake(input, id) : input.method === "solana-swap" ? await this.options.transactions.prepareSolanaSwap(input, id) : input.method === "solana-core-send" ? await this.options.transactions.prepareSolanaCoreSend(input, id) : internal ? await this.options.transactions.prepareEvmInternal(input, id) : await this.options.transactions.prepareReplacement(input, id);
|
|
2243
2290
|
const built = {
|
|
2244
2291
|
account: prepared.account,
|
|
2245
2292
|
network: prepared.network,
|
|
2246
2293
|
display: prepared.intent,
|
|
2247
2294
|
checks: collectChecks([prepared.intent.verifiability === "full" ? void 0 : "decode-partial", ...prepared.checks]),
|
|
2248
|
-
risk: input.method === "send" ? this.chainRisk(prepared.intent) : [],
|
|
2295
|
+
risk: input.method === "send" || internal ? this.chainRisk(prepared.intent) : [],
|
|
2249
2296
|
run: {
|
|
2250
2297
|
...prepared,
|
|
2251
2298
|
factor: "required"
|
|
2252
2299
|
}
|
|
2253
2300
|
};
|
|
2254
|
-
return input.method === "send" ? withSimulation(built, prepared.intent, prepared.simulation, prepared.resimulate) : built;
|
|
2301
|
+
return input.method === "send" || internal ? withSimulation(built, prepared.intent, prepared.simulation, prepared.resimulate) : built;
|
|
2255
2302
|
}
|
|
2256
2303
|
async approve(id, method, verify) {
|
|
2257
2304
|
const request = this.getState().requests[id];
|
|
@@ -2626,8 +2673,8 @@ var BitcoinWalletHandler = class {
|
|
|
2626
2673
|
}
|
|
2627
2674
|
/**
|
|
2628
2675
|
* Signs (and with `send` broadcasts) a batch of dApp PSBTs under one approval. Every account
|
|
2629
|
-
* named must be a session account of
|
|
2630
|
-
*
|
|
2676
|
+
* named must be a session account — inputs of both purposes may mix in one PSBT, each sign entry
|
|
2677
|
+
* carries its account's template — and `chain`, when given, must be the session's network.
|
|
2631
2678
|
*/
|
|
2632
2679
|
async signTransactions(checked, request, send) {
|
|
2633
2680
|
const network = this.options.bitcoinNetwork();
|
|
@@ -2637,36 +2684,28 @@ var BitcoinWalletHandler = class {
|
|
|
2637
2684
|
const inputs = transactionInputs(request.params);
|
|
2638
2685
|
if (send && inputs.some((input) => input.chain === void 0)) throw invalidParams("chain is required for bitcoin:signAndSendTransaction");
|
|
2639
2686
|
if (inputs.some((input) => input.chain !== void 0 && BITCOIN_CHAIN_IDS[input.chain] !== network)) throw invalidParams("chain is not the connected network");
|
|
2640
|
-
const
|
|
2641
|
-
for (const { address } of inputs.flatMap((input) => input.inputsToSign)) {
|
|
2687
|
+
const templateOf = (address) => {
|
|
2642
2688
|
const purpose = BITCOIN_PURPOSES.find((p) => accounts[p] === address);
|
|
2643
2689
|
if (purpose === void 0) throw new ProviderError(4100, "account is not a connected account");
|
|
2644
|
-
|
|
2645
|
-
}
|
|
2646
|
-
const [purpose, ...rest] = purposes;
|
|
2647
|
-
if (purpose === void 0) throw invalidParams("inputsToSign names no account");
|
|
2648
|
-
if (rest.length > 0) throw invalidParams("mixed payment and ordinals inputs are not supported yet");
|
|
2690
|
+
return TEMPLATES[purpose];
|
|
2691
|
+
};
|
|
2649
2692
|
const group = this.options.activeGroup();
|
|
2650
2693
|
if (group === void 0) throw new ProviderError(4100, "no account group is selected");
|
|
2651
|
-
const account = {
|
|
2652
|
-
...group,
|
|
2653
|
-
address: accounts[purpose],
|
|
2654
|
-
template: TEMPLATES[purpose]
|
|
2655
|
-
};
|
|
2656
2694
|
let outcome;
|
|
2657
2695
|
try {
|
|
2658
2696
|
const pending = await this.options.requests.prepare({
|
|
2659
2697
|
method: "bitcoin-sign",
|
|
2660
2698
|
origin: checked,
|
|
2661
|
-
account,
|
|
2699
|
+
account: group,
|
|
2662
2700
|
network,
|
|
2663
2701
|
request: {
|
|
2664
2702
|
kind: "psbt",
|
|
2665
2703
|
psbts: inputs.map(({ psbt, inputsToSign }) => ({
|
|
2666
2704
|
psbt,
|
|
2667
|
-
sign: inputsToSign.flatMap(({ signingIndexes, sigHash }) => signingIndexes.map((index) => ({
|
|
2705
|
+
sign: inputsToSign.flatMap(({ address, signingIndexes, sigHash }) => signingIndexes.map((index) => ({
|
|
2668
2706
|
index,
|
|
2669
|
-
sigHash
|
|
2707
|
+
sigHash,
|
|
2708
|
+
template: templateOf(address)
|
|
2670
2709
|
})))
|
|
2671
2710
|
})),
|
|
2672
2711
|
send
|
|
@@ -3633,6 +3672,6 @@ var WeblnHandler = class {
|
|
|
3633
3672
|
};
|
|
3634
3673
|
}
|
|
3635
3674
|
};
|
|
3636
|
-
export {
|
|
3675
|
+
export { errorMessage as $, accountAddressOf as A, safeDecimals as B, exceedsNetworkCap as C, mergeSatPerByte as D, mergeEvmQuote as E, prepareZap as F, ProviderError as G, normalizeAddress as H, withdrawLnurl as I, unauthorized as J, internalError as K, PaymentError as L, newId as M, replacementStaleReason as N, mergeSolanaQuote as O, submitTx as P, EngineStoreError as Q, SparkControllerError as R, collectChecks as S, feesDiffer as T, ConnectionController as U, safeDisplayText as V, evmChainId as W, unsupportedMethod as X, unrecognizedChain as Y, userRejectedRequest as Z, boundedSimulation as _, Nip07Handler as a, feeTiers as b, SessionEvents as c, OriginBusyError as d, Controller as et, REQUEST_TTL_MS as f, SignInOriginError as g, RequestEndedError as h, SolanaWalletHandler as i, failTx as j, accountAddress as k, BlindSigningDisabledError as l, RequestController as m, parsePayment as n, BITCOIN_CHAIN_IDS as o, RESIMULATE_AFTER_MS as p, invalidParams as q, SOLANA_CHAIN_IDS as r, BitcoinWalletHandler as s, WeblnHandler as t, InvalidTokenError as u, BitcoinChainAdapter as v, feeReachesAmount as w, timeoutSignal as x, esplora as y, categorize as z };
|
|
3637
3676
|
|
|
3638
|
-
//# sourceMappingURL=webln-
|
|
3677
|
+
//# sourceMappingURL=webln-DKqCnqx1.mjs.map
|