From 185bd45b194049ea0bfc1446060d9e0a58f76274 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Wed, 16 Aug 2023 12:09:50 +0500 Subject: [PATCH] api authentication added and abi's and constants updated --- package.json | 7 +- src/constants/FiberRouter.json | 676 +++++++++++++++++++++++++++++ src/constants/IERC20.json | 315 ++++++++++++++ src/constants/constants.ts | 84 ++++ src/constants/utils.ts | 0 src/middlewares/auth.middleware.ts | 6 +- 6 files changed, 1085 insertions(+), 3 deletions(-) create mode 100644 src/constants/FiberRouter.json create mode 100644 src/constants/IERC20.json delete mode 100644 src/constants/utils.ts diff --git a/package.json b/package.json index 5384d76..bbcbf56 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,11 @@ "mongoose-autopopulate": "^0.16.0", "winston": "^3.2.1", "jsonwebtoken": "^8.5.1", - "aws-sdk": "^2.1075.0" + "aws-sdk": "^2.1075.0", + "moment": "^2.29.4", + "moment-range": "^4.0.2", + "node-cron": "^2.0.3", + "@cosmjs/cosmwasm-stargate": "^0.30.1", + "crypto": "^1.0.1" } } diff --git a/src/constants/FiberRouter.json b/src/constants/FiberRouter.json new file mode 100644 index 0000000..3473a4f --- /dev/null +++ b/src/constants/FiberRouter.json @@ -0,0 +1,676 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "FiberRouter", + "sourceName": "contracts/upgradeable-Bridge/FiberRouter.sol", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sourceToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "targetToken", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "sourceChainId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "string", + "name": "targetChainId", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "sourceAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "sourceAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "targetAddress", + "type": "string" + } + ], + "name": "NonEvmSwap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sourceToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "targetToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "sourceChainId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "targetChainId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "sourceAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "sourceAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "targetAddress", + "type": "address" + } + ], + "name": "Swap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "name": "Withdraw", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + } + ], + "name": "getFoundryTokenPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "string", + "name": "targetNetwork", + "type": "string" + }, + { + "internalType": "string", + "name": "targetToken", + "type": "string" + }, + { + "internalType": "string", + "name": "targetAddress", + "type": "string" + } + ], + "name": "nonEvmSwap", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "swapRouter", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountCrossMin", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "string", + "name": "crossTargetNetwork", + "type": "string" + }, + { + "internalType": "string", + "name": "crossTargetToken", + "type": "string" + }, + { + "internalType": "string", + "name": "crossTargetAddress", + "type": "string" + } + ], + "name": "nonEvmSwapAndCross", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pool", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "priceFeed", + "outputs": [ + { + "internalType": "contract AggregatorV3Interface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "address", + "name": "_oracleAddress", + "type": "address" + } + ], + "name": "setOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_pool", + "type": "address" + } + ], + "name": "setPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "targetNetwork", + "type": "uint256" + }, + { + "internalType": "address", + "name": "targetToken", + "type": "address" + }, + { + "internalType": "address", + "name": "targetAddress", + "type": "address" + } + ], + "name": "swap", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "swapRouter", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountCrossMin", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "crossTargetNetwork", + "type": "uint256" + }, + { + "internalType": "address", + "name": "crossTargetToken", + "type": "address" + }, + { + "internalType": "address", + "name": "crossTargetAddress", + "type": "address" + } + ], + "name": "swapAndCross", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "swapRouter", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountCrossMin", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "crossTargetNetwork", + "type": "uint256" + }, + { + "internalType": "address", + "name": "crossTargetToken", + "type": "address" + }, + { + "internalType": "address", + "name": "crossTargetAddress", + "type": "address" + } + ], + "name": "swapAndCrossETH", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "payee", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "multiSignature", + "type": "bytes" + } + ], + "name": "withdrawSigned", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "address", + "name": "swapRouter", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "multiSignature", + "type": "bytes" + } + ], + "name": "withdrawSignedAndSwap", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "address", + "name": "swapRouter", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "multiSignature", + "type": "bytes" + } + ], + "name": "withdrawSignedAndSwapETH", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "bridgeFoundry", + "type": "address" + }, + { + "internalType": "address", + "name": "targetFoundry", + "type": "address" + }, + { + "internalType": "address", + "name": "payee", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "multiSignature", + "type": "bytes" + } + ], + "name": "withdrawSignedAndSwapToFoundry", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b50612a0b806100206000396000f3fe60806040526004361061010d5760003560e01c80637c8042f4116100955780638da5cb5b116100645780638da5cb5b146102d95780639f240e7d146102f7578063a81cb92e14610317578063bdb519b414610337578063f2fde38b1461035757610114565b80637c8042f4146102645780638129fc1c146102845780638909d733146102995780638d6e9291146102b957610114565b80634437152a116100dc5780634437152a146101dc578063473b4099146101fc5780635c38eb3a1461020f578063715018a61461022f57806373050a8a1461024457610114565b80630efe792d1461011957806316f0115b1461014c5780631fd48b9a146101845780633364a4e5146101ba57610114565b3661011457005b600080fd5b34801561012557600080fd5b50610139610134366004611fcc565b610377565b6040519081526020015b60405180910390f35b34801561015857600080fd5b5060975461016c906001600160a01b031681565b6040516001600160a01b039091168152602001610143565b34801561019057600080fd5b5061016c61019f366004611fcc565b6098602052600090815260409020546001600160a01b031681565b3480156101c657600080fd5b506101da6101d5366004612135565b6104c4565b005b3480156101e857600080fd5b506101da6101f7366004611fcc565b610829565b6101da61020a3660046121e7565b610853565b34801561021b57600080fd5b506101da61022a366004612004565b610a3b565b34801561023b57600080fd5b506101da610a71565b34801561025057600080fd5b506101da61025f36600461227e565b610a85565b34801561027057600080fd5b506101da61027f36600461242e565b610bf6565b34801561029057600080fd5b506101da610d99565b3480156102a557600080fd5b506101da6102b4366004612370565b610eb2565b3480156102c557600080fd5b506101da6102d43660046120c1565b61101c565b3480156102e557600080fd5b506065546001600160a01b031661016c565b34801561030357600080fd5b506101da610312366004612135565b6110de565b34801561032357600080fd5b506101da610332366004612312565b611281565b34801561034357600080fd5b506101da61035236600461203c565b6113f6565b34801561036357600080fd5b506101da610372366004611fcc565b6114ea565b6001600160a01b03808216600090815260986020526040808220548151633fabe5a360e21b815291519293849391169163feaf968c9160048083019260a0929190829003018186803b1580156103cc57600080fd5b505afa1580156103e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104049190612507565b5050506001600160a01b03808616600090815260986020908152604080832054815163313ce56760e01b81529151959750929550919092169263313ce56792600480840193919291829003018186803b15801561046057600080fd5b505afa158015610474573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104989190612556565b90506104a5816012612945565b6104b090600a61283e565b6104ba908361290f565b925050505b919050565b6001841161050e5760405162461bcd60e51b815260206004820152601260248201527110948e881c185d1a081d1bdbc81cda1bdc9d60721b60448201526064015b60405180910390fd5b6097546001600160a01b0316638d6e9291868660008161053e57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906105539190611fcc565b308a86866040518663ffffffff1660e01b81526004016105779594939291906125bf565b602060405180830381600087803b15801561059157600080fd5b505af11580156105a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c991906124ef565b50848460008181106105eb57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906106009190611fcc565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a082319060240160206040518083038186803b15801561064157600080fd5b505afa158015610655573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067991906124ef565b96508484600081811061069c57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906106b19190611fcc565b60405163095ea7b360e01b81526001600160a01b038a81166004830152602482018a9052919091169063095ea7b390604401602060405180830381600087803b1580156106fd57600080fd5b505af1158015610711573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073591906124cf565b50876001600160a01b0316635c11d795888888888e896040518763ffffffff1660e01b815260040161076c96959493929190612765565b600060405180830381600087803b15801561078657600080fd5b505af115801561079a573d6000803e3d6000fd5b507fddc564cdf1d96bd777ab33f08c46f9281c10a4caf7fd7f841bbfc4a85d55064092508791508690506107cf60018261292e565b8181106107ec57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906108019190611fcc565b8a8885856040516108169594939291906125bf565b60405180910390a1505050505050505050565b610831611560565b609780546001600160a01b0319166001600160a01b0392909216919091179055565b60003490506000896001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561089357600080fd5b505afa1580156108a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108cb9190611fe8565b60405163095ea7b360e01b81526001600160a01b038c81166004830152602482018590529192509082169063095ea7b390604401602060405180830381600087803b15801561091957600080fd5b505af115801561092d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095191906124cf565b50806001600160a01b031663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b15801561098d57600080fd5b505af11580156109a1573d6000803e3d6000fd5b50505050506109b7338b848c8c8c8c8c8c6115ba565b7f36ae4b8940731f7c85b7db5bd11f85e01c730875f98d40504a8ae214393ca58d888860008181106109f957634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610a0e9190611fcc565b854688863389604051610a279796959493929190612604565b60405180910390a150505050505050505050565b610a43611560565b6001600160a01b03918216600090815260986020526040902080546001600160a01b03191691909216179055565b610a79611560565b610a83600061179a565b565b610a9a6001600160a01b0386163330876117ec565b60975460405163095ea7b360e01b81526001600160a01b039182166004820152602481018690529086169063095ea7b390604401602060405180830381600087803b158015610ae857600080fd5b505af1158015610afc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2091906124cf565b5060975460405163ad93428360e01b81526001600160a01b039091169063ad93428390610b5990889088908890889088906004016126ae565b602060405180830381600087803b158015610b7357600080fd5b505af1158015610b87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bab91906124ef565b507fd4ae853fa41178d463a3b92f087a90e2c0f4716a4118223157c78cef74d8c1cc85834686883387604051610be79796959493929190612643565b60405180910390a15050505050565b610bfe61184c565b610c3f86866000818110610c2257634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610c379190611fcc565b33308b6118a6565b975085856000818110610c6257634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610c779190611fcc565b60405163095ea7b360e01b81526001600160a01b038b81166004830152602482018b9052919091169063095ea7b390604401602060405180830381600087803b158015610cc357600080fd5b505af1158015610cd7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cfb91906124cf565b50610d0d338a8a8a8a8a8a8a8a6115ba565b7f36ae4b8940731f7c85b7db5bd11f85e01c730875f98d40504a8ae214393ca58d86866000818110610d4f57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610d649190611fcc565b8346868c3387604051610d7d9796959493929190612604565b60405180910390a1610d8e60018055565b505050505050505050565b600054610100900460ff1615808015610db95750600054600160ff909116105b80610dd35750303b158015610dd3575060005460ff166001145b610e365760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610505565b6000805460ff191660011790558015610e59576000805461ff0019166101001790555b610e61611a3c565b610e69611a6b565b8015610eaf576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b610eba61184c565b610ede86866000818110610c2257634e487b7160e01b600052603260045260246000fd5b975085856000818110610f0157634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610f169190611fcc565b60405163095ea7b360e01b81526001600160a01b038b81166004830152602482018b9052919091169063095ea7b390604401602060405180830381600087803b158015610f6257600080fd5b505af1158015610f76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9a91906124cf565b50610fac818a8a8a8a8a8a8a8a611a9a565b7fd4ae853fa41178d463a3b92f087a90e2c0f4716a4118223157c78cef74d8c1cc86866000818110610fee57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906110039190611fcc565b8346868c3387604051610d7d9796959493929190612643565b609754604051638d6e929160e01b81526001600160a01b0390911690638d6e92919061105490889088908890889088906004016125bf565b602060405180830381600087803b15801561106e57600080fd5b505af1158015611082573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a691906124ef565b507fddc564cdf1d96bd777ab33f08c46f9281c10a4caf7fd7f841bbfc4a85d5506408585858585604051610be79594939291906125bf565b6097546001600160a01b0316638d6e9291868660008161110e57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906111239190611fcc565b308a86866040518663ffffffff1660e01b81526004016111479594939291906125bf565b602060405180830381600087803b15801561116157600080fd5b505af1158015611175573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119991906124ef565b50848460008181106111bb57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906111d09190611fcc565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a082319060240160206040518083038186803b15801561121157600080fd5b505afa158015611225573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061124991906124ef565b9650876001600160a01b031663791ac947888888888e896040518763ffffffff1660e01b815260040161076c96959493929190612765565b6112966001600160a01b0386163330876117ec565b60975460405163095ea7b360e01b81526001600160a01b039182166004820152602481018690529086169063095ea7b390604401602060405180830381600087803b1580156112e457600080fd5b505af11580156112f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131c91906124cf565b506097546040516352f9567d60e01b81526001600160a01b038781166004830152602482018790526044820186905284811660648301528381166084830152909116906352f9567d9060a401602060405180830381600087803b15801561138257600080fd5b505af1158015611396573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ba91906124ef565b507f36ae4b8940731f7c85b7db5bd11f85e01c730875f98d40504a8ae214393ca58d85834686883387604051610be79796959493929190612604565b600061140187610377565b9050600061140e87610377565b905060008161141d848861290f565b61142791906127d8565b609754604051638d6e929160e01b81529192506001600160a01b031690638d6e929190611460908b908b9086908b908b906004016125bf565b602060405180830381600087803b15801561147a57600080fd5b505af115801561148e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114b291906124ef565b507fddc564cdf1d96bd777ab33f08c46f9281c10a4caf7fd7f841bbfc4a85d55064088888888886040516108169594939291906125bf565b6114f2611560565b6001600160a01b0381166115575760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610505565b610eaf8161179a565b6065546001600160a01b03163314610a835760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610505565b604051635c11d79560e01b81526001600160a01b03891690635c11d795906115f0908a908a908a908a9030908b90600401612765565b600060405180830381600087803b15801561160a57600080fd5b505af115801561161e573d6000803e3d6000fd5b506000925087915086905061163460018261292e565b81811061165157634e487b7160e01b600052603260045260246000fd5b90506020020160208101906116669190611fcc565b60975460405163095ea7b360e01b81526001600160a01b039182166004820152602481018a905291925082169063095ea7b390604401602060405180830381600087803b1580156116b657600080fd5b505af11580156116ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ee91906124cf565b506097546040516352f9567d60e01b81526001600160a01b038381166004830152602482018a90526044820186905284811660648301528c81166084830152909116906352f9567d9060a4015b602060405180830381600087803b15801561175557600080fd5b505af1158015611769573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178d91906124ef565b5050505050505050505050565b606580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611846908590611c18565b50505050565b6002600154141561189f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610505565b6002600155565b6040516370a0823160e01b81526001600160a01b03838116600483015260009182918716906370a082319060240160206040518083038186803b1580156118ec57600080fd5b505afa158015611900573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061192491906124ef565b905061193b6001600160a01b0387168686866117ec565b6040516370a0823160e01b81526001600160a01b038581166004830152600091908816906370a082319060240160206040518083038186803b15801561198057600080fd5b505afa158015611994573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119b891906124ef565b90506119c4828261292e565b925083831115611a2c5760405162461bcd60e51b815260206004820152602d60248201527f53413a2061637475616c20616d6f756e74206c6172676572207468616e20747260448201526c185b9cd9995c88185b5bdd5b9d609a1b6064820152608401610505565b5050949350505050565b60018055565b600054610100900460ff16611a635760405162461bcd60e51b81526004016105059061271a565b610a83611cef565b600054610100900460ff16611a925760405162461bcd60e51b81526004016105059061271a565b610a83611d1f565b604051635c11d79560e01b81526001600160a01b03891690635c11d79590611ad0908a908a908a908a9030908b90600401612765565b600060405180830381600087803b158015611aea57600080fd5b505af1158015611afe573d6000803e3d6000fd5b5060009250879150869050611b1460018261292e565b818110611b3157634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611b469190611fcc565b60975460405163095ea7b360e01b81526001600160a01b039182166004820152602481018a905291925082169063095ea7b390604401602060405180830381600087803b158015611b9657600080fd5b505af1158015611baa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bce91906124cf565b50609760009054906101000a90046001600160a01b03166001600160a01b031663ad934283828986868f6040518663ffffffff1660e01b815260040161173b9594939291906126ae565b6000611c6d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611d469092919063ffffffff16565b805190915015611cea5780806020019051810190611c8b91906124cf565b611cea5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610505565b505050565b600054610100900460ff16611d165760405162461bcd60e51b81526004016105059061271a565b610a833361179a565b600054610100900460ff16611a365760405162461bcd60e51b81526004016105059061271a565b6060611d558484600085611d5f565b90505b9392505050565b606082471015611dc05760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610505565b600080866001600160a01b03168587604051611ddc91906125a3565b60006040518083038185875af1925050503d8060008114611e19576040519150601f19603f3d011682016040523d82523d6000602084013e611e1e565b606091505b5091509150611e2f87838387611e3c565b925050505b949350505050565b60608315611ea8578251611ea1576001600160a01b0385163b611ea15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610505565b5081611e34565b611e348383815115611ebd5781518083602001fd5b8060405162461bcd60e51b81526004016105059190612707565b80356104bf816129c0565b60008083601f840112611ef3578182fd5b50813567ffffffffffffffff811115611f0a578182fd5b6020830191508360208083028501011115611f2457600080fd5b9250929050565b600082601f830112611f3b578081fd5b813567ffffffffffffffff80821115611f5657611f566129aa565b604051601f8301601f19908116603f01168101908282118183101715611f7e57611f7e6129aa565b81604052838152866020858801011115611f96578485fd5b8360208701602083013792830160200193909352509392505050565b805169ffffffffffffffffffff811681146104bf57600080fd5b600060208284031215611fdd578081fd5b8135611d58816129c0565b600060208284031215611ff9578081fd5b8151611d58816129c0565b60008060408385031215612016578081fd5b8235612021816129c0565b91506020830135612031816129c0565b809150509250929050565b60008060008060008060c08789031215612054578182fd5b863561205f816129c0565b9550602087013561206f816129c0565b9450604087013561207f816129c0565b9350606087013592506080870135915060a087013567ffffffffffffffff8111156120a8578182fd5b6120b489828a01611f2b565b9150509295509295509295565b600080600080600060a086880312156120d8578081fd5b85356120e3816129c0565b945060208601356120f3816129c0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561211c578182fd5b61212888828901611f2b565b9150509295509295909350565b60008060008060008060008060006101008a8c031215612153578283fd5b893561215e816129c0565b985060208a013561216e816129c0565b975060408a0135965060608a0135955060808a013567ffffffffffffffff80821115612198578485fd5b6121a48d838e01611ee2565b909750955060a08c0135945060c08c0135935060e08c01359150808211156121ca578283fd5b506121d78c828d01611f2b565b9150509295985092959850929598565b60008060008060008060008060e0898b031215612202578384fd5b883561220d816129c0565b975060208901359650604089013567ffffffffffffffff81111561222f578485fd5b61223b8b828c01611ee2565b909750955050606089013593506080890135925060a089013561225d816129c0565b915060c089013561226d816129c0565b809150509295985092959890939650565b600080600080600060a08688031215612295578283fd5b85356122a0816129c0565b945060208601359350604086013567ffffffffffffffff808211156122c3578485fd5b6122cf89838a01611f2b565b945060608801359150808211156122e4578283fd5b6122f089838a01611f2b565b93506080880135915080821115612305578283fd5b5061212888828901611f2b565b600080600080600060a08688031215612329578283fd5b8535612334816129c0565b945060208601359350604086013592506060860135612352816129c0565b91506080860135612362816129c0565b809150509295509295909350565b60008060008060008060008060006101008a8c03121561238e578283fd5b6123978a611ed7565b985060208a0135975060408a0135965060608a013567ffffffffffffffff808211156123c1578485fd5b6123cd8d838e01611ee2565b909850965060808c0135955060a08c01359150808211156123ec578485fd5b6123f88d838e01611f2b565b945060c08c013591508082111561240d578384fd5b6124198d838e01611f2b565b935060e08c01359150808211156121ca578283fd5b60008060008060008060008060006101008a8c03121561244c578283fd5b8935612457816129c0565b985060208a0135975060408a0135965060608a013567ffffffffffffffff811115612480578384fd5b61248c8c828d01611ee2565b90975095505060808a0135935060a08a0135925060c08a01356124ae816129c0565b915060e08a01356124be816129c0565b809150509295985092959850929598565b6000602082840312156124e0578081fd5b81518015158114611d58578182fd5b600060208284031215612500578081fd5b5051919050565b600080600080600060a0868803121561251e578283fd5b61252786611fb2565b945060208601519350604086015192506060860151915061254a60808701611fb2565b90509295509295909350565b600060208284031215612567578081fd5b815160ff81168114611d58578182fd5b6000815180845261258f816020860160208601612968565b601f01601f19169290920160200192915050565b600082516125b5818460208701612968565b9190910192915050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190526000906125f990830184612577565b979650505050505050565b6001600160a01b0397881681529587166020870152604086019490945260608501929092526080840152831660a083015290911660c082015260e00190565b600060018060a01b03808a16835260e0602084015261266560e084018a612577565b886040850152838103606085015261267d8189612577565b905086608085015281861660a085015283810360c085015261269f8186612577565b9b9a5050505050505050505050565b600060018060a01b038716825285602083015260a060408301526126d560a0830186612577565b82810360608401526126e78186612577565b905082810360808401526126fb8185612577565b98975050505050505050565b600060208252611d586020830184612577565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b868152602080820187905260a0604083018190528201859052600090869060c08401835b888110156127b757833561279c816129c0565b6001600160a01b031682529282019290820190600101612789565b506001600160a01b0396909616606085015250505060800152949350505050565b6000826127f357634e487b7160e01b81526012600452602481fd5b500490565b80825b600180861161280a5750612835565b81870482111561281c5761281c612994565b8086161561282957918102915b9490941c9380026127fb565b94509492505050565b6000611d5860001960ff85168460008261285a57506001611d58565b8161286757506000611d58565b816001811461287d5760028114612887576128b4565b6001915050611d58565b60ff84111561289857612898612994565b6001841b9150848211156128ae576128ae612994565b50611d58565b5060208310610133831016604e8410600b84101617156128e7575081810a838111156128e2576128e2612994565b611d58565b6128f484848460016127f8565b80860482111561290657612906612994565b02949350505050565b600081600019048311821515161561292957612929612994565b500290565b60008282101561294057612940612994565b500390565b600060ff821660ff84168082101561295f5761295f612994565b90039392505050565b60005b8381101561298357818101518382015260200161296b565b838111156118465750506000910152565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610eaf57600080fdfea26469706673582212206e61bb8c6c0bbbb3d4df9ce1066fc299a60f13baea2e8795ce13efbac98ab25d64736f6c63430008020033", + "deployedBytecode": "0x60806040526004361061010d5760003560e01c80637c8042f4116100955780638da5cb5b116100645780638da5cb5b146102d95780639f240e7d146102f7578063a81cb92e14610317578063bdb519b414610337578063f2fde38b1461035757610114565b80637c8042f4146102645780638129fc1c146102845780638909d733146102995780638d6e9291146102b957610114565b80634437152a116100dc5780634437152a146101dc578063473b4099146101fc5780635c38eb3a1461020f578063715018a61461022f57806373050a8a1461024457610114565b80630efe792d1461011957806316f0115b1461014c5780631fd48b9a146101845780633364a4e5146101ba57610114565b3661011457005b600080fd5b34801561012557600080fd5b50610139610134366004611fcc565b610377565b6040519081526020015b60405180910390f35b34801561015857600080fd5b5060975461016c906001600160a01b031681565b6040516001600160a01b039091168152602001610143565b34801561019057600080fd5b5061016c61019f366004611fcc565b6098602052600090815260409020546001600160a01b031681565b3480156101c657600080fd5b506101da6101d5366004612135565b6104c4565b005b3480156101e857600080fd5b506101da6101f7366004611fcc565b610829565b6101da61020a3660046121e7565b610853565b34801561021b57600080fd5b506101da61022a366004612004565b610a3b565b34801561023b57600080fd5b506101da610a71565b34801561025057600080fd5b506101da61025f36600461227e565b610a85565b34801561027057600080fd5b506101da61027f36600461242e565b610bf6565b34801561029057600080fd5b506101da610d99565b3480156102a557600080fd5b506101da6102b4366004612370565b610eb2565b3480156102c557600080fd5b506101da6102d43660046120c1565b61101c565b3480156102e557600080fd5b506065546001600160a01b031661016c565b34801561030357600080fd5b506101da610312366004612135565b6110de565b34801561032357600080fd5b506101da610332366004612312565b611281565b34801561034357600080fd5b506101da61035236600461203c565b6113f6565b34801561036357600080fd5b506101da610372366004611fcc565b6114ea565b6001600160a01b03808216600090815260986020526040808220548151633fabe5a360e21b815291519293849391169163feaf968c9160048083019260a0929190829003018186803b1580156103cc57600080fd5b505afa1580156103e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104049190612507565b5050506001600160a01b03808616600090815260986020908152604080832054815163313ce56760e01b81529151959750929550919092169263313ce56792600480840193919291829003018186803b15801561046057600080fd5b505afa158015610474573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104989190612556565b90506104a5816012612945565b6104b090600a61283e565b6104ba908361290f565b925050505b919050565b6001841161050e5760405162461bcd60e51b815260206004820152601260248201527110948e881c185d1a081d1bdbc81cda1bdc9d60721b60448201526064015b60405180910390fd5b6097546001600160a01b0316638d6e9291868660008161053e57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906105539190611fcc565b308a86866040518663ffffffff1660e01b81526004016105779594939291906125bf565b602060405180830381600087803b15801561059157600080fd5b505af11580156105a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c991906124ef565b50848460008181106105eb57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906106009190611fcc565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a082319060240160206040518083038186803b15801561064157600080fd5b505afa158015610655573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067991906124ef565b96508484600081811061069c57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906106b19190611fcc565b60405163095ea7b360e01b81526001600160a01b038a81166004830152602482018a9052919091169063095ea7b390604401602060405180830381600087803b1580156106fd57600080fd5b505af1158015610711573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073591906124cf565b50876001600160a01b0316635c11d795888888888e896040518763ffffffff1660e01b815260040161076c96959493929190612765565b600060405180830381600087803b15801561078657600080fd5b505af115801561079a573d6000803e3d6000fd5b507fddc564cdf1d96bd777ab33f08c46f9281c10a4caf7fd7f841bbfc4a85d55064092508791508690506107cf60018261292e565b8181106107ec57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906108019190611fcc565b8a8885856040516108169594939291906125bf565b60405180910390a1505050505050505050565b610831611560565b609780546001600160a01b0319166001600160a01b0392909216919091179055565b60003490506000896001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561089357600080fd5b505afa1580156108a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108cb9190611fe8565b60405163095ea7b360e01b81526001600160a01b038c81166004830152602482018590529192509082169063095ea7b390604401602060405180830381600087803b15801561091957600080fd5b505af115801561092d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095191906124cf565b50806001600160a01b031663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b15801561098d57600080fd5b505af11580156109a1573d6000803e3d6000fd5b50505050506109b7338b848c8c8c8c8c8c6115ba565b7f36ae4b8940731f7c85b7db5bd11f85e01c730875f98d40504a8ae214393ca58d888860008181106109f957634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610a0e9190611fcc565b854688863389604051610a279796959493929190612604565b60405180910390a150505050505050505050565b610a43611560565b6001600160a01b03918216600090815260986020526040902080546001600160a01b03191691909216179055565b610a79611560565b610a83600061179a565b565b610a9a6001600160a01b0386163330876117ec565b60975460405163095ea7b360e01b81526001600160a01b039182166004820152602481018690529086169063095ea7b390604401602060405180830381600087803b158015610ae857600080fd5b505af1158015610afc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2091906124cf565b5060975460405163ad93428360e01b81526001600160a01b039091169063ad93428390610b5990889088908890889088906004016126ae565b602060405180830381600087803b158015610b7357600080fd5b505af1158015610b87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bab91906124ef565b507fd4ae853fa41178d463a3b92f087a90e2c0f4716a4118223157c78cef74d8c1cc85834686883387604051610be79796959493929190612643565b60405180910390a15050505050565b610bfe61184c565b610c3f86866000818110610c2257634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610c379190611fcc565b33308b6118a6565b975085856000818110610c6257634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610c779190611fcc565b60405163095ea7b360e01b81526001600160a01b038b81166004830152602482018b9052919091169063095ea7b390604401602060405180830381600087803b158015610cc357600080fd5b505af1158015610cd7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cfb91906124cf565b50610d0d338a8a8a8a8a8a8a8a6115ba565b7f36ae4b8940731f7c85b7db5bd11f85e01c730875f98d40504a8ae214393ca58d86866000818110610d4f57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610d649190611fcc565b8346868c3387604051610d7d9796959493929190612604565b60405180910390a1610d8e60018055565b505050505050505050565b600054610100900460ff1615808015610db95750600054600160ff909116105b80610dd35750303b158015610dd3575060005460ff166001145b610e365760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610505565b6000805460ff191660011790558015610e59576000805461ff0019166101001790555b610e61611a3c565b610e69611a6b565b8015610eaf576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b610eba61184c565b610ede86866000818110610c2257634e487b7160e01b600052603260045260246000fd5b975085856000818110610f0157634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610f169190611fcc565b60405163095ea7b360e01b81526001600160a01b038b81166004830152602482018b9052919091169063095ea7b390604401602060405180830381600087803b158015610f6257600080fd5b505af1158015610f76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9a91906124cf565b50610fac818a8a8a8a8a8a8a8a611a9a565b7fd4ae853fa41178d463a3b92f087a90e2c0f4716a4118223157c78cef74d8c1cc86866000818110610fee57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906110039190611fcc565b8346868c3387604051610d7d9796959493929190612643565b609754604051638d6e929160e01b81526001600160a01b0390911690638d6e92919061105490889088908890889088906004016125bf565b602060405180830381600087803b15801561106e57600080fd5b505af1158015611082573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a691906124ef565b507fddc564cdf1d96bd777ab33f08c46f9281c10a4caf7fd7f841bbfc4a85d5506408585858585604051610be79594939291906125bf565b6097546001600160a01b0316638d6e9291868660008161110e57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906111239190611fcc565b308a86866040518663ffffffff1660e01b81526004016111479594939291906125bf565b602060405180830381600087803b15801561116157600080fd5b505af1158015611175573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119991906124ef565b50848460008181106111bb57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906111d09190611fcc565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a082319060240160206040518083038186803b15801561121157600080fd5b505afa158015611225573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061124991906124ef565b9650876001600160a01b031663791ac947888888888e896040518763ffffffff1660e01b815260040161076c96959493929190612765565b6112966001600160a01b0386163330876117ec565b60975460405163095ea7b360e01b81526001600160a01b039182166004820152602481018690529086169063095ea7b390604401602060405180830381600087803b1580156112e457600080fd5b505af11580156112f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131c91906124cf565b506097546040516352f9567d60e01b81526001600160a01b038781166004830152602482018790526044820186905284811660648301528381166084830152909116906352f9567d9060a401602060405180830381600087803b15801561138257600080fd5b505af1158015611396573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ba91906124ef565b507f36ae4b8940731f7c85b7db5bd11f85e01c730875f98d40504a8ae214393ca58d85834686883387604051610be79796959493929190612604565b600061140187610377565b9050600061140e87610377565b905060008161141d848861290f565b61142791906127d8565b609754604051638d6e929160e01b81529192506001600160a01b031690638d6e929190611460908b908b9086908b908b906004016125bf565b602060405180830381600087803b15801561147a57600080fd5b505af115801561148e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114b291906124ef565b507fddc564cdf1d96bd777ab33f08c46f9281c10a4caf7fd7f841bbfc4a85d55064088888888886040516108169594939291906125bf565b6114f2611560565b6001600160a01b0381166115575760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610505565b610eaf8161179a565b6065546001600160a01b03163314610a835760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610505565b604051635c11d79560e01b81526001600160a01b03891690635c11d795906115f0908a908a908a908a9030908b90600401612765565b600060405180830381600087803b15801561160a57600080fd5b505af115801561161e573d6000803e3d6000fd5b506000925087915086905061163460018261292e565b81811061165157634e487b7160e01b600052603260045260246000fd5b90506020020160208101906116669190611fcc565b60975460405163095ea7b360e01b81526001600160a01b039182166004820152602481018a905291925082169063095ea7b390604401602060405180830381600087803b1580156116b657600080fd5b505af11580156116ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ee91906124cf565b506097546040516352f9567d60e01b81526001600160a01b038381166004830152602482018a90526044820186905284811660648301528c81166084830152909116906352f9567d9060a4015b602060405180830381600087803b15801561175557600080fd5b505af1158015611769573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178d91906124ef565b5050505050505050505050565b606580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611846908590611c18565b50505050565b6002600154141561189f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610505565b6002600155565b6040516370a0823160e01b81526001600160a01b03838116600483015260009182918716906370a082319060240160206040518083038186803b1580156118ec57600080fd5b505afa158015611900573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061192491906124ef565b905061193b6001600160a01b0387168686866117ec565b6040516370a0823160e01b81526001600160a01b038581166004830152600091908816906370a082319060240160206040518083038186803b15801561198057600080fd5b505afa158015611994573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119b891906124ef565b90506119c4828261292e565b925083831115611a2c5760405162461bcd60e51b815260206004820152602d60248201527f53413a2061637475616c20616d6f756e74206c6172676572207468616e20747260448201526c185b9cd9995c88185b5bdd5b9d609a1b6064820152608401610505565b5050949350505050565b60018055565b600054610100900460ff16611a635760405162461bcd60e51b81526004016105059061271a565b610a83611cef565b600054610100900460ff16611a925760405162461bcd60e51b81526004016105059061271a565b610a83611d1f565b604051635c11d79560e01b81526001600160a01b03891690635c11d79590611ad0908a908a908a908a9030908b90600401612765565b600060405180830381600087803b158015611aea57600080fd5b505af1158015611afe573d6000803e3d6000fd5b5060009250879150869050611b1460018261292e565b818110611b3157634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611b469190611fcc565b60975460405163095ea7b360e01b81526001600160a01b039182166004820152602481018a905291925082169063095ea7b390604401602060405180830381600087803b158015611b9657600080fd5b505af1158015611baa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bce91906124cf565b50609760009054906101000a90046001600160a01b03166001600160a01b031663ad934283828986868f6040518663ffffffff1660e01b815260040161173b9594939291906126ae565b6000611c6d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611d469092919063ffffffff16565b805190915015611cea5780806020019051810190611c8b91906124cf565b611cea5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610505565b505050565b600054610100900460ff16611d165760405162461bcd60e51b81526004016105059061271a565b610a833361179a565b600054610100900460ff16611a365760405162461bcd60e51b81526004016105059061271a565b6060611d558484600085611d5f565b90505b9392505050565b606082471015611dc05760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610505565b600080866001600160a01b03168587604051611ddc91906125a3565b60006040518083038185875af1925050503d8060008114611e19576040519150601f19603f3d011682016040523d82523d6000602084013e611e1e565b606091505b5091509150611e2f87838387611e3c565b925050505b949350505050565b60608315611ea8578251611ea1576001600160a01b0385163b611ea15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610505565b5081611e34565b611e348383815115611ebd5781518083602001fd5b8060405162461bcd60e51b81526004016105059190612707565b80356104bf816129c0565b60008083601f840112611ef3578182fd5b50813567ffffffffffffffff811115611f0a578182fd5b6020830191508360208083028501011115611f2457600080fd5b9250929050565b600082601f830112611f3b578081fd5b813567ffffffffffffffff80821115611f5657611f566129aa565b604051601f8301601f19908116603f01168101908282118183101715611f7e57611f7e6129aa565b81604052838152866020858801011115611f96578485fd5b8360208701602083013792830160200193909352509392505050565b805169ffffffffffffffffffff811681146104bf57600080fd5b600060208284031215611fdd578081fd5b8135611d58816129c0565b600060208284031215611ff9578081fd5b8151611d58816129c0565b60008060408385031215612016578081fd5b8235612021816129c0565b91506020830135612031816129c0565b809150509250929050565b60008060008060008060c08789031215612054578182fd5b863561205f816129c0565b9550602087013561206f816129c0565b9450604087013561207f816129c0565b9350606087013592506080870135915060a087013567ffffffffffffffff8111156120a8578182fd5b6120b489828a01611f2b565b9150509295509295509295565b600080600080600060a086880312156120d8578081fd5b85356120e3816129c0565b945060208601356120f3816129c0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561211c578182fd5b61212888828901611f2b565b9150509295509295909350565b60008060008060008060008060006101008a8c031215612153578283fd5b893561215e816129c0565b985060208a013561216e816129c0565b975060408a0135965060608a0135955060808a013567ffffffffffffffff80821115612198578485fd5b6121a48d838e01611ee2565b909750955060a08c0135945060c08c0135935060e08c01359150808211156121ca578283fd5b506121d78c828d01611f2b565b9150509295985092959850929598565b60008060008060008060008060e0898b031215612202578384fd5b883561220d816129c0565b975060208901359650604089013567ffffffffffffffff81111561222f578485fd5b61223b8b828c01611ee2565b909750955050606089013593506080890135925060a089013561225d816129c0565b915060c089013561226d816129c0565b809150509295985092959890939650565b600080600080600060a08688031215612295578283fd5b85356122a0816129c0565b945060208601359350604086013567ffffffffffffffff808211156122c3578485fd5b6122cf89838a01611f2b565b945060608801359150808211156122e4578283fd5b6122f089838a01611f2b565b93506080880135915080821115612305578283fd5b5061212888828901611f2b565b600080600080600060a08688031215612329578283fd5b8535612334816129c0565b945060208601359350604086013592506060860135612352816129c0565b91506080860135612362816129c0565b809150509295509295909350565b60008060008060008060008060006101008a8c03121561238e578283fd5b6123978a611ed7565b985060208a0135975060408a0135965060608a013567ffffffffffffffff808211156123c1578485fd5b6123cd8d838e01611ee2565b909850965060808c0135955060a08c01359150808211156123ec578485fd5b6123f88d838e01611f2b565b945060c08c013591508082111561240d578384fd5b6124198d838e01611f2b565b935060e08c01359150808211156121ca578283fd5b60008060008060008060008060006101008a8c03121561244c578283fd5b8935612457816129c0565b985060208a0135975060408a0135965060608a013567ffffffffffffffff811115612480578384fd5b61248c8c828d01611ee2565b90975095505060808a0135935060a08a0135925060c08a01356124ae816129c0565b915060e08a01356124be816129c0565b809150509295985092959850929598565b6000602082840312156124e0578081fd5b81518015158114611d58578182fd5b600060208284031215612500578081fd5b5051919050565b600080600080600060a0868803121561251e578283fd5b61252786611fb2565b945060208601519350604086015192506060860151915061254a60808701611fb2565b90509295509295909350565b600060208284031215612567578081fd5b815160ff81168114611d58578182fd5b6000815180845261258f816020860160208601612968565b601f01601f19169290920160200192915050565b600082516125b5818460208701612968565b9190910192915050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190526000906125f990830184612577565b979650505050505050565b6001600160a01b0397881681529587166020870152604086019490945260608501929092526080840152831660a083015290911660c082015260e00190565b600060018060a01b03808a16835260e0602084015261266560e084018a612577565b886040850152838103606085015261267d8189612577565b905086608085015281861660a085015283810360c085015261269f8186612577565b9b9a5050505050505050505050565b600060018060a01b038716825285602083015260a060408301526126d560a0830186612577565b82810360608401526126e78186612577565b905082810360808401526126fb8185612577565b98975050505050505050565b600060208252611d586020830184612577565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b868152602080820187905260a0604083018190528201859052600090869060c08401835b888110156127b757833561279c816129c0565b6001600160a01b031682529282019290820190600101612789565b506001600160a01b0396909616606085015250505060800152949350505050565b6000826127f357634e487b7160e01b81526012600452602481fd5b500490565b80825b600180861161280a5750612835565b81870482111561281c5761281c612994565b8086161561282957918102915b9490941c9380026127fb565b94509492505050565b6000611d5860001960ff85168460008261285a57506001611d58565b8161286757506000611d58565b816001811461287d5760028114612887576128b4565b6001915050611d58565b60ff84111561289857612898612994565b6001841b9150848211156128ae576128ae612994565b50611d58565b5060208310610133831016604e8410600b84101617156128e7575081810a838111156128e2576128e2612994565b611d58565b6128f484848460016127f8565b80860482111561290657612906612994565b02949350505050565b600081600019048311821515161561292957612929612994565b500290565b60008282101561294057612940612994565b500390565b600060ff821660ff84168082101561295f5761295f612994565b90039392505050565b60005b8381101561298357818101518382015260200161296b565b838111156118465750506000910152565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610eaf57600080fdfea26469706673582212206e61bb8c6c0bbbb3d4df9ce1066fc299a60f13baea2e8795ce13efbac98ab25d64736f6c63430008020033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/src/constants/IERC20.json b/src/constants/IERC20.json new file mode 100644 index 0000000..1a66a3f --- /dev/null +++ b/src/constants/IERC20.json @@ -0,0 +1,315 @@ +[ + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "account", + "type": "address" + }, + { + "name": "amount", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "recipient", + "type": "address" + }, + { + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "sender", + "type": "address" + }, + { + "name": "recipient", + "type": "address" + }, + { + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "from", + "type": "address" + }, + { + "indexed": true, + "name": "to", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "constant": true, + "inputs": [ + { + "name": "owner", + "type": "address" + }, + { + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "INITIAL_SUPPLY", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 1dba483..7d67d2d 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -1,4 +1,12 @@ +import moment from "moment"; +var crypto = require("crypto"); +var CryptoJS = require("crypto-js"); + +export const NAME = "FERRUM_TOKEN_BRIDGE_POOL"; +export const VERSION = "000.004"; +export const CUDOS_CHAIN_ID = "cudos-1"; let SECURITY_KEY = ""; +export const THRESHOLD = 10; export const getSecurityKey = function () { return SECURITY_KEY; @@ -7,3 +15,79 @@ export const getSecurityKey = function () { export const setSecurityKey = function (securityKey: string) { SECURITY_KEY = securityKey; }; + +export const createAuthToken = async function () { + let timelapse = 5; + let currentTime = new Date(); + let startDateTime = moment(currentTime) + .subtract("minutes", timelapse) + .utc() + .format(); + let endDateTime = moment(currentTime) + .add("minutes", timelapse) + .utc() + .format(); + let randomKey = crypto.randomBytes(512).toString("hex"); + let apiKey = (global as any).environment.apiKeyForGateway; + let tokenBody: any = {}; + tokenBody.startDateTime = startDateTime; + tokenBody.endDateTime = endDateTime; + tokenBody.randomKey = randomKey; + tokenBody.apiKey = apiKey; + + let strTokenBody = JSON.stringify(tokenBody); + let encryptedSessionToken = encryptApiKey(strTokenBody); + return encryptedSessionToken; +}; + +export const encryptApiKey = function (data: any) { + try { + var ciphertext = CryptoJS.AES.encrypt( + data, + (global as any).AWS_ENVIRONMENT.SECRET_KEY + ).toString(); + return ciphertext; + } catch (e) { + console.log(e); + return ""; + } +}; + +export const NETWORKS = [ + { + chainId: "56", + fundManagerAddress: "0x6EBED6276033A33b6C6d60e515BF18E979976668", + fiberRouterAddress: "0xd66C6a8277B4E258b4B6023F5B4085af00AfA9bB", + foundaryTokenAddress: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d", + }, + { + chainId: "250", + fundManagerAddress: "0x354CBFc2894d45a584a9Fd0223cf58495cE3cF7F", + fiberRouterAddress: "0xAA209557B51C28a8D050fB500e67498EB3d1d92b", + foundaryTokenAddress: "0x04068DA6C83AFCFA0e13ba15A6696662335D5B75", + }, + { + chainId: "137", + fundManagerAddress: "0xe54B5835e8aba22D52BF892b23Bb491E0bB1b579", + fiberRouterAddress: "0x704D29c86fD1347446c5F30f80E77B31Dc67539f", + foundaryTokenAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", + }, + { + chainId: "42161", + fundManagerAddress: "0xcfddF60db000D49d0F2dafd7eDB08Fca177F1A1E", + fiberRouterAddress: "0x0d618f4632C135e05d9fD795bab021e7DD3187c4", + foundaryTokenAddress: "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", + }, + { + chainId: "43114", + fundManagerAddress: "0x81A536479Af0FE02Ec2aC6BB59Db305aa72a774f", + fiberRouterAddress: "0x066599eD3abB7Eaf517119d376254af13871e5B1", + foundaryTokenAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E", + }, + { + chainId: "245022934", + fundManagerAddress: "0xE6ff690CC7B91A2B626F7A76Fe507028bc1Eb12D", + fiberRouterAddress: "0x2234157B16637AfA6f1A7C1C34b1b80D82b50D82", + foundaryTokenAddress: "0xea6b04272f9f62f997f666f07d3a974134f7ffb9", + }, +]; diff --git a/src/constants/utils.ts b/src/constants/utils.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/middlewares/auth.middleware.ts b/src/middlewares/auth.middleware.ts index b8a4f13..840bcc3 100755 --- a/src/middlewares/auth.middleware.ts +++ b/src/middlewares/auth.middleware.ts @@ -11,11 +11,13 @@ const auth = } else { try { const token = req.headers.authorization.split(" ")[1]; - next(); + if (token && token == (global as any).AWS_ENVIRONMENT.API_KEY) { + next(); + } } catch (error) { (global as any).log.error(error); - return res.http401(invalidToken); } + return res.http401(invalidToken); } }; export default auth;