@rsksmart/powpeg-sdk 1.2.0-beta.2 → 1.2.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/SECURITY.md +7 -132
- package/dist/index.d.mts +207 -7
- package/dist/index.d.ts +207 -7
- package/dist/index.js +285 -24
- package/dist/index.mjs +284 -24
- package/docs/api.md +51 -0
- package/docs/bitcoin-signers.md +36 -0
- package/docs/setup.md +61 -0
- package/package.json +13 -4
- package/pnpm-workspace.yaml +2 -0
package/docs/setup.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Setup
|
|
2
|
+
|
|
3
|
+
## Prerequisites
|
|
4
|
+
|
|
5
|
+
- Node.js 22 (matches the version used in CI)
|
|
6
|
+
- [pnpm](https://pnpm.io/) 10.15.1 (pinned via the `packageManager` field in `package.json`; run via [Corepack](https://nodejs.org/api/corepack.html) or `corepack enable`)
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pnpm install
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Build
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm build
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Bundles `src/index.ts` into `dist/` as CJS and ESM (`dist/index.js`, `dist/index.mjs`) plus its type declarations (`dist/index.d.ts`), via `tsup`. Use `pnpm build:watch` to rebuild on change.
|
|
21
|
+
|
|
22
|
+
## Test
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm test # run once
|
|
26
|
+
pnpm test:watch # watch mode
|
|
27
|
+
pnpm coverage # with coverage report
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Lint
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm lint # eslint on src + GitHub Actions workflows
|
|
34
|
+
pnpm lint:fix # auto-fix
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Consuming the package
|
|
38
|
+
[`See on NPM`](https://www.npmjs.com/package/@rsksmart/powpeg-sdk)
|
|
39
|
+
Install it as a dependency of your own app:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pnpm add @rsksmart/powpeg-sdk
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`PowPegSDK`'s constructor takes a `BitcoinSigner`, a `BitcoinDataSource`, the network, and optional URLs for the two services it talks to — there's no `.env` file to configure for the SDK itself; these are runtime constructor parameters instead, in this order:
|
|
46
|
+
|
|
47
|
+
| Parameter | Purpose | Default when omitted |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| `bitcoinSigner` | `BitcoinSigner` used to sign peg-in transactions (e.g. `LedgerSigner`, `TrezorSigner`) | `null` — required only for operations that sign transactions |
|
|
50
|
+
| `bitcoinDataSource` | `BitcoinDataSource` used for fee rates, UTXOs, tx broadcast and tx status | `null` — falls back to the built-in `apiUrl`-backed source |
|
|
51
|
+
| `network` | `'MAIN'` or `'TEST'` — selects Bitcoin network params and address validation rules | required |
|
|
52
|
+
| `rpcProviderUrl` | Rootstock JSON-RPC endpoint used to read the bridge precompile and send peg-outs | RSK public node for the given network (`https://public-node.rsk.co` / `https://public-node.testnet.rsk.co`) |
|
|
53
|
+
| `apiUrl` | 2WP API used as the default `BitcoinDataSource` (fee rates, UTXOs, tx broadcast, tx status) when no custom `BitcoinDataSource` is supplied | production 2WP API for the given network (`https://api.2wp.rootstock.io` / `https://api.2wp.testnet.rootstock.io`) |
|
|
54
|
+
|
|
55
|
+
## External dependencies
|
|
56
|
+
|
|
57
|
+
- **Rootstock RPC node** — read via `ethers.providers.JsonRpcProvider`, used for the bridge precompile (`Bridge` in `src/bridge.ts`) and to send peg-out transactions.
|
|
58
|
+
- **2WP API** — the SDK's built-in `BitcoinDataSource` implementation (`src/api/api.ts`); can be replaced with your own `BitcoinDataSource` for fee rates, UTXOs, tx broadcasting and address details.
|
|
59
|
+
- **Hardware wallets** (only needed if you use the bundled signers — see [`bitcoin-signers.md`](./bitcoin-signers.md)):
|
|
60
|
+
- **Ledger** — via `@ledgerhq/hw-transport-webusb`, requires a browser environment with WebUSB support.
|
|
61
|
+
- **Trezor** — via `@trezor/connect-web`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsksmart/powpeg-sdk",
|
|
3
|
-
"version": "1.2.0-beta.
|
|
3
|
+
"version": "1.2.0-beta.3",
|
|
4
4
|
"description": "SDK for creating native peg-in and peg-out transactions following the PowPeg protocol.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"test": "vitest run",
|
|
12
12
|
"test:watch": "vitest watch",
|
|
13
13
|
"coverage": "vitest run --coverage",
|
|
14
|
-
"lint": "eslint src",
|
|
14
|
+
"lint": "eslint src && pnpm lint:actions",
|
|
15
15
|
"lint:fix": "pnpm lint --fix",
|
|
16
16
|
"lint:actions": "eslint '.github/**/*.{yml,yaml}'"
|
|
17
17
|
},
|
|
@@ -46,5 +46,14 @@
|
|
|
46
46
|
"bitcoinjs-lib": "^6.1.7",
|
|
47
47
|
"tiny-secp256k1": "^2.2.4"
|
|
48
48
|
},
|
|
49
|
-
"packageManager": "pnpm@10.15.1+sha512.34e538c329b5553014ca8e8f4535997f96180a1d0f614339357449935350d924e22f8614682191264ec33d1462ac21561aff97f6bb18065351c162c7e8f6de67"
|
|
50
|
-
|
|
49
|
+
"packageManager": "pnpm@10.15.1+sha512.34e538c329b5553014ca8e8f4535997f96180a1d0f614339357449935350d924e22f8614682191264ec33d1462ac21561aff97f6bb18065351c162c7e8f6de67",
|
|
50
|
+
"pnpm": {
|
|
51
|
+
"onlyBuiltDependencies": [
|
|
52
|
+
"blake-hash",
|
|
53
|
+
"esbuild",
|
|
54
|
+
"protobufjs",
|
|
55
|
+
"tiny-secp256k1",
|
|
56
|
+
"usb"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
}
|