From 2cfc30e47d128b99bf2e4dd168cd001614b306b9 Mon Sep 17 00:00:00 2001 From: Christophe Le Bars Date: Sun, 20 Sep 2020 20:43:05 +0800 Subject: [PATCH] fix test @openzeppelin/contracts --- migrations/2_deploy_contracts.js | 41 ++++++++-------- package-lock.json | 82 +++++++++++++++++++++++++------- test/Attachments.js | 9 ++-- truffle.js | 5 +- 4 files changed, 94 insertions(+), 43 deletions(-) diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js index 28e269b..6664fb5 100644 --- a/migrations/2_deploy_contracts.js +++ b/migrations/2_deploy_contracts.js @@ -8,25 +8,7 @@ const RougeBridge = artifacts.require("./RougeBridge.sol") module.exports = async function(deployer, network) { - const rgeAddress = { - sokol: '0x5475300766433dd082a7340fc48a445c483df68f' - } - - if (network && rgeAddress[network]) { - - const rge = await RGETokenInterface.at(rgeAddress[network]) - - await deployer.deploy(RougeFactory) - const factory = await RougeFactory.deployed() - - const results = await Promise.all([ - rge.setFactory(factory.address), - factory.setParams(rge.address, 100000) - ]); - - console.log('results', results) - - } else if (false) { + if (['test'].includes(network)) { await Promise.all([ deployer.deploy(TestRGEToken), @@ -48,6 +30,27 @@ module.exports = async function(deployer, network) { factory.setParams(rge.address, 100000) ]); + return + } + + const rgeAddress = { + sokol: '0x5475300766433dd082a7340fc48a445c483df68f' + } + + if (network && rgeAddress[network]) { + + const rge = await RGETokenInterface.at(rgeAddress[network]) + + await deployer.deploy(RougeFactory) + const factory = await RougeFactory.deployed() + + const results = await Promise.all([ + rge.setFactory(factory.address), + factory.setParams(rge.address, 100000) + ]); + + console.log('results', results) + } }; diff --git a/package-lock.json b/package-lock.json index 1dcf77e..a8dbb90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -462,7 +462,6 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/@types/pbkdf2/-/pbkdf2-3.1.0.tgz", "integrity": "sha512-Cf63Rv7jCQ0LaL8tNXmEyqTHuIJxRdlS5vMh1mj5voN4+QFhVZnlZruezqpWYDiJ8UTzhP0VmeLXCmBk66YrMQ==", - "dev": true, "requires": { "@types/node": "*" } @@ -480,7 +479,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/@types/secp256k1/-/secp256k1-4.0.1.tgz", "integrity": "sha512-+ZjSA8ELlOp8SlKi0YLB2tz9d5iPNEmOBd+8Rz21wTMdaXQIa9b6TEnD6l5qKOCypE7FSyPyck12qZJxSDNoog==", - "dev": true, "requires": { "@types/node": "*" } @@ -1509,8 +1507,7 @@ "blakejs": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.1.0.tgz", - "integrity": "sha1-ad+S75U6qIylGjLfarHFShVfx6U=", - "dev": true + "integrity": "sha1-ad+S75U6qIylGjLfarHFShVfx6U=" }, "bluebird": { "version": "3.7.2", @@ -3256,7 +3253,6 @@ "version": "0.1.3", "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz", "integrity": "sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ==", - "dev": true, "requires": { "@types/pbkdf2": "^3.0.0", "@types/secp256k1": "^4.0.1", @@ -3279,7 +3275,6 @@ "version": "6.5.3", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", "integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", - "dev": true, "requires": { "bn.js": "^4.4.0", "brorand": "^1.0.1", @@ -3294,7 +3289,6 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/keccak/-/keccak-3.0.1.tgz", "integrity": "sha512-epq90L9jlFWCW7+pQa6JOnKn2Xgl2mtI664seYR6MHskvI9agt7AnDqmAlp9TqU4/caMYbA08Hi5DMZAl5zdkA==", - "dev": true, "requires": { "node-addon-api": "^2.0.0", "node-gyp-build": "^4.2.0" @@ -3303,14 +3297,12 @@ "scrypt-js": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", - "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==", - "dev": true + "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==" }, "secp256k1": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.2.tgz", "integrity": "sha512-UDar4sKvWAksIlfX3xIaQReADn+WFnHvbVujpcbr+9Sf/69odMwy2MUsz5CKLQgX9nsIyrjuxL2imVyoNHa3fg==", - "dev": true, "requires": { "elliptic": "^6.5.2", "node-addon-api": "^2.0.0", @@ -3320,8 +3312,7 @@ "setimmediate": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=", - "dev": true + "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" } } }, @@ -3487,6 +3478,7 @@ "ethereumjs-account": "^2.0.3", "ethereumjs-block": "~2.2.0", "ethereumjs-common": "^1.1.0", + "ethereumjs-util": "^6.0.0", "fake-merkle-patricia-tree": "^1.0.1", "functional-red-black-tree": "^1.0.1", "merkle-patricia-tree": "^2.3.2", @@ -3494,6 +3486,20 @@ "safe-buffer": "^5.1.1" }, "dependencies": { + "elliptic": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", + "integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", + "requires": { + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.0" + } + }, "ethereumjs-block": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/ethereumjs-block/-/ethereumjs-block-2.2.2.tgz", @@ -3527,7 +3533,22 @@ "resolved": "https://registry.npmjs.org/ethereumjs-tx/-/ethereumjs-tx-2.1.2.tgz", "integrity": "sha512-zZEK1onCeiORb0wyCXUvg94Ve5It/K6GD1K+26KfFKodiBiS6d9lfCXlUKGBBdQ+bv7Day+JK0tj1K+BeNFRAw==", "requires": { - "ethereumjs-common": "^1.5.0" + "ethereumjs-common": "^1.5.0", + "ethereumjs-util": "^6.0.0" + } + }, + "ethereumjs-util": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz", + "integrity": "sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw==", + "requires": { + "@types/bn.js": "^4.11.3", + "bn.js": "^4.11.0", + "create-hash": "^1.1.2", + "elliptic": "^6.5.2", + "ethereum-cryptography": "^0.1.3", + "ethjs-util": "0.1.6", + "rlp": "^2.2.3" } } } @@ -3539,6 +3560,7 @@ "requires": { "aes-js": "^3.1.1", "bs58check": "^2.1.2", + "ethereumjs-util": "^6.0.0", "hdkey": "^1.1.0", "randombytes": "^2.0.6", "safe-buffer": "^5.1.2", @@ -3552,6 +3574,34 @@ "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==" }, + "elliptic": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", + "integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", + "requires": { + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.0" + } + }, + "ethereumjs-util": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz", + "integrity": "sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw==", + "requires": { + "@types/bn.js": "^4.11.3", + "bn.js": "^4.11.0", + "create-hash": "^1.1.2", + "elliptic": "^6.5.2", + "ethereum-cryptography": "^0.1.3", + "ethjs-util": "0.1.6", + "rlp": "^2.2.3" + } + }, "uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", @@ -5665,8 +5715,7 @@ "node-addon-api": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", - "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==", - "dev": true + "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" }, "node-fetch": { "version": "2.6.0", @@ -5677,8 +5726,7 @@ "node-gyp-build": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz", - "integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==", - "dev": true + "integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==" }, "normalize-path": { "version": "1.0.0", diff --git a/test/Attachments.js b/test/Attachments.js index 54c602f..181d923 100644 --- a/test/Attachments.js +++ b/test/Attachments.js @@ -2,8 +2,8 @@ const { newTestCampaign, getBalanceInFinney, authHash, protocolSig } = require('./utils.js'); const truffleContract = require("@truffle/contract") -const EIP20 = require("@openzeppelin/contracts/build/contracts/ERC20.json"); -const EIP721 = require("@openzeppelin/contracts/build/contracts/ERC721.json"); +const EIP20 = require("@openzeppelin/contracts/build/contracts/ERC20Mintable.json"); +const EIP721 = require("@openzeppelin/contracts/build/contracts/ERC721Mintable.json"); const RGEToken = artifacts.require("./TestRGEToken.sol"); const Factory = artifacts.require("./RougeFactory.sol"); @@ -74,7 +74,8 @@ contract('SimpleRougeCampaign(Attachments)', function(accounts) { const ERC20 = truffleContract(EIP20) ERC20.setProvider(web3.currentProvider); - const erc20 = await ERC20.new(issuer, erc20_attachment * 10, {from: issuer}); + const erc20 = await ERC20.new({from: issuer}); + const tx_mint = await erc20.mint(issuer, erc20_attachment * 10, {from: issuer}); await erc20.approve(campaign.address, erc20_attachment, {from: issuer}); @@ -131,7 +132,7 @@ contract('SimpleRougeCampaign(Attachments)', function(accounts) { const ERC721 = truffleContract(EIP721) ERC721.setProvider(web3.currentProvider); - const erc721 = await ERC721.new({from: issuer}); + const erc721 = await ERC721.new( {from: issuer}); const campaignBalance_before = await erc721.balanceOf.call(campaign.address); assert.equal(campaignBalance_before, 0, "no erc721 transfered yet"); diff --git a/truffle.js b/truffle.js index 46931c0..4d6eabe 100644 --- a/truffle.js +++ b/truffle.js @@ -1,6 +1,5 @@ const PrivateKeyProvider = require("truffle-privatekey-provider"); -const privateKey = process.env.PKEY || ''; module.exports = { solc: { @@ -16,14 +15,14 @@ module.exports = { network_id: "*" // Match any network id }, // rinkeby: { - // provider: new PrivateKeyProvider(privateKey, "https://rinkeby.infura.io/"), + // provider: () => new PrivateKeyProvider(privateKey, "https://rinkeby.infura.io/"), // network_id: 4 // }, sokol: { //host: "https://sokol-trace.poa.network", //https://sokol.poa.network", host: "https://sokol.poa.network", port: 443, - provider: new PrivateKeyProvider(privateKey, "https://sokol.poa.network"), + provider: () => new PrivateKeyProvider(process.env.PKEY, "https://sokol.poa.network"), network_id: 77, } }