Skip to content
This repository has been archived by the owner on Mar 16, 2023. It is now read-only.

Commit

Permalink
fix(): fix patch, add migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud Schenk committed Mar 6, 2020
1 parent fd0036e commit 5563495
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 37 deletions.
1 change: 0 additions & 1 deletion packages/aztec.js/src/signer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import BN from 'bn.js';
import { constants, proofs } from '@aztec/dev-utils';
import BN from 'bn.js';

import secp256k1 from '@aztec/secp256k1';
import typedData from '@aztec/typed-data';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
pragma solidity >=0.5.0 <0.6.0;

import "../20200207/Behaviour20200207.sol";
import "../20200220/Behaviour20200220.sol";
import "../../../interfaces/IERC20Permit.sol";

/**
* @title Behaviour20200220 implementation
* @title Behaviour20200305 implementation
* @author AZTEC
* @dev This behaviour contract overloads the deposit() account registry method, with a deposit()
* implementation that is compatible with the DAI permit() function.
*
* Note the behaviour contract version naming convention is based on the date on which the contract
* was created, in the format: YYYYMMDD
*
* Copyright 2020 Spilsbury Holdings Ltd
*
Expand All @@ -25,7 +20,7 @@ import "../../../interfaces/IERC20Permit.sol";
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
contract Behaviour20200220 is Behaviour20200207 {
contract Behaviour20200305 is Behaviour20200220 {
/**
* @dev epoch number, used for version control in upgradeability. The naming convention is based on the
* date on which the contract was created, in the format: YYYYMMDD
Expand All @@ -39,7 +34,7 @@ contract Behaviour20200220 is Behaviour20200207 {
* @param _proofData - data generated from proof construction, which is used to validate the proof
* @param _spender - address that will be spending the notes
* @param _proofSignature - EIP712 signature used to approve/revoke permission for the proof
* @param _proofSignature2 - EIP712 signature with be s bit flipped for replay protection of ZkDai
* @param _proofSignature2 - EIP712 signature with be s bit flipped for replay protection of ZkDai
* to be spent
*/
function confidentialTransferFrom(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* global artifacts */
const dotenv = require('dotenv');

dotenv.config();
const AccountRegistryBehaviour20200305 = artifacts.require('./AccountRegistry/epochs/20200305/Behaviour20200305');
const AccountRegistryManager = artifacts.require('./AccountRegistry/AccountRegistryManager');

module.exports = (deployer, network) => {
return deployer.deploy(AccountRegistryBehaviour20200305).then(async (behaviourContract) => {
const isLocal = network === 'development' || network === 'test';

// Get the manager contract instance
let managerContract;
if (isLocal) {
managerContract = await AccountRegistryManager.deployed();
} else {
managerContract = await AccountRegistryManager.at(AccountRegistryManager.address);
}

// Perform the upgrade
await managerContract.upgradeAccountRegistry(behaviourContract.address);

// Get the proxy contract instance
const proxyAddress = await managerContract.proxyAddress();
const proxyContract = await AccountRegistryBehaviour20200305.at(proxyAddress);

// Set the GSN signer address
await proxyContract.setGSNSigner();
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const nacl = require('tweetnacl');
nacl.util = require('tweetnacl-util');
const { keccak256, randomHex } = require('web3-utils');

const AccountRegistry = artifacts.require('./AccountRegistry/epochs/20200106/Behaviour20200106');
const AccountRegistry = artifacts.require('./Behaviour20200106');

const createSignature = require('../../../helpers/AccountRegistry/AccountRegistryManager');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
const { randomHex } = require('web3-utils');

const AccountRegistryManager = artifacts.require('./AccountRegistry/AccountRegistryManager');
const Behaviour20200106 = artifacts.require('./Behaviour20200106/epochs/20200106/Behaviour20200106');
const Behaviour20200207 = artifacts.require('./Behaviour20200207/epochs/20200207/Behaviour20200207');
const Behaviour20200106 = artifacts.require('./Behaviour20200106');
const Behaviour20200207 = artifacts.require('./Behaviour20200207');

contract('AccountRegistry: Behaviour20200207', async (accounts) => {
let behaviour20200106;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const { randomHex, toChecksumAddress } = require('web3-utils');

const ACE = artifacts.require('./ACE');
const AccountRegistryManager = artifacts.require('./AccountRegistry/AccountRegistryManager');
const Behaviour20200106 = artifacts.require('./Behaviour20200106/epochs/20200106/Behaviour20200106');
const Behaviour20200220 = artifacts.require('./Behaviour20200106/epochs/20200106/Behaviour20200220');
const Behaviour20200106 = artifacts.require('./Behaviour20200106');
const Behaviour20200220 = artifacts.require('./Behaviour20200220');
const DAI = artifacts.require('./test/ERC20/DAI/Dai');
const ZkAsset = artifacts.require('ZkAssetOwnable');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

const {
JoinSplitProof,
note,
signer,
} = require('aztec.js');
const { constants, proofs } =require('@aztec/dev-utils');
const { generateAccount } = require('@aztec/secp256k1');
const { proofs } =require('@aztec/dev-utils');
const truffleAssert = require('truffle-assertions');
const { randomHex, toChecksumAddress } = require('web3-utils');
const { randomHex } = require('web3-utils');

const ACE = artifacts.require('./ACE');
const AccountRegistryManager = artifacts.require('./AccountRegistry/AccountRegistryManager');
const Behaviour20200220 = artifacts.require('./Behaviour20200106/epochs/20200106/Behaviour20200220');
const Behaviour20200305 = artifacts.require('./Behaviour20200106/epochs/20200106/Behaviour20200220');
const Behaviour20200220 = artifacts.require('./Behaviour20200220');
const Behaviour20200305 = artifacts.require('./Behaviour20200305');
const ERC20Mintable = artifacts.require('ERC20Mintable');
const ZkAsset = artifacts.require('ZkAssetOwnable');
const {
Expand All @@ -22,12 +20,9 @@ const {
getOwnerPrivateKey,
} = require('../../../helpers/AccountRegistry/epochs/20200106/Behaviour20200106');

const standardAccount = require('../../../helpers/getOwnerAccount');
const timetravel = require('../../../timeTravel');

contract.only('Behaviour20200305', async (accounts) => {
const [userAddress, anotherUserAddress, senderAddress] = accounts;
let behaviour20200220;
const [userAddress,, senderAddress] = accounts;
let behaviour20200305;
let manager;
let proxyContract;
let erc20;
Expand All @@ -39,8 +34,6 @@ contract.only('Behaviour20200305', async (accounts) => {
const updatedGSNSignerAddress = '0x5323B6bbD3421983323b3f4f0B11c2D6D3bCE1d8';
const initialAmount = 100;

const chainID = 4;

beforeEach(async () => {
ace = await ACE.deployed();
erc20 = await ERC20Mintable.new({ from: senderAddress });
Expand Down Expand Up @@ -76,7 +69,7 @@ contract.only('Behaviour20200305', async (accounts) => {
});

describe('Success states', async () => {
it('should call confidential approve twice if the a second signature is passed in', async () => {
it('should call confidential approve twice if a second signature is passed in', async () => {

const { inputNotes, outputNotes, publicValue, depositAmount } = await generateDepositProofInputs();
const publicOwner = proxyAddress;
Expand Down Expand Up @@ -134,13 +127,10 @@ contract.only('Behaviour20200305', async (accounts) => {
}),
);


await truffleAssert.reverts(
zkAsset.approveProof(proofs.JOIN_SPLIT_PROOF, transferProofData, delegatedAddress, true, proofSignature2),
'signature has already been used'
);


});

});
Expand Down Expand Up @@ -198,10 +188,6 @@ contract.only('Behaviour20200305', async (accounts) => {
expect(noteOwner).to.equal(userAddress);
}),
);



});

});

2 changes: 1 addition & 1 deletion packages/protocol/test/ERC1724/Approval.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const BaseFactory = artifacts.require('./noteRegistry/epochs/201907/base/Factory

JoinSplitValidator.abi = JoinSplitValidatorInterface.abi;

contract('Approval', (accounts) => {
contract.only('Approval', (accounts) => {
let ace;
let erc20;
let zkAssetOwnable;
Expand Down

0 comments on commit 5563495

Please sign in to comment.