update readme, cleanup comments

This commit is contained in:
boneyard93501
2021-10-24 19:10:23 -05:00
parent 2c59a94479
commit 4f163db19b
7 changed files with 108 additions and 83 deletions

View File

@ -17,8 +17,8 @@ import {
// Services
export interface EIPValidatorDef {
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_string: (eip_str: string, peer_id: string, callParams: CallParams<'eip_str' | 'peer_id'>) => { stderr: string; stdout: { signature: string; validation: { eip_validation: boolean; peer_id: string; timestamp: number; ts_validation: boolean; }; }; } | Promise<{ stderr: string; stdout: { signature: string; validation: { eip_validation: boolean; peer_id: string; timestamp: number; ts_validation: boolean; }; }; }>;
eip712_validation_url: (eip_str: string, peer_id: string, callParams: CallParams<'eip_str' | 'peer_id'>) => { stderr: string; stdout: { signature: string; validation: { eip_validation: boolean; peer_id: string; timestamp: number; ts_validation: boolean; }; }; } | Promise<{ stderr: string; stdout: { signature: string; validation: { eip_validation: boolean; peer_id: string; timestamp: number; ts_validation: boolean; }; }; }>;
}
export function registerEIPValidator(service: EIPValidatorDef): void;
export function registerEIPValidator(serviceId: string, service: EIPValidatorDef): void;
@ -338,9 +338,9 @@ export function delete_records(...args: any) {
}
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 type ValidateResult = { stderr: string; stdout: { signature: string; validation: { eip_validation: boolean; peer_id: string; timestamp: number; ts_validation: boolean; }; }; }
export function validate(eip712_url: string, node: string, relay: string, config?: {ttl?: number}): Promise<ValidateResult>;
export function validate(peer: FluencePeer, eip712_url: string, node: string, relay: string, config?: {ttl?: number}): Promise<ValidateResult>;
export function validate(...args: any) {
let script = `

View File

@ -61,26 +61,22 @@ async function main() {
console.log("Lets validate proposal %s, which is old and should fail.", EIP712_URL);
let doc_val = await validate(EIP712_URL, poc_topologies[0].node_id, poc_topologies[0].relay_id);
// if (doc_val.stderr.length > 0) {}
console.log("doc val: ", doc_val);
rec_count = await get_record_count(poc_topologies[0].node_id, poc_topologies[0].relay_id);
console.log("record count: ", rec_count);
console.log("signed eip validation result: ", doc_val);
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);
console.log("We should have one record in the node db but do not: ", records.stderr);
}
else {
console.log("record length: ", records.stdout.length);
console.log("We should have one record in the node db and have %s record(s).", records.stdout.length);
}
// verify test
// const address = ethers.utils.verifyMessage(resp_str, signed_response);
// console.log("verify signature. peer_id: ", peer_id, " verified addr: ", address, " equal: ", peer_id === address);
// console.log(resp_str);
console.log("We know from the EIP document that the snapshot is 9278489, which i sued as a unique key in the sqlite db.")
console.log(" and we can call individual recirds by snapshot:")
let good_record = await get_record(9278489, poc_topologies[0].node_id, poc_topologies[0].relay_id);
let bad_record = await get_record(92784890, poc_topologies[0].node_id, poc_topologies[0].relay_id);
console.log("result for call with 9278489: ", good_record);
console.log("result for call with bad 92784890: ", bad_record);
return;
}

View File

@ -1,47 +0,0 @@
/*
* 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, KeyPair } from "@fluencelabs/fluence";
import { krasnodar } from "@fluencelabs/fluence-network-environment";
import { validate } from "./_aqua/demo_validation";
const NODE_ID: string = "12D3KooWFCY8xqebtZqNeiA5took71bUNAedzCCDuCuM1QTdTbWT";
const RELAY_ID: string = krasnodar[0].peerId;
const EIP_URL: string = "https://ipfs.fleek.co/ipfs/QmWGzSQFm57ohEq2ATw4UNHWmYU2HkMjtedcNLodYywpmS";
async function main() {
await Fluence.start({
connectTo: krasnodar[0],
});
console.log("application started");
console.log("peer id is: ", Fluence.getStatus().peerId);
console.log("relay is: ", Fluence.getStatus().relayPeerId, "\n\n");
const result = await validate(EIP_URL, NODE_ID, RELAY_ID);
console.log("validation result: ", result);
await Fluence.stop();
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error('something went wrong: ', error);
process.exit(1);
});