@canton-network/dapp-sdk 0.7.0 → 0.8.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/dist/error.d.ts +14 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +19 -0
- package/dist/index.d.ts +6 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -7
- package/dist/provider/events.d.ts +5 -0
- package/dist/provider/events.d.ts.map +1 -0
- package/dist/provider/events.js +9 -0
- package/dist/provider/gateways.json +10 -0
- package/dist/provider/index.d.ts +3 -0
- package/dist/provider/index.d.ts.map +1 -0
- package/dist/provider/index.js +12 -0
- package/dist/provider/open.d.ts +2 -0
- package/dist/provider/open.d.ts.map +1 -0
- package/dist/provider/open.js +15 -0
- package/dist/provider/request.d.ts +8 -0
- package/dist/provider/request.d.ts.map +1 -0
- package/dist/{connect/index.js → provider/request.js} +32 -23
- package/dist/provider.js +1 -1
- package/package.json +9 -7
- package/src/provider/gateways.json +10 -0
- package/dist/connect/index.d.ts +0 -5
- package/dist/connect/index.d.ts.map +0 -1
- package/dist/connect/listNetworks.d.ts +0 -1
- package/dist/connect/listNetworks.d.ts.map +0 -1
- package/dist/connect/listNetworks.js +0 -3
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SpliceProvider } from '@canton-network/core-splice-provider';
|
|
2
|
+
export declare enum ErrorCode {
|
|
3
|
+
ProviderNotFound = 0,
|
|
4
|
+
UserCancelled = 1,
|
|
5
|
+
Timeout = 2,
|
|
6
|
+
Other = 3
|
|
7
|
+
}
|
|
8
|
+
export type ConnectError = {
|
|
9
|
+
status: 'error';
|
|
10
|
+
error: ErrorCode;
|
|
11
|
+
details: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const assertProvider: () => SpliceProvider;
|
|
14
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AAErE,oBAAY,SAAS;IACjB,gBAAgB,IAAA;IAChB,aAAa,IAAA;IACb,OAAO,IAAA;IACP,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,eAAO,MAAM,cAAc,QAAO,cAUjC,CAAA"}
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export var ErrorCode;
|
|
4
|
+
(function (ErrorCode) {
|
|
5
|
+
ErrorCode[ErrorCode["ProviderNotFound"] = 0] = "ProviderNotFound";
|
|
6
|
+
ErrorCode[ErrorCode["UserCancelled"] = 1] = "UserCancelled";
|
|
7
|
+
ErrorCode[ErrorCode["Timeout"] = 2] = "Timeout";
|
|
8
|
+
ErrorCode[ErrorCode["Other"] = 3] = "Other";
|
|
9
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
10
|
+
export const assertProvider = () => {
|
|
11
|
+
if (!window.canton) {
|
|
12
|
+
throw {
|
|
13
|
+
status: 'error',
|
|
14
|
+
error: ErrorCode.ProviderNotFound,
|
|
15
|
+
details: 'Canton provider not found. Please install the Splice Wallet.',
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return window.canton;
|
|
19
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './error';
|
|
2
|
+
export * from './provider';
|
|
3
|
+
export * from './provider/index';
|
|
4
|
+
export * from './provider/request';
|
|
5
|
+
export * from './provider/events';
|
|
6
|
+
export * from './provider/open';
|
|
2
7
|
export * as dappAPI from '@canton-network/core-wallet-dapp-rpc-client';
|
|
3
|
-
export declare enum ErrorCode {
|
|
4
|
-
UserCancelled = 0,
|
|
5
|
-
Timeout = 1,
|
|
6
|
-
Other = 2
|
|
7
|
-
}
|
|
8
|
-
export type ConnectError = {
|
|
9
|
-
status: 'error';
|
|
10
|
-
error: ErrorCode;
|
|
11
|
-
details: string;
|
|
12
|
-
};
|
|
13
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,OAAO,KAAK,OAAO,MAAM,6CAA6C,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
export * from './
|
|
3
|
+
export * from './error';
|
|
4
|
+
export * from './provider';
|
|
5
|
+
export * from './provider/index';
|
|
6
|
+
export * from './provider/request';
|
|
7
|
+
export * from './provider/events';
|
|
8
|
+
export * from './provider/open';
|
|
4
9
|
export * as dappAPI from '@canton-network/core-wallet-dapp-rpc-client';
|
|
5
|
-
export var ErrorCode;
|
|
6
|
-
(function (ErrorCode) {
|
|
7
|
-
ErrorCode[ErrorCode["UserCancelled"] = 0] = "UserCancelled";
|
|
8
|
-
ErrorCode[ErrorCode["Timeout"] = 1] = "Timeout";
|
|
9
|
-
ErrorCode[ErrorCode["Other"] = 2] = "Other";
|
|
10
|
-
})(ErrorCode || (ErrorCode = {}));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as dappAPI from '@canton-network/core-wallet-dapp-rpc-client';
|
|
2
|
+
import { EventListener } from '@canton-network/core-splice-provider';
|
|
3
|
+
export declare function onAccountsChanged(listener: EventListener<dappAPI.AccountsChangedEvent>): Promise<void>;
|
|
4
|
+
export declare function onTxChanged(listener: EventListener<dappAPI.TxChangedEvent>): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/provider/events.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,OAAO,MAAM,6CAA6C,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;AAGpE,wBAAsB,iBAAiB,CACnC,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,oBAAoB,CAAC,GACtD,OAAO,CAAC,IAAI,CAAC,CAKf;AAED,wBAAsB,WAAW,CAC7B,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,cAAc,CAAC,GAChD,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { assertProvider } from '../error.js';
|
|
4
|
+
export async function onAccountsChanged(listener) {
|
|
5
|
+
assertProvider().on('accountsChanged', listener);
|
|
6
|
+
}
|
|
7
|
+
export async function onTxChanged(listener) {
|
|
8
|
+
assertProvider().on('txChanged', listener);
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAK3D,eAAO,MAAM,cAAc,GAAI,WAAW,cAAc,kEAIvD,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Provider } from '../provider';
|
|
4
|
+
import { injectSpliceProvider } from '@canton-network/core-splice-provider';
|
|
5
|
+
import * as storage from '../storage';
|
|
6
|
+
export const injectProvider = (discovery) => {
|
|
7
|
+
return injectSpliceProvider(new Provider(discovery, storage.getKernelSession()?.sessionToken));
|
|
8
|
+
};
|
|
9
|
+
// On page load, restore and re-register the listener if needed
|
|
10
|
+
const discovery = storage.getKernelDiscovery();
|
|
11
|
+
if (discovery)
|
|
12
|
+
injectProvider(discovery);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../src/provider/open.ts"],"names":[],"mappings":"AAMA,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAY1C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { openKernelUserUI } from '../provider';
|
|
4
|
+
import * as storage from '../storage';
|
|
5
|
+
export async function open() {
|
|
6
|
+
const discovery = storage.getKernelDiscovery();
|
|
7
|
+
if (!discovery) {
|
|
8
|
+
throw new Error('No previous discovery found');
|
|
9
|
+
}
|
|
10
|
+
const session = storage.getKernelSession();
|
|
11
|
+
if (!session) {
|
|
12
|
+
throw new Error('No previous session found');
|
|
13
|
+
}
|
|
14
|
+
openKernelUserUI(discovery.walletType, session.kernel.userUrl ?? '');
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as dappAPI from '@canton-network/core-wallet-dapp-rpc-client';
|
|
2
|
+
export declare function connect(): Promise<dappAPI.ConnectResult>;
|
|
3
|
+
export declare function status(): Promise<dappAPI.StatusResult>;
|
|
4
|
+
export declare function darsAvailable(): Promise<dappAPI.DarsAvailableResult>;
|
|
5
|
+
export declare function requestAccounts(): Promise<dappAPI.RequestAccountsResult>;
|
|
6
|
+
export declare function prepareExecute(params: dappAPI.PrepareExecuteParams): Promise<dappAPI.PrepareExecuteResult>;
|
|
7
|
+
export declare function ledgerApi(params: dappAPI.LedgerApiParams): Promise<dappAPI.LedgerApiResult>;
|
|
8
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/provider/request.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,OAAO,MAAM,6CAA6C,CAAA;AAQtE,wBAAsB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CA+B9D;AAED,wBAAsB,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAI5D;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAI1E;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAI9E;AAED,wBAAsB,cAAc,CAChC,MAAM,EAAE,OAAO,CAAC,oBAAoB,GACrC,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAKvC;AAED,wBAAsB,SAAS,CAC3B,MAAM,EAAE,OAAO,CAAC,eAAe,GAChC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAKlC"}
|
|
@@ -1,31 +1,13 @@
|
|
|
1
1
|
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { injectSpliceProvider } from '@canton-network/core-splice-provider';
|
|
4
3
|
import { discover } from '@canton-network/core-wallet-ui-components';
|
|
4
|
+
import { assertProvider, ErrorCode } from '../error.js';
|
|
5
5
|
import * as storage from '../storage';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import { ErrorCode } from '../index';
|
|
9
|
-
const injectProvider = (discovery) => {
|
|
10
|
-
return injectSpliceProvider(new Provider(discovery, storage.getKernelSession()?.sessionToken));
|
|
11
|
-
};
|
|
12
|
-
// On page load, restore and re-register the listener if needed
|
|
13
|
-
const discovery = storage.getKernelDiscovery();
|
|
14
|
-
if (discovery)
|
|
15
|
-
injectProvider(discovery);
|
|
16
|
-
export async function open() {
|
|
17
|
-
const discovery = storage.getKernelDiscovery();
|
|
18
|
-
if (!discovery) {
|
|
19
|
-
throw new Error('No previous discovery found');
|
|
20
|
-
}
|
|
21
|
-
const session = storage.getKernelSession();
|
|
22
|
-
if (!session) {
|
|
23
|
-
throw new Error('No previous session found');
|
|
24
|
-
}
|
|
25
|
-
openKernelUserUI(discovery.walletType, session.kernel.userUrl ?? '');
|
|
26
|
-
}
|
|
6
|
+
import { injectProvider } from './index';
|
|
7
|
+
import gateways from './gateways.json';
|
|
27
8
|
export async function connect() {
|
|
28
|
-
|
|
9
|
+
const config = gateways;
|
|
10
|
+
return discover(config)
|
|
29
11
|
.then(async (result) => {
|
|
30
12
|
// Store discovery result and remove previous session
|
|
31
13
|
storage.setKernelDiscovery(result);
|
|
@@ -53,3 +35,30 @@ export async function connect() {
|
|
|
53
35
|
};
|
|
54
36
|
});
|
|
55
37
|
}
|
|
38
|
+
export async function status() {
|
|
39
|
+
return await assertProvider().request({
|
|
40
|
+
method: 'status',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export async function darsAvailable() {
|
|
44
|
+
return await assertProvider().request({
|
|
45
|
+
method: 'darsAvailable',
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export async function requestAccounts() {
|
|
49
|
+
return await assertProvider().request({
|
|
50
|
+
method: 'requestAccounts',
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export async function prepareExecute(params) {
|
|
54
|
+
return await assertProvider().request({
|
|
55
|
+
method: 'prepareExecute',
|
|
56
|
+
params,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export async function ledgerApi(params) {
|
|
60
|
+
return await assertProvider().request({
|
|
61
|
+
method: 'ledgerApi',
|
|
62
|
+
params,
|
|
63
|
+
});
|
|
64
|
+
}
|
package/dist/provider.js
CHANGED
|
@@ -5,7 +5,7 @@ import { WalletEvent, } from '@canton-network/core-types';
|
|
|
5
5
|
import { popupHref } from '@canton-network/core-wallet-ui-components';
|
|
6
6
|
import { SpliceProviderHttp, SpliceProviderWindow, } from '@canton-network/core-splice-provider';
|
|
7
7
|
import buildController from './dapp-api/rpc-gen';
|
|
8
|
-
import { ErrorCode } from './
|
|
8
|
+
import { ErrorCode } from './error.js';
|
|
9
9
|
/**
|
|
10
10
|
* The Provider class abstracts over the different types of SpliceProviders (Window and HTTP).
|
|
11
11
|
* It selects the appropriate provider based on the wallet type discovered during the connection process.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canton-network/dapp-sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"description": "Browser SDK for dApp development on the Canton Network",
|
|
6
6
|
"repository": "github:hyperledger-labs/splice-wallet-kernel",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -11,21 +11,23 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "tsc -b",
|
|
13
13
|
"dev": "tsc -b --watch",
|
|
14
|
+
"flatpack": "yarn pack --out \"$FLATPACK_OUTDIR\"",
|
|
14
15
|
"clean": "tsc -b --clean; rm -rf dist",
|
|
15
16
|
"test": "echo \"Warning: no test specified\""
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
|
-
"@canton-network/core-splice-provider": "
|
|
19
|
-
"@canton-network/core-types": "
|
|
20
|
-
"@canton-network/core-wallet-dapp-remote-rpc-client": "
|
|
21
|
-
"@canton-network/core-wallet-dapp-rpc-client": "
|
|
22
|
-
"@canton-network/core-wallet-ui-components": "
|
|
19
|
+
"@canton-network/core-splice-provider": "",
|
|
20
|
+
"@canton-network/core-types": "",
|
|
21
|
+
"@canton-network/core-wallet-dapp-remote-rpc-client": "",
|
|
22
|
+
"@canton-network/core-wallet-dapp-rpc-client": "",
|
|
23
|
+
"@canton-network/core-wallet-ui-components": ""
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
26
|
"typescript": "^5.8.3"
|
|
26
27
|
},
|
|
27
28
|
"files": [
|
|
28
|
-
"dist/**"
|
|
29
|
+
"dist/**",
|
|
30
|
+
"src/provider/gateways.json"
|
|
29
31
|
],
|
|
30
32
|
"publishConfig": {
|
|
31
33
|
"access": "public"
|
package/dist/connect/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export * from '@canton-network/core-splice-provider';
|
|
2
|
-
import * as dappAPI from '@canton-network/core-wallet-dapp-rpc-client';
|
|
3
|
-
export declare function open(): Promise<void>;
|
|
4
|
-
export declare function connect(): Promise<dappAPI.ConnectResult>;
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connect/index.ts"],"names":[],"mappings":"AASA,cAAc,sCAAsC,CAAA;AACpD,OAAO,KAAK,OAAO,MAAM,6CAA6C,CAAA;AAatE,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAY1C;AAED,wBAAsB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CA8B9D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=listNetworks.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listNetworks.d.ts","sourceRoot":"","sources":["../../src/connect/listNetworks.ts"],"names":[],"mappings":""}
|