@qntx/wallet-engine 0.13.0 → 0.14.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.
Files changed (80) hide show
  1. package/README.md +1057 -20
  2. package/dist/apps-fiat24.d.mts +202 -0
  3. package/dist/apps-fiat24.mjs +1378 -0
  4. package/dist/apps-fiat24.mjs.map +1 -0
  5. package/dist/apps-hyperliquid.d.mts +549 -0
  6. package/dist/apps-hyperliquid.mjs +2742 -0
  7. package/dist/apps-hyperliquid.mjs.map +1 -0
  8. package/dist/apps-polymarket.d.mts +729 -0
  9. package/dist/apps-polymarket.mjs +3786 -0
  10. package/dist/apps-polymarket.mjs.map +1 -0
  11. package/dist/apps.d.mts +136 -0
  12. package/dist/apps.mjs +535 -0
  13. package/dist/apps.mjs.map +1 -0
  14. package/dist/connect-BY1C5ZRI.mjs +210 -0
  15. package/dist/connect-BY1C5ZRI.mjs.map +1 -0
  16. package/dist/connect.d.mts +17 -9
  17. package/dist/connect.mjs +3 -185
  18. package/dist/{errors-CQnlTc1i.d.mts → controller-DpNVHVsj.d.mts} +1093 -758
  19. package/dist/controller-rMnaxKAH.mjs +46 -0
  20. package/dist/controller-rMnaxKAH.mjs.map +1 -0
  21. package/dist/decimal-COJ4g8qy.mjs +38 -0
  22. package/dist/decimal-COJ4g8qy.mjs.map +1 -0
  23. package/dist/eligibility-BfM9ybYZ.mjs +48 -0
  24. package/dist/eligibility-BfM9ybYZ.mjs.map +1 -0
  25. package/dist/engine-Dic_kkEr.d.mts +1829 -0
  26. package/dist/errors-B8W-hoYW.d.mts +7 -0
  27. package/dist/errors-horUy5k1.mjs +24 -0
  28. package/dist/errors-horUy5k1.mjs.map +1 -0
  29. package/dist/gateway-contract.d.mts +3 -608
  30. package/dist/gateway-contract.mjs +1467 -161
  31. package/dist/gateway-contract.mjs.map +1 -1
  32. package/dist/idb.d.mts +5 -0
  33. package/dist/idb.mjs +122 -46
  34. package/dist/idb.mjs.map +1 -1
  35. package/dist/index-vBgfOFIh.d.mts +2227 -0
  36. package/dist/index.d.mts +58 -618
  37. package/dist/index.mjs +21963 -6836
  38. package/dist/index.mjs.map +1 -1
  39. package/dist/json-BDwV38cj.mjs +15 -0
  40. package/dist/json-BDwV38cj.mjs.map +1 -0
  41. package/dist/link-Ceq8Dggp.mjs +139 -0
  42. package/dist/link-Ceq8Dggp.mjs.map +1 -0
  43. package/dist/primitives-DbSHLZKq.mjs +31 -0
  44. package/dist/primitives-DbSHLZKq.mjs.map +1 -0
  45. package/dist/push-message-AQuzoNFY.d.mts +84 -0
  46. package/dist/push-message-kbnH1A5w.mjs +142 -0
  47. package/dist/push-message-kbnH1A5w.mjs.map +1 -0
  48. package/dist/push.d.mts +13 -0
  49. package/dist/push.mjs +70 -0
  50. package/dist/push.mjs.map +1 -0
  51. package/dist/qr.d.mts +292 -0
  52. package/dist/qr.mjs +1725 -0
  53. package/dist/qr.mjs.map +1 -0
  54. package/dist/registry-CbtwcxkX.mjs +374 -0
  55. package/dist/registry-CbtwcxkX.mjs.map +1 -0
  56. package/dist/risk-DyABgg4W.mjs +757 -0
  57. package/dist/risk-DyABgg4W.mjs.map +1 -0
  58. package/dist/session-CNJFLarP.mjs +18 -0
  59. package/dist/session-CNJFLarP.mjs.map +1 -0
  60. package/dist/socket-ChG9JRT_.mjs +110 -0
  61. package/dist/socket-ChG9JRT_.mjs.map +1 -0
  62. package/dist/spi-BrTw5s98.d.mts +3 -0
  63. package/dist/timer-Cdk5rGM2.mjs +43 -0
  64. package/dist/timer-Cdk5rGM2.mjs.map +1 -0
  65. package/dist/types-BpvioFGo.d.mts +258 -0
  66. package/dist/types-DbftVZ3I.mjs +90 -0
  67. package/dist/types-DbftVZ3I.mjs.map +1 -0
  68. package/dist/walletconnect.d.mts +86 -0
  69. package/dist/walletconnect.mjs +1507 -0
  70. package/dist/walletconnect.mjs.map +1 -0
  71. package/dist/webln-BgrtPXpG.mjs +2593 -0
  72. package/dist/webln-BgrtPXpG.mjs.map +1 -0
  73. package/dist/webln-Bllk_xJ2.d.mts +666 -0
  74. package/package.json +92 -19
  75. package/dist/connect.mjs.map +0 -1
  76. package/dist/registry-DwguKWvt.d.mts +0 -27
  77. package/dist/registry-oorLoGtz.mjs +0 -120
  78. package/dist/registry-oorLoGtz.mjs.map +0 -1
  79. package/dist/webln-DKqCnqx1.mjs +0 -3677
  80. package/dist/webln-DKqCnqx1.mjs.map +0 -1
