Skip to content

Commit

Permalink
feat: light client support for peregrine stg
Browse files Browse the repository at this point in the history
  • Loading branch information
rflechtner committed Jul 13, 2023
1 parent 63f8a97 commit 9041726
Show file tree
Hide file tree
Showing 3 changed files with 1,122 additions and 2 deletions.
877 changes: 877 additions & 0 deletions src/specs/peregrine-stg-kilt.json

Large diffs are not rendered by default.

233 changes: 233 additions & 0 deletions src/specs/peregrine-stg-relay.json

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions src/utils/useConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let cachedApi: Promise<ApiPromise> | null = null
let provider: ScProvider | null = null

function loadSpecs(): {
relaychain: Sc.WellKnownChain
relaychain: Sc.WellKnownChain | Record<string, any>
parachain: Record<string, any>
} {
const chainId = process.env.REACT_APP_CHAIN_ID ?? 'kilt'
Expand All @@ -22,6 +22,12 @@ function loadSpecs(): {
relaychain: Sc.WellKnownChain.polkadot,
parachain: require('../specs/spiritnet.json'),
}
case 'peregrine-stg':
case 'peregrine_stg_kilt':
return {
relaychain: require('../specs/peregrine-stg-relay.json'),
parachain: require('../specs/peregrine-stg-kilt.json'),
}
default:
throw new Error(`unknown chain id '${chainId}'`)
}
Expand All @@ -33,7 +39,11 @@ function getSpecs(): { relaychain: string; parachain: string } {
if (!parachain.blockNumberBytes) {
parachain.blockNumberBytes = 8
}
return { relaychain, parachain: JSON.stringify(parachain) }
return {
relaychain:
typeof relaychain === 'string' ? relaychain : JSON.stringify(relaychain),
parachain: JSON.stringify(parachain),
}
}

async function createLightClientApi(
Expand Down

0 comments on commit 9041726

Please sign in to comment.