Skip to content

Commit

Permalink
Update playgrounds
Browse files Browse the repository at this point in the history
  • Loading branch information
yagopv committed Sep 13, 2023
1 parent cf72552 commit 2a2a2d4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
26 changes: 15 additions & 11 deletions playground/relay-kit/paid-transaction.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import AccountAbstraction, {
AccountAbstractionConfig
} from '@safe-global/account-abstraction-kit-poc'
import AccountAbstraction from '@safe-global/account-abstraction-kit-poc'
import { GelatoRelayPack } from '@safe-global/relay-kit'
import {
MetaTransactionData,
MetaTransactionOptions,
OperationType
} from '@safe-global/safe-core-sdk-types'
import { EthersAdapter } from '@safe-global/protocol-kit'

import { BigNumber, ethers } from 'ethers'

// Check the status of a transaction after it is relayed:
Expand Down Expand Up @@ -42,20 +42,24 @@ async function main() {
const provider = new ethers.providers.JsonRpcProvider(config.RPC_URL)
const signer = new ethers.Wallet(config.SAFE_SIGNER_PRIVATE_KEY, provider)

const relayPack = new GelatoRelayPack()
const safeAccountAbstraction = new AccountAbstraction(
new EthersAdapter({
ethers,
signerOrProvider: signer
})
)

const safeSdk = await safeAccountAbstraction.init()
const relayPack = new GelatoRelayPack({ safeSdk })

const safeAccountAbstraction = new AccountAbstraction(signer)
const sdkConfig: AccountAbstractionConfig = {
relayPack
}
await safeAccountAbstraction.init(sdkConfig)
safeAccountAbstraction.setRelayPack(relayPack)

// Calculate Safe address

const predictedSafeAddress = safeAccountAbstraction.getSafeAddress()
const predictedSafeAddress = await safeSdk.getAddress()
console.log({ predictedSafeAddress })

const isSafeDeployed = await safeAccountAbstraction.isSafeDeployed()
const isSafeDeployed = await safeSdk.isSafeDeployed()
console.log({ isSafeDeployed })

// Fake on-ramp to transfer enough funds to the Safe address
Expand Down
22 changes: 14 additions & 8 deletions playground/relay-kit/sponsored-transaction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import AccountAbstraction, {
AccountAbstractionConfig
} from '@safe-global/account-abstraction-kit-poc'
import { EthersAdapter } from '@safe-global/protocol-kit'
import { GelatoRelayPack } from '@safe-global/relay-kit'
import {
MetaTransactionData,
Expand Down Expand Up @@ -43,20 +44,25 @@ async function main() {
const provider = new ethers.providers.JsonRpcProvider(config.RPC_URL)
const signer = new ethers.Wallet(config.SAFE_SIGNER_PRIVATE_KEY, provider)

const relayPack = new GelatoRelayPack(config.RELAY_API_KEY)
const safeAccountAbstraction = new AccountAbstraction(
new EthersAdapter({
ethers,
signerOrProvider: signer
})
)

const safeAccountAbstraction = new AccountAbstraction(signer)
const sdkConfig: AccountAbstractionConfig = {
relayPack
}
await safeAccountAbstraction.init(sdkConfig)
const safeSdk = await safeAccountAbstraction.init()

safeAccountAbstraction.setRelayPack(
new GelatoRelayPack({ apiKey: config.RELAY_API_KEY, safeSdk })
)

// Calculate Safe address

const predictedSafeAddress = safeAccountAbstraction.getSafeAddress()
const predictedSafeAddress = await safeSdk.getAddress()
console.log({ predictedSafeAddress })

const isSafeDeployed = await safeAccountAbstraction.isSafeDeployed()
const isSafeDeployed = await safeSdk.isSafeDeployed()
console.log({ isSafeDeployed })

// Fake on-ramp to fund the Safe
Expand Down

0 comments on commit 2a2a2d4

Please sign in to comment.