@substrate/light-client-extension-helpers
Advanced tools
Comparing version 2.1.0 to 2.1.1
{ | ||
"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) | ||
} | ||
``` |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
236338
270
1
+ Added@scure/base@1.1.8(transitive)
- Removed@scure/base@1.1.9(transitive)