@txnlab/use-wallet 2.8.2 → 3.0.0-beta.10

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 (205) hide show
  1. package/README.md +3 -1009
  2. package/dist/index.cjs +5636 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +543 -0
  5. package/dist/index.d.ts +463 -897
  6. package/dist/index.js +5601 -0
  7. package/dist/index.js.map +1 -0
  8. package/package.json +52 -120
  9. package/dist/cjs/index.js +0 -3954
  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/encoding.d.ts +0 -4
  99. package/dist/cjs/src/utils/index.d.ts +0 -3
  100. package/dist/cjs/src/utils/initializeProviders.d.ts +0 -3
  101. package/dist/cjs/src/utils/initializeProviders.test.d.ts +0 -4
  102. package/dist/cjs/src/utils/providers.d.ts +0 -3
  103. package/dist/cjs/src/utils/providers.spec.d.ts +0 -1
  104. package/dist/cjs/src/utils/reconnectProviders.d.ts +0 -2
  105. package/dist/cjs/src/utils/reconnectProviders.test.d.ts +0 -1
  106. package/dist/cjs/src/utils/svgToBase64.d.ts +0 -1
  107. package/dist/cjs/src/utils/types.d.ts +0 -2
  108. package/dist/esm/index.js +0 -3931
  109. package/dist/esm/jest.config.d.ts +0 -11
  110. package/dist/esm/jest.setup.d.ts +0 -0
  111. package/dist/esm/src/algod/index.d.ts +0 -10
  112. package/dist/esm/src/clients/algosigner/client.d.ts +0 -37
  113. package/dist/esm/src/clients/algosigner/constants.d.ts +0 -2
  114. package/dist/esm/src/clients/algosigner/index.d.ts +0 -2
  115. package/dist/esm/src/clients/algosigner/types.d.ts +0 -39
  116. package/dist/esm/src/clients/base/base.d.ts +0 -46
  117. package/dist/esm/src/clients/base/index.d.ts +0 -2
  118. package/dist/esm/src/clients/custom/client.d.ts +0 -18
  119. package/dist/esm/src/clients/custom/constants.d.ts +0 -1
  120. package/dist/esm/src/clients/custom/index.d.ts +0 -2
  121. package/dist/esm/src/clients/custom/types.d.ts +0 -25
  122. package/dist/esm/src/clients/daffi/client.d.ts +0 -34
  123. package/dist/esm/src/clients/daffi/constants.d.ts +0 -1
  124. package/dist/esm/src/clients/daffi/index.d.ts +0 -2
  125. package/dist/esm/src/clients/daffi/types.d.ts +0 -27
  126. package/dist/esm/src/clients/defly/client.d.ts +0 -34
  127. package/dist/esm/src/clients/defly/constants.d.ts +0 -1
  128. package/dist/esm/src/clients/defly/index.d.ts +0 -2
  129. package/dist/esm/src/clients/defly/types.d.ts +0 -32
  130. package/dist/esm/src/clients/exodus/client.d.ts +0 -33
  131. package/dist/esm/src/clients/exodus/constants.d.ts +0 -1
  132. package/dist/esm/src/clients/exodus/index.d.ts +0 -2
  133. package/dist/esm/src/clients/exodus/types.d.ts +0 -34
  134. package/dist/esm/src/clients/index.d.ts +0 -19
  135. package/dist/esm/src/clients/kibisis/client.d.ts +0 -73
  136. package/dist/esm/src/clients/kibisis/constants.d.ts +0 -37
  137. package/dist/esm/src/clients/kibisis/index.d.ts +0 -2
  138. package/dist/esm/src/clients/kibisis/types.d.ts +0 -86
  139. package/dist/esm/src/clients/kibisis/utils.d.ts +0 -9
  140. package/dist/esm/src/clients/kibisis/utils.test.d.ts +0 -1
  141. package/dist/esm/src/clients/kmd/client.d.ts +0 -30
  142. package/dist/esm/src/clients/kmd/constants.d.ts +0 -1
  143. package/dist/esm/src/clients/kmd/index.d.ts +0 -2
  144. package/dist/esm/src/clients/kmd/types.d.ts +0 -32
  145. package/dist/esm/src/clients/lute/client.d.ts +0 -34
  146. package/dist/esm/src/clients/lute/constants.d.ts +0 -1
  147. package/dist/esm/src/clients/lute/index.d.ts +0 -2
  148. package/dist/esm/src/clients/lute/types.d.ts +0 -15
  149. package/dist/esm/src/clients/magic/client.d.ts +0 -35
  150. package/dist/esm/src/clients/magic/constants.d.ts +0 -1
  151. package/dist/esm/src/clients/magic/index.d.ts +0 -2
  152. package/dist/esm/src/clients/magic/types.d.ts +0 -27
  153. package/dist/esm/src/clients/mnemonic/client.d.ts +0 -35
  154. package/dist/esm/src/clients/mnemonic/constants.d.ts +0 -1
  155. package/dist/esm/src/clients/mnemonic/index.d.ts +0 -2
  156. package/dist/esm/src/clients/mnemonic/types.d.ts +0 -21
  157. package/dist/esm/src/clients/myalgo/client.d.ts +0 -33
  158. package/dist/esm/src/clients/myalgo/constants.d.ts +0 -1
  159. package/dist/esm/src/clients/myalgo/index.d.ts +0 -2
  160. package/dist/esm/src/clients/myalgo/types.d.ts +0 -19
  161. package/dist/esm/src/clients/pera/client.d.ts +0 -34
  162. package/dist/esm/src/clients/pera/constants.d.ts +0 -1
  163. package/dist/esm/src/clients/pera/index.d.ts +0 -2
  164. package/dist/esm/src/clients/pera/types.d.ts +0 -27
  165. package/dist/esm/src/clients/walletconnect2/client.d.ts +0 -36
  166. package/dist/esm/src/clients/walletconnect2/constants.d.ts +0 -5
  167. package/dist/esm/src/clients/walletconnect2/index.d.ts +0 -2
  168. package/dist/esm/src/clients/walletconnect2/types.d.ts +0 -28
  169. package/dist/esm/src/clients/walletconnect2/utils.d.ts +0 -2
  170. package/dist/esm/src/constants/constants.d.ts +0 -20
  171. package/dist/esm/src/constants/index.d.ts +0 -1
  172. package/dist/esm/src/context/WalletContext.d.ts +0 -8
  173. package/dist/esm/src/hooks/index.d.ts +0 -2
  174. package/dist/esm/src/hooks/useInitializeProviders.d.ts +0 -10
  175. package/dist/esm/src/hooks/useInitializeProviders.test.d.ts +0 -4
  176. package/dist/esm/src/hooks/useWallet.d.ts +0 -31
  177. package/dist/esm/src/hooks/useWallet.test.d.ts +0 -4
  178. package/dist/esm/src/index.d.ts +0 -6
  179. package/dist/esm/src/media/audio.d.ts +0 -1
  180. package/dist/esm/src/store/index.d.ts +0 -2
  181. package/dist/esm/src/store/state/debugStore.d.ts +0 -6
  182. package/dist/esm/src/store/state/walletStore.d.ts +0 -52
  183. package/dist/esm/src/testUtils/mockAccounts.d.ts +0 -3
  184. package/dist/esm/src/testUtils/mockClients.d.ts +0 -45
  185. package/dist/esm/src/types/api.d.ts +0 -14
  186. package/dist/esm/src/types/index.d.ts +0 -4
  187. package/dist/esm/src/types/node.d.ts +0 -44
  188. package/dist/esm/src/types/providers.d.ts +0 -148
  189. package/dist/esm/src/types/utilities.d.ts +0 -1
  190. package/dist/esm/src/types/wallet.d.ts +0 -54
  191. package/dist/esm/src/utils/clearAccounts.d.ts +0 -2
  192. package/dist/esm/src/utils/clearAccounts.test.d.ts +0 -1
  193. package/dist/esm/src/utils/debugLog.d.ts +0 -3
  194. package/dist/esm/src/utils/encodeNFDTransactionArray.spec.d.ts +0 -1
  195. package/dist/esm/src/utils/encodeNFDTransactionsArray.d.ts +0 -2
  196. package/dist/esm/src/utils/encoding.d.ts +0 -4
  197. package/dist/esm/src/utils/index.d.ts +0 -3
  198. package/dist/esm/src/utils/initializeProviders.d.ts +0 -3
  199. package/dist/esm/src/utils/initializeProviders.test.d.ts +0 -4
  200. package/dist/esm/src/utils/providers.d.ts +0 -3
  201. package/dist/esm/src/utils/providers.spec.d.ts +0 -1
  202. package/dist/esm/src/utils/reconnectProviders.d.ts +0 -2
  203. package/dist/esm/src/utils/reconnectProviders.test.d.ts +0 -1
  204. package/dist/esm/src/utils/svgToBase64.d.ts +0 -1
  205. package/dist/esm/src/utils/types.d.ts +0 -2
