@bootnodedev/canton-connect 0.3.0 → 0.4.0
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 +39 -5
- package/dist/index.d.ts +19 -15
- package/dist/index.js +5 -1
- package/dist/testing/index.d.ts +6 -6
- package/dist/{types-Deu_03jh.d.ts → types-CmnMRMoG.d.ts} +16 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -44,15 +44,16 @@ switching only once those gaps close. Until then, the machine earns its cost.
|
|
|
44
44
|
|
|
45
45
|
## Status
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
Published to npm as `@bootnodedev/canton-connect`. Also consumed by `dapp/frontend` in this repo,
|
|
48
|
+
which links the local folder while its version satisfies the declared range.
|
|
48
49
|
|
|
49
50
|
## Install
|
|
50
51
|
|
|
51
52
|
Peers a consumer installs beside it: `@canton-network/dapp-sdk`, `@canton-network/core-types`,
|
|
52
|
-
`react` 19 and `@walletconnect/sign-client`. The last is
|
|
53
|
-
it statically at the top of its bundle (checked on 1.5.1), so it has to
|
|
54
|
-
you set `walletConnectProjectId`. Only the session is lazy:
|
|
55
|
-
starts, not at import.
|
|
53
|
+
`react` 19 and `@walletconnect/sign-client`. The last is required here, though `dapp-sdk` marks it
|
|
54
|
+
optional: `dapp-sdk` imports it statically at the top of its bundle (checked on 1.5.1), so it has to
|
|
55
|
+
be present whether or not you set `walletConnectProjectId`. Only the session is lazy:
|
|
56
|
+
`SignClient.init()` runs when a pairing starts, not at import.
|
|
56
57
|
|
|
57
58
|
## Usage
|
|
58
59
|
|
|
@@ -116,6 +117,39 @@ and a wallet-side disconnect look the same
|
|
|
116
117
|
here. `useLedger().isReady` covers both, and `useParty().party` is `undefined` for the duration:
|
|
117
118
|
gate session content on the party, and use `isLocked` only to explain why it went away.
|
|
118
119
|
|
|
120
|
+
### Connecting through a Wallet Gateway
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
import { RemoteAdapter } from '@canton-network/dapp-sdk'
|
|
124
|
+
|
|
125
|
+
const config = {
|
|
126
|
+
appName: 'My dApp',
|
|
127
|
+
additionalAdapters: [
|
|
128
|
+
new RemoteAdapter({ name: 'Gateway', rpcUrl: 'http://localhost:3030/api/v0/dapp' }),
|
|
129
|
+
],
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
> [!NOTE]
|
|
134
|
+
> The dapp-sdk wallet picker also lets a user paste any gateway URL and connect to it without the
|
|
135
|
+
> dApp listing it. That session does not survive a reload; one with a gateway listed here does.
|
|
136
|
+
|
|
137
|
+
Details in [architecture.md](https://github.com/BootNodeDev/canton-dappbooster/blob/main/canton-connect/architecture.md#remote-gateway).
|
|
138
|
+
|
|
139
|
+
### Connecting through WalletConnect
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
const config = {
|
|
143
|
+
appName: 'My dApp',
|
|
144
|
+
networkId: 'canton:devnet',
|
|
145
|
+
walletConnectProjectId: 'YOUR_REOWN_PROJECT_ID',
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`networkId` is the Canton network the dApp targets, as a CAIP-2 chain id.
|
|
150
|
+
|
|
151
|
+
Details in [architecture.md](https://github.com/BootNodeDev/canton-dappbooster/blob/main/canton-connect/architecture.md#walletconnect).
|
|
152
|
+
|
|
119
153
|
## Reference
|
|
120
154
|
|
|
121
155
|
Every hook and every config field is documented in JSDoc, which your editor surfaces at the call
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as Party, c as WalletSdk, i as ConnectionSubscription, l as ConnectionInput, n as CantonConnectContextValue, o as PartyType, r as ConnectionStatus, s as TxStatusSnapshot, t as CantonConnectConfig, u as InitOptions } from "./types-
|
|
1
|
+
import { a as Party, c as WalletSdk, i as ConnectionSubscription, l as ConnectionInput, n as CantonConnectContextValue, o as PartyType, r as ConnectionStatus, s as TxStatusSnapshot, t as CantonConnectConfig, u as InitOptions } from "./types-CmnMRMoG.js";
|
|
2
2
|
import { LedgerApiParams, PrepareExecuteParams, ProviderAdapter } from "@canton-network/dapp-sdk";
|
|
3
3
|
import { JSX, ReactNode } from "react";
|
|
4
4
|
//#region src/CantonConnectProvider/index.d.ts
|
|
@@ -15,7 +15,7 @@ import { JSX, ReactNode } from "react";
|
|
|
15
15
|
*
|
|
16
16
|
* @category Hooks
|
|
17
17
|
*/
|
|
18
|
-
declare const useCantonConnectContext: () => CantonConnectContextValue;
|
|
18
|
+
export declare const useCantonConnectContext: () => CantonConnectContextValue;
|
|
19
19
|
/**
|
|
20
20
|
* Props for {@link CantonConnectProvider}. `config` is read once, when the connection actor is
|
|
21
21
|
* created: a `walletPicker` or `additionalAdapters` swapped later reaches `config` on the context,
|
|
@@ -43,7 +43,7 @@ interface CantonConnectProviderProps {
|
|
|
43
43
|
*
|
|
44
44
|
* @category Components
|
|
45
45
|
*/
|
|
46
|
-
declare const CantonConnectProvider: ({ config, children }: CantonConnectProviderProps) => JSX.Element;
|
|
46
|
+
export declare const CantonConnectProvider: ({ config, children }: CantonConnectProviderProps) => JSX.Element;
|
|
47
47
|
//#endregion
|
|
48
48
|
//#region src/connectError.d.ts
|
|
49
49
|
/**
|
|
@@ -56,7 +56,7 @@ declare const CantonConnectProvider: ({ config, children }: CantonConnectProvide
|
|
|
56
56
|
*
|
|
57
57
|
* @category Errors
|
|
58
58
|
*/
|
|
59
|
-
declare class ConnectCancelledError extends Error {
|
|
59
|
+
export declare class ConnectCancelledError extends Error {
|
|
60
60
|
constructor(cause?: unknown);
|
|
61
61
|
}
|
|
62
62
|
//#endregion
|
|
@@ -92,7 +92,7 @@ interface UseConnectResult {
|
|
|
92
92
|
*
|
|
93
93
|
* @category Hooks
|
|
94
94
|
*/
|
|
95
|
-
declare const useConnect: () => UseConnectResult;
|
|
95
|
+
export declare const useConnect: () => UseConnectResult;
|
|
96
96
|
//#endregion
|
|
97
97
|
//#region src/hooks/useDisconnect.d.ts
|
|
98
98
|
/**
|
|
@@ -118,7 +118,7 @@ interface UseDisconnectResult {
|
|
|
118
118
|
*
|
|
119
119
|
* @category Hooks
|
|
120
120
|
*/
|
|
121
|
-
declare const useDisconnect: () => UseDisconnectResult;
|
|
121
|
+
export declare const useDisconnect: () => UseDisconnectResult;
|
|
122
122
|
//#endregion
|
|
123
123
|
//#region src/hooks/useExecute.d.ts
|
|
124
124
|
/**
|
|
@@ -150,7 +150,7 @@ interface UseExecuteResult {
|
|
|
150
150
|
*
|
|
151
151
|
* @category Hooks
|
|
152
152
|
*/
|
|
153
|
-
declare const useExecute: () => UseExecuteResult;
|
|
153
|
+
export declare const useExecute: () => UseExecuteResult;
|
|
154
154
|
//#endregion
|
|
155
155
|
//#region src/hooks/useLedger.d.ts
|
|
156
156
|
/**
|
|
@@ -172,11 +172,15 @@ interface UseLedgerResult {
|
|
|
172
172
|
*
|
|
173
173
|
* @example
|
|
174
174
|
* const { ledgerApi } = useLedger()
|
|
175
|
-
* await ledgerApi({
|
|
175
|
+
* await ledgerApi({
|
|
176
|
+
* requestMethod: 'get',
|
|
177
|
+
* resource: '/v2/users/{user-id}/rights',
|
|
178
|
+
* path: { 'user-id': 'alice' },
|
|
179
|
+
* })
|
|
176
180
|
*
|
|
177
181
|
* @category Hooks
|
|
178
182
|
*/
|
|
179
|
-
declare const useLedger: () => UseLedgerResult;
|
|
183
|
+
export declare const useLedger: () => UseLedgerResult;
|
|
180
184
|
//#endregion
|
|
181
185
|
//#region src/hooks/useParty.d.ts
|
|
182
186
|
/**
|
|
@@ -202,7 +206,7 @@ interface UsePartyResult {
|
|
|
202
206
|
*
|
|
203
207
|
* @category Hooks
|
|
204
208
|
*/
|
|
205
|
-
declare const useParty: () => UsePartyResult;
|
|
209
|
+
export declare const useParty: () => UsePartyResult;
|
|
206
210
|
//#endregion
|
|
207
211
|
//#region src/hooks/usePartyType.d.ts
|
|
208
212
|
/**
|
|
@@ -232,7 +236,7 @@ interface UsePartyTypeResult {
|
|
|
232
236
|
*
|
|
233
237
|
* @category Hooks
|
|
234
238
|
*/
|
|
235
|
-
declare const usePartyType: () => UsePartyTypeResult;
|
|
239
|
+
export declare const usePartyType: () => UsePartyTypeResult;
|
|
236
240
|
//#endregion
|
|
237
241
|
//#region src/hooks/useSignMessage.d.ts
|
|
238
242
|
/**
|
|
@@ -260,7 +264,7 @@ interface UseSignMessageResult {
|
|
|
260
264
|
*
|
|
261
265
|
* @category Hooks
|
|
262
266
|
*/
|
|
263
|
-
declare const useSignMessage: () => UseSignMessageResult;
|
|
267
|
+
export declare const useSignMessage: () => UseSignMessageResult;
|
|
264
268
|
//#endregion
|
|
265
269
|
//#region src/hooks/useWalletStatus.d.ts
|
|
266
270
|
/**
|
|
@@ -288,7 +292,7 @@ interface UseWalletStatusResult {
|
|
|
288
292
|
*
|
|
289
293
|
* @category Hooks
|
|
290
294
|
*/
|
|
291
|
-
declare const useWalletStatus: () => UseWalletStatusResult;
|
|
295
|
+
export declare const useWalletStatus: () => UseWalletStatusResult;
|
|
292
296
|
//#endregion
|
|
293
297
|
//#region src/mock/mockAdapter.d.ts
|
|
294
298
|
/**
|
|
@@ -337,6 +341,6 @@ interface MockAdapter extends ProviderAdapter {
|
|
|
337
341
|
*
|
|
338
342
|
* @category Utilities
|
|
339
343
|
*/
|
|
340
|
-
declare const createMockAdapter: (options?: CreateMockAdapterOptions) => MockAdapter;
|
|
344
|
+
export declare const createMockAdapter: (options?: CreateMockAdapterOptions) => MockAdapter;
|
|
341
345
|
//#endregion
|
|
342
|
-
export {
|
|
346
|
+
export type { CantonConnectConfig, CantonConnectContextValue, CantonConnectProviderProps, ConnectionInput, ConnectionStatus, ConnectionSubscription, CreateMockAdapterOptions, InitOptions, LedgerApiParams, MockAccount, MockAdapter, Party, PartyType, PrepareExecuteParams, TxStatusSnapshot, UseConnectResult, UseDisconnectResult, UseExecuteResult, UseLedgerResult, UsePartyResult, UsePartyTypeResult, UseSignMessageResult, UseWalletStatusResult, WalletSdk };
|
package/dist/index.js
CHANGED
|
@@ -188,7 +188,11 @@ const useExecute = () => {
|
|
|
188
188
|
*
|
|
189
189
|
* @example
|
|
190
190
|
* const { ledgerApi } = useLedger()
|
|
191
|
-
* await ledgerApi({
|
|
191
|
+
* await ledgerApi({
|
|
192
|
+
* requestMethod: 'get',
|
|
193
|
+
* resource: '/v2/users/{user-id}/rights',
|
|
194
|
+
* path: { 'user-id': 'alice' },
|
|
195
|
+
* })
|
|
192
196
|
*
|
|
193
197
|
* @category Hooks
|
|
194
198
|
*/
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as Party, c as WalletSdk, r as ConnectionStatus } from "../types-
|
|
1
|
+
import { a as Party, c as WalletSdk, r as ConnectionStatus } from "../types-CmnMRMoG.js";
|
|
2
2
|
import { WalletPickerFn } from "@canton-network/dapp-sdk";
|
|
3
3
|
import { JSX, ReactNode } from "react";
|
|
4
4
|
//#region src/testing/autoPicker.d.ts
|
|
@@ -14,7 +14,7 @@ import { JSX, ReactNode } from "react";
|
|
|
14
14
|
*
|
|
15
15
|
* @category Utilities
|
|
16
16
|
*/
|
|
17
|
-
declare const createAutoPicker: (pick?: string) => WalletPickerFn;
|
|
17
|
+
export declare const createAutoPicker: (pick?: string) => WalletPickerFn;
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/testing/fakeSession.d.ts
|
|
20
20
|
/**
|
|
@@ -50,7 +50,7 @@ interface FakeSessionProviderProps {
|
|
|
50
50
|
*
|
|
51
51
|
* @category Components
|
|
52
52
|
*/
|
|
53
|
-
declare const FakeSessionProvider: ({ children, connectError, isLocked, party, readingAccounts, sdk, status: initialStatus }: FakeSessionProviderProps) => JSX.Element;
|
|
53
|
+
export declare const FakeSessionProvider: ({ children, connectError, isLocked, party, readingAccounts, sdk, status: initialStatus }: FakeSessionProviderProps) => JSX.Element;
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/testing/fakeWallet.d.ts
|
|
56
56
|
/**
|
|
@@ -109,7 +109,7 @@ interface FakeWallet {
|
|
|
109
109
|
*
|
|
110
110
|
* @category Utilities
|
|
111
111
|
*/
|
|
112
|
-
declare const createFakeWallet: (options: FakeWalletOptions) => FakeWallet;
|
|
112
|
+
export declare const createFakeWallet: (options: FakeWalletOptions) => FakeWallet;
|
|
113
113
|
//#endregion
|
|
114
114
|
//#region src/testing/pause.d.ts
|
|
115
115
|
/**
|
|
@@ -122,6 +122,6 @@ declare const createFakeWallet: (options: FakeWalletOptions) => FakeWallet;
|
|
|
122
122
|
*
|
|
123
123
|
* @category Utilities
|
|
124
124
|
*/
|
|
125
|
-
declare const pause: (ms: number) => Promise<unknown>;
|
|
125
|
+
export declare const pause: (ms: number) => Promise<unknown>;
|
|
126
126
|
//#endregion
|
|
127
|
-
export {
|
|
127
|
+
export type { FakeSessionProviderProps, FakeWallet, FakeWalletAccount, FakeWalletOptions };
|
|
@@ -329,7 +329,22 @@ interface Party {
|
|
|
329
329
|
* and that surface is yours. The app fields stay inert until `walletConnectProjectId` (Reown) is set.
|
|
330
330
|
*
|
|
331
331
|
* @example
|
|
332
|
-
* const config: CantonConnectConfig = {
|
|
332
|
+
* const config: CantonConnectConfig = {
|
|
333
|
+
* appName: 'Vesting',
|
|
334
|
+
* networkId: 'canton:devnet',
|
|
335
|
+
* walletConnectProjectId: 'REOWN_PROJECT_ID',
|
|
336
|
+
* }
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* import type { CantonConnectConfig } from '#src/types'
|
|
340
|
+
* import { RemoteAdapter } from '@canton-network/dapp-sdk'
|
|
341
|
+
*
|
|
342
|
+
* const config: CantonConnectConfig = {
|
|
343
|
+
* appName: 'Vesting',
|
|
344
|
+
* additionalAdapters: [
|
|
345
|
+
* new RemoteAdapter({ name: 'Gateway', rpcUrl: 'https://gateway.example.com/dapp' }),
|
|
346
|
+
* ],
|
|
347
|
+
* }
|
|
333
348
|
*
|
|
334
349
|
* @category Configuration
|
|
335
350
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bootnodedev/canton-connect",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "wagmi-style React hooks for connecting Canton dApps to CIP-0103 wallets",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/BootNodeDev/canton-dappbooster.git",
|
|
8
|
+
"directory": "canton-connect"
|
|
9
|
+
},
|
|
5
10
|
"license": "MIT",
|
|
6
11
|
"type": "module",
|
|
7
12
|
"private": false,
|
|
@@ -44,11 +49,6 @@
|
|
|
44
49
|
"@walletconnect/sign-client": "^2.23.9",
|
|
45
50
|
"react": "^19.0.0"
|
|
46
51
|
},
|
|
47
|
-
"peerDependenciesMeta": {
|
|
48
|
-
"@walletconnect/sign-client": {
|
|
49
|
-
"optional": true
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@canton-network/core-types": "1.10.0",
|
|
54
54
|
"@canton-network/dapp-sdk": "1.5.1",
|
|
@@ -58,16 +58,16 @@
|
|
|
58
58
|
"@types/react": "^19.2.17",
|
|
59
59
|
"@types/react-dom": "^19.2.3",
|
|
60
60
|
"@vitejs/plugin-react": "^6.0.4",
|
|
61
|
-
"@vitest/coverage-v8": "^
|
|
61
|
+
"@vitest/coverage-v8": "^5.0.0",
|
|
62
62
|
"@walletconnect/sign-client": "^2.23.9",
|
|
63
63
|
"@walletconnect/types": "^2.23.9",
|
|
64
64
|
"jsdom": "^30.0.0",
|
|
65
65
|
"react": "^19.2.8",
|
|
66
66
|
"react-dom": "^19.2.8",
|
|
67
|
-
"tsdown": "^0.
|
|
67
|
+
"tsdown": "^0.23.0",
|
|
68
68
|
"typescript": "^5.9.3",
|
|
69
69
|
"vite": "^8.1.5",
|
|
70
|
-
"vitest": "^
|
|
70
|
+
"vitest": "^5.0.0"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@xstate/react": "^6.1.0",
|