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

docs: Passkeys in the SDK references #495

Merged
merged 6 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pages/sdk/protocol-kit/reference/safe-factory.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ const safeFactory = await SafeFactory.init({
})
```

- The `signer` property

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'

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.
Expand Down Expand Up @@ -52,6 +71,7 @@ const safeFactory = await SafeFactory.init({
signMessageLibAddress: '<SIGN_MESSAGE_LIB_ADDRESS>',
createCallAddress: '<CREATE_CALL_ADDRESS>',
simulateTxAccessorAddress: '<SIMULATE_TX_ACCESSOR_ADDRESS>',
safeWebAuthnSignerFactoryAddress:'<SAFE_WEB_AUTHN_SIGNER_FACTORY_ADDRESS>',
safeSingletonAbi: '<SINGLETON_ABI>', // Optional. Only needed with web3.js
safeProxyFactoryAbi: '<PROXY_FACTORY_ABI>', // Optional. Only needed with web3.js
multiSendAbi: '<MULTI_SEND_ABI>', // Optional. Only needed with web3.js
Expand All @@ -60,6 +80,7 @@ const safeFactory = await SafeFactory.init({
signMessageLibAbi: '<SIGN_MESSAGE_LIB_ABI>', // Optional. Only needed with web3.js
createCallAbi: '<CREATE_CALL_ABI>', // Optional. Only needed with web3.js
simulateTxAccessorAbi: '<SIMULATE_TX_ACCESSOR_ABI>' // Optional. Only needed with web3.js
safeWebAuthnSignerFactoryAbi: '<SAFE_WEB_AUTHN_SIGNER_FACTORY_ABI>' // Optional. Only needed with web3.js
}
}

Expand Down
51 changes: 51 additions & 0 deletions pages/sdk/protocol-kit/reference/safe.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ const protocolKit = await Safe.init({
})
```

- The `signer` property

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'

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.
Expand Down Expand Up @@ -75,6 +95,7 @@ const protocolKit = await Safe.init({
signMessageLibAddress: '<SIGN_MESSAGE_LIB_ADDRESS>',
createCallAddress: '<CREATE_CALL_ADDRESS>',
simulateTxAccessorAddress: '<SIMULATE_TX_ACCESSOR_ADDRESS>',
safeWebAuthnSignerFactoryAddress:'<SAFE_WEB_AUTHN_SIGNER_FACTORY_ADDRESS>',
safeSingletonAbi: '<SINGLETON_ABI>', // Optional. Only needed with web3.js
safeProxyFactoryAbi: '<PROXY_FACTORY_ABI>', // Optional. Only needed with web3.js
multiSendAbi: '<MULTI_SEND_ABI>', // Optional. Only needed with web3.js
Expand All @@ -83,6 +104,7 @@ const protocolKit = await Safe.init({
signMessageLibAbi: '<SIGN_MESSAGE_LIB_ABI>', // Optional. Only needed with web3.js
createCallAbi: '<CREATE_CALL_ABI>', // Optional. Only needed with web3.js
simulateTxAccessorAbi: '<SIMULATE_TX_ACCESSOR_ABI>' // Optional. Only needed with web3.js
safeWebAuthnSignerFactoryAbi: '<SAFE_WEB_AUTHN_SIGNER_FACTORY_ABI>' // Optional. Only needed with web3.js
}
}

Expand Down Expand Up @@ -174,6 +196,7 @@ protocolKit = await protocolKit.connect({ predictedSafe })
signMessageLibAddress: '<SIGN_MESSAGE_LIB_ADDRESS>',
createCallAddress: '<CREATE_CALL_ADDRESS>',
simulateTxAccessorAddress: '<SIMULATE_TX_ACCESSOR_ADDRESS>',
safeWebAuthnSignerFactoryAddress:'<SAFE_WEB_AUTHN_SIGNER_FACTORY_ADDRESS>',
safeSingletonAbi: '<SINGLETON_ABI>', // Optional. Only needed with web3.js
safeProxyFactoryAbi: '<PROXY_FACTORY_ABI>', // Optional. Only needed with web3.js
multiSendAbi: '<MULTI_SEND_ABI>', // Optional. Only needed with web3.js
Expand All @@ -182,6 +205,7 @@ protocolKit = await protocolKit.connect({ predictedSafe })
signMessageLibAbi: '<SIGN_MESSAGE_LIB_ABI>', // Optional. Only needed with web3.js
createCallAbi: '<CREATE_CALL_ABI>', // Optional. Only needed with web3.js
simulateTxAccessorAbi: '<SIMULATE_TX_ACCESSOR_ABI>' // Optional. Only needed with web3.js
safeWebAuthnSignerFactoryAbi: '<SAFE_WEB_AUTHN_SIGNER_FACTORY_ABI>' // Optional. Only needed with web3.js
}
}

Expand Down Expand Up @@ -513,6 +537,22 @@ const txResponse = await protocolKit.executeTransaction(safeTransaction)
await txResponse.transactionResponse?.wait()
```

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 = {
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
Expand Down Expand Up @@ -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 also be used to check if the signer account is an owner of the current Safe.

```typescript
const passkey: PasskeyArgType = {
rawId,
publicKey,
}

const isOwner = await protocolKit.isOwner(passkey)
```

## Threshold

### `createChangeThresholdTx`
Expand Down
4 changes: 2 additions & 2 deletions pages/sdk/relay-kit/reference/safe-4337-pack.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 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).
Expand Down
Loading