@reown/appkit-common-react-native 2.0.0-alpha.2 → 2.0.0-alpha.4

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 (237) hide show
  1. package/lib/commonjs/adapters/BlockchainAdapter.js +25 -12
  2. package/lib/commonjs/adapters/BlockchainAdapter.js.map +1 -1
  3. package/lib/commonjs/adapters/EvmAdapter.js +0 -11
  4. package/lib/commonjs/adapters/EvmAdapter.js.map +1 -1
  5. package/lib/commonjs/index.js +4 -4
  6. package/lib/commonjs/index.js.map +1 -1
  7. package/lib/commonjs/types/api/blockchain-api.js +15 -0
  8. package/lib/commonjs/types/api/blockchain-api.js.map +1 -0
  9. package/lib/commonjs/types/api/events.js +6 -0
  10. package/lib/commonjs/types/api/events.js.map +1 -0
  11. package/lib/commonjs/types/api/index.js +39 -0
  12. package/lib/commonjs/types/api/index.js.map +1 -0
  13. package/lib/commonjs/types/api/wallet-api.js +6 -0
  14. package/lib/commonjs/types/api/wallet-api.js.map +1 -0
  15. package/lib/commonjs/types/blockchain/adapter.js +6 -0
  16. package/lib/commonjs/types/blockchain/adapter.js.map +1 -0
  17. package/lib/commonjs/types/blockchain/balance.js +6 -0
  18. package/lib/commonjs/types/blockchain/balance.js.map +1 -0
  19. package/lib/commonjs/types/blockchain/index.js +50 -0
  20. package/lib/commonjs/types/blockchain/index.js.map +1 -0
  21. package/lib/commonjs/types/blockchain/network.js +6 -0
  22. package/lib/commonjs/types/blockchain/network.js.map +1 -0
  23. package/lib/commonjs/types/blockchain/transaction.js +2 -0
  24. package/lib/commonjs/types/blockchain/transaction.js.map +1 -0
  25. package/lib/commonjs/types/common.js +2 -0
  26. package/lib/commonjs/types/common.js.map +1 -0
  27. package/lib/commonjs/types/index.js +105 -0
  28. package/lib/commonjs/types/index.js.map +1 -0
  29. package/lib/commonjs/types/onramp/countries.js +2 -0
  30. package/lib/commonjs/types/onramp/countries.js.map +1 -0
  31. package/lib/commonjs/types/onramp/currencies.js +2 -0
  32. package/lib/commonjs/types/onramp/currencies.js.map +1 -0
  33. package/lib/commonjs/types/onramp/errors.js +22 -0
  34. package/lib/commonjs/types/onramp/errors.js.map +1 -0
  35. package/lib/commonjs/types/onramp/index.js +50 -0
  36. package/lib/commonjs/types/onramp/index.js.map +1 -0
  37. package/lib/commonjs/types/onramp/quotes.js +2 -0
  38. package/lib/commonjs/types/onramp/quotes.js.map +1 -0
  39. package/lib/commonjs/types/siwe/config.js +6 -0
  40. package/lib/commonjs/types/siwe/config.js.map +1 -0
  41. package/lib/commonjs/types/siwe/index.js +28 -0
  42. package/lib/commonjs/types/siwe/index.js.map +1 -0
  43. package/lib/commonjs/types/siwe/message.js +6 -0
  44. package/lib/commonjs/types/siwe/message.js.map +1 -0
  45. package/lib/commonjs/types/storage.js +2 -0
  46. package/lib/commonjs/types/storage.js.map +1 -0
  47. package/lib/commonjs/types/swap/index.js +17 -0
  48. package/lib/commonjs/types/swap/index.js.map +1 -0
  49. package/lib/commonjs/types/swap/tokens.js +6 -0
  50. package/lib/commonjs/types/swap/tokens.js.map +1 -0
  51. package/lib/commonjs/types/ui.js +6 -0
  52. package/lib/commonjs/types/ui.js.map +1 -0
  53. package/lib/commonjs/types/wallet/connection.js +6 -0
  54. package/lib/commonjs/types/wallet/connection.js.map +1 -0
  55. package/lib/commonjs/{utils/TypeUtil.js → types/wallet/connector.js} +1 -15
  56. package/lib/commonjs/types/wallet/connector.js.map +1 -0
  57. package/lib/commonjs/types/wallet/index.js +39 -0
  58. package/lib/commonjs/types/wallet/index.js.map +1 -0
  59. package/lib/commonjs/types/wallet/wallet-info.js +6 -0
  60. package/lib/commonjs/types/wallet/wallet-info.js.map +1 -0
  61. package/lib/commonjs/utils/ConstantsUtil.js +27 -7
  62. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  63. package/lib/commonjs/utils/NetworkUtil.js +3 -0
  64. package/lib/commonjs/utils/NetworkUtil.js.map +1 -1
  65. package/lib/module/adapters/BlockchainAdapter.js +25 -12
  66. package/lib/module/adapters/BlockchainAdapter.js.map +1 -1
  67. package/lib/module/adapters/EvmAdapter.js +0 -11
  68. package/lib/module/adapters/EvmAdapter.js.map +1 -1
  69. package/lib/module/index.js +1 -1
  70. package/lib/module/index.js.map +1 -1
  71. package/lib/module/types/api/blockchain-api.js +10 -0
  72. package/lib/module/types/api/blockchain-api.js.map +1 -0
  73. package/lib/module/types/api/events.js +4 -0
  74. package/lib/module/types/api/events.js.map +1 -0
  75. package/lib/module/types/api/index.js +7 -0
  76. package/lib/module/types/api/index.js.map +1 -0
  77. package/lib/module/types/api/wallet-api.js +4 -0
  78. package/lib/module/types/api/wallet-api.js.map +1 -0
  79. package/lib/module/types/blockchain/adapter.js +4 -0
  80. package/lib/module/types/blockchain/adapter.js.map +1 -0
  81. package/lib/module/types/blockchain/balance.js +4 -0
  82. package/lib/module/types/blockchain/balance.js.map +1 -0
  83. package/lib/module/types/blockchain/index.js +8 -0
  84. package/lib/module/types/blockchain/index.js.map +1 -0
  85. package/lib/module/types/blockchain/network.js +4 -0
  86. package/lib/module/types/blockchain/network.js.map +1 -0
  87. package/lib/module/types/blockchain/transaction.js +2 -0
  88. package/lib/module/types/blockchain/transaction.js.map +1 -0
  89. package/lib/module/types/common.js +2 -0
  90. package/lib/module/types/common.js.map +1 -0
  91. package/lib/module/types/index.js +31 -0
  92. package/lib/module/types/index.js.map +1 -0
  93. package/lib/module/types/onramp/countries.js +2 -0
  94. package/lib/module/types/onramp/countries.js.map +1 -0
  95. package/lib/module/types/onramp/currencies.js +2 -0
  96. package/lib/module/types/onramp/currencies.js.map +1 -0
  97. package/lib/module/types/onramp/errors.js +18 -0
  98. package/lib/module/types/onramp/errors.js.map +1 -0
  99. package/lib/module/types/onramp/index.js +8 -0
  100. package/lib/module/types/onramp/index.js.map +1 -0
  101. package/lib/module/types/onramp/quotes.js +2 -0
  102. package/lib/module/types/onramp/quotes.js.map +1 -0
  103. package/lib/module/types/siwe/config.js +4 -0
  104. package/lib/module/types/siwe/config.js.map +1 -0
  105. package/lib/module/types/siwe/index.js +6 -0
  106. package/lib/module/types/siwe/index.js.map +1 -0
  107. package/lib/module/types/siwe/message.js +4 -0
  108. package/lib/module/types/siwe/message.js.map +1 -0
  109. package/lib/module/types/storage.js +2 -0
  110. package/lib/module/types/storage.js.map +1 -0
  111. package/lib/module/types/swap/index.js +5 -0
  112. package/lib/module/types/swap/index.js.map +1 -0
  113. package/lib/module/types/swap/tokens.js +4 -0
  114. package/lib/module/types/swap/tokens.js.map +1 -0
  115. package/lib/module/types/ui.js +4 -0
  116. package/lib/module/types/ui.js.map +1 -0
  117. package/lib/module/types/wallet/connection.js +4 -0
  118. package/lib/module/types/wallet/connection.js.map +1 -0
  119. package/lib/module/{utils/TypeUtil.js → types/wallet/connector.js} +1 -16
  120. package/lib/module/types/wallet/connector.js.map +1 -0
  121. package/lib/module/types/wallet/index.js +7 -0
  122. package/lib/module/types/wallet/index.js.map +1 -0
  123. package/lib/module/types/wallet/wallet-info.js +4 -0
  124. package/lib/module/types/wallet/wallet-info.js.map +1 -0
  125. package/lib/module/utils/ConstantsUtil.js +27 -7
  126. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  127. package/lib/module/utils/NetworkUtil.js +3 -0
  128. package/lib/module/utils/NetworkUtil.js.map +1 -1
  129. package/lib/typescript/adapters/BlockchainAdapter.d.ts +5 -4
  130. package/lib/typescript/adapters/BlockchainAdapter.d.ts.map +1 -1
  131. package/lib/typescript/adapters/EvmAdapter.d.ts +1 -2
  132. package/lib/typescript/adapters/EvmAdapter.d.ts.map +1 -1
  133. package/lib/typescript/index.d.ts +1 -1
  134. package/lib/typescript/index.d.ts.map +1 -1
  135. package/lib/typescript/networks/bitcoin.d.ts +1 -1
  136. package/lib/typescript/networks/bitcoin.d.ts.map +1 -1
  137. package/lib/typescript/networks/solana.d.ts +1 -1
  138. package/lib/typescript/networks/solana.d.ts.map +1 -1
  139. package/lib/typescript/types/api/blockchain-api.d.ts +183 -0
  140. package/lib/typescript/types/api/blockchain-api.d.ts.map +1 -0
  141. package/lib/typescript/types/api/events.d.ts +304 -0
  142. package/lib/typescript/types/api/events.d.ts.map +1 -0
  143. package/lib/typescript/types/api/index.d.ts +4 -0
  144. package/lib/typescript/types/api/index.d.ts.map +1 -0
  145. package/lib/typescript/types/api/wallet-api.d.ts +50 -0
  146. package/lib/typescript/types/api/wallet-api.d.ts.map +1 -0
  147. package/lib/typescript/types/blockchain/adapter.d.ts +40 -0
  148. package/lib/typescript/types/blockchain/adapter.d.ts.map +1 -0
  149. package/lib/typescript/types/blockchain/balance.d.ts +28 -0
  150. package/lib/typescript/types/blockchain/balance.d.ts.map +1 -0
  151. package/lib/typescript/types/blockchain/index.d.ts +5 -0
  152. package/lib/typescript/types/blockchain/index.d.ts.map +1 -0
  153. package/lib/typescript/types/blockchain/network.d.ts +47 -0
  154. package/lib/typescript/types/blockchain/network.d.ts.map +1 -0
  155. package/lib/typescript/types/blockchain/transaction.d.ts +63 -0
  156. package/lib/typescript/types/blockchain/transaction.d.ts.map +1 -0
  157. package/lib/typescript/types/common.d.ts +24 -0
  158. package/lib/typescript/types/common.d.ts.map +1 -0
  159. package/lib/typescript/types/index.d.ts +10 -0
  160. package/lib/typescript/types/index.d.ts.map +1 -0
  161. package/lib/typescript/types/onramp/countries.d.ts +11 -0
  162. package/lib/typescript/types/onramp/countries.d.ts.map +1 -0
  163. package/lib/typescript/types/onramp/currencies.d.ts +30 -0
  164. package/lib/typescript/types/onramp/currencies.d.ts.map +1 -0
  165. package/lib/typescript/types/onramp/errors.d.ts +21 -0
  166. package/lib/typescript/types/onramp/errors.d.ts.map +1 -0
  167. package/lib/typescript/types/onramp/index.d.ts +5 -0
  168. package/lib/typescript/types/onramp/index.d.ts.map +1 -0
  169. package/lib/typescript/types/onramp/quotes.d.ts +45 -0
  170. package/lib/typescript/types/onramp/quotes.d.ts.map +1 -0
  171. package/lib/typescript/types/siwe/config.d.ts +31 -0
  172. package/lib/typescript/types/siwe/config.d.ts.map +1 -0
  173. package/lib/typescript/types/siwe/index.d.ts +3 -0
  174. package/lib/typescript/types/siwe/index.d.ts.map +1 -0
  175. package/lib/typescript/types/siwe/message.d.ts +57 -0
  176. package/lib/typescript/types/siwe/message.d.ts.map +1 -0
  177. package/lib/typescript/types/storage.d.ts +27 -0
  178. package/lib/typescript/types/storage.d.ts.map +1 -0
  179. package/lib/typescript/types/swap/index.d.ts +2 -0
  180. package/lib/typescript/types/swap/index.d.ts.map +1 -0
  181. package/lib/typescript/types/swap/tokens.d.ts +19 -0
  182. package/lib/typescript/types/swap/tokens.d.ts.map +1 -0
  183. package/lib/typescript/types/ui.d.ts +26 -0
  184. package/lib/typescript/types/ui.d.ts.map +1 -0
  185. package/lib/typescript/types/wallet/connection.d.ts +30 -0
  186. package/lib/typescript/types/wallet/connection.d.ts.map +1 -0
  187. package/lib/typescript/types/wallet/connector.d.ts +61 -0
  188. package/lib/typescript/types/wallet/connector.d.ts.map +1 -0
  189. package/lib/typescript/types/wallet/index.d.ts +4 -0
  190. package/lib/typescript/types/wallet/index.d.ts.map +1 -0
  191. package/lib/typescript/types/wallet/wallet-info.d.ts +36 -0
  192. package/lib/typescript/types/wallet/wallet-info.d.ts.map +1 -0
  193. package/lib/typescript/utils/ConstantsUtil.d.ts +25 -5
  194. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  195. package/lib/typescript/utils/NetworkUtil.d.ts +2 -0
  196. package/lib/typescript/utils/NetworkUtil.d.ts.map +1 -1
  197. package/package.json +1 -1
  198. package/src/adapters/BlockchainAdapter.ts +34 -15
  199. package/src/adapters/EvmAdapter.ts +1 -13
  200. package/src/adapters/__tests__/EvmAdapter.test.ts +2 -2
  201. package/src/index.ts +2 -1
  202. package/src/networks/bitcoin.ts +1 -1
  203. package/src/networks/solana.ts +1 -1
  204. package/src/types/api/blockchain-api.ts +213 -0
  205. package/src/types/api/events.ts +394 -0
  206. package/src/types/api/index.ts +4 -0
  207. package/src/types/api/wallet-api.ts +70 -0
  208. package/src/types/blockchain/adapter.ts +52 -0
  209. package/src/types/blockchain/balance.ts +31 -0
  210. package/src/types/blockchain/index.ts +5 -0
  211. package/src/types/blockchain/network.ts +39 -0
  212. package/src/types/blockchain/transaction.ts +71 -0
  213. package/src/types/common.ts +56 -0
  214. package/src/types/index.ts +28 -0
  215. package/src/types/onramp/countries.ts +11 -0
  216. package/src/types/onramp/currencies.ts +32 -0
  217. package/src/types/onramp/errors.ts +22 -0
  218. package/src/types/onramp/index.ts +5 -0
  219. package/src/types/onramp/quotes.ts +46 -0
  220. package/src/types/siwe/config.ts +44 -0
  221. package/src/types/siwe/index.ts +3 -0
  222. package/src/types/siwe/message.ts +62 -0
  223. package/src/types/storage.ts +30 -0
  224. package/src/types/swap/index.ts +2 -0
  225. package/src/types/swap/tokens.ts +21 -0
  226. package/src/types/ui.ts +26 -0
  227. package/src/types/wallet/connection.ts +33 -0
  228. package/src/types/wallet/connector.ts +85 -0
  229. package/src/types/wallet/index.ts +4 -0
  230. package/src/types/wallet/wallet-info.ts +41 -0
  231. package/src/utils/ConstantsUtil.ts +29 -9
  232. package/src/utils/NetworkUtil.ts +5 -0
  233. package/lib/commonjs/utils/TypeUtil.js.map +0 -1
  234. package/lib/module/utils/TypeUtil.js.map +0 -1
  235. package/lib/typescript/utils/TypeUtil.d.ts +0 -394
  236. package/lib/typescript/utils/TypeUtil.d.ts.map +0 -1
  237. package/src/utils/TypeUtil.ts +0 -493
