async def send_neo_vm_transaction(self, contract_address: str or bytes or bytearray, signer: Account or None, payer: Account or None, gas_price: int, gas_limit: int, func: AbiFunction or InvokeFunction, is_full: bool = False): if isinstance(func, AbiFunction): params = BuildParams.serialize_abi_function(func) elif isinstance(func, InvokeFunction): params = func.create_invoke_code() else: raise SDKException( ErrorCode.other_error('the type of func is error.')) contract_address = ensure_bytearray_contract_address(contract_address) params.append(0x67) for i in contract_address: params.append(i) if payer is None: raise SDKException(ErrorCode.param_err('payer account is None.')) tx = Transaction(0, 0xd1, gas_price, gas_limit, payer.get_address_bytes(), params) tx.sign_transaction(payer) if isinstance( signer, Account ) and signer.get_address_base58() != payer.get_address_base58(): tx.add_sign_transaction(signer) return await self.send_raw_transaction(tx, is_full)
async def send_neo_vm_tx_pre_exec(self, contract_address: Union[str, bytes, bytearray], func: Union[AbiFunction, InvokeFunction], signer: Account = None, is_full: bool = False): contract_address = ensure_bytearray_contract_address(contract_address) tx = NeoVm.make_invoke_transaction(contract_address, func) if signer is not None: tx.sign_transaction(signer) return await self.send_raw_transaction_pre_exec(tx, is_full)
def send_neo_vm_tx_pre_exec(self, contract_address: str or bytes or bytearray, func: AbiFunction or NeoInvokeFunction, signer: Account = None, is_full: bool = False): contract_address = ensure_bytearray_contract_address(contract_address) tx = NeoVm.make_invoke_transaction(contract_address, func, b'', 0, 0) if signer is not None: tx.sign_transaction(signer) return self.send_raw_transaction_pre_exec(tx, is_full)
def generate_neo_vm_invoke_code(contract_address: Union[str, bytes, bytearray, Address], func: Union[AbiFunction, NeoInvokeFunction]): if isinstance(func, AbiFunction): params = BuildParams.serialize_abi_function(func) elif isinstance(func, NeoInvokeFunction): params = func.create_invoke_code() else: raise SDKException(ErrorCode.other_error('the type of func is error')) contract_address = ensure_bytearray_contract_address(contract_address) params.append(int.from_bytes(APPCALL, byteorder='little')) for i in contract_address: params.append(i) return params
def send_neo_vm_transaction_pre_exec(self, contract_address: str or bytes or bytearray, signer: Account or None, func: AbiFunction or InvokeFunction, is_full: bool = False): if isinstance(func, AbiFunction): params = BuildParams.serialize_abi_function(func) elif isinstance(func, InvokeFunction): params = func.create_invoke_code() else: raise SDKException(ErrorCode.other_error('the type of func is error.')) contract_address = ensure_bytearray_contract_address(contract_address) tx = NeoVm.make_invoke_transaction(contract_address, params, b'', 0, 0) if signer is not None: tx.sign_transaction(signer) return self.send_raw_transaction_pre_exec(tx, is_full)
def generate_wasm_vm_invoke_code(contract_address: Union[str, bytes, bytearray, Address], func: WasmInvokeFunction) -> bytearray: return ensure_bytearray_contract_address(contract_address) + func.create_invoke_code()