@bestinslot/wallet-kit 0.9.1 → 0.10.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/{balances-B09OW3BF.js → balances-BWhpck6N.js} +23 -23
- package/dist/browser.js +54 -52
- package/dist/core.js +32 -30
- package/dist/{mint-BXVHw4CQ.js → mint-CA_-62SJ.js} +13639 -16512
- package/dist/node.js +881 -1091
- package/dist/react.js +3 -3
- package/dist/{register-browser-providers-CLLT6W6P.js → register-browser-providers-_EU6DoLd.js} +220 -184
- package/dist/types/api/wallet.d.ts +3 -2
- package/dist/types/core/bis.d.ts +2 -1
- package/dist/types/core/providers.d.ts +33 -0
- package/dist/types/provider/api.d.ts +16 -0
- package/dist/types/types/global.d.ts +3 -0
- package/dist/vue.js +4 -4
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WalletInfo } from '../types/wallet';
|
|
2
|
-
export { getAllBalanceDetails, getCardinalBalance, getOrdinalsWallet, getPaymentWallet, getSession, sendBTC, sendInscription, setNetwork, signMessage, signMessageLocalVerify, signMessageLocalVerifyDeterministic, } from '../core/bis';
|
|
3
|
-
export {
|
|
2
|
+
export { getAllBalanceDetails, getCardinalBalance, getOrdinalsWallet, getPaymentWallet, getSession, sendBTC, sendInscription, setNetwork, signMessage, signMessageLocalVerify, signMessageLocalVerifyDeterministic, subscribeToAccountChanges, WalletAccountChangedError, } from '../core/bis';
|
|
3
|
+
export type { AccountChangeEvent } from '../core/bis';
|
|
4
4
|
export type { WalletInfo };
|
|
5
|
+
export { getNetwork } from '../core/store-network';
|
|
5
6
|
export type { BISNetwork, BISSession, BISWallet, BISWalletProvider, BISWalletPurpose, } from '../types/common';
|
|
6
7
|
export type { SendInscriptionResult } from '../types/inscription';
|
package/dist/types/core/bis.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { BISWalletPurpose } from '../types/common';
|
|
|
2
2
|
import { SendInscriptionResult } from '../types/inscription';
|
|
3
3
|
import { WalletInfo } from '../types/wallet';
|
|
4
4
|
export { getAllBalanceDetails, getCardinalBalance } from './helpers';
|
|
5
|
-
export { getOrdinalsWallet, getPaymentWallet, sendBTC, signMessage, signMessageLocalVerify, signMessageLocalVerifyDeterministic, } from './providers';
|
|
5
|
+
export { getOrdinalsWallet, getPaymentWallet, sendBTC, signMessage, signMessageLocalVerify, signMessageLocalVerifyDeterministic, subscribeToAccountChanges, WalletAccountChangedError, } from './providers';
|
|
6
|
+
export type { AccountChangeEvent } from './providers';
|
|
6
7
|
export { getWalletInfo as getSession } from './store';
|
|
7
8
|
export { getNetwork, setNetwork } from './store-network';
|
|
8
9
|
/**
|
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
import { BISProvider, SignFunction } from '../provider/api';
|
|
2
2
|
import { BISSession, BISWallet, BISWalletProvider, BISWalletPurpose } from '../types/common';
|
|
3
|
+
/**
|
|
4
|
+
* Thrown before signing when the account active in the wallet extension differs from the
|
|
5
|
+
* connected session (the user switched accounts inside the wallet after connecting). The stored
|
|
6
|
+
* session is cleared when this is thrown; the app should prompt the user to reconnect.
|
|
7
|
+
*/
|
|
8
|
+
export declare class WalletAccountChangedError extends Error {
|
|
9
|
+
readonly expectedAddress: string;
|
|
10
|
+
readonly accounts: string[];
|
|
11
|
+
readonly code = "WALLET_ACCOUNT_CHANGED";
|
|
12
|
+
/**
|
|
13
|
+
* @param expectedAddress The address of the connected session.
|
|
14
|
+
* @param accounts The addresses the wallet reports as active.
|
|
15
|
+
*/
|
|
16
|
+
constructor(expectedAddress: string, accounts: string[]);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Emitted when the wallet's active account no longer matches the connected session. The stored
|
|
20
|
+
* session has already been cleared when listeners run.
|
|
21
|
+
*/
|
|
22
|
+
export interface AccountChangeEvent {
|
|
23
|
+
provider: BISWalletProvider;
|
|
24
|
+
previousAddresses: string[];
|
|
25
|
+
accounts: string[];
|
|
26
|
+
}
|
|
3
27
|
/**
|
|
4
28
|
* Registry of wallet providers, populated per build via `registerProvider`. The
|
|
5
29
|
* browser build registers the extension wallets; the server build registers only
|
|
@@ -24,6 +48,15 @@ export declare function registerProvider(name: BISWalletProvider, provider: BISP
|
|
|
24
48
|
* @throws An error if the provider is not supported or if there is an error while fetching the wallets, with a message indicating the reason for the failure.
|
|
25
49
|
*/
|
|
26
50
|
export declare function getWallets(provider: BISWalletProvider): Promise<BISSession>;
|
|
51
|
+
/**
|
|
52
|
+
* Subscribes to account switches made inside the connected wallet extension (supported by
|
|
53
|
+
* Unisat and OKX). When the wallet's active account stops matching the session, the kit clears
|
|
54
|
+
* the stored session and calls the listener so the app can prompt a reconnect.
|
|
55
|
+
*
|
|
56
|
+
* @param listener Called with the provider, the session's previous addresses and the wallet's new accounts.
|
|
57
|
+
* @returns An unsubscribe function that removes the listener.
|
|
58
|
+
*/
|
|
59
|
+
export declare function subscribeToAccountChanges(listener: (event: AccountChangeEvent) => void): () => void;
|
|
27
60
|
/**
|
|
28
61
|
* Returns the currently connected ordinals wallet, or undefined if no ordinals wallet is connected. The function retrieves the wallet information from local storage and checks for a wallet with the purpose of 'ordinals'. If such a wallet is found, it is returned; otherwise, the function returns undefined.
|
|
29
62
|
*
|
|
@@ -48,6 +48,22 @@ export interface BISProvider {
|
|
|
48
48
|
* @returns A promise that resolves to an array of BISWallet objects, each representing a wallet associated with the provider. This allows developers to access the wallets available through the provider and perform various operations with them. If there is an error in retrieving the wallets, the promise will be rejected with an appropriate error message.
|
|
49
49
|
*/
|
|
50
50
|
getWallets: () => Promise<BISWallet[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the addresses of the account currently active in the wallet, without prompting the
|
|
53
|
+
* user. Implemented only by providers that expose this silently; the kit compares the result
|
|
54
|
+
* with the stored session before signing to detect an account switch made inside the wallet.
|
|
55
|
+
*
|
|
56
|
+
* @returns The active account's addresses, or an empty array when the wallet cannot tell (e.g. it is locked).
|
|
57
|
+
*/
|
|
58
|
+
getAccounts?: () => Promise<string[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Subscribes to account switches made inside the wallet. Implemented only by providers that
|
|
61
|
+
* emit such an event.
|
|
62
|
+
*
|
|
63
|
+
* @param handler Called with the newly active account's addresses (empty when the wallet cannot tell).
|
|
64
|
+
* @returns An unsubscribe function.
|
|
65
|
+
*/
|
|
66
|
+
onAccountsChanged?: (handler: (accounts: string[]) => void) => () => void;
|
|
51
67
|
/**
|
|
52
68
|
* Signs a message using the provider. The signMessage method takes a message as a string and returns a promise that resolves to the signature of the message as a hexadecimal string. This method allows developers to sign messages using the wallets associated with the provider, enabling functionalities such as authentication or transaction signing. If there is an error in signing the message, the promise will be rejected with an appropriate error message.
|
|
53
69
|
*
|
|
@@ -14,6 +14,9 @@ declare global {
|
|
|
14
14
|
|
|
15
15
|
interface UniSat {
|
|
16
16
|
requestAccounts: () => Promise<string[]>
|
|
17
|
+
getAccounts: () => Promise<string[]>
|
|
18
|
+
on: (event: 'accountsChanged', handler: (accounts: string[]) => void) => void
|
|
19
|
+
removeListener: (event: 'accountsChanged', handler: (accounts: string[]) => void) => void
|
|
17
20
|
getNetwork: () => Promise<'livenet' | 'testnet'>
|
|
18
21
|
switchNetwork: (network: string) => Promise<void>
|
|
19
22
|
signMessage: (message: string, type?: 'ecdsa' | 'bip322-simple') => Promise<string>
|
package/dist/vue.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ref as s, onScopeDispose as i, watch as u } from "vue";
|
|
2
|
-
import { d as r,
|
|
3
|
-
function
|
|
2
|
+
import { d as r, R as c, i as a } from "./mint-CA_-62SJ.js";
|
|
3
|
+
function w() {
|
|
4
4
|
const e = s(r()), t = c((o) => {
|
|
5
5
|
e.value !== o && (e.value = o);
|
|
6
6
|
});
|
|
7
7
|
return i(t, !0), u(e, (o) => {
|
|
8
|
-
o !== r() &&
|
|
8
|
+
o !== r() && a(o);
|
|
9
9
|
}), e;
|
|
10
10
|
}
|
|
11
11
|
export {
|
|
12
|
-
|
|
12
|
+
w as useNetwork
|
|
13
13
|
};
|
package/package.json
CHANGED