Skip to content

Add Kusama #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ RPC_BRIDGEHUB=wss://bridge-hub-polkadot-rpc.dwellir.com
SUBSQUID_NETWORK_BRIDGEHUB=bridge-hub-polkadot
START_BLOCK_BRIDGEHUB=2776300

# asset hub
# polkadot asset hub
RPC_ASSETHUB=wss://statemint.api.onfinality.io/public-ws
SUBSQUID_NETWORK_ASSETHUB=asset-hub-polkadot
START_BLOCK_ASSETHUB=6457397

# kusama asset hub
RPC_KUSAMA_ASSETHUB=wss://asset-hub-kusama-rpc.dwellir.com
SUBSQUID_NETWORK_ASSETHUB_KUSAMA=asset-hub-kusama
START_BLOCK_ASSETHUB_KUSAMA=9469109

# hydration
RPC_HYDRATION=wss://hydration.dotters.network
SUBSQUID_NETWORK_HYDRATION=hydradx
Expand All @@ -45,7 +50,7 @@ START_BLOCK_ACALA=7382962

# Mythos is not supported on Subsquid yet. However, can still use an RPC endpoint to sync from.
RPC_MYTHOS=wss://polkadot-mythos-rpc.polkadot.io
# SUBSQUID_NETWORK_MYTHOS=mythos
# SUBSQUID_NETWORK_MYTHOS=mythos
START_BLOCK_MYTHOS=2542302


26 changes: 26 additions & 0 deletions commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,32 @@
"src/polkadot/parachains/hydration/main.ts"
]
},
"generateMeta:kusama:assethub": {
"description": "Generate metadata for Kusama AssetHub",
"cmd": [
"npx",
"squid-substrate-metadata-explorer",
"--rpc=wss://kusama-asset-hub-rpc.polkadot.io",
"--out=versions/kusama/assethub-versions.jsonl"
]
},
"typegen:kusama:assethub": {
"description": "Generate data access classes from metadata",
"cmd": [
"squid-substrate-typegen",
"./versions/kusama/typegen-assethub.json"
]
},
"process:kusama:assethub": {
"description": "Start the squid processor for Kusama AssetHub",
"deps": ["build"],
"cmd": [
"node",
"--require=ts-node/register",
"--require=dotenv/config",
"src/kusama/assethub/main.ts"
]
},
"serve": {
"description": "Start the GraphQL API server",
"cmd": ["squid-graphql-server"]
Expand Down
4 changes: 4 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type MessageProcessedOnPolkadot @entity {
paraId: Int
success: Boolean
eventId: String
network: String
}

"""
Expand Down Expand Up @@ -79,6 +80,9 @@ type TransferStatusToPolkadot @entity {
tokenAddress: String
tokenLocation: String
senderAddress: String
sourceNetwork: String
sourceParaId: Int
destinationNetwork: String
destinationParaId: Int
destinationAddress: String
amount: BigInt
Expand Down
5 changes: 5 additions & 0 deletions squid-full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ deploy:
RPC_MYTHOS: "wss://polkadot-mythos-rpc.polkadot.io"
START_BLOCK_MYTHOS: 2542302
cmd: ["sqd", "process:parachain:mythos"]
- name: kusama-assethub-processor
env:
RPC_KUSAMA_ASSETHUB: "wss://asset-hub-kusama-rpc.dwellir.com"
START_BLOCK_KUSAMA_ASSETHUB: 9469109
cmd: [ "sqd", "process:kusama:assethub" ]
- name: post-processor
cmd: ["sqd", "postprocess"]
api:
Expand Down
5 changes: 5 additions & 0 deletions squid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ deploy:
RPC_MYTHOS: "wss://polkadot-mythos-rpc.polkadot.io"
START_BLOCK_MYTHOS: 2542302
cmd: ["sqd", "process:parachain:mythos"]
- name: kusama-assethub-processor
env:
RPC_KUSAMA_ASSETHUB: "wss://asset-hub-kusama-rpc.dwellir.com"
START_BLOCK_KUSAMA_ASSETHUB: 9469109
cmd: ["sqd", "process:kusama:assethub"]
- name: post-processor
cmd: ["sqd", "postprocess"]
api:
Expand Down
76 changes: 75 additions & 1 deletion src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const BridgeHubParaId = 1002;

export const AssetHubParaId = 1000;

export const KusamaAssetHubParaId = 1000;

export const MoonBeamParaId = 2004;

export const HydrationParaId = 2034;
Expand All @@ -21,6 +23,10 @@ export const MythosParaId = 3369;

export const AcalaParaId = 2000;

export const KusamaNetwork = "kusama";

export const PolkadotNetwork = "polkadot";

export interface ToEthereumAsset {
location: string;
address: string;
Expand Down Expand Up @@ -86,11 +92,79 @@ export const findTokenAddress = (network: string, tokenId: string): string => {
return key;
}
}
return "";
}
return "";
};

export const normalizeString = (str: string): string => {
return str.replace(/\s/g, "").toLowerCase();
};

export const dotTokenLocationString = () => {
return stringifyLocation({
parents: 1,
interior: {
__kind: "X1",
value: [
{
__kind: "GlobalConsensus",
value: {
__kind: "Polkadot",
},
},
],
},
});
}


export const ksmTokenLocationString = () => {
return stringifyLocation({
parents: 1,
interior: {
__kind: "X1",
value: [
{
__kind: "GlobalConsensus",
value: {
__kind: "Kusama",
},
},
],
},
});
}

export const ksmTokenLocationFromPolkadotAH = () => {
return stringifyLocation({
parents: 2,
interior: {
__kind: "X1",
value: [
{
__kind: "GlobalConsensus",
value: {
__kind: "Kusama",
},
},
],
},
});
}

export const hereLocation = () => {
return stringifyLocation({
parents: 1,
interior: {
__kind: "Here",
}
});
}

export const stringifyLocation = (location: any) => {
return JSON.stringify(
location,
(key, value) =>
typeof value === "bigint" ? value.toString() : value
);
}
2 changes: 2 additions & 0 deletions src/kusama/assethub/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
import './main'
Loading