@ledgerhq/coin-evm 16.4.0 → 16.5.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 +18 -0
- package/lib/adapters/etherscan.d.ts.map +1 -1
- package/lib/adapters/etherscan.js +4 -1
- package/lib/adapters/etherscan.js.map +1 -1
- package/lib/config.d.ts +27 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +21 -3
- package/lib/config.js.map +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +66 -6
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib/logic/internalTransactionsFetcher.js +47 -20
- package/lib/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib-es/adapters/etherscan.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.js +4 -1
- package/lib-es/adapters/etherscan.js.map +1 -1
- package/lib-es/config.d.ts +27 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js +21 -3
- package/lib-es/config.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +66 -6
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.js +47 -20
- package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
- package/package.json +3 -3
- package/src/adapters/etherscan.test.ts +16 -0
- package/src/adapters/etherscan.ts +4 -1
- package/src/config.ts +21 -3
- package/src/logic/getBlock.ts +88 -5
- package/src/logic/internalTransactionsFetcher.ts +55 -23
- package/src/logic/tests/getBlock.test.ts +203 -3
- package/src/logic/tests/internalTransactionsFetcher.test.ts +48 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBlock.js","sourceRoot":"","sources":["../../src/logic/getBlock.ts"],"names":[],"mappings":"AAAA,4CAA4C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rD,CAAA;IACD,IAAI,CAAC,UAAU;QAAE,OAAO,iBAAiB,CAAA;IACzC,MAAM,YAAY,GAA2B;QAC3C,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,MAAM,EAAE,UAAU,CAAC,MAAM;KAC1B,CAAA;IACD,OAAO;QACL,YAAY;QACZ,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,UAAU,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;KAC1F,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalTransactionsFetcher.d.ts","sourceRoot":"","sources":["../../src/logic/internalTransactionsFetcher.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAC/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAA;AAWpE,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAA;AAE7D,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"internalTransactionsFetcher.d.ts","sourceRoot":"","sources":["../../src/logic/internalTransactionsFetcher.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAC/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAA;AAWpE,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAA;AAE7D,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAA;AA2F1E,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,QAAQ,EAAE,MAAM,CAAC,gBAAgB,EAAE,aAAa,CAAC,GAChD,aAAa,CAEf;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAwDzC;AAED,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,MAAM,EAAE,MAAM,GACb,aAAa,CAEf"}
|
|
@@ -6,40 +6,67 @@ import { SourceUnavailableError } from '../errors';
|
|
|
6
6
|
import { getInternalTransactionsByBlock as getBlockscoutV2InternalTransactionsByBlock } from '../network/blockscoutV2';
|
|
7
7
|
import { getInternalTransactionsByBlock } from '../network/explorer/etherscan';
|
|
8
8
|
import { isBlockscoutV2ExplorerConfig, isEtherscanLikeExplorerConfig, } from '../network/explorer/types';
|
|
9
|
-
function
|
|
10
|
-
if (
|
|
11
|
-
|
|
9
|
+
function describeError(error) {
|
|
10
|
+
if (!(error instanceof Error))
|
|
11
|
+
return String(error);
|
|
12
|
+
const { cause } = error;
|
|
13
|
+
return cause === undefined ? error.message : `${error.message} (cause: ${describeError(cause)})`;
|
|
14
|
+
}
|
|
15
|
+
function describeFailures(failures) {
|
|
16
|
+
return failures.map(({ source, error }) => `[${source}] ${describeError(error)}`).join('; ');
|
|
17
|
+
}
|
|
18
|
+
function throwCollectedFailures(failures) {
|
|
19
|
+
const [first] = failures;
|
|
20
|
+
if (failures.length === 1 && first !== undefined) {
|
|
21
|
+
throw first.error;
|
|
22
|
+
}
|
|
23
|
+
throw new AggregateError(failures.map(({ error }) => error), `internal tx sources failed: ${describeFailures(failures)}`);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Records a failed source. Real errors are always kept. Unavailable errors are kept only when
|
|
27
|
+
* they carry a cause, because that cause is otherwise lost.
|
|
28
|
+
* Returns whether the error was real.
|
|
29
|
+
*/
|
|
30
|
+
function recordFailure(failures, source, error) {
|
|
31
|
+
if (!(error instanceof SourceUnavailableError)) {
|
|
32
|
+
failures.push({ source, error });
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
if (error.cause !== undefined)
|
|
36
|
+
failures.push({ source, error });
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
function throwExhausted(failures, hadUnavailableSource) {
|
|
40
|
+
if (hadUnavailableSource) {
|
|
41
|
+
const details = failures.length > 0 ? `: ${describeFailures(failures)}` : '';
|
|
42
|
+
throw new SourceUnavailableError(`all internal tx sources unavailable${details}`);
|
|
12
43
|
}
|
|
13
|
-
throw new
|
|
44
|
+
throw new Error('no internal tx sources configured');
|
|
14
45
|
}
|
|
15
46
|
async function runInternalTxSources(sources, fetchers, height) {
|
|
16
|
-
|
|
47
|
+
// Real errors, plus unavailable errors that carry a cause, in source order.
|
|
48
|
+
const failures = [];
|
|
49
|
+
let hasRealError = false;
|
|
17
50
|
let hadUnavailableSource = false;
|
|
18
51
|
for (const source of sources) {
|
|
19
52
|
if (source === 'empty') {
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
}
|
|
53
|
+
if (hasRealError)
|
|
54
|
+
throwCollectedFailures(failures);
|
|
23
55
|
return new Map();
|
|
24
56
|
}
|
|
25
57
|
try {
|
|
26
58
|
return await fetchers[source](height);
|
|
27
59
|
}
|
|
28
60
|
catch (error) {
|
|
29
|
-
if (
|
|
61
|
+
if (recordFailure(failures, source, error))
|
|
62
|
+
hasRealError = true;
|
|
63
|
+
else
|
|
30
64
|
hadUnavailableSource = true;
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
realErrors.push(error);
|
|
34
65
|
}
|
|
35
66
|
}
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (hadUnavailableSource) {
|
|
40
|
-
throw new SourceUnavailableError('all internal tx sources unavailable');
|
|
41
|
-
}
|
|
42
|
-
throw new Error('no internal tx sources configured');
|
|
67
|
+
if (hasRealError)
|
|
68
|
+
throwCollectedFailures(failures);
|
|
69
|
+
return throwExhausted(failures, hadUnavailableSource);
|
|
43
70
|
}
|
|
44
71
|
function explorerInternalTxsByBlock(explorer) {
|
|
45
72
|
if (isBlockscoutV2ExplorerConfig(explorer)) {
|
|
@@ -93,7 +120,7 @@ export function makeSourceFetchers(config, nodeApi, logger) {
|
|
|
93
120
|
blockHeight: height,
|
|
94
121
|
error,
|
|
95
122
|
});
|
|
96
|
-
throw new SourceUnavailableError('explorer internal txs failed');
|
|
123
|
+
throw new SourceUnavailableError('explorer internal txs failed', { cause: error });
|
|
97
124
|
});
|
|
98
125
|
},
|
|
99
126
|
empty: async () => new Map(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalTransactionsFetcher.js","sourceRoot":"","sources":["../../src/logic/internalTransactionsFetcher.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAOtC,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAA;AAC/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,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CACnE,CACF,CAAA;YACH,CAAC;YACD,OAAO,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC;iBAC9B,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,6BAA6B,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;iBACzD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACf,MAAM,CAAC,UAAU,EAAE,sDAAsD,EAAE;oBACzE,QAAQ,EAAE,MAAM,CAAC,IAAI;oBACrB,WAAW,EAAE,MAAM;oBACnB,KAAK;iBACN,CAAC,CAAA;gBACF,MAAM,IAAI,sBAAsB,CAAC,8BAA8B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;YACpF,CAAC,CAAC,CAAA;QACN,CAAC;QACD,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,GAAG,EAA4B;KACvD,CAAA;AACH,CAAC;AAED,MAAM,UAAU,iCAAiC,CAC/C,MAAqB,EACrB,OAAgB,EAChB,OAAoC,EACpC,MAAc;IAEd,OAAO,yBAAyB,CAAC,OAAO,EAAE,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAA;AACxF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-evm",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.5.0",
|
|
4
4
|
"description": "Ledger EVM Coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -137,8 +137,8 @@
|
|
|
137
137
|
"jest-sonar": "0.2.16",
|
|
138
138
|
"jest": "30.2.0",
|
|
139
139
|
"jest-expect-message": "^1.1.3",
|
|
140
|
-
"oxfmt": "0.
|
|
141
|
-
"oxlint": "1.
|
|
140
|
+
"oxfmt": "0.75.0",
|
|
141
|
+
"oxlint": "1.90.0",
|
|
142
142
|
"typescript": "6.0.2",
|
|
143
143
|
"@ledgerhq/live-network": "3.1.0"
|
|
144
144
|
},
|
|
@@ -2134,6 +2134,22 @@ describe('EVM Family', () => {
|
|
|
2134
2134
|
expect(byHash.size).toBe(0)
|
|
2135
2135
|
})
|
|
2136
2136
|
|
|
2137
|
+
it.each(['0x', '0x0'])(
|
|
2138
|
+
'leaves the credit of an internal tx from placeholder sender %s with no peer',
|
|
2139
|
+
(from) => {
|
|
2140
|
+
const internalTxs = [{ ...baseInternalTx, hash: '0xtx1', from, value: '1000' }]
|
|
2141
|
+
const ops = internalTxsToOperationsByHash(internalTxs, testLogger).get('0xtx1')!
|
|
2142
|
+
expect(ops).toEqual([
|
|
2143
|
+
{
|
|
2144
|
+
type: 'transfer',
|
|
2145
|
+
address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
|
|
2146
|
+
asset: { type: 'native' },
|
|
2147
|
+
amount: 1000n,
|
|
2148
|
+
},
|
|
2149
|
+
])
|
|
2150
|
+
}
|
|
2151
|
+
)
|
|
2152
|
+
|
|
2137
2153
|
it('returns empty map for empty internal txs array', () => {
|
|
2138
2154
|
const byHash = internalTxsToOperationsByHash([], testLogger)
|
|
2139
2155
|
expect(byHash.size).toBe(0)
|
|
@@ -421,10 +421,13 @@ export function internalTxsToOperationsByHash(
|
|
|
421
421
|
asset: NATIVE_ASSET,
|
|
422
422
|
amount: -amount,
|
|
423
423
|
}
|
|
424
|
+
// Built on its own, not from `fromOp`: a placeholder sender ('0x', '0x0') encodes to '' and
|
|
425
|
+
// must leave the credit with no peer, not with the recipient inherited from `fromOp`.
|
|
424
426
|
const toOp: TransferBlockOperation = {
|
|
425
|
-
|
|
427
|
+
type: 'transfer',
|
|
426
428
|
address: encodedTo,
|
|
427
429
|
...(encodedFrom ? { peer: encodedFrom } : {}),
|
|
430
|
+
asset: NATIVE_ASSET,
|
|
428
431
|
amount: amount,
|
|
429
432
|
}
|
|
430
433
|
if (encodedFrom) {
|
package/src/config.ts
CHANGED
|
@@ -1154,10 +1154,10 @@ export const evmDefaults = {
|
|
|
1154
1154
|
chainId: 20310,
|
|
1155
1155
|
name: 'Alpen Testnet',
|
|
1156
1156
|
unit: { name: 'BTC', code: 'BTC', magnitude: 18 },
|
|
1157
|
-
node: { type: 'external', uri: 'https://alpen
|
|
1157
|
+
node: { type: 'external', uri: 'https://alpen-testnet.coin.ledger.com' },
|
|
1158
1158
|
explorer: {
|
|
1159
|
-
type: 'blockscout',
|
|
1160
|
-
uri: 'https://explorer.
|
|
1159
|
+
type: 'blockscout-v2',
|
|
1160
|
+
uri: 'https://alpen-testnet-explorer.api.ledger.com/api/v2',
|
|
1161
1161
|
},
|
|
1162
1162
|
// Alpen's fee market is sparse: the base fee holds at 0.000875-0.001 gwei and
|
|
1163
1163
|
// eth_feeHistory reports no tips, so EIP-1559 estimation falls back to a 1 gwei tip
|
|
@@ -1166,4 +1166,22 @@ export const evmDefaults = {
|
|
|
1166
1166
|
forceLegacyTransactions: true,
|
|
1167
1167
|
minGasPrice: '2000000',
|
|
1168
1168
|
},
|
|
1169
|
+
alpen: {
|
|
1170
|
+
status: {
|
|
1171
|
+
type: 'active',
|
|
1172
|
+
features: [{ id: 'blockchain_txs', status: 'active' }],
|
|
1173
|
+
},
|
|
1174
|
+
chainId: 29032,
|
|
1175
|
+
name: 'Alpen',
|
|
1176
|
+
unit: { name: 'BTC', code: 'BTC', magnitude: 18 },
|
|
1177
|
+
node: { type: 'external', uri: 'https://alpen.coin.ledger.com' },
|
|
1178
|
+
explorer: {
|
|
1179
|
+
type: 'blockscout-v2',
|
|
1180
|
+
uri: 'https://alpen-explorer.api.ledger.com/api/v2',
|
|
1181
|
+
},
|
|
1182
|
+
// Same sparse fee market as Alpen Testnet, with a base fee of 0.00025 gwei and no tips:
|
|
1183
|
+
// price as legacy from eth_gasPrice, with a 2x-base-fee floor.
|
|
1184
|
+
forceLegacyTransactions: true,
|
|
1185
|
+
minGasPrice: '500000',
|
|
1186
|
+
},
|
|
1169
1187
|
} satisfies Record<string, EvmConfigInfo>
|
package/src/logic/getBlock.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import type { ChainId, EvmContext } from '../config'
|
|
5
5
|
import type { BlockReceiptInfo, PrefetchedBlockTransaction } from '../network/node/types'
|
|
6
|
+
import type { EvmStakingOperationType } from '../types/staking'
|
|
6
7
|
import type { InternalTxsByHash } from './internalTransactionsFetcher'
|
|
7
8
|
import type {
|
|
8
9
|
Block,
|
|
@@ -18,6 +19,7 @@ import { CHAIN_ID, DEFAULT_INTERNAL_TX_SOURCES } from '../config'
|
|
|
18
19
|
import { UnsupportedRpcMethodError } from '../errors'
|
|
19
20
|
import { buildSmartContractDetails, safeEncodeEIP55 } from '../logic-public'
|
|
20
21
|
import { getNodeApi } from '../network/node'
|
|
22
|
+
import { detectEvmStakingOperationType } from '../staking/detectOperationType'
|
|
21
23
|
import { createInternalTransactionsFetcher } from './internalTransactionsFetcher'
|
|
22
24
|
import { dropRootTraceDuplicates } from './rootTraceDedup'
|
|
23
25
|
|
|
@@ -61,7 +63,7 @@ export async function getBlock(context: EvmContext, height: number): Promise<Blo
|
|
|
61
63
|
// Internal transactions only exist inside transactions, so a block with none has nothing to
|
|
62
64
|
// merge. Skipping the fetch avoids a request for a guaranteed-empty answer — on the `explorer`
|
|
63
65
|
// source that is one metered `txlistinternal` call per empty block.
|
|
64
|
-
const [
|
|
66
|
+
const [transactionsResult, internalTxsResult] = await Promise.allSettled([
|
|
65
67
|
getTransactionsFromNode(
|
|
66
68
|
config.chainId,
|
|
67
69
|
config.name,
|
|
@@ -76,6 +78,19 @@ export async function getBlock(context: EvmContext, height: number): Promise<Blo
|
|
|
76
78
|
: fetchInternalTxs(height),
|
|
77
79
|
])
|
|
78
80
|
|
|
81
|
+
// Wait for both calls, so that no error is lost when both fail.
|
|
82
|
+
if (transactionsResult.status === 'rejected' && internalTxsResult.status === 'rejected') {
|
|
83
|
+
throw new AggregateError(
|
|
84
|
+
[transactionsResult.reason, internalTxsResult.reason],
|
|
85
|
+
`getBlock ${height} failed: transactions: ${describeReason(transactionsResult.reason)}; internal transactions: ${describeReason(internalTxsResult.reason)}`
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
if (transactionsResult.status === 'rejected') throw transactionsResult.reason
|
|
89
|
+
if (internalTxsResult.status === 'rejected') throw internalTxsResult.reason
|
|
90
|
+
|
|
91
|
+
const transactions = transactionsResult.value
|
|
92
|
+
const internalTxs = internalTxsResult.value
|
|
93
|
+
|
|
79
94
|
const mergedTransactions = mergeInternalTransactions(transactions, internalTxs)
|
|
80
95
|
|
|
81
96
|
return {
|
|
@@ -84,6 +99,10 @@ export async function getBlock(context: EvmContext, height: number): Promise<Blo
|
|
|
84
99
|
}
|
|
85
100
|
}
|
|
86
101
|
|
|
102
|
+
function describeReason(reason: unknown): string {
|
|
103
|
+
return reason instanceof Error ? reason.message : String(reason)
|
|
104
|
+
}
|
|
105
|
+
|
|
87
106
|
/**
|
|
88
107
|
* Merges internal transaction operations into block transactions by matching tx hash.
|
|
89
108
|
*
|
|
@@ -113,13 +132,55 @@ function mergeInternalTransactions(
|
|
|
113
132
|
if (!extraOps || extraOps.length === 0) return tx
|
|
114
133
|
const dedupedExtraOps = dropRootTraceDuplicates(tx.operations, extraOps)
|
|
115
134
|
if (dedupedExtraOps.length === 0) return tx
|
|
135
|
+
const internalTransfers = toInternalTransfers(dedupedExtraOps)
|
|
116
136
|
return {
|
|
117
137
|
...tx,
|
|
118
138
|
operations: [...tx.operations, ...dedupedExtraOps],
|
|
139
|
+
...(internalTransfers.length > 0 ? { details: { ...tx.details, internalTransfers } } : {}),
|
|
119
140
|
}
|
|
120
141
|
})
|
|
121
142
|
}
|
|
122
143
|
|
|
144
|
+
/**
|
|
145
|
+
* An internal transfer appended to the operations of a block transaction, as listed in the
|
|
146
|
+
* `internalTransfers` detail. `value` is in wei, as a decimal string.
|
|
147
|
+
*/
|
|
148
|
+
type InternalTransferDetail = {
|
|
149
|
+
from?: string
|
|
150
|
+
to?: string
|
|
151
|
+
value: string
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Describes the internal transfers that {@link mergeInternalTransactions} appends to a block
|
|
156
|
+
* transaction, so that consumers can tell them apart from the top-level transfers.
|
|
157
|
+
*
|
|
158
|
+
* The adapters turn each internal transfer into a debit op (`address = from`, `peer = to`,
|
|
159
|
+
* negative amount) followed by a credit op (`address = to`, `peer = from`, positive amount),
|
|
160
|
+
* leaving out the side whose address is unknown. The root-trace dedup drops both ops of a pair
|
|
161
|
+
* or none. So a debit op stands for one transfer, and a credit op stands for one only when it
|
|
162
|
+
* has no peer (no debit op was emitted for it).
|
|
163
|
+
*/
|
|
164
|
+
function toInternalTransfers(internalOps: readonly BlockOperation[]): InternalTransferDetail[] {
|
|
165
|
+
const transfers: InternalTransferDetail[] = []
|
|
166
|
+
for (const op of internalOps) {
|
|
167
|
+
if (op.type !== 'transfer' || op.asset.type !== 'native') continue
|
|
168
|
+
if (op.amount < 0n) {
|
|
169
|
+
transfers.push({
|
|
170
|
+
from: op.address,
|
|
171
|
+
...(op.peer !== undefined ? { to: op.peer } : {}),
|
|
172
|
+
value: (-op.amount).toString(),
|
|
173
|
+
})
|
|
174
|
+
} else if (op.peer === undefined) {
|
|
175
|
+
transfers.push({
|
|
176
|
+
to: op.address,
|
|
177
|
+
value: op.amount.toString(),
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return transfers
|
|
182
|
+
}
|
|
183
|
+
|
|
123
184
|
async function getTransactionsFromNode(
|
|
124
185
|
chainId: ChainId,
|
|
125
186
|
chainName: string,
|
|
@@ -177,7 +238,7 @@ async function getTransactionsFromPrefetchedData(
|
|
|
177
238
|
for (const tx of prefetchedTransactions) {
|
|
178
239
|
const receipt = receiptsByHash.get(tx.hash)
|
|
179
240
|
if (!receipt) return null
|
|
180
|
-
const blockTx = prefetchedTransactionToBlockTransaction(tx, receipt, logger)
|
|
241
|
+
const blockTx = prefetchedTransactionToBlockTransaction(chainId, tx, receipt, logger)
|
|
181
242
|
transactions.push({
|
|
182
243
|
...blockTx,
|
|
183
244
|
operations: applyChainSpecificCorrections(
|
|
@@ -204,6 +265,7 @@ async function getTransactionsFromPrefetchedData(
|
|
|
204
265
|
}
|
|
205
266
|
|
|
206
267
|
function prefetchedTransactionToBlockTransaction(
|
|
268
|
+
chainId: ChainId,
|
|
207
269
|
tx: PrefetchedBlockTransaction,
|
|
208
270
|
receipt: BlockReceiptInfo,
|
|
209
271
|
logger: Logger
|
|
@@ -229,7 +291,8 @@ function prefetchedTransactionToBlockTransaction(
|
|
|
229
291
|
gasPrice,
|
|
230
292
|
tx.gasLimit,
|
|
231
293
|
tx.nonce,
|
|
232
|
-
buildSmartContractDetails(tx.to, tx.input, logger, receipt.contractAddress)
|
|
294
|
+
buildSmartContractDetails(tx.to, tx.input, logger, receipt.contractAddress),
|
|
295
|
+
detectStakingOperationType(chainId, tx.to, tx.input)
|
|
233
296
|
)
|
|
234
297
|
|
|
235
298
|
return {
|
|
@@ -261,7 +324,8 @@ async function getTransactionFromHash(
|
|
|
261
324
|
BigInt(txInfo.gasPrice),
|
|
262
325
|
txInfo.gasLimit,
|
|
263
326
|
txInfo.nonce,
|
|
264
|
-
buildSmartContractDetails(txInfo.to, txInfo.input, logger, txInfo.contractAddress)
|
|
327
|
+
buildSmartContractDetails(txInfo.to, txInfo.input, logger, txInfo.contractAddress),
|
|
328
|
+
detectStakingOperationType(chainId, txInfo.to, txInfo.input)
|
|
265
329
|
)
|
|
266
330
|
|
|
267
331
|
return {
|
|
@@ -282,21 +346,40 @@ async function getTransactionFromHash(
|
|
|
282
346
|
* @param gasLimit gas limit set by the sender (decimal), when known
|
|
283
347
|
* @param nonce nonce of the transaction, when known
|
|
284
348
|
* @param smartContractDetails details of the contract interaction or deployment, if any
|
|
349
|
+
* @param stakingOperationType staking operation type of the transaction, if it is a staking call
|
|
285
350
|
*/
|
|
286
351
|
function buildTransactionDetails(
|
|
287
352
|
gasPrice: bigint,
|
|
288
353
|
gasLimit: string | undefined,
|
|
289
354
|
nonce: number | undefined,
|
|
290
|
-
smartContractDetails: Record<string, unknown> | undefined
|
|
355
|
+
smartContractDetails: Record<string, unknown> | undefined,
|
|
356
|
+
stakingOperationType: EvmStakingOperationType | undefined
|
|
291
357
|
): Record<string, unknown> {
|
|
292
358
|
return {
|
|
293
359
|
gasPrice: gasPrice.toString(),
|
|
294
360
|
...(gasLimit !== undefined ? { gasLimit } : {}),
|
|
295
361
|
...(nonce !== undefined ? { sequence: nonce } : {}),
|
|
296
362
|
...(smartContractDetails ?? {}),
|
|
363
|
+
...(stakingOperationType !== undefined ? { ledgerOpType: stakingOperationType } : {}),
|
|
297
364
|
}
|
|
298
365
|
}
|
|
299
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Detects a staking call (delegate, undelegate, redelegate, withdraw, reward) from the
|
|
369
|
+
* recipient and the function selector of the transaction, like {@link listOperations} does.
|
|
370
|
+
*
|
|
371
|
+
* @param chainId chain of the transaction
|
|
372
|
+
* @param to recipient of the transaction, undefined on a contract deployment
|
|
373
|
+
* @param input call data of the transaction, if any
|
|
374
|
+
*/
|
|
375
|
+
function detectStakingOperationType(
|
|
376
|
+
chainId: ChainId,
|
|
377
|
+
to: string | undefined,
|
|
378
|
+
input: string | undefined
|
|
379
|
+
): EvmStakingOperationType | undefined {
|
|
380
|
+
return detectEvmStakingOperationType(chainId, to, input?.slice(0, 10))
|
|
381
|
+
}
|
|
382
|
+
|
|
300
383
|
function applyChainSpecificCorrections(
|
|
301
384
|
chainId: ChainId,
|
|
302
385
|
operations: BlockOperation[],
|
|
@@ -20,11 +20,53 @@ export type InternalTxsByHash = Map<string, BlockOperation[]>
|
|
|
20
20
|
|
|
21
21
|
export type SourceFetcher = (height: number) => Promise<InternalTxsByHash>
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
type SourceFailure = { source: InternalTxSource; error: unknown }
|
|
24
|
+
|
|
25
|
+
function describeError(error: unknown): string {
|
|
26
|
+
if (!(error instanceof Error)) return String(error)
|
|
27
|
+
const { cause } = error
|
|
28
|
+
return cause === undefined ? error.message : `${error.message} (cause: ${describeError(cause)})`
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function describeFailures(failures: readonly SourceFailure[]): string {
|
|
32
|
+
return failures.map(({ source, error }) => `[${source}] ${describeError(error)}`).join('; ')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function throwCollectedFailures(failures: readonly SourceFailure[]): never {
|
|
36
|
+
const [first] = failures
|
|
37
|
+
if (failures.length === 1 && first !== undefined) {
|
|
38
|
+
throw first.error
|
|
26
39
|
}
|
|
27
|
-
throw new AggregateError(
|
|
40
|
+
throw new AggregateError(
|
|
41
|
+
failures.map(({ error }) => error),
|
|
42
|
+
`internal tx sources failed: ${describeFailures(failures)}`
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Records a failed source. Real errors are always kept. Unavailable errors are kept only when
|
|
48
|
+
* they carry a cause, because that cause is otherwise lost.
|
|
49
|
+
* Returns whether the error was real.
|
|
50
|
+
*/
|
|
51
|
+
function recordFailure(
|
|
52
|
+
failures: SourceFailure[],
|
|
53
|
+
source: InternalTxSource,
|
|
54
|
+
error: unknown
|
|
55
|
+
): boolean {
|
|
56
|
+
if (!(error instanceof SourceUnavailableError)) {
|
|
57
|
+
failures.push({ source, error })
|
|
58
|
+
return true
|
|
59
|
+
}
|
|
60
|
+
if (error.cause !== undefined) failures.push({ source, error })
|
|
61
|
+
return false
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function throwExhausted(failures: readonly SourceFailure[], hadUnavailableSource: boolean): never {
|
|
65
|
+
if (hadUnavailableSource) {
|
|
66
|
+
const details = failures.length > 0 ? `: ${describeFailures(failures)}` : ''
|
|
67
|
+
throw new SourceUnavailableError(`all internal tx sources unavailable${details}`)
|
|
68
|
+
}
|
|
69
|
+
throw new Error('no internal tx sources configured')
|
|
28
70
|
}
|
|
29
71
|
|
|
30
72
|
async function runInternalTxSources(
|
|
@@ -32,37 +74,27 @@ async function runInternalTxSources(
|
|
|
32
74
|
fetchers: Record<InternalTxSource, SourceFetcher>,
|
|
33
75
|
height: number
|
|
34
76
|
): Promise<InternalTxsByHash> {
|
|
35
|
-
|
|
77
|
+
// Real errors, plus unavailable errors that carry a cause, in source order.
|
|
78
|
+
const failures: SourceFailure[] = []
|
|
79
|
+
let hasRealError = false
|
|
36
80
|
let hadUnavailableSource = false
|
|
37
81
|
|
|
38
82
|
for (const source of sources) {
|
|
39
83
|
if (source === 'empty') {
|
|
40
|
-
if (
|
|
41
|
-
throwCollectedRealErrors(realErrors)
|
|
42
|
-
}
|
|
84
|
+
if (hasRealError) throwCollectedFailures(failures)
|
|
43
85
|
return new Map()
|
|
44
86
|
}
|
|
45
87
|
|
|
46
88
|
try {
|
|
47
89
|
return await fetchers[source](height)
|
|
48
90
|
} catch (error) {
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
continue
|
|
52
|
-
}
|
|
53
|
-
realErrors.push(error)
|
|
91
|
+
if (recordFailure(failures, source, error)) hasRealError = true
|
|
92
|
+
else hadUnavailableSource = true
|
|
54
93
|
}
|
|
55
94
|
}
|
|
56
95
|
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (hadUnavailableSource) {
|
|
62
|
-
throw new SourceUnavailableError('all internal tx sources unavailable')
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
throw new Error('no internal tx sources configured')
|
|
96
|
+
if (hasRealError) throwCollectedFailures(failures)
|
|
97
|
+
return throwExhausted(failures, hadUnavailableSource)
|
|
66
98
|
}
|
|
67
99
|
|
|
68
100
|
function explorerInternalTxsByBlock(
|
|
@@ -139,7 +171,7 @@ export function makeSourceFetchers(
|
|
|
139
171
|
blockHeight: height,
|
|
140
172
|
error,
|
|
141
173
|
})
|
|
142
|
-
throw new SourceUnavailableError('explorer internal txs failed')
|
|
174
|
+
throw new SourceUnavailableError('explorer internal txs failed', { cause: error })
|
|
143
175
|
})
|
|
144
176
|
},
|
|
145
177
|
empty: async () => new Map<string, BlockOperation[]>(),
|