@txnlab/use-wallet 0.1.22 → 1.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 (130) hide show
  1. package/README.md +252 -94
  2. package/dist/cjs/algod/index.d.ts +3 -2
  3. package/dist/cjs/clients/algosigner/client.d.ts +35 -0
  4. package/dist/cjs/clients/algosigner/constants.d.ts +2 -0
  5. package/dist/cjs/clients/algosigner/index.d.ts +2 -0
  6. package/dist/cjs/clients/algosigner/types.d.ts +40 -0
  7. package/dist/cjs/clients/base/base.d.ts +50 -0
  8. package/dist/cjs/clients/base/index.d.ts +2 -0
  9. package/dist/cjs/clients/defly/client.d.ts +37 -0
  10. package/dist/cjs/clients/defly/constants.d.ts +1 -0
  11. package/dist/cjs/clients/defly/index.d.ts +2 -0
  12. package/dist/cjs/clients/defly/types.d.ts +36 -0
  13. package/dist/cjs/clients/exodus/client.d.ts +33 -0
  14. package/dist/cjs/clients/exodus/constants.d.ts +1 -0
  15. package/dist/cjs/clients/exodus/index.d.ts +2 -0
  16. package/dist/cjs/clients/exodus/types.d.ts +40 -0
  17. package/dist/cjs/clients/index.d.ts +11 -15
  18. package/dist/cjs/clients/kmd/client.d.ts +29 -0
  19. package/dist/cjs/clients/kmd/constants.d.ts +1 -0
  20. package/dist/cjs/clients/kmd/index.d.ts +2 -0
  21. package/dist/cjs/clients/kmd/types.d.ts +38 -0
  22. package/dist/cjs/clients/myalgo/client.d.ts +37 -0
  23. package/dist/cjs/clients/myalgo/constants.d.ts +1 -0
  24. package/dist/cjs/clients/myalgo/index.d.ts +2 -0
  25. package/dist/cjs/clients/myalgo/types.d.ts +23 -0
  26. package/dist/cjs/clients/pera/client.d.ts +35 -0
  27. package/dist/cjs/clients/pera/constants.d.ts +1 -0
  28. package/dist/cjs/clients/pera/index.d.ts +2 -0
  29. package/dist/cjs/clients/pera/types.d.ts +36 -0
  30. package/dist/cjs/clients/walletconnect/client.d.ts +37 -0
  31. package/dist/cjs/clients/walletconnect/constants.d.ts +2 -0
  32. package/dist/cjs/clients/walletconnect/index.d.ts +2 -0
  33. package/dist/cjs/clients/walletconnect/types.d.ts +54 -0
  34. package/dist/cjs/constants/constants.d.ts +12 -16
  35. package/dist/cjs/hooks/index.d.ts +0 -1
  36. package/dist/cjs/hooks/useWallet.d.ts +140 -8
  37. package/dist/cjs/index.d.ts +4 -2
  38. package/dist/cjs/index.js +1428 -1031
  39. package/dist/cjs/index.js.map +1 -1
  40. package/dist/cjs/store/index.d.ts +1 -0
  41. package/dist/cjs/store/state/clientStore.d.ts +22 -0
  42. package/dist/cjs/store/state/walletStore.d.ts +17 -1
  43. package/dist/cjs/types/node.d.ts +3 -0
  44. package/dist/cjs/types/wallet.d.ts +2 -2
  45. package/dist/cjs/utils/index.d.ts +2 -2
  46. package/dist/cjs/utils/initializeProviders.d.ts +13 -0
  47. package/dist/cjs/utils/reconnectProviders.d.ts +6 -0
  48. package/dist/esm/algod/index.d.ts +3 -2
  49. package/dist/esm/clients/algosigner/client.d.ts +35 -0
  50. package/dist/esm/clients/algosigner/constants.d.ts +2 -0
  51. package/dist/esm/clients/algosigner/index.d.ts +2 -0
  52. package/dist/esm/clients/algosigner/types.d.ts +40 -0
  53. package/dist/esm/clients/base/base.d.ts +50 -0
  54. package/dist/esm/clients/base/index.d.ts +2 -0
  55. package/dist/esm/clients/defly/client.d.ts +37 -0
  56. package/dist/esm/clients/defly/constants.d.ts +1 -0
  57. package/dist/esm/clients/defly/index.d.ts +2 -0
  58. package/dist/esm/clients/defly/types.d.ts +36 -0
  59. package/dist/esm/clients/exodus/client.d.ts +33 -0
  60. package/dist/esm/clients/exodus/constants.d.ts +1 -0
  61. package/dist/esm/clients/exodus/index.d.ts +2 -0
  62. package/dist/esm/clients/exodus/types.d.ts +40 -0
  63. package/dist/esm/clients/index.d.ts +11 -15
  64. package/dist/esm/clients/kmd/client.d.ts +29 -0
  65. package/dist/esm/clients/kmd/constants.d.ts +1 -0
  66. package/dist/esm/clients/kmd/index.d.ts +2 -0
  67. package/dist/esm/clients/kmd/types.d.ts +38 -0
  68. package/dist/esm/clients/myalgo/client.d.ts +37 -0
  69. package/dist/esm/clients/myalgo/constants.d.ts +1 -0
  70. package/dist/esm/clients/myalgo/index.d.ts +2 -0
  71. package/dist/esm/clients/myalgo/types.d.ts +23 -0
  72. package/dist/esm/clients/pera/client.d.ts +35 -0
  73. package/dist/esm/clients/pera/constants.d.ts +1 -0
  74. package/dist/esm/clients/pera/index.d.ts +2 -0
  75. package/dist/esm/clients/pera/types.d.ts +36 -0
  76. package/dist/esm/clients/walletconnect/client.d.ts +37 -0
  77. package/dist/esm/clients/walletconnect/constants.d.ts +2 -0
  78. package/dist/esm/clients/walletconnect/index.d.ts +2 -0
  79. package/dist/esm/clients/walletconnect/types.d.ts +54 -0
  80. package/dist/esm/constants/constants.d.ts +12 -16
  81. package/dist/esm/hooks/index.d.ts +0 -1
  82. package/dist/esm/hooks/useWallet.d.ts +140 -8
  83. package/dist/esm/index.d.ts +4 -2
  84. package/dist/esm/index.js +1415 -1021
  85. package/dist/esm/store/index.d.ts +1 -0
  86. package/dist/esm/store/state/clientStore.d.ts +22 -0
  87. package/dist/esm/store/state/walletStore.d.ts +17 -1
  88. package/dist/esm/types/node.d.ts +3 -0
  89. package/dist/esm/types/wallet.d.ts +2 -2
  90. package/dist/esm/utils/index.d.ts +2 -2
  91. package/dist/esm/utils/initializeProviders.d.ts +13 -0
  92. package/dist/esm/utils/reconnectProviders.d.ts +6 -0
  93. package/dist/index.d.ts +669 -66
  94. package/package.json +5 -5
  95. package/dist/cjs/clients/algosigner.d.ts +0 -62
  96. package/dist/cjs/clients/base.d.ts +0 -63
  97. package/dist/cjs/clients/defly.d.ts +0 -51
  98. package/dist/cjs/clients/exodus.d.ts +0 -52
  99. package/dist/cjs/clients/kmd.d.ts +0 -31
  100. package/dist/cjs/clients/myalgowallet.d.ts +0 -40
  101. package/dist/cjs/clients/perawallet.d.ts +0 -47
  102. package/dist/cjs/clients/walletconnect.d.ts +0 -47
  103. package/dist/cjs/hooks/useConnectWallet.d.ts +0 -30
  104. package/dist/cjs/providers/algosigner.d.ts +0 -2
  105. package/dist/cjs/providers/defly.d.ts +0 -2
  106. package/dist/cjs/providers/exodus.d.ts +0 -2
  107. package/dist/cjs/providers/index.d.ts +0 -9
  108. package/dist/cjs/providers/kmd.d.ts +0 -2
  109. package/dist/cjs/providers/myalgowallet.d.ts +0 -2
  110. package/dist/cjs/providers/perawallet.d.ts +0 -2
  111. package/dist/cjs/providers/walletconnect.d.ts +0 -2
  112. package/dist/cjs/store/middelware/immer.d.ts +0 -10
  113. package/dist/esm/clients/algosigner.d.ts +0 -62
  114. package/dist/esm/clients/base.d.ts +0 -63
  115. package/dist/esm/clients/defly.d.ts +0 -51
  116. package/dist/esm/clients/exodus.d.ts +0 -52
  117. package/dist/esm/clients/kmd.d.ts +0 -31
  118. package/dist/esm/clients/myalgowallet.d.ts +0 -40
  119. package/dist/esm/clients/perawallet.d.ts +0 -47
  120. package/dist/esm/clients/walletconnect.d.ts +0 -47
  121. package/dist/esm/hooks/useConnectWallet.d.ts +0 -30
  122. package/dist/esm/providers/algosigner.d.ts +0 -2
  123. package/dist/esm/providers/defly.d.ts +0 -2
  124. package/dist/esm/providers/exodus.d.ts +0 -2
  125. package/dist/esm/providers/index.d.ts +0 -9
  126. package/dist/esm/providers/kmd.d.ts +0 -2
  127. package/dist/esm/providers/myalgowallet.d.ts +0 -2
  128. package/dist/esm/providers/perawallet.d.ts +0 -2
  129. package/dist/esm/providers/walletconnect.d.ts +0 -2
  130. package/dist/esm/store/middelware/immer.d.ts +0 -10
