@txnlab/use-wallet 2.0.0-alpha.5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +35 -29
  2. package/dist/cjs/index.js +597 -269
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/jest.config.d.ts +1 -1
  5. package/dist/cjs/src/clients/algosigner/client.d.ts +4 -3
  6. package/dist/cjs/src/clients/algosigner/types.d.ts +12 -12
  7. package/dist/cjs/src/clients/base/base.d.ts +4 -3
  8. package/dist/cjs/src/clients/daffi/client.d.ts +6 -4
  9. package/dist/cjs/src/clients/daffi/types.d.ts +7 -10
  10. package/dist/cjs/src/clients/defly/client.d.ts +6 -5
  11. package/dist/cjs/src/clients/defly/types.d.ts +8 -11
  12. package/dist/cjs/src/clients/exodus/client.d.ts +4 -3
  13. package/dist/cjs/src/clients/exodus/types.d.ts +10 -12
  14. package/dist/cjs/src/clients/kmd/client.d.ts +5 -3
  15. package/dist/cjs/src/clients/kmd/types.d.ts +8 -10
  16. package/dist/cjs/src/clients/mnemonic/client.d.ts +5 -3
  17. package/dist/cjs/src/clients/mnemonic/types.d.ts +7 -7
  18. package/dist/cjs/src/clients/myalgo/client.d.ts +4 -7
  19. package/dist/cjs/src/clients/myalgo/types.d.ts +7 -10
  20. package/dist/cjs/src/clients/pera/client.d.ts +6 -4
  21. package/dist/cjs/src/clients/pera/types.d.ts +7 -10
  22. package/dist/cjs/src/clients/walletconnect2/client.d.ts +7 -5
  23. package/dist/cjs/src/clients/walletconnect2/constants.d.ts +0 -1
  24. package/dist/cjs/src/clients/walletconnect2/types.d.ts +8 -11
  25. package/dist/cjs/src/constants/constants.d.ts +1 -1
  26. package/dist/cjs/src/hooks/useInitializeProviders.d.ts +1 -1
  27. package/dist/cjs/src/index.d.ts +1 -1
  28. package/dist/cjs/src/store/state/debugStore.d.ts +1 -1
  29. package/dist/cjs/src/store/state/walletStore.d.ts +3 -3
  30. package/dist/cjs/src/testUtils/mockClients.d.ts +1 -1
  31. package/dist/cjs/src/types/api.d.ts +3 -3
  32. package/dist/cjs/src/types/node.d.ts +8 -8
  33. package/dist/cjs/src/types/providers.d.ts +27 -15
  34. package/dist/cjs/src/types/utilities.d.ts +1 -1
  35. package/dist/cjs/src/types/wallet.d.ts +9 -12
  36. package/dist/cjs/src/utils/encodeNFDTransactionsArray.d.ts +1 -1
  37. package/dist/cjs/src/utils/reconnectProviders.d.ts +1 -1
  38. package/dist/esm/index.js +597 -269
  39. package/dist/esm/jest.config.d.ts +1 -1
  40. package/dist/esm/src/clients/algosigner/client.d.ts +4 -3
  41. package/dist/esm/src/clients/algosigner/types.d.ts +12 -12
  42. package/dist/esm/src/clients/base/base.d.ts +4 -3
  43. package/dist/esm/src/clients/daffi/client.d.ts +6 -4
  44. package/dist/esm/src/clients/daffi/types.d.ts +7 -10
  45. package/dist/esm/src/clients/defly/client.d.ts +6 -5
  46. package/dist/esm/src/clients/defly/types.d.ts +8 -11
  47. package/dist/esm/src/clients/exodus/client.d.ts +4 -3
  48. package/dist/esm/src/clients/exodus/types.d.ts +10 -12
  49. package/dist/esm/src/clients/kmd/client.d.ts +5 -3
  50. package/dist/esm/src/clients/kmd/types.d.ts +8 -10
  51. package/dist/esm/src/clients/mnemonic/client.d.ts +5 -3
  52. package/dist/esm/src/clients/mnemonic/types.d.ts +7 -7
  53. package/dist/esm/src/clients/myalgo/client.d.ts +4 -7
  54. package/dist/esm/src/clients/myalgo/types.d.ts +7 -10
  55. package/dist/esm/src/clients/pera/client.d.ts +6 -4
  56. package/dist/esm/src/clients/pera/types.d.ts +7 -10
  57. package/dist/esm/src/clients/walletconnect2/client.d.ts +7 -5
  58. package/dist/esm/src/clients/walletconnect2/constants.d.ts +0 -1
  59. package/dist/esm/src/clients/walletconnect2/types.d.ts +8 -11
  60. package/dist/esm/src/constants/constants.d.ts +1 -1
  61. package/dist/esm/src/hooks/useInitializeProviders.d.ts +1 -1
  62. package/dist/esm/src/index.d.ts +1 -1
  63. package/dist/esm/src/store/state/debugStore.d.ts +1 -1
  64. package/dist/esm/src/store/state/walletStore.d.ts +3 -3
  65. package/dist/esm/src/testUtils/mockClients.d.ts +1 -1
  66. package/dist/esm/src/types/api.d.ts +3 -3
  67. package/dist/esm/src/types/node.d.ts +8 -8
  68. package/dist/esm/src/types/providers.d.ts +27 -15
  69. package/dist/esm/src/types/utilities.d.ts +1 -1
  70. package/dist/esm/src/types/wallet.d.ts +9 -12
  71. package/dist/esm/src/utils/encodeNFDTransactionsArray.d.ts +1 -1
  72. package/dist/esm/src/utils/reconnectProviders.d.ts +1 -1
  73. package/dist/index.d.ts +180 -200
  74. package/package.json +16 -20
