From f988b050c8f60d659e931c3b6d78958fe2456789 Mon Sep 17 00:00:00 2001 From: Jordan Last Date: Thu, 28 Mar 2024 16:09:59 -0500 Subject: [PATCH] ic_evm_rpc canister candid needed an update --- examples/ic_evm_rpc/src/candid/evm_rpc.did | 55 ++++++++++++---------- examples/ic_evm_rpc/src/candid/server.did | 4 +- examples/ic_evm_rpc/src/server.ts | 4 +- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/examples/ic_evm_rpc/src/candid/evm_rpc.did b/examples/ic_evm_rpc/src/candid/evm_rpc.did index 2ac292620e..86d32f92ac 100644 --- a/examples/ic_evm_rpc/src/candid/evm_rpc.did +++ b/examples/ic_evm_rpc/src/candid/evm_rpc.did @@ -53,7 +53,7 @@ type GetLogsArgs = record { fromBlock : opt BlockTag; toBlock : opt BlockTag; addresses : vec text; - topics : opt vec text; + topics : opt vec vec text; }; type GetTransactionCountArgs = record { address : text; block : BlockTag }; type HttpHeader = record { value : text; name : text }; @@ -69,12 +69,6 @@ type InitArgs = record { nodesInSubnet : nat32; }; type JsonRpcError = record { code : int64; message : text }; -type JsonRpcSource = variant { - Custom : record { url : text; headers : opt vec HttpHeader }; - Service : record { hostname : text; chainId : opt nat64 }; - Chain : nat64; - Provider : nat64; -}; type LogEntry = record { transactionHash : opt text; blockNumber : opt nat; @@ -87,10 +81,9 @@ type LogEntry = record { removed : bool; }; type ManageProviderArgs = record { + providerId : nat64; "service" : opt RpcService; - owner : opt principal; primary : opt bool; - providerId : nat64; }; type Metrics = record { requests : vec record { record { text; text }; nat64 }; @@ -179,16 +172,24 @@ type RpcError = variant { ValidationError : ValidationError; HttpOutcallError : HttpOutcallError; }; +type RpcApi = record { url : text; headers : opt vec HttpHeader }; type RpcService = variant { EthSepolia : EthSepoliaService; EthMainnet : EthMainnetService; + Chain : nat64; + Provider : nat64; + Custom : RpcApi; }; -type RpcSource = variant { +type RpcServices = variant { EthSepolia : opt vec EthSepoliaService; EthMainnet : opt vec EthMainnetService; + Custom : record { + chainId : nat64; + services : vec RpcApi; + }; }; type SendRawTransactionStatus = variant { - Ok; + Ok : opt text; NonceTooLow; NonceTooHigh; InsufficientFunds; @@ -225,31 +226,33 @@ type ValidationError = variant { CredentialPathNotAllowed; CredentialHeaderNotAllowed; }; +type ProviderId = nat64; service : (InitArgs) -> { - authorize : (principal, Auth) -> (bool); - deauthorize : (principal, Auth) -> (bool); - eth_feeHistory : (RpcSource, opt RpcConfig, FeeHistoryArgs) -> (MultiFeeHistoryResult); - eth_getBlockByNumber : (RpcSource, opt RpcConfig, BlockTag) -> (MultiGetBlockByNumberResult); - eth_getLogs : (RpcSource, opt RpcConfig, GetLogsArgs) -> (MultiGetLogsResult); - eth_getTransactionCount : (RpcSource, opt RpcConfig, GetTransactionCountArgs) -> ( + authorize : (principal, Auth) -> (success: bool); + deauthorize : (principal, Auth) -> (success: bool); + eth_feeHistory : (RpcServices, opt RpcConfig, FeeHistoryArgs) -> (MultiFeeHistoryResult); + eth_getBlockByNumber : (RpcServices, opt RpcConfig, BlockTag) -> (MultiGetBlockByNumberResult); + eth_getLogs : (RpcServices, opt RpcConfig, GetLogsArgs) -> (MultiGetLogsResult); + eth_getTransactionCount : (RpcServices, opt RpcConfig, GetTransactionCountArgs) -> ( MultiGetTransactionCountResult ); - eth_getTransactionReceipt : (RpcSource, opt RpcConfig, text) -> (MultiGetTransactionReceiptResult); - eth_sendRawTransaction : (RpcSource, opt RpcConfig, text) -> (MultiSendRawTransactionResult); - getAccumulatedCycleCount : (nat64) -> (nat) query; + eth_getTransactionReceipt : (RpcServices, opt RpcConfig, hash: text) -> (MultiGetTransactionReceiptResult); + eth_sendRawTransaction : (RpcServices, opt RpcConfig, rawSignedTransactionHex: text) -> (MultiSendRawTransactionResult); + getAccumulatedCycleCount : (ProviderId) -> (cycles: nat) query; getAuthorized : (Auth) -> (vec principal) query; getMetrics : () -> (Metrics) query; - getOpenRpcAccess : () -> (bool) query; + getNodesInSubnet : () -> (numberOfNodes: nat32) query; + getOpenRpcAccess : () -> (active: bool) query; getProviders : () -> (vec ProviderView) query; getServiceProviderMap : () -> (vec record { RpcService; nat64 }) query; manageProvider : (ManageProviderArgs) -> (); registerProvider : (RegisterProviderArgs) -> (nat64); - request : (JsonRpcSource, text, nat64) -> (RequestResult); - requestCost : (JsonRpcSource, text, nat64) -> (RequestCostResult) query; - setOpenRpcAccess : (bool) -> (); - unregisterProvider : (nat64) -> (bool); + request : (RpcService, json: text, maxResponseBytes: nat64) -> (RequestResult); + requestCost : (RpcService, json: text, maxResponseBytes: nat64) -> (RequestCostResult) query; + setOpenRpcAccess : (active: bool) -> (); + unregisterProvider : (ProviderId) -> (bool); updateProvider : (UpdateProviderArgs) -> (); - withdrawAccumulatedCycles : (nat64, principal) -> (); + withdrawAccumulatedCycles : (ProviderId, recipient: principal) -> (); }; // Apache License diff --git a/examples/ic_evm_rpc/src/candid/server.did b/examples/ic_evm_rpc/src/candid/server.did index 02c019ab7d..7bf084795e 100644 --- a/examples/ic_evm_rpc/src/candid/server.did +++ b/examples/ic_evm_rpc/src/candid/server.did @@ -1,4 +1,4 @@ service: () -> { - http_request: (record {url:text; method:text; body:vec nat8; headers:vec record {text; text}; certificate_version:opt nat16}) -> (record {body:vec nat8; headers:vec record {text; text}; upgrade:opt bool; streaming_strategy:opt variant {Callback:record {token:record {}; callback:func (record {}) -> (opt record {token:opt record {}; body:vec nat8}) query}}; status_code:nat16}) query; - http_request_update: (record {url:text; method:text; body:vec nat8; headers:vec record {text; text}; certificate_version:opt nat16}) -> (record {body:vec nat8; headers:vec record {text; text}; upgrade:opt bool; streaming_strategy:opt variant {Callback:record {token:record {}; callback:func (record {}) -> (opt record {token:opt record {}; body:vec nat8}) query}}; status_code:nat16}); + http_request: (record {url:text; method:text; body:vec nat8; headers:vec record {text; text}; certificate_version:opt nat16}) -> (record {body:vec nat8; headers:vec record {text; text}; upgrade:opt bool; streaming_strategy:opt variant {Callback:record {token:vec nat8; callback:func (vec nat8) -> (opt record {token:opt vec nat8; body:vec nat8}) query}}; status_code:nat16}) query; + http_request_update: (record {url:text; method:text; body:vec nat8; headers:vec record {text; text}}) -> (record {body:vec nat8; headers:vec record {text; text}; upgrade:opt bool; streaming_strategy:opt variant {Callback:record {token:vec nat8; callback:func (vec nat8) -> (opt record {token:opt vec nat8; body:vec nat8}) query}}; status_code:nat16}); } diff --git a/examples/ic_evm_rpc/src/server.ts b/examples/ic_evm_rpc/src/server.ts index c717d9f303..c79645c10c 100644 --- a/examples/ic_evm_rpc/src/server.ts +++ b/examples/ic_evm_rpc/src/server.ts @@ -72,7 +72,7 @@ app.post( const result = await ethSendRawTransaction(rawTransaction); - if (result.Consistent?.Ok?.Ok === null) { + if (result.Consistent?.Ok?.Ok.length === 1) { res.send('transaction sent'); } else { res.status(500).send('transaction failed'); @@ -133,7 +133,7 @@ app.post( const result = await ethSendRawTransaction(rawTransaction); - if (result.Consistent?.Ok?.Ok === null) { + if (result.Consistent?.Ok?.Ok.length === 1) { res.send('transaction sent'); } else { res.status(500).send('transaction failed');