@0xsequence/indexer 2.3.35 → 3.0.0-beta.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.
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable */
2
- // sequence-indexer v0.4.0 f9220b18008af826218980db21a68ec39989fb80
2
+ // sequence-indexer v0.4.0 546b527de7002f409ffa602ad35b5a3abe979088
3
3
  // --
4
4
  // Code generated by webrpc-gen@v0.21.1 with typescript generator. DO NOT EDIT.
5
5
  //
@@ -16,7 +16,7 @@ export const WebRPCVersion = 'v1'
16
16
  export const WebRPCSchemaVersion = 'v0.4.0'
17
17
 
18
18
  // Schema hash generated from your RIDL schema
19
- export const WebRPCSchemaHash = 'f9220b18008af826218980db21a68ec39989fb80'
19
+ export const WebRPCSchemaHash = '546b527de7002f409ffa602ad35b5a3abe979088'
20
20
 
21
21
  type WebrpcGenVersions = {
22
22
  webrpcGenVersion: string
@@ -34,7 +34,7 @@ export function VersionFromHeader(headers: Headers): WebrpcGenVersions {
34
34
  codeGenName: '',
35
35
  codeGenVersion: '',
36
36
  schemaName: '',
37
- schemaVersion: ''
37
+ schemaVersion: '',
38
38
  }
39
39
  }
40
40
 
@@ -49,20 +49,20 @@ function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
49
49
  codeGenName: '',
50
50
  codeGenVersion: '',
51
51
  schemaName: '',
52
- schemaVersion: ''
52
+ schemaVersion: '',
53
53
  }
54
54
  }
55
55
 
56
- const [_, webrpcGenVersion] = versions[0].split('@')
57
- const [codeGenName, codeGenVersion] = versions[1].split('@')
58
- const [schemaName, schemaVersion] = versions[2].split('@')
56
+ const [_, webrpcGenVersion] = versions[0]!.split('@')
57
+ const [codeGenName, codeGenVersion] = versions[1]!.split('@')
58
+ const [schemaName, schemaVersion] = versions[2]!.split('@')
59
59
 
60
60
  return {
61
- webrpcGenVersion,
62
- codeGenName,
63
- codeGenVersion,
64
- schemaName,
65
- schemaVersion
61
+ webrpcGenVersion: webrpcGenVersion!,
62
+ codeGenName: codeGenName!,
63
+ codeGenVersion: codeGenVersion!,
64
+ schemaName: schemaName!,
65
+ schemaVersion: schemaVersion!,
66
66
  }
67
67
  }
68
68
 
@@ -73,7 +73,7 @@ function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
73
73
  export enum ResourceStatus {
74
74
  NOT_AVAILABLE = 'NOT_AVAILABLE',
75
75
  REFRESHING = 'REFRESHING',
76
- AVAILABLE = 'AVAILABLE'
76
+ AVAILABLE = 'AVAILABLE',
77
77
  }
78
78
 
