|
| 1 | +const hre = require("hardhat"); |
| 2 | +const ethers = hre.ethers; |
| 3 | +import { |
| 4 | + newWalletImpl, |
| 5 | + newWalletFactoryContract |
| 6 | +} from "../test/commons"; |
| 7 | +import { signCreateWallet } from "../test/helper/signatureUtils"; |
| 8 | +import BN = require("bn.js"); |
| 9 | + |
| 10 | +async function newWallet() { |
| 11 | + const smartWalletAddress = "0xE708Cb725D6F2aDeEab2258262Aa9129D2A28312"; |
| 12 | + const walletFactoryAddress = "0x5Dd70df24364DC05D46C8F40611BFDd107927263"; |
| 13 | + |
| 14 | + const ownerAccount = (await ethers.getSigners())[0]; |
| 15 | + const ownerAddr = await ownerAccount.getAddress(); |
| 16 | + const fakeGuardian1 = "0x" + "12".repeat(20); |
| 17 | + const salt = 1; |
| 18 | + const signature = signCreateWallet( |
| 19 | + walletFactoryAddress, |
| 20 | + ownerAddr, |
| 21 | + [fakeGuardian1], |
| 22 | + new BN(0), |
| 23 | + ethers.constants.AddressZero, |
| 24 | + ethers.constants.AddressZero, |
| 25 | + ethers.constants.AddressZero, |
| 26 | + new BN(0), |
| 27 | + salt |
| 28 | + ); |
| 29 | + const walletConfig: any = { |
| 30 | + owner: ownerAddr, |
| 31 | + guardians: [fakeGuardian1], |
| 32 | + quota: 0, |
| 33 | + inheritor: ethers.constants.AddressZero, |
| 34 | + feeRecipient: ethers.constants.AddressZero, |
| 35 | + feeToken: ethers.constants.AddressZero, |
| 36 | + feeAmount: 0, |
| 37 | + signature: Buffer.from(signature.txSignature.slice(2), "hex") |
| 38 | + }; |
| 39 | + |
| 40 | + const walletFactory = await (await ethers.getContractFactory( |
| 41 | + "WalletFactory" |
| 42 | + )).attach(walletFactoryAddress); |
| 43 | + |
| 44 | + const walletAddrComputed = await walletFactory.computeWalletAddress( |
| 45 | + ownerAddr, |
| 46 | + salt |
| 47 | + ); |
| 48 | + console.log("walletAddrcomputed:", walletAddrComputed); |
| 49 | + |
| 50 | + const tx = await walletFactory.createWallet(walletConfig, salt, { gasLimit:10000000 }); |
| 51 | + console.log("tx:", tx); |
| 52 | + const receipt = await tx.wait(); |
| 53 | + console.log("receipt:", receipt); |
| 54 | +} |
| 55 | + |
| 56 | +async function newWalletFactory() { |
| 57 | + const walletFactory = await newWalletFactoryContract(); |
| 58 | + console.log("walletFactory:", walletFactory.address); |
| 59 | +} |
| 60 | + |
| 61 | +// run with: npx hardhat run --network arbitrum scripts/deploy-arbitrum.ts |
| 62 | +async function main() { |
| 63 | + // await newWalletFactory(); |
| 64 | + |
| 65 | + // success tx: |
| 66 | + // https://testnet.bscscan.com/tx/0x9ab2028456c3e432cfb4ee63997b07716b757d9c215e4e96651674b74e473f7c |
| 67 | + await newWallet(); |
| 68 | +} |
| 69 | + |
| 70 | +main() |
| 71 | + .then(() => process.exit(0)) |
| 72 | + .catch(error => { |
| 73 | + console.error(error); |
| 74 | + process.exit(1); |
| 75 | + }); |
0 commit comments