From 7f2af838ed53146e2412a5ca85ef2c84f9bbc0df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20P=C3=A9rez=20V=C3=A1zquez?= Date: Mon, 23 Sep 2024 15:33:05 +0200 Subject: [PATCH] Add deploymentType as SafeProvider parameter --- packages/protocol-kit/src/Safe.ts | 19 +++++++++++++++---- packages/protocol-kit/src/SafeProvider.ts | 14 ++++++++++---- .../createPasskeyDeploymentTransaction.ts | 3 ++- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/packages/protocol-kit/src/Safe.ts b/packages/protocol-kit/src/Safe.ts index c53bf85e7..5600d4237 100644 --- a/packages/protocol-kit/src/Safe.ts +++ b/packages/protocol-kit/src/Safe.ts @@ -128,7 +128,10 @@ class Safe { provider, signer, DEFAULT_SAFE_VERSION, - contractNetworks + contractNetworks, + undefined, + undefined, + predictedSafe?.safeDeploymentConfig?.deploymentType ) if (isSafeConfigWithPredictedSafe(config)) { @@ -155,8 +158,15 @@ class Safe { } const safeVersion = await this.getContractVersion() - this.#safeProvider = await SafeProvider.init(provider, signer, safeVersion, contractNetworks) - this.#safeProvider.deploymentType = predictedSafe?.safeDeploymentConfig?.deploymentType + this.#safeProvider = await SafeProvider.init( + provider, + signer, + safeVersion, + contractNetworks, + undefined, + undefined, + this.#safeProvider.deploymentType + ) this.#ownerManager = new OwnerManager(this.#safeProvider, this.#contractManager.safeContract) this.#moduleManager = new ModuleManager(this.#safeProvider, this.#contractManager.safeContract) @@ -176,7 +186,8 @@ class Safe { safeVersion, contractNetworks, safeAddress, - owners + owners, + this.#safeProvider.deploymentType ) } } diff --git a/packages/protocol-kit/src/SafeProvider.ts b/packages/protocol-kit/src/SafeProvider.ts index a03c91c97..b31ad5c20 100644 --- a/packages/protocol-kit/src/SafeProvider.ts +++ b/packages/protocol-kit/src/SafeProvider.ts @@ -98,10 +98,12 @@ class SafeProvider { constructor({ provider, - signer + signer, + deploymentType }: { provider: SafeProviderConfig['provider'] signer?: SafeSigner + deploymentType?: 'canonical' | 'eip155' | 'zksync' }) { this.#externalProvider = createPublicClient({ transport: isEip1193Provider(provider) @@ -111,6 +113,7 @@ class SafeProvider { this.provider = provider this.signer = signer + this.deploymentType = deploymentType } getExternalProvider(): ExternalClient { @@ -123,7 +126,8 @@ class SafeProvider { safeVersion: SafeVersion = DEFAULT_SAFE_VERSION, contractNetworks?: ContractNetworksConfig, safeAddress?: string, - owners?: string[] + owners?: string[], + deploymentType?: 'canonical' | 'eip155' | 'zksync' ): Promise { const isPasskeySigner = signer && typeof signer !== 'string' @@ -172,12 +176,14 @@ class SafeProvider { return new SafeProvider({ provider, - signer: passkeySigner + signer: passkeySigner, + deploymentType }) } else { return new SafeProvider({ provider, - signer + signer, + deploymentType }) } } diff --git a/packages/protocol-kit/src/utils/passkeys/createPasskeyDeploymentTransaction.ts b/packages/protocol-kit/src/utils/passkeys/createPasskeyDeploymentTransaction.ts index dae2bad6d..c7ee410cb 100644 --- a/packages/protocol-kit/src/utils/passkeys/createPasskeyDeploymentTransaction.ts +++ b/packages/protocol-kit/src/utils/passkeys/createPasskeyDeploymentTransaction.ts @@ -25,7 +25,8 @@ async function createPasskeyDeploymentTransaction( safeVersion, safe.getContractManager().contractNetworks, safeAddress, - owners + owners, + safe.getSafeProvider().deploymentType ) const passkeySigner = (await safePasskeyProvider.getExternalSigner()) as PasskeyClient