@reown/appkit-common-react-native 0.0.0-feat-multichain-20250804182547 → 0.0.0-feat-multichain-20250805142032

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 (221) hide show
  1. package/lib/commonjs/index.js +4 -4
  2. package/lib/commonjs/index.js.map +1 -1
  3. package/lib/commonjs/types/api/blockchain-api.js +15 -0
  4. package/lib/commonjs/types/api/blockchain-api.js.map +1 -0
  5. package/lib/commonjs/types/api/events.js +6 -0
  6. package/lib/commonjs/types/api/events.js.map +1 -0
  7. package/lib/commonjs/types/api/index.js +39 -0
  8. package/lib/commonjs/types/api/index.js.map +1 -0
  9. package/lib/commonjs/types/api/wallet-api.js +2 -0
  10. package/lib/commonjs/types/api/wallet-api.js.map +1 -0
  11. package/lib/commonjs/types/blockchain/adapter.js +6 -0
  12. package/lib/commonjs/types/blockchain/adapter.js.map +1 -0
  13. package/lib/commonjs/types/blockchain/balance.js +6 -0
  14. package/lib/commonjs/types/blockchain/balance.js.map +1 -0
  15. package/lib/commonjs/types/blockchain/index.js +50 -0
  16. package/lib/commonjs/types/blockchain/index.js.map +1 -0
  17. package/lib/commonjs/types/blockchain/network.js +6 -0
  18. package/lib/commonjs/types/blockchain/network.js.map +1 -0
  19. package/lib/commonjs/types/blockchain/transaction.js +2 -0
  20. package/lib/commonjs/types/blockchain/transaction.js.map +1 -0
  21. package/lib/commonjs/types/common.js +2 -0
  22. package/lib/commonjs/types/common.js.map +1 -0
  23. package/lib/commonjs/types/index.js +105 -0
  24. package/lib/commonjs/types/index.js.map +1 -0
  25. package/lib/commonjs/types/onramp/countries.js +2 -0
  26. package/lib/commonjs/types/onramp/countries.js.map +1 -0
  27. package/lib/commonjs/types/onramp/currencies.js +2 -0
  28. package/lib/commonjs/types/onramp/currencies.js.map +1 -0
  29. package/lib/commonjs/types/onramp/errors.js +22 -0
  30. package/lib/commonjs/types/onramp/errors.js.map +1 -0
  31. package/lib/commonjs/types/onramp/index.js +50 -0
  32. package/lib/commonjs/types/onramp/index.js.map +1 -0
  33. package/lib/commonjs/types/onramp/quotes.js +2 -0
  34. package/lib/commonjs/types/onramp/quotes.js.map +1 -0
  35. package/lib/commonjs/types/siwe/config.js +6 -0
  36. package/lib/commonjs/types/siwe/config.js.map +1 -0
  37. package/lib/commonjs/types/siwe/index.js +28 -0
  38. package/lib/commonjs/types/siwe/index.js.map +1 -0
  39. package/lib/commonjs/types/siwe/message.js +6 -0
  40. package/lib/commonjs/types/siwe/message.js.map +1 -0
  41. package/lib/commonjs/types/storage.js +2 -0
  42. package/lib/commonjs/types/storage.js.map +1 -0
  43. package/lib/commonjs/types/swap/index.js +17 -0
  44. package/lib/commonjs/types/swap/index.js.map +1 -0
  45. package/lib/commonjs/types/swap/tokens.js +6 -0
  46. package/lib/commonjs/types/swap/tokens.js.map +1 -0
  47. package/lib/commonjs/types/ui.js +6 -0
  48. package/lib/commonjs/types/ui.js.map +1 -0
  49. package/lib/commonjs/types/wallet/connection.js +6 -0
  50. package/lib/commonjs/types/wallet/connection.js.map +1 -0
  51. package/lib/commonjs/{utils/TypeUtil.js → types/wallet/connector.js} +1 -15
  52. package/lib/commonjs/types/wallet/connector.js.map +1 -0
  53. package/lib/commonjs/types/wallet/index.js +39 -0
  54. package/lib/commonjs/types/wallet/index.js.map +1 -0
  55. package/lib/commonjs/types/wallet/wallet-info.js +6 -0
  56. package/lib/commonjs/types/wallet/wallet-info.js.map +1 -0
  57. package/lib/commonjs/utils/ConstantsUtil.js +1 -1
  58. package/lib/module/index.js +1 -1
  59. package/lib/module/index.js.map +1 -1
  60. package/lib/module/types/api/blockchain-api.js +10 -0
  61. package/lib/module/types/api/blockchain-api.js.map +1 -0
  62. package/lib/module/types/api/events.js +4 -0
  63. package/lib/module/types/api/events.js.map +1 -0
  64. package/lib/module/types/api/index.js +7 -0
  65. package/lib/module/types/api/index.js.map +1 -0
  66. package/lib/module/types/api/wallet-api.js +2 -0
  67. package/lib/module/types/api/wallet-api.js.map +1 -0
  68. package/lib/module/types/blockchain/adapter.js +4 -0
  69. package/lib/module/types/blockchain/adapter.js.map +1 -0
  70. package/lib/module/types/blockchain/balance.js +4 -0
  71. package/lib/module/types/blockchain/balance.js.map +1 -0
  72. package/lib/module/types/blockchain/index.js +8 -0
  73. package/lib/module/types/blockchain/index.js.map +1 -0
  74. package/lib/module/types/blockchain/network.js +4 -0
  75. package/lib/module/types/blockchain/network.js.map +1 -0
  76. package/lib/module/types/blockchain/transaction.js +2 -0
  77. package/lib/module/types/blockchain/transaction.js.map +1 -0
  78. package/lib/module/types/common.js +2 -0
  79. package/lib/module/types/common.js.map +1 -0
  80. package/lib/module/types/index.js +31 -0
  81. package/lib/module/types/index.js.map +1 -0
  82. package/lib/module/types/onramp/countries.js +2 -0
  83. package/lib/module/types/onramp/countries.js.map +1 -0
  84. package/lib/module/types/onramp/currencies.js +2 -0
  85. package/lib/module/types/onramp/currencies.js.map +1 -0
  86. package/lib/module/types/onramp/errors.js +18 -0
  87. package/lib/module/types/onramp/errors.js.map +1 -0
  88. package/lib/module/types/onramp/index.js +8 -0
  89. package/lib/module/types/onramp/index.js.map +1 -0
  90. package/lib/module/types/onramp/quotes.js +2 -0
  91. package/lib/module/types/onramp/quotes.js.map +1 -0
  92. package/lib/module/types/siwe/config.js +4 -0
  93. package/lib/module/types/siwe/config.js.map +1 -0
  94. package/lib/module/types/siwe/index.js +6 -0
  95. package/lib/module/types/siwe/index.js.map +1 -0
  96. package/lib/module/types/siwe/message.js +4 -0
  97. package/lib/module/types/siwe/message.js.map +1 -0
  98. package/lib/module/types/storage.js +2 -0
  99. package/lib/module/types/storage.js.map +1 -0
  100. package/lib/module/types/swap/index.js +5 -0
  101. package/lib/module/types/swap/index.js.map +1 -0
  102. package/lib/module/types/swap/tokens.js +4 -0
  103. package/lib/module/types/swap/tokens.js.map +1 -0
  104. package/lib/module/types/ui.js +4 -0
  105. package/lib/module/types/ui.js.map +1 -0
  106. package/lib/module/types/wallet/connection.js +4 -0
  107. package/lib/module/types/wallet/connection.js.map +1 -0
  108. package/lib/module/{utils/TypeUtil.js → types/wallet/connector.js} +1 -16
  109. package/lib/module/types/wallet/connector.js.map +1 -0
  110. package/lib/module/types/wallet/index.js +7 -0
  111. package/lib/module/types/wallet/index.js.map +1 -0
  112. package/lib/module/types/wallet/wallet-info.js +4 -0
  113. package/lib/module/types/wallet/wallet-info.js.map +1 -0
  114. package/lib/module/utils/ConstantsUtil.js +1 -1
  115. package/lib/typescript/adapters/BlockchainAdapter.d.ts +1 -1
  116. package/lib/typescript/adapters/BlockchainAdapter.d.ts.map +1 -1
  117. package/lib/typescript/adapters/EvmAdapter.d.ts +1 -1
  118. package/lib/typescript/adapters/EvmAdapter.d.ts.map +1 -1
  119. package/lib/typescript/index.d.ts +1 -1
  120. package/lib/typescript/index.d.ts.map +1 -1
  121. package/lib/typescript/networks/bitcoin.d.ts +1 -1
  122. package/lib/typescript/networks/bitcoin.d.ts.map +1 -1
  123. package/lib/typescript/networks/solana.d.ts +1 -1
  124. package/lib/typescript/networks/solana.d.ts.map +1 -1
  125. package/lib/typescript/types/api/blockchain-api.d.ts +183 -0
  126. package/lib/typescript/types/api/blockchain-api.d.ts.map +1 -0
  127. package/lib/typescript/types/api/events.d.ts +304 -0
  128. package/lib/typescript/types/api/events.d.ts.map +1 -0
  129. package/lib/typescript/types/api/index.d.ts +4 -0
  130. package/lib/typescript/types/api/index.d.ts.map +1 -0
  131. package/lib/typescript/types/api/wallet-api.d.ts +45 -0
  132. package/lib/typescript/types/api/wallet-api.d.ts.map +1 -0
  133. package/lib/typescript/types/blockchain/adapter.d.ts +40 -0
  134. package/lib/typescript/types/blockchain/adapter.d.ts.map +1 -0
  135. package/lib/typescript/types/blockchain/balance.d.ts +28 -0
  136. package/lib/typescript/types/blockchain/balance.d.ts.map +1 -0
  137. package/lib/typescript/types/blockchain/index.d.ts +5 -0
  138. package/lib/typescript/types/blockchain/index.d.ts.map +1 -0
  139. package/lib/typescript/types/blockchain/network.d.ts +47 -0
  140. package/lib/typescript/types/blockchain/network.d.ts.map +1 -0
  141. package/lib/typescript/types/blockchain/transaction.d.ts +63 -0
  142. package/lib/typescript/types/blockchain/transaction.d.ts.map +1 -0
  143. package/lib/typescript/types/common.d.ts +24 -0
  144. package/lib/typescript/types/common.d.ts.map +1 -0
  145. package/lib/typescript/types/index.d.ts +10 -0
  146. package/lib/typescript/types/index.d.ts.map +1 -0
  147. package/lib/typescript/types/onramp/countries.d.ts +11 -0
  148. package/lib/typescript/types/onramp/countries.d.ts.map +1 -0
  149. package/lib/typescript/types/onramp/currencies.d.ts +30 -0
  150. package/lib/typescript/types/onramp/currencies.d.ts.map +1 -0
  151. package/lib/typescript/types/onramp/errors.d.ts +21 -0
  152. package/lib/typescript/types/onramp/errors.d.ts.map +1 -0
  153. package/lib/typescript/types/onramp/index.d.ts +5 -0
  154. package/lib/typescript/types/onramp/index.d.ts.map +1 -0
  155. package/lib/typescript/types/onramp/quotes.d.ts +45 -0
  156. package/lib/typescript/types/onramp/quotes.d.ts.map +1 -0
  157. package/lib/typescript/types/siwe/config.d.ts +31 -0
  158. package/lib/typescript/types/siwe/config.d.ts.map +1 -0
  159. package/lib/typescript/types/siwe/index.d.ts +3 -0
  160. package/lib/typescript/types/siwe/index.d.ts.map +1 -0
  161. package/lib/typescript/types/siwe/message.d.ts +57 -0
  162. package/lib/typescript/types/siwe/message.d.ts.map +1 -0
  163. package/lib/typescript/types/storage.d.ts +27 -0
  164. package/lib/typescript/types/storage.d.ts.map +1 -0
  165. package/lib/typescript/types/swap/index.d.ts +2 -0
  166. package/lib/typescript/types/swap/index.d.ts.map +1 -0
  167. package/lib/typescript/types/swap/tokens.d.ts +19 -0
  168. package/lib/typescript/types/swap/tokens.d.ts.map +1 -0
  169. package/lib/typescript/types/ui.d.ts +26 -0
  170. package/lib/typescript/types/ui.d.ts.map +1 -0
  171. package/lib/typescript/types/wallet/connection.d.ts +30 -0
  172. package/lib/typescript/types/wallet/connection.d.ts.map +1 -0
  173. package/lib/typescript/types/wallet/connector.d.ts +57 -0
  174. package/lib/typescript/types/wallet/connector.d.ts.map +1 -0
  175. package/lib/typescript/types/wallet/index.d.ts +4 -0
  176. package/lib/typescript/types/wallet/index.d.ts.map +1 -0
  177. package/lib/typescript/types/wallet/wallet-info.d.ts +36 -0
  178. package/lib/typescript/types/wallet/wallet-info.d.ts.map +1 -0
  179. package/lib/typescript/utils/NetworkUtil.d.ts +1 -1
  180. package/lib/typescript/utils/NetworkUtil.d.ts.map +1 -1
  181. package/package.json +1 -1
  182. package/src/adapters/BlockchainAdapter.ts +1 -1
  183. package/src/adapters/EvmAdapter.ts +1 -1
  184. package/src/adapters/__tests__/EvmAdapter.test.ts +1 -1
  185. package/src/index.ts +2 -1
  186. package/src/networks/bitcoin.ts +1 -1
  187. package/src/networks/solana.ts +1 -1
  188. package/src/types/api/blockchain-api.ts +213 -0
  189. package/src/types/api/events.ts +394 -0
  190. package/src/types/api/index.ts +4 -0
  191. package/src/types/api/wallet-api.ts +64 -0
  192. package/src/types/blockchain/adapter.ts +52 -0
  193. package/src/types/blockchain/balance.ts +31 -0
  194. package/src/types/blockchain/index.ts +5 -0
  195. package/src/types/blockchain/network.ts +39 -0
  196. package/src/types/blockchain/transaction.ts +71 -0
  197. package/src/types/common.ts +56 -0
  198. package/src/types/index.ts +28 -0
  199. package/src/types/onramp/countries.ts +11 -0
  200. package/src/types/onramp/currencies.ts +32 -0
  201. package/src/types/onramp/errors.ts +22 -0
  202. package/src/types/onramp/index.ts +5 -0
  203. package/src/types/onramp/quotes.ts +46 -0
  204. package/src/types/siwe/config.ts +44 -0
  205. package/src/types/siwe/index.ts +3 -0
  206. package/src/types/siwe/message.ts +62 -0
  207. package/src/types/storage.ts +30 -0
  208. package/src/types/swap/index.ts +2 -0
  209. package/src/types/swap/tokens.ts +21 -0
  210. package/src/types/ui.ts +26 -0
  211. package/src/types/wallet/connection.ts +33 -0
  212. package/src/types/wallet/connector.ts +84 -0
  213. package/src/types/wallet/index.ts +4 -0
  214. package/src/types/wallet/wallet-info.ts +41 -0
  215. package/src/utils/ConstantsUtil.ts +1 -1
  216. package/src/utils/NetworkUtil.ts +1 -1
  217. package/lib/commonjs/utils/TypeUtil.js.map +0 -1
  218. package/lib/module/utils/TypeUtil.js.map +0 -1
  219. package/lib/typescript/utils/TypeUtil.d.ts +0 -395
  220. package/lib/typescript/utils/TypeUtil.d.ts.map +0 -1
  221. package/src/utils/TypeUtil.ts +0 -495
