-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revert unnecessary Viem changes in api-kit playground
- Loading branch information
Showing
5 changed files
with
166 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { ethers } from 'ethers' | ||
import { GelatoRelayPack } from '@safe-global/relay-kit' | ||
import Safe, { EthersAdapter } from '@safe-global/protocol-kit' | ||
import { MetaTransactionData } from '@safe-global/safe-core-sdk-types' | ||
|
||
// Check the status of a transaction after it is relayed: | ||
// https://relay.gelato.digital/tasks/status/<TASK_ID> | ||
|
||
// Check the status of a transaction after it is executed: | ||
// https://goerli.etherscan.io/tx/<TRANSACTION_HASH> | ||
const config = { | ||
SAFE_SIGNER_PRIVATE_KEY: process.env.DEV_MNEM as string, // '<SAFE_SIGNER_PRIVATE_KEY>', | ||
RPC_URL: `https://goerli.infura.io/v3/${process.env.INF_API as string}` | ||
} | ||
|
||
// const mockOnRampConfig = { | ||
// ADDRESS: '<ADDRESS>', | ||
// PRIVATE_KEY: '<PRIVATE_KEY>' | ||
// } | ||
|
||
// const txConfig = { | ||
// TO: '<TO>', | ||
// DATA: '<DATA>', | ||
// VALUE: '<VALUE>', | ||
// // Options: | ||
// GAS_LIMIT: BigNumber.from('<GAS_LIMIT>'), | ||
// GAS_TOKEN: ethers.constants.AddressZero | ||
// } | ||
|
||
async function main() { | ||
console.log('Create meta-transaction via Gelato Relay paid with balance in the Safe') | ||
|
||
// SDK Initialization | ||
const provider = new ethers.JsonRpcProvider(config.RPC_URL) | ||
const signer = new ethers.Wallet(config.SAFE_SIGNER_PRIVATE_KEY, provider) | ||
|
||
const transactions: MetaTransactionData[] = [ | ||
{ | ||
to: '0x883d9e75479c5064636984f592e9d2a110a27106', | ||
data: '0x', | ||
value: '10000000000000000' | ||
} | ||
] | ||
|
||
const ethAdapter = new EthersAdapter({ | ||
ethers, | ||
signerOrProvider: signer | ||
}) | ||
|
||
const protocolKit: Safe = await Safe.create({ | ||
ethAdapter, | ||
safeAddress: '0x883d9e75479c5064636984f592e9d2a110a27106' | ||
}) | ||
|
||
const relayKit = new GelatoRelayPack({ protocolKit }) | ||
|
||
const safeTransaction = await relayKit.createRelayedTransaction({ transactions }) | ||
|
||
console.log(safeTransaction) | ||
|
||
const signedSafeTransaction = await protocolKit.signTransaction(safeTransaction) | ||
|
||
const response = await relayKit.executeRelayTransaction(signedSafeTransaction) | ||
|
||
console.log( | ||
`Relay Transaction Task ID: https://relay.gelato.digital/tasks/status/${response.taskId}` | ||
) | ||
return response.taskId | ||
} | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { ethers } from 'ethers' | ||
import { GelatoRelayPack } from '@safe-global/relay-kit' | ||
import Safe, { EthersAdapter } from '@safe-global/protocol-kit' | ||
import { MetaTransactionData, MetaTransactionOptions } from '@safe-global/safe-core-sdk-types' | ||
|
||
// Check the status of a transaction after it is relayed: | ||
// https://relay.gelato.digital/tasks/status/<TASK_ID> | ||
|
||
// Check the status of a transaction after it is executed: | ||
// https://goerli.etherscan.io/tx/<TRANSACTION_HASH> | ||
const config = { | ||
SAFE_SIGNER_PRIVATE_KEY: process.env.DEV_MNEM as string, // '<SAFE_SIGNER_PRIVATE_KEY>', | ||
RPC_URL: `https://goerli.infura.io/v3/${process.env.INF_API as string}` | ||
} | ||
|
||
// const mockOnRampConfig = { | ||
// ADDRESS: '<ADDRESS>', | ||
// PRIVATE_KEY: '<PRIVATE_KEY>' | ||
// } | ||
|
||
// const txConfig = { | ||
// TO: '<TO>', | ||
// DATA: '<DATA>', | ||
// VALUE: '<VALUE>', | ||
// // Options: | ||
// GAS_LIMIT: BigNumber.from('<GAS_LIMIT>'), | ||
// GAS_TOKEN: ethers.constants.AddressZero | ||
// } | ||
|
||
async function main() { | ||
console.log('Execute meta-transaction via Gelato Relay paid by 1Balance') | ||
|
||
// SDK Initialization | ||
const provider = new ethers.JsonRpcProvider(config.RPC_URL) | ||
const signer = new ethers.Wallet(config.SAFE_SIGNER_PRIVATE_KEY, provider) | ||
const ethAdapter = new EthersAdapter({ | ||
ethers, | ||
signerOrProvider: signer | ||
}) | ||
|
||
const protocolKit = await Safe.create({ | ||
ethAdapter, | ||
safeAddress: '0x883d9e75479c5064636984f592e9d2a110a27106' | ||
}) | ||
|
||
const relayKit = new GelatoRelayPack({ protocolKit }) | ||
|
||
const transactions: MetaTransactionData[] = [ | ||
{ | ||
to: '0x883d9e75479c5064636984f592e9d2a110a27106', | ||
data: '0x', | ||
value: '10000000000000000' | ||
} | ||
] | ||
const options: MetaTransactionOptions = { | ||
isSponsored: true | ||
} | ||
|
||
const safeTransaction = await relayKit.createRelayedTransaction({ | ||
transactions, | ||
options | ||
}) | ||
|
||
console.log(safeTransaction) | ||
|
||
const signedSafeTransaction = await protocolKit.signTransaction(safeTransaction) | ||
|
||
const response = await relayKit.executeRelayTransaction(signedSafeTransaction, options) | ||
|
||
console.log( | ||
`Relay Transaction Task ID: https://relay.gelato.digital/tasks/status/${response.taskId}` | ||
) | ||
return response.taskId | ||
} | ||
|
||
main() |