@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,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Type definitions for wallet connection providers.
|
|
3
|
+
*
|
|
4
|
+
* @module models/provider-types
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* Defines the core type definitions used throughout the Angular SDK for wallet
|
|
8
|
+
* provider management. Includes provider types, connection status, metadata
|
|
9
|
+
* interfaces, and configuration interfaces for each supported protocol.
|
|
10
|
+
*
|
|
11
|
+
* **Provider Types:**
|
|
12
|
+
* - `hsuite-native` - HSuite Native Connect protocol
|
|
13
|
+
* - `walletconnect-v2` - WalletConnect v2 protocol
|
|
14
|
+
* - `mobile-native` - P2P Native mobile connections
|
|
15
|
+
*
|
|
16
|
+
* **Connection Status Lifecycle:**
|
|
17
|
+
* ```
|
|
18
|
+
* idle -> connecting -> connected -> disconnecting -> disconnected
|
|
19
|
+
* \-> error
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Supported wallet connection protocol types.
|
|
25
|
+
*
|
|
26
|
+
* @description
|
|
27
|
+
* Identifies the wallet connection protocol used by a provider.
|
|
28
|
+
* Each type has different capabilities and configuration requirements.
|
|
29
|
+
*
|
|
30
|
+
* - `hsuite-native` - Direct HSuite wallet connections via Nostr/WebRTC
|
|
31
|
+
* - `walletconnect-v2` - WalletConnect v2 protocol for mobile wallets
|
|
32
|
+
* - `mobile-native` - Direct P2P connections to mobile wallets
|
|
33
|
+
*/
|
|
34
|
+
export type ProviderType = 'hsuite-native' | 'walletconnect-v2' | 'mobile-native';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Connection status for a provider.
|
|
38
|
+
*
|
|
39
|
+
* @description
|
|
40
|
+
* Tracks the lifecycle state of a wallet connection. UI components can
|
|
41
|
+
* use this to show appropriate feedback (loading spinners, error messages, etc.).
|
|
42
|
+
*
|
|
43
|
+
* **Status Values:**
|
|
44
|
+
* - `idle` - Not connected, no connection attempt in progress
|
|
45
|
+
* - `connecting` - Connection attempt in progress
|
|
46
|
+
* - `connected` - Successfully connected to wallet
|
|
47
|
+
* - `disconnecting` - Disconnection in progress
|
|
48
|
+
* - `disconnected` - Previously connected, now disconnected
|
|
49
|
+
* - `error` - Connection failed
|
|
50
|
+
*/
|
|
51
|
+
export type ConnectionStatus =
|
|
52
|
+
| 'idle'
|
|
53
|
+
| 'connecting'
|
|
54
|
+
| 'connected'
|
|
55
|
+
| 'disconnecting'
|
|
56
|
+
| 'disconnected'
|
|
57
|
+
| 'error';
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Provider metadata for display purposes.
|
|
61
|
+
*
|
|
62
|
+
* @description
|
|
63
|
+
* Contains display information about a wallet provider, used by UI components
|
|
64
|
+
* to show provider information in connection dialogs and account selectors.
|
|
65
|
+
*/
|
|
66
|
+
export interface ProviderMetadata {
|
|
67
|
+
id?: string;
|
|
68
|
+
name: string;
|
|
69
|
+
type: ProviderType;
|
|
70
|
+
description: string;
|
|
71
|
+
iconUrl?: string;
|
|
72
|
+
icon?: string;
|
|
73
|
+
supportsMultipleAccounts?: boolean;
|
|
74
|
+
features?: string[];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Production HSuite Wallet URL.
|
|
79
|
+
*
|
|
80
|
+
* @description
|
|
81
|
+
* Single source of truth for the wallet origin the SDK targets when a consuming
|
|
82
|
+
* dApp does not supply its own `walletUrl`. Point local development at a dev
|
|
83
|
+
* server by passing an explicit `walletUrl` (e.g. `http://localhost:8100`) on the
|
|
84
|
+
* connection config or UI component; the SDK default must stay production-safe so
|
|
85
|
+
* published dApps never open the wallet on localhost.
|
|
86
|
+
*/
|
|
87
|
+
export const DEFAULT_WALLET_URL = 'https://wallet.hsuite.app';
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* HSuite Native Connect configuration.
|
|
91
|
+
*
|
|
92
|
+
* @description
|
|
93
|
+
* Configuration for connecting via the HSuite Native protocol. This protocol
|
|
94
|
+
* uses Nostr for discovery and WebRTC for direct P2P communication.
|
|
95
|
+
*
|
|
96
|
+
* **Required Fields:**
|
|
97
|
+
* - `type` - Must be 'hsuite-native'
|
|
98
|
+
* - `appId` - Unique identifier for your dApp
|
|
99
|
+
* - `appName` - Display name for your dApp
|
|
100
|
+
* - `ledgerId` - Target blockchain ('hedera' or 'xrpl')
|
|
101
|
+
* - `networkId` - Target network (e.g., 'testnet', 'mainnet')
|
|
102
|
+
*/
|
|
103
|
+
export interface HsuiteNativeConfig {
|
|
104
|
+
type: 'hsuite-native';
|
|
105
|
+
appId: string;
|
|
106
|
+
appName: string;
|
|
107
|
+
ledgerId: string;
|
|
108
|
+
networkId: string;
|
|
109
|
+
appUrl?: string;
|
|
110
|
+
appIconUrl?: string;
|
|
111
|
+
/** Wallet origin to open. Defaults to {@link DEFAULT_WALLET_URL} (production); set to a dev server for local testing. */
|
|
112
|
+
walletUrl?: string;
|
|
113
|
+
metadata?: Record<string, unknown>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* WalletConnect v2 configuration.
|
|
118
|
+
*
|
|
119
|
+
* @description
|
|
120
|
+
* Configuration for connecting via WalletConnect v2 protocol. Requires a
|
|
121
|
+
* WalletConnect Cloud project ID obtained from https://cloud.walletconnect.com.
|
|
122
|
+
*
|
|
123
|
+
* **Required Fields:**
|
|
124
|
+
* - `type` - Must be 'walletconnect-v2'
|
|
125
|
+
* - `projectId` - WalletConnect Cloud project ID
|
|
126
|
+
* - `ledgerId` - Target blockchain ('hedera' or 'xrpl')
|
|
127
|
+
* - `networkId` - Target network (e.g., 'hedera:testnet')
|
|
128
|
+
*/
|
|
129
|
+
export interface WalletConnectV2Config {
|
|
130
|
+
type: 'walletconnect-v2';
|
|
131
|
+
projectId: string; // WalletConnect Cloud project ID - REQUIRED
|
|
132
|
+
ledgerId: 'hedera' | 'xrpl'; // Which ledger to connect to
|
|
133
|
+
networkId: string; // e.g., 'hedera:testnet' or 'xrpl:testnet'
|
|
134
|
+
appName?: string;
|
|
135
|
+
appDescription?: string;
|
|
136
|
+
appIconUrl?: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Mobile Native P2P configuration.
|
|
141
|
+
*
|
|
142
|
+
* @description
|
|
143
|
+
* Configuration for direct P2P connections to mobile wallets. This protocol
|
|
144
|
+
* bypasses relay servers for direct device-to-device communication.
|
|
145
|
+
*
|
|
146
|
+
* All fields are optional as the P2P provider can operate with defaults.
|
|
147
|
+
*/
|
|
148
|
+
export interface MobileNativeConfig {
|
|
149
|
+
type: 'mobile-native';
|
|
150
|
+
appId?: string;
|
|
151
|
+
appName?: string;
|
|
152
|
+
ledgerId?: string;
|
|
153
|
+
networkId?: string;
|
|
154
|
+
metadata?: Record<string, unknown>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Union type of all connection configurations.
|
|
159
|
+
*
|
|
160
|
+
* @description
|
|
161
|
+
* Represents any valid connection configuration for the supported wallet providers.
|
|
162
|
+
* Use type guards from connection-config.model.ts to narrow to specific config types.
|
|
163
|
+
*/
|
|
164
|
+
export type ConnectionConfig = HsuiteNativeConfig | WalletConnectV2Config | MobileNativeConfig;
|
|
@@ -0,0 +1,76 @@
|
|
|
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 Unified account model that works across all wallet providers.
|
|
13
|
+
*
|
|
14
|
+
* @module models/unified-account
|
|
15
|
+
*
|
|
16
|
+
* @description
|
|
17
|
+
* Defines the UnifiedAccount interface that provides a consistent representation
|
|
18
|
+
* of blockchain accounts regardless of the underlying wallet provider or ledger type.
|
|
19
|
+
* This normalization allows dApps to work with accounts uniformly whether they come
|
|
20
|
+
* from HSuite Native, WalletConnect, or P2P Native connections.
|
|
21
|
+
*
|
|
22
|
+
* **Key Properties:**
|
|
23
|
+
* - `id` - Unique identifier combining provider and address
|
|
24
|
+
* - `address` - Blockchain-specific account identifier
|
|
25
|
+
* - `ledgerId` - Which blockchain ('hedera', 'xrpl')
|
|
26
|
+
* - `networkId` - Which network ('testnet', 'mainnet')
|
|
27
|
+
* - `providerId` - Which provider manages this account
|
|
28
|
+
* - `metadata` - Provider-specific additional data
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import type { ProviderType } from './provider-types';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Unified account representation across all wallet providers.
|
|
35
|
+
*
|
|
36
|
+
* @description
|
|
37
|
+
* A normalized account interface that provides consistent access to account
|
|
38
|
+
* properties regardless of the underlying wallet type. All connected accounts
|
|
39
|
+
* from all providers are represented using this interface.
|
|
40
|
+
*/
|
|
41
|
+
export interface UnifiedAccount {
|
|
42
|
+
/** Unique identifier for this account */
|
|
43
|
+
id: string;
|
|
44
|
+
|
|
45
|
+
/** Account address/public key */
|
|
46
|
+
address: string;
|
|
47
|
+
|
|
48
|
+
/** Human-readable label */
|
|
49
|
+
label?: string;
|
|
50
|
+
|
|
51
|
+
/** Ledger ID (e.g., 'hedera', 'xrpl') */
|
|
52
|
+
ledgerId: string;
|
|
53
|
+
|
|
54
|
+
/** Network ID (e.g., 'hedera:testnet', 'xrpl:mainnet') */
|
|
55
|
+
networkId: string;
|
|
56
|
+
|
|
57
|
+
/** Provider that manages this account */
|
|
58
|
+
providerId: string;
|
|
59
|
+
providerType: ProviderType;
|
|
60
|
+
|
|
61
|
+
/** Optional metadata from the provider */
|
|
62
|
+
metadata?: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Account with balance information.
|
|
67
|
+
*
|
|
68
|
+
* @description
|
|
69
|
+
* Extension of UnifiedAccount that includes balance data for display purposes.
|
|
70
|
+
* Used by UI components that need to show account balances.
|
|
71
|
+
*/
|
|
72
|
+
export interface AccountWithBalance extends UnifiedAccount {
|
|
73
|
+
balance?: string;
|
|
74
|
+
balanceFormatted?: string;
|
|
75
|
+
currencySymbol?: string;
|
|
76
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
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 Unified wallet context model for declarative state access.
|
|
13
|
+
*
|
|
14
|
+
* @module models/wallet-context
|
|
15
|
+
*
|
|
16
|
+
* @description
|
|
17
|
+
* Defines the WalletContext interface that provides a single, cohesive interface
|
|
18
|
+
* for all wallet state. This model eliminates the need to manually track multiple
|
|
19
|
+
* signals across different services by aggregating all wallet information.
|
|
20
|
+
*
|
|
21
|
+
* The WalletContext is the primary data structure used by:
|
|
22
|
+
* - {@link WalletContextService} to compute and expose wallet state
|
|
23
|
+
* - {@link WalletContextDirective} to provide context to templates
|
|
24
|
+
* - {@link WalletConnectedDirective} for conditional rendering
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import type { UnifiedAccount } from './unified-account.model';
|
|
28
|
+
import type { BaseWalletProvider } from '../providers/base-wallet-provider';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Unified wallet context interface.
|
|
32
|
+
*
|
|
33
|
+
* @description
|
|
34
|
+
* Aggregates all wallet state into a single, reactive context object.
|
|
35
|
+
* Used by `*walletContext` and `*walletConnected` directives to provide
|
|
36
|
+
* declarative state access in templates.
|
|
37
|
+
*
|
|
38
|
+
* **Properties:**
|
|
39
|
+
* - `isConnected` - True if any account is available
|
|
40
|
+
* - `activeAccount` - Currently selected account (null if none)
|
|
41
|
+
* - `allAccounts` - All accounts from all providers
|
|
42
|
+
* - `sessions` - Active sessions with metadata
|
|
43
|
+
* - `providers` - All registered providers
|
|
44
|
+
* - `connectedProviders` - Only providers with active connections
|
|
45
|
+
*/
|
|
46
|
+
export interface WalletContext {
|
|
47
|
+
/**
|
|
48
|
+
* Whether unknown wallet provider is currently connected
|
|
49
|
+
*/
|
|
50
|
+
isConnected: boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The currently active account across all providers
|
|
54
|
+
* Null if no account is selected
|
|
55
|
+
*/
|
|
56
|
+
activeAccount: UnifiedAccount | null;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* All accounts from all connected providers
|
|
60
|
+
* Empty array if no providers are connected
|
|
61
|
+
*/
|
|
62
|
+
allAccounts: UnifiedAccount[];
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* All active sessions across providers
|
|
66
|
+
* For HSuite Native: single session with multiple accounts
|
|
67
|
+
* For WalletConnect: multiple sessions, one per wallet
|
|
68
|
+
*/
|
|
69
|
+
sessions: WalletSession[];
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* All registered wallet providers
|
|
73
|
+
* Includes both connected and disconnected providers
|
|
74
|
+
*/
|
|
75
|
+
providers: BaseWalletProvider[];
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Only the currently connected providers
|
|
79
|
+
*/
|
|
80
|
+
connectedProviders: BaseWalletProvider[];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Session information for display and management.
|
|
85
|
+
*
|
|
86
|
+
* @description
|
|
87
|
+
* Represents a single wallet session, which may contain multiple accounts.
|
|
88
|
+
* For HSuite Native, there's typically one session with multiple accounts.
|
|
89
|
+
* For WalletConnect, there may be multiple sessions (one per paired wallet).
|
|
90
|
+
*/
|
|
91
|
+
export interface WalletSession {
|
|
92
|
+
/**
|
|
93
|
+
* Unique provider identifier
|
|
94
|
+
*/
|
|
95
|
+
providerId: string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Provider type (hsuite-native, walletconnect-v2)
|
|
99
|
+
*/
|
|
100
|
+
providerType: string;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Human-readable provider name
|
|
104
|
+
*/
|
|
105
|
+
providerName: string;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Accounts in this session
|
|
109
|
+
*/
|
|
110
|
+
accounts: UnifiedAccount[];
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Additional session metadata
|
|
114
|
+
*/
|
|
115
|
+
metadata?: {
|
|
116
|
+
sessionKey?: string;
|
|
117
|
+
topic?: string;
|
|
118
|
+
networkId?: string;
|
|
119
|
+
[key: string]: any;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
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 Event types for the WalletEventBus system.
|
|
13
|
+
*
|
|
14
|
+
* @module models/wallet-events
|
|
15
|
+
*
|
|
16
|
+
* @description
|
|
17
|
+
* Defines the event interfaces used by the WalletEventBus system. These events
|
|
18
|
+
* allow dApps to react to wallet-level changes that happen outside direct user
|
|
19
|
+
* interaction, such as wallet-initiated disconnects, session restorations,
|
|
20
|
+
* and account switches.
|
|
21
|
+
*
|
|
22
|
+
* **Event Types:**
|
|
23
|
+
* - {@link ConnectionEvent} - Provider connected
|
|
24
|
+
* - {@link DisconnectionEvent} - Provider disconnected
|
|
25
|
+
* - {@link AccountChangeEvent} - Active account changed
|
|
26
|
+
* - {@link AccountsUpdateEvent} - Account list updated
|
|
27
|
+
* - {@link SessionEvent} - Session created/deleted/restored
|
|
28
|
+
* - {@link ProviderStatusEvent} - Provider status changed
|
|
29
|
+
* - {@link ProviderErrorEvent} - Provider error occurred
|
|
30
|
+
*
|
|
31
|
+
* All events include a `timestamp` field (Unix milliseconds) for ordering
|
|
32
|
+
* and debugging purposes.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
import type { UnifiedAccount } from './unified-account.model';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Emitted when a provider successfully connects.
|
|
39
|
+
*
|
|
40
|
+
* @description
|
|
41
|
+
* Fired after a wallet connection is established and accounts are available.
|
|
42
|
+
* Use this event to update UI, fetch balances, or perform post-connection logic.
|
|
43
|
+
*/
|
|
44
|
+
export interface ConnectionEvent {
|
|
45
|
+
providerId: string;
|
|
46
|
+
providerType: 'hsuite-native' | 'walletconnect-v2';
|
|
47
|
+
accounts: UnifiedAccount[];
|
|
48
|
+
timestamp: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Emitted when a provider disconnects.
|
|
53
|
+
*
|
|
54
|
+
* @description
|
|
55
|
+
* Fired when a wallet connection is terminated. Can be user-initiated
|
|
56
|
+
* (via disconnect button) or wallet-initiated (remote disconnect).
|
|
57
|
+
*
|
|
58
|
+
* **Reason Values:**
|
|
59
|
+
* - `'user_initiated'` - User clicked disconnect in dApp
|
|
60
|
+
* - `'wallet_initiated_disconnect'` - Wallet app terminated session
|
|
61
|
+
* - `'session_terminated'` - Session ended by protocol
|
|
62
|
+
* - `'session_expired'` - Session timed out
|
|
63
|
+
*/
|
|
64
|
+
export interface DisconnectionEvent {
|
|
65
|
+
providerId: string;
|
|
66
|
+
providerType: string;
|
|
67
|
+
sessionKey?: string;
|
|
68
|
+
reason?:
|
|
69
|
+
| 'user_initiated'
|
|
70
|
+
| 'wallet_initiated_disconnect'
|
|
71
|
+
| 'session_terminated'
|
|
72
|
+
| 'session_expired'
|
|
73
|
+
| string;
|
|
74
|
+
timestamp: number;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Emitted when the active account changes.
|
|
79
|
+
*
|
|
80
|
+
* @description
|
|
81
|
+
* Fired when the user switches between accounts via setActiveAccount() or
|
|
82
|
+
* account selector UI. Includes both the previous and new account for
|
|
83
|
+
* comparison and transition logic.
|
|
84
|
+
*/
|
|
85
|
+
export interface AccountChangeEvent {
|
|
86
|
+
previousAccount: UnifiedAccount | null;
|
|
87
|
+
newAccount: UnifiedAccount | null;
|
|
88
|
+
timestamp: number;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Emitted when a provider's account list updates.
|
|
93
|
+
*
|
|
94
|
+
* @description
|
|
95
|
+
* Fired when accounts are added or removed from a provider. This can happen
|
|
96
|
+
* when the wallet adds new accounts or when the user grants access to
|
|
97
|
+
* additional accounts.
|
|
98
|
+
*/
|
|
99
|
+
export interface AccountsUpdateEvent {
|
|
100
|
+
providerId: string;
|
|
101
|
+
accounts: UnifiedAccount[];
|
|
102
|
+
totalAccounts: number;
|
|
103
|
+
timestamp: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Emitted for session lifecycle events (created, deleted, restored).
|
|
108
|
+
*
|
|
109
|
+
* @description
|
|
110
|
+
* Fired when a session is created, deleted, or restored. Sessions represent
|
|
111
|
+
* a logical connection to a wallet, which may contain multiple accounts.
|
|
112
|
+
*
|
|
113
|
+
* This same interface is used for:
|
|
114
|
+
* - `sessionCreated` - New session established
|
|
115
|
+
* - `sessionDeleted` - Session terminated
|
|
116
|
+
* - `sessionRestored` - Session restored from storage
|
|
117
|
+
*/
|
|
118
|
+
export interface SessionEvent {
|
|
119
|
+
providerId: string;
|
|
120
|
+
sessionKey: string;
|
|
121
|
+
accounts: UnifiedAccount[];
|
|
122
|
+
metadata?: Record<string, unknown>;
|
|
123
|
+
timestamp: number;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Emitted when a provider's status changes.
|
|
128
|
+
*
|
|
129
|
+
* @description
|
|
130
|
+
* Fired when a provider transitions between connection states. Useful for
|
|
131
|
+
* showing loading indicators or status badges.
|
|
132
|
+
*
|
|
133
|
+
* **Status Values:**
|
|
134
|
+
* - `'connecting'` - Connection attempt in progress
|
|
135
|
+
* - `'connected'` - Successfully connected
|
|
136
|
+
* - `'disconnected'` - Not connected
|
|
137
|
+
* - `'error'` - Connection failed
|
|
138
|
+
*/
|
|
139
|
+
export interface ProviderStatusEvent {
|
|
140
|
+
providerId: string;
|
|
141
|
+
status: 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
142
|
+
timestamp: number;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Emitted when a provider encounters an error.
|
|
147
|
+
*
|
|
148
|
+
* @description
|
|
149
|
+
* Fired when a wallet operation fails. Includes the error details and
|
|
150
|
+
* optional context about what operation failed. Use this to display
|
|
151
|
+
* error messages to users or for debugging.
|
|
152
|
+
*/
|
|
153
|
+
export interface ProviderErrorEvent {
|
|
154
|
+
providerId: string;
|
|
155
|
+
error: Error | string;
|
|
156
|
+
context?: string;
|
|
157
|
+
timestamp: number;
|
|
158
|
+
}
|