Skip to content

Commit

Permalink
docs(sdk): Update migration guides (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
yagopv authored and germartinez committed May 22, 2024
1 parent 41b2e33 commit 57e2a68
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Migrating to v1
# Migrate to v1

This guide references the major changes between `safe-service-client` and `api-kit` v1 to help those migrating an existing application.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Migrating to v2
# Migrate to v2

This guide references the major changes between v1 and v2 to help those migrating an existing app.

Expand Down
9 changes: 5 additions & 4 deletions pages/sdk/protocol-kit/reference/_meta.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"safe-factory": "Safe Factory",
"safe": "Safe",
"migrating-to-v1": "Migrating to V1",
"migrating-to-v2": "Migrating to V2"
"safe-factory": "Safe Factory",
"safe": "Safe",
"migrate-to-v1": "Migrate to v1",
"migrate-to-v2": "Migrate to v2",
"migrate-to-v3": "Migrate to v3"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Migrating to v1
# Migrate to v1

This guide references the major changes between `safe-core-sdk` and `protocol-kit` v1 to help those migrating an existing application.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Migrating to v2
# Migrate to v2

This guide references the major changes between v1 and v2 to help those migrating an existing app.

Expand Down
21 changes: 21 additions & 0 deletions pages/sdk/protocol-kit/reference/migrate-to-v3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Migrate to v3

This guide references the major changes between v2 and v3 to help those migrating an existing app.

**Note:** When upgrading to `protocol-kit` v3, it's necessary to upgrade to `safe-core-sdk-types` v4.

## The signTransactionHash() was renamed signHash()

The `signTransactionHash()` method was renamed to `signHash()` to align with the method's purpose. The method is not strictly for transactions, as the parameter is a hash, so the new name is more accurate.

```js
// old:
protocolKit.signTransactionHash(safeTxHash);

// new:
protocolKit.signHash(safeTxHash);
```

## Type changes

The `SafeTransactionEIP712Args` was renamed `SafeEIP712Args` as the EIP-712 is not exclusive for transactions.
79 changes: 79 additions & 0 deletions pages/sdk/protocol-kit/reference/migrate-to-v4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Migrate to v4

This guide references the major changes between v3 and v4 to help those migrating an existing app.

**Note:** When upgrading to `protocol-kit` v4, it's necessary to upgrade to `safe-core-sdk-types` v5.

## The create() method was renamed init() in the SafeFactory and Safe classes

We renamed the `create()` method to `init()` to better reflect the method's purpose. The term `create()` was misleading, suggesting a new Safe account would be created and deployed. However, this method only initializes the `Safe` class, so `init()` is a more accurate and descriptive name.

```js
// old
const protocolKit = await Safe.create({ ... })
const safeFactory = await SafeFactory.create({ ... })

// new
const protocolKit = await Safe.init({ ... })
const safeFactory = await SafeFactory.init({ ... })
```

## Remove the adapters

We have removed the concept of adapters from the `protocol-kit` to simplify the library. Instead of using specific library adapters, we use now an internal `SafeProvider` object to interact with the Safe. This `SafeProvider` will be created using:

- An Ethereum provider, an [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) compatible provider, or an RPC URL.
- An optional address of the signer that is connected to the provider or a private key. If not provided, the first account of the provider (`eth_accounts`) will be selected as the signer.

The `EthAdapter` interface, the `EthersAdapter` class, and the `Web3Adapter` class are no longer available. Similarly, `EthersAdapterConfig` and `Web3AdapterConfig` were removed as well.


```js
// old
const ethAdapter = new EthersAdapter({ ethers, signerOrProvider })
// const ethAdapter = new Web3Adapter({ web3, signerAddress })
await Safe.create({
ethAdapter,
safeAddress: '0xSafeAddress'
...
})

// new
await Safe.init({
provider: window.ethereum, // Or any compatible EIP-1193 provider
signer: "0xSignerAddressOrPrivateKey", // Signer address or private key
safeAddress: '0xSafeAddress'
...
})

// ...or...
await Safe.init({
provider: 'http://rpc.url', // Or websocket
signer: '0xPrivateKey' // Signer private key
safeAddress: '0xSafeAddress'
...
})
```

## `EthersTransactionOptions` and `Web3TransactionOptions` types are now `TransactionOptions`

Together with the adapters, we also removed the specific transaction options objects for each library, leaving just a single `TransactionOptions` type.

We removed the `gas` property from the `TransactionOptions` object as it was a specific property for the web3.js library. Now, you should use the `gasLimit` property instead.

## `EthersTransactionResult` and `Web3TransactionResult` types are now `TransactionResult`

Together with the adapters, we also removed the specific transaction result objects for each library, leaving just a single `TransactionResult` type.

## Contract classes suffixed with Ethers and Web3

All the contract classes that were suffixed with `Ethers` or `Web3` were renamed to remove the suffix.

```js
SafeBaseContractEthers, SafeBaseContractWeb3 -> SafeBaseContract
MultiSendBaseContractEthers, MultiSendBaseContractWeb3 -> MultiSendBaseContract
MultiSendCallOnlyBaseContractEthers, MultiSendCallOnlyBaseContractWeb3 -> MultiSendCallOnlyBaseContract
SafeProxyFactoryBaseContractEthers, SafeProxyFactoryBaseContractWeb3 -> SafeProxyFactoryBaseContract
SignMessageLibBaseContractEthers, SignMessageLibBaseContractWeb3 -> SignMessageLibBaseContract
CreateCallBaseContractEthers, CreateCallBaseContractWeb3 -> CreateCallBaseContract
```
3 changes: 2 additions & 1 deletion pages/sdk/relay-kit/reference/_meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"safe-4337-pack": "Safe4337Pack",
"migrating-to-v2": "Migrating to V2"
"migrate-to-v2": "Migrate to v2",
"migrate-to-v3": "Migrate to v3"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Migrating to v2
# Migrate to v2

This guide references the major changes between v1 and v2 to help those migrating an existing app.

Expand Down
35 changes: 35 additions & 0 deletions pages/sdk/relay-kit/reference/migrate-to-v3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Migrate to v3

This guide references the major changes between v2 and v3 to help those migrating an existing app.

## Remove the adapters

We have removed the concept of adapters from the `protocol-kit` to simplify the library. Instead of using specific library adapters, we use now an internal `SafeProvider` object to interact with the Safe. This `SafeProvider` will be created using:

- An Ethereum provider, an [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) compatible provider, or an RPC URL.
- An optional address of the signer that is connected to the provider or a private key. If not provided, the first account of the provider (`eth_accounts`) will be selected as the signer.

These changes affect the creation of the `Safe4337Pack` instance, as it was previously using an `ethAdapter` compatible object.

```typescript
// old
const safe4337Pack = await Safe4337Pack.init({
ethAdapter: new EthersAdapter({ ethers, signerOrProvider }),
// ...
});
```

```typescript
// new
const safe4337Pack = await Safe4337Pack.init({
provider: window.ethereum, // Or any compatible EIP-1193 provider,
signer: "signerAddressOrPrivateKey", // Signer address or signer private key
// ...
});

const safe4337Pack = await Safe4337Pack.init({
provider: "http://rpc.url", // Or websocket
signer: "privateKey", // Signer private key
// ...
});
```
47 changes: 36 additions & 11 deletions redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,22 +231,32 @@
},
{
"source": "/safe-core-aa-sdk/protocol-kit/reference/v1",
"destination": "/sdk/protocol-kit/reference/migrating-to-v1",
"destination": "/sdk/protocol-kit/reference/migrate-to-v1",
"permanent": true
},
{
"source": "/sdk-protocol-kit/reference/migrating-to-v1",
"destination": "/sdk/protocol-kit/reference/migrating-to-v1",
"destination": "/sdk/protocol-kit/reference/migrate-to-v1",
"permanent": true
},
{
"source": "/sdk/protocol-kit/reference/migrating-to-v1",
"destination": "/sdk/protocol-kit/reference/migrate-to-v1",
"permanent": true
},
{
"source": "/safe-core-aa-sdk/protocol-kit/reference/v2",
"destination": "/sdk/protocol-kit/reference/migrating-to-v2",
"destination": "/sdk/protocol-kit/reference/migrate-to-v2",
"permanent": true
},
{
"source": "/sdk-protocol-kit/reference/migrating-to-v2",
"destination": "/sdk/protocol-kit/reference/migrating-to-v2",
"destination": "/sdk/protocol-kit/reference/migrate-to-v2",
"permanent": true
},
{
"source": "/sdk/protocol-kit/reference/migrating-to-v2",
"destination": "/sdk/protocol-kit/reference/migrate-to-v2",
"permanent": true
},
{
Expand Down Expand Up @@ -341,12 +351,17 @@
},
{
"source": "/safe-core-aa-sdk/relay-kit/reference/v2",
"destination": "/sdk/relay-kit/reference/migrating-to-v2",
"destination": "/sdk/relay-kit/reference/migrate-to-v2",
"permanent": true
},
{
"source": "/sdk-relay-kit/reference/migrating-to-v2",
"destination": "/sdk/relay-kit/reference/migrating-to-v2",
"destination": "/sdk/relay-kit/reference/migrate-to-v2",
"permanent": true
},
{
"source": "/sdk/relay-kit/reference/migrating-to-v2",
"destination": "/sdk/relay-kit/reference/migrate-to-v2",
"permanent": true
},
{
Expand All @@ -371,22 +386,32 @@
},
{
"source": "/safe-core-aa-sdk/api-kit/reference/v1",
"destination": "/sdk/api-kit/reference/migrating-to-v1",
"destination": "/sdk/api-kit/reference/migrate-to-v1",
"permanent": true
},
{
"source": "/sdk-api-kit/reference/migrating-to-v1",
"destination": "/sdk/api-kit/reference/migrating-to-v1",
"destination": "/sdk/api-kit/reference/migrate-to-v1",
"permanent": true
},
{
"source": "/sdk/api-kit/reference/migrating-to-v1",
"destination": "/sdk/api-kit/reference/migrate-to-v1",
"permanent": true
},
{
"source": "/safe-core-aa-sdk/api-kit/reference/v2",
"destination": "/sdk/api-kit/reference/migrating-to-v2",
"destination": "/sdk/api-kit/reference/migrate-to-v2",
"permanent": true
},
{
"source": "/sdk/api-kit/reference/migrating-to-v2",
"destination": "/sdk/api-kit/reference/migrate-to-v2",
"permanent": true
},
{
"source": "/sdk-api-kit/reference/migrating-to-v2",
"destination": "/sdk/api-kit/reference/migrating-to-v2",
"source": "/sdk/api-kit/reference/migrating-to-v2",
"destination": "/sdk/api-kit/reference/migrate-to-v2",
"permanent": true
},
{
Expand Down

0 comments on commit 57e2a68

Please sign in to comment.