mirror of
https://github.com/fluencelabs/eip712-validation-node
synced 2025-06-25 12:41:53 +00:00
update demo client
This commit is contained in:
4
client-peer/.gitignore
vendored
4
client-peer/.gitignore
vendored
@ -1,2 +1,4 @@
|
|||||||
dist/
|
dist/
|
||||||
src/_aqua/
|
node_modules/
|
||||||
|
*bk
|
||||||
|
*bak
|
5123
client-peer/package-lock.json
generated
Normal file
5123
client-peer/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -19,14 +19,9 @@
|
|||||||
"it-all": "^1.0.5"
|
"it-all": "^1.0.5"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"compile-aqua": "aqua -i ../aqua-scripts -o src/_aqua/",
|
"start": "node dist/src/index.js",
|
||||||
"prebuild": "npm run compile-aqua",
|
"compile-aqua": "aqua -i aqua -o src/_aqua/",
|
||||||
"build": "tsc",
|
"watch-aqua": "chokidar \"**/*.aqua\" -c \"npm run compile-aqua\""
|
||||||
"prestart:local": "npm run build",
|
|
||||||
"start:local": "node dist/src/index.js local",
|
|
||||||
"prestart:remote": "npm run build",
|
|
||||||
"start:remote": "node dist/src/index.js krasnodar",
|
|
||||||
"start": "npm run start:remote"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -16,17 +16,17 @@ import {
|
|||||||
|
|
||||||
// Services
|
// Services
|
||||||
|
|
||||||
export interface ProVoValidationDef {
|
export interface EIPValidatorDef {
|
||||||
eip712_validation_string: (eip_str: string, peer_id: string, callParams: CallParams<'eip_str' | 'peer_id'>) => string | Promise<string>;
|
eip712_validation_string: (eip_str: string, peer_id: string, callParams: CallParams<'eip_str' | 'peer_id'>) => string | Promise<string>;
|
||||||
eip712_validation_url: (eip_str: string, peer_id: string, callParams: CallParams<'eip_str' | 'peer_id'>) => string | Promise<string>;
|
eip712_validation_url: (eip_str: string, peer_id: string, callParams: CallParams<'eip_str' | 'peer_id'>) => string | Promise<string>;
|
||||||
}
|
}
|
||||||
export function registerProVoValidation(service: ProVoValidationDef): void;
|
export function registerEIPValidator(service: EIPValidatorDef): void;
|
||||||
export function registerProVoValidation(serviceId: string, service: ProVoValidationDef): void;
|
export function registerEIPValidator(serviceId: string, service: EIPValidatorDef): void;
|
||||||
export function registerProVoValidation(peer: FluencePeer, service: ProVoValidationDef): void;
|
export function registerEIPValidator(peer: FluencePeer, service: EIPValidatorDef): void;
|
||||||
export function registerProVoValidation(peer: FluencePeer, serviceId: string, service: ProVoValidationDef): void;
|
export function registerEIPValidator(peer: FluencePeer, serviceId: string, service: EIPValidatorDef): void;
|
||||||
|
|
||||||
|
|
||||||
export function registerProVoValidation(...args: any) {
|
export function registerEIPValidator(...args: any) {
|
||||||
registerService(
|
registerService(
|
||||||
args,
|
args,
|
||||||
{
|
{
|
||||||
@ -80,8 +80,10 @@ export function registerProVoValidation(...args: any) {
|
|||||||
|
|
||||||
|
|
||||||
export interface DataProviderDef {
|
export interface DataProviderDef {
|
||||||
get_record: (snapshot_id: number, callParams: CallParams<'snapshot_id'>) => { snapshot_id: number; } | Promise<{ snapshot_id: number; }>;
|
clear_table: (password: string, callParams: CallParams<'password'>) => { stderr: string; stdout: { eip712_doc: string; eip_validation: boolean; event_address: string; event_signature: string; peer_id: string; signed_response: string; snapshot_id: number; timestamp: number; ts_validation: boolean; }[]; } | Promise<{ stderr: string; stdout: { eip712_doc: string; eip_validation: boolean; event_address: string; event_signature: string; peer_id: string; signed_response: string; snapshot_id: number; timestamp: number; ts_validation: boolean; }[]; }>;
|
||||||
get_records: (callParams: CallParams<null>) => { snapshot_id: number; }[] | Promise<{ snapshot_id: number; }[]>;
|
get_record: (snapshot_id: number, callParams: CallParams<'snapshot_id'>) => { stderr: string; stdout: { eip712_doc: string; eip_validation: boolean; event_address: string; event_signature: string; peer_id: string; signed_response: string; snapshot_id: number; timestamp: number; ts_validation: boolean; }[]; } | Promise<{ stderr: string; stdout: { eip712_doc: string; eip_validation: boolean; event_address: string; event_signature: string; peer_id: string; signed_response: string; snapshot_id: number; timestamp: number; ts_validation: boolean; }[]; }>;
|
||||||
|
get_record_count: (callParams: CallParams<null>) => number | Promise<number>;
|
||||||
|
get_records: (callParams: CallParams<null>) => { stderr: string; stdout: { eip712_doc: string; eip_validation: boolean; event_address: string; event_signature: string; peer_id: string; signed_response: string; snapshot_id: number; timestamp: number; ts_validation: boolean; }[]; } | Promise<{ stderr: string; stdout: { eip712_doc: string; eip_validation: boolean; event_address: string; event_signature: string; peer_id: string; signed_response: string; snapshot_id: number; timestamp: number; ts_validation: boolean; }[]; }>;
|
||||||
}
|
}
|
||||||
export function registerDataProvider(service: DataProviderDef): void;
|
export function registerDataProvider(service: DataProviderDef): void;
|
||||||
export function registerDataProvider(serviceId: string, service: DataProviderDef): void;
|
export function registerDataProvider(serviceId: string, service: DataProviderDef): void;
|
||||||
@ -95,6 +97,20 @@ export function registerDataProvider(...args: any) {
|
|||||||
{
|
{
|
||||||
"defaultServiceId" : "DataProvider",
|
"defaultServiceId" : "DataProvider",
|
||||||
"functions" : [
|
"functions" : [
|
||||||
|
{
|
||||||
|
"functionName" : "clear_table",
|
||||||
|
"argDefs" : [
|
||||||
|
{
|
||||||
|
"name" : "password",
|
||||||
|
"argType" : {
|
||||||
|
"tag" : "primitive"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"returnType" : {
|
||||||
|
"tag" : "primitive"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"functionName" : "get_record",
|
"functionName" : "get_record",
|
||||||
"argDefs" : [
|
"argDefs" : [
|
||||||
@ -109,6 +125,14 @@ export function registerDataProvider(...args: any) {
|
|||||||
"tag" : "primitive"
|
"tag" : "primitive"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"functionName" : "get_record_count",
|
||||||
|
"argDefs" : [
|
||||||
|
],
|
||||||
|
"returnType" : {
|
||||||
|
"tag" : "primitive"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"functionName" : "get_records",
|
"functionName" : "get_records",
|
||||||
"argDefs" : [
|
"argDefs" : [
|
||||||
@ -124,6 +148,196 @@ export function registerDataProvider(...args: any) {
|
|||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
|
|
||||||
|
export type Delete_rowsResult = { stderr: string; stdout: { eip712_doc: string; eip_validation: boolean; event_address: string; event_signature: string; peer_id: string; signed_response: string; snapshot_id: number; timestamp: number; ts_validation: boolean; }[]; }
|
||||||
|
export function delete_rows(password: string, node: string, relay: string, config?: {ttl?: number}): Promise<Delete_rowsResult>;
|
||||||
|
export function delete_rows(peer: FluencePeer, password: string, node: string, relay: string, config?: {ttl?: number}): Promise<Delete_rowsResult>;
|
||||||
|
export function delete_rows(...args: any) {
|
||||||
|
|
||||||
|
let script = `
|
||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||||
|
(call %init_peer_id% ("getDataSrv" "password") [] password)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("getDataSrv" "node") [] node)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("getDataSrv" "relay") [] relay)
|
||||||
|
)
|
||||||
|
(call -relay- ("op" "noop") [])
|
||||||
|
)
|
||||||
|
(call relay ("op" "noop") [])
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(call node ("DataProvider" "clear_table") [password] result)
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call relay ("op" "noop") [])
|
||||||
|
(call -relay- ("op" "noop") [])
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||||
|
)
|
||||||
|
(call -relay- ("op" "noop") [])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call relay ("op" "noop") [])
|
||||||
|
)
|
||||||
|
(call -relay- ("op" "noop") [])
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(call %init_peer_id% ("callbackSrv" "response") [result])
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
||||||
|
)
|
||||||
|
`
|
||||||
|
return callFunction(
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
"functionName" : "delete_rows",
|
||||||
|
"returnType" : {
|
||||||
|
"tag" : "primitive"
|
||||||
|
},
|
||||||
|
"argDefs" : [
|
||||||
|
{
|
||||||
|
"name" : "password",
|
||||||
|
"argType" : {
|
||||||
|
"tag" : "primitive"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "node",
|
||||||
|
"argType" : {
|
||||||
|
"tag" : "primitive"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "relay",
|
||||||
|
"argType" : {
|
||||||
|
"tag" : "primitive"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"names" : {
|
||||||
|
"relay" : "-relay-",
|
||||||
|
"getDataSrv" : "getDataSrv",
|
||||||
|
"callbackSrv" : "callbackSrv",
|
||||||
|
"responseSrv" : "callbackSrv",
|
||||||
|
"responseFnName" : "response",
|
||||||
|
"errorHandlingSrv" : "errorHandlingSrv",
|
||||||
|
"errorFnName" : "error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
script
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export type Get_recordResult = { stderr: string; stdout: { eip712_doc: string; eip_validation: boolean; event_address: string; event_signature: string; peer_id: string; signed_response: string; snapshot_id: number; timestamp: number; ts_validation: boolean; }[]; }
|
||||||
|
export function get_record(snapshot_id: number, node: string, relay: string, config?: {ttl?: number}): Promise<Get_recordResult>;
|
||||||
|
export function get_record(peer: FluencePeer, snapshot_id: number, node: string, relay: string, config?: {ttl?: number}): Promise<Get_recordResult>;
|
||||||
|
export function get_record(...args: any) {
|
||||||
|
|
||||||
|
let script = `
|
||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||||
|
(call %init_peer_id% ("getDataSrv" "snapshot_id") [] snapshot_id)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("getDataSrv" "node") [] node)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("getDataSrv" "relay") [] relay)
|
||||||
|
)
|
||||||
|
(call -relay- ("op" "noop") [])
|
||||||
|
)
|
||||||
|
(call relay ("op" "noop") [])
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(call node ("DataProvider" "get_record") [snapshot_id] res)
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call relay ("op" "noop") [])
|
||||||
|
(call -relay- ("op" "noop") [])
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||||
|
)
|
||||||
|
(call -relay- ("op" "noop") [])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call relay ("op" "noop") [])
|
||||||
|
)
|
||||||
|
(call -relay- ("op" "noop") [])
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(call %init_peer_id% ("callbackSrv" "response") [res])
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
||||||
|
)
|
||||||
|
`
|
||||||
|
return callFunction(
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
"functionName" : "get_record",
|
||||||
|
"returnType" : {
|
||||||
|
"tag" : "primitive"
|
||||||
|
},
|
||||||
|
"argDefs" : [
|
||||||
|
{
|
||||||
|
"name" : "snapshot_id",
|
||||||
|
"argType" : {
|
||||||
|
"tag" : "primitive"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "node",
|
||||||
|
"argType" : {
|
||||||
|
"tag" : "primitive"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "relay",
|
||||||
|
"argType" : {
|
||||||
|
"tag" : "primitive"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"names" : {
|
||||||
|
"relay" : "-relay-",
|
||||||
|
"getDataSrv" : "getDataSrv",
|
||||||
|
"callbackSrv" : "callbackSrv",
|
||||||
|
"responseSrv" : "callbackSrv",
|
||||||
|
"responseFnName" : "response",
|
||||||
|
"errorHandlingSrv" : "errorHandlingSrv",
|
||||||
|
"errorFnName" : "error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
script
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export function validate(eip712_url: string, node: string, relay: string, config?: {ttl?: number}): Promise<string>;
|
export function validate(eip712_url: string, node: string, relay: string, config?: {ttl?: number}): Promise<string>;
|
||||||
export function validate(peer: FluencePeer, eip712_url: string, node: string, relay: string, config?: {ttl?: number}): Promise<string>;
|
export function validate(peer: FluencePeer, eip712_url: string, node: string, relay: string, config?: {ttl?: number}): Promise<string>;
|
||||||
@ -220,9 +434,95 @@ export function validate(...args: any) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
export function get_all_validations(node: string, relay: string, config?: {ttl?: number}): Promise<{ snapshot_id: number; }[]>;
|
export function get_record_count(node: string, relay: string, config?: {ttl?: number}): Promise<number>;
|
||||||
export function get_all_validations(peer: FluencePeer, node: string, relay: string, config?: {ttl?: number}): Promise<{ snapshot_id: number; }[]>;
|
export function get_record_count(peer: FluencePeer, node: string, relay: string, config?: {ttl?: number}): Promise<number>;
|
||||||
export function get_all_validations(...args: any) {
|
export function get_record_count(...args: any) {
|
||||||
|
|
||||||
|
let script = `
|
||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||||
|
(call %init_peer_id% ("getDataSrv" "node") [] node)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("getDataSrv" "relay") [] relay)
|
||||||
|
)
|
||||||
|
(call -relay- ("op" "noop") [])
|
||||||
|
)
|
||||||
|
(call relay ("op" "noop") [])
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(call node ("DataProvider" "get_record_count") [] res)
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call relay ("op" "noop") [])
|
||||||
|
(call -relay- ("op" "noop") [])
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||||
|
)
|
||||||
|
(call -relay- ("op" "noop") [])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call relay ("op" "noop") [])
|
||||||
|
)
|
||||||
|
(call -relay- ("op" "noop") [])
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(call %init_peer_id% ("callbackSrv" "response") [res])
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
||||||
|
)
|
||||||
|
`
|
||||||
|
return callFunction(
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
"functionName" : "get_record_count",
|
||||||
|
"returnType" : {
|
||||||
|
"tag" : "primitive"
|
||||||
|
},
|
||||||
|
"argDefs" : [
|
||||||
|
{
|
||||||
|
"name" : "node",
|
||||||
|
"argType" : {
|
||||||
|
"tag" : "primitive"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "relay",
|
||||||
|
"argType" : {
|
||||||
|
"tag" : "primitive"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"names" : {
|
||||||
|
"relay" : "-relay-",
|
||||||
|
"getDataSrv" : "getDataSrv",
|
||||||
|
"callbackSrv" : "callbackSrv",
|
||||||
|
"responseSrv" : "callbackSrv",
|
||||||
|
"responseFnName" : "response",
|
||||||
|
"errorHandlingSrv" : "errorHandlingSrv",
|
||||||
|
"errorFnName" : "error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
script
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export type Get_recordsResult = { stderr: string; stdout: { eip712_doc: string; eip_validation: boolean; event_address: string; event_signature: string; peer_id: string; signed_response: string; snapshot_id: number; timestamp: number; ts_validation: boolean; }[]; }
|
||||||
|
export function get_records(node: string, relay: string, config?: {ttl?: number}): Promise<Get_recordsResult>;
|
||||||
|
export function get_records(peer: FluencePeer, node: string, relay: string, config?: {ttl?: number}): Promise<Get_recordsResult>;
|
||||||
|
export function get_records(...args: any) {
|
||||||
|
|
||||||
let script = `
|
let script = `
|
||||||
(xor
|
(xor
|
||||||
@ -272,7 +572,7 @@ export function get_all_validations(...args: any) {
|
|||||||
return callFunction(
|
return callFunction(
|
||||||
args,
|
args,
|
||||||
{
|
{
|
||||||
"functionName" : "get_all_validations",
|
"functionName" : "get_records",
|
||||||
"returnType" : {
|
"returnType" : {
|
||||||
"tag" : "primitive"
|
"tag" : "primitive"
|
||||||
},
|
},
|
||||||
@ -303,98 +603,3 @@ export function get_all_validations(...args: any) {
|
|||||||
script
|
script
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export type Get_validationResult = { snapshot_id: number; }
|
|
||||||
export function get_validation(snapshot_id: number, node: string, relay: string, config?: {ttl?: number}): Promise<Get_validationResult>;
|
|
||||||
export function get_validation(peer: FluencePeer, snapshot_id: number, node: string, relay: string, config?: {ttl?: number}): Promise<Get_validationResult>;
|
|
||||||
export function get_validation(...args: any) {
|
|
||||||
|
|
||||||
let script = `
|
|
||||||
(xor
|
|
||||||
(seq
|
|
||||||
(seq
|
|
||||||
(seq
|
|
||||||
(seq
|
|
||||||
(seq
|
|
||||||
(seq
|
|
||||||
(seq
|
|
||||||
(seq
|
|
||||||
(seq
|
|
||||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
|
||||||
(call %init_peer_id% ("getDataSrv" "snapshot_id") [] snapshot_id)
|
|
||||||
)
|
|
||||||
(call %init_peer_id% ("getDataSrv" "node") [] node)
|
|
||||||
)
|
|
||||||
(call %init_peer_id% ("getDataSrv" "relay") [] relay)
|
|
||||||
)
|
|
||||||
(call -relay- ("op" "noop") [])
|
|
||||||
)
|
|
||||||
(call relay ("op" "noop") [])
|
|
||||||
)
|
|
||||||
(xor
|
|
||||||
(call node ("DataProvider" "get_record") [snapshot_id] res)
|
|
||||||
(seq
|
|
||||||
(seq
|
|
||||||
(seq
|
|
||||||
(call relay ("op" "noop") [])
|
|
||||||
(call -relay- ("op" "noop") [])
|
|
||||||
)
|
|
||||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
|
||||||
)
|
|
||||||
(call -relay- ("op" "noop") [])
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(call relay ("op" "noop") [])
|
|
||||||
)
|
|
||||||
(call -relay- ("op" "noop") [])
|
|
||||||
)
|
|
||||||
(xor
|
|
||||||
(call %init_peer_id% ("callbackSrv" "response") [res])
|
|
||||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
|
||||||
)
|
|
||||||
`
|
|
||||||
return callFunction(
|
|
||||||
args,
|
|
||||||
{
|
|
||||||
"functionName" : "get_validation",
|
|
||||||
"returnType" : {
|
|
||||||
"tag" : "primitive"
|
|
||||||
},
|
|
||||||
"argDefs" : [
|
|
||||||
{
|
|
||||||
"name" : "snapshot_id",
|
|
||||||
"argType" : {
|
|
||||||
"tag" : "primitive"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "node",
|
|
||||||
"argType" : {
|
|
||||||
"tag" : "primitive"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "relay",
|
|
||||||
"argType" : {
|
|
||||||
"tag" : "primitive"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"names" : {
|
|
||||||
"relay" : "-relay-",
|
|
||||||
"getDataSrv" : "getDataSrv",
|
|
||||||
"callbackSrv" : "callbackSrv",
|
|
||||||
"responseSrv" : "callbackSrv",
|
|
||||||
"responseFnName" : "response",
|
|
||||||
"errorHandlingSrv" : "errorHandlingSrv",
|
|
||||||
"errorFnName" : "error"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
script
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
69
client-peer/src/index.ts
Normal file
69
client-peer/src/index.ts
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021 Fluence Labs Limited
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Fluence, setLogLevel, FluencePeer } from "@fluencelabs/fluence";
|
||||||
|
import { krasnodar, Node } from "@fluencelabs/fluence-network-environment";
|
||||||
|
import { validate, get_record, get_records, get_record_count } from "./_aqua/demo_validation";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
interface NodeTuple {
|
||||||
|
node_id: string;
|
||||||
|
relay_id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
let poc_topologies: Array<NodeTuple> = [
|
||||||
|
{
|
||||||
|
"node_id": "12D3KooWFCY8xqebtZqNeiA5took71bUNAedzCCDuCuM1QTdTbWT",
|
||||||
|
"relay_id": "12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e"
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
console.log("Welcome to Snapshot PoC demo.");
|
||||||
|
// setLogLevel('DEBUG');
|
||||||
|
|
||||||
|
await Fluence.start({ connectTo: krasnodar[2] });
|
||||||
|
console.log(
|
||||||
|
"created a Fluence client %s with relay %s",
|
||||||
|
Fluence.getStatus().peerId,
|
||||||
|
Fluence.getStatus().relayPeerId
|
||||||
|
);
|
||||||
|
|
||||||
|
let rec_count = await get_record_count(poc_topologies[0].node_id, poc_topologies[0].relay_id);
|
||||||
|
console.log("record count: ", rec_count);
|
||||||
|
|
||||||
|
let records = await get_records(poc_topologies[0].node_id, poc_topologies[0].relay_id);
|
||||||
|
if (records.stderr.length > 0) {
|
||||||
|
console.log("Records fetch error: ", records.stderr);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log("record length: ", records.stdout.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
.then(() => process.exit(0))
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
62
client-peer/tsconfig.json
Normal file
62
client-peer/tsconfig.json
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
||||||
|
/* Basic Options */
|
||||||
|
// "incremental": true, /* Enable incremental compilation */
|
||||||
|
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
||||||
|
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
||||||
|
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||||
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||||
|
// "checkJs": true, /* Report errors in .js files. */
|
||||||
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||||
|
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||||
|
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||||
|
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
||||||
|
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||||
|
"outDir": "./dist", /* Redirect output structure to the directory. */
|
||||||
|
"rootDir": ".", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||||
|
// "composite": true, /* Enable project compilation */
|
||||||
|
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||||
|
// "removeComments": true, /* Do not emit comments to output. */
|
||||||
|
// "noEmit": true, /* Do not emit outputs. */
|
||||||
|
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||||
|
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||||
|
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||||
|
/* Strict Type-Checking Options */
|
||||||
|
"strict": true, /* Enable all strict type-checking options. */
|
||||||
|
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||||
|
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||||
|
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||||
|
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||||
|
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||||
|
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||||
|
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||||
|
/* Additional Checks */
|
||||||
|
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||||
|
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||||
|
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||||
|
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||||
|
/* Module Resolution Options */
|
||||||
|
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||||
|
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||||
|
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||||
|
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||||
|
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||||
|
// "types": [], /* Type declaration files to be included in compilation. */
|
||||||
|
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||||
|
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||||
|
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||||
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||||
|
/* Source Map Options */
|
||||||
|
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||||
|
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||||
|
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||||
|
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||||
|
/* Experimental Options */
|
||||||
|
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||||
|
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||||
|
/* Advanced Options */
|
||||||
|
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
||||||
|
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user