Forkchoice Ethereum Mainnet

Address Contract Partially Verified

Address 0x6adF52Bd683949B2B7630Db0fDC48C1322eF2BDF
Balance 0.444000 ETH ($910.52)
Nonce 1
Code Size 18371 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

18371 bytes
0x60806040526004361061023b5760003560e01c80638c0c26311161012e578063c5b37c22116100ab578063d547741f1161006f578063d547741f146108ab578063d7a9cd79146108d4578063e8437ee7146108ff578063edc20c3c14610928578063ffaac0eb146109515761023b565b8063c5b37c22146107c6578063c5ec8970146107f1578063ca15c8731461081c578063cb10f21514610859578063cdb0f73a146108825761023b565b80639d5773e0116100f25780639d5773e0146106df5780639d82dd631461070a578063a217fddf14610733578063a9cf69fa1461075e578063beab71311461079b5761023b565b80638c0c2631146105e85780639010d07c1461061157806391c404ac1461064e57806391d1485414610677578063926d7d7f146106b45761023b565b80634e056005116101bc578063780cf00411610180578063780cf004146105035780637febe63f1461052c578063802aabe81461056957806380ae1c281461059457806384db809f146105ab5761023b565b80634e056005146104095780635059871914610432578063541d5548146104725780635c975abb146104af5780635e1fab0f146104da5761023b565b806336568abe1161020357806336568abe146103145780633ee7094a1461033d5780634454b20d1461037a5780634603ae38146103a35780634b0b919d146103cc5761023b565b806305e2ca171461024057806317f03ce51461025c5780631ff013f114610285578063248a9ca3146102ae5780632f2ff15d146102eb575b600080fd5b61025a600480360381019061025591906132f7565b610968565b005b34801561026857600080fd5b50610283600480360381019061027e919061339f565b610bc5565b005b34801561029157600080fd5b506102ac60048036038101906102a791906133ee565b610d72565b005b3480156102ba57600080fd5b506102d560048036038101906102d0919061313d565b6114f3565b6040516102e29190613f60565b60405180910390f35b3480156102f757600080fd5b50610312600480360381019061030d9190613166565b611513565b005b34801561032057600080fd5b5061033b60048036038101906103369190613166565b611587565b005b34801561034957600080fd5b50610364600480360381019061035f9190613207565b61160a565b60405161037191906140e5565b60405180910390f35b34801561038657600080fd5b506103a1600480360381019061039c9190613451565b6116c7565b005b3480156103af57600080fd5b506103ca60048036038101906103c591906130c8565b611a08565b005b3480156103d857600080fd5b506103f360048036038101906103ee91906132ce565b611afc565b6040516104009190614466565b60405180910390f35b34801561041557600080fd5b50610430600480360381019061042b91906131de565b611b23565b005b34801561043e57600080fd5b5061045960048036038101906104549190613243565b611b62565b6040516104699493929190614012565b60405180910390f35b34801561047e57600080fd5b5061049960048036038101906104949190612f11565b611bac565b6040516104a69190613f45565b60405180910390f35b3480156104bb57600080fd5b506104c4611bd2565b6040516104d19190613f45565b60405180910390f35b3480156104e657600080fd5b5061050160048036038101906104fc9190612f11565b611be8565b005b34801561050f57600080fd5b5061052a60048036038101906105259190612f9f565b611c0d565b005b34801561053857600080fd5b50610553600480360381019061054e919061327f565b611c90565b6040516105609190613f45565b60405180910390f35b34801561057557600080fd5b5061057e611ccc565b60405161058b919061444b565b60405180910390f35b3480156105a057600080fd5b506105a9611cd2565b005b3480156105b757600080fd5b506105d260048036038101906105cd919061313d565b611ce4565b6040516105df9190613ed8565b60405180910390f35b3480156105f457600080fd5b5061060f600480360381019061060a9190612f63565b611d17565b005b34801561061d57600080fd5b50610638600480360381019061063391906131a2565b611d94565b6040516106459190613ed8565b60405180910390f35b34801561065a57600080fd5b50610675600480360381019061067091906131de565b611dc6565b005b34801561068357600080fd5b5061069e60048036038101906106999190613166565b611e1d565b6040516106ab9190613f45565b60405180910390f35b3480156106c057600080fd5b506106c9611e4f565b6040516106d69190613f60565b60405180910390f35b3480156106eb57600080fd5b506106f4611e66565b604051610701919061444b565b60405180910390f35b34801561071657600080fd5b50610731600480360381019061072c9190612f11565b611e6c565b005b34801561073f57600080fd5b50610748611f46565b6040516107559190613f60565b60405180910390f35b34801561076a57600080fd5b506107856004803603810190610780919061339f565b611f4d565b6040516107929190614429565b60405180910390f35b3480156107a757600080fd5b506107b061212e565b6040516107bd9190614481565b60405180910390f35b3480156107d257600080fd5b506107db612141565b6040516107e8919061444b565b60405180910390f35b3480156107fd57600080fd5b50610806612147565b604051610813919061444b565b60405180910390f35b34801561082857600080fd5b50610843600480360381019061083e919061313d565b61214d565b604051610850919061444b565b60405180910390f35b34801561086557600080fd5b50610880600480360381019061087b9190613002565b612174565b005b34801561088e57600080fd5b506108a960048036038101906108a49190612f11565b612246565b005b3480156108b757600080fd5b506108d260048036038101906108cd9190613166565b612320565b005b3480156108e057600080fd5b506108e9612394565b6040516108f6919061444b565b60405180910390f35b34801561090b57600080fd5b5061092660048036038101906109219190613051565b61239a565b005b34801561093457600080fd5b5061094f600480360381019061094a9190613363565b612472565b005b34801561095d57600080fd5b506109666124be565b005b6109706124d0565b60065434146109b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ab90614249565b60405180910390fd5b60006009600085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610a5c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a53906142a9565b60405180910390fd5b6000600860008760ff1660ff168152602001908152602001600020600081819054906101000a900467ffffffffffffffff1660010191906101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905590508383600a60008467ffffffffffffffff1667ffffffffffffffff16815260200190815260200160002060008960ff1660ff1681526020019081526020016000209190610b05929190612bd2565b5060008290508073ffffffffffffffffffffffffffffffffffffffff166338995da9878985338a8a6040518763ffffffff1660e01b8152600401610b4e96959493929190614089565b600060405180830381600087803b158015610b6857600080fd5b505af1158015610b7c573d6000803e3d6000fd5b505050508167ffffffffffffffff16868860ff167fdbb69440df8433824a026ef190652f29929eb64b4d1d5d2a69be8afe3e6eaed860405160405180910390a450505050505050565b610bcd612521565b60008360ff1660088467ffffffffffffffff1668ffffffffffffffffff16901b1790506000600b60008368ffffffffffffffffff1668ffffffffffffffffff16815260200190815260200160002060008481526020019081526020016000209050600480811115610c3a57fe5b8160040160009054906101000a900460ff166004811115610c5757fe5b1415610c98576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8f90614289565b60405180910390fd5b600754610ca9438360050154612593565b11610ce9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ce0906142e9565b60405180910390fd5b60048160040160006101000a81548160ff02191690836004811115610d0a57fe5b0217905550600480811115610d1b57fe5b8467ffffffffffffffff168660ff167f803c5a12f6bde629cea32e63d4b92d1b560816a6fb72e939d3c89e1cab65041784600001548560010154604051610d63929190613fe9565b60405180910390a45050505050565b610d7a6125dd565b610d826124d0565b60008460ff1660088567ffffffffffffffff1668ffffffffffffffffff16901b1790506000600b60008368ffffffffffffffffff1668ffffffffffffffffff16815260200190815260200160002060008481526020019081526020016000209050600073ffffffffffffffffffffffffffffffffffffffff166009600086815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610e86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e7d906143e9565b60405180910390fd5b60018160040160009054906101000a900460ff166004811115610ea557fe5b1115610ee6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610edd90614349565b60405180910390fd5b600c60008368ffffffffffffffffff1668ffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610fab576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fa2906141e9565b60405180910390fd5b60008160040160009054906101000a900460ff166004811115610fca57fe5b14156111ea57600560008154600101919050819055506040518060c0016040528085815260200184815260200160016040519080825280602002602001820160405280156110275781602001602082028036833780820191505090505b508152602001600060405190808252806020026020018201604052801561105d5781602001602082028036833780820191505090505b5081526020016001600481111561107057fe5b815260200143815250600b60008468ffffffffffffffffff1668ffffffffffffffffff1681526020019081526020016000206000858152602001908152602001600020600082015181600001556020820151816001015560408201518160020190805190602001906110e3929190612c52565b506060820151816003019080519060200190611100929190612c52565b5060808201518160040160006101000a81548160ff0219169083600481111561112557fe5b021790555060a08201518160050155905050338160020160008154811061114857fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600481111561119d57fe5b8567ffffffffffffffff168760ff167f803c5a12f6bde629cea32e63d4b92d1b560816a6fb72e939d3c89e1cab65041787876040516111dd929190613fe9565b60405180910390a461132d565b6007546111fb438360050154612593565b11156112805760048160040160006101000a81548160ff0219169083600481111561122257fe5b021790555060048081111561123357fe5b8567ffffffffffffffff168760ff167f803c5a12f6bde629cea32e63d4b92d1b560816a6fb72e939d3c89e1cab6504178787604051611273929190613fe9565b60405180910390a461132c565b806001015483146112c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112bd906143c9565b60405180910390fd5b80600201339080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b60048081111561133957fe5b8160040160009054906101000a900460ff16600481111561135657fe5b146114eb576001600c60008468ffffffffffffffffff1668ffffffffffffffffff168152602001908152602001600020600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508060040160009054906101000a900460ff16600481111561140857fe5b8567ffffffffffffffff168760ff167f25f8daaa4635a7729927ba3f5b3d59cc3320aca7c32c9db4e7ca7b9574343640876040516114469190613f60565b60405180910390a460016003541115806114695750600354816002018054905010155b156114ea5760028160040160006101000a81548160ff0219169083600481111561148f57fe5b0217905550600260048111156114a157fe5b8567ffffffffffffffff168760ff167f803c5a12f6bde629cea32e63d4b92d1b560816a6fb72e939d3c89e1cab65041787876040516114e1929190613fe9565b60405180910390a45b5b505050505050565b600060016000838152602001908152602001600020600201549050919050565b61153a600160008481526020019081526020016000206002015461153561263b565b611e1d565b611579576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611570906141c9565b60405180910390fd5b6115838282612643565b5050565b61158f61263b565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146115fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115f390614409565b60405180910390fd5b61160682826126d7565b5050565b600a602052816000526040600020602052806000526040600020600091509150508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156116bf5780601f10611694576101008083540402835291602001916116bf565b820191906000526020600020905b8154815290600101906020018083116116a257829003601f168201915b505050505081565b6116cf6125dd565b6116d76124d0565b60006009600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905060008660ff1660088767ffffffffffffffff1668ffffffffffffffffff16901b179050600082868660405160200161174993929190613e99565b6040516020818303038152906040528051906020012090506000600b60008468ffffffffffffffffff1668ffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000209050600060048111156117ac57fe5b8160040160009054906101000a900460ff1660048111156117c957fe5b141561180a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161180190614149565b60405180910390fd5b6002600481111561181757fe5b8160040160009054906101000a900460ff16600481111561183457fe5b14611874576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161186b90614129565b60405180910390fd5b806001015482146118ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118b190614269565b60405180910390fd5b60038160040160006101000a81548160ff021916908360048111156118db57fe5b02179055506000600960008360000154815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff1663e248cff283600001548a8a6040518463ffffffff1660e01b815260040161195d93929190614057565b600060405180830381600087803b15801561197757600080fd5b505af115801561198b573d6000803e3d6000fd5b505050508160040160009054906101000a900460ff1660048111156119ac57fe5b8967ffffffffffffffff168b60ff167f803c5a12f6bde629cea32e63d4b92d1b560816a6fb72e939d3c89e1cab650417856000015486600101546040516119f4929190613fe9565b60405180910390a450505050505050505050565b611a1061276b565b818190508484905014611a58576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a4f906141a9565b60405180910390fd5b600084849050905060008090505b81811015611af457858582818110611a7a57fe5b9050602002016020810190611a8f9190612f3a565b73ffffffffffffffffffffffffffffffffffffffff166108fc858584818110611ab457fe5b905060200201359081150290604051600060405180830381858888f19350505050158015611ae6573d6000803e3d6000fd5b508080600101915050611a66565b505050505050565b60086020528060005260406000206000915054906101000a900467ffffffffffffffff1681565b611b2b61276b565b80600381905550807fa20d6b84cd798a24038be305eff8a45ca82ef54a2aa2082005d8e14c0a4746c860405160405180910390a250565b600b602052816000526040600020602052806000526040600020600091509150508060000154908060010154908060040160009054906101000a900460ff16908060050154905084565b6000611bcb604051611bbd90613ec3565b604051809103902083611e1d565b9050919050565b60008060009054906101000a900460ff16905090565b611bf061276b565b611bfd6000801b82611513565b611c0a6000801b33611587565b50565b611c1561276b565b60008490508073ffffffffffffffffffffffffffffffffffffffff1663d9caed128585856040518463ffffffff1660e01b8152600401611c5793929190613f0e565b600060405180830381600087803b158015611c7157600080fd5b505af1158015611c85573d6000803e3d6000fd5b505050505050505050565b600c602052826000526040600020602052816000526040600020602052806000526040600020600092509250509054906101000a900460ff1681565b60045481565b611cda61276b565b611ce26127b9565b565b60096020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611d1f61276b565b60008290508073ffffffffffffffffffffffffffffffffffffffff166307b7ed99836040518263ffffffff1660e01b8152600401611d5d9190613ed8565b600060405180830381600087803b158015611d7757600080fd5b505af1158015611d8b573d6000803e3d6000fd5b50505050505050565b6000611dbe826001600086815260200190815260200160002060000161281490919063ffffffff16565b905092915050565b611dce61276b565b806006541415611e13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e0a906143a9565b60405180910390fd5b8060068190555050565b6000611e47826001600086815260200190815260200160002060000161282e90919063ffffffff16565b905092915050565b604051611e5b90613ec3565b604051809103902081565b60055481565b611e7461276b565b611e91604051611e8390613ec3565b604051809103902082611e1d565b611ed0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ec790614229565b60405180910390fd5b611eed604051611edf90613ec3565b604051809103902082612320565b8073ffffffffffffffffffffffffffffffffffffffff167f10e1f7ce9fd7d1b90a66d13a2ab3cb8dd7f29f3f8d520b143b063ccfbab6906b60405160405180910390a26004600081548092919060019003919050555050565b6000801b81565b611f55612cdc565b60008460ff1660088567ffffffffffffffff1668ffffffffffffffffff16901b179050600b60008268ffffffffffffffffff1668ffffffffffffffffff16815260200190815260200160002060008481526020019081526020016000206040518060c001604052908160008201548152602001600182015481526020016002820180548060200260200160405190810160405280929190818152602001828054801561205657602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001906001019080831161200c575b50505050508152602001600382018054806020026020016040519081016040528092919081815260200182805480156120e457602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001906001019080831161209a575b505050505081526020016004820160009054906101000a900460ff16600481111561210b57fe5b600481111561211657fe5b81526020016005820154815250509150509392505050565b600260009054906101000a900460ff1681565b60065481565b60075481565b600061216d6001600084815260200190815260200160002060000161285e565b9050919050565b61217c61276b565b826009600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008390508073ffffffffffffffffffffffffffffffffffffffff1663b8fa373684846040518363ffffffff1660e01b815260040161220e929190613f7b565b600060405180830381600087803b15801561222857600080fd5b505af115801561223c573d6000803e3d6000fd5b5050505050505050565b61224e61276b565b61226b60405161225d90613ec3565b604051809103902082611e1d565b156122ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122a290614329565b60405180910390fd5b6122c86040516122ba90613ec3565b604051809103902082611513565b8073ffffffffffffffffffffffffffffffffffffffff167f03580ee9f53a62b7cb409a2cb56f9be87747dd15017afc5cef6eef321e4fb2c560405160405180910390a260046000815480929190600101919050555050565b612347600160008481526020019081526020016000206002015461234261263b565b611e1d565b612386576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161237d906142c9565b60405180910390fd5b61239082826126d7565b5050565b60035481565b6123a261276b565b846009600086815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008590508073ffffffffffffffffffffffffffffffffffffffff1663bba8185a868686866040518563ffffffff1660e01b81526004016124389493929190613fa4565b600060405180830381600087803b15801561245257600080fd5b505af1158015612466573d6000803e3d6000fd5b50505050505050505050565b61247a61276b565b80600860008460ff1660ff16815260200190815260200160002060006101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505050565b6124c661276b565b6124ce612873565b565b6000809054906101000a900460ff161561251f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161251690614309565b60405180910390fd5b565b61252e6000801b33611e1d565b80612552575061255160405161254390613ec3565b604051809103902033611e1d565b5b612591576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161258890614189565b60405180910390fd5b565b60006125d583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506128ce565b905092915050565b6125fa6040516125ec90613ec3565b604051809103902033611e1d565b612639576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161263090614369565b60405180910390fd5b565b600033905090565b61266b816001600085815260200190815260200160002060000161292990919063ffffffff16565b156126d35761267861263b565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b6126ff816001600085815260200190815260200160002060000161295990919063ffffffff16565b156127675761270c61263b565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b6127786000801b33611e1d565b6127b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127ae90614389565b60405180910390fd5b565b6127c16124d0565b60016000806101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2583360405161280a9190613ef3565b60405180910390a1565b60006128238360000183612989565b60001c905092915050565b6000612856836000018373ffffffffffffffffffffffffffffffffffffffff1660001b6129f6565b905092915050565b600061286c82600001612a19565b9050919050565b61287b612a2a565b60008060006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa336040516128c49190613ef3565b60405180910390a1565b6000838311158290612916576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161290d9190614107565b60405180910390fd5b5060008385039050809150509392505050565b6000612951836000018373ffffffffffffffffffffffffffffffffffffffff1660001b612a7a565b905092915050565b6000612981836000018373ffffffffffffffffffffffffffffffffffffffff1660001b612aea565b905092915050565b6000818360000180549050116129d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129cb90614169565b60405180910390fd5b8260000182815481106129e357fe5b9060005260206000200154905092915050565b600080836001016000848152602001908152602001600020541415905092915050565b600081600001805490509050919050565b6000809054906101000a900460ff16612a78576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a6f90614209565b60405180910390fd5b565b6000612a8683836129f6565b612adf578260000182908060018154018082558091505060019003906000526020600020016000909190919091505582600001805490508360010160008481526020019081526020016000208190555060019050612ae4565b600090505b92915050565b60008083600101600084815260200190815260200160002054905060008114612bc65760006001820390506000600186600001805490500390506000866000018281548110612b3557fe5b9060005260206000200154905080876000018481548110612b5257fe5b9060005260206000200181905550600183018760010160008381526020019081526020016000208190555086600001805480612b8a57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050612bcc565b60009150505b92915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10612c1357803560ff1916838001178555612c41565b82800160010185558215612c41579182015b82811115612c40578235825591602001919060010190612c25565b5b509050612c4e9190612d23565b5090565b828054828255906000526020600020908101928215612ccb579160200282015b82811115612cca5782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190612c72565b5b509050612cd89190612d48565b5090565b6040518060c001604052806000801916815260200160008019168152602001606081526020016060815260200160006004811115612d1657fe5b8152602001600081525090565b612d4591905b80821115612d41576000816000905550600101612d29565b5090565b90565b612d8891905b80821115612d8457600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905550600101612d4e565b5090565b90565b600081359050612d9a816146d5565b92915050565b600081359050612daf816146ec565b92915050565b60008083601f840112612dc757600080fd5b8235905067ffffffffffffffff811115612de057600080fd5b602083019150836020820283011115612df857600080fd5b9250929050565b60008083601f840112612e1157600080fd5b8235905067ffffffffffffffff811115612e2a57600080fd5b602083019150836020820283011115612e4257600080fd5b9250929050565b600081359050612e5881614703565b92915050565b600081359050612e6d8161471a565b92915050565b60008083601f840112612e8557600080fd5b8235905067ffffffffffffffff811115612e9e57600080fd5b602083019150836001820283011115612eb657600080fd5b9250929050565b600081359050612ecc81614731565b92915050565b600081359050612ee181614748565b92915050565b600081359050612ef68161475f565b92915050565b600081359050612f0b81614776565b92915050565b600060208284031215612f2357600080fd5b6000612f3184828501612d8b565b91505092915050565b600060208284031215612f4c57600080fd5b6000612f5a84828501612da0565b91505092915050565b60008060408385031215612f7657600080fd5b6000612f8485828601612d8b565b9250506020612f9585828601612d8b565b9150509250929050565b60008060008060808587031215612fb557600080fd5b6000612fc387828801612d8b565b9450506020612fd487828801612d8b565b9350506040612fe587828801612d8b565b9250506060612ff687828801612ebd565b91505092959194509250565b60008060006060848603121561301757600080fd5b600061302586828701612d8b565b935050602061303686828701612e49565b925050604061304786828701612d8b565b9150509250925092565b600080600080600060a0868803121561306957600080fd5b600061307788828901612d8b565b955050602061308888828901612e49565b945050604061309988828901612d8b565b93505060606130aa88828901612e5e565b92505060806130bb88828901612e5e565b9150509295509295909350565b600080600080604085870312156130de57600080fd5b600085013567ffffffffffffffff8111156130f857600080fd5b61310487828801612db5565b9450945050602085013567ffffffffffffffff81111561312357600080fd5b61312f87828801612dff565b925092505092959194509250565b60006020828403121561314f57600080fd5b600061315d84828501612e49565b91505092915050565b6000806040838503121561317957600080fd5b600061318785828601612e49565b925050602061319885828601612d8b565b9150509250929050565b600080604083850312156131b557600080fd5b60006131c385828601612e49565b92505060206131d485828601612ebd565b9150509250929050565b6000602082840312156131f057600080fd5b60006131fe84828501612ebd565b91505092915050565b6000806040838503121561321a57600080fd5b600061322885828601612ed2565b925050602061323985828601612efc565b9150509250929050565b6000806040838503121561325657600080fd5b600061326485828601612ee7565b925050602061327585828601612e49565b9150509250929050565b60008060006060848603121561329457600080fd5b60006132a286828701612ee7565b93505060206132b386828701612e49565b92505060406132c486828701612d8b565b9150509250925092565b6000602082840312156132e057600080fd5b60006132ee84828501612efc565b91505092915050565b6000806000806060858703121561330d57600080fd5b600061331b87828801612efc565b945050602061332c87828801612e49565b935050604085013567ffffffffffffffff81111561334957600080fd5b61335587828801612e73565b925092505092959194509250565b6000806040838503121561337657600080fd5b600061338485828601612efc565b925050602061339585828601612ed2565b9150509250929050565b6000806000606084860312156133b457600080fd5b60006133c286828701612efc565b93505060206133d386828701612ed2565b92505060406133e486828701612e49565b9150509250925092565b6000806000806080858703121561340457600080fd5b600061341287828801612efc565b945050602061342387828801612ed2565b935050604061343487828801612e49565b925050606061344587828801612e49565b91505092959194509250565b60008060008060006080868803121561346957600080fd5b600061347788828901612efc565b955050602061348888828901612ed2565b945050604086013567ffffffffffffffff8111156134a557600080fd5b6134b188828901612e73565b935093505060606134c488828901612e49565b9150509295509295909350565b60006134dd83836134f8565b60208301905092915050565b6134f2816145fc565b82525050565b61350181614523565b82525050565b61351081614523565b82525050565b61352761352282614523565b614686565b82525050565b6000613538826144ac565b61354281856144da565b935061354d8361449c565b8060005b8381101561357e57815161356588826134d1565b9750613570836144cd565b925050600181019050613551565b5085935050505092915050565b61359481614547565b82525050565b6135a381614553565b82525050565b6135b281614553565b82525050565b6135c18161455d565b82525050565b60006135d383856144eb565b93506135e0838584614644565b6135e9836146aa565b840190509392505050565b600061360083856144fc565b935061360d838584614644565b82840190509392505050565b6000613624826144b7565b61362e81856144eb565b935061363e818560208601614653565b613647816146aa565b840191505092915050565b61365b8161460e565b82525050565b61366a8161460e565b82525050565b600061367b826144c2565b6136858185614507565b9350613695818560208601614653565b61369e816146aa565b840191505092915050565b60006136b6601c83614507565b91507f70726f706f73616c20616c7265616479207472616e73666572726564000000006000830152602082019050919050565b60006136f6601683614507565b91507f70726f706f73616c206973206e6f7420616374697665000000000000000000006000830152602082019050919050565b6000613736602283614507565b91507f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60008301527f64730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061379c601e83614507565b91507f73656e646572206973206e6f742072656c61796572206f722061646d696e00006000830152602082019050919050565b60006137dc602683614507565b91507f6c656e677468206f66206164647265737320616e6420616d6f756e747320646960008301527f736d6174636800000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613842602f83614507565b91507f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60008301527f2061646d696e20746f206772616e7400000000000000000000000000000000006020830152604082019050919050565b60006138a8601583614507565b91507f72656c6179657220616c726561647920766f74656400000000000000000000006000830152602082019050919050565b60006138e8601483614507565b91507f5061757361626c653a206e6f74207061757365640000000000000000000000006000830152602082019050919050565b6000613928601f83614507565b91507f6164647220646f65736e277420686176652072656c6179657220726f6c6521006000830152602082019050919050565b6000613968601683614507565b91507f496e636f72726563742066656520737570706c696564000000000000000000006000830152602082019050919050565b60006139a8601b83614507565b91507f6461746120646f65736e2774206d6174636820646174616861736800000000006000830152602082019050919050565b60006139e8601a83614507565b91507f50726f706f73616c20616c72656164792063616e63656c6c65640000000000006000830152602082019050919050565b6000613a28602083614507565b91507f7265736f757263654944206e6f74206d617070656420746f2068616e646c65726000830152602082019050919050565b6000613a68603083614507565b91507f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60008301527f2061646d696e20746f207265766f6b65000000000000000000000000000000006020830152604082019050919050565b6000613ace602083614507565b91507f50726f706f73616c206e6f7420617420657870697279207468726573686f6c646000830152602082019050919050565b6000613b0e601083614507565b91507f5061757361626c653a20706175736564000000000000000000000000000000006000830152602082019050919050565b6000613b4e601e83614507565b91507f6164647220616c7265616479206861732072656c6179657220726f6c652100006000830152602082019050919050565b6000613b8e602a83614507565b91507f70726f706f73616c20616c7265616479207061737365642f657865637574656460008301527f2f63616e63656c6c6564000000000000000000000000000000000000000000006020830152604082019050919050565b6000613bf4602083614507565b91507f73656e64657220646f65736e277420686176652072656c6179657220726f6c656000830152602082019050919050565b6000613c34601e83614507565b91507f73656e64657220646f65736e277420686176652061646d696e20726f6c6500006000830152602082019050919050565b6000613c74601f83614507565b91507f43757272656e742066656520697320657175616c20746f206e657720666565006000830152602082019050919050565b6000613cb4600c83614518565b91507f52454c415945525f524f4c4500000000000000000000000000000000000000006000830152600c82019050919050565b6000613cf4601183614507565b91507f6461746168617368206d69736d617463680000000000000000000000000000006000830152602082019050919050565b6000613d34601983614507565b91507f6e6f2068616e646c657220666f72207265736f757263654944000000000000006000830152602082019050919050565b6000613d74602f83614507565b91507f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560008301527f20726f6c657320666f722073656c6600000000000000000000000000000000006020830152604082019050919050565b600060c083016000830151613de5600086018261359a565b506020830151613df8602086018261359a565b5060408301518482036040860152613e10828261352d565b91505060608301518482036060860152613e2a828261352d565b9150506080830151613e3f6080860182613652565b5060a0830151613e5260a0860182613e5d565b508091505092915050565b613e66816145bc565b82525050565b613e75816145bc565b82525050565b613e84816145c6565b82525050565b613e93816145ef565b82525050565b6000613ea58286613516565b601482019150613eb68284866135f4565b9150819050949350505050565b6000613ece82613ca7565b9150819050919050565b6000602082019050613eed6000830184613507565b92915050565b6000602082019050613f0860008301846134e9565b92915050565b6000606082019050613f236000830186613507565b613f306020830185613507565b613f3d6040830184613e6c565b949350505050565b6000602082019050613f5a600083018461358b565b92915050565b6000602082019050613f7560008301846135a9565b92915050565b6000604082019050613f9060008301856135a9565b613f9d6020830184613507565b9392505050565b6000608082019050613fb960008301876135a9565b613fc66020830186613507565b613fd360408301856135b8565b613fe060608301846135b8565b95945050505050565b6000604082019050613ffe60008301856135a9565b61400b60208301846135a9565b9392505050565b600060808201905061402760008301876135a9565b61403460208301866135a9565b6140416040830185613661565b61404e6060830184613e6c565b95945050505050565b600060408201905061406c60008301866135a9565b818103602083015261407f8184866135c7565b9050949350505050565b600060a08201905061409e60008301896135a9565b6140ab6020830188613e8a565b6140b86040830187613e7b565b6140c560608301866134e9565b81810360808301526140d88184866135c7565b9050979650505050505050565b600060208201905081810360008301526140ff8184613619565b905092915050565b600060208201905081810360008301526141218184613670565b905092915050565b60006020820190508181036000830152614142816136a9565b9050919050565b60006020820190508181036000830152614162816136e9565b9050919050565b6000602082019050818103600083015261418281613729565b9050919050565b600060208201905081810360008301526141a28161378f565b9050919050565b600060208201905081810360008301526141c2816137cf565b9050919050565b600060208201905081810360008301526141e281613835565b9050919050565b600060208201905081810360008301526142028161389b565b9050919050565b60006020820190508181036000830152614222816138db565b9050919050565b600060208201905081810360008301526142428161391b565b9050919050565b600060208201905081810360008301526142628161395b565b9050919050565b600060208201905081810360008301526142828161399b565b9050919050565b600060208201905081810360008301526142a2816139db565b9050919050565b600060208201905081810360008301526142c281613a1b565b9050919050565b600060208201905081810360008301526142e281613a5b565b9050919050565b6000602082019050818103600083015261430281613ac1565b9050919050565b6000602082019050818103600083015261432281613b01565b9050919050565b6000602082019050818103600083015261434281613b41565b9050919050565b6000602082019050818103600083015261436281613b81565b9050919050565b6000602082019050818103600083015261438281613be7565b9050919050565b600060208201905081810360008301526143a281613c27565b9050919050565b600060208201905081810360008301526143c281613c67565b9050919050565b600060208201905081810360008301526143e281613ce7565b9050919050565b6000602082019050818103600083015261440281613d27565b9050919050565b6000602082019050818103600083015261442281613d67565b9050919050565b600060208201905081810360008301526144438184613dcd565b905092915050565b60006020820190506144606000830184613e6c565b92915050565b600060208201905061447b6000830184613e7b565b92915050565b60006020820190506144966000830184613e8a565b92915050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b600061452e8261459c565b9050919050565b60006145408261459c565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6000819050614597826146c8565b919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600067ffffffffffffffff82169050919050565b600068ffffffffffffffffff82169050919050565b600060ff82169050919050565b600061460782614620565b9050919050565b600061461982614589565b9050919050565b600061462b82614632565b9050919050565b600061463d8261459c565b9050919050565b82818337600083830152505050565b60005b83811015614671578082015181840152602081019050614656565b83811115614680576000848401525b50505050565b600061469182614698565b9050919050565b60006146a3826146bb565b9050919050565b6000601f19601f8301169050919050565b60008160601b9050919050565b600581106146d257fe5b50565b6146de81614523565b81146146e957600080fd5b50565b6146f581614535565b811461470057600080fd5b50565b61470c81614553565b811461471757600080fd5b50565b6147238161455d565b811461472e57600080fd5b50565b61473a816145bc565b811461474557600080fd5b50565b614751816145c6565b811461475c57600080fd5b50565b614768816145da565b811461477357600080fd5b50565b61477f816145ef565b811461478a57600080fd5b5056fea264697066735822122092ee93d0430488ea41af1c4bf768ae62eaa23bfacdf509c75a06a36360d24c3764736f6c63430006040033

