@metamask/transaction-controller 8.0.0 → 9.0.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/CHANGELOG.md +44 -1
- package/dist/EtherscanRemoteTransactionSource.d.ts +15 -0
- package/dist/EtherscanRemoteTransactionSource.d.ts.map +1 -0
- package/dist/EtherscanRemoteTransactionSource.js +99 -0
- package/dist/EtherscanRemoteTransactionSource.js.map +1 -0
- package/dist/IncomingTransactionHelper.d.ts +24 -0
- package/dist/IncomingTransactionHelper.d.ts.map +1 -0
- package/dist/IncomingTransactionHelper.js +188 -0
- package/dist/IncomingTransactionHelper.js.map +1 -0
- package/dist/TransactionController.d.ts +58 -232
- package/dist/TransactionController.d.ts.map +1 -1
- package/dist/TransactionController.js +198 -311
- package/dist/TransactionController.js.map +1 -1
- package/dist/constants.d.ts +119 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +124 -0
- package/dist/constants.js.map +1 -0
- package/dist/etherscan.d.ts +65 -0
- package/dist/etherscan.d.ts.map +1 -0
- package/dist/etherscan.js +116 -0
- package/dist/etherscan.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +265 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +29 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +13 -23
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +20 -77
- package/dist/utils.js.map +1 -1
- package/package.json +5 -6
- package/dist/mocks/txsMock.d.ts +0 -64
- package/dist/mocks/txsMock.d.ts.map +0 -1
- package/dist/mocks/txsMock.js +0 -516
- package/dist/mocks/txsMock.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG;IACvB,OAAO,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CAAC,CAAC,QAAQ,EAAE;KACvD;IACD,CAAC,iBAAS,CAAC,gBAAgB,CAAC,EAAE;QAC5B,MAAM,EAAE,aAAa;QACrB,SAAS,EAAE,GAAG,kCAAkC,WAAW;QAC3D,SAAS,EAAE,QAAQ,CAAC,iBAAS,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE;KAC/D;IACD,CAAC,iBAAS,CAAC,SAAS,CAAC,EAAE;QACrB,MAAM,EAAE,aAAa;QACrB,SAAS,EAAE,GAAG,kCAAkC,YAAY;QAC5D,SAAS,EAAE,QAAQ,CAAC,iBAAS,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE;KACxD;IACD,CAAC,iBAAS,CAAC,MAAM,CAAC,EAAE;QAClB,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,GAAG,kCAAkC,SAAS;QACzD,SAAS,EAAE,QAAQ,CAAC,iBAAS,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE;KACrD;CACF,CAAC","sourcesContent":["export const CHAIN_IDS = {\n MAINNET: '0x1',\n GOERLI: '0x5',\n BSC: '0x38',\n BSC_TESTNET: '0x61',\n OPTIMISM: '0xa',\n OPTIMISM_TESTNET: '0x1a4',\n POLYGON: '0x89',\n POLYGON_TESTNET: '0x13881',\n AVALANCHE: '0xa86a',\n AVALANCHE_TESTNET: '0xa869',\n FANTOM: '0xfa',\n FANTOM_TESTNET: '0xfa2',\n SEPOLIA: '0xaa36a7',\n LINEA_GOERLI: '0xe704',\n LINEA_MAINNET: '0xe708',\n MOONBEAM: '0x504',\n MOONBEAM_TESTNET: '0x507',\n MOONRIVER: '0x505',\n GNOSIS: '0x64',\n} as const;\n\nconst DEFAULT_ETHERSCAN_DOMAIN = 'etherscan.io';\nconst DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX = 'api';\n\nexport const ETHERSCAN_SUPPORTED_NETWORKS = {\n [CHAIN_IDS.GOERLI]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli`,\n networkId: parseInt(CHAIN_IDS.GOERLI, 16).toString(),\n },\n [CHAIN_IDS.MAINNET]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n networkId: parseInt(CHAIN_IDS.MAINNET, 16).toString(),\n },\n [CHAIN_IDS.SEPOLIA]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-sepolia`,\n networkId: parseInt(CHAIN_IDS.SEPOLIA, 16).toString(),\n },\n [CHAIN_IDS.LINEA_GOERLI]: {\n domain: 'lineascan.build',\n subdomain: 'goerli',\n networkId: parseInt(CHAIN_IDS.LINEA_GOERLI, 16).toString(),\n },\n [CHAIN_IDS.LINEA_MAINNET]: {\n domain: 'lineascan.build',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n networkId: parseInt(CHAIN_IDS.LINEA_MAINNET, 16).toString(),\n },\n [CHAIN_IDS.BSC]: {\n domain: 'bscscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n networkId: parseInt(CHAIN_IDS.BSC, 16).toString(),\n },\n [CHAIN_IDS.BSC_TESTNET]: {\n domain: 'bscscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n networkId: parseInt(CHAIN_IDS.BSC_TESTNET, 16).toString(),\n },\n [CHAIN_IDS.OPTIMISM]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-optimistic`,\n networkId: parseInt(CHAIN_IDS.OPTIMISM, 16).toString(),\n },\n [CHAIN_IDS.OPTIMISM_TESTNET]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli-optimistic`,\n networkId: parseInt(CHAIN_IDS.OPTIMISM_TESTNET, 16).toString(),\n },\n [CHAIN_IDS.POLYGON]: {\n domain: 'polygonscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n networkId: parseInt(CHAIN_IDS.POLYGON, 16).toString(),\n },\n [CHAIN_IDS.POLYGON_TESTNET]: {\n domain: 'polygonscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-mumbai`,\n networkId: parseInt(CHAIN_IDS.POLYGON_TESTNET, 16).toString(),\n },\n [CHAIN_IDS.AVALANCHE]: {\n domain: 'snowtrace.io',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n networkId: parseInt(CHAIN_IDS.AVALANCHE, 16).toString(),\n },\n [CHAIN_IDS.AVALANCHE_TESTNET]: {\n domain: 'snowtrace.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n networkId: parseInt(CHAIN_IDS.AVALANCHE_TESTNET, 16).toString(),\n },\n [CHAIN_IDS.FANTOM]: {\n domain: 'ftmscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n networkId: parseInt(CHAIN_IDS.FANTOM, 16).toString(),\n },\n [CHAIN_IDS.FANTOM_TESTNET]: {\n domain: 'ftmscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n networkId: parseInt(CHAIN_IDS.FANTOM_TESTNET, 16).toString(),\n },\n [CHAIN_IDS.MOONBEAM]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbeam`,\n networkId: parseInt(CHAIN_IDS.MOONBEAM, 16).toString(),\n },\n [CHAIN_IDS.MOONBEAM_TESTNET]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbase`,\n networkId: parseInt(CHAIN_IDS.MOONBEAM_TESTNET, 16).toString(),\n },\n [CHAIN_IDS.MOONRIVER]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonriver`,\n networkId: parseInt(CHAIN_IDS.MOONRIVER, 16).toString(),\n },\n [CHAIN_IDS.GNOSIS]: {\n domain: 'gnosisscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-gnosis`,\n networkId: parseInt(CHAIN_IDS.GNOSIS, 16).toString(),\n },\n};\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Hex } from '@metamask/utils';
|
|
2
|
+
export interface EtherscanTransactionMetaBase {
|
|
3
|
+
blockNumber: string;
|
|
4
|
+
blockHash: string;
|
|
5
|
+
confirmations: string;
|
|
6
|
+
contractAddress: string;
|
|
7
|
+
cumulativeGasUsed: string;
|
|
8
|
+
from: string;
|
|
9
|
+
gas: string;
|
|
10
|
+
gasPrice: string;
|
|
11
|
+
gasUsed: string;
|
|
12
|
+
hash: string;
|
|
13
|
+
nonce: string;
|
|
14
|
+
timeStamp: string;
|
|
15
|
+
to: string;
|
|
16
|
+
transactionIndex: string;
|
|
17
|
+
value: string;
|
|
18
|
+
}
|
|
19
|
+
export interface EtherscanTransactionMeta extends EtherscanTransactionMetaBase {
|
|
20
|
+
functionName: string;
|
|
21
|
+
input: string;
|
|
22
|
+
isError: string;
|
|
23
|
+
methodId: string;
|
|
24
|
+
txreceipt_status: string;
|
|
25
|
+
}
|
|
26
|
+
export interface EtherscanTokenTransactionMeta extends EtherscanTransactionMetaBase {
|
|
27
|
+
tokenDecimal: string;
|
|
28
|
+
tokenName: string;
|
|
29
|
+
tokenSymbol: string;
|
|
30
|
+
}
|
|
31
|
+
export interface EtherscanTransactionResponse<T extends EtherscanTransactionMetaBase> {
|
|
32
|
+
result: T[];
|
|
33
|
+
}
|
|
34
|
+
export interface EtherscanTransactionRequest {
|
|
35
|
+
address: string;
|
|
36
|
+
apiKey?: string;
|
|
37
|
+
chainId: Hex;
|
|
38
|
+
fromBlock?: number;
|
|
39
|
+
limit?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves transaction data from Etherscan.
|
|
43
|
+
*
|
|
44
|
+
* @param request - Configuration required to fetch transactions.
|
|
45
|
+
* @param request.address - Address to retrieve transactions for.
|
|
46
|
+
* @param request.apiKey - Etherscan API key.
|
|
47
|
+
* @param request.chainId - Current chain ID used to determine subdomain and domain.
|
|
48
|
+
* @param request.fromBlock - Block number to start fetching transactions from.
|
|
49
|
+
* @param request.limit - Number of transactions to retrieve.
|
|
50
|
+
* @returns An Etherscan response object containing the request status and an array of token transaction data.
|
|
51
|
+
*/
|
|
52
|
+
export declare function fetchEtherscanTransactions({ address, apiKey, chainId, fromBlock, limit, }: EtherscanTransactionRequest): Promise<EtherscanTransactionResponse<EtherscanTransactionMeta>>;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves token transaction data from Etherscan.
|
|
55
|
+
*
|
|
56
|
+
* @param request - Configuration required to fetch token transactions.
|
|
57
|
+
* @param request.address - Address to retrieve token transactions for.
|
|
58
|
+
* @param request.apiKey - Etherscan API key.
|
|
59
|
+
* @param request.chainId - Current chain ID used to determine subdomain and domain.
|
|
60
|
+
* @param request.fromBlock - Block number to start fetching token transactions from.
|
|
61
|
+
* @param request.limit - Number of token transactions to retrieve.
|
|
62
|
+
* @returns An Etherscan response object containing the request status and an array of token transaction data.
|
|
63
|
+
*/
|
|
64
|
+
export declare function fetchEtherscanTokenTransactions({ address, apiKey, chainId, fromBlock, limit, }: EtherscanTransactionRequest): Promise<EtherscanTransactionResponse<EtherscanTokenTransactionMeta>>;
|
|
65
|
+
//# sourceMappingURL=etherscan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"etherscan.d.ts","sourceRoot":"","sources":["../src/etherscan.ts"],"names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AC,EAC/C,OAAO,EACP,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,GACN,EAAE,2BAA2B,GAAG,OAAO,CACtC,4BAA4B,CAAC,wBAAwB,CAAC,CACvD,CAQA;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,+BAA+B,CAAC,EACpD,OAAO,EACP,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,GACN,EAAE,2BAA2B,GAAG,OAAO,CACtC,4BAA4B,CAAC,6BAA6B,CAAC,CAC5D,CAQA"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.fetchEtherscanTokenTransactions = exports.fetchEtherscanTransactions = void 0;
|
|
13
|
+
const controller_utils_1 = require("@metamask/controller-utils");
|
|
14
|
+
const constants_1 = require("./constants");
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves transaction data from Etherscan.
|
|
17
|
+
*
|
|
18
|
+
* @param request - Configuration required to fetch transactions.
|
|
19
|
+
* @param request.address - Address to retrieve transactions for.
|
|
20
|
+
* @param request.apiKey - Etherscan API key.
|
|
21
|
+
* @param request.chainId - Current chain ID used to determine subdomain and domain.
|
|
22
|
+
* @param request.fromBlock - Block number to start fetching transactions from.
|
|
23
|
+
* @param request.limit - Number of transactions to retrieve.
|
|
24
|
+
* @returns An Etherscan response object containing the request status and an array of token transaction data.
|
|
25
|
+
*/
|
|
26
|
+
function fetchEtherscanTransactions({ address, apiKey, chainId, fromBlock, limit, }) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
return yield fetchTransactions('txlist', {
|
|
29
|
+
address,
|
|
30
|
+
apiKey,
|
|
31
|
+
chainId,
|
|
32
|
+
fromBlock,
|
|
33
|
+
limit,
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.fetchEtherscanTransactions = fetchEtherscanTransactions;
|
|
38
|
+
/**
|
|
39
|
+
* Retrieves token transaction data from Etherscan.
|
|
40
|
+
*
|
|
41
|
+
* @param request - Configuration required to fetch token transactions.
|
|
42
|
+
* @param request.address - Address to retrieve token transactions for.
|
|
43
|
+
* @param request.apiKey - Etherscan API key.
|
|
44
|
+
* @param request.chainId - Current chain ID used to determine subdomain and domain.
|
|
45
|
+
* @param request.fromBlock - Block number to start fetching token transactions from.
|
|
46
|
+
* @param request.limit - Number of token transactions to retrieve.
|
|
47
|
+
* @returns An Etherscan response object containing the request status and an array of token transaction data.
|
|
48
|
+
*/
|
|
49
|
+
function fetchEtherscanTokenTransactions({ address, apiKey, chainId, fromBlock, limit, }) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
return yield fetchTransactions('tokentx', {
|
|
52
|
+
address,
|
|
53
|
+
apiKey,
|
|
54
|
+
chainId,
|
|
55
|
+
fromBlock,
|
|
56
|
+
limit,
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
exports.fetchEtherscanTokenTransactions = fetchEtherscanTokenTransactions;
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves transaction data from Etherscan from a specific endpoint.
|
|
63
|
+
*
|
|
64
|
+
* @param action - The Etherscan endpoint to use.
|
|
65
|
+
* @param options - Options bag.
|
|
66
|
+
* @param options.address - Address to retrieve transactions for.
|
|
67
|
+
* @param options.apiKey - Etherscan API key.
|
|
68
|
+
* @param options.chainId - Current chain ID used to determine subdomain and domain.
|
|
69
|
+
* @param options.fromBlock - Block number to start fetching transactions from.
|
|
70
|
+
* @param options.limit - Number of transactions to retrieve.
|
|
71
|
+
* @returns An object containing the request status and an array of transaction data.
|
|
72
|
+
*/
|
|
73
|
+
function fetchTransactions(action, { address, apiKey, chainId, fromBlock, limit, }) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const urlParams = {
|
|
76
|
+
module: 'account',
|
|
77
|
+
address,
|
|
78
|
+
startBlock: fromBlock === null || fromBlock === void 0 ? void 0 : fromBlock.toString(),
|
|
79
|
+
apikey: apiKey,
|
|
80
|
+
offset: limit === null || limit === void 0 ? void 0 : limit.toString(),
|
|
81
|
+
order: 'desc',
|
|
82
|
+
};
|
|
83
|
+
const etherscanTxUrl = getEtherscanApiUrl(chainId, Object.assign(Object.assign({}, urlParams), { action }));
|
|
84
|
+
const response = (yield (0, controller_utils_1.handleFetch)(etherscanTxUrl));
|
|
85
|
+
if (response.status === '0' && response.message === 'NOTOK') {
|
|
86
|
+
throw new Error(`Etherscan request failed - ${response.result}`);
|
|
87
|
+
}
|
|
88
|
+
return { result: response.result };
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Return a URL that can be used to fetch data from Etherscan.
|
|
93
|
+
*
|
|
94
|
+
* @param chainId - Current chain ID used to determine subdomain and domain.
|
|
95
|
+
* @param urlParams - The parameters used to construct the URL.
|
|
96
|
+
* @returns URL to access Etherscan data.
|
|
97
|
+
*/
|
|
98
|
+
function getEtherscanApiUrl(chainId, urlParams) {
|
|
99
|
+
const networkInfo = constants_1.ETHERSCAN_SUPPORTED_NETWORKS[chainId];
|
|
100
|
+
if (!networkInfo) {
|
|
101
|
+
throw new Error(`Etherscan does not support chain with ID: ${chainId}`);
|
|
102
|
+
}
|
|
103
|
+
const apiUrl = `https://${networkInfo.subdomain}.${networkInfo.domain}`;
|
|
104
|
+
let url = `${apiUrl}/api?`;
|
|
105
|
+
// eslint-disable-next-line guard-for-in
|
|
106
|
+
for (const paramKey in urlParams) {
|
|
107
|
+
const value = urlParams[paramKey];
|
|
108
|
+
if (!value) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
url += `${paramKey}=${value}&`;
|
|
112
|
+
}
|
|
113
|
+
url += 'tag=latest&page=1';
|
|
114
|
+
return url;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=etherscan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"etherscan.js","sourceRoot":"","sources":["../src/etherscan.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAAyD;AAGzD,2CAA2D;AAuD3D;;;;;;;;;;GAUG;AACH,SAAsB,0BAA0B,CAAC,EAC/C,OAAO,EACP,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,GACuB;;QAG5B,OAAO,MAAM,iBAAiB,CAAC,QAAQ,EAAE;YACvC,OAAO;YACP,MAAM;YACN,OAAO;YACP,SAAS;YACT,KAAK;SACN,CAAC,CAAC;IACL,CAAC;CAAA;AAhBD,gEAgBC;AAED;;;;;;;;;;GAUG;AACH,SAAsB,+BAA+B,CAAC,EACpD,OAAO,EACP,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,GACuB;;QAG5B,OAAO,MAAM,iBAAiB,CAAC,SAAS,EAAE;YACxC,OAAO;YACP,MAAM;YACN,OAAO;YACP,SAAS;YACT,KAAK;SACN,CAAC,CAAC;IACL,CAAC;CAAA;AAhBD,0EAgBC;AAED;;;;;;;;;;;GAWG;AACH,SAAe,iBAAiB,CAC9B,MAAc,EACd,EACE,OAAO,EACP,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,GAON;;QAED,MAAM,SAAS,GAAG;YAChB,MAAM,EAAE,SAAS;YACjB,OAAO;YACP,UAAU,EAAE,SAAS,aAAT,SA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} from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { ETHERSCAN_SUPPORTED_NETWORKS } from './constants';\n\nexport interface EtherscanTransactionMetaBase {\n blockNumber: string;\n blockHash: string;\n confirmations: string;\n contractAddress: string;\n cumulativeGasUsed: string;\n from: string;\n gas: string;\n gasPrice: string;\n gasUsed: string;\n hash: string;\n nonce: string;\n timeStamp: string;\n to: string;\n transactionIndex: string;\n value: string;\n}\n\nexport interface EtherscanTransactionMeta extends EtherscanTransactionMetaBase {\n functionName: string;\n input: string;\n isError: string;\n methodId: string;\n txreceipt_status: string;\n}\n\nexport interface EtherscanTokenTransactionMeta\n extends EtherscanTransactionMetaBase {\n tokenDecimal: string;\n tokenName: string;\n tokenSymbol: string;\n}\n\nexport interface EtherscanTransactionResponse<\n T extends EtherscanTransactionMetaBase,\n> {\n result: T[];\n}\n\nexport interface EtherscanTransactionRequest {\n address: string;\n apiKey?: string;\n chainId: Hex;\n fromBlock?: number;\n limit?: number;\n}\n\ninterface RawEtherscanResponse<T extends EtherscanTransactionMetaBase> {\n status: '0' | '1';\n message: string;\n result: string | T[];\n}\n\n/**\n * Retrieves transaction data from Etherscan.\n *\n * @param request - Configuration required to fetch transactions.\n * @param request.address - Address to retrieve transactions for.\n * @param request.apiKey - Etherscan API key.\n * @param request.chainId - Current chain ID used to determine subdomain and domain.\n * @param request.fromBlock - Block number to start fetching transactions from.\n * @param request.limit - Number of transactions to retrieve.\n * @returns An Etherscan response object containing the request status and an array of token transaction data.\n */\nexport async function fetchEtherscanTransactions({\n address,\n apiKey,\n chainId,\n fromBlock,\n limit,\n}: EtherscanTransactionRequest): Promise<\n EtherscanTransactionResponse<EtherscanTransactionMeta>\n> {\n return await fetchTransactions('txlist', {\n address,\n apiKey,\n chainId,\n fromBlock,\n limit,\n });\n}\n\n/**\n * Retrieves token transaction data from Etherscan.\n *\n * @param request - Configuration required to fetch token transactions.\n * @param request.address - Address to retrieve token transactions for.\n * @param request.apiKey - Etherscan API key.\n * @param request.chainId - Current chain ID used to determine subdomain and domain.\n * @param request.fromBlock - Block number to start fetching token transactions from.\n * @param request.limit - Number of token transactions to retrieve.\n * @returns An Etherscan response object containing the request status and an array of token transaction data.\n */\nexport async function fetchEtherscanTokenTransactions({\n address,\n apiKey,\n chainId,\n fromBlock,\n limit,\n}: EtherscanTransactionRequest): Promise<\n EtherscanTransactionResponse<EtherscanTokenTransactionMeta>\n> {\n return await fetchTransactions('tokentx', {\n address,\n apiKey,\n chainId,\n fromBlock,\n limit,\n });\n}\n\n/**\n * Retrieves transaction data from Etherscan from a specific endpoint.\n *\n * @param action - The Etherscan endpoint to use.\n * @param options - Options bag.\n * @param options.address - Address to retrieve transactions for.\n * @param options.apiKey - Etherscan API key.\n * @param options.chainId - Current chain ID used to determine subdomain and domain.\n * @param options.fromBlock - Block number to start fetching transactions from.\n * @param options.limit - Number of transactions to retrieve.\n * @returns An object containing the request status and an array of transaction data.\n */\nasync function fetchTransactions<T extends EtherscanTransactionMetaBase>(\n action: string,\n {\n address,\n apiKey,\n chainId,\n fromBlock,\n limit,\n }: {\n address: string;\n apiKey?: string;\n chainId: Hex;\n fromBlock?: number;\n limit?: number;\n },\n): Promise<EtherscanTransactionResponse<T>> {\n const urlParams = {\n module: 'account',\n address,\n startBlock: fromBlock?.toString(),\n apikey: apiKey,\n offset: limit?.toString(),\n order: 'desc',\n };\n\n const etherscanTxUrl = getEtherscanApiUrl(chainId, {\n ...urlParams,\n action,\n });\n\n const response = (await handleFetch(\n etherscanTxUrl,\n )) as RawEtherscanResponse<T>;\n\n if (response.status === '0' && response.message === 'NOTOK') {\n throw new Error(`Etherscan request failed - ${response.result}`);\n }\n\n return { result: response.result as T[] };\n}\n\n/**\n * Return a URL that can be used to fetch data from Etherscan.\n *\n * @param chainId - Current chain ID used to determine subdomain and domain.\n * @param urlParams - The parameters used to construct the URL.\n * @returns URL to access Etherscan data.\n */\nfunction getEtherscanApiUrl(\n chainId: Hex,\n urlParams: Record<string, string | undefined>,\n): string {\n type SupportedChainId = keyof typeof ETHERSCAN_SUPPORTED_NETWORKS;\n\n const networkInfo = ETHERSCAN_SUPPORTED_NETWORKS[chainId as SupportedChainId];\n\n if (!networkInfo) {\n throw new Error(`Etherscan does not support chain with ID: ${chainId}`);\n }\n\n const apiUrl = `https://${networkInfo.subdomain}.${networkInfo.domain}`;\n let url = `${apiUrl}/api?`;\n\n // eslint-disable-next-line guard-for-in\n for (const paramKey in urlParams) {\n const value = urlParams[paramKey];\n\n if (!value) {\n continue;\n }\n\n url += `${paramKey}=${value}&`;\n }\n\n url += 'tag=latest&page=1';\n\n return url;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -18,4 +18,5 @@ exports.isEIP1559Transaction = void 0;
|
|
|
18
18
|
__exportStar(require("./TransactionController"), exports);
|
|
19
19
|
var utils_1 = require("./utils");
|
|
20
20
|
Object.defineProperty(exports, "isEIP1559Transaction", { enumerable: true, get: function () { return utils_1.isEIP1559Transaction; } });
|
|
21
|
+
__exportStar(require("./types"), exports);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0DAAwC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0DAAwC;AAExC,iCAA+C;AAAtC,6GAAA,oBAAoB,OAAA;AAC7B,0CAAwB","sourcesContent":["export * from './TransactionController';\nexport type { EtherscanTransactionMeta } from './etherscan';\nexport { isEIP1559Transaction } from './utils';\nexport * from './types';\n"]}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import type { Hex } from '@metamask/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Representation of transaction metadata.
|
|
4
|
+
*/
|
|
5
|
+
export declare type TransactionMeta = ({
|
|
6
|
+
status: Exclude<TransactionStatus, TransactionStatus.failed>;
|
|
7
|
+
} & TransactionMetaBase) | ({
|
|
8
|
+
status: TransactionStatus.failed;
|
|
9
|
+
error: Error;
|
|
10
|
+
} & TransactionMetaBase);
|
|
11
|
+
/**
|
|
12
|
+
* Information about a single transaction such as status and block number.
|
|
13
|
+
*/
|
|
14
|
+
declare type TransactionMetaBase = {
|
|
15
|
+
/**
|
|
16
|
+
* Base fee of the block as a hex value, introduced in EIP-1559.
|
|
17
|
+
*/
|
|
18
|
+
baseFeePerGas?: Hex;
|
|
19
|
+
/**
|
|
20
|
+
* Number of the block where the transaction has been included.
|
|
21
|
+
*/
|
|
22
|
+
blockNumber?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Network code as per EIP-155 for this transaction.
|
|
25
|
+
*/
|
|
26
|
+
chainId?: Hex;
|
|
27
|
+
/**
|
|
28
|
+
* Gas values provided by the dApp.
|
|
29
|
+
*/
|
|
30
|
+
dappSuggestedGasFees?: DappSuggestedGasFees;
|
|
31
|
+
/**
|
|
32
|
+
* String to indicate what device the transaction was confirmed on.
|
|
33
|
+
*/
|
|
34
|
+
deviceConfirmedOn?: WalletDevice;
|
|
35
|
+
/**
|
|
36
|
+
* Generated UUID associated with this transaction.
|
|
37
|
+
*/
|
|
38
|
+
id: string;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the transaction is a transfer.
|
|
41
|
+
*/
|
|
42
|
+
isTransfer?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Network code as per EIP-155 for this transaction.
|
|
45
|
+
*/
|
|
46
|
+
networkID?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Origin this transaction was sent from.
|
|
49
|
+
*/
|
|
50
|
+
origin?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Hex representation of the underlying transaction.
|
|
53
|
+
*/
|
|
54
|
+
rawTransaction?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Timestamp associated with this transaction.
|
|
57
|
+
*/
|
|
58
|
+
time: number;
|
|
59
|
+
/**
|
|
60
|
+
* Whether transaction recipient is a smart contract.
|
|
61
|
+
*/
|
|
62
|
+
toSmartContract?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Underlying Transaction object.
|
|
65
|
+
*/
|
|
66
|
+
transaction: Transaction;
|
|
67
|
+
/**
|
|
68
|
+
* Hash of a successful transaction.
|
|
69
|
+
*/
|
|
70
|
+
transactionHash?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Additional transfer information.
|
|
73
|
+
*/
|
|
74
|
+
transferInformation?: {
|
|
75
|
+
contractAddress: string;
|
|
76
|
+
decimals: number;
|
|
77
|
+
symbol: string;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Transaction receipt.
|
|
81
|
+
*/
|
|
82
|
+
txReceipt?: TransactionReceipt;
|
|
83
|
+
/**
|
|
84
|
+
* Whether the transaction is verified on the blockchain.
|
|
85
|
+
*/
|
|
86
|
+
verifiedOnBlockchain?: boolean;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* The status of the transaction. Each status represents the state of the transaction internally
|
|
90
|
+
* in the wallet. Some of these correspond with the state of the transaction on the network, but
|
|
91
|
+
* some are wallet-specific.
|
|
92
|
+
*/
|
|
93
|
+
export declare enum TransactionStatus {
|
|
94
|
+
approved = "approved",
|
|
95
|
+
cancelled = "cancelled",
|
|
96
|
+
confirmed = "confirmed",
|
|
97
|
+
failed = "failed",
|
|
98
|
+
rejected = "rejected",
|
|
99
|
+
signed = "signed",
|
|
100
|
+
submitted = "submitted",
|
|
101
|
+
unapproved = "unapproved"
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Options for wallet device.
|
|
105
|
+
*/
|
|
106
|
+
export declare enum WalletDevice {
|
|
107
|
+
MM_MOBILE = "metamask_mobile",
|
|
108
|
+
MM_EXTENSION = "metamask_extension",
|
|
109
|
+
OTHER = "other_device"
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Standard data concerning a transaction to be processed by the blockchain.
|
|
113
|
+
*/
|
|
114
|
+
export interface Transaction {
|
|
115
|
+
/**
|
|
116
|
+
* Network ID as per EIP-155.
|
|
117
|
+
*/
|
|
118
|
+
chainId?: Hex;
|
|
119
|
+
/**
|
|
120
|
+
* Data to pass with this transaction.
|
|
121
|
+
*/
|
|
122
|
+
data?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Error message for gas estimation failure.
|
|
125
|
+
*/
|
|
126
|
+
estimateGasError?: string;
|
|
127
|
+
/**
|
|
128
|
+
* Estimated base fee for this transaction.
|
|
129
|
+
*/
|
|
130
|
+
estimatedBaseFee?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Address to send this transaction from.
|
|
133
|
+
*/
|
|
134
|
+
from: string;
|
|
135
|
+
/**
|
|
136
|
+
* Gas to send with this transaction.
|
|
137
|
+
*/
|
|
138
|
+
gas?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Price of gas with this transaction.
|
|
141
|
+
*/
|
|
142
|
+
gasPrice?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Gas used in the transaction.
|
|
145
|
+
*/
|
|
146
|
+
gasUsed?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Maximum fee per gas for this transaction.
|
|
149
|
+
*/
|
|
150
|
+
maxFeePerGas?: string;
|
|
151
|
+
/**
|
|
152
|
+
* Maximum priority fee per gas for this transaction.
|
|
153
|
+
*/
|
|
154
|
+
maxPriorityFeePerGas?: string;
|
|
155
|
+
/**
|
|
156
|
+
* Unique number to prevent replay attacks.
|
|
157
|
+
*/
|
|
158
|
+
nonce?: string;
|
|
159
|
+
/**
|
|
160
|
+
* Address to send this transaction to.
|
|
161
|
+
*/
|
|
162
|
+
to?: string;
|
|
163
|
+
/**
|
|
164
|
+
* Value associated with this transaction.
|
|
165
|
+
*/
|
|
166
|
+
value?: string;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Standard data concerning a transaction processed by the blockchain.
|
|
170
|
+
*/
|
|
171
|
+
export interface TransactionReceipt {
|
|
172
|
+
/**
|
|
173
|
+
* The block hash of the block that this transaction was included in.
|
|
174
|
+
*/
|
|
175
|
+
blockHash?: string;
|
|
176
|
+
/**
|
|
177
|
+
* The block number of the block that this transaction was included in.
|
|
178
|
+
*/
|
|
179
|
+
blockNumber?: string;
|
|
180
|
+
/**
|
|
181
|
+
* Effective gas price the transaction was charged at.
|
|
182
|
+
*/
|
|
183
|
+
effectiveGasPrice?: string;
|
|
184
|
+
/**
|
|
185
|
+
* Gas used in the transaction.
|
|
186
|
+
*/
|
|
187
|
+
gasUsed?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Total used gas in hex.
|
|
190
|
+
*/
|
|
191
|
+
l1Fee?: string;
|
|
192
|
+
/**
|
|
193
|
+
* All the logs emitted by this transaction.
|
|
194
|
+
*/
|
|
195
|
+
logs?: Log[];
|
|
196
|
+
/**
|
|
197
|
+
* The status of the transaction.
|
|
198
|
+
*/
|
|
199
|
+
status?: string;
|
|
200
|
+
/**
|
|
201
|
+
* The index of this transaction in the list of transactions included in the block this transaction was mined in.
|
|
202
|
+
*/
|
|
203
|
+
transactionIndex?: number;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Represents an event that has been included in a transaction using the EVM `LOG` opcode.
|
|
207
|
+
*/
|
|
208
|
+
export interface Log {
|
|
209
|
+
/**
|
|
210
|
+
* Address of the contract that generated log.
|
|
211
|
+
*/
|
|
212
|
+
address?: string;
|
|
213
|
+
/**
|
|
214
|
+
* List of topics for log.
|
|
215
|
+
*/
|
|
216
|
+
topics?: string;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* The configuration required to fetch transaction data from a RemoteTransactionSource.
|
|
220
|
+
*/
|
|
221
|
+
export interface RemoteTransactionSourceRequest {
|
|
222
|
+
/**
|
|
223
|
+
* The address of the account to fetch transactions for.
|
|
224
|
+
*/
|
|
225
|
+
address: string;
|
|
226
|
+
/**
|
|
227
|
+
* API key if required by the remote source.
|
|
228
|
+
*/
|
|
229
|
+
apiKey?: string;
|
|
230
|
+
/**
|
|
231
|
+
* The chainId of the current network.
|
|
232
|
+
*/
|
|
233
|
+
currentChainId: Hex;
|
|
234
|
+
/**
|
|
235
|
+
* The networkId of the current network.
|
|
236
|
+
*/
|
|
237
|
+
currentNetworkId: string;
|
|
238
|
+
/**
|
|
239
|
+
* Block number to start fetching transactions from.
|
|
240
|
+
*/
|
|
241
|
+
fromBlock?: number;
|
|
242
|
+
/**
|
|
243
|
+
* Maximum number of transactions to retrieve.
|
|
244
|
+
*/
|
|
245
|
+
limit?: number;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* An object capable of fetching transaction data from a remote source.
|
|
249
|
+
* Used by the IncomingTransactionHelper to retrieve remote transaction data.
|
|
250
|
+
*/
|
|
251
|
+
export interface RemoteTransactionSource {
|
|
252
|
+
isSupportedNetwork: (chainId: Hex, networkId: string) => boolean;
|
|
253
|
+
fetchTransactions: (request: RemoteTransactionSourceRequest) => Promise<TransactionMeta[]>;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Gas values initially suggested by the dApp.
|
|
257
|
+
*/
|
|
258
|
+
export interface DappSuggestedGasFees {
|
|
259
|
+
gas?: string;
|
|
260
|
+
gasPrice?: string;
|
|
261
|
+
maxFeePerGas?: string;
|
|
262
|
+
maxPriorityFeePerGas?: string;
|
|
263
|
+
}
|
|
264
|
+
export {};
|
|
265
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;GAEG;AACH,oBAAY,eAAe,GACvB,CAAC;IACC,MAAM,EAAE,OAAO,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;CAC9D,GAAG,mBAAmB,CAAC,GACxB,CAAC;IAAE,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAAG,mBAAmB,CAAC,CAAC;AAE/E;;GAEG;AACH,aAAK,mBAAmB,GAAG;IACzB;;OAEG;IACH,aAAa,CAAC,EAAE,GAAG,CAAC;IAEpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,GAAG,CAAC;IAEd;;OAEG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAE5C;;OAEG;IACH,iBAAiB,CAAC,EAAE,YAAY,CAAC;IAEjC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;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AAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WalletDevice = exports.TransactionStatus = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The status of the transaction. Each status represents the state of the transaction internally
|
|
6
|
+
* in the wallet. Some of these correspond with the state of the transaction on the network, but
|
|
7
|
+
* some are wallet-specific.
|
|
8
|
+
*/
|
|
9
|
+
var TransactionStatus;
|
|
10
|
+
(function (TransactionStatus) {
|
|
11
|
+
TransactionStatus["approved"] = "approved";
|
|
12
|
+
TransactionStatus["cancelled"] = "cancelled";
|
|
13
|
+
TransactionStatus["confirmed"] = "confirmed";
|
|
14
|
+
TransactionStatus["failed"] = "failed";
|
|
15
|
+
TransactionStatus["rejected"] = "rejected";
|
|
16
|
+
TransactionStatus["signed"] = "signed";
|
|
17
|
+
TransactionStatus["submitted"] = "submitted";
|
|
18
|
+
TransactionStatus["unapproved"] = "unapproved";
|
|
19
|
+
})(TransactionStatus = exports.TransactionStatus || (exports.TransactionStatus = {}));
|
|
20
|
+
/**
|
|
21
|
+
* Options for wallet device.
|
|
22
|
+
*/
|
|
23
|
+
var WalletDevice;
|
|
24
|
+
(function (WalletDevice) {
|
|
25
|
+
WalletDevice["MM_MOBILE"] = "metamask_mobile";
|
|
26
|
+
WalletDevice["MM_EXTENSION"] = "metamask_extension";
|
|
27
|
+
WalletDevice["OTHER"] = "other_device";
|
|
28
|
+
})(WalletDevice = exports.WalletDevice || (exports.WalletDevice = {}));
|
|
29
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAyGA;;;;GAIG;AACH,IAAY,iBASX;AATD,WAAY,iBAAiB;IAC3B,0CAAqB,CAAA;IACrB,4CAAuB,CAAA;IACvB,4CAAuB,CAAA;IACvB,sCAAiB,CAAA;IACjB,0CAAqB,CAAA;IACrB,sCAAiB,CAAA;IACjB,4CAAuB,CAAA;IACvB,8CAAyB,CAAA;AAC3B,CAAC,EATW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAS5B;AAED;;GAEG;AACH,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,6CAA6B,CAAA;IAC7B,mDAAmC,CAAA;IACnC,sCAAsB,CAAA;AACxB,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n/**\n * Representation of transaction metadata.\n */\nexport type TransactionMeta =\n | ({\n status: Exclude<TransactionStatus, TransactionStatus.failed>;\n } & TransactionMetaBase)\n | ({ status: TransactionStatus.failed; error: Error } & TransactionMetaBase);\n\n/**\n * Information about a single transaction such as status and block number.\n */\ntype TransactionMetaBase = {\n /**\n * Base fee of the block as a hex value, introduced in EIP-1559.\n */\n baseFeePerGas?: Hex;\n\n /**\n * Number of the block where the transaction has been included.\n */\n blockNumber?: string;\n\n /**\n * Network code as per EIP-155 for this transaction.\n */\n chainId?: Hex;\n\n /**\n * Gas values provided by the dApp.\n */\n dappSuggestedGasFees?: DappSuggestedGasFees;\n\n /**\n * String to indicate what device the transaction was confirmed on.\n */\n deviceConfirmedOn?: WalletDevice;\n\n /**\n * Generated UUID associated with this transaction.\n */\n id: string;\n\n /**\n * Whether the transaction is a transfer.\n */\n isTransfer?: boolean;\n\n /**\n * Network code as per EIP-155 for this transaction.\n */\n networkID?: string;\n\n /**\n * Origin this transaction was sent from.\n */\n origin?: string;\n\n /**\n * Hex representation of the underlying transaction.\n */\n rawTransaction?: string;\n\n /**\n * Timestamp associated with this transaction.\n */\n time: number;\n\n /**\n * Whether transaction recipient is a smart contract.\n */\n toSmartContract?: boolean;\n\n /**\n * Underlying Transaction object.\n */\n transaction: Transaction;\n\n /**\n * Hash of a successful transaction.\n */\n transactionHash?: string;\n\n /**\n * Additional transfer information.\n */\n transferInformation?: {\n contractAddress: string;\n decimals: number;\n symbol: string;\n };\n\n /**\n * Transaction receipt.\n */\n txReceipt?: TransactionReceipt;\n\n /**\n * Whether the transaction is verified on the blockchain.\n */\n verifiedOnBlockchain?: boolean;\n};\n\n/**\n * The status of the transaction. Each status represents the state of the transaction internally\n * in the wallet. Some of these correspond with the state of the transaction on the network, but\n * some are wallet-specific.\n */\nexport enum TransactionStatus {\n approved = 'approved',\n cancelled = 'cancelled',\n confirmed = 'confirmed',\n failed = 'failed',\n rejected = 'rejected',\n signed = 'signed',\n submitted = 'submitted',\n unapproved = 'unapproved',\n}\n\n/**\n * Options for wallet device.\n */\nexport enum WalletDevice {\n MM_MOBILE = 'metamask_mobile',\n MM_EXTENSION = 'metamask_extension',\n OTHER = 'other_device',\n}\n\n/**\n * Standard data concerning a transaction to be processed by the blockchain.\n */\nexport interface Transaction {\n /**\n * Network ID as per EIP-155.\n */\n chainId?: Hex;\n\n /**\n * Data to pass with this transaction.\n */\n data?: string;\n\n /**\n * Error message for gas estimation failure.\n */\n estimateGasError?: string;\n\n /**\n * Estimated base fee for this transaction.\n */\n estimatedBaseFee?: string;\n\n /**\n * Address to send this transaction from.\n */\n from: string;\n\n /**\n * Gas to send with this transaction.\n */\n gas?: string;\n\n /**\n * Price of gas with this transaction.\n */\n gasPrice?: string;\n\n /**\n * Gas used in the transaction.\n */\n gasUsed?: string;\n\n /**\n * Maximum fee per gas for this transaction.\n */\n maxFeePerGas?: string;\n\n /**\n * Maximum priority fee per gas for this transaction.\n */\n maxPriorityFeePerGas?: string;\n\n /**\n * Unique number to prevent replay attacks.\n */\n nonce?: string;\n\n /**\n * Address to send this transaction to.\n */\n to?: string;\n\n /**\n * Value associated with this transaction.\n */\n value?: string;\n}\n\n/**\n * Standard data concerning a transaction processed by the blockchain.\n */\nexport interface TransactionReceipt {\n /**\n * The block hash of the block that this transaction was included in.\n */\n blockHash?: string;\n\n /**\n * The block number of the block that this transaction was included in.\n */\n blockNumber?: string;\n\n /**\n * Effective gas price the transaction was charged at.\n */\n effectiveGasPrice?: string;\n\n /**\n * Gas used in the transaction.\n */\n gasUsed?: string;\n\n /**\n * Total used gas in hex.\n */\n l1Fee?: string;\n\n /**\n * All the logs emitted by this transaction.\n */\n logs?: Log[];\n\n /**\n * The status of the transaction.\n */\n status?: string;\n\n /**\n * The index of this transaction in the list of transactions included in the block this transaction was mined in.\n */\n transactionIndex?: number;\n}\n\n/**\n * Represents an event that has been included in a transaction using the EVM `LOG` opcode.\n */\nexport interface Log {\n /**\n * Address of the contract that generated log.\n */\n address?: string;\n /**\n * List of topics for log.\n */\n topics?: string;\n}\n\n/**\n * The configuration required to fetch transaction data from a RemoteTransactionSource.\n */\nexport interface RemoteTransactionSourceRequest {\n /**\n * The address of the account to fetch transactions for.\n */\n address: string;\n\n /**\n * API key if required by the remote source.\n */\n apiKey?: string;\n\n /**\n * The chainId of the current network.\n */\n currentChainId: Hex;\n\n /**\n * The networkId of the current network.\n */\n currentNetworkId: string;\n\n /**\n * Block number to start fetching transactions from.\n */\n fromBlock?: number;\n\n /**\n * Maximum number of transactions to retrieve.\n */\n limit?: number;\n}\n\n/**\n * An object capable of fetching transaction data from a remote source.\n * Used by the IncomingTransactionHelper to retrieve remote transaction data.\n */\nexport interface RemoteTransactionSource {\n isSupportedNetwork: (chainId: Hex, networkId: string) => boolean;\n\n fetchTransactions: (\n request: RemoteTransactionSourceRequest,\n ) => Promise<TransactionMeta[]>;\n}\n\n/**\n * Gas values initially suggested by the dApp.\n */\nexport interface DappSuggestedGasFees {\n gas?: string;\n gasPrice?: string;\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n}\n"]}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
+
import type { Hex } from '@metamask/utils';
|
|
1
2
|
import type { Transaction as NonceTrackerTransaction } from 'nonce-tracker/dist/NonceTracker';
|
|
2
|
-
import type {
|
|
3
|
+
import type { GasPriceValue, FeeMarketEIP1559Values } from './TransactionController';
|
|
4
|
+
import type { Transaction, TransactionMeta, TransactionStatus } from './types';
|
|
3
5
|
export declare const ESTIMATE_GAS_ERROR = "eth_estimateGas rpc method error";
|
|
4
|
-
/**
|
|
5
|
-
* Return a URL that can be used to fetch ETH transactions.
|
|
6
|
-
*
|
|
7
|
-
* @param networkType - Network type of desired network.
|
|
8
|
-
* @param urlParams - The parameters used to construct the URL.
|
|
9
|
-
* @returns URL to fetch the access the endpoint.
|
|
10
|
-
*/
|
|
11
|
-
export declare function getEtherscanApiUrl(networkType: string, urlParams: any): string;
|
|
12
6
|
/**
|
|
13
7
|
* Normalizes properties on a Transaction object.
|
|
14
8
|
*
|
|
@@ -31,20 +25,6 @@ export declare function validateTransaction(transaction: Transaction): void;
|
|
|
31
25
|
* @returns Boolean that is true if the transaction is EIP-1559 (has maxFeePerGas and maxPriorityFeePerGas), otherwise returns false.
|
|
32
26
|
*/
|
|
33
27
|
export declare const isEIP1559Transaction: (transaction: Transaction) => boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Handles the fetch of incoming transactions.
|
|
36
|
-
*
|
|
37
|
-
* @param networkType - Network type of desired network.
|
|
38
|
-
* @param address - Address to get the transactions from.
|
|
39
|
-
* @param txHistoryLimit - The maximum number of transactions to fetch.
|
|
40
|
-
* @param opt - Object that can contain fromBlock and Etherscan service API key.
|
|
41
|
-
* @returns Responses for both ETH and ERC20 token transactions.
|
|
42
|
-
*/
|
|
43
|
-
export declare function handleTransactionFetch(networkType: string, address: string, txHistoryLimit: number, opt?: FetchAllOptions): Promise<[{
|
|
44
|
-
[result: string]: [];
|
|
45
|
-
}, {
|
|
46
|
-
[result: string]: [];
|
|
47
|
-
}]>;
|
|
48
28
|
export declare const validateGasValues: (gasValues: GasPriceValue | FeeMarketEIP1559Values) => void;
|
|
49
29
|
export declare const isFeeMarketEIP1559Values: (gasValues?: GasPriceValue | FeeMarketEIP1559Values | undefined) => gasValues is FeeMarketEIP1559Values;
|
|
50
30
|
export declare const isGasPriceValue: (gasValues?: GasPriceValue | FeeMarketEIP1559Values | undefined) => gasValues is GasPriceValue;
|
|
@@ -68,4 +48,14 @@ export declare function validateMinimumIncrease(proposed: string, min: string):
|
|
|
68
48
|
* @returns Array of transactions formatted for the nonce tracker.
|
|
69
49
|
*/
|
|
70
50
|
export declare function getAndFormatTransactionsForNonceTracker(fromAddress: string, transactionStatus: TransactionStatus, transactions: TransactionMeta[]): NonceTrackerTransaction[];
|
|
51
|
+
/**
|
|
52
|
+
* Checks whether a given transaction matches the specified network or chain ID.
|
|
53
|
+
* This function is used to determine if a transaction is relevant to the current network or chain.
|
|
54
|
+
*
|
|
55
|
+
* @param transaction - The transaction metadata to check.
|
|
56
|
+
* @param chainId - The chain ID of the current network.
|
|
57
|
+
* @param networkId - The network ID of the current network.
|
|
58
|
+
* @returns A boolean value indicating whether the transaction matches the current network or chain ID.
|
|
59
|
+
*/
|
|
60
|
+
export declare function transactionMatchesNetwork(transaction: TransactionMeta, chainId: Hex, networkId: string | null): boolean;
|
|
71
61
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,IAAI,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE9F,OAAO,KAAK,EACV,aAAa,EACb,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAA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