@xyo-network/gas-price-plugin 2.47.9 → 2.48.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/dist/docs.json +770 -710
- package/package.json +14 -14
- package/src/lib/identities/spec/isXyoEthereumGasBlocknativePayload.spec.ts +0 -29
- package/src/lib/identities/spec/isXyoEthereumGasEtherchainV2Payload.spec.ts +0 -29
- package/src/lib/identities/spec/isXyoEthereumGasEthersPayload.spec.ts +0 -29
- package/src/lib/identities/spec/isXyoEthereumGasEtherscanPayload.spec.ts +0 -29
- package/src/lib/identities/spec/isXyoEthereumGasEthgasstationPayload.spec.ts +0 -29
- package/src/lib/spec/average.spec.ts +0 -51
- package/src/lib/spec/divineGas.spec.ts +0 -55
- package/src/lib/transforms/spec/transformGasFromBlocknative.spec.ts +0 -39
- package/src/lib/transforms/spec/transformGasFromEtherchainV2.spec.ts +0 -34
- package/src/lib/transforms/spec/transformGasFromEthers.spec.ts +0 -33
- package/src/lib/transforms/spec/transformGasFromEtherscan.spec.ts +0 -34
- package/src/lib/transforms/spec/transformGasFromEthgasstation.spec.ts +0 -39
- package/src/spec/Diviner.spec.ts +0 -106
- package/src/spec/Plugin.spec.ts +0 -11
package/package.json
CHANGED
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/exists": "^2.7.
|
|
14
|
-
"@xyo-network/blocknative-ethereum-gas-payload-plugin": "^2.
|
|
15
|
-
"@xyo-network/diviner": "^2.
|
|
16
|
-
"@xyo-network/etherchain-gas-ethereum-blockchain-payload-plugins": "^2.
|
|
17
|
-
"@xyo-network/ethers-ethereum-gas-payload-plugin": "^2.
|
|
18
|
-
"@xyo-network/etherscan-ethereum-gas-payload-plugin": "^2.
|
|
19
|
-
"@xyo-network/ethgasstation-ethereum-gas-payload-plugin": "^2.
|
|
20
|
-
"@xyo-network/gas-price-payload-plugin": "^2.
|
|
21
|
-
"@xyo-network/module": "^2.
|
|
22
|
-
"@xyo-network/payload-builder": "^2.
|
|
23
|
-
"@xyo-network/payload-model": "^2.
|
|
24
|
-
"@xyo-network/payloadset-plugin": "^2.
|
|
25
|
-
"@xyo-network/promise": "^2.
|
|
13
|
+
"@xylabs/exists": "^2.7.4",
|
|
14
|
+
"@xyo-network/blocknative-ethereum-gas-payload-plugin": "^2.48.0",
|
|
15
|
+
"@xyo-network/diviner": "^2.48.0",
|
|
16
|
+
"@xyo-network/etherchain-gas-ethereum-blockchain-payload-plugins": "^2.48.0",
|
|
17
|
+
"@xyo-network/ethers-ethereum-gas-payload-plugin": "^2.48.0",
|
|
18
|
+
"@xyo-network/etherscan-ethereum-gas-payload-plugin": "^2.48.0",
|
|
19
|
+
"@xyo-network/ethgasstation-ethereum-gas-payload-plugin": "^2.48.0",
|
|
20
|
+
"@xyo-network/gas-price-payload-plugin": "^2.48.0",
|
|
21
|
+
"@xyo-network/module": "^2.48.0",
|
|
22
|
+
"@xyo-network/payload-builder": "^2.48.0",
|
|
23
|
+
"@xyo-network/payload-model": "^2.48.0",
|
|
24
|
+
"@xyo-network/payloadset-plugin": "^2.48.0",
|
|
25
|
+
"@xyo-network/promise": "^2.48.0",
|
|
26
26
|
"regression": "^2.0.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
},
|
|
83
83
|
"sideEffects": false,
|
|
84
84
|
"types": "dist/types/index.d.ts",
|
|
85
|
-
"version": "2.
|
|
85
|
+
"version": "2.48.0"
|
|
86
86
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { sampleBlocknativeGas } from '../../../test'
|
|
2
|
-
import { isXyoEthereumGasBlocknativePayload } from '../isXyoEthereumGasBlocknativePayload'
|
|
3
|
-
|
|
4
|
-
describe('isXyoEthereumGasBlocknativePayload', () => {
|
|
5
|
-
describe('returns true', () => {
|
|
6
|
-
it('when payload schema is XyoEthereumGasBlocknativeSchema', () => {
|
|
7
|
-
const result = isXyoEthereumGasBlocknativePayload(sampleBlocknativeGas)
|
|
8
|
-
expect(result).toBeTrue()
|
|
9
|
-
})
|
|
10
|
-
})
|
|
11
|
-
describe('returns false', () => {
|
|
12
|
-
it('when payload schema is not XyoEthereumGasBlocknativeSchema', () => {
|
|
13
|
-
const result = isXyoEthereumGasBlocknativePayload({ schema: 'network.xyo.debug' })
|
|
14
|
-
expect(result).toBeFalse()
|
|
15
|
-
})
|
|
16
|
-
it('when payload is missing', () => {
|
|
17
|
-
const result = isXyoEthereumGasBlocknativePayload()
|
|
18
|
-
expect(result).toBeFalse()
|
|
19
|
-
})
|
|
20
|
-
it('when payload is undefined', () => {
|
|
21
|
-
const result = isXyoEthereumGasBlocknativePayload(undefined)
|
|
22
|
-
expect(result).toBeFalse()
|
|
23
|
-
})
|
|
24
|
-
it('when payload is null', () => {
|
|
25
|
-
const result = isXyoEthereumGasBlocknativePayload(null)
|
|
26
|
-
expect(result).toBeFalse()
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
})
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { sampleEtherchainGasV2 } from '../../../test'
|
|
2
|
-
import { isXyoEthereumGasEtherchainV2Payload } from '../isXyoEthereumGasEtherchainV2Payload'
|
|
3
|
-
|
|
4
|
-
describe('isXyoEthereumGasEtherchainV2Payload', () => {
|
|
5
|
-
describe('returns true', () => {
|
|
6
|
-
it('when payload schema is XyoEthereumGasEtherchainV2Schema', () => {
|
|
7
|
-
const result = isXyoEthereumGasEtherchainV2Payload(sampleEtherchainGasV2)
|
|
8
|
-
expect(result).toBeTrue()
|
|
9
|
-
})
|
|
10
|
-
})
|
|
11
|
-
describe('returns false', () => {
|
|
12
|
-
it('when payload schema is not XyoEthereumGasEtherscanSchema', () => {
|
|
13
|
-
const result = isXyoEthereumGasEtherchainV2Payload({ schema: 'network.xyo.debug' })
|
|
14
|
-
expect(result).toBeFalse()
|
|
15
|
-
})
|
|
16
|
-
it('when payload is missing', () => {
|
|
17
|
-
const result = isXyoEthereumGasEtherchainV2Payload()
|
|
18
|
-
expect(result).toBeFalse()
|
|
19
|
-
})
|
|
20
|
-
it('when payload is undefined', () => {
|
|
21
|
-
const result = isXyoEthereumGasEtherchainV2Payload(undefined)
|
|
22
|
-
expect(result).toBeFalse()
|
|
23
|
-
})
|
|
24
|
-
it('when payload is null', () => {
|
|
25
|
-
const result = isXyoEthereumGasEtherchainV2Payload(null)
|
|
26
|
-
expect(result).toBeFalse()
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
})
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { sampleEthersGas } from '../../../test'
|
|
2
|
-
import { isXyoEthereumGasEthersPayload } from '../isXyoEthereumGasEthersPayload'
|
|
3
|
-
|
|
4
|
-
describe('isXyoEthereumGasEthersPayload', () => {
|
|
5
|
-
describe('returns true', () => {
|
|
6
|
-
it('when payload schema is XyoEthereumGasEthersSchema', () => {
|
|
7
|
-
const result = isXyoEthereumGasEthersPayload(sampleEthersGas)
|
|
8
|
-
expect(result).toBeTrue()
|
|
9
|
-
})
|
|
10
|
-
})
|
|
11
|
-
describe('returns false', () => {
|
|
12
|
-
it('when payload schema is not XyoEthereumGasEthersSchema', () => {
|
|
13
|
-
const result = isXyoEthereumGasEthersPayload({ schema: 'network.xyo.debug' })
|
|
14
|
-
expect(result).toBeFalse()
|
|
15
|
-
})
|
|
16
|
-
it('when payload is missing', () => {
|
|
17
|
-
const result = isXyoEthereumGasEthersPayload()
|
|
18
|
-
expect(result).toBeFalse()
|
|
19
|
-
})
|
|
20
|
-
it('when payload is undefined', () => {
|
|
21
|
-
const result = isXyoEthereumGasEthersPayload(undefined)
|
|
22
|
-
expect(result).toBeFalse()
|
|
23
|
-
})
|
|
24
|
-
it('when payload is null', () => {
|
|
25
|
-
const result = isXyoEthereumGasEthersPayload(null)
|
|
26
|
-
expect(result).toBeFalse()
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
})
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { sampleEtherscanGas } from '../../../test'
|
|
2
|
-
import { isXyoEthereumGasEtherscanPayload } from '../isXyoEthereumGasEtherscanPayload'
|
|
3
|
-
|
|
4
|
-
describe('isXyoEthereumGasEtherscanPayload', () => {
|
|
5
|
-
describe('returns true', () => {
|
|
6
|
-
it('when payload schema is XyoEthereumGasEtherscanSchema', () => {
|
|
7
|
-
const result = isXyoEthereumGasEtherscanPayload(sampleEtherscanGas)
|
|
8
|
-
expect(result).toBeTrue()
|
|
9
|
-
})
|
|
10
|
-
})
|
|
11
|
-
describe('returns false', () => {
|
|
12
|
-
it('when payload schema is not XyoEthereumGasEtherscanSchema', () => {
|
|
13
|
-
const result = isXyoEthereumGasEtherscanPayload({ schema: 'network.xyo.debug' })
|
|
14
|
-
expect(result).toBeFalse()
|
|
15
|
-
})
|
|
16
|
-
it('when payload is missing', () => {
|
|
17
|
-
const result = isXyoEthereumGasEtherscanPayload()
|
|
18
|
-
expect(result).toBeFalse()
|
|
19
|
-
})
|
|
20
|
-
it('when payload is undefined', () => {
|
|
21
|
-
const result = isXyoEthereumGasEtherscanPayload(undefined)
|
|
22
|
-
expect(result).toBeFalse()
|
|
23
|
-
})
|
|
24
|
-
it('when payload is null', () => {
|
|
25
|
-
const result = isXyoEthereumGasEtherscanPayload(null)
|
|
26
|
-
expect(result).toBeFalse()
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
})
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { sampleEthgasstationGas } from '../../../test'
|
|
2
|
-
import { isXyoEthereumGasEthgasstationPayload } from '../isXyoEthereumGasEthgasstationPayload'
|
|
3
|
-
|
|
4
|
-
describe('isXyoEthereumGasEthgasstationPayload', () => {
|
|
5
|
-
describe('returns true', () => {
|
|
6
|
-
it('when payload schema is XyoEthereumGasEthgasstationSchema', () => {
|
|
7
|
-
const result = isXyoEthereumGasEthgasstationPayload(sampleEthgasstationGas)
|
|
8
|
-
expect(result).toBeTrue()
|
|
9
|
-
})
|
|
10
|
-
})
|
|
11
|
-
describe('returns false', () => {
|
|
12
|
-
it('when payload schema is not XyoEthereumGasEthgasstationSchema', () => {
|
|
13
|
-
const result = isXyoEthereumGasEthgasstationPayload({ schema: 'network.xyo.debug' })
|
|
14
|
-
expect(result).toBeFalse()
|
|
15
|
-
})
|
|
16
|
-
it('when payload is missing', () => {
|
|
17
|
-
const result = isXyoEthereumGasEthgasstationPayload()
|
|
18
|
-
expect(result).toBeFalse()
|
|
19
|
-
})
|
|
20
|
-
it('when payload is undefined', () => {
|
|
21
|
-
const result = isXyoEthereumGasEthgasstationPayload(undefined)
|
|
22
|
-
expect(result).toBeFalse()
|
|
23
|
-
})
|
|
24
|
-
it('when payload is null', () => {
|
|
25
|
-
const result = isXyoEthereumGasEthgasstationPayload(null)
|
|
26
|
-
expect(result).toBeFalse()
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
})
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@xyo-network/gas-price-payload-plugin'
|
|
2
|
-
|
|
3
|
-
import { sampleBlocknativeGas, sampleEtherchainGasV2, sampleEtherscanGas, sampleEthgasstationGas } from '../../test'
|
|
4
|
-
import { average } from '../average'
|
|
5
|
-
import { transformGasFromBlocknative, transformGasFromEtherchainV2, transformGasFromEtherscan, transformGasFromEthgasstation } from '../transforms'
|
|
6
|
-
|
|
7
|
-
const results: FeeData[] = [
|
|
8
|
-
transformGasFromBlocknative(sampleBlocknativeGas),
|
|
9
|
-
transformGasFromEtherchainV2(sampleEtherchainGasV2),
|
|
10
|
-
transformGasFromEtherscan(sampleEtherscanGas),
|
|
11
|
-
transformGasFromEthgasstation(sampleEthgasstationGas),
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
describe('average', () => {
|
|
15
|
-
it('averages payloads', () => {
|
|
16
|
-
const payloads = results
|
|
17
|
-
const result = average(payloads)
|
|
18
|
-
expect(result).toBeObject()
|
|
19
|
-
expect(result.baseFee).toBeNumber()
|
|
20
|
-
expect(result.feePerGas).toBeObject()
|
|
21
|
-
expect(result.feePerGas.low).toBeNumber()
|
|
22
|
-
expect(result.feePerGas.medium).toBeNumber()
|
|
23
|
-
expect(result.feePerGas.high).toBeNumber()
|
|
24
|
-
expect(result.feePerGas.veryHigh).toBeNumber()
|
|
25
|
-
expect(result.priorityFeePerGas).toBeObject()
|
|
26
|
-
expect(result.priorityFeePerGas.low).toBeNumber()
|
|
27
|
-
expect(result.priorityFeePerGas.medium).toBeNumber()
|
|
28
|
-
expect(result.priorityFeePerGas.high).toBeNumber()
|
|
29
|
-
expect(result.priorityFeePerGas.veryHigh).toBeNumber()
|
|
30
|
-
})
|
|
31
|
-
it('handles single payload', () => {
|
|
32
|
-
const payloads = [results[0]]
|
|
33
|
-
const result = average(payloads)
|
|
34
|
-
expect(result).toBeObject()
|
|
35
|
-
})
|
|
36
|
-
it('handles no values', () => {
|
|
37
|
-
const result = average()
|
|
38
|
-
expect(result).toBeObject()
|
|
39
|
-
expect(result.baseFee).toBeUndefined()
|
|
40
|
-
expect(result.feePerGas).toBeObject()
|
|
41
|
-
expect(result.feePerGas.low).toBeUndefined()
|
|
42
|
-
expect(result.feePerGas.medium).toBeUndefined()
|
|
43
|
-
expect(result.feePerGas.high).toBeUndefined()
|
|
44
|
-
expect(result.feePerGas.veryHigh).toBeUndefined()
|
|
45
|
-
expect(result.priorityFeePerGas).toBeObject()
|
|
46
|
-
expect(result.priorityFeePerGas.low).toBeUndefined()
|
|
47
|
-
expect(result.priorityFeePerGas.medium).toBeUndefined()
|
|
48
|
-
expect(result.priorityFeePerGas.high).toBeUndefined()
|
|
49
|
-
expect(result.priorityFeePerGas.veryHigh).toBeUndefined()
|
|
50
|
-
})
|
|
51
|
-
})
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { sampleBlocknativeGas, sampleEtherchainGasV2, sampleEtherscanGas, sampleEthersGas, sampleEthgasstationGas } from '../../test'
|
|
2
|
-
import { divineGas } from '../divineGas'
|
|
3
|
-
|
|
4
|
-
describe('divineGas', () => {
|
|
5
|
-
describe('with no payloads supplied', () => {
|
|
6
|
-
it('divines gas', () => {
|
|
7
|
-
const result = divineGas([])
|
|
8
|
-
expect(result).toBeObject()
|
|
9
|
-
expect(result.timestamp).toBeNumber()
|
|
10
|
-
})
|
|
11
|
-
})
|
|
12
|
-
describe('with sparse payloads supplied', () => {
|
|
13
|
-
it.each([[sampleEtherscanGas], [sampleEtherchainGasV2], [sampleEtherchainGasV2, sampleEtherscanGas]])('divines gas', (...payloads) => {
|
|
14
|
-
const result = divineGas(payloads)
|
|
15
|
-
expect(result).toBeObject()
|
|
16
|
-
expect(result.timestamp).toBeNumber()
|
|
17
|
-
})
|
|
18
|
-
})
|
|
19
|
-
describe('with one of each supported payload supplied', () => {
|
|
20
|
-
it('divines gas', () => {
|
|
21
|
-
const result = divineGas([sampleBlocknativeGas, sampleEtherchainGasV2, sampleEtherscanGas, sampleEthersGas, sampleEthgasstationGas])
|
|
22
|
-
expect(result).toBeObject()
|
|
23
|
-
expect(result.baseFee).toBeNumber()
|
|
24
|
-
expect(result.feePerGas).toBeObject()
|
|
25
|
-
expect(result.feePerGas.low).toBeNumber()
|
|
26
|
-
expect(result.feePerGas.medium).toBeNumber()
|
|
27
|
-
expect(result.feePerGas.high).toBeNumber()
|
|
28
|
-
expect(result.feePerGas.veryHigh).toBeNumber()
|
|
29
|
-
expect(result.priorityFeePerGas).toBeObject()
|
|
30
|
-
expect(result.priorityFeePerGas.low).toBeNumber()
|
|
31
|
-
expect(result.priorityFeePerGas.medium).toBeNumber()
|
|
32
|
-
expect(result.priorityFeePerGas.high).toBeNumber()
|
|
33
|
-
expect(result.priorityFeePerGas.veryHigh).toBeNumber()
|
|
34
|
-
expect(result.timestamp).toBeNumber()
|
|
35
|
-
})
|
|
36
|
-
})
|
|
37
|
-
describe('with multiple of each supported payload supplied', () => {
|
|
38
|
-
it('divines gas', () => {
|
|
39
|
-
const result = divineGas([
|
|
40
|
-
sampleBlocknativeGas,
|
|
41
|
-
sampleBlocknativeGas,
|
|
42
|
-
sampleEtherchainGasV2,
|
|
43
|
-
sampleEtherchainGasV2,
|
|
44
|
-
sampleEtherscanGas,
|
|
45
|
-
sampleEtherscanGas,
|
|
46
|
-
sampleEthersGas,
|
|
47
|
-
sampleEthersGas,
|
|
48
|
-
sampleEthgasstationGas,
|
|
49
|
-
sampleEthgasstationGas,
|
|
50
|
-
])
|
|
51
|
-
expect(result).toBeObject()
|
|
52
|
-
expect(result.timestamp).toBeNumber()
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
})
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
2
|
-
import { sampleBlocknativeGas } from '../../../test'
|
|
3
|
-
import { transformGasFromBlocknative } from '../transformGasFromBlocknative'
|
|
4
|
-
|
|
5
|
-
describe('transformGasFromEtherscan', () => {
|
|
6
|
-
it('returns values in the expected format', () => {
|
|
7
|
-
const result = transformGasFromBlocknative(sampleBlocknativeGas)
|
|
8
|
-
expect(result).toBeObject()
|
|
9
|
-
expect(result.baseFee).toBeNumber()
|
|
10
|
-
expect(result.feePerGas).toBeObject()
|
|
11
|
-
expect(result.feePerGas.low).toBeNumber()
|
|
12
|
-
expect(result.feePerGas.medium).toBeNumber()
|
|
13
|
-
expect(result.feePerGas.high).toBeNumber()
|
|
14
|
-
expect(result.feePerGas.veryHigh).toBeNumber()
|
|
15
|
-
expect(result.priorityFeePerGas).toBeObject()
|
|
16
|
-
expect(result.priorityFeePerGas.low).toBeNumber()
|
|
17
|
-
expect(result.priorityFeePerGas.medium).toBeNumber()
|
|
18
|
-
expect(result.priorityFeePerGas.high).toBeNumber()
|
|
19
|
-
expect(result.priorityFeePerGas.veryHigh).toBeNumber()
|
|
20
|
-
})
|
|
21
|
-
it('matches expected output', () => {
|
|
22
|
-
const result = transformGasFromBlocknative(sampleBlocknativeGas)
|
|
23
|
-
expect(result).toMatchObject({
|
|
24
|
-
baseFee: 13.691764456,
|
|
25
|
-
feePerGas: {
|
|
26
|
-
low: 12.95,
|
|
27
|
-
medium: 13.25,
|
|
28
|
-
high: 13.55,
|
|
29
|
-
veryHigh: 13.85,
|
|
30
|
-
},
|
|
31
|
-
priorityFeePerGas: {
|
|
32
|
-
low: 0.14,
|
|
33
|
-
medium: 0.37,
|
|
34
|
-
high: 0.6,
|
|
35
|
-
veryHigh: 0.83,
|
|
36
|
-
},
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
})
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
2
|
-
import { sampleEtherchainGasV2 } from '../../../test'
|
|
3
|
-
import { transformGasFromEtherchainV2 } from '../transformGasFromEtherchainV2'
|
|
4
|
-
|
|
5
|
-
describe('transformGasFromEtherchainV2', () => {
|
|
6
|
-
it('returns values in the expected format', () => {
|
|
7
|
-
const result = transformGasFromEtherchainV2(sampleEtherchainGasV2)
|
|
8
|
-
expect(result).toBeObject()
|
|
9
|
-
expect(result.baseFee).toBeUndefined()
|
|
10
|
-
expect(result.feePerGas).toBeObject()
|
|
11
|
-
expect(result.feePerGas.low).toBeNumber()
|
|
12
|
-
expect(result.feePerGas.medium).toBeNumber()
|
|
13
|
-
expect(result.feePerGas.high).toBeNumber()
|
|
14
|
-
expect(result.feePerGas.veryHigh).toBeNumber()
|
|
15
|
-
expect(result.priorityFeePerGas).toBeObject()
|
|
16
|
-
expect(result.priorityFeePerGas.low).toBeUndefined()
|
|
17
|
-
expect(result.priorityFeePerGas.medium).toBeUndefined()
|
|
18
|
-
expect(result.priorityFeePerGas.high).toBeUndefined()
|
|
19
|
-
expect(result.priorityFeePerGas.veryHigh).toBeUndefined()
|
|
20
|
-
})
|
|
21
|
-
it('matches expected output', () => {
|
|
22
|
-
const result = transformGasFromEtherchainV2(sampleEtherchainGasV2)
|
|
23
|
-
expect(result).toMatchObject({
|
|
24
|
-
baseFee: undefined,
|
|
25
|
-
feePerGas: {
|
|
26
|
-
low: 11.2,
|
|
27
|
-
medium: 12.0,
|
|
28
|
-
high: 19.80304733,
|
|
29
|
-
veryHigh: 29.71428617,
|
|
30
|
-
},
|
|
31
|
-
priorityFeePerGas: {},
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
})
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
2
|
-
import { sampleEthersGas } from '../../../test'
|
|
3
|
-
import { transformGasFromEthers } from '../transformGasFromEthers'
|
|
4
|
-
|
|
5
|
-
describe('transformGasFromEthers', () => {
|
|
6
|
-
it('returns values in the expected format', () => {
|
|
7
|
-
const result = transformGasFromEthers(sampleEthersGas)
|
|
8
|
-
expect(result).toBeObject()
|
|
9
|
-
expect(result.baseFee).toBeNumber()
|
|
10
|
-
expect(result.feePerGas).toBeObject()
|
|
11
|
-
expect(result.feePerGas.low).toBeUndefined()
|
|
12
|
-
expect(result.feePerGas.medium).toBeUndefined()
|
|
13
|
-
expect(result.feePerGas.high).toBeNumber()
|
|
14
|
-
expect(result.feePerGas.veryHigh).toBeUndefined()
|
|
15
|
-
expect(result.priorityFeePerGas).toBeObject()
|
|
16
|
-
expect(result.priorityFeePerGas.low).toBeUndefined()
|
|
17
|
-
expect(result.priorityFeePerGas.medium).toBeUndefined()
|
|
18
|
-
expect(result.priorityFeePerGas.high).toBeNumber()
|
|
19
|
-
expect(result.priorityFeePerGas.veryHigh).toBeUndefined()
|
|
20
|
-
})
|
|
21
|
-
it('matches expected output', () => {
|
|
22
|
-
const result = transformGasFromEthers(sampleEthersGas)
|
|
23
|
-
expect(result).toMatchObject({
|
|
24
|
-
baseFee: 13.447862081,
|
|
25
|
-
feePerGas: {
|
|
26
|
-
high: 28.395724162,
|
|
27
|
-
},
|
|
28
|
-
priorityFeePerGas: {
|
|
29
|
-
high: 1.5,
|
|
30
|
-
},
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
})
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
2
|
-
import { sampleEtherscanGas } from '../../../test'
|
|
3
|
-
import { transformGasFromEtherscan } from '../transformGasFromEtherscan'
|
|
4
|
-
|
|
5
|
-
describe('transformGasFromEtherscan', () => {
|
|
6
|
-
it('returns values in the expected format', () => {
|
|
7
|
-
const result = transformGasFromEtherscan(sampleEtherscanGas)
|
|
8
|
-
expect(result).toBeObject()
|
|
9
|
-
expect(result.baseFee).toBeNumber()
|
|
10
|
-
expect(result.feePerGas).toBeObject()
|
|
11
|
-
expect(result.feePerGas.low).toBeNumber()
|
|
12
|
-
expect(result.feePerGas.medium).toBeNumber()
|
|
13
|
-
expect(result.feePerGas.high).toBeNumber()
|
|
14
|
-
expect(result.feePerGas.veryHigh).toBeNumber()
|
|
15
|
-
expect(result.priorityFeePerGas).toBeObject()
|
|
16
|
-
expect(result.priorityFeePerGas.low).toBeUndefined()
|
|
17
|
-
expect(result.priorityFeePerGas.medium).toBeUndefined()
|
|
18
|
-
expect(result.priorityFeePerGas.high).toBeUndefined()
|
|
19
|
-
expect(result.priorityFeePerGas.veryHigh).toBeUndefined()
|
|
20
|
-
})
|
|
21
|
-
it('matches expected output', () => {
|
|
22
|
-
const result = transformGasFromEtherscan(sampleEtherscanGas)
|
|
23
|
-
expect(result).toMatchObject({
|
|
24
|
-
baseFee: 27.616709247,
|
|
25
|
-
feePerGas: {
|
|
26
|
-
low: 28,
|
|
27
|
-
medium: 29,
|
|
28
|
-
high: 30,
|
|
29
|
-
veryHigh: 31,
|
|
30
|
-
},
|
|
31
|
-
priorityFeePerGas: {},
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
})
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
2
|
-
import { sampleEthgasstationGas } from '../../../test'
|
|
3
|
-
import { transformGasFromEthgasstation } from '../transformGasFromEthgasstation'
|
|
4
|
-
|
|
5
|
-
describe('transformGasFromEthgasstation', () => {
|
|
6
|
-
it('returns values in the expected format', () => {
|
|
7
|
-
const result = transformGasFromEthgasstation(sampleEthgasstationGas)
|
|
8
|
-
expect(result).toBeObject()
|
|
9
|
-
expect(result.baseFee).toBeNumber()
|
|
10
|
-
expect(result.feePerGas).toBeObject()
|
|
11
|
-
expect(result.feePerGas.low).toBeNumber()
|
|
12
|
-
expect(result.feePerGas.medium).toBeNumber()
|
|
13
|
-
expect(result.feePerGas.high).toBeNumber()
|
|
14
|
-
expect(result.feePerGas.veryHigh).toBeNumber()
|
|
15
|
-
expect(result.priorityFeePerGas).toBeObject()
|
|
16
|
-
expect(result.priorityFeePerGas.low).toBeNumber()
|
|
17
|
-
expect(result.priorityFeePerGas.medium).toBeNumber()
|
|
18
|
-
expect(result.priorityFeePerGas.high).toBeNumber()
|
|
19
|
-
expect(result.priorityFeePerGas.veryHigh).toBeNumber()
|
|
20
|
-
})
|
|
21
|
-
it('matches expected output', () => {
|
|
22
|
-
const result = transformGasFromEthgasstation(sampleEthgasstationGas)
|
|
23
|
-
expect(result).toMatchObject({
|
|
24
|
-
baseFee: 10,
|
|
25
|
-
feePerGas: {
|
|
26
|
-
low: 11.33,
|
|
27
|
-
medium: 12,
|
|
28
|
-
high: 12,
|
|
29
|
-
veryHigh: 13,
|
|
30
|
-
},
|
|
31
|
-
priorityFeePerGas: {
|
|
32
|
-
low: 2,
|
|
33
|
-
medium: 2,
|
|
34
|
-
high: 2,
|
|
35
|
-
veryHigh: 2,
|
|
36
|
-
},
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
})
|
package/src/spec/Diviner.spec.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { InfuraProvider } from '@ethersproject/providers'
|
|
2
|
-
import { XyoEthereumGasBlocknativeWitness, XyoEthereumGasBlocknativeWitnessConfigSchema } from '@xyo-network/blocknative-ethereum-gas-plugin'
|
|
3
|
-
import { DivinerWrapper } from '@xyo-network/diviner-wrapper'
|
|
4
|
-
import {
|
|
5
|
-
XyoEtherchainEthereumGasWitnessV2,
|
|
6
|
-
XyoEthereumGasEtherchainV2WitnessConfigSchema,
|
|
7
|
-
} from '@xyo-network/etherchain-gas-ethereum-blockchain-plugins'
|
|
8
|
-
import { XyoEthereumGasEthersWitness, XyoEthereumGasEthersWitnessConfigSchema } from '@xyo-network/ethers-ethereum-gas-plugin'
|
|
9
|
-
import { XyoEthereumGasEtherscanWitness, XyoEthereumGasEtherscanWitnessConfigSchema } from '@xyo-network/etherscan-ethereum-gas-plugin'
|
|
10
|
-
import { XyoEthereumGasEthgasstationWitness, XyoEthereumGasEthgasstationWitnessConfigSchema } from '@xyo-network/ethgasstation-ethereum-gas-plugin'
|
|
11
|
-
import { XyoEthereumGasPayload, XyoEthereumGasSchema } from '@xyo-network/gas-price-payload-plugin'
|
|
12
|
-
import { XyoPayload } from '@xyo-network/payload-model'
|
|
13
|
-
|
|
14
|
-
import { XyoEthereumGasDiviner } from '../Diviner'
|
|
15
|
-
import { sampleBlocknativeGas, sampleEtherchainGasV2, sampleEtherscanGas, sampleEthersGas, sampleEthgasstationGas } from '../test'
|
|
16
|
-
|
|
17
|
-
describe('Diviner', () => {
|
|
18
|
-
test('returns divined gas price', async () => {
|
|
19
|
-
const module = await XyoEthereumGasDiviner.create()
|
|
20
|
-
const wrapper = new DivinerWrapper(module)
|
|
21
|
-
|
|
22
|
-
const payloads = await wrapper.divine([sampleBlocknativeGas, sampleEtherchainGasV2, sampleEtherscanGas, sampleEthersGas, sampleEthgasstationGas])
|
|
23
|
-
|
|
24
|
-
expect(payloads).toBeArray()
|
|
25
|
-
expect(payloads.length).toBe(1)
|
|
26
|
-
payloads.map((payload) => {
|
|
27
|
-
if (payload?.schema === XyoEthereumGasSchema) {
|
|
28
|
-
const gasPayload = payload as XyoEthereumGasPayload
|
|
29
|
-
expect(gasPayload).toBeObject()
|
|
30
|
-
expect(gasPayload.schema).toBe(XyoEthereumGasSchema)
|
|
31
|
-
expect(gasPayload.timestamp).toBeNumber()
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
})
|
|
35
|
-
test.skip('diviner calibration', async () => {
|
|
36
|
-
// NOTE: This test is for obtaining concurrent witnessed
|
|
37
|
-
// results for diviner weighting/calibration
|
|
38
|
-
const blocknativeGas = (
|
|
39
|
-
await (
|
|
40
|
-
await XyoEthereumGasBlocknativeWitness.create({
|
|
41
|
-
config: {
|
|
42
|
-
schema: XyoEthereumGasBlocknativeWitnessConfigSchema,
|
|
43
|
-
},
|
|
44
|
-
})
|
|
45
|
-
).observe()
|
|
46
|
-
)?.[0]
|
|
47
|
-
const etherchainGasV2 = (
|
|
48
|
-
await (
|
|
49
|
-
await XyoEtherchainEthereumGasWitnessV2.create({
|
|
50
|
-
config: {
|
|
51
|
-
schema: XyoEthereumGasEtherchainV2WitnessConfigSchema,
|
|
52
|
-
},
|
|
53
|
-
})
|
|
54
|
-
).observe()
|
|
55
|
-
)?.[0]
|
|
56
|
-
const etherscanGas = (
|
|
57
|
-
await (
|
|
58
|
-
await XyoEthereumGasEtherscanWitness.create({
|
|
59
|
-
config: {
|
|
60
|
-
apiKey: process.env.ETHERSCAN_API_KEY || '',
|
|
61
|
-
schema: XyoEthereumGasEtherscanWitnessConfigSchema,
|
|
62
|
-
},
|
|
63
|
-
})
|
|
64
|
-
).observe()
|
|
65
|
-
)?.[0]
|
|
66
|
-
const ethersGas = (
|
|
67
|
-
await (
|
|
68
|
-
await XyoEthereumGasEthersWitness.create({
|
|
69
|
-
config: {
|
|
70
|
-
schema: XyoEthereumGasEthersWitnessConfigSchema,
|
|
71
|
-
},
|
|
72
|
-
provider: new InfuraProvider('homestead', {
|
|
73
|
-
projectId: process.env.INFURA_PROJECT_ID,
|
|
74
|
-
projectSecret: process.env.INFURA_PROJECT_SECRET,
|
|
75
|
-
}),
|
|
76
|
-
})
|
|
77
|
-
).observe()
|
|
78
|
-
)?.[0]
|
|
79
|
-
const ethgasstationGas = (
|
|
80
|
-
await (
|
|
81
|
-
await XyoEthereumGasEthgasstationWitness.create({
|
|
82
|
-
config: {
|
|
83
|
-
schema: XyoEthereumGasEthgasstationWitnessConfigSchema,
|
|
84
|
-
},
|
|
85
|
-
})
|
|
86
|
-
).observe()
|
|
87
|
-
)?.[0]
|
|
88
|
-
const observations: XyoPayload[] = [blocknativeGas, etherchainGasV2, etherscanGas, ethersGas, ethgasstationGas]
|
|
89
|
-
|
|
90
|
-
const module = await XyoEthereumGasDiviner.create()
|
|
91
|
-
const wrapper = new DivinerWrapper(module)
|
|
92
|
-
|
|
93
|
-
const payloads = await wrapper.divine(observations)
|
|
94
|
-
|
|
95
|
-
expect(payloads).toBeArray()
|
|
96
|
-
expect(payloads.length).toBe(1)
|
|
97
|
-
payloads.map((payload) => {
|
|
98
|
-
if (payload?.schema === XyoEthereumGasSchema) {
|
|
99
|
-
const gasPayload = payload as XyoEthereumGasPayload
|
|
100
|
-
expect(gasPayload).toBeObject()
|
|
101
|
-
expect(gasPayload.schema).toBe(XyoEthereumGasSchema)
|
|
102
|
-
expect(gasPayload.timestamp).toBeNumber()
|
|
103
|
-
}
|
|
104
|
-
})
|
|
105
|
-
})
|
|
106
|
-
})
|
package/src/spec/Plugin.spec.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { PayloadSetPluginResolver } from '@xyo-network/payloadset-plugin'
|
|
2
|
-
|
|
3
|
-
import { XyoEthereumGasPlugin } from '../Plugin'
|
|
4
|
-
|
|
5
|
-
describe('XyoCryptoMarketCoinGeckoPlugin', () => {
|
|
6
|
-
test('Add to Resolver', () => {
|
|
7
|
-
const plugin = XyoEthereumGasPlugin()
|
|
8
|
-
const resolver = new PayloadSetPluginResolver().register(plugin)
|
|
9
|
-
expect(resolver.resolve(plugin.set)).toBeDefined()
|
|
10
|
-
})
|
|
11
|
-
})
|