Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
.env
coverage
coverage.json
typechain

#Hardhat files
cache
artifacts
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,22 @@ This project contains the token bridge contract for the bridge protocol.the tas
7. register a mintTransaction
8. validate the mint transaction
you have 72 hours to attempt this. once successful share the contract addresses of the deployed project.Thank you and goodluck.


Answer:
3. Contract Addresses:
Controller: 0x151E05aB10b05dC744fc0573272A0CB5dB1AdF40
Deployer: 0xB2EF60Dd97fD62DD4C2a1F211A55145966f80F33
Registry: 0xAeDC1eeAda0a13bf23AB031469CC6Fe6bE094071
Settings: 0x606806107361ca9F232576918B14B9519293B4D8
FeeConroller: 0x5D3D1126C2F0dBf7f00c5862C8b254be0c27e151
BridgePool: 0x1b5208b160D08547105b07C04fE5B7F5F7F72497
Bridge: 0x955ce90A740d9cb841423CdeC66c5556c2173aF1
TokenContract: 0x9c096c3f3171f6443cf7cd766684D09fBdBD376f


4. transactionHash = 0xd207f6f60673a03fd4d391bdbbaea5991f492d171602ccc0f1189be785f25c8b
5. transactionHash = 0x186c4d2d012b0fc1060071edd8c4310551f9a5f1d2ea9cb042e09f22ba928eef
6. transactionHash = 0x48f8d4f74866e976c8c681d9973432f9733d7f66620d49cc4c892c760e6f48bc
7. transactionHash = 0x16339681957e6e94954f750b422a95e9797f49731fa7dae590d0ca3d321d6d31
8. transactionHash = 0x5df67a489a220c91e47654129227b4b6caeb6335a6b2417097c43b46ca8fb5fc
11 changes: 11 additions & 0 deletions contracts/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,17 @@ contract Bridge is Context , ReentrancyGuard {
}
}

// this was not defined in the code and its not allowing the contract to compile.
// so i defined the function based on assumption
function removeBaseFee(address assetAddress, uint256 amount) view internal returns (uint256){
asset storage currentasset;
currentasset = nativeAssets[assetAddress];
if((currentasset.tokenAddress == address(0)))
currentasset = foriegnAssets[assetAddress];
require(currentasset.isSet ,"I_A");
return amount - currentasset.baseFeeBalance;
}


// internal fxn used to process incoming payments
function processedPayment(address assetAddress ,uint256 chainID, uint256 amount) internal returns (bool , uint256) {
Expand Down
54 changes: 43 additions & 11 deletions contracts/Registry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -215,21 +215,28 @@ contract Registry is Ownable {
// this part of the code was remove to access if you can recreate it to verify the signatures for a transaction

// the message that was signed by the validators is a hash of derived as shown bellow
for (uint256 index ; index < signatures.length ; index++){
bytes32 messageHash = keccak256(abi.encodePacked(
"\x19Ethereum Signed Message:\n32",
keccak256(abi.encodePacked(
Ibridge(owner()).chainId(), // this is goten from Ibridge(owner()).chainId()
transaction.chainId,
transaction.assetAddress,
transaction.amount,
transaction.receiver,
transaction.nounce
))));

bool verified = recoverSigner(messageHash, signatures[index]) == msg.sender;
if (verified){
validSignatures += 1;
}

// keccak256(abi.encodePacked(
// "\x19Ethereum Signed Message:\n32",
// keccak256(abi.encodePacked(
// chainID, // this is goten from Ibridge(owner()).chainId()
// interfacingChainId,
// assetAddress,
// amount,
// receiver,
// nounce
// ))))
}


// to all you need to do here is verify each of this signatures to accertain if the are from a valid signer


//
require(validSignatures >= Isettings(Ibridge(owner()).settings()).minValidations() ,"insuficient_signers");
transactionValidations[transactionId].validationCount = validSignatures;
Expand All @@ -249,6 +256,31 @@ contract Registry is Ownable {
function transactionValidated(bytes32 transactionID) external view returns (bool) {
return transactionValidations[transactionID].validated;
}
function recoverSigner(
bytes32 _signedMessageHash,
bytes memory _signature
) public pure returns (address) {
(bytes32 r, bytes32 s, uint8 v) = splitSignature(_signature);

return ecrecover(_signedMessageHash, v, r, s);
}

function splitSignature(
bytes memory sig
) public pure returns (bytes32 r, bytes32 s, uint8 v) {
require(sig.length == 65, "invalid signature length");

assembly {

r := mload(add(sig, 32))
// second 32 bytes
s := mload(add(sig, 64))
// final byte (first byte of the next 32 bytes)
v := byte(0, mload(add(sig, 96)))
}

return (r, s, v);
}

}

Expand Down
57 changes: 57 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
require("dotenv").config();

require("@nomiclabs/hardhat-etherscan");
require("@nomiclabs/hardhat-waffle");

// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();

for (const account of accounts) {
console.log(account.address);
}
});

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more

/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: {
version: "0.8.0",
settings: {
optimizer: {
enabled: true,
runs: 1000,
},
},
},
paths:{
artifacts: './artifacts',
},
networks: {

testnet: {
url: process.env.BINANCE_TESTNET_RPC_URL,
timeout: 150000000,
allowUnlimitedContractSize:true,
chainId: 97,
accounts: [`${process.env.PRIVATE_KEY}`],
},
hardhat: {
allowUnlimitedContractSize:true,
chainId: 1337,
timeout: 150000000,
},
},
// gasReporter: {
// enabled: process.env.REPORT_GAS !== undefined,
// currency: "USD",
// },
// etherscan: {
// apiKey: process.env.ETHERSCAN_API_KEY,
// },
};
Loading