@reown/appkit-common-react-native 0.0.0-fix-approved-networks-20250822000414 → 0.0.0-fix-ui-changes-20250828183750
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/BlockchainAdapter.js +94 -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 +66 -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/siwe/config.js +6 -0
- package/lib/commonjs/types/siwe/config.js.map +1 -0
- package/lib/commonjs/types/siwe/index.js +28 -0
- package/lib/commonjs/types/siwe/index.js.map +1 -0
- package/lib/commonjs/types/siwe/message.js +6 -0
- package/lib/commonjs/types/siwe/message.js.map +1 -0
- package/lib/commonjs/types/storage.js +2 -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 +52 -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/BlockchainAdapter.js +89 -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 +8 -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/siwe/config.js +4 -0
- package/lib/module/types/siwe/config.js.map +1 -0
- package/lib/module/types/siwe/index.js +6 -0
- package/lib/module/types/siwe/index.js.map +1 -0
- package/lib/module/types/siwe/message.js +4 -0
- package/lib/module/types/siwe/message.js.map +1 -0
- package/lib/module/types/storage.js +2 -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 +54 -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/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 +6 -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 +6 -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 +304 -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 +50 -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/siwe/config.d.ts +31 -0
- package/lib/typescript/types/siwe/config.d.ts.map +1 -0
- package/lib/typescript/types/siwe/index.d.ts +3 -0
- package/lib/typescript/types/siwe/index.d.ts.map +1 -0
- package/lib/typescript/types/siwe/message.d.ts +57 -0
- package/lib/typescript/types/siwe/message.d.ts.map +1 -0
- package/lib/typescript/types/storage.d.ts +27 -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 +30 -0
- package/lib/typescript/types/wallet/connection.d.ts.map +1 -0
- package/lib/typescript/types/wallet/connector.d.ts +61 -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 +36 -0
- package/lib/typescript/types/wallet/wallet-info.d.ts.map +1 -0
- package/lib/typescript/utils/ConstantsUtil.d.ts +48 -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 +6 -16
- package/src/adapters/BlockchainAdapter.ts +126 -0
- package/src/adapters/EvmAdapter.ts +247 -0
- package/src/adapters/SolanaBaseAdapter.ts +6 -0
- package/src/adapters/__tests__/EvmAdapter.test.ts +126 -0
- package/src/index.ts +7 -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 +394 -0
- package/src/types/api/index.ts +4 -0
- package/src/types/api/wallet-api.ts +70 -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/siwe/config.ts +44 -0
- package/src/types/siwe/index.ts +3 -0
- package/src/types/siwe/message.ts +62 -0
- package/src/types/storage.ts +30 -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 +33 -0
- package/src/types/wallet/connector.ts +85 -0
- package/src/types/wallet/index.ts +4 -0
- package/src/types/wallet/wallet-info.ts +41 -0
- package/src/utils/ConstantsUtil.ts +55 -8
- 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
|
@@ -8,10 +8,54 @@ export declare const ConstantsUtil: {
|
|
|
8
8
|
BLOCKCHAIN_API_RPC_URL_STAGING: string;
|
|
9
9
|
PULSE_API_URL: string;
|
|
10
10
|
API_URL: string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
WEB_WALLET_URL: string;
|
|
12
|
+
SECURE_SITE_DASHBOARD: string;
|
|
13
|
+
SECURE_SITE_ICON: string;
|
|
14
|
+
REOWN_URL: string;
|
|
15
15
|
USDT_CONTRACT_ADDRESSES: string[];
|
|
16
|
+
PHANTOM_CUSTOM_WALLET: {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
image_id: string;
|
|
20
|
+
mobile_link: string;
|
|
21
|
+
play_store: string;
|
|
22
|
+
app_store: string;
|
|
23
|
+
android_app_id: string;
|
|
24
|
+
ios_schema: string;
|
|
25
|
+
};
|
|
26
|
+
COINBASE_CUSTOM_WALLET: {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
image_id: string;
|
|
30
|
+
mobile_link: string;
|
|
31
|
+
play_store: string;
|
|
32
|
+
app_store: string;
|
|
33
|
+
android_app_id: string;
|
|
34
|
+
ios_schema: string;
|
|
35
|
+
};
|
|
36
|
+
SOLFLARE_CUSTOM_WALLET: {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
image_id: string;
|
|
40
|
+
mobile_link: string;
|
|
41
|
+
play_store: string;
|
|
42
|
+
app_store: string;
|
|
43
|
+
android_app_id: string;
|
|
44
|
+
ios_schema: string;
|
|
45
|
+
};
|
|
46
|
+
STORAGE_KEYS: {
|
|
47
|
+
WC_DEEPLINK: string;
|
|
48
|
+
RECENT_WALLET: string;
|
|
49
|
+
CONNECTED_CONNECTORS: string;
|
|
50
|
+
ONRAMP_PREFERRED_COUNTRY: string;
|
|
51
|
+
ONRAMP_COUNTRIES: string;
|
|
52
|
+
ONRAMP_SERVICE_PROVIDERS: string;
|
|
53
|
+
ONRAMP_FIAT_LIMITS: string;
|
|
54
|
+
ONRAMP_FIAT_CURRENCIES: string;
|
|
55
|
+
ONRAMP_PREFERRED_FIAT_CURRENCY: string;
|
|
56
|
+
ONRAMP_COUNTRIES_DEFAULTS: string;
|
|
57
|
+
ACTIVE_NAMESPACE: string;
|
|
58
|
+
COINBASE_CONNECTOR_SESSION: string;
|
|
59
|
+
};
|
|
16
60
|
};
|
|
17
61
|
//# sourceMappingURL=ConstantsUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConstantsUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/ConstantsUtil.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"ConstantsUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/ConstantsUtil.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmFzB,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { CaipAddress } from '../types';
|
|
1
2
|
export declare const NetworkUtil: {
|
|
2
3
|
caipNetworkIdToNumber(caipnetworkId?: `${string}:${string}`): number | undefined;
|
|
4
|
+
getPlainAddress(caipAddress?: CaipAddress): string | undefined;
|
|
3
5
|
};
|
|
4
6
|
//# sourceMappingURL=NetworkUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/NetworkUtil.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;0CACgB,GAAG,MAAM,IAAI,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"NetworkUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/NetworkUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,eAAO,MAAM,WAAW;0CACgB,GAAG,MAAM,IAAI,MAAM,EAAE;kCAG7B,WAAW;CAG1C,CAAC"}
|
|
@@ -1,27 +1,55 @@
|
|
|
1
1
|
import * as BigNumber from 'bignumber.js';
|
|
2
2
|
export declare const NumberUtil: {
|
|
3
|
+
/**
|
|
4
|
+
* Creates a BigNumber instance from a given value.
|
|
5
|
+
* If the value is a string, commas are removed before conversion.
|
|
6
|
+
* @param value - The input value (string, number, or BigNumber) to convert to a BigNumber.
|
|
7
|
+
* @returns A BigNumber instance.
|
|
8
|
+
*/
|
|
3
9
|
bigNumber(value: BigNumber.BigNumber.Value): BigNumber.BigNumber;
|
|
4
10
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @param
|
|
8
|
-
* @
|
|
11
|
+
* Multiplies two numbers using BigNumber for precision, especially with decimals.
|
|
12
|
+
* Handles undefined inputs by returning BigNumber(0).
|
|
13
|
+
* @param a - The first multiplicand (string, number, or BigNumber). Commas are removed if it's a string.
|
|
14
|
+
* @param b - The second multiplicand (string, number, or BigNumber). Commas are removed if it's a string.
|
|
15
|
+
* @returns The product as a BigNumber instance, or BigNumber(0) if either input is undefined.
|
|
9
16
|
*/
|
|
10
17
|
multiply(a: BigNumber.BigNumber.Value | undefined, b: BigNumber.BigNumber.Value | undefined): BigNumber.BigNumber;
|
|
18
|
+
/**
|
|
19
|
+
* Rounds a number to a specified number of decimal places if its string representation meets a certain length threshold.
|
|
20
|
+
* @param number - The number to potentially round.
|
|
21
|
+
* @param threshold - The minimum string length of the number to trigger rounding.
|
|
22
|
+
* @param fixed - The number of decimal places to round to.
|
|
23
|
+
* @returns The rounded number (as a string if rounded, otherwise the original number) or the original number.
|
|
24
|
+
*/
|
|
11
25
|
roundNumber(number: number, threshold: number, fixed: number): string | number;
|
|
26
|
+
/**
|
|
27
|
+
* Calculates the next multiple of ten greater than or equal to the given amount.
|
|
28
|
+
* Defaults to 10 if no amount is provided or if the calculated multiple is less than 10.
|
|
29
|
+
* @param amount - The number for which to find the next multiple of ten. Optional.
|
|
30
|
+
* @returns The next multiple of ten, at least 10.
|
|
31
|
+
*/
|
|
12
32
|
nextMultipleOfTen(amount?: number): number;
|
|
13
33
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @param value - The value to format
|
|
16
|
-
* @param decimals - number of
|
|
17
|
-
* @returns
|
|
34
|
+
* Formats a number or string to a human-readable string with a specified number of decimal places, using US locale formatting.
|
|
35
|
+
* @param value - The value to format (string, number, or undefined). If undefined, returns '0.00'.
|
|
36
|
+
* @param decimals - The number of decimal places to display. Defaults to 2.
|
|
37
|
+
* @returns A locale-formatted string representation of the number.
|
|
18
38
|
*/
|
|
19
39
|
formatNumberToLocalString(value: string | number | undefined, decimals?: number): string;
|
|
20
40
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @param value - The formatted string to parse
|
|
23
|
-
* @returns
|
|
41
|
+
* Parses a locale-formatted numeric string (e.g., with commas) back into a number.
|
|
42
|
+
* @param value - The formatted string to parse. If undefined, returns 0.
|
|
43
|
+
* @returns The parsed number, or 0 if the input is undefined.
|
|
24
44
|
*/
|
|
25
45
|
parseLocalStringToNumber(value: string | undefined): number;
|
|
46
|
+
/**
|
|
47
|
+
* Converts a numeric value (BigInt, number, or string representation of a number) to a 0x-prefixed hexadecimal string.
|
|
48
|
+
* This is often required for Ethereum RPC parameters like value, gas, gasPrice.
|
|
49
|
+
* @param value - The value to convert. Can be BigInt, number, or a string (decimal or hex).
|
|
50
|
+
* @returns A 0x-prefixed hexadecimal string, or undefined if the input is undefined or null.
|
|
51
|
+
* @throws Error if the value cannot be converted to BigInt.
|
|
52
|
+
*/
|
|
53
|
+
convertNumericToHexString: (value: any) => string | undefined;
|
|
26
54
|
};
|
|
27
55
|
//# sourceMappingURL=NumberUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/NumberUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAE1C,eAAO,MAAM,UAAU;
|
|
1
|
+
{"version":3,"file":"NumberUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/NumberUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAE1C,eAAO,MAAM,UAAU;IACrB;;;;;OAKG;qBACc,mBAAmB,CAAC,KAAK;IAQ1C;;;;;;OAMG;gBACS,mBAAmB,CAAC,KAAK,GAAG,SAAS,KAAK,mBAAmB,CAAC,KAAK,GAAG,SAAS;IAW3F;;;;;;OAMG;wBACiB,MAAM,aAAa,MAAM,SAAS,MAAM;IAO5D;;;;;OAKG;+BACwB,MAAM;IAMjC;;;;;OAKG;qCAC8B,MAAM,GAAG,MAAM,GAAG,SAAS;IAkB5D;;;;OAIG;oCAC6B,MAAM,GAAG,SAAS;IASlD;;;;;;OAMG;uCACgC,GAAG,KAAG,MAAM,GAAG,SAAS;CAc5D,CAAC"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import type { ConnectorType } from './TypeUtil';
|
|
2
1
|
export declare const PresetsUtil: {
|
|
3
|
-
|
|
4
|
-
EIP155NetworkImageIds: Record<string, string>;
|
|
5
|
-
ConnectorNamesMap: Record<string, string>;
|
|
6
|
-
ConnectorImageIds: Record<string, string>;
|
|
7
|
-
ConnectorTypesMap: Record<string, ConnectorType>;
|
|
2
|
+
NetworkImageIds: Record<string, string>;
|
|
8
3
|
RpcChainIds: number[];
|
|
9
4
|
};
|
|
10
5
|
//# sourceMappingURL=PresetsUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresetsUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/PresetsUtil.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"PresetsUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/PresetsUtil.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;CA2HvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StringUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/StringUtil.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;uBACF,MAAM;
|
|
1
|
+
{"version":3,"file":"StringUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/StringUtil.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;uBACF,MAAM;0BAOH,MAAM;CAO7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reown/appkit-common-react-native",
|
|
3
|
-
"version": "0.0.0-fix-
|
|
3
|
+
"version": "0.0.0-fix-ui-changes-20250828183750",
|
|
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,126 @@
|
|
|
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
|
+
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 });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
onDisconnect(): void {
|
|
102
|
+
this.emit('disconnect', undefined);
|
|
103
|
+
|
|
104
|
+
const provider = this.connector?.getProvider();
|
|
105
|
+
if (provider) {
|
|
106
|
+
provider.off('chainChanged', this.onChainChanged.bind(this));
|
|
107
|
+
provider.off('accountsChanged', this.onAccountsChanged.bind(this));
|
|
108
|
+
provider.off('disconnect', this.onDisconnect.bind(this));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
this.connector = undefined;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
parseUnits(value: string, decimals: number): bigint {
|
|
115
|
+
const [whole, fraction = ''] = value.split('.');
|
|
116
|
+
const paddedFraction = (fraction + '0'.repeat(decimals)).slice(0, decimals);
|
|
117
|
+
|
|
118
|
+
return BigInt(whole + paddedFraction);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
abstract disconnect(): Promise<void>;
|
|
122
|
+
abstract getSupportedNamespace(): ChainNamespace;
|
|
123
|
+
abstract getBalance(params: GetBalanceParams): Promise<GetBalanceResponse>;
|
|
124
|
+
abstract getAccounts(): CaipAddress[] | undefined;
|
|
125
|
+
abstract switchNetwork(network: AppKitNetwork): Promise<void>;
|
|
126
|
+
}
|
|
@@ -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, chain?: 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:${chain}`
|
|
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
|
+
}
|