Socket
Socket
Sign inDemoInstall

@substrate/light-client-extension-helpers

Package Overview
Dependencies
Maintainers
16
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@substrate/light-client-extension-helpers - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

6

package.json
{
"name": "@substrate/light-client-extension-helpers",
"version": "2.1.0",
"version": "2.1.1",
"author": "Matias Volpe (https://github.com/kratico)",

@@ -60,4 +60,4 @@ "repository": {

"rxjs": "^7.8.1",
"@substrate/connect-known-chains": "^1.1.9",
"@substrate/connect-extension-protocol": "^2.0.0"
"@substrate/connect-extension-protocol": "^2.0.0",
"@substrate/connect-known-chains": "^1.1.10"
},

@@ -64,0 +64,0 @@ "scripts": {

@@ -1,3 +0,17 @@

# @substrate/light-client-extension-helpers
<br /><br />
<div align="center">
<h1 align="center">@substrate/light-client-extension-helpers</h1>
<p align="center">
<a href="https://www.npmjs.com/package/@substrate/light-client-extension-helpers">
<img alt="npm" src="https://img.shields.io/npm/v/@substrate/light-client-extension-helpers" />
</a>
<a href="https://github.com/paritytech/substrate-connect/blob/master/LICENSE">
<img alt="GPL-3.0-or-later" src="https://img.shields.io/npm/l/@substrate/light-client-extension-helpers" />
</a>
</p>
</div>
<br /><br />
## Components

@@ -214,2 +228,43 @@

TODO: write usage guide
The tx-helper package allows you to easily sign transactions. You just need the calldata and an implementation of the
`@polkadot-api/signer` interface.
#### PJS Example Implementation
```ts
import { getLightClientProvider } from "@substrate/light-client-extension-helpers/web-page"
import { connectInjectedExtension } from "@polkadot-api/pjs-signer"
import { fromHex, toHex } from "@polkadot-api/utils"
import { createTx } from "@substrate/light-client-extension-helpers/tx-helper" // 👈 create-tx import
const CHANNEL_ID = "..."
const lightClientProvider = await getLightClientProvider(CHANNEL_ID)
const createTx = async (chainId: string, from: string, callData: string) => {
const chains = Object.values(lightClientProvider.getChains())
const chain = chains.find(({ genesisHash }) => genesisHash === chainId)
if (!chain) {
throw new Error("unknown chain")
}
const injectedExt = await connectInjectedExtension("polkadot-js")
const account = injectedExt
.getAccounts()
.find((account) => toHex(account.polkadotSigner.publicKey) === from)
if (!account) {
throw new Error("no account")
}
const signer = account.polkadotSigner // 👈 @polkadot-api/signer implementation
const tx = await createTx(chain.connect)({
callData: fromHex(callData),
signer,
})
return toHex(tx)
}
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc