@usebutr/wallet-standard-shared 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +22 -100
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -80
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import { Account, ChainBase, ConnectorEvent, WalletAdapter, WalletCapabilities, buildAccount } from "@usebutr/core";
|
|
2
2
|
//#region src/types.d.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* `@usebutr/bitcoin`) shares. Declared inline so butr stays
|
|
7
|
-
* self-contained at the type level; the actual `@wallet-standard/app`
|
|
8
|
-
* package is dynamic-imported at runtime, and apps that don't enable
|
|
9
|
-
* Wallet Standard discovery never resolve it.
|
|
10
|
-
*
|
|
4
|
+
* Declared inline so butr stays self-contained at the type level;
|
|
5
|
+
* `@wallet-standard/app` is only dynamic-imported when discovery runs.
|
|
11
6
|
* Spec: https://github.com/wallet-standard/wallet-standard
|
|
12
|
-
*
|
|
13
|
-
* Platform-specific feature shapes (e.g. `solana:signMessage`,
|
|
14
|
-
* `sui:signPersonalMessage`, `bitcoin:signPsbt`) live in their own
|
|
15
|
-
* platform packages.
|
|
16
7
|
*/
|
|
17
8
|
type WalletStandardWalletAccount = {
|
|
18
9
|
address: string;
|
|
@@ -59,39 +50,21 @@ type StandardEventsFeature = {
|
|
|
59
50
|
//#endregion
|
|
60
51
|
//#region src/primitives.d.ts
|
|
61
52
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* Phantom Sui, Phantom BTC) coexist in the pool without colliding on
|
|
65
|
-
* the shared `getWallets()` bus.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* slugify("svm", "Phantom") // "wallet-standard:svm-phantom"
|
|
69
|
-
* slugify("sui", "Sui Wallet") // "wallet-standard:sui-sui-wallet"
|
|
70
|
-
* slugify("btc", "Phantom") // "wallet-standard:btc-phantom"
|
|
53
|
+
* The platform prefix scopes the id so one multi-chain wallet (Phantom
|
|
54
|
+
* SVM, Sui, BTC) yields distinct adapters on the shared `getWallets()` bus.
|
|
71
55
|
*/
|
|
72
56
|
declare const slugify: (platformPrefix: string, name: string) => string;
|
|
73
57
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* concrete feature shape it expects; this accessor is the single
|
|
78
|
-
* boundary where that dynamism is acknowledged. The `T` parameter is
|
|
79
|
-
* intentionally caller-supplied (not inferable) and the assertion is
|
|
80
|
-
* unavoidable for an untyped registry.
|
|
58
|
+
* The spec types `features` as a reverse-DNS-keyed `Record<string,
|
|
59
|
+
* unknown>`, so the caller declares the shape it expects. This accessor is
|
|
60
|
+
* the single boundary where that dynamism is acknowledged.
|
|
81
61
|
*/
|
|
82
62
|
declare const getFeature: <T>(wallet: WalletStandardWallet, name: string) => T | undefined;
|
|
83
|
-
/**
|
|
84
|
-
* Pick the first address out of a wallet's accounts array, returning
|
|
85
|
-
* `null` when the wallet currently exposes none.
|
|
86
|
-
*/
|
|
87
63
|
declare const pickFirstAddress: (accounts: ReadonlyArray<WalletStandardWalletAccount>) => string | null;
|
|
88
64
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* Used by per-call routing in `sendTx` / `signMessage`: callers pass
|
|
93
|
-
* an `account` from `ConnectedWallet.accounts` to sign with a non-
|
|
94
|
-
* active address; the wallet's `accounts[]` is the source of truth.
|
|
65
|
+
* Per-call routing for `sendTx` / `signMessage`: callers pass an `account`
|
|
66
|
+
* from `ConnectedWallet.accounts` to sign with a non-active address, but
|
|
67
|
+
* the wallet's own `accounts[]` stays the source of truth.
|
|
95
68
|
*/
|
|
96
69
|
declare const pickAccountByAddress: (accounts: ReadonlyArray<WalletStandardWalletAccount>, address: string) => WalletStandardWalletAccount | undefined;
|
|
97
70
|
//#endregion
|
|
@@ -150,17 +123,9 @@ type WalletStandardCore = {
|
|
|
150
123
|
toChain: () => ChainBase;
|
|
151
124
|
};
|
|
152
125
|
/**
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* the `standard:events` bridge. Returns `null` for wallets butr can't
|
|
157
|
-
* drive (no chain in this namespace, or no `standard:connect`), which is
|
|
158
|
-
* the same `null` each platform adapter returns to its caller.
|
|
159
|
-
*
|
|
160
|
-
* Platform packages keep what genuinely differs: which features they read
|
|
161
|
-
* off the wallet, how they encode transactions and messages, and their
|
|
162
|
-
* balance units. `getSigner` hands back the raw Wallet Standard wallet so
|
|
163
|
-
* consumers can wrap it in their own signing library.
|
|
126
|
+
* Shared session plumbing for every Wallet Standard platform adapter.
|
|
127
|
+
* `getSigner` hands back the raw Wallet Standard wallet so consumers can
|
|
128
|
+
* wrap it in their own signing library.
|
|
164
129
|
*/
|
|
165
130
|
declare const createWalletStandardCore: ({ chainPrefix, id, label, namespace, platform, preferredChainIds, registerDisconnector, trackChainChanges, wallet }: WalletStandardCoreInput) => WalletStandardCore | null;
|
|
166
131
|
//#endregion
|
|
@@ -183,66 +148,23 @@ type WalletCapabilityProfile = {
|
|
|
183
148
|
signTransaction: boolean;
|
|
184
149
|
};
|
|
185
150
|
/**
|
|
186
|
-
* Wallet Standard
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* - `getBalance` / `getTransactionReceipt`: Wallet Standard exposes no
|
|
190
|
-
* balance/receipt RPC, and butr ships no RPC client of its own.
|
|
191
|
-
* - `requestAccounts`: no programmatic equivalent of EIP-2255; re-running
|
|
192
|
-
* `standard:connect` doesn't produce new accounts on any major Wallet
|
|
193
|
-
* Standard wallet in practice (Phantom, MetaMask Snap, Solflare,
|
|
194
|
-
* Backpack, Xverse, Talisman).
|
|
195
|
-
* - `switchAccount`: no protocol-level silent account switch; the user
|
|
196
|
-
* picks the account inside the wallet.
|
|
197
|
-
* - `switchChain`: true when the wallet advertises more than one chain in
|
|
198
|
-
* this namespace. The switch is local re-routing (the per-call `chain`
|
|
199
|
-
* input), so with a single chain there's nothing to switch to.
|
|
200
|
-
*
|
|
201
|
-
* Each platform package owns only the feature-name → flag mapping, since
|
|
202
|
-
* the feature names differ per namespace.
|
|
151
|
+
* Wallet Standard has no balance/receipt RPC, no EIP-2255 equivalent, and
|
|
152
|
+
* no silent account switch, so those flags are false everywhere.
|
|
153
|
+
* `switchChain` re-routes locally, so it needs a second advertised chain.
|
|
203
154
|
*/
|
|
204
155
|
declare const buildWalletCapabilities: (profile: WalletCapabilityProfile) => WalletCapabilities;
|
|
205
156
|
//#endregion
|
|
206
157
|
//#region src/discovery.d.ts
|
|
207
158
|
/**
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
* Returns `null` when the wallet doesn't advertise this platform; that
|
|
212
|
-
* lets a multi-chain wallet (e.g. Phantom: SVM + EVM + Sui + Bitcoin)
|
|
213
|
-
* produce one adapter per platform without each builder needing to know
|
|
214
|
-
* about the others.
|
|
215
|
-
*
|
|
216
|
-
* The second argument is a hook the builder calls during construction
|
|
217
|
-
* to wire a synthetic `disconnected` event into its subscriber set.
|
|
218
|
-
* The discovery loop fires the registered emitter when Wallet Standard
|
|
219
|
-
* announces `unregister` for that wallet.
|
|
159
|
+
* Returns `null` when the wallet doesn't advertise this platform, so a
|
|
160
|
+
* multi-chain wallet yields one adapter per platform. `registerDisconnector`
|
|
161
|
+
* wires the synthetic `disconnected` fired on Wallet Standard `unregister`.
|
|
220
162
|
*/
|
|
221
163
|
type WalletStandardAdapterBuilder = (wallet: WalletStandardWallet, registerDisconnector: (emit: () => void) => void) => WalletAdapter | null;
|
|
222
164
|
/**
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
* **Shared machinery** every platform package needs:
|
|
227
|
-
* - Dynamic import of `@wallet-standard/app` (optional peer dep;
|
|
228
|
-
* failure to resolve quietly disables discovery so consumers who
|
|
229
|
-
* don't install it pay nothing).
|
|
230
|
-
* - Cancellation: the returned unsubscribe is safe to call before the
|
|
231
|
-
* dynamic import has resolved.
|
|
232
|
-
* - Dedupe by adapter id, so re-announcements don't double-emit.
|
|
233
|
-
* - `unregister` integration: when an extension is removed mid-session,
|
|
234
|
-
* fire the disconnector the builder registered so connected pool
|
|
235
|
-
* entries on the consumer side tear down cleanly.
|
|
236
|
-
*
|
|
237
|
-
* **What's platform-specific** lives entirely in `build`:
|
|
238
|
-
* - Which `wallet.chains` to accept.
|
|
239
|
-
* - Which features to gate on.
|
|
240
|
-
* - The `id` slug prefix (use `slugify(prefix, wallet.name)`).
|
|
241
|
-
* - The capability resolver, the feature decoding, the chain coercion.
|
|
242
|
-
*
|
|
243
|
-
* Disconnectors are keyed by the wallet object itself (identity equality),
|
|
244
|
-
* not by adapter id; Wallet Standard's `register` / `unregister` emit
|
|
245
|
-
* the same wallet object, so identity is the cheapest stable key.
|
|
165
|
+
* `@wallet-standard/app` is an optional peer dep: a failed import quietly
|
|
166
|
+
* disables discovery. Disconnectors are keyed by wallet identity rather
|
|
167
|
+
* than adapter id because `register` / `unregister` emit the same object.
|
|
246
168
|
*/
|
|
247
169
|
declare const discoverWalletStandard: (onAdapter: (adapter: WalletAdapter) => void, build: WalletStandardAdapterBuilder) => (() => void);
|
|
248
170
|
//#endregion
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/primitives.ts","../src/adapter-core.ts","../src/capabilities.ts","../src/discovery.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/primitives.ts","../src/adapter-core.ts","../src/capabilities.ts","../src/discovery.ts"],"mappings":";;;;;;;KAMK;EACH;EACA,QAAQ;EACR,UAAU;;EAEV,YAAY;;KAGT;EACH,UAAU,cAAc;EACxB,QAAQ;;;EAGR,UAAU,SAAS;EACnB;EACA;EACA;;KAGG;EACH,WAAW,cAAc;EACzB,KACE,kCACA,cAAc,SAAS,cAAc;;KAIpC;EACH,kBAAkB;;KAGf;EACH,UAAU;IAAU;QAAuB;IACzC,UAAU,cAAc;;;KAIvB;EACH,kBAAkB;;KAGf,0BAA0B;EAC7B,WAAW,cAAc;EACzB,SAAS;EACT,WAAW;;KAGR;EACH,KAAK,iBAAiB,UAAU;;;;;;;;cChD5B,UAAW,wBAAwB;;;;;;cAcnC,aAAc,GAAG,QAAQ,sBAAsB,iBAAe;cAS9D,mBAAoB,UAAU,cAAc;;;;;;cAU5C,uBACJ,UAAU,cAAc,8BACxB,oBACC;;;KC9BE;;EAEH;;EAEA;;EAEA;;EAEA;;EAEA;;;;EAIA,mBAAmB;;;;EAInB,wBAAwB;;;;EAIxB;EACA,QAAQ;;KAGL;;EAEH;EACA,UAAU;IAAS;QAAuB;;EAE1C;EACA,kBAAkB;EAClB,kBAAkB,QAAQ;EAC1B,mBAAmB,QAAQ,MAAM;EACjC,iBAAiB;;EAEjB;EACA;EACA;EACA;;;EAGA,iBAAiB;IAAY;QAA4B;EACzD,YAAY,WAAW,OAAO;EAC9B,cAAc,OAAO,cAAc;;;EAGnC,eAAe;;;;;;;cAQX,6BAA4B,aAAA,IAAA,OAAA,WAAA,UAAA,mBAAA,sBAAA,mBAAA,UAU/B,4BAA0B;;;KC5ExB;;EAEH;;EAEA;;;;EAIA;;;EAGA;EACA;;;EAGA;;;;;;;cAQI,0BAA2B,SAAS,4BAA0B;;;;;;;;KCb/D,gCACH,QAAQ,sBACR,uBAAuB,8BACpB;;;;;;cAOC,yBACJ,YAAY,SAAS,wBACrB,OAAO"}
|
package/dist/index.js
CHANGED
|
@@ -2,65 +2,39 @@ import { buildAccount, buildAccount as buildAccount$1, logWarn, sanitizeIcon } f
|
|
|
2
2
|
|
|
3
3
|
//#region src/primitives.ts
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Phantom Sui, Phantom BTC) coexist in the pool without colliding on
|
|
8
|
-
* the shared `getWallets()` bus.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* slugify("svm", "Phantom") // "wallet-standard:svm-phantom"
|
|
12
|
-
* slugify("sui", "Sui Wallet") // "wallet-standard:sui-sui-wallet"
|
|
13
|
-
* slugify("btc", "Phantom") // "wallet-standard:btc-phantom"
|
|
5
|
+
* The platform prefix scopes the id so one multi-chain wallet (Phantom
|
|
6
|
+
* SVM, Sui, BTC) yields distinct adapters on the shared `getWallets()` bus.
|
|
14
7
|
*/
|
|
15
8
|
const slugify = (platformPrefix, name) => {
|
|
16
|
-
return `wallet-standard:${platformPrefix}-${name.trim().toLowerCase().replaceAll(
|
|
9
|
+
return `wallet-standard:${platformPrefix}-${name.trim().toLowerCase().replaceAll(new RegExp("[^a-z0-9]+", "gv"), "-")}`;
|
|
17
10
|
};
|
|
18
11
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* concrete feature shape it expects; this accessor is the single
|
|
23
|
-
* boundary where that dynamism is acknowledged. The `T` parameter is
|
|
24
|
-
* intentionally caller-supplied (not inferable) and the assertion is
|
|
25
|
-
* unavoidable for an untyped registry.
|
|
12
|
+
* The spec types `features` as a reverse-DNS-keyed `Record<string,
|
|
13
|
+
* unknown>`, so the caller declares the shape it expects. This accessor is
|
|
14
|
+
* the single boundary where that dynamism is acknowledged.
|
|
26
15
|
*/
|
|
27
16
|
const getFeature = (wallet, name) => {
|
|
28
17
|
const feature = wallet.features[name];
|
|
29
18
|
if (typeof feature !== "object" || feature === null) return;
|
|
30
19
|
return feature;
|
|
31
20
|
};
|
|
32
|
-
/**
|
|
33
|
-
* Pick the first address out of a wallet's accounts array, returning
|
|
34
|
-
* `null` when the wallet currently exposes none.
|
|
35
|
-
*/
|
|
36
21
|
const pickFirstAddress = (accounts) => {
|
|
37
22
|
const first = accounts[0];
|
|
38
23
|
return first === void 0 ? null : first.address;
|
|
39
24
|
};
|
|
40
25
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* Used by per-call routing in `sendTx` / `signMessage`: callers pass
|
|
45
|
-
* an `account` from `ConnectedWallet.accounts` to sign with a non-
|
|
46
|
-
* active address; the wallet's `accounts[]` is the source of truth.
|
|
26
|
+
* Per-call routing for `sendTx` / `signMessage`: callers pass an `account`
|
|
27
|
+
* from `ConnectedWallet.accounts` to sign with a non-active address, but
|
|
28
|
+
* the wallet's own `accounts[]` stays the source of truth.
|
|
47
29
|
*/
|
|
48
30
|
const pickAccountByAddress = (accounts, address) => accounts.find((a) => a.address === address) ?? accounts[0];
|
|
49
31
|
|
|
50
32
|
//#endregion
|
|
51
33
|
//#region src/adapter-core.ts
|
|
52
34
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* the `standard:events` bridge. Returns `null` for wallets butr can't
|
|
57
|
-
* drive (no chain in this namespace, or no `standard:connect`), which is
|
|
58
|
-
* the same `null` each platform adapter returns to its caller.
|
|
59
|
-
*
|
|
60
|
-
* Platform packages keep what genuinely differs: which features they read
|
|
61
|
-
* off the wallet, how they encode transactions and messages, and their
|
|
62
|
-
* balance units. `getSigner` hands back the raw Wallet Standard wallet so
|
|
63
|
-
* consumers can wrap it in their own signing library.
|
|
35
|
+
* Shared session plumbing for every Wallet Standard platform adapter.
|
|
36
|
+
* `getSigner` hands back the raw Wallet Standard wallet so consumers can
|
|
37
|
+
* wrap it in their own signing library.
|
|
64
38
|
*/
|
|
65
39
|
const createWalletStandardCore = ({ chainPrefix, id, label, namespace, platform, preferredChainIds, registerDisconnector, trackChainChanges, wallet }) => {
|
|
66
40
|
const pickChain = (chains) => chains.find((c) => preferredChainIds.includes(c)) ?? chains.find((c) => c.startsWith(chainPrefix)) ?? null;
|
|
@@ -160,12 +134,12 @@ const createWalletStandardCore = ({ chainPrefix, id, label, namespace, platform,
|
|
|
160
134
|
unsubWallet?.();
|
|
161
135
|
};
|
|
162
136
|
},
|
|
163
|
-
switchChain: (chain) => {
|
|
137
|
+
switchChain: async (chain) => {
|
|
164
138
|
if (chain.namespace !== namespace) throw new Error(`${label} adapter received non-${platform} chain "${chain.id}". Pass a chain with namespace "${namespace}".`);
|
|
165
139
|
if (!wallet.chains.includes(chain.id)) throw new Error(`Wallet ${wallet.name} does not advertise chain "${chain.id}". Available: ${wallet.chains.join(", ")}`);
|
|
166
140
|
currentChainId = chain.id;
|
|
167
141
|
notifyAccountChanged();
|
|
168
|
-
|
|
142
|
+
await Promise.resolve();
|
|
169
143
|
},
|
|
170
144
|
toChain
|
|
171
145
|
};
|
|
@@ -174,23 +148,9 @@ const createWalletStandardCore = ({ chainPrefix, id, label, namespace, platform,
|
|
|
174
148
|
//#endregion
|
|
175
149
|
//#region src/capabilities.ts
|
|
176
150
|
/**
|
|
177
|
-
* Wallet Standard
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
* - `getBalance` / `getTransactionReceipt`: Wallet Standard exposes no
|
|
181
|
-
* balance/receipt RPC, and butr ships no RPC client of its own.
|
|
182
|
-
* - `requestAccounts`: no programmatic equivalent of EIP-2255; re-running
|
|
183
|
-
* `standard:connect` doesn't produce new accounts on any major Wallet
|
|
184
|
-
* Standard wallet in practice (Phantom, MetaMask Snap, Solflare,
|
|
185
|
-
* Backpack, Xverse, Talisman).
|
|
186
|
-
* - `switchAccount`: no protocol-level silent account switch; the user
|
|
187
|
-
* picks the account inside the wallet.
|
|
188
|
-
* - `switchChain`: true when the wallet advertises more than one chain in
|
|
189
|
-
* this namespace. The switch is local re-routing (the per-call `chain`
|
|
190
|
-
* input), so with a single chain there's nothing to switch to.
|
|
191
|
-
*
|
|
192
|
-
* Each platform package owns only the feature-name → flag mapping, since
|
|
193
|
-
* the feature names differ per namespace.
|
|
151
|
+
* Wallet Standard has no balance/receipt RPC, no EIP-2255 equivalent, and
|
|
152
|
+
* no silent account switch, so those flags are false everywhere.
|
|
153
|
+
* `switchChain` re-routes locally, so it needs a second advertised chain.
|
|
194
154
|
*/
|
|
195
155
|
const buildWalletCapabilities = (profile) => ({
|
|
196
156
|
getBalance: false,
|
|
@@ -209,29 +169,9 @@ const buildWalletCapabilities = (profile) => ({
|
|
|
209
169
|
//#region src/discovery.ts
|
|
210
170
|
let warnedMissingApp = false;
|
|
211
171
|
/**
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
* **Shared machinery** every platform package needs:
|
|
216
|
-
* - Dynamic import of `@wallet-standard/app` (optional peer dep;
|
|
217
|
-
* failure to resolve quietly disables discovery so consumers who
|
|
218
|
-
* don't install it pay nothing).
|
|
219
|
-
* - Cancellation: the returned unsubscribe is safe to call before the
|
|
220
|
-
* dynamic import has resolved.
|
|
221
|
-
* - Dedupe by adapter id, so re-announcements don't double-emit.
|
|
222
|
-
* - `unregister` integration: when an extension is removed mid-session,
|
|
223
|
-
* fire the disconnector the builder registered so connected pool
|
|
224
|
-
* entries on the consumer side tear down cleanly.
|
|
225
|
-
*
|
|
226
|
-
* **What's platform-specific** lives entirely in `build`:
|
|
227
|
-
* - Which `wallet.chains` to accept.
|
|
228
|
-
* - Which features to gate on.
|
|
229
|
-
* - The `id` slug prefix (use `slugify(prefix, wallet.name)`).
|
|
230
|
-
* - The capability resolver, the feature decoding, the chain coercion.
|
|
231
|
-
*
|
|
232
|
-
* Disconnectors are keyed by the wallet object itself (identity equality),
|
|
233
|
-
* not by adapter id; Wallet Standard's `register` / `unregister` emit
|
|
234
|
-
* the same wallet object, so identity is the cheapest stable key.
|
|
172
|
+
* `@wallet-standard/app` is an optional peer dep: a failed import quietly
|
|
173
|
+
* disables discovery. Disconnectors are keyed by wallet identity rather
|
|
174
|
+
* than adapter id because `register` / `unregister` emit the same object.
|
|
235
175
|
*/
|
|
236
176
|
const discoverWalletStandard = (onAdapter, build) => {
|
|
237
177
|
let cancelled = false;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["buildAccount"],"sources":["../src/primitives.ts","../src/adapter-core.ts","../src/capabilities.ts","../src/discovery.ts"],"sourcesContent":["import type { WalletStandardWallet, WalletStandardWalletAccount } from \"./types\";\n\n/**\n * Convert a wallet name into a stable kebab-case adapter id, scoped by\n * a platform prefix so adapters from different platforms (Phantom SVM,\n * Phantom Sui, Phantom BTC) coexist in the pool without colliding on\n * the shared `getWallets()` bus.\n *\n * @example\n * slugify(\"svm\", \"Phantom\") // \"wallet-standard:svm-phantom\"\n * slugify(\"sui\", \"Sui Wallet\") // \"wallet-standard:sui-sui-wallet\"\n * slugify(\"btc\", \"Phantom\") // \"wallet-standard:btc-phantom\"\n */\nconst slugify = (platformPrefix: string, name: string): string => {\n const slug = name\n .trim()\n .toLowerCase()\n .replaceAll(/[^a-z0-9]+/gv, \"-\");\n return `wallet-standard:${platformPrefix}-${slug}`;\n};\n\n/**\n * Read a Wallet Standard feature off a wallet, returning `undefined`\n * when absent. `features` is a reverse-DNS-keyed registry typed\n * `Record<string, unknown>` by the spec, so the caller declares the\n * concrete feature shape it expects; this accessor is the single\n * boundary where that dynamism is acknowledged. The `T` parameter is\n * intentionally caller-supplied (not inferable) and the assertion is\n * unavoidable for an untyped registry.\n */\n// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- caller-supplied feature shape; not inferable from args\nconst getFeature = <T>(wallet: WalletStandardWallet, name: string): T | undefined => {\n const feature: unknown = wallet.features[name];\n if (typeof feature !== \"object\" || feature === null) {\n return undefined;\n }\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- untyped Wallet Standard feature registry; caller declares the shape\n return feature as T;\n};\n\n/**\n * Pick the first address out of a wallet's accounts array, returning\n * `null` when the wallet currently exposes none.\n */\nconst pickFirstAddress = (accounts: ReadonlyArray<WalletStandardWalletAccount>): string | null => {\n const first = accounts[0];\n return first === undefined ? null : first.address;\n};\n\n/**\n * Look up a wallet account by address, falling back to the first\n * exposed account when the requested address isn't present.\n *\n * Used by per-call routing in `sendTx` / `signMessage`: callers pass\n * an `account` from `ConnectedWallet.accounts` to sign with a non-\n * active address; the wallet's `accounts[]` is the source of truth.\n */\nconst pickAccountByAddress = (\n accounts: ReadonlyArray<WalletStandardWalletAccount>,\n address: string,\n): WalletStandardWalletAccount | undefined =>\n accounts.find((a) => a.address === address) ?? accounts[0];\n\n// Re-exported so this package's public surface keeps offering the shared\n// account builder now that the implementation lives in @usebutr/core\n// (next to `Account` and the reducer that relies on its id format).\nexport { buildAccount } from \"@usebutr/core\";\nexport { getFeature, pickAccountByAddress, pickFirstAddress, slugify };\n","import type { Account, ChainBase, ConnectorEvent } from \"@usebutr/core\";\nimport { buildAccount, logWarn, sanitizeIcon } from \"@usebutr/core\";\n\nimport { getFeature, pickAccountByAddress, pickFirstAddress } from \"./primitives\";\nimport type {\n StandardConnectFeature,\n StandardDisconnectFeature,\n StandardEventsFeature,\n WalletStandardWallet,\n WalletStandardWalletAccount,\n} from \"./types\";\n\ntype WalletStandardCoreInput = {\n /** CAIP-2 prefix including its colon (`solana:`, `sui:`, `bip122:`). */\n chainPrefix: string;\n /** Stable adapter id. Each platform package owns its own slug prefix. */\n id: string;\n /** How this adapter names itself in errors (`Bitcoin`, `SVM`, `Sui`). */\n label: string;\n /** CAIP-2 namespace without its colon. */\n namespace: string;\n /** How the chain family reads in errors (`Bitcoin`, `Solana`, `Sui`). */\n platform: string;\n /** Chain ids worth preferring over a bare prefix match. Matched against\n * the wallet's own ordering, so a wallet listing `mainnet-beta` before\n * `mainnet` keeps the chain it advertised first. */\n preferredChainIds: ReadonlyArray<string>;\n /** Called with a function that pushes a synthetic `disconnected` event\n * to all current subscribers. The discovery layer invokes it on Wallet\n * Standard `unregister`. */\n registerDisconnector?: (emit: () => void) => void;\n /** Re-point the active chain when the wallet reports a `chains` change.\n * Polkadot opts out: its wallets advertise a single relay chain, so a\n * re-point would only ever move the adapter off the chain it resolved. */\n trackChainChanges: boolean;\n wallet: WalletStandardWallet;\n};\n\ntype WalletStandardCore = {\n /** Chains the wallet advertises in this namespace; feeds capability gating. */\n chainCount: number;\n connect: (opts?: { silent?: boolean }) => Promise<void>;\n /** Active CAIP-2 chain id, for features that take a per-call `chain`. */\n currentChainId: () => string;\n disconnect: () => Promise<void>;\n getAccount: () => Promise<Account | null>;\n getAccounts: () => Promise<Array<Account>>;\n getSigner: () => Promise<unknown>;\n /** Whether the wallet advertises `standard:events`; feeds capability gating. */\n hasEvents: boolean;\n icon: string | undefined;\n id: string;\n name: string;\n /** Wallet Standard account a call should route through: the one matching\n * `account`, else the wallet's first exposed account. */\n resolveAccount: (account?: { walletAddress: string }) => WalletStandardWalletAccount;\n subscribe: (listener: (event: ConnectorEvent) => void) => () => void;\n switchChain: (chain: ChainBase) => Promise<void>;\n /** butr chain for the active chain id, for responses that mint their own\n * `Account` (Sign-In-With-Solana) rather than going through `getAccounts`. */\n toChain: () => ChainBase;\n};\n\n/**\n * Session plumbing every Wallet Standard platform adapter repeats: chain\n * resolution, the connect/disconnect handshake, account reads, the local\n * listener set that lets `switchChain` synthesise `accountChanged`, and\n * the `standard:events` bridge. Returns `null` for wallets butr can't\n * drive (no chain in this namespace, or no `standard:connect`), which is\n * the same `null` each platform adapter returns to its caller.\n *\n * Platform packages keep what genuinely differs: which features they read\n * off the wallet, how they encode transactions and messages, and their\n * balance units. `getSigner` hands back the raw Wallet Standard wallet so\n * consumers can wrap it in their own signing library.\n */\nconst createWalletStandardCore = ({\n chainPrefix,\n id,\n label,\n namespace,\n platform,\n preferredChainIds,\n registerDisconnector,\n trackChainChanges,\n wallet,\n}: WalletStandardCoreInput): WalletStandardCore | null => {\n const pickChain = (chains: ReadonlyArray<string>): string | null =>\n chains.find((c) => preferredChainIds.includes(c)) ??\n chains.find((c) => c.startsWith(chainPrefix)) ??\n null;\n\n const initialChainId = pickChain(wallet.chains);\n if (initialChainId === null) {\n return null;\n }\n const connect = getFeature<StandardConnectFeature>(wallet, \"standard:connect\");\n if (connect === undefined) {\n return null;\n }\n\n const disconnect = getFeature<StandardDisconnectFeature>(wallet, \"standard:disconnect\");\n const events = getFeature<StandardEventsFeature>(wallet, \"standard:events\");\n\n let currentChainId = initialChainId;\n const toChain = (): ChainBase => ({\n id: currentChainId,\n // butr ships no chain-id → display-name table; the wallet name stands\n // in and consumers overlay their own labels via structural typing.\n name: wallet.name,\n namespace,\n reference: currentChainId.slice(chainPrefix.length),\n });\n\n const listeners = new Set<(event: ConnectorEvent) => void>();\n const notifyAccountChanged = () => {\n if (wallet.accounts.length === 0) {\n return;\n }\n const chain = toChain();\n const built = wallet.accounts.map((a) => buildAccount(a.address, chain));\n const first = built[0];\n if (first === undefined) {\n return;\n }\n for (const listener of listeners) {\n listener({ account: first, accounts: built, type: \"accountChanged\" });\n }\n };\n\n registerDisconnector?.(() => {\n for (const listener of listeners) {\n listener({ type: \"disconnected\" });\n }\n });\n\n return {\n chainCount: wallet.chains.filter((c) => c.startsWith(chainPrefix)).length,\n\n async connect(opts) {\n // Forward `silent` so eager hydration restores already-authorized\n // accounts without re-opening the wallet's approval UI. Wallets\n // that don't honour `silent` fall back to their normal behaviour.\n await connect.connect(opts?.silent === true ? { silent: true } : undefined);\n },\n\n currentChainId: () => currentChainId,\n\n async disconnect() {\n if (disconnect !== undefined) {\n try {\n await disconnect.disconnect();\n } catch (error) {\n logWarn(`[butr] ${label} Wallet Standard disconnect threw:`, error);\n }\n }\n },\n\n getAccount: () => {\n const address = pickFirstAddress(wallet.accounts);\n return Promise.resolve(address === null ? null : buildAccount(address, toChain()));\n },\n\n getAccounts: () => {\n const chain = toChain();\n return Promise.resolve(wallet.accounts.map((a) => buildAccount(a.address, chain)));\n },\n\n getSigner: () => Promise.resolve(wallet),\n\n hasEvents: Boolean(events),\n\n icon: sanitizeIcon(wallet.icon),\n id,\n name: wallet.name,\n\n resolveAccount: (account) => {\n const wsAccount = account\n ? pickAccountByAddress(wallet.accounts, account.walletAddress)\n : wallet.accounts[0];\n if (wsAccount === undefined) {\n throw new Error(\"No connected account\");\n }\n return wsAccount;\n },\n\n subscribe(listener) {\n listeners.add(listener);\n let unsubWallet: (() => void) | null = null;\n if (events !== undefined) {\n const unsub = events.on(\"change\", (changes) => {\n // Chain change: the wallet switched network. Re-point\n // currentChainId so subsequent per-call `chain` inputs route\n // through it, mirroring `switchChain`'s local-state model.\n if (trackChainChanges && changes.chains !== undefined) {\n const next = pickChain(changes.chains);\n if (next !== null) {\n currentChainId = next;\n }\n }\n\n if (changes.accounts !== undefined) {\n if (changes.accounts.length === 0) {\n listener({ type: \"disconnected\" });\n return;\n }\n // Forward the FULL accounts list; Wallet Standard's\n // change.accounts reflects the wallet's current exposure\n // set. Mirroring it into the pool entry keeps the array in\n // sync with what the wallet actually allows us to sign with,\n // so single-account-exposure wallets (Phantom Solana,\n // MetaMask Snap) don't accumulate stale addresses.\n const chain = toChain();\n const built = changes.accounts.map((a) => buildAccount(a.address, chain));\n const first = built[0];\n if (first === undefined) {\n return;\n }\n listener({ account: first, accounts: built, type: \"accountChanged\" });\n return;\n }\n\n if (trackChainChanges && changes.chains !== undefined) {\n notifyAccountChanged();\n }\n });\n unsubWallet = () => {\n unsub();\n };\n }\n return () => {\n listeners.delete(listener);\n unsubWallet?.();\n };\n },\n\n switchChain: (chain) => {\n if (chain.namespace !== namespace) {\n throw new Error(\n `${label} adapter received non-${platform} chain \"${chain.id}\". Pass a chain with namespace \"${namespace}\".`,\n );\n }\n // The wallet must advertise this chain; otherwise the per-call\n // `chain` input would be rejected by the wallet later.\n if (!wallet.chains.includes(chain.id)) {\n throw new Error(\n `Wallet ${wallet.name} does not advertise chain \"${chain.id}\". Available: ${wallet.chains.join(\", \")}`,\n );\n }\n currentChainId = chain.id;\n // Synthesise an `accountChanged` so butr's reducer updates the pool\n // entry's chain; the wallet itself has no event to fire here.\n notifyAccountChanged();\n return Promise.resolve();\n },\n\n toChain,\n };\n};\n\nexport type { WalletStandardCore };\nexport { createWalletStandardCore };\n","import type { WalletCapabilities } from \"@usebutr/core\";\n\ntype WalletCapabilityProfile = {\n /** Chains the wallet advertises in this namespace. */\n chainCount: number;\n /** Wallet advertises `standard:events`. */\n events: boolean;\n /** Wallet advertises a sign-and-broadcast feature:\n * `solana:signAndSendTransaction`, `sui:signAndExecuteTransaction`,\n * `bitcoin:sendTransfer`. */\n sendTransaction: boolean;\n /** Wallet advertises `solana:signIn`. No other namespace has an\n * equivalent, so every non-SVM caller passes `false`. */\n signIn: boolean;\n signMessage: boolean;\n /** Wallet advertises a sign-only feature: `solana:signTransaction`,\n * `sui:signTransaction`, `bitcoin:signPsbt`. */\n signTransaction: boolean;\n};\n\n/**\n * Wallet Standard → butr capability mapping, shared by every platform\n * package. The flags that are constant across all of them:\n *\n * - `getBalance` / `getTransactionReceipt`: Wallet Standard exposes no\n * balance/receipt RPC, and butr ships no RPC client of its own.\n * - `requestAccounts`: no programmatic equivalent of EIP-2255; re-running\n * `standard:connect` doesn't produce new accounts on any major Wallet\n * Standard wallet in practice (Phantom, MetaMask Snap, Solflare,\n * Backpack, Xverse, Talisman).\n * - `switchAccount`: no protocol-level silent account switch; the user\n * picks the account inside the wallet.\n * - `switchChain`: true when the wallet advertises more than one chain in\n * this namespace. The switch is local re-routing (the per-call `chain`\n * input), so with a single chain there's nothing to switch to.\n *\n * Each platform package owns only the feature-name → flag mapping, since\n * the feature names differ per namespace.\n */\nconst buildWalletCapabilities = (profile: WalletCapabilityProfile): WalletCapabilities => ({\n getBalance: false,\n getTransactionReceipt: false,\n requestAccounts: false,\n sendTransaction: profile.sendTransaction,\n signIn: profile.signIn,\n signMessage: profile.signMessage,\n signTransaction: profile.signTransaction,\n subscribe: profile.events,\n switchAccount: false,\n switchChain: profile.chainCount > 1,\n});\n\nexport type { WalletCapabilityProfile };\nexport { buildWalletCapabilities };\n","import type { WalletAdapter } from \"@usebutr/core\";\nimport { logWarn } from \"@usebutr/core\";\n\nimport type { WalletStandardAppModule, WalletStandardWallet } from \"./types\";\n\nlet warnedMissingApp = false;\n\n/**\n * Callback supplied by per-platform discovery to build a `WalletAdapter`\n * out of a Wallet Standard wallet announcement.\n *\n * Returns `null` when the wallet doesn't advertise this platform; that\n * lets a multi-chain wallet (e.g. Phantom: SVM + EVM + Sui + Bitcoin)\n * produce one adapter per platform without each builder needing to know\n * about the others.\n *\n * The second argument is a hook the builder calls during construction\n * to wire a synthetic `disconnected` event into its subscriber set.\n * The discovery loop fires the registered emitter when Wallet Standard\n * announces `unregister` for that wallet.\n */\ntype WalletStandardAdapterBuilder = (\n wallet: WalletStandardWallet,\n registerDisconnector: (emit: () => void) => void,\n) => WalletAdapter | null;\n\n/**\n * Subscribe to Wallet Standard announcements and turn matching wallets\n * into butr `WalletAdapter`s using a per-platform `build` callback.\n *\n * **Shared machinery** every platform package needs:\n * - Dynamic import of `@wallet-standard/app` (optional peer dep;\n * failure to resolve quietly disables discovery so consumers who\n * don't install it pay nothing).\n * - Cancellation: the returned unsubscribe is safe to call before the\n * dynamic import has resolved.\n * - Dedupe by adapter id, so re-announcements don't double-emit.\n * - `unregister` integration: when an extension is removed mid-session,\n * fire the disconnector the builder registered so connected pool\n * entries on the consumer side tear down cleanly.\n *\n * **What's platform-specific** lives entirely in `build`:\n * - Which `wallet.chains` to accept.\n * - Which features to gate on.\n * - The `id` slug prefix (use `slugify(prefix, wallet.name)`).\n * - The capability resolver, the feature decoding, the chain coercion.\n *\n * Disconnectors are keyed by the wallet object itself (identity equality),\n * not by adapter id; Wallet Standard's `register` / `unregister` emit\n * the same wallet object, so identity is the cheapest stable key.\n */\nconst discoverWalletStandard = (\n onAdapter: (adapter: WalletAdapter) => void,\n build: WalletStandardAdapterBuilder,\n): (() => void) => {\n let cancelled = false;\n let internalUnsub: (() => void) | null = null;\n\n void (async () => {\n let mod: WalletStandardAppModule;\n try {\n const imported: unknown = await import(\"@wallet-standard/app\");\n if (\n typeof imported !== \"object\" ||\n imported === null ||\n !(\"getWallets\" in imported) ||\n typeof imported.getWallets !== \"function\"\n ) {\n throw new Error(\"@wallet-standard/app has no getWallets export\");\n }\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- validated getWallets export above; the rest of the untyped module is trusted\n mod = imported as WalletStandardAppModule;\n } catch (error) {\n if (!warnedMissingApp) {\n warnedMissingApp = true;\n logWarn(\n \"[butr] Wallet Standard wallet discovery is disabled: `@wallet-standard/app` could not be loaded. Install it (`npm i @wallet-standard/app`) to detect Wallet Standard wallets.\",\n error,\n );\n }\n return;\n }\n if (cancelled) {\n return;\n }\n\n const seenIds = new Set<string>();\n // wallet object → emitter that pushes synthetic `disconnected` to\n // this wallet's adapter's subscribers. Identity-keyed so the\n // unregister handler can find the right emitter cheaply.\n const disconnectors = new Map<WalletStandardWallet, () => void>();\n\n const tryAdd = (wallet: WalletStandardWallet) => {\n const adapter = build(wallet, (emit) => {\n disconnectors.set(wallet, emit);\n });\n if (!adapter || seenIds.has(adapter.id)) {\n return;\n }\n seenIds.add(adapter.id);\n onAdapter(adapter);\n };\n\n const app = mod.getWallets();\n for (const wallet of app.get()) {\n tryAdd(wallet);\n }\n\n const offRegister = app.on(\"register\", (...wallets) => {\n for (const wallet of wallets) {\n tryAdd(wallet);\n }\n });\n const offUnregister = app.on(\"unregister\", (...wallets) => {\n for (const wallet of wallets) {\n const emit = disconnectors.get(wallet);\n if (emit) {\n emit();\n disconnectors.delete(wallet);\n }\n }\n });\n internalUnsub = () => {\n offRegister();\n offUnregister();\n };\n })();\n\n return () => {\n cancelled = true;\n internalUnsub?.();\n internalUnsub = null;\n };\n};\n\nexport type { WalletStandardAdapterBuilder };\nexport { discoverWalletStandard };\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAM,WAAW,gBAAwB,SAAyB;CAKhE,OAAO,mBAAmB,eAAe,GAJ5B,KACV,KAAK,CAAC,CACN,YAAY,CAAC,CACb,2BAAW,6BAAa,GAAG,GACiB;AACjD;;;;;;;;;;AAYA,MAAM,cAAiB,QAA8B,SAAgC;CACnF,MAAM,UAAmB,OAAO,SAAS;CACzC,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,YACpB,aAAa,QACb,EAAE,gBAAgB,aAClB,OAAO,SAAS,eAAe,YAE/B,MAAM,IAAI,MAAM,+CAA+C;GAGjE,MAAM;EACR,SAAS,OAAO;GACd,IAAI,CAAC,kBAAkB;IACrB,mBAAmB;IACnB,QACE,iLACA,KACF;GACF;GACA;EACF;EACA,IAAI,WACF;EAGF,MAAM,0BAAU,IAAI,IAAY;EAIhC,MAAM,gCAAgB,IAAI,IAAsC;EAEhE,MAAM,UAAU,WAAiC;GAC/C,MAAM,UAAU,MAAM,SAAS,SAAS;IACtC,cAAc,IAAI,QAAQ,IAAI;GAChC,CAAC;GACD,IAAI,CAAC,WAAW,QAAQ,IAAI,QAAQ,EAAE,GACpC;GAEF,QAAQ,IAAI,QAAQ,EAAE;GACtB,UAAU,OAAO;EACnB;EAEA,MAAM,MAAM,IAAI,WAAW;EAC3B,KAAK,MAAM,UAAU,IAAI,IAAI,GAC3B,OAAO,MAAM;EAGf,MAAM,cAAc,IAAI,GAAG,aAAa,GAAG,YAAY;GACrD,KAAK,MAAM,UAAU,SACnB,OAAO,MAAM;EAEjB,CAAC;EACD,MAAM,gBAAgB,IAAI,GAAG,eAAe,GAAG,YAAY;GACzD,KAAK,MAAM,UAAU,SAAS;IAC5B,MAAM,OAAO,cAAc,IAAI,MAAM;IACrC,IAAI,MAAM;KACR,KAAK;KACL,cAAc,OAAO,MAAM;IAC7B;GACF;EACF,CAAC;EACD,sBAAsB;GACpB,YAAY;GACZ,cAAc;EAChB;CACF,EAAC,CAAE;CAEH,aAAa;EACX,YAAY;EACZ,gBAAgB;EAChB,gBAAgB;CAClB;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["buildAccount"],"sources":["../src/primitives.ts","../src/adapter-core.ts","../src/capabilities.ts","../src/discovery.ts"],"sourcesContent":["import type { WalletStandardWallet, WalletStandardWalletAccount } from \"./types\";\n\n/**\n * The platform prefix scopes the id so one multi-chain wallet (Phantom\n * SVM, Sui, BTC) yields distinct adapters on the shared `getWallets()` bus.\n */\nconst slugify = (platformPrefix: string, name: string): string => {\n const slug = name\n .trim()\n .toLowerCase()\n .replaceAll(/[^a-z0-9]+/gv, \"-\");\n return `wallet-standard:${platformPrefix}-${slug}`;\n};\n\n/**\n * The spec types `features` as a reverse-DNS-keyed `Record<string,\n * unknown>`, so the caller declares the shape it expects. This accessor is\n * the single boundary where that dynamism is acknowledged.\n */\n// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- caller-supplied feature shape; not inferable from args\nconst getFeature = <T>(wallet: WalletStandardWallet, name: string): T | undefined => {\n const feature: unknown = wallet.features[name];\n if (typeof feature !== \"object\" || feature === null) {\n return undefined;\n }\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- untyped Wallet Standard feature registry; caller declares the shape\n return feature as T;\n};\n\nconst pickFirstAddress = (accounts: ReadonlyArray<WalletStandardWalletAccount>): string | null => {\n const first = accounts[0];\n return first === undefined ? null : first.address;\n};\n\n/**\n * Per-call routing for `sendTx` / `signMessage`: callers pass an `account`\n * from `ConnectedWallet.accounts` to sign with a non-active address, but\n * the wallet's own `accounts[]` stays the source of truth.\n */\nconst pickAccountByAddress = (\n accounts: ReadonlyArray<WalletStandardWalletAccount>,\n address: string,\n): WalletStandardWalletAccount | undefined =>\n accounts.find((a) => a.address === address) ?? accounts[0];\n\nexport { buildAccount } from \"@usebutr/core\";\nexport { getFeature, pickAccountByAddress, pickFirstAddress, slugify };\n","import type { Account, ChainBase, ConnectorEvent } from \"@usebutr/core\";\nimport { buildAccount, logWarn, sanitizeIcon } from \"@usebutr/core\";\n\nimport { getFeature, pickAccountByAddress, pickFirstAddress } from \"./primitives\";\nimport type {\n StandardConnectFeature,\n StandardDisconnectFeature,\n StandardEventsFeature,\n WalletStandardWallet,\n WalletStandardWalletAccount,\n} from \"./types\";\n\ntype WalletStandardCoreInput = {\n /** CAIP-2 prefix including its colon (`solana:`, `sui:`, `bip122:`). */\n chainPrefix: string;\n /** Stable adapter id. Each platform package owns its own slug prefix. */\n id: string;\n /** How this adapter names itself in errors (`Bitcoin`, `SVM`, `Sui`). */\n label: string;\n /** CAIP-2 namespace without its colon. */\n namespace: string;\n /** How the chain family reads in errors (`Bitcoin`, `Solana`, `Sui`). */\n platform: string;\n /** Chain ids worth preferring over a bare prefix match. Matched against\n * the wallet's own ordering, so a wallet listing `mainnet-beta` before\n * `mainnet` keeps the chain it advertised first. */\n preferredChainIds: ReadonlyArray<string>;\n /** Called with a function that pushes a synthetic `disconnected` event\n * to all current subscribers. The discovery layer invokes it on Wallet\n * Standard `unregister`. */\n registerDisconnector?: (emit: () => void) => void;\n /** Re-point the active chain when the wallet reports a `chains` change.\n * Polkadot opts out: its wallets advertise a single relay chain, so a\n * re-point would only ever move the adapter off the chain it resolved. */\n trackChainChanges: boolean;\n wallet: WalletStandardWallet;\n};\n\ntype WalletStandardCore = {\n /** Chains the wallet advertises in this namespace; feeds capability gating. */\n chainCount: number;\n connect: (opts?: { silent?: boolean }) => Promise<void>;\n /** Active CAIP-2 chain id, for features that take a per-call `chain`. */\n currentChainId: () => string;\n disconnect: () => Promise<void>;\n getAccount: () => Promise<Account | null>;\n getAccounts: () => Promise<Array<Account>>;\n getSigner: () => Promise<unknown>;\n /** Whether the wallet advertises `standard:events`; feeds capability gating. */\n hasEvents: boolean;\n icon: string | undefined;\n id: string;\n name: string;\n /** Wallet Standard account a call should route through: the one matching\n * `account`, else the wallet's first exposed account. */\n resolveAccount: (account?: { walletAddress: string }) => WalletStandardWalletAccount;\n subscribe: (listener: (event: ConnectorEvent) => void) => () => void;\n switchChain: (chain: ChainBase) => Promise<void>;\n /** butr chain for the active chain id, for responses that mint their own\n * `Account` (Sign-In-With-Solana) rather than going through `getAccounts`. */\n toChain: () => ChainBase;\n};\n\n/**\n * Shared session plumbing for every Wallet Standard platform adapter.\n * `getSigner` hands back the raw Wallet Standard wallet so consumers can\n * wrap it in their own signing library.\n */\nconst createWalletStandardCore = ({\n chainPrefix,\n id,\n label,\n namespace,\n platform,\n preferredChainIds,\n registerDisconnector,\n trackChainChanges,\n wallet,\n}: WalletStandardCoreInput): WalletStandardCore | null => {\n const pickChain = (chains: ReadonlyArray<string>): string | null =>\n chains.find((c) => preferredChainIds.includes(c)) ??\n chains.find((c) => c.startsWith(chainPrefix)) ??\n null;\n\n const initialChainId = pickChain(wallet.chains);\n if (initialChainId === null) {\n return null;\n }\n const connect = getFeature<StandardConnectFeature>(wallet, \"standard:connect\");\n if (connect === undefined) {\n return null;\n }\n\n const disconnect = getFeature<StandardDisconnectFeature>(wallet, \"standard:disconnect\");\n const events = getFeature<StandardEventsFeature>(wallet, \"standard:events\");\n\n let currentChainId = initialChainId;\n const toChain = (): ChainBase => ({\n id: currentChainId,\n name: wallet.name,\n namespace,\n reference: currentChainId.slice(chainPrefix.length),\n });\n\n const listeners = new Set<(event: ConnectorEvent) => void>();\n const notifyAccountChanged = () => {\n if (wallet.accounts.length === 0) {\n return;\n }\n const chain = toChain();\n const built = wallet.accounts.map((a) => buildAccount(a.address, chain));\n const first = built[0];\n if (first === undefined) {\n return;\n }\n for (const listener of listeners) {\n listener({ account: first, accounts: built, type: \"accountChanged\" });\n }\n };\n\n registerDisconnector?.(() => {\n for (const listener of listeners) {\n listener({ type: \"disconnected\" });\n }\n });\n\n return {\n chainCount: wallet.chains.filter((c) => c.startsWith(chainPrefix)).length,\n\n async connect(opts) {\n await connect.connect(opts?.silent === true ? { silent: true } : undefined);\n },\n\n currentChainId: () => currentChainId,\n\n async disconnect() {\n if (disconnect !== undefined) {\n try {\n await disconnect.disconnect();\n } catch (error) {\n logWarn(`[butr] ${label} Wallet Standard disconnect threw:`, error);\n }\n }\n },\n\n getAccount: () => {\n const address = pickFirstAddress(wallet.accounts);\n return Promise.resolve(address === null ? null : buildAccount(address, toChain()));\n },\n\n getAccounts: () => {\n const chain = toChain();\n return Promise.resolve(wallet.accounts.map((a) => buildAccount(a.address, chain)));\n },\n\n getSigner: () => Promise.resolve(wallet),\n\n hasEvents: Boolean(events),\n\n icon: sanitizeIcon(wallet.icon),\n id,\n name: wallet.name,\n\n resolveAccount: (account) => {\n const wsAccount = account\n ? pickAccountByAddress(wallet.accounts, account.walletAddress)\n : wallet.accounts[0];\n if (wsAccount === undefined) {\n throw new Error(\"No connected account\");\n }\n return wsAccount;\n },\n\n subscribe(listener) {\n listeners.add(listener);\n let unsubWallet: (() => void) | null = null;\n if (events !== undefined) {\n const unsub = events.on(\"change\", (changes) => {\n if (trackChainChanges && changes.chains !== undefined) {\n const next = pickChain(changes.chains);\n if (next !== null) {\n currentChainId = next;\n }\n }\n\n if (changes.accounts !== undefined) {\n if (changes.accounts.length === 0) {\n listener({ type: \"disconnected\" });\n return;\n }\n const chain = toChain();\n const built = changes.accounts.map((a) => buildAccount(a.address, chain));\n const first = built[0];\n if (first === undefined) {\n return;\n }\n listener({ account: first, accounts: built, type: \"accountChanged\" });\n return;\n }\n\n if (trackChainChanges && changes.chains !== undefined) {\n notifyAccountChanged();\n }\n });\n unsubWallet = () => {\n unsub();\n };\n }\n return () => {\n listeners.delete(listener);\n unsubWallet?.();\n };\n },\n\n // Async so a rejected chain surfaces as a rejection. Declared\n // `Promise<void>`, this previously threw synchronously, so a caller\n // attaching `.catch()` instead of awaiting got an uncaught throw.\n switchChain: async (chain) => {\n if (chain.namespace !== namespace) {\n throw new Error(\n `${label} adapter received non-${platform} chain \"${chain.id}\". Pass a chain with namespace \"${namespace}\".`,\n );\n }\n if (!wallet.chains.includes(chain.id)) {\n throw new Error(\n `Wallet ${wallet.name} does not advertise chain \"${chain.id}\". Available: ${wallet.chains.join(\", \")}`,\n );\n }\n currentChainId = chain.id;\n notifyAccountChanged();\n await Promise.resolve();\n },\n\n toChain,\n };\n};\n\nexport type { WalletStandardCore };\nexport { createWalletStandardCore };\n","import type { WalletCapabilities } from \"@usebutr/core\";\n\ntype WalletCapabilityProfile = {\n /** Chains the wallet advertises in this namespace. */\n chainCount: number;\n /** Wallet advertises `standard:events`. */\n events: boolean;\n /** Wallet advertises a sign-and-broadcast feature:\n * `solana:signAndSendTransaction`, `sui:signAndExecuteTransaction`,\n * `bitcoin:sendTransfer`. */\n sendTransaction: boolean;\n /** Wallet advertises `solana:signIn`. No other namespace has an\n * equivalent, so every non-SVM caller passes `false`. */\n signIn: boolean;\n signMessage: boolean;\n /** Wallet advertises a sign-only feature: `solana:signTransaction`,\n * `sui:signTransaction`, `bitcoin:signPsbt`. */\n signTransaction: boolean;\n};\n\n/**\n * Wallet Standard has no balance/receipt RPC, no EIP-2255 equivalent, and\n * no silent account switch, so those flags are false everywhere.\n * `switchChain` re-routes locally, so it needs a second advertised chain.\n */\nconst buildWalletCapabilities = (profile: WalletCapabilityProfile): WalletCapabilities => ({\n getBalance: false,\n getTransactionReceipt: false,\n requestAccounts: false,\n sendTransaction: profile.sendTransaction,\n signIn: profile.signIn,\n signMessage: profile.signMessage,\n signTransaction: profile.signTransaction,\n subscribe: profile.events,\n switchAccount: false,\n switchChain: profile.chainCount > 1,\n});\n\nexport type { WalletCapabilityProfile };\nexport { buildWalletCapabilities };\n","import type { WalletAdapter } from \"@usebutr/core\";\nimport { logWarn } from \"@usebutr/core\";\n\nimport type { WalletStandardAppModule, WalletStandardWallet } from \"./types\";\n\nlet warnedMissingApp = false;\n\n/**\n * Returns `null` when the wallet doesn't advertise this platform, so a\n * multi-chain wallet yields one adapter per platform. `registerDisconnector`\n * wires the synthetic `disconnected` fired on Wallet Standard `unregister`.\n */\ntype WalletStandardAdapterBuilder = (\n wallet: WalletStandardWallet,\n registerDisconnector: (emit: () => void) => void,\n) => WalletAdapter | null;\n\n/**\n * `@wallet-standard/app` is an optional peer dep: a failed import quietly\n * disables discovery. Disconnectors are keyed by wallet identity rather\n * than adapter id because `register` / `unregister` emit the same object.\n */\nconst discoverWalletStandard = (\n onAdapter: (adapter: WalletAdapter) => void,\n build: WalletStandardAdapterBuilder,\n): (() => void) => {\n let cancelled = false;\n let internalUnsub: (() => void) | null = null;\n\n void (async () => {\n let mod: WalletStandardAppModule;\n try {\n const imported: unknown = await import(\"@wallet-standard/app\");\n if (\n typeof imported !== \"object\" ||\n imported === null ||\n !(\"getWallets\" in imported) ||\n typeof imported.getWallets !== \"function\"\n ) {\n throw new Error(\"@wallet-standard/app has no getWallets export\");\n }\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- validated getWallets export above; the rest of the untyped module is trusted\n mod = imported as WalletStandardAppModule;\n } catch (error) {\n if (!warnedMissingApp) {\n warnedMissingApp = true;\n logWarn(\n \"[butr] Wallet Standard wallet discovery is disabled: `@wallet-standard/app` could not be loaded. Install it (`npm i @wallet-standard/app`) to detect Wallet Standard wallets.\",\n error,\n );\n }\n return;\n }\n if (cancelled) {\n return;\n }\n\n const seenIds = new Set<string>();\n const disconnectors = new Map<WalletStandardWallet, () => void>();\n\n const tryAdd = (wallet: WalletStandardWallet) => {\n const adapter = build(wallet, (emit) => {\n disconnectors.set(wallet, emit);\n });\n if (!adapter || seenIds.has(adapter.id)) {\n return;\n }\n seenIds.add(adapter.id);\n onAdapter(adapter);\n };\n\n const app = mod.getWallets();\n for (const wallet of app.get()) {\n tryAdd(wallet);\n }\n\n const offRegister = app.on(\"register\", (...wallets) => {\n for (const wallet of wallets) {\n tryAdd(wallet);\n }\n });\n const offUnregister = app.on(\"unregister\", (...wallets) => {\n for (const wallet of wallets) {\n const emit = disconnectors.get(wallet);\n if (emit) {\n emit();\n disconnectors.delete(wallet);\n }\n }\n });\n internalUnsub = () => {\n offRegister();\n offUnregister();\n };\n })();\n\n return () => {\n cancelled = true;\n internalUnsub?.();\n internalUnsub = null;\n };\n};\n\nexport type { WalletStandardAdapterBuilder };\nexport { discoverWalletStandard };\n"],"mappings":";;;;;;;AAMA,MAAM,WAAW,gBAAwB,SAAyB;CAKhE,OAAO,mBAAmB,eAAe,GAJ5B,KACV,KAAK,CAAC,CACN,YAAY,CAAC,CACb,WAAW,6BAAa,GAAG,GACiB;AACjD;;;;;;AAQA,MAAM,cAAiB,QAA8B,SAAgC;CACnF,MAAM,UAAmB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,OAAO,SAAS,eAAe,YAE/B,MAAM,IAAI,MAAM,+CAA+C;GAGjE,MAAM;EACR,SAAS,OAAO;GACd,IAAI,CAAC,kBAAkB;IACrB,mBAAmB;IACnB,QACE,iLACA,KACF;GACF;GACA;EACF;EACA,IAAI,WACF;EAGF,MAAM,0BAAU,IAAI,IAAY;EAChC,MAAM,gCAAgB,IAAI,IAAsC;EAEhE,MAAM,UAAU,WAAiC;GAC/C,MAAM,UAAU,MAAM,SAAS,SAAS;IACtC,cAAc,IAAI,QAAQ,IAAI;GAChC,CAAC;GACD,IAAI,CAAC,WAAW,QAAQ,IAAI,QAAQ,EAAE,GACpC;GAEF,QAAQ,IAAI,QAAQ,EAAE;GACtB,UAAU,OAAO;EACnB;EAEA,MAAM,MAAM,IAAI,WAAW;EAC3B,KAAK,MAAM,UAAU,IAAI,IAAI,GAC3B,OAAO,MAAM;EAGf,MAAM,cAAc,IAAI,GAAG,aAAa,GAAG,YAAY;GACrD,KAAK,MAAM,UAAU,SACnB,OAAO,MAAM;EAEjB,CAAC;EACD,MAAM,gBAAgB,IAAI,GAAG,eAAe,GAAG,YAAY;GACzD,KAAK,MAAM,UAAU,SAAS;IAC5B,MAAM,OAAO,cAAc,IAAI,MAAM;IACrC,IAAI,MAAM;KACR,KAAK;KACL,cAAc,OAAO,MAAM;IAC7B;GACF;EACF,CAAC;EACD,sBAAsB;GACpB,YAAY;GACZ,cAAc;EAChB;CACF,EAAC,CAAE;CAEH,aAAa;EACX,YAAY;EACZ,gBAAgB;EAChB,gBAAgB;CAClB;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usebutr/wallet-standard-shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Shared Wallet Standard discovery primitives used by @usebutr/svm, @usebutr/sui, @usebutr/bitcoin.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Pedro Filho <pedro@filho.me>",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@usebutr/core": "
|
|
25
|
+
"@usebutr/core": "2.0.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@wallet-standard/app": "^1.1.1",
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"build": "tsdown",
|
|
44
44
|
"clean": "rm -rf dist",
|
|
45
45
|
"dev": "tsdown --watch",
|
|
46
|
-
"lint": "oxlint src",
|
|
47
46
|
"test": "vitest run --passWithNoTests",
|
|
48
47
|
"test:coverage": "vitest run --coverage --passWithNoTests",
|
|
49
48
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|