@ledgerhq/coin-evm 5.3.6 → 5.3.9
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 +2 -1
- package/lib/adapters/etherscan.js.map +1 -1
- package/lib/logic/getBlock.js +2 -2
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/network/explorer/etherscan.d.ts.map +1 -1
- package/lib/network/explorer/etherscan.js +23 -5
- package/lib/network/explorer/etherscan.js.map +1 -1
- package/lib/network/node/rpc.common.d.ts.map +1 -1
- package/lib/network/node/rpc.common.js +30 -6
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +3 -1
- package/lib/network/node/types.d.ts.map +1 -1
- package/lib/network/node/types.js.map +1 -1
- package/lib/types/etherscan.d.ts +2 -0
- package/lib/types/etherscan.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.js +2 -1
- package/lib-es/adapters/etherscan.js.map +1 -1
- package/lib-es/logic/getBlock.js +2 -2
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
- package/lib-es/network/explorer/etherscan.js +23 -5
- package/lib-es/network/explorer/etherscan.js.map +1 -1
- package/lib-es/network/node/rpc.common.d.ts.map +1 -1
- package/lib-es/network/node/rpc.common.js +30 -6
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +3 -1
- package/lib-es/network/node/types.d.ts.map +1 -1
- package/lib-es/network/node/types.js.map +1 -1
- package/lib-es/types/etherscan.d.ts +2 -0
- package/lib-es/types/etherscan.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/adapters/etherscan.test.ts +67 -0
- package/src/adapters/etherscan.ts +3 -1
- package/src/api/getBlock.integ.test.ts +1 -1
- package/src/api/index.avalanche_c_chain_fuji.integ.test.ts +1 -1
- package/src/api/index.integ.test.ts +7 -4
- package/src/api/index.linea.integ.test.ts +1 -1
- package/src/api/index.monad_testnet.integ.test.ts +1 -1
- package/src/api/index.optimism.integ.test.ts +30 -1
- package/src/api/index.rsk.integ.test.ts +1 -1
- package/src/api/index.shape.integ.test.ts +1 -1
- package/src/api/index.somnia.integ.test.ts +40 -0
- package/src/api/index.zksync.integ.test.ts +6 -2
- package/src/logic/getBlock.test.ts +49 -0
- package/src/logic/getBlock.ts +3 -2
- package/src/network/explorer/etherscan.test.ts +339 -90
- package/src/network/explorer/etherscan.ts +32 -6
- package/src/network/node/rpc.common.ts +35 -6
- package/src/network/node/rpc.test.ts +73 -0
- package/src/network/node/types.ts +10 -1
- package/src/staking/validators.integ.test.ts +1 -1
- package/src/types/etherscan.ts +2 -0
|
@@ -1970,26 +1970,48 @@ describe('EVM Family', () => {
|
|
|
1970
1970
|
).rejects.toBeInstanceOf(RateLimitError)
|
|
1971
1971
|
})
|
|
1972
1972
|
|
|
1973
|
+
// An operation plus a stable identity: its position in the scenario's op list. The identity
|
|
1974
|
+
// is encoded in the tx hash so it survives the adapters and can be checked on the way out.
|
|
1975
|
+
// Indexing per response page instead would make the same operation change hash from page to
|
|
1976
|
+
// page, and would leave two ops of the same type at the same block indistinguishable — a
|
|
1977
|
+
// duplicate of one masking the omission of the other would then pass an exactly-once check.
|
|
1978
|
+
type IndexedOp = { type: OpType; block: number; uid: number }
|
|
1979
|
+
const opHash = (op: IndexedOp): string => `0x${op.type}${op.uid}`
|
|
1980
|
+
|
|
1973
1981
|
// Helpers to create mock Etherscan responses with specific block heights for each operation type
|
|
1974
|
-
const createMockCoinTxResponse = (
|
|
1975
|
-
|
|
1982
|
+
const createMockCoinTxResponse = (ops: IndexedOp[]) =>
|
|
1983
|
+
ops.map((op) => ({
|
|
1976
1984
|
...etherscanCoinOperations[0],
|
|
1977
|
-
blockNumber: String(
|
|
1978
|
-
hash:
|
|
1985
|
+
blockNumber: String(op.block),
|
|
1986
|
+
hash: opHash(op),
|
|
1979
1987
|
}))
|
|
1980
1988
|
|
|
1981
|
-
const createMockInternalTxResponse = (
|
|
1982
|
-
|
|
1989
|
+
const createMockInternalTxResponse = (ops: IndexedOp[]) =>
|
|
1990
|
+
ops.map((op) => ({
|
|
1983
1991
|
...etherscanInternalOperations[0],
|
|
1984
|
-
blockNumber: String(
|
|
1985
|
-
hash:
|
|
1992
|
+
blockNumber: String(op.block),
|
|
1993
|
+
hash: opHash(op),
|
|
1986
1994
|
}))
|
|
1987
1995
|
|
|
1988
|
-
const createMockTokenTxResponse = (
|
|
1989
|
-
|
|
1996
|
+
const createMockTokenTxResponse = (ops: IndexedOp[]) =>
|
|
1997
|
+
ops.map((op) => ({
|
|
1990
1998
|
...etherscanTokenOperations[0],
|
|
1991
|
-
blockNumber: String(
|
|
1992
|
-
hash:
|
|
1999
|
+
blockNumber: String(op.block),
|
|
2000
|
+
hash: opHash(op),
|
|
2001
|
+
}))
|
|
2002
|
+
|
|
2003
|
+
const createMockERC721TxResponse = (ops: IndexedOp[]) =>
|
|
2004
|
+
ops.map((op) => ({
|
|
2005
|
+
...etherscanERC721Operations[0],
|
|
2006
|
+
blockNumber: String(op.block),
|
|
2007
|
+
hash: opHash(op),
|
|
2008
|
+
}))
|
|
2009
|
+
|
|
2010
|
+
const createMockERC1155TxResponse = (ops: IndexedOp[]) =>
|
|
2011
|
+
ops.map((op) => ({
|
|
2012
|
+
...etherscanERC1155Operations[0],
|
|
2013
|
+
blockNumber: String(op.block),
|
|
2014
|
+
hash: opHash(op),
|
|
1993
2015
|
}))
|
|
1994
2016
|
|
|
1995
2017
|
// Helper to identify endpoint type from URL - order matters due to substring matching
|
|
@@ -2002,16 +2024,28 @@ describe('EVM Family', () => {
|
|
|
2002
2024
|
return 'unknown'
|
|
2003
2025
|
}
|
|
2004
2026
|
|
|
2005
|
-
// Type for blockchain operation representation in test scenarios
|
|
2006
|
-
|
|
2027
|
+
// Type for blockchain operation representation in test scenarios.
|
|
2028
|
+
// N = ERC-721 (tokennfttx), M = ERC-1155 (token1155tx); both are served by the same
|
|
2029
|
+
// NFT endpoint, which merges them into a single result.
|
|
2030
|
+
type OpType = 'C' | 'I' | 'T' | 'N' | 'M'
|
|
2031
|
+
type BlockchainOp = { type: OpType; block: number; toString: () => string }
|
|
2007
2032
|
|
|
2008
2033
|
// Factory to create operation constants
|
|
2009
|
-
const makeOp = (type:
|
|
2034
|
+
const makeOp = (type: OpType, block: number): BlockchainOp => ({
|
|
2010
2035
|
type,
|
|
2011
2036
|
block,
|
|
2012
2037
|
toString: () => `${type}${block}`,
|
|
2013
2038
|
})
|
|
2014
2039
|
|
|
2040
|
+
// Pins each op in a scenario to a stable identity. Op constants are shared singletons and a
|
|
2041
|
+
// scenario may list the same one twice, so identity has to come from the position in the
|
|
2042
|
+
// list rather than from the constant itself.
|
|
2043
|
+
const identify = (allOps: BlockchainOp[]): IndexedOp[] =>
|
|
2044
|
+
allOps.map((op, uid) => ({ type: op.type, block: op.block, uid }))
|
|
2045
|
+
|
|
2046
|
+
// How an op is labelled in exactly-once assertions: type, block and identity.
|
|
2047
|
+
const opLabel = (op: IndexedOp): string => `${op.type}${op.block}#${opHash(op)}`
|
|
2048
|
+
|
|
2015
2049
|
// Operation constants for clean test syntax: C0, C1, ..., I0, I1, ..., T0, T1, ...
|
|
2016
2050
|
const [C0, C1, C2, C3, C4, C5, C6, C7, C8, C9] = Array.from({ length: 10 }, (_, i) =>
|
|
2017
2051
|
makeOp('C', i)
|
|
@@ -2022,6 +2056,12 @@ describe('EVM Family', () => {
|
|
|
2022
2056
|
const [_T0, T1, T2, T3, T4, T5, T6, T7, T8, T9] = Array.from({ length: 10 }, (_, i) =>
|
|
2023
2057
|
makeOp('T', i)
|
|
2024
2058
|
)
|
|
2059
|
+
const [_N0, N1, N2, N3, N4, _N5, _N6, N7, N8, N9] = Array.from({ length: 10 }, (_, i) =>
|
|
2060
|
+
makeOp('N', i)
|
|
2061
|
+
)
|
|
2062
|
+
const [_M0, M1, M2, M3, M4, _M5, _M6, M7, M8, M9] = Array.from({ length: 10 }, (_, i) =>
|
|
2063
|
+
makeOp('M', i)
|
|
2064
|
+
)
|
|
2025
2065
|
|
|
2026
2066
|
// Helper to convert ops to string array for assertions: ops(I6, I6, I6) => ["I6", "I6", "I6"]
|
|
2027
2067
|
const ops = (...items: BlockchainOp[]) => items.map(String)
|
|
@@ -2029,6 +2069,7 @@ describe('EVM Family', () => {
|
|
|
2029
2069
|
// Create intelligent mock that simulates blockchain based on given operations
|
|
2030
2070
|
const createBlockchainMock = (allOps: BlockchainOp[], limit: number, order: 'asc' | 'desc') => {
|
|
2031
2071
|
const pageCounts: Record<string, number> = {}
|
|
2072
|
+
const indexedOps = identify(allOps)
|
|
2032
2073
|
|
|
2033
2074
|
return async (config: AxiosRequestConfig) => {
|
|
2034
2075
|
const url: string = config.url ?? ''
|
|
@@ -2044,15 +2085,17 @@ describe('EVM Family', () => {
|
|
|
2044
2085
|
const currentPage = pageCounts[key]
|
|
2045
2086
|
|
|
2046
2087
|
// Filter ops by type and range
|
|
2047
|
-
const typeMap: Record<string,
|
|
2088
|
+
const typeMap: Record<string, OpType> = {
|
|
2048
2089
|
coin: 'C',
|
|
2049
2090
|
internal: 'I',
|
|
2050
2091
|
token: 'T',
|
|
2092
|
+
erc721: 'N',
|
|
2093
|
+
erc1155: 'M',
|
|
2051
2094
|
}
|
|
2052
2095
|
const opType = typeMap[endpointType]
|
|
2053
2096
|
if (!opType) return { data: { result: [] } }
|
|
2054
2097
|
|
|
2055
|
-
const filteredOps =
|
|
2098
|
+
const filteredOps = indexedOps
|
|
2056
2099
|
.filter((op) => op.type === opType && op.block >= startBlock && op.block <= endBlock)
|
|
2057
2100
|
.sort((a, b) => (order === 'desc' ? b.block - a.block : a.block - b.block))
|
|
2058
2101
|
|
|
@@ -2062,11 +2105,15 @@ describe('EVM Family', () => {
|
|
|
2062
2105
|
|
|
2063
2106
|
// Convert to Etherscan response format
|
|
2064
2107
|
if (opType === 'C') {
|
|
2065
|
-
return { data: { result: createMockCoinTxResponse(pageOps
|
|
2108
|
+
return { data: { result: createMockCoinTxResponse(pageOps) } }
|
|
2066
2109
|
} else if (opType === 'I') {
|
|
2067
|
-
return { data: { result: createMockInternalTxResponse(pageOps
|
|
2110
|
+
return { data: { result: createMockInternalTxResponse(pageOps) } }
|
|
2111
|
+
} else if (opType === 'N') {
|
|
2112
|
+
return { data: { result: createMockERC721TxResponse(pageOps) } }
|
|
2113
|
+
} else if (opType === 'M') {
|
|
2114
|
+
return { data: { result: createMockERC1155TxResponse(pageOps) } }
|
|
2068
2115
|
} else {
|
|
2069
|
-
return { data: { result: createMockTokenTxResponse(pageOps
|
|
2116
|
+
return { data: { result: createMockTokenTxResponse(pageOps) } }
|
|
2070
2117
|
}
|
|
2071
2118
|
}
|
|
2072
2119
|
}
|
|
@@ -2112,9 +2159,14 @@ describe('EVM Family', () => {
|
|
|
2112
2159
|
...result.lastCoinOperations.map((op) => ({ type: 'C', block: op.tx.block.height })),
|
|
2113
2160
|
...result.lastInternalOperations.map((op) => ({ type: 'I', block: op.tx.block.height })),
|
|
2114
2161
|
...result.lastTokenOperations.map((op) => ({ type: 'T', block: op.tx.block.height })),
|
|
2162
|
+
// The NFT endpoint merges ERC-721 and ERC-1155; tell them apart by asset type
|
|
2163
|
+
...result.lastNftOperations.map((op) => ({
|
|
2164
|
+
type: op.asset.type === 'erc1155' ? 'M' : 'N',
|
|
2165
|
+
block: op.tx.block.height,
|
|
2166
|
+
})),
|
|
2115
2167
|
]
|
|
2116
|
-
// Secondary sort order: C < I < T (coin first at same block)
|
|
2117
|
-
const typeOrder: Record<string, number> = { C: 0, I: 1, T: 2 }
|
|
2168
|
+
// Secondary sort order: C < I < T < N < M (coin first at same block)
|
|
2169
|
+
const typeOrder: Record<string, number> = { C: 0, I: 1, T: 2, N: 3, M: 4 }
|
|
2118
2170
|
const ops = tagged
|
|
2119
2171
|
.filter((op): op is { type: string; block: number } => op.block !== undefined)
|
|
2120
2172
|
.sort((a, b) => b.block - a.block || typeOrder[a.type] - typeOrder[b.type])
|
|
@@ -2123,16 +2175,45 @@ describe('EVM Family', () => {
|
|
|
2123
2175
|
return { ops, pagingState }
|
|
2124
2176
|
}
|
|
2125
2177
|
|
|
2126
|
-
//
|
|
2178
|
+
// Same ordering as summarize, but each op keeps the identity the mock gave it. Exactly-once
|
|
2179
|
+
// assertions need this: type + block alone cannot tell two ops in the same block apart.
|
|
2180
|
+
const summarizeIdentified = (result: {
|
|
2181
|
+
lastCoinOperations: Array<Operation<MemoNotSupported>>
|
|
2182
|
+
lastTokenOperations: Array<Operation<MemoNotSupported>>
|
|
2183
|
+
lastInternalOperations: Array<Operation<MemoNotSupported>>
|
|
2184
|
+
lastNftOperations: Array<Operation<MemoNotSupported>>
|
|
2185
|
+
}): string[] => {
|
|
2186
|
+
const tagged = [
|
|
2187
|
+
...result.lastCoinOperations.map((op) => ({ type: 'C', op })),
|
|
2188
|
+
...result.lastInternalOperations.map((op) => ({ type: 'I', op })),
|
|
2189
|
+
...result.lastTokenOperations.map((op) => ({ type: 'T', op })),
|
|
2190
|
+
...result.lastNftOperations.map((op) => ({
|
|
2191
|
+
type: op.asset.type === 'erc1155' ? 'M' : 'N',
|
|
2192
|
+
op,
|
|
2193
|
+
})),
|
|
2194
|
+
]
|
|
2195
|
+
const typeOrder: Record<string, number> = { C: 0, I: 1, T: 2, N: 3, M: 4 }
|
|
2196
|
+
return tagged
|
|
2197
|
+
.filter((entry) => entry.op.tx.block.height !== undefined)
|
|
2198
|
+
.sort(
|
|
2199
|
+
(a, b) =>
|
|
2200
|
+
(b.op.tx.block.height ?? 0) - (a.op.tx.block.height ?? 0) ||
|
|
2201
|
+
typeOrder[a.type] - typeOrder[b.type]
|
|
2202
|
+
)
|
|
2203
|
+
.map((entry) => `${entry.type}${entry.op.tx.block.height}#${entry.op.tx.hash}`)
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
// Helper to create expected paging state. Every flag is spelled out: nft varies like the
|
|
2207
|
+
// others now that the endpoint is gated only by supportedTokens, and a default would hide it.
|
|
2127
2208
|
const paging = (
|
|
2128
2209
|
boundBlock: number,
|
|
2129
|
-
flags: { coin: boolean; internal: boolean; token: boolean }
|
|
2210
|
+
flags: { coin: boolean; internal: boolean; token: boolean; nft: boolean }
|
|
2130
2211
|
): PagingState => ({
|
|
2131
2212
|
boundBlock,
|
|
2132
2213
|
coinIsDone: flags.coin,
|
|
2133
2214
|
internalIsDone: flags.internal,
|
|
2134
2215
|
tokenIsDone: flags.token,
|
|
2135
|
-
nftIsDone:
|
|
2216
|
+
nftIsDone: flags.nft,
|
|
2136
2217
|
})
|
|
2137
2218
|
|
|
2138
2219
|
describe('desc mode', () => {
|
|
@@ -2141,11 +2222,11 @@ describe('EVM Family', () => {
|
|
|
2141
2222
|
const result = await callGetOperations('desc')([I6, I6, I6, I5, T5, C4, C3, C2])
|
|
2142
2223
|
// - coin([Ø, Ø]) [C4 C3 C2] boundBlock=2, isPageFull=true, hasMorePage=true (full page)
|
|
2143
2224
|
// - internal([2, Ø]) [I6 I6 I6] boundBlock=6, isPageFull=true, hasMorePage=true (full page, higher boundBlock)
|
|
2144
|
-
// - token([6, Ø]) [] boundBlock=Ø, isPageFull=false, hasMorePage=
|
|
2225
|
+
// - token([6, Ø]) [] boundBlock=Ø, isPageFull=false, hasMorePage=true (constrained by internal's bound, T5 at block 5 not yet reached)
|
|
2145
2226
|
// Result: only I6s kept, coin ops dropped (below boundBlock=6)
|
|
2146
2227
|
expect(summarize(result)).toEqual({
|
|
2147
2228
|
ops: ops(I6, I6, I6),
|
|
2148
|
-
pagingState: paging(5, { coin: false, internal: false, token:
|
|
2229
|
+
pagingState: paging(5, { coin: false, internal: false, token: false, nft: false }),
|
|
2149
2230
|
})
|
|
2150
2231
|
})
|
|
2151
2232
|
|
|
@@ -2153,11 +2234,11 @@ describe('EVM Family', () => {
|
|
|
2153
2234
|
const result = await callGetOperations('desc')([T7, I6, I6, I6, T5, C4, C3, C2, I2])
|
|
2154
2235
|
// - coin([Ø, Ø]) [C4 C3 C2] boundBlock=2, isPageFull=true, hasMorePage=true (full page)
|
|
2155
2236
|
// - internal([2, Ø]) [I6 I6 I6] boundBlock=6, isPageFull=true, hasMorePage=true (full page, higher boundBlock)
|
|
2156
|
-
// - token([6, Ø]) [T7] boundBlock=Ø, isPageFull=false, hasMorePage=
|
|
2237
|
+
// - token([6, Ø]) [T7] boundBlock=Ø, isPageFull=false, hasMorePage=true (constrained by internal's bound, T5 at block 5 not yet reached)
|
|
2157
2238
|
// Result: T7 + I6s kept, coin ops dropped (below boundBlock=6)
|
|
2158
2239
|
expect(summarize(result)).toEqual({
|
|
2159
2240
|
ops: ops(T7, I6, I6, I6),
|
|
2160
|
-
pagingState: paging(5, { coin: false, internal: false, token:
|
|
2241
|
+
pagingState: paging(5, { coin: false, internal: false, token: false, nft: false }),
|
|
2161
2242
|
})
|
|
2162
2243
|
})
|
|
2163
2244
|
|
|
@@ -2177,11 +2258,11 @@ describe('EVM Family', () => {
|
|
|
2177
2258
|
])
|
|
2178
2259
|
// - coin([Ø, Ø]) [C3 C2 C1] boundBlock=1, isPageFull=true, hasMorePage=true (full page)
|
|
2179
2260
|
// - internal([1, Ø]) [I6 I5 I4] boundBlock=4, isPageFull=true, hasMorePage=true (full page)
|
|
2180
|
-
// - token([4, Ø]) [T9 T8 T7] boundBlock=7, isPageFull=true, hasMorePage=true (
|
|
2261
|
+
// - token([4, Ø]) [T9 T8 T7] boundBlock=7, isPageFull=true, hasMorePage=true (constrained by internal's bound, T1 at block 1 not yet reached)
|
|
2181
2262
|
// Result: only T9/T8/T7 kept, coin+internal ops dropped (below boundBlock=7)
|
|
2182
2263
|
expect(summarize(result)).toEqual({
|
|
2183
2264
|
ops: ops(T9, T8, T7),
|
|
2184
|
-
pagingState: paging(6, { coin: false, internal: false, token:
|
|
2265
|
+
pagingState: paging(6, { coin: false, internal: false, token: false, nft: false }),
|
|
2185
2266
|
})
|
|
2186
2267
|
})
|
|
2187
2268
|
|
|
@@ -2206,7 +2287,7 @@ describe('EVM Family', () => {
|
|
|
2206
2287
|
// Result: ops >= 7 kept, lower ops dropped (below boundBlock=7)
|
|
2207
2288
|
expect(summarize(result)).toEqual({
|
|
2208
2289
|
ops: ops(T9, I8, T8, C7, I7, T7),
|
|
2209
|
-
pagingState: paging(6, { coin: false, internal: false, token: false }),
|
|
2290
|
+
pagingState: paging(6, { coin: false, internal: false, token: false, nft: false }),
|
|
2210
2291
|
})
|
|
2211
2292
|
})
|
|
2212
2293
|
})
|
|
@@ -2215,12 +2296,12 @@ describe('EVM Family', () => {
|
|
|
2215
2296
|
it('keeps all when subsequent pages are not full', async () => {
|
|
2216
2297
|
const result = await callGetOperations('desc')([I6, I6, T5, C4, C3, C2, C1, T1])
|
|
2217
2298
|
// - coin([Ø, Ø]) [C4 C3 C2] boundBlock=1, isPageFull=true, hasMorePage=true (full page)
|
|
2218
|
-
// - internal([1, Ø]) [I6 I6] boundBlock=1, isPageFull=false, hasMorePage=true (
|
|
2219
|
-
// - token([1, Ø]) [T5] boundBlock=1, isPageFull=false, hasMorePage=true (
|
|
2299
|
+
// - internal([1, Ø]) [I6 I6] boundBlock=1, isPageFull=false, hasMorePage=true (constrained by coins's bound, C1/T1 not yet reached)
|
|
2300
|
+
// - token([1, Ø]) [T5] boundBlock=1, isPageFull=false, hasMorePage=true (constrained by coins's bound, T1 not yet reached)
|
|
2220
2301
|
// Result: all ops kept, boundBlock stays at 1 because subsequent pages not full
|
|
2221
2302
|
expect(summarize(result)).toEqual({
|
|
2222
2303
|
ops: ops(I6, I6, T5, C4, C3, C2),
|
|
2223
|
-
pagingState: paging(1, { coin: false, internal:
|
|
2304
|
+
pagingState: paging(1, { coin: false, internal: false, token: false, nft: false }),
|
|
2224
2305
|
})
|
|
2225
2306
|
})
|
|
2226
2307
|
|
|
@@ -2236,12 +2317,12 @@ describe('EVM Family', () => {
|
|
|
2236
2317
|
it('keeps all when only coin has ops', async () => {
|
|
2237
2318
|
const result = await callGetOperations('desc')([C4, C3, C2, C1])
|
|
2238
2319
|
// - coin([Ø, Ø]) [C4 C3 C2] boundBlock=1, isPageFull=true, hasMorePage=true (full page)
|
|
2239
|
-
// - internal([1, Ø]) [] boundBlock=1, isPageFull=false, hasMorePage=true (
|
|
2240
|
-
// - token([1, Ø]) [] boundBlock=1, isPageFull=false, hasMorePage=true (
|
|
2320
|
+
// - internal([1, Ø]) [] boundBlock=1, isPageFull=false, hasMorePage=true (constrained by coins's bound, C1 not yet reached)
|
|
2321
|
+
// - token([1, Ø]) [] boundBlock=1, isPageFull=false, hasMorePage=true (constrained by coins's bound)
|
|
2241
2322
|
// Result: coin ops kept, nextPagingToken=1 for remaining C1
|
|
2242
2323
|
expect(summarize(result)).toEqual({
|
|
2243
2324
|
ops: ops(C4, C3, C2),
|
|
2244
|
-
pagingState: paging(1, { coin: false, internal:
|
|
2325
|
+
pagingState: paging(1, { coin: false, internal: false, token: false, nft: false }),
|
|
2245
2326
|
})
|
|
2246
2327
|
})
|
|
2247
2328
|
|
|
@@ -2253,19 +2334,19 @@ describe('EVM Family', () => {
|
|
|
2253
2334
|
// Result: token ops kept, nextPagingToken=1 for remaining T1
|
|
2254
2335
|
expect(summarize(result)).toEqual({
|
|
2255
2336
|
ops: ops(T4, T3, T2),
|
|
2256
|
-
pagingState: paging(1, { coin: true, internal: true, token: false }),
|
|
2337
|
+
pagingState: paging(1, { coin: true, internal: true, token: false, nft: false }),
|
|
2257
2338
|
})
|
|
2258
2339
|
})
|
|
2259
2340
|
|
|
2260
2341
|
it('cascades without dropping when blocks interleave nicely', async () => {
|
|
2261
2342
|
const result = await callGetOperations('desc')([T6, C5, I5, C4, I4, C3, I2, I1, C1, T1])
|
|
2262
2343
|
// - coin([Ø, Ø]) [C5 C4 C3] boundBlock=3, isPageFull=true, hasMorePage=true (full page)
|
|
2263
|
-
// - internal([3, Ø]) [I5 I4] boundBlock=Ø, isPageFull=false, hasMorePage=
|
|
2264
|
-
// - token([3, Ø]) [T6] boundBlock=Ø, isPageFull=false, hasMorePage=
|
|
2344
|
+
// - internal([3, Ø]) [I5 I4] boundBlock=Ø, isPageFull=false, hasMorePage=true (constrained by coins's bound, I2/I1 not yet reached)
|
|
2345
|
+
// - token([3, Ø]) [T6] boundBlock=Ø, isPageFull=false, hasMorePage=true (constrained by coins's bound, T1 not yet reached)
|
|
2265
2346
|
// Result: all ops >= 3 kept, interleaved blocks don't cause drops
|
|
2266
2347
|
expect(summarize(result)).toEqual({
|
|
2267
2348
|
ops: ops(T6, C5, I5, C4, I4, C3),
|
|
2268
|
-
pagingState: paging(2, { coin: false, internal:
|
|
2349
|
+
pagingState: paging(2, { coin: false, internal: false, token: false, nft: false }),
|
|
2269
2350
|
})
|
|
2270
2351
|
})
|
|
2271
2352
|
|
|
@@ -2273,11 +2354,11 @@ describe('EVM Family', () => {
|
|
|
2273
2354
|
const result = await callGetOperations('desc')([T6, I6, C5, C4, I4, I3, I2, I1, T1])
|
|
2274
2355
|
// - coin([Ø, Ø]) [C5 C4] boundBlock=Ø, isPageFull=false, hasMorePage=false (not full)
|
|
2275
2356
|
// - internal([Ø, Ø]) [I6 I4 I3] boundBlock=3, isPageFull=true, hasMorePage=true (full page)
|
|
2276
|
-
// - token([3, Ø]) [T6] boundBlock=Ø, isPageFull=false, hasMorePage=
|
|
2357
|
+
// - token([3, Ø]) [T6] boundBlock=Ø, isPageFull=false, hasMorePage=true (constrained by internal's bound, T1 not yet reached)
|
|
2277
2358
|
// Result: all ops >= 3 kept, boundBlock from internal applies
|
|
2278
2359
|
expect(summarize(result)).toEqual({
|
|
2279
2360
|
ops: ops(I6, T6, C5, C4, I4, I3),
|
|
2280
|
-
pagingState: paging(2, { coin: true, internal: false, token:
|
|
2361
|
+
pagingState: paging(2, { coin: true, internal: false, token: false, nft: false }),
|
|
2281
2362
|
})
|
|
2282
2363
|
})
|
|
2283
2364
|
|
|
@@ -2285,11 +2366,11 @@ describe('EVM Family', () => {
|
|
|
2285
2366
|
const result = await callGetOperations('desc')([I6, C5, C4, I4, I3, I2, I1, T1])
|
|
2286
2367
|
// - coin([Ø, Ø]) [C5 C4] boundBlock=Ø, isPageFull=false, hasMorePage=false (not full)
|
|
2287
2368
|
// - internal([Ø, Ø]) [I6 I4 I3] boundBlock=3, isPageFull=true, hasMorePage=true (full page)
|
|
2288
|
-
// - token([3, Ø]) [] boundBlock=Ø, isPageFull=false, hasMorePage=
|
|
2369
|
+
// - token([3, Ø]) [] boundBlock=Ø, isPageFull=false, hasMorePage=true (constrained by internal's bound, T1 not yet reached)
|
|
2289
2370
|
// Result: coin + internal ops kept
|
|
2290
2371
|
expect(summarize(result)).toEqual({
|
|
2291
2372
|
ops: ops(I6, C5, C4, I4, I3),
|
|
2292
|
-
pagingState: paging(2, { coin: true, internal: false, token:
|
|
2373
|
+
pagingState: paging(2, { coin: true, internal: false, token: false, nft: false }),
|
|
2293
2374
|
})
|
|
2294
2375
|
})
|
|
2295
2376
|
|
|
@@ -2309,12 +2390,12 @@ describe('EVM Family', () => {
|
|
|
2309
2390
|
I1,
|
|
2310
2391
|
])
|
|
2311
2392
|
// - coin([Ø, Ø]) [C4 C4 C4] boundBlock=4, isPageFull=true, hasMorePage=true (full page)
|
|
2312
|
-
// - internal([4, Ø]) [I4 I4 I4] boundBlock=4, isPageFull=true, hasMorePage=true (
|
|
2313
|
-
// - token([4, Ø]) [T4 T4 T4] boundBlock=4, isPageFull=true, hasMorePage=true (
|
|
2393
|
+
// - internal([4, Ø]) [I4 I4 I4] boundBlock=4, isPageFull=true, hasMorePage=true (constrained by coins's bound, I1 not yet reached)
|
|
2394
|
+
// - token([4, Ø]) [T4 T4 T4] boundBlock=4, isPageFull=true, hasMorePage=true (constrained by coins's bound, T1 not yet reached)
|
|
2314
2395
|
// Result: all 9 ops at block 4 kept, all at boundBlock=4
|
|
2315
2396
|
expect(summarize(result)).toEqual({
|
|
2316
2397
|
ops: ops(C4, C4, C4, I4, I4, I4, T4, T4, T4),
|
|
2317
|
-
pagingState: paging(3, { coin: false, internal:
|
|
2398
|
+
pagingState: paging(3, { coin: false, internal: false, token: false, nft: false }),
|
|
2318
2399
|
})
|
|
2319
2400
|
})
|
|
2320
2401
|
|
|
@@ -2331,7 +2412,7 @@ describe('EVM Family', () => {
|
|
|
2331
2412
|
describe('with pagination token', () => {
|
|
2332
2413
|
it('skips coin endpoint when it is done', async () => {
|
|
2333
2414
|
const result = await callGetOperations('desc')([C1], {
|
|
2334
|
-
pagingState: paging(5, { coin: true, internal: false, token: false }),
|
|
2415
|
+
pagingState: paging(5, { coin: true, internal: false, token: false, nft: true }),
|
|
2335
2416
|
})
|
|
2336
2417
|
expect(summarize(result)).toEqual({
|
|
2337
2418
|
ops: ops(),
|
|
@@ -2341,7 +2422,7 @@ describe('EVM Family', () => {
|
|
|
2341
2422
|
|
|
2342
2423
|
it('skips internal endpoint when it is done', async () => {
|
|
2343
2424
|
const result = await callGetOperations('desc')([I1], {
|
|
2344
|
-
pagingState: paging(5, { coin: false, internal: true, token: false }),
|
|
2425
|
+
pagingState: paging(5, { coin: false, internal: true, token: false, nft: true }),
|
|
2345
2426
|
})
|
|
2346
2427
|
expect(summarize(result)).toEqual({
|
|
2347
2428
|
ops: ops(),
|
|
@@ -2351,7 +2432,7 @@ describe('EVM Family', () => {
|
|
|
2351
2432
|
|
|
2352
2433
|
it('skips token endpoint when it is done', async () => {
|
|
2353
2434
|
const result = await callGetOperations('desc')([T1], {
|
|
2354
|
-
pagingState: paging(5, { coin: false, internal: false, token: true }),
|
|
2435
|
+
pagingState: paging(5, { coin: false, internal: false, token: true, nft: true }),
|
|
2355
2436
|
})
|
|
2356
2437
|
expect(summarize(result)).toEqual({
|
|
2357
2438
|
ops: ops(),
|
|
@@ -2363,17 +2444,19 @@ describe('EVM Family', () => {
|
|
|
2363
2444
|
const result = await callGetOperations('desc')(
|
|
2364
2445
|
[T6, I6, C6, C5, I5, C4, I4, C3, I2, I1, C1, T1],
|
|
2365
2446
|
{
|
|
2366
|
-
pagingState: paging(5, { coin: false, internal: false, token: false }),
|
|
2447
|
+
pagingState: paging(5, { coin: false, internal: false, token: false, nft: true }),
|
|
2367
2448
|
}
|
|
2368
2449
|
)
|
|
2369
2450
|
// pagingState.boundBlock=5 acts as toBlock for all endpoints
|
|
2370
2451
|
// - coin([Ø, 5]) [C5 C4 C3] boundBlock=3, isPageFull=true, hasMorePage=true (full page)
|
|
2371
|
-
// - internal([3, 5]) [I5 I4] boundBlock=Ø, isPageFull=false, hasMorePage=
|
|
2372
|
-
// - token([3, 5]) [] boundBlock=Ø, isPageFull=false, hasMorePage=
|
|
2452
|
+
// - internal([3, 5]) [I5 I4] boundBlock=Ø, isPageFull=false, hasMorePage=true (constrained by coins's bound, I2/I1 not yet reached)
|
|
2453
|
+
// - token([3, 5]) [] boundBlock=Ø, isPageFull=false, hasMorePage=true (constrained by coins's bound, T1 not yet reached)
|
|
2373
2454
|
// Result: C5/C4/C3 + I5/I4 kept, T6/I6/C6 excluded by pagingToken
|
|
2374
2455
|
expect(summarize(result)).toEqual({
|
|
2375
2456
|
ops: ops(C5, I5, C4, I4, C3),
|
|
2376
|
-
|
|
2457
|
+
// nft stays done: the incoming cursor already marked it done, so the endpoint is
|
|
2458
|
+
// short-circuited rather than re-queried, and a short-circuit is never "constrained".
|
|
2459
|
+
pagingState: paging(2, { coin: false, internal: false, token: false, nft: true }),
|
|
2377
2460
|
})
|
|
2378
2461
|
})
|
|
2379
2462
|
})
|
|
@@ -2389,12 +2472,12 @@ describe('EVM Family', () => {
|
|
|
2389
2472
|
)
|
|
2390
2473
|
// fromBlock=2, toBlock=6 restricts all endpoints
|
|
2391
2474
|
// - coin([2, 6]) [C5 C4 C3] boundBlock=3, isPageFull=true, hasMorePage=true (full page)
|
|
2392
|
-
// - internal([3, 6]) [I5 I4] boundBlock=3, isPageFull=false, hasMorePage=true (
|
|
2393
|
-
// - token([3, 6]) [] boundBlock=3, isPageFull=false, hasMorePage=true (
|
|
2475
|
+
// - internal([3, 6]) [I5 I4] boundBlock=3, isPageFull=false, hasMorePage=true (constrained by coins's bound: 3 > fromBlock=2)
|
|
2476
|
+
// - token([3, 6]) [] boundBlock=3, isPageFull=false, hasMorePage=true (constrained by coins's bound: 3 > fromBlock=2)
|
|
2394
2477
|
// Result: ops in [3, 6] kept, T7/I7/C7 excluded by toBlock
|
|
2395
2478
|
expect(summarize(result)).toEqual({
|
|
2396
2479
|
ops: ops(C5, I5, C4, I4, C3),
|
|
2397
|
-
pagingState: paging(2, { coin: false, internal:
|
|
2480
|
+
pagingState: paging(2, { coin: false, internal: false, token: false, nft: false }),
|
|
2398
2481
|
})
|
|
2399
2482
|
})
|
|
2400
2483
|
|
|
@@ -2426,11 +2509,11 @@ describe('EVM Family', () => {
|
|
|
2426
2509
|
const result = await callGetOperations('asc')([C5, C6, C7, C8, T4, I2, I2, I3, I4])
|
|
2427
2510
|
// - coin([Ø, Ø]) [C5 C6 C7]+[C8] boundBlock=7, isPageFull=true, hasMorePage=true (full page + more)
|
|
2428
2511
|
// - internal([Ø, 7]) [I2 I2 I3]+[I4] boundBlock=3, isPageFull=true, hasMorePage=true (full page + more, lower boundBlock)
|
|
2429
|
-
// - token([Ø, 3]) [] boundBlock=Ø, isPageFull=false, hasMorePage=
|
|
2512
|
+
// - token([Ø, 3]) [] boundBlock=Ø, isPageFull=false, hasMorePage=true (constrained by internal's bound, T4 at block 4 not yet reached)
|
|
2430
2513
|
// Result: only I2s and I3 kept, coin ops dropped (above boundBlock=3)
|
|
2431
2514
|
expect(summarize(result)).toEqual({
|
|
2432
2515
|
ops: ops(I3, I2, I2),
|
|
2433
|
-
pagingState: paging(4, { coin: false, internal: false, token:
|
|
2516
|
+
pagingState: paging(4, { coin: false, internal: false, token: false, nft: false }),
|
|
2434
2517
|
})
|
|
2435
2518
|
})
|
|
2436
2519
|
|
|
@@ -2439,11 +2522,11 @@ describe('EVM Family', () => {
|
|
|
2439
2522
|
const result = await callGetOperations('asc')([T1, I2, I2, I3, I4, T4, C5, C6, C7, C8])
|
|
2440
2523
|
// - coin([Ø, Ø]) [C5 C6 C7]+[C8] boundBlock=7, isPageFull=true, hasMorePage=true (full page + more)
|
|
2441
2524
|
// - internal([Ø, 7]) [I2 I2 I3]+[I4] boundBlock=3, isPageFull=true, hasMorePage=true (full page + more, lower boundBlock)
|
|
2442
|
-
// - token([Ø, 3]) [T1] boundBlock=Ø, isPageFull=false, hasMorePage=
|
|
2525
|
+
// - token([Ø, 3]) [T1] boundBlock=Ø, isPageFull=false, hasMorePage=true (constrained by internal's bound, T4 at block 4 not yet reached)
|
|
2443
2526
|
// Result: T1 + I2s + I3 kept, coin ops dropped (above boundBlock=3)
|
|
2444
2527
|
expect(summarize(result)).toEqual({
|
|
2445
2528
|
ops: ops(I3, I2, I2, T1),
|
|
2446
|
-
pagingState: paging(4, { coin: false, internal: false, token:
|
|
2529
|
+
pagingState: paging(4, { coin: false, internal: false, token: false, nft: false }),
|
|
2447
2530
|
})
|
|
2448
2531
|
})
|
|
2449
2532
|
|
|
@@ -2463,11 +2546,11 @@ describe('EVM Family', () => {
|
|
|
2463
2546
|
])
|
|
2464
2547
|
// - coin([Ø, Ø]) [C7 C8 C9] boundBlock=Ø, isPageFull=true, hasMorePage=true (full page)
|
|
2465
2548
|
// - internal([Ø, Ø]) [I4 I5 I6] boundBlock=7, isPageFull=true, hasMorePage=true (full page)
|
|
2466
|
-
// - token([Ø, 7]) [T1 T2 T3] boundBlock=4, isPageFull=true, hasMorePage=true (
|
|
2549
|
+
// - token([Ø, 7]) [T1 T2 T3] boundBlock=4, isPageFull=true, hasMorePage=true (constrained by internal's bound, T9 at block 9 not yet reached)
|
|
2467
2550
|
// Result: only T1/T2/T3 kept, coin+internal ops dropped (above boundBlock=4)
|
|
2468
2551
|
expect(summarize(result)).toEqual({
|
|
2469
2552
|
ops: ops(T3, T2, T1),
|
|
2470
|
-
pagingState: paging(4, { coin: false, internal: false, token:
|
|
2553
|
+
pagingState: paging(4, { coin: false, internal: false, token: false, nft: false }),
|
|
2471
2554
|
})
|
|
2472
2555
|
})
|
|
2473
2556
|
|
|
@@ -2492,7 +2575,7 @@ describe('EVM Family', () => {
|
|
|
2492
2575
|
// Result: ops <= 3 kept, higher ops dropped (above boundBlock=4)
|
|
2493
2576
|
expect(summarize(result)).toEqual({
|
|
2494
2577
|
ops: ops(C3, I3, T3, I2, T2, T1),
|
|
2495
|
-
pagingState: paging(4, { coin: false, internal: false, token: false }),
|
|
2578
|
+
pagingState: paging(4, { coin: false, internal: false, token: false, nft: false }),
|
|
2496
2579
|
})
|
|
2497
2580
|
})
|
|
2498
2581
|
})
|
|
@@ -2501,12 +2584,12 @@ describe('EVM Family', () => {
|
|
|
2501
2584
|
it('keeps all when subsequent pages are not full', async () => {
|
|
2502
2585
|
const result = await callGetOperations('asc')([I2, I2, T4, C5, C6, C7, C8, T8])
|
|
2503
2586
|
// - coin([Ø, Ø]) [C5 C6 C7] boundBlock=8, isPageFull=true, hasMorePage=true (full page)
|
|
2504
|
-
// - internal([Ø, 8]) [I2 I2] boundBlock=8, isPageFull=false, hasMorePage=true (
|
|
2505
|
-
// - token([Ø, 8]) [T4] boundBlock=8, isPageFull=false, hasMorePage=true (
|
|
2587
|
+
// - internal([Ø, 8]) [I2 I2] boundBlock=8, isPageFull=false, hasMorePage=true (constrained by coins's bound, T8 not yet reached)
|
|
2588
|
+
// - token([Ø, 8]) [T4] boundBlock=8, isPageFull=false, hasMorePage=true (constrained by coins's bound, T8 not yet reached)
|
|
2506
2589
|
// Result: all ops kept, boundBlock stays at 8 because subsequent pages not full
|
|
2507
2590
|
expect(summarize(result)).toEqual({
|
|
2508
2591
|
ops: ops(C7, C6, C5, T4, I2, I2),
|
|
2509
|
-
pagingState: paging(8, { coin: false, internal:
|
|
2592
|
+
pagingState: paging(8, { coin: false, internal: false, token: false, nft: false }),
|
|
2510
2593
|
})
|
|
2511
2594
|
})
|
|
2512
2595
|
|
|
@@ -2522,12 +2605,12 @@ describe('EVM Family', () => {
|
|
|
2522
2605
|
it('keeps all when only coin has ops', async () => {
|
|
2523
2606
|
const result = await callGetOperations('asc')([C5, C6, C7, C8])
|
|
2524
2607
|
// - coin([Ø, Ø]) [C5 C6 C7] boundBlock=8, isPageFull=true, hasMorePage=true (full page)
|
|
2525
|
-
// - internal([Ø, 8]) [] boundBlock=8, isPageFull=false, hasMorePage=true (
|
|
2526
|
-
// - token([Ø, 8]) [] boundBlock=8, isPageFull=false, hasMorePage=true (
|
|
2608
|
+
// - internal([Ø, 8]) [] boundBlock=8, isPageFull=false, hasMorePage=true (constrained by coins's bound, C8 not yet reached)
|
|
2609
|
+
// - token([Ø, 8]) [] boundBlock=8, isPageFull=false, hasMorePage=true (constrained by coins's bound)
|
|
2527
2610
|
// Result: coin ops kept, nextPagingToken=8 for remaining C8
|
|
2528
2611
|
expect(summarize(result)).toEqual({
|
|
2529
2612
|
ops: ops(C7, C6, C5),
|
|
2530
|
-
pagingState: paging(8, { coin: false, internal:
|
|
2613
|
+
pagingState: paging(8, { coin: false, internal: false, token: false, nft: false }),
|
|
2531
2614
|
})
|
|
2532
2615
|
})
|
|
2533
2616
|
|
|
@@ -2539,19 +2622,19 @@ describe('EVM Family', () => {
|
|
|
2539
2622
|
// Result: token ops kept, nextPagingToken=8 for remaining T8
|
|
2540
2623
|
expect(summarize(result)).toEqual({
|
|
2541
2624
|
ops: ops(T7, T6, T5),
|
|
2542
|
-
pagingState: paging(8, { coin: true, internal: true, token: false }),
|
|
2625
|
+
pagingState: paging(8, { coin: true, internal: true, token: false, nft: false }),
|
|
2543
2626
|
})
|
|
2544
2627
|
})
|
|
2545
2628
|
|
|
2546
2629
|
it('cascades without dropping when blocks interleave nicely', async () => {
|
|
2547
2630
|
const result = await callGetOperations('asc')([T2, C4, I4, C5, I5, C6, I7, I8, C8, T8])
|
|
2548
2631
|
// - coin([Ø, Ø]) [C4 C5 C6] boundBlock=7, isPageFull=true, hasMorePage=true (full page)
|
|
2549
|
-
// - internal([Ø, 7]) [I4 I5] boundBlock=7, isPageFull=false, hasMorePage=true (
|
|
2550
|
-
// - token([Ø, 7]) [T2] boundBlock=7, isPageFull=false, hasMorePage=true (
|
|
2632
|
+
// - internal([Ø, 7]) [I4 I5] boundBlock=7, isPageFull=false, hasMorePage=true (constrained by coins's bound, I7/I8 not yet reached)
|
|
2633
|
+
// - token([Ø, 7]) [T2] boundBlock=7, isPageFull=false, hasMorePage=true (constrained by coins's bound, T8 not yet reached)
|
|
2551
2634
|
// Result: all ops <= 6 kept, interleaved blocks don't cause drops
|
|
2552
2635
|
expect(summarize(result)).toEqual({
|
|
2553
2636
|
ops: ops(C6, C5, I5, C4, I4, T2),
|
|
2554
|
-
pagingState: paging(7, { coin: false, internal:
|
|
2637
|
+
pagingState: paging(7, { coin: false, internal: false, token: false, nft: false }),
|
|
2555
2638
|
})
|
|
2556
2639
|
})
|
|
2557
2640
|
|
|
@@ -2559,11 +2642,11 @@ describe('EVM Family', () => {
|
|
|
2559
2642
|
const result = await callGetOperations('asc')([T2, I2, C4, C5, I5, I6, I7, I8, T8])
|
|
2560
2643
|
// - coin([Ø, Ø]) [C4 C5] boundBlock=Ø, isPageFull=false, hasMorePage=false (not full)
|
|
2561
2644
|
// - internal([Ø, Ø]) [I2 I5 I6] boundBlock=7, isPageFull=true, hasMorePage=true (full page)
|
|
2562
|
-
// - token([Ø, 7]) [T2] boundBlock=7, isPageFull=false, hasMorePage=true (
|
|
2645
|
+
// - token([Ø, 7]) [T2] boundBlock=7, isPageFull=false, hasMorePage=true (constrained by internal's bound, T8 not yet reached)
|
|
2563
2646
|
// Result: all ops <= 6 kept, boundBlock from internal applies
|
|
2564
2647
|
expect(summarize(result)).toEqual({
|
|
2565
2648
|
ops: ops(I6, C5, I5, C4, I2, T2),
|
|
2566
|
-
pagingState: paging(7, { coin: true, internal: false, token:
|
|
2649
|
+
pagingState: paging(7, { coin: true, internal: false, token: false, nft: false }),
|
|
2567
2650
|
})
|
|
2568
2651
|
})
|
|
2569
2652
|
|
|
@@ -2571,11 +2654,11 @@ describe('EVM Family', () => {
|
|
|
2571
2654
|
const result = await callGetOperations('asc')([I2, C4, C5, I5, I6, I7, I8, T8])
|
|
2572
2655
|
// - coin([Ø, Ø]) [C4 C5] boundBlock=Ø, isPageFull=false, hasMorePage=false (not full)
|
|
2573
2656
|
// - internal([Ø, Ø]) [I2 I5 I6] boundBlock=7, isPageFull=true, hasMorePage=true (full page)
|
|
2574
|
-
// - token([Ø, 7]) [] boundBlock=7, isPageFull=false, hasMorePage=true (
|
|
2657
|
+
// - token([Ø, 7]) [] boundBlock=7, isPageFull=false, hasMorePage=true (constrained by internal's bound, T8 not yet reached)
|
|
2575
2658
|
// Result: coin + internal ops kept
|
|
2576
2659
|
expect(summarize(result)).toEqual({
|
|
2577
2660
|
ops: ops(I6, C5, I5, C4, I2),
|
|
2578
|
-
pagingState: paging(7, { coin: true, internal: false, token:
|
|
2661
|
+
pagingState: paging(7, { coin: true, internal: false, token: false, nft: false }),
|
|
2579
2662
|
})
|
|
2580
2663
|
})
|
|
2581
2664
|
|
|
@@ -2595,12 +2678,12 @@ describe('EVM Family', () => {
|
|
|
2595
2678
|
I8,
|
|
2596
2679
|
])
|
|
2597
2680
|
// - coin([Ø, Ø]) [C5 C5 C5] boundBlock=6, isPageFull=true, hasMorePage=true (full page)
|
|
2598
|
-
// - internal([Ø, 6]) [I5 I5 I5] boundBlock=6, isPageFull=true, hasMorePage=true (
|
|
2599
|
-
// - token([Ø, 6]) [T5 T5 T5] boundBlock=6, isPageFull=true, hasMorePage=true (
|
|
2681
|
+
// - internal([Ø, 6]) [I5 I5 I5] boundBlock=6, isPageFull=true, hasMorePage=true (constrained by coins's bound, I8 not yet reached)
|
|
2682
|
+
// - token([Ø, 6]) [T5 T5 T5] boundBlock=6, isPageFull=true, hasMorePage=true (constrained by coins's bound, T8 not yet reached)
|
|
2600
2683
|
// Result: all 9 ops at block 5 kept, all below boundBlock=6
|
|
2601
2684
|
expect(summarize(result)).toEqual({
|
|
2602
2685
|
ops: ops(C5, C5, C5, I5, I5, I5, T5, T5, T5),
|
|
2603
|
-
pagingState: paging(6, { coin: false, internal:
|
|
2686
|
+
pagingState: paging(6, { coin: false, internal: false, token: false, nft: false }),
|
|
2604
2687
|
})
|
|
2605
2688
|
})
|
|
2606
2689
|
|
|
@@ -2619,17 +2702,19 @@ describe('EVM Family', () => {
|
|
|
2619
2702
|
const result = await callGetOperations('asc')(
|
|
2620
2703
|
[T2, I2, C2, C4, I4, C5, I5, C6, I7, I8, C8, T8],
|
|
2621
2704
|
{
|
|
2622
|
-
pagingState: paging(4, { coin: false, internal: false, token: false }),
|
|
2705
|
+
pagingState: paging(4, { coin: false, internal: false, token: false, nft: true }),
|
|
2623
2706
|
}
|
|
2624
2707
|
)
|
|
2625
2708
|
// pagingState.boundBlock=4 acts as fromBlock for all endpoints
|
|
2626
2709
|
// - coin([4, Ø]) [C4 C5 C6] boundBlock=7, isPageFull=true, hasMorePage=true (full page)
|
|
2627
|
-
// - internal([4, 7]) [I4 I5] boundBlock=7, isPageFull=false, hasMorePage=true (
|
|
2628
|
-
// - token([4, 7]) [] boundBlock=7, isPageFull=false, hasMorePage=true (
|
|
2710
|
+
// - internal([4, 7]) [I4 I5] boundBlock=7, isPageFull=false, hasMorePage=true (constrained by coins's bound, I7/I8 not yet reached)
|
|
2711
|
+
// - token([4, 7]) [] boundBlock=7, isPageFull=false, hasMorePage=true (constrained by coins's bound, T8 not yet reached)
|
|
2629
2712
|
// Result: C4/C5/C6 + I4/I5 kept, T2/I2/C2 excluded by pagingToken
|
|
2630
2713
|
expect(summarize(result)).toEqual({
|
|
2631
2714
|
ops: ops(C6, C5, I5, C4, I4),
|
|
2632
|
-
|
|
2715
|
+
// nft stays done: the incoming cursor already marked it done, so the endpoint is
|
|
2716
|
+
// short-circuited rather than re-queried, and a short-circuit is never "constrained".
|
|
2717
|
+
pagingState: paging(7, { coin: false, internal: false, token: false, nft: true }),
|
|
2633
2718
|
})
|
|
2634
2719
|
})
|
|
2635
2720
|
})
|
|
@@ -2646,12 +2731,12 @@ describe('EVM Family', () => {
|
|
|
2646
2731
|
)
|
|
2647
2732
|
// fromBlock=3, toBlock=7 restricts all endpoints
|
|
2648
2733
|
// - coin([3, 7]) [C4 C5 C6]+[C7] boundBlock=6, isPageFull=true, hasMorePage=true (full page + more)
|
|
2649
|
-
// - internal([3, 6]) [I4 I5] boundBlock=Ø, isPageFull=false, hasMorePage=
|
|
2650
|
-
// - token([3, 6]) [] boundBlock=Ø, isPageFull=false, hasMorePage=
|
|
2734
|
+
// - internal([3, 6]) [I4 I5] boundBlock=Ø, isPageFull=false, hasMorePage=true (constrained by coins's bound: 6 < toBlock=7)
|
|
2735
|
+
// - token([3, 6]) [] boundBlock=Ø, isPageFull=false, hasMorePage=true (constrained by coins's bound: 6 < toBlock=7)
|
|
2651
2736
|
// Result: ops in [3, 6] kept, C7/I7/T1/I1/C1 excluded
|
|
2652
2737
|
expect(summarize(result)).toEqual({
|
|
2653
2738
|
ops: ops(C6, C5, I5, C4, I4),
|
|
2654
|
-
pagingState: paging(7, { coin: false, internal:
|
|
2739
|
+
pagingState: paging(7, { coin: false, internal: false, token: false, nft: false }),
|
|
2655
2740
|
})
|
|
2656
2741
|
})
|
|
2657
2742
|
|
|
@@ -2675,6 +2760,170 @@ describe('EVM Family', () => {
|
|
|
2675
2760
|
})
|
|
2676
2761
|
})
|
|
2677
2762
|
})
|
|
2763
|
+
|
|
2764
|
+
describe('multi-page completeness', () => {
|
|
2765
|
+
const MAX_PAGES = 50
|
|
2766
|
+
|
|
2767
|
+
// Drives getOperations page by page, feeding each nextPagingToken back in, until
|
|
2768
|
+
// the cursor is exhausted. Returns every page so tests can assert on the union.
|
|
2769
|
+
const paginateToExhaustion = async (
|
|
2770
|
+
order: 'asc' | 'desc',
|
|
2771
|
+
allOps: BlockchainOp[],
|
|
2772
|
+
opts: { fromBlock?: number; toBlock?: number; limit?: number } = {}
|
|
2773
|
+
): Promise<string[][]> => {
|
|
2774
|
+
const pages: string[][] = []
|
|
2775
|
+
let pagingState: PagingState | undefined
|
|
2776
|
+
for (let page = 0; page < MAX_PAGES; page++) {
|
|
2777
|
+
const result = await callGetOperations(order)(allOps, {
|
|
2778
|
+
...opts,
|
|
2779
|
+
...(pagingState !== undefined && { pagingState }),
|
|
2780
|
+
})
|
|
2781
|
+
pages.push(summarizeIdentified(result))
|
|
2782
|
+
const { pagingState: next } = summarize(result)
|
|
2783
|
+
if (!next) return pages
|
|
2784
|
+
pagingState = next
|
|
2785
|
+
}
|
|
2786
|
+
throw new Error(`pagination did not terminate within ${MAX_PAGES} pages`)
|
|
2787
|
+
}
|
|
2788
|
+
|
|
2789
|
+
// The scenario's ops as the labels a complete pagination must produce, one per op.
|
|
2790
|
+
const expected = (allOps: BlockchainOp[]): string[] => identify(allOps).map(opLabel)
|
|
2791
|
+
|
|
2792
|
+
// Canonical ordering so a union of pages can be compared regardless of page order.
|
|
2793
|
+
// Keeps duplicates, so an op returned on two pages fails the comparison too.
|
|
2794
|
+
const blockOf = (label: string): number => Number(label.replace(/^[A-Z]/, '').split('#')[0])
|
|
2795
|
+
const canonical = (items: string[]): string[] =>
|
|
2796
|
+
[...items].sort((a, b) => blockOf(b) - blockOf(a) || a.localeCompare(b))
|
|
2797
|
+
|
|
2798
|
+
// Guards the guard. If the labels ever lose operation identity, one op returned twice
|
|
2799
|
+
// while another at the same type and block is dropped would stop being detected, and
|
|
2800
|
+
// every exactly-once assertion below would quietly weaken without any of them failing.
|
|
2801
|
+
it('exactly-once comparison tells apart operations sharing a type and block', () => {
|
|
2802
|
+
const labels = expected([C4, C4, C4])
|
|
2803
|
+
const duplicatedAndDropped = [labels[0], labels[1], labels[1]]
|
|
2804
|
+
|
|
2805
|
+
// Type and block alone cannot tell these two multisets apart...
|
|
2806
|
+
const withoutIdentity = (items: string[]): string[] =>
|
|
2807
|
+
items.map((label) => label.split('#')[0]).sort()
|
|
2808
|
+
expect(withoutIdentity(duplicatedAndDropped)).toEqual(withoutIdentity(labels))
|
|
2809
|
+
|
|
2810
|
+
// ...but the labels the assertions actually compare do.
|
|
2811
|
+
expect(canonical(duplicatedAndDropped)).not.toEqual(canonical(labels))
|
|
2812
|
+
})
|
|
2813
|
+
|
|
2814
|
+
// Scanning from genesis used to silently drop every token transfer once the first page
|
|
2815
|
+
// of native txs filled up.
|
|
2816
|
+
//
|
|
2817
|
+
// Cause: coin returns a full page, which cascades a bound block onto the token endpoint.
|
|
2818
|
+
// Token then finds nothing *inside that narrowed window* and reports isDone=true. The
|
|
2819
|
+
// cursor used to record that as "token globally done", so page 2 skipped the endpoint
|
|
2820
|
+
// entirely and the transfers below the bound were never fetched by any page.
|
|
2821
|
+
it('does not lose token transfers that sit below the first page bound block', async () => {
|
|
2822
|
+
// Native txs occupy the newest blocks; the token transfers are all older.
|
|
2823
|
+
const allOps = [C9, C8, C7, C6, T3, T2, T1]
|
|
2824
|
+
const labels = expected(allOps)
|
|
2825
|
+
const pages = await paginateToExhaustion('desc', allOps, { fromBlock: 0 })
|
|
2826
|
+
|
|
2827
|
+
// Page 1 is native-only: the token endpoint was constrained to the coin bound and
|
|
2828
|
+
// legitimately found nothing there. The bug was in what the cursor recorded next.
|
|
2829
|
+
expect(pages[0]).toEqual(labels.slice(0, 3))
|
|
2830
|
+
|
|
2831
|
+
// The whole point: the token transfers still show up on a later page.
|
|
2832
|
+
expect(canonical(pages.flat())).toEqual(canonical(labels))
|
|
2833
|
+
})
|
|
2834
|
+
|
|
2835
|
+
it('re-queries an internal endpoint that was only locally done', async () => {
|
|
2836
|
+
const allOps = [C9, C8, C7, C6, I3, I2]
|
|
2837
|
+
const pages = await paginateToExhaustion('desc', allOps, { fromBlock: 0 })
|
|
2838
|
+
|
|
2839
|
+
expect(canonical(pages.flat())).toEqual(canonical(expected(allOps)))
|
|
2840
|
+
})
|
|
2841
|
+
|
|
2842
|
+
// The scenarios below are the ones whose single-page cursor expectations changed with the
|
|
2843
|
+
// fix. Walking each to exhaustion checks the new cursor values against an invariant that
|
|
2844
|
+
// does not depend on those expectations: every op is returned exactly once.
|
|
2845
|
+
const scenarios: Array<{ name: string; ops: BlockchainOp[] }> = [
|
|
2846
|
+
{ name: 'internal above a full coin page', ops: [I6, I6, I6, I5, T5, C4, C3, C2] },
|
|
2847
|
+
{ name: 'token above a full coin page', ops: [T9, T8, T7, I6, I5, C4, C3, C2, T1] },
|
|
2848
|
+
{ name: 'interleaved blocks', ops: [T6, C5, I5, C4, I4, C3, I2, I1, T1] },
|
|
2849
|
+
{
|
|
2850
|
+
name: 'all endpoints stacked on one block',
|
|
2851
|
+
ops: [C4, C4, C4, I4, I4, I4, T4, T4, T4, C1, I1, T1],
|
|
2852
|
+
},
|
|
2853
|
+
{ name: 'only coin has ops', ops: [C4, C3, C2, C1] },
|
|
2854
|
+
{ name: 'only token has ops', ops: [T4, T3, T2, T1] },
|
|
2855
|
+
// One of each direction: ops stranded below the bound only fall outside the window
|
|
2856
|
+
// when paging desc, and above it only when paging asc.
|
|
2857
|
+
{ name: 'sparse tail below the bound', ops: [C9, C8, C7, C6, I3, T2, T1] },
|
|
2858
|
+
{ name: 'sparse head above the bound', ops: [C1, C2, C3, C4, I7, T8, T9] },
|
|
2859
|
+
]
|
|
2860
|
+
|
|
2861
|
+
it.each(scenarios)('desc: returns every op exactly once - $name', async ({ ops: allOps }) => {
|
|
2862
|
+
const pages = await paginateToExhaustion('desc', allOps, { fromBlock: 0 })
|
|
2863
|
+
expect(canonical(pages.flat())).toEqual(canonical(expected(allOps)))
|
|
2864
|
+
})
|
|
2865
|
+
|
|
2866
|
+
it.each(scenarios)('asc: returns every op exactly once - $name', async ({ ops: allOps }) => {
|
|
2867
|
+
const pages = await paginateToExhaustion('asc', allOps, { fromBlock: 0 })
|
|
2868
|
+
expect(canonical(pages.flat())).toEqual(canonical(expected(allOps)))
|
|
2869
|
+
})
|
|
2870
|
+
|
|
2871
|
+
// The NFT endpoint is the last in the cascade, so it is handed the most narrowed window
|
|
2872
|
+
// and is the most exposed to being marked done too early. The scenarios above carry no
|
|
2873
|
+
// NFT operations, so they only ever exercise it as an empty endpoint.
|
|
2874
|
+
describe('nft endpoints (ERC-721 + ERC-1155)', () => {
|
|
2875
|
+
// desc pages from the highest block down, so the first coin page sets a floor and the
|
|
2876
|
+
// nft ops have to sit below it to fall outside the narrowed window. asc is the mirror
|
|
2877
|
+
// image: the first coin page sets a ceiling, so they have to sit above it. Using the
|
|
2878
|
+
// same block layout for both directions would leave one of them never exercising the
|
|
2879
|
+
// constrained path at all.
|
|
2880
|
+
const descScenarios: Array<{ name: string; ops: BlockchainOp[] }> = [
|
|
2881
|
+
{ name: 'erc721 below a full coin page', ops: [C9, C8, C7, C6, N3, N2, N1] },
|
|
2882
|
+
{ name: 'erc1155 below a full coin page', ops: [C9, C8, C7, C6, M3, M2, M1] },
|
|
2883
|
+
{ name: 'erc721 and erc1155 interleaved', ops: [C9, C8, C7, C6, N3, M2, N1, M1] },
|
|
2884
|
+
{ name: 'nft behind coin, internal and token', ops: [C9, C8, C7, C6, I5, T4, N3, M2] },
|
|
2885
|
+
{ name: 'erc721 and erc1155 on the same block', ops: [C9, C8, C7, C6, N2, M2] },
|
|
2886
|
+
{ name: 'nft only', ops: [N4, N3, M2, M1] },
|
|
2887
|
+
]
|
|
2888
|
+
|
|
2889
|
+
const ascScenarios: Array<{ name: string; ops: BlockchainOp[] }> = [
|
|
2890
|
+
{ name: 'erc721 above a full coin page', ops: [C1, C2, C3, C4, N7, N8, N9] },
|
|
2891
|
+
{ name: 'erc1155 above a full coin page', ops: [C1, C2, C3, C4, M7, M8, M9] },
|
|
2892
|
+
{ name: 'erc721 and erc1155 interleaved', ops: [C1, C2, C3, C4, N7, M8, N9, M9] },
|
|
2893
|
+
{ name: 'nft behind coin, internal and token', ops: [C1, C2, C3, C4, I5, T6, N7, M8] },
|
|
2894
|
+
{ name: 'erc721 and erc1155 on the same block', ops: [C1, C2, C3, C4, N8, M8] },
|
|
2895
|
+
{ name: 'nft only', ops: [N1, N2, M3, M4] },
|
|
2896
|
+
]
|
|
2897
|
+
|
|
2898
|
+
it.each(descScenarios)(
|
|
2899
|
+
'desc: returns every nft op exactly once - $name',
|
|
2900
|
+
async ({ ops: allOps }) => {
|
|
2901
|
+
const pages = await paginateToExhaustion('desc', allOps, { fromBlock: 0 })
|
|
2902
|
+
expect(canonical(pages.flat())).toEqual(canonical(expected(allOps)))
|
|
2903
|
+
}
|
|
2904
|
+
)
|
|
2905
|
+
|
|
2906
|
+
it.each(ascScenarios)(
|
|
2907
|
+
'asc: returns every nft op exactly once - $name',
|
|
2908
|
+
async ({ ops: allOps }) => {
|
|
2909
|
+
const pages = await paginateToExhaustion('asc', allOps, { fromBlock: 0 })
|
|
2910
|
+
expect(canonical(pages.flat())).toEqual(canonical(expected(allOps)))
|
|
2911
|
+
}
|
|
2912
|
+
)
|
|
2913
|
+
|
|
2914
|
+
// Same shape as the coin/token regression above, but for the last endpoint in the
|
|
2915
|
+
// cascade: the first coin page narrows the NFT window to nothing, and the NFT
|
|
2916
|
+
// transfers all sit below that bound.
|
|
2917
|
+
it('does not lose nft transfers that sit below the first page bound block', async () => {
|
|
2918
|
+
const allOps = [C9, C8, C7, C6, N3, M2, N1]
|
|
2919
|
+
const labels = expected(allOps)
|
|
2920
|
+
const pages = await paginateToExhaustion('desc', allOps, { fromBlock: 0 })
|
|
2921
|
+
|
|
2922
|
+
expect(pages[0]).toEqual(labels.slice(0, 3))
|
|
2923
|
+
expect(canonical(pages.flat())).toEqual(canonical(labels))
|
|
2924
|
+
})
|
|
2925
|
+
})
|
|
2926
|
+
})
|
|
2678
2927
|
})
|
|
2679
2928
|
|
|
2680
2929
|
describe('exhaustEndpoint', () => {
|