| @@ -13,6 +13,7 @@ import { | |||
| // import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers"; | |||
| import {checkReceipt,checkReceipt2, setProvider,getDeploymentAddresses, | |||
| getElapsed, sleep,getBlockInfo} from '../inc/util' | |||
| import { sign } from "crypto"; | |||
| dotevnv.config(); | |||
| if (!process.env.RPCURL) { | |||
| console.log(`No rpcur value specified...`) | |||
| @@ -100,37 +101,56 @@ async function transfer(signer: Wallet,symbol:string,from: Wallet, to: Wallet, a | |||
| const proxy = getDeploymentAddresses(symbol).address; | |||
| console.log(`토큰 주소 : ${proxy}`); | |||
| const token = new SecurityToken__factory(issuer).attach(proxy) as SecurityToken; | |||
| const decimals = await token.decimals(); | |||
| const digit = 10 ** Number(decimals); | |||
| console.log(`자릿수 = ${digit}`); | |||
| let fb = await getBalance(symbol,from.address); | |||
| let tb = await getBalance(symbol,to.address); | |||
| console.log(`from balance before : ${fb}, to balance before : ${tb}`); | |||
| fb = (1/digit) * fb; | |||
| tb = (1/digit) * tb; | |||
| console.log(`from balance before : ${fb.toFixed(Number(decimals))}, to balance before : ${tb.toFixed(Number(decimals))}`); | |||
| const token = new SecurityToken__factory(issuer).attach(proxy) as SecurityToken; | |||
| await token.connect(admin); | |||
| const ops = await token.operators(); | |||
| console.log(ops); | |||
| // const balance = await token.balanceOf(firstHolder); | |||
| // console.log(balance); | |||
| let signedData = []; | |||
| for(let i = 0; i < count; i++) { | |||
| const rawTx = await getTx(signer.address,symbol,from.address,to.address, amount * digit); | |||
| const tx = Transaction.from(rawTx.data); | |||
| const signed = await signer.signTransaction(tx); | |||
| signedData.push(signed); | |||
| } | |||
| const decimals = await token.decimals(); | |||
| const digit = 10 ** Number(decimals); | |||
| const rawTx = await getTx(signer.address,symbol,firstHolder,to.address, amount * digit); | |||
| const tx = Transaction.from(rawTx.data); | |||
| let proms = []; | |||
| for(let i = 0; i < count; i++) { | |||
| proms.push(send(signedData[i])); | |||
| } | |||
| console.log(tx.nonce); | |||
| let resolved = await Promise.all(proms); | |||
| const signed = await signer.signTransaction(tx); | |||
| const txid = await send(signed); | |||
| console.log(txid); | |||
| resolved.forEach(tx => { | |||
| console.log(tx.data.transactionHash); | |||
| }); | |||
| // for(let i = 0; i < count; i++) { | |||
| // const rawTx = await getTx(signer.address,symbol,from.address,to.address, amount * digit); | |||
| // const tx = Transaction.from(rawTx.data); | |||
| // // console.log(tx.nonce); | |||
| // const signed = await signer.signTransaction(tx); | |||
| // const txid = await send(signed); | |||
| // // console.log(txid); | |||
| // } | |||
| fb = await getBalance(symbol,from.address); | |||
| tb = await getBalance(symbol,to.address); | |||
| console.log(`from balance before : ${fb}, to balance before : ${tb}`); | |||
| fb = (1/digit) * fb; | |||
| tb = (1/digit) * tb; | |||
| console.log(`from balance after : ${fb.toFixed(Number(decimals))}, to balance after : ${tb.toFixed(Number(decimals))}`); | |||
| } | |||
| @@ -154,11 +174,7 @@ async function main() { | |||
| // console.log(issuer); | |||
| // console.log(holder1); | |||
| // console.log(holder2); | |||
| transfer(holder1,'BCG_TEST',holder1, holder2,1, 10); | |||
| // info('BCG_TEST'); | |||
| // getTx('0xf17f52151EbEF6C7334FAD080c5704D77216b732','BCG_TEST','0x2071ec931b2567a1418e9bc34b786d654a079b43',holder1.address,1); | |||
| // getTx2('BCG_TEST'); | |||
| } | |||