package/dist/index.d.ts CHANGED
@@ -1,977 +1,543 @@
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
3
  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"
4
+ import { AlgorandExtension } from '@magic-ext/algorand';
5
+ import { MagicUserMetadata } from 'magic-sdk';
6
+ import { WalletConnectModalConfig } from '@walletconnect/modal';
7
+ import { SignClientTypes } from '@walletconnect/types';
8
+
9
+ declare enum NetworkId {
10
+ MAINNET = "mainnet",
11
+ TESTNET = "testnet",
12
+ BETANET = "betanet",
13
+ LOCALNET = "localnet"
88
14
  }
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;
15
+ interface AlgodConfig {
16
+ token: string | algosdk.AlgodTokenHeader | algosdk.CustomTokenHeader | algosdk.BaseHTTPClient;
17
+ baseServer: string;
18
+ port?: string | number;
19
+ headers?: Record<string, string>;
100
20
  }
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>;
21
+ type NetworkConfigMap = Record<NetworkId, AlgodConfig>;
22
+ type NetworkConfig = Partial<AlgodConfig> | Partial<Record<NetworkId, Partial<AlgodConfig>>>;
146
23
 
147
- type PeraWalletConnectOptions = {
24
+ interface DeflyWalletConnectOptions {
148
25
  bridge?: string;
149
26
  shouldShowSignTxnToast?: boolean;
150
27
  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;
28
+ }
29
+ declare class DeflyWallet extends BaseWallet {
30
+ private client;
31
+ private options;
32
+ protected store: Store<State>;
33
+ constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.DEFLY>);
34
+ static defaultMetadata: {
166
35
  name: string;
167
- main_color: string;
36
+ icon: string;
168
37
  };
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
- };
38
+ private initializeClient;
39
+ connect: () => Promise<WalletAccount[]>;
40
+ disconnect: () => Promise<void>;
41
+ resumeSession: () => Promise<void>;
42
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
43
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
44
+ }
179
45
 