package/dist/index.d.ts CHANGED
@@ -1,24 +1,12 @@
1
- import _algosdk from 'algosdk';
2
-
3
- declare enum PROVIDER_ID {
4
- KMD_WALLET = "KMD Wallet",
5
- PERA_WALLET = "Pera Wallet",
6
- MYALGO_WALLET = "MyAlgo Wallet",
7
- ALGO_SIGNER = "Algo Signer",
8
- DEFLY = "Defly",
9
- EXODUS = "Exodus",
10
- WALLET_CONNECT = "Wallet Connect"
11
- }
12
- declare const NODE_SERVER: string;
13
- declare const NODE_TOKEN: string;
14
- declare const NODE_PORT: string;
15
- declare const NODE_NETWORK: string;
16
- declare const KMD_HOST: string;
17
- declare const KMD_TOKEN: string;
18
- declare const KMD_PORT: string;
19
- declare const KMD_WALLET: string;
20
- declare const KMD_PASSWORD: string;
1
+ import _algosdk, { Transaction } from 'algosdk';
2
+ import * as react from 'react';
3
+ import { PeraWalletConnect } from '@perawallet/connect';
4
+ import _MyAlgoConnect from '@randlabs/myalgo-connect';
5
+ import { DeflyWalletConnect } from '@blockshake/defly-connect';
6
+ import WalletConnect from '@walletconnect/client';
7
+ import QRCodeModal from 'algorand-walletconnect-qrcode-modal';
21
8
 
