@canton-network/core-wallet-ui-components 0.1.0 → 0.1.1

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.
@@ -0,0 +1,7 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class AppHeader extends LitElement {
3
+ iconSrc: string;
4
+ createRenderRoot(): this;
5
+ render(): import("lit-html").TemplateResult<1>;
6
+ }
7
+ //# sourceMappingURL=AppHeader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppHeader.d.ts","sourceRoot":"","sources":["../../src/components/AppHeader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAA;AAGtC,qBACa,SAAU,SAAQ,UAAU;IACT,OAAO,EAAE,MAAM,CAAoB;IAG/D,gBAAgB;IAIhB,MAAM;CA0CT"}
@@ -0,0 +1,71 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { LitElement, html } from 'lit';
11
+ import { customElement, property } from 'lit/decorators.js';
12
+ let AppHeader = class AppHeader extends LitElement {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.iconSrc = 'images/icon.png';
16
+ }
17
+ // Prevent shadow DOM so external CSS applies
18
+ createRenderRoot() {
19
+ return this;
20
+ }
21
+ render() {
22
+ return html `
23
+ <div
24
+ class="header d-flex justify-content-between align-items-center"
25
+ >
26
+ <h2>
27
+ <div
28
+ class="logo-box"
29
+ @click=${() => (window.location.href = '/')}
30
+ aria-label="Go to home"
31
+ >
32
+ <img
33
+ src="${this.iconSrc}"
34
+ alt="Icon"
35
+ width="24"
36
+ height="24"
37
+ />
38
+ Splice Wallet
39
+ </div>
40
+ </h2>
41
+ <div>
42
+ <button
43
+ class="btn btn-outline-secondary btn-sm"
44
+ id="settingsButton"
45
+ @click=${() => (window.location.href = '/networks/')}
46
+ >
47
+ Settings
48
+ </button>
49
+ <button
50
+ class="btn btn-outline-secondary btn-sm"
51
+ @click=${() => {
52
+ localStorage.clear();
53
+ window.location.href = '/login';
54
+ }}
55
+ id="logoutButton"
56
+ >
57
+ Logout
58
+ </button>
59
+ </div>
60
+ </div>
61
+ `;
62
+ }
63
+ };
64
+ __decorate([
65
+ property({ type: String }),
66
+ __metadata("design:type", String)
67
+ ], AppHeader.prototype, "iconSrc", void 0);
68
+ AppHeader = __decorate([
69
+ customElement('app-header')
70
+ ], AppHeader);
71
+ export { AppHeader };
@@ -0,0 +1,11 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class AppLayout extends LitElement {
3
+ iconSrc: string;
4
+ themeSrc?: string;
5
+ static styles: import("lit").CSSResult;
6
+ private customThemeCss;
7
+ updated(changedProps: Map<string, unknown>): Promise<void>;
8
+ private get effectiveThemeCss();
9
+ render(): import("lit-html").TemplateResult<1>;
10
+ }
11
+ //# sourceMappingURL=AppLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppLayout.d.ts","sourceRoot":"","sources":["../../src/components/AppLayout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwB,MAAM,KAAK,CAAA;AAKtD,qBACa,SAAU,SAAQ,UAAU;IACT,OAAO,EAAE,MAAM,CAAqB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAE7C,MAAM,CAAC,MAAM,0BAiBZ;IAED,OAAO,CAAC,cAAc,CAAsB;IAEtC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAqBhD,OAAO,KAAK,iBAAiB,GAE5B;IAED,MAAM;CAYT"}
@@ -0,0 +1,85 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { LitElement, html, css, unsafeCSS } from 'lit';
11
+ import { customElement, property } from 'lit/decorators.js';
12
+ import bootstrapCss from 'bootstrap/dist/css/bootstrap.min.css?inline';
13
+ import defaultTheme from '../../themes/default.css?inline';
14
+ let AppLayout = class AppLayout extends LitElement {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.iconSrc = '/images/icon.png';
18
+ this.customThemeCss = null;
19
+ }
20
+ static { this.styles = css `
21
+ ${unsafeCSS(bootstrapCss.replaceAll(/:root/g, ':root,:host'))}
22
+
23
+ :host {
24
+ --bs-body-color: var(--splice-wk-text-color);
25
+
26
+ margin: 0;
27
+ font-family: var(--bs-body-font-family);
28
+ font-size: var(--bs-body-font-size);
29
+ font-weight: var(--bs-body-font-weight);
30
+ line-height: var(--bs-body-line-height);
31
+ color: var(--bs-body-color);
32
+ text-align: var(--bs-body-text-align);
33
+ background-color: var(--bs-body-bg);
34
+ -webkit-text-size-adjust: 100%;
35
+ -webkit-tap-highlight-color: transparent;
36
+ }
37
+ `; }
38
+ async updated(changedProps) {
39
+ if (changedProps.has('themeSrc')) {
40
+ if (this.themeSrc) {
41
+ try {
42
+ const res = await fetch(this.themeSrc);
43
+ if (!res.ok)
44
+ throw new Error(`HTTP ${res.status}`);
45
+ this.customThemeCss = await res.text();
46
+ }
47
+ catch (err) {
48
+ console.warn(`[app-layout] Failed to load theme from "${this.themeSrc}":`, err);
49
+ this.customThemeCss = null;
50
+ }
51
+ this.requestUpdate();
52
+ }
53
+ else {
54
+ this.customThemeCss = null;
55
+ }
56
+ }
57
+ }
58
+ get effectiveThemeCss() {
59
+ return this.customThemeCss ?? defaultTheme;
60
+ }
61
+ render() {
62
+ return html `
63
+ <style>
64
+ ${unsafeCSS(this.effectiveThemeCss)}
65
+ </style>
66
+
67
+ <app-header .iconSrc=${this.iconSrc}></app-header>
68
+ <div class="container" id="mainContent">
69
+ <slot></slot>
70
+ </div>
71
+ `;
72
+ }
73
+ };
74
+ __decorate([
75
+ property({ type: String }),
76
+ __metadata("design:type", String)
77
+ ], AppLayout.prototype, "iconSrc", void 0);
78
+ __decorate([
79
+ property({ type: String }),
80
+ __metadata("design:type", String)
81
+ ], AppLayout.prototype, "themeSrc", void 0);
82
+ AppLayout = __decorate([
83
+ customElement('app-layout')
84
+ ], AppLayout);
85
+ export { AppLayout };
@@ -0,0 +1,5 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class Configuration extends LitElement {
3
+ protected render(): import("lit-html").TemplateResult<1>;
4
+ }
5
+ //# sourceMappingURL=Configuration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../../src/components/Configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAA;AAGtC,qBACa,aAAc,SAAQ,UAAU;IACzC,SAAS,CAAC,MAAM;CAQnB"}
@@ -0,0 +1,22 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { html, LitElement } from 'lit';
8
+ import { customElement } from 'lit/decorators.js';
9
+ let Configuration = class Configuration extends LitElement {
10
+ render() {
11
+ return html `
12
+ <div>
13
+ <h1>Configuration</h1>
14
+ <p>Wallet Kernel configuration page.</p>
15
+ </div>
16
+ `;
17
+ }
18
+ };
19
+ Configuration = __decorate([
20
+ customElement('swk-configuration')
21
+ ], Configuration);
22
+ export { Configuration };
@@ -0,0 +1,19 @@
1
+ import { DiscoverResult } from '@canton-network/core-types';
2
+ /**
3
+ * Discovery implements the view of the Wallet Kernel selection window.
4
+ * It is implemented directly as a Web Component without using LitElement, so to avoid having external dependencies.
5
+ */
6
+ export declare class Discovery extends HTMLElement {
7
+ static observedAttributes: string[];
8
+ get walletExtensionLoaded(): boolean;
9
+ set walletExtensionLoaded(val: boolean);
10
+ private root;
11
+ constructor();
12
+ verifiedKernels(): DiscoverResult[];
13
+ private renderKernelOption;
14
+ private selectKernel;
15
+ render(): void;
16
+ connectedCallback(): void;
17
+ attributeChangedCallback(): void;
18
+ }
19
+ //# sourceMappingURL=Discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Discovery.d.ts","sourceRoot":"","sources":["../../src/components/Discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAsB,MAAM,4BAA4B,CAAA;AAE/E;;;GAGG;AACH,qBAAa,SAAU,SAAQ,WAAW;IACtC,MAAM,CAAC,kBAAkB,WAA8B;IAEvD,IAAI,qBAAqB,YAExB;IAED,IAAI,qBAAqB,CAAC,GAAG,SAAA,EAM5B;IAED,OAAO,CAAC,IAAI,CAAa;;IA2DzB,eAAe,IAAI,cAAc,EAAE;IAInC,OAAO,CAAC,kBAAkB;IA2B1B,OAAO,CAAC,YAAY;IAQpB,MAAM;IAiDN,iBAAiB;IAIjB,wBAAwB;CAG3B"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Discovery implements the view of the Wallet Kernel selection window.
3
+ * It is implemented directly as a Web Component without using LitElement, so to avoid having external dependencies.
4
+ */
5
+ export class Discovery extends HTMLElement {
6
+ static { this.observedAttributes = ['wallet-extension-loaded']; }
7
+ get walletExtensionLoaded() {
8
+ return this.hasAttribute('wallet-extension-loaded');
9
+ }
10
+ set walletExtensionLoaded(val) {
11
+ if (val) {
12
+ this.setAttribute('wallet-extension-loaded', '');
13
+ }
14
+ else {
15
+ this.removeAttribute('wallet-extension-loaded');
16
+ }
17
+ }
18
+ constructor() {
19
+ super();
20
+ this.attachShadow({ mode: 'open' });
21
+ const styles = document.createElement('style');
22
+ styles.textContent = `
23
+ * {
24
+ color: var(--splice-wk-text-color, black);
25
+ font-family: var(--splice-wk-font-family);
26
+ }
27
+
28
+ h1 {
29
+ margin: 0px;
30
+ }
31
+
32
+ div {
33
+ background-color: var(--splice-wk-background-color, none);
34
+ width: 100%;
35
+ height: 100%;
36
+ }
37
+
38
+ .kernel {
39
+ height: auto;
40
+ margin-bottom: 8px;
41
+ }
42
+
43
+ .kernel button {
44
+ margin-left: 8px;
45
+ }
46
+
47
+ input {
48
+ margin-left: 8px;
49
+ }
50
+ `;
51
+ this.root = document.createElement('div');
52
+ this.root.id = 'discovery-root';
53
+ if (this.shadowRoot) {
54
+ this.shadowRoot.appendChild(styles);
55
+ this.shadowRoot.appendChild(this.root);
56
+ }
57
+ if (window.opener) {
58
+ // uses the string literal instead of the WalletEvent enum to avoid bundling issues
59
+ window.opener.postMessage({ type: 'SPLICE_WALLET_EXT_READY' }, '*');
60
+ window.opener.addEventListener('message', (event) => {
61
+ if (event.data.type === 'SPLICE_WALLET_EXT_ACK') {
62
+ this.setAttribute('wallet-extension-loaded', '');
63
+ }
64
+ });
65
+ }
66
+ }
67
+ verifiedKernels() {
68
+ return [{ url: 'http://localhost:3000/rpc', walletType: 'remote' }];
69
+ }
70
+ renderKernelOption(kernel) {
71
+ const div = document.createElement('div');
72
+ div.setAttribute('class', 'kernel');
73
+ const span = document.createElement('span');
74
+ switch (kernel.walletType) {
75
+ case 'extension':
76
+ span.innerText = 'Browser Extension';
77
+ break;
78
+ case 'remote':
79
+ span.innerText = `${kernel.walletType} - ${kernel.url}`;
80
+ break;
81
+ }
82
+ const button = document.createElement('button');
83
+ button.innerText = `Connect`;
84
+ button.addEventListener('click', () => {
85
+ this.selectKernel(kernel);
86
+ });
87
+ div.appendChild(span);
88
+ div.appendChild(button);
89
+ return div;
90
+ }
91
+ selectKernel(kernel) {
92
+ if (window.opener) {
93
+ window.opener.postMessage(kernel, '*');
94
+ }
95
+ else {
96
+ console.warn('no window opener...');
97
+ }
98
+ }
99
+ render() {
100
+ const root = document.createElement('div');
101
+ const header = document.createElement('h1');
102
+ header.innerText = 'Add Remote Wallet Kernel';
103
+ const input = document.createElement('input');
104
+ input.setAttribute('autofocus', '');
105
+ input.setAttribute('id', 'wkurl');
106
+ input.setAttribute('type', 'text');
107
+ input.setAttribute('placeholder', 'RPC URL');
108
+ const button = document.createElement('button');
109
+ button.setAttribute('id', 'connect');
110
+ button.innerText = 'Connect';
111
+ button.addEventListener('click', () => {
112
+ const url = input.value;
113
+ console.log('Connecting to Wallet Kernel...' + url);
114
+ this.selectKernel({ url, walletType: 'remote' });
115
+ });
116
+ root.appendChild(header);
117
+ if (this.walletExtensionLoaded) {
118
+ const k = this.renderKernelOption({
119
+ walletType: 'extension',
120
+ });
121
+ root.appendChild(k);
122
+ }
123
+ for (const kernel of this.verifiedKernels()) {
124
+ const k = this.renderKernelOption(kernel);
125
+ root.appendChild(k);
126
+ }
127
+ root.appendChild(input);
128
+ root.appendChild(button);
129
+ // Replace the whole root (except styles), don't append
130
+ if (this.shadowRoot) {
131
+ Array.from(this.shadowRoot.childNodes).forEach((node) => {
132
+ if (!(node instanceof HTMLStyleElement)) {
133
+ this.shadowRoot.removeChild(node);
134
+ }
135
+ });
136
+ this.shadowRoot.appendChild(root);
137
+ }
138
+ }
139
+ connectedCallback() {
140
+ this.render();
141
+ }
142
+ attributeChangedCallback() {
143
+ this.render();
144
+ }
145
+ }
146
+ customElements.define('swk-discovery', Discovery);
@@ -0,0 +1,12 @@
1
+ import { Network } from '@canton-network/core-wallet-store';
2
+ import { LitElement } from 'lit';
3
+ export declare class NetworkForm extends LitElement {
4
+ editingNetwork: Network | null;
5
+ authType: string;
6
+ static styles: import("lit").CSSResult[];
7
+ private getAuthField;
8
+ onAuthTypeChange(e: Event): void;
9
+ handleSubmit(e: Event): void;
10
+ render(): import("lit-html").TemplateResult<1>;
11
+ }
12
+ //# sourceMappingURL=NetworkForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NetworkForm.d.ts","sourceRoot":"","sources":["../../src/components/NetworkForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAA;AAItC,qBACa,WAAY,SAAQ,UAAU;IACX,cAAc,EAAE,OAAO,GAAG,IAAI,CAAO;IACrC,QAAQ,EAAE,MAAM,CAAa;IAEzD,MAAM,CAAC,MAAM,4BAAW;IAExB,OAAO,CAAC,YAAY;IAOpB,gBAAgB,CAAC,CAAC,EAAE,KAAK;IAKzB,YAAY,CAAC,CAAC,EAAE,KAAK;IAerB,MAAM;CA6GT"}
@@ -0,0 +1,162 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { LitElement, html } from 'lit';
11
+ import { customElement, property } from 'lit/decorators.js';
12
+ import { styles } from '../themes/styles.js';
13
+ let NetworkForm = class NetworkForm extends LitElement {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.editingNetwork = null;
17
+ this.authType = 'implicit';
18
+ }
19
+ static { this.styles = [styles]; }
20
+ getAuthField(field) {
21
+ if (!this.editingNetwork)
22
+ return '';
23
+ const auth = this.editingNetwork.auth;
24
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
+ return auth?.[field] ?? '';
26
+ }
27
+ onAuthTypeChange(e) {
28
+ const select = e.target;
29
+ this.authType = select.value;
30
+ }
31
+ handleSubmit(e) {
32
+ e.preventDefault();
33
+ const form = e.target;
34
+ const formData = new FormData(form);
35
+ this.dispatchEvent(new CustomEvent('form-submit', {
36
+ detail: formData,
37
+ bubbles: true,
38
+ composed: true,
39
+ }));
40
+ }
41
+ render() {
42
+ return html `
43
+ <form @submit=${this.handleSubmit}>
44
+ <input
45
+ name="name"
46
+ placeholder="Name"
47
+ .value=${this.editingNetwork?.name ?? ''}
48
+ required
49
+ />
50
+ <input
51
+ name="chainId"
52
+ placeholder="Network Id"
53
+ .value=${this.editingNetwork?.chainId ?? ''}
54
+ required
55
+ />
56
+ <input
57
+ name="synchronizerId"
58
+ placeholder="Synchronizer Id"
59
+ .value=${this.editingNetwork?.synchronizerId ?? ''}
60
+ required
61
+ />
62
+ <input
63
+ name="description"
64
+ placeholder="Description"
65
+ .value=${this.editingNetwork?.description ?? ''}
66
+ required
67
+ />
68
+ <input
69
+ name="ledgerApi.baseurl"
70
+ placeholder="Ledger API Base Url"
71
+ .value=${this.editingNetwork?.ledgerApi?.baseUrl ?? ''}
72
+ required
73
+ />
74
+
75
+ <select
76
+ name="authType"
77
+ @change=${this.onAuthTypeChange}
78
+ .value=${this.authType}
79
+ >
80
+ <option value="password">password</option>
81
+ <option value="implicit">implicit</option>
82
+ </select>
83
+
84
+ ${this.authType === 'implicit'
85
+ ? html `
86
+ <input
87
+ name="domain"
88
+ placeholder="Domain"
89
+ .value=${this.getAuthField('domain')}
90
+ required
91
+ />
92
+ <input
93
+ name="clientId"
94
+ placeholder="ClientId"
95
+ .value=${this.getAuthField('clientId')}
96
+ required
97
+ />
98
+ <input
99
+ name="scope"
100
+ placeholder="Scope"
101
+ .value=${this.getAuthField('scope')}
102
+ required
103
+ />
104
+ <input
105
+ name="audience"
106
+ placeholder="Audience"
107
+ .value=${this.getAuthField('audience')}
108
+ required
109
+ />
110
+ `
111
+ : html `
112
+ <input
113
+ name="tokenUrl"
114
+ placeholder="TokenUrl"
115
+ .value=${this.getAuthField('tokenUrl')}
116
+ required
117
+ />
118
+ <input
119
+ name="grantType"
120
+ placeholder="GrantType"
121
+ .value=${this.getAuthField('grantType')}
122
+ required
123
+ />
124
+ <input
125
+ name="scope"
126
+ placeholder="Scope"
127
+ .value=${this.getAuthField('scope')}
128
+ required
129
+ />
130
+ <input
131
+ name="audience"
132
+ placeholder="Audience"
133
+ .value=${this.getAuthField('audience')}
134
+ required
135
+ />
136
+ `}
137
+
138
+ <div class="buttons">
139
+ <button type="submit">Save</button>
140
+ <button
141
+ type="button"
142
+ @click=${() => this.dispatchEvent(new Event('cancel'))}
143
+ >
144
+ Cancel
145
+ </button>
146
+ </div>
147
+ </form>
148
+ `;
149
+ }
150
+ };
151
+ __decorate([
152
+ property({ type: Object }),
153
+ __metadata("design:type", Object)
154
+ ], NetworkForm.prototype, "editingNetwork", void 0);
155
+ __decorate([
156
+ property({ type: String }),
157
+ __metadata("design:type", String)
158
+ ], NetworkForm.prototype, "authType", void 0);
159
+ NetworkForm = __decorate([
160
+ customElement('network-form')
161
+ ], NetworkForm);
162
+ export { NetworkForm };
@@ -0,0 +1,8 @@
1
+ import { Network } from '@canton-network/core-wallet-store';
2
+ import { LitElement } from 'lit';
3
+ export declare class NetworkTable extends LitElement {
4
+ networks: Network[];
5
+ static styles: import("lit").CSSResult[];
6
+ render(): import("lit-html").TemplateResult<1>;
7
+ }
8
+ //# sourceMappingURL=NetworkTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NetworkTable.d.ts","sourceRoot":"","sources":["../../src/components/NetworkTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAA;AAKtC,qBACa,YAAa,SAAQ,UAAU;IACb,QAAQ,EAAE,OAAO,EAAE,CAAK;IAEnD,MAAM,CAAC,MAAM,4BAAW;IAExB,MAAM;CA2CT"}
@@ -0,0 +1,65 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { LitElement, html } from 'lit';
11
+ import { customElement, property } from 'lit/decorators.js';
12
+ import { styles } from '../themes/styles.js';
13
+ let NetworkTable = class NetworkTable extends LitElement {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.networks = [];
17
+ }
18
+ static { this.styles = [styles]; }
19
+ render() {
20
+ console.log('rendering with networks ' + JSON.stringify(this.networks));
21
+ return html `
22
+ <table>
23
+ <thead>
24
+ <tr>
25
+ <th>Name</th>
26
+ <th>ID</th>
27
+ <th>Description</th>
28
+ <th>Auth type</th>
29
+ <th>Synchronizer ID</th>
30
+ <th>Actions</th>
31
+ </tr>
32
+ </thead>
33
+ <tbody>
34
+ ${this.networks.map((net) => html `
35
+ <tr>
36
+ <td>${net.name}</td>
37
+ <td>${net.chainId}</td>
38
+ <td>${net.description}</td>
39
+ <td>${net.auth.type}</td>
40
+ <td>${net.synchronizerId}</td>
41
+ <td class="actions">
42
+ <button>Update</button>
43
+ <button
44
+ @click=${() => this.dispatchEvent(new CustomEvent('delete', {
45
+ detail: net,
46
+ }))}
47
+ >
48
+ Delete
49
+ </button>
50
+ </td>
51
+ </tr>
52
+ `)}
53
+ </tbody>
54
+ </table>
55
+ `;
56
+ }
57
+ };
58
+ __decorate([
59
+ property({ type: Array }),
60
+ __metadata("design:type", Array)
61
+ ], NetworkTable.prototype, "networks", void 0);
62
+ NetworkTable = __decorate([
63
+ customElement('network-table')
64
+ ], NetworkTable);
65
+ export { NetworkTable };
@@ -0,0 +1,2 @@
1
+ export declare const styles: import("lit").CSSResult;
2
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/themes/styles.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,MAAM,yBAuElB,CAAA"}
@@ -0,0 +1,73 @@
1
+ import { css } from 'lit';
2
+ export const styles = css `
3
+ .table-wrapper {
4
+ max-height: 300px;
5
+ overflow-y: auto;
6
+ border: 1px solid var(--splice-wk-border-color, #ccc);
7
+ border-radius: 4px;
8
+ }
9
+
10
+ table {
11
+ width: 100%;
12
+ border-collapse: collapse;
13
+ }
14
+
15
+ thead th {
16
+ position: sticky;
17
+ top: 0;
18
+ z-index: 1;
19
+ text-align: left;
20
+ padding: 8px 12px;
21
+ border-bottom: 1px solid var(--splice-wk-border-color, #ccc);
22
+ }
23
+
24
+ tbody td {
25
+ padding: 8px 12px;
26
+ border-bottom: 1px solid var(--splice-wk-border-color, #ccc);
27
+ }
28
+
29
+ tr:nth-child(even) {
30
+ background-color: var(--splice-wk-background-color, none);
31
+ }
32
+
33
+ .actions button {
34
+ margin-right: 4px;
35
+ font-size: 0.8rem;
36
+ padding: 4px 8px;
37
+ }
38
+
39
+ .modal {
40
+ position: fixed;
41
+ display: flex;
42
+ align-items: center;
43
+ justify-content: center;
44
+ }
45
+
46
+ .modal-content {
47
+ background: var(--splice-wk-background-color, none);
48
+ padding: 1.5rem;
49
+ border-radius: 8px;
50
+ width: 400px;
51
+ box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
52
+ }
53
+
54
+ .form {
55
+ display: flex;
56
+ flex-direction: column;
57
+ gap: 10px;
58
+ }
59
+
60
+ input,
61
+ select {
62
+ padding: 6px;
63
+ font-size: 1rem;
64
+ }
65
+
66
+ .buttons {
67
+ display: flex;
68
+ justify-content: flex-end;
69
+ margin-top: 1rem;
70
+ gap: 0.5rem;
71
+ margin-bottom: 1.5rem;
72
+ }
73
+ `;
@@ -0,0 +1,3 @@
1
+ import { DiscoverResult } from '@canton-network/core-types';
2
+ export declare function discover(): Promise<DiscoverResult>;
3
+ //# sourceMappingURL=discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/windows/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAI3D,wBAAsB,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC,CAiCxD"}
@@ -0,0 +1,30 @@
1
+ import { Discovery } from '../components/Discovery.js';
2
+ import { popup } from './popup.js';
3
+ export async function discover() {
4
+ const win = await popup(Discovery, {
5
+ title: 'Wallet Discovery',
6
+ target: 'wallet-discovery',
7
+ });
8
+ return new Promise((resolve, reject) => {
9
+ let response = undefined;
10
+ win.addEventListener('beforeunload', () => {
11
+ if (response === undefined) {
12
+ console.log('Wallet discovery window closed by user');
13
+ reject('User closed the wallet discovery window');
14
+ }
15
+ });
16
+ const handler = (event) => {
17
+ if (event.origin === window.location.origin &&
18
+ typeof event.data.walletType === 'string') {
19
+ response = event.data;
20
+ resolve({
21
+ url: event.data.url,
22
+ walletType: event.data.walletType,
23
+ });
24
+ window.removeEventListener('message', handler);
25
+ win.close();
26
+ }
27
+ };
28
+ window.addEventListener('message', handler);
29
+ });
30
+ }
@@ -0,0 +1,12 @@
1
+ interface PopupOptions {
2
+ title?: string;
3
+ target?: string;
4
+ width?: number;
5
+ height?: number;
6
+ screenX?: number;
7
+ screenY?: number;
8
+ }
9
+ export declare function popup(component: new () => HTMLElement, options?: PopupOptions): Promise<Window>;
10
+ export declare function popupHref(url: URL | string, options?: PopupOptions): Promise<Window>;
11
+ export {};
12
+ //# sourceMappingURL=popup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popup.d.ts","sourceRoot":"","sources":["../../src/windows/popup.ts"],"names":[],"mappings":"AAEA,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,wBAAgB,KAAK,CACjB,SAAS,EAAE,UAAU,WAAW,EAChC,OAAO,CAAC,EAAE,YAAY,GACvB,OAAO,CAAC,MAAM,CAAC,CA6DjB;AAED,wBAAgB,SAAS,CACrB,GAAG,EAAE,GAAG,GAAG,MAAM,EACjB,OAAO,CAAC,EAAE,YAAY,GACvB,OAAO,CAAC,MAAM,CAAC,CAuBjB"}
@@ -0,0 +1,62 @@
1
+ import styles from '../../themes/default.css?inline';
2
+ export function popup(component, options) {
3
+ const { title = 'Custom Popup', target = 'wallet-popup', width = 400, height = 500, screenX = 200, screenY = 200, } = options || {};
4
+ const html = `<!DOCTYPE html>
5
+ <html>
6
+ <head>
7
+ <title>${title}</title>
8
+ <style>
9
+ html, body {
10
+ margin: 0;
11
+ padding: 0;
12
+ width: 100%;
13
+ height: 100%;
14
+ }
15
+
16
+ body {
17
+ display: flex;
18
+ }
19
+ </style>
20
+ <style>${styles}</style>
21
+ </head>
22
+ <body>
23
+ </body>
24
+
25
+ <script>
26
+ customElements.define('popup-content', ${component})
27
+
28
+ const root = document.getElementsByTagName('body')[0]
29
+
30
+ const content = document.createElement('popup-content')
31
+ content.setAttribute('style', 'width: 100%; height: 100%;')
32
+
33
+ root.appendChild(content)
34
+ </script>
35
+ </html>`;
36
+ const url = URL.createObjectURL(new Blob([html], { type: 'text/html' }));
37
+ return new Promise((resolve, reject) => {
38
+ const win = window.open(url, target, `width=${width},height=${height},screenX=${screenX},screenY=${screenY}`);
39
+ if (win) {
40
+ win.addEventListener('beforeunload', () => {
41
+ URL.revokeObjectURL(url); // clean up the URL object to prevent memory leaks
42
+ });
43
+ resolve(win);
44
+ }
45
+ else {
46
+ reject(new Error('Failed to open popup window.'));
47
+ }
48
+ });
49
+ }
50
+ export function popupHref(url, options) {
51
+ const { target = 'wallet-popup', width = 400, height = 500, screenX = 200, screenY = 200, } = options || {};
52
+ return new Promise((resolve, reject) => {
53
+ const win = window.open(url, target, `width=${width},height=${height},screenX=${screenX},screenY=${screenY}`);
54
+ if (win) {
55
+ win.focus();
56
+ resolve(win);
57
+ }
58
+ else {
59
+ reject(new Error('Failed to open popup window.'));
60
+ }
61
+ });
62
+ }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@canton-network/core-wallet-ui-components",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "description": "Reusable UI components for the Splice wallet",
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",
@@ -23,16 +23,16 @@
23
23
  "typescript": "^5.8.3",
24
24
  "vite": "^6.3.5"
25
25
  },
26
- "packageManager": "yarn@4.9.2",
26
+ "packageManager": "yarn@4.9.4",
27
27
  "dependencies": {
28
- "@canton-network/core-types": "^0.1.0",
29
- "@canton-network/core-wallet-store": "^0.1.0",
28
+ "@canton-network/core-types": "^0.1.1",
29
+ "@canton-network/core-wallet-store": "^0.1.1",
30
30
  "@popperjs/core": "^2.11.8",
31
31
  "bootstrap": "^5.3.7",
32
32
  "lit": "^3.3.0"
33
33
  },
34
34
  "files": [
35
- "dist/*"
35
+ "dist/**"
36
36
  ],
37
37
  "publishConfig": {
38
38
  "access": "public"