@xyo-network/chain-services 1.11.0 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/AccountBalance/BaseAccountBalanceService.d.ts.map +1 -1
- package/dist/neutral/BlockProducer/BaseBlockProducerService.d.ts +17 -3
- package/dist/neutral/BlockProducer/BaseBlockProducerService.d.ts.map +1 -1
- package/dist/neutral/ChainBlockNumberIteration/model/BlockNumberIteration.d.ts +2 -2
- package/dist/neutral/ChainBlockNumberIteration/model/BlockNumberIteration.d.ts.map +1 -1
- package/dist/neutral/ChainValidator/XyoValidator.d.ts +20 -7
- package/dist/neutral/ChainValidator/XyoValidator.d.ts.map +1 -1
- package/dist/neutral/ChainValidator/model/Validator.d.ts +2 -2
- package/dist/neutral/ChainValidator/model/Validator.d.ts.map +1 -1
- package/dist/neutral/PendingTransactions/BasePendingTransactions.d.ts +4 -4
- package/dist/neutral/PendingTransactions/BasePendingTransactions.d.ts.map +1 -1
- package/dist/neutral/PendingTransactions/bundledPayloadToHydratedTransaction.d.ts +2 -2
- package/dist/neutral/PendingTransactions/bundledPayloadToHydratedTransaction.d.ts.map +1 -1
- package/dist/neutral/PendingTransactions/hydratedTransactionToPayloadBundle.d.ts +2 -2
- package/dist/neutral/PendingTransactions/hydratedTransactionToPayloadBundle.d.ts.map +1 -1
- package/dist/neutral/StakeIntent/XyoStakeIntentService.d.ts +5 -1
- package/dist/neutral/StakeIntent/XyoStakeIntentService.d.ts.map +1 -1
- package/dist/neutral/index.mjs +344 -225
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +37 -37
- package/src/AccountBalance/BaseAccountBalanceService.ts +2 -1
- package/src/BlockProducer/spec/BaseBlockProducerService.spec.ts +3 -3
- package/src/BlockProducer/spec/generateTransactionTransfer.spec.ts +2 -2
- package/src/ChainBlockNumberIteration/model/BlockNumberIteration.ts +2 -2
- package/src/ChainValidator/XyoValidator.ts +4 -4
- package/src/ChainValidator/model/Validator.ts +2 -2
- package/src/PendingTransactions/BasePendingTransactions.ts +8 -7
- package/src/PendingTransactions/bundledPayloadToHydratedTransaction.ts +2 -2
- package/src/PendingTransactions/hydratedTransactionToPayloadBundle.ts +3 -3
- package/src/PendingTransactions/spec/BasePendingTransactions.spec.ts +11 -10
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@xyo-network/chain-services",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.12.1",
|
|
5
5
|
"description": "XYO Layer One SDK Services",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -37,48 +37,48 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@opentelemetry/api": "~1.9.0",
|
|
40
|
-
"@xylabs/array": "~5.0.
|
|
41
|
-
"@xylabs/assert": "~5.0.
|
|
42
|
-
"@xylabs/creatable": "~5.0.
|
|
43
|
-
"@xylabs/decimal-precision": "~5.0.
|
|
44
|
-
"@xylabs/events": "~5.0.
|
|
45
|
-
"@xylabs/exists": "~5.0.
|
|
46
|
-
"@xylabs/forget": "~5.0.
|
|
47
|
-
"@xylabs/hex": "~5.0.
|
|
48
|
-
"@xylabs/promise": "~5.0.
|
|
49
|
-
"@xylabs/telemetry": "~5.0.
|
|
50
|
-
"@xylabs/typeof": "~5.0.
|
|
51
|
-
"@xyo-network/account-model": "~5.0.
|
|
52
|
-
"@xyo-network/archivist-memory": "~5.0.
|
|
53
|
-
"@xyo-network/archivist-model": "~5.0.
|
|
54
|
-
"@xyo-network/boundwitness-model": "~5.0.
|
|
55
|
-
"@xyo-network/boundwitness-validator": "~5.0.
|
|
56
|
-
"@xyo-network/boundwitness-wrapper": "~5.0.
|
|
57
|
-
"@xyo-network/chain-analyze": "~1.
|
|
58
|
-
"@xyo-network/chain-modules": "~1.
|
|
59
|
-
"@xyo-network/chain-protocol": "~1.
|
|
60
|
-
"@xyo-network/chain-utils": "~1.
|
|
61
|
-
"@xyo-network/payload-builder": "~5.0.
|
|
62
|
-
"@xyo-network/payload-model": "~5.0.
|
|
40
|
+
"@xylabs/array": "~5.0.8",
|
|
41
|
+
"@xylabs/assert": "~5.0.8",
|
|
42
|
+
"@xylabs/creatable": "~5.0.8",
|
|
43
|
+
"@xylabs/decimal-precision": "~5.0.8",
|
|
44
|
+
"@xylabs/events": "~5.0.8",
|
|
45
|
+
"@xylabs/exists": "~5.0.8",
|
|
46
|
+
"@xylabs/forget": "~5.0.8",
|
|
47
|
+
"@xylabs/hex": "~5.0.8",
|
|
48
|
+
"@xylabs/promise": "~5.0.8",
|
|
49
|
+
"@xylabs/telemetry": "~5.0.8",
|
|
50
|
+
"@xylabs/typeof": "~5.0.8",
|
|
51
|
+
"@xyo-network/account-model": "~5.0.5",
|
|
52
|
+
"@xyo-network/archivist-memory": "~5.0.5",
|
|
53
|
+
"@xyo-network/archivist-model": "~5.0.5",
|
|
54
|
+
"@xyo-network/boundwitness-model": "~5.0.5",
|
|
55
|
+
"@xyo-network/boundwitness-validator": "~5.0.5",
|
|
56
|
+
"@xyo-network/boundwitness-wrapper": "~5.0.5",
|
|
57
|
+
"@xyo-network/chain-analyze": "~1.12.1",
|
|
58
|
+
"@xyo-network/chain-modules": "~1.12.1",
|
|
59
|
+
"@xyo-network/chain-protocol": "~1.12.1",
|
|
60
|
+
"@xyo-network/chain-utils": "~1.12.1",
|
|
61
|
+
"@xyo-network/payload-builder": "~5.0.5",
|
|
62
|
+
"@xyo-network/payload-model": "~5.0.5",
|
|
63
63
|
"@xyo-network/typechain": "~4.0.0",
|
|
64
|
-
"@xyo-network/xl1-protocol": "~1.10.
|
|
65
|
-
"@xyo-network/xl1-protocol-sdk": "~1.
|
|
66
|
-
"@xyo-network/xl1-validation": "~1.
|
|
67
|
-
"@xyo-network/xl1-wrappers": "~1.
|
|
64
|
+
"@xyo-network/xl1-protocol": "~1.10.13",
|
|
65
|
+
"@xyo-network/xl1-protocol-sdk": "~1.12.1",
|
|
66
|
+
"@xyo-network/xl1-validation": "~1.12.1",
|
|
67
|
+
"@xyo-network/xl1-wrappers": "~1.12.1",
|
|
68
68
|
"async-mutex": "~0.5.0",
|
|
69
69
|
"ethers": "6.15.0",
|
|
70
70
|
"lru-cache": "~11.1.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@types/node": "~24.2.
|
|
74
|
-
"@xylabs/delay": "~5.0.
|
|
75
|
-
"@xylabs/ts-scripts-yarn3": "~7.1.
|
|
76
|
-
"@xylabs/tsconfig": "~7.1.
|
|
77
|
-
"@xylabs/vitest-extended": "~5.0.
|
|
78
|
-
"@xyo-network/account": "~5.0.
|
|
79
|
-
"@xyo-network/account-model": "~5.0.
|
|
80
|
-
"@xyo-network/chain-validation": "~1.
|
|
81
|
-
"@xyo-network/wallet": "~5.0.
|
|
73
|
+
"@types/node": "~24.2.1",
|
|
74
|
+
"@xylabs/delay": "~5.0.8",
|
|
75
|
+
"@xylabs/ts-scripts-yarn3": "~7.1.2",
|
|
76
|
+
"@xylabs/tsconfig": "~7.1.2",
|
|
77
|
+
"@xylabs/vitest-extended": "~5.0.8",
|
|
78
|
+
"@xyo-network/account": "~5.0.5",
|
|
79
|
+
"@xyo-network/account-model": "~5.0.5",
|
|
80
|
+
"@xyo-network/chain-validation": "~1.12.1",
|
|
81
|
+
"@xyo-network/wallet": "~5.0.5",
|
|
82
82
|
"tslib": "~2.8.1",
|
|
83
83
|
"typescript": "~5.9.2",
|
|
84
84
|
"vitest": "~3.2.4",
|
|
@@ -26,7 +26,8 @@ export class BaseAccountBalanceService extends BaseService<BaseAccountBalanceSer
|
|
|
26
26
|
})
|
|
27
27
|
const result: Record<Address, AttoXL1> = {}
|
|
28
28
|
for (const addr of address) {
|
|
29
|
-
|
|
29
|
+
const summaryBalance = summary[addr] ?? 0n
|
|
30
|
+
result[addr] = AttoXL1(summaryBalance < 0n ? 0n : summaryBalance)
|
|
30
31
|
}
|
|
31
32
|
return result
|
|
32
33
|
}
|
|
@@ -4,7 +4,7 @@ import { filterAs } from '@xylabs/array'
|
|
|
4
4
|
import { assertEx } from '@xylabs/assert'
|
|
5
5
|
import type { CreatableName } from '@xylabs/creatable'
|
|
6
6
|
import { delay } from '@xylabs/delay'
|
|
7
|
-
import type { Address
|
|
7
|
+
import type { Address } from '@xylabs/hex'
|
|
8
8
|
import {
|
|
9
9
|
asAddress, hexToBigInt, ZERO_HASH,
|
|
10
10
|
} from '@xylabs/hex'
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from '@xyo-network/payload-model'
|
|
20
20
|
import { HDWallet } from '@xyo-network/wallet'
|
|
21
21
|
import type {
|
|
22
|
-
BlockBoundWitness, BlockRewardService, ElectionService,
|
|
22
|
+
BlockBoundWitness, BlockRewardService, Chain, ElectionService,
|
|
23
23
|
HydratedBlock,
|
|
24
24
|
HydratedBlockStateValidationFunctionV2,
|
|
25
25
|
StakeIntentService,
|
|
@@ -175,7 +175,7 @@ describe('XyoBlockProducer', () => {
|
|
|
175
175
|
let rejectBlock = true
|
|
176
176
|
const validateHydratedBlockState: HydratedBlockStateValidationFunctionV2 = async (
|
|
177
177
|
hydratedBlock: HydratedBlock,
|
|
178
|
-
chainId:
|
|
178
|
+
chainId: Chain,
|
|
179
179
|
) => {
|
|
180
180
|
return rejectBlock ? [await Promise.resolve(new HydratedBlockStateValidationError(ZERO_HASH, chainId, hydratedBlock, 'Invalid block'))] : []
|
|
181
181
|
}
|
|
@@ -9,7 +9,7 @@ import { isDefined } from '@xylabs/typeof'
|
|
|
9
9
|
import type { Sequence, WithStorageMeta } from '@xyo-network/payload-model'
|
|
10
10
|
import { XYO_ZERO_ADDRESS } from '@xyo-network/xl1-protocol'
|
|
11
11
|
import {
|
|
12
|
-
defaultTransactionFees, type
|
|
12
|
+
defaultTransactionFees, type SignedHydratedTransactionWithStorageMeta, type Transfer,
|
|
13
13
|
} from '@xyo-network/xl1-protocol'
|
|
14
14
|
import {
|
|
15
15
|
describe, expect, it,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
import { generateTransactionFeeTransfers } from '../generateTransactionFeeTransfers.ts'
|
|
19
19
|
|
|
20
20
|
describe('generateTransactionTransfers', () => {
|
|
21
|
-
const testCases:
|
|
21
|
+
const testCases: SignedHydratedTransactionWithStorageMeta[][] = [
|
|
22
22
|
[
|
|
23
23
|
[
|
|
24
24
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Promisable } from '@xylabs/promise'
|
|
2
|
-
import type { BlockBoundWitness,
|
|
2
|
+
import type { BlockBoundWitness, SignedHydratedTransactionWithStorageMeta } from '@xyo-network/xl1-protocol'
|
|
3
3
|
|
|
4
4
|
export interface BlockNumberIteration {
|
|
5
5
|
validatePendingBlock(block: BlockBoundWitness): Promisable<Error[]>
|
|
6
|
-
validatePendingTransaction(tx:
|
|
6
|
+
validatePendingTransaction(tx: SignedHydratedTransactionWithStorageMeta): Promise<boolean>
|
|
7
7
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
2
|
import { creatable } from '@xylabs/creatable'
|
|
3
|
-
import { Address } from '@xylabs/hex'
|
|
4
3
|
import { Promisable } from '@xylabs/promise'
|
|
5
4
|
import { AccountInstance } from '@xyo-network/account-model'
|
|
6
5
|
import { ArchivistInstance, ReadArchivist } from '@xyo-network/archivist-model'
|
|
7
6
|
import {
|
|
8
7
|
BlockBoundWitness,
|
|
9
8
|
BlockRewardService,
|
|
9
|
+
Chain,
|
|
10
10
|
ElectionService,
|
|
11
11
|
HydratedBlockStateValidationFunctionV2,
|
|
12
|
-
|
|
12
|
+
SignedHydratedTransactionWithStorageMeta,
|
|
13
13
|
StakeIntentService,
|
|
14
14
|
} from '@xyo-network/xl1-protocol'
|
|
15
15
|
|
|
@@ -20,7 +20,7 @@ import { Validator } from './model/index.ts'
|
|
|
20
20
|
export interface XyoValidatorParams extends BaseServiceParams {
|
|
21
21
|
account: AccountInstance
|
|
22
22
|
chainArchivist: ReadArchivist
|
|
23
|
-
chainId:
|
|
23
|
+
chainId: Chain
|
|
24
24
|
electionService: ElectionService
|
|
25
25
|
pendingBundledTransactionsArchivist: ArchivistInstance
|
|
26
26
|
rewardService: BlockRewardService
|
|
@@ -63,7 +63,7 @@ export class XyoValidator<TParams extends XyoValidatorParams = XyoValidatorParam
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
// TODO: Move to validator and inherit this class from validator
|
|
66
|
-
async validatePendingTransaction(hydratedTransaction:
|
|
66
|
+
async validatePendingTransaction(hydratedTransaction: SignedHydratedTransactionWithStorageMeta): Promise<boolean> {
|
|
67
67
|
const [tx] = hydratedTransaction
|
|
68
68
|
// Ensure not confirmed already (replay attack)
|
|
69
69
|
if ((await this.chainArchivist.get([tx._hash])).length > 0) return false
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Promisable } from '@xylabs/promise'
|
|
2
|
-
import type { BlockBoundWitness,
|
|
2
|
+
import type { BlockBoundWitness, SignedHydratedTransactionWithStorageMeta } from '@xyo-network/xl1-protocol'
|
|
3
3
|
|
|
4
4
|
export interface Validator {
|
|
5
5
|
validatePendingBlock(block: BlockBoundWitness): Promisable<Error[]>
|
|
6
|
-
validatePendingTransaction(tx:
|
|
6
|
+
validatePendingTransaction(tx: SignedHydratedTransactionWithStorageMeta): Promise<boolean>
|
|
7
7
|
}
|
|
@@ -4,7 +4,7 @@ import { assertEx } from '@xylabs/assert'
|
|
|
4
4
|
import { creatable } from '@xylabs/creatable'
|
|
5
5
|
import { exists } from '@xylabs/exists'
|
|
6
6
|
import { forget } from '@xylabs/forget'
|
|
7
|
-
import {
|
|
7
|
+
import { Hash } from '@xylabs/hex'
|
|
8
8
|
import { isDefined, isUndefined } from '@xylabs/typeof'
|
|
9
9
|
import { MemoryArchivist } from '@xyo-network/archivist-memory'
|
|
10
10
|
import { ArchivistInstance } from '@xyo-network/archivist-model'
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
Payload, PayloadBundle, Sequence, WithStorageMeta,
|
|
14
14
|
} from '@xyo-network/payload-model'
|
|
15
15
|
import {
|
|
16
|
-
asBlockBoundWitnessWithHashStorageMeta,
|
|
16
|
+
asBlockBoundWitnessWithHashStorageMeta, Chain, isTransactionBoundWitnessWithStorageMeta, PendingTransactionsService,
|
|
17
|
+
SignedHydratedTransactionWithStorageMeta,
|
|
17
18
|
} from '@xyo-network/xl1-protocol'
|
|
18
19
|
import { TransactionJsonSchemaValidator, validateTransaction } from '@xyo-network/xl1-validation'
|
|
19
20
|
import { Mutex } from 'async-mutex'
|
|
@@ -25,7 +26,7 @@ import { hydratedTransactionToPayloadBundle } from './hydratedTransactionToPaylo
|
|
|
25
26
|
|
|
26
27
|
export interface BasePendingTransactionsServiceParams extends BaseServiceParams {
|
|
27
28
|
chainArchivist?: ArchivistInstance
|
|
28
|
-
chainId?:
|
|
29
|
+
chainId?: Chain
|
|
29
30
|
pendingBundledTransactionsArchivist?: ArchivistInstance
|
|
30
31
|
rejectedTransactionsArchivist?: ArchivistInstance
|
|
31
32
|
}
|
|
@@ -134,7 +135,7 @@ export class BasePendingTransactionsService extends BaseService<BasePendingTrans
|
|
|
134
135
|
})
|
|
135
136
|
}
|
|
136
137
|
|
|
137
|
-
async getPendingTransactions(head: Hash, limit: number): Promise<
|
|
138
|
+
async getPendingTransactions(head: Hash, limit: number): Promise<SignedHydratedTransactionWithStorageMeta[]> {
|
|
138
139
|
return await this.spanAsync('getPendingTransactions', async () => {
|
|
139
140
|
// Acquires an exclusive mutex to ensure no race conditions while accessing pending transactions.
|
|
140
141
|
return await this._updateCuratedPendingTransactionsArchivistMutex.runExclusive(async () => {
|
|
@@ -144,7 +145,7 @@ export class BasePendingTransactionsService extends BaseService<BasePendingTrans
|
|
|
144
145
|
|
|
145
146
|
await this.pruneCuratedPendingTransactionsArchivist(lastHead._hash)
|
|
146
147
|
|
|
147
|
-
const foundPendingTransactions:
|
|
148
|
+
const foundPendingTransactions: SignedHydratedTransactionWithStorageMeta[] = []
|
|
148
149
|
let cursor: Sequence | undefined
|
|
149
150
|
|
|
150
151
|
// Continue fetching until the desired number of transactions is reached.
|
|
@@ -333,7 +334,7 @@ export class BasePendingTransactionsService extends BaseService<BasePendingTrans
|
|
|
333
334
|
* @returns True if the transaction is expired for the given block, false otherwise.
|
|
334
335
|
*/
|
|
335
336
|
const isTransactionExpired = (block: number) =>
|
|
336
|
-
([txBw]:
|
|
337
|
+
([txBw]: SignedHydratedTransactionWithStorageMeta): boolean =>
|
|
337
338
|
txBw.exp < block
|
|
338
339
|
|
|
339
340
|
/**
|
|
@@ -342,5 +343,5 @@ const isTransactionExpired = (block: number) =>
|
|
|
342
343
|
* @returns True if the transaction is active for the given block, false otherwise.
|
|
343
344
|
*/
|
|
344
345
|
const isTransactionActive = (block: number) =>
|
|
345
|
-
([txBw]:
|
|
346
|
+
([txBw]: SignedHydratedTransactionWithStorageMeta): boolean =>
|
|
346
347
|
txBw.nbf <= block && txBw.exp >= block
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
2
2
|
import type { PayloadBundle, WithStorageMeta } from '@xyo-network/payload-model'
|
|
3
|
-
import type {
|
|
3
|
+
import type { SignedHydratedTransactionWithStorageMeta } from '@xyo-network/xl1-protocol'
|
|
4
4
|
import { asTransactionBoundWitnessWithStorageMeta } from '@xyo-network/xl1-protocol'
|
|
5
5
|
|
|
6
6
|
export const bundledPayloadToHydratedTransaction = async (
|
|
7
7
|
payload: WithStorageMeta<PayloadBundle>,
|
|
8
|
-
): Promise<
|
|
8
|
+
): Promise<SignedHydratedTransactionWithStorageMeta | undefined> => {
|
|
9
9
|
const withStorageMeta = await PayloadBuilder.addStorageMeta(payload.payloads)
|
|
10
10
|
const tx = asTransactionBoundWitnessWithStorageMeta(withStorageMeta.find(p => p._hash === payload.root))
|
|
11
11
|
if (tx) {
|
|
@@ -2,15 +2,15 @@ import type { Hash } from '@xylabs/hex'
|
|
|
2
2
|
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
3
3
|
import type { PayloadBundle } from '@xyo-network/payload-model'
|
|
4
4
|
import { PayloadBundleSchema } from '@xyo-network/payload-model'
|
|
5
|
-
import type {
|
|
5
|
+
import type { SignedHydratedTransactionWithStorageMeta } from '@xyo-network/xl1-protocol'
|
|
6
6
|
import { flattenHydratedTransaction } from '@xyo-network/xl1-protocol-sdk'
|
|
7
7
|
|
|
8
|
-
export const hydratedTransactionToPayloadBundle = (transaction:
|
|
8
|
+
export const hydratedTransactionToPayloadBundle = (transaction: SignedHydratedTransactionWithStorageMeta): PayloadBundle => {
|
|
9
9
|
const root = transaction[0]._hash
|
|
10
10
|
return bundle(root, transaction)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const bundle = (root: Hash, transaction:
|
|
13
|
+
const bundle = (root: Hash, transaction: SignedHydratedTransactionWithStorageMeta) => {
|
|
14
14
|
const payloads = flattenHydratedTransaction(transaction).flatMap(p => PayloadBuilder.omitStorageMeta(p))
|
|
15
15
|
return new PayloadBuilder<PayloadBundle>({ schema: PayloadBundleSchema })
|
|
16
16
|
.fields({ payloads, root })
|
|
@@ -14,7 +14,8 @@ import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
|
14
14
|
import type { WithStorageMeta } from '@xyo-network/payload-model'
|
|
15
15
|
import type {
|
|
16
16
|
BlockBoundWitness, HashPayload,
|
|
17
|
-
HydratedBlock,
|
|
17
|
+
HydratedBlock,
|
|
18
|
+
SignedHydratedTransactionWithStorageMeta,
|
|
18
19
|
} from '@xyo-network/xl1-protocol'
|
|
19
20
|
import { HashSchema } from '@xyo-network/xl1-protocol'
|
|
20
21
|
import {
|
|
@@ -64,7 +65,7 @@ describe('BasePendingTransactionsService', () => {
|
|
|
64
65
|
})
|
|
65
66
|
|
|
66
67
|
describe('with pending transactions', () => {
|
|
67
|
-
let newTransactions:
|
|
68
|
+
let newTransactions: SignedHydratedTransactionWithStorageMeta[] = []
|
|
68
69
|
beforeEach(async () => {
|
|
69
70
|
for (let index = 0; index < 5; index++) {
|
|
70
71
|
const tx = await buildRandomTransaction(TestChainId)
|
|
@@ -88,8 +89,8 @@ describe('BasePendingTransactionsService', () => {
|
|
|
88
89
|
})
|
|
89
90
|
|
|
90
91
|
describe('with pending and finalized transactions', () => {
|
|
91
|
-
let finalizedTransactions:
|
|
92
|
-
let newTransactions:
|
|
92
|
+
let finalizedTransactions: SignedHydratedTransactionWithStorageMeta[] = []
|
|
93
|
+
let newTransactions: SignedHydratedTransactionWithStorageMeta[] = []
|
|
93
94
|
beforeEach(async () => {
|
|
94
95
|
for (let index = 0; index < 5; index++) {
|
|
95
96
|
const tx = await buildRandomTransaction(TestChainId)
|
|
@@ -118,7 +119,7 @@ describe('BasePendingTransactionsService', () => {
|
|
|
118
119
|
.build()
|
|
119
120
|
beforeEach(async () => {})
|
|
120
121
|
it('when unique should allow transactions', async () => {
|
|
121
|
-
let newTransactions:
|
|
122
|
+
let newTransactions: SignedHydratedTransactionWithStorageMeta[] = []
|
|
122
123
|
// NOTE: Cast to Account to allow loadPreviousHash to be called
|
|
123
124
|
const signer = await Account.random()
|
|
124
125
|
const transaction1 = await buildTransaction(TestChainId, [hashPayload], [], signer, 0, 100)
|
|
@@ -133,7 +134,7 @@ describe('BasePendingTransactionsService', () => {
|
|
|
133
134
|
expect(result.length).toEqual(newTransactions.length)
|
|
134
135
|
})
|
|
135
136
|
it('when non-unique should filter duplicate transactions', async () => {
|
|
136
|
-
let newTransactions:
|
|
137
|
+
let newTransactions: SignedHydratedTransactionWithStorageMeta[] = []
|
|
137
138
|
const previousHash = 'bb27dd470ccf91665d573a16b4f652a47b8a24686d1b44c189c1fa826cd3fef5'
|
|
138
139
|
// NOTE: Cast to Account to allow loadPreviousHash to be called
|
|
139
140
|
const signer = await Account.random() as Account
|
|
@@ -154,7 +155,7 @@ describe('BasePendingTransactionsService', () => {
|
|
|
154
155
|
|
|
155
156
|
describe('with expiring transactions', () => {
|
|
156
157
|
const insertTransaction = async (nbf: number, exp: number) => {
|
|
157
|
-
const newTransactions:
|
|
158
|
+
const newTransactions: SignedHydratedTransactionWithStorageMeta[] = []
|
|
158
159
|
const signer = await Account.random()
|
|
159
160
|
const hashPayload = new PayloadBuilder<HashPayload>({ schema: HashSchema })
|
|
160
161
|
.fields({ hash: head._hash })
|
|
@@ -237,8 +238,8 @@ describe('BasePendingTransactionsService', () => {
|
|
|
237
238
|
})
|
|
238
239
|
|
|
239
240
|
describe('with pending and rejected transactions', () => {
|
|
240
|
-
let rejectedTransactions:
|
|
241
|
-
let newTransactions:
|
|
241
|
+
let rejectedTransactions: SignedHydratedTransactionWithStorageMeta[] = []
|
|
242
|
+
let newTransactions: SignedHydratedTransactionWithStorageMeta[] = []
|
|
242
243
|
beforeEach(async () => {
|
|
243
244
|
for (let index = 0; index < 5; index++) {
|
|
244
245
|
const tx = await buildRandomTransaction(TestChainId)
|
|
@@ -263,7 +264,7 @@ describe('BasePendingTransactionsService', () => {
|
|
|
263
264
|
describe('with invalid transactions in mempool', () => {
|
|
264
265
|
beforeEach(async () => {
|
|
265
266
|
const incorrectChainId = assertEx(asAddress('1234567890abcdef1234567890abcdef12345678'))
|
|
266
|
-
const invalidTransactions:
|
|
267
|
+
const invalidTransactions: SignedHydratedTransactionWithStorageMeta[] = [await buildRandomTransaction(incorrectChainId)]
|
|
267
268
|
const pending = invalidTransactions.map(hydratedTransactionToPayloadBundle)
|
|
268
269
|
await pendingBundledTransactionsArchivist.insert(pending)
|
|
269
270
|
})
|