180
- type ExodusOptions = {
181
- onlyIfTrusted: boolean;
182
- };
183
- type Bytes = Readonly<Uint8Array>;
184
- type Exodus = {
46
+ /** @see https://docs.exodus.com/api-reference/algorand-provider-arc-api/ */
47
+ interface EnableNetworkOpts {
48
+ genesisID?: string;
49
+ genesisHash?: string;
50
+ }
51
+ interface EnableAccountsOpts {
52
+ accounts?: string[];
53
+ }
54
+ type ExodusOptions = EnableNetworkOpts & EnableAccountsOpts;
55
+ interface EnableNetworkResult {
56
+ genesisID: string;
57
+ genesisHash: string;
58
+ }
59
+ interface EnableAccountsResult {
60
+ accounts: string[];
61
+ }
62
+ type EnableResult = EnableNetworkResult & EnableAccountsResult;
63
+ type SignTxnsResult = (string | null)[];
64
+ interface Exodus {
185
65
  isConnected: boolean;
186
66
  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;
67
+ enable: (options?: ExodusOptions) => Promise<EnableResult>;
68
+ signTxns: (transactions: WalletTransaction[]) => Promise<SignTxnsResult>;
302
69
  }
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
- }
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;
70
+ type WindowExtended = {
71
+ algorand: Exodus;
72
+ } & Window & typeof globalThis;
73
+ declare class ExodusWallet extends BaseWallet {
74
+ private client;
75
+ private options;
76
+ protected store: Store<State>;
77
+ constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.EXODUS>);
78
+ static defaultMetadata: {
472
79
  name: string;
473
80
  icon: string;
474
- isWalletConnect: boolean;
475
81
  };
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>;
489
- disconnect(): Promise<void>;
490
- signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
82
+ private initializeClient;
83
+ connect: () => Promise<WalletAccount[]>;
84
+ disconnect: () => Promise<void>;
85
+ resumeSession: () => Promise<void>;
86
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
87
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
491
88
  }
