@0xsequence/indexer 0.42.10 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,46 +2,42 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
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
5
  function _extends() {
12
- _extends = Object.assign || function (target) {
6
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
13
7
  for (var i = 1; i < arguments.length; i++) {
14
8
  var source = arguments[i];
15
-
16
9
  for (var key in source) {
17
10
  if (Object.prototype.hasOwnProperty.call(source, key)) {
18
11
  target[key] = source[key];
19
12
  }
20
13
  }
21
14
  }
22
-
23
15
  return target;
24
16
  };
25
-
26
17
  return _extends.apply(this, arguments);
27
18
  }
28
19
 
29
20
  /* eslint-disable */
30
- // sequence-indexer v0.4.0 6071879702f8258e8912ca95cf2d9c1459ca991d
21
+ // sequence-indexer v0.4.0 7cdd11a44d6d1c5371dca8be8a603b1c67d53e22
31
22
  // --
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.
23
+ // Code generated by webrpc-gen@v0.7.0 with typescript generator. DO NOT EDIT.
24
+ //
25
+ // webrpc-gen -schema=indexer.ridl -target=typescript -client -out=./clients/indexer.gen.ts
26
+
34
27
  // WebRPC description and code-gen version
35
- const WebRPCVersion = "v1"; // Schema version of your RIDL schema
28
+ const WebRPCVersion = "v1";
29
+
30
+ // Schema version of your RIDL schema
31
+ const WebRPCSchemaVersion = "v0.4.0";
36
32
 
37
- const WebRPCSchemaVersion = "v0.4.0"; // Schema hash generated from your RIDL schema
33
+ // Schema hash generated from your RIDL schema
34
+ const WebRPCSchemaHash = "7cdd11a44d6d1c5371dca8be8a603b1c67d53e22";
38
35
 
39
- const WebRPCSchemaHash = "6071879702f8258e8912ca95cf2d9c1459ca991d"; //
36
+ //
40
37
  // Types
41
38
  //
42
39
 
43
40
  exports.ContractType = void 0;
44
-
45
41
  (function (ContractType) {
46
42
  ContractType["UNKNOWN"] = "UNKNOWN";
47
43
  ContractType["ERC20"] = "ERC20";
@@ -52,38 +48,29 @@ exports.ContractType = void 0;
52
48
  ContractType["ERC721_BRIDGE"] = "ERC721_BRIDGE";
53
49
  ContractType["ERC1155_BRIDGE"] = "ERC1155_BRIDGE";
54
50
  })(exports.ContractType || (exports.ContractType = {}));
55
-
56
51
  exports.EventLogType = void 0;
57
-
58
52
  (function (EventLogType) {
59
53
  EventLogType["UNKNOWN"] = "UNKNOWN";
60
54
  EventLogType["BLOCK_ADDED"] = "BLOCK_ADDED";
61
55
  EventLogType["BLOCK_REMOVED"] = "BLOCK_REMOVED";
62
56
  })(exports.EventLogType || (exports.EventLogType = {}));
63
-
64
57
  exports.EventLogDataType = void 0;
65
-
66
58
  (function (EventLogDataType) {
67
59
  EventLogDataType["UNKNOWN"] = "UNKNOWN";
68
60
  EventLogDataType["TOKEN_TRANSFER"] = "TOKEN_TRANSFER";
69
61
  EventLogDataType["SEQUENCE_TXN"] = "SEQUENCE_TXN";
70
62
  })(exports.EventLogDataType || (exports.EventLogDataType = {}));
71
-
72
63
  exports.TxnTransferType = void 0;
73
-
74
64
  (function (TxnTransferType) {
75
65
  TxnTransferType["UNKNOWN"] = "UNKNOWN";
76
66
  TxnTransferType["SEND"] = "SEND";
77
67
  TxnTransferType["RECEIVE"] = "RECEIVE";
78
68
  })(exports.TxnTransferType || (exports.TxnTransferType = {}));
79
-
80
69
  exports.SortOrder = void 0;
81
-
82
70
  (function (SortOrder) {
83
71
  SortOrder["DESC"] = "DESC";
84
72
  SortOrder["ASC"] = "ASC";
85
73
  })(exports.SortOrder || (exports.SortOrder = {}));
86
-
87
74
  //
88
75
  // Client
89
76
  //
@@ -92,7 +79,6 @@ class Indexer {
92
79
  this.hostname = void 0;
93
80
  this.fetch = void 0;
94
81
  this.path = '/rpc/Indexer/';
95
-
96
82
  this.ping = headers => {
97
83
  return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
98
84
  return buildResponse(res).then(_data => {
@@ -102,7 +88,6 @@ class Indexer {
102
88
  });
103
89
  });
104
90
  };
105
-
106
91
  this.version = headers => {
107
92
  return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
108
93
  return buildResponse(res).then(_data => {
@@ -112,7 +97,6 @@ class Indexer {
112
97
  });
113
98
  });
114
99
  };
115
-
116
100
  this.runtimeStatus = headers => {
117
101
  return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
118
102
  return buildResponse(res).then(_data => {
@@ -122,7 +106,6 @@ class Indexer {
122
106
  });
123
107
  });
