@canton-network/core-wallet-ui-components 0.4.0 → 0.6.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 +1 -1
- package/dist/components/AppHeader.d.ts +12 -3
- package/dist/components/AppHeader.d.ts.map +1 -1
- package/dist/components/AppLayout.d.ts +3 -3
- package/dist/components/AppLayout.d.ts.map +1 -1
- package/dist/components/Discovery.d.ts +8 -2
- package/dist/components/Discovery.d.ts.map +1 -1
- package/dist/components/NetworkForm.d.ts +3 -3
- package/dist/components/NetworkForm.d.ts.map +1 -1
- package/dist/components/NetworkTable.d.ts +3 -3
- package/dist/components/NetworkTable.d.ts.map +1 -1
- package/dist/index.css +5 -0
- package/dist/index.d.ts +2 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1357 -83
- package/dist/internal/BaseElement.d.ts +10 -0
- package/dist/internal/BaseElement.d.ts.map +1 -0
- package/dist/styles/index.d.ts +4 -0
- package/dist/styles/index.d.ts.map +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/windows/popup.d.ts +5 -1
- package/dist/windows/popup.d.ts.map +1 -1
- package/package.json +15 -8
- package/themes/default.css +6 -0
- package/dist/components/AppHeader.js +0 -73
- package/dist/components/AppLayout.js +0 -87
- package/dist/components/Configuration.d.ts +0 -5
- package/dist/components/Configuration.d.ts.map +0 -1
- package/dist/components/Configuration.js +0 -24
- package/dist/components/Discovery.js +0 -148
- package/dist/components/NetworkForm.js +0 -164
- package/dist/components/NetworkTable.js +0 -67
- package/dist/themes/styles.d.ts +0 -2
- package/dist/themes/styles.d.ts.map +0 -1
- package/dist/themes/styles.js +0 -75
- package/dist/windows/discovery.js +0 -32
- package/dist/windows/popup.js +0 -64
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CSSResultGroup, LitElement } from 'lit';
|
|
2
|
+
import 'bootstrap/dist/css/bootstrap.min.css';
|
|
3
|
+
import '../../themes/default.css';
|
|
4
|
+
/**
|
|
5
|
+
* Use this element as the base class for all custom elements to ensure consistent theming
|
|
6
|
+
*/
|
|
7
|
+
export declare class BaseElement extends LitElement {
|
|
8
|
+
static styles: CSSResultGroup;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=BaseElement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseElement.d.ts","sourceRoot":"","sources":["../../src/internal/BaseElement.ts"],"names":[],"mappings":"AAGA,OAAO,EAAO,cAAc,EAAE,UAAU,EAAa,MAAM,KAAK,CAAA;AAEhE,OAAO,sCAAsC,CAAA;AAC7C,OAAO,0BAA0B,CAAA;AAMjC;;GAEG;AACH,qBAAa,WAAY,SAAQ,UAAU;IACvC,MAAM,CAAC,MAAM,EAqBR,cAAc,CAAA;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/styles/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAO,cAAc,EAAE,MAAM,KAAK,CAAA;wBAgBhB,cAAc;AAAvC,wBAAuC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,cAAc,EAAE,MAAM,KAAK,CAAA;AAE/C,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAQ1D"}
|
package/dist/windows/popup.d.ts
CHANGED
|
@@ -6,7 +6,11 @@ interface PopupOptions {
|
|
|
6
6
|
screenX?: number;
|
|
7
7
|
screenY?: number;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
interface StyledElement {
|
|
10
|
+
new (): HTMLElement;
|
|
11
|
+
styles: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function popup(component: StyledElement, options?: PopupOptions): Promise<Window>;
|
|
10
14
|
export declare function popupHref(url: URL | string, options?: PopupOptions): Promise<Window>;
|
|
11
15
|
export {};
|
|
12
16
|
//# sourceMappingURL=popup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popup.d.ts","sourceRoot":"","sources":["../../src/windows/popup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"popup.d.ts","sourceRoot":"","sources":["../../src/windows/popup.ts"],"names":[],"mappings":"AAGA,UAAU,YAAY;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,UAAU,aAAa;IACnB,QAAQ,WAAW,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,KAAK,CACjB,SAAS,EAAE,aAAa,EACxB,OAAO,CAAC,EAAE,YAAY,GACvB,OAAO,CAAC,MAAM,CAAC,CA6EjB;AAED,wBAAgB,SAAS,CACrB,GAAG,EAAE,GAAG,GAAG,MAAM,EACjB,OAAO,CAAC,EAAE,YAAY,GACvB,OAAO,CAAC,MAAM,CAAC,CAuBjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canton-network/core-wallet-ui-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Reusable UI components for the Splice wallet",
|
|
6
6
|
"repository": "github:hyperledger-labs/splice-wallet-kernel",
|
|
@@ -13,26 +13,33 @@
|
|
|
13
13
|
"./themes": "./themes"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
-
"build": "tsc
|
|
17
|
-
"build:watch": "tsc
|
|
18
|
-
"
|
|
19
|
-
"
|
|
16
|
+
"build": "vite build && tsc --emitDeclarationOnly",
|
|
17
|
+
"build:watch": "vite build --watch & tsc --emitDeclarationOnly --watch",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"clean": "tsc -b --clean; rm -rf dist",
|
|
20
|
+
"dev": "storybook dev -p 6006"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
23
|
+
"@storybook/web-components-vite": "^9.1.10",
|
|
22
24
|
"@types/bootstrap": "^5",
|
|
25
|
+
"@types/fs-extra": "^11",
|
|
26
|
+
"fs-extra": "^11.3.2",
|
|
27
|
+
"storybook": "^9.1.10",
|
|
28
|
+
"tsx": "^4.20.4",
|
|
23
29
|
"typescript": "^5.8.3",
|
|
24
30
|
"vite": "^6.3.5"
|
|
25
31
|
},
|
|
26
32
|
"packageManager": "yarn@4.9.4",
|
|
27
33
|
"dependencies": {
|
|
28
|
-
"@canton-network/core-types": "^0.
|
|
29
|
-
"@canton-network/core-wallet-store": "^0.
|
|
34
|
+
"@canton-network/core-types": "^0.6.0",
|
|
35
|
+
"@canton-network/core-wallet-store": "^0.6.0",
|
|
30
36
|
"@popperjs/core": "^2.11.8",
|
|
31
37
|
"bootstrap": "^5.3.7",
|
|
32
38
|
"lit": "^3.3.0"
|
|
33
39
|
},
|
|
34
40
|
"files": [
|
|
35
|
-
"dist/**"
|
|
41
|
+
"dist/**",
|
|
42
|
+
"themes/**"
|
|
36
43
|
],
|
|
37
44
|
"publishConfig": {
|
|
38
45
|
"access": "public"
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
-
};
|
|
9
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11
|
-
};
|
|
12
|
-
import { LitElement, html } from 'lit';
|
|
13
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
14
|
-
let AppHeader = class AppHeader extends LitElement {
|
|
15
|
-
constructor() {
|
|
16
|
-
super(...arguments);
|
|
17
|
-
this.iconSrc = 'images/icon.png';
|
|
18
|
-
}
|
|
19
|
-
// Prevent shadow DOM so external CSS applies
|
|
20
|
-
createRenderRoot() {
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
render() {
|
|
24
|
-
return html `
|
|
25
|
-
<div
|
|
26
|
-
class="header d-flex justify-content-between align-items-center"
|
|
27
|
-
>
|
|
28
|
-
<h2>
|
|
29
|
-
<div
|
|
30
|
-
class="logo-box"
|
|
31
|
-
@click=${() => (window.location.href = '/')}
|
|
32
|
-
aria-label="Go to home"
|
|
33
|
-
>
|
|
34
|
-
<img
|
|
35
|
-
src="${this.iconSrc}"
|
|
36
|
-
alt="Icon"
|
|
37
|
-
width="24"
|
|
38
|
-
height="24"
|
|
39
|
-
/>
|
|
40
|
-
Splice Wallet
|
|
41
|
-
</div>
|
|
42
|
-
</h2>
|
|
43
|
-
<div>
|
|
44
|
-
<button
|
|
45
|
-
class="btn btn-outline-secondary btn-sm"
|
|
46
|
-
id="settingsButton"
|
|
47
|
-
@click=${() => (window.location.href = '/networks/')}
|
|
48
|
-
>
|
|
49
|
-
Settings
|
|
50
|
-
</button>
|
|
51
|
-
<button
|
|
52
|
-
class="btn btn-outline-secondary btn-sm"
|
|
53
|
-
@click=${() => {
|
|
54
|
-
localStorage.clear();
|
|
55
|
-
window.location.href = '/login';
|
|
56
|
-
}}
|
|
57
|
-
id="logoutButton"
|
|
58
|
-
>
|
|
59
|
-
Logout
|
|
60
|
-
</button>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
`;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
__decorate([
|
|
67
|
-
property({ type: String }),
|
|
68
|
-
__metadata("design:type", String)
|
|
69
|
-
], AppHeader.prototype, "iconSrc", void 0);
|
|
70
|
-
AppHeader = __decorate([
|
|
71
|
-
customElement('app-header')
|
|
72
|
-
], AppHeader);
|
|
73
|
-
export { AppHeader };
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
-
};
|
|
9
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11
|
-
};
|
|
12
|
-
import { LitElement, html, css, unsafeCSS } from 'lit';
|
|
13
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
14
|
-
import bootstrapCss from 'bootstrap/dist/css/bootstrap.min.css?inline';
|
|
15
|
-
import defaultTheme from '../../themes/default.css?inline';
|
|
16
|
-
let AppLayout = class AppLayout extends LitElement {
|
|
17
|
-
constructor() {
|
|
18
|
-
super(...arguments);
|
|
19
|
-
this.iconSrc = '/images/icon.png';
|
|
20
|
-
this.customThemeCss = null;
|
|
21
|
-
}
|
|
22
|
-
static { this.styles = css `
|
|
23
|
-
${unsafeCSS(bootstrapCss.replaceAll(/:root/g, ':root,:host'))}
|
|
24
|
-
|
|
25
|
-
:host {
|
|
26
|
-
--bs-body-color: var(--splice-wk-text-color);
|
|
27
|
-
|
|
28
|
-
margin: 0;
|
|
29
|
-
font-family: var(--bs-body-font-family);
|
|
30
|
-
font-size: var(--bs-body-font-size);
|
|
31
|
-
font-weight: var(--bs-body-font-weight);
|
|
32
|
-
line-height: var(--bs-body-line-height);
|
|
33
|
-
color: var(--bs-body-color);
|
|
34
|
-
text-align: var(--bs-body-text-align);
|
|
35
|
-
background-color: var(--bs-body-bg);
|
|
36
|
-
-webkit-text-size-adjust: 100%;
|
|
37
|
-
-webkit-tap-highlight-color: transparent;
|
|
38
|
-
}
|
|
39
|
-
`; }
|
|
40
|
-
async updated(changedProps) {
|
|
41
|
-
if (changedProps.has('themeSrc')) {
|
|
42
|
-
if (this.themeSrc) {
|
|
43
|
-
try {
|
|
44
|
-
const res = await fetch(this.themeSrc);
|
|
45
|
-
if (!res.ok)
|
|
46
|
-
throw new Error(`HTTP ${res.status}`);
|
|
47
|
-
this.customThemeCss = await res.text();
|
|
48
|
-
}
|
|
49
|
-
catch (err) {
|
|
50
|
-
console.warn(`[app-layout] Failed to load theme from "${this.themeSrc}":`, err);
|
|
51
|
-
this.customThemeCss = null;
|
|
52
|
-
}
|
|
53
|
-
this.requestUpdate();
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
this.customThemeCss = null;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
get effectiveThemeCss() {
|
|
61
|
-
return this.customThemeCss ?? defaultTheme;
|
|
62
|
-
}
|
|
63
|
-
render() {
|
|
64
|
-
return html `
|
|
65
|
-
<style>
|
|
66
|
-
${unsafeCSS(this.effectiveThemeCss)}
|
|
67
|
-
</style>
|
|
68
|
-
|
|
69
|
-
<app-header .iconSrc=${this.iconSrc}></app-header>
|
|
70
|
-
<div class="container" id="mainContent">
|
|
71
|
-
<slot></slot>
|
|
72
|
-
</div>
|
|
73
|
-
`;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
__decorate([
|
|
77
|
-
property({ type: String }),
|
|
78
|
-
__metadata("design:type", String)
|
|
79
|
-
], AppLayout.prototype, "iconSrc", void 0);
|
|
80
|
-
__decorate([
|
|
81
|
-
property({ type: String }),
|
|
82
|
-
__metadata("design:type", String)
|
|
83
|
-
], AppLayout.prototype, "themeSrc", void 0);
|
|
84
|
-
AppLayout = __decorate([
|
|
85
|
-
customElement('app-layout')
|
|
86
|
-
], AppLayout);
|
|
87
|
-
export { AppLayout };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../../src/components/Configuration.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAA;AAGtC,qBACa,aAAc,SAAQ,UAAU;IACzC,SAAS,CAAC,MAAM;CAQnB"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
-
};
|
|
9
|
-
import { html, LitElement } from 'lit';
|
|
10
|
-
import { customElement } from 'lit/decorators.js';
|
|
11
|
-
let Configuration = class Configuration extends LitElement {
|
|
12
|
-
render() {
|
|
13
|
-
return html `
|
|
14
|
-
<div>
|
|
15
|
-
<h1>Configuration</h1>
|
|
16
|
-
<p>Wallet Kernel configuration page.</p>
|
|
17
|
-
</div>
|
|
18
|
-
`;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
Configuration = __decorate([
|
|
22
|
-
customElement('swk-configuration')
|
|
23
|
-
], Configuration);
|
|
24
|
-
export { Configuration };
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
/**
|
|
4
|
-
* Discovery implements the view of the Wallet Kernel selection window.
|
|
5
|
-
* It is implemented directly as a Web Component without using LitElement, so to avoid having external dependencies.
|
|
6
|
-
*/
|
|
7
|
-
export class Discovery extends HTMLElement {
|
|
8
|
-
static { this.observedAttributes = ['wallet-extension-loaded']; }
|
|
9
|
-
get walletExtensionLoaded() {
|
|
10
|
-
return this.hasAttribute('wallet-extension-loaded');
|
|
11
|
-
}
|
|
12
|
-
set walletExtensionLoaded(val) {
|
|
13
|
-
if (val) {
|
|
14
|
-
this.setAttribute('wallet-extension-loaded', '');
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
this.removeAttribute('wallet-extension-loaded');
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
constructor() {
|
|
21
|
-
super();
|
|
22
|
-
this.attachShadow({ mode: 'open' });
|
|
23
|
-
const styles = document.createElement('style');
|
|
24
|
-
styles.textContent = `
|
|
25
|
-
* {
|
|
26
|
-
color: var(--splice-wk-text-color, black);
|
|
27
|
-
font-family: var(--splice-wk-font-family);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
h1 {
|
|
31
|
-
margin: 0px;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
div {
|
|
35
|
-
background-color: var(--splice-wk-background-color, none);
|
|
36
|
-
width: 100%;
|
|
37
|
-
height: 100%;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.kernel {
|
|
41
|
-
height: auto;
|
|
42
|
-
margin-bottom: 8px;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.kernel button {
|
|
46
|
-
margin-left: 8px;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
input {
|
|
50
|
-
margin-left: 8px;
|
|
51
|
-
}
|
|
52
|
-
`;
|
|
53
|
-
this.root = document.createElement('div');
|
|
54
|
-
this.root.id = 'discovery-root';
|
|
55
|
-
if (this.shadowRoot) {
|
|
56
|
-
this.shadowRoot.appendChild(styles);
|
|
57
|
-
this.shadowRoot.appendChild(this.root);
|
|
58
|
-
}
|
|
59
|
-
if (window.opener) {
|
|
60
|
-
// uses the string literal instead of the WalletEvent enum to avoid bundling issues
|
|
61
|
-
window.opener.postMessage({ type: 'SPLICE_WALLET_EXT_READY' }, '*');
|
|
62
|
-
window.opener.addEventListener('message', (event) => {
|
|
63
|
-
if (event.data.type === 'SPLICE_WALLET_EXT_ACK') {
|
|
64
|
-
this.setAttribute('wallet-extension-loaded', '');
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
verifiedKernels() {
|
|
70
|
-
return [{ url: 'http://localhost:3008/rpc', walletType: 'remote' }];
|
|
71
|
-
}
|
|
72
|
-
renderKernelOption(kernel) {
|
|
73
|
-
const div = document.createElement('div');
|
|
74
|
-
div.setAttribute('class', 'kernel');
|
|
75
|
-
const span = document.createElement('span');
|
|
76
|
-
switch (kernel.walletType) {
|
|
77
|
-
case 'extension':
|
|
78
|
-
span.innerText = 'Browser Extension';
|
|
79
|
-
break;
|
|
80
|
-
case 'remote':
|
|
81
|
-
span.innerText = `${kernel.walletType} - ${kernel.url}`;
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
const button = document.createElement('button');
|
|
85
|
-
button.innerText = `Connect`;
|
|
86
|
-
button.addEventListener('click', () => {
|
|
87
|
-
this.selectKernel(kernel);
|
|
88
|
-
});
|
|
89
|
-
div.appendChild(span);
|
|
90
|
-
div.appendChild(button);
|
|
91
|
-
return div;
|
|
92
|
-
}
|
|
93
|
-
selectKernel(kernel) {
|
|
94
|
-
if (window.opener) {
|
|
95
|
-
window.opener.postMessage(kernel, '*');
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
console.warn('no window opener...');
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
render() {
|
|
102
|
-
const root = document.createElement('div');
|
|
103
|
-
const header = document.createElement('h1');
|
|
104
|
-
header.innerText = 'Add Remote Wallet Kernel';
|
|
105
|
-
const input = document.createElement('input');
|
|
106
|
-
input.setAttribute('autofocus', '');
|
|
107
|
-
input.setAttribute('id', 'wkurl');
|
|
108
|
-
input.setAttribute('type', 'text');
|
|
109
|
-
input.setAttribute('placeholder', 'RPC URL');
|
|
110
|
-
const button = document.createElement('button');
|
|
111
|
-
button.setAttribute('id', 'connect');
|
|
112
|
-
button.innerText = 'Connect';
|
|
113
|
-
button.addEventListener('click', () => {
|
|
114
|
-
const url = input.value;
|
|
115
|
-
console.log('Connecting to Wallet Kernel...' + url);
|
|
116
|
-
this.selectKernel({ url, walletType: 'remote' });
|
|
117
|
-
});
|
|
118
|
-
root.appendChild(header);
|
|
119
|
-
if (this.walletExtensionLoaded) {
|
|
120
|
-
const k = this.renderKernelOption({
|
|
121
|
-
walletType: 'extension',
|
|
122
|
-
});
|
|
123
|
-
root.appendChild(k);
|
|
124
|
-
}
|
|
125
|
-
for (const kernel of this.verifiedKernels()) {
|
|
126
|
-
const k = this.renderKernelOption(kernel);
|
|
127
|
-
root.appendChild(k);
|
|
128
|
-
}
|
|
129
|
-
root.appendChild(input);
|
|
130
|
-
root.appendChild(button);
|
|
131
|
-
// Replace the whole root (except styles), don't append
|
|
132
|
-
if (this.shadowRoot) {
|
|
133
|
-
Array.from(this.shadowRoot.childNodes).forEach((node) => {
|
|
134
|
-
if (!(node instanceof HTMLStyleElement)) {
|
|
135
|
-
this.shadowRoot.removeChild(node);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
this.shadowRoot.appendChild(root);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
connectedCallback() {
|
|
142
|
-
this.render();
|
|
143
|
-
}
|
|
144
|
-
attributeChangedCallback() {
|
|
145
|
-
this.render();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
customElements.define('swk-discovery', Discovery);
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
-
};
|
|
9
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11
|
-
};
|
|
12
|
-
import { LitElement, html } from 'lit';
|
|
13
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
14
|
-
import { styles } from '../themes/styles.js';
|
|
15
|
-
let NetworkForm = class NetworkForm extends LitElement {
|
|
16
|
-
constructor() {
|
|
17
|
-
super(...arguments);
|
|
18
|
-
this.editingNetwork = null;
|
|
19
|
-
this.authType = 'implicit';
|
|
20
|
-
}
|
|
21
|
-
static { this.styles = [styles]; }
|
|
22
|
-
getAuthField(field) {
|
|
23
|
-
if (!this.editingNetwork)
|
|
24
|
-
return '';
|
|
25
|
-
const auth = this.editingNetwork.auth;
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
-
return auth?.[field] ?? '';
|
|
28
|
-
}
|
|
29
|
-
onAuthTypeChange(e) {
|
|
30
|
-
const select = e.target;
|
|
31
|
-
this.authType = select.value;
|
|
32
|
-
}
|
|
33
|
-
handleSubmit(e) {
|
|
34
|
-
e.preventDefault();
|
|
35
|
-
const form = e.target;
|
|
36
|
-
const formData = new FormData(form);
|
|
37
|
-
this.dispatchEvent(new CustomEvent('form-submit', {
|
|
38
|
-
detail: formData,
|
|
39
|
-
bubbles: true,
|
|
40
|
-
composed: true,
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
render() {
|
|
44
|
-
return html `
|
|
45
|
-
<form @submit=${this.handleSubmit}>
|
|
46
|
-
<input
|
|
47
|
-
name="name"
|
|
48
|
-
placeholder="Name"
|
|
49
|
-
.value=${this.editingNetwork?.name ?? ''}
|
|
50
|
-
required
|
|
51
|
-
/>
|
|
52
|
-
<input
|
|
53
|
-
name="chainId"
|
|
54
|
-
placeholder="Network Id"
|
|
55
|
-
.value=${this.editingNetwork?.chainId ?? ''}
|
|
56
|
-
required
|
|
57
|
-
/>
|
|
58
|
-
<input
|
|
59
|
-
name="synchronizerId"
|
|
60
|
-
placeholder="Synchronizer Id"
|
|
61
|
-
.value=${this.editingNetwork?.synchronizerId ?? ''}
|
|
62
|
-
required
|
|
63
|
-
/>
|
|
64
|
-
<input
|
|
65
|
-
name="description"
|
|
66
|
-
placeholder="Description"
|
|
67
|
-
.value=${this.editingNetwork?.description ?? ''}
|
|
68
|
-
required
|
|
69
|
-
/>
|
|
70
|
-
<input
|
|
71
|
-
name="ledgerApi.baseurl"
|
|
72
|
-
placeholder="Ledger API Base Url"
|
|
73
|
-
.value=${this.editingNetwork?.ledgerApi?.baseUrl ?? ''}
|
|
74
|
-
required
|
|
75
|
-
/>
|
|
76
|
-
|
|
77
|
-
<select
|
|
78
|
-
name="authType"
|
|
79
|
-
@change=${this.onAuthTypeChange}
|
|
80
|
-
.value=${this.authType}
|
|
81
|
-
>
|
|
82
|
-
<option value="password">password</option>
|
|
83
|
-
<option value="implicit">implicit</option>
|
|
84
|
-
</select>
|
|
85
|
-
|
|
86
|
-
${this.authType === 'implicit'
|
|
87
|
-
? html `
|
|
88
|
-
<input
|
|
89
|
-
name="domain"
|
|
90
|
-
placeholder="Domain"
|
|
91
|
-
.value=${this.getAuthField('domain')}
|
|
92
|
-
required
|
|
93
|
-
/>
|
|
94
|
-
<input
|
|
95
|
-
name="clientId"
|
|
96
|
-
placeholder="ClientId"
|
|
97
|
-
.value=${this.getAuthField('clientId')}
|
|
98
|
-
required
|
|
99
|
-
/>
|
|
100
|
-
<input
|
|
101
|
-
name="scope"
|
|
102
|
-
placeholder="Scope"
|
|
103
|
-
.value=${this.getAuthField('scope')}
|
|
104
|
-
required
|
|
105
|
-
/>
|
|
106
|
-
<input
|
|
107
|
-
name="audience"
|
|
108
|
-
placeholder="Audience"
|
|
109
|
-
.value=${this.getAuthField('audience')}
|
|
110
|
-
required
|
|
111
|
-
/>
|
|
112
|
-
`
|
|
113
|
-
: html `
|
|
114
|
-
<input
|
|
115
|
-
name="tokenUrl"
|
|
116
|
-
placeholder="TokenUrl"
|
|
117
|
-
.value=${this.getAuthField('tokenUrl')}
|
|
118
|
-
required
|
|
119
|
-
/>
|
|
120
|
-
<input
|
|
121
|
-
name="grantType"
|
|
122
|
-
placeholder="GrantType"
|
|
123
|
-
.value=${this.getAuthField('grantType')}
|
|
124
|
-
required
|
|
125
|
-
/>
|
|
126
|
-
<input
|
|
127
|
-
name="scope"
|
|
128
|
-
placeholder="Scope"
|
|
129
|
-
.value=${this.getAuthField('scope')}
|
|
130
|
-
required
|
|
131
|
-
/>
|
|
132
|
-
<input
|
|
133
|
-
name="audience"
|
|
134
|
-
placeholder="Audience"
|
|
135
|
-
.value=${this.getAuthField('audience')}
|
|
136
|
-
required
|
|
137
|
-
/>
|
|
138
|
-
`}
|
|
139
|
-
|
|
140
|
-
<div class="buttons">
|
|
141
|
-
<button type="submit">Save</button>
|
|
142
|
-
<button
|
|
143
|
-
type="button"
|
|
144
|
-
@click=${() => this.dispatchEvent(new Event('cancel'))}
|
|
145
|
-
>
|
|
146
|
-
Cancel
|
|
147
|
-
</button>
|
|
148
|
-
</div>
|
|
149
|
-
</form>
|
|
150
|
-
`;
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
__decorate([
|
|
154
|
-
property({ type: Object }),
|
|
155
|
-
__metadata("design:type", Object)
|
|
156
|
-
], NetworkForm.prototype, "editingNetwork", void 0);
|
|
157
|
-
__decorate([
|
|
158
|
-
property({ type: String }),
|
|
159
|
-
__metadata("design:type", String)
|
|
160
|
-
], NetworkForm.prototype, "authType", void 0);
|
|
161
|
-
NetworkForm = __decorate([
|
|
162
|
-
customElement('network-form')
|
|
163
|
-
], NetworkForm);
|
|
164
|
-
export { NetworkForm };
|