Skip to content

Commit

Permalink
ic_evm_rpc canister candid needed an update
Browse files Browse the repository at this point in the history
  • Loading branch information
lastmjs committed Mar 28, 2024
1 parent bf5c04c commit f988b05
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 30 deletions.
55 changes: 29 additions & 26 deletions examples/ic_evm_rpc/src/candid/evm_rpc.did
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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;
Expand All @@ -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 };
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/ic_evm_rpc/src/candid/server.did
Original file line number Diff line number Diff line change
@@ -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});
}
4 changes: 2 additions & 2 deletions examples/ic_evm_rpc/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit f988b05

Please sign in to comment.