text: const Caver = require('caver-js')
  
  const abi = [{"constant":true,"inputs":[],"name":"initialLockupStaking","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_rewardAddress","type":"address"}],"name":"submitUpdateRewardAddress","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_approvedWithdrawalId","type":"uint256"}],"name":"submitCancelApprovedStakingWithdrawal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_id","type":"uint256"}],"name":"getRequestInfo","outputs":[{"name":"","type":"uint8"},{"name":"","type":"bytes32"},{"name":"","type":"bytes32"},{"name":"","type":"bytes32"},{"name":"","type":"address"},{"name":"","type":"address[]"},{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_from","type":"uint256"},{"name":"_to","type":"uint256"},{"name":"_state","type":"uint8"}],"name":"getRequestIds","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"nodeId","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_id","type":"uint256"},{"name":"_functionId","type":"uint8"},{"name":"_firstArg","type":"bytes32"},{"name":"_secondArg","type":"bytes32"},{"name":"_thirdArg","type":"bytes32"}],"name":"revokeConfirmation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getState","outputs":[{"name":"","type":"address"},{"name":"","type":"address"},{"name":"","type":"address"},{"name":"","type":"address[]"},{"name":"","type":"uint256"},{"name":"","type":"uint256[]"},{"name":"","type":"uint256[]"},{"name":"","type":"bool"},{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"withdrawalRequestCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lockupConditions","outputs":[{"name":"allReviewed","type":"bool"},{"name":"reviewedCount","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_admin","type":"address"}],"name":"deleteAdmin","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isInitialized","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_id","type":"uint256"},{"name":"_functionId","type":"uint8"},{"name":"_firstArg","type":"bytes32"},{"name":"_secondArg","type":"bytes32"},{"name":"_thirdArg","type":"bytes32"}],"name":"confirmRequest","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_TYPE","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"submitWithdrawLockupStaking","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"staking","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"clearRequest","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"withdrawLockupStaking","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"MAX_ADMIN","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"requestCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"approveStakingWithdrawal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getLockupStakingInfo","outputs":[{"name":"","type":"uint256[]"},{"name":"","type":"uint256[]"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"depositLockupStakingAndInit","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_approvedWithdrawalId","type":"uint256"}],"name":"withdrawApprovedStaking","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"reviewInitialConditions","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_admin","type":"address"}],"name":"addAdmin","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_index","type":"uint256"}],"name":"getApprovedStakingWithdrawalInfo","outputs":[{"name":"","type":"address"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getReviewers","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"submitApproveStakingWithdrawal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_admin","type":"address"}],"name":"submitDeleteAdmin","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"contractValidator","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"remainingLockupStaking","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_admin","type":"address"}],"name":"submitAddAdmin","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"submitClearRequest","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"rewardAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ONE_WEEK","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_rewardAddress","type":"address"}],"name":"updateRewardAddress","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"requirement","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_requirement","type":"uint256"}],"name":"updateRequirement","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"stakeKlay","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_approvedWithdrawalId","type":"uint256"}],"name":"cancelApprovedStakingWithdrawal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_from","type":"uint256"},{"name":"_to","type":"uint256"},{"name":"_state","type":"uint8"}],"name":"getApprovedStakingWithdrawalIds","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_requirement","type":"uint256"}],"name":"submitUpdateRequirement","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"lastClearedId","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ADDRESS_BOOK_ADDRESS","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"VERSION","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_contractValidator","type":"address"},{"name":"_nodeId","type":"address"},{"name":"_rewardAddress","type":"address"},{"name":"_cnAdminlist","type":"address[]"},{"name":"_requirement","type":"uint256"},{"name":"_unlockTime","type":"uint256[]"},{"name":"_unlockAmount","type":"uint256[]"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"contractType","type":"string"},{"indexed":false,"name":"contractValidator","type":"address"},{"indexed":false,"name":"nodeId","type":"address"},{"indexed":false,"name":"rewardAddress","type":"address"},{"indexed":false,"name":"cnAdminList","type":"address[]"},{"indexed":false,"name":"requirement","type":"uint256"},{"indexed":false,"name":"unlockTime","type":"uint256[]"},{"indexed":false,"name":"unlockAmount","type":"uint256[]"}],"name":"DeployContract","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"}],"name":"ReviewInitialConditions","type":"event"},{"anonymous":false,"inputs":[],"name":"CompleteReviewInitialConditions","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"from","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"DepositLockupStakingAndInit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"id","type":"uint256"},{"indexed":true,"name":"from","type":"address"},{"indexed":false,"name":"functionId","type":"uint8"},{"indexed":false,"name":"firstArg","type":"bytes32"},{"indexed":false,"name":"secondArg","type":"bytes32"},{"indexed":false,"name":"thirdArg","type":"bytes32"}],"name":"SubmitRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"id","type":"uint256"},{"indexed":true,"name":"from","type":"address"},{"indexed":false,"name":"functionId","type":"uint8"},{"indexed":false,"name":"firstArg","type":"bytes32"},{"indexed":false,"name":"secondArg","type":"bytes32"},{"indexed":false,"name":"thirdArg","type":"bytes32"},{"indexed":false,"name":"confirmers","type":"address[]"}],"name":"ConfirmRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"id","type":"uint256"},{"indexed":true,"name":"from","type":"address"},{"indexed":false,"name":"functionId","type":"uint8"},{"indexed":false,"name":"firstArg","type":"bytes32"},{"indexed":false,"name":"secondArg","type":"bytes32"},{"indexed":false,"name":"thirdArg","type":"bytes32"},{"indexed":false,"name":"confirmers","type":"address[]"}],"name":"RevokeConfirmation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"id","type":"uint256"},{"indexed":true,"name":"from","type":"address"},{"indexed":false,"name":"functionId","type":"uint8"},{"indexed":false,"name":"firstArg","type":"bytes32"},{"indexed":false,"name":"secondArg","type":"bytes32"},{"indexed":false,"name":"thirdArg","type":"bytes32"}],"name":"CancelRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"id","type":"uint256"},{"indexed":true,"name":"from","type":"address"},{"indexed":false,"name":"functionId","type":"uint8"},{"indexed":false,"name":"firstArg","type":"bytes32"},{"indexed":false,"name":"secondArg","type":"bytes32"},{"indexed":false,"name":"thirdArg","type":"bytes32"}],"name":"ExecuteRequestSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"id","type":"uint256"},{"indexed":true,"name":"from","type":"address"},{"indexed":false,"name":"functionId","type":"uint8"},{"indexed":false,"name":"firstArg","type":"bytes32"},{"indexed":false,"name":"secondArg","type":"bytes32"},{"indexed":false,"name":"thirdArg","type":"bytes32"}],"name":"ExecuteRequestFailure","type":"event"},{"anonymous":false,"inputs":[],"name":"ClearRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"admin","type":"address"}],"name":"AddAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"admin","type":"address"}],"name":"DeleteAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"requirement","type":"uint256"}],"name":"UpdateRequirement","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"WithdrawLockupStaking","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"approvedWithdrawalId","type":"uint256"},{"indexed":false,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":false,"name":"withdrawableFrom","type":"uint256"}],"name":"ApproveStakingWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"approvedWithdrawalId","type":"uint256"},{"indexed":false,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"CancelApprovedStakingWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"rewardAddress","type":"address"}],"name":"UpdateRewardAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"from","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"StakeKlay","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"approvedWithdrawalId","type":"uint256"},{"indexed":false,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"WithdrawApprovedStaking","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"cnNodeId","type":"address"},{"indexed":false,"name":"prevRewardAddress","type":"address"},{"indexed":false,"name":"curRewardAddress","type":"address"}],"name":"ReviseRewardAddress","type":"event"}]
  
  const bytecode = "60806040523480156200001157600080fd5b506040516200539d3803806200539d83398101604090815281516020830151918301516060840151608085015160a086015160c08701519287018051959794959094929391830192919091019060009081908560328211801590620000765750818111155b80156200008257508015155b80156200008e57508115155b1515620000fc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f496e76616c696420726571756972656d656e742e000000000000000000000000604482015290519081900360640190fd5b89600160a060020a03811615156200017557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f41646472657373206973206e756c6c0000000000000000000000000000000000604482015290519081900360640190fd5b89600160a060020a0381161515620001ee57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f41646472657373206973206e756c6c0000000000000000000000000000000000604482015290519081900360640190fd5b600160a060020a038d1615156200026657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f56616c696461746f72206973206e756c6c2e0000000000000000000000000000604482015290519081900360640190fd5b600160a060020a038d166000908152600260205260408120805460ff1916600117905595505b8951861015620003c157600260008b88815181101515620002a957fe5b6020908102909101810151600160a060020a031682528101919091526040016000205460ff16158015620002ff57508986815181101515620002e757fe5b90602001906020020151600160a060020a0316600014155b15156200036d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f41646472657373206973206e756c6c206f72206e6f7420756e697175652e0000604482015290519081900360640190fd5b6001600260008c898151811015156200038257fe5b602090810291909101810151600160a060020a03168252810191909152604001600020805460ff1916911515919091179055600195909501946200028c565b875115801590620003d25750865115155b8015620003e0575086518851145b15156200044e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f496e76616c696420756e6c6f636b2074696d6520616e6420616d6f756e742e00604482015290519081900360640190fd5b429450600095505b8651861015620005bc5787868151811015156200046f57fe5b6020908102909101015185106200050d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f556e6c6f636b2074696d65206973206e6f7420696e20617363656e64696e672060448201527f6f726465722e0000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b600087878151811015156200051e57fe5b60209081029091010151116200059557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f416d6f756e74206973206e6f7420706f736974697665206e756d6265722e0000604482015290519081900360640190fd5b8786815181101515620005a457fe5b60209081029091010151600190960195945062000456565b8c600660006101000a815481600160a060020a030219169083600160a060020a031602179055508b600e60006101000a815481600160a060020a030219169083600160a060020a031602179055508a600f60006101000a815481600160a060020a030219169083600160a060020a03160217905550896000908051906020019062000649929190620008a4565b5060018990558751620006649060079060208b01906200090e565b5086516200067a9060089060208a01906200090e565b506000600660146101000a81548160ff0219169083151502179055507fb03718e2ed5bd9937371e2b685eccb81e680ebd61609db18f411eb1539ad3aaf6040805190810160405280601181526020017f436e5374616b696e67436f6e74726163740000000000000000000000000000008152508e8e8e8e8e8e8e604051808060200189600160a060020a0316600160a060020a0316815260200188600160a060020a0316600160a060020a0316815260200187600160a060020a0316600160a060020a0316815260200180602001868152602001806020018060200185810385528d818151815260200191508051906020019080838360005b838110156200078d57818101518382015260200162000773565b50505050905090810190601f168015620007bb5780820380516001836020036101000a031916815260200191505b508581038452895181528951602091820191808c01910280838360005b83811015620007f2578181015183820152602001620007d8565b50505050905001858103835287818151815260200191508051906020019060200280838360005b838110156200083357818101518382015260200162000819565b50505050905001858103825286818151815260200191508051906020019060200280838360005b83811015620008745781810151838201526020016200085a565b505050509050019c5050505050505050505050505060405180910390a150505050505050505050505050620009a1565b828054828255906000526020600020908101928215620008fc579160200282015b82811115620008fc5782518254600160a060020a031916600160a060020a03909116178255602090920191600190910190620008c5565b506200090a9291506200095a565b5090565b8280548282559060005260206000209081019282156200094c579160200282015b828111156200094c5782518255916020019190600101906200092f565b506200090a92915062000984565b6200098191905b808211156200090a578054600160a060020a031916815560010162000961565b90565b6200098191905b808211156200090a57600081556001016200098b565b6149ec80620009b16000396000f30060806040526004361061022f5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306704222811461032d578063069135af1461035457806306b35d31146103775780630b8160451461038f5780630fd440ec1461044e578063139d7fed146104bf578063164990f8146104f05780631865c57d1461051757806319e44e32146106725780632429f8a91461068757806327e1f7df146106b7578063392e53cd146106d85780633b2d2aca146107015780634b6a94cc146107285780634b8bc6f8146107b25780634cf088d9146107d65780634f97638f146107eb578063505ebed41461080057806358d65880146108245780635badbe4c146108395780635df8b09a1461084e5780635ecd75f2146108725780636a27c206146109355780636e93df0d1461093d578063702b9c9b14610955578063704802751461096a578063725c05031461098b57806375a87643146109ee5780637818097c14610a03578063791b512314610a275780637a5db06814610a485780637b5e048114610a5d578063863f5c0a14610a7257806387cd9feb14610a935780638cf57cb914610aa85780638e6f6b7714610abd578063944dd5a214610ad2578063b756393014610af3578063c47afb3a14610b08578063c72507e914610b20578063c804b11514610b28578063d2569eb914610b40578063e748357b14610b61578063e7abb98d14610b79578063f2f2f49b14610b8e578063ffa1ad7414610ba3575b60065460a060020a900460ff161515600114610283576040805160e560020a62461bcd02815260206004820152601c6024820152600080516020614961833981519152604482015290519081900360640190fd5b600034116102db576040805160e560020a62461bcd02815260206004820152600f60248201527f496e76616c696420616d6f756e742e0000000000000000000000000000000000604482015290519081900360640190fd5b6010546102ee903463ffffffff610bb816565b6010556040805133815234602082015281517f016a7abf22d0d58c184d5eb406e8e9f6007698168251cf67add43fa4d13768f6929181900390910190a1005b34801561033957600080fd5b50610342610bd1565b60408051918252519081900360200190f35b34801561036057600080fd5b50610375600160a060020a0360043516610bd7565b005b34801561038357600080fd5b50610375600435610d27565b34801561039b57600080fd5b506103a7600435610f27565b604051808860088111156103b757fe5b60ff168152602081018890526040810187905260608101869052600160a060020a038516608082015260a081019060c0018360048111156103f457fe5b60ff168152602001828103825284818151815260200191508051906020019060200280838360005b8381101561043457818101518382015260200161041c565b505050509050019850505050505050505060405180910390f35b34801561045a57600080fd5b5061046f60043560243560ff60443516610ff0565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156104ab578181015183820152602001610493565b505050509050019250505060405180910390f35b3480156104cb57600080fd5b506104d4611118565b60408051600160a060020a039092168252519081900360200190f35b3480156104fc57600080fd5b5061037560043560ff60243516604435606435608435611127565b34801561052357600080fd5b5061052c6113d1565b604051808a600160a060020a0316600160a060020a0316815260200189600160a060020a0316600160a060020a0316815260200188600160a060020a0316600160a060020a03168152602001806020018781526020018060200180602001861515151581526020018515151515815260200184810384528a818151815260200191508051906020019060200280838360005b838110156105d65781810151838201526020016105be565b50505050905001848103835288818151815260200191508051906020019060200280838360005b838110156106155781810151838201526020016105fd565b50505050905001848103825287818151815260200191508051906020019060200280838360005b8381101561065457818101518382015260200161063c565b505050509050019c5050505050505050505050505060405180910390f35b34801561067e57600080fd5b5061034261153a565b34801561069357600080fd5b5061069c611540565b60408051921515835260208301919091528051918290030190f35b3480156106c357600080fd5b50610375600160a060020a036004351661154f565b3480156106e457600080fd5b506106ed6117e1565b604080519115158252519081900360200190f35b34801561070d57600080fd5b5061037560043560ff602435166044356064356084356117f1565b34801561073457600080fd5b5061073d611bec565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561077757818101518382015260200161075f565b50505050905090810190601f1680156107a45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156107be57600080fd5b50610375600160a060020a0360043516602435611c23565b3480156107e257600080fd5b50610342611ded565b3480156107f757600080fd5b50610375611df3565b34801561080c57600080fd5b50610375600160a060020a0360043516602435611ec8565b34801561083057600080fd5b50610342612007565b34801561084557600080fd5b5061034261200c565b34801561085a57600080fd5b50610375600160a060020a0360043516602435612012565b34801561087e57600080fd5b506108876121b0565b604051808060200180602001868152602001858152602001848152602001838103835288818151815260200191508051906020019060200280838360005b838110156108dd5781810151838201526020016108c5565b50505050905001838103825287818151815260200191508051906020019060200280838360005b8381101561091c578181015183820152602001610904565b5050505090500197505050505050505060405180910390f35b610375612384565b34801561094957600080fd5b5061037560043561257c565b34801561096157600080fd5b50610375612931565b34801561097657600080fd5b50610375600160a060020a0360043516612afa565b34801561099757600080fd5b506109a3600435612cd9565b6040518085600160a060020a0316600160a060020a031681526020018481526020018381526020018260028111156109d757fe5b60ff16815260200194505050505060405180910390f35b3480156109fa57600080fd5b5061046f612d0e565b348015610a0f57600080fd5b50610375600160a060020a0360043516602435612ec9565b348015610a3357600080fd5b50610375600160a060020a0360043516613082565b348015610a5457600080fd5b506104d46132b9565b348015610a6957600080fd5b506103426132c8565b348015610a7e57600080fd5b50610375600160a060020a03600435166132ce565b348015610a9f57600080fd5b506103756134dd565b348015610ab457600080fd5b506104d46135d0565b348015610ac957600080fd5b506103426135df565b348015610ade57600080fd5b50610375600160a060020a03600435166135e6565b348015610aff57600080fd5b506103426136fe565b348015610b1457600080fd5b50610375600435613704565b6103756137fd565b348015610b3457600080fd5b506103756004356138fb565b348015610b4c57600080fd5b5061046f60043560243560ff60443516613ac0565b348015610b6d57600080fd5b50610375600435613c28565b348015610b8557600080fd5b50610342613de3565b348015610b9a57600080fd5b506104d4613de9565b348015610baf57600080fd5b50610342613def565b600082820183811015610bca57600080fd5b9392505050565b600c5481565b60065460009060a060020a900460ff161515600114610c2e576040805160e560020a62461bcd02815260206004820152601c6024820152600080516020614961833981519152604482015290519081900360640190fd5b81600160a060020a0381161515610c7d576040805160e560020a62461bcd02815260206004820152600f60248201526000805160206149a1833981519152604482015290519081900360640190fd5b3360008181526002602052604090205460ff161515610cd4576040805160e560020a62461bcd0281526020600482015260156024820152600080516020614921833981519152604482015290519081900360640190fd5b6004549250610cf1836008600160a060020a038716600080613df4565b6000838152600560205260409020805460018201546002830154600390930154610d2193879360ff1692916117f1565b50505050565b60065460009060a060020a900460ff161515600114610d7e576040805160e560020a62461bcd02815260206004820152601c6024820152600080516020614961833981519152604482015290519081900360640190fd5b3360008181526002602052604090205460ff161515610dd5576040805160e560020a62461bcd0281526020600482015260156024820152600080516020614921833981519152604482015290519081900360640190fd5b600083815260126020526040902054600160a060020a03161515610e69576040805160e560020a62461bcd02815260206004820152602260248201527f5769746864726177616c207265717565737420646f6573206e6f74206578697360448201527f742e000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b60008381526012602052604081206003015460ff166002811115610e8957fe5b14610ede576040805160e560020a62461bcd02815260206004820152600e60248201527f496e76616c69642073746174652e000000000000000000000000000000000000604482015290519081900360640190fd5b6004549150610ef282600785600080613df4565b6000828152600560205260409020805460018201546002830154600390930154610f2293869360ff1692916117f1565b505050565b60008181526005602081815260408084208054600182015460028301546003840154600485015460068601549590980180548751818a0281018a019098528088528a998a998a998a996060998b9960ff91821699909890979096600160a060020a039096169590949190921692918491830182828015610fd057602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610fb2575b505050505091509650965096509650965096509650919395979092949650565b6060826000808383158061100657506004548710155b156110115760045493505b8784101561101e57600080fd5b600092508791505b838210156110725785600481111561103a57fe5b60008381526005602052604090206006015460ff16600481111561105a57fe5b1415611067576001830192505b600190910190611026565b8260405190808252806020026020018201604052801561109c578160200160208202803883390190505b509050600092508791505b8382101561110d578560048111156110bb57fe5b60008381526005602052604090206006015460ff1660048111156110db57fe5b1415611102578181848151811015156110f057fe5b60209081029091010152600192909201915b6001909101906110a7565b979650505050505050565b600e54600160a060020a031681565b6000808087600160008281526005602052604090206006015460ff16600481111561114e57fe5b146111a3576040805160e560020a62461bcd02815260206004820152601f60248201527f4d757374206265206174206e6f742d636f6e6669726d65642073746174652e00604482015290519081900360640190fd5b3360008181526002602052604090205460ff1615156111fa576040805160e560020a62461bcd0281526020600482015260156024820152600080516020614921833981519152604482015290519081900360640190fd5b60008a81526005602081905260408220015490955093508492505b8383101561126b5760008a81526005602081905260409091200180548490811061123b57fe5b600091825260209091200154600160a060020a0316331415611260576001945061126b565b600190920191611215565b8415156112c2576040805160e560020a62461bcd02815260206004820152601d60248201527f4d73672e73656e64657220686173206e6f7420636f6e6669726d65642e000000604482015290519081900360640190fd5b8860088111156112ce57fe5b60008b81526005602052604090205460ff1660088111156112eb57fe5b148015611308575060008a81526005602052604090206001015488145b8015611324575060008a81526005602052604090206002015487145b8015611340575060008a81526005602052604090206003015486145b15156113bc576040805160e560020a62461bcd02815260206004820152602760248201527f46756e6374696f6e20696420616e6420617267756d656e747320646f206e6f7460448201527f206d617463682e00000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b6113c58a613f7b565b50505050505050505050565b600654600e54600f5460015460095460008054604080516020808402820181019092528281529297889788976060978997899788978a978897600160a060020a038082169881169716958995909460079460089460ff9384169460a060020a90049093169288919083018282801561147257602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311611454575b50505050509550838054806020026020016040519081016040528092919081815260200182805480156114c457602002820191906000526020600020905b8154815260200190600101908083116114b0575b505050505093508280548060200260200160405190810160405280929190818152602001828054801561151657602002820191906000526020600020905b815481526020019060010190808311611502575b50505050509250985098509850985098509850985098509850909192939495969798565b60115481565b600954600a5460ff9091169082565b600080333014611597576040805160e560020a62461bcd02815260206004820152601b6024820152600080516020614941833981519152604482015290519081900360640190fd5b600160a060020a038316600090815260026020526040902054839060ff1615156115f9576040805160e560020a62461bcd0281526020600482015260156024820152600080516020614921833981519152604482015290519081900360640190fd5b60005461160d90600163ffffffff61412516565b600154603282111580156116215750818111155b801561162c57508015155b801561163757508115155b151561167b576040805160e560020a62461bcd0281526020600482015260146024820152600080516020614981833981519152604482015290519081900360640190fd5b600160a060020a0386166000908152600260205260408120805460ff191690558054955093505b600185038410156117555785600160a060020a03166000858154811015156116c657fe5b600091825260209091200154600160a060020a0316141561174a576000805460001987019081106116f357fe5b60009182526020822001548154600160a060020a0390911691908690811061171757fe5b9060005260206000200160006101000a815481600160a060020a030219169083600160a060020a03160217905550611755565b6001909301926116a2565b60008054600019870190811061176757fe5b600091825260208220018054600160a060020a03191690555461179190600163ffffffff61412516565b61179c600082614856565b506117a5611df3565b604051600160a060020a038716907f1af6bd3d85a56e7c4a0700756fd2ca3b3b65c266e56c77652c5a346bc256522090600090a2505050505050565b60065460a060020a900460ff1681565b60008080606088600160008281526005602052604090206006015460ff16600481111561181a57fe5b1461186f576040805160e560020a62461bcd02815260206004820152601f60248201527f4d757374206265206174206e6f742d636f6e6669726d65642073746174652e00604482015290519081900360640190fd5b3360008181526002602052604090205460ff1615156118c6576040805160e560020a62461bcd0281526020600482015260156024820152600080516020614921833981519152604482015290519081900360640190fd5b60008b81526005602081905260408220015490965094508593505b848410156119375760008b81526005602081905260409091200180548590811061190757fe5b600091825260209091200154600160a060020a031633141561192c5760019550611937565b6001909301926118e1565b851561198d576040805160e560020a62461bcd02815260206004820152601d60248201527f4d73672e73656e64657220616c726561647920636f6e6669726d65642e000000604482015290519081900360640190fd5b89600881111561199957fe5b60008c81526005602052604090205460ff1660088111156119b657fe5b1480156119d3575060008b81526005602052604090206001015489145b80156119ef575060008b81526005602052604090206002015488145b8015611a0b575060008b81526005602052604090206003015487145b1515611a87576040805160e560020a62461bcd02815260206004820152602760248201527f46756e6374696f6e20696420616e6420617267756d656e747320646f206e6f7460448201527f206d617463682e00000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b60008b81526005602081815260408084209092018054600181018255818552828520018054600160a060020a03191633179055928e9052825482518183028101830190935280835291929190830182828015611b0c57602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311611aee575b5050505050925033600160a060020a03168b7f658055f08cf63659025f616b2baf94baf8f4d2ee9c600c2ae722b4b7716cce468c8c8c8c8960405180866008811115611b5457fe5b60ff1681526020808201879052604082018690526060820185905260a08383038101608084019081528551918401919091528451909260c00191858101910280838360005b83811015611bb1578181015183820152602001611b99565b50505050905001965050505050505060405180910390a3611bd18b61413c565b15611bdf57611bdf8b614159565b5050505050505050505050565b60408051808201909152601181527f436e5374616b696e67436f6e7472616374000000000000000000000000000000602082015281565b600654600090819060a060020a900460ff161515600114611c7c576040805160e560020a62461bcd02815260206004820152601c6024820152600080516020614961833981519152604482015290519081900360640190fd5b83600160a060020a0381161515611ccb576040805160e560020a62461bcd02815260206004820152600f60248201526000805160206149a1833981519152604482015290519081900360640190fd5b3360008181526002602052604090205460ff161515611d22576040805160e560020a62461bcd0281526020600482015260156024820152600080516020614921833981519152604482015290519081900360640190fd5b611d2a6121b0565b9750506000881192505081159050611d425750838511155b1515611d98576040805160e560020a62461bcd02815260206004820152600e60248201527f496e76616c69642076616c75652e000000000000000000000000000000000000604482015290519081900360640190fd5b6004549250611db5836005600160a060020a038916886000613df4565b6000838152600560205260409020805460018201546002830154600390930154611de593879360ff1692916117f1565b505050505050565b60105481565b6000333014611e3a576040805160e560020a62461bcd02815260206004820152601b6024820152600080516020614941833981519152604482015290519081900360640190fd5b506003545b600454811015611e9657600160008281526005602052604090206006015460ff166004811115611e6b57fe5b1415611e8e576000818152600560205260409020600601805460ff191660041790555b600101611e3f565b6004546003556040517f907527d30089abd16e30f06ddbbbc18480505176262f19bc16c1fbf9262f9c6b90600090a150565b6000333014611f0f576040805160e560020a62461bcd02815260206004820152601b6024820152600080516020614941833981519152604482015290519081900360640190fd5b611f176121b0565b9450505050828210159050611f76576040805160e560020a62461bcd02815260206004820152601a60248201527f56616c7565206973206e6f7420776974686472617761626c652e000000000000604482015290519081900360640190fd5b600d54611f89908363ffffffff61412516565b600d55604051600160a060020a0384169083156108fc029084906000818181858888f19350505050158015611fc2573d6000803e3d6000fd5b50604080518381529051600160a060020a038516917f2d9d65e4fcab96e158761a8d3cc0bd7fd76951ab5574667b07190da171777470919081900360200190a2505050565b603281565b60045481565b6000333014612059576040805160e560020a62461bcd02815260206004820152601b6024820152600080516020614941833981519152604482015290519081900360640190fd5b6010548211156120b3576040805160e560020a62461bcd02815260206004820152601a60248201527f56616c7565206973206e6f7420776974686472617761626c652e000000000000604482015290519081900360640190fd5b5060115460408051608081018252600160a060020a03858116825260208083018681524284860190815260006060860181815288825260129094529590952084518154600160a060020a03191694169390931783555160018084019190915593516002808401919091559051600383018054949593949193909260ff1990921691849081111561213f57fe5b02179055505060115461215a9150600163ffffffff610bb816565b60115560408051828152600160a060020a038516602082015280820184905242606082015290517fdd0988b8c11a867814c87be652f93a86d35c6a235b92977e99d5394bd8580ced9181900360800190a1505050565b6060806000806000806000806000806000600660149054906101000a900460ff1615156001151514151561221c576040805160e560020a62461bcd02815260206004820152601c6024820152600080516020614961833981519152604482015290519081900360640190fd5b6007544296506000955093508492505b8383101561228f57600780548490811061224257fe5b9060005260206000200154861115612284576008805461228191908590811061226757fe5b906000526020600020015486610bb890919063ffffffff16565b94505b60019092019161222c565b600d54600c546122a49163ffffffff61412516565b91506122b6858363ffffffff61412516565b905060076000016007600101600c54600d54848480548060200260200160405190810160405280929190818152602001828054801561231457602002820191906000526020600020905b815481526020019060010190808311612300575b505050505094508380548060200260200160405190810160405280929190818152602001828054801561236657602002820191906000526020600020905b815481526020019060010190808311612352575b505050505093509a509a509a509a509a505050505050509091929394565b6006546000908190819060a060020a900460ff16156123ed576040805160e560020a62461bcd02815260206004820152601e60248201527f436f6e747261637420686173206265656e20696e697469616c697a65642e0000604482015290519081900360640190fd5b505060085460005b81811015612434576008805461242a91908390811061241057fe5b906000526020600020015484610bb890919063ffffffff16565b92506001016123f5565b60095460ff161515600114612493576040805160e560020a62461bcd02815260206004820152601a60248201527f526576696577696e67206973206e6f742066696e69736865642e000000000000604482015290519081900360640190fd5b3483146124ea576040805160e560020a62461bcd02815260206004820152601560248201527f56616c756520646f6573206e6f74206d617463682e0000000000000000000000604482015290519081900360640190fd5b60068054600160a060020a0316600090815260026020908152604091829020805460ff191690558254600c879055600d87905574ffffffffffffffffffffffffffffffffffffffffff191660a060020a179092558051338152349281019290925280517f2b3c5e8e58d7d1e42ccd071c6f749d53f9ee506020a81fad9ff98140ccccde699281900390910190a1505050565b3360008181526002602052604090205460ff1615156125d3576040805160e560020a62461bcd0281526020600482015260156024820152600080516020614921833981519152604482015290519081900360640190fd5b600082815260126020526040902054600160a060020a03161515612667576040805160e560020a62461bcd02815260206004820152602260248201527f5769746864726177616c207265717565737420646f6573206e6f74206578697360448201527f742e000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b60008281526012602052604081206003015460ff16600281111561268757fe5b146126dc576040805160e560020a62461bcd02815260206004820152600e60248201527f496e76616c69642073746174652e000000000000000000000000000000000000604482015290519081900360640190fd5b6010546000838152601260205260409020600101541115612747576040805160e560020a62461bcd02815260206004820152601a60248201527f56616c7565206973206e6f7420776974686472617761626c652e000000000000604482015290519081900360640190fd5b6000828152601260205260409020600201544210156127b0576040805160e560020a62461bcd02815260206004820152601560248201527f4e6f7420776974686472617761626c65207965742e0000000000000000000000604482015290519081900360640190fd5b60008281526012602052604090206002015462093a800142106128465760008281526012602090815260409182902060038101805460ff1916600217905580546001909101548351868152600160a060020a03909216928201929092528083019190915290517fcc847b5f283b573ff21408ad42cb442f358bbce95269470b05097215598173df916060908290030190a161292d565b60008281526012602052604090206001015460105461286a9163ffffffff61412516565b60105560008281526012602052604080822060038101805460ff1916600190811790915581549101549151600160a060020a03909116926108fc831502929190818181858888f193505050501580156128c7573d6000803e3d6000fd5b5060008281526012602090815260409182902080546001909101548351868152600160a060020a03909216928201929092528083019190915290517f7a2d48d1df1249429730a253e5713a7d7a2024913de2fbccafdf36efdd32bf059181900360600190a15b5050565b3360008181526002602052604090205460ff161515612988576040805160e560020a62461bcd0281526020600482015260156024820152600080516020614921833981519152604482015290519081900360640190fd5b60065460a060020a900460ff16156129ea576040805160e560020a62461bcd02815260206004820152601e60248201527f436f6e747261637420686173206265656e20696e697469616c697a65642e0000604482015290519081900360640190fd5b336000908152600b602052604090205460ff1615612a52576040805160e560020a62461bcd02815260206004820152601c60248201527f4d73672e73656e64657220616c72656164792072657669657765642e00000000604482015290519081900360640190fd5b336000908152600b60205260409020805460ff19166001908117909155600a54612a819163ffffffff610bb816565b600a5560405133907f65d287f4118b03f8cc979b433fd0b2246074200dd5da70c9daf204aaa0da1a2c90600090a2600054600a5460019091011415612af7576009805460ff191660011790556040517f244ff9a3d72b1dc5a4bce7f05fb615395f2a8c7ad6ea525d2bac9030f75d7a9b90600090a15b50565b333014612b3f576040805160e560020a62461bcd02815260206004820152601b6024820152600080516020614941833981519152604482015290519081900360640190fd5b600160a060020a038116600090815260026020526040902054819060ff1615612bb2576040805160e560020a62461bcd02815260206004820152601560248201527f41646d696e20616c7265616479206578697374732e0000000000000000000000604482015290519081900360640190fd5b600054612bc690600163ffffffff610bb816565b60015460328211158015612bda5750818111155b8015612be557508015155b8015612bf057508115155b1515612c34576040805160e560020a62461bcd0281526020600482015260146024820152600080516020614981833981519152604482015290519081900360640190fd5b600160a060020a0384166000818152600260205260408120805460ff19166001908117909155815490810182559080527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563018054600160a060020a0319169091179055612c9f611df3565b604051600160a060020a038516907fad6de4452a631e641cb59902236607946ce9272b9b981f2f80e8d129cb9084ba90600090a250505050565b6000908152601260205260409020805460018201546002830154600390930154600160a060020a039092169390929160ff1690565b6006546060908190600090819060a060020a900460ff1615612d7a576040805160e560020a62461bcd02815260206004820152601e60248201527f436f6e747261637420686173206265656e20696e697469616c697a65642e0000604482015290519081900360640190fd5b600760030154604051908082528060200260200182016040528015612da9578160200160208202803883390190505b50600654600160a060020a03166000908152600b6020526040812054919450925060ff16151560011415612e12576006548351600160a060020a0390911690849084908110612df457fe5b600160a060020a039092166020928302909101909101526001909101905b5060005b600054811015612ec157600760040160008083815481101515612e3557fe5b6000918252602080832090910154600160a060020a0316835282019290925260400190205460ff16151560011415612eb9576000805482908110612e7557fe5b6000918252602090912001548351600160a060020a0390911690849084908110612e9b57fe5b600160a060020a039092166020928302909101909101526001909101905b600101612e16565b509092915050565b60065460009060a060020a900460ff161515600114612f20576040805160e560020a62461bcd02815260206004820152601c6024820152600080516020614961833981519152604482015290519081900360640190fd5b82600160a060020a0381161515612f6f576040805160e560020a62461bcd02815260206004820152600f60248201526000805160206149a1833981519152604482015290519081900360640190fd5b3360008181526002602052604090205460ff161515612fc6576040805160e560020a62461bcd0281526020600482015260156024820152600080516020614921833981519152604482015290519081900360640190fd5b600084118015612fd857506010548411155b151561302e576040805160e560020a62461bcd02815260206004820152600e60248201527f496e76616c69642076616c75652e000000000000000000000000000000000000604482015290519081900360640190fd5b600454925061304b836006600160a060020a038816876000613df4565b600083815260056020526040902080546001820154600283015460039093015461307b93879360ff1692916117f1565b5050505050565b60065460009060a060020a900460ff1615156001146130d9576040805160e560020a62461bcd02815260206004820152601c6024820152600080516020614961833981519152604482015290519081900360640190fd5b600160a060020a038216600090815260026020526040902054829060ff16151561313b576040805160e560020a62461bcd0281526020600482015260156024820152600080516020614921833981519152604482015290519081900360640190fd5b82600160a060020a038116151561318a576040805160e560020a62461bcd02815260206004820152600f60248201526000805160206149a1833981519152604482015290519081900360640190fd5b3360008181526002602052604090205460ff1615156131e1576040805160e560020a62461bcd0281526020600482015260156024820152600080516020614921833981519152604482015290519081900360640190fd5b6000546131f590600163ffffffff61412516565b600154603282111580156132095750818111155b801561321457508015155b801561321f57508115155b1515613263576040805160e560020a62461bcd0281526020600482015260146024820152600080516020614981833981519152604482015290519081900360640190fd5b6004549550613280866002600160a060020a038a16600080613df4565b60008681526005602052604090208054600182015460028301546003909301546132b0938a9360ff1692916117f1565b50505050505050565b600654600160a060020a031681565b600d5481565b60065460009060a060020a900460ff161515600114613325576040805160e560020a62461bcd02815260206004820152601c6024820152600080516020614961833981519152604482015290519081900360640190fd5b600160a060020a038216600090815260026020526040902054829060ff1615613398576040805160e560020a62461bcd02815260206004820152601560248201527f41646d696e20616c7265616479206578697374732e0000000000000000000000604482015290519081900360640190fd5b82600160a060020a03811615156133e7576040805160e560020a62461bcd02815260206004820152600f60248201526000805160206149a1833981519152604482015290519081900360640190fd5b3360008181526002602052604090205460ff16151561343e576040805160e560020a62461bcd0281526020600482015260156024820152600080516020614921833981519152604482015290519081900360640190fd5b60005461345290600163ffffffff610bb816565b600154603282111580156134665750818111155b801561347157508015155b801561347c57508115155b15156134c0576040805160e560020a62461bcd0281526020600482015260146024820152600080516020614981833981519152604482015290519081900360640190fd5b6004549550613280866001600160a060020a038a16600080613df4565b60065460009060a060020a900460ff161515600114613534576040805160e560020a62461bcd02815260206004820152601c6024820152600080516020614961833981519152604482015290519081900360640190fd5b3360008181526002602052604090205460ff16151561358b576040805160e560020a62461bcd0281526020600482015260156024820152600080516020614921833981519152604482015290519081900360640190fd5b6004805492506135a090839060008080613df4565b600082815260056020526040902080546001820154600283015460039093015461292d93869360ff1692916117f1565b600f54600160a060020a031681565b62093a8081565b33301461362b576040805160e560020a62461bcd02815260206004820152601b6024820152600080516020614941833981519152604482015290519081900360640190fd5b600f8054600160a060020a031916600160a060020a038316908117909155604080517f832a2aad0000000000000000000000000000000000000000000000000000000081526004810192909252516104009163832a2aad91602480830192600092919082900301818387803b1580156136a357600080fd5b505af11580156136b7573d6000803e3d6000fd5b5050600f5460408051600160a060020a039092168252517fbe1849831e6775a2022006aeebcc00f70d10bc4202c8187e215ad9e9911f2b069350908190036020019150a150565b60015481565b333014613749576040805160e560020a62461bcd02815260206004820152601b6024820152600080516020614941833981519152604482015290519081900360640190fd5b600054816032821180159061375e5750818111155b801561376957508015155b801561377457508115155b15156137b8576040805160e560020a62461bcd0281526020600482015260146024820152600080516020614981833981519152604482015290519081900360640190fd5b60018390556137c5611df3565b6040805184815290517f8951393946c27b45080aad111464c16c70f3d5e7d24b114a627334441961bf5f9181900360200190a1505050565b60065460a060020a900460ff161515600114613851576040805160e560020a62461bcd02815260206004820152601c6024820152600080516020614961833981519152604482015290519081900360640190fd5b600034116138a9576040805160e560020a62461bcd02815260206004820152600f60248201527f496e76616c696420616d6f756e742e0000000000000000000000000000000000604482015290519081900360640190fd5b6010546138bc903463ffffffff610bb816565b6010556040805133815234602082015281517f016a7abf22d0d58c184d5eb406e8e9f6007698168251cf67add43fa4d13768f6929181900390910190a1565b333014613940576040805160e560020a62461bcd02815260206004820152601b6024820152600080516020614941833981519152604482015290519081900360640190fd5b600081815260126020526040902054600160a060020a031615156139d4576040805160e560020a62461bcd02815260206004820152602260248201527f5769746864726177616c207265717565737420646f6573206e6f74206578697360448201527f742e000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b60008181526012602052604081206003015460ff1660028111156139f457fe5b14613a49576040805160e560020a62461bcd02815260206004820152600e60248201527f496e76616c69642073746174652e000000000000000000000000000000000000604482015290519081900360640190fd5b60008181526012602090815260409182902060038101805460ff1916600217905580546001909101548351858152600160a060020a03909216928201929092528083019190915290517fcc847b5f283b573ff21408ad42cb442f358bbce95269470b05097215598173df916060908290030190a150565b60608260008083831580613ad657506011548710155b15613ae15760115493505b87841015613b39576040805160e560020a62461bcd02815260206004820152600e60248201527f496e76616c696420696e6465782e000000000000000000000000000000000000604482015290519081900360640190fd5b600092508791505b83821015613b8d57856002811115613b5557fe5b60008381526012602052604090206003015460ff166002811115613b7557fe5b1415613b82576001830192505b600190910190613b41565b82604051908082528060200260200182016040528015613bb7578160200160208202803883390190505b509050600092508791505b8382101561110d57856002811115613bd657fe5b60008381526012602052604090206003015460ff166002811115613bf657fe5b1415613c1d57818184815181101515613c0b57fe5b60209081029091010152600192909201915b600190910190613bc2565b60065460009060a060020a900460ff161515600114613c7f576040805160e560020a62461bcd02815260206004820152601c6024820152600080516020614961833981519152604482015290519081900360640190fd5b3360008181526002602052604090205460ff161515613cd6576040805160e560020a62461bcd0281526020600482015260156024820152600080516020614921833981519152604482015290519081900360640190fd5b6000548360328211801590613ceb5750818111155b8015613cf657508015155b8015613d0157508115155b1515613d45576040805160e560020a62461bcd0281526020600482015260146024820152600080516020614981833981519152604482015290519081900360640190fd5b600154851415613d9f576040805160e560020a62461bcd02815260206004820152600d60248201527f496e76616c69642076616c756500000000000000000000000000000000000000604482015290519081900360640190fd5b6004549350613db384600387600080613df4565b600084815260056020526040902080546001820154600283015460039093015461307b93889360ff1692916117f1565b60035481565b61040081565b600181565b60e060405190810160405280856008811115613e0c57fe5b815260208082018690526040808301869052606083018590523360808401528051600080825292810190915260a0909201919050815260200160019052600086815260056020526040902081518154829060ff19166001836008811115613e6f57fe5b0217905550602082810151600183015560408301516002830155606083015160038301556080830151600483018054600160a060020a031916600160a060020a0390921691909117905560a08301518051613ed0926005850192019061487a565b5060c082015160068201805460ff19166001836004811115613eee57fe5b021790555090505033600160a060020a0316857fdd9ce6d431d4ac3e8bea81bc2d7760b97d30c4e54252d8c8c59054849b8f61b58686868660405180856008811115613f3657fe5b60ff168152602081019490945250604080840192909252606083015251908190036080019150a3600454613f7190600163ffffffff610bb816565b6004555050505050565b600081815260056020526040902060040154600160a060020a0316331415614037576000818152600560205260409081902060068101805460ff191660041790558054600182015460028301546003909301549351339486947f01011152a3b44da915f5831c5c63c3448b616dcc166c3543f289ed79645280c99460ff1693929091908085600881111561400b57fe5b60ff168152602081019490945250604080840192909252606083015251908190036080019150a3612af7565b61404181336146f6565b60008181526005602081905260409182902080546001820154600283015460038401549551339688967fed38e5621fac2aa23736077187104abfe9c8aa1c5b4eb73015d8cfdf403fe0709660ff909616959192910190808660088111156140a457fe5b60ff16815260208101869052604081018590526060810184905260a082820381016080830190815284549183018290529160c001908490801561411057602002820191906000526020600020905b8154600160a060020a031681526001909101906020018083116140f2575b5050965050505050505060405180910390a350565b6000808383111561413557600080fd5b5050900390565b600154600082815260056020819052604090912001541015919050565b6000600160008381526005602052604090205460ff16600881111561417a57fe5b14156141e8576000828152600560205260408082206001015481517f70480275000000000000000000000000000000000000000000000000000000008152600160a060020a0390911660048201529051309263704802759260248082019391829003018183875af193505050505b600260008381526005602052604090205460ff16600881111561420757fe5b1415614275576000828152600560205260408082206001015481517f27e1f7df000000000000000000000000000000000000000000000000000000008152600160a060020a039091166004820152905130926327e1f7df9260248082019391829003018183875af193505050505b600360008381526005602052604090205460ff16600881111561429457fe5b14156142fa576000828152600560205260408082206001015481517fc47afb3a00000000000000000000000000000000000000000000000000000000815260048101919091529051309263c47afb3a9260248082019391829003018183875af193505050505b600460008381526005602052604090205460ff16600881111561431957fe5b14156143705730600160a060020a0316634f97638f6040518163ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004016000604051808303816000875af193505050505b600560008381526005602052604090205460ff16600881111561438f57fe5b141561440957600082815260056020526040808220600181015460029091015482517f505ebed4000000000000000000000000000000000000000000000000000000008152600160a060020a03909216600483015260248201529051309263505ebed49260448082019391829003018183875af193505050505b600660008381526005602052604090205460ff16600881111561442857fe5b14156144a257600082815260056020526040808220600181015460029091015482517f5df8b09a000000000000000000000000000000000000000000000000000000008152600160a060020a039092166004830152602482015290513092635df8b09a9260448082019391829003018183875af193505050505b600760008381526005602052604090205460ff1660088111156144c157fe5b1415614527576000828152600560205260408082206001015481517fc804b11500000000000000000000000000000000000000000000000000000000815260048101919091529051309263c804b1159260248082019391829003018183875af193505050505b600860008381526005602052604090205460ff16600881111561454657fe5b14156145b4576000828152600560205260408082206001015481517f944dd5a2000000000000000000000000000000000000000000000000000000008152600160a060020a0390911660048201529051309263944dd5a29260248082019391829003018183875af193505050505b8015614658576000828152600560205260409081902060068101805460ff1916600290811790915581546001830154918301546003909301549351339487947f48f16d9e6ab6f19798a7c7f307ecea3def480049fa0a09280e2a3fa45aaa84269460ff90941693929091908085600881111561462c57fe5b60ff168152602081019490945250604080840192909252606083015251908190036080019150a361292d565b6000828152600560205260409081902060068101805460ff1916600390811790915581546001830154600284015492909301549351339487947fbd3ad69fc5a8e233118506c67ebe892bef493fcf2eb9e6986f6d6c3f2adf0e8a9460ff909416939092909190808560088111156146cb57fe5b60ff168152602081019490945250604080840192909252606083015251908190036080019150a35050565b600082815260056020819052604082200154905b81811015610d215760008481526005602081905260409091200180548290811061473057fe5b600091825260209091200154600160a060020a038481169116141561484e57600019820181146147e0576000848152600560208190526040909120018054600019840190811061477c57fe5b60009182526020808320909101548683526005918290526040909220018054600160a060020a0390921691839081106147b157fe5b9060005260206000200160006101000a815481600160a060020a030219169083600160a060020a031602179055505b6000848152600560208190526040909120018054600019840190811061480257fe5b60009182526020909120018054600160a060020a031916905561482c82600163ffffffff61412516565b6000858152600560208190526040909120614848910182614856565b50610d21565b60010161470a565b815481835581811115610f2257600083815260209020610f229181019083016148df565b8280548282559060005260206000209081019282156148cf579160200282015b828111156148cf5782518254600160a060020a031916600160a060020a0390911617825560209092019160019091019061489a565b506148db9291506148fc565b5090565b6148f991905b808211156148db57600081556001016148e5565b90565b6148f991905b808211156148db578054600160a060020a0319168155600101614902560041646472657373206973206e6f742061646d696e2e00000000000000000000004e6f742061206d756c74697369672d7472616e73616374696f6e2e0000000000436f6e7472616374206973206e6f7420696e697469616c697a65642e00000000496e76616c696420726571756972656d656e742e00000000000000000000000041646472657373206973206e756c6c0000000000000000000000000000000000a165627a7a723058206d9f1e6e6fb0134dd42441ce02facba57ed6684e3040437738f8d7e2db4f74630029" 
  
  const caver = new Caver("http://localhost:8551")
  const privateKey1 = "0x6355336d831705b82e24f0b13f553d9f8ad2d90420478957e57b16b08e47d6e1"
  const addr1 = "0x7b6a8527e0aa483c08fc305cf39a244e65bae545"
  const privateKey2 = "0x396d712edc1547126990664659275fbdab4828d049d04409f346c7581331c4ea"
  const addr2 = "0xa951bd1a6c81fcf38966e036c876752ab97a35e5"
  const privateKey3 = "0x1e8c4101c972e66513fc73b18636e3bcd1fdefe488f2fce606b089d260c73366"
  const addr3 = "0x93b753a3be04b1353b78c0ac221061fcbd48fae0"
  const privateKey4 = "0x30c34401e33c1b1ab0fe3d619b44ce245dbe62824ab0669752ed29deb2905f4e"
  const addr4 = "0x73843d1ed1c9f7ea74cfab3ffe9b4ca2bfbdd815"
  const privateKey5 = "0x09b64fc25b8d7833d4d9236c95399d1ad50085fd32da92c9f0e4cb1584ea7233"
  const addr5 = "0x264e567ae5b9678ce068c8bdd09a599713a678ce"
  const privateKey6 = "0xc90431a4f939387006a8c6f43bec95d77022ae342d695864deefd80a30476c0a"
  const addr6 = "0x6b44ad54e5dbd62d5a6d3ed62ce954a2ba23f2a6"
  
  var u1 = caver.klay.accounts.wallet.add(privateKey1)
  var u2 = caver.klay.accounts.wallet.add(privateKey2)
  var u3 = caver.klay.accounts.wallet.add(privateKey3)
  var u4 = caver.klay.accounts.wallet.add(privateKey4)
  var u5 = caver.klay.accounts.wallet.add(privateKey5)
  var u6 = caver.klay.accounts.wallet.add(privateKey6)
  
  const requestStates = {0:"Unknown", 1:"NotConfirmed", 2:"Executed", 3:"ExecutionFailed", 4:"Canceled", "Unknown":0, "NotConfirmed":1, "Executed":2, "ExecutionFailed":3, "Canceled":4};
  const functionIds = {0:"Unknown", 1:"AddAdmin", 2:"DeleteAdmin", 3:"UpdateRequirement", 4:"ClearRequest", 5:"WithdrawLockupStaking", 6:"ApproveStakingWithdrawal", 7:"CancelApprovedStakingWithdrawal", 8:"UpdateRewardAddress",
  "Unknown":0, "AddAdmin":1, "DeleteAdmin":2, "UpdateRequirement":3, "ClearRequest":4, "WithdrawLockupStaking":5, "ApproveStakingWithdrawal":6, "CancelApprovedStakingWithdrawal":7, "UpdateRewardAddress":8};
  const WithdrawalStakingStates = { 0:"Unknown", 1:"Transferred", 2:"Canceled", "Unknown":0, "Transferred":1, "Canceled":2};
  
  var contractAddr = "0x22D2101dfBD8B6cF19Ad6d04c59027B2Bb1F2d3D";
  var stakingAmount = caver.utils.toPeb(100000, "KLAY")
  var unstakingTo = u6.address;
  var unstakingAmount = 10000;
  var requestId = 0;
  var withdrawalRequestId = 0;
  
  async function fillKlay() {
    // fill up klay first
    console.log("filling up KLAY to accounts...")
    var tx = {
      from: u1.address,
      to: u3.address,
      value: caver.utils.toPeb(100, "KLAY"),
      gas: '0x3b9ac9ff',
    };
    console.log(await caver.klay.sendTransaction(tx));
    var tx = {
      from: u1.address,
      to: u4.address,
      value: caver.utils.toPeb(100, "KLAY"),
      gas: '0x3b9ac9ff',
    };
    console.log(await caver.klay.sendTransaction(tx));
    var tx = {
      from: u1.address,
      to: u5.address,
      value: caver.utils.toPeb(100, "KLAY"),
      gas: '0x3b9ac9ff',
    };
    console.log(await caver.klay.sendTransaction(tx));
  
    console.log("Checking balances...")
    console.log(await caver.klay.getBalance(u1.address));
    console.log(await caver.klay.getBalance(u2.address));
    console.log(await caver.klay.getBalance(u3.address));
    console.log(await caver.klay.getBalance(u4.address));
    console.log(await caver.klay.getBalance(u5.address));
  
  }
  async function deploy() {
    var c = new caver.klay.Contract(abi)
  
    var unlocktime = Math.round(new Date().getTime()/1000+1000);
  
    console.log("Deploying the contract...")
    var p = c.deploy({
      data: bytecode,
      arguments: [u1.address, u2.address, u2.address, [addr2, addr3, addr4, addr5], 2, [unlocktime], [stakingAmount]]
    })
    .send({ from: u1.address, gas: 40000000, value: 0 })
  
    var r = await p;
    contractAddr = r._address;
    console.log("contract addr = " +contractAddr);
  }
  
  async function reviewInitialConditions() {
    var c = new caver.klay.Contract(abi, contractAddr);
  
    console.log("Reviewing the condition and approving the contract...")
  
    console.log(await c.methods.reviewInitialConditions().send({from:u1.address, gas:4000000, value:0}));
    console.log(await c.methods.reviewInitialConditions().send({from:u2.address, gas:4000000, value:0}));
    console.log(await c.methods.reviewInitialConditions().send({from:u3.address, gas:4000000, value:0}));
    console.log(await c.methods.reviewInitialConditions().send({from:u4.address, gas:4000000, value:0}));
    console.log(await c.methods.reviewInitialConditions().send({from:u5.address, gas:4000000, value:0}));
  }
  
  async function init() {
    var c = new caver.klay.Contract(abi, contractAddr);
  
    console.log("Initializing the contract...")
    console.log(await c.methods.depositLockupStakingAndInit().send({from:u1.address, gas:4000000, value:stakingAmount}));
  }
  
  async function stakeKlay() {
    var c = new caver.klay.Contract(abi, contractAddr);
  
    console.log("Staking KLAY...")
    console.log(await c.methods.stakeKlay().send({from:u1.address, gas:4000000, value:caver.utils.toPeb(200000, "KLAY")}));
  }
  
  async function submit() {
    var c = new caver.klay.Contract(abi, contractAddr);
  
    console.log("Submit withdrawal...")
    console.log(await c.methods.submitApproveStakingWithdrawal(unstakingTo, unstakingAmount).send({from:u2.address, gas:4000000, value:0}));
  }
  
  async function getRequestIds(state) {
    var c = new caver.klay.Contract(abi, contractAddr);
  
    console.log("Get request ids from state "+requestStates[state])
  
    return await c.methods.getRequestIds(0,10000,state).call({from:u3.address, gas:4000000, value:0});
  }
  
  async function getRequestInfo(id) {
    var c = new caver.klay.Contract(abi, contractAddr);
  
    console.log("get the request info...")
    var request = await c.methods.getRequestInfo(id).call({from:u2.address, gas:4000000, value:0})
    console.log("functionId: ",request[0], functionIds[request[0]])
    console.log("firstArg: ",request[1])
    console.log("secondArg: ",request[2])
    console.log("thirdArg: ",request[3])
    console.log("requestProposer: ",request[4])
    console.log("confirmers: ",request[5])
    console.log("request state: ",request[6], requestStates[request[6]])
  }
  
  async function getApprovedStakingWithdrawalIds(state) {
    var c = new caver.klay.Contract(abi, contractAddr);
  
    console.log("Get ApprovedStakingWithdrawalIds from state "+WithdrawalStakingStates[state])
    return await c.methods.getApprovedStakingWithdrawalIds(0,10000,state).call({from:u3.address, gas:4000000, value:0});
  }
  
  async function getApprovedStakingWithdrawalInfo(id) {
    var c = new caver.klay.Contract(abi, contractAddr);
  
    console.log("get the request info...")
    var request = await c.methods.getApprovedStakingWithdrawalInfo(id).call({from:u2.address, gas:4000000, value:0})
    console.log("to:", request[0]);
    console.log("value:", request[1])
    console.log("withdrawableFrom(unixtime):", request[2])
    console.log("approval state: ", WithdrawalStakingStates[request[3]])
  }
  
  async function confirm(id) {
    var c = new caver.klay.Contract(abi, contractAddr);
  
    var firstArg = caver.utils.padLeft(unstakingTo,64);
    var secondArg = caver.utils.padLeft(caver.utils.toHex(unstakingAmount),64);
    var thirdArg = caver.utils.padLeft('0x0', 64);
  
    console.log(await c.methods.confirmRequest(id, functionIds.ApproveStakingWithdrawal, firstArg, secondArg, thirdArg).send({from:u3.address, gas:4000000, value:0}));
    // In case of 2-of-4 multisig, only the first confirm is possible. Other confirms will be reverted because the state is not in the not-confirmed state.
    // console.log(await c.methods.confirmRequest(id, functionIds.ApproveStakingWithdrawal, firstArg, secondArg, thirdArg).send({from:u4.address, gas:4000000, value:0}));
    // console.log(await c.methods.confirmRequest(id, functionIds.ApproveStakingWithdrawal, firstArg, secondArg, thirdArg).send({from:u5.address, gas:4000000, value:0}));
  }
  
  async function withdraw(id) {
    var c = new caver.klay.Contract(abi, contractAddr);
  
    var r = await c.methods.withdrawApprovedStaking(id).send({from:u3.address, gas:4000000, value:0});
    console.log(r);
    console.log(r.events.WithdrawApprovedStaking.returnValues)
    console.log(r.events.WithdrawApprovedStaking.raw)
  }
  
  async function fullExec() {
    // filling KLAY before execution.
    await fillKlay();
  
    // Deploy CN staking contract.
    await deploy();
  
    // initialize CN staking contract.
    await reviewInitialConditions();
    await init();
  
    // staking more KLAYs.
    await stakeKlay();
  
    // Submit withdrawal
    await submit();
  
    ids = await getRequestIds(requestStates.NotConfirmed);
    console.log("request Ids=", ids);
    requestId = ids[0];
    await getRequestInfo(requestId);
  
    // confirm the withdrawal
    await confirm(requestId);
    await getRequestInfo(requestId);
  
    ids = await getApprovedStakingWithdrawalIds(WithdrawalStakingStates.Unknown);
    console.log("approval ids =", ids);
    withdrawalRequestId = ids[0];
    await getApprovedStakingWithdrawalInfo(withdrawalRequestId);
  
    // unstake!!!
    console.log("check balance before withdrawal...")
    console.log(await caver.klay.getBalance(u6.address));
  
    await withdraw(withdrawalRequestId);
  
    console.log("check balance after withdrawal...")
    console.log(await caver.klay.getBalance(u6.address));
  
    await getApprovedStakingWithdrawalInfo(withdrawalRequestId);
  }
  
  fullExec();