@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,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @component WalletTransactionStatus
|
|
3
|
+
* @compodoc
|
|
4
|
+
* Theme-aware transaction status display
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
.status-card {
|
|
8
|
+
margin: 0;
|
|
9
|
+
background: var(--wallet-session-bg, var(--surface-flat, rgba(var(--ion-color-light-rgb), 0.05)));
|
|
10
|
+
border: var(--border-width-thin, 1px) solid var(--wallet-session-border, var(--border-flat, rgba(var(--ion-color-light-rgb), 0.1)));
|
|
11
|
+
border-radius: var(--wallet-status-radius, var(--border-radius-lg, 12px));
|
|
12
|
+
padding: var(--wallet-status-padding, var(--space-lg, 16px));
|
|
13
|
+
box-shadow: var(--wallet-session-shadow, var(--shadow-md));
|
|
14
|
+
animation: slideInFade var(--wallet-transition-slow, var(--duration-slow, 0.3s)) ease-out;
|
|
15
|
+
|
|
16
|
+
&.status-success {
|
|
17
|
+
border-left: var(--wallet-status-border-width, var(--border-width-heavy, 4px)) solid var(--wallet-status-success-border, var(--ion-color-success));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&.status-failed,
|
|
21
|
+
&.status-rejected {
|
|
22
|
+
border-left: var(--wallet-status-border-width, var(--border-width-heavy, 4px)) solid var(--wallet-status-failed-border, var(--ion-color-danger));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&.status-timeout {
|
|
26
|
+
border-left: var(--wallet-status-border-width, var(--border-width-heavy, 4px)) solid var(--wallet-status-warning-border, var(--ion-color-warning));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&.status-processing,
|
|
30
|
+
&.status-pending {
|
|
31
|
+
border-left: var(--wallet-status-border-width, var(--border-width-heavy, 4px)) solid var(--wallet-status-pending-border, var(--ion-color-primary));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.status-header {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
gap: var(--wallet-status-gap, var(--space-md, 12px));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.status-icon {
|
|
42
|
+
font-size: var(--wallet-status-icon-size, var(--font-size-3xl, 32px));
|
|
43
|
+
flex-shrink: 0;
|
|
44
|
+
transition: transform var(--wallet-transition-fast, var(--duration-fast, 0.15s)) ease;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.status-spinner {
|
|
48
|
+
width: var(--wallet-status-icon-size, var(--font-size-3xl, 32px));
|
|
49
|
+
height: var(--wallet-status-icon-size, var(--font-size-3xl, 32px));
|
|
50
|
+
flex-shrink: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.status-description {
|
|
54
|
+
font-size: var(--wallet-font-size-base, var(--font-size-sm, 14px));
|
|
55
|
+
line-height: var(--wallet-line-height-relaxed, var(--line-height-relaxed, 1.6));
|
|
56
|
+
color: var(--wallet-session-text-primary, var(--ion-text-color));
|
|
57
|
+
margin-bottom: var(--wallet-spacing-lg, var(--space-lg, 16px));
|
|
58
|
+
|
|
59
|
+
p {
|
|
60
|
+
margin: 0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.transaction-id-section,
|
|
65
|
+
.error-section {
|
|
66
|
+
background: var(--wallet-status-section-bg, var(--surface-flat, rgba(var(--ion-color-medium-rgb), 0.05)));
|
|
67
|
+
padding: var(--wallet-status-section-padding, var(--space-md, 12px));
|
|
68
|
+
border-radius: var(--wallet-status-section-radius, var(--border-radius-md, 8px));
|
|
69
|
+
margin-bottom: var(--wallet-spacing-lg, var(--space-lg, 16px));
|
|
70
|
+
border: var(--border-width-thin, 1px) solid var(--wallet-session-border, var(--border-flat, rgba(var(--ion-color-light-rgb), 0.1)));
|
|
71
|
+
transition: all var(--wallet-transition-normal, var(--transition-all, 0.2s ease));
|
|
72
|
+
|
|
73
|
+
&:hover {
|
|
74
|
+
background: var(--surface-flat-hover, rgba(var(--ion-color-medium-rgb), 0.08));
|
|
75
|
+
transform: translateY(-1px);
|
|
76
|
+
box-shadow: var(--wallet-shadow-sm, var(--shadow-sm));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.section-label {
|
|
80
|
+
font-size: var(--wallet-font-size-sm, var(--font-size-sm, 13px));
|
|
81
|
+
font-weight: var(--wallet-font-weight-semibold, var(--font-weight-semibold, 600));
|
|
82
|
+
color: var(--wallet-session-text-primary, var(--ion-text-color));
|
|
83
|
+
line-height: var(--wallet-line-height-normal, var(--line-height-normal, 1.4));
|
|
84
|
+
margin: 0 0 var(--wallet-spacing-xs, var(--space-xs, 4px)) 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.transaction-id {
|
|
88
|
+
font-family: var(--wallet-account-font-family, var(--font-family-mono, monospace));
|
|
89
|
+
font-size: var(--wallet-font-size-sm, var(--font-size-sm, 13px));
|
|
90
|
+
color: var(--wallet-session-text-primary, var(--ion-text-color));
|
|
91
|
+
line-height: var(--wallet-line-height-normal, var(--line-height-normal, 1.4));
|
|
92
|
+
word-break: break-all;
|
|
93
|
+
margin: 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.error-message {
|
|
97
|
+
font-size: var(--wallet-font-size-sm, var(--font-size-sm, 13px));
|
|
98
|
+
color: var(--wallet-session-text-primary, var(--ion-text-color));
|
|
99
|
+
line-height: var(--wallet-line-height-normal, var(--line-height-normal, 1.4));
|
|
100
|
+
margin: 0;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.error-section {
|
|
105
|
+
background: var(--wallet-status-error-bg, rgba(var(--ion-color-danger-rgb), 0.05));
|
|
106
|
+
border-left: var(--wallet-status-error-border, 3px solid var(--ion-color-danger));
|
|
107
|
+
|
|
108
|
+
&:hover {
|
|
109
|
+
background: rgba(var(--ion-color-danger-rgb), 0.1);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.actions {
|
|
114
|
+
display: flex;
|
|
115
|
+
flex-direction: column;
|
|
116
|
+
gap: var(--wallet-spacing-sm, 8px);
|
|
117
|
+
margin-top: var(--wallet-spacing-lg, 16px);
|
|
118
|
+
|
|
119
|
+
ion-button {
|
|
120
|
+
--border-radius: var(--wallet-button-radius, 12px);
|
|
121
|
+
font-weight: var(--wallet-button-font-weight, 600);
|
|
122
|
+
transition: all var(--wallet-transition-normal, 0.2s) ease;
|
|
123
|
+
|
|
124
|
+
&:hover:not([disabled]) {
|
|
125
|
+
transform: translateY(-2px);
|
|
126
|
+
box-shadow: var(--shadow-md);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
&:active:not([disabled]) {
|
|
130
|
+
transform: translateY(0);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* Animations */
|
|
136
|
+
@keyframes pulse {
|
|
137
|
+
0%, 100% {
|
|
138
|
+
opacity: 1;
|
|
139
|
+
}
|
|
140
|
+
50% {
|
|
141
|
+
opacity: 0.5;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.status-processing,
|
|
146
|
+
.status-pending {
|
|
147
|
+
.status-spinner {
|
|
148
|
+
animation: pulse 2s ease-in-out infinite;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@keyframes slideInFade {
|
|
153
|
+
from {
|
|
154
|
+
opacity: 0;
|
|
155
|
+
transform: translateY(-10px);
|
|
156
|
+
}
|
|
157
|
+
to {
|
|
158
|
+
opacity: 1;
|
|
159
|
+
transform: translateY(0);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* Success confetti effect */
|
|
164
|
+
@keyframes celebrate {
|
|
165
|
+
0%, 100% {
|
|
166
|
+
transform: scale(1);
|
|
167
|
+
}
|
|
168
|
+
25% {
|
|
169
|
+
transform: scale(1.1) rotate(-5deg);
|
|
170
|
+
}
|
|
171
|
+
50% {
|
|
172
|
+
transform: scale(1.05) rotate(5deg);
|
|
173
|
+
}
|
|
174
|
+
75% {
|
|
175
|
+
transform: scale(1.1) rotate(-5deg);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.status-success {
|
|
180
|
+
.status-icon {
|
|
181
|
+
animation: celebrate 0.6s ease-in-out;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/* Failed shake effect */
|
|
186
|
+
@keyframes shake {
|
|
187
|
+
0%, 100% {
|
|
188
|
+
transform: translateX(0);
|
|
189
|
+
}
|
|
190
|
+
25% {
|
|
191
|
+
transform: translateX(-5px);
|
|
192
|
+
}
|
|
193
|
+
75% {
|
|
194
|
+
transform: translateX(5px);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.status-failed,
|
|
199
|
+
.status-rejected {
|
|
200
|
+
.status-icon {
|
|
201
|
+
animation: shake 0.4s ease-in-out;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/* Responsive */
|
|
206
|
+
@media (max-width: 576px) {
|
|
207
|
+
.status-header {
|
|
208
|
+
flex-direction: column;
|
|
209
|
+
text-align: center;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.actions {
|
|
213
|
+
flex-direction: column;
|
|
214
|
+
|
|
215
|
+
ion-button {
|
|
216
|
+
width: 100%;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/* Reduced Motion Support */
|
|
222
|
+
@media (prefers-reduced-motion: reduce) {
|
|
223
|
+
*,
|
|
224
|
+
*::before,
|
|
225
|
+
*::after {
|
|
226
|
+
animation-duration: 0.01ms !important;
|
|
227
|
+
transition-duration: 0.01ms !important;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
@keyframes slideInFade {
|
|
231
|
+
from, to {
|
|
232
|
+
opacity: 1;
|
|
233
|
+
transform: translateY(0);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
@keyframes celebrate {
|
|
238
|
+
from, to {
|
|
239
|
+
transform: scale(1) rotate(0);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
@keyframes shake {
|
|
244
|
+
from, to {
|
|
245
|
+
transform: translateX(0);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
@keyframes pulse {
|
|
250
|
+
from, to {
|
|
251
|
+
opacity: 1;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HSuite Native Connect
|
|
3
|
+
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
6
|
+
*
|
|
7
|
+
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
8
|
+
* visit https://hsuite.finance/licensing
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
|
12
|
+
import { CommonModule } from '@angular/common';
|
|
13
|
+
import {
|
|
14
|
+
IonCard,
|
|
15
|
+
IonCardHeader,
|
|
16
|
+
IonCardTitle,
|
|
17
|
+
IonCardContent,
|
|
18
|
+
IonText,
|
|
19
|
+
IonIcon,
|
|
20
|
+
IonSpinner,
|
|
21
|
+
IonButton,
|
|
22
|
+
} from '@ionic/angular/standalone';
|
|
23
|
+
import { addIcons } from 'ionicons';
|
|
24
|
+
import {
|
|
25
|
+
checkmarkCircleOutline,
|
|
26
|
+
closeCircleOutline,
|
|
27
|
+
timeOutline,
|
|
28
|
+
alertCircleOutline,
|
|
29
|
+
hourglassOutline,
|
|
30
|
+
openOutline,
|
|
31
|
+
refreshOutline,
|
|
32
|
+
} from 'ionicons/icons';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @component WalletTransactionStatusComponent
|
|
36
|
+
* Displays transaction status with user-friendly messaging.
|
|
37
|
+
*
|
|
38
|
+
* **Features:**
|
|
39
|
+
* - Visual status indicators
|
|
40
|
+
* - Status-specific colors and icons
|
|
41
|
+
* - Transaction hash/ID display
|
|
42
|
+
* - Error messages
|
|
43
|
+
* - Loading states
|
|
44
|
+
* - Action buttons (view explorer, retry)
|
|
45
|
+
* - Theme-aware styling
|
|
46
|
+
*
|
|
47
|
+
* **Status Types:**
|
|
48
|
+
* - `pending` - Transaction submitted, awaiting confirmation
|
|
49
|
+
* - `processing` - Being processed by wallet
|
|
50
|
+
* - `success` - Transaction confirmed
|
|
51
|
+
* - `failed` - Transaction failed
|
|
52
|
+
* - `rejected` - User rejected transaction
|
|
53
|
+
* - `timeout` - Transaction timed out
|
|
54
|
+
*/
|
|
55
|
+
@Component({
|
|
56
|
+
selector: 'wallet-transaction-status',
|
|
57
|
+
standalone: true,
|
|
58
|
+
imports: [
|
|
59
|
+
CommonModule,
|
|
60
|
+
IonCard,
|
|
61
|
+
IonCardHeader,
|
|
62
|
+
IonCardTitle,
|
|
63
|
+
IonCardContent,
|
|
64
|
+
IonText,
|
|
65
|
+
IonIcon,
|
|
66
|
+
IonSpinner,
|
|
67
|
+
IonButton,
|
|
68
|
+
],
|
|
69
|
+
templateUrl: './wallet-transaction-status.component.html',
|
|
70
|
+
styleUrls: ['./wallet-transaction-status.component.scss'],
|
|
71
|
+
})
|
|
72
|
+
export class WalletTransactionStatusComponent {
|
|
73
|
+
/**
|
|
74
|
+
* Transaction status
|
|
75
|
+
*/
|
|
76
|
+
@Input({ required: true }) status!:
|
|
77
|
+
| 'pending'
|
|
78
|
+
| 'processing'
|
|
79
|
+
| 'success'
|
|
80
|
+
| 'failed'
|
|
81
|
+
| 'rejected'
|
|
82
|
+
| 'timeout';
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Transaction ID/hash (for success state)
|
|
86
|
+
*/
|
|
87
|
+
@Input() transactionId?: string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Error message (for failed state)
|
|
91
|
+
*/
|
|
92
|
+
@Input() error?: string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Link to blockchain explorer
|
|
96
|
+
*/
|
|
97
|
+
@Input() explorerUrl?: string;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Custom message to display
|
|
101
|
+
*/
|
|
102
|
+
@Input() message?: string;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Whether to show retry button (for failed state)
|
|
106
|
+
* @default false
|
|
107
|
+
*/
|
|
108
|
+
@Input() showRetry = false;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Emitted when retry button is clicked
|
|
112
|
+
*/
|
|
113
|
+
@Output() retry = new EventEmitter<void>();
|
|
114
|
+
|
|
115
|
+
constructor() {
|
|
116
|
+
addIcons({
|
|
117
|
+
checkmarkCircleOutline,
|
|
118
|
+
closeCircleOutline,
|
|
119
|
+
timeOutline,
|
|
120
|
+
alertCircleOutline,
|
|
121
|
+
hourglassOutline,
|
|
122
|
+
openOutline,
|
|
123
|
+
refreshOutline,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Get status config (color, icon, message)
|
|
129
|
+
*/
|
|
130
|
+
getStatusConfig(): {
|
|
131
|
+
color: string;
|
|
132
|
+
icon: string;
|
|
133
|
+
title: string;
|
|
134
|
+
description: string;
|
|
135
|
+
} {
|
|
136
|
+
switch (this.status) {
|
|
137
|
+
case 'success':
|
|
138
|
+
return {
|
|
139
|
+
color: 'success',
|
|
140
|
+
icon: 'checkmark-circle-outline',
|
|
141
|
+
title: 'Transaction Successful',
|
|
142
|
+
description: this.message || 'Your transaction has been confirmed on the blockchain.',
|
|
143
|
+
};
|
|
144
|
+
case 'failed':
|
|
145
|
+
return {
|
|
146
|
+
color: 'danger',
|
|
147
|
+
icon: 'close-circle-outline',
|
|
148
|
+
title: 'Transaction Failed',
|
|
149
|
+
description: this.message || this.error || 'Transaction failed. Please try again.',
|
|
150
|
+
};
|
|
151
|
+
case 'rejected':
|
|
152
|
+
return {
|
|
153
|
+
color: 'warning',
|
|
154
|
+
icon: 'close-circle-outline',
|
|
155
|
+
title: 'Transaction Rejected',
|
|
156
|
+
description: this.message || 'You rejected the transaction in your wallet.',
|
|
157
|
+
};
|
|
158
|
+
case 'timeout':
|
|
159
|
+
return {
|
|
160
|
+
color: 'warning',
|
|
161
|
+
icon: 'time-outline',
|
|
162
|
+
title: 'Transaction Timeout',
|
|
163
|
+
description: this.message || 'Transaction timed out. Please try again.',
|
|
164
|
+
};
|
|
165
|
+
case 'processing':
|
|
166
|
+
return {
|
|
167
|
+
color: 'primary',
|
|
168
|
+
icon: 'hourglass-outline',
|
|
169
|
+
title: 'Processing Transaction',
|
|
170
|
+
description: this.message || 'Please confirm the transaction in your wallet...',
|
|
171
|
+
};
|
|
172
|
+
case 'pending':
|
|
173
|
+
default:
|
|
174
|
+
return {
|
|
175
|
+
color: 'medium',
|
|
176
|
+
icon: 'hourglass-outline',
|
|
177
|
+
title: 'Transaction Pending',
|
|
178
|
+
description: this.message || 'Waiting for confirmation...',
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Truncate transaction ID for display
|
|
185
|
+
*/
|
|
186
|
+
formatTransactionId(id: string): string {
|
|
187
|
+
if (id.length <= 20) return id;
|
|
188
|
+
return `${id.substring(0, 10)}...${id.substring(id.length - 8)}`;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Open transaction in explorer
|
|
193
|
+
*/
|
|
194
|
+
openExplorer(): void {
|
|
195
|
+
if (this.explorerUrl) {
|
|
196
|
+
window.open(this.explorerUrl, '_blank', 'noopener,noreferrer');
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Handle retry click
|
|
202
|
+
*/
|
|
203
|
+
onRetry(): void {
|
|
204
|
+
this.retry.emit();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
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 guards content based on wallet connection status.
|
|
13
|
+
*
|
|
14
|
+
* @module directives/wallet-connected
|
|
15
|
+
*
|
|
16
|
+
* @description
|
|
17
|
+
* WalletConnectedDirective is a structural directive that conditionally renders content
|
|
18
|
+
* based on wallet connection status. It acts as a guard, showing the main template when
|
|
19
|
+
* a wallet is connected and optionally showing an alternate template when not connected.
|
|
20
|
+
*
|
|
21
|
+
* **Key Features:**
|
|
22
|
+
* - Conditional rendering based on connection status
|
|
23
|
+
* - Provides wallet context to the connected template
|
|
24
|
+
* - Supports `else` template for disconnected state
|
|
25
|
+
* - Automatically updates when connection status changes
|
|
26
|
+
*
|
|
27
|
+
* **Selector:** `*walletConnected`
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import {
|
|
31
|
+
Directive,
|
|
32
|
+
Input,
|
|
33
|
+
TemplateRef,
|
|
34
|
+
ViewContainerRef,
|
|
35
|
+
inject,
|
|
36
|
+
effect,
|
|
37
|
+
EmbeddedViewRef,
|
|
38
|
+
} from '@angular/core';
|
|
39
|
+
import { WalletContextService } from '../services/wallet-context.service';
|
|
40
|
+
import type { WalletContext } from '../models/wallet-context.model';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Context object passed to the connected template.
|
|
44
|
+
*
|
|
45
|
+
* @description
|
|
46
|
+
* Contains the wallet context that is exposed to the template when using
|
|
47
|
+
* the `*walletConnected` structural directive. Both `$implicit` and
|
|
48
|
+
* `walletConnected` contain the same context for flexible access.
|
|
49
|
+
*/
|
|
50
|
+
export class WalletConnectedDirectiveContext {
|
|
51
|
+
constructor(
|
|
52
|
+
public $implicit: WalletContext,
|
|
53
|
+
public walletConnected: WalletContext,
|
|
54
|
+
) {}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Structural directive that conditionally shows content when wallet is connected.
|
|
59
|
+
*
|
|
60
|
+
* @directive WalletConnectedDirective
|
|
61
|
+
* @selector [walletConnected]
|
|
62
|
+
*
|
|
63
|
+
* @description
|
|
64
|
+
* Acts as a guard - shows main template when connected, else template when not.
|
|
65
|
+
* Also provides wallet context to the main template for convenience, allowing
|
|
66
|
+
* access to active account, all accounts, sessions, and providers.
|
|
67
|
+
*
|
|
68
|
+
* The directive uses Angular's effect() to reactively update the view when
|
|
69
|
+
* the wallet connection status changes.
|
|
70
|
+
*/
|
|
71
|
+
@Directive({
|
|
72
|
+
selector: '[walletConnected]',
|
|
73
|
+
standalone: true,
|
|
74
|
+
})
|
|
75
|
+
export class WalletConnectedDirective {
|
|
76
|
+
private readonly contextService = inject(WalletContextService);
|
|
77
|
+
private readonly templateRef = inject(TemplateRef<WalletConnectedDirectiveContext>);
|
|
78
|
+
private readonly viewContainer = inject(ViewContainerRef);
|
|
79
|
+
|
|
80
|
+
private connectedViewRef: EmbeddedViewRef<WalletConnectedDirectiveContext> | null = null;
|
|
81
|
+
private elseViewRef: EmbeddedViewRef<void> | null = null;
|
|
82
|
+
private _elseTemplateRef: TemplateRef<void> | null = null;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Template to show when wallet is NOT connected.
|
|
86
|
+
*
|
|
87
|
+
* @description
|
|
88
|
+
* Reference to an ng-template that will be rendered when no wallet is connected.
|
|
89
|
+
* Use this to show a login prompt, connect button, or informational message.
|
|
90
|
+
*
|
|
91
|
+
* @param templateRef - Reference to the else template, or null to clear
|
|
92
|
+
*/
|
|
93
|
+
@Input()
|
|
94
|
+
set walletConnectedElse(templateRef: TemplateRef<void> | null) {
|
|
95
|
+
this._elseTemplateRef = templateRef;
|
|
96
|
+
this.updateView();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
constructor() {
|
|
100
|
+
// React to connection status changes
|
|
101
|
+
effect(() => {
|
|
102
|
+
const context = this.contextService.context();
|
|
103
|
+
this.updateView(context);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Updates the view based on connection status.
|
|
109
|
+
*
|
|
110
|
+
* @description
|
|
111
|
+
* Determines whether to show the connected template or the else template
|
|
112
|
+
* based on the current wallet context. Called automatically when the
|
|
113
|
+
* context signal changes.
|
|
114
|
+
*
|
|
115
|
+
* @param context - Optional wallet context, fetched from service if not provided
|
|
116
|
+
*/
|
|
117
|
+
private updateView(context?: WalletContext): void {
|
|
118
|
+
const walletContext = context || this.contextService.context();
|
|
119
|
+
|
|
120
|
+
if (walletContext.isConnected) {
|
|
121
|
+
// Show connected template
|
|
122
|
+
this.showConnectedTemplate(walletContext);
|
|
123
|
+
} else {
|
|
124
|
+
// Show else template if provided
|
|
125
|
+
this.showElseTemplate();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Shows the main template when wallet is connected.
|
|
131
|
+
*
|
|
132
|
+
* @description
|
|
133
|
+
* Creates or updates the connected template view, providing the wallet
|
|
134
|
+
* context as both the implicit variable and the named `walletConnected` property.
|
|
135
|
+
*
|
|
136
|
+
* @param walletContext - The current wallet context to expose to the template
|
|
137
|
+
*/
|
|
138
|
+
private showConnectedTemplate(walletContext: WalletContext): void {
|
|
139
|
+
// Clear else template if shown
|
|
140
|
+
if (this.elseViewRef) {
|
|
141
|
+
this.elseViewRef.destroy();
|
|
142
|
+
this.elseViewRef = null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Create or update connected template
|
|
146
|
+
if (!this.connectedViewRef) {
|
|
147
|
+
const context = new WalletConnectedDirectiveContext(walletContext, walletContext);
|
|
148
|
+
this.connectedViewRef = this.viewContainer.createEmbeddedView(this.templateRef, context);
|
|
149
|
+
} else {
|
|
150
|
+
// Update existing context
|
|
151
|
+
this.connectedViewRef.context.$implicit = walletContext;
|
|
152
|
+
this.connectedViewRef.context.walletConnected = walletContext;
|
|
153
|
+
this.connectedViewRef.markForCheck();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Shows the else template when wallet is NOT connected.
|
|
159
|
+
*
|
|
160
|
+
* @description
|
|
161
|
+
* Clears the connected template and renders the else template if one
|
|
162
|
+
* was provided via the `walletConnectedElse` input.
|
|
163
|
+
*/
|
|
164
|
+
private showElseTemplate(): void {
|
|
165
|
+
// Clear connected template if shown
|
|
166
|
+
if (this.connectedViewRef) {
|
|
167
|
+
this.connectedViewRef.destroy();
|
|
168
|
+
this.connectedViewRef = null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Show else template if provided
|
|
172
|
+
if (this._elseTemplateRef && !this.elseViewRef) {
|
|
173
|
+
this.elseViewRef = this.viewContainer.createEmbeddedView(this._elseTemplateRef);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Static type guard for Angular template type checking.
|
|
179
|
+
*
|
|
180
|
+
* @description
|
|
181
|
+
* Enables TypeScript type inference in templates when using the directive.
|
|
182
|
+
* This allows the template to have proper types for the context variable.
|
|
183
|
+
*
|
|
184
|
+
* @param dir - The directive instance
|
|
185
|
+
* @param ctx - The context to type-guard
|
|
186
|
+
*
|
|
187
|
+
* @returns True, asserting that ctx is WalletConnectedDirectiveContext
|
|
188
|
+
*/
|
|
189
|
+
static ngTemplateContextGuard(
|
|
190
|
+
dir: WalletConnectedDirective,
|
|
191
|
+
ctx: any,
|
|
192
|
+
): ctx is WalletConnectedDirectiveContext {
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
}
|