@@ -1,495 +0,0 @@
1
- import { EventEmitter } from 'events';
2
- import type { BlockchainAdapter } from '../adapters/BlockchainAdapter';
3
-
4
- export type CaipAddress = `${string}:${string}:${string}`;
5
-
6
- export type CaipNetworkId = `${string}:${string}`;
7
-
8
- export type ChainNamespace = 'eip155' | 'solana' | 'polkadot' | 'bip122';
9
-
10
- export type AdapterType = 'solana' | 'wagmi' | 'ethers' | 'universal' | 'bip122';
11
-
12
- export type Network = {
13
- // Core viem/chain properties
14
- id: number | string;
15
- name: string;
16
- nativeCurrency: { name: string; symbol: string; decimals: number };
17
- rpcUrls: {
18
- default: { http: readonly string[] };
19
- [key: string]: { http: readonly string[] } | undefined;
20
- };
21
- blockExplorers?: {
22
- default: { name: string; url: string };
23
- [key: string]: { name: string; url: string } | undefined;
24
- };
25
-
26
- // AppKit specific / CAIP properties (Optional in type, but needed in practice)
27
- chainNamespace?: ChainNamespace; // e.g., 'eip155'
28
- caipNetworkId?: CaipNetworkId; // e.g., 'eip155:1'
29
- testnet?: boolean;
30
- deprecatedCaipNetworkId?: CaipNetworkId; // for Solana deprecated id
31
- imageUrl?: string;
32
- };
33
-
34
- export type AppKitNetwork = Network & {
35
- chainNamespace: ChainNamespace; // mandatory for AppKitNetwork
36
- caipNetworkId: CaipNetworkId; // mandatory for AppKitNetwork
37
- };
38
-
39
- export interface AppKitOpenOptions {
40
- view: 'Account' | 'Connect' | 'Networks' | 'Swap' | 'OnRamp';
41
- }
42
-
43
- export type AppKitConnectOptions = Pick<
44
- ConnectOptions,
45
- 'namespaces' | 'defaultChain' | 'universalLink'
46
- >;
47
-
48
- export interface CaipNetwork {
49
- id: CaipNetworkId;
50
- name?: string;
51
- imageId?: string;
52
- imageUrl?: string;
53
- }
54
-
55
- export interface Balance {
56
- name?: string;
57
- amount: string;
58
- symbol: string;
59
- quantity?: {
60
- decimals: string;
61
- numeric: string;
62
- };
63
- chainId?: string;
64
- address?: CaipAddress; // contract address
65
- value?: number; //total value of the amount in currency
66
- price?: number; //price of the token in currency
67
- iconUrl?: string;
68
- }
69
-
70
- export type TransactionStatus = 'confirmed' | 'failed' | 'pending';
71
- export type TransactionDirection = 'in' | 'out' | 'self';
72
- export type TransactionImage = {
73
- type: 'FUNGIBLE' | 'NFT' | undefined;
74
- url: string | undefined;
75
- };
76
-
77
- export interface Transaction {
78
- id: string;
79
- metadata: TransactionMetadata;
80
- transfers: TransactionTransfer[];
81
- }
82
-
83
- export interface TransactionMetadata {
84
- application: {
85
- iconUrl: string | null;
86
- name: string | null;
87
- };
88
- operationType: string;
89
- hash: string;
90
- minedAt: string;
91
- sentFrom: string;
92
- sentTo: string;
93
- status: TransactionStatus;
94
- nonce: number;
95
- chain?: string;
96
- }
97
-
98
- export interface TransactionTransfer {
99
- fungible_info?: {
100
- name?: string;
101
- symbol?: string;
102
- icon?: {
103
- url: string;
104
- };
105
- };
106
- nft_info?: TransactionNftInfo;
107
- direction: TransactionDirection;
108
- quantity: TransactionQuantity;
109
- value?: number;
110
- price?: number;
111
- }
112
-
113
- export interface TransactionNftInfo {
114
- name?: string;
115
- content?: TransactionContent;
116
- flags: TransactionNftInfoFlags;
117
- }
118
-
119
- export interface TransactionNftInfoFlags {
120
- is_spam: boolean;
121
- }
122
-
123
- export interface TransactionContent {
124
- preview?: TransactionPreview;
125
- detail?: TransactionDetail;
126
- }
127
-
128
- export interface TransactionPreview {
129
- url: string;
130
- content_type?: null;
131
- }
132
-
133
- export interface TransactionDetail {
134
- url: string;
135
- content_type?: null;
136
- }
137
-
138
- export interface TransactionQuantity {
139
- numeric: string;
140
- }
141
-
142
- export type SocialProvider =
143
- | 'google'
144
- | 'facebook'
145
- | 'github'
146
- | 'apple'
147
- | 'x'
148
- | 'discord'
149
- | 'email'
150
- | 'farcaster';
151
-
152
- export type ThemeMode = 'dark' | 'light';
153
-
154
- export interface ThemeVariables {
155
- accent?: string;
156
- }
157
-
158
- export interface Token {
159
- address: string;
160
- image?: string;
161
- }
162
-
163
- export type Tokens = Record<CaipNetworkId, Token>;
164
-
165
- export type Metadata = {
166
- name: string;
167
- description: string;
168
- url: string;
169
- icons: string[];
170
- redirect?: {
171
- native?: string;
172
- universal?: string;
173
- linkMode?: boolean;
174
- };
175
- };
176
-
177
- export interface Identity {
178
- name: string;
179
- avatar?: string;
180
- }
181
-
182
- export interface Connection {
183
- accounts: CaipAddress[];
184
- balances: Map<CaipAddress, Balance[]>;
185
- adapter: BlockchainAdapter;
186
- caipNetwork: CaipNetworkId;
187
- wallet?: WalletInfo;
188
- properties?: ConnectionProperties;
189
- type?: AccountType;
190
- identities?: Map<CaipAddress, Identity>;
191
- }
192
-
193
- export type BlockchainAdapterConfig = {
194
- supportedNamespace: ChainNamespace;
195
- adapterType: AdapterType;
196
- };
197
-
198
- export interface BlockchainAdapterInitParams {
199
- connector: WalletConnector;
200
- }
201
-
202
- //********** Adapter Event Payloads **********//
203
- export type AccountsChangedEvent = {
204
- accounts: CaipAddress[];
205
- };
206
-
207
- export type ChainChangedEvent = {
208
- chainId: string;
209
- };
210
-
211
- export type DisconnectEvent = undefined;
212
-
213
- export type BalanceChangedEvent = {
214
- address: CaipAddress;
215
- balance: Balance;
216
- };
217
-
218
- //********** Adapter Event Map **********//
219
- export interface AdapterEvents {
220
- accountsChanged: (event: AccountsChangedEvent) => void;
221
- chainChanged: (event: ChainChangedEvent) => void;
222
- disconnect: (event: DisconnectEvent) => void;
223
- balanceChanged: (event: BalanceChangedEvent) => void;
224
- }
225
-
226
- export interface GetBalanceParams {
227
- network: AppKitNetwork;
228
- address?: CaipAddress;
229
- tokens?: Tokens;
230
- }
231
-
232
- export type GetBalanceResponse = Balance;
233
-
234
- //********** Connector Types **********//
235
- interface BaseNamespace {
236
- chains?: CaipNetworkId[];
237
- accounts: CaipAddress[];
238
- methods: string[];
239
- events: string[];
240
- }
241
-
242
- type Namespace = BaseNamespace;
243
-
244
- export type Namespaces = Record<string, Namespace>;
245
-
246
- export type ProposalNamespaces = Record<
247
- string,
248
- Omit<Namespace, 'accounts'> &
249
- Required<Pick<Namespace, 'chains'>> & { rpcMap: Record<string, string> }
250
- >;
251
-
252
- export type ConnectOptions = {
253
- namespaces?: ProposalNamespaces;
254
- defaultChain?: CaipNetworkId;
255
- universalLink?: string;
256
- siweConfig?: AppKitSIWEClient;
257
- };
258
-
259
- export type ConnectorInitOptions = {
260
- storage: Storage;
261
- metadata: Metadata;
262
- };
263
-
264
- export abstract class WalletConnector extends EventEmitter {
265
- public type: ConnectorType;
266
- protected provider?: Provider;
267
- protected namespaces?: Namespaces;
268
- protected wallet?: WalletInfo;
269
- protected storage?: Storage;
270
- protected metadata?: Metadata;
271
- protected properties?: ConnectionProperties;
272
-
273
- constructor({ type }: { type: ConnectorType }) {
274
- super();
275
- this.type = type;
276
- }
277
-
278
- public async init(ops: ConnectorInitOptions) {
279
- this.storage = ops.storage;
280
- this.metadata = ops.metadata;
281
- }
282
-
283
- public setProvider(provider: Provider) {
284
- this.provider = provider;
285
- }
286
-
287
- public async disconnect() {
288
- await this.provider?.disconnect();
289
- this.namespaces = undefined;
290
- this.wallet = undefined;
291
- this.properties = undefined;
292
- }
293
-
294
- abstract connect(opts: ConnectOptions): Promise<Namespaces | undefined>;
295
- abstract getProvider(namespace?: ChainNamespace): Provider;
296
- abstract getNamespaces(): Namespaces;
297
- abstract getChainId(namespace: ChainNamespace): CaipNetworkId | undefined;
298
- abstract getWalletInfo(): WalletInfo | undefined;
299
- abstract getProperties(): ConnectionProperties | undefined;
300
- abstract switchNetwork(network: AppKitNetwork): Promise<void>;
301
- abstract restoreSession(): Promise<boolean>;
302
- }
303
-
304
- export type ConnectorType = 'walletconnect' | 'coinbase' | 'phantom';
305
-
306
- //********** Provider Types **********//
307
-
308
- export interface Provider {
309
- connect<T>(params?: any): Promise<T>;
310
- disconnect(): Promise<void>;
311
- request<T = unknown>(
312
- args: RequestArguments,
313
- chain?: string | undefined,
314
- expiry?: number | undefined
315
- ): Promise<T>;
316
- on(event: string, listener: (args?: any) => void): any;
317
- off(event: string, listener: (args?: any) => void): any;
318
- }
319
-
320
- export interface RequestArguments {
321
- method: string;
322
- params?: unknown[] | Record<string, unknown> | object | undefined;
323
- }
324
-
325
- //********** Others **********//
326
-
327
- export interface ConnectionResponse {
328
- accounts: string[];
329
- chainId: string;
330
- [key: string]: any;
331
- }
332
-
333
- export interface WalletInfo {
334
- name?: string;
335
- icon?: string;
336
- description?: string;
337
- url?: string;
338
- icons?: string[];
339
- redirect?: {
340
- native?: string;
341
- universal?: string;
342
- linkMode?: boolean;
343
- };
344
- [key: string]: unknown;
345
- }
346
-
347
- export interface ConnectionProperties {
348
- email?: string;
349
- username?: string;
350
- smartAccounts?: CaipAddress[];
351
- provider?: SocialProvider;
352
- sessionTopic?: string;
353
- }
354
-
355
- export interface LinkingRecord {
356
- redirect: string;
357
- href: string;
358
- }
359
-
360
- export interface WalletDeepLink {
361
- href: string;
362
- name: string;
363
- }
364
-
365
- export type AccountType = 'eoa' | 'smartAccount';
366
-
367
- export interface Storage {
368
- /**
369
- * Returns all keys in storage.
370
- */
371
- getKeys(): Promise<string[]>;
372
-
373
- /**
374
- * Returns all key-value entries in storage.
375
- */
376
- getEntries<T = any>(): Promise<[string, T][]>;
377
-
378
- /**
379
- * Get an item from storage for a given key.
380
- * @param key The key to retrieve.
381
- */
382
- getItem<T = any>(key: string): Promise<T | undefined>;
383
-
384
- /**
385
- * Set an item in storage for a given key.
386
- * @param key The key to set.
387
- * @param value The value to set.
388
- */
389
- setItem<T = any>(key: string, value: T): Promise<void>;
390
-
391
- /**
392
- * Remove an item from storage for a given key.
393
- * @param key The key to remove.
394
- */
395
- removeItem(key: string): Promise<void>;
396
- }
397
-
398
- //********** SIWE Types **********//
399
- export interface SIWESession {
400
- address: string;
401
- chainId: number;
402
- }
403
-
404
- interface CacaoHeader {
405
- t: 'caip122';
406
- }
407
-
408
- export interface SIWECreateMessageArgs {
409
- domain: string;
410
- nonce: string;
411
- uri: string;
412
- address: CaipAddress;
413
- version: '1';
414
- type?: CacaoHeader['t'];
415
- nbf?: string;
416
- exp?: string;
417
- statement?: string;
418
- requestId?: string;
419
- resources?: string[];
420
- expiry?: number;
421
- iat?: string;
422
- }
423
- export type SIWEMessageArgs = {
424
- chains: CaipNetworkId[];
425
- methods?: string[];
426
- } & Omit<SIWECreateMessageArgs, 'address' | 'nonce' | 'version'>;
427
- // Signed Cacao (CAIP-74)
428
- interface CacaoPayload {
429
- domain: string;
430
- aud: string;
431
- nonce: string;
432
- iss: string;
433
- version?: string;
434
- iat?: string;
435
- nbf?: string;
436
- exp?: string;
437
- statement?: string;
438
- requestId?: string;
439
- resources?: string[];
440
- type?: string;
441
- }
442
-
443
- interface Cacao {
444
- h: CacaoHeader;
445
- p: CacaoPayload;
446
- s: {
447
- t: 'eip191' | 'eip1271';
448
- s: string;
449
- m?: string;
450
- };
451
- }
452
-
453
- export interface SIWEVerifyMessageArgs {
454
- message: string;
455
- signature: string;
456
- cacao?: Cacao;
457
- }
458
-
459
- export interface SIWEClientMethods {
460
- getNonce: (address?: string) => Promise<string>;
461
- createMessage: (args: SIWECreateMessageArgs) => string;
462
- verifyMessage: (args: SIWEVerifyMessageArgs) => Promise<boolean>;
463
- getSession: () => Promise<SIWESession | null>;
464
- signOut: () => Promise<boolean>;
465
- getMessageParams?: () => Promise<SIWEMessageArgs>;
466
- onSignIn?: (session?: SIWESession) => void;
467
- onSignOut?: () => void;
468
- }
469
-
470
- export interface SIWEConfig extends SIWEClientMethods {
471
- // Defaults to true
472
- enabled?: boolean;
473
- // In milliseconds, defaults to 5 minutes
474
- nonceRefetchIntervalMs?: number;
475
- // In milliseconds, defaults to 5 minutes
476
- sessionRefetchIntervalMs?: number;
477
- // Defaults to true
478
- signOutOnDisconnect?: boolean;
479
- // Defaults to true
480
- signOutOnAccountChange?: boolean;
481
- // Defaults to true
482
- signOutOnNetworkChange?: boolean;
483
- }
484
-
485
- export interface AppKitSIWEClient extends SIWEClientMethods {
486
- signIn: () => Promise<SIWESession | undefined>;
487
- options: {
488
- enabled: boolean;
489
- nonceRefetchIntervalMs: number;
490
- sessionRefetchIntervalMs: number;
491
- signOutOnDisconnect: boolean;
492
- signOutOnAccountChange: boolean;
493
- signOutOnNetworkChange: boolean;
494
- };
495
- }