@0xsequence/relayer 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -180,7 +180,7 @@ class LocalRelayer extends ProviderRelayer {
180
180
  provider: options.signer.provider
181
181
  }));
182
182
  this.signer = ethers.Signer.isSigner(options) ? options : options.signer;
183
- if (!this.signer.provider) throw new Error("Signer must have a provider");
183
+ if (!this.signer.provider) throw new Error('Signer must have a provider');
184
184
  }
185
185
  async getFeeOptions(_address, ..._transactions) {
186
186
  return {
@@ -236,13 +236,13 @@ class LocalRelayer extends ProviderRelayer {
236
236
  // webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts
237
237
 
238
238
  // WebRPC description and code-gen version
239
- const WebRPCVersion = "v1";
239
+ const WebRPCVersion = 'v1';
240
240
 
241
241
  // Schema version of your RIDL schema
242
- const WebRPCSchemaVersion = "v0.4.0";
242
+ const WebRPCSchemaVersion = 'v0.4.0';
243
243
 
244
244
  // Schema hash generated from your RIDL schema
245
- const WebRPCSchemaHash = "752f4f4274ca80d2fd974b5b44ed8245dfe40554";
245
+ const WebRPCSchemaHash = '752f4f4274ca80d2fd974b5b44ed8245dfe40554';
246
246
 
247
247
  //
248
248
  // Types
@@ -180,7 +180,7 @@ class LocalRelayer extends ProviderRelayer {
180
180
  provider: options.signer.provider
181
181
  }));
182
182
  this.signer = ethers.Signer.isSigner(options) ? options : options.signer;
183
- if (!this.signer.provider) throw new Error("Signer must have a provider");
183
+ if (!this.signer.provider) throw new Error('Signer must have a provider');
184
184
  }
185
185
  async getFeeOptions(_address, ..._transactions) {
186
186
  return {
@@ -236,13 +236,13 @@ class LocalRelayer extends ProviderRelayer {
236
236
  // webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts
237
237
 
238
238
  // WebRPC description and code-gen version
239
- const WebRPCVersion = "v1";
239
+ const WebRPCVersion = 'v1';
240
240
 
241
241
  // Schema version of your RIDL schema
242
- const WebRPCSchemaVersion = "v0.4.0";
242
+ const WebRPCSchemaVersion = 'v0.4.0';
243
243
 
244
244
  // Schema hash generated from your RIDL schema
245
- const WebRPCSchemaHash = "752f4f4274ca80d2fd974b5b44ed8245dfe40554";
245
+ const WebRPCSchemaHash = '752f4f4274ca80d2fd974b5b44ed8245dfe40554';
246
246
 
247
247
  //
248
248
  // Types
@@ -176,7 +176,7 @@ class LocalRelayer extends ProviderRelayer {
176
176
  provider: options.signer.provider
177
177
  }));
178
178
  this.signer = Signer.isSigner(options) ? options : options.signer;
179
- if (!this.signer.provider) throw new Error("Signer must have a provider");
179
+ if (!this.signer.provider) throw new Error('Signer must have a provider');
180
180
  }
