@reown/appkit-common-react-native 0.0.0-develop-20250728153935 → 0.0.0-develop-20251030154825
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.
- package/lib/commonjs/adapters/BitcoinBaseAdapter.js +10 -0
- package/lib/commonjs/adapters/BitcoinBaseAdapter.js.map +1 -0
- package/lib/commonjs/adapters/BlockchainAdapter.js +103 -0
- package/lib/commonjs/adapters/BlockchainAdapter.js.map +1 -0
- package/lib/commonjs/adapters/EvmAdapter.js +193 -0
- package/lib/commonjs/adapters/EvmAdapter.js.map +1 -0
- package/lib/commonjs/adapters/SolanaBaseAdapter.js +10 -0
- package/lib/commonjs/adapters/SolanaBaseAdapter.js.map +1 -0
- package/lib/commonjs/contracts/erc20.js.map +1 -1
- package/lib/commonjs/contracts/usdt.js.map +1 -1
- package/lib/commonjs/index.js +74 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/networks/bitcoin.js +40 -0
- package/lib/commonjs/networks/bitcoin.js.map +1 -0
- package/lib/commonjs/networks/solana.js +78 -0
- package/lib/commonjs/networks/solana.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types/api/blockchain-api.js +15 -0
- package/lib/commonjs/types/api/blockchain-api.js.map +1 -0
- package/lib/commonjs/types/api/events.js +6 -0
- package/lib/commonjs/types/api/events.js.map +1 -0
- package/lib/commonjs/types/api/index.js +39 -0
- package/lib/commonjs/types/api/index.js.map +1 -0
- package/lib/commonjs/types/api/wallet-api.js +6 -0
- package/lib/commonjs/types/api/wallet-api.js.map +1 -0
- package/lib/commonjs/types/blockchain/adapter.js +6 -0
- package/lib/commonjs/types/blockchain/adapter.js.map +1 -0
- package/lib/commonjs/types/blockchain/balance.js +6 -0
- package/lib/commonjs/types/blockchain/balance.js.map +1 -0
- package/lib/commonjs/types/blockchain/index.js +50 -0
- package/lib/commonjs/types/blockchain/index.js.map +1 -0
- package/lib/commonjs/types/blockchain/network.js +6 -0
- package/lib/commonjs/types/blockchain/network.js.map +1 -0
- package/lib/commonjs/types/blockchain/transaction.js +2 -0
- package/lib/commonjs/types/blockchain/transaction.js.map +1 -0
- package/lib/commonjs/types/common.js +2 -0
- package/lib/commonjs/types/common.js.map +1 -0
- package/lib/commonjs/types/index.js +105 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/onramp/countries.js +2 -0
- package/lib/commonjs/types/onramp/countries.js.map +1 -0
- package/lib/commonjs/types/onramp/currencies.js +2 -0
- package/lib/commonjs/types/onramp/currencies.js.map +1 -0
- package/lib/commonjs/types/onramp/errors.js +22 -0
- package/lib/commonjs/types/onramp/errors.js.map +1 -0
- package/lib/commonjs/types/onramp/index.js +50 -0
- package/lib/commonjs/types/onramp/index.js.map +1 -0
- package/lib/commonjs/types/onramp/quotes.js +2 -0
- package/lib/commonjs/types/onramp/quotes.js.map +1 -0
- package/lib/commonjs/types/siwx/config.js +6 -0
- package/lib/commonjs/types/siwx/config.js.map +1 -0
- package/lib/commonjs/types/siwx/index.js +50 -0
- package/lib/commonjs/types/siwx/index.js.map +1 -0
- package/lib/commonjs/types/siwx/message.js +6 -0
- package/lib/commonjs/types/siwx/message.js.map +1 -0
- package/lib/commonjs/types/siwx/storage.js +6 -0
- package/lib/commonjs/types/siwx/storage.js.map +1 -0
- package/lib/commonjs/types/siwx/verifier.js +35 -0
- package/lib/commonjs/types/siwx/verifier.js.map +1 -0
- package/lib/commonjs/types/storage.js +24 -0
- package/lib/commonjs/types/storage.js.map +1 -0
- package/lib/commonjs/types/swap/index.js +17 -0
- package/lib/commonjs/types/swap/index.js.map +1 -0
- package/lib/commonjs/types/swap/tokens.js +6 -0
- package/lib/commonjs/types/swap/tokens.js.map +1 -0
- package/lib/commonjs/types/ui.js +6 -0
- package/lib/commonjs/{utils/TypeUtil.js.map → types/ui.js.map} +1 -1
- package/lib/commonjs/types/wallet/connection.js +6 -0
- package/lib/commonjs/types/wallet/connection.js.map +1 -0
- package/lib/commonjs/types/wallet/connector.js +30 -0
- package/lib/commonjs/types/wallet/connector.js.map +1 -0
- package/lib/commonjs/types/wallet/index.js +39 -0
- package/lib/commonjs/types/wallet/index.js.map +1 -0
- package/lib/commonjs/types/wallet/wallet-info.js +6 -0
- package/lib/commonjs/types/wallet/wallet-info.js.map +1 -0
- package/lib/commonjs/utils/ConstantsUtil.js +45 -6
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/commonjs/utils/ContractUtil.js.map +1 -1
- package/lib/commonjs/utils/DateUtil.js.map +1 -1
- package/lib/commonjs/utils/ErrorUtil.js.map +1 -1
- package/lib/commonjs/utils/NamesUtil.js.map +1 -1
- package/lib/commonjs/utils/NetworkUtil.js +3 -0
- package/lib/commonjs/utils/NetworkUtil.js.map +1 -1
- package/lib/commonjs/utils/NumberUtil.js +53 -13
- package/lib/commonjs/utils/NumberUtil.js.map +1 -1
- package/lib/commonjs/utils/PresetsUtil.js +34 -21
- package/lib/commonjs/utils/PresetsUtil.js.map +1 -1
- package/lib/commonjs/utils/StringUtil.js +7 -0
- package/lib/commonjs/utils/StringUtil.js.map +1 -1
- package/lib/module/adapters/BitcoinBaseAdapter.js +5 -0
- package/lib/module/adapters/BitcoinBaseAdapter.js.map +1 -0
- package/lib/module/adapters/BlockchainAdapter.js +98 -0
- package/lib/module/adapters/BlockchainAdapter.js.map +1 -0
- package/lib/module/adapters/EvmAdapter.js +189 -0
- package/lib/module/adapters/EvmAdapter.js.map +1 -0
- package/lib/module/adapters/SolanaBaseAdapter.js +5 -0
- package/lib/module/adapters/SolanaBaseAdapter.js.map +1 -0
- package/lib/module/contracts/erc20.js +2 -0
- package/lib/module/contracts/erc20.js.map +1 -1
- package/lib/module/contracts/usdt.js +2 -0
- package/lib/module/contracts/usdt.js.map +1 -1
- package/lib/module/index.js +9 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/networks/bitcoin.js +36 -0
- package/lib/module/networks/bitcoin.js.map +1 -0
- package/lib/module/networks/solana.js +74 -0
- package/lib/module/networks/solana.js.map +1 -0
- package/lib/module/types/api/blockchain-api.js +10 -0
- package/lib/module/types/api/blockchain-api.js.map +1 -0
- package/lib/module/types/api/events.js +4 -0
- package/lib/module/types/api/events.js.map +1 -0
- package/lib/module/types/api/index.js +7 -0
- package/lib/module/types/api/index.js.map +1 -0
- package/lib/module/types/api/wallet-api.js +4 -0
- package/lib/module/types/api/wallet-api.js.map +1 -0
- package/lib/module/types/blockchain/adapter.js +4 -0
- package/lib/module/types/blockchain/adapter.js.map +1 -0
- package/lib/module/types/blockchain/balance.js +4 -0
- package/lib/module/types/blockchain/balance.js.map +1 -0
- package/lib/module/types/blockchain/index.js +8 -0
- package/lib/module/types/blockchain/index.js.map +1 -0
- package/lib/module/types/blockchain/network.js +4 -0
- package/lib/module/types/blockchain/network.js.map +1 -0
- package/lib/module/types/blockchain/transaction.js +2 -0
- package/lib/module/types/blockchain/transaction.js.map +1 -0
- package/lib/module/types/common.js +2 -0
- package/lib/module/types/common.js.map +1 -0
- package/lib/module/types/index.js +31 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/onramp/countries.js +2 -0
- package/lib/module/types/onramp/countries.js.map +1 -0
- package/lib/module/types/onramp/currencies.js +2 -0
- package/lib/module/types/onramp/currencies.js.map +1 -0
- package/lib/module/types/onramp/errors.js +18 -0
- package/lib/module/types/onramp/errors.js.map +1 -0
- package/lib/module/types/onramp/index.js +8 -0
- package/lib/module/types/onramp/index.js.map +1 -0
- package/lib/module/types/onramp/quotes.js +2 -0
- package/lib/module/types/onramp/quotes.js.map +1 -0
- package/lib/module/types/siwx/config.js +4 -0
- package/lib/module/types/siwx/config.js.map +1 -0
- package/lib/module/types/siwx/index.js +7 -0
- package/lib/module/types/siwx/index.js.map +1 -0
- package/lib/module/types/siwx/message.js +4 -0
- package/lib/module/types/siwx/message.js.map +1 -0
- package/lib/module/types/siwx/storage.js +4 -0
- package/lib/module/types/siwx/storage.js.map +1 -0
- package/lib/module/types/siwx/verifier.js +30 -0
- package/lib/module/types/siwx/verifier.js.map +1 -0
- package/lib/module/types/storage.js +20 -0
- package/lib/module/types/storage.js.map +1 -0
- package/lib/module/types/swap/index.js +5 -0
- package/lib/module/types/swap/index.js.map +1 -0
- package/lib/module/types/swap/tokens.js +4 -0
- package/lib/module/types/swap/tokens.js.map +1 -0
- package/lib/module/types/ui.js +4 -0
- package/lib/module/{utils/TypeUtil.js.map → types/ui.js.map} +1 -1
- package/lib/module/types/wallet/connection.js +4 -0
- package/lib/module/types/wallet/connection.js.map +1 -0
- package/lib/module/types/wallet/connector.js +25 -0
- package/lib/module/types/wallet/connector.js.map +1 -0
- package/lib/module/types/wallet/index.js +7 -0
- package/lib/module/types/wallet/index.js.map +1 -0
- package/lib/module/types/wallet/wallet-info.js +4 -0
- package/lib/module/types/wallet/wallet-info.js.map +1 -0
- package/lib/module/utils/ConstantsUtil.js +47 -6
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/utils/ContractUtil.js +2 -0
- package/lib/module/utils/ContractUtil.js.map +1 -1
- package/lib/module/utils/DateUtil.js +2 -0
- package/lib/module/utils/DateUtil.js.map +1 -1
- package/lib/module/utils/ErrorUtil.js +2 -0
- package/lib/module/utils/ErrorUtil.js.map +1 -1
- package/lib/module/utils/NamesUtil.js +2 -0
- package/lib/module/utils/NamesUtil.js.map +1 -1
- package/lib/module/utils/NetworkUtil.js +5 -0
- package/lib/module/utils/NetworkUtil.js.map +1 -1
- package/lib/module/utils/NumberUtil.js +54 -11
- package/lib/module/utils/NumberUtil.js.map +1 -1
- package/lib/module/utils/PresetsUtil.js +36 -21
- package/lib/module/utils/PresetsUtil.js.map +1 -1
- package/lib/module/utils/StringUtil.js +9 -0
- package/lib/module/utils/StringUtil.js.map +1 -1
- package/lib/typescript/adapters/BitcoinBaseAdapter.d.ts +5 -0
- package/lib/typescript/adapters/BitcoinBaseAdapter.d.ts.map +1 -0
- package/lib/typescript/adapters/BlockchainAdapter.d.ts +26 -0
- package/lib/typescript/adapters/BlockchainAdapter.d.ts.map +1 -0
- package/lib/typescript/adapters/EvmAdapter.d.ts +26 -0
- package/lib/typescript/adapters/EvmAdapter.d.ts.map +1 -0
- package/lib/typescript/adapters/SolanaBaseAdapter.d.ts +7 -0
- package/lib/typescript/adapters/SolanaBaseAdapter.d.ts.map +1 -0
- package/lib/typescript/adapters/__tests__/EvmAdapter.test.d.ts +2 -0
- package/lib/typescript/adapters/__tests__/EvmAdapter.test.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +7 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/networks/bitcoin.d.ts +4 -0
- package/lib/typescript/networks/bitcoin.d.ts.map +1 -0
- package/lib/typescript/networks/solana.d.ts +5 -0
- package/lib/typescript/networks/solana.d.ts.map +1 -0
- package/lib/typescript/types/api/blockchain-api.d.ts +183 -0
- package/lib/typescript/types/api/blockchain-api.d.ts.map +1 -0
- package/lib/typescript/types/api/events.d.ts +357 -0
- package/lib/typescript/types/api/events.d.ts.map +1 -0
- package/lib/typescript/types/api/index.d.ts +4 -0
- package/lib/typescript/types/api/index.d.ts.map +1 -0
- package/lib/typescript/types/api/wallet-api.d.ts +51 -0
- package/lib/typescript/types/api/wallet-api.d.ts.map +1 -0
- package/lib/typescript/types/blockchain/adapter.d.ts +40 -0
- package/lib/typescript/types/blockchain/adapter.d.ts.map +1 -0
- package/lib/typescript/types/blockchain/balance.d.ts +28 -0
- package/lib/typescript/types/blockchain/balance.d.ts.map +1 -0
- package/lib/typescript/types/blockchain/index.d.ts +5 -0
- package/lib/typescript/types/blockchain/index.d.ts.map +1 -0
- package/lib/typescript/types/blockchain/network.d.ts +47 -0
- package/lib/typescript/types/blockchain/network.d.ts.map +1 -0
- package/lib/typescript/{utils/TypeUtil.d.ts → types/blockchain/transaction.d.ts} +1 -22
- package/lib/typescript/types/blockchain/transaction.d.ts.map +1 -0
- package/lib/typescript/types/common.d.ts +24 -0
- package/lib/typescript/types/common.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +10 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/lib/typescript/types/onramp/countries.d.ts +11 -0
- package/lib/typescript/types/onramp/countries.d.ts.map +1 -0
- package/lib/typescript/types/onramp/currencies.d.ts +30 -0
- package/lib/typescript/types/onramp/currencies.d.ts.map +1 -0
- package/lib/typescript/types/onramp/errors.d.ts +21 -0
- package/lib/typescript/types/onramp/errors.d.ts.map +1 -0
- package/lib/typescript/types/onramp/index.d.ts +5 -0
- package/lib/typescript/types/onramp/index.d.ts.map +1 -0
- package/lib/typescript/types/onramp/quotes.d.ts +45 -0
- package/lib/typescript/types/onramp/quotes.d.ts.map +1 -0
- package/lib/typescript/types/siwx/config.d.ts +73 -0
- package/lib/typescript/types/siwx/config.d.ts.map +1 -0
- package/lib/typescript/types/siwx/index.d.ts +5 -0
- package/lib/typescript/types/siwx/index.d.ts.map +1 -0
- package/lib/typescript/types/siwx/message.d.ts +92 -0
- package/lib/typescript/types/siwx/message.d.ts.map +1 -0
- package/lib/typescript/types/siwx/storage.d.ts +41 -0
- package/lib/typescript/types/siwx/storage.d.ts.map +1 -0
- package/lib/typescript/types/siwx/verifier.d.ts +28 -0
- package/lib/typescript/types/siwx/verifier.d.ts.map +1 -0
- package/lib/typescript/types/storage.d.ts +59 -0
- package/lib/typescript/types/storage.d.ts.map +1 -0
- package/lib/typescript/types/swap/index.d.ts +2 -0
- package/lib/typescript/types/swap/index.d.ts.map +1 -0
- package/lib/typescript/types/swap/tokens.d.ts +19 -0
- package/lib/typescript/types/swap/tokens.d.ts.map +1 -0
- package/lib/typescript/types/ui.d.ts +26 -0
- package/lib/typescript/types/ui.d.ts.map +1 -0
- package/lib/typescript/types/wallet/connection.d.ts +31 -0
- package/lib/typescript/types/wallet/connection.d.ts.map +1 -0
- package/lib/typescript/types/wallet/connector.d.ts +59 -0
- package/lib/typescript/types/wallet/connector.d.ts.map +1 -0
- package/lib/typescript/types/wallet/index.d.ts +4 -0
- package/lib/typescript/types/wallet/index.d.ts.map +1 -0
- package/lib/typescript/types/wallet/wallet-info.d.ts +37 -0
- package/lib/typescript/types/wallet/wallet-info.d.ts.map +1 -0
- package/lib/typescript/utils/ConstantsUtil.d.ts +43 -4
- package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
- package/lib/typescript/utils/NetworkUtil.d.ts +2 -0
- package/lib/typescript/utils/NetworkUtil.d.ts.map +1 -1
- package/lib/typescript/utils/NumberUtil.d.ts +39 -11
- package/lib/typescript/utils/NumberUtil.d.ts.map +1 -1
- package/lib/typescript/utils/PresetsUtil.d.ts +1 -6
- package/lib/typescript/utils/PresetsUtil.d.ts.map +1 -1
- package/lib/typescript/utils/StringUtil.d.ts +1 -0
- package/lib/typescript/utils/StringUtil.d.ts.map +1 -1
- package/package.json +9 -18
- package/src/adapters/BitcoinBaseAdapter.ts +5 -0
- package/src/adapters/BlockchainAdapter.ts +136 -0
- package/src/adapters/EvmAdapter.ts +247 -0
- package/src/adapters/SolanaBaseAdapter.ts +7 -0
- package/src/adapters/__tests__/EvmAdapter.test.ts +126 -0
- package/src/index.ts +8 -1
- package/src/networks/bitcoin.ts +32 -0
- package/src/networks/solana.ts +44 -0
- package/src/types/api/blockchain-api.ts +213 -0
- package/src/types/api/events.ts +462 -0
- package/src/types/api/index.ts +4 -0
- package/src/types/api/wallet-api.ts +71 -0
- package/src/types/blockchain/adapter.ts +52 -0
- package/src/types/blockchain/balance.ts +31 -0
- package/src/types/blockchain/index.ts +5 -0
- package/src/types/blockchain/network.ts +39 -0
- package/src/{utils/TypeUtil.ts → types/blockchain/transaction.ts} +0 -26
- package/src/types/common.ts +56 -0
- package/src/types/index.ts +28 -0
- package/src/types/onramp/countries.ts +11 -0
- package/src/types/onramp/currencies.ts +32 -0
- package/src/types/onramp/errors.ts +22 -0
- package/src/types/onramp/index.ts +5 -0
- package/src/types/onramp/quotes.ts +46 -0
- package/src/types/siwx/config.ts +73 -0
- package/src/types/siwx/index.ts +4 -0
- package/src/types/siwx/message.ts +92 -0
- package/src/types/siwx/storage.ts +44 -0
- package/src/types/siwx/verifier.ts +32 -0
- package/src/types/storage.ts +64 -0
- package/src/types/swap/index.ts +2 -0
- package/src/types/swap/tokens.ts +21 -0
- package/src/types/ui.ts +26 -0
- package/src/types/wallet/connection.ts +34 -0
- package/src/types/wallet/connector.ts +83 -0
- package/src/types/wallet/index.ts +4 -0
- package/src/types/wallet/wallet-info.ts +42 -0
- package/src/utils/ConstantsUtil.ts +48 -7
- package/src/utils/NetworkUtil.ts +5 -0
- package/src/utils/NumberUtil.ts +54 -11
- package/src/utils/PresetsUtil.ts +34 -26
- package/src/utils/StringUtil.ts +7 -0
- package/lib/commonjs/utils/TypeUtil.js +0 -2
- package/lib/module/utils/TypeUtil.js +0 -2
- package/lib/typescript/utils/TypeUtil.d.ts.map +0 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import type {
|
|
3
|
+
AdapterEvents,
|
|
4
|
+
AdapterType,
|
|
5
|
+
AppKitNetwork,
|
|
6
|
+
BlockchainAdapterConfig,
|
|
7
|
+
BlockchainAdapterInitParams,
|
|
8
|
+
CaipAddress,
|
|
9
|
+
ChainNamespace,
|
|
10
|
+
GetBalanceParams,
|
|
11
|
+
GetBalanceResponse,
|
|
12
|
+
Provider,
|
|
13
|
+
WalletConnector
|
|
14
|
+
} from '../types';
|
|
15
|
+
import { NetworkUtil } from '../utils/NetworkUtil';
|
|
16
|
+
|
|
17
|
+
export abstract class BlockchainAdapter extends EventEmitter {
|
|
18
|
+
public connector?: WalletConnector;
|
|
19
|
+
public supportedNamespace: ChainNamespace;
|
|
20
|
+
public adapterType: AdapterType;
|
|
21
|
+
|
|
22
|
+
// Typed emit method
|
|
23
|
+
override emit<K extends keyof AdapterEvents>(
|
|
24
|
+
event: K,
|
|
25
|
+
payload: Parameters<AdapterEvents[K]>[0]
|
|
26
|
+
): boolean {
|
|
27
|
+
return super.emit(event, payload);
|
|
28
|
+
}
|
|
29
|
+
|
|
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) {
|
|
41
|
+
super();
|
|
42
|
+
this.supportedNamespace = supportedNamespace;
|
|
43
|
+
this.adapterType = adapterType;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
init({ connector }: BlockchainAdapterInitParams) {
|
|
47
|
+
this.connector = connector;
|
|
48
|
+
|
|
49
|
+
this.subscribeToEvents();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
removeConnector() {
|
|
53
|
+
this.connector = undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getProvider(): Provider {
|
|
57
|
+
if (!this.connector) throw new Error('No active connector');
|
|
58
|
+
|
|
59
|
+
return this.connector.getProvider(this.getSupportedNamespace());
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
subscribeToEvents(): void {
|
|
63
|
+
const provider = this.connector?.getProvider();
|
|
64
|
+
if (!provider) return;
|
|
65
|
+
|
|
66
|
+
provider.on('chainChanged', this.onChainChanged.bind(this));
|
|
67
|
+
provider.on('accountsChanged', this.onAccountsChanged.bind(this));
|
|
68
|
+
provider.on('disconnect', this.onDisconnect.bind(this));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
onChainChanged(chainId: string): void {
|
|
72
|
+
const _chains = this.getAccounts()?.map(account => account.split(':')[1]);
|
|
73
|
+
const shouldEmit = _chains?.some(chain => chain === chainId);
|
|
74
|
+
|
|
75
|
+
if (shouldEmit) {
|
|
76
|
+
this.emit('chainChanged', { chainId });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
onAccountsChanged(accounts: string[]): void {
|
|
81
|
+
const _accounts = this.getAccounts();
|
|
82
|
+
// Normalize incoming accounts to lowercase for case-insensitive comparison
|
|
83
|
+
const normalizedIncomingAccounts = accounts.map(addr => addr.toLowerCase());
|
|
84
|
+
|
|
85
|
+
// Filter: Keep only adapter accounts (CAIP) whose plain address is in the incoming accounts array
|
|
86
|
+
const updatedAccounts =
|
|
87
|
+
_accounts
|
|
88
|
+
?.filter(account => {
|
|
89
|
+
// Normalize to lowercase for case-insensitive comparison since plain addresses from CAIP may vary in casing
|
|
90
|
+
const accountAddress = NetworkUtil.getPlainAddress(account)?.toLowerCase();
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
accountAddress !== undefined && normalizedIncomingAccounts.includes(accountAddress)
|
|
94
|
+
);
|
|
95
|
+
})
|
|
96
|
+
// Sort: Maintain the order from the incoming accounts parameter
|
|
97
|
+
.sort((a, b) => {
|
|
98
|
+
const aAddress = NetworkUtil.getPlainAddress(a)?.toLowerCase() ?? '';
|
|
99
|
+
const bAddress = NetworkUtil.getPlainAddress(b)?.toLowerCase() ?? '';
|
|
100
|
+
const aIndex = normalizedIncomingAccounts.indexOf(aAddress);
|
|
101
|
+
const bIndex = normalizedIncomingAccounts.indexOf(bAddress);
|
|
102
|
+
|
|
103
|
+
return aIndex - bIndex;
|
|
104
|
+
}) ?? [];
|
|
105
|
+
|
|
106
|
+
if (updatedAccounts.length > 0) {
|
|
107
|
+
this.emit('accountsChanged', { accounts: updatedAccounts });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
onDisconnect(): void {
|
|
112
|
+
this.emit('disconnect', undefined);
|
|
113
|
+
|
|
114
|
+
const provider = this.connector?.getProvider();
|
|
115
|
+
if (provider) {
|
|
116
|
+
provider.off('chainChanged', this.onChainChanged.bind(this));
|
|
117
|
+
provider.off('accountsChanged', this.onAccountsChanged.bind(this));
|
|
118
|
+
provider.off('disconnect', this.onDisconnect.bind(this));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
this.connector = undefined;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
parseUnits(value: string, decimals: number): bigint {
|
|
125
|
+
const [whole, fraction = ''] = value.split('.');
|
|
126
|
+
const paddedFraction = (fraction + '0'.repeat(decimals)).slice(0, decimals);
|
|
127
|
+
|
|
128
|
+
return BigInt(whole + paddedFraction);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
abstract disconnect(): Promise<void>;
|
|
132
|
+
abstract getSupportedNamespace(): ChainNamespace;
|
|
133
|
+
abstract getBalance(params: GetBalanceParams): Promise<GetBalanceResponse>;
|
|
134
|
+
abstract getAccounts(): CaipAddress[] | undefined;
|
|
135
|
+
abstract switchNetwork(network: AppKitNetwork): Promise<void>;
|
|
136
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { BlockchainAdapter } from './BlockchainAdapter';
|
|
2
|
+
import { NumberUtil } from '../utils/NumberUtil';
|
|
3
|
+
import type { AppKitNetwork } from '../types';
|
|
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
|
+
async signMessage(address: string, message: string, chainId?: string): Promise<string> {
|
|
75
|
+
const provider = this.getProvider();
|
|
76
|
+
|
|
77
|
+
if (!provider) {
|
|
78
|
+
throw new Error('EVMAdapter:signMessage - provider is undefined');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const signature = await provider.request(
|
|
82
|
+
{
|
|
83
|
+
method: 'personal_sign',
|
|
84
|
+
params: [message, address]
|
|
85
|
+
},
|
|
86
|
+
`eip155:${chainId}`
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
return signature as string;
|
|
90
|
+
}
|
|
91
|
+
async estimateGas({ address, to, data, chainNamespace }: any): Promise<bigint> {
|
|
92
|
+
const provider = this.getProvider();
|
|
93
|
+
|
|
94
|
+
if (!provider) {
|
|
95
|
+
throw new Error('EVMAdapter:estimateGas - provider is undefined');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (!address) {
|
|
99
|
+
throw new Error('EVMAdapter:estimateGas - from address is undefined');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (chainNamespace && chainNamespace !== 'eip155') {
|
|
103
|
+
throw new Error('EVMAdapter:estimateGas - chainNamespace is not eip155');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
const txParams = {
|
|
108
|
+
from: address,
|
|
109
|
+
to,
|
|
110
|
+
data,
|
|
111
|
+
type: '0x0' // optional, legacy type
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const estimatedGasHex = await provider.request({
|
|
115
|
+
method: 'eth_estimateGas',
|
|
116
|
+
params: [txParams]
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
return BigInt(estimatedGasHex as string);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
throw new Error('EVMAdapter:estimateGas - eth_estimateGas RPC failed');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async sendTransaction(data: SendTransactionData): Promise<`0x${string}` | null> {
|
|
126
|
+
const { address, network } = data || {};
|
|
127
|
+
|
|
128
|
+
if (!this.getProvider()) {
|
|
129
|
+
throw new Error('EVMAdapter:sendTransaction - provider is undefined');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (!address) {
|
|
133
|
+
throw new Error('EVMAdapter:sendTransaction - address is undefined');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!network) {
|
|
137
|
+
throw new Error('EVMAdapter:sendTransaction - network is undefined');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const txParams = {
|
|
141
|
+
from: address,
|
|
142
|
+
to: data.to,
|
|
143
|
+
value: NumberUtil.convertNumericToHexString(data.value),
|
|
144
|
+
data: data.data, // hex-encoded bytecode
|
|
145
|
+
type: '0x0' // optional: legacy transaction type
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const txHash = await this.getProvider().request(
|
|
149
|
+
{
|
|
150
|
+
method: 'eth_sendTransaction',
|
|
151
|
+
params: [txParams]
|
|
152
|
+
},
|
|
153
|
+
network.caipNetworkId
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
return txHash as `0x${string}` | null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async writeContract(data: WriteContractData): Promise<`0x${string}` | null> {
|
|
160
|
+
const {
|
|
161
|
+
tokenAddress,
|
|
162
|
+
receiverAddress,
|
|
163
|
+
tokenAmount,
|
|
164
|
+
method,
|
|
165
|
+
fromAddress,
|
|
166
|
+
spenderAddress,
|
|
167
|
+
network
|
|
168
|
+
} = data;
|
|
169
|
+
|
|
170
|
+
if (!this.getProvider()) {
|
|
171
|
+
throw new Error('EVMAdapter:writeContract - provider is undefined');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (!fromAddress) {
|
|
175
|
+
throw new Error('EVMAdapter:writeContract - fromAddress is undefined');
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (!tokenAddress) {
|
|
179
|
+
throw new Error('EVMAdapter:writeContract - tokenAddress is undefined');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (!tokenAmount) {
|
|
183
|
+
throw new Error('EVMAdapter:writeContract - tokenAmount is undefined');
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (!method) {
|
|
187
|
+
throw new Error('EVMAdapter:writeContract - method is undefined');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Validate method-specific parameters
|
|
191
|
+
if (method === 'transfer' && !receiverAddress) {
|
|
192
|
+
throw new Error('EVMAdapter:writeContract - receiverAddress is required for transfer method');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if ((method === 'transferFrom' || method === 'approve') && !spenderAddress) {
|
|
196
|
+
throw new Error(`EVMAdapter:writeContract - spenderAddress is required for ${method} method`);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Encode the function call data based on method
|
|
200
|
+
let encodedData: string;
|
|
201
|
+
|
|
202
|
+
switch (method) {
|
|
203
|
+
case 'transfer':
|
|
204
|
+
encodedData = encodeERC20Function('transfer', [receiverAddress, tokenAmount]);
|
|
205
|
+
break;
|
|
206
|
+
case 'transferFrom':
|
|
207
|
+
encodedData = encodeERC20Function('transferFrom', [
|
|
208
|
+
fromAddress,
|
|
209
|
+
receiverAddress,
|
|
210
|
+
tokenAmount
|
|
211
|
+
]);
|
|
212
|
+
break;
|
|
213
|
+
case 'approve':
|
|
214
|
+
encodedData = encodeERC20Function('approve', [spenderAddress, tokenAmount]);
|
|
215
|
+
break;
|
|
216
|
+
default:
|
|
217
|
+
throw new Error(`EVMAdapter:writeContract - method '${method}' is not supported`);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Create transaction parameters
|
|
221
|
+
const txParams = {
|
|
222
|
+
from: fromAddress,
|
|
223
|
+
to: tokenAddress,
|
|
224
|
+
data: encodedData,
|
|
225
|
+
value: '0x0', // No ETH value for token operations
|
|
226
|
+
type: '0x0' // legacy transaction type
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
try {
|
|
230
|
+
// Send the transaction
|
|
231
|
+
const txHash = await this.getProvider().request(
|
|
232
|
+
{
|
|
233
|
+
method: 'eth_sendTransaction',
|
|
234
|
+
params: [txParams]
|
|
235
|
+
},
|
|
236
|
+
network.caipNetworkId
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
return txHash as `0x${string}` | null;
|
|
240
|
+
} catch (error) {
|
|
241
|
+
if (error instanceof Error) {
|
|
242
|
+
throw new Error(`EVMAdapter:writeContract - ${error.message}`);
|
|
243
|
+
}
|
|
244
|
+
throw new Error('EVMAdapter:writeContract - unknown error occurred');
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
abstract signMessage(address: string, message: string, chainId?: string): Promise<string>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { EVMAdapter } from '../EvmAdapter';
|
|
2
|
+
import type { AppKitNetwork, CaipAddress } from '../../types';
|
|
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({ 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,11 @@ 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
|
|
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';
|
|
16
|
+
export { BitcoinBaseAdapter } from './adapters/BitcoinBaseAdapter';
|
|
17
|
+
|
|
18
|
+
export * from './types';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AppKitNetwork } from '../types';
|
|
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 '../types';
|
|
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
|
+
};
|