@reown/appkit-common-react-native 0.0.0-feat-onramp-20250602154313 → 0.0.0-feat-multichain-20250604171123
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 +79 -0
- package/lib/commonjs/adapters/BlockchainAdapter.js.map +1 -0
- package/lib/commonjs/adapters/EvmAdapter.js +83 -0
- package/lib/commonjs/adapters/EvmAdapter.js.map +1 -0
- package/lib/commonjs/adapters/SolanaBaseAdapter.js +12 -0
- package/lib/commonjs/adapters/SolanaBaseAdapter.js.map +1 -0
- package/lib/commonjs/index.js +25 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/ConstantsUtil.js +1 -1
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/commonjs/utils/NumberUtil.js +52 -11
- package/lib/commonjs/utils/NumberUtil.js.map +1 -1
- package/lib/commonjs/utils/PresetsUtil.js +34 -3
- package/lib/commonjs/utils/PresetsUtil.js.map +1 -1
- package/lib/commonjs/utils/TypeUtil.js +29 -0
- package/lib/commonjs/utils/TypeUtil.js.map +1 -1
- package/lib/module/adapters/BlockchainAdapter.js +72 -0
- package/lib/module/adapters/BlockchainAdapter.js.map +1 -0
- package/lib/module/adapters/EvmAdapter.js +76 -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/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/ConstantsUtil.js +1 -1
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/utils/NumberUtil.js +52 -11
- package/lib/module/utils/NumberUtil.js.map +1 -1
- package/lib/module/utils/PresetsUtil.js +34 -3
- package/lib/module/utils/PresetsUtil.js.map +1 -1
- package/lib/module/utils/TypeUtil.js +23 -0
- package/lib/module/utils/TypeUtil.js.map +1 -1
- package/lib/typescript/adapters/BlockchainAdapter.d.ts +27 -0
- package/lib/typescript/adapters/BlockchainAdapter.d.ts.map +1 -0
- package/lib/typescript/adapters/EvmAdapter.d.ts +6 -0
- package/lib/typescript/adapters/EvmAdapter.d.ts.map +1 -0
- package/lib/typescript/adapters/SolanaBaseAdapter.d.ts +4 -0
- package/lib/typescript/adapters/SolanaBaseAdapter.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/index.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 -1
- package/lib/typescript/utils/PresetsUtil.d.ts.map +1 -1
- package/lib/typescript/utils/TypeUtil.d.ts +147 -1
- package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/adapters/BlockchainAdapter.ts +109 -0
- package/src/adapters/EvmAdapter.ts +79 -0
- package/src/adapters/SolanaBaseAdapter.ts +5 -0
- package/src/index.ts +3 -0
- package/src/utils/ConstantsUtil.ts +1 -1
- package/src/utils/NumberUtil.ts +54 -11
- package/src/utils/PresetsUtil.ts +36 -3
- package/src/utils/TypeUtil.ts +181 -1
package/src/utils/TypeUtil.ts
CHANGED
|
@@ -1,8 +1,51 @@
|
|
|
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
|
+
|
|
1
44
|
export interface Balance {
|
|
2
45
|
name: string;
|
|
3
46
|
symbol: string;
|
|
4
47
|
chainId: string;
|
|
5
|
-
address?:
|
|
48
|
+
address?: CaipAddress;
|
|
6
49
|
value?: number;
|
|
7
50
|
price: number;
|
|
8
51
|
quantity: BalanceQuantity;
|
|
@@ -94,4 +137,141 @@ export interface ThemeVariables {
|
|
|
94
137
|
accent?: string;
|
|
95
138
|
}
|
|
96
139
|
|
|
140
|
+
export interface Token {
|
|
141
|
+
address: string;
|
|
142
|
+
image?: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export type Tokens = Record<CaipNetworkId, Token>;
|
|
146
|
+
|
|
97
147
|
export type ConnectorType = 'WALLET_CONNECT' | 'COINBASE' | 'AUTH' | 'EXTERNAL';
|
|
148
|
+
|
|
149
|
+
//********** Adapter Event Payloads **********//
|
|
150
|
+
export type AccountsChangedEvent = {
|
|
151
|
+
accounts: string[];
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export type ChainChangedEvent = {
|
|
155
|
+
chainId: string;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export type DisconnectEvent = {};
|
|
159
|
+
|
|
160
|
+
export type BalanceChangedEvent = {
|
|
161
|
+
address: CaipAddress;
|
|
162
|
+
balance: {
|
|
163
|
+
amount: string;
|
|
164
|
+
symbol: string;
|
|
165
|
+
contractAddress?: ContractAddress;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
//********** Adapter Event Map **********//
|
|
170
|
+
export interface AdapterEvents {
|
|
171
|
+
accountsChanged: (event: AccountsChangedEvent) => void;
|
|
172
|
+
chainChanged: (event: ChainChangedEvent) => void;
|
|
173
|
+
disconnect: (event: DisconnectEvent) => void;
|
|
174
|
+
balanceChanged: (event: BalanceChangedEvent) => void;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface GetBalanceParams {
|
|
178
|
+
address?: CaipAddress;
|
|
179
|
+
network?: AppKitNetwork;
|
|
180
|
+
tokens?: Tokens;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
type ContractAddress = CaipAddress;
|
|
184
|
+
|
|
185
|
+
export interface GetBalanceResponse {
|
|
186
|
+
amount: string;
|
|
187
|
+
symbol: string;
|
|
188
|
+
contractAddress?: ContractAddress;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
//********** Connector Types **********//
|
|
192
|
+
interface BaseNamespace {
|
|
193
|
+
chains?: CaipNetworkId[];
|
|
194
|
+
accounts: CaipAddress[];
|
|
195
|
+
methods: string[];
|
|
196
|
+
events: string[];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
type Namespace = BaseNamespace;
|
|
200
|
+
|
|
201
|
+
export type Namespaces = Record<string, Namespace>;
|
|
202
|
+
|
|
203
|
+
export type ProposalNamespaces = Record<
|
|
204
|
+
string,
|
|
205
|
+
Omit<Namespace, 'accounts'> & Required<Pick<Namespace, 'chains'>>
|
|
206
|
+
>;
|
|
207
|
+
|
|
208
|
+
export type ConnectOptions = {
|
|
209
|
+
namespaces?: ProposalNamespaces;
|
|
210
|
+
defaultChain?: CaipNetworkId;
|
|
211
|
+
universalLink?: string;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export abstract class WalletConnector extends EventEmitter {
|
|
215
|
+
public type: New_ConnectorType;
|
|
216
|
+
protected provider: Provider;
|
|
217
|
+
protected namespaces?: Namespaces;
|
|
218
|
+
protected wallet?: WalletInfo;
|
|
219
|
+
|
|
220
|
+
constructor({ type, provider }: { type: New_ConnectorType; provider: Provider }) {
|
|
221
|
+
super();
|
|
222
|
+
this.type = type;
|
|
223
|
+
this.provider = provider;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
abstract connect(opts: ConnectOptions): Promise<Namespaces | undefined>;
|
|
227
|
+
abstract disconnect(): Promise<void>;
|
|
228
|
+
abstract getProvider(): Provider;
|
|
229
|
+
abstract getNamespaces(): Namespaces;
|
|
230
|
+
abstract getChainId(namespace: ChainNamespace): CaipNetworkId | undefined;
|
|
231
|
+
abstract getWalletInfo(): WalletInfo | undefined;
|
|
232
|
+
abstract switchNetwork(network: AppKitNetwork): Promise<void>;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
//********** Provider Types **********//
|
|
236
|
+
|
|
237
|
+
export interface Provider {
|
|
238
|
+
connect<T>(params?: any): Promise<T>;
|
|
239
|
+
disconnect(): Promise<void>;
|
|
240
|
+
request<T = unknown>(
|
|
241
|
+
args: RequestArguments,
|
|
242
|
+
chain?: string | undefined,
|
|
243
|
+
expiry?: number | undefined
|
|
244
|
+
): Promise<T>;
|
|
245
|
+
on(event: string, listener: (args?: any) => void): any;
|
|
246
|
+
off(event: string, listener: (args?: any) => void): any;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface RequestArguments {
|
|
250
|
+
method: string;
|
|
251
|
+
params?: unknown[] | Record<string, unknown> | object | undefined;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
//TODO: rename this and remove the old one ConnectorType
|
|
255
|
+
export type New_ConnectorType = 'walletconnect' | 'coinbase' | 'auth';
|
|
256
|
+
|
|
257
|
+
//********** Others **********//
|
|
258
|
+
|
|
259
|
+
export interface ConnectionResponse {
|
|
260
|
+
accounts: string[];
|
|
261
|
+
chainId: string;
|
|
262
|
+
[key: string]: any;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface WalletInfo {
|
|
266
|
+
name?: string;
|
|
267
|
+
icon?: string;
|
|
268
|
+
description?: string;
|
|
269
|
+
url?: string;
|
|
270
|
+
icons?: string[];
|
|
271
|
+
redirect?: {
|
|
272
|
+
native?: string;
|
|
273
|
+
universal?: string;
|
|
274
|
+
linkMode?: boolean;
|
|
275
|
+
};
|
|
276
|
+
[key: string]: unknown;
|
|
277
|
+
}
|