@0xsequence/indexer 1.1.0 → 1.1.2

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.
@@ -25,13 +25,13 @@ function _extends() {
25
25
  // webrpc-gen -schema=indexer.ridl -target=typescript -client -out=./clients/indexer.gen.ts
26
26
 
27
27
  // WebRPC description and code-gen version
28
- const WebRPCVersion = "v1";
28
+ const WebRPCVersion = 'v1';
29
29
 
30
30
  // Schema version of your RIDL schema
31
- const WebRPCSchemaVersion = "v0.4.0";
31
+ const WebRPCSchemaVersion = 'v0.4.0';
32
32
 
33
33
  // Schema hash generated from your RIDL schema
34
- const WebRPCSchemaHash = "3254a537c563d6b612b7ab5365c305664abb5951";
34
+ const WebRPCSchemaHash = '3254a537c563d6b612b7ab5365c305664abb5951';
35
35
 
36
36
  //
37
37
  // Types
@@ -25,13 +25,13 @@ function _extends() {
25
25
  // webrpc-gen -schema=indexer.ridl -target=typescript -client -out=./clients/indexer.gen.ts
26
26
 
27
27
  // WebRPC description and code-gen version
28
- const WebRPCVersion = "v1";
28
+ const WebRPCVersion = 'v1';
29
29
 
30
30
  // Schema version of your RIDL schema
31
- const WebRPCSchemaVersion = "v0.4.0";
31
+ const WebRPCSchemaVersion = 'v0.4.0';
32
32
 
33
33
  // Schema hash generated from your RIDL schema
34
- const WebRPCSchemaHash = "3254a537c563d6b612b7ab5365c305664abb5951";
34
+ const WebRPCSchemaHash = '3254a537c563d6b612b7ab5365c305664abb5951';
35
35
 
36
36
  //
37
37
  // Types
@@ -21,13 +21,13 @@ function _extends() {
21
21
  // webrpc-gen -schema=indexer.ridl -target=typescript -client -out=./clients/indexer.gen.ts
22
22
 
23
23
  // WebRPC description and code-gen version
24
- const WebRPCVersion = "v1";
24
+ const WebRPCVersion = 'v1';
25
25
 
26
26
  // Schema version of your RIDL schema
27
- const WebRPCSchemaVersion = "v0.4.0";
27
+ const WebRPCSchemaVersion = 'v0.4.0';
28
28
 
29
29
  // Schema hash generated from your RIDL schema
30
- const WebRPCSchemaHash = "3254a537c563d6b612b7ab5365c305664abb5951";
30
+ const WebRPCSchemaHash = '3254a537c563d6b612b7ab5365c305664abb5951';
31
31
 
32
32
  //
33
33
  // Types
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/indexer",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
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",
package/src/index.ts CHANGED
@@ -8,7 +8,7 @@ export enum SequenceIndexerServices {
8
8
 
9
9
  POLYGON = 'https://polygon-indexer.sequence.app',
10
10
  POLYGON_MUMBAI = 'https://mumbai-indexer.sequence.app',
11
-
11
+
12
12
  POLYGON_ZKEVM = 'https://polygon-zkevm-indexer.sequence.app',
13
13
 
14
14
  ARBITRUM = 'https://arbitrum-indexer.sequence.app',
@@ -27,7 +27,10 @@ export enum SequenceIndexerServices {
27
27
  const fetch = typeof global === 'object' ? global.fetch : window.fetch
28
28
 
29
29
  export class SequenceIndexerClient extends IndexerRpc {
30
- constructor(hostname: string, public jwtAuth?: string) {
30
+ constructor(
31
+ hostname: string,
32
+ public jwtAuth?: string
33
+ ) {
31
34
  super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch)
32
35
  this.fetch = this._fetch
33
36
  }
@@ -47,7 +50,6 @@ export class SequenceIndexerClient extends IndexerRpc {
47
50
  }
48
51
  }
49
52
 
50
-
51
53
  // const SequenceIndexerServices: { [key: string]: string } = {}
52
54
 
53
55
  // {
@@ -6,19 +6,18 @@
6
6
  // webrpc-gen -schema=indexer.ridl -target=typescript -client -out=./clients/indexer.gen.ts
7
7
 
8
8
  // WebRPC description and code-gen version
9
- export const WebRPCVersion = "v1"
9
+ export const WebRPCVersion = 'v1'
10
10
 
11
11
  // Schema version of your RIDL schema
12
- export const WebRPCSchemaVersion = "v0.4.0"
12
+ export const WebRPCSchemaVersion = 'v0.4.0'
13
13
 
14
14
  // Schema hash generated from your RIDL schema
15
- export const WebRPCSchemaHash = "3254a537c563d6b612b7ab5365c305664abb5951"
15
+ export const WebRPCSchemaHash = '3254a537c563d6b612b7ab5365c305664abb5951'
16
16
 
17
17
  //
18
18
  // Types
19
19
  //
20
20
 
21
-
22
21
  export interface ContractInfo {
23
22
  chainId: number
24
23
  address: string
@@ -30,7 +29,6 @@ export interface ContractInfo {
30
29
  deployed: boolean
31
30
  bytecodeHash: string
32
31
  extensions: ContractInfoExtensions
33
-
34
32
  }
35
33
 
36
34
  export interface ContractInfoExtensions {
@@ -49,14 +47,14 @@ export interface TokenMetadata {
49
47
  description: string
50
48
  image: string
51
49
  decimals: number
52
- properties: {[key: string]: any}
50
+ properties: { [key: string]: any }
53
51
  video: string
54
52
  audio: string
55
53
  image_data: string
56
54
  external_url: string
57
55
  background_color: string
58
56
  animation_url: string
59
- attributes: Array<{[key: string]: any}>
57
+ attributes: Array<{ [key: string]: any }>
60
58
  }
61
59
  export enum ContractType {
62
60
  UNKNOWN = 'UNKNOWN',
@@ -173,7 +171,7 @@ export interface TokenBalance {
173
171
  blockHash: string
174
172
  blockNumber: number
175
173
  chainId: number
176
-
174
+
177
175
  contractInfo?: ContractInfo
178
176
  tokenMetadata?: TokenMetadata
179
177
  }
@@ -223,7 +221,7 @@ export interface TxnTransfer {
223
221
  amounts: Array<string>
224
222
  logIndex: number
225
223
  contractInfo?: ContractInfo
226
- tokenMetadata?: {[key: string]: TokenMetadata}
224
+ tokenMetadata?: { [key: string]: TokenMetadata }
227
225
  }
228
226
 
229
227
  export interface TransactionHistoryFilter {
@@ -297,39 +295,38 @@ export interface Indexer {
297
295
  getTransactionHistory(args: GetTransactionHistoryArgs, headers?: object): Promise<GetTransactionHistoryReturn>
298
296
  syncBalance(args: SyncBalanceArgs, headers?: object): Promise<SyncBalanceReturn>
299
297
  fetchTransactionReceipt(args: FetchTransactionReceiptArgs, headers?: object): Promise<FetchTransactionReceiptReturn>
300
- fetchTransactionReceiptWithFilter(args: FetchTransactionReceiptWithFilterArgs, headers?: object): Promise<FetchTransactionReceiptWithFilterReturn>
298
+ fetchTransactionReceiptWithFilter(
299
+ args: FetchTransactionReceiptWithFilterArgs,
300
+ headers?: object
301
+ ): Promise<FetchTransactionReceiptWithFilterReturn>
301
302
  }
302
303
 
303
- export interface PingArgs {
304
- }
304
+ export interface PingArgs {}
305
305
 
306
306
  export interface PingReturn {
307
- status: boolean
308
- }
309
- export interface VersionArgs {
307
+ status: boolean
310
308
  }
309
+ export interface VersionArgs {}
311
310
 
312
311
  export interface VersionReturn {
313
- version: Version
314
- }
315
- export interface RuntimeStatusArgs {
312
+ version: Version
316
313
  }
314
+ export interface RuntimeStatusArgs {}
317
315
 
318
316
  export interface RuntimeStatusReturn {
319
- status: RuntimeStatus
320
- }
321
- export interface GetChainIDArgs {
317
+ status: RuntimeStatus
322
318
  }
319
+ export interface GetChainIDArgs {}
323
320
 
324
321
  export interface GetChainIDReturn {
325
- chainID: number
322
+ chainID: number
326
323
  }
327
324
  export interface GetEtherBalanceArgs {
328
325
  accountAddress?: string
329
326
  }
330
327
 
331
328
  export interface GetEtherBalanceReturn {
332
- balance: EtherBalance
329
+ balance: EtherBalance
333
330
  }
334
331
  export interface GetTokenBalancesArgs {
335
332
  accountAddress?: string
@@ -341,7 +338,7 @@ export interface GetTokenBalancesArgs {
341
338
 
342
339
  export interface GetTokenBalancesReturn {
343
340
  page: Page
344
- balances: Array<TokenBalance>
341
+ balances: Array<TokenBalance>
345
342
  }
346
343
  export interface GetTokenSuppliesArgs {
347
344
  contractAddress: string
@@ -352,15 +349,15 @@ export interface GetTokenSuppliesArgs {
352
349
  export interface GetTokenSuppliesReturn {
353
350
  page: Page
354
351
  contractType: ContractType
355
- tokenIDs: Array<TokenSupply>
352
+ tokenIDs: Array<TokenSupply>
356
353
  }
357
354
  export interface GetTokenSuppliesMapArgs {
358
- tokenMap: {[key: string]: Array<string>}
355
+ tokenMap: { [key: string]: Array<string> }
359
356
  includeMetadata?: boolean
360
357
  }
361
358
 
362
359
  export interface GetTokenSuppliesMapReturn {
363
- supplies: {[key: string]: Array<TokenSupply>}
360
+ supplies: { [key: string]: Array<TokenSupply> }
364
361
  }
365
362
  export interface GetBalanceUpdatesArgs {
366
363
  contractAddress: string
@@ -371,7 +368,7 @@ export interface GetBalanceUpdatesArgs {
371
368
 
372
369
  export interface GetBalanceUpdatesReturn {
373
370
  page: Page
374
- balances: Array<TokenBalance>
371
+ balances: Array<TokenBalance>
375
372
  }
376
373
  export interface GetTransactionHistoryArgs {
377
374
  filter: TransactionHistoryFilter
@@ -381,7 +378,7 @@ export interface GetTransactionHistoryArgs {
381
378
 
382
379
  export interface GetTransactionHistoryReturn {
383
380
  page: Page
384
- transactions: Array<Transaction>
381
+ transactions: Array<Transaction>
385
382
  }
386
383
  export interface SyncBalanceArgs {
387
384
  accountAddress: string
@@ -389,15 +386,14 @@ export interface SyncBalanceArgs {
389
386
  tokenID?: string
390
387
  }
391
388
 
392
- export interface SyncBalanceReturn {
393
- }
389
+ export interface SyncBalanceReturn {}
394
390
  export interface FetchTransactionReceiptArgs {
395
391
  txnHash: string
396
392
  maxBlockWait?: number
397
393
  }
398
394
 
399
395
  export interface FetchTransactionReceiptReturn {
400
- receipt: TransactionReceipt
396
+ receipt: TransactionReceipt
401
397
  }
402
398
  export interface FetchTransactionReceiptWithFilterArgs {
403
399
  filter: Filter
@@ -405,11 +401,9 @@ export interface FetchTransactionReceiptWithFilterArgs {
405
401
  }
406
402
 
407
403
  export interface FetchTransactionReceiptWithFilterReturn {
408
- receipt: TransactionReceipt
404
+ receipt: TransactionReceipt
409
405
  }
410
406
 
411
-
412
-
413
407
  //
414
408
  // Client
415
409
  //
@@ -426,178 +420,148 @@ export class Indexer implements Indexer {
426
420
  private url(name: string): string {
427
421
  return this.hostname + this.path + name
428
422
  }
429
-
423
+
430
424
  ping = (headers?: object): Promise<PingReturn> => {
431
- return this.fetch(
432
- this.url('Ping'),
433
- createHTTPRequest({}, headers)
434
- ).then((res) => {
425
+ return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
435
426
  return buildResponse(res).then(_data => {
436
427
  return {
437
- status: <boolean>(_data.status)
428
+ status: <boolean>_data.status
438
429
  }
439
430
  })
440
431
  })
441
432
  }
442
-
433
+
443
434
  version = (headers?: object): Promise<VersionReturn> => {
444
- return this.fetch(
445
- this.url('Version'),
446
- createHTTPRequest({}, headers)
447
- ).then((res) => {
435
+ return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
448
436
  return buildResponse(res).then(_data => {
449
437
  return {
450
- version: <Version>(_data.version)
438
+ version: <Version>_data.version
451
439
  }
452
440
  })
453
441
  })
454
442
  }
455
-
443
+
456
444
  runtimeStatus = (headers?: object): Promise<RuntimeStatusReturn> => {
457
- return this.fetch(
458
- this.url('RuntimeStatus'),
459
- createHTTPRequest({}, headers)
460
- ).then((res) => {
445
+ return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
461
446
  return buildResponse(res).then(_data => {
462
447
  return {
463
- status: <RuntimeStatus>(_data.status)
448
+ status: <RuntimeStatus>_data.status
464
449
  }
465
450
  })
466
451
  })
467
452
  }
468
-
453
+
469
454
  getChainID = (headers?: object): Promise<GetChainIDReturn> => {
470
- return this.fetch(
471
- this.url('GetChainID'),
472
- createHTTPRequest({}, headers)
473
- ).then((res) => {
455
+ return this.fetch(this.url('GetChainID'), createHTTPRequest({}, headers)).then(res => {
474
456
  return buildResponse(res).then(_data => {
475
457
  return {
476
- chainID: <number>(_data.chainID)
458
+ chainID: <number>_data.chainID
477
459
  }
478
460
  })
479
461
  })
480
462
  }
481
-
463
+
482
464
  getEtherBalance = (args: GetEtherBalanceArgs, headers?: object): Promise<GetEtherBalanceReturn> => {
483
- return this.fetch(
484
- this.url('GetEtherBalance'),
485
- createHTTPRequest(args, headers)).then((res) => {
465
+ return this.fetch(this.url('GetEtherBalance'), createHTTPRequest(args, headers)).then(res => {
486
466
  return buildResponse(res).then(_data => {
487
467
  return {
488
- balance: <EtherBalance>(_data.balance)
468
+ balance: <EtherBalance>_data.balance
489
469
  }
490
470
  })
491
471
  })
492
472
  }
493
-
473
+
494
474
  getTokenBalances = (args: GetTokenBalancesArgs, headers?: object): Promise<GetTokenBalancesReturn> => {
495
- return this.fetch(
496
- this.url('GetTokenBalances'),
497
- createHTTPRequest(args, headers)).then((res) => {
475
+ return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers)).then(res => {
498
476
  return buildResponse(res).then(_data => {
499
477
  return {
500
- page: <Page>(_data.page),
501
- balances: <Array<TokenBalance>>(_data.balances)
478
+ page: <Page>_data.page,
479
+ balances: <Array<TokenBalance>>_data.balances
502
480
  }
503
481
  })
504
482
  })
505
483
  }
506
-
484
+
507
485
  getTokenSupplies = (args: GetTokenSuppliesArgs, headers?: object): Promise<GetTokenSuppliesReturn> => {
508
- return this.fetch(
509
- this.url('GetTokenSupplies'),
510
- createHTTPRequest(args, headers)).then((res) => {
486
+ return this.fetch(this.url('GetTokenSupplies'), createHTTPRequest(args, headers)).then(res => {
511
487
  return buildResponse(res).then(_data => {
512
488
  return {
513
- page: <Page>(_data.page),
514
- contractType: <ContractType>(_data.contractType),
515
- tokenIDs: <Array<TokenSupply>>(_data.tokenIDs)
489
+ page: <Page>_data.page,
490
+ contractType: <ContractType>_data.contractType,
491
+ tokenIDs: <Array<TokenSupply>>_data.tokenIDs
516
492
  }
517
493
  })
518
494
  })
519
495
  }
520
-
496
+
521
497
  getTokenSuppliesMap = (args: GetTokenSuppliesMapArgs, headers?: object): Promise<GetTokenSuppliesMapReturn> => {
522
- return this.fetch(
523
- this.url('GetTokenSuppliesMap'),
524
- createHTTPRequest(args, headers)).then((res) => {
498
+ return this.fetch(this.url('GetTokenSuppliesMap'), createHTTPRequest(args, headers)).then(res => {
525
499
  return buildResponse(res).then(_data => {
526
500
  return {
527
- supplies: <{[key: string]: Array<TokenSupply>}>(_data.supplies)
501
+ supplies: <{ [key: string]: Array<TokenSupply> }>_data.supplies
528
502
  }
529
503
  })
530
504
  })
531
505
  }
532
-
506
+
533
507
  getBalanceUpdates = (args: GetBalanceUpdatesArgs, headers?: object): Promise<GetBalanceUpdatesReturn> => {
534
- return this.fetch(
535
- this.url('GetBalanceUpdates'),
536
- createHTTPRequest(args, headers)).then((res) => {
508
+ return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest(args, headers)).then(res => {
537
509
  return buildResponse(res).then(_data => {
538
510
  return {
539
- page: <Page>(_data.page),
540
- balances: <Array<TokenBalance>>(_data.balances)
511
+ page: <Page>_data.page,
512
+ balances: <Array<TokenBalance>>_data.balances
541
513
  }
542
514
  })
543
515
  })
544
516
  }
545
-
517
+
546
518
  getTransactionHistory = (args: GetTransactionHistoryArgs, headers?: object): Promise<GetTransactionHistoryReturn> => {
547
- return this.fetch(
548
- this.url('GetTransactionHistory'),
549
- createHTTPRequest(args, headers)).then((res) => {
519
+ return this.fetch(this.url('GetTransactionHistory'), createHTTPRequest(args, headers)).then(res => {
550
520
  return buildResponse(res).then(_data => {
551
521
  return {
552
- page: <Page>(_data.page),
553
- transactions: <Array<Transaction>>(_data.transactions)
522
+ page: <Page>_data.page,
523
+ transactions: <Array<Transaction>>_data.transactions
554
524
  }
555
525
  })
556
526
  })
557
527
  }
558
-
528
+
559
529
  syncBalance = (args: SyncBalanceArgs, headers?: object): Promise<SyncBalanceReturn> => {
560
- return this.fetch(
561
- this.url('SyncBalance'),
562
- createHTTPRequest(args, headers)).then((res) => {
530
+ return this.fetch(this.url('SyncBalance'), createHTTPRequest(args, headers)).then(res => {
563
531
  return buildResponse(res).then(_data => {
564
- return {
565
- }
532
+ return {}
566
533
  })
567
534
  })
568
535
  }
569
-
536
+
570
537
  fetchTransactionReceipt = (args: FetchTransactionReceiptArgs, headers?: object): Promise<FetchTransactionReceiptReturn> => {
571
- return this.fetch(
572
- this.url('FetchTransactionReceipt'),
573
- createHTTPRequest(args, headers)).then((res) => {
538
+ return this.fetch(this.url('FetchTransactionReceipt'), createHTTPRequest(args, headers)).then(res => {
574
539
  return buildResponse(res).then(_data => {
575
540
  return {
576
- receipt: <TransactionReceipt>(_data.receipt)
541
+ receipt: <TransactionReceipt>_data.receipt
577
542
  }
578
543
  })
579
544
  })
580
545
  }
581
-
582
- fetchTransactionReceiptWithFilter = (args: FetchTransactionReceiptWithFilterArgs, headers?: object): Promise<FetchTransactionReceiptWithFilterReturn> => {
583
- return this.fetch(
584
- this.url('FetchTransactionReceiptWithFilter'),
585
- createHTTPRequest(args, headers)).then((res) => {
546
+
547
+ fetchTransactionReceiptWithFilter = (
548
+ args: FetchTransactionReceiptWithFilterArgs,
549
+ headers?: object
550
+ ): Promise<FetchTransactionReceiptWithFilterReturn> => {
551
+ return this.fetch(this.url('FetchTransactionReceiptWithFilter'), createHTTPRequest(args, headers)).then(res => {
586
552
  return buildResponse(res).then(_data => {
587
553
  return {
588
- receipt: <TransactionReceipt>(_data.receipt)
554
+ receipt: <TransactionReceipt>_data.receipt
589
555
  }
590
556
  })
591
557
  })
592
558
  }
593
-
594
559
  }
595
560
 
596
-
597
561
  export interface WebRPCError extends Error {
598
562
  code: string
599
563
  msg: string
600
- status: number
564
+ status: number
601
565
  }
602
566
 
603
567
  const createHTTPRequest = (body: object = {}, headers: object = {}): object => {
@@ -613,7 +577,7 @@ const buildResponse = (res: Response): Promise<any> => {
613
577
  let data
614
578
  try {
615
579
  data = JSON.parse(text)
616
- } catch(err) {
580
+ } catch (err) {
617
581
  throw { code: 'unknown', msg: `expecting JSON, got: ${text}`, status: res.status } as WebRPCError
618
582
  }
619
583
  if (!res.ok) {