Exemple #1
0
 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 NeoInvokeFunction,
                                   is_full: bool = False):
     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(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)
Exemple #2
0
 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
Exemple #3
0
 async def send_neo_vm_tx_pre_exec(self,
                                   contract_address: Union[str, bytes,
                                                           bytearray],
                                   func: Union[AbiFunction,
                                               NeoInvokeFunction],
                                   signer: Account = None,
                                   is_full: bool = False):
     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)
     tx = NeoVm.make_invoke_transaction(contract_address, params)
     if signer is not None:
         tx.sign_transaction(signer)
     return await self.send_raw_transaction_pre_exec(tx, is_full)
 def create_invoke_code(self) -> bytearray:
     param_list = list()
     param_list.append(self.func_name)
     param_list += self.parameters
     return BuildParams.create_wasm_vm_invoke_code(param_list)
Exemple #5
0
 def create_invoke_code(self):
     param_list = list()
     param_list.append(self.func_name.encode('utf-8'))
     param_list.append(self.parameters)
     return BuildParams.create_neo_vm_invoke_code(param_list)