124
108
  };
125
-
126
109
  this.getChainID = headers => {
127
110
  return this.fetch(this.url('GetChainID'), createHTTPRequest({}, headers)).then(res => {
128
111
  return buildResponse(res).then(_data => {
@@ -132,7 +115,6 @@ class Indexer {
132
115
  });
133
116
  });
134
117
  };
135
-
136
118
  this.getEtherBalance = (args, headers) => {
137
119
  return this.fetch(this.url('GetEtherBalance'), createHTTPRequest(args, headers)).then(res => {
138
120
  return buildResponse(res).then(_data => {
@@ -142,7 +124,6 @@ class Indexer {
142
124
  });
143
125
  });
144
126
  };
145
-
146
127
  this.getTokenBalances = (args, headers) => {
147
128
  return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers)).then(res => {
148
129
  return buildResponse(res).then(_data => {
@@ -153,7 +134,6 @@ class Indexer {
153
134
  });
154
135
  });
155
136
  };
156
-
157
137
  this.getTokenSupplies = (args, headers) => {
158
138
  return this.fetch(this.url('GetTokenSupplies'), createHTTPRequest(args, headers)).then(res => {
159
139
  return buildResponse(res).then(_data => {
@@ -165,7 +145,6 @@ class Indexer {
165
145
  });
166
146
  });
167
147
  };
168
-
169
148
  this.getTokenSuppliesMap = (args, headers) => {
170
149
  return this.fetch(this.url('GetTokenSuppliesMap'), createHTTPRequest(args, headers)).then(res => {
171
150
  return buildResponse(res).then(_data => {
@@ -175,7 +154,6 @@ class Indexer {
175
154
  });
176
155
  });
177
156
  };
178
-
179
157
  this.getBalanceUpdates = (args, headers) => {
180
158
  return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest(args, headers)).then(res => {
181
159
  return buildResponse(res).then(_data => {
@@ -186,7 +164,6 @@ class Indexer {
186
164
  });
187
165
  });
188
166
  };
189
-
190
167
  this.getTransactionHistory = (args, headers) => {
191
168
  return this.fetch(this.url('GetTransactionHistory'), createHTTPRequest(args, headers)).then(res => {
192
169
  return buildResponse(res).then(_data => {
@@ -197,7 +174,6 @@ class Indexer {
197
174
  });
198
175
  });
199
176
  };
200
-
201
177
  this.syncBalance = (args, headers) => {
202
178
  return this.fetch(this.url('SyncBalance'), createHTTPRequest(args, headers)).then(res => {
203
179
  return buildResponse(res).then(_data => {
@@ -205,17 +181,13 @@ class Indexer {
205
181
  });
206
182
  });
207
183
  };
208
-
209
184
  this.hostname = hostname;
210
- this.fetch = fetch;
185
+ this.fetch = (input, init) => fetch(input, init);
211
186
  }
212
-
213
187
  url(name) {
214
188
  return this.hostname + this.path + name;
215
189
  }
216
-
217
190
  }
218
-
219
191
  const createHTTPRequest = (body = {}, headers = {}) => {
220
192
  return {
221
193
  method: 'POST',
@@ -225,11 +197,9 @@ const createHTTPRequest = (body = {}, headers = {}) => {
225
197
  body: JSON.stringify(body || {})
226
198
  };
227
199
  };
228
-
229
200
  const buildResponse = res => {
230
201
  return res.text().then(text => {
231
202
  let data;
232
-
233
203
  try {
234
204
  data = JSON.parse(text);
235
205
  } catch (err) {
@@ -239,7 +209,6 @@ const buildResponse = res => {
239
209
  status: res.status
240
210
  };
241
211
  }
242
-
243
212
  if (!res.ok) {
244
213
  throw data; // webrpc error response
245
214
  }
@@ -248,8 +217,8 @@ const buildResponse = res => {
248
217
  });
249
218
  };
250
219
 
220
+ // TODO: rename to SequenceIndexerNetworks
251
221
  exports.SequenceIndexerServices = void 0;
252
-
253
222
  (function (SequenceIndexerServices) {
254
223
  SequenceIndexerServices["MAINNET"] = "https://mainnet-indexer.sequence.app";
255
224
  SequenceIndexerServices["POLYGON"] = "https://polygon-indexer.sequence.app";
@@ -263,30 +232,28 @@ exports.SequenceIndexerServices = void 0;
263
232
  SequenceIndexerServices["BSC_TESTNET"] = "https://bsc-testnet-indexer.sequence.app";
264
233
  SequenceIndexerServices["GOERLI"] = "https://goerli-indexer.sequence.app";
265
234
  })(exports.SequenceIndexerServices || (exports.SequenceIndexerServices = {}));
266
-
267
235
  class SequenceIndexerClient extends Indexer {
268
236
  constructor(hostname, jwtAuth) {
269
- super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch__default["default"]);
237
+ super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, global.fetch);
270
238
  this.jwtAuth = jwtAuth;
271
-
272
239
  this._fetch = (input, init) => {
273
240
  // automatically include jwt auth header to requests
274
241
  // if its been set on the api client
275
242
  const headers = {};
276
-
277
243
  if (this.jwtAuth && this.jwtAuth.length > 0) {
278
244
  headers['Authorization'] = `BEARER ${this.jwtAuth}`;
279
- } // before the request is made
280
-
245
+ }
281
246
 
247
+ // before the request is made
282
248
  init.headers = _extends({}, init.headers, headers);
283
- return fetch__default["default"](input, init);
249
+ return global.fetch(input, init);
284
250
  };
285
-
286
251
  this.fetch = this._fetch;
287
252
  }
253
+ }
254
+
255
+ // const SequenceIndexerServices: { [key: string]: string } = {}
288
256
 
289
- } // const SequenceIndexerServices: { [key: string]: string } = {}
290
257
  // {
291
258
  // [ ...mainnetNetworks, ...testnetNetworks ].forEach(n => {
292
259
  // if (n.indexerUrl) {
@@ -294,6 +261,7 @@ class SequenceIndexerClient extends Indexer {
294
261
  // }
295
262
  // })
296
263
  // }
264
+
297
265
  // export { SequenceIndexerServices }
298
266
 
299
267
  exports.Indexer = Indexer;
@@ -2,46 +2,42 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
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
5
  function _extends() {
12
- _extends = Object.assign || function (target) {
6
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
13
7
  for (var i = 1; i < arguments.length; i++) {
14
8
  var source = arguments[i];
15
-
16
9
  for (var key in source) {
17
10
  if (Object.prototype.hasOwnProperty.call(source, key)) {
18
11
  target[key] = source[key];
19
12
  }
20
13
  }
21
14
  }
22
-
23
15
  return target;
24
16
  };
25
-
26
17
  return _extends.apply(this, arguments);
27
18
  }
28
19
 
29
20
  /* eslint-disable */
30
- // sequence-indexer v0.4.0 6071879702f8258e8912ca95cf2d9c1459ca991d
21
+ // sequence-indexer v0.4.0 7cdd11a44d6d1c5371dca8be8a603b1c67d53e22
31
22
  // --
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.
23
+ // Code generated by webrpc-gen@v0.7.0 with typescript generator. DO NOT EDIT.
24
+ //
25
+ // webrpc-gen -schema=indexer.ridl -target=typescript -client -out=./clients/indexer.gen.ts
26
+
34
27
  // WebRPC description and code-gen version
35
- const WebRPCVersion = "v1"; // Schema version of your RIDL schema
28
+ const WebRPCVersion = "v1";
29
+
30
+ // Schema version of your RIDL schema
31
+ const WebRPCSchemaVersion = "v0.4.0";
36
32
 
37
- const WebRPCSchemaVersion = "v0.4.0"; // Schema hash generated from your RIDL schema
33
+ // Schema hash generated from your RIDL schema
34
+ const WebRPCSchemaHash = "7cdd11a44d6d1c5371dca8be8a603b1c67d53e22";
38
35
 
39
- const WebRPCSchemaHash = "6071879702f8258e8912ca95cf2d9c1459ca991d"; //
36
+ //
40
37
  // Types
41
38
  //
42
39
 
43
40
  exports.ContractType = void 0;
44
-
45
41
  (function (ContractType) {
46
42
  ContractType["UNKNOWN"] = "UNKNOWN";
47
43
  ContractType["ERC20"] = "ERC20";
@@ -52,38 +48,29 @@ exports.ContractType = void 0;
52
48
  ContractType["ERC721_BRIDGE"] = "ERC721_BRIDGE";
53
49
  ContractType["ERC1155_BRIDGE"] = "ERC1155_BRIDGE";
54
50
  })(exports.ContractType || (exports.ContractType = {}));
55
-
56
51
  exports.EventLogType = void 0;
57
-
58
52
  (function (EventLogType) {
59
53
  EventLogType["UNKNOWN"] = "UNKNOWN";
60
54
  EventLogType["BLOCK_ADDED"] = "BLOCK_ADDED";
61
55
  EventLogType["BLOCK_REMOVED"] = "BLOCK_REMOVED";
62
56
  })(exports.EventLogType || (exports.EventLogType = {}));
63
-
64
57
  exports.EventLogDataType = void 0;
65
-
66
58
  (function (EventLogDataType) {
67
59
  EventLogDataType["UNKNOWN"] = "UNKNOWN";
68
60
  EventLogDataType["TOKEN_TRANSFER"] = "TOKEN_TRANSFER";
69
61
  EventLogDataType["SEQUENCE_TXN"] = "SEQUENCE_TXN";
70
62
  })(exports.EventLogDataType || (exports.EventLogDataType = {}));
71
-
72
63
  exports.TxnTransferType = void 0;
73
-
74
64
  (function (TxnTransferType) {
75
65
  TxnTransferType["UNKNOWN"] = "UNKNOWN";
76
66
  TxnTransferType["SEND"] = "SEND";
77
67
  TxnTransferType["RECEIVE"] = "RECEIVE";
78
68
  })(exports.TxnTransferType || (exports.TxnTransferType = {}));
79
-
80
69
  exports.SortOrder = void 0;
81
-
82
70
  (function (SortOrder) {
83
71
  SortOrder["DESC"] = "DESC";
84
72
  SortOrder["ASC"] = "ASC";
85
73
  })(exports.SortOrder || (exports.SortOrder = {}));
86
-
87
74
  //
88
75
  // Client
89
76
  //
@@ -92,7 +79,6 @@ class Indexer {
92
79
  this.hostname = void 0;
93
80
  this.fetch = void 0;
94
81
  this.path = '/rpc/Indexer/';
95
-
96
82
  this.ping = headers => {
97
83
  return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
98
84
  return buildResponse(res).then(_data => {
@@ -102,7 +88,6 @@ class Indexer {
102
88
  });
103
89
  });
104
90
  };
105
-
106
91
  this.version = headers => {
107
92
  return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
108
93
  return buildResponse(res).then(_data => {
@@ -112,7 +97,6 @@ class Indexer {
112
97
  });
113
98
  });
114
99
  };
115
-
116
100
  this.runtimeStatus = headers => {
117
101
  return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
118
102
  return buildResponse(res).then(_data => {
@@ -122,7 +106,6 @@ class Indexer {
122
106
  });
123
107
  });
124
108
  };
