@xyo-network/etherscan-ethereum-gas-plugin 5.1.3 → 5.1.5
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.mjs +2 -2
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +20 -17
- package/src/lib/getGasFromEtherscan.ts +2 -2
- package/dist/neutral/lib/spec/getGasFromEtherscan.spec.d.ts +0 -2
- package/dist/neutral/lib/spec/getGasFromEtherscan.spec.d.ts.map +0 -1
- package/dist/neutral/spec/Plugin.spec.d.ts +0 -2
- package/dist/neutral/spec/Plugin.spec.d.ts.map +0 -1
- package/dist/neutral/spec/Witness.spec.d.ts +0 -2
- package/dist/neutral/spec/Witness.spec.d.ts.map +0 -1
- package/src/lib/spec/getGasFromEtherscan.spec.ts +0 -26
- package/src/spec/Plugin.spec.ts +0 -21
- package/src/spec/Witness.spec.ts +0 -45
package/dist/neutral/index.mjs
CHANGED
|
@@ -10,10 +10,10 @@ import { EthereumGasEtherscanSchema } from "@xyo-network/etherscan-ethereum-gas-
|
|
|
10
10
|
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
11
11
|
|
|
12
12
|
// src/lib/getGasFromEtherscan.ts
|
|
13
|
-
import {
|
|
13
|
+
import { axiosJson } from "@xylabs/axios";
|
|
14
14
|
var getGasFromEtherscan = async (apiKey) => {
|
|
15
15
|
const url = `https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=${apiKey}`;
|
|
16
|
-
return (await
|
|
16
|
+
return (await axiosJson.get(url)).data;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
// src/Schema.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Plugin.ts","../../src/Witness.ts","../../src/lib/getGasFromEtherscan.ts","../../src/Schema.ts"],"sourcesContent":["import { EthereumGasEtherscanSchema } from '@xyo-network/etherscan-ethereum-gas-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { EthereumGasEtherscanWitness } from './Witness.ts'\n\nexport const EthereumGasEtherscanPlugin = () =>\n createPayloadSetWitnessPlugin<EthereumGasEtherscanWitness>(\n { required: { [EthereumGasEtherscanSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await EthereumGasEtherscanWitness.create(params)\n return result as EthereumGasEtherscanWitness\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport type { EthereumGasEtherscanPayload } from '@xyo-network/etherscan-ethereum-gas-payload-plugin'\nimport { EthereumGasEtherscanSchema } from '@xyo-network/etherscan-ethereum-gas-payload-plugin'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport type { WitnessParams } from '@xyo-network/witness-model'\n\nimport type { EthereumGasEtherscanWitnessConfig } from './Config.ts'\nimport { getGasFromEtherscan } from './lib/index.ts'\nimport { EthereumGasEtherscanWitnessConfigSchema } from './Schema.ts'\n\nexport class EthereumGasEtherscanWitness extends AbstractWitness<WitnessParams<AnyConfigSchema<EthereumGasEtherscanWitnessConfig>>> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, EthereumGasEtherscanWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = EthereumGasEtherscanWitnessConfigSchema\n\n protected override async observeHandler(): Promise<Payload[]> {\n const apiKey = assertEx(this.config?.apiKey, () => 'apiKey is required')\n const payload = new PayloadBuilder<EthereumGasEtherscanPayload>({ schema: EthereumGasEtherscanSchema })\n .fields(await getGasFromEtherscan(apiKey))\n .build()\n return [payload]\n }\n}\n","import {
|
|
1
|
+
{"version":3,"sources":["../../src/Plugin.ts","../../src/Witness.ts","../../src/lib/getGasFromEtherscan.ts","../../src/Schema.ts"],"sourcesContent":["import { EthereumGasEtherscanSchema } from '@xyo-network/etherscan-ethereum-gas-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { EthereumGasEtherscanWitness } from './Witness.ts'\n\nexport const EthereumGasEtherscanPlugin = () =>\n createPayloadSetWitnessPlugin<EthereumGasEtherscanWitness>(\n { required: { [EthereumGasEtherscanSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await EthereumGasEtherscanWitness.create(params)\n return result as EthereumGasEtherscanWitness\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport type { EthereumGasEtherscanPayload } from '@xyo-network/etherscan-ethereum-gas-payload-plugin'\nimport { EthereumGasEtherscanSchema } from '@xyo-network/etherscan-ethereum-gas-payload-plugin'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport type { WitnessParams } from '@xyo-network/witness-model'\n\nimport type { EthereumGasEtherscanWitnessConfig } from './Config.ts'\nimport { getGasFromEtherscan } from './lib/index.ts'\nimport { EthereumGasEtherscanWitnessConfigSchema } from './Schema.ts'\n\nexport class EthereumGasEtherscanWitness extends AbstractWitness<WitnessParams<AnyConfigSchema<EthereumGasEtherscanWitnessConfig>>> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, EthereumGasEtherscanWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = EthereumGasEtherscanWitnessConfigSchema\n\n protected override async observeHandler(): Promise<Payload[]> {\n const apiKey = assertEx(this.config?.apiKey, () => 'apiKey is required')\n const payload = new PayloadBuilder<EthereumGasEtherscanPayload>({ schema: EthereumGasEtherscanSchema })\n .fields(await getGasFromEtherscan(apiKey))\n .build()\n return [payload]\n }\n}\n","import { axiosJson } from '@xylabs/axios'\nimport type { EthereumGasEtherscanResponse } from '@xyo-network/etherscan-ethereum-gas-payload-plugin'\n\nexport const getGasFromEtherscan = async (apiKey: string): Promise<EthereumGasEtherscanResponse> => {\n const url = `https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=${apiKey}`\n return (await axiosJson.get<EthereumGasEtherscanResponse>(url)).data\n}\n","export type EthereumGasEtherscanWitnessConfigSchema = 'network.xyo.blockchain.ethereum.gas.etherscan.witness.config'\nexport const EthereumGasEtherscanWitnessConfigSchema: EthereumGasEtherscanWitnessConfigSchema\n = 'network.xyo.blockchain.ethereum.gas.etherscan.witness.config'\n"],"mappings":";AAAA,SAAS,8BAAAA,mCAAkC;AAC3C,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;;;ACF9C,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAEhC,SAAS,kCAAkC;AAE3C,SAAS,sBAAsB;;;ACL/B,SAAS,iBAAiB;AAGnB,IAAM,sBAAsB,OAAO,WAA0D;AAClG,QAAM,MAAM,0EAA0E,MAAM;AAC5F,UAAQ,MAAM,UAAU,IAAkC,GAAG,GAAG;AAClE;;;ACLO,IAAM,0CACT;;;AFWG,IAAM,8BAAN,cAA0C,gBAAmF;AAAA,EAClI,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,uCAAuC;AAAA,EACnH,OAAyB,sBAA8B;AAAA,EAEvD,MAAyB,iBAAqC;AAC5D,UAAM,SAAS,SAAS,KAAK,QAAQ,QAAQ,MAAM,oBAAoB;AACvE,UAAM,UAAU,IAAI,eAA4C,EAAE,QAAQ,2BAA2B,CAAC,EACnG,OAAO,MAAM,oBAAoB,MAAM,CAAC,EACxC,MAAM;AACT,WAAO,CAAC,OAAO;AAAA,EACjB;AACF;;;ADlBO,IAAM,6BAA6B,MACxC;AAAA,EACE,EAAE,UAAU,EAAE,CAACC,2BAA0B,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EAC1E;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM,4BAA4B,OAAO,MAAM;AAC9D,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["EthereumGasEtherscanSchema","EthereumGasEtherscanSchema"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/etherscan-ethereum-gas-plugin",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.5",
|
|
4
4
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -30,26 +30,29 @@
|
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
|
-
"src"
|
|
33
|
+
"src",
|
|
34
|
+
"!**/*.bench.*",
|
|
35
|
+
"!**/*.spec.*",
|
|
36
|
+
"!**/*.test.*"
|
|
34
37
|
],
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"@xylabs/assert": "~5.0.
|
|
37
|
-
"@xylabs/axios": "~5.0.
|
|
38
|
-
"@xyo-network/abstract-witness": "~5.1.
|
|
39
|
-
"@xyo-network/etherscan-ethereum-gas-payload-plugin": "~5.1.
|
|
40
|
-
"@xyo-network/module-model": "~5.1.
|
|
41
|
-
"@xyo-network/payload-builder": "~5.1.
|
|
42
|
-
"@xyo-network/payload-model": "~5.1.
|
|
43
|
-
"@xyo-network/payloadset-plugin": "~5.1.
|
|
44
|
-
"@xyo-network/witness-model": "~5.1.
|
|
39
|
+
"@xylabs/assert": "~5.0.37",
|
|
40
|
+
"@xylabs/axios": "~5.0.37",
|
|
41
|
+
"@xyo-network/abstract-witness": "~5.1.23",
|
|
42
|
+
"@xyo-network/etherscan-ethereum-gas-payload-plugin": "~5.1.5",
|
|
43
|
+
"@xyo-network/module-model": "~5.1.23",
|
|
44
|
+
"@xyo-network/payload-builder": "~5.1.23",
|
|
45
|
+
"@xyo-network/payload-model": "~5.1.23",
|
|
46
|
+
"@xyo-network/payloadset-plugin": "~5.1.23",
|
|
47
|
+
"@xyo-network/witness-model": "~5.1.23"
|
|
45
48
|
},
|
|
46
49
|
"devDependencies": {
|
|
47
|
-
"@xylabs/ts-scripts-yarn3": "~7.
|
|
48
|
-
"@xylabs/tsconfig": "~7.
|
|
49
|
-
"@xylabs/vitest-extended": "~5.0.
|
|
50
|
-
"@xyo-network/payload-wrapper": "~5.1.
|
|
51
|
-
"typescript": "~5.9.
|
|
52
|
-
"vitest": "~
|
|
50
|
+
"@xylabs/ts-scripts-yarn3": "~7.2.8",
|
|
51
|
+
"@xylabs/tsconfig": "~7.2.8",
|
|
52
|
+
"@xylabs/vitest-extended": "~5.0.37",
|
|
53
|
+
"@xyo-network/payload-wrapper": "~5.1.23",
|
|
54
|
+
"typescript": "~5.9.3",
|
|
55
|
+
"vitest": "~4.0.10"
|
|
53
56
|
},
|
|
54
57
|
"publishConfig": {
|
|
55
58
|
"access": "public"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { axiosJson } from '@xylabs/axios'
|
|
2
2
|
import type { EthereumGasEtherscanResponse } from '@xyo-network/etherscan-ethereum-gas-payload-plugin'
|
|
3
3
|
|
|
4
4
|
export const getGasFromEtherscan = async (apiKey: string): Promise<EthereumGasEtherscanResponse> => {
|
|
5
5
|
const url = `https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=${apiKey}`
|
|
6
|
-
return (await
|
|
6
|
+
return (await axiosJson.get<EthereumGasEtherscanResponse>(url)).data
|
|
7
7
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getGasFromEtherscan.spec.d.ts","sourceRoot":"","sources":["../../../../src/lib/spec/getGasFromEtherscan.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Plugin.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Witness.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Witness.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
})
|
package/src/spec/Plugin.spec.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
})
|
package/src/spec/Witness.spec.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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
|
-
})
|