@txnlab/use-wallet 2.8.0 → 3.0.0-beta.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.
Files changed (203) hide show
  1. package/README.md +3 -1009
  2. package/dist/index.cjs +2060 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +511 -0
  5. package/dist/index.d.ts +429 -895
  6. package/dist/index.js +2012 -0
  7. package/dist/index.js.map +1 -0
  8. package/package.json +50 -119
  9. package/dist/cjs/index.js +0 -3934
  10. package/dist/cjs/index.js.map +0 -1
  11. package/dist/cjs/jest.config.d.ts +0 -11
  12. package/dist/cjs/jest.setup.d.ts +0 -0
  13. package/dist/cjs/src/algod/index.d.ts +0 -10
  14. package/dist/cjs/src/clients/algosigner/client.d.ts +0 -37
  15. package/dist/cjs/src/clients/algosigner/constants.d.ts +0 -2
  16. package/dist/cjs/src/clients/algosigner/index.d.ts +0 -2
  17. package/dist/cjs/src/clients/algosigner/types.d.ts +0 -39
  18. package/dist/cjs/src/clients/base/base.d.ts +0 -46
  19. package/dist/cjs/src/clients/base/index.d.ts +0 -2
  20. package/dist/cjs/src/clients/custom/client.d.ts +0 -18
  21. package/dist/cjs/src/clients/custom/constants.d.ts +0 -1
  22. package/dist/cjs/src/clients/custom/index.d.ts +0 -2
  23. package/dist/cjs/src/clients/custom/types.d.ts +0 -25
  24. package/dist/cjs/src/clients/daffi/client.d.ts +0 -34
  25. package/dist/cjs/src/clients/daffi/constants.d.ts +0 -1
  26. package/dist/cjs/src/clients/daffi/index.d.ts +0 -2
  27. package/dist/cjs/src/clients/daffi/types.d.ts +0 -27
  28. package/dist/cjs/src/clients/defly/client.d.ts +0 -34
  29. package/dist/cjs/src/clients/defly/constants.d.ts +0 -1
  30. package/dist/cjs/src/clients/defly/index.d.ts +0 -2
  31. package/dist/cjs/src/clients/defly/types.d.ts +0 -32
  32. package/dist/cjs/src/clients/exodus/client.d.ts +0 -33
  33. package/dist/cjs/src/clients/exodus/constants.d.ts +0 -1
  34. package/dist/cjs/src/clients/exodus/index.d.ts +0 -2
  35. package/dist/cjs/src/clients/exodus/types.d.ts +0 -34
  36. package/dist/cjs/src/clients/index.d.ts +0 -19
  37. package/dist/cjs/src/clients/kibisis/client.d.ts +0 -73
  38. package/dist/cjs/src/clients/kibisis/constants.d.ts +0 -37
  39. package/dist/cjs/src/clients/kibisis/index.d.ts +0 -2
  40. package/dist/cjs/src/clients/kibisis/types.d.ts +0 -86
  41. package/dist/cjs/src/clients/kibisis/utils.d.ts +0 -9
  42. package/dist/cjs/src/clients/kibisis/utils.test.d.ts +0 -1
  43. package/dist/cjs/src/clients/kmd/client.d.ts +0 -30
  44. package/dist/cjs/src/clients/kmd/constants.d.ts +0 -1
  45. package/dist/cjs/src/clients/kmd/index.d.ts +0 -2
  46. package/dist/cjs/src/clients/kmd/types.d.ts +0 -32
  47. package/dist/cjs/src/clients/lute/client.d.ts +0 -34
  48. package/dist/cjs/src/clients/lute/constants.d.ts +0 -1
  49. package/dist/cjs/src/clients/lute/index.d.ts +0 -2
  50. package/dist/cjs/src/clients/lute/types.d.ts +0 -15
  51. package/dist/cjs/src/clients/magic/client.d.ts +0 -35
  52. package/dist/cjs/src/clients/magic/constants.d.ts +0 -1
  53. package/dist/cjs/src/clients/magic/index.d.ts +0 -2
  54. package/dist/cjs/src/clients/magic/types.d.ts +0 -27
  55. package/dist/cjs/src/clients/mnemonic/client.d.ts +0 -35
  56. package/dist/cjs/src/clients/mnemonic/constants.d.ts +0 -1
  57. package/dist/cjs/src/clients/mnemonic/index.d.ts +0 -2
  58. package/dist/cjs/src/clients/mnemonic/types.d.ts +0 -21
  59. package/dist/cjs/src/clients/myalgo/client.d.ts +0 -33
  60. package/dist/cjs/src/clients/myalgo/constants.d.ts +0 -1
  61. package/dist/cjs/src/clients/myalgo/index.d.ts +0 -2
  62. package/dist/cjs/src/clients/myalgo/types.d.ts +0 -19
  63. package/dist/cjs/src/clients/pera/client.d.ts +0 -34
  64. package/dist/cjs/src/clients/pera/constants.d.ts +0 -1
  65. package/dist/cjs/src/clients/pera/index.d.ts +0 -2
  66. package/dist/cjs/src/clients/pera/types.d.ts +0 -27
  67. package/dist/cjs/src/clients/walletconnect2/client.d.ts +0 -36
  68. package/dist/cjs/src/clients/walletconnect2/constants.d.ts +0 -5
  69. package/dist/cjs/src/clients/walletconnect2/index.d.ts +0 -2
  70. package/dist/cjs/src/clients/walletconnect2/types.d.ts +0 -28
  71. package/dist/cjs/src/clients/walletconnect2/utils.d.ts +0 -2
  72. package/dist/cjs/src/constants/constants.d.ts +0 -20
  73. package/dist/cjs/src/constants/index.d.ts +0 -1
  74. package/dist/cjs/src/context/WalletContext.d.ts +0 -8
  75. package/dist/cjs/src/hooks/index.d.ts +0 -2
  76. package/dist/cjs/src/hooks/useInitializeProviders.d.ts +0 -10
  77. package/dist/cjs/src/hooks/useInitializeProviders.test.d.ts +0 -4
  78. package/dist/cjs/src/hooks/useWallet.d.ts +0 -31
  79. package/dist/cjs/src/hooks/useWallet.test.d.ts +0 -4
  80. package/dist/cjs/src/index.d.ts +0 -6
  81. package/dist/cjs/src/media/audio.d.ts +0 -1
  82. package/dist/cjs/src/store/index.d.ts +0 -2
  83. package/dist/cjs/src/store/state/debugStore.d.ts +0 -6
  84. package/dist/cjs/src/store/state/walletStore.d.ts +0 -52
  85. package/dist/cjs/src/testUtils/mockAccounts.d.ts +0 -3
  86. package/dist/cjs/src/testUtils/mockClients.d.ts +0 -45
  87. package/dist/cjs/src/types/api.d.ts +0 -14
  88. package/dist/cjs/src/types/index.d.ts +0 -4
  89. package/dist/cjs/src/types/node.d.ts +0 -44
  90. package/dist/cjs/src/types/providers.d.ts +0 -148
  91. package/dist/cjs/src/types/utilities.d.ts +0 -1
  92. package/dist/cjs/src/types/wallet.d.ts +0 -54
  93. package/dist/cjs/src/utils/clearAccounts.d.ts +0 -2
  94. package/dist/cjs/src/utils/clearAccounts.test.d.ts +0 -1
  95. package/dist/cjs/src/utils/debugLog.d.ts +0 -3
  96. package/dist/cjs/src/utils/encodeNFDTransactionArray.spec.d.ts +0 -1
  97. package/dist/cjs/src/utils/encodeNFDTransactionsArray.d.ts +0 -2
  98. package/dist/cjs/src/utils/index.d.ts +0 -3
  99. package/dist/cjs/src/utils/initializeProviders.d.ts +0 -3
  100. package/dist/cjs/src/utils/initializeProviders.test.d.ts +0 -4
  101. package/dist/cjs/src/utils/providers.d.ts +0 -3
  102. package/dist/cjs/src/utils/providers.spec.d.ts +0 -1
  103. package/dist/cjs/src/utils/reconnectProviders.d.ts +0 -2
  104. package/dist/cjs/src/utils/reconnectProviders.test.d.ts +0 -1
  105. package/dist/cjs/src/utils/svgToBase64.d.ts +0 -1
  106. package/dist/cjs/src/utils/types.d.ts +0 -2
  107. package/dist/esm/index.js +0 -3911
  108. package/dist/esm/jest.config.d.ts +0 -11
  109. package/dist/esm/jest.setup.d.ts +0 -0
  110. package/dist/esm/src/algod/index.d.ts +0 -10
  111. package/dist/esm/src/clients/algosigner/client.d.ts +0 -37
  112. package/dist/esm/src/clients/algosigner/constants.d.ts +0 -2
  113. package/dist/esm/src/clients/algosigner/index.d.ts +0 -2
  114. package/dist/esm/src/clients/algosigner/types.d.ts +0 -39
  115. package/dist/esm/src/clients/base/base.d.ts +0 -46
  116. package/dist/esm/src/clients/base/index.d.ts +0 -2
  117. package/dist/esm/src/clients/custom/client.d.ts +0 -18
  118. package/dist/esm/src/clients/custom/constants.d.ts +0 -1
  119. package/dist/esm/src/clients/custom/index.d.ts +0 -2
  120. package/dist/esm/src/clients/custom/types.d.ts +0 -25
  121. package/dist/esm/src/clients/daffi/client.d.ts +0 -34
  122. package/dist/esm/src/clients/daffi/constants.d.ts +0 -1
  123. package/dist/esm/src/clients/daffi/index.d.ts +0 -2
  124. package/dist/esm/src/clients/daffi/types.d.ts +0 -27
  125. package/dist/esm/src/clients/defly/client.d.ts +0 -34
  126. package/dist/esm/src/clients/defly/constants.d.ts +0 -1
  127. package/dist/esm/src/clients/defly/index.d.ts +0 -2
  128. package/dist/esm/src/clients/defly/types.d.ts +0 -32
  129. package/dist/esm/src/clients/exodus/client.d.ts +0 -33
  130. package/dist/esm/src/clients/exodus/constants.d.ts +0 -1
  131. package/dist/esm/src/clients/exodus/index.d.ts +0 -2
  132. package/dist/esm/src/clients/exodus/types.d.ts +0 -34
  133. package/dist/esm/src/clients/index.d.ts +0 -19
  134. package/dist/esm/src/clients/kibisis/client.d.ts +0 -73
  135. package/dist/esm/src/clients/kibisis/constants.d.ts +0 -37
  136. package/dist/esm/src/clients/kibisis/index.d.ts +0 -2
  137. package/dist/esm/src/clients/kibisis/types.d.ts +0 -86
  138. package/dist/esm/src/clients/kibisis/utils.d.ts +0 -9
  139. package/dist/esm/src/clients/kibisis/utils.test.d.ts +0 -1
  140. package/dist/esm/src/clients/kmd/client.d.ts +0 -30
  141. package/dist/esm/src/clients/kmd/constants.d.ts +0 -1
  142. package/dist/esm/src/clients/kmd/index.d.ts +0 -2
  143. package/dist/esm/src/clients/kmd/types.d.ts +0 -32
  144. package/dist/esm/src/clients/lute/client.d.ts +0 -34
  145. package/dist/esm/src/clients/lute/constants.d.ts +0 -1
  146. package/dist/esm/src/clients/lute/index.d.ts +0 -2
  147. package/dist/esm/src/clients/lute/types.d.ts +0 -15
  148. package/dist/esm/src/clients/magic/client.d.ts +0 -35
  149. package/dist/esm/src/clients/magic/constants.d.ts +0 -1
  150. package/dist/esm/src/clients/magic/index.d.ts +0 -2
  151. package/dist/esm/src/clients/magic/types.d.ts +0 -27
  152. package/dist/esm/src/clients/mnemonic/client.d.ts +0 -35
  153. package/dist/esm/src/clients/mnemonic/constants.d.ts +0 -1
  154. package/dist/esm/src/clients/mnemonic/index.d.ts +0 -2
  155. package/dist/esm/src/clients/mnemonic/types.d.ts +0 -21
  156. package/dist/esm/src/clients/myalgo/client.d.ts +0 -33
  157. package/dist/esm/src/clients/myalgo/constants.d.ts +0 -1
  158. package/dist/esm/src/clients/myalgo/index.d.ts +0 -2
  159. package/dist/esm/src/clients/myalgo/types.d.ts +0 -19
  160. package/dist/esm/src/clients/pera/client.d.ts +0 -34
  161. package/dist/esm/src/clients/pera/constants.d.ts +0 -1
  162. package/dist/esm/src/clients/pera/index.d.ts +0 -2
  163. package/dist/esm/src/clients/pera/types.d.ts +0 -27
  164. package/dist/esm/src/clients/walletconnect2/client.d.ts +0 -36
  165. package/dist/esm/src/clients/walletconnect2/constants.d.ts +0 -5
  166. package/dist/esm/src/clients/walletconnect2/index.d.ts +0 -2
  167. package/dist/esm/src/clients/walletconnect2/types.d.ts +0 -28
  168. package/dist/esm/src/clients/walletconnect2/utils.d.ts +0 -2
  169. package/dist/esm/src/constants/constants.d.ts +0 -20
  170. package/dist/esm/src/constants/index.d.ts +0 -1
  171. package/dist/esm/src/context/WalletContext.d.ts +0 -8
  172. package/dist/esm/src/hooks/index.d.ts +0 -2
  173. package/dist/esm/src/hooks/useInitializeProviders.d.ts +0 -10
  174. package/dist/esm/src/hooks/useInitializeProviders.test.d.ts +0 -4
  175. package/dist/esm/src/hooks/useWallet.d.ts +0 -31
  176. package/dist/esm/src/hooks/useWallet.test.d.ts +0 -4
  177. package/dist/esm/src/index.d.ts +0 -6
  178. package/dist/esm/src/media/audio.d.ts +0 -1
  179. package/dist/esm/src/store/index.d.ts +0 -2
  180. package/dist/esm/src/store/state/debugStore.d.ts +0 -6
  181. package/dist/esm/src/store/state/walletStore.d.ts +0 -52
  182. package/dist/esm/src/testUtils/mockAccounts.d.ts +0 -3
  183. package/dist/esm/src/testUtils/mockClients.d.ts +0 -45
  184. package/dist/esm/src/types/api.d.ts +0 -14
  185. package/dist/esm/src/types/index.d.ts +0 -4
  186. package/dist/esm/src/types/node.d.ts +0 -44
  187. package/dist/esm/src/types/providers.d.ts +0 -148
  188. package/dist/esm/src/types/utilities.d.ts +0 -1
  189. package/dist/esm/src/types/wallet.d.ts +0 -54
  190. package/dist/esm/src/utils/clearAccounts.d.ts +0 -2
  191. package/dist/esm/src/utils/clearAccounts.test.d.ts +0 -1
  192. package/dist/esm/src/utils/debugLog.d.ts +0 -3
  193. package/dist/esm/src/utils/encodeNFDTransactionArray.spec.d.ts +0 -1
  194. package/dist/esm/src/utils/encodeNFDTransactionsArray.d.ts +0 -2
  195. package/dist/esm/src/utils/index.d.ts +0 -3
  196. package/dist/esm/src/utils/initializeProviders.d.ts +0 -3
  197. package/dist/esm/src/utils/initializeProviders.test.d.ts +0 -4
  198. package/dist/esm/src/utils/providers.d.ts +0 -3
  199. package/dist/esm/src/utils/providers.spec.d.ts +0 -1
  200. package/dist/esm/src/utils/reconnectProviders.d.ts +0 -2
  201. package/dist/esm/src/utils/reconnectProviders.test.d.ts +0 -1
  202. package/dist/esm/src/utils/svgToBase64.d.ts +0 -1
  203. package/dist/esm/src/utils/types.d.ts +0 -2
