@hsuite/native-connect-angular 1.0.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 +48 -0
- package/USAGE_EXAMPLES.md +476 -0
- package/assets/wallets/extension.svg +7 -0
- package/assets/wallets/hashpack.svg +6 -0
- package/assets/wallets/hsuite.svg +11 -0
- package/assets/wallets/kabila.svg +11 -0
- package/assets/wallets/walletconnect.svg +13 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/coverage-summary.json +50 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +476 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +476 -0
- package/coverage/lcov-report/lib/components/account-selector/account-actions/account-actions.component.ts.html +868 -0
- package/coverage/lcov-report/lib/components/account-selector/account-actions/index.html +116 -0
- package/coverage/lcov-report/lib/components/account-selector/account-filter/account-filter.component.ts.html +1288 -0
- package/coverage/lcov-report/lib/components/account-selector/account-filter/index.html +116 -0
- package/coverage/lcov-report/lib/components/account-selector/account-formatting.service.ts.html +685 -0
- package/coverage/lcov-report/lib/components/account-selector/account-grouping.service.ts.html +766 -0
- package/coverage/lcov-report/lib/components/account-selector/account-list/account-list.component.ts.html +1495 -0
- package/coverage/lcov-report/lib/components/account-selector/account-list/index.html +116 -0
- package/coverage/lcov-report/lib/components/account-selector/account-selector.component.ts.html +1495 -0
- package/coverage/lcov-report/lib/components/account-selector/account-selector.service.ts.html +1588 -0
- package/coverage/lcov-report/lib/components/account-selector/index.html +161 -0
- package/coverage/lcov-report/lib/components/wallet-account-display/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-account-display/wallet-account-display.component.ts.html +505 -0
- package/coverage/lcov-report/lib/components/wallet-connect-button/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +805 -0
- package/coverage/lcov-report/lib/components/wallet-connect-prompt/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +409 -0
- package/coverage/lcov-report/lib/components/wallet-connected-guard/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +304 -0
- package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +436 -0
- package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-connection-modal/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +2287 -0
- package/coverage/lcov-report/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +2275 -0
- package/coverage/lcov-report/lib/components/wallet-session-display/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-session-display/wallet-session-display.component.ts.html +676 -0
- package/coverage/lcov-report/lib/components/wallet-transaction-status/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +703 -0
- package/coverage/lcov-report/lib/directives/index.html +146 -0
- package/coverage/lcov-report/lib/directives/wallet-connected.directive.ts.html +670 -0
- package/coverage/lcov-report/lib/directives/wallet-context.directive.ts.html +547 -0
- package/coverage/lcov-report/lib/directives/wallet-events.directive.ts.html +781 -0
- package/coverage/lcov-report/lib/hsuite-wallet.module.ts.html +715 -0
- package/coverage/lcov-report/lib/index.html +116 -0
- package/coverage/lcov-report/lib/models/connection-config.model.ts.html +280 -0
- package/coverage/lcov-report/lib/models/index.html +131 -0
- package/coverage/lcov-report/lib/models/provider-types.ts.html +577 -0
- package/coverage/lcov-report/lib/providers/base-wallet-provider.ts.html +1138 -0
- package/coverage/lcov-report/lib/providers/hsuite-native/channel-client.service.ts.html +2671 -0
- package/coverage/lcov-report/lib/providers/hsuite-native/index.html +116 -0
- package/coverage/lcov-report/lib/providers/hsuite-native-provider.ts.html +2347 -0
- package/coverage/lcov-report/lib/providers/index.html +146 -0
- package/coverage/lcov-report/lib/providers/p2p-native/index.html +131 -0
- package/coverage/lcov-report/lib/providers/p2p-native/p2p-native.provider.ts.html +2254 -0
- package/coverage/lcov-report/lib/providers/p2p-native/p2p-session-manager.ts.html +2170 -0
- package/coverage/lcov-report/lib/providers/wallet-error-handler.ts.html +1132 -0
- package/coverage/lcov-report/lib/providers/walletconnect/core/index.html +176 -0
- package/coverage/lcov-report/lib/providers/walletconnect/core/session-health.ts.html +673 -0
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +1177 -0
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-provider.ts.html +2563 -0
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +904 -0
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +982 -0
- package/coverage/lcov-report/lib/providers/walletconnect/signers/hedera-signer.ts.html +1915 -0
- package/coverage/lcov-report/lib/providers/walletconnect/signers/index.html +146 -0
- package/coverage/lcov-report/lib/providers/walletconnect/signers/signer-factory.ts.html +445 -0
- package/coverage/lcov-report/lib/providers/walletconnect/signers/xrpl-signer.ts.html +1519 -0
- package/coverage/lcov-report/lib/services/index.html +191 -0
- package/coverage/lcov-report/lib/services/logger.service.ts.html +463 -0
- package/coverage/lcov-report/lib/services/transaction-builders/base-transaction-builder.service.ts.html +1840 -0
- package/coverage/lcov-report/lib/services/transaction-builders/hedera-amount-utils.ts.html +337 -0
- package/coverage/lcov-report/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +3940 -0
- package/coverage/lcov-report/lib/services/transaction-builders/index.html +161 -0
- package/coverage/lcov-report/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +2581 -0
- package/coverage/lcov-report/lib/services/transaction.service.ts.html +1123 -0
- package/coverage/lcov-report/lib/services/unified-wallet.service.ts.html +2641 -0
- package/coverage/lcov-report/lib/services/wallet-context.service.ts.html +637 -0
- package/coverage/lcov-report/lib/services/wallet-event-bus.service.ts.html +643 -0
- package/coverage/lcov-report/lib/services/wallet-providers.service.ts.html +496 -0
- package/coverage/lcov-report/lib/transports/chrome-extension-transport.ts.html +823 -0
- package/coverage/lcov-report/lib/transports/index.html +116 -0
- package/coverage/lcov-report/lib/utils/index.html +116 -0
- package/coverage/lcov-report/lib/utils/ledger-icons.util.ts.html +319 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov.info +19252 -0
- package/coverage/lib/components/account-selector/account-actions/account-actions.component.ts.html +868 -0
- package/coverage/lib/components/account-selector/account-actions/index.html +116 -0
- package/coverage/lib/components/account-selector/account-filter/account-filter.component.ts.html +1288 -0
- package/coverage/lib/components/account-selector/account-filter/index.html +116 -0
- package/coverage/lib/components/account-selector/account-formatting.service.ts.html +685 -0
- package/coverage/lib/components/account-selector/account-grouping.service.ts.html +766 -0
- package/coverage/lib/components/account-selector/account-list/account-list.component.ts.html +1495 -0
- package/coverage/lib/components/account-selector/account-list/index.html +116 -0
- package/coverage/lib/components/account-selector/account-selector.component.ts.html +1495 -0
- package/coverage/lib/components/account-selector/account-selector.service.ts.html +1588 -0
- package/coverage/lib/components/account-selector/index.html +161 -0
- package/coverage/lib/components/wallet-account-display/index.html +116 -0
- package/coverage/lib/components/wallet-account-display/wallet-account-display.component.ts.html +505 -0
- package/coverage/lib/components/wallet-connect-button/index.html +116 -0
- package/coverage/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +805 -0
- package/coverage/lib/components/wallet-connect-prompt/index.html +116 -0
- package/coverage/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +409 -0
- package/coverage/lib/components/wallet-connected-guard/index.html +116 -0
- package/coverage/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +304 -0
- package/coverage/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +436 -0
- package/coverage/lib/components/wallet-connection-modal/connection-method-step/index.html +116 -0
- package/coverage/lib/components/wallet-connection-modal/index.html +116 -0
- package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/index.html +116 -0
- package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +2287 -0
- package/coverage/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +2275 -0
- package/coverage/lib/components/wallet-session-display/index.html +116 -0
- package/coverage/lib/components/wallet-session-display/wallet-session-display.component.ts.html +676 -0
- package/coverage/lib/components/wallet-transaction-status/index.html +116 -0
- package/coverage/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +703 -0
- package/coverage/lib/directives/index.html +146 -0
- package/coverage/lib/directives/wallet-connected.directive.ts.html +670 -0
- package/coverage/lib/directives/wallet-context.directive.ts.html +547 -0
- package/coverage/lib/directives/wallet-events.directive.ts.html +781 -0
- package/coverage/lib/hsuite-wallet.module.ts.html +715 -0
- package/coverage/lib/index.html +116 -0
- package/coverage/lib/models/connection-config.model.ts.html +280 -0
- package/coverage/lib/models/index.html +131 -0
- package/coverage/lib/models/provider-types.ts.html +577 -0
- package/coverage/lib/providers/base-wallet-provider.ts.html +1138 -0
- package/coverage/lib/providers/hsuite-native/channel-client.service.ts.html +2671 -0
- package/coverage/lib/providers/hsuite-native/index.html +116 -0
- package/coverage/lib/providers/hsuite-native-provider.ts.html +2347 -0
- package/coverage/lib/providers/index.html +146 -0
- package/coverage/lib/providers/p2p-native/index.html +131 -0
- package/coverage/lib/providers/p2p-native/p2p-native.provider.ts.html +2254 -0
- package/coverage/lib/providers/p2p-native/p2p-session-manager.ts.html +2170 -0
- package/coverage/lib/providers/wallet-error-handler.ts.html +1132 -0
- package/coverage/lib/providers/walletconnect/core/index.html +176 -0
- package/coverage/lib/providers/walletconnect/core/session-health.ts.html +673 -0
- package/coverage/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +1177 -0
- package/coverage/lib/providers/walletconnect/core/walletconnect-provider.ts.html +2563 -0
- package/coverage/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +904 -0
- package/coverage/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +982 -0
- package/coverage/lib/providers/walletconnect/signers/hedera-signer.ts.html +1915 -0
- package/coverage/lib/providers/walletconnect/signers/index.html +146 -0
- package/coverage/lib/providers/walletconnect/signers/signer-factory.ts.html +445 -0
- package/coverage/lib/providers/walletconnect/signers/xrpl-signer.ts.html +1519 -0
- package/coverage/lib/services/index.html +191 -0
- package/coverage/lib/services/logger.service.ts.html +463 -0
- package/coverage/lib/services/transaction-builders/base-transaction-builder.service.ts.html +1840 -0
- package/coverage/lib/services/transaction-builders/hedera-amount-utils.ts.html +337 -0
- package/coverage/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +3940 -0
- package/coverage/lib/services/transaction-builders/index.html +161 -0
- package/coverage/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +2581 -0
- package/coverage/lib/services/transaction.service.ts.html +1123 -0
- package/coverage/lib/services/unified-wallet.service.ts.html +2641 -0
- package/coverage/lib/services/wallet-context.service.ts.html +637 -0
- package/coverage/lib/services/wallet-event-bus.service.ts.html +643 -0
- package/coverage/lib/services/wallet-providers.service.ts.html +496 -0
- package/coverage/lib/transports/chrome-extension-transport.ts.html +823 -0
- package/coverage/lib/transports/index.html +116 -0
- package/coverage/lib/utils/index.html +116 -0
- package/coverage/lib/utils/ledger-icons.util.ts.html +319 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/dist/README.md +48 -0
- package/dist/fesm2022/hsuite-native-connect-angular.mjs +14592 -0
- package/dist/fesm2022/hsuite-native-connect-angular.mjs.map +1 -0
- package/dist/index.d.ts +6949 -0
- package/examples/minimal-connect.ts +178 -0
- package/examples/multi-protocol.ts +495 -0
- package/examples/transaction-signing.ts +361 -0
- package/jest.config.json +45 -0
- package/karma.conf.js +42 -0
- package/ng-package.json +20 -0
- package/package.json +60 -0
- package/src/index.ts +203 -0
- package/src/lib/components/account-selector/account-actions/account-actions.component.ts +261 -0
- package/src/lib/components/account-selector/account-filter/account-filter.component.ts +401 -0
- package/src/lib/components/account-selector/account-formatting.service.ts +200 -0
- package/src/lib/components/account-selector/account-grouping.service.ts +227 -0
- package/src/lib/components/account-selector/account-list/account-list.component.ts +470 -0
- package/src/lib/components/account-selector/account-selector.component.html +135 -0
- package/src/lib/components/account-selector/account-selector.component.scss +2039 -0
- package/src/lib/components/account-selector/account-selector.component.ts +470 -0
- package/src/lib/components/account-selector/account-selector.service.ts +501 -0
- package/src/lib/components/wallet-account-display/wallet-account-display.component.html +34 -0
- package/src/lib/components/wallet-account-display/wallet-account-display.component.scss +99 -0
- package/src/lib/components/wallet-account-display/wallet-account-display.component.ts +140 -0
- package/src/lib/components/wallet-connect-button/wallet-connect-button.component.html +14 -0
- package/src/lib/components/wallet-connect-button/wallet-connect-button.component.scss +272 -0
- package/src/lib/components/wallet-connect-button/wallet-connect-button.component.ts +240 -0
- package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.html +24 -0
- package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.scss +50 -0
- package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts +108 -0
- package/src/lib/components/wallet-connected-guard/wallet-connected-guard.component.html +24 -0
- package/src/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts +73 -0
- package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.html +56 -0
- package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.scss +218 -0
- package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts +117 -0
- package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.html +94 -0
- package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.scss +272 -0
- package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts +734 -0
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.html +197 -0
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.scss +678 -0
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts +730 -0
- package/src/lib/components/wallet-session-display/wallet-session-display.component.html +110 -0
- package/src/lib/components/wallet-session-display/wallet-session-display.component.scss +179 -0
- package/src/lib/components/wallet-session-display/wallet-session-display.component.ts +197 -0
- package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.html +65 -0
- package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.scss +254 -0
- package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts +206 -0
- package/src/lib/directives/wallet-connected.directive.ts +195 -0
- package/src/lib/directives/wallet-context.directive.ts +154 -0
- package/src/lib/directives/wallet-events.directive.ts +232 -0
- package/src/lib/hsuite-wallet.module.ts +210 -0
- package/src/lib/models/connection-config.model.ts +65 -0
- package/src/lib/models/provider-types.ts +164 -0
- package/src/lib/models/unified-account.model.ts +76 -0
- package/src/lib/models/wallet-context.model.ts +121 -0
- package/src/lib/models/wallet-events.model.ts +158 -0
- package/src/lib/providers/base-wallet-provider.ts +351 -0
- package/src/lib/providers/hsuite-native/channel-client.service.spec.ts +73 -0
- package/src/lib/providers/hsuite-native/channel-client.service.ts +862 -0
- package/src/lib/providers/hsuite-native/index.ts +8 -0
- package/src/lib/providers/hsuite-native-provider.ts +754 -0
- package/src/lib/providers/mobile-native/mobile-native.provider.spec.ts +19 -0
- package/src/lib/providers/p2p-native/index.ts +30 -0
- package/src/lib/providers/p2p-native/p2p-native.provider.spec.ts +523 -0
- package/src/lib/providers/p2p-native/p2p-native.provider.ts +723 -0
- package/src/lib/providers/p2p-native/p2p-session-manager.ts +695 -0
- package/src/lib/providers/wallet-error-handler.ts +349 -0
- package/src/lib/providers/walletconnect/core/base-signer.interface.ts +122 -0
- package/src/lib/providers/walletconnect/core/session-health.ts +196 -0
- package/src/lib/providers/walletconnect/core/walletconnect-client-manager.ts +364 -0
- package/src/lib/providers/walletconnect/core/walletconnect-provider.integration.spec.ts +348 -0
- package/src/lib/providers/walletconnect/core/walletconnect-provider.ts +826 -0
- package/src/lib/providers/walletconnect/core/walletconnect-session-store.ts +273 -0
- package/src/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts +299 -0
- package/src/lib/providers/walletconnect/core/walletconnect-types.ts +48 -0
- package/src/lib/providers/walletconnect/index.ts +33 -0
- package/src/lib/providers/walletconnect/signers/hedera-signer.spec.ts +367 -0
- package/src/lib/providers/walletconnect/signers/hedera-signer.ts +610 -0
- package/src/lib/providers/walletconnect/signers/signer-factory.spec.ts +62 -0
- package/src/lib/providers/walletconnect/signers/signer-factory.ts +120 -0
- package/src/lib/providers/walletconnect/signers/xrpl-signer.spec.ts +296 -0
- package/src/lib/providers/walletconnect/signers/xrpl-signer.ts +478 -0
- package/src/lib/services/logger.service.ts +126 -0
- package/src/lib/services/transaction-builders/base-transaction-builder.service.ts +585 -0
- package/src/lib/services/transaction-builders/hedera-amount-utils.ts +84 -0
- package/src/lib/services/transaction-builders/hedera-transaction-builder.service.spec.ts +741 -0
- package/src/lib/services/transaction-builders/hedera-transaction-builder.service.ts +1285 -0
- package/src/lib/services/transaction-builders/index.ts +54 -0
- package/src/lib/services/transaction-builders/xrpl-transaction-builder.service.spec.ts +937 -0
- package/src/lib/services/transaction-builders/xrpl-transaction-builder.service.ts +832 -0
- package/src/lib/services/transaction.service.ts +346 -0
- package/src/lib/services/unified-wallet.service.spec.ts +1382 -0
- package/src/lib/services/unified-wallet.service.ts +852 -0
- package/src/lib/services/wallet-context.service.ts +184 -0
- package/src/lib/services/wallet-event-bus.service.ts +186 -0
- package/src/lib/services/wallet-providers.service.ts +137 -0
- package/src/lib/transports/chrome-extension-transport.ts +246 -0
- package/src/lib/utils/index.ts +14 -0
- package/src/lib/utils/ledger-icons.util.ts +78 -0
- package/test/test-setup.ts +21 -0
- package/test-setup.ts +63 -0
- package/tsconfig.build.json +11 -0
- package/tsconfig.json +29 -0
- package/tsconfig.spec.json +15 -0
- package/vitest.config.ts +48 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HSuite Native Connect
|
|
3
|
+
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
6
|
+
*
|
|
7
|
+
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
8
|
+
* visit https://hsuite.finance/licensing
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @file wallet-account-display.component.ts
|
|
13
|
+
* @description Pre-built component for displaying active account information
|
|
14
|
+
*
|
|
15
|
+
* Automatically displays the active account with badges, formatted address,
|
|
16
|
+
* and responsive styling. Eliminates repetitive account display boilerplate.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { Component, Input, computed, inject } from '@angular/core';
|
|
20
|
+
import { CommonModule } from '@angular/common';
|
|
21
|
+
import { IonText, IonBadge, IonIcon } from '@ionic/angular/standalone';
|
|
22
|
+
import { addIcons } from 'ionicons';
|
|
23
|
+
import { walletOutline, personOutline, peopleOutline } from 'ionicons/icons';
|
|
24
|
+
import { WalletContextService } from '../../services/wallet-context.service';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Pre-built component for displaying active account
|
|
28
|
+
*
|
|
29
|
+
* Features:
|
|
30
|
+
* - Auto-syncs with active account
|
|
31
|
+
* - Optional badges for ledger and network
|
|
32
|
+
* - Optional address truncation
|
|
33
|
+
* - Responsive styling
|
|
34
|
+
* - Customizable colors
|
|
35
|
+
*/
|
|
36
|
+
@Component({
|
|
37
|
+
selector: 'wallet-account-display',
|
|
38
|
+
standalone: true,
|
|
39
|
+
imports: [CommonModule, IonText, IonBadge, IonIcon],
|
|
40
|
+
templateUrl: './wallet-account-display.component.html',
|
|
41
|
+
styleUrls: ['./wallet-account-display.component.scss'],
|
|
42
|
+
})
|
|
43
|
+
export class WalletAccountDisplayComponent {
|
|
44
|
+
private readonly contextService = inject(WalletContextService);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Whether to show ledger and network badges
|
|
48
|
+
*/
|
|
49
|
+
@Input() showBadges = true;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Whether to show account label
|
|
53
|
+
*/
|
|
54
|
+
@Input() showLabel = true;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Whether to truncate long addresses
|
|
58
|
+
*/
|
|
59
|
+
@Input() truncateAddress = true;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Color for the address text
|
|
63
|
+
*/
|
|
64
|
+
@Input() addressColor: 'primary' | 'secondary' | 'tertiary' | 'medium' | 'dark' = 'medium';
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Text to show when no account is selected
|
|
68
|
+
*/
|
|
69
|
+
@Input() emptyText = 'No account selected';
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Active account from context
|
|
73
|
+
*/
|
|
74
|
+
protected readonly account = computed(() => this.contextService.context().activeAccount);
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Computed display address (truncated or full)
|
|
78
|
+
*/
|
|
79
|
+
protected readonly displayAddress = computed(() => {
|
|
80
|
+
const acc = this.account();
|
|
81
|
+
if (!acc) return '';
|
|
82
|
+
|
|
83
|
+
if (this.truncateAddress && acc.address.length > 20) {
|
|
84
|
+
return `${acc.address.substring(0, 10)}...${acc.address.substring(acc.address.length - 8)}`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return acc.address;
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Computed check if account is multisig
|
|
92
|
+
*/
|
|
93
|
+
protected readonly isMultisig = computed(() => {
|
|
94
|
+
const acc = this.account();
|
|
95
|
+
if (!acc) return false;
|
|
96
|
+
const metadata = acc.metadata as Record<string, unknown> | undefined;
|
|
97
|
+
return metadata?.['isMultisig'] === true || metadata?.['accountType'] === 'multisig';
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get multisig threshold info (e.g., "2/3")
|
|
102
|
+
*/
|
|
103
|
+
protected readonly multisigInfo = computed(() => {
|
|
104
|
+
const acc = this.account();
|
|
105
|
+
if (!acc) return null;
|
|
106
|
+
const metadata = acc.metadata as Record<string, unknown> | undefined;
|
|
107
|
+
const threshold = metadata?.['multisigThreshold'] as number | undefined;
|
|
108
|
+
const total = metadata?.['multisigTotal'] as number | undefined;
|
|
109
|
+
if (threshold && total) {
|
|
110
|
+
return `${threshold}/${total}`;
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
constructor() {
|
|
116
|
+
addIcons({ walletOutline, personOutline, peopleOutline });
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Get color for ledger badge
|
|
121
|
+
*/
|
|
122
|
+
protected getLedgerColor(ledgerId: string): string {
|
|
123
|
+
switch (ledgerId.toLowerCase()) {
|
|
124
|
+
case 'hedera':
|
|
125
|
+
return 'success';
|
|
126
|
+
case 'xrpl':
|
|
127
|
+
return 'tertiary';
|
|
128
|
+
default:
|
|
129
|
+
return 'primary';
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Format network ID for display
|
|
135
|
+
*/
|
|
136
|
+
protected formatNetwork(networkId: string): string {
|
|
137
|
+
const parts = networkId.split(':');
|
|
138
|
+
return parts[parts.length - 1] || networkId;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<div class="wallet-connect-container" [class]="'size-' + size">
|
|
2
|
+
<!-- Connect Button (Multi-Session Support) -->
|
|
3
|
+
<ion-button
|
|
4
|
+
[color]="buttonColor"
|
|
5
|
+
[size]="size"
|
|
6
|
+
[disabled]="isConnecting"
|
|
7
|
+
(click)="connect()"
|
|
8
|
+
class="wallet-button">
|
|
9
|
+
<ion-spinner *ngIf="isConnecting" slot="start" name="crescent"></ion-spinner>
|
|
10
|
+
<ion-icon *ngIf="!isConnecting" [name]="getIconName()" slot="start"></ion-icon>
|
|
11
|
+
{{ getButtonText() }}
|
|
12
|
+
</ion-button>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @component WalletConnectButton
|
|
3
|
+
* @compodoc
|
|
4
|
+
* Theme-aware wallet connection button for dApps
|
|
5
|
+
* Fully customizable via CSS variables
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
.wallet-connect-container {
|
|
9
|
+
display: inline-block;
|
|
10
|
+
width: 100%;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* Wallet Button */
|
|
14
|
+
.wallet-button {
|
|
15
|
+
--border-radius: var(--wallet-button-radius, var(--border-radius-lg, 12px));
|
|
16
|
+
--padding-top: var(--wallet-button-padding-vertical, var(--space-md, 14px));
|
|
17
|
+
--padding-bottom: var(--wallet-button-padding-vertical, var(--space-md, 14px));
|
|
18
|
+
--padding-start: var(--wallet-button-padding-horizontal, var(--space-lg, 24px));
|
|
19
|
+
--padding-end: var(--wallet-button-padding-horizontal, var(--space-lg, 24px));
|
|
20
|
+
width: 100%;
|
|
21
|
+
font-weight: var(--wallet-button-font-weight, var(--font-weight-semibold, 600));
|
|
22
|
+
font-size: var(--wallet-button-font-size, var(--font-size-md, 16px));
|
|
23
|
+
text-transform: none;
|
|
24
|
+
letter-spacing: var(--letter-spacing-wide, 0.5px);
|
|
25
|
+
transition: var(--wallet-transition-normal, var(--transition-all, 0.2s ease));
|
|
26
|
+
box-shadow: var(--wallet-button-shadow, var(--shadow-md));
|
|
27
|
+
|
|
28
|
+
&:hover:not([disabled]) {
|
|
29
|
+
transform: translateY(-2px);
|
|
30
|
+
box-shadow: var(--shadow-lg);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&:active:not([disabled]) {
|
|
34
|
+
transform: translateY(0);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
ion-icon {
|
|
38
|
+
font-size: 1.25em;
|
|
39
|
+
transition: transform var(--wallet-transition-fast, var(--transition-fade, 0.15s)) ease;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&:hover:not([disabled]) ion-icon {
|
|
43
|
+
transform: scale(var(--button-hover-scale, 1.1));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* Session Display */
|
|
48
|
+
.session-display {
|
|
49
|
+
background: var(--wallet-session-bg, var(--surface-flat, rgba(var(--ion-color-light-rgb), 0.05)));
|
|
50
|
+
border: var(--border-width-thin, 1px) solid var(--wallet-session-border, var(--border-flat, rgba(var(--ion-color-light-rgb), 0.1)));
|
|
51
|
+
border-radius: var(--wallet-session-radius, var(--border-radius-lg, 12px));
|
|
52
|
+
padding: var(--wallet-session-padding, var(--space-lg, 16px));
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
gap: var(--wallet-session-gap, var(--space-md, 12px));
|
|
56
|
+
box-shadow: var(--wallet-session-shadow, var(--shadow-md));
|
|
57
|
+
animation: slideIn var(--wallet-transition-slow, var(--duration-slow, 0.3s)) ease-out;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.session-header {
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
justify-content: space-between;
|
|
64
|
+
gap: var(--wallet-spacing-lg, var(--space-lg, 16px));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.session-info {
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
gap: var(--wallet-spacing-md, var(--space-md, 8px));
|
|
71
|
+
flex: 1;
|
|
72
|
+
min-width: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.session-icon {
|
|
76
|
+
font-size: var(--wallet-session-icon-size, var(--font-size-2xl, 28px));
|
|
77
|
+
color: var(--ion-color-primary);
|
|
78
|
+
flex-shrink: 0;
|
|
79
|
+
transition: transform var(--wallet-transition-fast, var(--duration-fast, 0.15s)) ease;
|
|
80
|
+
|
|
81
|
+
.session-display:hover & {
|
|
82
|
+
transform: scale(1.05);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.session-details {
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
gap: var(--wallet-spacing-xs, var(--space-xs, 4px));
|
|
90
|
+
min-width: 0;
|
|
91
|
+
flex: 1;
|
|
92
|
+
|
|
93
|
+
strong {
|
|
94
|
+
font-size: var(--wallet-font-size-base, var(--font-size-sm, 14px));
|
|
95
|
+
font-weight: var(--wallet-font-weight-semibold, var(--font-weight-semibold, 600));
|
|
96
|
+
color: var(--wallet-session-text-primary, var(--ion-text-color));
|
|
97
|
+
line-height: var(--wallet-line-height-normal, var(--line-height-normal, 1.4));
|
|
98
|
+
display: block;
|
|
99
|
+
overflow: hidden;
|
|
100
|
+
text-overflow: ellipsis;
|
|
101
|
+
white-space: nowrap;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.session-badges {
|
|
106
|
+
display: flex;
|
|
107
|
+
gap: var(--wallet-spacing-xs, var(--space-xs, 4px));
|
|
108
|
+
flex-wrap: wrap;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.network-badge {
|
|
112
|
+
font-size: var(--wallet-badge-font-size, var(--font-size-xs, 10px));
|
|
113
|
+
font-weight: var(--wallet-badge-font-weight, var(--font-weight-semibold, 600));
|
|
114
|
+
padding: var(--wallet-badge-padding, var(--space-xs, 3px) var(--space-sm, 8px));
|
|
115
|
+
border-radius: var(--wallet-badge-radius, var(--border-radius-sm, 6px));
|
|
116
|
+
line-height: var(--line-height-tight, 1.2);
|
|
117
|
+
transition: transform var(--wallet-transition-fast, var(--duration-fast, 0.15s)) ease;
|
|
118
|
+
|
|
119
|
+
.session-display:hover & {
|
|
120
|
+
transform: scale(1.05);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.disconnect-button {
|
|
125
|
+
--border-radius: var(--wallet-spacing-sm, var(--border-radius-md, 8px));
|
|
126
|
+
--padding-start: var(--wallet-spacing-sm, var(--space-sm, 8px));
|
|
127
|
+
--padding-end: var(--wallet-spacing-sm, var(--space-sm, 8px));
|
|
128
|
+
flex-shrink: 0;
|
|
129
|
+
transition: all var(--wallet-transition-fast, var(--transition-all, 0.15s ease));
|
|
130
|
+
|
|
131
|
+
&:hover:not([disabled]) {
|
|
132
|
+
transform: scale(1.05);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
&:active:not([disabled]) {
|
|
136
|
+
transform: scale(var(--button-press-scale, 0.95));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* Account List */
|
|
141
|
+
.account-list {
|
|
142
|
+
display: flex;
|
|
143
|
+
flex-direction: column;
|
|
144
|
+
gap: var(--wallet-spacing-sm, var(--space-sm, 4px));
|
|
145
|
+
padding-top: var(--wallet-spacing-md, var(--space-md, 8px));
|
|
146
|
+
border-top: var(--border-width-thin, 1px) solid var(--wallet-session-border, var(--border-flat, rgba(var(--ion-color-light-rgb), 0.1)));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.account-item {
|
|
150
|
+
display: flex;
|
|
151
|
+
align-items: center;
|
|
152
|
+
justify-content: space-between;
|
|
153
|
+
padding: var(--wallet-account-padding, var(--space-sm, 8px) var(--space-md, 12px));
|
|
154
|
+
background: var(--wallet-account-bg, var(--surface-flat, rgba(var(--ion-color-primary-rgb), 0.05)));
|
|
155
|
+
border-radius: var(--wallet-account-radius, var(--border-radius-md, 8px));
|
|
156
|
+
transition: all var(--wallet-transition-normal, var(--transition-all, 0.2s ease));
|
|
157
|
+
|
|
158
|
+
&:hover {
|
|
159
|
+
background: var(--wallet-account-bg-hover, var(--surface-flat-hover, rgba(var(--ion-color-primary-rgb), 0.1)));
|
|
160
|
+
transform: translateX(2px);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.account-address {
|
|
164
|
+
font-family: var(--wallet-account-font-family, var(--font-family-mono, monospace));
|
|
165
|
+
font-size: var(--wallet-account-font-size, var(--font-size-sm, 14px));
|
|
166
|
+
color: var(--wallet-session-text-primary, var(--ion-text-color));
|
|
167
|
+
line-height: var(--wallet-line-height-normal, var(--line-height-normal, 1.4));
|
|
168
|
+
overflow: hidden;
|
|
169
|
+
text-overflow: ellipsis;
|
|
170
|
+
white-space: nowrap;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/* Size Variants */
|
|
175
|
+
.size-small {
|
|
176
|
+
.wallet-button {
|
|
177
|
+
--padding-top: var(--wallet-spacing-sm, var(--space-sm, 8px));
|
|
178
|
+
--padding-bottom: var(--wallet-spacing-sm, var(--space-sm, 8px));
|
|
179
|
+
--padding-start: var(--wallet-spacing-lg, var(--space-lg, 16px));
|
|
180
|
+
--padding-end: var(--wallet-spacing-lg, var(--space-lg, 16px));
|
|
181
|
+
font-size: var(--wallet-font-size-sm, var(--font-size-sm, 13px));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
--wallet-session-padding: var(--wallet-spacing-md, var(--space-md, 12px));
|
|
185
|
+
|
|
186
|
+
.session-icon {
|
|
187
|
+
font-size: var(--font-size-xl, 24px);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.session-details strong {
|
|
191
|
+
font-size: var(--wallet-font-size-sm, var(--font-size-sm, 13px));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.size-large {
|
|
196
|
+
.wallet-button {
|
|
197
|
+
--padding-top: var(--wallet-spacing-lg, var(--space-lg, 18px));
|
|
198
|
+
--padding-bottom: var(--wallet-spacing-lg, var(--space-lg, 18px));
|
|
199
|
+
--padding-start: var(--wallet-spacing-2xl, var(--space-2xl, 32px));
|
|
200
|
+
--padding-end: var(--wallet-spacing-2xl, var(--space-2xl, 32px));
|
|
201
|
+
font-size: var(--wallet-font-size-lg, var(--font-size-lg, 18px));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
--wallet-session-padding: var(--wallet-spacing-xl, var(--space-xl, 20px));
|
|
205
|
+
|
|
206
|
+
.session-icon {
|
|
207
|
+
font-size: var(--font-size-3xl, 32px);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.session-details strong {
|
|
211
|
+
font-size: var(--wallet-font-size-lg, var(--font-size-lg, 18px));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/* Responsive */
|
|
216
|
+
@media (max-width: 576px) {
|
|
217
|
+
.session-header {
|
|
218
|
+
flex-wrap: wrap;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.disconnect-button {
|
|
222
|
+
width: 100%;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* Animations */
|
|
227
|
+
@keyframes pulse {
|
|
228
|
+
0%, 100% {
|
|
229
|
+
opacity: 1;
|
|
230
|
+
}
|
|
231
|
+
50% {
|
|
232
|
+
opacity: 0.6;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.wallet-button[disabled] {
|
|
237
|
+
animation: pulse 1.5s ease-in-out infinite;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
@keyframes slideIn {
|
|
241
|
+
from {
|
|
242
|
+
opacity: 0;
|
|
243
|
+
transform: translateY(-10px);
|
|
244
|
+
}
|
|
245
|
+
to {
|
|
246
|
+
opacity: 1;
|
|
247
|
+
transform: translateY(0);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/* Reduced Motion Support */
|
|
252
|
+
@media (prefers-reduced-motion: reduce) {
|
|
253
|
+
*,
|
|
254
|
+
*::before,
|
|
255
|
+
*::after {
|
|
256
|
+
animation-duration: 0.01ms !important;
|
|
257
|
+
transition-duration: 0.01ms !important;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
@keyframes slideIn {
|
|
261
|
+
from, to {
|
|
262
|
+
opacity: 1;
|
|
263
|
+
transform: translateY(0);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
@keyframes pulse {
|
|
268
|
+
from, to {
|
|
269
|
+
opacity: 1;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HSuite Native Connect
|
|
3
|
+
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
6
|
+
*
|
|
7
|
+
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
8
|
+
* visit https://hsuite.finance/licensing
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { CommonModule } from '@angular/common';
|
|
12
|
+
import { Component, EventEmitter, Input, Output, inject } from '@angular/core';
|
|
13
|
+
import { getLogger } from '@hsuite/native-connect-sdk';
|
|
14
|
+
import { IonButton, IonIcon, IonSpinner, ModalController } from '@ionic/angular/standalone';
|
|
15
|
+
import { addIcons } from 'ionicons';
|
|
16
|
+
import { walletOutline, linkOutline, checkmarkCircleOutline } from 'ionicons/icons';
|
|
17
|
+
|
|
18
|
+
import { DEFAULT_WALLET_URL } from '../../models/provider-types';
|
|
19
|
+
import { UnifiedWalletService } from '../../services/unified-wallet.service';
|
|
20
|
+
import { WalletConnectionModalComponent } from '../wallet-connection-modal/wallet-connection-modal.component';
|
|
21
|
+
|
|
22
|
+
const logger = getLogger().scoped?.('WalletConnectButton') ?? getLogger();
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @component WalletConnectButtonComponent
|
|
26
|
+
* Ready-to-use wallet connection button for dApps with multi-protocol support.
|
|
27
|
+
*
|
|
28
|
+
* **Features:**
|
|
29
|
+
* - Beautiful connection modal with protocol/network selection
|
|
30
|
+
* - Support for HSuite Native and WalletConnect
|
|
31
|
+
* - Automatic connection state management
|
|
32
|
+
* - Loading states
|
|
33
|
+
* - Session display
|
|
34
|
+
* - One-click connect/disconnect
|
|
35
|
+
* - Theme-aware styling
|
|
36
|
+
*
|
|
37
|
+
* **Design Principles:**
|
|
38
|
+
* - Easy configuration
|
|
39
|
+
* - Fully customizable appearance
|
|
40
|
+
* - Accessible
|
|
41
|
+
* - Responsive
|
|
42
|
+
*/
|
|
43
|
+
@Component({
|
|
44
|
+
selector: 'wallet-connect-button',
|
|
45
|
+
standalone: true,
|
|
46
|
+
imports: [CommonModule, IonButton, IonIcon, IonSpinner],
|
|
47
|
+
providers: [ModalController],
|
|
48
|
+
templateUrl: './wallet-connect-button.component.html',
|
|
49
|
+
styleUrls: ['./wallet-connect-button.component.scss'],
|
|
50
|
+
})
|
|
51
|
+
export class WalletConnectButtonComponent {
|
|
52
|
+
/**
|
|
53
|
+
* WalletConnect project ID (required for WalletConnect)
|
|
54
|
+
*/
|
|
55
|
+
@Input() walletConnectProjectId?: string;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* App name for wallet metadata
|
|
59
|
+
*/
|
|
60
|
+
@Input() appName: string = 'HSuite Demo';
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* App description for wallet metadata
|
|
64
|
+
*/
|
|
65
|
+
@Input() appDescription: string = 'Multi-chain wallet connection';
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Wallet URL for targeting the wallet window
|
|
69
|
+
*/
|
|
70
|
+
@Input() walletUrl = DEFAULT_WALLET_URL;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Whether to show session information when connected
|
|
74
|
+
* @default true
|
|
75
|
+
*/
|
|
76
|
+
@Input() showSessionInfo = true;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Button color (Ionic color)
|
|
80
|
+
* @default 'primary'
|
|
81
|
+
*/
|
|
82
|
+
@Input() buttonColor: string = 'primary';
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Button size
|
|
86
|
+
* @default 'default'
|
|
87
|
+
*/
|
|
88
|
+
@Input() size: 'small' | 'default' | 'large' = 'default';
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Custom button text for connect state
|
|
92
|
+
*/
|
|
93
|
+
@Input() connectText = 'Connect Wallet';
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Custom button text for when wallets are connected (multi-session mode)
|
|
97
|
+
*/
|
|
98
|
+
@Input() connectedText = 'Add Another Wallet';
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Enable multi-session mode (allows multiple connections)
|
|
102
|
+
* @default true
|
|
103
|
+
*/
|
|
104
|
+
@Input() multiSessionMode = true;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Emitted when wallet successfully connects
|
|
108
|
+
*/
|
|
109
|
+
@Output() connected = new EventEmitter<unknown>();
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Emitted when wallet disconnects
|
|
113
|
+
*/
|
|
114
|
+
@Output() disconnected = new EventEmitter<void>();
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Emitted when connection fails
|
|
118
|
+
*/
|
|
119
|
+
@Output() error = new EventEmitter<Error>();
|
|
120
|
+
|
|
121
|
+
protected readonly wallet = inject(UnifiedWalletService);
|
|
122
|
+
protected readonly modalController = inject(ModalController);
|
|
123
|
+
|
|
124
|
+
protected isConnecting = false;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
*
|
|
128
|
+
*/
|
|
129
|
+
constructor() {
|
|
130
|
+
addIcons({ walletOutline, linkOutline, checkmarkCircleOutline });
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Connect to wallet (opens modal - supports multi-session)
|
|
135
|
+
*/
|
|
136
|
+
async connect(): Promise<void> {
|
|
137
|
+
if (this.isConnecting) return;
|
|
138
|
+
|
|
139
|
+
this.isConnecting = true;
|
|
140
|
+
try {
|
|
141
|
+
await this.openConnectionModal();
|
|
142
|
+
} catch (err) {
|
|
143
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
144
|
+
this.error.emit(error);
|
|
145
|
+
logger.error('Connection failed', { error: error.message });
|
|
146
|
+
} finally {
|
|
147
|
+
this.isConnecting = false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Open the new multi-protocol connection modal
|
|
153
|
+
* Passes wallet configuration including walletUrl and metadata for proper window targeting.
|
|
154
|
+
*/
|
|
155
|
+
private async openConnectionModal(): Promise<void> {
|
|
156
|
+
const modal = await this.modalController.create({
|
|
157
|
+
component: WalletConnectionModalComponent,
|
|
158
|
+
componentProps: {
|
|
159
|
+
projectId: this.walletConnectProjectId,
|
|
160
|
+
appName: this.appName,
|
|
161
|
+
appDescription: this.appDescription,
|
|
162
|
+
walletUrl: this.walletUrl,
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
await modal.present();
|
|
167
|
+
|
|
168
|
+
const { data } = await modal.onDidDismiss();
|
|
169
|
+
|
|
170
|
+
if (data?.connected) {
|
|
171
|
+
// Emit connected event with unified accounts
|
|
172
|
+
const accounts = this.wallet.allAccounts();
|
|
173
|
+
this.connected.emit({
|
|
174
|
+
protocol: data.protocol,
|
|
175
|
+
network: data.network,
|
|
176
|
+
accounts,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Disconnect from wallet
|
|
183
|
+
* In multi-session mode, this disconnects ALL sessions
|
|
184
|
+
*/
|
|
185
|
+
async disconnect(): Promise<void> {
|
|
186
|
+
try {
|
|
187
|
+
// Disconnect all sessions via UnifiedWalletService
|
|
188
|
+
await this.wallet.disconnectAll();
|
|
189
|
+
|
|
190
|
+
this.disconnected.emit();
|
|
191
|
+
} catch (err) {
|
|
192
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
193
|
+
this.error.emit(error);
|
|
194
|
+
logger.error('Disconnect failed', { error: error.message });
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Check if unknown wallet is connected
|
|
200
|
+
*/
|
|
201
|
+
isConnected(): boolean {
|
|
202
|
+
return this.wallet.isAnyConnected();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Get display text for connection state
|
|
207
|
+
*/
|
|
208
|
+
getButtonText(): string {
|
|
209
|
+
if (this.isConnecting) return 'Connecting...';
|
|
210
|
+
|
|
211
|
+
if (this.multiSessionMode) {
|
|
212
|
+
return this.isConnected() ? this.connectedText : this.connectText;
|
|
213
|
+
}
|
|
214
|
+
return this.isConnected() ? 'Disconnect' : this.connectText;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Get icon name for current state
|
|
219
|
+
*/
|
|
220
|
+
getIconName(): string {
|
|
221
|
+
if (this.isConnected()) return 'checkmark-circle-outline';
|
|
222
|
+
return 'wallet-outline';
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Truncate address for display
|
|
227
|
+
* @param address
|
|
228
|
+
*/
|
|
229
|
+
truncateAddress(address: string): string {
|
|
230
|
+
if (address.length <= 12) return address;
|
|
231
|
+
return `${address.substring(0, 6)}...${address.substring(address.length - 4)}`;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Get connected accounts (unified)
|
|
236
|
+
*/
|
|
237
|
+
getConnectedAccounts(): any[] {
|
|
238
|
+
return this.wallet.allAccounts();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<ion-card class="wallet-connect-prompt" [color]="cardColor">
|
|
2
|
+
<ion-card-header>
|
|
3
|
+
<div class="prompt-header">
|
|
4
|
+
<ion-icon *ngIf="showIcon" name="wallet-outline" class="prompt-icon"></ion-icon>
|
|
5
|
+
<div>
|
|
6
|
+
<ion-card-title>{{ title }}</ion-card-title>
|
|
7
|
+
<ion-card-subtitle *ngIf="subtitle">{{ subtitle }}</ion-card-subtitle>
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
</ion-card-header>
|
|
11
|
+
|
|
12
|
+
<ion-card-content>
|
|
13
|
+
<p class="prompt-message">{{ message }}</p>
|
|
14
|
+
|
|
15
|
+
<wallet-connect-button
|
|
16
|
+
[walletConnectProjectId]="walletConnectProjectId"
|
|
17
|
+
[connectText]="buttonText"
|
|
18
|
+
[size]="buttonSize"
|
|
19
|
+
[buttonColor]="buttonColor"
|
|
20
|
+
class="prompt-button"
|
|
21
|
+
/>
|
|
22
|
+
</ion-card-content>
|
|
23
|
+
</ion-card>
|
|
24
|
+
|