Verified Source Code Partial Match

Compiler: v0.6.4+commit.1dca32f3 EVM: istanbul Optimization: No
Bridge.sol 1213 lines
// File: contracts/interfaces/IGenericHandler.sol

pragma solidity 0.6.4;

/**
    @title Interface for handler that handles generic deposits and deposit executions.
    @author ChainSafe Systems.
 */
interface IGenericHandler {
    /**
        @notice Correlates {resourceID} with {contractAddress}, {depositFunctionSig}, and {executeFunctionSig}.
        @param resourceID ResourceID to be used when making deposits.
        @param contractAddress Address of contract to be called when a deposit is made and a deposited is executed.
        @param depositFunctionSig Function signature of method to be called in {contractAddress} when a deposit is made.
        @param executeFunctionSig Function signature of method to be called in {contractAddress} when a deposit is executed.
     */
    function setResource(bytes32 resourceID, address contractAddress, bytes4 depositFunctionSig, bytes4 executeFunctionSig) external;
}
// File: contracts/interfaces/IERCHandler.sol

pragma solidity 0.6.4;

/**
    @title Interface to be used with handlers that support ERC20s and ERC721s.
    @author ChainSafe Systems.
 */
interface IERCHandler {
    /**
        @notice Correlates {resourceID} with {contractAddress}.
        @param resourceID ResourceID to be used when making deposits.
        @param contractAddress Address of contract to be called when a deposit is made and a deposited is executed.
     */
    function setResource(bytes32 resourceID, address contractAddress) external;
    /**
        @notice Marks {contractAddress} as mintable/burnable.
        @param contractAddress Address of contract to be used when making or executing deposits.
     */
    function setBurnable(address contractAddress) external;
    /**
        @notice Used to manually release funds from ERC safes.
        @param tokenAddress Address of token contract to release.
        @param recipient Address to release tokens to.
        @param amountOrTokenID Either the amount of ERC20 tokens or the ERC721 token ID to release.
     */
    function withdraw(address tokenAddress, address recipient, uint256 amountOrTokenID) external;
}

