@reown/appkit-common-react-native 0.0.0-chore-canary-20250722145858 → 0.0.0-chore-bump-builder-20250728195048

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 (98) hide show
  1. package/lib/commonjs/adapters/BlockchainAdapter.js +81 -0
  2. package/lib/commonjs/adapters/BlockchainAdapter.js.map +1 -0
  3. package/lib/commonjs/adapters/EvmAdapter.js +204 -0
  4. package/lib/commonjs/adapters/EvmAdapter.js.map +1 -0
  5. package/lib/commonjs/adapters/SolanaBaseAdapter.js +10 -0
  6. package/lib/commonjs/adapters/SolanaBaseAdapter.js.map +1 -0
  7. package/lib/commonjs/index.js +62 -1
  8. package/lib/commonjs/index.js.map +1 -1
  9. package/lib/commonjs/networks/bitcoin.js +40 -0
  10. package/lib/commonjs/networks/bitcoin.js.map +1 -0
  11. package/lib/commonjs/networks/solana.js +78 -0
  12. package/lib/commonjs/networks/solana.js.map +1 -0
  13. package/lib/commonjs/package.json +1 -0
  14. package/lib/commonjs/utils/ConstantsUtil.js +31 -5
  15. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  16. package/lib/commonjs/utils/ErrorUtil.js +2 -2
  17. package/lib/commonjs/utils/NumberUtil.js +52 -11
  18. package/lib/commonjs/utils/NumberUtil.js.map +1 -1
  19. package/lib/commonjs/utils/PresetsUtil.js +34 -21
  20. package/lib/commonjs/utils/PresetsUtil.js.map +1 -1
  21. package/lib/commonjs/utils/StringUtil.js +7 -0
  22. package/lib/commonjs/utils/StringUtil.js.map +1 -1
  23. package/lib/commonjs/utils/TypeUtil.js +42 -0
  24. package/lib/commonjs/utils/TypeUtil.js.map +1 -1
  25. package/lib/module/adapters/BlockchainAdapter.js +76 -0
  26. package/lib/module/adapters/BlockchainAdapter.js.map +1 -0
  27. package/lib/module/adapters/EvmAdapter.js +200 -0
  28. package/lib/module/adapters/EvmAdapter.js.map +1 -0
  29. package/lib/module/adapters/SolanaBaseAdapter.js +5 -0
  30. package/lib/module/adapters/SolanaBaseAdapter.js.map +1 -0
  31. package/lib/module/contracts/erc20.js +2 -0
  32. package/lib/module/contracts/erc20.js.map +1 -1
  33. package/lib/module/contracts/usdt.js +2 -0
  34. package/lib/module/contracts/usdt.js.map +1 -1
  35. package/lib/module/index.js +7 -0
  36. package/lib/module/index.js.map +1 -1
  37. package/lib/module/networks/bitcoin.js +36 -0
  38. package/lib/module/networks/bitcoin.js.map +1 -0
  39. package/lib/module/networks/solana.js +74 -0
  40. package/lib/module/networks/solana.js.map +1 -0
  41. package/lib/module/utils/ConstantsUtil.js +33 -5
  42. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  43. package/lib/module/utils/ContractUtil.js +2 -0
  44. package/lib/module/utils/ContractUtil.js.map +1 -1
  45. package/lib/module/utils/DateUtil.js +2 -0
  46. package/lib/module/utils/DateUtil.js.map +1 -1
  47. package/lib/module/utils/ErrorUtil.js +4 -2
  48. package/lib/module/utils/ErrorUtil.js.map +1 -1
  49. package/lib/module/utils/NamesUtil.js +2 -0
  50. package/lib/module/utils/NamesUtil.js.map +1 -1
  51. package/lib/module/utils/NetworkUtil.js +2 -0
  52. package/lib/module/utils/NetworkUtil.js.map +1 -1
  53. package/lib/module/utils/NumberUtil.js +54 -11
  54. package/lib/module/utils/NumberUtil.js.map +1 -1
  55. package/lib/module/utils/PresetsUtil.js +36 -21
  56. package/lib/module/utils/PresetsUtil.js.map +1 -1
  57. package/lib/module/utils/StringUtil.js +9 -0
  58. package/lib/module/utils/StringUtil.js.map +1 -1
  59. package/lib/module/utils/TypeUtil.js +38 -0
  60. package/lib/module/utils/TypeUtil.js.map +1 -1
  61. package/lib/typescript/adapters/BlockchainAdapter.d.ts +25 -0
  62. package/lib/typescript/adapters/BlockchainAdapter.d.ts.map +1 -0
  63. package/lib/typescript/adapters/EvmAdapter.d.ts +27 -0
  64. package/lib/typescript/adapters/EvmAdapter.d.ts.map +1 -0
  65. package/lib/typescript/adapters/SolanaBaseAdapter.d.ts +6 -0
  66. package/lib/typescript/adapters/SolanaBaseAdapter.d.ts.map +1 -0
  67. package/lib/typescript/adapters/__tests__/EvmAdapter.test.d.ts +2 -0
  68. package/lib/typescript/adapters/__tests__/EvmAdapter.test.d.ts.map +1 -0
  69. package/lib/typescript/index.d.ts +5 -0
  70. package/lib/typescript/index.d.ts.map +1 -1
  71. package/lib/typescript/networks/bitcoin.d.ts +4 -0
  72. package/lib/typescript/networks/bitcoin.d.ts.map +1 -0
  73. package/lib/typescript/networks/solana.d.ts +5 -0
  74. package/lib/typescript/networks/solana.d.ts.map +1 -0
  75. package/lib/typescript/utils/ConstantsUtil.d.ts +27 -3
  76. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  77. package/lib/typescript/utils/NumberUtil.d.ts +39 -11
  78. package/lib/typescript/utils/NumberUtil.d.ts.map +1 -1
  79. package/lib/typescript/utils/PresetsUtil.d.ts +1 -6
  80. package/lib/typescript/utils/PresetsUtil.d.ts.map +1 -1
  81. package/lib/typescript/utils/StringUtil.d.ts +1 -0
  82. package/lib/typescript/utils/StringUtil.d.ts.map +1 -1
  83. package/lib/typescript/utils/TypeUtil.d.ts +322 -12
  84. package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
  85. package/package.json +6 -16
  86. package/src/adapters/BlockchainAdapter.ts +107 -0
  87. package/src/adapters/EvmAdapter.ts +259 -0
  88. package/src/adapters/SolanaBaseAdapter.ts +6 -0
  89. package/src/adapters/__tests__/EvmAdapter.test.ts +126 -0
  90. package/src/index.ts +5 -0
  91. package/src/networks/bitcoin.ts +32 -0
  92. package/src/networks/solana.ts +44 -0
  93. package/src/utils/ConstantsUtil.ts +33 -6
  94. package/src/utils/ErrorUtil.ts +2 -2
  95. package/src/utils/NumberUtil.ts +54 -11
  96. package/src/utils/PresetsUtil.ts +34 -26
  97. package/src/utils/StringUtil.ts +7 -0
  98. package/src/utils/TypeUtil.ts +410 -14
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@reown/appkit-common-react-native",
3
- "version": "0.0.0-chore-canary-20250722145858",
3
+ "version": "0.0.0-chore-bump-builder-20250728195048",
4
4
  "main": "lib/commonjs/index.js",
