@0xsequence/indexer 0.0.0-2021823181734
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/CHANGELOG.md +6 -0
- package/README.md +4 -0
- package/dist/0xsequence-indexer.cjs.d.ts +1 -0
- package/dist/0xsequence-indexer.cjs.dev.js +256 -0
- package/dist/0xsequence-indexer.cjs.js +7 -0
- package/dist/0xsequence-indexer.cjs.prod.js +256 -0
- package/dist/0xsequence-indexer.esm.js +244 -0
- package/dist/declarations/src/index.d.ts +8 -0
- package/dist/declarations/src/indexer.gen.d.ts +229 -0
- package/package.json +24 -0
- package/src/index.ts +26 -0
- package/src/indexer.gen.ts +415 -0
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./declarations/src/index";
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var fetch = require('cross-fetch');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var fetch__default = /*#__PURE__*/_interopDefault(fetch);
|
|
10
|
+
|
|
11
|
+
function _extends() {
|
|
12
|
+
_extends = Object.assign || function (target) {
|
|
13
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
14
|
+
var source = arguments[i];
|
|
15
|
+
|
|
16
|
+
for (var key in source) {
|
|
17
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
18
|
+
target[key] = source[key];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return target;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return _extends.apply(this, arguments);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* eslint-disable */
|
|
30
|
+
// sequence-indexer v0.4.0 af55f42a2e22fda0417a49eaefd8db7c5ad28a6a
|
|
31
|
+
// --
|
|
32
|
+
// This file has been generated by https://github.com/webrpc/webrpc using gen/typescript
|
|
33
|
+
// Do not edit by hand. Update your webrpc schema and re-generate.
|
|
34
|
+
// WebRPC description and code-gen version
|
|
35
|
+
const WebRPCVersion = "v1"; // Schema version of your RIDL schema
|
|
36
|
+
|
|
37
|
+
const WebRPCSchemaVersion = "v0.4.0"; // Schema hash generated from your RIDL schema
|
|
38
|
+
|
|
39
|
+
const WebRPCSchemaHash = "af55f42a2e22fda0417a49eaefd8db7c5ad28a6a"; //
|
|
40
|
+
// Types
|
|
41
|
+
//
|
|
42
|
+
|
|
43
|
+
exports.ContractType = void 0;
|
|
44
|
+
|
|
45
|
+
(function (ContractType) {
|
|
46
|
+
ContractType["UNKNOWN"] = "UNKNOWN";
|
|
47
|
+
ContractType["ERC20"] = "ERC20";
|
|
48
|
+
ContractType["ERC721"] = "ERC721";
|
|
49
|
+
ContractType["ERC1155"] = "ERC1155";
|
|
50
|
+
ContractType["SEQUENCE_WALLET"] = "SEQUENCE_WALLET";
|
|
51
|
+
})(exports.ContractType || (exports.ContractType = {}));
|
|
52
|
+
|
|
53
|
+
exports.EventLogType = void 0;
|
|
54
|
+
|
|
55
|
+
(function (EventLogType) {
|
|
56
|
+
EventLogType["UNKNOWN"] = "UNKNOWN";
|
|
57
|
+
EventLogType["BLOCK_ADDED"] = "BLOCK_ADDED";
|
|
58
|
+
EventLogType["BLOCK_REMOVED"] = "BLOCK_REMOVED";
|
|
59
|
+
})(exports.EventLogType || (exports.EventLogType = {}));
|
|
60
|
+
|
|
61
|
+
exports.EventLogDataType = void 0;
|
|
62
|
+
|
|
63
|
+
(function (EventLogDataType) {
|
|
64
|
+
EventLogDataType["UNKNOWN"] = "UNKNOWN";
|
|
65
|
+
EventLogDataType["TOKEN_TRANSFER"] = "TOKEN_TRANSFER";
|
|
66
|
+
EventLogDataType["SEQUENCE_TXN"] = "SEQUENCE_TXN";
|
|
67
|
+
})(exports.EventLogDataType || (exports.EventLogDataType = {}));
|
|
68
|
+
|
|
69
|
+
exports.TxnTransferType = void 0;
|
|
70
|
+
|
|
71
|
+
(function (TxnTransferType) {
|
|
72
|
+
TxnTransferType["UNKNOWN"] = "UNKNOWN";
|
|
73
|
+
TxnTransferType["SEND"] = "SEND";
|
|
74
|
+
TxnTransferType["RECEIVE"] = "RECEIVE";
|
|
75
|
+
})(exports.TxnTransferType || (exports.TxnTransferType = {}));
|
|
76
|
+
|
|
77
|
+
exports.SortOrder = void 0;
|
|
78
|
+
|
|
79
|
+
(function (SortOrder) {
|
|
80
|
+
SortOrder["DESC"] = "DESC";
|
|
81
|
+
SortOrder["ASC"] = "ASC";
|
|
82
|
+
})(exports.SortOrder || (exports.SortOrder = {}));
|
|
83
|
+
|
|
84
|
+
//
|
|
85
|
+
// Client
|
|
86
|
+
//
|
|
87
|
+
class Indexer {
|
|
88
|
+
constructor(hostname, fetch) {
|
|
89
|
+
this.hostname = void 0;
|
|
90
|
+
this.fetch = void 0;
|
|
91
|
+
this.path = '/rpc/Indexer/';
|
|
92
|
+
|
|
93
|
+
this.ping = headers => {
|
|
94
|
+
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
|
|
95
|
+
return buildResponse(res).then(_data => {
|
|
96
|
+
return {
|
|
97
|
+
status: _data.status
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
this.version = headers => {
|
|
104
|
+
return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
|
|
105
|
+
return buildResponse(res).then(_data => {
|
|
106
|
+
return {
|
|
107
|
+
version: _data.version
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
this.runtimeStatus = headers => {
|
|
114
|
+
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
|
|
115
|
+
return buildResponse(res).then(_data => {
|
|
116
|
+
return {
|
|
117
|
+
status: _data.status
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
this.getChainID = headers => {
|
|
124
|
+
return this.fetch(this.url('GetChainID'), createHTTPRequest({}, headers)).then(res => {
|
|
125
|
+
return buildResponse(res).then(_data => {
|
|
126
|
+
return {
|
|
127
|
+
chainID: _data.chainID
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
this.getEtherBalance = (args, headers) => {
|
|
134
|
+
return this.fetch(this.url('GetEtherBalance'), createHTTPRequest(args, headers)).then(res => {
|
|
135
|
+
return buildResponse(res).then(_data => {
|
|
136
|
+
return {
|
|
137
|
+
balance: _data.balance
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
this.getTokenBalances = (args, headers) => {
|
|
144
|
+
return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers)).then(res => {
|
|
145
|
+
return buildResponse(res).then(_data => {
|
|
146
|
+
return {
|
|
147
|
+
balances: _data.balances
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
this.getTokenSupplies = (args, headers) => {
|
|
154
|
+
return this.fetch(this.url('GetTokenSupplies'), createHTTPRequest(args, headers)).then(res => {
|
|
155
|
+
return buildResponse(res).then(_data => {
|
|
156
|
+
return {
|
|
157
|
+
supplies: _data.supplies
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
this.getBalanceUpdates = (args, headers) => {
|
|
164
|
+
return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest(args, headers)).then(res => {
|
|
165
|
+
return buildResponse(res).then(_data => {
|
|
166
|
+
return {
|
|
167
|
+
page: _data.page,
|
|
168
|
+
balances: _data.balances
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
this.getTransactionHistory = (args, headers) => {
|
|
175
|
+
return this.fetch(this.url('GetTransactionHistory'), createHTTPRequest(args, headers)).then(res => {
|
|
176
|
+
return buildResponse(res).then(_data => {
|
|
177
|
+
return {
|
|
178
|
+
page: _data.page,
|
|
179
|
+
transactions: _data.transactions
|
|
180
|
+
};
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
this.hostname = hostname;
|
|
186
|
+
this.fetch = fetch;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
url(name) {
|
|
190
|
+
return this.hostname + this.path + name;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const createHTTPRequest = (body = {}, headers = {}) => {
|
|
196
|
+
return {
|
|
197
|
+
method: 'POST',
|
|
198
|
+
headers: _extends({}, headers, {
|
|
199
|
+
'Content-Type': 'application/json'
|
|
200
|
+
}),
|
|
201
|
+
body: JSON.stringify(body || {})
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const buildResponse = res => {
|
|
206
|
+
return res.text().then(text => {
|
|
207
|
+
let data;
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
data = JSON.parse(text);
|
|
211
|
+
} catch (err) {
|
|
212
|
+
throw {
|
|
213
|
+
code: 'unknown',
|
|
214
|
+
msg: `expecting JSON, got: ${text}`,
|
|
215
|
+
status: res.status
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (!res.ok) {
|
|
220
|
+
throw data; // webrpc error response
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return data;
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
class SequenceIndexerClient extends Indexer {
|
|
228
|
+
constructor(hostname, chainId, jwtAuth) {
|
|
229
|
+
super(hostname, fetch__default['default']);
|
|
230
|
+
this.chainId = chainId;
|
|
231
|
+
this.jwtAuth = jwtAuth;
|
|
232
|
+
|
|
233
|
+
this._fetch = (input, init) => {
|
|
234
|
+
// automatically include jwt auth header to requests
|
|
235
|
+
// if its been set on the api client
|
|
236
|
+
const headers = {};
|
|
237
|
+
|
|
238
|
+
if (this.jwtAuth && this.jwtAuth.length > 0) {
|
|
239
|
+
headers['Authorization'] = `BEARER ${this.jwtAuth}`;
|
|
240
|
+
} // before the request is made
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
init.headers = _extends({}, init.headers, headers);
|
|
244
|
+
return fetch__default['default'](input, init);
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
this.fetch = this._fetch;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
exports.Indexer = Indexer;
|
|
253
|
+
exports.SequenceIndexerClient = SequenceIndexerClient;
|
|
254
|
+
exports.WebRPCSchemaHash = WebRPCSchemaHash;
|
|
255
|
+
exports.WebRPCSchemaVersion = WebRPCSchemaVersion;
|
|
256
|
+
exports.WebRPCVersion = WebRPCVersion;
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var fetch = require('cross-fetch');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var fetch__default = /*#__PURE__*/_interopDefault(fetch);
|
|
10
|
+
|
|
11
|
+
function _extends() {
|
|
12
|
+
_extends = Object.assign || function (target) {
|
|
13
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
14
|
+
var source = arguments[i];
|
|
15
|
+
|
|
16
|
+
for (var key in source) {
|
|
17
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
18
|
+
target[key] = source[key];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return target;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return _extends.apply(this, arguments);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* eslint-disable */
|
|
30
|
+
// sequence-indexer v0.4.0 af55f42a2e22fda0417a49eaefd8db7c5ad28a6a
|
|
31
|
+
// --
|
|
32
|
+
// This file has been generated by https://github.com/webrpc/webrpc using gen/typescript
|
|
33
|
+
// Do not edit by hand. Update your webrpc schema and re-generate.
|
|
34
|
+
// WebRPC description and code-gen version
|
|
35
|
+
const WebRPCVersion = "v1"; // Schema version of your RIDL schema
|
|
36
|
+
|
|
37
|
+
const WebRPCSchemaVersion = "v0.4.0"; // Schema hash generated from your RIDL schema
|
|
38
|
+
|
|
39
|
+
const WebRPCSchemaHash = "af55f42a2e22fda0417a49eaefd8db7c5ad28a6a"; //
|
|
40
|
+
// Types
|
|
41
|
+
//
|
|
42
|
+
|
|
43
|
+
exports.ContractType = void 0;
|
|
44
|
+
|
|
45
|
+
(function (ContractType) {
|
|
46
|
+
ContractType["UNKNOWN"] = "UNKNOWN";
|
|
47
|
+
ContractType["ERC20"] = "ERC20";
|
|
48
|
+
ContractType["ERC721"] = "ERC721";
|
|
49
|
+
ContractType["ERC1155"] = "ERC1155";
|
|
50
|
+
ContractType["SEQUENCE_WALLET"] = "SEQUENCE_WALLET";
|
|
51
|
+
})(exports.ContractType || (exports.ContractType = {}));
|
|
52
|
+
|
|
53
|
+
exports.EventLogType = void 0;
|
|
54
|
+
|
|
55
|
+
(function (EventLogType) {
|
|
56
|
+
EventLogType["UNKNOWN"] = "UNKNOWN";
|
|
57
|
+
EventLogType["BLOCK_ADDED"] = "BLOCK_ADDED";
|
|
58
|
+
EventLogType["BLOCK_REMOVED"] = "BLOCK_REMOVED";
|
|
59
|
+
})(exports.EventLogType || (exports.EventLogType = {}));
|
|
60
|
+
|
|
61
|
+
exports.EventLogDataType = void 0;
|
|
62
|
+
|
|
63
|
+
(function (EventLogDataType) {
|
|
64
|
+
EventLogDataType["UNKNOWN"] = "UNKNOWN";
|
|
65
|
+
EventLogDataType["TOKEN_TRANSFER"] = "TOKEN_TRANSFER";
|
|
66
|
+
EventLogDataType["SEQUENCE_TXN"] = "SEQUENCE_TXN";
|
|
67
|
+
})(exports.EventLogDataType || (exports.EventLogDataType = {}));
|
|
68
|
+
|
|
69
|
+
exports.TxnTransferType = void 0;
|
|
70
|
+
|
|
71
|
+
(function (TxnTransferType) {
|
|
72
|
+
TxnTransferType["UNKNOWN"] = "UNKNOWN";
|
|
73
|
+
TxnTransferType["SEND"] = "SEND";
|
|
74
|
+
TxnTransferType["RECEIVE"] = "RECEIVE";
|
|
75
|
+
})(exports.TxnTransferType || (exports.TxnTransferType = {}));
|
|
76
|
+
|
|
77
|
+
exports.SortOrder = void 0;
|
|
78
|
+
|
|
79
|
+
(function (SortOrder) {
|
|
80
|
+
SortOrder["DESC"] = "DESC";
|
|
81
|
+
SortOrder["ASC"] = "ASC";
|
|
82
|
+
})(exports.SortOrder || (exports.SortOrder = {}));
|
|
83
|
+
|
|
84
|
+
//
|
|
85
|
+
// Client
|
|
86
|
+
//
|
|
87
|
+
class Indexer {
|
|
88
|
+
constructor(hostname, fetch) {
|
|
89
|
+
this.hostname = void 0;
|
|
90
|
+
this.fetch = void 0;
|
|
91
|
+
this.path = '/rpc/Indexer/';
|
|
92
|
+
|
|
93
|
+
this.ping = headers => {
|
|
94
|
+
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
|
|
95
|
+
return buildResponse(res).then(_data => {
|
|
96
|
+
return {
|
|
97
|
+
status: _data.status
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
this.version = headers => {
|
|
104
|
+
return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
|
|
105
|
+
return buildResponse(res).then(_data => {
|
|
106
|
+
return {
|
|
107
|
+
version: _data.version
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
this.runtimeStatus = headers => {
|
|
114
|
+
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
|
|
115
|
+
return buildResponse(res).then(_data => {
|
|
116
|
+
return {
|
|
117
|
+
status: _data.status
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
this.getChainID = headers => {
|
|
124
|
+
return this.fetch(this.url('GetChainID'), createHTTPRequest({}, headers)).then(res => {
|
|
125
|
+
return buildResponse(res).then(_data => {
|
|
126
|
+
return {
|
|
127
|
+
chainID: _data.chainID
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
this.getEtherBalance = (args, headers) => {
|
|
134
|
+
return this.fetch(this.url('GetEtherBalance'), createHTTPRequest(args, headers)).then(res => {
|
|
135
|
+
return buildResponse(res).then(_data => {
|
|
136
|
+
return {
|
|
137
|
+
balance: _data.balance
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
this.getTokenBalances = (args, headers) => {
|
|
144
|
+
return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers)).then(res => {
|
|
145
|
+
return buildResponse(res).then(_data => {
|
|
146
|
+
return {
|
|
147
|
+
balances: _data.balances
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
this.getTokenSupplies = (args, headers) => {
|
|
154
|
+
return this.fetch(this.url('GetTokenSupplies'), createHTTPRequest(args, headers)).then(res => {
|
|
155
|
+
return buildResponse(res).then(_data => {
|
|
156
|
+
return {
|
|
157
|
+
supplies: _data.supplies
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
this.getBalanceUpdates = (args, headers) => {
|
|
164
|
+
return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest(args, headers)).then(res => {
|
|
165
|
+
return buildResponse(res).then(_data => {
|
|
166
|
+
return {
|
|
167
|
+
page: _data.page,
|
|
168
|
+
balances: _data.balances
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
this.getTransactionHistory = (args, headers) => {
|
|
175
|
+
return this.fetch(this.url('GetTransactionHistory'), createHTTPRequest(args, headers)).then(res => {
|
|
176
|
+
return buildResponse(res).then(_data => {
|
|
177
|
+
return {
|
|
178
|
+
page: _data.page,
|
|
179
|
+
transactions: _data.transactions
|
|
180
|
+
};
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
this.hostname = hostname;
|
|
186
|
+
this.fetch = fetch;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
url(name) {
|
|
190
|
+
return this.hostname + this.path + name;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const createHTTPRequest = (body = {}, headers = {}) => {
|
|
196
|
+
return {
|
|
197
|
+
method: 'POST',
|
|
198
|
+
headers: _extends({}, headers, {
|
|
199
|
+
'Content-Type': 'application/json'
|
|
200
|
+
}),
|
|
201
|
+
body: JSON.stringify(body || {})
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const buildResponse = res => {
|
|
206
|
+
return res.text().then(text => {
|
|
207
|
+
let data;
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
data = JSON.parse(text);
|
|
211
|
+
} catch (err) {
|
|
212
|
+
throw {
|
|
213
|
+
code: 'unknown',
|
|
214
|
+
msg: `expecting JSON, got: ${text}`,
|
|
215
|
+
status: res.status
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (!res.ok) {
|
|
220
|
+
throw data; // webrpc error response
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return data;
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
class SequenceIndexerClient extends Indexer {
|
|
228
|
+
constructor(hostname, chainId, jwtAuth) {
|
|
229
|
+
super(hostname, fetch__default['default']);
|
|
230
|
+
this.chainId = chainId;
|
|
231
|
+
this.jwtAuth = jwtAuth;
|
|
232
|
+
|
|
233
|
+
this._fetch = (input, init) => {
|
|
234
|
+
// automatically include jwt auth header to requests
|
|
235
|
+
// if its been set on the api client
|
|
236
|
+
const headers = {};
|
|
237
|
+
|
|
238
|
+
if (this.jwtAuth && this.jwtAuth.length > 0) {
|
|
239
|
+
headers['Authorization'] = `BEARER ${this.jwtAuth}`;
|
|
240
|
+
} // before the request is made
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
init.headers = _extends({}, init.headers, headers);
|
|
244
|
+
return fetch__default['default'](input, init);
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
this.fetch = this._fetch;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
exports.Indexer = Indexer;
|
|
253
|
+
exports.SequenceIndexerClient = SequenceIndexerClient;
|
|
254
|
+
exports.WebRPCSchemaHash = WebRPCSchemaHash;
|
|
255
|
+
exports.WebRPCSchemaVersion = WebRPCSchemaVersion;
|
|
256
|
+
exports.WebRPCVersion = WebRPCVersion;
|