-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PRO-1991-Manual CallDataLimit Override (#88)
- Loading branch information
1 parent
9729b6c
commit 1934acb
Showing
7 changed files
with
95 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { ethers } from 'ethers'; | ||
import { PrimeSdk } from '../src'; | ||
import { printOp } from '../src/sdk/common/OperationUtils'; | ||
import * as dotenv from 'dotenv'; | ||
import { sleep } from '../src/sdk/common'; | ||
|
||
dotenv.config(); | ||
|
||
const recipient = '0x80a1874E1046B1cc5deFdf4D3153838B72fF94Ac'; // recipient wallet address | ||
const value = '0.0001'; // transfer value | ||
|
||
async function main() { | ||
// initializating sdk... | ||
const primeSdk = new PrimeSdk({ privateKey: process.env.WALLET_PRIVATE_KEY }, { chainId: Number(process.env.CHAIN_ID), projectKey: 'public-prime-testnet-key' }) | ||
|
||
console.log('address: ', primeSdk.state.walletAddress) | ||
|
||
// get address of EtherspotWallet... | ||
const address: string = await primeSdk.getCounterFactualAddress(); | ||
console.log('\x1b[33m%s\x1b[0m', `EtherspotWallet address: ${address}`); | ||
|
||
// clear the transaction batch | ||
await primeSdk.clearUserOpsFromBatch(); | ||
|
||
// add transactions to the batch | ||
const transactionBatch = await primeSdk.addUserOpsToBatch({to: recipient, value: ethers.utils.parseEther(value)}); | ||
console.log('transactions: ', transactionBatch); | ||
|
||
// get balance of the account address | ||
const balance = await primeSdk.getNativeBalance(); | ||
|
||
console.log('balances: ', balance); | ||
|
||
// estimate transactions added to the batch and get the fee data for the UserOp | ||
// passing callGasLimit as 40000 to manually set it | ||
const op = await primeSdk.estimate(null, null, 40000); | ||
console.log(`Estimate UserOp: ${await printOp(op)}`); | ||
|
||
// sign the UserOp and sending to the bundler... | ||
const uoHash = await primeSdk.send(op); | ||
console.log(`UserOpHash: ${uoHash}`); | ||
|
||
// get transaction hash... | ||
console.log('Waiting for transaction...'); | ||
let userOpsReceipt = null; | ||
const timeout = Date.now() + 60000; // 1 minute timeout | ||
while((userOpsReceipt == null) && (Date.now() < timeout)) { | ||
await sleep(2); | ||
userOpsReceipt = await primeSdk.getUserOpReceipt(uoHash); | ||
} | ||
console.log('\x1b[33m%s\x1b[0m', `Transaction Receipt: `, userOpsReceipt); | ||
} | ||
|
||
main() | ||
.catch(console.error) | ||
.finally(() => process.exit()); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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