492
89
 
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[]>;
90
+ type ProviderMethod = 'enable' | 'getProviders' | 'postTxns' | 'signAndPostTxns' | 'signBytes' | 'signTxns';
91
+ interface SendRequestWithTimeoutOptions<Params> {
92
+ method: ProviderMethod;
93
+ params: Params;
94
+ reference: string;
95
+ timeout?: number;
519
96
  }
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;
97
+ declare class KibisisWallet extends BaseWallet {
98
+ methods: ProviderMethod[];
99
+ protected store: Store<State>;
100
+ constructor({ id, store, subscribe, getAlgodClient, metadata }: WalletConstructor<WalletId.KIBISIS>);
101
+ static defaultMetadata: {
528
102
  name: string;
529
103
  icon: string;
530
- isWalletConnect: boolean;
531
104
  };
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[]>;
105
+ static sendRequestWithTimeout<Params, Result>({ method, params, timeout, reference }: SendRequestWithTimeoutOptions<Params>): Promise<Result | undefined>;
106
+ /**
107
+ * Calls the enable method on the provider that returns the authorized accounts.
108
+ * @returns {Arc0027Account[]} the authorized accounts.
109
+ * @throws {METHOD_CANCELED_ERROR} if the method was cancelled by the user.
110
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
111
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
112
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
113
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
114
+ */
115
+ private enable;
116
+ /**
117
+ * Gets the genesis hash of the algod client's configured network.
118
+ * @returns {string} the genesis hash
119
+ */
120
+ private getGenesisHash;
121
+ /**
122
+ * Gets the provider information and updates the supported methods. This should be called
123
+ * before interacting with the provider to ensure methods are supported.
124
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
125
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
126
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
127
+ */
128
+ private getSupportedMethods;
129
+ /**
130
+ * Calls the signTxns methods to sign the supplied transactions.
131
+ * @param {Arc0001SignTxns[]} txns - the unsigned or signed transactions as defined in ARC-0001.
132
+ * @returns {(string | null)[]} the authorized accounts.
133
+ * @throws {INVALID_INPUT_ERROR} if computed group ID for the txns does not match the assigned group ID.
134
+ * @throws {INVALID_GROUP_ID_ERROR} if the unsigned txns is malformed or not conforming to ARC-0001.
135
+ * @throws {METHOD_CANCELED_ERROR} if the method was cancelled by the user.
136
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
137
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
138
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
139
+ * @throws {UNAUTHORIZED_SIGNER_ERROR} if a signer in the request is not authorized by the provider.
140
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
141
+ */
142
+ private signTxns;
143
+ /**
144
+ * Validates whether a method is supported with the provider.
145
+ * @param {ProviderMethod} method - the method to validate.
146
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
147
+ */
148
+ private validateMethod;
149
+ connect: () => Promise<WalletAccount[]>;
150
+ disconnect: () => Promise<void>;
151
+ resumeSession: () => Promise<void>;
152
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
153
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
547
154
  }
548
155
 
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;
556
- name: string;
557
- icon: string;
558
- isWalletConnect: boolean;
559
- };
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>;
573
- disconnect(): Promise<void>;
574
- signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
156
+ interface KmdConstructor {
157
+ token: string | algosdk.KMDTokenHeader | algosdk.CustomTokenHeader;
158
+ baseServer?: string;
159
+ port?: string | number;
160
+ headers?: Record<string, string>;
575
161
  }
576
-
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;
162
+ type KmdOptions = Partial<Pick<KmdConstructor, 'token'>> & Omit<KmdConstructor, 'token'> & {
163
+ wallet?: string;
164
+ };
165
+ declare class KmdWallet extends BaseWallet {
166
+ private client;
167
+ private options;
168
+ private walletName;
169
+ private walletId;
170
+ private password;
171
+ protected store: Store<State>;
172
+ constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.KMD>);
173
+ static defaultMetadata: {
644
174
  name: string;
645
175
  icon: string;
646
- isWalletConnect: boolean;
647
176
  };
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>;
662
- disconnect(): Promise<void>;
663
- signTransactions(connectedAccounts: string[], transactions: Uint8Array[], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
664
- getGenesisID(): string;
665
- getAuthAddress(address: string): string | undefined;
177
+ private initializeClient;
178
+ connect: () => Promise<WalletAccount[]>;
179
+ disconnect: () => Promise<void>;
180
+ resumeSession: () => Promise<void>;
181
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
182
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
183
+ private fetchWalletId;
184
+ private fetchToken;
185
+ private fetchAccounts;
186
+ private releaseToken;
187
+ private getPassword;
666
188
  }
