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: Viem migration + Passkeys #931

Merged
merged 197 commits into from
Sep 11, 2024
Merged

feat: Viem migration + Passkeys #931

merged 197 commits into from
Sep 11, 2024

Conversation

leonardotc
Copy link
Contributor

@leonardotc leonardotc commented Aug 2, 2024

What it solves

Resolves issues #870 and #871.

How this PR fixes it

This pull request migrates the entire repository to viem, removing ethers as a dependency. ethers is retained only as a devDependency for the test-utils in api-kit and protocol-kit.

⚠️ Breaking Changes

protocol-kit

  • SafeProvider
    • getExternalProvider now returns a viem PublicClient (previously an ethers Provider).
    • getExternalSigner now returns a viem WalletClient (previously an ethers AbstractSigner).
    • getTransaction now returns a viem Transaction (previously an ethers TransactionResponse).
    • encodeParameters and decodeParameters now expect a string as the first parameter, containing the Human-readable ABI parameters (previously a string[]).
  • All ABI parameters are now a viem Abi (previously JsonFragment | JsonFragment[]). This affects:
    • defaultAbi and customContractAbi in all Contract classes.
    • customContractAbi parameter in all get...ContractInstance functions and in the GetContractProps type.
  • getSafeProxyFactoryContractInstance function's signerOrProvider parameter is now a viem PublicClient.

api-kit

  • SafeApiKit's addSafeDelegate and removeSafeDelegate functions now expect a viem WalletClient as the signer prop (previously an ethers Signer).

relay-kit

  • Safe4337Options now expects a bundlerClient prop of viem's type PublicClient (previously ethers JsonRpcProvider).

auth-kit

  • AuthKitEthereumProvider type is now a viem EIP1193Provider (previously ethers Eip1193Provider). This new type restricts the RPC methods for EIP-1193, as opposed to the ethers type, which accepted any string as a method name.

Other context

Replaces #887

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 <daniel.somoza@safe.global>
@dasanra dasanra changed the base branch from development to passkey-support August 23, 2024 11:34
@dasanra dasanra changed the base branch from passkey-support to development September 10, 2024 09:46
…e-sdk into passkey-support-viem

# Conflicts:
#	packages/api-kit/package.json
#	packages/auth-kit/package.json
#	packages/onramp-kit/package.json
#	packages/protocol-kit/package.json
#	packages/protocol-kit/src/Safe.ts
#	packages/protocol-kit/src/SafeProvider.ts
#	packages/protocol-kit/src/contracts/SafeWebAuthnSharedSigner/SafeWebAuthnSharedSignerBaseContract.ts
#	packages/protocol-kit/src/contracts/SafeWebAuthnSharedSigner/v0.2.1/SafeWebAuthnSharedSignerContract_v0_2_1.ts
#	packages/protocol-kit/src/contracts/SafeWebAuthnSignerFactory/SafeWebAuthnSignerFactoryBaseContract.ts
#	packages/protocol-kit/src/contracts/SafeWebAuthnSignerFactory/v0.2.1/SafeWebAuthnSignerFactoryContract_v0_2_1.ts
#	packages/protocol-kit/src/contracts/config.ts
#	packages/protocol-kit/src/contracts/contractInstances.ts
#	packages/protocol-kit/src/contracts/utils.ts
#	packages/protocol-kit/src/index.ts
#	packages/protocol-kit/src/types/contracts.ts
#	packages/protocol-kit/src/types/safeProvider.ts
#	packages/protocol-kit/src/utils/passkeys/createPasskeyDeploymentTransaction.ts
#	packages/protocol-kit/src/utils/passkeys/getPasskeyOwnerAddress.ts
#	packages/protocol-kit/src/utils/passkeys/index.ts
#	packages/protocol-kit/src/utils/passkeys/isSharedSigner.ts
#	packages/protocol-kit/src/utils/transactions/utils.ts
#	packages/protocol-kit/tests/e2e/passkey.test.ts
#	packages/protocol-kit/tests/e2e/safeProvider.test.ts
#	packages/protocol-kit/tests/e2e/utils/passkeys.ts
#	packages/protocol-kit/tests/e2e/utils/setupContractNetworks.ts
#	packages/protocol-kit/tests/e2e/utils/setupContracts.ts
#	packages/relay-kit/package.json
#	packages/relay-kit/src/packs/safe-4337/Safe4337Pack.test.ts
#	packages/relay-kit/src/packs/safe-4337/Safe4337Pack.ts
#	packages/relay-kit/src/packs/safe-4337/utils.ts
#	packages/safe-core-sdk-types/package.json
#	packages/sdk-starter-kit/package.json
#	yarn.lock
@coveralls
Copy link

coveralls commented Sep 10, 2024

Pull Request Test Coverage Report for Build 10813799887

Details

  • 72 of 87 (82.76%) changed or added relevant lines in 14 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 77.405%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/sdk-starter-kit/src/utils/index.ts 0 2 0.0%
packages/relay-kit/src/packs/safe-4337/utils.ts 7 13 53.85%
packages/sdk-starter-kit/src/utils/sendTransaction.ts 1 8 12.5%
Totals Coverage Status
Change from base Build 10576918345: -0.1%
Covered Lines: 984
Relevant Lines: 1199

💛 - Coveralls

@dasanra dasanra changed the title Passkey support viem feat: Viem migration + Passkeys Sep 11, 2024
@dasanra dasanra merged commit a7c0bd5 into development Sep 11, 2024
20 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2024
@dasanra dasanra deleted the passkey-support-viem branch October 2, 2024 13:43
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] Merge Viem changes into Passkeys branch
6 participants