@reown/appkit-common-react-native 0.0.0-feat-multi-siwe-20250623145640 → 0.0.0-feat-onramp-20250625192635
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/index.js +1 -62
- 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 +11 -52
- package/lib/commonjs/utils/NumberUtil.js.map +1 -1
- package/lib/commonjs/utils/PresetsUtil.js +3 -34
- package/lib/commonjs/utils/PresetsUtil.js.map +1 -1
- package/lib/commonjs/utils/TypeUtil.js +0 -38
- package/lib/commonjs/utils/TypeUtil.js.map +1 -1
- package/lib/module/index.js +0 -5
- 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 +11 -52
- package/lib/module/utils/NumberUtil.js.map +1 -1
- package/lib/module/utils/PresetsUtil.js +3 -34
- package/lib/module/utils/PresetsUtil.js.map +1 -1
- package/lib/module/utils/TypeUtil.js +0 -32
- package/lib/module/utils/TypeUtil.js.map +1 -1
- package/lib/typescript/index.d.ts +0 -5
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/NumberUtil.d.ts +11 -39
- 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 +1 -279
- package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +0 -5
- package/src/utils/ConstantsUtil.ts +1 -1
- package/src/utils/NumberUtil.ts +11 -54
- package/src/utils/PresetsUtil.ts +3 -36
- package/src/utils/TypeUtil.ts +1 -346
- package/lib/commonjs/adapters/BlockchainAdapter.js +0 -79
- package/lib/commonjs/adapters/BlockchainAdapter.js.map +0 -1
- package/lib/commonjs/adapters/EvmAdapter.js +0 -94
- package/lib/commonjs/adapters/EvmAdapter.js.map +0 -1
- package/lib/commonjs/adapters/SolanaBaseAdapter.js +0 -12
- package/lib/commonjs/adapters/SolanaBaseAdapter.js.map +0 -1
- package/lib/commonjs/networks/bitcoin.js +0 -40
- package/lib/commonjs/networks/bitcoin.js.map +0 -1
- package/lib/commonjs/networks/solana.js +0 -78
- package/lib/commonjs/networks/solana.js.map +0 -1
- package/lib/module/adapters/BlockchainAdapter.js +0 -72
- package/lib/module/adapters/BlockchainAdapter.js.map +0 -1
- package/lib/module/adapters/EvmAdapter.js +0 -87
- package/lib/module/adapters/EvmAdapter.js.map +0 -1
- package/lib/module/adapters/SolanaBaseAdapter.js +0 -5
- package/lib/module/adapters/SolanaBaseAdapter.js.map +0 -1
- package/lib/module/networks/bitcoin.js +0 -34
- package/lib/module/networks/bitcoin.js.map +0 -1
- package/lib/module/networks/solana.js +0 -72
- package/lib/module/networks/solana.js.map +0 -1
- package/lib/typescript/adapters/BlockchainAdapter.d.ts +0 -27
- package/lib/typescript/adapters/BlockchainAdapter.d.ts.map +0 -1
- package/lib/typescript/adapters/EvmAdapter.d.ts +0 -7
- package/lib/typescript/adapters/EvmAdapter.d.ts.map +0 -1
- package/lib/typescript/adapters/SolanaBaseAdapter.d.ts +0 -4
- package/lib/typescript/adapters/SolanaBaseAdapter.d.ts.map +0 -1
- package/lib/typescript/networks/bitcoin.d.ts +0 -4
- package/lib/typescript/networks/bitcoin.d.ts.map +0 -1
- package/lib/typescript/networks/solana.d.ts +0 -5
- package/lib/typescript/networks/solana.d.ts.map +0 -1
- package/src/adapters/BlockchainAdapter.ts +0 -109
- package/src/adapters/EvmAdapter.ts +0 -96
- package/src/adapters/SolanaBaseAdapter.ts +0 -5
- package/src/networks/bitcoin.ts +0 -32
- package/src/networks/solana.ts +0 -44
|
@@ -1,34 +1,2 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
1
|
|
|
3
|
-
//********** Adapter Event Payloads **********//
|
|
4
|
-
|
|
5
|
-
//********** Adapter Event Map **********//
|
|
6
|
-
|
|
7
|
-
//********** Connector Types **********//
|
|
8
|
-
|
|
9
|
-
export class WalletConnector extends EventEmitter {
|
|
10
|
-
constructor({
|
|
11
|
-
type
|
|
12
|
-
}) {
|
|
13
|
-
super();
|
|
14
|
-
this.type = type;
|
|
15
|
-
}
|
|
16
|
-
async init(ops) {
|
|
17
|
-
this.storage = ops.storage;
|
|
18
|
-
this.metadata = ops.metadata;
|
|
19
|
-
}
|
|
20
|
-
setProvider(provider) {
|
|
21
|
-
this.provider = provider;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
//********** Provider Types **********//
|
|
26
|
-
|
|
27
|
-
//TODO: rename this and remove the old one ConnectorType
|
|
28
|
-
|
|
29
|
-
//********** Others **********//
|
|
30
|
-
|
|
31
|
-
//********** SIWE Types **********//
|
|
32
|
-
|
|
33
|
-
// Signed Cacao (CAIP-74)
|
|
34
2
|
//# sourceMappingURL=TypeUtil.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["utils/TypeUtil.ts"],"mappings":""}
|
|
@@ -8,10 +8,5 @@ export { PresetsUtil } from './utils/PresetsUtil';
|
|
|
8
8
|
export { StringUtil } from './utils/StringUtil';
|
|
9
9
|
export { ErrorUtil } from './utils/ErrorUtil';
|
|
10
10
|
export { erc20ABI } from './contracts/erc20';
|
|
11
|
-
export { solana, solanaDevnet, solanaTestnet } from './networks/solana';
|
|
12
|
-
export { bitcoin, bitcoinTestnet } from './networks/bitcoin';
|
|
13
|
-
export { BlockchainAdapter } from './adapters/BlockchainAdapter';
|
|
14
|
-
export { EVMAdapter } from './adapters/EvmAdapter';
|
|
15
|
-
export { SolanaBaseAdapter } from './adapters/SolanaBaseAdapter';
|
|
16
11
|
export * from './utils/TypeUtil';
|
|
17
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,55 +1,27 @@
|
|
|
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
|
-
*/
|
|
9
3
|
bigNumber(value: BigNumber.BigNumber.Value): BigNumber.BigNumber;
|
|
10
4
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @param
|
|
14
|
-
* @
|
|
15
|
-
* @returns The product as a BigNumber instance, or BigNumber(0) if either input is undefined.
|
|
5
|
+
* Multiply two numbers represented as strings with BigNumber to handle decimals correctly
|
|
6
|
+
* @param a string
|
|
7
|
+
* @param b string
|
|
8
|
+
* @returns
|
|
16
9
|
*/
|
|
17
10
|
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
|
-
*/
|
|
25
11
|
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
|
-
*/
|
|
32
12
|
nextMultipleOfTen(amount?: number): number;
|
|
33
13
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @param value - The value to format
|
|
36
|
-
* @param decimals -
|
|
37
|
-
* @returns
|
|
14
|
+
* Format the given number or string to human readable numbers with the given number of decimals
|
|
15
|
+
* @param value - The value to format. It could be a number or string. If it's a string, it will be parsed to a float then formatted.
|
|
16
|
+
* @param decimals - number of decimals after dot
|
|
17
|
+
* @returns
|
|
38
18
|
*/
|
|
39
19
|
formatNumberToLocalString(value: string | number | undefined, decimals?: number): string;
|
|
40
20
|
/**
|
|
41
|
-
*
|
|
42
|
-
* @param value - The formatted string to parse
|
|
43
|
-
* @returns
|
|
21
|
+
* Parse a formatted local string back to a number
|
|
22
|
+
* @param value - The formatted string to parse
|
|
23
|
+
* @returns
|
|
44
24
|
*/
|
|
45
25
|
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;
|
|
54
26
|
};
|
|
55
27
|
//# 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;qBACJ,mBAAmB,CAAC,KAAK;IAQ1C;;;;;OAKG;gBACS,mBAAmB,CAAC,KAAK,GAAG,SAAS,KAAK,mBAAmB,CAAC,KAAK,GAAG,SAAS;wBAWvE,MAAM,aAAa,MAAM,SAAS,MAAM;+BAOjC,MAAM;IAMjC;;;;;OAKG;qCAC8B,MAAM,GAAG,MAAM,GAAG,SAAS;IAiB5D;;;;OAIG;oCAC6B,MAAM,GAAG,SAAS;CAQnD,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ConnectorType } from './TypeUtil';
|
|
2
2
|
export declare const PresetsUtil: {
|
|
3
3
|
ConnectorExplorerIds: Record<string, string>;
|
|
4
|
-
|
|
4
|
+
EIP155NetworkImageIds: Record<string, string>;
|
|
5
5
|
ConnectorNamesMap: Record<string, string>;
|
|
6
6
|
ConnectorImageIds: Record<string, string>;
|
|
7
7
|
ConnectorTypesMap: Record<string, ConnectorType>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresetsUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/PresetsUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,eAAO,MAAM,WAAW;;;;;;;
|
|
1
|
+
{"version":3,"file":"PresetsUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/PresetsUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,eAAO,MAAM,WAAW;;;;;;;CAgHvB,CAAC"}
|
|
@@ -1,57 +1,8 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
export type CaipAddress = `${string}:${string}:${string}`;
|
|
4
|
-
export type CaipNetworkId = `${string}:${string}`;
|
|
5
|
-
export type ChainNamespace = 'eip155' | 'solana' | 'polkadot' | 'bip122';
|
|
6
|
-
export type Network = {
|
|
7
|
-
id: number | string;
|
|
8
|
-
name: string;
|
|
9
|
-
nativeCurrency: {
|
|
10
|
-
name: string;
|
|
11
|
-
symbol: string;
|
|
12
|
-
decimals: number;
|
|
13
|
-
};
|
|
14
|
-
rpcUrls: {
|
|
15
|
-
default: {
|
|
16
|
-
http: readonly string[];
|
|
17
|
-
};
|
|
18
|
-
[key: string]: {
|
|
19
|
-
http: readonly string[];
|
|
20
|
-
} | undefined;
|
|
21
|
-
};
|
|
22
|
-
blockExplorers?: {
|
|
23
|
-
default: {
|
|
24
|
-
name: string;
|
|
25
|
-
url: string;
|
|
26
|
-
};
|
|
27
|
-
[key: string]: {
|
|
28
|
-
name: string;
|
|
29
|
-
url: string;
|
|
30
|
-
} | undefined;
|
|
31
|
-
};
|
|
32
|
-
chainNamespace?: ChainNamespace;
|
|
33
|
-
caipNetworkId?: CaipNetworkId;
|
|
34
|
-
testnet?: boolean;
|
|
35
|
-
deprecatedCaipNetworkId?: CaipNetworkId;
|
|
36
|
-
};
|
|
37
|
-
export type AppKitNetwork = Network & {
|
|
38
|
-
chainNamespace: ChainNamespace;
|
|
39
|
-
caipNetworkId: CaipNetworkId;
|
|
40
|
-
testnet?: boolean;
|
|
41
|
-
deprecatedCaipNetworkId?: CaipNetworkId;
|
|
42
|
-
};
|
|
43
|
-
export type AppKitConnectOptions = Pick<ConnectOptions, 'namespaces' | 'defaultChain' | 'universalLink'>;
|
|
44
|
-
export interface CaipNetwork {
|
|
45
|
-
id: CaipNetworkId;
|
|
46
|
-
name?: string;
|
|
47
|
-
imageId?: string;
|
|
48
|
-
imageUrl?: string;
|
|
49
|
-
}
|
|
50
1
|
export interface Balance {
|
|
51
2
|
name: string;
|
|
52
3
|
symbol: string;
|
|
53
4
|
chainId: string;
|
|
54
|
-
address?:
|
|
5
|
+
address?: string;
|
|
55
6
|
value?: number;
|
|
56
7
|
price: number;
|
|
57
8
|
quantity: BalanceQuantity;
|
|
@@ -128,235 +79,6 @@ export type ThemeMode = 'dark' | 'light';
|
|
|
128
79
|
export interface ThemeVariables {
|
|
129
80
|
accent?: string;
|
|
130
81
|
}
|
|
131
|
-
export interface Token {
|
|
132
|
-
address: string;
|
|
133
|
-
image?: string;
|
|
134
|
-
}
|
|
135
|
-
export type Tokens = Record<CaipNetworkId, Token>;
|
|
136
82
|
export type ConnectorType = 'WALLET_CONNECT' | 'COINBASE' | 'AUTH' | 'EXTERNAL';
|
|
137
|
-
export type Metadata = {
|
|
138
|
-
name: string;
|
|
139
|
-
description: string;
|
|
140
|
-
url: string;
|
|
141
|
-
icons: string[];
|
|
142
|
-
redirect?: {
|
|
143
|
-
native?: string;
|
|
144
|
-
universal?: string;
|
|
145
|
-
linkMode?: boolean;
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
export type AccountsChangedEvent = {
|
|
149
|
-
accounts: string[];
|
|
150
|
-
};
|
|
151
|
-
export type ChainChangedEvent = {
|
|
152
|
-
chainId: string;
|
|
153
|
-
};
|
|
154
|
-
export type DisconnectEvent = {};
|
|
155
|
-
export type BalanceChangedEvent = {
|
|
156
|
-
address: CaipAddress;
|
|
157
|
-
balance: {
|
|
158
|
-
amount: string;
|
|
159
|
-
symbol: string;
|
|
160
|
-
contractAddress?: ContractAddress;
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
export interface AdapterEvents {
|
|
164
|
-
accountsChanged: (event: AccountsChangedEvent) => void;
|
|
165
|
-
chainChanged: (event: ChainChangedEvent) => void;
|
|
166
|
-
disconnect: (event: DisconnectEvent) => void;
|
|
167
|
-
balanceChanged: (event: BalanceChangedEvent) => void;
|
|
168
|
-
}
|
|
169
|
-
export interface GetBalanceParams {
|
|
170
|
-
address?: CaipAddress;
|
|
171
|
-
network?: AppKitNetwork;
|
|
172
|
-
tokens?: Tokens;
|
|
173
|
-
}
|
|
174
|
-
type ContractAddress = CaipAddress;
|
|
175
|
-
export interface GetBalanceResponse {
|
|
176
|
-
amount: string;
|
|
177
|
-
symbol: string;
|
|
178
|
-
contractAddress?: ContractAddress;
|
|
179
|
-
}
|
|
180
|
-
interface BaseNamespace {
|
|
181
|
-
chains?: CaipNetworkId[];
|
|
182
|
-
accounts: CaipAddress[];
|
|
183
|
-
methods: string[];
|
|
184
|
-
events: string[];
|
|
185
|
-
}
|
|
186
|
-
type Namespace = BaseNamespace;
|
|
187
|
-
export type Namespaces = Record<string, Namespace>;
|
|
188
|
-
export type ProposalNamespaces = Record<string, Omit<Namespace, 'accounts'> & Required<Pick<Namespace, 'chains'>> & {
|
|
189
|
-
rpcMap: Record<string, string>;
|
|
190
|
-
}>;
|
|
191
|
-
export type ConnectOptions = {
|
|
192
|
-
namespaces?: ProposalNamespaces;
|
|
193
|
-
defaultChain?: CaipNetworkId;
|
|
194
|
-
universalLink?: string;
|
|
195
|
-
siweConfig?: AppKitSIWEClient;
|
|
196
|
-
};
|
|
197
|
-
export type ConnectorInitOptions = {
|
|
198
|
-
storage: Storage;
|
|
199
|
-
metadata: Metadata;
|
|
200
|
-
};
|
|
201
|
-
export declare abstract class WalletConnector extends EventEmitter {
|
|
202
|
-
type: New_ConnectorType;
|
|
203
|
-
protected provider?: Provider;
|
|
204
|
-
protected namespaces?: Namespaces;
|
|
205
|
-
protected wallet?: WalletInfo;
|
|
206
|
-
protected storage?: Storage;
|
|
207
|
-
protected metadata?: Metadata;
|
|
208
|
-
constructor({ type }: {
|
|
209
|
-
type: New_ConnectorType;
|
|
210
|
-
});
|
|
211
|
-
init(ops: ConnectorInitOptions): Promise<void>;
|
|
212
|
-
setProvider(provider: Provider): void;
|
|
213
|
-
abstract connect(opts: ConnectOptions): Promise<Namespaces | undefined>;
|
|
214
|
-
abstract disconnect(): Promise<void>;
|
|
215
|
-
abstract getProvider(): Provider;
|
|
216
|
-
abstract getNamespaces(): Namespaces;
|
|
217
|
-
abstract getChainId(namespace: ChainNamespace): CaipNetworkId | undefined;
|
|
218
|
-
abstract getWalletInfo(): WalletInfo | undefined;
|
|
219
|
-
abstract switchNetwork(network: AppKitNetwork): Promise<void>;
|
|
220
|
-
}
|
|
221
|
-
export interface Provider {
|
|
222
|
-
connect<T>(params?: any): Promise<T>;
|
|
223
|
-
disconnect(): Promise<void>;
|
|
224
|
-
request<T = unknown>(args: RequestArguments, chain?: string | undefined, expiry?: number | undefined): Promise<T>;
|
|
225
|
-
on(event: string, listener: (args?: any) => void): any;
|
|
226
|
-
off(event: string, listener: (args?: any) => void): any;
|
|
227
|
-
}
|
|
228
|
-
export interface RequestArguments {
|
|
229
|
-
method: string;
|
|
230
|
-
params?: unknown[] | Record<string, unknown> | object | undefined;
|
|
231
|
-
}
|
|
232
|
-
export type New_ConnectorType = 'walletconnect' | 'coinbase' | 'auth' | 'phantom';
|
|
233
|
-
export interface ConnectionResponse {
|
|
234
|
-
accounts: string[];
|
|
235
|
-
chainId: string;
|
|
236
|
-
[key: string]: any;
|
|
237
|
-
}
|
|
238
|
-
export interface WalletInfo {
|
|
239
|
-
name?: string;
|
|
240
|
-
icon?: string;
|
|
241
|
-
description?: string;
|
|
242
|
-
url?: string;
|
|
243
|
-
icons?: string[];
|
|
244
|
-
redirect?: {
|
|
245
|
-
native?: string;
|
|
246
|
-
universal?: string;
|
|
247
|
-
linkMode?: boolean;
|
|
248
|
-
};
|
|
249
|
-
[key: string]: unknown;
|
|
250
|
-
}
|
|
251
|
-
export interface Storage {
|
|
252
|
-
/**
|
|
253
|
-
* Returns all keys in storage.
|
|
254
|
-
*/
|
|
255
|
-
getKeys(): Promise<string[]>;
|
|
256
|
-
/**
|
|
257
|
-
* Returns all key-value entries in storage.
|
|
258
|
-
*/
|
|
259
|
-
getEntries<T = any>(): Promise<[string, T][]>;
|
|
260
|
-
/**
|
|
261
|
-
* Get an item from storage for a given key.
|
|
262
|
-
* @param key The key to retrieve.
|
|
263
|
-
*/
|
|
264
|
-
getItem<T = any>(key: string): Promise<T | undefined>;
|
|
265
|
-
/**
|
|
266
|
-
* Set an item in storage for a given key.
|
|
267
|
-
* @param key The key to set.
|
|
268
|
-
* @param value The value to set.
|
|
269
|
-
*/
|
|
270
|
-
setItem<T = any>(key: string, value: T): Promise<void>;
|
|
271
|
-
/**
|
|
272
|
-
* Remove an item from storage for a given key.
|
|
273
|
-
* @param key The key to remove.
|
|
274
|
-
*/
|
|
275
|
-
removeItem(key: string): Promise<void>;
|
|
276
|
-
}
|
|
277
|
-
export interface SIWESession {
|
|
278
|
-
address: string;
|
|
279
|
-
chainId: number;
|
|
280
|
-
}
|
|
281
|
-
interface CacaoHeader {
|
|
282
|
-
t: 'caip122';
|
|
283
|
-
}
|
|
284
|
-
export interface SIWECreateMessageArgs {
|
|
285
|
-
chainId: number;
|
|
286
|
-
domain: string;
|
|
287
|
-
nonce: string;
|
|
288
|
-
uri: string;
|
|
289
|
-
address: string;
|
|
290
|
-
version: '1';
|
|
291
|
-
type?: CacaoHeader['t'];
|
|
292
|
-
nbf?: string;
|
|
293
|
-
exp?: string;
|
|
294
|
-
statement?: string;
|
|
295
|
-
requestId?: string;
|
|
296
|
-
resources?: string[];
|
|
297
|
-
expiry?: number;
|
|
298
|
-
iat?: string;
|
|
299
|
-
}
|
|
300
|
-
export type SIWEMessageArgs = {
|
|
301
|
-
chains: string[];
|
|
302
|
-
methods?: string[];
|
|
303
|
-
} & Omit<SIWECreateMessageArgs, 'address' | 'chainId' | 'nonce' | 'version'>;
|
|
304
|
-
interface CacaoPayload {
|
|
305
|
-
domain: string;
|
|
306
|
-
aud: string;
|
|
307
|
-
nonce: string;
|
|
308
|
-
iss: string;
|
|
309
|
-
version?: string;
|
|
310
|
-
iat?: string;
|
|
311
|
-
nbf?: string;
|
|
312
|
-
exp?: string;
|
|
313
|
-
statement?: string;
|
|
314
|
-
requestId?: string;
|
|
315
|
-
resources?: string[];
|
|
316
|
-
type?: string;
|
|
317
|
-
}
|
|
318
|
-
interface Cacao {
|
|
319
|
-
h: CacaoHeader;
|
|
320
|
-
p: CacaoPayload;
|
|
321
|
-
s: {
|
|
322
|
-
t: 'eip191' | 'eip1271';
|
|
323
|
-
s: string;
|
|
324
|
-
m?: string;
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
export interface SIWEVerifyMessageArgs {
|
|
328
|
-
message: string;
|
|
329
|
-
signature: string;
|
|
330
|
-
cacao?: Cacao;
|
|
331
|
-
}
|
|
332
|
-
export interface SIWEClientMethods {
|
|
333
|
-
getNonce: (address?: string) => Promise<string>;
|
|
334
|
-
createMessage: (args: SIWECreateMessageArgs) => string;
|
|
335
|
-
verifyMessage: (args: SIWEVerifyMessageArgs) => Promise<boolean>;
|
|
336
|
-
getSession: () => Promise<SIWESession | null>;
|
|
337
|
-
signOut: () => Promise<boolean>;
|
|
338
|
-
getMessageParams?: () => Promise<SIWEMessageArgs>;
|
|
339
|
-
onSignIn?: (session?: SIWESession) => void;
|
|
340
|
-
onSignOut?: () => void;
|
|
341
|
-
}
|
|
342
|
-
export interface SIWEConfig extends SIWEClientMethods {
|
|
343
|
-
enabled?: boolean;
|
|
344
|
-
nonceRefetchIntervalMs?: number;
|
|
345
|
-
sessionRefetchIntervalMs?: number;
|
|
346
|
-
signOutOnDisconnect?: boolean;
|
|
347
|
-
signOutOnAccountChange?: boolean;
|
|
348
|
-
signOutOnNetworkChange?: boolean;
|
|
349
|
-
}
|
|
350
|
-
export interface AppKitSIWEClient extends SIWEClientMethods {
|
|
351
|
-
signIn: () => Promise<SIWESession | undefined>;
|
|
352
|
-
options: {
|
|
353
|
-
enabled: boolean;
|
|
354
|
-
nonceRefetchIntervalMs: number;
|
|
355
|
-
sessionRefetchIntervalMs: number;
|
|
356
|
-
signOutOnDisconnect: boolean;
|
|
357
|
-
signOutOnAccountChange: boolean;
|
|
358
|
-
signOutOnNetworkChange: boolean;
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
83
|
export {};
|
|
362
84
|
//# sourceMappingURL=TypeUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeUtil.d.ts","sourceRo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CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,KAAK,EAAE,uBAAuB,CAAC;CAChC;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,GAAG,GAAG,SAAS,GAAG,WAAW,CAAC;AAErE,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAEzC,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -8,9 +8,4 @@ export { PresetsUtil } from './utils/PresetsUtil';
|
|
|
8
8
|
export { StringUtil } from './utils/StringUtil';
|
|
9
9
|
export { ErrorUtil } from './utils/ErrorUtil';
|
|
10
10
|
export { erc20ABI } from './contracts/erc20';
|
|
11
|
-
export { solana, solanaDevnet, solanaTestnet } from './networks/solana';
|
|
12
|
-
export { bitcoin, bitcoinTestnet } from './networks/bitcoin';
|
|
13
|
-
export { BlockchainAdapter } from './adapters/BlockchainAdapter';
|
|
14
|
-
export { EVMAdapter } from './adapters/EvmAdapter';
|
|
15
|
-
export { SolanaBaseAdapter } from './adapters/SolanaBaseAdapter';
|
|
16
11
|
export * from './utils/TypeUtil';
|
package/src/utils/NumberUtil.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import * as BigNumber from 'bignumber.js';
|
|
2
2
|
|
|
3
3
|
export const NumberUtil = {
|
|
4
|
-
/**
|
|
5
|
-
* Creates a BigNumber instance from a given value.
|
|
6
|
-
* If the value is a string, commas are removed before conversion.
|
|
7
|
-
* @param value - The input value (string, number, or BigNumber) to convert to a BigNumber.
|
|
8
|
-
* @returns A BigNumber instance.
|
|
9
|
-
*/
|
|
10
4
|
bigNumber(value: BigNumber.BigNumber.Value) {
|
|
11
5
|
if (typeof value === 'string') {
|
|
12
6
|
return new BigNumber.BigNumber(value.replace(/,/g, ''));
|
|
@@ -16,11 +10,10 @@ export const NumberUtil = {
|
|
|
16
10
|
},
|
|
17
11
|
|
|
18
12
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @param
|
|
22
|
-
* @
|
|
23
|
-
* @returns The product as a BigNumber instance, or BigNumber(0) if either input is undefined.
|
|
13
|
+
* Multiply two numbers represented as strings with BigNumber to handle decimals correctly
|
|
14
|
+
* @param a string
|
|
15
|
+
* @param b string
|
|
16
|
+
* @returns
|
|
24
17
|
*/
|
|
25
18
|
multiply(a: BigNumber.BigNumber.Value | undefined, b: BigNumber.BigNumber.Value | undefined) {
|
|
26
19
|
if (a === undefined || b === undefined) {
|
|
@@ -33,13 +26,6 @@ export const NumberUtil = {
|
|
|
33
26
|
return aBigNumber.multipliedBy(bBigNumber);
|
|
34
27
|
},
|
|
35
28
|
|
|
36
|
-
/**
|
|
37
|
-
* Rounds a number to a specified number of decimal places if its string representation meets a certain length threshold.
|
|
38
|
-
* @param number - The number to potentially round.
|
|
39
|
-
* @param threshold - The minimum string length of the number to trigger rounding.
|
|
40
|
-
* @param fixed - The number of decimal places to round to.
|
|
41
|
-
* @returns The rounded number (as a string if rounded, otherwise the original number) or the original number.
|
|
42
|
-
*/
|
|
43
29
|
roundNumber(number: number, threshold: number, fixed: number) {
|
|
44
30
|
const roundedNumber =
|
|
45
31
|
number.toString().length >= threshold ? Number(number).toFixed(fixed) : number;
|
|
@@ -47,12 +33,6 @@ export const NumberUtil = {
|
|
|
47
33
|
return roundedNumber;
|
|
48
34
|
},
|
|
49
35
|
|
|
50
|
-
/**
|
|
51
|
-
* Calculates the next multiple of ten greater than or equal to the given amount.
|
|
52
|
-
* Defaults to 10 if no amount is provided or if the calculated multiple is less than 10.
|
|
53
|
-
* @param amount - The number for which to find the next multiple of ten. Optional.
|
|
54
|
-
* @returns The next multiple of ten, at least 10.
|
|
55
|
-
*/
|
|
56
36
|
nextMultipleOfTen(amount?: number) {
|
|
57
37
|
if (!amount) return 10;
|
|
58
38
|
|
|
@@ -60,10 +40,10 @@ export const NumberUtil = {
|
|
|
60
40
|
},
|
|
61
41
|
|
|
62
42
|
/**
|
|
63
|
-
*
|
|
64
|
-
* @param value - The value to format
|
|
65
|
-
* @param decimals -
|
|
66
|
-
* @returns
|
|
43
|
+
* Format the given number or string to human readable numbers with the given number of decimals
|
|
44
|
+
* @param value - The value to format. It could be a number or string. If it's a string, it will be parsed to a float then formatted.
|
|
45
|
+
* @param decimals - number of decimals after dot
|
|
46
|
+
* @returns
|
|
67
47
|
*/
|
|
68
48
|
formatNumberToLocalString(value: string | number | undefined, decimals = 2) {
|
|
69
49
|
if (value === undefined) {
|
|
@@ -82,11 +62,10 @@ export const NumberUtil = {
|
|
|
82
62
|
minimumFractionDigits: decimals
|
|
83
63
|
});
|
|
84
64
|
},
|
|
85
|
-
|
|
86
65
|
/**
|
|
87
|
-
*
|
|
88
|
-
* @param value - The formatted string to parse
|
|
89
|
-
* @returns
|
|
66
|
+
* Parse a formatted local string back to a number
|
|
67
|
+
* @param value - The formatted string to parse
|
|
68
|
+
* @returns
|
|
90
69
|
*/
|
|
91
70
|
parseLocalStringToNumber(value: string | undefined) {
|
|
92
71
|
if (value === undefined) {
|
|
@@ -95,27 +74,5 @@ export const NumberUtil = {
|
|
|
95
74
|
|
|
96
75
|
// Remove any commas used as thousand separators and parse the float
|
|
97
76
|
return parseFloat(value.replace(/,/gu, ''));
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Converts a numeric value (BigInt, number, or string representation of a number) to a 0x-prefixed hexadecimal string.
|
|
102
|
-
* This is often required for Ethereum RPC parameters like value, gas, gasPrice.
|
|
103
|
-
* @param value - The value to convert. Can be BigInt, number, or a string (decimal or hex).
|
|
104
|
-
* @returns A 0x-prefixed hexadecimal string, or undefined if the input is undefined or null.
|
|
105
|
-
* @throws Error if the value cannot be converted to BigInt.
|
|
106
|
-
*/
|
|
107
|
-
convertNumericToHexString: (value: any): string | undefined => {
|
|
108
|
-
if (value === undefined || value === null) {
|
|
109
|
-
return undefined;
|
|
110
|
-
}
|
|
111
|
-
try {
|
|
112
|
-
// This handles BigInt, number, or string representation of a number (decimal or hex)
|
|
113
|
-
const bigIntValue = BigInt(value);
|
|
114
|
-
// Ethereum RPC spec requires "0x0" for zero, and other values to be 0x-prefixed hex.
|
|
115
|
-
|
|
116
|
-
return '0x' + bigIntValue.toString(16);
|
|
117
|
-
} catch (error) {
|
|
118
|
-
throw new Error(`NumberUtil: Invalid parameter, cannot convert to hex: ${value}`);
|
|
119
|
-
}
|
|
120
77
|
}
|
|
121
78
|
};
|