667
189
 
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;
190
+ interface LuteConnectOptions {
191
+ siteName?: string;
192
+ }
193
+ declare class LuteWallet extends BaseWallet {
194
+ private client;
195
+ private options;
196
+ protected store: Store<State>;
197
+ constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.LUTE>);
198
+ static defaultMetadata: {
675
199
  name: string;
676
200
  icon: string;
677
- isWalletConnect: boolean;
678
201
  };
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>;
692
- 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[]>;
202
+ private initializeClient;
203
+ private getGenesisId;
204
+ connect: () => Promise<WalletAccount[]>;
205
+ disconnect: () => Promise<void>;
206
+ resumeSession: () => Promise<void>;
207
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
208
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
695
209
  }
696
210
 
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;
211
+ /** @see https://magic.link/docs/blockchains/other-chains/other/algorand */
212
+ interface MagicAuthOptions {
213
+ apiKey?: string;
214
+ }
215
+ type MagicAuthClient = InstanceWithExtensions<SDKBase, {
216
+ algorand: AlgorandExtension;
217
+ }>;
218
+ declare class MagicAuth extends BaseWallet {
219
+ private client;
220
+ private options;
221
+ protected store: Store<State>;
222
+ userInfo: MagicUserMetadata | null;
223
+ constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.MAGIC>);
224
+ static defaultMetadata: {
715
225
  name: string;
716
226
  icon: string;
717
- isWalletConnect: boolean;
718
227
  };
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>;
732
- disconnect(): Promise<void>;
733
- signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
228
+ private initializeClient;
229
+ connect: (args?: Record<string, any>) => Promise<WalletAccount[]>;
230
+ disconnect: () => Promise<void>;
231
+ resumeSession: () => Promise<void>;
232
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
233
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
734
234
  }
735
235
 
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;
236
+ type MnemonicOptions = {
237
+ persistToStorage?: boolean;
748
238
  };
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;
239
+ declare class MnemonicWallet extends BaseWallet {
240
+ private account;
241
+ private options;
242
+ protected store: Store<State>;
243
+ constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.MNEMONIC>);
244
+ static defaultMetadata: {
757
245
  name: string;
758
246
  icon: string;
759
- isWalletConnect: boolean;
760
247
  };
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>;
775
- disconnect(): Promise<void>;
776
- signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
248
+ private initializeAccount;
249
+ connect: () => Promise<WalletAccount[]>;
250
+ disconnect: () => Promise<void>;
251
+ resumeSession: () => Promise<void>;
252
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
253
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
777
254
  }
778
255
 
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;
256
+ interface PeraWalletConnectOptions {
257
+ projectId: string;
258
+ bridge?: string;
259
+ shouldShowSignTxnToast?: boolean;
260
+ chainId?: 416001 | 416002 | 416003 | 4160;
261
+ compactMode?: boolean;
262
+ }
263
+ declare class PeraWallet extends BaseWallet {
264
+ private client;
265
+ private options;
266
+ protected store: Store<State>;
267
+ constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.PERA>);
268
+ static defaultMetadata: {
786
269
  name: string;
787
270
  icon: string;
788
- isWalletConnect: boolean;
789
271
  };
790
- static init({ clientOptions, algodOptions, algosdkStatic, network }: InitParams<PROVIDER_ID.KMD>): Promise<BaseClient | null>;
791
- connect(): Promise<Wallet>;
792
- 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[]>;
272
+ private initializeClient;
273
+ connect: () => Promise<WalletAccount[]>;
274
+ disconnect: () => Promise<void>;
275
+ resumeSession: () => Promise<void>;
276
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
277
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
801
278
  }
