Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit c95fa0d

Browse files
committed
check for restricted transfer, transfer_from -> transfer
1 parent cb38a0b commit c95fa0d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

thirdweb/errors/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ class UploadError(Exception):
2121
def __init__(self, message: str):
2222
super().__init__(f"There was an error while uploading the image : {message}")
2323

24+
25+
class RestrictedTransferError(Exception):
26+
def __init__(self, address: str = None):
27+
super().__init__(f"Failed to transfer asset, transfer is restricted.${f'Address : {address}' if address is not None else ''}")

thirdweb/modules/currency.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Interact with the Currency module of the app.
33
"""
4+
from thirdweb.errors import RestrictedTransferError
45
from thirdweb_web3 import Web3
56

67
from ..abi.coin import Coin
@@ -156,7 +157,9 @@ def transfer(self, to_address: str, amount: int):
156157
157158
Transfers the given amount from the current address
158159
"""
159-
return self.execute_tx(self.__abi_module.transfer_from.build_transaction(
160+
if(self.__abi_module.is_restricted_transfer()):
161+
raise RestrictedTransferError(self.address)
162+
return self.execute_tx(self.__abi_module.transfer.build_transaction(
160163
self.get_signer_address(), to_address, amount, self.get_transact_opts()
161164
))
162165

0 commit comments

Comments
 (0)