@0xsequence/indexer 3.0.0-beta.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-lint.log +4 -0
- package/.turbo/turbo-test.log +5 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/CHANGELOG.md +91 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -47
- package/dist/indexer.gen.d.ts +993 -633
- package/dist/indexer.gen.d.ts.map +1 -1
- package/dist/indexer.gen.js +885 -632
- package/dist/indexergw.gen.d.ts +686 -455
- package/dist/indexergw.gen.d.ts.map +1 -1
- package/dist/indexergw.gen.js +684 -426
- package/eslint.config.js +4 -0
- package/package.json +8 -5
- package/src/index.ts +6 -6
- package/src/indexer.gen.ts +1904 -1487
- package/src/indexergw.gen.ts +1215 -946
- package/tsconfig.json +3 -1
package/dist/indexer.gen.js
CHANGED
|
@@ -1,67 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* eslint-disable */
|
|
3
|
-
// sequence-indexer v0.4.0
|
|
2
|
+
// sequence-indexer v0.4.0 2bca559c4c590bce7d70c33df115a58399efec82
|
|
4
3
|
// --
|
|
5
|
-
// Code generated by
|
|
4
|
+
// Code generated by Webrpc-gen@v0.31.2 with typescript generator. DO NOT EDIT.
|
|
6
5
|
//
|
|
7
|
-
// webrpc-gen -schema=
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.errors = exports.MetadataCallFailedError = exports.NotFoundError = exports.ResourceExhaustedError = exports.QueryFailedError = void 0;
|
|
11
|
-
exports.VersionFromHeader = VersionFromHeader;
|
|
12
|
-
exports.WebrpcHeader = 'Webrpc';
|
|
13
|
-
exports.WebrpcHeaderValue = 'webrpc@v0.21.1;gen-typescript@v0.15.1;sequence-indexer@v0.4.0';
|
|
14
|
-
// WebRPC description and code-gen version
|
|
15
|
-
exports.WebRPCVersion = 'v1';
|
|
6
|
+
// webrpc-gen -schema=merged.gen.json -service=Indexer -target=typescript -client -out=./clients/indexer.gen.ts
|
|
7
|
+
// Webrpc description and code-gen version
|
|
8
|
+
export const WebrpcVersion = 'v1';
|
|
16
9
|
// Schema version of your RIDL schema
|
|
17
|
-
|
|
10
|
+
export const WebrpcSchemaVersion = 'v0.4.0';
|
|
18
11
|
// Schema hash generated from your RIDL schema
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
codeGenVersion: '',
|
|
27
|
-
schemaName: '',
|
|
28
|
-
schemaVersion: '',
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
return parseWebrpcGenVersions(headerValue);
|
|
32
|
-
}
|
|
33
|
-
function parseWebrpcGenVersions(header) {
|
|
34
|
-
const versions = header.split(';');
|
|
35
|
-
if (versions.length < 3) {
|
|
36
|
-
return {
|
|
37
|
-
webrpcGenVersion: '',
|
|
38
|
-
codeGenName: '',
|
|
39
|
-
codeGenVersion: '',
|
|
40
|
-
schemaName: '',
|
|
41
|
-
schemaVersion: '',
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
const [_, webrpcGenVersion] = versions[0].split('@');
|
|
45
|
-
const [codeGenName, codeGenVersion] = versions[1].split('@');
|
|
46
|
-
const [schemaName, schemaVersion] = versions[2].split('@');
|
|
47
|
-
return {
|
|
48
|
-
webrpcGenVersion: webrpcGenVersion,
|
|
49
|
-
codeGenName: codeGenName,
|
|
50
|
-
codeGenVersion: codeGenVersion,
|
|
51
|
-
schemaName: schemaName,
|
|
52
|
-
schemaVersion: schemaVersion,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
//
|
|
56
|
-
// Types
|
|
57
|
-
//
|
|
58
|
-
var ResourceStatus;
|
|
59
|
-
(function (ResourceStatus) {
|
|
60
|
-
ResourceStatus["NOT_AVAILABLE"] = "NOT_AVAILABLE";
|
|
61
|
-
ResourceStatus["REFRESHING"] = "REFRESHING";
|
|
62
|
-
ResourceStatus["AVAILABLE"] = "AVAILABLE";
|
|
63
|
-
})(ResourceStatus || (exports.ResourceStatus = ResourceStatus = {}));
|
|
64
|
-
var ContractType;
|
|
12
|
+
export const WebrpcSchemaHash = '2bca559c4c590bce7d70c33df115a58399efec82';
|
|
13
|
+
export var BackupMode;
|
|
14
|
+
(function (BackupMode) {
|
|
15
|
+
BackupMode["INCREMENTAL"] = "INCREMENTAL";
|
|
16
|
+
BackupMode["COMPLETE"] = "COMPLETE";
|
|
17
|
+
})(BackupMode || (BackupMode = {}));
|
|
18
|
+
export var ContractType;
|
|
65
19
|
(function (ContractType) {
|
|
66
20
|
ContractType["UNKNOWN"] = "UNKNOWN";
|
|
67
21
|
ContractType["NATIVE"] = "NATIVE";
|
|
@@ -73,58 +27,71 @@ var ContractType;
|
|
|
73
27
|
ContractType["ERC721_BRIDGE"] = "ERC721_BRIDGE";
|
|
74
28
|
ContractType["ERC1155_BRIDGE"] = "ERC1155_BRIDGE";
|
|
75
29
|
ContractType["SEQ_MARKETPLACE"] = "SEQ_MARKETPLACE";
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
30
|
+
ContractType["ERC6909"] = "ERC6909";
|
|
31
|
+
})(ContractType || (ContractType = {}));
|
|
32
|
+
export var ContractVerificationStatus;
|
|
33
|
+
(function (ContractVerificationStatus) {
|
|
34
|
+
ContractVerificationStatus["VERIFIED"] = "VERIFIED";
|
|
35
|
+
ContractVerificationStatus["UNVERIFIED"] = "UNVERIFIED";
|
|
36
|
+
ContractVerificationStatus["ALL"] = "ALL";
|
|
37
|
+
})(ContractVerificationStatus || (ContractVerificationStatus = {}));
|
|
38
|
+
export var EventLogDataType;
|
|
84
39
|
(function (EventLogDataType) {
|
|
85
40
|
EventLogDataType["EVENT"] = "EVENT";
|
|
86
41
|
EventLogDataType["TOKEN_TRANSFER"] = "TOKEN_TRANSFER";
|
|
87
42
|
EventLogDataType["NATIVE_TOKEN_TRANSFER"] = "NATIVE_TOKEN_TRANSFER";
|
|
88
43
|
EventLogDataType["SEQUENCE_TXN"] = "SEQUENCE_TXN";
|
|
89
|
-
})(EventLogDataType || (
|
|
90
|
-
var
|
|
44
|
+
})(EventLogDataType || (EventLogDataType = {}));
|
|
45
|
+
export var EventLogType;
|
|
46
|
+
(function (EventLogType) {
|
|
47
|
+
EventLogType["UNKNOWN"] = "UNKNOWN";
|
|
48
|
+
EventLogType["BLOCK_ADDED"] = "BLOCK_ADDED";
|
|
49
|
+
EventLogType["BLOCK_REMOVED"] = "BLOCK_REMOVED";
|
|
50
|
+
})(EventLogType || (EventLogType = {}));
|
|
51
|
+
export var NetworkType;
|
|
52
|
+
(function (NetworkType) {
|
|
53
|
+
NetworkType["MAINNETS"] = "MAINNETS";
|
|
54
|
+
NetworkType["TESTNETS"] = "TESTNETS";
|
|
55
|
+
NetworkType["ALL"] = "ALL";
|
|
56
|
+
})(NetworkType || (NetworkType = {}));
|
|
57
|
+
export var OrderStatus;
|
|
91
58
|
(function (OrderStatus) {
|
|
92
59
|
OrderStatus["OPEN"] = "OPEN";
|
|
93
60
|
OrderStatus["CLOSED"] = "CLOSED";
|
|
94
61
|
OrderStatus["CANCELLED"] = "CANCELLED";
|
|
95
|
-
})(OrderStatus || (
|
|
96
|
-
var
|
|
97
|
-
(function (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
})(
|
|
102
|
-
var
|
|
62
|
+
})(OrderStatus || (OrderStatus = {}));
|
|
63
|
+
export var ResourceStatus;
|
|
64
|
+
(function (ResourceStatus) {
|
|
65
|
+
ResourceStatus["NOT_AVAILABLE"] = "NOT_AVAILABLE";
|
|
66
|
+
ResourceStatus["REFRESHING"] = "REFRESHING";
|
|
67
|
+
ResourceStatus["AVAILABLE"] = "AVAILABLE";
|
|
68
|
+
})(ResourceStatus || (ResourceStatus = {}));
|
|
69
|
+
export var SortOrder;
|
|
70
|
+
(function (SortOrder) {
|
|
71
|
+
SortOrder["DESC"] = "DESC";
|
|
72
|
+
SortOrder["ASC"] = "ASC";
|
|
73
|
+
})(SortOrder || (SortOrder = {}));
|
|
74
|
+
export var TransactionStatus;
|
|
103
75
|
(function (TransactionStatus) {
|
|
104
76
|
TransactionStatus["FAILED"] = "FAILED";
|
|
105
77
|
TransactionStatus["SUCCESSFUL"] = "SUCCESSFUL";
|
|
106
|
-
})(TransactionStatus || (
|
|
107
|
-
var TransactionType;
|
|
78
|
+
})(TransactionStatus || (TransactionStatus = {}));
|
|
79
|
+
export var TransactionType;
|
|
108
80
|
(function (TransactionType) {
|
|
109
81
|
TransactionType["LegacyTxnType"] = "LegacyTxnType";
|
|
110
82
|
TransactionType["AccessListTxnType"] = "AccessListTxnType";
|
|
111
83
|
TransactionType["DynamicFeeTxnType"] = "DynamicFeeTxnType";
|
|
112
|
-
})(TransactionType || (
|
|
113
|
-
var
|
|
114
|
-
(function (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
(function (ContractVerificationStatus) {
|
|
120
|
-
ContractVerificationStatus["VERIFIED"] = "VERIFIED";
|
|
121
|
-
ContractVerificationStatus["UNVERIFIED"] = "UNVERIFIED";
|
|
122
|
-
ContractVerificationStatus["ALL"] = "ALL";
|
|
123
|
-
})(ContractVerificationStatus || (exports.ContractVerificationStatus = ContractVerificationStatus = {}));
|
|
84
|
+
})(TransactionType || (TransactionType = {}));
|
|
85
|
+
export var TxnTransferType;
|
|
86
|
+
(function (TxnTransferType) {
|
|
87
|
+
TxnTransferType["UNKNOWN"] = "UNKNOWN";
|
|
88
|
+
TxnTransferType["SEND"] = "SEND";
|
|
89
|
+
TxnTransferType["RECEIVE"] = "RECEIVE";
|
|
90
|
+
})(TxnTransferType || (TxnTransferType = {}));
|
|
124
91
|
//
|
|
125
92
|
// Client
|
|
126
93
|
//
|
|
127
|
-
class Indexer {
|
|
94
|
+
export class Indexer {
|
|
128
95
|
hostname;
|
|
129
96
|
fetch;
|
|
130
97
|
path = '/rpc/Indexer/';
|
|
@@ -135,376 +102,399 @@ class Indexer {
|
|
|
135
102
|
url(name) {
|
|
136
103
|
return this.hostname + this.path + name;
|
|
137
104
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
105
|
+
queryKey = {
|
|
106
|
+
addWebhookListener: (req) => ['Indexer', 'addWebhookListener', req],
|
|
107
|
+
fetchTransactionReceipt: (req) => ['Indexer', 'fetchTransactionReceipt', req],
|
|
108
|
+
fetchTransactionReceiptWithFilter: (req) => ['Indexer', 'fetchTransactionReceiptWithFilter', req],
|
|
109
|
+
getAllWebhookListeners: (req) => ['Indexer', 'getAllWebhookListeners', req],
|
|
110
|
+
getBalanceUpdates: (req) => ['Indexer', 'getBalanceUpdates', req],
|
|
111
|
+
getChainID: () => ['Indexer', 'getChainID'],
|
|
112
|
+
getEtherBalance: (req) => ['Indexer', 'getEtherBalance', req],
|
|
113
|
+
getMarketplaceOrders: (req) => ['Indexer', 'getMarketplaceOrders', req],
|
|
114
|
+
getMarketplaceTopOrders: (req) => ['Indexer', 'getMarketplaceTopOrders', req],
|
|
115
|
+
getNativeTokenBalance: (req) => ['Indexer', 'getNativeTokenBalance', req],
|
|
116
|
+
getTokenBalances: (req) => ['Indexer', 'getTokenBalances', req],
|
|
117
|
+
getTokenBalancesByContract: (req) => ['Indexer', 'getTokenBalancesByContract', req],
|
|
118
|
+
getTokenBalancesDetails: (req) => ['Indexer', 'getTokenBalancesDetails', req],
|
|
119
|
+
getTokenBalancesSummary: (req) => ['Indexer', 'getTokenBalancesSummary', req],
|
|
120
|
+
getTokenIDRanges: (req) => ['Indexer', 'getTokenIDRanges', req],
|
|
121
|
+
getTokenIDs: (req) => ['Indexer', 'getTokenIDs', req],
|
|
122
|
+
getTokenPrice: (req) => ['Indexer', 'getTokenPrice', req],
|
|
123
|
+
getTokenPrices: (req) => ['Indexer', 'getTokenPrices', req],
|
|
124
|
+
getTokenSupplies: (req) => ['Indexer', 'getTokenSupplies', req],
|
|
125
|
+
getTokenSuppliesMap: (req) => ['Indexer', 'getTokenSuppliesMap', req],
|
|
126
|
+
getTransactionHistory: (req) => ['Indexer', 'getTransactionHistory', req],
|
|
127
|
+
getWebhookListener: (req) => ['Indexer', 'getWebhookListener', req],
|
|
128
|
+
listTokenPrices: (req) => ['Indexer', 'listTokenPrices', req],
|
|
129
|
+
pauseAllWebhookListeners: (req) => ['Indexer', 'pauseAllWebhookListeners', req],
|
|
130
|
+
ping: () => ['Indexer', 'ping'],
|
|
131
|
+
removeAllWebhookListeners: (req) => ['Indexer', 'removeAllWebhookListeners', req],
|
|
132
|
+
removeWebhookListener: (req) => ['Indexer', 'removeWebhookListener', req],
|
|
133
|
+
resumeAllWebhookListeners: (req) => ['Indexer', 'resumeAllWebhookListeners', req],
|
|
134
|
+
runtimeStatus: () => ['Indexer', 'runtimeStatus'],
|
|
135
|
+
subscribeBalanceUpdates: (req) => ['Indexer', 'subscribeBalanceUpdates', req],
|
|
136
|
+
subscribeEvents: (req) => ['Indexer', 'subscribeEvents', req],
|
|
137
|
+
subscribeReceipts: (req) => ['Indexer', 'subscribeReceipts', req],
|
|
138
|
+
syncBalance: (req) => ['Indexer', 'syncBalance', req],
|
|
139
|
+
toggleWebhookListener: (req) => ['Indexer', 'toggleWebhookListener', req],
|
|
140
|
+
updateWebhookListener: (req) => ['Indexer', 'updateWebhookListener', req],
|
|
141
|
+
version: () => ['Indexer', 'version']
|
|
142
|
+
};
|
|
143
|
+
addWebhookListener = (req, headers, signal) => {
|
|
144
|
+
return this.fetch(this.url('AddWebhookListener'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
145
|
+
return buildResponse(res).then(_data => {
|
|
146
|
+
return JsonDecode(_data, 'AddWebhookListenerResponse');
|
|
144
147
|
});
|
|
145
|
-
},
|
|
146
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
148
|
+
}, error => {
|
|
149
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
147
150
|
});
|
|
148
151
|
};
|
|
149
|
-
|
|
150
|
-
return this.fetch(this.url('
|
|
151
|
-
return buildResponse(res).then(
|
|
152
|
-
return
|
|
153
|
-
version: _data.version,
|
|
154
|
-
};
|
|
152
|
+
fetchTransactionReceipt = (req, headers, signal) => {
|
|
153
|
+
return this.fetch(this.url('FetchTransactionReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
154
|
+
return buildResponse(res).then(_data => {
|
|
155
|
+
return JsonDecode(_data, 'FetchTransactionReceiptResponse');
|
|
155
156
|
});
|
|
156
|
-
},
|
|
157
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
157
|
+
}, error => {
|
|
158
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
158
159
|
});
|
|
159
160
|
};
|
|
160
|
-
|
|
161
|
-
return this.fetch(this.url('
|
|
162
|
-
return buildResponse(res).then(
|
|
163
|
-
return
|
|
164
|
-
status: _data.status,
|
|
165
|
-
};
|
|
161
|
+
fetchTransactionReceiptWithFilter = (req, headers, signal) => {
|
|
162
|
+
return this.fetch(this.url('FetchTransactionReceiptWithFilter'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
163
|
+
return buildResponse(res).then(_data => {
|
|
164
|
+
return JsonDecode(_data, 'FetchTransactionReceiptWithFilterResponse');
|
|
166
165
|
});
|
|
167
|
-
},
|
|
168
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
166
|
+
}, error => {
|
|
167
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
getAllWebhookListeners = (req, headers, signal) => {
|
|
171
|
+
return this.fetch(this.url('GetAllWebhookListeners'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
172
|
+
return buildResponse(res).then(_data => {
|
|
173
|
+
return JsonDecode(_data, 'GetAllWebhookListenersResponse');
|
|
174
|
+
});
|
|
175
|
+
}, error => {
|
|
176
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
getBalanceUpdates = (req, headers, signal) => {
|
|
180
|
+
return this.fetch(this.url('GetBalanceUpdates'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
181
|
+
return buildResponse(res).then(_data => {
|
|
182
|
+
return JsonDecode(_data, 'GetBalanceUpdatesResponse');
|
|
183
|
+
});
|
|
184
|
+
}, error => {
|
|
185
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
169
186
|
});
|
|
170
187
|
};
|
|
171
188
|
getChainID = (headers, signal) => {
|
|
172
|
-
return this.fetch(this.url('GetChainID'),
|
|
173
|
-
return buildResponse(res).then(
|
|
174
|
-
return
|
|
175
|
-
chainID: _data.chainID,
|
|
176
|
-
};
|
|
189
|
+
return this.fetch(this.url('GetChainID'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
190
|
+
return buildResponse(res).then(_data => {
|
|
191
|
+
return JsonDecode(_data, 'GetChainIDResponse');
|
|
177
192
|
});
|
|
178
|
-
},
|
|
179
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
193
|
+
}, error => {
|
|
194
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
180
195
|
});
|
|
181
196
|
};
|
|
182
|
-
getEtherBalance = (
|
|
183
|
-
return this.fetch(this.url('GetEtherBalance'),
|
|
184
|
-
return buildResponse(res).then(
|
|
185
|
-
return
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
});
|
|
189
|
-
}, (error) => {
|
|
190
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
197
|
+
getEtherBalance = (req, headers, signal) => {
|
|
198
|
+
return this.fetch(this.url('GetEtherBalance'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
199
|
+
return buildResponse(res).then(_data => {
|
|
200
|
+
return JsonDecode(_data, 'GetEtherBalanceResponse');
|
|
201
|
+
});
|
|
202
|
+
}, error => {
|
|
203
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
191
204
|
});
|
|
192
205
|
};
|
|
193
|
-
|
|
194
|
-
return this.fetch(this.url('
|
|
195
|
-
return buildResponse(res).then(
|
|
196
|
-
return
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
});
|
|
200
|
-
}, (error) => {
|
|
201
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
206
|
+
getMarketplaceOrders = (req, headers, signal) => {
|
|
207
|
+
return this.fetch(this.url('GetMarketplaceOrders'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
208
|
+
return buildResponse(res).then(_data => {
|
|
209
|
+
return JsonDecode(_data, 'GetMarketplaceOrdersResponse');
|
|
210
|
+
});
|
|
211
|
+
}, error => {
|
|
212
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
202
213
|
});
|
|
203
214
|
};
|
|
204
|
-
|
|
205
|
-
return this.fetch(this.url('
|
|
206
|
-
return buildResponse(res).then(
|
|
207
|
-
return
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
};
|
|
212
|
-
});
|
|
213
|
-
}, (error) => {
|
|
214
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
215
|
+
getMarketplaceTopOrders = (req, headers, signal) => {
|
|
216
|
+
return this.fetch(this.url('GetMarketplaceTopOrders'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
217
|
+
return buildResponse(res).then(_data => {
|
|
218
|
+
return JsonDecode(_data, 'GetMarketplaceTopOrdersResponse');
|
|
219
|
+
});
|
|
220
|
+
}, error => {
|
|
221
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
215
222
|
});
|
|
216
223
|
};
|
|
217
|
-
|
|
218
|
-
return this.fetch(this.url('
|
|
219
|
-
return buildResponse(res).then(
|
|
220
|
-
return
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
};
|
|
225
|
-
});
|
|
226
|
-
}, (error) => {
|
|
227
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
224
|
+
getNativeTokenBalance = (req, headers, signal) => {
|
|
225
|
+
return this.fetch(this.url('GetNativeTokenBalance'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
226
|
+
return buildResponse(res).then(_data => {
|
|
227
|
+
return JsonDecode(_data, 'GetNativeTokenBalanceResponse');
|
|
228
|
+
});
|
|
229
|
+
}, error => {
|
|
230
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
228
231
|
});
|
|
229
232
|
};
|
|
230
|
-
|
|
231
|
-
return this.fetch(this.url('
|
|
232
|
-
return buildResponse(res).then(
|
|
233
|
-
return
|
|
234
|
-
page: _data.page,
|
|
235
|
-
balances: _data.balances,
|
|
236
|
-
};
|
|
233
|
+
getTokenBalances = (req, headers, signal) => {
|
|
234
|
+
return this.fetch(this.url('GetTokenBalances'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
235
|
+
return buildResponse(res).then(_data => {
|
|
236
|
+
return JsonDecode(_data, 'GetTokenBalancesResponse');
|
|
237
237
|
});
|
|
238
|
-
},
|
|
239
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
238
|
+
}, error => {
|
|
239
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
240
240
|
});
|
|
241
241
|
};
|
|
242
|
-
|
|
243
|
-
return this.fetch(this.url('
|
|
244
|
-
return buildResponse(res).then(
|
|
245
|
-
return
|
|
246
|
-
page: _data.page,
|
|
247
|
-
balances: _data.balances,
|
|
248
|
-
};
|
|
242
|
+
getTokenBalancesByContract = (req, headers, signal) => {
|
|
243
|
+
return this.fetch(this.url('GetTokenBalancesByContract'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
244
|
+
return buildResponse(res).then(_data => {
|
|
245
|
+
return JsonDecode(_data, 'GetTokenBalancesByContractResponse');
|
|
249
246
|
});
|
|
250
|
-
},
|
|
251
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
247
|
+
}, error => {
|
|
248
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
252
249
|
});
|
|
253
250
|
};
|
|
254
|
-
|
|
255
|
-
return this.fetch(this.url('
|
|
256
|
-
return buildResponse(res).then(
|
|
257
|
-
return
|
|
258
|
-
page: _data.page,
|
|
259
|
-
contractType: _data.contractType,
|
|
260
|
-
tokenIDs: _data.tokenIDs,
|
|
261
|
-
};
|
|
251
|
+
getTokenBalancesDetails = (req, headers, signal) => {
|
|
252
|
+
return this.fetch(this.url('GetTokenBalancesDetails'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
253
|
+
return buildResponse(res).then(_data => {
|
|
254
|
+
return JsonDecode(_data, 'GetTokenBalancesDetailsResponse');
|
|
262
255
|
});
|
|
263
|
-
},
|
|
264
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
256
|
+
}, error => {
|
|
257
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
265
258
|
});
|
|
266
259
|
};
|
|
267
|
-
|
|
268
|
-
return this.fetch(this.url('
|
|
269
|
-
return buildResponse(res).then(
|
|
270
|
-
return
|
|
271
|
-
supplies: _data.supplies,
|
|
272
|
-
};
|
|
260
|
+
getTokenBalancesSummary = (req, headers, signal) => {
|
|
261
|
+
return this.fetch(this.url('GetTokenBalancesSummary'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
262
|
+
return buildResponse(res).then(_data => {
|
|
263
|
+
return JsonDecode(_data, 'GetTokenBalancesSummaryResponse');
|
|
273
264
|
});
|
|
274
|
-
},
|
|
275
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
265
|
+
}, error => {
|
|
266
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
276
267
|
});
|
|
277
268
|
};
|
|
278
|
-
|
|
279
|
-
return this.fetch(this.url('
|
|
280
|
-
return buildResponse(res).then(
|
|
281
|
-
return
|
|
282
|
-
page: _data.page,
|
|
283
|
-
contractType: _data.contractType,
|
|
284
|
-
tokenIDs: _data.tokenIDs,
|
|
285
|
-
};
|
|
269
|
+
getTokenIDRanges = (req, headers, signal) => {
|
|
270
|
+
return this.fetch(this.url('GetTokenIDRanges'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
271
|
+
return buildResponse(res).then(_data => {
|
|
272
|
+
return JsonDecode(_data, 'GetTokenIDRangesResponse');
|
|
286
273
|
});
|
|
287
|
-
},
|
|
288
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
274
|
+
}, error => {
|
|
275
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
289
276
|
});
|
|
290
277
|
};
|
|
291
|
-
|
|
292
|
-
return this.fetch(this.url('
|
|
293
|
-
return buildResponse(res).then(
|
|
294
|
-
return
|
|
295
|
-
contractType: _data.contractType,
|
|
296
|
-
tokenIDRanges: _data.tokenIDRanges,
|
|
297
|
-
moreRanges: _data.moreRanges,
|
|
298
|
-
};
|
|
278
|
+
getTokenIDs = (req, headers, signal) => {
|
|
279
|
+
return this.fetch(this.url('GetTokenIDs'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
280
|
+
return buildResponse(res).then(_data => {
|
|
281
|
+
return JsonDecode(_data, 'GetTokenIDsResponse');
|
|
299
282
|
});
|
|
300
|
-
},
|
|
301
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
283
|
+
}, error => {
|
|
284
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
302
285
|
});
|
|
303
286
|
};
|
|
304
|
-
|
|
305
|
-
return this.fetch(this.url('
|
|
306
|
-
return buildResponse(res).then(
|
|
307
|
-
return
|
|
308
|
-
page: _data.page,
|
|
309
|
-
balances: _data.balances,
|
|
310
|
-
};
|
|
287
|
+
getTokenPrice = (req, headers, signal) => {
|
|
288
|
+
return this.fetch(this.url('GetTokenPrice'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
289
|
+
return buildResponse(res).then(_data => {
|
|
290
|
+
return JsonDecode(_data, 'GetTokenPriceResponse');
|
|
311
291
|
});
|
|
312
|
-
},
|
|
313
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
292
|
+
}, error => {
|
|
293
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
314
294
|
});
|
|
315
295
|
};
|
|
316
|
-
|
|
317
|
-
return this.fetch(this.url('
|
|
318
|
-
return buildResponse(res).then(
|
|
319
|
-
return
|
|
320
|
-
page: _data.page,
|
|
321
|
-
transactions: _data.transactions,
|
|
322
|
-
};
|
|
296
|
+
getTokenPrices = (req, headers, signal) => {
|
|
297
|
+
return this.fetch(this.url('GetTokenPrices'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
298
|
+
return buildResponse(res).then(_data => {
|
|
299
|
+
return JsonDecode(_data, 'GetTokenPricesResponse');
|
|
323
300
|
});
|
|
324
|
-
},
|
|
325
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
301
|
+
}, error => {
|
|
302
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
326
303
|
});
|
|
327
304
|
};
|
|
328
|
-
|
|
329
|
-
return this.fetch(this.url('
|
|
330
|
-
return buildResponse(res).then(
|
|
331
|
-
return
|
|
332
|
-
receipt: _data.receipt,
|
|
333
|
-
};
|
|
305
|
+
getTokenSupplies = (req, headers, signal) => {
|
|
306
|
+
return this.fetch(this.url('GetTokenSupplies'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
307
|
+
return buildResponse(res).then(_data => {
|
|
308
|
+
return JsonDecode(_data, 'GetTokenSuppliesResponse');
|
|
334
309
|
});
|
|
335
|
-
},
|
|
336
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
310
|
+
}, error => {
|
|
311
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
337
312
|
});
|
|
338
313
|
};
|
|
339
|
-
|
|
340
|
-
return this.fetch(this.url('
|
|
341
|
-
return buildResponse(res).then(
|
|
342
|
-
return
|
|
343
|
-
receipt: _data.receipt,
|
|
344
|
-
};
|
|
314
|
+
getTokenSuppliesMap = (req, headers, signal) => {
|
|
315
|
+
return this.fetch(this.url('GetTokenSuppliesMap'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
316
|
+
return buildResponse(res).then(_data => {
|
|
317
|
+
return JsonDecode(_data, 'GetTokenSuppliesMapResponse');
|
|
345
318
|
});
|
|
346
|
-
},
|
|
347
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
319
|
+
}, error => {
|
|
320
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
348
321
|
});
|
|
349
322
|
};
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
323
|
+
getTransactionHistory = (req, headers, signal) => {
|
|
324
|
+
return this.fetch(this.url('GetTransactionHistory'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
325
|
+
return buildResponse(res).then(_data => {
|
|
326
|
+
return JsonDecode(_data, 'GetTransactionHistoryResponse');
|
|
327
|
+
});
|
|
328
|
+
}, error => {
|
|
329
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
355
330
|
});
|
|
356
|
-
return _fetch();
|
|
357
331
|
};
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
332
|
+
getWebhookListener = (req, headers, signal) => {
|
|
333
|
+
return this.fetch(this.url('GetWebhookListener'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
334
|
+
return buildResponse(res).then(_data => {
|
|
335
|
+
return JsonDecode(_data, 'GetWebhookListenerResponse');
|
|
336
|
+
});
|
|
337
|
+
}, error => {
|
|
338
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
363
339
|
});
|
|
364
|
-
return _fetch();
|
|
365
340
|
};
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
341
|
+
listTokenPrices = (req, headers, signal) => {
|
|
342
|
+
return this.fetch(this.url('ListTokenPrices'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
343
|
+
return buildResponse(res).then(_data => {
|
|
344
|
+
return JsonDecode(_data, 'ListTokenPricesResponse');
|
|
345
|
+
});
|
|
346
|
+
}, error => {
|
|
347
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
371
348
|
});
|
|
372
|
-
return _fetch();
|
|
373
349
|
};
|
|
374
|
-
|
|
375
|
-
return this.fetch(this.url('
|
|
376
|
-
return buildResponse(res).then(
|
|
377
|
-
return
|
|
350
|
+
pauseAllWebhookListeners = (req, headers, signal) => {
|
|
351
|
+
return this.fetch(this.url('PauseAllWebhookListeners'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
352
|
+
return buildResponse(res).then(_data => {
|
|
353
|
+
return JsonDecode(_data, 'PauseAllWebhookListenersResponse');
|
|
378
354
|
});
|
|
379
|
-
},
|
|
380
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
355
|
+
}, error => {
|
|
356
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
381
357
|
});
|
|
382
358
|
};
|
|
383
|
-
|
|
384
|
-
return this.fetch(this.url('
|
|
385
|
-
return buildResponse(res).then(
|
|
386
|
-
return
|
|
387
|
-
listeners: _data.listeners,
|
|
388
|
-
};
|
|
359
|
+
ping = (headers, signal) => {
|
|
360
|
+
return this.fetch(this.url('Ping'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
361
|
+
return buildResponse(res).then(_data => {
|
|
362
|
+
return JsonDecode(_data, 'PingResponse');
|
|
389
363
|
});
|
|
390
|
-
},
|
|
391
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
364
|
+
}, error => {
|
|
365
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
392
366
|
});
|
|
393
367
|
};
|
|
394
|
-
|
|
395
|
-
return this.fetch(this.url('
|
|
396
|
-
return buildResponse(res).then(
|
|
397
|
-
return
|
|
398
|
-
listener: _data.listener,
|
|
399
|
-
};
|
|
368
|
+
removeAllWebhookListeners = (req, headers, signal) => {
|
|
369
|
+
return this.fetch(this.url('RemoveAllWebhookListeners'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
370
|
+
return buildResponse(res).then(_data => {
|
|
371
|
+
return JsonDecode(_data, 'RemoveAllWebhookListenersResponse');
|
|
400
372
|
});
|
|
401
|
-
},
|
|
402
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
373
|
+
}, error => {
|
|
374
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
403
375
|
});
|
|
404
376
|
};
|
|
405
|
-
|
|
406
|
-
return this.fetch(this.url('
|
|
407
|
-
return buildResponse(res).then(
|
|
408
|
-
return
|
|
409
|
-
status: _data.status,
|
|
410
|
-
listener: _data.listener,
|
|
411
|
-
};
|
|
377
|
+
removeWebhookListener = (req, headers, signal) => {
|
|
378
|
+
return this.fetch(this.url('RemoveWebhookListener'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
379
|
+
return buildResponse(res).then(_data => {
|
|
380
|
+
return JsonDecode(_data, 'RemoveWebhookListenerResponse');
|
|
412
381
|
});
|
|
413
|
-
},
|
|
414
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
382
|
+
}, error => {
|
|
383
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
415
384
|
});
|
|
416
385
|
};
|
|
417
|
-
|
|
418
|
-
return this.fetch(this.url('
|
|
419
|
-
return buildResponse(res).then(
|
|
420
|
-
return
|
|
421
|
-
status: _data.status,
|
|
422
|
-
};
|
|
386
|
+
resumeAllWebhookListeners = (req, headers, signal) => {
|
|
387
|
+
return this.fetch(this.url('ResumeAllWebhookListeners'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
388
|
+
return buildResponse(res).then(_data => {
|
|
389
|
+
return JsonDecode(_data, 'ResumeAllWebhookListenersResponse');
|
|
423
390
|
});
|
|
424
|
-
},
|
|
425
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
391
|
+
}, error => {
|
|
392
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
426
393
|
});
|
|
427
394
|
};
|
|
428
|
-
|
|
429
|
-
return this.fetch(this.url('
|
|
430
|
-
return buildResponse(res).then(
|
|
431
|
-
return
|
|
432
|
-
status: _data.status,
|
|
433
|
-
};
|
|
395
|
+
runtimeStatus = (headers, signal) => {
|
|
396
|
+
return this.fetch(this.url('RuntimeStatus'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
397
|
+
return buildResponse(res).then(_data => {
|
|
398
|
+
return JsonDecode(_data, 'RuntimeStatusResponse');
|
|
434
399
|
});
|
|
435
|
-
},
|
|
436
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
400
|
+
}, error => {
|
|
401
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
437
402
|
});
|
|
438
403
|
};
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
404
|
+
subscribeBalanceUpdates = (req, options) => {
|
|
405
|
+
const abortController = new AbortController();
|
|
406
|
+
const abortSignal = abortController.signal;
|
|
407
|
+
if (options.signal) {
|
|
408
|
+
abortSignal.addEventListener('abort', () => abortController.abort(options.signal?.reason), {
|
|
409
|
+
signal: options.signal
|
|
445
410
|
});
|
|
446
|
-
}
|
|
447
|
-
|
|
411
|
+
}
|
|
412
|
+
const _fetch = () => this.fetch(this.url('SubscribeBalanceUpdates'), createHttpRequest(JsonEncode(req), options.headers, abortSignal)).then(async (res) => {
|
|
413
|
+
await sseResponse(res, options, _fetch);
|
|
414
|
+
}, error => {
|
|
415
|
+
options.onError(error, _fetch);
|
|
448
416
|
});
|
|
417
|
+
const resp = _fetch();
|
|
418
|
+
return {
|
|
419
|
+
abort: abortController.abort.bind(abortController),
|
|
420
|
+
closed: resp
|
|
421
|
+
};
|
|
449
422
|
};
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
423
|
+
subscribeEvents = (req, options) => {
|
|
424
|
+
const abortController = new AbortController();
|
|
425
|
+
const abortSignal = abortController.signal;
|
|
426
|
+
if (options.signal) {
|
|
427
|
+
abortSignal.addEventListener('abort', () => abortController.abort(options.signal?.reason), {
|
|
428
|
+
signal: options.signal
|
|
456
429
|
});
|
|
457
|
-
}
|
|
458
|
-
|
|
430
|
+
}
|
|
431
|
+
const _fetch = () => this.fetch(this.url('SubscribeEvents'), createHttpRequest(JsonEncode(req), options.headers, abortSignal)).then(async (res) => {
|
|
432
|
+
await sseResponse(res, options, _fetch);
|
|
433
|
+
}, error => {
|
|
434
|
+
options.onError(error, _fetch);
|
|
459
435
|
});
|
|
436
|
+
const resp = _fetch();
|
|
437
|
+
return {
|
|
438
|
+
abort: abortController.abort.bind(abortController),
|
|
439
|
+
closed: resp
|
|
440
|
+
};
|
|
460
441
|
};
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
442
|
+
subscribeReceipts = (req, options) => {
|
|
443
|
+
const abortController = new AbortController();
|
|
444
|
+
const abortSignal = abortController.signal;
|
|
445
|
+
if (options.signal) {
|
|
446
|
+
abortSignal.addEventListener('abort', () => abortController.abort(options.signal?.reason), {
|
|
447
|
+
signal: options.signal
|
|
467
448
|
});
|
|
468
|
-
}
|
|
469
|
-
|
|
449
|
+
}
|
|
450
|
+
const _fetch = () => this.fetch(this.url('SubscribeReceipts'), createHttpRequest(JsonEncode(req), options.headers, abortSignal)).then(async (res) => {
|
|
451
|
+
await sseResponse(res, options, _fetch);
|
|
452
|
+
}, error => {
|
|
453
|
+
options.onError(error, _fetch);
|
|
470
454
|
});
|
|
455
|
+
const resp = _fetch();
|
|
456
|
+
return {
|
|
457
|
+
abort: abortController.abort.bind(abortController),
|
|
458
|
+
closed: resp
|
|
459
|
+
};
|
|
471
460
|
};
|
|
472
|
-
|
|
473
|
-
return this.fetch(this.url('
|
|
474
|
-
return buildResponse(res).then(
|
|
475
|
-
return
|
|
476
|
-
status: _data.status,
|
|
477
|
-
};
|
|
461
|
+
syncBalance = (req, headers, signal) => {
|
|
462
|
+
return this.fetch(this.url('SyncBalance'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
463
|
+
return buildResponse(res).then(_data => {
|
|
464
|
+
return JsonDecode(_data, 'SyncBalanceResponse');
|
|
478
465
|
});
|
|
479
|
-
},
|
|
480
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
466
|
+
}, error => {
|
|
467
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
481
468
|
});
|
|
482
469
|
};
|
|
483
|
-
|
|
484
|
-
return this.fetch(this.url('
|
|
485
|
-
return buildResponse(res).then(
|
|
486
|
-
return
|
|
487
|
-
page: _data.page,
|
|
488
|
-
orders: _data.orders,
|
|
489
|
-
};
|
|
470
|
+
toggleWebhookListener = (req, headers, signal) => {
|
|
471
|
+
return this.fetch(this.url('ToggleWebhookListener'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
472
|
+
return buildResponse(res).then(_data => {
|
|
473
|
+
return JsonDecode(_data, 'ToggleWebhookListenerResponse');
|
|
490
474
|
});
|
|
491
|
-
},
|
|
492
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
475
|
+
}, error => {
|
|
476
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
493
477
|
});
|
|
494
478
|
};
|
|
495
|
-
|
|
496
|
-
return this.fetch(this.url('
|
|
497
|
-
return buildResponse(res).then(
|
|
498
|
-
return
|
|
499
|
-
|
|
500
|
-
|
|
479
|
+
updateWebhookListener = (req, headers, signal) => {
|
|
480
|
+
return this.fetch(this.url('UpdateWebhookListener'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
481
|
+
return buildResponse(res).then(_data => {
|
|
482
|
+
return JsonDecode(_data, 'UpdateWebhookListenerResponse');
|
|
483
|
+
});
|
|
484
|
+
}, error => {
|
|
485
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
486
|
+
});
|
|
487
|
+
};
|
|
488
|
+
version = (headers, signal) => {
|
|
489
|
+
return this.fetch(this.url('Version'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
490
|
+
return buildResponse(res).then(_data => {
|
|
491
|
+
return JsonDecode(_data, 'VersionResponse');
|
|
501
492
|
});
|
|
502
|
-
},
|
|
503
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
493
|
+
}, error => {
|
|
494
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
504
495
|
});
|
|
505
496
|
};
|
|
506
497
|
}
|
|
507
|
-
exports.Indexer = Indexer;
|
|
508
498
|
const sseResponse = async (res, options, retryFetch) => {
|
|
509
499
|
const { onMessage, onOpen, onClose, onError } = options;
|
|
510
500
|
if (!res.ok) {
|
|
@@ -520,7 +510,7 @@ const sseResponse = async (res, options, retryFetch) => {
|
|
|
520
510
|
if (!res.body) {
|
|
521
511
|
onError(WebrpcBadResponseError.new({
|
|
522
512
|
status: res.status,
|
|
523
|
-
cause: 'Invalid response, missing body'
|
|
513
|
+
cause: 'Invalid response, missing body'
|
|
524
514
|
}), retryFetch);
|
|
525
515
|
return;
|
|
526
516
|
}
|
|
@@ -550,33 +540,30 @@ const sseResponse = async (res, options, retryFetch) => {
|
|
|
550
540
|
buffer += decoder.decode(value, { stream: true });
|
|
551
541
|
}
|
|
552
542
|
catch (error) {
|
|
553
|
-
let message = '';
|
|
554
|
-
if (error instanceof Error) {
|
|
555
|
-
message = error.message;
|
|
556
|
-
}
|
|
557
543
|
if (error instanceof DOMException && error.name === 'AbortError') {
|
|
558
|
-
onError(
|
|
544
|
+
onError(WebrpcClientAbortedError.new({
|
|
559
545
|
message: 'AbortError',
|
|
560
|
-
cause: `AbortError: ${message}
|
|
546
|
+
cause: `AbortError: ${error instanceof Error ? error.message : String(error)}`
|
|
561
547
|
}), () => {
|
|
562
548
|
throw new Error('Abort signal cannot be used to reconnect');
|
|
563
549
|
});
|
|
564
550
|
}
|
|
565
551
|
else {
|
|
566
552
|
onError(WebrpcStreamLostError.new({
|
|
567
|
-
cause: `reader.read(): ${message}
|
|
553
|
+
cause: `reader.read(): ${error instanceof Error ? error.message : String(error)}`
|
|
568
554
|
}), retryFetch);
|
|
569
555
|
}
|
|
570
556
|
return;
|
|
571
557
|
}
|
|
572
558
|
let lines = buffer.split('\n');
|
|
573
559
|
for (let i = 0; i < lines.length - 1; i++) {
|
|
574
|
-
|
|
560
|
+
const line = lines[i];
|
|
561
|
+
if (line?.length === 0) {
|
|
575
562
|
continue;
|
|
576
563
|
}
|
|
577
564
|
let data;
|
|
578
565
|
try {
|
|
579
|
-
data = JSON.parse(
|
|
566
|
+
data = JSON.parse(line);
|
|
580
567
|
if (data.hasOwnProperty('webrpcError')) {
|
|
581
568
|
const error = data.webrpcError;
|
|
582
569
|
const code = typeof error.code === 'number' ? error.code : 0;
|
|
@@ -590,44 +577,38 @@ const sseResponse = async (res, options, retryFetch) => {
|
|
|
590
577
|
}
|
|
591
578
|
onError(WebrpcBadResponseError.new({
|
|
592
579
|
status: res.status,
|
|
593
|
-
|
|
594
|
-
cause: `JSON.parse(): ${error.message}`,
|
|
580
|
+
cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}`
|
|
595
581
|
}), retryFetch);
|
|
596
582
|
}
|
|
597
583
|
onMessage(data);
|
|
598
584
|
}
|
|
599
585
|
if (!done) {
|
|
600
|
-
|
|
586
|
+
const lastLine = lines[lines.length - 1];
|
|
587
|
+
buffer = lastLine || '';
|
|
601
588
|
continue;
|
|
602
589
|
}
|
|
603
590
|
onClose && onClose();
|
|
604
591
|
return;
|
|
605
592
|
}
|
|
606
593
|
};
|
|
607
|
-
const
|
|
608
|
-
const reqHeaders = {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
headers: reqHeaders,
|
|
613
|
-
body: JSON.stringify(body || {}),
|
|
614
|
-
signal,
|
|
594
|
+
const createHttpRequest = (body = '{}', headers = {}, signal = null) => {
|
|
595
|
+
const reqHeaders = {
|
|
596
|
+
...headers,
|
|
597
|
+
'Content-Type': 'application/json',
|
|
598
|
+
[WebrpcHeader]: WebrpcHeaderValue
|
|
615
599
|
};
|
|
600
|
+
return { method: 'POST', headers: reqHeaders, body, signal };
|
|
616
601
|
};
|
|
617
602
|
const buildResponse = (res) => {
|
|
618
|
-
return res.text().then(
|
|
603
|
+
return res.text().then(text => {
|
|
619
604
|
let data;
|
|
620
605
|
try {
|
|
621
606
|
data = JSON.parse(text);
|
|
622
607
|
}
|
|
623
608
|
catch (error) {
|
|
624
|
-
let message = '';
|
|
625
|
-
if (error instanceof Error) {
|
|
626
|
-
message = error.message;
|
|
627
|
-
}
|
|
628
609
|
throw WebrpcBadResponseError.new({
|
|
629
610
|
status: res.status,
|
|
630
|
-
cause: `JSON.parse(): ${message}: response text: ${text}
|
|
611
|
+
cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`
|
|
631
612
|
});
|
|
632
613
|
}
|
|
633
614
|
if (!res.ok) {
|
|
@@ -637,294 +618,486 @@ const buildResponse = (res) => {
|
|
|
637
618
|
return data;
|
|
638
619
|
});
|
|
639
620
|
};
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
621
|
+
export const JsonEncode = (obj) => {
|
|
622
|
+
return JSON.stringify(obj);
|
|
623
|
+
};
|
|
624
|
+
export const JsonDecode = (data, _typ = '') => {
|
|
625
|
+
let parsed = data;
|
|
626
|
+
if (typeof data === 'string') {
|
|
627
|
+
try {
|
|
628
|
+
parsed = JSON.parse(data);
|
|
629
|
+
}
|
|
630
|
+
catch (err) {
|
|
631
|
+
throw WebrpcBadResponseError.new({ cause: `JsonDecode: JSON.parse failed: ${err.message}` });
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return parsed;
|
|
635
|
+
};
|
|
636
|
+
export class WebrpcError extends Error {
|
|
645
637
|
code;
|
|
646
|
-
message;
|
|
647
638
|
status;
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
this.
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
this.msg = this.message;
|
|
657
|
-
this.status = typeof status === 'number' ? status : 0;
|
|
658
|
-
this.cause = cause;
|
|
639
|
+
constructor(error = {}) {
|
|
640
|
+
super(error.message);
|
|
641
|
+
this.name = error.name || 'WebrpcEndpointError';
|
|
642
|
+
this.code = typeof error.code === 'number' ? error.code : 0;
|
|
643
|
+
this.message = error.message || `endpoint error`;
|
|
644
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
645
|
+
if (error.cause !== undefined)
|
|
646
|
+
this.cause = error.cause;
|
|
659
647
|
Object.setPrototypeOf(this, WebrpcError.prototype);
|
|
660
648
|
}
|
|
661
649
|
static new(payload) {
|
|
662
|
-
return new this(
|
|
650
|
+
return new this({ message: payload.message, code: payload.code, status: payload.status, cause: payload.cause });
|
|
663
651
|
}
|
|
664
652
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
653
|
+
export class WebrpcEndpointError extends WebrpcError {
|
|
654
|
+
constructor(error = {}) {
|
|
655
|
+
super(error);
|
|
656
|
+
this.name = error.name || 'WebrpcEndpoint';
|
|
657
|
+
this.code = typeof error.code === 'number' ? error.code : 0;
|
|
658
|
+
this.message = error.message || `endpoint error`;
|
|
659
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
660
|
+
if (error.cause !== undefined)
|
|
661
|
+
this.cause = error.cause;
|
|
670
662
|
Object.setPrototypeOf(this, WebrpcEndpointError.prototype);
|
|
671
663
|
}
|
|
672
664
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
665
|
+
export class WebrpcRequestFailedError extends WebrpcError {
|
|
666
|
+
constructor(error = {}) {
|
|
667
|
+
super(error);
|
|
668
|
+
this.name = error.name || 'WebrpcRequestFailed';
|
|
669
|
+
this.code = typeof error.code === 'number' ? error.code : -1;
|
|
670
|
+
this.message = error.message || `request failed`;
|
|
671
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
672
|
+
if (error.cause !== undefined)
|
|
673
|
+
this.cause = error.cause;
|
|
677
674
|
Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype);
|
|
678
675
|
}
|
|
679
676
|
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
677
|
+
export class WebrpcBadRouteError extends WebrpcError {
|
|
678
|
+
constructor(error = {}) {
|
|
679
|
+
super(error);
|
|
680
|
+
this.name = error.name || 'WebrpcBadRoute';
|
|
681
|
+
this.code = typeof error.code === 'number' ? error.code : -2;
|
|
682
|
+
this.message = error.message || `bad route`;
|
|
683
|
+
this.status = typeof error.status === 'number' ? error.status : 404;
|
|
684
|
+
if (error.cause !== undefined)
|
|
685
|
+
this.cause = error.cause;
|
|
684
686
|
Object.setPrototypeOf(this, WebrpcBadRouteError.prototype);
|
|
685
687
|
}
|
|
686
688
|
}
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
689
|
+
export class WebrpcBadMethodError extends WebrpcError {
|
|
690
|
+
constructor(error = {}) {
|
|
691
|
+
super(error);
|
|
692
|
+
this.name = error.name || 'WebrpcBadMethod';
|
|
693
|
+
this.code = typeof error.code === 'number' ? error.code : -3;
|
|
694
|
+
this.message = error.message || `bad method`;
|
|
695
|
+
this.status = typeof error.status === 'number' ? error.status : 405;
|
|
696
|
+
if (error.cause !== undefined)
|
|
697
|
+
this.cause = error.cause;
|
|
691
698
|
Object.setPrototypeOf(this, WebrpcBadMethodError.prototype);
|
|
692
699
|
}
|
|
693
700
|
}
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
701
|
+
export class WebrpcBadRequestError extends WebrpcError {
|
|
702
|
+
constructor(error = {}) {
|
|
703
|
+
super(error);
|
|
704
|
+
this.name = error.name || 'WebrpcBadRequest';
|
|
705
|
+
this.code = typeof error.code === 'number' ? error.code : -4;
|
|
706
|
+
this.message = error.message || `bad request`;
|
|
707
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
708
|
+
if (error.cause !== undefined)
|
|
709
|
+
this.cause = error.cause;
|
|
698
710
|
Object.setPrototypeOf(this, WebrpcBadRequestError.prototype);
|
|
699
711
|
}
|
|
700
712
|
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
713
|
+
export class WebrpcBadResponseError extends WebrpcError {
|
|
714
|
+
constructor(error = {}) {
|
|
715
|
+
super(error);
|
|
716
|
+
this.name = error.name || 'WebrpcBadResponse';
|
|
717
|
+
this.code = typeof error.code === 'number' ? error.code : -5;
|
|
718
|
+
this.message = error.message || `bad response`;
|
|
719
|
+
this.status = typeof error.status === 'number' ? error.status : 500;
|
|
720
|
+
if (error.cause !== undefined)
|
|
721
|
+
this.cause = error.cause;
|
|
705
722
|
Object.setPrototypeOf(this, WebrpcBadResponseError.prototype);
|
|
706
723
|
}
|
|
707
724
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
725
|
+
export class WebrpcServerPanicError extends WebrpcError {
|
|
726
|
+
constructor(error = {}) {
|
|
727
|
+
super(error);
|
|
728
|
+
this.name = error.name || 'WebrpcServerPanic';
|
|
729
|
+
this.code = typeof error.code === 'number' ? error.code : -6;
|
|
730
|
+
this.message = error.message || `server panic`;
|
|
731
|
+
this.status = typeof error.status === 'number' ? error.status : 500;
|
|
732
|
+
if (error.cause !== undefined)
|
|
733
|
+
this.cause = error.cause;
|
|
712
734
|
Object.setPrototypeOf(this, WebrpcServerPanicError.prototype);
|
|
713
735
|
}
|
|
714
736
|
}
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
737
|
+
export class WebrpcInternalErrorError extends WebrpcError {
|
|
738
|
+
constructor(error = {}) {
|
|
739
|
+
super(error);
|
|
740
|
+
this.name = error.name || 'WebrpcInternalError';
|
|
741
|
+
this.code = typeof error.code === 'number' ? error.code : -7;
|
|
742
|
+
this.message = error.message || `internal error`;
|
|
743
|
+
this.status = typeof error.status === 'number' ? error.status : 500;
|
|
744
|
+
if (error.cause !== undefined)
|
|
745
|
+
this.cause = error.cause;
|
|
719
746
|
Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype);
|
|
720
747
|
}
|
|
721
748
|
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
749
|
+
export class WebrpcClientAbortedError extends WebrpcError {
|
|
750
|
+
constructor(error = {}) {
|
|
751
|
+
super(error);
|
|
752
|
+
this.name = error.name || 'WebrpcClientAborted';
|
|
753
|
+
this.code = typeof error.code === 'number' ? error.code : -8;
|
|
754
|
+
this.message = error.message || `request aborted by client`;
|
|
755
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
756
|
+
if (error.cause !== undefined)
|
|
757
|
+
this.cause = error.cause;
|
|
758
|
+
Object.setPrototypeOf(this, WebrpcClientAbortedError.prototype);
|
|
727
759
|
}
|
|
728
760
|
}
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
761
|
+
export class WebrpcStreamLostError extends WebrpcError {
|
|
762
|
+
constructor(error = {}) {
|
|
763
|
+
super(error);
|
|
764
|
+
this.name = error.name || 'WebrpcStreamLost';
|
|
765
|
+
this.code = typeof error.code === 'number' ? error.code : -9;
|
|
766
|
+
this.message = error.message || `stream lost`;
|
|
767
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
768
|
+
if (error.cause !== undefined)
|
|
769
|
+
this.cause = error.cause;
|
|
733
770
|
Object.setPrototypeOf(this, WebrpcStreamLostError.prototype);
|
|
734
771
|
}
|
|
735
772
|
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
773
|
+
export class WebrpcStreamFinishedError extends WebrpcError {
|
|
774
|
+
constructor(error = {}) {
|
|
775
|
+
super(error);
|
|
776
|
+
this.name = error.name || 'WebrpcStreamFinished';
|
|
777
|
+
this.code = typeof error.code === 'number' ? error.code : -10;
|
|
778
|
+
this.message = error.message || `stream finished`;
|
|
779
|
+
this.status = typeof error.status === 'number' ? error.status : 200;
|
|
780
|
+
if (error.cause !== undefined)
|
|
781
|
+
this.cause = error.cause;
|
|
740
782
|
Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype);
|
|
741
783
|
}
|
|
742
784
|
}
|
|
743
|
-
|
|
785
|
+
//
|
|
744
786
|
// Schema errors
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
787
|
+
//
|
|
788
|
+
export class AbortedError extends WebrpcError {
|
|
789
|
+
constructor(error = {}) {
|
|
790
|
+
super(error);
|
|
791
|
+
this.name = error.name || 'Aborted';
|
|
792
|
+
this.code = typeof error.code === 'number' ? error.code : 1005;
|
|
793
|
+
this.message = error.message || `Request aborted`;
|
|
794
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
795
|
+
if (error.cause !== undefined)
|
|
796
|
+
this.cause = error.cause;
|
|
797
|
+
Object.setPrototypeOf(this, AbortedError.prototype);
|
|
749
798
|
}
|
|
750
799
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
800
|
+
export class AccessKeyMismatchError extends WebrpcError {
|
|
801
|
+
constructor(error = {}) {
|
|
802
|
+
super(error);
|
|
803
|
+
this.name = error.name || 'AccessKeyMismatch';
|
|
804
|
+
this.code = typeof error.code === 'number' ? error.code : 1102;
|
|
805
|
+
this.message = error.message || `Access key mismatch`;
|
|
806
|
+
this.status = typeof error.status === 'number' ? error.status : 409;
|
|
807
|
+
if (error.cause !== undefined)
|
|
808
|
+
this.cause = error.cause;
|
|
809
|
+
Object.setPrototypeOf(this, AccessKeyMismatchError.prototype);
|
|
756
810
|
}
|
|
757
811
|
}
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
812
|
+
export class AccessKeyNotFoundError extends WebrpcError {
|
|
813
|
+
constructor(error = {}) {
|
|
814
|
+
super(error);
|
|
815
|
+
this.name = error.name || 'AccessKeyNotFound';
|
|
816
|
+
this.code = typeof error.code === 'number' ? error.code : 1101;
|
|
817
|
+
this.message = error.message || `Access key not found`;
|
|
818
|
+
this.status = typeof error.status === 'number' ? error.status : 401;
|
|
819
|
+
if (error.cause !== undefined)
|
|
820
|
+
this.cause = error.cause;
|
|
821
|
+
Object.setPrototypeOf(this, AccessKeyNotFoundError.prototype);
|
|
763
822
|
}
|
|
764
823
|
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
824
|
+
export class AtLeastOneKeyError extends WebrpcError {
|
|
825
|
+
constructor(error = {}) {
|
|
826
|
+
super(error);
|
|
827
|
+
this.name = error.name || 'AtLeastOneKey';
|
|
828
|
+
this.code = typeof error.code === 'number' ? error.code : 1302;
|
|
829
|
+
this.message = error.message || `You need at least one Access Key`;
|
|
830
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
831
|
+
if (error.cause !== undefined)
|
|
832
|
+
this.cause = error.cause;
|
|
833
|
+
Object.setPrototypeOf(this, AtLeastOneKeyError.prototype);
|
|
770
834
|
}
|
|
771
835
|
}
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
836
|
+
export class GeoblockedError extends WebrpcError {
|
|
837
|
+
constructor(error = {}) {
|
|
838
|
+
super(error);
|
|
839
|
+
this.name = error.name || 'Geoblocked';
|
|
840
|
+
this.code = typeof error.code === 'number' ? error.code : 1006;
|
|
841
|
+
this.message = error.message || `Geoblocked region`;
|
|
842
|
+
this.status = typeof error.status === 'number' ? error.status : 451;
|
|
843
|
+
if (error.cause !== undefined)
|
|
844
|
+
this.cause = error.cause;
|
|
845
|
+
Object.setPrototypeOf(this, GeoblockedError.prototype);
|
|
777
846
|
}
|
|
778
847
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
848
|
+
export class InvalidArgumentError extends WebrpcError {
|
|
849
|
+
constructor(error = {}) {
|
|
850
|
+
super(error);
|
|
851
|
+
this.name = error.name || 'InvalidArgument';
|
|
852
|
+
this.code = typeof error.code === 'number' ? error.code : 2001;
|
|
853
|
+
this.message = error.message || `Invalid argument`;
|
|
854
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
855
|
+
if (error.cause !== undefined)
|
|
856
|
+
this.cause = error.cause;
|
|
857
|
+
Object.setPrototypeOf(this, InvalidArgumentError.prototype);
|
|
784
858
|
}
|
|
785
859
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
860
|
+
export class InvalidOriginError extends WebrpcError {
|
|
861
|
+
constructor(error = {}) {
|
|
862
|
+
super(error);
|
|
863
|
+
this.name = error.name || 'InvalidOrigin';
|
|
864
|
+
this.code = typeof error.code === 'number' ? error.code : 1103;
|
|
865
|
+
this.message = error.message || `Invalid origin for Access Key`;
|
|
866
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
867
|
+
if (error.cause !== undefined)
|
|
868
|
+
this.cause = error.cause;
|
|
869
|
+
Object.setPrototypeOf(this, InvalidOriginError.prototype);
|
|
791
870
|
}
|
|
792
871
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
872
|
+
export class InvalidServiceError extends WebrpcError {
|
|
873
|
+
constructor(error = {}) {
|
|
874
|
+
super(error);
|
|
875
|
+
this.name = error.name || 'InvalidService';
|
|
876
|
+
this.code = typeof error.code === 'number' ? error.code : 1104;
|
|
877
|
+
this.message = error.message || `Service not enabled for Access key`;
|
|
878
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
879
|
+
if (error.cause !== undefined)
|
|
880
|
+
this.cause = error.cause;
|
|
881
|
+
Object.setPrototypeOf(this, InvalidServiceError.prototype);
|
|
798
882
|
}
|
|
799
883
|
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
884
|
+
export class MaxAccessKeysError extends WebrpcError {
|
|
885
|
+
constructor(error = {}) {
|
|
886
|
+
super(error);
|
|
887
|
+
this.name = error.name || 'MaxAccessKeys';
|
|
888
|
+
this.code = typeof error.code === 'number' ? error.code : 1301;
|
|
889
|
+
this.message = error.message || `Access keys limit reached`;
|
|
890
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
891
|
+
if (error.cause !== undefined)
|
|
892
|
+
this.cause = error.cause;
|
|
893
|
+
Object.setPrototypeOf(this, MaxAccessKeysError.prototype);
|
|
805
894
|
}
|
|
806
895
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
896
|
+
export class MetadataCallFailedError extends WebrpcError {
|
|
897
|
+
constructor(error = {}) {
|
|
898
|
+
super(error);
|
|
899
|
+
this.name = error.name || 'MetadataCallFailed';
|
|
900
|
+
this.code = typeof error.code === 'number' ? error.code : 3003;
|
|
901
|
+
this.message = error.message || `Metadata service call failed`;
|
|
902
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
903
|
+
if (error.cause !== undefined)
|
|
904
|
+
this.cause = error.cause;
|
|
905
|
+
Object.setPrototypeOf(this, MetadataCallFailedError.prototype);
|
|
812
906
|
}
|
|
813
907
|
}
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
908
|
+
export class MethodNotFoundError extends WebrpcError {
|
|
909
|
+
constructor(error = {}) {
|
|
910
|
+
super(error);
|
|
911
|
+
this.name = error.name || 'MethodNotFound';
|
|
912
|
+
this.code = typeof error.code === 'number' ? error.code : 1003;
|
|
913
|
+
this.message = error.message || `Method not found`;
|
|
914
|
+
this.status = typeof error.status === 'number' ? error.status : 404;
|
|
915
|
+
if (error.cause !== undefined)
|
|
916
|
+
this.cause = error.cause;
|
|
917
|
+
Object.setPrototypeOf(this, MethodNotFoundError.prototype);
|
|
819
918
|
}
|
|
820
919
|
}
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
920
|
+
export class NoDefaultKeyError extends WebrpcError {
|
|
921
|
+
constructor(error = {}) {
|
|
922
|
+
super(error);
|
|
923
|
+
this.name = error.name || 'NoDefaultKey';
|
|
924
|
+
this.code = typeof error.code === 'number' ? error.code : 1300;
|
|
925
|
+
this.message = error.message || `No default access key found`;
|
|
926
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
927
|
+
if (error.cause !== undefined)
|
|
928
|
+
this.cause = error.cause;
|
|
929
|
+
Object.setPrototypeOf(this, NoDefaultKeyError.prototype);
|
|
826
930
|
}
|
|
827
931
|
}
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
932
|
+
export class NotFoundError extends WebrpcError {
|
|
933
|
+
constructor(error = {}) {
|
|
934
|
+
super(error);
|
|
935
|
+
this.name = error.name || 'NotFound';
|
|
936
|
+
this.code = typeof error.code === 'number' ? error.code : 3000;
|
|
937
|
+
this.message = error.message || `Resource not found`;
|
|
938
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
939
|
+
if (error.cause !== undefined)
|
|
940
|
+
this.cause = error.cause;
|
|
941
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
833
942
|
}
|
|
834
943
|
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
944
|
+
export class PermissionDeniedError extends WebrpcError {
|
|
945
|
+
constructor(error = {}) {
|
|
946
|
+
super(error);
|
|
947
|
+
this.name = error.name || 'PermissionDenied';
|
|
948
|
+
this.code = typeof error.code === 'number' ? error.code : 1001;
|
|
949
|
+
this.message = error.message || `Permission denied`;
|
|
950
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
951
|
+
if (error.cause !== undefined)
|
|
952
|
+
this.cause = error.cause;
|
|
953
|
+
Object.setPrototypeOf(this, PermissionDeniedError.prototype);
|
|
840
954
|
}
|
|
841
955
|
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
956
|
+
export class ProjectNotFoundError extends WebrpcError {
|
|
957
|
+
constructor(error = {}) {
|
|
958
|
+
super(error);
|
|
959
|
+
this.name = error.name || 'ProjectNotFound';
|
|
960
|
+
this.code = typeof error.code === 'number' ? error.code : 1100;
|
|
961
|
+
this.message = error.message || `Project not found`;
|
|
962
|
+
this.status = typeof error.status === 'number' ? error.status : 401;
|
|
963
|
+
if (error.cause !== undefined)
|
|
964
|
+
this.cause = error.cause;
|
|
965
|
+
Object.setPrototypeOf(this, ProjectNotFoundError.prototype);
|
|
847
966
|
}
|
|
848
967
|
}
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
968
|
+
export class QueryFailedError extends WebrpcError {
|
|
969
|
+
constructor(error = {}) {
|
|
970
|
+
super(error);
|
|
971
|
+
this.name = error.name || 'QueryFailed';
|
|
972
|
+
this.code = typeof error.code === 'number' ? error.code : 2003;
|
|
973
|
+
this.message = error.message || `Query failed`;
|
|
974
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
975
|
+
if (error.cause !== undefined)
|
|
976
|
+
this.cause = error.cause;
|
|
977
|
+
Object.setPrototypeOf(this, QueryFailedError.prototype);
|
|
854
978
|
}
|
|
855
979
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
980
|
+
export class QuotaExceededError extends WebrpcError {
|
|
981
|
+
constructor(error = {}) {
|
|
982
|
+
super(error);
|
|
983
|
+
this.name = error.name || 'QuotaExceeded';
|
|
984
|
+
this.code = typeof error.code === 'number' ? error.code : 1200;
|
|
985
|
+
this.message = error.message || `Quota exceeded`;
|
|
986
|
+
this.status = typeof error.status === 'number' ? error.status : 429;
|
|
987
|
+
if (error.cause !== undefined)
|
|
988
|
+
this.cause = error.cause;
|
|
989
|
+
Object.setPrototypeOf(this, QuotaExceededError.prototype);
|
|
861
990
|
}
|
|
862
991
|
}
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
992
|
+
export class RateLimitError extends WebrpcError {
|
|
993
|
+
constructor(error = {}) {
|
|
994
|
+
super(error);
|
|
995
|
+
this.name = error.name || 'RateLimit';
|
|
996
|
+
this.code = typeof error.code === 'number' ? error.code : 1201;
|
|
997
|
+
this.message = error.message || `Rate limit exceeded`;
|
|
998
|
+
this.status = typeof error.status === 'number' ? error.status : 429;
|
|
999
|
+
if (error.cause !== undefined)
|
|
1000
|
+
this.cause = error.cause;
|
|
1001
|
+
Object.setPrototypeOf(this, RateLimitError.prototype);
|
|
868
1002
|
}
|
|
869
1003
|
}
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
1004
|
+
export class RateLimitedError extends WebrpcError {
|
|
1005
|
+
constructor(error = {}) {
|
|
1006
|
+
super(error);
|
|
1007
|
+
this.name = error.name || 'RateLimited';
|
|
1008
|
+
this.code = typeof error.code === 'number' ? error.code : 1007;
|
|
1009
|
+
this.message = error.message || `Rate-limited. Please slow down.`;
|
|
1010
|
+
this.status = typeof error.status === 'number' ? error.status : 429;
|
|
1011
|
+
if (error.cause !== undefined)
|
|
1012
|
+
this.cause = error.cause;
|
|
1013
|
+
Object.setPrototypeOf(this, RateLimitedError.prototype);
|
|
875
1014
|
}
|
|
876
1015
|
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
1016
|
+
export class RequestConflictError extends WebrpcError {
|
|
1017
|
+
constructor(error = {}) {
|
|
1018
|
+
super(error);
|
|
1019
|
+
this.name = error.name || 'RequestConflict';
|
|
1020
|
+
this.code = typeof error.code === 'number' ? error.code : 1004;
|
|
1021
|
+
this.message = error.message || `Conflict with target resource`;
|
|
1022
|
+
this.status = typeof error.status === 'number' ? error.status : 409;
|
|
1023
|
+
if (error.cause !== undefined)
|
|
1024
|
+
this.cause = error.cause;
|
|
1025
|
+
Object.setPrototypeOf(this, RequestConflictError.prototype);
|
|
882
1026
|
}
|
|
883
1027
|
}
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
1028
|
+
export class ResourceExhaustedError extends WebrpcError {
|
|
1029
|
+
constructor(error = {}) {
|
|
1030
|
+
super(error);
|
|
1031
|
+
this.name = error.name || 'ResourceExhausted';
|
|
1032
|
+
this.code = typeof error.code === 'number' ? error.code : 2004;
|
|
1033
|
+
this.message = error.message || `Resource exhausted`;
|
|
1034
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1035
|
+
if (error.cause !== undefined)
|
|
1036
|
+
this.cause = error.cause;
|
|
1037
|
+
Object.setPrototypeOf(this, ResourceExhaustedError.prototype);
|
|
889
1038
|
}
|
|
890
1039
|
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
1040
|
+
export class SessionExpiredError extends WebrpcError {
|
|
1041
|
+
constructor(error = {}) {
|
|
1042
|
+
super(error);
|
|
1043
|
+
this.name = error.name || 'SessionExpired';
|
|
1044
|
+
this.code = typeof error.code === 'number' ? error.code : 1002;
|
|
1045
|
+
this.message = error.message || `Session expired`;
|
|
1046
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1047
|
+
if (error.cause !== undefined)
|
|
1048
|
+
this.cause = error.cause;
|
|
1049
|
+
Object.setPrototypeOf(this, SessionExpiredError.prototype);
|
|
896
1050
|
}
|
|
897
1051
|
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
1052
|
+
export class TimeoutError extends WebrpcError {
|
|
1053
|
+
constructor(error = {}) {
|
|
1054
|
+
super(error);
|
|
1055
|
+
this.name = error.name || 'Timeout';
|
|
1056
|
+
this.code = typeof error.code === 'number' ? error.code : 1900;
|
|
1057
|
+
this.message = error.message || `Request timed out`;
|
|
1058
|
+
this.status = typeof error.status === 'number' ? error.status : 408;
|
|
1059
|
+
if (error.cause !== undefined)
|
|
1060
|
+
this.cause = error.cause;
|
|
1061
|
+
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
903
1062
|
}
|
|
904
1063
|
}
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
1064
|
+
export class UnauthorizedError extends WebrpcError {
|
|
1065
|
+
constructor(error = {}) {
|
|
1066
|
+
super(error);
|
|
1067
|
+
this.name = error.name || 'Unauthorized';
|
|
1068
|
+
this.code = typeof error.code === 'number' ? error.code : 1000;
|
|
1069
|
+
this.message = error.message || `Unauthorized access`;
|
|
1070
|
+
this.status = typeof error.status === 'number' ? error.status : 401;
|
|
1071
|
+
if (error.cause !== undefined)
|
|
1072
|
+
this.cause = error.cause;
|
|
1073
|
+
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
910
1074
|
}
|
|
911
1075
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1076
|
+
export class UnauthorizedUserError extends WebrpcError {
|
|
1077
|
+
constructor(error = {}) {
|
|
1078
|
+
super(error);
|
|
1079
|
+
this.name = error.name || 'UnauthorizedUser';
|
|
1080
|
+
this.code = typeof error.code === 'number' ? error.code : 1105;
|
|
1081
|
+
this.message = error.message || `Unauthorized user`;
|
|
1082
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
1083
|
+
if (error.cause !== undefined)
|
|
1084
|
+
this.cause = error.cause;
|
|
1085
|
+
Object.setPrototypeOf(this, UnauthorizedUserError.prototype);
|
|
917
1086
|
}
|
|
918
1087
|
}
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
1088
|
+
export class UnavailableError extends WebrpcError {
|
|
1089
|
+
constructor(error = {}) {
|
|
1090
|
+
super(error);
|
|
1091
|
+
this.name = error.name || 'Unavailable';
|
|
1092
|
+
this.code = typeof error.code === 'number' ? error.code : 2002;
|
|
1093
|
+
this.message = error.message || `Unavailable resource`;
|
|
1094
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1095
|
+
if (error.cause !== undefined)
|
|
1096
|
+
this.cause = error.cause;
|
|
1097
|
+
Object.setPrototypeOf(this, UnavailableError.prototype);
|
|
924
1098
|
}
|
|
925
1099
|
}
|
|
926
|
-
|
|
927
|
-
var errors;
|
|
1100
|
+
export var errors;
|
|
928
1101
|
(function (errors) {
|
|
929
1102
|
errors["WebrpcEndpoint"] = "WebrpcEndpoint";
|
|
930
1103
|
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed";
|
|
@@ -934,37 +1107,77 @@ var errors;
|
|
|
934
1107
|
errors["WebrpcBadResponse"] = "WebrpcBadResponse";
|
|
935
1108
|
errors["WebrpcServerPanic"] = "WebrpcServerPanic";
|
|
936
1109
|
errors["WebrpcInternalError"] = "WebrpcInternalError";
|
|
937
|
-
errors["
|
|
1110
|
+
errors["WebrpcClientAborted"] = "WebrpcClientAborted";
|
|
938
1111
|
errors["WebrpcStreamLost"] = "WebrpcStreamLost";
|
|
939
1112
|
errors["WebrpcStreamFinished"] = "WebrpcStreamFinished";
|
|
940
|
-
errors["Unauthorized"] = "Unauthorized";
|
|
941
|
-
errors["PermissionDenied"] = "PermissionDenied";
|
|
942
|
-
errors["SessionExpired"] = "SessionExpired";
|
|
943
|
-
errors["MethodNotFound"] = "MethodNotFound";
|
|
944
|
-
errors["RequestConflict"] = "RequestConflict";
|
|
945
1113
|
errors["Aborted"] = "Aborted";
|
|
946
|
-
errors["Geoblocked"] = "Geoblocked";
|
|
947
|
-
errors["RateLimited"] = "RateLimited";
|
|
948
|
-
errors["ProjectNotFound"] = "ProjectNotFound";
|
|
949
|
-
errors["AccessKeyNotFound"] = "AccessKeyNotFound";
|
|
950
1114
|
errors["AccessKeyMismatch"] = "AccessKeyMismatch";
|
|
1115
|
+
errors["AccessKeyNotFound"] = "AccessKeyNotFound";
|
|
1116
|
+
errors["AtLeastOneKey"] = "AtLeastOneKey";
|
|
1117
|
+
errors["Geoblocked"] = "Geoblocked";
|
|
1118
|
+
errors["InvalidArgument"] = "InvalidArgument";
|
|
951
1119
|
errors["InvalidOrigin"] = "InvalidOrigin";
|
|
952
1120
|
errors["InvalidService"] = "InvalidService";
|
|
953
|
-
errors["
|
|
1121
|
+
errors["MaxAccessKeys"] = "MaxAccessKeys";
|
|
1122
|
+
errors["MetadataCallFailed"] = "MetadataCallFailed";
|
|
1123
|
+
errors["MethodNotFound"] = "MethodNotFound";
|
|
1124
|
+
errors["NoDefaultKey"] = "NoDefaultKey";
|
|
1125
|
+
errors["NotFound"] = "NotFound";
|
|
1126
|
+
errors["PermissionDenied"] = "PermissionDenied";
|
|
1127
|
+
errors["ProjectNotFound"] = "ProjectNotFound";
|
|
1128
|
+
errors["QueryFailed"] = "QueryFailed";
|
|
954
1129
|
errors["QuotaExceeded"] = "QuotaExceeded";
|
|
955
1130
|
errors["RateLimit"] = "RateLimit";
|
|
956
|
-
errors["
|
|
957
|
-
errors["
|
|
958
|
-
errors["
|
|
1131
|
+
errors["RateLimited"] = "RateLimited";
|
|
1132
|
+
errors["RequestConflict"] = "RequestConflict";
|
|
1133
|
+
errors["ResourceExhausted"] = "ResourceExhausted";
|
|
1134
|
+
errors["SessionExpired"] = "SessionExpired";
|
|
959
1135
|
errors["Timeout"] = "Timeout";
|
|
960
|
-
errors["
|
|
1136
|
+
errors["Unauthorized"] = "Unauthorized";
|
|
1137
|
+
errors["UnauthorizedUser"] = "UnauthorizedUser";
|
|
961
1138
|
errors["Unavailable"] = "Unavailable";
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
1139
|
+
})(errors || (errors = {}));
|
|
1140
|
+
export var WebrpcErrorCodes;
|
|
1141
|
+
(function (WebrpcErrorCodes) {
|
|
1142
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcEndpoint"] = 0] = "WebrpcEndpoint";
|
|
1143
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcRequestFailed"] = -1] = "WebrpcRequestFailed";
|
|
1144
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadRoute"] = -2] = "WebrpcBadRoute";
|
|
1145
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadMethod"] = -3] = "WebrpcBadMethod";
|
|
1146
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadRequest"] = -4] = "WebrpcBadRequest";
|
|
1147
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadResponse"] = -5] = "WebrpcBadResponse";
|
|
1148
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcServerPanic"] = -6] = "WebrpcServerPanic";
|
|
1149
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcInternalError"] = -7] = "WebrpcInternalError";
|
|
1150
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcClientAborted"] = -8] = "WebrpcClientAborted";
|
|
1151
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamLost"] = -9] = "WebrpcStreamLost";
|
|
1152
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamFinished"] = -10] = "WebrpcStreamFinished";
|
|
1153
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Aborted"] = 1005] = "Aborted";
|
|
1154
|
+
WebrpcErrorCodes[WebrpcErrorCodes["AccessKeyMismatch"] = 1102] = "AccessKeyMismatch";
|
|
1155
|
+
WebrpcErrorCodes[WebrpcErrorCodes["AccessKeyNotFound"] = 1101] = "AccessKeyNotFound";
|
|
1156
|
+
WebrpcErrorCodes[WebrpcErrorCodes["AtLeastOneKey"] = 1302] = "AtLeastOneKey";
|
|
1157
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Geoblocked"] = 1006] = "Geoblocked";
|
|
1158
|
+
WebrpcErrorCodes[WebrpcErrorCodes["InvalidArgument"] = 2001] = "InvalidArgument";
|
|
1159
|
+
WebrpcErrorCodes[WebrpcErrorCodes["InvalidOrigin"] = 1103] = "InvalidOrigin";
|
|
1160
|
+
WebrpcErrorCodes[WebrpcErrorCodes["InvalidService"] = 1104] = "InvalidService";
|
|
1161
|
+
WebrpcErrorCodes[WebrpcErrorCodes["MaxAccessKeys"] = 1301] = "MaxAccessKeys";
|
|
1162
|
+
WebrpcErrorCodes[WebrpcErrorCodes["MetadataCallFailed"] = 3003] = "MetadataCallFailed";
|
|
1163
|
+
WebrpcErrorCodes[WebrpcErrorCodes["MethodNotFound"] = 1003] = "MethodNotFound";
|
|
1164
|
+
WebrpcErrorCodes[WebrpcErrorCodes["NoDefaultKey"] = 1300] = "NoDefaultKey";
|
|
1165
|
+
WebrpcErrorCodes[WebrpcErrorCodes["NotFound"] = 3000] = "NotFound";
|
|
1166
|
+
WebrpcErrorCodes[WebrpcErrorCodes["PermissionDenied"] = 1001] = "PermissionDenied";
|
|
1167
|
+
WebrpcErrorCodes[WebrpcErrorCodes["ProjectNotFound"] = 1100] = "ProjectNotFound";
|
|
1168
|
+
WebrpcErrorCodes[WebrpcErrorCodes["QueryFailed"] = 2003] = "QueryFailed";
|
|
1169
|
+
WebrpcErrorCodes[WebrpcErrorCodes["QuotaExceeded"] = 1200] = "QuotaExceeded";
|
|
1170
|
+
WebrpcErrorCodes[WebrpcErrorCodes["RateLimit"] = 1201] = "RateLimit";
|
|
1171
|
+
WebrpcErrorCodes[WebrpcErrorCodes["RateLimited"] = 1007] = "RateLimited";
|
|
1172
|
+
WebrpcErrorCodes[WebrpcErrorCodes["RequestConflict"] = 1004] = "RequestConflict";
|
|
1173
|
+
WebrpcErrorCodes[WebrpcErrorCodes["ResourceExhausted"] = 2004] = "ResourceExhausted";
|
|
1174
|
+
WebrpcErrorCodes[WebrpcErrorCodes["SessionExpired"] = 1002] = "SessionExpired";
|
|
1175
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Timeout"] = 1900] = "Timeout";
|
|
1176
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Unauthorized"] = 1000] = "Unauthorized";
|
|
1177
|
+
WebrpcErrorCodes[WebrpcErrorCodes["UnauthorizedUser"] = 1105] = "UnauthorizedUser";
|
|
1178
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Unavailable"] = 2002] = "Unavailable";
|
|
1179
|
+
})(WebrpcErrorCodes || (WebrpcErrorCodes = {}));
|
|
1180
|
+
export const webrpcErrorByCode = {
|
|
968
1181
|
[0]: WebrpcEndpointError,
|
|
969
1182
|
[-1]: WebrpcRequestFailedError,
|
|
970
1183
|
[-2]: WebrpcBadRouteError,
|
|
@@ -973,33 +1186,73 @@ const webrpcErrorByCode = {
|
|
|
973
1186
|
[-5]: WebrpcBadResponseError,
|
|
974
1187
|
[-6]: WebrpcServerPanicError,
|
|
975
1188
|
[-7]: WebrpcInternalErrorError,
|
|
976
|
-
[-8]:
|
|
1189
|
+
[-8]: WebrpcClientAbortedError,
|
|
977
1190
|
[-9]: WebrpcStreamLostError,
|
|
978
1191
|
[-10]: WebrpcStreamFinishedError,
|
|
979
|
-
[1000]: UnauthorizedError,
|
|
980
|
-
[1001]: PermissionDeniedError,
|
|
981
|
-
[1002]: SessionExpiredError,
|
|
982
|
-
[1003]: MethodNotFoundError,
|
|
983
|
-
[1004]: RequestConflictError,
|
|
984
1192
|
[1005]: AbortedError,
|
|
985
|
-
[1006]: GeoblockedError,
|
|
986
|
-
[1007]: RateLimitedError,
|
|
987
|
-
[1100]: ProjectNotFoundError,
|
|
988
|
-
[1101]: AccessKeyNotFoundError,
|
|
989
1193
|
[1102]: AccessKeyMismatchError,
|
|
1194
|
+
[1101]: AccessKeyNotFoundError,
|
|
1195
|
+
[1302]: AtLeastOneKeyError,
|
|
1196
|
+
[1006]: GeoblockedError,
|
|
1197
|
+
[2001]: InvalidArgumentError,
|
|
990
1198
|
[1103]: InvalidOriginError,
|
|
991
1199
|
[1104]: InvalidServiceError,
|
|
992
|
-
[1105]: UnauthorizedUserError,
|
|
993
|
-
[1200]: QuotaExceededError,
|
|
994
|
-
[1201]: RateLimitError,
|
|
995
|
-
[1300]: NoDefaultKeyError,
|
|
996
1200
|
[1301]: MaxAccessKeysError,
|
|
997
|
-
[
|
|
998
|
-
[
|
|
999
|
-
[
|
|
1000
|
-
[
|
|
1201
|
+
[3003]: MetadataCallFailedError,
|
|
1202
|
+
[1003]: MethodNotFoundError,
|
|
1203
|
+
[1300]: NoDefaultKeyError,
|
|
1204
|
+
[3000]: NotFoundError,
|
|
1205
|
+
[1001]: PermissionDeniedError,
|
|
1206
|
+
[1100]: ProjectNotFoundError,
|
|
1001
1207
|
[2003]: QueryFailedError,
|
|
1208
|
+
[1200]: QuotaExceededError,
|
|
1209
|
+
[1201]: RateLimitError,
|
|
1210
|
+
[1007]: RateLimitedError,
|
|
1211
|
+
[1004]: RequestConflictError,
|
|
1002
1212
|
[2004]: ResourceExhaustedError,
|
|
1003
|
-
[
|
|
1004
|
-
[
|
|
1213
|
+
[1002]: SessionExpiredError,
|
|
1214
|
+
[1900]: TimeoutError,
|
|
1215
|
+
[1000]: UnauthorizedError,
|
|
1216
|
+
[1105]: UnauthorizedUserError,
|
|
1217
|
+
[2002]: UnavailableError
|
|
1005
1218
|
};
|
|
1219
|
+
//
|
|
1220
|
+
// Webrpc
|
|
1221
|
+
//
|
|
1222
|
+
export const WebrpcHeader = 'Webrpc';
|
|
1223
|
+
export const WebrpcHeaderValue = 'webrpc@v0.31.2;gen-typescript@v0.23.1;sequence-indexer@v0.4.0';
|
|
1224
|
+
export function VersionFromHeader(headers) {
|
|
1225
|
+
const headerValue = headers.get(WebrpcHeader);
|
|
1226
|
+
if (!headerValue) {
|
|
1227
|
+
return {
|
|
1228
|
+
WebrpcGenVersion: '',
|
|
1229
|
+
codeGenName: '',
|
|
1230
|
+
codeGenVersion: '',
|
|
1231
|
+
schemaName: '',
|
|
1232
|
+
schemaVersion: ''
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
return parseWebrpcGenVersions(headerValue);
|
|
1236
|
+
}
|
|
1237
|
+
function parseWebrpcGenVersions(header) {
|
|
1238
|
+
const versions = header.split(';');
|
|
1239
|
+
if (versions.length < 3) {
|
|
1240
|
+
return {
|
|
1241
|
+
WebrpcGenVersion: '',
|
|
1242
|
+
codeGenName: '',
|
|
1243
|
+
codeGenVersion: '',
|
|
1244
|
+
schemaName: '',
|
|
1245
|
+
schemaVersion: ''
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
const [_, WebrpcGenVersion] = versions[0].split('@');
|
|
1249
|
+
const [codeGenName, codeGenVersion] = versions[1].split('@');
|
|
1250
|
+
const [schemaName, schemaVersion] = versions[2].split('@');
|
|
1251
|
+
return {
|
|
1252
|
+
WebrpcGenVersion: WebrpcGenVersion ?? '',
|
|
1253
|
+
codeGenName: codeGenName ?? '',
|
|
1254
|
+
codeGenVersion: codeGenVersion ?? '',
|
|
1255
|
+
schemaName: schemaName ?? '',
|
|
1256
|
+
schemaVersion: schemaVersion ?? ''
|
|
1257
|
+
};
|
|
1258
|
+
}
|