802
279
 
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;
280
+ interface SignClientOptions {
281
+ projectId: string;
282
+ relayUrl?: string;
283
+ metadata?: SignClientTypes.Metadata;
284
+ }
285
+ type WalletConnectModalOptions = Pick<WalletConnectModalConfig, 'enableExplorer' | 'explorerRecommendedWalletIds' | 'privacyPolicyUrl' | 'termsOfServiceUrl' | 'themeMode' | 'themeVariables'>;
286
+ type WalletConnectOptions = SignClientOptions & WalletConnectModalOptions;
287
+ declare class WalletConnect extends BaseWallet {
288
+ private client;
289
+ private options;
290
+ private modal;
291
+ private modalOptions;
292
+ private session;
293
+ private chains;
294
+ protected store: Store<State>;
295
+ constructor({ id, store, subscribe, getAlgodClient, options, metadata }: WalletConstructor<WalletId.WALLETCONNECT>);
296
+ static defaultMetadata: {
816
297
  name: string;
817
298
  icon: string;
818
- isWalletConnect: boolean;
819
299
  };
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
- }>;
832
- 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[]>;
837
- }
838
-
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[]>;
300
+ private initializeClient;
301
+ private initializeModal;
302
+ private onSessionConnected;
303
+ connect: () => Promise<WalletAccount[]>;
304
+ disconnect: () => Promise<void>;
305
+ resumeSession: () => Promise<void>;
306
+ signTransactions: (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean) => Promise<Uint8Array[]>;
307
+ transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
849
308
  }
850
309
 
