Skip to content

Commit

Permalink
revert unnecessary Viem changes in api-kit playground
Browse files Browse the repository at this point in the history
  • Loading branch information
dasanra committed Aug 8, 2024
1 parent eeeeb84 commit 4dc89f1
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 44 deletions.
12 changes: 6 additions & 6 deletions playground/api-kit/confirm-transaction.ts
Original file line number Diff line number Diff line change
@@ -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: '<SIGNER_ADDRESS_PRIVATE_KEY>',
SAFE_ADDRESS: '<SAFE_ADDRESS>',
SAFE_TX_HASH: '<SAFE_TX_HASH>'
Expand All @@ -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
Expand Down
13 changes: 7 additions & 6 deletions playground/api-kit/execute-transaction.ts
Original file line number Diff line number Diff line change
@@ -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: '<SIGNER_ADDRESS_PRIVATE_KEY>',
SAFE_ADDRESS: '<SAFE_ADDRESS>',
SAFE_TX_HASH: '<SAFE_TX_HASH>'
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions playground/api-kit/propose-transaction.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
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'

// 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: '<SIGNER_ADDRESS_PRIVATE_KEY>',
SAFE_ADDRESS: '<SAFE_ADDRESS>'
}

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
Expand Down
4 changes: 2 additions & 2 deletions playground/relay-kit/paid-transaction.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions playground/relay-kit/sponsored-transaction.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions playground/relay-kit/usdc-transfer-4337-counterfactual.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)

Expand Down
3 changes: 1 addition & 2 deletions playground/relay-kit/usdc-transfer-4337-erc20.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -46,7 +41,6 @@ async function main() {
paymasterOptions: {
isSponsored: true,
sponsorshipPolicyId: POLICY_ID,
paymasterAddress,
paymasterUrl: PAYMASTER_URL
},
options: {
Expand All @@ -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)

Expand Down
8 changes: 1 addition & 7 deletions playground/relay-kit/usdc-transfer-4337-sponsored.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -46,7 +41,6 @@ async function main() {
paymasterOptions: {
isSponsored: true,
paymasterUrl: PAYMASTER_URL,
paymasterAddress,
sponsorshipPolicyId: POLICY_ID
},
options: {
Expand All @@ -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

Expand Down
3 changes: 1 addition & 2 deletions playground/relay-kit/usdc-transfer-4337.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 4dc89f1

Please sign in to comment.