79
79
  export interface ContractInfo {
@@ -155,60 +155,54 @@ export enum ContractType {
155
155
  ERC20_BRIDGE = 'ERC20_BRIDGE',
156
156
  ERC721_BRIDGE = 'ERC721_BRIDGE',
157
157
  ERC1155_BRIDGE = 'ERC1155_BRIDGE',
158
- SEQ_MARKETPLACE = 'SEQ_MARKETPLACE'
158
+ SEQ_MARKETPLACE = 'SEQ_MARKETPLACE',
159
159
  }
160
160
 
161
161
  export enum EventLogType {
162
162
  UNKNOWN = 'UNKNOWN',
163
163
  BLOCK_ADDED = 'BLOCK_ADDED',
164
- BLOCK_REMOVED = 'BLOCK_REMOVED'
164
+ BLOCK_REMOVED = 'BLOCK_REMOVED',
165
165
  }
166
166
 
167
167
  export enum EventLogDataType {
168
168
  EVENT = 'EVENT',
169
169
  TOKEN_TRANSFER = 'TOKEN_TRANSFER',
170
170
  NATIVE_TOKEN_TRANSFER = 'NATIVE_TOKEN_TRANSFER',
171
- SEQUENCE_TXN = 'SEQUENCE_TXN'
171
+ SEQUENCE_TXN = 'SEQUENCE_TXN',
172
172
  }
173
173
 
174
174
  export enum OrderStatus {
175
175
  OPEN = 'OPEN',
176
176
  CLOSED = 'CLOSED',
177
- CANCELLED = 'CANCELLED'
177
+ CANCELLED = 'CANCELLED',
178
178
  }
179
179
 
180
180
  export enum TxnTransferType {
181
181
  UNKNOWN = 'UNKNOWN',
182
182
  SEND = 'SEND',
183
- RECEIVE = 'RECEIVE'
183
+ RECEIVE = 'RECEIVE',
184
184
  }
185
185
 
186
186
  export enum TransactionStatus {
187
187
  FAILED = 'FAILED',
188
- SUCCESSFUL = 'SUCCESSFUL'
188
+ SUCCESSFUL = 'SUCCESSFUL',
189
189
  }
190
190
 
191
191
  export enum TransactionType {
192
192
  LegacyTxnType = 'LegacyTxnType',
193
193
  AccessListTxnType = 'AccessListTxnType',
194
- DynamicFeeTxnType = 'DynamicFeeTxnType'
194
+ DynamicFeeTxnType = 'DynamicFeeTxnType',
195
195
  }
196
196
 
197
197
  export enum SortOrder {
198
198
  DESC = 'DESC',
199
- ASC = 'ASC'
199
+ ASC = 'ASC',
200
200
  }
201
201
 
202
202
  export enum ContractVerificationStatus {
203
203
  VERIFIED = 'VERIFIED',
204
204
  UNVERIFIED = 'UNVERIFIED',
205
- ALL = 'ALL'
206
- }
207
-
208
- export enum NetworkType {
209
- MAINNETS = 'MAINNETS',
210
- TESTNETS = 'TESTNETS',
211
- ALL = 'ALL'
205
+ ALL = 'ALL',
212
206
  }
213
207
 
214
208
  export interface Version {
@@ -313,7 +307,7 @@ export interface NativeTokenBalance {
313
307
  accountAddress: string
314
308
  chainId: number
315
309
  balance: string
316
- errorReason?: string
310
+ error: string
317
311
  }
318
312
 
319
313
  export interface IndexState {
@@ -560,33 +554,28 @@ export interface TokenBalancesByContractFilter {
560
554
 
561
555
  export interface GatewayEtherBalance {
562
556
  chainId: number
563
- errorReason?: string
557
+ error: string
564
558
  result: EtherBalance
565
559
  }
566
560
 
567
561
  export interface GatewayNativeTokenBalance {
568
562
  chainId: number
569
- errorReason?: string
563
+ error: string
570
564
  result: NativeTokenBalance
571
565
  }
572
566
 
573
567
  export interface GatewayNativeTokenBalances {
574
568
  chainId: number
575
- errorReason?: string
569
+ error: string
576
570
  results: Array<NativeTokenBalance>
577
571
  }
578
572
 
579
573
  export interface GatewayTokenBalance {
580
574
  chainId: number
581
- errorReason?: string
575
+ error: string
582
576
  results: Array<TokenBalance>
583
577
  }
584
578
 
585
- export interface ChainInfo {
586
- chainId: number
587
- chainName: string
588
- }
589
-
590
579
  export interface Indexer {
591
580
  ping(headers?: object, signal?: AbortSignal): Promise<PingReturn>
592
581
  version(headers?: object, signal?: AbortSignal): Promise<VersionReturn>
@@ -596,89 +585,109 @@ export interface Indexer {
596
585
  getNativeTokenBalance(
597
586
  args: GetNativeTokenBalanceArgs,
598
587
  headers?: object,
599
- signal?: AbortSignal
588
+ signal?: AbortSignal,
600
589
  ): Promise<GetNativeTokenBalanceReturn>
601
590
  getTokenBalancesSummary(
602
591
  args: GetTokenBalancesSummaryArgs,
603
592
  headers?: object,
604
- signal?: AbortSignal
593
+ signal?: AbortSignal,
605
594
  ): Promise<GetTokenBalancesSummaryReturn>
606
595
  getTokenBalancesDetails(
607
596
  args: GetTokenBalancesDetailsArgs,
608
597
  headers?: object,
609
- signal?: AbortSignal
598
+ signal?: AbortSignal,
610
599
  ): Promise<GetTokenBalancesDetailsReturn>
611
600
  getTokenBalancesByContract(
612
601
  args: GetTokenBalancesByContractArgs,
613
602
  headers?: object,
614
- signal?: AbortSignal
603
+ signal?: AbortSignal,
615
604
  ): Promise<GetTokenBalancesByContractReturn>
616
605
  getTokenBalances(args: GetTokenBalancesArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenBalancesReturn>
617
606
  getTokenSupplies(args: GetTokenSuppliesArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenSuppliesReturn>
618
- getTokenSuppliesMap(args: GetTokenSuppliesMapArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenSuppliesMapReturn>
607
+ getTokenSuppliesMap(
608
+ args: GetTokenSuppliesMapArgs,
609
+ headers?: object,
610
+ signal?: AbortSignal,
611
+ ): Promise<GetTokenSuppliesMapReturn>
619
612
  getTokenIDs(args: GetTokenIDsArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenIDsReturn>
620
613
  getTokenIDRanges(args: GetTokenIDRangesArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenIDRangesReturn>
621
- getBalanceUpdates(args: GetBalanceUpdatesArgs, headers?: object, signal?: AbortSignal): Promise<GetBalanceUpdatesReturn>
614
+ getBalanceUpdates(
615
+ args: GetBalanceUpdatesArgs,
616
+ headers?: object,
617
+ signal?: AbortSignal,
618
+ ): Promise<GetBalanceUpdatesReturn>
622
619
  getTransactionHistory(
623
620
  args: GetTransactionHistoryArgs,
624
621
  headers?: object,
625
- signal?: AbortSignal
622
+ signal?: AbortSignal,
626
623
  ): Promise<GetTransactionHistoryReturn>
627
624
  fetchTransactionReceipt(
628
625
  args: FetchTransactionReceiptArgs,
629
626
  headers?: object,
630
- signal?: AbortSignal
627
+ signal?: AbortSignal,
631
628
  ): Promise<FetchTransactionReceiptReturn>
632
629
  fetchTransactionReceiptWithFilter(
633
630
  args: FetchTransactionReceiptWithFilterArgs,
634
631
  headers?: object,
635
- signal?: AbortSignal
632
+ signal?: AbortSignal,
636
633
  ): Promise<FetchTransactionReceiptWithFilterReturn>
637
634
  subscribeReceipts(args: SubscribeReceiptsArgs, options: WebrpcStreamOptions<SubscribeReceiptsReturn>): Promise<void>
638
635
  subscribeEvents(args: SubscribeEventsArgs, options: WebrpcStreamOptions<SubscribeEventsReturn>): Promise<void>
639
636
  subscribeBalanceUpdates(
640
637
  args: SubscribeBalanceUpdatesArgs,
641
- options: WebrpcStreamOptions<SubscribeBalanceUpdatesReturn>
638
+ options: WebrpcStreamOptions<SubscribeBalanceUpdatesReturn>,
642
639
  ): Promise<void>
643
640
  syncBalance(args: SyncBalanceArgs, headers?: object, signal?: AbortSignal): Promise<SyncBalanceReturn>
644
641
  getAllWebhookListeners(
645
642
  args: GetAllWebhookListenersArgs,
646
643
  headers?: object,
647
- signal?: AbortSignal
644
+ signal?: AbortSignal,
648
645
  ): Promise<GetAllWebhookListenersReturn>
649
- getWebhookListener(args: GetWebhookListenerArgs, headers?: object, signal?: AbortSignal): Promise<GetWebhookListenerReturn>
650
- addWebhookListener(args: AddWebhookListenerArgs, headers?: object, signal?: AbortSignal): Promise<AddWebhookListenerReturn>
646
+ getWebhookListener(
647
+ args: GetWebhookListenerArgs,
648
+ headers?: object,
649
+ signal?: AbortSignal,
650
+ ): Promise<GetWebhookListenerReturn>
651
+ addWebhookListener(
652
+ args: AddWebhookListenerArgs,
653
+ headers?: object,
654
+ signal?: AbortSignal,
655
+ ): Promise<AddWebhookListenerReturn>
651
656
  updateWebhookListener(
652
657
  args: UpdateWebhookListenerArgs,
653
658
  headers?: object,
654
- signal?: AbortSignal
659
+ signal?: AbortSignal,
655
660
  ): Promise<UpdateWebhookListenerReturn>
656
661
  removeWebhookListener(
657
662
  args: RemoveWebhookListenerArgs,
658
663
  headers?: object,
659
- signal?: AbortSignal
664
+ signal?: AbortSignal,
660
665
  ): Promise<RemoveWebhookListenerReturn>
661
666
  removeAllWebhookListeners(
662
667
  args: RemoveAllWebhookListenersArgs,
663
668
  headers?: object,
664
- signal?: AbortSignal
669
+ signal?: AbortSignal,
665
670
  ): Promise<RemoveAllWebhookListenersReturn>
666
671
  toggleWebhookListener(
667
672
  args: ToggleWebhookListenerArgs,
668
673
  headers?: object,
669
- signal?: AbortSignal
674
+ signal?: AbortSignal,
670
675
  ): Promise<ToggleWebhookListenerReturn>
671
676
  pauseAllWebhookListeners(
672
677
  args: PauseAllWebhookListenersArgs,
673
678
  headers?: object,
674
- signal?: AbortSignal
679
+ signal?: AbortSignal,
675
680
  ): Promise<PauseAllWebhookListenersReturn>
676
681
  resumeAllWebhookListeners(
677
682
  args: ResumeAllWebhookListenersArgs,
678
683
  headers?: object,
679
- signal?: AbortSignal
684
+ signal?: AbortSignal,
680
685
  ): Promise<ResumeAllWebhookListenersReturn>
681
- getOrderbookOrders(args: GetOrderbookOrdersArgs, headers?: object, signal?: AbortSignal): Promise<GetOrderbookOrdersReturn>
686
+ getOrderbookOrders(
687
+ args: GetOrderbookOrdersArgs,
688
+ headers?: object,
689
+ signal?: AbortSignal,
690
+ ): Promise<GetOrderbookOrdersReturn>
682
691
  getTopOrders(args: GetTopOrdersArgs, headers?: object, signal?: AbortSignal): Promise<GetTopOrdersReturn>
683
692
  }
684
693
 
@@ -988,576 +997,599 @@ export class Indexer implements Indexer {
988
997
 
989
998
  ping = (headers?: object, signal?: AbortSignal): Promise<PingReturn> => {
990
999
  return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then(
991
- res => {
992
- return buildResponse(res).then(_data => {
1000
+ (res) => {
1001
+ return buildResponse(res).then((_data) => {
993
1002
  return {
994
- status: <boolean>_data.status
1003
+ status: <boolean>_data.status,
995
1004
  }
996
1005
  })
997
1006
  },
998
- error => {
1007
+ (error) => {
999
1008
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1000
- }
1009
+ },
1001
1010
  )
1002
1011
  }
1003
1012
 
1004
1013
  version = (headers?: object, signal?: AbortSignal): Promise<VersionReturn> => {
1005
1014
  return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then(
1006
- res => {
1007
- return buildResponse(res).then(_data => {
1015
+ (res) => {
1016
+ return buildResponse(res).then((_data) => {
1008
1017
  return {
1009
- version: <Version>_data.version
1018
+ version: <Version>_data.version,
1010
1019
  }
1011
1020
  })
1012
1021
  },
1013
- error => {
1022
+ (error) => {
1014
1023
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1015
- }
1024
+ },
1016
1025
  )
1017
1026
  }
1018
1027
 
1019
1028
  runtimeStatus = (headers?: object, signal?: AbortSignal): Promise<RuntimeStatusReturn> => {
1020
1029
  return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then(
1021
- res => {
1022
- return buildResponse(res).then(_data => {
1030
+ (res) => {
1031
+ return buildResponse(res).then((_data) => {
1023
1032
  return {
1024
- status: <RuntimeStatus>_data.status
1033
+ status: <RuntimeStatus>_data.status,
1025
1034
  }
1026
1035
  })
1027
1036
  },
1028
- error => {
1037
+ (error) => {
1029
1038
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1030
- }
1039
+ },
1031
1040
  )
1032
1041
  }
1033
1042
 
1034
1043
  getChainID = (headers?: object, signal?: AbortSignal): Promise<GetChainIDReturn> => {
1035
1044
  return this.fetch(this.url('GetChainID'), createHTTPRequest({}, headers, signal)).then(
1036
- res => {
1037
- return buildResponse(res).then(_data => {
1045
+ (res) => {
1046
+ return buildResponse(res).then((_data) => {
1038
1047
  return {
1039
- chainID: <number>_data.chainID
1048
+ chainID: <number>_data.chainID,
1040
1049
  }
1041
1050
  })
1042
1051
  },
1043
- error => {
1052
+ (error) => {
1044
1053
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1045
- }
1054
+ },
1046
1055
  )
1047
1056
  }
1048
1057
 
1049
- getEtherBalance = (args: GetEtherBalanceArgs, headers?: object, signal?: AbortSignal): Promise<GetEtherBalanceReturn> => {
1058
+ getEtherBalance = (
1059
+ args: GetEtherBalanceArgs,
1060
+ headers?: object,
1061
+ signal?: AbortSignal,
1062
+ ): Promise<GetEtherBalanceReturn> => {
1050
1063
  return this.fetch(this.url('GetEtherBalance'), createHTTPRequest(args, headers, signal)).then(
1051
- res => {
1052
- return buildResponse(res).then(_data => {
1064
+ (res) => {
1065
+ return buildResponse(res).then((_data) => {
1053
1066
  return {
1054
- balance: <EtherBalance>_data.balance
1067
+ balance: <EtherBalance>_data.balance,
1055
1068
  }
1056
1069
  })
1057
1070
  },
1058
- error => {
1071
+ (error) => {
1059
1072
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1060
- }
1073
+ },
1061
1074
  )
1062
1075
  }
1063
1076
 
1064
1077
  getNativeTokenBalance = (
1065
1078
  args: GetNativeTokenBalanceArgs,
1066
1079
  headers?: object,
1067
- signal?: AbortSignal
1080
+ signal?: AbortSignal,
1068
1081
  ): Promise<GetNativeTokenBalanceReturn> => {
1069
1082
  return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest(args, headers, signal)).then(
1070
- res => {
1071
- return buildResponse(res).then(_data => {
1083
+ (res) => {
1084
+ return buildResponse(res).then((_data) => {
1072
1085
  return {
1073
- balance: <NativeTokenBalance>_data.balance
1086
+ balance: <NativeTokenBalance>_data.balance,
1074
1087
  }
1075
1088
  })
1076
1089
  },
1077
- error => {
1090
+ (error) => {
1078
1091
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1079
- }
1092
+ },
1080
1093
  )
1081
1094
  }
1082
1095
 
1083
1096
  getTokenBalancesSummary = (
1084
1097
  args: GetTokenBalancesSummaryArgs,
1085
1098
  headers?: object,
1086
- signal?: AbortSignal
1099
+ signal?: AbortSignal,
1087
1100
  ): Promise<GetTokenBalancesSummaryReturn> => {
1088
1101
  return this.fetch(this.url('GetTokenBalancesSummary'), createHTTPRequest(args, headers, signal)).then(
1089
- res => {
1090
- return buildResponse(res).then(_data => {
1102
+ (res) => {
1103
+ return buildResponse(res).then((_data) => {
1091
1104
  return {
1092
1105
  page: <Page>_data.page,
1093
1106
  nativeBalances: <Array<NativeTokenBalance>>_data.nativeBalances,
1094
- balances: <Array<TokenBalance>>_data.balances
1107
+ balances: <Array<TokenBalance>>_data.balances,
1095
1108
  }
1096
1109
  })
1097
1110
  },
1098
- error => {
1111
+ (error) => {
1099
1112
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1100
- }
1113
+ },
1101
1114
  )
1102
1115
  }
1103
1116
 
1104
1117
  getTokenBalancesDetails = (
1105
1118
  args: GetTokenBalancesDetailsArgs,
1106
1119
  headers?: object,
1107
- signal?: AbortSignal
1120
+ signal?: AbortSignal,
1108
1121
  ): Promise<GetTokenBalancesDetailsReturn> => {
1109
1122
  return this.fetch(this.url('GetTokenBalancesDetails'), createHTTPRequest(args, headers, signal)).then(
1110
- res => {
1111
- return buildResponse(res).then(_data => {
1123
+ (res) => {
1124
+ return buildResponse(res).then((_data) => {
1112
1125
  return {
1113
1126
  page: <Page>_data.page,
1114
1127
  nativeBalances: <Array<NativeTokenBalance>>_data.nativeBalances,
1115
- balances: <Array<TokenBalance>>_data.balances
1128
+ balances: <Array<TokenBalance>>_data.balances,
1116
1129
  }
1117
1130
  })
1118
1131
  },
1119
- error => {
1132
+ (error) => {
1120
1133
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1121
- }
1134
+ },
1122
1135
  )
1123
1136
  }
1124
1137
 
1125
1138
  getTokenBalancesByContract = (
1126
1139
  args: GetTokenBalancesByContractArgs,
1127
1140
  headers?: object,
1128
- signal?: AbortSignal
1141
+ signal?: AbortSignal,
1129
1142
  ): Promise<GetTokenBalancesByContractReturn> => {
1130
1143
  return this.fetch(this.url('GetTokenBalancesByContract'), createHTTPRequest(args, headers, signal)).then(
1131
- res => {
1132
- return buildResponse(res).then(_data => {
1144
+ (res) => {
1145
+ return buildResponse(res).then((_data) => {
1133
1146
  return {
1134
1147
  page: <Page>_data.page,
1135
- balances: <Array<TokenBalance>>_data.balances
1148
+ balances: <Array<TokenBalance>>_data.balances,
1136
1149
  }
1137
1150
  })
1138
1151
  },
1139
- error => {
1152
+ (error) => {
1140
1153
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1141
- }
1154
+ },
1142
1155
  )
1143
1156
  }
1144
1157
 
1145
- getTokenBalances = (args: GetTokenBalancesArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenBalancesReturn> => {
1158
+ getTokenBalances = (
1159
+ args: GetTokenBalancesArgs,
1160
+ headers?: object,
1161
+ signal?: AbortSignal,
1162
+ ): Promise<GetTokenBalancesReturn> => {
1146
1163
  return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers, signal)).then(
1147
- res => {
1148
- return buildResponse(res).then(_data => {
1164
+ (res) => {
1165
+ return buildResponse(res).then((_data) => {
1149
1166
  return {
1150
1167
  page: <Page>_data.page,
1151
- balances: <Array<TokenBalance>>_data.balances
1168
+ balances: <Array<TokenBalance>>_data.balances,
1152
1169
  }
1153
1170
  })
1154
1171
  },
1155
- error => {
1172
+ (error) => {
1156
1173
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1157
- }
1174
+ },
1158
1175
  )
1159
1176
  }
1160
1177
 
1161
- getTokenSupplies = (args: GetTokenSuppliesArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenSuppliesReturn> => {
1178
+ getTokenSupplies = (
1179
+ args: GetTokenSuppliesArgs,
1180
+ headers?: object,
1181
+ signal?: AbortSignal,
1182
+ ): Promise<GetTokenSuppliesReturn> => {
1162
1183
  return this.fetch(this.url('GetTokenSupplies'), createHTTPRequest(args, headers, signal)).then(
1163
- res => {
1164
- return buildResponse(res).then(_data => {
1184
+ (res) => {
1185
+ return buildResponse(res).then((_data) => {
1165
1186
  return {
1166
1187
  page: <Page>_data.page,
1167
1188
  contractType: <ContractType>_data.contractType,
1168
- tokenIDs: <Array<TokenSupply>>_data.tokenIDs
1189
+ tokenIDs: <Array<TokenSupply>>_data.tokenIDs,
1169
1190
  }
1170
1191
  })
1171
1192
  },
1172
- error => {
1193
+ (error) => {
1173
1194
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1174
- }
1195
+ },
1175
1196
  )
1176
1197
  }
1177
1198
 
1178
1199
  getTokenSuppliesMap = (
1179
1200
  args: GetTokenSuppliesMapArgs,
1180
1201
  headers?: object,
1181
- signal?: AbortSignal
1202
+ signal?: AbortSignal,
1182
1203
  ): Promise<GetTokenSuppliesMapReturn> => {
1183
1204
  return this.fetch(this.url('GetTokenSuppliesMap'), createHTTPRequest(args, headers, signal)).then(
1184
- res => {
1185
- return buildResponse(res).then(_data => {
1205
+ (res) => {
1206
+ return buildResponse(res).then((_data) => {
1186
1207
  return {
1187
- supplies: <{ [key: string]: Array<TokenSupply> }>_data.supplies
1208
+ supplies: <{ [key: string]: Array<TokenSupply> }>_data.supplies,
1188
1209
  }
1189
1210
  })
1190
1211
  },
1191
- error => {
1212
+ (error) => {
1192
1213
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1193
- }
1214
+ },
1194
1215
  )
1195
1216
  }
1196
1217
 
1197
1218
  getTokenIDs = (args: GetTokenIDsArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenIDsReturn> => {
1198
1219
  return this.fetch(this.url('GetTokenIDs'), createHTTPRequest(args, headers, signal)).then(
1199
- res => {
1200
- return buildResponse(res).then(_data => {
1220
+ (res) => {
1221
+ return buildResponse(res).then((_data) => {
1201
1222
  return {
1202
1223
  page: <Page>_data.page,
1203
1224
  contractType: <ContractType>_data.contractType,
1204
- tokenIDs: <Array<string>>_data.tokenIDs
1225
+ tokenIDs: <Array<string>>_data.tokenIDs,
1205
1226
  }
1206
1227
  })
1207
1228
  },
1208
- error => {
1229
+ (error) => {
1209
1230
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1210
- }
1231
+ },
1211
1232
  )
1212
1233
  }
1213
1234
 
1214
- getTokenIDRanges = (args: GetTokenIDRangesArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenIDRangesReturn> => {
1235
+ getTokenIDRanges = (
1236
+ args: GetTokenIDRangesArgs,
1237
+ headers?: object,
1238
+ signal?: AbortSignal,
1239
+ ): Promise<GetTokenIDRangesReturn> => {
1215
1240
  return this.fetch(this.url('GetTokenIDRanges'), createHTTPRequest(args, headers, signal)).then(
1216
- res => {
1217
- return buildResponse(res).then(_data => {
1241
+ (res) => {
1242
+ return buildResponse(res).then((_data) => {
1218
1243
  return {
1219
1244
  contractType: <ContractType>_data.contractType,
1220
1245
  tokenIDRanges: <Array<TokenIDRange>>_data.tokenIDRanges,
1221
- moreRanges: <boolean>_data.moreRanges
1246
+ moreRanges: <boolean>_data.moreRanges,
1222
1247
  }
1223
1248
  })
1224
1249
  },
1225
- error => {
1250
+ (error) => {
1226
1251
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1227
- }
1252
+ },
1228
1253
  )
1229
1254
  }
1230
1255
 
1231
- getBalanceUpdates = (args: GetBalanceUpdatesArgs, headers?: object, signal?: AbortSignal): Promise<GetBalanceUpdatesReturn> => {
1256
+ getBalanceUpdates = (
1257
+ args: GetBalanceUpdatesArgs,
1258
+ headers?: object,
1259
+ signal?: AbortSignal,
1260
+ ): Promise<GetBalanceUpdatesReturn> => {
1232
1261
  return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest(args, headers, signal)).then(
1233
- res => {
1234
- return buildResponse(res).then(_data => {
1262
+ (res) => {
1263
+ return buildResponse(res).then((_data) => {
1235
1264
  return {
1236
1265
  page: <Page>_data.page,
1237
- balances: <Array<TokenBalance>>_data.balances
1266
+ balances: <Array<TokenBalance>>_data.balances,
1238
1267
  }
1239
1268
  })
1240
1269
  },
1241
- error => {
1270
+ (error) => {
1242
1271
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1243
- }
1272
+ },
1244
1273
  )
1245
1274
  }
1246
1275
 
1247
1276
  getTransactionHistory = (
1248
1277
  args: GetTransactionHistoryArgs,
1249
1278
  headers?: object,
1250
- signal?: AbortSignal
1279
+ signal?: AbortSignal,
1251
1280
  ): Promise<GetTransactionHistoryReturn> => {
1252
1281
  return this.fetch(this.url('GetTransactionHistory'), createHTTPRequest(args, headers, signal)).then(
1253
- res => {
1254
- return buildResponse(res).then(_data => {
1282
+ (res) => {
1283
+ return buildResponse(res).then((_data) => {
1255
1284
  return {
1256
1285
  page: <Page>_data.page,
1257
- transactions: <Array<Transaction>>_data.transactions
1286
+ transactions: <Array<Transaction>>_data.transactions,
1258
1287
  }
1259
1288
  })
1260
1289
  },
1261
- error => {
1290
+ (error) => {
1262
1291
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1263
- }
1292
+ },
1264
1293
  )
1265
1294
  }
1266
1295
 
1267
1296
  fetchTransactionReceipt = (
1268
1297
  args: FetchTransactionReceiptArgs,
1269
1298
  headers?: object,
1270
- signal?: AbortSignal
1299
+ signal?: AbortSignal,
1271
1300
  ): Promise<FetchTransactionReceiptReturn> => {
1272
1301
  return this.fetch(this.url('FetchTransactionReceipt'), createHTTPRequest(args, headers, signal)).then(
1273
- res => {
1274
- return buildResponse(res).then(_data => {
1302
+ (res) => {
1303
+ return buildResponse(res).then((_data) => {
1275
1304
  return {
1276
- receipt: <TransactionReceipt>_data.receipt
1305
+ receipt: <TransactionReceipt>_data.receipt,
1277
1306
  }
1278
1307
  })
1279
1308
  },
1280
- error => {
1309
+ (error) => {
1281
1310
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1282
- }
1311
+ },
1283
1312
  )
1284
1313
  }
1285
1314
 
1286
1315
  fetchTransactionReceiptWithFilter = (
1287
1316
  args: FetchTransactionReceiptWithFilterArgs,
1288
1317
  headers?: object,
1289
- signal?: AbortSignal
1318
+ signal?: AbortSignal,
1290
1319
  ): Promise<FetchTransactionReceiptWithFilterReturn> => {
1291
1320
  return this.fetch(this.url('FetchTransactionReceiptWithFilter'), createHTTPRequest(args, headers, signal)).then(
1292
- res => {
1293
- return buildResponse(res).then(_data => {
1321
+ (res) => {
1322
+ return buildResponse(res).then((_data) => {
1294
1323
  return {
1295
- receipt: <TransactionReceipt>_data.receipt
1324
+ receipt: <TransactionReceipt>_data.receipt,
1296
1325
  }
1297
1326
  })
1298
1327
  },
1299
- error => {
1328
+ (error) => {
1300
1329
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1301
- }
1330
+ },
1302
1331
  )
1303
1332
  }
1304
1333
 
1305
- subscribeReceipts = (args: SubscribeReceiptsArgs, options: WebrpcStreamOptions<SubscribeReceiptsReturn>): Promise<void> => {
1334
+ subscribeReceipts = (
1335
+ args: SubscribeReceiptsArgs,
1336
+ options: WebrpcStreamOptions<SubscribeReceiptsReturn>,
1337
+ ): Promise<void> => {
1306
1338
  const _fetch = () =>
1307
1339
  this.fetch(this.url('SubscribeReceipts'), createHTTPRequest(args, options.headers, options.signal)).then(
1308
- async res => {
1340
+ async (res) => {
1309
1341
  await sseResponse(res, options, _fetch)
1310
1342
  },
1311
- error => {
1343
+ (error) => {
1312
1344
  options.onError(error, _fetch)
1313
- }
1345
+ },
1314
1346
  )
1315
1347
  return _fetch()
1316
1348
  }
1317
1349
  subscribeEvents = (args: SubscribeEventsArgs, options: WebrpcStreamOptions<SubscribeEventsReturn>): Promise<void> => {
1318
1350
  const _fetch = () =>
1319
1351
  this.fetch(this.url('SubscribeEvents'), createHTTPRequest(args, options.headers, options.signal)).then(
1320
- async res => {
1352
+ async (res) => {
1321
1353
  await sseResponse(res, options, _fetch)
1322
1354
  },
1323
- error => {
1355
+ (error) => {
1324
1356
  options.onError(error, _fetch)
1325
- }
1357
+ },
1326
1358
  )
1327
1359
  return _fetch()
1328
1360
  }
1329
1361
  subscribeBalanceUpdates = (
1330
1362
  args: SubscribeBalanceUpdatesArgs,
1331
- options: WebrpcStreamOptions<SubscribeBalanceUpdatesReturn>
1363
+ options: WebrpcStreamOptions<SubscribeBalanceUpdatesReturn>,
1332
1364
  ): Promise<void> => {
1333
1365
  const _fetch = () =>
1334
1366
  this.fetch(this.url('SubscribeBalanceUpdates'), createHTTPRequest(args, options.headers, options.signal)).then(
1335
- async res => {
1367
+ async (res) => {
1336
1368
  await sseResponse(res, options, _fetch)
1337
1369
  },
1338
- error => {
1370
+ (error) => {
1339
1371
  options.onError(error, _fetch)
1340
- }
1372
+ },
1341
1373
  )
1342
1374
  return _fetch()
1343
1375
  }
1344
1376
  syncBalance = (args: SyncBalanceArgs, headers?: object, signal?: AbortSignal): Promise<SyncBalanceReturn> => {
1345
1377
  return this.fetch(this.url('SyncBalance'), createHTTPRequest(args, headers, signal)).then(
1346
- res => {
1347
- return buildResponse(res).then(_data => {
1378
+ (res) => {
1379
+ return buildResponse(res).then((_data) => {
1348
1380
  return {}
1349
1381
  })
1350
1382
  },
1351
- error => {
1383
+ (error) => {
1352
1384
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1353
- }
1385
+ },
1354
1386
  )
1355
1387
  }
1356
1388
 
1357
1389
  getAllWebhookListeners = (
1358
1390
  args: GetAllWebhookListenersArgs,
1359
1391
  headers?: object,
1360
- signal?: AbortSignal
1392
+ signal?: AbortSignal,
1361
1393
  ): Promise<GetAllWebhookListenersReturn> => {
1362
1394
  return this.fetch(this.url('GetAllWebhookListeners'), createHTTPRequest(args, headers, signal)).then(
1363
- res => {
1364
- return buildResponse(res).then(_data => {
1395
+ (res) => {
1396
+ return buildResponse(res).then((_data) => {
1365
1397
  return {
1366
- listeners: <Array<WebhookListener>>_data.listeners
1398
+ listeners: <Array<WebhookListener>>_data.listeners,
1367
1399
  }
1368
1400
  })
1369
1401
  },
1370
- error => {
1402
+ (error) => {
1371
1403
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1372
- }
1404
+ },
1373
1405
  )
1374
1406
  }
1375
1407
 
1376
1408
  getWebhookListener = (
1377
1409
  args: GetWebhookListenerArgs,
1378
1410
  headers?: object,
1379
- signal?: AbortSignal
1411
+ signal?: AbortSignal,
1380
1412
  ): Promise<GetWebhookListenerReturn> => {
1381
1413
  return this.fetch(this.url('GetWebhookListener'), createHTTPRequest(args, headers, signal)).then(
1382
- res => {
1383
- return buildResponse(res).then(_data => {
1414
+ (res) => {
1415
+ return buildResponse(res).then((_data) => {
1384
1416
  return {
1385
- listener: <WebhookListener>_data.listener
1417
+ listener: <WebhookListener>_data.listener,
1386
1418
  }
1387
1419
  })
1388
1420
  },
1389
- error => {
1421
+ (error) => {
1390
1422
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1391
- }
1423
+ },
1392
1424
  )
1393
1425
  }
1394
1426
 
1395
1427
  addWebhookListener = (
1396
1428
  args: AddWebhookListenerArgs,
1397
1429
  headers?: object,
1398
- signal?: AbortSignal
1430
+ signal?: AbortSignal,
1399
1431
  ): Promise<AddWebhookListenerReturn> => {
1400
1432
  return this.fetch(this.url('AddWebhookListener'), createHTTPRequest(args, headers, signal)).then(
1401
- res => {
1402
- return buildResponse(res).then(_data => {
1433
+ (res) => {
1434
+ return buildResponse(res).then((_data) => {
1403
1435
  return {
1404
1436
  status: <boolean>_data.status,
1405
- listener: <WebhookListener>_data.listener
1437
+ listener: <WebhookListener>_data.listener,
1406
1438
  }
1407
1439
  })
1408
1440
  },
1409
- error => {
1441
+ (error) => {
1410
1442
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1411
- }
1443
+ },
1412
1444
  )
1413
1445
  }
1414
1446
 
1415
1447
  updateWebhookListener = (
1416
1448
  args: UpdateWebhookListenerArgs,
1417
1449
  headers?: object,
1418
- signal?: AbortSignal
1450
+ signal?: AbortSignal,
1419
1451
  ): Promise<UpdateWebhookListenerReturn> => {
1420
1452
  return this.fetch(this.url('UpdateWebhookListener'), createHTTPRequest(args, headers, signal)).then(
1421
- res => {
1422
- return buildResponse(res).then(_data => {
1453
+ (res) => {
1454
+ return buildResponse(res).then((_data) => {
1423
1455
  return {
1424
- status: <boolean>_data.status
1456
+ status: <boolean>_data.status,
1425
1457
  }
1426
1458
  })
1427
1459
  },
1428
- error => {
1460
+ (error) => {
1429
1461
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1430
- }
1462
+ },
1431
1463
  )
1432
1464
  }
1433
1465
 
1434
1466
  removeWebhookListener = (
1435
1467
  args: RemoveWebhookListenerArgs,
1436
1468
  headers?: object,
1437
- signal?: AbortSignal
1469
+ signal?: AbortSignal,
1438
1470
  ): Promise<RemoveWebhookListenerReturn> => {
1439
1471
  return this.fetch(this.url('RemoveWebhookListener'), createHTTPRequest(args, headers, signal)).then(
1440
- res => {
1441
- return buildResponse(res).then(_data => {
1472
+ (res) => {
1473
+ return buildResponse(res).then((_data) => {
1442
1474
  return {
1443
- status: <boolean>_data.status
1475
+ status: <boolean>_data.status,
1444
1476
  }
1445
1477
  })
1446
1478
  },
1447
- error => {
1479
+ (error) => {
1448
1480
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1449
- }
1481
+ },
1450
1482
  )
1451
1483
  }
1452
1484
 
1453
1485
  removeAllWebhookListeners = (
1454
1486
  args: RemoveAllWebhookListenersArgs,
1455
1487
  headers?: object,
1456
- signal?: AbortSignal
1488
+ signal?: AbortSignal,
1457
1489
  ): Promise<RemoveAllWebhookListenersReturn> => {
1458
1490
  return this.fetch(this.url('RemoveAllWebhookListeners'), createHTTPRequest(args, headers, signal)).then(
1459
- res => {
1460
- return buildResponse(res).then(_data => {
1491
+ (res) => {
1492
+ return buildResponse(res).then((_data) => {
1461
1493
  return {
1462
- status: <boolean>_data.status
1494
+ status: <boolean>_data.status,
1463
1495
  }
1464
1496
  })
1465
1497
  },
1466
- error => {
1498
+ (error) => {
1467
1499
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1468
- }
1500
+ },
1469
1501
  )
1470
1502
  }
1471
1503
 
1472
1504
  toggleWebhookListener = (
1473
1505
  args: ToggleWebhookListenerArgs,
1474
1506
  headers?: object,
1475
- signal?: AbortSignal
1507
+ signal?: AbortSignal,
1476
1508
  ): Promise<ToggleWebhookListenerReturn> => {
1477
1509
  return this.fetch(this.url('ToggleWebhookListener'), createHTTPRequest(args, headers, signal)).then(
1478
- res => {
1479
- return buildResponse(res).then(_data => {
1510
+ (res) => {
1511
+ return buildResponse(res).then((_data) => {
1480
1512
  return {
1481
- webhookListener: <WebhookListener>_data.webhookListener
1513
+ webhookListener: <WebhookListener>_data.webhookListener,
1482
1514
  }
1483
1515
  })
1484
1516
  },
1485
- error => {
1517
+ (error) => {
1486
1518
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1487
- }
1519
+ },
1488
1520
  )
1489
1521
  }
1490
1522
 
1491
1523
  pauseAllWebhookListeners = (
1492
1524
  args: PauseAllWebhookListenersArgs,
1493
1525
  headers?: object,
1494
- signal?: AbortSignal
1526
+ signal?: AbortSignal,
1495
1527
  ): Promise<PauseAllWebhookListenersReturn> => {
1496
1528
  return this.fetch(this.url('PauseAllWebhookListeners'), createHTTPRequest(args, headers, signal)).then(
1497
- res => {
1498
- return buildResponse(res).then(_data => {
1529
+ (res) => {
1530
+ return buildResponse(res).then((_data) => {
1499
1531
  return {
1500
- status: <boolean>_data.status
1532
+ status: <boolean>_data.status,
1501
1533
  }
1502
1534
  })
1503
1535
  },
1504
- error => {
1536
+ (error) => {
1505
1537
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1506
- }
1538
+ },
1507
1539
  )
1508
1540
  }
1509
1541
 
1510
1542
  resumeAllWebhookListeners = (
1511
1543
  args: ResumeAllWebhookListenersArgs,
1512
1544
  headers?: object,
1513
- signal?: AbortSignal
1545
+ signal?: AbortSignal,
1514
1546
  ): Promise<ResumeAllWebhookListenersReturn> => {
1515
1547
  return this.fetch(this.url('ResumeAllWebhookListeners'), createHTTPRequest(args, headers, signal)).then(
1516
- res => {
1517
- return buildResponse(res).then(_data => {
1548
+ (res) => {
1549
+ return buildResponse(res).then((_data) => {
1518
1550
  return {
1519
- status: <boolean>_data.status
1551
+ status: <boolean>_data.status,
1520
1552
  }
1521
1553
  })
1522
1554
  },
1523
- error => {
1555
+ (error) => {
1524
1556
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1525
- }
1557
+ },
1526
1558
  )
1527
1559
  }
1528
1560
 
1529
1561
  getOrderbookOrders = (
1530
1562
  args: GetOrderbookOrdersArgs,
1531
1563
  headers?: object,
1532
- signal?: AbortSignal
1564
+ signal?: AbortSignal,
1533
1565
  ): Promise<GetOrderbookOrdersReturn> => {
1534
1566
  return this.fetch(this.url('GetOrderbookOrders'), createHTTPRequest(args, headers, signal)).then(
1535
- res => {
1536
- return buildResponse(res).then(_data => {
1567
+ (res) => {
1568
+ return buildResponse(res).then((_data) => {
1537
1569
  return {
1538
1570
  page: <Page>_data.page,
1539
- orders: <Array<OrderbookOrder>>_data.orders
1571
+ orders: <Array<OrderbookOrder>>_data.orders,
1540
1572
  }
1541
1573
  })
1542
1574
  },
1543
- error => {
1575
+ (error) => {
1544
1576
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1545
- }
1577
+ },
1546
1578
  )
1547
1579
  }
1548
1580
 
1549
1581
  getTopOrders = (args: GetTopOrdersArgs, headers?: object, signal?: AbortSignal): Promise<GetTopOrdersReturn> => {
1550
1582
  return this.fetch(this.url('GetTopOrders'), createHTTPRequest(args, headers, signal)).then(
1551
- res => {
1552
- return buildResponse(res).then(_data => {
1583
+ (res) => {
1584
+ return buildResponse(res).then((_data) => {
1553
1585
  return {
1554
- orders: <Array<OrderbookOrder>>_data.orders
1586
+ orders: <Array<OrderbookOrder>>_data.orders,
1555
1587
  }
1556
1588
  })
1557
1589
  },
1558
- error => {
1590
+ (error) => {
1559
1591
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1560
- }
1592
+ },
1561
1593
  )
1562
1594
  }
1563
1595
  }
@@ -1579,9 +1611,9 @@ const sseResponse = async (res: Response, options: WebrpcStreamOptions<any>, ret
1579
1611
  onError(
1580
1612
  WebrpcBadResponseError.new({
1581
1613
  status: res.status,
1582
- cause: 'Invalid response, missing body'
1614
+ cause: 'Invalid response, missing body',
1583
1615
  }),
1584
- retryFetch
1616
+ retryFetch,
1585
1617
  )
1586
1618
  return
1587
1619
  }
@@ -1620,18 +1652,18 @@ const sseResponse = async (res: Response, options: WebrpcStreamOptions<any>, ret
1620
1652
  onError(
1621
1653
  WebrpcRequestFailedError.new({
1622
1654
  message: 'AbortError',
1623
- cause: `AbortError: ${message}`
1655
+ cause: `AbortError: ${message}`,
1624
1656
  }),
1625
1657
  () => {
1626
1658
  throw new Error('Abort signal cannot be used to reconnect')
1627
- }
1659
+ },
1628
1660
  )
1629
1661
  } else {
1630
1662
  onError(
1631
1663
  WebrpcStreamLostError.new({
1632
- cause: `reader.read(): ${message}`
1664
+ cause: `reader.read(): ${message}`,
1633
1665
  }),
1634
- retryFetch
1666
+ retryFetch,
1635
1667
  )
1636
1668
  }
1637
1669
  return
@@ -1639,12 +1671,12 @@ const sseResponse = async (res: Response, options: WebrpcStreamOptions<any>, ret
1639
1671
 
1640
1672
  let lines = buffer.split('\n')
1641
1673
  for (let i = 0; i < lines.length - 1; i++) {
1642
- if (lines[i].length == 0) {
1674
+ if (lines[i]!.length == 0) {
1643
1675
  continue
1644
1676
  }
1645
1677
  let data: any
1646
1678
  try {
1647
- data = JSON.parse(lines[i])
1679
+ data = JSON.parse(lines[i]!)
1648
1680
  if (data.hasOwnProperty('webrpcError')) {
1649
1681
  const error = data.webrpcError
1650
1682
  const code: number = typeof error.code === 'number' ? error.code : 0
@@ -1659,16 +1691,16 @@ const sseResponse = async (res: Response, options: WebrpcStreamOptions<any>, ret
1659
1691
  WebrpcBadResponseError.new({
1660
1692
  status: res.status,
1661
1693
  // @ts-ignore
1662
- cause: `JSON.parse(): ${error.message}`
1694
+ cause: `JSON.parse(): ${error.message}`,
1663
1695
  }),
1664
- retryFetch
1696
+ retryFetch,
1665
1697
  )
1666
1698
  }
1667
1699
  onMessage(data)
1668
1700
  }
1669
1701
 
1670
1702
  if (!done) {
1671
- buffer = lines[lines.length - 1]
1703
+ buffer = lines[lines.length - 1]!
1672
1704
  continue
1673
1705
  }
1674
1706
 
@@ -1685,12 +1717,12 @@ const createHTTPRequest = (body: object = {}, headers: object = {}, signal: Abor
1685
1717
  method: 'POST',
1686
1718
  headers: reqHeaders,
1687
1719
  body: JSON.stringify(body || {}),
1688
- signal
1720
+ signal,
1689
1721
  }
1690
1722
  }
1691
1723
 
1692
1724
  const buildResponse = (res: Response): Promise<any> => {
1693
- return res.text().then(text => {
1725
+ return res.text().then((text) => {
1694
1726
  let data
1695
1727
  try {
1696
1728
  data = JSON.parse(text)
@@ -1701,7 +1733,7 @@ const buildResponse = (res: Response): Promise<any> => {
1701
1733
  }
1702
1734
  throw WebrpcBadResponseError.new({
1703
1735
  status: res.status,
1704
- cause: `JSON.parse(): ${message}: response text: ${text}`
1736
+ cause: `JSON.parse(): ${message}: response text: ${text}`,
1705
1737
  })
1706
1738
  }
1707
1739
  if (!res.ok) {
@@ -1750,7 +1782,7 @@ export class WebrpcEndpointError extends WebrpcError {
1750
1782
  code: number = 0,
1751
1783
  message: string = 'endpoint error',
1752
1784
  status: number = 0,
1753
- cause?: string
1785
+ cause?: string,
1754
1786
  ) {
1755
1787
  super(name, code, message, status, cause)
1756
1788
  Object.setPrototypeOf(this, WebrpcEndpointError.prototype)
@@ -1763,7 +1795,7 @@ export class WebrpcRequestFailedError extends WebrpcError {
1763
1795
  code: number = -1,
1764
1796
  message: string = 'request failed',
1765
1797
  status: number = 0,
1766
- cause?: string
1798
+ cause?: string,
1767
1799
  ) {
1768
1800
  super(name, code, message, status, cause)
1769
1801
  Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype)
@@ -1776,7 +1808,7 @@ export class WebrpcBadRouteError extends WebrpcError {
1776
1808
  code: number = -2,
1777
1809
  message: string = 'bad route',
1778
1810
  status: number = 0,
1779
- cause?: string
1811
+ cause?: string,
1780
1812
  ) {
1781
1813
  super(name, code, message, status, cause)
1782
1814
  Object.setPrototypeOf(this, WebrpcBadRouteError.prototype)
@@ -1789,7 +1821,7 @@ export class WebrpcBadMethodError extends WebrpcError {
1789
1821
  code: number = -3,
1790
1822
  message: string = 'bad method',
1791
1823
  status: number = 0,
1792
- cause?: string
1824
+ cause?: string,
1793
1825
  ) {
1794
1826
  super(name, code, message, status, cause)
1795
1827
  Object.setPrototypeOf(this, WebrpcBadMethodError.prototype)
@@ -1802,7 +1834,7 @@ export class WebrpcBadRequestError extends WebrpcError {
1802
1834
  code: number = -4,
1803
1835
  message: string = 'bad request',
1804
1836
  status: number = 0,
1805
- cause?: string
1837
+ cause?: string,
1806
1838
  ) {
1807
1839
  super(name, code, message, status, cause)
1808
1840
  Object.setPrototypeOf(this, WebrpcBadRequestError.prototype)
@@ -1815,7 +1847,7 @@ export class WebrpcBadResponseError extends WebrpcError {
1815
1847
  code: number = -5,
1816
1848
  message: string = 'bad response',
1817
1849
  status: number = 0,
1818
- cause?: string
1850
+ cause?: string,
1819
1851
  ) {
1820
1852
  super(name, code, message, status, cause)
1821
1853
  Object.setPrototypeOf(this, WebrpcBadResponseError.prototype)
@@ -1828,7 +1860,7 @@ export class WebrpcServerPanicError extends WebrpcError {
1828
1860
  code: number = -6,
1829
1861
  message: string = 'server panic',
1830
1862
  status: number = 0,
1831
- cause?: string
1863
+ cause?: string,
1832
1864
  ) {
1833
1865
  super(name, code, message, status, cause)
1834
1866
  Object.setPrototypeOf(this, WebrpcServerPanicError.prototype)
@@ -1841,7 +1873,7 @@ export class WebrpcInternalErrorError extends WebrpcError {
1841
1873
  code: number = -7,
1842
1874
  message: string = 'internal error',
1843
1875
  status: number = 0,
1844
- cause?: string
1876
+ cause?: string,
1845
1877
  ) {
1846
1878
  super(name, code, message, status, cause)
1847
1879
  Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype)
@@ -1854,7 +1886,7 @@ export class WebrpcClientDisconnectedError extends WebrpcError {
1854
1886
  code: number = -8,
1855
1887
  message: string = 'client disconnected',
1856
1888
  status: number = 0,
1857
- cause?: string
1889
+ cause?: string,
1858
1890
  ) {
1859
1891
  super(name, code, message, status, cause)
1860
1892
  Object.setPrototypeOf(this, WebrpcClientDisconnectedError.prototype)
@@ -1867,7 +1899,7 @@ export class WebrpcStreamLostError extends WebrpcError {
1867
1899
  code: number = -9,
1868
1900
  message: string = 'stream lost',
1869
1901
  status: number = 0,
1870
- cause?: string
1902
+ cause?: string,
1871
1903
  ) {
1872
1904
  super(name, code, message, status, cause)
1873
1905
  Object.setPrototypeOf(this, WebrpcStreamLostError.prototype)
@@ -1880,7 +1912,7 @@ export class WebrpcStreamFinishedError extends WebrpcError {
1880
1912
  code: number = -10,
1881
1913
  message: string = 'stream finished',
1882
1914
  status: number = 0,
1883
- cause?: string
1915
+ cause?: string,
1884
1916
  ) {
1885
1917
  super(name, code, message, status, cause)
1886
1918
  Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype)
@@ -1895,7 +1927,7 @@ export class UnauthorizedError extends WebrpcError {
1895
1927
  code: number = 1000,
1896
1928
  message: string = 'Unauthorized access',
1897
1929
  status: number = 0,
1898
- cause?: string
1930
+ cause?: string,
1899
1931
  ) {
1900
1932
  super(name, code, message, status, cause)
1901
1933
  Object.setPrototypeOf(this, UnauthorizedError.prototype)
@@ -1908,7 +1940,7 @@ export class PermissionDeniedError extends WebrpcError {
1908
1940
  code: number = 1001,
1909
1941
  message: string = 'Permission denied',
1910
1942
  status: number = 0,
1911
- cause?: string
1943
+ cause?: string,
1912
1944
  ) {
1913
1945
  super(name, code, message, status, cause)
1914
1946
  Object.setPrototypeOf(this, PermissionDeniedError.prototype)
@@ -1921,7 +1953,7 @@ export class SessionExpiredError extends WebrpcError {
1921
1953
  code: number = 1002,
1922
1954
  message: string = 'Session expired',
1923
1955
  status: number = 0,
1924
- cause?: string
1956
+ cause?: string,
1925
1957
  ) {
1926
1958
  super(name, code, message, status, cause)
1927
1959
  Object.setPrototypeOf(this, SessionExpiredError.prototype)
@@ -1934,7 +1966,7 @@ export class MethodNotFoundError extends WebrpcError {
1934
1966
  code: number = 1003,
1935
1967
  message: string = 'Method not found',
1936
1968
  status: number = 0,
1937
- cause?: string
1969
+ cause?: string,
1938
1970
  ) {
1939
1971
  super(name, code, message, status, cause)
1940
1972
  Object.setPrototypeOf(this, MethodNotFoundError.prototype)
@@ -1947,7 +1979,7 @@ export class RequestConflictError extends WebrpcError {
1947
1979
  code: number = 1004,
1948
1980
  message: string = 'Conflict with target resource',
1949
1981
  status: number = 0,
1950
- cause?: string
1982
+ cause?: string,
1951
1983
  ) {
1952
1984
  super(name, code, message, status, cause)
1953
1985
  Object.setPrototypeOf(this, RequestConflictError.prototype)
@@ -1960,7 +1992,7 @@ export class AbortedError extends WebrpcError {
1960
1992
  code: number = 1005,
1961
1993
  message: string = 'Request aborted',
1962
1994
  status: number = 0,
1963
- cause?: string
1995
+ cause?: string,
1964
1996
  ) {
1965
1997
  super(name, code, message, status, cause)
1966
1998
  Object.setPrototypeOf(this, AbortedError.prototype)
@@ -1973,7 +2005,7 @@ export class GeoblockedError extends WebrpcError {
1973
2005
  code: number = 1006,
1974
2006
  message: string = 'Geoblocked region',
1975
2007
  status: number = 0,
1976
- cause?: string
2008
+ cause?: string,
1977
2009
  ) {
1978
2010
  super(name, code, message, status, cause)
1979
2011
  Object.setPrototypeOf(this, GeoblockedError.prototype)
@@ -1986,7 +2018,7 @@ export class RateLimitedError extends WebrpcError {
1986
2018
  code: number = 1007,
1987
2019
  message: string = 'Rate-limited. Please slow down.',
1988
2020
  status: number = 0,
1989
- cause?: string
2021
+ cause?: string,
1990
2022
  ) {
1991
2023
  super(name, code, message, status, cause)
1992
2024
  Object.setPrototypeOf(this, RateLimitedError.prototype)
@@ -1999,7 +2031,7 @@ export class ProjectNotFoundError extends WebrpcError {
1999
2031
  code: number = 1100,
2000
2032
  message: string = 'Project not found',
2001
2033
  status: number = 0,
2002
- cause?: string
2034
+ cause?: string,
2003
2035
  ) {
2004
2036
  super(name, code, message, status, cause)
2005
2037
  Object.setPrototypeOf(this, ProjectNotFoundError.prototype)
@@ -2012,7 +2044,7 @@ export class AccessKeyNotFoundError extends WebrpcError {
2012
2044
  code: number = 1101,
2013
2045
  message: string = 'Access key not found',
2014
2046
  status: number = 0,
2015
- cause?: string
2047
+ cause?: string,
2016
2048
  ) {
2017
2049
  super(name, code, message, status, cause)
2018
2050
  Object.setPrototypeOf(this, AccessKeyNotFoundError.prototype)
@@ -2025,7 +2057,7 @@ export class AccessKeyMismatchError extends WebrpcError {
2025
2057
  code: number = 1102,
2026
2058
  message: string = 'Access key mismatch',
2027
2059
  status: number = 0,
2028
- cause?: string
2060
+ cause?: string,
2029
2061
  ) {
2030
2062
  super(name, code, message, status, cause)
2031
2063
  Object.setPrototypeOf(this, AccessKeyMismatchError.prototype)
@@ -2038,7 +2070,7 @@ export class InvalidOriginError extends WebrpcError {
2038
2070
  code: number = 1103,
2039
2071
  message: string = 'Invalid origin for Access Key',
2040
2072
  status: number = 0,
2041
- cause?: string
2073
+ cause?: string,
2042
2074
  ) {
2043
2075
  super(name, code, message, status, cause)
2044
2076
  Object.setPrototypeOf(this, InvalidOriginError.prototype)
@@ -2051,7 +2083,7 @@ export class InvalidServiceError extends WebrpcError {
2051
2083
  code: number = 1104,
2052
2084
  message: string = 'Service not enabled for Access key',
2053
2085
  status: number = 0,
2054
- cause?: string
2086
+ cause?: string,
2055
2087
  ) {
2056
2088
  super(name, code, message, status, cause)
2057
2089
  Object.setPrototypeOf(this, InvalidServiceError.prototype)
@@ -2064,7 +2096,7 @@ export class UnauthorizedUserError extends WebrpcError {
2064
2096
  code: number = 1105,
2065
2097
  message: string = 'Unauthorized user',
2066
2098
  status: number = 0,
2067
- cause?: string
2099
+ cause?: string,
2068
2100
  ) {
2069
2101
  super(name, code, message, status, cause)
2070
2102
  Object.setPrototypeOf(this, UnauthorizedUserError.prototype)
@@ -2077,7 +2109,7 @@ export class QuotaExceededError extends WebrpcError {
2077
2109
  code: number = 1200,
2078
2110
  message: string = 'Quota exceeded',
2079
2111
  status: number = 0,
2080
- cause?: string
2112
+ cause?: string,
2081
2113
  ) {
2082
2114
  super(name, code, message, status, cause)
2083
2115
  Object.setPrototypeOf(this, QuotaExceededError.prototype)
@@ -2090,7 +2122,7 @@ export class RateLimitError extends WebrpcError {
2090
2122
  code: number = 1201,
2091
2123
  message: string = 'Rate limit exceeded',
2092
2124
  status: number = 0,
2093
- cause?: string
2125
+ cause?: string,
2094
2126
  ) {
2095
2127
  super(name, code, message, status, cause)
2096
2128
  Object.setPrototypeOf(this, RateLimitError.prototype)
@@ -2103,7 +2135,7 @@ export class NoDefaultKeyError extends WebrpcError {
2103
2135
  code: number = 1300,
2104
2136
  message: string = 'No default access key found',
2105
2137
  status: number = 0,
2106
- cause?: string
2138
+ cause?: string,
2107
2139
  ) {
2108
2140
  super(name, code, message, status, cause)
2109
2141
  Object.setPrototypeOf(this, NoDefaultKeyError.prototype)
@@ -2116,7 +2148,7 @@ export class MaxAccessKeysError extends WebrpcError {
2116
2148
  code: number = 1301,
2117
2149
  message: string = 'Access keys limit reached',
2118
2150
  status: number = 0,
2119
- cause?: string
2151
+ cause?: string,
2120
2152
  ) {
2121
2153
  super(name, code, message, status, cause)
2122
2154
  Object.setPrototypeOf(this, MaxAccessKeysError.prototype)
@@ -2129,7 +2161,7 @@ export class AtLeastOneKeyError extends WebrpcError {
2129
2161
  code: number = 1302,
2130
2162
  message: string = 'You need at least one Access Key',
2131
2163
  status: number = 0,
2132
- cause?: string
2164
+ cause?: string,
2133
2165
  ) {
2134
2166
  super(name, code, message, status, cause)
2135
2167
  Object.setPrototypeOf(this, AtLeastOneKeyError.prototype)
@@ -2142,7 +2174,7 @@ export class TimeoutError extends WebrpcError {
2142
2174
  code: number = 1900,
2143
2175
  message: string = 'Request timed out',
2144
2176
  status: number = 0,
2145
- cause?: string
2177
+ cause?: string,
2146
2178
  ) {
2147
2179
  super(name, code, message, status, cause)
2148
2180
  Object.setPrototypeOf(this, TimeoutError.prototype)
@@ -2155,7 +2187,7 @@ export class InvalidArgumentError extends WebrpcError {
2155
2187
  code: number = 2001,
2156
2188
  message: string = 'Invalid argument',
2157
2189
  status: number = 0,
2158
- cause?: string
2190
+ cause?: string,
2159
2191
  ) {
2160
2192
  super(name, code, message, status, cause)
2161
2193
  Object.setPrototypeOf(this, InvalidArgumentError.prototype)
@@ -2168,7 +2200,7 @@ export class UnavailableError extends WebrpcError {
2168
2200
  code: number = 2002,
2169
2201
  message: string = 'Unavailable resource',
2170
2202
  status: number = 0,
2171
- cause?: string
2203
+ cause?: string,
2172
2204
  ) {
2173
2205
  super(name, code, message, status, cause)
2174
2206
  Object.setPrototypeOf(this, UnavailableError.prototype)
@@ -2181,7 +2213,7 @@ export class QueryFailedError extends WebrpcError {
2181
2213
  code: number = 2003,
2182
2214
  message: string = 'Query failed',
2183
2215
  status: number = 0,
2184
- cause?: string
2216
+ cause?: string,
2185
2217
  ) {
2186
2218
  super(name, code, message, status, cause)
2187
2219
  Object.setPrototypeOf(this, QueryFailedError.prototype)
@@ -2194,7 +2226,7 @@ export class ResourceExhaustedError extends WebrpcError {
2194
2226
  code: number = 2004,
2195
2227
  message: string = 'Resource exhausted',
2196
2228
  status: number = 0,
2197
- cause?: string
2229
+ cause?: string,
2198
2230
  ) {
2199
2231
  super(name, code, message, status, cause)
2200
2232
  Object.setPrototypeOf(this, ResourceExhaustedError.prototype)
@@ -2207,7 +2239,7 @@ export class NotFoundError extends WebrpcError {
2207
2239
  code: number = 3000,
2208
2240
  message: string = 'Resource not found',
2209
2241
  status: number = 0,
2210
- cause?: string
2242
+ cause?: string,
2211
2243
  ) {
2212
2244
  super(name, code, message, status, cause)
2213
2245
  Object.setPrototypeOf(this, NotFoundError.prototype)
@@ -2220,7 +2252,7 @@ export class MetadataCallFailedError extends WebrpcError {
2220
2252
  code: number = 3003,
2221
2253
  message: string = 'Metadata service call failed',
2222
2254
  status: number = 0,
2223
- cause?: string
2255
+ cause?: string,
2224
2256
  ) {
2225
2257
  super(name, code, message, status, cause)
2226
2258
  Object.setPrototypeOf(this, MetadataCallFailedError.prototype)
@@ -2264,7 +2296,7 @@ export enum errors {
2264
2296
  QueryFailed = 'QueryFailed',
2265
2297
  ResourceExhausted = 'ResourceExhausted',
2266
2298
  NotFound = 'NotFound',
2267
- MetadataCallFailed = 'MetadataCallFailed'
2299
+ MetadataCallFailed = 'MetadataCallFailed',
2268
2300
  }
2269
2301
 
2270
2302
  const webrpcErrorByCode: { [code: number]: any } = {
@@ -2304,7 +2336,7 @@ const webrpcErrorByCode: { [code: number]: any } = {
2304
2336
  [2003]: QueryFailedError,
2305
2337
  [2004]: ResourceExhaustedError,
2306
2338
  [3000]: NotFoundError,
2307
- [3003]: MetadataCallFailedError
2339
+ [3003]: MetadataCallFailedError,
2308
2340
  }
2309
2341
 
2310
2342
  export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>