@0xsequence/relayer 2.3.39 → 3.0.0-beta.10
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 +3926 -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 +3 -2
- 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/{rpc-relayer → relayer/rpc-relayer}/relayer.gen.ts +483 -258
- 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 -1865
- package/dist/0xsequence-relayer.cjs.js +0 -7
- package/dist/0xsequence-relayer.cjs.prod.js +0 -1865
- package/dist/0xsequence-relayer.esm.js +0 -1852
- 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
|
@@ -1,1865 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var utils = require('@0xsequence/utils');
|
|
6
|
-
var ethers = require('ethers');
|
|
7
|
-
var abi = require('@0xsequence/abi');
|
|
8
|
-
var core = require('@0xsequence/core');
|
|
9
|
-
|
|
10
|
-
function _extends() {
|
|
11
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
12
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
13
|
-
var t = arguments[e];
|
|
14
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
15
|
-
}
|
|
16
|
-
return n;
|
|
17
|
-
}, _extends.apply(null, arguments);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const DEFAULT_GAS_LIMIT = 800000n;
|
|
21
|
-
const ProviderRelayerDefaults = {
|
|
22
|
-
waitPollRate: 1000,
|
|
23
|
-
deltaBlocksLog: 12,
|
|
24
|
-
fromBlockLog: -1024
|
|
25
|
-
};
|
|
26
|
-
function isProviderRelayerOptions(obj) {
|
|
27
|
-
return typeof obj === 'object' && isAbstractProvider$1(obj.provider);
|
|
28
|
-
}
|
|
29
|
-
class ProviderRelayer {
|
|
30
|
-
constructor(options) {
|
|
31
|
-
this.provider = void 0;
|
|
32
|
-
this.waitPollRate = void 0;
|
|
33
|
-
this.deltaBlocksLog = void 0;
|
|
34
|
-
this.fromBlockLog = void 0;
|
|
35
|
-
const opts = _extends({}, ProviderRelayerDefaults, options);
|
|
36
|
-
this.provider = opts.provider;
|
|
37
|
-
this.waitPollRate = opts.waitPollRate;
|
|
38
|
-
this.deltaBlocksLog = opts.deltaBlocksLog;
|
|
39
|
-
this.fromBlockLog = opts.fromBlockLog;
|
|
40
|
-
}
|
|
41
|
-
async simulate(wallet, ...transactions) {
|
|
42
|
-
var _this = this;
|
|
43
|
-
return (await Promise.all(transactions.map(async function (tx) {
|
|
44
|
-
// Respect gasLimit request of the transaction (as long as its not 0)
|
|
45
|
-
if (tx.gasLimit && BigInt(tx.gasLimit || 0) !== 0n) {
|
|
46
|
-
return tx.gasLimit;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Fee can't be estimated locally for delegateCalls
|
|
50
|
-
if (tx.delegateCall) {
|
|
51
|
-
return DEFAULT_GAS_LIMIT;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Fee can't be estimated for self-called if wallet hasn't been deployed
|
|
55
|
-
if (tx.to === wallet && (await _this.provider.getCode(wallet).then(code => ethers.ethers.getBytes(code).length === 0))) {
|
|
56
|
-
return DEFAULT_GAS_LIMIT;
|
|
57
|
-
}
|
|
58
|
-
if (!_this.provider) {
|
|
59
|
-
throw new Error('signer.provider is not set, but is required');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// TODO: If the wallet address has been deployed, gas limits can be
|
|
63
|
-
// estimated with more accurately by using self-calls with the batch transactions one by one
|
|
64
|
-
return _this.provider.estimateGas({
|
|
65
|
-
from: wallet,
|
|
66
|
-
to: tx.to,
|
|
67
|
-
data: tx.data,
|
|
68
|
-
value: tx.value
|
|
69
|
-
});
|
|
70
|
-
}))).map(gasLimit => ({
|
|
71
|
-
executed: true,
|
|
72
|
-
succeeded: true,
|
|
73
|
-
gasUsed: Number(gasLimit),
|
|
74
|
-
gasLimit: Number(gasLimit)
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
77
|
-
async getNonce(address, space, blockTag) {
|
|
78
|
-
if (!this.provider) {
|
|
79
|
-
throw new Error('provider is not set');
|
|
80
|
-
}
|
|
81
|
-
if ((await this.provider.getCode(address)) === '0x') {
|
|
82
|
-
return 0;
|
|
83
|
-
}
|
|
84
|
-
if (space === undefined) {
|
|
85
|
-
space = 0;
|
|
86
|
-
}
|
|
87
|
-
const module = new ethers.ethers.Contract(address, abi.walletContracts.mainModule.abi, this.provider);
|
|
88
|
-
const nonce = await module.readNonce(space, {
|
|
89
|
-
blockTag: blockTag
|
|
90
|
-
});
|
|
91
|
-
return core.commons.transaction.encodeNonce(space, nonce);
|
|
92
|
-
}
|
|
93
|
-
async wait(metaTxnId, timeoutDuration, delay = this.waitPollRate, maxFails = 5) {
|
|
94
|
-
var _this2 = this;
|
|
95
|
-
if (typeof metaTxnId !== 'string') {
|
|
96
|
-
metaTxnId = core.commons.transaction.intendedTransactionID(metaTxnId);
|
|
97
|
-
}
|
|
98
|
-
let timedOut = false;
|
|
99
|
-
const retry = async function retry(f, errorMessage) {
|
|
100
|
-
let fails = 0;
|
|
101
|
-
while (!timedOut) {
|
|
102
|
-
try {
|
|
103
|
-
return await f();
|
|
104
|
-
} catch (error) {
|
|
105
|
-
fails++;
|
|
106
|
-
if (maxFails !== undefined && fails >= maxFails) {
|
|
107
|
-
utils.logger.error(`giving up after ${fails} failed attempts${errorMessage ? `: ${errorMessage}` : ''}`, error);
|
|
108
|
-
throw error;
|
|
109
|
-
} else {
|
|
110
|
-
utils.logger.warn(`attempt #${fails} failed${errorMessage ? `: ${errorMessage}` : ''}`, error);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (delay > 0) {
|
|
114
|
-
await new Promise(resolve => setTimeout(resolve, delay));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
throw new Error(`timed out after ${fails} failed attempts${errorMessage ? `: ${errorMessage}` : ''}`);
|
|
118
|
-
};
|
|
119
|
-
const waitReceipt = async function waitReceipt() {
|
|
120
|
-
// Transactions can only get executed on nonce change
|
|
121
|
-
// get all nonce changes and look for metaTxnIds in between logs
|
|
122
|
-
let lastBlock = _this2.fromBlockLog;
|
|
123
|
-
if (lastBlock < 0) {
|
|
124
|
-
const block = await retry(() => _this2.provider.getBlockNumber(), 'unable to get latest block number');
|
|
125
|
-
lastBlock = block + lastBlock;
|
|
126
|
-
}
|
|
127
|
-
if (typeof metaTxnId !== 'string') {
|
|
128
|
-
throw new Error('impossible');
|
|
129
|
-
}
|
|
130
|
-
const normalMetaTxnId = metaTxnId.replace('0x', '');
|
|
131
|
-
while (!timedOut) {
|
|
132
|
-
const block = await retry(() => _this2.provider.getBlockNumber(), 'unable to get latest block number');
|
|
133
|
-
const logs = await retry(() => _this2.provider.getLogs({
|
|
134
|
-
fromBlock: Math.max(0, lastBlock - _this2.deltaBlocksLog),
|
|
135
|
-
toBlock: block,
|
|
136
|
-
// Nonce change event topic
|
|
137
|
-
topics: ['0x1f180c27086c7a39ea2a7b25239d1ab92348f07ca7bb59d1438fcf527568f881']
|
|
138
|
-
}), `unable to get NonceChange logs for blocks ${Math.max(0, lastBlock - _this2.deltaBlocksLog)} to ${block}`);
|
|
139
|
-
lastBlock = block;
|
|
140
|
-
|
|
141
|
-
// Get receipts of all transactions
|
|
142
|
-
const txs = await Promise.all(logs.map(l => retry(() => _this2.provider.getTransactionReceipt(l.transactionHash), `unable to get receipt for transaction ${l.transactionHash}`)));
|
|
143
|
-
|
|
144
|
-
// Find a transaction with a TxExecuted log
|
|
145
|
-
const found = txs.find(tx => tx == null ? void 0 : tx.logs.find(l => l.topics.length === 0 && l.data.replace('0x', '') === normalMetaTxnId || l.topics.length === 1 &&
|
|
146
|
-
// TxFailed event topic
|
|
147
|
-
l.topics[0] === '0x3dbd1590ea96dd3253a91f24e64e3a502e1225d602a5731357bc12643070ccd7' && l.data.length >= 64 && l.data.replace('0x', '').startsWith(normalMetaTxnId)));
|
|
148
|
-
|
|
149
|
-
// If found return that
|
|
150
|
-
if (found) {
|
|
151
|
-
const response = await retry(() => _this2.provider.getTransaction(found.hash), `unable to get transaction ${found.hash}`);
|
|
152
|
-
if (!response) {
|
|
153
|
-
throw new Error(`Transaction response not found for ${metaTxnId}`);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// NOTE: we have to do this, because ethers-v6 uses private fields
|
|
157
|
-
// and we can't just extend the class and override the method, so
|
|
158
|
-
// we just modify the response object directly by adding the receipt to it.
|
|
159
|
-
const out = response;
|
|
160
|
-
out.receipt = found;
|
|
161
|
-
return out;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// Otherwise wait and try again
|
|
165
|
-
if (!timedOut) {
|
|
166
|
-
await new Promise(r => setTimeout(r, delay));
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
throw new Error(`Timeout waiting for transaction receipt ${metaTxnId}`);
|
|
170
|
-
};
|
|
171
|
-
if (timeoutDuration !== undefined) {
|
|
172
|
-
return Promise.race([waitReceipt(), new Promise((_, reject) => setTimeout(() => {
|
|
173
|
-
timedOut = true;
|
|
174
|
-
reject(`Timeout waiting for transaction receipt ${metaTxnId}`);
|
|
175
|
-
}, timeoutDuration))]);
|
|
176
|
-
} else {
|
|
177
|
-
return waitReceipt();
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
function isAbstractProvider$1(provider) {
|
|
182
|
-
return provider && typeof provider === 'object' && typeof provider.getNetwork === 'function' && typeof provider.getBlockNumber === 'function';
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function isLocalRelayerOptions(obj) {
|
|
186
|
-
return typeof obj === 'object' && isAbstractSigner(obj.signer);
|
|
187
|
-
}
|
|
188
|
-
class LocalRelayer extends ProviderRelayer {
|
|
189
|
-
constructor(options) {
|
|
190
|
-
super(isAbstractSigner(options) ? {
|
|
191
|
-
provider: options.provider
|
|
192
|
-
} : _extends({}, options, {
|
|
193
|
-
provider: options.signer.provider
|
|
194
|
-
}));
|
|
195
|
-
this.signer = void 0;
|
|
196
|
-
this.txnOptions = void 0;
|
|
197
|
-
this.signer = isAbstractSigner(options) ? options : options.signer;
|
|
198
|
-
if (!this.signer.provider) throw new Error('Signer must have a provider');
|
|
199
|
-
}
|
|
200
|
-
async getFeeOptions(_address, ..._transactions) {
|
|
201
|
-
return {
|
|
202
|
-
options: []
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
async getFeeOptionsRaw(_entrypoint, _data, _options) {
|
|
206
|
-
return {
|
|
207
|
-
options: []
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
async gasRefundOptions(address, ...transactions) {
|
|
211
|
-
const {
|
|
212
|
-
options
|
|
213
|
-
} = await this.getFeeOptions(address, ...transactions);
|
|
214
|
-
return options;
|
|
215
|
-
}
|
|
216
|
-
setTransactionOptions(transactionRequest) {
|
|
217
|
-
this.txnOptions = transactionRequest;
|
|
218
|
-
}
|
|
219
|
-
async relay(signedTxs, quote, waitForReceipt = true) {
|
|
220
|
-
if (quote !== undefined) {
|
|
221
|
-
utils.logger.warn(`LocalRelayer doesn't accept fee quotes`);
|
|
222
|
-
}
|
|
223
|
-
const data = core.commons.transaction.encodeBundleExecData(signedTxs);
|
|
224
|
-
|
|
225
|
-
// TODO: think about computing gas limit individually, summing together and passing across
|
|
226
|
-
// NOTE: we expect that all txns have set their gasLimit ahead of time through proper estimation
|
|
227
|
-
// const gasLimit = signedTxs.transactions.reduce((sum, tx) => sum + tx.gasLimit, 0n)
|
|
228
|
-
// txRequest.gasLimit = gasLimit
|
|
229
|
-
|
|
230
|
-
const responsePromise = this.signer.sendTransaction(_extends({
|
|
231
|
-
to: signedTxs.entrypoint,
|
|
232
|
-
data
|
|
233
|
-
}, this.txnOptions, {
|
|
234
|
-
gasLimit: 9000000
|
|
235
|
-
}));
|
|
236
|
-
if (waitForReceipt) {
|
|
237
|
-
const response = await responsePromise;
|
|
238
|
-
response.receipt = await response.wait();
|
|
239
|
-
return response;
|
|
240
|
-
} else {
|
|
241
|
-
return responsePromise;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
async getMetaTransactions(projectId, page) {
|
|
245
|
-
return {
|
|
246
|
-
page: {
|
|
247
|
-
page: 0,
|
|
248
|
-
pageSize: 100
|
|
249
|
-
},
|
|
250
|
-
transactions: []
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
async getTransactionCost(projectId, from, to) {
|
|
254
|
-
return {
|
|
255
|
-
cost: 0
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
async listGasSponsors(args) {
|
|
259
|
-
return {
|
|
260
|
-
page: {
|
|
261
|
-
page: 0,
|
|
262
|
-
pageSize: 100
|
|
263
|
-
},
|
|
264
|
-
gasSponsors: []
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
async addGasSponsor(args) {
|
|
268
|
-
return {
|
|
269
|
-
status: true,
|
|
270
|
-
gasSponsor: {}
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
async updateGasSponsor(args) {
|
|
274
|
-
return {
|
|
275
|
-
status: true,
|
|
276
|
-
gasSponsor: {}
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
async removeGasSponsor(args) {
|
|
280
|
-
return {
|
|
281
|
-
status: true
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
function isAbstractSigner(signer) {
|
|
286
|
-
return signer && typeof signer === 'object' && typeof signer.provider === 'object' && typeof signer.getAddress === 'function' && typeof signer.connect === 'function';
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
/* eslint-disable */
|
|
290
|
-
// sequence-relayer v0.4.1 7f8a4b83b00e0b6849c76c2ff0e23931e26b3d9f
|
|
291
|
-
// --
|
|
292
|
-
// Code generated by Webrpc-gen@v0.31.2 with typescript generator. DO NOT EDIT.
|
|
293
|
-
//
|
|
294
|
-
// webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts -compat
|
|
295
|
-
|
|
296
|
-
// Webrpc description and code-gen version
|
|
297
|
-
const WebrpcVersion = 'v1';
|
|
298
|
-
|
|
299
|
-
// Schema version of your RIDL schema
|
|
300
|
-
const WebrpcSchemaVersion = 'v0.4.1';
|
|
301
|
-
|
|
302
|
-
// Schema hash generated from your RIDL schema
|
|
303
|
-
const WebrpcSchemaHash = '7f8a4b83b00e0b6849c76c2ff0e23931e26b3d9f';
|
|
304
|
-
|
|
305
|
-
//
|
|
306
|
-
// Client interface
|
|
307
|
-
//
|
|
308
|
-
|
|
309
|
-
//
|
|
310
|
-
// Schema types
|
|
311
|
-
//
|
|
312
|
-
|
|
313
|
-
let ETHTxnStatus = /*#__PURE__*/function (ETHTxnStatus) {
|
|
314
|
-
ETHTxnStatus["UNKNOWN"] = "UNKNOWN";
|
|
315
|
-
ETHTxnStatus["DROPPED"] = "DROPPED";
|
|
316
|
-
ETHTxnStatus["QUEUED"] = "QUEUED";
|
|
317
|
-
ETHTxnStatus["SENT"] = "SENT";
|
|
318
|
-
ETHTxnStatus["SUCCEEDED"] = "SUCCEEDED";
|
|
319
|
-
ETHTxnStatus["PARTIALLY_FAILED"] = "PARTIALLY_FAILED";
|
|
320
|
-
ETHTxnStatus["FAILED"] = "FAILED";
|
|
321
|
-
ETHTxnStatus["PENDING_PRECONDITION"] = "PENDING_PRECONDITION";
|
|
322
|
-
return ETHTxnStatus;
|
|
323
|
-
}({});
|
|
324
|
-
let TransferType = /*#__PURE__*/function (TransferType) {
|
|
325
|
-
TransferType["SEND"] = "SEND";
|
|
326
|
-
TransferType["RECEIVE"] = "RECEIVE";
|
|
327
|
-
TransferType["BRIDGE_DEPOSIT"] = "BRIDGE_DEPOSIT";
|
|
328
|
-
TransferType["BRIDGE_WITHDRAW"] = "BRIDGE_WITHDRAW";
|
|
329
|
-
TransferType["BURN"] = "BURN";
|
|
330
|
-
TransferType["UNKNOWN"] = "UNKNOWN";
|
|
331
|
-
return TransferType;
|
|
332
|
-
}({});
|
|
333
|
-
let SimulateStatus = /*#__PURE__*/function (SimulateStatus) {
|
|
334
|
-
SimulateStatus["SKIPPED"] = "SKIPPED";
|
|
335
|
-
SimulateStatus["SUCCEEDED"] = "SUCCEEDED";
|
|
336
|
-
SimulateStatus["FAILED"] = "FAILED";
|
|
337
|
-
SimulateStatus["ABORTED"] = "ABORTED";
|
|
338
|
-
SimulateStatus["REVERTED"] = "REVERTED";
|
|
339
|
-
SimulateStatus["NOT_ENOUGH_GAS"] = "NOT_ENOUGH_GAS";
|
|
340
|
-
return SimulateStatus;
|
|
341
|
-
}({});
|
|
342
|
-
let FeeTokenType = /*#__PURE__*/function (FeeTokenType) {
|
|
343
|
-
FeeTokenType["UNKNOWN"] = "UNKNOWN";
|
|
344
|
-
FeeTokenType["ERC20_TOKEN"] = "ERC20_TOKEN";
|
|
345
|
-
FeeTokenType["ERC1155_TOKEN"] = "ERC1155_TOKEN";
|
|
346
|
-
return FeeTokenType;
|
|
347
|
-
}({});
|
|
348
|
-
let SortOrder = /*#__PURE__*/function (SortOrder) {
|
|
349
|
-
SortOrder["DESC"] = "DESC";
|
|
350
|
-
SortOrder["ASC"] = "ASC";
|
|
351
|
-
return SortOrder;
|
|
352
|
-
}({});
|
|
353
|
-
//
|
|
354
|
-
// Client
|
|
355
|
-
//
|
|
356
|
-
|
|
357
|
-
class Relayer {
|
|
358
|
-
constructor(hostname, fetch) {
|
|
359
|
-
this.hostname = void 0;
|
|
360
|
-
this.fetch = void 0;
|
|
361
|
-
this.path = '/rpc/Relayer/';
|
|
362
|
-
this.queryKey = {
|
|
363
|
-
ping: () => ['Relayer', 'ping'],
|
|
364
|
-
version: () => ['Relayer', 'version'],
|
|
365
|
-
runtimeStatus: () => ['Relayer', 'runtimeStatus'],
|
|
366
|
-
getSequenceContext: () => ['Relayer', 'getSequenceContext'],
|
|
367
|
-
getChainID: () => ['Relayer', 'getChainID'],
|
|
368
|
-
sendMetaTxn: req => ['Relayer', 'sendMetaTxn', req],
|
|
369
|
-
getMetaTxnNonce: req => ['Relayer', 'getMetaTxnNonce', req],
|
|
370
|
-
getMetaTxnReceipt: req => ['Relayer', 'getMetaTxnReceipt', req],
|
|
371
|
-
simulate: req => ['Relayer', 'simulate', req],
|
|
372
|
-
simulateV3: req => ['Relayer', 'simulateV3', req],
|
|
373
|
-
updateMetaTxnGasLimits: req => ['Relayer', 'updateMetaTxnGasLimits', req],
|
|
374
|
-
feeTokens: () => ['Relayer', 'feeTokens'],
|
|
375
|
-
feeOptions: req => ['Relayer', 'feeOptions', req],
|
|
376
|
-
getMetaTxnNetworkFeeOptions: req => ['Relayer', 'getMetaTxnNetworkFeeOptions', req],
|
|
377
|
-
getMetaTransactions: req => ['Relayer', 'getMetaTransactions', req],
|
|
378
|
-
getTransactionCost: req => ['Relayer', 'getTransactionCost', req],
|
|
379
|
-
sentTransactions: req => ['Relayer', 'sentTransactions', req],
|
|
380
|
-
pendingTransactions: req => ['Relayer', 'pendingTransactions', req],
|
|
381
|
-
getGasTank: req => ['Relayer', 'getGasTank', req],
|
|
382
|
-
addGasTank: req => ['Relayer', 'addGasTank', req],
|
|
383
|
-
updateGasTank: req => ['Relayer', 'updateGasTank', req],
|
|
384
|
-
nextGasTankBalanceAdjustmentNonce: req => ['Relayer', 'nextGasTankBalanceAdjustmentNonce', req],
|
|
385
|
-
adjustGasTankBalance: req => ['Relayer', 'adjustGasTankBalance', req],
|
|
386
|
-
getGasTankBalanceAdjustment: req => ['Relayer', 'getGasTankBalanceAdjustment', req],
|
|
387
|
-
listGasTankBalanceAdjustments: req => ['Relayer', 'listGasTankBalanceAdjustments', req],
|
|
388
|
-
listGasSponsors: req => ['Relayer', 'listGasSponsors', req],
|
|
389
|
-
getGasSponsor: req => ['Relayer', 'getGasSponsor', req],
|
|
390
|
-
addGasSponsor: req => ['Relayer', 'addGasSponsor', req],
|
|
391
|
-
updateGasSponsor: req => ['Relayer', 'updateGasSponsor', req],
|
|
392
|
-
removeGasSponsor: req => ['Relayer', 'removeGasSponsor', req],
|
|
393
|
-
addressGasSponsors: req => ['Relayer', 'addressGasSponsors', req],
|
|
394
|
-
getProjectBalance: req => ['Relayer', 'getProjectBalance', req],
|
|
395
|
-
adjustProjectBalance: req => ['Relayer', 'adjustProjectBalance', req]
|
|
396
|
-
};
|
|
397
|
-
this.ping = (headers, signal) => {
|
|
398
|
-
return this.fetch(this.url('Ping'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
399
|
-
return buildResponse(res).then(_data => {
|
|
400
|
-
return JsonDecode(_data, 'PingReturn');
|
|
401
|
-
});
|
|
402
|
-
}, error => {
|
|
403
|
-
throw WebrpcRequestFailedError.new({
|
|
404
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
405
|
-
});
|
|
406
|
-
});
|
|
407
|
-
};
|
|
408
|
-
this.version = (headers, signal) => {
|
|
409
|
-
return this.fetch(this.url('Version'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
410
|
-
return buildResponse(res).then(_data => {
|
|
411
|
-
return JsonDecode(_data, 'VersionReturn');
|
|
412
|
-
});
|
|
413
|
-
}, error => {
|
|
414
|
-
throw WebrpcRequestFailedError.new({
|
|
415
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
416
|
-
});
|
|
417
|
-
});
|
|
418
|
-
};
|
|
419
|
-
this.runtimeStatus = (headers, signal) => {
|
|
420
|
-
return this.fetch(this.url('RuntimeStatus'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
421
|
-
return buildResponse(res).then(_data => {
|
|
422
|
-
return JsonDecode(_data, 'RuntimeStatusReturn');
|
|
423
|
-
});
|
|
424
|
-
}, error => {
|
|
425
|
-
throw WebrpcRequestFailedError.new({
|
|
426
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
427
|
-
});
|
|
428
|
-
});
|
|
429
|
-
};
|
|
430
|
-
this.getSequenceContext = (headers, signal) => {
|
|
431
|
-
return this.fetch(this.url('GetSequenceContext'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
432
|
-
return buildResponse(res).then(_data => {
|
|
433
|
-
return JsonDecode(_data, 'GetSequenceContextReturn');
|
|
434
|
-
});
|
|
435
|
-
}, error => {
|
|
436
|
-
throw WebrpcRequestFailedError.new({
|
|
437
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
438
|
-
});
|
|
439
|
-
});
|
|
440
|
-
};
|
|
441
|
-
this.getChainID = (headers, signal) => {
|
|
442
|
-
return this.fetch(this.url('GetChainID'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
443
|
-
return buildResponse(res).then(_data => {
|
|
444
|
-
return JsonDecode(_data, 'GetChainIDReturn');
|
|
445
|
-
});
|
|
446
|
-
}, error => {
|
|
447
|
-
throw WebrpcRequestFailedError.new({
|
|
448
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
449
|
-
});
|
|
450
|
-
});
|
|
451
|
-
};
|
|
452
|
-
this.sendMetaTxn = (req, headers, signal) => {
|
|
453
|
-
return this.fetch(this.url('SendMetaTxn'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
454
|
-
return buildResponse(res).then(_data => {
|
|
455
|
-
return JsonDecode(_data, 'SendMetaTxnReturn');
|
|
456
|
-
});
|
|
457
|
-
}, error => {
|
|
458
|
-
throw WebrpcRequestFailedError.new({
|
|
459
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
460
|
-
});
|
|
461
|
-
});
|
|
462
|
-
};
|
|
463
|
-
this.getMetaTxnNonce = (req, headers, signal) => {
|
|
464
|
-
return this.fetch(this.url('GetMetaTxnNonce'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
465
|
-
return buildResponse(res).then(_data => {
|
|
466
|
-
return JsonDecode(_data, 'GetMetaTxnNonceReturn');
|
|
467
|
-
});
|
|
468
|
-
}, error => {
|
|
469
|
-
throw WebrpcRequestFailedError.new({
|
|
470
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
471
|
-
});
|
|
472
|
-
});
|
|
473
|
-
};
|
|
474
|
-
this.getMetaTxnReceipt = (req, headers, signal) => {
|
|
475
|
-
return this.fetch(this.url('GetMetaTxnReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
476
|
-
return buildResponse(res).then(_data => {
|
|
477
|
-
return JsonDecode(_data, 'GetMetaTxnReceiptReturn');
|
|
478
|
-
});
|
|
479
|
-
}, error => {
|
|
480
|
-
throw WebrpcRequestFailedError.new({
|
|
481
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
482
|
-
});
|
|
483
|
-
});
|
|
484
|
-
};
|
|
485
|
-
this.simulate = (req, headers, signal) => {
|
|
486
|
-
return this.fetch(this.url('Simulate'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
487
|
-
return buildResponse(res).then(_data => {
|
|
488
|
-
return JsonDecode(_data, 'SimulateReturn');
|
|
489
|
-
});
|
|
490
|
-
}, error => {
|
|
491
|
-
throw WebrpcRequestFailedError.new({
|
|
492
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
493
|
-
});
|
|
494
|
-
});
|
|
495
|
-
};
|
|
496
|
-
this.simulateV3 = (req, headers, signal) => {
|
|
497
|
-
return this.fetch(this.url('SimulateV3'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
498
|
-
return buildResponse(res).then(_data => {
|
|
499
|
-
return JsonDecode(_data, 'SimulateV3Return');
|
|
500
|
-
});
|
|
501
|
-
}, error => {
|
|
502
|
-
throw WebrpcRequestFailedError.new({
|
|
503
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
504
|
-
});
|
|
505
|
-
});
|
|
506
|
-
};
|
|
507
|
-
this.updateMetaTxnGasLimits = (req, headers, signal) => {
|
|
508
|
-
return this.fetch(this.url('UpdateMetaTxnGasLimits'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
509
|
-
return buildResponse(res).then(_data => {
|
|
510
|
-
return JsonDecode(_data, 'UpdateMetaTxnGasLimitsReturn');
|
|
511
|
-
});
|
|
512
|
-
}, error => {
|
|
513
|
-
throw WebrpcRequestFailedError.new({
|
|
514
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
515
|
-
});
|
|
516
|
-
});
|
|
517
|
-
};
|
|
518
|
-
this.feeTokens = (headers, signal) => {
|
|
519
|
-
return this.fetch(this.url('FeeTokens'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
520
|
-
return buildResponse(res).then(_data => {
|
|
521
|
-
return JsonDecode(_data, 'FeeTokensReturn');
|
|
522
|
-
});
|
|
523
|
-
}, error => {
|
|
524
|
-
throw WebrpcRequestFailedError.new({
|
|
525
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
526
|
-
});
|
|
527
|
-
});
|
|
528
|
-
};
|
|
529
|
-
this.feeOptions = (req, headers, signal) => {
|
|
530
|
-
return this.fetch(this.url('FeeOptions'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
531
|
-
return buildResponse(res).then(_data => {
|
|
532
|
-
return JsonDecode(_data, 'FeeOptionsReturn');
|
|
533
|
-
});
|
|
534
|
-
}, error => {
|
|
535
|
-
throw WebrpcRequestFailedError.new({
|
|
536
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
537
|
-
});
|
|
538
|
-
});
|
|
539
|
-
};
|
|
540
|
-
this.getMetaTxnNetworkFeeOptions = (req, headers, signal) => {
|
|
541
|
-
return this.fetch(this.url('GetMetaTxnNetworkFeeOptions'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
542
|
-
return buildResponse(res).then(_data => {
|
|
543
|
-
return JsonDecode(_data, 'GetMetaTxnNetworkFeeOptionsReturn');
|
|
544
|
-
});
|
|
545
|
-
}, error => {
|
|
546
|
-
throw WebrpcRequestFailedError.new({
|
|
547
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
548
|
-
});
|
|
549
|
-
});
|
|
550
|
-
};
|
|
551
|
-
this.getMetaTransactions = (req, headers, signal) => {
|
|
552
|
-
return this.fetch(this.url('GetMetaTransactions'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
553
|
-
return buildResponse(res).then(_data => {
|
|
554
|
-
return JsonDecode(_data, 'GetMetaTransactionsReturn');
|
|
555
|
-
});
|
|
556
|
-
}, error => {
|
|
557
|
-
throw WebrpcRequestFailedError.new({
|
|
558
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
559
|
-
});
|
|
560
|
-
});
|
|
561
|
-
};
|
|
562
|
-
this.getTransactionCost = (req, headers, signal) => {
|
|
563
|
-
return this.fetch(this.url('GetTransactionCost'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
564
|
-
return buildResponse(res).then(_data => {
|
|
565
|
-
return JsonDecode(_data, 'GetTransactionCostReturn');
|
|
566
|
-
});
|
|
567
|
-
}, error => {
|
|
568
|
-
throw WebrpcRequestFailedError.new({
|
|
569
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
570
|
-
});
|
|
571
|
-
});
|
|
572
|
-
};
|
|
573
|
-
this.sentTransactions = (req, headers, signal) => {
|
|
574
|
-
return this.fetch(this.url('SentTransactions'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
575
|
-
return buildResponse(res).then(_data => {
|
|
576
|
-
return JsonDecode(_data, 'SentTransactionsReturn');
|
|
577
|
-
});
|
|
578
|
-
}, error => {
|
|
579
|
-
throw WebrpcRequestFailedError.new({
|
|
580
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
581
|
-
});
|
|
582
|
-
});
|
|
583
|
-
};
|
|
584
|
-
this.pendingTransactions = (req, headers, signal) => {
|
|
585
|
-
return this.fetch(this.url('PendingTransactions'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
586
|
-
return buildResponse(res).then(_data => {
|
|
587
|
-
return JsonDecode(_data, 'PendingTransactionsReturn');
|
|
588
|
-
});
|
|
589
|
-
}, error => {
|
|
590
|
-
throw WebrpcRequestFailedError.new({
|
|
591
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
592
|
-
});
|
|
593
|
-
});
|
|
594
|
-
};
|
|
595
|
-
this.getGasTank = (req, headers, signal) => {
|
|
596
|
-
return this.fetch(this.url('GetGasTank'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
597
|
-
return buildResponse(res).then(_data => {
|
|
598
|
-
return JsonDecode(_data, 'GetGasTankReturn');
|
|
599
|
-
});
|
|
600
|
-
}, error => {
|
|
601
|
-
throw WebrpcRequestFailedError.new({
|
|
602
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
603
|
-
});
|
|
604
|
-
});
|
|
605
|
-
};
|
|
606
|
-
this.addGasTank = (req, headers, signal) => {
|
|
607
|
-
return this.fetch(this.url('AddGasTank'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
608
|
-
return buildResponse(res).then(_data => {
|
|
609
|
-
return JsonDecode(_data, 'AddGasTankReturn');
|
|
610
|
-
});
|
|
611
|
-
}, error => {
|
|
612
|
-
throw WebrpcRequestFailedError.new({
|
|
613
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
614
|
-
});
|
|
615
|
-
});
|
|
616
|
-
};
|
|
617
|
-
this.updateGasTank = (req, headers, signal) => {
|
|
618
|
-
return this.fetch(this.url('UpdateGasTank'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
619
|
-
return buildResponse(res).then(_data => {
|
|
620
|
-
return JsonDecode(_data, 'UpdateGasTankReturn');
|
|
621
|
-
});
|
|
622
|
-
}, error => {
|
|
623
|
-
throw WebrpcRequestFailedError.new({
|
|
624
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
625
|
-
});
|
|
626
|
-
});
|
|
627
|
-
};
|
|
628
|
-
this.nextGasTankBalanceAdjustmentNonce = (req, headers, signal) => {
|
|
629
|
-
return this.fetch(this.url('NextGasTankBalanceAdjustmentNonce'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
630
|
-
return buildResponse(res).then(_data => {
|
|
631
|
-
return JsonDecode(_data, 'NextGasTankBalanceAdjustmentNonceReturn');
|
|
632
|
-
});
|
|
633
|
-
}, error => {
|
|
634
|
-
throw WebrpcRequestFailedError.new({
|
|
635
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
636
|
-
});
|
|
637
|
-
});
|
|
638
|
-
};
|
|
639
|
-
this.adjustGasTankBalance = (req, headers, signal) => {
|
|
640
|
-
return this.fetch(this.url('AdjustGasTankBalance'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
641
|
-
return buildResponse(res).then(_data => {
|
|
642
|
-
return JsonDecode(_data, 'AdjustGasTankBalanceReturn');
|
|
643
|
-
});
|
|
644
|
-
}, error => {
|
|
645
|
-
throw WebrpcRequestFailedError.new({
|
|
646
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
647
|
-
});
|
|
648
|
-
});
|
|
649
|
-
};
|
|
650
|
-
this.getGasTankBalanceAdjustment = (req, headers, signal) => {
|
|
651
|
-
return this.fetch(this.url('GetGasTankBalanceAdjustment'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
652
|
-
return buildResponse(res).then(_data => {
|
|
653
|
-
return JsonDecode(_data, 'GetGasTankBalanceAdjustmentReturn');
|
|
654
|
-
});
|
|
655
|
-
}, error => {
|
|
656
|
-
throw WebrpcRequestFailedError.new({
|
|
657
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
658
|
-
});
|
|
659
|
-
});
|
|
660
|
-
};
|
|
661
|
-
this.listGasTankBalanceAdjustments = (req, headers, signal) => {
|
|
662
|
-
return this.fetch(this.url('ListGasTankBalanceAdjustments'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
663
|
-
return buildResponse(res).then(_data => {
|
|
664
|
-
return JsonDecode(_data, 'ListGasTankBalanceAdjustmentsReturn');
|
|
665
|
-
});
|
|
666
|
-
}, error => {
|
|
667
|
-
throw WebrpcRequestFailedError.new({
|
|
668
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
669
|
-
});
|
|
670
|
-
});
|
|
671
|
-
};
|
|
672
|
-
this.listGasSponsors = (req, headers, signal) => {
|
|
673
|
-
return this.fetch(this.url('ListGasSponsors'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
674
|
-
return buildResponse(res).then(_data => {
|
|
675
|
-
return JsonDecode(_data, 'ListGasSponsorsReturn');
|
|
676
|
-
});
|
|
677
|
-
}, error => {
|
|
678
|
-
throw WebrpcRequestFailedError.new({
|
|
679
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
680
|
-
});
|
|
681
|
-
});
|
|
682
|
-
};
|
|
683
|
-
this.getGasSponsor = (req, headers, signal) => {
|
|
684
|
-
return this.fetch(this.url('GetGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
685
|
-
return buildResponse(res).then(_data => {
|
|
686
|
-
return JsonDecode(_data, 'GetGasSponsorReturn');
|
|
687
|
-
});
|
|
688
|
-
}, error => {
|
|
689
|
-
throw WebrpcRequestFailedError.new({
|
|
690
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
691
|
-
});
|
|
692
|
-
});
|
|
693
|
-
};
|
|
694
|
-
this.addGasSponsor = (req, headers, signal) => {
|
|
695
|
-
return this.fetch(this.url('AddGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
696
|
-
return buildResponse(res).then(_data => {
|
|
697
|
-
return JsonDecode(_data, 'AddGasSponsorReturn');
|
|
698
|
-
});
|
|
699
|
-
}, error => {
|
|
700
|
-
throw WebrpcRequestFailedError.new({
|
|
701
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
702
|
-
});
|
|
703
|
-
});
|
|
704
|
-
};
|
|
705
|
-
this.updateGasSponsor = (req, headers, signal) => {
|
|
706
|
-
return this.fetch(this.url('UpdateGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
707
|
-
return buildResponse(res).then(_data => {
|
|
708
|
-
return JsonDecode(_data, 'UpdateGasSponsorReturn');
|
|
709
|
-
});
|
|
710
|
-
}, error => {
|
|
711
|
-
throw WebrpcRequestFailedError.new({
|
|
712
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
713
|
-
});
|
|
714
|
-
});
|
|
715
|
-
};
|
|
716
|
-
this.removeGasSponsor = (req, headers, signal) => {
|
|
717
|
-
return this.fetch(this.url('RemoveGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
718
|
-
return buildResponse(res).then(_data => {
|
|
719
|
-
return JsonDecode(_data, 'RemoveGasSponsorReturn');
|
|
720
|
-
});
|
|
721
|
-
}, error => {
|
|
722
|
-
throw WebrpcRequestFailedError.new({
|
|
723
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
724
|
-
});
|
|
725
|
-
});
|
|
726
|
-
};
|
|
727
|
-
this.addressGasSponsors = (req, headers, signal) => {
|
|
728
|
-
return this.fetch(this.url('AddressGasSponsors'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
729
|
-
return buildResponse(res).then(_data => {
|
|
730
|
-
return JsonDecode(_data, 'AddressGasSponsorsReturn');
|
|
731
|
-
});
|
|
732
|
-
}, error => {
|
|
733
|
-
throw WebrpcRequestFailedError.new({
|
|
734
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
735
|
-
});
|
|
736
|
-
});
|
|
737
|
-
};
|
|
738
|
-
this.getProjectBalance = (req, headers, signal) => {
|
|
739
|
-
return this.fetch(this.url('GetProjectBalance'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
740
|
-
return buildResponse(res).then(_data => {
|
|
741
|
-
return JsonDecode(_data, 'GetProjectBalanceReturn');
|
|
742
|
-
});
|
|
743
|
-
}, error => {
|
|
744
|
-
throw WebrpcRequestFailedError.new({
|
|
745
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
746
|
-
});
|
|
747
|
-
});
|
|
748
|
-
};
|
|
749
|
-
this.adjustProjectBalance = (req, headers, signal) => {
|
|
750
|
-
return this.fetch(this.url('AdjustProjectBalance'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
751
|
-
return buildResponse(res).then(_data => {
|
|
752
|
-
return JsonDecode(_data, 'AdjustProjectBalanceReturn');
|
|
753
|
-
});
|
|
754
|
-
}, error => {
|
|
755
|
-
throw WebrpcRequestFailedError.new({
|
|
756
|
-
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
757
|
-
});
|
|
758
|
-
});
|
|
759
|
-
};
|
|
760
|
-
this.hostname = hostname.replace(/\/*$/, '');
|
|
761
|
-
this.fetch = (input, init) => fetch(input, init);
|
|
762
|
-
}
|
|
763
|
-
url(name) {
|
|
764
|
-
return this.hostname + this.path + name;
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
const createHttpRequest = (body = '{}', headers = {}, signal = null) => {
|
|
768
|
-
const reqHeaders = _extends({}, headers, {
|
|
769
|
-
'Content-Type': 'application/json',
|
|
770
|
-
[WebrpcHeader]: WebrpcHeaderValue
|
|
771
|
-
});
|
|
772
|
-
return {
|
|
773
|
-
method: 'POST',
|
|
774
|
-
headers: reqHeaders,
|
|
775
|
-
body,
|
|
776
|
-
signal
|
|
777
|
-
};
|
|
778
|
-
};
|
|
779
|
-
const buildResponse = res => {
|
|
780
|
-
return res.text().then(text => {
|
|
781
|
-
let data;
|
|
782
|
-
try {
|
|
783
|
-
data = JSON.parse(text);
|
|
784
|
-
} catch (error) {
|
|
785
|
-
throw WebrpcBadResponseError.new({
|
|
786
|
-
status: res.status,
|
|
787
|
-
cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`
|
|
788
|
-
});
|
|
789
|
-
}
|
|
790
|
-
if (!res.ok) {
|
|
791
|
-
const code = typeof data.code === 'number' ? data.code : 0;
|
|
792
|
-
throw (webrpcErrorByCode[code] || WebrpcError).new(data);
|
|
793
|
-
}
|
|
794
|
-
return data;
|
|
795
|
-
});
|
|
796
|
-
};
|
|
797
|
-
//
|
|
798
|
-
// BigInt helpers
|
|
799
|
-
//
|
|
800
|
-
|
|
801
|
-
const BIG_INT_FIELDS = {
|
|
802
|
-
SendMetaTxnArgs: [['preconditions', 'TransactionPrecondition[]']],
|
|
803
|
-
TransactionPrecondition: ['minAmount'],
|
|
804
|
-
Transactions: [['preconditions', 'TransactionPrecondition[]']]
|
|
805
|
-
};
|
|
806
|
-
|
|
807
|
-
// Decode in-place: mutate object graph; throw if expected numeric string is invalid.
|
|
808
|
-
function decodeType(typ, obj) {
|
|
809
|
-
if (obj == null || typeof obj !== 'object') return obj;
|
|
810
|
-
const descs = BIG_INT_FIELDS[typ] || [];
|
|
811
|
-
if (!descs.length) return obj;
|
|
812
|
-
for (const d of descs) {
|
|
813
|
-
if (Array.isArray(d)) {
|
|
814
|
-
const [fieldName, nestedType] = d;
|
|
815
|
-
if (fieldName.endsWith('[]')) {
|
|
816
|
-
const base = fieldName.slice(0, -2);
|
|
817
|
-
const arr = obj[base];
|
|
818
|
-
if (Array.isArray(arr)) {
|
|
819
|
-
for (let i = 0; i < arr.length; i++) arr[i] = decodeType(nestedType, arr[i]);
|
|
820
|
-
}
|
|
821
|
-
} else if (obj[fieldName]) {
|
|
822
|
-
// Handle nestedType that might be an array type like 'Message[]'
|
|
823
|
-
if (nestedType.endsWith('[]')) {
|
|
824
|
-
const baseType = nestedType.slice(0, -2);
|
|
825
|
-
const arr = obj[fieldName];
|
|
826
|
-
if (Array.isArray(arr)) {
|
|
827
|
-
for (let i = 0; i < arr.length; i++) arr[i] = decodeType(baseType, arr[i]);
|
|
828
|
-
}
|
|
829
|
-
} else {
|
|
830
|
-
obj[fieldName] = decodeType(nestedType, obj[fieldName]);
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
continue;
|
|
834
|
-
}
|
|
835
|
-
if (d.endsWith('[]')) {
|
|
836
|
-
const base = d.slice(0, -2);
|
|
837
|
-
const arr = obj[base];
|
|
838
|
-
if (Array.isArray(arr)) {
|
|
839
|
-
for (let i = 0; i < arr.length; i++) {
|
|
840
|
-
const _v = arr[i];
|
|
841
|
-
if (typeof _v === 'string') {
|
|
842
|
-
try {
|
|
843
|
-
arr[i] = BigInt(_v);
|
|
844
|
-
} catch (e) {
|
|
845
|
-
throw WebrpcBadResponseError.new({
|
|
846
|
-
cause: `Invalid bigint value for ${base}[${i}]: ${_v}`
|
|
847
|
-
});
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
continue;
|
|
853
|
-
}
|
|
854
|
-
const v = obj[d];
|
|
855
|
-
if (typeof v === 'string') {
|
|
856
|
-
try {
|
|
857
|
-
obj[d] = BigInt(v);
|
|
858
|
-
} catch (e) {
|
|
859
|
-
throw WebrpcBadResponseError.new({
|
|
860
|
-
cause: `Invalid bigint value for ${d}: ${v}`
|
|
861
|
-
});
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
return obj;
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
// Encode object to JSON with BigInts converted to decimal strings.
|
|
869
|
-
const JsonEncode = obj => {
|
|
870
|
-
return JSON.stringify(obj, (key, value) => typeof value === 'bigint' ? value.toString() : value);
|
|
871
|
-
};
|
|
872
|
-
|
|
873
|
-
// Decode data (JSON string or already-parsed object) and convert declared BigInt string fields back to BigInt.
|
|
874
|
-
const JsonDecode = (data, typ = '') => {
|
|
875
|
-
let parsed = data;
|
|
876
|
-
if (typeof data === 'string') {
|
|
877
|
-
try {
|
|
878
|
-
parsed = JSON.parse(data);
|
|
879
|
-
} catch (err) {
|
|
880
|
-
throw WebrpcBadResponseError.new({
|
|
881
|
-
cause: `JsonDecode: JSON.parse failed: ${err.message}`
|
|
882
|
-
});
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
return decodeType(typ, parsed);
|
|
886
|
-
};
|
|
887
|
-
|
|
888
|
-
//
|
|
889
|
-
// Errors
|
|
890
|
-
//
|
|
891
|
-
|
|
892
|
-
class WebrpcError extends Error {
|
|
893
|
-
constructor(error = {}) {
|
|
894
|
-
super(error.message);
|
|
895
|
-
this.code = void 0;
|
|
896
|
-
this.status = void 0;
|
|
897
|
-
this.name = error.name || 'WebrpcEndpointError';
|
|
898
|
-
this.code = typeof error.code === 'number' ? error.code : 0;
|
|
899
|
-
this.message = error.message || `endpoint error`;
|
|
900
|
-
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
901
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
902
|
-
Object.setPrototypeOf(this, WebrpcError.prototype);
|
|
903
|
-
}
|
|
904
|
-
static new(payload) {
|
|
905
|
-
return new this({
|
|
906
|
-
message: payload.message,
|
|
907
|
-
code: payload.code,
|
|
908
|
-
status: payload.status,
|
|
909
|
-
cause: payload.cause
|
|
910
|
-
});
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
class WebrpcEndpointError extends WebrpcError {
|
|
914
|
-
constructor(error = {}) {
|
|
915
|
-
super(error);
|
|
916
|
-
this.name = error.name || 'WebrpcEndpoint';
|
|
917
|
-
this.code = typeof error.code === 'number' ? error.code : 0;
|
|
918
|
-
this.message = error.message || `endpoint error`;
|
|
919
|
-
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
920
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
921
|
-
Object.setPrototypeOf(this, WebrpcEndpointError.prototype);
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
class WebrpcRequestFailedError extends WebrpcError {
|
|
925
|
-
constructor(error = {}) {
|
|
926
|
-
super(error);
|
|
927
|
-
this.name = error.name || 'WebrpcRequestFailed';
|
|
928
|
-
this.code = typeof error.code === 'number' ? error.code : -1;
|
|
929
|
-
this.message = error.message || `request failed`;
|
|
930
|
-
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
931
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
932
|
-
Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype);
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
class WebrpcBadRouteError extends WebrpcError {
|
|
936
|
-
constructor(error = {}) {
|
|
937
|
-
super(error);
|
|
938
|
-
this.name = error.name || 'WebrpcBadRoute';
|
|
939
|
-
this.code = typeof error.code === 'number' ? error.code : -2;
|
|
940
|
-
this.message = error.message || `bad route`;
|
|
941
|
-
this.status = typeof error.status === 'number' ? error.status : 404;
|
|
942
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
943
|
-
Object.setPrototypeOf(this, WebrpcBadRouteError.prototype);
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
class WebrpcBadMethodError extends WebrpcError {
|
|
947
|
-
constructor(error = {}) {
|
|
948
|
-
super(error);
|
|
949
|
-
this.name = error.name || 'WebrpcBadMethod';
|
|
950
|
-
this.code = typeof error.code === 'number' ? error.code : -3;
|
|
951
|
-
this.message = error.message || `bad method`;
|
|
952
|
-
this.status = typeof error.status === 'number' ? error.status : 405;
|
|
953
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
954
|
-
Object.setPrototypeOf(this, WebrpcBadMethodError.prototype);
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
class WebrpcBadRequestError extends WebrpcError {
|
|
958
|
-
constructor(error = {}) {
|
|
959
|
-
super(error);
|
|
960
|
-
this.name = error.name || 'WebrpcBadRequest';
|
|
961
|
-
this.code = typeof error.code === 'number' ? error.code : -4;
|
|
962
|
-
this.message = error.message || `bad request`;
|
|
963
|
-
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
964
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
965
|
-
Object.setPrototypeOf(this, WebrpcBadRequestError.prototype);
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
class WebrpcBadResponseError extends WebrpcError {
|
|
969
|
-
constructor(error = {}) {
|
|
970
|
-
super(error);
|
|
971
|
-
this.name = error.name || 'WebrpcBadResponse';
|
|
972
|
-
this.code = typeof error.code === 'number' ? error.code : -5;
|
|
973
|
-
this.message = error.message || `bad response`;
|
|
974
|
-
this.status = typeof error.status === 'number' ? error.status : 500;
|
|
975
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
976
|
-
Object.setPrototypeOf(this, WebrpcBadResponseError.prototype);
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
class WebrpcServerPanicError extends WebrpcError {
|
|
980
|
-
constructor(error = {}) {
|
|
981
|
-
super(error);
|
|
982
|
-
this.name = error.name || 'WebrpcServerPanic';
|
|
983
|
-
this.code = typeof error.code === 'number' ? error.code : -6;
|
|
984
|
-
this.message = error.message || `server panic`;
|
|
985
|
-
this.status = typeof error.status === 'number' ? error.status : 500;
|
|
986
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
987
|
-
Object.setPrototypeOf(this, WebrpcServerPanicError.prototype);
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
class WebrpcInternalErrorError extends WebrpcError {
|
|
991
|
-
constructor(error = {}) {
|
|
992
|
-
super(error);
|
|
993
|
-
this.name = error.name || 'WebrpcInternalError';
|
|
994
|
-
this.code = typeof error.code === 'number' ? error.code : -7;
|
|
995
|
-
this.message = error.message || `internal error`;
|
|
996
|
-
this.status = typeof error.status === 'number' ? error.status : 500;
|
|
997
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
998
|
-
Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype);
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
class WebrpcClientAbortedError extends WebrpcError {
|
|
1002
|
-
constructor(error = {}) {
|
|
1003
|
-
super(error);
|
|
1004
|
-
this.name = error.name || 'WebrpcClientAborted';
|
|
1005
|
-
this.code = typeof error.code === 'number' ? error.code : -8;
|
|
1006
|
-
this.message = error.message || `request aborted by client`;
|
|
1007
|
-
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1008
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1009
|
-
Object.setPrototypeOf(this, WebrpcClientAbortedError.prototype);
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
class WebrpcStreamLostError extends WebrpcError {
|
|
1013
|
-
constructor(error = {}) {
|
|
1014
|
-
super(error);
|
|
1015
|
-
this.name = error.name || 'WebrpcStreamLost';
|
|
1016
|
-
this.code = typeof error.code === 'number' ? error.code : -9;
|
|
1017
|
-
this.message = error.message || `stream lost`;
|
|
1018
|
-
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1019
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1020
|
-
Object.setPrototypeOf(this, WebrpcStreamLostError.prototype);
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
class WebrpcStreamFinishedError extends WebrpcError {
|
|
1024
|
-
constructor(error = {}) {
|
|
1025
|
-
super(error);
|
|
1026
|
-
this.name = error.name || 'WebrpcStreamFinished';
|
|
1027
|
-
this.code = typeof error.code === 'number' ? error.code : -10;
|
|
1028
|
-
this.message = error.message || `stream finished`;
|
|
1029
|
-
this.status = typeof error.status === 'number' ? error.status : 200;
|
|
1030
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1031
|
-
Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype);
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
//
|
|
1036
|
-
// Schema errors
|
|
1037
|
-
//
|
|
1038
|
-
|
|
1039
|
-
class UnauthorizedError extends WebrpcError {
|
|
1040
|
-
constructor(error = {}) {
|
|
1041
|
-
super(error);
|
|
1042
|
-
this.name = error.name || 'Unauthorized';
|
|
1043
|
-
this.code = typeof error.code === 'number' ? error.code : 1000;
|
|
1044
|
-
this.message = error.message || `Unauthorized access`;
|
|
1045
|
-
this.status = typeof error.status === 'number' ? error.status : 401;
|
|
1046
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1047
|
-
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
class PermissionDeniedError extends WebrpcError {
|
|
1051
|
-
constructor(error = {}) {
|
|
1052
|
-
super(error);
|
|
1053
|
-
this.name = error.name || 'PermissionDenied';
|
|
1054
|
-
this.code = typeof error.code === 'number' ? error.code : 1001;
|
|
1055
|
-
this.message = error.message || `Permission denied`;
|
|
1056
|
-
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1057
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1058
|
-
Object.setPrototypeOf(this, PermissionDeniedError.prototype);
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
class SessionExpiredError extends WebrpcError {
|
|
1062
|
-
constructor(error = {}) {
|
|
1063
|
-
super(error);
|
|
1064
|
-
this.name = error.name || 'SessionExpired';
|
|
1065
|
-
this.code = typeof error.code === 'number' ? error.code : 1002;
|
|
1066
|
-
this.message = error.message || `Session expired`;
|
|
1067
|
-
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1068
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1069
|
-
Object.setPrototypeOf(this, SessionExpiredError.prototype);
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
class MethodNotFoundError extends WebrpcError {
|
|
1073
|
-
constructor(error = {}) {
|
|
1074
|
-
super(error);
|
|
1075
|
-
this.name = error.name || 'MethodNotFound';
|
|
1076
|
-
this.code = typeof error.code === 'number' ? error.code : 1003;
|
|
1077
|
-
this.message = error.message || `Method not found`;
|
|
1078
|
-
this.status = typeof error.status === 'number' ? error.status : 404;
|
|
1079
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1080
|
-
Object.setPrototypeOf(this, MethodNotFoundError.prototype);
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
class RequestConflictError extends WebrpcError {
|
|
1084
|
-
constructor(error = {}) {
|
|
1085
|
-
super(error);
|
|
1086
|
-
this.name = error.name || 'RequestConflict';
|
|
1087
|
-
this.code = typeof error.code === 'number' ? error.code : 1004;
|
|
1088
|
-
this.message = error.message || `Conflict with target resource`;
|
|
1089
|
-
this.status = typeof error.status === 'number' ? error.status : 409;
|
|
1090
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1091
|
-
Object.setPrototypeOf(this, RequestConflictError.prototype);
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
|
-
class AbortedError extends WebrpcError {
|
|
1095
|
-
constructor(error = {}) {
|
|
1096
|
-
super(error);
|
|
1097
|
-
this.name = error.name || 'Aborted';
|
|
1098
|
-
this.code = typeof error.code === 'number' ? error.code : 1005;
|
|
1099
|
-
this.message = error.message || `Request aborted`;
|
|
1100
|
-
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1101
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1102
|
-
Object.setPrototypeOf(this, AbortedError.prototype);
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
class GeoblockedError extends WebrpcError {
|
|
1106
|
-
constructor(error = {}) {
|
|
1107
|
-
super(error);
|
|
1108
|
-
this.name = error.name || 'Geoblocked';
|
|
1109
|
-
this.code = typeof error.code === 'number' ? error.code : 1006;
|
|
1110
|
-
this.message = error.message || `Geoblocked region`;
|
|
1111
|
-
this.status = typeof error.status === 'number' ? error.status : 451;
|
|
1112
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1113
|
-
Object.setPrototypeOf(this, GeoblockedError.prototype);
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
class RateLimitedError extends WebrpcError {
|
|
1117
|
-
constructor(error = {}) {
|
|
1118
|
-
super(error);
|
|
1119
|
-
this.name = error.name || 'RateLimited';
|
|
1120
|
-
this.code = typeof error.code === 'number' ? error.code : 1007;
|
|
1121
|
-
this.message = error.message || `Rate-limited. Please slow down.`;
|
|
1122
|
-
this.status = typeof error.status === 'number' ? error.status : 429;
|
|
1123
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1124
|
-
Object.setPrototypeOf(this, RateLimitedError.prototype);
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
class ProjectNotFoundError extends WebrpcError {
|
|
1128
|
-
constructor(error = {}) {
|
|
1129
|
-
super(error);
|
|
1130
|
-
this.name = error.name || 'ProjectNotFound';
|
|
1131
|
-
this.code = typeof error.code === 'number' ? error.code : 1008;
|
|
1132
|
-
this.message = error.message || `Project not found`;
|
|
1133
|
-
this.status = typeof error.status === 'number' ? error.status : 401;
|
|
1134
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1135
|
-
Object.setPrototypeOf(this, ProjectNotFoundError.prototype);
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
class AccessKeyNotFoundError extends WebrpcError {
|
|
1139
|
-
constructor(error = {}) {
|
|
1140
|
-
super(error);
|
|
1141
|
-
this.name = error.name || 'AccessKeyNotFound';
|
|
1142
|
-
this.code = typeof error.code === 'number' ? error.code : 1101;
|
|
1143
|
-
this.message = error.message || `Access key not found`;
|
|
1144
|
-
this.status = typeof error.status === 'number' ? error.status : 401;
|
|
1145
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1146
|
-
Object.setPrototypeOf(this, AccessKeyNotFoundError.prototype);
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
class AccessKeyMismatchError extends WebrpcError {
|
|
1150
|
-
constructor(error = {}) {
|
|
1151
|
-
super(error);
|
|
1152
|
-
this.name = error.name || 'AccessKeyMismatch';
|
|
1153
|
-
this.code = typeof error.code === 'number' ? error.code : 1102;
|
|
1154
|
-
this.message = error.message || `Access key mismatch`;
|
|
1155
|
-
this.status = typeof error.status === 'number' ? error.status : 409;
|
|
1156
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1157
|
-
Object.setPrototypeOf(this, AccessKeyMismatchError.prototype);
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
class InvalidOriginError extends WebrpcError {
|
|
1161
|
-
constructor(error = {}) {
|
|
1162
|
-
super(error);
|
|
1163
|
-
this.name = error.name || 'InvalidOrigin';
|
|
1164
|
-
this.code = typeof error.code === 'number' ? error.code : 1103;
|
|
1165
|
-
this.message = error.message || `Invalid origin for Access Key`;
|
|
1166
|
-
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1167
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1168
|
-
Object.setPrototypeOf(this, InvalidOriginError.prototype);
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
class InvalidServiceError extends WebrpcError {
|
|
1172
|
-
constructor(error = {}) {
|
|
1173
|
-
super(error);
|
|
1174
|
-
this.name = error.name || 'InvalidService';
|
|
1175
|
-
this.code = typeof error.code === 'number' ? error.code : 1104;
|
|
1176
|
-
this.message = error.message || `Service not enabled for Access key`;
|
|
1177
|
-
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1178
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1179
|
-
Object.setPrototypeOf(this, InvalidServiceError.prototype);
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
class UnauthorizedUserError extends WebrpcError {
|
|
1183
|
-
constructor(error = {}) {
|
|
1184
|
-
super(error);
|
|
1185
|
-
this.name = error.name || 'UnauthorizedUser';
|
|
1186
|
-
this.code = typeof error.code === 'number' ? error.code : 1105;
|
|
1187
|
-
this.message = error.message || `Unauthorized user`;
|
|
1188
|
-
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1189
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1190
|
-
Object.setPrototypeOf(this, UnauthorizedUserError.prototype);
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
class QuotaExceededError extends WebrpcError {
|
|
1194
|
-
constructor(error = {}) {
|
|
1195
|
-
super(error);
|
|
1196
|
-
this.name = error.name || 'QuotaExceeded';
|
|
1197
|
-
this.code = typeof error.code === 'number' ? error.code : 1200;
|
|
1198
|
-
this.message = error.message || `Quota request exceeded`;
|
|
1199
|
-
this.status = typeof error.status === 'number' ? error.status : 429;
|
|
1200
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1201
|
-
Object.setPrototypeOf(this, QuotaExceededError.prototype);
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
class QuotaRateLimitError extends WebrpcError {
|
|
1205
|
-
constructor(error = {}) {
|
|
1206
|
-
super(error);
|
|
1207
|
-
this.name = error.name || 'QuotaRateLimit';
|
|
1208
|
-
this.code = typeof error.code === 'number' ? error.code : 1201;
|
|
1209
|
-
this.message = error.message || `Quota rate limit exceeded`;
|
|
1210
|
-
this.status = typeof error.status === 'number' ? error.status : 429;
|
|
1211
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1212
|
-
Object.setPrototypeOf(this, QuotaRateLimitError.prototype);
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
class NoDefaultKeyError extends WebrpcError {
|
|
1216
|
-
constructor(error = {}) {
|
|
1217
|
-
super(error);
|
|
1218
|
-
this.name = error.name || 'NoDefaultKey';
|
|
1219
|
-
this.code = typeof error.code === 'number' ? error.code : 1300;
|
|
1220
|
-
this.message = error.message || `No default access key found`;
|
|
1221
|
-
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1222
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1223
|
-
Object.setPrototypeOf(this, NoDefaultKeyError.prototype);
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
class MaxAccessKeysError extends WebrpcError {
|
|
1227
|
-
constructor(error = {}) {
|
|
1228
|
-
super(error);
|
|
1229
|
-
this.name = error.name || 'MaxAccessKeys';
|
|
1230
|
-
this.code = typeof error.code === 'number' ? error.code : 1301;
|
|
1231
|
-
this.message = error.message || `Access keys limit reached`;
|
|
1232
|
-
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1233
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1234
|
-
Object.setPrototypeOf(this, MaxAccessKeysError.prototype);
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
class AtLeastOneKeyError extends WebrpcError {
|
|
1238
|
-
constructor(error = {}) {
|
|
1239
|
-
super(error);
|
|
1240
|
-
this.name = error.name || 'AtLeastOneKey';
|
|
1241
|
-
this.code = typeof error.code === 'number' ? error.code : 1302;
|
|
1242
|
-
this.message = error.message || `You need at least one Access Key`;
|
|
1243
|
-
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1244
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1245
|
-
Object.setPrototypeOf(this, AtLeastOneKeyError.prototype);
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
class TimeoutError extends WebrpcError {
|
|
1249
|
-
constructor(error = {}) {
|
|
1250
|
-
super(error);
|
|
1251
|
-
this.name = error.name || 'Timeout';
|
|
1252
|
-
this.code = typeof error.code === 'number' ? error.code : 1900;
|
|
1253
|
-
this.message = error.message || `Request timed out`;
|
|
1254
|
-
this.status = typeof error.status === 'number' ? error.status : 408;
|
|
1255
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1256
|
-
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
class InvalidArgumentError extends WebrpcError {
|
|
1260
|
-
constructor(error = {}) {
|
|
1261
|
-
super(error);
|
|
1262
|
-
this.name = error.name || 'InvalidArgument';
|
|
1263
|
-
this.code = typeof error.code === 'number' ? error.code : 2001;
|
|
1264
|
-
this.message = error.message || `Invalid argument`;
|
|
1265
|
-
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1266
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1267
|
-
Object.setPrototypeOf(this, InvalidArgumentError.prototype);
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
class UnavailableError extends WebrpcError {
|
|
1271
|
-
constructor(error = {}) {
|
|
1272
|
-
super(error);
|
|
1273
|
-
this.name = error.name || 'Unavailable';
|
|
1274
|
-
this.code = typeof error.code === 'number' ? error.code : 2002;
|
|
1275
|
-
this.message = error.message || `Unavailable resource`;
|
|
1276
|
-
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1277
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1278
|
-
Object.setPrototypeOf(this, UnavailableError.prototype);
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
class QueryFailedError extends WebrpcError {
|
|
1282
|
-
constructor(error = {}) {
|
|
1283
|
-
super(error);
|
|
1284
|
-
this.name = error.name || 'QueryFailed';
|
|
1285
|
-
this.code = typeof error.code === 'number' ? error.code : 2003;
|
|
1286
|
-
this.message = error.message || `Query failed`;
|
|
1287
|
-
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1288
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1289
|
-
Object.setPrototypeOf(this, QueryFailedError.prototype);
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
class NotFoundError extends WebrpcError {
|
|
1293
|
-
constructor(error = {}) {
|
|
1294
|
-
super(error);
|
|
1295
|
-
this.name = error.name || 'NotFound';
|
|
1296
|
-
this.code = typeof error.code === 'number' ? error.code : 3000;
|
|
1297
|
-
this.message = error.message || `Resource not found`;
|
|
1298
|
-
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1299
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1300
|
-
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
class InsufficientFeeError extends WebrpcError {
|
|
1304
|
-
constructor(error = {}) {
|
|
1305
|
-
super(error);
|
|
1306
|
-
this.name = error.name || 'InsufficientFee';
|
|
1307
|
-
this.code = typeof error.code === 'number' ? error.code : 3004;
|
|
1308
|
-
this.message = error.message || `Insufficient fee`;
|
|
1309
|
-
this.status = typeof error.status === 'number' ? error.status : 402;
|
|
1310
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1311
|
-
Object.setPrototypeOf(this, InsufficientFeeError.prototype);
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
class NotEnoughBalanceError extends WebrpcError {
|
|
1315
|
-
constructor(error = {}) {
|
|
1316
|
-
super(error);
|
|
1317
|
-
this.name = error.name || 'NotEnoughBalance';
|
|
1318
|
-
this.code = typeof error.code === 'number' ? error.code : 3005;
|
|
1319
|
-
this.message = error.message || `Not enough balance`;
|
|
1320
|
-
this.status = typeof error.status === 'number' ? error.status : 402;
|
|
1321
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1322
|
-
Object.setPrototypeOf(this, NotEnoughBalanceError.prototype);
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
class SimulationFailedError extends WebrpcError {
|
|
1326
|
-
constructor(error = {}) {
|
|
1327
|
-
super(error);
|
|
1328
|
-
this.name = error.name || 'SimulationFailed';
|
|
1329
|
-
this.code = typeof error.code === 'number' ? error.code : 3006;
|
|
1330
|
-
this.message = error.message || `Simulation failed`;
|
|
1331
|
-
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1332
|
-
if (error.cause !== undefined) this.cause = error.cause;
|
|
1333
|
-
Object.setPrototypeOf(this, SimulationFailedError.prototype);
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
let errors = /*#__PURE__*/function (errors) {
|
|
1337
|
-
errors["WebrpcEndpoint"] = "WebrpcEndpoint";
|
|
1338
|
-
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed";
|
|
1339
|
-
errors["WebrpcBadRoute"] = "WebrpcBadRoute";
|
|
1340
|
-
errors["WebrpcBadMethod"] = "WebrpcBadMethod";
|
|
1341
|
-
errors["WebrpcBadRequest"] = "WebrpcBadRequest";
|
|
1342
|
-
errors["WebrpcBadResponse"] = "WebrpcBadResponse";
|
|
1343
|
-
errors["WebrpcServerPanic"] = "WebrpcServerPanic";
|
|
1344
|
-
errors["WebrpcInternalError"] = "WebrpcInternalError";
|
|
1345
|
-
errors["WebrpcClientAborted"] = "WebrpcClientAborted";
|
|
1346
|
-
errors["WebrpcStreamLost"] = "WebrpcStreamLost";
|
|
1347
|
-
errors["WebrpcStreamFinished"] = "WebrpcStreamFinished";
|
|
1348
|
-
errors["Unauthorized"] = "Unauthorized";
|
|
1349
|
-
errors["PermissionDenied"] = "PermissionDenied";
|
|
1350
|
-
errors["SessionExpired"] = "SessionExpired";
|
|
1351
|
-
errors["MethodNotFound"] = "MethodNotFound";
|
|
1352
|
-
errors["RequestConflict"] = "RequestConflict";
|
|
1353
|
-
errors["Aborted"] = "Aborted";
|
|
1354
|
-
errors["Geoblocked"] = "Geoblocked";
|
|
1355
|
-
errors["RateLimited"] = "RateLimited";
|
|
1356
|
-
errors["ProjectNotFound"] = "ProjectNotFound";
|
|
1357
|
-
errors["AccessKeyNotFound"] = "AccessKeyNotFound";
|
|
1358
|
-
errors["AccessKeyMismatch"] = "AccessKeyMismatch";
|
|
1359
|
-
errors["InvalidOrigin"] = "InvalidOrigin";
|
|
1360
|
-
errors["InvalidService"] = "InvalidService";
|
|
1361
|
-
errors["UnauthorizedUser"] = "UnauthorizedUser";
|
|
1362
|
-
errors["QuotaExceeded"] = "QuotaExceeded";
|
|
1363
|
-
errors["QuotaRateLimit"] = "QuotaRateLimit";
|
|
1364
|
-
errors["NoDefaultKey"] = "NoDefaultKey";
|
|
1365
|
-
errors["MaxAccessKeys"] = "MaxAccessKeys";
|
|
1366
|
-
errors["AtLeastOneKey"] = "AtLeastOneKey";
|
|
1367
|
-
errors["Timeout"] = "Timeout";
|
|
1368
|
-
errors["InvalidArgument"] = "InvalidArgument";
|
|
1369
|
-
errors["Unavailable"] = "Unavailable";
|
|
1370
|
-
errors["QueryFailed"] = "QueryFailed";
|
|
1371
|
-
errors["NotFound"] = "NotFound";
|
|
1372
|
-
errors["InsufficientFee"] = "InsufficientFee";
|
|
1373
|
-
errors["NotEnoughBalance"] = "NotEnoughBalance";
|
|
1374
|
-
errors["SimulationFailed"] = "SimulationFailed";
|
|
1375
|
-
return errors;
|
|
1376
|
-
}({});
|
|
1377
|
-
let WebrpcErrorCodes = /*#__PURE__*/function (WebrpcErrorCodes) {
|
|
1378
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcEndpoint"] = 0] = "WebrpcEndpoint";
|
|
1379
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcRequestFailed"] = -1] = "WebrpcRequestFailed";
|
|
1380
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadRoute"] = -2] = "WebrpcBadRoute";
|
|
1381
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadMethod"] = -3] = "WebrpcBadMethod";
|
|
1382
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadRequest"] = -4] = "WebrpcBadRequest";
|
|
1383
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadResponse"] = -5] = "WebrpcBadResponse";
|
|
1384
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcServerPanic"] = -6] = "WebrpcServerPanic";
|
|
1385
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcInternalError"] = -7] = "WebrpcInternalError";
|
|
1386
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcClientAborted"] = -8] = "WebrpcClientAborted";
|
|
1387
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamLost"] = -9] = "WebrpcStreamLost";
|
|
1388
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamFinished"] = -10] = "WebrpcStreamFinished";
|
|
1389
|
-
WebrpcErrorCodes[WebrpcErrorCodes["Unauthorized"] = 1000] = "Unauthorized";
|
|
1390
|
-
WebrpcErrorCodes[WebrpcErrorCodes["PermissionDenied"] = 1001] = "PermissionDenied";
|
|
1391
|
-
WebrpcErrorCodes[WebrpcErrorCodes["SessionExpired"] = 1002] = "SessionExpired";
|
|
1392
|
-
WebrpcErrorCodes[WebrpcErrorCodes["MethodNotFound"] = 1003] = "MethodNotFound";
|
|
1393
|
-
WebrpcErrorCodes[WebrpcErrorCodes["RequestConflict"] = 1004] = "RequestConflict";
|
|
1394
|
-
WebrpcErrorCodes[WebrpcErrorCodes["Aborted"] = 1005] = "Aborted";
|
|
1395
|
-
WebrpcErrorCodes[WebrpcErrorCodes["Geoblocked"] = 1006] = "Geoblocked";
|
|
1396
|
-
WebrpcErrorCodes[WebrpcErrorCodes["RateLimited"] = 1007] = "RateLimited";
|
|
1397
|
-
WebrpcErrorCodes[WebrpcErrorCodes["ProjectNotFound"] = 1008] = "ProjectNotFound";
|
|
1398
|
-
WebrpcErrorCodes[WebrpcErrorCodes["AccessKeyNotFound"] = 1101] = "AccessKeyNotFound";
|
|
1399
|
-
WebrpcErrorCodes[WebrpcErrorCodes["AccessKeyMismatch"] = 1102] = "AccessKeyMismatch";
|
|
1400
|
-
WebrpcErrorCodes[WebrpcErrorCodes["InvalidOrigin"] = 1103] = "InvalidOrigin";
|
|
1401
|
-
WebrpcErrorCodes[WebrpcErrorCodes["InvalidService"] = 1104] = "InvalidService";
|
|
1402
|
-
WebrpcErrorCodes[WebrpcErrorCodes["UnauthorizedUser"] = 1105] = "UnauthorizedUser";
|
|
1403
|
-
WebrpcErrorCodes[WebrpcErrorCodes["QuotaExceeded"] = 1200] = "QuotaExceeded";
|
|
1404
|
-
WebrpcErrorCodes[WebrpcErrorCodes["QuotaRateLimit"] = 1201] = "QuotaRateLimit";
|
|
1405
|
-
WebrpcErrorCodes[WebrpcErrorCodes["NoDefaultKey"] = 1300] = "NoDefaultKey";
|
|
1406
|
-
WebrpcErrorCodes[WebrpcErrorCodes["MaxAccessKeys"] = 1301] = "MaxAccessKeys";
|
|
1407
|
-
WebrpcErrorCodes[WebrpcErrorCodes["AtLeastOneKey"] = 1302] = "AtLeastOneKey";
|
|
1408
|
-
WebrpcErrorCodes[WebrpcErrorCodes["Timeout"] = 1900] = "Timeout";
|
|
1409
|
-
WebrpcErrorCodes[WebrpcErrorCodes["InvalidArgument"] = 2001] = "InvalidArgument";
|
|
1410
|
-
WebrpcErrorCodes[WebrpcErrorCodes["Unavailable"] = 2002] = "Unavailable";
|
|
1411
|
-
WebrpcErrorCodes[WebrpcErrorCodes["QueryFailed"] = 2003] = "QueryFailed";
|
|
1412
|
-
WebrpcErrorCodes[WebrpcErrorCodes["NotFound"] = 3000] = "NotFound";
|
|
1413
|
-
WebrpcErrorCodes[WebrpcErrorCodes["InsufficientFee"] = 3004] = "InsufficientFee";
|
|
1414
|
-
WebrpcErrorCodes[WebrpcErrorCodes["NotEnoughBalance"] = 3005] = "NotEnoughBalance";
|
|
1415
|
-
WebrpcErrorCodes[WebrpcErrorCodes["SimulationFailed"] = 3006] = "SimulationFailed";
|
|
1416
|
-
return WebrpcErrorCodes;
|
|
1417
|
-
}({});
|
|
1418
|
-
const webrpcErrorByCode = {
|
|
1419
|
-
[0]: WebrpcEndpointError,
|
|
1420
|
-
[-1]: WebrpcRequestFailedError,
|
|
1421
|
-
[-2]: WebrpcBadRouteError,
|
|
1422
|
-
[-3]: WebrpcBadMethodError,
|
|
1423
|
-
[-4]: WebrpcBadRequestError,
|
|
1424
|
-
[-5]: WebrpcBadResponseError,
|
|
1425
|
-
[-6]: WebrpcServerPanicError,
|
|
1426
|
-
[-7]: WebrpcInternalErrorError,
|
|
1427
|
-
[-8]: WebrpcClientAbortedError,
|
|
1428
|
-
[-9]: WebrpcStreamLostError,
|
|
1429
|
-
[-10]: WebrpcStreamFinishedError,
|
|
1430
|
-
[1000]: UnauthorizedError,
|
|
1431
|
-
[1001]: PermissionDeniedError,
|
|
1432
|
-
[1002]: SessionExpiredError,
|
|
1433
|
-
[1003]: MethodNotFoundError,
|
|
1434
|
-
[1004]: RequestConflictError,
|
|
1435
|
-
[1005]: AbortedError,
|
|
1436
|
-
[1006]: GeoblockedError,
|
|
1437
|
-
[1007]: RateLimitedError,
|
|
1438
|
-
[1008]: ProjectNotFoundError,
|
|
1439
|
-
[1101]: AccessKeyNotFoundError,
|
|
1440
|
-
[1102]: AccessKeyMismatchError,
|
|
1441
|
-
[1103]: InvalidOriginError,
|
|
1442
|
-
[1104]: InvalidServiceError,
|
|
1443
|
-
[1105]: UnauthorizedUserError,
|
|
1444
|
-
[1200]: QuotaExceededError,
|
|
1445
|
-
[1201]: QuotaRateLimitError,
|
|
1446
|
-
[1300]: NoDefaultKeyError,
|
|
1447
|
-
[1301]: MaxAccessKeysError,
|
|
1448
|
-
[1302]: AtLeastOneKeyError,
|
|
1449
|
-
[1900]: TimeoutError,
|
|
1450
|
-
[2001]: InvalidArgumentError,
|
|
1451
|
-
[2002]: UnavailableError,
|
|
1452
|
-
[2003]: QueryFailedError,
|
|
1453
|
-
[3000]: NotFoundError,
|
|
1454
|
-
[3004]: InsufficientFeeError,
|
|
1455
|
-
[3005]: NotEnoughBalanceError,
|
|
1456
|
-
[3006]: SimulationFailedError
|
|
1457
|
-
};
|
|
1458
|
-
|
|
1459
|
-
//
|
|
1460
|
-
// Webrpc
|
|
1461
|
-
//
|
|
1462
|
-
|
|
1463
|
-
const WebrpcHeader = 'Webrpc';
|
|
1464
|
-
const WebrpcHeaderValue = 'webrpc@v0.31.2;gen-typescript@v0.23.1;sequence-relayer@v0.4.1';
|
|
1465
|
-
function VersionFromHeader(headers) {
|
|
1466
|
-
const headerValue = headers.get(WebrpcHeader);
|
|
1467
|
-
if (!headerValue) {
|
|
1468
|
-
return {
|
|
1469
|
-
WebrpcGenVersion: '',
|
|
1470
|
-
codeGenName: '',
|
|
1471
|
-
codeGenVersion: '',
|
|
1472
|
-
schemaName: '',
|
|
1473
|
-
schemaVersion: ''
|
|
1474
|
-
};
|
|
1475
|
-
}
|
|
1476
|
-
return parseWebrpcGenVersions(headerValue);
|
|
1477
|
-
}
|
|
1478
|
-
function parseWebrpcGenVersions(header) {
|
|
1479
|
-
const versions = header.split(';');
|
|
1480
|
-
if (versions.length < 3) {
|
|
1481
|
-
return {
|
|
1482
|
-
WebrpcGenVersion: '',
|
|
1483
|
-
codeGenName: '',
|
|
1484
|
-
codeGenVersion: '',
|
|
1485
|
-
schemaName: '',
|
|
1486
|
-
schemaVersion: ''
|
|
1487
|
-
};
|
|
1488
|
-
}
|
|
1489
|
-
const [_, WebrpcGenVersion] = versions[0].split('@');
|
|
1490
|
-
const [codeGenName, codeGenVersion] = versions[1].split('@');
|
|
1491
|
-
const [schemaName, schemaVersion] = versions[2].split('@');
|
|
1492
|
-
return {
|
|
1493
|
-
WebrpcGenVersion: WebrpcGenVersion != null ? WebrpcGenVersion : '',
|
|
1494
|
-
codeGenName: codeGenName != null ? codeGenName : '',
|
|
1495
|
-
codeGenVersion: codeGenVersion != null ? codeGenVersion : '',
|
|
1496
|
-
schemaName: schemaName != null ? schemaName : '',
|
|
1497
|
-
schemaVersion: schemaVersion != null ? schemaVersion : ''
|
|
1498
|
-
};
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
|
-
var relayer_gen = /*#__PURE__*/Object.freeze({
|
|
1502
|
-
__proto__: null,
|
|
1503
|
-
WebrpcVersion: WebrpcVersion,
|
|
1504
|
-
WebrpcSchemaVersion: WebrpcSchemaVersion,
|
|
1505
|
-
WebrpcSchemaHash: WebrpcSchemaHash,
|
|
1506
|
-
ETHTxnStatus: ETHTxnStatus,
|
|
1507
|
-
TransferType: TransferType,
|
|
1508
|
-
SimulateStatus: SimulateStatus,
|
|
1509
|
-
FeeTokenType: FeeTokenType,
|
|
1510
|
-
SortOrder: SortOrder,
|
|
1511
|
-
Relayer: Relayer,
|
|
1512
|
-
JsonEncode: JsonEncode,
|
|
1513
|
-
JsonDecode: JsonDecode,
|
|
1514
|
-
WebrpcError: WebrpcError,
|
|
1515
|
-
WebrpcEndpointError: WebrpcEndpointError,
|
|
1516
|
-
WebrpcRequestFailedError: WebrpcRequestFailedError,
|
|
1517
|
-
WebrpcBadRouteError: WebrpcBadRouteError,
|
|
1518
|
-
WebrpcBadMethodError: WebrpcBadMethodError,
|
|
1519
|
-
WebrpcBadRequestError: WebrpcBadRequestError,
|
|
1520
|
-
WebrpcBadResponseError: WebrpcBadResponseError,
|
|
1521
|
-
WebrpcServerPanicError: WebrpcServerPanicError,
|
|
1522
|
-
WebrpcInternalErrorError: WebrpcInternalErrorError,
|
|
1523
|
-
WebrpcClientAbortedError: WebrpcClientAbortedError,
|
|
1524
|
-
WebrpcStreamLostError: WebrpcStreamLostError,
|
|
1525
|
-
WebrpcStreamFinishedError: WebrpcStreamFinishedError,
|
|
1526
|
-
UnauthorizedError: UnauthorizedError,
|
|
1527
|
-
PermissionDeniedError: PermissionDeniedError,
|
|
1528
|
-
SessionExpiredError: SessionExpiredError,
|
|
1529
|
-
MethodNotFoundError: MethodNotFoundError,
|
|
1530
|
-
RequestConflictError: RequestConflictError,
|
|
1531
|
-
AbortedError: AbortedError,
|
|
1532
|
-
GeoblockedError: GeoblockedError,
|
|
1533
|
-
RateLimitedError: RateLimitedError,
|
|
1534
|
-
ProjectNotFoundError: ProjectNotFoundError,
|
|
1535
|
-
AccessKeyNotFoundError: AccessKeyNotFoundError,
|
|
1536
|
-
AccessKeyMismatchError: AccessKeyMismatchError,
|
|
1537
|
-
InvalidOriginError: InvalidOriginError,
|
|
1538
|
-
InvalidServiceError: InvalidServiceError,
|
|
1539
|
-
UnauthorizedUserError: UnauthorizedUserError,
|
|
1540
|
-
QuotaExceededError: QuotaExceededError,
|
|
1541
|
-
QuotaRateLimitError: QuotaRateLimitError,
|
|
1542
|
-
NoDefaultKeyError: NoDefaultKeyError,
|
|
1543
|
-
MaxAccessKeysError: MaxAccessKeysError,
|
|
1544
|
-
AtLeastOneKeyError: AtLeastOneKeyError,
|
|
1545
|
-
TimeoutError: TimeoutError,
|
|
1546
|
-
InvalidArgumentError: InvalidArgumentError,
|
|
1547
|
-
UnavailableError: UnavailableError,
|
|
1548
|
-
QueryFailedError: QueryFailedError,
|
|
1549
|
-
NotFoundError: NotFoundError,
|
|
1550
|
-
InsufficientFeeError: InsufficientFeeError,
|
|
1551
|
-
NotEnoughBalanceError: NotEnoughBalanceError,
|
|
1552
|
-
SimulationFailedError: SimulationFailedError,
|
|
1553
|
-
errors: errors,
|
|
1554
|
-
WebrpcErrorCodes: WebrpcErrorCodes,
|
|
1555
|
-
webrpcErrorByCode: webrpcErrorByCode,
|
|
1556
|
-
WebrpcHeader: WebrpcHeader,
|
|
1557
|
-
WebrpcHeaderValue: WebrpcHeaderValue,
|
|
1558
|
-
VersionFromHeader: VersionFromHeader
|
|
1559
|
-
});
|
|
1560
|
-
|
|
1561
|
-
const FINAL_STATUSES = [ETHTxnStatus.DROPPED, ETHTxnStatus.SUCCEEDED, ETHTxnStatus.PARTIALLY_FAILED, ETHTxnStatus.FAILED];
|
|
1562
|
-
const FAILED_STATUSES = [ETHTxnStatus.DROPPED, ETHTxnStatus.PARTIALLY_FAILED, ETHTxnStatus.FAILED];
|
|
1563
|
-
function isRpcRelayerOptions(obj) {
|
|
1564
|
-
return obj.url !== undefined && typeof obj.url === 'string' && obj.provider !== undefined && isAbstractProvider(obj.provider);
|
|
1565
|
-
}
|
|
1566
|
-
|
|
1567
|
-
// TODO: rename to SequenceRelayer
|
|
1568
|
-
class RpcRelayer {
|
|
1569
|
-
constructor(options) {
|
|
1570
|
-
this.options = options;
|
|
1571
|
-
this.service = void 0;
|
|
1572
|
-
this.provider = void 0;
|
|
1573
|
-
this._fetch = (input, init) => {
|
|
1574
|
-
// automatically include jwt and access key auth header to requests
|
|
1575
|
-
// if its been set on the api client
|
|
1576
|
-
const headers = {};
|
|
1577
|
-
const {
|
|
1578
|
-
jwtAuth,
|
|
1579
|
-
projectAccessKey
|
|
1580
|
-
} = this.options;
|
|
1581
|
-
if (jwtAuth && jwtAuth.length > 0) {
|
|
1582
|
-
headers['Authorization'] = `BEARER ${jwtAuth}`;
|
|
1583
|
-
}
|
|
1584
|
-
if (projectAccessKey && projectAccessKey.length > 0) {
|
|
1585
|
-
headers['X-Access-Key'] = projectAccessKey;
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
// before the request is made
|
|
1589
|
-
init.headers = _extends({}, headers, init.headers);
|
|
1590
|
-
return fetch(input, init);
|
|
1591
|
-
};
|
|
1592
|
-
this.service = new Relayer(options.url, this._fetch);
|
|
1593
|
-
if (isAbstractProvider(options.provider)) {
|
|
1594
|
-
this.provider = options.provider;
|
|
1595
|
-
} else {
|
|
1596
|
-
const {
|
|
1597
|
-
jwtAuth,
|
|
1598
|
-
projectAccessKey
|
|
1599
|
-
} = this.options;
|
|
1600
|
-
const fetchRequest = utils.getFetchRequest(options.provider.url, projectAccessKey, jwtAuth);
|
|
1601
|
-
this.provider = new ethers.ethers.JsonRpcProvider(fetchRequest, undefined, {
|
|
1602
|
-
staticNetwork: true
|
|
1603
|
-
});
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
async waitReceipt(metaTxnId, delay = 1000, maxFails = 5, isCancelled) {
|
|
1607
|
-
if (typeof metaTxnId !== 'string') {
|
|
1608
|
-
metaTxnId = core.commons.transaction.intendedTransactionID(metaTxnId);
|
|
1609
|
-
}
|
|
1610
|
-
utils.logger.info(`[rpc-relayer/waitReceipt] waiting for ${metaTxnId}`);
|
|
1611
|
-
let fails = 0;
|
|
1612
|
-
while (isCancelled === undefined || !isCancelled()) {
|
|
1613
|
-
try {
|
|
1614
|
-
const {
|
|
1615
|
-
receipt
|
|
1616
|
-
} = await this.service.getMetaTxnReceipt({
|
|
1617
|
-
metaTxID: metaTxnId
|
|
1618
|
-
});
|
|
1619
|
-
if (receipt && receipt.txnReceipt && receipt.txnReceipt !== 'null' && FINAL_STATUSES.includes(receipt.status)) {
|
|
1620
|
-
return {
|
|
1621
|
-
receipt
|
|
1622
|
-
};
|
|
1623
|
-
}
|
|
1624
|
-
} catch (e) {
|
|
1625
|
-
fails++;
|
|
1626
|
-
if (fails === maxFails) {
|
|
1627
|
-
throw e;
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
if (isCancelled === undefined || !isCancelled()) {
|
|
1631
|
-
await new Promise(resolve => setTimeout(resolve, delay));
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
throw new Error(`Cancelled waiting for transaction receipt ${metaTxnId}`);
|
|
1635
|
-
}
|
|
1636
|
-
async simulate(wallet, ...transactions) {
|
|
1637
|
-
const coder = ethers.ethers.AbiCoder.defaultAbiCoder();
|
|
1638
|
-
const encoded = coder.encode([core.commons.transaction.MetaTransactionsType], [core.commons.transaction.sequenceTxAbiEncode(transactions)]);
|
|
1639
|
-
return (await this.service.simulate({
|
|
1640
|
-
wallet,
|
|
1641
|
-
transactions: encoded
|
|
1642
|
-
})).results;
|
|
1643
|
-
}
|
|
1644
|
-
async getFeeOptions(address, ...transactions) {
|
|
1645
|
-
// NOTE/TODO: for a given `service` the feeTokens will not change between execution, so we should memoize this value
|
|
1646
|
-
// for a short-period of time, perhaps for 1 day or in memory. Perhaps one day we can make this happen automatically
|
|
1647
|
-
// with http cache response for this endpoint and service-worker.. lots of approaches
|
|
1648
|
-
const feeTokens = await this.service.feeTokens();
|
|
1649
|
-
if (feeTokens.isFeeRequired) {
|
|
1650
|
-
const symbols = feeTokens.tokens.map(token => token.symbol).join(', ');
|
|
1651
|
-
utils.logger.info(`[rpc-relayer/getFeeOptions] relayer fees are required, accepted tokens are ${symbols}`);
|
|
1652
|
-
const nonce = await this.getNonce(address);
|
|
1653
|
-
if (!this.provider) {
|
|
1654
|
-
utils.logger.warn(`[rpc-relayer/getFeeOptions] provider not set, needed for stub signature`);
|
|
1655
|
-
throw new Error('provider is not set');
|
|
1656
|
-
}
|
|
1657
|
-
const {
|
|
1658
|
-
options,
|
|
1659
|
-
quote
|
|
1660
|
-
} = await this.service.feeOptions({
|
|
1661
|
-
wallet: address,
|
|
1662
|
-
to: address,
|
|
1663
|
-
data: core.commons.transaction.encodeBundleExecData({
|
|
1664
|
-
entrypoint: address,
|
|
1665
|
-
transactions,
|
|
1666
|
-
nonce
|
|
1667
|
-
})
|
|
1668
|
-
});
|
|
1669
|
-
utils.logger.info(`[rpc-relayer/getFeeOptions] got refund options ${JSON.stringify(options, utils.bigintReplacer)}`);
|
|
1670
|
-
return {
|
|
1671
|
-
options,
|
|
1672
|
-
quote: {
|
|
1673
|
-
_tag: 'FeeQuote',
|
|
1674
|
-
_quote: quote
|
|
1675
|
-
}
|
|
1676
|
-
};
|
|
1677
|
-
} else {
|
|
1678
|
-
utils.logger.info(`[rpc-relayer/getFeeOptions] relayer fees are not required`);
|
|
1679
|
-
return {
|
|
1680
|
-
options: []
|
|
1681
|
-
};
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
async getFeeOptionsRaw(entrypoint, data, options) {
|
|
1685
|
-
const {
|
|
1686
|
-
options: feeOptions,
|
|
1687
|
-
quote
|
|
1688
|
-
} = await this.service.feeOptions({
|
|
1689
|
-
wallet: entrypoint,
|
|
1690
|
-
to: entrypoint,
|
|
1691
|
-
data: ethers.ethers.hexlify(data),
|
|
1692
|
-
simulate: options == null ? void 0 : options.simulate
|
|
1693
|
-
}, _extends({}, options != null && options.projectAccessKey ? {
|
|
1694
|
-
'X-Access-Key': options.projectAccessKey
|
|
1695
|
-
} : undefined));
|
|
1696
|
-
return {
|
|
1697
|
-
options: feeOptions,
|
|
1698
|
-
quote: {
|
|
1699
|
-
_tag: 'FeeQuote',
|
|
1700
|
-
_quote: quote
|
|
1701
|
-
}
|
|
1702
|
-
};
|
|
1703
|
-
}
|
|
1704
|
-
async gasRefundOptions(address, ...transactions) {
|
|
1705
|
-
const {
|
|
1706
|
-
options
|
|
1707
|
-
} = await this.getFeeOptions(address, ...transactions);
|
|
1708
|
-
return options;
|
|
1709
|
-
}
|
|
1710
|
-
async getNonce(address, space) {
|
|
1711
|
-
utils.logger.info(`[rpc-relayer/getNonce] get nonce for wallet ${address} space: ${space}`);
|
|
1712
|
-
const encodedNonce = space !== undefined ? utils.toHexString(BigInt(space)) : undefined;
|
|
1713
|
-
const resp = await this.service.getMetaTxnNonce({
|
|
1714
|
-
walletContractAddress: address,
|
|
1715
|
-
space: encodedNonce
|
|
1716
|
-
});
|
|
1717
|
-
const nonce = BigInt(resp.nonce);
|
|
1718
|
-
const [decodedSpace, decodedNonce] = core.commons.transaction.decodeNonce(nonce);
|
|
1719
|
-
utils.logger.info(`[rpc-relayer/getNonce] got next nonce for wallet ${address} ${decodedNonce} space: ${decodedSpace}`);
|
|
1720
|
-
return nonce;
|
|
1721
|
-
}
|
|
1722
|
-
async relay(signedTxs, quote, waitForReceipt = true, projectAccessKey) {
|
|
1723
|
-
var _this = this;
|
|
1724
|
-
utils.logger.info(`[rpc-relayer/relay] relaying signed meta-transactions ${JSON.stringify(signedTxs, utils.bigintReplacer)} with quote ${JSON.stringify(quote, utils.bigintReplacer)}`);
|
|
1725
|
-
let typecheckedQuote;
|
|
1726
|
-
if (quote !== undefined) {
|
|
1727
|
-
if (typeof quote._quote === 'string') {
|
|
1728
|
-
typecheckedQuote = quote._quote;
|
|
1729
|
-
} else {
|
|
1730
|
-
utils.logger.warn('[rpc-relayer/relay] ignoring invalid fee quote');
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
if (!this.provider) {
|
|
1734
|
-
utils.logger.warn(`[rpc-relayer/relay] provider not set, failed relay`);
|
|
1735
|
-
throw new Error('provider is not set');
|
|
1736
|
-
}
|
|
1737
|
-
const data = core.commons.transaction.encodeBundleExecData(signedTxs);
|
|
1738
|
-
const metaTxn = await this.service.sendMetaTxn({
|
|
1739
|
-
call: {
|
|
1740
|
-
walletAddress: signedTxs.intent.wallet,
|
|
1741
|
-
contract: signedTxs.entrypoint,
|
|
1742
|
-
input: data
|
|
1743
|
-
},
|
|
1744
|
-
quote: typecheckedQuote
|
|
1745
|
-
}, _extends({}, projectAccessKey ? {
|
|
1746
|
-
'X-Access-Key': projectAccessKey
|
|
1747
|
-
} : undefined));
|
|
1748
|
-
utils.logger.info(`[rpc-relayer/relay] got relay result ${JSON.stringify(metaTxn, utils.bigintReplacer)}`);
|
|
1749
|
-
if (waitForReceipt) {
|
|
1750
|
-
return this.wait(signedTxs.intent.id);
|
|
1751
|
-
} else {
|
|
1752
|
-
const response = {
|
|
1753
|
-
hash: signedTxs.intent.id,
|
|
1754
|
-
confirmations: 0,
|
|
1755
|
-
from: signedTxs.intent.wallet,
|
|
1756
|
-
wait: _confirmations => Promise.reject(new Error('impossible'))
|
|
1757
|
-
};
|
|
1758
|
-
const wait = async function wait(confirmations) {
|
|
1759
|
-
var _waitResponse$receipt;
|
|
1760
|
-
if (!_this.provider) {
|
|
1761
|
-
throw new Error('cannot wait for receipt, relayer has no provider set');
|
|
1762
|
-
}
|
|
1763
|
-
const waitResponse = await _this.wait(signedTxs.intent.id);
|
|
1764
|
-
const transactionHash = (_waitResponse$receipt = waitResponse.receipt) == null ? void 0 : _waitResponse$receipt.transactionHash;
|
|
1765
|
-
if (!transactionHash) {
|
|
1766
|
-
throw new Error('cannot wait for receipt, unknown native transaction hash');
|
|
1767
|
-
}
|
|
1768
|
-
Object.assign(response, waitResponse);
|
|
1769
|
-
return _this.provider.waitForTransaction(transactionHash, confirmations);
|
|
1770
|
-
};
|
|
1771
|
-
response.wait = wait;
|
|
1772
|
-
|
|
1773
|
-
// NOTE: we just ignore these errors which come from the private fields
|
|
1774
|
-
// of ethers-v6 .. but, we should probably rework this instead..
|
|
1775
|
-
// @ts-ignore
|
|
1776
|
-
return response;
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
async wait(metaTxnId, timeout, delay = 1000, maxFails = 5) {
|
|
1780
|
-
var _this2 = this;
|
|
1781
|
-
let timedOut = false;
|
|
1782
|
-
const {
|
|
1783
|
-
receipt
|
|
1784
|
-
} = await (timeout !== undefined ? Promise.race([this.waitReceipt(metaTxnId, delay, maxFails, () => timedOut), new Promise((_, reject) => setTimeout(() => {
|
|
1785
|
-
timedOut = true;
|
|
1786
|
-
reject(`Timeout waiting for transaction receipt ${metaTxnId}`);
|
|
1787
|
-
}, timeout))]) : this.waitReceipt(metaTxnId, delay, maxFails));
|
|
1788
|
-
if (!receipt.txnReceipt || FAILED_STATUSES.includes(receipt.status)) {
|
|
1789
|
-
throw new MetaTransactionResponseException(receipt);
|
|
1790
|
-
}
|
|
1791
|
-
const txReceipt = JSON.parse(receipt.txnReceipt);
|
|
1792
|
-
|
|
1793
|
-
// NOTE: we just ignore these errors which come from the private fields
|
|
1794
|
-
// of ethers-v6 .. but, we should probably rework this instead..
|
|
1795
|
-
// @ts-ignore
|
|
1796
|
-
return {
|
|
1797
|
-
blockHash: txReceipt.blockHash,
|
|
1798
|
-
blockNumber: Number(txReceipt.blockNumber),
|
|
1799
|
-
confirmations: 1,
|
|
1800
|
-
from: typeof metaTxnId === 'string' ? undefined : metaTxnId.intent.wallet,
|
|
1801
|
-
hash: txReceipt.transactionHash,
|
|
1802
|
-
raw: receipt.txnReceipt,
|
|
1803
|
-
receipt: txReceipt,
|
|
1804
|
-
// extended type which is Sequence-specific. Contains the decoded metaTxReceipt
|
|
1805
|
-
wait: async function (confirmations) {
|
|
1806
|
-
return _this2.provider.waitForTransaction(txReceipt.transactionHash, confirmations);
|
|
1807
|
-
}
|
|
1808
|
-
};
|
|
1809
|
-
}
|
|
1810
|
-
async getMetaTransactions(projectId, page) {
|
|
1811
|
-
return this.service.getMetaTransactions({
|
|
1812
|
-
projectId,
|
|
1813
|
-
page
|
|
1814
|
-
});
|
|
1815
|
-
}
|
|
1816
|
-
async getTransactionCost(projectId, from, to) {
|
|
1817
|
-
return this.service.getTransactionCost({
|
|
1818
|
-
projectId,
|
|
1819
|
-
from,
|
|
1820
|
-
to
|
|
1821
|
-
});
|
|
1822
|
-
}
|
|
1823
|
-
async listGasSponsors(args) {
|
|
1824
|
-
return this.service.listGasSponsors(args);
|
|
1825
|
-
}
|
|
1826
|
-
async addGasSponsor(args) {
|
|
1827
|
-
return this.service.addGasSponsor(args);
|
|
1828
|
-
}
|
|
1829
|
-
async updateGasSponsor(args) {
|
|
1830
|
-
return this.service.updateGasSponsor(args);
|
|
1831
|
-
}
|
|
1832
|
-
async removeGasSponsor(args) {
|
|
1833
|
-
return this.service.removeGasSponsor(args);
|
|
1834
|
-
}
|
|
1835
|
-
}
|
|
1836
|
-
class MetaTransactionResponseException {
|
|
1837
|
-
constructor(receipt) {
|
|
1838
|
-
this.receipt = receipt;
|
|
1839
|
-
}
|
|
1840
|
-
}
|
|
1841
|
-
function isAbstractProvider(provider) {
|
|
1842
|
-
return provider && typeof provider === 'object' && typeof provider.getNetwork === 'function' && typeof provider.getBlockNumber === 'function';
|
|
1843
|
-
}
|
|
1844
|
-
|
|
1845
|
-
// A fee quote is simply an opaque value that can be obtained via Relayer.getFeeOptions(), and
|
|
1846
|
-
// returned back to the same relayer via Relayer.relay(). Fee quotes should be treated as an
|
|
1847
|
-
// implementation detail of the relayer that produces them.
|
|
1848
|
-
//
|
|
1849
|
-
// This interface exists for type-safety purposes to protect against passing non-FeeQuotes to
|
|
1850
|
-
// Relayer.relay(), or any other functions that call it indirectly (e.g. Account.sendTransaction).
|
|
1851
|
-
|
|
1852
|
-
function isRelayer(cand) {
|
|
1853
|
-
return typeof cand === 'object' && typeof cand.simulate === 'function' && typeof cand.getFeeOptions === 'function' && typeof cand.gasRefundOptions === 'function' && typeof cand.getNonce === 'function' && typeof cand.relay === 'function' && typeof cand.wait === 'function';
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
|
-
exports.LocalRelayer = LocalRelayer;
|
|
1857
|
-
exports.ProviderRelayer = ProviderRelayer;
|
|
1858
|
-
exports.ProviderRelayerDefaults = ProviderRelayerDefaults;
|
|
1859
|
-
exports.RpcRelayer = RpcRelayer;
|
|
1860
|
-
exports.RpcRelayerProto = relayer_gen;
|
|
1861
|
-
exports.isLocalRelayerOptions = isLocalRelayerOptions;
|
|
1862
|
-
exports.isProviderRelayerOptions = isProviderRelayerOptions;
|
|
1863
|
-
exports.isRelayer = isRelayer;
|
|
1864
|
-
exports.isRpcRelayerOptions = isRpcRelayerOptions;
|
|
1865
|
-
exports.proto = relayer_gen;
|