Skip to content

Commit

Permalink
[#] match mutiple platform resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongFuze committed Oct 12, 2024
1 parent cf8da48 commit 7081fba
Show file tree
Hide file tree
Showing 16 changed files with 685 additions and 34 deletions.
62 changes: 62 additions & 0 deletions src/resolver/aptos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Author: Zella Zhong
Date: 2024-10-12 16:24:59
LastEditors: Zella Zhong
LastEditTime: 2024-10-12 16:25:52
FilePath: /data_service/src/resolver/aptos.py
Description:
'''
import logging
from datetime import datetime
from sqlalchemy.inspection import inspect
from sqlalchemy import select, update, and_, or_
from sqlalchemy.orm import load_only
from urllib.parse import unquote

from session import get_session
from model import EnsnameModel

from utils import check_evm_address, convert_camel_case

from scalar.platform import Platform
from scalar.network import Network
from scalar.identity_graph import IdentityRecordSimplified
from scalar.identity_record import IdentityRecord
from scalar.profile import Profile
from scalar.error import EmptyInput, EvmAddressInvalid, ExceedRangeInput

QUERY_MAX_LIMIT = 200


async def query_profile_by_single_aptos(info, address):
identity_record = IdentityRecord(
id=f"{Platform.aptos.value},{address}",
identity=address,
platform=Platform.aptos.value,
network=Network.aptos.value,
primary_name=None,
is_primary=False,
profile=None
)
return identity_record

async def query_profile_by_aptos_addresses(info, addresses):
if len(addresses) > QUERY_MAX_LIMIT:
return ExceedRangeInput(QUERY_MAX_LIMIT)

logging.debug("query_profile_by_aptos_addresses %s", addresses)
result = []
for addr in addresses:
result.append(IdentityRecordSimplified(
id=f"{Platform.aptos.value},{addr}",
identity=addr,
platform=Platform.aptos.value,
network=Network.aptos.value,
primary_name=None,
is_primary=False,
profile=None
))

return result
62 changes: 62 additions & 0 deletions src/resolver/bitcoin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Author: Zella Zhong
Date: 2024-10-12 16:23:07
LastEditors: Zella Zhong
LastEditTime: 2024-10-12 16:26:22
FilePath: /data_service/src/resolver/bitcoin.py
Description:
'''
import logging
from datetime import datetime
from sqlalchemy.inspection import inspect
from sqlalchemy import select, update, and_, or_
from sqlalchemy.orm import load_only
from urllib.parse import unquote

from session import get_session
from model import EnsnameModel

from utils import check_evm_address, convert_camel_case

from scalar.platform import Platform
from scalar.network import Network
from scalar.identity_graph import IdentityRecordSimplified
from scalar.identity_record import IdentityRecord
from scalar.profile import Profile
from scalar.error import EmptyInput, EvmAddressInvalid, ExceedRangeInput

QUERY_MAX_LIMIT = 200


async def query_profile_by_single_bitcoin(info, address):
identity_record = IdentityRecord(
id=f"{Platform.bitcoin.value},{address}",
identity=address,
platform=Platform.bitcoin.value,
network=Network.bitcoin.value,
primary_name=None,
is_primary=False,
profile=None
)
return identity_record

async def query_profile_by_bitcoin_addresses(info, addresses):
if len(addresses) > QUERY_MAX_LIMIT:
return ExceedRangeInput(QUERY_MAX_LIMIT)

logging.debug("query_profile_by_bitcoin_addresses %s", addresses)
result = []
for addr in addresses:
result.append(IdentityRecordSimplified(
id=f"{Platform.bitcoin.value},{addr}",
identity=addr,
platform=Platform.bitcoin.value,
network=Network.bitcoin.value,
primary_name=None,
is_primary=False,
profile=None
))

return result
62 changes: 62 additions & 0 deletions src/resolver/cosmos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Author: Zella Zhong
Date: 2024-10-12 16:25:36
LastEditors: Zella Zhong
LastEditTime: 2024-10-12 16:26:52
FilePath: /data_service/src/resolver/cosmos.py
Description:
'''
import logging
from datetime import datetime
from sqlalchemy.inspection import inspect
from sqlalchemy import select, update, and_, or_
from sqlalchemy.orm import load_only
from urllib.parse import unquote

from session import get_session
from model import EnsnameModel

from utils import check_evm_address, convert_camel_case

from scalar.platform import Platform
from scalar.network import Network
from scalar.identity_graph import IdentityRecordSimplified
from scalar.identity_record import IdentityRecord
from scalar.profile import Profile
from scalar.error import EmptyInput, EvmAddressInvalid, ExceedRangeInput

QUERY_MAX_LIMIT = 200


async def query_profile_by_single_cosmos(info, address):
identity_record = IdentityRecord(
id=f"{Platform.cosmos.value},{address}",
identity=address,
platform=Platform.cosmos.value,
network=Network.cosmos.value,
primary_name=None,
is_primary=False,
profile=None
)
return identity_record

async def query_profile_by_cosmos_addresses(info, addresses):
if len(addresses) > QUERY_MAX_LIMIT:
return ExceedRangeInput(QUERY_MAX_LIMIT)

logging.debug("query_profile_by_cosmos_addresses %s", addresses)
result = []
for addr in addresses:
result.append(IdentityRecordSimplified(
id=f"{Platform.cosmos.value},{addr}",
identity=addr,
platform=Platform.cosmos.value,
network=Network.cosmos.value,
primary_name=None,
is_primary=False,
profile=None
))

return result
62 changes: 62 additions & 0 deletions src/resolver/dogecoin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Author: Zella Zhong
Date: 2024-10-12 16:24:51
LastEditors: Zella Zhong
LastEditTime: 2024-10-12 16:26:46
FilePath: /data_service/src/resolver/dogecoin.py
Description:
'''
import logging
from datetime import datetime
from sqlalchemy.inspection import inspect
from sqlalchemy import select, update, and_, or_
from sqlalchemy.orm import load_only
from urllib.parse import unquote

from session import get_session
from model import EnsnameModel

from utils import check_evm_address, convert_camel_case

from scalar.platform import Platform
from scalar.network import Network
from scalar.identity_graph import IdentityRecordSimplified
from scalar.identity_record import IdentityRecord
from scalar.profile import Profile
from scalar.error import EmptyInput, EvmAddressInvalid, ExceedRangeInput

QUERY_MAX_LIMIT = 200


async def query_profile_by_single_dogecoin(info, address):
identity_record = IdentityRecord(
id=f"{Platform.dogecoin.value},{address}",
identity=address,
platform=Platform.dogecoin.value,
network=Network.dogecoin.value,
primary_name=None,
is_primary=False,
profile=None
)
return identity_record

async def query_profile_by_dogecoin_addresses(info, addresses):
if len(addresses) > QUERY_MAX_LIMIT:
return ExceedRangeInput(QUERY_MAX_LIMIT)

logging.debug("query_profile_by_dogecoin_addresses %s", addresses)
result = []
for addr in addresses:
result.append(IdentityRecordSimplified(
id=f"{Platform.dogecoin.value},{addr}",
identity=addr,
platform=Platform.dogecoin.value,
network=Network.dogecoin.value,
primary_name=None,
is_primary=False,
profile=None
))

return result
6 changes: 3 additions & 3 deletions src/resolver/ensname.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-10-06 18:32:53
LastEditors: Zella Zhong
LastEditTime: 2024-10-09 14:45:05
LastEditTime: 2024-10-12 14:17:15
FilePath: /data_service/src/resolver/ensname.py
Description:
'''
Expand Down Expand Up @@ -257,8 +257,8 @@ async def query_profile_by_single_ensname(info, name):
return identity_record

async def query_profile_by_ensnames(info, names):
if len(names) == 0:
return EmptyInput()
# if len(names) == 0:
# return EmptyInput()
if len(names) > QUERY_MAX_LIMIT:
return ExceedRangeInput(QUERY_MAX_LIMIT)

Expand Down
6 changes: 3 additions & 3 deletions src/resolver/ethereum.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-10-06 18:41:34
LastEditors: Zella Zhong
LastEditTime: 2024-10-09 14:46:09
LastEditTime: 2024-10-12 14:17:22
FilePath: /data_service/src/resolver/ethereum.py
Description:
'''
Expand Down Expand Up @@ -248,8 +248,8 @@ async def query_profile_by_single_address(info, address):
return identity_record

async def query_profile_by_addresses(info, addresses):
if len(addresses) == 0:
return EmptyInput()
# if len(addresses) == 0:
# return EmptyInput()
if len(addresses) > QUERY_MAX_LIMIT:
return ExceedRangeInput(QUERY_MAX_LIMIT)
logging.debug("query_profile_by_addresses %s", addresses)
Expand Down
6 changes: 3 additions & 3 deletions src/resolver/farcaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-10-06 21:38:55
LastEditors: Zella Zhong
LastEditTime: 2024-10-10 19:17:04
LastEditTime: 2024-10-12 14:17:27
FilePath: /data_service/src/resolver/farcaster.py
Description:
'''
Expand Down Expand Up @@ -309,8 +309,8 @@ async def query_profile_by_single_fname(info, fname):
return identity_record

async def query_profile_by_fnames(info, fnames):
if len(fnames) == 0:
return EmptyInput()
# if len(fnames) == 0:
# return EmptyInput()

if len(fnames) > QUERY_MAX_LIMIT:
return ExceedRangeInput(QUERY_MAX_LIMIT)
Expand Down
Loading

0 comments on commit 7081fba

Please sign in to comment.