@@ -4,16 +4,17 @@ import type {
4
4
  AdapterType,
5
5
  AppKitNetwork,
6
6
  BlockchainAdapterConfig,
7
+ BlockchainAdapterInitParams,
7
8
  CaipAddress,
8
9
  ChainNamespace,
9
10
  GetBalanceParams,
10
11
  GetBalanceResponse,
11
12
  Provider,
12
13
  WalletConnector
13
- } from '../utils/TypeUtil';
14
+ } from '../types';
15
+ import { NetworkUtil } from '../utils/NetworkUtil';
14
16
 
15
17
  export abstract class BlockchainAdapter extends EventEmitter {
16
- public projectId: string;
17
18
  public connector?: WalletConnector;
18
19
  public supportedNamespace: ChainNamespace;
19
20
  public adapterType: AdapterType;
@@ -26,15 +27,25 @@ export abstract class BlockchainAdapter extends EventEmitter {
26
27
  return super.emit(event, payload);
27
28
  }
28
29
 
29
- constructor({ projectId, supportedNamespace, adapterType }: BlockchainAdapterConfig) {
30
+ // Typed on method
31
+ override on<K extends keyof AdapterEvents>(event: K, listener: AdapterEvents[K]): this {
32
+ return super.on(event, listener);
33
+ }
34
+
35
+ // Typed off method for consistency
36
+ override off<K extends keyof AdapterEvents>(event: K, listener: AdapterEvents[K]): this {
37
+ return super.off(event, listener);
38
+ }
39
+
40
+ constructor({ supportedNamespace, adapterType }: BlockchainAdapterConfig) {
30
41
  super();
31
- this.projectId = projectId;
32
42
  this.supportedNamespace = supportedNamespace;
33
43
  this.adapterType = adapterType;
34
44
  }
35
45
 
36
- setConnector(connector: WalletConnector) {
46
+ init({ connector }: BlockchainAdapterInitParams) {
37
47
  this.connector = connector;
48
+
38
49
  this.subscribeToEvents();
39
50
  }
40
51
 
@@ -45,7 +56,7 @@ export abstract class BlockchainAdapter extends EventEmitter {
45
56
  getProvider(): Provider {
46
57
  if (!this.connector) throw new Error('No active connector');
47
58
 
48
- return this.connector.getProvider();
59
+ return this.connector.getProvider(this.getSupportedNamespace());
49
60
  }
50
61
 
51
62
  subscribeToEvents(): void {
@@ -68,19 +79,27 @@ export abstract class BlockchainAdapter extends EventEmitter {
68
79
 
69
80
  onAccountsChanged(accounts: string[]): void {
70
81
  const _accounts = this.getAccounts();
71
- const shouldEmit = _accounts?.some(account => {
72
- const accountAddress = account.split(':')[2];
73
-
74
- return accountAddress !== undefined && accounts.includes(accountAddress);
75
- });
76
-
77
- if (shouldEmit) {
78
- this.emit('accountsChanged', { accounts });
82
+ const updatedAccounts =
83
+ _accounts
84
+ ?.filter(account => {
85
+ const accountAddress = NetworkUtil.getPlainAddress(account);
86
+
87
+ return accountAddress !== undefined && accounts.includes(accountAddress);
88
+ })
89
+ ?.sort((a, b) => {
90
+ const aIndex = accounts.indexOf(NetworkUtil.getPlainAddress(a) ?? '');
91
+ const bIndex = accounts.indexOf(NetworkUtil.getPlainAddress(b) ?? '');
92
+
93
+ return aIndex - bIndex;
94
+ }) ?? [];
95
+
96
+ if (updatedAccounts.length > 0) {
97
+ this.emit('accountsChanged', { accounts: updatedAccounts });
79
98
  }
80
99
  }
81
100
 
82
101
  onDisconnect(): void {
83
- this.emit('disconnect', { namespace: this.getSupportedNamespace() });
102
+ this.emit('disconnect', undefined);
84
103
 
85
104
  const provider = this.connector?.getProvider();
86
105
  if (provider) {
@@ -1,6 +1,6 @@
1
1
  import { BlockchainAdapter } from './BlockchainAdapter';
2
2
  import { NumberUtil } from '../utils/NumberUtil';
3
- import type { AppKitNetwork } from '../utils/TypeUtil';
3
+ import type { AppKitNetwork } from '../types';
4
4
 
5
5
  // Type definitions for writeContract
6
6
  export interface WriteContractData {
@@ -71,18 +71,6 @@ function encodeERC20Function(method: string, params: any[]): string {
71
71
  }
72
72
 
73
73
  export abstract class EVMAdapter extends BlockchainAdapter {
74
- override subscribeToEvents(): void {
75
- super.subscribeToEvents();
76
- const provider = this.getProvider();
77
- if (!provider) return;
78
-
79
- // provider.on('reown_updateEmail', (info: any) => {
80
- // // this.emit('updateEmail', email);
81
- // //TODO: check this
82
- // // console.log('reown_updateEmail', info);
83
- // });
84
- }
85
-
86
74
  async signMessage(address: string, message: string, chain?: string): Promise<string> {
87
75
  const provider = this.getProvider();
88
76
 
@@ -1,5 +1,5 @@
1
1
  import { EVMAdapter } from '../EvmAdapter';
2
- import type { AppKitNetwork, CaipAddress } from '../../utils/TypeUtil';
2
+ import type { AppKitNetwork, CaipAddress } from '../../types';
3
3
 
4
4
  const network: AppKitNetwork = {
5
5
  id: 1,
@@ -25,7 +25,7 @@ class MockEVMAdapter extends EVMAdapter {
25
25
  private mockProvider: any;
26
26
 
27
27
  constructor() {
28
- super({ projectId: 'test', supportedNamespace: 'eip155', adapterType: 'ethers' });
28
+ super({ supportedNamespace: 'eip155', adapterType: 'ethers' });
29
29
  this.mockProvider = {
30
30
  request: jest.fn(),
31
31
  on: jest.fn(),
package/src/index.ts CHANGED
@@ -13,4 +13,5 @@ export { bitcoin, bitcoinTestnet } from './networks/bitcoin';
13
13
  export { BlockchainAdapter } from './adapters/BlockchainAdapter';
14
14
  export { EVMAdapter } from './adapters/EvmAdapter';
15
15
  export { SolanaBaseAdapter } from './adapters/SolanaBaseAdapter';
16
- export * from './utils/TypeUtil';
16
+
17
+ export * from './types';
@@ -1,4 +1,4 @@
1
- import type { AppKitNetwork } from '../utils/TypeUtil';
1
+ import type { AppKitNetwork } from '../types';
2
2
 
3
3
  export const bitcoin: AppKitNetwork = {
4
4
  id: '000000000019d6689c085ae165831e93',
@@ -1,4 +1,4 @@
1
- import type { AppKitNetwork } from '../utils/TypeUtil';
1
+ import type { AppKitNetwork } from '../types';
2
2
 
3
3
  export const solana: AppKitNetwork = {
4
4
  id: '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
@@ -0,0 +1,213 @@
1
+ import type { CaipAddress, CaipNetworkId, BaseError, RequestCache } from '../common';
2
+ import type { Transaction } from '../blockchain/transaction';
3
+ import type { SwapToken } from '../swap';
4
+
5
+ export interface BlockchainApiIdentityRequest {
6
+ address: `0x${string}`;
7
+ }
8
+
9
+ export interface BlockchainApiIdentityResponse {
10
+ avatar: string;
11
+ name: string;
12
+ }
13
+
14
+ export interface BlockchainApiBalance {
15
+ name: string;
16
+ symbol: string;
17
+ chainId: string;
18
+ address?: CaipAddress;
19
+ value?: number;
20
+ price: number;
21
+ quantity: {
22
+ decimals: string;
23
+ numeric: string;
24
+ };
25
+ iconUrl: string;
26
+ }
27
+
28
+ export interface BlockchainApiBalanceResponse {
29
+ balances: BlockchainApiBalance[];
30
+ }
31
+
32
+ export interface BlockchainApiTransactionsRequest {
33
+ account: string;
34
+ projectId: string;
35
+ cursor?: string;
36
+ signal?: AbortSignal;
37
+ cache?: RequestCache;
38
+ chainId: CaipNetworkId;
39
+ }
40
+
41
+ export interface BlockchainApiTransactionsResponse {
42
+ data: Transaction[];
43
+ next: string | null;
44
+ }
45
+
46
+ export interface BlockchainApiSwapAllowanceResponse {
47
+ allowance: string;
48
+ }
49
+
50
+ export interface BlockchainApiGenerateSwapCalldataRequest {
51
+ projectId: string;
52
+ userAddress: CaipAddress;
53
+ from: CaipAddress;
54
+ to: CaipAddress;
55
+ amount: string;
56
+ eip155?: {
57
+ slippage: string;
58
+ permit?: string;
59
+ };
60
+ }
61
+
62
+ export interface BlockchainApiGenerateSwapCalldataResponse {
63
+ tx: {
64
+ from: CaipAddress;
65
+ to: CaipAddress;
66
+ data: `0x${string}`;
67
+ amount: string;
68
+ eip155: {
69
+ gas: string;
70
+ gasPrice: string;
71
+ };
72
+ };
73
+ }
74
+
75
+ export interface BlockchainApiGenerateApproveCalldataRequest {
76
+ projectId: string;
77
+ userAddress: CaipAddress;
78
+ from: CaipAddress;
79
+ to: CaipAddress;
80
+ amount?: number;
81
+ }
82
+
83
+ export interface BlockchainApiGenerateApproveCalldataResponse {
84
+ tx: {
85
+ from: CaipAddress;
86
+ to: CaipAddress;
87
+ data: `0x${string}`;
88
+ value: string;
89
+ eip155: {
90
+ gas: number;
91
+ gasPrice: string;
92
+ };
93
+ };
94
+ }
95
+
96
+ export interface BlockchainApiTokenPriceRequest {
97
+ projectId: string;
98
+ currency?: 'usd' | 'eur' | 'gbp' | 'aud' | 'cad' | 'inr' | 'jpy' | 'btc' | 'eth';
99
+ addresses: CaipAddress[];
100
+ }
101
+
102
+ export interface BlockchainApiTokenPriceResponse {
103
+ fungibles: {
104
+ name: string;
105
+ symbol: string;
106
+ iconUrl: string;
107
+ price: number;
108
+ }[];
109
+ }
110
+
111
+ export interface BlockchainApiSwapAllowanceRequest {
112
+ projectId: string;
113
+ tokenAddress: CaipAddress;
114
+ userAddress: CaipAddress;
115
+ }
116
+
117
+ export interface BlockchainApiGasPriceRequest {
118
+ projectId: string;
119
+ chainId: CaipNetworkId;
120
+ }
121
+
122
+ export interface BlockchainApiGasPriceResponse {
123
+ standard: string;
124
+ fast: string;
125
+ instant: string;
126
+ }
127
+
128
+ export interface BlockchainApiEnsError extends BaseError {
129
+ status: string;
130
+ reasons: { name: string; description: string }[];
131
+ }
132
+
133
+ export type ReownName = `${string}.reown.id` | `${string}.wcn.id`;
134
+
135
+ export interface BlockchainApiLookupEnsName {
136
+ name: ReownName;
137
+ registered: number;
138
+ updated: number;
139
+ addresses: Record<
140
+ string,
141
+ {
142
+ address: string;
143
+ created: string;
144
+ }
145
+ >;
146
+ attributes: {
147
+ avatar?: string;
148
+ bio?: string;
149
+ }[];
150
+ }
151
+
152
+ export interface BlockchainApiSwapQuoteRequest {
153
+ projectId: string;
154
+ chainId?: CaipNetworkId;
155
+ amount: string;
156
+ userAddress: CaipAddress;
157
+ from: CaipAddress;
158
+ to: CaipAddress;
159
+ gasPrice: string;
160
+ }
161
+
162
+ export interface BlockchainApiSwapQuoteResponse {
163
+ quotes: {
164
+ id: string | null;
165
+ fromAmount: string;
166
+ fromAccount: string;
167
+ toAmount: string;
168
+ toAccount: string;
169
+ }[];
170
+ }
171
+
172
+ export interface BlockchainApiSwapTokensRequest {
173
+ projectId: string;
174
+ chainId: CaipNetworkId;
175
+ }
176
+
177
+ export interface BlockchainApiOnRampQuotesRequest {
178
+ countryCode: string;
179
+ paymentMethodType?: string;
180
+ destinationCurrencyCode: string;
181
+ sourceAmount: number;
182
+ sourceCurrencyCode: string;
183
+ walletAddress: string;
184
+ excludeProviders?: string[];
185
+ }
186
+
187
+ export interface BlockchainApiSwapTokensResponse {
188
+ tokens: SwapToken[];
189
+ }
190
+
191
+ export interface BlockchainApiOnRampWidgetRequest {
192
+ countryCode: string;
193
+ destinationCurrencyCode: string;
194
+ paymentMethodType: string;
195
+ serviceProvider: string;
196
+ sourceAmount: number;
197
+ sourceCurrencyCode: string;
198
+ walletAddress: string;
199
+ redirectUrl?: string;
200
+ }
201
+
202
+ export type BlockchainApiOnRampWidgetResponse = {
203
+ widgetUrl: string;
204
+ };
205
+
206
+ export class BlockchainOnRampError extends Error {
207
+ code: string;
208
+ constructor(code: string, message: string) {
209
+ super(message);
210
+ this.code = code;
211
+ this.message = message;
212
+ }
213
+ }