@@ -0,0 +1,90 @@
1
+ import { t as APP_ID } from "./eligibility-BfM9ybYZ.mjs";
2
+ // src/requests/types.ts
3
+ /** The URL a dApp origin's phishing and sign-in checks run against. */
4
+ const dappUrl = (origin) => origin.kind === "browser" ? origin.origin : origin.url;
5
+ const walletConnectKey = (topic) => `walletconnect:${topic}`;
6
+ const isObject = (value) => typeof value === "object" && value !== null;
7
+ const VERIFY_VALIDATIONS = /* @__PURE__ */ new Set([
8
+ "VALID",
9
+ "INVALID",
10
+ "UNKNOWN"
11
+ ]);
12
+ /** The persisted shape of a dApp origin; the sign log and session store read them back with it. */
13
+ const isDappOrigin = (value) => {
14
+ if (!isObject(value)) return false;
15
+ if (value["kind"] === "browser") return typeof value["origin"] === "string";
16
+ const { verify } = value;
17
+ return value["kind"] === "walletconnect" && typeof value["origin"] === "string" && typeof value["topic"] === "string" && typeof value["url"] === "string" && typeof value["name"] === "string" && isObject(verify) && VERIFY_VALIDATIONS.has(verify["validation"]) && typeof verify["isScam"] === "boolean";
18
+ };
19
+ /** The dApp origin a request origin carries, if any — an app origin is never one. */
20
+ const dappOf = (origin) => origin.kind === "browser" || origin.kind === "walletconnect" ? origin : void 0;
21
+ /** The exact persisted shape of an app origin; `prepare` also validates an `AppOrigin` with it. */
22
+ const isAppOrigin = (value) => isObject(value) && value["kind"] === "app" && typeof value["id"] === "string" && APP_ID.test(value["id"]) && Object.keys(value).length === 2;
23
+ /** The persisted shape of a QR origin; `declared` is already sanitised display text. */
24
+ const isQrOrigin = (value) => {
25
+ if (!isObject(value) || value["kind"] !== "qr") return false;
26
+ if (!Object.keys(value).every((key) => key === "kind" || key === "declared")) return false;
27
+ const { declared } = value;
28
+ return declared === void 0 || typeof declared === "string" && declared.length <= 64;
29
+ };
30
+ /** The persisted shape of a request origin. */
31
+ const isRequestOrigin = (value) => {
32
+ if (!isObject(value)) return false;
33
+ return value["kind"] === "internal" || isAppOrigin(value) || isDappOrigin(value) || isQrOrigin(value);
34
+ };
35
+ /** A token the page asked to watch whose on-chain metadata cannot be shown; the dApp's bad input. */
36
+ var InvalidTokenError = class extends Error {
37
+ constructor(message) {
38
+ super(message);
39
+ this.name = "InvalidTokenError";
40
+ }
41
+ };
42
+ /** A Sign-In with X message for another domain than the page that asked for the signature. */
43
+ var SignInOriginError = class extends Error {
44
+ constructor(message) {
45
+ super(message);
46
+ this.name = "SignInOriginError";
47
+ }
48
+ };
49
+ /** A request that ended without a result: `stage` says how, `message` is the failure if any. */
50
+ var RequestEndedError = class extends Error {
51
+ stage;
52
+ /**
53
+ * Whether the request had reached the `signed` stage when it ended — `false` proves nothing it
54
+ * produced was broadcast, `true` means a signature may already be out.
55
+ */
56
+ signed;
57
+ constructor(stage, message, signed) {
58
+ super(message ?? `request ${stage}`);
59
+ this.name = "RequestEndedError";
60
+ this.stage = stage;
61
+ this.signed = signed;
62
+ }
63
+ };
64
+ /**
65
+ * An app pinned the nonce its transaction must carry but the sender's next free nonce differs — the
66
+ * request is refused before anything is shown rather than signed at a nonce that would sit
67
+ * `unknown` forever.
68
+ */
69
+ var NonceConflictError = class extends Error {
70
+ /** The nonce the caller requires the transaction to carry. */
71
+ expected;
72
+ /** The sender's next free nonce as the engine sees it. */
73
+ next;
74
+ constructor(expected, next) {
75
+ super("the transaction must carry a nonce the sender cannot sign next");
76
+ this.name = "NonceConflictError";
77
+ this.expected = expected;
78
+ this.next = next;
79
+ }
80
+ };
81
+ /** The origin already has a request in flight; a dApp gets one at a time. */
82
+ var OriginBusyError = class extends Error {
83
+ constructor(origin) {
84
+ super(`${origin} already has an unfinished request`);
85
+ this.name = "OriginBusyError";
86
+ }
87
+ };
88
+ export { SignInOriginError as a, isAppOrigin as c, walletConnectKey as d, RequestEndedError as i, isDappOrigin as l, NonceConflictError as n, dappOf as o, OriginBusyError as r, dappUrl as s, InvalidTokenError as t, isRequestOrigin as u };
89
+
90
+ //# sourceMappingURL=types-DbftVZ3I.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-DbftVZ3I.mjs","names":[],"sources":["../src/requests/types.ts"],"sourcesContent":["/**\n * Request method and origin types shared by the request controller and its sign log — kept in a\n * leaf module so persistence code can name them without importing the controller. The pipeline's\n * error classes live here too so the connect layer's provider-error mapping can test them without\n * importing the controller either.\n */\nimport type { BitcoinTemplate, SignRequest } from \"@qntx/wallet-chains\";\nimport type { BitcoinOwn } from \"@qntx/wallet-chains/bitcoin\";\n\nimport { APP_ID } from \"../gateway/contract/eligibility.ts\";\n\nexport type ChainRequestMethod =\n | \"send\"\n | \"speed-up\"\n | \"cancel\"\n | \"cpfp\"\n | \"evm-delegation\"\n | \"evm-batch\"\n | \"evm-approve\"\n | \"evm-revoke\"\n | \"evm-cctp\"\n | \"evm-swap\"\n | \"evm-bridge\"\n | \"evm-nft-send\"\n | \"solana-nft-send\"\n | \"evm-lido\"\n | \"solana-stake\"\n | \"solana-revoke\"\n | \"solana-swap\"\n | \"tron-stake\"\n | \"tron-approve\";\n\n/** A web page; `origin` is `scheme://host[:port]`, computed by the host from the top-level URL. */\nexport type BrowserOrigin = { readonly kind: \"browser\"; readonly origin: string };\n\nexport type WalletConnectVerify = {\n readonly validation: \"VALID\" | \"INVALID\" | \"UNKNOWN\";\n readonly isScam: boolean;\n};\n\n/** A WalletConnect peer. `origin` is the session key `walletconnect:<topic>` — never a URL. */\nexport type WalletConnectOrigin = {\n readonly kind: \"walletconnect\";\n readonly origin: string;\n readonly topic: string;\n /** The peer's self-declared metadata URL reduced to its origin — display only, never verified. */\n readonly url: string;\n readonly name: string;\n readonly verify: WalletConnectVerify;\n};\n\nexport type DappOrigin = BrowserOrigin | WalletConnectOrigin;\n\n/** A request an in-engine application (Hyperliquid, …) opened — core never enumerates app ids. */\nexport type AppOrigin = { readonly kind: \"app\"; readonly id: string };\n\n/**\n * A scanned QR sign request. `declared` is the counterpart's self-declared origin text — display\n * only, never verified; it is already sanitised and at most 64 characters.\n */\nexport type QrOrigin = { readonly kind: \"qr\"; readonly declared?: string };\n\nexport type RequestOrigin = { readonly kind: \"internal\" } | AppOrigin | DappOrigin | QrOrigin;\n\n/** The URL a dApp origin's phishing and sign-in checks run against. */\nexport const dappUrl = (origin: DappOrigin): string =>\n origin.kind === \"browser\" ? origin.origin : origin.url;\n\nexport const walletConnectKey = (topic: string): string => `walletconnect:${topic}`;\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst VERIFY_VALIDATIONS: ReadonlySet<unknown> = new Set([\"VALID\", \"INVALID\", \"UNKNOWN\"]);\n\n/** The persisted shape of a dApp origin; the sign log and session store read them back with it. */\nexport const isDappOrigin = (value: unknown): value is DappOrigin => {\n if (!isObject(value)) {\n return false;\n }\n if (value[\"kind\"] === \"browser\") {\n return typeof value[\"origin\"] === \"string\";\n }\n const { verify } = value;\n return (\n value[\"kind\"] === \"walletconnect\" &&\n typeof value[\"origin\"] === \"string\" &&\n typeof value[\"topic\"] === \"string\" &&\n typeof value[\"url\"] === \"string\" &&\n typeof value[\"name\"] === \"string\" &&\n isObject(verify) &&\n VERIFY_VALIDATIONS.has(verify[\"validation\"]) &&\n typeof verify[\"isScam\"] === \"boolean\"\n );\n};\n\n/** The dApp origin a request origin carries, if any — an app origin is never one. */\nexport const dappOf = (origin: RequestOrigin): DappOrigin | undefined =>\n origin.kind === \"browser\" || origin.kind === \"walletconnect\" ? origin : undefined;\n\n/** The exact persisted shape of an app origin; `prepare` also validates an `AppOrigin` with it. */\nexport const isAppOrigin = (value: unknown): value is AppOrigin =>\n isObject(value) &&\n value[\"kind\"] === \"app\" &&\n typeof value[\"id\"] === \"string\" &&\n APP_ID.test(value[\"id\"]) &&\n Object.keys(value).length === 2;\n\n/** The persisted shape of a QR origin; `declared` is already sanitised display text. */\nexport const isQrOrigin = (value: unknown): value is QrOrigin => {\n if (!isObject(value) || value[\"kind\"] !== \"qr\") {\n return false;\n }\n if (!Object.keys(value).every((key) => key === \"kind\" || key === \"declared\")) {\n return false;\n }\n const { declared } = value;\n return declared === undefined || (typeof declared === \"string\" && declared.length <= 64);\n};\n\n/** The persisted shape of a request origin. */\nexport const isRequestOrigin = (value: unknown): value is RequestOrigin => {\n if (!isObject(value)) {\n return false;\n }\n return (\n value[\"kind\"] === \"internal\" || isAppOrigin(value) || isDappOrigin(value) || isQrOrigin(value)\n );\n};\n\nexport type RequestMethod =\n | ChainRequestMethod\n | \"pay\"\n | \"zap\"\n | \"evm-sign\"\n | \"tron-sign\"\n | \"evm-delegation\"\n | \"evm-batch\"\n | \"nostr-sign\"\n | \"webln-invoice\"\n | \"watch-asset\"\n | \"solana-sign\"\n | \"bitcoin-sign\"\n | \"spark-deposit\"\n | \"spark-exit\";\n\n/** A Solana chain account the `solana-sign` request signs for. */\nexport type SolanaAccount = {\n readonly walletId: string;\n readonly groupIndex: number;\n readonly address: string;\n};\n\n/** A Bitcoin account the `bitcoin-sign` request signs for: the group's fixed dApp-facing address. */\nexport type BitcoinAccount = {\n readonly walletId: string;\n readonly groupIndex: number;\n readonly address: string;\n /** `btc.bip84` for the `payment` purpose, `btc.bip86` for `ordinals`. */\n readonly template: \"btc.bip84\" | \"btc.bip86\";\n};\n\n/**\n * The wallet group a `bitcoin-sign` PSBT request signs for: inputs of several dApp-facing templates\n * of the same group may mix in one PSBT — each sign entry names its own template.\n */\nexport type BitcoinGroup = {\n readonly walletId: string;\n readonly groupIndex: number;\n};\n\n/** The sighash a dApp asks for per input; anything else is refused before it reaches a request. */\nexport type BitcoinSigHash = \"ALL\" | \"SINGLE|ANYONECANPAY\";\n\n/**\n * One PSBT and the inputs it asks the wallet to sign — a QR counterpart may request any of the\n * group's four templates where a dApp only uses the two dApp-facing ones.\n */\nexport type BitcoinPsbtInput = {\n readonly psbt: Uint8Array;\n readonly sign: ReadonlyArray<{\n readonly index: number;\n readonly sigHash: BitcoinSigHash;\n readonly template: BitcoinTemplate;\n }>;\n};\n\n/**\n * A dApp PSBT after the engine enriched the requested inputs with this account's derivation data:\n * `request` is what the kernel signs, `own` the verified own-key outputs split into discoverable\n * change and unusual paths, `inputs` the signed inputs' prevout values and sighash (for risk).\n */\nexport type PreparedBitcoinPsbt = {\n readonly request: Extract<SignRequest, { kind: \"bitcoin.psbt\" }>;\n readonly own: BitcoinOwn;\n readonly inputs: ReadonlyArray<{\n readonly index: number;\n readonly value: number;\n readonly sigHash: BitcoinSigHash;\n readonly template: BitcoinTemplate;\n /** The user froze this outpoint — signing it is a danger finding. */\n readonly frozen: boolean;\n }>;\n};\n\n/** A token the page asked to watch whose on-chain metadata cannot be shown; the dApp's bad input. */\nexport class InvalidTokenError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"InvalidTokenError\";\n }\n}\n\n/** A Sign-In with X message for another domain than the page that asked for the signature. */\nexport class SignInOriginError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"SignInOriginError\";\n }\n}\n\n/** A request that ended without a result: `stage` says how, `message` is the failure if any. */\nexport class RequestEndedError extends Error {\n readonly stage: \"rejected\" | \"failed\" | \"expired\" | \"invalidated\";\n /**\n * Whether the request had reached the `signed` stage when it ended — `false` proves nothing it\n * produced was broadcast, `true` means a signature may already be out.\n */\n readonly signed: boolean;\n constructor(stage: RequestEndedError[\"stage\"], message: string | undefined, signed: boolean) {\n super(message ?? `request ${stage}`);\n this.name = \"RequestEndedError\";\n this.stage = stage;\n this.signed = signed;\n }\n}\n\n/**\n * An app pinned the nonce its transaction must carry but the sender's next free nonce differs — the\n * request is refused before anything is shown rather than signed at a nonce that would sit\n * `unknown` forever.\n */\nexport class NonceConflictError extends Error {\n /** The nonce the caller requires the transaction to carry. */\n readonly expected: number;\n /** The sender's next free nonce as the engine sees it. */\n readonly next: number;\n constructor(expected: number, next: number) {\n super(\"the transaction must carry a nonce the sender cannot sign next\");\n this.name = \"NonceConflictError\";\n this.expected = expected;\n this.next = next;\n }\n}\n\n/** The origin already has a request in flight; a dApp gets one at a time. */\nexport class OriginBusyError extends Error {\n constructor(origin: string) {\n super(`${origin} already has an unfinished request`);\n this.name = \"OriginBusyError\";\n }\n}\n"],"mappings":";;;AAiEA,MAAa,WAAW,WACtB,OAAO,SAAS,YAAY,OAAO,SAAS,OAAO;AAErD,MAAa,oBAAoB,UAA0B,iBAAiB;AAE5E,MAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAAU;AAEzC,MAAM,qCAA2C,IAAI,IAAI;CAAC;CAAS;CAAW;AAAS,CAAC;;AAGxF,MAAa,gBAAgB,UAAwC;CACnE,IAAI,CAAC,SAAS,KAAK,GACjB,OAAO;CAET,IAAI,MAAM,YAAY,WACpB,OAAO,OAAO,MAAM,cAAc;CAEpC,MAAM,EAAE,WAAW;CACnB,OACE,MAAM,YAAY,mBAClB,OAAO,MAAM,cAAc,YAC3B,OAAO,MAAM,aAAa,YAC1B,OAAO,MAAM,WAAW,YACxB,OAAO,MAAM,YAAY,YACzB,SAAS,MAAM,KACf,mBAAmB,IAAI,OAAO,aAAa,KAC3C,OAAO,OAAO,cAAc;AAEhC;;AAGA,MAAa,UAAU,WACrB,OAAO,SAAS,aAAa,OAAO,SAAS,kBAAkB,SAAS,KAAA;;AAG1E,MAAa,eAAe,UAC1B,SAAS,KAAK,KACd,MAAM,YAAY,SAClB,OAAO,MAAM,UAAU,YACvB,OAAO,KAAK,MAAM,KAAK,KACvB,OAAO,KAAK,KAAK,CAAC,CAAC,WAAW;;AAGhC,MAAa,cAAc,UAAsC;CAC/D,IAAI,CAAC,SAAS,KAAK,KAAK,MAAM,YAAY,MACxC,OAAO;CAET,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,CAAC,OAAO,QAAQ,QAAQ,UAAU,QAAQ,UAAU,GACzE,OAAO;CAET,MAAM,EAAE,aAAa;CACrB,OAAO,aAAa,KAAA,KAAc,OAAO,aAAa,YAAY,SAAS,UAAU;AACvF;;AAGA,MAAa,mBAAmB,UAA2C;CACzE,IAAI,CAAC,SAAS,KAAK,GACjB,OAAO;CAET,OACE,MAAM,YAAY,cAAc,YAAY,KAAK,KAAK,aAAa,KAAK,KAAK,WAAW,KAAK;AAEjG;;AA8EA,IAAa,oBAAb,cAAuC,MAAM;CAC3C,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,oBAAb,cAAuC,MAAM;CAC3C,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,oBAAb,cAAuC,MAAM;CAC3C;;;;;CAKA;CACA,YAAY,OAAmC,SAA6B,QAAiB;EAC3F,MAAM,WAAW,WAAW,OAAO;EACnC,KAAK,OAAO;EACZ,KAAK,QAAQ;EACb,KAAK,SAAS;CAChB;AACF;;;;;;AAOA,IAAa,qBAAb,cAAwC,MAAM;;CAE5C;;CAEA;CACA,YAAY,UAAkB,MAAc;EAC1C,MAAM,gEAAgE;EACtE,KAAK,OAAO;EACZ,KAAK,WAAW;EAChB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,kBAAb,cAAqC,MAAM;CACzC,YAAY,QAAgB;EAC1B,MAAM,GAAG,OAAO,mCAAmC;EACnD,KAAK,OAAO;CACd;AACF"}
@@ -0,0 +1,86 @@
1
+ import { Et as WalletConnectVerify, Rn as EngineLogger, st as RiskFinding } from "./controller-DpNVHVsj.mjs";
2
+ import { j as ConnectionSession } from "./webln-Bllk_xJ2.mjs";
3
+ import { a as WalletEngine, i as ReadonlyStore } from "./engine-Dic_kkEr.mjs";
4
+ import { Wallet } from "@qntx/wallet";
5
+ import { WalletKit } from "@reown/walletkit";
6
+ import "@walletconnect/types";
7
+ /** What the entry needs from `createWalletEngine` — a `WalletEngine` satisfies it. */
8
+ type WalletConnectEngine = {
9
+ readonly connections: Pick<WalletEngine["connections"], "getState" | "store" | "session" | "sessionAccounts" | "previewAccounts" | "establishWalletConnect" | "revoke" | "invalidateOrigin" | "authorize" | "touch" | "isEnabled">;
10
+ readonly eip1193: Pick<WalletEngine["eip1193"], "handle">;
11
+ readonly solanaWallet: Pick<WalletEngine["solanaWallet"], "handle">;
12
+ readonly bitcoinWallet: Pick<WalletEngine["bitcoinWallet"], "handle">;
13
+ readonly requests: Pick<WalletEngine["requests"], "prepare" | "outcome">;
14
+ readonly phishing: Pick<WalletEngine["phishing"], "check">;
15
+ };
16
+ type WalletConnectStorage = {
17
+ readonly getKeys: () => Promise<string[]>;
18
+ readonly getEntries: () => Promise<Array<[string, unknown]>>;
19
+ readonly getItem: (key: string) => Promise<unknown>;
20
+ readonly setItem: (key: string, value: unknown) => Promise<void>;
21
+ readonly removeItem: (key: string) => Promise<void>;
22
+ };
23
+ type WalletConnectMetadata = {
24
+ readonly name: string;
25
+ readonly description: string;
26
+ readonly url: string;
27
+ readonly icons: ReadonlyArray<string>;
28
+ readonly redirect?: {
29
+ readonly native?: string;
30
+ readonly universal?: string;
31
+ };
32
+ };
33
+ type WalletConnectOptions = {
34
+ readonly projectId: string;
35
+ readonly metadata: WalletConnectMetadata;
36
+ readonly storage: WalletConnectStorage;
37
+ /** Overrides Reown's relay — tests and the gated e2e only. */
38
+ readonly relayUrl?: string;
39
+ readonly wallet: Pick<Wallet, "getSnapshot" | "subscribe">;
40
+ readonly engine: WalletConnectEngine;
41
+ readonly now: () => number;
42
+ readonly logger: EngineLogger;
43
+ };
44
+ type WalletConnectProposal = {
45
+ readonly id: number;
46
+ /** Self-declared by the peer — display only, never verified. */
47
+ readonly peer: {
48
+ readonly name: string;
49
+ readonly url: string;
50
+ readonly description: string;
51
+ readonly icons: ReadonlyArray<string>;
52
+ };
53
+ readonly verify: WalletConnectVerify;
54
+ readonly risk: ReadonlyArray<RiskFinding>;
55
+ /** What the grant may contain: requested ∩ served by a namespace row ∩ enabled, in request order. */
56
+ readonly networks: ReadonlyArray<string>;
57
+ /** The required networks; a grant must keep them all. */
58
+ readonly required: ReadonlyArray<string>;
59
+ /** The WalletConnect methods the session will carry, per namespace. */
60
+ readonly methods: Readonly<Record<string, ReadonlyArray<string>>>;
61
+ readonly expiresAt: number;
62
+ };
63
+ type WalletConnectState = {
64
+ readonly proposals: Readonly<Record<string, WalletConnectProposal>>;
65
+ };
66
+ type WalletConnect = {
67
+ readonly getState: () => WalletConnectState;
68
+ readonly store: ReadonlyStore<WalletConnectState>;
69
+ readonly pair: (uri: string) => Promise<void>;
70
+ readonly approve: (id: number, grant: {
71
+ readonly networks: ReadonlyArray<string>;
72
+ readonly acknowledged?: ReadonlyArray<RiskFinding["code"]>;
73
+ }) => Promise<ConnectionSession>;
74
+ readonly reject: (id: number) => Promise<void>;
75
+ readonly dispose: () => Promise<void>;
76
+ };
77
+ /** The `Core`/`WalletKit` pair plus the controller that drives them — one entry, one instance. */
78
+ export declare const createWalletConnect: (options: WalletConnectOptions) => Promise<WalletConnect>;
79
+ type WalletConnectErrorCode = "invalid-uri" | "expired-uri" | "duplicate-pairing" | "unknown-proposal" | "expired" | "locked" | "blocked" | "invalid-grant" | "unacknowledged";
80
+ /** A `createWalletConnect` misuse or a refused pairing/proposal/grant; `code` says which. */
81
+ export declare class WalletConnectError extends Error {
82
+ readonly code: WalletConnectErrorCode;
83
+ constructor(code: WalletConnectErrorCode, message: string);
84
+ }
85
+ export type { WalletConnect, WalletConnectEngine, WalletConnectErrorCode, WalletConnectMetadata, WalletConnectOptions, WalletConnectProposal, WalletConnectState, WalletConnectStorage };
86
+ //# sourceMappingURL=walletconnect.d.mts.map