5
5
  "types": "lib/typescript/index.d.ts",
6
6
  "module": "lib/module/index.js",
7
+ "react-native": "src/index.ts",
7
8
  "source": "src/index.ts",
8
9
  "scripts": {
9
10
  "build": "bob build",
@@ -15,6 +16,10 @@
15
16
  "bignumber.js": "9.1.2",
16
17
  "dayjs": "1.11.10"
17
18
  },
19
+ "peerDependencies": {
20
+ "react": ">=18",
21
+ "react-native": ">=0.72"
22
+ },
18
23
  "files": [
19
24
  "src",
20
25
  "lib"
@@ -38,21 +43,6 @@
38
43
  "registry": "https://registry.npmjs.org/",
39
44
  "access": "public"
40
45
  },
41
- "react-native": "src/index.ts",
42
- "react-native-builder-bob": {
43
- "source": "src",
44
- "output": "lib",
45
- "targets": [
46
- "commonjs",
47
- "module",
48
- [
49
- "typescript",
50
- {
51
- "tsc": "../../node_modules/.bin/tsc"
52
- }
53
- ]
54
- ]
55
- },
56
46
  "eslintIgnore": [
57
47
  "node_modules/",
58
48
  "lib/"
@@ -0,0 +1,107 @@
1
+ import { EventEmitter } from 'events';
2
+ import type {
3
+ AdapterEvents,
4
+ AdapterType,
5
+ AppKitNetwork,
6
+ BlockchainAdapterConfig,
7
+ CaipAddress,
8
+ ChainNamespace,
9
+ GetBalanceParams,
10
+ GetBalanceResponse,
11
+ Provider,
12
+ WalletConnector
13
+ } from '../utils/TypeUtil';
14
+
15
+ export abstract class BlockchainAdapter extends EventEmitter {
16
+ public projectId: string;
17
+ public connector?: WalletConnector;
18
+ public supportedNamespace: ChainNamespace;
19
+ public adapterType: AdapterType;
20
+
21
+ // Typed emit method
22
+ override emit<K extends keyof AdapterEvents>(
23
+ event: K,
24
+ payload: Parameters<AdapterEvents[K]>[0]
25
+ ): boolean {
26
+ return super.emit(event, payload);
27
+ }
28
+
29
+ constructor({ projectId, supportedNamespace, adapterType }: BlockchainAdapterConfig) {
30
+ super();
31
+ this.projectId = projectId;
32
+ this.supportedNamespace = supportedNamespace;
33
+ this.adapterType = adapterType;
34
+ }
35
+
36
+ setConnector(connector: WalletConnector) {
37
+ this.connector = connector;
38
+ this.subscribeToEvents();
39
+ }
40
+
41
+ removeConnector() {
42
+ this.connector = undefined;
43
+ }
44
+
45
+ getProvider(): Provider {
46
+ if (!this.connector) throw new Error('No active connector');
47
+
48
+ return this.connector.getProvider();
49
+ }
50
+
51
+ subscribeToEvents(): void {
52
+ const provider = this.connector?.getProvider();
53
+ if (!provider) return;
54
+
55
+ provider.on('chainChanged', this.onChainChanged.bind(this));
56
+ provider.on('accountsChanged', this.onAccountsChanged.bind(this));
57
+ provider.on('disconnect', this.onDisconnect.bind(this));
58
+ }
59
+
60
+ onChainChanged(chainId: string): void {
61
+ const _chains = this.getAccounts()?.map(account => account.split(':')[1]);
62
+ const shouldEmit = _chains?.some(chain => chain === chainId);
63
+
64
+ if (shouldEmit) {
65
+ this.emit('chainChanged', { chainId });
66
+ }
67
+ }
68
+
69
+ onAccountsChanged(accounts: string[]): void {
70
+ 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 });
79
+ }
80
+ }
81
+
82
+ onDisconnect(): void {
83
+ this.emit('disconnect', { namespace: this.getSupportedNamespace() });
84
+
85
+ const provider = this.connector?.getProvider();
86
+ if (provider) {
87
+ provider.off('chainChanged', this.onChainChanged.bind(this));
88
+ provider.off('accountsChanged', this.onAccountsChanged.bind(this));
89
+ provider.off('disconnect', this.onDisconnect.bind(this));
90
+ }
91
+
92
+ this.connector = undefined;
93
+ }
94
+
95
+ parseUnits(value: string, decimals: number): bigint {
96
+ const [whole, fraction = ''] = value.split('.');
97
+ const paddedFraction = (fraction + '0'.repeat(decimals)).slice(0, decimals);
98
+
99
+ return BigInt(whole + paddedFraction);
100
+ }
101
+
102
+ abstract disconnect(): Promise<void>;
103
+ abstract getSupportedNamespace(): ChainNamespace;
104
+ abstract getBalance(params: GetBalanceParams): Promise<GetBalanceResponse>;
105
+ abstract getAccounts(): CaipAddress[] | undefined;
106
+ abstract switchNetwork(network: AppKitNetwork): Promise<void>;
107
+ }
@@ -0,0 +1,259 @@
1
+ import { BlockchainAdapter } from './BlockchainAdapter';
2
+ import { NumberUtil } from '../utils/NumberUtil';
3
+ import type { AppKitNetwork } from '../utils/TypeUtil';
4
+
5
+ // Type definitions for writeContract
6
+ export interface WriteContractData {
7
+ tokenAddress: `0x${string}`;
8
+ receiverAddress: `0x${string}`;
9
+ tokenAmount: bigint;
10
+ fromAddress: `0x${string}`;
11
+ method: 'transfer' | 'transferFrom' | 'approve';
12
+ abi?: any; // Optional ABI for future extensibility
13
+ spenderAddress?: `0x${string}`; // Required for transferFrom and approve
14
+ network: AppKitNetwork;
15
+ }
16
+
17
+ export interface SendTransactionData {
18
+ address: `0x${string}`;
19
+ network: AppKitNetwork;
20
+ to: `0x${string}`;
21
+ value: string;
22
+ data: string;
23
+ }
24
+
25
+ // Simple ABI encoder for ERC20 functions
26
+ function encodeERC20Function(method: string, params: any[]): string {
27
+ const functionSelectors = {
28
+ transfer: '0xa9059cbb', // transfer(address,uint256)
29
+ transferFrom: '0x23b872dd', // transferFrom(address,address,uint256)
30
+ approve: '0x095ea7b3' // approve(address,uint256)
31
+ };
32
+
33
+ const selector = functionSelectors[method as keyof typeof functionSelectors];
34
+ if (!selector) {
35
+ throw new Error(`EVMAdapter:encodeERC20Function - unsupported method: ${method}`);
36
+ }
37
+
38
+ let encodedParams = '';
39
+
40
+ switch (method) {
41
+ case 'transfer':
42
+ if (params.length !== 2) throw new Error('transfer requires 2 parameters: to, amount');
43
+ const [to, amount] = params;
44
+ encodedParams =
45
+ to.toLowerCase().slice(2).padStart(64, '0') + amount.toString(16).padStart(64, '0');
46
+ break;
47
+
48
+ case 'transferFrom':
49
+ if (params.length !== 3)
50
+ throw new Error('transferFrom requires 3 parameters: from, to, amount');
51
+ const [from, toTransferFrom, amountTransferFrom] = params;
52
+ encodedParams =
53
+ from.toLowerCase().slice(2).padStart(64, '0') +
54
+ toTransferFrom.toLowerCase().slice(2).padStart(64, '0') +
55
+ amountTransferFrom.toString(16).padStart(64, '0');
56
+ break;
57
+
58
+ case 'approve':
59
+ if (params.length !== 2) throw new Error('approve requires 2 parameters: spender, amount');
60
+ const [spender, amountApprove] = params;
61
+ encodedParams =
62
+ spender.toLowerCase().slice(2).padStart(64, '0') +
63
+ amountApprove.toString(16).padStart(64, '0');
64
+ break;
65
+
66
+ default:
67
+ throw new Error(`EVMAdapter:encodeERC20Function - unsupported method: ${method}`);
68
+ }
69
+
70
+ return selector + encodedParams;
71
+ }
72
+
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
+ async signMessage(address: string, message: string, chain?: string): Promise<string> {
87
+ const provider = this.getProvider();
88
+
89
+ if (!provider) {
90
+ throw new Error('EVMAdapter:signMessage - provider is undefined');
91
+ }
92
+
93
+ const signature = await provider.request(
94
+ {
95
+ method: 'personal_sign',
96
+ params: [message, address]
97
+ },
98
+ `eip155:${chain}`
99
+ );
100
+
101
+ return signature as string;
102
+ }
103
+ async estimateGas({ address, to, data, chainNamespace }: any): Promise<bigint> {
104
+ const provider = this.getProvider();
105
+
106
+ if (!provider) {
107
+ throw new Error('EVMAdapter:estimateGas - provider is undefined');
108
+ }
109
+
110
+ if (!address) {
111
+ throw new Error('EVMAdapter:estimateGas - from address is undefined');
112
+ }
113
+
114
+ if (chainNamespace && chainNamespace !== 'eip155') {
115
+ throw new Error('EVMAdapter:estimateGas - chainNamespace is not eip155');
116
+ }
117
+
118
+ try {
119
+ const txParams = {
120
+ from: address,
121
+ to,
122
+ data,
123
+ type: '0x0' // optional, legacy type
124
+ };
125
+
126
+ const estimatedGasHex = await provider.request({
127
+ method: 'eth_estimateGas',
128
+ params: [txParams]
129
+ });
130
+
131
+ return BigInt(estimatedGasHex as string);
132
+ } catch (error) {
133
+ throw new Error('EVMAdapter:estimateGas - eth_estimateGas RPC failed');
134
+ }
135
+ }
136
+
137
+ async sendTransaction(data: SendTransactionData): Promise<`0x${string}` | null> {
138
+ const { address, network } = data || {};
139
+
140
+ if (!this.getProvider()) {
141
+ throw new Error('EVMAdapter:sendTransaction - provider is undefined');
142
+ }
143
+
144
+ if (!address) {
145
+ throw new Error('EVMAdapter:sendTransaction - address is undefined');
146
+ }
147
+
148
+ if (!network) {
149
+ throw new Error('EVMAdapter:sendTransaction - network is undefined');
150
+ }
151
+
152
+ const txParams = {
153
+ from: address,
154
+ to: data.to,
155
+ value: NumberUtil.convertNumericToHexString(data.value),
156
+ data: data.data, // hex-encoded bytecode
157
+ type: '0x0' // optional: legacy transaction type
158
+ };
159
+
160
+ const txHash = await this.getProvider().request(
161
+ {
162
+ method: 'eth_sendTransaction',
163
+ params: [txParams]
164
+ },
165
+ network.caipNetworkId
166
+ );
167
+
168
+ return txHash as `0x${string}` | null;
169
+ }
170
+
171
+ async writeContract(data: WriteContractData): Promise<`0x${string}` | null> {
172
+ const {
173
+ tokenAddress,
174
+ receiverAddress,
175
+ tokenAmount,
176
+ method,
177
+ fromAddress,
178
+ spenderAddress,
179
+ network
180
+ } = data;
181
+
182
+ if (!this.getProvider()) {
183
+ throw new Error('EVMAdapter:writeContract - provider is undefined');
184
+ }
185
+
186
+ if (!fromAddress) {
187
+ throw new Error('EVMAdapter:writeContract - fromAddress is undefined');
188
+ }
189
+
190
+ if (!tokenAddress) {
191
+ throw new Error('EVMAdapter:writeContract - tokenAddress is undefined');
192
+ }
193
+
194
+ if (!tokenAmount) {
195
+ throw new Error('EVMAdapter:writeContract - tokenAmount is undefined');
196
+ }
197
+
198
+ if (!method) {
199
+ throw new Error('EVMAdapter:writeContract - method is undefined');
200
+ }
201
+
202
+ // Validate method-specific parameters
203
+ if (method === 'transfer' && !receiverAddress) {
204
+ throw new Error('EVMAdapter:writeContract - receiverAddress is required for transfer method');
205
+ }
206
+
207
+ if ((method === 'transferFrom' || method === 'approve') && !spenderAddress) {
208
+ throw new Error(`EVMAdapter:writeContract - spenderAddress is required for ${method} method`);
209
+ }
210
+
211
+ // Encode the function call data based on method
212
+ let encodedData: string;
213
+
214
+ switch (method) {
215
+ case 'transfer':
216
+ encodedData = encodeERC20Function('transfer', [receiverAddress, tokenAmount]);
217
+ break;
218
+ case 'transferFrom':
219
+ encodedData = encodeERC20Function('transferFrom', [
220
+ fromAddress,
221
+ receiverAddress,
222
+ tokenAmount
223
+ ]);
224
+ break;
225
+ case 'approve':
226
+ encodedData = encodeERC20Function('approve', [spenderAddress, tokenAmount]);
227
+ break;
228
+ default:
229
+ throw new Error(`EVMAdapter:writeContract - method '${method}' is not supported`);
230
+ }
231
+
232
+ // Create transaction parameters
233
+ const txParams = {
234
+ from: fromAddress,
235
+ to: tokenAddress,
236
+ data: encodedData,
237
+ value: '0x0', // No ETH value for token operations
238
+ type: '0x0' // legacy transaction type
239
+ };
240
+
241
+ try {
242
+ // Send the transaction
243
+ const txHash = await this.getProvider().request(
244
+ {
245
+ method: 'eth_sendTransaction',
246
+ params: [txParams]
247
+ },
248
+ network.caipNetworkId
249
+ );
250
+
251
+ return txHash as `0x${string}` | null;
252
+ } catch (error) {
253
+ if (error instanceof Error) {
254
+ throw new Error(`EVMAdapter:writeContract - ${error.message}`);
255
+ }
256
+ throw new Error('EVMAdapter:writeContract - unknown error occurred');
257
+ }
258
+ }
259
+ }
@@ -0,0 +1,6 @@
1
+ import { BlockchainAdapter } from './BlockchainAdapter';
2
+
3
+ export abstract class SolanaBaseAdapter extends BlockchainAdapter {
4
+ abstract signTransaction(data: any): Promise<string | null>;
5
+ abstract sendTransaction(data: any): Promise<string | null>;
6
+ }
@@ -0,0 +1,126 @@
1
+ import { EVMAdapter } from '../EvmAdapter';
2
+ import type { AppKitNetwork, CaipAddress } from '../../utils/TypeUtil';
3
+
4
+ const network: AppKitNetwork = {
5
+ id: 1,
6
+ name: 'Ethereum',
7
+ nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
8
+ rpcUrls: {
9
+ default: {
10
+ http: ['https://eth.merkle.io']
11
+ }
12
+ },
13
+ blockExplorers: {
14
+ default: {
15
+ name: 'Etherscan',
16
+ url: 'https://etherscan.io'
17
+ }
18
+ },
19
+ chainNamespace: 'eip155',
20
+ caipNetworkId: 'eip155:1'
21
+ };
22
+
23
+ // Mock implementation for testing
24
+ class MockEVMAdapter extends EVMAdapter {
25
+ private mockProvider: any;
26
+
27
+ constructor() {
28
+ super({ projectId: 'test', supportedNamespace: 'eip155', adapterType: 'ethers' });
29
+ this.mockProvider = {
30
+ request: jest.fn(),
31
+ on: jest.fn(),
32
+ off: jest.fn()
33
+ };
34
+ }
35
+
36
+ setMockProvider(provider: any) {
37
+ this.mockProvider = provider;
38
+ }
39
+
40
+ override getProvider() {
41
+ return this.mockProvider;
42
+ }
43
+
44
+ async disconnect(): Promise<void> {}
45
+ getSupportedNamespace() {
46
+ return 'eip155' as const;
47
+ }
48
+ async getBalance() {
49
+ return { amount: '0', symbol: 'ETH' };
50
+ }
51
+ getAccounts(): CaipAddress[] | undefined {
52
+ return ['eip155:1:0x1234567890123456789012345678901234567890'];
53
+ }
54
+ async switchNetwork() {}
55
+ }
56
+
57
+ describe('EVMAdapter', () => {
58
+ let adapter: MockEVMAdapter;
59
+
60
+ beforeEach(() => {
61
+ adapter = new MockEVMAdapter();
62
+ });
63
+
64
+ describe('writeContract', () => {
65
+ it('should encode transfer function correctly', async () => {
66
+ const mockProvider = {
67
+ request: jest.fn().mockResolvedValueOnce('0x1234567890abcdef') // eth_sendTransaction
68
+ };
69
+ adapter.setMockProvider(mockProvider);
70
+
71
+ const result = await adapter.writeContract({
72
+ tokenAddress: '0x1234567890123456789012345678901234567890',
73
+ receiverAddress: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd',
74
+ tokenAmount: BigInt(1000000000000000000), // 1 token with 18 decimals
75
+ fromAddress: '0x1234567890123456789012345678901234567890',
76
+ method: 'transfer',
77
+ network
78
+ });
79
+
80
+ expect(result).toBe('0x1234567890abcdef');
81
+ expect(mockProvider.request).toHaveBeenCalledWith(
82
+ {
83
+ method: 'eth_sendTransaction',
84
+ params: [
85
+ {
86
+ from: '0x1234567890123456789012345678901234567890',
87
+ to: '0x1234567890123456789012345678901234567890',
88
+ data: '0xa9059cbb000000000000000000000000abcdefabcdefabcdefabcdefabcdefabcdefabcd0000000000000000000000000000000000000000000000000de0b6b3a7640000',
89
+ value: '0x0',
90
+ type: '0x0'
91
+ }
92
+ ]
93
+ },
94
+ 'eip155:1'
95
+ );
96
+ });
97
+
98
+ it('should throw error for unsupported method', async () => {
99
+ await expect(
100
+ adapter.writeContract({
101
+ tokenAddress: '0x1234567890123456789012345678901234567890',
102
+ receiverAddress: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd',
103
+ tokenAmount: BigInt(1000000000000000000),
104
+ fromAddress: '0x1234567890123456789012345678901234567890',
105
+ method: 'unsupported' as any,
106
+ network
107
+ })
108
+ ).rejects.toThrow("method 'unsupported' is not supported");
109
+ });
110
+
111
+ it('should throw error when provider is undefined', async () => {
112
+ adapter.setMockProvider(undefined);
113
+
114
+ await expect(
115
+ adapter.writeContract({
116
+ tokenAddress: '0x1234567890123456789012345678901234567890',
117
+ receiverAddress: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd',
118
+ tokenAmount: BigInt(1000000000000000000),
119
+ fromAddress: '0x1234567890123456789012345678901234567890',
120
+ method: 'transfer',
121
+ network
122
+ })
123
+ ).rejects.toThrow('provider is undefined');
124
+ });
125
+ });
126
+ });
package/src/index.ts CHANGED
@@ -8,4 +8,9 @@ export { PresetsUtil } from './utils/PresetsUtil';
8
8
  export { StringUtil } from './utils/StringUtil';
