@xyo-network/etherscan-ethereum-gas-plugin 4.1.1 → 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/dist/neutral/index.d.ts +5 -24
- package/package.json +18 -15
- package/src/lib/spec/getGasFromEtherscan.spec.ts +26 -0
- package/src/spec/Plugin.spec.ts +21 -0
- package/src/spec/Witness.spec.ts +45 -0
- package/typedoc.json +0 -5
- package/xy.config.ts +0 -10
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
type EthereumGasEtherscanWitnessConfigSchema = 'network.xyo.blockchain.ethereum.gas.etherscan.witness.config';
|
|
8
|
-
declare const EthereumGasEtherscanWitnessConfigSchema: EthereumGasEtherscanWitnessConfigSchema;
|
|
9
|
-
|
|
10
|
-
type EthereumGasEtherscanWitnessConfig = WitnessConfig<{
|
|
11
|
-
apiKey: string;
|
|
12
|
-
schema: EthereumGasEtherscanWitnessConfigSchema;
|
|
13
|
-
}>;
|
|
14
|
-
|
|
15
|
-
declare class EthereumGasEtherscanWitness extends AbstractWitness<WitnessParams<AnyConfigSchema<EthereumGasEtherscanWitnessConfig>>> {
|
|
16
|
-
static readonly configSchemas: Schema[];
|
|
17
|
-
static readonly defaultConfigSchema: Schema;
|
|
18
|
-
protected observeHandler(): Promise<Payload[]>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
declare const EthereumGasEtherscanPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<EthereumGasEtherscanWitness>;
|
|
22
|
-
|
|
23
|
-
export { EthereumGasEtherscanPlugin, EthereumGasEtherscanWitness, EthereumGasEtherscanWitnessConfigSchema, EthereumGasEtherscanPlugin as default };
|
|
24
|
-
export type { EthereumGasEtherscanWitnessConfig };
|
|
1
|
+
export * from './Config.ts';
|
|
2
|
+
export { EthereumGasEtherscanPlugin as default, EthereumGasEtherscanPlugin } from './Plugin.ts';
|
|
3
|
+
export * from './Schema.ts';
|
|
4
|
+
export * from './Witness.ts';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/etherscan-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,23 +28,26 @@
|
|
|
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/assert": "^
|
|
33
|
-
"@xylabs/axios": "^
|
|
34
|
-
"@xyo-network/abstract-witness": "^
|
|
35
|
-
"@xyo-network/etherscan-ethereum-gas-payload-plugin": "^
|
|
36
|
-
"@xyo-network/module-model": "^
|
|
37
|
-
"@xyo-network/payload-builder": "^
|
|
38
|
-
"@xyo-network/payload-model": "^
|
|
39
|
-
"@xyo-network/payloadset-plugin": "^
|
|
40
|
-
"@xyo-network/witness-model": "^
|
|
36
|
+
"@xylabs/assert": "^5.0.0",
|
|
37
|
+
"@xylabs/axios": "^5.0.0",
|
|
38
|
+
"@xyo-network/abstract-witness": "^5.0.0",
|
|
39
|
+
"@xyo-network/etherscan-ethereum-gas-payload-plugin": "^5.0.0",
|
|
40
|
+
"@xyo-network/module-model": "^5.0.0",
|
|
41
|
+
"@xyo-network/payload-builder": "^5.0.0",
|
|
42
|
+
"@xyo-network/payload-model": "^5.0.0",
|
|
43
|
+
"@xyo-network/payloadset-plugin": "^5.0.0",
|
|
44
|
+
"@xyo-network/witness-model": "^5.0.0"
|
|
41
45
|
},
|
|
42
46
|
"devDependencies": {
|
|
43
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.
|
|
44
|
-
"@xylabs/tsconfig": "^7.0.
|
|
45
|
-
"@xylabs/vitest-extended": "^
|
|
46
|
-
"@xyo-network/payload-wrapper": "^
|
|
47
|
-
"knip": "^5.62.0",
|
|
47
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.2",
|
|
48
|
+
"@xylabs/tsconfig": "^7.0.2",
|
|
49
|
+
"@xylabs/vitest-extended": "^5.0.0",
|
|
50
|
+
"@xyo-network/payload-wrapper": "^5.0.0",
|
|
48
51
|
"typescript": "^5.8.3",
|
|
49
52
|
"vitest": "^3.2.4"
|
|
50
53
|
},
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
describe, expect,
|
|
5
|
+
test,
|
|
6
|
+
} from 'vitest'
|
|
7
|
+
|
|
8
|
+
import { getGasFromEtherscan } from '../getGasFromEtherscan.ts'
|
|
9
|
+
|
|
10
|
+
const apiKey = process.env.ETHERSCAN_API_KEY || ''
|
|
11
|
+
|
|
12
|
+
describe('getGasFromEtherscan', () => {
|
|
13
|
+
test.skipIf(!apiKey)('returns prices', async () => {
|
|
14
|
+
const gas = await getGasFromEtherscan(apiKey)
|
|
15
|
+
expect(gas).toBeTruthy()
|
|
16
|
+
expect(gas.status).toEqual('1')
|
|
17
|
+
expect(gas.message).toEqual('OK')
|
|
18
|
+
expect(gas.result).toBeObject()
|
|
19
|
+
expect(gas.result.FastGasPrice).toBeString()
|
|
20
|
+
expect(gas.result.LastBlock).toBeString()
|
|
21
|
+
expect(gas.result.ProposeGasPrice).toBeString()
|
|
22
|
+
expect(gas.result.SafeGasPrice).toBeString()
|
|
23
|
+
expect(gas.result.gasUsedRatio).toBeString()
|
|
24
|
+
expect(gas.result.suggestBaseFee).toBeString()
|
|
25
|
+
})
|
|
26
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
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 { EthereumGasEtherscanPlugin } from '../Plugin.ts'
|
|
10
|
+
import { EthereumGasEtherscanWitness } from '../Witness.ts'
|
|
11
|
+
|
|
12
|
+
const apiKey = process.env.ETHERSCAN_API_KEY || ''
|
|
13
|
+
|
|
14
|
+
describe('EthereumGasEtherscanPlugin', () => {
|
|
15
|
+
test.skipIf(!apiKey)('Add to Resolver', async () => {
|
|
16
|
+
const plugin = EthereumGasEtherscanPlugin()
|
|
17
|
+
const resolver = await new PayloadSetPluginResolver().register(plugin, { config: { apiKey, schema: EthereumGasEtherscanWitness.defaultConfigSchema } })
|
|
18
|
+
expect(await resolver.resolve(plugin.set)).toBeObject()
|
|
19
|
+
expect(await resolver.witness(plugin.set)).toBeObject()
|
|
20
|
+
})
|
|
21
|
+
})
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import type { EthereumGasEtherscanPayload } from '@xyo-network/etherscan-ethereum-gas-payload-plugin'
|
|
4
|
+
import { EthereumGasEtherscanSchema } from '@xyo-network/etherscan-ethereum-gas-payload-plugin'
|
|
5
|
+
import { PayloadWrapper } from '@xyo-network/payload-wrapper'
|
|
6
|
+
import {
|
|
7
|
+
describe, expect,
|
|
8
|
+
test,
|
|
9
|
+
} from 'vitest'
|
|
10
|
+
|
|
11
|
+
import { EthereumGasEtherscanWitnessConfigSchema } from '../Schema.ts'
|
|
12
|
+
import { EthereumGasEtherscanWitness } from '../Witness.ts'
|
|
13
|
+
|
|
14
|
+
const apiKey = process.env.ETHERSCAN_API_KEY || ''
|
|
15
|
+
|
|
16
|
+
describe('EthereumGasEtherscanWitness', () => {
|
|
17
|
+
test.skipIf(!apiKey)('returns observation', async () => {
|
|
18
|
+
const sut = await EthereumGasEtherscanWitness.create({
|
|
19
|
+
config: {
|
|
20
|
+
apiKey,
|
|
21
|
+
schema: EthereumGasEtherscanWitnessConfigSchema,
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
const [actual] = (await sut.observe()) as EthereumGasEtherscanPayload[]
|
|
25
|
+
expect(actual.result).toBeObject()
|
|
26
|
+
expect(actual.result.FastGasPrice).toBeString()
|
|
27
|
+
expect(actual.result.gasUsedRatio).toBeString()
|
|
28
|
+
expect(actual.result.LastBlock).toBeString()
|
|
29
|
+
expect(actual.result.ProposeGasPrice).toBeString()
|
|
30
|
+
expect(actual.result.SafeGasPrice).toBeString()
|
|
31
|
+
expect(actual.result.suggestBaseFee).toBeString()
|
|
32
|
+
|
|
33
|
+
expect(actual.timestamp).toBeNumber()
|
|
34
|
+
expect(actual.schema).toBe(EthereumGasEtherscanSchema)
|
|
35
|
+
|
|
36
|
+
const answerWrapper = PayloadWrapper.wrap(actual)
|
|
37
|
+
expect(await answerWrapper.getValid()).toBe(true)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
/* describe('create', () => {
|
|
41
|
+
it('throws if no params provided', async () => {
|
|
42
|
+
await expect(EthereumGasEtherscanWitness.create()).toReject()
|
|
43
|
+
})
|
|
44
|
+
}) */
|
|
45
|
+
})
|
package/typedoc.json
DELETED