@0xsequence/relayer 3.0.5 → 3.0.7

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,7 +1,7 @@
1
1
  /* eslint-disable */
2
- // sequence-relayer v0.4.1 7f8a4b83b00e0b6849c76c2ff0e23931e26b3d9f
2
+ // sequence-relayer v0.4.1 0a2503bc893179ba968b0015d7580aabf6a88dd4
3
3
  // --
4
- // Code generated by Webrpc-gen@v0.30.2 with typescript generator. DO NOT EDIT.
4
+ // Code generated by Webrpc-gen@v0.32.2 with typescript generator. DO NOT EDIT.
5
5
  //
6
6
  // webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts -compat
7
7
 
@@ -12,7 +12,7 @@ export const WebrpcVersion = 'v1'
12
12
  export const WebrpcSchemaVersion = 'v0.4.1'
13
13
 
14
14
  // Schema hash generated from your RIDL schema
15
- export const WebrpcSchemaHash = '7f8a4b83b00e0b6849c76c2ff0e23931e26b3d9f'
15
+ export const WebrpcSchemaHash = '0a2503bc893179ba968b0015d7580aabf6a88dd4'
16
16
 
17
17
  //
18
18
  // Client interface
@@ -72,6 +72,23 @@ export interface RelayerClient {
72
72
 
73
73
  feeOptions(req: FeeOptionsArgs, headers?: object, signal?: AbortSignal): Promise<FeeOptionsReturn>
74
74
 
75
+ /**
76
+ * Bridge gas endpoints for S2S calls
77
+ * Used for bridge fees (e.g., LayerZero messaging fees) that require msg.value to be fronted at runtime.
78
+ * bridgeGas will be included in fee calculation so the relayer gets reimbursed.
79
+ */
80
+ sendMetaTxnWithBridgeGas(
81
+ req: SendMetaTxnWithBridgeGasArgs,
82
+ headers?: object,
83
+ signal?: AbortSignal,
84
+ ): Promise<SendMetaTxnWithBridgeGasReturn>
85
+
86
+ feeOptionsWithBridgeGas(
87
+ req: FeeOptionsWithBridgeGasArgs,
88
+ headers?: object,
89
+ signal?: AbortSignal,
90
+ ): Promise<FeeOptionsWithBridgeGasReturn>
91
+
75
92
  /**
76
93
  * TODO: deprecated, to be removed by https://github.com/0xsequence/stack/pull/356 at a later date
77
94
  */
@@ -81,6 +98,17 @@ export interface RelayerClient {
81
98
  signal?: AbortSignal,
82
99
  ): Promise<GetMetaTxnNetworkFeeOptionsReturn>
83
100
 
101
+ /**
102
+ *
103
+ * Sender administration
104
+ *
105
+ */
106
+ startSender(req: StartSenderArgs, headers?: object, signal?: AbortSignal): Promise<StartSenderReturn>
107
+
108
+ stopSender(req: StopSenderArgs, headers?: object, signal?: AbortSignal): Promise<StopSenderReturn>
109
+
110
+ repairSender(req: RepairSenderArgs, headers?: object, signal?: AbortSignal): Promise<RepairSenderReturn>
111
+
84
112
  getMetaTransactions(
85
113
  req: GetMetaTransactionsArgs,
86
114
  headers?: object,
@@ -93,21 +121,6 @@ export interface RelayerClient {
93
121
  signal?: AbortSignal,
94
122
  ): Promise<GetTransactionCostReturn>
95
123
 
96
- /**
97
- * Sent transactions from an account. If filter is omitted then it will return all transactions.
98
- */
99
- sentTransactions(req: SentTransactionsArgs, headers?: object, signal?: AbortSignal): Promise<SentTransactionsReturn>
100
-
101
- /**
102
- * Pending transactions waiting to be mined for an account. This endpoint is just a sugar of `SentTransactions`
103
- * with the filter set to pending: true.
104
- */
105
- pendingTransactions(
106
- req: PendingTransactionsArgs,
107
- headers?: object,
108
- signal?: AbortSignal,
109
- ): Promise<PendingTransactionsReturn>
110
-
111
124
  /**
112
125
  * Legacy Gas Tank
113
126
  */
@@ -145,7 +158,7 @@ export interface RelayerClient {
145
158
  ): Promise<ListGasTankBalanceAdjustmentsReturn>
146
159
 
147
160
  /**
148
- * Gas Sponsorship
161
+ * Project-Level Gas Sponsorship
149
162
  */
150
163
  listGasSponsors(req: ListGasSponsorsArgs, headers?: object, signal?: AbortSignal): Promise<ListGasSponsorsReturn>
151
164
 
@@ -157,6 +170,39 @@ export interface RelayerClient {
157
170
 
158
171
  removeGasSponsor(req: RemoveGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<RemoveGasSponsorReturn>
159
172
 
173
+ /**
174
+ * Ecosystem-level Gas Sponsorship
175
+ */
176
+ listEcosystemGasSponsors(
177
+ req: ListEcosystemGasSponsorsArgs,
178
+ headers?: object,
179
+ signal?: AbortSignal,
180
+ ): Promise<ListEcosystemGasSponsorsReturn>
181
+
182
+ getEcosystemGasSponsor(
183
+ req: GetEcosystemGasSponsorArgs,
184
+ headers?: object,
185
+ signal?: AbortSignal,
186
+ ): Promise<GetEcosystemGasSponsorReturn>
187
+
188
+ addEcosystemGasSponsor(
189
+ req: AddEcosystemGasSponsorArgs,
190
+ headers?: object,
191
+ signal?: AbortSignal,
192
+ ): Promise<AddEcosystemGasSponsorReturn>
193
+
194
+ updateEcosystemGasSponsor(
195
+ req: UpdateEcosystemGasSponsorArgs,
196
+ headers?: object,
197
+ signal?: AbortSignal,
198
+ ): Promise<UpdateEcosystemGasSponsorReturn>
199
+
200
+ removeEcosystemGasSponsor(
201
+ req: RemoveEcosystemGasSponsorArgs,
202
+ headers?: object,
203
+ signal?: AbortSignal,
204
+ ): Promise<RemoveEcosystemGasSponsorReturn>
205
+
160
206
  /**
161
207
  * Gas Sponsor Lookup
162
208
  */
@@ -186,6 +232,12 @@ export interface RelayerClient {
186
232
  // Schema types
187
233
  //
188
234
 
235
+ export enum RepairOperation {
236
+ SKIP = 'SKIP',
237
+ REQUEUE = 'REQUEUE',
238
+ DROP = 'DROP',
239
+ }
240
+
189
241
  export enum ETHTxnStatus {
190
242
  UNKNOWN = 'UNKNOWN',
191
243
  DROPPED = 'DROPPED',
@@ -195,6 +247,7 @@ export enum ETHTxnStatus {
195
247
  PARTIALLY_FAILED = 'PARTIALLY_FAILED',
196
248
  FAILED = 'FAILED',
197
249
  PENDING_PRECONDITION = 'PENDING_PRECONDITION',
250
+ MINED = 'MINED',
198
251
  }
199
252
 
200
253
  export enum TransferType {
@@ -221,7 +274,7 @@ export enum FeeTokenType {
221
274
  ERC1155_TOKEN = 'ERC1155_TOKEN',
222
275
  }
223
276
 
224
- export enum SortOrder {
277
+ export enum Order {
225
278
  DESC = 'DESC',
226
279
  ASC = 'ASC',
227
280
  }
@@ -250,7 +303,31 @@ export interface SenderStatus {
250
303
  index: number
251
304
  address: string
252
305
  etherBalance: number
306
+ enabled: boolean
253
307
  active: boolean
308
+ nonce?: NonceStatus
309
+ current?: CurrentStatus
310
+ }
311
+
312
+ export interface NonceStatus {
313
+ chain: number
314
+ mempool: number
315
+ }
316
+
317
+ export interface CurrentStatus {
318
+ transaction: string
319
+ first: TransactionStatus
320
+ latest?: TransactionStatus
321
+ }
322
+
323
+ export interface TransactionStatus {
324
+ transaction: string
325
+ gas: number
326
+ gasPrice: string
327
+ priorityFee: string
328
+ time: string
329
+ age: string
330
+ error?: string
254
331
  }
255
332
 
256
333
  export interface RuntimeChecks {}
@@ -287,6 +364,7 @@ export interface GasSponsor {
287
364
  id: number
288
365
  gasTankId: number
289
366
  projectId: number
367
+ ecosystemId: number
290
368
  chainId: number
291
369
  address: string
292
370
  name: string
@@ -329,6 +407,7 @@ export interface MetaTxnLog {
329
407
  minedAt: string
330
408
  target: string
331
409
  input: string
410
+ bridgeGas?: string
332
411
  txnArgs: { [key: string]: any }
333
412
  txnReceipt?: { [key: string]: any }
334
413
  walletAddress: string
@@ -402,11 +481,6 @@ export interface TxnLogTransfer {
402
481
  amounts: Array<string>
403
482
  }
404
483
 
405
- export interface SentTransactionsFilter {
406
- pending?: boolean
407
- failed?: boolean
408
- }
409
-
410
484
  export interface SimulateResult {
411
485
  executed: boolean
412
486
  succeeded: boolean
@@ -443,19 +517,16 @@ export interface FeeToken {
443
517
  }
444
518
 
445
519
  export interface Page {
446
- pageSize?: number
447
- page?: number
448
- more?: boolean
449
- totalRecords?: number
450
- column?: string
451
- before?: any
452
- after?: any
453
- sort?: Array<SortBy>
520
+ pageSize: number
521
+ page: number
522
+ more: boolean
523
+ column: string
524
+ sort: Array<Sort>
454
525
  }
455
526
 
456
- export interface SortBy {
527
+ export interface Sort {
457
528
  column: string
458
- order: SortOrder
529
+ order: Order
459
530
  }
460
531
 
461
532
  export interface PingArgs {}
@@ -566,6 +637,33 @@ export interface FeeOptionsReturn {
566
637
  quote?: string
567
638
  }
568
639
 
640
+ export interface SendMetaTxnWithBridgeGasArgs {
641
+ call: MetaTxn
642
+ quote?: string
643
+ projectID?: number
644
+ bridgeGas: string
645
+ preconditions?: Array<TransactionPrecondition>
646
+ }
647
+
648
+ export interface SendMetaTxnWithBridgeGasReturn {
649
+ status: boolean
650
+ txnHash: string
651
+ }
652
+
653
+ export interface FeeOptionsWithBridgeGasArgs {
654
+ wallet: string
655
+ to: string
656
+ data: string
657
+ simulate?: boolean
658
+ bridgeGas: string
659
+ }
660
+
661
+ export interface FeeOptionsWithBridgeGasReturn {
662
+ options: Array<FeeOption>
663
+ sponsored: boolean
664
+ quote?: string
665
+ }
666
+
569
667
  export interface GetMetaTxnNetworkFeeOptionsArgs {
570
668
  walletConfig: any
571
669
  payload: string
@@ -575,6 +673,26 @@ export interface GetMetaTxnNetworkFeeOptionsReturn {
575
673
  options: Array<FeeOption>
576
674
  }
577
675
 
676
+ export interface StartSenderArgs {
677
+ sender: number
678
+ }
679
+
680
+ export interface StartSenderReturn {}
681
+
682
+ export interface StopSenderArgs {
683
+ sender: number
684
+ }
685
+
686
+ export interface StopSenderReturn {}
687
+
688
+ export interface RepairSenderArgs {
689
+ sender: number
690
+ nonce: number
691
+ operation: RepairOperation
692
+ }
693
+
694
+ export interface RepairSenderReturn {}
695
+
578
696
  export interface GetMetaTransactionsArgs {
579
697
  projectId: number
580
698
  page?: Page
@@ -595,25 +713,6 @@ export interface GetTransactionCostReturn {
595
713
  cost: number
596
714
  }
597
715
 
598
- export interface SentTransactionsArgs {
599
- filter?: SentTransactionsFilter
600
- page?: Page
601
- }
602
-
603
- export interface SentTransactionsReturn {
604
- page: Page
605
- transactions: Array<Transaction>
606
- }
607
-
608
- export interface PendingTransactionsArgs {
609
- page?: Page
610
- }
611
-
612
- export interface PendingTransactionsReturn {
613
- page: Page
614
- transactions: Array<Transaction>
615
- }
616
-
617
716
  export interface GetGasTankArgs {
618
717
  id: number
619
718
  }
@@ -735,6 +834,58 @@ export interface RemoveGasSponsorReturn {
735
834
  status: boolean
736
835
  }
737
836
 
837
+ export interface ListEcosystemGasSponsorsArgs {
838
+ ecosystemId: number
839
+ page?: Page
840
+ }
841
+
842
+ export interface ListEcosystemGasSponsorsReturn {
843
+ page: Page
844
+ gasSponsors: Array<GasSponsor>
845
+ }
846
+
847
+ export interface GetEcosystemGasSponsorArgs {
848
+ ecosystemId: number
849
+ id: number
850
+ }
851
+
852
+ export interface GetEcosystemGasSponsorReturn {
853
+ gasSponsor: GasSponsor
854
+ }
855
+
856
+ export interface AddEcosystemGasSponsorArgs {
857
+ ecosystemId: number
858
+ address: string
859
+ name?: string
860
+ active?: boolean
861
+ }
862
+
863
+ export interface AddEcosystemGasSponsorReturn {
864
+ status: boolean
865
+ gasSponsor: GasSponsor
866
+ }
867
+
868
+ export interface UpdateEcosystemGasSponsorArgs {
869
+ ecosystemId: number
870
+ id: number
871
+ name?: string
872
+ active?: boolean
873
+ }
874
+
875
+ export interface UpdateEcosystemGasSponsorReturn {
876
+ status: boolean
877
+ gasSponsor: GasSponsor
878
+ }
879
+
880
+ export interface RemoveEcosystemGasSponsorArgs {
881
+ ecosystemId: number
882
+ id: number
883
+ }
884
+
885
+ export interface RemoveEcosystemGasSponsorReturn {
886
+ status: boolean
887
+ }
888
+
738
889
  export interface AddressGasSponsorsArgs {
739
890
  address: string
740
891
  page?: Page
@@ -795,12 +946,16 @@ export class Relayer implements RelayerClient {
795
946
  updateMetaTxnGasLimits: (req: UpdateMetaTxnGasLimitsArgs) => ['Relayer', 'updateMetaTxnGasLimits', req] as const,
796
947
  feeTokens: () => ['Relayer', 'feeTokens'] as const,
797
948
  feeOptions: (req: FeeOptionsArgs) => ['Relayer', 'feeOptions', req] as const,
949
+ sendMetaTxnWithBridgeGas: (req: SendMetaTxnWithBridgeGasArgs) =>
950
+ ['Relayer', 'sendMetaTxnWithBridgeGas', req] as const,
951
+ feeOptionsWithBridgeGas: (req: FeeOptionsWithBridgeGasArgs) => ['Relayer', 'feeOptionsWithBridgeGas', req] as const,
798
952
  getMetaTxnNetworkFeeOptions: (req: GetMetaTxnNetworkFeeOptionsArgs) =>
799
953
  ['Relayer', 'getMetaTxnNetworkFeeOptions', req] as const,
954
+ startSender: (req: StartSenderArgs) => ['Relayer', 'startSender', req] as const,
955
+ stopSender: (req: StopSenderArgs) => ['Relayer', 'stopSender', req] as const,
956
+ repairSender: (req: RepairSenderArgs) => ['Relayer', 'repairSender', req] as const,
800
957
  getMetaTransactions: (req: GetMetaTransactionsArgs) => ['Relayer', 'getMetaTransactions', req] as const,
801
958
  getTransactionCost: (req: GetTransactionCostArgs) => ['Relayer', 'getTransactionCost', req] as const,
802
- sentTransactions: (req: SentTransactionsArgs) => ['Relayer', 'sentTransactions', req] as const,
803
- pendingTransactions: (req: PendingTransactionsArgs) => ['Relayer', 'pendingTransactions', req] as const,
804
959
  getGasTank: (req: GetGasTankArgs) => ['Relayer', 'getGasTank', req] as const,
805
960
  addGasTank: (req: AddGasTankArgs) => ['Relayer', 'addGasTank', req] as const,
806
961
  updateGasTank: (req: UpdateGasTankArgs) => ['Relayer', 'updateGasTank', req] as const,
@@ -816,6 +971,14 @@ export class Relayer implements RelayerClient {
816
971
  addGasSponsor: (req: AddGasSponsorArgs) => ['Relayer', 'addGasSponsor', req] as const,
817
972
  updateGasSponsor: (req: UpdateGasSponsorArgs) => ['Relayer', 'updateGasSponsor', req] as const,
818
973
  removeGasSponsor: (req: RemoveGasSponsorArgs) => ['Relayer', 'removeGasSponsor', req] as const,
974
+ listEcosystemGasSponsors: (req: ListEcosystemGasSponsorsArgs) =>
975
+ ['Relayer', 'listEcosystemGasSponsors', req] as const,
976
+ getEcosystemGasSponsor: (req: GetEcosystemGasSponsorArgs) => ['Relayer', 'getEcosystemGasSponsor', req] as const,
977
+ addEcosystemGasSponsor: (req: AddEcosystemGasSponsorArgs) => ['Relayer', 'addEcosystemGasSponsor', req] as const,
978
+ updateEcosystemGasSponsor: (req: UpdateEcosystemGasSponsorArgs) =>
979
+ ['Relayer', 'updateEcosystemGasSponsor', req] as const,
980
+ removeEcosystemGasSponsor: (req: RemoveEcosystemGasSponsorArgs) =>
981
+ ['Relayer', 'removeEcosystemGasSponsor', req] as const,
819
982
  addressGasSponsors: (req: AddressGasSponsorsArgs) => ['Relayer', 'addressGasSponsors', req] as const,
820
983
  getProjectBalance: (req: GetProjectBalanceArgs) => ['Relayer', 'getProjectBalance', req] as const,
821
984
  adjustProjectBalance: (req: AdjustProjectBalanceArgs) => ['Relayer', 'adjustProjectBalance', req] as const,
@@ -897,10 +1060,7 @@ export class Relayer implements RelayerClient {
897
1060
  }
898
1061
 
899
1062
  sendMetaTxn = (req: SendMetaTxnArgs, headers?: object, signal?: AbortSignal): Promise<SendMetaTxnReturn> => {
900
- return this.fetch(
901
- this.url('SendMetaTxn'),
902
- createHttpRequest(JsonEncode(req, 'SendMetaTxnArgs'), headers, signal),
903
- ).then(
1063
+ return this.fetch(this.url('SendMetaTxn'), createHttpRequest(JsonEncode(req), headers, signal)).then(
904
1064
  (res) => {
905
1065
  return buildResponse(res).then((_data) => {
906
1066
  return JsonDecode<SendMetaTxnReturn>(_data, 'SendMetaTxnReturn')
@@ -919,10 +1079,7 @@ export class Relayer implements RelayerClient {
919
1079
  headers?: object,
920
1080
  signal?: AbortSignal,
921
1081
  ): Promise<GetMetaTxnNonceReturn> => {
922
- return this.fetch(
923
- this.url('GetMetaTxnNonce'),
924
- createHttpRequest(JsonEncode(req, 'GetMetaTxnNonceArgs'), headers, signal),
925
- ).then(
1082
+ return this.fetch(this.url('GetMetaTxnNonce'), createHttpRequest(JsonEncode(req), headers, signal)).then(
926
1083
  (res) => {
927
1084
  return buildResponse(res).then((_data) => {
928
1085
  return JsonDecode<GetMetaTxnNonceReturn>(_data, 'GetMetaTxnNonceReturn')
@@ -941,10 +1098,7 @@ export class Relayer implements RelayerClient {
941
1098
  headers?: object,
942
1099
  signal?: AbortSignal,
943
1100
  ): Promise<GetMetaTxnReceiptReturn> => {
944
- return this.fetch(
945
- this.url('GetMetaTxnReceipt'),
946
- createHttpRequest(JsonEncode(req, 'GetMetaTxnReceiptArgs'), headers, signal),
947
- ).then(
1101
+ return this.fetch(this.url('GetMetaTxnReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(
948
1102
  (res) => {
949
1103
  return buildResponse(res).then((_data) => {
950
1104
  return JsonDecode<GetMetaTxnReceiptReturn>(_data, 'GetMetaTxnReceiptReturn')
@@ -959,7 +1113,7 @@ export class Relayer implements RelayerClient {
959
1113
  }
960
1114
 
961
1115
  simulate = (req: SimulateArgs, headers?: object, signal?: AbortSignal): Promise<SimulateReturn> => {
962
- return this.fetch(this.url('Simulate'), createHttpRequest(JsonEncode(req, 'SimulateArgs'), headers, signal)).then(
1116
+ return this.fetch(this.url('Simulate'), createHttpRequest(JsonEncode(req), headers, signal)).then(
963
1117
  (res) => {
964
1118
  return buildResponse(res).then((_data) => {
965
1119
  return JsonDecode<SimulateReturn>(_data, 'SimulateReturn')
@@ -974,10 +1128,7 @@ export class Relayer implements RelayerClient {
974
1128
  }
975
1129
 
976
1130
  simulateV3 = (req: SimulateV3Args, headers?: object, signal?: AbortSignal): Promise<SimulateV3Return> => {
977
- return this.fetch(
978
- this.url('SimulateV3'),
979
- createHttpRequest(JsonEncode(req, 'SimulateV3Args'), headers, signal),
980
- ).then(
1131
+ return this.fetch(this.url('SimulateV3'), createHttpRequest(JsonEncode(req), headers, signal)).then(
981
1132
  (res) => {
982
1133
  return buildResponse(res).then((_data) => {
983
1134
  return JsonDecode<SimulateV3Return>(_data, 'SimulateV3Return')
@@ -996,10 +1147,7 @@ export class Relayer implements RelayerClient {
996
1147
  headers?: object,
997
1148
  signal?: AbortSignal,
998
1149
  ): Promise<UpdateMetaTxnGasLimitsReturn> => {
999
- return this.fetch(
1000
- this.url('UpdateMetaTxnGasLimits'),
1001
- createHttpRequest(JsonEncode(req, 'UpdateMetaTxnGasLimitsArgs'), headers, signal),
1002
- ).then(
1150
+ return this.fetch(this.url('UpdateMetaTxnGasLimits'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1003
1151
  (res) => {
1004
1152
  return buildResponse(res).then((_data) => {
1005
1153
  return JsonDecode<UpdateMetaTxnGasLimitsReturn>(_data, 'UpdateMetaTxnGasLimitsReturn')
@@ -1029,10 +1177,7 @@ export class Relayer implements RelayerClient {
1029
1177
  }
1030
1178
 
1031
1179
  feeOptions = (req: FeeOptionsArgs, headers?: object, signal?: AbortSignal): Promise<FeeOptionsReturn> => {
1032
- return this.fetch(
1033
- this.url('FeeOptions'),
1034
- createHttpRequest(JsonEncode(req, 'FeeOptionsArgs'), headers, signal),
1035
- ).then(
1180
+ return this.fetch(this.url('FeeOptions'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1036
1181
  (res) => {
1037
1182
  return buildResponse(res).then((_data) => {
1038
1183
  return JsonDecode<FeeOptionsReturn>(_data, 'FeeOptionsReturn')
@@ -1046,6 +1191,44 @@ export class Relayer implements RelayerClient {
1046
1191
  )
1047
1192
  }
1048
1193
 
1194
+ sendMetaTxnWithBridgeGas = (
1195
+ req: SendMetaTxnWithBridgeGasArgs,
1196
+ headers?: object,
1197
+ signal?: AbortSignal,
1198
+ ): Promise<SendMetaTxnWithBridgeGasReturn> => {
1199
+ return this.fetch(this.url('SendMetaTxnWithBridgeGas'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1200
+ (res) => {
1201
+ return buildResponse(res).then((_data) => {
1202
+ return JsonDecode<SendMetaTxnWithBridgeGasReturn>(_data, 'SendMetaTxnWithBridgeGasReturn')
1203
+ })
1204
+ },
1205
+ (error) => {
1206
+ throw WebrpcRequestFailedError.new({
1207
+ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
1208
+ })
1209
+ },
1210
+ )
1211
+ }
1212
+
1213
+ feeOptionsWithBridgeGas = (
1214
+ req: FeeOptionsWithBridgeGasArgs,
1215
+ headers?: object,
1216
+ signal?: AbortSignal,
1217
+ ): Promise<FeeOptionsWithBridgeGasReturn> => {
1218
+ return this.fetch(this.url('FeeOptionsWithBridgeGas'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1219
+ (res) => {
1220
+ return buildResponse(res).then((_data) => {
1221
+ return JsonDecode<FeeOptionsWithBridgeGasReturn>(_data, 'FeeOptionsWithBridgeGasReturn')
1222
+ })
1223
+ },
1224
+ (error) => {
1225
+ throw WebrpcRequestFailedError.new({
1226
+ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
1227
+ })
1228
+ },
1229
+ )
1230
+ }
1231
+
1049
1232
  getMetaTxnNetworkFeeOptions = (
1050
1233
  req: GetMetaTxnNetworkFeeOptionsArgs,
1051
1234
  headers?: object,
@@ -1053,7 +1236,7 @@ export class Relayer implements RelayerClient {
1053
1236
  ): Promise<GetMetaTxnNetworkFeeOptionsReturn> => {
1054
1237
  return this.fetch(
1055
1238
  this.url('GetMetaTxnNetworkFeeOptions'),
1056
- createHttpRequest(JsonEncode(req, 'GetMetaTxnNetworkFeeOptionsArgs'), headers, signal),
1239
+ createHttpRequest(JsonEncode(req), headers, signal),
1057
1240
  ).then(
1058
1241
  (res) => {
1059
1242
  return buildResponse(res).then((_data) => {
@@ -1068,18 +1251,11 @@ export class Relayer implements RelayerClient {
1068
1251
  )
1069
1252
  }
1070
1253
 
1071
- getMetaTransactions = (
1072
- req: GetMetaTransactionsArgs,
1073
- headers?: object,
1074
- signal?: AbortSignal,
1075
- ): Promise<GetMetaTransactionsReturn> => {
1076
- return this.fetch(
1077
- this.url('GetMetaTransactions'),
1078
- createHttpRequest(JsonEncode(req, 'GetMetaTransactionsArgs'), headers, signal),
1079
- ).then(
1254
+ startSender = (req: StartSenderArgs, headers?: object, signal?: AbortSignal): Promise<StartSenderReturn> => {
1255
+ return this.fetch(this.url('StartSender'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1080
1256
  (res) => {
1081
1257
  return buildResponse(res).then((_data) => {
1082
- return JsonDecode<GetMetaTransactionsReturn>(_data, 'GetMetaTransactionsReturn')
1258
+ return JsonDecode<StartSenderReturn>(_data, 'StartSenderReturn')
1083
1259
  })
1084
1260
  },
1085
1261
  (error) => {
@@ -1090,18 +1266,26 @@ export class Relayer implements RelayerClient {
1090
1266
  )
1091
1267
  }
1092
1268
 
1093
- getTransactionCost = (
1094
- req: GetTransactionCostArgs,
1095
- headers?: object,
1096
- signal?: AbortSignal,
1097
- ): Promise<GetTransactionCostReturn> => {
1098
- return this.fetch(
1099
- this.url('GetTransactionCost'),
1100
- createHttpRequest(JsonEncode(req, 'GetTransactionCostArgs'), headers, signal),
1101
- ).then(
1269
+ stopSender = (req: StopSenderArgs, headers?: object, signal?: AbortSignal): Promise<StopSenderReturn> => {
1270
+ return this.fetch(this.url('StopSender'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1102
1271
  (res) => {
1103
1272
  return buildResponse(res).then((_data) => {
1104
- return JsonDecode<GetTransactionCostReturn>(_data, 'GetTransactionCostReturn')
1273
+ return JsonDecode<StopSenderReturn>(_data, 'StopSenderReturn')
1274
+ })
1275
+ },
1276
+ (error) => {
1277
+ throw WebrpcRequestFailedError.new({
1278
+ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
1279
+ })
1280
+ },
1281
+ )
1282
+ }
1283
+
1284
+ repairSender = (req: RepairSenderArgs, headers?: object, signal?: AbortSignal): Promise<RepairSenderReturn> => {
1285
+ return this.fetch(this.url('RepairSender'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1286
+ (res) => {
1287
+ return buildResponse(res).then((_data) => {
1288
+ return JsonDecode<RepairSenderReturn>(_data, 'RepairSenderReturn')
1105
1289
  })
1106
1290
  },
1107
1291
  (error) => {
@@ -1112,18 +1296,15 @@ export class Relayer implements RelayerClient {
1112
1296
  )
1113
1297
  }
1114
1298
 
1115
- sentTransactions = (
1116
- req: SentTransactionsArgs,
1299
+ getMetaTransactions = (
1300
+ req: GetMetaTransactionsArgs,
1117
1301
  headers?: object,
1118
1302
  signal?: AbortSignal,
1119
- ): Promise<SentTransactionsReturn> => {
1120
- return this.fetch(
1121
- this.url('SentTransactions'),
1122
- createHttpRequest(JsonEncode(req, 'SentTransactionsArgs'), headers, signal),
1123
- ).then(
1303
+ ): Promise<GetMetaTransactionsReturn> => {
1304
+ return this.fetch(this.url('GetMetaTransactions'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1124
1305
  (res) => {
1125
1306
  return buildResponse(res).then((_data) => {
1126
- return JsonDecode<SentTransactionsReturn>(_data, 'SentTransactionsReturn')
1307
+ return JsonDecode<GetMetaTransactionsReturn>(_data, 'GetMetaTransactionsReturn')
1127
1308
  })
1128
1309
  },
1129
1310
  (error) => {
@@ -1134,18 +1315,15 @@ export class Relayer implements RelayerClient {
1134
1315
  )
1135
1316
  }
1136
1317
 
1137
- pendingTransactions = (
1138
- req: PendingTransactionsArgs,
1318
+ getTransactionCost = (
1319
+ req: GetTransactionCostArgs,
1139
1320
  headers?: object,
1140
1321
  signal?: AbortSignal,
1141
- ): Promise<PendingTransactionsReturn> => {
1142
- return this.fetch(
1143
- this.url('PendingTransactions'),
1144
- createHttpRequest(JsonEncode(req, 'PendingTransactionsArgs'), headers, signal),
1145
- ).then(
1322
+ ): Promise<GetTransactionCostReturn> => {
1323
+ return this.fetch(this.url('GetTransactionCost'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1146
1324
  (res) => {
1147
1325
  return buildResponse(res).then((_data) => {
1148
- return JsonDecode<PendingTransactionsReturn>(_data, 'PendingTransactionsReturn')
1326
+ return JsonDecode<GetTransactionCostReturn>(_data, 'GetTransactionCostReturn')
1149
1327
  })
1150
1328
  },
1151
1329
  (error) => {
@@ -1157,10 +1335,7 @@ export class Relayer implements RelayerClient {
1157
1335
  }
1158
1336
 
1159
1337
  getGasTank = (req: GetGasTankArgs, headers?: object, signal?: AbortSignal): Promise<GetGasTankReturn> => {
1160
- return this.fetch(
1161
- this.url('GetGasTank'),
1162
- createHttpRequest(JsonEncode(req, 'GetGasTankArgs'), headers, signal),
1163
- ).then(
1338
+ return this.fetch(this.url('GetGasTank'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1164
1339
  (res) => {
1165
1340
  return buildResponse(res).then((_data) => {
1166
1341
  return JsonDecode<GetGasTankReturn>(_data, 'GetGasTankReturn')
@@ -1175,10 +1350,7 @@ export class Relayer implements RelayerClient {
1175
1350
  }
1176
1351
 
1177
1352
  addGasTank = (req: AddGasTankArgs, headers?: object, signal?: AbortSignal): Promise<AddGasTankReturn> => {
1178
- return this.fetch(
1179
- this.url('AddGasTank'),
1180
- createHttpRequest(JsonEncode(req, 'AddGasTankArgs'), headers, signal),
1181
- ).then(
1353
+ return this.fetch(this.url('AddGasTank'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1182
1354
  (res) => {
1183
1355
  return buildResponse(res).then((_data) => {
1184
1356
  return JsonDecode<AddGasTankReturn>(_data, 'AddGasTankReturn')
@@ -1193,10 +1365,7 @@ export class Relayer implements RelayerClient {
1193
1365
  }
1194
1366
 
1195
1367
  updateGasTank = (req: UpdateGasTankArgs, headers?: object, signal?: AbortSignal): Promise<UpdateGasTankReturn> => {
1196
- return this.fetch(
1197
- this.url('UpdateGasTank'),
1198
- createHttpRequest(JsonEncode(req, 'UpdateGasTankArgs'), headers, signal),
1199
- ).then(
1368
+ return this.fetch(this.url('UpdateGasTank'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1200
1369
  (res) => {
1201
1370
  return buildResponse(res).then((_data) => {
1202
1371
  return JsonDecode<UpdateGasTankReturn>(_data, 'UpdateGasTankReturn')
@@ -1217,7 +1386,7 @@ export class Relayer implements RelayerClient {
1217
1386
  ): Promise<NextGasTankBalanceAdjustmentNonceReturn> => {
1218
1387
  return this.fetch(
1219
1388
  this.url('NextGasTankBalanceAdjustmentNonce'),
1220
- createHttpRequest(JsonEncode(req, 'NextGasTankBalanceAdjustmentNonceArgs'), headers, signal),
1389
+ createHttpRequest(JsonEncode(req), headers, signal),
1221
1390
  ).then(
1222
1391
  (res) => {
1223
1392
  return buildResponse(res).then((_data) => {
@@ -1237,10 +1406,7 @@ export class Relayer implements RelayerClient {
1237
1406
  headers?: object,
1238
1407
  signal?: AbortSignal,
1239
1408
  ): Promise<AdjustGasTankBalanceReturn> => {
1240
- return this.fetch(
1241
- this.url('AdjustGasTankBalance'),
1242
- createHttpRequest(JsonEncode(req, 'AdjustGasTankBalanceArgs'), headers, signal),
1243
- ).then(
1409
+ return this.fetch(this.url('AdjustGasTankBalance'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1244
1410
  (res) => {
1245
1411
  return buildResponse(res).then((_data) => {
1246
1412
  return JsonDecode<AdjustGasTankBalanceReturn>(_data, 'AdjustGasTankBalanceReturn')
@@ -1261,7 +1427,7 @@ export class Relayer implements RelayerClient {
1261
1427
  ): Promise<GetGasTankBalanceAdjustmentReturn> => {
1262
1428
  return this.fetch(
1263
1429
  this.url('GetGasTankBalanceAdjustment'),
1264
- createHttpRequest(JsonEncode(req, 'GetGasTankBalanceAdjustmentArgs'), headers, signal),
1430
+ createHttpRequest(JsonEncode(req), headers, signal),
1265
1431
  ).then(
1266
1432
  (res) => {
1267
1433
  return buildResponse(res).then((_data) => {
@@ -1283,7 +1449,7 @@ export class Relayer implements RelayerClient {
1283
1449
  ): Promise<ListGasTankBalanceAdjustmentsReturn> => {
1284
1450
  return this.fetch(
1285
1451
  this.url('ListGasTankBalanceAdjustments'),
1286
- createHttpRequest(JsonEncode(req, 'ListGasTankBalanceAdjustmentsArgs'), headers, signal),
1452
+ createHttpRequest(JsonEncode(req), headers, signal),
1287
1453
  ).then(
1288
1454
  (res) => {
1289
1455
  return buildResponse(res).then((_data) => {
@@ -1303,10 +1469,7 @@ export class Relayer implements RelayerClient {
1303
1469
  headers?: object,
1304
1470
  signal?: AbortSignal,
1305
1471
  ): Promise<ListGasSponsorsReturn> => {
1306
- return this.fetch(
1307
- this.url('ListGasSponsors'),
1308
- createHttpRequest(JsonEncode(req, 'ListGasSponsorsArgs'), headers, signal),
1309
- ).then(
1472
+ return this.fetch(this.url('ListGasSponsors'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1310
1473
  (res) => {
1311
1474
  return buildResponse(res).then((_data) => {
1312
1475
  return JsonDecode<ListGasSponsorsReturn>(_data, 'ListGasSponsorsReturn')
@@ -1321,10 +1484,7 @@ export class Relayer implements RelayerClient {
1321
1484
  }
1322
1485
 
1323
1486
  getGasSponsor = (req: GetGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<GetGasSponsorReturn> => {
1324
- return this.fetch(
1325
- this.url('GetGasSponsor'),
1326
- createHttpRequest(JsonEncode(req, 'GetGasSponsorArgs'), headers, signal),
1327
- ).then(
1487
+ return this.fetch(this.url('GetGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1328
1488
  (res) => {
1329
1489
  return buildResponse(res).then((_data) => {
1330
1490
  return JsonDecode<GetGasSponsorReturn>(_data, 'GetGasSponsorReturn')
@@ -1339,10 +1499,7 @@ export class Relayer implements RelayerClient {
1339
1499
  }
1340
1500
 
1341
1501
  addGasSponsor = (req: AddGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise<AddGasSponsorReturn> => {
1342
- return this.fetch(
1343
- this.url('AddGasSponsor'),
1344
- createHttpRequest(JsonEncode(req, 'AddGasSponsorArgs'), headers, signal),
1345
- ).then(
1502
+ return this.fetch(this.url('AddGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1346
1503
  (res) => {
1347
1504
  return buildResponse(res).then((_data) => {
1348
1505
  return JsonDecode<AddGasSponsorReturn>(_data, 'AddGasSponsorReturn')
@@ -1361,10 +1518,7 @@ export class Relayer implements RelayerClient {
1361
1518
  headers?: object,
1362
1519
  signal?: AbortSignal,
1363
1520
  ): Promise<UpdateGasSponsorReturn> => {
1364
- return this.fetch(
1365
- this.url('UpdateGasSponsor'),
1366
- createHttpRequest(JsonEncode(req, 'UpdateGasSponsorArgs'), headers, signal),
1367
- ).then(
1521
+ return this.fetch(this.url('UpdateGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1368
1522
  (res) => {
1369
1523
  return buildResponse(res).then((_data) => {
1370
1524
  return JsonDecode<UpdateGasSponsorReturn>(_data, 'UpdateGasSponsorReturn')
@@ -1383,10 +1537,7 @@ export class Relayer implements RelayerClient {
1383
1537
  headers?: object,
1384
1538
  signal?: AbortSignal,
1385
1539
  ): Promise<RemoveGasSponsorReturn> => {
1386
- return this.fetch(
1387
- this.url('RemoveGasSponsor'),
1388
- createHttpRequest(JsonEncode(req, 'RemoveGasSponsorArgs'), headers, signal),
1389
- ).then(
1540
+ return this.fetch(this.url('RemoveGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1390
1541
  (res) => {
1391
1542
  return buildResponse(res).then((_data) => {
1392
1543
  return JsonDecode<RemoveGasSponsorReturn>(_data, 'RemoveGasSponsorReturn')
@@ -1400,15 +1551,107 @@ export class Relayer implements RelayerClient {
1400
1551
  )
1401
1552
  }
1402
1553
 
1554
+ listEcosystemGasSponsors = (
1555
+ req: ListEcosystemGasSponsorsArgs,
1556
+ headers?: object,
1557
+ signal?: AbortSignal,
1558
+ ): Promise<ListEcosystemGasSponsorsReturn> => {
1559
+ return this.fetch(this.url('ListEcosystemGasSponsors'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1560
+ (res) => {
1561
+ return buildResponse(res).then((_data) => {
1562
+ return JsonDecode<ListEcosystemGasSponsorsReturn>(_data, 'ListEcosystemGasSponsorsReturn')
1563
+ })
1564
+ },
1565
+ (error) => {
1566
+ throw WebrpcRequestFailedError.new({
1567
+ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
1568
+ })
1569
+ },
1570
+ )
1571
+ }
1572
+
1573
+ getEcosystemGasSponsor = (
1574
+ req: GetEcosystemGasSponsorArgs,
1575
+ headers?: object,
1576
+ signal?: AbortSignal,
1577
+ ): Promise<GetEcosystemGasSponsorReturn> => {
1578
+ return this.fetch(this.url('GetEcosystemGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1579
+ (res) => {
1580
+ return buildResponse(res).then((_data) => {
1581
+ return JsonDecode<GetEcosystemGasSponsorReturn>(_data, 'GetEcosystemGasSponsorReturn')
1582
+ })
1583
+ },
1584
+ (error) => {
1585
+ throw WebrpcRequestFailedError.new({
1586
+ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
1587
+ })
1588
+ },
1589
+ )
1590
+ }
1591
+
1592
+ addEcosystemGasSponsor = (
1593
+ req: AddEcosystemGasSponsorArgs,
1594
+ headers?: object,
1595
+ signal?: AbortSignal,
1596
+ ): Promise<AddEcosystemGasSponsorReturn> => {
1597
+ return this.fetch(this.url('AddEcosystemGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1598
+ (res) => {
1599
+ return buildResponse(res).then((_data) => {
1600
+ return JsonDecode<AddEcosystemGasSponsorReturn>(_data, 'AddEcosystemGasSponsorReturn')
1601
+ })
1602
+ },
1603
+ (error) => {
1604
+ throw WebrpcRequestFailedError.new({
1605
+ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
1606
+ })
1607
+ },
1608
+ )
1609
+ }
1610
+
1611
+ updateEcosystemGasSponsor = (
1612
+ req: UpdateEcosystemGasSponsorArgs,
1613
+ headers?: object,
1614
+ signal?: AbortSignal,
1615
+ ): Promise<UpdateEcosystemGasSponsorReturn> => {
1616
+ return this.fetch(this.url('UpdateEcosystemGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1617
+ (res) => {
1618
+ return buildResponse(res).then((_data) => {
1619
+ return JsonDecode<UpdateEcosystemGasSponsorReturn>(_data, 'UpdateEcosystemGasSponsorReturn')
1620
+ })
1621
+ },
1622
+ (error) => {
1623
+ throw WebrpcRequestFailedError.new({
1624
+ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
1625
+ })
1626
+ },
1627
+ )
1628
+ }
1629
+
1630
+ removeEcosystemGasSponsor = (
1631
+ req: RemoveEcosystemGasSponsorArgs,
1632
+ headers?: object,
1633
+ signal?: AbortSignal,
1634
+ ): Promise<RemoveEcosystemGasSponsorReturn> => {
1635
+ return this.fetch(this.url('RemoveEcosystemGasSponsor'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1636
+ (res) => {
1637
+ return buildResponse(res).then((_data) => {
1638
+ return JsonDecode<RemoveEcosystemGasSponsorReturn>(_data, 'RemoveEcosystemGasSponsorReturn')
1639
+ })
1640
+ },
1641
+ (error) => {
1642
+ throw WebrpcRequestFailedError.new({
1643
+ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`,
1644
+ })
1645
+ },
1646
+ )
1647
+ }
1648
+
1403
1649
  addressGasSponsors = (
1404
1650
  req: AddressGasSponsorsArgs,
1405
1651
  headers?: object,
1406
1652
  signal?: AbortSignal,
1407
1653
  ): Promise<AddressGasSponsorsReturn> => {
1408
- return this.fetch(
1409
- this.url('AddressGasSponsors'),
1410
- createHttpRequest(JsonEncode(req, 'AddressGasSponsorsArgs'), headers, signal),
1411
- ).then(
1654
+ return this.fetch(this.url('AddressGasSponsors'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1412
1655
  (res) => {
1413
1656
  return buildResponse(res).then((_data) => {
1414
1657
  return JsonDecode<AddressGasSponsorsReturn>(_data, 'AddressGasSponsorsReturn')
@@ -1427,10 +1670,7 @@ export class Relayer implements RelayerClient {
1427
1670
  headers?: object,
1428
1671
  signal?: AbortSignal,
1429
1672
  ): Promise<GetProjectBalanceReturn> => {
1430
- return this.fetch(
1431
- this.url('GetProjectBalance'),
1432
- createHttpRequest(JsonEncode(req, 'GetProjectBalanceArgs'), headers, signal),
1433
- ).then(
1673
+ return this.fetch(this.url('GetProjectBalance'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1434
1674
  (res) => {
1435
1675
  return buildResponse(res).then((_data) => {
1436
1676
  return JsonDecode<GetProjectBalanceReturn>(_data, 'GetProjectBalanceReturn')
@@ -1449,10 +1689,7 @@ export class Relayer implements RelayerClient {
1449
1689
  headers?: object,
1450
1690
  signal?: AbortSignal,
1451
1691
  ): Promise<AdjustProjectBalanceReturn> => {
1452
- return this.fetch(
1453
- this.url('AdjustProjectBalance'),
1454
- createHttpRequest(JsonEncode(req, 'AdjustProjectBalanceArgs'), headers, signal),
1455
- ).then(
1692
+ return this.fetch(this.url('AdjustProjectBalance'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1456
1693
  (res) => {
1457
1694
  return buildResponse(res).then((_data) => {
1458
1695
  return JsonDecode<AdjustProjectBalanceReturn>(_data, 'AdjustProjectBalanceReturn')
@@ -1468,7 +1705,11 @@ export class Relayer implements RelayerClient {
1468
1705
  }
1469
1706
 
1470
1707
  const createHttpRequest = (body: string = '{}', headers: object = {}, signal: AbortSignal | null = null): object => {
1471
- const reqHeaders: { [key: string]: string } = { ...headers, 'Content-Type': 'application/json' }
1708
+ const reqHeaders: { [key: string]: string } = {
1709
+ ...headers,
1710
+ 'Content-Type': 'application/json',
1711
+ [WebrpcHeader]: WebrpcHeaderValue,
1712
+ }
1472
1713
  return { method: 'POST', headers: reqHeaders, body, signal }
1473
1714
  }
1474
1715
 
@@ -1499,44 +1740,11 @@ export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response
1499
1740
 
1500
1741
  const BIG_INT_FIELDS: { [typ: string]: (string | [string, string])[] } = {
1501
1742
  SendMetaTxnArgs: [['preconditions', 'TransactionPrecondition[]']],
1743
+ SendMetaTxnWithBridgeGasArgs: [['preconditions', 'TransactionPrecondition[]']],
1502
1744
  TransactionPrecondition: ['minAmount'],
1503
1745
  Transactions: [['preconditions', 'TransactionPrecondition[]']],
1504
1746
  }
1505
1747
 
1506
- // Encode in-place: mutate provided object graph to serialize bigints to strings.
1507
- function encodeType(typ: string, obj: any): any {
1508
- if (obj == null || typeof obj !== 'object') return obj
1509
- const descs = BIG_INT_FIELDS[typ] || []
1510
- if (!descs.length) return obj
1511
- for (const d of descs) {
1512
- if (Array.isArray(d)) {
1513
- const [fieldName, nestedType] = d
1514
- if (fieldName.endsWith('[]')) {
1515
- const base = fieldName.slice(0, -2)
1516
- const arr = obj[base]
1517
- if (Array.isArray(arr)) {
1518
- for (let i = 0; i < arr.length; i++) arr[i] = encodeType(nestedType, arr[i])
1519
- }
1520
- } else if (obj[fieldName]) {
1521
- obj[fieldName] = encodeType(nestedType, obj[fieldName])
1522
- }
1523
- continue
1524
- }
1525
- if (d.endsWith('[]')) {
1526
- const base = d.slice(0, -2)
1527
- const arr = obj[base]
1528
- if (Array.isArray(arr)) {
1529
- for (let i = 0; i < arr.length; i++) {
1530
- if (typeof arr[i] === 'bigint') arr[i] = arr[i].toString()
1531
- }
1532
- }
1533
- continue
1534
- }
1535
- if (typeof obj[d] === 'bigint') obj[d] = obj[d].toString()
1536
- }
1537
- return obj
1538
- }
1539
-
1540
1748
  // Decode in-place: mutate object graph; throw if expected numeric string is invalid.
1541
1749
  function decodeType(typ: string, obj: any): any {
1542
1750
  if (obj == null || typeof obj !== 'object') return obj
@@ -1552,7 +1760,16 @@ function decodeType(typ: string, obj: any): any {
1552
1760
  for (let i = 0; i < arr.length; i++) arr[i] = decodeType(nestedType, arr[i])
1553
1761
  }
1554
1762
  } else if (obj[fieldName]) {
1555
- obj[fieldName] = decodeType(nestedType, obj[fieldName])
1763
+ // Handle nestedType that might be an array type like 'Message[]'
1764
+ if (nestedType.endsWith('[]')) {
1765
+ const baseType = nestedType.slice(0, -2)
1766
+ const arr = obj[fieldName]
1767
+ if (Array.isArray(arr)) {
1768
+ for (let i = 0; i < arr.length; i++) arr[i] = decodeType(baseType, arr[i])
1769
+ }
1770
+ } else {
1771
+ obj[fieldName] = decodeType(nestedType, obj[fieldName])
1772
+ }
1556
1773
  }
1557
1774
  continue
1558
1775
  }
@@ -1585,9 +1802,9 @@ function decodeType(typ: string, obj: any): any {
1585
1802
  return obj
1586
1803
  }
1587
1804
 
1588
- // Encode object of given root type to JSON with BigInts converted to decimal strings.
1589
- export const JsonEncode = <T = any>(obj: T, typ: string = ''): string => {
1590
- return JSON.stringify(encodeType(typ, obj))
1805
+ // Encode object to JSON with BigInts converted to decimal strings.
1806
+ export const JsonEncode = <T = any>(obj: T): string => {
1807
+ return JSON.stringify(obj, (key, value) => (typeof value === 'bigint' ? value.toString() : value))
1591
1808
  }
1592
1809
 
1593
1810
  // Decode data (JSON string or already-parsed object) and convert declared BigInt string fields back to BigInt.
@@ -1890,7 +2107,7 @@ export class AccessKeyMismatchError extends WebrpcError {
1890
2107
  this.name = error.name || 'AccessKeyMismatch'
1891
2108
  this.code = typeof error.code === 'number' ? error.code : 1102
1892
2109
  this.message = error.message || `Access key mismatch`
1893
- this.status = typeof error.status === 'number' ? error.status : 409
2110
+ this.status = typeof error.status === 'number' ? error.status : 403
1894
2111
  if (error.cause !== undefined) this.cause = error.cause
1895
2112
  Object.setPrototypeOf(this, AccessKeyMismatchError.prototype)
1896
2113
  }
@@ -1932,6 +2149,18 @@ export class UnauthorizedUserError extends WebrpcError {
1932
2149
  }
1933
2150
  }
1934
2151
 
2152
+ export class InvalidChainError extends WebrpcError {
2153
+ constructor(error: WebrpcErrorParams = {}) {
2154
+ super(error)
2155
+ this.name = error.name || 'InvalidChain'
2156
+ this.code = typeof error.code === 'number' ? error.code : 1106
2157
+ this.message = error.message || `Network not enabled for Access key`
2158
+ this.status = typeof error.status === 'number' ? error.status : 403
2159
+ if (error.cause !== undefined) this.cause = error.cause
2160
+ Object.setPrototypeOf(this, InvalidChainError.prototype)
2161
+ }
2162
+ }
2163
+
1935
2164
  export class QuotaExceededError extends WebrpcError {
1936
2165
  constructor(error: WebrpcErrorParams = {}) {
1937
2166
  super(error)
@@ -2114,6 +2343,7 @@ export enum errors {
2114
2343
  InvalidOrigin = 'InvalidOrigin',
2115
2344
  InvalidService = 'InvalidService',
2116
2345
  UnauthorizedUser = 'UnauthorizedUser',
2346
+ InvalidChain = 'InvalidChain',
2117
2347
  QuotaExceeded = 'QuotaExceeded',
2118
2348
  QuotaRateLimit = 'QuotaRateLimit',
2119
2349
  NoDefaultKey = 'NoDefaultKey',
@@ -2155,6 +2385,7 @@ export enum WebrpcErrorCodes {
2155
2385
  InvalidOrigin = 1103,
2156
2386
  InvalidService = 1104,
2157
2387
  UnauthorizedUser = 1105,
2388
+ InvalidChain = 1106,
2158
2389
  QuotaExceeded = 1200,
2159
2390
  QuotaRateLimit = 1201,
2160
2391
  NoDefaultKey = 1300,
@@ -2196,6 +2427,7 @@ export const webrpcErrorByCode: { [code: number]: any } = {
2196
2427
  [1103]: InvalidOriginError,
2197
2428
  [1104]: InvalidServiceError,
2198
2429
  [1105]: UnauthorizedUserError,
2430
+ [1106]: InvalidChainError,
2199
2431
  [1200]: QuotaExceededError,
2200
2432
  [1201]: QuotaRateLimitError,
2201
2433
  [1300]: NoDefaultKeyError,
@@ -2217,7 +2449,7 @@ export const webrpcErrorByCode: { [code: number]: any } = {
2217
2449
 
2218
2450
  export const WebrpcHeader = 'Webrpc'
2219
2451
 
2220
- export const WebrpcHeaderValue = 'webrpc@v0.30.2;gen-typescript@v0.22.2;sequence-relayer@v0.4.1'
2452
+ export const WebrpcHeaderValue = 'webrpc@v0.32.2;gen-typescript@v0.23.1;sequence-relayer@v0.4.1'
2221
2453
 
2222
2454
  type WebrpcGenVersions = {
2223
2455
  WebrpcGenVersion: string