This commit is contained in:
poma 2021-02-11 09:23:18 +03:00
parent c6b442713a
commit 346ffcee3c
No known key found for this signature in database
GPG key ID: BA20CB01FE165657
35 changed files with 852 additions and 8943 deletions

16
cli.js
View file

@ -178,7 +178,7 @@ async function generateProof({ deposit, recipient, relayerAddress = 0, fee = 0,
toHex(input.recipient, 20),
toHex(input.relayer, 20),
toHex(input.fee),
toHex(input.refund)
toHex(input.refund),
]
return { proof, args }
@ -265,7 +265,7 @@ function fromDecimals({ amount, decimals }) {
const comps = ether.split('.')
if (comps.length > 2) {
throw new Error(
'[ethjs-unit] while converting number ' + amount + ' to wei, too many decimal points'
'[ethjs-unit] while converting number ' + amount + ' to wei, too many decimal points',
)
}
@ -280,7 +280,7 @@ function fromDecimals({ amount, decimals }) {
}
if (fraction.length > baseLength) {
throw new Error(
'[ethjs-unit] while converting number ' + amount + ' to wei, too many decimal places'
'[ethjs-unit] while converting number ' + amount + ' to wei, too many decimal places',
)
}
@ -417,10 +417,10 @@ async function loadDepositData({ deposit }) {
try {
const eventWhenHappened = await tornado.getPastEvents('Deposit', {
filter: {
commitment: deposit.commitmentHex
commitment: deposit.commitmentHex,
},
fromBlock: 0,
toBlock: 'latest'
toBlock: 'latest',
})
if (eventWhenHappened.length === 0) {
throw new Error('There is no related deposit, the note is invalid')
@ -441,7 +441,7 @@ async function loadWithdrawalData({ amount, currency, deposit }) {
try {
const events = await await tornado.getPastEvents('Withdrawal', {
fromBlock: 0,
toBlock: 'latest'
toBlock: 'latest',
})
const withdrawEvent = events.filter((event) => {
@ -451,7 +451,7 @@ async function loadWithdrawalData({ amount, currency, deposit }) {
const fee = withdrawEvent.returnValues.fee
const decimals = config.deployments[`netId${netId}`][currency].decimals
const withdrawalAmount = toBN(fromDecimals({ amount, decimals })).sub(
toBN(fee)
toBN(fee),
)
const { timestamp } = await web3.eth.getBlock(withdrawEvent.blockHash)
return {
@ -460,7 +460,7 @@ async function loadWithdrawalData({ amount, currency, deposit }) {
to: withdrawEvent.returnValues.to,
timestamp,
nullifier: deposit.nullifierHex,
fee: toDecimals(fee, decimals, 9)
fee: toDecimals(fee, decimals, 9),
}
} catch (e) {
console.error('loadWithdrawalData', e)