Skip to content

Commit

Permalink
Add deploymentType as SafeProvider parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
yagopv committed Sep 23, 2024
1 parent c10fd16 commit 7f2af83
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
19 changes: 15 additions & 4 deletions packages/protocol-kit/src/Safe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ class Safe {
provider,
signer,
DEFAULT_SAFE_VERSION,
contractNetworks
contractNetworks,
undefined,
undefined,
predictedSafe?.safeDeploymentConfig?.deploymentType
)

if (isSafeConfigWithPredictedSafe(config)) {
Expand All @@ -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)
Expand All @@ -176,7 +186,8 @@ class Safe {
safeVersion,
contractNetworks,
safeAddress,
owners
owners,
this.#safeProvider.deploymentType
)
}
}
Expand Down
14 changes: 10 additions & 4 deletions packages/protocol-kit/src/SafeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -111,6 +113,7 @@ class SafeProvider {

this.provider = provider
this.signer = signer
this.deploymentType = deploymentType
}

getExternalProvider(): ExternalClient {
Expand All @@ -123,7 +126,8 @@ class SafeProvider {
safeVersion: SafeVersion = DEFAULT_SAFE_VERSION,
contractNetworks?: ContractNetworksConfig,
safeAddress?: string,
owners?: string[]
owners?: string[],
deploymentType?: 'canonical' | 'eip155' | 'zksync'
): Promise<SafeProvider> {
const isPasskeySigner = signer && typeof signer !== 'string'

Expand Down Expand Up @@ -172,12 +176,14 @@ class SafeProvider {

return new SafeProvider({
provider,
signer: passkeySigner
signer: passkeySigner,
deploymentType
})
} else {
return new SafeProvider({
provider,
signer
signer,
deploymentType
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ async function createPasskeyDeploymentTransaction(
safeVersion,
safe.getContractManager().contractNetworks,
safeAddress,
owners
owners,
safe.getSafeProvider().deploymentType
)

const passkeySigner = (await safePasskeyProvider.getExternalSigner()) as PasskeyClient
Expand Down

0 comments on commit 7f2af83

Please sign in to comment.