125
-
126
109
  this.getChainID = headers => {
127
110
  return this.fetch(this.url('GetChainID'), createHTTPRequest({}, headers)).then(res => {
128
111
  return buildResponse(res).then(_data => {
@@ -132,7 +115,6 @@ class Indexer {
132
115
  });
133
116
  });
134
117
  };
135
-
136
118
  this.getEtherBalance = (args, headers) => {
137
119
  return this.fetch(this.url('GetEtherBalance'), createHTTPRequest(args, headers)).then(res => {
138
120
  return buildResponse(res).then(_data => {
@@ -142,7 +124,6 @@ class Indexer {
142
124
  });
143
125
  });
144
126
  };
145
-
146
127
  this.getTokenBalances = (args, headers) => {
147
128
  return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers)).then(res => {
148
129
  return buildResponse(res).then(_data => {
@@ -153,7 +134,6 @@ class Indexer {
153
134
  });
154
135
  });
155
136
  };
156
-
157
137
  this.getTokenSupplies = (args, headers) => {
158
138
  return this.fetch(this.url('GetTokenSupplies'), createHTTPRequest(args, headers)).then(res => {
159
139
  return buildResponse(res).then(_data => {
@@ -165,7 +145,6 @@ class Indexer {
165
145
  });
166
146
  });
167
147
  };
168
-
169
148
  this.getTokenSuppliesMap = (args, headers) => {
170
149
  return this.fetch(this.url('GetTokenSuppliesMap'), createHTTPRequest(args, headers)).then(res => {
171
150
  return buildResponse(res).then(_data => {
@@ -175,7 +154,6 @@ class Indexer {
175
154
  });
176
155
  });
177
156
  };
178
-
179
157
  this.getBalanceUpdates = (args, headers) => {
180
158
  return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest(args, headers)).then(res => {
181
159
  return buildResponse(res).then(_data => {
@@ -186,7 +164,6 @@ class Indexer {
186
164
  });
187
165
  });
188
166
  };
189
-
190
167
  this.getTransactionHistory = (args, headers) => {
191
168
  return this.fetch(this.url('GetTransactionHistory'), createHTTPRequest(args, headers)).then(res => {
192
169
  return buildResponse(res).then(_data => {
@@ -197,7 +174,6 @@ class Indexer {
197
174
  });
198
175
  });
199
176
  };
200
-
201
177
  this.syncBalance = (args, headers) => {
202
178
  return this.fetch(this.url('SyncBalance'), createHTTPRequest(args, headers)).then(res => {
203
179
  return buildResponse(res).then(_data => {
@@ -205,17 +181,13 @@ class Indexer {
205
181
  });
206
182
  });
207
183
  };
208
-
209
184
  this.hostname = hostname;
210
- this.fetch = fetch;
185
+ this.fetch = (input, init) => fetch(input, init);
211
186
  }
212
-
213
187
  url(name) {
214
188
  return this.hostname + this.path + name;
215
189
  }
216
-
217
190
  }
218
-
219
191
  const createHTTPRequest = (body = {}, headers = {}) => {
220
192
  return {
221
193
  method: 'POST',
@@ -225,11 +197,9 @@ const createHTTPRequest = (body = {}, headers = {}) => {
225
197
  body: JSON.stringify(body || {})
226
198
  };
227
199
  };
228
-
229
200
  const buildResponse = res => {
230
201
  return res.text().then(text => {
231
202
  let data;
232
-
233
203
  try {
234
204
  data = JSON.parse(text);
235
205
  } catch (err) {
@@ -239,7 +209,6 @@ const buildResponse = res => {
239
209
  status: res.status
240
210
  };
241
211
  }
242
-
243
212
  if (!res.ok) {
244
213
  throw data; // webrpc error response
245
214
  }
@@ -248,8 +217,8 @@ const buildResponse = res => {
248
217
  });
249
218
  };
250
219
 
220
+ // TODO: rename to SequenceIndexerNetworks
251
221
  exports.SequenceIndexerServices = void 0;
252
-
253
222
  (function (SequenceIndexerServices) {
254
223
  SequenceIndexerServices["MAINNET"] = "https://mainnet-indexer.sequence.app";
255
224
  SequenceIndexerServices["POLYGON"] = "https://polygon-indexer.sequence.app";
@@ -263,30 +232,28 @@ exports.SequenceIndexerServices = void 0;
263
232
  SequenceIndexerServices["BSC_TESTNET"] = "https://bsc-testnet-indexer.sequence.app";
264
233
  SequenceIndexerServices["GOERLI"] = "https://goerli-indexer.sequence.app";
265
234
  })(exports.SequenceIndexerServices || (exports.SequenceIndexerServices = {}));
266
-
267
235
  class SequenceIndexerClient extends Indexer {
268
236
  constructor(hostname, jwtAuth) {
269
- super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch__default["default"]);
237
+ super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, global.fetch);
270
238
  this.jwtAuth = jwtAuth;
271
-
272
239
  this._fetch = (input, init) => {
273
240
  // automatically include jwt auth header to requests
274
241
  // if its been set on the api client
275
242
  const headers = {};
276
-
277
243
  if (this.jwtAuth && this.jwtAuth.length > 0) {
278
244
  headers['Authorization'] = `BEARER ${this.jwtAuth}`;
279
- } // before the request is made
280
-
245
+ }
281
246
 
247
+ // before the request is made
282
248
  init.headers = _extends({}, init.headers, headers);
283
- return fetch__default["default"](input, init);
249
+ return global.fetch(input, init);
284
250
  };
285
-
286
251
  this.fetch = this._fetch;
287
252
  }
253
+ }
254
+
255
+ // const SequenceIndexerServices: { [key: string]: string } = {}
288
256
 
289
- } // const SequenceIndexerServices: { [key: string]: string } = {}
290
257
  // {
291
258
  // [ ...mainnetNetworks, ...testnetNetworks ].forEach(n => {
292
259
  // if (n.indexerUrl) {
@@ -294,6 +261,7 @@ class SequenceIndexerClient extends Indexer {
294
261
  // }
295
262
  // })
296
263
  // }
264
+
297
265
  // export { SequenceIndexerServices }
298
266
 
299
267
  exports.Indexer = Indexer;
@@ -1,39 +1,39 @@
1
- import fetch from 'cross-fetch';
2
-
3
1
  function _extends() {
4
- _extends = Object.assign || function (target) {
2
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
5
3
  for (var i = 1; i < arguments.length; i++) {
6
4
  var source = arguments[i];
7
-
8
5
  for (var key in source) {
9
6
  if (Object.prototype.hasOwnProperty.call(source, key)) {
10
7
  target[key] = source[key];
11
8
  }
12
9
  }
13
10
  }
14
-
15
11
  return target;
16
12
  };
17
-
18
13
  return _extends.apply(this, arguments);
19
14
  }
20
15
 
21
16
  /* eslint-disable */
22
- // sequence-indexer v0.4.0 6071879702f8258e8912ca95cf2d9c1459ca991d
17
+ // sequence-indexer v0.4.0 7cdd11a44d6d1c5371dca8be8a603b1c67d53e22
23
18
  // --
24
- // This file has been generated by https://github.com/webrpc/webrpc using gen/typescript
25
- // Do not edit by hand. Update your webrpc schema and re-generate.
19
+ // Code generated by webrpc-gen@v0.7.0 with typescript generator. DO NOT EDIT.
20
+ //
21
+ // webrpc-gen -schema=indexer.ridl -target=typescript -client -out=./clients/indexer.gen.ts
22
+
26
23
  // WebRPC description and code-gen version
27
- const WebRPCVersion = "v1"; // Schema version of your RIDL schema
24
+ const WebRPCVersion = "v1";
28
25
 
29
- const WebRPCSchemaVersion = "v0.4.0"; // Schema hash generated from your RIDL schema
26
+ // Schema version of your RIDL schema
27
+ const WebRPCSchemaVersion = "v0.4.0";
30
28
 
31
- const WebRPCSchemaHash = "6071879702f8258e8912ca95cf2d9c1459ca991d"; //
29
+ // Schema hash generated from your RIDL schema
30
+ const WebRPCSchemaHash = "7cdd11a44d6d1c5371dca8be8a603b1c67d53e22";
31
+
32
+ //
32
33
  // Types
33
34
  //
34
35
 
35
36
  let ContractType;
36
-
37
37
  (function (ContractType) {
38
38
  ContractType["UNKNOWN"] = "UNKNOWN";
39
39
  ContractType["ERC20"] = "ERC20";
@@ -44,38 +44,29 @@ let ContractType;
44
44
  ContractType["ERC721_BRIDGE"] = "ERC721_BRIDGE";
45
45
  ContractType["ERC1155_BRIDGE"] = "ERC1155_BRIDGE";
46
46
  })(ContractType || (ContractType = {}));
47
-
48
47
  let EventLogType;
49
-
50
48
  (function (EventLogType) {
51
49
  EventLogType["UNKNOWN"] = "UNKNOWN";
52
50
  EventLogType["BLOCK_ADDED"] = "BLOCK_ADDED";
53
51
  EventLogType["BLOCK_REMOVED"] = "BLOCK_REMOVED";
54
52
  })(EventLogType || (EventLogType = {}));
55
-
56
53
  let EventLogDataType;
57
-
58
54
  (function (EventLogDataType) {
59
55
  EventLogDataType["UNKNOWN"] = "UNKNOWN";
60
56
  EventLogDataType["TOKEN_TRANSFER"] = "TOKEN_TRANSFER";
61
57
  EventLogDataType["SEQUENCE_TXN"] = "SEQUENCE_TXN";
62
58
  })(EventLogDataType || (EventLogDataType = {}));
63
-
64
59
  let TxnTransferType;
65
-
66
60
  (function (TxnTransferType) {
67
61
  TxnTransferType["UNKNOWN"] = "UNKNOWN";
68
62
  TxnTransferType["SEND"] = "SEND";
69
63
  TxnTransferType["RECEIVE"] = "RECEIVE";
70
64
  })(TxnTransferType || (TxnTransferType = {}));
71
-
72
65
  let SortOrder;
73
-
74
66
  (function (SortOrder) {
75
67
  SortOrder["DESC"] = "DESC";
76
68
  SortOrder["ASC"] = "ASC";
77
69
  })(SortOrder || (SortOrder = {}));
78
-
79
70
  //
80
71
  // Client
81
72
  //
@@ -84,7 +75,6 @@ class Indexer {
84
75
  this.hostname = void 0;
85
76
  this.fetch = void 0;
86
77
  this.path = '/rpc/Indexer/';
87
-
88
78
  this.ping = headers => {
89
79
  return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
90
80
  return buildResponse(res).then(_data => {
@@ -94,7 +84,6 @@ class Indexer {
94
84
  });
95
85
  });
96
86
  };
97
-
98
87
  this.version = headers => {
99
88
  return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
100
89
  return buildResponse(res).then(_data => {
@@ -104,7 +93,6 @@ class Indexer {
104
93
  });
105
94
  });
106
95
  };
107
-
108
96
  this.runtimeStatus = headers => {
109
97
  return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
110
98
  return buildResponse(res).then(_data => {
@@ -114,7 +102,6 @@ class Indexer {
114
102
  });
115
103
  });
116
104
  };
