@xyo-network/blocknative-ethereum-gas-plugin 4.2.0 → 5.0.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/package.json +17 -13
- package/src/lib/spec/getGasFromBlocknative.spec.ts +46 -0
- package/src/spec/Plugin.spec.ts +19 -0
- package/src/spec/Witness.spec.ts +24 -0
- package/typedoc.json +0 -5
- package/xy.config.ts +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/blocknative-ethereum-gas-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -28,21 +28,25 @@
|
|
|
28
28
|
},
|
|
29
29
|
"module": "dist/neutral/index.mjs",
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"src"
|
|
34
|
+
],
|
|
31
35
|
"dependencies": {
|
|
32
|
-
"@xylabs/axios": "^
|
|
33
|
-
"@xyo-network/abstract-witness": "^
|
|
34
|
-
"@xyo-network/blocknative-ethereum-gas-payload-plugin": "^
|
|
35
|
-
"@xyo-network/module-model": "^
|
|
36
|
-
"@xyo-network/payload-builder": "^
|
|
37
|
-
"@xyo-network/payload-model": "^
|
|
38
|
-
"@xyo-network/payloadset-plugin": "^
|
|
39
|
-
"@xyo-network/witness-timestamp": "^
|
|
36
|
+
"@xylabs/axios": "^5.0.0",
|
|
37
|
+
"@xyo-network/abstract-witness": "^5.0.0",
|
|
38
|
+
"@xyo-network/blocknative-ethereum-gas-payload-plugin": "^5.0.0",
|
|
39
|
+
"@xyo-network/module-model": "^5.0.0",
|
|
40
|
+
"@xyo-network/payload-builder": "^5.0.0",
|
|
41
|
+
"@xyo-network/payload-model": "^5.0.0",
|
|
42
|
+
"@xyo-network/payloadset-plugin": "^5.0.0",
|
|
43
|
+
"@xyo-network/witness-timestamp": "^5.0.0"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.
|
|
43
|
-
"@xylabs/tsconfig": "^7.0.
|
|
44
|
-
"@xylabs/vitest-extended": "^
|
|
45
|
-
"@xyo-network/payload-wrapper": "^
|
|
46
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.2",
|
|
47
|
+
"@xylabs/tsconfig": "^7.0.2",
|
|
48
|
+
"@xylabs/vitest-extended": "^5.0.0",
|
|
49
|
+
"@xyo-network/payload-wrapper": "^5.0.0",
|
|
46
50
|
"typescript": "^5.8.3",
|
|
47
51
|
"vitest": "^3.2.4"
|
|
48
52
|
},
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// import { PendingBlockNumber } from '@xyo-network/blocknative-ethereum-gas-payload-plugin'
|
|
2
|
+
|
|
3
|
+
import '@xylabs/vitest-extended'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
describe, expect,
|
|
7
|
+
test,
|
|
8
|
+
} from 'vitest'
|
|
9
|
+
|
|
10
|
+
import { getGasFromBlocknative } from '../getGasFromBlocknative.ts'
|
|
11
|
+
|
|
12
|
+
describe('getGasFromBlocknative', () => {
|
|
13
|
+
test('returns prices', async () => {
|
|
14
|
+
const result = await getGasFromBlocknative()
|
|
15
|
+
expect(result).toBeObject()
|
|
16
|
+
expect(result?.blockPrices).toBeArrayOfSize(1)
|
|
17
|
+
for (let blockPrice of result.blockPrices) {
|
|
18
|
+
expect(blockPrice.baseFeePerGas).toBeNumber()
|
|
19
|
+
expect(blockPrice.blockNumber).toBeNumber()
|
|
20
|
+
expect(blockPrice.estimatedPrices).toBeArrayOfSize(5)
|
|
21
|
+
for (let estimatedPrice of blockPrice.estimatedPrices) {
|
|
22
|
+
expect(estimatedPrice?.confidence).toBeNumber()
|
|
23
|
+
expect(estimatedPrice?.maxFeePerGas).toBeNumber()
|
|
24
|
+
expect(estimatedPrice?.maxPriorityFeePerGas).toBeNumber()
|
|
25
|
+
expect(estimatedPrice?.price).toBeNumber()
|
|
26
|
+
}
|
|
27
|
+
expect(blockPrice.estimatedTransactionCount).toBeNumber()
|
|
28
|
+
}
|
|
29
|
+
/* expect(result?.estimatedBaseFees).toBeArrayOfSize(5)
|
|
30
|
+
for (let index = 0; index < result?.estimatedBaseFees.length; index++) {
|
|
31
|
+
const blockNumber = `pending+${index + 1}` as PendingBlockNumber
|
|
32
|
+
const pendingBlockInfo = result.estimatedBaseFees?.[index]?.[blockNumber]
|
|
33
|
+
expect(pendingBlockInfo.length).toBeGreaterThan(0)
|
|
34
|
+
const pendingBlock = pendingBlockInfo?.[0]
|
|
35
|
+
expect(pendingBlock).toBeObject()
|
|
36
|
+
expect(pendingBlock?.baseFee).toBeNumber()
|
|
37
|
+
expect(pendingBlock?.confidence).toBeNumber()
|
|
38
|
+
} */
|
|
39
|
+
expect(result?.currentBlockNumber).toBeNumber()
|
|
40
|
+
expect(result?.maxPrice).toBeNumber()
|
|
41
|
+
expect(result?.msSinceLastBlock).toBeNumber()
|
|
42
|
+
expect(result?.network).toEqual('main')
|
|
43
|
+
expect(result?.system).toEqual('ethereum')
|
|
44
|
+
expect(result?.unit).toEqual('gwei')
|
|
45
|
+
})
|
|
46
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import { PayloadSetPluginResolver } from '@xyo-network/payloadset-plugin'
|
|
4
|
+
import {
|
|
5
|
+
describe, expect,
|
|
6
|
+
test,
|
|
7
|
+
} from 'vitest'
|
|
8
|
+
|
|
9
|
+
import { EthereumGasBlocknativePlugin } from '../Plugin.ts'
|
|
10
|
+
import { EthereumGasBlocknativeWitness } from '../Witness.ts'
|
|
11
|
+
|
|
12
|
+
describe('EthereumGasBlocknativePlugin', () => {
|
|
13
|
+
test('Add to Resolver', async () => {
|
|
14
|
+
const plugin = EthereumGasBlocknativePlugin()
|
|
15
|
+
const resolver = await new PayloadSetPluginResolver().register(plugin, { config: { schema: EthereumGasBlocknativeWitness.defaultConfigSchema } })
|
|
16
|
+
expect(await resolver.resolve(plugin.set)).toBeObject()
|
|
17
|
+
expect(await resolver.witness(plugin.set)).toBeObject()
|
|
18
|
+
})
|
|
19
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import { EthereumGasBlocknativeSchema } from '@xyo-network/blocknative-ethereum-gas-payload-plugin'
|
|
4
|
+
import { PayloadWrapper } from '@xyo-network/payload-wrapper'
|
|
5
|
+
import {
|
|
6
|
+
describe, expect,
|
|
7
|
+
it,
|
|
8
|
+
} from 'vitest'
|
|
9
|
+
|
|
10
|
+
import { EthereumGasBlocknativeWitnessConfigSchema } from '../Schema.ts'
|
|
11
|
+
import { EthereumGasBlocknativeWitness } from '../Witness.ts'
|
|
12
|
+
|
|
13
|
+
describe('EthereumGasBlocknativeWitness', () => {
|
|
14
|
+
it('returns observation', async () => {
|
|
15
|
+
const sut = await EthereumGasBlocknativeWitness.create({
|
|
16
|
+
account: 'random',
|
|
17
|
+
config: { schema: EthereumGasBlocknativeWitnessConfigSchema },
|
|
18
|
+
})
|
|
19
|
+
const [actual] = await sut.observe()
|
|
20
|
+
expect(actual.schema).toBe(EthereumGasBlocknativeSchema)
|
|
21
|
+
const answerWrapper = PayloadWrapper.wrap(actual)
|
|
22
|
+
expect(await answerWrapper.getValid()).toBe(true)
|
|
23
|
+
})
|
|
24
|
+
})
|
package/typedoc.json
DELETED