@reown/appkit-common-react-native 2.0.0-alpha.1 → 2.0.0-alpha.3
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 +28 -13
- 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 +4 -4
- 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 +2 -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/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 +34 -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/BlockchainAdapter.js +30 -13
- 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 +3 -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 +2 -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/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 +36 -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/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 +2 -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 +1 -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 +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 +45 -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/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 +57 -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 +30 -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 +7 -17
- package/src/adapters/BlockchainAdapter.ts +38 -21
- package/src/adapters/EvmAdapter.ts +186 -18
- package/src/adapters/SolanaBaseAdapter.ts +2 -1
- package/src/adapters/__tests__/EvmAdapter.test.ts +126 -0
- package/src/index.ts +2 -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 +394 -0
- package/src/types/api/index.ts +4 -0
- package/src/types/api/wallet-api.ts +64 -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/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 +84 -0
- package/src/types/wallet/index.ts +4 -0
- package/src/types/wallet/wallet-info.ts +41 -0
- package/src/utils/ConstantsUtil.ts +36 -8
- 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
package/src/utils/TypeUtil.ts
DELETED
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
|
|
3
|
-
export type CaipAddress = `${string}:${string}:${string}`;
|
|
4
|
-
|
|
5
|
-
export type CaipNetworkId = `${string}:${string}`;
|
|
6
|
-
|
|
7
|
-
export type ChainNamespace = 'eip155' | 'solana' | 'polkadot' | 'bip122';
|
|
8
|
-
|
|
9
|
-
export type Network = {
|
|
10
|
-
// Core viem/chain properties
|
|
11
|
-
id: number | string;
|
|
12
|
-
name: string;
|
|
13
|
-
nativeCurrency: { name: string; symbol: string; decimals: number };
|
|
14
|
-
rpcUrls: {
|
|
15
|
-
default: { http: readonly string[] };
|
|
16
|
-
[key: string]: { http: readonly string[] } | undefined;
|
|
17
|
-
};
|
|
18
|
-
blockExplorers?: {
|
|
19
|
-
default: { name: string; url: string };
|
|
20
|
-
[key: string]: { name: string; url: string } | undefined;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// AppKit specific / CAIP properties (Optional in type, but needed in practice)
|
|
24
|
-
chainNamespace?: ChainNamespace; // e.g., 'eip155'
|
|
25
|
-
caipNetworkId?: CaipNetworkId; // e.g., 'eip155:1'
|
|
26
|
-
testnet?: boolean;
|
|
27
|
-
deprecatedCaipNetworkId?: CaipNetworkId; // for Solana deprecated id
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export type AppKitNetwork = Network & {
|
|
31
|
-
chainNamespace: ChainNamespace; // e.g., 'eip155'
|
|
32
|
-
caipNetworkId: CaipNetworkId; // e.g., 'eip155:1'
|
|
33
|
-
testnet?: boolean;
|
|
34
|
-
deprecatedCaipNetworkId?: CaipNetworkId; // for Solana deprecated id
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export interface CaipNetwork {
|
|
38
|
-
id: CaipNetworkId;
|
|
39
|
-
name?: string;
|
|
40
|
-
imageId?: string;
|
|
41
|
-
imageUrl?: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface Balance {
|
|
45
|
-
name: string;
|
|
46
|
-
symbol: string;
|
|
47
|
-
chainId: string;
|
|
48
|
-
address?: CaipAddress;
|
|
49
|
-
value?: number;
|
|
50
|
-
price: number;
|
|
51
|
-
quantity: BalanceQuantity;
|
|
52
|
-
iconUrl: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
type BalanceQuantity = {
|
|
56
|
-
decimals: string;
|
|
57
|
-
numeric: string;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export type TransactionStatus = 'confirmed' | 'failed' | 'pending';
|
|
61
|
-
export type TransactionDirection = 'in' | 'out' | 'self';
|
|
62
|
-
export type TransactionImage = {
|
|
63
|
-
type: 'FUNGIBLE' | 'NFT' | undefined;
|
|
64
|
-
url: string | undefined;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export interface Transaction {
|
|
68
|
-
id: string;
|
|
69
|
-
metadata: TransactionMetadata;
|
|
70
|
-
transfers: TransactionTransfer[];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface TransactionMetadata {
|
|
74
|
-
application: {
|
|
75
|
-
iconUrl: string | null;
|
|
76
|
-
name: string | null;
|
|
77
|
-
};
|
|
78
|
-
operationType: string;
|
|
79
|
-
hash: string;
|
|
80
|
-
minedAt: string;
|
|
81
|
-
sentFrom: string;
|
|
82
|
-
sentTo: string;
|
|
83
|
-
status: TransactionStatus;
|
|
84
|
-
nonce: number;
|
|
85
|
-
chain?: string;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface TransactionTransfer {
|
|
89
|
-
fungible_info?: {
|
|
90
|
-
name?: string;
|
|
91
|
-
symbol?: string;
|
|
92
|
-
icon?: {
|
|
93
|
-
url: string;
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
nft_info?: TransactionNftInfo;
|
|
97
|
-
direction: TransactionDirection;
|
|
98
|
-
quantity: TransactionQuantity;
|
|
99
|
-
value?: number;
|
|
100
|
-
price?: number;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export interface TransactionNftInfo {
|
|
104
|
-
name?: string;
|
|
105
|
-
content?: TransactionContent;
|
|
106
|
-
flags: TransactionNftInfoFlags;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export interface TransactionNftInfoFlags {
|
|
110
|
-
is_spam: boolean;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface TransactionContent {
|
|
114
|
-
preview?: TransactionPreview;
|
|
115
|
-
detail?: TransactionDetail;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export interface TransactionPreview {
|
|
119
|
-
url: string;
|
|
120
|
-
content_type?: null;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export interface TransactionDetail {
|
|
124
|
-
url: string;
|
|
125
|
-
content_type?: null;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export interface TransactionQuantity {
|
|
129
|
-
numeric: string;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export type SocialProvider = 'apple' | 'x' | 'discord' | 'farcaster';
|
|
133
|
-
|
|
134
|
-
export type ThemeMode = 'dark' | 'light';
|
|
135
|
-
|
|
136
|
-
export interface ThemeVariables {
|
|
137
|
-
accent?: string;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export interface Token {
|
|
141
|
-
address: string;
|
|
142
|
-
image?: string;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export type Tokens = Record<CaipNetworkId, Token>;
|
|
146
|
-
|
|
147
|
-
export type ConnectorType = 'WALLET_CONNECT' | 'COINBASE' | 'AUTH' | 'EXTERNAL';
|
|
148
|
-
|
|
149
|
-
export type Metadata = {
|
|
150
|
-
name: string;
|
|
151
|
-
description: string;
|
|
152
|
-
url: string;
|
|
153
|
-
icons: string[];
|
|
154
|
-
redirect?: {
|
|
155
|
-
native?: string;
|
|
156
|
-
universal?: string;
|
|
157
|
-
linkMode?: boolean;
|
|
158
|
-
};
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
//********** Adapter Event Payloads **********//
|
|
162
|
-
export type AccountsChangedEvent = {
|
|
163
|
-
accounts: string[];
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
export type ChainChangedEvent = {
|
|
167
|
-
chainId: string;
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
export type DisconnectEvent = {};
|
|
171
|
-
|
|
172
|
-
export type BalanceChangedEvent = {
|
|
173
|
-
address: CaipAddress;
|
|
174
|
-
balance: {
|
|
175
|
-
amount: string;
|
|
176
|
-
symbol: string;
|
|
177
|
-
contractAddress?: ContractAddress;
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
//********** Adapter Event Map **********//
|
|
182
|
-
export interface AdapterEvents {
|
|
183
|
-
accountsChanged: (event: AccountsChangedEvent) => void;
|
|
184
|
-
chainChanged: (event: ChainChangedEvent) => void;
|
|
185
|
-
disconnect: (event: DisconnectEvent) => void;
|
|
186
|
-
balanceChanged: (event: BalanceChangedEvent) => void;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export interface GetBalanceParams {
|
|
190
|
-
address?: CaipAddress;
|
|
191
|
-
network?: AppKitNetwork;
|
|
192
|
-
tokens?: Tokens;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
type ContractAddress = CaipAddress;
|
|
196
|
-
|
|
197
|
-
export interface GetBalanceResponse {
|
|
198
|
-
amount: string;
|
|
199
|
-
symbol: string;
|
|
200
|
-
contractAddress?: ContractAddress;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
//********** Connector Types **********//
|
|
204
|
-
interface BaseNamespace {
|
|
205
|
-
chains?: CaipNetworkId[];
|
|
206
|
-
accounts: CaipAddress[];
|
|
207
|
-
methods: string[];
|
|
208
|
-
events: string[];
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
type Namespace = BaseNamespace;
|
|
212
|
-
|
|
213
|
-
export type Namespaces = Record<string, Namespace>;
|
|
214
|
-
|
|
215
|
-
export type ProposalNamespaces = Record<
|
|
216
|
-
string,
|
|
217
|
-
Omit<Namespace, 'accounts'> &
|
|
218
|
-
Required<Pick<Namespace, 'chains'>> & { rpcMap: Record<string, string> }
|
|
219
|
-
>;
|
|
220
|
-
|
|
221
|
-
export type ConnectOptions = {
|
|
222
|
-
namespaces?: ProposalNamespaces;
|
|
223
|
-
defaultChain?: CaipNetworkId;
|
|
224
|
-
universalLink?: string;
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
export type ConnectorInitOptions = {
|
|
228
|
-
storage: Storage;
|
|
229
|
-
metadata: Metadata;
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
export abstract class WalletConnector extends EventEmitter {
|
|
233
|
-
public type: New_ConnectorType;
|
|
234
|
-
protected provider?: Provider;
|
|
235
|
-
protected namespaces?: Namespaces;
|
|
236
|
-
protected wallet?: WalletInfo;
|
|
237
|
-
protected storage?: Storage;
|
|
238
|
-
protected metadata?: Metadata;
|
|
239
|
-
|
|
240
|
-
constructor({ type }: { type: New_ConnectorType }) {
|
|
241
|
-
super();
|
|
242
|
-
this.type = type;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
public async init(ops: ConnectorInitOptions) {
|
|
246
|
-
this.storage = ops.storage;
|
|
247
|
-
this.metadata = ops.metadata;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
public setProvider(provider: Provider) {
|
|
251
|
-
this.provider = provider;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
abstract connect(opts: ConnectOptions): Promise<Namespaces | undefined>;
|
|
255
|
-
abstract disconnect(): Promise<void>;
|
|
256
|
-
abstract getProvider(): Provider;
|
|
257
|
-
abstract getNamespaces(): Namespaces;
|
|
258
|
-
abstract getChainId(namespace: ChainNamespace): CaipNetworkId | undefined;
|
|
259
|
-
abstract getWalletInfo(): WalletInfo | undefined;
|
|
260
|
-
abstract switchNetwork(network: AppKitNetwork): Promise<void>;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
//********** Provider Types **********//
|
|
264
|
-
|
|
265
|
-
export interface Provider {
|
|
266
|
-
connect<T>(params?: any): Promise<T>;
|
|
267
|
-
disconnect(): Promise<void>;
|
|
268
|
-
request<T = unknown>(
|
|
269
|
-
args: RequestArguments,
|
|
270
|
-
chain?: string | undefined,
|
|
271
|
-
expiry?: number | undefined
|
|
272
|
-
): Promise<T>;
|
|
273
|
-
on(event: string, listener: (args?: any) => void): any;
|
|
274
|
-
off(event: string, listener: (args?: any) => void): any;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
export interface RequestArguments {
|
|
278
|
-
method: string;
|
|
279
|
-
params?: unknown[] | Record<string, unknown> | object | undefined;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
//TODO: rename this and remove the old one ConnectorType
|
|
283
|
-
export type New_ConnectorType = 'walletconnect' | 'coinbase' | 'auth' | 'phantom';
|
|
284
|
-
|
|
285
|
-
//********** Others **********//
|
|
286
|
-
|
|
287
|
-
export interface ConnectionResponse {
|
|
288
|
-
accounts: string[];
|
|
289
|
-
chainId: string;
|
|
290
|
-
[key: string]: any;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
export interface WalletInfo {
|
|
294
|
-
name?: string;
|
|
295
|
-
icon?: string;
|
|
296
|
-
description?: string;
|
|
297
|
-
url?: string;
|
|
298
|
-
icons?: string[];
|
|
299
|
-
redirect?: {
|
|
300
|
-
native?: string;
|
|
301
|
-
universal?: string;
|
|
302
|
-
linkMode?: boolean;
|
|
303
|
-
};
|
|
304
|
-
[key: string]: unknown;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
export interface Storage {
|
|
308
|
-
/**
|
|
309
|
-
* Returns all keys in storage.
|
|
310
|
-
*/
|
|
311
|
-
getKeys(): Promise<string[]>;
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Returns all key-value entries in storage.
|
|
315
|
-
*/
|
|
316
|
-
getEntries<T = any>(): Promise<[string, T][]>;
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Get an item from storage for a given key.
|
|
320
|
-
* @param key The key to retrieve.
|
|
321
|
-
*/
|
|
322
|
-
getItem<T = any>(key: string): Promise<T | undefined>;
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Set an item in storage for a given key.
|
|
326
|
-
* @param key The key to set.
|
|
327
|
-
* @param value The value to set.
|
|
328
|
-
*/
|
|
329
|
-
setItem<T = any>(key: string, value: T): Promise<void>;
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Remove an item from storage for a given key.
|
|
333
|
-
* @param key The key to remove.
|
|
334
|
-
*/
|
|
335
|
-
removeItem(key: string): Promise<void>;
|
|
336
|
-
}
|