@0xsequence/relayer 2.3.35 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +5 -0
- package/CHANGELOG.md +3862 -0
- package/LICENSE +0 -17
- package/README.md +1 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/preconditions/codec.d.ts +12 -0
- package/dist/preconditions/codec.d.ts.map +1 -0
- package/dist/preconditions/codec.js +125 -0
- package/dist/preconditions/index.d.ts +4 -0
- package/dist/preconditions/index.d.ts.map +1 -0
- package/dist/preconditions/index.js +3 -0
- package/dist/preconditions/selectors.d.ts +7 -0
- package/dist/preconditions/selectors.d.ts.map +1 -0
- package/dist/preconditions/selectors.js +27 -0
- package/dist/preconditions/types.d.ts +70 -0
- package/dist/preconditions/types.d.ts.map +1 -0
- package/dist/preconditions/types.js +203 -0
- package/dist/relayer/index.d.ts +45 -0
- package/dist/relayer/index.d.ts.map +1 -0
- package/dist/relayer/index.js +3 -0
- package/dist/relayer/relayer.d.ts +26 -0
- package/dist/relayer/relayer.d.ts.map +1 -0
- package/dist/relayer/relayer.js +7 -0
- package/dist/relayer/rpc-relayer/index.d.ts +38 -0
- package/dist/relayer/rpc-relayer/index.d.ts.map +1 -0
- package/dist/relayer/rpc-relayer/index.js +375 -0
- package/dist/{declarations/src → relayer}/rpc-relayer/relayer.gen.d.ts +218 -178
- package/dist/relayer/rpc-relayer/relayer.gen.d.ts.map +1 -0
- package/dist/relayer/rpc-relayer/relayer.gen.js +1246 -0
- package/dist/relayer/standard/abi.d.ts +73 -0
- package/dist/relayer/standard/abi.d.ts.map +1 -0
- package/dist/relayer/standard/abi.js +10 -0
- package/dist/relayer/standard/eip6963.d.ts +31 -0
- package/dist/relayer/standard/eip6963.d.ts.map +1 -0
- package/dist/relayer/standard/eip6963.js +51 -0
- package/dist/relayer/standard/index.d.ts +5 -0
- package/dist/relayer/standard/index.d.ts.map +1 -0
- package/dist/relayer/standard/index.js +4 -0
- package/dist/relayer/standard/local.d.ts +60 -0
- package/dist/relayer/standard/local.d.ts.map +1 -0
- package/dist/relayer/standard/local.js +285 -0
- package/dist/relayer/standard/pk-relayer.d.ts +28 -0
- package/dist/relayer/standard/pk-relayer.d.ts.map +1 -0
- package/dist/relayer/standard/pk-relayer.js +112 -0
- package/dist/relayer/standard/sequence.d.ts +27 -0
- package/dist/relayer/standard/sequence.d.ts.map +1 -0
- package/dist/relayer/standard/sequence.js +84 -0
- package/package.json +28 -25
- package/src/index.ts +3 -111
- package/src/preconditions/codec.ts +190 -0
- package/src/preconditions/index.ts +3 -0
- package/src/preconditions/selectors.ts +38 -0
- package/src/preconditions/types.ts +201 -0
- package/src/relayer/index.ts +60 -0
- package/src/relayer/relayer.ts +37 -0
- package/src/relayer/rpc-relayer/index.ts +449 -0
- package/src/relayer/rpc-relayer/relayer.gen.ts +2268 -0
- package/src/relayer/standard/abi.ts +13 -0
- package/src/relayer/standard/eip6963.ts +74 -0
- package/src/relayer/standard/index.ts +4 -0
- package/src/relayer/standard/local.ts +353 -0
- package/src/relayer/standard/pk-relayer.ts +138 -0
- package/src/relayer/standard/sequence.ts +110 -0
- package/test/preconditions/codec.test.ts +531 -0
- package/test/preconditions/preconditions.test.ts +283 -0
- package/test/preconditions/selectors.test.ts +415 -0
- package/test/preconditions/types.test.ts +443 -0
- package/test/relayer/relayer.test.ts +355 -0
- package/tsconfig.json +10 -0
- package/dist/0xsequence-relayer.cjs.d.ts +0 -2
- package/dist/0xsequence-relayer.cjs.dev.js +0 -1626
- package/dist/0xsequence-relayer.cjs.js +0 -7
- package/dist/0xsequence-relayer.cjs.prod.js +0 -1626
- package/dist/0xsequence-relayer.esm.js +0 -1613
- package/dist/declarations/src/index.d.ts +0 -42
- package/dist/declarations/src/local-relayer.d.ts +0 -35
- package/dist/declarations/src/provider-relayer.d.ts +0 -47
- package/dist/declarations/src/rpc-relayer/index.d.ts +0 -72
- package/src/local-relayer.ts +0 -125
- package/src/provider-relayer.ts +0 -284
- package/src/rpc-relayer/index.ts +0 -380
- package/src/rpc-relayer/relayer.gen.ts +0 -1900
|
@@ -0,0 +1,2268 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// sequence-relayer v0.4.1 7f8a4b83b00e0b6849c76c2ff0e23931e26b3d9f
|
|
3
|
+
// --
|
|
4
|
+
// Code generated by Webrpc-gen@v0.30.2 with typescript generator. DO NOT EDIT.
|
|
5
|
+
//
|
|
6
|
+
// webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts -compat
|
|
7
|
+
|
|
8
|
+
// Webrpc description and code-gen version
|
|
9
|
+
export const WebrpcVersion = 'v1'
|
|
10
|
+
|
|
11
|
+
// Schema version of your RIDL schema
|
|
12
|
+
export const WebrpcSchemaVersion = 'v0.4.1'
|
|
13
|
+
|
|
14
|
+
// Schema hash generated from your RIDL schema
|
|
15
|
+
export const WebrpcSchemaHash = '7f8a4b83b00e0b6849c76c2ff0e23931e26b3d9f'
|
|
16
|
+
|
|
17
|
+
//
|
|
18
|
+
// Client interface
|
|
19
|
+
//
|
|
20
|
+
|
|
21
|
+
export interface RelayerClient {
|
|
22
|
+
ping(headers?: object, signal?: AbortSignal): Promise<PingReturn>
|
|
23
|
+
|
|
24
|
+
version(headers?: object, signal?: AbortSignal): Promise<VersionReturn>
|
|
25
|
+
|
|
26
|
+
runtimeStatus(headers?: object, signal?: AbortSignal): Promise<RuntimeStatusReturn>
|
|
27
|
+
|
|
28
|
+
getSequenceContext(headers?: object, signal?: AbortSignal): Promise<GetSequenceContextReturn>
|
|
29
|
+
|
|
30
|
+
getChainID(headers?: object, signal?: AbortSignal): Promise<GetChainIDReturn>
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* Transactions
|
|
35
|
+
*
|
|
36
|
+
* TODO (future): rename this to just, 'SendTransaction(txn: MetaTransaction)' or 'SendTransaction(txn: SignedTransaction)', or something..
|
|
37
|
+
* Project ID is only used by service and admin calls. Other clients must have projectID passed via the context
|
|
38
|
+
* TODO: rename return txnHash: string to metaTxnID: string
|
|
39
|
+
*/
|
|
40
|
+
sendMetaTxn(req: SendMetaTxnArgs, headers?: object, signal?: AbortSignal): Promise<SendMetaTxnReturn>
|
|
41
|
+
|
|
42
|
+
getMetaTxnNonce(req: GetMetaTxnNonceArgs, headers?: object, signal?: AbortSignal): Promise<GetMetaTxnNonceReturn>
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* TODO: one day, make GetMetaTxnReceipt respond immediately with receipt or not
|
|
46
|
+
* and add WaitTransactionReceipt method, which will block and wait, similar to how GetMetaTxnReceipt
|
|
47
|
+
* is implemented now.
|
|
48
|
+
* For backwards compat, we can leave the current GetMetaTxnReceipt how it is, an deprecate it, and introduce
|
|
49
|
+
* new, GetTransactionReceipt and WaitTransactionReceipt methods
|
|
50
|
+
* we can also accept metaTxnId and txnHash .. so can take either or.. I wonder if ERC-4337 has any convention on this?
|
|
51
|
+
*/
|
|
52
|
+
getMetaTxnReceipt(
|
|
53
|
+
req: GetMetaTxnReceiptArgs,
|
|
54
|
+
headers?: object,
|
|
55
|
+
signal?: AbortSignal,
|
|
56
|
+
): Promise<GetMetaTxnReceiptReturn>
|
|
57
|
+
|
|
58
|
+
simulate(req: SimulateArgs, headers?: object, signal?: AbortSignal): Promise<SimulateReturn>
|
|
59
|
+
|
|
60
|
+
simulateV3(req: SimulateV3Args, headers?: object, signal?: AbortSignal): Promise<SimulateV3Return>
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* TODO: deprecated, to be removed by https://github.com/0xsequence/stack/pull/356 at a later date
|
|
64
|
+
*/
|
|
65
|
+
updateMetaTxnGasLimits(
|
|
66
|
+
req: UpdateMetaTxnGasLimitsArgs,
|
|
67
|
+
headers?: object,
|
|
68
|
+
signal?: AbortSignal,
|
|
69
|
+
): Promise<UpdateMetaTxnGasLimitsReturn>
|
|
70
|
+
|
|
71
|
+
feeTokens(headers?: object, signal?: AbortSignal): Promise<FeeTokensReturn>
|
|
72
|
+
|
|
73
|
+
feeOptions(req: FeeOptionsArgs, headers?: object, signal?: AbortSignal): Promise<FeeOptionsReturn>
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* TODO: deprecated, to be removed by https://github.com/0xsequence/stack/pull/356 at a later date
|
|
77
|
+
*/
|
|
78
|
+
getMetaTxnNetworkFeeOptions(
|
|
79
|
+
req: GetMetaTxnNetworkFeeOptionsArgs,
|
|
80
|
+
headers?: object,
|
|
81
|
+
signal?: AbortSignal,
|
|
82
|
+
): Promise<GetMetaTxnNetworkFeeOptionsReturn>
|
|
83
|
+
|
|
84
|
+
getMetaTransactions(
|
|
85
|
+
req: GetMetaTransactionsArgs,
|
|
86
|
+
headers?: object,
|
|
87
|
+
signal?: AbortSignal,
|
|
88
|
+
): Promise<GetMetaTransactionsReturn>
|
|
89
|
+
|
|
90
|
+
getTransactionCost(
|
|
91
|
+
req: GetTransactionCostArgs,
|
|
92
|
+
headers?: object,
|
|
93
|
+
signal?: AbortSignal,
|
|
94
|
+
): Promise<GetTransactionCostReturn>
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Sent transactions from an account. If filter is omitted then it will return all transactions.
|
|
98
|
+
*/
|
|
99
|
+
sentTransactions(req: SentTransactionsArgs, headers?: object, signal?: AbortSignal): Promise<SentTransactionsReturn>
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Pending transactions waiting to be mined for an account. This endpoint is just a sugar of `SentTransactions`
|
|
103
|
+
* with the filter set to pending: true.
|
|
104
|
+
*/
|
|
105
|
+
pendingTransactions(
|
|
106
|
+
req: PendingTransactionsArgs,
|
|
107
|
+
headers?: object,
|
|
108
|
+
signal?: AbortSignal,
|
|
109
|
+
): Promise<PendingTransactionsReturn>
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Legacy Gas Tank
|
|
113
|
+
*/
|
|
114
|
+
getGasTank(req: GetGasTankArgs, headers?: object, signal?: AbortSignal): Promise<GetGasTankReturn>
|
|
115
|
+
|
|
116
|
+
addGasTank(req: AddGasTankArgs, headers?: object, signal?: AbortSignal): Promise<AddGasTankReturn>
|
|
117
|
+
|
|
118
|
+
updateGasTank(req: UpdateGasTankArgs, headers?: object, signal?: AbortSignal): Promise<UpdateGasTankReturn>
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Legacy Gas Adjustment
|
|
122
|
+
*/
|
|
123
|
+
nextGasTankBalanceAdjustmentNonce(
|
|
124
|
+
req: NextGasTankBalanceAdjustmentNonceArgs,
|
|
125
|
+
headers?: object,
|
|
126
|
+
signal?: AbortSignal,
|
|
127
|
+
): Promise<NextGasTankBalanceAdjustmentNonceReturn>
|
|
128
|
+
|
|
129
|
+
adjustGasTankBalance(
|
|
130
|
+
req: AdjustGasTankBalanceArgs,
|
|
131
|
+
headers?: object,
|
|
132
|
+
signal?: AbortSignal,
|
|
133
|
+
): Promise<AdjustGasTankBalanceReturn>
|
|
134
|
+
|
|
135
|
+
getGasTankBalanceAdjustment(
|
|
136
|
+
req: GetGasTankBalanceAdjustmentArgs,
|
|
137
|
+
headers?: object,
|
|
138
|
+
signal?: AbortSignal,
|
|
139
|
+
): Promise<GetGasTankBalanceAdjustmentReturn>
|
|
140
|
+
|
|
141
|
+
listGasTankBalanceAdjustments(
|
|
142
|
+
req: ListGasTankBalanceAdjustmentsArgs,
|
|
143
|
+
headers?: object,
|
|
144
|
+
signal?: AbortSignal,
|
|
145
|
+
): Promise<ListGasTankBalanceAdjustmentsReturn>
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Gas Sponsorship
|
|
149
|
+
*/
|
|
150
|
+
listGasSponsors(req: ListGasSponsorsArgs, headers?: object, signal?: AbortSignal): Promise<ListGasSponsorsReturn>
|
|
151
|
+
|
|
152
|
+
getGasSponsor(req: GetGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<GetGasSponsorReturn>
|
|
153
|
+
|
|
154
|
+
addGasSponsor(req: AddGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<AddGasSponsorReturn>
|
|
155
|
+
|
|
156
|
+
updateGasSponsor(req: UpdateGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<UpdateGasSponsorReturn>
|
|
157
|
+
|
|
158
|
+
removeGasSponsor(req: RemoveGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<RemoveGasSponsorReturn>
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Gas Sponsor Lookup
|
|
162
|
+
*/
|
|
163
|
+
addressGasSponsors(
|
|
164
|
+
req: AddressGasSponsorsArgs,
|
|
165
|
+
headers?: object,
|
|
166
|
+
signal?: AbortSignal,
|
|
167
|
+
): Promise<AddressGasSponsorsReturn>
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Project Balance
|
|
171
|
+
*/
|
|
172
|
+
getProjectBalance(
|
|
173
|
+
req: GetProjectBalanceArgs,
|
|
174
|
+
headers?: object,
|
|
175
|
+
signal?: AbortSignal,
|
|
176
|
+
): Promise<GetProjectBalanceReturn>
|
|
177
|
+
|
|
178
|
+
adjustProjectBalance(
|
|
179
|
+
req: AdjustProjectBalanceArgs,
|
|
180
|
+
headers?: object,
|
|
181
|
+
signal?: AbortSignal,
|
|
182
|
+
): Promise<AdjustProjectBalanceReturn>
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
//
|
|
186
|
+
// Schema types
|
|
187
|
+
//
|
|
188
|
+
|
|
189
|
+
export enum ETHTxnStatus {
|
|
190
|
+
UNKNOWN = 'UNKNOWN',
|
|
191
|
+
DROPPED = 'DROPPED',
|
|
192
|
+
QUEUED = 'QUEUED',
|
|
193
|
+
SENT = 'SENT',
|
|
194
|
+
SUCCEEDED = 'SUCCEEDED',
|
|
195
|
+
PARTIALLY_FAILED = 'PARTIALLY_FAILED',
|
|
196
|
+
FAILED = 'FAILED',
|
|
197
|
+
PENDING_PRECONDITION = 'PENDING_PRECONDITION',
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export enum TransferType {
|
|
201
|
+
SEND = 'SEND',
|
|
202
|
+
RECEIVE = 'RECEIVE',
|
|
203
|
+
BRIDGE_DEPOSIT = 'BRIDGE_DEPOSIT',
|
|
204
|
+
BRIDGE_WITHDRAW = 'BRIDGE_WITHDRAW',
|
|
205
|
+
BURN = 'BURN',
|
|
206
|
+
UNKNOWN = 'UNKNOWN',
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export enum SimulateStatus {
|
|
210
|
+
SKIPPED = 'SKIPPED',
|
|
211
|
+
SUCCEEDED = 'SUCCEEDED',
|
|
212
|
+
FAILED = 'FAILED',
|
|
213
|
+
ABORTED = 'ABORTED',
|
|
214
|
+
REVERTED = 'REVERTED',
|
|
215
|
+
NOT_ENOUGH_GAS = 'NOT_ENOUGH_GAS',
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export enum FeeTokenType {
|
|
219
|
+
UNKNOWN = 'UNKNOWN',
|
|
220
|
+
ERC20_TOKEN = 'ERC20_TOKEN',
|
|
221
|
+
ERC1155_TOKEN = 'ERC1155_TOKEN',
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export enum SortOrder {
|
|
225
|
+
DESC = 'DESC',
|
|
226
|
+
ASC = 'ASC',
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export interface Version {
|
|
230
|
+
webrpcVersion: string
|
|
231
|
+
schemaVersion: string
|
|
232
|
+
schemaHash: string
|
|
233
|
+
appVersion: string
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface RuntimeStatus {
|
|
237
|
+
healthOK: boolean
|
|
238
|
+
startTime: string
|
|
239
|
+
uptime: number
|
|
240
|
+
ver: string
|
|
241
|
+
branch: string
|
|
242
|
+
commitHash: string
|
|
243
|
+
chainID: number
|
|
244
|
+
useEIP1559: boolean
|
|
245
|
+
senders: Array<SenderStatus>
|
|
246
|
+
checks: RuntimeChecks
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface SenderStatus {
|
|
250
|
+
index: number
|
|
251
|
+
address: string
|
|
252
|
+
etherBalance: number
|
|
253
|
+
active: boolean
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export interface RuntimeChecks {}
|
|
257
|
+
|
|
258
|
+
export interface SequenceContext {
|
|
259
|
+
factory: string
|
|
260
|
+
mainModule: string
|
|
261
|
+
mainModuleUpgradable: string
|
|
262
|
+
guestModule: string
|
|
263
|
+
utils: string
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export interface GasTank {
|
|
267
|
+
id: number
|
|
268
|
+
chainId: number
|
|
269
|
+
name: string
|
|
270
|
+
currentBalance: number
|
|
271
|
+
unlimited: boolean
|
|
272
|
+
feeMarkupFactor: number
|
|
273
|
+
updatedAt: string
|
|
274
|
+
createdAt: string
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface GasTankBalanceAdjustment {
|
|
278
|
+
gasTankId: number
|
|
279
|
+
nonce: number
|
|
280
|
+
amount: number
|
|
281
|
+
totalBalance: number
|
|
282
|
+
balanceTimestamp: string
|
|
283
|
+
createdAt: string
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export interface GasSponsor {
|
|
287
|
+
id: number
|
|
288
|
+
gasTankId: number
|
|
289
|
+
projectId: number
|
|
290
|
+
chainId: number
|
|
291
|
+
address: string
|
|
292
|
+
name: string
|
|
293
|
+
active: boolean
|
|
294
|
+
updatedAt: string
|
|
295
|
+
createdAt: string
|
|
296
|
+
deletedAt: string
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export interface GasSponsorUsage {
|
|
300
|
+
name: string
|
|
301
|
+
id: number
|
|
302
|
+
totalGasUsed: number
|
|
303
|
+
totalTxnFees: number
|
|
304
|
+
totalTxnFeesUsd: number
|
|
305
|
+
avgGasPrice: number
|
|
306
|
+
totalTxns: number
|
|
307
|
+
startTime: string
|
|
308
|
+
endTime: string
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export interface MetaTxn {
|
|
312
|
+
walletAddress: string
|
|
313
|
+
contract: string
|
|
314
|
+
input: string
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export interface MetaTxnLog {
|
|
318
|
+
id: number
|
|
319
|
+
chainId: number
|
|
320
|
+
projectId: number
|
|
321
|
+
txnHash: string
|
|
322
|
+
txnNonce: string
|
|
323
|
+
metaTxnID?: string
|
|
324
|
+
txnStatus: ETHTxnStatus
|
|
325
|
+
txnRevertReason: string
|
|
326
|
+
requeues: number
|
|
327
|
+
queuedAt: string
|
|
328
|
+
sentAt: string
|
|
329
|
+
minedAt: string
|
|
330
|
+
target: string
|
|
331
|
+
input: string
|
|
332
|
+
txnArgs: { [key: string]: any }
|
|
333
|
+
txnReceipt?: { [key: string]: any }
|
|
334
|
+
walletAddress: string
|
|
335
|
+
metaTxnNonce: string
|
|
336
|
+
gasLimit: number
|
|
337
|
+
gasPrice: string
|
|
338
|
+
gasUsed: number
|
|
339
|
+
gasEstimated: number
|
|
340
|
+
gasFeeMarkup?: number
|
|
341
|
+
usdRate: string
|
|
342
|
+
creditsUsed: number
|
|
343
|
+
cost: string
|
|
344
|
+
isWhitelisted: boolean
|
|
345
|
+
gasSponsor?: number
|
|
346
|
+
gasTank?: number
|
|
347
|
+
updatedAt: string
|
|
348
|
+
createdAt: string
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export interface MetaTxnReceipt {
|
|
352
|
+
id: string
|
|
353
|
+
status: string
|
|
354
|
+
revertReason?: string
|
|
355
|
+
index: number
|
|
356
|
+
logs: Array<MetaTxnReceiptLog>
|
|
357
|
+
receipts: Array<MetaTxnReceipt>
|
|
358
|
+
blockNumber: string
|
|
359
|
+
txnHash: string
|
|
360
|
+
txnReceipt: string
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export interface MetaTxnReceiptLog {
|
|
364
|
+
address: string
|
|
365
|
+
topics: Array<string>
|
|
366
|
+
data: string
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export interface Transactions {
|
|
370
|
+
chainID: string
|
|
371
|
+
transactions: Array<Transaction>
|
|
372
|
+
preconditions?: Array<TransactionPrecondition>
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export interface Transaction {
|
|
376
|
+
delegateCall: boolean
|
|
377
|
+
revertOnError: boolean
|
|
378
|
+
gasLimit: string
|
|
379
|
+
target: string
|
|
380
|
+
value: string
|
|
381
|
+
data: string
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export interface TransactionPrecondition {
|
|
385
|
+
type: string
|
|
386
|
+
chainId: number
|
|
387
|
+
ownerAddress: string
|
|
388
|
+
tokenAddress: string
|
|
389
|
+
minAmount: bigint
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export interface TxnLogUser {
|
|
393
|
+
username: string
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export interface TxnLogTransfer {
|
|
397
|
+
transferType: TransferType
|
|
398
|
+
contractAddress: string
|
|
399
|
+
from: string
|
|
400
|
+
to: string
|
|
401
|
+
ids: Array<string>
|
|
402
|
+
amounts: Array<string>
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export interface SentTransactionsFilter {
|
|
406
|
+
pending?: boolean
|
|
407
|
+
failed?: boolean
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export interface SimulateResult {
|
|
411
|
+
executed: boolean
|
|
412
|
+
succeeded: boolean
|
|
413
|
+
result?: string
|
|
414
|
+
reason?: string
|
|
415
|
+
gasUsed: number
|
|
416
|
+
gasLimit: number
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export interface SimulateV3Result {
|
|
420
|
+
status: SimulateStatus
|
|
421
|
+
result?: string
|
|
422
|
+
error?: string
|
|
423
|
+
gasUsed: number
|
|
424
|
+
gasLimit: number
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export interface FeeOption {
|
|
428
|
+
token: FeeToken
|
|
429
|
+
to: string
|
|
430
|
+
value: string
|
|
431
|
+
gasLimit: number
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export interface FeeToken {
|
|
435
|
+
chainId: number
|
|
436
|
+
name: string
|
|
437
|
+
symbol: string
|
|
438
|
+
type: FeeTokenType
|
|
439
|
+
decimals?: number
|
|
440
|
+
logoURL: string
|
|
441
|
+
contractAddress?: string
|
|
442
|
+
tokenID?: string
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export interface Page {
|
|
446
|
+
pageSize?: number
|
|
447
|
+
page?: number
|
|
448
|
+
more?: boolean
|
|
449
|
+
totalRecords?: number
|
|
450
|
+
column?: string
|
|
451
|
+
before?: any
|
|
452
|
+
after?: any
|
|
453
|
+
sort?: Array<SortBy>
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export interface SortBy {
|
|
457
|
+
column: string
|
|
458
|
+
order: SortOrder
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export interface PingArgs {}
|
|
462
|
+
|
|
463
|
+
export interface PingReturn {
|
|
464
|
+
status: boolean
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
export interface VersionArgs {}
|
|
468
|
+
|
|
469
|
+
export interface VersionReturn {
|
|
470
|
+
version: Version
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export interface RuntimeStatusArgs {}
|
|
474
|
+
|
|
475
|
+
export interface RuntimeStatusReturn {
|
|
476
|
+
status: RuntimeStatus
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export interface GetSequenceContextArgs {}
|
|
480
|
+
|
|
481
|
+
export interface GetSequenceContextReturn {
|
|
482
|
+
data: SequenceContext
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export interface GetChainIDArgs {}
|
|
486
|
+
|
|
487
|
+
export interface GetChainIDReturn {
|
|
488
|
+
chainID: number
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export interface SendMetaTxnArgs {
|
|
492
|
+
call: MetaTxn
|
|
493
|
+
quote?: string
|
|
494
|
+
projectID?: number
|
|
495
|
+
preconditions?: Array<TransactionPrecondition>
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
export interface SendMetaTxnReturn {
|
|
499
|
+
status: boolean
|
|
500
|
+
txnHash: string
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
export interface GetMetaTxnNonceArgs {
|
|
504
|
+
walletContractAddress: string
|
|
505
|
+
space?: string
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
export interface GetMetaTxnNonceReturn {
|
|
509
|
+
nonce: string
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export interface GetMetaTxnReceiptArgs {
|
|
513
|
+
metaTxID: string
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
export interface GetMetaTxnReceiptReturn {
|
|
517
|
+
receipt: MetaTxnReceipt
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export interface SimulateArgs {
|
|
521
|
+
wallet: string
|
|
522
|
+
transactions: string
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
export interface SimulateReturn {
|
|
526
|
+
results: Array<SimulateResult>
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
export interface SimulateV3Args {
|
|
530
|
+
wallet: string
|
|
531
|
+
calls: string
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
export interface SimulateV3Return {
|
|
535
|
+
results: Array<SimulateV3Result>
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
export interface UpdateMetaTxnGasLimitsArgs {
|
|
539
|
+
walletAddress: string
|
|
540
|
+
walletConfig: any
|
|
541
|
+
payload: string
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
export interface UpdateMetaTxnGasLimitsReturn {
|
|
545
|
+
payload: string
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
export interface FeeTokensArgs {}
|
|
549
|
+
|
|
550
|
+
export interface FeeTokensReturn {
|
|
551
|
+
isFeeRequired: boolean
|
|
552
|
+
tokens: Array<FeeToken>
|
|
553
|
+
paymentAddress: string
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
export interface FeeOptionsArgs {
|
|
557
|
+
wallet: string
|
|
558
|
+
to: string
|
|
559
|
+
data: string
|
|
560
|
+
simulate?: boolean
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
export interface FeeOptionsReturn {
|
|
564
|
+
options: Array<FeeOption>
|
|
565
|
+
sponsored: boolean
|
|
566
|
+
quote?: string
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
export interface GetMetaTxnNetworkFeeOptionsArgs {
|
|
570
|
+
walletConfig: any
|
|
571
|
+
payload: string
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
export interface GetMetaTxnNetworkFeeOptionsReturn {
|
|
575
|
+
options: Array<FeeOption>
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
export interface GetMetaTransactionsArgs {
|
|
579
|
+
projectId: number
|
|
580
|
+
page?: Page
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
export interface GetMetaTransactionsReturn {
|
|
584
|
+
page: Page
|
|
585
|
+
transactions: Array<MetaTxnLog>
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
export interface GetTransactionCostArgs {
|
|
589
|
+
projectId: number
|
|
590
|
+
from: string
|
|
591
|
+
to: string
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
export interface GetTransactionCostReturn {
|
|
595
|
+
cost: number
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
export interface SentTransactionsArgs {
|
|
599
|
+
filter?: SentTransactionsFilter
|
|
600
|
+
page?: Page
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
export interface SentTransactionsReturn {
|
|
604
|
+
page: Page
|
|
605
|
+
transactions: Array<Transaction>
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
export interface PendingTransactionsArgs {
|
|
609
|
+
page?: Page
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
export interface PendingTransactionsReturn {
|
|
613
|
+
page: Page
|
|
614
|
+
transactions: Array<Transaction>
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
export interface GetGasTankArgs {
|
|
618
|
+
id: number
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
export interface GetGasTankReturn {
|
|
622
|
+
gasTank: GasTank
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
export interface AddGasTankArgs {
|
|
626
|
+
name: string
|
|
627
|
+
feeMarkupFactor: number
|
|
628
|
+
unlimited?: boolean
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
export interface AddGasTankReturn {
|
|
632
|
+
status: boolean
|
|
633
|
+
gasTank: GasTank
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
export interface UpdateGasTankArgs {
|
|
637
|
+
id: number
|
|
638
|
+
name?: string
|
|
639
|
+
feeMarkupFactor?: number
|
|
640
|
+
unlimited?: boolean
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
export interface UpdateGasTankReturn {
|
|
644
|
+
status: boolean
|
|
645
|
+
gasTank: GasTank
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
export interface NextGasTankBalanceAdjustmentNonceArgs {
|
|
649
|
+
id: number
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
export interface NextGasTankBalanceAdjustmentNonceReturn {
|
|
653
|
+
nonce: number
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
export interface AdjustGasTankBalanceArgs {
|
|
657
|
+
id: number
|
|
658
|
+
nonce: number
|
|
659
|
+
amount: number
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
export interface AdjustGasTankBalanceReturn {
|
|
663
|
+
status: boolean
|
|
664
|
+
adjustment: GasTankBalanceAdjustment
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
export interface GetGasTankBalanceAdjustmentArgs {
|
|
668
|
+
id: number
|
|
669
|
+
nonce: number
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
export interface GetGasTankBalanceAdjustmentReturn {
|
|
673
|
+
adjustment: GasTankBalanceAdjustment
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
export interface ListGasTankBalanceAdjustmentsArgs {
|
|
677
|
+
id: number
|
|
678
|
+
page?: Page
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
export interface ListGasTankBalanceAdjustmentsReturn {
|
|
682
|
+
page: Page
|
|
683
|
+
adjustments: Array<GasTankBalanceAdjustment>
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
export interface ListGasSponsorsArgs {
|
|
687
|
+
projectId: number
|
|
688
|
+
page?: Page
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
export interface ListGasSponsorsReturn {
|
|
692
|
+
page: Page
|
|
693
|
+
gasSponsors: Array<GasSponsor>
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
export interface GetGasSponsorArgs {
|
|
697
|
+
projectId: number
|
|
698
|
+
id: number
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
export interface GetGasSponsorReturn {
|
|
702
|
+
gasSponsor: GasSponsor
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
export interface AddGasSponsorArgs {
|
|
706
|
+
projectId: number
|
|
707
|
+
address: string
|
|
708
|
+
name?: string
|
|
709
|
+
active?: boolean
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
export interface AddGasSponsorReturn {
|
|
713
|
+
status: boolean
|
|
714
|
+
gasSponsor: GasSponsor
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
export interface UpdateGasSponsorArgs {
|
|
718
|
+
projectId: number
|
|
719
|
+
id: number
|
|
720
|
+
name?: string
|
|
721
|
+
active?: boolean
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
export interface UpdateGasSponsorReturn {
|
|
725
|
+
status: boolean
|
|
726
|
+
gasSponsor: GasSponsor
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
export interface RemoveGasSponsorArgs {
|
|
730
|
+
projectId: number
|
|
731
|
+
id: number
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
export interface RemoveGasSponsorReturn {
|
|
735
|
+
status: boolean
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
export interface AddressGasSponsorsArgs {
|
|
739
|
+
address: string
|
|
740
|
+
page?: Page
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
export interface AddressGasSponsorsReturn {
|
|
744
|
+
page: Page
|
|
745
|
+
gasSponsors: Array<GasSponsor>
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
export interface GetProjectBalanceArgs {
|
|
749
|
+
projectId: number
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
export interface GetProjectBalanceReturn {
|
|
753
|
+
balance: number
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
export interface AdjustProjectBalanceArgs {
|
|
757
|
+
projectId: number
|
|
758
|
+
amount: number
|
|
759
|
+
identifier: string
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
export interface AdjustProjectBalanceReturn {
|
|
763
|
+
balance: number
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
//
|
|
767
|
+
// Client
|
|
768
|
+
//
|
|
769
|
+
|
|
770
|
+
export class Relayer implements RelayerClient {
|
|
771
|
+
protected hostname: string
|
|
772
|
+
protected fetch: Fetch
|
|
773
|
+
protected path = '/rpc/Relayer/'
|
|
774
|
+
|
|
775
|
+
constructor(hostname: string, fetch: Fetch) {
|
|
776
|
+
this.hostname = hostname.replace(/\/*$/, '')
|
|
777
|
+
this.fetch = (input: RequestInfo, init?: RequestInit) => fetch(input, init)
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
private url(name: string): string {
|
|
781
|
+
return this.hostname + this.path + name
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
queryKey = {
|
|
785
|
+
ping: () => ['Relayer', 'ping'] as const,
|
|
786
|
+
version: () => ['Relayer', 'version'] as const,
|
|
787
|
+
runtimeStatus: () => ['Relayer', 'runtimeStatus'] as const,
|
|
788
|
+
getSequenceContext: () => ['Relayer', 'getSequenceContext'] as const,
|
|
789
|
+
getChainID: () => ['Relayer', 'getChainID'] as const,
|
|
790
|
+
sendMetaTxn: (req: SendMetaTxnArgs) => ['Relayer', 'sendMetaTxn', req] as const,
|
|
791
|
+
getMetaTxnNonce: (req: GetMetaTxnNonceArgs) => ['Relayer', 'getMetaTxnNonce', req] as const,
|
|
792
|
+
getMetaTxnReceipt: (req: GetMetaTxnReceiptArgs) => ['Relayer', 'getMetaTxnReceipt', req] as const,
|
|
793
|
+
simulate: (req: SimulateArgs) => ['Relayer', 'simulate', req] as const,
|
|
794
|
+
simulateV3: (req: SimulateV3Args) => ['Relayer', 'simulateV3', req] as const,
|
|
795
|
+
updateMetaTxnGasLimits: (req: UpdateMetaTxnGasLimitsArgs) => ['Relayer', 'updateMetaTxnGasLimits', req] as const,
|
|
796
|
+
feeTokens: () => ['Relayer', 'feeTokens'] as const,
|
|
797
|
+
feeOptions: (req: FeeOptionsArgs) => ['Relayer', 'feeOptions', req] as const,
|
|
798
|
+
getMetaTxnNetworkFeeOptions: (req: GetMetaTxnNetworkFeeOptionsArgs) =>
|
|
799
|
+
['Relayer', 'getMetaTxnNetworkFeeOptions', req] as const,
|
|
800
|
+
getMetaTransactions: (req: GetMetaTransactionsArgs) => ['Relayer', 'getMetaTransactions', req] as const,
|
|
801
|
+
getTransactionCost: (req: GetTransactionCostArgs) => ['Relayer', 'getTransactionCost', req] as const,
|
|
802
|
+
sentTransactions: (req: SentTransactionsArgs) => ['Relayer', 'sentTransactions', req] as const,
|
|
803
|
+
pendingTransactions: (req: PendingTransactionsArgs) => ['Relayer', 'pendingTransactions', req] as const,
|
|
804
|
+
getGasTank: (req: GetGasTankArgs) => ['Relayer', 'getGasTank', req] as const,
|
|
805
|
+
addGasTank: (req: AddGasTankArgs) => ['Relayer', 'addGasTank', req] as const,
|
|
806
|
+
updateGasTank: (req: UpdateGasTankArgs) => ['Relayer', 'updateGasTank', req] as const,
|
|
807
|
+
nextGasTankBalanceAdjustmentNonce: (req: NextGasTankBalanceAdjustmentNonceArgs) =>
|
|
808
|
+
['Relayer', 'nextGasTankBalanceAdjustmentNonce', req] as const,
|
|
809
|
+
adjustGasTankBalance: (req: AdjustGasTankBalanceArgs) => ['Relayer', 'adjustGasTankBalance', req] as const,
|
|
810
|
+
getGasTankBalanceAdjustment: (req: GetGasTankBalanceAdjustmentArgs) =>
|
|
811
|
+
['Relayer', 'getGasTankBalanceAdjustment', req] as const,
|
|
812
|
+
listGasTankBalanceAdjustments: (req: ListGasTankBalanceAdjustmentsArgs) =>
|
|
813
|
+
['Relayer', 'listGasTankBalanceAdjustments', req] as const,
|
|
814
|
+
listGasSponsors: (req: ListGasSponsorsArgs) => ['Relayer', 'listGasSponsors', req] as const,
|
|
815
|
+
getGasSponsor: (req: GetGasSponsorArgs) => ['Relayer', 'getGasSponsor', req] as const,
|
|
816
|
+
addGasSponsor: (req: AddGasSponsorArgs) => ['Relayer', 'addGasSponsor', req] as const,
|
|
817
|
+
updateGasSponsor: (req: UpdateGasSponsorArgs) => ['Relayer', 'updateGasSponsor', req] as const,
|
|
818
|
+
removeGasSponsor: (req: RemoveGasSponsorArgs) => ['Relayer', 'removeGasSponsor', req] as const,
|
|
819
|
+
addressGasSponsors: (req: AddressGasSponsorsArgs) => ['Relayer', 'addressGasSponsors', req] as const,
|
|
820
|
+
getProjectBalance: (req: GetProjectBalanceArgs) => ['Relayer', 'getProjectBalance', req] as const,
|
|
821
|
+
adjustProjectBalance: (req: AdjustProjectBalanceArgs) => ['Relayer', 'adjustProjectBalance', req] as const,
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
ping = (headers?: object, signal?: AbortSignal): Promise<PingReturn> => {
|
|
825
|
+
return this.fetch(this.url('Ping'), createHttpRequest('{}', headers, signal)).then(
|
|
826
|
+
(res) => {
|
|
827
|
+
return buildResponse(res).then((_data) => {
|
|
828
|
+
return JsonDecode<PingReturn>(_data, 'PingReturn')
|
|
829
|
+
})
|
|
830
|
+
},
|
|
831
|
+
(error) => {
|
|
832
|
+
throw WebrpcRequestFailedError.new({
|
|
833
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
834
|
+
})
|
|
835
|
+
},
|
|
836
|
+
)
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
version = (headers?: object, signal?: AbortSignal): Promise<VersionReturn> => {
|
|
840
|
+
return this.fetch(this.url('Version'), createHttpRequest('{}', headers, signal)).then(
|
|
841
|
+
(res) => {
|
|
842
|
+
return buildResponse(res).then((_data) => {
|
|
843
|
+
return JsonDecode<VersionReturn>(_data, 'VersionReturn')
|
|
844
|
+
})
|
|
845
|
+
},
|
|
846
|
+
(error) => {
|
|
847
|
+
throw WebrpcRequestFailedError.new({
|
|
848
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
849
|
+
})
|
|
850
|
+
},
|
|
851
|
+
)
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
runtimeStatus = (headers?: object, signal?: AbortSignal): Promise<RuntimeStatusReturn> => {
|
|
855
|
+
return this.fetch(this.url('RuntimeStatus'), createHttpRequest('{}', headers, signal)).then(
|
|
856
|
+
(res) => {
|
|
857
|
+
return buildResponse(res).then((_data) => {
|
|
858
|
+
return JsonDecode<RuntimeStatusReturn>(_data, 'RuntimeStatusReturn')
|
|
859
|
+
})
|
|
860
|
+
},
|
|
861
|
+
(error) => {
|
|
862
|
+
throw WebrpcRequestFailedError.new({
|
|
863
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
864
|
+
})
|
|
865
|
+
},
|
|
866
|
+
)
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
getSequenceContext = (headers?: object, signal?: AbortSignal): Promise<GetSequenceContextReturn> => {
|
|
870
|
+
return this.fetch(this.url('GetSequenceContext'), createHttpRequest('{}', headers, signal)).then(
|
|
871
|
+
(res) => {
|
|
872
|
+
return buildResponse(res).then((_data) => {
|
|
873
|
+
return JsonDecode<GetSequenceContextReturn>(_data, 'GetSequenceContextReturn')
|
|
874
|
+
})
|
|
875
|
+
},
|
|
876
|
+
(error) => {
|
|
877
|
+
throw WebrpcRequestFailedError.new({
|
|
878
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
879
|
+
})
|
|
880
|
+
},
|
|
881
|
+
)
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
getChainID = (headers?: object, signal?: AbortSignal): Promise<GetChainIDReturn> => {
|
|
885
|
+
return this.fetch(this.url('GetChainID'), createHttpRequest('{}', headers, signal)).then(
|
|
886
|
+
(res) => {
|
|
887
|
+
return buildResponse(res).then((_data) => {
|
|
888
|
+
return JsonDecode<GetChainIDReturn>(_data, 'GetChainIDReturn')
|
|
889
|
+
})
|
|
890
|
+
},
|
|
891
|
+
(error) => {
|
|
892
|
+
throw WebrpcRequestFailedError.new({
|
|
893
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
894
|
+
})
|
|
895
|
+
},
|
|
896
|
+
)
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
sendMetaTxn = (req: SendMetaTxnArgs, headers?: object, signal?: AbortSignal): Promise<SendMetaTxnReturn> => {
|
|
900
|
+
return this.fetch(
|
|
901
|
+
this.url('SendMetaTxn'),
|
|
902
|
+
createHttpRequest(JsonEncode(req, 'SendMetaTxnArgs'), headers, signal),
|
|
903
|
+
).then(
|
|
904
|
+
(res) => {
|
|
905
|
+
return buildResponse(res).then((_data) => {
|
|
906
|
+
return JsonDecode<SendMetaTxnReturn>(_data, 'SendMetaTxnReturn')
|
|
907
|
+
})
|
|
908
|
+
},
|
|
909
|
+
(error) => {
|
|
910
|
+
throw WebrpcRequestFailedError.new({
|
|
911
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
912
|
+
})
|
|
913
|
+
},
|
|
914
|
+
)
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
getMetaTxnNonce = (
|
|
918
|
+
req: GetMetaTxnNonceArgs,
|
|
919
|
+
headers?: object,
|
|
920
|
+
signal?: AbortSignal,
|
|
921
|
+
): Promise<GetMetaTxnNonceReturn> => {
|
|
922
|
+
return this.fetch(
|
|
923
|
+
this.url('GetMetaTxnNonce'),
|
|
924
|
+
createHttpRequest(JsonEncode(req, 'GetMetaTxnNonceArgs'), headers, signal),
|
|
925
|
+
).then(
|
|
926
|
+
(res) => {
|
|
927
|
+
return buildResponse(res).then((_data) => {
|
|
928
|
+
return JsonDecode<GetMetaTxnNonceReturn>(_data, 'GetMetaTxnNonceReturn')
|
|
929
|
+
})
|
|
930
|
+
},
|
|
931
|
+
(error) => {
|
|
932
|
+
throw WebrpcRequestFailedError.new({
|
|
933
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
934
|
+
})
|
|
935
|
+
},
|
|
936
|
+
)
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
getMetaTxnReceipt = (
|
|
940
|
+
req: GetMetaTxnReceiptArgs,
|
|
941
|
+
headers?: object,
|
|
942
|
+
signal?: AbortSignal,
|
|
943
|
+
): Promise<GetMetaTxnReceiptReturn> => {
|
|
944
|
+
return this.fetch(
|
|
945
|
+
this.url('GetMetaTxnReceipt'),
|
|
946
|
+
createHttpRequest(JsonEncode(req, 'GetMetaTxnReceiptArgs'), headers, signal),
|
|
947
|
+
).then(
|
|
948
|
+
(res) => {
|
|
949
|
+
return buildResponse(res).then((_data) => {
|
|
950
|
+
return JsonDecode<GetMetaTxnReceiptReturn>(_data, 'GetMetaTxnReceiptReturn')
|
|
951
|
+
})
|
|
952
|
+
},
|
|
953
|
+
(error) => {
|
|
954
|
+
throw WebrpcRequestFailedError.new({
|
|
955
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
956
|
+
})
|
|
957
|
+
},
|
|
958
|
+
)
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
simulate = (req: SimulateArgs, headers?: object, signal?: AbortSignal): Promise<SimulateReturn> => {
|
|
962
|
+
return this.fetch(this.url('Simulate'), createHttpRequest(JsonEncode(req, 'SimulateArgs'), headers, signal)).then(
|
|
963
|
+
(res) => {
|
|
964
|
+
return buildResponse(res).then((_data) => {
|
|
965
|
+
return JsonDecode<SimulateReturn>(_data, 'SimulateReturn')
|
|
966
|
+
})
|
|
967
|
+
},
|
|
968
|
+
(error) => {
|
|
969
|
+
throw WebrpcRequestFailedError.new({
|
|
970
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
971
|
+
})
|
|
972
|
+
},
|
|
973
|
+
)
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
simulateV3 = (req: SimulateV3Args, headers?: object, signal?: AbortSignal): Promise<SimulateV3Return> => {
|
|
977
|
+
return this.fetch(
|
|
978
|
+
this.url('SimulateV3'),
|
|
979
|
+
createHttpRequest(JsonEncode(req, 'SimulateV3Args'), headers, signal),
|
|
980
|
+
).then(
|
|
981
|
+
(res) => {
|
|
982
|
+
return buildResponse(res).then((_data) => {
|
|
983
|
+
return JsonDecode<SimulateV3Return>(_data, 'SimulateV3Return')
|
|
984
|
+
})
|
|
985
|
+
},
|
|
986
|
+
(error) => {
|
|
987
|
+
throw WebrpcRequestFailedError.new({
|
|
988
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
989
|
+
})
|
|
990
|
+
},
|
|
991
|
+
)
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
updateMetaTxnGasLimits = (
|
|
995
|
+
req: UpdateMetaTxnGasLimitsArgs,
|
|
996
|
+
headers?: object,
|
|
997
|
+
signal?: AbortSignal,
|
|
998
|
+
): Promise<UpdateMetaTxnGasLimitsReturn> => {
|
|
999
|
+
return this.fetch(
|
|
1000
|
+
this.url('UpdateMetaTxnGasLimits'),
|
|
1001
|
+
createHttpRequest(JsonEncode(req, 'UpdateMetaTxnGasLimitsArgs'), headers, signal),
|
|
1002
|
+
).then(
|
|
1003
|
+
(res) => {
|
|
1004
|
+
return buildResponse(res).then((_data) => {
|
|
1005
|
+
return JsonDecode<UpdateMetaTxnGasLimitsReturn>(_data, 'UpdateMetaTxnGasLimitsReturn')
|
|
1006
|
+
})
|
|
1007
|
+
},
|
|
1008
|
+
(error) => {
|
|
1009
|
+
throw WebrpcRequestFailedError.new({
|
|
1010
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1011
|
+
})
|
|
1012
|
+
},
|
|
1013
|
+
)
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
feeTokens = (headers?: object, signal?: AbortSignal): Promise<FeeTokensReturn> => {
|
|
1017
|
+
return this.fetch(this.url('FeeTokens'), createHttpRequest('{}', headers, signal)).then(
|
|
1018
|
+
(res) => {
|
|
1019
|
+
return buildResponse(res).then((_data) => {
|
|
1020
|
+
return JsonDecode<FeeTokensReturn>(_data, 'FeeTokensReturn')
|
|
1021
|
+
})
|
|
1022
|
+
},
|
|
1023
|
+
(error) => {
|
|
1024
|
+
throw WebrpcRequestFailedError.new({
|
|
1025
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1026
|
+
})
|
|
1027
|
+
},
|
|
1028
|
+
)
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
feeOptions = (req: FeeOptionsArgs, headers?: object, signal?: AbortSignal): Promise<FeeOptionsReturn> => {
|
|
1032
|
+
return this.fetch(
|
|
1033
|
+
this.url('FeeOptions'),
|
|
1034
|
+
createHttpRequest(JsonEncode(req, 'FeeOptionsArgs'), headers, signal),
|
|
1035
|
+
).then(
|
|
1036
|
+
(res) => {
|
|
1037
|
+
return buildResponse(res).then((_data) => {
|
|
1038
|
+
return JsonDecode<FeeOptionsReturn>(_data, 'FeeOptionsReturn')
|
|
1039
|
+
})
|
|
1040
|
+
},
|
|
1041
|
+
(error) => {
|
|
1042
|
+
throw WebrpcRequestFailedError.new({
|
|
1043
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1044
|
+
})
|
|
1045
|
+
},
|
|
1046
|
+
)
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
getMetaTxnNetworkFeeOptions = (
|
|
1050
|
+
req: GetMetaTxnNetworkFeeOptionsArgs,
|
|
1051
|
+
headers?: object,
|
|
1052
|
+
signal?: AbortSignal,
|
|
1053
|
+
): Promise<GetMetaTxnNetworkFeeOptionsReturn> => {
|
|
1054
|
+
return this.fetch(
|
|
1055
|
+
this.url('GetMetaTxnNetworkFeeOptions'),
|
|
1056
|
+
createHttpRequest(JsonEncode(req, 'GetMetaTxnNetworkFeeOptionsArgs'), headers, signal),
|
|
1057
|
+
).then(
|
|
1058
|
+
(res) => {
|
|
1059
|
+
return buildResponse(res).then((_data) => {
|
|
1060
|
+
return JsonDecode<GetMetaTxnNetworkFeeOptionsReturn>(_data, 'GetMetaTxnNetworkFeeOptionsReturn')
|
|
1061
|
+
})
|
|
1062
|
+
},
|
|
1063
|
+
(error) => {
|
|
1064
|
+
throw WebrpcRequestFailedError.new({
|
|
1065
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1066
|
+
})
|
|
1067
|
+
},
|
|
1068
|
+
)
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
getMetaTransactions = (
|
|
1072
|
+
req: GetMetaTransactionsArgs,
|
|
1073
|
+
headers?: object,
|
|
1074
|
+
signal?: AbortSignal,
|
|
1075
|
+
): Promise<GetMetaTransactionsReturn> => {
|
|
1076
|
+
return this.fetch(
|
|
1077
|
+
this.url('GetMetaTransactions'),
|
|
1078
|
+
createHttpRequest(JsonEncode(req, 'GetMetaTransactionsArgs'), headers, signal),
|
|
1079
|
+
).then(
|
|
1080
|
+
(res) => {
|
|
1081
|
+
return buildResponse(res).then((_data) => {
|
|
1082
|
+
return JsonDecode<GetMetaTransactionsReturn>(_data, 'GetMetaTransactionsReturn')
|
|
1083
|
+
})
|
|
1084
|
+
},
|
|
1085
|
+
(error) => {
|
|
1086
|
+
throw WebrpcRequestFailedError.new({
|
|
1087
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1088
|
+
})
|
|
1089
|
+
},
|
|
1090
|
+
)
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
getTransactionCost = (
|
|
1094
|
+
req: GetTransactionCostArgs,
|
|
1095
|
+
headers?: object,
|
|
1096
|
+
signal?: AbortSignal,
|
|
1097
|
+
): Promise<GetTransactionCostReturn> => {
|
|
1098
|
+
return this.fetch(
|
|
1099
|
+
this.url('GetTransactionCost'),
|
|
1100
|
+
createHttpRequest(JsonEncode(req, 'GetTransactionCostArgs'), headers, signal),
|
|
1101
|
+
).then(
|
|
1102
|
+
(res) => {
|
|
1103
|
+
return buildResponse(res).then((_data) => {
|
|
1104
|
+
return JsonDecode<GetTransactionCostReturn>(_data, 'GetTransactionCostReturn')
|
|
1105
|
+
})
|
|
1106
|
+
},
|
|
1107
|
+
(error) => {
|
|
1108
|
+
throw WebrpcRequestFailedError.new({
|
|
1109
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1110
|
+
})
|
|
1111
|
+
},
|
|
1112
|
+
)
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
sentTransactions = (
|
|
1116
|
+
req: SentTransactionsArgs,
|
|
1117
|
+
headers?: object,
|
|
1118
|
+
signal?: AbortSignal,
|
|
1119
|
+
): Promise<SentTransactionsReturn> => {
|
|
1120
|
+
return this.fetch(
|
|
1121
|
+
this.url('SentTransactions'),
|
|
1122
|
+
createHttpRequest(JsonEncode(req, 'SentTransactionsArgs'), headers, signal),
|
|
1123
|
+
).then(
|
|
1124
|
+
(res) => {
|
|
1125
|
+
return buildResponse(res).then((_data) => {
|
|
1126
|
+
return JsonDecode<SentTransactionsReturn>(_data, 'SentTransactionsReturn')
|
|
1127
|
+
})
|
|
1128
|
+
},
|
|
1129
|
+
(error) => {
|
|
1130
|
+
throw WebrpcRequestFailedError.new({
|
|
1131
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1132
|
+
})
|
|
1133
|
+
},
|
|
1134
|
+
)
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
pendingTransactions = (
|
|
1138
|
+
req: PendingTransactionsArgs,
|
|
1139
|
+
headers?: object,
|
|
1140
|
+
signal?: AbortSignal,
|
|
1141
|
+
): Promise<PendingTransactionsReturn> => {
|
|
1142
|
+
return this.fetch(
|
|
1143
|
+
this.url('PendingTransactions'),
|
|
1144
|
+
createHttpRequest(JsonEncode(req, 'PendingTransactionsArgs'), headers, signal),
|
|
1145
|
+
).then(
|
|
1146
|
+
(res) => {
|
|
1147
|
+
return buildResponse(res).then((_data) => {
|
|
1148
|
+
return JsonDecode<PendingTransactionsReturn>(_data, 'PendingTransactionsReturn')
|
|
1149
|
+
})
|
|
1150
|
+
},
|
|
1151
|
+
(error) => {
|
|
1152
|
+
throw WebrpcRequestFailedError.new({
|
|
1153
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1154
|
+
})
|
|
1155
|
+
},
|
|
1156
|
+
)
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
getGasTank = (req: GetGasTankArgs, headers?: object, signal?: AbortSignal): Promise<GetGasTankReturn> => {
|
|
1160
|
+
return this.fetch(
|
|
1161
|
+
this.url('GetGasTank'),
|
|
1162
|
+
createHttpRequest(JsonEncode(req, 'GetGasTankArgs'), headers, signal),
|
|
1163
|
+
).then(
|
|
1164
|
+
(res) => {
|
|
1165
|
+
return buildResponse(res).then((_data) => {
|
|
1166
|
+
return JsonDecode<GetGasTankReturn>(_data, 'GetGasTankReturn')
|
|
1167
|
+
})
|
|
1168
|
+
},
|
|
1169
|
+
(error) => {
|
|
1170
|
+
throw WebrpcRequestFailedError.new({
|
|
1171
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1172
|
+
})
|
|
1173
|
+
},
|
|
1174
|
+
)
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
addGasTank = (req: AddGasTankArgs, headers?: object, signal?: AbortSignal): Promise<AddGasTankReturn> => {
|
|
1178
|
+
return this.fetch(
|
|
1179
|
+
this.url('AddGasTank'),
|
|
1180
|
+
createHttpRequest(JsonEncode(req, 'AddGasTankArgs'), headers, signal),
|
|
1181
|
+
).then(
|
|
1182
|
+
(res) => {
|
|
1183
|
+
return buildResponse(res).then((_data) => {
|
|
1184
|
+
return JsonDecode<AddGasTankReturn>(_data, 'AddGasTankReturn')
|
|
1185
|
+
})
|
|
1186
|
+
},
|
|
1187
|
+
(error) => {
|
|
1188
|
+
throw WebrpcRequestFailedError.new({
|
|
1189
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1190
|
+
})
|
|
1191
|
+
},
|
|
1192
|
+
)
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
updateGasTank = (req: UpdateGasTankArgs, headers?: object, signal?: AbortSignal): Promise<UpdateGasTankReturn> => {
|
|
1196
|
+
return this.fetch(
|
|
1197
|
+
this.url('UpdateGasTank'),
|
|
1198
|
+
createHttpRequest(JsonEncode(req, 'UpdateGasTankArgs'), headers, signal),
|
|
1199
|
+
).then(
|
|
1200
|
+
(res) => {
|
|
1201
|
+
return buildResponse(res).then((_data) => {
|
|
1202
|
+
return JsonDecode<UpdateGasTankReturn>(_data, 'UpdateGasTankReturn')
|
|
1203
|
+
})
|
|
1204
|
+
},
|
|
1205
|
+
(error) => {
|
|
1206
|
+
throw WebrpcRequestFailedError.new({
|
|
1207
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1208
|
+
})
|
|
1209
|
+
},
|
|
1210
|
+
)
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
nextGasTankBalanceAdjustmentNonce = (
|
|
1214
|
+
req: NextGasTankBalanceAdjustmentNonceArgs,
|
|
1215
|
+
headers?: object,
|
|
1216
|
+
signal?: AbortSignal,
|
|
1217
|
+
): Promise<NextGasTankBalanceAdjustmentNonceReturn> => {
|
|
1218
|
+
return this.fetch(
|
|
1219
|
+
this.url('NextGasTankBalanceAdjustmentNonce'),
|
|
1220
|
+
createHttpRequest(JsonEncode(req, 'NextGasTankBalanceAdjustmentNonceArgs'), headers, signal),
|
|
1221
|
+
).then(
|
|
1222
|
+
(res) => {
|
|
1223
|
+
return buildResponse(res).then((_data) => {
|
|
1224
|
+
return JsonDecode<NextGasTankBalanceAdjustmentNonceReturn>(_data, 'NextGasTankBalanceAdjustmentNonceReturn')
|
|
1225
|
+
})
|
|
1226
|
+
},
|
|
1227
|
+
(error) => {
|
|
1228
|
+
throw WebrpcRequestFailedError.new({
|
|
1229
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1230
|
+
})
|
|
1231
|
+
},
|
|
1232
|
+
)
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
adjustGasTankBalance = (
|
|
1236
|
+
req: AdjustGasTankBalanceArgs,
|
|
1237
|
+
headers?: object,
|
|
1238
|
+
signal?: AbortSignal,
|
|
1239
|
+
): Promise<AdjustGasTankBalanceReturn> => {
|
|
1240
|
+
return this.fetch(
|
|
1241
|
+
this.url('AdjustGasTankBalance'),
|
|
1242
|
+
createHttpRequest(JsonEncode(req, 'AdjustGasTankBalanceArgs'), headers, signal),
|
|
1243
|
+
).then(
|
|
1244
|
+
(res) => {
|
|
1245
|
+
return buildResponse(res).then((_data) => {
|
|
1246
|
+
return JsonDecode<AdjustGasTankBalanceReturn>(_data, 'AdjustGasTankBalanceReturn')
|
|
1247
|
+
})
|
|
1248
|
+
},
|
|
1249
|
+
(error) => {
|
|
1250
|
+
throw WebrpcRequestFailedError.new({
|
|
1251
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1252
|
+
})
|
|
1253
|
+
},
|
|
1254
|
+
)
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
getGasTankBalanceAdjustment = (
|
|
1258
|
+
req: GetGasTankBalanceAdjustmentArgs,
|
|
1259
|
+
headers?: object,
|
|
1260
|
+
signal?: AbortSignal,
|
|
1261
|
+
): Promise<GetGasTankBalanceAdjustmentReturn> => {
|
|
1262
|
+
return this.fetch(
|
|
1263
|
+
this.url('GetGasTankBalanceAdjustment'),
|
|
1264
|
+
createHttpRequest(JsonEncode(req, 'GetGasTankBalanceAdjustmentArgs'), headers, signal),
|
|
1265
|
+
).then(
|
|
1266
|
+
(res) => {
|
|
1267
|
+
return buildResponse(res).then((_data) => {
|
|
1268
|
+
return JsonDecode<GetGasTankBalanceAdjustmentReturn>(_data, 'GetGasTankBalanceAdjustmentReturn')
|
|
1269
|
+
})
|
|
1270
|
+
},
|
|
1271
|
+
(error) => {
|
|
1272
|
+
throw WebrpcRequestFailedError.new({
|
|
1273
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1274
|
+
})
|
|
1275
|
+
},
|
|
1276
|
+
)
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
listGasTankBalanceAdjustments = (
|
|
1280
|
+
req: ListGasTankBalanceAdjustmentsArgs,
|
|
1281
|
+
headers?: object,
|
|
1282
|
+
signal?: AbortSignal,
|
|
1283
|
+
): Promise<ListGasTankBalanceAdjustmentsReturn> => {
|
|
1284
|
+
return this.fetch(
|
|
1285
|
+
this.url('ListGasTankBalanceAdjustments'),
|
|
1286
|
+
createHttpRequest(JsonEncode(req, 'ListGasTankBalanceAdjustmentsArgs'), headers, signal),
|
|
1287
|
+
).then(
|
|
1288
|
+
(res) => {
|
|
1289
|
+
return buildResponse(res).then((_data) => {
|
|
1290
|
+
return JsonDecode<ListGasTankBalanceAdjustmentsReturn>(_data, 'ListGasTankBalanceAdjustmentsReturn')
|
|
1291
|
+
})
|
|
1292
|
+
},
|
|
1293
|
+
(error) => {
|
|
1294
|
+
throw WebrpcRequestFailedError.new({
|
|
1295
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1296
|
+
})
|
|
1297
|
+
},
|
|
1298
|
+
)
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
listGasSponsors = (
|
|
1302
|
+
req: ListGasSponsorsArgs,
|
|
1303
|
+
headers?: object,
|
|
1304
|
+
signal?: AbortSignal,
|
|
1305
|
+
): Promise<ListGasSponsorsReturn> => {
|
|
1306
|
+
return this.fetch(
|
|
1307
|
+
this.url('ListGasSponsors'),
|
|
1308
|
+
createHttpRequest(JsonEncode(req, 'ListGasSponsorsArgs'), headers, signal),
|
|
1309
|
+
).then(
|
|
1310
|
+
(res) => {
|
|
1311
|
+
return buildResponse(res).then((_data) => {
|
|
1312
|
+
return JsonDecode<ListGasSponsorsReturn>(_data, 'ListGasSponsorsReturn')
|
|
1313
|
+
})
|
|
1314
|
+
},
|
|
1315
|
+
(error) => {
|
|
1316
|
+
throw WebrpcRequestFailedError.new({
|
|
1317
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1318
|
+
})
|
|
1319
|
+
},
|
|
1320
|
+
)
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
getGasSponsor = (req: GetGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<GetGasSponsorReturn> => {
|
|
1324
|
+
return this.fetch(
|
|
1325
|
+
this.url('GetGasSponsor'),
|
|
1326
|
+
createHttpRequest(JsonEncode(req, 'GetGasSponsorArgs'), headers, signal),
|
|
1327
|
+
).then(
|
|
1328
|
+
(res) => {
|
|
1329
|
+
return buildResponse(res).then((_data) => {
|
|
1330
|
+
return JsonDecode<GetGasSponsorReturn>(_data, 'GetGasSponsorReturn')
|
|
1331
|
+
})
|
|
1332
|
+
},
|
|
1333
|
+
(error) => {
|
|
1334
|
+
throw WebrpcRequestFailedError.new({
|
|
1335
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1336
|
+
})
|
|
1337
|
+
},
|
|
1338
|
+
)
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
addGasSponsor = (req: AddGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<AddGasSponsorReturn> => {
|
|
1342
|
+
return this.fetch(
|
|
1343
|
+
this.url('AddGasSponsor'),
|
|
1344
|
+
createHttpRequest(JsonEncode(req, 'AddGasSponsorArgs'), headers, signal),
|
|
1345
|
+
).then(
|
|
1346
|
+
(res) => {
|
|
1347
|
+
return buildResponse(res).then((_data) => {
|
|
1348
|
+
return JsonDecode<AddGasSponsorReturn>(_data, 'AddGasSponsorReturn')
|
|
1349
|
+
})
|
|
1350
|
+
},
|
|
1351
|
+
(error) => {
|
|
1352
|
+
throw WebrpcRequestFailedError.new({
|
|
1353
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1354
|
+
})
|
|
1355
|
+
},
|
|
1356
|
+
)
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
updateGasSponsor = (
|
|
1360
|
+
req: UpdateGasSponsorArgs,
|
|
1361
|
+
headers?: object,
|
|
1362
|
+
signal?: AbortSignal,
|
|
1363
|
+
): Promise<UpdateGasSponsorReturn> => {
|
|
1364
|
+
return this.fetch(
|
|
1365
|
+
this.url('UpdateGasSponsor'),
|
|
1366
|
+
createHttpRequest(JsonEncode(req, 'UpdateGasSponsorArgs'), headers, signal),
|
|
1367
|
+
).then(
|
|
1368
|
+
(res) => {
|
|
1369
|
+
return buildResponse(res).then((_data) => {
|
|
1370
|
+
return JsonDecode<UpdateGasSponsorReturn>(_data, 'UpdateGasSponsorReturn')
|
|
1371
|
+
})
|
|
1372
|
+
},
|
|
1373
|
+
(error) => {
|
|
1374
|
+
throw WebrpcRequestFailedError.new({
|
|
1375
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1376
|
+
})
|
|
1377
|
+
},
|
|
1378
|
+
)
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
removeGasSponsor = (
|
|
1382
|
+
req: RemoveGasSponsorArgs,
|
|
1383
|
+
headers?: object,
|
|
1384
|
+
signal?: AbortSignal,
|
|
1385
|
+
): Promise<RemoveGasSponsorReturn> => {
|
|
1386
|
+
return this.fetch(
|
|
1387
|
+
this.url('RemoveGasSponsor'),
|
|
1388
|
+
createHttpRequest(JsonEncode(req, 'RemoveGasSponsorArgs'), headers, signal),
|
|
1389
|
+
).then(
|
|
1390
|
+
(res) => {
|
|
1391
|
+
return buildResponse(res).then((_data) => {
|
|
1392
|
+
return JsonDecode<RemoveGasSponsorReturn>(_data, 'RemoveGasSponsorReturn')
|
|
1393
|
+
})
|
|
1394
|
+
},
|
|
1395
|
+
(error) => {
|
|
1396
|
+
throw WebrpcRequestFailedError.new({
|
|
1397
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1398
|
+
})
|
|
1399
|
+
},
|
|
1400
|
+
)
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
addressGasSponsors = (
|
|
1404
|
+
req: AddressGasSponsorsArgs,
|
|
1405
|
+
headers?: object,
|
|
1406
|
+
signal?: AbortSignal,
|
|
1407
|
+
): Promise<AddressGasSponsorsReturn> => {
|
|
1408
|
+
return this.fetch(
|
|
1409
|
+
this.url('AddressGasSponsors'),
|
|
1410
|
+
createHttpRequest(JsonEncode(req, 'AddressGasSponsorsArgs'), headers, signal),
|
|
1411
|
+
).then(
|
|
1412
|
+
(res) => {
|
|
1413
|
+
return buildResponse(res).then((_data) => {
|
|
1414
|
+
return JsonDecode<AddressGasSponsorsReturn>(_data, 'AddressGasSponsorsReturn')
|
|
1415
|
+
})
|
|
1416
|
+
},
|
|
1417
|
+
(error) => {
|
|
1418
|
+
throw WebrpcRequestFailedError.new({
|
|
1419
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1420
|
+
})
|
|
1421
|
+
},
|
|
1422
|
+
)
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
getProjectBalance = (
|
|
1426
|
+
req: GetProjectBalanceArgs,
|
|
1427
|
+
headers?: object,
|
|
1428
|
+
signal?: AbortSignal,
|
|
1429
|
+
): Promise<GetProjectBalanceReturn> => {
|
|
1430
|
+
return this.fetch(
|
|
1431
|
+
this.url('GetProjectBalance'),
|
|
1432
|
+
createHttpRequest(JsonEncode(req, 'GetProjectBalanceArgs'), headers, signal),
|
|
1433
|
+
).then(
|
|
1434
|
+
(res) => {
|
|
1435
|
+
return buildResponse(res).then((_data) => {
|
|
1436
|
+
return JsonDecode<GetProjectBalanceReturn>(_data, 'GetProjectBalanceReturn')
|
|
1437
|
+
})
|
|
1438
|
+
},
|
|
1439
|
+
(error) => {
|
|
1440
|
+
throw WebrpcRequestFailedError.new({
|
|
1441
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1442
|
+
})
|
|
1443
|
+
},
|
|
1444
|
+
)
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
adjustProjectBalance = (
|
|
1448
|
+
req: AdjustProjectBalanceArgs,
|
|
1449
|
+
headers?: object,
|
|
1450
|
+
signal?: AbortSignal,
|
|
1451
|
+
): Promise<AdjustProjectBalanceReturn> => {
|
|
1452
|
+
return this.fetch(
|
|
1453
|
+
this.url('AdjustProjectBalance'),
|
|
1454
|
+
createHttpRequest(JsonEncode(req, 'AdjustProjectBalanceArgs'), headers, signal),
|
|
1455
|
+
).then(
|
|
1456
|
+
(res) => {
|
|
1457
|
+
return buildResponse(res).then((_data) => {
|
|
1458
|
+
return JsonDecode<AdjustProjectBalanceReturn>(_data, 'AdjustProjectBalanceReturn')
|
|
1459
|
+
})
|
|
1460
|
+
},
|
|
1461
|
+
(error) => {
|
|
1462
|
+
throw WebrpcRequestFailedError.new({
|
|
1463
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
|
|
1464
|
+
})
|
|
1465
|
+
},
|
|
1466
|
+
)
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
const createHttpRequest = (body: string = '{}', headers: object = {}, signal: AbortSignal | null = null): object => {
|
|
1471
|
+
const reqHeaders: { [key: string]: string } = { ...headers, 'Content-Type': 'application/json' }
|
|
1472
|
+
return { method: 'POST', headers: reqHeaders, body, signal }
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
const buildResponse = (res: Response): Promise<any> => {
|
|
1476
|
+
return res.text().then((text) => {
|
|
1477
|
+
let data
|
|
1478
|
+
try {
|
|
1479
|
+
data = JSON.parse(text)
|
|
1480
|
+
} catch (error) {
|
|
1481
|
+
throw WebrpcBadResponseError.new({
|
|
1482
|
+
status: res.status,
|
|
1483
|
+
cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`,
|
|
1484
|
+
})
|
|
1485
|
+
}
|
|
1486
|
+
if (!res.ok) {
|
|
1487
|
+
const code: number = typeof data.code === 'number' ? data.code : 0
|
|
1488
|
+
throw (webrpcErrorByCode[code] || WebrpcError).new(data)
|
|
1489
|
+
}
|
|
1490
|
+
return data
|
|
1491
|
+
})
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>
|
|
1495
|
+
|
|
1496
|
+
//
|
|
1497
|
+
// BigInt helpers
|
|
1498
|
+
//
|
|
1499
|
+
|
|
1500
|
+
const BIG_INT_FIELDS: { [typ: string]: (string | [string, string])[] } = {
|
|
1501
|
+
SendMetaTxnArgs: [['preconditions', 'TransactionPrecondition[]']],
|
|
1502
|
+
TransactionPrecondition: ['minAmount'],
|
|
1503
|
+
Transactions: [['preconditions', 'TransactionPrecondition[]']],
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
// Encode in-place: mutate provided object graph to serialize bigints to strings.
|
|
1507
|
+
function encodeType(typ: string, obj: any): any {
|
|
1508
|
+
if (obj == null || typeof obj !== 'object') return obj
|
|
1509
|
+
const descs = BIG_INT_FIELDS[typ] || []
|
|
1510
|
+
if (!descs.length) return obj
|
|
1511
|
+
for (const d of descs) {
|
|
1512
|
+
if (Array.isArray(d)) {
|
|
1513
|
+
const [fieldName, nestedType] = d
|
|
1514
|
+
if (fieldName.endsWith('[]')) {
|
|
1515
|
+
const base = fieldName.slice(0, -2)
|
|
1516
|
+
const arr = obj[base]
|
|
1517
|
+
if (Array.isArray(arr)) {
|
|
1518
|
+
for (let i = 0; i < arr.length; i++) arr[i] = encodeType(nestedType, arr[i])
|
|
1519
|
+
}
|
|
1520
|
+
} else if (obj[fieldName]) {
|
|
1521
|
+
obj[fieldName] = encodeType(nestedType, obj[fieldName])
|
|
1522
|
+
}
|
|
1523
|
+
continue
|
|
1524
|
+
}
|
|
1525
|
+
if (d.endsWith('[]')) {
|
|
1526
|
+
const base = d.slice(0, -2)
|
|
1527
|
+
const arr = obj[base]
|
|
1528
|
+
if (Array.isArray(arr)) {
|
|
1529
|
+
for (let i = 0; i < arr.length; i++) {
|
|
1530
|
+
if (typeof arr[i] === 'bigint') arr[i] = arr[i].toString()
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
continue
|
|
1534
|
+
}
|
|
1535
|
+
if (typeof obj[d] === 'bigint') obj[d] = obj[d].toString()
|
|
1536
|
+
}
|
|
1537
|
+
return obj
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
// Decode in-place: mutate object graph; throw if expected numeric string is invalid.
|
|
1541
|
+
function decodeType(typ: string, obj: any): any {
|
|
1542
|
+
if (obj == null || typeof obj !== 'object') return obj
|
|
1543
|
+
const descs = BIG_INT_FIELDS[typ] || []
|
|
1544
|
+
if (!descs.length) return obj
|
|
1545
|
+
for (const d of descs) {
|
|
1546
|
+
if (Array.isArray(d)) {
|
|
1547
|
+
const [fieldName, nestedType] = d
|
|
1548
|
+
if (fieldName.endsWith('[]')) {
|
|
1549
|
+
const base = fieldName.slice(0, -2)
|
|
1550
|
+
const arr = obj[base]
|
|
1551
|
+
if (Array.isArray(arr)) {
|
|
1552
|
+
for (let i = 0; i < arr.length; i++) arr[i] = decodeType(nestedType, arr[i])
|
|
1553
|
+
}
|
|
1554
|
+
} else if (obj[fieldName]) {
|
|
1555
|
+
obj[fieldName] = decodeType(nestedType, obj[fieldName])
|
|
1556
|
+
}
|
|
1557
|
+
continue
|
|
1558
|
+
}
|
|
1559
|
+
if (d.endsWith('[]')) {
|
|
1560
|
+
const base = d.slice(0, -2)
|
|
1561
|
+
const arr = obj[base]
|
|
1562
|
+
if (Array.isArray(arr)) {
|
|
1563
|
+
for (let i = 0; i < arr.length; i++) {
|
|
1564
|
+
const v = arr[i]
|
|
1565
|
+
if (typeof v === 'string') {
|
|
1566
|
+
try {
|
|
1567
|
+
arr[i] = BigInt(v)
|
|
1568
|
+
} catch (e) {
|
|
1569
|
+
throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${base}[${i}]: ${v}` })
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
continue
|
|
1575
|
+
}
|
|
1576
|
+
const v = obj[d]
|
|
1577
|
+
if (typeof v === 'string') {
|
|
1578
|
+
try {
|
|
1579
|
+
obj[d] = BigInt(v)
|
|
1580
|
+
} catch (e) {
|
|
1581
|
+
throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${d}: ${v}` })
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
return obj
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
// Encode object of given root type to JSON with BigInts converted to decimal strings.
|
|
1589
|
+
export const JsonEncode = <T = any>(obj: T, typ: string = ''): string => {
|
|
1590
|
+
return JSON.stringify(encodeType(typ, obj))
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
// Decode data (JSON string or already-parsed object) and convert declared BigInt string fields back to BigInt.
|
|
1594
|
+
export const JsonDecode = <T = any>(data: string | any, typ: string = ''): T => {
|
|
1595
|
+
let parsed: any = data
|
|
1596
|
+
if (typeof data === 'string') {
|
|
1597
|
+
try {
|
|
1598
|
+
parsed = JSON.parse(data)
|
|
1599
|
+
} catch (err) {
|
|
1600
|
+
throw WebrpcBadResponseError.new({ cause: `JsonDecode: JSON.parse failed: ${(err as Error).message}` })
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
return decodeType(typ, parsed) as T
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
//
|
|
1607
|
+
// Errors
|
|
1608
|
+
//
|
|
1609
|
+
|
|
1610
|
+
type WebrpcErrorParams = { name?: string; code?: number; message?: string; status?: number; cause?: string }
|
|
1611
|
+
|
|
1612
|
+
export class WebrpcError extends Error {
|
|
1613
|
+
code: number
|
|
1614
|
+
status: number
|
|
1615
|
+
|
|
1616
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1617
|
+
super(error.message)
|
|
1618
|
+
this.name = error.name || 'WebrpcEndpointError'
|
|
1619
|
+
this.code = typeof error.code === 'number' ? error.code : 0
|
|
1620
|
+
this.message = error.message || `endpoint error`
|
|
1621
|
+
this.status = typeof error.status === 'number' ? error.status : 400
|
|
1622
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1623
|
+
Object.setPrototypeOf(this, WebrpcError.prototype)
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
static new(payload: any): WebrpcError {
|
|
1627
|
+
return new this({ message: payload.message, code: payload.code, status: payload.status, cause: payload.cause })
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
export class WebrpcEndpointError extends WebrpcError {
|
|
1632
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1633
|
+
super(error)
|
|
1634
|
+
this.name = error.name || 'WebrpcEndpoint'
|
|
1635
|
+
this.code = typeof error.code === 'number' ? error.code : 0
|
|
1636
|
+
this.message = error.message || `endpoint error`
|
|
1637
|
+
this.status = typeof error.status === 'number' ? error.status : 400
|
|
1638
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1639
|
+
Object.setPrototypeOf(this, WebrpcEndpointError.prototype)
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
export class WebrpcRequestFailedError extends WebrpcError {
|
|
1644
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1645
|
+
super(error)
|
|
1646
|
+
this.name = error.name || 'WebrpcRequestFailed'
|
|
1647
|
+
this.code = typeof error.code === 'number' ? error.code : -1
|
|
1648
|
+
this.message = error.message || `request failed`
|
|
1649
|
+
this.status = typeof error.status === 'number' ? error.status : 400
|
|
1650
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1651
|
+
Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype)
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
export class WebrpcBadRouteError extends WebrpcError {
|
|
1656
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1657
|
+
super(error)
|
|
1658
|
+
this.name = error.name || 'WebrpcBadRoute'
|
|
1659
|
+
this.code = typeof error.code === 'number' ? error.code : -2
|
|
1660
|
+
this.message = error.message || `bad route`
|
|
1661
|
+
this.status = typeof error.status === 'number' ? error.status : 404
|
|
1662
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1663
|
+
Object.setPrototypeOf(this, WebrpcBadRouteError.prototype)
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
export class WebrpcBadMethodError extends WebrpcError {
|
|
1668
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1669
|
+
super(error)
|
|
1670
|
+
this.name = error.name || 'WebrpcBadMethod'
|
|
1671
|
+
this.code = typeof error.code === 'number' ? error.code : -3
|
|
1672
|
+
this.message = error.message || `bad method`
|
|
1673
|
+
this.status = typeof error.status === 'number' ? error.status : 405
|
|
1674
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1675
|
+
Object.setPrototypeOf(this, WebrpcBadMethodError.prototype)
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
export class WebrpcBadRequestError extends WebrpcError {
|
|
1680
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1681
|
+
super(error)
|
|
1682
|
+
this.name = error.name || 'WebrpcBadRequest'
|
|
1683
|
+
this.code = typeof error.code === 'number' ? error.code : -4
|
|
1684
|
+
this.message = error.message || `bad request`
|
|
1685
|
+
this.status = typeof error.status === 'number' ? error.status : 400
|
|
1686
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1687
|
+
Object.setPrototypeOf(this, WebrpcBadRequestError.prototype)
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
export class WebrpcBadResponseError extends WebrpcError {
|
|
1692
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1693
|
+
super(error)
|
|
1694
|
+
this.name = error.name || 'WebrpcBadResponse'
|
|
1695
|
+
this.code = typeof error.code === 'number' ? error.code : -5
|
|
1696
|
+
this.message = error.message || `bad response`
|
|
1697
|
+
this.status = typeof error.status === 'number' ? error.status : 500
|
|
1698
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1699
|
+
Object.setPrototypeOf(this, WebrpcBadResponseError.prototype)
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
export class WebrpcServerPanicError extends WebrpcError {
|
|
1704
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1705
|
+
super(error)
|
|
1706
|
+
this.name = error.name || 'WebrpcServerPanic'
|
|
1707
|
+
this.code = typeof error.code === 'number' ? error.code : -6
|
|
1708
|
+
this.message = error.message || `server panic`
|
|
1709
|
+
this.status = typeof error.status === 'number' ? error.status : 500
|
|
1710
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1711
|
+
Object.setPrototypeOf(this, WebrpcServerPanicError.prototype)
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
export class WebrpcInternalErrorError extends WebrpcError {
|
|
1716
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1717
|
+
super(error)
|
|
1718
|
+
this.name = error.name || 'WebrpcInternalError'
|
|
1719
|
+
this.code = typeof error.code === 'number' ? error.code : -7
|
|
1720
|
+
this.message = error.message || `internal error`
|
|
1721
|
+
this.status = typeof error.status === 'number' ? error.status : 500
|
|
1722
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1723
|
+
Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype)
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
export class WebrpcClientAbortedError extends WebrpcError {
|
|
1728
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1729
|
+
super(error)
|
|
1730
|
+
this.name = error.name || 'WebrpcClientAborted'
|
|
1731
|
+
this.code = typeof error.code === 'number' ? error.code : -8
|
|
1732
|
+
this.message = error.message || `request aborted by client`
|
|
1733
|
+
this.status = typeof error.status === 'number' ? error.status : 400
|
|
1734
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1735
|
+
Object.setPrototypeOf(this, WebrpcClientAbortedError.prototype)
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
export class WebrpcStreamLostError extends WebrpcError {
|
|
1740
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1741
|
+
super(error)
|
|
1742
|
+
this.name = error.name || 'WebrpcStreamLost'
|
|
1743
|
+
this.code = typeof error.code === 'number' ? error.code : -9
|
|
1744
|
+
this.message = error.message || `stream lost`
|
|
1745
|
+
this.status = typeof error.status === 'number' ? error.status : 400
|
|
1746
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1747
|
+
Object.setPrototypeOf(this, WebrpcStreamLostError.prototype)
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
export class WebrpcStreamFinishedError extends WebrpcError {
|
|
1752
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1753
|
+
super(error)
|
|
1754
|
+
this.name = error.name || 'WebrpcStreamFinished'
|
|
1755
|
+
this.code = typeof error.code === 'number' ? error.code : -10
|
|
1756
|
+
this.message = error.message || `stream finished`
|
|
1757
|
+
this.status = typeof error.status === 'number' ? error.status : 200
|
|
1758
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1759
|
+
Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype)
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
//
|
|
1764
|
+
// Schema errors
|
|
1765
|
+
//
|
|
1766
|
+
|
|
1767
|
+
export class UnauthorizedError extends WebrpcError {
|
|
1768
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1769
|
+
super(error)
|
|
1770
|
+
this.name = error.name || 'Unauthorized'
|
|
1771
|
+
this.code = typeof error.code === 'number' ? error.code : 1000
|
|
1772
|
+
this.message = error.message || `Unauthorized access`
|
|
1773
|
+
this.status = typeof error.status === 'number' ? error.status : 401
|
|
1774
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1775
|
+
Object.setPrototypeOf(this, UnauthorizedError.prototype)
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
export class PermissionDeniedError extends WebrpcError {
|
|
1780
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1781
|
+
super(error)
|
|
1782
|
+
this.name = error.name || 'PermissionDenied'
|
|
1783
|
+
this.code = typeof error.code === 'number' ? error.code : 1001
|
|
1784
|
+
this.message = error.message || `Permission denied`
|
|
1785
|
+
this.status = typeof error.status === 'number' ? error.status : 403
|
|
1786
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1787
|
+
Object.setPrototypeOf(this, PermissionDeniedError.prototype)
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
export class SessionExpiredError extends WebrpcError {
|
|
1792
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1793
|
+
super(error)
|
|
1794
|
+
this.name = error.name || 'SessionExpired'
|
|
1795
|
+
this.code = typeof error.code === 'number' ? error.code : 1002
|
|
1796
|
+
this.message = error.message || `Session expired`
|
|
1797
|
+
this.status = typeof error.status === 'number' ? error.status : 403
|
|
1798
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1799
|
+
Object.setPrototypeOf(this, SessionExpiredError.prototype)
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
export class MethodNotFoundError extends WebrpcError {
|
|
1804
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1805
|
+
super(error)
|
|
1806
|
+
this.name = error.name || 'MethodNotFound'
|
|
1807
|
+
this.code = typeof error.code === 'number' ? error.code : 1003
|
|
1808
|
+
this.message = error.message || `Method not found`
|
|
1809
|
+
this.status = typeof error.status === 'number' ? error.status : 404
|
|
1810
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1811
|
+
Object.setPrototypeOf(this, MethodNotFoundError.prototype)
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
export class RequestConflictError extends WebrpcError {
|
|
1816
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1817
|
+
super(error)
|
|
1818
|
+
this.name = error.name || 'RequestConflict'
|
|
1819
|
+
this.code = typeof error.code === 'number' ? error.code : 1004
|
|
1820
|
+
this.message = error.message || `Conflict with target resource`
|
|
1821
|
+
this.status = typeof error.status === 'number' ? error.status : 409
|
|
1822
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1823
|
+
Object.setPrototypeOf(this, RequestConflictError.prototype)
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
export class AbortedError extends WebrpcError {
|
|
1828
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1829
|
+
super(error)
|
|
1830
|
+
this.name = error.name || 'Aborted'
|
|
1831
|
+
this.code = typeof error.code === 'number' ? error.code : 1005
|
|
1832
|
+
this.message = error.message || `Request aborted`
|
|
1833
|
+
this.status = typeof error.status === 'number' ? error.status : 400
|
|
1834
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1835
|
+
Object.setPrototypeOf(this, AbortedError.prototype)
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
export class GeoblockedError extends WebrpcError {
|
|
1840
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1841
|
+
super(error)
|
|
1842
|
+
this.name = error.name || 'Geoblocked'
|
|
1843
|
+
this.code = typeof error.code === 'number' ? error.code : 1006
|
|
1844
|
+
this.message = error.message || `Geoblocked region`
|
|
1845
|
+
this.status = typeof error.status === 'number' ? error.status : 451
|
|
1846
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1847
|
+
Object.setPrototypeOf(this, GeoblockedError.prototype)
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
export class RateLimitedError extends WebrpcError {
|
|
1852
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1853
|
+
super(error)
|
|
1854
|
+
this.name = error.name || 'RateLimited'
|
|
1855
|
+
this.code = typeof error.code === 'number' ? error.code : 1007
|
|
1856
|
+
this.message = error.message || `Rate-limited. Please slow down.`
|
|
1857
|
+
this.status = typeof error.status === 'number' ? error.status : 429
|
|
1858
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1859
|
+
Object.setPrototypeOf(this, RateLimitedError.prototype)
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
export class ProjectNotFoundError extends WebrpcError {
|
|
1864
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1865
|
+
super(error)
|
|
1866
|
+
this.name = error.name || 'ProjectNotFound'
|
|
1867
|
+
this.code = typeof error.code === 'number' ? error.code : 1008
|
|
1868
|
+
this.message = error.message || `Project not found`
|
|
1869
|
+
this.status = typeof error.status === 'number' ? error.status : 401
|
|
1870
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1871
|
+
Object.setPrototypeOf(this, ProjectNotFoundError.prototype)
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
export class AccessKeyNotFoundError extends WebrpcError {
|
|
1876
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1877
|
+
super(error)
|
|
1878
|
+
this.name = error.name || 'AccessKeyNotFound'
|
|
1879
|
+
this.code = typeof error.code === 'number' ? error.code : 1101
|
|
1880
|
+
this.message = error.message || `Access key not found`
|
|
1881
|
+
this.status = typeof error.status === 'number' ? error.status : 401
|
|
1882
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1883
|
+
Object.setPrototypeOf(this, AccessKeyNotFoundError.prototype)
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
export class AccessKeyMismatchError extends WebrpcError {
|
|
1888
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1889
|
+
super(error)
|
|
1890
|
+
this.name = error.name || 'AccessKeyMismatch'
|
|
1891
|
+
this.code = typeof error.code === 'number' ? error.code : 1102
|
|
1892
|
+
this.message = error.message || `Access key mismatch`
|
|
1893
|
+
this.status = typeof error.status === 'number' ? error.status : 409
|
|
1894
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1895
|
+
Object.setPrototypeOf(this, AccessKeyMismatchError.prototype)
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
export class InvalidOriginError extends WebrpcError {
|
|
1900
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1901
|
+
super(error)
|
|
1902
|
+
this.name = error.name || 'InvalidOrigin'
|
|
1903
|
+
this.code = typeof error.code === 'number' ? error.code : 1103
|
|
1904
|
+
this.message = error.message || `Invalid origin for Access Key`
|
|
1905
|
+
this.status = typeof error.status === 'number' ? error.status : 403
|
|
1906
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1907
|
+
Object.setPrototypeOf(this, InvalidOriginError.prototype)
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
export class InvalidServiceError extends WebrpcError {
|
|
1912
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1913
|
+
super(error)
|
|
1914
|
+
this.name = error.name || 'InvalidService'
|
|
1915
|
+
this.code = typeof error.code === 'number' ? error.code : 1104
|
|
1916
|
+
this.message = error.message || `Service not enabled for Access key`
|
|
1917
|
+
this.status = typeof error.status === 'number' ? error.status : 403
|
|
1918
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1919
|
+
Object.setPrototypeOf(this, InvalidServiceError.prototype)
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
export class UnauthorizedUserError extends WebrpcError {
|
|
1924
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1925
|
+
super(error)
|
|
1926
|
+
this.name = error.name || 'UnauthorizedUser'
|
|
1927
|
+
this.code = typeof error.code === 'number' ? error.code : 1105
|
|
1928
|
+
this.message = error.message || `Unauthorized user`
|
|
1929
|
+
this.status = typeof error.status === 'number' ? error.status : 403
|
|
1930
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1931
|
+
Object.setPrototypeOf(this, UnauthorizedUserError.prototype)
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
export class QuotaExceededError extends WebrpcError {
|
|
1936
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1937
|
+
super(error)
|
|
1938
|
+
this.name = error.name || 'QuotaExceeded'
|
|
1939
|
+
this.code = typeof error.code === 'number' ? error.code : 1200
|
|
1940
|
+
this.message = error.message || `Quota request exceeded`
|
|
1941
|
+
this.status = typeof error.status === 'number' ? error.status : 429
|
|
1942
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1943
|
+
Object.setPrototypeOf(this, QuotaExceededError.prototype)
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
export class QuotaRateLimitError extends WebrpcError {
|
|
1948
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1949
|
+
super(error)
|
|
1950
|
+
this.name = error.name || 'QuotaRateLimit'
|
|
1951
|
+
this.code = typeof error.code === 'number' ? error.code : 1201
|
|
1952
|
+
this.message = error.message || `Quota rate limit exceeded`
|
|
1953
|
+
this.status = typeof error.status === 'number' ? error.status : 429
|
|
1954
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1955
|
+
Object.setPrototypeOf(this, QuotaRateLimitError.prototype)
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
export class NoDefaultKeyError extends WebrpcError {
|
|
1960
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1961
|
+
super(error)
|
|
1962
|
+
this.name = error.name || 'NoDefaultKey'
|
|
1963
|
+
this.code = typeof error.code === 'number' ? error.code : 1300
|
|
1964
|
+
this.message = error.message || `No default access key found`
|
|
1965
|
+
this.status = typeof error.status === 'number' ? error.status : 403
|
|
1966
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1967
|
+
Object.setPrototypeOf(this, NoDefaultKeyError.prototype)
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
export class MaxAccessKeysError extends WebrpcError {
|
|
1972
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1973
|
+
super(error)
|
|
1974
|
+
this.name = error.name || 'MaxAccessKeys'
|
|
1975
|
+
this.code = typeof error.code === 'number' ? error.code : 1301
|
|
1976
|
+
this.message = error.message || `Access keys limit reached`
|
|
1977
|
+
this.status = typeof error.status === 'number' ? error.status : 403
|
|
1978
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1979
|
+
Object.setPrototypeOf(this, MaxAccessKeysError.prototype)
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
export class AtLeastOneKeyError extends WebrpcError {
|
|
1984
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1985
|
+
super(error)
|
|
1986
|
+
this.name = error.name || 'AtLeastOneKey'
|
|
1987
|
+
this.code = typeof error.code === 'number' ? error.code : 1302
|
|
1988
|
+
this.message = error.message || `You need at least one Access Key`
|
|
1989
|
+
this.status = typeof error.status === 'number' ? error.status : 403
|
|
1990
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
1991
|
+
Object.setPrototypeOf(this, AtLeastOneKeyError.prototype)
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
export class TimeoutError extends WebrpcError {
|
|
1996
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
1997
|
+
super(error)
|
|
1998
|
+
this.name = error.name || 'Timeout'
|
|
1999
|
+
this.code = typeof error.code === 'number' ? error.code : 1900
|
|
2000
|
+
this.message = error.message || `Request timed out`
|
|
2001
|
+
this.status = typeof error.status === 'number' ? error.status : 408
|
|
2002
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
2003
|
+
Object.setPrototypeOf(this, TimeoutError.prototype)
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
export class InvalidArgumentError extends WebrpcError {
|
|
2008
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
2009
|
+
super(error)
|
|
2010
|
+
this.name = error.name || 'InvalidArgument'
|
|
2011
|
+
this.code = typeof error.code === 'number' ? error.code : 2001
|
|
2012
|
+
this.message = error.message || `Invalid argument`
|
|
2013
|
+
this.status = typeof error.status === 'number' ? error.status : 400
|
|
2014
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
2015
|
+
Object.setPrototypeOf(this, InvalidArgumentError.prototype)
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
export class UnavailableError extends WebrpcError {
|
|
2020
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
2021
|
+
super(error)
|
|
2022
|
+
this.name = error.name || 'Unavailable'
|
|
2023
|
+
this.code = typeof error.code === 'number' ? error.code : 2002
|
|
2024
|
+
this.message = error.message || `Unavailable resource`
|
|
2025
|
+
this.status = typeof error.status === 'number' ? error.status : 400
|
|
2026
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
2027
|
+
Object.setPrototypeOf(this, UnavailableError.prototype)
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
export class QueryFailedError extends WebrpcError {
|
|
2032
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
2033
|
+
super(error)
|
|
2034
|
+
this.name = error.name || 'QueryFailed'
|
|
2035
|
+
this.code = typeof error.code === 'number' ? error.code : 2003
|
|
2036
|
+
this.message = error.message || `Query failed`
|
|
2037
|
+
this.status = typeof error.status === 'number' ? error.status : 400
|
|
2038
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
2039
|
+
Object.setPrototypeOf(this, QueryFailedError.prototype)
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
export class NotFoundError extends WebrpcError {
|
|
2044
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
2045
|
+
super(error)
|
|
2046
|
+
this.name = error.name || 'NotFound'
|
|
2047
|
+
this.code = typeof error.code === 'number' ? error.code : 3000
|
|
2048
|
+
this.message = error.message || `Resource not found`
|
|
2049
|
+
this.status = typeof error.status === 'number' ? error.status : 400
|
|
2050
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
2051
|
+
Object.setPrototypeOf(this, NotFoundError.prototype)
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
export class InsufficientFeeError extends WebrpcError {
|
|
2056
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
2057
|
+
super(error)
|
|
2058
|
+
this.name = error.name || 'InsufficientFee'
|
|
2059
|
+
this.code = typeof error.code === 'number' ? error.code : 3004
|
|
2060
|
+
this.message = error.message || `Insufficient fee`
|
|
2061
|
+
this.status = typeof error.status === 'number' ? error.status : 402
|
|
2062
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
2063
|
+
Object.setPrototypeOf(this, InsufficientFeeError.prototype)
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
export class NotEnoughBalanceError extends WebrpcError {
|
|
2068
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
2069
|
+
super(error)
|
|
2070
|
+
this.name = error.name || 'NotEnoughBalance'
|
|
2071
|
+
this.code = typeof error.code === 'number' ? error.code : 3005
|
|
2072
|
+
this.message = error.message || `Not enough balance`
|
|
2073
|
+
this.status = typeof error.status === 'number' ? error.status : 402
|
|
2074
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
2075
|
+
Object.setPrototypeOf(this, NotEnoughBalanceError.prototype)
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
export class SimulationFailedError extends WebrpcError {
|
|
2080
|
+
constructor(error: WebrpcErrorParams = {}) {
|
|
2081
|
+
super(error)
|
|
2082
|
+
this.name = error.name || 'SimulationFailed'
|
|
2083
|
+
this.code = typeof error.code === 'number' ? error.code : 3006
|
|
2084
|
+
this.message = error.message || `Simulation failed`
|
|
2085
|
+
this.status = typeof error.status === 'number' ? error.status : 400
|
|
2086
|
+
if (error.cause !== undefined) this.cause = error.cause
|
|
2087
|
+
Object.setPrototypeOf(this, SimulationFailedError.prototype)
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
export enum errors {
|
|
2092
|
+
WebrpcEndpoint = 'WebrpcEndpoint',
|
|
2093
|
+
WebrpcRequestFailed = 'WebrpcRequestFailed',
|
|
2094
|
+
WebrpcBadRoute = 'WebrpcBadRoute',
|
|
2095
|
+
WebrpcBadMethod = 'WebrpcBadMethod',
|
|
2096
|
+
WebrpcBadRequest = 'WebrpcBadRequest',
|
|
2097
|
+
WebrpcBadResponse = 'WebrpcBadResponse',
|
|
2098
|
+
WebrpcServerPanic = 'WebrpcServerPanic',
|
|
2099
|
+
WebrpcInternalError = 'WebrpcInternalError',
|
|
2100
|
+
WebrpcClientAborted = 'WebrpcClientAborted',
|
|
2101
|
+
WebrpcStreamLost = 'WebrpcStreamLost',
|
|
2102
|
+
WebrpcStreamFinished = 'WebrpcStreamFinished',
|
|
2103
|
+
Unauthorized = 'Unauthorized',
|
|
2104
|
+
PermissionDenied = 'PermissionDenied',
|
|
2105
|
+
SessionExpired = 'SessionExpired',
|
|
2106
|
+
MethodNotFound = 'MethodNotFound',
|
|
2107
|
+
RequestConflict = 'RequestConflict',
|
|
2108
|
+
Aborted = 'Aborted',
|
|
2109
|
+
Geoblocked = 'Geoblocked',
|
|
2110
|
+
RateLimited = 'RateLimited',
|
|
2111
|
+
ProjectNotFound = 'ProjectNotFound',
|
|
2112
|
+
AccessKeyNotFound = 'AccessKeyNotFound',
|
|
2113
|
+
AccessKeyMismatch = 'AccessKeyMismatch',
|
|
2114
|
+
InvalidOrigin = 'InvalidOrigin',
|
|
2115
|
+
InvalidService = 'InvalidService',
|
|
2116
|
+
UnauthorizedUser = 'UnauthorizedUser',
|
|
2117
|
+
QuotaExceeded = 'QuotaExceeded',
|
|
2118
|
+
QuotaRateLimit = 'QuotaRateLimit',
|
|
2119
|
+
NoDefaultKey = 'NoDefaultKey',
|
|
2120
|
+
MaxAccessKeys = 'MaxAccessKeys',
|
|
2121
|
+
AtLeastOneKey = 'AtLeastOneKey',
|
|
2122
|
+
Timeout = 'Timeout',
|
|
2123
|
+
InvalidArgument = 'InvalidArgument',
|
|
2124
|
+
Unavailable = 'Unavailable',
|
|
2125
|
+
QueryFailed = 'QueryFailed',
|
|
2126
|
+
NotFound = 'NotFound',
|
|
2127
|
+
InsufficientFee = 'InsufficientFee',
|
|
2128
|
+
NotEnoughBalance = 'NotEnoughBalance',
|
|
2129
|
+
SimulationFailed = 'SimulationFailed',
|
|
2130
|
+
}
|
|
2131
|
+
|
|
2132
|
+
export enum WebrpcErrorCodes {
|
|
2133
|
+
WebrpcEndpoint = 0,
|
|
2134
|
+
WebrpcRequestFailed = -1,
|
|
2135
|
+
WebrpcBadRoute = -2,
|
|
2136
|
+
WebrpcBadMethod = -3,
|
|
2137
|
+
WebrpcBadRequest = -4,
|
|
2138
|
+
WebrpcBadResponse = -5,
|
|
2139
|
+
WebrpcServerPanic = -6,
|
|
2140
|
+
WebrpcInternalError = -7,
|
|
2141
|
+
WebrpcClientAborted = -8,
|
|
2142
|
+
WebrpcStreamLost = -9,
|
|
2143
|
+
WebrpcStreamFinished = -10,
|
|
2144
|
+
Unauthorized = 1000,
|
|
2145
|
+
PermissionDenied = 1001,
|
|
2146
|
+
SessionExpired = 1002,
|
|
2147
|
+
MethodNotFound = 1003,
|
|
2148
|
+
RequestConflict = 1004,
|
|
2149
|
+
Aborted = 1005,
|
|
2150
|
+
Geoblocked = 1006,
|
|
2151
|
+
RateLimited = 1007,
|
|
2152
|
+
ProjectNotFound = 1008,
|
|
2153
|
+
AccessKeyNotFound = 1101,
|
|
2154
|
+
AccessKeyMismatch = 1102,
|
|
2155
|
+
InvalidOrigin = 1103,
|
|
2156
|
+
InvalidService = 1104,
|
|
2157
|
+
UnauthorizedUser = 1105,
|
|
2158
|
+
QuotaExceeded = 1200,
|
|
2159
|
+
QuotaRateLimit = 1201,
|
|
2160
|
+
NoDefaultKey = 1300,
|
|
2161
|
+
MaxAccessKeys = 1301,
|
|
2162
|
+
AtLeastOneKey = 1302,
|
|
2163
|
+
Timeout = 1900,
|
|
2164
|
+
InvalidArgument = 2001,
|
|
2165
|
+
Unavailable = 2002,
|
|
2166
|
+
QueryFailed = 2003,
|
|
2167
|
+
NotFound = 3000,
|
|
2168
|
+
InsufficientFee = 3004,
|
|
2169
|
+
NotEnoughBalance = 3005,
|
|
2170
|
+
SimulationFailed = 3006,
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
export const webrpcErrorByCode: { [code: number]: any } = {
|
|
2174
|
+
[0]: WebrpcEndpointError,
|
|
2175
|
+
[-1]: WebrpcRequestFailedError,
|
|
2176
|
+
[-2]: WebrpcBadRouteError,
|
|
2177
|
+
[-3]: WebrpcBadMethodError,
|
|
2178
|
+
[-4]: WebrpcBadRequestError,
|
|
2179
|
+
[-5]: WebrpcBadResponseError,
|
|
2180
|
+
[-6]: WebrpcServerPanicError,
|
|
2181
|
+
[-7]: WebrpcInternalErrorError,
|
|
2182
|
+
[-8]: WebrpcClientAbortedError,
|
|
2183
|
+
[-9]: WebrpcStreamLostError,
|
|
2184
|
+
[-10]: WebrpcStreamFinishedError,
|
|
2185
|
+
[1000]: UnauthorizedError,
|
|
2186
|
+
[1001]: PermissionDeniedError,
|
|
2187
|
+
[1002]: SessionExpiredError,
|
|
2188
|
+
[1003]: MethodNotFoundError,
|
|
2189
|
+
[1004]: RequestConflictError,
|
|
2190
|
+
[1005]: AbortedError,
|
|
2191
|
+
[1006]: GeoblockedError,
|
|
2192
|
+
[1007]: RateLimitedError,
|
|
2193
|
+
[1008]: ProjectNotFoundError,
|
|
2194
|
+
[1101]: AccessKeyNotFoundError,
|
|
2195
|
+
[1102]: AccessKeyMismatchError,
|
|
2196
|
+
[1103]: InvalidOriginError,
|
|
2197
|
+
[1104]: InvalidServiceError,
|
|
2198
|
+
[1105]: UnauthorizedUserError,
|
|
2199
|
+
[1200]: QuotaExceededError,
|
|
2200
|
+
[1201]: QuotaRateLimitError,
|
|
2201
|
+
[1300]: NoDefaultKeyError,
|
|
2202
|
+
[1301]: MaxAccessKeysError,
|
|
2203
|
+
[1302]: AtLeastOneKeyError,
|
|
2204
|
+
[1900]: TimeoutError,
|
|
2205
|
+
[2001]: InvalidArgumentError,
|
|
2206
|
+
[2002]: UnavailableError,
|
|
2207
|
+
[2003]: QueryFailedError,
|
|
2208
|
+
[3000]: NotFoundError,
|
|
2209
|
+
[3004]: InsufficientFeeError,
|
|
2210
|
+
[3005]: NotEnoughBalanceError,
|
|
2211
|
+
[3006]: SimulationFailedError,
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
//
|
|
2215
|
+
// Webrpc
|
|
2216
|
+
//
|
|
2217
|
+
|
|
2218
|
+
export const WebrpcHeader = 'Webrpc'
|
|
2219
|
+
|
|
2220
|
+
export const WebrpcHeaderValue = 'webrpc@v0.30.2;gen-typescript@v0.22.2;sequence-relayer@v0.4.1'
|
|
2221
|
+
|
|
2222
|
+
type WebrpcGenVersions = {
|
|
2223
|
+
WebrpcGenVersion: string
|
|
2224
|
+
codeGenName: string
|
|
2225
|
+
codeGenVersion: string
|
|
2226
|
+
schemaName: string
|
|
2227
|
+
schemaVersion: string
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
export function VersionFromHeader(headers: Headers): WebrpcGenVersions {
|
|
2231
|
+
const headerValue = headers.get(WebrpcHeader)
|
|
2232
|
+
if (!headerValue) {
|
|
2233
|
+
return {
|
|
2234
|
+
WebrpcGenVersion: '',
|
|
2235
|
+
codeGenName: '',
|
|
2236
|
+
codeGenVersion: '',
|
|
2237
|
+
schemaName: '',
|
|
2238
|
+
schemaVersion: '',
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
return parseWebrpcGenVersions(headerValue)
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
|
|
2246
|
+
const versions = header.split(';')
|
|
2247
|
+
if (versions.length < 3) {
|
|
2248
|
+
return {
|
|
2249
|
+
WebrpcGenVersion: '',
|
|
2250
|
+
codeGenName: '',
|
|
2251
|
+
codeGenVersion: '',
|
|
2252
|
+
schemaName: '',
|
|
2253
|
+
schemaVersion: '',
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2257
|
+
const [_, WebrpcGenVersion] = versions[0]!.split('@')
|
|
2258
|
+
const [codeGenName, codeGenVersion] = versions[1]!.split('@')
|
|
2259
|
+
const [schemaName, schemaVersion] = versions[2]!.split('@')
|
|
2260
|
+
|
|
2261
|
+
return {
|
|
2262
|
+
WebrpcGenVersion: WebrpcGenVersion ?? '',
|
|
2263
|
+
codeGenName: codeGenName ?? '',
|
|
2264
|
+
codeGenVersion: codeGenVersion ?? '',
|
|
2265
|
+
schemaName: schemaName ?? '',
|
|
2266
|
+
schemaVersion: schemaVersion ?? '',
|
|
2267
|
+
}
|
|
2268
|
+
}
|