@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,154 @@
|
|
|
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
|
+
* @fileoverview Structural directive that provides unified wallet context to templates.
|
|
13
|
+
*
|
|
14
|
+
* @module directives/wallet-context
|
|
15
|
+
*
|
|
16
|
+
* @description
|
|
17
|
+
* WalletContextDirective is a structural directive that provides a unified wallet context
|
|
18
|
+
* to templates, eliminating the need to manually inject services and track multiple signals.
|
|
19
|
+
* It provides a single context variable with all wallet state.
|
|
20
|
+
*
|
|
21
|
+
* Unlike `*walletConnected`, this directive always renders its template and provides
|
|
22
|
+
* context regardless of connection status. Use this when you need access to wallet state
|
|
23
|
+
* but want to handle the connected/disconnected logic yourself.
|
|
24
|
+
*
|
|
25
|
+
* **Key Features:**
|
|
26
|
+
* - Provides complete wallet context (isConnected, accounts, sessions, providers)
|
|
27
|
+
* - Always renders (use *walletConnected for conditional rendering)
|
|
28
|
+
* - Automatically updates when any wallet state changes
|
|
29
|
+
* - Type-safe template context with full IDE support
|
|
30
|
+
*
|
|
31
|
+
* **Selector:** `*walletContext`
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import {
|
|
35
|
+
Directive,
|
|
36
|
+
TemplateRef,
|
|
37
|
+
ViewContainerRef,
|
|
38
|
+
inject,
|
|
39
|
+
effect,
|
|
40
|
+
EmbeddedViewRef,
|
|
41
|
+
} from '@angular/core';
|
|
42
|
+
import { WalletContextService } from '../services/wallet-context.service';
|
|
43
|
+
import type { WalletContext } from '../models/wallet-context.model';
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Context object passed to the template.
|
|
47
|
+
*
|
|
48
|
+
* @description
|
|
49
|
+
* Contains the wallet context that is exposed to the template when using
|
|
50
|
+
* the `*walletContext` structural directive. Both `$implicit` and
|
|
51
|
+
* `walletContext` contain the same context for flexible access.
|
|
52
|
+
*/
|
|
53
|
+
export class WalletContextDirectiveContext {
|
|
54
|
+
constructor(
|
|
55
|
+
public $implicit: WalletContext,
|
|
56
|
+
public walletContext: WalletContext,
|
|
57
|
+
) {}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Structural directive that provides unified wallet context.
|
|
62
|
+
*
|
|
63
|
+
* @directive WalletContextDirective
|
|
64
|
+
* @selector [walletContext]
|
|
65
|
+
*
|
|
66
|
+
* @description
|
|
67
|
+
* Automatically updates the view when wallet state changes, exposing a single
|
|
68
|
+
* `WalletContext` object with all wallet state. Unlike `*walletConnected`,
|
|
69
|
+
* this directive always renders its template.
|
|
70
|
+
*
|
|
71
|
+
* The directive uses Angular's effect() to reactively update the context
|
|
72
|
+
* whenever any underlying wallet state changes.
|
|
73
|
+
*
|
|
74
|
+
* @if (w.isConnected) {
|
|
75
|
+
* <account-selector [accounts]="w.allAccounts" />
|
|
76
|
+
* } @else {
|
|
77
|
+
* <wallet-connect-button />
|
|
78
|
+
* }
|
|
79
|
+
* </div>
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
@Directive({
|
|
83
|
+
selector: '[walletContext]',
|
|
84
|
+
standalone: true,
|
|
85
|
+
})
|
|
86
|
+
export class WalletContextDirective {
|
|
87
|
+
private readonly contextService = inject(WalletContextService);
|
|
88
|
+
private readonly templateRef = inject(TemplateRef<WalletContextDirectiveContext>);
|
|
89
|
+
private readonly viewContainer = inject(ViewContainerRef);
|
|
90
|
+
|
|
91
|
+
private viewRef: EmbeddedViewRef<WalletContextDirectiveContext> | null = null;
|
|
92
|
+
|
|
93
|
+
constructor() {
|
|
94
|
+
// Create the view immediately
|
|
95
|
+
this.createView();
|
|
96
|
+
|
|
97
|
+
// Update context reactively when wallet state changes
|
|
98
|
+
effect(() => {
|
|
99
|
+
const context = this.contextService.context();
|
|
100
|
+
this.updateContext(context);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Creates the embedded view with initial context.
|
|
106
|
+
*
|
|
107
|
+
* @description
|
|
108
|
+
* Called once during directive construction to create the view.
|
|
109
|
+
* The view is created immediately and then updated reactively.
|
|
110
|
+
*/
|
|
111
|
+
private createView(): void {
|
|
112
|
+
if (!this.viewRef) {
|
|
113
|
+
const initialContext = this.contextService.context();
|
|
114
|
+
const context = new WalletContextDirectiveContext(initialContext, initialContext);
|
|
115
|
+
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef, context);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Updates the context when wallet state changes.
|
|
121
|
+
*
|
|
122
|
+
* @description
|
|
123
|
+
* Called reactively by Angular's effect() whenever the wallet context
|
|
124
|
+
* signal changes. Updates both the implicit and named context properties.
|
|
125
|
+
*
|
|
126
|
+
* @param walletContext - The new wallet context
|
|
127
|
+
*/
|
|
128
|
+
private updateContext(walletContext: WalletContext): void {
|
|
129
|
+
if (this.viewRef) {
|
|
130
|
+
this.viewRef.context.$implicit = walletContext;
|
|
131
|
+
this.viewRef.context.walletContext = walletContext;
|
|
132
|
+
this.viewRef.markForCheck();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Static type guard for Angular template type checking.
|
|
138
|
+
*
|
|
139
|
+
* @description
|
|
140
|
+
* Enables TypeScript type inference in templates when using the directive.
|
|
141
|
+
* This allows the template to have proper types for the context variable.
|
|
142
|
+
*
|
|
143
|
+
* @param dir - The directive instance
|
|
144
|
+
* @param ctx - The context to type-guard
|
|
145
|
+
*
|
|
146
|
+
* @returns True, asserting that ctx is WalletContextDirectiveContext
|
|
147
|
+
*/
|
|
148
|
+
static ngTemplateContextGuard(
|
|
149
|
+
dir: WalletContextDirective,
|
|
150
|
+
ctx: any,
|
|
151
|
+
): ctx is WalletContextDirectiveContext {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
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
|
+
* @fileoverview Attribute directive for declarative wallet event subscriptions.
|
|
13
|
+
*
|
|
14
|
+
* @module directives/wallet-events
|
|
15
|
+
*
|
|
16
|
+
* @description
|
|
17
|
+
* WalletEventsDirective is an attribute directive that provides declarative event
|
|
18
|
+
* subscriptions for wallet lifecycle events. It automatically subscribes to wallet
|
|
19
|
+
* events and unsubscribes on directive destruction, eliminating manual subscription
|
|
20
|
+
* management boilerplate.
|
|
21
|
+
*
|
|
22
|
+
* **Key Features:**
|
|
23
|
+
* - Automatic subscription management (subscribe on init, unsubscribe on destroy)
|
|
24
|
+
* - All wallet events exposed as Angular @Output() bindings
|
|
25
|
+
* - Works with any element or component
|
|
26
|
+
* - Type-safe event payloads
|
|
27
|
+
*
|
|
28
|
+
* **Available Events:**
|
|
29
|
+
* - `connected` - Provider successfully connected
|
|
30
|
+
* - `disconnected` - Provider disconnected
|
|
31
|
+
* - `accountChanged` - Active account switched
|
|
32
|
+
* - `accountsUpdated` - Provider's account list changed
|
|
33
|
+
* - `sessionCreated` - New session established
|
|
34
|
+
* - `sessionDeleted` - Session terminated
|
|
35
|
+
* - `sessionRestored` - Session restored from storage
|
|
36
|
+
* - `providerStatusChanged` - Provider status changed
|
|
37
|
+
* - `providerError` - Provider encountered an error
|
|
38
|
+
*
|
|
39
|
+
* **Selector:** `[walletEvents]`
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
import { Directive, Output, EventEmitter, inject, OnDestroy } from '@angular/core';
|
|
43
|
+
import { Subscription } from 'rxjs';
|
|
44
|
+
import { WalletEventBus } from '../services/wallet-event-bus.service';
|
|
45
|
+
import type {
|
|
46
|
+
ConnectionEvent,
|
|
47
|
+
DisconnectionEvent,
|
|
48
|
+
AccountChangeEvent,
|
|
49
|
+
AccountsUpdateEvent,
|
|
50
|
+
SessionEvent,
|
|
51
|
+
ProviderStatusEvent,
|
|
52
|
+
ProviderErrorEvent,
|
|
53
|
+
} from '../models/wallet-events.model';
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Attribute directive that provides declarative event subscriptions.
|
|
57
|
+
*
|
|
58
|
+
* @directive WalletEventsDirective
|
|
59
|
+
* @selector [walletEvents]
|
|
60
|
+
*
|
|
61
|
+
* @description
|
|
62
|
+
* Automatically manages subscriptions and cleanup - no manual ngOnDestroy needed.
|
|
63
|
+
* Simply declare which events you want to handle in your template using Angular's
|
|
64
|
+
* output binding syntax.
|
|
65
|
+
*
|
|
66
|
+
* All subscriptions are collected in a single Subscription object and cleaned up
|
|
67
|
+
* together when the directive is destroyed.
|
|
68
|
+
*
|
|
69
|
+
* @Component({
|
|
70
|
+
* template: `
|
|
71
|
+
* <div walletEvents
|
|
72
|
+
* (disconnected)="handleDisconnect($event)"
|
|
73
|
+
* (providerError)="handleError($event)">
|
|
74
|
+
* </div>
|
|
75
|
+
* `
|
|
76
|
+
* })
|
|
77
|
+
* export class MyComponent {
|
|
78
|
+
* handleDisconnect(event: DisconnectionEvent) {
|
|
79
|
+
* if (event.reason === 'wallet_initiated_disconnect') {
|
|
80
|
+
* this.toast.warning('Wallet disconnected by remote');
|
|
81
|
+
* }
|
|
82
|
+
* }
|
|
83
|
+
*
|
|
84
|
+
* handleError(event: ProviderErrorEvent) {
|
|
85
|
+
* this.toast.error('Error: ' + event.error);
|
|
86
|
+
* }
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
@Directive({
|
|
91
|
+
selector: '[walletEvents]',
|
|
92
|
+
standalone: true,
|
|
93
|
+
})
|
|
94
|
+
export class WalletEventsDirective implements OnDestroy {
|
|
95
|
+
private readonly eventBus = inject(WalletEventBus);
|
|
96
|
+
private readonly subscriptions = new Subscription();
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Emitted when a provider successfully connects.
|
|
100
|
+
*
|
|
101
|
+
* @description
|
|
102
|
+
* Fired after a wallet connection is established. The event includes
|
|
103
|
+
* the provider ID, type, and the list of accounts that are now available.
|
|
104
|
+
*/
|
|
105
|
+
@Output() connected = new EventEmitter<ConnectionEvent>();
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Emitted when a provider disconnects.
|
|
109
|
+
*
|
|
110
|
+
* @description
|
|
111
|
+
* Fired when a wallet connection is terminated. The event includes
|
|
112
|
+
* the reason for disconnection (user-initiated, wallet-initiated, expired).
|
|
113
|
+
*/
|
|
114
|
+
@Output() disconnected = new EventEmitter<DisconnectionEvent>();
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Emitted when the active account changes.
|
|
118
|
+
*
|
|
119
|
+
* @description
|
|
120
|
+
* Fired when the user switches between accounts. Includes both the
|
|
121
|
+
* previous account and the newly selected account.
|
|
122
|
+
*/
|
|
123
|
+
@Output() accountChanged = new EventEmitter<AccountChangeEvent>();
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Emitted when a provider's account list updates.
|
|
127
|
+
*
|
|
128
|
+
* @description
|
|
129
|
+
* Fired when accounts are added or removed from a provider. Includes
|
|
130
|
+
* the updated account list and total count.
|
|
131
|
+
*/
|
|
132
|
+
@Output() accountsUpdated = new EventEmitter<AccountsUpdateEvent>();
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Emitted when a new session is created.
|
|
136
|
+
*
|
|
137
|
+
* @description
|
|
138
|
+
* Fired when a new wallet session is established. Includes session
|
|
139
|
+
* key, accounts, and metadata.
|
|
140
|
+
*/
|
|
141
|
+
@Output() sessionCreated = new EventEmitter<SessionEvent>();
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Emitted when a session is deleted.
|
|
145
|
+
*
|
|
146
|
+
* @description
|
|
147
|
+
* Fired when a wallet session is terminated. Includes session key
|
|
148
|
+
* and optional reason metadata.
|
|
149
|
+
*/
|
|
150
|
+
@Output() sessionDeleted = new EventEmitter<SessionEvent>();
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Emitted when a session is restored from storage.
|
|
154
|
+
*
|
|
155
|
+
* @description
|
|
156
|
+
* Fired when a previously saved session is restored (e.g., after page reload).
|
|
157
|
+
* Includes the restored accounts and session metadata.
|
|
158
|
+
*/
|
|
159
|
+
@Output() sessionRestored = new EventEmitter<SessionEvent>();
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Emitted when a provider's status changes.
|
|
163
|
+
*
|
|
164
|
+
* @description
|
|
165
|
+
* Fired when a provider transitions between states (connecting, connected,
|
|
166
|
+
* disconnected, error).
|
|
167
|
+
*/
|
|
168
|
+
@Output() providerStatusChanged = new EventEmitter<ProviderStatusEvent>();
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Emitted when a provider encounters an error.
|
|
172
|
+
*
|
|
173
|
+
* @description
|
|
174
|
+
* Fired when a wallet operation fails. Includes the error message
|
|
175
|
+
* and optional context about what operation failed.
|
|
176
|
+
*/
|
|
177
|
+
@Output() providerError = new EventEmitter<ProviderErrorEvent>();
|
|
178
|
+
|
|
179
|
+
constructor() {
|
|
180
|
+
// Auto-subscribe to all events and forward to outputs
|
|
181
|
+
// Subscriptions are automatically cleaned up in ngOnDestroy
|
|
182
|
+
|
|
183
|
+
this.subscriptions.add(
|
|
184
|
+
this.eventBus.connected.subscribe((event) => this.connected.emit(event)),
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
this.subscriptions.add(
|
|
188
|
+
this.eventBus.disconnected.subscribe((event) => this.disconnected.emit(event)),
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
this.subscriptions.add(
|
|
192
|
+
this.eventBus.accountChanged.subscribe((event) => this.accountChanged.emit(event)),
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
this.subscriptions.add(
|
|
196
|
+
this.eventBus.accountsUpdated.subscribe((event) => this.accountsUpdated.emit(event)),
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
this.subscriptions.add(
|
|
200
|
+
this.eventBus.sessionCreated.subscribe((event) => this.sessionCreated.emit(event)),
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
this.subscriptions.add(
|
|
204
|
+
this.eventBus.sessionDeleted.subscribe((event) => this.sessionDeleted.emit(event)),
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
this.subscriptions.add(
|
|
208
|
+
this.eventBus.sessionRestored.subscribe((event) => this.sessionRestored.emit(event)),
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
this.subscriptions.add(
|
|
212
|
+
this.eventBus.providerStatusChanged.subscribe((event) =>
|
|
213
|
+
this.providerStatusChanged.emit(event),
|
|
214
|
+
),
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
this.subscriptions.add(
|
|
218
|
+
this.eventBus.providerError.subscribe((event) => this.providerError.emit(event)),
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Cleans up all subscriptions on directive destruction.
|
|
224
|
+
*
|
|
225
|
+
* @description
|
|
226
|
+
* Called automatically by Angular when the directive is destroyed.
|
|
227
|
+
* Unsubscribes from all wallet events to prevent memory leaks.
|
|
228
|
+
*/
|
|
229
|
+
ngOnDestroy(): void {
|
|
230
|
+
this.subscriptions.unsubscribe();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
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 NgModule wrapper for HSuite Wallet Angular SDK.
|
|
13
|
+
*
|
|
14
|
+
* @module HsuiteWalletModule
|
|
15
|
+
*
|
|
16
|
+
* @description
|
|
17
|
+
* Provides a traditional NgModule for module-based Angular/Ionic applications.
|
|
18
|
+
* All components internally use @ionic/angular/standalone imports but are re-exported
|
|
19
|
+
* through this module for compatibility with module-based apps.
|
|
20
|
+
*
|
|
21
|
+
* **When to Use This Module:**
|
|
22
|
+
* - Your Angular application uses NgModule-based architecture
|
|
23
|
+
* - You're migrating an existing Ionic/Angular app to use wallet features
|
|
24
|
+
* - You prefer importing a single module over individual components
|
|
25
|
+
*
|
|
26
|
+
* **When to Use Standalone Components Instead:**
|
|
27
|
+
* - New Angular 17+ applications using standalone components
|
|
28
|
+
* - You only need a few components and want tree-shaking benefits
|
|
29
|
+
* - Following modern Angular best practices
|
|
30
|
+
*
|
|
31
|
+
* **Included Components:**
|
|
32
|
+
* - WalletConnectButtonComponent - Ready-to-use connection button
|
|
33
|
+
* - WalletSessionDisplayComponent - Session information display
|
|
34
|
+
* - WalletTransactionStatusComponent - Transaction status indicator
|
|
35
|
+
* - AccountSelectorComponent - Multi-account dropdown
|
|
36
|
+
* - WalletAccountDisplayComponent - Account details display
|
|
37
|
+
* - WalletConnectPromptComponent - Connection prompt UI
|
|
38
|
+
* - WalletConnectedGuardComponent - Protected route guard
|
|
39
|
+
* - WalletConnectionModalComponent - Multi-protocol connection modal
|
|
40
|
+
*
|
|
41
|
+
* **Included Directives:**
|
|
42
|
+
* - WalletContextDirective (*walletContext) - Unified context access
|
|
43
|
+
* - WalletConnectedDirective (*walletConnected) - Conditional rendering
|
|
44
|
+
* - WalletEventsDirective (walletEvents) - Event subscriptions
|
|
45
|
+
*
|
|
46
|
+
* **Note:** Services (UnifiedWalletService, WalletEventBus, etc.) are NOT provided
|
|
47
|
+
* by this module because they use `providedIn: 'root'`. They're automatically
|
|
48
|
+
* available throughout your application.
|
|
49
|
+
*
|
|
50
|
+
* @NgModule({
|
|
51
|
+
* imports: [HsuiteWalletModule],
|
|
52
|
+
* })
|
|
53
|
+
* export class AppModule {}
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @Component({
|
|
57
|
+
* standalone: true,
|
|
58
|
+
* imports: [WalletConnectButtonComponent],
|
|
59
|
+
* })
|
|
60
|
+
* export class MyComponent {}
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
import { CommonModule } from '@angular/common';
|
|
65
|
+
import { NgModule } from '@angular/core';
|
|
66
|
+
import { IonicModule } from '@ionic/angular';
|
|
67
|
+
|
|
68
|
+
// Components
|
|
69
|
+
import { AccountActionsComponent } from './components/account-selector/account-actions/account-actions.component';
|
|
70
|
+
import { AccountFilterComponent } from './components/account-selector/account-filter/account-filter.component';
|
|
71
|
+
import { AccountListComponent } from './components/account-selector/account-list/account-list.component';
|
|
72
|
+
import { AccountSelectorComponent } from './components/account-selector/account-selector.component';
|
|
73
|
+
import { WalletAccountDisplayComponent } from './components/wallet-account-display/wallet-account-display.component';
|
|
74
|
+
import { WalletConnectButtonComponent } from './components/wallet-connect-button/wallet-connect-button.component';
|
|
75
|
+
import { WalletConnectPromptComponent } from './components/wallet-connect-prompt/wallet-connect-prompt.component';
|
|
76
|
+
import { WalletConnectedGuardComponent } from './components/wallet-connected-guard/wallet-connected-guard.component';
|
|
77
|
+
import { WalletConnectionModalComponent } from './components/wallet-connection-modal/wallet-connection-modal.component';
|
|
78
|
+
import { WalletSessionDisplayComponent } from './components/wallet-session-display/wallet-session-display.component';
|
|
79
|
+
import { WalletTransactionStatusComponent } from './components/wallet-transaction-status/wallet-transaction-status.component';
|
|
80
|
+
|
|
81
|
+
// Directives
|
|
82
|
+
import { WalletConnectedDirective } from './directives/wallet-connected.directive';
|
|
83
|
+
import { WalletContextDirective } from './directives/wallet-context.directive';
|
|
84
|
+
import { WalletEventsDirective } from './directives/wallet-events.directive';
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @module HsuiteWalletModule
|
|
88
|
+
*
|
|
89
|
+
* NgModule wrapper for HSuite Wallet Angular SDK components, directives, and services.
|
|
90
|
+
*
|
|
91
|
+
* **What's Included:**
|
|
92
|
+
*
|
|
93
|
+
* **Components:**
|
|
94
|
+
* - `WalletConnectButtonComponent` - Ready-to-use wallet connection button
|
|
95
|
+
* - `WalletSessionDisplayComponent` - Display connected session information
|
|
96
|
+
* - `WalletTransactionStatusComponent` - Transaction status indicator
|
|
97
|
+
* - `AccountSelectorComponent` - Multi-account dropdown selector
|
|
98
|
+
* - `WalletAccountDisplayComponent` - Display account details
|
|
99
|
+
* - `WalletConnectPromptComponent` - Connection prompt UI
|
|
100
|
+
* - `WalletConnectedGuardComponent` - Guard component for protected routes
|
|
101
|
+
* - `WalletConnectionModalComponent` - Multi-protocol connection modal
|
|
102
|
+
*
|
|
103
|
+
* **Directives:**
|
|
104
|
+
* - `WalletContextDirective` (*walletContext) - Structural directive for wallet context
|
|
105
|
+
* - `WalletConnectedDirective` (*walletConnected) - Conditional rendering based on connection
|
|
106
|
+
* - `WalletEventsDirective` (walletEvents) - Listen to wallet events
|
|
107
|
+
*
|
|
108
|
+
* **Services:**
|
|
109
|
+
* - `UnifiedWalletService` - Multi-protocol wallet service (recommended)
|
|
110
|
+
* - `WalletEventBus` - Event system for wallet lifecycle
|
|
111
|
+
* - `WalletContextService` - Centralized wallet context
|
|
112
|
+
* - `TransactionService` - Transaction helper utilities
|
|
113
|
+
*
|
|
114
|
+
* **Usage:**
|
|
115
|
+
*
|
|
116
|
+
* Import this module in your app's main module:
|
|
117
|
+
*
|
|
118
|
+
* ```typescript
|
|
119
|
+
* import { NgModule } from '@angular/core';
|
|
120
|
+
* import { BrowserModule } from '@angular/platform-browser';
|
|
121
|
+
* import { IonicModule } from '@ionic/angular';
|
|
122
|
+
* import { HsuiteWalletModule } from '@hsuite/native-connect-angular';
|
|
123
|
+
* import { AppComponent } from './app.component';
|
|
124
|
+
*
|
|
125
|
+
* @NgModule({
|
|
126
|
+
* declarations: [AppComponent],
|
|
127
|
+
* imports: [
|
|
128
|
+
* BrowserModule,
|
|
129
|
+
* IonicModule.forRoot(),
|
|
130
|
+
* HsuiteWalletModule, // Add this
|
|
131
|
+
* ],
|
|
132
|
+
* bootstrap: [AppComponent],
|
|
133
|
+
* })
|
|
134
|
+
* export class AppModule {}
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* Then use components in your templates:
|
|
138
|
+
*
|
|
139
|
+
* ```html
|
|
140
|
+
* <wallet-connect-button
|
|
141
|
+
* [walletConnectProjectId]="'YOUR_PROJECT_ID'"
|
|
142
|
+
* [showSessionInfo]="true">
|
|
143
|
+
* </wallet-connect-button>
|
|
144
|
+
*
|
|
145
|
+
* <wallet-session-display></wallet-session-display>
|
|
146
|
+
*
|
|
147
|
+
* <wallet-account-selector
|
|
148
|
+
* [selectedAddress]="currentAccount"
|
|
149
|
+
* (accountChanged)="onAccountChange($event)">
|
|
150
|
+
* </wallet-account-selector>
|
|
151
|
+
* ```
|
|
152
|
+
*
|
|
153
|
+
* **Note:** This module is designed for module-based Angular apps. If you're using
|
|
154
|
+
* Angular standalone components (recommended for new projects), you can import
|
|
155
|
+
* components individually instead:
|
|
156
|
+
*
|
|
157
|
+
* ```typescript
|
|
158
|
+
* import { WalletConnectButtonComponent } from '@hsuite/native-connect-angular';
|
|
159
|
+
*
|
|
160
|
+
* @Component({
|
|
161
|
+
* standalone: true,
|
|
162
|
+
* imports: [WalletConnectButtonComponent],
|
|
163
|
+
* // ...
|
|
164
|
+
* })
|
|
165
|
+
* export class MyComponent {}
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
@NgModule({
|
|
169
|
+
imports: [
|
|
170
|
+
CommonModule,
|
|
171
|
+
IonicModule,
|
|
172
|
+
// Import all standalone components
|
|
173
|
+
WalletConnectButtonComponent,
|
|
174
|
+
WalletSessionDisplayComponent,
|
|
175
|
+
WalletTransactionStatusComponent,
|
|
176
|
+
AccountSelectorComponent,
|
|
177
|
+
AccountListComponent,
|
|
178
|
+
AccountFilterComponent,
|
|
179
|
+
AccountActionsComponent,
|
|
180
|
+
WalletAccountDisplayComponent,
|
|
181
|
+
WalletConnectPromptComponent,
|
|
182
|
+
WalletConnectedGuardComponent,
|
|
183
|
+
WalletConnectionModalComponent,
|
|
184
|
+
// Import all standalone directives
|
|
185
|
+
WalletContextDirective,
|
|
186
|
+
WalletConnectedDirective,
|
|
187
|
+
WalletEventsDirective,
|
|
188
|
+
],
|
|
189
|
+
exports: [
|
|
190
|
+
// Export all components for use in module-based apps
|
|
191
|
+
WalletConnectButtonComponent,
|
|
192
|
+
WalletSessionDisplayComponent,
|
|
193
|
+
WalletTransactionStatusComponent,
|
|
194
|
+
AccountSelectorComponent,
|
|
195
|
+
AccountListComponent,
|
|
196
|
+
AccountFilterComponent,
|
|
197
|
+
AccountActionsComponent,
|
|
198
|
+
WalletAccountDisplayComponent,
|
|
199
|
+
WalletConnectPromptComponent,
|
|
200
|
+
WalletConnectedGuardComponent,
|
|
201
|
+
WalletConnectionModalComponent,
|
|
202
|
+
// Export all directives
|
|
203
|
+
WalletContextDirective,
|
|
204
|
+
WalletConnectedDirective,
|
|
205
|
+
WalletEventsDirective,
|
|
206
|
+
],
|
|
207
|
+
// NOTE: Services are NOT provided here because they already have providedIn: 'root'
|
|
208
|
+
// Providing them here would cause a double-provider error
|
|
209
|
+
})
|
|
210
|
+
export class HsuiteWalletModule {}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
* @fileoverview Configuration models for different connection protocols.
|
|
13
|
+
*
|
|
14
|
+
* @module models/connection-config
|
|
15
|
+
*
|
|
16
|
+
* @description
|
|
17
|
+
* Defines configuration types and type guards for wallet connection protocols.
|
|
18
|
+
* Each provider type has its own configuration interface with protocol-specific
|
|
19
|
+
* options. The ConnectionConfig union type allows type-safe handling of
|
|
20
|
+
* different provider configurations.
|
|
21
|
+
*
|
|
22
|
+
* **Configuration Types:**
|
|
23
|
+
* - {@link HsuiteNativeConfig} - HSuite Native Connect protocol
|
|
24
|
+
* - {@link WalletConnectV2Config} - WalletConnect v2 protocol
|
|
25
|
+
* - {@link MobileNativeConfig} - P2P Native mobile connections
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import type { HsuiteNativeConfig, WalletConnectV2Config } from './provider-types';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Union type of all connection configurations.
|
|
32
|
+
*
|
|
33
|
+
* @description
|
|
34
|
+
* Represents any valid connection configuration for the supported wallet providers.
|
|
35
|
+
* Use type guards to narrow to specific config types when needed.
|
|
36
|
+
*/
|
|
37
|
+
export type ConnectionConfig = HsuiteNativeConfig | WalletConnectV2Config;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Type guard for HSuite Native configuration.
|
|
41
|
+
*
|
|
42
|
+
* @description
|
|
43
|
+
* Narrows a ConnectionConfig to HsuiteNativeConfig based on the type property.
|
|
44
|
+
*
|
|
45
|
+
* @param config - Configuration to check
|
|
46
|
+
*
|
|
47
|
+
* @returns True if config is HsuiteNativeConfig
|
|
48
|
+
*/
|
|
49
|
+
export function isHsuiteNativeConfig(config: ConnectionConfig): config is HsuiteNativeConfig {
|
|
50
|
+
return config.type === 'hsuite-native';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Type guard for WalletConnect v2 configuration.
|
|
55
|
+
*
|
|
56
|
+
* @description
|
|
57
|
+
* Narrows a ConnectionConfig to WalletConnectV2Config based on the type property.
|
|
58
|
+
*
|
|
59
|
+
* @param config - Configuration to check
|
|
60
|
+
*
|
|
61
|
+
* @returns True if config is WalletConnectV2Config
|
|
62
|
+
*/
|
|
63
|
+
export function isWalletConnectV2Config(config: ConnectionConfig): config is WalletConnectV2Config {
|
|
64
|
+
return config.type === 'walletconnect-v2';
|
|
65
|
+
}
|