@0xsequence/relayer 2.2.9 → 2.2.11

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.
@@ -1,10 +1,14 @@
1
1
  /* eslint-disable */
2
- // sequence-relayer v0.4.1 dd95e21fa884c6564199bc3dd5f588534827ffe2
2
+ // sequence-relayer v0.4.1 9c42435ea10493aecdfbbecb2be284b8dd721539
3
3
  // --
4
- // Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT.
4
+ // Code generated by webrpc-gen@v0.22.0 with typescript generator. DO NOT EDIT.
5
5
  //
6
6
  // webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts
7
7
 
8
+ export const WebrpcHeader = 'Webrpc'
9
+
10
+ export const WebrpcHeaderValue = 'webrpc@v0.22.0;gen-typescript@v0.16.1;sequence-relayer@v0.4.1'
11
+
8
12
  // WebRPC description and code-gen version
9
13
  export const WebRPCVersion = 'v1'
10
14
 
@@ -12,7 +16,55 @@ export const WebRPCVersion = 'v1'
12
16
  export const WebRPCSchemaVersion = 'v0.4.1'
13
17
 
14
18
  // Schema hash generated from your RIDL schema
15
- export const WebRPCSchemaHash = 'dd95e21fa884c6564199bc3dd5f588534827ffe2'
19
+ export const WebRPCSchemaHash = '9c42435ea10493aecdfbbecb2be284b8dd721539'
20
+
21
+ type WebrpcGenVersions = {
22
+ webrpcGenVersion: string
23
+ codeGenName: string
24
+ codeGenVersion: string
25
+ schemaName: string
26
+ schemaVersion: string
27
+ }
28
+
29
+ export function VersionFromHeader(headers: Headers): WebrpcGenVersions {
30
+ const headerValue = headers.get(WebrpcHeader)
31
+ if (!headerValue) {
32
+ return {
33
+ webrpcGenVersion: '',
34
+ codeGenName: '',
35
+ codeGenVersion: '',
36
+ schemaName: '',
37
+ schemaVersion: ''
38
+ }
39
+ }
40
+
41
+ return parseWebrpcGenVersions(headerValue)
42
+ }
43
+
44
+ function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
45
+ const versions = header.split(';')
46
+ if (versions.length < 3) {
47
+ return {
48
+ webrpcGenVersion: '',
49
+ codeGenName: '',
50
+ codeGenVersion: '',
51
+ schemaName: '',
52
+ schemaVersion: ''
53
+ }
54
+ }
55
+
56
+ const [_, webrpcGenVersion] = versions[0].split('@')
57
+ const [codeGenName, codeGenVersion] = versions[1].split('@')
58
+ const [schemaName, schemaVersion] = versions[2].split('@')
59
+
60
+ return {
61
+ webrpcGenVersion,
62
+ codeGenName,
63
+ codeGenVersion,
64
+ schemaName,
65
+ schemaVersion
66
+ }
67
+ }
16
68
 
17
69
  //
18
70
  // Types
