@canton-network/dapp-sdk 0.1.0 → 0.2.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 CHANGED
@@ -1,11 +1,23 @@
1
- # SDK
1
+ # DApp SDK
2
2
 
3
- Connects your Splice dApp to Wallet Client users.
3
+ This SDK is for 3rd-party dApps developed against the Canton Network. It's intended to be used in a browser to securely connect users to Canton Network wallets. Once connected, the SDK provides a dApp UI permissions to read a user's selected Canton party and request transaction signatures.
4
4
 
5
- ## Build
5
+ The dApp SDK aims to adopt or follow Ethereum development conventions where possible, for example [eip-1193](https://eips.ethereum.org/EIPS/eip-1193).
6
6
 
7
- Generate the client code and build the SDK:
7
+ ## Installation
8
8
 
9
- ```sh
10
- yarn build
9
+ Install the SDK with your package manager of choice
10
+
11
+ ```shell
12
+ $ npm install @canton-network/dapp-sdk
13
+ ```
14
+
15
+ or
16
+
17
+ ```shell
18
+ $ yarn add @canton-network/dapp-sdk
11
19
  ```
20
+
21
+ ## Getting Started
22
+
23
+ Coming soon...
@@ -0,0 +1,13 @@
1
+ import * as dappAPI from '@canton-network/core-wallet-dapp-rpc-client';
2
+ export * from '@canton-network/core-splice-provider';
3
+ export declare enum ErrorCode {
4
+ UserCancelled = 0,
5
+ Other = 1
6
+ }
7
+ export type ConnectError = {
8
+ status: 'error';
9
+ error: ErrorCode;
10
+ details: string;
11
+ };
12
+ export declare function connect(): Promise<dappAPI.ConnectResult>;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connect/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,OAAO,MAAM,6CAA6C,CAAA;AAOtE,cAAc,sCAAsC,CAAA;AAqCpD,oBAAY,SAAS;IACjB,aAAa,IAAA;IACb,KAAK,IAAA;CACR;AAED,MAAM,MAAM,YAAY,GAAG;IACvB,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,SAAS,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,wBAAsB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CA+B9D"}
@@ -0,0 +1,67 @@
1
+ // Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { discover, popupHref } from '@canton-network/core-wallet-ui-components';
4
+ import { injectSpliceProvider, ProviderType, } from '@canton-network/core-splice-provider';
5
+ import * as storage from '../storage';
6
+ import { WalletEvent, } from '@canton-network/core-types';
7
+ export * from '@canton-network/core-splice-provider';
8
+ const injectProvider = ({ walletType, url }) => {
9
+ if (walletType === 'remote') {
10
+ return injectSpliceProvider(ProviderType.HTTP, new URL(url), storage.getKernelSession()?.sessionToken);
11
+ }
12
+ else {
13
+ return injectSpliceProvider(ProviderType.WINDOW);
14
+ }
15
+ };
16
+ // On page load, restore and re-register the listener if needed
17
+ const discovery = storage.getKernelDiscovery();
18
+ if (discovery)
19
+ injectProvider(discovery);
20
+ const openKernelUserUI = (walletType, userUrl) => {
21
+ switch (walletType) {
22
+ case 'remote':
23
+ popupHref(new URL(userUrl));
24
+ break;
25
+ case 'extension': {
26
+ const msg = {
27
+ type: WalletEvent.SPLICE_WALLET_EXT_OPEN,
28
+ url: userUrl,
29
+ };
30
+ window.postMessage(msg, '*');
31
+ break;
32
+ }
33
+ }
34
+ };
35
+ export var ErrorCode;
36
+ (function (ErrorCode) {
37
+ ErrorCode[ErrorCode["UserCancelled"] = 0] = "UserCancelled";
38
+ ErrorCode[ErrorCode["Other"] = 1] = "Other";
39
+ })(ErrorCode || (ErrorCode = {}));
40
+ export async function connect() {
41
+ return discover()
42
+ .then(async (result) => {
43
+ // Store discovery result and remove previous session
44
+ storage.setKernelDiscovery(result);
45
+ storage.removeKernelSession();
46
+ const provider = injectProvider(result);
47
+ // Listen for connected event from the provider
48
+ // This will be triggered when the user connects to the wallet kernel
49
+ provider.on('onConnected', (event) => {
50
+ console.log('SDK: Store connection', event);
51
+ storage.setKernelSession(event);
52
+ });
53
+ const response = await provider.request({
54
+ method: 'connect',
55
+ });
56
+ if (!response.isConnected)
57
+ openKernelUserUI(result.walletType, response.userUrl);
58
+ return response;
59
+ })
60
+ .catch((err) => {
61
+ throw {
62
+ status: 'error',
63
+ error: ErrorCode.Other,
64
+ details: err instanceof Error ? err.message : String(err),
65
+ };
66
+ });
67
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=listNetworks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listNetworks.d.ts","sourceRoot":"","sources":["../../src/connect/listNetworks.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,OAAO,KAAK,OAAO,MAAM,6CAA6C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,WAAW,CAAA;AACzB,OAAO,KAAK,OAAO,MAAM,6CAA6C,CAAA"}
package/dist/index.js CHANGED
@@ -1,2 +1,4 @@
1
+ // Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
1
3
  export * from './connect';
2
4
  export * as dappAPI from '@canton-network/core-wallet-dapp-rpc-client';
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,OAAO,MAAM,6CAA6C,CAAA;AAOtE,eAAO,MAAM,kBAAkB,QAAO,cAAc,GAAG,SAUtD,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,WAAW,cAAc,KAAG,IAK9D,CAAA;AAED,eAAO,MAAM,gBAAgB,QAAO,OAAO,CAAC,gBAAgB,GAAG,SAU9D,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,SAAS,OAAO,CAAC,gBAAgB,KAAG,IAEpE,CAAA;AAED,eAAO,MAAM,mBAAmB,QAAO,IAEtC,CAAA"}
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,OAAO,MAAM,6CAA6C,CAAA;AAOtE,eAAO,MAAM,kBAAkB,QAAO,cAAc,GAAG,SAUtD,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,WAAW,cAAc,KAAG,IAK9D,CAAA;AAED,eAAO,MAAM,gBAAgB,QAAO,OAAO,CAAC,gBAAgB,GAAG,SAU9D,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,SAAS,OAAO,CAAC,gBAAgB,KAAG,IAEpE,CAAA;AAED,eAAO,MAAM,mBAAmB,QAAO,IAEtC,CAAA"}
package/dist/storage.js CHANGED
@@ -1,3 +1,5 @@
1
+ // Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
1
3
  import { DiscoverResult } from '@canton-network/core-types';
2
4
  var LOCAL_STORAGE;
3
5
  (function (LOCAL_STORAGE) {
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@canton-network/dapp-sdk",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.2.0",
5
5
  "description": "Browser SDK for dApp development on the Canton Network",
6
- "repository": "https://github.com/hyperledger-labs/splice-wallet-kernel",
6
+ "repository": "github:hyperledger-labs/splice-wallet-kernel",
7
7
  "license": "Apache-2.0",
8
8
  "author": "Marc Juchli <marc.juchli@digitalasset.com>",
9
9
  "main": "dist/index.js",
@@ -15,16 +15,16 @@
15
15
  "test": "echo \"Warning: no test specified\""
16
16
  },
17
17
  "dependencies": {
18
- "@canton-network/core-splice-provider": "^0.1.0",
19
- "@canton-network/core-types": "^0.1.0",
18
+ "@canton-network/core-splice-provider": "^0.2.0",
19
+ "@canton-network/core-types": "^0.2.0",
20
20
  "@canton-network/core-wallet-dapp-rpc-client": "^0.1.0",
21
- "@canton-network/core-wallet-ui-components": "^0.1.0"
21
+ "@canton-network/core-wallet-ui-components": "^0.2.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "typescript": "^5.8.3"
25
25
  },
26
26
  "files": [
27
- "dist/*"
27
+ "dist/**"
28
28
  ],
29
29
  "publishConfig": {
30
30
  "access": "public"