@hsuite/native-connect-angular 2.2.0 → 3.0.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.
- package/README.md +163 -4
- package/dist/README.md +163 -4
- package/dist/fesm2022/hsuite-native-connect-angular.mjs +6258 -1798
- package/dist/fesm2022/hsuite-native-connect-angular.mjs.map +1 -1
- package/dist/index.d.ts +1417 -643
- package/dist/styles/wallet-ui.scss +90 -0
- package/package.json +17 -5
package/README.md
CHANGED
|
@@ -10,17 +10,36 @@ npm install @hsuite/native-connect-angular
|
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
|
+
Provide the wallet UI once, then put `hsuite-wallet-button` in the header:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
// app.config.ts (or AppModule providers)
|
|
17
|
+
import { provideWalletUi } from '@hsuite/native-connect-angular';
|
|
18
|
+
|
|
19
|
+
export const appConfig = {
|
|
20
|
+
providers: [
|
|
21
|
+
provideWalletUi({
|
|
22
|
+
appId: 'my-dapp',
|
|
23
|
+
appName: 'My dApp',
|
|
24
|
+
projectId: 'YOUR_WALLETCONNECT_PROJECT_ID', // omit to hide WalletConnect
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
```
|
|
29
|
+
|
|
13
30
|
```typescript
|
|
14
31
|
import { Component, inject } from '@angular/core';
|
|
15
|
-
import { UnifiedWalletService,
|
|
32
|
+
import { UnifiedWalletService, WalletButtonComponent } from '@hsuite/native-connect-angular';
|
|
16
33
|
|
|
17
34
|
@Component({
|
|
18
35
|
selector: 'app-home',
|
|
19
36
|
standalone: true,
|
|
20
|
-
imports: [
|
|
37
|
+
imports: [WalletButtonComponent],
|
|
21
38
|
template: `
|
|
22
|
-
<wallet-
|
|
23
|
-
|
|
39
|
+
<hsuite-wallet-button></hsuite-wallet-button>
|
|
40
|
+
@if (wallet.activeAccount(); as account) {
|
|
41
|
+
<div>Connected: {{ account.address }}</div>
|
|
42
|
+
}
|
|
24
43
|
`,
|
|
25
44
|
})
|
|
26
45
|
export class HomeComponent {
|
|
@@ -28,6 +47,146 @@ export class HomeComponent {
|
|
|
28
47
|
}
|
|
29
48
|
```
|
|
30
49
|
|
|
50
|
+
Also include the overlay stylesheet (see [Overlay styles](#overlay-styles-required)).
|
|
51
|
+
|
|
52
|
+
> **Legacy:** `wallet-connect-button` (`WalletConnectButtonComponent`) still
|
|
53
|
+
> works but is deprecated; see the note at the end of the next section.
|
|
54
|
+
|
|
55
|
+
## Wallet UI (connect modal, account chip and menu)
|
|
56
|
+
|
|
57
|
+
Configure the wallet UI once and drop `hsuite-wallet-button` in the header. It
|
|
58
|
+
shows "Connect Wallet" (opens the connect modal) or the active account (opens
|
|
59
|
+
the account menu: switch account, add another wallet, view on explorer,
|
|
60
|
+
disconnect).
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// app.config.ts (or AppModule providers)
|
|
64
|
+
import { provideWalletUi } from '@hsuite/native-connect-angular';
|
|
65
|
+
|
|
66
|
+
providers: [
|
|
67
|
+
provideWalletUi({
|
|
68
|
+
appId: 'my-dapp',
|
|
69
|
+
appName: 'My dApp',
|
|
70
|
+
projectId: environment.walletConnectProjectId, // WalletConnect rows; omit to hide them
|
|
71
|
+
walletUrl: environment.walletUrl,
|
|
72
|
+
network: 'testnet', // pins the network; omit to let the user pick
|
|
73
|
+
termsUrl: 'https://example.com/terms', // optional "Terms of Service" line
|
|
74
|
+
}),
|
|
75
|
+
];
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
@Component({
|
|
80
|
+
standalone: true,
|
|
81
|
+
imports: [WalletButtonComponent],
|
|
82
|
+
template: `<hsuite-wallet-button [compact]="isPhone"></hsuite-wallet-button>`,
|
|
83
|
+
})
|
|
84
|
+
export class HeaderComponent {}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
To open the UI from code, inject `WalletUiService`: `openConnect()` (resolves
|
|
88
|
+
with a `ConnectResult`), `openAccountMenu(event)` and `openAccounts()`. On
|
|
89
|
+
phones (Ionic mobile platform or a viewport of 575px or less) the modal and
|
|
90
|
+
menu open as bottom sheets; elsewhere the modal is a 360px dialog and the menu
|
|
91
|
+
a popover anchored on the chip. Inside the docked navbar (`hs-app-navbar`, or
|
|
92
|
+
a `header`) the popover opens below the bar, at the bar's bottom plus
|
|
93
|
+
`--app-navbar-dropdown-gap` (8px by default) like the navbar's dropdown cards;
|
|
94
|
+
elsewhere 8px below the chip.
|
|
95
|
+
|
|
96
|
+
Only one connect modal is shown at a time. Opening it while one is already up
|
|
97
|
+
(for example the Reconnect toast's modal, then "Add another wallet") joins the
|
|
98
|
+
open modal: the new call's options (`mode`, `showBack`, overrides) are ignored
|
|
99
|
+
and it resolves with that modal's result. Close the open modal first to show
|
|
100
|
+
it with other options.
|
|
101
|
+
|
|
102
|
+
### On a lazy route
|
|
103
|
+
|
|
104
|
+
To keep the wallet UI out of the first bundle, provide it on the lazy route
|
|
105
|
+
instead of at the root:
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
// app.routes.ts
|
|
109
|
+
{
|
|
110
|
+
path: 'wallet',
|
|
111
|
+
providers: [provideWalletUi({ appId: 'my-dapp', appName: 'My dApp' })],
|
|
112
|
+
loadComponent: () => import('./wallet/wallet.page').then((m) => m.WalletPage),
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
`provideWalletUi()` provides `WalletUiService` together with its config, so
|
|
117
|
+
`hsuite-wallet-button`, `wallet-connect-button` and anything that injects
|
|
118
|
+
`WalletUiService` under that route get the route's instance, which sees the
|
|
119
|
+
route's config. Do not also provide `WalletUiService` yourself. Outside the
|
|
120
|
+
route, `WalletUiService` is still injectable from the root, but that instance
|
|
121
|
+
has no config (the modal falls back to its defaults). Provided at the root,
|
|
122
|
+
there is a single instance, as before.
|
|
123
|
+
|
|
124
|
+
### Chip styling
|
|
125
|
+
|
|
126
|
+
The header chip sizes itself from public custom properties, falling back to
|
|
127
|
+
the docked navbar's control properties (`hs-app-navbar`), so it matches the
|
|
128
|
+
other header buttons without `::ng-deep`:
|
|
129
|
+
|
|
130
|
+
| Property | Fallback | Default |
|
|
131
|
+
| ----------------------------- | -------------------------------- | ------------------------- |
|
|
132
|
+
| `--hs-connect-chip-height` | `--app-navbar-control-size` | `40px` |
|
|
133
|
+
| `--hs-connect-chip-radius` | `--app-navbar-control-radius` | `8px` |
|
|
134
|
+
| `--hs-connect-chip-border` | `--app-navbar-control-border` | `1px solid` (text at 14%) |
|
|
135
|
+
| `--hs-connect-chip-bg` | `--app-navbar-control-bg` | `transparent` |
|
|
136
|
+
| `--hs-connect-chip-bg-active` | `--app-navbar-control-bg-active` | text at 6% (hover / open) |
|
|
137
|
+
|
|
138
|
+
The touch target stays at least 44px tall whatever the height. The "Connect
|
|
139
|
+
Wallet" state keeps its accent fill.
|
|
140
|
+
|
|
141
|
+
### Overlay styles (required)
|
|
142
|
+
|
|
143
|
+
Ionic renders modals and popovers outside the components, so their size comes
|
|
144
|
+
from a global stylesheet shipped with the package. Add it once to the app's
|
|
145
|
+
global styles:
|
|
146
|
+
|
|
147
|
+
```jsonc
|
|
148
|
+
// angular.json → projects.<app>.architect.build.options.styles
|
|
149
|
+
"styles": [
|
|
150
|
+
"node_modules/@hsuite/native-connect-angular/dist/styles/wallet-ui.scss",
|
|
151
|
+
"src/global.scss"
|
|
152
|
+
]
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
or, from a global Sass file (resolved through the package's `exports`; checked
|
|
156
|
+
with the `@angular-devkit/build-angular:browser` builder):
|
|
157
|
+
|
|
158
|
+
```scss
|
|
159
|
+
@use '@hsuite/native-connect-angular/styles/wallet-ui';
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
It sizes the overlays the service opens by their CSS classes:
|
|
163
|
+
`hs-connect-modal` (connect modal and accounts list: 360px wide, height of the
|
|
164
|
+
content, 24px radius; an auto-height sheet on phones), `hs-account-popover`
|
|
165
|
+
(account menu, 340px) and `hs-account-sheet` (account menu on phones). Colors
|
|
166
|
+
come from the `--hs-connect-*` custom properties (see
|
|
167
|
+
`hsc-theme.styles.ts`), falling back to the Ionic theme.
|
|
168
|
+
|
|
169
|
+
The "… disconnected — Reconnect" toast that `hsuite-wallet-button` shows when
|
|
170
|
+
the wallet ends a session is a plain Ionic toast with the class
|
|
171
|
+
`hs-session-toast`. The stylesheet has no rule for it, so it follows the app's
|
|
172
|
+
`ion-toast` theme; the class is a hook for apps that want to style it:
|
|
173
|
+
|
|
174
|
+
```scss
|
|
175
|
+
ion-toast.hs-session-toast {
|
|
176
|
+
--background: var(--hs-connect-bg, var(--ion-overlay-background-color));
|
|
177
|
+
--color: var(--hs-connect-text, var(--ion-text-color));
|
|
178
|
+
--button-color: var(--hs-connect-accent, var(--ion-color-primary));
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Apps that still open `WalletConnectionModalComponent` with their own
|
|
183
|
+
`ModalController` call (a full-screen modal) keep working: the card centres
|
|
184
|
+
itself unless its modal has the `hs-connect-modal` class.
|
|
185
|
+
|
|
186
|
+
> `wallet-connect-button` (`WalletConnectButtonComponent`) is deprecated in favour of
|
|
187
|
+
> `hsuite-wallet-button`. With `provideWalletUi()` it opens the connect modal
|
|
188
|
+
> through `WalletUiService`; its explicit inputs override the config.
|
|
189
|
+
|
|
31
190
|
## Features
|
|
32
191
|
|
|
33
192
|
- HSuite Channel Protocol - Native `hsc:` protocol with Nostr + P2P transport
|
package/dist/README.md
CHANGED
|
@@ -10,17 +10,36 @@ npm install @hsuite/native-connect-angular
|
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
|
+
Provide the wallet UI once, then put `hsuite-wallet-button` in the header:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
// app.config.ts (or AppModule providers)
|
|
17
|
+
import { provideWalletUi } from '@hsuite/native-connect-angular';
|
|
18
|
+
|
|
19
|
+
export const appConfig = {
|
|
20
|
+
providers: [
|
|
21
|
+
provideWalletUi({
|
|
22
|
+
appId: 'my-dapp',
|
|
23
|
+
appName: 'My dApp',
|
|
24
|
+
projectId: 'YOUR_WALLETCONNECT_PROJECT_ID', // omit to hide WalletConnect
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
```
|
|
29
|
+
|
|
13
30
|
```typescript
|
|
14
31
|
import { Component, inject } from '@angular/core';
|
|
15
|
-
import { UnifiedWalletService,
|
|
32
|
+
import { UnifiedWalletService, WalletButtonComponent } from '@hsuite/native-connect-angular';
|
|
16
33
|
|
|
17
34
|
@Component({
|
|
18
35
|
selector: 'app-home',
|
|
19
36
|
standalone: true,
|
|
20
|
-
imports: [
|
|
37
|
+
imports: [WalletButtonComponent],
|
|
21
38
|
template: `
|
|
22
|
-
<wallet-
|
|
23
|
-
|
|
39
|
+
<hsuite-wallet-button></hsuite-wallet-button>
|
|
40
|
+
@if (wallet.activeAccount(); as account) {
|
|
41
|
+
<div>Connected: {{ account.address }}</div>
|
|
42
|
+
}
|
|
24
43
|
`,
|
|
25
44
|
})
|
|
26
45
|
export class HomeComponent {
|
|
@@ -28,6 +47,146 @@ export class HomeComponent {
|
|
|
28
47
|
}
|
|
29
48
|
```
|
|
30
49
|
|
|
50
|
+
Also include the overlay stylesheet (see [Overlay styles](#overlay-styles-required)).
|
|
51
|
+
|
|
52
|
+
> **Legacy:** `wallet-connect-button` (`WalletConnectButtonComponent`) still
|
|
53
|
+
> works but is deprecated; see the note at the end of the next section.
|
|
54
|
+
|
|
55
|
+
## Wallet UI (connect modal, account chip and menu)
|
|
56
|
+
|
|
57
|
+
Configure the wallet UI once and drop `hsuite-wallet-button` in the header. It
|
|
58
|
+
shows "Connect Wallet" (opens the connect modal) or the active account (opens
|
|
59
|
+
the account menu: switch account, add another wallet, view on explorer,
|
|
60
|
+
disconnect).
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// app.config.ts (or AppModule providers)
|
|
64
|
+
import { provideWalletUi } from '@hsuite/native-connect-angular';
|
|
65
|
+
|
|
66
|
+
providers: [
|
|
67
|
+
provideWalletUi({
|
|
68
|
+
appId: 'my-dapp',
|
|
69
|
+
appName: 'My dApp',
|
|
70
|
+
projectId: environment.walletConnectProjectId, // WalletConnect rows; omit to hide them
|
|
71
|
+
walletUrl: environment.walletUrl,
|
|
72
|
+
network: 'testnet', // pins the network; omit to let the user pick
|
|
73
|
+
termsUrl: 'https://example.com/terms', // optional "Terms of Service" line
|
|
74
|
+
}),
|
|
75
|
+
];
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
@Component({
|
|
80
|
+
standalone: true,
|
|
81
|
+
imports: [WalletButtonComponent],
|
|
82
|
+
template: `<hsuite-wallet-button [compact]="isPhone"></hsuite-wallet-button>`,
|
|
83
|
+
})
|
|
84
|
+
export class HeaderComponent {}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
To open the UI from code, inject `WalletUiService`: `openConnect()` (resolves
|
|
88
|
+
with a `ConnectResult`), `openAccountMenu(event)` and `openAccounts()`. On
|
|
89
|
+
phones (Ionic mobile platform or a viewport of 575px or less) the modal and
|
|
90
|
+
menu open as bottom sheets; elsewhere the modal is a 360px dialog and the menu
|
|
91
|
+
a popover anchored on the chip. Inside the docked navbar (`hs-app-navbar`, or
|
|
92
|
+
a `header`) the popover opens below the bar, at the bar's bottom plus
|
|
93
|
+
`--app-navbar-dropdown-gap` (8px by default) like the navbar's dropdown cards;
|
|
94
|
+
elsewhere 8px below the chip.
|
|
95
|
+
|
|
96
|
+
Only one connect modal is shown at a time. Opening it while one is already up
|
|
97
|
+
(for example the Reconnect toast's modal, then "Add another wallet") joins the
|
|
98
|
+
open modal: the new call's options (`mode`, `showBack`, overrides) are ignored
|
|
99
|
+
and it resolves with that modal's result. Close the open modal first to show
|
|
100
|
+
it with other options.
|
|
101
|
+
|
|
102
|
+
### On a lazy route
|
|
103
|
+
|
|
104
|
+
To keep the wallet UI out of the first bundle, provide it on the lazy route
|
|
105
|
+
instead of at the root:
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
// app.routes.ts
|
|
109
|
+
{
|
|
110
|
+
path: 'wallet',
|
|
111
|
+
providers: [provideWalletUi({ appId: 'my-dapp', appName: 'My dApp' })],
|
|
112
|
+
loadComponent: () => import('./wallet/wallet.page').then((m) => m.WalletPage),
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
`provideWalletUi()` provides `WalletUiService` together with its config, so
|
|
117
|
+
`hsuite-wallet-button`, `wallet-connect-button` and anything that injects
|
|
118
|
+
`WalletUiService` under that route get the route's instance, which sees the
|
|
119
|
+
route's config. Do not also provide `WalletUiService` yourself. Outside the
|
|
120
|
+
route, `WalletUiService` is still injectable from the root, but that instance
|
|
121
|
+
has no config (the modal falls back to its defaults). Provided at the root,
|
|
122
|
+
there is a single instance, as before.
|
|
123
|
+
|
|
124
|
+
### Chip styling
|
|
125
|
+
|
|
126
|
+
The header chip sizes itself from public custom properties, falling back to
|
|
127
|
+
the docked navbar's control properties (`hs-app-navbar`), so it matches the
|
|
128
|
+
other header buttons without `::ng-deep`:
|
|
129
|
+
|
|
130
|
+
| Property | Fallback | Default |
|
|
131
|
+
| ----------------------------- | -------------------------------- | ------------------------- |
|
|
132
|
+
| `--hs-connect-chip-height` | `--app-navbar-control-size` | `40px` |
|
|
133
|
+
| `--hs-connect-chip-radius` | `--app-navbar-control-radius` | `8px` |
|
|
134
|
+
| `--hs-connect-chip-border` | `--app-navbar-control-border` | `1px solid` (text at 14%) |
|
|
135
|
+
| `--hs-connect-chip-bg` | `--app-navbar-control-bg` | `transparent` |
|
|
136
|
+
| `--hs-connect-chip-bg-active` | `--app-navbar-control-bg-active` | text at 6% (hover / open) |
|
|
137
|
+
|
|
138
|
+
The touch target stays at least 44px tall whatever the height. The "Connect
|
|
139
|
+
Wallet" state keeps its accent fill.
|
|
140
|
+
|
|
141
|
+
### Overlay styles (required)
|
|
142
|
+
|
|
143
|
+
Ionic renders modals and popovers outside the components, so their size comes
|
|
144
|
+
from a global stylesheet shipped with the package. Add it once to the app's
|
|
145
|
+
global styles:
|
|
146
|
+
|
|
147
|
+
```jsonc
|
|
148
|
+
// angular.json → projects.<app>.architect.build.options.styles
|
|
149
|
+
"styles": [
|
|
150
|
+
"node_modules/@hsuite/native-connect-angular/dist/styles/wallet-ui.scss",
|
|
151
|
+
"src/global.scss"
|
|
152
|
+
]
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
or, from a global Sass file (resolved through the package's `exports`; checked
|
|
156
|
+
with the `@angular-devkit/build-angular:browser` builder):
|
|
157
|
+
|
|
158
|
+
```scss
|
|
159
|
+
@use '@hsuite/native-connect-angular/styles/wallet-ui';
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
It sizes the overlays the service opens by their CSS classes:
|
|
163
|
+
`hs-connect-modal` (connect modal and accounts list: 360px wide, height of the
|
|
164
|
+
content, 24px radius; an auto-height sheet on phones), `hs-account-popover`
|
|
165
|
+
(account menu, 340px) and `hs-account-sheet` (account menu on phones). Colors
|
|
166
|
+
come from the `--hs-connect-*` custom properties (see
|
|
167
|
+
`hsc-theme.styles.ts`), falling back to the Ionic theme.
|
|
168
|
+
|
|
169
|
+
The "… disconnected — Reconnect" toast that `hsuite-wallet-button` shows when
|
|
170
|
+
the wallet ends a session is a plain Ionic toast with the class
|
|
171
|
+
`hs-session-toast`. The stylesheet has no rule for it, so it follows the app's
|
|
172
|
+
`ion-toast` theme; the class is a hook for apps that want to style it:
|
|
173
|
+
|
|
174
|
+
```scss
|
|
175
|
+
ion-toast.hs-session-toast {
|
|
176
|
+
--background: var(--hs-connect-bg, var(--ion-overlay-background-color));
|
|
177
|
+
--color: var(--hs-connect-text, var(--ion-text-color));
|
|
178
|
+
--button-color: var(--hs-connect-accent, var(--ion-color-primary));
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Apps that still open `WalletConnectionModalComponent` with their own
|
|
183
|
+
`ModalController` call (a full-screen modal) keep working: the card centres
|
|
184
|
+
itself unless its modal has the `hs-connect-modal` class.
|
|
185
|
+
|
|
186
|
+
> `wallet-connect-button` (`WalletConnectButtonComponent`) is deprecated in favour of
|
|
187
|
+
> `hsuite-wallet-button`. With `provideWalletUi()` it opens the connect modal
|
|
188
|
+
> through `WalletUiService`; its explicit inputs override the config.
|
|
189
|
+
|
|
31
190
|
## Features
|
|
32
191
|
|
|
33
192
|
- HSuite Channel Protocol - Native `hsc:` protocol with Nostr + P2P transport
|