From 2f9a2856d65e27a2a219fffe0db8fcd9e79897d3 Mon Sep 17 00:00:00 2001 From: Daniel Somoza Date: Fri, 27 Oct 2023 10:55:56 +0200 Subject: [PATCH 01/29] update ethers docs --- examples/package.json | 2 +- examples/protocol-kit/index.ts | 10 ++-- examples/relay-kit/index.ts | 4 +- examples/yarn.lock | 50 +++++++++++++++++++ .../safe-core-sdk/auth-kit/AuthKitBasePack.md | 2 +- .../auth-kit/Web3AuthModalPack.md | 2 +- safe-core-sdk/api-kit/README.md | 4 +- safe-core-sdk/auth-kit/web3auth.md | 6 +-- safe-core-sdk/protocol-kit/README.md | 12 ++--- safe-core-sdk/relay-kit/gelato.md | 8 +-- safe-smart-account/signatures/eip-1271.md | 4 +- 11 files changed, 77 insertions(+), 27 deletions(-) diff --git a/examples/package.json b/examples/package.json index c9b062f9..894a091b 100644 --- a/examples/package.json +++ b/examples/package.json @@ -13,6 +13,6 @@ "@safe-global/relay-kit": "^1.0.0", "@safe-global/safe-core-sdk-types": "^2.0.0", "dotenv": "^16.0.3", - "ethers": "5.7.2" + "ethers": "^6.8.0" } } diff --git a/examples/protocol-kit/index.ts b/examples/protocol-kit/index.ts index fa3060ac..8f5a5174 100644 --- a/examples/protocol-kit/index.ts +++ b/examples/protocol-kit/index.ts @@ -9,7 +9,7 @@ import { ethers } from 'ethers' // https://chainlist.org/?search=goerli&testnets=true const RPC_URL = 'https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161' -const provider = new ethers.providers.JsonRpcProvider(RPC_URL) +const provider = new ethers.JsonRpcProvider(RPC_URL) // Initialize signers @@ -74,7 +74,7 @@ async function initalizeSafe(existingAddress = EXISTING_SAFE_ADDRESS) { async function depositToSafe(depositSigner = owner1Signer, amount = '0.01') { - const safeAmount = ethers.utils.parseUnits(amount, 'ether').toHexString() + const safeAmount = ethers.parseUnits(amount, 'ether').toHexString() const transactionParameters = { to: safeAddress, @@ -91,7 +91,7 @@ async function proposeTransaction(withdrawAmount = '0.005', destination = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045') { // Create a transaction object - withdrawAmount = ethers.utils.parseUnits(withdrawAmount, 'ether').toString() + withdrawAmount = ethers.parseUnits(withdrawAmount, 'ether').toString() const safeTransactionData: SafeTransactionDataPartial = { to: destination, @@ -145,7 +145,7 @@ async function executeTransaction(safeTxHash: string, safeSdk: Safe = safeSdkOwn let safeBalance = await safeSdk.getBalance() - console.log(`[Before Transaction] Safe Balance: ${ethers.utils.formatUnits(safeBalance, 'ether')} ETH`) + console.log(`[Before Transaction] Safe Balance: ${ethers.formatUnits(safeBalance, 'ether')} ETH`) const safeTransaction = await safeService.getTransaction(safeTxHash) const executeTxResponse = await safeSdk.executeTransaction(safeTransaction) @@ -156,7 +156,7 @@ async function executeTransaction(safeTxHash: string, safeSdk: Safe = safeSdkOwn safeBalance = await safeSdk.getBalance() - console.log(`[After Transaction] Safe Balance: ${ethers.utils.formatUnits(safeBalance, 'ether')} ETH`) + console.log(`[After Transaction] Safe Balance: ${ethers.formatUnits(safeBalance, 'ether')} ETH`) } async function main() { diff --git a/examples/relay-kit/index.ts b/examples/relay-kit/index.ts index 296c1530..68483c12 100644 --- a/examples/relay-kit/index.ts +++ b/examples/relay-kit/index.ts @@ -6,14 +6,14 @@ import { MetaTransactionData, MetaTransactionOptions, OperationType, RelayTransa // Customize the following variables // https://chainlist.org const RPC_URL = 'https://endpoints.omniatech.io/v1/bsc/mainnet/public' -const provider = new ethers.providers.JsonRpcProvider(RPC_URL) +const provider = new ethers.JsonRpcProvider(RPC_URL) const signer = new ethers.Wallet(process.env.OWNER_1_PRIVATE_KEY!, provider) const safeAddress = '0x6651FD6Abe0843f7B6CB9047b89655cc7Aa78221' // Safe from which the transaction will be sent. Replace with your Safe address const chainId = 56 // Any address can be used for destination. In this example, we use vitalik.eth const destinationAddress = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' -const withdrawAmount = ethers.utils.parseUnits('0.0005', 'ether').toString() +const withdrawAmount = ethers.parseUnits('0.0005', 'ether').toString() // Get Gelato Relay API Key: https://relay.gelato.network/ const GELATO_RELAY_API_KEY = process.env.GELATO_RELAY_API_KEY! diff --git a/examples/yarn.lock b/examples/yarn.lock index bdde832c..081ec313 100644 --- a/examples/yarn.lock +++ b/examples/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@adraffy/ens-normalize@1.10.0": + version "1.10.0" + resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz#d2a39395c587e092d77cbbc80acf956a54f38bf7" + integrity sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q== + "@ethereumjs/common@2.5.0": version "2.5.0" resolved "https://registry.yarnpkg.com/@ethereumjs/common/-/common-2.5.0.tgz#ec61551b31bef7a69d1dc634d8932468866a4268" @@ -376,6 +381,18 @@ axios "0.24.0" ethers "5.7.2" +"@noble/curves@1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.2.0.tgz#92d7e12e4e49b23105a2555c6984d41733d65c35" + integrity sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw== + dependencies: + "@noble/hashes" "1.3.2" + +"@noble/hashes@1.3.2": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39" + integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== + "@safe-global/api-kit@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@safe-global/api-kit/-/api-kit-1.1.0.tgz#b46bcb4491d43576832488183019769d37e3f3e6" @@ -481,6 +498,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-20.1.0.tgz#258805edc37c327cf706e64c6957f241ca4c4c20" integrity sha512-O+z53uwx64xY7D6roOi4+jApDGFg0qn6WHcxe5QeqjMaTezBO/mxdfFXIVAVVyNWKx84OmPB3L8kbVYOTeN34A== +"@types/node@18.15.13": + version "18.15.13" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.15.13.tgz#f64277c341150c979e42b00e4ac289290c9df469" + integrity sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q== + "@types/node@^12.12.6": version "12.20.55" resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240" @@ -525,6 +547,11 @@ aes-js@3.0.0: resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.0.0.tgz#e21df10ad6c2053295bcbb8dab40b09dbea87e4d" integrity sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw== +aes-js@4.0.0-beta.5: + version "4.0.0-beta.5" + resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-4.0.0-beta.5.tgz#8d2452c52adedebc3a3e28465d858c11ca315873" + integrity sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q== + ajv@^6.12.3: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" @@ -1149,6 +1176,19 @@ ethers@5.7.2, ethers@^5.7.2: "@ethersproject/web" "5.7.1" "@ethersproject/wordlists" "5.7.0" +ethers@^6.8.0: + version "6.8.0" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.8.0.tgz#0a26f57e96fd697cefcfcef464e0c325689d1daf" + integrity sha512-zrFbmQRlraM+cU5mE4CZTLBurZTs2gdp2ld0nG/f3ecBK+x6lZ69KSxBqZ4NjclxwfTxl5LeNufcBbMsTdY53Q== + dependencies: + "@adraffy/ens-normalize" "1.10.0" + "@noble/curves" "1.2.0" + "@noble/hashes" "1.3.2" + "@types/node" "18.15.13" + aes-js "4.0.0-beta.5" + tslib "2.4.0" + ws "8.5.0" + ethjs-unit@0.1.6: version "0.1.6" resolved "https://registry.yarnpkg.com/ethjs-unit/-/ethjs-unit-0.1.6.tgz#c665921e476e87bce2a9d588a6fe0405b2c41699" @@ -2323,6 +2363,11 @@ tr46@~0.0.3: resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== +tslib@2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" + integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== + tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" @@ -2725,6 +2770,11 @@ ws@7.4.6: resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c" integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== +ws@8.5.0: + version "8.5.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.5.0.tgz#bfb4be96600757fe5382de12c670dab984a1ed4f" + integrity sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg== + ws@^3.0.0: version "3.3.3" resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2" diff --git a/reference/safe-core-sdk/auth-kit/AuthKitBasePack.md b/reference/safe-core-sdk/auth-kit/AuthKitBasePack.md index 81125fb9..154dd0da 100644 --- a/reference/safe-core-sdk/auth-kit/AuthKitBasePack.md +++ b/reference/safe-core-sdk/auth-kit/AuthKitBasePack.md @@ -36,7 +36,7 @@ Provides a mechanism to connect to the provider services and returns an Ethereum Disconnects the provider services and cleans up any data related to the current user. -### `getProvider(): web3Provider` +### `getProvider(): BrowserProvider` Returns a Web3 provider that can be used to interact with the blockchain (`web3.js` or `ethers.js` for example). diff --git a/reference/safe-core-sdk/auth-kit/Web3AuthModalPack.md b/reference/safe-core-sdk/auth-kit/Web3AuthModalPack.md index 72825461..81e50315 100644 --- a/reference/safe-core-sdk/auth-kit/Web3AuthModalPack.md +++ b/reference/safe-core-sdk/auth-kit/Web3AuthModalPack.md @@ -140,7 +140,7 @@ await web3AuthModalPack.init(web3AuthModalOptions, adapters, modalConfig) // Sign in const { eoa, safes } = await web3AuthModalPack.signIn() const userInfo = await web3AuthModalPack.getUserInfo() -const web3Provider = web3AuthModalPack.getProvider() +const BrowserProvider = web3AuthModalPack.getProvider() // Subscribe to events const handler = (event) => {} diff --git a/safe-core-sdk/api-kit/README.md b/safe-core-sdk/api-kit/README.md index 4e463d53..494e4e86 100644 --- a/safe-core-sdk/api-kit/README.md +++ b/safe-core-sdk/api-kit/README.md @@ -24,7 +24,7 @@ yarn add @safe-global/api-kit ## Instantiate an EthAdapter -First of all, we need to create an `EthAdapter`, which contains all the required utilities for the SDKs to interact with the blockchain. It acts as a wrapper for [web3.js](https://web3js.readthedocs.io/) or [ethers.js](https://docs.ethers.io/v5/) Ethereum libraries. +First of all, we need to create an `EthAdapter`, which contains all the required utilities for the SDKs to interact with the blockchain. It acts as a wrapper for [web3.js](https://web3js.readthedocs.io/) or [ethers.js](https://docs.ethers.org/v6/) Ethereum libraries. Depending on the library used by the Dapp, there are two options: @@ -36,7 +36,7 @@ Once the instance of `EthersAdapter` or `Web3Adapter` is created, it can be used ```typescript import { EthersAdapter } from '@safe-global/protocol-kit' -const provider = new ethers.providers.JsonRpcProvider(config.RPC_URL) +const provider = new ethers.JsonRpcProvider(config.RPC_URL) const signer = new ethers.Wallet(config.SIGNER_ADDRESS_PRIVATE_KEY, provider) const ethAdapter = new EthersAdapter({ diff --git a/safe-core-sdk/auth-kit/web3auth.md b/safe-core-sdk/auth-kit/web3auth.md index 9d6d9119..459ed7c3 100644 --- a/safe-core-sdk/auth-kit/web3auth.md +++ b/safe-core-sdk/auth-kit/web3auth.md @@ -145,7 +145,7 @@ Once connected, you can use any of the methods available in the [Protocol Kit](h import { ethers } from 'ethers' import { EthersAdapter } from '@safe-global/protocol-kit' -provider = new ethers.providers.Web3Provider(web3AuthModalPack.getProvider()) +provider = new ethers.BrowserProvider(web3AuthModalPack.getProvider()) signer = provider.getSigner() const ethAdapter = new EthersAdapter({ @@ -162,7 +162,7 @@ const safeSDK = await Safe.create({ const safeTransactionData: MetaTransactionData = { to: '0x', data: '0x', - value: ethers.utils.parseUnits('0.0001', 'ether').toString() + value: ethers.parseUnits('0.0001', 'ether').toString() } const safeTransaction = await safeSDK.createTransaction({ safeTransactionData }) @@ -183,7 +183,7 @@ const address = '0x...' await web3.eth.personal.sign(message, address) // Using ethers -const provider = new ethers.providers.Web3Provider(web3AuthModalPack.getProvider()) +const provider = new ethers.BrowserProvider(web3AuthModalPack.getProvider()) const signer = provider.getSigner() await signer.sendTransaction(tx) diff --git a/safe-core-sdk/protocol-kit/README.md b/safe-core-sdk/protocol-kit/README.md index 019be1a6..a445ca29 100644 --- a/safe-core-sdk/protocol-kit/README.md +++ b/safe-core-sdk/protocol-kit/README.md @@ -19,12 +19,12 @@ First, we'll need to install some dependences from `safe-core-sdk` and the `ethe To interact with Ethereum and other EVM blockchains in Node, we can either use: web3.js or ethers.js. In this tutorial, we'll use the ethers.js library. To use `web3js`, see [Instantiate an EthAdapter section in Guide: Integrating the Safe Core SDK](https://github.com/safe-global/safe-core-sdk/blob/main/guides/integrating-the-safe-core-sdk.md#instantiate-an-ethadapter). -The Protocol Kit is compatible with ethers v4 and v5, not the latest v6 version so make sure you specify this when installing the SDK. +The Protocol Kit is compatible only with ethers v6. Make sure you specify this version when installing the SDK. You can store your environment variables such as private keys in a `.env` file. To read easily from `.env` files, use the `dotenv` library. ```bash -yarn add ethers@5.7.2 @safe-global/protocol-kit \ +yarn add ethers @safe-global/protocol-kit \ @safe-global/api-kit \ @safe-global/safe-core-sdk-types \ dotenv @@ -73,7 +73,7 @@ dotenv.config() // https://chainlist.org/?search=goerli&testnets=true const RPC_URL='https://eth-goerli.public.blastapi.io' -const provider = new ethers.providers.JsonRpcProvider(RPC_URL) +const provider = new ethers.JsonRpcProvider(RPC_URL) // Initialize signers const owner1Signer = new ethers.Wallet(process.env.OWNER_1_PRIVATE_KEY!, provider) @@ -146,7 +146,7 @@ You will send some ETH to this Safe. ```tsx const safeAddress = safeSdk.getAddress() -const safeAmount = ethers.utils.parseUnits('0.01', 'ether').toHexString() +const safeAmount = ethers.parseUnits('0.01', 'ether').toHexString() const transactionParameters = { to: safeAddress, @@ -191,7 +191,7 @@ import { SafeTransactionDataPartial } from '@safe-global/safe-core-sdk-types' // Any address can be used. In this example you will use vitalik.eth const destination = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' -const amount = ethers.utils.parseUnits('0.005', 'ether').toString() +const amount = ethers.parseUnits('0.005', 'ether').toString() const safeTransactionData: SafeTransactionDataPartial = { to: destination, @@ -275,7 +275,7 @@ You know that the transaction was executed if the balance in your Safe changes. ```tsx const afterBalance = await safeSdk.getBalance() -console.log(`The final balance of the Safe: ${ethers.utils.formatUnits(afterBalance, 'ether')} ETH`) +console.log(`The final balance of the Safe: ${ethers.formatUnits(afterBalance, 'ether')} ETH`) ``` ```bash diff --git a/safe-core-sdk/relay-kit/gelato.md b/safe-core-sdk/relay-kit/gelato.md index c1723c2c..30a20b2c 100644 --- a/safe-core-sdk/relay-kit/gelato.md +++ b/safe-core-sdk/relay-kit/gelato.md @@ -60,13 +60,13 @@ Modify the variables to customize to match your desired transaction settings. ```typescript // https://chainlist.org const RPC_URL='https://endpoints.omniatech.io/v1/bsc/mainnet/public' -const provider = new ethers.providers.JsonRpcProvider(RPC_URL) +const provider = new ethers.JsonRpcProvider(RPC_URL) const signer = new ethers.Wallet(process.env.OWNER_1_PRIVATE_KEY!, provider) const safeAddress = '0x...' // Safe from which the transaction will be sent // Any address can be used for destination. In this example, we use vitalik.eth const destinationAddress = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' -const withdrawAmount = ethers.utils.parseUnits('0.005', 'ether').toString() +const withdrawAmount = ethers.parseUnits('0.005', 'ether').toString() ``` ### Create the transaction object @@ -143,13 +143,13 @@ Modify the variables to customize to match your desired transaction settings. ```typescript // https://chainlist.org const RPC_URL='https://endpoints.omniatech.io/v1/bsc/mainnet/public' -const provider = new ethers.providers.JsonRpcProvider(RPC_URL) +const provider = new ethers.JsonRpcProvider(RPC_URL) const signer = new ethers.Wallet(process.env.OWNER_1_PRIVATE_KEY!, provider) const safeAddress = '0x...' // Safe from which the transaction will be sent // Any address can be used for destination. In this example, we use vitalik.eth const destinationAddress = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' -const withdrawAmount = ethers.utils.parseUnits('0.005', 'ether').toString() +const withdrawAmount = ethers.parseUnits('0.005', 'ether').toString() ``` ### Create the transaction object diff --git a/safe-smart-account/signatures/eip-1271.md b/safe-smart-account/signatures/eip-1271.md index 50977e27..00865e87 100644 --- a/safe-smart-account/signatures/eip-1271.md +++ b/safe-smart-account/signatures/eip-1271.md @@ -2,7 +2,7 @@ The Safe contracts and interface support off-chain [EIP-1271](https://eips.ethereum.org/EIPS/eip-1271) signatures. However, because Safe is a smart account, the flow is slightly different from simple EOA signatures. -This doc explains signing and verifying messages off-chain. All examples use [WalletConnect](https://walletconnect.com/) to connect to the Safe and [ethers](https://ethers.io). +This doc explains signing and verifying messages off-chain. All examples use [WalletConnect](https://walletconnect.com/) to connect to the Safe and [ethers](https://docs.ethers.org/). ## Signing messages @@ -29,7 +29,7 @@ As Safe{Wallet} is a multi signature wallet, this process can take some time bec #### Example: sign message ```typescript -import { hashMessage, hexlify, toUtf8Bytes } from 'ethers/lib/utils' +import { hashMessage, hexlify, toUtf8Bytes } from 'ethers' const signMessage = async (message: string) => { const hexMessage = hexlify(toUtf8Bytes(message)) From 53646d29552dac78010c3387b72844815d025187 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Thu, 23 Nov 2023 14:04:47 +0100 Subject: [PATCH 02/29] add singleton change to api-kit and protocol-kit update api-kit initialization update createTransaction use --- safe-core-sdk/api-kit/README.md | 16 ++- safe-core-sdk/api-kit/reference/README.md | 6 +- safe-core-sdk/auth-kit/guides/web3auth.md | 2 +- .../auth-kit/reference/Web3AuthModalPack.md | 2 +- safe-core-sdk/protocol-kit/README.md | 20 ++- .../protocol-kit/reference/README.md | 124 ++++++++---------- 6 files changed, 82 insertions(+), 88 deletions(-) diff --git a/safe-core-sdk/api-kit/README.md b/safe-core-sdk/api-kit/README.md index 494e4e86..0cfea830 100644 --- a/safe-core-sdk/api-kit/README.md +++ b/safe-core-sdk/api-kit/README.md @@ -47,14 +47,20 @@ const ethAdapter = new EthersAdapter({ ## Initialize the API Kit -We need to create an instance of the API Kit. +We need to create an instance of the API Kit. In those chains where Safe provides a transaction service is enough to specify the chainId. You can specify your own service using the optional `txServiceUrl` parameter. ```typescript import SafeApiKit from '@safe-global/api-kit' const safeApiKit = new SafeApiKit({ - txServiceUrl: 'https://safe-transaction-mainnet.safe.global', - ethAdapter + chainId: 1n +}) + + +// or using a custom service +const safeApiKit = new SafeApiKit({ + chainId: 1n, // set the correct chainId + txServiceUrl: 'https://url-to-your-custom-service' }) ``` @@ -72,14 +78,14 @@ const safe = await Safe.create({ }) // Create transaction -const safeTransactionData: SafeTransactionDataPartial = { +const safeTransactionData: MetaTransactionData = { to: '0x', value: '1', // 1 wei data: '0x', operation: OperationType.Call } -const safeTransaction = await safe.createTransaction({ safeTransactionData }) +const safeTransaction = await safe.createTransaction({ transactions: [safeTransactionData] }) const senderAddress = await signer.getAddress() const safeTxHash = await safe.getTransactionHash(safeTransaction) diff --git a/safe-core-sdk/api-kit/reference/README.md b/safe-core-sdk/api-kit/reference/README.md index 98cdb596..7f305481 100644 --- a/safe-core-sdk/api-kit/reference/README.md +++ b/safe-core-sdk/api-kit/reference/README.md @@ -20,12 +20,12 @@ Returns the information and configuration of the service. const serviceInfo: SafeServiceInfoResponse = await safeService.getServiceInfo() ``` -### `getServiceMasterCopiesInfo` +### `getServiceSingletonsInfo` -Returns the list of Safe master copies. +Returns the list of Safe singletons. ```typescript -const masterCopies: MasterCopyResponse = await safeService.getServiceMasterCopiesInfo() +const singletons: SafeSingletonResponse = await safeService.getServiceSingletonsInfo() ``` ### `decodeData` diff --git a/safe-core-sdk/auth-kit/guides/web3auth.md b/safe-core-sdk/auth-kit/guides/web3auth.md index dc5f4da8..92d69d3c 100644 --- a/safe-core-sdk/auth-kit/guides/web3auth.md +++ b/safe-core-sdk/auth-kit/guides/web3auth.md @@ -165,7 +165,7 @@ const safeTransactionData: MetaTransactionData = { value: ethers.parseUnits('0.0001', 'ether').toString() } -const safeTransaction = await safeSDK.createTransaction({ safeTransactionData }) +const safeTransaction = await safeSDK.createTransaction({ transactions: [safeTransactionData] }) ``` ## Sign messages using the `Web3AuthModalPack` diff --git a/safe-core-sdk/auth-kit/reference/Web3AuthModalPack.md b/safe-core-sdk/auth-kit/reference/Web3AuthModalPack.md index 81e50315..72825461 100644 --- a/safe-core-sdk/auth-kit/reference/Web3AuthModalPack.md +++ b/safe-core-sdk/auth-kit/reference/Web3AuthModalPack.md @@ -140,7 +140,7 @@ await web3AuthModalPack.init(web3AuthModalOptions, adapters, modalConfig) // Sign in const { eoa, safes } = await web3AuthModalPack.signIn() const userInfo = await web3AuthModalPack.getUserInfo() -const BrowserProvider = web3AuthModalPack.getProvider() +const web3Provider = web3AuthModalPack.getProvider() // Subscribe to events const handler = (event) => {} diff --git a/safe-core-sdk/protocol-kit/README.md b/safe-core-sdk/protocol-kit/README.md index a445ca29..b0e88619 100644 --- a/safe-core-sdk/protocol-kit/README.md +++ b/safe-core-sdk/protocol-kit/README.md @@ -88,15 +88,23 @@ const ethAdapterOwner1 = new EthersAdapter({ ### Initialize the API Kit -The [API Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/api-kit) consumes the [Safe Transaction Service API](https://github.com/safe-global/safe-transaction-service). To start using this library, create a new instance of the `SafeApiKit` class, imported from `@safe-global/api-kit`, and pass the Safe Transaction Service URL for your desired network to the constructor of the `SafeApiKit`. +The [API Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/api-kit) consumes the [Safe Transaction Service API](https://github.com/safe-global/safe-transaction-service). To start using this library, create a new instance of the `SafeApiKit` class, imported from `@safe-global/api-kit. In those chains where Safe provides a transaction service is enough to specify the chainId. You can specify your own service using the optional `txServiceUrl` parameter. You will be using Goerli for this tutorial, however, you can also get [service URLs for different networks](../../safe-core-api/available-services.md). ```tsx import SafeApiKit from '@safe-global/api-kit' -const txServiceUrl = 'https://safe-transaction-goerli.safe.global' -const safeService = new SafeApiKit({ txServiceUrl, ethAdapter: ethAdapterOwner1 }) +const safeApiKit = new SafeApiKit({ + chainId: 1n +}) + + +// or using a custom service +const safeApiKit = new SafeApiKit({ + chainId: 1n, // set the correct chainId + txServiceUrl: 'https://url-to-your-custom-service' +}) ``` ### Initialize the Protocol Kit @@ -187,19 +195,19 @@ The high-level overview of a multi-sig transaction is PCE: Propose. Confirm. Exe For more details on what to include in a transaction see [Create a Transaction in the Safe Core SDK Guide](https://github.com/safe-global/safe-core-sdk/blob/main/guides/integrating-the-safe-core-sdk.md#4-create-a-transaction). ```tsx -import { SafeTransactionDataPartial } from '@safe-global/safe-core-sdk-types' +import { MetaTransactionData } from '@safe-global/safe-core-sdk-types' // Any address can be used. In this example you will use vitalik.eth const destination = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' const amount = ethers.parseUnits('0.005', 'ether').toString() -const safeTransactionData: SafeTransactionDataPartial = { +const safeTransactionData: MetaTransactionData = { to: destination, data: '0x', value: amount } // Create a Safe transaction with the provided parameters -const safeTransaction = await safeSdkOwner1.createTransaction({ safeTransactionData }) +const safeTransaction = await safeSdkOwner1.createTransaction({ transactions: [safeTransactionData] }) ``` ### Propose the transaction diff --git a/safe-core-sdk/protocol-kit/reference/README.md b/safe-core-sdk/protocol-kit/reference/README.md index ed4d131d..79dbe1ce 100644 --- a/safe-core-sdk/protocol-kit/reference/README.md +++ b/safe-core-sdk/protocol-kit/reference/README.md @@ -22,14 +22,14 @@ import { SafeFactory } from '@safe-global/protocol-kit' const safeFactory = await SafeFactory.create({ ethAdapter }) ``` -- The `isL1SafeMasterCopy` flag +- The `isL1SafeSingleton` flag There are two versions of the Safe contracts: [Safe.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/Safe.sol) that does not trigger events in order 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. - By default `Safe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `SafeL2.sol` contract will be used unless you add the `isL1SafeMasterCopy` flag to force the use of the `Safe.sol` contract. + By default `Safe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `SafeL2.sol` contract will be used unless you add the `isL1SafeSingleton` flag to force the use of the `Safe.sol` contract. ```typescript - const safeFactory = await SafeFactory.create({ ethAdapter, isL1SafeMasterCopy: true }) + const safeFactory = await SafeFactory.create({ ethAdapter, isL1SafeSingleton: true }) ``` - The `contractNetworks` property @@ -42,7 +42,7 @@ const safeFactory = await SafeFactory.create({ ethAdapter }) const chainId = await ethAdapter.getChainId() const contractNetworks: ContractNetworksConfig = { [chainId]: { - safeMasterCopyAddress: '', + safeSingletonAddress: '', safeProxyFactoryAddress: '', multiSendAddress: '', multiSendCallOnlyAddress: '', @@ -50,7 +50,7 @@ const safeFactory = await SafeFactory.create({ ethAdapter }) signMessageLibAddress: '', createCallAddress: '', simulateTxAccessorAddress: '', - safeMasterCopyAbi: '', // Optional. Only needed with web3.js + safeSingletonAbi: '', // Optional. Only needed with web3.js safeProxyFactoryAbi: '', // Optional. Only needed with web3.js multiSendAbi: '', // Optional. Only needed with web3.js multiSendCallOnlyAbi: '', // Optional. Only needed with web3.js @@ -75,7 +75,7 @@ const safeFactory = await SafeFactory.create({ ethAdapter }) ### `deploySafe` -Deploys a new Safe and returns an instance of the Protocol Kit connected to the deployed Safe. The address of the Master Copy, Safe contract version and the contract (`Safe.sol` or `SafeL2.sol`) of the deployed Safe will depend on the initialization of the `safeFactory` instance. +Deploys a new Safe and returns an instance of the Protocol Kit connected to the deployed Safe. The address of the singleton, Safe contract version and the contract (`Safe.sol` or `SafeL2.sol`) of the deployed Safe will depend on the initialization of the `safeFactory` instance. ```typescript const safeAccountConfig: SafeAccountConfig = { @@ -176,14 +176,14 @@ const predictedSafe: PredictedSafeProps = { const safeSdk = await Safe.create({ ethAdapter, predictedSafe }) ``` -- The `isL1SafeMasterCopy` flag +- The `isL1SafeSingleton` flag There are two versions of the Safe contracts: [Safe.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/Safe.sol) that does not trigger events in order 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. - By default `Safe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `SafeL2.sol` contract will be used unless you add the `isL1SafeMasterCopy` flag to force the use of the `Safe.sol` contract. + By default `Safe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `SafeL2.sol` contract will be used unless you add the `isL1SafeSingleton` flag to force the use of the `Safe.sol` contract. ```typescript - const safeSdk = await Safe.create({ ethAdapter, safeAddress, isL1SafeMasterCopy: true }) + const safeSdk = await Safe.create({ ethAdapter, safeAddress, isL1SafeSingleton: true }) ``` - The `contractNetworks` property @@ -196,7 +196,7 @@ const safeSdk = await Safe.create({ ethAdapter, predictedSafe }) const chainId = await ethAdapter.getChainId() const contractNetworks: ContractNetworksConfig = { [chainId]: { - safeMasterCopyAddress: '', + safeSingletonAddress: '', safeProxyFactoryAddress: '', multiSendAddress: '', multiSendCallOnlyAddress: '', @@ -204,7 +204,7 @@ const safeSdk = await Safe.create({ ethAdapter, predictedSafe }) signMessageLibAddress: '', createCallAddress: '', simulateTxAccessorAddress: '', - safeMasterCopyAbi: '', // Optional. Only needed with web3.js + safeSingletonAbi: '', // Optional. Only needed with web3.js safeProxyFactoryAbi: '', // Optional. Only needed with web3.js multiSendAbi: '', // Optional. Only needed with web3.js multiSendCallOnlyAbi: '', // Optional. Only needed with web3.js @@ -241,14 +241,14 @@ const predictedSafe: PredictedSafeProps = { const safeSdk = await safeSdk.connect({ ethAdapter, predictedSafe }) ``` -- The `isL1SafeMasterCopy` flag +- The `isL1SafeSingleton` flag There are two versions of the Safe contracts: [Safe.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/Safe.sol) that does not trigger events in order 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. - By default `Safe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `SafeL2.sol` contract will be used unless you add the `isL1SafeMasterCopy` flag to force the use of the `Safe.sol` contract. + By default `Safe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `SafeL2.sol` contract will be used unless you add the `isL1SafeSingleton` flag to force the use of the `Safe.sol` contract. ```typescript - const safeSdk = await Safe.connect({ ethAdapter, safeAddress, isL1SafeMasterCopy: true }) + const safeSdk = await Safe.connect({ ethAdapter, safeAddress, isL1SafeSingleton: true }) ``` - The `contractNetworks` property @@ -261,7 +261,7 @@ const safeSdk = await safeSdk.connect({ ethAdapter, predictedSafe }) const chainId = await ethAdapter.getChainId() const contractNetworks: ContractNetworksConfig = { [chainId]: { - safeMasterCopyAddress: '', + safeSingletonAddress: '', safeProxyFactoryAddress: '', multiSendAddress: '', multiSendCallOnlyAddress: '', @@ -269,7 +269,7 @@ const safeSdk = await safeSdk.connect({ ethAdapter, predictedSafe }) signMessageLibAddress: '', createCallAddress: '', simulateTxAccessorAddress: '', - safeMasterCopyAbi: '', // Optional. Only needed with web3.js + safeSingletonAbi: '', // Optional. Only needed with web3.js safeProxyFactoryAbi: '', // Optional. Only needed with web3.js multiSendAbi: '', // Optional. Only needed with web3.js multiSendCallOnlyAbi: '', // Optional. Only needed with web3.js @@ -292,7 +292,7 @@ const safeAddress = await safeSdk.getAddress() ### `getContractVersion` -Returns the Safe Master Copy contract version. +Returns the Safe singleton contract version. ```typescript const contractVersion = await safeSdk.getContractVersion() @@ -376,32 +376,12 @@ Returns a Safe transaction ready to be signed by the owners and executed. The Pr - **Single transactions** - This method can take an object of type `SafeTransactionDataPartial` that represents the transaction we want to execute (once the signatures are collected). It accepts some optional properties as follows. + This method takes an array of `MetaTransactionData` objects that represent the individual transactions we want to include in our MultiSend transaction. - ```typescript - import { SafeTransactionDataPartial } from '@safe-global/safe-core-sdk-types' - - const safeTransactionData: SafeTransactionDataPartial = { - to, - data, - value, - operation, // Optional - safeTxGas, // Optional - baseGas, // Optional - gasPrice, // Optional - gasToken, // Optional - refundReceiver, // Optional - nonce // Optional - } - const safeTransaction = await safeSdk.createTransaction({ safeTransactionData }) - ``` - -- **MultiSend transactions** - - This method can take an array of `MetaTransactionData` objects that represent the multiple transactions we want to include in our MultiSend transaction. If we want to specify some of the optional properties in our MultiSend transaction, we can pass a second argument to the `createTransaction` method with the `SafeTransactionOptionalProps` object. + When the array contains only one transaction, it is not wrapped in the MultiSend. ```typescript - const safeTransactionData: MetaTransactionData[] = [ + const transactions: MetaTransactionData[] = [ { to, data, @@ -416,13 +396,13 @@ Returns a Safe transaction ready to be signed by the owners and executed. The Pr } // ... ] - const safeTransaction = await safeSdk.createTransaction({ safeTransactionData }) + const safeTransaction = await safeSdk.createTransaction({ transactions }) ``` This method can also receive the `options` parameter to set the optional properties in the MultiSend transaction: ```typescript - const safeTransactionData: MetaTransactionData[] = [ + const transactions: MetaTransactionData[] = [ { to, data, @@ -445,7 +425,7 @@ Returns a Safe transaction ready to be signed by the owners and executed. The Pr refundReceiver, // Optional nonce // Optional } - const safeTransaction = await safeSdk.createTransaction({ safeTransactionData, options }) + const safeTransaction = await safeSdk.createTransaction({ transactions, options }) ``` In addition, the optional `callsOnly` parameter, which is `false` by default, allows to force the use of the `MultiSendCallOnly` instead of the `MultiSend` contract when sending a batch transaction: @@ -453,7 +433,7 @@ Returns a Safe transaction ready to be signed by the owners and executed. The Pr ```typescript const callsOnly = true const safeTransaction = await safeSdk.createTransaction({ - safeTransactionData, + transactions, options, callsOnly }) @@ -474,10 +454,10 @@ If the optional properties are not manually set, the Safe transaction returned w Returns a Safe transaction ready to be signed by the owners that invalidates the pending Safe transaction/s with a specific nonce. ```typescript -const safeTransactionData: SafeTransactionDataPartial = { +const transactions: MetaTransactionData[] = [{ // ... -} -const safeTransaction = await safeSdk.createTransaction({ safeTransactionData }) +}] +const safeTransaction = await safeSdk.createTransaction({ transactions }) const rejectionTransaction = await safeSdk.createRejectionTransaction(safeTransaction.data.nonce) ``` @@ -486,7 +466,7 @@ const rejectionTransaction = await safeSdk.createRejectionTransaction(safeTransa Copies a Safe transaction. ```typescript -const safeTransaction1 = await safeSdk.createTransaction({ safeTransactionData }) +const safeTransaction1 = await safeSdk.createTransaction({ transactions }) const safeTransaction2 = await copyTransaction(safeTransaction1) ``` @@ -495,10 +475,10 @@ const safeTransaction2 = await copyTransaction(safeTransaction1) Returns the transaction hash of a Safe transaction. ```typescript -const safeTransactionData: SafeTransactionDataPartial = { +const transactions: MetaTransactionData[] = [{ // ... -} -const safeTransaction = await safeSdk.createTransaction({ safeTransactionData }) +}] +const safeTransaction = await safeSdk.createTransaction({ transactions }) const txHash = await safeSdk.getTransactionHash(safeTransaction) ``` @@ -507,10 +487,10 @@ const txHash = await safeSdk.getTransactionHash(safeTransaction) Signs a hash using the current owner account. ```typescript -const safeTransactionData: SafeTransactionDataPartial = { +const transactions: MetaTransactionData[] = [{ // ... -} -const safeTransaction = await safeSdk.createTransaction({ safeTransactionData }) +}] +const safeTransaction = await safeSdk.createTransaction({ transactions }) const txHash = await safeSdk.getTransactionHash(safeTransaction) const signature = await safeSdk.signTransactionHash(txHash) ``` @@ -520,10 +500,10 @@ const signature = await safeSdk.signTransactionHash(txHash) Signs a transaction according to the EIP-712 using the current signer account. ```typescript -const safeTransactionData: SafeTransactionDataPartial = { +const transactions: MetaTransactionData[] = [{ // ... -} -const safeTransaction = await safeSdk.createTransaction({ safeTransactionData }) +}] +const safeTransaction = await safeSdk.createTransaction({ transactions }) const signature = await safeSdk.signTypedData(safeTransaction) ``` @@ -532,10 +512,10 @@ const signature = await safeSdk.signTypedData(safeTransaction) Returns a new `SafeTransaction` object that includes the signature of the current owner. `eth_sign` will be used by default to generate the signature. ```typescript -const safeTransactionData: SafeTransactionDataPartial = { +const transactions: MetaTransactionData[] = [{ // ... -} -const safeTransaction = await safeSdk.createTransaction({ safeTransactionData }) +}] +const safeTransaction = await safeSdk.createTransaction({ transactions }) const signedSafeTransaction = await safeSdk.signTransaction(safeTransaction) ``` @@ -554,10 +534,10 @@ const signedSafeTransaction = await safeSdk.signTransaction(safeTransaction, 'et Approves a hash on-chain using the current owner account. ```typescript -const safeTransactionData: SafeTransactionDataPartial = { +const transactions: MetaTransactionData[] = [{ // ... -} -const safeTransaction = await safeSdk.createTransaction({ safeTransactionData }) +}] +const safeTransaction = await safeSdk.createTransaction({ transactions }) const txHash = await safeSdk.getTransactionHash(safeTransaction) const txResponse = await safeSdk.approveTransactionHash(txHash) await txResponse.transactionResponse?.wait() @@ -596,10 +576,10 @@ const txResponse = await safeSdk.approveTransactionHash(txHash, options) Returns a list of owners who have approved a specific Safe transaction. ```typescript -const safeTransactionData: SafeTransactionDataPartial = { +const transactions: MetaTransactionData[] = [{ // ... -} -const safeTransaction = await safeSdk.createTransaction({ safeTransactionData }) +}] +const safeTransaction = await safeSdk.createTransaction({ transactions }) const txHash = await safeSdk.getTransactionHash(safeTransaction) const ownerAddresses = await safeSdk.getOwnersWhoApprovedTx(txHash) ``` @@ -805,10 +785,10 @@ const safeTransaction = await safeSdk.createChangeThresholdTx(newThreshold, opti Checks if a Safe transaction can be executed successfully with no errors. ```typescript -const safeTransactionData: SafeTransactionDataPartial = { +const transactions: MetaTransactionData[] = [{ // ... -} -const safeTransaction = await safeSdk.createTransaction({ safeTransactionData }) +}] +const safeTransaction = await safeSdk.createTransaction({ transactions }) const isValidTx = await safeSdk.isValidTransaction(safeTransaction) ``` @@ -845,10 +825,10 @@ const isValidTx = await safeSdk.isValidTransaction(safeTransaction, options) Executes a Safe transaction. ```typescript -const safeTransactionData: SafeTransactionDataPartial = { +const transactions: MetaTransactionData[] = [{ // ... -} -const safeTransaction = await safeSdk.createTransaction({ safeTransactionData }) +}] +const safeTransaction = await safeSdk.createTransaction({ transactions }) const txResponse = await safeSdk.executeTransaction(safeTransaction) await txResponse.transactionResponse?.wait() ``` From 17cbde5353a8898a1ba58fc0503758b849ef7cd0 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Thu, 23 Nov 2023 14:17:18 +0100 Subject: [PATCH 03/29] Fix linting and typos --- safe-core-sdk/api-kit/README.md | 8 ++++---- safe-core-sdk/protocol-kit/reference/README.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/safe-core-sdk/api-kit/README.md b/safe-core-sdk/api-kit/README.md index 0cfea830..ca7463eb 100644 --- a/safe-core-sdk/api-kit/README.md +++ b/safe-core-sdk/api-kit/README.md @@ -47,7 +47,7 @@ const ethAdapter = new EthersAdapter({ ## Initialize the API Kit -We need to create an instance of the API Kit. In those chains where Safe provides a transaction service is enough to specify the chainId. You can specify your own service using the optional `txServiceUrl` parameter. +We need to create an instance of the API Kit. In those chains where Safe provides a Transaction Service is enough to specify the `chainId`. You can set your own service using the optional `txServiceUrl` parameter. ```typescript import SafeApiKit from '@safe-global/api-kit' @@ -66,7 +66,7 @@ const safeApiKit = new SafeApiKit({ ## Propose a transaction to the service -Before a transaction can be executed, any of the Safe signers needs to initiate the process by creating a proposal of a transaction. We send this transaction to the service to make it accessible by the other owners so they can give their approbal and sign the transaction as well. +Before a transaction can be executed, any of the Safe signers needs to initiate the process by creating a proposal of a transaction. We send this transaction to the service to make it accessible by the other owners so they can give their approval and sign the transaction as well. ```typescript import Safe from '@safe-global/protocol-kit' @@ -116,7 +116,7 @@ const transaction = await service.getTransaction("") ## Confirm the transaction -In this step we need to sing the transaction with the Protocol Kit and submit the signature the the Safe Transaction Service using the `confirmTransaction` method. +In this step we need to sign the transaction with the Protocol Kit and submit the signature the the Safe Transaction Service using the `confirmTransaction` method. ```typescript const safeTxHash = transaction.transactionHash @@ -126,4 +126,4 @@ const signature = await safe.signTransactionHash(safeTxHash) const signatureResponse = await service.confirmTransaction(safeTxHash, signature.data) ``` -The Safe transaction is now ready to be executed. This can be done using the Safe{Wallet} web interface, the Protocol Kit or any other tool that is available. +The Safe transaction is now ready to be executed. This can be done using the Safe{Wallet} web interface, the Protocol Kit or any other tool that's available. diff --git a/safe-core-sdk/protocol-kit/reference/README.md b/safe-core-sdk/protocol-kit/reference/README.md index 79dbe1ce..85787dca 100644 --- a/safe-core-sdk/protocol-kit/reference/README.md +++ b/safe-core-sdk/protocol-kit/reference/README.md @@ -378,7 +378,7 @@ Returns a Safe transaction ready to be signed by the owners and executed. The Pr This method takes an array of `MetaTransactionData` objects that represent the individual transactions we want to include in our MultiSend transaction. - When the array contains only one transaction, it is not wrapped in the MultiSend. + When the array contains only one transaction, it's not wrapped in the MultiSend. ```typescript const transactions: MetaTransactionData[] = [ From 4657adf0329dd21c4e0cac3c2919d758efe12482 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Thu, 23 Nov 2023 14:23:55 +0100 Subject: [PATCH 04/29] fix: broken links --- safe-core-sdk/api-kit/README.md | 2 +- safe-core-sdk/auth-kit/guides/web3auth.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/safe-core-sdk/api-kit/README.md b/safe-core-sdk/api-kit/README.md index ca7463eb..4843b008 100644 --- a/safe-core-sdk/api-kit/README.md +++ b/safe-core-sdk/api-kit/README.md @@ -6,7 +6,7 @@ The [API Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/ap In this guide we will see how to propose transactions to the service and collect the signatures from the owners so they become executable. -For more detailed information, see the guide [Integrating the Protocol Kit and API Kit](https://github.com/safe-global/safe-core-sdk/blob/main/guides/integrating-the-safe-core-sdk.md) and the [API Kit Reference](../../reference/safe-core-sdk//api-kit/). +For more detailed information, see the guide [Integrating the Protocol Kit and API Kit](https://github.com/safe-global/safe-core-sdk/blob/main/guides/integrating-the-safe-core-sdk.md) and the [API Kit Reference](./reference/README.md). ### Prerequisites diff --git a/safe-core-sdk/auth-kit/guides/web3auth.md b/safe-core-sdk/auth-kit/guides/web3auth.md index 92d69d3c..b661ee1d 100644 --- a/safe-core-sdk/auth-kit/guides/web3auth.md +++ b/safe-core-sdk/auth-kit/guides/web3auth.md @@ -137,7 +137,7 @@ const web3AuthModalPack = new Web3AuthModalPack({ ## Signing transactions using the Web3AuthModalPack and Protocol Kit -The `Web3AuthModalPack` can be combined with the [Protocol Kit](../protocol-kit/) to connect to a Safe using the `provider` and `signer` of the currently authenticated account. +The `Web3AuthModalPack` can be combined with the [Protocol Kit](../../protocol-kit/) to connect to a Safe using the `provider` and `signer` of the currently authenticated account. Once connected, you can use any of the methods available in the [Protocol Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/protocol-kit#sdk-api). From 25b524c6f1a9b08a2b74867e54db1219837fb952 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Thu, 23 Nov 2023 15:50:29 +0100 Subject: [PATCH 05/29] update GelatoRelayKit breaking changes --- safe-core-sdk/relay-kit/guides/gelato.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/safe-core-sdk/relay-kit/guides/gelato.md b/safe-core-sdk/relay-kit/guides/gelato.md index 30a20b2c..d3f33145 100644 --- a/safe-core-sdk/relay-kit/guides/gelato.md +++ b/safe-core-sdk/relay-kit/guides/gelato.md @@ -91,30 +91,29 @@ const ethAdapter = new EthersAdapter({ signerOrProvider: signer }) -const safeSDK = await Safe.create({ +const protocolKit = await Safe.create({ ethAdapter, safeAddress }) -const relayKit = new GelatoRelayPack(process.env.GELATO_RELAY_API_KEY!) +const relayKit = new GelatoRelayPack({ apiKey: process.env.GELATO_RELAY_API_KEY!, protocolKit }) ``` ### Prepare the transaction ```typescript const safeTransaction = await relayKit.createRelayedTransaction({ - safe: safeSDK, transactions, options }) -const signedSafeTransaction = await safeSDK.signTransaction(safeTransaction) +const signedSafeTransaction = await protocolKit.signTransaction(safeTransaction) ``` ### Send the transaction to the relay ```typescript -const response = await relayKit.executeRelayTransaction(signedSafeTransaction, safeSDK, options) +const response = await relayKit.executeRelayTransaction(signedSafeTransaction, options) console.log(`Relay Transaction Task ID: https://relay.gelato.digital/tasks/status/${response.taskId}`) ``` @@ -171,26 +170,26 @@ const ethAdapter = new EthersAdapter({ signerOrProvider: signer }) -const safeSDK = await Safe.create({ +const protocolKit = await Safe.create({ ethAdapter, safeAddress }) -const relayKit = new GelatoRelayPack() +const relayKit = new GelatoRelayPack({ protocolKit }) ``` ### Prepare the transaction ```typescript -const safeTransaction = await relayKit.createRelayedTransaction({ safe: safeSDK, transactions }) +const safeTransaction = await relayKit.createRelayedTransaction({ transactions }) -const signedSafeTransaction = await safeSDK.signTransaction(safeTransaction) +const signedSafeTransaction = await protocolKit.signTransaction(safeTransaction) ``` ### Send the transaction to the relay ```typescript -const response = await relayKit.executeRelayTransaction(signedSafeTransaction, safeSDK) +const response = await relayKit.executeRelayTransaction(signedSafeTransaction) console.log(`Relay Transaction Task ID: https://relay.gelato.digital/tasks/status/${response.taskId}`) ``` From a56bc1abbba3b6bb6460cd6da8bbb1fbe1a4571d Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Thu, 23 Nov 2023 16:19:29 +0100 Subject: [PATCH 06/29] improve parameter naming --- safe-core-sdk/api-kit/README.md | 16 +-- safe-core-sdk/api-kit/reference/README.md | 48 ++++---- .../auth-kit/reference/AuthKitBasePack.md | 13 +- .../protocol-kit/reference/README.md | 114 +++++++++--------- 4 files changed, 95 insertions(+), 96 deletions(-) diff --git a/safe-core-sdk/api-kit/README.md b/safe-core-sdk/api-kit/README.md index 4843b008..11252cbd 100644 --- a/safe-core-sdk/api-kit/README.md +++ b/safe-core-sdk/api-kit/README.md @@ -72,7 +72,7 @@ Before a transaction can be executed, any of the Safe signers needs to initiate import Safe from '@safe-global/protocol-kit' // Create Safe instance -const safe = await Safe.create({ +const protocolKit = await Safe.create({ ethAdapter, safeAddress: config.SAFE_ADDRESS }) @@ -85,15 +85,15 @@ const safeTransactionData: MetaTransactionData = { operation: OperationType.Call } -const safeTransaction = await safe.createTransaction({ transactions: [safeTransactionData] }) +const safeTransaction = await protocolKit.createTransaction({ transactions: [safeTransactionData] }) const senderAddress = await signer.getAddress() -const safeTxHash = await safe.getTransactionHash(safeTransaction) -const signature = await safe.signTransactionHash(safeTxHash) +const safeTxHash = await protocolKit.getTransactionHash(safeTransaction) +const signature = await protocolKit.signTransactionHash(safeTxHash) // Propose transaction to the service await safeApiKit.proposeTransaction({ - safeAddress: await safe.getAddress(), + safeAddress: await protocolKit.getAddress(), safeTransactionData: safeTransaction.data, safeTxHash, senderAddress, @@ -116,14 +116,14 @@ const transaction = await service.getTransaction("") ## Confirm the transaction -In this step we need to sign the transaction with the Protocol Kit and submit the signature the the Safe Transaction Service using the `confirmTransaction` method. +In this step we need to sign the transaction with the Protocol Kit and submit the signature to the Safe Transaction Service using the `confirmTransaction` method. ```typescript const safeTxHash = transaction.transactionHash -const signature = await safe.signTransactionHash(safeTxHash) +const signature = await protocolKit.signTransactionHash(safeTxHash) // Confirm the Safe transaction -const signatureResponse = await service.confirmTransaction(safeTxHash, signature.data) +const signatureResponse = await safeApiKit.confirmTransaction(safeTxHash, signature.data) ``` The Safe transaction is now ready to be executed. This can be done using the Safe{Wallet} web interface, the Protocol Kit or any other tool that's available. diff --git a/safe-core-sdk/api-kit/reference/README.md b/safe-core-sdk/api-kit/reference/README.md index 7f305481..41b3cefe 100644 --- a/safe-core-sdk/api-kit/reference/README.md +++ b/safe-core-sdk/api-kit/reference/README.md @@ -17,7 +17,7 @@ yarn add @safe-global/api-kit Returns the information and configuration of the service. ```typescript -const serviceInfo: SafeServiceInfoResponse = await safeService.getServiceInfo() +const serviceInfo: SafeServiceInfoResponse = await safeApiKit.getServiceInfo() ``` ### `getServiceSingletonsInfo` @@ -25,7 +25,7 @@ const serviceInfo: SafeServiceInfoResponse = await safeService.getServiceInfo() Returns the list of Safe singletons. ```typescript -const singletons: SafeSingletonResponse = await safeService.getServiceSingletonsInfo() +const singletons: SafeSingletonResponse = await safeApiKit.getServiceSingletonsInfo() ``` ### `decodeData` @@ -33,7 +33,7 @@ const singletons: SafeSingletonResponse = await safeService.getServiceSingletons Decodes the specified Safe transaction data. ```typescript -const decodedData = await safeService.decodeData(data) +const decodedData = await safeApiKit.decodeData(data) ``` ### `getSafesByOwner` @@ -41,7 +41,7 @@ const decodedData = await safeService.decodeData(data) Returns the list of Safes where the address provided is an owner. ```typescript -const safes: OwnerResponse = await safeService.getSafesByOwner(ownerAddress) +const safes: OwnerResponse = await safeApiKit.getSafesByOwner(ownerAddress) ``` ### `getSafesByModule` @@ -57,7 +57,7 @@ const safes: ModulesResponse = await getSafesByModule(moduleAddress) Returns all the information of a Safe transaction. ```typescript -const tx: SafeMultisigTransactionResponse = await safeService.getTransaction(safeTxHash) +const tx: SafeMultisigTransactionResponse = await safeApiKit.getTransaction(safeTxHash) ``` ### `getTransactionConfirmations` @@ -66,7 +66,7 @@ Returns the list of confirmations for a given a Safe transaction. ```typescript const confirmations: SafeMultisigConfirmationListResponse = - await safeService.getTransactionConfirmations(safeTxHash) + await safeApiKit.getTransactionConfirmations(safeTxHash) ``` ### `confirmTransaction` @@ -74,7 +74,7 @@ const confirmations: SafeMultisigConfirmationListResponse = Adds a confirmation for a Safe transaction. ```typescript -const signature: SignatureResponse = await safeService.confirmTransaction(safeTxHash, signature) +const signature: SignatureResponse = await safeApiKit.confirmTransaction(safeTxHash, signature) ``` ### `getSafeInfo` @@ -82,7 +82,7 @@ const signature: SignatureResponse = await safeService.confirmTransaction(safeTx Returns the information and configuration of the provided Safe address. ```typescript -const safeInfo: SafeInfoResponse = await safeService.getSafeInfo(safeAddress) +const safeInfo: SafeInfoResponse = await safeApiKit.getSafeInfo(safeAddress) ``` ### `getSafeDelegates` @@ -98,7 +98,7 @@ const delegateConfig: GetSafeDelegateProps = { limit, // Optional offset // Optional } -const delegates: SafeDelegateListResponse = await safeService.getSafeDelegates(delegateConfig) +const delegates: SafeDelegateListResponse = await safeApiKit.getSafeDelegates(delegateConfig) ``` ### `addSafeDelegate` @@ -113,7 +113,7 @@ const delegateConfig: AddSafeDelegateProps = { label, signer } -await safeService.addSafeDelegate(delegateConfig) +await safeApiKit.addSafeDelegate(delegateConfig) ``` ### `removeSafeDelegate` @@ -126,7 +126,7 @@ const delegateConfig: DeleteSafeDelegateProps = { delegatorAddress, signer } -await safeService.removeSafeDelegate(delegateConfig) +await safeApiKit.removeSafeDelegate(delegateConfig) ``` ### `getSafeCreationInfo` @@ -134,7 +134,7 @@ await safeService.removeSafeDelegate(delegateConfig) Returns the creation information of a Safe. ```typescript -const safeCreationInfo: SafeCreationInfoResponse = await safeService.getSafeCreationInfo( +const safeCreationInfo: SafeCreationInfoResponse = await safeApiKit.getSafeCreationInfo( safeAddress ) ``` @@ -145,7 +145,7 @@ Estimates the safeTxGas for a given Safe multi-signature transaction. ```typescript const estimateTx: SafeMultisigTransactionEstimateResponse = - await safeService.estimateSafeTransaction(safeAddress, safeTransaction) + await safeApiKit.estimateSafeTransaction(safeAddress, safeTransaction) ``` ### `proposeTransaction` @@ -161,7 +161,7 @@ const transactionConfig: ProposeTransactionProps = { senderSignature, origin } -await safeService.proposeTransaction(transactionConfig) +await safeApiKit.proposeTransaction(transactionConfig) ``` ### `getIncomingTransactions` @@ -169,7 +169,7 @@ await safeService.proposeTransaction(transactionConfig) Returns the history of incoming transactions of a Safe account. ```typescript -const incomingTxs: TransferListResponse = await safeService.getIncomingTransactions(safeAddress) +const incomingTxs: TransferListResponse = await safeApiKit.getIncomingTransactions(safeAddress) ``` ### `getModuleTransactions` @@ -177,7 +177,7 @@ const incomingTxs: TransferListResponse = await safeService.getIncomingTransacti Returns the history of module transactions of a Safe account. ```typescript -const moduleTxs: SafeModuleTransactionListResponse = await safeService.getModuleTransactions( +const moduleTxs: SafeModuleTransactionListResponse = await safeApiKit.getModuleTransactions( safeAddress ) ``` @@ -187,7 +187,7 @@ const moduleTxs: SafeModuleTransactionListResponse = await safeService.getModule Returns the history of multi-signature transactions of a Safe account. ```typescript -const multisigTxs: SafeMultisigTransactionListResponse = await safeService.getMultisigTransactions( +const multisigTxs: SafeMultisigTransactionListResponse = await safeApiKit.getMultisigTransactions( safeAddress ) ``` @@ -197,13 +197,13 @@ const multisigTxs: SafeMultisigTransactionListResponse = await safeService.getMu Returns the list of multi-signature transactions that are waiting for the confirmation of the Safe owners. ```typescript -const pendingTxs: SafeMultisigTransactionListResponse = await safeService.getPendingTransactions( +const pendingTxs: SafeMultisigTransactionListResponse = await safeApiKit.getPendingTransactions( safeAddress ) ``` ```typescript -const pendingTxs: SafeMultisigTransactionListResponse = await safeService.getPendingTransactions( +const pendingTxs: SafeMultisigTransactionListResponse = await safeApiKit.getPendingTransactions( safeAddress, currentNonce ) @@ -214,7 +214,7 @@ const pendingTxs: SafeMultisigTransactionListResponse = await safeService.getPen Returns a list of transactions for a Safe. The list has different structures depending on the transaction type. ```typescript -const allTxs: SafeMultisigTransactionListResponse = await safeService.getAllTransactions( +const allTxs: SafeMultisigTransactionListResponse = await safeApiKit.getAllTransactions( safeAddress ) ``` @@ -225,7 +225,7 @@ const allTxsOptions: AllTransactionsOptions = { queued, trusted } -const allTxs: SafeMultisigTransactionListResponse = await safeService.getAllTransactions( +const allTxs: SafeMultisigTransactionListResponse = await safeApiKit.getAllTransactions( safeAddress, allTxsOptions ) @@ -236,7 +236,7 @@ const allTxs: SafeMultisigTransactionListResponse = await safeService.getAllTran Returns the right nonce to propose a new transaction right after the last pending transaction. ```typescript -const nextNonce = await safeService.getNextNonce(safeAddress) +const nextNonce = await safeApiKit.getNextNonce(safeAddress) ``` ### `getTokenList` @@ -244,7 +244,7 @@ const nextNonce = await safeService.getNextNonce(safeAddress) Returns the list of all the ERC20 tokens handled by the Safe. ```typescript -const tokens: TokenInfoListResponse = await safeService.getTokenList() +const tokens: TokenInfoListResponse = await safeApiKit.getTokenList() ``` ### `getToken` @@ -252,5 +252,5 @@ const tokens: TokenInfoListResponse = await safeService.getTokenList() Returns the information of a given ERC20 token. ```typescript -const token: TokenInfoResponse = await safeService.getToken(tokenAddress) +const token: TokenInfoResponse = await safeApiKit.getToken(tokenAddress) ``` diff --git a/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md b/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md index 154dd0da..3dea60db 100644 --- a/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md +++ b/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md @@ -24,19 +24,19 @@ class MyPack extends AuthKitBasePack { These methods are the common interface for all the Auth packs. Check each pack's documentation to get more details. -### `init(options?)` +### `init(options?): Promise` Provides the initialization options for the required packages, classes and properties. -### `signIn(): authKitSignInData` +### `signIn(): Promise` Provides a mechanism to connect to the provider services and returns an Ethereum address that will be used as a signer along with the associated Safe addresses. -### `signOut()` +### `signOut(): Promise` Disconnects the provider services and cleans up any data related to the current user. -### `getProvider(): BrowserProvider` +### `getProvider(): Eip1193Provider | null` Returns a Web3 provider that can be used to interact with the blockchain (`web3.js` or `ethers.js` for example). @@ -63,12 +63,13 @@ Returns the Ethereum address extracted from the provider retrieved by `getProvid **Returns** - `address`: The Ethereum address extracted from the provider. -### `getSafes(txServiceUrl): safes[]` +### `getSafes(chainId, txServiceUrl?): safes[]` Returns the list of Safes associated with the signer address by calling the `getAddress()` method internally. **Params** -- `txServiceUrl`: The Safe Transaction Service url to retrieve the Safes associated with the owner (signer). +- `chainId`: Indicate the chain ID. +- `txServiceUrl`(optional): The Safe Transaction Service url to retrieve the Safes associated with the owner (signer). **Returns** - `safes[]`: The list of Safes associated with the owner (signer). diff --git a/safe-core-sdk/protocol-kit/reference/README.md b/safe-core-sdk/protocol-kit/reference/README.md index 85787dca..173323ac 100644 --- a/safe-core-sdk/protocol-kit/reference/README.md +++ b/safe-core-sdk/protocol-kit/reference/README.md @@ -324,7 +324,7 @@ const threshold = await safeSdk.getThreshold() ### `getChainId` -Returns the chainId of the connected network. +Returns the chain ID of the connected network. ```typescript const chainId = await safeSdk.getChainId() @@ -374,70 +374,68 @@ const isOwner = await safeSdk.isOwner(address) Returns a Safe transaction ready to be signed by the owners and executed. The Protocol Kit supports the creation of single Safe transactions but also MultiSend transactions. -- **Single transactions** +This method takes an array of `MetaTransactionData` objects that represent the individual transactions we want to include in our MultiSend transaction. - This method takes an array of `MetaTransactionData` objects that represent the individual transactions we want to include in our MultiSend transaction. +When the array contains only one transaction, it's not wrapped in the MultiSend. - When the array contains only one transaction, it's not wrapped in the MultiSend. - - ```typescript - const transactions: MetaTransactionData[] = [ - { - to, - data, - value, - operation // Optional - }, - { - to, - data, - value, - operation // Optional - } - // ... - ] - const safeTransaction = await safeSdk.createTransaction({ transactions }) - ``` +```typescript +const transactions: MetaTransactionData[] = [ + { + to, + data, + value, + operation // Optional + }, + { + to, + data, + value, + operation // Optional + } + // ... +] +const safeTransaction = await safeSdk.createTransaction({ transactions }) +``` - This method can also receive the `options` parameter to set the optional properties in the MultiSend transaction: +This method can also receive the `options` parameter to set the optional properties in the MultiSend transaction: - ```typescript - const transactions: MetaTransactionData[] = [ - { - to, - data, - value, - operation // Optional - }, - { - to, - data, - value, - operation // Optional - } - // ... - ] - const options: SafeTransactionOptionalProps = { - safeTxGas, // Optional - baseGas, // Optional - gasPrice, // Optional - gasToken, // Optional - refundReceiver, // Optional - nonce // Optional +```typescript +const transactions: MetaTransactionData[] = [ + { + to, + data, + value, + operation // Optional + }, + { + to, + data, + value, + operation // Optional } - const safeTransaction = await safeSdk.createTransaction({ transactions, options }) - ``` + // ... +] +const options: SafeTransactionOptionalProps = { + safeTxGas, // Optional + baseGas, // Optional + gasPrice, // Optional + gasToken, // Optional + refundReceiver, // Optional + nonce // Optional +} +const safeTransaction = await safeSdk.createTransaction({ transactions, options }) +``` - In addition, the optional `callsOnly` parameter, which is `false` by default, allows to force the use of the `MultiSendCallOnly` instead of the `MultiSend` contract when sending a batch transaction: +In addition, the optional `callsOnly` parameter, which is `false` by default, allows to force the use of the `MultiSendCallOnly` instead of the `MultiSend` contract when sending a batch transaction: - ```typescript - const callsOnly = true - const safeTransaction = await safeSdk.createTransaction({ - transactions, - options, - callsOnly - }) - ``` +```typescript +const callsOnly = true +const safeTransaction = await safeSdk.createTransaction({ + transactions, + options, + callsOnly +}) +``` If the optional properties are not manually set, the Safe transaction returned will have the default value for each one: From 43e8a613ee18e69e2e8e252ab73ebb82fadea9dd Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Thu, 23 Nov 2023 16:23:07 +0100 Subject: [PATCH 07/29] fix linter reported issue --- safe-core-sdk/auth-kit/reference/AuthKitBasePack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md b/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md index 3dea60db..54b07d83 100644 --- a/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md +++ b/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md @@ -69,7 +69,7 @@ Returns the list of Safes associated with the signer address by calling the `ge **Params** - `chainId`: Indicate the chain ID. -- `txServiceUrl`(optional): The Safe Transaction Service url to retrieve the Safes associated with the owner (signer). +- `txServiceUrl`(optional): The Safe Transaction Service URL to retrieve the Safes associated with the owner (signer). **Returns** - `safes[]`: The list of Safes associated with the owner (signer). From 07514e54398f7deacc2790cf55a4f293ad176684 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Thu, 23 Nov 2023 16:32:02 +0100 Subject: [PATCH 08/29] fix wording recommendations --- safe-core-sdk/onramp-kit/reference/MoneriumPack.md | 2 +- safe-core-sdk/onramp-kit/reference/README.md | 8 ++++---- safe-core-sdk/protocol-kit/README.md | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/safe-core-sdk/onramp-kit/reference/MoneriumPack.md b/safe-core-sdk/onramp-kit/reference/MoneriumPack.md index bd01aa58..7c5e1943 100644 --- a/safe-core-sdk/onramp-kit/reference/MoneriumPack.md +++ b/safe-core-sdk/onramp-kit/reference/MoneriumPack.md @@ -4,7 +4,7 @@ Monerium Pack enables using Safe with [Monerium](https://monerium.com), a regula ## Install dependencies -To use the `MoneriumPack`, you need to install the monerium SDK in addition to the `@safe-global/onramp-kit` package. +To use the `MoneriumPack`, you need to install the Monerium SDK in addition to the `@safe-global/onramp-kit` package. ```bash yarn add @safe-global/onramp-kit @monerium/sdk diff --git a/safe-core-sdk/onramp-kit/reference/README.md b/safe-core-sdk/onramp-kit/reference/README.md index acf05bd1..fb4a81ff 100644 --- a/safe-core-sdk/onramp-kit/reference/README.md +++ b/safe-core-sdk/onramp-kit/reference/README.md @@ -1,17 +1,17 @@ -# OnRamp Kit +# Onramp Kit -The [OnRamp Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/onramp-kit) allow users to access on-ramp services and use them with their Safes. +The [Onramp Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/onramp-kit) allow users to access on-ramp services and use them with their Safes. These services can be used to buy crypto assets with credit cards or make SEPA transfers between their Safe and bank accounts (Monerium). ## Install dependencies -To add the OnRamp Kit to your project, run: +To add the Onramp Kit to your project, run: ```bash yarn add @safe-global/onramp-kit ``` -The OnRamp Kit can integrate several providers in the form of "packs". A pack is a piece of code that works with the chosen provider to give Safe users access to new services. +The Onramp Kit can integrate several providers in the form of "packs". A pack is a piece of code that works with the chosen provider to give Safe users access to new services. To use each pack, the right package needs to be installed: diff --git a/safe-core-sdk/protocol-kit/README.md b/safe-core-sdk/protocol-kit/README.md index b0e88619..596bd20a 100644 --- a/safe-core-sdk/protocol-kit/README.md +++ b/safe-core-sdk/protocol-kit/README.md @@ -11,11 +11,11 @@ For a more detailed guide, including how to integrate with `web3.js`` and more S ### Prerequisites 1. [Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) -2. 3 externally-owned accounts with testnet ETH in at least one account +2. 3 externally-owned accounts with Testnet ETH in at least one account ### Install dependencies -First, we'll need to install some dependences from `safe-core-sdk` and the `ethers` library. +First, we'll need to install some dependencies from `safe-core-sdk` and the `ethers` library. To interact with Ethereum and other EVM blockchains in Node, we can either use: web3.js or ethers.js. In this tutorial, we'll use the ethers.js library. To use `web3js`, see [Instantiate an EthAdapter section in Guide: Integrating the Safe Core SDK](https://github.com/safe-global/safe-core-sdk/blob/main/guides/integrating-the-safe-core-sdk.md#instantiate-an-ethadapter). @@ -62,7 +62,7 @@ The signers trigger transactions to the Ethereum blockchain or off-chain transac You can get a public RPC URL from [Chainlist](https://chainlist.org), however, public RPC URLs can be unreliable so you can also try a dedicated provider like Infura or Alchemy. -For this tutorial, we will be creating a Safe on the Goerli testnet. +For this tutorial, we will be creating a Safe on the Goerli Testnet. ```tsx import { ethers } from 'ethers' @@ -240,7 +240,7 @@ Recall that you created the `safeService` in [Initialize the API Kit](./#initial const pendingTransactions = await safeService.getPendingTransactions(safeAddress).results ``` -### Confirm the transaction: second confirmation +### Confirm the transaction: Second confirmation When owner 2 is connected to the application, the Protocol Kit should be initialized again with the existing Safe address the address of the owner 2 instead of the owner 1. From 0886e8049b18b9aa59807408b698f1c411853c06 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Thu, 23 Nov 2023 16:39:38 +0100 Subject: [PATCH 09/29] highlight ethers.js v6 --- safe-core-sdk/onramp-kit/reference/MoneriumPack.md | 2 +- safe-core-sdk/protocol-kit/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/safe-core-sdk/onramp-kit/reference/MoneriumPack.md b/safe-core-sdk/onramp-kit/reference/MoneriumPack.md index 7c5e1943..a0240068 100644 --- a/safe-core-sdk/onramp-kit/reference/MoneriumPack.md +++ b/safe-core-sdk/onramp-kit/reference/MoneriumPack.md @@ -51,7 +51,7 @@ You should always call the `init()` method afterwards before interacting with th ### `init(moneriumInitOptions)` -The `init` method initializes the Monerium SDK and the Safe services by creating a new instance of the [`SafeMoneriumClient`](https://github.com/safe-global/safe-core-sdk/blob/main/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.ts) class. This class extends the [`MoneriumClient`](https://github.com/monerium/sdk/blob/main/src/client.ts) class from the Monerium SDK and adds extra features to use it with the Safe services. +The `init` method initializes the Monerium SDK and the Safe services by creating a new instance of the [`SafeMoneriumClient`](https://github.com/safe-global/safe-core-sdk/blob/main/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.ts) class. This class extends the [`MoneriumClient`](https://github.com/monerium/js-sdk/blob/main/libs/sdk/src/client.ts) class from the Monerium SDK and adds extra features to use it with the Safe services. **Params** diff --git a/safe-core-sdk/protocol-kit/README.md b/safe-core-sdk/protocol-kit/README.md index 596bd20a..696e8d05 100644 --- a/safe-core-sdk/protocol-kit/README.md +++ b/safe-core-sdk/protocol-kit/README.md @@ -19,7 +19,7 @@ First, we'll need to install some dependencies from `safe-core-sdk` and the `eth To interact with Ethereum and other EVM blockchains in Node, we can either use: web3.js or ethers.js. In this tutorial, we'll use the ethers.js library. To use `web3js`, see [Instantiate an EthAdapter section in Guide: Integrating the Safe Core SDK](https://github.com/safe-global/safe-core-sdk/blob/main/guides/integrating-the-safe-core-sdk.md#instantiate-an-ethadapter). -The Protocol Kit is compatible only with ethers v6. Make sure you specify this version when installing the SDK. +The Protocol Kit is compatible only with **ethers.js v6**. Make sure you specify this version when installing the SDK. You can store your environment variables such as private keys in a `.env` file. To read easily from `.env` files, use the `dotenv` library. From e5dc4639dc6e743414efaec90c393d29911fdad6 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Thu, 23 Nov 2023 17:34:16 +0100 Subject: [PATCH 10/29] add migration guides highlighting the major changes --- safe-core-sdk/api-kit/migrating/v2.md | 26 ++++++++++++ safe-core-sdk/protocol-kit/migrating/v2.md | 48 ++++++++++++++++++++++ safe-core-sdk/relay-kit/migrating/v2.md | 15 +++++++ 3 files changed, 89 insertions(+) create mode 100644 safe-core-sdk/api-kit/migrating/v2.md create mode 100644 safe-core-sdk/protocol-kit/migrating/v2.md create mode 100644 safe-core-sdk/relay-kit/migrating/v2.md diff --git a/safe-core-sdk/api-kit/migrating/v2.md b/safe-core-sdk/api-kit/migrating/v2.md new file mode 100644 index 00000000..ca32cecd --- /dev/null +++ b/safe-core-sdk/api-kit/migrating/v2.md @@ -0,0 +1,26 @@ +# API Kit: Migrating from v1 + +This guide aims to be a reference of the major changes between v1 and v2 to help those migrating an existing app. + +## API Kit constructor + +Now it won't be necessary to specify a `txServiceUrl` in those environments where Safe has a Transaction Service running, specifiying the chain ID will be enough. If you want to use your custom service or use the kit in a chain not supported by a Safe Transaction Service, you can add `txServiceUrl` parameter. + +```js +// old: +constructor({ txServiceUrl, ethAdapter }: SafeApiKitConfig) + +// new: +constructor({ chainId, txServiceUrl? }: SafeApiKitConfig) +``` + +## Use the route you prefer + +API Kit v1 forced the use of a custom service hosted under `/api` route of the URL specified in `txServiceUrl`. This is not the case anymore, you can specify any route you prefer or subdomain. + +## MasterCopy to Singleton + +To avoid confusion between terms that have been used as synonyms we aligned all our code to use the word `singleton`. + +- Rename type `MasterCopyResponse` to `SafeSingletonResponse` +- Rename method `getServiceMasterCopiesInfo()` to `getServiceSingletonsInfo()` \ No newline at end of file diff --git a/safe-core-sdk/protocol-kit/migrating/v2.md b/safe-core-sdk/protocol-kit/migrating/v2.md new file mode 100644 index 00000000..25d53192 --- /dev/null +++ b/safe-core-sdk/protocol-kit/migrating/v2.md @@ -0,0 +1,48 @@ +# Protocol Kit: Migrating from v1 + +This guide aims to be a reference of the major changes between v1 and v2 to help those migrating an existing app. + +## MasterCopy to Singleton + +To avoid confusion between terms that have been used as synonyms we aligned all our code to use the word `singleton`. + +- Rename `isL1SafeMasterCopy` to `isL1SafeSingleton` +```js +// old: +SafeFactory.create({ ethAdapter, isL1SafeMasterCopy: true }) + +// new: +SafeFactory.create({ ethAdapter, isL1SafeSingleton: true }) +``` + +## Ethers v6 + +From protocolKit v2, EthersAdapter will only be compatible with ethers.js v6. If you still need to use v5 we recommend you to keep protocolKit v1, but encourage you to migrate to the latest version when you have the chance. + +## Protocol Kit createTransaction() accepts only transaction array + +In protocolKit v1 the `createTranasction()` method accepted either an object or an array as parameter. To avoid confusion we aligned to accept an array only. Migration can be done as the code below: + +```js +// old: +const safeTransactionData = { + to: '', + data: '', + value: '', + nonce: '', + safeTxGas: '' +} +const safeTransaction = protocolKit.createTransaction({ safeTransactionData }) + +// new: +const safeTransactionData = { + to: '', + data: '', + value: '' +} +const options = { + nonce: '', + safeTxGas: '' +} +const safeTransaction = protocolKit.createTransaction({ [safeTransactionData], options }) +``` \ No newline at end of file diff --git a/safe-core-sdk/relay-kit/migrating/v2.md b/safe-core-sdk/relay-kit/migrating/v2.md new file mode 100644 index 00000000..ee707f54 --- /dev/null +++ b/safe-core-sdk/relay-kit/migrating/v2.md @@ -0,0 +1,15 @@ +# Relay Kit: Migrating from v1 + +This guide aims to be a reference of the major changes between v1 and v2 to help those migrating an existing app. + +## GelatoRelayPack + +- The `GelatoRelayPack` constructor now includes a mandatory `protocolKit` parameter as we made it required for any new pack extending the `RelayKitBasePack` + +```js +constructor({ apiKey, protocolKit }: GelatoOptions) +``` + +- We removed the `protocolKit` parameter from `createTransactionWithHandlePayment()`, `createTransactionWithTransfer()` and `executeRelayTransaction()` methods in the `GelatoRelayPack` as we now it's included in the constructor. + +- Removed the type `export interface RelayPack` as we use now an abstract class. \ No newline at end of file From de1f6871b8364c47201fcd80de2d78765bba454b Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Thu, 23 Nov 2023 17:47:22 +0100 Subject: [PATCH 11/29] fix typos --- safe-core-sdk/api-kit/migrating/v2.md | 16 ++++++++++++++-- safe-core-sdk/protocol-kit/migrating/v2.md | 4 ++-- safe-core-sdk/relay-kit/migrating/v2.md | 4 ++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/safe-core-sdk/api-kit/migrating/v2.md b/safe-core-sdk/api-kit/migrating/v2.md index ca32cecd..e6c61cb1 100644 --- a/safe-core-sdk/api-kit/migrating/v2.md +++ b/safe-core-sdk/api-kit/migrating/v2.md @@ -4,7 +4,7 @@ This guide aims to be a reference of the major changes between v1 and v2 to help ## API Kit constructor -Now it won't be necessary to specify a `txServiceUrl` in those environments where Safe has a Transaction Service running, specifiying the chain ID will be enough. If you want to use your custom service or use the kit in a chain not supported by a Safe Transaction Service, you can add `txServiceUrl` parameter. +Now it won't be necessary to specify a `txServiceUrl` in those environments where Safe has a Transaction Service running, providing the chain ID will be enough. If you want to use your custom service or use the kit in a chain not supported by a Safe Transaction Service, you can add `txServiceUrl` parameter. ```js // old: @@ -16,7 +16,19 @@ constructor({ chainId, txServiceUrl? }: SafeApiKitConfig) ## Use the route you prefer -API Kit v1 forced the use of a custom service hosted under `/api` route of the URL specified in `txServiceUrl`. This is not the case anymore, you can specify any route you prefer or subdomain. +API Kit v1 forced that any custom service was hosted under `/api` route of the URL specified in `txServiceUrl`. This isn't the case anymore, you can specify any route you prefer or subdomain. + +Note that if you use a custom service running under `/api` you will now need to migrate as follow: + +```js +// old: +const txServiceUrl = 'https://your-transaction-service-domain/' +constructor({ txServiceUrl, ethAdapter }: SafeApiKitConfig) + +// new: +const txServiceUrl = 'https://your-transaction-service-domain/api' +constructor({ chainId, txServiceUrl? }: SafeApiKitConfig) +``` ## MasterCopy to Singleton diff --git a/safe-core-sdk/protocol-kit/migrating/v2.md b/safe-core-sdk/protocol-kit/migrating/v2.md index 25d53192..f34ba7c1 100644 --- a/safe-core-sdk/protocol-kit/migrating/v2.md +++ b/safe-core-sdk/protocol-kit/migrating/v2.md @@ -17,11 +17,11 @@ SafeFactory.create({ ethAdapter, isL1SafeSingleton: true }) ## Ethers v6 -From protocolKit v2, EthersAdapter will only be compatible with ethers.js v6. If you still need to use v5 we recommend you to keep protocolKit v1, but encourage you to migrate to the latest version when you have the chance. +From `protocolKit v2`, EthersAdapter will only be compatible with ethers.js v6. If you still need to use v5 we recommend you to keep `protocolKit v1`, but we encourage you to migrate to the latest version when you have the chance. ## Protocol Kit createTransaction() accepts only transaction array -In protocolKit v1 the `createTranasction()` method accepted either an object or an array as parameter. To avoid confusion we aligned to accept an array only. Migration can be done as the code below: +In `protocolKit v1` the `createTranasction()` method accepted either an object or an array as parameter. To avoid confusion we aligned to accept only an array. Here is a migration example: ```js // old: diff --git a/safe-core-sdk/relay-kit/migrating/v2.md b/safe-core-sdk/relay-kit/migrating/v2.md index ee707f54..677d8c97 100644 --- a/safe-core-sdk/relay-kit/migrating/v2.md +++ b/safe-core-sdk/relay-kit/migrating/v2.md @@ -4,12 +4,12 @@ This guide aims to be a reference of the major changes between v1 and v2 to help ## GelatoRelayPack -- The `GelatoRelayPack` constructor now includes a mandatory `protocolKit` parameter as we made it required for any new pack extending the `RelayKitBasePack` +- The `GelatoRelayPack` constructor now includes a mandatory `protocolKit` parameter. It's required for any new pack extending the `RelayKitBasePack`. ```js constructor({ apiKey, protocolKit }: GelatoOptions) ``` -- We removed the `protocolKit` parameter from `createTransactionWithHandlePayment()`, `createTransactionWithTransfer()` and `executeRelayTransaction()` methods in the `GelatoRelayPack` as we now it's included in the constructor. +- We removed the `protocolKit` parameter from `createTransactionWithHandlePayment()`, `createTransactionWithTransfer()` and `executeRelayTransaction()` methods in the `GelatoRelayPack` as now it's included in the constructor. - Removed the type `export interface RelayPack` as we use now an abstract class. \ No newline at end of file From 450548210e6467ac265e6f13b73f42d01065b669 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Fri, 24 Nov 2023 10:01:46 +0100 Subject: [PATCH 12/29] Apply suggestions from code review Co-authored-by: Tanay Pant <7481165+tanay1337@users.noreply.github.com> --- safe-core-sdk/api-kit/migrating/v2.md | 10 +++++----- safe-core-sdk/protocol-kit/migrating/v2.md | 8 ++++---- safe-core-sdk/relay-kit/migrating/v2.md | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/safe-core-sdk/api-kit/migrating/v2.md b/safe-core-sdk/api-kit/migrating/v2.md index e6c61cb1..66458fb8 100644 --- a/safe-core-sdk/api-kit/migrating/v2.md +++ b/safe-core-sdk/api-kit/migrating/v2.md @@ -1,10 +1,10 @@ # API Kit: Migrating from v1 -This guide aims to be a reference of the major changes between v1 and v2 to help those migrating an existing app. +This guide references the major changes between v1 and v2 to help those migrating an existing app. ## API Kit constructor -Now it won't be necessary to specify a `txServiceUrl` in those environments where Safe has a Transaction Service running, providing the chain ID will be enough. If you want to use your custom service or use the kit in a chain not supported by a Safe Transaction Service, you can add `txServiceUrl` parameter. +It won't be necessary to specify a `txServiceUrl` in environments where Safe has a Transaction Service running. Providing the chain ID will be enough. If you want to use your custom service or the kit in a chain not supported by a Safe Transaction Service, you can add the `txServiceUrl` parameter. ```js // old: @@ -16,9 +16,9 @@ constructor({ chainId, txServiceUrl? }: SafeApiKitConfig) ## Use the route you prefer -API Kit v1 forced that any custom service was hosted under `/api` route of the URL specified in `txServiceUrl`. This isn't the case anymore, you can specify any route you prefer or subdomain. +API Kit v1 forced any custom service to be hosted under the `/api` route of the URL specified in `txServiceUrl`. This isn't the case anymore; you can specify any preferred route or subdomain. -Note that if you use a custom service running under `/api` you will now need to migrate as follow: +Note that if you use a custom service running under `/api`, you will now need to migrate as follows: ```js // old: @@ -32,7 +32,7 @@ constructor({ chainId, txServiceUrl? }: SafeApiKitConfig) ## MasterCopy to Singleton -To avoid confusion between terms that have been used as synonyms we aligned all our code to use the word `singleton`. +To avoid confusion between terms used as synonyms, we aligned all our code to use the word `singleton`. - Rename type `MasterCopyResponse` to `SafeSingletonResponse` - Rename method `getServiceMasterCopiesInfo()` to `getServiceSingletonsInfo()` \ No newline at end of file diff --git a/safe-core-sdk/protocol-kit/migrating/v2.md b/safe-core-sdk/protocol-kit/migrating/v2.md index f34ba7c1..92d9badf 100644 --- a/safe-core-sdk/protocol-kit/migrating/v2.md +++ b/safe-core-sdk/protocol-kit/migrating/v2.md @@ -1,10 +1,10 @@ # Protocol Kit: Migrating from v1 -This guide aims to be a reference of the major changes between v1 and v2 to help those migrating an existing app. +This guide references the major changes between v1 and v2 to help those migrating an existing app. ## MasterCopy to Singleton -To avoid confusion between terms that have been used as synonyms we aligned all our code to use the word `singleton`. +To avoid confusion between terms used as synonyms, we aligned all our code to use the word `singleton`. - Rename `isL1SafeMasterCopy` to `isL1SafeSingleton` ```js @@ -17,11 +17,11 @@ SafeFactory.create({ ethAdapter, isL1SafeSingleton: true }) ## Ethers v6 -From `protocolKit v2`, EthersAdapter will only be compatible with ethers.js v6. If you still need to use v5 we recommend you to keep `protocolKit v1`, but we encourage you to migrate to the latest version when you have the chance. +From `protocolKit v2`, EthersAdapter will only be compatible with ethers.js v6. If you still need to use v5, we recommend you keep `protocolKit v1`, but we encourage you to migrate to the latest version when you can. ## Protocol Kit createTransaction() accepts only transaction array -In `protocolKit v1` the `createTranasction()` method accepted either an object or an array as parameter. To avoid confusion we aligned to accept only an array. Here is a migration example: +In `protocolKit v1`, the `createTransaction()` method accepted either an object or an array as a parameter. To avoid confusion, we changed it to accept only an array. Here is a migration example: ```js // old: diff --git a/safe-core-sdk/relay-kit/migrating/v2.md b/safe-core-sdk/relay-kit/migrating/v2.md index 677d8c97..31407513 100644 --- a/safe-core-sdk/relay-kit/migrating/v2.md +++ b/safe-core-sdk/relay-kit/migrating/v2.md @@ -1,6 +1,6 @@ # Relay Kit: Migrating from v1 -This guide aims to be a reference of the major changes between v1 and v2 to help those migrating an existing app. +This guide references the major changes between v1 and v2 to help those migrating an existing app. ## GelatoRelayPack @@ -10,6 +10,6 @@ This guide aims to be a reference of the major changes between v1 and v2 to help constructor({ apiKey, protocolKit }: GelatoOptions) ``` -- We removed the `protocolKit` parameter from `createTransactionWithHandlePayment()`, `createTransactionWithTransfer()` and `executeRelayTransaction()` methods in the `GelatoRelayPack` as now it's included in the constructor. +- We removed the `protocolKit` parameter from the `createTransactionWithHandlePayment()`, `createTransactionWithTransfer()`, and `executeRelayTransaction()` methods in the `GelatoRelayPack` as now it's included in the constructor. -- Removed the type `export interface RelayPack` as we use now an abstract class. \ No newline at end of file +- Removed the `export interface RelayPack` type as we now use an abstract class. \ No newline at end of file From f0c8c2a3ede2c780e32b2196a5ffe7980135f0b6 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Fri, 24 Nov 2023 10:07:48 +0100 Subject: [PATCH 13/29] add backticks to EthersAdapter --- safe-core-sdk/protocol-kit/migrating/v2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/protocol-kit/migrating/v2.md b/safe-core-sdk/protocol-kit/migrating/v2.md index 92d9badf..5348835e 100644 --- a/safe-core-sdk/protocol-kit/migrating/v2.md +++ b/safe-core-sdk/protocol-kit/migrating/v2.md @@ -17,7 +17,7 @@ SafeFactory.create({ ethAdapter, isL1SafeSingleton: true }) ## Ethers v6 -From `protocolKit v2`, EthersAdapter will only be compatible with ethers.js v6. If you still need to use v5, we recommend you keep `protocolKit v1`, but we encourage you to migrate to the latest version when you can. +From `protocolKit v2`, `EthersAdapter` will only be compatible with ethers.js v6. If you still need to use v5, we recommend you keep `protocolKit v1`, but we encourage you to migrate to the latest version when you can. ## Protocol Kit createTransaction() accepts only transaction array From 11a4f5ce93078e601dd0718b3dafee49591ed94c Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Fri, 24 Nov 2023 10:12:44 +0100 Subject: [PATCH 14/29] Apply suggestions from code review Co-authored-by: Tanay Pant <7481165+tanay1337@users.noreply.github.com> --- safe-core-sdk/api-kit/README.md | 2 +- safe-core-sdk/protocol-kit/README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/safe-core-sdk/api-kit/README.md b/safe-core-sdk/api-kit/README.md index 11252cbd..932376eb 100644 --- a/safe-core-sdk/api-kit/README.md +++ b/safe-core-sdk/api-kit/README.md @@ -47,7 +47,7 @@ const ethAdapter = new EthersAdapter({ ## Initialize the API Kit -We need to create an instance of the API Kit. In those chains where Safe provides a Transaction Service is enough to specify the `chainId`. You can set your own service using the optional `txServiceUrl` parameter. +We need to create an instance of the API Kit. In chains where Safe provides a Transaction Service, it is enough to specify the `chainId`. You can set your own service using the optional `txServiceUrl` parameter. ```typescript import SafeApiKit from '@safe-global/api-kit' diff --git a/safe-core-sdk/protocol-kit/README.md b/safe-core-sdk/protocol-kit/README.md index 696e8d05..ff4a7ec7 100644 --- a/safe-core-sdk/protocol-kit/README.md +++ b/safe-core-sdk/protocol-kit/README.md @@ -11,7 +11,7 @@ For a more detailed guide, including how to integrate with `web3.js`` and more S ### Prerequisites 1. [Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) -2. 3 externally-owned accounts with Testnet ETH in at least one account +2. Three externally-owned accounts with Testnet ETH in at least one account ### Install dependencies @@ -88,7 +88,7 @@ const ethAdapterOwner1 = new EthersAdapter({ ### Initialize the API Kit -The [API Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/api-kit) consumes the [Safe Transaction Service API](https://github.com/safe-global/safe-transaction-service). To start using this library, create a new instance of the `SafeApiKit` class, imported from `@safe-global/api-kit. In those chains where Safe provides a transaction service is enough to specify the chainId. You can specify your own service using the optional `txServiceUrl` parameter. +The [API Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/api-kit) consumes the [Safe Transaction Service API](https://github.com/safe-global/safe-transaction-service). To use this library, create a new instance of the `SafeApiKit` class, imported from `@safe-global/api-kit`. In those chains where Safe provides a transaction service, it is enough to specify the `chainId.` You can specify your own service using the optional `txServiceUrl` parameter. You will be using Goerli for this tutorial, however, you can also get [service URLs for different networks](../../safe-core-api/available-services.md). From 912e7bb7e466a4c40e5f6c733dc2a678737b0730 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Fri, 24 Nov 2023 10:41:37 +0100 Subject: [PATCH 15/29] set migrating guides below reference --- SUMMARY.md | 5 +++++ safe-core-sdk/api-kit/{ => reference}/migrating/v2.md | 0 safe-core-sdk/onramp-kit/reference/README.md | 2 +- safe-core-sdk/protocol-kit/{ => reference}/migrating/v2.md | 0 safe-core-sdk/relay-kit/{ => reference}/migrating/v2.md | 0 5 files changed, 6 insertions(+), 1 deletion(-) rename safe-core-sdk/api-kit/{ => reference}/migrating/v2.md (100%) rename safe-core-sdk/protocol-kit/{ => reference}/migrating/v2.md (100%) rename safe-core-sdk/relay-kit/{ => reference}/migrating/v2.md (100%) diff --git a/SUMMARY.md b/SUMMARY.md index 0c5eda81..36a13b87 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -34,6 +34,7 @@ * [Protocol Kit](safe-core-sdk/protocol-kit/README.md) * [Reference](safe-core-sdk/protocol-kit/reference/README.md) + * [Migrating to v2](safe-core-sdk/protocol-kit/reference/migrating/v2.md) * [Onramp Kit](safe-core-sdk/onramp-kit/README.md) * [Guides](safe-core-sdk/onramp-kit/guides/README.md) @@ -47,9 +48,13 @@ * [Relay Kit](safe-core-sdk/relay-kit/README.md) * [Guides](safe-core-sdk/relay-kit/guides/README.md) * [Gelato Relay](safe-core-sdk/relay-kit/guides/gelato.md) + * [Reference](safe-core-sdk/relay-kit/reference/README.md) + * [Migrating to v2](safe-core-sdk/relay-kit/reference/migrating/v2.md) * [API Kit](safe-core-sdk/api-kit/README.md) * [Reference](safe-core-sdk/api-kit/reference/README.md) + * [Migrating to v2](safe-core-sdk/api-kit/reference/migrating/v2.md) + ## Safe{Core} Protocol diff --git a/safe-core-sdk/api-kit/migrating/v2.md b/safe-core-sdk/api-kit/reference/migrating/v2.md similarity index 100% rename from safe-core-sdk/api-kit/migrating/v2.md rename to safe-core-sdk/api-kit/reference/migrating/v2.md diff --git a/safe-core-sdk/onramp-kit/reference/README.md b/safe-core-sdk/onramp-kit/reference/README.md index fb4a81ff..26e59ecb 100644 --- a/safe-core-sdk/onramp-kit/reference/README.md +++ b/safe-core-sdk/onramp-kit/reference/README.md @@ -11,7 +11,7 @@ To add the Onramp Kit to your project, run: ```bash yarn add @safe-global/onramp-kit ``` -The Onramp Kit can integrate several providers in the form of "packs". A pack is a piece of code that works with the chosen provider to give Safe users access to new services. +The Onramp Kit can integrate several providers in the form of **"packs"**. A pack is a piece of code that works with the chosen provider to give Safe users access to new services. To use each pack, the right package needs to be installed: diff --git a/safe-core-sdk/protocol-kit/migrating/v2.md b/safe-core-sdk/protocol-kit/reference/migrating/v2.md similarity index 100% rename from safe-core-sdk/protocol-kit/migrating/v2.md rename to safe-core-sdk/protocol-kit/reference/migrating/v2.md diff --git a/safe-core-sdk/relay-kit/migrating/v2.md b/safe-core-sdk/relay-kit/reference/migrating/v2.md similarity index 100% rename from safe-core-sdk/relay-kit/migrating/v2.md rename to safe-core-sdk/relay-kit/reference/migrating/v2.md From e15332578d46b0447cce0026954b9bba9dd8d9cc Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Fri, 24 Nov 2023 10:54:22 +0100 Subject: [PATCH 16/29] add wording suggestions --- safe-core-sdk/api-kit/README.md | 2 +- safe-core-sdk/protocol-kit/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/safe-core-sdk/api-kit/README.md b/safe-core-sdk/api-kit/README.md index 932376eb..6b7a5104 100644 --- a/safe-core-sdk/api-kit/README.md +++ b/safe-core-sdk/api-kit/README.md @@ -47,7 +47,7 @@ const ethAdapter = new EthersAdapter({ ## Initialize the API Kit -We need to create an instance of the API Kit. In chains where Safe provides a Transaction Service, it is enough to specify the `chainId`. You can set your own service using the optional `txServiceUrl` parameter. +We need to create an instance of the API Kit. In chains where Safe provides a Transaction Service, it's enough to specify the `chainId`. You can set your own service using the optional `txServiceUrl` parameter. ```typescript import SafeApiKit from '@safe-global/api-kit' diff --git a/safe-core-sdk/protocol-kit/README.md b/safe-core-sdk/protocol-kit/README.md index ff4a7ec7..d0da795e 100644 --- a/safe-core-sdk/protocol-kit/README.md +++ b/safe-core-sdk/protocol-kit/README.md @@ -88,7 +88,7 @@ const ethAdapterOwner1 = new EthersAdapter({ ### Initialize the API Kit -The [API Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/api-kit) consumes the [Safe Transaction Service API](https://github.com/safe-global/safe-transaction-service). To use this library, create a new instance of the `SafeApiKit` class, imported from `@safe-global/api-kit`. In those chains where Safe provides a transaction service, it is enough to specify the `chainId.` You can specify your own service using the optional `txServiceUrl` parameter. +The [API Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/api-kit) consumes the [Safe Transaction Service API](https://github.com/safe-global/safe-transaction-service). To use this library, create a new instance of the `SafeApiKit` class, imported from `@safe-global/api-kit`. In chains where Safe provides a Transaction Service, it's enough to specify the `chainId.` You can specify your own service using the optional `txServiceUrl` parameter. You will be using Goerli for this tutorial, however, you can also get [service URLs for different networks](../../safe-core-api/available-services.md). From ded1c68fa9a835aff2533fd1dd5591e78343ba9c Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Fri, 24 Nov 2023 17:51:12 +0100 Subject: [PATCH 17/29] Add safe-transaction-service migration guide --- .../api-kit/reference/migrating/v1.md | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 safe-core-sdk/api-kit/reference/migrating/v1.md diff --git a/safe-core-sdk/api-kit/reference/migrating/v1.md b/safe-core-sdk/api-kit/reference/migrating/v1.md new file mode 100644 index 00000000..58e3b2f6 --- /dev/null +++ b/safe-core-sdk/api-kit/reference/migrating/v1.md @@ -0,0 +1,112 @@ +# API Kit: Migrating from `safe-service-client` + +This guide references the major changes between `safe-service-client` and `api-kit v1` to help those migrating an existing app. + +**It's recommended to go through this guide before migrating to `api-kit v2`** + +## Adding the new dependency + +To add the API Kit to your project, run: + +```bash +yarn add @safe-global/api-kit@1.3.1 +``` + +Then change your initialization like this: + +```typescript +// old +import SafeServiceClient from '@safe-global/safe-service-client' + +const safeService = new SafeServiceClient({ + txServiceUrl: 'https://your-transaction-service-url', + ethAdapter +}) + +// new +import SafeApiKit from '@safe-global/api-kit' + +const apiKit = new SafeApiKit({ + txServiceUrl: 'https://your-transaction-service-url', + ethAdapter +}) +``` + +## getSafeDelegates() + +The getSafeDelegates was updated to accept more filtering parametes. Now it accepts an object with multiple properties instead of only `safeAddress` parameter. + +```typescript +const delegateConfig: GetSafeDelegateProps = { + safeAddress, // Optional + delegateAddress, // Optional + delegatorAddress, // Optional + label, // Optional + limit, // Optional + offset // Optional +} +const delegates: SafeDelegateListResponse = await apiKit.getSafeDelegates(delegateConfig) +``` + +## addSafeDelegate() + +Parameter object properties were updated as follows: + +```typescript +// old +const delegateConfig: SafeDelegateConfig = { + safe, + delegate, + label, + signer +} +await safeService.addSafeDelegate(delegateConfig) + +// new +const delegateConfig: AddSafeDelegateProps = { + safeAddress, // Optional + delegateAddress, + delegatorAddress, + label, + signer +} +await apiKit.addSafeDelegate(delegateConfig) +``` + +## removeAllSafeDelegates() + +Method was deprecated and removed. + +## removeSafeDelegate() + +Parameter object properties were updated as follow: + +```typescript +// old +const delegateConfig: SafeDelegateDeleteConfig = { + safe, + delegate, + signer +} +await safeService.removeSafeDelegate(delegateConfig) + +// new +const delegateConfig: DeleteSafeDelegateProps = { + delegateAddress, + delegatorAddress, + signer +} +await apiKit.removeSafeDelegate(delegateConfig) +``` + +## getBalances() + +Method was deprecated and removed. + +## getUSDBalances() + +Method was deprecated and removed. + +## getCollectibles() + +Method was deprecated and removed. \ No newline at end of file From 969fb4779afbe57fef3159b8c7657cf2ccd16caa Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Fri, 24 Nov 2023 18:09:27 +0100 Subject: [PATCH 18/29] Add migration guide from legacy safe-core-sdk --- .../protocol-kit/reference/migrating/v1.md | 59 +++++++++++++++++++ .../protocol-kit/reference/migrating/v2.md | 2 + 2 files changed, 61 insertions(+) create mode 100644 safe-core-sdk/protocol-kit/reference/migrating/v1.md diff --git a/safe-core-sdk/protocol-kit/reference/migrating/v1.md b/safe-core-sdk/protocol-kit/reference/migrating/v1.md new file mode 100644 index 00000000..bdc6343a --- /dev/null +++ b/safe-core-sdk/protocol-kit/reference/migrating/v1.md @@ -0,0 +1,59 @@ +# Protocol Kit: Migrating from `safe-core-sdk` + +This guide references the major changes between `safe-core-sdk` and `protocol-kit v1` to help those migrating an existing app. + +**It's recommended to go through this guide before migrating to `protocol-kit v2`** + +## Adding the new dependency + +To add the Protocol Kit to your project, run: + +```bash +yarn add @safe-global/protocol-kit@1.3.0 +``` + +If you use the types library you will need to update to v2.3.0: + +```bash +yarn add @safe-global/safe-core-sdk-types@2.3.0 +``` + +## `EthersAdapter` (safe-ethers-lib) + +`EthersAdapter` is not in a separate package anymore. Now it's provided inside the `protocol-kit` package aswell. + +**`protocol-kit v1` only supports `ethers v5`** + +```typescript +// old +import EthersAdapter from '@safe-global/safe-ethers-lib' + +// new +import { EthersAdapter } from '@safe-global/protocol-kit' +``` + +## `Web3Adapter` (safe-web3-lib) + +`Web3Adapter` is not in a separate package anymore. Now it's provided inside the `protocol-kit` package aswell. + +**`protocol-kit v1` only supports `Web3.js v1`** + +```typescript +// old +import Web3Adapter from '@safe-global/safe-web3-lib' + +// new +import { Web3Adapter } from '@safe-global/protocol-kit' +``` + +## getAddress() + +The get address method now returns a Promise. + +```typescript +// old +const safeAddress = safeSdk.getAddress() + +// new +const safeAddress = await protocolKit.getAddress() +``` \ No newline at end of file diff --git a/safe-core-sdk/protocol-kit/reference/migrating/v2.md b/safe-core-sdk/protocol-kit/reference/migrating/v2.md index 5348835e..1ad7cbc0 100644 --- a/safe-core-sdk/protocol-kit/reference/migrating/v2.md +++ b/safe-core-sdk/protocol-kit/reference/migrating/v2.md @@ -2,6 +2,8 @@ This guide references the major changes between v1 and v2 to help those migrating an existing app. +**When upgrading to `protocol-kit v2` it's necessary to upgrade `safe-core-sdk-types v3`** + ## MasterCopy to Singleton To avoid confusion between terms used as synonyms, we aligned all our code to use the word `singleton`. From 73b2693ab2a8ec972ee42afdb0426e49e9c28f99 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Tue, 28 Nov 2023 12:26:09 +0100 Subject: [PATCH 19/29] Add types changes --- .../api-kit/reference/migrating/v1.md | 2 + .../protocol-kit/reference/migrating/v1.md | 45 +++++++++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/safe-core-sdk/api-kit/reference/migrating/v1.md b/safe-core-sdk/api-kit/reference/migrating/v1.md index 58e3b2f6..91fff481 100644 --- a/safe-core-sdk/api-kit/reference/migrating/v1.md +++ b/safe-core-sdk/api-kit/reference/migrating/v1.md @@ -4,6 +4,8 @@ This guide references the major changes between `safe-service-client` and `api-k **It's recommended to go through this guide before migrating to `api-kit v2`** +You can remove `@safe-global/safe-service-client` from your `package.json` after completing this guide. + ## Adding the new dependency To add the API Kit to your project, run: diff --git a/safe-core-sdk/protocol-kit/reference/migrating/v1.md b/safe-core-sdk/protocol-kit/reference/migrating/v1.md index bdc6343a..21a823a4 100644 --- a/safe-core-sdk/protocol-kit/reference/migrating/v1.md +++ b/safe-core-sdk/protocol-kit/reference/migrating/v1.md @@ -4,6 +4,8 @@ This guide references the major changes between `safe-core-sdk` and `protocol-ki **It's recommended to go through this guide before migrating to `protocol-kit v2`** +You can remove `@safe-global/safe-core-sdk` from your `package.json` after completing this guide. + ## Adding the new dependency To add the Protocol Kit to your project, run: @@ -18,7 +20,9 @@ If you use the types library you will need to update to v2.3.0: yarn add @safe-global/safe-core-sdk-types@2.3.0 ``` -## `EthersAdapter` (safe-ethers-lib) +## `EthAdapter` + +### `EthersAdapter` (safe-ethers-lib) `EthersAdapter` is not in a separate package anymore. Now it's provided inside the `protocol-kit` package aswell. @@ -32,7 +36,9 @@ import EthersAdapter from '@safe-global/safe-ethers-lib' import { EthersAdapter } from '@safe-global/protocol-kit' ``` -## `Web3Adapter` (safe-web3-lib) +You can remove `@safe-global/safe-ethers-lib` from your `package.json` after this change. + +### `Web3Adapter` (safe-web3-lib) `Web3Adapter` is not in a separate package anymore. Now it's provided inside the `protocol-kit` package aswell. @@ -46,6 +52,39 @@ import Web3Adapter from '@safe-global/safe-web3-lib' import { Web3Adapter } from '@safe-global/protocol-kit' ``` +You can remove `@safe-global/safe-web3-lib` from your `package.json` after this change. + +### Types changes + +There are type changes affecting web3 and ethers adapter libraries. + +`getSafeContract`, `getMultisendContract`, `getMultisendCallOnlyContract`, `getCompatibilityFallbackHandlerContract`, `getSafeProxyFactoryContract`, `getSignMessageLibContract` and `getCreateCallContract` don't need the `chainId` parameter any more, they will use the provider connected one. Also they will return a `Promise` now. + +`estimateGas` will return now a `string` instead of a `number` + +## safeFactory.deploySafe() + +`SafeDeploymentConfig` was simplified. If you were using a `saltNonce` you should set it like this: + +```typescript +// old +const safeAccountConfig: SafeAccountConfig = { + ... +} +const safeDeploymentConfig: SafeDeploymentConfig = { saltNonce } + +const safeSdk = await safeFactory.deploySafe({ safeAccountConfig, safeDeploymentConfig }) + +// new +const safeAccountConfig: SafeAccountConfig = { + ... +} + +const saltNonce = '' + +const safeSdk = await safeFactory.deploySafe({ safeAccountConfig, saltNonce }) +``` + ## getAddress() The get address method now returns a Promise. @@ -56,4 +95,4 @@ const safeAddress = safeSdk.getAddress() // new const safeAddress = await protocolKit.getAddress() -``` \ No newline at end of file +``` From 09a86b6cd8f6d0b0e94958582fbdf1a49864659c Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Tue, 28 Nov 2023 12:31:02 +0100 Subject: [PATCH 20/29] remove auth-kit changes --- safe-core-sdk/auth-kit/guides/web3auth.md | 8 ++++---- safe-core-sdk/auth-kit/reference/AuthKitBasePack.md | 13 ++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/safe-core-sdk/auth-kit/guides/web3auth.md b/safe-core-sdk/auth-kit/guides/web3auth.md index 118cd810..d949c17f 100644 --- a/safe-core-sdk/auth-kit/guides/web3auth.md +++ b/safe-core-sdk/auth-kit/guides/web3auth.md @@ -145,7 +145,7 @@ Once connected, you can use any of the methods available in the [Protocol Kit](h import { ethers } from 'ethers' import { EthersAdapter } from '@safe-global/protocol-kit' -provider = new ethers.BrowserProvider(web3AuthModalPack.getProvider()) +provider = new ethers.providers.Web3Provider(web3AuthModalPack.getProvider()) signer = provider.getSigner() const ethAdapter = new EthersAdapter({ @@ -162,10 +162,10 @@ const safeSDK = await Safe.create({ const safeTransactionData: MetaTransactionData = { to: '0x', data: '0x', - value: ethers.parseUnits('0.0001', 'ether').toString() + value: ethers.utils.parseUnits('0.0001', 'ether').toString() } -const safeTransaction = await safeSDK.createTransaction({ transactions: [safeTransactionData] }) +const safeTransaction = await safeSDK.createTransaction({ safeTransactionData }) ``` ## Sign messages using the `Web3AuthModalPack` @@ -183,7 +183,7 @@ const address = '0x...' await web3.eth.personal.sign(message, address) // Using ethers -const provider = new ethers.BrowserProvider(web3AuthModalPack.getProvider()) +const provider = new ethers.providers.Web3Provider(web3AuthModalPack.getProvider()) const signer = provider.getSigner() await signer.sendTransaction(tx) diff --git a/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md b/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md index 54b07d83..81125fb9 100644 --- a/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md +++ b/safe-core-sdk/auth-kit/reference/AuthKitBasePack.md @@ -24,19 +24,19 @@ class MyPack extends AuthKitBasePack { These methods are the common interface for all the Auth packs. Check each pack's documentation to get more details. -### `init(options?): Promise` +### `init(options?)` Provides the initialization options for the required packages, classes and properties. -### `signIn(): Promise` +### `signIn(): authKitSignInData` Provides a mechanism to connect to the provider services and returns an Ethereum address that will be used as a signer along with the associated Safe addresses. -### `signOut(): Promise` +### `signOut()` Disconnects the provider services and cleans up any data related to the current user. -### `getProvider(): Eip1193Provider | null` +### `getProvider(): web3Provider` Returns a Web3 provider that can be used to interact with the blockchain (`web3.js` or `ethers.js` for example). @@ -63,13 +63,12 @@ Returns the Ethereum address extracted from the provider retrieved by `getProvid **Returns** - `address`: The Ethereum address extracted from the provider. -### `getSafes(chainId, txServiceUrl?): safes[]` +### `getSafes(txServiceUrl): safes[]` Returns the list of Safes associated with the signer address by calling the `getAddress()` method internally. **Params** -- `chainId`: Indicate the chain ID. -- `txServiceUrl`(optional): The Safe Transaction Service URL to retrieve the Safes associated with the owner (signer). +- `txServiceUrl`: The Safe Transaction Service url to retrieve the Safes associated with the owner (signer). **Returns** - `safes[]`: The list of Safes associated with the owner (signer). From af6d717b2cfc56df541074c75f82080d3f9b3288 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Tue, 28 Nov 2023 12:36:36 +0100 Subject: [PATCH 21/29] fix linting issues --- safe-core-sdk/api-kit/reference/migrating/v1.md | 16 ++++++++-------- .../protocol-kit/reference/migrating/v1.md | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/safe-core-sdk/api-kit/reference/migrating/v1.md b/safe-core-sdk/api-kit/reference/migrating/v1.md index 91fff481..5ebbd3cf 100644 --- a/safe-core-sdk/api-kit/reference/migrating/v1.md +++ b/safe-core-sdk/api-kit/reference/migrating/v1.md @@ -34,9 +34,9 @@ const apiKit = new SafeApiKit({ }) ``` -## getSafeDelegates() +## `getSafeDelegates()` -The getSafeDelegates was updated to accept more filtering parametes. Now it accepts an object with multiple properties instead of only `safeAddress` parameter. +The `getSafeDelegates` was updated to accept more filtering parameters. Now it accepts an object with multiple properties instead of only `safeAddress` parameter. ```typescript const delegateConfig: GetSafeDelegateProps = { @@ -50,7 +50,7 @@ const delegateConfig: GetSafeDelegateProps = { const delegates: SafeDelegateListResponse = await apiKit.getSafeDelegates(delegateConfig) ``` -## addSafeDelegate() +## `addSafeDelegate()` Parameter object properties were updated as follows: @@ -75,11 +75,11 @@ const delegateConfig: AddSafeDelegateProps = { await apiKit.addSafeDelegate(delegateConfig) ``` -## removeAllSafeDelegates() +## `removeAllSafeDelegates()` Method was deprecated and removed. -## removeSafeDelegate() +## `removeSafeDelegate()` Parameter object properties were updated as follow: @@ -101,14 +101,14 @@ const delegateConfig: DeleteSafeDelegateProps = { await apiKit.removeSafeDelegate(delegateConfig) ``` -## getBalances() +## `getBalances()` Method was deprecated and removed. -## getUSDBalances() +## `getUSDBalances()` Method was deprecated and removed. -## getCollectibles() +## `getCollectibles()` Method was deprecated and removed. \ No newline at end of file diff --git a/safe-core-sdk/protocol-kit/reference/migrating/v1.md b/safe-core-sdk/protocol-kit/reference/migrating/v1.md index 21a823a4..ea282c0c 100644 --- a/safe-core-sdk/protocol-kit/reference/migrating/v1.md +++ b/safe-core-sdk/protocol-kit/reference/migrating/v1.md @@ -24,7 +24,7 @@ yarn add @safe-global/safe-core-sdk-types@2.3.0 ### `EthersAdapter` (safe-ethers-lib) -`EthersAdapter` is not in a separate package anymore. Now it's provided inside the `protocol-kit` package aswell. +`EthersAdapter` isn't in a separate package anymore. Now it's provided inside the `protocol-kit` package. **`protocol-kit v1` only supports `ethers v5`** @@ -40,7 +40,7 @@ You can remove `@safe-global/safe-ethers-lib` from your `package.json` after thi ### `Web3Adapter` (safe-web3-lib) -`Web3Adapter` is not in a separate package anymore. Now it's provided inside the `protocol-kit` package aswell. +`Web3Adapter` is not in a separate package anymore. Now it's provided inside the `protocol-kit` package. **`protocol-kit v1` only supports `Web3.js v1`** @@ -62,7 +62,7 @@ There are type changes affecting web3 and ethers adapter libraries. `estimateGas` will return now a `string` instead of a `number` -## safeFactory.deploySafe() +## `safeFactory.deploySafe()` `SafeDeploymentConfig` was simplified. If you were using a `saltNonce` you should set it like this: @@ -85,7 +85,7 @@ const saltNonce = '' const safeSdk = await safeFactory.deploySafe({ safeAccountConfig, saltNonce }) ``` -## getAddress() +## `getAddress()` The get address method now returns a Promise. From 29d49709bd3d667bac9367ba2038845bebd66ae3 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Tue, 28 Nov 2023 13:31:59 +0100 Subject: [PATCH 22/29] improve api-kit v2 migration --- .../api-kit/reference/migrating/v2.md | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/safe-core-sdk/api-kit/reference/migrating/v2.md b/safe-core-sdk/api-kit/reference/migrating/v2.md index 66458fb8..67fddd19 100644 --- a/safe-core-sdk/api-kit/reference/migrating/v2.md +++ b/safe-core-sdk/api-kit/reference/migrating/v2.md @@ -8,10 +8,26 @@ It won't be necessary to specify a `txServiceUrl` in environments where Safe has ```js // old: -constructor({ txServiceUrl, ethAdapter }: SafeApiKitConfig) +import SafeApiKit from '@safe-global/api-kit' + +const apiKit = new SafeApiKit({ + txServiceUrl: 'https://your-transaction-service-url', + ethAdapter +}) // new: -constructor({ chainId, txServiceUrl? }: SafeApiKitConfig) +import SafeApiKit from '@safe-global/api-kit' + +const chainId: bigint = 1n +const apiKit = new SafeApiKit({ + chainId +}) + +// or set a custom Transaction Service +const apiKit = new SafeApiKit({ + chainId, + txServiceUrl: 'https://your-transaction-service-url' +}) ``` ## Use the route you prefer @@ -23,11 +39,17 @@ Note that if you use a custom service running under `/api`, you will now need to ```js // old: const txServiceUrl = 'https://your-transaction-service-domain/' -constructor({ txServiceUrl, ethAdapter }: SafeApiKitConfig) - +const apiKit = new SafeApiKit({ + txServiceUrl, + ethAdapter +}) // new: +const chainId: bigint = 1n const txServiceUrl = 'https://your-transaction-service-domain/api' -constructor({ chainId, txServiceUrl? }: SafeApiKitConfig) +const apiKit = new SafeApiKit({ + chainId, + txServiceUrl +}) ``` ## MasterCopy to Singleton From 3012b3a1b11d4a48c7a442eb0c5dcb068f43e380 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:37:52 +0100 Subject: [PATCH 23/29] Add latest changes --- safe-core-sdk/protocol-kit/reference/migrating/v1.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/safe-core-sdk/protocol-kit/reference/migrating/v1.md b/safe-core-sdk/protocol-kit/reference/migrating/v1.md index ea282c0c..7bf5a363 100644 --- a/safe-core-sdk/protocol-kit/reference/migrating/v1.md +++ b/safe-core-sdk/protocol-kit/reference/migrating/v1.md @@ -58,9 +58,9 @@ You can remove `@safe-global/safe-web3-lib` from your `package.json` after this There are type changes affecting web3 and ethers adapter libraries. -`getSafeContract`, `getMultisendContract`, `getMultisendCallOnlyContract`, `getCompatibilityFallbackHandlerContract`, `getSafeProxyFactoryContract`, `getSignMessageLibContract` and `getCreateCallContract` don't need the `chainId` parameter any more, they will use the provider connected one. Also they will return a `Promise` now. +`getSafeContract`, `getMultisendContract`, `getMultisendCallOnlyContract`, `getCompatibilityFallbackHandlerContract`, `getSafeProxyFactoryContract`, `getSignMessageLibContract` and `getCreateCallContract` don't need the `chainId` parameter any more, they will use the chain set on the provider. Also they return a `Promise` now. -`estimateGas` will return now a `string` instead of a `number` +`estimateGas` returns now a `string` instead of a `number` ## `safeFactory.deploySafe()` @@ -96,3 +96,7 @@ const safeAddress = safeSdk.getAddress() // new const safeAddress = await protocolKit.getAddress() ``` + +## General types changes + +If you set `safeTxGas`, `baseGas`, and `gasPrice` you must use `string` instead of `number`. \ No newline at end of file From c189a746b33cfbe6e18ea59f402fb0ea5f56d2f2 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:39:08 +0100 Subject: [PATCH 24/29] Add missing type --- safe-core-sdk/protocol-kit/reference/migrating/v1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/protocol-kit/reference/migrating/v1.md b/safe-core-sdk/protocol-kit/reference/migrating/v1.md index 7bf5a363..2f6046e3 100644 --- a/safe-core-sdk/protocol-kit/reference/migrating/v1.md +++ b/safe-core-sdk/protocol-kit/reference/migrating/v1.md @@ -99,4 +99,4 @@ const safeAddress = await protocolKit.getAddress() ## General types changes -If you set `safeTxGas`, `baseGas`, and `gasPrice` you must use `string` instead of `number`. \ No newline at end of file +If you set `safeTxGas`, `baseGas`, and `gasPrice` you must use type `string` instead of `number`. \ No newline at end of file From 3e4abbe3b14a0c8f25b66ea006beca7771eb1050 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:39:41 +0100 Subject: [PATCH 25/29] fix typo --- safe-core-sdk/protocol-kit/reference/migrating/v1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/protocol-kit/reference/migrating/v1.md b/safe-core-sdk/protocol-kit/reference/migrating/v1.md index 2f6046e3..03a23727 100644 --- a/safe-core-sdk/protocol-kit/reference/migrating/v1.md +++ b/safe-core-sdk/protocol-kit/reference/migrating/v1.md @@ -99,4 +99,4 @@ const safeAddress = await protocolKit.getAddress() ## General types changes -If you set `safeTxGas`, `baseGas`, and `gasPrice` you must use type `string` instead of `number`. \ No newline at end of file +If you set `safeTxGas`, `baseGas`, or `gasPrice` you must use type `string` instead of `number`. \ No newline at end of file From 65a244ff1764dc05d680f0ba8fe6373e2f011289 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Wed, 29 Nov 2023 14:04:31 +0100 Subject: [PATCH 26/29] Apply suggestions from code review Co-authored-by: Tanay Pant <7481165+tanay1337@users.noreply.github.com> --- .../api-kit/reference/migrating/v1.md | 22 +++++++------- .../protocol-kit/reference/migrating/v1.md | 30 +++++++++---------- .../protocol-kit/reference/migrating/v2.md | 2 +- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/safe-core-sdk/api-kit/reference/migrating/v1.md b/safe-core-sdk/api-kit/reference/migrating/v1.md index 5ebbd3cf..0d581a11 100644 --- a/safe-core-sdk/api-kit/reference/migrating/v1.md +++ b/safe-core-sdk/api-kit/reference/migrating/v1.md @@ -1,20 +1,20 @@ # API Kit: Migrating from `safe-service-client` -This guide references the major changes between `safe-service-client` and `api-kit v1` to help those migrating an existing app. +This guide references the major changes between `safe-service-client` and `api-kit` v1 to help those migrating an existing application. -**It's recommended to go through this guide before migrating to `api-kit v2`** +**Note:** Follow this guide before migrating to `api-kit` v2. -You can remove `@safe-global/safe-service-client` from your `package.json` after completing this guide. +After completing this guide, you can remove `@safe-global/safe-service-client` from your package.json`. ## Adding the new dependency -To add the API Kit to your project, run: +To add the API Kit to your project, run the following: ```bash yarn add @safe-global/api-kit@1.3.1 ``` -Then change your initialization like this: +Change your initialization like this: ```typescript // old @@ -36,7 +36,7 @@ const apiKit = new SafeApiKit({ ## `getSafeDelegates()` -The `getSafeDelegates` was updated to accept more filtering parameters. Now it accepts an object with multiple properties instead of only `safeAddress` parameter. +The `getSafeDelegates` was updated to accept more filtering parameters. Now, it accepts an object with multiple properties instead of only the `safeAddress` parameter. ```typescript const delegateConfig: GetSafeDelegateProps = { @@ -77,11 +77,11 @@ await apiKit.addSafeDelegate(delegateConfig) ## `removeAllSafeDelegates()` -Method was deprecated and removed. +The method was deprecated and removed. ## `removeSafeDelegate()` -Parameter object properties were updated as follow: +Parameter object properties were updated as follows: ```typescript // old @@ -103,12 +103,12 @@ await apiKit.removeSafeDelegate(delegateConfig) ## `getBalances()` -Method was deprecated and removed. +The method was deprecated and removed. ## `getUSDBalances()` -Method was deprecated and removed. +The method was deprecated and removed. ## `getCollectibles()` -Method was deprecated and removed. \ No newline at end of file +The method was deprecated and removed. \ No newline at end of file diff --git a/safe-core-sdk/protocol-kit/reference/migrating/v1.md b/safe-core-sdk/protocol-kit/reference/migrating/v1.md index 03a23727..0a375cb1 100644 --- a/safe-core-sdk/protocol-kit/reference/migrating/v1.md +++ b/safe-core-sdk/protocol-kit/reference/migrating/v1.md @@ -1,20 +1,20 @@ # Protocol Kit: Migrating from `safe-core-sdk` -This guide references the major changes between `safe-core-sdk` and `protocol-kit v1` to help those migrating an existing app. +This guide references the major changes between `safe-core-sdk` and `protocol-kit` v1 to help those migrating an existing application. -**It's recommended to go through this guide before migrating to `protocol-kit v2`** +**Note:** Follow this guide before migrating to `protocol-kit` v2. You can remove `@safe-global/safe-core-sdk` from your `package.json` after completing this guide. ## Adding the new dependency -To add the Protocol Kit to your project, run: +To add the Protocol Kit to your project, run the following: ```bash yarn add @safe-global/protocol-kit@1.3.0 ``` -If you use the types library you will need to update to v2.3.0: +If you use the types library, you will need to update to v2.3.0: ```bash yarn add @safe-global/safe-core-sdk-types@2.3.0 @@ -24,7 +24,7 @@ yarn add @safe-global/safe-core-sdk-types@2.3.0 ### `EthersAdapter` (safe-ethers-lib) -`EthersAdapter` isn't in a separate package anymore. Now it's provided inside the `protocol-kit` package. +`EthersAdapter` isn't in a separate package anymore. Now, it's provided inside the `protocol-kit` package. **`protocol-kit v1` only supports `ethers v5`** @@ -36,13 +36,13 @@ import EthersAdapter from '@safe-global/safe-ethers-lib' import { EthersAdapter } from '@safe-global/protocol-kit' ``` -You can remove `@safe-global/safe-ethers-lib` from your `package.json` after this change. +After this change, you can remove `@safe-global/safe-ethers-lib` from your `package.json`. ### `Web3Adapter` (safe-web3-lib) -`Web3Adapter` is not in a separate package anymore. Now it's provided inside the `protocol-kit` package. +`Web3Adapter` isn't in a separate package anymore. Now, it's part of the `protocol-kit` package. -**`protocol-kit v1` only supports `Web3.js v1`** +**Note:** `protocol-kit` v1 only supports Web3.js v1. ```typescript // old @@ -52,13 +52,13 @@ import Web3Adapter from '@safe-global/safe-web3-lib' import { Web3Adapter } from '@safe-global/protocol-kit' ``` -You can remove `@safe-global/safe-web3-lib` from your `package.json` after this change. +After this change, you can remove `@safe-global/safe-web3-lib` from your `package.json`. -### Types changes +### Type changes -There are type changes affecting web3 and ethers adapter libraries. +Type changes are affecting the web3 and ethers adapter libraries. -`getSafeContract`, `getMultisendContract`, `getMultisendCallOnlyContract`, `getCompatibilityFallbackHandlerContract`, `getSafeProxyFactoryContract`, `getSignMessageLibContract` and `getCreateCallContract` don't need the `chainId` parameter any more, they will use the chain set on the provider. Also they return a `Promise` now. +`getSafeContract`, `getMultisendContract`, `getMultisendCallOnlyContract`, `getCompatibilityFallbackHandlerContract`, `getSafeProxyFactoryContract`, `getSignMessageLibContract` and `getCreateCallContract` don't need the `chainId` parameter anymore, they will use the chain set on the provider. Also, they return a `Promise` now. `estimateGas` returns now a `string` instead of a `number` @@ -87,7 +87,7 @@ const safeSdk = await safeFactory.deploySafe({ safeAccountConfig, saltNonce }) ## `getAddress()` -The get address method now returns a Promise. +The `getAddress()` method now returns a `Promise`. ```typescript // old @@ -97,6 +97,6 @@ const safeAddress = safeSdk.getAddress() const safeAddress = await protocolKit.getAddress() ``` -## General types changes +## General type changes -If you set `safeTxGas`, `baseGas`, or `gasPrice` you must use type `string` instead of `number`. \ No newline at end of file +If you set `safeTxGas`, `baseGas`, or `gasPrice`, you must use the type `string` instead of `number`. \ No newline at end of file diff --git a/safe-core-sdk/protocol-kit/reference/migrating/v2.md b/safe-core-sdk/protocol-kit/reference/migrating/v2.md index 1ad7cbc0..4d34d9ae 100644 --- a/safe-core-sdk/protocol-kit/reference/migrating/v2.md +++ b/safe-core-sdk/protocol-kit/reference/migrating/v2.md @@ -2,7 +2,7 @@ This guide references the major changes between v1 and v2 to help those migrating an existing app. -**When upgrading to `protocol-kit v2` it's necessary to upgrade `safe-core-sdk-types v3`** +**Note:** When upgrading to `protocol-kit` v2, it's necessary to upgrade to `safe-core-sdk-types` v3. ## MasterCopy to Singleton From 7bcdec4a85e847b9883cf776370656663b8be5bf Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Wed, 29 Nov 2023 14:30:13 +0100 Subject: [PATCH 27/29] add migration links --- SUMMARY.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SUMMARY.md b/SUMMARY.md index 36a13b87..7d8d3e05 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -34,6 +34,7 @@ * [Protocol Kit](safe-core-sdk/protocol-kit/README.md) * [Reference](safe-core-sdk/protocol-kit/reference/README.md) + * [Migrating to v1](safe-core-sdk/protocol-kit/reference/migrating/v1.md) * [Migrating to v2](safe-core-sdk/protocol-kit/reference/migrating/v2.md) * [Onramp Kit](safe-core-sdk/onramp-kit/README.md) @@ -53,6 +54,7 @@ * [API Kit](safe-core-sdk/api-kit/README.md) * [Reference](safe-core-sdk/api-kit/reference/README.md) + * [Migrating to v1](safe-core-sdk/api-kit/reference/migrating/v1.md) * [Migrating to v2](safe-core-sdk/api-kit/reference/migrating/v2.md) From 74d0a408326fad246cf980389fea9b065f41ea4d Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Wed, 29 Nov 2023 14:35:12 +0100 Subject: [PATCH 28/29] Update safe-core-sdk/protocol-kit/reference/migrating/v1.md Co-authored-by: Tanay Pant <7481165+tanay1337@users.noreply.github.com> --- safe-core-sdk/protocol-kit/reference/migrating/v1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-core-sdk/protocol-kit/reference/migrating/v1.md b/safe-core-sdk/protocol-kit/reference/migrating/v1.md index 0a375cb1..3467699f 100644 --- a/safe-core-sdk/protocol-kit/reference/migrating/v1.md +++ b/safe-core-sdk/protocol-kit/reference/migrating/v1.md @@ -60,7 +60,7 @@ Type changes are affecting the web3 and ethers adapter libraries. `getSafeContract`, `getMultisendContract`, `getMultisendCallOnlyContract`, `getCompatibilityFallbackHandlerContract`, `getSafeProxyFactoryContract`, `getSignMessageLibContract` and `getCreateCallContract` don't need the `chainId` parameter anymore, they will use the chain set on the provider. Also, they return a `Promise` now. -`estimateGas` returns now a `string` instead of a `number` +`estimateGas` now returns a `string` instead of a `number`. ## `safeFactory.deploySafe()` From 8190b5ade043c4a7a7a1d3f2ebb44c76933e5b39 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Wed, 29 Nov 2023 14:37:10 +0100 Subject: [PATCH 29/29] Reverse migration links order in SUMMARY --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 7d8d3e05..8ae757be 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -34,8 +34,8 @@ * [Protocol Kit](safe-core-sdk/protocol-kit/README.md) * [Reference](safe-core-sdk/protocol-kit/reference/README.md) - * [Migrating to v1](safe-core-sdk/protocol-kit/reference/migrating/v1.md) * [Migrating to v2](safe-core-sdk/protocol-kit/reference/migrating/v2.md) + * [Migrating to v1](safe-core-sdk/protocol-kit/reference/migrating/v1.md) * [Onramp Kit](safe-core-sdk/onramp-kit/README.md) * [Guides](safe-core-sdk/onramp-kit/guides/README.md) @@ -54,8 +54,8 @@ * [API Kit](safe-core-sdk/api-kit/README.md) * [Reference](safe-core-sdk/api-kit/reference/README.md) - * [Migrating to v1](safe-core-sdk/api-kit/reference/migrating/v1.md) * [Migrating to v2](safe-core-sdk/api-kit/reference/migrating/v2.md) + * [Migrating to v1](safe-core-sdk/api-kit/reference/migrating/v1.md) ## Safe{Core} Protocol