-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevm-rpc.did
238 lines (238 loc) · 6.98 KB
/
evm-rpc.did
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
type Auth = variant { FreeRpc; PriorityRpc; RegisterProvider; Manage };
type Block = record {
miner : text;
totalDifficulty : nat;
receiptsRoot : text;
stateRoot : text;
hash : text;
difficulty : nat;
size : nat;
uncles : vec text;
baseFeePerGas : nat;
extraData : text;
transactionsRoot : opt text;
sha3Uncles : text;
nonce : nat;
number : nat;
timestamp : nat;
transactions : vec text;
gasLimit : nat;
logsBloom : text;
parentHash : text;
gasUsed : nat;
mixHash : text;
};
type BlockTag = variant {
Earliest;
Safe;
Finalized;
Latest;
Number : nat;
Pending;
};
type EthMainnetService = variant { Alchemy; Ankr; BlockPi; Cloudflare; PublicNode };
type EthSepoliaService = variant { Alchemy; Ankr; BlockPi; PublicNode };
type FeeHistory = record {
reward : vec vec nat;
gasUsedRatio : vec float64;
oldestBlock : nat;
baseFeePerGas : vec nat;
};
type FeeHistoryArgs = record {
blockCount : nat;
newestBlock : BlockTag;
rewardPercentiles : opt vec nat8;
};
type GetLogsArgs = record {
fromBlock : opt BlockTag;
toBlock : opt BlockTag;
addresses : vec text;
topics : opt vec text;
};
type GetTransactionCountArgs = record { address : text; block : BlockTag };
type HttpHeader = record { value : text; name : text };
type HttpOutcallError = variant {
IcError : record { code : RejectionCode; message : text };
InvalidHttpJsonRpcResponse : record {
status : nat16;
body : text;
parsingError : opt text;
};
};
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;
data : text;
blockHash : opt text;
transactionIndex : opt nat;
topics : vec text;
address : text;
logIndex : opt nat;
removed : bool;
};
type Message = variant { Data : blob; Hash : blob };
type Metrics = record {
requests : vec record { record { text; text }; nat64 };
responses : vec record { record { text; text }; nat64 };
cyclesCharged : vec record { record { text; text }; nat };
cyclesWithdrawn : nat;
errNoPermission : nat64;
errHttpOutcall : vec record { record { text; text }; nat64 };
errHttpResponse : vec record { record { text; text }; nat64 };
errHostNotAllowed : vec record { text; nat64 };
};
type MultiFeeHistoryResult = variant {
Consistent : FeeHistoryResult;
Inconsistent : vec record { RpcService; FeeHistoryResult };
};
type MultiGetBlockByNumberResult = variant {
Consistent : GetBlockByNumberResult;
Inconsistent : vec record { RpcService; GetBlockByNumberResult };
};
type MultiGetLogsResult = variant {
Consistent : GetLogsResult;
Inconsistent : vec record { RpcService; GetLogsResult };
};
type MultiGetTransactionCountResult = variant {
Consistent : GetTransactionCountResult;
Inconsistent : vec record { RpcService; GetTransactionCountResult };
};
type MultiGetTransactionReceiptResult = variant {
Consistent : GetTransactionReceiptResult;
Inconsistent : vec record { RpcService; GetTransactionReceiptResult };
};
type MultiSendRawTransactionResult = variant {
Consistent : SendRawTransactionResult;
Inconsistent : vec record { RpcService; SendRawTransactionResult };
};
type ProviderError = variant {
TooFewCycles : record { expected : nat; received : nat };
MissingRequiredProvider;
ProviderNotFound;
NoPermission;
};
type ProviderView = record {
cyclesPerCall : nat64;
owner : principal;
hostname : text;
primary : bool;
chainId : nat64;
cyclesPerMessageByte : nat64;
providerId : nat64;
};
type RegisterProviderArgs = record {
cyclesPerCall : nat64;
credentialPath : text;
hostname : text;
credentialHeaders : opt vec HttpHeader;
chainId : nat64;
cyclesPerMessageByte : nat64;
};
type RejectionCode = variant {
NoError;
CanisterError;
SysTransient;
DestinationInvalid;
Unknown;
SysFatal;
CanisterReject;
};
type FeeHistoryResult = variant { Ok : opt FeeHistory; Err : RpcError };
type GetBlockByNumberResult = variant { Ok : Block; Err : RpcError };
type GetLogsResult = variant { Ok : vec LogEntry; Err : RpcError };
type GetTransactionCountResult = variant { Ok : nat; Err : RpcError };
type GetTransactionReceiptResult = variant {
Ok : opt TransactionReceipt;
Err : RpcError;
};
type SendRawTransactionResult = variant {
Ok : SendRawTransactionStatus;
Err : RpcError;
};
type RequestResult = variant { Ok : text; Err : RpcError };
type RequestCostResult = variant { Ok : nat; Err : RpcError };
type RpcError = variant {
JsonRpcError : JsonRpcError;
ProviderError : ProviderError;
ValidationError : ValidationError;
HttpOutcallError : HttpOutcallError;
};
type RpcService = variant {
EthSepolia : EthSepoliaService;
EthMainnet : EthMainnetService;
};
type RpcSource = variant {
EthSepolia : opt vec EthSepoliaService;
EthMainnet : opt vec EthMainnetService;
};
type SendRawTransactionStatus = variant {
Ok;
NonceTooLow;
NonceTooHigh;
InsufficientFunds;
};
type TransactionReceipt = record {
to : text;
status : nat;
transactionHash : text;
blockNumber : nat;
from : text;
logs : vec LogEntry;
blockHash : text;
"type" : text;
transactionIndex : nat;
effectiveGasPrice : nat;
logsBloom : text;
contractAddress : opt text;
gasUsed : nat;
};
type UpdateProviderArgs = record {
cyclesPerCall : opt nat64;
credentialPath : opt text;
hostname : opt text;
credentialHeaders : opt vec HttpHeader;
primary : opt bool;
cyclesPerMessageByte : opt nat64;
providerId : nat64;
};
type ValidationError = variant {
CredentialPathNotAllowed : text;
HostNotAllowed : text;
CredentialHeaderNotAllowed : text;
UrlParseError : text;
InvalidHex : text;
};
service : (InitArgs) -> {
authorize : (principal, Auth) -> ();
deauthorize : (principal, Auth) -> ();
eth_feeHistory : (RpcSource, FeeHistoryArgs) -> (MultiFeeHistoryResult);
eth_getBlockByNumber : (RpcSource, BlockTag) -> (MultiGetBlockByNumberResult);
eth_getLogs : (RpcSource, GetLogsArgs) -> (MultiGetLogsResult);
eth_getTransactionCount : (RpcSource, GetTransactionCountArgs) -> (
MultiGetTransactionCountResult
);
eth_getTransactionReceipt : (RpcSource, text) -> (MultiGetTransactionReceiptResult);
eth_sendRawTransaction : (RpcSource, text) -> (MultiSendRawTransactionResult);
getAccumulatedCycleCount : (nat64) -> (nat) query;
getAuthorized : (Auth) -> (vec text) query;
getMetrics : () -> (Metrics) query;
getOpenRpcAccess : () -> (bool) query;
getProviders : () -> (vec ProviderView) query;
registerProvider : (RegisterProviderArgs) -> (nat64);
request : (JsonRpcSource, text, nat64) -> (RequestResult);
requestCost : (JsonRpcSource, text, nat64) -> (RequestCostResult) query;
setOpenRpcAccess : (bool) -> ();
unregisterProvider : (nat64) -> (bool);
updateProvider : (UpdateProviderArgs) -> ();
withdrawAccumulatedCycles : (nat64, principal) -> ();
};