-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(sdk): Update migration guides (#473)
- Loading branch information
1 parent
41b2e33
commit 57e2a68
Showing
11 changed files
with
183 additions
and
21 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.../sdk/api-kit/reference/migrating-to-v1.md → pages/sdk/api-kit/reference/migrate-to-v1.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../sdk/api-kit/reference/migrating-to-v2.md → pages/sdk/api-kit/reference/migrate-to-v2.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
2 changes: 1 addition & 1 deletion
2
...protocol-kit/reference/migrating-to-v1.md → ...k/protocol-kit/reference/migrate-to-v1.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...protocol-kit/reference/migrating-to-v2.md → ...k/protocol-kit/reference/migrate-to-v2.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
2 changes: 1 addition & 1 deletion
2
...dk/relay-kit/reference/migrating-to-v2.md → .../sdk/relay-kit/reference/migrate-to-v2.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
// ... | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters