From 4dc89f1f84e57d7e1c77db2d96b7d180d3a91a66 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:49:35 +0200 Subject: [PATCH] revert unnecessary Viem changes in api-kit playground --- playground/api-kit/confirm-transaction.ts | 12 ++++++------ playground/api-kit/execute-transaction.ts | 13 +++++++------ playground/api-kit/propose-transaction.ts | 12 ++++++------ playground/relay-kit/paid-transaction.ts | 4 ++-- playground/relay-kit/sponsored-transaction.ts | 4 ++-- .../relay-kit/usdc-transfer-4337-counterfactual.ts | 4 ++-- .../usdc-transfer-4337-erc20-counterfactual.ts | 3 +-- playground/relay-kit/usdc-transfer-4337-erc20.ts | 3 +-- .../usdc-transfer-4337-sponsored-counterfactual.ts | 8 +------- .../relay-kit/usdc-transfer-4337-sponsored.ts | 8 +------- playground/relay-kit/usdc-transfer-4337.ts | 3 +-- 11 files changed, 30 insertions(+), 44 deletions(-) diff --git a/playground/api-kit/confirm-transaction.ts b/playground/api-kit/confirm-transaction.ts index 876fd5845..14a4fead3 100644 --- a/playground/api-kit/confirm-transaction.ts +++ b/playground/api-kit/confirm-transaction.ts @@ -1,19 +1,19 @@ -import { Chain } from 'viem' -import { sepolia } from 'viem/chains' import Safe from '@safe-global/protocol-kit' import SafeApiKit from '@safe-global/api-kit' // This file can be used to play around with the Safe Core SDK interface Config { - CHAIN: Chain + CHAIN_ID: bigint + RPC_URL: string SIGNER_ADDRESS_PRIVATE_KEY: string SAFE_ADDRESS: string SAFE_TX_HASH: string } const config: Config = { - CHAIN: sepolia, + CHAIN_ID: 11155111n, + RPC_URL: 'https://sepolia.gateway.tenderly.co', SIGNER_ADDRESS_PRIVATE_KEY: '', SAFE_ADDRESS: '', SAFE_TX_HASH: '' @@ -22,14 +22,14 @@ const config: Config = { async function main() { // Create Safe instance const protocolKit = await Safe.init({ - provider: config.CHAIN.rpcUrls.default.http[0], + provider: config.RPC_URL, signer: config.SIGNER_ADDRESS_PRIVATE_KEY, safeAddress: config.SAFE_ADDRESS }) // Create Safe API Kit instance const apiKit = new SafeApiKit({ - chainId: BigInt(config.CHAIN.id) + chainId: config.CHAIN_ID }) // Get the transaction diff --git a/playground/api-kit/execute-transaction.ts b/playground/api-kit/execute-transaction.ts index 9ed1c78c8..ace08f7d4 100644 --- a/playground/api-kit/execute-transaction.ts +++ b/playground/api-kit/execute-transaction.ts @@ -1,20 +1,21 @@ -import { Chain, Hash } from 'viem' +import { Hash } from 'viem' import { waitForTransactionReceipt } from 'viem/actions' -import { sepolia } from 'viem/chains' import Safe from '@safe-global/protocol-kit' import SafeApiKit from '@safe-global/api-kit' // This file can be used to play around with the Safe Core SDK interface Config { - CHAIN: Chain + CHAIN_ID: bigint + RPC_URL: string SIGNER_ADDRESS_PRIVATE_KEY: string SAFE_ADDRESS: string SAFE_TX_HASH: string } const config: Config = { - CHAIN: sepolia, + CHAIN_ID: 11155111n, + RPC_URL: 'https://sepolia.gateway.tenderly.co', SIGNER_ADDRESS_PRIVATE_KEY: '', SAFE_ADDRESS: '', SAFE_TX_HASH: '' @@ -23,14 +24,14 @@ const config: Config = { async function main() { // Create Safe instance const protocolKit = await Safe.init({ - provider: config.CHAIN.rpcUrls.default.http[0], + provider: config.RPC_URL, signer: config.SIGNER_ADDRESS_PRIVATE_KEY, safeAddress: config.SAFE_ADDRESS }) // Create Safe API Kit instance const apiKit = new SafeApiKit({ - chainId: BigInt(config.CHAIN.id) + chainId: config.CHAIN_ID }) // Get the transaction diff --git a/playground/api-kit/propose-transaction.ts b/playground/api-kit/propose-transaction.ts index 8acb986eb..f2f3ca7c5 100644 --- a/playground/api-kit/propose-transaction.ts +++ b/playground/api-kit/propose-transaction.ts @@ -1,5 +1,3 @@ -import { Chain } from 'viem' -import { sepolia } from 'viem/chains' import Safe from '@safe-global/protocol-kit' import SafeApiKit from '@safe-global/api-kit' import { OperationType, SafeTransactionDataPartial } from '@safe-global/safe-core-sdk-types' @@ -7,13 +5,15 @@ import { OperationType, SafeTransactionDataPartial } from '@safe-global/safe-cor // This file can be used to play around with the Safe Core SDK interface Config { - CHAIN: Chain + CHAIN_ID: bigint + RPC_URL: string SIGNER_ADDRESS_PRIVATE_KEY: string SAFE_ADDRESS: string } const config: Config = { - CHAIN: sepolia, + CHAIN_ID: 11155111n, + RPC_URL: 'https://sepolia.gateway.tenderly.co', SIGNER_ADDRESS_PRIVATE_KEY: '', SAFE_ADDRESS: '' } @@ -21,14 +21,14 @@ const config: Config = { async function main() { // Create Safe instance const protocolKit = await Safe.init({ - provider: config.CHAIN.rpcUrls.default.http[0], + provider: config.RPC_URL, signer: config.SIGNER_ADDRESS_PRIVATE_KEY, safeAddress: config.SAFE_ADDRESS }) // Create Safe API Kit instance const apiKit = new SafeApiKit({ - chainId: BigInt(config.CHAIN.id) + chainId: config.CHAIN_ID }) // Create transaction diff --git a/playground/relay-kit/paid-transaction.ts b/playground/relay-kit/paid-transaction.ts index 210c1f518..bb28861c1 100644 --- a/playground/relay-kit/paid-transaction.ts +++ b/playground/relay-kit/paid-transaction.ts @@ -1,4 +1,4 @@ -import { Address, Chain, formatEther, createWalletClient, custom, Hex } from 'viem' +import { Chain, formatEther, createWalletClient, custom, Hex } from 'viem' import { sepolia } from 'viem/chains' import { getBalance, waitForTransactionReceipt } from 'viem/actions' import { privateKeyToAccount } from 'viem/accounts' @@ -76,7 +76,7 @@ async function main() { }) // Calculate Safe address - const predictedSafeAddress = (await gelatoSafeClient.protocolKit.getAddress()) + const predictedSafeAddress = await gelatoSafeClient.protocolKit.getAddress() console.log({ predictedSafeAddress }) const isSafeDeployed = await gelatoSafeClient.protocolKit.isSafeDeployed() diff --git a/playground/relay-kit/sponsored-transaction.ts b/playground/relay-kit/sponsored-transaction.ts index 469fa7510..4573aafb2 100644 --- a/playground/relay-kit/sponsored-transaction.ts +++ b/playground/relay-kit/sponsored-transaction.ts @@ -1,4 +1,4 @@ -import { Address, Chain, createWalletClient, custom, formatEther, Hex } from 'viem' +import { Chain, createWalletClient, custom, formatEther, Hex } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { getBalance, waitForTransactionReceipt } from 'viem/actions' import { sepolia } from 'viem/chains' @@ -78,7 +78,7 @@ async function main() { // Calculate Safe address - const predictedSafeAddress = (await gelatoSafeClient.protocolKit.getAddress()) + const predictedSafeAddress = await gelatoSafeClient.protocolKit.getAddress() console.log({ predictedSafeAddress }) const isSafeDeployed = await gelatoSafeClient.protocolKit.isSafeDeployed() diff --git a/playground/relay-kit/usdc-transfer-4337-counterfactual.ts b/playground/relay-kit/usdc-transfer-4337-counterfactual.ts index 32df5af15..28bcd026f 100644 --- a/playground/relay-kit/usdc-transfer-4337-counterfactual.ts +++ b/playground/relay-kit/usdc-transfer-4337-counterfactual.ts @@ -1,4 +1,4 @@ -import { parseEther, Address } from 'viem' +import { parseEther } from 'viem' import { getBlock, waitForTransactionReceipt } from 'viem/actions' import { sepolia } from 'viem/chains' import { Safe4337Pack } from '@safe-global/relay-kit' @@ -45,7 +45,7 @@ async function main() { console.log('Supported Entry Points', await safe4337Pack.getSupportedEntryPoints()) console.log('Chain Id', await safe4337Pack.getChainId()) - const senderAddress = (await safe4337Pack.protocolKit.getAddress()) + const senderAddress = await safe4337Pack.protocolKit.getAddress() console.log('senderAddress: ', senderAddress) diff --git a/playground/relay-kit/usdc-transfer-4337-erc20-counterfactual.ts b/playground/relay-kit/usdc-transfer-4337-erc20-counterfactual.ts index 82a6fe59f..974f4eff8 100644 --- a/playground/relay-kit/usdc-transfer-4337-erc20-counterfactual.ts +++ b/playground/relay-kit/usdc-transfer-4337-erc20-counterfactual.ts @@ -1,4 +1,3 @@ -import { Address } from 'viem' import { getBlock } from 'viem/actions' import { Safe4337Pack } from '@safe-global/relay-kit' import { waitForOperationToFinish, transfer, generateTransferCallData } from '../utils' @@ -54,7 +53,7 @@ async function main() { console.log('Chain Id', await safe4337Pack.getChainId()) // Create transaction batch with two 0.1 USDC transfers - const senderAddress = (await safe4337Pack.protocolKit.getAddress()) + const senderAddress = await safe4337Pack.protocolKit.getAddress() console.log('senderAddress: ', senderAddress) diff --git a/playground/relay-kit/usdc-transfer-4337-erc20.ts b/playground/relay-kit/usdc-transfer-4337-erc20.ts index 104312d17..5f54a2db0 100644 --- a/playground/relay-kit/usdc-transfer-4337-erc20.ts +++ b/playground/relay-kit/usdc-transfer-4337-erc20.ts @@ -1,4 +1,3 @@ -import { Address } from 'viem' import { getBlock } from 'viem/actions' import { Safe4337Pack } from '@safe-global/relay-kit' import { waitForOperationToFinish, transfer, generateTransferCallData } from '../utils' @@ -52,7 +51,7 @@ async function main() { console.log('Chain Id', await safe4337Pack.getChainId()) // Create transaction batch with two 0.1 USDC transfers - const senderAddress = (await safe4337Pack.protocolKit.getAddress()) + const senderAddress = await safe4337Pack.protocolKit.getAddress() const usdcAmount = 100_000n // 0.1 USDC diff --git a/playground/relay-kit/usdc-transfer-4337-sponsored-counterfactual.ts b/playground/relay-kit/usdc-transfer-4337-sponsored-counterfactual.ts index de1477784..abf437791 100644 --- a/playground/relay-kit/usdc-transfer-4337-sponsored-counterfactual.ts +++ b/playground/relay-kit/usdc-transfer-4337-sponsored-counterfactual.ts @@ -1,4 +1,3 @@ -import { Address } from 'viem' import { getBlock } from 'viem/actions' import { Safe4337Pack } from '@safe-global/relay-kit' import { waitForOperationToFinish, transfer, generateTransferCallData } from '../utils' @@ -28,10 +27,6 @@ const BUNDLER_URL = `https://api.pimlico.io/v2/${CHAIN_NAME}/rpc?apikey=${PIMLIC // Paymaster URL const PAYMASTER_URL = `https://api.pimlico.io/v2/${CHAIN_NAME}/rpc?apikey=${PIMLICO_API_KEY}` // PIMLICO -// PAYMASTER ADDRESS -const paymasterAddress = '0x0000000000325602a77416A16136FDafd04b299f' // SEPOLIA -// const paymasterAddress = '0x000000000034B78bfe02Be30AE4D324c8702803d' // GNOSIS - // USDC CONTRACT ADDRESS IN SEPOLIA // faucet: https://faucet.circle.com/ const usdcTokenAddress = '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238' // SEPOLIA @@ -46,7 +41,6 @@ async function main() { paymasterOptions: { isSponsored: true, sponsorshipPolicyId: POLICY_ID, - paymasterAddress, paymasterUrl: PAYMASTER_URL }, options: { @@ -61,7 +55,7 @@ async function main() { console.log('Chain Id', await safe4337Pack.getChainId()) // Create transaction batch with two 0.1 USDC transfers - const senderAddress = (await safe4337Pack.protocolKit.getAddress()) + const senderAddress = await safe4337Pack.protocolKit.getAddress() console.log('senderAddress: ', senderAddress) diff --git a/playground/relay-kit/usdc-transfer-4337-sponsored.ts b/playground/relay-kit/usdc-transfer-4337-sponsored.ts index df02d80a6..82c1b6298 100644 --- a/playground/relay-kit/usdc-transfer-4337-sponsored.ts +++ b/playground/relay-kit/usdc-transfer-4337-sponsored.ts @@ -1,4 +1,3 @@ -import { Address } from 'viem' import { getBlock } from 'viem/actions' import { Safe4337Pack } from '@safe-global/relay-kit' import { generateTransferCallData, waitForOperationToFinish } from '../utils' @@ -28,10 +27,6 @@ const BUNDLER_URL = `https://api.pimlico.io/v2/${CHAIN_NAME}/rpc?apikey=${PIMLIC // Paymaster URL const PAYMASTER_URL = `https://api.pimlico.io/v2/${CHAIN_NAME}/rpc?apikey=${PIMLICO_API_KEY}` // PIMLICO -// PAYMASTER ADDRESS -const paymasterAddress = '0x0000000000325602a77416A16136FDafd04b299f' // SEPOLIA -// const paymasterAddress = '0x000000000034B78bfe02Be30AE4D324c8702803d' // GNOSIS - // USDC CONTRACT ADDRESS IN SEPOLIA // faucet: https://faucet.circle.com/ const usdcTokenAddress = '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238' // SEPOLIA @@ -46,7 +41,6 @@ async function main() { paymasterOptions: { isSponsored: true, paymasterUrl: PAYMASTER_URL, - paymasterAddress, sponsorshipPolicyId: POLICY_ID }, options: { @@ -59,7 +53,7 @@ async function main() { console.log('Chain Id', await safe4337Pack.getChainId()) // Create transaction batch with two 0.1 USDC transfers - const senderAddress = (await safe4337Pack.protocolKit.getAddress()) + const senderAddress = await safe4337Pack.protocolKit.getAddress() const usdcAmount = 100_000n // 0.1 USDC diff --git a/playground/relay-kit/usdc-transfer-4337.ts b/playground/relay-kit/usdc-transfer-4337.ts index fb6b6bda4..3b56e313e 100644 --- a/playground/relay-kit/usdc-transfer-4337.ts +++ b/playground/relay-kit/usdc-transfer-4337.ts @@ -1,4 +1,3 @@ -import { Address } from 'viem' import { getBlock } from 'viem/actions' import { Safe4337Pack } from '@safe-global/relay-kit' import { generateTransferCallData, waitForOperationToFinish } from '../utils' @@ -39,7 +38,7 @@ async function main() { console.log('Chain Id', await safe4337Pack.getChainId()) // Create transaction batch with two 0.1 USDC transfers - const senderAddress = (await safe4337Pack.protocolKit.getAddress()) + const senderAddress = await safe4337Pack.protocolKit.getAddress() const usdcAmount = 100_000n // 0.1 USDC