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