851
- interface Arc0027Account {
852
- address: string;
853
- name?: string;
310
+ declare enum WalletId {
311
+ DEFLY = "defly",
312
+ EXODUS = "exodus",
313
+ KIBISIS = "kibisis",
314
+ KMD = "kmd",
315
+ LUTE = "lute",
316
+ MAGIC = "magic",
317
+ MNEMONIC = "mnemonic",
318
+ PERA = "pera",
319
+ WALLETCONNECT = "walletconnect"
854
320
  }
855
- interface KibisisClientConstructor {
856
- metadata: Metadata;
857
- algosdk: typeof algosdk;
858
- algodClient: algosdk.Algodv2;
859
- genesisHash: string;
860
- methods: ProviderMethods[];
861
- network: Network;
321
+ type WalletMap = {
322
+ [WalletId.DEFLY]: typeof DeflyWallet;
323
+ [WalletId.EXODUS]: typeof ExodusWallet;
324
+ [WalletId.KIBISIS]: typeof KibisisWallet;
325
+ [WalletId.KMD]: typeof KmdWallet;
326
+ [WalletId.LUTE]: typeof LuteWallet;
327
+ [WalletId.MAGIC]: typeof MagicAuth;
328
+ [WalletId.MNEMONIC]: typeof MnemonicWallet;
329
+ [WalletId.PERA]: typeof PeraWallet;
330
+ [WalletId.WALLETCONNECT]: typeof WalletConnect;
331
+ };
332
+ type WalletOptionsMap = {
333
+ [WalletId.DEFLY]: DeflyWalletConnectOptions;
334
+ [WalletId.EXODUS]: ExodusOptions;
335
+ [WalletId.KIBISIS]: Record<string, never>;
336
+ [WalletId.KMD]: KmdOptions;
337
+ [WalletId.LUTE]: LuteConnectOptions;
338
+ [WalletId.MAGIC]: MagicAuthOptions;
339
+ [WalletId.MNEMONIC]: MnemonicOptions;
340
+ [WalletId.PERA]: PeraWalletConnectOptions;
341
+ [WalletId.WALLETCONNECT]: WalletConnectOptions;
342
+ };
343
+ type SupportedWallet = WalletIdConfig<WalletId> | WalletId;
344
+ type WalletConfigMap = {
345
+ [K in keyof WalletOptionsMap]: {
346
+ options?: WalletOptionsMap[K];
347
+ metadata?: Partial<WalletMetadata>;
348
+ };
349
+ };
350
+ type WalletOptions<T extends keyof WalletOptionsMap> = WalletOptionsMap[T];
351
+ type WalletConfig<T extends keyof WalletConfigMap> = WalletConfigMap[T];
352
+ type WalletIdConfig<T extends keyof WalletConfigMap> = {
353
+ [K in T]: {
354
+ id: K;
355
+ } & WalletConfigMap[K];
356
+ }[T];
357
+ type NonEmptyArray<T> = [T, ...T[]];
358
+ type SupportedWallets = NonEmptyArray<SupportedWallet>;
359
+ type WalletMetadata = {
360
+ name: string;
361
+ icon: string;
362
+ };
363
+ interface BaseWalletConstructor {
364
+ id: WalletId;
365
+ metadata: Partial<WalletMetadata> | undefined;
366
+ getAlgodClient: () => algosdk.Algodv2;
367
+ store: Store<State>;
368
+ subscribe: (callback: (state: State) => void) => () => void;
862
369
  }
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;
370
+ type WalletConstructor<T extends keyof WalletOptionsMap> = BaseWalletConstructor & {
371
+ options?: WalletOptions<T>;
372
+ defaultMetadata?: WalletMetadata;
373
+ };
374
+ type WalletAccount = {
375
+ name: string;
376
+ address: string;
377
+ };
378
+ /** @see https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0001.md#interface-multisigmetadata */
379
+ interface MultisigMetadata {
380
+ /**
381
+ * Multisig version.
382
+ */
383
+ version: number;
384
+ /**
385
+ * Multisig threshold value. Authorization requires a subset of signatures,
386
+ * equal to or greater than the threshold value.
387
+ */
388
+ threshold: number;
389
+ /**
390
+ * List of Algorand addresses of possible signers for this
391
+ * multisig. Order is important.
392
+ */
393
+ addrs: string[];
869
394
  }
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
- };
395
+ /** @see https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0001.md#interface-wallettransaction */
396
+ interface WalletTransaction {
882
397
  /**
883
- * public static functions
398
+ * Base64 encoding of the canonical msgpack encoding of a Transaction.
884
399
  */
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>;
400
+ txn: string;
888
401
  /**
889
- * private functions
402
+ * Optional authorized address used to sign the transaction when the account
403
+ * is rekeyed. Also called the signor/sgnr.
890
404
  */
891
- private convertBytesToBase64;
892
- private convertBase64ToBytes;
405
+ authAddr?: string;
893
406
  /**
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.
407
+ * Multisig metadata used to sign the transaction
901
408
  */
902
- private enable;
409
+ msig?: MultisigMetadata;
903
410
  /**
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.
411
+ * Optional list of addresses that must sign the transactions
909
412
  */
910
- private refreshSupportedMethods;
413
+ signers?: string[];
911
414
  /**
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.
415
+ * Optional base64 encoding of the canonical msgpack encoding of a
416
+ * SignedTxn corresponding to txn, when signers=[]
923
417
  */
924
- private signTxns;
418
+ stxn?: string;
925
419
  /**
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.
420
+ * Optional message explaining the reason of the transaction
929
421
  */
930
- private validateMethod;
422
+ message?: string;
931
423
  /**
932
- * public functions
424
+ * Optional message explaining the reason of this group of transaction
425
+ * Field only allowed in the first transaction of a group
933
426
  */
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[]>;
427
+ groupMessage?: string;
428
+ }
429
+ /** @see https://github.com/perawallet/connect/blob/1.3.3/src/util/model/peraWalletModels.ts */
430
+ interface SignerTransaction {
431
+ txn: algosdk.Transaction;
432
+ /**
433
+ * Optional authorized address used to sign the transaction when
434
+ * the account is rekeyed. Also called the signor/sgnr.
435
+ */
436
+ authAddr?: string;
437
+ /**
438
+ * Optional list of addresses that must sign the transactions.
439
+ * Wallet skips to sign this txn if signers is empty array.
440
+ * If undefined, wallet tries to sign it.
441
+ */
442
+ signers?: string[];
443
+ /**
444
+ * Optional message explaining the reason of the transaction
445
+ */
446
+ message?: string;
447
+ }
448
+ interface JsonRpcRequest<T = any> {
449
+ id: number;
450
+ jsonrpc: string;
451
+ method: string;
452
+ params: T;
453
+ }
454
+
455
+ declare abstract class BaseWallet {
456
+ readonly id: WalletId;
457
+ readonly metadata: WalletMetadata;
458
+ protected store: Store<State>;
459
+ protected getAlgodClient: () => algosdk.Algodv2;
460
+ subscribe: (callback: (state: State) => void) => () => void;
461
+ protected constructor({ id, metadata, store, subscribe, getAlgodClient }: WalletConstructor<WalletId>);
462
+ static defaultMetadata: WalletMetadata;
463
+ abstract connect(args?: Record<string, any>): Promise<WalletAccount[]>;
464
+ abstract disconnect(): Promise<void>;
465
+ abstract resumeSession(): Promise<void>;
466
+ setActive: () => void;
467
+ setActiveAccount: (account: string) => void;
468
+ abstract signTransactions(txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
469
+ abstract transactionSigner(txnGroup: algosdk.Transaction[], indexesToSign: number[]): Promise<Uint8Array[]>;
470
+ get name(): string;
471
+ get accounts(): WalletAccount[];
472
+ get addresses(): string[];
473
+ get activeAccount(): WalletAccount | null;
474
+ get activeAddress(): string | null;
475
+ get activeNetwork(): NetworkId;
476
+ get isConnected(): boolean;
477
+ get isActive(): boolean;
478
+ protected onDisconnect(): void;
938
479
  }
939
480
 
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[]>;
481
+ type WalletState = {
482
+ accounts: WalletAccount[];
483
+ activeAccount: WalletAccount | null;
967
484
  };
485
+ type WalletStateMap = Partial<Record<WalletId, WalletState>>;
486
+ interface State {
487
+ wallets: WalletStateMap;
488
+ activeWallet: WalletId | null;
489
+ activeNetwork: NetworkId;
490
+ }
491
+ declare const defaultState: State;
492
+
493
+ interface WalletManagerConfig {
494
+ wallets?: SupportedWallet[];
495
+ network?: NetworkId;
496
+ algod?: NetworkConfig;
497
+ }
498
+ declare class WalletManager {
499
+ _clients: Map<WalletId, BaseWallet>;
500
+ networkConfig: NetworkConfigMap;
501
+ algodClient: algosdk.Algodv2;
502
+ store: Store<State>;
503
+ subscribe: (callback: (state: State) => void) => () => void;
504
+ constructor({ wallets, network, algod }?: WalletManagerConfig);
505
+ private loadPersistedState;
506
+ private savePersistedState;
507
+ private initializeWallets;
508
+ get wallets(): BaseWallet[];
509
+ getWallet(walletId: WalletId): BaseWallet | undefined;
510
+ resumeSessions(): Promise<void>;
511
+ private initNetworkConfig;
512
+ private createAlgodClient;
513
+ getAlgodClient: () => algosdk.Algodv2;
514
+ setActiveNetwork: (networkId: NetworkId) => void;
515
+ get activeNetwork(): NetworkId;
516
+ get activeWallet(): BaseWallet | null;
517
+ get activeWalletAccounts(): WalletAccount[] | null;
518
+ get activeWalletAddresses(): string[] | null;
519
+ get activeAccount(): WalletAccount | null;
520
+ get activeAddress(): string | null;
521
+ get signTransactions(): (txnGroup: algosdk.Transaction[] | algosdk.Transaction[][] | Uint8Array[] | Uint8Array[][], indexesToSign?: number[] | undefined, returnGroup?: boolean | undefined) => Promise<Uint8Array[]>;
522
+ /**
523
+ * A function which can sign transactions from an atomic transaction group. The logic will be
524
+ * specific to each wallet, but the function will always return a promise that resolves to an
525
+ * array of encoded signed transactions matching the length of the indexesToSign array.
526
+ *
527
+ * @see https://github.com/algorand/js-algorand-sdk/blob/v2.6.0/src/signer.ts#L7-L18
528
+ *
529
+ * @param txnGroup - The atomic group containing transactions to be signed
530
+ * @param indexesToSign - An array of indexes in the atomic transaction group that should be signed
531
+ * @returns A promise which resolves an array of encoded signed transactions. The length of the
532
+ * array will be the same as the length of indexesToSign, and each index i in the array
533
+ * corresponds to the signed transaction from txnGroup[indexesToSign[i]]
534
+ */
535
+ get transactionSigner(): algosdk.TransactionSigner;
536
+ }
968
537
 
969
- interface InitializeProvidersOptions {
970
- providers: ProvidersArray;
971
- nodeConfig?: NodeConfig;
972
- algosdkStatic?: typeof algosdk;
973
- debug?: boolean;
538
+ declare class StorageAdapter {
539
+ static getItem(key: string): string | null;
540
+ static setItem(key: string, value: string): void;
974
541
  }
975
- declare function useInitializeProviders({ providers, nodeConfig, algosdkStatic, debug }: InitializeProvidersOptions): Partial<Record<PROVIDER_ID, BaseClient | null>> | null;
976
542
 
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 };
543
+ export { BaseWallet, type BaseWalletConstructor, DeflyWallet, type DeflyWalletConnectOptions, type EnableResult, type Exodus, type ExodusOptions, ExodusWallet, type JsonRpcRequest, type KmdOptions, KmdWallet, MagicAuth, type MagicAuthClient, type MagicAuthOptions, 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 };