From d67cf4e77f75360430d92ace2455e6f5fb1fe787 Mon Sep 17 00:00:00 2001 From: prin-r Date: Mon, 18 May 2020 01:04:58 +0700 Subject: [PATCH 01/38] add title for button --- scan/src/components/Packet.re | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scan/src/components/Packet.re b/scan/src/components/Packet.re index 5c3cdabdc8..775e775e0b 100644 --- a/scan/src/components/Packet.re +++ b/scan/src/components/Packet.re @@ -50,7 +50,7 @@ let make = (~packet: IBCSub.packet_t, ~oracleScriptID: ID.OracleScript.t) => {
- +
; switch (outputKVsOpt) { | Some(_) => calldataHeadRender @@ -140,7 +140,7 @@ let make = (~packet: IBCSub.packet_t, ~oracleScriptID: ID.OracleScript.t) => {
- +
; switch (outputKVsOpt) { | Some(_) => resultHeadRender From c96a5289ef1643644531d53200842fab390161ff Mon Sep 17 00:00:00 2001 From: prin-r Date: Mon, 18 May 2020 01:05:33 +0700 Subject: [PATCH 02/38] remove proof text --- scan/src/components/RequestProof.re | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/scan/src/components/RequestProof.re b/scan/src/components/RequestProof.re index ee779c69b1..7b1f8239df 100644 --- a/scan/src/components/RequestProof.re +++ b/scan/src/components/RequestProof.re @@ -62,27 +62,16 @@ let make = (~requestID: ID.Request.t) => { color=Colors.gray6 /> - -
- JsBuffer.toHex} - weight=Text.Medium - color=Colors.gray7 - block=true - code=true - ellipsis=true - /> -
-
- React.null
- + + +
From d966e99b3a780777bd499f1afde601ba4c437e0b Mon Sep 17 00:00:00 2001 From: prin-r Date: Mon, 18 May 2020 01:05:47 +0700 Subject: [PATCH 03/38] add title for button --- scan/src/components/TxIndexPageTable.re | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scan/src/components/TxIndexPageTable.re b/scan/src/components/TxIndexPageTable.re index e7a6112391..c7446c4c47 100644 --- a/scan/src/components/TxIndexPageTable.re +++ b/scan/src/components/TxIndexPageTable.re @@ -90,7 +90,7 @@ let renderRequest = (request: TxSub.Msg.Request.t) => {
- +
{switch (calldataKVsOpt) { From 54f2e6e81ab43b4f2d843fcd13867209eba460b9 Mon Sep 17 00:00:00 2001 From: prin-r Date: Mon, 18 May 2020 01:07:14 +0700 Subject: [PATCH 04/38] add title --- scan/src/components/buttons/CopyButton.re | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scan/src/components/buttons/CopyButton.re b/scan/src/components/buttons/CopyButton.re index 62b62324ab..70b7314531 100644 --- a/scan/src/components/buttons/CopyButton.re +++ b/scan/src/components/buttons/CopyButton.re @@ -16,10 +16,10 @@ module Styles = { }; [@react.component] -let make = (~data) => { +let make = (~data, ~title) => {
{Copy.copy(data |> JsBuffer.toHex(~with0x=false))}}> - +
; }; From 12f49f665202de7f35a15a18d75010395dde8d44 Mon Sep 17 00:00:00 2001 From: prin-r Date: Mon, 18 May 2020 01:07:48 +0700 Subject: [PATCH 05/38] remove proof text --- .../oracle-script/OracleScriptExecuteProof.re | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/scan/src/components/oracle-script/OracleScriptExecuteProof.re b/scan/src/components/oracle-script/OracleScriptExecuteProof.re index d398d2af10..491bdf49c8 100644 --- a/scan/src/components/oracle-script/OracleScriptExecuteProof.re +++ b/scan/src/components/oracle-script/OracleScriptExecuteProof.re @@ -49,13 +49,12 @@ let make = (~id: ID.Request.t) => {
{switch (proofOpt) { | Some(proof) => -
- JsBuffer.toHex} - height={Text.Px(15)} - code=true - ellipsis=true - /> +
+ + + + +
| None =>
@@ -63,17 +62,5 @@ let make = (~id: ID.Request.t) => {
}}
- - {switch (proofOpt) { - | Some(proof) => -
- -
- - - -
- | None => React.null - }} ; }; From 83c43750540db9fe69236342925dc63ddd3f7b5a Mon Sep 17 00:00:00 2001 From: prin-r Date: Mon, 18 May 2020 01:08:25 +0700 Subject: [PATCH 06/38] add title --- scan/src/pages/RequestIndexPage.re | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scan/src/pages/RequestIndexPage.re b/scan/src/pages/RequestIndexPage.re index bb3768932f..9aad3956d3 100644 --- a/scan/src/pages/RequestIndexPage.re +++ b/scan/src/pages/RequestIndexPage.re @@ -208,7 +208,7 @@ let make = (~reqID) => color=Colors.gray6 /> - +
@@ -272,7 +272,7 @@ let make = (~reqID) => color=Colors.gray6 /> - + From e3cc1964a1c680e19d6a5153f11a9d54c47a58a8 Mon Sep 17 00:00:00 2001 From: prin-r Date: Mon, 18 May 2020 01:37:35 +0700 Subject: [PATCH 07/38] add utils for create non evm proof --- scan/src/utils/proof/Solana.re | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 scan/src/utils/proof/Solana.re diff --git a/scan/src/utils/proof/Solana.re b/scan/src/utils/proof/Solana.re new file mode 100644 index 0000000000..42e6e7daf5 --- /dev/null +++ b/scan/src/utils/proof/Solana.re @@ -0,0 +1,29 @@ +// TODO: No need for this because it doesn't make sense +let rev: string => string = [%bs.raw + {| +function(x) { + return x.match(/.{1,2}/g).reverse().join("") +} + |} +]; + +// TODO: No need for this because it doesn't make sense +let toSolanaCommand: string => string = [%bs.raw + {| + function(x) { + return ("02" + Number((x.length)>>1).toString(16).padStart(8,"0").match(/.{1,2}/g).reverse().join("")) + x; + } + |} +]; + +// TODO: Replace this mocking format by the real +let createProofFromResult = result => { + // Just a mock padding + "00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000580" + // Validator pubkey is [2u8; 32] + // TODO: Use real validator + ++ "0202020202020202020202020202020202020202020202020202020202020202" + ++ (result |> JsBuffer.toHex(~with0x=false) |> rev) + |> toSolanaCommand + |> JsBuffer.fromHex; +}; From cd6ce916186973dcbc9c71df7d27bf1abdc7171d Mon Sep 17 00:00:00 2001 From: prin-r Date: Mon, 18 May 2020 01:37:57 +0700 Subject: [PATCH 08/38] use result to make proof --- scan/src/components/RequestProof.re | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scan/src/components/RequestProof.re b/scan/src/components/RequestProof.re index 7b1f8239df..2021b5d27b 100644 --- a/scan/src/components/RequestProof.re +++ b/scan/src/components/RequestProof.re @@ -29,7 +29,7 @@ module Styles = { }; [@react.component] -let make = (~requestID: ID.Request.t) => { +let make = (~requestID: ID.Request.t, ~resultOpt: option(JsBuffer.t)) => { let (proofOpt, reload) = ProofHook.get(requestID); let (showProof, setShowProof) = React.useState(_ => false); @@ -71,7 +71,15 @@ let make = (~requestID: ID.Request.t) => { - + result |> Solana.createProofFromResult + | None => "" |> JsBuffer.fromHex + } + } + title="Copy Solana proof" + /> From 78bae115326d473414b8af2618d43a81f794dc65 Mon Sep 17 00:00:00 2001 From: prin-r Date: Mon, 18 May 2020 01:38:14 +0700 Subject: [PATCH 09/38] use result to make proof --- scan/src/components/oracle-script/OracleScriptExecuteProof.re | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scan/src/components/oracle-script/OracleScriptExecuteProof.re b/scan/src/components/oracle-script/OracleScriptExecuteProof.re index 491bdf49c8..bece64965f 100644 --- a/scan/src/components/oracle-script/OracleScriptExecuteProof.re +++ b/scan/src/components/oracle-script/OracleScriptExecuteProof.re @@ -17,7 +17,7 @@ module Styles = { }; [@react.component] -let make = (~id: ID.Request.t) => { +let make = (~id: ID.Request.t, ~result: JsBuffer.t) => { let (proofOpt, reload) = ProofHook.get(id); React.useEffect1( @@ -52,7 +52,7 @@ let make = (~id: ID.Request.t) => {
- + Solana.createProofFromResult} title="Copy Solana proof" />
From ec2cb81c9e531e75a945ee2728a5b3324730e157 Mon Sep 17 00:00:00 2001 From: prin-r Date: Mon, 18 May 2020 01:38:24 +0700 Subject: [PATCH 10/38] use result to make proof --- scan/src/pages/RequestIndexPage.re | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scan/src/pages/RequestIndexPage.re b/scan/src/pages/RequestIndexPage.re index 9aad3956d3..946ba3eb9f 100644 --- a/scan/src/pages/RequestIndexPage.re +++ b/scan/src/pages/RequestIndexPage.re @@ -292,7 +292,7 @@ let make = (~reqID) => }} {numReport >= request.minCount ? { - ; + ; } : React.null} From 5d563c3e70753e027ae7190f5a9ae08439e6c6ea Mon Sep 17 00:00:00 2001 From: prin-r Date: Mon, 18 May 2020 01:38:35 +0700 Subject: [PATCH 11/38] use result to make proof --- .../src/components/oracle-script/OracleScriptExecuteResponse.re | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scan/src/components/oracle-script/OracleScriptExecuteResponse.re b/scan/src/components/oracle-script/OracleScriptExecuteResponse.re index b5283db400..9bafbe18df 100644 --- a/scan/src/components/oracle-script/OracleScriptExecuteResponse.re +++ b/scan/src/components/oracle-script/OracleScriptExecuteResponse.re @@ -108,7 +108,7 @@ let make = (~txResponse: TxCreator.tx_response_t, ~schema: string) => - + ; | Some(request) =>
From 5586e3393ee8ff8f5e120cdb436a3bb670a4769e Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 2 Jun 2020 18:21:28 +0700 Subject: [PATCH 12/38] fix name --- .../src/components/oracle-script/OracleScriptExecuteProof.re | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scan/src/components/oracle-script/OracleScriptExecuteProof.re b/scan/src/components/oracle-script/OracleScriptExecuteProof.re index bece64965f..98457947c4 100644 --- a/scan/src/components/oracle-script/OracleScriptExecuteProof.re +++ b/scan/src/components/oracle-script/OracleScriptExecuteProof.re @@ -52,7 +52,10 @@ let make = (~id: ID.Request.t, ~result: JsBuffer.t) => {
- Solana.createProofFromResult} title="Copy Solana proof" /> + ProofType2.createProofFromResult} + title="Copy proof type2" + />
From aa98da16500563463de0827426db0b8ffe1da435 Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 2 Jun 2020 18:21:28 +0700 Subject: [PATCH 13/38] fix name --- scan/src/components/RequestProof.re | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scan/src/components/RequestProof.re b/scan/src/components/RequestProof.re index 2021b5d27b..3eca4cee5e 100644 --- a/scan/src/components/RequestProof.re +++ b/scan/src/components/RequestProof.re @@ -74,11 +74,11 @@ let make = (~requestID: ID.Request.t, ~resultOpt: option(JsBuffer.t)) => { result |> Solana.createProofFromResult + | Some(result) => result |> ProofType2.createProofFromResult | None => "" |> JsBuffer.fromHex } } - title="Copy Solana proof" + title="Copy proof type2" /> From b8df4bde7ac29809b815abccc901f28fc1a26ae0 Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 2 Jun 2020 18:21:46 +0700 Subject: [PATCH 14/38] fix name --- scan/src/utils/proof/ProofType2.re | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 scan/src/utils/proof/ProofType2.re diff --git a/scan/src/utils/proof/ProofType2.re b/scan/src/utils/proof/ProofType2.re new file mode 100644 index 0000000000..e155e21ec3 --- /dev/null +++ b/scan/src/utils/proof/ProofType2.re @@ -0,0 +1,29 @@ +// TODO: No need for this because it doesn't make sense +let rev: string => string = [%bs.raw + {| +function(x) { + return x.match(/.{1,2}/g).reverse().join("") +} + |} +]; + +// TODO: No need for this because it doesn't make sense +let encodeToCommand: string => string = [%bs.raw + {| + function(x) { + return ("02" + Number((x.length)>>1).toString(16).padStart(8,"0").match(/.{1,2}/g).reverse().join("")) + x; + } + |} +]; + +// TODO: Replace this mocking format by the real +let createProofFromResult = result => { + // Just a mock padding + "00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000580" + // Validator pubkey is [2u8; 32] + // TODO: Use real validator + ++ "0202020202020202020202020202020202020202020202020202020202020202" + ++ (result |> JsBuffer.toHex(~with0x=false) |> rev) + |> encodeToCommand + |> JsBuffer.fromHex; +}; From 0a4a45da429576de381362a2f7cf9030489c411d Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 2 Jun 2020 18:21:57 +0700 Subject: [PATCH 15/38] remove unused --- scan/src/utils/proof/Solana.re | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 scan/src/utils/proof/Solana.re diff --git a/scan/src/utils/proof/Solana.re b/scan/src/utils/proof/Solana.re deleted file mode 100644 index 42e6e7daf5..0000000000 --- a/scan/src/utils/proof/Solana.re +++ /dev/null @@ -1,29 +0,0 @@ -// TODO: No need for this because it doesn't make sense -let rev: string => string = [%bs.raw - {| -function(x) { - return x.match(/.{1,2}/g).reverse().join("") -} - |} -]; - -// TODO: No need for this because it doesn't make sense -let toSolanaCommand: string => string = [%bs.raw - {| - function(x) { - return ("02" + Number((x.length)>>1).toString(16).padStart(8,"0").match(/.{1,2}/g).reverse().join("")) + x; - } - |} -]; - -// TODO: Replace this mocking format by the real -let createProofFromResult = result => { - // Just a mock padding - "00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000580" - // Validator pubkey is [2u8; 32] - // TODO: Use real validator - ++ "0202020202020202020202020202020202020202020202020202020202020202" - ++ (result |> JsBuffer.toHex(~with0x=false) |> rev) - |> toSolanaCommand - |> JsBuffer.fromHex; -}; From c9dbfe0e190ce66667b65234af9ee83177af84f2 Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:49 +0700 Subject: [PATCH 16/38] fix encodeing , add for functions to JsBuffer --- scan/src/utils/proof/NonEVMProof.re | 148 ++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 scan/src/utils/proof/NonEVMProof.re diff --git a/scan/src/utils/proof/NonEVMProof.re b/scan/src/utils/proof/NonEVMProof.re new file mode 100644 index 0000000000..1af727f12e --- /dev/null +++ b/scan/src/utils/proof/NonEVMProof.re @@ -0,0 +1,148 @@ +// TODO: Replace this mock by the real +type request_t = + | Request(RequestSub.t) + | RequestMini(RequestSub.Mini.t); + +type request_packet_t = { + clientID: string, + oracleScriptID: int, + calldata: JsBuffer.t, + askCount: int, + minCount: int, +}; + +type response_packet_t = { + clientID: string, + requestID: int, + ansCount: int, + requestTime: int, + resolveTimne: int, + resolveStatus: int, + result: JsBuffer.t, +}; + +let int8ToHex: int => string = [%bs.raw + {| + function int32ToHex(x) { + return x.toString(16).padStart(2,0) + } +|} +]; + +let int32ToHex: int => string = [%bs.raw + {| + function int32ToHex(x) { + return x.toString(16).padStart(8,0) + } +|} +]; + +let int64ToHex: int => string = [%bs.raw + {| + function int32ToHex(x) { + return x.toString(16).padStart(16,0) + } +|} +]; + +let encodeString = (s: string) => { + let buf = JsBuffer.fromUTF8(s); + JsBuffer.concat([|buf->JsBuffer.byteLength->int32ToHex->JsBuffer.fromHex, buf|]); +}; + +let encodeBuffer = (buf: JsBuffer.t) => + JsBuffer.concat([|buf->JsBuffer.byteLength->int32ToHex->JsBuffer.fromHex, buf|]); + +let encodeRequest = (req: request_packet_t) => { + JsBuffer.concat([| + req.clientID->encodeString, + req.oracleScriptID->int64ToHex->JsBuffer.fromHex, + req.calldata->encodeBuffer, + req.askCount->int64ToHex->JsBuffer.fromHex, + req.minCount->int64ToHex->JsBuffer.fromHex, + |]); +}; + +let encodeResponse = (res: response_packet_t) => { + JsBuffer.concat([| + res.clientID->encodeString, + res.requestID->int64ToHex->JsBuffer.fromHex, + res.ansCount->int64ToHex->JsBuffer.fromHex, + res.requestTime->int64ToHex->JsBuffer.fromHex, + res.resolveTimne->int64ToHex->JsBuffer.fromHex, + res.resolveStatus->int8ToHex->JsBuffer.fromHex, + res.result->encodeBuffer, + |]); +}; + +let resolveStatusToInt = (rs: RequestSub.resolve_status_t) => + switch (rs) { + | Pending => 0 + | Success => 1 + | Failure => 2 + | Unknown => 3 + }; + +let toPackets = (request: request_t) => { + switch (request) { + | Request({ + clientID, + oracleScript: {oracleScriptID: ID(oracleScriptID)}, + calldata, + requestedValidators, + minCount, + id: ID(requestID), + reports, + requestTime, + resolveTime, + resolveStatus, + result, + }) => ( + { + clientID, + oracleScriptID, + calldata, + askCount: requestedValidators |> Belt_Array.length, + minCount, + }, + { + clientID, + requestID, + ansCount: reports |> Belt_Array.length, + requestTime: requestTime |> MomentRe.Moment.toUnix, + resolveTimne: resolveTime |> Belt_Option.getExn |> MomentRe.Moment.toUnix, + resolveStatus: resolveStatus |> resolveStatusToInt, + result: result |> Belt_Option.getExn, + }, + ) + | RequestMini({ + clientID, + oracleScriptID: ID(oracleScriptID), + calldata, + askCount, + minCount, + id: ID(requestID), + reportsCount: ansCount, + requestTime, + resolveTime, + resolveStatus, + result, + }) => ( + {clientID, oracleScriptID, calldata, askCount, minCount}, + { + clientID, + requestID, + ansCount, + requestTime: requestTime |> MomentRe.Moment.toUnix, + resolveTimne: resolveTime |> Belt_Option.getExn |> MomentRe.Moment.toUnix, + resolveStatus: resolveStatus |> resolveStatusToInt, + result: result |> Belt_Option.getExn, + }, + ) + }; +}; + +let createProof = (request: request_t) => { + let (req, res) = request->toPackets; + JsBuffer.concat([|req->encodeRequest, res->encodeResponse|]); +}; From 36d50e3e1a914f2ce662897f5e7ed5911d6bba38 Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:49 +0700 Subject: [PATCH 17/38] fix encodeing , add for functions to JsBuffer --- scan/src/subscriptions/DataSourceRevisionSub.re | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scan/src/subscriptions/DataSourceRevisionSub.re b/scan/src/subscriptions/DataSourceRevisionSub.re index 7c4a459321..ae7228592b 100644 --- a/scan/src/subscriptions/DataSourceRevisionSub.re +++ b/scan/src/subscriptions/DataSourceRevisionSub.re @@ -16,7 +16,7 @@ module RevisionsConfig = [%graphql transaction @bsRecord { txHash: tx_hash @bsDecoder(fn: "GraphQLParser.hash") blockHeight: block_height @bsDecoder(fn: "ID.Block.fromJson") - timestamp @bsDecoder(fn: "GraphQLParser.time") + timestamp @bsDecoder(fn: "GraphQLParser.timeMS") } } } From 27a1bd9d3c09f9db313643a8d169f18677ca8462 Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:49 +0700 Subject: [PATCH 18/38] fix encodeing , add for functions to JsBuffer --- scan/src/subscriptions/UnbondingSub.re | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scan/src/subscriptions/UnbondingSub.re b/scan/src/subscriptions/UnbondingSub.re index 32231ca773..47bf73947d 100644 --- a/scan/src/subscriptions/UnbondingSub.re +++ b/scan/src/subscriptions/UnbondingSub.re @@ -23,7 +23,7 @@ module MultiConfig = [%graphql {| subscription Unbonding($delegator_address: String!, $validator_address: String!) { unbonding_delegations(where: {_and: {delegator_address: {_eq: $delegator_address}, validator_address: {_eq: $validator_address}}}, order_by: {completion_time: asc}) @bsRecord { - completionTime: completion_time @bsDecoder(fn: "GraphQLParser.time") + completionTime: completion_time @bsDecoder(fn: "GraphQLParser.timeMS") balance @bsDecoder(fn: "GraphQLParser.coin") } } From 30095c9983db03d2609ace1367773d86a7774958 Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:50 +0700 Subject: [PATCH 19/38] fix encodeing , add for functions to JsBuffer --- scan/src/subscriptions/BlockSub.re | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scan/src/subscriptions/BlockSub.re b/scan/src/subscriptions/BlockSub.re index e64aabf53b..b771a4e592 100644 --- a/scan/src/subscriptions/BlockSub.re +++ b/scan/src/subscriptions/BlockSub.re @@ -43,7 +43,7 @@ module MultiConfig = [%graphql operatorAddress: operator_address @bsDecoder(fn: "Address.fromBech32") moniker } - timestamp @bsDecoder(fn: "GraphQLParser.time") + timestamp @bsDecoder(fn: "GraphQLParser.timeMS") transactions_aggregate @bsRecord { aggregate @bsRecord { count @bsDecoder(fn: "Belt_Option.getExn") @@ -65,7 +65,7 @@ module MultiConsensusAddressConfig = [%graphql operatorAddress: operator_address @bsDecoder(fn: "Address.fromBech32") moniker } - timestamp @bsDecoder(fn: "GraphQLParser.time") + timestamp @bsDecoder(fn: "GraphQLParser.timeMS") transactions_aggregate @bsRecord { aggregate @bsRecord { count @bsDecoder(fn: "Belt_Option.getExn") @@ -87,7 +87,7 @@ module SingleConfig = [%graphql operatorAddress: operator_address @bsDecoder(fn: "Address.fromBech32") moniker } - timestamp @bsDecoder(fn: "GraphQLParser.time") + timestamp @bsDecoder(fn: "GraphQLParser.timeMS") transactions_aggregate @bsRecord { aggregate @bsRecord { count @bsDecoder(fn: "Belt_Option.getExn") From 92774f4a314c3fd0ff6f569ca0f7efc6b3aab288 Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:50 +0700 Subject: [PATCH 20/38] fix encodeing , add for functions to JsBuffer --- scan/src/subscriptions/RequestSub.re | 131 ++++++++++++++++++--------- 1 file changed, 89 insertions(+), 42 deletions(-) diff --git a/scan/src/subscriptions/RequestSub.re b/scan/src/subscriptions/RequestSub.re index 9bf7b1731e..8c01be2ebe 100644 --- a/scan/src/subscriptions/RequestSub.re +++ b/scan/src/subscriptions/RequestSub.re @@ -1,6 +1,20 @@ open ValidatorSub.Mini; open TxSub.Mini; +type resolve_status_t = + | Pending + | Success + | Failure + | Unknown; + +let parseResolveStatus = x => + switch (x) { + | "Pending" => Pending + | "Success" => Success + | "Failure" => Failure + | _ => Unknown + }; + module Mini = { open TxSub.Mini; @@ -17,30 +31,37 @@ module Mini = { type request_internal = { id: ID.Request.t, requester: Address.t, + clientID: string, + requestTime: MomentRe.Moment.t, + resolveTime: option(MomentRe.Moment.t), + calldata: JsBuffer.t, oracleScript: oracle_script_internal_t, transaction: TxSub.Mini.t, reportsAggregate: aggregate_wrapper_intenal_t, minCount: int, - requestedValidatorsAgregate: aggregate_wrapper_intenal_t, + resolveStatus: resolve_status_t, + requestedValidatorsAggregate: aggregate_wrapper_intenal_t, result: option(JsBuffer.t), }; type t = { id: ID.Request.t, requester: Address.t, + clientID: string, + requestTime: MomentRe.Moment.t, + resolveTime: option(MomentRe.Moment.t), + calldata: JsBuffer.t, oracleScriptID: ID.OracleScript.t, oracleScriptName: string, txHash: Hash.t, blockHeight: ID.Block.t, - timestamp: MomentRe.Moment.t, reportsCount: int, minCount: int, askCount: int, + resolveStatus: resolve_status_t, result: option(JsBuffer.t), }; - let optionBuffer = Belt_Option.map(_, GraphQLParser.buffer); - module MultiMiniByDataSourceConfig = [%graphql {| subscription RequestsMiniByDataSource($id: bigint!, $limit: Int!, $offset: Int!) { @@ -52,7 +73,11 @@ module Mini = { ) { request @bsRecord { id @bsDecoder(fn: "ID.Request.fromJson") + clientID: client_id + requestTime: request_time @bsDecoder(fn: "GraphQLParser.optionTimeSExn") + resolveTime: resolve_time @bsDecoder(fn: "GraphQLParser.optionTimeS") requester @bsDecoder(fn: "Address.fromBech32") + calldata @bsDecoder(fn: "GraphQLParser.buffer") oracleScript: oracle_script @bsRecord { id @bsDecoder(fn: "ID.OracleScript.fromJson") name @@ -61,20 +86,21 @@ module Mini = { transaction @bsRecord { txHash: tx_hash @bsDecoder(fn: "GraphQLParser.hash") blockHeight: block_height @bsDecoder(fn: "ID.Block.fromJson") - timestamp @bsDecoder(fn: "GraphQLParser.time") + timestamp @bsDecoder(fn: "GraphQLParser.timeMS") } reportsAggregate: reports_aggregate @bsRecord { aggregate @bsRecord { count @bsDecoder(fn: "Belt_Option.getExn") } } + resolveStatus: resolve_status @bsDecoder(fn: "parseResolveStatus") minCount: min_count @bsDecoder(fn: "GraphQLParser.int64") - requestedValidatorsAgregate: requested_validators_aggregate @bsRecord { + requestedValidatorsAggregate: requested_validators_aggregate @bsRecord { aggregate @bsRecord { count @bsDecoder(fn: "Belt_Option.getExn") } } - result @bsDecoder(fn: "optionBuffer") + result @bsDecoder(fn: "GraphQLParser.optionBuffer") } } } @@ -91,7 +117,11 @@ module Mini = { order_by: {id: desc} ) { id @bsDecoder(fn: "ID.Request.fromJson") + clientID: client_id + requestTime: request_time @bsDecoder(fn: "GraphQLParser.optionTimeSExn") + resolveTime: resolve_time @bsDecoder(fn: "GraphQLParser.optionTimeS") requester @bsDecoder(fn: "Address.fromBech32") + calldata @bsDecoder(fn: "GraphQLParser.buffer") oracleScript: oracle_script @bsRecord { id @bsDecoder(fn: "ID.OracleScript.fromJson") name @@ -100,20 +130,21 @@ module Mini = { transaction @bsRecord { txHash: tx_hash @bsDecoder(fn: "GraphQLParser.hash") blockHeight: block_height @bsDecoder(fn: "ID.Block.fromJson") - timestamp @bsDecoder(fn: "GraphQLParser.time") + timestamp @bsDecoder(fn: "GraphQLParser.timeMS") } reportsAggregate: reports_aggregate @bsRecord { aggregate @bsRecord { count @bsDecoder(fn: "Belt_Option.getExn") } } + resolveStatus: resolve_status @bsDecoder(fn: "parseResolveStatus") minCount: min_count @bsDecoder(fn: "GraphQLParser.int64") - requestedValidatorsAgregate: requested_validators_aggregate @bsRecord { + requestedValidatorsAggregate: requested_validators_aggregate @bsRecord { aggregate @bsRecord { count @bsDecoder(fn: "Belt_Option.getExn") } } - result @bsDecoder(fn: "optionBuffer") + result @bsDecoder(fn: "GraphQLParser.optionBuffer") } } |} @@ -124,7 +155,11 @@ module Mini = { subscription RequestsMiniByTxHashCon($tx_hash:bytea!) { requests(where: {tx_hash: {_eq: $tx_hash}}) { id @bsDecoder(fn: "ID.Request.fromJson") + clientID: client_id + requestTime: request_time @bsDecoder(fn: "GraphQLParser.optionTimeSExn") + resolveTime: resolve_time @bsDecoder(fn: "GraphQLParser.optionTimeS") requester @bsDecoder(fn: "Address.fromBech32") + calldata @bsDecoder(fn: "GraphQLParser.buffer") oracle_script @bsRecord { id @bsDecoder(fn: "ID.OracleScript.fromJson") name @@ -133,20 +168,21 @@ module Mini = { transaction @bsRecord { txHash: tx_hash @bsDecoder(fn: "GraphQLParser.hash") blockHeight: block_height @bsDecoder(fn: "ID.Block.fromJson") - timestamp @bsDecoder(fn: "GraphQLParser.time") + timestamp @bsDecoder(fn: "GraphQLParser.timeMS") } reportsAggregate: reports_aggregate @bsRecord { aggregate @bsRecord { count @bsDecoder(fn: "Belt_Option.getExn") } } + resolveStatus: resolve_status @bsDecoder(fn: "parseResolveStatus") minCount: min_count @bsDecoder(fn: "GraphQLParser.int64") - requestedValidatorsAgregate: requested_validators_aggregate @bsRecord { + requestedValidatorsAggregate: requested_validators_aggregate @bsRecord { aggregate @bsRecord { count @bsDecoder(fn: "Belt_Option.getExn") } } - result @bsDecoder(fn: "optionBuffer") + result @bsDecoder(fn: "GraphQLParser.optionBuffer") } } |} @@ -157,28 +193,37 @@ module Mini = { { id, requester, + clientID, + requestTime, + resolveTime, + calldata, oracleScript, - transaction: {txHash, blockHeight, timestamp}, + transaction: {txHash, blockHeight}, reportsAggregate, minCount, - requestedValidatorsAgregate, + resolveStatus, + requestedValidatorsAggregate, result, }, ) => { id, requester, + clientID, + requestTime, + resolveTime, + calldata, oracleScriptID: oracleScript.id, oracleScriptName: oracleScript.name, txHash, blockHeight, - timestamp, reportsCount: reportsAggregate.aggregate->Belt_Option.map(({count}) => count)->Belt_Option.getExn, minCount, askCount: - requestedValidatorsAgregate.aggregate + requestedValidatorsAggregate.aggregate ->Belt_Option.map(({count}) => count) ->Belt_Option.getExn, + resolveStatus, result, }; @@ -199,20 +244,24 @@ module Mini = { { id: y##id, requester: y##requester, + clientID: y##clientID, + requestTime: y##requestTime, + resolveTime: y##resolveTime, + calldata: y##calldata, oracleScriptID: y##oracle_script.id, oracleScriptName: y##oracle_script.name, txHash: y##transaction.txHash, blockHeight: y##transaction.blockHeight, - timestamp: y##transaction.timestamp, reportsCount: y##reportsAggregate.aggregate ->Belt_Option.map(({count}) => count) ->Belt_Option.getExn, minCount: y##minCount, askCount: - y##requestedValidatorsAgregate.aggregate + y##requestedValidatorsAggregate.aggregate ->Belt_Option.map(({count}) => count) ->Belt_Option.getExn, + resolveStatus: y##resolveStatus, result: y##result, } ) @@ -255,20 +304,24 @@ module Mini = { { id: y##id, requester: y##requester, + clientID: y##clientID, + requestTime: y##requestTime, + resolveTime: y##resolveTime, + calldata: y##calldata, oracleScriptID: y##oracleScript.id, oracleScriptName: y##oracleScript.name, txHash: y##transaction.txHash, blockHeight: y##transaction.blockHeight, - timestamp: y##transaction.timestamp, reportsCount: y##reportsAggregate.aggregate ->Belt_Option.map(({count}) => count) ->Belt_Option.getExn, minCount: y##minCount, askCount: - y##requestedValidatorsAgregate.aggregate + y##requestedValidatorsAggregate.aggregate ->Belt_Option.map(({count}) => count) ->Belt_Option.getExn, + resolveStatus: y##resolveStatus, result: y##result, } ) @@ -331,14 +384,11 @@ type raw_data_request_t = { type requested_validator_internal_t = {validator: ValidatorSub.Mini.t}; -type resolve_status_t = - | Pending - | Success - | Failure - | Unknown; - type t = { id: ID.Request.t, + clientID: string, + requestTime: MomentRe.Moment.t, + resolveTime: option(MomentRe.Moment.t), oracleScript: oracle_script_internal_t, calldata: JsBuffer.t, requestedValidators: array(requested_validator_internal_t), @@ -352,20 +402,14 @@ type t = { result: option(JsBuffer.t), }; -let optionBuffer = Belt_Option.map(_, GraphQLParser.buffer); -let parseResolveStatus = x => - switch (x) { - | "Pending" => Pending - | "Success" => Success - | "Failure" => Failure - | _ => Unknown - }; - module SingleRequestConfig = [%graphql {| subscription Request($id: bigint!) { requests_by_pk(id: $id) @bsRecord { id @bsDecoder(fn: "ID.Request.fromJson") + clientID: client_id + requestTime: request_time @bsDecoder(fn: "GraphQLParser.optionTimeSExn") + resolveTime: resolve_time @bsDecoder(fn: "GraphQLParser.optionTimeS") oracleScript: oracle_script @bsRecord { oracleScriptID:id @bsDecoder(fn: "ID.OracleScript.fromJson") name @@ -386,7 +430,7 @@ module SingleRequestConfig = [%graphql transaction @bsRecord { txHash: tx_hash @bsDecoder(fn: "GraphQLParser.hash") blockHeight: block_height @bsDecoder(fn: "ID.Block.fromJson") - timestamp @bsDecoder(fn: "GraphQLParser.time") + timestamp @bsDecoder(fn: "GraphQLParser.timeMS") } rawDataRequests: raw_data_requests @bsRecord { externalID: external_id @bsDecoder(fn: "GraphQLParser.int64") @@ -401,7 +445,7 @@ module SingleRequestConfig = [%graphql transaction @bsRecord { txHash: tx_hash @bsDecoder(fn: "GraphQLParser.hash") blockHeight: block_height @bsDecoder(fn: "ID.Block.fromJson") - timestamp @bsDecoder(fn: "GraphQLParser.time") + timestamp @bsDecoder(fn: "GraphQLParser.timeMS") } reportDetails: report_details @bsRecord { externalID: external_id @bsDecoder(fn: "GraphQLParser.int64") @@ -413,7 +457,7 @@ module SingleRequestConfig = [%graphql moniker } } - result @bsDecoder(fn: "optionBuffer") + result @bsDecoder(fn: "GraphQLParser.optionBuffer") } } |} @@ -424,6 +468,9 @@ module MultiRequestConfig = [%graphql subscription Requests($limit: Int!, $offset: Int!) { requests(limit: $limit, offset: $offset, order_by: {id: desc}) @bsRecord { id @bsDecoder(fn: "ID.Request.fromJson") + clientID: client_id + requestTime: request_time @bsDecoder(fn: "GraphQLParser.optionTimeSExn") + resolveTime: resolve_time @bsDecoder(fn: "GraphQLParser.optionTimeS") oracleScript: oracle_script @bsRecord { oracleScriptID:id @bsDecoder(fn: "ID.OracleScript.fromJson") name @@ -444,7 +491,7 @@ module MultiRequestConfig = [%graphql transaction @bsRecord { txHash: tx_hash @bsDecoder(fn: "GraphQLParser.hash") blockHeight: block_height @bsDecoder(fn: "ID.Block.fromJson") - timestamp @bsDecoder(fn: "GraphQLParser.time") + timestamp @bsDecoder(fn: "GraphQLParser.timeMS") } rawDataRequests: raw_data_requests @bsRecord { externalID: external_id @bsDecoder(fn: "GraphQLParser.int64") @@ -459,7 +506,7 @@ module MultiRequestConfig = [%graphql transaction @bsRecord { txHash: tx_hash @bsDecoder(fn: "GraphQLParser.hash") blockHeight: block_height @bsDecoder(fn: "ID.Block.fromJson") - timestamp @bsDecoder(fn: "GraphQLParser.time") + timestamp @bsDecoder(fn: "GraphQLParser.timeMS") } reportDetails: report_details @bsRecord { externalID: external_id @bsDecoder(fn: "GraphQLParser.int64") @@ -471,7 +518,7 @@ module MultiRequestConfig = [%graphql moniker } } - result @bsDecoder(fn: "optionBuffer") + result @bsDecoder(fn: "GraphQLParser.optionBuffer") } } |} From 02201a2fa3a784208dc15dc3f820d198a2106ce1 Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:50 +0700 Subject: [PATCH 21/38] fix encodeing , add for functions to JsBuffer --- scan/src/subscriptions/OracleScriptSub.re | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scan/src/subscriptions/OracleScriptSub.re b/scan/src/subscriptions/OracleScriptSub.re index 975528b79a..e134466ba1 100644 --- a/scan/src/subscriptions/OracleScriptSub.re +++ b/scan/src/subscriptions/OracleScriptSub.re @@ -45,7 +45,7 @@ module MultiConfig = [%graphql description schema sourceCodeURL: source_code_url - timestamp: last_updated @bsDecoder(fn: "GraphQLParser.time") + timestamp: last_updated @bsDecoder(fn: "GraphQLParser.timeMS") related_data_sources @bsRecord { dataSourceID: data_source_id @bsDecoder(fn: "ID.DataSource.fromJson") } @@ -64,7 +64,7 @@ module SingleConfig = [%graphql description schema sourceCodeURL: source_code_url - timestamp: last_updated @bsDecoder(fn: "GraphQLParser.time") + timestamp: last_updated @bsDecoder(fn: "GraphQLParser.timeMS") related_data_sources @bsRecord { dataSourceID: data_source_id @bsDecoder(fn: "ID.DataSource.fromJson") } From f9b19bd95bf41e1f879122d67125a2913958a0e7 Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:50 +0700 Subject: [PATCH 22/38] fix encodeing , add for functions to JsBuffer --- scan/src/subscriptions/DataSourceSub.re | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scan/src/subscriptions/DataSourceSub.re b/scan/src/subscriptions/DataSourceSub.re index a0ecbfb4b3..b159f154ba 100644 --- a/scan/src/subscriptions/DataSourceSub.re +++ b/scan/src/subscriptions/DataSourceSub.re @@ -16,7 +16,7 @@ module MultiConfig = [%graphql name description executable @bsDecoder(fn: "GraphQLParser.buffer") - timestamp: last_updated @bsDecoder(fn: "GraphQLParser.time") + timestamp: last_updated @bsDecoder(fn: "GraphQLParser.timeMS") } } |} @@ -31,7 +31,7 @@ module SingleConfig = [%graphql name description executable @bsDecoder(fn: "GraphQLParser.buffer") - timestamp: last_updated @bsDecoder(fn: "GraphQLParser.time") + timestamp: last_updated @bsDecoder(fn: "GraphQLParser.timeMS") } }, |} From b13cd1f9bc04d0b8e1e0d59a386528ae65fa5876 Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:50 +0700 Subject: [PATCH 23/38] fix encodeing , add for functions to JsBuffer --- scan/src/subscriptions/TxSub.re | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scan/src/subscriptions/TxSub.re b/scan/src/subscriptions/TxSub.re index eb9cc771c5..6001e92682 100644 --- a/scan/src/subscriptions/TxSub.re +++ b/scan/src/subscriptions/TxSub.re @@ -1170,7 +1170,7 @@ module SingleConfig = [%graphql gasLimit: gas_limit @bsDecoder(fn: "GraphQLParser.int64") gasUsed : gas_used @bsDecoder(fn: "GraphQLParser.int64") sender @bsDecoder(fn: "Address.fromBech32") - timestamp @bsDecoder(fn: "GraphQLParser.time") + timestamp @bsDecoder(fn: "GraphQLParser.timeMS") messages @bsDecoder(fn: "Msg.decodeActions") rawLog: raw_log } @@ -1189,7 +1189,7 @@ module MultiConfig = [%graphql gasLimit: gas_limit @bsDecoder(fn: "GraphQLParser.int64") gasUsed : gas_used @bsDecoder(fn: "GraphQLParser.int64") sender @bsDecoder(fn: "Address.fromBech32") - timestamp @bsDecoder(fn: "GraphQLParser.time") + timestamp @bsDecoder(fn: "GraphQLParser.timeMS") messages @bsDecoder(fn: "Msg.decodeActions") rawLog: raw_log } @@ -1208,7 +1208,7 @@ module MultiByHeightConfig = [%graphql gasLimit: gas_limit @bsDecoder(fn: "GraphQLParser.int64") gasUsed : gas_used @bsDecoder(fn: "GraphQLParser.int64") sender @bsDecoder(fn: "Address.fromBech32") - timestamp @bsDecoder(fn: "GraphQLParser.time") + timestamp @bsDecoder(fn: "GraphQLParser.timeMS") messages @bsDecoder(fn: "Msg.decodeActions") rawLog: raw_log } @@ -1232,7 +1232,7 @@ module MultiBySenderConfig = [%graphql gasLimit: gas_limit @bsDecoder(fn: "GraphQLParser.int64") gasUsed : gas_used @bsDecoder(fn: "GraphQLParser.int64") sender @bsDecoder(fn: "Address.fromBech32") - timestamp @bsDecoder(fn: "GraphQLParser.time") + timestamp @bsDecoder(fn: "GraphQLParser.timeMS") messages @bsDecoder(fn: "Msg.decodeActions") rawLog: raw_log } From 7fa65e66451935a36a08f9762388a67c5d718c7b Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:50 +0700 Subject: [PATCH 24/38] fix encodeing , add for functions to JsBuffer --- scan/src/subscriptions/GraphQLParser.re | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/scan/src/subscriptions/GraphQLParser.re b/scan/src/subscriptions/GraphQLParser.re index 9b52592d94..bb2642fa11 100644 --- a/scan/src/subscriptions/GraphQLParser.re +++ b/scan/src/subscriptions/GraphQLParser.re @@ -7,7 +7,16 @@ let buffer = json => |> Js.String.substr(~from=2) |> JsBuffer.fromHex; -let time = json => { +let timeS = json => { + json + |> Js.Json.decodeNumber + |> Belt.Option.getExn + |> int_of_float + |> MomentRe.momentWithUnix + |> MomentRe.Moment.defaultUtc; +}; + +let timeMS = json => { json |> Js.Json.decodeNumber |> Belt.Option.getExn @@ -15,6 +24,14 @@ let time = json => { |> MomentRe.Moment.defaultUtc; }; +let optionBuffer = Belt_Option.map(_, buffer); + +let optionTimeMS = Belt_Option.map(_, timeMS); + +let optionTimeS = Belt_Option.map(_, timeS); + +let optionTimeSExn = timeSOpt => timeSOpt |> Belt_Option.getExn |> timeS; + let bool = json => json |> Js.Json.decodeBoolean |> Belt.Option.getExn; let hash = json => From 279c56d01a72b8c5a4043c99d3dfd284944571ed Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:50 +0700 Subject: [PATCH 25/38] fix encodeing , add for functions to JsBuffer --- scan/src/subscriptions/OracleScriptRevisionSub.re | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scan/src/subscriptions/OracleScriptRevisionSub.re b/scan/src/subscriptions/OracleScriptRevisionSub.re index 02ce6fc09d..2a67dc931e 100644 --- a/scan/src/subscriptions/OracleScriptRevisionSub.re +++ b/scan/src/subscriptions/OracleScriptRevisionSub.re @@ -16,7 +16,7 @@ module RevisionsConfig = [%graphql transaction @bsRecord { txHash: tx_hash @bsDecoder(fn: "GraphQLParser.hash") blockHeight: block_height @bsDecoder(fn: "ID.Block.fromJson") - timestamp @bsDecoder(fn: "GraphQLParser.time") + timestamp @bsDecoder(fn: "GraphQLParser.timeMS") } } } From f06ff835b24c7148f6ce70110410b7bc16e030e5 Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:50 +0700 Subject: [PATCH 26/38] fix encodeing , add for functions to JsBuffer --- scan/src/components/buttons/CopyButton.re | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scan/src/components/buttons/CopyButton.re b/scan/src/components/buttons/CopyButton.re index 70b7314531..309733d21e 100644 --- a/scan/src/components/buttons/CopyButton.re +++ b/scan/src/components/buttons/CopyButton.re @@ -1,12 +1,12 @@ module Styles = { open Css; - let button = + let button = w => style([ backgroundColor(Colors.blue1), padding2(~h=`px(8), ~v=`px(4)), display(`flex), - width(`px(103)), + width(`px(w)), borderRadius(`px(6)), cursor(`pointer), boxShadow(Shadow.box(~x=`zero, ~y=`px(2), ~blur=`px(4), rgba(20, 32, 184, 0.2))), @@ -16,8 +16,10 @@ module Styles = { }; [@react.component] -let make = (~data, ~title) => { -
{Copy.copy(data |> JsBuffer.toHex(~with0x=false))}}> +let make = (~data, ~title, ~width=105) => { +
{Copy.copy(data |> JsBuffer.toHex(~with0x=false))}}> From bcbf85f2906554beadfdeebac3398240c9110095 Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:51 +0700 Subject: [PATCH 27/38] fix encodeing , add for functions to JsBuffer --- .../src/components/oracle-script/OracleScriptExecuteResponse.re | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scan/src/components/oracle-script/OracleScriptExecuteResponse.re b/scan/src/components/oracle-script/OracleScriptExecuteResponse.re index 9bafbe18df..bb18405902 100644 --- a/scan/src/components/oracle-script/OracleScriptExecuteResponse.re +++ b/scan/src/components/oracle-script/OracleScriptExecuteResponse.re @@ -108,7 +108,7 @@ let make = (~txResponse: TxCreator.tx_response_t, ~schema: string) =>
- + ; | Some(request) =>
From 638b8b3f26b1408817a76e496e34e7d30cb8311c Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:51 +0700 Subject: [PATCH 28/38] fix encodeing , add for functions to JsBuffer --- .../oracle-script/OracleScriptExecuteProof.re | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scan/src/components/oracle-script/OracleScriptExecuteProof.re b/scan/src/components/oracle-script/OracleScriptExecuteProof.re index 98457947c4..dadccf30a0 100644 --- a/scan/src/components/oracle-script/OracleScriptExecuteProof.re +++ b/scan/src/components/oracle-script/OracleScriptExecuteProof.re @@ -17,7 +17,7 @@ module Styles = { }; [@react.component] -let make = (~id: ID.Request.t, ~result: JsBuffer.t) => { +let make = (~id: ID.Request.t, ~requestOpt: option(RequestSub.Mini.t)) => { let (proofOpt, reload) = ProofHook.get(id); React.useEffect1( @@ -47,19 +47,22 @@ let make = (~id: ID.Request.t, ~result: JsBuffer.t) => { height={Text.Px(15)} />
- {switch (proofOpt) { - | Some(proof) => + {switch (proofOpt, requestOpt) { + | (Some(proof), Some({result: Some(_)})) =>
- + ProofType2.createProofFromResult} - title="Copy proof type2" + data={ + NonEVMProof.RequestMini(requestOpt->Belt_Option.getExn)->NonEVMProof.createProof + } + title="Copy non-EVM proof" + width=130 />
- | None => + | _ =>
From d2163e20f7d9f86cda0aa2ce36d8431f6df0a61e Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:51 +0700 Subject: [PATCH 29/38] fix encodeing , add for functions to JsBuffer --- scan/src/components/oracle-script/OracleScriptRequestTable.re | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scan/src/components/oracle-script/OracleScriptRequestTable.re b/scan/src/components/oracle-script/OracleScriptRequestTable.re index 01fabb89ba..8558fbc491 100644 --- a/scan/src/components/oracle-script/OracleScriptRequestTable.re +++ b/scan/src/components/oracle-script/OracleScriptRequestTable.re @@ -99,7 +99,7 @@ let make = (~oracleScriptID: ID.OracleScript.t) => {requests - ->Belt_Array.map(({id, requester, timestamp, blockHeight, txHash}) => { + ->Belt_Array.map(({id, requester, requestTime, blockHeight, txHash}) => { Hash.toHex(~upper=true)}> @@ -110,7 +110,7 @@ let make = (~oracleScriptID: ID.OracleScript.t) =>
- + From b977426ff3faa0629c29cc27fa178df1166054d8 Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:51 +0700 Subject: [PATCH 30/38] fix encodeing , add for functions to JsBuffer --- scan/src/components/data-source/DataSourceRequestTable.re | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scan/src/components/data-source/DataSourceRequestTable.re b/scan/src/components/data-source/DataSourceRequestTable.re index 88b2a0bce4..1c5a7e008c 100644 --- a/scan/src/components/data-source/DataSourceRequestTable.re +++ b/scan/src/components/data-source/DataSourceRequestTable.re @@ -96,7 +96,7 @@ let make = (~dataSourceID: ID.DataSource.t) => {requests ->Belt_Array.map( - ({id, oracleScriptID, oracleScriptName, timestamp, blockHeight, txHash}) => { + ({id, oracleScriptID, oracleScriptName, requestTime, blockHeight, txHash}) => { Hash.toHex(~upper=true)}> @@ -114,7 +114,7 @@ let make = (~dataSourceID: ID.DataSource.t) => - + From 9c58685222378b2a6eecf9c5a8d693343bda4c5e Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:51 +0700 Subject: [PATCH 31/38] fix encodeing , add for functions to JsBuffer --- scan/src/components/RequestProof.re | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scan/src/components/RequestProof.re b/scan/src/components/RequestProof.re index 3eca4cee5e..e8a39c58f5 100644 --- a/scan/src/components/RequestProof.re +++ b/scan/src/components/RequestProof.re @@ -29,7 +29,7 @@ module Styles = { }; [@react.component] -let make = (~requestID: ID.Request.t, ~resultOpt: option(JsBuffer.t)) => { +let make = (~requestID: ID.Request.t, ~requestOpt: option(RequestSub.t)) => { let (proofOpt, reload) = ProofHook.get(requestID); let (showProof, setShowProof) = React.useState(_ => false); @@ -69,16 +69,18 @@ let make = (~requestID: ID.Request.t, ~resultOpt: option(JsBuffer.t)) => {
- + result |> ProofType2.createProofFromResult - | None => "" |> JsBuffer.fromHex + switch (requestOpt) { + | Some({result: Some(_)}) => + NonEVMProof.Request(requestOpt->Belt_Option.getExn)->NonEVMProof.createProof + | _ => "" |> JsBuffer.fromHex } } - title="Copy proof type2" + title="Copy non-EVM proof" + width=130 /> From 21bf0e43767ba733e8faa64485e20254b3608f02 Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:52 +0700 Subject: [PATCH 32/38] fix encodeing , add for functions to JsBuffer --- scan/src/bindings/JsBuffer.re | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scan/src/bindings/JsBuffer.re b/scan/src/bindings/JsBuffer.re index 08f6a72b9d..07915341a2 100644 --- a/scan/src/bindings/JsBuffer.re +++ b/scan/src/bindings/JsBuffer.re @@ -2,9 +2,16 @@ type t; [@bs.val] external from: array(int) => t = "Buffer.from"; +[@bs.val] external byteLength: t => int = "Buffer.byteLength"; + +[@bs.val] external concat: array(t) => t = "Buffer.concat"; + [@bs.val] external _from: (string, string) => t = "Buffer.from"; + let fromHex = hexstr => hexstr->HexUtils.normalizeHexString->_from("hex"); +let fromUTF8 = utf8 => _from(utf8, "utf-8"); + let fromBase64 = hexstr => _from(hexstr, "base64"); [@bs.send] external _toString: (t, string) => string = "toString"; @@ -22,4 +29,3 @@ let arrayToHex = arr => arr->from->toHex; let hexToArray = hexstr => hexstr->fromHex->toArray; let arrayToBase64 = arr => arr->from->toBase64; let base64ToArray = base64str => base64str->fromBase64->toArray; - From 8d2ab4aa0af414348b25dedd683fbe294d68b75d Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:52:52 +0700 Subject: [PATCH 33/38] fix encodeing , add for functions to JsBuffer --- scan/src/pages/RequestIndexPage.re | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scan/src/pages/RequestIndexPage.re b/scan/src/pages/RequestIndexPage.re index 946ba3eb9f..0d20eea970 100644 --- a/scan/src/pages/RequestIndexPage.re +++ b/scan/src/pages/RequestIndexPage.re @@ -292,7 +292,7 @@ let make = (~reqID) => }} {numReport >= request.minCount ? { - ; + ; } : React.null} From 3ff482b8824a8fec0570a1defd8a137e8dced2cb Mon Sep 17 00:00:00 2001 From: prin-r Date: Tue, 9 Jun 2020 11:53:12 +0700 Subject: [PATCH 34/38] remove unused --- scan/src/utils/proof/ProofType2.re | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 scan/src/utils/proof/ProofType2.re diff --git a/scan/src/utils/proof/ProofType2.re b/scan/src/utils/proof/ProofType2.re deleted file mode 100644 index e155e21ec3..0000000000 --- a/scan/src/utils/proof/ProofType2.re +++ /dev/null @@ -1,29 +0,0 @@ -// TODO: No need for this because it doesn't make sense -let rev: string => string = [%bs.raw - {| -function(x) { - return x.match(/.{1,2}/g).reverse().join("") -} - |} -]; - -// TODO: No need for this because it doesn't make sense -let encodeToCommand: string => string = [%bs.raw - {| - function(x) { - return ("02" + Number((x.length)>>1).toString(16).padStart(8,"0").match(/.{1,2}/g).reverse().join("")) + x; - } - |} -]; - -// TODO: Replace this mocking format by the real -let createProofFromResult = result => { - // Just a mock padding - "00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000580" - // Validator pubkey is [2u8; 32] - // TODO: Use real validator - ++ "0202020202020202020202020202020202020202020202020202020202020202" - ++ (result |> JsBuffer.toHex(~with0x=false) |> rev) - |> encodeToCommand - |> JsBuffer.fromHex; -}; From ecc3d6fbae10e8a130c0d81139e323616bfad822 Mon Sep 17 00:00:00 2001 From: prin-r Date: Wed, 10 Jun 2020 13:42:29 +0700 Subject: [PATCH 35/38] fix timestamp --- scan/src/components/data-source/DataSourceRequestTable.re | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scan/src/components/data-source/DataSourceRequestTable.re b/scan/src/components/data-source/DataSourceRequestTable.re index 1c5a7e008c..5f8364a160 100644 --- a/scan/src/components/data-source/DataSourceRequestTable.re +++ b/scan/src/components/data-source/DataSourceRequestTable.re @@ -96,7 +96,7 @@ let make = (~dataSourceID: ID.DataSource.t) => {requests ->Belt_Array.map( - ({id, oracleScriptID, oracleScriptName, requestTime, blockHeight, txHash}) => { + ({id, oracleScriptID, oracleScriptName, txTimestamp, blockHeight, txHash}) => { Hash.toHex(~upper=true)}> @@ -114,7 +114,7 @@ let make = (~dataSourceID: ID.DataSource.t) => - + From d48f68a3a29d4f9c84cb93c48c4fbf5e5eb5ea01 Mon Sep 17 00:00:00 2001 From: prin-r Date: Wed, 10 Jun 2020 13:44:40 +0700 Subject: [PATCH 36/38] fix timestamp --- scan/src/components/oracle-script/OracleScriptRequestTable.re | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scan/src/components/oracle-script/OracleScriptRequestTable.re b/scan/src/components/oracle-script/OracleScriptRequestTable.re index 8558fbc491..60163a41a8 100644 --- a/scan/src/components/oracle-script/OracleScriptRequestTable.re +++ b/scan/src/components/oracle-script/OracleScriptRequestTable.re @@ -99,7 +99,7 @@ let make = (~oracleScriptID: ID.OracleScript.t) => {requests - ->Belt_Array.map(({id, requester, requestTime, blockHeight, txHash}) => { + ->Belt_Array.map(({id, requester, txTimestamp, blockHeight, txHash}) => { Hash.toHex(~upper=true)}> @@ -110,7 +110,7 @@ let make = (~oracleScriptID: ID.OracleScript.t) =>
- + From 98fba123b0feb700132e9602c1a481f22471362d Mon Sep 17 00:00:00 2001 From: prin-r Date: Wed, 10 Jun 2020 13:45:06 +0700 Subject: [PATCH 37/38] change to option --- scan/src/subscriptions/RequestSub.re | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/scan/src/subscriptions/RequestSub.re b/scan/src/subscriptions/RequestSub.re index 8c01be2ebe..2d2a6e5522 100644 --- a/scan/src/subscriptions/RequestSub.re +++ b/scan/src/subscriptions/RequestSub.re @@ -32,7 +32,7 @@ module Mini = { id: ID.Request.t, requester: Address.t, clientID: string, - requestTime: MomentRe.Moment.t, + requestTime: option(MomentRe.Moment.t), resolveTime: option(MomentRe.Moment.t), calldata: JsBuffer.t, oracleScript: oracle_script_internal_t, @@ -48,12 +48,13 @@ module Mini = { id: ID.Request.t, requester: Address.t, clientID: string, - requestTime: MomentRe.Moment.t, + requestTime: option(MomentRe.Moment.t), resolveTime: option(MomentRe.Moment.t), calldata: JsBuffer.t, oracleScriptID: ID.OracleScript.t, oracleScriptName: string, txHash: Hash.t, + txTimestamp: MomentRe.Moment.t, blockHeight: ID.Block.t, reportsCount: int, minCount: int, @@ -74,7 +75,7 @@ module Mini = { request @bsRecord { id @bsDecoder(fn: "ID.Request.fromJson") clientID: client_id - requestTime: request_time @bsDecoder(fn: "GraphQLParser.optionTimeSExn") + requestTime: request_time @bsDecoder(fn: "GraphQLParser.optionTimeS") resolveTime: resolve_time @bsDecoder(fn: "GraphQLParser.optionTimeS") requester @bsDecoder(fn: "Address.fromBech32") calldata @bsDecoder(fn: "GraphQLParser.buffer") @@ -118,7 +119,7 @@ module Mini = { ) { id @bsDecoder(fn: "ID.Request.fromJson") clientID: client_id - requestTime: request_time @bsDecoder(fn: "GraphQLParser.optionTimeSExn") + requestTime: request_time @bsDecoder(fn: "GraphQLParser.optionTimeS") resolveTime: resolve_time @bsDecoder(fn: "GraphQLParser.optionTimeS") requester @bsDecoder(fn: "Address.fromBech32") calldata @bsDecoder(fn: "GraphQLParser.buffer") @@ -156,7 +157,7 @@ module Mini = { requests(where: {tx_hash: {_eq: $tx_hash}}) { id @bsDecoder(fn: "ID.Request.fromJson") clientID: client_id - requestTime: request_time @bsDecoder(fn: "GraphQLParser.optionTimeSExn") + requestTime: request_time @bsDecoder(fn: "GraphQLParser.optionTimeS") resolveTime: resolve_time @bsDecoder(fn: "GraphQLParser.optionTimeS") requester @bsDecoder(fn: "Address.fromBech32") calldata @bsDecoder(fn: "GraphQLParser.buffer") @@ -198,7 +199,7 @@ module Mini = { resolveTime, calldata, oracleScript, - transaction: {txHash, blockHeight}, + transaction: {txHash, blockHeight, timestamp: txTimestamp}, reportsAggregate, minCount, resolveStatus, @@ -215,6 +216,7 @@ module Mini = { oracleScriptID: oracleScript.id, oracleScriptName: oracleScript.name, txHash, + txTimestamp, blockHeight, reportsCount: reportsAggregate.aggregate->Belt_Option.map(({count}) => count)->Belt_Option.getExn, @@ -251,6 +253,7 @@ module Mini = { oracleScriptID: y##oracle_script.id, oracleScriptName: y##oracle_script.name, txHash: y##transaction.txHash, + txTimestamp: y##transaction.timestamp, blockHeight: y##transaction.blockHeight, reportsCount: y##reportsAggregate.aggregate @@ -311,6 +314,7 @@ module Mini = { oracleScriptID: y##oracleScript.id, oracleScriptName: y##oracleScript.name, txHash: y##transaction.txHash, + txTimestamp: y##transaction.timestamp, blockHeight: y##transaction.blockHeight, reportsCount: y##reportsAggregate.aggregate @@ -387,7 +391,7 @@ type requested_validator_internal_t = {validator: ValidatorSub.Mini.t}; type t = { id: ID.Request.t, clientID: string, - requestTime: MomentRe.Moment.t, + requestTime: option(MomentRe.Moment.t), resolveTime: option(MomentRe.Moment.t), oracleScript: oracle_script_internal_t, calldata: JsBuffer.t, @@ -408,7 +412,7 @@ module SingleRequestConfig = [%graphql requests_by_pk(id: $id) @bsRecord { id @bsDecoder(fn: "ID.Request.fromJson") clientID: client_id - requestTime: request_time @bsDecoder(fn: "GraphQLParser.optionTimeSExn") + requestTime: request_time @bsDecoder(fn: "GraphQLParser.optionTimeS") resolveTime: resolve_time @bsDecoder(fn: "GraphQLParser.optionTimeS") oracleScript: oracle_script @bsRecord { oracleScriptID:id @bsDecoder(fn: "ID.OracleScript.fromJson") @@ -469,7 +473,7 @@ module MultiRequestConfig = [%graphql requests(limit: $limit, offset: $offset, order_by: {id: desc}) @bsRecord { id @bsDecoder(fn: "ID.Request.fromJson") clientID: client_id - requestTime: request_time @bsDecoder(fn: "GraphQLParser.optionTimeSExn") + requestTime: request_time @bsDecoder(fn: "GraphQLParser.optionTimeS") resolveTime: resolve_time @bsDecoder(fn: "GraphQLParser.optionTimeS") oracleScript: oracle_script @bsRecord { oracleScriptID:id @bsDecoder(fn: "ID.OracleScript.fromJson") From f0d2feb3415b9f16cab84b70ac9243f13a1fa158 Mon Sep 17 00:00:00 2001 From: prin-r Date: Wed, 10 Jun 2020 13:45:28 +0700 Subject: [PATCH 38/38] add getExn --- scan/src/utils/proof/NonEVMProof.re | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scan/src/utils/proof/NonEVMProof.re b/scan/src/utils/proof/NonEVMProof.re index 1af727f12e..62d8aa2b56 100644 --- a/scan/src/utils/proof/NonEVMProof.re +++ b/scan/src/utils/proof/NonEVMProof.re @@ -109,7 +109,7 @@ let toPackets = (request: request_t) => { clientID, requestID, ansCount: reports |> Belt_Array.length, - requestTime: requestTime |> MomentRe.Moment.toUnix, + requestTime: requestTime |> Belt_Option.getExn |> MomentRe.Moment.toUnix, resolveTimne: resolveTime |> Belt_Option.getExn |> MomentRe.Moment.toUnix, resolveStatus: resolveStatus |> resolveStatusToInt, result: result |> Belt_Option.getExn, @@ -133,7 +133,7 @@ let toPackets = (request: request_t) => { clientID, requestID, ansCount, - requestTime: requestTime |> MomentRe.Moment.toUnix, + requestTime: requestTime |> Belt_Option.getExn |> MomentRe.Moment.toUnix, resolveTimne: resolveTime |> Belt_Option.getExn |> MomentRe.Moment.toUnix, resolveStatus: resolveStatus |> resolveStatusToInt, result: result |> Belt_Option.getExn,