From 49f39c8e31cc390bc9473ecf507e8134d2dd71bf Mon Sep 17 00:00:00 2001 From: klaidliadon <5322228+klaidliadon@users.noreply.github.com> Date: Mon, 13 Jan 2025 15:58:11 +0000 Subject: [PATCH] [AUTOMATED] Update: relayer/proto/clients/relayer.gen.ts --- .../relayer/src/rpc-relayer/relayer.gen.ts | 1106 ++++++++--------- 1 file changed, 506 insertions(+), 600 deletions(-) diff --git a/packages/relayer/src/rpc-relayer/relayer.gen.ts b/packages/relayer/src/rpc-relayer/relayer.gen.ts index 66a6f195e..0c1b90cef 100644 --- a/packages/relayer/src/rpc-relayer/relayer.gen.ts +++ b/packages/relayer/src/rpc-relayer/relayer.gen.ts @@ -1,23 +1,24 @@ /* eslint-disable */ -// sequence-relayer v0.4.1 7f94f0984b0dfe97d4f16c7f27cdd899f2467649 +// sequence-relayer v0.4.1 904b2d766c6deda7180931a1bb558929502143fc // -- // Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT. // // webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts // WebRPC description and code-gen version -export const WebRPCVersion = 'v1' +export const WebRPCVersion = "v1" // Schema version of your RIDL schema -export const WebRPCSchemaVersion = 'v0.4.1' +export const WebRPCSchemaVersion = "v0.4.1" // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = '7f94f0984b0dfe97d4f16c7f27cdd899f2467649' +export const WebRPCSchemaHash = "904b2d766c6deda7180931a1bb558929502143fc" // // Types // + export enum ETHTxnStatus { UNKNOWN = 'UNKNOWN', DROPPED = 'DROPPED', @@ -75,7 +76,8 @@ export interface SenderStatus { active: boolean } -export interface RuntimeChecks {} +export interface RuntimeChecks { +} export interface SequenceContext { factory: string @@ -131,7 +133,6 @@ export interface GasSponsorUsage { } export interface MetaTxn { - chainId: number walletAddress: string contract: string input: string @@ -152,8 +153,8 @@ export interface MetaTxnLog { minedAt: string target: string input: string - txnArgs: { [key: string]: any } - txnReceipt?: { [key: string]: any } + txnArgs: {[key: string]: any} + txnReceipt?: {[key: string]: any} walletAddress: string metaTxnNonce: string gasLimit: number @@ -192,7 +193,7 @@ export interface Transaction { chainId: number metaTxnID?: string transfers?: Array - users?: { [key: string]: TxnLogUser } + users?: {[key: string]: TxnLogUser} timestamp: string } @@ -267,18 +268,10 @@ export interface Relayer { getMetaTxnNonce(args: GetMetaTxnNonceArgs, headers?: object, signal?: AbortSignal): Promise getMetaTxnReceipt(args: GetMetaTxnReceiptArgs, headers?: object, signal?: AbortSignal): Promise simulate(args: SimulateArgs, headers?: object, signal?: AbortSignal): Promise - updateMetaTxnGasLimits( - args: UpdateMetaTxnGasLimitsArgs, - headers?: object, - signal?: AbortSignal - ): Promise + updateMetaTxnGasLimits(args: UpdateMetaTxnGasLimitsArgs, headers?: object, signal?: AbortSignal): Promise feeTokens(headers?: object, signal?: AbortSignal): Promise feeOptions(args: FeeOptionsArgs, headers?: object, signal?: AbortSignal): Promise - getMetaTxnNetworkFeeOptions( - args: GetMetaTxnNetworkFeeOptionsArgs, - headers?: object, - signal?: AbortSignal - ): Promise + getMetaTxnNetworkFeeOptions(args: GetMetaTxnNetworkFeeOptionsArgs, headers?: object, signal?: AbortSignal): Promise getMetaTransactions(args: GetMetaTransactionsArgs, headers?: object, signal?: AbortSignal): Promise getTransactionCost(args: GetTransactionCostArgs, headers?: object, signal?: AbortSignal): Promise sentTransactions(args: SentTransactionsArgs, headers?: object, signal?: AbortSignal): Promise @@ -292,63 +285,44 @@ export interface Relayer { addGasSponsor(args: AddGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise updateGasSponsor(args: UpdateGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise removeGasSponsor(args: RemoveGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise - reportGasSponsorUsage( - args: ReportGasSponsorUsageArgs, - headers?: object, - signal?: AbortSignal - ): Promise - nextGasTankBalanceAdjustmentNonce( - args: NextGasTankBalanceAdjustmentNonceArgs, - headers?: object, - signal?: AbortSignal - ): Promise - adjustGasTankBalance( - args: AdjustGasTankBalanceArgs, - headers?: object, - signal?: AbortSignal - ): Promise - getGasTankBalanceAdjustment( - args: GetGasTankBalanceAdjustmentArgs, - headers?: object, - signal?: AbortSignal - ): Promise - listGasTankBalanceAdjustments( - args: ListGasTankBalanceAdjustmentsArgs, - headers?: object, - signal?: AbortSignal - ): Promise + reportGasSponsorUsage(args: ReportGasSponsorUsageArgs, headers?: object, signal?: AbortSignal): Promise + nextGasTankBalanceAdjustmentNonce(args: NextGasTankBalanceAdjustmentNonceArgs, headers?: object, signal?: AbortSignal): Promise + adjustGasTankBalance(args: AdjustGasTankBalanceArgs, headers?: object, signal?: AbortSignal): Promise + getGasTankBalanceAdjustment(args: GetGasTankBalanceAdjustmentArgs, headers?: object, signal?: AbortSignal): Promise + listGasTankBalanceAdjustments(args: ListGasTankBalanceAdjustmentsArgs, headers?: object, signal?: AbortSignal): Promise getProjectBalance(args: GetProjectBalanceArgs, headers?: object, signal?: AbortSignal): Promise - adjustProjectBalance( - args: AdjustProjectBalanceArgs, - headers?: object, - signal?: AbortSignal - ): Promise + adjustProjectBalance(args: AdjustProjectBalanceArgs, headers?: object, signal?: AbortSignal): Promise } -export interface PingArgs {} +export interface PingArgs { +} export interface PingReturn { - status: boolean + status: boolean +} +export interface VersionArgs { } -export interface VersionArgs {} export interface VersionReturn { - version: Version + version: Version +} +export interface RuntimeStatusArgs { } -export interface RuntimeStatusArgs {} export interface RuntimeStatusReturn { - status: RuntimeStatus + status: RuntimeStatus +} +export interface GetSequenceContextArgs { } -export interface GetSequenceContextArgs {} export interface GetSequenceContextReturn { - data: SequenceContext + data: SequenceContext +} +export interface GetChainIDArgs { } -export interface GetChainIDArgs {} export interface GetChainIDReturn { - chainID: number + chainID: number } export interface SendMetaTxnArgs { call: MetaTxn @@ -358,7 +332,7 @@ export interface SendMetaTxnArgs { export interface SendMetaTxnReturn { status: boolean - txnHash: string + txnHash: string } export interface GetMetaTxnNonceArgs { walletContractAddress: string @@ -366,14 +340,14 @@ export interface GetMetaTxnNonceArgs { } export interface GetMetaTxnNonceReturn { - nonce: string + nonce: string } export interface GetMetaTxnReceiptArgs { metaTxID: string } export interface GetMetaTxnReceiptReturn { - receipt: MetaTxnReceipt + receipt: MetaTxnReceipt } export interface SimulateArgs { wallet: string @@ -381,7 +355,7 @@ export interface SimulateArgs { } export interface SimulateReturn { - results: Array + results: Array } export interface UpdateMetaTxnGasLimitsArgs { walletAddress: string @@ -390,13 +364,14 @@ export interface UpdateMetaTxnGasLimitsArgs { } export interface UpdateMetaTxnGasLimitsReturn { - payload: string + payload: string +} +export interface FeeTokensArgs { } -export interface FeeTokensArgs {} export interface FeeTokensReturn { isFeeRequired: boolean - tokens: Array + tokens: Array } export interface FeeOptionsArgs { wallet: string @@ -408,7 +383,7 @@ export interface FeeOptionsArgs { export interface FeeOptionsReturn { options: Array sponsored: boolean - quote?: string + quote?: string } export interface GetMetaTxnNetworkFeeOptionsArgs { walletConfig: any @@ -416,7 +391,7 @@ export interface GetMetaTxnNetworkFeeOptionsArgs { } export interface GetMetaTxnNetworkFeeOptionsReturn { - options: Array + options: Array } export interface GetMetaTransactionsArgs { projectId: number @@ -426,7 +401,7 @@ export interface GetMetaTransactionsArgs { export interface GetMetaTransactionsReturn { page: Page - transactions: Array + transactions: Array } export interface GetTransactionCostArgs { projectId: number @@ -435,7 +410,7 @@ export interface GetTransactionCostArgs { } export interface GetTransactionCostReturn { - cost: number + cost: number } export interface SentTransactionsArgs { filter?: SentTransactionsFilter @@ -444,7 +419,7 @@ export interface SentTransactionsArgs { export interface SentTransactionsReturn { page: Page - transactions: Array + transactions: Array } export interface PendingTransactionsArgs { page?: Page @@ -452,14 +427,14 @@ export interface PendingTransactionsArgs { export interface PendingTransactionsReturn { page: Page - transactions: Array + transactions: Array } export interface GetGasTankArgs { id: number } export interface GetGasTankReturn { - gasTank: GasTank + gasTank: GasTank } export interface AddGasTankArgs { name: string @@ -469,7 +444,7 @@ export interface AddGasTankArgs { export interface AddGasTankReturn { status: boolean - gasTank: GasTank + gasTank: GasTank } export interface UpdateGasTankArgs { id: number @@ -480,14 +455,14 @@ export interface UpdateGasTankArgs { export interface UpdateGasTankReturn { status: boolean - gasTank: GasTank + gasTank: GasTank } export interface GetGasSponsorArgs { id: number } export interface GetGasSponsorReturn { - gasSponsor: GasSponsor + gasSponsor: GasSponsor } export interface AddressGasSponsorsArgs { address: string @@ -496,7 +471,7 @@ export interface AddressGasSponsorsArgs { export interface AddressGasSponsorsReturn { page: Page - gasSponsors: Array + gasSponsors: Array } export interface ListGasSponsorsArgs { projectId: number @@ -506,7 +481,7 @@ export interface ListGasSponsorsArgs { export interface ListGasSponsorsReturn { page: Page - gasSponsors: Array + gasSponsors: Array } export interface AddGasSponsorArgs { projectId: number @@ -518,7 +493,7 @@ export interface AddGasSponsorArgs { export interface AddGasSponsorReturn { status: boolean - gasSponsor: GasSponsor + gasSponsor: GasSponsor } export interface UpdateGasSponsorArgs { id: number @@ -528,14 +503,14 @@ export interface UpdateGasSponsorArgs { export interface UpdateGasSponsorReturn { status: boolean - gasSponsor: GasSponsor + gasSponsor: GasSponsor } export interface RemoveGasSponsorArgs { id: number } export interface RemoveGasSponsorReturn { - status: boolean + status: boolean } export interface ReportGasSponsorUsageArgs { projectId: number @@ -545,14 +520,14 @@ export interface ReportGasSponsorUsageArgs { } export interface ReportGasSponsorUsageReturn { - gasSponsorUsage: Array + gasSponsorUsage: Array } export interface NextGasTankBalanceAdjustmentNonceArgs { id: number } export interface NextGasTankBalanceAdjustmentNonceReturn { - nonce: number + nonce: number } export interface AdjustGasTankBalanceArgs { id: number @@ -562,7 +537,7 @@ export interface AdjustGasTankBalanceArgs { export interface AdjustGasTankBalanceReturn { status: boolean - adjustment: GasTankBalanceAdjustment + adjustment: GasTankBalanceAdjustment } export interface GetGasTankBalanceAdjustmentArgs { id: number @@ -570,7 +545,7 @@ export interface GetGasTankBalanceAdjustmentArgs { } export interface GetGasTankBalanceAdjustmentReturn { - adjustment: GasTankBalanceAdjustment + adjustment: GasTankBalanceAdjustment } export interface ListGasTankBalanceAdjustmentsArgs { id: number @@ -579,14 +554,14 @@ export interface ListGasTankBalanceAdjustmentsArgs { export interface ListGasTankBalanceAdjustmentsReturn { page: Page - adjustments: Array + adjustments: Array } export interface GetProjectBalanceArgs { projectId: number } export interface GetProjectBalanceReturn { - balance: number + balance: number } export interface AdjustProjectBalanceArgs { projectId: number @@ -595,9 +570,11 @@ export interface AdjustProjectBalanceArgs { } export interface AdjustProjectBalanceReturn { - balance: number + balance: number } + + // // Client // @@ -614,567 +591,493 @@ export class Relayer implements Relayer { private url(name: string): string { return this.hostname + this.path + name } - + ping = (headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - status: _data.status - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('Ping'), + createHTTPRequest({}, headers, signal) + ).then((res) => { + return buildResponse(res).then(_data => { + return { + status: (_data.status), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + version = (headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - version: _data.version - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('Version'), + createHTTPRequest({}, headers, signal) + ).then((res) => { + return buildResponse(res).then(_data => { + return { + version: (_data.version), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + runtimeStatus = (headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - status: _data.status - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('RuntimeStatus'), + createHTTPRequest({}, headers, signal) + ).then((res) => { + return buildResponse(res).then(_data => { + return { + status: (_data.status), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + getSequenceContext = (headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('GetSequenceContext'), createHTTPRequest({}, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - data: _data.data - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('GetSequenceContext'), + createHTTPRequest({}, headers, signal) + ).then((res) => { + return buildResponse(res).then(_data => { + return { + data: (_data.data), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + getChainID = (headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('GetChainID'), createHTTPRequest({}, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - chainID: _data.chainID - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('GetChainID'), + createHTTPRequest({}, headers, signal) + ).then((res) => { + return buildResponse(res).then(_data => { + return { + chainID: (_data.chainID), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + sendMetaTxn = (args: SendMetaTxnArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('SendMetaTxn'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - status: _data.status, - txnHash: _data.txnHash - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('SendMetaTxn'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + status: (_data.status), + txnHash: (_data.txnHash), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + getMetaTxnNonce = (args: GetMetaTxnNonceArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('GetMetaTxnNonce'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - nonce: _data.nonce - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('GetMetaTxnNonce'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + nonce: (_data.nonce), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + getMetaTxnReceipt = (args: GetMetaTxnReceiptArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('GetMetaTxnReceipt'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - receipt: _data.receipt - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('GetMetaTxnReceipt'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + receipt: (_data.receipt), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + simulate = (args: SimulateArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('Simulate'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - results: >_data.results - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('Simulate'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + results: >(_data.results), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - - updateMetaTxnGasLimits = ( - args: UpdateMetaTxnGasLimitsArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('UpdateMetaTxnGasLimits'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - payload: _data.payload - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + + updateMetaTxnGasLimits = (args: UpdateMetaTxnGasLimitsArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('UpdateMetaTxnGasLimits'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + payload: (_data.payload), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + feeTokens = (headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('FeeTokens'), createHTTPRequest({}, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - isFeeRequired: _data.isFeeRequired, - tokens: >_data.tokens - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('FeeTokens'), + createHTTPRequest({}, headers, signal) + ).then((res) => { + return buildResponse(res).then(_data => { + return { + isFeeRequired: (_data.isFeeRequired), + tokens: >(_data.tokens), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + feeOptions = (args: FeeOptionsArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('FeeOptions'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - options: >_data.options, - sponsored: _data.sponsored, - quote: _data.quote - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('FeeOptions'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + options: >(_data.options), + sponsored: (_data.sponsored), + quote: (_data.quote), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - - getMetaTxnNetworkFeeOptions = ( - args: GetMetaTxnNetworkFeeOptionsArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('GetMetaTxnNetworkFeeOptions'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - options: >_data.options - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + + getMetaTxnNetworkFeeOptions = (args: GetMetaTxnNetworkFeeOptionsArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('GetMetaTxnNetworkFeeOptions'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + options: >(_data.options), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - - getMetaTransactions = ( - args: GetMetaTransactionsArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('GetMetaTransactions'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - page: _data.page, - transactions: >_data.transactions - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + + getMetaTransactions = (args: GetMetaTransactionsArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('GetMetaTransactions'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + page: (_data.page), + transactions: >(_data.transactions), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - - getTransactionCost = ( - args: GetTransactionCostArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('GetTransactionCost'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - cost: _data.cost - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + + getTransactionCost = (args: GetTransactionCostArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('GetTransactionCost'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + cost: (_data.cost), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + sentTransactions = (args: SentTransactionsArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('SentTransactions'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - page: _data.page, - transactions: >_data.transactions - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('SentTransactions'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + page: (_data.page), + transactions: >(_data.transactions), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - - pendingTransactions = ( - args: PendingTransactionsArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('PendingTransactions'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - page: _data.page, - transactions: >_data.transactions - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + + pendingTransactions = (args: PendingTransactionsArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('PendingTransactions'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + page: (_data.page), + transactions: >(_data.transactions), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + getGasTank = (args: GetGasTankArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('GetGasTank'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - gasTank: _data.gasTank - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('GetGasTank'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + gasTank: (_data.gasTank), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + addGasTank = (args: AddGasTankArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('AddGasTank'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - status: _data.status, - gasTank: _data.gasTank - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('AddGasTank'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + status: (_data.status), + gasTank: (_data.gasTank), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + updateGasTank = (args: UpdateGasTankArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('UpdateGasTank'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - status: _data.status, - gasTank: _data.gasTank - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('UpdateGasTank'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + status: (_data.status), + gasTank: (_data.gasTank), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + getGasSponsor = (args: GetGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('GetGasSponsor'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - gasSponsor: _data.gasSponsor - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('GetGasSponsor'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + gasSponsor: (_data.gasSponsor), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - - addressGasSponsors = ( - args: AddressGasSponsorsArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('AddressGasSponsors'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - page: _data.page, - gasSponsors: >_data.gasSponsors - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + + addressGasSponsors = (args: AddressGasSponsorsArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('AddressGasSponsors'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + page: (_data.page), + gasSponsors: >(_data.gasSponsors), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + listGasSponsors = (args: ListGasSponsorsArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('ListGasSponsors'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - page: _data.page, - gasSponsors: >_data.gasSponsors - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('ListGasSponsors'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + page: (_data.page), + gasSponsors: >(_data.gasSponsors), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + addGasSponsor = (args: AddGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('AddGasSponsor'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - status: _data.status, - gasSponsor: _data.gasSponsor - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('AddGasSponsor'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + status: (_data.status), + gasSponsor: (_data.gasSponsor), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + updateGasSponsor = (args: UpdateGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('UpdateGasSponsor'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - status: _data.status, - gasSponsor: _data.gasSponsor - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('UpdateGasSponsor'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + status: (_data.status), + gasSponsor: (_data.gasSponsor), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + removeGasSponsor = (args: RemoveGasSponsorArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('RemoveGasSponsor'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - status: _data.status - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('RemoveGasSponsor'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + status: (_data.status), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - - reportGasSponsorUsage = ( - args: ReportGasSponsorUsageArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('ReportGasSponsorUsage'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - gasSponsorUsage: >_data.gasSponsorUsage - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + + reportGasSponsorUsage = (args: ReportGasSponsorUsageArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('ReportGasSponsorUsage'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + gasSponsorUsage: >(_data.gasSponsorUsage), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - - nextGasTankBalanceAdjustmentNonce = ( - args: NextGasTankBalanceAdjustmentNonceArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('NextGasTankBalanceAdjustmentNonce'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - nonce: _data.nonce - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + + nextGasTankBalanceAdjustmentNonce = (args: NextGasTankBalanceAdjustmentNonceArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('NextGasTankBalanceAdjustmentNonce'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + nonce: (_data.nonce), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - - adjustGasTankBalance = ( - args: AdjustGasTankBalanceArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('AdjustGasTankBalance'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - status: _data.status, - adjustment: _data.adjustment - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + + adjustGasTankBalance = (args: AdjustGasTankBalanceArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('AdjustGasTankBalance'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + status: (_data.status), + adjustment: (_data.adjustment), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - - getGasTankBalanceAdjustment = ( - args: GetGasTankBalanceAdjustmentArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('GetGasTankBalanceAdjustment'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - adjustment: _data.adjustment - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + + getGasTankBalanceAdjustment = (args: GetGasTankBalanceAdjustmentArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('GetGasTankBalanceAdjustment'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + adjustment: (_data.adjustment), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - - listGasTankBalanceAdjustments = ( - args: ListGasTankBalanceAdjustmentsArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('ListGasTankBalanceAdjustments'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - page: _data.page, - adjustments: >_data.adjustments - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + + listGasTankBalanceAdjustments = (args: ListGasTankBalanceAdjustmentsArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('ListGasTankBalanceAdjustments'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + page: (_data.page), + adjustments: >(_data.adjustments), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + getProjectBalance = (args: GetProjectBalanceArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('GetProjectBalance'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - balance: _data.balance - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('GetProjectBalance'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + balance: (_data.balance), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - - adjustProjectBalance = ( - args: AdjustProjectBalanceArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('AdjustProjectBalance'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - balance: _data.balance - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + + adjustProjectBalance = (args: AdjustProjectBalanceArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('AdjustProjectBalance'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + balance: (_data.balance), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } + } -const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => { + const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => { return { method: 'POST', headers: { ...headers, 'Content-Type': 'application/json' }, @@ -1188,18 +1091,18 @@ const buildResponse = (res: Response): Promise => { let data try { data = JSON.parse(text) - } catch (error) { + } catch(error) { let message = '' - if (error instanceof Error) { + if (error instanceof Error) { message = error.message } throw WebrpcBadResponseError.new({ status: res.status, - cause: `JSON.parse(): ${message}: response text: ${text}` - }) + cause: `JSON.parse(): ${message}: response text: ${text}`}, + ) } if (!res.ok) { - const code: number = typeof data.code === 'number' ? data.code : 0 + const code: number = (typeof data.code === 'number') ? data.code : 0 throw (webrpcErrorByCode[code] || WebrpcError).new(data) } return data @@ -1381,6 +1284,7 @@ export class WebrpcStreamFinishedError extends WebrpcError { } } + // Schema errors export class UnauthorizedError extends WebrpcError { @@ -1526,6 +1430,7 @@ export class InsufficientFeeError extends WebrpcError { } } + export enum errors { WebrpcEndpoint = 'WebrpcEndpoint', WebrpcRequestFailed = 'WebrpcRequestFailed', @@ -1548,7 +1453,7 @@ export enum errors { Unavailable = 'Unavailable', QueryFailed = 'QueryFailed', NotFound = 'NotFound', - InsufficientFee = 'InsufficientFee' + InsufficientFee = 'InsufficientFee', } const webrpcErrorByCode: { [code: number]: any } = { @@ -1573,7 +1478,8 @@ const webrpcErrorByCode: { [code: number]: any } = { [2002]: UnavailableError, [2003]: QueryFailedError, [3000]: NotFoundError, - [3004]: InsufficientFeeError + [3004]: InsufficientFeeError, } export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise +