diff --git a/packages/api-kit/src/types/safeTransactionServiceTypes.ts b/packages/api-kit/src/types/safeTransactionServiceTypes.ts index 80fcb80ab..348d19b4e 100644 --- a/packages/api-kit/src/types/safeTransactionServiceTypes.ts +++ b/packages/api-kit/src/types/safeTransactionServiceTypes.ts @@ -1,9 +1,9 @@ import { Signer, TypedDataDomain, TypedDataField } from 'ethers' import { SafeMultisigTransactionResponse, + SafeOperation, SafeTransactionData } from '@safe-global/safe-core-sdk-types' -import SafeOperation from '@safe-global/relay-kit/src/packs/safe-4337/SafeOperation' export type SafeServiceInfoResponse = { readonly name: string diff --git a/packages/api-kit/tests/endpoint/index.test.ts b/packages/api-kit/tests/endpoint/index.test.ts index 5ac189233..39eaa99d3 100644 --- a/packages/api-kit/tests/endpoint/index.test.ts +++ b/packages/api-kit/tests/endpoint/index.test.ts @@ -7,14 +7,13 @@ import SafeApiKit, { } from '@safe-global/api-kit/index' import * as httpRequests from '@safe-global/api-kit/utils/httpRequests' import Safe from '@safe-global/protocol-kit' -import { EthAdapter } from '@safe-global/safe-core-sdk-types' +import { EthAdapter, SafeOperation } from '@safe-global/safe-core-sdk-types' import chai from 'chai' import chaiAsPromised from 'chai-as-promised' import sinon from 'sinon' import sinonChai from 'sinon-chai' import config from '../utils/config' import { getServiceClient } from '../utils/setupServiceClient' -import SafeOperation from '@safe-global/relay-kit/packs/safe-4337/SafeOperation' chai.use(chaiAsPromised) chai.use(sinonChai) diff --git a/packages/relay-kit/src/packs/safe-4337/Safe4337Pack.ts b/packages/relay-kit/src/packs/safe-4337/Safe4337Pack.ts index d5b5d10b6..65d20f6a3 100644 --- a/packages/relay-kit/src/packs/safe-4337/Safe4337Pack.ts +++ b/packages/relay-kit/src/packs/safe-4337/Safe4337Pack.ts @@ -8,12 +8,17 @@ import Safe, { getMultiSendContract } from '@safe-global/protocol-kit' import { RelayKitBasePack } from '@safe-global/relay-kit/RelayKitBasePack' -import { MetaTransactionData, OperationType, SafeSignature } from '@safe-global/safe-core-sdk-types' +import { + MetaTransactionData, + OperationType, + SafeSignature, + UserOperation, + SafeUserOperation +} from '@safe-global/safe-core-sdk-types' import { getAddModulesLibDeployment, getSafe4337ModuleDeployment } from '@safe-global/safe-modules-deployments' - import SafeOperation from './SafeOperation' import { EstimateFeeProps, @@ -21,8 +26,6 @@ import { Safe4337ExecutableProps, Safe4337InitOptions, Safe4337Options, - SafeUserOperation, - UserOperation, UserOperationReceipt, UserOperationWithPayload, PaymasterOptions diff --git a/packages/relay-kit/src/packs/safe-4337/SafeOperation.ts b/packages/relay-kit/src/packs/safe-4337/SafeOperation.ts index e27e6d974..b7dc1a9b0 100644 --- a/packages/relay-kit/src/packs/safe-4337/SafeOperation.ts +++ b/packages/relay-kit/src/packs/safe-4337/SafeOperation.ts @@ -1,12 +1,16 @@ import { ethers } from 'ethers' -import { SafeSignature } from '@safe-global/safe-core-sdk-types' +import { + EstimateGasData, + SafeOperation as SafeOperationType, + SafeSignature, + SafeUserOperation, + UserOperation +} from '@safe-global/safe-core-sdk-types' import { buildSignatureBytes } from '@safe-global/protocol-kit' -import { EstimateGasData, SafeUserOperation, UserOperation } from './types' - type SafeOperationOptions = { entryPoint: string; validAfter?: number; validUntil?: number } -class SafeOperation { +class SafeOperation implements SafeOperationType { data: SafeUserOperation signatures: Map = new Map() diff --git a/packages/relay-kit/src/packs/safe-4337/estimators/PimlicoFeeEstimator.ts b/packages/relay-kit/src/packs/safe-4337/estimators/PimlicoFeeEstimator.ts index a61eca986..f00932f43 100644 --- a/packages/relay-kit/src/packs/safe-4337/estimators/PimlicoFeeEstimator.ts +++ b/packages/relay-kit/src/packs/safe-4337/estimators/PimlicoFeeEstimator.ts @@ -1,7 +1,7 @@ import { ethers } from 'ethers' +import { EstimateGasData } from '@safe-global/safe-core-sdk-types' import { EstimateFeeFunctionProps, - EstimateGasData, EstimateSponsoredFeeFunctionProps, EstimateSponsoredGasData, IFeeEstimator diff --git a/packages/relay-kit/src/packs/safe-4337/types.ts b/packages/relay-kit/src/packs/safe-4337/types.ts index ddb701b37..c338a11fc 100644 --- a/packages/relay-kit/src/packs/safe-4337/types.ts +++ b/packages/relay-kit/src/packs/safe-4337/types.ts @@ -1,5 +1,10 @@ import Safe, { EthersAdapter } from '@safe-global/protocol-kit' -import { MetaTransactionData, SafeVersion } from '@safe-global/safe-core-sdk-types' +import { + EstimateGasData, + MetaTransactionData, + SafeVersion, + UserOperation +} from '@safe-global/safe-core-sdk-types' import { ethers } from 'ethers' import SafeOperation from './SafeOperation' @@ -61,44 +66,6 @@ export type Safe4337ExecutableProps = { executable: SafeOperation } -export type SafeUserOperation = { - safe: string - nonce: bigint - initCode: string - callData: string - callGasLimit: bigint - verificationGasLimit: bigint - preVerificationGas: bigint - maxFeePerGas: bigint - maxPriorityFeePerGas: bigint - paymasterAndData: string - validAfter: number - validUntil: number - entryPoint: string -} - -export type UserOperation = { - sender: string - nonce: string - initCode: string - callData: string - callGasLimit: bigint - verificationGasLimit: bigint - preVerificationGas: bigint - maxFeePerGas: bigint - maxPriorityFeePerGas: bigint - paymasterAndData: string - signature: string -} - -export type EstimateGasData = { - maxFeePerGas?: bigint - maxPriorityFeePerGas?: bigint - preVerificationGas?: bigint - verificationGasLimit?: bigint - callGasLimit?: bigint -} - export type EstimateSponsoredGasData = { paymasterAndData: string } & EstimateGasData diff --git a/packages/relay-kit/src/packs/safe-4337/utils.ts b/packages/relay-kit/src/packs/safe-4337/utils.ts index c3d132872..1e2db76c2 100644 --- a/packages/relay-kit/src/packs/safe-4337/utils.ts +++ b/packages/relay-kit/src/packs/safe-4337/utils.ts @@ -1,5 +1,5 @@ import { ethers } from 'ethers' -import { UserOperation } from './types' +import { UserOperation } from '@safe-global/safe-core-sdk-types' /** * Gets the EIP-4337 bundler provider. diff --git a/packages/safe-core-sdk-types/src/types.ts b/packages/safe-core-sdk-types/src/types.ts index 30eb4e7e8..4430d18ce 100644 --- a/packages/safe-core-sdk-types/src/types.ts +++ b/packages/safe-core-sdk-types/src/types.ts @@ -252,3 +252,51 @@ export interface MetaTransactionOptions { gasToken?: string isSponsored?: boolean } + +export type UserOperation = { + sender: string + nonce: string + initCode: string + callData: string + callGasLimit: bigint + verificationGasLimit: bigint + preVerificationGas: bigint + maxFeePerGas: bigint + maxPriorityFeePerGas: bigint + paymasterAndData: string + signature: string +} + +export type SafeUserOperation = { + safe: string + nonce: bigint + initCode: string + callData: string + callGasLimit: bigint + verificationGasLimit: bigint + preVerificationGas: bigint + maxFeePerGas: bigint + maxPriorityFeePerGas: bigint + paymasterAndData: string + validAfter: number + validUntil: number + entryPoint: string +} + +export type EstimateGasData = { + maxFeePerGas?: bigint + maxPriorityFeePerGas?: bigint + preVerificationGas?: bigint + verificationGasLimit?: bigint + callGasLimit?: bigint +} + +export interface SafeOperation { + readonly data: SafeUserOperation + readonly signatures: Map + getSignature(signer: string): SafeSignature | undefined + addSignature(signature: SafeSignature): void + encodedSignatures(): string + addEstimations(estimations: EstimateGasData): void + toUserOperation(): UserOperation +}