@xyo-network/coingecko-crypto-market-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 +6 -34
- package/package.json +16 -13
- package/src/lib/spec/pricesFromCoingecko.spec.ts +16 -0
- package/src/spec/Plugin.spec.ts +17 -0
- package/src/spec/Witness.spec.ts +46 -0
- package/typedoc.json +0 -5
- package/xy.config.ts +0 -10
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,34 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type CoingeckoCryptoMarketWitnessConfigSchema = 'network.xyo.crypto.market.coingecko.witness.config';
|
|
9
|
-
declare const CoingeckoCryptoMarketWitnessConfigSchema: CoingeckoCryptoMarketWitnessConfigSchema;
|
|
10
|
-
|
|
11
|
-
type CoingeckoCryptoMarketWitnessConfig = WitnessConfig<{
|
|
12
|
-
coins?: CryptoAsset[];
|
|
13
|
-
currencies?: CryptoAsset[];
|
|
14
|
-
schema: CoingeckoCryptoMarketWitnessConfigSchema;
|
|
15
|
-
}>;
|
|
16
|
-
|
|
17
|
-
declare const coingeckoCoinToAssetMap: Record<string, AssetSymbol>;
|
|
18
|
-
|
|
19
|
-
declare const defaultCoins: CryptoAsset[];
|
|
20
|
-
declare const defaultCurrencies: CryptoAsset[];
|
|
21
|
-
|
|
22
|
-
declare const pricesFromCoingecko: (coins: CryptoAsset[], currencies: CryptoAsset[]) => Promise<Partial<Record<string, Partial<Record<string, number> | undefined>>>>;
|
|
23
|
-
|
|
24
|
-
type CoingeckoCryptoMarketWitnessParams = WitnessParams<AnyConfigSchema<CoingeckoCryptoMarketWitnessConfig>>;
|
|
25
|
-
declare class CoingeckoCryptoMarketWitness<TParams extends CoingeckoCryptoMarketWitnessParams = CoingeckoCryptoMarketWitnessParams> extends AbstractWitness<TParams> {
|
|
26
|
-
static readonly configSchemas: Schema[];
|
|
27
|
-
static readonly defaultConfigSchema: Schema;
|
|
28
|
-
protected observeHandler(): Promise<Payload[]>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
declare const CoingeckoCryptoMarketPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<CoingeckoCryptoMarketWitness<CoingeckoCryptoMarketWitnessParams>>;
|
|
32
|
-
|
|
33
|
-
export { CoingeckoCryptoMarketPlugin, CoingeckoCryptoMarketWitness, CoingeckoCryptoMarketWitnessConfigSchema, coingeckoCoinToAssetMap, CoingeckoCryptoMarketPlugin as default, defaultCoins, defaultCurrencies, pricesFromCoingecko };
|
|
34
|
-
export type { CoingeckoCryptoMarketWitnessConfig, CoingeckoCryptoMarketWitnessParams };
|
|
1
|
+
export * from './Config.ts';
|
|
2
|
+
export * from './lib/index.ts';
|
|
3
|
+
export { CoingeckoCryptoMarketPlugin, CoingeckoCryptoMarketPlugin as default } from './Plugin.ts';
|
|
4
|
+
export * from './Schema.ts';
|
|
5
|
+
export * from './Witness.ts';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/coingecko-crypto-market-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,24 @@
|
|
|
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/coingecko-crypto-market-payload-plugin": "^
|
|
35
|
-
"@xyo-network/module-model": "^
|
|
36
|
-
"@xyo-network/payload-model": "^
|
|
37
|
-
"@xyo-network/payloadset-plugin": "^
|
|
38
|
-
"@xyo-network/witness-model": "^
|
|
36
|
+
"@xylabs/axios": "^5.0.0",
|
|
37
|
+
"@xyo-network/abstract-witness": "^5.0.0",
|
|
38
|
+
"@xyo-network/coingecko-crypto-market-payload-plugin": "^5.0.0",
|
|
39
|
+
"@xyo-network/module-model": "^5.0.0",
|
|
40
|
+
"@xyo-network/payload-model": "^5.0.0",
|
|
41
|
+
"@xyo-network/payloadset-plugin": "^5.0.0",
|
|
42
|
+
"@xyo-network/witness-model": "^5.0.0"
|
|
39
43
|
},
|
|
40
44
|
"devDependencies": {
|
|
41
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.
|
|
42
|
-
"@xylabs/tsconfig": "^7.0.
|
|
43
|
-
"@xylabs/vitest-extended": "^
|
|
44
|
-
"@xyo-network/payload-wrapper": "^
|
|
45
|
-
"knip": "^5.62.0",
|
|
45
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.2",
|
|
46
|
+
"@xylabs/tsconfig": "^7.0.2",
|
|
47
|
+
"@xylabs/vitest-extended": "^5.0.0",
|
|
48
|
+
"@xyo-network/payload-wrapper": "^5.0.0",
|
|
46
49
|
"typescript": "^5.8.3",
|
|
47
50
|
"vitest": "^3.2.4"
|
|
48
51
|
},
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
describe, expect,
|
|
5
|
+
test,
|
|
6
|
+
} from 'vitest'
|
|
7
|
+
|
|
8
|
+
import { defaultCoins, defaultCurrencies } from '../defaults.ts'
|
|
9
|
+
import { pricesFromCoingecko } from '../pricesFromCoingecko.ts'
|
|
10
|
+
|
|
11
|
+
describe('pricesFromCoingecko', () => {
|
|
12
|
+
test('observe', async () => {
|
|
13
|
+
const assets = await pricesFromCoingecko(defaultCoins, defaultCurrencies)
|
|
14
|
+
expect(assets.btc?.btc).toBe(1)
|
|
15
|
+
})
|
|
16
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { CoingeckoCryptoMarketPlugin } from '../Plugin.ts'
|
|
10
|
+
|
|
11
|
+
describe('CryptoMarketCoinGeckoPlugin', () => {
|
|
12
|
+
test('Add to Resolver', async () => {
|
|
13
|
+
const plugin = CoingeckoCryptoMarketPlugin()
|
|
14
|
+
const resolver = await new PayloadSetPluginResolver().register(plugin)
|
|
15
|
+
expect(await resolver.resolve(plugin.set)).toBeDefined()
|
|
16
|
+
})
|
|
17
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import type { CoingeckoCryptoMarketPayload } from '@xyo-network/coingecko-crypto-market-payload-plugin'
|
|
4
|
+
import { CoingeckoCryptoMarketSchema } from '@xyo-network/coingecko-crypto-market-payload-plugin'
|
|
5
|
+
import { PayloadWrapper } from '@xyo-network/payload-wrapper'
|
|
6
|
+
import {
|
|
7
|
+
describe, expect,
|
|
8
|
+
test,
|
|
9
|
+
} from 'vitest'
|
|
10
|
+
|
|
11
|
+
import { defaultCoins, defaultCurrencies } from '../lib/index.ts'
|
|
12
|
+
import { CoingeckoCryptoMarketWitnessConfigSchema } from '../Schema.ts'
|
|
13
|
+
import { CoingeckoCryptoMarketWitness } from '../Witness.ts'
|
|
14
|
+
|
|
15
|
+
describe('CoingeckoCryptoMarketWitness', () => {
|
|
16
|
+
test('returns observation', async () => {
|
|
17
|
+
const sut = await CoingeckoCryptoMarketWitness.create({
|
|
18
|
+
account: 'random',
|
|
19
|
+
config: {
|
|
20
|
+
coins: defaultCoins,
|
|
21
|
+
currencies: defaultCurrencies,
|
|
22
|
+
schema: CoingeckoCryptoMarketWitnessConfigSchema,
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
const [actual] = await sut.observe()
|
|
26
|
+
expect(actual.schema).toBe(CoingeckoCryptoMarketSchema)
|
|
27
|
+
const answerWrapper = PayloadWrapper.wrap(actual) as PayloadWrapper<CoingeckoCryptoMarketPayload>
|
|
28
|
+
expect(await answerWrapper.getValid()).toBe(true)
|
|
29
|
+
expect(answerWrapper.payload.assets).toBeObject()
|
|
30
|
+
const assets = Object.keys(answerWrapper.payload.assets)
|
|
31
|
+
expect(assets).toBeArray()
|
|
32
|
+
expect(assets.length).toBeGreaterThan(0)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
test('returns observation [no config]', async () => {
|
|
36
|
+
const sut = await CoingeckoCryptoMarketWitness.create({ account: 'random' })
|
|
37
|
+
const [actual] = await sut.observe()
|
|
38
|
+
expect(actual.schema).toBe(CoingeckoCryptoMarketSchema)
|
|
39
|
+
const answerWrapper = PayloadWrapper.wrap(actual) as PayloadWrapper<CoingeckoCryptoMarketPayload>
|
|
40
|
+
expect(await answerWrapper.getValid()).toBe(true)
|
|
41
|
+
expect(answerWrapper.payload.assets).toBeObject()
|
|
42
|
+
const assets = Object.keys(answerWrapper.payload.assets)
|
|
43
|
+
expect(assets).toBeArray()
|
|
44
|
+
expect(assets.length).toBe(0)
|
|
45
|
+
})
|
|
46
|
+
})
|
package/typedoc.json
DELETED