9
9
  export { ErrorUtil } from './utils/ErrorUtil';
10
10
  export { erc20ABI } from './contracts/erc20';
11
+ export { solana, solanaDevnet, solanaTestnet } from './networks/solana';
12
+ export { bitcoin, bitcoinTestnet } from './networks/bitcoin';
13
+ export { BlockchainAdapter } from './adapters/BlockchainAdapter';
14
+ export { EVMAdapter } from './adapters/EvmAdapter';
15
+ export { SolanaBaseAdapter } from './adapters/SolanaBaseAdapter';
11
16
  export * from './utils/TypeUtil';
@@ -0,0 +1,32 @@
1
+ import type { AppKitNetwork } from '../utils/TypeUtil';
2
+
3
+ export const bitcoin: AppKitNetwork = {
4
+ id: '000000000019d6689c085ae165831e93',
5
+ caipNetworkId: 'bip122:000000000019d6689c085ae165831e93',
6
+ chainNamespace: 'bip122',
7
+ name: 'Bitcoin',
8
+ nativeCurrency: {
9
+ name: 'Bitcoin',
10
+ symbol: 'BTC',
11
+ decimals: 8
12
+ },
13
+ rpcUrls: {
14
+ default: { http: ['https://rpc.walletconnect.org/v1'] }
15
+ }
16
+ };
17
+
18
+ export const bitcoinTestnet: AppKitNetwork = {
19
+ id: '000000000933ea01ad0ee984209779ba',
20
+ caipNetworkId: 'bip122:000000000933ea01ad0ee984209779ba',
21
+ chainNamespace: 'bip122',
22
+ name: 'Bitcoin Testnet',
23
+ nativeCurrency: {
24
+ name: 'Bitcoin',
25
+ symbol: 'BTC',
26
+ decimals: 8
27
+ },
28
+ rpcUrls: {
29
+ default: { http: ['https://rpc.walletconnect.org/v1'] }
30
+ },
31
+ testnet: true
32
+ };
@@ -0,0 +1,44 @@
1
+ import type { AppKitNetwork } from '../utils/TypeUtil';
2
+
3
+ export const solana: AppKitNetwork = {
4
+ id: '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
5
+ name: 'Solana',
6
+ nativeCurrency: { name: 'Solana', symbol: 'SOL', decimals: 9 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ['https://rpc.walletconnect.org/v1']
10
+ }
11
+ },
12
+ blockExplorers: { default: { name: 'Solscan', url: 'https://solscan.io' } },
13
+ chainNamespace: 'solana',
14
+ caipNetworkId: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
15
+ deprecatedCaipNetworkId: 'solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ',
16
+ testnet: false
17
+ };
18
+
19
+ export const solanaDevnet: AppKitNetwork = {
20
+ id: 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1',
21
+ name: 'Solana Devnet',
22
+ nativeCurrency: { name: 'Solana', symbol: 'SOL', decimals: 9 },
23
+ rpcUrls: {
24
+ default: { http: ['https://rpc.walletconnect.org/v1'] }
25
+ },
26
+ blockExplorers: { default: { name: 'Solscan', url: 'https://solscan.io' } },
27
+ chainNamespace: 'solana',
28
+ caipNetworkId: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',
29
+ deprecatedCaipNetworkId: 'solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K',
30
+ testnet: true
31
+ };
32
+
33
+ export const solanaTestnet: AppKitNetwork = {
34
+ id: '4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',
35
+ name: 'Solana Testnet',
36
+ nativeCurrency: { name: 'Solana', symbol: 'SOL', decimals: 9 },
37
+ rpcUrls: {
38
+ default: { http: ['https://rpc.walletconnect.org/v1'] }
39
+ },
40
+ blockExplorers: { default: { name: 'Solscan', url: 'https://solscan.io' } },
41
+ chainNamespace: 'solana',
42
+ caipNetworkId: 'solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',
43
+ testnet: true
44
+ };
@@ -1,5 +1,5 @@
1
1
  export const ConstantsUtil = {
2
- VERSION: '0.0.0-chore-canary-20250722145858',
2
+ VERSION: '0.0.0-chore-bump-builder-20250728195048',
3
3
 
4
4
  EIP155: 'eip155',
5
5
  ADD_CHAIN_METHOD: 'wallet_addEthereumChain',
@@ -11,12 +11,14 @@ export const ConstantsUtil = {
11
11
  BLOCKCHAIN_API_RPC_URL_STAGING: 'https://staging.rpc.walletconnect.org',
12
12
  PULSE_API_URL: 'https://pulse.walletconnect.org',
13
13
  API_URL: 'https://api.web3modal.org',
14
-
15
- WALLET_CONNECT_CONNECTOR_ID: 'walletConnect',
16
- COINBASE_CONNECTOR_ID: 'coinbaseWallet',
17
- AUTH_CONNECTOR_ID: 'appKitAuth',
14
+ WEB_WALLET_URL: 'https://web-wallet.walletconnect.org',
15
+ SECURE_SITE_DASHBOARD: `https://secure.reown.com/dashboard`,
16
+ SECURE_SITE_ICON: `https://secure.reown.com/images/favicon.png`,
18
17
 
19
18
  COINBASE_EXPLORER_ID: 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa',
19
+ PHANTOM_EXPLORER_ID: 'a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393',
20
+
21
+ WALLET_CONNECT_IMAGE_ID: 'ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400',
20
22
 
21
23
  USDT_CONTRACT_ADDRESSES: [
22
24
  // Mainnet
@@ -33,5 +35,30 @@ export const ConstantsUtil = {
33
35
  '0x55d398326f99059fF775485246999027B3197955',
34
36
  // Arbitrum
35
37
  '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9'
36
- ]
38
+ ],
39
+
40
+ PHANTOM_CUSTOM_WALLET: {
41
+ id: 'a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393',
42
+ name: 'Phantom Wallet',
43
+ image_id: 'b6ec7b81-bb4f-427d-e290-7631e6e50d00',
44
+ mobile_link: 'phantom://'
45
+ },
46
+
47
+ // Storage Keys
48
+ STORAGE_KEYS: {
49
+ WC_DEEPLINK: 'WALLETCONNECT_DEEPLINK_CHOICE', //dont change this one
50
+ RECENT_WALLET: '@appkit/recent_wallet',
51
+ CONNECTED_WALLET_IMAGE_URL: '@appkit/connected_wallet_image_url',
52
+ CONNECTED_CONNECTORS: '@appkit/connected_connectors',
53
+ CONNECTED_SOCIAL: '@appkit/connected_social',
54
+ ONRAMP_PREFERRED_COUNTRY: '@appkit/onramp_preferred_country',
55
+ ONRAMP_COUNTRIES: '@appkit/onramp_countries',
56
+ ONRAMP_SERVICE_PROVIDERS: '@appkit/onramp_service_providers',
57
+ ONRAMP_FIAT_LIMITS: '@appkit/onramp_fiat_limits',
58
+ ONRAMP_FIAT_CURRENCIES: '@appkit/onramp_fiat_currencies',
59
+ ONRAMP_PREFERRED_FIAT_CURRENCY: '@appkit/onramp_preferred_fiat_currency',
60
+ ONRAMP_COUNTRIES_DEFAULTS: '@appkit/onramp_countries_defaults',
61
+ ACTIVE_NAMESPACE: '@appkit/active_namespace',
62
+ COINBASE_CONNECTOR_SESSION: '@appkit/coinbase_connector/session'
63
+ }
37
64
  };