// File: contracts/interfaces/IBridge.sol

pragma solidity 0.6.4;

/**
    @title Interface for Bridge contract.
    @author ChainSafe Systems.
 */
interface IBridge {
    /**
        @notice Exposing getter for {_chainID} instead of forcing the use of call.
        @return uint8 The {_chainID} that is currently set for the Bridge contract.
     */
    function _chainID() external returns (uint8);
}
// File: contracts/interfaces/IDepositExecute.sol

pragma solidity 0.6.4;

/**
    @title Interface for handler contracts that support deposits and deposit executions.
    @author ChainSafe Systems.
 */
interface IDepositExecute {
    /**
        @notice It is intended that deposit are made using the Bridge contract.
        @param destinationChainID Chain ID deposit is expected to be bridged to.
        @param depositNonce This value is generated as an ID by the Bridge contract.
        @param depositer Address of account making the deposit in the Bridge contract.
        @param data Consists of additional data needed for a specific deposit.
     */
    function deposit(bytes32 resourceID, uint8 destinationChainID, uint64 depositNonce, address depositer, bytes calldata data) external;

    /**
        @notice It is intended that proposals are executed by the Bridge contract.
        @param data Consists of additional data needed for a specific deposit execution.
     */
    function executeProposal(bytes32 resourceID, bytes calldata data) external;
}

