From 50daaf889421927342df78a37d6fc9418fd563cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Bu=C4=9Fra=20Yi=C4=9Fiter?= Date: Tue, 14 Jan 2025 12:24:46 +0300 Subject: [PATCH 1/7] Extract new relayer endpoints --- packages/relayer/src/index.ts | 11 +++++++++++ packages/relayer/src/rpc-relayer/index.ts | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/packages/relayer/src/index.ts b/packages/relayer/src/index.ts index 95a8eb287..6cec30d21 100644 --- a/packages/relayer/src/index.ts +++ b/packages/relayer/src/index.ts @@ -54,6 +54,17 @@ export interface Relayer { delay?: number, maxFails?: number ): Promise + + // getMetaTransactions returns a list of meta transactions for a given project and gas tank + getMetaTransactions(projectId: number, gasTankId: number, page?: proto.Page): Promise<{ + page: proto.Page, + transactions: proto.MetaTxnLog[] + }> + + // getTransactionCost returns the estimated cost of a transaction between addresses + getTransactionCost(projectId: number, from: string, to: string): Promise<{ + cost: number + }> } export * from './local-relayer' diff --git a/packages/relayer/src/rpc-relayer/index.ts b/packages/relayer/src/rpc-relayer/index.ts index 5b04a6893..bdb073cbe 100644 --- a/packages/relayer/src/rpc-relayer/index.ts +++ b/packages/relayer/src/rpc-relayer/index.ts @@ -304,6 +304,19 @@ export class RpcRelayer implements Relayer { wait: async (confirmations?: number) => this.provider!.waitForTransaction(txReceipt.transactionHash, confirmations) } as commons.transaction.TransactionResponse } + + async getMetaTransactions(projectId: number, gasTankId: number, page?: proto.Page): Promise<{ + page: proto.Page, + transactions: proto.MetaTxnLog[] + }> { + return this.service.getMetaTransactions({ projectId, gasTankId, page }) + } + + async getTransactionCost(projectId: number, from: string, to: string): Promise<{ + cost: number + }> { + return this.service.getTransactionCost({ projectId, from, to }) + } } class MetaTransactionResponseException { From c4246e4f3c47d6a87e0f0f46d4769ef421f1f7e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Bu=C4=9Fra=20Yi=C4=9Fiter?= Date: Tue, 14 Jan 2025 12:26:03 +0300 Subject: [PATCH 2/7] Update comment --- packages/relayer/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/relayer/src/index.ts b/packages/relayer/src/index.ts index 6cec30d21..40f8e16bb 100644 --- a/packages/relayer/src/index.ts +++ b/packages/relayer/src/index.ts @@ -61,7 +61,7 @@ export interface Relayer { transactions: proto.MetaTxnLog[] }> - // getTransactionCost returns the estimated cost of a transaction between addresses + // getTransactionCost returns the used fee cost for gas tank during a given period getTransactionCost(projectId: number, from: string, to: string): Promise<{ cost: number }> From dd38307fc3d238371bb68e6f1ca57cc0b7f47e76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Bu=C4=9Fra=20Yi=C4=9Fiter?= Date: Tue, 14 Jan 2025 12:31:07 +0300 Subject: [PATCH 3/7] Add local relayer --- packages/relayer/src/local-relayer.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/relayer/src/local-relayer.ts b/packages/relayer/src/local-relayer.ts index c0aacf899..65f478605 100644 --- a/packages/relayer/src/local-relayer.ts +++ b/packages/relayer/src/local-relayer.ts @@ -1,6 +1,6 @@ import { ethers } from 'ethers' import { logger } from '@0xsequence/utils' -import { FeeOption, FeeQuote, Relayer } from '.' +import { FeeOption, FeeQuote, proto, Relayer } from '.' import { ProviderRelayer, ProviderRelayerOptions } from './provider-relayer' import { commons } from '@0xsequence/core' @@ -76,6 +76,19 @@ export class LocalRelayer extends ProviderRelayer implements Relayer { return responsePromise } } + + async getMetaTransactions(projectId: number, gasTankId: number, page?: proto.Page): Promise<{ + page: proto.Page, + transactions: proto.MetaTxnLog[] + }> { + return { page: { page: 0, pageSize: 100 }, transactions: [] } + } + + async getTransactionCost(projectId: number, from: string, to: string): Promise<{ + cost: number + }> { + return { cost: 0 } + } } function isAbstractSigner(signer: any): signer is ethers.AbstractSigner { From e4af4f3fdc4602119d48358cf8ceec52fddcddb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Bu=C4=9Fra=20Yi=C4=9Fiter?= Date: Tue, 14 Jan 2025 12:34:50 +0300 Subject: [PATCH 4/7] Update provider relayer --- packages/relayer/src/provider-relayer.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/relayer/src/provider-relayer.ts b/packages/relayer/src/provider-relayer.ts index 86652efe1..e3dc8499c 100644 --- a/packages/relayer/src/provider-relayer.ts +++ b/packages/relayer/src/provider-relayer.ts @@ -59,6 +59,15 @@ export abstract class ProviderRelayer implements Relayer { waitForReceipt?: boolean ): Promise + abstract getTransactionCost(projectId: number, from: string, to: string): Promise<{ + cost: number + }> + + abstract getMetaTransactions(projectId: number, gasTankId: number, page?: proto.Page): Promise<{ + page: commons.Page, + transactions: commons.MetaTxnLog[] + }> + async simulate(wallet: string, ...transactions: commons.transaction.Transaction[]): Promise { return ( await Promise.all( @@ -248,6 +257,8 @@ export abstract class ProviderRelayer implements Relayer { return waitReceipt() } } + + } function isAbstractProvider(provider: any): provider is ethers.AbstractProvider { From 62bdd83c47c6fd9d054b5a22fcf1279585925f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Bu=C4=9Fra=20Yi=C4=9Fiter?= Date: Tue, 14 Jan 2025 12:37:25 +0300 Subject: [PATCH 5/7] Fix ts issues --- packages/relayer/src/provider-relayer.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/relayer/src/provider-relayer.ts b/packages/relayer/src/provider-relayer.ts index e3dc8499c..41e2b153d 100644 --- a/packages/relayer/src/provider-relayer.ts +++ b/packages/relayer/src/provider-relayer.ts @@ -1,6 +1,6 @@ import { ethers } from 'ethers' import { walletContracts } from '@0xsequence/abi' -import { FeeOption, FeeQuote, Relayer, SimulateResult } from '.' +import { FeeOption, FeeQuote, proto, Relayer, SimulateResult } from '.' import { logger, Optionals } from '@0xsequence/utils' import { commons } from '@0xsequence/core' @@ -63,9 +63,9 @@ export abstract class ProviderRelayer implements Relayer { cost: number }> - abstract getMetaTransactions(projectId: number, gasTankId: number, page?: proto.Page): Promise<{ + abstract getMetaTransactions(projectId: number, gasTankId: number, page?: commons.Page): Promise<{ page: commons.Page, - transactions: commons.MetaTxnLog[] + transactions: proto.MetaTxnLog[] }> async simulate(wallet: string, ...transactions: commons.transaction.Transaction[]): Promise { From c946b2ad95406a21879a4f8db851f295f0151a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Bu=C4=9Fra=20Yi=C4=9Fiter?= Date: Tue, 14 Jan 2025 12:40:06 +0300 Subject: [PATCH 6/7] Update --- packages/relayer/src/provider-relayer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/relayer/src/provider-relayer.ts b/packages/relayer/src/provider-relayer.ts index 41e2b153d..eef5f5b87 100644 --- a/packages/relayer/src/provider-relayer.ts +++ b/packages/relayer/src/provider-relayer.ts @@ -63,8 +63,8 @@ export abstract class ProviderRelayer implements Relayer { cost: number }> - abstract getMetaTransactions(projectId: number, gasTankId: number, page?: commons.Page): Promise<{ - page: commons.Page, + abstract getMetaTransactions(projectId: number, gasTankId: number, page?: proto.Page): Promise<{ + page: proto.Page, transactions: proto.MetaTxnLog[] }> From 2b0bde0da4ac6c68f9afd84bb4608c14fc3d75c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Bu=C4=9Fra=20Yi=C4=9Fiter?= Date: Tue, 14 Jan 2025 13:54:53 +0300 Subject: [PATCH 7/7] Update --- packages/relayer/src/index.ts | 2 +- packages/relayer/src/local-relayer.ts | 2 +- packages/relayer/src/provider-relayer.ts | 2 +- packages/relayer/src/rpc-relayer/index.ts | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/relayer/src/index.ts b/packages/relayer/src/index.ts index 40f8e16bb..48c29b8ec 100644 --- a/packages/relayer/src/index.ts +++ b/packages/relayer/src/index.ts @@ -56,7 +56,7 @@ export interface Relayer { ): Promise // getMetaTransactions returns a list of meta transactions for a given project and gas tank - getMetaTransactions(projectId: number, gasTankId: number, page?: proto.Page): Promise<{ + getMetaTransactions(projectId: number, page?: proto.Page): Promise<{ page: proto.Page, transactions: proto.MetaTxnLog[] }> diff --git a/packages/relayer/src/local-relayer.ts b/packages/relayer/src/local-relayer.ts index 65f478605..9cf3a0acd 100644 --- a/packages/relayer/src/local-relayer.ts +++ b/packages/relayer/src/local-relayer.ts @@ -77,7 +77,7 @@ export class LocalRelayer extends ProviderRelayer implements Relayer { } } - async getMetaTransactions(projectId: number, gasTankId: number, page?: proto.Page): Promise<{ + async getMetaTransactions(projectId: number, page?: proto.Page): Promise<{ page: proto.Page, transactions: proto.MetaTxnLog[] }> { diff --git a/packages/relayer/src/provider-relayer.ts b/packages/relayer/src/provider-relayer.ts index eef5f5b87..17800a921 100644 --- a/packages/relayer/src/provider-relayer.ts +++ b/packages/relayer/src/provider-relayer.ts @@ -63,7 +63,7 @@ export abstract class ProviderRelayer implements Relayer { cost: number }> - abstract getMetaTransactions(projectId: number, gasTankId: number, page?: proto.Page): Promise<{ + abstract getMetaTransactions(projectId: number, page?: proto.Page): Promise<{ page: proto.Page, transactions: proto.MetaTxnLog[] }> diff --git a/packages/relayer/src/rpc-relayer/index.ts b/packages/relayer/src/rpc-relayer/index.ts index bdb073cbe..bde372eb1 100644 --- a/packages/relayer/src/rpc-relayer/index.ts +++ b/packages/relayer/src/rpc-relayer/index.ts @@ -305,11 +305,11 @@ export class RpcRelayer implements Relayer { } as commons.transaction.TransactionResponse } - async getMetaTransactions(projectId: number, gasTankId: number, page?: proto.Page): Promise<{ + async getMetaTransactions(projectId: number, page?: proto.Page): Promise<{ page: proto.Page, transactions: proto.MetaTxnLog[] }> { - return this.service.getMetaTransactions({ projectId, gasTankId, page }) + return this.service.getMetaTransactions({ projectId, page }) } async getTransactionCost(projectId: number, from: string, to: string): Promise<{