コード例 #1
0
ファイル: oep4.py プロジェクト: Honglei-Cong/DNA-python-sdk
 def new_transfer_multi_tx(self, transfer_list: list,
                           payer: Union[str, bytes,
                                        Address], gas_price: int,
                           gas_limit: int) -> InvokeTransaction:
     """
     This interface is used to generate a transaction which can
     transfer amount of token from from-account to to-account multiple times.
     """
     func = NeoInvokeFunction('transferMulti')
     for index, item in enumerate(transfer_list):
         if not isinstance(item[2], int):
             raise SDKException(
                 ErrorCode.param_err(
                     'the data type of value should be int.'))
         if item[2] < 0:
             raise SDKException(
                 ErrorCode.param_err(
                     'the value should be equal or great than 0.'))
         transfer_list[index] = [
             Address.b58decode(item[0]),
             Address.b58decode(item[1]), item[2]
         ]
     for item in transfer_list:
         func.add_params_value(item)
     params = InvokeTransaction.generate_neo_vm_invoke_code(
         self._contract_address, func)
     tx = InvokeTransaction(payer, gas_price, gas_limit, params)
     return tx
コード例 #2
0
 def new_revoke_tx(self, claim_id: str, issuer: Union[str, bytes, Address],
                   payer: Union[str, bytes,
                                Address], gas_price: int, gas_limit: int):
     func = NeoInvokeFunction('Revoke')
     func.set_params_value(claim_id, Address.b58decode(issuer))
     tx = InvokeTransaction(Address.b58decode(payer), gas_price, gas_limit)
     tx.add_invoke_code(self.__hex_contract_address, func)
     return tx
コード例 #3
0
ファイル: oep4.py プロジェクト: Honglei-Cong/DNA-python-sdk
 def new_total_supply_tx(self) -> InvokeTransaction:
     """
     This interface is used to generate transaction which can get the total token supply.
     """
     tx = InvokeTransaction()
     tx.add_invoke_code(self._contract_address,
                        NeoInvokeFunction('totalSupply'))
     return tx
コード例 #4
0
ファイル: oep4.py プロジェクト: Honglei-Cong/DNA-python-sdk
 def new_allowance_tx(
         self, owner: Union[str, bytes, Address],
         spender: Union[str, bytes, Address]) -> InvokeTransaction:
     func = NeoInvokeFunction('allowance')
     func.set_params_value(Address.b58decode(owner),
                           Address.b58decode(spender))
     tx = InvokeTransaction()
     tx.add_invoke_code(self._contract_address, func)
     return tx
コード例 #5
0
ファイル: vm.py プロジェクト: Honglei-Cong/DNA-python-sdk
 def make_invoke_transaction(contract_address: Union[str, bytes, bytearray,
                                                     Address],
                             func: Union[AbiFunction, NeoInvokeFunction],
                             payer: Union[str, bytes, Address] = b'',
                             gas_price: int = 0,
                             gas_limit: int = 0) -> InvokeTransaction:
     tx = InvokeTransaction(payer, gas_price, gas_limit)
     tx.add_invoke_code(contract_address, func)
     return tx
コード例 #6
0
ファイル: oep4.py プロジェクト: Honglei-Cong/DNA-python-sdk
 def new_init_tx(self, payer: Union[str, bytes, Address], gas_price: int,
                 gas_limit: int) -> InvokeTransaction:
     """
     This interface is used to call the TotalSupply method in ope4
     that initialize smart contract parameter.
     """
     tx = InvokeTransaction(payer, gas_price, gas_limit)
     tx.add_invoke_code(self._contract_address, NeoInvokeFunction('init'))
     return tx
コード例 #7
0
ファイル: oep4.py プロジェクト: Honglei-Cong/DNA-python-sdk
 def new_balance_of_tx(
         self, owner: Union[str, bytes, Address]) -> InvokeTransaction:
     """
     This interface is used to generate transaction which can get the account balance of another account with owner address.
     """
     func = NeoInvokeFunction('balanceOf')
     func.set_params_value(Address.b58decode(owner))
     tx = InvokeTransaction()
     tx.add_invoke_code(self._contract_address, func)
     return tx
