From 655e0f979fc0c460241f72a5bce7f01c415b6d14 Mon Sep 17 00:00:00 2001 From: Daniel Somoza Date: Wed, 5 Jun 2024 18:24:25 +0200 Subject: [PATCH 1/6] add passkeys in the doc references --- .../protocol-kit/reference/safe-factory.md | 21 ++++++++ pages/sdk/protocol-kit/reference/safe.md | 51 +++++++++++++++++++ .../relay-kit/reference/safe-4337-pack.mdx | 4 +- 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/pages/sdk/protocol-kit/reference/safe-factory.md b/pages/sdk/protocol-kit/reference/safe-factory.md index a344e889..2dd35777 100644 --- a/pages/sdk/protocol-kit/reference/safe-factory.md +++ b/pages/sdk/protocol-kit/reference/safe-factory.md @@ -15,6 +15,25 @@ const safeFactory = await SafeFactory.init({ }) ``` +#### Using passkeys + +A Passkey can be used as a signer to create an instance of the Safe Factory. + +```typescript +import { SafeFactory, PasskeyArgType } from '@safe-global/protocol-kit' + +const passkey: PasskeyArgType = { + rawId, + publicKey, +} + +const safeFactory = await SafeFactory.init({ + provider, + signer: passkey +}) +``` + + - The `isL1SafeSingleton` flag Two versions of the Safe contracts are available: [Safe.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/Safe.sol) that doesn't trigger events to save gas and [SafeL2.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/SafeL2.sol) that does, which is more appropriate for L2 networks. @@ -52,6 +71,7 @@ const safeFactory = await SafeFactory.init({ signMessageLibAddress: '', createCallAddress: '', simulateTxAccessorAddress: '', + safeWebAuthnSignerFactoryAddress:'', safeSingletonAbi: '', // Optional. Only needed with web3.js safeProxyFactoryAbi: '', // Optional. Only needed with web3.js multiSendAbi: '', // Optional. Only needed with web3.js @@ -60,6 +80,7 @@ const safeFactory = await SafeFactory.init({ signMessageLibAbi: '', // Optional. Only needed with web3.js createCallAbi: '', // Optional. Only needed with web3.js simulateTxAccessorAbi: '' // Optional. Only needed with web3.js + safeWebAuthnSignerFactoryAbi: '' // Optional. Only needed with web3.js } } diff --git a/pages/sdk/protocol-kit/reference/safe.md b/pages/sdk/protocol-kit/reference/safe.md index 69e55b5c..2a4cdfc9 100644 --- a/pages/sdk/protocol-kit/reference/safe.md +++ b/pages/sdk/protocol-kit/reference/safe.md @@ -37,6 +37,26 @@ const protocolKit = await Safe.init({ }) ``` +#### Using passkeys + +A Passkey can be used as a signer to create an instance of the Protocol Kit. + +```typescript +import Safe from '@safe-global/protocol-kit' + +const passkey: PasskeyArgType = { + rawId, + publicKey, +} + +const protocolKit = await Safe.init({ + provider, + signer: passkey, + // safeAddress or predictedSafe +}) +``` + + - The `isL1SafeSingleton` flag Two versions of the Safe contracts are available: [Safe.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/Safe.sol) that doesn't trigger events to save gas and [SafeL2.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/SafeL2.sol) that does, which is more appropriate for L2 networks. @@ -75,6 +95,7 @@ const protocolKit = await Safe.init({ signMessageLibAddress: '', createCallAddress: '', simulateTxAccessorAddress: '', + safeWebAuthnSignerFactoryAddress:'', safeSingletonAbi: '', // Optional. Only needed with web3.js safeProxyFactoryAbi: '', // Optional. Only needed with web3.js multiSendAbi: '', // Optional. Only needed with web3.js @@ -83,6 +104,7 @@ const protocolKit = await Safe.init({ signMessageLibAbi: '', // Optional. Only needed with web3.js createCallAbi: '', // Optional. Only needed with web3.js simulateTxAccessorAbi: '' // Optional. Only needed with web3.js + safeWebAuthnSignerFactoryAbi: '' // Optional. Only needed with web3.js } } @@ -174,6 +196,7 @@ protocolKit = await protocolKit.connect({ predictedSafe }) signMessageLibAddress: '', createCallAddress: '', simulateTxAccessorAddress: '', + safeWebAuthnSignerFactoryAddress:'', safeSingletonAbi: '', // Optional. Only needed with web3.js safeProxyFactoryAbi: '', // Optional. Only needed with web3.js multiSendAbi: '', // Optional. Only needed with web3.js @@ -182,6 +205,7 @@ protocolKit = await protocolKit.connect({ predictedSafe }) signMessageLibAbi: '', // Optional. Only needed with web3.js createCallAbi: '', // Optional. Only needed with web3.js simulateTxAccessorAbi: '' // Optional. Only needed with web3.js + safeWebAuthnSignerFactoryAbi: '' // Optional. Only needed with web3.js } } @@ -513,6 +537,22 @@ const txResponse = await protocolKit.executeTransaction(safeTransaction) await txResponse.transactionResponse?.wait() ``` +This method can be used with Passkeys: + +```typescript +const passkey: PasskeyArgType = { + rawId, + publicKey, +} +const params: AddPasskeyOwnerTxParams = { + passkey, + threshold // Optional. If `threshold` isn't provided the current threshold won't change. +} +const safeTransaction = await protocolKit.createAddOwnerTx(params) +const txResponse = await protocolKit.executeTransaction(safeTransaction) +await txResponse.transactionResponse?.wait() +``` + This method can optionally receive the `options` parameter: ```typescript @@ -591,6 +631,17 @@ Checks if a specific address is an owner of the current Safe. const isOwner = await protocolKit.isOwner(address) ``` +A Passkey can be used to check if it is an owner of the current Safe. + +```typescript +const passkey: PasskeyArgType = { + rawId, + publicKey, +} + +const isOwner = await protocolKit.isOwner(passkey) +``` + ## Threshold ### `createChangeThresholdTx` diff --git a/pages/sdk/relay-kit/reference/safe-4337-pack.mdx b/pages/sdk/relay-kit/reference/safe-4337-pack.mdx index 9d963667..230526b2 100644 --- a/pages/sdk/relay-kit/reference/safe-4337-pack.mdx +++ b/pages/sdk/relay-kit/reference/safe-4337-pack.mdx @@ -40,7 +40,7 @@ The `Safe4337InitOptions` used in the `init()` method are: ```typescript Safe4337InitOptions = { provider: Eip1193Provider | HttpTransport | SocketTransport - signer?: HexAddress | PrivateKey + signer?: HexAddress | PrivateKey | PasskeyArgType bundlerUrl: string rpcUrl: string safeModulesVersion?: string @@ -89,7 +89,7 @@ PaymasterOptions = { ``` - **`provider`** : The EIP-1193 compatible provider or RPC URL of the selected chain. -- **`signer`** : The signer private address if the `provider` doesn't resolve to a signer account. If the `provider` resolves to multiple signer addresses, the `signer` property can be used to specify which account to connect, otherwise the first address returned will be used. +- **`signer`** : A passkey or the signer private address if the `provider` doesn't resolve to a signer account. If the `provider` resolves to multiple signer addresses, the `signer` property can be used to specify which account to connect, otherwise the first address returned will be used. - **`rpcUrl`** : The RPC URL of the selected chain. - **`bundlerUrl`** : The bundler's URL. - **`safeModulesVersion`** : The version of the [Safe Modules contract](https://github.com/safe-global/safe-modules-deployments/tree/main/src/assets/safe-4337-module). From ae4ee39d774d460631b6db91526da8a7ea067ad3 Mon Sep 17 00:00:00 2001 From: Dani Somoza Date: Thu, 6 Jun 2024 13:04:57 +0200 Subject: [PATCH 2/6] Update pages/sdk/protocol-kit/reference/safe-factory.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Germán Martínez <6764315+germartinez@users.noreply.github.com> --- pages/sdk/protocol-kit/reference/safe-factory.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/sdk/protocol-kit/reference/safe-factory.md b/pages/sdk/protocol-kit/reference/safe-factory.md index 2dd35777..bb11b961 100644 --- a/pages/sdk/protocol-kit/reference/safe-factory.md +++ b/pages/sdk/protocol-kit/reference/safe-factory.md @@ -15,9 +15,9 @@ const safeFactory = await SafeFactory.init({ }) ``` -#### Using passkeys +- The `signer` property -A Passkey can be used as a signer to create an instance of the Safe Factory. + A passkey object can be passed as a signer to initialize an instance of the Safe Factory. ```typescript import { SafeFactory, PasskeyArgType } from '@safe-global/protocol-kit' From c8724ba23269ad403b72ee9dcb2a7bc28c50a85d Mon Sep 17 00:00:00 2001 From: Dani Somoza Date: Thu, 6 Jun 2024 13:05:12 +0200 Subject: [PATCH 3/6] Update pages/sdk/protocol-kit/reference/safe.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Germán Martínez <6764315+germartinez@users.noreply.github.com> --- pages/sdk/protocol-kit/reference/safe.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/sdk/protocol-kit/reference/safe.md b/pages/sdk/protocol-kit/reference/safe.md index 2a4cdfc9..937cca4b 100644 --- a/pages/sdk/protocol-kit/reference/safe.md +++ b/pages/sdk/protocol-kit/reference/safe.md @@ -37,9 +37,9 @@ const protocolKit = await Safe.init({ }) ``` -#### Using passkeys +- The `signer` property -A Passkey can be used as a signer to create an instance of the Protocol Kit. + A passkey object can be passed as a signer to initialize an instance of the Protocol Kit. ```typescript import Safe from '@safe-global/protocol-kit' From f3686d208562dff37b355dbad0ece7d1eee1114d Mon Sep 17 00:00:00 2001 From: Dani Somoza Date: Thu, 6 Jun 2024 13:05:27 +0200 Subject: [PATCH 4/6] Update pages/sdk/protocol-kit/reference/safe.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Germán Martínez <6764315+germartinez@users.noreply.github.com> --- pages/sdk/protocol-kit/reference/safe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/sdk/protocol-kit/reference/safe.md b/pages/sdk/protocol-kit/reference/safe.md index 937cca4b..54f64f65 100644 --- a/pages/sdk/protocol-kit/reference/safe.md +++ b/pages/sdk/protocol-kit/reference/safe.md @@ -537,7 +537,7 @@ const txResponse = await protocolKit.executeTransaction(safeTransaction) await txResponse.transactionResponse?.wait() ``` -This method can be used with Passkeys: +Instead of using an address, this method also supports the use of a passkey to set the address of the new owner: ```typescript const passkey: PasskeyArgType = { From ba01ca3203e886899c579b25a89c641ac42affb5 Mon Sep 17 00:00:00 2001 From: Dani Somoza Date: Thu, 6 Jun 2024 13:05:43 +0200 Subject: [PATCH 5/6] Update pages/sdk/protocol-kit/reference/safe.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Germán Martínez <6764315+germartinez@users.noreply.github.com> --- pages/sdk/protocol-kit/reference/safe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/sdk/protocol-kit/reference/safe.md b/pages/sdk/protocol-kit/reference/safe.md index 54f64f65..dd570e19 100644 --- a/pages/sdk/protocol-kit/reference/safe.md +++ b/pages/sdk/protocol-kit/reference/safe.md @@ -631,7 +631,7 @@ Checks if a specific address is an owner of the current Safe. const isOwner = await protocolKit.isOwner(address) ``` -A Passkey can be used to check if it is an owner of the current Safe. +A passkey can also be used to check if the signer account is an owner of the current Safe. ```typescript const passkey: PasskeyArgType = { From d9504110042347da786c775326c542fda2aad834 Mon Sep 17 00:00:00 2001 From: Dani Somoza Date: Thu, 6 Jun 2024 13:06:14 +0200 Subject: [PATCH 6/6] Update pages/sdk/relay-kit/reference/safe-4337-pack.mdx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Germán Martínez <6764315+germartinez@users.noreply.github.com> --- pages/sdk/relay-kit/reference/safe-4337-pack.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/sdk/relay-kit/reference/safe-4337-pack.mdx b/pages/sdk/relay-kit/reference/safe-4337-pack.mdx index 230526b2..8e2f1d4c 100644 --- a/pages/sdk/relay-kit/reference/safe-4337-pack.mdx +++ b/pages/sdk/relay-kit/reference/safe-4337-pack.mdx @@ -89,7 +89,7 @@ PaymasterOptions = { ``` - **`provider`** : The EIP-1193 compatible provider or RPC URL of the selected chain. -- **`signer`** : A passkey or the signer private address if the `provider` doesn't resolve to a signer account. If the `provider` resolves to multiple signer addresses, the `signer` property can be used to specify which account to connect, otherwise the first address returned will be used. +- **`signer`** : A passkey or the signer private key if the `provider` doesn't resolve to a signer account. If the `provider` resolves to multiple signer addresses, the `signer` property can be used to specify which account to connect, otherwise the first address returned will be used. - **`rpcUrl`** : The RPC URL of the selected chain. - **`bundlerUrl`** : The bundler's URL. - **`safeModulesVersion`** : The version of the [Safe Modules contract](https://github.com/safe-global/safe-modules-deployments/tree/main/src/assets/safe-4337-module).