Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protocol-kit): Add deployment functionality to Safe class + Viem #948

Closed
wants to merge 209 commits into from

Conversation

leonardotc
Copy link
Contributor

@leonardotc leonardotc commented Aug 19, 2024

What it solves

Resolves #446

  • Removed the SafeFactory class
  • created 2 private functions in the Safe class:
  • Added the deploy function in the Safe class.
  • Added getSafeAddressFromDeploymentTx util function: Returns the address of a SafeProxy from the deployment tx receipt.

Open Questions

  1. Callback Parameter Removal:

    • I have opted to remove the callback parameter from the new deploy() function that was present in the old SafeFactory class. We can reintroduce it if the team prefers.
  2. Function Naming:

    • I chose to name the function deploy() instead of deployAndSend(). I am open to changing it if there are any objections or suggestions for a better name.
  3. Return Type of deploy():

    • Currently, the new deploy() method returns the new instance of the protocol-kit with the Safe already deployed. However, we can change this to return the transaction hash (tx-hash) or another value if that is preferable.

Please review and provide your feedback on these points.

Previous PR reference

#905

DaniSomoza and others added 30 commits May 16, 2024 14:01
* Add `SafeWebAuthnSignerFactory` contract

* Add tests for passkey flow in `isOwner` function

* Add tests for signTransaction + createAddOwnerTx (wip)

* Add webauthnShim to emulate the Web Authentication API implemented in browsers

Copied from [safe-modules repo](https://github.com/safe-global/safe-modules/blob/main/modules/passkey/test/utils/webauthnShim.ts)

* Use webauthnShim for passkey mocks

* Deploy `FCLP256Verifier` in local hardhat environment and use it as as WebAuthnContract

* Run passkey tests only for contract versions 1.3.0 + 1.4.1

---------

Co-authored-by: Daniel Somoza <[email protected]>
@dasanra dasanra changed the base branch from added-deployment-safe-class to development September 11, 2024 15:29
@dasanra dasanra changed the base branch from development to added-deployment-safe-class September 11, 2024 15:30
@dasanra dasanra changed the base branch from added-deployment-safe-class to development September 11, 2024 15:35
@coveralls
Copy link

coveralls commented Sep 11, 2024

Pull Request Test Coverage Report for Build 10815229465

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 77.405%

Totals Coverage Status
Change from base Build 10814566523: 0.0%
Covered Lines: 984
Relevant Lines: 1199

💛 - Coveralls

@dasanra dasanra changed the title Added deployment safe class viem feat(protocol-kit): Add deployment functionality to Safe class Sep 11, 2024
@dasanra dasanra changed the title feat(protocol-kit): Add deployment functionality to Safe class feat(protocol-kit): Add deployment functionality to Safe class + Viem Sep 11, 2024
const saltNonce = config.DEPLOY_SAFE.SALT_NONCE

// Create SDK instance
const safeSDK = await Safe.init({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const safeSDK = await Safe.init({
let protocolKit = await Safe.init({

saltNonce,
callback
})
const deployedSafeSDK = await safeSDK.deploy()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const deployedSafeSDK = await safeSDK.deploy()
protocolKit = await safeSDK.deploy()

})
const deployedSafeSDK = await safeSDK.deploy()

console.log('Deployed Safe address:', await deployedSafeSDK.getAddress())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log('Deployed Safe address:', await deployedSafeSDK.getAddress())
console.log('Deployed Safe address:', await protocolKit.getAddress())


console.log('Deployed Safe:', await safe.getAddress())
// check if its deployed
console.log('Safe Account deployed: ', await deployedSafeSDK.isSafeDeployed())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log('Safe Account deployed: ', await deployedSafeSDK.isSafeDeployed())
console.log('Safe Account deployed: ', await protocolKit.isSafeDeployed())

@@ -264,13 +268,6 @@ class Safe {
*/
async getAddress(): Promise<string> {
if (this.#predictedSafe) {
const safeVersion = await this.getContractVersion()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed in several places but not sure why

@yagopv
Copy link
Member

yagopv commented Sep 12, 2024

About the open questions:

  1. 👍🏻 It's ok for me to remove the callback
  2. 👍🏻 deploy() is much better than deployAndSend() imo
  3. 👎🏻 In this case, I'm not completely sure. My initial thought is that it's more about reinstating it internally and returning the transaction hash

@dasanra dasanra linked an issue Sep 12, 2024 that may be closed by this pull request
@dasanra dasanra closed this Sep 25, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 25, 2024
@dasanra dasanra deleted the added-deployment-safe-class-viem branch September 27, 2024 11:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SDK Refactor] Align Safe Factory PR to Viem Add Safe deployment functionality to Safe class
6 participants