@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
|
@@ -287,61 +287,27 @@ function isAbstractSigner(signer) {
|
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
/* eslint-disable */
|
|
290
|
-
// sequence-relayer v0.4.1
|
|
290
|
+
// sequence-relayer v0.4.1 7f8a4b83b00e0b6849c76c2ff0e23931e26b3d9f
|
|
291
291
|
// --
|
|
292
|
-
// Code generated by
|
|
292
|
+
// Code generated by Webrpc-gen@v0.31.2 with typescript generator. DO NOT EDIT.
|
|
293
293
|
//
|
|
294
|
-
// webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts
|
|
294
|
+
// webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts -compat
|
|
295
295
|
|
|
296
|
-
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
// WebRPC description and code-gen version
|
|
300
|
-
const WebRPCVersion = "v1";
|
|
296
|
+
// Webrpc description and code-gen version
|
|
297
|
+
const WebrpcVersion = 'v1';
|
|
301
298
|
|
|
302
299
|
// Schema version of your RIDL schema
|
|
303
|
-
const
|
|
300
|
+
const WebrpcSchemaVersion = 'v0.4.1';
|
|
304
301
|
|
|
305
302
|
// Schema hash generated from your RIDL schema
|
|
306
|
-
const
|
|
307
|
-
function VersionFromHeader(headers) {
|
|
308
|
-
const headerValue = headers.get(WebrpcHeader);
|
|
309
|
-
if (!headerValue) {
|
|
310
|
-
return {
|
|
311
|
-
webrpcGenVersion: "",
|
|
312
|
-
codeGenName: "",
|
|
313
|
-
codeGenVersion: "",
|
|
314
|
-
schemaName: "",
|
|
315
|
-
schemaVersion: ""
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
return parseWebrpcGenVersions(headerValue);
|
|
319
|
-
}
|
|
320
|
-
function parseWebrpcGenVersions(header) {
|
|
321
|
-
const versions = header.split(";");
|
|
322
|
-
if (versions.length < 3) {
|
|
323
|
-
return {
|
|
324
|
-
webrpcGenVersion: "",
|
|
325
|
-
codeGenName: "",
|
|
326
|
-
codeGenVersion: "",
|
|
327
|
-
schemaName: "",
|
|
328
|
-
schemaVersion: ""
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
const [_, webrpcGenVersion] = versions[0].split("@");
|
|
332
|
-
const [codeGenName, codeGenVersion] = versions[1].split("@");
|
|
333
|
-
const [schemaName, schemaVersion] = versions[2].split("@");
|
|
334
|
-
return {
|
|
335
|
-
webrpcGenVersion: webrpcGenVersion != null ? webrpcGenVersion : "",
|
|
336
|
-
codeGenName: codeGenName != null ? codeGenName : "",
|
|
337
|
-
codeGenVersion: codeGenVersion != null ? codeGenVersion : "",
|
|
338
|
-
schemaName: schemaName != null ? schemaName : "",
|
|
339
|
-
schemaVersion: schemaVersion != null ? schemaVersion : ""
|
|
340
|
-
};
|
|
341
|
-
}
|
|
303
|
+
const WebrpcSchemaHash = '7f8a4b83b00e0b6849c76c2ff0e23931e26b3d9f';
|
|
342
304
|
|
|
343
305
|
//
|
|
344
|
-
//
|
|
306
|
+
// Client interface
|
|
307
|
+
//
|
|
308
|
+
|
|
309
|
+
//
|
|
310
|
+
// Schema types
|
|
345
311
|
//
|
|
346
312
|
|
|
347
313
|
let ETHTxnStatus = /*#__PURE__*/function (ETHTxnStatus) {
|
|
@@ -387,452 +353,407 @@ let SortOrder = /*#__PURE__*/function (SortOrder) {
|
|
|
387
353
|
//
|
|
388
354
|
// Client
|
|
389
355
|
//
|
|
356
|
+
|
|
390
357
|
class Relayer {
|
|
391
358
|
constructor(hostname, fetch) {
|
|
392
359
|
this.hostname = void 0;
|
|
393
360
|
this.fetch = void 0;
|
|
394
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
|
+
};
|
|
395
397
|
this.ping = (headers, signal) => {
|
|
396
|
-
return this.fetch(this.url('Ping'),
|
|
398
|
+
return this.fetch(this.url('Ping'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
397
399
|
return buildResponse(res).then(_data => {
|
|
398
|
-
return
|
|
399
|
-
status: _data.status
|
|
400
|
-
};
|
|
400
|
+
return JsonDecode(_data, 'PingReturn');
|
|
401
401
|
});
|
|
402
402
|
}, error => {
|
|
403
403
|
throw WebrpcRequestFailedError.new({
|
|
404
|
-
cause: `fetch(): ${error.message
|
|
404
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
405
405
|
});
|
|
406
406
|
});
|
|
407
407
|
};
|
|
408
408
|
this.version = (headers, signal) => {
|
|
409
|
-
return this.fetch(this.url('Version'),
|
|
409
|
+
return this.fetch(this.url('Version'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
410
410
|
return buildResponse(res).then(_data => {
|
|
411
|
-
return
|
|
412
|
-
version: _data.version
|
|
413
|
-
};
|
|
411
|
+
return JsonDecode(_data, 'VersionReturn');
|
|
414
412
|
});
|
|
415
413
|
}, error => {
|
|
416
414
|
throw WebrpcRequestFailedError.new({
|
|
417
|
-
cause: `fetch(): ${error.message
|
|
415
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
418
416
|
});
|
|
419
417
|
});
|
|
420
418
|
};
|
|
421
419
|
this.runtimeStatus = (headers, signal) => {
|
|
422
|
-
return this.fetch(this.url('RuntimeStatus'),
|
|
420
|
+
return this.fetch(this.url('RuntimeStatus'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
423
421
|
return buildResponse(res).then(_data => {
|
|
424
|
-
return
|
|
425
|
-
status: _data.status
|
|
426
|
-
};
|
|
422
|
+
return JsonDecode(_data, 'RuntimeStatusReturn');
|
|
427
423
|
});
|
|
428
424
|
}, error => {
|
|
429
425
|
throw WebrpcRequestFailedError.new({
|
|
430
|
-
cause: `fetch(): ${error.message
|
|
426
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
431
427
|
});
|
|
432
428
|
});
|
|
433
429
|
};
|
|
434
430
|
this.getSequenceContext = (headers, signal) => {
|
|
435
|
-
return this.fetch(this.url('GetSequenceContext'),
|
|
431
|
+
return this.fetch(this.url('GetSequenceContext'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
436
432
|
return buildResponse(res).then(_data => {
|
|
437
|
-
return
|
|
438
|
-
data: _data.data
|
|
439
|
-
};
|
|
433
|
+
return JsonDecode(_data, 'GetSequenceContextReturn');
|
|
440
434
|
});
|
|
441
435
|
}, error => {
|
|
442
436
|
throw WebrpcRequestFailedError.new({
|
|
443
|
-
cause: `fetch(): ${error.message
|
|
437
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
444
438
|
});
|
|
445
439
|
});
|
|
446
440
|
};
|
|
447
441
|
this.getChainID = (headers, signal) => {
|
|
448
|
-
return this.fetch(this.url('GetChainID'),
|
|
442
|
+
return this.fetch(this.url('GetChainID'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
449
443
|
return buildResponse(res).then(_data => {
|
|
450
|
-
return
|
|
451
|
-
chainID: _data.chainID
|
|
452
|
-
};
|
|
444
|
+
return JsonDecode(_data, 'GetChainIDReturn');
|
|
453
445
|
});
|
|
454
446
|
}, error => {
|
|
455
447
|
throw WebrpcRequestFailedError.new({
|
|
456
|
-
cause: `fetch(): ${error.message
|
|
448
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
457
449
|
});
|
|
458
450
|
});
|
|
459
451
|
};
|
|
460
|
-
this.sendMetaTxn = (
|
|
461
|
-
return this.fetch(this.url('SendMetaTxn'),
|
|
452
|
+
this.sendMetaTxn = (req, headers, signal) => {
|
|
453
|
+
return this.fetch(this.url('SendMetaTxn'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
462
454
|
return buildResponse(res).then(_data => {
|
|
463
|
-
return
|
|
464
|
-
status: _data.status,
|
|
465
|
-
txnHash: _data.txnHash
|
|
466
|
-
};
|
|
455
|
+
return JsonDecode(_data, 'SendMetaTxnReturn');
|
|
467
456
|
});
|
|
468
457
|
}, error => {
|
|
469
458
|
throw WebrpcRequestFailedError.new({
|
|
470
|
-
cause: `fetch(): ${error.message
|
|
459
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
471
460
|
});
|
|
472
461
|
});
|
|
473
462
|
};
|
|
474
|
-
this.getMetaTxnNonce = (
|
|
475
|
-
return this.fetch(this.url('GetMetaTxnNonce'),
|
|
463
|
+
this.getMetaTxnNonce = (req, headers, signal) => {
|
|
464
|
+
return this.fetch(this.url('GetMetaTxnNonce'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
476
465
|
return buildResponse(res).then(_data => {
|
|
477
|
-
return
|
|
478
|
-
nonce: _data.nonce
|
|
479
|
-
};
|
|
466
|
+
return JsonDecode(_data, 'GetMetaTxnNonceReturn');
|
|
480
467
|
});
|
|
481
468
|
}, error => {
|
|
482
469
|
throw WebrpcRequestFailedError.new({
|
|
483
|
-
cause: `fetch(): ${error.message
|
|
470
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
484
471
|
});
|
|
485
472
|
});
|
|
486
473
|
};
|
|
487
|
-
this.getMetaTxnReceipt = (
|
|
488
|
-
return this.fetch(this.url('GetMetaTxnReceipt'),
|
|
474
|
+
this.getMetaTxnReceipt = (req, headers, signal) => {
|
|
475
|
+
return this.fetch(this.url('GetMetaTxnReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
489
476
|
return buildResponse(res).then(_data => {
|
|
490
|
-
return
|
|
491
|
-
receipt: _data.receipt
|
|
492
|
-
};
|
|
477
|
+
return JsonDecode(_data, 'GetMetaTxnReceiptReturn');
|
|
493
478
|
});
|
|
494
479
|
}, error => {
|
|
495
480
|
throw WebrpcRequestFailedError.new({
|
|
496
|
-
cause: `fetch(): ${error.message
|
|
481
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
497
482
|
});
|
|
498
483
|
});
|
|
499
484
|
};
|
|
500
|
-
this.simulate = (
|
|
501
|
-
return this.fetch(this.url('Simulate'),
|
|
485
|
+
this.simulate = (req, headers, signal) => {
|
|
486
|
+
return this.fetch(this.url('Simulate'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
502
487
|
return buildResponse(res).then(_data => {
|
|
503
|
-
return
|
|
504
|
-
results: _data.results
|
|
505
|
-
};
|
|
488
|
+
return JsonDecode(_data, 'SimulateReturn');
|
|
506
489
|
});
|
|
507
490
|
}, error => {
|
|
508
491
|
throw WebrpcRequestFailedError.new({
|
|
509
|
-
cause: `fetch(): ${error.message
|
|
492
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
510
493
|
});
|
|
511
494
|
});
|
|
512
495
|
};
|
|
513
|
-
this.simulateV3 = (
|
|
514
|
-
return this.fetch(this.url('SimulateV3'),
|
|
496
|
+
this.simulateV3 = (req, headers, signal) => {
|
|
497
|
+
return this.fetch(this.url('SimulateV3'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
515
498
|
return buildResponse(res).then(_data => {
|
|
516
|
-
return
|
|
517
|
-
results: _data.results
|
|
518
|
-
};
|
|
499
|
+
return JsonDecode(_data, 'SimulateV3Return');
|
|
519
500
|
});
|
|
520
501
|
}, error => {
|
|
521
502
|
throw WebrpcRequestFailedError.new({
|
|
522
|
-
cause: `fetch(): ${error.message
|
|
503
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
523
504
|
});
|
|
524
505
|
});
|
|
525
506
|
};
|
|
526
|
-
this.updateMetaTxnGasLimits = (
|
|
527
|
-
return this.fetch(this.url('UpdateMetaTxnGasLimits'),
|
|
507
|
+
this.updateMetaTxnGasLimits = (req, headers, signal) => {
|
|
508
|
+
return this.fetch(this.url('UpdateMetaTxnGasLimits'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
528
509
|
return buildResponse(res).then(_data => {
|
|
529
|
-
return
|
|
530
|
-
payload: _data.payload
|
|
531
|
-
};
|
|
510
|
+
return JsonDecode(_data, 'UpdateMetaTxnGasLimitsReturn');
|
|
532
511
|
});
|
|
533
512
|
}, error => {
|
|
534
513
|
throw WebrpcRequestFailedError.new({
|
|
535
|
-
cause: `fetch(): ${error.message
|
|
514
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
536
515
|
});
|
|
537
516
|
});
|
|
538
517
|
};
|
|
539
518
|
this.feeTokens = (headers, signal) => {
|
|
540
|
-
return this.fetch(this.url('FeeTokens'),
|
|
519
|
+
return this.fetch(this.url('FeeTokens'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
541
520
|
return buildResponse(res).then(_data => {
|
|
542
|
-
return
|
|
543
|
-
isFeeRequired: _data.isFeeRequired,
|
|
544
|
-
tokens: _data.tokens
|
|
545
|
-
};
|
|
521
|
+
return JsonDecode(_data, 'FeeTokensReturn');
|
|
546
522
|
});
|
|
547
523
|
}, error => {
|
|
548
524
|
throw WebrpcRequestFailedError.new({
|
|
549
|
-
cause: `fetch(): ${error.message
|
|
525
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
550
526
|
});
|
|
551
527
|
});
|
|
552
528
|
};
|
|
553
|
-
this.feeOptions = (
|
|
554
|
-
return this.fetch(this.url('FeeOptions'),
|
|
529
|
+
this.feeOptions = (req, headers, signal) => {
|
|
530
|
+
return this.fetch(this.url('FeeOptions'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
555
531
|
return buildResponse(res).then(_data => {
|
|
556
|
-
return
|
|
557
|
-
options: _data.options,
|
|
558
|
-
sponsored: _data.sponsored,
|
|
559
|
-
quote: _data.quote
|
|
560
|
-
};
|
|
532
|
+
return JsonDecode(_data, 'FeeOptionsReturn');
|
|
561
533
|
});
|
|
562
534
|
}, error => {
|
|
563
535
|
throw WebrpcRequestFailedError.new({
|
|
564
|
-
cause: `fetch(): ${error.message
|
|
536
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
565
537
|
});
|
|
566
538
|
});
|
|
567
539
|
};
|
|
568
|
-
this.getMetaTxnNetworkFeeOptions = (
|
|
569
|
-
return this.fetch(this.url('GetMetaTxnNetworkFeeOptions'),
|
|
540
|
+
this.getMetaTxnNetworkFeeOptions = (req, headers, signal) => {
|
|
541
|
+
return this.fetch(this.url('GetMetaTxnNetworkFeeOptions'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
570
542
|
return buildResponse(res).then(_data => {
|
|
571
|
-
return
|
|
572
|
-
options: _data.options
|
|
573
|
-
};
|
|
543
|
+
return JsonDecode(_data, 'GetMetaTxnNetworkFeeOptionsReturn');
|
|
574
544
|
});
|
|
575
545
|
}, error => {
|
|
576
546
|
throw WebrpcRequestFailedError.new({
|
|
577
|
-
cause: `fetch(): ${error.message
|
|
547
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
578
548
|
});
|
|
579
549
|
});
|
|
580
550
|
};
|
|
581
|
-
this.getMetaTransactions = (
|
|
582
|
-
return this.fetch(this.url('GetMetaTransactions'),
|
|
551
|
+
this.getMetaTransactions = (req, headers, signal) => {
|
|
552
|
+
return this.fetch(this.url('GetMetaTransactions'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
583
553
|
return buildResponse(res).then(_data => {
|
|
584
|
-
return
|
|
585
|
-
page: _data.page,
|
|
586
|
-
transactions: _data.transactions
|
|
587
|
-
};
|
|
554
|
+
return JsonDecode(_data, 'GetMetaTransactionsReturn');
|
|
588
555
|
});
|
|
589
556
|
}, error => {
|
|
590
557
|
throw WebrpcRequestFailedError.new({
|
|
591
|
-
cause: `fetch(): ${error.message
|
|
558
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
592
559
|
});
|
|
593
560
|
});
|
|
594
561
|
};
|
|
595
|
-
this.getTransactionCost = (
|
|
596
|
-
return this.fetch(this.url('GetTransactionCost'),
|
|
562
|
+
this.getTransactionCost = (req, headers, signal) => {
|
|
563
|
+
return this.fetch(this.url('GetTransactionCost'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
597
564
|
return buildResponse(res).then(_data => {
|
|
598
|
-
return
|
|
599
|
-
cost: _data.cost
|
|
600
|
-
};
|
|
565
|
+
return JsonDecode(_data, 'GetTransactionCostReturn');
|
|
601
566
|
});
|
|
602
567
|
}, error => {
|
|
603
568
|
throw WebrpcRequestFailedError.new({
|
|
604
|
-
cause: `fetch(): ${error.message
|
|
569
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
605
570
|
});
|
|
606
571
|
});
|
|
607
572
|
};
|
|
608
|
-
this.sentTransactions = (
|
|
609
|
-
return this.fetch(this.url('SentTransactions'),
|
|
573
|
+
this.sentTransactions = (req, headers, signal) => {
|
|
574
|
+
return this.fetch(this.url('SentTransactions'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
610
575
|
return buildResponse(res).then(_data => {
|
|
611
|
-
return
|
|
612
|
-
page: _data.page,
|
|
613
|
-
transactions: _data.transactions
|
|
614
|
-
};
|
|
576
|
+
return JsonDecode(_data, 'SentTransactionsReturn');
|
|
615
577
|
});
|
|
616
578
|
}, error => {
|
|
617
579
|
throw WebrpcRequestFailedError.new({
|
|
618
|
-
cause: `fetch(): ${error.message
|
|
580
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
619
581
|
});
|
|
620
582
|
});
|
|
621
583
|
};
|
|
622
|
-
this.pendingTransactions = (
|
|
623
|
-
return this.fetch(this.url('PendingTransactions'),
|
|
584
|
+
this.pendingTransactions = (req, headers, signal) => {
|
|
585
|
+
return this.fetch(this.url('PendingTransactions'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
624
586
|
return buildResponse(res).then(_data => {
|
|
625
|
-
return
|
|
626
|
-
page: _data.page,
|
|
627
|
-
transactions: _data.transactions
|
|
628
|
-
};
|
|
587
|
+
return JsonDecode(_data, 'PendingTransactionsReturn');
|
|
629
588
|
});
|
|
630
589
|
}, error => {
|
|
631
590
|
throw WebrpcRequestFailedError.new({
|
|
632
|
-
cause: `fetch(): ${error.message
|
|
591
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
633
592
|
});
|
|
634
593
|
});
|
|
635
594
|
};
|
|
636
|
-
this.getGasTank = (
|
|
637
|
-
return this.fetch(this.url('GetGasTank'),
|
|
595
|
+
this.getGasTank = (req, headers, signal) => {
|
|
596
|
+
return this.fetch(this.url('GetGasTank'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
638
597
|
return buildResponse(res).then(_data => {
|
|
639
|
-
return
|
|
640
|
-
gasTank: _data.gasTank
|
|
641
|
-
};
|
|
598
|
+
return JsonDecode(_data, 'GetGasTankReturn');
|
|
642
599
|
});
|
|
643
600
|
}, error => {
|
|
644
601
|
throw WebrpcRequestFailedError.new({
|
|
645
|
-
cause: `fetch(): ${error.message
|
|
602
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
646
603
|
});
|
|
647
604
|
});
|
|
648
605
|
};
|
|
649
|
-
this.addGasTank = (
|
|
650
|
-
return this.fetch(this.url('AddGasTank'),
|
|
606
|
+
this.addGasTank = (req, headers, signal) => {
|
|
607
|
+
return this.fetch(this.url('AddGasTank'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
651
608
|
return buildResponse(res).then(_data => {
|
|
652
|
-
return
|
|
653
|
-
status: _data.status,
|
|
654
|
-
gasTank: _data.gasTank
|
|
655
|
-
};
|
|
609
|
+
return JsonDecode(_data, 'AddGasTankReturn');
|
|
656
610
|
});
|
|
657
611
|
}, error => {
|
|
658
612
|
throw WebrpcRequestFailedError.new({
|
|
659
|
-
cause: `fetch(): ${error.message
|
|
613
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
660
614
|
});
|
|
661
615
|
});
|
|
662
616
|
};
|
|
663
|
-
this.updateGasTank = (
|
|
664
|
-
return this.fetch(this.url('UpdateGasTank'),
|
|
617
|
+
this.updateGasTank = (req, headers, signal) => {
|
|
618
|
+
return this.fetch(this.url('UpdateGasTank'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
665
619
|
return buildResponse(res).then(_data => {
|
|
666
|
-
return
|
|
667
|
-
status: _data.status,
|
|
668
|
-
gasTank: _data.gasTank
|
|
669
|
-
};
|
|
620
|
+
return JsonDecode(_data, 'UpdateGasTankReturn');
|
|
670
621
|
});
|
|
671
622
|
}, error => {
|
|
672
623
|
throw WebrpcRequestFailedError.new({
|
|
673
|
-
cause: `fetch(): ${error.message
|
|
624
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
674
625
|
});
|
|
675
626
|
});
|
|
676
627
|
};
|
|
677
|
-
this.nextGasTankBalanceAdjustmentNonce = (
|
|
678
|
-
return this.fetch(this.url('NextGasTankBalanceAdjustmentNonce'),
|
|
628
|
+
this.nextGasTankBalanceAdjustmentNonce = (req, headers, signal) => {
|
|
629
|
+
return this.fetch(this.url('NextGasTankBalanceAdjustmentNonce'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
679
630
|
return buildResponse(res).then(_data => {
|
|
680
|
-
return
|
|
681
|
-
nonce: _data.nonce
|
|
682
|
-
};
|
|
631
|
+
return JsonDecode(_data, 'NextGasTankBalanceAdjustmentNonceReturn');
|
|
683
632
|
});
|
|
684
633
|
}, error => {
|
|
685
634
|
throw WebrpcRequestFailedError.new({
|
|
686
|
-
cause: `fetch(): ${error.message
|
|
635
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
687
636
|
});
|
|
688
637
|
});
|
|
689
638
|
};
|
|
690
|
-
this.adjustGasTankBalance = (
|
|
691
|
-
return this.fetch(this.url('AdjustGasTankBalance'),
|
|
639
|
+
this.adjustGasTankBalance = (req, headers, signal) => {
|
|
640
|
+
return this.fetch(this.url('AdjustGasTankBalance'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
692
641
|
return buildResponse(res).then(_data => {
|
|
693
|
-
return
|
|
694
|
-
status: _data.status,
|
|
695
|
-
adjustment: _data.adjustment
|
|
696
|
-
};
|
|
642
|
+
return JsonDecode(_data, 'AdjustGasTankBalanceReturn');
|
|
697
643
|
});
|
|
698
644
|
}, error => {
|
|
699
645
|
throw WebrpcRequestFailedError.new({
|
|
700
|
-
cause: `fetch(): ${error.message
|
|
646
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
701
647
|
});
|
|
702
648
|
});
|
|
703
649
|
};
|
|
704
|
-
this.getGasTankBalanceAdjustment = (
|
|
705
|
-
return this.fetch(this.url('GetGasTankBalanceAdjustment'),
|
|
650
|
+
this.getGasTankBalanceAdjustment = (req, headers, signal) => {
|
|
651
|
+
return this.fetch(this.url('GetGasTankBalanceAdjustment'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
706
652
|
return buildResponse(res).then(_data => {
|
|
707
|
-
return
|
|
708
|
-
adjustment: _data.adjustment
|
|
709
|
-
};
|
|
653
|
+
return JsonDecode(_data, 'GetGasTankBalanceAdjustmentReturn');
|
|
710
654
|
});
|
|
711
655
|
}, error => {
|
|
712
656
|
throw WebrpcRequestFailedError.new({
|
|
713
|
-
cause: `fetch(): ${error.message
|
|
657
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
714
658
|
});
|
|
715
659
|
});
|
|
716
660
|
};
|
|
717
|
-
this.listGasTankBalanceAdjustments = (
|
|
718
|
-
return this.fetch(this.url('ListGasTankBalanceAdjustments'),
|
|
661
|
+
this.listGasTankBalanceAdjustments = (req, headers, signal) => {
|
|
662
|
+
return this.fetch(this.url('ListGasTankBalanceAdjustments'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
719
663
|
return buildResponse(res).then(_data => {
|
|
720
|
-
return
|
|
721
|
-
page: _data.page,
|
|
722
|
-
adjustments: _data.adjustments
|
|
723
|
-
};
|
|
664
|
+
return JsonDecode(_data, 'ListGasTankBalanceAdjustmentsReturn');
|
|
724
665
|
});
|
|
725
666
|
}, error => {
|
|
726
667
|
throw WebrpcRequestFailedError.new({
|
|
727
|
-
cause: `fetch(): ${error.message
|
|
668
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
728
669
|
});
|
|
729
670
|
});
|
|
730
671
|
};
|
|
731
|
-
this.listGasSponsors = (
|
|
732
|
-
return this.fetch(this.url('ListGasSponsors'),
|
|
672
|
+
this.listGasSponsors = (req, headers, signal) => {
|
|
673
|
+
return this.fetch(this.url('ListGasSponsors'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
733
674
|
return buildResponse(res).then(_data => {
|
|
734
|
-
return
|
|
735
|
-
page: _data.page,
|
|
736
|
-
gasSponsors: _data.gasSponsors
|
|
737
|
-
};
|
|
675
|
+
return JsonDecode(_data, 'ListGasSponsorsReturn');
|
|
738
676
|
});
|
|
739
677
|
}, error => {
|
|
740
678
|
throw WebrpcRequestFailedError.new({
|
|
741
|
-
cause: `fetch(): ${error.message
|
|
679
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
742
680
|
});
|
|
743
681
|
});
|
|
744
682
|
};
|
|
745
|
-
this.getGasSponsor = (
|
|
746
|
-
return this.fetch(this.url('GetGasSponsor'),
|
|
683
|
+
this.getGasSponsor = (req, headers, signal) => {
|
|
684
|
+
return this.fetch(this.url('GetGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
747
685
|
return buildResponse(res).then(_data => {
|
|
748
|
-
return
|
|
749
|
-
gasSponsor: _data.gasSponsor
|
|
750
|
-
};
|
|
686
|
+
return JsonDecode(_data, 'GetGasSponsorReturn');
|
|
751
687
|
});
|
|
752
688
|
}, error => {
|
|
753
689
|
throw WebrpcRequestFailedError.new({
|
|
754
|
-
cause: `fetch(): ${error.message
|
|
690
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
755
691
|
});
|
|
756
692
|
});
|
|
757
693
|
};
|
|
758
|
-
this.addGasSponsor = (
|
|
759
|
-
return this.fetch(this.url('AddGasSponsor'),
|
|
694
|
+
this.addGasSponsor = (req, headers, signal) => {
|
|
695
|
+
return this.fetch(this.url('AddGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
760
696
|
return buildResponse(res).then(_data => {
|
|
761
|
-
return
|
|
762
|
-
status: _data.status,
|
|
763
|
-
gasSponsor: _data.gasSponsor
|
|
764
|
-
};
|
|
697
|
+
return JsonDecode(_data, 'AddGasSponsorReturn');
|
|
765
698
|
});
|
|
766
699
|
}, error => {
|
|
767
700
|
throw WebrpcRequestFailedError.new({
|
|
768
|
-
cause: `fetch(): ${error.message
|
|
701
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
769
702
|
});
|
|
770
703
|
});
|
|
771
704
|
};
|
|
772
|
-
this.updateGasSponsor = (
|
|
773
|
-
return this.fetch(this.url('UpdateGasSponsor'),
|
|
705
|
+
this.updateGasSponsor = (req, headers, signal) => {
|
|
706
|
+
return this.fetch(this.url('UpdateGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
774
707
|
return buildResponse(res).then(_data => {
|
|
775
|
-
return
|
|
776
|
-
status: _data.status,
|
|
777
|
-
gasSponsor: _data.gasSponsor
|
|
778
|
-
};
|
|
708
|
+
return JsonDecode(_data, 'UpdateGasSponsorReturn');
|
|
779
709
|
});
|
|
780
710
|
}, error => {
|
|
781
711
|
throw WebrpcRequestFailedError.new({
|
|
782
|
-
cause: `fetch(): ${error.message
|
|
712
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
783
713
|
});
|
|
784
714
|
});
|
|
785
715
|
};
|
|
786
|
-
this.removeGasSponsor = (
|
|
787
|
-
return this.fetch(this.url('RemoveGasSponsor'),
|
|
716
|
+
this.removeGasSponsor = (req, headers, signal) => {
|
|
717
|
+
return this.fetch(this.url('RemoveGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
788
718
|
return buildResponse(res).then(_data => {
|
|
789
|
-
return
|
|
790
|
-
status: _data.status
|
|
791
|
-
};
|
|
719
|
+
return JsonDecode(_data, 'RemoveGasSponsorReturn');
|
|
792
720
|
});
|
|
793
721
|
}, error => {
|
|
794
722
|
throw WebrpcRequestFailedError.new({
|
|
795
|
-
cause: `fetch(): ${error.message
|
|
723
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
796
724
|
});
|
|
797
725
|
});
|
|
798
726
|
};
|
|
799
|
-
this.addressGasSponsors = (
|
|
800
|
-
return this.fetch(this.url('AddressGasSponsors'),
|
|
727
|
+
this.addressGasSponsors = (req, headers, signal) => {
|
|
728
|
+
return this.fetch(this.url('AddressGasSponsors'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
801
729
|
return buildResponse(res).then(_data => {
|
|
802
|
-
return
|
|
803
|
-
page: _data.page,
|
|
804
|
-
gasSponsors: _data.gasSponsors
|
|
805
|
-
};
|
|
730
|
+
return JsonDecode(_data, 'AddressGasSponsorsReturn');
|
|
806
731
|
});
|
|
807
732
|
}, error => {
|
|
808
733
|
throw WebrpcRequestFailedError.new({
|
|
809
|
-
cause: `fetch(): ${error.message
|
|
734
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
810
735
|
});
|
|
811
736
|
});
|
|
812
737
|
};
|
|
813
|
-
this.getProjectBalance = (
|
|
814
|
-
return this.fetch(this.url('GetProjectBalance'),
|
|
738
|
+
this.getProjectBalance = (req, headers, signal) => {
|
|
739
|
+
return this.fetch(this.url('GetProjectBalance'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
815
740
|
return buildResponse(res).then(_data => {
|
|
816
|
-
return
|
|
817
|
-
balance: _data.balance
|
|
818
|
-
};
|
|
741
|
+
return JsonDecode(_data, 'GetProjectBalanceReturn');
|
|
819
742
|
});
|
|
820
743
|
}, error => {
|
|
821
744
|
throw WebrpcRequestFailedError.new({
|
|
822
|
-
cause: `fetch(): ${error.message
|
|
745
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
823
746
|
});
|
|
824
747
|
});
|
|
825
748
|
};
|
|
826
|
-
this.adjustProjectBalance = (
|
|
827
|
-
return this.fetch(this.url('AdjustProjectBalance'),
|
|
749
|
+
this.adjustProjectBalance = (req, headers, signal) => {
|
|
750
|
+
return this.fetch(this.url('AdjustProjectBalance'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
828
751
|
return buildResponse(res).then(_data => {
|
|
829
|
-
return
|
|
830
|
-
balance: _data.balance
|
|
831
|
-
};
|
|
752
|
+
return JsonDecode(_data, 'AdjustProjectBalanceReturn');
|
|
832
753
|
});
|
|
833
754
|
}, error => {
|
|
834
755
|
throw WebrpcRequestFailedError.new({
|
|
835
|
-
cause: `fetch(): ${error.message
|
|
756
|
+
cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
|
|
836
757
|
});
|
|
837
758
|
});
|
|
838
759
|
};
|
|
@@ -843,15 +764,15 @@ class Relayer {
|
|
|
843
764
|
return this.hostname + this.path + name;
|
|
844
765
|
}
|
|
845
766
|
}
|
|
846
|
-
const
|
|
767
|
+
const createHttpRequest = (body = '{}', headers = {}, signal = null) => {
|
|
847
768
|
const reqHeaders = _extends({}, headers, {
|
|
848
|
-
'Content-Type': 'application/json'
|
|
769
|
+
'Content-Type': 'application/json',
|
|
770
|
+
[WebrpcHeader]: WebrpcHeaderValue
|
|
849
771
|
});
|
|
850
|
-
reqHeaders[WebrpcHeader] = WebrpcHeaderValue;
|
|
851
772
|
return {
|
|
852
773
|
method: 'POST',
|
|
853
774
|
headers: reqHeaders,
|
|
854
|
-
body
|
|
775
|
+
body,
|
|
855
776
|
signal
|
|
856
777
|
};
|
|
857
778
|
};
|
|
@@ -861,13 +782,9 @@ const buildResponse = res => {
|
|
|
861
782
|
try {
|
|
862
783
|
data = JSON.parse(text);
|
|
863
784
|
} catch (error) {
|
|
864
|
-
let message = '';
|
|
865
|
-
if (error instanceof Error) {
|
|
866
|
-
message = error.message;
|
|
867
|
-
}
|
|
868
785
|
throw WebrpcBadResponseError.new({
|
|
869
786
|
status: res.status,
|
|
870
|
-
cause: `JSON.parse(): ${message}: response text: ${text}`
|
|
787
|
+
cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`
|
|
871
788
|
});
|
|
872
789
|
}
|
|
873
790
|
if (!res.ok) {
|
|
@@ -877,264 +794,542 @@ const buildResponse = res => {
|
|
|
877
794
|
return data;
|
|
878
795
|
});
|
|
879
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
|
+
};
|
|
880
887
|
|
|
881
888
|
//
|
|
882
889
|
// Errors
|
|
883
890
|
//
|
|
884
891
|
|
|
885
892
|
class WebrpcError extends Error {
|
|
886
|
-
constructor(
|
|
887
|
-
super(message);
|
|
888
|
-
this.name = void 0;
|
|
893
|
+
constructor(error = {}) {
|
|
894
|
+
super(error.message);
|
|
889
895
|
this.code = void 0;
|
|
890
|
-
this.message = void 0;
|
|
891
896
|
this.status = void 0;
|
|
892
|
-
this.
|
|
893
|
-
|
|
894
|
-
this.
|
|
895
|
-
this.
|
|
896
|
-
|
|
897
|
-
this.message = message || `endpoint error ${this.code}`;
|
|
898
|
-
this.msg = this.message;
|
|
899
|
-
this.status = typeof status === 'number' ? status : 0;
|
|
900
|
-
this.cause = cause;
|
|
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;
|
|
901
902
|
Object.setPrototypeOf(this, WebrpcError.prototype);
|
|
902
903
|
}
|
|
903
904
|
static new(payload) {
|
|
904
|
-
return new this(
|
|
905
|
+
return new this({
|
|
906
|
+
message: payload.message,
|
|
907
|
+
code: payload.code,
|
|
908
|
+
status: payload.status,
|
|
909
|
+
cause: payload.cause
|
|
910
|
+
});
|
|
905
911
|
}
|
|
906
912
|
}
|
|
907
|
-
|
|
908
|
-
// Webrpc errors
|
|
909
|
-
|
|
910
913
|
class WebrpcEndpointError extends WebrpcError {
|
|
911
|
-
constructor(
|
|
912
|
-
super(
|
|
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;
|
|
913
921
|
Object.setPrototypeOf(this, WebrpcEndpointError.prototype);
|
|
914
922
|
}
|
|
915
923
|
}
|
|
916
924
|
class WebrpcRequestFailedError extends WebrpcError {
|
|
917
|
-
constructor(
|
|
918
|
-
super(
|
|
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;
|
|
919
932
|
Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype);
|
|
920
933
|
}
|
|
921
934
|
}
|
|
922
935
|
class WebrpcBadRouteError extends WebrpcError {
|
|
923
|
-
constructor(
|
|
924
|
-
super(
|
|
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;
|
|
925
943
|
Object.setPrototypeOf(this, WebrpcBadRouteError.prototype);
|
|
926
944
|
}
|
|
927
945
|
}
|
|
928
946
|
class WebrpcBadMethodError extends WebrpcError {
|
|
929
|
-
constructor(
|
|
930
|
-
super(
|
|
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;
|
|
931
954
|
Object.setPrototypeOf(this, WebrpcBadMethodError.prototype);
|
|
932
955
|
}
|
|
933
956
|
}
|
|
934
957
|
class WebrpcBadRequestError extends WebrpcError {
|
|
935
|
-
constructor(
|
|
936
|
-
super(
|
|
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;
|
|
937
965
|
Object.setPrototypeOf(this, WebrpcBadRequestError.prototype);
|
|
938
966
|
}
|
|
939
967
|
}
|
|
940
968
|
class WebrpcBadResponseError extends WebrpcError {
|
|
941
|
-
constructor(
|
|
942
|
-
super(
|
|
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;
|
|
943
976
|
Object.setPrototypeOf(this, WebrpcBadResponseError.prototype);
|
|
944
977
|
}
|
|
945
978
|
}
|
|
946
979
|
class WebrpcServerPanicError extends WebrpcError {
|
|
947
|
-
constructor(
|
|
948
|
-
super(
|
|
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;
|
|
949
987
|
Object.setPrototypeOf(this, WebrpcServerPanicError.prototype);
|
|
950
988
|
}
|
|
951
989
|
}
|
|
952
990
|
class WebrpcInternalErrorError extends WebrpcError {
|
|
953
|
-
constructor(
|
|
954
|
-
super(
|
|
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;
|
|
955
998
|
Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype);
|
|
956
999
|
}
|
|
957
1000
|
}
|
|
958
|
-
class
|
|
959
|
-
constructor(
|
|
960
|
-
super(
|
|
961
|
-
|
|
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);
|
|
962
1010
|
}
|
|
963
1011
|
}
|
|
964
1012
|
class WebrpcStreamLostError extends WebrpcError {
|
|
965
|
-
constructor(
|
|
966
|
-
super(
|
|
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;
|
|
967
1020
|
Object.setPrototypeOf(this, WebrpcStreamLostError.prototype);
|
|
968
1021
|
}
|
|
969
1022
|
}
|
|
970
1023
|
class WebrpcStreamFinishedError extends WebrpcError {
|
|
971
|
-
constructor(
|
|
972
|
-
super(
|
|
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;
|
|
973
1031
|
Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype);
|
|
974
1032
|
}
|
|
975
1033
|
}
|
|
976
1034
|
|
|
1035
|
+
//
|
|
977
1036
|
// Schema errors
|
|
1037
|
+
//
|
|
978
1038
|
|
|
979
1039
|
class UnauthorizedError extends WebrpcError {
|
|
980
|
-
constructor(
|
|
981
|
-
super(
|
|
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;
|
|
982
1047
|
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
983
1048
|
}
|
|
984
1049
|
}
|
|
985
1050
|
class PermissionDeniedError extends WebrpcError {
|
|
986
|
-
constructor(
|
|
987
|
-
super(
|
|
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;
|
|
988
1058
|
Object.setPrototypeOf(this, PermissionDeniedError.prototype);
|
|
989
1059
|
}
|
|
990
1060
|
}
|
|
991
1061
|
class SessionExpiredError extends WebrpcError {
|
|
992
|
-
constructor(
|
|
993
|
-
super(
|
|
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;
|
|
994
1069
|
Object.setPrototypeOf(this, SessionExpiredError.prototype);
|
|
995
1070
|
}
|
|
996
1071
|
}
|
|
997
1072
|
class MethodNotFoundError extends WebrpcError {
|
|
998
|
-
constructor(
|
|
999
|
-
super(
|
|
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;
|
|
1000
1080
|
Object.setPrototypeOf(this, MethodNotFoundError.prototype);
|
|
1001
1081
|
}
|
|
1002
1082
|
}
|
|
1003
1083
|
class RequestConflictError extends WebrpcError {
|
|
1004
|
-
constructor(
|
|
1005
|
-
super(
|
|
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;
|
|
1006
1091
|
Object.setPrototypeOf(this, RequestConflictError.prototype);
|
|
1007
1092
|
}
|
|
1008
1093
|
}
|
|
1009
1094
|
class AbortedError extends WebrpcError {
|
|
1010
|
-
constructor(
|
|
1011
|
-
super(
|
|
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;
|
|
1012
1102
|
Object.setPrototypeOf(this, AbortedError.prototype);
|
|
1013
1103
|
}
|
|
1014
1104
|
}
|
|
1015
1105
|
class GeoblockedError extends WebrpcError {
|
|
1016
|
-
constructor(
|
|
1017
|
-
super(
|
|
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;
|
|
1018
1113
|
Object.setPrototypeOf(this, GeoblockedError.prototype);
|
|
1019
1114
|
}
|
|
1020
1115
|
}
|
|
1021
1116
|
class RateLimitedError extends WebrpcError {
|
|
1022
|
-
constructor(
|
|
1023
|
-
super(
|
|
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;
|
|
1024
1124
|
Object.setPrototypeOf(this, RateLimitedError.prototype);
|
|
1025
1125
|
}
|
|
1026
1126
|
}
|
|
1027
1127
|
class ProjectNotFoundError extends WebrpcError {
|
|
1028
|
-
constructor(
|
|
1029
|
-
super(
|
|
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;
|
|
1030
1135
|
Object.setPrototypeOf(this, ProjectNotFoundError.prototype);
|
|
1031
1136
|
}
|
|
1032
1137
|
}
|
|
1033
1138
|
class AccessKeyNotFoundError extends WebrpcError {
|
|
1034
|
-
constructor(
|
|
1035
|
-
super(
|
|
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;
|
|
1036
1146
|
Object.setPrototypeOf(this, AccessKeyNotFoundError.prototype);
|
|
1037
1147
|
}
|
|
1038
1148
|
}
|
|
1039
1149
|
class AccessKeyMismatchError extends WebrpcError {
|
|
1040
|
-
constructor(
|
|
1041
|
-
super(
|
|
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;
|
|
1042
1157
|
Object.setPrototypeOf(this, AccessKeyMismatchError.prototype);
|
|
1043
1158
|
}
|
|
1044
1159
|
}
|
|
1045
1160
|
class InvalidOriginError extends WebrpcError {
|
|
1046
|
-
constructor(
|
|
1047
|
-
super(
|
|
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;
|
|
1048
1168
|
Object.setPrototypeOf(this, InvalidOriginError.prototype);
|
|
1049
1169
|
}
|
|
1050
1170
|
}
|
|
1051
1171
|
class InvalidServiceError extends WebrpcError {
|
|
1052
|
-
constructor(
|
|
1053
|
-
super(
|
|
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;
|
|
1054
1179
|
Object.setPrototypeOf(this, InvalidServiceError.prototype);
|
|
1055
1180
|
}
|
|
1056
1181
|
}
|
|
1057
1182
|
class UnauthorizedUserError extends WebrpcError {
|
|
1058
|
-
constructor(
|
|
1059
|
-
super(
|
|
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;
|
|
1060
1190
|
Object.setPrototypeOf(this, UnauthorizedUserError.prototype);
|
|
1061
1191
|
}
|
|
1062
1192
|
}
|
|
1063
1193
|
class QuotaExceededError extends WebrpcError {
|
|
1064
|
-
constructor(
|
|
1065
|
-
super(
|
|
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;
|
|
1066
1201
|
Object.setPrototypeOf(this, QuotaExceededError.prototype);
|
|
1067
1202
|
}
|
|
1068
1203
|
}
|
|
1069
1204
|
class QuotaRateLimitError extends WebrpcError {
|
|
1070
|
-
constructor(
|
|
1071
|
-
super(
|
|
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;
|
|
1072
1212
|
Object.setPrototypeOf(this, QuotaRateLimitError.prototype);
|
|
1073
1213
|
}
|
|
1074
1214
|
}
|
|
1075
1215
|
class NoDefaultKeyError extends WebrpcError {
|
|
1076
|
-
constructor(
|
|
1077
|
-
super(
|
|
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;
|
|
1078
1223
|
Object.setPrototypeOf(this, NoDefaultKeyError.prototype);
|
|
1079
1224
|
}
|
|
1080
1225
|
}
|
|
1081
1226
|
class MaxAccessKeysError extends WebrpcError {
|
|
1082
|
-
constructor(
|
|
1083
|
-
super(
|
|
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;
|
|
1084
1234
|
Object.setPrototypeOf(this, MaxAccessKeysError.prototype);
|
|
1085
1235
|
}
|
|
1086
1236
|
}
|
|
1087
1237
|
class AtLeastOneKeyError extends WebrpcError {
|
|
1088
|
-
constructor(
|
|
1089
|
-
super(
|
|
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;
|
|
1090
1245
|
Object.setPrototypeOf(this, AtLeastOneKeyError.prototype);
|
|
1091
1246
|
}
|
|
1092
1247
|
}
|
|
1093
1248
|
class TimeoutError extends WebrpcError {
|
|
1094
|
-
constructor(
|
|
1095
|
-
super(
|
|
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;
|
|
1096
1256
|
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
1097
1257
|
}
|
|
1098
1258
|
}
|
|
1099
1259
|
class InvalidArgumentError extends WebrpcError {
|
|
1100
|
-
constructor(
|
|
1101
|
-
super(
|
|
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;
|
|
1102
1267
|
Object.setPrototypeOf(this, InvalidArgumentError.prototype);
|
|
1103
1268
|
}
|
|
1104
1269
|
}
|
|
1105
1270
|
class UnavailableError extends WebrpcError {
|
|
1106
|
-
constructor(
|
|
1107
|
-
super(
|
|
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;
|
|
1108
1278
|
Object.setPrototypeOf(this, UnavailableError.prototype);
|
|
1109
1279
|
}
|
|
1110
1280
|
}
|
|
1111
1281
|
class QueryFailedError extends WebrpcError {
|
|
1112
|
-
constructor(
|
|
1113
|
-
super(
|
|
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;
|
|
1114
1289
|
Object.setPrototypeOf(this, QueryFailedError.prototype);
|
|
1115
1290
|
}
|
|
1116
1291
|
}
|
|
1117
1292
|
class NotFoundError extends WebrpcError {
|
|
1118
|
-
constructor(
|
|
1119
|
-
super(
|
|
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;
|
|
1120
1300
|
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
1121
1301
|
}
|
|
1122
1302
|
}
|
|
1123
1303
|
class InsufficientFeeError extends WebrpcError {
|
|
1124
|
-
constructor(
|
|
1125
|
-
super(
|
|
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;
|
|
1126
1311
|
Object.setPrototypeOf(this, InsufficientFeeError.prototype);
|
|
1127
1312
|
}
|
|
1128
1313
|
}
|
|
1129
1314
|
class NotEnoughBalanceError extends WebrpcError {
|
|
1130
|
-
constructor(
|
|
1131
|
-
super(
|
|
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;
|
|
1132
1322
|
Object.setPrototypeOf(this, NotEnoughBalanceError.prototype);
|
|
1133
1323
|
}
|
|
1134
1324
|
}
|
|
1135
1325
|
class SimulationFailedError extends WebrpcError {
|
|
1136
|
-
constructor(
|
|
1137
|
-
super(
|
|
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;
|
|
1138
1333
|
Object.setPrototypeOf(this, SimulationFailedError.prototype);
|
|
1139
1334
|
}
|
|
1140
1335
|
}
|
|
@@ -1147,7 +1342,7 @@ let errors = /*#__PURE__*/function (errors) {
|
|
|
1147
1342
|
errors["WebrpcBadResponse"] = "WebrpcBadResponse";
|
|
1148
1343
|
errors["WebrpcServerPanic"] = "WebrpcServerPanic";
|
|
1149
1344
|
errors["WebrpcInternalError"] = "WebrpcInternalError";
|
|
1150
|
-
errors["
|
|
1345
|
+
errors["WebrpcClientAborted"] = "WebrpcClientAborted";
|
|
1151
1346
|
errors["WebrpcStreamLost"] = "WebrpcStreamLost";
|
|
1152
1347
|
errors["WebrpcStreamFinished"] = "WebrpcStreamFinished";
|
|
1153
1348
|
errors["Unauthorized"] = "Unauthorized";
|
|
@@ -1188,7 +1383,7 @@ let WebrpcErrorCodes = /*#__PURE__*/function (WebrpcErrorCodes) {
|
|
|
1188
1383
|
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadResponse"] = -5] = "WebrpcBadResponse";
|
|
1189
1384
|
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcServerPanic"] = -6] = "WebrpcServerPanic";
|
|
1190
1385
|
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcInternalError"] = -7] = "WebrpcInternalError";
|
|
1191
|
-
WebrpcErrorCodes[WebrpcErrorCodes["
|
|
1386
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcClientAborted"] = -8] = "WebrpcClientAborted";
|
|
1192
1387
|
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamLost"] = -9] = "WebrpcStreamLost";
|
|
1193
1388
|
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamFinished"] = -10] = "WebrpcStreamFinished";
|
|
1194
1389
|
WebrpcErrorCodes[WebrpcErrorCodes["Unauthorized"] = 1000] = "Unauthorized";
|
|
@@ -1229,7 +1424,7 @@ const webrpcErrorByCode = {
|
|
|
1229
1424
|
[-5]: WebrpcBadResponseError,
|
|
1230
1425
|
[-6]: WebrpcServerPanicError,
|
|
1231
1426
|
[-7]: WebrpcInternalErrorError,
|
|
1232
|
-
[-8]:
|
|
1427
|
+
[-8]: WebrpcClientAbortedError,
|
|
1233
1428
|
[-9]: WebrpcStreamLostError,
|
|
1234
1429
|
[-10]: WebrpcStreamFinishedError,
|
|
1235
1430
|
[1000]: UnauthorizedError,
|
|
@@ -1261,20 +1456,61 @@ const webrpcErrorByCode = {
|
|
|
1261
1456
|
[3006]: SimulationFailedError
|
|
1262
1457
|
};
|
|
1263
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
|
+
|
|
1264
1501
|
var relayer_gen = /*#__PURE__*/Object.freeze({
|
|
1265
1502
|
__proto__: null,
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
WebRPCSchemaVersion: WebRPCSchemaVersion,
|
|
1270
|
-
WebRPCSchemaHash: WebRPCSchemaHash,
|
|
1271
|
-
VersionFromHeader: VersionFromHeader,
|
|
1503
|
+
WebrpcVersion: WebrpcVersion,
|
|
1504
|
+
WebrpcSchemaVersion: WebrpcSchemaVersion,
|
|
1505
|
+
WebrpcSchemaHash: WebrpcSchemaHash,
|
|
1272
1506
|
ETHTxnStatus: ETHTxnStatus,
|
|
1273
1507
|
TransferType: TransferType,
|
|
1274
1508
|
SimulateStatus: SimulateStatus,
|
|
1275
1509
|
FeeTokenType: FeeTokenType,
|
|
1276
1510
|
SortOrder: SortOrder,
|
|
1277
1511
|
Relayer: Relayer,
|
|
1512
|
+
JsonEncode: JsonEncode,
|
|
1513
|
+
JsonDecode: JsonDecode,
|
|
1278
1514
|
WebrpcError: WebrpcError,
|
|
1279
1515
|
WebrpcEndpointError: WebrpcEndpointError,
|
|
1280
1516
|
WebrpcRequestFailedError: WebrpcRequestFailedError,
|
|
@@ -1284,7 +1520,7 @@ var relayer_gen = /*#__PURE__*/Object.freeze({
|
|
|
1284
1520
|
WebrpcBadResponseError: WebrpcBadResponseError,
|
|
1285
1521
|
WebrpcServerPanicError: WebrpcServerPanicError,
|
|
1286
1522
|
WebrpcInternalErrorError: WebrpcInternalErrorError,
|
|
1287
|
-
|
|
1523
|
+
WebrpcClientAbortedError: WebrpcClientAbortedError,
|
|
1288
1524
|
WebrpcStreamLostError: WebrpcStreamLostError,
|
|
1289
1525
|
WebrpcStreamFinishedError: WebrpcStreamFinishedError,
|
|
1290
1526
|
UnauthorizedError: UnauthorizedError,
|
|
@@ -1316,7 +1552,10 @@ var relayer_gen = /*#__PURE__*/Object.freeze({
|
|
|
1316
1552
|
SimulationFailedError: SimulationFailedError,
|
|
1317
1553
|
errors: errors,
|
|
1318
1554
|
WebrpcErrorCodes: WebrpcErrorCodes,
|
|
1319
|
-
webrpcErrorByCode: webrpcErrorByCode
|
|
1555
|
+
webrpcErrorByCode: webrpcErrorByCode,
|
|
1556
|
+
WebrpcHeader: WebrpcHeader,
|
|
1557
|
+
WebrpcHeaderValue: WebrpcHeaderValue,
|
|
1558
|
+
VersionFromHeader: VersionFromHeader
|
|
1320
1559
|
});
|
|
1321
1560
|
|
|
1322
1561
|
const FINAL_STATUSES = [ETHTxnStatus.DROPPED, ETHTxnStatus.SUCCEEDED, ETHTxnStatus.PARTIALLY_FAILED, ETHTxnStatus.FAILED];
|