From 509e5f4ead69ab02b96ff7fb20391493048c9e5b Mon Sep 17 00:00:00 2001 From: boneyard93501 <4523011+boneyard93501@users.noreply.github.com> Date: Thu, 30 Sep 2021 14:06:59 -0500 Subject: [PATCH] init aqua inerfaces and funcs --- aqua/snapshot.aqua | 36 ++++++++++++++++++++++++++++++++++++ data/snapshot.db | Bin 8192 -> 8192 bytes src/index.ts | 2 +- src/local_db.ts | 11 +++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 aqua/snapshot.aqua diff --git a/aqua/snapshot.aqua b/aqua/snapshot.aqua new file mode 100644 index 0000000..9998a16 --- /dev/null +++ b/aqua/snapshot.aqua @@ -0,0 +1,36 @@ +data PVResponse: + peer_id: string + timestamp: u64 + eip_validation: bool + ts_validation: bool + +data DBResponse: + snapshot_id: u64 + +service ProVoValidation("eip_validation"): + eip_validation(eip_str: string, peer_id: string) + +service DataProvider(""): + get_records() + get_record(snapshot_id: u64) + + +func validate(relay: string, peer:string, eip712_json: string) -> PVResponse { + on peer via relay: + result <- ProVoValidation.eip_validation(eip712_json, peer) + <- result +} + + +func get_record(relay:string, peer:string, snapshot_id: u64) -> DBResponse: + on peer via relay: + result <- DataProvider.get_record(snapshot_id) + <- result + + +func get_records(relay:string, peer:string) -> []DBResponse: + on peer via relay: + result <- DataProvider.get_records() + <- result + + diff --git a/data/snapshot.db b/data/snapshot.db index 69bc9579fd441c4faad27bb62b174d92f8105c6e..dce303520bb70d94a8529ce0328ab7e6bd2bd2f9 100644 GIT binary patch delta 101 zcmZp0XmFU2#j=ZmZ`Wo)0UtiDCTB)=aamc$mdMF_`J5*4YfskUmz(U(FR7c9lb@u+ sr2qv5si{TrnJEe-sTCy%(UQ#E)Z&uF+=9uI`4uN`<(J=lm0w!`0GIh3`Tzg` delta 82 zcmZp0XmFU2#j=@!Z}Y}NS3a&LFGhB8Sy{%G^vOr~oF=pK>r6J_m!Is%FC|uzT2Z3I hr2qv5si{TrnJEgBYxyN7Pvuvfyp>;J^A&y_0RY;57uo;- diff --git a/src/index.ts b/src/index.ts index d870cac..61c89cd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ import { ethers } from "ethers"; import { TypedDataUtils } from 'ethers-eip712'; // https://github.com/0xsequence/ethers-eip712 import { eip_validation, Response } from "./eip_processor"; -import { get_db, create_table, insert_event } from './local_db'; +import { get_db, create_table, insert_event, DBRecord } from './local_db'; var sqlite3 = require('sqlite3').verbose(); diff --git a/src/local_db.ts b/src/local_db.ts index 4df8918..8583670 100644 --- a/src/local_db.ts +++ b/src/local_db.ts @@ -6,6 +6,17 @@ const sqlite3 = sqlite.verbose(); import { Response } from './eip_processor'; +export interface DBRecord { + snapshot_id: number; + event_address: string; + event_signature: string; + eip712_doc: string; + peer_id: string; + timestamp: number; + eip_validation: boolean; + ts_validation: boolean; + signed_response: string; +} // db handler export function get_db(db_path: any): sqlite.Database {