9
+ declare type Network = "betanet" | "testnet" | "mainnet" | string;
22
10
  declare type Txn = {
23
11
  apaa: Uint8Array;
24
12
  apas: number[];
@@ -59,6 +47,7 @@ declare type DecodedSignedTransaction = {
59
47
  sig: Uint8Array;
60
48
  txn: DecodedTransaction;
61
49
  };
50
+ declare type AlgodClientOptions = ConstructorParameters<typeof _algosdk.Algodv2>;
62
51
 
63
52
  declare type TransactionsArray = ["u" | "s", string][];
64
53
  declare type TxnInfo = {
@@ -71,22 +60,65 @@ declare type TxnInfo = {
71
60
  signedTxn?: Uint8Array;
72
61
  };
73
62
 
74
- interface BaseWalletInterface {
75
- connect(onDisconnect: () => void): Promise<Wallet>;
76
- healthCheck(): Promise<Record<string, never>>;
77
- disconnect(): Promise<void>;
78
- reconnect(onDisconnect: () => void): Promise<Wallet | null>;
79
- decodeTransaction(txn: string, isSigned: boolean): _algosdk.Transaction;
80
- logEncodedTransaction(txn: string, isSigned: boolean): void;
81
- groupTransactionsBySender(transactions: TransactionsArray): Record<string, TxnInfo[]>;
82
- signTransactions(activeAddress: string, transactions: Array<Uint8Array>): Promise<Uint8Array[]>;
83
- signEncodedTransactions(transactions: TransactionsArray): Promise<Uint8Array[]>;
84
- sendRawTransactions(transactions: Uint8Array[]): Promise<ConfirmedTxn & {
85
- id: string;
86
- }>;
63
+ declare enum PROVIDER_ID {
64
+ KMD = "kmd",
65
+ PERA = "pera",
66
+ MYALGO = "myalgo",
67
+ ALGOSIGNER = "algosigner",
68
+ DEFLY = "defly",
69
+ EXODUS = "exodus",
70
+ WALLETCONNECT = "walletconnect"
71
+ }
72
+ declare const DEFAULT_NETWORK: Network;
73
+ declare const DEFAULT_NODE_BASEURL = "https://mainnet-api.algonode.cloud";
74
+ declare const DEFAULT_NODE_TOKEN = "";
75
+ declare const DEFAULT_NODE_PORT = "";
76
+
77
+ declare abstract class BaseClient {
78
+ algosdk: typeof _algosdk;
79
+ algodClient: _algosdk.Algodv2;
80
+ keepWCAlive: HTMLAudioElement;
81
+ static metadata: {
82
+ id: PROVIDER_ID;
83
+ name: string;
84
+ icon: string;
85
+ isWalletConnect: boolean;
86
+ };
87
+ abstract connect(onDisconnect: () => void): Promise<Wallet>;
88
+ abstract disconnect(): Promise<void>;
89
+ abstract reconnect(onDisconnect: () => void): Promise<Wallet | null>;
90
+ abstract signTransactions(connectedAccounts: string[], transactions: Array<Uint8Array>): Promise<Uint8Array[]>;
91
+ abstract signEncodedTransactions(transactions: TransactionsArray): Promise<Uint8Array[]>;
92
+ protected constructor(algosdk: typeof _algosdk, algodClient: _algosdk.Algodv2);
93
+ healthCheck(): Promise<{}>;
87
94
  getAccountInfo(address: string): Promise<AccountInfo>;
88
95
  getAssets(address: string): Promise<Asset[]>;
89
- waitForConfirmation(txId: string, timeout?: number): Promise<ConfirmedTxn>;
96
+ waitForConfirmation(txId: string, timeout?: number): Promise<{
97
+ "confirmed-round": number;
98
+ "global-state-delta": Record<string, unknown>[];
99
+ "pool-error": string;
100
+ txn: {
101
+ sig: Uint8Array;
102
+ txn: Txn;
103
+ };
104
+ txId: string;
105
+ }>;
106
+ decodeTransaction: (txn: string, isSigned: boolean) => _algosdk.Transaction;
107
+ logEncodedTransaction(txn: string, isSigned: boolean): void;
108
+ groupTransactionsBySender(transactions: TransactionsArray): Record<string, any>;
109
+ sendRawTransactions(transactions: Uint8Array[], waitRoundsToConfirm?: number): Promise<{
110
+ "confirmed-round": number;
111
+ "global-state-delta": Record<string, unknown>[];
112
+ "pool-error": string;
113
+ txn: {
114
+ sig: Uint8Array;
115
+ txn: Txn;
116
+ };
117
+ txId: string;
118
+ id: any;
119
+ }>;
120
+ keepWCAliveStart(): void;
121
+ keepWCAliveStop(): void;
90
122
  }
91
123
 
92
124
  interface Account {
@@ -132,55 +164,626 @@ declare type ExtendValues<Type> = {
132
164
  declare type Wallet = ExtendValues<WalletProvider> & {
133
165
  accounts: Account[];
134
166
  };
135
- declare type WalletClient = BaseWalletInterface;
167
+ declare type WalletClient = BaseClient;
136
168
 
137
169
  declare function useWallet(): {
138
- accounts: Account[];
170
+ clients: Partial<{
171
+ kmd: Promise<BaseClient | null>;
172
+ pera: Promise<BaseClient | null>;
173
+ myalgo: Promise<BaseClient | null>;
174
+ algosigner: Promise<BaseClient | null>;
175
+ defly: Promise<BaseClient | null>;
176
+ exodus: Promise<BaseClient | null>;
177
+ walletconnect: Promise<BaseClient | null>;
178
+ }> | null;
179
+ providers: ({
180
+ accounts: Account[];
181
+ isActive: boolean;
182
+ isConnected: boolean;
183
+ connect: () => Promise<void>;
184
+ disconnect: () => Promise<void>;
185
+ reconnect: () => Promise<void>;
186
+ setActiveProvider: () => Promise<void>;
187
+ setActiveAccount: (account: string) => Promise<void>;
188
+ metadata: {
189
+ id: PROVIDER_ID;
190
+ name: string;
191
+ icon: string;
192
+ isWalletConnect: boolean;
193
+ };
194
+ } | {
195
+ accounts: Account[];
196
+ isActive: boolean;
197
+ isConnected: boolean;
198
+ connect: () => Promise<void>;
199
+ disconnect: () => Promise<void>;
200
+ reconnect: () => Promise<void>;
201
+ setActiveProvider: () => Promise<void>;
202
+ setActiveAccount: (account: string) => Promise<void>;
203
+ metadata: {
204
+ id: PROVIDER_ID;
205
+ name: string;
206
+ icon: string;
207
+ isWalletConnect: boolean;
208
+ };
209
+ } | {
210
+ accounts: Account[];
211
+ isActive: boolean;
212
+ isConnected: boolean;
213
+ connect: () => Promise<void>;
214
+ disconnect: () => Promise<void>;
215
+ reconnect: () => Promise<void>;
216
+ setActiveProvider: () => Promise<void>;
217
+ setActiveAccount: (account: string) => Promise<void>;
218
+ metadata: {
219
+ id: PROVIDER_ID;
220
+ name: string;
221
+ icon: string;
222
+ isWalletConnect: boolean;
223
+ };
224
+ } | {
225
+ accounts: Account[];
226
+ isActive: boolean;
227
+ isConnected: boolean;
228
+ connect: () => Promise<void>;
229
+ disconnect: () => Promise<void>;
230
+ reconnect: () => Promise<void>;
231
+ setActiveProvider: () => Promise<void>;
232
+ setActiveAccount: (account: string) => Promise<void>;
233
+ metadata: {
234
+ id: PROVIDER_ID;
235
+ name: string;
236
+ icon: string;
237
+ isWalletConnect: boolean;
238
+ };
239
+ } | {
240
+ accounts: Account[];
241
+ isActive: boolean;
242
+ isConnected: boolean;
243
+ connect: () => Promise<void>;
244
+ disconnect: () => Promise<void>;
245
+ reconnect: () => Promise<void>;
246
+ setActiveProvider: () => Promise<void>;
247
+ setActiveAccount: (account: string) => Promise<void>;
248
+ metadata: {
249
+ id: PROVIDER_ID;
250
+ name: string;
251
+ icon: string;
252
+ isWalletConnect: boolean;
253
+ };
254
+ } | {
255
+ accounts: Account[];
256
+ isActive: boolean;
257
+ isConnected: boolean;
258
+ connect: () => Promise<void>;
259
+ disconnect: () => Promise<void>;
260
+ reconnect: () => Promise<void>;
261
+ setActiveProvider: () => Promise<void>;
262
+ setActiveAccount: (account: string) => Promise<void>;
263
+ metadata: {
264
+ id: PROVIDER_ID;
265
+ name: string;
266
+ icon: string;
267
+ isWalletConnect: boolean;
268
+ };
269
+ } | {
270
+ accounts: Account[];
271
+ isActive: boolean;
272
+ isConnected: boolean;
273
+ connect: () => Promise<void>;
274
+ disconnect: () => Promise<void>;
275
+ reconnect: () => Promise<void>;
276
+ setActiveProvider: () => Promise<void>;
277
+ setActiveAccount: (account: string) => Promise<void>;
278
+ metadata: {
279
+ id: PROVIDER_ID;
280
+ name: string;
281
+ icon: string;
282
+ isWalletConnect: boolean;
283
+ };
284
+ })[] | null;
285
+ connectedAccounts: Account[];
286
+ connectedActiveAccounts: Account[];
139
287
  activeAccount: Account | null;
288
+ activeAddress: string | undefined;
140
289
  signer: _algosdk.TransactionSigner;
141
290
  signTransactions: (transactions: Array<Uint8Array>) => Promise<Uint8Array[]>;
142
- sendTransactions: (transactions: Uint8Array[]) => Promise<ConfirmedTxn & {
143
- id: string;
291
+ sendTransactions: (transactions: Uint8Array[], waitRoundsToConfirm?: number) => Promise<{
292
+ "confirmed-round": number;
293
+ "global-state-delta": Record<string, unknown>[];
294
+ "pool-error": string;
295
+ txn: {
296
+ sig: Uint8Array;
297
+ txn: Txn;
298
+ };
299
+ txId: string;
300
+ id: any;
144
301
  }>;
145
302
  getAddress: () => string | undefined;
146
- groupTransactionsBySender: (transactions: TransactionsArray) => Promise<Record<string, TxnInfo[]>>;
303
+ groupTransactionsBySender: (transactions: TransactionsArray) => Promise<Record<string, any>>;
147
304
  getAccountInfo: () => Promise<AccountInfo>;
148
305
  getAssets: () => Promise<Asset[]>;
149
306
  signEncodedTransactions: (transactions: TransactionsArray) => Promise<Uint8Array[]>;
150
- sendRawTransactions: (transactions: Uint8Array[]) => Promise<ConfirmedTxn & {
151
- id: string;
307
+ sendRawTransactions: (transactions: Uint8Array[], waitRoundsToConfirm?: number) => Promise<{
308
+ "confirmed-round": number;
309
+ "global-state-delta": Record<string, unknown>[];
310
+ "pool-error": string;
311
+ txn: {
312
+ sig: Uint8Array;
313
+ txn: Txn;
314
+ };
315
+ txId: string;
316
+ id: any;
152
317
  }>;
153
318
  };
154
319
 
155
- declare type Options = Partial<{
156
- providers: PROVIDER_ID[];
157
- }>;
158
- declare function useConnectWallet(options?: Options): {
159
- providers: {
320
+ declare type SupportedProviders$1 = {
321
+ [x: string]: Promise<WalletClient | null>;
322
+ };
323
+ declare type NodeConfig = {
324
+ network: Network;
325
+ nodeServer: string;
326
+ nodeToken?: string;
327
+ nodePort?: string;
328
+ };
329
+ declare const initializeProviders: (providers?: PROVIDER_ID[], nodeConfig?: NodeConfig, algosdkStatic?: typeof _algosdk) => SupportedProviders$1;
330
+
331
+ declare type SupportedProviders = {
332
+ [x: string]: Promise<WalletClient | null>;
333
+ };
334
+ declare const reconnectProviders: (providers: SupportedProviders) => Promise<void>;
335
+
336
+ declare const _default: react.Provider<Partial<{
337
+ kmd: Promise<BaseClient | null>;
338
+ pera: Promise<BaseClient | null>;
339
+ myalgo: Promise<BaseClient | null>;
340
+ algosigner: Promise<BaseClient | null>;
341
+ defly: Promise<BaseClient | null>;
342
+ exodus: Promise<BaseClient | null>;
343
+ walletconnect: Promise<BaseClient | null>;
344
+ }> | null>;
345
+
346
+ declare type ClientOptions$5 = {
347
+ bridge?: string;
348
+ deep_link?: string;
349
+ app_meta?: {
350
+ logo: string;
351
+ name: string;
352
+ main_color: string;
353
+ };
354
+ shouldShowSignTxnToast?: boolean;
355
+ };
356
+ interface PeraTransaction {
357
+ txn: Transaction;
358
+ /**
359
+ * Optional list of addresses that must sign the transactions.
360
+ * Wallet skips to sign this txn if signers is empty array.
361
+ * If undefined, wallet tries to sign it.
362
+ */
363
+ signers?: string[];
364
+ }
365
+ declare type PeraWalletClientConstructor = {
366
+ client: PeraWalletConnect;
367
+ algosdk: typeof _algosdk;
368
+ algodClient: _algosdk.Algodv2;
369
+ network: Network;
370
+ };
371
+ declare type InitParams$6 = {
372
+ clientOptions?: ClientOptions$5;
373
+ algodOptions?: AlgodClientOptions;
374
+ clientStatic?: typeof PeraWalletConnect;
375
+ algosdkStatic?: typeof _algosdk;
376
+ network?: Network;
377
+ };
378
+
379
+ declare class PeraWalletClient extends BaseClient {
380
+ #private;
381
+ network: Network;
382
+ constructor({ client, algosdk, algodClient, network, }: PeraWalletClientConstructor);
383
+ static metadata: {
160
384
  id: PROVIDER_ID;
161
385
  name: string;
162
386
  icon: string;
163
- accounts: Account[];
164
- activeAccount: Account | null;
165
- isActive: boolean;
166
- isConnected: boolean;
167
387
  isWalletConnect: boolean;
168
- connect: () => Promise<void>;
169
- disconnect: () => Promise<void>;
170
- reconnect: () => Promise<void>;
171
- setActive: () => Promise<void>;
172
- selectAccount: (account: string) => Promise<void>;
173
- }[];
174
- activeAccount: Account | null;
175
- accounts: Account[];
176
- connect: (id: PROVIDER_ID) => Promise<void>;
177
- reconnect: (id: PROVIDER_ID) => Promise<void>;
178
- disconnect: (id: PROVIDER_ID) => Promise<void>;
179
- selectActiveAccount: (providerId: PROVIDER_ID, address: string) => Promise<void>;
180
- setActive: (id: PROVIDER_ID) => Promise<void>;
181
- reconnectProviders: () => Promise<void>;
388
+ };
389
+ static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network, }: InitParams$6): Promise<PeraWalletClient | null>;
390
+ connect(onDisconnect: () => void): Promise<Wallet>;
391
+ reconnect(onDisconnect: () => void): Promise<{
392
+ accounts: {
393
+ name: string;
394
+ address: string;
395
+ providerId: PROVIDER_ID;
396
+ }[];
397
+ id: PROVIDER_ID;
398
+ name: string;
399
+ icon: string;
400
+ isWalletConnect: boolean;
401
+ } | null>;
402
+ disconnect(): Promise<void>;
403
+ signTransactions(connectedAccounts: string[], transactions: Uint8Array[]): Promise<Uint8Array[]>;
404
+ /** @deprecated */
405
+ formatTransactionsArray(transactions: TransactionsArray): PeraTransaction[];
406
+ /** @deprecated */
407
+ signEncodedTransactions(transactions: TransactionsArray): Promise<Uint8Array[]>;
408
+ }
409
+
410
+ /**
411
+ * Helpful resources:
412
+ * https://github.com/randlabs/myalgo-connect
413
+ */
414
+
415
+ declare type MyAlgoWalletClientConstructor = {
416
+ client: _MyAlgoConnect;
417
+ algosdk: typeof _algosdk;
418
+ algodClient: _algosdk.Algodv2;
419
+ network: Network;
420
+ };
421
+ declare type ClientOptions$4 = {
422
+ disableLedgerNano: boolean;
423
+ };
424
+ declare type InitParams$5 = {
425
+ clientOptions?: ClientOptions$4;
426
+ algodOptions?: AlgodClientOptions;
427
+ clientStatic?: typeof _MyAlgoConnect;
428
+ algosdkStatic?: typeof _algosdk;
429
+ network?: Network;
430
+ };
431
+
432
+ /**
433
+ * Helpful resources:
434
+ * https://github.com/randlabs/myalgo-connect
435
+ */
436
+
437
+ declare class MyAlgoWalletClient extends BaseClient {
438
+ #private;
439
+ network: Network;
440
+ constructor({ client, algosdk, algodClient, network, }: MyAlgoWalletClientConstructor);
441
+ static metadata: {
442
+ id: PROVIDER_ID;
443
+ name: string;
444
+ icon: string;
445
+ isWalletConnect: boolean;
446
+ };
447
+ static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network, }: InitParams$5): Promise<MyAlgoWalletClient | null>;
448
+ connect(): Promise<{
449
+ accounts: {
450
+ providerId: PROVIDER_ID;
451
+ address: string;
452
+ name: string;
453
+ }[];
454
+ id: PROVIDER_ID;
455
+ name: string;
456
+ icon: string;
457
+ isWalletConnect: boolean;
458
+ }>;
459
+ reconnect(): Promise<null>;
460
+ disconnect(): Promise<void>;
461
+ signTransactions(connectedAccounts: string[], transactions: Uint8Array[]): Promise<Uint8Array[]>;
462
+ /** @deprecated */
463
+ signEncodedTransactions(transactions: TransactionsArray): Promise<Uint8Array[]>;
464
+ }
465
+
466
+ declare type ClientOptions$3 = {
467
+ bridge?: string;
468
+ deep_link?: string;
469
+ app_meta?: {
470
+ logo: string;
471
+ name: string;
472
+ main_color: string;
473
+ };
474
+ shouldShowSignTxnToast?: boolean;
475
+ };
476
+ declare type DeflyTransaction = {
477
+ txn: Transaction;
478
+ /**
479
+ * Optional list of addresses that must sign the transactions.
480
+ * Wallet skips to sign this txn if signers is empty array.
481
+ * If undefined, wallet tries to sign it.
482
+ */
483
+ signers?: string[];
484
+ };
485
+ declare type DeflyWalletClientConstructor = {
486
+ client: DeflyWalletConnect;
487
+ algosdk: typeof _algosdk;
488
+ algodClient: _algosdk.Algodv2;
489
+ network: Network;
490
+ };
491
+ declare type InitParams$4 = {
492
+ clientOptions?: ClientOptions$3;
493
+ algodOptions?: AlgodClientOptions;
494
+ clientStatic?: typeof DeflyWalletConnect;
495
+ algosdkStatic?: typeof _algosdk;
496
+ network?: Network;
497
+ };
498
+
499
+ declare class DeflyWalletClient extends BaseClient {
500
+ #private;
501
+ network: Network;
502
+ constructor({ client, algosdk, algodClient, network, }: DeflyWalletClientConstructor);
503
+ static metadata: {
504
+ id: PROVIDER_ID;
505
+ name: string;
506
+ icon: string;
507
+ isWalletConnect: boolean;
508
+ };
509
+ static init({ clientOptions, algodOptions, clientStatic, algosdkStatic, network, }: InitParams$4): Promise<DeflyWalletClient | null>;
510
+ connect(onDisconnect: () => void): Promise<Wallet>;
511
+ reconnect(onDisconnect: () => void): Promise<{
512
+ accounts: {
513
+ name: string;
514
+ address: string;
515
+ providerId: PROVIDER_ID;
516
+ }[];
517
+ id: PROVIDER_ID;
518
+ name: string;
519
+ icon: string;
520
+ isWalletConnect: boolean;
521
+ } | null>;
522
+ disconnect(): Promise<void>;
523
+ signTransactions(connectedAccounts: string[], transactions: Uint8Array[]): Promise<Uint8Array[]>;
524
+ /** @deprecated */
525
+ signEncodedTransactions(transactions: TransactionsArray): Promise<Uint8Array[]>;
526
+ /** @deprecated */
527
+ formatTransactionsArray(transactions: TransactionsArray): DeflyTransaction[];
528
+ }
529
+
530
+ declare type ClientOptions$2 = {
531
+ onlyIfTrusted: boolean;
532
+ };
533
+ declare type Bytes = Readonly<Uint8Array>;
534
+ declare type Exodus = {
535
+ isConnected: boolean;
536
+ address: string | null;
537
+ connect: ({ onlyIfTrusted }: {
538
+ onlyIfTrusted: boolean;
539
+ }) => Promise<{
540
+ address: string;
541
+ }>;
542
+ disconnect: () => void;
543
+ signAndSendTransaction(transactions: Bytes[]): Promise<{
544
+ txId: string;
545
+ }>;
546
+ signTransaction(transactions: Bytes[]): Promise<Bytes[]>;
547
+ };
548
+ declare type ExodusClientConstructor = {
549
+ client: Exodus;
550
+ id: PROVIDER_ID;
551
+ algosdk: typeof _algosdk;
552
+ algodClient: _algosdk.Algodv2;
553
+ onlyIfTrusted: boolean;
554
+ network: Network;
555
+ };
556
+ declare type InitParams$3 = {
557
+ clientOptions?: ClientOptions$2;
558
+ algodOptions?: AlgodClientOptions;
559
+ algosdkStatic?: typeof _algosdk;
560
+ network?: Network;
182
561
  };
183
562
 
184
- declare const getWalletClient: (id: PROVIDER_ID | undefined) => Promise<WalletClient>;
563
+ declare class ExodusClient extends BaseClient {
564
+ #private;
565
+ network: Network;
566
+ constructor({ client, algosdk, algodClient, onlyIfTrusted, network, }: ExodusClientConstructor);
567
+ static metadata: {
568
+ id: PROVIDER_ID;
569
+ name: string;
570
+ icon: string;
571
+ isWalletConnect: boolean;
572
+ };
573
+ static init({ clientOptions, algodOptions, algosdkStatic, network, }: InitParams$3): Promise<ExodusClient | null>;
574
+ connect(): Promise<{
575
+ accounts: {
576
+ name: string;
577
+ address: string;
578
+ providerId: PROVIDER_ID;
579
+ }[];
580
+ id: PROVIDER_ID;
581
+ name: string;
582
+ icon: string;
583
+ isWalletConnect: boolean;
584
+ }>;
585
+ reconnect(onDisconnect: () => void): Promise<null>;
586
+ disconnect(): Promise<void>;
587
+ signTransactions(connectedAccounts: string[], transactions: Array<Uint8Array>): Promise<Uint8Array[]>;
588
+ /** @deprecated */
589
+ signEncodedTransactions(transactions: TransactionsArray): Promise<Uint8Array[]>;
590
+ }
591
+
592
+ declare type AlgoSignerTransaction = {
593
+ txn: string;
594
+ signers?: [];
595
+ multisig?: string;
596
+ };
597
+ declare type SupportedLedgers = "MainNet" | "TestNet" | "BetaNet" | string;
598
+ declare type AlgoSigner = {
599
+ connect: () => Promise<Record<string, never>>;
600
+ accounts: (ledger: {
601
+ ledger: SupportedLedgers;
602
+ }) => Promise<{
603
+ address: string;
604
+ }[]>;
605
+ signTxn: (transactions: AlgoSignerTransaction[]) => Promise<{
606
+ txID: string;
607
+ blob: string;
608
+ }[]>;
609
+ encoding: {
610
+ msgpackToBase64(transaction: Uint8Array): string;
611
+ byteArrayToString(transaction: Uint8Array): string;
612
+ };
613
+ };
614
+ declare type AlgoSignerClientConstructor = {
615
+ client: AlgoSigner;
616
+ id: PROVIDER_ID;
617
+ algosdk: typeof _algosdk;
618
+ algodClient: _algosdk.Algodv2;
619
+ network: SupportedLedgers;
620
+ };
621
+ declare type InitParams$2 = {
622
+ algodOptions?: AlgodClientOptions;
623
+ algosdkStatic?: typeof _algosdk;
624
+ network?: Network;
625
+ };
626
+
627
+ declare class AlgoSignerClient extends BaseClient {
628
+ #private;
629
+ network: Network;
630
+ constructor({ client, algosdk, algodClient, network, }: AlgoSignerClientConstructor);
631
+ static metadata: {
632
+ id: PROVIDER_ID;
633
+ name: string;
634
+ icon: string;
635
+ isWalletConnect: boolean;
636
+ };
637
+ static init({ algodOptions, algosdkStatic, network, }: InitParams$2): Promise<AlgoSignerClient | null>;
638
+ connect(): Promise<{
639
+ accounts: {
640
+ name: string;
641
+ address: string;
642
+ providerId: PROVIDER_ID;
643
+ }[];
644
+ id: PROVIDER_ID;
645
+ name: string;
646
+ icon: string;
647
+ isWalletConnect: boolean;
648
+ }>;
649
+ reconnect(onDisconnect: () => void): Promise<null>;
650
+ disconnect(): Promise<void>;
651
+ signTransactions(connectedAccounts: string[], transactions: Uint8Array[]): Promise<Uint8Array[]>;
652
+ /** @deprecated */
653
+ formatTransactionsArray(transactions: TransactionsArray): AlgoSignerTransaction[];
654
+ /** @deprecated */
655
+ signEncodedTransactions(transactions: TransactionsArray): Promise<Uint8Array[]>;
656
+ }
657
+
658
+ interface IClientMeta {
659
+ description: string;
660
+ url: string;
661
+ icons: string[];
662
+ name: string;
663
+ }
664
+ interface IWalletConnectSession {
665
+ connected: boolean;
666
+ accounts: string[];
667
+ chainId: number;
668
+ bridge: string;
669
+ key: string;
670
+ clientId: string;
671
+ clientMeta: IClientMeta | null;
672
+ peerId: string;
673
+ peerMeta: IClientMeta | null;
674
+ handshakeId: number;
675
+ handshakeTopic: string;
676
+ qrcodeModal: {
677
+ open: (uri: string, cb: any, qrcodeModalOptions?: any) => void;
678
+ close: () => void;
679
+ };
680
+ }
681
+ declare type ClientOptions$1 = {
682
+ bridge?: string;
683
+ uri?: string;
684
+ storageId?: string;
685
+ signingMethods?: string[];
686
+ session?: IWalletConnectSession;
687
+ clientMeta?: IClientMeta;
688
+ };
689
+ declare type WalletConnectTransaction = {
690
+ txn: string;
691
+ message?: string;
692
+ signers?: string[] | [];
693
+ };
694
+ declare type InitParams$1 = {
695
+ clientOptions?: ClientOptions$1;
696
+ algodOptions?: AlgodClientOptions;
697
+ clientStatic?: typeof WalletConnect;
698
+ modalStatic?: typeof QRCodeModal;
699
+ algosdkStatic?: typeof _algosdk;
700
+ network?: Network;
701
+ };
702
+ declare type WalletConnectClientConstructor = {
703
+ client: WalletConnect;
704
+ algosdk: typeof _algosdk;
705
+ algodClient: _algosdk.Algodv2;
706
+ network: Network;
707
+ };
708
+
709
+ declare class WalletConnectClient extends BaseClient {
710
+ #private;
711
+ network: Network;
712
+ constructor({ client, algosdk, algodClient, network, }: WalletConnectClientConstructor);
713
+ static metadata: {
714
+ id: PROVIDER_ID;
715
+ name: string;
716
+ icon: string;
717
+ isWalletConnect: boolean;
718
+ };
719
+ static init({ clientOptions, algodOptions, clientStatic, modalStatic, algosdkStatic, network, }: InitParams$1): Promise<WalletConnectClient | null>;
720
+ connect(): Promise<Wallet>;
721
+ reconnect(): Promise<{
722
+ accounts: {
723
+ name: string;
724
+ address: string;
725
+ providerId: PROVIDER_ID;
726
+ }[];
727
+ id: PROVIDER_ID;
728
+ name: string;
729
+ icon: string;
730
+ isWalletConnect: boolean;
731
+ } | null>;
732
+ check(): boolean;
733
+ disconnect(): Promise<void>;
734
+ signTransactions(connectedAccounts: string[], transactions: Uint8Array[]): Promise<Uint8Array[]>;
735
+ /** @deprecarted */
736
+ formatTransactionsArray(transactions: TransactionsArray): WalletConnectTransaction[];
737
+ /** @deprecated */
738
+ signEncodedTransactions(transactions: TransactionsArray): Promise<Uint8Array[]>;
739
+ }
740
+
741
+ declare type ClientOptions = {
742
+ wallet: string;
743
+ password: string;
744
+ host: string;
745
+ token: string;
746
+ port: string;
747
+ };
748
+ declare type KMDWalletClientConstructor = {
749
+ client: _algosdk.Kmd;
750
+ id: PROVIDER_ID;
751
+ algosdk: typeof _algosdk;
752
+ algodClient: _algosdk.Algodv2;
753
+ wallet: string;
754
+ password: string;
755
+ network: Network;
756
+ };
757
+ declare type InitParams = {
758
+ clientOptions?: ClientOptions;
759
+ algodOptions?: AlgodClientOptions;
760
+ algosdkStatic?: typeof _algosdk;
761
+ network?: Network;
762
+ };
763
+
764
+ declare class KMDWalletClient extends BaseClient {
765
+ #private;
766
+ walletId: string;
767
+ id: PROVIDER_ID;
768
+ network: Network;
769
+ constructor({ client, id, wallet, password, algosdk, algodClient, network, }: KMDWalletClientConstructor);
770
+ static metadata: {
771
+ id: PROVIDER_ID;
772
+ name: string;
773
+ icon: string;
774
+ isWalletConnect: boolean;
775
+ };
776
+ static init({ clientOptions, algodOptions, algosdkStatic, network, }: InitParams): Promise<KMDWalletClient | null>;
777
+ connect(): Promise<Wallet>;
778
+ disconnect(): Promise<void>;
779
+ reconnect(): Promise<Wallet | null>;
780
+ requestPassword(): Promise<string>;
781
+ getWalletToken(walletId: string, password: string): Promise<string>;
782
+ releaseToken(token: string): Promise<void>;
783
+ listWallets(): Promise<Record<string, string>>;
784
+ listAccounts(wallet: string, password: string): Promise<Array<Account>>;
785
+ signTransactions(connectedAccounts: string[], transactions: Uint8Array[]): Promise<Uint8Array[]>;
786
+ signEncodedTransactions(transactions: TransactionsArray): Promise<Uint8Array[]>;
787
+ }
185
788
 
186
- export { Account, AccountInfo, Asset, ConfirmedTxn, DecodedSignedTransaction, DecodedTransaction, KMD_HOST, KMD_PASSWORD, KMD_PORT, KMD_TOKEN, KMD_WALLET, NODE_NETWORK, NODE_PORT, NODE_SERVER, NODE_TOKEN, PROVIDER_ID, Provider, TransactionsArray, Txn, TxnInfo, TxnType, Wallet, WalletClient, WalletProvider, getWalletClient, useConnectWallet, useWallet };
789
+ export { Account, AccountInfo, AlgodClientOptions, Asset, ConfirmedTxn, DEFAULT_NETWORK, DEFAULT_NODE_BASEURL, DEFAULT_NODE_PORT, DEFAULT_NODE_TOKEN, DecodedSignedTransaction, DecodedTransaction, Network, PROVIDER_ID, Provider, TransactionsArray, Txn, TxnInfo, TxnType, Wallet, WalletClient, _default as WalletProvider, AlgoSignerClient as algosigner, DeflyWalletClient as defly, ExodusClient as exodus, initializeProviders, KMDWalletClient as kmd, MyAlgoWalletClient as myalgo, PeraWalletClient as pera, reconnectProviders, useWallet, WalletConnectClient as walletconnect };