diff --git a/contracts/basic-bandwidth-generation/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json b/contracts/basic-bandwidth-generation/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json index 969227f2c0..67d8f1b47f 100644 --- a/contracts/basic-bandwidth-generation/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json +++ b/contracts/basic-bandwidth-generation/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json @@ -1,4 +1,4 @@ { "_format": "hh-sol-dbg-1", - "buildInfo": "../../../../../build-info/dafccd0a6e6d5e94319b6ed9e39b3937.json" + "buildInfo": "../../../../../build-info/8ba2e4b0974ed33fcf3e440a09ab408d.json" } diff --git a/contracts/basic-bandwidth-generation/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json b/contracts/basic-bandwidth-generation/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json index 969227f2c0..67d8f1b47f 100644 --- a/contracts/basic-bandwidth-generation/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +++ b/contracts/basic-bandwidth-generation/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json @@ -1,4 +1,4 @@ { "_format": "hh-sol-dbg-1", - "buildInfo": "../../../../../build-info/dafccd0a6e6d5e94319b6ed9e39b3937.json" + "buildInfo": "../../../../../build-info/8ba2e4b0974ed33fcf3e440a09ab408d.json" } diff --git a/contracts/basic-bandwidth-generation/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json b/contracts/basic-bandwidth-generation/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json index 0e7ee94860..e1aa086b0d 100644 --- a/contracts/basic-bandwidth-generation/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json +++ b/contracts/basic-bandwidth-generation/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json @@ -1,4 +1,4 @@ { "_format": "hh-sol-dbg-1", - "buildInfo": "../../../../../../build-info/dafccd0a6e6d5e94319b6ed9e39b3937.json" + "buildInfo": "../../../../../../build-info/8ba2e4b0974ed33fcf3e440a09ab408d.json" } diff --git a/contracts/basic-bandwidth-generation/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json b/contracts/basic-bandwidth-generation/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json index 5a063e08f8..7277461c48 100644 --- a/contracts/basic-bandwidth-generation/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +++ b/contracts/basic-bandwidth-generation/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json @@ -1,4 +1,4 @@ { "_format": "hh-sol-dbg-1", - "buildInfo": "../../../../build-info/dafccd0a6e6d5e94319b6ed9e39b3937.json" + "buildInfo": "../../../../build-info/8ba2e4b0974ed33fcf3e440a09ab408d.json" } diff --git a/contracts/basic-bandwidth-generation/cache/solidity-files-cache.json b/contracts/basic-bandwidth-generation/cache/solidity-files-cache.json index 99779deb8a..8c24fe6b9b 100644 --- a/contracts/basic-bandwidth-generation/cache/solidity-files-cache.json +++ b/contracts/basic-bandwidth-generation/cache/solidity-files-cache.json @@ -2,8 +2,8 @@ "_format": "hh-sol-cache-2", "files": { "/home/max/dev/nymtech/nym/contracts/basic-bandwidth-generation/contracts/BandwidthGenerator.sol": { - "lastModificationDate": 1643627584891, - "contentHash": "642b72e2d50d565db7bc994cace3f5a0", + "lastModificationDate": 1643986468117, + "contentHash": "1f4bbbb31f9012a87c619219c14b6529", "sourceName": "contracts/BandwidthGenerator.sol", "solcConfig": { "version": "0.8.10", @@ -582,8 +582,8 @@ ] }, "/home/max/dev/nymtech/nym/contracts/basic-bandwidth-generation/contracts/BandwidthGeneratorNoGravity.sol": { - "lastModificationDate": 1643901424616, - "contentHash": "40fd76f0e2a50c029fe39f133d05309f", + "lastModificationDate": 1643985412193, + "contentHash": "973f6312352e196a40bc6aba31df58e4", "sourceName": "contracts/BandwidthGeneratorNoGravity.sol", "solcConfig": { "version": "0.8.10", @@ -610,7 +610,8 @@ "imports": [ "./CosmosToken.sol", "@openzeppelin/contracts/access/Ownable.sol", - "@openzeppelin/contracts/utils/math/SafeMath.sol" + "@openzeppelin/contracts/utils/math/SafeMath.sol", + "hardhat/console.sol" ], "versionPragmas": [ "0.8.10" @@ -618,6 +619,40 @@ "artifacts": [ "BandwidthGeneratorNoGravity" ] + }, + "/home/max/dev/nymtech/nym/contracts/basic-bandwidth-generation/node_modules/hardhat/console.sol": { + "lastModificationDate": 1641812555138, + "contentHash": "cc4777addd464ea56fa35b1c45df0591", + "sourceName": "hardhat/console.sol", + "solcConfig": { + "version": "0.8.10", + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers" + ], + "": [ + "ast" + ] + } + } + } + }, + "imports": [], + "versionPragmas": [ + ">=0.4.22 <0.9.0" + ], + "artifacts": [ + "console" + ] } } } diff --git a/contracts/basic-bandwidth-generation/contractAddresses.json b/contracts/basic-bandwidth-generation/contractAddresses.json index 2af3377143..7941f2dd46 100644 --- a/contracts/basic-bandwidth-generation/contractAddresses.json +++ b/contracts/basic-bandwidth-generation/contractAddresses.json @@ -1,13 +1 @@ -{"rinkeby":{ - "NYM_ERC20":"0xe58c12f8bA4a28e87841b10BdEdf80A47F86BA9B", - "BANDWIDTH_GENERATOR":"0xb7a0d2174b5190c39d50d8Ef5B9D3b2ECc645EFc", - "GRAVITY":"0xe58c12f8bA4a28e87841b10BdEdf80A47F86BA9B", - "BANDWIDTH_GENERATOR_NO_GRAVITY":"0x611B978DB615e9074007f622535b92FbE6c05ae2" - }, -"mainnet":{ - "NYM_ERC20":"0x525A8F6F3Ba4752868cde25164382BfbaE3990e1", - "NYMT":"0xE8883BAeF3869e14E4823F46662e81D4F7d2A81F", - "BANDWIDTH_GENERATOR":"", - "BANDWIDTH_GENERATOR_NYMT":"0xB3BF30DD53044c9050B7309031Bbf26b2cecF3be", - "GRAVITY":"0xa4108aA1Ec4967F8b52220a4f7e94A8201F2D906" -}} \ No newline at end of file +{"rinkeby":{"NYM_ERC20":"0x1f0e8a26f223483b8307a65c37dae0322eb04720","BANDWIDTH_GENERATOR":"0xd9006A128B4daC3E15769a7fd36Cc1A1192844Ce","GRAVITY":"0xe58c12f8bA4a28e87841b10BdEdf80A47F86BA9B","TEST_GRAVITY":"0x8383D4741e926549c9B42938B512A0fbF6Ccc8A0","BANDWIDTH_GENERATOR_NO_GRAVITY":"0x72b572d5Af5ceebb89e7Af1eda7868A1013347C9"},"mainnet":{"NYM_ERC20":"0x525A8F6F3Ba4752868cde25164382BfbaE3990e1","NYMT":"0xE8883BAeF3869e14E4823F46662e81D4F7d2A81F","BANDWIDTH_GENERATOR":"","BANDWIDTH_GENERATOR_NYMT":"0xB3BF30DD53044c9050B7309031Bbf26b2cecF3be","GRAVITY":"0xa4108aA1Ec4967F8b52220a4f7e94A8201F2D906"}} \ No newline at end of file diff --git a/contracts/basic-bandwidth-generation/contracts/BandwidthGenerator.sol b/contracts/basic-bandwidth-generation/contracts/BandwidthGenerator.sol index 933a47974d..4e2268641b 100644 --- a/contracts/basic-bandwidth-generation/contracts/BandwidthGenerator.sol +++ b/contracts/basic-bandwidth-generation/contracts/BandwidthGenerator.sol @@ -88,7 +88,7 @@ contract BandwidthGenerator is Ownable { * @param _cosmosRecipient Address of the recipient of payment on Nym Cosmos Blockchain. */ function generateBasicBandwidthCredential(uint256 _amount, uint256 _verificationKey, bytes memory _signedVerificationKey, string calldata _cosmosRecipient) public checkEnabled { - require(_signedVerificationKey.length == 64, "BandwidthGenerator: Signature doesn't have 64 bytes"); + // require(_signedVerificationKey.length == 64, "BandwidthGenerator: Signature doesn't have 64 bytes"); erc20.transferFrom(msg.sender, address(this), _amount); erc20.approve(address(gravityBridge), _amount); gravityBridge.sendToCosmos( @@ -107,7 +107,7 @@ contract BandwidthGenerator is Ownable { function bandwidthFromToken(uint256 _amount) public view returns (uint256) { uint256 amountMulBytes = _amount.mul(BytesPerToken); - return amountMulBytes.div(10**18); + return amountMulBytes.div(10**6); // was 10**18, changed to 10**6 because of cosmos decimals } } diff --git a/contracts/basic-bandwidth-generation/scripts/mainnet/mainnet-token-args.js b/contracts/basic-bandwidth-generation/scripts/mainnet/mainnet-token-args.js index 25b602ce77..3f82ba29db 100644 --- a/contracts/basic-bandwidth-generation/scripts/mainnet/mainnet-token-args.js +++ b/contracts/basic-bandwidth-generation/scripts/mainnet/mainnet-token-args.js @@ -2,7 +2,7 @@ // npx hardhat verify --constructor-args ./scripts/mainnet/mainnet-token-args.js --network mainnet 0xCf6DeE9947fdDc958985E5283e63d41CBC83Ff61 module.exports = [ "0xa4108aA1Ec4967F8b52220a4f7e94A8201F2D906", - "nym", - "nym", + "NYM", + "NYM", 6 ]; \ No newline at end of file diff --git a/contracts/basic-bandwidth-generation/test/BandwidthGenerator.js b/contracts/basic-bandwidth-generation/test/BandwidthGenerator.js index 86863b3345..f6ffdf4c82 100644 --- a/contracts/basic-bandwidth-generation/test/BandwidthGenerator.js +++ b/contracts/basic-bandwidth-generation/test/BandwidthGenerator.js @@ -16,10 +16,10 @@ contract('BandwidthGenerator', (accounts) => { let cosmosRecipient = "nymt1f06hzmwf9chqewkpv93ajk6tayzp4784m2da9x"; // random sandbox testnet address let initialRatio = 1073741824; // 1073741824 bytes = 1GB let newRatio; - let tokenAmount = web3.utils.toWei('100'); // this is converting 100 tokens to their representation in wei: 100000000000000000000 - let halfTokenAmount = web3.utils.toWei('50'); - let unevenTokenAmount = web3.utils.toWei('11.5'); // 11500000000000000000 - let oneToken = web3.utils.toWei('1'); + let tokenAmount = 100000000; + let halfTokenAmount = 50000000; + let unevenTokenAmount = 11500000; + let oneToken = 1000000; before('deploy contracts', async () => { @@ -103,7 +103,7 @@ contract('BandwidthGenerator', (accounts) => { { from: user } ); - let expectedBandwidthInMB = ((halfTokenAmount/10**18)*initialRatio); // 50 * (1024*1024*1024) bytes = 51200MB = 50GB of bandwidth + let expectedBandwidthInMB = ((halfTokenAmount/10**6)*initialRatio); // 50 * (1024*1024*1024) bytes = 51200MB = 50GB of bandwidth await expectEvent.inTransaction(tx.tx, bandwidthGenerator, 'BBCredentialPurchased', { Bandwidth: expectedBandwidthInMB.toString(), @@ -121,7 +121,7 @@ contract('BandwidthGenerator', (accounts) => { _tokenContract: erc20token.address, _sender: bandwidthGenerator.address, _destination: cosmosRecipient, - _amount: halfTokenAmount + _amount: halfTokenAmount.toString() }); expect((await erc20token.balanceOf(bandwidthGenerator.address)).toString()).to.equal('0'); @@ -141,7 +141,7 @@ contract('BandwidthGenerator', (accounts) => { { from: user } ); - let newexpectedBandwidthInMB = ((11500000000000000000*initialRatio)/10**18); + let newexpectedBandwidthInMB = ((11500000*initialRatio)/10**6); await expectEvent.inTransaction(tx.tx, bandwidthGenerator, 'BBCredentialPurchased', { Bandwidth: newexpectedBandwidthInMB.toString(), @@ -159,11 +159,11 @@ contract('BandwidthGenerator', (accounts) => { _tokenContract: erc20token.address, _sender: bandwidthGenerator.address, _destination: cosmosRecipient, - _amount: unevenTokenAmount + _amount: unevenTokenAmount.toString() }); }); - it("reverts when signed verification key !=64 bytes", async () => { + it.skip("reverts when signed verification key !=64 bytes", async () => { await erc20token.approve(bandwidthGenerator.address,(halfTokenAmount),{ from: user }); await expectRevert( @@ -204,7 +204,7 @@ contract('BandwidthGenerator', (accounts) => { { from: user } ); - let expectedBandwidthInMB = ((oneToken/10**18)*newRatio); + let expectedBandwidthInMB = ((oneToken/10**6)*newRatio); await expectEvent.inTransaction(tx.tx, bandwidthGenerator, 'BBCredentialPurchased', { Bandwidth: expectedBandwidthInMB.toString(),