@0xsequence/api 2.2.10 → 2.2.12

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,6 +1,16 @@
1
+ export declare const WebrpcHeader = "Webrpc";
2
+ export declare const WebrpcHeaderValue = "webrpc@v0.22.0;gen-typescript@v0.16.1;sequence-api@v0.4.0";
1
3
  export declare const WebRPCVersion = "v1";
2
4
  export declare const WebRPCSchemaVersion = "v0.4.0";
3
- export declare const WebRPCSchemaHash = "24814ebb88457c0545aa80e8388cb0f08ec59bec";
5
+ export declare const WebRPCSchemaHash = "c3eb9010746703c095291691cd8f08dc04999062";
6
+ type WebrpcGenVersions = {
7
+ webrpcGenVersion: string;
8
+ codeGenName: string;
9
+ codeGenVersion: string;
10
+ schemaName: string;
11
+ schemaVersion: string;
12
+ };
13
+ export declare function VersionFromHeader(headers: Headers): WebrpcGenVersions;
4
14
  export declare enum SortOrder {
5
15
  DESC = "DESC",
6
16
  ASC = "ASC"
@@ -257,6 +267,11 @@ export interface SardineSupportedToken {
257
267
  token: string;
258
268
  tokenAddress: string;
259
269
  }
270
+ export interface SardineSupportedTokenForSwap {
271
+ isSupported: boolean;
272
+ isSupportedForAbstraction: boolean;
273
+ currentBalance: string;
274
+ }
260
275
  export interface SardineEnabledToken {
261
276
  network: string;
262
277
  assetSymbol: string;
@@ -417,6 +432,7 @@ export interface API {
417
432
  sardineGetSupportedRegions(headers?: object, signal?: AbortSignal): Promise<SardineGetSupportedRegionsReturn>;
418
433
  sardineGetSupportedFiatCurrencies(headers?: object, signal?: AbortSignal): Promise<SardineGetSupportedFiatCurrenciesReturn>;
419
434
  sardineGetSupportedTokens(headers?: object, signal?: AbortSignal): Promise<SardineGetSupportedTokensReturn>;
435
+ sardineGetSupportedTokenForSwap(args: SardineGetSupportedTokenForSwapArgs, headers?: object, signal?: AbortSignal): Promise<SardineGetSupportedTokenForSwapReturn>;
420
436
  sardineGetEnabledTokens(headers?: object, signal?: AbortSignal): Promise<SardineGetEnabledTokensReturn>;
421
437
  sardineGetQuote(args: SardineGetQuoteArgs, headers?: object, signal?: AbortSignal): Promise<SardineGetQuoteReturn>;
422
438
  getSardineClientToken(headers?: object, signal?: AbortSignal): Promise<GetSardineClientTokenReturn>;
@@ -689,6 +705,13 @@ export interface SardineGetSupportedTokensArgs {
689
705
  export interface SardineGetSupportedTokensReturn {
690
706
  tokens: Array<SardineSupportedToken>;
691
707
  }
708
+ export interface SardineGetSupportedTokenForSwapArgs {
709
+ network: string;
710
+ tokenAddress: string;
711
+ }
712
+ export interface SardineGetSupportedTokenForSwapReturn {
713
+ token: SardineSupportedTokenForSwap;
714
+ }
692
715
  export interface SardineGetEnabledTokensArgs {
693
716
  }
694
717
  export interface SardineGetEnabledTokensReturn {
@@ -970,6 +993,7 @@ export declare class API implements API {
970
993
  sardineGetSupportedRegions: (headers?: object, signal?: AbortSignal) => Promise<SardineGetSupportedRegionsReturn>;
971
994
  sardineGetSupportedFiatCurrencies: (headers?: object, signal?: AbortSignal) => Promise<SardineGetSupportedFiatCurrenciesReturn>;
972
995
  sardineGetSupportedTokens: (headers?: object, signal?: AbortSignal) => Promise<SardineGetSupportedTokensReturn>;
996
+ sardineGetSupportedTokenForSwap: (args: SardineGetSupportedTokenForSwapArgs, headers?: object, signal?: AbortSignal) => Promise<SardineGetSupportedTokenForSwapReturn>;
973
997
  sardineGetEnabledTokens: (headers?: object, signal?: AbortSignal) => Promise<SardineGetEnabledTokensReturn>;
974
998
  sardineGetQuote: (args: SardineGetQuoteArgs, headers?: object, signal?: AbortSignal) => Promise<SardineGetQuoteReturn>;
975
999
  getSardineClientToken: (headers?: object, signal?: AbortSignal) => Promise<GetSardineClientTokenReturn>;
@@ -1057,12 +1081,57 @@ export declare class PermissionDeniedError extends WebrpcError {
1057
1081
  export declare class SessionExpiredError extends WebrpcError {
1058
1082
  constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1059
1083
  }
1084
+ export declare class MethodNotFoundError extends WebrpcError {
1085
+ constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1086
+ }
1087
+ export declare class RequestConflictError extends WebrpcError {
1088
+ constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1089
+ }
1060
1090
  export declare class AbortedError extends WebrpcError {
1061
1091
  constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1062
1092
  }
1063
1093
  export declare class GeoblockedError extends WebrpcError {
1064
1094
  constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1065
1095
  }
1096
+ export declare class RateLimitedError extends WebrpcError {
1097
+ constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1098
+ }
1099
+ export declare class ProjectNotFoundError extends WebrpcError {
1100
+ constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1101
+ }
1102
+ export declare class AccessKeyNotFoundError extends WebrpcError {
1103
+ constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1104
+ }
1105
+ export declare class AccessKeyMismatchError extends WebrpcError {
1106
+ constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1107
+ }
1108
+ export declare class InvalidOriginError extends WebrpcError {
1109
+ constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1110
+ }
1111
+ export declare class InvalidServiceError extends WebrpcError {
1112
+ constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1113
+ }
1114
+ export declare class UnauthorizedUserError extends WebrpcError {
1115
+ constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1116
+ }
1117
+ export declare class QuotaExceededError extends WebrpcError {
1118
+ constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1119
+ }
1120
+ export declare class QuotaRateLimitError extends WebrpcError {
1121
+ constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1122
+ }
1123
+ export declare class NoDefaultKeyError extends WebrpcError {
1124
+ constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1125
+ }
1126
+ export declare class MaxAccessKeysError extends WebrpcError {
1127
+ constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1128
+ }
1129
+ export declare class AtLeastOneKeyError extends WebrpcError {
1130
+ constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1131
+ }
1132
+ export declare class TimeoutError extends WebrpcError {
1133
+ constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1134
+ }
1066
1135
  export declare class InvalidArgumentError extends WebrpcError {
1067
1136
  constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1068
1137
  }
@@ -1075,6 +1144,9 @@ export declare class QueryFailedError extends WebrpcError {
1075
1144
  export declare class NotFoundError extends WebrpcError {
1076
1145
  constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1077
1146
  }
1147
+ export declare class UnsupportedNetworkError extends WebrpcError {
1148
+ constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
1149
+ }
1078
1150
  export declare enum errors {
1079
1151
  WebrpcEndpoint = "WebrpcEndpoint",
1080
1152
  WebrpcRequestFailed = "WebrpcRequestFailed",
@@ -1090,11 +1162,69 @@ export declare enum errors {
1090
1162
  Unauthorized = "Unauthorized",
1091
1163
  PermissionDenied = "PermissionDenied",
1092
1164
  SessionExpired = "SessionExpired",
1165
+ MethodNotFound = "MethodNotFound",
1166
+ RequestConflict = "RequestConflict",
1093
1167
  Aborted = "Aborted",
1094
1168
  Geoblocked = "Geoblocked",
1169
+ RateLimited = "RateLimited",
1170
+ ProjectNotFound = "ProjectNotFound",
1171
+ AccessKeyNotFound = "AccessKeyNotFound",
1172
+ AccessKeyMismatch = "AccessKeyMismatch",
1173
+ InvalidOrigin = "InvalidOrigin",
1174
+ InvalidService = "InvalidService",
1175
+ UnauthorizedUser = "UnauthorizedUser",
1176
+ QuotaExceeded = "QuotaExceeded",
1177
+ QuotaRateLimit = "QuotaRateLimit",
1178
+ NoDefaultKey = "NoDefaultKey",
1179
+ MaxAccessKeys = "MaxAccessKeys",
1180
+ AtLeastOneKey = "AtLeastOneKey",
1181
+ Timeout = "Timeout",
1095
1182
  InvalidArgument = "InvalidArgument",
1096
1183
  Unavailable = "Unavailable",
1097
1184
  QueryFailed = "QueryFailed",
1098
- NotFound = "NotFound"
1099
- }
1185
+ NotFound = "NotFound",
1186
+ UnsupportedNetwork = "UnsupportedNetwork"
1187
+ }
1188
+ export declare enum WebrpcErrorCodes {
1189
+ WebrpcEndpoint = 0,
1190
+ WebrpcRequestFailed = -1,
1191
+ WebrpcBadRoute = -2,
1192
+ WebrpcBadMethod = -3,
1193
+ WebrpcBadRequest = -4,
1194
+ WebrpcBadResponse = -5,
1195
+ WebrpcServerPanic = -6,
1196
+ WebrpcInternalError = -7,
1197
+ WebrpcClientDisconnected = -8,
1198
+ WebrpcStreamLost = -9,
1199
+ WebrpcStreamFinished = -10,
1200
+ Unauthorized = 1000,
1201
+ PermissionDenied = 1001,
1202
+ SessionExpired = 1002,
1203
+ MethodNotFound = 1003,
1204
+ RequestConflict = 1004,
1205
+ Aborted = 1005,
1206
+ Geoblocked = 1006,
1207
+ RateLimited = 1007,
1208
+ ProjectNotFound = 1008,
1209
+ AccessKeyNotFound = 1101,
1210
+ AccessKeyMismatch = 1102,
1211
+ InvalidOrigin = 1103,
1212
+ InvalidService = 1104,
1213
+ UnauthorizedUser = 1105,
1214
+ QuotaExceeded = 1200,
1215
+ QuotaRateLimit = 1201,
1216
+ NoDefaultKey = 1300,
1217
+ MaxAccessKeys = 1301,
1218
+ AtLeastOneKey = 1302,
1219
+ Timeout = 1900,
1220
+ InvalidArgument = 2000,
1221
+ Unavailable = 2002,
1222
+ QueryFailed = 2003,
1223
+ NotFound = 3000,
1224
+ UnsupportedNetwork = 3008
1225
+ }
1226
+ export declare const webrpcErrorByCode: {
1227
+ [code: number]: any;
1228
+ };
1100
1229
  export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
1230
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/api",
3
- "version": "2.2.10",
3
+ "version": "2.2.12",
4
4
  "description": "api sub-package for Sequence",
5
5
  "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/api",
6
6
  "source": "src/index.ts",
package/src/api.gen.ts CHANGED
@@ -1,10 +1,14 @@
1
1
  /* eslint-disable */
2
- // sequence-api v0.4.0 24814ebb88457c0545aa80e8388cb0f08ec59bec
2
+ // sequence-api v0.4.0 c3eb9010746703c095291691cd8f08dc04999062
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=api.ridl -target=typescript -client -out=./clients/api.gen.ts
7
7
 
8
+ export const WebrpcHeader = 'Webrpc'
9
+
10
+ export const WebrpcHeaderValue = 'webrpc@v0.22.0;gen-typescript@v0.16.1;sequence-api@v0.4.0'
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.0'
13
17
 
14
18
  // Schema hash generated from your RIDL schema
15
- export const WebRPCSchemaHash = '24814ebb88457c0545aa80e8388cb0f08ec59bec'
19
+ export const WebRPCSchemaHash = 'c3eb9010746703c095291691cd8f08dc04999062'
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
@@ -305,6 +357,12 @@ export interface SardineSupportedToken {
305
357
  tokenAddress: string
306
358
  }
307
359
 
360
+ export interface SardineSupportedTokenForSwap {
361
+ isSupported: boolean
362
+ isSupportedForAbstraction: boolean
363
+ currentBalance: string
364
+ }
365
+
308
366
  export interface SardineEnabledToken {
309
367
  network: string
310
368
  assetSymbol: string
@@ -506,6 +564,11 @@ export interface API {
506
564
  sardineGetSupportedRegions(headers?: object, signal?: AbortSignal): Promise<SardineGetSupportedRegionsReturn>
507
565
  sardineGetSupportedFiatCurrencies(headers?: object, signal?: AbortSignal): Promise<SardineGetSupportedFiatCurrenciesReturn>
508
566
  sardineGetSupportedTokens(headers?: object, signal?: AbortSignal): Promise<SardineGetSupportedTokensReturn>
567
+ sardineGetSupportedTokenForSwap(
568
+ args: SardineGetSupportedTokenForSwapArgs,
569
+ headers?: object,
570
+ signal?: AbortSignal
571
+ ): Promise<SardineGetSupportedTokenForSwapReturn>
509
572
  sardineGetEnabledTokens(headers?: object, signal?: AbortSignal): Promise<SardineGetEnabledTokensReturn>
510
573
  sardineGetQuote(args: SardineGetQuoteArgs, headers?: object, signal?: AbortSignal): Promise<SardineGetQuoteReturn>
511
574
  getSardineClientToken(headers?: object, signal?: AbortSignal): Promise<GetSardineClientTokenReturn>
@@ -855,6 +918,14 @@ export interface SardineGetSupportedTokensArgs {}
855
918
  export interface SardineGetSupportedTokensReturn {
856
919
  tokens: Array<SardineSupportedToken>
857
920
  }
921
+ export interface SardineGetSupportedTokenForSwapArgs {
922
+ network: string
923
+ tokenAddress: string
924
+ }
925
+
926
+ export interface SardineGetSupportedTokenForSwapReturn {
927
+ token: SardineSupportedTokenForSwap
928
+ }
858
929
  export interface SardineGetEnabledTokensArgs {}
859
930
 
860
931
  export interface SardineGetEnabledTokensReturn {
@@ -1724,6 +1795,25 @@ export class API implements API {
1724
1795
  )
1725
1796
  }
1726
1797
 
1798
+ sardineGetSupportedTokenForSwap = (
1799
+ args: SardineGetSupportedTokenForSwapArgs,
1800
+ headers?: object,
1801
+ signal?: AbortSignal
1802
+ ): Promise<SardineGetSupportedTokenForSwapReturn> => {
1803
+ return this.fetch(this.url('SardineGetSupportedTokenForSwap'), createHTTPRequest(args, headers, signal)).then(
1804
+ res => {
1805
+ return buildResponse(res).then(_data => {
1806
+ return {
1807
+ token: <SardineSupportedTokenForSwap>_data.token
1808
+ }
1809
+ })
1810
+ },
1811
+ error => {
1812
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1813
+ }
1814
+ )
1815
+ }
1816
+
1727
1817
  sardineGetEnabledTokens = (headers?: object, signal?: AbortSignal): Promise<SardineGetEnabledTokensReturn> => {
1728
1818
  return this.fetch(this.url('SardineGetEnabledTokens'), createHTTPRequest({}, headers, signal)).then(
1729
1819
  res => {
@@ -2290,9 +2380,12 @@ export class API implements API {
2290
2380
  }
2291
2381
 
2292
2382
  const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => {
2383
+ const reqHeaders: { [key: string]: string } = { ...headers, 'Content-Type': 'application/json' }
2384
+ reqHeaders[WebrpcHeader] = WebrpcHeaderValue
2385
+
2293
2386
  return {
2294
2387
  method: 'POST',
2295
- headers: { ...headers, 'Content-Type': 'application/json' },
2388
+ headers: reqHeaders,
2296
2389
  body: JSON.stringify(body || {}),
2297
2390
  signal
2298
2391
  }
@@ -2537,6 +2630,32 @@ export class SessionExpiredError extends WebrpcError {
2537
2630
  }
2538
2631
  }
2539
2632
 
2633
+ export class MethodNotFoundError extends WebrpcError {
2634
+ constructor(
2635
+ name: string = 'MethodNotFound',
2636
+ code: number = 1003,
2637
+ message: string = 'Method not found',
2638
+ status: number = 0,
2639
+ cause?: string
2640
+ ) {
2641
+ super(name, code, message, status, cause)
2642
+ Object.setPrototypeOf(this, MethodNotFoundError.prototype)
2643
+ }
2644
+ }
2645
+
2646
+ export class RequestConflictError extends WebrpcError {
2647
+ constructor(
2648
+ name: string = 'RequestConflict',
2649
+ code: number = 1004,
2650
+ message: string = 'Conflict with target resource',
2651
+ status: number = 0,
2652
+ cause?: string
2653
+ ) {
2654
+ super(name, code, message, status, cause)
2655
+ Object.setPrototypeOf(this, RequestConflictError.prototype)
2656
+ }
2657
+ }
2658
+
2540
2659
  export class AbortedError extends WebrpcError {
2541
2660
  constructor(
2542
2661
  name: string = 'Aborted',
@@ -2563,6 +2682,175 @@ export class GeoblockedError extends WebrpcError {
2563
2682
  }
2564
2683
  }
2565
2684
 
2685
+ export class RateLimitedError extends WebrpcError {
2686
+ constructor(
2687
+ name: string = 'RateLimited',
2688
+ code: number = 1007,
2689
+ message: string = 'Rate-limited. Please slow down.',
2690
+ status: number = 0,
2691
+ cause?: string
2692
+ ) {
2693
+ super(name, code, message, status, cause)
2694
+ Object.setPrototypeOf(this, RateLimitedError.prototype)
2695
+ }
2696
+ }
2697
+
2698
+ export class ProjectNotFoundError extends WebrpcError {
2699
+ constructor(
2700
+ name: string = 'ProjectNotFound',
2701
+ code: number = 1008,
2702
+ message: string = 'Project not found',
2703
+ status: number = 0,
2704
+ cause?: string
2705
+ ) {
2706
+ super(name, code, message, status, cause)
2707
+ Object.setPrototypeOf(this, ProjectNotFoundError.prototype)
2708
+ }
2709
+ }
2710
+
2711
+ export class AccessKeyNotFoundError extends WebrpcError {
2712
+ constructor(
2713
+ name: string = 'AccessKeyNotFound',
2714
+ code: number = 1101,
2715
+ message: string = 'Access key not found',
2716
+ status: number = 0,
2717
+ cause?: string
2718
+ ) {
2719
+ super(name, code, message, status, cause)
2720
+ Object.setPrototypeOf(this, AccessKeyNotFoundError.prototype)
2721
+ }
2722
+ }
2723
+
2724
+ export class AccessKeyMismatchError extends WebrpcError {
2725
+ constructor(
2726
+ name: string = 'AccessKeyMismatch',
2727
+ code: number = 1102,
2728
+ message: string = 'Access key mismatch',
2729
+ status: number = 0,
2730
+ cause?: string
2731
+ ) {
2732
+ super(name, code, message, status, cause)
2733
+ Object.setPrototypeOf(this, AccessKeyMismatchError.prototype)
2734
+ }
2735
+ }
2736
+
2737
+ export class InvalidOriginError extends WebrpcError {
2738
+ constructor(
2739
+ name: string = 'InvalidOrigin',
2740
+ code: number = 1103,
2741
+ message: string = 'Invalid origin for Access Key',
2742
+ status: number = 0,
2743
+ cause?: string
2744
+ ) {
2745
+ super(name, code, message, status, cause)
2746
+ Object.setPrototypeOf(this, InvalidOriginError.prototype)
2747
+ }
2748
+ }
2749
+
2750
+ export class InvalidServiceError extends WebrpcError {
2751
+ constructor(
2752
+ name: string = 'InvalidService',
2753
+ code: number = 1104,
2754
+ message: string = 'Service not enabled for Access key',
2755
+ status: number = 0,
2756
+ cause?: string
2757
+ ) {
2758
+ super(name, code, message, status, cause)
2759
+ Object.setPrototypeOf(this, InvalidServiceError.prototype)
2760
+ }
2761
+ }
2762
+
2763
+ export class UnauthorizedUserError extends WebrpcError {
2764
+ constructor(
2765
+ name: string = 'UnauthorizedUser',
2766
+ code: number = 1105,
2767
+ message: string = 'Unauthorized user',
2768
+ status: number = 0,
2769
+ cause?: string
2770
+ ) {
2771
+ super(name, code, message, status, cause)
2772
+ Object.setPrototypeOf(this, UnauthorizedUserError.prototype)
2773
+ }
2774
+ }
2775
+
2776
+ export class QuotaExceededError extends WebrpcError {
2777
+ constructor(
2778
+ name: string = 'QuotaExceeded',
2779
+ code: number = 1200,
2780
+ message: string = 'Quota request exceeded',
2781
+ status: number = 0,
2782
+ cause?: string
2783
+ ) {
2784
+ super(name, code, message, status, cause)
2785
+ Object.setPrototypeOf(this, QuotaExceededError.prototype)
2786
+ }
2787
+ }
2788
+
2789
+ export class QuotaRateLimitError extends WebrpcError {
2790
+ constructor(
2791
+ name: string = 'QuotaRateLimit',
2792
+ code: number = 1201,
2793
+ message: string = 'Quota rate limit exceeded',
2794
+ status: number = 0,
2795
+ cause?: string
2796
+ ) {
2797
+ super(name, code, message, status, cause)
2798
+ Object.setPrototypeOf(this, QuotaRateLimitError.prototype)
2799
+ }
2800
+ }
2801
+
2802
+ export class NoDefaultKeyError extends WebrpcError {
2803
+ constructor(
2804
+ name: string = 'NoDefaultKey',
2805
+ code: number = 1300,
2806
+ message: string = 'No default access key found',
2807
+ status: number = 0,
2808
+ cause?: string
2809
+ ) {
2810
+ super(name, code, message, status, cause)
2811
+ Object.setPrototypeOf(this, NoDefaultKeyError.prototype)
2812
+ }
2813
+ }
2814
+
2815
+ export class MaxAccessKeysError extends WebrpcError {
2816
+ constructor(
2817
+ name: string = 'MaxAccessKeys',
2818
+ code: number = 1301,
2819
+ message: string = 'Access keys limit reached',
2820
+ status: number = 0,
2821
+ cause?: string
2822
+ ) {
2823
+ super(name, code, message, status, cause)
2824
+ Object.setPrototypeOf(this, MaxAccessKeysError.prototype)
2825
+ }
2826
+ }
2827
+
2828
+ export class AtLeastOneKeyError extends WebrpcError {
2829
+ constructor(
2830
+ name: string = 'AtLeastOneKey',
2831
+ code: number = 1302,
2832
+ message: string = 'You need at least one Access Key',
2833
+ status: number = 0,
2834
+ cause?: string
2835
+ ) {
2836
+ super(name, code, message, status, cause)
2837
+ Object.setPrototypeOf(this, AtLeastOneKeyError.prototype)
2838
+ }
2839
+ }
2840
+
2841
+ export class TimeoutError extends WebrpcError {
2842
+ constructor(
2843
+ name: string = 'Timeout',
2844
+ code: number = 1900,
2845
+ message: string = 'Request timed out',
2846
+ status: number = 0,
2847
+ cause?: string
2848
+ ) {
2849
+ super(name, code, message, status, cause)
2850
+ Object.setPrototypeOf(this, TimeoutError.prototype)
2851
+ }
2852
+ }
2853
+
2566
2854
  export class InvalidArgumentError extends WebrpcError {
2567
2855
  constructor(
2568
2856
  name: string = 'InvalidArgument',
@@ -2615,6 +2903,19 @@ export class NotFoundError extends WebrpcError {
2615
2903
  }
2616
2904
  }
2617
2905
 
2906
+ export class UnsupportedNetworkError extends WebrpcError {
2907
+ constructor(
2908
+ name: string = 'UnsupportedNetwork',
2909
+ code: number = 3008,
2910
+ message: string = 'Unsupported network',
2911
+ status: number = 0,
2912
+ cause?: string
2913
+ ) {
2914
+ super(name, code, message, status, cause)
2915
+ Object.setPrototypeOf(this, UnsupportedNetworkError.prototype)
2916
+ }
2917
+ }
2918
+
2618
2919
  export enum errors {
2619
2920
  WebrpcEndpoint = 'WebrpcEndpoint',
2620
2921
  WebrpcRequestFailed = 'WebrpcRequestFailed',
@@ -2630,15 +2931,70 @@ export enum errors {
2630
2931
  Unauthorized = 'Unauthorized',
2631
2932
  PermissionDenied = 'PermissionDenied',
2632
2933
  SessionExpired = 'SessionExpired',
2934
+ MethodNotFound = 'MethodNotFound',
2935
+ RequestConflict = 'RequestConflict',
2633
2936
  Aborted = 'Aborted',
2634
2937
  Geoblocked = 'Geoblocked',
2938
+ RateLimited = 'RateLimited',
2939
+ ProjectNotFound = 'ProjectNotFound',
2940
+ AccessKeyNotFound = 'AccessKeyNotFound',
2941
+ AccessKeyMismatch = 'AccessKeyMismatch',
2942
+ InvalidOrigin = 'InvalidOrigin',
2943
+ InvalidService = 'InvalidService',
2944
+ UnauthorizedUser = 'UnauthorizedUser',
2945
+ QuotaExceeded = 'QuotaExceeded',
2946
+ QuotaRateLimit = 'QuotaRateLimit',
2947
+ NoDefaultKey = 'NoDefaultKey',
2948
+ MaxAccessKeys = 'MaxAccessKeys',
2949
+ AtLeastOneKey = 'AtLeastOneKey',
2950
+ Timeout = 'Timeout',
2635
2951
  InvalidArgument = 'InvalidArgument',
2636
2952
  Unavailable = 'Unavailable',
2637
2953
  QueryFailed = 'QueryFailed',
2638
- NotFound = 'NotFound'
2639
- }
2640
-
2641
- const webrpcErrorByCode: { [code: number]: any } = {
2954
+ NotFound = 'NotFound',
2955
+ UnsupportedNetwork = 'UnsupportedNetwork'
2956
+ }
2957
+
2958
+ export enum WebrpcErrorCodes {
2959
+ WebrpcEndpoint = 0,
2960
+ WebrpcRequestFailed = -1,
2961
+ WebrpcBadRoute = -2,
2962
+ WebrpcBadMethod = -3,
2963
+ WebrpcBadRequest = -4,
2964
+ WebrpcBadResponse = -5,
2965
+ WebrpcServerPanic = -6,
2966
+ WebrpcInternalError = -7,
2967
+ WebrpcClientDisconnected = -8,
2968
+ WebrpcStreamLost = -9,
2969
+ WebrpcStreamFinished = -10,
2970
+ Unauthorized = 1000,
2971
+ PermissionDenied = 1001,
2972
+ SessionExpired = 1002,
2973
+ MethodNotFound = 1003,
2974
+ RequestConflict = 1004,
2975
+ Aborted = 1005,
2976
+ Geoblocked = 1006,
2977
+ RateLimited = 1007,
2978
+ ProjectNotFound = 1008,
2979
+ AccessKeyNotFound = 1101,
2980
+ AccessKeyMismatch = 1102,
2981
+ InvalidOrigin = 1103,
2982
+ InvalidService = 1104,
2983
+ UnauthorizedUser = 1105,
2984
+ QuotaExceeded = 1200,
2985
+ QuotaRateLimit = 1201,
2986
+ NoDefaultKey = 1300,
2987
+ MaxAccessKeys = 1301,
2988
+ AtLeastOneKey = 1302,
2989
+ Timeout = 1900,
2990
+ InvalidArgument = 2000,
2991
+ Unavailable = 2002,
2992
+ QueryFailed = 2003,
2993
+ NotFound = 3000,
2994
+ UnsupportedNetwork = 3008
2995
+ }
2996
+
2997
+ export const webrpcErrorByCode: { [code: number]: any } = {
2642
2998
  [0]: WebrpcEndpointError,
2643
2999
  [-1]: WebrpcRequestFailedError,
2644
3000
  [-2]: WebrpcBadRouteError,
@@ -2653,12 +3009,28 @@ const webrpcErrorByCode: { [code: number]: any } = {
2653
3009
  [1000]: UnauthorizedError,
2654
3010
  [1001]: PermissionDeniedError,
2655
3011
  [1002]: SessionExpiredError,
3012
+ [1003]: MethodNotFoundError,
3013
+ [1004]: RequestConflictError,
2656
3014
  [1005]: AbortedError,
2657
3015
  [1006]: GeoblockedError,
3016
+ [1007]: RateLimitedError,
3017
+ [1008]: ProjectNotFoundError,
3018
+ [1101]: AccessKeyNotFoundError,
3019
+ [1102]: AccessKeyMismatchError,
3020
+ [1103]: InvalidOriginError,
3021
+ [1104]: InvalidServiceError,
3022
+ [1105]: UnauthorizedUserError,
3023
+ [1200]: QuotaExceededError,
3024
+ [1201]: QuotaRateLimitError,
3025
+ [1300]: NoDefaultKeyError,
3026
+ [1301]: MaxAccessKeysError,
3027
+ [1302]: AtLeastOneKeyError,
3028
+ [1900]: TimeoutError,
2658
3029
  [2000]: InvalidArgumentError,
2659
3030
  [2002]: UnavailableError,
2660
3031
  [2003]: QueryFailedError,
2661
- [3000]: NotFoundError
3032
+ [3000]: NotFoundError,
3033
+ [3008]: UnsupportedNetworkError
2662
3034
  }
2663
3035
 
2664
3036
  export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>