@0xsequence/relayer 2.3.38 → 2.3.39
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/dist/0xsequence-relayer.cjs.dev.js +607 -368
- package/dist/0xsequence-relayer.cjs.prod.js +607 -368
- package/dist/0xsequence-relayer.esm.js +607 -368
- package/dist/declarations/src/rpc-relayer/relayer.gen.d.ts +217 -178
- package/package.json +6 -6
- package/src/rpc-relayer/relayer.gen.ts +1163 -1020
|
@@ -283,61 +283,27 @@ function isAbstractSigner(signer) {
|
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
/* eslint-disable */
|
|
286
|
-
// sequence-relayer v0.4.1
|
|
286
|
+
// sequence-relayer v0.4.1 7f8a4b83b00e0b6849c76c2ff0e23931e26b3d9f
|
|
287
287
|
// --
|
|
288
|
-
// Code generated by
|
|
288
|
+
// Code generated by Webrpc-gen@v0.31.2 with typescript generator. DO NOT EDIT.
|
|
289
289
|
//
|
|
290
|
-
// webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts
|
|
290
|
+
// webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts -compat
|
|
291
291
|
|
|
292
|
-
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
// WebRPC description and code-gen version
|
|
296
|
-
const WebRPCVersion = "v1";
|
|
292
|
+
// Webrpc description and code-gen version
|
|
293
|
+
const WebrpcVersion = 'v1';
|
|
297
294
|
|
|
298
295
|
// Schema version of your RIDL schema
|
|
299
|
-
const
|
|
296
|
+
const WebrpcSchemaVersion = 'v0.4.1';
|
|
300
297
|
|
|
301
298
|
// Schema hash generated from your RIDL schema
|
|
302
|
-
const
|
|
303
|
-
function VersionFromHeader(headers) {
|
|
304
|
-
const headerValue = headers.get(WebrpcHeader);
|
|
305
|
-
if (!headerValue) {
|
|
306
|
-
return {
|
|
307
|
-
webrpcGenVersion: "",
|
|
308
|
-
codeGenName: "",
|
|
309
|
-
codeGenVersion: "",
|
|
310
|
-
schemaName: "",
|
|
311
|
-
schemaVersion: ""
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
return parseWebrpcGenVersions(headerValue);
|
|
315
|
-
}
|
|
316
|
-
function parseWebrpcGenVersions(header) {
|
|
317
|
-
const versions = header.split(";");
|
|
318
|
-
if (versions.length < 3) {
|
|
319
|
-
return {
|
|
320
|
-
webrpcGenVersion: "",
|
|
321
|
-
codeGenName: "",
|
|
322
|
-
codeGenVersion: "",
|
|
323
|
-
schemaName: "",
|
|
324
|
-
schemaVersion: ""
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
const [_, webrpcGenVersion] = versions[0].split("@");
|
|
328
|
-
const [codeGenName, codeGenVersion] = versions[1].split("@");
|
|
329
|
-
const [schemaName, schemaVersion] = versions[2].split("@");
|
|
330
|
-
return {
|
|
331
|
-
webrpcGenVersion: webrpcGenVersion != null ? webrpcGenVersion : "",
|
|
332
|
-
codeGenName: codeGenName != null ? codeGenName : "",
|
|
333
|
-
codeGenVersion: codeGenVersion != null ? codeGenVersion : "",
|
|
334
|
-
schemaName: schemaName != null ? schemaName : "",
|
|
335
|
-
schemaVersion: schemaVersion != null ? schemaVersion : ""
|
|
336
|
-
};
|
|
337
|
-
}
|
|
299
|
+
const WebrpcSchemaHash = '7f8a4b83b00e0b6849c76c2ff0e23931e26b3d9f';
|
|
338
300
|
|
|
339
301
|
//
|
|
340
|
-
//
|
|
302
|
+
// Client interface
|
|
303
|
+
//
|
|
304
|
+
|
|
305
|
+
//
|
|
306
|
+
// Schema types
|
|
341
307
|
//
|
|
342
308
|
|
|
343
309
|
let ETHTxnStatus = /*#__PURE__*/function (ETHTxnStatus) {
|
|
@@ -383,452 +349,407 @@ let SortOrder = /*#__PURE__*/function (SortOrder) {
|
|
|
383
349
|
//
|
|
384
350
|
// Client
|
|
385
351
|
//
|
|
352
|
+
|
|
386
353
|
class Relayer {
|
|
387
354
|
constructor(hostname, fetch) {
|
|
388
355
|
this.hostname = void 0;
|
|
389
356
|
this.fetch = void 0;
|
|
390
357
|
this.path = '/rpc/Relayer/';
|
|
358
|
+
this.queryKey = {
|
|
359
|
+
ping: () => ['Relayer', 'ping'],
|
|
360
|
+
version: () => ['Relayer', 'version'],
|
|
361
|
+
runtimeStatus: () => ['Relayer', 'runtimeStatus'],
|
|
362
|
+
getSequenceContext: () => ['Relayer', 'getSequenceContext'],
|
|
363
|
+
getChainID: () => ['Relayer', 'getChainID'],
|
|
364
|
+
sendMetaTxn: req => ['Relayer', 'sendMetaTxn', req],
|
|
365
|
+
getMetaTxnNonce: req => ['Relayer', 'getMetaTxnNonce', req],
|
|
366
|
+
getMetaTxnReceipt: req => ['Relayer', 'getMetaTxnReceipt', req],
|
|
367
|
+
simulate: req => ['Relayer', 'simulate', req],
|
|
368
|
+
simulateV3: req => ['Relayer', 'simulateV3', req],
|
|
369
|
+
updateMetaTxnGasLimits: req => ['Relayer', 'updateMetaTxnGasLimits', req],
|
|
370
|
+
feeTokens: () => ['Relayer', 'feeTokens'],
|
|
371
|
+
feeOptions: req => ['Relayer', 'feeOptions', req],
|
|
372
|
+
getMetaTxnNetworkFeeOptions: req => ['Relayer', 'getMetaTxnNetworkFeeOptions', req],
|
|
373
|
+
getMetaTransactions: req => ['Relayer', 'getMetaTransactions', req],
|
|
374
|
+
getTransactionCost: req => ['Relayer', 'getTransactionCost', req],
|
|
375
|
+
sentTransactions: req => ['Relayer', 'sentTransactions', req],
|
|
376
|
+
pendingTransactions: req => ['Relayer', 'pendingTransactions', req],
|
|
377
|
+
getGasTank: req => ['Relayer', 'getGasTank', req],
|
|
378
|
+
addGasTank: req => ['Relayer', 'addGasTank', req],
|
|
379
|
+
updateGasTank: req => ['Relayer', 'updateGasTank', req],
|
|
380
|
+
nextGasTankBalanceAdjustmentNonce: req => ['Relayer', 'nextGasTankBalanceAdjustmentNonce', req],
|
|
381
|
+
adjustGasTankBalance: req => ['Relayer', 'adjustGasTankBalance', req],
|
|
382
|
+
getGasTankBalanceAdjustment: req => ['Relayer', 'getGasTankBalanceAdjustment', req],
|
|
383
|
+
listGasTankBalanceAdjustments: req => ['Relayer', 'listGasTankBalanceAdjustments', req],
|
|
384
|
+
listGasSponsors: req => ['Relayer', 'listGasSponsors', req],
|
|
385
|
+
getGasSponsor: req => ['Relayer', 'getGasSponsor', req],
|
|
386
|
+
addGasSponsor: req => ['Relayer', 'addGasSponsor', req],
|
|
387
|
+
updateGasSponsor: req => ['Relayer', 'updateGasSponsor', req],
|
|
388
|
+
removeGasSponsor: req => ['Relayer', 'removeGasSponsor', req],
|
|
389
|
+
addressGasSponsors: req => ['Relayer', 'addressGasSponsors', req],
|
|
390
|
+
getProjectBalance: req => ['Relayer', 'getProjectBalance', req],
|
|
391
|
+
adjustProjectBalance: req => ['Relayer', 'adjustProjectBalance', req]
|
|
392
|
+
};
|
|
391
393
|
this.ping = (headers, signal) => {
|
|
392
|
-
return this.fetch(this.url('Ping'),
|
|
394
|
+
return this.fetch(this.url('Ping'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
393
395
|
return buildResponse(res).then(_data => {
|
|
394
|
-
return
|
|
395
|
-
status: _data.status
|
|
396
|
-
};
|
|
396
|
+
return JsonDecode(_data, 'PingReturn');
|
|
397
397
|
});
|
|
398
398
|
}, error => {
|
|
399
399
|
throw WebrpcRequestFailedError.new({
|
|
400
|
-
cause: `fetch(): ${error.message
|
|
400
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
401
401
|
});
|
|
402
402
|
});
|
|
403
403
|
};
|
|
404
404
|
this.version = (headers, signal) => {
|
|
405
|
-
return this.fetch(this.url('Version'),
|
|
405
|
+
return this.fetch(this.url('Version'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
406
406
|
return buildResponse(res).then(_data => {
|
|
407
|
-
return
|
|
408
|
-
version: _data.version
|
|
409
|
-
};
|
|
407
|
+
return JsonDecode(_data, 'VersionReturn');
|
|
410
408
|
});
|
|
411
409
|
}, error => {
|
|
412
410
|
throw WebrpcRequestFailedError.new({
|
|
413
|
-
cause: `fetch(): ${error.message
|
|
411
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
414
412
|
});
|
|
415
413
|
});
|
|
416
414
|
};
|
|
417
415
|
this.runtimeStatus = (headers, signal) => {
|
|
418
|
-
return this.fetch(this.url('RuntimeStatus'),
|
|
416
|
+
return this.fetch(this.url('RuntimeStatus'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
419
417
|
return buildResponse(res).then(_data => {
|
|
420
|
-
return
|
|
421
|
-
status: _data.status
|
|
422
|
-
};
|
|
418
|
+
return JsonDecode(_data, 'RuntimeStatusReturn');
|
|
423
419
|
});
|
|
424
420
|
}, error => {
|
|
425
421
|
throw WebrpcRequestFailedError.new({
|
|
426
|
-
cause: `fetch(): ${error.message
|
|
422
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
427
423
|
});
|
|
428
424
|
});
|
|
429
425
|
};
|
|
430
426
|
this.getSequenceContext = (headers, signal) => {
|
|
431
|
-
return this.fetch(this.url('GetSequenceContext'),
|
|
427
|
+
return this.fetch(this.url('GetSequenceContext'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
432
428
|
return buildResponse(res).then(_data => {
|
|
433
|
-
return
|
|
434
|
-
data: _data.data
|
|
435
|
-
};
|
|
429
|
+
return JsonDecode(_data, 'GetSequenceContextReturn');
|
|
436
430
|
});
|
|
437
431
|
}, error => {
|
|
438
432
|
throw WebrpcRequestFailedError.new({
|
|
439
|
-
cause: `fetch(): ${error.message
|
|
433
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
440
434
|
});
|
|
441
435
|
});
|
|
442
436
|
};
|
|
443
437
|
this.getChainID = (headers, signal) => {
|
|
444
|
-
return this.fetch(this.url('GetChainID'),
|
|
438
|
+
return this.fetch(this.url('GetChainID'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
445
439
|
return buildResponse(res).then(_data => {
|
|
446
|
-
return
|
|
447
|
-
chainID: _data.chainID
|
|
448
|
-
};
|
|
440
|
+
return JsonDecode(_data, 'GetChainIDReturn');
|
|
449
441
|
});
|
|
450
442
|
}, error => {
|
|
451
443
|
throw WebrpcRequestFailedError.new({
|
|
452
|
-
cause: `fetch(): ${error.message
|
|
444
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
453
445
|
});
|
|
454
446
|
});
|
|
455
447
|
};
|
|
456
|
-
this.sendMetaTxn = (
|
|
457
|
-
return this.fetch(this.url('SendMetaTxn'),
|
|
448
|
+
this.sendMetaTxn = (req, headers, signal) => {
|
|
449
|
+
return this.fetch(this.url('SendMetaTxn'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
458
450
|
return buildResponse(res).then(_data => {
|
|
459
|
-
return
|
|
460
|
-
status: _data.status,
|
|
461
|
-
txnHash: _data.txnHash
|
|
462
|
-
};
|
|
451
|
+
return JsonDecode(_data, 'SendMetaTxnReturn');
|
|
463
452
|
});
|
|
464
453
|
}, error => {
|
|
465
454
|
throw WebrpcRequestFailedError.new({
|
|
466
|
-
cause: `fetch(): ${error.message
|
|
455
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
467
456
|
});
|
|
468
457
|
});
|
|
469
458
|
};
|
|
470
|
-
this.getMetaTxnNonce = (
|
|
471
|
-
return this.fetch(this.url('GetMetaTxnNonce'),
|
|
459
|
+
this.getMetaTxnNonce = (req, headers, signal) => {
|
|
460
|
+
return this.fetch(this.url('GetMetaTxnNonce'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
472
461
|
return buildResponse(res).then(_data => {
|
|
473
|
-
return
|
|
474
|
-
nonce: _data.nonce
|
|
475
|
-
};
|
|
462
|
+
return JsonDecode(_data, 'GetMetaTxnNonceReturn');
|
|
476
463
|
});
|
|
477
464
|
}, error => {
|
|
478
465
|
throw WebrpcRequestFailedError.new({
|
|
479
|
-
cause: `fetch(): ${error.message
|
|
466
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
480
467
|
});
|
|
481
468
|
});
|
|
482
469
|
};
|
|
483
|
-
this.getMetaTxnReceipt = (
|
|
484
|
-
return this.fetch(this.url('GetMetaTxnReceipt'),
|
|
470
|
+
this.getMetaTxnReceipt = (req, headers, signal) => {
|
|
471
|
+
return this.fetch(this.url('GetMetaTxnReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
485
472
|
return buildResponse(res).then(_data => {
|
|
486
|
-
return
|
|
487
|
-
receipt: _data.receipt
|
|
488
|
-
};
|
|
473
|
+
return JsonDecode(_data, 'GetMetaTxnReceiptReturn');
|
|
489
474
|
});
|
|
490
475
|
}, error => {
|
|
491
476
|
throw WebrpcRequestFailedError.new({
|
|
492
|
-
cause: `fetch(): ${error.message
|
|
477
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
493
478
|
});
|
|
494
479
|
});
|
|
495
480
|
};
|
|
496
|
-
this.simulate = (
|
|
497
|
-
return this.fetch(this.url('Simulate'),
|
|
481
|
+
this.simulate = (req, headers, signal) => {
|
|
482
|
+
return this.fetch(this.url('Simulate'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
498
483
|
return buildResponse(res).then(_data => {
|
|
499
|
-
return
|
|
500
|
-
results: _data.results
|
|
501
|
-
};
|
|
484
|
+
return JsonDecode(_data, 'SimulateReturn');
|
|
502
485
|
});
|
|
503
486
|
}, error => {
|
|
504
487
|
throw WebrpcRequestFailedError.new({
|
|
505
|
-
cause: `fetch(): ${error.message
|
|
488
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
506
489
|
});
|
|
507
490
|
});
|
|
508
491
|
};
|
|
509
|
-
this.simulateV3 = (
|
|
510
|
-
return this.fetch(this.url('SimulateV3'),
|
|
492
|
+
this.simulateV3 = (req, headers, signal) => {
|
|
493
|
+
return this.fetch(this.url('SimulateV3'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
511
494
|
return buildResponse(res).then(_data => {
|
|
512
|
-
return
|
|
513
|
-
results: _data.results
|
|
514
|
-
};
|
|
495
|
+
return JsonDecode(_data, 'SimulateV3Return');
|
|
515
496
|
});
|
|
516
497
|
}, error => {
|
|
517
498
|
throw WebrpcRequestFailedError.new({
|
|
518
|
-
cause: `fetch(): ${error.message
|
|
499
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
519
500
|
});
|
|
520
501
|
});
|
|
521
502
|
};
|
|
522
|
-
this.updateMetaTxnGasLimits = (
|
|
523
|
-
return this.fetch(this.url('UpdateMetaTxnGasLimits'),
|
|
503
|
+
this.updateMetaTxnGasLimits = (req, headers, signal) => {
|
|
504
|
+
return this.fetch(this.url('UpdateMetaTxnGasLimits'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
524
505
|
return buildResponse(res).then(_data => {
|
|
525
|
-
return
|
|
526
|
-
payload: _data.payload
|
|
527
|
-
};
|
|
506
|
+
return JsonDecode(_data, 'UpdateMetaTxnGasLimitsReturn');
|
|
528
507
|
});
|
|
529
508
|
}, error => {
|
|
530
509
|
throw WebrpcRequestFailedError.new({
|
|
531
|
-
cause: `fetch(): ${error.message
|
|
510
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
532
511
|
});
|
|
533
512
|
});
|
|
534
513
|
};
|
|
535
514
|
this.feeTokens = (headers, signal) => {
|
|
536
|
-
return this.fetch(this.url('FeeTokens'),
|
|
515
|
+
return this.fetch(this.url('FeeTokens'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
537
516
|
return buildResponse(res).then(_data => {
|
|
538
|
-
return
|
|
539
|
-
isFeeRequired: _data.isFeeRequired,
|
|
540
|
-
tokens: _data.tokens
|
|
541
|
-
};
|
|
517
|
+
return JsonDecode(_data, 'FeeTokensReturn');
|
|
542
518
|
});
|
|
543
519
|
}, error => {
|
|
544
520
|
throw WebrpcRequestFailedError.new({
|
|
545
|
-
cause: `fetch(): ${error.message
|
|
521
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
546
522
|
});
|
|
547
523
|
});
|
|
548
524
|
};
|
|
549
|
-
this.feeOptions = (
|
|
550
|
-
return this.fetch(this.url('FeeOptions'),
|
|
525
|
+
this.feeOptions = (req, headers, signal) => {
|
|
526
|
+
return this.fetch(this.url('FeeOptions'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
551
527
|
return buildResponse(res).then(_data => {
|
|
552
|
-
return
|
|
553
|
-
options: _data.options,
|
|
554
|
-
sponsored: _data.sponsored,
|
|
555
|
-
quote: _data.quote
|
|
556
|
-
};
|
|
528
|
+
return JsonDecode(_data, 'FeeOptionsReturn');
|
|
557
529
|
});
|
|
558
530
|
}, error => {
|
|
559
531
|
throw WebrpcRequestFailedError.new({
|
|
560
|
-
cause: `fetch(): ${error.message
|
|
532
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
561
533
|
});
|
|
562
534
|
});
|
|
563
535
|
};
|
|
564
|
-
this.getMetaTxnNetworkFeeOptions = (
|
|
565
|
-
return this.fetch(this.url('GetMetaTxnNetworkFeeOptions'),
|
|
536
|
+
this.getMetaTxnNetworkFeeOptions = (req, headers, signal) => {
|
|
537
|
+
return this.fetch(this.url('GetMetaTxnNetworkFeeOptions'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
566
538
|
return buildResponse(res).then(_data => {
|
|
567
|
-
return
|
|
568
|
-
options: _data.options
|
|
569
|
-
};
|
|
539
|
+
return JsonDecode(_data, 'GetMetaTxnNetworkFeeOptionsReturn');
|
|
570
540
|
});
|
|
571
541
|
}, error => {
|
|
572
542
|
throw WebrpcRequestFailedError.new({
|
|
573
|
-
cause: `fetch(): ${error.message
|
|
543
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
574
544
|
});
|
|
575
545
|
});
|
|
576
546
|
};
|
|
577
|
-
this.getMetaTransactions = (
|
|
578
|
-
return this.fetch(this.url('GetMetaTransactions'),
|
|
547
|
+
this.getMetaTransactions = (req, headers, signal) => {
|
|
548
|
+
return this.fetch(this.url('GetMetaTransactions'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
579
549
|
return buildResponse(res).then(_data => {
|
|
580
|
-
return
|
|
581
|
-
page: _data.page,
|
|
582
|
-
transactions: _data.transactions
|
|
583
|
-
};
|
|
550
|
+
return JsonDecode(_data, 'GetMetaTransactionsReturn');
|
|
584
551
|
});
|
|
585
552
|
}, error => {
|
|
586
553
|
throw WebrpcRequestFailedError.new({
|
|
587
|
-
cause: `fetch(): ${error.message
|
|
554
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
588
555
|
});
|
|
589
556
|
});
|
|
590
557
|
};
|
|
591
|
-
this.getTransactionCost = (
|
|
592
|
-
return this.fetch(this.url('GetTransactionCost'),
|
|
558
|
+
this.getTransactionCost = (req, headers, signal) => {
|
|
559
|
+
return this.fetch(this.url('GetTransactionCost'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
593
560
|
return buildResponse(res).then(_data => {
|
|
594
|
-
return
|
|
595
|
-
cost: _data.cost
|
|
596
|
-
};
|
|
561
|
+
return JsonDecode(_data, 'GetTransactionCostReturn');
|
|
597
562
|
});
|
|
598
563
|
}, error => {
|
|
599
564
|
throw WebrpcRequestFailedError.new({
|
|
600
|
-
cause: `fetch(): ${error.message
|
|
565
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
601
566
|
});
|
|
602
567
|
});
|
|
603
568
|
};
|
|
604
|
-
this.sentTransactions = (
|
|
605
|
-
return this.fetch(this.url('SentTransactions'),
|
|
569
|
+
this.sentTransactions = (req, headers, signal) => {
|
|
570
|
+
return this.fetch(this.url('SentTransactions'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
606
571
|
return buildResponse(res).then(_data => {
|
|
607
|
-
return
|
|
608
|
-
page: _data.page,
|
|
609
|
-
transactions: _data.transactions
|
|
610
|
-
};
|
|
572
|
+
return JsonDecode(_data, 'SentTransactionsReturn');
|
|
611
573
|
});
|
|
612
574
|
}, error => {
|
|
613
575
|
throw WebrpcRequestFailedError.new({
|
|
614
|
-
cause: `fetch(): ${error.message
|
|
576
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
615
577
|
});
|
|
616
578
|
});
|
|
617
579
|
};
|
|
618
|
-
this.pendingTransactions = (
|
|
619
|
-
return this.fetch(this.url('PendingTransactions'),
|
|
580
|
+
this.pendingTransactions = (req, headers, signal) => {
|
|
581
|
+
return this.fetch(this.url('PendingTransactions'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
620
582
|
return buildResponse(res).then(_data => {
|
|
621
|
-
return
|
|
622
|
-
page: _data.page,
|
|
623
|
-
transactions: _data.transactions
|
|
624
|
-
};
|
|
583
|
+
return JsonDecode(_data, 'PendingTransactionsReturn');
|
|
625
584
|
});
|
|
626
585
|
}, error => {
|
|
627
586
|
throw WebrpcRequestFailedError.new({
|
|
628
|
-
cause: `fetch(): ${error.message
|
|
587
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
629
588
|
});
|
|
630
589
|
});
|
|
631
590
|
};
|
|
632
|
-
this.getGasTank = (
|
|
633
|
-
return this.fetch(this.url('GetGasTank'),
|
|
591
|
+
this.getGasTank = (req, headers, signal) => {
|
|
592
|
+
return this.fetch(this.url('GetGasTank'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
634
593
|
return buildResponse(res).then(_data => {
|
|
635
|
-
return
|
|
636
|
-
gasTank: _data.gasTank
|
|
637
|
-
};
|
|
594
|
+
return JsonDecode(_data, 'GetGasTankReturn');
|
|
638
595
|
});
|
|
639
596
|
}, error => {
|
|
640
597
|
throw WebrpcRequestFailedError.new({
|
|
641
|
-
cause: `fetch(): ${error.message
|
|
598
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
642
599
|
});
|
|
643
600
|
});
|
|
644
601
|
};
|
|
645
|
-
this.addGasTank = (
|
|
646
|
-
return this.fetch(this.url('AddGasTank'),
|
|
602
|
+
this.addGasTank = (req, headers, signal) => {
|
|
603
|
+
return this.fetch(this.url('AddGasTank'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
647
604
|
return buildResponse(res).then(_data => {
|
|
648
|
-
return
|
|
649
|
-
status: _data.status,
|
|
650
|
-
gasTank: _data.gasTank
|
|
651
|
-
};
|
|
605
|
+
return JsonDecode(_data, 'AddGasTankReturn');
|
|
652
606
|
});
|
|
653
607
|
}, error => {
|
|
654
608
|
throw WebrpcRequestFailedError.new({
|
|
655
|
-
cause: `fetch(): ${error.message
|
|
609
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
656
610
|
});
|
|
657
611
|
});
|
|
658
612
|
};
|
|
659
|
-
this.updateGasTank = (
|
|
660
|
-
return this.fetch(this.url('UpdateGasTank'),
|
|
613
|
+
this.updateGasTank = (req, headers, signal) => {
|
|
614
|
+
return this.fetch(this.url('UpdateGasTank'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
661
615
|
return buildResponse(res).then(_data => {
|
|
662
|
-
return
|
|
663
|
-
status: _data.status,
|
|
664
|
-
gasTank: _data.gasTank
|
|
665
|
-
};
|
|
616
|
+
return JsonDecode(_data, 'UpdateGasTankReturn');
|
|
666
617
|
});
|
|
667
618
|
}, error => {
|
|
668
619
|
throw WebrpcRequestFailedError.new({
|
|
669
|
-
cause: `fetch(): ${error.message
|
|
620
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
670
621
|
});
|
|
671
622
|
});
|
|
672
623
|
};
|
|
673
|
-
this.nextGasTankBalanceAdjustmentNonce = (
|
|
674
|
-
return this.fetch(this.url('NextGasTankBalanceAdjustmentNonce'),
|
|
624
|
+
this.nextGasTankBalanceAdjustmentNonce = (req, headers, signal) => {
|
|
625
|
+
return this.fetch(this.url('NextGasTankBalanceAdjustmentNonce'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
675
626
|
return buildResponse(res).then(_data => {
|
|
676
|
-
return
|
|
677
|
-
nonce: _data.nonce
|
|
678
|
-
};
|
|
627
|
+
return JsonDecode(_data, 'NextGasTankBalanceAdjustmentNonceReturn');
|
|
679
628
|
});
|
|
680
629
|
}, error => {
|
|
681
630
|
throw WebrpcRequestFailedError.new({
|
|
682
|
-
cause: `fetch(): ${error.message
|
|
631
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
683
632
|
});
|
|
684
633
|
});
|
|
685
634
|
};
|
|
686
|
-
this.adjustGasTankBalance = (
|
|
687
|
-
return this.fetch(this.url('AdjustGasTankBalance'),
|
|
635
|
+
this.adjustGasTankBalance = (req, headers, signal) => {
|
|
636
|
+
return this.fetch(this.url('AdjustGasTankBalance'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
688
637
|
return buildResponse(res).then(_data => {
|
|
689
|
-
return
|
|
690
|
-
status: _data.status,
|
|
691
|
-
adjustment: _data.adjustment
|
|
692
|
-
};
|
|
638
|
+
return JsonDecode(_data, 'AdjustGasTankBalanceReturn');
|
|
693
639
|
});
|
|
694
640
|
}, error => {
|
|
695
641
|
throw WebrpcRequestFailedError.new({
|
|
696
|
-
cause: `fetch(): ${error.message
|
|
642
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
697
643
|
});
|
|
698
644
|
});
|
|
699
645
|
};
|
|
700
|
-
this.getGasTankBalanceAdjustment = (
|
|
701
|
-
return this.fetch(this.url('GetGasTankBalanceAdjustment'),
|
|
646
|
+
this.getGasTankBalanceAdjustment = (req, headers, signal) => {
|
|
647
|
+
return this.fetch(this.url('GetGasTankBalanceAdjustment'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
702
648
|
return buildResponse(res).then(_data => {
|
|
703
|
-
return
|
|
704
|
-
adjustment: _data.adjustment
|
|
705
|
-
};
|
|
649
|
+
return JsonDecode(_data, 'GetGasTankBalanceAdjustmentReturn');
|
|
706
650
|
});
|
|
707
651
|
}, error => {
|
|
708
652
|
throw WebrpcRequestFailedError.new({
|
|
709
|
-
cause: `fetch(): ${error.message
|
|
653
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
710
654
|
});
|
|
711
655
|
});
|
|
712
656
|
};
|
|
713
|
-
this.listGasTankBalanceAdjustments = (
|
|
714
|
-
return this.fetch(this.url('ListGasTankBalanceAdjustments'),
|
|
657
|
+
this.listGasTankBalanceAdjustments = (req, headers, signal) => {
|
|
658
|
+
return this.fetch(this.url('ListGasTankBalanceAdjustments'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
715
659
|
return buildResponse(res).then(_data => {
|
|
716
|
-
return
|
|
717
|
-
page: _data.page,
|
|
718
|
-
adjustments: _data.adjustments
|
|
719
|
-
};
|
|
660
|
+
return JsonDecode(_data, 'ListGasTankBalanceAdjustmentsReturn');
|
|
720
661
|
});
|
|
721
662
|
}, error => {
|
|
722
663
|
throw WebrpcRequestFailedError.new({
|
|
723
|
-
cause: `fetch(): ${error.message
|
|
664
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
724
665
|
});
|
|
725
666
|
});
|
|
726
667
|
};
|
|
727
|
-
this.listGasSponsors = (
|
|
728
|
-
return this.fetch(this.url('ListGasSponsors'),
|
|
668
|
+
this.listGasSponsors = (req, headers, signal) => {
|
|
669
|
+
return this.fetch(this.url('ListGasSponsors'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
729
670
|
return buildResponse(res).then(_data => {
|
|
730
|
-
return
|
|
731
|
-
page: _data.page,
|
|
732
|
-
gasSponsors: _data.gasSponsors
|
|
733
|
-
};
|
|
671
|
+
return JsonDecode(_data, 'ListGasSponsorsReturn');
|
|
734
672
|
});
|
|
735
673
|
}, error => {
|
|
736
674
|
throw WebrpcRequestFailedError.new({
|
|
737
|
-
cause: `fetch(): ${error.message
|
|
675
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
738
676
|
});
|
|
739
677
|
});
|
|
740
678
|
};
|
|
741
|
-
this.getGasSponsor = (
|
|
742
|
-
return this.fetch(this.url('GetGasSponsor'),
|
|
679
|
+
this.getGasSponsor = (req, headers, signal) => {
|
|
680
|
+
return this.fetch(this.url('GetGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
743
681
|
return buildResponse(res).then(_data => {
|
|
744
|
-
return
|
|
745
|
-
gasSponsor: _data.gasSponsor
|
|
746
|
-
};
|
|
682
|
+
return JsonDecode(_data, 'GetGasSponsorReturn');
|
|
747
683
|
});
|
|
748
684
|
}, error => {
|
|
749
685
|
throw WebrpcRequestFailedError.new({
|
|
750
|
-
cause: `fetch(): ${error.message
|
|
686
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
751
687
|
});
|
|
752
688
|
});
|
|
753
689
|
};
|
|
754
|
-
this.addGasSponsor = (
|
|
755
|
-
return this.fetch(this.url('AddGasSponsor'),
|
|
690
|
+
this.addGasSponsor = (req, headers, signal) => {
|
|
691
|
+
return this.fetch(this.url('AddGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
756
692
|
return buildResponse(res).then(_data => {
|
|
757
|
-
return
|
|
758
|
-
status: _data.status,
|
|
759
|
-
gasSponsor: _data.gasSponsor
|
|
760
|
-
};
|
|
693
|
+
return JsonDecode(_data, 'AddGasSponsorReturn');
|
|
761
694
|
});
|
|
762
695
|
}, error => {
|
|
763
696
|
throw WebrpcRequestFailedError.new({
|
|
764
|
-
cause: `fetch(): ${error.message
|
|
697
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
765
698
|
});
|
|
766
699
|
});
|
|
767
700
|
};
|
|
768
|
-
this.updateGasSponsor = (
|
|
769
|
-
return this.fetch(this.url('UpdateGasSponsor'),
|
|
701
|
+
this.updateGasSponsor = (req, headers, signal) => {
|
|
702
|
+
return this.fetch(this.url('UpdateGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
770
703
|
return buildResponse(res).then(_data => {
|
|
771
|
-
return
|
|
772
|
-
status: _data.status,
|
|
773
|
-
gasSponsor: _data.gasSponsor
|
|
774
|
-
};
|
|
704
|
+
return JsonDecode(_data, 'UpdateGasSponsorReturn');
|
|
775
705
|
});
|
|
776
706
|
}, error => {
|
|
777
707
|
throw WebrpcRequestFailedError.new({
|
|
778
|
-
cause: `fetch(): ${error.message
|
|
708
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
779
709
|
});
|
|
780
710
|
});
|
|
781
711
|
};
|
|
782
|
-
this.removeGasSponsor = (
|
|
783
|
-
return this.fetch(this.url('RemoveGasSponsor'),
|
|
712
|
+
this.removeGasSponsor = (req, headers, signal) => {
|
|
713
|
+
return this.fetch(this.url('RemoveGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
784
714
|
return buildResponse(res).then(_data => {
|
|
785
|
-
return
|
|
786
|
-
status: _data.status
|
|
787
|
-
};
|
|
715
|
+
return JsonDecode(_data, 'RemoveGasSponsorReturn');
|
|
788
716
|
});
|
|
789
717
|
}, error => {
|
|
790
718
|
throw WebrpcRequestFailedError.new({
|
|
791
|
-
cause: `fetch(): ${error.message
|
|
719
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
792
720
|
});
|
|
793
721
|
});
|
|
794
722
|
};
|
|
795
|
-
this.addressGasSponsors = (
|
|
796
|
-
return this.fetch(this.url('AddressGasSponsors'),
|
|
723
|
+
this.addressGasSponsors = (req, headers, signal) => {
|
|
724
|
+
return this.fetch(this.url('AddressGasSponsors'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
797
725
|
return buildResponse(res).then(_data => {
|
|
798
|
-
return
|
|
799
|
-
page: _data.page,
|
|
800
|
-
gasSponsors: _data.gasSponsors
|
|
801
|
-
};
|
|
726
|
+
return JsonDecode(_data, 'AddressGasSponsorsReturn');
|
|
802
727
|
});
|
|
803
728
|
}, error => {
|
|
804
729
|
throw WebrpcRequestFailedError.new({
|
|
805
|
-
cause: `fetch(): ${error.message
|
|
730
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
806
731
|
});
|
|
807
732
|
});
|
|
808
733
|
};
|
|
809
|
-
this.getProjectBalance = (
|
|
810
|
-
return this.fetch(this.url('GetProjectBalance'),
|
|
734
|
+
this.getProjectBalance = (req, headers, signal) => {
|
|
735
|
+
return this.fetch(this.url('GetProjectBalance'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
811
736
|
return buildResponse(res).then(_data => {
|
|
812
|
-
return
|
|
813
|
-
balance: _data.balance
|
|
814
|
-
};
|
|
737
|
+
return JsonDecode(_data, 'GetProjectBalanceReturn');
|
|
815
738
|
});
|
|
816
739
|
}, error => {
|
|
817
740
|
throw WebrpcRequestFailedError.new({
|
|
818
|
-
cause: `fetch(): ${error.message
|
|
741
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
819
742
|
});
|
|
820
743
|
});
|
|
821
744
|
};
|
|
822
|
-
this.adjustProjectBalance = (
|
|
823
|
-
return this.fetch(this.url('AdjustProjectBalance'),
|
|
745
|
+
this.adjustProjectBalance = (req, headers, signal) => {
|
|
746
|
+
return this.fetch(this.url('AdjustProjectBalance'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
824
747
|
return buildResponse(res).then(_data => {
|
|
825
|
-
return
|
|
826
|
-
balance: _data.balance
|
|
827
|
-
};
|
|
748
|
+
return JsonDecode(_data, 'AdjustProjectBalanceReturn');
|
|
828
749
|
});
|
|
829
750
|
}, error => {
|
|
830
751
|
throw WebrpcRequestFailedError.new({
|
|
831
|
-
cause: `fetch(): ${error.message
|
|
752
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
832
753
|
});
|
|
833
754
|
});
|
|
834
755
|
};
|
|
@@ -839,15 +760,15 @@ class Relayer {
|
|
|
839
760
|
return this.hostname + this.path + name;
|
|
840
761
|
}
|
|
841
762
|
}
|
|
842
|
-
const
|
|
763
|
+
const createHttpRequest = (body = '{}', headers = {}, signal = null) => {
|
|
843
764
|
const reqHeaders = _extends({}, headers, {
|
|
844
|
-
'Content-Type': 'application/json'
|
|
765
|
+
'Content-Type': 'application/json',
|
|
766
|
+
[WebrpcHeader]: WebrpcHeaderValue
|
|
845
767
|
});
|
|
846
|
-
reqHeaders[WebrpcHeader] = WebrpcHeaderValue;
|
|
847
768
|
return {
|
|
848
769
|
method: 'POST',
|
|
849
770
|
headers: reqHeaders,
|
|
850
|
-
body
|
|
771
|
+
body,
|
|
851
772
|
signal
|
|
852
773
|
};
|
|
853
774
|
};
|
|
@@ -857,13 +778,9 @@ const buildResponse = res => {
|
|
|
857
778
|
try {
|
|
858
779
|
data = JSON.parse(text);
|
|
859
780
|
} catch (error) {
|
|
860
|
-
let message = '';
|
|
861
|
-
if (error instanceof Error) {
|
|
862
|
-
message = error.message;
|
|
863
|
-
}
|
|
864
781
|
throw WebrpcBadResponseError.new({
|
|
865
782
|
status: res.status,
|
|
866
|
-
cause: `JSON.parse(): ${message}: response text: ${text}`
|
|
783
|
+
cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`
|
|
867
784
|
});
|
|
868
785
|
}
|
|
869
786
|
if (!res.ok) {
|
|
@@ -873,264 +790,542 @@ const buildResponse = res => {
|
|
|
873
790
|
return data;
|
|
874
791
|
});
|
|
875
792
|
};
|
|
793
|
+
//
|
|
794
|
+
// BigInt helpers
|
|
795
|
+
//
|
|
796
|
+
|
|
797
|
+
const BIG_INT_FIELDS = {
|
|
798
|
+
SendMetaTxnArgs: [['preconditions', 'TransactionPrecondition[]']],
|
|
799
|
+
TransactionPrecondition: ['minAmount'],
|
|
800
|
+
Transactions: [['preconditions', 'TransactionPrecondition[]']]
|
|
801
|
+
};
|
|
802
|
+
|
|
803
|
+
// Decode in-place: mutate object graph; throw if expected numeric string is invalid.
|
|
804
|
+
function decodeType(typ, obj) {
|
|
805
|
+
if (obj == null || typeof obj !== 'object') return obj;
|
|
806
|
+
const descs = BIG_INT_FIELDS[typ] || [];
|
|
807
|
+
if (!descs.length) return obj;
|
|
808
|
+
for (const d of descs) {
|
|
809
|
+
if (Array.isArray(d)) {
|
|
810
|
+
const [fieldName, nestedType] = d;
|
|
811
|
+
if (fieldName.endsWith('[]')) {
|
|
812
|
+
const base = fieldName.slice(0, -2);
|
|
813
|
+
const arr = obj[base];
|
|
814
|
+
if (Array.isArray(arr)) {
|
|
815
|
+
for (let i = 0; i < arr.length; i++) arr[i] = decodeType(nestedType, arr[i]);
|
|
816
|
+
}
|
|
817
|
+
} else if (obj[fieldName]) {
|
|
818
|
+
// Handle nestedType that might be an array type like 'Message[]'
|
|
819
|
+
if (nestedType.endsWith('[]')) {
|
|
820
|
+
const baseType = nestedType.slice(0, -2);
|
|
821
|
+
const arr = obj[fieldName];
|
|
822
|
+
if (Array.isArray(arr)) {
|
|
823
|
+
for (let i = 0; i < arr.length; i++) arr[i] = decodeType(baseType, arr[i]);
|
|
824
|
+
}
|
|
825
|
+
} else {
|
|
826
|
+
obj[fieldName] = decodeType(nestedType, obj[fieldName]);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
continue;
|
|
830
|
+
}
|
|
831
|
+
if (d.endsWith('[]')) {
|
|
832
|
+
const base = d.slice(0, -2);
|
|
833
|
+
const arr = obj[base];
|
|
834
|
+
if (Array.isArray(arr)) {
|
|
835
|
+
for (let i = 0; i < arr.length; i++) {
|
|
836
|
+
const _v = arr[i];
|
|
837
|
+
if (typeof _v === 'string') {
|
|
838
|
+
try {
|
|
839
|
+
arr[i] = BigInt(_v);
|
|
840
|
+
} catch (e) {
|
|
841
|
+
throw WebrpcBadResponseError.new({
|
|
842
|
+
cause: `Invalid bigint value for ${base}[${i}]: ${_v}`
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
continue;
|
|
849
|
+
}
|
|
850
|
+
const v = obj[d];
|
|
851
|
+
if (typeof v === 'string') {
|
|
852
|
+
try {
|
|
853
|
+
obj[d] = BigInt(v);
|
|
854
|
+
} catch (e) {
|
|
855
|
+
throw WebrpcBadResponseError.new({
|
|
856
|
+
cause: `Invalid bigint value for ${d}: ${v}`
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
return obj;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
// Encode object to JSON with BigInts converted to decimal strings.
|
|
865
|
+
const JsonEncode = obj => {
|
|
866
|
+
return JSON.stringify(obj, (key, value) => typeof value === 'bigint' ? value.toString() : value);
|
|
867
|
+
};
|
|
868
|
+
|
|
869
|
+
// Decode data (JSON string or already-parsed object) and convert declared BigInt string fields back to BigInt.
|
|
870
|
+
const JsonDecode = (data, typ = '') => {
|
|
871
|
+
let parsed = data;
|
|
872
|
+
if (typeof data === 'string') {
|
|
873
|
+
try {
|
|
874
|
+
parsed = JSON.parse(data);
|
|
875
|
+
} catch (err) {
|
|
876
|
+
throw WebrpcBadResponseError.new({
|
|
877
|
+
cause: `JsonDecode: JSON.parse failed: ${err.message}`
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
return decodeType(typ, parsed);
|
|
882
|
+
};
|
|
876
883
|
|
|
877
884
|
//
|
|
878
885
|
// Errors
|
|
879
886
|
//
|
|
880
887
|
|
|
881
888
|
class WebrpcError extends Error {
|
|
882
|
-
constructor(
|
|
883
|
-
super(message);
|
|
884
|
-
this.name = void 0;
|
|
889
|
+
constructor(error = {}) {
|
|
890
|
+
super(error.message);
|
|
885
891
|
this.code = void 0;
|
|
886
|
-
this.message = void 0;
|
|
887
892
|
this.status = void 0;
|
|
888
|
-
this.
|
|
889
|
-
|
|
890
|
-
this.
|
|
891
|
-
this.
|
|
892
|
-
|
|
893
|
-
this.message = message || `endpoint error ${this.code}`;
|
|
894
|
-
this.msg = this.message;
|
|
895
|
-
this.status = typeof status === 'number' ? status : 0;
|
|
896
|
-
this.cause = cause;
|
|
893
|
+
this.name = error.name || 'WebrpcEndpointError';
|
|
894
|
+
this.code = typeof error.code === 'number' ? error.code : 0;
|
|
895
|
+
this.message = error.message || `endpoint error`;
|
|
896
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
897
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
897
898
|
Object.setPrototypeOf(this, WebrpcError.prototype);
|
|
898
899
|
}
|
|
899
900
|
static new(payload) {
|
|
900
|
-
return new this(
|
|
901
|
+
return new this({
|
|
902
|
+
message: payload.message,
|
|
903
|
+
code: payload.code,
|
|
904
|
+
status: payload.status,
|
|
905
|
+
cause: payload.cause
|
|
906
|
+
});
|
|
901
907
|
}
|
|
902
908
|
}
|
|
903
|
-
|
|
904
|
-
// Webrpc errors
|
|
905
|
-
|
|
906
909
|
class WebrpcEndpointError extends WebrpcError {
|
|
907
|
-
constructor(
|
|
908
|
-
super(
|
|
910
|
+
constructor(error = {}) {
|
|
911
|
+
super(error);
|
|
912
|
+
this.name = error.name || 'WebrpcEndpoint';
|
|
913
|
+
this.code = typeof error.code === 'number' ? error.code : 0;
|
|
914
|
+
this.message = error.message || `endpoint error`;
|
|
915
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
916
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
909
917
|
Object.setPrototypeOf(this, WebrpcEndpointError.prototype);
|
|
910
918
|
}
|
|
911
919
|
}
|
|
912
920
|
class WebrpcRequestFailedError extends WebrpcError {
|
|
913
|
-
constructor(
|
|
914
|
-
super(
|
|
921
|
+
constructor(error = {}) {
|
|
922
|
+
super(error);
|
|
923
|
+
this.name = error.name || 'WebrpcRequestFailed';
|
|
924
|
+
this.code = typeof error.code === 'number' ? error.code : -1;
|
|
925
|
+
this.message = error.message || `request failed`;
|
|
926
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
927
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
915
928
|
Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype);
|
|
916
929
|
}
|
|
917
930
|
}
|
|
918
931
|
class WebrpcBadRouteError extends WebrpcError {
|
|
919
|
-
constructor(
|
|
920
|
-
super(
|
|
932
|
+
constructor(error = {}) {
|
|
933
|
+
super(error);
|
|
934
|
+
this.name = error.name || 'WebrpcBadRoute';
|
|
935
|
+
this.code = typeof error.code === 'number' ? error.code : -2;
|
|
936
|
+
this.message = error.message || `bad route`;
|
|
937
|
+
this.status = typeof error.status === 'number' ? error.status : 404;
|
|
938
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
921
939
|
Object.setPrototypeOf(this, WebrpcBadRouteError.prototype);
|
|
922
940
|
}
|
|
923
941
|
}
|
|
924
942
|
class WebrpcBadMethodError extends WebrpcError {
|
|
925
|
-
constructor(
|
|
926
|
-
super(
|
|
943
|
+
constructor(error = {}) {
|
|
944
|
+
super(error);
|
|
945
|
+
this.name = error.name || 'WebrpcBadMethod';
|
|
946
|
+
this.code = typeof error.code === 'number' ? error.code : -3;
|
|
947
|
+
this.message = error.message || `bad method`;
|
|
948
|
+
this.status = typeof error.status === 'number' ? error.status : 405;
|
|
949
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
927
950
|
Object.setPrototypeOf(this, WebrpcBadMethodError.prototype);
|
|
928
951
|
}
|
|
929
952
|
}
|
|
930
953
|
class WebrpcBadRequestError extends WebrpcError {
|
|
931
|
-
constructor(
|
|
932
|
-
super(
|
|
954
|
+
constructor(error = {}) {
|
|
955
|
+
super(error);
|
|
956
|
+
this.name = error.name || 'WebrpcBadRequest';
|
|
957
|
+
this.code = typeof error.code === 'number' ? error.code : -4;
|
|
958
|
+
this.message = error.message || `bad request`;
|
|
959
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
960
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
933
961
|
Object.setPrototypeOf(this, WebrpcBadRequestError.prototype);
|
|
934
962
|
}
|
|
935
963
|
}
|
|
936
964
|
class WebrpcBadResponseError extends WebrpcError {
|
|
937
|
-
constructor(
|
|
938
|
-
super(
|
|
965
|
+
constructor(error = {}) {
|
|
966
|
+
super(error);
|
|
967
|
+
this.name = error.name || 'WebrpcBadResponse';
|
|
968
|
+
this.code = typeof error.code === 'number' ? error.code : -5;
|
|
969
|
+
this.message = error.message || `bad response`;
|
|
970
|
+
this.status = typeof error.status === 'number' ? error.status : 500;
|
|
971
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
939
972
|
Object.setPrototypeOf(this, WebrpcBadResponseError.prototype);
|
|
940
973
|
}
|
|
941
974
|
}
|
|
942
975
|
class WebrpcServerPanicError extends WebrpcError {
|
|
943
|
-
constructor(
|
|
944
|
-
super(
|
|
976
|
+
constructor(error = {}) {
|
|
977
|
+
super(error);
|
|
978
|
+
this.name = error.name || 'WebrpcServerPanic';
|
|
979
|
+
this.code = typeof error.code === 'number' ? error.code : -6;
|
|
980
|
+
this.message = error.message || `server panic`;
|
|
981
|
+
this.status = typeof error.status === 'number' ? error.status : 500;
|
|
982
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
945
983
|
Object.setPrototypeOf(this, WebrpcServerPanicError.prototype);
|
|
946
984
|
}
|
|
947
985
|
}
|
|
948
986
|
class WebrpcInternalErrorError extends WebrpcError {
|
|
949
|
-
constructor(
|
|
950
|
-
super(
|
|
987
|
+
constructor(error = {}) {
|
|
988
|
+
super(error);
|
|
989
|
+
this.name = error.name || 'WebrpcInternalError';
|
|
990
|
+
this.code = typeof error.code === 'number' ? error.code : -7;
|
|
991
|
+
this.message = error.message || `internal error`;
|
|
992
|
+
this.status = typeof error.status === 'number' ? error.status : 500;
|
|
993
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
951
994
|
Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype);
|
|
952
995
|
}
|
|
953
996
|
}
|
|
954
|
-
class
|
|
955
|
-
constructor(
|
|
956
|
-
super(
|
|
957
|
-
|
|
997
|
+
class WebrpcClientAbortedError extends WebrpcError {
|
|
998
|
+
constructor(error = {}) {
|
|
999
|
+
super(error);
|
|
1000
|
+
this.name = error.name || 'WebrpcClientAborted';
|
|
1001
|
+
this.code = typeof error.code === 'number' ? error.code : -8;
|
|
1002
|
+
this.message = error.message || `request aborted by client`;
|
|
1003
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1004
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1005
|
+
Object.setPrototypeOf(this, WebrpcClientAbortedError.prototype);
|
|
958
1006
|
}
|
|
959
1007
|
}
|
|
960
1008
|
class WebrpcStreamLostError extends WebrpcError {
|
|
961
|
-
constructor(
|
|
962
|
-
super(
|
|
1009
|
+
constructor(error = {}) {
|
|
1010
|
+
super(error);
|
|
1011
|
+
this.name = error.name || 'WebrpcStreamLost';
|
|
1012
|
+
this.code = typeof error.code === 'number' ? error.code : -9;
|
|
1013
|
+
this.message = error.message || `stream lost`;
|
|
1014
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1015
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
963
1016
|
Object.setPrototypeOf(this, WebrpcStreamLostError.prototype);
|
|
964
1017
|
}
|
|
965
1018
|
}
|
|
966
1019
|
class WebrpcStreamFinishedError extends WebrpcError {
|
|
967
|
-
constructor(
|
|
968
|
-
super(
|
|
1020
|
+
constructor(error = {}) {
|
|
1021
|
+
super(error);
|
|
1022
|
+
this.name = error.name || 'WebrpcStreamFinished';
|
|
1023
|
+
this.code = typeof error.code === 'number' ? error.code : -10;
|
|
1024
|
+
this.message = error.message || `stream finished`;
|
|
1025
|
+
this.status = typeof error.status === 'number' ? error.status : 200;
|
|
1026
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
969
1027
|
Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype);
|
|
970
1028
|
}
|
|
971
1029
|
}
|
|
972
1030
|
|
|
1031
|
+
//
|
|
973
1032
|
// Schema errors
|
|
1033
|
+
//
|
|
974
1034
|
|
|
975
1035
|
class UnauthorizedError extends WebrpcError {
|
|
976
|
-
constructor(
|
|
977
|
-
super(
|
|
1036
|
+
constructor(error = {}) {
|
|
1037
|
+
super(error);
|
|
1038
|
+
this.name = error.name || 'Unauthorized';
|
|
1039
|
+
this.code = typeof error.code === 'number' ? error.code : 1000;
|
|
1040
|
+
this.message = error.message || `Unauthorized access`;
|
|
1041
|
+
this.status = typeof error.status === 'number' ? error.status : 401;
|
|
1042
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
978
1043
|
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
979
1044
|
}
|
|
980
1045
|
}
|
|
981
1046
|
class PermissionDeniedError extends WebrpcError {
|
|
982
|
-
constructor(
|
|
983
|
-
super(
|
|
1047
|
+
constructor(error = {}) {
|
|
1048
|
+
super(error);
|
|
1049
|
+
this.name = error.name || 'PermissionDenied';
|
|
1050
|
+
this.code = typeof error.code === 'number' ? error.code : 1001;
|
|
1051
|
+
this.message = error.message || `Permission denied`;
|
|
1052
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1053
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
984
1054
|
Object.setPrototypeOf(this, PermissionDeniedError.prototype);
|
|
985
1055
|
}
|
|
986
1056
|
}
|
|
987
1057
|
class SessionExpiredError extends WebrpcError {
|
|
988
|
-
constructor(
|
|
989
|
-
super(
|
|
1058
|
+
constructor(error = {}) {
|
|
1059
|
+
super(error);
|
|
1060
|
+
this.name = error.name || 'SessionExpired';
|
|
1061
|
+
this.code = typeof error.code === 'number' ? error.code : 1002;
|
|
1062
|
+
this.message = error.message || `Session expired`;
|
|
1063
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1064
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
990
1065
|
Object.setPrototypeOf(this, SessionExpiredError.prototype);
|
|
991
1066
|
}
|
|
992
1067
|
}
|
|
993
1068
|
class MethodNotFoundError extends WebrpcError {
|
|
994
|
-
constructor(
|
|
995
|
-
super(
|
|
1069
|
+
constructor(error = {}) {
|
|
1070
|
+
super(error);
|
|
1071
|
+
this.name = error.name || 'MethodNotFound';
|
|
1072
|
+
this.code = typeof error.code === 'number' ? error.code : 1003;
|
|
1073
|
+
this.message = error.message || `Method not found`;
|
|
1074
|
+
this.status = typeof error.status === 'number' ? error.status : 404;
|
|
1075
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
996
1076
|
Object.setPrototypeOf(this, MethodNotFoundError.prototype);
|
|
997
1077
|
}
|
|
998
1078
|
}
|
|
999
1079
|
class RequestConflictError extends WebrpcError {
|
|
1000
|
-
constructor(
|
|
1001
|
-
super(
|
|
1080
|
+
constructor(error = {}) {
|
|
1081
|
+
super(error);
|
|
1082
|
+
this.name = error.name || 'RequestConflict';
|
|
1083
|
+
this.code = typeof error.code === 'number' ? error.code : 1004;
|
|
1084
|
+
this.message = error.message || `Conflict with target resource`;
|
|
1085
|
+
this.status = typeof error.status === 'number' ? error.status : 409;
|
|
1086
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1002
1087
|
Object.setPrototypeOf(this, RequestConflictError.prototype);
|
|
1003
1088
|
}
|
|
1004
1089
|
}
|
|
1005
1090
|
class AbortedError extends WebrpcError {
|
|
1006
|
-
constructor(
|
|
1007
|
-
super(
|
|
1091
|
+
constructor(error = {}) {
|
|
1092
|
+
super(error);
|
|
1093
|
+
this.name = error.name || 'Aborted';
|
|
1094
|
+
this.code = typeof error.code === 'number' ? error.code : 1005;
|
|
1095
|
+
this.message = error.message || `Request aborted`;
|
|
1096
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1097
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1008
1098
|
Object.setPrototypeOf(this, AbortedError.prototype);
|
|
1009
1099
|
}
|
|
1010
1100
|
}
|
|
1011
1101
|
class GeoblockedError extends WebrpcError {
|
|
1012
|
-
constructor(
|
|
1013
|
-
super(
|
|
1102
|
+
constructor(error = {}) {
|
|
1103
|
+
super(error);
|
|
1104
|
+
this.name = error.name || 'Geoblocked';
|
|
1105
|
+
this.code = typeof error.code === 'number' ? error.code : 1006;
|
|
1106
|
+
this.message = error.message || `Geoblocked region`;
|
|
1107
|
+
this.status = typeof error.status === 'number' ? error.status : 451;
|
|
1108
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1014
1109
|
Object.setPrototypeOf(this, GeoblockedError.prototype);
|
|
1015
1110
|
}
|
|
1016
1111
|
}
|
|
1017
1112
|
class RateLimitedError extends WebrpcError {
|
|
1018
|
-
constructor(
|
|
1019
|
-
super(
|
|
1113
|
+
constructor(error = {}) {
|
|
1114
|
+
super(error);
|
|
1115
|
+
this.name = error.name || 'RateLimited';
|
|
1116
|
+
this.code = typeof error.code === 'number' ? error.code : 1007;
|
|
1117
|
+
this.message = error.message || `Rate-limited. Please slow down.`;
|
|
1118
|
+
this.status = typeof error.status === 'number' ? error.status : 429;
|
|
1119
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1020
1120
|
Object.setPrototypeOf(this, RateLimitedError.prototype);
|
|
1021
1121
|
}
|
|
1022
1122
|
}
|
|
1023
1123
|
class ProjectNotFoundError extends WebrpcError {
|
|
1024
|
-
constructor(
|
|
1025
|
-
super(
|
|
1124
|
+
constructor(error = {}) {
|
|
1125
|
+
super(error);
|
|
1126
|
+
this.name = error.name || 'ProjectNotFound';
|
|
1127
|
+
this.code = typeof error.code === 'number' ? error.code : 1008;
|
|
1128
|
+
this.message = error.message || `Project not found`;
|
|
1129
|
+
this.status = typeof error.status === 'number' ? error.status : 401;
|
|
1130
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1026
1131
|
Object.setPrototypeOf(this, ProjectNotFoundError.prototype);
|
|
1027
1132
|
}
|
|
1028
1133
|
}
|
|
1029
1134
|
class AccessKeyNotFoundError extends WebrpcError {
|
|
1030
|
-
constructor(
|
|
1031
|
-
super(
|
|
1135
|
+
constructor(error = {}) {
|
|
1136
|
+
super(error);
|
|
1137
|
+
this.name = error.name || 'AccessKeyNotFound';
|
|
1138
|
+
this.code = typeof error.code === 'number' ? error.code : 1101;
|
|
1139
|
+
this.message = error.message || `Access key not found`;
|
|
1140
|
+
this.status = typeof error.status === 'number' ? error.status : 401;
|
|
1141
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1032
1142
|
Object.setPrototypeOf(this, AccessKeyNotFoundError.prototype);
|
|
1033
1143
|
}
|
|
1034
1144
|
}
|
|
1035
1145
|
class AccessKeyMismatchError extends WebrpcError {
|
|
1036
|
-
constructor(
|
|
1037
|
-
super(
|
|
1146
|
+
constructor(error = {}) {
|
|
1147
|
+
super(error);
|
|
1148
|
+
this.name = error.name || 'AccessKeyMismatch';
|
|
1149
|
+
this.code = typeof error.code === 'number' ? error.code : 1102;
|
|
1150
|
+
this.message = error.message || `Access key mismatch`;
|
|
1151
|
+
this.status = typeof error.status === 'number' ? error.status : 409;
|
|
1152
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1038
1153
|
Object.setPrototypeOf(this, AccessKeyMismatchError.prototype);
|
|
1039
1154
|
}
|
|
1040
1155
|
}
|
|
1041
1156
|
class InvalidOriginError extends WebrpcError {
|
|
1042
|
-
constructor(
|
|
1043
|
-
super(
|
|
1157
|
+
constructor(error = {}) {
|
|
1158
|
+
super(error);
|
|
1159
|
+
this.name = error.name || 'InvalidOrigin';
|
|
1160
|
+
this.code = typeof error.code === 'number' ? error.code : 1103;
|
|
1161
|
+
this.message = error.message || `Invalid origin for Access Key`;
|
|
1162
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1163
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1044
1164
|
Object.setPrototypeOf(this, InvalidOriginError.prototype);
|
|
1045
1165
|
}
|
|
1046
1166
|
}
|
|
1047
1167
|
class InvalidServiceError extends WebrpcError {
|
|
1048
|
-
constructor(
|
|
1049
|
-
super(
|
|
1168
|
+
constructor(error = {}) {
|
|
1169
|
+
super(error);
|
|
1170
|
+
this.name = error.name || 'InvalidService';
|
|
1171
|
+
this.code = typeof error.code === 'number' ? error.code : 1104;
|
|
1172
|
+
this.message = error.message || `Service not enabled for Access key`;
|
|
1173
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1174
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1050
1175
|
Object.setPrototypeOf(this, InvalidServiceError.prototype);
|
|
1051
1176
|
}
|
|
1052
1177
|
}
|
|
1053
1178
|
class UnauthorizedUserError extends WebrpcError {
|
|
1054
|
-
constructor(
|
|
1055
|
-
super(
|
|
1179
|
+
constructor(error = {}) {
|
|
1180
|
+
super(error);
|
|
1181
|
+
this.name = error.name || 'UnauthorizedUser';
|
|
1182
|
+
this.code = typeof error.code === 'number' ? error.code : 1105;
|
|
1183
|
+
this.message = error.message || `Unauthorized user`;
|
|
1184
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1185
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1056
1186
|
Object.setPrototypeOf(this, UnauthorizedUserError.prototype);
|
|
1057
1187
|
}
|
|
1058
1188
|
}
|
|
1059
1189
|
class QuotaExceededError extends WebrpcError {
|
|
1060
|
-
constructor(
|
|
1061
|
-
super(
|
|
1190
|
+
constructor(error = {}) {
|
|
1191
|
+
super(error);
|
|
1192
|
+
this.name = error.name || 'QuotaExceeded';
|
|
1193
|
+
this.code = typeof error.code === 'number' ? error.code : 1200;
|
|
1194
|
+
this.message = error.message || `Quota request exceeded`;
|
|
1195
|
+
this.status = typeof error.status === 'number' ? error.status : 429;
|
|
1196
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1062
1197
|
Object.setPrototypeOf(this, QuotaExceededError.prototype);
|
|
1063
1198
|
}
|
|
1064
1199
|
}
|
|
1065
1200
|
class QuotaRateLimitError extends WebrpcError {
|
|
1066
|
-
constructor(
|
|
1067
|
-
super(
|
|
1201
|
+
constructor(error = {}) {
|
|
1202
|
+
super(error);
|
|
1203
|
+
this.name = error.name || 'QuotaRateLimit';
|
|
1204
|
+
this.code = typeof error.code === 'number' ? error.code : 1201;
|
|
1205
|
+
this.message = error.message || `Quota rate limit exceeded`;
|
|
1206
|
+
this.status = typeof error.status === 'number' ? error.status : 429;
|
|
1207
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1068
1208
|
Object.setPrototypeOf(this, QuotaRateLimitError.prototype);
|
|
1069
1209
|
}
|
|
1070
1210
|
}
|
|
1071
1211
|
class NoDefaultKeyError extends WebrpcError {
|
|
1072
|
-
constructor(
|
|
1073
|
-
super(
|
|
1212
|
+
constructor(error = {}) {
|
|
1213
|
+
super(error);
|
|
1214
|
+
this.name = error.name || 'NoDefaultKey';
|
|
1215
|
+
this.code = typeof error.code === 'number' ? error.code : 1300;
|
|
1216
|
+
this.message = error.message || `No default access key found`;
|
|
1217
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1218
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1074
1219
|
Object.setPrototypeOf(this, NoDefaultKeyError.prototype);
|
|
1075
1220
|
}
|
|
1076
1221
|
}
|
|
1077
1222
|
class MaxAccessKeysError extends WebrpcError {
|
|
1078
|
-
constructor(
|
|
1079
|
-
super(
|
|
1223
|
+
constructor(error = {}) {
|
|
1224
|
+
super(error);
|
|
1225
|
+
this.name = error.name || 'MaxAccessKeys';
|
|
1226
|
+
this.code = typeof error.code === 'number' ? error.code : 1301;
|
|
1227
|
+
this.message = error.message || `Access keys limit reached`;
|
|
1228
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1229
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1080
1230
|
Object.setPrototypeOf(this, MaxAccessKeysError.prototype);
|
|
1081
1231
|
}
|
|
1082
1232
|
}
|
|
1083
1233
|
class AtLeastOneKeyError extends WebrpcError {
|
|
1084
|
-
constructor(
|
|
1085
|
-
super(
|
|
1234
|
+
constructor(error = {}) {
|
|
1235
|
+
super(error);
|
|
1236
|
+
this.name = error.name || 'AtLeastOneKey';
|
|
1237
|
+
this.code = typeof error.code === 'number' ? error.code : 1302;
|
|
1238
|
+
this.message = error.message || `You need at least one Access Key`;
|
|
1239
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1240
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1086
1241
|
Object.setPrototypeOf(this, AtLeastOneKeyError.prototype);
|
|
1087
1242
|
}
|
|
1088
1243
|
}
|
|
1089
1244
|
class TimeoutError extends WebrpcError {
|
|
1090
|
-
constructor(
|
|
1091
|
-
super(
|
|
1245
|
+
constructor(error = {}) {
|
|
1246
|
+
super(error);
|
|
1247
|
+
this.name = error.name || 'Timeout';
|
|
1248
|
+
this.code = typeof error.code === 'number' ? error.code : 1900;
|
|
1249
|
+
this.message = error.message || `Request timed out`;
|
|
1250
|
+
this.status = typeof error.status === 'number' ? error.status : 408;
|
|
1251
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1092
1252
|
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
1093
1253
|
}
|
|
1094
1254
|
}
|
|
1095
1255
|
class InvalidArgumentError extends WebrpcError {
|
|
1096
|
-
constructor(
|
|
1097
|
-
super(
|
|
1256
|
+
constructor(error = {}) {
|
|
1257
|
+
super(error);
|
|
1258
|
+
this.name = error.name || 'InvalidArgument';
|
|
1259
|
+
this.code = typeof error.code === 'number' ? error.code : 2001;
|
|
1260
|
+
this.message = error.message || `Invalid argument`;
|
|
1261
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1262
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1098
1263
|
Object.setPrototypeOf(this, InvalidArgumentError.prototype);
|
|
1099
1264
|
}
|
|
1100
1265
|
}
|
|
1101
1266
|
class UnavailableError extends WebrpcError {
|
|
1102
|
-
constructor(
|
|
1103
|
-
super(
|
|
1267
|
+
constructor(error = {}) {
|
|
1268
|
+
super(error);
|
|
1269
|
+
this.name = error.name || 'Unavailable';
|
|
1270
|
+
this.code = typeof error.code === 'number' ? error.code : 2002;
|
|
1271
|
+
this.message = error.message || `Unavailable resource`;
|
|
1272
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1273
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1104
1274
|
Object.setPrototypeOf(this, UnavailableError.prototype);
|
|
1105
1275
|
}
|
|
1106
1276
|
}
|
|
1107
1277
|
class QueryFailedError extends WebrpcError {
|
|
1108
|
-
constructor(
|
|
1109
|
-
super(
|
|
1278
|
+
constructor(error = {}) {
|
|
1279
|
+
super(error);
|
|
1280
|
+
this.name = error.name || 'QueryFailed';
|
|
1281
|
+
this.code = typeof error.code === 'number' ? error.code : 2003;
|
|
1282
|
+
this.message = error.message || `Query failed`;
|
|
1283
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1284
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1110
1285
|
Object.setPrototypeOf(this, QueryFailedError.prototype);
|
|
1111
1286
|
}
|
|
1112
1287
|
}
|
|
1113
1288
|
class NotFoundError extends WebrpcError {
|
|
1114
|
-
constructor(
|
|
1115
|
-
super(
|
|
1289
|
+
constructor(error = {}) {
|
|
1290
|
+
super(error);
|
|
1291
|
+
this.name = error.name || 'NotFound';
|
|
1292
|
+
this.code = typeof error.code === 'number' ? error.code : 3000;
|
|
1293
|
+
this.message = error.message || `Resource not found`;
|
|
1294
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1295
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1116
1296
|
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
1117
1297
|
}
|
|
1118
1298
|
}
|
|
1119
1299
|
class InsufficientFeeError extends WebrpcError {
|
|
1120
|
-
constructor(
|
|
1121
|
-
super(
|
|
1300
|
+
constructor(error = {}) {
|
|
1301
|
+
super(error);
|
|
1302
|
+
this.name = error.name || 'InsufficientFee';
|
|
1303
|
+
this.code = typeof error.code === 'number' ? error.code : 3004;
|
|
1304
|
+
this.message = error.message || `Insufficient fee`;
|
|
1305
|
+
this.status = typeof error.status === 'number' ? error.status : 402;
|
|
1306
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1122
1307
|
Object.setPrototypeOf(this, InsufficientFeeError.prototype);
|
|
1123
1308
|
}
|
|
1124
1309
|
}
|
|
1125
1310
|
class NotEnoughBalanceError extends WebrpcError {
|
|
1126
|
-
constructor(
|
|
1127
|
-
super(
|
|
1311
|
+
constructor(error = {}) {
|
|
1312
|
+
super(error);
|
|
1313
|
+
this.name = error.name || 'NotEnoughBalance';
|
|
1314
|
+
this.code = typeof error.code === 'number' ? error.code : 3005;
|
|
1315
|
+
this.message = error.message || `Not enough balance`;
|
|
1316
|
+
this.status = typeof error.status === 'number' ? error.status : 402;
|
|
1317
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1128
1318
|
Object.setPrototypeOf(this, NotEnoughBalanceError.prototype);
|
|
1129
1319
|
}
|
|
1130
1320
|
}
|
|
1131
1321
|
class SimulationFailedError extends WebrpcError {
|
|
1132
|
-
constructor(
|
|
1133
|
-
super(
|
|
1322
|
+
constructor(error = {}) {
|
|
1323
|
+
super(error);
|
|
1324
|
+
this.name = error.name || 'SimulationFailed';
|
|
1325
|
+
this.code = typeof error.code === 'number' ? error.code : 3006;
|
|
1326
|
+
this.message = error.message || `Simulation failed`;
|
|
1327
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1328
|
+
if (error.cause !== undefined) this.cause = error.cause;
|
|
1134
1329
|
Object.setPrototypeOf(this, SimulationFailedError.prototype);
|
|
1135
1330
|
}
|
|
1136
1331
|
}
|
|
@@ -1143,7 +1338,7 @@ let errors = /*#__PURE__*/function (errors) {
|
|
|
1143
1338
|
errors["WebrpcBadResponse"] = "WebrpcBadResponse";
|
|
1144
1339
|
errors["WebrpcServerPanic"] = "WebrpcServerPanic";
|
|
1145
1340
|
errors["WebrpcInternalError"] = "WebrpcInternalError";
|
|
1146
|
-
errors["
|
|
1341
|
+
errors["WebrpcClientAborted"] = "WebrpcClientAborted";
|
|
1147
1342
|
errors["WebrpcStreamLost"] = "WebrpcStreamLost";
|
|
1148
1343
|
errors["WebrpcStreamFinished"] = "WebrpcStreamFinished";
|
|
1149
1344
|
errors["Unauthorized"] = "Unauthorized";
|
|
@@ -1184,7 +1379,7 @@ let WebrpcErrorCodes = /*#__PURE__*/function (WebrpcErrorCodes) {
|
|
|
1184
1379
|
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadResponse"] = -5] = "WebrpcBadResponse";
|
|
1185
1380
|
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcServerPanic"] = -6] = "WebrpcServerPanic";
|
|
1186
1381
|
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcInternalError"] = -7] = "WebrpcInternalError";
|
|
1187
|
-
WebrpcErrorCodes[WebrpcErrorCodes["
|
|
1382
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcClientAborted"] = -8] = "WebrpcClientAborted";
|
|
1188
1383
|
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamLost"] = -9] = "WebrpcStreamLost";
|
|
1189
1384
|
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamFinished"] = -10] = "WebrpcStreamFinished";
|
|
1190
1385
|
WebrpcErrorCodes[WebrpcErrorCodes["Unauthorized"] = 1000] = "Unauthorized";
|
|
@@ -1225,7 +1420,7 @@ const webrpcErrorByCode = {
|
|
|
1225
1420
|
[-5]: WebrpcBadResponseError,
|
|
1226
1421
|
[-6]: WebrpcServerPanicError,
|
|
1227
1422
|
[-7]: WebrpcInternalErrorError,
|
|
1228
|
-
[-8]:
|
|
1423
|
+
[-8]: WebrpcClientAbortedError,
|
|
1229
1424
|
[-9]: WebrpcStreamLostError,
|
|
1230
1425
|
[-10]: WebrpcStreamFinishedError,
|
|
1231
1426
|
[1000]: UnauthorizedError,
|
|
@@ -1257,20 +1452,61 @@ const webrpcErrorByCode = {
|
|
|
1257
1452
|
[3006]: SimulationFailedError
|
|
1258
1453
|
};
|
|
1259
1454
|
|
|
1455
|
+
//
|
|
1456
|
+
// Webrpc
|
|
1457
|
+
//
|
|
1458
|
+
|
|
1459
|
+
const WebrpcHeader = 'Webrpc';
|
|
1460
|
+
const WebrpcHeaderValue = 'webrpc@v0.31.2;gen-typescript@v0.23.1;sequence-relayer@v0.4.1';
|
|
1461
|
+
function VersionFromHeader(headers) {
|
|
1462
|
+
const headerValue = headers.get(WebrpcHeader);
|
|
1463
|
+
if (!headerValue) {
|
|
1464
|
+
return {
|
|
1465
|
+
WebrpcGenVersion: '',
|
|
1466
|
+
codeGenName: '',
|
|
1467
|
+
codeGenVersion: '',
|
|
1468
|
+
schemaName: '',
|
|
1469
|
+
schemaVersion: ''
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1472
|
+
return parseWebrpcGenVersions(headerValue);
|
|
1473
|
+
}
|
|
1474
|
+
function parseWebrpcGenVersions(header) {
|
|
1475
|
+
const versions = header.split(';');
|
|
1476
|
+
if (versions.length < 3) {
|
|
1477
|
+
return {
|
|
1478
|
+
WebrpcGenVersion: '',
|
|
1479
|
+
codeGenName: '',
|
|
1480
|
+
codeGenVersion: '',
|
|
1481
|
+
schemaName: '',
|
|
1482
|
+
schemaVersion: ''
|
|
1483
|
+
};
|
|
1484
|
+
}
|
|
1485
|
+
const [_, WebrpcGenVersion] = versions[0].split('@');
|
|
1486
|
+
const [codeGenName, codeGenVersion] = versions[1].split('@');
|
|
1487
|
+
const [schemaName, schemaVersion] = versions[2].split('@');
|
|
1488
|
+
return {
|
|
1489
|
+
WebrpcGenVersion: WebrpcGenVersion != null ? WebrpcGenVersion : '',
|
|
1490
|
+
codeGenName: codeGenName != null ? codeGenName : '',
|
|
1491
|
+
codeGenVersion: codeGenVersion != null ? codeGenVersion : '',
|
|
1492
|
+
schemaName: schemaName != null ? schemaName : '',
|
|
1493
|
+
schemaVersion: schemaVersion != null ? schemaVersion : ''
|
|
1494
|
+
};
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1260
1497
|
var relayer_gen = /*#__PURE__*/Object.freeze({
|
|
1261
1498
|
__proto__: null,
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
WebRPCSchemaVersion: WebRPCSchemaVersion,
|
|
1266
|
-
WebRPCSchemaHash: WebRPCSchemaHash,
|
|
1267
|
-
VersionFromHeader: VersionFromHeader,
|
|
1499
|
+
WebrpcVersion: WebrpcVersion,
|
|
1500
|
+
WebrpcSchemaVersion: WebrpcSchemaVersion,
|
|
1501
|
+
WebrpcSchemaHash: WebrpcSchemaHash,
|
|
1268
1502
|
ETHTxnStatus: ETHTxnStatus,
|
|
1269
1503
|
TransferType: TransferType,
|
|
1270
1504
|
SimulateStatus: SimulateStatus,
|
|
1271
1505
|
FeeTokenType: FeeTokenType,
|
|
1272
1506
|
SortOrder: SortOrder,
|
|
1273
1507
|
Relayer: Relayer,
|
|
1508
|
+
JsonEncode: JsonEncode,
|
|
1509
|
+
JsonDecode: JsonDecode,
|
|
1274
1510
|
WebrpcError: WebrpcError,
|
|
1275
1511
|
WebrpcEndpointError: WebrpcEndpointError,
|
|
1276
1512
|
WebrpcRequestFailedError: WebrpcRequestFailedError,
|
|
@@ -1280,7 +1516,7 @@ var relayer_gen = /*#__PURE__*/Object.freeze({
|
|
|
1280
1516
|
WebrpcBadResponseError: WebrpcBadResponseError,
|
|
1281
1517
|
WebrpcServerPanicError: WebrpcServerPanicError,
|
|
1282
1518
|
WebrpcInternalErrorError: WebrpcInternalErrorError,
|
|
1283
|
-
|
|
1519
|
+
WebrpcClientAbortedError: WebrpcClientAbortedError,
|
|
1284
1520
|
WebrpcStreamLostError: WebrpcStreamLostError,
|
|
1285
1521
|
WebrpcStreamFinishedError: WebrpcStreamFinishedError,
|
|
1286
1522
|
UnauthorizedError: UnauthorizedError,
|
|
@@ -1312,7 +1548,10 @@ var relayer_gen = /*#__PURE__*/Object.freeze({
|
|
|
1312
1548
|
SimulationFailedError: SimulationFailedError,
|
|
1313
1549
|
errors: errors,
|
|
1314
1550
|
WebrpcErrorCodes: WebrpcErrorCodes,
|
|
1315
|
-
webrpcErrorByCode: webrpcErrorByCode
|
|
1551
|
+
webrpcErrorByCode: webrpcErrorByCode,
|
|
1552
|
+
WebrpcHeader: WebrpcHeader,
|
|
1553
|
+
WebrpcHeaderValue: WebrpcHeaderValue,
|
|
1554
|
+
VersionFromHeader: VersionFromHeader
|
|
1316
1555
|
});
|
|
1317
1556
|
|
|
1318
1557
|
const FINAL_STATUSES = [ETHTxnStatus.DROPPED, ETHTxnStatus.SUCCEEDED, ETHTxnStatus.PARTIALLY_FAILED, ETHTxnStatus.FAILED];
|