コード例 #8
0
 def make_invoke_transaction(contract_address: Union[str, bytes, bytearray,
                                                     Address],
                             func: WasmInvokeFunction,
                             payer: Union[str, bytes, Address] = b'',
                             gas_price: int = 0,
                             gas_limit: int = 0) -> InvokeTransaction:
     payload = InvokeTransaction.generate_wasm_vm_invoke_code(
         contract_address, func)
     tx = InvokeTransaction(payer, gas_price, gas_limit, payload,
                            TxType.InvokeWasmVm)
     return tx
コード例 #9
0
 def new_commit_tx(self, claim_id: str, issuer_address: Union[str, bytes,
                                                              Address],
                   owner_ont_id: str, payer_address: Union[str, bytes,
                                                           Address],
                   gas_price: int, gas_limit: int) -> InvokeTransaction:
     func = NeoInvokeFunction('Commit')
     func.set_params_value(claim_id, Address.b58decode(issuer_address),
                           owner_ont_id)
     tx = InvokeTransaction(Address.b58decode(payer_address), gas_price,
                            gas_limit)
     tx.add_invoke_code(self.__hex_contract_address, func)
     return tx
コード例 #10
0
ファイル: oep4.py プロジェクト: Honglei-Cong/DNA-python-sdk
 def new_transfer_tx(self, from_address: Union[str, Address],
                     to_address: Union[str, Address], amount: int,
                     payer: Union[str, Address], gas_price: int,
                     gas_limit: int) -> InvokeTransaction:
     """
     This interface is used to generate a transaction which can transfer amount of tokens to to_address.
     """
     func = NeoInvokeFunction('transfer')
     func.set_params_value(Address.b58decode(from_address),
                           Address.b58decode(to_address), amount)
     params = InvokeTransaction.generate_neo_vm_invoke_code(
         self._contract_address, func)
     tx = InvokeTransaction(payer, gas_price, gas_limit, params)
     return tx
コード例 #11
0
ファイル: oep4.py プロジェクト: Honglei-Cong/DNA-python-sdk
 def new_transfer_from_tx(self, spender: Union[str, bytes, Address],
                          owner: Union[str, bytes, Address],
                          to_address: Union[str, bytes, Address],
                          value: int, payer: Union[str, bytes,
                                                   Address], gas_price: int,
                          gas_limit: int) -> InvokeTransaction:
     func = NeoInvokeFunction('transferFrom')
     if not isinstance(value, int):
         raise SDKException(
             ErrorCode.param_err('the data type of value should be int.'))
     func.set_params_value(Address.b58decode(spender),
                           Address.b58decode(owner),
                           Address.b58decode(to_address), value)
     tx = InvokeTransaction(payer, gas_price, gas_limit)
     tx.add_invoke_code(self._contract_address, func)
     return tx
コード例 #12
0
ファイル: did.py プロジェクト: Honglei-Cong/DNA-python-sdk
 def _generate_transaction(self, method: str, args: dict,
                           payer: Union[str, bytes,
                                        Address], gas_price: int,
                           gas_limit: int) -> InvokeTransaction:
     invoke_code = build_vm.build_native_invoke_code(
         self._contract_address, self._version, method, args)
     return InvokeTransaction(payer, gas_price, gas_limit, invoke_code)
コード例 #13
0
 def new_balance_of_tx(self, owner: Union[str,
                                          Address]) -> InvokeTransaction:
     owner = Address.b58decode(owner)
     invoke_code = build_native_invoke_code(self._invoke_address,
                                            self._version, 'balanceOf',
                                            owner)
     return InvokeTransaction(payload=invoke_code)
コード例 #14
0
 def new_allowance_tx(self, from_address: Union[str, Address],
                      to_address: Union[str, Address]) -> InvokeTransaction:
     args = dict(from_address=Address.b58decode(from_address),
                 to_address=Address.b58decode(to_address))
     invoke_code = build_native_invoke_code(self._invoke_address,
                                            self._version, 'allowance',
                                            args)
     return InvokeTransaction(payload=invoke_code)
