Skip to content

Commit

Permalink
[AUTOMATED] Update files from 0xsequence/stack (#639)
Browse files Browse the repository at this point in the history
* [AUTOMATED] Update: relayer/proto/clients/relayer.gen.ts

* [AUTOMATED] pnpm format

* add empty chainID

* [AUTOMATED] Update: relayer/proto/clients/relayer.gen.ts

* [AUTOMATED] pnpm format

* remove added 0

---------

Co-authored-by: VojtechVitek <[email protected]>
Co-authored-by: Alex Guerrieri <[email protected]>
Co-authored-by: klaidliadon <[email protected]>
  • Loading branch information
4 people authored Jan 13, 2025
1 parent 14b8b2e commit 3feeda2
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 27 deletions.
2 changes: 1 addition & 1 deletion packages/account/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ export class Account {
to: this.address,
data: hooksInterface.encodeFunctionData(hooksInterface.getFunction('addHook')!, [
'0x90611127',
proxyImplementationHook,
proxyImplementationHook
]),
gasLimit: 50000, // Expected ~28k gas. Buffer added
delegateCall: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/commons/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type WalletContext = {

walletCreationCode: string

proxyImplementationHook?: string;
proxyImplementationHook?: string
}

export function addressOf(context: WalletContext, imageHash: ethers.BytesLike) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ export const DeployedWalletContext: WalletContext = {
mainModule: '0xfBf8f1A5E00034762D928f46d438B947f5d4065d',
mainModuleUpgradable: '0x4222dcA3974E39A8b41c411FeDDE9b09Ae14b911',
walletCreationCode: '0x603a600e3d39601a805130553df3363d3d373d3d3d363d30545af43d82803e903d91601857fd5bf3',
proxyImplementationHook: '0x1f56dbAD5e8319F0DE9a323E24A31b5077dEB1a4',
proxyImplementationHook: '0x1f56dbAD5e8319F0DE9a323E24A31b5077dEB1a4'
}
165 changes: 141 additions & 24 deletions packages/relayer/src/rpc-relayer/relayer.gen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable */
// sequence-relayer v0.4.1 1e27d0fd295aa5897878939595ef0c6adc54b1a3
// sequence-relayer v0.4.1 904b2d766c6deda7180931a1bb558929502143fc
// --
// Code generated by webrpc-gen@v0.18.6 with typescript generator. DO NOT EDIT.
// 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

Expand All @@ -12,7 +12,7 @@ export const WebRPCVersion = 'v1'
export const WebRPCSchemaVersion = 'v0.4.1'

// Schema hash generated from your RIDL schema
export const WebRPCSchemaHash = '1e27d0fd295aa5897878939595ef0c6adc54b1a3'
export const WebRPCSchemaHash = '904b2d766c6deda7180931a1bb558929502143fc'

//
// Types
Expand Down Expand Up @@ -62,10 +62,10 @@ export interface RuntimeStatus {
ver: string
branch: string
commitHash: string
chainID: number
useEIP1559: boolean
senders: Array<SenderStatus>
checks: RuntimeChecks
numTxnsRelayed: NumTxnsRelayed
}

export interface SenderStatus {
Expand All @@ -77,12 +77,6 @@ export interface SenderStatus {

export interface RuntimeChecks {}

export interface NumTxnsRelayed {
prev: number
current: number
period: number
}

export interface SequenceContext {
factory: string
mainModule: string
Expand All @@ -93,6 +87,7 @@ export interface SequenceContext {

export interface GasTank {
id: number
chainId: number
name: string
currentBalance: number
unlimited: boolean
Expand All @@ -114,6 +109,7 @@ export interface GasSponsor {
id: number
gasTankId: number
projectId: number
chainId: number
address: string
name: string
active: boolean
Expand Down Expand Up @@ -142,6 +138,7 @@ export interface MetaTxn {

export interface MetaTxnLog {
id: number
chainId: number
projectId: number
txnHash: string
txnNonce: string
Expand Down Expand Up @@ -172,17 +169,6 @@ export interface MetaTxnLog {
createdAt: string
}

export interface MetaTxnEntry {
id: number
metaTxnID: string
txnStatus: ETHTxnStatus
txnRevertReason: string
index: number
logs?: Array<any>
updatedAt: string
createdAt: string
}

export interface MetaTxnReceipt {
id: string
status: string
Expand Down Expand Up @@ -293,6 +279,7 @@ export interface Relayer {
signal?: AbortSignal
): Promise<GetMetaTxnNetworkFeeOptionsReturn>
getMetaTransactions(args: GetMetaTransactionsArgs, headers?: object, signal?: AbortSignal): Promise<GetMetaTransactionsReturn>
getTransactionCost(args: GetTransactionCostArgs, headers?: object, signal?: AbortSignal): Promise<GetTransactionCostReturn>
sentTransactions(args: SentTransactionsArgs, headers?: object, signal?: AbortSignal): Promise<SentTransactionsReturn>
pendingTransactions(args: PendingTransactionsArgs, headers?: object, signal?: AbortSignal): Promise<PendingTransactionsReturn>
getGasTank(args: GetGasTankArgs, headers?: object, signal?: AbortSignal): Promise<GetGasTankReturn>
Expand Down Expand Up @@ -329,6 +316,12 @@ export interface Relayer {
headers?: object,
signal?: AbortSignal
): Promise<ListGasTankBalanceAdjustmentsReturn>
getProjectBalance(args: GetProjectBalanceArgs, headers?: object, signal?: AbortSignal): Promise<GetProjectBalanceReturn>
adjustProjectBalance(
args: AdjustProjectBalanceArgs,
headers?: object,
signal?: AbortSignal
): Promise<AdjustProjectBalanceReturn>
}

export interface PingArgs {}
Expand Down Expand Up @@ -359,6 +352,7 @@ export interface GetChainIDReturn {
export interface SendMetaTxnArgs {
call: MetaTxn
quote?: string
projectID?: number
}

export interface SendMetaTxnReturn {
Expand Down Expand Up @@ -433,6 +427,15 @@ export interface GetMetaTransactionsReturn {
page: Page
transactions: Array<MetaTxnLog>
}
export interface GetTransactionCostArgs {
projectId: number
from: string
to: string
}

export interface GetTransactionCostReturn {
cost: number
}
export interface SentTransactionsArgs {
filter?: SentTransactionsFilter
page?: Page
Expand Down Expand Up @@ -577,6 +580,22 @@ export interface ListGasTankBalanceAdjustmentsReturn {
page: Page
adjustments: Array<GasTankBalanceAdjustment>
}
export interface GetProjectBalanceArgs {
projectId: number
}

export interface GetProjectBalanceReturn {
balance: number
}
export interface AdjustProjectBalanceArgs {
projectId: number
amount: number
identifier: string
}

export interface AdjustProjectBalanceReturn {
balance: number
}

//
// Client
Expand All @@ -587,7 +606,7 @@ export class Relayer implements Relayer {
protected path = '/rpc/Relayer/'

constructor(hostname: string, fetch: Fetch) {
this.hostname = hostname
this.hostname = hostname.replace(/\/*$/, '')
this.fetch = (input: RequestInfo, init?: RequestInit) => fetch(input, init)
}

Expand Down Expand Up @@ -822,6 +841,25 @@ export class Relayer implements Relayer {
)
}

getTransactionCost = (
args: GetTransactionCostArgs,
headers?: object,
signal?: AbortSignal
): Promise<GetTransactionCostReturn> => {
return this.fetch(this.url('GetTransactionCost'), createHTTPRequest(args, headers, signal)).then(
res => {
return buildResponse(res).then(_data => {
return {
cost: <number>_data.cost
}
})
},
error => {
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
}
)
}

sentTransactions = (args: SentTransactionsArgs, headers?: object, signal?: AbortSignal): Promise<SentTransactionsReturn> => {
return this.fetch(this.url('SentTransactions'), createHTTPRequest(args, headers, signal)).then(
res => {
Expand Down Expand Up @@ -1099,6 +1137,40 @@ export class Relayer implements Relayer {
}
)
}

getProjectBalance = (args: GetProjectBalanceArgs, headers?: object, signal?: AbortSignal): Promise<GetProjectBalanceReturn> => {
return this.fetch(this.url('GetProjectBalance'), createHTTPRequest(args, headers, signal)).then(
res => {
return buildResponse(res).then(_data => {
return {
balance: <number>_data.balance
}
})
},
error => {
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
}
)
}

adjustProjectBalance = (
args: AdjustProjectBalanceArgs,
headers?: object,
signal?: AbortSignal
): Promise<AdjustProjectBalanceReturn> => {
return this.fetch(this.url('AdjustProjectBalance'), createHTTPRequest(args, headers, signal)).then(
res => {
return buildResponse(res).then(_data => {
return {
balance: <number>_data.balance
}
})
},
error => {
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
}
)
}
}

const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => {
Expand Down Expand Up @@ -1349,6 +1421,19 @@ export class MethodNotFoundError extends WebrpcError {
}
}

export class RequestConflictError extends WebrpcError {
constructor(
name: string = 'RequestConflict',
code: number = 1004,
message: string = 'Conflict with target resource',
status: number = 0,
cause?: string
) {
super(name, code, message, status, cause)
Object.setPrototypeOf(this, RequestConflictError.prototype)
}
}

export class AbortedError extends WebrpcError {
constructor(
name: string = 'Aborted',
Expand All @@ -1362,6 +1447,19 @@ export class AbortedError extends WebrpcError {
}
}

export class GeoblockedError extends WebrpcError {
constructor(
name: string = 'Geoblocked',
code: number = 1006,
message: string = 'Geoblocked region',
status: number = 0,
cause?: string
) {
super(name, code, message, status, cause)
Object.setPrototypeOf(this, GeoblockedError.prototype)
}
}

export class InvalidArgumentError extends WebrpcError {
constructor(
name: string = 'InvalidArgument',
Expand Down Expand Up @@ -1414,6 +1512,19 @@ export class NotFoundError extends WebrpcError {
}
}

export class InsufficientFeeError extends WebrpcError {
constructor(
name: string = 'InsufficientFee',
code: number = 3004,
message: string = 'Insufficient fee',
status: number = 0,
cause?: string
) {
super(name, code, message, status, cause)
Object.setPrototypeOf(this, InsufficientFeeError.prototype)
}
}

export enum errors {
WebrpcEndpoint = 'WebrpcEndpoint',
WebrpcRequestFailed = 'WebrpcRequestFailed',
Expand All @@ -1429,11 +1540,14 @@ export enum errors {
Unauthorized = 'Unauthorized',
PermissionDenied = 'PermissionDenied',
MethodNotFound = 'MethodNotFound',
RequestConflict = 'RequestConflict',
Aborted = 'Aborted',
Geoblocked = 'Geoblocked',
InvalidArgument = 'InvalidArgument',
Unavailable = 'Unavailable',
QueryFailed = 'QueryFailed',
NotFound = 'NotFound'
NotFound = 'NotFound',
InsufficientFee = 'InsufficientFee'
}

const webrpcErrorByCode: { [code: number]: any } = {
Expand All @@ -1451,11 +1565,14 @@ const webrpcErrorByCode: { [code: number]: any } = {
[1000]: UnauthorizedError,
[1001]: PermissionDeniedError,
[1003]: MethodNotFoundError,
[1004]: RequestConflictError,
[1005]: AbortedError,
[1006]: GeoblockedError,
[2001]: InvalidArgumentError,
[2002]: UnavailableError,
[2003]: QueryFailedError,
[3000]: NotFoundError
[3000]: NotFoundError,
[3004]: InsufficientFeeError
}

export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>

0 comments on commit 3feeda2

Please sign in to comment.