@reclack/walletkit 0.0.0-stage → 0.1.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 (170) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +341 -2
  3. package/assets/backpack.webp +0 -0
  4. package/assets/berasig.webp +0 -0
  5. package/assets/bestwallet.webp +0 -0
  6. package/assets/bifrostwallet.webp +0 -0
  7. package/assets/binance.webp +0 -0
  8. package/assets/bitcoincom.webp +0 -0
  9. package/assets/bitget.webp +0 -0
  10. package/assets/bitpay.webp +0 -0
  11. package/assets/bitski.webp +0 -0
  12. package/assets/bitverse.webp +0 -0
  13. package/assets/blockchaincom.webp +0 -0
  14. package/assets/brave.webp +0 -0
  15. package/assets/bybit.webp +0 -0
  16. package/assets/clv.webp +0 -0
  17. package/assets/coin98.webp +0 -0
  18. package/assets/coinbase.webp +0 -0
  19. package/assets/compass.webp +0 -0
  20. package/assets/core.webp +0 -0
  21. package/assets/crypto_com.webp +0 -0
  22. package/assets/ctrl.webp +0 -0
  23. package/assets/dawn.webp +0 -0
  24. package/assets/desig.webp +0 -0
  25. package/assets/enkrypt.webp +0 -0
  26. package/assets/exodus.webp +0 -0
  27. package/assets/foxwallet.webp +0 -0
  28. package/assets/frame.webp +0 -0
  29. package/assets/frontier.webp +0 -0
  30. package/assets/gate.webp +0 -0
  31. package/assets/gemini.webp +0 -0
  32. package/assets/imtoken.webp +0 -0
  33. package/assets/iopay.webp +0 -0
  34. package/assets/kaia.webp +0 -0
  35. package/assets/kaikas.webp +0 -0
  36. package/assets/kraken.webp +0 -0
  37. package/assets/kresuswallet.webp +0 -0
  38. package/assets/ledger.webp +0 -0
  39. package/assets/magiceden.webp +0 -0
  40. package/assets/meco.webp +0 -0
  41. package/assets/metamask.webp +0 -0
  42. package/assets/mew.webp +0 -0
  43. package/assets/nest.webp +0 -0
  44. package/assets/nova.webp +0 -0
  45. package/assets/okto.webp +0 -0
  46. package/assets/okx.webp +0 -0
  47. package/assets/oneinch.webp +0 -0
  48. package/assets/onekey.webp +0 -0
  49. package/assets/phantom.webp +0 -0
  50. package/assets/rabby.webp +0 -0
  51. package/assets/rainbow.webp +0 -0
  52. package/assets/ramper.webp +0 -0
  53. package/assets/ready.webp +0 -0
  54. package/assets/ronin.webp +0 -0
  55. package/assets/safe.webp +0 -0
  56. package/assets/safepal.webp +0 -0
  57. package/assets/solflare.webp +0 -0
  58. package/assets/subwallet.webp +0 -0
  59. package/assets/taho.webp +0 -0
  60. package/assets/talisman.webp +0 -0
  61. package/assets/tokenary.webp +0 -0
  62. package/assets/tokenpocket.webp +0 -0
  63. package/assets/trust-wallet.webp +0 -0
  64. package/assets/uniswap.webp +0 -0
  65. package/assets/universalprofiles.webp +0 -0
  66. package/assets/valora.webp +0 -0
  67. package/assets/wigwam.webp +0 -0
  68. package/assets/xportal.webp +0 -0
  69. package/assets/zeal.webp +0 -0
  70. package/assets/zerion.webp +0 -0
  71. package/custom-elements.json +207 -0
  72. package/dist/abi.d.ts +21 -0
  73. package/dist/abi.d.ts.map +1 -0
  74. package/dist/abi.js +50 -0
  75. package/dist/abi.js.map +1 -0
  76. package/dist/address.d.ts +15 -0
  77. package/dist/address.d.ts.map +1 -0
  78. package/dist/address.js +25 -0
  79. package/dist/address.js.map +1 -0
  80. package/dist/balance.d.ts +78 -0
  81. package/dist/balance.d.ts.map +1 -0
  82. package/dist/balance.js +146 -0
  83. package/dist/balance.js.map +1 -0
  84. package/dist/base58.d.ts +15 -0
  85. package/dist/base58.d.ts.map +1 -0
  86. package/dist/base58.js +52 -0
  87. package/dist/base58.js.map +1 -0
  88. package/dist/catalog-fetch.d.ts +18 -0
  89. package/dist/catalog-fetch.d.ts.map +1 -0
  90. package/dist/catalog-fetch.js +85 -0
  91. package/dist/catalog-fetch.js.map +1 -0
  92. package/dist/catalog.d.ts +57 -0
  93. package/dist/catalog.d.ts.map +1 -0
  94. package/dist/catalog.js +80 -0
  95. package/dist/catalog.js.map +1 -0
  96. package/dist/chains.d.ts +32 -0
  97. package/dist/chains.d.ts.map +1 -0
  98. package/dist/chains.js +103 -0
  99. package/dist/chains.js.map +1 -0
  100. package/dist/config.d.ts +40 -0
  101. package/dist/config.d.ts.map +1 -0
  102. package/dist/config.js +44 -0
  103. package/dist/config.js.map +1 -0
  104. package/dist/deep-links.d.ts +22 -0
  105. package/dist/deep-links.d.ts.map +1 -0
  106. package/dist/deep-links.js +201 -0
  107. package/dist/deep-links.js.map +1 -0
  108. package/dist/device.d.ts +23 -0
  109. package/dist/device.d.ts.map +1 -0
  110. package/dist/device.js +59 -0
  111. package/dist/device.js.map +1 -0
  112. package/dist/element/attributes.d.ts +48 -0
  113. package/dist/element/element.d.ts +92 -0
  114. package/dist/element/index.d.ts +4 -0
  115. package/dist/element/props.d.ts +67 -0
  116. package/dist/element/ui/app.d.ts +22 -0
  117. package/dist/element/ui/assets.d.ts +7 -0
  118. package/dist/element/ui/qr.d.ts +16 -0
  119. package/dist/element/ui/use-handheld.d.ts +8 -0
  120. package/dist/element/ui/wallet-connect-panel.d.ts +26 -0
  121. package/dist/element/ui/wallet-dialog.d.ts +37 -0
  122. package/dist/element/ui/wallet-list.d.ts +26 -0
  123. package/dist/element/ui/wallet-mark.d.ts +15 -0
  124. package/dist/element.js +2079 -0
  125. package/dist/errors.d.ts +34 -0
  126. package/dist/errors.d.ts.map +1 -0
  127. package/dist/errors.js +64 -0
  128. package/dist/errors.js.map +1 -0
  129. package/dist/evm.d.ts +49 -0
  130. package/dist/evm.d.ts.map +1 -0
  131. package/dist/evm.js +217 -0
  132. package/dist/evm.js.map +1 -0
  133. package/dist/icons.d.ts +22 -0
  134. package/dist/icons.d.ts.map +1 -0
  135. package/dist/icons.js +98 -0
  136. package/dist/icons.js.map +1 -0
  137. package/dist/index.d.ts +39 -0
  138. package/dist/index.d.ts.map +1 -0
  139. package/dist/index.js +43 -0
  140. package/dist/index.js.map +1 -0
  141. package/dist/intent.d.ts +60 -0
  142. package/dist/intent.d.ts.map +1 -0
  143. package/dist/intent.js +2 -0
  144. package/dist/intent.js.map +1 -0
  145. package/dist/kit.d.ts +124 -0
  146. package/dist/kit.d.ts.map +1 -0
  147. package/dist/kit.js +362 -0
  148. package/dist/kit.js.map +1 -0
  149. package/dist/svm.d.ts +45 -0
  150. package/dist/svm.d.ts.map +1 -0
  151. package/dist/svm.js +201 -0
  152. package/dist/svm.js.map +1 -0
  153. package/dist/theme.d.ts +101 -0
  154. package/dist/theme.d.ts.map +1 -0
  155. package/dist/theme.js +217 -0
  156. package/dist/theme.js.map +1 -0
  157. package/dist/types.d.ts +144 -0
  158. package/dist/types.d.ts.map +1 -0
  159. package/dist/types.js +2 -0
  160. package/dist/types.js.map +1 -0
  161. package/dist/wallet-standard.d.ts +77 -0
  162. package/dist/wallet-standard.d.ts.map +1 -0
  163. package/dist/wallet-standard.js +89 -0
  164. package/dist/wallet-standard.js.map +1 -0
  165. package/dist/walletconnect.d.ts +74 -0
  166. package/dist/walletconnect.d.ts.map +1 -0
  167. package/dist/walletconnect.js +133 -0
  168. package/dist/walletconnect.js.map +1 -0
  169. package/package.json +71 -3
  170. package/vscode.html-custom-data.json +55 -0
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Wallet errors, and turning one into something a person can read.
3
+ *
4
+ * Family-neutral and so in its own file, beside evm.ts and svm.ts rather than
5
+ * inside either: a payer who rejects a request in their wallet has done the
6
+ * same thing whichever chain they were paying on, and the message they see
7
+ * must not depend on which module happened to own the type.
8
+ */
9
+ /** Errors a payer can actually act on, separated from raw RPC noise. */
10
+ export declare class WalletError extends Error {
11
+ code?: number;
12
+ /**
13
+ * Marks a message this app wrote, so walletErrorMessage shows it verbatim.
14
+ *
15
+ * Without it every deliberate message ("your wallet holds 0 USDC…") was
16
+ * replaced by the generic fallback, which told the payer nothing and hid
17
+ * the actual reason the payment stopped.
18
+ */
19
+ readonly payerFacing = true;
20
+ constructor(message: string, code?: number);
21
+ }
22
+ export interface ProviderRpcError {
23
+ code?: number;
24
+ message?: string;
25
+ }
26
+ /**
27
+ * Turns a provider rejection into something a person can read.
28
+ *
29
+ * Raw RPC errors leak internals and frighten payers; the codes that matter
30
+ * are standardised (EIP-1193 / EIP-1474) and Solana wallets reuse the same
31
+ * numbers, so they are mapped explicitly for both and anything unrecognised
32
+ * falls back to a plain sentence.
33
+ */
34
+ export declare function walletErrorMessage(error: unknown, fallback: string): string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,wEAAwE;AACxE,qBAAa,WAAY,SAAQ,KAAK;IAGrC,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;;;;;OAMG;IACH,QAAQ,CAAC,WAAW,QAAO;gBAEd,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAK3C;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB;AAgBD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAgB5E"}
package/dist/errors.js ADDED
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Wallet errors, and turning one into something a person can read.
3
+ *
4
+ * Family-neutral and so in its own file, beside evm.ts and svm.ts rather than
5
+ * inside either: a payer who rejects a request in their wallet has done the
6
+ * same thing whichever chain they were paying on, and the message they see
7
+ * must not depend on which module happened to own the type.
8
+ */
9
+ /** Errors a payer can actually act on, separated from raw RPC noise. */
10
+ export class WalletError extends Error {
11
+ // Declared and assigned rather than a constructor parameter property:
12
+ // the build runs with erasableSyntaxOnly, which forbids the shorthand.
13
+ code;
14
+ /**
15
+ * Marks a message this app wrote, so walletErrorMessage shows it verbatim.
16
+ *
17
+ * Without it every deliberate message ("your wallet holds 0 USDC…") was
18
+ * replaced by the generic fallback, which told the payer nothing and hid
19
+ * the actual reason the payment stopped.
20
+ */
21
+ payerFacing = true;
22
+ constructor(message, code) {
23
+ super(message);
24
+ this.name = 'WalletError';
25
+ this.code = code;
26
+ }
27
+ }
28
+ /**
29
+ * True for an error this app authored, so its text is safe to show.
30
+ *
31
+ * Checked structurally rather than with instanceof so the wallet layer needs
32
+ * no import from the API client: anything that marks itself payerFacing
33
+ * qualifies.
34
+ */
35
+ function isPayerFacing(error) {
36
+ return (error instanceof Error &&
37
+ error.payerFacing === true);
38
+ }
39
+ /**
40
+ * Turns a provider rejection into something a person can read.
41
+ *
42
+ * Raw RPC errors leak internals and frighten payers; the codes that matter
43
+ * are standardised (EIP-1193 / EIP-1474) and Solana wallets reuse the same
44
+ * numbers, so they are mapped explicitly for both and anything unrecognised
45
+ * falls back to a plain sentence.
46
+ */
47
+ export function walletErrorMessage(error, fallback) {
48
+ const rpc = error;
49
+ switch (rpc?.code) {
50
+ case 4001:
51
+ return 'Request rejected in your wallet.';
52
+ case 4100:
53
+ return 'Your wallet has not authorized this account.';
54
+ case -32002:
55
+ return 'Your wallet already has a pending request. Open it to continue.';
56
+ case -32603:
57
+ return 'Your wallet could not complete the request.';
58
+ default:
59
+ // Our own messages pass through; anything else is raw RPC noise and
60
+ // is replaced, so internals never reach a payer.
61
+ return isPayerFacing(error) ? error.message : fallback;
62
+ }
63
+ }
64
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,wEAAwE;AACxE,MAAM,OAAO,WAAY,SAAQ,KAAK;IACrC,sEAAsE;IACtE,uEAAuE;IACvE,IAAI,CAAS;IAEb;;;;;;OAMG;IACM,WAAW,GAAG,IAAI,CAAA;IAE3B,YAAa,OAAe,EAAE,IAAa;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,aAAa,CAAA;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IACjB,CAAC;CACD;AAOD;;;;;;GAMG;AACH,SAAS,aAAa,CAAE,KAAc;IACrC,OAAO,CACN,KAAK,YAAY,KAAK;QACrB,KAAmC,CAAC,WAAW,KAAK,IAAI,CACzD,CAAA;AACF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAE,KAAc,EAAE,QAAgB;IACnE,MAAM,GAAG,GAAG,KAAyB,CAAA;IACrC,QAAQ,GAAG,EAAE,IAAI,EAAE,CAAC;QACnB,KAAK,IAAI;YACR,OAAO,kCAAkC,CAAA;QAC1C,KAAK,IAAI;YACR,OAAO,8CAA8C,CAAA;QACtD,KAAK,CAAC,KAAK;YACV,OAAO,iEAAiE,CAAA;QACzE,KAAK,CAAC,KAAK;YACV,OAAO,6CAA6C,CAAA;QACrD;YACC,oEAAoE;YACpE,iDAAiD;YACjD,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAA;IACxD,CAAC;AACF,CAAC"}
package/dist/evm.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Everything about EVM wallets: finding them, connecting to one, and getting
3
+ * it onto the right chain.
4
+ *
5
+ * The family's own half of the wallet layer, beside svm.ts, and laid out the
6
+ * same way: which wallets exist, how to detect them, how to connect, and what
7
+ * can be asked of one afterwards. Named for the family rather than for what
8
+ * it does, because what it does has no meaning without it: switchEvmChain is
9
+ * an EVM idea, and Solana has nothing to switch to.
10
+ *
11
+ * One file rather than three. The registry and the discovery were their own
12
+ * modules back when there was only one family and "the wallet layer" needed
13
+ * no qualifier; with two, a reader looking for how EVM works should find it
14
+ * in one place, exactly as they do for Solana.
15
+ */
16
+ import { type WalletEntry } from './catalog.js';
17
+ import type { ConnectedEvmWallet, DetectedEvmWallet, Eip1193Provider } from './types.js';
18
+ /**
19
+ * Finds the wallets available in this browser.
20
+ *
21
+ * EIP-6963 first: it is the standard, it survives several wallets being
22
+ * installed together, and the wallet supplies its own name and icon, so no
23
+ * brand assets ship in this bundle. Global sniffing is only a fallback for
24
+ * wallets that have not adopted it, and never overrides an announced provider.
25
+ *
26
+ * Returns a cleanup function; callers must call it to drop the listener.
27
+ */
28
+ export declare function discoverEvmWallets(catalog: WalletEntry[], onChange: (wallets: DetectedEvmWallet[]) => void): () => void;
29
+ /** Prompts the wallet for an account. */
30
+ export declare function connectEvmWallet(wallet: DetectedEvmWallet): Promise<ConnectedEvmWallet>;
31
+ /**
32
+ * Moves the wallet to the chain the payment link settles on.
33
+ *
34
+ * A payer on the wrong network would otherwise sign a transaction that can
35
+ * never settle, so this runs before anything is signed.
36
+ *
37
+ * If the wallet does not know the chain, it is offered rather than reported as
38
+ * a dead end: being told "that network is not added to your wallet" leaves the
39
+ * payer to go and add it by hand, which is exactly what
40
+ * `wallet_addEthereumChain` exists to avoid. The wallet still shows its own
41
+ * confirmation, so the payer approves both the addition and the switch; nothing
42
+ * is added silently.
43
+ *
44
+ * Only chains in the local registry can be offered: see chains.ts for why the
45
+ * RPC endpoints are pinned in the bundle.
46
+ */
47
+ export declare function switchEvmChain(provider: Eip1193Provider, chainId: number): Promise<void>;
48
+ /** Truncates an address for display: 0x1234…ab34. */
49
+ export declare function shortEvmAddress(address: string): string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../src/evm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAgC,KAAK,WAAW,EAAE,MAAM,cAAc,CAAA;AAG7E,OAAO,KAAK,EACX,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,MAAM,YAAY,CAAA;AA8BnB;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,WAAW,EAAE,EACtB,QAAQ,EAAE,CAAC,OAAO,EAAE,iBAAiB,EAAE,KAAK,IAAI,GAC9C,MAAM,IAAI,CAkGZ;AAmBD,yCAAyC;AACzC,wBAAsB,gBAAgB,CACrC,MAAM,EAAE,iBAAiB,GACvB,OAAO,CAAC,kBAAkB,CAAC,CAgB7B;AAeD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,cAAc,CACnC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAyCf;AAED,qDAAqD;AACrD,wBAAgB,eAAe,CAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKxD"}
package/dist/evm.js ADDED
@@ -0,0 +1,217 @@
1
+ /**
2
+ * Everything about EVM wallets: finding them, connecting to one, and getting
3
+ * it onto the right chain.
4
+ *
5
+ * The family's own half of the wallet layer, beside svm.ts, and laid out the
6
+ * same way: which wallets exist, how to detect them, how to connect, and what
7
+ * can be asked of one afterwards. Named for the family rather than for what
8
+ * it does, because what it does has no meaning without it: switchEvmChain is
9
+ * an EVM idea, and Solana has nothing to switch to.
10
+ *
11
+ * One file rather than three. The registry and the discovery were their own
12
+ * modules back when there was only one family and "the wallet layer" needed
13
+ * no qualifier; with two, a reader looking for how EVM works should find it
14
+ * in one place, exactly as they do for Solana.
15
+ */
16
+ import { detect, engineOf, walletsFor } from './catalog.js';
17
+ import { chainMetadata } from './chains.js';
18
+ import { WalletError } from './errors.js';
19
+ /**
20
+ * Finds the wallets available in this browser.
21
+ *
22
+ * EIP-6963 first: it is the standard, it survives several wallets being
23
+ * installed together, and the wallet supplies its own name and icon, so no
24
+ * brand assets ship in this bundle. Global sniffing is only a fallback for
25
+ * wallets that have not adopted it, and never overrides an announced provider.
26
+ *
27
+ * Returns a cleanup function; callers must call it to drop the listener.
28
+ */
29
+ export function discoverEvmWallets(catalog, onChange) {
30
+ const known = walletsFor(catalog, 'evm');
31
+ const announced = new Map();
32
+ function emit() {
33
+ const found = new Map(announced);
34
+ // The providers already accounted for, by object and not by id.
35
+ //
36
+ // A wallet whose rdns this registry does not know announces under
37
+ // its own rdns, which matches no entry here, and the sniff below
38
+ // would then find the same extension again and list it twice. It is
39
+ // the same provider instance both times, so comparing the object
40
+ // settles it without needing to know the rdns.
41
+ const seen = new Set([...announced.values()].map((wallet) => wallet.provider));
42
+ // Fall back to globals only for wallets that did not announce.
43
+ for (const definition of known) {
44
+ if (found.has(definition.id)) {
45
+ continue;
46
+ }
47
+ const provider = detect(window, engineOf(definition, 'evm'));
48
+ if (provider && !seen.has(provider)) {
49
+ found.set(definition.id, {
50
+ id: definition.id,
51
+ name: definition.name,
52
+ provider,
53
+ announced: false,
54
+ });
55
+ }
56
+ }
57
+ // Registry order, so the list is stable rather than dependent on which
58
+ // wallet happened to answer first.
59
+ const ordered = known
60
+ .map((definition) => found.get(definition.id))
61
+ .filter((wallet) => Boolean(wallet));
62
+ // Anything that announced itself but is not in the registry still works;
63
+ // it is listed after the known names.
64
+ for (const [id, wallet] of found) {
65
+ if (!known.some((definition) => definition.id === id)) {
66
+ ordered.push(wallet);
67
+ }
68
+ }
69
+ onChange(ordered);
70
+ }
71
+ function handleAnnounce(event) {
72
+ const detail = event.detail;
73
+ if (!detail?.info || !detail.provider) {
74
+ return;
75
+ }
76
+ // Matched to a catalogued wallet by the id it announces, so a known
77
+ // wallet keeps our name and ordering; anything else is listed under
78
+ // the rdns it gave. Any of a wallet's ids will do: a payment signed
79
+ // in MetaMask's phone browser is a payment signed in MetaMask, and
80
+ // matching its extension id alone recorded one against a wallet
81
+ // nothing downstream could name or draw.
82
+ const match = known.find((wallet) => engineOf(wallet, 'evm')?.rdns?.includes(detail.info.rdns));
83
+ announced.set(match?.id ?? detail.info.rdns, {
84
+ id: match?.id ?? detail.info.rdns,
85
+ name: match?.name ?? detail.info.name,
86
+ icon: detail.info.icon,
87
+ provider: detail.provider,
88
+ announced: true,
89
+ });
90
+ emit();
91
+ }
92
+ // Asked for repeatedly, which EIP-6963 is built for: an extension that
93
+ // injects after the first request never hears it, and in a frame it
94
+ // often does. The announcement listener stays up throughout, so a wallet
95
+ // that answers any of these is picked up.
96
+ function ask() {
97
+ window.dispatchEvent(new Event('eip6963:requestProvider'));
98
+ emit();
99
+ }
100
+ window.addEventListener('eip6963:announceProvider', handleAnnounce);
101
+ // A frame's load can come well after this module runs.
102
+ window.addEventListener('load', ask);
103
+ const retries = [100, 400, 1000, 2000].map((delay) => window.setTimeout(ask, delay));
104
+ ask();
105
+ return () => {
106
+ window.removeEventListener('eip6963:announceProvider', handleAnnounce);
107
+ window.removeEventListener('load', ask);
108
+ for (const retry of retries) {
109
+ window.clearTimeout(retry);
110
+ }
111
+ };
112
+ }
113
+ // ---------------------------------------------------------------------------
114
+ // Connecting, and what can be asked of a wallet once connected.
115
+ // ---------------------------------------------------------------------------
116
+ function firstAddress(accounts) {
117
+ if (!Array.isArray(accounts) || accounts.length === 0) {
118
+ return undefined;
119
+ }
120
+ const address = accounts[0];
121
+ return typeof address === 'string' ? address : undefined;
122
+ }
123
+ async function chainIdOf(provider) {
124
+ const raw = await provider.request({ method: 'eth_chainId' });
125
+ return typeof raw === 'string' ? Number.parseInt(raw, 16) : Number(raw);
126
+ }
127
+ /** Prompts the wallet for an account. */
128
+ export async function connectEvmWallet(wallet) {
129
+ const accounts = await wallet.provider.request({
130
+ method: 'eth_requestAccounts',
131
+ });
132
+ const address = firstAddress(accounts);
133
+ if (!address) {
134
+ throw new WalletError('No account was shared by the wallet.');
135
+ }
136
+ return {
137
+ walletId: wallet.id,
138
+ name: wallet.name,
139
+ icon: wallet.icon,
140
+ address,
141
+ chainId: await chainIdOf(wallet.provider),
142
+ provider: wallet.provider,
143
+ };
144
+ }
145
+ /**
146
+ * Some wallets report an unknown chain as 4902; others bury that code inside a
147
+ * -32603 wrapper, and a few only say so in the message. All three mean the same
148
+ * thing: the chain is not in the wallet yet.
149
+ */
150
+ function isUnknownChain(error) {
151
+ const rpc = error;
152
+ if (rpc?.code === 4902 || rpc?.data?.code === 4902) {
153
+ return true;
154
+ }
155
+ return /unrecognized chain|unknown chain|add.*chain/i.test(rpc?.message ?? '');
156
+ }
157
+ /**
158
+ * Moves the wallet to the chain the payment link settles on.
159
+ *
160
+ * A payer on the wrong network would otherwise sign a transaction that can
161
+ * never settle, so this runs before anything is signed.
162
+ *
163
+ * If the wallet does not know the chain, it is offered rather than reported as
164
+ * a dead end: being told "that network is not added to your wallet" leaves the
165
+ * payer to go and add it by hand, which is exactly what
166
+ * `wallet_addEthereumChain` exists to avoid. The wallet still shows its own
167
+ * confirmation, so the payer approves both the addition and the switch; nothing
168
+ * is added silently.
169
+ *
170
+ * Only chains in the local registry can be offered: see chains.ts for why the
171
+ * RPC endpoints are pinned in the bundle.
172
+ */
173
+ export async function switchEvmChain(provider, chainId) {
174
+ const hexChainId = `0x${chainId.toString(16)}`;
175
+ try {
176
+ await provider.request({
177
+ method: 'wallet_switchEthereumChain',
178
+ params: [{ chainId: hexChainId }],
179
+ });
180
+ return;
181
+ }
182
+ catch (error) {
183
+ if (!isUnknownChain(error)) {
184
+ throw error;
185
+ }
186
+ const metadata = chainMetadata(chainId);
187
+ if (!metadata) {
188
+ throw new WalletError('This network is not supported by your wallet yet. Add it manually to continue.');
189
+ }
190
+ await provider.request({
191
+ method: 'wallet_addEthereumChain',
192
+ params: [
193
+ {
194
+ chainId: hexChainId,
195
+ chainName: metadata.chainName,
196
+ nativeCurrency: metadata.nativeCurrency,
197
+ rpcUrls: metadata.rpcUrls,
198
+ blockExplorerUrls: metadata.blockExplorerUrls,
199
+ },
200
+ ],
201
+ });
202
+ // Most wallets switch as part of adding, but not all: asking again is
203
+ // cheap and a no-op when the wallet already moved.
204
+ await provider.request({
205
+ method: 'wallet_switchEthereumChain',
206
+ params: [{ chainId: hexChainId }],
207
+ });
208
+ }
209
+ }
210
+ /** Truncates an address for display: 0x1234…ab34. */
211
+ export function shortEvmAddress(address) {
212
+ if (address.length < 12) {
213
+ return address;
214
+ }
215
+ return `${address.slice(0, 6)}…${address.slice(-4)}`;
216
+ }
217
+ //# sourceMappingURL=evm.js.map
@@ -0,0 +1 @@
1
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AM,QAAQ,CAAC,OAAO,CAAC;YACtB,MAAM,EAAE,4BAA4B;YACpC,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;SACjC,CAAC,CAAA;IACH,CAAC;AACF,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,eAAe,CAAE,OAAe;IAC/C,IAAI,OAAO,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACzB,OAAO,OAAO,CAAA;IACf,CAAC;IACD,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AACrD,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Brand logos for wallets the payer does not have installed.
3
+ *
4
+ * Filenames rather than paths, joined to a base the host supplies. The files
5
+ * are served by the host from its own origin so that a checkout still makes
6
+ * no third-party image request, they stay out of the JS payload, and the
7
+ * browser caches and fetches them in parallel instead of blocking the page.
8
+ * The files themselves ship in this package under `assets/`; a host copies
9
+ * them into whatever it serves static files from.
10
+ *
11
+ * An installed wallet's own EIP-6963 icon still wins over these: it is the
12
+ * artwork of the provider actually present, which matters when a payer runs a
13
+ * fork or a wallet that has rebranded since these files were added.
14
+ *
15
+ * Filenames are mapped explicitly rather than derived from the wallet id: the
16
+ * assets do not follow one naming convention (crypto_com vs trust-wallet), and
17
+ * a derived path would break silently the next time one is added.
18
+ */
19
+ export declare const WALLET_LOGOS: Record<string, string>;
20
+ /** Where a host serves the files in this package's `assets/` directory. */
21
+ export declare const DEFAULT_LOGO_BASE = "/images/";
22
+ export declare function walletLogo(id: string, base?: string): string | undefined;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../src/icons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAqE/C,CAAA;AAED,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,aAAa,CAAA;AAE3C,wBAAgB,UAAU,CACzB,EAAE,EAAE,MAAM,EACV,IAAI,GAAE,MAA0B,GAC9B,MAAM,GAAG,SAAS,CAMpB"}
package/dist/icons.js ADDED
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Brand logos for wallets the payer does not have installed.
3
+ *
4
+ * Filenames rather than paths, joined to a base the host supplies. The files
5
+ * are served by the host from its own origin so that a checkout still makes
6
+ * no third-party image request, they stay out of the JS payload, and the
7
+ * browser caches and fetches them in parallel instead of blocking the page.
8
+ * The files themselves ship in this package under `assets/`; a host copies
9
+ * them into whatever it serves static files from.
10
+ *
11
+ * An installed wallet's own EIP-6963 icon still wins over these: it is the
12
+ * artwork of the provider actually present, which matters when a payer runs a
13
+ * fork or a wallet that has rebranded since these files were added.
14
+ *
15
+ * Filenames are mapped explicitly rather than derived from the wallet id: the
16
+ * assets do not follow one naming convention (crypto_com vs trust-wallet), and
17
+ * a derived path would break silently the next time one is added.
18
+ */
19
+ export const WALLET_LOGOS = {
20
+ metamask: 'metamask.webp',
21
+ phantom: 'phantom.webp',
22
+ brave: 'brave.webp',
23
+ binance: 'binance.webp',
24
+ trust: 'trust-wallet.webp',
25
+ okx: 'okx.webp',
26
+ cryptocom: 'crypto_com.webp',
27
+ coinbase: 'coinbase.webp',
28
+ solflare: 'solflare.webp',
29
+ backpack: 'backpack.webp',
30
+ rainbow: 'rainbow.webp',
31
+ rabby: 'rabby.webp',
32
+ ledger: 'ledger.webp',
33
+ bitpay: 'bitpay.webp',
34
+ bitget: 'bitget.webp',
35
+ bitcoincom: 'bitcoincom.webp',
36
+ blockchaincom: 'blockchaincom.webp',
37
+ bybit: 'bybit.webp',
38
+ safe: 'safe.webp',
39
+ exodus: 'exodus.webp',
40
+ kraken: 'kraken.webp',
41
+ berasig: 'berasig.webp',
42
+ bestwallet: 'bestwallet.webp',
43
+ bifrostwallet: 'bifrostwallet.webp',
44
+ bitski: 'bitski.webp',
45
+ bitverse: 'bitverse.webp',
46
+ clv: 'clv.webp',
47
+ coin98: 'coin98.webp',
48
+ compass: 'compass.webp',
49
+ core: 'core.webp',
50
+ ctrl: 'ctrl.webp',
51
+ dawn: 'dawn.webp',
52
+ desig: 'desig.webp',
53
+ enkrypt: 'enkrypt.webp',
54
+ foxwallet: 'foxwallet.webp',
55
+ frame: 'frame.webp',
56
+ frontier: 'frontier.webp',
57
+ gate: 'gate.webp',
58
+ gemini: 'gemini.webp',
59
+ imtoken: 'imtoken.webp',
60
+ iopay: 'iopay.webp',
61
+ kaia: 'kaia.webp',
62
+ kaikas: 'kaikas.webp',
63
+ kresuswallet: 'kresuswallet.webp',
64
+ magiceden: 'magiceden.webp',
65
+ meco: 'meco.webp',
66
+ mew: 'mew.webp',
67
+ nest: 'nest.webp',
68
+ nova: 'nova.webp',
69
+ okto: 'okto.webp',
70
+ oneinch: 'oneinch.webp',
71
+ onekey: 'onekey.webp',
72
+ ramper: 'ramper.webp',
73
+ ready: 'ready.webp',
74
+ ronin: 'ronin.webp',
75
+ safepal: 'safepal.webp',
76
+ subwallet: 'subwallet.webp',
77
+ taho: 'taho.webp',
78
+ talisman: 'talisman.webp',
79
+ tokenpocket: 'tokenpocket.webp',
80
+ tokenary: 'tokenary.webp',
81
+ uniswap: 'uniswap.webp',
82
+ universalprofiles: 'universalprofiles.webp',
83
+ valora: 'valora.webp',
84
+ wigwam: 'wigwam.webp',
85
+ xportal: 'xportal.webp',
86
+ zeal: 'zeal.webp',
87
+ zerion: 'zerion.webp',
88
+ };
89
+ /** Where a host serves the files in this package's `assets/` directory. */
90
+ export const DEFAULT_LOGO_BASE = '/images/';
91
+ export function walletLogo(id, base = DEFAULT_LOGO_BASE) {
92
+ const file = WALLET_LOGOS[id];
93
+ if (!file) {
94
+ return undefined;
95
+ }
96
+ return `${base.endsWith('/') ? base : `${base}/`}${file}`;
97
+ }
98
+ //# sourceMappingURL=icons.js.map
@@ -0,0 +1 @@
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,EAAE,gBAAgB;IAC3B,IAAI,EAAE,WAAW;IACjB,GAAG,EAAE,UAAU;IACf,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,aAAa;IACrB,MAAM,EAAE,aAAa;IACrB,KAAK,EAAE,YAAY;IACnB,KAAK,EAAE,YAAY;IACnB,OAAO,EAAE,cAAc;IACvB,SAAS,EAAE,gBAAgB;IAC3B,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,eAAe;IACzB,WAAW,EAAE,kBAAkB;IAC/B,QAAQ,EAAE,eAAe;IACzB,OAAO,EAAE,cAAc;IACvB,iBAAiB,EAAE,wBAAwB;IAC3C,MAAM,EAAE,aAAa;IACrB,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE,cAAc;IACvB,IAAI,EAAE,WAAW;IACjB,MAAM,EAAE,aAAa;CACrB,CAAA;AAED,2EAA2E;AAC3E,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAA;AAE3C,MAAM,UAAU,UAAU,CACzB,EAAU,EACV,OAAe,iBAAiB;IAEhC,MAAM,IAAI,GAAG,YAAY,CAAC,EAAE,CAAC,CAAA;IAC7B,IAAI,CAAC,IAAI,EAAE,CAAC;QACX,OAAO,SAAS,CAAA;IACjB,CAAC;IACD,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,GAAG,IAAI,EAAE,CAAA;AAC1D,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @reclack/walletkit
3
+ *
4
+ * Connecting a wallet, reading an address, reading a balance, and nothing
5
+ * else. No React, no Vue, no renderer of any kind: a store with `getState`
6
+ * and `subscribe`, which is the one shape every framework can consume and
7
+ * plain JavaScript can call directly.
8
+ *
9
+ * No wallet SDK either, and no dependencies. Every wallet here speaks
10
+ * EIP-1193 or the Wallet Standard, both of which are small enough to talk to
11
+ * by hand, and a page that handles other people's money should ship as little
12
+ * code it did not write as it can.
13
+ */
14
+ export { createWalletKit } from './kit.js';
15
+ export type { EvmState, SvmState, WalletKit, WalletKitOptions, WalletKitState, } from './kit.js';
16
+ export type { ConnectRequest, ConnectResult, Intent } from './intent.js';
17
+ export { applyTheme, DARK_TOKENS, LIGHT_TOKENS, readableInk, resolveScheme, safeColor, subscribeScheme, themeCss, themeVariables, } from './theme.js';
18
+ export type { ColorScheme, ThemeMode, ThemeTokens, WalletKitTheme, } from './theme.js';
19
+ export { formatUnits, readEvmBalance, readSvmBalance } from './balance.js';
20
+ export type { Asset, Balance, BalanceSource } from './balance.js';
21
+ export { engineOf, walletsFor } from './catalog.js';
22
+ export type { WalletEngine, WalletEntry } from './catalog.js';
23
+ export { fetchWalletCatalog, walletCatalogUrl } from './catalog-fetch.js';
24
+ export { connectEvmWallet, discoverEvmWallets, shortEvmAddress, switchEvmChain, } from './evm.js';
25
+ export { connectSvmWallet, disconnectSvmWallet, discoverSvmWallets, shortSvmAddress, signAndSendSvm, } from './svm.js';
26
+ export { defaultMetadata, openWalletConnectSession, walletConnectReady, } from './walletconnect.js';
27
+ export type { RemoteSession, SessionMetadata, WalletConnectOptions, } from './walletconnect.js';
28
+ export { walletDeepLink, walletPairingLink, walletScans } from './deep-links.js';
29
+ export { isHandheld, mobileOS, subscribeHandheld } from './device.js';
30
+ export type { MobileOS } from './device.js';
31
+ export { DEFAULT_API_URL, DEFAULT_SVM_RPC_URL, DEFAULT_WALLETCONNECT_PROJECT_ID, defaultRpcUrl, } from './config.js';
32
+ export { CHAINS, chainMetadata, explorerHost, explorerTxUrl } from './chains.js';
33
+ export type { ChainMetadata } from './chains.js';
34
+ export { DEFAULT_LOGO_BASE, WALLET_LOGOS, walletLogo } from './icons.js';
35
+ export { shortAddress } from './address.js';
36
+ export { WalletError, walletErrorMessage } from './errors.js';
37
+ export type { ProviderRpcError } from './errors.js';
38
+ export { addressWord, bytes32, calldata, word } from './abi.js';
39
+ export type { ChainFamily, ConnectedEvmWallet, ConnectedSvmWallet, DetectedEvmWallet, DetectedSvmWallet, Eip1193Provider, SvmProvider, WalletChoice, WalletOption, } from './types.js';
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,YAAY,EACX,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,cAAc,GACd,MAAM,UAAU,CAAA;AAGjB,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGxE,OAAO,EACN,UAAU,EACV,WAAW,EACX,YAAY,EACZ,WAAW,EACX,aAAa,EACb,SAAS,EACT,eAAe,EACf,QAAQ,EACR,cAAc,GACd,MAAM,YAAY,CAAA;AACnB,YAAY,EACX,WAAW,EACX,SAAS,EACT,WAAW,EACX,cAAc,GACd,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC1E,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAGjE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACnD,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAIzE,OAAO,EACN,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,cAAc,GACd,MAAM,UAAU,CAAA;AACjB,OAAO,EACN,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,cAAc,GACd,MAAM,UAAU,CAAA;AAGjB,OAAO,EACN,eAAe,EACf,wBAAwB,EACxB,kBAAkB,GAClB,MAAM,oBAAoB,CAAA;AAC3B,YAAY,EACX,aAAa,EACb,eAAe,EACf,oBAAoB,GACpB,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAChF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACrE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAG3C,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,gCAAgC,EAChC,aAAa,GACb,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChF,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAGhD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAC7D,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAGnD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAG/D,YAAY,EACX,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,YAAY,EACZ,YAAY,GACZ,MAAM,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @reclack/walletkit
3
+ *
4
+ * Connecting a wallet, reading an address, reading a balance, and nothing
5
+ * else. No React, no Vue, no renderer of any kind: a store with `getState`
6
+ * and `subscribe`, which is the one shape every framework can consume and
7
+ * plain JavaScript can call directly.
8
+ *
9
+ * No wallet SDK either, and no dependencies. Every wallet here speaks
10
+ * EIP-1193 or the Wallet Standard, both of which are small enough to talk to
11
+ * by hand, and a page that handles other people's money should ship as little
12
+ * code it did not write as it can.
13
+ */
14
+ // The kit. Start here.
15
+ export { createWalletKit } from './kit.js';
16
+ // Colours, corner radius, type, and light or dark.
17
+ export { applyTheme, DARK_TOKENS, LIGHT_TOKENS, readableInk, resolveScheme, safeColor, subscribeScheme, themeCss, themeVariables, } from './theme.js';
18
+ // Balances.
19
+ export { formatUnits, readEvmBalance, readSvmBalance } from './balance.js';
20
+ // The catalogue: which wallets exist, and how to recognise them.
21
+ export { engineOf, walletsFor } from './catalog.js';
22
+ export { fetchWalletCatalog, walletCatalogUrl } from './catalog-fetch.js';
23
+ // The two families, for a host that drives them itself rather than through
24
+ // the kit.
25
+ export { connectEvmWallet, discoverEvmWallets, shortEvmAddress, switchEvmChain, } from './evm.js';
26
+ export { connectSvmWallet, disconnectSvmWallet, discoverSvmWallets, shortSvmAddress, signAndSendSvm, } from './svm.js';
27
+ // Wallets that inject nothing, reached over a relay.
28
+ export { defaultMetadata, openWalletConnectSession, walletConnectReady, } from './walletconnect.js';
29
+ // Getting from a desktop to a phone, and from a phone into a wallet.
30
+ export { walletDeepLink, walletPairingLink, walletScans } from './deep-links.js';
31
+ export { isHandheld, mobileOS, subscribeHandheld } from './device.js';
32
+ // The defaults every option above overrides.
33
+ export { DEFAULT_API_URL, DEFAULT_SVM_RPC_URL, DEFAULT_WALLETCONNECT_PROJECT_ID, defaultRpcUrl, } from './config.js';
34
+ // Chains this kit can propose to a wallet, and where to look a payment up.
35
+ export { CHAINS, chainMetadata, explorerHost, explorerTxUrl } from './chains.js';
36
+ // Names and marks.
37
+ export { DEFAULT_LOGO_BASE, WALLET_LOGOS, walletLogo } from './icons.js';
38
+ export { shortAddress } from './address.js';
39
+ // Failures, in words somebody can act on.
40
+ export { WalletError, walletErrorMessage } from './errors.js';
41
+ // Encoding, for a caller building its own calls.
42
+ export { addressWord, bytes32, calldata, word } from './abi.js';
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,uBAAuB;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAY1C,mDAAmD;AACnD,OAAO,EACN,UAAU,EACV,WAAW,EACX,YAAY,EACZ,WAAW,EACX,aAAa,EACb,SAAS,EACT,eAAe,EACf,QAAQ,EACR,cAAc,GACd,MAAM,YAAY,CAAA;AAQnB,YAAY;AACZ,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAG1E,iEAAiE;AACjE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEnD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAEzE,2EAA2E;AAC3E,WAAW;AACX,OAAO,EACN,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,cAAc,GACd,MAAM,UAAU,CAAA;AACjB,OAAO,EACN,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,cAAc,GACd,MAAM,UAAU,CAAA;AAEjB,qDAAqD;AACrD,OAAO,EACN,eAAe,EACf,wBAAwB,EACxB,kBAAkB,GAClB,MAAM,oBAAoB,CAAA;AAO3B,qEAAqE;AACrE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAChF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAGrE,6CAA6C;AAC7C,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,gCAAgC,EAChC,aAAa,GACb,MAAM,aAAa,CAAA;AAEpB,2EAA2E;AAC3E,OAAO,EAAE,MAAM,EAA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