// File: contracts/utils/SafeMath.sol



pragma solidity ^0.6.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * note that this is a stripped down version of open zeppelin's safemath
 * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/SafeMath.sol
 */

contract SafeMath {

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return _sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function _sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

}
// File: contracts/utils/Pausable.sol



pragma solidity ^0.6.0;


/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This is a stripped down version of Open zeppelin's Pausable contract.
 * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/EnumerableSet.sol
 *
 */
contract Pausable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor () internal {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _whenNotPaused();
        _;
    }

    function _whenNotPaused() private view {
        require(!_paused, "Pausable: paused");
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenPaused() {
        _whenPaused();
        _;
    }

    function _whenPaused() private view {
        require(_paused, "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(msg.sender);
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(msg.sender);
    }
}
// File: @openzeppelin/contracts/GSN/Context.sol

pragma solidity ^0.6.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
contract Context {
    // Empty internal constructor, to prevent people from mistakenly deploying
    // an instance of this contract, which should be used via inheritance.
    constructor () internal { }

    function _msgSender() internal view virtual returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

// File: @openzeppelin/contracts/utils/Address.sol

pragma solidity ^0.6.2;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }
}

// File: @openzeppelin/contracts/utils/EnumerableSet.sol

pragma solidity ^0.6.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
 * (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;

        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) { // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            bytes32 lastvalue = set._values[lastIndex];

            // Move the last value to the index where the value to delete is
            set._values[toDeleteIndex] = lastvalue;
            // Update the index for the moved value
            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        require(set._values.length > index, "EnumerableSet: index out of bounds");
        return set._values[index];
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(value)));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(value)));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(value)));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint256(_at(set._inner, index)));
    }


    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }
}

