@metamask/transaction-controller 41.1.0 → 42.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/CHANGELOG.md +40 -1
- package/dist/TransactionController.cjs +57 -51
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +72 -13
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +72 -13
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +57 -51
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/api/accounts-api.cjs +48 -3
- package/dist/api/accounts-api.cjs.map +1 -1
- package/dist/api/accounts-api.d.cts +49 -0
- package/dist/api/accounts-api.d.cts.map +1 -1
- package/dist/api/accounts-api.d.mts +49 -0
- package/dist/api/accounts-api.d.mts.map +1 -1
- package/dist/api/accounts-api.mjs +46 -2
- package/dist/api/accounts-api.mjs.map +1 -1
- package/dist/constants.cjs +1 -85
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +0 -84
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +0 -84
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +0 -84
- package/dist/constants.mjs.map +1 -1
- package/dist/helpers/AccountsApiRemoteTransactionSource.cjs +183 -0
- package/dist/helpers/AccountsApiRemoteTransactionSource.cjs.map +1 -0
- package/dist/helpers/AccountsApiRemoteTransactionSource.d.cts +12 -0
- package/dist/helpers/AccountsApiRemoteTransactionSource.d.cts.map +1 -0
- package/dist/helpers/AccountsApiRemoteTransactionSource.d.mts +12 -0
- package/dist/helpers/AccountsApiRemoteTransactionSource.d.mts.map +1 -0
- package/dist/helpers/AccountsApiRemoteTransactionSource.mjs +183 -0
- package/dist/helpers/AccountsApiRemoteTransactionSource.mjs.map +1 -0
- package/dist/helpers/IncomingTransactionHelper.cjs +90 -142
- package/dist/helpers/IncomingTransactionHelper.cjs.map +1 -1
- package/dist/helpers/IncomingTransactionHelper.d.cts +10 -16
- package/dist/helpers/IncomingTransactionHelper.d.cts.map +1 -1
- package/dist/helpers/IncomingTransactionHelper.d.mts +10 -16
- package/dist/helpers/IncomingTransactionHelper.d.mts.map +1 -1
- package/dist/helpers/IncomingTransactionHelper.mjs +91 -143
- package/dist/helpers/IncomingTransactionHelper.mjs.map +1 -1
- package/dist/helpers/MultichainTrackingHelper.cjs +23 -70
- package/dist/helpers/MultichainTrackingHelper.cjs.map +1 -1
- package/dist/helpers/MultichainTrackingHelper.d.cts +1 -14
- package/dist/helpers/MultichainTrackingHelper.d.cts.map +1 -1
- package/dist/helpers/MultichainTrackingHelper.d.mts +1 -14
- package/dist/helpers/MultichainTrackingHelper.d.mts.map +1 -1
- package/dist/helpers/MultichainTrackingHelper.mjs +23 -70
- package/dist/helpers/MultichainTrackingHelper.mjs.map +1 -1
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +21 -14
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +21 -14
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/validation.cjs +6 -0
- package/dist/utils/validation.cjs.map +1 -1
- package/dist/utils/validation.d.cts.map +1 -1
- package/dist/utils/validation.d.mts.map +1 -1
- package/dist/utils/validation.mjs +6 -0
- package/dist/utils/validation.mjs.map +1 -1
- package/package.json +8 -8
- package/dist/helpers/EtherscanRemoteTransactionSource.cjs +0 -158
- package/dist/helpers/EtherscanRemoteTransactionSource.cjs.map +0 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.d.cts +0 -16
- package/dist/helpers/EtherscanRemoteTransactionSource.d.cts.map +0 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.d.mts +0 -16
- package/dist/helpers/EtherscanRemoteTransactionSource.d.mts.map +0 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.mjs +0 -158
- package/dist/helpers/EtherscanRemoteTransactionSource.mjs.map +0 -1
- package/dist/utils/etherscan.cjs +0 -116
- package/dist/utils/etherscan.cjs.map +0 -1
- package/dist/utils/etherscan.d.cts +0 -74
- package/dist/utils/etherscan.d.cts.map +0 -1
- package/dist/utils/etherscan.d.mts +0 -74
- package/dist/utils/etherscan.d.mts.map +0 -1
- package/dist/utils/etherscan.mjs +0 -110
- package/dist/utils/etherscan.mjs.map +0 -1
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
var _EtherscanRemoteTransactionSource_instances, _EtherscanRemoteTransactionSource_apiKeysByChainId, _EtherscanRemoteTransactionSource_includeTokenTransfers, _EtherscanRemoteTransactionSource_isTokenRequestPending, _EtherscanRemoteTransactionSource_mutex, _EtherscanRemoteTransactionSource_releaseLockAfterInterval, _EtherscanRemoteTransactionSource_fetchNormalTransactions, _EtherscanRemoteTransactionSource_fetchTokenTransactions, _EtherscanRemoteTransactionSource_getResponseTransactions, _EtherscanRemoteTransactionSource_normalizeTransaction, _EtherscanRemoteTransactionSource_normalizeTokenTransaction, _EtherscanRemoteTransactionSource_normalizeTransactionBase;
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.EtherscanRemoteTransactionSource = void 0;
|
|
19
|
-
const controller_utils_1 = require("@metamask/controller-utils");
|
|
20
|
-
const async_mutex_1 = require("async-mutex");
|
|
21
|
-
const bn_js_1 = __importDefault(require("bn.js"));
|
|
22
|
-
const uuid_1 = require("uuid");
|
|
23
|
-
const constants_1 = require("../constants.cjs");
|
|
24
|
-
const logger_1 = require("../logger.cjs");
|
|
25
|
-
const types_1 = require("../types.cjs");
|
|
26
|
-
const etherscan_1 = require("../utils/etherscan.cjs");
|
|
27
|
-
const ETHERSCAN_RATE_LIMIT_INTERVAL = 5000;
|
|
28
|
-
/**
|
|
29
|
-
* A RemoteTransactionSource that fetches transaction data from Etherscan.
|
|
30
|
-
*/
|
|
31
|
-
class EtherscanRemoteTransactionSource {
|
|
32
|
-
constructor({ apiKeysByChainId, includeTokenTransfers, } = {}) {
|
|
33
|
-
_EtherscanRemoteTransactionSource_instances.add(this);
|
|
34
|
-
_EtherscanRemoteTransactionSource_apiKeysByChainId.set(this, void 0);
|
|
35
|
-
_EtherscanRemoteTransactionSource_includeTokenTransfers.set(this, void 0);
|
|
36
|
-
_EtherscanRemoteTransactionSource_isTokenRequestPending.set(this, void 0);
|
|
37
|
-
_EtherscanRemoteTransactionSource_mutex.set(this, new async_mutex_1.Mutex());
|
|
38
|
-
_EtherscanRemoteTransactionSource_fetchNormalTransactions.set(this, async (request, etherscanRequest) => {
|
|
39
|
-
const { chainId } = request;
|
|
40
|
-
const etherscanTransactions = await (0, etherscan_1.fetchEtherscanTransactions)(etherscanRequest);
|
|
41
|
-
return __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_getResponseTransactions).call(this, etherscanTransactions).map((tx) => __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_normalizeTransaction).call(this, tx, chainId));
|
|
42
|
-
});
|
|
43
|
-
_EtherscanRemoteTransactionSource_fetchTokenTransactions.set(this, async (request, etherscanRequest) => {
|
|
44
|
-
const { chainId } = request;
|
|
45
|
-
const etherscanTransactions = await (0, etherscan_1.fetchEtherscanTokenTransactions)(etherscanRequest);
|
|
46
|
-
return __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_getResponseTransactions).call(this, etherscanTransactions).map((tx) => __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_normalizeTokenTransaction).call(this, tx, chainId));
|
|
47
|
-
});
|
|
48
|
-
__classPrivateFieldSet(this, _EtherscanRemoteTransactionSource_apiKeysByChainId, apiKeysByChainId, "f");
|
|
49
|
-
__classPrivateFieldSet(this, _EtherscanRemoteTransactionSource_includeTokenTransfers, includeTokenTransfers ?? true, "f");
|
|
50
|
-
__classPrivateFieldSet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, false, "f");
|
|
51
|
-
}
|
|
52
|
-
isSupportedNetwork(chainId) {
|
|
53
|
-
return Object.keys(constants_1.ETHERSCAN_SUPPORTED_NETWORKS).includes(chainId);
|
|
54
|
-
}
|
|
55
|
-
getLastBlockVariations() {
|
|
56
|
-
return [__classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, "f") ? 'token' : 'normal'];
|
|
57
|
-
}
|
|
58
|
-
async fetchTransactions(request) {
|
|
59
|
-
const releaseLock = await __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_mutex, "f").acquire();
|
|
60
|
-
const acquiredTime = Date.now();
|
|
61
|
-
const { chainId } = request;
|
|
62
|
-
const apiKey = __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_apiKeysByChainId, "f")?.[chainId];
|
|
63
|
-
if (apiKey) {
|
|
64
|
-
(0, logger_1.incomingTransactionsLogger)('Etherscan API key found for chain', chainId);
|
|
65
|
-
}
|
|
66
|
-
const etherscanRequest = {
|
|
67
|
-
...request,
|
|
68
|
-
apiKey,
|
|
69
|
-
chainId,
|
|
70
|
-
};
|
|
71
|
-
try {
|
|
72
|
-
const transactions = __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, "f")
|
|
73
|
-
? await __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_fetchTokenTransactions, "f").call(this, request, etherscanRequest)
|
|
74
|
-
: await __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_fetchNormalTransactions, "f").call(this, request, etherscanRequest);
|
|
75
|
-
if (__classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_includeTokenTransfers, "f")) {
|
|
76
|
-
__classPrivateFieldSet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, !__classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, "f"), "f");
|
|
77
|
-
}
|
|
78
|
-
return transactions;
|
|
79
|
-
}
|
|
80
|
-
finally {
|
|
81
|
-
__classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_releaseLockAfterInterval).call(this, acquiredTime, releaseLock);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
exports.EtherscanRemoteTransactionSource = EtherscanRemoteTransactionSource;
|
|
86
|
-
_EtherscanRemoteTransactionSource_apiKeysByChainId = new WeakMap(), _EtherscanRemoteTransactionSource_includeTokenTransfers = new WeakMap(), _EtherscanRemoteTransactionSource_isTokenRequestPending = new WeakMap(), _EtherscanRemoteTransactionSource_mutex = new WeakMap(), _EtherscanRemoteTransactionSource_fetchNormalTransactions = new WeakMap(), _EtherscanRemoteTransactionSource_fetchTokenTransactions = new WeakMap(), _EtherscanRemoteTransactionSource_instances = new WeakSet(), _EtherscanRemoteTransactionSource_releaseLockAfterInterval = function _EtherscanRemoteTransactionSource_releaseLockAfterInterval(acquireTime, releaseLock) {
|
|
87
|
-
const elapsedTime = Date.now() - acquireTime;
|
|
88
|
-
const remainingTime = Math.max(0, ETHERSCAN_RATE_LIMIT_INTERVAL - elapsedTime);
|
|
89
|
-
// Wait for the remaining time if it hasn't been 5 seconds yet
|
|
90
|
-
if (remainingTime > 0) {
|
|
91
|
-
setTimeout(releaseLock, remainingTime);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
releaseLock();
|
|
95
|
-
}
|
|
96
|
-
}, _EtherscanRemoteTransactionSource_getResponseTransactions = function _EtherscanRemoteTransactionSource_getResponseTransactions(response) {
|
|
97
|
-
let result = response.result;
|
|
98
|
-
if (response.status === '0') {
|
|
99
|
-
result = [];
|
|
100
|
-
if (response.result.length) {
|
|
101
|
-
(0, logger_1.incomingTransactionsLogger)('Ignored Etherscan request error', {
|
|
102
|
-
message: response.result,
|
|
103
|
-
type: __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, "f") ? 'token' : 'normal',
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return result;
|
|
108
|
-
}, _EtherscanRemoteTransactionSource_normalizeTransaction = function _EtherscanRemoteTransactionSource_normalizeTransaction(txMeta, chainId) {
|
|
109
|
-
const base = __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_normalizeTransactionBase).call(this, txMeta, chainId);
|
|
110
|
-
return {
|
|
111
|
-
...base,
|
|
112
|
-
txParams: {
|
|
113
|
-
...base.txParams,
|
|
114
|
-
data: txMeta.input,
|
|
115
|
-
},
|
|
116
|
-
...(txMeta.isError === '0'
|
|
117
|
-
? { status: types_1.TransactionStatus.confirmed }
|
|
118
|
-
: {
|
|
119
|
-
error: new Error('Transaction failed'),
|
|
120
|
-
status: types_1.TransactionStatus.failed,
|
|
121
|
-
}),
|
|
122
|
-
};
|
|
123
|
-
}, _EtherscanRemoteTransactionSource_normalizeTokenTransaction = function _EtherscanRemoteTransactionSource_normalizeTokenTransaction(txMeta, chainId) {
|
|
124
|
-
const base = __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_normalizeTransactionBase).call(this, txMeta, chainId);
|
|
125
|
-
return {
|
|
126
|
-
...base,
|
|
127
|
-
isTransfer: true,
|
|
128
|
-
transferInformation: {
|
|
129
|
-
contractAddress: txMeta.contractAddress,
|
|
130
|
-
decimals: Number(txMeta.tokenDecimal),
|
|
131
|
-
symbol: txMeta.tokenSymbol,
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
}, _EtherscanRemoteTransactionSource_normalizeTransactionBase = function _EtherscanRemoteTransactionSource_normalizeTransactionBase(txMeta, chainId) {
|
|
135
|
-
const time = parseInt(txMeta.timeStamp, 10) * 1000;
|
|
136
|
-
return {
|
|
137
|
-
blockNumber: txMeta.blockNumber,
|
|
138
|
-
chainId,
|
|
139
|
-
hash: txMeta.hash,
|
|
140
|
-
id: (0, uuid_1.v1)({ msecs: time }),
|
|
141
|
-
networkClientId: '',
|
|
142
|
-
status: types_1.TransactionStatus.confirmed,
|
|
143
|
-
time,
|
|
144
|
-
txParams: {
|
|
145
|
-
chainId,
|
|
146
|
-
from: txMeta.from,
|
|
147
|
-
gas: (0, controller_utils_1.BNToHex)(new bn_js_1.default(txMeta.gas)),
|
|
148
|
-
gasPrice: (0, controller_utils_1.BNToHex)(new bn_js_1.default(txMeta.gasPrice)),
|
|
149
|
-
gasUsed: (0, controller_utils_1.BNToHex)(new bn_js_1.default(txMeta.gasUsed)),
|
|
150
|
-
nonce: (0, controller_utils_1.BNToHex)(new bn_js_1.default(txMeta.nonce)),
|
|
151
|
-
to: txMeta.to,
|
|
152
|
-
value: (0, controller_utils_1.BNToHex)(new bn_js_1.default(txMeta.value)),
|
|
153
|
-
},
|
|
154
|
-
type: types_1.TransactionType.incoming,
|
|
155
|
-
verifiedOnBlockchain: false,
|
|
156
|
-
};
|
|
157
|
-
};
|
|
158
|
-
//# sourceMappingURL=EtherscanRemoteTransactionSource.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EtherscanRemoteTransactionSource.cjs","sourceRoot":"","sources":["../../src/helpers/EtherscanRemoteTransactionSource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iEAAqD;AAErD,6CAAoC;AACpC,kDAAuB;AACvB,+BAAoC;AAEpC,gDAA4D;AAC5D,0CAA8D;AAM9D,wCAA8D;AAC9D,sDAG4B;AAS5B,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAE3C;;GAEG;AACH,MAAa,gCAAgC;IAW3C,YAAY,EACV,gBAAgB,EAChB,qBAAqB,MAInB,EAAE;;QAdN,qEAAwC;QAExC,0EAAgC;QAEhC,0EAAgC;QAEhC,kDAAS,IAAI,mBAAK,EAAE,EAAC;QAqErB,oEAA2B,KAAK,EAC9B,OAAuC,EACvC,gBAA6C,EAC7C,EAAE;YACF,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;YAE5B,MAAM,qBAAqB,GAAG,MAAM,IAAA,sCAA0B,EAC5D,gBAAgB,CACjB,CAAC;YAEF,OAAO,uBAAA,IAAI,8GAAyB,MAA7B,IAAI,EAA0B,qBAAqB,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CACrE,uBAAA,IAAI,2GAAsB,MAA1B,IAAI,EAAuB,EAAE,EAAE,OAAO,CAAC,CACxC,CAAC;QACJ,CAAC,EAAC;QAEF,mEAA0B,KAAK,EAC7B,OAAuC,EACvC,gBAA6C,EAC7C,EAAE;YACF,MAAM,EAAE,OAAO,EAAE,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IAAI;QACJ,QAAQ,EAAE;YACR,OAAO;YACP,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,GAAG,EAAE,IAAA,0BAAO,EAAC,IAAI,eAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAChC,QAAQ,EAAE,IAAA,0BAAO,EAAC,IAAI,eAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC1C,OAAO,EAAE,IAAA,0BAAO,EAAC,IAAI,eAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACxC,KAAK,EAAE,IAAA,0BAAO,EAAC,IAAI,eAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACpC,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,KAAK,EAAE,IAAA,0BAAO,EAAC,IAAI,eAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACrC;QACD,IAAI,EAAE,uBAAe,CAAC,QAAQ;QAC9B,oBAAoB,EAAE,KAAK;KAC5B,CAAC;AACJ,CAAC","sourcesContent":["import { BNToHex } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\nimport { Mutex } from 'async-mutex';\nimport BN from 'bn.js';\nimport { v1 as random } from 'uuid';\n\nimport { ETHERSCAN_SUPPORTED_NETWORKS } from '../constants';\nimport { incomingTransactionsLogger as log } from '../logger';\nimport type {\n RemoteTransactionSource,\n RemoteTransactionSourceRequest,\n TransactionMeta,\n} from '../types';\nimport { TransactionStatus, TransactionType } from '../types';\nimport {\n fetchEtherscanTokenTransactions,\n fetchEtherscanTransactions,\n} from '../utils/etherscan';\nimport type {\n EtherscanTokenTransactionMeta,\n EtherscanTransactionMeta,\n EtherscanTransactionMetaBase,\n EtherscanTransactionRequest,\n EtherscanTransactionResponse,\n} from '../utils/etherscan';\n\nconst ETHERSCAN_RATE_LIMIT_INTERVAL = 5000;\n\n/**\n * A RemoteTransactionSource that fetches transaction data from Etherscan.\n */\nexport class EtherscanRemoteTransactionSource\n implements RemoteTransactionSource\n{\n #apiKeysByChainId?: Record<Hex, string>;\n\n #includeTokenTransfers: boolean;\n\n #isTokenRequestPending: boolean;\n\n #mutex = new Mutex();\n\n constructor({\n apiKeysByChainId,\n includeTokenTransfers,\n }: {\n apiKeysByChainId?: Record<Hex, string>;\n includeTokenTransfers?: boolean;\n } = {}) {\n this.#apiKeysByChainId = apiKeysByChainId;\n this.#includeTokenTransfers = includeTokenTransfers ?? true;\n this.#isTokenRequestPending = false;\n }\n\n isSupportedNetwork(chainId: Hex): boolean {\n return Object.keys(ETHERSCAN_SUPPORTED_NETWORKS).includes(chainId);\n }\n\n getLastBlockVariations(): string[] {\n return [this.#isTokenRequestPending ? 'token' : 'normal'];\n }\n\n async fetchTransactions(\n request: RemoteTransactionSourceRequest,\n ): Promise<TransactionMeta[]> {\n const releaseLock = await this.#mutex.acquire();\n const acquiredTime = Date.now();\n const { chainId } = request;\n const apiKey = this.#apiKeysByChainId?.[chainId];\n\n if (apiKey) {\n log('Etherscan API key found for chain', chainId);\n }\n\n const etherscanRequest: EtherscanTransactionRequest = {\n ...request,\n apiKey,\n chainId,\n };\n\n try {\n const transactions = this.#isTokenRequestPending\n ? await this.#fetchTokenTransactions(request, etherscanRequest)\n : await this.#fetchNormalTransactions(request, etherscanRequest);\n\n if (this.#includeTokenTransfers) {\n this.#isTokenRequestPending = !this.#isTokenRequestPending;\n }\n\n return transactions;\n } finally {\n this.#releaseLockAfterInterval(acquiredTime, releaseLock);\n }\n }\n\n #releaseLockAfterInterval(acquireTime: number, releaseLock: () => void) {\n const elapsedTime = Date.now() - acquireTime;\n const remainingTime = Math.max(\n 0,\n ETHERSCAN_RATE_LIMIT_INTERVAL - elapsedTime,\n );\n // Wait for the remaining time if it hasn't been 5 seconds yet\n if (remainingTime > 0) {\n setTimeout(releaseLock, remainingTime);\n } else {\n releaseLock();\n }\n }\n\n #fetchNormalTransactions = async (\n request: RemoteTransactionSourceRequest,\n etherscanRequest: EtherscanTransactionRequest,\n ) => {\n const { chainId } = request;\n\n const etherscanTransactions = await fetchEtherscanTransactions(\n etherscanRequest,\n );\n\n return this.#getResponseTransactions(etherscanTransactions).map((tx) =>\n this.#normalizeTransaction(tx, chainId),\n );\n };\n\n #fetchTokenTransactions = async (\n request: RemoteTransactionSourceRequest,\n etherscanRequest: EtherscanTransactionRequest,\n ) => {\n const { chainId } = request;\n\n const etherscanTransactions = await fetchEtherscanTokenTransactions(\n etherscanRequest,\n );\n\n return this.#getResponseTransactions(etherscanTransactions).map((tx) =>\n this.#normalizeTokenTransaction(tx, chainId),\n );\n };\n\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n #getResponseTransactions<T extends EtherscanTransactionMetaBase>(\n response: EtherscanTransactionResponse<T>,\n ): T[] {\n let result = response.result as T[];\n\n if (response.status === '0') {\n result = [];\n\n if (response.result.length) {\n log('Ignored Etherscan request error', {\n message: response.result,\n type: this.#isTokenRequestPending ? 'token' : 'normal',\n });\n }\n }\n\n return result;\n }\n\n #normalizeTransaction(\n txMeta: EtherscanTransactionMeta,\n chainId: Hex,\n ): TransactionMeta {\n const base = this.#normalizeTransactionBase(txMeta, chainId);\n\n return {\n ...base,\n txParams: {\n ...base.txParams,\n data: txMeta.input,\n },\n ...(txMeta.isError === '0'\n ? { status: TransactionStatus.confirmed }\n : {\n error: new Error('Transaction failed'),\n status: TransactionStatus.failed,\n }),\n };\n }\n\n #normalizeTokenTransaction(\n txMeta: EtherscanTokenTransactionMeta,\n chainId: Hex,\n ): TransactionMeta {\n const base = this.#normalizeTransactionBase(txMeta, chainId);\n\n return {\n ...base,\n isTransfer: true,\n transferInformation: {\n contractAddress: txMeta.contractAddress,\n decimals: Number(txMeta.tokenDecimal),\n symbol: txMeta.tokenSymbol,\n },\n };\n }\n\n #normalizeTransactionBase(\n txMeta: EtherscanTransactionMetaBase,\n chainId: Hex,\n ): TransactionMeta {\n const time = parseInt(txMeta.timeStamp, 10) * 1000;\n\n return {\n blockNumber: txMeta.blockNumber,\n chainId,\n hash: txMeta.hash,\n id: random({ msecs: time }),\n networkClientId: '',\n status: TransactionStatus.confirmed,\n time,\n txParams: {\n chainId,\n from: txMeta.from,\n gas: BNToHex(new BN(txMeta.gas)),\n gasPrice: BNToHex(new BN(txMeta.gasPrice)),\n gasUsed: BNToHex(new BN(txMeta.gasUsed)),\n nonce: BNToHex(new BN(txMeta.nonce)),\n to: txMeta.to,\n value: BNToHex(new BN(txMeta.value)),\n },\n type: TransactionType.incoming,\n verifiedOnBlockchain: false,\n };\n }\n}\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Hex } from "@metamask/utils";
|
|
2
|
-
import type { RemoteTransactionSource, RemoteTransactionSourceRequest, TransactionMeta } from "../types.cjs";
|
|
3
|
-
/**
|
|
4
|
-
* A RemoteTransactionSource that fetches transaction data from Etherscan.
|
|
5
|
-
*/
|
|
6
|
-
export declare class EtherscanRemoteTransactionSource implements RemoteTransactionSource {
|
|
7
|
-
#private;
|
|
8
|
-
constructor({ apiKeysByChainId, includeTokenTransfers, }?: {
|
|
9
|
-
apiKeysByChainId?: Record<Hex, string>;
|
|
10
|
-
includeTokenTransfers?: boolean;
|
|
11
|
-
});
|
|
12
|
-
isSupportedNetwork(chainId: Hex): boolean;
|
|
13
|
-
getLastBlockVariations(): string[];
|
|
14
|
-
fetchTransactions(request: RemoteTransactionSourceRequest): Promise<TransactionMeta[]>;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=EtherscanRemoteTransactionSource.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EtherscanRemoteTransactionSource.d.cts","sourceRoot":"","sources":["../../src/helpers/EtherscanRemoteTransactionSource.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAO3C,OAAO,KAAK,EACV,uBAAuB,EACvB,8BAA8B,EAC9B,eAAe,EAChB,qBAAiB;AAgBlB;;GAEG;AACH,qBAAa,gCACX,YAAW,uBAAuB;;gBAUtB,EACV,gBAAgB,EAChB,qBAAqB,GACtB,GAAE;QACD,gBAAgB,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACvC,qBAAqB,CAAC,EAAE,OAAO,CAAC;KAC5B;IAMN,kBAAkB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;IAIzC,sBAAsB,IAAI,MAAM,EAAE;IAI5B,iBAAiB,CACrB,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,eAAe,EAAE,CAAC;CAkK9B"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Hex } from "@metamask/utils";
|
|
2
|
-
import type { RemoteTransactionSource, RemoteTransactionSourceRequest, TransactionMeta } from "../types.mjs";
|
|
3
|
-
/**
|
|
4
|
-
* A RemoteTransactionSource that fetches transaction data from Etherscan.
|
|
5
|
-
*/
|
|
6
|
-
export declare class EtherscanRemoteTransactionSource implements RemoteTransactionSource {
|
|
7
|
-
#private;
|
|
8
|
-
constructor({ apiKeysByChainId, includeTokenTransfers, }?: {
|
|
9
|
-
apiKeysByChainId?: Record<Hex, string>;
|
|
10
|
-
includeTokenTransfers?: boolean;
|
|
11
|
-
});
|
|
12
|
-
isSupportedNetwork(chainId: Hex): boolean;
|
|
13
|
-
getLastBlockVariations(): string[];
|
|
14
|
-
fetchTransactions(request: RemoteTransactionSourceRequest): Promise<TransactionMeta[]>;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=EtherscanRemoteTransactionSource.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EtherscanRemoteTransactionSource.d.mts","sourceRoot":"","sources":["../../src/helpers/EtherscanRemoteTransactionSource.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAO3C,OAAO,KAAK,EACV,uBAAuB,EACvB,8BAA8B,EAC9B,eAAe,EAChB,qBAAiB;AAgBlB;;GAEG;AACH,qBAAa,gCACX,YAAW,uBAAuB;;gBAUtB,EACV,gBAAgB,EAChB,qBAAqB,GACtB,GAAE;QACD,gBAAgB,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACvC,qBAAqB,CAAC,EAAE,OAAO,CAAC;KAC5B;IAMN,kBAAkB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;IAIzC,sBAAsB,IAAI,MAAM,EAAE;IAI5B,iBAAiB,CACrB,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,eAAe,EAAE,CAAC;CAkK9B"}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _EtherscanRemoteTransactionSource_instances, _EtherscanRemoteTransactionSource_apiKeysByChainId, _EtherscanRemoteTransactionSource_includeTokenTransfers, _EtherscanRemoteTransactionSource_isTokenRequestPending, _EtherscanRemoteTransactionSource_mutex, _EtherscanRemoteTransactionSource_releaseLockAfterInterval, _EtherscanRemoteTransactionSource_fetchNormalTransactions, _EtherscanRemoteTransactionSource_fetchTokenTransactions, _EtherscanRemoteTransactionSource_getResponseTransactions, _EtherscanRemoteTransactionSource_normalizeTransaction, _EtherscanRemoteTransactionSource_normalizeTokenTransaction, _EtherscanRemoteTransactionSource_normalizeTransactionBase;
|
|
13
|
-
function $importDefault(module) {
|
|
14
|
-
if (module?.__esModule) {
|
|
15
|
-
return module.default;
|
|
16
|
-
}
|
|
17
|
-
return module;
|
|
18
|
-
}
|
|
19
|
-
import { BNToHex } from "@metamask/controller-utils";
|
|
20
|
-
import { Mutex } from "async-mutex";
|
|
21
|
-
import $BN from "bn.js";
|
|
22
|
-
const BN = $importDefault($BN);
|
|
23
|
-
import { v1 as random } from "uuid";
|
|
24
|
-
import { ETHERSCAN_SUPPORTED_NETWORKS } from "../constants.mjs";
|
|
25
|
-
import { incomingTransactionsLogger as log } from "../logger.mjs";
|
|
26
|
-
import { TransactionStatus, TransactionType } from "../types.mjs";
|
|
27
|
-
import { fetchEtherscanTokenTransactions, fetchEtherscanTransactions } from "../utils/etherscan.mjs";
|
|
28
|
-
const ETHERSCAN_RATE_LIMIT_INTERVAL = 5000;
|
|
29
|
-
/**
|
|
30
|
-
* A RemoteTransactionSource that fetches transaction data from Etherscan.
|
|
31
|
-
*/
|
|
32
|
-
export class EtherscanRemoteTransactionSource {
|
|
33
|
-
constructor({ apiKeysByChainId, includeTokenTransfers, } = {}) {
|
|
34
|
-
_EtherscanRemoteTransactionSource_instances.add(this);
|
|
35
|
-
_EtherscanRemoteTransactionSource_apiKeysByChainId.set(this, void 0);
|
|
36
|
-
_EtherscanRemoteTransactionSource_includeTokenTransfers.set(this, void 0);
|
|
37
|
-
_EtherscanRemoteTransactionSource_isTokenRequestPending.set(this, void 0);
|
|
38
|
-
_EtherscanRemoteTransactionSource_mutex.set(this, new Mutex());
|
|
39
|
-
_EtherscanRemoteTransactionSource_fetchNormalTransactions.set(this, async (request, etherscanRequest) => {
|
|
40
|
-
const { chainId } = request;
|
|
41
|
-
const etherscanTransactions = await fetchEtherscanTransactions(etherscanRequest);
|
|
42
|
-
return __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_getResponseTransactions).call(this, etherscanTransactions).map((tx) => __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_normalizeTransaction).call(this, tx, chainId));
|
|
43
|
-
});
|
|
44
|
-
_EtherscanRemoteTransactionSource_fetchTokenTransactions.set(this, async (request, etherscanRequest) => {
|
|
45
|
-
const { chainId } = request;
|
|
46
|
-
const etherscanTransactions = await fetchEtherscanTokenTransactions(etherscanRequest);
|
|
47
|
-
return __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_getResponseTransactions).call(this, etherscanTransactions).map((tx) => __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_normalizeTokenTransaction).call(this, tx, chainId));
|
|
48
|
-
});
|
|
49
|
-
__classPrivateFieldSet(this, _EtherscanRemoteTransactionSource_apiKeysByChainId, apiKeysByChainId, "f");
|
|
50
|
-
__classPrivateFieldSet(this, _EtherscanRemoteTransactionSource_includeTokenTransfers, includeTokenTransfers ?? true, "f");
|
|
51
|
-
__classPrivateFieldSet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, false, "f");
|
|
52
|
-
}
|
|
53
|
-
isSupportedNetwork(chainId) {
|
|
54
|
-
return Object.keys(ETHERSCAN_SUPPORTED_NETWORKS).includes(chainId);
|
|
55
|
-
}
|
|
56
|
-
getLastBlockVariations() {
|
|
57
|
-
return [__classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, "f") ? 'token' : 'normal'];
|
|
58
|
-
}
|
|
59
|
-
async fetchTransactions(request) {
|
|
60
|
-
const releaseLock = await __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_mutex, "f").acquire();
|
|
61
|
-
const acquiredTime = Date.now();
|
|
62
|
-
const { chainId } = request;
|
|
63
|
-
const apiKey = __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_apiKeysByChainId, "f")?.[chainId];
|
|
64
|
-
if (apiKey) {
|
|
65
|
-
log('Etherscan API key found for chain', chainId);
|
|
66
|
-
}
|
|
67
|
-
const etherscanRequest = {
|
|
68
|
-
...request,
|
|
69
|
-
apiKey,
|
|
70
|
-
chainId,
|
|
71
|
-
};
|
|
72
|
-
try {
|
|
73
|
-
const transactions = __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, "f")
|
|
74
|
-
? await __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_fetchTokenTransactions, "f").call(this, request, etherscanRequest)
|
|
75
|
-
: await __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_fetchNormalTransactions, "f").call(this, request, etherscanRequest);
|
|
76
|
-
if (__classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_includeTokenTransfers, "f")) {
|
|
77
|
-
__classPrivateFieldSet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, !__classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, "f"), "f");
|
|
78
|
-
}
|
|
79
|
-
return transactions;
|
|
80
|
-
}
|
|
81
|
-
finally {
|
|
82
|
-
__classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_releaseLockAfterInterval).call(this, acquiredTime, releaseLock);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
_EtherscanRemoteTransactionSource_apiKeysByChainId = new WeakMap(), _EtherscanRemoteTransactionSource_includeTokenTransfers = new WeakMap(), _EtherscanRemoteTransactionSource_isTokenRequestPending = new WeakMap(), _EtherscanRemoteTransactionSource_mutex = new WeakMap(), _EtherscanRemoteTransactionSource_fetchNormalTransactions = new WeakMap(), _EtherscanRemoteTransactionSource_fetchTokenTransactions = new WeakMap(), _EtherscanRemoteTransactionSource_instances = new WeakSet(), _EtherscanRemoteTransactionSource_releaseLockAfterInterval = function _EtherscanRemoteTransactionSource_releaseLockAfterInterval(acquireTime, releaseLock) {
|
|
87
|
-
const elapsedTime = Date.now() - acquireTime;
|
|
88
|
-
const remainingTime = Math.max(0, ETHERSCAN_RATE_LIMIT_INTERVAL - elapsedTime);
|
|
89
|
-
// Wait for the remaining time if it hasn't been 5 seconds yet
|
|
90
|
-
if (remainingTime > 0) {
|
|
91
|
-
setTimeout(releaseLock, remainingTime);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
releaseLock();
|
|
95
|
-
}
|
|
96
|
-
}, _EtherscanRemoteTransactionSource_getResponseTransactions = function _EtherscanRemoteTransactionSource_getResponseTransactions(response) {
|
|
97
|
-
let result = response.result;
|
|
98
|
-
if (response.status === '0') {
|
|
99
|
-
result = [];
|
|
100
|
-
if (response.result.length) {
|
|
101
|
-
log('Ignored Etherscan request error', {
|
|
102
|
-
message: response.result,
|
|
103
|
-
type: __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, "f") ? 'token' : 'normal',
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return result;
|
|
108
|
-
}, _EtherscanRemoteTransactionSource_normalizeTransaction = function _EtherscanRemoteTransactionSource_normalizeTransaction(txMeta, chainId) {
|
|
109
|
-
const base = __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_normalizeTransactionBase).call(this, txMeta, chainId);
|
|
110
|
-
return {
|
|
111
|
-
...base,
|
|
112
|
-
txParams: {
|
|
113
|
-
...base.txParams,
|
|
114
|
-
data: txMeta.input,
|
|
115
|
-
},
|
|
116
|
-
...(txMeta.isError === '0'
|
|
117
|
-
? { status: TransactionStatus.confirmed }
|
|
118
|
-
: {
|
|
119
|
-
error: new Error('Transaction failed'),
|
|
120
|
-
status: TransactionStatus.failed,
|
|
121
|
-
}),
|
|
122
|
-
};
|
|
123
|
-
}, _EtherscanRemoteTransactionSource_normalizeTokenTransaction = function _EtherscanRemoteTransactionSource_normalizeTokenTransaction(txMeta, chainId) {
|
|
124
|
-
const base = __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_normalizeTransactionBase).call(this, txMeta, chainId);
|
|
125
|
-
return {
|
|
126
|
-
...base,
|
|
127
|
-
isTransfer: true,
|
|
128
|
-
transferInformation: {
|
|
129
|
-
contractAddress: txMeta.contractAddress,
|
|
130
|
-
decimals: Number(txMeta.tokenDecimal),
|
|
131
|
-
symbol: txMeta.tokenSymbol,
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
}, _EtherscanRemoteTransactionSource_normalizeTransactionBase = function _EtherscanRemoteTransactionSource_normalizeTransactionBase(txMeta, chainId) {
|
|
135
|
-
const time = parseInt(txMeta.timeStamp, 10) * 1000;
|
|
136
|
-
return {
|
|
137
|
-
blockNumber: txMeta.blockNumber,
|
|
138
|
-
chainId,
|
|
139
|
-
hash: txMeta.hash,
|
|
140
|
-
id: random({ msecs: time }),
|
|
141
|
-
networkClientId: '',
|
|
142
|
-
status: TransactionStatus.confirmed,
|
|
143
|
-
time,
|
|
144
|
-
txParams: {
|
|
145
|
-
chainId,
|
|
146
|
-
from: txMeta.from,
|
|
147
|
-
gas: BNToHex(new BN(txMeta.gas)),
|
|
148
|
-
gasPrice: BNToHex(new BN(txMeta.gasPrice)),
|
|
149
|
-
gasUsed: BNToHex(new BN(txMeta.gasUsed)),
|
|
150
|
-
nonce: BNToHex(new BN(txMeta.nonce)),
|
|
151
|
-
to: txMeta.to,
|
|
152
|
-
value: BNToHex(new BN(txMeta.value)),
|
|
153
|
-
},
|
|
154
|
-
type: TransactionType.incoming,
|
|
155
|
-
verifiedOnBlockchain: false,
|
|
156
|
-
};
|
|
157
|
-
};
|
|
158
|
-
//# sourceMappingURL=EtherscanRemoteTransactionSource.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version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C,IAAI,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAChC,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC1C,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACxC,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACpC,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACrC;QACD,IAAI,EAAE,eAAe,CAAC,QAAQ;QAC9B,oBAAoB,EAAE,KAAK;KAC5B,CAAC;AACJ,CAAC","sourcesContent":["import { BNToHex } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\nimport { Mutex } from 'async-mutex';\nimport BN from 'bn.js';\nimport { v1 as random } from 'uuid';\n\nimport { ETHERSCAN_SUPPORTED_NETWORKS } from '../constants';\nimport { incomingTransactionsLogger as log } from '../logger';\nimport type {\n RemoteTransactionSource,\n RemoteTransactionSourceRequest,\n TransactionMeta,\n} from '../types';\nimport { TransactionStatus, TransactionType } from '../types';\nimport {\n fetchEtherscanTokenTransactions,\n fetchEtherscanTransactions,\n} from '../utils/etherscan';\nimport type {\n EtherscanTokenTransactionMeta,\n EtherscanTransactionMeta,\n EtherscanTransactionMetaBase,\n EtherscanTransactionRequest,\n EtherscanTransactionResponse,\n} from '../utils/etherscan';\n\nconst ETHERSCAN_RATE_LIMIT_INTERVAL = 5000;\n\n/**\n * A RemoteTransactionSource that fetches transaction data from Etherscan.\n */\nexport class EtherscanRemoteTransactionSource\n implements RemoteTransactionSource\n{\n #apiKeysByChainId?: Record<Hex, string>;\n\n #includeTokenTransfers: boolean;\n\n #isTokenRequestPending: boolean;\n\n #mutex = new Mutex();\n\n constructor({\n apiKeysByChainId,\n includeTokenTransfers,\n }: {\n apiKeysByChainId?: Record<Hex, string>;\n includeTokenTransfers?: boolean;\n } = {}) {\n this.#apiKeysByChainId = apiKeysByChainId;\n this.#includeTokenTransfers = includeTokenTransfers ?? true;\n this.#isTokenRequestPending = false;\n }\n\n isSupportedNetwork(chainId: Hex): boolean {\n return Object.keys(ETHERSCAN_SUPPORTED_NETWORKS).includes(chainId);\n }\n\n getLastBlockVariations(): string[] {\n return [this.#isTokenRequestPending ? 'token' : 'normal'];\n }\n\n async fetchTransactions(\n request: RemoteTransactionSourceRequest,\n ): Promise<TransactionMeta[]> {\n const releaseLock = await this.#mutex.acquire();\n const acquiredTime = Date.now();\n const { chainId } = request;\n const apiKey = this.#apiKeysByChainId?.[chainId];\n\n if (apiKey) {\n log('Etherscan API key found for chain', chainId);\n }\n\n const etherscanRequest: EtherscanTransactionRequest = {\n ...request,\n apiKey,\n chainId,\n };\n\n try {\n const transactions = this.#isTokenRequestPending\n ? await this.#fetchTokenTransactions(request, etherscanRequest)\n : await this.#fetchNormalTransactions(request, etherscanRequest);\n\n if (this.#includeTokenTransfers) {\n this.#isTokenRequestPending = !this.#isTokenRequestPending;\n }\n\n return transactions;\n } finally {\n this.#releaseLockAfterInterval(acquiredTime, releaseLock);\n }\n }\n\n #releaseLockAfterInterval(acquireTime: number, releaseLock: () => void) {\n const elapsedTime = Date.now() - acquireTime;\n const remainingTime = Math.max(\n 0,\n ETHERSCAN_RATE_LIMIT_INTERVAL - elapsedTime,\n );\n // Wait for the remaining time if it hasn't been 5 seconds yet\n if (remainingTime > 0) {\n setTimeout(releaseLock, remainingTime);\n } else {\n releaseLock();\n }\n }\n\n #fetchNormalTransactions = async (\n request: RemoteTransactionSourceRequest,\n etherscanRequest: EtherscanTransactionRequest,\n ) => {\n const { chainId } = request;\n\n const etherscanTransactions = await fetchEtherscanTransactions(\n etherscanRequest,\n );\n\n return this.#getResponseTransactions(etherscanTransactions).map((tx) =>\n this.#normalizeTransaction(tx, chainId),\n );\n };\n\n #fetchTokenTransactions = async (\n request: RemoteTransactionSourceRequest,\n etherscanRequest: EtherscanTransactionRequest,\n ) => {\n const { chainId } = request;\n\n const etherscanTransactions = await fetchEtherscanTokenTransactions(\n etherscanRequest,\n );\n\n return this.#getResponseTransactions(etherscanTransactions).map((tx) =>\n this.#normalizeTokenTransaction(tx, chainId),\n );\n };\n\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n #getResponseTransactions<T extends EtherscanTransactionMetaBase>(\n response: EtherscanTransactionResponse<T>,\n ): T[] {\n let result = response.result as T[];\n\n if (response.status === '0') {\n result = [];\n\n if (response.result.length) {\n log('Ignored Etherscan request error', {\n message: response.result,\n type: this.#isTokenRequestPending ? 'token' : 'normal',\n });\n }\n }\n\n return result;\n }\n\n #normalizeTransaction(\n txMeta: EtherscanTransactionMeta,\n chainId: Hex,\n ): TransactionMeta {\n const base = this.#normalizeTransactionBase(txMeta, chainId);\n\n return {\n ...base,\n txParams: {\n ...base.txParams,\n data: txMeta.input,\n },\n ...(txMeta.isError === '0'\n ? { status: TransactionStatus.confirmed }\n : {\n error: new Error('Transaction failed'),\n status: TransactionStatus.failed,\n }),\n };\n }\n\n #normalizeTokenTransaction(\n txMeta: EtherscanTokenTransactionMeta,\n chainId: Hex,\n ): TransactionMeta {\n const base = this.#normalizeTransactionBase(txMeta, chainId);\n\n return {\n ...base,\n isTransfer: true,\n transferInformation: {\n contractAddress: txMeta.contractAddress,\n decimals: Number(txMeta.tokenDecimal),\n symbol: txMeta.tokenSymbol,\n },\n };\n }\n\n #normalizeTransactionBase(\n txMeta: EtherscanTransactionMetaBase,\n chainId: Hex,\n ): TransactionMeta {\n const time = parseInt(txMeta.timeStamp, 10) * 1000;\n\n return {\n blockNumber: txMeta.blockNumber,\n chainId,\n hash: txMeta.hash,\n id: random({ msecs: time }),\n networkClientId: '',\n status: TransactionStatus.confirmed,\n time,\n txParams: {\n chainId,\n from: txMeta.from,\n gas: BNToHex(new BN(txMeta.gas)),\n gasPrice: BNToHex(new BN(txMeta.gasPrice)),\n gasUsed: BNToHex(new BN(txMeta.gasUsed)),\n nonce: BNToHex(new BN(txMeta.nonce)),\n to: txMeta.to,\n value: BNToHex(new BN(txMeta.value)),\n },\n type: TransactionType.incoming,\n verifiedOnBlockchain: false,\n };\n }\n}\n"]}
|
package/dist/utils/etherscan.cjs
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEtherscanApiHost = exports.fetchEtherscanTokenTransactions = exports.fetchEtherscanTransactions = void 0;
|
|
4
|
-
const controller_utils_1 = require("@metamask/controller-utils");
|
|
5
|
-
const constants_1 = require("../constants.cjs");
|
|
6
|
-
const logger_1 = require("../logger.cjs");
|
|
7
|
-
const log = (0, logger_1.createModuleLogger)(logger_1.projectLogger, 'etherscan');
|
|
8
|
-
/**
|
|
9
|
-
* Retrieves transaction data from Etherscan.
|
|
10
|
-
*
|
|
11
|
-
* @param request - Configuration required to fetch transactions.
|
|
12
|
-
* @param request.address - Address to retrieve transactions for.
|
|
13
|
-
* @param request.apiKey - Etherscan API key to prevent rate limiting.
|
|
14
|
-
* @param request.chainId - Current chain ID used to determine subdomain and domain.
|
|
15
|
-
* @param request.fromBlock - Block number to start fetching transactions from.
|
|
16
|
-
* @param request.limit - Number of transactions to retrieve.
|
|
17
|
-
* @returns An Etherscan response object containing the request status and an array of token transaction data.
|
|
18
|
-
*/
|
|
19
|
-
async function fetchEtherscanTransactions({ address, apiKey, chainId, fromBlock, limit, }) {
|
|
20
|
-
return await fetchTransactions('txlist', {
|
|
21
|
-
address,
|
|
22
|
-
apiKey,
|
|
23
|
-
chainId,
|
|
24
|
-
fromBlock,
|
|
25
|
-
limit,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
exports.fetchEtherscanTransactions = fetchEtherscanTransactions;
|
|
29
|
-
/**
|
|
30
|
-
* Retrieves token transaction data from Etherscan.
|
|
31
|
-
*
|
|
32
|
-
* @param request - Configuration required to fetch token transactions.
|
|
33
|
-
* @param request.address - Address to retrieve token transactions for.
|
|
34
|
-
* @param request.apiKey - Etherscan API key to prevent rate limiting.
|
|
35
|
-
* @param request.chainId - Current chain ID used to determine subdomain and domain.
|
|
36
|
-
* @param request.fromBlock - Block number to start fetching token transactions from.
|
|
37
|
-
* @param request.limit - Number of token transactions to retrieve.
|
|
38
|
-
* @returns An Etherscan response object containing the request status and an array of token transaction data.
|
|
39
|
-
*/
|
|
40
|
-
async function fetchEtherscanTokenTransactions({ address, apiKey, chainId, fromBlock, limit, }) {
|
|
41
|
-
return await fetchTransactions('tokentx', {
|
|
42
|
-
address,
|
|
43
|
-
apiKey,
|
|
44
|
-
chainId,
|
|
45
|
-
fromBlock,
|
|
46
|
-
limit,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
exports.fetchEtherscanTokenTransactions = fetchEtherscanTokenTransactions;
|
|
50
|
-
/**
|
|
51
|
-
* Retrieves transaction data from Etherscan from a specific endpoint.
|
|
52
|
-
*
|
|
53
|
-
* @param action - The Etherscan endpoint to use.
|
|
54
|
-
* @param options - Options bag.
|
|
55
|
-
* @param options.address - Address to retrieve transactions for.
|
|
56
|
-
* @param options.apiKey - Etherscan API key to prevent rate limiting.
|
|
57
|
-
* @param options.chainId - Current chain ID used to determine subdomain and domain.
|
|
58
|
-
* @param options.fromBlock - Block number to start fetching transactions from.
|
|
59
|
-
* @param options.limit - Number of transactions to retrieve.
|
|
60
|
-
* @returns An object containing the request status and an array of transaction data.
|
|
61
|
-
*/
|
|
62
|
-
async function fetchTransactions(action, { address, apiKey, chainId, fromBlock, limit, }) {
|
|
63
|
-
const urlParams = {
|
|
64
|
-
module: 'account',
|
|
65
|
-
address,
|
|
66
|
-
startBlock: fromBlock?.toString(),
|
|
67
|
-
offset: limit?.toString(),
|
|
68
|
-
sort: 'desc',
|
|
69
|
-
};
|
|
70
|
-
const etherscanTxUrl = getEtherscanApiUrl(chainId, {
|
|
71
|
-
...urlParams,
|
|
72
|
-
action,
|
|
73
|
-
apikey: apiKey,
|
|
74
|
-
});
|
|
75
|
-
log('Sending request', etherscanTxUrl);
|
|
76
|
-
const response = (await (0, controller_utils_1.handleFetch)(etherscanTxUrl));
|
|
77
|
-
return response;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Return a URL that can be used to fetch data from Etherscan.
|
|
81
|
-
*
|
|
82
|
-
* @param chainId - Current chain ID used to determine subdomain and domain.
|
|
83
|
-
* @param urlParams - The parameters used to construct the URL.
|
|
84
|
-
* @returns URL to access Etherscan data.
|
|
85
|
-
*/
|
|
86
|
-
function getEtherscanApiUrl(chainId, urlParams) {
|
|
87
|
-
const apiUrl = getEtherscanApiHost(chainId);
|
|
88
|
-
let url = `${apiUrl}/api?`;
|
|
89
|
-
for (const paramKey of Object.keys(urlParams)) {
|
|
90
|
-
const value = urlParams[paramKey];
|
|
91
|
-
if (!value) {
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
url += `${paramKey}=${value}&`;
|
|
95
|
-
}
|
|
96
|
-
url += 'tag=latest&page=1';
|
|
97
|
-
return url;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Return the host url used to fetch data from Etherscan.
|
|
101
|
-
*
|
|
102
|
-
* @param chainId - Current chain ID used to determine subdomain and domain.
|
|
103
|
-
* @returns host URL to access Etherscan data.
|
|
104
|
-
*/
|
|
105
|
-
function getEtherscanApiHost(chainId) {
|
|
106
|
-
// @ts-expect-error We account for `chainId` not being a property below
|
|
107
|
-
const networkInfo = constants_1.ETHERSCAN_SUPPORTED_NETWORKS[chainId];
|
|
108
|
-
if (!networkInfo) {
|
|
109
|
-
throw new Error(`Etherscan does not support chain with ID: ${chainId}`);
|
|
110
|
-
}
|
|
111
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
112
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
113
|
-
return `https://${networkInfo.subdomain}.${networkInfo.domain}`;
|
|
114
|
-
}
|
|
115
|
-
exports.getEtherscanApiHost = getEtherscanApiHost;
|
|
116
|
-
//# sourceMappingURL=etherscan.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"etherscan.cjs","sourceRoot":"","sources":["../../src/utils/etherscan.ts"],"names":[],"mappings":";;;AAAA,iEAAyD;AAGzD,gDAA4D;AAC5D,0CAA8D;AAE9D,MAAM,GAAG,GAAG,IAAA,2BAAkB,EAAC,sBAAa,EAAE,WAAW,CAAC,CAAC;AAsE3D;;;;;;;;;;GAUG;AACI,KAAK,UAAU,0BAA0B,CAAC,EAC/C,OAAO,EACP,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,GACuB;IAG5B,OAAO,MAAM,iBAAiB,CAAC,QAAQ,EAAE;QACvC,OAAO;QACP,MAAM;QACN,OAAO;QACP,SAAS;QACT,KAAK;KACN,CAAC,CAAC;AACL,CAAC;AAhBD,gEAgBC;AAED;;;;;;;;;;GAUG;AACI,KAAK,UAAU,+BAA+B,CAAC,EACpD,OAAO,EACP,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,GACuB;IAG5B,OAAO,MAAM,iBAAiB,CAAC,SAAS,EAAE;QACxC,OAAO;QACP,MAAM;QACN,OAAO;QACP,SAAS;QACT,KAAK;KACN,CAAC,CAAC;AACL,CAAC;AAhBD,0EAgBC;AAED;;;;;;;;;;;GAWG;AACH,KAAK,UAAU,iBAAiB,CAG9B,MAAc,EACd,EACE,OAAO,EACP,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,GAON;IAED,MAAM,SAAS,GAAG;QAChB,MAAM,EAAE,SAAS;QACjB,OAAO;QACP,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE;QACjC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE;QACzB,IAAI,EAAE,MAAM;KACb,CAAC;IAEF,MAAM,cAAc,GAAG,kBAAkB,CAAC,OAAO,EAAE;QACjD,GAAG,SAAS;QACZ,MAAM;QACN,MAAM,EAAE,MAAM;KACf,CAAC,CAAC;IAEH,GAAG,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC;IAEvC,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAA,8BAAW,EACjC,cAAc,CACf,CAA+C,CAAC;IAEjD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CACzB,OAAY,EACZ,SAA6C;IAE7C,MAAM,MAAM,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC5C,IAAI,GAAG,GAAG,GAAG,MAAM,OAAO,CAAC;IAE3B,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QAC7C,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QAElC,IAAI,CAAC,KAAK,EAAE;YACV,SAAS;SACV;QAED,GAAG,IAAI,GAAG,QAAQ,IAAI,KAAK,GAAG,CAAC;KAChC;IAED,GAAG,IAAI,mBAAmB,CAAC;IAE3B,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,OAAY;IAC9C,uEAAuE;IACvE,MAAM,WAAW,GAAG,wCAA4B,CAAC,OAAO,CAAC,CAAC;IAE1D,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,6CAA6C,OAAO,EAAE,CAAC,CAAC;KACzE;IAED,gFAAgF;IAChF,4EAA4E;IAC5E,OAAO,WAAW,WAAW,CAAC,SAAS,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;AAClE,CAAC;AAXD,kDAWC","sourcesContent":["import { handleFetch } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { ETHERSCAN_SUPPORTED_NETWORKS } from '../constants';\nimport { createModuleLogger, projectLogger } from '../logger';\n\nconst log = createModuleLogger(projectLogger, 'etherscan');\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\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\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface EtherscanTransactionMeta extends EtherscanTransactionMetaBase {\n functionName: string;\n input: string;\n isError: string;\n methodId: string;\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n txreceipt_status: string;\n}\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface EtherscanTokenTransactionMeta\n extends EtherscanTransactionMetaBase {\n tokenDecimal: string;\n tokenName: string;\n tokenSymbol: string;\n}\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface EtherscanTransactionResponse<\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n T extends EtherscanTransactionMetaBase,\n> {\n status: '0' | '1';\n message?: string;\n result: string | T[];\n}\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface EtherscanTransactionRequest {\n address: string;\n apiKey?: string;\n chainId: Hex;\n fromBlock?: number;\n limit?: number;\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 to prevent rate limiting.\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 to prevent rate limiting.\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 to prevent rate limiting.\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<\n ResponseData extends EtherscanTransactionMetaBase,\n>(\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<ResponseData>> {\n const urlParams = {\n module: 'account',\n address,\n startBlock: fromBlock?.toString(),\n offset: limit?.toString(),\n sort: 'desc',\n };\n\n const etherscanTxUrl = getEtherscanApiUrl(chainId, {\n ...urlParams,\n action,\n apikey: apiKey,\n });\n\n log('Sending request', etherscanTxUrl);\n\n const response = (await handleFetch(\n etherscanTxUrl,\n )) as EtherscanTransactionResponse<ResponseData>;\n\n return response;\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 const apiUrl = getEtherscanApiHost(chainId);\n let url = `${apiUrl}/api?`;\n\n for (const paramKey of Object.keys(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\n/**\n * Return the host url used to fetch data from Etherscan.\n *\n * @param chainId - Current chain ID used to determine subdomain and domain.\n * @returns host URL to access Etherscan data.\n */\nexport function getEtherscanApiHost(chainId: Hex) {\n // @ts-expect-error We account for `chainId` not being a property below\n const networkInfo = ETHERSCAN_SUPPORTED_NETWORKS[chainId];\n\n if (!networkInfo) {\n throw new Error(`Etherscan does not support chain with ID: ${chainId}`);\n }\n\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n return `https://${networkInfo.subdomain}.${networkInfo.domain}`;\n}\n"]}
|
|
@@ -1,74 +0,0 @@
|
|
|
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
|
-
status: '0' | '1';
|
|
33
|
-
message?: string;
|
|
34
|
-
result: string | T[];
|
|
35
|
-
}
|
|
36
|
-
export interface EtherscanTransactionRequest {
|
|
37
|
-
address: string;
|
|
38
|
-
apiKey?: string;
|
|
39
|
-
chainId: Hex;
|
|
40
|
-
fromBlock?: number;
|
|
41
|
-
limit?: number;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Retrieves transaction data from Etherscan.
|
|
45
|
-
*
|
|
46
|
-
* @param request - Configuration required to fetch transactions.
|
|
47
|
-
* @param request.address - Address to retrieve transactions for.
|
|
48
|
-
* @param request.apiKey - Etherscan API key to prevent rate limiting.
|
|
49
|
-
* @param request.chainId - Current chain ID used to determine subdomain and domain.
|
|
50
|
-
* @param request.fromBlock - Block number to start fetching transactions from.
|
|
51
|
-
* @param request.limit - Number of transactions to retrieve.
|
|
52
|
-
* @returns An Etherscan response object containing the request status and an array of token transaction data.
|
|
53
|
-
*/
|
|
54
|
-
export declare function fetchEtherscanTransactions({ address, apiKey, chainId, fromBlock, limit, }: EtherscanTransactionRequest): Promise<EtherscanTransactionResponse<EtherscanTransactionMeta>>;
|
|
55
|
-
/**
|
|
56
|
-
* Retrieves token transaction data from Etherscan.
|
|
57
|
-
*
|
|
58
|
-
* @param request - Configuration required to fetch token transactions.
|
|
59
|
-
* @param request.address - Address to retrieve token transactions for.
|
|
60
|
-
* @param request.apiKey - Etherscan API key to prevent rate limiting.
|
|
61
|
-
* @param request.chainId - Current chain ID used to determine subdomain and domain.
|
|
62
|
-
* @param request.fromBlock - Block number to start fetching token transactions from.
|
|
63
|
-
* @param request.limit - Number of token transactions to retrieve.
|
|
64
|
-
* @returns An Etherscan response object containing the request status and an array of token transaction data.
|
|
65
|
-
*/
|
|
66
|
-
export declare function fetchEtherscanTokenTransactions({ address, apiKey, chainId, fromBlock, limit, }: EtherscanTransactionRequest): Promise<EtherscanTransactionResponse<EtherscanTokenTransactionMeta>>;
|
|
67
|
-
/**
|
|
68
|
-
* Return the host url used to fetch data from Etherscan.
|
|
69
|
-
*
|
|
70
|
-
* @param chainId - Current chain ID used to determine subdomain and domain.
|
|
71
|
-
* @returns host URL to access Etherscan data.
|
|
72
|
-
*/
|
|
73
|
-
export declare function getEtherscanApiHost(chainId: Hex): string;
|
|
74
|
-
//# sourceMappingURL=etherscan.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"etherscan.d.cts","sourceRoot":"","sources":["../../src/utils/etherscan.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAU3C,MAAM,WAAW,4BAA4B;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAA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