Skip to content

Commit

Permalink
feat: introduce new registries
Browse files Browse the repository at this point in the history
  • Loading branch information
octo-gone committed Dec 20, 2024
1 parent 8ee368d commit 5e220d5
Show file tree
Hide file tree
Showing 7 changed files with 590 additions and 10 deletions.
80 changes: 73 additions & 7 deletions scripts/archives/add_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@

def update_parser(parser: argparse.ArgumentParser):
parser.description = "Add new archive to the CDN"
parser.add_argument("variant", help="archive variant", choices=["evm", "substrate"])
parser.add_argument(
"variant",
help="archive variant",
choices=[
"evm",
"substrate",
"solana",
"tron",
"fuel",
"starknet",
],
)
parser.set_defaults(func=_run)


Expand All @@ -19,19 +30,75 @@ def _run(parsed_args):
hr_name = Prompt.ask("Human readable name")
data_source_id = Prompt.ask("Data source identifier")
registry_name = Prompt.ask("Registry name", default=data_source_id)
chain_testnet = Confirm.ask("Is chain testnet?", default=False)
support_tier = int(Prompt.ask("Support tier", default="2", choices=["1", "2", "3"]))
entry = {}
match parsed_args.variant:
case "solana" | "tron" | "fuel" | "starknet":
match parsed_args.variant:
case "fuel":
datasource_data = [
"blocks",
"tx",
"receipts",
"inputs",
"outputs",
]
case "solana":
start_block = Prompt.ask("First supported block", default="null")
datasource_data = [
"blocks",
"logs",
"tx",
"instructions",
"balances",
"token_balances",
"rewards",
]
if start_block != "null":
datasource_data = [
{
"name": v,
"ranges": [[start_block, None]]
} for v in datasource_data
]
case "starknet":
datasource_data = [
"blocks",
"tx",
"events",
]
case "tron":
datasource_data = [
"blocks",
"tx",
"logs",
"internal_tx",
]
entry = {
"id": data_source_id,
"chainName": hr_name,
"isTestnet": chain_testnet,
"network": registry_name,
"providers": [
{
"data": datasource_data,
"dataSourceUrl": f"https://v2.archive.subsquid.io/network/{data_source_id}",
"provider": "subsquid",
"release": "ArrowSquid",
"supportTier": support_tier,
}
],
}
case "evm":
chain_id = Prompt.ask("Chain ID", default="null")
chain_testnet = Confirm.ask("Is chain testnet?", default=False)
datasource_data = ["blocks", "tx"]
if Confirm.ask("Datasource supports logs?", default=True):
datasource_data.append("logs")
if Confirm.ask("Datasource supports traces?", default=False):
datasource_data.append("traces")
if Confirm.ask("Datasource supports statediffs?", default=False):
datasource_data.append("stateDiffs")
support_tier = int(Prompt.ask("Support tier", default="2", choices=["1", "2", "3"]))
logo_url = Prompt.ask("Logo url (only name if in /img/networks)", default="null")
if logo_url == "null":
logo_url = None
Expand All @@ -55,10 +122,9 @@ def _run(parsed_args):
],
}
case "substrate":
chain_testnet = Confirm.ask("Is chain testnet?", default=False)
chain_ss58_prefix = Prompt.ask("Chain SS58 Prefix", default="null")
genesis_hash = Prompt.ask("Genesis hash", default="")
support_tier = int(Prompt.ask("Support tier", default="2", choices=["1", "2", "3"]))
datasource_data = ["blocks", "calls", "events", "extrinsics"]
entry = {
"id": data_source_id,
"chainName": hr_name,
Expand All @@ -70,7 +136,7 @@ def _run(parsed_args):
"network": registry_name,
"providers": [
{
"data": ["blocks", "calls", "events", "extrinsics"],
"data": datasource_data,
"dataSourceUrl": f"https://v2.archive.subsquid.io/network/{data_source_id}",
"provider": "subsquid",
"release": "ArrowSquid",
Expand All @@ -79,7 +145,7 @@ def _run(parsed_args):
],
}
case _:
raise ValueError("Invalid archive variant")
raise ValueError("Archive variant is not supported")
syntax = Syntax(
json.dumps(entry, indent=2), "json", theme="monokai", line_numbers=True
)
Expand Down
19 changes: 17 additions & 2 deletions scripts/archives/list_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ def update_parser(parser: argparse.ArgumentParser):
parser.add_argument(
"variant",
help="archive variant",
choices=["evm", "substrate"],
choices=[
"evm",
"substrate",
"solana",
"tron",
"fuel",
"starknet",
],
)
parser.add_argument("-s", "--search", type=str, help="search by name")
parser.set_defaults(func=_run)
Expand All @@ -29,8 +36,16 @@ def _run(parsed_args):
table = Table(title="EVM Archives")
case "substrate":
table = Table(title="Substrate Archives")
case "fuel":
table = Table(title="Fuel Archives")
case "solana":
table = Table(title="Solana Archives")
case "starknet":
table = Table(title="Starknet Archives")
case "Tron":
table = Table(title="Tron Archives")
case _:
raise ValueError("Invalid archive variant")
raise ValueError("Archive variant is not supported")

table.add_column("ID", justify="left", no_wrap=True)
table.add_column("Name", justify="left", no_wrap=True)
Expand Down
9 changes: 8 additions & 1 deletion scripts/archives/sort_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ def update_parser(parser: argparse.ArgumentParser):
parser.add_argument(
"variant",
help="archive variant",
choices=["evm", "substrate"],
choices=[
"evm",
"substrate",
"solana",
"tron",
"fuel",
"starknet",
],
)
parser.set_defaults(func=_run)

Expand Down
46 changes: 46 additions & 0 deletions src/archives/fuel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"archives": [
{
"id": "fuel-mainnet",
"chainName": "Fuel Mainnet",
"isTestnet": false,
"network": "fuel-mainnet",
"providers": [
{
"data": [
"blocks",
"tx",
"receipts",
"inputs",
"outputs"
],
"dataSourceUrl": "https://v2.archive.subsquid.io/network/fuel-mainnet",
"provider": "subsquid",
"release": "ArrowSquid",
"supportTier": 1
}
]
},
{
"id": "fuel-testnet",
"chainName": "Fuel Testnet",
"isTestnet": true,
"network": "fuel-testnet",
"providers": [
{
"data": [
"blocks",
"tx",
"receipts",
"inputs",
"outputs"
],
"dataSourceUrl": "https://v2.archive.subsquid.io/network/fuel-testnet",
"provider": "subsquid",
"release": "ArrowSquid",
"supportTier": 1
}
]
}
]
}
Loading

0 comments on commit 5e220d5

Please sign in to comment.