def execute_timelocks(self, timelock_ids): sp.set_type(timelock_ids, sp.TList(sp.TNat)) sp.for timelock_id in timelock_ids: timelocked_execution_request = self.data.timelocked_execution_requests[timelock_id] sp.verify(timelocked_execution_request.creation_timestamp.add_seconds(sp.to_int(self.data.timelock_seconds)) < sp.now) sp.add_operations(timelocked_execution_request.execution_request.execution_payload(sp.unit).rev()) del self.data.timelocked_execution_requests[timelock_id]
def runLambda(self, lambdaToExecute): sp.set_type(lambdaToExecute, sp.TLambda(sp.TUnit, sp.TList(sp.TOperation))) # Can only be called by the DAO. sp.verify(sp.sender == self.data.daoAddress, "NOT_DAO") # Execute Request operations = lambdaToExecute(sp.unit) sp.set_type(operations, sp.TList(sp.TOperation)) sp.add_operations(operations)
self.operator_public_keys = operator_public_keys self.init(**self.get_init_storage()) @sp.entry_point def execute(self, execution_request): sp.set_type(execution_request, ExecutionRequest.get_type()) signing_payload = ExecutionRequest.get_signing_payload(sp.chain_id, sp.self_address, self.data.nonce+sp.nat(1), execution_request.execution_payload) valid_signatures_counter = sp.local('valid_signatures_counter', sp.nat(0)) sp.for operator_public_key in self.data.operator_public_keys: operator_hash_key = sp.hash_key(operator_public_key) sp.if execution_request.signatures.contains(operator_hash_key) & sp.check_signature(operator_public_key, execution_request.signatures[operator_hash_key], sp.pack(signing_payload)): valid_signatures_counter.value += 1 sp.verify(valid_signatures_counter.value >= self.data.signers_threshold) self.data.nonce += 1 sp.add_operations(execution_request.execution_payload(sp.unit).rev()) @sp.entry_point def update_signatory(self, update_signatory_request): sp.set_type(update_signatory_request, UpdateSignatoryRequest.get_type()) signing_payload = UpdateSignatoryRequest.get_signing_payload(sp.chain_id, sp.self_address, self.data.nonce+sp.nat(1), update_signatory_request.signers_threshold, update_signatory_request.operator_public_keys ) valid_signatures_counter = sp.local('valid_signatures_counter', sp.nat(0)) sp.for operator_public_key in self.data.operator_public_keys: operator_hash_key = sp.hash_key(operator_public_key) sp.if update_signatory_request.signatures.contains(operator_hash_key) & sp.check_signature(operator_public_key, update_signatory_request.signatures[operator_hash_key], sp.pack(signing_payload)): valid_signatures_counter.value += 1 sp.verify(valid_signatures_counter.value >= self.data.signers_threshold) self.data.nonce += 1 self.data.signers_threshold = update_signatory_request.signers_threshold self.data.operator_public_keys = update_signatory_request.operator_public_keys