diff --git a/cli/lib/nf3.mjs b/cli/lib/nf3.mjs index e9257d3a1..cc19eaba4 100644 --- a/cli/lib/nf3.mjs +++ b/cli/lib/nf3.mjs @@ -380,6 +380,7 @@ class Nf3 { !!this.ethereumSigningKey, ); } catch (err) { + logger.error(`Approve transaction failed`); throw new Error(err); } if (txDataToSign) { @@ -406,6 +407,7 @@ class Nf3 { ); resolve(receipt); } catch (err) { + logger.error('Deposit transaction failed'); reject(err); } }); diff --git a/config/default.js b/config/default.js index 00c6ec071..01628ba9e 100644 --- a/config/default.js +++ b/config/default.js @@ -327,7 +327,7 @@ module.exports = { development: [ { name: 'ERC20Mock', - address: '0xB5Acbe9a0F1F8B98F3fC04471F7fE5d2c222cB44', + address: '0x470556dE5865D293dCcc0b47644fac7721168065', amount: '100000000000', }, { diff --git a/nightfall-deployer/migrations/2_deploy_upgradeable.js b/nightfall-deployer/migrations/2_deploy_upgradeable.js index 3290277d2..3b82ab3f0 100644 --- a/nightfall-deployer/migrations/2_deploy_upgradeable.js +++ b/nightfall-deployer/migrations/2_deploy_upgradeable.js @@ -45,6 +45,7 @@ module.exports = async function (deployer) { const restrictions = await Shield.deployed(); // restrict transfer amounts for (let token of RESTRICTIONS.tokens[process.env.ETH_NETWORK]) { + if (token.name = 'ERC20Mock') break; // ignore test tokens, they're already handled in the test_tokens migration console.log(`Max allowed deposit value for ${token.name}: ${(BigInt(token.amount) / BigInt(4)).toString()}`); // BigInt division returns whole number which is a floor. Not Math.floor() needed console.log(`Max allowed withdraw value for ${token.name}: ${token.amount}`); await restrictions.setRestriction(token.address, (BigInt(token.amount) / BigInt(4)).toString(), token.amount); diff --git a/nightfall-deployer/migrations/3_test_tokens_migration.js b/nightfall-deployer/migrations/3_test_tokens_migration.js index a0062aa3a..26ac83bf4 100644 --- a/nightfall-deployer/migrations/3_test_tokens_migration.js +++ b/nightfall-deployer/migrations/3_test_tokens_migration.js @@ -1,12 +1,6 @@ const config = require('config'); -const { - TEST_OPTIONS: { - restrictions: { erc20default }, - addresses, - }, - RESTRICTIONS, -} = config; +const { TEST_OPTIONS: { addresses }, RESTRICTIONS } = config; const { DEPLOY_MOCK_TOKENS = true } = process.env; const Shield = artifacts.require('Shield.sol'); @@ -32,6 +26,14 @@ module.exports = function (deployer, _, accounts) { await ERC20deployed.transfer(addresses.user2, 1000000000000); await ERC20deployed.transfer(restrictions.address, 1000000000000); // for testing Shield balance withdraw + // set restictions for test ERC20Mock contract (we handle this differently because the address is not fixed) + try { + const erc20MockRestriction = RESTRICTIONS.tokens[process.env.ETH_NETWORK].find(el => el.name === 'ERC20Mock').amount; + await restrictions.setRestriction(ERC20Mock.address, (BigInt(erc20MockRestriction) / BigInt(4)).toString(), erc20MockRestriction); + } catch (err) { + console.warn('Test contract restrictions were not set, and yet you have deployed test contracts'); + } + if (!config.ETH_ADDRESS) { // indicates we're running a wallet test that uses hardcoded addresses // For e2e tests