@reown/appkit-common-react-native 2.0.0 → 2.0.1
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 +38 -14
- package/lib/commonjs/adapters/BlockchainAdapter.js.map +1 -1
- package/lib/commonjs/adapters/EvmAdapter.js +126 -16
- package/lib/commonjs/adapters/EvmAdapter.js.map +1 -1
- package/lib/commonjs/adapters/SolanaBaseAdapter.js +1 -3
- package/lib/commonjs/adapters/SolanaBaseAdapter.js.map +1 -1
- package/lib/commonjs/contracts/erc20.js.map +1 -1
- package/lib/commonjs/contracts/usdt.js.map +1 -1
- package/lib/commonjs/index.js +13 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/networks/bitcoin.js.map +1 -1
- package/lib/commonjs/networks/solana.js.map +1 -1
- 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/types/ui.js.map +1 -0
- package/lib/commonjs/types/wallet/connection.js +6 -0
- package/lib/commonjs/types/wallet/connection.js.map +1 -0
- package/lib/commonjs/{utils/TypeUtil.js → types/wallet/connector.js} +7 -13
- 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 +2 -2
- 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 +1 -2
- package/lib/commonjs/utils/NumberUtil.js.map +1 -1
- package/lib/commonjs/utils/PresetsUtil.js +0 -18
- 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 +40 -14
- package/lib/module/adapters/BlockchainAdapter.js.map +1 -1
- package/lib/module/adapters/EvmAdapter.js +129 -16
- package/lib/module/adapters/EvmAdapter.js.map +1 -1
- package/lib/module/adapters/SolanaBaseAdapter.js +3 -3
- package/lib/module/adapters/SolanaBaseAdapter.js.map +1 -1
- 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 +4 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/networks/bitcoin.js +2 -0
- package/lib/module/networks/bitcoin.js.map +1 -1
- package/lib/module/networks/solana.js +2 -0
- package/lib/module/networks/solana.js.map +1 -1
- 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/types/ui.js.map +1 -0
- package/lib/module/types/wallet/connection.js +4 -0
- package/lib/module/types/wallet/connection.js.map +1 -0
- package/lib/module/{utils/TypeUtil.js → types/wallet/connector.js} +9 -14
- 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 +4 -2
- 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 +2 -0
- package/lib/module/utils/NumberUtil.js.map +1 -1
- package/lib/module/utils/PresetsUtil.js +2 -18
- 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 +6 -7
- package/lib/typescript/adapters/BlockchainAdapter.d.ts.map +1 -1
- package/lib/typescript/adapters/EvmAdapter.d.ts +21 -1
- package/lib/typescript/adapters/EvmAdapter.d.ts.map +1 -1
- package/lib/typescript/adapters/SolanaBaseAdapter.d.ts +3 -0
- package/lib/typescript/adapters/SolanaBaseAdapter.d.ts.map +1 -1
- 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 +2 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/networks/bitcoin.d.ts +1 -1
- package/lib/typescript/networks/bitcoin.d.ts.map +1 -1
- package/lib/typescript/networks/solana.d.ts +1 -1
- package/lib/typescript/networks/solana.d.ts.map +1 -1
- 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/types/blockchain/transaction.d.ts +63 -0
- 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/PresetsUtil.d.ts +0 -5
- 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 +10 -19
- package/src/adapters/BitcoinBaseAdapter.ts +5 -0
- package/src/adapters/BlockchainAdapter.ts +48 -21
- package/src/adapters/EvmAdapter.ts +186 -18
- package/src/adapters/SolanaBaseAdapter.ts +3 -1
- package/src/adapters/__tests__/EvmAdapter.test.ts +126 -0
- package/src/index.ts +3 -1
- package/src/networks/bitcoin.ts +1 -1
- package/src/networks/solana.ts +1 -1
- 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/types/blockchain/transaction.ts +71 -0
- 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/ErrorUtil.ts +2 -2
- package/src/utils/NetworkUtil.ts +5 -0
- package/src/utils/PresetsUtil.ts +0 -25
- package/src/utils/StringUtil.ts +7 -0
- package/lib/commonjs/utils/TypeUtil.js.map +0 -1
- package/lib/module/utils/TypeUtil.js.map +0 -1
- package/lib/typescript/utils/TypeUtil.d.ts +0 -276
- package/lib/typescript/utils/TypeUtil.d.ts.map +0 -1
- package/src/utils/TypeUtil.ts +0 -336
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../../../src/types/wallet/connector.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/wallet/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CaipNetworkId } from '../common';
|
|
2
|
+
export interface WalletInfo {
|
|
3
|
+
name?: string;
|
|
4
|
+
icon?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
icons?: string[];
|
|
8
|
+
redirect?: {
|
|
9
|
+
native?: string;
|
|
10
|
+
universal?: string;
|
|
11
|
+
linkMode?: boolean;
|
|
12
|
+
};
|
|
13
|
+
type?: 'walletconnect' | 'external' | 'unknown';
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
export type Metadata = {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
url: string;
|
|
20
|
+
icons: string[];
|
|
21
|
+
redirect?: {
|
|
22
|
+
native?: string;
|
|
23
|
+
universal?: string;
|
|
24
|
+
linkMode?: boolean;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export interface Token {
|
|
28
|
+
address: string;
|
|
29
|
+
image?: string;
|
|
30
|
+
}
|
|
31
|
+
export type Tokens = Record<CaipNetworkId, Token>;
|
|
32
|
+
export interface Identity {
|
|
33
|
+
name: string;
|
|
34
|
+
avatar?: string;
|
|
35
|
+
}
|
|
36
|
+
export type ConnectedWalletInfo = WalletInfo | undefined;
|
|
37
|
+
//# sourceMappingURL=wallet-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-info.d.ts","sourceRoot":"","sources":["../../../../src/types/wallet/wallet-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE;QACT,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;IACF,IAAI,CAAC,EAAE,eAAe,GAAG,UAAU,GAAG,SAAS,CAAC;IAChD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE;QACT,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;CACH,CAAC;AAEF,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAElD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,SAAS,CAAC"}
|
|
@@ -8,10 +8,49 @@ 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
|
+
CHAIN_NAME_MAP: {
|
|
16
|
+
eip155: string;
|
|
17
|
+
solana: string;
|
|
18
|
+
polkadot: string;
|
|
19
|
+
bip122: string;
|
|
20
|
+
cosmos: string;
|
|
21
|
+
sui: string;
|
|
22
|
+
stacks: string;
|
|
23
|
+
};
|
|
15
24
|
USDT_CONTRACT_ADDRESSES: string[];
|
|
25
|
+
PHANTOM_CUSTOM_WALLET: {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
image_id: string;
|
|
29
|
+
mobile_link: string;
|
|
30
|
+
play_store: string;
|
|
31
|
+
app_store: string;
|
|
32
|
+
android_app_id: string;
|
|
33
|
+
ios_schema: string;
|
|
34
|
+
};
|
|
35
|
+
COINBASE_CUSTOM_WALLET: {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
image_id: string;
|
|
39
|
+
mobile_link: string;
|
|
40
|
+
play_store: string;
|
|
41
|
+
app_store: string;
|
|
42
|
+
android_app_id: string;
|
|
43
|
+
ios_schema: string;
|
|
44
|
+
};
|
|
45
|
+
SOLFLARE_CUSTOM_WALLET: {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
image_id: string;
|
|
49
|
+
mobile_link: string;
|
|
50
|
+
play_store: string;
|
|
51
|
+
app_store: string;
|
|
52
|
+
android_app_id: string;
|
|
53
|
+
ios_schema: string;
|
|
54
|
+
};
|
|
16
55
|
};
|
|
17
56
|
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6EzB,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,10 +1,5 @@
|
|
|
1
|
-
import type { ConnectorType } from './TypeUtil';
|
|
2
1
|
export declare const PresetsUtil: {
|
|
3
|
-
ConnectorExplorerIds: Record<string, string>;
|
|
4
2
|
NetworkImageIds: Record<string, string>;
|
|
5
|
-
ConnectorNamesMap: Record<string, string>;
|
|
6
|
-
ConnectorImageIds: Record<string, string>;
|
|
7
|
-
ConnectorTypesMap: Record<string, ConnectorType>;
|
|
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": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
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"
|
|
@@ -28,30 +33,16 @@
|
|
|
28
33
|
"react-native"
|
|
29
34
|
],
|
|
30
35
|
"repository": "https://github.com/reown-com/appkit-react-native",
|
|
31
|
-
"author": "Reown
|
|
36
|
+
"author": "Reown (https://discord.gg/reown)",
|
|
32
37
|
"homepage": "https://reown.com/appkit",
|
|
33
|
-
"license": "
|
|
38
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
34
39
|
"bugs": {
|
|
35
40
|
"url": "https://github.com/reown-com/appkit-react-native/issues"
|
|
36
41
|
},
|
|
37
42
|
"publishConfig": {
|
|
38
43
|
"registry": "https://registry.npmjs.org/",
|
|
39
|
-
"access": "public"
|
|
40
|
-
|
|
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
|
-
]
|
|
44
|
+
"access": "public",
|
|
45
|
+
"provenance": true
|
|
55
46
|
},
|
|
56
47
|
"eslintIgnore": [
|
|
57
48
|
"node_modules/",
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import type {
|
|
3
3
|
AdapterEvents,
|
|
4
|
+
AdapterType,
|
|
4
5
|
AppKitNetwork,
|
|
6
|
+
BlockchainAdapterConfig,
|
|
7
|
+
BlockchainAdapterInitParams,
|
|
5
8
|
CaipAddress,
|
|
6
9
|
ChainNamespace,
|
|
7
10
|
GetBalanceParams,
|
|
8
11
|
GetBalanceResponse,
|
|
9
12
|
Provider,
|
|
10
13
|
WalletConnector
|
|
11
|
-
} from '../
|
|
14
|
+
} from '../types';
|
|
15
|
+
import { NetworkUtil } from '../utils/NetworkUtil';
|
|
12
16
|
|
|
13
17
|
export abstract class BlockchainAdapter extends EventEmitter {
|
|
14
|
-
public projectId: string;
|
|
15
18
|
public connector?: WalletConnector;
|
|
16
19
|
public supportedNamespace: ChainNamespace;
|
|
20
|
+
public adapterType: AdapterType;
|
|
17
21
|
|
|
18
22
|
// Typed emit method
|
|
19
23
|
override emit<K extends keyof AdapterEvents>(
|
|
@@ -23,20 +27,25 @@ export abstract class BlockchainAdapter extends EventEmitter {
|
|
|
23
27
|
return super.emit(event, payload);
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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) {
|
|
33
41
|
super();
|
|
34
|
-
this.projectId = projectId;
|
|
35
42
|
this.supportedNamespace = supportedNamespace;
|
|
43
|
+
this.adapterType = adapterType;
|
|
36
44
|
}
|
|
37
45
|
|
|
38
|
-
|
|
46
|
+
init({ connector }: BlockchainAdapterInitParams) {
|
|
39
47
|
this.connector = connector;
|
|
48
|
+
|
|
40
49
|
this.subscribeToEvents();
|
|
41
50
|
}
|
|
42
51
|
|
|
@@ -47,7 +56,7 @@ export abstract class BlockchainAdapter extends EventEmitter {
|
|
|
47
56
|
getProvider(): Provider {
|
|
48
57
|
if (!this.connector) throw new Error('No active connector');
|
|
49
58
|
|
|
50
|
-
return this.connector.getProvider();
|
|
59
|
+
return this.connector.getProvider(this.getSupportedNamespace());
|
|
51
60
|
}
|
|
52
61
|
|
|
53
62
|
subscribeToEvents(): void {
|
|
@@ -70,19 +79,37 @@ export abstract class BlockchainAdapter extends EventEmitter {
|
|
|
70
79
|
|
|
71
80
|
onAccountsChanged(accounts: string[]): void {
|
|
72
81
|
const _accounts = this.getAccounts();
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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 });
|
|
81
108
|
}
|
|
82
109
|
}
|
|
83
110
|
|
|
84
111
|
onDisconnect(): void {
|
|
85
|
-
this.emit('disconnect',
|
|
112
|
+
this.emit('disconnect', undefined);
|
|
86
113
|
|
|
87
114
|
const provider = this.connector?.getProvider();
|
|
88
115
|
if (provider) {
|
|
@@ -1,7 +1,93 @@
|
|
|
1
1
|
import { BlockchainAdapter } from './BlockchainAdapter';
|
|
2
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
|
+
}
|
|
3
72
|
|
|
4
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
|
+
}
|
|
5
91
|
async estimateGas({ address, to, data, chainNamespace }: any): Promise<bigint> {
|
|
6
92
|
const provider = this.getProvider();
|
|
7
93
|
|
|
@@ -36,8 +122,8 @@ export abstract class EVMAdapter extends BlockchainAdapter {
|
|
|
36
122
|
}
|
|
37
123
|
}
|
|
38
124
|
|
|
39
|
-
async sendTransaction(data:
|
|
40
|
-
const { address } = data || {};
|
|
125
|
+
async sendTransaction(data: SendTransactionData): Promise<`0x${string}` | null> {
|
|
126
|
+
const { address, network } = data || {};
|
|
41
127
|
|
|
42
128
|
if (!this.getProvider()) {
|
|
43
129
|
throw new Error('EVMAdapter:sendTransaction - provider is undefined');
|
|
@@ -47,33 +133,115 @@ export abstract class EVMAdapter extends BlockchainAdapter {
|
|
|
47
133
|
throw new Error('EVMAdapter:sendTransaction - address is undefined');
|
|
48
134
|
}
|
|
49
135
|
|
|
136
|
+
if (!network) {
|
|
137
|
+
throw new Error('EVMAdapter:sendTransaction - network is undefined');
|
|
138
|
+
}
|
|
139
|
+
|
|
50
140
|
const txParams = {
|
|
51
141
|
from: address,
|
|
52
142
|
to: data.to,
|
|
53
143
|
value: NumberUtil.convertNumericToHexString(data.value),
|
|
54
|
-
gas: NumberUtil.convertNumericToHexString(data.gas),
|
|
55
|
-
gasPrice: NumberUtil.convertNumericToHexString(data.gasPrice),
|
|
56
144
|
data: data.data, // hex-encoded bytecode
|
|
57
145
|
type: '0x0' // optional: legacy transaction type
|
|
58
146
|
};
|
|
59
147
|
|
|
60
|
-
const txHash = await this.getProvider().request(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
+
}
|
|
64
158
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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;
|
|
71
169
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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');
|
|
75
193
|
}
|
|
76
194
|
|
|
77
|
-
|
|
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
|
+
}
|
|
78
246
|
}
|
|
79
247
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { BlockchainAdapter } from './BlockchainAdapter';
|
|
2
2
|
|
|
3
3
|
export abstract class SolanaBaseAdapter extends BlockchainAdapter {
|
|
4
|
-
|
|
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>;
|
|
5
7
|
}
|