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/README.md b/safe-core-sdk/api-kit/README.md index 7efe49e8..6b7a5104 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({ @@ -47,47 +47,53 @@ 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 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' 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' }) ``` ## 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' // Create Safe instance -const safe = await Safe.create({ +const protocolKit = await Safe.create({ ethAdapter, safeAddress: config.SAFE_ADDRESS }) // 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 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, @@ -110,14 +116,14 @@ 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 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 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/api-kit/reference/README.md b/safe-core-sdk/api-kit/reference/README.md index 98cdb596..41b3cefe 100644 --- a/safe-core-sdk/api-kit/reference/README.md +++ b/safe-core-sdk/api-kit/reference/README.md @@ -17,15 +17,15 @@ 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() ``` -### `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 safeApiKit.getServiceSingletonsInfo() ``` ### `decodeData` @@ -33,7 +33,7 @@ const masterCopies: MasterCopyResponse = await safeService.getServiceMasterCopie 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/api-kit/reference/migrating/v2.md b/safe-core-sdk/api-kit/reference/migrating/v2.md new file mode 100644 index 00000000..66458fb8 --- /dev/null +++ b/safe-core-sdk/api-kit/reference/migrating/v2.md @@ -0,0 +1,38 @@ +# API Kit: Migrating from v1 + +This guide references the major changes between v1 and v2 to help those migrating an existing app. + +## API Kit constructor + +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: +constructor({ txServiceUrl, ethAdapter }: SafeApiKitConfig) + +// new: +constructor({ chainId, txServiceUrl? }: SafeApiKitConfig) +``` + +## Use the route you prefer + +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 follows: + +```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 + +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/auth-kit/reference/Web3AuthModalPack.md b/safe-core-sdk/auth-kit/reference/Web3AuthModalPack.md index 72825461..469c5c64 100644 --- a/safe-core-sdk/auth-kit/reference/Web3AuthModalPack.md +++ b/safe-core-sdk/auth-kit/reference/Web3AuthModalPack.md @@ -9,13 +9,13 @@ The `Web3AuthModalPack` enables the use of [Web3Auth modal SDK](https://web3auth To use the `Web3AuthModalPack`, you need to install some extra dependencies in addition to the `@safe-global/auth-kit` package. ```bash -yarn add @safe-global/auth-kit @web3auth/base @web3auth/modal +yarn add @safe-global/auth-kit @web3auth/base@4.6.0 @web3auth/modal@4.6.2 ``` Choose the adapters to use with Web3Auth, and add them. For example, to use the [OpenLogin](https://web3auth.io/docs/sdk/pnp/web/adapters/openlogin) adapter, you must install the following dependency: ```bash -yarn add @web3auth/openlogin-adapter +yarn add @web3auth/openlogin-adapter@4.6.0 ``` Refer to the [supported adapters](https://web3auth.io/docs/sdk/pnp/web/adapters/#currently-available-wallet-adapters) in the official documentation. diff --git a/safe-core-sdk/onramp-kit/reference/MoneriumPack.md b/safe-core-sdk/onramp-kit/reference/MoneriumPack.md index bd01aa58..a0240068 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 @@ -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/onramp-kit/reference/README.md b/safe-core-sdk/onramp-kit/reference/README.md index acf05bd1..26e59ecb 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 019be1a6..d0da795e 100644 --- a/safe-core-sdk/protocol-kit/README.md +++ b/safe-core-sdk/protocol-kit/README.md @@ -11,20 +11,20 @@ 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 -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). -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.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. ```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 @@ -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' @@ -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) @@ -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 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). ```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 @@ -146,7 +154,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, @@ -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.utils.parseUnits('0.005', 'ether').toString() +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 @@ -232,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. @@ -275,7 +283,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/protocol-kit/reference/README.md b/safe-core-sdk/protocol-kit/reference/README.md index ed4d131d..173323ac 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() @@ -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,90 +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 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. +When the array contains only one transaction, it's not wrapped in the MultiSend. - ```typescript - import { SafeTransactionDataPartial } from '@safe-global/safe-core-sdk-types' - - const safeTransactionData: SafeTransactionDataPartial = { +```typescript +const transactions: MetaTransactionData[] = [ + { + to, + data, + value, + operation // Optional + }, + { to, data, value, - operation, // Optional - safeTxGas, // Optional - baseGas, // Optional - gasPrice, // Optional - gasToken, // Optional - refundReceiver, // Optional - nonce // Optional + operation // 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. - - ```typescript - const safeTransactionData: MetaTransactionData[] = [ - { - to, - data, - value, - operation // Optional - }, - { - to, - data, - value, - operation // Optional - } - // ... - ] - 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: +This method can also receive the `options` parameter to set the optional properties in the MultiSend transaction: - ```typescript - const safeTransactionData: 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({ safeTransactionData, 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({ - safeTransactionData, - 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: @@ -474,10 +452,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 +464,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 +473,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 +485,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 +498,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 +510,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 +532,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 +574,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 +783,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 +823,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() ``` diff --git a/safe-core-sdk/protocol-kit/reference/migrating/v2.md b/safe-core-sdk/protocol-kit/reference/migrating/v2.md new file mode 100644 index 00000000..5348835e --- /dev/null +++ b/safe-core-sdk/protocol-kit/reference/migrating/v2.md @@ -0,0 +1,48 @@ +# Protocol Kit: Migrating from v1 + +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 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 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 `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: +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/guides/gelato.md b/safe-core-sdk/relay-kit/guides/gelato.md index 49afcc9d..978d7151 100644 --- a/safe-core-sdk/relay-kit/guides/gelato.md +++ b/safe-core-sdk/relay-kit/guides/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 @@ -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}`) ``` @@ -143,13 +142,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 @@ -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}`) ``` diff --git a/safe-core-sdk/relay-kit/reference/migrating/v2.md b/safe-core-sdk/relay-kit/reference/migrating/v2.md new file mode 100644 index 00000000..31407513 --- /dev/null +++ b/safe-core-sdk/relay-kit/reference/migrating/v2.md @@ -0,0 +1,15 @@ +# Relay Kit: Migrating from v1 + +This guide references the major changes between v1 and v2 to help those migrating an existing app. + +## GelatoRelayPack + +- 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 the `createTransactionWithHandlePayment()`, `createTransactionWithTransfer()`, and `executeRelayTransaction()` methods in the `GelatoRelayPack` as now it's included in the constructor. + +- Removed the `export interface RelayPack` type as we now use an abstract class. \ No newline at end of file