コード例 #15
0
ファイル: oep4.py プロジェクト: Honglei-Cong/DNA-python-sdk
 def new_approve_tx(self, owner: Union[str, bytes,
                                       Address], spender: Union[str, bytes,
                                                                Address],
                    amount: int, payer: Union[str, bytes, Address],
                    gas_price: int, gas_limit: int) -> InvokeTransaction:
     """
     This interface is used to generate a transaction which allows spender to
     withdraw from owner account multiple times, up to the _value amount.
     If this function is called again it overwrites the current allowance with amount value.
     """
     if not isinstance(amount, int):
         raise SDKException(
             ErrorCode.param_err('the data type of amount should be int.'))
     if amount < 0:
         raise SDKException(
             ErrorCode.param_err(
                 'the amount should be equal or great than 0.'))
     func = NeoInvokeFunction('approve')
     func.set_params_value(Address.b58decode(owner),
                           Address.b58decode(spender), amount)
     params = InvokeTransaction.generate_neo_vm_invoke_code(
         self._contract_address, func)
     tx = InvokeTransaction(payer, gas_price, gas_limit, params)
     return tx
コード例 #16
0
 def new_transfer_from_tx(self, spender: Union[str, Address],
                          from_address: Union[str, Address],
                          receiver: Union[str, Address], amount: int,
                          payer: Union[str, Address], gas_price: int,
                          gas_limit: int) -> InvokeTransaction:
     """
     This interface is used to generate a Transaction object that allow one account to transfer
     a amount of ONT or ONG Asset to another account, in the condition of the first account had been approved.
     """
     args = dict(spender=Address.b58decode(spender),
                 from_address=Address.b58decode(from_address),
                 to_address=Address.b58decode(receiver),
                 amount=amount)
     invoke_code = build_native_invoke_code(self._invoke_address,
                                            self._version, 'transferFrom',
                                            args)
     return InvokeTransaction(Address.b58decode(payer), gas_price,
                              gas_limit, invoke_code)
コード例 #17
0
 def new_approve_tx(self, approver: Union[str,
                                          Address], spender: Union[str,
                                                                   Address],
                    amount: int, payer: Union[str, Address], gas_price: int,
                    gas_limit: int) -> Transaction:
     """
     This interface is used to generate a Transaction object for approve.
     """
     if amount <= 0:
         raise SDKException(
             ErrorCode.other_error(
                 'the amount should be greater than than zero.'))
     args = dict(sender=Address.b58decode(approver),
                 receiver=Address.b58decode(spender),
                 amount=amount)
     invoke_code = build_native_invoke_code(self._invoke_address,
                                            self._version, 'approve', args)
     return InvokeTransaction(Address.b58decode(payer), gas_price,
                              gas_limit, invoke_code)
コード例 #18
0
 def new_transfer_tx(self, from_address: Union[str, Address],
                     to_address: Union[str, Address], amount: int,
                     payer: Union[str, Address], gas_price: int,
                     gas_limit: int) -> Transaction:
     """
     This interface is used to generate a Transaction object for transfer.
     """
     if amount <= 0:
         raise SDKException(
             ErrorCode.other_error(
                 'the amount should be greater than than zero.'))
     state = [{
         'from': Address.b58decode(from_address),
         'to': Address.b58decode(to_address),
         'amount': amount
     }]
     invoke_code = build_native_invoke_code(self._invoke_address,
                                            self._version, 'transfer',
                                            state)
     return InvokeTransaction(Address.b58decode(payer), gas_price,
                              gas_limit, invoke_code)
コード例 #19
0
 def new_get_status_tx(self, claim_id: str) -> InvokeTransaction:
     func = NeoInvokeFunction('GetStatus')
     func.set_params_value(claim_id)
     tx = InvokeTransaction()
     tx.add_invoke_code(self.__hex_contract_address, func)
     return tx
コード例 #20
0
 def _new_token_setting_tx(self, func_name: str) -> InvokeTransaction:
     invoke_code = build_native_invoke_code(self._invoke_address,
                                            self._version, func_name,
                                            bytearray())
     return InvokeTransaction(payload=invoke_code)
コード例 #21
0
ファイル: oep4.py プロジェクト: Honglei-Cong/DNA-python-sdk
 def __new_token_setting_tx(self, func_name: str) -> InvokeTransaction:
     func = NeoInvokeFunction(func_name)
     tx = InvokeTransaction()
     tx.add_invoke_code(self._contract_address, func)
     return tx