@usebutr/polkadot 1.0.1 → 1.1.2
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/CHANGELOG.md +177 -0
- package/LICENSE +21 -0
- package/README.md +39 -0
- package/dist/index.d.ts +28 -53
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +96 -93
- package/dist/index.js.map +1 -1
- package/package.json +21 -6
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# @usebutr/polkadot
|
|
2
|
+
|
|
3
|
+
## 1.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`bc5b58c`](https://github.com/pedroapfilho/usebutr/commit/bc5b58cd87601be38dbb77a14e16eaaa36e8f012), [`bc5b58c`](https://github.com/pedroapfilho/usebutr/commit/bc5b58cd87601be38dbb77a14e16eaaa36e8f012)]:
|
|
8
|
+
- @usebutr/wallet-standard-shared@1.0.0
|
|
9
|
+
- @usebutr/core@2.0.1
|
|
10
|
+
|
|
11
|
+
## 1.1.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [302ae4a]
|
|
16
|
+
- @usebutr/wallet-standard-shared@0.5.1
|
|
17
|
+
|
|
18
|
+
## 1.1.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- 9b1caa2: Correctness pass across the storage, hydration and connector layers. Several of
|
|
23
|
+
these change observable behaviour; the ones worth knowing about before upgrading:
|
|
24
|
+
|
|
25
|
+
**Breaking**
|
|
26
|
+
|
|
27
|
+
- `SuiWallet.signTransaction` now returns `{ bytes, signature }` instead of
|
|
28
|
+
`Uint8Array`. Sui's `executeTransactionBlock` needs both, and each connector
|
|
29
|
+
previously returned a different half, so the old value could not be broadcast
|
|
30
|
+
and a consumer could not tell which half they held. SVM and Bitcoin keep their
|
|
31
|
+
single-`Uint8Array` shape.
|
|
32
|
+
- `@usebutr/svm`'s `sendTx` returns the signature base58-encoded, matching the
|
|
33
|
+
WalletConnect namespace, the Ledger app, Solana explorers and
|
|
34
|
+
`getSignatureStatuses`. It previously returned base64.
|
|
35
|
+
- `@usebutr/sui`'s feature input types drop the `string` arm from
|
|
36
|
+
`transaction`; wallets only ever accepted the `toJSON()` form. Strings and BCS
|
|
37
|
+
bytes are now wrapped for you, so `sendTx` accepts strictly more than before.
|
|
38
|
+
|
|
39
|
+
**Behaviour fixes**
|
|
40
|
+
|
|
41
|
+
- `WalletStorage.setPool` and `removePoolEntry` could self-deadlock on a corrupt
|
|
42
|
+
pool payload, leaving `connectWallet` unresolved and every later pool write
|
|
43
|
+
jammed for the page's life. Both are fixed, and `readWalletSnapshot` now shares
|
|
44
|
+
one codec with `WalletStorage` so the server and client decodes cannot drift.
|
|
45
|
+
- A seeded (SSR) entry whose silent reconnect failed used to stay in the pool
|
|
46
|
+
backed by a placeholder connector forever, so `useSigner`/`useBalance`
|
|
47
|
+
reported an error and `useConnectionStatus` reported `"reconnecting"`
|
|
48
|
+
permanently. Those entries are now dropped.
|
|
49
|
+
- `useSigner` and `useBalance` stay `idle` for a wallet that is still
|
|
50
|
+
reconnecting instead of surfacing a placeholder rejection as `status: "error"`.
|
|
51
|
+
- `useConnectionStatus` lets a live `"connecting"`/`"error"` take precedence over
|
|
52
|
+
the derived `"reconnecting"`, so an in-flight attempt and a connection error
|
|
53
|
+
are no longer hidden. New `useIsReconnecting(connectorId?)` answers the
|
|
54
|
+
per-wallet question directly.
|
|
55
|
+
- A background restore no longer writes the connect-attempt status or steals
|
|
56
|
+
`activeConnectorId`, and a superseded `CONNECT_FAILED` no longer overwrites the
|
|
57
|
+
current attempt.
|
|
58
|
+
- An externally-disconnected connector is now torn down, not just dropped from
|
|
59
|
+
the pool, so a cached adapter is not reused while still holding a session.
|
|
60
|
+
- EVM: a malformed provider response is treated as absent rather than `""`, which
|
|
61
|
+
previously produced chain `eip155:0`, zero-length signatures, empty transaction
|
|
62
|
+
hashes and a confident `0 ETH`. `switchChain` gained the same-chain
|
|
63
|
+
short-circuit `sendTxToChain` already had.
|
|
64
|
+
- WalletConnect: accounts carry their own chain instead of all being stamped with
|
|
65
|
+
the active one, so a multi-chain session no longer returns a wrong-chain
|
|
66
|
+
address. One pairing now covers every configured namespace, the pairing URI
|
|
67
|
+
survives a reconnect, and concurrent connects share one pairing.
|
|
68
|
+
- Bitcoin: the sats-connect (Xverse) adapter honours `silent`, so a reload no
|
|
69
|
+
longer triggers an unsolicited approval prompt, and exposes the payment address
|
|
70
|
+
as its single account instead of also presenting the ordinals address as
|
|
71
|
+
spendable.
|
|
72
|
+
- Polkadot: the injected adapter actually delivers events to subscribers,
|
|
73
|
+
`switchChain` notifies like its Wallet Standard sibling, and chain resolution
|
|
74
|
+
prefers the mainnets rather than whatever the wallet listed first.
|
|
75
|
+
- Ledger: the device session is committed atomically, so a locked device no
|
|
76
|
+
longer leaves an open transport that reports itself connected, and concurrent
|
|
77
|
+
connects open one transport.
|
|
78
|
+
- SVM: `sendTxToChain` submits to the chain you asked for instead of the
|
|
79
|
+
adapter's current one, and rejects a chain the wallet does not advertise.
|
|
80
|
+
- `@usebutr/svm`'s `switchChain` capability now counts only `solana:` chains, so
|
|
81
|
+
a multi-namespace wallet no longer advertises a method that always throws.
|
|
82
|
+
|
|
83
|
+
**Testing**
|
|
84
|
+
|
|
85
|
+
- `createFakePersistence` is now the real `WalletStorage` over memory drivers
|
|
86
|
+
rather than a parallel implementation, so it inherits upsert semantics,
|
|
87
|
+
validation and JSON round-tripping. Two divergences are fixed as a result:
|
|
88
|
+
`setPool` upserts rather than replaces, and `clearAll` leaves the
|
|
89
|
+
user-disconnected flag alone.
|
|
90
|
+
- `createFakeConnectedWallet` rejects being given both an `adapter` and explicit
|
|
91
|
+
`addresses`/`accounts`, a combination whose halves could disagree.
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- Updated dependencies [9b1caa2]
|
|
96
|
+
- @usebutr/wallet-standard-shared@0.5.0
|
|
97
|
+
- @usebutr/core@2.0.0
|
|
98
|
+
|
|
99
|
+
## 1.0.1
|
|
100
|
+
|
|
101
|
+
### Patch Changes
|
|
102
|
+
|
|
103
|
+
- Updated dependencies [8ecaf89]
|
|
104
|
+
- @usebutr/core@1.1.0
|
|
105
|
+
- @usebutr/wallet-standard-shared@0.4.1
|
|
106
|
+
|
|
107
|
+
## 1.0.0
|
|
108
|
+
|
|
109
|
+
### Major Changes
|
|
110
|
+
|
|
111
|
+
- f0a5116: **Breaking:** the `platform` field is gone from the `PlatformDiscoverer` type in `@usebutr/core`, and from the `evmDiscoverer`, `svmDiscoverer`, `suiDiscoverer`, `bitcoinDiscoverer` and `polkadotDiscoverer` objects that implement it. Nothing read it: the aggregator keys discoverers by `ChainPlatform` in its own registry, so the field only restated the key.
|
|
112
|
+
|
|
113
|
+
Migration: read the platform from the `KNOWN_DISCOVERERS` key in `@usebutr/wallets` (`Object.entries(KNOWN_DISCOVERERS)`), or from `adapter.chainPlatform` on a discovered adapter. Custom `PlatformDiscoverer` implementations must drop the `platform` property; keeping it is now an excess-property error.
|
|
114
|
+
|
|
115
|
+
### Patch Changes
|
|
116
|
+
|
|
117
|
+
- 7887cf0: Resolve capabilities through `buildWalletCapabilities` from `@usebutr/wallet-standard-shared` instead of a per-package copy of the same object literal. Resolver names, input types and returned flags are unchanged. The injected Polkadot profile now derives its chain count from `POLKADOT_CHAINS_LIST` rather than asserting `switchChain: true` directly; the result is the same.
|
|
118
|
+
- 7887cf0: Move each package's `discover*Adapters` function next to the adapter builder it wraps and drop the single-function `wallet-standard.ts` module. The functions are still exported from the package root under the same names; only an internal file boundary went away.
|
|
119
|
+
- Updated dependencies [7887cf0]
|
|
120
|
+
- Updated dependencies [7887cf0]
|
|
121
|
+
- Updated dependencies [f0a5116]
|
|
122
|
+
- Updated dependencies [f0a5116]
|
|
123
|
+
- Updated dependencies [7887cf0]
|
|
124
|
+
- @usebutr/core@1.0.0
|
|
125
|
+
- @usebutr/wallet-standard-shared@0.4.0
|
|
126
|
+
|
|
127
|
+
## 0.1.4
|
|
128
|
+
|
|
129
|
+
### Patch Changes
|
|
130
|
+
|
|
131
|
+
- efe4550: Share the session plumbing behind the Wallet Standard and WalletConnect CAIP adapters. `@usebutr/wallet-standard-shared` now exports `createWalletStandardCore`, which the Bitcoin, Polkadot, Sui and SVM adapters build on; the WalletConnect Bitcoin, Sui and SVM namespaces share an equivalent CAIP core. Every package's public API is unchanged. The one visible difference is a dev-console warning: a failed SVM disconnect now logs `[butr] SVM Wallet Standard disconnect threw:` instead of `[butr] Wallet Standard disconnect threw:`.
|
|
132
|
+
- Updated dependencies [efe4550]
|
|
133
|
+
- Updated dependencies [4467a5e]
|
|
134
|
+
- @usebutr/wallet-standard-shared@0.3.0
|
|
135
|
+
- @usebutr/core@0.5.0
|
|
136
|
+
|
|
137
|
+
## 0.1.3
|
|
138
|
+
|
|
139
|
+
### Patch Changes
|
|
140
|
+
|
|
141
|
+
- Updated dependencies [c1309ee]
|
|
142
|
+
- @usebutr/core@0.4.2
|
|
143
|
+
- @usebutr/wallet-standard-shared@0.2.6
|
|
144
|
+
|
|
145
|
+
## 0.1.2
|
|
146
|
+
|
|
147
|
+
### Patch Changes
|
|
148
|
+
|
|
149
|
+
- 937dfae: Bump runtime dependency floors (`@wallet-standard/app` 1.1.1, `@ledgerhq/*` latest minors, `@walletconnect/universal-provider` 2.23.10) and modernize public type declarations from method signatures to property function types (oxlint `method-signature-style`). Type-level only — no runtime behavior change.
|
|
150
|
+
- Updated dependencies [937dfae]
|
|
151
|
+
- @usebutr/core@0.4.1
|
|
152
|
+
- @usebutr/wallet-standard-shared@0.2.5
|
|
153
|
+
|
|
154
|
+
## 0.1.1
|
|
155
|
+
|
|
156
|
+
### Patch Changes
|
|
157
|
+
|
|
158
|
+
- a46eecd: Ship unminified ESM so downstream bundlers (Vite/esbuild dep pre-bundling) process the package correctly; fixes a ReferenceError in consumer dev servers. The consuming app minifies once at its own build.
|
|
159
|
+
- Updated dependencies [b5322ae]
|
|
160
|
+
- Updated dependencies [d5f32c7]
|
|
161
|
+
- Updated dependencies [a46eecd]
|
|
162
|
+
- Updated dependencies [3f26776]
|
|
163
|
+
- @usebutr/core@0.4.0
|
|
164
|
+
- @usebutr/wallet-standard-shared@0.2.4
|
|
165
|
+
|
|
166
|
+
## 0.1.0
|
|
167
|
+
|
|
168
|
+
### Minor Changes
|
|
169
|
+
|
|
170
|
+
- 886ee1d: Add Polkadot/Substrate support. New `@usebutr/polkadot` package discovers wallets via injectedWeb3 (polkadot-js, Talisman, SubWallet, Nova, Enkrypt) with a Wallet Standard `polkadot:*` fallback. `ChainPlatform` widens to include `"polkadot"`; `autoDiscovery({ polkadot: true })` and `CHAINS_BY_PLATFORM` now cover it. Message signing works via the injected `signer.signRaw`; transaction signing is delegated to the consumer through `getSigner()` (e.g. polkadot-api), matching butr's no-RPC posture.
|
|
171
|
+
|
|
172
|
+
### Patch Changes
|
|
173
|
+
|
|
174
|
+
- 0751cc3: Share the no-RPC placeholders between the injectedWeb3 and Wallet Standard adapters (single `no-rpc` module), so the "butr ships no RPC on Polkadot" invariant lives in one place. `getBalance` now returns a neutral, chain-agnostic placeholder (`{ decimals: 0, symbol: "" }`) instead of a hardcoded `DOT`/10 that was wrong for Kusama/Westend/Paseo; it stays gated behind `capabilities.getBalance === false`. The injected `getSigner()` now throws `"No connected account"` instead of handing back an empty-string address.
|
|
175
|
+
- Updated dependencies [886ee1d]
|
|
176
|
+
- @usebutr/core@0.3.0
|
|
177
|
+
- @usebutr/wallet-standard-shared@0.2.3
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pedro Filho
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @usebutr/polkadot
|
|
2
|
+
|
|
3
|
+
injectedWeb3 + Wallet Standard adapter for butr (Polkadot/Substrate).
|
|
4
|
+
|
|
5
|
+
Part of [butr](https://www.usebutr.com), a multi-chain wallet discovery and
|
|
6
|
+
connection-state library. Your application owns the picker UI and chain client.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @usebutr/react @usebutr/core @usebutr/polkadot zustand
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
React 18+ is a peer dependency of the provider. Discovery does not render a connect modal; add your picker as the provider child. This example uses injectedWeb3. Use `@usebutr/wallets` to also compose the Wallet Standard fallback.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import type { ReactNode } from "react";
|
|
20
|
+
import { createWalletSource } from "@usebutr/core";
|
|
21
|
+
import { discoverInjectedPolkadotAdapters } from "@usebutr/polkadot";
|
|
22
|
+
import { WalletManagerProvider } from "@usebutr/react";
|
|
23
|
+
|
|
24
|
+
const discovery = createWalletSource(discoverInjectedPolkadotAdapters);
|
|
25
|
+
export const WalletProvider = ({ children }: { children: ReactNode }) => (
|
|
26
|
+
<WalletManagerProvider discovery={discovery}>{children}</WalletManagerProvider>
|
|
27
|
+
);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Documentation
|
|
31
|
+
|
|
32
|
+
- [Package reference](https://docs.usebutr.com/api/polkadot)
|
|
33
|
+
- [Getting started](https://docs.usebutr.com/getting-started/quickstart)
|
|
34
|
+
- [Examples and source](https://github.com/pedroapfilho/usebutr)
|
|
35
|
+
- [Report an issue](https://github.com/pedroapfilho/usebutr/issues)
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
[MIT](./LICENSE), copyright 2026 Pedro Filho.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WalletStandardWallet, WalletStandardWalletAccount } from "@usebutr/wallet-standard-shared";
|
|
2
|
-
import { ChainBase, PlatformDiscoverer, PolkadotAdapter, WalletAdapter, WalletCapabilities } from "@usebutr/core";
|
|
2
|
+
import { ChainBase, PlatformDiscoverer, PolkadotAdapter, WalletAdapter, WalletCapabilities, WalletSigner } from "@usebutr/core";
|
|
3
3
|
//#region src/chains.d.ts
|
|
4
4
|
declare const POLKADOT_CHAINS: {
|
|
5
5
|
readonly kusama: {
|
|
@@ -38,10 +38,9 @@ type WalletStandardPolkadotCapabilityInput = {
|
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
41
|
-
* injectedWeb3
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* because injectedWeb3 wallets advertise no chains of their own.
|
|
41
|
+
* injectedWeb3 always exposes `signer.signRaw` and `accounts.subscribe`, so
|
|
42
|
+
* those flags are unconditional. The chain count comes from butr's own
|
|
43
|
+
* registry because injectedWeb3 wallets advertise no chains.
|
|
45
44
|
*/
|
|
46
45
|
declare const resolveInjectedPolkadotCapabilities: () => WalletCapabilities;
|
|
47
46
|
/**
|
|
@@ -53,11 +52,9 @@ declare const resolveWalletStandardPolkadotCapabilities: (input: WalletStandardP
|
|
|
53
52
|
//#endregion
|
|
54
53
|
//#region src/injected/injected-web3.d.ts
|
|
55
54
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* `@polkadot/extension-inject
|
|
59
|
-
* posture as `@usebutr/bitcoin`'s `UnisatProvider`. These narrow the
|
|
60
|
-
* spec to only the fields butr reads.
|
|
55
|
+
* Local narrowing of the `@polkadot/extension-dapp` injectedWeb3 standard
|
|
56
|
+
* to the fields butr reads, so the connector takes no dependency on
|
|
57
|
+
* `@polkadot/extension-inject`.
|
|
61
58
|
*/
|
|
62
59
|
/** A single account the extension exposes. Addresses are SS58; accounts
|
|
63
60
|
* are chain-agnostic across Substrate. */
|
|
@@ -95,6 +92,11 @@ type InjectedWindowProvider = {
|
|
|
95
92
|
type InjectedWindow = {
|
|
96
93
|
injectedWeb3?: Record<string, InjectedWindowProvider>;
|
|
97
94
|
};
|
|
95
|
+
declare global {
|
|
96
|
+
interface Window {
|
|
97
|
+
injectedWeb3?: Record<string, InjectedWindowProvider>;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
98
100
|
//#endregion
|
|
99
101
|
//#region src/injected/adapter.d.ts
|
|
100
102
|
/** Handle returned by `getSigner()`. Carries the `window.injectedWeb3`
|
|
@@ -106,14 +108,10 @@ type PolkadotSignerHandle = {
|
|
|
106
108
|
extension: Injected;
|
|
107
109
|
extensionName: string;
|
|
108
110
|
};
|
|
111
|
+
declare const isPolkadotSignerHandle: (value: WalletSigner) => value is PolkadotSignerHandle;
|
|
109
112
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* `enable()` triggers the authorization prompt, so it runs lazily in
|
|
113
|
-
* `connect()`. Before connect, `getAccount` returns null.
|
|
114
|
-
*
|
|
115
|
-
* `id` is `injected:polkadot:<slug>` so consumers can distinguish the
|
|
116
|
-
* injected channel from the Wallet Standard one in their picker.
|
|
113
|
+
* The provider is not enabled at construction: `enable()` raises the
|
|
114
|
+
* extension's authorization prompt, so it runs lazily in `connect()`.
|
|
117
115
|
*/
|
|
118
116
|
declare const buildInjectedPolkadotAdapter: (extensionName: string, displayName: string, provider: InjectedWindowProvider) => PolkadotAdapter;
|
|
119
117
|
//#endregion
|
|
@@ -126,13 +124,9 @@ type InjectedPolkadotDiscoveryOptions = {
|
|
|
126
124
|
target?: InjectedWindow | null;
|
|
127
125
|
};
|
|
128
126
|
/**
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* lazily.
|
|
133
|
-
*
|
|
134
|
-
* Extensions inject at different times during page load, so we read
|
|
135
|
-
* immediately and re-check on a short poll schedule, deduping by key.
|
|
127
|
+
* Adapters are built without calling `enable()`, which would raise the
|
|
128
|
+
* extension's authorization prompt at discovery time. Extensions inject at
|
|
129
|
+
* different points during page load, hence the poll schedule.
|
|
136
130
|
*/
|
|
137
131
|
declare const discoverInjectedPolkadotAdapters: (onAdapter: (adapter: WalletAdapter) => void, options?: InjectedPolkadotDiscoveryOptions) => (() => void);
|
|
138
132
|
//#endregion
|
|
@@ -147,53 +141,34 @@ type PolkadotSignMessageOutput = {
|
|
|
147
141
|
};
|
|
148
142
|
type PolkadotSignMessageFeature = {
|
|
149
143
|
signMessage: (input: PolkadotSignMessageInput) => Promise<PolkadotSignMessageOutput>;
|
|
144
|
+
version?: string;
|
|
150
145
|
};
|
|
151
146
|
//#endregion
|
|
152
147
|
//#region src/wallet-standard-adapter.d.ts
|
|
153
|
-
/**
|
|
154
|
-
* Adapt a Wallet Standard wallet advertising `polkadot:*` features into a
|
|
155
|
-
* butr `WalletAdapter`. Returns `null` for wallets that don't advertise a
|
|
156
|
-
* polkadot chain or `standard:connect`. butr ships no RPC, so
|
|
157
|
-
* sendTx/getBalance/getTransactionReceipt are placeholders; transaction
|
|
158
|
-
* signing goes through `getSigner()` (returns the Wallet Standard wallet).
|
|
159
|
-
*/
|
|
160
148
|
declare const buildPolkadotWalletStandardAdapter: (wallet: WalletStandardWallet,
|
|
161
149
|
/** Optional. Called with a function that pushes a synthetic
|
|
162
150
|
* `disconnected` event to all current subscribers. The discovery
|
|
163
151
|
* layer invokes it on Wallet Standard `unregister`. */
|
|
164
152
|
registerDisconnector?: (emit: () => void) => void) => WalletAdapter | null;
|
|
165
153
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* as the FALLBACK channel; see `polkadotDiscoverer`. Requires the
|
|
169
|
-
* optional `@wallet-standard/app` peer dep; absent → no-op.
|
|
154
|
+
* The fallback channel; see `polkadotDiscoverer`. Requires the optional
|
|
155
|
+
* `@wallet-standard/app` peer dep and no-ops without it.
|
|
170
156
|
*/
|
|
171
157
|
declare const discoverPolkadotWalletStandardAdapters: (onAdapter: (adapter: WalletAdapter) => void) => (() => void);
|
|
172
158
|
//#endregion
|
|
173
159
|
//#region src/discoverer.d.ts
|
|
174
160
|
/**
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* - FALLBACK is Wallet Standard `polkadot:*`. It defers when the primary
|
|
179
|
-
* channel already produced an adapter for the session
|
|
180
|
-
* (`hasAnyPrimaryAdapter`). Since Wallet Standard support is always
|
|
181
|
-
* additive on Polkadot today (Talisman/SubWallet expose both), the
|
|
182
|
-
* discovery-bus also dedups overlaps and the defer prevents
|
|
183
|
-
* double-listing.
|
|
161
|
+
* Primary is injectedWeb3; Wallet Standard `polkadot:*` is the fallback. Its
|
|
162
|
+
* defer is the only thing preventing double-listing: a wallet on both
|
|
163
|
+
* channels mints two unrelated ids the discovery bus cannot collapse.
|
|
184
164
|
*/
|
|
185
165
|
declare const polkadotDiscoverer: PlatformDiscoverer;
|
|
186
166
|
//#endregion
|
|
187
167
|
//#region src/signer-augmentation.d.ts
|
|
188
168
|
/**
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
* the
|
|
192
|
-
* - injectedWeb3 (primary) → `PolkadotSignerHandle` (`extensionName` +
|
|
193
|
-
* `address` + `extension`). Bridge to polkadot-api via
|
|
194
|
-
* `connectInjectedExtension(extensionName)`.
|
|
195
|
-
* - Wallet Standard (fallback) → the `WalletStandardWallet`, narrowed by
|
|
196
|
-
* the consumer via its `features` map.
|
|
169
|
+
* The `getSigner()` shape depends on the discovery channel: injectedWeb3
|
|
170
|
+
* yields a `PolkadotSignerHandle` to bridge into polkadot-api's
|
|
171
|
+
* `connectInjectedExtension`, Wallet Standard yields the raw wallet.
|
|
197
172
|
*/
|
|
198
173
|
declare module "@usebutr/core" {
|
|
199
174
|
interface SignerForPlatform {
|
|
@@ -201,5 +176,5 @@ declare module "@usebutr/core" {
|
|
|
201
176
|
}
|
|
202
177
|
}
|
|
203
178
|
//#endregion
|
|
204
|
-
export { type InjectedPolkadotDiscoveryOptions, POLKADOT_CHAINS, POLKADOT_CHAINS_LIST, type PolkadotSignMessageFeature, type PolkadotSignMessageInput, type PolkadotSignMessageOutput, type PolkadotSignerHandle, type WalletStandardPolkadotCapabilityInput, buildInjectedPolkadotAdapter, buildPolkadotWalletStandardAdapter, discoverInjectedPolkadotAdapters, discoverPolkadotWalletStandardAdapters, polkadotDiscoverer, resolveInjectedPolkadotCapabilities, resolveWalletStandardPolkadotCapabilities };
|
|
179
|
+
export { type InjectedPolkadotDiscoveryOptions, POLKADOT_CHAINS, POLKADOT_CHAINS_LIST, type PolkadotSignMessageFeature, type PolkadotSignMessageInput, type PolkadotSignMessageOutput, type PolkadotSignerHandle, type WalletStandardPolkadotCapabilityInput, buildInjectedPolkadotAdapter, buildPolkadotWalletStandardAdapter, discoverInjectedPolkadotAdapters, discoverPolkadotWalletStandardAdapters, isPolkadotSignerHandle, polkadotDiscoverer, resolveInjectedPolkadotCapabilities, resolveWalletStandardPolkadotCapabilities };
|
|
205
180
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/chains.ts","../src/capabilities.ts","../src/injected/injected-web3.ts","../src/injected/adapter.ts","../src/injected/index.ts","../src/wallet-standard-types.ts","../src/wallet-standard-adapter.ts","../src/discoverer.ts","../src/signer-augmentation.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/chains.ts","../src/capabilities.ts","../src/injected/injected-web3.ts","../src/injected/adapter.ts","../src/injected/index.ts","../src/wallet-standard-types.ts","../src/wallet-standard-adapter.ts","../src/discoverer.ts","../src/signer-augmentation.ts"],"mappings":";;;cAEM;;aAEF;aACA;aACA;aACA;;;aAGA;aACA;aACA;aACA;;;aAGA;aACA;aACA;aACA;;;aAGA;aACA;aACA;aACA;;;cAIE,sBAAsB,cAAc;;;KCxBrC;EACH;EACA;IACE;IACA;;;;;;;;cASE,2CAA0C;;;;;;cAe1C,4CAAyC,OACtC,0CACN;;;;;;;;;;KC3BE;EACH;EACA;EACA;EACA;;;;KAKG;EACH,WAAW;IACT;IACA;IACA;QACI;IAAU;IAAY;;;;KAIzB;EACH;IACE,WAAW,QAAQ,cAAc;IACjC,aAAa,KAAK,UAAU,cAAc;;EAE5C,QAAQ;;;KAIL;EACH,SAAS,mBAAmB,QAAQ;EACpC;;KAGG;EACH,eAAe,eAAe;;QAGxB;YAEI;IACR,eAAe,eAAe;;;;;;;;;KCvB7B;EACH;EACA,WAAW;EACX;;cAGI,yBAAsB,OAAW,iBAAe,SAAS;;;;;cAuCzD,+BAA4B,uBACX,qBACF,UACT,2BACT;;;KCrCE;;;EAGH,SAAS;;EAET,SAAS;;;;;;;cAUL,mCAAgC,YACxB,SAAS,wBAAsB,UAClC;;;KC9CN;EACH,SAAS;EACT,SAAS;;KAGN;EACH,WAAW;EACX,gBAAgB;;KAGb;EACH,cAAc,OAAO,6BAA6B,QAAQ;EAC1D;;;;cCII,qCAAkC,QAC9B,sBAIe;;;;AAAA,wBAAC,8BACvB;;;;;cAmDG,yCAAsC,YAC9B,SAAS;;;;;;;;cCvEjB,oBAAoB;;;;;;;;;YCCd;IACR,UAAU,uBAAuB"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { buildWalletCapabilities, createWalletStandardCore, discoverWalletStandard, getFeature, slugify } from "@usebutr/wallet-standard-shared";
|
|
2
|
-
import { bytesToHexPrefixed as bytesToHex, hexToBytes, sanitizeIcon } from "@usebutr/core";
|
|
2
|
+
import { bytesToHexPrefixed as bytesToHex, hexToBytes, logWarn, sanitizeIcon } from "@usebutr/core";
|
|
3
3
|
|
|
4
4
|
//#region src/chains.ts
|
|
5
5
|
const POLKADOT_CHAINS = {
|
|
@@ -29,14 +29,18 @@ const POLKADOT_CHAINS = {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
const POLKADOT_CHAINS_LIST = Object.values(POLKADOT_CHAINS);
|
|
32
|
+
const POLKADOT_CHAIN_BY_ID = new Map(POLKADOT_CHAINS_LIST.map((chain) => [chain.id, chain]));
|
|
33
|
+
/** Chains a wallet advertising several networks should resolve to first.
|
|
34
|
+
* Kusama sits alongside Polkadot because it carries real value; Westend
|
|
35
|
+
* and Paseo are faucet testnets and must never win the default. */
|
|
36
|
+
const POLKADOT_MAINNET_IDS = [POLKADOT_CHAINS.polkadot.id, POLKADOT_CHAINS.kusama.id];
|
|
32
37
|
|
|
33
38
|
//#endregion
|
|
34
39
|
//#region src/capabilities.ts
|
|
35
40
|
/**
|
|
36
|
-
* injectedWeb3
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* because injectedWeb3 wallets advertise no chains of their own.
|
|
41
|
+
* injectedWeb3 always exposes `signer.signRaw` and `accounts.subscribe`, so
|
|
42
|
+
* those flags are unconditional. The chain count comes from butr's own
|
|
43
|
+
* registry because injectedWeb3 wallets advertise no chains.
|
|
40
44
|
*/
|
|
41
45
|
const resolveInjectedPolkadotCapabilities = () => buildWalletCapabilities({
|
|
42
46
|
chainCount: POLKADOT_CHAINS_LIST.length,
|
|
@@ -63,13 +67,9 @@ const resolveWalletStandardPolkadotCapabilities = (input) => buildWalletCapabili
|
|
|
63
67
|
//#endregion
|
|
64
68
|
//#region src/no-rpc.ts
|
|
65
69
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* `capabilities.getBalance` / `getTransactionReceipt === false`);
|
|
70
|
-
* transaction submission rejects with a hint to drive polkadot-api via
|
|
71
|
-
* `getSigner()`. Both discovery channels (injectedWeb3 + Wallet Standard)
|
|
72
|
-
* share these so the invariant lives in one place.
|
|
70
|
+
* Building an extrinsic or reading on-chain state both need chain metadata
|
|
71
|
+
* butr doesn't fetch, so it ships no Polkadot RPC. The neutral balance and
|
|
72
|
+
* receipt values are gated behind the matching `capabilities` flags.
|
|
73
73
|
*/
|
|
74
74
|
const POLKADOT_SEND_TX_HINT = "Polkadot sendTx is unsupported: use getSigner() with polkadot-api to build and submit extrinsics";
|
|
75
75
|
const POLKADOT_SEND_TX_TO_CHAIN_HINT = "Polkadot sendTxToChain is unsupported: use getSigner() with polkadot-api to build and submit extrinsics";
|
|
@@ -107,16 +107,11 @@ const readInjectedWindow = (target) => {
|
|
|
107
107
|
//#endregion
|
|
108
108
|
//#region src/injected/adapter.ts
|
|
109
109
|
const DAPP_NAME = "butr";
|
|
110
|
+
const isPolkadotSignerHandle = (value) => "address" in value && typeof value.address === "string" && "extension" in value && typeof value.extension === "object" && value.extension !== null && "extensionName" in value && typeof value.extensionName === "string";
|
|
110
111
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* injected Polkadot channel prefix.
|
|
115
|
-
*
|
|
116
|
-
* This is intentionally NOT the wallet-standard-shared `slugify` helper;
|
|
117
|
-
* that helper embeds the `wallet-standard:` scheme which is wrong for
|
|
118
|
-
* the injected channel. The ID convention for injected adapters is
|
|
119
|
-
* `injected:polkadot:<slug>`.
|
|
112
|
+
* Deliberately not wallet-standard-shared's `slugify`: that helper embeds
|
|
113
|
+
* the `wallet-standard:` scheme, while injected adapter ids follow the
|
|
114
|
+
* `injected:polkadot:<slug>` convention.
|
|
120
115
|
*/
|
|
121
116
|
const toKebab = (name) => name.trim().toLowerCase().replaceAll(new RegExp("[^a-z0-9]+", "gv"), "-").replaceAll(new RegExp("^-|-$", "gv"), "");
|
|
122
117
|
const buildPolkadotAccount = (address, chain) => ({
|
|
@@ -125,36 +120,73 @@ const buildPolkadotAccount = (address, chain) => ({
|
|
|
125
120
|
walletAddress: address
|
|
126
121
|
});
|
|
127
122
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
* `enable()` triggers the authorization prompt, so it runs lazily in
|
|
131
|
-
* `connect()`. Before connect, `getAccount` returns null.
|
|
132
|
-
*
|
|
133
|
-
* `id` is `injected:polkadot:<slug>` so consumers can distinguish the
|
|
134
|
-
* injected channel from the Wallet Standard one in their picker.
|
|
123
|
+
* The provider is not enabled at construction: `enable()` raises the
|
|
124
|
+
* extension's authorization prompt, so it runs lazily in `connect()`.
|
|
135
125
|
*/
|
|
136
126
|
const buildInjectedPolkadotAdapter = (extensionName, displayName, provider) => {
|
|
137
127
|
const capabilities = resolveInjectedPolkadotCapabilities();
|
|
138
|
-
let
|
|
128
|
+
let session = null;
|
|
139
129
|
let chain = POLKADOT_CHAINS.polkadot;
|
|
140
130
|
const listenersSet = /* @__PURE__ */ new Set();
|
|
131
|
+
const emit = (event) => {
|
|
132
|
+
const snapshot = [...listenersSet];
|
|
133
|
+
for (const listener of snapshot) listener(event);
|
|
134
|
+
};
|
|
135
|
+
const emitAccounts = (accounts) => {
|
|
136
|
+
const built = accounts.map((a) => buildPolkadotAccount(a.address, chain));
|
|
137
|
+
const first = built[0];
|
|
138
|
+
if (first !== void 0) emit({
|
|
139
|
+
account: first,
|
|
140
|
+
accounts: built,
|
|
141
|
+
type: "accountChanged"
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
const closeSession = () => {
|
|
145
|
+
session?.unsubscribe?.();
|
|
146
|
+
session = null;
|
|
147
|
+
};
|
|
148
|
+
const handleWalletAccounts = (accounts) => {
|
|
149
|
+
if (accounts.length === 0) {
|
|
150
|
+
closeSession();
|
|
151
|
+
emit({ type: "disconnected" });
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
emitAccounts(accounts);
|
|
155
|
+
};
|
|
156
|
+
const openSession = (injected) => {
|
|
157
|
+
closeSession();
|
|
158
|
+
const opened = {
|
|
159
|
+
injected,
|
|
160
|
+
unsubscribe: null
|
|
161
|
+
};
|
|
162
|
+
session = opened;
|
|
163
|
+
try {
|
|
164
|
+
const unsubscribe = injected.accounts.subscribe?.(handleWalletAccounts);
|
|
165
|
+
if (unsubscribe === void 0) return;
|
|
166
|
+
if (session === opened) opened.unsubscribe = unsubscribe;
|
|
167
|
+
else unsubscribe();
|
|
168
|
+
} catch (error) {
|
|
169
|
+
logWarn(`[butr/polkadot] ${displayName} accounts.subscribe threw:`, error);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
141
172
|
const requireInjected = () => {
|
|
142
|
-
if (
|
|
143
|
-
return injected;
|
|
173
|
+
if (session === null) throw new Error(`Wallet ${displayName} is not connected`);
|
|
174
|
+
return session.injected;
|
|
144
175
|
};
|
|
145
176
|
const firstAddress = async () => {
|
|
146
|
-
if (
|
|
147
|
-
return (await injected.accounts.get())[0]?.address ?? null;
|
|
177
|
+
if (session === null) return null;
|
|
178
|
+
return (await session.injected.accounts.get())[0]?.address ?? null;
|
|
148
179
|
};
|
|
149
180
|
return {
|
|
150
181
|
capabilities,
|
|
151
182
|
chainPlatform: "polkadot",
|
|
152
183
|
async connect() {
|
|
153
|
-
injected = await provider.enable(DAPP_NAME);
|
|
184
|
+
const injected = await provider.enable(DAPP_NAME);
|
|
154
185
|
if ((await injected.accounts.get()).length === 0) throw new Error(`Wallet ${displayName} exposed no accounts`);
|
|
186
|
+
openSession(injected);
|
|
155
187
|
},
|
|
156
188
|
disconnect: () => {
|
|
157
|
-
|
|
189
|
+
closeSession();
|
|
158
190
|
return Promise.resolve();
|
|
159
191
|
},
|
|
160
192
|
async getAccount() {
|
|
@@ -162,8 +194,8 @@ const buildInjectedPolkadotAdapter = (extensionName, displayName, provider) => {
|
|
|
162
194
|
return address === null ? null : buildPolkadotAccount(address, chain);
|
|
163
195
|
},
|
|
164
196
|
async getAccounts() {
|
|
165
|
-
if (
|
|
166
|
-
return (await injected.accounts.get()).map((a) => buildPolkadotAccount(a.address, chain));
|
|
197
|
+
if (session === null) return [];
|
|
198
|
+
return (await session.injected.accounts.get()).map((a) => buildPolkadotAccount(a.address, chain));
|
|
167
199
|
},
|
|
168
200
|
getBalance: noRpcBalance,
|
|
169
201
|
async getSigner() {
|
|
@@ -200,52 +232,37 @@ const buildInjectedPolkadotAdapter = (extensionName, displayName, provider) => {
|
|
|
200
232
|
},
|
|
201
233
|
subscribe(listener) {
|
|
202
234
|
listenersSet.add(listener);
|
|
203
|
-
let unsubWallet = null;
|
|
204
|
-
if (injected?.accounts.subscribe) unsubWallet = injected.accounts.subscribe((accounts) => {
|
|
205
|
-
if (accounts.length === 0) {
|
|
206
|
-
listener({ type: "disconnected" });
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
const built = accounts.map((a) => buildPolkadotAccount(a.address, chain));
|
|
210
|
-
const first = built[0];
|
|
211
|
-
if (first !== void 0) listener({
|
|
212
|
-
account: first,
|
|
213
|
-
accounts: built,
|
|
214
|
-
type: "accountChanged"
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
235
|
return () => {
|
|
218
236
|
listenersSet.delete(listener);
|
|
219
|
-
unsubWallet?.();
|
|
220
237
|
};
|
|
221
238
|
},
|
|
222
|
-
switchChain
|
|
223
|
-
if (target.namespace !== "polkadot")
|
|
224
|
-
chain = target;
|
|
225
|
-
|
|
239
|
+
async switchChain(target) {
|
|
240
|
+
if (target.namespace !== "polkadot") throw new Error(`Polkadot adapter received non-Polkadot chain "${target.id}". Pass a chain with namespace "polkadot".`);
|
|
241
|
+
chain = POLKADOT_CHAIN_BY_ID.get(target.id) ?? target;
|
|
242
|
+
if (session === null) return;
|
|
243
|
+
emitAccounts(await session.injected.accounts.get());
|
|
226
244
|
}
|
|
227
245
|
};
|
|
228
246
|
};
|
|
229
247
|
|
|
230
248
|
//#endregion
|
|
231
249
|
//#region src/injected/index.ts
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
250
|
+
const knownDisplayNameFor = (key) => {
|
|
251
|
+
switch (key) {
|
|
252
|
+
case "enkrypt": return "Enkrypt";
|
|
253
|
+
case "nova-wallet": return "Nova Wallet";
|
|
254
|
+
case "polkadot-js": return "Polkadot{.js}";
|
|
255
|
+
case "subwallet-js": return "SubWallet";
|
|
256
|
+
case "talisman": return "Talisman";
|
|
257
|
+
default: return;
|
|
258
|
+
}
|
|
238
259
|
};
|
|
239
|
-
const displayNameFor = (key) =>
|
|
260
|
+
const displayNameFor = (key) => knownDisplayNameFor(key) ?? key.split(new RegExp("[\\-_]", "v")).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
240
261
|
const DEFAULT_POLLS = [250, 750];
|
|
241
262
|
/**
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
* lazily.
|
|
246
|
-
*
|
|
247
|
-
* Extensions inject at different times during page load, so we read
|
|
248
|
-
* immediately and re-check on a short poll schedule, deduping by key.
|
|
263
|
+
* Adapters are built without calling `enable()`, which would raise the
|
|
264
|
+
* extension's authorization prompt at discovery time. Extensions inject at
|
|
265
|
+
* different points during page load, hence the poll schedule.
|
|
249
266
|
*/
|
|
250
267
|
const discoverInjectedPolkadotAdapters = (onAdapter, options = {}) => {
|
|
251
268
|
const polls = options.pollMs ?? DEFAULT_POLLS;
|
|
@@ -276,14 +293,8 @@ const discoverInjectedPolkadotAdapters = (onAdapter, options = {}) => {
|
|
|
276
293
|
//#endregion
|
|
277
294
|
//#region src/wallet-standard-adapter.ts
|
|
278
295
|
const POLKADOT_PREFIX = "polkadot:";
|
|
296
|
+
const isPolkadotSignMessageFeature = (feature) => "signMessage" in feature && typeof feature.signMessage === "function";
|
|
279
297
|
const slugify$1 = (name) => slugify("polkadot", name);
|
|
280
|
-
/**
|
|
281
|
-
* Adapt a Wallet Standard wallet advertising `polkadot:*` features into a
|
|
282
|
-
* butr `WalletAdapter`. Returns `null` for wallets that don't advertise a
|
|
283
|
-
* polkadot chain or `standard:connect`. butr ships no RPC, so
|
|
284
|
-
* sendTx/getBalance/getTransactionReceipt are placeholders; transaction
|
|
285
|
-
* signing goes through `getSigner()` (returns the Wallet Standard wallet).
|
|
286
|
-
*/
|
|
287
298
|
const buildPolkadotWalletStandardAdapter = (wallet, registerDisconnector) => {
|
|
288
299
|
const core = createWalletStandardCore({
|
|
289
300
|
chainPrefix: POLKADOT_PREFIX,
|
|
@@ -291,13 +302,13 @@ const buildPolkadotWalletStandardAdapter = (wallet, registerDisconnector) => {
|
|
|
291
302
|
label: "Polkadot",
|
|
292
303
|
namespace: "polkadot",
|
|
293
304
|
platform: "Polkadot",
|
|
294
|
-
preferredChainIds:
|
|
305
|
+
preferredChainIds: POLKADOT_MAINNET_IDS,
|
|
295
306
|
registerDisconnector,
|
|
296
307
|
trackChainChanges: false,
|
|
297
308
|
wallet
|
|
298
309
|
});
|
|
299
310
|
if (core === null) return null;
|
|
300
|
-
const signMessage = getFeature(wallet, "polkadot:signMessage");
|
|
311
|
+
const signMessage = getFeature(wallet, "polkadot:signMessage", isPolkadotSignMessageFeature);
|
|
301
312
|
return {
|
|
302
313
|
...core,
|
|
303
314
|
capabilities: resolveWalletStandardPolkadotCapabilities({
|
|
@@ -326,25 +337,17 @@ const buildPolkadotWalletStandardAdapter = (wallet, registerDisconnector) => {
|
|
|
326
337
|
};
|
|
327
338
|
};
|
|
328
339
|
/**
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
* as the FALLBACK channel; see `polkadotDiscoverer`. Requires the
|
|
332
|
-
* optional `@wallet-standard/app` peer dep; absent → no-op.
|
|
340
|
+
* The fallback channel; see `polkadotDiscoverer`. Requires the optional
|
|
341
|
+
* `@wallet-standard/app` peer dep and no-ops without it.
|
|
333
342
|
*/
|
|
334
343
|
const discoverPolkadotWalletStandardAdapters = (onAdapter) => discoverWalletStandard(onAdapter, (wallet, registerDisconnector) => buildPolkadotWalletStandardAdapter(wallet, registerDisconnector));
|
|
335
344
|
|
|
336
345
|
//#endregion
|
|
337
346
|
//#region src/discoverer.ts
|
|
338
347
|
/**
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
* - FALLBACK is Wallet Standard `polkadot:*`. It defers when the primary
|
|
343
|
-
* channel already produced an adapter for the session
|
|
344
|
-
* (`hasAnyPrimaryAdapter`). Since Wallet Standard support is always
|
|
345
|
-
* additive on Polkadot today (Talisman/SubWallet expose both), the
|
|
346
|
-
* discovery-bus also dedups overlaps and the defer prevents
|
|
347
|
-
* double-listing.
|
|
348
|
+
* Primary is injectedWeb3; Wallet Standard `polkadot:*` is the fallback. Its
|
|
349
|
+
* defer is the only thing preventing double-listing: a wallet on both
|
|
350
|
+
* channels mints two unrelated ids the discovery bus cannot collapse.
|
|
348
351
|
*/
|
|
349
352
|
const polkadotDiscoverer = {
|
|
350
353
|
fallback: { subscribe: (onAdapter, opts) => {
|
|
@@ -355,5 +358,5 @@ const polkadotDiscoverer = {
|
|
|
355
358
|
};
|
|
356
359
|
|
|
357
360
|
//#endregion
|
|
358
|
-
export { POLKADOT_CHAINS, POLKADOT_CHAINS_LIST, buildInjectedPolkadotAdapter, buildPolkadotWalletStandardAdapter, discoverInjectedPolkadotAdapters, discoverPolkadotWalletStandardAdapters, polkadotDiscoverer, resolveInjectedPolkadotCapabilities, resolveWalletStandardPolkadotCapabilities };
|
|
361
|
+
export { POLKADOT_CHAINS, POLKADOT_CHAINS_LIST, buildInjectedPolkadotAdapter, buildPolkadotWalletStandardAdapter, discoverInjectedPolkadotAdapters, discoverPolkadotWalletStandardAdapters, isPolkadotSignerHandle, polkadotDiscoverer, resolveInjectedPolkadotCapabilities, resolveWalletStandardPolkadotCapabilities };
|
|
359
362
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["slugify","kitSlugify"],"sources":["../src/chains.ts","../src/capabilities.ts","../src/no-rpc.ts","../src/injected/icon.ts","../src/injected/injected-web3.ts","../src/injected/adapter.ts","../src/injected/index.ts","../src/wallet-standard-adapter.ts","../src/discoverer.ts"],"sourcesContent":["import type { ChainBase } from \"@usebutr/core\";\n\n// CAIP-2 for Polkadot is `polkadot:{first-32-hex-of-genesis-hash}`.\n// injectedWeb3 doesn't advertise chains (accounts are chain-agnostic\n// across Substrate), so this registry is butr-authored. Wallet Standard\n// polkadot wallets advertise these same CAIP-2 ids.\nconst POLKADOT_CHAINS = {\n kusama: {\n id: \"polkadot:b0a8d493285c2df73290dfb7e61f870f\",\n name: \"Kusama\",\n namespace: \"polkadot\",\n reference: \"b0a8d493285c2df73290dfb7e61f870f\",\n },\n paseo: {\n id: \"polkadot:77afd6190f1554ad45fd0d31aee62aac\",\n name: \"Paseo\",\n namespace: \"polkadot\",\n reference: \"77afd6190f1554ad45fd0d31aee62aac\",\n },\n polkadot: {\n id: \"polkadot:91b171bb158e2d3848fa23a9f1c25182\",\n name: \"Polkadot\",\n namespace: \"polkadot\",\n reference: \"91b171bb158e2d3848fa23a9f1c25182\",\n },\n westend: {\n id: \"polkadot:e143f23803ac50e8f6f8e62695d1ce9e\",\n name: \"Westend\",\n namespace: \"polkadot\",\n reference: \"e143f23803ac50e8f6f8e62695d1ce9e\",\n },\n} as const satisfies Record<string, ChainBase>;\n\nconst POLKADOT_CHAINS_LIST: ReadonlyArray<ChainBase> = Object.values(POLKADOT_CHAINS);\n\nexport { POLKADOT_CHAINS, POLKADOT_CHAINS_LIST };\n","import type { WalletCapabilities } from \"@usebutr/core\";\nimport { buildWalletCapabilities } from \"@usebutr/wallet-standard-shared\";\n\nimport { POLKADOT_CHAINS_LIST } from \"./chains\";\n\ntype WalletStandardPolkadotCapabilityInput = {\n chainCount: number;\n features: {\n events: boolean;\n signMessage: boolean;\n };\n};\n\n/**\n * injectedWeb3 capability profile. The injected `signer.signRaw` always\n * supports message signing and `accounts.subscribe` always supports events,\n * so both are unconditional. The chain count comes from butr's own registry\n * because injectedWeb3 wallets advertise no chains of their own.\n */\nconst resolveInjectedPolkadotCapabilities = (): WalletCapabilities =>\n buildWalletCapabilities({\n chainCount: POLKADOT_CHAINS_LIST.length,\n events: true,\n sendTransaction: false,\n signIn: false,\n signMessage: true,\n signTransaction: false,\n });\n\n/**\n * Wallet Standard `polkadot:*` feature → butr capability mapping. No\n * standalone `signTransaction`: building an extrinsic needs chain metadata\n * butr doesn't fetch, so transaction signing goes through `getSigner()`.\n */\nconst resolveWalletStandardPolkadotCapabilities = (\n input: WalletStandardPolkadotCapabilityInput,\n): WalletCapabilities =>\n buildWalletCapabilities({\n chainCount: input.chainCount,\n events: input.features.events,\n sendTransaction: false,\n signIn: false,\n signMessage: input.features.signMessage,\n signTransaction: false,\n });\n\nexport type { WalletStandardPolkadotCapabilityInput };\nexport { resolveInjectedPolkadotCapabilities, resolveWalletStandardPolkadotCapabilities };\n","import type { Balance } from \"@usebutr/core\";\n\n/**\n * butr ships no RPC on Polkadot: building/broadcasting an extrinsic and\n * reading on-chain state both need chain metadata. Balance and receipt\n * reads return neutral placeholders (gated behind\n * `capabilities.getBalance` / `getTransactionReceipt === false`);\n * transaction submission rejects with a hint to drive polkadot-api via\n * `getSigner()`. Both discovery channels (injectedWeb3 + Wallet Standard)\n * share these so the invariant lives in one place.\n */\nconst POLKADOT_SEND_TX_HINT =\n \"Polkadot sendTx is unsupported: use getSigner() with polkadot-api to build and submit extrinsics\";\nconst POLKADOT_SEND_TX_TO_CHAIN_HINT =\n \"Polkadot sendTxToChain is unsupported: use getSigner() with polkadot-api to build and submit extrinsics\";\n\nconst noRpcBalance = (): Promise<Balance> =>\n Promise.resolve({ decimals: 0, formatted: \"0\", symbol: \"\", value: 0n });\n\nconst noRpcTransactionReceipt = (): Promise<{ status: \"Success\" | \"Error\" | \"Pending\" }> =>\n Promise.resolve({ status: \"Pending\" });\n\nconst noRpcSendTx = (): Promise<string> => Promise.reject(new Error(POLKADOT_SEND_TX_HINT));\n\nconst noRpcSendTxToChain = (): Promise<string> =>\n Promise.reject(new Error(POLKADOT_SEND_TX_TO_CHAIN_HINT));\n\nexport { noRpcBalance, noRpcSendTx, noRpcSendTxToChain, noRpcTransactionReceipt };\n","const GENERIC_POLKADOT_ICON =\n \"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+PGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTYiIGZpbGw9IiNFNjAwN0EiLz48L3N2Zz4=\";\n\nexport { GENERIC_POLKADOT_ICON };\n","/**\n * Minimal local types for the `@polkadot/extension-dapp` injectedWeb3\n * standard. Declared here (rather than depending on\n * `@polkadot/extension-inject`) so the connector stays lean; same\n * posture as `@usebutr/bitcoin`'s `UnisatProvider`. These narrow the\n * spec to only the fields butr reads.\n */\n\n/** A single account the extension exposes. Addresses are SS58; accounts\n * are chain-agnostic across Substrate. */\ntype InjectedAccount = {\n address: string;\n genesisHash?: string | null;\n name?: string;\n type?: string;\n};\n\n/** The polkadot-js `Signer`: butr only uses `signRaw` for message\n * signing. `signPayload` is consumer territory (via polkadot-api). */\ntype InjectedSigner = {\n signRaw?: (raw: {\n address: string;\n data: string;\n type: \"bytes\" | \"payload\";\n }) => Promise<{ id: number; signature: string }>;\n};\n\n/** The object returned by `enable()`. */\ntype Injected = {\n accounts: {\n get: () => Promise<ReadonlyArray<InjectedAccount>>;\n subscribe?: (cb: (accounts: ReadonlyArray<InjectedAccount>) => void) => () => void;\n };\n signer: InjectedSigner;\n};\n\n/** What lives at `window.injectedWeb3[key]`. */\ntype InjectedWindowProvider = {\n enable: (origin: string) => Promise<Injected>;\n version?: string;\n};\n\ntype InjectedWindow = {\n injectedWeb3?: Record<string, InjectedWindowProvider>;\n};\n\nconst BYTES_PREFIX = new TextEncoder().encode(\"<Bytes>\");\nconst BYTES_SUFFIX = new TextEncoder().encode(\"</Bytes>\");\n\nconst wrapBytes = (message: Uint8Array): Uint8Array => {\n const out = new Uint8Array(BYTES_PREFIX.length + message.length + BYTES_SUFFIX.length);\n out.set(BYTES_PREFIX, 0);\n out.set(message, BYTES_PREFIX.length);\n out.set(BYTES_SUFFIX, BYTES_PREFIX.length + message.length);\n return out;\n};\n\nconst readInjectedWindow = (target?: InjectedWindow | null): InjectedWindow | null => {\n if (target !== undefined) {\n return target;\n }\n if (typeof window === \"undefined\") {\n return null;\n }\n // `window.injectedWeb3` is the untyped Polkadot extension registry; the\n // DOM lib doesn't declare it, so this boundary assertion is unavoidable.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- untyped window.injectedWeb3 extension registry\n return window as unknown as InjectedWindow;\n};\n\nexport type { Injected, InjectedAccount, InjectedSigner, InjectedWindow, InjectedWindowProvider };\nexport { bytesToHexPrefixed as bytesToHex, hexToBytes } from \"@usebutr/core\";\nexport { readInjectedWindow, wrapBytes };\n","import type {\n Account,\n ChainBase,\n ConnectorEvent,\n PolkadotAdapter,\n WalletCapabilities,\n} from \"@usebutr/core\";\nimport { sanitizeIcon } from \"@usebutr/core\";\n\nimport { resolveInjectedPolkadotCapabilities } from \"../capabilities\";\nimport { POLKADOT_CHAINS } from \"../chains\";\nimport { noRpcBalance, noRpcSendTx, noRpcSendTxToChain, noRpcTransactionReceipt } from \"../no-rpc\";\n\nimport { GENERIC_POLKADOT_ICON } from \"./icon\";\nimport type { Injected, InjectedWindowProvider } from \"./injected-web3\";\nimport { bytesToHex, hexToBytes, wrapBytes } from \"./injected-web3\";\n\nconst DAPP_NAME = \"butr\";\n\n/** Handle returned by `getSigner()`. Carries the `window.injectedWeb3`\n * key (`extensionName`) so consumers can bridge to polkadot-api's\n * `connectInjectedExtension`, the active SS58 address, and the raw\n * `Injected` object for direct `signer` access. */\ntype PolkadotSignerHandle = {\n address: string;\n extension: Injected;\n extensionName: string;\n};\n\n/**\n * Convert a wallet display name into a stable kebab-case slug for the\n * injected adapter id. Strips anything that isn't a lowercase letter or\n * digit (turning \"Polkadot{.js}\" → \"polkadot-js\"), then prepends the\n * injected Polkadot channel prefix.\n *\n * This is intentionally NOT the wallet-standard-shared `slugify` helper;\n * that helper embeds the `wallet-standard:` scheme which is wrong for\n * the injected channel. The ID convention for injected adapters is\n * `injected:polkadot:<slug>`.\n */\nconst toKebab = (name: string): string =>\n name\n .trim()\n .toLowerCase()\n .replaceAll(/[^a-z0-9]+/gv, \"-\")\n .replaceAll(/^-|-$/gv, \"\");\n\nconst buildPolkadotAccount = (address: string, chain: ChainBase): Account => ({\n chain,\n id: `${chain.id}:${address}`,\n walletAddress: address,\n});\n\n/**\n * Wrap a `window.injectedWeb3[name]` provider into a butr\n * `PolkadotAdapter`. The provider is NOT enabled at construction;\n * `enable()` triggers the authorization prompt, so it runs lazily in\n * `connect()`. Before connect, `getAccount` returns null.\n *\n * `id` is `injected:polkadot:<slug>` so consumers can distinguish the\n * injected channel from the Wallet Standard one in their picker.\n */\nconst buildInjectedPolkadotAdapter = (\n extensionName: string,\n displayName: string,\n provider: InjectedWindowProvider,\n): PolkadotAdapter => {\n const capabilities: WalletCapabilities = resolveInjectedPolkadotCapabilities();\n let injected: Injected | null = null;\n let chain: ChainBase = POLKADOT_CHAINS.polkadot;\n const listenersSet = new Set<(event: ConnectorEvent) => void>();\n\n const requireInjected = (): Injected => {\n if (injected === null) {\n throw new Error(`Wallet ${displayName} is not connected`);\n }\n return injected;\n };\n\n const firstAddress = async (): Promise<string | null> => {\n if (injected === null) {\n return null;\n }\n const accounts = await injected.accounts.get();\n return accounts[0]?.address ?? null;\n };\n\n return {\n capabilities,\n chainPlatform: \"polkadot\",\n\n async connect() {\n injected = await provider.enable(DAPP_NAME);\n const accounts = await injected.accounts.get();\n if (accounts.length === 0) {\n throw new Error(`Wallet ${displayName} exposed no accounts`);\n }\n },\n\n disconnect: () => {\n injected = null;\n return Promise.resolve();\n },\n\n async getAccount() {\n const address = await firstAddress();\n return address === null ? null : buildPolkadotAccount(address, chain);\n },\n\n async getAccounts() {\n if (injected === null) {\n return [];\n }\n const accounts = await injected.accounts.get();\n return accounts.map((a) => buildPolkadotAccount(a.address, chain));\n },\n\n getBalance: noRpcBalance,\n\n async getSigner() {\n const ext = requireInjected();\n const address = await firstAddress();\n if (address === null) {\n throw new Error(\"No connected account\");\n }\n const handle: PolkadotSignerHandle = { address, extension: ext, extensionName };\n return handle;\n },\n\n getTransactionReceipt: noRpcTransactionReceipt,\n\n icon: sanitizeIcon(GENERIC_POLKADOT_ICON),\n id: `injected:polkadot:${toKebab(extensionName)}`,\n name: displayName,\n\n sendTx: noRpcSendTx,\n\n sendTxToChain: noRpcSendTxToChain,\n\n async signMessage(msg, account) {\n const ext = requireInjected();\n if (ext.signer.signRaw === undefined) {\n throw new Error(`Wallet ${displayName} does not expose signRaw`);\n }\n const address = account?.walletAddress ?? (await firstAddress());\n if (address === null || address === \"\") {\n throw new Error(\"No connected account\");\n }\n const wrapped = wrapBytes(msg);\n const result = await ext.signer.signRaw({\n address,\n data: bytesToHex(wrapped),\n type: \"bytes\",\n });\n return { signature: hexToBytes(result.signature), signedMessage: wrapped };\n },\n\n subscribe(listener) {\n listenersSet.add(listener);\n let unsubWallet: (() => void) | null = null;\n if (injected?.accounts.subscribe) {\n unsubWallet = injected.accounts.subscribe((accounts) => {\n if (accounts.length === 0) {\n listener({ type: \"disconnected\" });\n return;\n }\n const built = accounts.map((a) => buildPolkadotAccount(a.address, chain));\n const first = built[0];\n if (first !== undefined) {\n listener({ account: first, accounts: built, type: \"accountChanged\" });\n }\n });\n }\n return () => {\n listenersSet.delete(listener);\n unsubWallet?.();\n };\n },\n\n switchChain: (target) => {\n if (target.namespace !== \"polkadot\") {\n return Promise.reject(\n new Error(\n `Polkadot adapter received non-Polkadot chain \"${target.id}\". Pass a chain with namespace \"polkadot\".`,\n ),\n );\n }\n chain = target;\n return Promise.resolve();\n },\n };\n};\n\nexport type { PolkadotSignerHandle };\nexport { buildInjectedPolkadotAdapter };\n","import type { WalletAdapter } from \"@usebutr/core\";\n\nimport { buildInjectedPolkadotAdapter } from \"./adapter\";\nimport type { InjectedWindow } from \"./injected-web3\";\nimport { readInjectedWindow } from \"./injected-web3\";\n\nconst KNOWN_NAMES: Readonly<Record<string, string>> = {\n enkrypt: \"Enkrypt\",\n \"nova-wallet\": \"Nova Wallet\",\n \"polkadot-js\": \"Polkadot{.js}\",\n \"subwallet-js\": \"SubWallet\",\n talisman: \"Talisman\",\n};\n\nconst displayNameFor = (key: string): string =>\n KNOWN_NAMES[key] ??\n key\n .split(/[\\-_]/v)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \");\n\ntype InjectedPolkadotDiscoveryOptions = {\n /** Poll schedule (ms offsets) for late-injecting extensions. Defaults\n * to a few short polls; pass `[]` in tests for a single sync read. */\n pollMs?: ReadonlyArray<number>;\n /** Override the global host (tests, iframes). */\n target?: InjectedWindow | null;\n};\n\nconst DEFAULT_POLLS: ReadonlyArray<number> = [250, 750];\n\n/**\n * Primary Polkadot discovery: enumerate `window.injectedWeb3` keys and\n * emit one `PolkadotAdapter` per extension. Adapters are built WITHOUT\n * calling `enable()` (no prompt at discovery time); `connect()` enables\n * lazily.\n *\n * Extensions inject at different times during page load, so we read\n * immediately and re-check on a short poll schedule, deduping by key.\n */\nconst discoverInjectedPolkadotAdapters = (\n onAdapter: (adapter: WalletAdapter) => void,\n options: InjectedPolkadotDiscoveryOptions = {},\n): (() => void) => {\n const polls = options.pollMs ?? DEFAULT_POLLS;\n const seen = new Set<string>();\n const timers: Array<ReturnType<typeof setTimeout>> = [];\n let cancelled = false;\n\n const scan = () => {\n if (cancelled) {\n return;\n }\n const host = readInjectedWindow(options.target);\n const registry = host?.injectedWeb3;\n if (!registry) {\n return;\n }\n for (const [key, provider] of Object.entries(registry)) {\n if (seen.has(key)) {\n continue;\n }\n seen.add(key);\n onAdapter(buildInjectedPolkadotAdapter(key, displayNameFor(key), provider));\n }\n };\n\n // Always do one synchronous read so tests (and fast extensions) don't\n // wait for a timer.\n scan();\n for (const offset of polls) {\n if (offset === 0) {\n continue;\n }\n timers.push(setTimeout(scan, offset));\n }\n\n return () => {\n cancelled = true;\n for (const timer of timers) {\n clearTimeout(timer);\n }\n };\n};\n\nexport type { InjectedPolkadotDiscoveryOptions };\nexport { discoverInjectedPolkadotAdapters };\n","import type { WalletAdapter } from \"@usebutr/core\";\nimport {\n createWalletStandardCore,\n discoverWalletStandard,\n getFeature,\n slugify as kitSlugify,\n} from \"@usebutr/wallet-standard-shared\";\nimport type { WalletStandardWallet } from \"@usebutr/wallet-standard-shared\";\n\nimport { resolveWalletStandardPolkadotCapabilities } from \"./capabilities\";\nimport { noRpcBalance, noRpcSendTx, noRpcSendTxToChain, noRpcTransactionReceipt } from \"./no-rpc\";\nimport type { PolkadotSignMessageFeature } from \"./wallet-standard-types\";\n\nconst POLKADOT_PREFIX = \"polkadot:\";\n\nconst slugify = (name: string): string => kitSlugify(\"polkadot\", name);\n\n/**\n * Adapt a Wallet Standard wallet advertising `polkadot:*` features into a\n * butr `WalletAdapter`. Returns `null` for wallets that don't advertise a\n * polkadot chain or `standard:connect`. butr ships no RPC, so\n * sendTx/getBalance/getTransactionReceipt are placeholders; transaction\n * signing goes through `getSigner()` (returns the Wallet Standard wallet).\n */\nconst buildPolkadotWalletStandardAdapter = (\n wallet: WalletStandardWallet,\n /** Optional. Called with a function that pushes a synthetic\n * `disconnected` event to all current subscribers. The discovery\n * layer invokes it on Wallet Standard `unregister`. */\n registerDisconnector?: (emit: () => void) => void,\n): WalletAdapter | null => {\n const core = createWalletStandardCore({\n chainPrefix: POLKADOT_PREFIX,\n id: slugify(wallet.name),\n label: \"Polkadot\",\n namespace: \"polkadot\",\n platform: \"Polkadot\",\n preferredChainIds: [],\n registerDisconnector,\n // Polkadot wallets advertise a single relay chain, so a wallet-side\n // `chains` change has no better chain to move to.\n trackChainChanges: false,\n wallet,\n });\n if (core === null) {\n return null;\n }\n\n const signMessage = getFeature<PolkadotSignMessageFeature>(wallet, \"polkadot:signMessage\");\n\n return {\n ...core,\n capabilities: resolveWalletStandardPolkadotCapabilities({\n chainCount: core.chainCount,\n features: { events: core.hasEvents, signMessage: Boolean(signMessage) },\n }),\n chainPlatform: \"polkadot\",\n\n getBalance: noRpcBalance,\n\n getTransactionReceipt: noRpcTransactionReceipt,\n\n sendTx: noRpcSendTx,\n\n sendTxToChain: noRpcSendTxToChain,\n\n async signMessage(msg, account) {\n if (signMessage === undefined) {\n throw new Error(`Wallet ${wallet.name} does not advertise polkadot:signMessage`);\n }\n const output = await signMessage.signMessage({\n account: core.resolveAccount(account),\n message: msg,\n });\n return { signature: output.signature, signedMessage: output.signedMessage ?? msg };\n },\n };\n};\n\n/**\n * Subscribe to Wallet Standard announcements and emit adapters for\n * wallets advertising `polkadot:*` features (Talisman, SubWallet). Used\n * as the FALLBACK channel; see `polkadotDiscoverer`. Requires the\n * optional `@wallet-standard/app` peer dep; absent → no-op.\n */\nconst discoverPolkadotWalletStandardAdapters = (\n onAdapter: (adapter: WalletAdapter) => void,\n): (() => void) =>\n discoverWalletStandard(onAdapter, (wallet, registerDisconnector) =>\n buildPolkadotWalletStandardAdapter(wallet, registerDisconnector),\n );\n\nexport { buildPolkadotWalletStandardAdapter, discoverPolkadotWalletStandardAdapters };\n","import type { PlatformDiscoverer } from \"@usebutr/core\";\n\nimport { discoverInjectedPolkadotAdapters } from \"./injected\";\nimport { discoverPolkadotWalletStandardAdapters } from \"./wallet-standard-adapter\";\n\n/**\n * Polkadot's `PlatformDiscoverer`. Inverts the Bitcoin layout:\n * - PRIMARY (`subscribe`) is injectedWeb3; the dominant, broadest\n * Polkadot standard (polkadot-js, Talisman, SubWallet, Nova, Enkrypt).\n * - FALLBACK is Wallet Standard `polkadot:*`. It defers when the primary\n * channel already produced an adapter for the session\n * (`hasAnyPrimaryAdapter`). Since Wallet Standard support is always\n * additive on Polkadot today (Talisman/SubWallet expose both), the\n * discovery-bus also dedups overlaps and the defer prevents\n * double-listing.\n */\nconst polkadotDiscoverer: PlatformDiscoverer = {\n fallback: {\n subscribe: (onAdapter, opts) => {\n // Defer entirely when injected discovery has already surfaced a\n // wallet; no Polkadot wallet is Wallet-Standard-only today.\n if (opts.hasAnyPrimaryAdapter()) {\n return () => undefined;\n }\n return discoverPolkadotWalletStandardAdapters(onAdapter);\n },\n },\n subscribe: discoverInjectedPolkadotAdapters,\n};\n\nexport { polkadotDiscoverer };\n"],"mappings":";;;;AAMA,MAAM,kBAAkB;CACtB,QAAQ;EACN,IAAI;EACJ,MAAM;EACN,WAAW;EACX,WAAW;CACb;CACA,OAAO;EACL,IAAI;EACJ,MAAM;EACN,WAAW;EACX,WAAW;CACb;CACA,UAAU;EACR,IAAI;EACJ,MAAM;EACN,WAAW;EACX,WAAW;CACb;CACA,SAAS;EACP,IAAI;EACJ,MAAM;EACN,WAAW;EACX,WAAW;CACb;AACF;AAEA,MAAM,uBAAiD,OAAO,OAAO,eAAe;;;;;;;;;;ACdpF,MAAM,4CACJ,wBAAwB;CACtB,YAAY,qBAAqB;CACjC,QAAQ;CACR,iBAAiB;CACjB,QAAQ;CACR,aAAa;CACb,iBAAiB;AACnB,CAAC;;;;;;AAOH,MAAM,6CACJ,UAEA,wBAAwB;CACtB,YAAY,MAAM;CAClB,QAAQ,MA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,gBAAgB,QAClB,MAAM,IAAI,MAAM,UAAU,OAAO,KAAK,yCAAyC;GAEjF,MAAM,SAAS,MAAM,YAAY,YAAY;IAC3C,SAAS,KAAK,eAAe,OAAO;IACpC,SAAS;GACX,CAAC;GACD,OAAO;IAAE,WAAW,OAAO;IAAW,eAAe,OAAO,iBAAiB;GAAI;EACnF;CACF;AACF;;;;;;;AAQA,MAAM,0CACJ,cAEA,uBAAuB,YAAY,QAAQ,yBACzC,mCAAmC,QAAQ,oBAAoB,CACjE;;;;;;;;;;;;;;;AC1EF,MAAM,qBAAyC;CAC7C,UAAU,EACR,YAAY,WAAW,SAAS;EAG9B,IAAI,KAAK,qBAAqB,GAC5B,aAAa;EAEf,OAAO,uCAAuC,SAAS;CACzD,EACF;CACA,WAAW;AACb"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["slugify","kitSlugify"],"sources":["../src/chains.ts","../src/capabilities.ts","../src/no-rpc.ts","../src/injected/icon.ts","../src/injected/injected-web3.ts","../src/injected/adapter.ts","../src/injected/index.ts","../src/wallet-standard-adapter.ts","../src/discoverer.ts"],"sourcesContent":["import type { ChainBase } from \"@usebutr/core\";\n\nconst POLKADOT_CHAINS = {\n kusama: {\n id: \"polkadot:b0a8d493285c2df73290dfb7e61f870f\",\n name: \"Kusama\",\n namespace: \"polkadot\",\n reference: \"b0a8d493285c2df73290dfb7e61f870f\",\n },\n paseo: {\n id: \"polkadot:77afd6190f1554ad45fd0d31aee62aac\",\n name: \"Paseo\",\n namespace: \"polkadot\",\n reference: \"77afd6190f1554ad45fd0d31aee62aac\",\n },\n polkadot: {\n id: \"polkadot:91b171bb158e2d3848fa23a9f1c25182\",\n name: \"Polkadot\",\n namespace: \"polkadot\",\n reference: \"91b171bb158e2d3848fa23a9f1c25182\",\n },\n westend: {\n id: \"polkadot:e143f23803ac50e8f6f8e62695d1ce9e\",\n name: \"Westend\",\n namespace: \"polkadot\",\n reference: \"e143f23803ac50e8f6f8e62695d1ce9e\",\n },\n} as const satisfies Record<string, ChainBase>;\n\nconst POLKADOT_CHAINS_LIST: ReadonlyArray<ChainBase> = Object.values(POLKADOT_CHAINS);\n\nconst POLKADOT_CHAIN_BY_ID: ReadonlyMap<string, ChainBase> = new Map(\n POLKADOT_CHAINS_LIST.map((chain) => [chain.id, chain]),\n);\n\n/** Chains a wallet advertising several networks should resolve to first.\n * Kusama sits alongside Polkadot because it carries real value; Westend\n * and Paseo are faucet testnets and must never win the default. */\nconst POLKADOT_MAINNET_IDS: ReadonlyArray<string> = [\n POLKADOT_CHAINS.polkadot.id,\n POLKADOT_CHAINS.kusama.id,\n];\n\nexport { POLKADOT_CHAIN_BY_ID, POLKADOT_CHAINS, POLKADOT_CHAINS_LIST, POLKADOT_MAINNET_IDS };\n","import type { WalletCapabilities } from \"@usebutr/core\";\nimport { buildWalletCapabilities } from \"@usebutr/wallet-standard-shared\";\n\nimport { POLKADOT_CHAINS_LIST } from \"./chains\";\n\ntype WalletStandardPolkadotCapabilityInput = {\n chainCount: number;\n features: {\n events: boolean;\n signMessage: boolean;\n };\n};\n\n/**\n * injectedWeb3 always exposes `signer.signRaw` and `accounts.subscribe`, so\n * those flags are unconditional. The chain count comes from butr's own\n * registry because injectedWeb3 wallets advertise no chains.\n */\nconst resolveInjectedPolkadotCapabilities = (): WalletCapabilities =>\n buildWalletCapabilities({\n chainCount: POLKADOT_CHAINS_LIST.length,\n events: true,\n sendTransaction: false,\n signIn: false,\n signMessage: true,\n signTransaction: false,\n });\n\n/**\n * Wallet Standard `polkadot:*` feature → butr capability mapping. No\n * standalone `signTransaction`: building an extrinsic needs chain metadata\n * butr doesn't fetch, so transaction signing goes through `getSigner()`.\n */\nconst resolveWalletStandardPolkadotCapabilities = (\n input: WalletStandardPolkadotCapabilityInput,\n): WalletCapabilities =>\n buildWalletCapabilities({\n chainCount: input.chainCount,\n events: input.features.events,\n sendTransaction: false,\n signIn: false,\n signMessage: input.features.signMessage,\n signTransaction: false,\n });\n\nexport type { WalletStandardPolkadotCapabilityInput };\nexport { resolveInjectedPolkadotCapabilities, resolveWalletStandardPolkadotCapabilities };\n","import type { Balance } from \"@usebutr/core\";\n\n/**\n * Building an extrinsic or reading on-chain state both need chain metadata\n * butr doesn't fetch, so it ships no Polkadot RPC. The neutral balance and\n * receipt values are gated behind the matching `capabilities` flags.\n */\nconst POLKADOT_SEND_TX_HINT =\n \"Polkadot sendTx is unsupported: use getSigner() with polkadot-api to build and submit extrinsics\";\nconst POLKADOT_SEND_TX_TO_CHAIN_HINT =\n \"Polkadot sendTxToChain is unsupported: use getSigner() with polkadot-api to build and submit extrinsics\";\n\nconst noRpcBalance = (): Promise<Balance> =>\n Promise.resolve({ decimals: 0, formatted: \"0\", symbol: \"\", value: 0n });\n\nconst noRpcTransactionReceipt = (): Promise<{ status: \"Success\" | \"Error\" | \"Pending\" }> =>\n Promise.resolve({ status: \"Pending\" });\n\nconst noRpcSendTx = (): Promise<string> => Promise.reject(new Error(POLKADOT_SEND_TX_HINT));\n\nconst noRpcSendTxToChain = (): Promise<string> =>\n Promise.reject(new Error(POLKADOT_SEND_TX_TO_CHAIN_HINT));\n\nexport { noRpcBalance, noRpcSendTx, noRpcSendTxToChain, noRpcTransactionReceipt };\n","const GENERIC_POLKADOT_ICON =\n \"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+PGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTYiIGZpbGw9IiNFNjAwN0EiLz48L3N2Zz4=\";\n\nexport { GENERIC_POLKADOT_ICON };\n","/**\n * Local narrowing of the `@polkadot/extension-dapp` injectedWeb3 standard\n * to the fields butr reads, so the connector takes no dependency on\n * `@polkadot/extension-inject`.\n */\n\n/** A single account the extension exposes. Addresses are SS58; accounts\n * are chain-agnostic across Substrate. */\ntype InjectedAccount = {\n address: string;\n genesisHash?: string | null;\n name?: string;\n type?: string;\n};\n\n/** The polkadot-js `Signer`: butr only uses `signRaw` for message\n * signing. `signPayload` is consumer territory (via polkadot-api). */\ntype InjectedSigner = {\n signRaw?: (raw: {\n address: string;\n data: string;\n type: \"bytes\" | \"payload\";\n }) => Promise<{ id: number; signature: string }>;\n};\n\n/** The object returned by `enable()`. */\ntype Injected = {\n accounts: {\n get: () => Promise<ReadonlyArray<InjectedAccount>>;\n subscribe?: (cb: (accounts: ReadonlyArray<InjectedAccount>) => void) => () => void;\n };\n signer: InjectedSigner;\n};\n\n/** What lives at `window.injectedWeb3[key]`. */\ntype InjectedWindowProvider = {\n enable: (origin: string) => Promise<Injected>;\n version?: string;\n};\n\ntype InjectedWindow = {\n injectedWeb3?: Record<string, InjectedWindowProvider>;\n};\n\ndeclare global {\n // oxlint-disable-next-line typescript/consistent-type-definitions -- DOM globals require interface merging.\n interface Window {\n injectedWeb3?: Record<string, InjectedWindowProvider>;\n }\n}\n\nconst BYTES_PREFIX = new TextEncoder().encode(\"<Bytes>\");\nconst BYTES_SUFFIX = new TextEncoder().encode(\"</Bytes>\");\n\nconst wrapBytes = (message: Uint8Array): Uint8Array => {\n const out = new Uint8Array(BYTES_PREFIX.length + message.length + BYTES_SUFFIX.length);\n out.set(BYTES_PREFIX, 0);\n out.set(message, BYTES_PREFIX.length);\n out.set(BYTES_SUFFIX, BYTES_PREFIX.length + message.length);\n return out;\n};\n\nconst readInjectedWindow = (target?: InjectedWindow | null): InjectedWindow | null => {\n if (target !== undefined) {\n return target;\n }\n if (typeof window === \"undefined\") {\n return null;\n }\n return window;\n};\n\nexport type { Injected, InjectedAccount, InjectedSigner, InjectedWindow, InjectedWindowProvider };\nexport { bytesToHexPrefixed as bytesToHex, hexToBytes } from \"@usebutr/core\";\nexport { readInjectedWindow, wrapBytes };\n","import type {\n Account,\n ChainBase,\n ConnectorEvent,\n PolkadotAdapter,\n WalletCapabilities,\n WalletSigner,\n} from \"@usebutr/core\";\nimport { logWarn, sanitizeIcon } from \"@usebutr/core\";\n\nimport { resolveInjectedPolkadotCapabilities } from \"../capabilities\";\nimport { POLKADOT_CHAIN_BY_ID, POLKADOT_CHAINS } from \"../chains\";\nimport { noRpcBalance, noRpcSendTx, noRpcSendTxToChain, noRpcTransactionReceipt } from \"../no-rpc\";\n\nimport { GENERIC_POLKADOT_ICON } from \"./icon\";\nimport type { Injected, InjectedAccount, InjectedWindowProvider } from \"./injected-web3\";\nimport { bytesToHex, hexToBytes, wrapBytes } from \"./injected-web3\";\n\nconst DAPP_NAME = \"butr\";\n\n/** Handle returned by `getSigner()`. Carries the `window.injectedWeb3`\n * key (`extensionName`) so consumers can bridge to polkadot-api's\n * `connectInjectedExtension`, the active SS58 address, and the raw\n * `Injected` object for direct `signer` access. */\ntype PolkadotSignerHandle = {\n address: string;\n extension: Injected;\n extensionName: string;\n};\n\nconst isPolkadotSignerHandle = (value: WalletSigner): value is PolkadotSignerHandle =>\n \"address\" in value &&\n typeof value.address === \"string\" &&\n \"extension\" in value &&\n typeof value.extension === \"object\" &&\n value.extension !== null &&\n \"extensionName\" in value &&\n typeof value.extensionName === \"string\";\n\n/**\n * Deliberately not wallet-standard-shared's `slugify`: that helper embeds\n * the `wallet-standard:` scheme, while injected adapter ids follow the\n * `injected:polkadot:<slug>` convention.\n */\nconst toKebab = (name: string): string =>\n name\n .trim()\n .toLowerCase()\n .replaceAll(/[^a-z0-9]+/gv, \"-\")\n .replaceAll(/^-|-$/gv, \"\");\n\nconst buildPolkadotAccount = (address: string, chain: ChainBase): Account => ({\n chain,\n id: `${chain.id}:${address}`,\n walletAddress: address,\n});\n\n/** Everything that only exists between `connect()` and `disconnect()`: the\n * enabled provider and the wallet-side account subscription opened against\n * it. One value so the adapter can never be half-connected. */\ntype InjectedSession = {\n injected: Injected;\n unsubscribe: (() => void) | null;\n};\n\n/**\n * The provider is not enabled at construction: `enable()` raises the\n * extension's authorization prompt, so it runs lazily in `connect()`.\n */\nconst buildInjectedPolkadotAdapter = (\n extensionName: string,\n displayName: string,\n provider: InjectedWindowProvider,\n): PolkadotAdapter => {\n const capabilities: WalletCapabilities = resolveInjectedPolkadotCapabilities();\n let session: InjectedSession | null = null;\n let chain: ChainBase = POLKADOT_CHAINS.polkadot;\n const listenersSet = new Set<(event: ConnectorEvent) => void>();\n\n const emit = (event: ConnectorEvent): void => {\n const snapshot = [...listenersSet];\n for (const listener of snapshot) {\n listener(event);\n }\n };\n\n const emitAccounts = (accounts: ReadonlyArray<InjectedAccount>): void => {\n const built = accounts.map((a) => buildPolkadotAccount(a.address, chain));\n const first = built[0];\n if (first !== undefined) {\n emit({ account: first, accounts: built, type: \"accountChanged\" });\n }\n };\n\n const closeSession = (): void => {\n session?.unsubscribe?.();\n session = null;\n };\n\n const handleWalletAccounts = (accounts: ReadonlyArray<InjectedAccount>): void => {\n if (accounts.length === 0) {\n closeSession();\n emit({ type: \"disconnected\" });\n return;\n }\n emitAccounts(accounts);\n };\n\n const openSession = (injected: Injected): void => {\n closeSession();\n const opened: InjectedSession = { injected, unsubscribe: null };\n session = opened;\n try {\n const unsubscribe = injected.accounts.subscribe?.(handleWalletAccounts);\n if (unsubscribe === undefined) {\n return;\n }\n // Wallets may fire the callback synchronously; an empty first payload\n // closes the session before this assignment, so never revive it.\n if (session === opened) {\n opened.unsubscribe = unsubscribe;\n } else {\n unsubscribe();\n }\n } catch (error) {\n logWarn(`[butr/polkadot] ${displayName} accounts.subscribe threw:`, error);\n }\n };\n\n const requireInjected = (): Injected => {\n if (session === null) {\n throw new Error(`Wallet ${displayName} is not connected`);\n }\n return session.injected;\n };\n\n const firstAddress = async (): Promise<string | null> => {\n if (session === null) {\n return null;\n }\n const accounts = await session.injected.accounts.get();\n return accounts[0]?.address ?? null;\n };\n\n return {\n capabilities,\n chainPlatform: \"polkadot\",\n\n async connect() {\n const injected = await provider.enable(DAPP_NAME);\n const accounts = await injected.accounts.get();\n if (accounts.length === 0) {\n throw new Error(`Wallet ${displayName} exposed no accounts`);\n }\n openSession(injected);\n },\n\n disconnect: () => {\n closeSession();\n return Promise.resolve();\n },\n\n async getAccount() {\n const address = await firstAddress();\n return address === null ? null : buildPolkadotAccount(address, chain);\n },\n\n async getAccounts() {\n if (session === null) {\n return [];\n }\n const accounts = await session.injected.accounts.get();\n return accounts.map((a) => buildPolkadotAccount(a.address, chain));\n },\n\n getBalance: noRpcBalance,\n\n async getSigner() {\n const ext = requireInjected();\n const address = await firstAddress();\n if (address === null) {\n throw new Error(\"No connected account\");\n }\n const handle: PolkadotSignerHandle = { address, extension: ext, extensionName };\n return handle;\n },\n\n getTransactionReceipt: noRpcTransactionReceipt,\n\n icon: sanitizeIcon(GENERIC_POLKADOT_ICON),\n id: `injected:polkadot:${toKebab(extensionName)}`,\n name: displayName,\n\n sendTx: noRpcSendTx,\n\n sendTxToChain: noRpcSendTxToChain,\n\n async signMessage(msg, account) {\n const ext = requireInjected();\n if (ext.signer.signRaw === undefined) {\n throw new Error(`Wallet ${displayName} does not expose signRaw`);\n }\n const address = account?.walletAddress ?? (await firstAddress());\n if (address === null || address === \"\") {\n throw new Error(\"No connected account\");\n }\n const wrapped = wrapBytes(msg);\n const result = await ext.signer.signRaw({\n address,\n data: bytesToHex(wrapped),\n type: \"bytes\",\n });\n return { signature: hexToBytes(result.signature), signedMessage: wrapped };\n },\n\n subscribe(listener) {\n listenersSet.add(listener);\n return () => {\n listenersSet.delete(listener);\n };\n },\n\n async switchChain(target) {\n if (target.namespace !== \"polkadot\") {\n throw new Error(\n `Polkadot adapter received non-Polkadot chain \"${target.id}\". Pass a chain with namespace \"polkadot\".`,\n );\n }\n chain = POLKADOT_CHAIN_BY_ID.get(target.id) ?? target;\n if (session === null) {\n return;\n }\n emitAccounts(await session.injected.accounts.get());\n },\n };\n};\n\nexport type { PolkadotSignerHandle };\nexport { buildInjectedPolkadotAdapter, isPolkadotSignerHandle };\n","import type { WalletAdapter } from \"@usebutr/core\";\n\nimport { buildInjectedPolkadotAdapter } from \"./adapter\";\nimport type { InjectedWindow } from \"./injected-web3\";\nimport { readInjectedWindow } from \"./injected-web3\";\n\nconst knownDisplayNameFor = (key: string): string | undefined => {\n switch (key) {\n case \"enkrypt\": {\n return \"Enkrypt\";\n }\n case \"nova-wallet\": {\n return \"Nova Wallet\";\n }\n case \"polkadot-js\": {\n return \"Polkadot{.js}\";\n }\n case \"subwallet-js\": {\n return \"SubWallet\";\n }\n case \"talisman\": {\n return \"Talisman\";\n }\n default: {\n return undefined;\n }\n }\n};\n\nconst displayNameFor = (key: string): string =>\n knownDisplayNameFor(key) ??\n key\n .split(/[\\-_]/v)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \");\n\ntype InjectedPolkadotDiscoveryOptions = {\n /** Poll schedule (ms offsets) for late-injecting extensions. Defaults\n * to a few short polls; pass `[]` in tests for a single sync read. */\n pollMs?: ReadonlyArray<number>;\n /** Override the global host (tests, iframes). */\n target?: InjectedWindow | null;\n};\n\nconst DEFAULT_POLLS: ReadonlyArray<number> = [250, 750];\n\n/**\n * Adapters are built without calling `enable()`, which would raise the\n * extension's authorization prompt at discovery time. Extensions inject at\n * different points during page load, hence the poll schedule.\n */\nconst discoverInjectedPolkadotAdapters = (\n onAdapter: (adapter: WalletAdapter) => void,\n options: InjectedPolkadotDiscoveryOptions = {},\n): (() => void) => {\n const polls = options.pollMs ?? DEFAULT_POLLS;\n const seen = new Set<string>();\n const timers: Array<ReturnType<typeof setTimeout>> = [];\n let cancelled = false;\n\n const scan = () => {\n if (cancelled) {\n return;\n }\n const host = readInjectedWindow(options.target);\n const registry = host?.injectedWeb3;\n if (!registry) {\n return;\n }\n for (const [key, provider] of Object.entries(registry)) {\n if (seen.has(key)) {\n continue;\n }\n seen.add(key);\n onAdapter(buildInjectedPolkadotAdapter(key, displayNameFor(key), provider));\n }\n };\n\n scan();\n for (const offset of polls) {\n if (offset === 0) {\n continue;\n }\n timers.push(setTimeout(scan, offset));\n }\n\n return () => {\n cancelled = true;\n for (const timer of timers) {\n clearTimeout(timer);\n }\n };\n};\n\nexport type { InjectedPolkadotDiscoveryOptions };\nexport { discoverInjectedPolkadotAdapters };\n","import type { WalletAdapter } from \"@usebutr/core\";\nimport {\n createWalletStandardCore,\n discoverWalletStandard,\n getFeature,\n slugify as kitSlugify,\n} from \"@usebutr/wallet-standard-shared\";\nimport type { WalletStandardFeature, WalletStandardWallet } from \"@usebutr/wallet-standard-shared\";\n\nimport { resolveWalletStandardPolkadotCapabilities } from \"./capabilities\";\nimport { POLKADOT_MAINNET_IDS } from \"./chains\";\nimport { noRpcBalance, noRpcSendTx, noRpcSendTxToChain, noRpcTransactionReceipt } from \"./no-rpc\";\nimport type { PolkadotSignMessageFeature } from \"./wallet-standard-types\";\n\nconst POLKADOT_PREFIX = \"polkadot:\";\n\nconst isPolkadotSignMessageFeature = (\n feature: WalletStandardFeature,\n): feature is WalletStandardFeature & PolkadotSignMessageFeature =>\n \"signMessage\" in feature && typeof feature.signMessage === \"function\";\n\nconst slugify = (name: string): string => kitSlugify(\"polkadot\", name);\n\nconst buildPolkadotWalletStandardAdapter = (\n wallet: WalletStandardWallet,\n /** Optional. Called with a function that pushes a synthetic\n * `disconnected` event to all current subscribers. The discovery\n * layer invokes it on Wallet Standard `unregister`. */\n registerDisconnector?: (emit: () => void) => void,\n): WalletAdapter | null => {\n const core = createWalletStandardCore({\n chainPrefix: POLKADOT_PREFIX,\n id: slugify(wallet.name),\n label: \"Polkadot\",\n namespace: \"polkadot\",\n platform: \"Polkadot\",\n preferredChainIds: POLKADOT_MAINNET_IDS,\n registerDisconnector,\n trackChainChanges: false,\n wallet,\n });\n if (core === null) {\n return null;\n }\n\n const signMessage = getFeature(wallet, \"polkadot:signMessage\", isPolkadotSignMessageFeature);\n\n return {\n ...core,\n capabilities: resolveWalletStandardPolkadotCapabilities({\n chainCount: core.chainCount,\n features: { events: core.hasEvents, signMessage: Boolean(signMessage) },\n }),\n chainPlatform: \"polkadot\",\n\n getBalance: noRpcBalance,\n\n getTransactionReceipt: noRpcTransactionReceipt,\n\n sendTx: noRpcSendTx,\n\n sendTxToChain: noRpcSendTxToChain,\n\n async signMessage(msg, account) {\n if (signMessage === undefined) {\n throw new Error(`Wallet ${wallet.name} does not advertise polkadot:signMessage`);\n }\n const output = await signMessage.signMessage({\n account: core.resolveAccount(account),\n message: msg,\n });\n return { signature: output.signature, signedMessage: output.signedMessage ?? msg };\n },\n };\n};\n\n/**\n * The fallback channel; see `polkadotDiscoverer`. Requires the optional\n * `@wallet-standard/app` peer dep and no-ops without it.\n */\nconst discoverPolkadotWalletStandardAdapters = (\n onAdapter: (adapter: WalletAdapter) => void,\n): (() => void) =>\n discoverWalletStandard(onAdapter, (wallet, registerDisconnector) =>\n buildPolkadotWalletStandardAdapter(wallet, registerDisconnector),\n );\n\nexport { buildPolkadotWalletStandardAdapter, discoverPolkadotWalletStandardAdapters };\n","import type { PlatformDiscoverer } from \"@usebutr/core\";\n\nimport { discoverInjectedPolkadotAdapters } from \"./injected\";\nimport { discoverPolkadotWalletStandardAdapters } from \"./wallet-standard-adapter\";\n\n/**\n * Primary is injectedWeb3; Wallet Standard `polkadot:*` is the fallback. Its\n * defer is the only thing preventing double-listing: a wallet on both\n * channels mints two unrelated ids the discovery bus cannot collapse.\n */\nconst polkadotDiscoverer: PlatformDiscoverer = {\n fallback: {\n subscribe: (onAdapter, opts) => {\n if (opts.hasAnyPrimaryAdapter()) {\n return () => undefined;\n }\n return discoverPolkadotWalletStandardAdapters(onAdapter);\n },\n },\n subscribe: discoverInjectedPolkadotAdapters,\n};\n\nexport { polkadotDiscoverer };\n"],"mappings":";;;;AAEA,MAAM,kBAAkB;CACtB,QAAQ;EACN,IAAI;EACJ,MAAM;EACN,WAAW;EACX,WAAW;CACb;CACA,OAAO;EACL,IAAI;EACJ,MAAM;EACN,WAAW;EACX,WAAW;CACb;CACA,UAAU;EACR,IAAI;EACJ,MAAM;EACN,WAAW;EACX,WAAW;CACb;CACA,SAAS;EACP,IAAI;EACJ,MAAM;EACN,WAAW;EACX,WAAW;CACb;AACF;AAEA,MAAM,uBAAiD,OAAO,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AC9B,IAAI,gBAAgB,QAClB,MAAM,IAAI,MAAM,UAAU,OAAO,KAAK,yCAAyC;GAEjF,MAAM,SAAS,MAAM,YAAY,YAAY;IAC3C,SAAS,KAAK,eAAe,OAAO;IACpC,SAAS;GACX,CAAC;GACD,OAAO;IAAE,WAAW,OAAO;IAAW,eAAe,OAAO,iBAAiB;GAAI;EACnF;CACF;AACF;;;;;AAMA,MAAM,0CACJ,cAEA,uBAAuB,YAAY,QAAQ,yBACzC,mCAAmC,QAAQ,oBAAoB,CACjE;;;;;;;;;AC3EF,MAAM,qBAAyC;CAC7C,UAAU,EACR,YAAY,WAAW,SAAS;EAC9B,IAAI,KAAK,qBAAqB,GAC5B,aAAa;EAEf,OAAO,uCAAuC,SAAS;CACzD,EACF;CACA,WAAW;AACb"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usebutr/polkadot",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "injectedWeb3 + Wallet Standard adapter for butr (Polkadot/Substrate).",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"butr",
|
|
7
|
+
"dapp",
|
|
8
|
+
"injectedweb3",
|
|
9
|
+
"polkadot",
|
|
10
|
+
"react",
|
|
11
|
+
"substrate",
|
|
12
|
+
"typescript",
|
|
13
|
+
"wallet",
|
|
14
|
+
"web3"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://docs.usebutr.com/api/polkadot",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/pedroapfilho/usebutr/issues"
|
|
19
|
+
},
|
|
5
20
|
"license": "MIT",
|
|
6
21
|
"author": "Pedro Filho <pedro@filho.me>",
|
|
7
22
|
"repository": {
|
|
@@ -10,7 +25,8 @@
|
|
|
10
25
|
"directory": "packages/polkadot"
|
|
11
26
|
},
|
|
12
27
|
"files": [
|
|
13
|
-
"dist"
|
|
28
|
+
"dist",
|
|
29
|
+
"CHANGELOG.md"
|
|
14
30
|
],
|
|
15
31
|
"type": "module",
|
|
16
32
|
"sideEffects": false,
|
|
@@ -25,12 +41,12 @@
|
|
|
25
41
|
"access": "public"
|
|
26
42
|
},
|
|
27
43
|
"dependencies": {
|
|
28
|
-
"@usebutr/core": "
|
|
29
|
-
"@usebutr/wallet-standard-shared": "0.
|
|
44
|
+
"@usebutr/core": "2.0.1",
|
|
45
|
+
"@usebutr/wallet-standard-shared": "1.0.0"
|
|
30
46
|
},
|
|
31
47
|
"devDependencies": {
|
|
32
48
|
"@wallet-standard/app": "^1.1.1",
|
|
33
|
-
"typescript": "^
|
|
49
|
+
"typescript": "^7.0.2",
|
|
34
50
|
"vitest": "^4.1.10",
|
|
35
51
|
"@repo/config-vitest": "0.0.0",
|
|
36
52
|
"@repo/typescript-config": "0.0.0"
|
|
@@ -47,7 +63,6 @@
|
|
|
47
63
|
"build": "tsdown",
|
|
48
64
|
"clean": "rm -rf dist",
|
|
49
65
|
"dev": "tsdown --watch",
|
|
50
|
-
"lint": "oxlint src",
|
|
51
66
|
"test": "vitest run --passWithNoTests",
|
|
52
67
|
"test:coverage": "vitest run --coverage --passWithNoTests",
|
|
53
68
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|