@nockchain/sdk 0.1.4-nightly.2 → 0.1.4-nightly.4
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 +3 -3
- package/dist/errors.d.ts +2 -2
- package/dist/errors.js +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/provider.d.ts +4 -4
- package/dist/provider.js +8 -8
- package/dist/types.d.ts +2 -2
- package/dist/types.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@nockchain/sdk`
|
|
2
2
|
|
|
3
|
-
TypeScript SDK for interacting with the **
|
|
3
|
+
TypeScript SDK for interacting with the **Rose** browser wallet extension (Nockchain).
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ npm i @nockchain/sdk
|
|
|
10
10
|
|
|
11
11
|
## What you get
|
|
12
12
|
|
|
13
|
-
- **`NockchainProvider`**: connect to
|
|
13
|
+
- **`NockchainProvider`**: connect to Rose and request signatures / transactions (EIP-1193-ish API).
|
|
14
14
|
- **`TransactionBuilder`**: small fluent helper for constructing the simple “send transaction” payload.
|
|
15
15
|
- **WASM**: use `@nockchain/rose-wasm` directly for `TxBuilder`, `GrpcClient`, etc.
|
|
16
16
|
- **React Hook**: `useIris()` for one-time WASM init + gRPC client + provider wiring.
|
|
@@ -85,4 +85,4 @@ Notes:
|
|
|
85
85
|
|
|
86
86
|
This SDK is built with `tsc` and publishes **compiled output** from `sdk/dist/`.
|
|
87
87
|
|
|
88
|
-
If you are iterating on `@nockchain/rose-wasm`, the recommended workflow is to publish it to a **local npm registry** (e.g. Verdaccio), then publish `@nockchain/sdk` against that version, and finally consume
|
|
88
|
+
If you are iterating on `@nockchain/rose-wasm`, the recommended workflow is to publish it to a **local npm registry** (e.g. Verdaccio), then publish `@nockchain/sdk` against that version, and finally consume Rose using normal semver dependencies (no `file:`).
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Custom error classes for
|
|
2
|
+
* Custom error classes for Rose SDK
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* Thrown when the
|
|
5
|
+
* Thrown when the Rose wallet extension is not installed
|
|
6
6
|
*/
|
|
7
7
|
export declare class WalletNotInstalledError extends Error {
|
|
8
8
|
constructor();
|
package/dist/errors.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Custom error classes for
|
|
2
|
+
* Custom error classes for Rose SDK
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* Thrown when the
|
|
5
|
+
* Thrown when the Rose wallet extension is not installed
|
|
6
6
|
*/
|
|
7
7
|
export class WalletNotInstalledError extends Error {
|
|
8
8
|
constructor() {
|
|
9
|
-
super('
|
|
9
|
+
super('Rose wallet extension not installed. Please install it from the Chrome Web Store.');
|
|
10
10
|
this.name = 'WalletNotInstalledError';
|
|
11
11
|
Object.setPrototypeOf(this, WalletNotInstalledError.prototype);
|
|
12
12
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/provider.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* NockchainProvider - Main SDK class for interacting with
|
|
2
|
+
* NockchainProvider - Main SDK class for interacting with Rose wallet
|
|
3
3
|
*/
|
|
4
4
|
import type { Transaction, NockchainEvent, EventListener } from './types.js';
|
|
5
5
|
import { TransactionBuilder } from './transaction.js';
|
|
6
6
|
/**
|
|
7
|
-
* NockchainProvider class - Main interface for dApps to interact with
|
|
7
|
+
* NockchainProvider class - Main interface for dApps to interact with Rose wallet
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
@@ -30,7 +30,7 @@ export declare class NockchainProvider {
|
|
|
30
30
|
private _messageHandler?;
|
|
31
31
|
/**
|
|
32
32
|
* Create a new NockchainProvider instance
|
|
33
|
-
* @throws {WalletNotInstalledError} If the
|
|
33
|
+
* @throws {WalletNotInstalledError} If the Rose extension is not installed
|
|
34
34
|
*/
|
|
35
35
|
constructor();
|
|
36
36
|
/**
|
|
@@ -185,7 +185,7 @@ export declare class NockchainProvider {
|
|
|
185
185
|
*/
|
|
186
186
|
private emit;
|
|
187
187
|
/**
|
|
188
|
-
* Check if the
|
|
188
|
+
* Check if the Rose extension is installed and authentic
|
|
189
189
|
* @returns true if the extension is installed
|
|
190
190
|
*/
|
|
191
191
|
static isInstalled(): boolean;
|
package/dist/provider.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* NockchainProvider - Main SDK class for interacting with
|
|
2
|
+
* NockchainProvider - Main SDK class for interacting with Rose wallet
|
|
3
3
|
*/
|
|
4
4
|
import { TransactionBuilder } from './transaction.js';
|
|
5
5
|
import { WalletNotInstalledError, UserRejectedError, RpcError, NoAccountError } from './errors.js';
|
|
6
6
|
import { PROVIDER_METHODS } from './constants.js';
|
|
7
7
|
/**
|
|
8
|
-
* NockchainProvider class - Main interface for dApps to interact with
|
|
8
|
+
* NockchainProvider class - Main interface for dApps to interact with Rose wallet
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* ```typescript
|
|
@@ -26,7 +26,7 @@ import { PROVIDER_METHODS } from './constants.js';
|
|
|
26
26
|
export class NockchainProvider {
|
|
27
27
|
/**
|
|
28
28
|
* Create a new NockchainProvider instance
|
|
29
|
-
* @throws {WalletNotInstalledError} If the
|
|
29
|
+
* @throws {WalletNotInstalledError} If the Rose extension is not installed
|
|
30
30
|
*/
|
|
31
31
|
constructor() {
|
|
32
32
|
this._accounts = [];
|
|
@@ -34,7 +34,7 @@ export class NockchainProvider {
|
|
|
34
34
|
if (typeof window === 'undefined') {
|
|
35
35
|
throw new Error('NockchainProvider can only be used in a browser environment');
|
|
36
36
|
}
|
|
37
|
-
// Verify
|
|
37
|
+
// Verify Rose extension is installed and authentic
|
|
38
38
|
if (!NockchainProvider.isInstalled()) {
|
|
39
39
|
throw new WalletNotInstalledError();
|
|
40
40
|
}
|
|
@@ -283,9 +283,9 @@ export class NockchainProvider {
|
|
|
283
283
|
if (event.source !== window)
|
|
284
284
|
return;
|
|
285
285
|
const payload = event.data;
|
|
286
|
-
// SECURITY: Verify the message is from
|
|
286
|
+
// SECURITY: Verify the message is from Rose extension
|
|
287
287
|
// This prevents malicious scripts from forging wallet events
|
|
288
|
-
if (!payload || payload.
|
|
288
|
+
if (!payload || payload.__rose !== true)
|
|
289
289
|
return;
|
|
290
290
|
// Check if this is a valid wallet event
|
|
291
291
|
if (typeof payload.type !== 'string' || !payload.type.startsWith('nockchain_'))
|
|
@@ -339,12 +339,12 @@ export class NockchainProvider {
|
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
/**
|
|
342
|
-
* Check if the
|
|
342
|
+
* Check if the Rose extension is installed and authentic
|
|
343
343
|
* @returns true if the extension is installed
|
|
344
344
|
*/
|
|
345
345
|
static isInstalled() {
|
|
346
346
|
// TODO: Support other providers
|
|
347
|
-
return typeof window !== 'undefined' && window.nockchain?.provider === '
|
|
347
|
+
return typeof window !== 'undefined' && window.nockchain?.provider === 'rose';
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
//# sourceMappingURL=provider.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TypeScript type definitions for
|
|
2
|
+
* TypeScript type definitions for Rose SDK
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* Transaction object representing a Nockchain transaction
|
|
@@ -55,7 +55,7 @@ export interface InjectedNockchain {
|
|
|
55
55
|
*/
|
|
56
56
|
request<T = unknown>(request: RpcRequest): Promise<T>;
|
|
57
57
|
/**
|
|
58
|
-
* Provider name (e.g., '
|
|
58
|
+
* Provider name (e.g., 'rose')
|
|
59
59
|
*/
|
|
60
60
|
provider?: string;
|
|
61
61
|
/**
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nockchain/sdk",
|
|
3
|
-
"version": "0.1.4-nightly.
|
|
3
|
+
"version": "0.1.4-nightly.4",
|
|
4
4
|
"description": "TypeScript SDK for interacting with Nockchain wallet extensions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"prepublishOnly": "npm run build"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@nockchain/rose-wasm": "^0.1.4-nightly.
|
|
55
|
+
"@nockchain/rose-wasm": "^0.1.4-nightly.17.1.a460619",
|
|
56
56
|
"@scure/base": "2.0.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|