181
181
  async getFeeOptions(_address, ..._transactions) {
182
182
  return {
@@ -232,13 +232,13 @@ class LocalRelayer extends ProviderRelayer {
232
232
  // webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts
233
233
 
234
234
  // WebRPC description and code-gen version
235
- const WebRPCVersion = "v1";
235
+ const WebRPCVersion = 'v1';
236
236
 
237
237
  // Schema version of your RIDL schema
238
- const WebRPCSchemaVersion = "v0.4.0";
238
+ const WebRPCSchemaVersion = 'v0.4.0';
239
239
 
240
240
  // Schema hash generated from your RIDL schema
241
- const WebRPCSchemaHash = "752f4f4274ca80d2fd974b5b44ed8245dfe40554";
241
+ const WebRPCSchemaHash = '752f4f4274ca80d2fd974b5b44ed8245dfe40554';
242
242
 
243
243
  //
244
244
  // Types
@@ -2,7 +2,7 @@ import { Signer as AbstractSigner, providers, BytesLike } from 'ethers';
2
2
  import { FeeOption, FeeQuote, Relayer } from "./index.js";
3
3
  import { ProviderRelayer, ProviderRelayerOptions } from "./provider-relayer.js";
4
4
  import { commons } from '@0xsequence/core';
5
- export type LocalRelayerOptions = Omit<ProviderRelayerOptions, "provider"> & {
5
+ export type LocalRelayerOptions = Omit<ProviderRelayerOptions, 'provider'> & {
6
6
  signer: AbstractSigner;
7
7
  };
8
8
  export declare function isLocalRelayerOptions(obj: any): obj is LocalRelayerOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/relayer",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "relayer sub-package for Sequence",
5
5
  "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/relayer",
6
6
  "source": "src/index.ts",
@@ -9,9 +9,9 @@
9
9
  "author": "Horizon Blockchain Games",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
- "@0xsequence/abi": "1.1.0",
13
- "@0xsequence/utils": "1.1.0",
14
- "@0xsequence/core": "1.1.0"
12
+ "@0xsequence/abi": "1.1.2",
13
+ "@0xsequence/core": "1.1.2",
14
+ "@0xsequence/utils": "1.1.2"
15
15
  },
16
16
  "peerDependencies": {
17
17
  "ethers": ">=5.5 < 6"
@@ -19,8 +19,8 @@
19
19
  "devDependencies": {
20
20
  "@0xsequence/wallet-contracts": "^1.10.0",
21
21
  "ethers": "^5.7.2",
22
- "@0xsequence/tests": "1.1.0",
23
- "@0xsequence/signhub": "1.1.0"
22
+ "@0xsequence/signhub": "1.1.2",
23
+ "@0xsequence/tests": "1.1.2"
24
24
  },
25
25
  "files": [
26
26
  "src",
package/src/index.ts CHANGED
@@ -12,22 +12,16 @@ export interface Relayer {
12
12
  getFeeOptions(
13
13
  address: string,
14
14
  ...transactions: commons.transaction.Transaction[]
15
- ): Promise<{ options: FeeOption[], quote?: FeeQuote }>
15
+ ): Promise<{ options: FeeOption[]; quote?: FeeQuote }>
16
16
 
17
17
  // getFeeOptionsRaw returns the fee options that the relayer will accept as payment.
18
18
  // If a quote is returned, it may be passed back to the relayer for dispatch.
19
19
  // It doesn't make any assumptions about the transaction format.
20
- getFeeOptionsRaw(
21
- entrypoint: string,
22
- data: ethers.utils.BytesLike
23
- ): Promise<{ options: FeeOption[]; quote?: FeeQuote }>
20
+ getFeeOptionsRaw(entrypoint: string, data: ethers.utils.BytesLike): Promise<{ options: FeeOption[]; quote?: FeeQuote }>
24
21
 
25
22
  // gasRefundOptions returns the transactions which can be included to refund a
26
23
  // relayer for submitting your transaction to a network.
27
- gasRefundOptions(
28
- address: string,
29
- ...transactions: commons.transaction.Transaction[]
30
- ): Promise<FeeOption[]>
24
+ gasRefundOptions(address: string, ...transactions: commons.transaction.Transaction[]): Promise<FeeOption[]>
31
25
 
32
26
  // getNonce returns the transaction count/nonce for a wallet, encoded with nonce space.
33
27
  // If space is undefined, the relayer can choose a nonce space to encode the result with.
@@ -37,13 +31,22 @@ export interface Relayer {
37
31
  // relayer will submit the transaction(s) to the network and return the transaction response.
38
32
  // The quote should be the one returned from getFeeOptions, if any.
39
33
  // waitForReceipt must default to true.
40
- relay(signedTxs: commons.transaction.IntendedTransactionBundle, quote?: FeeQuote, waitForReceipt?: boolean): Promise<commons.transaction.TransactionResponse>
34
+ relay(
35
+ signedTxs: commons.transaction.IntendedTransactionBundle,
36
+ quote?: FeeQuote,
37
+ waitForReceipt?: boolean
38
+ ): Promise<commons.transaction.TransactionResponse>
41
39
 
42
40
  // wait for transaction confirmation
43
41
  // timeout is the maximum time to wait for the transaction response
44
42
  // delay is the polling interval, i.e. the time to wait between requests
45
43
  // maxFails is the maximum number of hard failures to tolerate before giving up
46
- wait(metaTxnId: string | commons.transaction.SignedTransactionBundle, timeout?: number, delay?: number, maxFails?: number): Promise<commons.transaction.TransactionResponse>
44
+ wait(
45
+ metaTxnId: string | commons.transaction.SignedTransactionBundle,
46
+ timeout?: number,
47
+ delay?: number,
48
+ maxFails?: number
49
+ ): Promise<commons.transaction.TransactionResponse>
47
50
  }
48
51
 
49
52
  export * from './local-relayer'
@@ -4,7 +4,7 @@ import { FeeOption, FeeQuote, Relayer } from '.'
4
4
  import { ProviderRelayer, ProviderRelayerOptions } from './provider-relayer'
5
5
  import { commons } from '@0xsequence/core'
6
6
 
7
- export type LocalRelayerOptions = Omit<ProviderRelayerOptions, "provider"> & {
7
+ export type LocalRelayerOptions = Omit<ProviderRelayerOptions, 'provider'> & {
8
8
  signer: AbstractSigner
9
9
  }
10
10
 
@@ -19,13 +19,10 @@ export class LocalRelayer extends ProviderRelayer implements Relayer {
19
19
  constructor(options: LocalRelayerOptions | AbstractSigner) {
20
20
  super(AbstractSigner.isSigner(options) ? { provider: options.provider! } : { ...options, provider: options.signer.provider! })
21
21
  this.signer = AbstractSigner.isSigner(options) ? options : options.signer
22
- if (!this.signer.provider) throw new Error("Signer must have a provider")
22
+ if (!this.signer.provider) throw new Error('Signer must have a provider')
23
23
  }
24
24
 
25
- async getFeeOptions(
26
- _address: string,
27
- ..._transactions: commons.transaction.Transaction[]
28
- ): Promise<{ options: FeeOption[] }> {
25
+ async getFeeOptions(_address: string, ..._transactions: commons.transaction.Transaction[]): Promise<{ options: FeeOption[] }> {
29
26
  return { options: [] }
30
27
  }
31
28
 
@@ -33,10 +30,7 @@ export class LocalRelayer extends ProviderRelayer implements Relayer {
33
30
  return { options: [] }
34
31
  }
35
32
 
36
- async gasRefundOptions(
37
- address: string,
38
- ...transactions:commons.transaction.Transaction[]
39
- ): Promise<FeeOption[]> {
33
+ async gasRefundOptions(address: string, ...transactions: commons.transaction.Transaction[]): Promise<FeeOption[]> {
40
34
  const { options } = await this.getFeeOptions(address, ...transactions)
41
35
  return options
42
36
  }
@@ -47,12 +41,13 @@ export class LocalRelayer extends ProviderRelayer implements Relayer {
47
41
 
48
42
  async relay(
49
43
  signedTxs: commons.transaction.IntendedTransactionBundle,
50
- quote?: FeeQuote, waitForReceipt: boolean = true
44
+ quote?: FeeQuote,
45
+ waitForReceipt: boolean = true
51
46
  ): Promise<commons.transaction.TransactionResponse<providers.TransactionReceipt>> {
52
47
  if (quote !== undefined) {
53
48
  logger.warn(`LocalRelayer doesn't accept fee quotes`)
54
49
  }
55
-
50
+
56
51
  const data = commons.transaction.encodeBundleExecData(signedTxs)
57
52
 
58
53
  // TODO: think about computing gas limit individually, summing together and passing across
@@ -7,9 +7,9 @@ import { commons } from '@0xsequence/core'
7
7
  const DEFAULT_GAS_LIMIT = ethers.BigNumber.from(800000)
8
8
 
9
9
  export interface ProviderRelayerOptions {
10
- provider: providers.Provider,
11
- waitPollRate?: number,
12
- deltaBlocksLog?: number,
10
+ provider: providers.Provider
11
+ waitPollRate?: number
12
+ deltaBlocksLog?: number
13
13
  fromBlockLog?: number
14
14
  }
15
15
 
@@ -37,50 +37,52 @@ export abstract class ProviderRelayer implements Relayer {
37
37
  abstract getFeeOptions(
38
38
  address: string,
39
39
  ...transactions: commons.transaction.Transaction[]
40
- ): Promise<{ options: FeeOption[], quote?: FeeQuote }>
40
+ ): Promise<{ options: FeeOption[]; quote?: FeeQuote }>
41
41
 
42
- abstract getFeeOptionsRaw(
43
- entrypoint: string,
44
- data: ethers.utils.BytesLike
45
- ): Promise<{ options: FeeOption[], quote?: FeeQuote }>
42
+ abstract getFeeOptionsRaw(entrypoint: string, data: ethers.utils.BytesLike): Promise<{ options: FeeOption[]; quote?: FeeQuote }>
46
43
 
47
- abstract gasRefundOptions(
48
- address: string,
49
- ...transactions: commons.transaction.Transaction[]
50
- ): Promise<FeeOption[]>
44
+ abstract gasRefundOptions(address: string, ...transactions: commons.transaction.Transaction[]): Promise<FeeOption[]>
51
45
 
52
- abstract relay(signedTxs: commons.transaction.IntendedTransactionBundle, quote?: FeeQuote, waitForReceipt?: boolean): Promise<commons.transaction.TransactionResponse>
46
+ abstract relay(
47
+ signedTxs: commons.transaction.IntendedTransactionBundle,
48
+ quote?: FeeQuote,
49
+ waitForReceipt?: boolean
50
+ ): Promise<commons.transaction.TransactionResponse>
53
51
 
54
52
  async simulate(wallet: string, ...transactions: commons.transaction.Transaction[]): Promise<SimulateResult[]> {
55
- return (await Promise.all(transactions.map(async tx => {
56
- // Respect gasLimit request of the transaction (as long as its not 0)
57
- if (tx.gasLimit && !ethers.BigNumber.from(tx.gasLimit || 0).eq(ethers.constants.Zero)) {
58
- return tx.gasLimit
59
- }
53
+ return (
54
+ await Promise.all(
55
+ transactions.map(async tx => {
56
+ // Respect gasLimit request of the transaction (as long as its not 0)
57
+ if (tx.gasLimit && !ethers.BigNumber.from(tx.gasLimit || 0).eq(ethers.constants.Zero)) {
58
+ return tx.gasLimit
59
+ }
60
60
 
61
- // Fee can't be estimated locally for delegateCalls
62
- if (tx.delegateCall) {
63
- return DEFAULT_GAS_LIMIT
64
- }
61
+ // Fee can't be estimated locally for delegateCalls
62
+ if (tx.delegateCall) {
63
+ return DEFAULT_GAS_LIMIT
64
+ }
65
65
 
66
- // Fee can't be estimated for self-called if wallet hasn't been deployed
67
- if (tx.to === wallet && await this.provider.getCode(wallet).then((code) => ethers.utils.arrayify(code).length === 0)) {
68
- return DEFAULT_GAS_LIMIT
69
- }
66
+ // Fee can't be estimated for self-called if wallet hasn't been deployed
67
+ if (tx.to === wallet && (await this.provider.getCode(wallet).then(code => ethers.utils.arrayify(code).length === 0))) {
68
+ return DEFAULT_GAS_LIMIT
69
+ }
70
70
 
71
- if (!this.provider) {
72
- throw new Error('signer.provider is not set, but is required')
73
- }
71
+ if (!this.provider) {
72
+ throw new Error('signer.provider is not set, but is required')
73
+ }
74
74
 
75
- // TODO: If the wallet address has been deployed, gas limits can be
76
- // estimated with more accurately by using self-calls with the batch transactions one by one
77
- return this.provider.estimateGas({
78
- from: wallet,
79
- to: tx.to,
80
- data: tx.data,
81
- value: tx.value
82
- })
83
- }))).map(gasLimit => ({
75
+ // TODO: If the wallet address has been deployed, gas limits can be
76
+ // estimated with more accurately by using self-calls with the batch transactions one by one
77
+ return this.provider.estimateGas({
78
+ from: wallet,
79
+ to: tx.to,
80
+ data: tx.data,
81
+ value: tx.value
82
+ })
83
+ })
84
+ )
85
+ ).map(gasLimit => ({
84
86
  executed: true,
85
87
  succeeded: true,
86
88
  gasUsed: ethers.BigNumber.from(gasLimit).toNumber(),
@@ -88,11 +90,7 @@ export abstract class ProviderRelayer implements Relayer {
88
90
  }))
89
91
  }
90
92
 
91
- async getNonce(
92
- address: string,
93
- space?: ethers.BigNumberish,
94
- blockTag?: providers.BlockTag
95
- ): Promise<ethers.BigNumberish> {
93
+ async getNonce(address: string, space?: ethers.BigNumberish, blockTag?: providers.BlockTag): Promise<ethers.BigNumberish> {
96
94
  if (!this.provider) {
97
95
  throw new Error('provider is not set')
98
96
  }
@@ -6,13 +6,13 @@
6
6
  // webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts
7
7
 
8
8
  // WebRPC description and code-gen version
9
- export const WebRPCVersion = "v1"
9
+ export const WebRPCVersion = 'v1'
10
10
 
11
11
  // Schema version of your RIDL schema
12
- export const WebRPCSchemaVersion = "v0.4.0"
12
+ export const WebRPCSchemaVersion = 'v0.4.0'
13
13
 
14
14
  // Schema hash generated from your RIDL schema
15
- export const WebRPCSchemaHash = "752f4f4274ca80d2fd974b5b44ed8245dfe40554"
15
+ export const WebRPCSchemaHash = '752f4f4274ca80d2fd974b5b44ed8245dfe40554'
16
16
 
17
17
  //
18
18
  // Types
@@ -71,8 +71,7 @@ export interface SenderStatus {
71
71
  active: boolean
72
72
  }
73
73
 
74
- export interface RuntimeChecks {
75
- }
74
+ export interface RuntimeChecks {}
76
75
 
77
76
  export interface SequenceContext {
78
77
  factory: string
@@ -133,8 +132,8 @@ export interface MetaTxnLog {
133
132
  minedAt: string
134
133
  target: string
135
134
  input: string
136
- txnArgs: {[key: string]: any}
137
- txnReceipt?: {[key: string]: any}
135
+ txnArgs: { [key: string]: any }
136
+ txnReceipt?: { [key: string]: any }
138
137
  walletAddress: string
139
138
  metaTxnNonce: string
140
139
  gasLimit: number
@@ -179,7 +178,7 @@ export interface Transaction {
179
178
  chainId: number
180
179
  metaTxnID?: string
181
180
  transfers?: Array<TxnLogTransfer>
182
- users?: {[key: string]: TxnLogUser}
181
+ users?: { [key: string]: TxnLogUser }
183
182
  timestamp: string
184
183
  }
185
184
 
@@ -265,35 +264,30 @@ export interface Relayer {
265
264
  reportGasSponsorUsage(args: ReportGasSponsorUsageArgs, headers?: object): Promise<ReportGasSponsorUsageReturn>
266
265
  }
267
266
 
268
- export interface PingArgs {
269
- }
267
+ export interface PingArgs {}
270
268
 
271
269
  export interface PingReturn {
272
- status: boolean
273
- }
274
- export interface VersionArgs {
270
+ status: boolean
275
271
  }
272
+ export interface VersionArgs {}
276
273
 
277
274
  export interface VersionReturn {
278
- version: Version
279
- }
280
- export interface RuntimeStatusArgs {
275
+ version: Version
281
276
  }
277
+ export interface RuntimeStatusArgs {}
282
278
 
283
279
  export interface RuntimeStatusReturn {
284
- status: RuntimeStatus
285
- }
286
- export interface GetSequenceContextArgs {
280
+ status: RuntimeStatus
287
281
  }
282
+ export interface GetSequenceContextArgs {}
288
283
 
289
284
  export interface GetSequenceContextReturn {
290
- data: SequenceContext
291
- }
292
- export interface GetChainIDArgs {
285
+ data: SequenceContext
293
286
  }
287
+ export interface GetChainIDArgs {}
294
288
 
295
289
  export interface GetChainIDReturn {
296
- chainID: number
290
+ chainID: number
297
291
  }
298
292
  export interface SendMetaTxnArgs {
299
293
  call: MetaTxn
@@ -302,7 +296,7 @@ export interface SendMetaTxnArgs {
302
296
 
303
297
  export interface SendMetaTxnReturn {
304
298
  status: boolean
305
- txnHash: string
299
+ txnHash: string
306
300
  }
307
301
  export interface GetMetaTxnNonceArgs {
308
302
  walletContractAddress: string
@@ -310,14 +304,14 @@ export interface GetMetaTxnNonceArgs {
310
304
  }
311
305
 
312
306
  export interface GetMetaTxnNonceReturn {
313
- nonce: string
307
+ nonce: string
314
308
  }
315
309
  export interface GetMetaTxnReceiptArgs {
316
310
  metaTxID: string
317
311
  }
318
312
 
319
313
  export interface GetMetaTxnReceiptReturn {
320
- receipt: MetaTxnReceipt
314
+ receipt: MetaTxnReceipt
321
315
  }
322
316
  export interface SimulateArgs {
323
317
  wallet: string
@@ -325,7 +319,7 @@ export interface SimulateArgs {
325
319
  }
326
320
 
327
321
  export interface SimulateReturn {
328
- results: Array<SimulateResult>
322
+ results: Array<SimulateResult>
329
323
  }
330
324
  export interface UpdateMetaTxnGasLimitsArgs {
331
325
  walletAddress: string
@@ -334,14 +328,13 @@ export interface UpdateMetaTxnGasLimitsArgs {
334
328
  }
335
329
 
336
330
  export interface UpdateMetaTxnGasLimitsReturn {
337
- payload: string
338
- }
339
- export interface FeeTokensArgs {
331
+ payload: string
340
332
  }
333
+ export interface FeeTokensArgs {}
341
334
 
342
335
  export interface FeeTokensReturn {
343
336
  isFeeRequired: boolean
344
- tokens: Array<FeeToken>
337
+ tokens: Array<FeeToken>
345
338
  }
346
339
  export interface FeeOptionsArgs {
347
340
  wallet: string
@@ -351,7 +344,7 @@ export interface FeeOptionsArgs {
351
344
 
352
345
  export interface FeeOptionsReturn {
353
346
  options: Array<FeeOption>
354
- quote?: string
347
+ quote?: string
355
348
  }
356
349
  export interface GetMetaTxnNetworkFeeOptionsArgs {
357
350
  walletConfig: WalletConfig
@@ -359,7 +352,7 @@ export interface GetMetaTxnNetworkFeeOptionsArgs {
359
352
  }
360
353
 
361
354
  export interface GetMetaTxnNetworkFeeOptionsReturn {
362
- options: Array<FeeOption>
355
+ options: Array<FeeOption>
363
356
  }
364
357
  export interface SentTransactionsArgs {
365
358
  filter?: SentTransactionsFilter
@@ -368,7 +361,7 @@ export interface SentTransactionsArgs {
368
361
 
369
362
  export interface SentTransactionsReturn {
370
363
  page: Page
371
- transactions: Array<Transaction>
364
+ transactions: Array<Transaction>
372
365
  }
373
366
  export interface PendingTransactionsArgs {
374
367
  page?: Page
@@ -376,7 +369,7 @@ export interface PendingTransactionsArgs {
376
369
 
377
370
  export interface PendingTransactionsReturn {
378
371
  page: Page
379
- transactions: Array<Transaction>
372
+ transactions: Array<Transaction>
380
373
  }
381
374
  export interface ListGasSponsorsArgs {
382
375
  page?: Page
@@ -384,7 +377,7 @@ export interface ListGasSponsorsArgs {
384
377
 
385
378
  export interface ListGasSponsorsReturn {
386
379
  page: Page
387
- gasSponsors: Array<GasSponsor>
380
+ gasSponsors: Array<GasSponsor>
388
381
  }
389
382
  export interface AddGasSponsorArgs {
390
383
  address: string
@@ -394,7 +387,7 @@ export interface AddGasSponsorArgs {
394
387
 
395
388
  export interface AddGasSponsorReturn {
396
389
  status: boolean
397
- gasSponsor: GasSponsor
390
+ gasSponsor: GasSponsor
398
391
  }
399
392
  export interface UpdateGasSponsorArgs {
400
393
  address: string
@@ -404,7 +397,7 @@ export interface UpdateGasSponsorArgs {
404
397
 
405
398
  export interface UpdateGasSponsorReturn {
406
399
  status: boolean
407
- gasSponsor: GasSponsor
400
+ gasSponsor: GasSponsor
408
401
  }
409
402
  export interface ReportGasSponsorUsageArgs {
410
403
  startTime?: string
@@ -412,11 +405,9 @@ export interface ReportGasSponsorUsageArgs {
412
405
  }
413
406
 
414
407
  export interface ReportGasSponsorUsageReturn {
415
- gasSponsorUsage: Array<GasSponsorUsage>
408
+ gasSponsorUsage: Array<GasSponsorUsage>
416
409
  }
417
410
 
418
-
419
-
420
411
  //
421
412
  // Client
422
413
  //
@@ -433,256 +424,213 @@ export class Relayer implements Relayer {
433
424
  private url(name: string): string {
434
425
  return this.hostname + this.path + name
435
426
  }
436
-
427
+
437
428
  ping = (headers?: object): Promise<PingReturn> => {
438
- return this.fetch(
439
- this.url('Ping'),
440
- createHTTPRequest({}, headers)
441
- ).then((res) => {
429
+ return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
442
430
  return buildResponse(res).then(_data => {
443
431
  return {
444
- status: <boolean>(_data.status)
432
+ status: <boolean>_data.status
445
433
  }
446
434
  })
447
435
  })
448
436
  }
449
-
437
+
450
438
  version = (headers?: object): Promise<VersionReturn> => {
451
- return this.fetch(
452
- this.url('Version'),
453
- createHTTPRequest({}, headers)
454
- ).then((res) => {
439
+ return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
455
440
  return buildResponse(res).then(_data => {
456
441
  return {
457
- version: <Version>(_data.version)
442
+ version: <Version>_data.version
458
443
  }
459
444
  })
460
445
  })
461
446
  }
462
-
447
+
463
448
  runtimeStatus = (headers?: object): Promise<RuntimeStatusReturn> => {
464
- return this.fetch(
465
- this.url('RuntimeStatus'),
466
- createHTTPRequest({}, headers)
467
- ).then((res) => {
449
+ return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
468
450
  return buildResponse(res).then(_data => {
469
451
  return {
470
- status: <RuntimeStatus>(_data.status)
452
+ status: <RuntimeStatus>_data.status
471
453
  }
472
454
  })
473
455
  })
474
456
  }
475
-
457
+
476
458
  getSequenceContext = (headers?: object): Promise<GetSequenceContextReturn> => {
477
- return this.fetch(
478
- this.url('GetSequenceContext'),
479
- createHTTPRequest({}, headers)
480
- ).then((res) => {
459
+ return this.fetch(this.url('GetSequenceContext'), createHTTPRequest({}, headers)).then(res => {
481
460
  return buildResponse(res).then(_data => {
482
461
  return {
483
- data: <SequenceContext>(_data.data)
462
+ data: <SequenceContext>_data.data
484
463
  }
485
464
  })
486
465
  })
487
466
  }
488
-
467
+
489
468
  getChainID = (headers?: object): Promise<GetChainIDReturn> => {
490
- return this.fetch(
491
- this.url('GetChainID'),
492
- createHTTPRequest({}, headers)
493
- ).then((res) => {
469
+ return this.fetch(this.url('GetChainID'), createHTTPRequest({}, headers)).then(res => {
494
470
  return buildResponse(res).then(_data => {
495
471
  return {
496
- chainID: <number>(_data.chainID)
472
+ chainID: <number>_data.chainID
497
473
  }
498
474
  })
499
475
  })
500
476
  }
501
-
477
+
502
478
  sendMetaTxn = (args: SendMetaTxnArgs, headers?: object): Promise<SendMetaTxnReturn> => {
503
- return this.fetch(
504
- this.url('SendMetaTxn'),
505
- createHTTPRequest(args, headers)).then((res) => {
479
+ return this.fetch(this.url('SendMetaTxn'), createHTTPRequest(args, headers)).then(res => {
506
480
  return buildResponse(res).then(_data => {
507
481
  return {
508
- status: <boolean>(_data.status),
509
- txnHash: <string>(_data.txnHash)
482
+ status: <boolean>_data.status,
483
+ txnHash: <string>_data.txnHash
510
484
  }
511
485
  })
512
486
  })
513
487
  }
514
-
488
+
515
489
  getMetaTxnNonce = (args: GetMetaTxnNonceArgs, headers?: object): Promise<GetMetaTxnNonceReturn> => {
516
- return this.fetch(
517
- this.url('GetMetaTxnNonce'),
518
- createHTTPRequest(args, headers)).then((res) => {
490
+ return this.fetch(this.url('GetMetaTxnNonce'), createHTTPRequest(args, headers)).then(res => {
519
491
  return buildResponse(res).then(_data => {
520
492
  return {
521
- nonce: <string>(_data.nonce)
493
+ nonce: <string>_data.nonce
522
494
  }
523
495
  })
524
496
  })
525
497
  }
526
-
498
+
527
499
  getMetaTxnReceipt = (args: GetMetaTxnReceiptArgs, headers?: object): Promise<GetMetaTxnReceiptReturn> => {
528
- return this.fetch(
529
- this.url('GetMetaTxnReceipt'),
530
- createHTTPRequest(args, headers)).then((res) => {
500
+ return this.fetch(this.url('GetMetaTxnReceipt'), createHTTPRequest(args, headers)).then(res => {
531
501
  return buildResponse(res).then(_data => {
532
502
  return {
533
- receipt: <MetaTxnReceipt>(_data.receipt)
503
+ receipt: <MetaTxnReceipt>_data.receipt
534
504
  }
535
505
  })
536
506
  })
537
507
  }
538
-
508
+
539
509
  simulate = (args: SimulateArgs, headers?: object): Promise<SimulateReturn> => {
540
- return this.fetch(
541
- this.url('Simulate'),
542
- createHTTPRequest(args, headers)).then((res) => {
510
+ return this.fetch(this.url('Simulate'), createHTTPRequest(args, headers)).then(res => {
543
511
  return buildResponse(res).then(_data => {
544
512
  return {
545
- results: <Array<SimulateResult>>(_data.results)
513
+ results: <Array<SimulateResult>>_data.results
546
514
  }
547
515
  })
548
516
  })
549
517
  }
550
-
518
+
551
519
  updateMetaTxnGasLimits = (args: UpdateMetaTxnGasLimitsArgs, headers?: object): Promise<UpdateMetaTxnGasLimitsReturn> => {
552
- return this.fetch(
553
- this.url('UpdateMetaTxnGasLimits'),
554
- createHTTPRequest(args, headers)).then((res) => {
520
+ return this.fetch(this.url('UpdateMetaTxnGasLimits'), createHTTPRequest(args, headers)).then(res => {
555
521
  return buildResponse(res).then(_data => {
556
522
  return {
557
- payload: <string>(_data.payload)
523
+ payload: <string>_data.payload
558
524
  }
559
525
  })
560
526
  })
561
527
  }
562
-
528
+
563
529
  feeTokens = (headers?: object): Promise<FeeTokensReturn> => {
564
- return this.fetch(
565
- this.url('FeeTokens'),
566
- createHTTPRequest({}, headers)
567
- ).then((res) => {
530
+ return this.fetch(this.url('FeeTokens'), createHTTPRequest({}, headers)).then(res => {
568
531
  return buildResponse(res).then(_data => {
569
532
  return {
570
- isFeeRequired: <boolean>(_data.isFeeRequired),
571
- tokens: <Array<FeeToken>>(_data.tokens)
533
+ isFeeRequired: <boolean>_data.isFeeRequired,
534
+ tokens: <Array<FeeToken>>_data.tokens
572
535
  }
573
536
  })
574
537
  })
575
538
  }
576
-
539
+
577
540
  feeOptions = (args: FeeOptionsArgs, headers?: object): Promise<FeeOptionsReturn> => {
578
- return this.fetch(
579
- this.url('FeeOptions'),
580
- createHTTPRequest(args, headers)).then((res) => {
541
+ return this.fetch(this.url('FeeOptions'), createHTTPRequest(args, headers)).then(res => {
581
542
  return buildResponse(res).then(_data => {
582
543
  return {
583
- options: <Array<FeeOption>>(_data.options),
584
- quote: <string>(_data.quote)
544
+ options: <Array<FeeOption>>_data.options,
545
+ quote: <string>_data.quote
585
546
  }
586
547
  })
587
548
  })
588
549
  }
589
-
590
- getMetaTxnNetworkFeeOptions = (args: GetMetaTxnNetworkFeeOptionsArgs, headers?: object): Promise<GetMetaTxnNetworkFeeOptionsReturn> => {
591
- return this.fetch(
592
- this.url('GetMetaTxnNetworkFeeOptions'),
593
- createHTTPRequest(args, headers)).then((res) => {
550
+
551
+ getMetaTxnNetworkFeeOptions = (
552
+ args: GetMetaTxnNetworkFeeOptionsArgs,
553
+ headers?: object
554
+ ): Promise<GetMetaTxnNetworkFeeOptionsReturn> => {
555
+ return this.fetch(this.url('GetMetaTxnNetworkFeeOptions'), createHTTPRequest(args, headers)).then(res => {
594
556
  return buildResponse(res).then(_data => {
595
557
  return {
596
- options: <Array<FeeOption>>(_data.options)
558
+ options: <Array<FeeOption>>_data.options
597
559
  }
598
560
  })
599
561
  })
600
562
  }
601
-
563
+
602
564
  sentTransactions = (args: SentTransactionsArgs, headers?: object): Promise<SentTransactionsReturn> => {
603
- return this.fetch(
604
- this.url('SentTransactions'),
605
- createHTTPRequest(args, headers)).then((res) => {
565
+ return this.fetch(this.url('SentTransactions'), createHTTPRequest(args, headers)).then(res => {
606
566
  return buildResponse(res).then(_data => {
607
567
  return {
608
- page: <Page>(_data.page),
609
- transactions: <Array<Transaction>>(_data.transactions)
568
+ page: <Page>_data.page,
569
+ transactions: <Array<Transaction>>_data.transactions
610
570
  }
611
571
  })
612
572
  })
613
573
  }
614
-
574
+
615
575
  pendingTransactions = (args: PendingTransactionsArgs, headers?: object): Promise<PendingTransactionsReturn> => {
616
- return this.fetch(
617
- this.url('PendingTransactions'),
618
- createHTTPRequest(args, headers)).then((res) => {
576
+ return this.fetch(this.url('PendingTransactions'), createHTTPRequest(args, headers)).then(res => {
619
577
  return buildResponse(res).then(_data => {
620
578
  return {
621
- page: <Page>(_data.page),
622
- transactions: <Array<Transaction>>(_data.transactions)
579
+ page: <Page>_data.page,
580
+ transactions: <Array<Transaction>>_data.transactions
623
581
  }
624
582
  })
625
583
  })
626
584
  }
627
-
585
+
628
586
  listGasSponsors = (args: ListGasSponsorsArgs, headers?: object): Promise<ListGasSponsorsReturn> => {
629
- return this.fetch(
630
- this.url('ListGasSponsors'),
631
- createHTTPRequest(args, headers)).then((res) => {
587
+ return this.fetch(this.url('ListGasSponsors'), createHTTPRequest(args, headers)).then(res => {
632
588
  return buildResponse(res).then(_data => {
633
589
  return {
634
- page: <Page>(_data.page),
635
- gasSponsors: <Array<GasSponsor>>(_data.gasSponsors)
590
+ page: <Page>_data.page,
591
+ gasSponsors: <Array<GasSponsor>>_data.gasSponsors
636
592
  }
637
593
  })
638
594
  })
639
595
  }
640
-
596
+
641
597
  addGasSponsor = (args: AddGasSponsorArgs, headers?: object): Promise<AddGasSponsorReturn> => {
642
- return this.fetch(
643
- this.url('AddGasSponsor'),
644
- createHTTPRequest(args, headers)).then((res) => {
598
+ return this.fetch(this.url('AddGasSponsor'), createHTTPRequest(args, headers)).then(res => {
645
599
  return buildResponse(res).then(_data => {
646
600
  return {
647
- status: <boolean>(_data.status),
648
- gasSponsor: <GasSponsor>(_data.gasSponsor)
601
+ status: <boolean>_data.status,
602
+ gasSponsor: <GasSponsor>_data.gasSponsor
649
603
  }
650
604
  })
651
605
  })
652
606
  }
653
-
607
+
654
608
  updateGasSponsor = (args: UpdateGasSponsorArgs, headers?: object): Promise<UpdateGasSponsorReturn> => {
655
- return this.fetch(
656
- this.url('UpdateGasSponsor'),
657
- createHTTPRequest(args, headers)).then((res) => {
609
+ return this.fetch(this.url('UpdateGasSponsor'), createHTTPRequest(args, headers)).then(res => {
658
610
  return buildResponse(res).then(_data => {
659
611
  return {
660
- status: <boolean>(_data.status),
661
- gasSponsor: <GasSponsor>(_data.gasSponsor)
612
+ status: <boolean>_data.status,
613
+ gasSponsor: <GasSponsor>_data.gasSponsor
662
614
  }
663
615
  })
664
616
  })
665
617
  }
666
-
618
+
667
619
  reportGasSponsorUsage = (args: ReportGasSponsorUsageArgs, headers?: object): Promise<ReportGasSponsorUsageReturn> => {
668
- return this.fetch(
669
- this.url('ReportGasSponsorUsage'),
670
- createHTTPRequest(args, headers)).then((res) => {
620
+ return this.fetch(this.url('ReportGasSponsorUsage'), createHTTPRequest(args, headers)).then(res => {
671
621
  return buildResponse(res).then(_data => {
672
622
  return {
673
- gasSponsorUsage: <Array<GasSponsorUsage>>(_data.gasSponsorUsage)
623
+ gasSponsorUsage: <Array<GasSponsorUsage>>_data.gasSponsorUsage
674
624
  }
675
625
  })
676
626
  })
677
627
  }
678
-
679
628
  }
680
629
 
681
-
682
630
  export interface WebRPCError extends Error {
683
631
  code: string
684
632
  msg: string
685
- status: number
633
+ status: number
686
634
  }
687
635
 
688
636
  const createHTTPRequest = (body: object = {}, headers: object = {}): object => {
@@ -698,7 +646,7 @@ const buildResponse = (res: Response): Promise<any> => {
698
646
  let data
699
647
  try {
700
648
  data = JSON.parse(text)
701
- } catch(err) {
649
+ } catch (err) {
702
650
  throw { code: 'unknown', msg: `expecting JSON, got: ${text}`, status: res.status } as WebRPCError
703
651
  }
704
652
  if (!res.ok) {