package/dist/index.d.ts CHANGED
@@ -1,977 +1,511 @@
1
+ import { Store } from '@tanstack/store';
1
2
  import algosdk from 'algosdk';
2
- import { PeraWalletConnect } from '@perawallet/connect';
3
- import { DeflyWalletConnect } from '@blockshake/defly-connect';
4
- import { DaffiWalletConnect } from '@daffiwallet/connect';
5
- import LuteConnect from 'lute-connect';
6
- import { Magic } from 'magic-sdk';
7
- import { AlgorandExtension } from '@magic-ext/algorand';
8
- import MyAlgoConnect from '@randlabs/myalgo-connect';
9
- import { WalletConnectModalSignOptions, WalletConnectModalSign } from '@walletconnect/modal-sign-html';
10
- import React from 'react';
11
- import * as zustand_middleware from 'zustand/middleware';
12
- import * as immer_dist_internal from 'immer/dist/internal';
13
- import * as zustand from 'zustand';
14
- import { InstanceWithExtensions, SDKBase } from '@magic-sdk/provider';
15
-
16
- type PublicNetwork = 'betanet' | 'testnet' | 'mainnet';
17
- type Network = PublicNetwork | string;
18
- type Txn = {
19
- apaa: Uint8Array;
20
- apas: number[];
21
- apid: number;
22
- fee: number;
23
- fv: number;
24
- gen: string;
25
- gh: Uint8Array;
26
- grp: Uint8Array;
27
- lv: number;
28
- snd: Uint8Array;
29
- type: string;
30
- };
31
- type ConfirmedTxn = {
32
- 'confirmed-round': number;
33
- 'global-state-delta': Record<string, unknown>[];
34
- 'pool-error': string;
35
- txn: {
36
- sig: Uint8Array;
37
- txn: Txn;
38
- };
39
- };
40
- type TxnType = 'pay' | 'keyreg' | 'acfg' | 'axfer' | 'afrz' | 'appl' | 'stpf';
41
- type DecodedTransaction = {
42
- amt: number;
43
- fee: number;
44
- fv: number;
45
- gen: string;
46
- gh: Uint8Array;
47
- grp: Uint8Array;
48
- lv: number;
49
- note: Uint8Array;
50
- rcv: Uint8Array;
51
- snd: Uint8Array;
52
- type: TxnType;
53
- };
54
- type DecodedSignedTransaction = {
55
- sig: Uint8Array;
56
- txn: DecodedTransaction;
57
- };
58
- type AlgodClientOptions = ConstructorParameters<typeof algosdk.Algodv2>;
59
-
60
- type TransactionsArray = ['u' | 's', string][];
61
- type TxnInfo = {
62
- groupIndex: number;
63
- amount: number;
64
- from: string;
65
- to: string;
66
- type: TxnType;
67
- txn: string;
68
- signedTxn?: Uint8Array;
69
- };
70
- type RawTxnResponse = {
71
- txId: string;
72
- };
73
-
74
- declare enum PROVIDER_ID {
75
- KMD = "kmd",
76
- CUSTOM = "custom",
77
- PERA = "pera",
78
- DAFFI = "daffi",
79
- LUTE = "lute",
80
- MYALGO = "myalgo",
81
- ALGOSIGNER = "algosigner",
82
- DEFLY = "defly",
83
- EXODUS = "exodus",
84
- KIBISIS = "kibisis",
85
- WALLETCONNECT = "walletconnect",
86
- MNEMONIC = "mnemonic",
87
- MAGIC = "magic"
3
+ import { WalletConnectModalConfig } from '@walletconnect/modal';
4
+ import { SignClientTypes } from '@walletconnect/types';
5
+
6
+ declare enum NetworkId {
7
+ MAINNET = "mainnet",
8
+ TESTNET = "testnet",
9
+ BETANET = "betanet",
10
+ LOCALNET = "localnet"
88
11
  }
89
- declare const DEFAULT_NETWORK: Network;
90
- declare const DEFAULT_NODE_BASEURL = "https://mainnet-api.algonode.cloud";
91
- declare const DEFAULT_NODE_TOKEN = "";
92
- declare const DEFAULT_NODE_PORT = "";
93
-
94
- interface Account {
95
- providerId: PROVIDER_ID;
96
- name: string;
97
- address: string;
98
- authAddr?: string;
99
- email?: string;
12
+ interface AlgodConfig {
13
+ token: string | algosdk.AlgodTokenHeader | algosdk.CustomTokenHeader | algosdk.BaseHTTPClient;
14
+ baseServer: string;
15
+ port?: string | number;
16
+ headers?: Record<string, string>;
100
17
  }
101
- type Provider = {
102
- accounts: Account[];
103
- isActive: boolean;
104
- isConnected: boolean;
105
- connect: (arg?: any, throws?: boolean) => Promise<void>;
106
- disconnect: () => Promise<void>;
107
- reconnect: () => Promise<void>;
108
- setActiveProvider: () => void;
109
- setActiveAccount: (account: string) => void;
110
- metadata: Metadata;
111
- };
112
- type Asset = {
113
- amount: number;
114
- 'asset-id': number;
115
- creator: string;
116
- 'is-frozen': boolean;
117
- 'unit-name': string;
118
- name: string;
119
- };
120
- type AccountInfo = {
121
- address: string;
122
- amount: number;
123
- 'min-balance': number;
124
- 'auth-addr'?: string;
125
- assets?: Asset[];
126
- };
127
- type WalletProvider$1 = {
128
- id: PROVIDER_ID;
129
- name: string;
130
- icon: string;
131
- isWalletConnect: boolean;
132
- };
133
- type ExtendValues<Type> = {
134
- [Property in keyof Type]: Type[Property] | null;
135
- };
136
- type Wallet = ExtendValues<WalletProvider$1> & {
137
- accounts: Account[];
138
- };
139
- type Metadata = {
140
- id: PROVIDER_ID;
141
- name: string;
142
- icon: string;
143
- isWalletConnect: boolean;
144
- };
145
- type ClientOptions = Record<string, any>;
18
+ type NetworkConfigMap = Record<NetworkId, AlgodConfig>;
19
+ type NetworkConfig = Partial<AlgodConfig> | Partial<Record<NetworkId, Partial<AlgodConfig>>>;
146
20
 
147
- type PeraWalletConnectOptions = {
21
+ interface DeflyWalletConnectOptions {
148
22
  bridge?: string;
149
23
  shouldShowSignTxnToast?: boolean;
150
24
  chainId?: 416001 | 416002 | 416003 | 4160;
151
- };
152
- type PeraWalletClientConstructor = {
153
- metadata: Metadata;
154
- client: PeraWalletConnect;
155
- clientOptions?: PeraWalletConnectOptions;
156
- algosdk: typeof algosdk;
157
- algodClient: algosdk.Algodv2;
158
- network: Network;
159
- };
160
-
161
- type DeflyWalletConnectOptions = {
162
- bridge?: string;
163
- deep_link?: string;
164
- app_meta?: {
165
- logo: string;
166
- name: string;
167
- main_color: string;
168
- };
169
- shouldShowSignTxnToast?: boolean;
170
- };
171
- type DeflyWalletClientConstructor = {
172
- metadata: Metadata;
173
- client: DeflyWalletConnect;
174
- clientOptions?: DeflyWalletConnectOptions;
175
- algosdk: typeof algosdk;
176
- algodClient: algosdk.Algodv2;
177
- network: Network;
178
- };
179
-
180
- type ExodusOptions = {
181
- onlyIfTrusted: boolean;
182
- };
183
- type Bytes = Readonly<Uint8Array>;
184
- type Exodus = {
185
- isConnected: boolean;
186
- address: string | null;
187
- connect: ({ onlyIfTrusted }: {
188
- onlyIfTrusted: boolean;
189
- }) => Promise<{
190
- address: string;
191
- }>;
192
- disconnect: () => void;
193
- signAndSendTransaction(transactions: Bytes[]): Promise<{
194
- txId: string;
195
- }>;
196
- signTransaction(transactions: Bytes[]): Promise<Bytes[]>;
197
- };
198
- type ExodusClientConstructor = {
199
- metadata: Metadata;
200
- client: Exodus;
201
- clientOptions: ExodusOptions;
202
- algosdk: typeof algosdk;
203
- algodClient: algosdk.Algodv2;
204
- network: Network;
205
- };
206
-
207
- type KmdOptions = {
208
- wallet: string;
209
- password: string;
210
- host: string;
211
- token: string;
212
- port: string;
213
- };
214
- type KMDWalletClientConstructor = {
215
- metadata: Metadata;
216
- client: algosdk.Kmd;
217
- algosdk: typeof algosdk;
218
- algodClient: algosdk.Algodv2;
219
- wallet: string;
220
- password: string;
221
- network: Network;
222
- };
223
-
224
- type LuteConnectOptions = {
225
- siteName: string;
226
- };
227
- type LuteClientConstructor = {
228
- metadata: Metadata;
229
- client: LuteConnect;
230
- clientOptions?: LuteConnectOptions;
231
- algosdk: typeof algosdk;
232
- algodClient: algosdk.Algodv2;
233
- network: Network;
234
- };
235
-
236
- /**
237
- * Helpful resources:
238
- * https://github.com/randlabs/myalgo-connect
239
- */
240
-
241
- type MyAlgoConnectOptions = {
242
- disableLedgerNano: boolean;
243
- };
244
- type MyAlgoWalletClientConstructor = {
245
- metadata: Metadata;
246
- client: MyAlgoConnect;
247
- clientOptions?: MyAlgoConnectOptions;
248
- algosdk: typeof algosdk;
249
- algodClient: algosdk.Algodv2;
250
- network: Network;
251
- };
252
-
253
- type DaffiWalletConnectOptions = {
254
- bridge?: string;
255
- shouldShowSignTxnToast?: boolean;
256
- chainId?: 416001 | 416002 | 416003 | 4160;
257
- };
258
-
259
- type NonEmptyArray<T> = [T, ...T[]];
260
-
261
- declare abstract class BaseClient {
262
- algosdk: typeof algosdk;
263
- algodClient: algosdk.Algodv2;
264
- clientOptions?: ClientOptions;
265
- keepWCAlive: HTMLAudioElement;
266
- metadata: Metadata;
267
- static metadata: Metadata;
268
- abstract connect(onDisconnect: () => void, arg?: any): Promise<Wallet>;
269
- abstract disconnect(): Promise<void>;
270
- abstract reconnect(onDisconnect: () => void): Promise<Wallet | null>;
271
- abstract signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
272
- protected constructor(metadata: Metadata, algosdk: typeof algosdk, algodClient: algosdk.Algodv2, clientOptions?: ClientOptions);
273
- healthCheck(): Promise<{}>;
274
- getAccountInfo(address: string): Promise<AccountInfo>;
275
- getAssets(address: string): Promise<Asset[]>;
276
- waitForConfirmation(txId: string, timeout?: number): Promise<{
277
- 'confirmed-round': number;
278
- 'global-state-delta': Record<string, unknown>[];
279
- 'pool-error': string;
280
- txn: {
281
- sig: Uint8Array;
282
- txn: Txn;
283
- };
284
- txId: string;
285
- }>;
286
- decodeTransaction: (txn: string, isSigned: boolean) => algosdk.Transaction;
287
- logEncodedTransaction(txn: string, isSigned: boolean): void;
288
- groupTransactionsBySender(transactions: TransactionsArray): Record<string, TxnInfo[]>;
289
- sendRawTransactions(transactions: Uint8Array[], waitRoundsToConfirm?: number): Promise<{
290
- 'confirmed-round': number;
291
- 'global-state-delta': Record<string, unknown>[];
292
- 'pool-error': string;
293
- txn: {
294
- sig: Uint8Array;
295
- txn: Txn;
296
- };
297
- txId: string;
298
- id: string;
299
- }>;
300
- keepWCAliveStart(): Promise<void>;
301
- keepWCAliveStop(): void;
302
- }
303
-
304
- type CustomOptions = {
305
- name: string;
306
- icon?: string;
307
- getProvider: (params: {
308
- network?: Network;
309
- algod?: algosdk.Algodv2;
310
- algosdkStatic?: typeof algosdk;
311
- }) => CustomProvider;
312
- };
313
- type CustomProvider = {
314
- connect(metadata: Metadata): Promise<Wallet>;
315
- disconnect(): Promise<void>;
316
- reconnect(metadata: Metadata): Promise<Wallet | null>;
317
- signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
318
- };
319
- type CustomWalletClientConstructor = {
320
- providerProxy: CustomProvider;
321
- metadata: Metadata;
322
- algosdk: typeof algosdk;
323
- algodClient: algosdk.Algodv2;
324
- network: Network;
325
- };
326
-
327
- type ProviderConfigMapping = {
328
- [PROVIDER_ID.PERA]: {
329
- clientOptions?: PeraWalletConnectOptions;
330
- clientStatic?: typeof PeraWalletConnect;
331
- getDynamicClient?: () => Promise<typeof PeraWalletConnect>;
332
- };
333
- [PROVIDER_ID.DAFFI]: {
334
- clientOptions?: DaffiWalletConnectOptions;
335
- clientStatic?: typeof DaffiWalletConnect;
336
- getDynamicClient?: () => Promise<typeof DaffiWalletConnect>;
337
- };
338
- [PROVIDER_ID.DEFLY]: {
339
- clientOptions?: DeflyWalletConnectOptions;
340
- clientStatic?: typeof DeflyWalletConnect;
341
- getDynamicClient?: () => Promise<typeof DeflyWalletConnect>;
342
- };
343
- [PROVIDER_ID.WALLETCONNECT]: {
344
- clientOptions?: WalletConnectModalSignOptions;
345
- clientStatic?: typeof WalletConnectModalSign;
346
- getDynamicClient?: () => Promise<typeof WalletConnectModalSign>;
347
- };
348
- [PROVIDER_ID.LUTE]: {
349
- clientOptions?: LuteConnectOptions;
350
- clientStatic?: typeof LuteConnect;
351
- getDynamicClient?: () => Promise<typeof LuteConnect>;
352
- };
353
- [PROVIDER_ID.MYALGO]: {
354
- clientOptions?: MyAlgoConnectOptions;
355
- clientStatic?: typeof MyAlgoConnect;
356
- getDynamicClient?: () => Promise<typeof MyAlgoConnect>;
357
- };
358
- [PROVIDER_ID.EXODUS]: {
359
- clientOptions?: ExodusOptions;
360
- clientStatic?: undefined;
361
- getDynamicClient?: undefined;
362
- };
363
- [PROVIDER_ID.KMD]: {
364
- clientOptions?: KmdOptions;
365
- clientStatic?: undefined;
366
- getDynamicClient?: undefined;
367
- };
368
- [PROVIDER_ID.CUSTOM]: {
369
- clientOptions?: CustomOptions;
370
- clientStatic?: undefined;
371
- getDynamicClient?: undefined;
372
- };
373
- [PROVIDER_ID.ALGOSIGNER]: {
374
- clientOptions?: undefined;
375
- clientStatic?: undefined;
376
- getDynamicClient?: undefined;
377
- };
378
- [PROVIDER_ID.MNEMONIC]: {
379
- clientOptions?: undefined;
380
- clientStatic?: undefined;
381
- getDynamicClient?: undefined;
382
- };
383
- [PROVIDER_ID.KIBISIS]: {
384
- clientOptions?: undefined;
385
- clientStatic?: undefined;
386
- getDynamicClient?: undefined;
387
- };
388
- [PROVIDER_ID.MAGIC]: {
389
- clientOptions?: {
390
- apiKey: string;
391
- };
392
- clientStatic?: undefined;
393
- getDynamicClient?: () => Promise<typeof Magic>;
394
- extensionStatic?: typeof AlgorandExtension;
395
- getDynamicExtension?: () => Promise<typeof AlgorandExtension>;
396
- };
397
- };
398
- /**
399
- * Enforces correct configuration given for each provider. For example,
400
- * if `id` is `PROVIDER_ID.PERA`, then `clientOptions` must be of type
401
- * `PeraWalletConnectOptions`.
402
- *
403
- * @todo install `tsd` to test TypeScript type definitions in CI
404
- */
405
- type ProviderConfig<T extends keyof ProviderConfigMapping> = {
406
- [K in T]: {
407
- id: K;
408
- } & ProviderConfigMapping[K];
409
- }[T];
410
- type CommonInitParams = {
411
- network?: Network;
412
- algodOptions?: AlgodClientOptions;
413
- algosdkStatic?: typeof algosdk;
414
- };
415
- type InitParams<T extends keyof ProviderConfigMapping> = CommonInitParams & ProviderConfigMapping[T];
416
- type NodeConfig = {
417
- network: Network;
418
- nodeServer: string;
419
- nodeToken?: string | algosdk.AlgodTokenHeader | algosdk.CustomTokenHeader | algosdk.BaseHTTPClient;
420
- nodePort?: string | number;
421
- nodeHeaders?: Record<string, string>;
422
- };
423
- type StaticClient<T> = {
424
- clientStatic: T;
425
- getDynamicClient?: undefined;
426
- };
427
- type DynamicClient<T> = {
428
- clientStatic?: undefined;
429
- getDynamicClient: () => Promise<T>;
430
- };
431
- type OneOfStaticOrDynamicClient<T> = StaticClient<T> | DynamicClient<T>;
432
- type StaticAlgoExtension<T> = {
433
- extensionStatic: T;
434
- getDynamicExtension?: undefined;
435
- };
436
- type DynamicAlgoExtension<T> = {
437
- extensionStatic?: undefined;
438
- getDynamicExtension: () => Promise<T>;
439
- };
440
- type OneOfStaticOrDynamicAlgoExtension<T> = StaticAlgoExtension<T> | DynamicAlgoExtension<T>;
441
- type ProviderDef = (ProviderConfig<PROVIDER_ID.PERA> & OneOfStaticOrDynamicClient<typeof PeraWalletConnect>) | (ProviderConfig<PROVIDER_ID.MAGIC> & OneOfStaticOrDynamicClient<typeof Magic> & OneOfStaticOrDynamicAlgoExtension<typeof AlgorandExtension> & {
442
- clientOptions: {
443
- apiKey: string;
444
- };
445
- }) | (ProviderConfig<PROVIDER_ID.DEFLY> & OneOfStaticOrDynamicClient<typeof DeflyWalletConnect>) | (ProviderConfig<PROVIDER_ID.DAFFI> & OneOfStaticOrDynamicClient<typeof DaffiWalletConnect>) | (ProviderConfig<PROVIDER_ID.LUTE> & OneOfStaticOrDynamicClient<typeof LuteConnect> & {
446
- clientOptions: LuteConnectOptions;
447
- }) | (ProviderConfig<PROVIDER_ID.WALLETCONNECT> & OneOfStaticOrDynamicClient<typeof WalletConnectModalSign> & {
448
- clientOptions: WalletConnectModalSignOptions;
449
- }) | (ProviderConfig<PROVIDER_ID.MYALGO> & OneOfStaticOrDynamicClient<typeof MyAlgoConnect>) | ProviderConfig<PROVIDER_ID.EXODUS> | ProviderConfig<PROVIDER_ID.KMD> | ProviderConfig<PROVIDER_ID.CUSTOM> | ProviderConfig<PROVIDER_ID.KIBISIS> | PROVIDER_ID.EXODUS | PROVIDER_ID.KMD | PROVIDER_ID.ALGOSIGNER | PROVIDER_ID.MNEMONIC | PROVIDER_ID.CUSTOM | PROVIDER_ID.KIBISIS;
450
- type ProvidersArray = NonEmptyArray<ProviderDef>;
451
- type WalletClient = BaseClient;
452
- type SupportedProviders = Partial<Record<PROVIDER_ID, WalletClient | null>>;
453
-
454
- declare const reconnectProviders: (providers: SupportedProviders) => Promise<void>;
455
-
456
- type NFDTransactionsArray = ['u' | 's', string][];
457
- declare function encodeNFDTransactionsArray(transactionsArray: NFDTransactionsArray): Uint8Array[];
458
-
459
- interface WalletProviderProps {
460
- children: React.ReactNode;
461
- value: SupportedProviders | null;
462
25
  }
463
- declare const WalletProvider: ({ children, value }: WalletProviderProps) => React.JSX.Element;
464
-
465
- declare class PeraWalletClient extends BaseClient {
466
- #private;
467
- clientOptions?: PeraWalletConnectOptions;
468
- network: Network;
469
- constructor({ metadata, client, clientOptions, algosdk, algodClient, network }: PeraWalletClientConstructor);
470
- static metadata: {
471
- id: PROVIDER_ID;
26
+ declare class DeflyWallet extends BaseWallet {
27
+ private client;
28
+ private options;
29
+ protected store: Store<State>;
30
+ constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.DEFLY>);
31
+ static defaultMetadata: {
472
32
  name: string;
473
33
  icon: string;
474
- isWalletConnect: boolean;
475
34
  };
476
- static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.PERA>): Promise<BaseClient | null>;
477
- connect(onDisconnect: () => void): Promise<Wallet>;
478
- reconnect(onDisconnect: () => void): Promise<{
479
- accounts: {
480
- name: string;
481
- address: string;
482
- providerId: PROVIDER_ID;
483
- }[];
484
- id: PROVIDER_ID;
485
- name: string;
486
- icon: string;
487
- isWalletConnect: boolean;
488
- } | null>;
35
+ private initializeClient;
36
+ connect(): Promise<WalletAccount[]>;
489
37
  disconnect(): Promise<void>;
490
- signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
38
+ resumeSession(): Promise<void>;
39
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
40
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
491
41
  }
492
42
 
493
- declare class MyAlgoWalletClient extends BaseClient {
494
- #private;
495
- clientOptions?: MyAlgoConnectOptions;
496
- network: Network;
497
- constructor({ metadata, client, clientOptions, algosdk, algodClient, network }: MyAlgoWalletClientConstructor);
498
- static metadata: {
499
- id: PROVIDER_ID;
500
- name: string;
501
- icon: string;
502
- isWalletConnect: boolean;
503
- };
504
- static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.MYALGO>): Promise<BaseClient | null>;
505
- connect(): Promise<{
506
- accounts: {
507
- providerId: PROVIDER_ID;
508
- address: string;
509
- name: string;
510
- }[];
511
- id: PROVIDER_ID;
512
- name: string;
513
- icon: string;
514
- isWalletConnect: boolean;
515
- }>;
516
- reconnect(): Promise<null>;
517
- disconnect(): Promise<void>;
518
- signTransactions(connectedAccounts: string[], transactions: Uint8Array[], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
43
+ /** @see https://docs.exodus.com/api-reference/algorand-provider-arc-api/ */
44
+ interface EnableNetworkOpts {
45
+ genesisID?: string;
46
+ genesisHash?: string;
519
47
  }
520
-
521
- declare class DeflyWalletClient extends BaseClient {
522
- #private;
523
- clientOptions?: DeflyWalletConnectOptions;
524
- network: Network;
525
- constructor({ metadata, client, clientOptions, algosdk, algodClient, network }: DeflyWalletClientConstructor);
526
- static metadata: {
527
- id: PROVIDER_ID;
528
- name: string;
529
- icon: string;
530
- isWalletConnect: boolean;
531
- };
532
- static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.DEFLY>): Promise<BaseClient | null>;
533
- connect(onDisconnect: () => void): Promise<Wallet>;
534
- reconnect(onDisconnect: () => void): Promise<{
535
- accounts: {
536
- name: string;
537
- address: string;
538
- providerId: PROVIDER_ID;
539
- }[];
540
- id: PROVIDER_ID;
541
- name: string;
542
- icon: string;
543
- isWalletConnect: boolean;
544
- } | null>;
545
- disconnect(): Promise<void>;
546
- signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
48
+ interface EnableAccountsOpts {
49
+ accounts?: string[];
547
50
  }
548
-
549
- declare class ExodusClient extends BaseClient {
550
- #private;
551
- clientOptions: ExodusOptions;
552
- network: Network;
553
- constructor({ metadata, client, clientOptions, algosdk, algodClient, network }: ExodusClientConstructor);
554
- static metadata: {
555
- id: PROVIDER_ID;
51
+ type ExodusOptions = EnableNetworkOpts & EnableAccountsOpts;
52
+ interface EnableNetworkResult {
53
+ genesisID: string;
54
+ genesisHash: string;
55
+ }
56
+ interface EnableAccountsResult {
57
+ accounts: string[];
58
+ }
59
+ type EnableResult = EnableNetworkResult & EnableAccountsResult;
60
+ type SignTxnsResult = (string | null)[];
61
+ interface Exodus {
62
+ isConnected: boolean;
63
+ address: string | null;
64
+ enable: (options?: ExodusOptions) => Promise<EnableResult>;
65
+ signTxns: (transactions: WalletTransaction[]) => Promise<SignTxnsResult>;
66
+ }
67
+ type WindowExtended = {
68
+ algorand: Exodus;
69
+ } & Window & typeof globalThis;
70
+ declare class ExodusWallet extends BaseWallet {
71
+ private client;
72
+ private options;
73
+ protected store: Store<State>;
74
+ constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.EXODUS>);
75
+ static defaultMetadata: {
556
76
  name: string;
557
77
  icon: string;
558
- isWalletConnect: boolean;
559
78
  };
560
- static init({ clientOptions, algodOptions, algosdkStatic, network }: InitParams<PROVIDER_ID.EXODUS>): Promise<BaseClient | null>;
561
- connect(): Promise<{
562
- accounts: {
563
- name: string;
564
- address: string;
565
- providerId: PROVIDER_ID;
566
- }[];
567
- id: PROVIDER_ID;
568
- name: string;
569
- icon: string;
570
- isWalletConnect: boolean;
571
- }>;
572
- reconnect(onDisconnect: () => void): Promise<null>;
79
+ private initializeClient;
80
+ connect(): Promise<WalletAccount[]>;
573
81
  disconnect(): Promise<void>;
574
- signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
82
+ resumeSession(): Promise<void>;
83
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
84
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
575
85
  }
576
86
 
577
- type WalletStore = {
578
- accounts: Account[];
579
- activeAccount: Account | null | undefined;
580
- setActiveAccount: (account: Account) => void;
581
- clearActiveAccount: (id: PROVIDER_ID) => void;
582
- addAccounts: (accounts: Account[]) => void;
583
- removeAccounts: (providerId: PROVIDER_ID) => void;
584
- };
585
- declare const useWalletStore: zustand.UseBoundStore<Omit<Omit<Omit<zustand.StoreApi<WalletStore>, "setState"> & {
586
- setState(nextStateOrUpdater: WalletStore | Partial<WalletStore> | ((state: immer_dist_internal.WritableDraft<WalletStore>) => void), shouldReplace?: boolean | undefined): void;
587
- }, "persist"> & {
588
- persist: {
589
- setOptions: (options: Partial<zustand_middleware.PersistOptions<WalletStore, WalletStore>>) => void;
590
- clearStorage: () => void;
591
- rehydrate: () => void | Promise<void>;
592
- hasHydrated: () => boolean;
593
- onHydrate: (fn: (state: WalletStore) => void) => () => void;
594
- onFinishHydration: (fn: (state: WalletStore) => void) => () => void;
595
- getOptions: () => Partial<zustand_middleware.PersistOptions<WalletStore, WalletStore>>;
596
- };
597
- }, "setState"> & {
598
- setState<A extends string | {
599
- type: string;
600
- }>(nextStateOrUpdater: WalletStore | Partial<WalletStore> | ((state: immer_dist_internal.WritableDraft<WalletStore>) => void), shouldReplace?: boolean | undefined, action?: A | undefined): void;
601
- }>;
602
-
603
- type GenesisId = 'betanet-v1.0' | 'testnet-v1.0' | 'mainnet-v1.0' | string;
604
- type EnableParams = {
605
- genesisID?: GenesisId;
606
- genesisHash?: string;
607
- accounts?: string[];
608
- };
609
- type EnableResponse = {
610
- genesisID: GenesisId;
611
- genesisHash: string;
612
- accounts: string[];
613
- };
614
- type AlgoSignerTransaction = {
615
- txn: string;
616
- signers?: string[];
617
- stxn?: string;
618
- multisig?: string;
619
- authAddr?: string;
620
- };
621
- type AlgoSigner = {
622
- enable: (params?: EnableParams) => Promise<EnableResponse>;
623
- signTxns: (transactions: AlgoSignerTransaction[]) => Promise<string[]>;
624
- encoding: {
625
- msgpackToBase64(transaction: Uint8Array): string;
626
- byteArrayToString(transaction: Uint8Array): string;
627
- };
628
- };
629
- type AlgoSignerClientConstructor = {
630
- metadata: Metadata;
631
- client: AlgoSigner;
632
- algosdk: typeof algosdk;
633
- algodClient: algosdk.Algodv2;
634
- network: Network;
635
- };
636
-
637
- declare class AlgoSignerClient extends BaseClient {
638
- #private;
639
- network: Network;
640
- walletStore: typeof useWalletStore;
641
- constructor({ metadata, client, algosdk, algodClient, network }: AlgoSignerClientConstructor);
642
- static metadata: {
643
- id: PROVIDER_ID;
87
+ type ProviderMethod = 'enable' | 'getProviders' | 'postTxns' | 'signAndPostTxns' | 'signBytes' | 'signTxns';
88
+ interface SendRequestWithTimeoutOptions<Params> {
89
+ method: ProviderMethod;
90
+ params: Params;
91
+ reference: string;
92
+ timeout?: number;
93
+ }
94
+ declare class KibisisWallet extends BaseWallet {
95
+ methods: ProviderMethod[];
96
+ protected store: Store<State>;
97
+ constructor({ id, store, subscribe, getAlgodClient, metadata }: WalletConstructor<WalletId.KIBISIS>);
98
+ static defaultMetadata: {
644
99
  name: string;
645
100
  icon: string;
646
- isWalletConnect: boolean;
647
101
  };
648
- static init({ algodOptions, algosdkStatic, network }: InitParams<PROVIDER_ID.ALGOSIGNER>): Promise<BaseClient | null>;
649
- connect(): Promise<{
650
- accounts: {
651
- authAddr?: string | undefined;
652
- name: string;
653
- address: string;
654
- providerId: PROVIDER_ID;
655
- }[];
656
- id: PROVIDER_ID;
657
- name: string;
658
- icon: string;
659
- isWalletConnect: boolean;
660
- }>;
661
- reconnect(onDisconnect: () => void): Promise<null>;
102
+ static sendRequestWithTimeout<Params, Result>({ method, params, timeout, reference }: SendRequestWithTimeoutOptions<Params>): Promise<Result | undefined>;
103
+ /**
104
+ * Calls the enable method on the provider that returns the authorized accounts.
105
+ * @returns {Arc0027Account[]} the authorized accounts.
106
+ * @throws {METHOD_CANCELED_ERROR} if the method was cancelled by the user.
107
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
108
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
109
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
110
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
111
+ */
112
+ private enable;
113
+ /**
114
+ * Gets the genesis hash of the algod client's configured network.
115
+ * @returns {string} the genesis hash
116
+ */
117
+ private getGenesisHash;
118
+ /**
119
+ * Gets the provider information and updates the supported methods. This should be called
120
+ * before interacting with the provider to ensure methods are supported.
121
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
122
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
123
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
124
+ */
125
+ private getSupportedMethods;
126
+ /**
127
+ * Calls the signTxns methods to sign the supplied transactions.
128
+ * @param {Arc0001SignTxns[]} txns - the unsigned or signed transactions as defined in ARC-0001.
129
+ * @returns {(string | null)[]} the authorized accounts.
130
+ * @throws {INVALID_INPUT_ERROR} if computed group ID for the txns does not match the assigned group ID.
131
+ * @throws {INVALID_GROUP_ID_ERROR} if the unsigned txns is malformed or not conforming to ARC-0001.
132
+ * @throws {METHOD_CANCELED_ERROR} if the method was cancelled by the user.
133
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
134
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
135
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
136
+ * @throws {UNAUTHORIZED_SIGNER_ERROR} if a signer in the request is not authorized by the provider.
137
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
138
+ */
139
+ private signTxns;
140
+ /**
141
+ * Validates whether a method is supported with the provider.
142
+ * @param {ProviderMethod} method - the method to validate.
143
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
144
+ */
145
+ private validateMethod;
146
+ connect(): Promise<WalletAccount[]>;
662
147
  disconnect(): Promise<void>;
663
- signTransactions(connectedAccounts: string[], transactions: Uint8Array[], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
664
- getGenesisID(): string;
665
- getAuthAddress(address: string): string | undefined;
148
+ resumeSession(): Promise<void>;
149
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
150
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
666
151
  }
667
152
 
668
- declare class LuteClient extends BaseClient {
669
- #private;
670
- clientOptions?: LuteConnectOptions;
671
- network: Network;
672
- constructor({ metadata, client, clientOptions, algosdk, algodClient, network }: LuteClientConstructor);
673
- static metadata: {
674
- id: PROVIDER_ID;
153
+ interface KmdConstructor {
154
+ token: string | algosdk.KMDTokenHeader | algosdk.CustomTokenHeader;
155
+ baseServer?: string;
156
+ port?: string | number;
157
+ headers?: Record<string, string>;
158
+ }
159
+ type KmdOptions = Partial<Pick<KmdConstructor, 'token'>> & Omit<KmdConstructor, 'token'> & {
160
+ wallet?: string;
161
+ };
162
+ declare class KmdWallet extends BaseWallet {
163
+ private client;
164
+ private options;
165
+ private walletName;
166
+ private walletId;
167
+ private password;
168
+ protected store: Store<State>;
169
+ constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.KMD>);
170
+ static defaultMetadata: {
675
171
  name: string;
676
172
  icon: string;
677
- isWalletConnect: boolean;
678
173
  };
679
- static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.LUTE>): Promise<BaseClient | null>;
680
- connect(): Promise<{
681
- accounts: {
682
- name: string;
683
- address: string;
684
- providerId: PROVIDER_ID;
685
- }[];
686
- id: PROVIDER_ID;
687
- name: string;
688
- icon: string;
689
- isWalletConnect: boolean;
690
- }>;
691
- reconnect(): Promise<null>;
174
+ private initializeClient;
175
+ connect(): Promise<WalletAccount[]>;
692
176
  disconnect(): Promise<void>;
693
- shouldSignTxnObject(txn: DecodedTransaction | DecodedSignedTransaction, addresses: string[], indexesToSign: number[] | undefined, idx: number): boolean;
694
- signTransactions(connectedAccounts: string[], transactions: Uint8Array[], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
177
+ resumeSession: () => Promise<void>;
178
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
179
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
180
+ private fetchWalletId;
181
+ private fetchToken;
182
+ private fetchAccounts;
183
+ private releaseToken;
184
+ private getPassword;
695
185
  }
696
186
 
697
- type WalletConnectClientConstructor = {
698
- metadata: Metadata;
699
- client: WalletConnectModalSign;
700
- clientOptions: WalletConnectModalSignOptions;
701
- algosdk: typeof algosdk;
702
- algodClient: algosdk.Algodv2;
703
- network: Network;
704
- chain: string;
705
- };
706
-
707
- declare class WalletConnectClient extends BaseClient {
708
- #private;
709
- clientOptions?: WalletConnectModalSignOptions;
710
- network: Network;
711
- chain: string;
712
- constructor({ metadata, client, clientOptions, algosdk, algodClient, network, chain }: WalletConnectClientConstructor);
713
- static metadata: {
714
- id: PROVIDER_ID;
187
+ interface LuteConnectOptions {
188
+ siteName?: string;
189
+ }
190
+ declare class LuteWallet extends BaseWallet {
191
+ private client;
192
+ private options;
193
+ protected store: Store<State>;
194
+ constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.LUTE>);
195
+ static defaultMetadata: {
715
196
  name: string;
716
197
  icon: string;
717
- isWalletConnect: boolean;
718
198
  };
719
- static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.WALLETCONNECT>): Promise<BaseClient | 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>;
199
+ private initializeClient;
200
+ private getGenesisId;
201
+ connect(): Promise<WalletAccount[]>;
732
202
  disconnect(): Promise<void>;
733
- signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
203
+ resumeSession(): Promise<void>;
204
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
205
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
734
206
  }
735
207
 
736
- type MagicAuthConnectOptions = {
737
- apiKey: string;
738
- };
739
- type MagicAuthConstructor = {
740
- metadata: Metadata;
741
- client: InstanceWithExtensions<SDKBase, {
742
- algorand: AlgorandExtension;
743
- }>;
744
- clientOptions: MagicAuthConnectOptions;
745
- algosdk: typeof algosdk;
746
- algodClient: algosdk.Algodv2;
747
- network: Network;
208
+ type MnemonicOptions = {
209
+ persistToStorage?: boolean;
748
210
  };
749
-
750
- declare class MagicAuth extends BaseClient {
751
- #private;
752
- clientOptions?: MagicAuthConnectOptions;
753
- network: Network;
754
- constructor({ metadata, client, clientOptions, algosdk, algodClient, network }: MagicAuthConstructor);
755
- static metadata: {
756
- id: PROVIDER_ID;
211
+ declare class MnemonicWallet extends BaseWallet {
212
+ private account;
213
+ private options;
214
+ protected store: Store<State>;
215
+ constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.MNEMONIC>);
216
+ static defaultMetadata: {
757
217
  name: string;
758
218
  icon: string;
759
- isWalletConnect: boolean;
760
219
  };
761
- static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, extensionStatic, getDynamicExtension, algosdkStatic, network }: InitParams<PROVIDER_ID.MAGIC>): Promise<BaseClient | null>;
762
- connect(_: () => void, arg?: any): Promise<Wallet>;
763
- reconnect(): Promise<{
764
- accounts: {
765
- name: string;
766
- address: string;
767
- providerId: PROVIDER_ID;
768
- email: string;
769
- }[];
770
- id: PROVIDER_ID;
771
- name: string;
772
- icon: string;
773
- isWalletConnect: boolean;
774
- } | null>;
220
+ private initializeAccount;
221
+ connect(): Promise<WalletAccount[]>;
775
222
  disconnect(): Promise<void>;
776
- signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
223
+ resumeSession(): Promise<void>;
224
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
225
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
777
226
  }
778
227
 
779
- declare class KMDWalletClient extends BaseClient {
780
- #private;
781
- walletId: string;
782
- network: Network;
783
- constructor({ metadata, client, wallet, password, algosdk, algodClient, network }: KMDWalletClientConstructor);
784
- static metadata: {
785
- id: PROVIDER_ID;
228
+ interface PeraWalletConnectOptions {
229
+ bridge?: string;
230
+ shouldShowSignTxnToast?: boolean;
231
+ chainId?: 416001 | 416002 | 416003 | 4160;
232
+ compactMode?: boolean;
233
+ }
234
+ declare class PeraWallet extends BaseWallet {
235
+ private client;
236
+ private options;
237
+ protected store: Store<State>;
238
+ constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.PERA>);
239
+ static defaultMetadata: {
786
240
  name: string;
787
241
  icon: string;
788
- isWalletConnect: boolean;
789
242
  };
790
- static init({ clientOptions, algodOptions, algosdkStatic, network }: InitParams<PROVIDER_ID.KMD>): Promise<BaseClient | null>;
791
- connect(): Promise<Wallet>;
243
+ private initializeClient;
244
+ connect(): Promise<WalletAccount[]>;
792
245
  disconnect(): Promise<void>;
793
- reconnect(): Promise<Wallet | null>;
794
- requestPassword(): string;
795
- getWalletToken(walletId: string, password: string): Promise<string>;
796
- releaseToken(token: string): Promise<void>;
797
- listWallets(): Promise<Record<string, string>>;
798
- listAccounts(wallet: string, password: string): Promise<Array<Account>>;
799
- getWalletId(): Promise<string>;
800
- signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
246
+ resumeSession(): Promise<void>;
247
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
248
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
801
249
  }
802
250
 
803
- type MnemonicWalletClientConstructor = {
804
- metadata: Metadata;
805
- algosdk: typeof algosdk;
806
- algodClient: algosdk.Algodv2;
807
- network: Network;
808
- };
809
-
810
- declare class MnemonicWalletClient extends BaseClient {
811
- #private;
812
- network: Network;
813
- constructor({ metadata, algosdk, algodClient, network }: MnemonicWalletClientConstructor);
814
- static metadata: {
815
- id: PROVIDER_ID;
251
+ interface SignClientOptions {
252
+ projectId: string;
253
+ relayUrl?: string;
254
+ metadata?: SignClientTypes.Metadata;
255
+ }
256
+ type WalletConnectModalOptions = Pick<WalletConnectModalConfig, 'enableExplorer' | 'explorerRecommendedWalletIds' | 'privacyPolicyUrl' | 'termsOfServiceUrl' | 'themeMode' | 'themeVariables'>;
257
+ type WalletConnectOptions = SignClientOptions & WalletConnectModalOptions;
258
+ declare class WalletConnect extends BaseWallet {
259
+ private client;
260
+ private options;
261
+ private modal;
262
+ private modalOptions;
263
+ private session;
264
+ private chains;
265
+ protected store: Store<State>;
266
+ constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.WALLETCONNECT>);
267
+ static defaultMetadata: {
816
268
  name: string;
817
269
  icon: string;
818
- isWalletConnect: boolean;
819
270
  };
820
- static init({ algodOptions, algosdkStatic, network }: InitParams<PROVIDER_ID.MNEMONIC>): Promise<BaseClient | null>;
821
- connect(): Promise<{
822
- accounts: {
823
- name: string;
824
- address: string;
825
- providerId: PROVIDER_ID;
826
- }[];
827
- id: PROVIDER_ID;
828
- name: string;
829
- icon: string;
830
- isWalletConnect: boolean;
831
- }>;
271
+ private initializeClient;
272
+ private initializeModal;
273
+ private onSessionConnected;
274
+ connect(): Promise<WalletAccount[]>;
832
275
  disconnect(): Promise<void>;
833
- reconnect(): Promise<null>;
834
- requestPassword(): string;
835
- signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
836
- signEncodedTransactions(_transactions: TransactionsArray): Promise<Uint8Array[]>;
276
+ resumeSession(): Promise<void>;
277
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
278
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
837
279
  }
838
280
 
839
- declare class CustomWalletClient extends BaseClient {
840
- network: Network;
841
- providerProxy: CustomProvider;
842
- static metadata: Metadata;
843
- constructor({ providerProxy, metadata, algosdk, algodClient, network }: CustomWalletClientConstructor);
844
- static init({ clientOptions, algodOptions, algosdkStatic, network }: InitParams<PROVIDER_ID.CUSTOM>): Promise<BaseClient | null>;
845
- connect(): Promise<Wallet>;
846
- disconnect(): Promise<void>;
847
- reconnect(): Promise<Wallet | null>;
848
- signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
849
- }
850
-
851
- interface Arc0027Account {
852
- address: string;
853
- name?: string;
281
+ declare enum WalletId {
282
+ DEFLY = "defly",
283
+ EXODUS = "exodus",
284
+ KIBISIS = "kibisis",
285
+ KMD = "kmd",
286
+ LUTE = "lute",
287
+ MNEMONIC = "mnemonic",
288
+ PERA = "pera",
289
+ WALLETCONNECT = "walletconnect"
854
290
  }
855
- interface KibisisClientConstructor {
856
- metadata: Metadata;
857
- algosdk: typeof algosdk;
858
- algodClient: algosdk.Algodv2;
859
- genesisHash: string;
860
- methods: ProviderMethods[];
861
- network: Network;
291
+ type WalletMap = {
292
+ [WalletId.DEFLY]: typeof DeflyWallet;
293
+ [WalletId.EXODUS]: typeof ExodusWallet;
294
+ [WalletId.KIBISIS]: typeof KibisisWallet;
295
+ [WalletId.KMD]: typeof KmdWallet;
296
+ [WalletId.LUTE]: typeof LuteWallet;
297
+ [WalletId.MNEMONIC]: typeof MnemonicWallet;
298
+ [WalletId.PERA]: typeof PeraWallet;
299
+ [WalletId.WALLETCONNECT]: typeof WalletConnect;
300
+ };
301
+ type WalletOptionsMap = {
302
+ [WalletId.DEFLY]: DeflyWalletConnectOptions;
303
+ [WalletId.EXODUS]: ExodusOptions;
304
+ [WalletId.KIBISIS]: Record<string, never>;
305
+ [WalletId.KMD]: KmdOptions;
306
+ [WalletId.LUTE]: LuteConnectOptions;
307
+ [WalletId.MNEMONIC]: MnemonicOptions;
308
+ [WalletId.PERA]: PeraWalletConnectOptions;
309
+ [WalletId.WALLETCONNECT]: WalletConnectOptions;
310
+ };
311
+ type SupportedWallet = WalletIdConfig<WalletId> | WalletId;
312
+ type WalletConfigMap = {
313
+ [K in keyof WalletOptionsMap]: {
314
+ options?: WalletOptionsMap[K];
315
+ metadata?: Partial<WalletMetadata>;
316
+ };
317
+ };
318
+ type WalletOptions<T extends keyof WalletOptionsMap> = WalletOptionsMap[T];
319
+ type WalletConfig<T extends keyof WalletConfigMap> = WalletConfigMap[T];
320
+ type WalletIdConfig<T extends keyof WalletConfigMap> = {
321
+ [K in T]: {
322
+ id: K;
323
+ } & WalletConfigMap[K];
324
+ }[T];
325
+ type NonEmptyArray<T> = [T, ...T[]];
326
+ type SupportedWallets = NonEmptyArray<SupportedWallet>;
327
+ type WalletMetadata = {
328
+ name: string;
329
+ icon: string;
330
+ };
331
+ interface BaseWalletConstructor {
332
+ id: WalletId;
333
+ metadata: Partial<WalletMetadata> | undefined;
334
+ getAlgodClient: () => algosdk.Algodv2;
335
+ store: Store<State>;
336
+ subscribe: (callback: (state: State) => void) => () => void;
862
337
  }
863
- type ProviderMethods = 'enable' | 'getProviders' | 'postTxns' | 'signAndPostTxns' | 'signBytes' | 'signTxns';
864
- interface SendRequestWithTimeoutOptions<Params> {
865
- method: ProviderMethods;
866
- params: Params;
867
- reference: string;
868
- timeout?: number;
338
+ type WalletConstructor<T extends keyof WalletOptionsMap> = BaseWalletConstructor & {
339
+ options?: WalletOptions<T>;
340
+ defaultMetadata?: WalletMetadata;
341
+ };
342
+ type WalletAccount = {
343
+ name: string;
344
+ address: string;
345
+ };
346
+ /** @see https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0001.md#interface-multisigmetadata */
347
+ interface MultisigMetadata {
348
+ /**
349
+ * Multisig version.
350
+ */
351
+ version: number;
352
+ /**
353
+ * Multisig threshold value. Authorization requires a subset of signatures,
354
+ * equal to or greater than the threshold value.
355
+ */
356
+ threshold: number;
357
+ /**
358
+ * List of Algorand addresses of possible signers for this
359
+ * multisig. Order is important.
360
+ */
361
+ addrs: string[];
869
362
  }
870
-
871
- declare class KibisisClient extends BaseClient {
872
- genesisHash: string;
873
- methods: ProviderMethods[];
874
- network: Network;
875
- constructor({ metadata, algosdk, algodClient, genesisHash, methods, network }: KibisisClientConstructor);
876
- static metadata: {
877
- id: PROVIDER_ID;
878
- icon: string;
879
- isWalletConnect: boolean;
880
- name: string;
881
- };
363
+ /** @see https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0001.md#interface-wallettransaction */
364
+ interface WalletTransaction {
882
365
  /**
883
- * public static functions
366
+ * Base64 encoding of the canonical msgpack encoding of a Transaction.
884
367
  */
885
- static init({ algodOptions, algosdkStatic, network }: InitParams<PROVIDER_ID.KIBISIS>): Promise<BaseClient | null>;
886
- static mapAccountsToWallet(accounts: Arc0027Account[]): Wallet;
887
- static sendRequestWithTimeout<Params, Result>({ method, params, timeout, reference }: SendRequestWithTimeoutOptions<Params>): Promise<Result | undefined>;
368
+ txn: string;
888
369
  /**
889
- * private functions
370
+ * Optional authorized address used to sign the transaction when the account
371
+ * is rekeyed. Also called the signor/sgnr.
890
372
  */
891
- private convertBytesToBase64;
892
- private convertBase64ToBytes;
373
+ authAddr?: string;
893
374
  /**
894
- * Calls the enable method on the provider that returns the authorized accounts.
895
- * @returns {Arc0027Account[]} the authorized accounts.
896
- * @throws {METHOD_CANCELED_ERROR} if the method was cancelled by the user.
897
- * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
898
- * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
899
- * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
900
- * @throws {UNKNOWN_ERROR} if the response result was empty.
375
+ * Multisig metadata used to sign the transaction
901
376
  */
902
- private enable;
377
+ msig?: MultisigMetadata;
903
378
  /**
904
- * Convenience function that gets the provider information and updates the supported methods. This should be called
905
- * before interacting with the provider to ensure methods are supported.
906
- * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
907
- * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
908
- * @throws {UNKNOWN_ERROR} if the response result was empty.
379
+ * Optional list of addresses that must sign the transactions
909
380
  */
910
- private refreshSupportedMethods;
381
+ signers?: string[];
911
382
  /**
912
- * Calls the signTxns methods to sign the supplied transactions.
913
- * @param {Arc0001SignTxns[]} txns - the unsigned or signed transactions as defined in ARC-0001.
914
- * @returns {(string | null)[]} the authorized accounts.
915
- * @throws {INVALID_INPUT_ERROR} if computed group ID for the txns does not match the assigned group ID.
916
- * @throws {INVALID_GROUP_ID_ERROR} if the unsigned txns is malformed or not conforming to ARC-0001.
917
- * @throws {METHOD_CANCELED_ERROR} if the method was cancelled by the user.
918
- * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
919
- * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
920
- * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
921
- * @throws {UNAUTHORIZED_SIGNER_ERROR} if a signer in the request is not authorized by the provider.
922
- * @throws {UNKNOWN_ERROR} if the response result was empty.
383
+ * Optional base64 encoding of the canonical msgpack encoding of a
384
+ * SignedTxn corresponding to txn, when signers=[]
923
385
  */
924
- private signTxns;
386
+ stxn?: string;
925
387
  /**
926
- * Validates whether a method is supported with the provider.
927
- * @param {ProviderMethods} method - the method to validate.
928
- * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
388
+ * Optional message explaining the reason of the transaction
929
389
  */
930
- private validateMethod;
390
+ message?: string;
931
391
  /**
932
- * public functions
392
+ * Optional message explaining the reason of this group of transaction
393
+ * Field only allowed in the first transaction of a group
933
394
  */
934
- connect(): Promise<Wallet>;
935
- disconnect(): Promise<void>;
936
- reconnect(): Promise<Wallet | null>;
937
- signTransactions(connectedAccounts: string[], transactions: Uint8Array[], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
395
+ groupMessage?: string;
396
+ }
397
+ /** @see https://github.com/perawallet/connect/blob/1.3.3/src/util/model/peraWalletModels.ts */
398
+ interface SignerTransaction {
399
+ txn: algosdk.Transaction;
400
+ /**
401
+ * Optional authorized address used to sign the transaction when
402
+ * the account is rekeyed. Also called the signor/sgnr.
403
+ */
404
+ authAddr?: string;
405
+ /**
406
+ * Optional list of addresses that must sign the transactions.
407
+ * Wallet skips to sign this txn if signers is empty array.
408
+ * If undefined, wallet tries to sign it.
409
+ */
410
+ signers?: string[];
411
+ /**
412
+ * Optional message explaining the reason of the transaction
413
+ */
414
+ message?: string;
415
+ }
416
+ interface JsonRpcRequest<T = any> {
417
+ id: number;
418
+ jsonrpc: string;
419
+ method: string;
420
+ params: T;
938
421
  }
939
422
 
940
- declare function useWallet(): {
941
- clients: Partial<Record<PROVIDER_ID, BaseClient | null>> | null;
942
- providers: Provider[] | null;
943
- connectedAccounts: Account[];
944
- connectedActiveAccounts: Account[];
945
- activeAccount: Account | null | undefined;
946
- activeAddress: string | undefined;
947
- status: string;
948
- isActive: boolean;
949
- isReady: boolean;
950
- signer: algosdk.TransactionSigner;
951
- signTransactions: (transactions: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
952
- sendTransactions: (transactions: Uint8Array[], waitRoundsToConfirm?: number) => Promise<{
953
- 'confirmed-round': number;
954
- 'global-state-delta': Record<string, unknown>[];
955
- 'pool-error': string;
956
- txn: {
957
- sig: Uint8Array;
958
- txn: Txn;
959
- };
960
- txId: string;
961
- id: string;
962
- }>;
963
- getAddress: () => string | undefined;
964
- groupTransactionsBySender: (transactions: TransactionsArray) => Record<string, TxnInfo[]>;
965
- getAccountInfo: () => Promise<AccountInfo>;
966
- getAssets: () => Promise<Asset[]>;
423
+ declare abstract class BaseWallet {
424
+ readonly id: WalletId;
425
+ readonly metadata: WalletMetadata;
426
+ protected store: Store<State>;
427
+ protected getAlgodClient: () => algosdk.Algodv2;
428
+ subscribe: (callback: (state: State) => void) => () => void;
429
+ protected constructor({ id, metadata, store, subscribe, getAlgodClient }: WalletConstructor<WalletId>);
430
+ static defaultMetadata: WalletMetadata;
431
+ abstract connect(): Promise<WalletAccount[]>;
432
+ abstract disconnect(): Promise<void>;
433
+ abstract resumeSession(): Promise<void>;
434
+ setActive(): void;
435
+ setActiveAccount(account: string): void;
436
+ abstract signTransactions(txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
437
+ abstract transactionSigner(txnGroup: algosdk.Transaction[], indexesToSign: number[]): Promise<Uint8Array[]>;
438
+ get name(): string;
439
+ get accounts(): WalletAccount[];
440
+ get addresses(): string[];
441
+ get activeAccount(): WalletAccount | null;
442
+ get activeAddress(): string | null;
443
+ get activeNetwork(): NetworkId;
444
+ get isConnected(): boolean;
445
+ get isActive(): boolean;
446
+ protected onDisconnect(): void;
447
+ }
448
+
449
+ type WalletState = {
450
+ accounts: WalletAccount[];
451
+ activeAccount: WalletAccount | null;
967
452
  };
453
+ type WalletStateMap = Partial<Record<WalletId, WalletState>>;
454
+ interface State {
455
+ wallets: WalletStateMap;
456
+ activeWallet: WalletId | null;
457
+ activeNetwork: NetworkId;
458
+ }
459
+ declare const defaultState: State;
460
+
461
+ interface WalletManagerConfig {
462
+ wallets?: SupportedWallet[];
463
+ network?: NetworkId;
464
+ algod?: NetworkConfig;
465
+ }
466
+ declare class WalletManager {
467
+ _clients: Map<WalletId, BaseWallet>;
468
+ networkConfig: NetworkConfigMap;
469
+ algodClient: algosdk.Algodv2;
470
+ store: Store<State>;
471
+ subscribe: (callback: (state: State) => void) => () => void;
472
+ constructor({ wallets, network, algod }?: WalletManagerConfig);
473
+ private loadPersistedState;
474
+ private savePersistedState;
475
+ private initializeWallets;
476
+ get wallets(): BaseWallet[];
477
+ getWallet(walletId: WalletId): BaseWallet | undefined;
478
+ resumeSessions(): Promise<void>;
479
+ private initNetworkConfig;
480
+ private createAlgodClient;
481
+ getAlgodClient: () => algosdk.Algodv2;
482
+ setActiveNetwork(networkId: NetworkId): void;
483
+ get activeNetwork(): NetworkId;
484
+ get activeWallet(): BaseWallet | null;
485
+ get activeWalletAccounts(): WalletAccount[] | null;
486
+ get activeWalletAddresses(): string[] | null;
487
+ get activeAccount(): WalletAccount | null;
488
+ get activeAddress(): string | null;
489
+ get signTransactions(): (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[] | undefined, returnGroup?: boolean | undefined) => Promise<Uint8Array[]>;
490
+ /**
491
+ * A function which can sign transactions from an atomic transaction group. The logic will be
492
+ * specific to each wallet, but the function will always return a promise that resolves to an
493
+ * array of encoded signed transactions matching the length of the indexesToSign array.
494
+ *
495
+ * @see https://github.com/algorand/js-algorand-sdk/blob/v2.6.0/src/signer.ts#L7-L18
496
+ *
497
+ * @param txnGroup - The atomic group containing transactions to be signed
498
+ * @param indexesToSign - An array of indexes in the atomic transaction group that should be signed
499
+ * @returns A promise which resolves an array of encoded signed transactions. The length of the
500
+ * array will be the same as the length of indexesToSign, and each index i in the array
501
+ * corresponds to the signed transaction from txnGroup[indexesToSign[i]]
502
+ */
503
+ get transactionSigner(): algosdk.TransactionSigner;
504
+ }
968
505
 
969
- interface InitializeProvidersOptions {
970
- providers: ProvidersArray;
971
- nodeConfig?: NodeConfig;
972
- algosdkStatic?: typeof algosdk;
973
- debug?: boolean;
506
+ declare class StorageAdapter {
507
+ static getItem(key: string): string | null;
508
+ static setItem(key: string, value: string): void;
974
509
  }
975
- declare function useInitializeProviders({ providers, nodeConfig, algosdkStatic, debug }: InitializeProvidersOptions): Partial<Record<PROVIDER_ID, BaseClient | null>> | null;
976
510
 
977
- export { Account, AccountInfo, AlgodClientOptions, Asset, ClientOptions, CommonInitParams, ConfirmedTxn, CustomProvider, 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, WalletProvider, AlgoSignerClient as algosigner, CustomWalletClient as custom, DeflyWalletClient as defly, encodeNFDTransactionsArray, ExodusClient as exodus, KibisisClient as kibisis, KMDWalletClient as kmd, LuteClient as lute, MagicAuth as magic, MnemonicWalletClient as mnemonic, MyAlgoWalletClient as myalgo, PeraWalletClient as pera, reconnectProviders, useInitializeProviders, useWallet, WalletConnectClient as walletconnect };
511
+ export { BaseWallet, type BaseWalletConstructor, DeflyWallet, type DeflyWalletConnectOptions, type EnableResult, type Exodus, type ExodusOptions, ExodusWallet, type JsonRpcRequest, type KmdOptions, KmdWallet, type MnemonicOptions, MnemonicWallet, type MultisigMetadata, NetworkId, PeraWallet, type PeraWalletConnectOptions, type SignTxnsResult, type SignerTransaction, type State, StorageAdapter, type SupportedWallet, type SupportedWallets, type WalletAccount, type WalletConfig, type WalletConfigMap, WalletConnect, type WalletConnectOptions, type WalletConstructor, WalletId, type WalletIdConfig, WalletManager, type WalletManagerConfig, type WalletMap, type WalletMetadata, type WalletOptions, type WalletOptionsMap, type WalletState, type WalletTransaction, type WindowExtended, defaultState };