@substrate/connect
Advanced tools
Comparing version 1.1.0 to 1.1.1
# Changelog | ||
## 1.1.1 | ||
### Patch Changes | ||
- 80187a0: docs(substrate-connect): add polkadotjs example | ||
- e8fef4e: update docs | ||
- Updated dependencies [897f553] | ||
- Updated dependencies [e8fef4e] | ||
- Updated dependencies [0ce9864] | ||
- Updated dependencies [4a45295] | ||
- Updated dependencies [4a45295] | ||
- @substrate/connect-known-chains@1.2.1 | ||
- @substrate/smoldot-discovery@1.0.1 | ||
## 1.1.0 | ||
@@ -4,0 +18,0 @@ |
@@ -119,2 +119,10 @@ import { AddChain, AddWellKnownChain } from '@substrate/smoldot-discovery/types'; | ||
* extension is installed and available. | ||
* | ||
* The substrate-connect extension is identified via the `@substrate/discovery` protocol. | ||
* | ||
* It must: | ||
* | ||
* 1. Be compliant `@substrate/smoldot-discovery` interface | ||
* 2. Include an rdns label starting with `io.github.paritytech.SubstrateConnect` | ||
* | ||
*/ | ||
@@ -121,0 +129,0 @@ declare const createScClient: (config?: Config) => ScClient; |
@@ -338,3 +338,6 @@ var __defProp = Object.defineProperty; | ||
const lightClientProvider = getSmoldotExtensionProviders().filter( | ||
(detail) => detail.info.rdns.startsWith("io.github.paritytech.SubstrateConnect") | ||
(detail) => ( | ||
// Filter for Substrate Connect to find the correct provider among multiple providers. | ||
detail.info.rdns.startsWith("io.github.paritytech.SubstrateConnect") | ||
) | ||
).map((detail) => detail.provider)[0]; | ||
@@ -341,0 +344,0 @@ return lightClientProvider; |
{ | ||
"name": "@substrate/connect", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Substrate-connect to Smoldot clients. Using either substrate extension with predefined clients or an internal smoldot client based on chainSpecs provided.", | ||
@@ -38,5 +38,5 @@ "author": "Parity Team <admin@parity.io>", | ||
"smoldot": "2.0.29", | ||
"@substrate/connect-known-chains": "^1.2.0", | ||
"@substrate/smoldot-discovery": "^1.0.0", | ||
"@substrate/connect-extension-protocol": "^2.0.0" | ||
"@substrate/smoldot-discovery": "^1.0.1", | ||
"@substrate/connect-extension-protocol": "^2.0.0", | ||
"@substrate/connect-known-chains": "^1.2.1" | ||
}, | ||
@@ -43,0 +43,0 @@ "devDependencies": { |
@@ -5,3 +5,3 @@ <br /><br /> | ||
<h1 align="center">@substrate/connect</h1> | ||
<h4 align="center"> NPM package that offers an innovative way to interact with <a href="https://substrate.dev/">Substrate</a>-based blockchains directly in your browser.</h4> | ||
<h4 align="center">An NPM package that offers an innovative way to interact with <a href="https://substrate.dev/">Substrate</a>-based blockchains directly in your browser.</h4> | ||
<p align="center"> | ||
@@ -19,8 +19,12 @@ <a href="https://www.npmjs.com/package/@substrate/connect"> | ||
The main implementation of the light-client provider for a given substrate-based chain. | ||
The primary implementation of the light-client provider for any Substrate-based chain. | ||
## Using `@substrate/connect` for library authors | ||
Provide a well-known chain name ('polkadot', 'ksmcc3', 'westend2', 'rococo_v2_2'): | ||
The `connect` package searches for a light client provider via the discovery protocol. If none is found, it will initiate a smoldot instance in the user's browser tab. | ||
### Example Usage | ||
To connect to a well-known chain ('polkadot', 'ksmcc3', 'westend2', 'rococo_v2_2'): | ||
```js | ||
@@ -42,3 +46,3 @@ import { createScClient, WellKnownChain } from '@substrate/connect'; | ||
...or provide your custom substrate chain's name and chainspec: | ||
To connect to a custom Substrate chain using its name and chainspec: | ||
@@ -64,7 +68,6 @@ ```js | ||
In order to connect to a parachain, you must first instantiate the relay chain | ||
this parachain is connected to, then instantiate the parachain on the same | ||
relay chain. The following example connects to a parachain of the Westend test | ||
network: | ||
### Connecting to a Parachain | ||
To connect to a parachain, first instantiate the relay chain it is connected to, then instantiate the parachain on the same relay chain. The following example connects to a parachain on the Westend test network: | ||
```js | ||
@@ -77,3 +80,3 @@ import { createScClient, WellKnownChain } from '@substrate/connect'; | ||
const scClient = createScClient(); | ||
const relayChain = await scClient.addWellKnownChain(WellKnownChain.westend2) | ||
const relayChain = await scClient.addWellKnownChain(WellKnownChain.westend2); | ||
const parachain = await relayChain.addChain( | ||
@@ -91,2 +94,19 @@ parachainSpec, | ||
### PokladotJs Example | ||
```ts | ||
import { ScProvider } from '@polkadot/rpc-provider/substrate-connect'; | ||
import * as Sc from '@substrate/connect'; | ||
// Connect to polkadot relay chain | ||
const provider = new ScProvider(Sc, Sc.WellKnownChain.polkadot); | ||
await provider.connect(); | ||
const api = await ApiPromise.create({ provider }) | ||
// Connect to parachain | ||
const provider2 = new ScProvider(Sc, Sc.WellKnownChain.people, provider); | ||
await provider2.connect(); | ||
const api2 = await ApiPromise.create({ provider }) | ||
``` | ||
## Scripts | ||
@@ -93,0 +113,0 @@ |
@@ -37,2 +37,10 @@ import { SmoldotExtensionAPI } from "@substrate/smoldot-discovery/types" | ||
* extension is installed and available. | ||
* | ||
* The substrate-connect extension is identified via the `@substrate/discovery` protocol. | ||
* | ||
* It must: | ||
* | ||
* 1. Be compliant `@substrate/smoldot-discovery` interface | ||
* 2. Include an rdns label starting with `io.github.paritytech.SubstrateConnect` | ||
* | ||
*/ | ||
@@ -70,2 +78,3 @@ export const createScClient = (config?: Config): ScClient => { | ||
.filter((detail) => | ||
// Filter for Substrate Connect to find the correct provider among multiple providers. | ||
detail.info.rdns.startsWith("io.github.paritytech.SubstrateConnect"), | ||
@@ -72,0 +81,0 @@ ) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
191718
1742
111