@toruslabs/ethereum-controllers 4.1.0
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/dist/ethereumControllers.cjs.js +6153 -0
- package/dist/ethereumControllers.cjs.js.map +1 -0
- package/dist/ethereumControllers.esm.js +5570 -0
- package/dist/ethereumControllers.esm.js.map +1 -0
- package/dist/ethereumControllers.umd.min.js +3 -0
- package/dist/ethereumControllers.umd.min.js.LICENSE.txt +38 -0
- package/dist/ethereumControllers.umd.min.js.map +1 -0
- package/dist/types/Account/AccountTrackerController.d.ts +35 -0
- package/dist/types/Block/PollingBlockTracker.d.ts +14 -0
- package/dist/types/Currency/CurrencyController.d.ts +30 -0
- package/dist/types/Gas/GasFeeController.d.ts +64 -0
- package/dist/types/Gas/IGasFeeController.d.ts +49 -0
- package/dist/types/Gas/gasUtil.d.ts +21 -0
- package/dist/types/Keyring/KeyringController.d.ts +20 -0
- package/dist/types/Message/AbstractMessageController.d.ts +36 -0
- package/dist/types/Message/DecryptMessageController.d.ts +20 -0
- package/dist/types/Message/EncryptionPublicKeyController.d.ts +20 -0
- package/dist/types/Message/MessageController.d.ts +20 -0
- package/dist/types/Message/PersonalMessageController.d.ts +20 -0
- package/dist/types/Message/TypedMessageController.d.ts +21 -0
- package/dist/types/Message/utils.d.ts +10 -0
- package/dist/types/Network/NetworkController.d.ts +40 -0
- package/dist/types/Network/createEthereumMiddleware.d.ts +66 -0
- package/dist/types/Network/createJsonRpcClient.d.ts +9 -0
- package/dist/types/Nfts/INftsController.d.ts +10 -0
- package/dist/types/Nfts/NftHandler.d.ts +35 -0
- package/dist/types/Nfts/NftsController.d.ts +40 -0
- package/dist/types/Preferences/PreferencesController.d.ts +53 -0
- package/dist/types/Tokens/ITokensController.d.ts +10 -0
- package/dist/types/Tokens/TokenHandler.d.ts +20 -0
- package/dist/types/Tokens/TokenRatesController.d.ts +42 -0
- package/dist/types/Tokens/TokensController.d.ts +42 -0
- package/dist/types/Transaction/NonceTracker.d.ts +37 -0
- package/dist/types/Transaction/PendingTransactionTracker.d.ts +32 -0
- package/dist/types/Transaction/TransactionController.d.ts +67 -0
- package/dist/types/Transaction/TransactionGasUtil.d.ts +21 -0
- package/dist/types/Transaction/TransactionStateHistoryHelper.d.ts +16 -0
- package/dist/types/Transaction/TransactionStateManager.d.ts +30 -0
- package/dist/types/Transaction/TransactionUtils.d.ts +70 -0
- package/dist/types/index.d.ts +43 -0
- package/dist/types/utils/abiDecoder.d.ts +17 -0
- package/dist/types/utils/abis.d.ts +84 -0
- package/dist/types/utils/constants.d.ts +81 -0
- package/dist/types/utils/contractAddresses.d.ts +1 -0
- package/dist/types/utils/conversionUtils.d.ts +42 -0
- package/dist/types/utils/helpers.d.ts +24 -0
- package/dist/types/utils/interfaces.d.ts +384 -0
- package/package.json +71 -0
- package/src/Account/AccountTrackerController.ts +157 -0
- package/src/Block/PollingBlockTracker.ts +89 -0
- package/src/Currency/CurrencyController.ts +117 -0
- package/src/Gas/GasFeeController.ts +254 -0
- package/src/Gas/IGasFeeController.ts +56 -0
- package/src/Gas/gasUtil.ts +163 -0
- package/src/Keyring/KeyringController.ts +118 -0
- package/src/Message/AbstractMessageController.ts +136 -0
- package/src/Message/DecryptMessageController.ts +81 -0
- package/src/Message/EncryptionPublicKeyController.ts +83 -0
- package/src/Message/MessageController.ts +74 -0
- package/src/Message/PersonalMessageController.ts +74 -0
- package/src/Message/TypedMessageController.ts +112 -0
- package/src/Message/utils.ts +107 -0
- package/src/Network/NetworkController.ts +184 -0
- package/src/Network/createEthereumMiddleware.ts +307 -0
- package/src/Network/createJsonRpcClient.ts +59 -0
- package/src/Nfts/INftsController.ts +13 -0
- package/src/Nfts/NftHandler.ts +191 -0
- package/src/Nfts/NftsController.ts +230 -0
- package/src/Preferences/PreferencesController.ts +409 -0
- package/src/Tokens/ITokensController.ts +13 -0
- package/src/Tokens/TokenHandler.ts +60 -0
- package/src/Tokens/TokenRatesController.ts +134 -0
- package/src/Tokens/TokensController.ts +278 -0
- package/src/Transaction/NonceTracker.ts +152 -0
- package/src/Transaction/PendingTransactionTracker.ts +235 -0
- package/src/Transaction/TransactionController.ts +558 -0
- package/src/Transaction/TransactionGasUtil.ts +74 -0
- package/src/Transaction/TransactionStateHistoryHelper.ts +41 -0
- package/src/Transaction/TransactionStateManager.ts +315 -0
- package/src/Transaction/TransactionUtils.ts +333 -0
- package/src/index.ts +45 -0
- package/src/utils/abiDecoder.ts +195 -0
- package/src/utils/abis.ts +677 -0
- package/src/utils/constants.ts +379 -0
- package/src/utils/contractAddresses.ts +21 -0
- package/src/utils/conversionUtils.ts +269 -0
- package/src/utils/helpers.ts +177 -0
- package/src/utils/interfaces.ts +454 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { EthereumProviderConfig } from "./interfaces";
|
|
2
|
+
export declare const LOCALHOST = "localhost";
|
|
3
|
+
export declare const CONTRACT_TYPE_ETH = "eth";
|
|
4
|
+
export declare const CONTRACT_TYPE_ERC20 = "erc20";
|
|
5
|
+
export declare const CONTRACT_TYPE_ERC721 = "erc721";
|
|
6
|
+
export declare const CONTRACT_TYPE_ERC1155 = "erc1155";
|
|
7
|
+
export declare const ERC1155_INTERFACE_ID = "0xd9b67a26";
|
|
8
|
+
export declare const ERC721_INTERFACE_ID = "0x80ac58cd";
|
|
9
|
+
export declare const ERC721_METADATA_INTERFACE_ID = "0x5b5e139f";
|
|
10
|
+
export declare const ERC721_ENUMERABLE_INTERFACE_ID = "0x780e9d63";
|
|
11
|
+
export declare const MAINNET_CHAIN_ID = "0x1";
|
|
12
|
+
export declare const POLYGON_CHAIN_ID = "0x89";
|
|
13
|
+
export declare const BSC_MAINNET_CHAIN_ID = "0x38";
|
|
14
|
+
export declare const AVALANCHE_MAINNET_CHAIN_ID = "0xa86a";
|
|
15
|
+
export declare const XDAI_CHAIN_ID = "0x64";
|
|
16
|
+
export declare const ARBITRUM_MAINNET_CHAIN_ID = "0xa4b1";
|
|
17
|
+
export declare const OPTIMISM_MAINNET_CHAIN_ID = "0xa";
|
|
18
|
+
export declare const CELO_MAINNET_CHAIN_ID = "0xa4ec";
|
|
19
|
+
export declare const GOERLI_CHAIN_ID = "0x5";
|
|
20
|
+
export declare const SEPOLIA_CHAIN_ID = "0xaa36a7";
|
|
21
|
+
export declare const POLYGON_MUMBAI_CHAIN_ID = "0x13881";
|
|
22
|
+
export declare const BSC_TESTNET_CHAIN_ID = "0x61";
|
|
23
|
+
export declare const AVALANCHE_TESTNET_CHAIN_ID = "0xa869";
|
|
24
|
+
export declare const ARBITRUM_TESTNET_CHAIN_ID = "0x66eeb";
|
|
25
|
+
export declare const OPTIMISM_TESTNET_CHAIN_ID = "0x1a4";
|
|
26
|
+
export declare const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig>;
|
|
27
|
+
export declare const METHOD_TYPES: {
|
|
28
|
+
readonly GET_ACCOUNTS: "eth_accounts";
|
|
29
|
+
readonly ETH_TRANSACTION: "eth_sendTransaction";
|
|
30
|
+
readonly ETH_REQUEST_ACCOUNTS: "eth_requestAccounts";
|
|
31
|
+
readonly ETH_SEND_RAW_TRANSACTION: "eth_sendRawTransaction";
|
|
32
|
+
readonly ETH_SIGN: "eth_sign";
|
|
33
|
+
readonly ETH_SIGN_TYPED_DATA: "eth_signTypedData";
|
|
34
|
+
readonly ETH_SIGN_TYPED_DATA_V3: "eth_signTypedData_v3";
|
|
35
|
+
readonly ETH_SIGN_TYPED_DATA_V4: "eth_signTypedData_v4";
|
|
36
|
+
readonly PERSONAL_SIGN: "personal_sign";
|
|
37
|
+
readonly ETH_GET_TRANSACTION_COUNT: "eth_getTransactionCount";
|
|
38
|
+
readonly ETH_GET_TRANSACTION_BY_HASH: "eth_getTransactionByHash";
|
|
39
|
+
readonly ETH_GET_ENCRYPTION_PUBLIC_KEY: "eth_getEncryptionPublicKey";
|
|
40
|
+
readonly ETH_DECRYPT: "eth_decrypt";
|
|
41
|
+
readonly ETH_GET_TRANSACTION_RECEIPT: "eth_getTransactionReceipt";
|
|
42
|
+
readonly WATCH_ASSET: "wallet_watchAsset";
|
|
43
|
+
readonly ETH_GET_BLOCK_BY_HASH: "eth_getBlockByHash";
|
|
44
|
+
readonly ETH_GET_CODE: "eth_getCode";
|
|
45
|
+
readonly ETH_GET_GAS_PRICE: "eth_gasPrice";
|
|
46
|
+
};
|
|
47
|
+
export declare const TRANSACTION_ENVELOPE_TYPES: {
|
|
48
|
+
readonly LEGACY: "0x0";
|
|
49
|
+
readonly ACCESS_LIST: "0x1";
|
|
50
|
+
readonly FEE_MARKET: "0x2";
|
|
51
|
+
};
|
|
52
|
+
export declare const GAS_ESTIMATE_TYPES: {
|
|
53
|
+
readonly FEE_MARKET: "fee-market";
|
|
54
|
+
readonly LEGACY: "legacy";
|
|
55
|
+
readonly ETH_GASPRICE: "eth_gasPrice";
|
|
56
|
+
readonly NONE: "none";
|
|
57
|
+
};
|
|
58
|
+
export declare const CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP: Record<string, number>;
|
|
59
|
+
export declare const OLD_ERC721_LIST: Record<string, {
|
|
60
|
+
name?: string;
|
|
61
|
+
logo?: string;
|
|
62
|
+
erc20?: boolean;
|
|
63
|
+
symbol?: string;
|
|
64
|
+
decimals?: number;
|
|
65
|
+
}>;
|
|
66
|
+
export declare const TEST_CHAINS: string[];
|
|
67
|
+
export declare const ETHERSCAN_SUPPORTED_CHAINS: string[];
|
|
68
|
+
export declare const SIMPLEHASH_SUPPORTED_CHAINS: string[];
|
|
69
|
+
export declare const COINGECKO_SUPPORTED_CURRENCIES: Set<string>;
|
|
70
|
+
export declare const COINGECKO_PLATFORMS_CHAIN_CODE_MAP: Record<string, {
|
|
71
|
+
platform: string;
|
|
72
|
+
currency: string;
|
|
73
|
+
}>;
|
|
74
|
+
export declare const MessageStatus: {
|
|
75
|
+
readonly UNAPPROVED: "unapproved";
|
|
76
|
+
readonly SIGNED: "signed";
|
|
77
|
+
readonly PENDING: "pending";
|
|
78
|
+
readonly APPROVED: "approved";
|
|
79
|
+
readonly REJECTED: "rejected";
|
|
80
|
+
readonly FAILED: "failed";
|
|
81
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SINGLE_CALL_BALANCES_ADDRESSES: Record<string, string>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
type NumericBase = "hex" | "dec" | "BN";
|
|
3
|
+
type EthDenomination = "WEI" | "GWEI" | "ETH";
|
|
4
|
+
type ConverterOptions = {
|
|
5
|
+
value: BigNumber | string;
|
|
6
|
+
fromNumericBase: NumericBase;
|
|
7
|
+
fromDenomination: EthDenomination;
|
|
8
|
+
fromCurrency: string;
|
|
9
|
+
toNumericBase: NumericBase;
|
|
10
|
+
toDenomination: EthDenomination;
|
|
11
|
+
toCurrency: string;
|
|
12
|
+
numberOfDecimals: number;
|
|
13
|
+
conversionRate: number;
|
|
14
|
+
invertConversionRate: boolean;
|
|
15
|
+
roundDown?: number;
|
|
16
|
+
};
|
|
17
|
+
export declare const conversionUtil: (value: BigNumber | string, { fromCurrency, toCurrency, fromNumericBase, toNumericBase, fromDenomination, toDenomination, numberOfDecimals, conversionRate, invertConversionRate, }: Omit<ConverterOptions, "value">) => string | 0 | BigNumber;
|
|
18
|
+
export declare const getBigNumber: (value: any, base: any) => BigNumber;
|
|
19
|
+
export declare const addCurrencies: (a: any, b: any, options?: Record<string, unknown>) => string | BigNumber;
|
|
20
|
+
export declare const subtractCurrencies: (a: any, b: any, options?: Record<string, unknown>) => string | BigNumber;
|
|
21
|
+
export declare const multiplyCurrencies: (a: any, b: any, options?: Record<string, unknown>) => string | BigNumber;
|
|
22
|
+
export declare const conversionGreaterThan: ({ ...firstProps }: ConverterOptions, { ...secondProps }: ConverterOptions) => any;
|
|
23
|
+
export declare const conversionLessThan: ({ ...firstProps }: ConverterOptions, { ...secondProps }: ConverterOptions) => any;
|
|
24
|
+
export declare const conversionMax: ({ ...firstProps }: {
|
|
25
|
+
[x: string]: any;
|
|
26
|
+
}, { ...secondProps }: {
|
|
27
|
+
[x: string]: any;
|
|
28
|
+
}) => any;
|
|
29
|
+
export declare const conversionGTE: ({ ...firstProps }: {
|
|
30
|
+
[x: string]: any;
|
|
31
|
+
}, { ...secondProps }: {
|
|
32
|
+
[x: string]: any;
|
|
33
|
+
}) => any;
|
|
34
|
+
export declare const conversionLTE: ({ ...firstProps }: {
|
|
35
|
+
[x: string]: any;
|
|
36
|
+
}, { ...secondProps }: {
|
|
37
|
+
[x: string]: any;
|
|
38
|
+
}) => any;
|
|
39
|
+
export declare const toNegative: (n: any, options?: {}) => string | BigNumber;
|
|
40
|
+
export declare const decGWEIToHexWEI: (decGWEI: BigNumber) => BigNumber;
|
|
41
|
+
export declare const hexWEIToDecGWEI: (decGWEI: BigNumber | string) => BigNumber;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TransactionStatus } from "@toruslabs/base-controllers";
|
|
2
|
+
import { SafeEventEmitterProvider } from "@toruslabs/openlogin-jrpc";
|
|
3
|
+
import { FormattedTransactionActivity, TransactionPayload } from "./interfaces";
|
|
4
|
+
export declare function getEtherScanHashLink(txHash: string, chainId: string): string;
|
|
5
|
+
export declare const formatPastTx: (x: TransactionPayload, lowerCaseSelectedAddress?: string) => FormattedTransactionActivity;
|
|
6
|
+
/**
|
|
7
|
+
* Ref - https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt
|
|
8
|
+
*/
|
|
9
|
+
export declare const getEthTxStatus: (hash: string, provider: SafeEventEmitterProvider) => Promise<TransactionStatus | undefined>;
|
|
10
|
+
export declare function formatDate(inputDate: string): string;
|
|
11
|
+
export declare function formatTime(time: number): string;
|
|
12
|
+
export declare const idleTimeTracker: {
|
|
13
|
+
checkIfIdle: () => boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare function isAddressByChainId(address: string, _chainId: string): boolean;
|
|
16
|
+
export declare function toChecksumAddressByChainId(address: string, chainId: string): string;
|
|
17
|
+
export declare const GAS_LIMITS: {
|
|
18
|
+
SIMPLE: string;
|
|
19
|
+
BASE_TOKEN_ESTIMATE: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function bnLessThan(a: string | number, b: string | number): boolean;
|
|
22
|
+
export declare const getIpfsEndpoint: (path: string) => string;
|
|
23
|
+
export declare function sanitizeNftMetdataUrl(url: string): string;
|
|
24
|
+
export declare function getChainType(chainId: string): "mainnet" | "testnet" | "custom";
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { AccessList } from "@ethereumjs/common";
|
|
2
|
+
import { SignTypedDataVersion } from "@metamask/eth-sig-util";
|
|
3
|
+
import { AddressPreferences, BaseBlockTrackerState, NetworkConfig, NetworkState, PaymentTransaction, PopupWhitelabelData, ProviderConfig, TRANSACTION_TYPE, TransactionMeta, TransactionStatus, User } from "@toruslabs/base-controllers";
|
|
4
|
+
import { Json } from "@toruslabs/openlogin-jrpc";
|
|
5
|
+
import { MutexInterface } from "async-mutex";
|
|
6
|
+
import { MessageStatus, METHOD_TYPES, TRANSACTION_ENVELOPE_TYPES } from "./constants";
|
|
7
|
+
export type CustomTokenInfo = {
|
|
8
|
+
tokenAddress: string;
|
|
9
|
+
name: string;
|
|
10
|
+
chainId: string;
|
|
11
|
+
erc20: boolean;
|
|
12
|
+
symbol: string;
|
|
13
|
+
decimals: string;
|
|
14
|
+
balance?: string;
|
|
15
|
+
customTokenId?: string;
|
|
16
|
+
isEtherScan?: boolean;
|
|
17
|
+
logo?: string;
|
|
18
|
+
};
|
|
19
|
+
export type CustomNftItemInfo = {
|
|
20
|
+
image: string;
|
|
21
|
+
name: string;
|
|
22
|
+
tokenBalance: string;
|
|
23
|
+
description: string;
|
|
24
|
+
tokenId: string;
|
|
25
|
+
video?: string;
|
|
26
|
+
decimals?: string;
|
|
27
|
+
customNftId?: string;
|
|
28
|
+
};
|
|
29
|
+
export type NftStandardType = "erc721" | "erc1155";
|
|
30
|
+
export type CustomNftInfo = {
|
|
31
|
+
contractAddress: string;
|
|
32
|
+
contractName: string;
|
|
33
|
+
contractSymbol: string;
|
|
34
|
+
contractImage?: string;
|
|
35
|
+
contractSupply?: string;
|
|
36
|
+
contractFallbackLogo?: string;
|
|
37
|
+
nftStandard: NftStandardType;
|
|
38
|
+
contractDescription?: string;
|
|
39
|
+
chainId: string;
|
|
40
|
+
assets: CustomNftItemInfo[];
|
|
41
|
+
};
|
|
42
|
+
export interface EthereumBlock {
|
|
43
|
+
blockHash: string;
|
|
44
|
+
idempotencyKey: string;
|
|
45
|
+
timestamp: string;
|
|
46
|
+
baseFeePerGas: string;
|
|
47
|
+
gasLimit: string;
|
|
48
|
+
}
|
|
49
|
+
export interface UserRequestApprovalParams {
|
|
50
|
+
windowId?: string;
|
|
51
|
+
origin?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface BaseRequestParams {
|
|
54
|
+
/**
|
|
55
|
+
* Unique id for each request
|
|
56
|
+
*/
|
|
57
|
+
id: string;
|
|
58
|
+
/**
|
|
59
|
+
* Address to send this transaction from.
|
|
60
|
+
*/
|
|
61
|
+
from: string;
|
|
62
|
+
/**
|
|
63
|
+
* Domain requested from
|
|
64
|
+
*/
|
|
65
|
+
origin?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface MessageParams extends BaseRequestParams {
|
|
68
|
+
data: string;
|
|
69
|
+
}
|
|
70
|
+
export type MessageStatusType = (typeof MessageStatus)[keyof typeof MessageStatus];
|
|
71
|
+
export interface AbstractMessage {
|
|
72
|
+
id: string;
|
|
73
|
+
time: number;
|
|
74
|
+
status: MessageStatusType;
|
|
75
|
+
/**
|
|
76
|
+
* JRPC method for which sig request is made
|
|
77
|
+
*/
|
|
78
|
+
type: string;
|
|
79
|
+
rawSig?: string;
|
|
80
|
+
metadata?: Json;
|
|
81
|
+
error?: string;
|
|
82
|
+
}
|
|
83
|
+
export interface Message extends AbstractMessage {
|
|
84
|
+
messageParams: MessageParams;
|
|
85
|
+
}
|
|
86
|
+
export type SignTypedDataMessageV3V4 = {
|
|
87
|
+
types: Record<string, unknown>;
|
|
88
|
+
domain: Record<string, unknown>;
|
|
89
|
+
primaryType: string;
|
|
90
|
+
message: unknown;
|
|
91
|
+
};
|
|
92
|
+
export interface TypedMessageParams extends BaseRequestParams {
|
|
93
|
+
data: Record<string, unknown>[] | string | SignTypedDataMessageV3V4;
|
|
94
|
+
version?: SignTypedDataVersion;
|
|
95
|
+
}
|
|
96
|
+
export interface TypedMessage extends AbstractMessage {
|
|
97
|
+
messageParams: TypedMessageParams;
|
|
98
|
+
}
|
|
99
|
+
export type TRANSACTION_ENVELOPE_TYPES_TYPE = (typeof TRANSACTION_ENVELOPE_TYPES)[keyof typeof TRANSACTION_ENVELOPE_TYPES];
|
|
100
|
+
export interface TransactionParams extends BaseRequestParams {
|
|
101
|
+
/**
|
|
102
|
+
* Network ID as per EIP-155.
|
|
103
|
+
*/
|
|
104
|
+
chainId?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Data to pass with this transaction.
|
|
107
|
+
*/
|
|
108
|
+
data?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Error message for gas estimation failure.
|
|
111
|
+
*/
|
|
112
|
+
estimateGasError?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Estimated base fee for this transaction.
|
|
115
|
+
*/
|
|
116
|
+
estimatedBaseFee?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Gas to send with this transaction.
|
|
119
|
+
*/
|
|
120
|
+
gas?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Price of gas with this transaction.
|
|
123
|
+
*/
|
|
124
|
+
gasPrice?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Gas used in the transaction.
|
|
127
|
+
*/
|
|
128
|
+
gasUsed?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Maximum fee per gas for this transaction.
|
|
131
|
+
*/
|
|
132
|
+
maxFeePerGas?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Maximum priority fee per gas for this transaction.
|
|
135
|
+
*/
|
|
136
|
+
maxPriorityFeePerGas?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Unique number to prevent replay attacks.
|
|
139
|
+
*/
|
|
140
|
+
nonce?: string;
|
|
141
|
+
/**
|
|
142
|
+
* Address to send this transaction to.
|
|
143
|
+
*/
|
|
144
|
+
to?: string;
|
|
145
|
+
/**
|
|
146
|
+
* Value associated with this transaction.
|
|
147
|
+
*/
|
|
148
|
+
value?: string;
|
|
149
|
+
/**
|
|
150
|
+
* EIP 2930
|
|
151
|
+
*/
|
|
152
|
+
accessList?: AccessList;
|
|
153
|
+
/**
|
|
154
|
+
* Custom Nonce passed by the user
|
|
155
|
+
*/
|
|
156
|
+
customNonceValue?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Transaction envelope type
|
|
159
|
+
*/
|
|
160
|
+
type?: TRANSACTION_ENVELOPE_TYPES_TYPE;
|
|
161
|
+
/**
|
|
162
|
+
* Max Gas to send with this transaction.
|
|
163
|
+
*/
|
|
164
|
+
gasLimit?: string;
|
|
165
|
+
}
|
|
166
|
+
export type Nonce = {
|
|
167
|
+
name: string;
|
|
168
|
+
nonce: number;
|
|
169
|
+
details: {
|
|
170
|
+
startPoint?: number;
|
|
171
|
+
highest?: number;
|
|
172
|
+
block?: EthereumBlock;
|
|
173
|
+
baseCount?: number;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
export type NonceDetails = {
|
|
177
|
+
params: {
|
|
178
|
+
highestLocallyConfirmed: number;
|
|
179
|
+
nextNetworkNonce: number;
|
|
180
|
+
highestSuggested: number;
|
|
181
|
+
};
|
|
182
|
+
local: Nonce;
|
|
183
|
+
network: Nonce;
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Ref - https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt
|
|
187
|
+
*/
|
|
188
|
+
export interface TransactionReceipt {
|
|
189
|
+
transactionHash: string;
|
|
190
|
+
transactionIndex: string;
|
|
191
|
+
blockNumber: string;
|
|
192
|
+
blockHash: string;
|
|
193
|
+
from: string;
|
|
194
|
+
to: string | null;
|
|
195
|
+
cumulativeGasUsed: string;
|
|
196
|
+
effectiveGasPrice: string;
|
|
197
|
+
gasUsed: string;
|
|
198
|
+
contractAddress: string | null;
|
|
199
|
+
logs: unknown[];
|
|
200
|
+
logsBloom: string;
|
|
201
|
+
type: TRANSACTION_ENVELOPE_TYPES_TYPE;
|
|
202
|
+
root?: string;
|
|
203
|
+
status?: "0x0" | "0x1";
|
|
204
|
+
}
|
|
205
|
+
export type BlockTag = "earliest" | "finalized" | "safe" | "latest" | "pending";
|
|
206
|
+
export type BlockParams = string | BlockTag;
|
|
207
|
+
export interface TransactionRPCMeta {
|
|
208
|
+
v: string;
|
|
209
|
+
r: string;
|
|
210
|
+
s: string;
|
|
211
|
+
to: string | null;
|
|
212
|
+
gas: string;
|
|
213
|
+
from: string;
|
|
214
|
+
hash: string;
|
|
215
|
+
nonce: string;
|
|
216
|
+
input: string;
|
|
217
|
+
value: string;
|
|
218
|
+
accessList?: string[];
|
|
219
|
+
blockHash: string | null;
|
|
220
|
+
blockNumber: string | null;
|
|
221
|
+
transactionIndex: string | null;
|
|
222
|
+
maxFeePerGas?: string;
|
|
223
|
+
maxPriorityFeePerGas?: string;
|
|
224
|
+
gasPrice?: string;
|
|
225
|
+
type: TRANSACTION_ENVELOPE_TYPES_TYPE;
|
|
226
|
+
chainID?: string;
|
|
227
|
+
}
|
|
228
|
+
export type PollingBlockTrackerState = BaseBlockTrackerState<EthereumBlock>;
|
|
229
|
+
export interface EthereumProviderConfig extends ProviderConfig {
|
|
230
|
+
isErc20?: boolean;
|
|
231
|
+
tokenAddress?: string;
|
|
232
|
+
isTestNet?: boolean;
|
|
233
|
+
}
|
|
234
|
+
export interface EthereumNetworkState extends NetworkState {
|
|
235
|
+
providerConfig: EthereumProviderConfig;
|
|
236
|
+
}
|
|
237
|
+
export interface EthereumNetworkConfig extends NetworkConfig {
|
|
238
|
+
providerConfig: EthereumProviderConfig;
|
|
239
|
+
}
|
|
240
|
+
export type CustomNetworkPayload = Partial<EthereumProviderConfig> & Pick<EthereumProviderConfig, "chainId" | "displayName" | "rpcTarget" | "ticker">;
|
|
241
|
+
export interface CustomNetworks {
|
|
242
|
+
id: number;
|
|
243
|
+
created_at: Date;
|
|
244
|
+
updated_at: Date;
|
|
245
|
+
network_name: string;
|
|
246
|
+
public_address: string;
|
|
247
|
+
chain_id: string;
|
|
248
|
+
type: string;
|
|
249
|
+
rpc_url: string;
|
|
250
|
+
deleted: boolean;
|
|
251
|
+
symbol?: string;
|
|
252
|
+
block_explorer_url?: string;
|
|
253
|
+
is_test_net?: boolean;
|
|
254
|
+
}
|
|
255
|
+
export interface EthereumUser extends User {
|
|
256
|
+
customNetworks: CustomNetworks[];
|
|
257
|
+
}
|
|
258
|
+
export interface ContractParams {
|
|
259
|
+
erc20?: boolean;
|
|
260
|
+
erc721?: boolean;
|
|
261
|
+
erc1155?: boolean;
|
|
262
|
+
isSpecial?: boolean;
|
|
263
|
+
symbol?: string;
|
|
264
|
+
logo?: string;
|
|
265
|
+
decimals?: number;
|
|
266
|
+
}
|
|
267
|
+
export interface DappSuggestedGasFees {
|
|
268
|
+
gasPrice?: string;
|
|
269
|
+
maxPriorityFeePerGas?: string;
|
|
270
|
+
maxFeePerGas?: string;
|
|
271
|
+
gas?: string;
|
|
272
|
+
}
|
|
273
|
+
export interface EthereumTransactionMeta extends TransactionMeta<TransactionParams> {
|
|
274
|
+
r?: string;
|
|
275
|
+
s?: string;
|
|
276
|
+
v?: string;
|
|
277
|
+
type: string;
|
|
278
|
+
txReceipt?: TransactionReceipt;
|
|
279
|
+
history: Record<string, unknown>[];
|
|
280
|
+
accessList?: string[];
|
|
281
|
+
firstRetryBlockNumber?: string;
|
|
282
|
+
retryCount?: number;
|
|
283
|
+
simulationFails?: Record<string, unknown>;
|
|
284
|
+
loadingDefaults?: boolean;
|
|
285
|
+
transactionCategory?: TRANSACTION_TYPE;
|
|
286
|
+
nonceDetails?: NonceDetails;
|
|
287
|
+
methodParams?: unknown[];
|
|
288
|
+
dappSuggestedGasFees?: DappSuggestedGasFees;
|
|
289
|
+
}
|
|
290
|
+
export interface TransactionPayload {
|
|
291
|
+
created_at: Date;
|
|
292
|
+
from: string;
|
|
293
|
+
to: string;
|
|
294
|
+
total_amount: string;
|
|
295
|
+
currency_amount: string;
|
|
296
|
+
selected_currency: string;
|
|
297
|
+
status?: TransactionStatus;
|
|
298
|
+
network: string;
|
|
299
|
+
transaction_hash: string;
|
|
300
|
+
transaction_category: string;
|
|
301
|
+
gas: string;
|
|
302
|
+
gasPrice: string;
|
|
303
|
+
nonce: string;
|
|
304
|
+
type: string;
|
|
305
|
+
type_name: string;
|
|
306
|
+
type_image_link: string;
|
|
307
|
+
symbol: string;
|
|
308
|
+
is_cancel: boolean;
|
|
309
|
+
contract_address?: string;
|
|
310
|
+
from_aa_address?: string;
|
|
311
|
+
}
|
|
312
|
+
export interface FetchedTransaction extends TransactionPayload {
|
|
313
|
+
id: string;
|
|
314
|
+
}
|
|
315
|
+
export interface FetchCommonTransaction extends PaymentTransaction {
|
|
316
|
+
etherscanLink?: string | null;
|
|
317
|
+
}
|
|
318
|
+
export interface FormattedTransactionActivity {
|
|
319
|
+
id: string;
|
|
320
|
+
date: string;
|
|
321
|
+
from: string;
|
|
322
|
+
from_aa_address?: string;
|
|
323
|
+
slicedFrom: string;
|
|
324
|
+
to: string;
|
|
325
|
+
slicedTo: string;
|
|
326
|
+
action: string;
|
|
327
|
+
totalAmount: string;
|
|
328
|
+
totalAmountString: string;
|
|
329
|
+
currencyAmount: string;
|
|
330
|
+
currencyAmountString: string;
|
|
331
|
+
amount: string;
|
|
332
|
+
status: TransactionStatus;
|
|
333
|
+
etherscanLink: string;
|
|
334
|
+
ethRate: string;
|
|
335
|
+
currencyUsed: string;
|
|
336
|
+
networkType: string;
|
|
337
|
+
type: string;
|
|
338
|
+
type_name: string;
|
|
339
|
+
type_image_link: string;
|
|
340
|
+
transaction_hash: string;
|
|
341
|
+
isEtherscan?: boolean;
|
|
342
|
+
transaction_category: string;
|
|
343
|
+
input?: string;
|
|
344
|
+
contract_address?: string;
|
|
345
|
+
token_id?: string;
|
|
346
|
+
nonce: string;
|
|
347
|
+
is_cancel: boolean;
|
|
348
|
+
gas: string;
|
|
349
|
+
gasPrice: string;
|
|
350
|
+
hasCancel?: boolean;
|
|
351
|
+
cancelDateInitiated?: string;
|
|
352
|
+
cancelGas?: string;
|
|
353
|
+
cancelGasPrice?: string;
|
|
354
|
+
}
|
|
355
|
+
export interface ExtendedAddressPreferences extends AddressPreferences {
|
|
356
|
+
fetchedPastTx?: FetchedTransaction[];
|
|
357
|
+
formattedPastTransactions?: FormattedTransactionActivity[];
|
|
358
|
+
paymentTx: FetchCommonTransaction[];
|
|
359
|
+
customNetworks: CustomNetworks[];
|
|
360
|
+
}
|
|
361
|
+
export interface ProviderChangeChannelEventData {
|
|
362
|
+
newNetwork: EthereumProviderConfig;
|
|
363
|
+
whitelabelData: PopupWhitelabelData;
|
|
364
|
+
origin: string;
|
|
365
|
+
currentChainId: string;
|
|
366
|
+
}
|
|
367
|
+
export interface NonceLockRes {
|
|
368
|
+
nextNonce: number;
|
|
369
|
+
nonceDetails: NonceDetails;
|
|
370
|
+
releaseLock: MutexInterface.Releaser;
|
|
371
|
+
}
|
|
372
|
+
export type METHOD_TYPES_TYPE = (typeof METHOD_TYPES)[keyof typeof METHOD_TYPES];
|
|
373
|
+
export interface EncryptionPublicKeyParams extends BaseRequestParams {
|
|
374
|
+
data: string;
|
|
375
|
+
}
|
|
376
|
+
export interface EncryptionPublicKey extends AbstractMessage {
|
|
377
|
+
messageParams: EncryptionPublicKeyParams;
|
|
378
|
+
}
|
|
379
|
+
export interface DecryptMessageParams extends BaseRequestParams {
|
|
380
|
+
data: string;
|
|
381
|
+
}
|
|
382
|
+
export interface DecryptMessage extends AbstractMessage {
|
|
383
|
+
messageParams: DecryptMessageParams;
|
|
384
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@toruslabs/ethereum-controllers",
|
|
3
|
+
"version": "4.1.0",
|
|
4
|
+
"homepage": "https://github.com/torusresearch/controllers#readme",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"main": "dist/ethereumControllers.cjs.js",
|
|
7
|
+
"module": "dist/ethereumControllers.esm.js",
|
|
8
|
+
"unpkg": "dist/ethereumControllers.umd.min.js",
|
|
9
|
+
"jsdelivr": "dist/ethereumControllers.umd.min.js",
|
|
10
|
+
"types": "dist/types/index.d.ts",
|
|
11
|
+
"author": "Torus Labs",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "mocha --config ../../.mocharc.json test/**/*.ts",
|
|
14
|
+
"test-debugger": "mocha --config ../../.mocharc.json --inspect-brk test/**/*.ts",
|
|
15
|
+
"dev": "rimraf dist/ && cross-env NODE_ENV=development torus-scripts start",
|
|
16
|
+
"build": "rimraf dist/ && cross-env NODE_ENV=production torus-scripts build",
|
|
17
|
+
"lint": "eslint --fix 'src/**/*.ts'",
|
|
18
|
+
"prepack": "npm run build",
|
|
19
|
+
"pre-commit": "lint-staged --cwd ."
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@ethereumjs/common": "^4.0.0",
|
|
23
|
+
"@ethereumjs/tx": "^5.0.0",
|
|
24
|
+
"@ethereumjs/util": "^9.0.0",
|
|
25
|
+
"@metamask/eth-sig-util": "^7.0.0",
|
|
26
|
+
"@metamask/rpc-errors": "^6.0.0",
|
|
27
|
+
"@toruslabs/base-controllers": "^4.1.0",
|
|
28
|
+
"@toruslabs/http-helpers": "^5.0.0",
|
|
29
|
+
"@toruslabs/openlogin-jrpc": "^5.1.0",
|
|
30
|
+
"async-mutex": "^0.4.0",
|
|
31
|
+
"bignumber.js": "^9.1.2",
|
|
32
|
+
"bn.js": "^5.2.1",
|
|
33
|
+
"ethers": "^6.7.1",
|
|
34
|
+
"fast-json-patch": "^3.1.1",
|
|
35
|
+
"jsonschema": "^1.4.1",
|
|
36
|
+
"lodash": "^4.17.21",
|
|
37
|
+
"loglevel": "^1.8.1"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@babel/runtime": "7.x"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"src"
|
|
45
|
+
],
|
|
46
|
+
"lint-staged": {
|
|
47
|
+
"!(*d).ts": [
|
|
48
|
+
"eslint --cache --fix",
|
|
49
|
+
"prettier --write"
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git+https://github.com/torusresearch/controllers.git"
|
|
55
|
+
},
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/torusresearch/controllers/issues"
|
|
58
|
+
},
|
|
59
|
+
"engines": {
|
|
60
|
+
"node": ">=16.18.1",
|
|
61
|
+
"npm": ">=8.x"
|
|
62
|
+
},
|
|
63
|
+
"keywords": [],
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public"
|
|
66
|
+
},
|
|
67
|
+
"gitHead": "13b57afe21257c71e11d4e019fca62d517bfdc54",
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"ganache": "^7.9.1"
|
|
70
|
+
}
|
|
71
|
+
}
|