117
-
118
105
  this.getChainID = headers => {
119
106
  return this.fetch(this.url('GetChainID'), createHTTPRequest({}, headers)).then(res => {
120
107
  return buildResponse(res).then(_data => {
@@ -124,7 +111,6 @@ class Indexer {
124
111
  });
125
112
  });
126
113
  };
127
-
128
114
  this.getEtherBalance = (args, headers) => {
129
115
  return this.fetch(this.url('GetEtherBalance'), createHTTPRequest(args, headers)).then(res => {
130
116
  return buildResponse(res).then(_data => {
@@ -134,7 +120,6 @@ class Indexer {
134
120
  });
135
121
  });
136
122
  };
137
-
138
123
  this.getTokenBalances = (args, headers) => {
139
124
  return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers)).then(res => {
140
125
  return buildResponse(res).then(_data => {
@@ -145,7 +130,6 @@ class Indexer {
145
130
  });
146
131
  });
147
132
  };
148
-
149
133
  this.getTokenSupplies = (args, headers) => {
150
134
  return this.fetch(this.url('GetTokenSupplies'), createHTTPRequest(args, headers)).then(res => {
151
135
  return buildResponse(res).then(_data => {
@@ -157,7 +141,6 @@ class Indexer {
157
141
  });
158
142
  });
159
143
  };
160
-
161
144
  this.getTokenSuppliesMap = (args, headers) => {
162
145
  return this.fetch(this.url('GetTokenSuppliesMap'), createHTTPRequest(args, headers)).then(res => {
163
146
  return buildResponse(res).then(_data => {
@@ -167,7 +150,6 @@ class Indexer {
167
150
  });
168
151
  });
169
152
  };
170
-
171
153
  this.getBalanceUpdates = (args, headers) => {
172
154
  return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest(args, headers)).then(res => {
173
155
  return buildResponse(res).then(_data => {
@@ -178,7 +160,6 @@ class Indexer {
178
160
  });
179
161
  });
180
162
  };
181
-
182
163
  this.getTransactionHistory = (args, headers) => {
183
164
  return this.fetch(this.url('GetTransactionHistory'), createHTTPRequest(args, headers)).then(res => {
184
165
  return buildResponse(res).then(_data => {
@@ -189,7 +170,6 @@ class Indexer {
189
170
  });
190
171
  });
191
172
  };
192
-
193
173
  this.syncBalance = (args, headers) => {
194
174
  return this.fetch(this.url('SyncBalance'), createHTTPRequest(args, headers)).then(res => {
195
175
  return buildResponse(res).then(_data => {
@@ -197,17 +177,13 @@ class Indexer {
197
177
  });
198
178
  });
199
179
  };
200
-
201
180
  this.hostname = hostname;
202
- this.fetch = fetch;
181
+ this.fetch = (input, init) => fetch(input, init);
203
182
  }
204
-
205
183
  url(name) {
206
184
  return this.hostname + this.path + name;
207
185
  }
208
-
209
186
  }
210
-
211
187
  const createHTTPRequest = (body = {}, headers = {}) => {
212
188
  return {
213
189
  method: 'POST',
@@ -217,11 +193,9 @@ const createHTTPRequest = (body = {}, headers = {}) => {
217
193
  body: JSON.stringify(body || {})
218
194
  };
219
195
  };
220
-
221
196
  const buildResponse = res => {
222
197
  return res.text().then(text => {
223
198
  let data;
224
-
225
199
  try {
226
200
  data = JSON.parse(text);
227
201
  } catch (err) {
@@ -231,7 +205,6 @@ const buildResponse = res => {
231
205
  status: res.status
232
206
  };
233
207
  }
234
-
235
208
  if (!res.ok) {
236
209
  throw data; // webrpc error response
237
210
  }
@@ -240,8 +213,8 @@ const buildResponse = res => {
240
213
  });
241
214
  };
242
215
 
216
+ // TODO: rename to SequenceIndexerNetworks
243
217
  let SequenceIndexerServices;
244
-
245
218
  (function (SequenceIndexerServices) {
246
219
  SequenceIndexerServices["MAINNET"] = "https://mainnet-indexer.sequence.app";
247
220
  SequenceIndexerServices["POLYGON"] = "https://polygon-indexer.sequence.app";
@@ -255,30 +228,28 @@ let SequenceIndexerServices;
255
228
  SequenceIndexerServices["BSC_TESTNET"] = "https://bsc-testnet-indexer.sequence.app";
256
229
  SequenceIndexerServices["GOERLI"] = "https://goerli-indexer.sequence.app";
257
230
  })(SequenceIndexerServices || (SequenceIndexerServices = {}));
258
-
259
231
  class SequenceIndexerClient extends Indexer {
260
232
  constructor(hostname, jwtAuth) {
261
- super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
233
+ super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, global.fetch);
262
234
  this.jwtAuth = jwtAuth;
263
-
264
235
  this._fetch = (input, init) => {
265
236
  // automatically include jwt auth header to requests
266
237
  // if its been set on the api client
267
238
  const headers = {};
268
-
269
239
  if (this.jwtAuth && this.jwtAuth.length > 0) {
270
240
  headers['Authorization'] = `BEARER ${this.jwtAuth}`;
271
- } // before the request is made
272
-
241
+ }
273
242
 
243
+ // before the request is made
274
244
  init.headers = _extends({}, init.headers, headers);
275
- return fetch(input, init);
245
+ return global.fetch(input, init);
276
246
  };
277
-
278
247
  this.fetch = this._fetch;
279
248
  }
249
+ }
250
+
251
+ // const SequenceIndexerServices: { [key: string]: string } = {}
280
252
 
281
- } // const SequenceIndexerServices: { [key: string]: string } = {}
282
253
  // {
283
254
  // [ ...mainnetNetworks, ...testnetNetworks ].forEach(n => {
284
255
  // if (n.indexerUrl) {
@@ -286,6 +257,7 @@ class SequenceIndexerClient extends Indexer {
286
257
  // }
287
258
  // })
288
259
  // }
260
+
289
261
  // export { SequenceIndexerServices }
290
262
 
291
263
  export { ContractType, EventLogDataType, EventLogType, Indexer, SequenceIndexerClient, SequenceIndexerServices, SortOrder, TxnTransferType, WebRPCSchemaHash, WebRPCSchemaVersion, WebRPCVersion };
@@ -1,5 +1,5 @@
1
1
  export * from './indexer.gen';
2
- import { Indexer as BaseSequenceIndexer } from './indexer.gen';
2
+ import { Indexer as IndexerRpc } from './indexer.gen';
3
3
  export declare enum SequenceIndexerServices {
4
4
  MAINNET = "https://mainnet-indexer.sequence.app",
5
5
  POLYGON = "https://polygon-indexer.sequence.app",
@@ -13,8 +13,8 @@ export declare enum SequenceIndexerServices {
13
13
  BSC_TESTNET = "https://bsc-testnet-indexer.sequence.app",
14
14
  GOERLI = "https://goerli-indexer.sequence.app"
15
15
  }
16
- export declare class SequenceIndexerClient extends BaseSequenceIndexer {
16
+ export declare class SequenceIndexerClient extends IndexerRpc {
17
17
  jwtAuth?: string | undefined;
18
18
  constructor(hostname: string, jwtAuth?: string | undefined);
19
- _fetch: (input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
19
+ _fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
20
20
  }
@@ -1,6 +1,6 @@
1
1
  export declare const WebRPCVersion = "v1";
2
2
  export declare const WebRPCSchemaVersion = "v0.4.0";
3
- export declare const WebRPCSchemaHash = "6071879702f8258e8912ca95cf2d9c1459ca991d";
3
+ export declare const WebRPCSchemaHash = "7cdd11a44d6d1c5371dca8be8a603b1c67d53e22";
4
4
  export interface ContractInfo {
5
5
  chainId: number;
6
6
  address: string;
@@ -89,6 +89,7 @@ export interface RuntimeChecks {
89
89
  running: boolean;
90
90
  syncMode: string;
91
91
  lastBlockNum: number;
92
+ lastBlockNumWithState: number;
92
93
  }
93
94
  export interface EtherBalance {
94
95
  accountAddress: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/indexer",
3
- "version": "0.42.10",
3
+ "version": "0.43.0",
4
4
  "description": "indexer sub-package for Sequence",
5
5
  "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/indexer",
6
6
  "source": "src/index.ts",
@@ -12,9 +12,7 @@
12
12
  "test": "echo",
13
13
  "typecheck": "tsc --noEmit"
14
14
  },
15
- "dependencies": {
16
- "cross-fetch": "^3.1.5"
17
- },
15
+ "dependencies": {},
18
16
  "peerDependencies": {},
19
17
  "devDependencies": {},
20
18
  "files": [
package/src/index.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  export * from './indexer.gen'
2
2
 
3
- import fetch from 'cross-fetch'
4
-
5
- import { Indexer as BaseSequenceIndexer } from './indexer.gen'
3
+ import { Indexer as IndexerRpc } from './indexer.gen'
6
4
 
5
+ // TODO: rename to SequenceIndexerNetworks
7
6
  export enum SequenceIndexerServices {
8
7
  MAINNET = 'https://mainnet-indexer.sequence.app',
9
8
 
@@ -23,9 +22,9 @@ export enum SequenceIndexerServices {
23
22
  GOERLI = 'https://goerli-indexer.sequence.app'
24
23
  }
25
24
 
26
- export class SequenceIndexerClient extends BaseSequenceIndexer {
25
+ export class SequenceIndexerClient extends IndexerRpc {
27
26
  constructor(hostname: string, public jwtAuth?: string) {
28
- super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch)
27
+ super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, global.fetch)
29
28
  this.fetch = this._fetch
30
29
  }
31
30
 
@@ -40,7 +39,7 @@ export class SequenceIndexerClient extends BaseSequenceIndexer {
40
39
  // before the request is made
41
40
  init!.headers = { ...init!.headers, ...headers }
42
41
 
43
- return fetch(input, init)
42
+ return global.fetch(input, init)
44
43
  }
45
44
  }
46
45
 
@@ -1,8 +1,9 @@
1
1
  /* eslint-disable */
2
- // sequence-indexer v0.4.0 6071879702f8258e8912ca95cf2d9c1459ca991d
2
+ // sequence-indexer v0.4.0 7cdd11a44d6d1c5371dca8be8a603b1c67d53e22
3
3
  // --
4
- // This file has been generated by https://github.com/webrpc/webrpc using gen/typescript
5
- // Do not edit by hand. Update your webrpc schema and re-generate.
4
+ // Code generated by webrpc-gen@v0.7.0 with typescript generator. DO NOT EDIT.
5
+ //
6
+ // webrpc-gen -schema=indexer.ridl -target=typescript -client -out=./clients/indexer.gen.ts
6
7
 
7
8
  // WebRPC description and code-gen version
8
9
  export const WebRPCVersion = "v1"
@@ -11,8 +12,7 @@ export const WebRPCVersion = "v1"
11
12
  export const WebRPCSchemaVersion = "v0.4.0"
12
13
 
13
14
  // Schema hash generated from your RIDL schema
14
- export const WebRPCSchemaHash = "6071879702f8258e8912ca95cf2d9c1459ca991d"
15
-
15
+ export const WebRPCSchemaHash = "7cdd11a44d6d1c5371dca8be8a603b1c67d53e22"
16
16
 
17
17
  //
18
18
  // Types
@@ -111,6 +111,7 @@ export interface RuntimeChecks {
111
111
  running: boolean
112
112
  syncMode: string
113
113
  lastBlockNum: number
114
+ lastBlockNumWithState: number
114
115
  }
115
116
 
116
117
  export interface EtherBalance {
@@ -342,7 +343,7 @@ export class Indexer implements Indexer {
342
343
 
343
344
  constructor(hostname: string, fetch: Fetch) {
344
345
  this.hostname = hostname
345
- this.fetch = fetch
346
+ this.fetch = (input: RequestInfo, init?: RequestInit) => fetch(input, init)
346
347
  }
347
348
 
348
349
  private url(name: string): string {
@@ -521,4 +522,4 @@ const buildResponse = (res: Response): Promise<any> => {
521
522
  })
522
523
  }
523
524
 
524
- export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>
525
+ export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>