Skip to content

Commit

Permalink
fix: Update blob verifier injection pattern - bring back _getPrescale…
Browse files Browse the repository at this point in the history
…dAmount function
  • Loading branch information
epociask committed Nov 21, 2024
1 parent a2de1c3 commit 2bddc8f
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion scripts/rollupCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { run } from 'hardhat'
import { abi as rollupCreatorAbi } from '../build/contracts/src/rollup/RollupCreator.sol/RollupCreator.json'
import { config, maxDataSize } from './config'
import { BigNumber, Signer } from 'ethers'
import { IERC20__factory } from '../build/types'
import { ERC20, ERC20__factory, IERC20__factory } from '../build/types'
import { sleep } from './testSetup'
import { promises as fs } from 'fs'
import { _isRunningOnArbitrum } from './deploymentUtils'
Expand Down Expand Up @@ -349,4 +349,26 @@ async function _getDevRollupConfig(
nonce: nonceHex,
})
}
}

async function _getPrescaledAmount(
nativeToken: ERC20,
amount: BigNumber
): Promise<BigNumber> {
const decimals = BigNumber.from(await nativeToken.decimals())
if (decimals.lt(BigNumber.from(18))) {
const scalingFactor = BigNumber.from(10).pow(
BigNumber.from(18).sub(decimals)
)
let prescaledAmount = amount.div(scalingFactor)
// round up if needed
if (prescaledAmount.mul(scalingFactor).lt(amount)) {
prescaledAmount = prescaledAmount.add(BigNumber.from(1))
}
return prescaledAmount
} else if (decimals.gt(BigNumber.from(18))) {
return amount.mul(BigNumber.from(10).pow(decimals.sub(BigNumber.from(18))))
}

return amount
}

0 comments on commit 2bddc8f

Please sign in to comment.