-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
62 changed files
with
662 additions
and
428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/payloadset/packages/api/src/spec/tzero-marketdata-sandbox-price-history.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/a5a229a767e3998e13cce8160fd1c2b027317424/packages/manifest/src/schema.json", | ||
"nodes": [ | ||
{ | ||
"config": { | ||
"accountPath": "0", | ||
"name": "ApiCall", | ||
"schema": "network.xyo.node.config" | ||
}, | ||
"modules": { | ||
"public": [ | ||
{ | ||
"config": { | ||
"accountPath": "0/0", | ||
"language": "javascript", | ||
"name": "ApiCallWitness", | ||
"schema": "network.xyo.api.call.witness.config", | ||
"uriTemplate": "https://gateway-web-markets-staging.tzero.com/mdt/public-pricehistory/${symbol}" | ||
} | ||
}, | ||
{ | ||
"config": { | ||
"accountPath": "1/0", | ||
"language": "javascript", | ||
"name": "ApiCallSentinel", | ||
"schema": "network.xyo.sentinel.config", | ||
"synchronous": "true", | ||
"tasks": [ | ||
{ | ||
"input": true, | ||
"module": "ApiCallWitness" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"schema": "network.xyo.manifest" | ||
} |
41 changes: 41 additions & 0 deletions
41
packages/payloadset/packages/api/src/spec/tzero-marketdata-sandbox-snapshots-symbol.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/a5a229a767e3998e13cce8160fd1c2b027317424/packages/manifest/src/schema.json", | ||
"nodes": [ | ||
{ | ||
"config": { | ||
"accountPath": "0", | ||
"name": "ApiCall", | ||
"schema": "network.xyo.node.config" | ||
}, | ||
"modules": { | ||
"public": [ | ||
{ | ||
"config": { | ||
"accountPath": "0/0", | ||
"language": "javascript", | ||
"name": "ApiCallWitness", | ||
"schema": "network.xyo.api.call.witness.config", | ||
"uriTemplate": "https://gateway-web-markets-staging.tzero.com/mdt/public-snapshots/${symbol}" | ||
} | ||
}, | ||
{ | ||
"config": { | ||
"accountPath": "1/0", | ||
"language": "javascript", | ||
"name": "ApiCallSentinel", | ||
"schema": "network.xyo.sentinel.config", | ||
"synchronous": "true", | ||
"tasks": [ | ||
{ | ||
"input": true, | ||
"module": "ApiCallWitness" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"schema": "network.xyo.manifest" | ||
} |
41 changes: 41 additions & 0 deletions
41
packages/payloadset/packages/api/src/spec/tzero-marketdata-sandbox-snapshots.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/a5a229a767e3998e13cce8160fd1c2b027317424/packages/manifest/src/schema.json", | ||
"nodes": [ | ||
{ | ||
"config": { | ||
"accountPath": "0", | ||
"name": "ApiCall", | ||
"schema": "network.xyo.node.config" | ||
}, | ||
"modules": { | ||
"public": [ | ||
{ | ||
"config": { | ||
"accountPath": "0/0", | ||
"language": "javascript", | ||
"name": "ApiCallWitness", | ||
"schema": "network.xyo.api.call.witness.config", | ||
"uriTemplate": "https://gateway-web-markets-staging.tzero.com/mdt/public-snapshots" | ||
} | ||
}, | ||
{ | ||
"config": { | ||
"accountPath": "0/1", | ||
"language": "javascript", | ||
"name": "ApiCallSentinel", | ||
"schema": "network.xyo.sentinel.config", | ||
"synchronous": "true", | ||
"tasks": [ | ||
{ | ||
"input": true, | ||
"module": "ApiCallWitness" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"schema": "network.xyo.manifest" | ||
} |
59 changes: 59 additions & 0 deletions
59
packages/payloadset/packages/api/src/spec/tzero-marketdata-sanddbox-price-history.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* eslint-disable max-statements */ | ||
import { describeIf } from '@xylabs/jest-helpers' | ||
import { JsonObject, toJsonString } from '@xylabs/object' | ||
import { HDWallet } from '@xyo-network/account' | ||
import { ManifestWrapper, PackageManifestPayload } from '@xyo-network/manifest' | ||
import { ModuleFactory, ModuleFactoryLocator } from '@xyo-network/module-model' | ||
import { isPayloadOfSchemaType } from '@xyo-network/payload-model' | ||
import { asSentinelInstance } from '@xyo-network/sentinel-model' | ||
import { asWitnessInstance } from '@xyo-network/witness-model' | ||
|
||
import { ApiCallJsonResult, ApiCallResultSchema, ApiCallSchema, ApiUriTemplateCall } from '../Payload' | ||
import { ApiCallWitness } from '../Witness' | ||
import tzeroMarketdataManifest from './tzero-marketdata-sandbox-price-history.json' | ||
|
||
describe('tZero', () => { | ||
const symbol = 'XYLB' | ||
|
||
const apiKey = process.env.TZERO_MARKETDATA_SANDBOX_API_KEY | ||
|
||
describeIf(apiKey)('price-history', () => { | ||
type TZeroMarketdataSandboxResponse = JsonObject | ||
it('specifying symbol', async () => { | ||
const mnemonic = 'later puppy sound rebuild rebuild noise ozone amazing hope broccoli crystal grief' | ||
const wallet = await HDWallet.fromPhrase(mnemonic) | ||
const locator = new ModuleFactoryLocator() | ||
|
||
locator.register( | ||
new ModuleFactory(ApiCallWitness, { | ||
headers: { 'x-apikey': apiKey }, | ||
}), | ||
) | ||
|
||
const manifest = new ManifestWrapper(tzeroMarketdataManifest as PackageManifestPayload, wallet, locator) | ||
|
||
const node = await manifest.loadNodeFromIndex(0) | ||
|
||
const mods = await node.resolve('*') | ||
|
||
expect(mods.length).toBeGreaterThan(1) | ||
|
||
const resolvedWitness = await node.resolve('ApiCallWitness') | ||
expect(resolvedWitness).toBeDefined() | ||
|
||
const witness = asWitnessInstance(resolvedWitness) | ||
expect(witness).toBeDefined() | ||
|
||
const sentinel = asSentinelInstance(await node.resolve('ApiCallSentinel')) | ||
expect(sentinel).toBeDefined() | ||
|
||
const call: ApiUriTemplateCall = { params: { symbol }, schema: ApiCallSchema } | ||
|
||
const report = await sentinel?.report([call]) | ||
|
||
const apiCallResult = report?.find(isPayloadOfSchemaType<ApiCallJsonResult<TZeroMarketdataSandboxResponse>>(ApiCallResultSchema)) | ||
expect(apiCallResult).toBeDefined() | ||
console.log(`Result: ${toJsonString(apiCallResult, 10)}`) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.