@xyo-network/chain-services 1.20.14 → 1.20.16
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/README.md +9 -7634
- package/dist/neutral/index.mjs +2 -2
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/simple/block/runner/SimpleBlockRunner.d.ts +2 -2
- package/dist/neutral/simple/block/runner/SimpleBlockRunner.d.ts.map +1 -1
- package/package.json +122 -29
- package/src/BlockReward/EvmBlockRewardViewer.ts +0 -53
- package/src/BlockReward/index.ts +0 -1
- package/src/ChainValidator/XyoValidator.ts +0 -71
- package/src/ChainValidator/index.ts +0 -2
- package/src/ChainValidator/model/Validator.ts +0 -7
- package/src/ChainValidator/model/index.ts +0 -1
- package/src/Election/BaseElectionService.ts +0 -55
- package/src/Election/index.ts +0 -1
- package/src/NetworkStakeStepReward/BaseNetworkStakeStepRewardService.ts +0 -99
- package/src/NetworkStakeStepReward/index.ts +0 -1
- package/src/StepStake/BaseStepStakeService.ts +0 -24
- package/src/StepStake/index.ts +0 -1
- package/src/implementation/head/createBootstrapHead.ts +0 -36
- package/src/implementation/head/index.ts +0 -1
- package/src/implementation/index.ts +0 -1
- package/src/index.ts +0 -8
- package/src/model/Params.ts +0 -10
- package/src/model/index.ts +0 -1
- package/src/simple/block/index.ts +0 -1
- package/src/simple/block/runner/SimpleBlockRunner.ts +0 -363
- package/src/simple/block/runner/generateTransactionFeeTransfers.ts +0 -56
- package/src/simple/block/runner/index.ts +0 -1
- package/src/simple/index.ts +0 -1
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { type Address, hexFromBigInt } from '@xylabs/sdk-js'
|
|
2
|
-
import { assertEx } from '@xylabs/sdk-js'
|
|
3
|
-
import { PayloadBuilder } from '@xyo-network/sdk-js'
|
|
4
|
-
import type {
|
|
5
|
-
SignedHydratedTransaction,
|
|
6
|
-
Transfer,
|
|
7
|
-
XL1,
|
|
8
|
-
} from '@xyo-network/xl1-sdk'
|
|
9
|
-
import {
|
|
10
|
-
HydratedTransactionWrapper,
|
|
11
|
-
transactionRequiredGas, TransferSchema, XYO_ZERO_ADDRESS,
|
|
12
|
-
} from '@xyo-network/xl1-sdk'
|
|
13
|
-
|
|
14
|
-
export async function generateTransactionFeeTransfers(address: Address, transactions: SignedHydratedTransaction[]): Promise<Transfer[]> {
|
|
15
|
-
const txs = await Promise.all(transactions.map(async (tx) => {
|
|
16
|
-
return HydratedTransactionWrapper.parse([await PayloadBuilder.addStorageMeta(tx[0]), await PayloadBuilder.addStorageMeta(tx[1])])
|
|
17
|
-
}))
|
|
18
|
-
|
|
19
|
-
// merge transactions with the same from address
|
|
20
|
-
const txBaseFeeCosts: Record<Address, bigint> = {}
|
|
21
|
-
for (const tx of txs) {
|
|
22
|
-
txBaseFeeCosts[tx.boundWitness.from] = (txBaseFeeCosts[tx.boundWitness.from] ?? 0n)
|
|
23
|
-
+ tx.fees.base
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const txGasCosts: Record<Address, bigint> = {}
|
|
27
|
-
for (const tx of txs) {
|
|
28
|
-
const requiredGas = transactionRequiredGas(tx.data)
|
|
29
|
-
const totalGasCost = requiredGas * tx.fees.gasPrice
|
|
30
|
-
txGasCosts[tx.boundWitness.from] = (txBaseFeeCosts[tx.boundWitness.from] ?? 0n)
|
|
31
|
-
+ totalGasCost
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// generate actual Transfer Payloads & burn the base fee
|
|
35
|
-
const payloads = (Object.entries(txBaseFeeCosts) as [Address, XL1][]).map(([from, amount]) => {
|
|
36
|
-
const payload: Transfer = {
|
|
37
|
-
schema: TransferSchema,
|
|
38
|
-
epoch: Date.now(),
|
|
39
|
-
from,
|
|
40
|
-
transfers: {
|
|
41
|
-
// burn the base fee
|
|
42
|
-
[XYO_ZERO_ADDRESS]: hexFromBigInt(amount),
|
|
43
|
-
},
|
|
44
|
-
}
|
|
45
|
-
return payload
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
// transfer gas cost to producer
|
|
49
|
-
for (const [from, amount] of Object.entries(txGasCosts)) {
|
|
50
|
-
// every gas from should also be a base fee from
|
|
51
|
-
const fromPayload = assertEx(payloads.find(p => p.from === from), () => 'from payload not found')
|
|
52
|
-
fromPayload.transfers[address] = hexFromBigInt(amount)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return payloads
|
|
56
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './SimpleBlockRunner.ts'
|
package/src/simple/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './block/index.ts'
|