@@ -162,6 +214,7 @@ export interface MetaTxnLog {
162
214
  gasFeeMarkup?: number
163
215
  usdRate: string
164
216
  creditsUsed: number
217
+ cost: string
165
218
  isWhitelisted: boolean
166
219
  gasSponsor?: number
167
220
  gasTank?: number
@@ -285,17 +338,6 @@ export interface Relayer {
285
338
  getGasTank(args: GetGasTankArgs, headers?: object, signal?: AbortSignal): Promise<GetGasTankReturn>
286
339
  addGasTank(args: AddGasTankArgs, headers?: object, signal?: AbortSignal): Promise<AddGasTankReturn>
287
340
  updateGasTank(args: UpdateGasTankArgs, headers?: object, signal?: AbortSignal): Promise<UpdateGasTankReturn>
288
- getGasSponsor(args: GetGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<GetGasSponsorReturn>
289
- addressGasSponsors(args: AddressGasSponsorsArgs, headers?: object, signal?: AbortSignal): Promise<AddressGasSponsorsReturn>
290
- listGasSponsors(args: ListGasSponsorsArgs, headers?: object, signal?: AbortSignal): Promise<ListGasSponsorsReturn>
291
- addGasSponsor(args: AddGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<AddGasSponsorReturn>
292
- updateGasSponsor(args: UpdateGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<UpdateGasSponsorReturn>
293
- removeGasSponsor(args: RemoveGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<RemoveGasSponsorReturn>
294
- reportGasSponsorUsage(
295
- args: ReportGasSponsorUsageArgs,
296
- headers?: object,
297
- signal?: AbortSignal
298
- ): Promise<ReportGasSponsorUsageReturn>
299
341
  nextGasTankBalanceAdjustmentNonce(
300
342
  args: NextGasTankBalanceAdjustmentNonceArgs,
301
343
  headers?: object,
@@ -316,6 +358,12 @@ export interface Relayer {
316
358
  headers?: object,
317
359
  signal?: AbortSignal
318
360
  ): Promise<ListGasTankBalanceAdjustmentsReturn>
361
+ listGasSponsors(args: ListGasSponsorsArgs, headers?: object, signal?: AbortSignal): Promise<ListGasSponsorsReturn>
362
+ getGasSponsor(args: GetGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<GetGasSponsorReturn>
363
+ addGasSponsor(args: AddGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<AddGasSponsorReturn>
364
+ updateGasSponsor(args: UpdateGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<UpdateGasSponsorReturn>
365
+ removeGasSponsor(args: RemoveGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<RemoveGasSponsorReturn>
366
+ addressGasSponsors(args: AddressGasSponsorsArgs, headers?: object, signal?: AbortSignal): Promise<AddressGasSponsorsReturn>
319
367
  getProjectBalance(args: GetProjectBalanceArgs, headers?: object, signal?: AbortSignal): Promise<GetProjectBalanceReturn>
320
368
  adjustProjectBalance(
321
369
  args: AdjustProjectBalanceArgs,
@@ -480,25 +528,42 @@ export interface UpdateGasTankReturn {
480
528
  status: boolean
481
529
  gasTank: GasTank
482
530
  }
483
- export interface GetGasSponsorArgs {
531
+ export interface NextGasTankBalanceAdjustmentNonceArgs {
484
532
  id: number
485
533
  }
486
534
 
487
- export interface GetGasSponsorReturn {
488
- gasSponsor: GasSponsor
535
+ export interface NextGasTankBalanceAdjustmentNonceReturn {
536
+ nonce: number
489
537
  }
490
- export interface AddressGasSponsorsArgs {
491
- address: string
538
+ export interface AdjustGasTankBalanceArgs {
539
+ id: number
540
+ nonce: number
541
+ amount: number
542
+ }
543
+
544
+ export interface AdjustGasTankBalanceReturn {
545
+ status: boolean
546
+ adjustment: GasTankBalanceAdjustment
547
+ }
548
+ export interface GetGasTankBalanceAdjustmentArgs {
549
+ id: number
550
+ nonce: number
551
+ }
552
+
553
+ export interface GetGasTankBalanceAdjustmentReturn {
554
+ adjustment: GasTankBalanceAdjustment
555
+ }
556
+ export interface ListGasTankBalanceAdjustmentsArgs {
557
+ id: number
492
558
  page?: Page
493
559
  }
494
560
 
495
- export interface AddressGasSponsorsReturn {
561
+ export interface ListGasTankBalanceAdjustmentsReturn {
496
562
  page: Page
497
- gasSponsors: Array<GasSponsor>
563
+ adjustments: Array<GasTankBalanceAdjustment>
498
564
  }
499
565
  export interface ListGasSponsorsArgs {
500
566
  projectId: number
501
- gasTankId: number
502
567
  page?: Page
503
568
  }
504
569
 
@@ -506,9 +571,16 @@ export interface ListGasSponsorsReturn {
506
571
  page: Page
507
572
  gasSponsors: Array<GasSponsor>
508
573
  }
574
+ export interface GetGasSponsorArgs {
575
+ projectId: number
576
+ id: number
577
+ }
578
+
579
+ export interface GetGasSponsorReturn {
580
+ gasSponsor: GasSponsor
581
+ }
509
582
  export interface AddGasSponsorArgs {
510
583
  projectId: number
511
- gasTankId: number
512
584
  address: string
513
585
  name?: string
514
586
  active?: boolean
@@ -519,6 +591,7 @@ export interface AddGasSponsorReturn {
519
591
  gasSponsor: GasSponsor
520
592
  }
521
593
  export interface UpdateGasSponsorArgs {
594
+ projectId: number
522
595
  id: number
523
596
  name?: string
524
597
  active?: boolean
@@ -529,55 +602,21 @@ export interface UpdateGasSponsorReturn {
529
602
  gasSponsor: GasSponsor
530
603
  }
531
604
  export interface RemoveGasSponsorArgs {
532
- id: number
533
- }
534
-
535
- export interface RemoveGasSponsorReturn {
536
- status: boolean
537
- }
538
- export interface ReportGasSponsorUsageArgs {
539
605
  projectId: number
540
- gasTankId: number
541
- startTime?: string
542
- endTime?: string
543
- }
544
-
545
- export interface ReportGasSponsorUsageReturn {
546
- gasSponsorUsage: Array<GasSponsorUsage>
547
- }
548
- export interface NextGasTankBalanceAdjustmentNonceArgs {
549
606
  id: number
550
607
  }
551
608
 
552
- export interface NextGasTankBalanceAdjustmentNonceReturn {
553
- nonce: number
554
- }
555
- export interface AdjustGasTankBalanceArgs {
556
- id: number
557
- nonce: number
558
- amount: number
559
- }
560
-
561
- export interface AdjustGasTankBalanceReturn {
609
+ export interface RemoveGasSponsorReturn {
562
610
  status: boolean
563
- adjustment: GasTankBalanceAdjustment
564
- }
565
- export interface GetGasTankBalanceAdjustmentArgs {
566
- id: number
567
- nonce: number
568
611
  }
569
-
570
- export interface GetGasTankBalanceAdjustmentReturn {
571
- adjustment: GasTankBalanceAdjustment
572
- }
573
- export interface ListGasTankBalanceAdjustmentsArgs {
574
- id: number
612
+ export interface AddressGasSponsorsArgs {
613
+ address: string
575
614
  page?: Page
576
615
  }
577
616
 
578
- export interface ListGasTankBalanceAdjustmentsReturn {
617
+ export interface AddressGasSponsorsReturn {
579
618
  page: Page
580
- adjustments: Array<GasTankBalanceAdjustment>
619
+ gasSponsors: Array<GasSponsor>
581
620
  }
582
621
  export interface GetProjectBalanceArgs {
583
622
  projectId: number
@@ -942,32 +981,16 @@ export class Relayer implements Relayer {
942
981
  )
943
982
  }
944
983
 
945
- getGasSponsor = (args: GetGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<GetGasSponsorReturn> => {
946
- return this.fetch(this.url('GetGasSponsor'), createHTTPRequest(args, headers, signal)).then(
947
- res => {
948
- return buildResponse(res).then(_data => {
949
- return {
950
- gasSponsor: <GasSponsor>_data.gasSponsor
951
- }
952
- })
953
- },
954
- error => {
955
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
956
- }
957
- )
958
- }
959
-
960
- addressGasSponsors = (
961
- args: AddressGasSponsorsArgs,
984
+ nextGasTankBalanceAdjustmentNonce = (
985
+ args: NextGasTankBalanceAdjustmentNonceArgs,
962
986
  headers?: object,
963
987
  signal?: AbortSignal
964
- ): Promise<AddressGasSponsorsReturn> => {
965
- return this.fetch(this.url('AddressGasSponsors'), createHTTPRequest(args, headers, signal)).then(
988
+ ): Promise<NextGasTankBalanceAdjustmentNonceReturn> => {
989
+ return this.fetch(this.url('NextGasTankBalanceAdjustmentNonce'), createHTTPRequest(args, headers, signal)).then(
966
990
  res => {
967
991
  return buildResponse(res).then(_data => {
968
992
  return {
969
- page: <Page>_data.page,
970
- gasSponsors: <Array<GasSponsor>>_data.gasSponsors
993
+ nonce: <number>_data.nonce
971
994
  }
972
995
  })
973
996
  },
@@ -977,13 +1000,17 @@ export class Relayer implements Relayer {
977
1000
  )
978
1001
  }
979
1002
 
980
- listGasSponsors = (args: ListGasSponsorsArgs, headers?: object, signal?: AbortSignal): Promise<ListGasSponsorsReturn> => {
981
- return this.fetch(this.url('ListGasSponsors'), createHTTPRequest(args, headers, signal)).then(
1003
+ adjustGasTankBalance = (
1004
+ args: AdjustGasTankBalanceArgs,
1005
+ headers?: object,
1006
+ signal?: AbortSignal
1007
+ ): Promise<AdjustGasTankBalanceReturn> => {
1008
+ return this.fetch(this.url('AdjustGasTankBalance'), createHTTPRequest(args, headers, signal)).then(
982
1009
  res => {
983
1010
  return buildResponse(res).then(_data => {
984
1011
  return {
985
- page: <Page>_data.page,
986
- gasSponsors: <Array<GasSponsor>>_data.gasSponsors
1012
+ status: <boolean>_data.status,
1013
+ adjustment: <GasTankBalanceAdjustment>_data.adjustment
987
1014
  }
988
1015
  })
989
1016
  },
@@ -993,13 +1020,16 @@ export class Relayer implements Relayer {
993
1020
  )
994
1021
  }
995
1022
 
996
- addGasSponsor = (args: AddGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<AddGasSponsorReturn> => {
997
- return this.fetch(this.url('AddGasSponsor'), createHTTPRequest(args, headers, signal)).then(
1023
+ getGasTankBalanceAdjustment = (
1024
+ args: GetGasTankBalanceAdjustmentArgs,
1025
+ headers?: object,
1026
+ signal?: AbortSignal
1027
+ ): Promise<GetGasTankBalanceAdjustmentReturn> => {
1028
+ return this.fetch(this.url('GetGasTankBalanceAdjustment'), createHTTPRequest(args, headers, signal)).then(
998
1029
  res => {
999
1030
  return buildResponse(res).then(_data => {
1000
1031
  return {
1001
- status: <boolean>_data.status,
1002
- gasSponsor: <GasSponsor>_data.gasSponsor
1032
+ adjustment: <GasTankBalanceAdjustment>_data.adjustment
1003
1033
  }
1004
1034
  })
1005
1035
  },
@@ -1009,13 +1039,17 @@ export class Relayer implements Relayer {
1009
1039
  )
1010
1040
  }
1011
1041
 
1012
- updateGasSponsor = (args: UpdateGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<UpdateGasSponsorReturn> => {
1013
- return this.fetch(this.url('UpdateGasSponsor'), createHTTPRequest(args, headers, signal)).then(
1042
+ listGasTankBalanceAdjustments = (
1043
+ args: ListGasTankBalanceAdjustmentsArgs,
1044
+ headers?: object,
1045
+ signal?: AbortSignal
1046
+ ): Promise<ListGasTankBalanceAdjustmentsReturn> => {
1047
+ return this.fetch(this.url('ListGasTankBalanceAdjustments'), createHTTPRequest(args, headers, signal)).then(
1014
1048
  res => {
1015
1049
  return buildResponse(res).then(_data => {
1016
1050
  return {
1017
- status: <boolean>_data.status,
1018
- gasSponsor: <GasSponsor>_data.gasSponsor
1051
+ page: <Page>_data.page,
1052
+ adjustments: <Array<GasTankBalanceAdjustment>>_data.adjustments
1019
1053
  }
1020
1054
  })
1021
1055
  },
@@ -1025,12 +1059,13 @@ export class Relayer implements Relayer {
1025
1059
  )
1026
1060
  }
1027
1061
 
1028
- removeGasSponsor = (args: RemoveGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<RemoveGasSponsorReturn> => {
1029
- return this.fetch(this.url('RemoveGasSponsor'), createHTTPRequest(args, headers, signal)).then(
1062
+ listGasSponsors = (args: ListGasSponsorsArgs, headers?: object, signal?: AbortSignal): Promise<ListGasSponsorsReturn> => {
1063
+ return this.fetch(this.url('ListGasSponsors'), createHTTPRequest(args, headers, signal)).then(
1030
1064
  res => {
1031
1065
  return buildResponse(res).then(_data => {
1032
1066
  return {
1033
- status: <boolean>_data.status
1067
+ page: <Page>_data.page,
1068
+ gasSponsors: <Array<GasSponsor>>_data.gasSponsors
1034
1069
  }
1035
1070
  })
1036
1071
  },
@@ -1040,16 +1075,12 @@ export class Relayer implements Relayer {
1040
1075
  )
1041
1076
  }
1042
1077
 
1043
- reportGasSponsorUsage = (
1044
- args: ReportGasSponsorUsageArgs,
1045
- headers?: object,
1046
- signal?: AbortSignal
1047
- ): Promise<ReportGasSponsorUsageReturn> => {
1048
- return this.fetch(this.url('ReportGasSponsorUsage'), createHTTPRequest(args, headers, signal)).then(
1078
+ getGasSponsor = (args: GetGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<GetGasSponsorReturn> => {
1079
+ return this.fetch(this.url('GetGasSponsor'), createHTTPRequest(args, headers, signal)).then(
1049
1080
  res => {
1050
1081
  return buildResponse(res).then(_data => {
1051
1082
  return {
1052
- gasSponsorUsage: <Array<GasSponsorUsage>>_data.gasSponsorUsage
1083
+ gasSponsor: <GasSponsor>_data.gasSponsor
1053
1084
  }
1054
1085
  })
1055
1086
  },
@@ -1059,16 +1090,13 @@ export class Relayer implements Relayer {
1059
1090
  )
1060
1091
  }
1061
1092
 
1062
- nextGasTankBalanceAdjustmentNonce = (
1063
- args: NextGasTankBalanceAdjustmentNonceArgs,
1064
- headers?: object,
1065
- signal?: AbortSignal
1066
- ): Promise<NextGasTankBalanceAdjustmentNonceReturn> => {
1067
- return this.fetch(this.url('NextGasTankBalanceAdjustmentNonce'), createHTTPRequest(args, headers, signal)).then(
1093
+ addGasSponsor = (args: AddGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<AddGasSponsorReturn> => {
1094
+ return this.fetch(this.url('AddGasSponsor'), createHTTPRequest(args, headers, signal)).then(
1068
1095
  res => {
1069
1096
  return buildResponse(res).then(_data => {
1070
1097
  return {
1071
- nonce: <number>_data.nonce
1098
+ status: <boolean>_data.status,
1099
+ gasSponsor: <GasSponsor>_data.gasSponsor
1072
1100
  }
1073
1101
  })
1074
1102
  },
@@ -1078,17 +1106,13 @@ export class Relayer implements Relayer {
1078
1106
  )
1079
1107
  }
1080
1108
 
1081
- adjustGasTankBalance = (
1082
- args: AdjustGasTankBalanceArgs,
1083
- headers?: object,
1084
- signal?: AbortSignal
1085
- ): Promise<AdjustGasTankBalanceReturn> => {
1086
- return this.fetch(this.url('AdjustGasTankBalance'), createHTTPRequest(args, headers, signal)).then(
1109
+ updateGasSponsor = (args: UpdateGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<UpdateGasSponsorReturn> => {
1110
+ return this.fetch(this.url('UpdateGasSponsor'), createHTTPRequest(args, headers, signal)).then(
1087
1111
  res => {
1088
1112
  return buildResponse(res).then(_data => {
1089
1113
  return {
1090
1114
  status: <boolean>_data.status,
1091
- adjustment: <GasTankBalanceAdjustment>_data.adjustment
1115
+ gasSponsor: <GasSponsor>_data.gasSponsor
1092
1116
  }
1093
1117
  })
1094
1118
  },
@@ -1098,16 +1122,12 @@ export class Relayer implements Relayer {
1098
1122
  )
1099
1123
  }
1100
1124
 
1101
- getGasTankBalanceAdjustment = (
1102
- args: GetGasTankBalanceAdjustmentArgs,
1103
- headers?: object,
1104
- signal?: AbortSignal
1105
- ): Promise<GetGasTankBalanceAdjustmentReturn> => {
1106
- return this.fetch(this.url('GetGasTankBalanceAdjustment'), createHTTPRequest(args, headers, signal)).then(
1125
+ removeGasSponsor = (args: RemoveGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<RemoveGasSponsorReturn> => {
1126
+ return this.fetch(this.url('RemoveGasSponsor'), createHTTPRequest(args, headers, signal)).then(
1107
1127
  res => {
1108
1128
  return buildResponse(res).then(_data => {
1109
1129
  return {
1110
- adjustment: <GasTankBalanceAdjustment>_data.adjustment
1130
+ status: <boolean>_data.status
1111
1131
  }
1112
1132
  })
1113
1133
  },
@@ -1117,17 +1137,17 @@ export class Relayer implements Relayer {
1117
1137
  )
1118
1138
  }
1119
1139
 
1120
- listGasTankBalanceAdjustments = (
1121
- args: ListGasTankBalanceAdjustmentsArgs,
1140
+ addressGasSponsors = (
1141
+ args: AddressGasSponsorsArgs,
1122
1142
  headers?: object,
1123
1143
  signal?: AbortSignal
1124
- ): Promise<ListGasTankBalanceAdjustmentsReturn> => {
1125
- return this.fetch(this.url('ListGasTankBalanceAdjustments'), createHTTPRequest(args, headers, signal)).then(
1144
+ ): Promise<AddressGasSponsorsReturn> => {
1145
+ return this.fetch(this.url('AddressGasSponsors'), createHTTPRequest(args, headers, signal)).then(
1126
1146
  res => {
1127
1147
  return buildResponse(res).then(_data => {
1128
1148
  return {
1129
1149
  page: <Page>_data.page,
1130
- adjustments: <Array<GasTankBalanceAdjustment>>_data.adjustments
1150
+ gasSponsors: <Array<GasSponsor>>_data.gasSponsors
1131
1151
  }
1132
1152
  })
1133
1153
  },
@@ -1173,9 +1193,12 @@ export class Relayer implements Relayer {
1173
1193
  }
1174
1194
 
1175
1195
  const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => {
1196
+ const reqHeaders: { [key: string]: string } = { ...headers, 'Content-Type': 'application/json' }
1197
+ reqHeaders[WebrpcHeader] = WebrpcHeaderValue
1198
+
1176
1199
  return {
1177
1200
  method: 'POST',
1178
- headers: { ...headers, 'Content-Type': 'application/json' },
1201
+ headers: reqHeaders,
1179
1202
  body: JSON.stringify(body || {}),
1180
1203
  signal
1181
1204
  }
@@ -1407,6 +1430,19 @@ export class PermissionDeniedError extends WebrpcError {
1407
1430
  }
1408
1431
  }
1409
1432
 
1433
+ export class SessionExpiredError extends WebrpcError {
1434
+ constructor(
1435
+ name: string = 'SessionExpired',
1436
+ code: number = 1002,
1437
+ message: string = 'Session expired',
1438
+ status: number = 0,
1439
+ cause?: string
1440
+ ) {
1441
+ super(name, code, message, status, cause)
1442
+ Object.setPrototypeOf(this, SessionExpiredError.prototype)
1443
+ }
1444
+ }
1445
+
1410
1446
  export class MethodNotFoundError extends WebrpcError {
1411
1447
  constructor(
1412
1448
  name: string = 'MethodNotFound',
@@ -1459,6 +1495,175 @@ export class GeoblockedError extends WebrpcError {
1459
1495
  }
1460
1496
  }
1461
1497
 
1498
+ export class RateLimitedError extends WebrpcError {
1499
+ constructor(
1500
+ name: string = 'RateLimited',
1501
+ code: number = 1007,
1502
+ message: string = 'Rate-limited. Please slow down.',
1503
+ status: number = 0,
1504
+ cause?: string
1505
+ ) {
1506
+ super(name, code, message, status, cause)
1507
+ Object.setPrototypeOf(this, RateLimitedError.prototype)
1508
+ }
1509
+ }
1510
+
1511
+ export class ProjectNotFoundError extends WebrpcError {
1512
+ constructor(
1513
+ name: string = 'ProjectNotFound',
1514
+ code: number = 1008,
1515
+ message: string = 'Project not found',
1516
+ status: number = 0,
1517
+ cause?: string
1518
+ ) {
1519
+ super(name, code, message, status, cause)
1520
+ Object.setPrototypeOf(this, ProjectNotFoundError.prototype)
1521
+ }
1522
+ }
1523
+
1524
+ export class AccessKeyNotFoundError extends WebrpcError {
1525
+ constructor(
1526
+ name: string = 'AccessKeyNotFound',
1527
+ code: number = 1101,
1528
+ message: string = 'Access key not found',
1529
+ status: number = 0,
1530
+ cause?: string
1531
+ ) {
1532
+ super(name, code, message, status, cause)
1533
+ Object.setPrototypeOf(this, AccessKeyNotFoundError.prototype)
1534
+ }
1535
+ }
1536
+
1537
+ export class AccessKeyMismatchError extends WebrpcError {
1538
+ constructor(
1539
+ name: string = 'AccessKeyMismatch',
1540
+ code: number = 1102,
1541
+ message: string = 'Access key mismatch',
1542
+ status: number = 0,
1543
+ cause?: string
1544
+ ) {
1545
+ super(name, code, message, status, cause)
1546
+ Object.setPrototypeOf(this, AccessKeyMismatchError.prototype)
1547
+ }
1548
+ }
1549
+
1550
+ export class InvalidOriginError extends WebrpcError {
1551
+ constructor(
1552
+ name: string = 'InvalidOrigin',
1553
+ code: number = 1103,
1554
+ message: string = 'Invalid origin for Access Key',
1555
+ status: number = 0,
1556
+ cause?: string
1557
+ ) {
1558
+ super(name, code, message, status, cause)
1559
+ Object.setPrototypeOf(this, InvalidOriginError.prototype)
1560
+ }
1561
+ }
1562
+
1563
+ export class InvalidServiceError extends WebrpcError {
1564
+ constructor(
1565
+ name: string = 'InvalidService',
1566
+ code: number = 1104,
1567
+ message: string = 'Service not enabled for Access key',
1568
+ status: number = 0,
1569
+ cause?: string
1570
+ ) {
1571
+ super(name, code, message, status, cause)
1572
+ Object.setPrototypeOf(this, InvalidServiceError.prototype)
1573
+ }
1574
+ }
1575
+
1576
+ export class UnauthorizedUserError extends WebrpcError {
1577
+ constructor(
1578
+ name: string = 'UnauthorizedUser',
1579
+ code: number = 1105,
1580
+ message: string = 'Unauthorized user',
1581
+ status: number = 0,
1582
+ cause?: string
1583
+ ) {
1584
+ super(name, code, message, status, cause)
1585
+ Object.setPrototypeOf(this, UnauthorizedUserError.prototype)
1586
+ }
1587
+ }
1588
+
1589
+ export class QuotaExceededError extends WebrpcError {
1590
+ constructor(
1591
+ name: string = 'QuotaExceeded',
1592
+ code: number = 1200,
1593
+ message: string = 'Quota request exceeded',
1594
+ status: number = 0,
1595
+ cause?: string
1596
+ ) {
1597
+ super(name, code, message, status, cause)
1598
+ Object.setPrototypeOf(this, QuotaExceededError.prototype)
1599
+ }
1600
+ }
1601
+
1602
+ export class QuotaRateLimitError extends WebrpcError {
1603
+ constructor(
1604
+ name: string = 'QuotaRateLimit',
1605
+ code: number = 1201,
1606
+ message: string = 'Quota rate limit exceeded',
1607
+ status: number = 0,
1608
+ cause?: string
1609
+ ) {
1610
+ super(name, code, message, status, cause)
1611
+ Object.setPrototypeOf(this, QuotaRateLimitError.prototype)
1612
+ }
1613
+ }
1614
+
1615
+ export class NoDefaultKeyError extends WebrpcError {
1616
+ constructor(
1617
+ name: string = 'NoDefaultKey',
1618
+ code: number = 1300,
1619
+ message: string = 'No default access key found',
1620
+ status: number = 0,
1621
+ cause?: string
1622
+ ) {
1623
+ super(name, code, message, status, cause)
1624
+ Object.setPrototypeOf(this, NoDefaultKeyError.prototype)
1625
+ }
1626
+ }
1627
+
1628
+ export class MaxAccessKeysError extends WebrpcError {
1629
+ constructor(
1630
+ name: string = 'MaxAccessKeys',
1631
+ code: number = 1301,
1632
+ message: string = 'Access keys limit reached',
1633
+ status: number = 0,
1634
+ cause?: string
1635
+ ) {
1636
+ super(name, code, message, status, cause)
1637
+ Object.setPrototypeOf(this, MaxAccessKeysError.prototype)
1638
+ }
1639
+ }
1640
+
1641
+ export class AtLeastOneKeyError extends WebrpcError {
1642
+ constructor(
1643
+ name: string = 'AtLeastOneKey',
1644
+ code: number = 1302,
1645
+ message: string = 'You need at least one Access Key',
1646
+ status: number = 0,
1647
+ cause?: string
1648
+ ) {
1649
+ super(name, code, message, status, cause)
1650
+ Object.setPrototypeOf(this, AtLeastOneKeyError.prototype)
1651
+ }
1652
+ }
1653
+
1654
+ export class TimeoutError extends WebrpcError {
1655
+ constructor(
1656
+ name: string = 'Timeout',
1657
+ code: number = 1900,
1658
+ message: string = 'Request timed out',
1659
+ status: number = 0,
1660
+ cause?: string
1661
+ ) {
1662
+ super(name, code, message, status, cause)
1663
+ Object.setPrototypeOf(this, TimeoutError.prototype)
1664
+ }
1665
+ }
1666
+
1462
1667
  export class InvalidArgumentError extends WebrpcError {
1463
1668
  constructor(
1464
1669
  name: string = 'InvalidArgument',
@@ -1538,10 +1743,24 @@ export enum errors {
1538
1743
  WebrpcStreamFinished = 'WebrpcStreamFinished',
1539
1744
  Unauthorized = 'Unauthorized',
1540
1745
  PermissionDenied = 'PermissionDenied',
1746
+ SessionExpired = 'SessionExpired',
1541
1747
  MethodNotFound = 'MethodNotFound',
1542
1748
  RequestConflict = 'RequestConflict',
1543
1749
  Aborted = 'Aborted',
1544
1750
  Geoblocked = 'Geoblocked',
1751
+ RateLimited = 'RateLimited',
1752
+ ProjectNotFound = 'ProjectNotFound',
1753
+ AccessKeyNotFound = 'AccessKeyNotFound',
1754
+ AccessKeyMismatch = 'AccessKeyMismatch',
1755
+ InvalidOrigin = 'InvalidOrigin',
1756
+ InvalidService = 'InvalidService',
1757
+ UnauthorizedUser = 'UnauthorizedUser',
1758
+ QuotaExceeded = 'QuotaExceeded',
1759
+ QuotaRateLimit = 'QuotaRateLimit',
1760
+ NoDefaultKey = 'NoDefaultKey',
1761
+ MaxAccessKeys = 'MaxAccessKeys',
1762
+ AtLeastOneKey = 'AtLeastOneKey',
1763
+ Timeout = 'Timeout',
1545
1764
  InvalidArgument = 'InvalidArgument',
1546
1765
  Unavailable = 'Unavailable',
1547
1766
  QueryFailed = 'QueryFailed',
@@ -1549,7 +1768,46 @@ export enum errors {
1549
1768
  InsufficientFee = 'InsufficientFee'
1550
1769
  }
1551
1770
 
1552
- const webrpcErrorByCode: { [code: number]: any } = {
1771
+ export enum WebrpcErrorCodes {
1772
+ WebrpcEndpoint = 0,
1773
+ WebrpcRequestFailed = -1,
1774
+ WebrpcBadRoute = -2,
1775
+ WebrpcBadMethod = -3,
1776
+ WebrpcBadRequest = -4,
1777
+ WebrpcBadResponse = -5,
1778
+ WebrpcServerPanic = -6,
1779
+ WebrpcInternalError = -7,
1780
+ WebrpcClientDisconnected = -8,
1781
+ WebrpcStreamLost = -9,
1782
+ WebrpcStreamFinished = -10,
1783
+ Unauthorized = 1000,
1784
+ PermissionDenied = 1001,
1785
+ SessionExpired = 1002,
1786
+ MethodNotFound = 1003,
1787
+ RequestConflict = 1004,
1788
+ Aborted = 1005,
1789
+ Geoblocked = 1006,
1790
+ RateLimited = 1007,
1791
+ ProjectNotFound = 1008,
1792
+ AccessKeyNotFound = 1101,
1793
+ AccessKeyMismatch = 1102,
1794
+ InvalidOrigin = 1103,
1795
+ InvalidService = 1104,
1796
+ UnauthorizedUser = 1105,
1797
+ QuotaExceeded = 1200,
1798
+ QuotaRateLimit = 1201,
1799
+ NoDefaultKey = 1300,
1800
+ MaxAccessKeys = 1301,
1801
+ AtLeastOneKey = 1302,
1802
+ Timeout = 1900,
1803
+ InvalidArgument = 2001,
1804
+ Unavailable = 2002,
1805
+ QueryFailed = 2003,
1806
+ NotFound = 3000,
1807
+ InsufficientFee = 3004
1808
+ }
1809
+
1810
+ export const webrpcErrorByCode: { [code: number]: any } = {
1553
1811
  [0]: WebrpcEndpointError,
1554
1812
  [-1]: WebrpcRequestFailedError,
1555
1813
  [-2]: WebrpcBadRouteError,
@@ -1563,10 +1821,24 @@ const webrpcErrorByCode: { [code: number]: any } = {
1563
1821
  [-10]: WebrpcStreamFinishedError,
1564
1822
  [1000]: UnauthorizedError,
1565
1823
  [1001]: PermissionDeniedError,
1824
+ [1002]: SessionExpiredError,
1566
1825
  [1003]: MethodNotFoundError,
1567
1826
  [1004]: RequestConflictError,
1568
1827
  [1005]: AbortedError,
1569
1828
  [1006]: GeoblockedError,
1829
+ [1007]: RateLimitedError,
1830
+ [1008]: ProjectNotFoundError,
1831
+ [1101]: AccessKeyNotFoundError,
1832
+ [1102]: AccessKeyMismatchError,
1833
+ [1103]: InvalidOriginError,
1834
+ [1104]: InvalidServiceError,
1835
+ [1105]: UnauthorizedUserError,
1836
+ [1200]: QuotaExceededError,
1837
+ [1201]: QuotaRateLimitError,
1838
+ [1300]: NoDefaultKeyError,
1839
+ [1301]: MaxAccessKeysError,
1840
+ [1302]: AtLeastOneKeyError,
1841
+ [1900]: TimeoutError,
1570
1842
  [2001]: InvalidArgumentError,
1571
1843
  [2002]: UnavailableError,
1572
1844
  [2003]: QueryFailedError,