Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshihitoAso committed Apr 8, 2024
1 parent fd5ccf8 commit f8687ac
Show file tree
Hide file tree
Showing 99 changed files with 929 additions and 930 deletions.
2 changes: 1 addition & 1 deletion app/model/db/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TokenType(str, Enum):
class TokenVersion(StrEnum):
V_22_12 = "22_12"
V_23_12 = "23_12"
V_24_6 = "24_6"
V_24_06 = "24_06"


class Token(Base):
Expand Down
4 changes: 2 additions & 2 deletions app/model/schema/base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
class IbetStraightBondContractVersion(StrEnum):
V_22_12 = "22_12"
V_23_12 = "23_12"
V_24_6 = "24_6"
V_24_06 = "24_06"


class IbetShareContractVersion(StrEnum):
V_22_12 = "22_12"
V_24_6 = "24_6"
V_24_06 = "24_06"


MMDD_constr = Annotated[
Expand Down
6 changes: 3 additions & 3 deletions app/routers/bond.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ async def issue_token(
_token.token_address = contract_address
_token.abi = abi
_token.token_status = token_status
_token.version = TokenVersion.V_24_6
_token.version = TokenVersion.V_24_06
db.add(_token)

# Register operation log
Expand Down Expand Up @@ -522,7 +522,7 @@ async def update_token(
f"the operation is not supported in {_token.version}"
)

if _token.version < TokenVersion.V_24_6:
if _token.version < TokenVersion.V_24_06:
if update_data.require_personal_info_registered is not None:
raise OperationNotSupportedVersionError(
f"the operation is not supported in {_token.version}"
Expand Down Expand Up @@ -1604,7 +1604,7 @@ async def schedule_new_update_event(
f"the operation is not supported in {_token.version}"
)

if _token.version < TokenVersion.V_24_6:
if _token.version < TokenVersion.V_24_06:
if event_data.data.require_personal_info_registered is not None:
raise OperationNotSupportedVersionError(
f"the operation is not supported in {_token.version}"
Expand Down
41 changes: 20 additions & 21 deletions app/routers/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,36 +923,35 @@ async def __get_personal_info(
personal_info_not_registered = False
return _idx_personal_info.personal_info, personal_info_not_registered

# Get issuer account
issuer_account = (
await db.scalars(
select(Account)
.where(Account.issuer_address == token.issuer_address)
.limit(1)
)
).first()

# Get token attributes
token_contract = None
if token_type == TokenType.IBET_SHARE.value:
token_contract = await IbetShareContract(token_address).get()
elif token_type == TokenType.IBET_STRAIGHT_BOND.value:
token_contract = await IbetStraightBondContract(token_address).get()

# Retrieve personal info
if token_contract.require_personal_info_registered is True:
# Retrieve from contract storage
personal_info_contract = PersonalInfoContract(
issuer=issuer_account,
contract_address=token_contract.personal_info_contract_address,
)
personal_info = await personal_info_contract.get_info(
account_address=account_address, default_value=None
)
personal_info_not_registered = False
else:
if token_contract.require_personal_info_registered is False:
# Do not retrieve contract data and return the default value
personal_info = ContractPersonalInfoType().model_dump()
personal_info_not_registered = True
return personal_info, personal_info_not_registered

# Get issuer account
issuer_account = (
await db.scalars(
select(Account)
.where(Account.issuer_address == token.issuer_address)
.limit(1)
)
).first()

# Retrieve personal info from contract storage
personal_info_contract = PersonalInfoContract(
issuer=issuer_account,
contract_address=token_contract.personal_info_contract_address,
)
personal_info = await personal_info_contract.get_info(
account_address=account_address, default_value=None
)
personal_info_not_registered = False
return personal_info, personal_info_not_registered
6 changes: 3 additions & 3 deletions app/routers/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ async def issue_token(
_token.token_address = contract_address
_token.abi = abi
_token.token_status = token_status
_token.version = TokenVersion.V_24_6
_token.version = TokenVersion.V_24_06
db.add(_token)

# Register operation log
Expand Down Expand Up @@ -494,7 +494,7 @@ async def update_token(
raise InvalidParameterError("this token is temporarily unavailable")

# Verify that the token version supports the operation
if _token.version < TokenVersion.V_24_6:
if _token.version < TokenVersion.V_24_06:
if update_data.require_personal_info_registered is not None:
raise OperationNotSupportedVersionError(
f"the operation is not supported in {_token.version}"
Expand Down Expand Up @@ -1565,7 +1565,7 @@ async def schedule_new_update_event(
raise InvalidParameterError("this token is temporarily unavailable")

# Verify that the token version supports the operation
if _token.version < TokenVersion.V_24_6:
if _token.version < TokenVersion.V_24_06:
if event_data.data.require_personal_info_registered is not None:
raise OperationNotSupportedVersionError(
f"the operation is not supported in {_token.version}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def insert_token_data(session, token_info):
token.issuer_address = ""
token.token_address = token_info.get("token_address")
token.abi = ""
token.version = TokenVersion.V_24_6
token.version = TokenVersion.V_24_06
session.add(token)
session.commit()

Expand Down
14 changes: 7 additions & 7 deletions tests/test_app_routers_bond_bulk_transfer_POST.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_normal_1(self, client, db):
_token.issuer_address = self.admin_address
_token.token_address = _t
_token.abi = ""
_token.version = TokenVersion.V_24_6
_token.version = TokenVersion.V_24_06
db.add(_token)

db.commit()
Expand Down Expand Up @@ -172,7 +172,7 @@ def test_normal_2(self, client, db):
_token.issuer_address = self.admin_address
_token.token_address = _t
_token.abi = ""
_token.version = TokenVersion.V_24_6
_token.version = TokenVersion.V_24_06
db.add(_token)

db.commit()
Expand Down Expand Up @@ -254,7 +254,7 @@ def test_normal_3(self, client, db):
_token.issuer_address = self.from_address
_token.token_address = _t
_token.abi = ""
_token.version = TokenVersion.V_24_6
_token.version = TokenVersion.V_24_06
db.add(_token)

db.commit()
Expand Down Expand Up @@ -693,7 +693,7 @@ def test_error_10(self, client, db):
_token.token_address = self.req_tokens[0]
_token.abi = ""
_token.token_status = 0
_token.version = TokenVersion.V_24_6
_token.version = TokenVersion.V_24_06
db.add(_token)

db.commit()
Expand Down Expand Up @@ -743,7 +743,7 @@ def test_error_11_1(self, client, db):
_token.issuer_address = self.from_address
_token.token_address = _t
_token.abi = ""
_token.version = TokenVersion.V_24_6
_token.version = TokenVersion.V_24_06
db.add(_token)

db.commit()
Expand Down Expand Up @@ -801,7 +801,7 @@ def test_error_11_2(self, client, db):
_token.issuer_address = self.from_address
_token.token_address = _t
_token.abi = ""
_token.version = TokenVersion.V_24_6
_token.version = TokenVersion.V_24_06
db.add(_token)

db.commit()
Expand Down Expand Up @@ -859,7 +859,7 @@ def test_error_11_3(self, client, db):
_token.issuer_address = self.admin_address
_token.token_address = _t
_token.abi = ""
_token.version = TokenVersion.V_24_6
_token.version = TokenVersion.V_24_06
db.add(_token)

db.commit()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_app_routers_bond_lock_events_GET.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def setup_data(self, db: Session, token_status: int = 1):
_token.tx_hash = ""
_token.abi = ""
_token.token_status = token_status
_token.version = TokenVersion.V_24_6
_token.version = TokenVersion.V_24_06
db.add(_token)

# prepare data: Token
Expand All @@ -67,7 +67,7 @@ def setup_data(self, db: Session, token_status: int = 1):
_token.tx_hash = ""
_token.abi = ""
_token.token_status = token_status
_token.version = TokenVersion.V_24_6
_token.version = TokenVersion.V_24_06
db.add(_token)

# prepare data: Lock events
Expand Down Expand Up @@ -207,7 +207,7 @@ def test_normal_1(self, client, db):
_token.type = TokenType.IBET_STRAIGHT_BOND.value
_token.tx_hash = ""
_token.abi = ""
_token.version = TokenVersion.V_24_6
_token.version = TokenVersion.V_24_06
db.add(_token)

db.commit()
Expand Down
30 changes: 15 additions & 15 deletions tests/test_app_routers_bond_tokens_GET.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_normal_2(self, mock_get, client, db):
token.issuer_address = issuer_address_1
token.token_address = "token_address_test1"
token.abi = "abi_test1"
token.version = TokenVersion.V_24_6
token.version = TokenVersion.V_24_06
db.add(token)
db.commit()
_issue_datetime = (
Expand Down Expand Up @@ -164,7 +164,7 @@ def test_normal_2(self, mock_get, client, db):
"token_status": 1,
"transfer_approval_required": True,
"memo": "memo_test1",
"contract_version": TokenVersion.V_24_6,
"contract_version": TokenVersion.V_24_06,
}
]

Expand All @@ -187,7 +187,7 @@ def test_normal_3(self, mock_get, client, db):
token_1.issuer_address = issuer_address_1
token_1.token_address = "token_address_test1"
token_1.abi = "abi_test1"
token_1.version = TokenVersion.V_24_6
token_1.version = TokenVersion.V_24_06
db.add(token_1)
db.commit()
_issue_datetime_1 = (
Expand Down Expand Up @@ -252,7 +252,7 @@ def test_normal_3(self, mock_get, client, db):
token_2.token_address = "token_address_test2"
token_2.abi = "abi_test2"
token_2.token_status = 0
token_2.version = TokenVersion.V_24_6
token_2.version = TokenVersion.V_24_06
db.add(token_2)
db.commit()
_issue_datetime_2 = (
Expand Down Expand Up @@ -361,7 +361,7 @@ def test_normal_3(self, mock_get, client, db):
"token_status": 1,
"transfer_approval_required": True,
"memo": "memo_test1",
"contract_version": TokenVersion.V_24_6,
"contract_version": TokenVersion.V_24_06,
},
{
"issuer_address": token_2.issuer_address,
Expand Down Expand Up @@ -407,7 +407,7 @@ def test_normal_3(self, mock_get, client, db):
"token_status": 0,
"transfer_approval_required": False,
"memo": "memo_test2",
"contract_version": TokenVersion.V_24_6,
"contract_version": TokenVersion.V_24_06,
},
]

Expand All @@ -429,7 +429,7 @@ def test_normal_4(self, client, db):
token.issuer_address = issuer_address_1
token.token_address = "token_address_test1"
token.abi = "abi_test1"
token.version = TokenVersion.V_24_6
token.version = TokenVersion.V_24_06
db.add(token)

resp = client.get(self.apiurl, headers={"issuer-address": issuer_address_2})
Expand All @@ -452,7 +452,7 @@ def test_normal_5(self, mock_get, client, db):
token_1.issuer_address = issuer_address_1
token_1.token_address = "token_address_test1"
token_1.abi = "abi_test1"
token_1.version = TokenVersion.V_24_6
token_1.version = TokenVersion.V_24_06
db.add(token_1)
db.commit()
_issue_datetime = (
Expand Down Expand Up @@ -518,7 +518,7 @@ def test_normal_5(self, mock_get, client, db):
token_2.issuer_address = issuer_address_2
token_2.token_address = "token_address_test1"
token_2.abi = "abi_test1"
token_2.version = TokenVersion.V_24_6
token_2.version = TokenVersion.V_24_06
db.add(token_2)

resp = client.get(self.apiurl, headers={"issuer-address": issuer_address_1})
Expand Down Expand Up @@ -568,7 +568,7 @@ def test_normal_5(self, mock_get, client, db):
"token_status": 1,
"transfer_approval_required": True,
"memo": "memo_test1",
"contract_version": TokenVersion.V_24_6,
"contract_version": TokenVersion.V_24_06,
}
]

Expand All @@ -591,7 +591,7 @@ def test_normal_6(self, mock_get, client, db):
token_1.issuer_address = issuer_address_1
token_1.token_address = "token_address_test1"
token_1.abi = "abi_test1"
token_1.version = TokenVersion.V_24_6
token_1.version = TokenVersion.V_24_06
db.add(token_1)
db.commit()
_issue_datetime_1 = (
Expand Down Expand Up @@ -656,7 +656,7 @@ def test_normal_6(self, mock_get, client, db):
token_2.token_address = "token_address_test2"
token_2.abi = "abi_test2"
token_2.token_status = 0
token_2.version = TokenVersion.V_24_6
token_2.version = TokenVersion.V_24_06
db.add(token_2)
db.commit()
_issue_datetime_2 = (
Expand Down Expand Up @@ -725,7 +725,7 @@ def test_normal_6(self, mock_get, client, db):
token_3.issuer_address = issuer_address_2
token_3.token_address = "token_address_test1"
token_3.abi = "abi_test1"
token_3.version = TokenVersion.V_24_6
token_3.version = TokenVersion.V_24_06
db.add(token_3)

resp = client.get(self.apiurl, headers={"issuer-address": issuer_address_1})
Expand Down Expand Up @@ -775,7 +775,7 @@ def test_normal_6(self, mock_get, client, db):
"token_status": 1,
"transfer_approval_required": True,
"memo": "memo_test1",
"contract_version": TokenVersion.V_24_6,
"contract_version": TokenVersion.V_24_06,
},
{
"issuer_address": token_2.issuer_address,
Expand Down Expand Up @@ -821,7 +821,7 @@ def test_normal_6(self, mock_get, client, db):
"token_status": 0,
"transfer_approval_required": False,
"memo": "memo_test2",
"contract_version": TokenVersion.V_24_6,
"contract_version": TokenVersion.V_24_06,
},
]

Expand Down
6 changes: 3 additions & 3 deletions tests/test_app_routers_bond_tokens_POST.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async def test_normal_1(self, client, db):
assert token_1.token_address == "contract_address_test1"
assert token_1.abi == "abi_test1"
assert token_1.token_status == 1
assert token_1.version == TokenVersion.V_24_6
assert token_1.version == TokenVersion.V_24_06

position = db.scalars(select(IDXPosition).limit(1)).first()
assert position.token_address == "contract_address_test1"
Expand Down Expand Up @@ -307,7 +307,7 @@ async def test_normal_2(self, client, db):
assert token_1.token_address == "contract_address_test1"
assert token_1.abi == "abi_test1"
assert token_1.token_status == 0
assert token_1.version == TokenVersion.V_24_6
assert token_1.version == TokenVersion.V_24_06

position = db.scalars(select(IDXPosition).limit(1)).first()
assert position is None
Expand Down Expand Up @@ -437,7 +437,7 @@ async def test_normal_3(self, client, db):
assert token_1.token_address == "contract_address_test1"
assert token_1.abi == "abi_test1"
assert token_1.token_status == 1
assert token_1.version == TokenVersion.V_24_6
assert token_1.version == TokenVersion.V_24_06

position = db.scalars(select(IDXPosition).limit(1)).first()
assert position.token_address == "contract_address_test1"
Expand Down
Loading

0 comments on commit f8687ac

Please sign in to comment.