@txnlab/use-wallet 2.0.0 → 2.1.1
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/README.md +91 -13
- package/dist/cjs/index.js +57 -27
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/src/clients/daffi/client.d.ts +1 -1
- package/dist/cjs/src/clients/defly/client.d.ts +1 -1
- package/dist/cjs/src/clients/myalgo/client.d.ts +1 -1
- package/dist/cjs/src/clients/pera/client.d.ts +1 -1
- package/dist/cjs/src/clients/walletconnect2/client.d.ts +1 -1
- package/dist/cjs/src/types/providers.d.ts +20 -11
- package/dist/esm/index.js +57 -27
- package/dist/esm/src/clients/daffi/client.d.ts +1 -1
- package/dist/esm/src/clients/defly/client.d.ts +1 -1
- package/dist/esm/src/clients/myalgo/client.d.ts +1 -1
- package/dist/esm/src/clients/pera/client.d.ts +1 -1
- package/dist/esm/src/clients/walletconnect2/client.d.ts +1 -1
- package/dist/esm/src/types/providers.d.ts +20 -11
- package/dist/index.d.ts +24 -15
- package/package.json +8 -2
|
@@ -15,7 +15,7 @@ declare class DaffiWalletClient extends BaseClient {
|
|
|
15
15
|
icon: string;
|
|
16
16
|
isWalletConnect: boolean;
|
|
17
17
|
};
|
|
18
|
-
static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.DAFFI>): Promise<DaffiWalletClient | null>;
|
|
18
|
+
static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.DAFFI>): Promise<DaffiWalletClient | null>;
|
|
19
19
|
connect(onDisconnect: () => void): Promise<Wallet>;
|
|
20
20
|
reconnect(onDisconnect: () => void): Promise<{
|
|
21
21
|
accounts: {
|
|
@@ -15,7 +15,7 @@ declare class DeflyWalletClient extends BaseClient {
|
|
|
15
15
|
icon: string;
|
|
16
16
|
isWalletConnect: boolean;
|
|
17
17
|
};
|
|
18
|
-
static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.DEFLY>): Promise<BaseClient | null>;
|
|
18
|
+
static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.DEFLY>): Promise<BaseClient | null>;
|
|
19
19
|
connect(onDisconnect: () => void): Promise<Wallet>;
|
|
20
20
|
reconnect(onDisconnect: () => void): Promise<{
|
|
21
21
|
accounts: {
|
|
@@ -14,7 +14,7 @@ declare class MyAlgoWalletClient extends BaseClient {
|
|
|
14
14
|
icon: string;
|
|
15
15
|
isWalletConnect: boolean;
|
|
16
16
|
};
|
|
17
|
-
static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.MYALGO>): Promise<BaseClient | null>;
|
|
17
|
+
static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.MYALGO>): Promise<BaseClient | null>;
|
|
18
18
|
connect(): Promise<{
|
|
19
19
|
accounts: {
|
|
20
20
|
providerId: PROVIDER_ID;
|
|
@@ -15,7 +15,7 @@ declare class PeraWalletClient extends BaseClient {
|
|
|
15
15
|
icon: string;
|
|
16
16
|
isWalletConnect: boolean;
|
|
17
17
|
};
|
|
18
|
-
static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.PERA>): Promise<BaseClient | null>;
|
|
18
|
+
static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.PERA>): Promise<BaseClient | null>;
|
|
19
19
|
connect(onDisconnect: () => void): Promise<Wallet>;
|
|
20
20
|
reconnect(onDisconnect: () => void): Promise<{
|
|
21
21
|
accounts: {
|
|
@@ -17,7 +17,7 @@ declare class WalletConnectClient extends BaseClient {
|
|
|
17
17
|
icon: string;
|
|
18
18
|
isWalletConnect: boolean;
|
|
19
19
|
};
|
|
20
|
-
static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.WALLETCONNECT>): Promise<BaseClient | null>;
|
|
20
|
+
static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.WALLETCONNECT>): Promise<BaseClient | null>;
|
|
21
21
|
connect(): Promise<Wallet>;
|
|
22
22
|
reconnect(): Promise<{
|
|
23
23
|
accounts: {
|
|
@@ -18,38 +18,47 @@ export type ProviderConfigMapping = {
|
|
|
18
18
|
[PROVIDER_ID.PERA]: {
|
|
19
19
|
clientOptions?: PeraWalletConnectOptions;
|
|
20
20
|
clientStatic?: typeof PeraWalletConnect;
|
|
21
|
+
getDynamicClient?: () => Promise<typeof PeraWalletConnect>;
|
|
21
22
|
};
|
|
22
23
|
[PROVIDER_ID.DAFFI]: {
|
|
23
24
|
clientOptions?: DaffiWalletConnectOptions;
|
|
24
25
|
clientStatic?: typeof DaffiWalletConnect;
|
|
26
|
+
getDynamicClient?: () => Promise<typeof DaffiWalletConnect>;
|
|
25
27
|
};
|
|
26
28
|
[PROVIDER_ID.DEFLY]: {
|
|
27
29
|
clientOptions?: DeflyWalletConnectOptions;
|
|
28
30
|
clientStatic?: typeof DeflyWalletConnect;
|
|
31
|
+
getDynamicClient?: () => Promise<typeof DeflyWalletConnect>;
|
|
29
32
|
};
|
|
30
33
|
[PROVIDER_ID.WALLETCONNECT]: {
|
|
31
34
|
clientOptions?: WalletConnectModalSignOptions;
|
|
32
35
|
clientStatic?: typeof WalletConnectModalSign;
|
|
36
|
+
getDynamicClient?: () => Promise<typeof WalletConnectModalSign>;
|
|
33
37
|
};
|
|
34
38
|
[PROVIDER_ID.MYALGO]: {
|
|
35
39
|
clientOptions?: MyAlgoConnectOptions;
|
|
36
40
|
clientStatic?: typeof MyAlgoConnect;
|
|
41
|
+
getDynamicClient?: () => Promise<typeof MyAlgoConnect>;
|
|
37
42
|
};
|
|
38
43
|
[PROVIDER_ID.EXODUS]: {
|
|
39
44
|
clientOptions?: ExodusOptions;
|
|
40
45
|
clientStatic?: undefined;
|
|
46
|
+
getDynamicClient?: undefined;
|
|
41
47
|
};
|
|
42
48
|
[PROVIDER_ID.KMD]: {
|
|
43
49
|
clientOptions?: KmdOptions;
|
|
44
50
|
clientStatic?: undefined;
|
|
51
|
+
getDynamicClient?: undefined;
|
|
45
52
|
};
|
|
46
53
|
[PROVIDER_ID.ALGOSIGNER]: {
|
|
47
54
|
clientOptions?: undefined;
|
|
48
55
|
clientStatic?: undefined;
|
|
56
|
+
getDynamicClient?: undefined;
|
|
49
57
|
};
|
|
50
58
|
[PROVIDER_ID.MNEMONIC]: {
|
|
51
59
|
clientOptions?: undefined;
|
|
52
60
|
clientStatic?: undefined;
|
|
61
|
+
getDynamicClient?: undefined;
|
|
53
62
|
};
|
|
54
63
|
};
|
|
55
64
|
/**
|
|
@@ -77,18 +86,18 @@ export type NodeConfig = {
|
|
|
77
86
|
nodePort?: string | number;
|
|
78
87
|
nodeHeaders?: Record<string, string>;
|
|
79
88
|
};
|
|
80
|
-
type
|
|
81
|
-
clientStatic:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
clientStatic
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
type StaticClient<T> = {
|
|
90
|
+
clientStatic: T;
|
|
91
|
+
getDynamicClient?: undefined;
|
|
92
|
+
};
|
|
93
|
+
type DynamicClient<T> = {
|
|
94
|
+
clientStatic?: undefined;
|
|
95
|
+
getDynamicClient: () => Promise<T>;
|
|
96
|
+
};
|
|
97
|
+
type OneOfStaticOrDynamicClient<T> = StaticClient<T> | DynamicClient<T>;
|
|
98
|
+
type ProviderDef = (ProviderConfig<PROVIDER_ID.PERA> & OneOfStaticOrDynamicClient<typeof PeraWalletConnect>) | (ProviderConfig<PROVIDER_ID.DEFLY> & OneOfStaticOrDynamicClient<typeof DeflyWalletConnect>) | (ProviderConfig<PROVIDER_ID.DAFFI> & OneOfStaticOrDynamicClient<typeof DaffiWalletConnect>) | (ProviderConfig<PROVIDER_ID.WALLETCONNECT> & OneOfStaticOrDynamicClient<typeof WalletConnectModalSign> & {
|
|
88
99
|
clientOptions: WalletConnectModalSignOptions;
|
|
89
|
-
}) | (ProviderConfig<PROVIDER_ID.MYALGO> &
|
|
90
|
-
clientStatic: typeof MyAlgoConnect;
|
|
91
|
-
}) | ProviderConfig<PROVIDER_ID.EXODUS> | ProviderConfig<PROVIDER_ID.KMD> | PROVIDER_ID.EXODUS | PROVIDER_ID.KMD | PROVIDER_ID.ALGOSIGNER | PROVIDER_ID.MNEMONIC;
|
|
100
|
+
}) | (ProviderConfig<PROVIDER_ID.MYALGO> & OneOfStaticOrDynamicClient<typeof MyAlgoConnect>) | ProviderConfig<PROVIDER_ID.EXODUS> | ProviderConfig<PROVIDER_ID.KMD> | PROVIDER_ID.EXODUS | PROVIDER_ID.KMD | PROVIDER_ID.ALGOSIGNER | PROVIDER_ID.MNEMONIC;
|
|
92
101
|
export type ProvidersArray = NonEmptyArray<ProviderDef>;
|
|
93
102
|
export type WalletClient = BaseClient;
|
|
94
103
|
export type SupportedProviders = Partial<Record<PROVIDER_ID, WalletClient | null>>;
|
package/dist/esm/index.js
CHANGED
|
@@ -196,7 +196,7 @@ const createStoreImpl = (createState) => {
|
|
|
196
196
|
return () => listeners.delete(listener);
|
|
197
197
|
};
|
|
198
198
|
const destroy = () => {
|
|
199
|
-
if ((import.meta.env
|
|
199
|
+
if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production") {
|
|
200
200
|
console.warn(
|
|
201
201
|
"[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."
|
|
202
202
|
);
|
|
@@ -728,7 +728,7 @@ function useStore(api, selector = api.getState, equalityFn) {
|
|
|
728
728
|
return slice;
|
|
729
729
|
}
|
|
730
730
|
const createImpl = (createState) => {
|
|
731
|
-
if ((import.meta.env
|
|
731
|
+
if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && typeof createState !== "function") {
|
|
732
732
|
console.warn(
|
|
733
733
|
"[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`."
|
|
734
734
|
);
|
|
@@ -771,11 +771,11 @@ const devtoolsImpl = (fn, devtoolsOptions = {}) => (set, get, api) => {
|
|
|
771
771
|
const { enabled, anonymousActionType, store, ...options } = devtoolsOptions;
|
|
772
772
|
let extensionConnector;
|
|
773
773
|
try {
|
|
774
|
-
extensionConnector = (enabled != null ? enabled : (import.meta.env
|
|
774
|
+
extensionConnector = (enabled != null ? enabled : (import.meta.env ? import.meta.env.MODE : void 0) !== "production") && window.__REDUX_DEVTOOLS_EXTENSION__;
|
|
775
775
|
} catch (e) {
|
|
776
776
|
}
|
|
777
777
|
if (!extensionConnector) {
|
|
778
|
-
if ((import.meta.env
|
|
778
|
+
if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && enabled) {
|
|
779
779
|
console.warn(
|
|
780
780
|
"[zustand devtools middleware] Please install/enable Redux devtools extension"
|
|
781
781
|
);
|
|
@@ -829,7 +829,7 @@ const devtoolsImpl = (fn, devtoolsOptions = {}) => (set, get, api) => {
|
|
|
829
829
|
let didWarnAboutReservedActionType = false;
|
|
830
830
|
const originalDispatch = api.dispatch;
|
|
831
831
|
api.dispatch = (...a) => {
|
|
832
|
-
if ((import.meta.env
|
|
832
|
+
if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && a[0].type === "__setState" && !didWarnAboutReservedActionType) {
|
|
833
833
|
console.warn(
|
|
834
834
|
'[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'
|
|
835
835
|
);
|
|
@@ -1274,7 +1274,7 @@ const newImpl = (config, baseOptions) => (set, get, api) => {
|
|
|
1274
1274
|
};
|
|
1275
1275
|
const persistImpl = (config, baseOptions) => {
|
|
1276
1276
|
if ("getStorage" in baseOptions || "serialize" in baseOptions || "deserialize" in baseOptions) {
|
|
1277
|
-
if ((import.meta.env
|
|
1277
|
+
if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production") {
|
|
1278
1278
|
console.warn(
|
|
1279
1279
|
"[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."
|
|
1280
1280
|
);
|
|
@@ -1405,13 +1405,19 @@ class PeraWalletClient extends BaseClient {
|
|
|
1405
1405
|
icon: ICON$8,
|
|
1406
1406
|
isWalletConnect: true
|
|
1407
1407
|
};
|
|
1408
|
-
static async init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network = DEFAULT_NETWORK }) {
|
|
1408
|
+
static async init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network = DEFAULT_NETWORK }) {
|
|
1409
1409
|
try {
|
|
1410
1410
|
debugLog(`${PROVIDER_ID.PERA.toUpperCase()} initializing...`);
|
|
1411
|
-
|
|
1412
|
-
|
|
1411
|
+
let PeraWalletConnect;
|
|
1412
|
+
if (clientStatic) {
|
|
1413
|
+
PeraWalletConnect = clientStatic;
|
|
1414
|
+
}
|
|
1415
|
+
else if (getDynamicClient) {
|
|
1416
|
+
PeraWalletConnect = await getDynamicClient();
|
|
1417
|
+
}
|
|
1418
|
+
else {
|
|
1419
|
+
throw new Error('Pera Wallet provider missing required property: clientStatic or getDynamicClient');
|
|
1413
1420
|
}
|
|
1414
|
-
const PeraWalletConnect = clientStatic;
|
|
1415
1421
|
const algosdk = algosdkStatic || (await Algod.init(algodOptions)).algosdk;
|
|
1416
1422
|
const algodClient = getAlgodClient(algosdk, algodOptions);
|
|
1417
1423
|
const peraWallet = new PeraWalletConnect({
|
|
@@ -1562,13 +1568,19 @@ class DaffiWalletClient extends BaseClient {
|
|
|
1562
1568
|
icon: ICON$7,
|
|
1563
1569
|
isWalletConnect: true
|
|
1564
1570
|
};
|
|
1565
|
-
static async init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network = DEFAULT_NETWORK }) {
|
|
1571
|
+
static async init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network = DEFAULT_NETWORK }) {
|
|
1566
1572
|
try {
|
|
1567
1573
|
debugLog(`${PROVIDER_ID.DAFFI.toUpperCase()} initializing...`);
|
|
1568
|
-
|
|
1569
|
-
|
|
1574
|
+
let DaffiWalletConnect;
|
|
1575
|
+
if (clientStatic) {
|
|
1576
|
+
DaffiWalletConnect = clientStatic;
|
|
1577
|
+
}
|
|
1578
|
+
else if (getDynamicClient) {
|
|
1579
|
+
DaffiWalletConnect = await getDynamicClient();
|
|
1580
|
+
}
|
|
1581
|
+
else {
|
|
1582
|
+
throw new Error('Daffi Wallet provider missing required property: clientStatic or getDynamicClient');
|
|
1570
1583
|
}
|
|
1571
|
-
const DaffiWalletConnect = clientStatic;
|
|
1572
1584
|
const algosdk = algosdkStatic || (await Algod.init(algodOptions)).algosdk;
|
|
1573
1585
|
const algodClient = getAlgodClient(algosdk, algodOptions);
|
|
1574
1586
|
const daffiWallet = new DaffiWalletConnect({
|
|
@@ -1720,13 +1732,19 @@ class MyAlgoWalletClient extends BaseClient {
|
|
|
1720
1732
|
icon: ICON$6,
|
|
1721
1733
|
isWalletConnect: false
|
|
1722
1734
|
};
|
|
1723
|
-
static async init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network = DEFAULT_NETWORK }) {
|
|
1735
|
+
static async init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network = DEFAULT_NETWORK }) {
|
|
1724
1736
|
try {
|
|
1725
1737
|
debugLog(`${PROVIDER_ID.MYALGO.toUpperCase()} initializing...`);
|
|
1726
|
-
|
|
1727
|
-
|
|
1738
|
+
let MyAlgoConnect;
|
|
1739
|
+
if (clientStatic) {
|
|
1740
|
+
MyAlgoConnect = clientStatic;
|
|
1741
|
+
}
|
|
1742
|
+
else if (getDynamicClient) {
|
|
1743
|
+
MyAlgoConnect = await getDynamicClient();
|
|
1744
|
+
}
|
|
1745
|
+
else {
|
|
1746
|
+
throw new Error('MyAlgo Wallet provider missing required property: clientStatic or getDynamicClient');
|
|
1728
1747
|
}
|
|
1729
|
-
const MyAlgoConnect = clientStatic;
|
|
1730
1748
|
const algosdk = algosdkStatic || (await Algod.init(algodOptions)).algosdk;
|
|
1731
1749
|
const algodClient = getAlgodClient(algosdk, algodOptions);
|
|
1732
1750
|
const myAlgo = new MyAlgoConnect({
|
|
@@ -1832,13 +1850,19 @@ class DeflyWalletClient extends BaseClient {
|
|
|
1832
1850
|
icon: ICON$5,
|
|
1833
1851
|
isWalletConnect: true
|
|
1834
1852
|
};
|
|
1835
|
-
static async init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network = DEFAULT_NETWORK }) {
|
|
1853
|
+
static async init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network = DEFAULT_NETWORK }) {
|
|
1836
1854
|
try {
|
|
1837
1855
|
debugLog(`${PROVIDER_ID.DEFLY.toUpperCase()} initializing...`);
|
|
1838
|
-
|
|
1839
|
-
|
|
1856
|
+
let DeflyWalletConnect;
|
|
1857
|
+
if (clientStatic) {
|
|
1858
|
+
DeflyWalletConnect = clientStatic;
|
|
1859
|
+
}
|
|
1860
|
+
else if (getDynamicClient) {
|
|
1861
|
+
DeflyWalletConnect = await getDynamicClient();
|
|
1862
|
+
}
|
|
1863
|
+
else {
|
|
1864
|
+
throw new Error('Defly Wallet provider missing required property: clientStatic or getDynamicClient');
|
|
1840
1865
|
}
|
|
1841
|
-
const DeflyWalletConnect = clientStatic;
|
|
1842
1866
|
const algosdk = algosdkStatic || (await Algod.init(algodOptions)).algosdk;
|
|
1843
1867
|
const algodClient = getAlgodClient(algosdk, algodOptions);
|
|
1844
1868
|
const deflyWallet = new DeflyWalletConnect({
|
|
@@ -2292,11 +2316,18 @@ class WalletConnectClient extends BaseClient {
|
|
|
2292
2316
|
icon: ICON$2,
|
|
2293
2317
|
isWalletConnect: true
|
|
2294
2318
|
};
|
|
2295
|
-
static async init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network = DEFAULT_NETWORK }) {
|
|
2319
|
+
static async init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network = DEFAULT_NETWORK }) {
|
|
2296
2320
|
try {
|
|
2297
2321
|
debugLog(`${PROVIDER_ID.WALLETCONNECT.toUpperCase()} initializing...`);
|
|
2298
|
-
|
|
2299
|
-
|
|
2322
|
+
let Client;
|
|
2323
|
+
if (clientStatic) {
|
|
2324
|
+
Client = clientStatic;
|
|
2325
|
+
}
|
|
2326
|
+
else if (getDynamicClient) {
|
|
2327
|
+
Client = await getDynamicClient();
|
|
2328
|
+
}
|
|
2329
|
+
else {
|
|
2330
|
+
throw new Error('WalletConnect provider missing required property: clientStatic or getDynamicClient');
|
|
2300
2331
|
}
|
|
2301
2332
|
if (!clientOptions) {
|
|
2302
2333
|
throw new Error('WalletConnect provider missing required property: clientOptions');
|
|
@@ -2305,7 +2336,6 @@ class WalletConnectClient extends BaseClient {
|
|
|
2305
2336
|
throw new Error(`WalletConnect only supports Algorand mainnet, testnet, and betanet. "${network}" is not supported.`);
|
|
2306
2337
|
}
|
|
2307
2338
|
const chain = ALGORAND_CHAINS[network];
|
|
2308
|
-
const Client = clientStatic;
|
|
2309
2339
|
// Initialize client
|
|
2310
2340
|
const client = new Client({
|
|
2311
2341
|
...clientOptions,
|
|
@@ -2867,7 +2897,7 @@ function shallow(objA, objB) {
|
|
|
2867
2897
|
return true;
|
|
2868
2898
|
}
|
|
2869
2899
|
var shallow$1 = (objA, objB) => {
|
|
2870
|
-
if ((import.meta.env
|
|
2900
|
+
if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production") {
|
|
2871
2901
|
console.warn(
|
|
2872
2902
|
"[DEPRECATED] Default export is deprecated. Instead use `import { shallow } from 'zustand/shallow'`."
|
|
2873
2903
|
);
|
|
@@ -15,7 +15,7 @@ declare class DaffiWalletClient extends BaseClient {
|
|
|
15
15
|
icon: string;
|
|
16
16
|
isWalletConnect: boolean;
|
|
17
17
|
};
|
|
18
|
-
static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.DAFFI>): Promise<DaffiWalletClient | null>;
|
|
18
|
+
static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.DAFFI>): Promise<DaffiWalletClient | null>;
|
|
19
19
|
connect(onDisconnect: () => void): Promise<Wallet>;
|
|
20
20
|
reconnect(onDisconnect: () => void): Promise<{
|
|
21
21
|
accounts: {
|
|
@@ -15,7 +15,7 @@ declare class DeflyWalletClient extends BaseClient {
|
|
|
15
15
|
icon: string;
|
|
16
16
|
isWalletConnect: boolean;
|
|
17
17
|
};
|
|
18
|
-
static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.DEFLY>): Promise<BaseClient | null>;
|
|
18
|
+
static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.DEFLY>): Promise<BaseClient | null>;
|
|
19
19
|
connect(onDisconnect: () => void): Promise<Wallet>;
|
|
20
20
|
reconnect(onDisconnect: () => void): Promise<{
|
|
21
21
|
accounts: {
|
|
@@ -14,7 +14,7 @@ declare class MyAlgoWalletClient extends BaseClient {
|
|
|
14
14
|
icon: string;
|
|
15
15
|
isWalletConnect: boolean;
|
|
16
16
|
};
|
|
17
|
-
static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.MYALGO>): Promise<BaseClient | null>;
|
|
17
|
+
static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.MYALGO>): Promise<BaseClient | null>;
|
|
18
18
|
connect(): Promise<{
|
|
19
19
|
accounts: {
|
|
20
20
|
providerId: PROVIDER_ID;
|
|
@@ -15,7 +15,7 @@ declare class PeraWalletClient extends BaseClient {
|
|
|
15
15
|
icon: string;
|
|
16
16
|
isWalletConnect: boolean;
|
|
17
17
|
};
|
|
18
|
-
static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.PERA>): Promise<BaseClient | null>;
|
|
18
|
+
static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.PERA>): Promise<BaseClient | null>;
|
|
19
19
|
connect(onDisconnect: () => void): Promise<Wallet>;
|
|
20
20
|
reconnect(onDisconnect: () => void): Promise<{
|
|
21
21
|
accounts: {
|
|
@@ -17,7 +17,7 @@ declare class WalletConnectClient extends BaseClient {
|
|
|
17
17
|
icon: string;
|
|
18
18
|
isWalletConnect: boolean;
|
|
19
19
|
};
|
|
20
|
-
static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.WALLETCONNECT>): Promise<BaseClient | null>;
|
|
20
|
+
static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.WALLETCONNECT>): Promise<BaseClient | null>;
|
|
21
21
|
connect(): Promise<Wallet>;
|
|
22
22
|
reconnect(): Promise<{
|
|
23
23
|
accounts: {
|
|
@@ -18,38 +18,47 @@ export type ProviderConfigMapping = {
|
|
|
18
18
|
[PROVIDER_ID.PERA]: {
|
|
19
19
|
clientOptions?: PeraWalletConnectOptions;
|
|
20
20
|
clientStatic?: typeof PeraWalletConnect;
|
|
21
|
+
getDynamicClient?: () => Promise<typeof PeraWalletConnect>;
|
|
21
22
|
};
|
|
22
23
|
[PROVIDER_ID.DAFFI]: {
|
|
23
24
|
clientOptions?: DaffiWalletConnectOptions;
|
|
24
25
|
clientStatic?: typeof DaffiWalletConnect;
|
|
26
|
+
getDynamicClient?: () => Promise<typeof DaffiWalletConnect>;
|
|
25
27
|
};
|
|
26
28
|
[PROVIDER_ID.DEFLY]: {
|
|
27
29
|
clientOptions?: DeflyWalletConnectOptions;
|
|
28
30
|
clientStatic?: typeof DeflyWalletConnect;
|
|
31
|
+
getDynamicClient?: () => Promise<typeof DeflyWalletConnect>;
|
|
29
32
|
};
|
|
30
33
|
[PROVIDER_ID.WALLETCONNECT]: {
|
|
31
34
|
clientOptions?: WalletConnectModalSignOptions;
|
|
32
35
|
clientStatic?: typeof WalletConnectModalSign;
|
|
36
|
+
getDynamicClient?: () => Promise<typeof WalletConnectModalSign>;
|
|
33
37
|
};
|
|
34
38
|
[PROVIDER_ID.MYALGO]: {
|
|
35
39
|
clientOptions?: MyAlgoConnectOptions;
|
|
36
40
|
clientStatic?: typeof MyAlgoConnect;
|
|
41
|
+
getDynamicClient?: () => Promise<typeof MyAlgoConnect>;
|
|
37
42
|
};
|
|
38
43
|
[PROVIDER_ID.EXODUS]: {
|
|
39
44
|
clientOptions?: ExodusOptions;
|
|
40
45
|
clientStatic?: undefined;
|
|
46
|
+
getDynamicClient?: undefined;
|
|
41
47
|
};
|
|
42
48
|
[PROVIDER_ID.KMD]: {
|
|
43
49
|
clientOptions?: KmdOptions;
|
|
44
50
|
clientStatic?: undefined;
|
|
51
|
+
getDynamicClient?: undefined;
|
|
45
52
|
};
|
|
46
53
|
[PROVIDER_ID.ALGOSIGNER]: {
|
|
47
54
|
clientOptions?: undefined;
|
|
48
55
|
clientStatic?: undefined;
|
|
56
|
+
getDynamicClient?: undefined;
|
|
49
57
|
};
|
|
50
58
|
[PROVIDER_ID.MNEMONIC]: {
|
|
51
59
|
clientOptions?: undefined;
|
|
52
60
|
clientStatic?: undefined;
|
|
61
|
+
getDynamicClient?: undefined;
|
|
53
62
|
};
|
|
54
63
|
};
|
|
55
64
|
/**
|
|
@@ -77,18 +86,18 @@ export type NodeConfig = {
|
|
|
77
86
|
nodePort?: string | number;
|
|
78
87
|
nodeHeaders?: Record<string, string>;
|
|
79
88
|
};
|
|
80
|
-
type
|
|
81
|
-
clientStatic:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
clientStatic
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
type StaticClient<T> = {
|
|
90
|
+
clientStatic: T;
|
|
91
|
+
getDynamicClient?: undefined;
|
|
92
|
+
};
|
|
93
|
+
type DynamicClient<T> = {
|
|
94
|
+
clientStatic?: undefined;
|
|
95
|
+
getDynamicClient: () => Promise<T>;
|
|
96
|
+
};
|
|
97
|
+
type OneOfStaticOrDynamicClient<T> = StaticClient<T> | DynamicClient<T>;
|
|
98
|
+
type ProviderDef = (ProviderConfig<PROVIDER_ID.PERA> & OneOfStaticOrDynamicClient<typeof PeraWalletConnect>) | (ProviderConfig<PROVIDER_ID.DEFLY> & OneOfStaticOrDynamicClient<typeof DeflyWalletConnect>) | (ProviderConfig<PROVIDER_ID.DAFFI> & OneOfStaticOrDynamicClient<typeof DaffiWalletConnect>) | (ProviderConfig<PROVIDER_ID.WALLETCONNECT> & OneOfStaticOrDynamicClient<typeof WalletConnectModalSign> & {
|
|
88
99
|
clientOptions: WalletConnectModalSignOptions;
|
|
89
|
-
}) | (ProviderConfig<PROVIDER_ID.MYALGO> &
|
|
90
|
-
clientStatic: typeof MyAlgoConnect;
|
|
91
|
-
}) | ProviderConfig<PROVIDER_ID.EXODUS> | ProviderConfig<PROVIDER_ID.KMD> | PROVIDER_ID.EXODUS | PROVIDER_ID.KMD | PROVIDER_ID.ALGOSIGNER | PROVIDER_ID.MNEMONIC;
|
|
100
|
+
}) | (ProviderConfig<PROVIDER_ID.MYALGO> & OneOfStaticOrDynamicClient<typeof MyAlgoConnect>) | ProviderConfig<PROVIDER_ID.EXODUS> | ProviderConfig<PROVIDER_ID.KMD> | PROVIDER_ID.EXODUS | PROVIDER_ID.KMD | PROVIDER_ID.ALGOSIGNER | PROVIDER_ID.MNEMONIC;
|
|
92
101
|
export type ProvidersArray = NonEmptyArray<ProviderDef>;
|
|
93
102
|
export type WalletClient = BaseClient;
|
|
94
103
|
export type SupportedProviders = Partial<Record<PROVIDER_ID, WalletClient | null>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -284,38 +284,47 @@ type ProviderConfigMapping = {
|
|
|
284
284
|
[PROVIDER_ID.PERA]: {
|
|
285
285
|
clientOptions?: PeraWalletConnectOptions;
|
|
286
286
|
clientStatic?: typeof PeraWalletConnect;
|
|
287
|
+
getDynamicClient?: () => Promise<typeof PeraWalletConnect>;
|
|
287
288
|
};
|
|
288
289
|
[PROVIDER_ID.DAFFI]: {
|
|
289
290
|
clientOptions?: DaffiWalletConnectOptions;
|
|
290
291
|
clientStatic?: typeof DaffiWalletConnect;
|
|
292
|
+
getDynamicClient?: () => Promise<typeof DaffiWalletConnect>;
|
|
291
293
|
};
|
|
292
294
|
[PROVIDER_ID.DEFLY]: {
|
|
293
295
|
clientOptions?: DeflyWalletConnectOptions;
|
|
294
296
|
clientStatic?: typeof DeflyWalletConnect;
|
|
297
|
+
getDynamicClient?: () => Promise<typeof DeflyWalletConnect>;
|
|
295
298
|
};
|
|
296
299
|
[PROVIDER_ID.WALLETCONNECT]: {
|
|
297
300
|
clientOptions?: WalletConnectModalSignOptions;
|
|
298
301
|
clientStatic?: typeof WalletConnectModalSign;
|
|
302
|
+
getDynamicClient?: () => Promise<typeof WalletConnectModalSign>;
|
|
299
303
|
};
|
|
300
304
|
[PROVIDER_ID.MYALGO]: {
|
|
301
305
|
clientOptions?: MyAlgoConnectOptions;
|
|
302
306
|
clientStatic?: typeof MyAlgoConnect;
|
|
307
|
+
getDynamicClient?: () => Promise<typeof MyAlgoConnect>;
|
|
303
308
|
};
|
|
304
309
|
[PROVIDER_ID.EXODUS]: {
|
|
305
310
|
clientOptions?: ExodusOptions;
|
|
306
311
|
clientStatic?: undefined;
|
|
312
|
+
getDynamicClient?: undefined;
|
|
307
313
|
};
|
|
308
314
|
[PROVIDER_ID.KMD]: {
|
|
309
315
|
clientOptions?: KmdOptions;
|
|
310
316
|
clientStatic?: undefined;
|
|
317
|
+
getDynamicClient?: undefined;
|
|
311
318
|
};
|
|
312
319
|
[PROVIDER_ID.ALGOSIGNER]: {
|
|
313
320
|
clientOptions?: undefined;
|
|
314
321
|
clientStatic?: undefined;
|
|
322
|
+
getDynamicClient?: undefined;
|
|
315
323
|
};
|
|
316
324
|
[PROVIDER_ID.MNEMONIC]: {
|
|
317
325
|
clientOptions?: undefined;
|
|
318
326
|
clientStatic?: undefined;
|
|
327
|
+
getDynamicClient?: undefined;
|
|
319
328
|
};
|
|
320
329
|
};
|
|
321
330
|
/**
|
|
@@ -343,18 +352,18 @@ type NodeConfig = {
|
|
|
343
352
|
nodePort?: string | number;
|
|
344
353
|
nodeHeaders?: Record<string, string>;
|
|
345
354
|
};
|
|
346
|
-
type
|
|
347
|
-
clientStatic:
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
clientStatic
|
|
352
|
-
|
|
353
|
-
|
|
355
|
+
type StaticClient<T> = {
|
|
356
|
+
clientStatic: T;
|
|
357
|
+
getDynamicClient?: undefined;
|
|
358
|
+
};
|
|
359
|
+
type DynamicClient<T> = {
|
|
360
|
+
clientStatic?: undefined;
|
|
361
|
+
getDynamicClient: () => Promise<T>;
|
|
362
|
+
};
|
|
363
|
+
type OneOfStaticOrDynamicClient<T> = StaticClient<T> | DynamicClient<T>;
|
|
364
|
+
type ProviderDef = (ProviderConfig<PROVIDER_ID.PERA> & OneOfStaticOrDynamicClient<typeof PeraWalletConnect>) | (ProviderConfig<PROVIDER_ID.DEFLY> & OneOfStaticOrDynamicClient<typeof DeflyWalletConnect>) | (ProviderConfig<PROVIDER_ID.DAFFI> & OneOfStaticOrDynamicClient<typeof DaffiWalletConnect>) | (ProviderConfig<PROVIDER_ID.WALLETCONNECT> & OneOfStaticOrDynamicClient<typeof WalletConnectModalSign> & {
|
|
354
365
|
clientOptions: WalletConnectModalSignOptions;
|
|
355
|
-
}) | (ProviderConfig<PROVIDER_ID.MYALGO> &
|
|
356
|
-
clientStatic: typeof MyAlgoConnect;
|
|
357
|
-
}) | ProviderConfig<PROVIDER_ID.EXODUS> | ProviderConfig<PROVIDER_ID.KMD> | PROVIDER_ID.EXODUS | PROVIDER_ID.KMD | PROVIDER_ID.ALGOSIGNER | PROVIDER_ID.MNEMONIC;
|
|
366
|
+
}) | (ProviderConfig<PROVIDER_ID.MYALGO> & OneOfStaticOrDynamicClient<typeof MyAlgoConnect>) | ProviderConfig<PROVIDER_ID.EXODUS> | ProviderConfig<PROVIDER_ID.KMD> | PROVIDER_ID.EXODUS | PROVIDER_ID.KMD | PROVIDER_ID.ALGOSIGNER | PROVIDER_ID.MNEMONIC;
|
|
358
367
|
type ProvidersArray = NonEmptyArray<ProviderDef>;
|
|
359
368
|
type WalletClient = BaseClient;
|
|
360
369
|
type SupportedProviders = Partial<Record<PROVIDER_ID, WalletClient | null>>;
|
|
@@ -403,7 +412,7 @@ declare class PeraWalletClient extends BaseClient {
|
|
|
403
412
|
icon: string;
|
|
404
413
|
isWalletConnect: boolean;
|
|
405
414
|
};
|
|
406
|
-
static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.PERA>): Promise<BaseClient | null>;
|
|
415
|
+
static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.PERA>): Promise<BaseClient | null>;
|
|
407
416
|
connect(onDisconnect: () => void): Promise<Wallet>;
|
|
408
417
|
reconnect(onDisconnect: () => void): Promise<{
|
|
409
418
|
accounts: {
|
|
@@ -431,7 +440,7 @@ declare class MyAlgoWalletClient extends BaseClient {
|
|
|
431
440
|
icon: string;
|
|
432
441
|
isWalletConnect: boolean;
|
|
433
442
|
};
|
|
434
|
-
static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.MYALGO>): Promise<BaseClient | null>;
|
|
443
|
+
static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.MYALGO>): Promise<BaseClient | null>;
|
|
435
444
|
connect(): Promise<{
|
|
436
445
|
accounts: {
|
|
437
446
|
providerId: PROVIDER_ID;
|
|
@@ -459,7 +468,7 @@ declare class DeflyWalletClient extends BaseClient {
|
|
|
459
468
|
icon: string;
|
|
460
469
|
isWalletConnect: boolean;
|
|
461
470
|
};
|
|
462
|
-
static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.DEFLY>): Promise<BaseClient | null>;
|
|
471
|
+
static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.DEFLY>): Promise<BaseClient | null>;
|
|
463
472
|
connect(onDisconnect: () => void): Promise<Wallet>;
|
|
464
473
|
reconnect(onDisconnect: () => void): Promise<{
|
|
465
474
|
accounts: {
|
|
@@ -591,7 +600,7 @@ declare class WalletConnectClient extends BaseClient {
|
|
|
591
600
|
icon: string;
|
|
592
601
|
isWalletConnect: boolean;
|
|
593
602
|
};
|
|
594
|
-
static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.WALLETCONNECT>): Promise<BaseClient | null>;
|
|
603
|
+
static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.WALLETCONNECT>): Promise<BaseClient | null>;
|
|
595
604
|
connect(): Promise<Wallet>;
|
|
596
605
|
reconnect(): Promise<{
|
|
597
606
|
accounts: {
|
package/package.json
CHANGED
|
@@ -12,17 +12,21 @@
|
|
|
12
12
|
"url": "https://github.com/txnlab/use-wallet/issues"
|
|
13
13
|
},
|
|
14
14
|
"homepage": "https://txnlab.github.io/use-wallet",
|
|
15
|
-
"version": "2.
|
|
15
|
+
"version": "2.1.1",
|
|
16
16
|
"description": "React hooks for using Algorand compatible wallets in dApps.",
|
|
17
17
|
"scripts": {
|
|
18
18
|
"dev": "yarn storybook",
|
|
19
19
|
"build": "rm -rf dist && rollup -c",
|
|
20
20
|
"test": "jest",
|
|
21
|
+
"lint": "eslint '**/*.{js,ts,tsx}'",
|
|
22
|
+
"format": "prettier --check '**/*.{js,ts,tsx}'",
|
|
21
23
|
"storybook": "start-storybook -p 6006",
|
|
22
24
|
"deploy-storybook": "build-storybook && gh-pages -d storybook-static",
|
|
23
25
|
"build-storybook": "build-storybook",
|
|
24
26
|
"check-types": "tsc --noEmit",
|
|
25
|
-
"commit": "cz"
|
|
27
|
+
"commit": "cz",
|
|
28
|
+
"pre-release": "yarn lint && yarn format && yarn check-types && yarn test && yarn build",
|
|
29
|
+
"release": "release-it"
|
|
26
30
|
},
|
|
27
31
|
"author": "txnlab",
|
|
28
32
|
"license": "MIT",
|
|
@@ -36,6 +40,7 @@
|
|
|
36
40
|
"@mdx-js/react": "^2.3.0",
|
|
37
41
|
"@perawallet/connect": "^1.2.1",
|
|
38
42
|
"@randlabs/myalgo-connect": "^1.4.2",
|
|
43
|
+
"@release-it/conventional-changelog": "^7.0.0",
|
|
39
44
|
"@rollup/plugin-commonjs": "^23.0.2",
|
|
40
45
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
41
46
|
"@storybook/addon-actions": "^6.5.16",
|
|
@@ -73,6 +78,7 @@
|
|
|
73
78
|
"prettier": "2.8.8",
|
|
74
79
|
"react": "^18.2.0",
|
|
75
80
|
"react-dom": "^18.2.0",
|
|
81
|
+
"release-it": "^16.1.0",
|
|
76
82
|
"require-from-string": "^2.0.2",
|
|
77
83
|
"rollup": "^3.3.0",
|
|
78
84
|
"rollup-plugin-analyzer": "^4.0.0",
|