// File: @openzeppelin/contracts/access/AccessControl.sol

pragma solidity ^0.6.0;




/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context {
    using EnumerableSet for EnumerableSet.AddressSet;
    using Address for address;

    struct RoleData {
        EnumerableSet.AddressSet members;
        bytes32 adminRole;
    }

    mapping (bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view returns (bool) {
        return _roles[role].members.contains(account);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view returns (uint256) {
        return _roles[role].members.length();
    }

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
        return _roles[role].members.at(index);
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) public virtual {
        require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");

        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) public virtual {
        require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");

        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        _roles[role].adminRole = adminRole;
    }

    function _grantRole(bytes32 role, address account) private {
        if (_roles[role].members.add(account)) {
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (_roles[role].members.remove(account)) {
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

// File: contracts/Bridge.sol

pragma solidity 0.6.4;
pragma experimental ABIEncoderV2;








/**
    @title Facilitates deposits, creation and votiing of deposit proposals, and deposit executions.
    @author ChainSafe Systems.
 */
contract Bridge is Pausable, AccessControl, SafeMath {

    uint8   public _chainID;
    uint256 public _relayerThreshold;
    uint256 public _totalRelayers;
    uint256 public _totalProposals;
    uint256 public _fee;
    uint256 public _expiry;

    enum Vote {No, Yes}

    enum ProposalStatus {Inactive, Active, Passed, Executed, Cancelled}

    struct Proposal {
        bytes32 _resourceID;
        bytes32 _dataHash;
        address[] _yesVotes;
        address[] _noVotes;
        ProposalStatus _status;
        uint256 _proposedBlock;
    }

    // destinationChainID => number of deposits
    mapping(uint8 => uint64) public _depositCounts;
    // resourceID => handler address
    mapping(bytes32 => address) public _resourceIDToHandlerAddress;
    // depositNonce => destinationChainID => bytes
    mapping(uint64 => mapping(uint8 => bytes)) public _depositRecords;
    // destinationChainID + depositNonce => dataHash => Proposal
    mapping(uint72 => mapping(bytes32 => Proposal)) public _proposals;
    // destinationChainID + depositNonce => dataHash => relayerAddress => bool
    mapping(uint72 => mapping(bytes32 => mapping(address => bool))) public _hasVotedOnProposal;

    event RelayerThresholdChanged(uint indexed newThreshold);
    event RelayerAdded(address indexed relayer);
    event RelayerRemoved(address indexed relayer);
    event Deposit(
        uint8   indexed destinationChainID,
        bytes32 indexed resourceID,
        uint64  indexed depositNonce
    );
    event ProposalEvent(
        uint8           indexed originChainID,
        uint64          indexed depositNonce,
        ProposalStatus  indexed status,
        bytes32 resourceID,
        bytes32 dataHash
    );

    event ProposalVote(
        uint8   indexed originChainID,
        uint64  indexed depositNonce,
        ProposalStatus indexed status,
        bytes32 resourceID
    );

    bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");

    modifier onlyAdmin() {
        _onlyAdmin();
        _;
    }

    modifier onlyAdminOrRelayer() {
        _onlyAdminOrRelayer();
        _;
    }

    modifier onlyRelayers() {
        _onlyRelayers();
        _;
    }

    function _onlyAdminOrRelayer() private {
        require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(RELAYER_ROLE, msg.sender),
            "sender is not relayer or admin");
    }

    function _onlyAdmin() private {
        require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "sender doesn't have admin role");
    }

    function _onlyRelayers() private {
        require(hasRole(RELAYER_ROLE, msg.sender), "sender doesn't have relayer role");
    }

    /**
        @notice Initializes Bridge, creates and grants {msg.sender} the admin role,
        creates and grants {initialRelayers} the relayer role.
        @param chainID ID of chain the Bridge contract exists on.
        @param initialRelayers Addresses that should be initially granted the relayer role.
        @param initialRelayerThreshold Number of votes needed for a deposit proposal to be considered passed.
     */
    constructor (uint8 chainID, address[] memory initialRelayers, uint initialRelayerThreshold, uint256 fee, uint256 expiry) public {
        _chainID = chainID;
        _relayerThreshold = initialRelayerThreshold;
        _fee = fee;
        _expiry = expiry;

        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setRoleAdmin(RELAYER_ROLE, DEFAULT_ADMIN_ROLE);

        uint initialRelayerCount = initialRelayers.length;
        for (uint i; i < initialRelayerCount; i++) {
            grantRole(RELAYER_ROLE, initialRelayers[i]);
            _totalRelayers++;
        }

    }

    /**
        @notice Returns true if {relayer} has the relayer role.
        @param relayer Address to check.
     */
    function isRelayer(address relayer) external view returns (bool) {
        return hasRole(RELAYER_ROLE, relayer);
    }

    /**
        @notice Removes admin role from {msg.sender} and grants it to {newAdmin}.
        @notice Only callable by an address that currently has the admin role.
        @param newAdmin Address that admin role will be granted to.
     */
    function renounceAdmin(address newAdmin) external onlyAdmin {
        grantRole(DEFAULT_ADMIN_ROLE, newAdmin);
        renounceRole(DEFAULT_ADMIN_ROLE, msg.sender);
    }

    /**
        @notice Pauses deposits, proposal creation and voting, and deposit executions.
        @notice Only callable by an address that currently has the admin role.
     */
    function adminPauseTransfers() external onlyAdmin {
        _pause();
    }

    /**
        @notice Unpauses deposits, proposal creation and voting, and deposit executions.
        @notice Only callable by an address that currently has the admin role.
     */
    function adminUnpauseTransfers() external onlyAdmin {
        _unpause();
    }

    /**
        @notice Modifies the number of votes required for a proposal to be considered passed.
        @notice Only callable by an address that currently has the admin role.
        @param newThreshold Value {_relayerThreshold} will be changed to.
        @notice Emits {RelayerThresholdChanged} event.
     */
    function adminChangeRelayerThreshold(uint newThreshold) external onlyAdmin {
        _relayerThreshold = newThreshold;
        emit RelayerThresholdChanged(newThreshold);
    }

    /**
        @notice Grants {relayerAddress} the relayer role and increases {_totalRelayer} count.
        @notice Only callable by an address that currently has the admin role.
        @param relayerAddress Address of relayer to be added.
        @notice Emits {RelayerAdded} event.
     */
    function adminAddRelayer(address relayerAddress) external onlyAdmin {
        require(!hasRole(RELAYER_ROLE, relayerAddress), "addr already has relayer role!");
        grantRole(RELAYER_ROLE, relayerAddress);
        emit RelayerAdded(relayerAddress);
        _totalRelayers++;
    }

    /**
        @notice Removes relayer role for {relayerAddress} and decreases {_totalRelayer} count.
        @notice Only callable by an address that currently has the admin role.
        @param relayerAddress Address of relayer to be removed.
        @notice Emits {RelayerRemoved} event.
     */
    function adminRemoveRelayer(address relayerAddress) external onlyAdmin {
        require(hasRole(RELAYER_ROLE, relayerAddress), "addr doesn't have relayer role!");
        revokeRole(RELAYER_ROLE, relayerAddress);
        emit RelayerRemoved(relayerAddress);
        _totalRelayers--;
    }

    /**
        @notice Sets a new resource for handler contracts that use the IERCHandler interface,
        and maps the {handlerAddress} to {resourceID} in {_resourceIDToHandlerAddress}.
        @notice Only callable by an address that currently has the admin role.
        @param handlerAddress Address of handler resource will be set for.
        @param resourceID ResourceID to be used when making deposits.
        @param tokenAddress Address of contract to be called when a deposit is made and a deposited is executed.
     */
    function adminSetResource(address handlerAddress, bytes32 resourceID, address tokenAddress) external onlyAdmin {
        _resourceIDToHandlerAddress[resourceID] = handlerAddress;
        IERCHandler handler = IERCHandler(handlerAddress);
        handler.setResource(resourceID, tokenAddress);
    }

    /**
        @notice Sets a new resource for handler contracts that use the IGenericHandler interface,
        and maps the {handlerAddress} to {resourceID} in {_resourceIDToHandlerAddress}.
        @notice Only callable by an address that currently has the admin role.
        @param handlerAddress Address of handler resource will be set for.
        @param resourceID ResourceID to be used when making deposits.
        @param contractAddress Address of contract to be called when a deposit is made and a deposited is executed.
     */
    function adminSetGenericResource(
        address handlerAddress,
        bytes32 resourceID,
        address contractAddress,
        bytes4 depositFunctionSig,
        bytes4 executeFunctionSig
    ) external onlyAdmin {
        _resourceIDToHandlerAddress[resourceID] = handlerAddress;
        IGenericHandler handler = IGenericHandler(handlerAddress);
        handler.setResource(resourceID, contractAddress, depositFunctionSig, executeFunctionSig);
    }

    /**
        @notice Sets a resource as burnable for handler contracts that use the IERCHandler interface.
        @notice Only callable by an address that currently has the admin role.
        @param handlerAddress Address of handler resource will be set for.
        @param tokenAddress Address of contract to be called when a deposit is made and a deposited is executed.
     */
    function adminSetBurnable(address handlerAddress, address tokenAddress) external onlyAdmin {
        IERCHandler handler = IERCHandler(handlerAddress);
        handler.setBurnable(tokenAddress);
    }

    /**
        @notice Sets a initial deposit nonce for dest chan, this is used to migrate to a new bridge contract.
        @param chainId Dest chain id.
        @param depositNonce Initial deposit nonce.
    */
    function adminSetDepositNonce(uint8 chainId, uint64 depositNonce) external onlyAdmin {
        _depositCounts[chainId] = depositNonce;
    }

    /**
        @notice Returns a proposal.
        @param originChainID Chain ID deposit originated from.
        @param depositNonce ID of proposal generated by proposal's origin Bridge contract.
        @param dataHash Hash of data to be provided when deposit proposal is executed.
        @return Proposal which consists of:
        - _dataHash Hash of data to be provided when deposit proposal is executed.
        - _yesVotes Number of votes in favor of proposal.
        - _noVotes Number of votes against proposal.
        - _status Current status of proposal.
     */
    function getProposal(uint8 originChainID, uint64 depositNonce, bytes32 dataHash) external view returns (Proposal memory) {
        uint72 nonceAndID = (uint72(depositNonce) << 8) | uint72(originChainID);
        return _proposals[nonceAndID][dataHash];
    }

    /**
        @notice Changes deposit fee.
        @notice Only callable by admin.
        @param newFee Value {_fee} will be updated to.
     */
    function adminChangeFee(uint newFee) external onlyAdmin {
        require(_fee != newFee, "Current fee is equal to new fee");
        _fee = newFee;
    }

    /**
        @notice Used to manually withdraw funds from ERC safes.
        @param handlerAddress Address of handler to withdraw from.
        @param tokenAddress Address of token to withdraw.
        @param recipient Address to withdraw tokens to.
        @param amountOrTokenID Either the amount of ERC20 tokens or the ERC721 token ID to withdraw.
     */
    function adminWithdraw(
        address handlerAddress,
        address tokenAddress,
        address recipient,
        uint256 amountOrTokenID
    ) external onlyAdmin {
        IERCHandler handler = IERCHandler(handlerAddress);
        handler.withdraw(tokenAddress, recipient, amountOrTokenID);
    }

    /**
        @notice Initiates a transfer using a specified handler contract.
        @notice Only callable when Bridge is not paused.
        @param destinationChainID ID of chain deposit will be bridged to.
        @param resourceID ResourceID used to find address of handler to be used for deposit.
        @param data Additional data to be passed to specified handler.
        @notice Emits {Deposit} event.
     */
    function deposit(uint8 destinationChainID, bytes32 resourceID, bytes calldata data) external payable whenNotPaused {
        require(msg.value == _fee, "Incorrect fee supplied");

        address handler = _resourceIDToHandlerAddress[resourceID];
        require(handler != address(0), "resourceID not mapped to handler");

        uint64 depositNonce = ++_depositCounts[destinationChainID];
        _depositRecords[depositNonce][destinationChainID] = data;

        IDepositExecute depositHandler = IDepositExecute(handler);
        depositHandler.deposit(resourceID, destinationChainID, depositNonce, msg.sender, data);

        emit Deposit(destinationChainID, resourceID, depositNonce);
    }

    /**
        @notice When called, {msg.sender} will be marked as voting in favor of proposal.
        @notice Only callable by relayers when Bridge is not paused.
        @param chainID ID of chain deposit originated from.
        @param depositNonce ID of deposited generated by origin Bridge contract.
        @param dataHash Hash of data provided when deposit was made.
        @notice Proposal must not have already been passed or executed.
        @notice {msg.sender} must not have already voted on proposal.
        @notice Emits {ProposalEvent} event with status indicating the proposal status.
        @notice Emits {ProposalVote} event.
     */
    function voteProposal(uint8 chainID, uint64 depositNonce, bytes32 resourceID, bytes32 dataHash) external onlyRelayers whenNotPaused {

        uint72 nonceAndID = (uint72(depositNonce) << 8) | uint72(chainID);
        Proposal storage proposal = _proposals[nonceAndID][dataHash];

        require(_resourceIDToHandlerAddress[resourceID] != address(0), "no handler for resourceID");
        require(uint(proposal._status) <= 1, "proposal already passed/executed/cancelled");
        require(!_hasVotedOnProposal[nonceAndID][dataHash][msg.sender], "relayer already voted");

        if (uint(proposal._status) == 0) {
            ++_totalProposals;
            _proposals[nonceAndID][dataHash] = Proposal({
                _resourceID : resourceID,
                _dataHash : dataHash,
                _yesVotes : new address[](1),
                _noVotes : new address[](0),
                _status : ProposalStatus.Active,
                _proposedBlock : block.number
                });

            proposal._yesVotes[0] = msg.sender;
            emit ProposalEvent(chainID, depositNonce, ProposalStatus.Active, resourceID, dataHash);
        } else {
            if (sub(block.number, proposal._proposedBlock) > _expiry) {
                // if the number of blocks that has passed since this proposal was
                // submitted exceeds the expiry threshold set, cancel the proposal
                proposal._status = ProposalStatus.Cancelled;
                emit ProposalEvent(chainID, depositNonce, ProposalStatus.Cancelled, resourceID, dataHash);
            } else {
                require(dataHash == proposal._dataHash, "datahash mismatch");
                proposal._yesVotes.push(msg.sender);


            }

        }
        if (proposal._status != ProposalStatus.Cancelled) {
            _hasVotedOnProposal[nonceAndID][dataHash][msg.sender] = true;
            emit ProposalVote(chainID, depositNonce, proposal._status, resourceID);

            // If _depositThreshold is set to 1, then auto finalize
            // or if _relayerThreshold has been exceeded
            if (_relayerThreshold <= 1 || proposal._yesVotes.length >= _relayerThreshold) {
                proposal._status = ProposalStatus.Passed;

                emit ProposalEvent(chainID, depositNonce, ProposalStatus.Passed, resourceID, dataHash);
            }
        }

    }

    /**
        @notice Executes a deposit proposal that is considered passed using a specified handler contract.
        @notice Only callable by relayers when Bridge is not paused.
        @param chainID ID of chain deposit originated from.
        @param depositNonce ID of deposited generated by origin Bridge contract.
        @param dataHash Hash of data originally provided when deposit was made.
        @notice Proposal must be past expiry threshold.
        @notice Emits {ProposalEvent} event with status {Cancelled}.
     */
    function cancelProposal(uint8 chainID, uint64 depositNonce, bytes32 dataHash) public onlyAdminOrRelayer {
        uint72 nonceAndID = (uint72(depositNonce) << 8) | uint72(chainID);
        Proposal storage proposal = _proposals[nonceAndID][dataHash];

        require(proposal._status != ProposalStatus.Cancelled, "Proposal already cancelled");
        require(sub(block.number, proposal._proposedBlock) > _expiry, "Proposal not at expiry threshold");

        proposal._status = ProposalStatus.Cancelled;
        emit ProposalEvent(chainID, depositNonce, ProposalStatus.Cancelled, proposal._resourceID, proposal._dataHash);

    }

    /**
        @notice Executes a deposit proposal that is considered passed using a specified handler contract.
        @notice Only callable by relayers when Bridge is not paused.
        @param chainID ID of chain deposit originated from.
        @param resourceID ResourceID to be used when making deposits.
        @param depositNonce ID of deposited generated by origin Bridge contract.
        @param data Data originally provided when deposit was made.
        @notice Proposal must have Passed status.
        @notice Hash of {data} must equal proposal's {dataHash}.
        @notice Emits {ProposalEvent} event with status {Executed}.
     */
    function executeProposal(uint8 chainID, uint64 depositNonce, bytes calldata data, bytes32 resourceID) external onlyRelayers whenNotPaused {
        address handler = _resourceIDToHandlerAddress[resourceID];
        uint72 nonceAndID = (uint72(depositNonce) << 8) | uint72(chainID);
        bytes32 dataHash = keccak256(abi.encodePacked(handler, data));
        Proposal storage proposal = _proposals[nonceAndID][dataHash];

        require(proposal._status != ProposalStatus.Inactive, "proposal is not active");
        require(proposal._status == ProposalStatus.Passed, "proposal already transferred");
        require(dataHash == proposal._dataHash, "data doesn't match datahash");

        proposal._status = ProposalStatus.Executed;

        IDepositExecute depositHandler = IDepositExecute(_resourceIDToHandlerAddress[proposal._resourceID]);
        depositHandler.executeProposal(proposal._resourceID, data);

        emit ProposalEvent(chainID, depositNonce, proposal._status, proposal._resourceID, proposal._dataHash);
    }

    /**
        @notice Transfers eth in the contract to the specified addresses. The parameters addrs and amounts are mapped 1-1.
        This means that the address at index 0 for addrs will receive the amount (in WEI) from amounts at index 0.
        @param addrs Array of addresses to transfer {amounts} to.
        @param amounts Array of amonuts to transfer to {addrs}.
     */
    function transferFunds(address payable[] calldata addrs, uint[] calldata amounts) external onlyAdmin {
        require(addrs.length == amounts.length, "length of address and amounts dismatch");
        uint addrCount = addrs.length;
        for (uint i = 0; i < addrCount; i++) {
            addrs[i].transfer(amounts[i]);
        }
    }

}

Read Contract

DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
RELAYER_ROLE 0x926d7d7f → bytes32
_chainID 0xbeab7131 → uint8
_depositCounts 0x4b0b919d → uint64
_depositRecords 0x3ee7094a → bytes
_expiry 0xc5ec8970 → uint256
_fee 0xc5b37c22 → uint256
_hasVotedOnProposal 0x7febe63f → bool
_proposals 0x50598719 → bytes32, bytes32, uint8, uint256
_relayerThreshold 0xd7a9cd79 → uint256
_resourceIDToHandlerAddress 0x84db809f → address
_totalProposals 0x9d5773e0 → uint256
_totalRelayers 0x802aabe8 → uint256
getProposal 0xa9cf69fa → tuple
getRoleAdmin 0x248a9ca3 → bytes32
getRoleMember 0x9010d07c → address
getRoleMemberCount 0xca15c873 → uint256
hasRole 0x91d14854 → bool
isRelayer 0x541d5548 → bool
paused 0x5c975abb → bool

Write Contract 20 functions

These functions modify contract state and require a wallet transaction to execute.

adminAddRelayer 0xcdb0f73a
address relayerAddress
adminChangeFee 0x91c404ac
uint256 newFee
adminChangeRelayerThreshold 0x4e056005
uint256 newThreshold
adminPauseTransfers 0x80ae1c28
No parameters
adminRemoveRelayer 0x9d82dd63
address relayerAddress
adminSetBurnable 0x8c0c2631
address handlerAddress
address tokenAddress
adminSetDepositNonce 0xedc20c3c
uint8 chainId
uint64 depositNonce
adminSetGenericResource 0xe8437ee7
address handlerAddress
bytes32 resourceID
address contractAddress
bytes4 depositFunctionSig
bytes4 executeFunctionSig
adminSetResource 0xcb10f215
address handlerAddress
bytes32 resourceID
address tokenAddress
adminUnpauseTransfers 0xffaac0eb
No parameters
adminWithdraw 0x780cf004
address handlerAddress
address tokenAddress
address recipient
uint256 amountOrTokenID
cancelProposal 0x17f03ce5
uint8 chainID
uint64 depositNonce
bytes32 dataHash
deposit 0x05e2ca17
uint8 destinationChainID
bytes32 resourceID
bytes data
executeProposal 0x4454b20d
uint8 chainID
uint64 depositNonce
bytes data
bytes32 resourceID
grantRole 0x2f2ff15d
bytes32 role
address account
renounceAdmin 0x5e1fab0f
address newAdmin
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
transferFunds 0x4603ae38
address[] addrs
uint256[] amounts
voteProposal 0x1ff013f1
uint8 chainID
uint64 depositNonce
bytes32 resourceID
bytes32 dataHash

Recent Transactions

No transactions found for this address