package/dist/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- import _algosdk from 'algosdk';
1
+ import algosdk from 'algosdk';
2
2
  import { PeraWalletConnect } from '@perawallet/connect';
3
3
  import { DeflyWalletConnect } from '@blockshake/defly-connect';
4
4
  import { DaffiWalletConnect } from '@daffiwallet/connect';
5
5
  import MyAlgoConnect from '@randlabs/myalgo-connect';
6
- import { Web3ModalSignOptions, Web3ModalSign } from '@web3modal/sign-html';
6
+ import { WalletConnectModalSignOptions, WalletConnectModalSign } from '@walletconnect/modal-sign-html';
7
7
  import * as react from 'react';
8
8
  import * as zustand_middleware from 'zustand/middleware';
9
9
  import * as immer_dist_internal from 'immer/dist/internal';
10
10
  import * as zustand from 'zustand';
11
11
 
12
- declare type PublicNetwork = 'betanet' | 'testnet' | 'mainnet';
13
- declare type Network = PublicNetwork | string;
14
- declare type Txn = {
12
+ type PublicNetwork = 'betanet' | 'testnet' | 'mainnet';
13
+ type Network = PublicNetwork | string;
14
+ type Txn = {
15
15
  apaa: Uint8Array;
16
16
  apas: number[];
17
17
  apid: number;
@@ -24,7 +24,7 @@ declare type Txn = {
24
24
  snd: Uint8Array;
25
25
  type: string;
26
26
  };
27
- declare type ConfirmedTxn = {
27
+ type ConfirmedTxn = {
28
28
  'confirmed-round': number;
29
29
  'global-state-delta': Record<string, unknown>[];
30
30
  'pool-error': string;
@@ -33,8 +33,8 @@ declare type ConfirmedTxn = {
33
33
  txn: Txn;
34
34
  };
35
35
  };
36
- declare type TxnType = 'pay' | 'keyreg' | 'acfg' | 'axfer' | 'afrz' | 'appl' | 'stpf';
37
- declare type DecodedTransaction = {
36
+ type TxnType = 'pay' | 'keyreg' | 'acfg' | 'axfer' | 'afrz' | 'appl' | 'stpf';
37
+ type DecodedTransaction = {
38
38
  amt: number;
39
39
  fee: number;
40
40
  fv: number;
@@ -47,14 +47,14 @@ declare type DecodedTransaction = {
47
47
  snd: Uint8Array;
48
48
  type: TxnType;
49
49
  };
50
- declare type DecodedSignedTransaction = {
50
+ type DecodedSignedTransaction = {
51
51
  sig: Uint8Array;
52
52
  txn: DecodedTransaction;
53
53
  };
54
- declare type AlgodClientOptions = ConstructorParameters<typeof _algosdk.Algodv2>;
54
+ type AlgodClientOptions = ConstructorParameters<typeof algosdk.Algodv2>;
55
55
 
56
- declare type TransactionsArray = ['u' | 's', string][];
57
- declare type TxnInfo = {
56
+ type TransactionsArray = ['u' | 's', string][];
57
+ type TxnInfo = {
58
58
  groupIndex: number;
59
59
  amount: number;
60
60
  from: string;
@@ -63,7 +63,7 @@ declare type TxnInfo = {
63
63
  txn: string;
64
64
  signedTxn?: Uint8Array;
65
65
  };
66
- declare type RawTxnResponse = {
66
+ type RawTxnResponse = {
67
67
  txId: string;
68
68
  };
69
69
 
@@ -83,56 +83,13 @@ declare const DEFAULT_NODE_BASEURL = "https://mainnet-api.algonode.cloud";
83
83
  declare const DEFAULT_NODE_TOKEN = "";
84
84
  declare const DEFAULT_NODE_PORT = "";
85
85
 
86
- declare abstract class BaseClient {
87
- algosdk: typeof _algosdk;
88
- algodClient: _algosdk.Algodv2;
89
- clientOptions?: ClientOptions;
90
- keepWCAlive: HTMLAudioElement;
91
- metadata: Metadata;
92
- static metadata: Metadata;
93
- abstract connect(onDisconnect: () => void): Promise<Wallet>;
94
- abstract disconnect(): Promise<void>;
95
- abstract reconnect(onDisconnect: () => void): Promise<Wallet | null>;
96
- abstract signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
97
- protected constructor(metadata: Metadata, algosdk: typeof _algosdk, algodClient: _algosdk.Algodv2, clientOptions?: ClientOptions);
98
- healthCheck(): Promise<{}>;
99
- getAccountInfo(address: string): Promise<AccountInfo>;
100
- getAssets(address: string): Promise<Asset[]>;
101
- waitForConfirmation(txId: string, timeout?: number): Promise<{
102
- 'confirmed-round': number;
103
- 'global-state-delta': Record<string, unknown>[];
104
- 'pool-error': string;
105
- txn: {
106
- sig: Uint8Array;
107
- txn: Txn;
108
- };
109
- txId: string;
110
- }>;
111
- decodeTransaction: (txn: string, isSigned: boolean) => _algosdk.Transaction;
112
- logEncodedTransaction(txn: string, isSigned: boolean): void;
113
- groupTransactionsBySender(transactions: TransactionsArray): Record<string, TxnInfo[]>;
114
- sendRawTransactions(transactions: Uint8Array[], waitRoundsToConfirm?: number): Promise<{
115
- 'confirmed-round': number;
116
- 'global-state-delta': Record<string, unknown>[];
117
- 'pool-error': string;
118
- txn: {
119
- sig: Uint8Array;
120
- txn: Txn;
121
- };
122
- txId: string;
123
- id: string;
124
- }>;
125
- keepWCAliveStart(): Promise<void>;
126
- keepWCAliveStop(): void;
127
- }
128
-
129
86
  interface Account {
130
87
  providerId: PROVIDER_ID;
131
88
  name: string;
132
89
  address: string;
133
90
  authAddr?: string;
134
91
  }
135
- declare type Provider = {
92
+ type Provider = {
136
93
  accounts: Account[];
137
94
  isActive: boolean;
138
95
  isConnected: boolean;
@@ -143,7 +100,7 @@ declare type Provider = {
143
100
  setActiveAccount: (account: string) => void;
144
101
  metadata: Metadata;
145
102
  };
146
- declare type Asset = {
103
+ type Asset = {
147
104
  amount: number;
148
105
  'asset-id': number;
149
106
  creator: string;
@@ -151,54 +108,48 @@ declare type Asset = {
151
108
  'unit-name': string;
152
109
  name: string;
153
110
  };
154
- declare type AccountInfo = {
111
+ type AccountInfo = {
155
112
  address: string;
156
113
  amount: number;
157
114
  'min-balance': number;
158
115
  'auth-addr'?: string;
159
116
  assets?: Asset[];
160
117
  };
161
- declare type WalletProvider = {
118
+ type WalletProvider = {
162
119
  id: PROVIDER_ID;
163
120
  name: string;
164
121
  icon: string;
165
122
  isWalletConnect: boolean;
166
123
  };
167
- declare type ExtendValues<Type> = {
124
+ type ExtendValues<Type> = {
168
125
  [Property in keyof Type]: Type[Property] | null;
169
126
  };
170
- declare type Wallet = ExtendValues<WalletProvider> & {
127
+ type Wallet = ExtendValues<WalletProvider> & {
171
128
  accounts: Account[];
172
129
  };
173
- declare type Metadata = {
130
+ type Metadata = {
174
131
  id: PROVIDER_ID;
175
132
  name: string;
176
133
  icon: string;
177
134
  isWalletConnect: boolean;
178
135
  };
179
- declare type ClientOptions = Record<string, any>;
180
- declare type WalletClient = BaseClient;
181
- declare type SupportedProviders = Partial<Record<PROVIDER_ID, WalletClient | null>>;
136
+ type ClientOptions = Record<string, any>;
182
137
 
183
- declare type PeraWalletConnectOptions = {
138
+ type PeraWalletConnectOptions = {
184
139
  bridge?: string;
185
140
  shouldShowSignTxnToast?: boolean;
186
141
  chainId?: 416001 | 416002 | 416003 | 4160;
187
142
  };
188
- declare type PeraWalletClientConstructor = {
143
+ type PeraWalletClientConstructor = {
189
144
  metadata: Metadata;
190
145
  client: PeraWalletConnect;
191
146
  clientOptions?: PeraWalletConnectOptions;
192
- algosdk: typeof _algosdk;
193
- algodClient: _algosdk.Algodv2;
147
+ algosdk: typeof algosdk;
148
+ algodClient: algosdk.Algodv2;
194
149
  network: Network;
195
150
  };
196
- declare type InitParams$7 = CommonInitParams & {
197
- clientOptions?: PeraWalletConnectOptions;
198
- clientStatic?: typeof PeraWalletConnect;
199
- };
200
151
 
201
- declare type DeflyWalletConnectOptions = {
152
+ type DeflyWalletConnectOptions = {
202
153
  bridge?: string;
203
154
  deep_link?: string;
204
155
  app_meta?: {
@@ -208,24 +159,20 @@ declare type DeflyWalletConnectOptions = {
208
159
  };
209
160
  shouldShowSignTxnToast?: boolean;
210
161
  };
211
- declare type DeflyWalletClientConstructor = {
162
+ type DeflyWalletClientConstructor = {
212
163
  metadata: Metadata;
213
164
  client: DeflyWalletConnect;
214
165
  clientOptions?: DeflyWalletConnectOptions;
215
- algosdk: typeof _algosdk;
216
- algodClient: _algosdk.Algodv2;
166
+ algosdk: typeof algosdk;
167
+ algodClient: algosdk.Algodv2;
217
168
  network: Network;
218
169
  };
219
- declare type InitParams$6 = CommonInitParams & {
220
- clientOptions?: DeflyWalletConnectOptions;
221
- clientStatic?: typeof DeflyWalletConnect;
222
- };
223
170
 
224
- declare type ExodusOptions = {
171
+ type ExodusOptions = {
225
172
  onlyIfTrusted: boolean;
226
173
  };
227
- declare type Bytes = Readonly<Uint8Array>;
228
- declare type Exodus = {
174
+ type Bytes = Readonly<Uint8Array>;
175
+ type Exodus = {
229
176
  isConnected: boolean;
230
177
  address: string | null;
231
178
  connect: ({ onlyIfTrusted }: {
@@ -239,68 +186,101 @@ declare type Exodus = {
239
186
  }>;
240
187
  signTransaction(transactions: Bytes[]): Promise<Bytes[]>;
241
188
  };
242
- declare type ExodusClientConstructor = {
189
+ type ExodusClientConstructor = {
243
190
  metadata: Metadata;
244
191
  client: Exodus;
245
192
  clientOptions: ExodusOptions;
246
- algosdk: typeof _algosdk;
247
- algodClient: _algosdk.Algodv2;
193
+ algosdk: typeof algosdk;
194
+ algodClient: algosdk.Algodv2;
248
195
  network: Network;
249
196
  };
250
- declare type InitParams$5 = CommonInitParams & {
251
- clientOptions?: ExodusOptions;
252
- };
253
197
 
254
- declare type KmdOptions = {
198
+ type KmdOptions = {
255
199
  wallet: string;
256
200
  password: string;
257
201
  host: string;
258
202
  token: string;
259
203
  port: string;
260
204
  };
261
- declare type KMDWalletClientConstructor = {
205
+ type KMDWalletClientConstructor = {
262
206
  metadata: Metadata;
263
- client: _algosdk.Kmd;
264
- algosdk: typeof _algosdk;
265
- algodClient: _algosdk.Algodv2;
207
+ client: algosdk.Kmd;
208
+ algosdk: typeof algosdk;
209
+ algodClient: algosdk.Algodv2;
266
210
  wallet: string;
267
211
  password: string;
268
212
  network: Network;
269
213
  };
270
- declare type InitParams$4 = CommonInitParams & {
271
- clientOptions?: KmdOptions;
272
- };
273
214
 
274
215
  /**
275
216
  * Helpful resources:
276
217
  * https://github.com/randlabs/myalgo-connect
277
218
  */
278
219
 
279
- declare type MyAlgoConnectOptions = {
220
+ type MyAlgoConnectOptions = {
280
221
  disableLedgerNano: boolean;
281
222
  };
282
- declare type MyAlgoWalletClientConstructor = {
223
+ type MyAlgoWalletClientConstructor = {
283
224
  metadata: Metadata;
284
225
  client: MyAlgoConnect;
285
226
  clientOptions?: MyAlgoConnectOptions;
286
- algosdk: typeof _algosdk;
287
- algodClient: _algosdk.Algodv2;
227
+ algosdk: typeof algosdk;
228
+ algodClient: algosdk.Algodv2;
288
229
  network: Network;
289
230
  };
290
- declare type InitParams$3 = CommonInitParams & {
291
- clientOptions?: MyAlgoConnectOptions;
292
- clientStatic?: typeof MyAlgoConnect;
293
- };
294
231
 
295
- declare type DaffiWalletConnectOptions = {
232
+ type DaffiWalletConnectOptions = {
296
233
  bridge?: string;
297
234
  shouldShowSignTxnToast?: boolean;
298
235
  chainId?: 416001 | 416002 | 416003 | 4160;
299
236
  };
300
237
 
301
- declare type NonEmptyArray<T> = [T, ...T[]];
238
+ type NonEmptyArray<T> = [T, ...T[]];
239
+
240
+ declare abstract class BaseClient {
241
+ algosdk: typeof algosdk;
242
+ algodClient: algosdk.Algodv2;
243
+ clientOptions?: ClientOptions;
244
+ keepWCAlive: HTMLAudioElement;
245
+ metadata: Metadata;
246
+ static metadata: Metadata;
247
+ abstract connect(onDisconnect: () => void): Promise<Wallet>;
248
+ abstract disconnect(): Promise<void>;
249
+ abstract reconnect(onDisconnect: () => void): Promise<Wallet | null>;
250
+ abstract signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
251
+ protected constructor(metadata: Metadata, algosdk: typeof algosdk, algodClient: algosdk.Algodv2, clientOptions?: ClientOptions);
252
+ healthCheck(): Promise<{}>;
253
+ getAccountInfo(address: string): Promise<AccountInfo>;
254
+ getAssets(address: string): Promise<Asset[]>;
255
+ waitForConfirmation(txId: string, timeout?: number): Promise<{
256
+ 'confirmed-round': number;
257
+ 'global-state-delta': Record<string, unknown>[];
258
+ 'pool-error': string;
259
+ txn: {
260
+ sig: Uint8Array;
261
+ txn: Txn;
262
+ };
263
+ txId: string;
264
+ }>;
265
+ decodeTransaction: (txn: string, isSigned: boolean) => algosdk.Transaction;
266
+ logEncodedTransaction(txn: string, isSigned: boolean): void;
267
+ groupTransactionsBySender(transactions: TransactionsArray): Record<string, TxnInfo[]>;
268
+ sendRawTransactions(transactions: Uint8Array[], waitRoundsToConfirm?: number): Promise<{
269
+ 'confirmed-round': number;
270
+ 'global-state-delta': Record<string, unknown>[];
271
+ 'pool-error': string;
272
+ txn: {
273
+ sig: Uint8Array;
274
+ txn: Txn;
275
+ };
276
+ txId: string;
277
+ id: string;
278
+ }>;
279
+ keepWCAliveStart(): Promise<void>;
280
+ keepWCAliveStop(): void;
281
+ }
302
282
 
303
- declare type ProviderConfigMapping = {
283
+ type ProviderConfigMapping = {
304
284
  [PROVIDER_ID.PERA]: {
305
285
  clientOptions?: PeraWalletConnectOptions;
306
286
  clientStatic?: typeof PeraWalletConnect;
@@ -314,8 +294,8 @@ declare type ProviderConfigMapping = {
314
294
  clientStatic?: typeof DeflyWalletConnect;
315
295
  };
316
296
  [PROVIDER_ID.WALLETCONNECT]: {
317
- clientOptions?: Web3ModalSignOptions;
318
- clientStatic?: typeof Web3ModalSign;
297
+ clientOptions?: WalletConnectModalSignOptions;
298
+ clientStatic?: typeof WalletConnectModalSign;
319
299
  };
320
300
  [PROVIDER_ID.MYALGO]: {
321
301
  clientOptions?: MyAlgoConnectOptions;
@@ -323,12 +303,20 @@ declare type ProviderConfigMapping = {
323
303
  };
324
304
  [PROVIDER_ID.EXODUS]: {
325
305
  clientOptions?: ExodusOptions;
306
+ clientStatic?: undefined;
326
307
  };
327
308
  [PROVIDER_ID.KMD]: {
328
309
  clientOptions?: KmdOptions;
310
+ clientStatic?: undefined;
311
+ };
312
+ [PROVIDER_ID.ALGOSIGNER]: {
313
+ clientOptions?: undefined;
314
+ clientStatic?: undefined;
315
+ };
316
+ [PROVIDER_ID.MNEMONIC]: {
317
+ clientOptions?: undefined;
318
+ clientStatic?: undefined;
329
319
  };
330
- [PROVIDER_ID.ALGOSIGNER]: Record<string, never>;
331
- [PROVIDER_ID.MNEMONIC]: Record<string, never>;
332
320
  };
333
321
  /**
334
322
  * Enforces correct configuration given for each provider. For example,
@@ -337,80 +325,46 @@ declare type ProviderConfigMapping = {
337
325
  *
338
326
  * @todo install `tsd` to test TypeScript type definitions in CI
339
327
  */
340
- declare type ProviderConfig<T extends keyof ProviderConfigMapping> = {
328
+ type ProviderConfig<T extends keyof ProviderConfigMapping> = {
341
329
  [K in T]: {
342
330
  id: K;
343
331
  } & ProviderConfigMapping[K];
344
332
  }[T];
345
- declare type CommonInitParams = {
333
+ type CommonInitParams = {
346
334
  network?: Network;
347
335
  algodOptions?: AlgodClientOptions;
348
- algosdkStatic?: typeof _algosdk;
336
+ algosdkStatic?: typeof algosdk;
349
337
  };
350
- declare type NodeConfig = {
338
+ type InitParams<T extends keyof ProviderConfigMapping> = CommonInitParams & ProviderConfigMapping[T];
339
+ type NodeConfig = {
351
340
  network: Network;
352
341
  nodeServer: string;
353
- nodeToken?: string;
342
+ nodeToken?: string | algosdk.AlgodTokenHeader | algosdk.CustomTokenHeader | algosdk.BaseHTTPClient;
354
343
  nodePort?: string | number;
355
344
  nodeHeaders?: Record<string, string>;
356
345
  };
357
- declare type ProviderDef = (ProviderConfig<PROVIDER_ID.PERA> & {
346
+ type ProviderDef = (ProviderConfig<PROVIDER_ID.PERA> & {
358
347
  clientStatic: typeof PeraWalletConnect;
359
348
  }) | (ProviderConfig<PROVIDER_ID.DEFLY> & {
360
349
  clientStatic: typeof DeflyWalletConnect;
361
350
  }) | (ProviderConfig<PROVIDER_ID.DAFFI> & {
362
351
  clientStatic: typeof DaffiWalletConnect;
363
352
  }) | (ProviderConfig<PROVIDER_ID.WALLETCONNECT> & {
364
- clientStatic: typeof Web3ModalSign;
365
- clientOptions: Web3ModalSignOptions;
353
+ clientStatic: typeof WalletConnectModalSign;
354
+ clientOptions: WalletConnectModalSignOptions;
366
355
  }) | (ProviderConfig<PROVIDER_ID.MYALGO> & {
367
356
  clientStatic: typeof MyAlgoConnect;
368
357
  }) | ProviderConfig<PROVIDER_ID.EXODUS> | ProviderConfig<PROVIDER_ID.KMD> | PROVIDER_ID.EXODUS | PROVIDER_ID.KMD | PROVIDER_ID.ALGOSIGNER | PROVIDER_ID.MNEMONIC;
369
- declare type ProvidersArray = NonEmptyArray<ProviderDef>;
370
-
371
- declare function useWallet(): {
372
- clients: Partial<Record<PROVIDER_ID, BaseClient | null>> | null;
373
- providers: Provider[] | null;
374
- connectedAccounts: Account[];
375
- connectedActiveAccounts: Account[];
376
- activeAccount: Account | null | undefined;
377
- activeAddress: string | undefined;
378
- status: string;
379
- isActive: boolean;
380
- isReady: boolean;
381
- signer: _algosdk.TransactionSigner;
382
- signTransactions: (transactions: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
383
- sendTransactions: (transactions: Uint8Array[], waitRoundsToConfirm?: number) => Promise<{
384
- 'confirmed-round': number;
385
- 'global-state-delta': Record<string, unknown>[];
386
- 'pool-error': string;
387
- txn: {
388
- sig: Uint8Array;
389
- txn: Txn;
390
- };
391
- txId: string;
392
- id: string;
393
- }>;
394
- getAddress: () => string | undefined;
395
- groupTransactionsBySender: (transactions: TransactionsArray) => Record<string, TxnInfo[]>;
396
- getAccountInfo: () => Promise<AccountInfo>;
397
- getAssets: () => Promise<Asset[]>;
398
- };
399
-
400
- interface InitializeProvidersOptions {
401
- providers: ProvidersArray;
402
- nodeConfig?: NodeConfig;
403
- algosdkStatic?: typeof _algosdk;
404
- debug?: boolean;
405
- }
406
- declare function useInitializeProviders({ providers, nodeConfig, algosdkStatic, debug }: InitializeProvidersOptions): Partial<Record<PROVIDER_ID, BaseClient | null>> | null;
358
+ type ProvidersArray = NonEmptyArray<ProviderDef>;
359
+ type WalletClient = BaseClient;
360
+ type SupportedProviders = Partial<Record<PROVIDER_ID, WalletClient | null>>;
407
361
 
408
362
  declare const reconnectProviders: (providers: SupportedProviders) => Promise<void>;
409
363
 
410
- declare type NFDTransactionsArray = ['u' | 's', string][];
364
+ type NFDTransactionsArray = ['u' | 's', string][];
411
365
  declare function encodeNFDTransactionsArray(transactionsArray: NFDTransactionsArray): Uint8Array[];
412
366
 
413
- declare type WalletStore = {
367
+ type WalletStore = {
414
368
  accounts: Account[];
415
369
  activeAccount: Account | null | undefined;
416
370
  setActiveAccount: (account: Account) => void;
@@ -424,7 +378,7 @@ declare const useWalletStore: zustand.UseBoundStore<Omit<Omit<Omit<zustand.Store
424
378
  persist: {
425
379
  setOptions: (options: Partial<zustand_middleware.PersistOptions<WalletStore, WalletStore>>) => void;
426
380
  clearStorage: () => void;
427
- rehydrate: () => Promise<void>;
381
+ rehydrate: () => void | Promise<void>;
428
382
  hasHydrated: () => boolean;
429
383
  onHydrate: (fn: (state: WalletStore) => void) => () => void;
430
384
  onFinishHydration: (fn: (state: WalletStore) => void) => () => void;
@@ -449,7 +403,7 @@ declare class PeraWalletClient extends BaseClient {
449
403
  icon: string;
450
404
  isWalletConnect: boolean;
451
405
  };
452
- static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams$7): Promise<BaseClient | null>;
406
+ static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.PERA>): Promise<BaseClient | null>;
453
407
  connect(onDisconnect: () => void): Promise<Wallet>;
454
408
  reconnect(onDisconnect: () => void): Promise<{
455
409
  accounts: {
@@ -466,11 +420,6 @@ declare class PeraWalletClient extends BaseClient {
466
420
  signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
467
421
  }
468
422
 
469
- /**
470
- * Helpful resources:
471
- * https://github.com/randlabs/myalgo-connect
472
- */
473
-
474
423
  declare class MyAlgoWalletClient extends BaseClient {
475
424
  #private;
476
425
  clientOptions?: MyAlgoConnectOptions;
@@ -482,7 +431,7 @@ declare class MyAlgoWalletClient extends BaseClient {
482
431
  icon: string;
483
432
  isWalletConnect: boolean;
484
433
  };
485
- static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams$3): Promise<BaseClient | null>;
434
+ static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.MYALGO>): Promise<BaseClient | null>;
486
435
  connect(): Promise<{
487
436
  accounts: {
488
437
  providerId: PROVIDER_ID;
@@ -510,7 +459,7 @@ declare class DeflyWalletClient extends BaseClient {
510
459
  icon: string;
511
460
  isWalletConnect: boolean;
512
461
  };
513
- static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams$6): Promise<BaseClient | null>;
462
+ static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.DEFLY>): Promise<BaseClient | null>;
514
463
  connect(onDisconnect: () => void): Promise<Wallet>;
515
464
  reconnect(onDisconnect: () => void): Promise<{
516
465
  accounts: {
@@ -538,7 +487,7 @@ declare class ExodusClient extends BaseClient {
538
487
  icon: string;
539
488
  isWalletConnect: boolean;
540
489
  };
541
- static init({ clientOptions, algodOptions, algosdkStatic, network }: InitParams$5): Promise<BaseClient | null>;
490
+ static init({ clientOptions, algodOptions, algosdkStatic, network }: InitParams<PROVIDER_ID.EXODUS>): Promise<BaseClient | null>;
542
491
  connect(): Promise<{
543
492
  accounts: {
544
493
  name: string;
@@ -555,25 +504,25 @@ declare class ExodusClient extends BaseClient {
555
504
  signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
556
505
  }
557
506
 
558
- declare type GenesisId = 'betanet-v1.0' | 'testnet-v1.0' | 'mainnet-v1.0' | string;
559
- declare type EnableParams = {
507
+ type GenesisId = 'betanet-v1.0' | 'testnet-v1.0' | 'mainnet-v1.0' | string;
508
+ type EnableParams = {
560
509
  genesisID?: GenesisId;
561
510
  genesisHash?: string;
562
511
  accounts?: string[];
563
512
  };
564
- declare type EnableResponse = {
513
+ type EnableResponse = {
565
514
  genesisID: GenesisId;
566
515
  genesisHash: string;
567
516
  accounts: string[];
568
517
  };
569
- declare type AlgoSignerTransaction = {
518
+ type AlgoSignerTransaction = {
570
519
  txn: string;
571
520
  signers?: string[];
572
521
  stxn?: string;
573
522
  multisig?: string;
574
523
  authAddr?: string;
575
524
  };
576
- declare type AlgoSigner = {
525
+ type AlgoSigner = {
577
526
  enable: (params?: EnableParams) => Promise<EnableResponse>;
578
527
  signTxns: (transactions: AlgoSignerTransaction[]) => Promise<string[]>;
579
528
  encoding: {
@@ -581,14 +530,13 @@ declare type AlgoSigner = {
581
530
  byteArrayToString(transaction: Uint8Array): string;
582
531
  };
583
532
  };
584
- declare type AlgoSignerClientConstructor = {
533
+ type AlgoSignerClientConstructor = {
585
534
  metadata: Metadata;
586
535
  client: AlgoSigner;
587
- algosdk: typeof _algosdk;
588
- algodClient: _algosdk.Algodv2;
536
+ algosdk: typeof algosdk;
537
+ algodClient: algosdk.Algodv2;
589
538
  network: Network;
590
539
  };
591
- declare type InitParams$2 = CommonInitParams;
592
540
 
593
541
  declare class AlgoSignerClient extends BaseClient {
594
542
  #private;
@@ -601,7 +549,7 @@ declare class AlgoSignerClient extends BaseClient {
601
549
  icon: string;
602
550
  isWalletConnect: boolean;
603
551
  };
604
- static init({ algodOptions, algosdkStatic, network }: InitParams$2): Promise<BaseClient | null>;
552
+ static init({ algodOptions, algosdkStatic, network }: InitParams<PROVIDER_ID.ALGOSIGNER>): Promise<BaseClient | null>;
605
553
  connect(): Promise<{
606
554
  accounts: {
607
555
  authAddr?: string | undefined;
@@ -621,23 +569,19 @@ declare class AlgoSignerClient extends BaseClient {
621
569
  getAuthAddress(address: string): string | undefined;
622
570
  }
623
571
 
624
- declare type WalletConnectClientConstructor = {
572
+ type WalletConnectClientConstructor = {
625
573
  metadata: Metadata;
626
- client: Web3ModalSign;
627
- clientOptions: Web3ModalSignOptions;
628
- algosdk: typeof _algosdk;
629
- algodClient: _algosdk.Algodv2;
574
+ client: WalletConnectModalSign;
575
+ clientOptions: WalletConnectModalSignOptions;
576
+ algosdk: typeof algosdk;
577
+ algodClient: algosdk.Algodv2;
630
578
  network: Network;
631
579
  chain: string;
632
580
  };
633
- declare type InitParams$1 = CommonInitParams & {
634
- clientOptions?: Web3ModalSignOptions;
635
- clientStatic?: typeof Web3ModalSign;
636
- };
637
581
 
638
582
  declare class WalletConnectClient extends BaseClient {
639
583
  #private;
640
- clientOptions?: Web3ModalSignOptions;
584
+ clientOptions?: WalletConnectModalSignOptions;
641
585
  network: Network;
642
586
  chain: string;
643
587
  constructor({ metadata, client, clientOptions, algosdk, algodClient, network, chain }: WalletConnectClientConstructor);
@@ -647,7 +591,7 @@ declare class WalletConnectClient extends BaseClient {
647
591
  icon: string;
648
592
  isWalletConnect: boolean;
649
593
  };
650
- static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams$1): Promise<BaseClient | null>;
594
+ static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network }: InitParams<PROVIDER_ID.WALLETCONNECT>): Promise<BaseClient | null>;
651
595
  connect(): Promise<Wallet>;
652
596
  reconnect(): Promise<{
653
597
  accounts: {
@@ -675,7 +619,7 @@ declare class KMDWalletClient extends BaseClient {
675
619
  icon: string;
676
620
  isWalletConnect: boolean;
677
621
  };
678
- static init({ clientOptions, algodOptions, algosdkStatic, network }: InitParams$4): Promise<BaseClient | null>;
622
+ static init({ clientOptions, algodOptions, algosdkStatic, network }: InitParams<PROVIDER_ID.KMD>): Promise<BaseClient | null>;
679
623
  connect(): Promise<Wallet>;
680
624
  disconnect(): Promise<void>;
681
625
  reconnect(): Promise<Wallet | null>;
@@ -688,13 +632,12 @@ declare class KMDWalletClient extends BaseClient {
688
632
  signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
689
633
  }
690
634
 
691
- declare type MnemonicWalletClientConstructor = {
635
+ type MnemonicWalletClientConstructor = {
692
636
  metadata: Metadata;
693
- algosdk: typeof _algosdk;
694
- algodClient: _algosdk.Algodv2;
637
+ algosdk: typeof algosdk;
638
+ algodClient: algosdk.Algodv2;
695
639
  network: Network;
696
640
  };
697
- declare type InitParams = CommonInitParams;
698
641
 
699
642
  declare class MnemonicWalletClient extends BaseClient {
700
643
  #private;
@@ -706,7 +649,7 @@ declare class MnemonicWalletClient extends BaseClient {
706
649
  icon: string;
707
650
  isWalletConnect: boolean;
708
651
  };
709
- static init({ algodOptions, algosdkStatic, network }: InitParams): Promise<BaseClient | null>;
652
+ static init({ algodOptions, algosdkStatic, network }: InitParams<PROVIDER_ID.MNEMONIC>): Promise<BaseClient | null>;
710
653
  connect(): Promise<{
711
654
  accounts: {
712
655
  name: string;
@@ -725,4 +668,41 @@ declare class MnemonicWalletClient extends BaseClient {
725
668
  signEncodedTransactions(_transactions: TransactionsArray): Promise<Uint8Array[]>;
726
669
  }
727
670
 
728
- export { Account, AccountInfo, AlgodClientOptions, Asset, ClientOptions, CommonInitParams, ConfirmedTxn, DEFAULT_NETWORK, DEFAULT_NODE_BASEURL, DEFAULT_NODE_PORT, DEFAULT_NODE_TOKEN, DecodedSignedTransaction, DecodedTransaction, Metadata, Network, NodeConfig, PROVIDER_ID, Provider, ProviderConfig, ProviderConfigMapping, ProvidersArray, PublicNetwork, RawTxnResponse, SupportedProviders, TransactionsArray, Txn, TxnInfo, TxnType, Wallet, WalletClient, _default as WalletProvider, AlgoSignerClient as algosigner, DeflyWalletClient as defly, encodeNFDTransactionsArray, ExodusClient as exodus, KMDWalletClient as kmd, MnemonicWalletClient as mnemonic, MyAlgoWalletClient as myalgo, PeraWalletClient as pera, reconnectProviders, useInitializeProviders, useWallet, WalletConnectClient as walletconnect };
671
+ declare function useWallet(): {
672
+ clients: Partial<Record<PROVIDER_ID, BaseClient | null>> | null;
673
+ providers: Provider[] | null;
674
+ connectedAccounts: Account[];
675
+ connectedActiveAccounts: Account[];
676
+ activeAccount: Account | null | undefined;
677
+ activeAddress: string | undefined;
678
+ status: string;
679
+ isActive: boolean;
680
+ isReady: boolean;
681
+ signer: algosdk.TransactionSigner;
682
+ signTransactions: (transactions: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
683
+ sendTransactions: (transactions: Uint8Array[], waitRoundsToConfirm?: number) => Promise<{
684
+ 'confirmed-round': number;
685
+ 'global-state-delta': Record<string, unknown>[];
686
+ 'pool-error': string;
687
+ txn: {
688
+ sig: Uint8Array;
689
+ txn: Txn;
690
+ };
691
+ txId: string;
692
+ id: string;
693
+ }>;
694
+ getAddress: () => string | undefined;
695
+ groupTransactionsBySender: (transactions: TransactionsArray) => Record<string, TxnInfo[]>;
696
+ getAccountInfo: () => Promise<AccountInfo>;
697
+ getAssets: () => Promise<Asset[]>;
698
+ };
699
+
700
+ interface InitializeProvidersOptions {
701
+ providers: ProvidersArray;
702
+ nodeConfig?: NodeConfig;
703
+ algosdkStatic?: typeof algosdk;
704
+ debug?: boolean;
705
+ }
706
+ declare function useInitializeProviders({ providers, nodeConfig, algosdkStatic, debug }: InitializeProvidersOptions): Partial<Record<PROVIDER_ID, BaseClient | null>> | null;
707
+
708
+ export { Account, AccountInfo, AlgodClientOptions, Asset, ClientOptions, CommonInitParams, ConfirmedTxn, DEFAULT_NETWORK, DEFAULT_NODE_BASEURL, DEFAULT_NODE_PORT, DEFAULT_NODE_TOKEN, DecodedSignedTransaction, DecodedTransaction, InitParams, Metadata, Network, NodeConfig, PROVIDER_ID, Provider, ProviderConfig, ProviderConfigMapping, ProvidersArray, PublicNetwork, RawTxnResponse, SupportedProviders, TransactionsArray, Txn, TxnInfo, TxnType, Wallet, WalletClient, _default as WalletProvider, AlgoSignerClient as algosigner, DeflyWalletClient as defly, encodeNFDTransactionsArray, ExodusClient as exodus, KMDWalletClient as kmd, MnemonicWalletClient as mnemonic, MyAlgoWalletClient as myalgo, PeraWalletClient as pera, reconnectProviders, useInitializeProviders, useWallet, WalletConnectClient as walletconnect };