Skip to content

Commit

Permalink
api: accept NeoAddress types in transfer_friendly() (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
ixje authored Oct 25, 2023
1 parent ca55ebc commit 6a5611d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions neo3/api/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,11 @@ def transfer(
return ContractMethodResult(sb.to_array(), unwrap.as_bool)

def transfer_friendly(
self, source, dest, amount, data: Optional[noderpc.ContractParameter] = None
self,
source: types.UInt160 | NeoAddress,
destination: types.UInt160 | NeoAddress,
amount,
data: Optional[noderpc.ContractParameter] = None,
):
"""
Transfer `amount` of tokens from `source` account to `destination` account.
Expand All @@ -875,15 +879,20 @@ def transfer_friendly(
The return value after invoking with `invoke()` or `test_invoke()` is
`True` if the token transferred successful.
`False` otherwise.
Raises:
ValueError: if `source` or `destination` is an invalid NeoAddress format
"""
source = _check_address_and_convert(source)
destination = _check_address_and_convert(destination)
sb = vm.ScriptBuilder()
sb.emit_push(data)
sb.emit_push(10) # multiplier base
sb.emit_contract_call(self.hash, "decimals")
sb.emit(vm.OpCode.POW)
sb.emit_push(amount)
sb.emit(vm.OpCode.MUL)
sb.emit_push(dest)
sb.emit_push(destination)
sb.emit_push(source)
sb.emit_push(4)
sb.emit(vm.OpCode.PACK)
Expand Down

0 comments on commit 6a5611d

Please sign in to comment.