@hsuite/native-connect-angular 2.1.1 → 2.1.3
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/LICENSE +146 -0
- package/dist/fesm2022/hsuite-native-connect-angular.mjs +321 -619
- package/dist/fesm2022/hsuite-native-connect-angular.mjs.map +1 -1
- package/dist/index.d.ts +5 -235
- package/package.json +37 -15
- package/USAGE_EXAMPLES.md +0 -476
- package/assets/wallets/extension.svg +0 -7
- package/assets/wallets/hashpack.svg +0 -6
- package/assets/wallets/hsuite.svg +0 -11
- package/assets/wallets/kabila.svg +0 -11
- package/assets/wallets/walletconnect.svg +0 -13
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/coverage-summary.json +0 -54
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -476
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -476
- package/coverage/lcov-report/lib/components/account-selector/account-actions/account-actions.component.ts.html +0 -868
- package/coverage/lcov-report/lib/components/account-selector/account-actions/index.html +0 -116
- package/coverage/lcov-report/lib/components/account-selector/account-filter/account-filter.component.ts.html +0 -1288
- package/coverage/lcov-report/lib/components/account-selector/account-filter/index.html +0 -116
- package/coverage/lcov-report/lib/components/account-selector/account-formatting.service.ts.html +0 -679
- package/coverage/lcov-report/lib/components/account-selector/account-grouping.service.ts.html +0 -766
- package/coverage/lcov-report/lib/components/account-selector/account-list/account-list.component.ts.html +0 -1495
- package/coverage/lcov-report/lib/components/account-selector/account-list/index.html +0 -116
- package/coverage/lcov-report/lib/components/account-selector/account-selector.component.ts.html +0 -1495
- package/coverage/lcov-report/lib/components/account-selector/account-selector.service.ts.html +0 -1588
- package/coverage/lcov-report/lib/components/account-selector/index.html +0 -161
- package/coverage/lcov-report/lib/components/wallet-account-display/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-account-display/wallet-account-display.component.ts.html +0 -505
- package/coverage/lcov-report/lib/components/wallet-connect-button/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +0 -829
- package/coverage/lcov-report/lib/components/wallet-connect-prompt/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +0 -409
- package/coverage/lcov-report/lib/components/wallet-connected-guard/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +0 -304
- package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +0 -436
- package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-connection-modal/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +0 -2287
- package/coverage/lcov-report/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +0 -2518
- package/coverage/lcov-report/lib/components/wallet-session-display/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-session-display/wallet-session-display.component.ts.html +0 -676
- package/coverage/lcov-report/lib/components/wallet-transaction-status/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +0 -703
- package/coverage/lcov-report/lib/directives/index.html +0 -146
- package/coverage/lcov-report/lib/directives/wallet-connected.directive.ts.html +0 -670
- package/coverage/lcov-report/lib/directives/wallet-context.directive.ts.html +0 -547
- package/coverage/lcov-report/lib/directives/wallet-events.directive.ts.html +0 -781
- package/coverage/lcov-report/lib/hsuite-wallet.module.ts.html +0 -715
- package/coverage/lcov-report/lib/index.html +0 -116
- package/coverage/lcov-report/lib/models/connection-config.model.ts.html +0 -280
- package/coverage/lcov-report/lib/models/index.html +0 -131
- package/coverage/lcov-report/lib/models/provider-types.ts.html +0 -583
- package/coverage/lcov-report/lib/providers/base-wallet-provider.ts.html +0 -1138
- package/coverage/lcov-report/lib/providers/hsuite-native/channel-client.service.ts.html +0 -2674
- package/coverage/lcov-report/lib/providers/hsuite-native/index.html +0 -116
- package/coverage/lcov-report/lib/providers/hsuite-native-provider.ts.html +0 -2347
- package/coverage/lcov-report/lib/providers/index.html +0 -146
- package/coverage/lcov-report/lib/providers/p2p-native/index.html +0 -131
- package/coverage/lcov-report/lib/providers/p2p-native/p2p-native.provider.ts.html +0 -2254
- package/coverage/lcov-report/lib/providers/p2p-native/p2p-session-manager.ts.html +0 -2173
- package/coverage/lcov-report/lib/providers/wallet-error-handler.ts.html +0 -1132
- package/coverage/lcov-report/lib/providers/walletconnect/core/index.html +0 -176
- package/coverage/lcov-report/lib/providers/walletconnect/core/session-health.ts.html +0 -673
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +0 -1177
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-provider.ts.html +0 -2566
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +0 -904
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +0 -982
- package/coverage/lcov-report/lib/providers/walletconnect/signers/hedera-signer.ts.html +0 -1915
- package/coverage/lcov-report/lib/providers/walletconnect/signers/index.html +0 -146
- package/coverage/lcov-report/lib/providers/walletconnect/signers/signer-factory.ts.html +0 -445
- package/coverage/lcov-report/lib/providers/walletconnect/signers/xrpl-signer.ts.html +0 -1519
- package/coverage/lcov-report/lib/services/hsuite-auth.interceptor.ts.html +0 -568
- package/coverage/lcov-report/lib/services/index.html +0 -221
- package/coverage/lcov-report/lib/services/logger.service.ts.html +0 -463
- package/coverage/lcov-report/lib/services/smart-session.service.ts.html +0 -1264
- package/coverage/lcov-report/lib/services/transaction-builders/active-account-source.ts.html +0 -250
- package/coverage/lcov-report/lib/services/transaction-builders/base-transaction-builder.service.ts.html +0 -1840
- package/coverage/lcov-report/lib/services/transaction-builders/hedera-amount-utils.ts.html +0 -337
- package/coverage/lcov-report/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +0 -3940
- package/coverage/lcov-report/lib/services/transaction-builders/index.html +0 -176
- package/coverage/lcov-report/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +0 -2581
- package/coverage/lcov-report/lib/services/transaction.service.ts.html +0 -1120
- package/coverage/lcov-report/lib/services/unified-wallet.service.ts.html +0 -2638
- package/coverage/lcov-report/lib/services/wallet-context.service.ts.html +0 -637
- package/coverage/lcov-report/lib/services/wallet-event-bus.service.ts.html +0 -643
- package/coverage/lcov-report/lib/services/wallet-providers.service.ts.html +0 -493
- package/coverage/lcov-report/lib/transports/chrome-extension-transport.ts.html +0 -823
- package/coverage/lcov-report/lib/transports/index.html +0 -116
- package/coverage/lcov-report/lib/utils/index.html +0 -131
- package/coverage/lcov-report/lib/utils/ledger-icons.util.ts.html +0 -412
- package/coverage/lcov-report/lib/utils/ledger-ui-registry.ts.html +0 -676
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov.info +0 -20366
- package/coverage/lib/components/account-selector/account-actions/account-actions.component.ts.html +0 -868
- package/coverage/lib/components/account-selector/account-actions/index.html +0 -116
- package/coverage/lib/components/account-selector/account-filter/account-filter.component.ts.html +0 -1288
- package/coverage/lib/components/account-selector/account-filter/index.html +0 -116
- package/coverage/lib/components/account-selector/account-formatting.service.ts.html +0 -679
- package/coverage/lib/components/account-selector/account-grouping.service.ts.html +0 -766
- package/coverage/lib/components/account-selector/account-list/account-list.component.ts.html +0 -1495
- package/coverage/lib/components/account-selector/account-list/index.html +0 -116
- package/coverage/lib/components/account-selector/account-selector.component.ts.html +0 -1495
- package/coverage/lib/components/account-selector/account-selector.service.ts.html +0 -1588
- package/coverage/lib/components/account-selector/index.html +0 -161
- package/coverage/lib/components/wallet-account-display/index.html +0 -116
- package/coverage/lib/components/wallet-account-display/wallet-account-display.component.ts.html +0 -505
- package/coverage/lib/components/wallet-connect-button/index.html +0 -116
- package/coverage/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +0 -829
- package/coverage/lib/components/wallet-connect-prompt/index.html +0 -116
- package/coverage/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +0 -409
- package/coverage/lib/components/wallet-connected-guard/index.html +0 -116
- package/coverage/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +0 -304
- package/coverage/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +0 -436
- package/coverage/lib/components/wallet-connection-modal/connection-method-step/index.html +0 -116
- package/coverage/lib/components/wallet-connection-modal/index.html +0 -116
- package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/index.html +0 -116
- package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +0 -2287
- package/coverage/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +0 -2518
- package/coverage/lib/components/wallet-session-display/index.html +0 -116
- package/coverage/lib/components/wallet-session-display/wallet-session-display.component.ts.html +0 -676
- package/coverage/lib/components/wallet-transaction-status/index.html +0 -116
- package/coverage/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +0 -703
- package/coverage/lib/directives/index.html +0 -146
- package/coverage/lib/directives/wallet-connected.directive.ts.html +0 -670
- package/coverage/lib/directives/wallet-context.directive.ts.html +0 -547
- package/coverage/lib/directives/wallet-events.directive.ts.html +0 -781
- package/coverage/lib/hsuite-wallet.module.ts.html +0 -715
- package/coverage/lib/index.html +0 -116
- package/coverage/lib/models/connection-config.model.ts.html +0 -280
- package/coverage/lib/models/index.html +0 -131
- package/coverage/lib/models/provider-types.ts.html +0 -583
- package/coverage/lib/providers/base-wallet-provider.ts.html +0 -1138
- package/coverage/lib/providers/hsuite-native/channel-client.service.ts.html +0 -2674
- package/coverage/lib/providers/hsuite-native/index.html +0 -116
- package/coverage/lib/providers/hsuite-native-provider.ts.html +0 -2347
- package/coverage/lib/providers/index.html +0 -146
- package/coverage/lib/providers/p2p-native/index.html +0 -131
- package/coverage/lib/providers/p2p-native/p2p-native.provider.ts.html +0 -2254
- package/coverage/lib/providers/p2p-native/p2p-session-manager.ts.html +0 -2173
- package/coverage/lib/providers/wallet-error-handler.ts.html +0 -1132
- package/coverage/lib/providers/walletconnect/core/index.html +0 -176
- package/coverage/lib/providers/walletconnect/core/session-health.ts.html +0 -673
- package/coverage/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +0 -1177
- package/coverage/lib/providers/walletconnect/core/walletconnect-provider.ts.html +0 -2566
- package/coverage/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +0 -904
- package/coverage/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +0 -982
- package/coverage/lib/providers/walletconnect/signers/hedera-signer.ts.html +0 -1915
- package/coverage/lib/providers/walletconnect/signers/index.html +0 -146
- package/coverage/lib/providers/walletconnect/signers/signer-factory.ts.html +0 -445
- package/coverage/lib/providers/walletconnect/signers/xrpl-signer.ts.html +0 -1519
- package/coverage/lib/services/hsuite-auth.interceptor.ts.html +0 -568
- package/coverage/lib/services/index.html +0 -221
- package/coverage/lib/services/logger.service.ts.html +0 -463
- package/coverage/lib/services/smart-session.service.ts.html +0 -1264
- package/coverage/lib/services/transaction-builders/active-account-source.ts.html +0 -250
- package/coverage/lib/services/transaction-builders/base-transaction-builder.service.ts.html +0 -1840
- package/coverage/lib/services/transaction-builders/hedera-amount-utils.ts.html +0 -337
- package/coverage/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +0 -3940
- package/coverage/lib/services/transaction-builders/index.html +0 -176
- package/coverage/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +0 -2581
- package/coverage/lib/services/transaction.service.ts.html +0 -1120
- package/coverage/lib/services/unified-wallet.service.ts.html +0 -2638
- package/coverage/lib/services/wallet-context.service.ts.html +0 -637
- package/coverage/lib/services/wallet-event-bus.service.ts.html +0 -643
- package/coverage/lib/services/wallet-providers.service.ts.html +0 -493
- package/coverage/lib/transports/chrome-extension-transport.ts.html +0 -823
- package/coverage/lib/transports/index.html +0 -116
- package/coverage/lib/utils/index.html +0 -131
- package/coverage/lib/utils/ledger-icons.util.ts.html +0 -412
- package/coverage/lib/utils/ledger-ui-registry.ts.html +0 -676
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -210
- package/examples/minimal-connect.ts +0 -178
- package/examples/multi-protocol.ts +0 -495
- package/examples/transaction-signing.ts +0 -361
- package/jest.config.json +0 -45
- package/karma.conf.js +0 -42
- package/ng-package.json +0 -20
- package/src/index.ts +0 -229
- package/src/lib/components/account-selector/account-actions/account-actions.component.ts +0 -261
- package/src/lib/components/account-selector/account-filter/account-filter.component.ts +0 -401
- package/src/lib/components/account-selector/account-formatting.service.ts +0 -198
- package/src/lib/components/account-selector/account-grouping.service.ts +0 -227
- package/src/lib/components/account-selector/account-list/account-list.component.ts +0 -470
- package/src/lib/components/account-selector/account-selector.component.html +0 -135
- package/src/lib/components/account-selector/account-selector.component.scss +0 -2039
- package/src/lib/components/account-selector/account-selector.component.ts +0 -470
- package/src/lib/components/account-selector/account-selector.service.ts +0 -501
- package/src/lib/components/wallet-account-display/wallet-account-display.component.html +0 -34
- package/src/lib/components/wallet-account-display/wallet-account-display.component.scss +0 -99
- package/src/lib/components/wallet-account-display/wallet-account-display.component.ts +0 -140
- package/src/lib/components/wallet-connect-button/wallet-connect-button.component.html +0 -14
- package/src/lib/components/wallet-connect-button/wallet-connect-button.component.scss +0 -272
- package/src/lib/components/wallet-connect-button/wallet-connect-button.component.spec.ts +0 -89
- package/src/lib/components/wallet-connect-button/wallet-connect-button.component.ts +0 -248
- package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.html +0 -24
- package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.scss +0 -50
- package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts +0 -108
- package/src/lib/components/wallet-connected-guard/wallet-connected-guard.component.html +0 -24
- package/src/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts +0 -73
- package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.html +0 -56
- package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.scss +0 -218
- package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts +0 -117
- package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.html +0 -94
- package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.scss +0 -272
- package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts +0 -734
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.html +0 -192
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.scss +0 -678
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.spec.ts +0 -173
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts +0 -811
- package/src/lib/components/wallet-session-display/wallet-session-display.component.html +0 -110
- package/src/lib/components/wallet-session-display/wallet-session-display.component.scss +0 -179
- package/src/lib/components/wallet-session-display/wallet-session-display.component.ts +0 -197
- package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.html +0 -65
- package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.scss +0 -254
- package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts +0 -206
- package/src/lib/directives/wallet-connected.directive.ts +0 -195
- package/src/lib/directives/wallet-context.directive.ts +0 -154
- package/src/lib/directives/wallet-events.directive.ts +0 -232
- package/src/lib/hsuite-wallet.module.ts +0 -210
- package/src/lib/models/connection-config.model.ts +0 -65
- package/src/lib/models/provider-types.ts +0 -166
- package/src/lib/models/unified-account.model.ts +0 -79
- package/src/lib/models/wallet-context.model.ts +0 -121
- package/src/lib/models/wallet-events.model.ts +0 -158
- package/src/lib/providers/base-wallet-provider.ts +0 -351
- package/src/lib/providers/hsuite-native/channel-client.service.spec.ts +0 -73
- package/src/lib/providers/hsuite-native/channel-client.service.ts +0 -863
- package/src/lib/providers/hsuite-native/index.ts +0 -8
- package/src/lib/providers/hsuite-native-provider.ts +0 -754
- package/src/lib/providers/mobile-native/mobile-native.provider.spec.ts +0 -19
- package/src/lib/providers/p2p-native/index.ts +0 -30
- package/src/lib/providers/p2p-native/p2p-native.provider.spec.ts +0 -523
- package/src/lib/providers/p2p-native/p2p-native.provider.ts +0 -723
- package/src/lib/providers/p2p-native/p2p-session-manager.ts +0 -696
- package/src/lib/providers/wallet-error-handler.ts +0 -349
- package/src/lib/providers/walletconnect/core/base-signer.interface.ts +0 -122
- package/src/lib/providers/walletconnect/core/session-health.ts +0 -196
- package/src/lib/providers/walletconnect/core/walletconnect-client-manager.ts +0 -364
- package/src/lib/providers/walletconnect/core/walletconnect-provider.integration.spec.ts +0 -348
- package/src/lib/providers/walletconnect/core/walletconnect-provider.ts +0 -827
- package/src/lib/providers/walletconnect/core/walletconnect-session-store.ts +0 -273
- package/src/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts +0 -299
- package/src/lib/providers/walletconnect/core/walletconnect-types.ts +0 -48
- package/src/lib/providers/walletconnect/index.ts +0 -33
- package/src/lib/providers/walletconnect/signers/hedera-signer.spec.ts +0 -367
- package/src/lib/providers/walletconnect/signers/hedera-signer.ts +0 -610
- package/src/lib/providers/walletconnect/signers/signer-factory.spec.ts +0 -62
- package/src/lib/providers/walletconnect/signers/signer-factory.ts +0 -120
- package/src/lib/providers/walletconnect/signers/xrpl-signer.spec.ts +0 -296
- package/src/lib/providers/walletconnect/signers/xrpl-signer.ts +0 -478
- package/src/lib/services/hsuite-auth.interceptor.ts +0 -159
- package/src/lib/services/logger.service.ts +0 -126
- package/src/lib/services/smart-session.service.ts +0 -378
- package/src/lib/services/transaction-builders/active-account-source.spec.ts +0 -75
- package/src/lib/services/transaction-builders/active-account-source.ts +0 -55
- package/src/lib/services/transaction-builders/base-transaction-builder.service.ts +0 -585
- package/src/lib/services/transaction-builders/hedera-amount-utils.ts +0 -84
- package/src/lib/services/transaction-builders/hedera-transaction-builder.service.spec.ts +0 -741
- package/src/lib/services/transaction-builders/hedera-transaction-builder.service.ts +0 -1285
- package/src/lib/services/transaction-builders/index.ts +0 -55
- package/src/lib/services/transaction-builders/xrpl-transaction-builder.service.spec.ts +0 -937
- package/src/lib/services/transaction-builders/xrpl-transaction-builder.service.ts +0 -832
- package/src/lib/services/transaction.service.ts +0 -349
- package/src/lib/services/unified-wallet.service.spec.ts +0 -1382
- package/src/lib/services/unified-wallet.service.ts +0 -851
- package/src/lib/services/wallet-context.service.ts +0 -184
- package/src/lib/services/wallet-event-bus.service.ts +0 -186
- package/src/lib/services/wallet-providers.service.ts +0 -136
- package/src/lib/transports/chrome-extension-transport.ts +0 -246
- package/src/lib/utils/index.ts +0 -15
- package/src/lib/utils/ledger-icons.util.ts +0 -109
- package/src/lib/utils/ledger-ui-registry.ts +0 -197
- package/test/test-setup.ts +0 -21
- package/test-setup.ts +0 -63
- package/tsconfig.build.json +0 -11
- package/tsconfig.json +0 -29
- package/tsconfig.spec.json +0 -15
- package/vitest.config.ts +0 -48
|
@@ -12,10 +12,8 @@ export { HederaTransactionEncoder, XrplTransactionEncoder } from '@hsuite/native
|
|
|
12
12
|
import { WalletConnectModal } from '@walletconnect/modal';
|
|
13
13
|
import SignClient from '@walletconnect/sign-client';
|
|
14
14
|
import { toObservable } from '@angular/core/rxjs-interop';
|
|
15
|
-
import { copyToClipboard } from '@hsuite/native-connect-ui';
|
|
16
15
|
import * as QRCode from 'qrcode';
|
|
17
|
-
import { Subscription
|
|
18
|
-
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
|
|
16
|
+
import { Subscription } from 'rxjs';
|
|
19
17
|
import { PublicKey, KeyList, TransferTransaction, AccountId, Hbar, TokenId, NftId, TokenAssociateTransaction, TokenDissociateTransaction, ScheduleCreateTransaction, TokenCreateTransaction, TokenType, TokenSupplyType, TokenMintTransaction, TokenBurnTransaction, TopicCreateTransaction, TopicMessageSubmitTransaction, AccountCreateTransaction, PrivateKey, AccountUpdateTransaction, TransactionId, BatchTransaction, Client } from '@hashgraph/sdk';
|
|
20
18
|
|
|
21
19
|
/**
|
|
@@ -1429,7 +1427,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
1429
1427
|
* Each event is available as both an Angular EventEmitter (for template bindings)
|
|
1430
1428
|
* and an RxJS Observable (for advanced composition with operators).
|
|
1431
1429
|
*/
|
|
1432
|
-
const logger$
|
|
1430
|
+
const logger$j = getLogger().scoped?.('WalletEventBus') ?? getLogger();
|
|
1433
1431
|
/**
|
|
1434
1432
|
* Centralized event bus for wallet events.
|
|
1435
1433
|
*
|
|
@@ -1541,7 +1539,7 @@ class WalletEventBus {
|
|
|
1541
1539
|
*
|
|
1542
1540
|
*/
|
|
1543
1541
|
constructor() {
|
|
1544
|
-
logger$
|
|
1542
|
+
logger$j.debug('Event bus initialized');
|
|
1545
1543
|
}
|
|
1546
1544
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: WalletEventBus, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1547
1545
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: WalletEventBus, providedIn: 'root' });
|
|
@@ -1728,7 +1726,7 @@ class BaseWalletProvider {
|
|
|
1728
1726
|
* }
|
|
1729
1727
|
* ```
|
|
1730
1728
|
*/
|
|
1731
|
-
const logger$
|
|
1729
|
+
const logger$i = getLogger().scoped?.('ChannelClientService') ?? getLogger();
|
|
1732
1730
|
/**
|
|
1733
1731
|
* ChannelClientService
|
|
1734
1732
|
*
|
|
@@ -1778,7 +1776,6 @@ class ChannelClientService {
|
|
|
1778
1776
|
return {
|
|
1779
1777
|
id: `channel-${account.address}`,
|
|
1780
1778
|
address: account.address,
|
|
1781
|
-
publicKey: account.publicKey,
|
|
1782
1779
|
label: account.alias ?? `Account ${index + 1}`,
|
|
1783
1780
|
ledgerId: account.ledgerId,
|
|
1784
1781
|
networkId: account.networkId,
|
|
@@ -1817,7 +1814,7 @@ class ChannelClientService {
|
|
|
1817
1814
|
*/
|
|
1818
1815
|
async connect(config) {
|
|
1819
1816
|
if (this._state() === 'connecting' || this._state() === 'pending') {
|
|
1820
|
-
logger$
|
|
1817
|
+
logger$i.warn('Connection already in progress');
|
|
1821
1818
|
const existing = this._currentInvite();
|
|
1822
1819
|
if (existing)
|
|
1823
1820
|
return existing;
|
|
@@ -1859,7 +1856,7 @@ class ChannelClientService {
|
|
|
1859
1856
|
this.runInZone(() => {
|
|
1860
1857
|
const previousState = this._state();
|
|
1861
1858
|
if (state !== previousState) {
|
|
1862
|
-
logger$
|
|
1859
|
+
logger$i.debug('State change via callback', { from: previousState, to: state });
|
|
1863
1860
|
this._state.set(state);
|
|
1864
1861
|
// Handle error state - this is triggered on rejection
|
|
1865
1862
|
if (state === 'error') {
|
|
@@ -1884,7 +1881,7 @@ class ChannelClientService {
|
|
|
1884
1881
|
},
|
|
1885
1882
|
onAccountsChange: (accounts) => {
|
|
1886
1883
|
this.runInZone(() => {
|
|
1887
|
-
logger$
|
|
1884
|
+
logger$i.debug('Accounts change via callback', { count: accounts.length });
|
|
1888
1885
|
this._accounts.set(accounts);
|
|
1889
1886
|
// Re-persist when accounts change
|
|
1890
1887
|
if (this._state() === 'active') {
|
|
@@ -1895,7 +1892,7 @@ class ChannelClientService {
|
|
|
1895
1892
|
onTransportChange: (transport) => {
|
|
1896
1893
|
this.runInZone(() => {
|
|
1897
1894
|
if (transport !== this._transportState()) {
|
|
1898
|
-
logger$
|
|
1895
|
+
logger$i.debug('Transport change via callback', { state: transport });
|
|
1899
1896
|
this._transportState.set(transport);
|
|
1900
1897
|
}
|
|
1901
1898
|
});
|
|
@@ -1930,7 +1927,7 @@ class ChannelClientService {
|
|
|
1930
1927
|
});
|
|
1931
1928
|
// Store invite for reconnection
|
|
1932
1929
|
this.storeInvite(invite);
|
|
1933
|
-
logger$
|
|
1930
|
+
logger$i.info('Channel connection initiated', {
|
|
1934
1931
|
channelId: invite.id.slice(0, 8),
|
|
1935
1932
|
type: invite.type,
|
|
1936
1933
|
});
|
|
@@ -1938,7 +1935,7 @@ class ChannelClientService {
|
|
|
1938
1935
|
}
|
|
1939
1936
|
catch (error) {
|
|
1940
1937
|
const message = error instanceof Error ? error.message : String(error);
|
|
1941
|
-
logger$
|
|
1938
|
+
logger$i.error('Connection failed', { error: message });
|
|
1942
1939
|
// Reset connecting flag on error
|
|
1943
1940
|
this.connectingNewSession = false;
|
|
1944
1941
|
this.runInZone(() => {
|
|
@@ -1979,7 +1976,7 @@ class ChannelClientService {
|
|
|
1979
1976
|
if (state !== 'active' && state !== 'approved') {
|
|
1980
1977
|
throw new Error(`Not connected - channel state is '${state}'. Please reconnect to the wallet.`);
|
|
1981
1978
|
}
|
|
1982
|
-
logger$
|
|
1979
|
+
logger$i.debug('Sending RPC request', { method, state });
|
|
1983
1980
|
return this.client.request(method, params, timeoutMs);
|
|
1984
1981
|
}
|
|
1985
1982
|
/**
|
|
@@ -2056,7 +2053,7 @@ class ChannelClientService {
|
|
|
2056
2053
|
await this.client.disconnect();
|
|
2057
2054
|
}
|
|
2058
2055
|
catch (error) {
|
|
2059
|
-
logger$
|
|
2056
|
+
logger$i.warn('Disconnect error', { error });
|
|
2060
2057
|
}
|
|
2061
2058
|
this.client = null;
|
|
2062
2059
|
}
|
|
@@ -2068,7 +2065,7 @@ class ChannelClientService {
|
|
|
2068
2065
|
this._currentInvite.set(null);
|
|
2069
2066
|
this._error.set(null);
|
|
2070
2067
|
});
|
|
2071
|
-
logger$
|
|
2068
|
+
logger$i.info('Disconnected from channel');
|
|
2072
2069
|
}
|
|
2073
2070
|
/**
|
|
2074
2071
|
* Attempt to restore a previous session.
|
|
@@ -2081,7 +2078,7 @@ class ChannelClientService {
|
|
|
2081
2078
|
async attemptRestore() {
|
|
2082
2079
|
// Skip restore if a new connection is being initiated
|
|
2083
2080
|
if (this.connectingNewSession) {
|
|
2084
|
-
logger$
|
|
2081
|
+
logger$i.debug('Skipping restore - new connection in progress');
|
|
2085
2082
|
return false;
|
|
2086
2083
|
}
|
|
2087
2084
|
const stored = this.getStoredChannel();
|
|
@@ -2097,11 +2094,11 @@ class ChannelClientService {
|
|
|
2097
2094
|
// Safe to do unconditionally at this point in the project's lifecycle:
|
|
2098
2095
|
// no dApp sessions are live in production yet.
|
|
2099
2096
|
if (stored.localContext === undefined) {
|
|
2100
|
-
logger$
|
|
2097
|
+
logger$i.warn('Clearing legacy persisted channel without localContext — user must re-approve the dApp connection (§21.1)', { channelId: stored.id.slice(0, 8) });
|
|
2101
2098
|
this.clearStoredChannel();
|
|
2102
2099
|
return false;
|
|
2103
2100
|
}
|
|
2104
|
-
logger$
|
|
2101
|
+
logger$i.info('Attempting session restore', {
|
|
2105
2102
|
channelId: stored.id.slice(0, 8),
|
|
2106
2103
|
});
|
|
2107
2104
|
this.runInZone(() => {
|
|
@@ -2114,7 +2111,7 @@ class ChannelClientService {
|
|
|
2114
2111
|
this.runInZone(() => {
|
|
2115
2112
|
const previousState = this._state();
|
|
2116
2113
|
if (state !== previousState) {
|
|
2117
|
-
logger$
|
|
2114
|
+
logger$i.debug('State change via callback (reconnect)', {
|
|
2118
2115
|
from: previousState,
|
|
2119
2116
|
to: state,
|
|
2120
2117
|
});
|
|
@@ -2134,7 +2131,7 @@ class ChannelClientService {
|
|
|
2134
2131
|
},
|
|
2135
2132
|
onAccountsChange: (accounts) => {
|
|
2136
2133
|
this.runInZone(() => {
|
|
2137
|
-
logger$
|
|
2134
|
+
logger$i.debug('Accounts change via callback (reconnect)', { count: accounts.length });
|
|
2138
2135
|
this._accounts.set(accounts);
|
|
2139
2136
|
if (this._state() === 'active') {
|
|
2140
2137
|
this.persistCurrentState();
|
|
@@ -2144,7 +2141,7 @@ class ChannelClientService {
|
|
|
2144
2141
|
onTransportChange: (transport) => {
|
|
2145
2142
|
this.runInZone(() => {
|
|
2146
2143
|
if (transport !== this._transportState()) {
|
|
2147
|
-
logger$
|
|
2144
|
+
logger$i.debug('Transport change via callback (reconnect)', { state: transport });
|
|
2148
2145
|
this._transportState.set(transport);
|
|
2149
2146
|
}
|
|
2150
2147
|
});
|
|
@@ -2167,14 +2164,14 @@ class ChannelClientService {
|
|
|
2167
2164
|
}
|
|
2168
2165
|
this._state.set('active');
|
|
2169
2166
|
});
|
|
2170
|
-
logger$
|
|
2167
|
+
logger$i.info('Session restored successfully', {
|
|
2171
2168
|
channelId: stored.id.slice(0, 8),
|
|
2172
2169
|
accounts: restoredAccounts.length,
|
|
2173
2170
|
});
|
|
2174
2171
|
return true;
|
|
2175
2172
|
}
|
|
2176
2173
|
catch (error) {
|
|
2177
|
-
logger$
|
|
2174
|
+
logger$i.warn('Session restore failed', {
|
|
2178
2175
|
error: error instanceof Error ? error.message : String(error),
|
|
2179
2176
|
});
|
|
2180
2177
|
// Clean up the partially initialized client
|
|
@@ -2250,7 +2247,7 @@ class ChannelClientService {
|
|
|
2250
2247
|
}
|
|
2251
2248
|
if (clientTransport !== this._transportState()) {
|
|
2252
2249
|
this._transportState.set(clientTransport);
|
|
2253
|
-
logger$
|
|
2250
|
+
logger$i.debug('Transport state updated', { state: clientTransport });
|
|
2254
2251
|
}
|
|
2255
2252
|
});
|
|
2256
2253
|
// Continue polling as long as client exists
|
|
@@ -2293,14 +2290,14 @@ class ChannelClientService {
|
|
|
2293
2290
|
const persisted = this.client.exportState();
|
|
2294
2291
|
if (persisted) {
|
|
2295
2292
|
localStorage.setItem(ChannelClientService.STORAGE_KEY, JSON.stringify(persisted));
|
|
2296
|
-
logger$
|
|
2293
|
+
logger$i.debug('Channel state persisted', {
|
|
2297
2294
|
channelId: persisted.id.slice(0, 8),
|
|
2298
2295
|
accounts: persisted.accounts?.length ?? 0,
|
|
2299
2296
|
});
|
|
2300
2297
|
}
|
|
2301
2298
|
}
|
|
2302
2299
|
catch (error) {
|
|
2303
|
-
logger$
|
|
2300
|
+
logger$i.warn('Failed to persist channel state', { error });
|
|
2304
2301
|
}
|
|
2305
2302
|
}
|
|
2306
2303
|
/**
|
|
@@ -2341,7 +2338,7 @@ class ChannelClientService {
|
|
|
2341
2338
|
}
|
|
2342
2339
|
}
|
|
2343
2340
|
catch {
|
|
2344
|
-
logger$
|
|
2341
|
+
logger$i.warn('Failed to store channel');
|
|
2345
2342
|
}
|
|
2346
2343
|
}
|
|
2347
2344
|
/**
|
|
@@ -2355,7 +2352,7 @@ class ChannelClientService {
|
|
|
2355
2352
|
}
|
|
2356
2353
|
}
|
|
2357
2354
|
catch {
|
|
2358
|
-
logger$
|
|
2355
|
+
logger$i.warn('Failed to retrieve stored channel');
|
|
2359
2356
|
}
|
|
2360
2357
|
return null;
|
|
2361
2358
|
}
|
|
@@ -2407,7 +2404,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
2407
2404
|
* 8. P2P upgrade happens automatically in background
|
|
2408
2405
|
* ```
|
|
2409
2406
|
*/
|
|
2410
|
-
const logger$
|
|
2407
|
+
const logger$h = getLogger().scoped?.('HsuiteNativeProvider') ?? getLogger();
|
|
2411
2408
|
/**
|
|
2412
2409
|
* HSuite Native Connect Provider.
|
|
2413
2410
|
*
|
|
@@ -2493,7 +2490,7 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2493
2490
|
const isConnected = this.channelService.isConnected();
|
|
2494
2491
|
// If we were connected but now disconnected, emit disconnect event
|
|
2495
2492
|
if (this.previouslyConnected && !isConnected && status === 'disconnected') {
|
|
2496
|
-
logger$
|
|
2493
|
+
logger$h.info('[HsuiteNativeProvider] Channel terminated');
|
|
2497
2494
|
this.eventBus.disconnected.emit({
|
|
2498
2495
|
providerId: this.id,
|
|
2499
2496
|
providerType: 'hsuite-native',
|
|
@@ -2506,7 +2503,7 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2506
2503
|
});
|
|
2507
2504
|
// Attempt automatic reconnect when session exists after reload
|
|
2508
2505
|
void this.attemptReconnect().catch((error) => {
|
|
2509
|
-
logger$
|
|
2506
|
+
logger$h.debug('[HsuiteNativeProvider] Auto-reconnect skipped', { error });
|
|
2510
2507
|
});
|
|
2511
2508
|
}
|
|
2512
2509
|
/**
|
|
@@ -2600,10 +2597,10 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2600
2597
|
// Guard: Don't start a new connection if already connecting
|
|
2601
2598
|
const currentStatus = this.status();
|
|
2602
2599
|
if (currentStatus === 'connecting') {
|
|
2603
|
-
logger$
|
|
2600
|
+
logger$h.warn('Connection already in progress, ignoring duplicate request');
|
|
2604
2601
|
return;
|
|
2605
2602
|
}
|
|
2606
|
-
logger$
|
|
2603
|
+
logger$h.info('Connecting to HSuite Wallet via unified channel protocol', { config });
|
|
2607
2604
|
try {
|
|
2608
2605
|
const invite = await this.channelService.connect({
|
|
2609
2606
|
type: 'session',
|
|
@@ -2629,14 +2626,14 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2629
2626
|
accounts,
|
|
2630
2627
|
timestamp: Date.now(),
|
|
2631
2628
|
});
|
|
2632
|
-
logger$
|
|
2629
|
+
logger$h.info('Connected successfully via unified channel', {
|
|
2633
2630
|
channelId: invite.id.slice(0, 8),
|
|
2634
2631
|
accountCount: accounts.length,
|
|
2635
2632
|
});
|
|
2636
2633
|
});
|
|
2637
2634
|
}
|
|
2638
2635
|
catch (error) {
|
|
2639
|
-
logger$
|
|
2636
|
+
logger$h.error('Connection failed', { error });
|
|
2640
2637
|
throw error;
|
|
2641
2638
|
}
|
|
2642
2639
|
}
|
|
@@ -2669,7 +2666,7 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2669
2666
|
if (wallet) {
|
|
2670
2667
|
// Send invite directly via BroadcastChannel - instant, no network!
|
|
2671
2668
|
this.localDiscoveryService.sendInvite(wallet.fingerprint, inviteUrl, config?.appId, config?.appName);
|
|
2672
|
-
logger$
|
|
2669
|
+
logger$h.info('[HsuiteNativeProvider] Sent invite via local discovery', {
|
|
2673
2670
|
wallet: wallet.fingerprint.slice(0, 8),
|
|
2674
2671
|
});
|
|
2675
2672
|
return;
|
|
@@ -2761,7 +2758,7 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2761
2758
|
* @throws {Error} If disconnection fails (event still emitted)
|
|
2762
2759
|
*/
|
|
2763
2760
|
async disconnect() {
|
|
2764
|
-
logger$
|
|
2761
|
+
logger$h.info('Disconnecting from HSuite Wallet');
|
|
2765
2762
|
try {
|
|
2766
2763
|
await this.channelService.disconnect();
|
|
2767
2764
|
// Emit disconnection event
|
|
@@ -2771,10 +2768,10 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2771
2768
|
reason: 'user_initiated',
|
|
2772
2769
|
timestamp: Date.now(),
|
|
2773
2770
|
});
|
|
2774
|
-
logger$
|
|
2771
|
+
logger$h.info('Disconnected successfully');
|
|
2775
2772
|
}
|
|
2776
2773
|
catch (error) {
|
|
2777
|
-
logger$
|
|
2774
|
+
logger$h.error('Disconnection failed', { error });
|
|
2778
2775
|
// Still emit event even if disconnect fails
|
|
2779
2776
|
this.eventBus.disconnected.emit({
|
|
2780
2777
|
providerId: this.id,
|
|
@@ -2802,7 +2799,7 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2802
2799
|
* @throws {Error} If channel communication fails
|
|
2803
2800
|
*/
|
|
2804
2801
|
async signTransaction(options) {
|
|
2805
|
-
logger$
|
|
2802
|
+
logger$h.info('Signing transaction', { options });
|
|
2806
2803
|
try {
|
|
2807
2804
|
const response = await this.channelService.signTransaction({
|
|
2808
2805
|
accountAddress: options.accountAddress,
|
|
@@ -2810,7 +2807,7 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2810
2807
|
ledgerId: options.ledgerId,
|
|
2811
2808
|
networkId: options.networkId,
|
|
2812
2809
|
});
|
|
2813
|
-
logger$
|
|
2810
|
+
logger$h.info('Transaction signed');
|
|
2814
2811
|
return {
|
|
2815
2812
|
signedPayload: response.signedPayload || '',
|
|
2816
2813
|
signature: response.signature,
|
|
@@ -2818,7 +2815,7 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2818
2815
|
};
|
|
2819
2816
|
}
|
|
2820
2817
|
catch (error) {
|
|
2821
|
-
logger$
|
|
2818
|
+
logger$h.error('Transaction signing failed', { error });
|
|
2822
2819
|
throw error;
|
|
2823
2820
|
}
|
|
2824
2821
|
}
|
|
@@ -2842,7 +2839,7 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2842
2839
|
* @throws {Error} If transaction submission fails
|
|
2843
2840
|
*/
|
|
2844
2841
|
async signAndExecuteTransaction(options) {
|
|
2845
|
-
logger$
|
|
2842
|
+
logger$h.info('signAndExecuteTransaction called (single prompt)', {
|
|
2846
2843
|
accountAddress: options.accountAddress,
|
|
2847
2844
|
ledgerId: options.ledgerId,
|
|
2848
2845
|
networkId: options.networkId,
|
|
@@ -2879,7 +2876,7 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2879
2876
|
* @param options
|
|
2880
2877
|
*/
|
|
2881
2878
|
async submitTransactionInternal(options) {
|
|
2882
|
-
logger$
|
|
2879
|
+
logger$h.info('Signing and submitting transaction (single prompt)', {
|
|
2883
2880
|
accountAddress: options.accountAddress,
|
|
2884
2881
|
ledgerId: options.ledgerId,
|
|
2885
2882
|
networkId: options.networkId,
|
|
@@ -2897,7 +2894,7 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2897
2894
|
innerTransactions: options.innerTransactions,
|
|
2898
2895
|
}),
|
|
2899
2896
|
});
|
|
2900
|
-
logger$
|
|
2897
|
+
logger$h.info('Transaction signed and submitted successfully', {
|
|
2901
2898
|
transactionId: response.transactionId,
|
|
2902
2899
|
transactionHash: response.transactionHash?.substring(0, 16),
|
|
2903
2900
|
});
|
|
@@ -2908,7 +2905,7 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2908
2905
|
};
|
|
2909
2906
|
}
|
|
2910
2907
|
catch (error) {
|
|
2911
|
-
logger$
|
|
2908
|
+
logger$h.error('Transaction sign+submit failed', { error });
|
|
2912
2909
|
throw error;
|
|
2913
2910
|
}
|
|
2914
2911
|
}
|
|
@@ -2930,7 +2927,7 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2930
2927
|
* @throws {Error} If wallet is not connected
|
|
2931
2928
|
*/
|
|
2932
2929
|
async signMessage(options) {
|
|
2933
|
-
logger$
|
|
2930
|
+
logger$h.info('Signing message', {
|
|
2934
2931
|
accountAddress: options.accountAddress,
|
|
2935
2932
|
encoding: options.encoding,
|
|
2936
2933
|
messageLength: options.message?.length,
|
|
@@ -2943,7 +2940,7 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2943
2940
|
ledgerId: options.ledgerId,
|
|
2944
2941
|
networkId: options.networkId,
|
|
2945
2942
|
});
|
|
2946
|
-
logger$
|
|
2943
|
+
logger$h.info('Message signed successfully', {
|
|
2947
2944
|
algorithm: response.algorithm,
|
|
2948
2945
|
caipChainId: response.caipChainId,
|
|
2949
2946
|
});
|
|
@@ -2960,7 +2957,7 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2960
2957
|
};
|
|
2961
2958
|
}
|
|
2962
2959
|
catch (error) {
|
|
2963
|
-
logger$
|
|
2960
|
+
logger$h.error('Message signing failed', { error });
|
|
2964
2961
|
throw error;
|
|
2965
2962
|
}
|
|
2966
2963
|
}
|
|
@@ -2992,7 +2989,7 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
2992
2989
|
* @returns Promise resolving to true if reconnection succeeded, false otherwise
|
|
2993
2990
|
*/
|
|
2994
2991
|
async attemptReconnect() {
|
|
2995
|
-
logger$
|
|
2992
|
+
logger$h.info('Attempting reconnect via unified channel');
|
|
2996
2993
|
try {
|
|
2997
2994
|
const success = await this.channelService.attemptRestore();
|
|
2998
2995
|
if (success) {
|
|
@@ -3005,15 +3002,15 @@ class HsuiteNativeProvider extends BaseWalletProvider {
|
|
|
3005
3002
|
metadata: { autoReconnected: true },
|
|
3006
3003
|
timestamp: Date.now(),
|
|
3007
3004
|
});
|
|
3008
|
-
logger$
|
|
3005
|
+
logger$h.info('Reconnect successful');
|
|
3009
3006
|
}
|
|
3010
3007
|
else {
|
|
3011
|
-
logger$
|
|
3008
|
+
logger$h.warn('Reconnect failed - no session or unable to connect');
|
|
3012
3009
|
}
|
|
3013
3010
|
return success;
|
|
3014
3011
|
}
|
|
3015
3012
|
catch (error) {
|
|
3016
|
-
logger$
|
|
3013
|
+
logger$h.error('Reconnect failed', { error });
|
|
3017
3014
|
return false;
|
|
3018
3015
|
}
|
|
3019
3016
|
}
|
|
@@ -3048,7 +3045,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
3048
3045
|
* Implements the IWalletConnectSigner interface for Hedera ledger.
|
|
3049
3046
|
* Handles Hedera-specific JSON-RPC methods and transaction formats.
|
|
3050
3047
|
*/
|
|
3051
|
-
const logger$
|
|
3048
|
+
const logger$g = getLogger().scoped?.('HederaSigner') ?? getLogger();
|
|
3052
3049
|
/**
|
|
3053
3050
|
* Extract a meaningful error message from various error shapes.
|
|
3054
3051
|
* WalletConnect SDK throws errors that are not standard Error instances.
|
|
@@ -3066,7 +3063,7 @@ const logger$h = getLogger().scoped?.('HederaSigner') ?? getLogger();
|
|
|
3066
3063
|
*/
|
|
3067
3064
|
function extractErrorMessage$1(error) {
|
|
3068
3065
|
// Log the raw error for debugging
|
|
3069
|
-
logger$
|
|
3066
|
+
logger$g.debug('Extracting error message', {
|
|
3070
3067
|
errorType: typeof error,
|
|
3071
3068
|
isError: error instanceof Error,
|
|
3072
3069
|
constructorName: error?.constructor?.name,
|
|
@@ -3104,7 +3101,7 @@ function extractErrorMessage$1(error) {
|
|
|
3104
3101
|
propDebug[prop] = '[err]';
|
|
3105
3102
|
}
|
|
3106
3103
|
}
|
|
3107
|
-
logger$
|
|
3104
|
+
logger$g.error('WC Error object dump', propDebug);
|
|
3108
3105
|
// Check for code property first (common in SDK errors like PIN_REQUIRED)
|
|
3109
3106
|
if (typeof errorObj['code'] === 'string') {
|
|
3110
3107
|
const codeMsg = errorObj['message']
|
|
@@ -3185,7 +3182,7 @@ function extractErrorMessage$1(error) {
|
|
|
3185
3182
|
}
|
|
3186
3183
|
// Try getting own property names (includes non-enumerable)
|
|
3187
3184
|
const ownProps = Object.getOwnPropertyNames(errorObj);
|
|
3188
|
-
logger$
|
|
3185
|
+
logger$g.debug('Error object properties', { props: ownProps });
|
|
3189
3186
|
if (ownProps.length > 0) {
|
|
3190
3187
|
// Try to read ALL properties for better debugging
|
|
3191
3188
|
const propValues = [];
|
|
@@ -3206,7 +3203,7 @@ function extractErrorMessage$1(error) {
|
|
|
3206
3203
|
propValues.push(k);
|
|
3207
3204
|
}
|
|
3208
3205
|
}
|
|
3209
|
-
logger$
|
|
3206
|
+
logger$g.debug('Error property values', { values: propValues });
|
|
3210
3207
|
// Return a more informative error
|
|
3211
3208
|
return `Error with properties: ${propValues.slice(0, 5).join(', ')}`;
|
|
3212
3209
|
}
|
|
@@ -3219,7 +3216,7 @@ function extractErrorMessage$1(error) {
|
|
|
3219
3216
|
}
|
|
3220
3217
|
}
|
|
3221
3218
|
// Last resort - log what we know about the object
|
|
3222
|
-
logger$
|
|
3219
|
+
logger$g.warn('Could not extract error message', {
|
|
3223
3220
|
constructor: error?.constructor?.name,
|
|
3224
3221
|
prototype: Object.getPrototypeOf(error)?.constructor?.name,
|
|
3225
3222
|
});
|
|
@@ -3318,13 +3315,13 @@ class HederaSigner {
|
|
|
3318
3315
|
Object.keys(error).length === 0 &&
|
|
3319
3316
|
!(error instanceof Error);
|
|
3320
3317
|
if (isEmptyError) {
|
|
3321
|
-
logger$
|
|
3318
|
+
logger$g.warn('WalletConnect SDK empty error - relay subscription may have been stale', {
|
|
3322
3319
|
topic: params.topic?.substring(0, 16) + '...',
|
|
3323
3320
|
});
|
|
3324
3321
|
throw new Error('WalletConnect connection issue - please try again');
|
|
3325
3322
|
}
|
|
3326
3323
|
const errorMsg = extractErrorMessage$1(error);
|
|
3327
|
-
logger$
|
|
3324
|
+
logger$g.error('Sign failed', { error: errorMsg });
|
|
3328
3325
|
throw new Error(`Hedera sign failed: ${errorMsg}`);
|
|
3329
3326
|
}
|
|
3330
3327
|
}
|
|
@@ -3340,7 +3337,7 @@ class HederaSigner {
|
|
|
3340
3337
|
const network = params.networkId.includes('mainnet') ? 'mainnet' : 'testnet';
|
|
3341
3338
|
// Format account ID in HIP-30 format
|
|
3342
3339
|
const signerAccountId = `hedera:${network}:${params.accountAddress}`;
|
|
3343
|
-
logger$
|
|
3340
|
+
logger$g.debug('Sending hedera_signAndExecuteTransaction request', {
|
|
3344
3341
|
topic: params.topic?.substring(0, 16) + '...',
|
|
3345
3342
|
chainId: `hedera:${network}`,
|
|
3346
3343
|
signerAccountId,
|
|
@@ -3368,7 +3365,7 @@ class HederaSigner {
|
|
|
3368
3365
|
try {
|
|
3369
3366
|
// Race between the request and our timeout
|
|
3370
3367
|
const result = await Promise.race([requestPromise, timeoutPromise]);
|
|
3371
|
-
logger$
|
|
3368
|
+
logger$g.debug('Received hedera_signAndExecuteTransaction response', {
|
|
3372
3369
|
hasResult: !!result,
|
|
3373
3370
|
resultKeys: result ? Object.keys(result) : [],
|
|
3374
3371
|
});
|
|
@@ -3401,7 +3398,7 @@ class HederaSigner {
|
|
|
3401
3398
|
// Get all own property names
|
|
3402
3399
|
ownProps: error && typeof error === 'object' ? Object.getOwnPropertyNames(error) : [],
|
|
3403
3400
|
};
|
|
3404
|
-
logger$
|
|
3401
|
+
logger$g.error('Submit failed - full error analysis', errorInfo);
|
|
3405
3402
|
// Check if this is an empty error object (WalletConnect SDK bug)
|
|
3406
3403
|
// This typically happens when relay subscription is stale
|
|
3407
3404
|
const isEmptyError = typeof error === 'object' &&
|
|
@@ -3413,7 +3410,7 @@ class HederaSigner {
|
|
|
3413
3410
|
// It usually means the relay subscription was stale
|
|
3414
3411
|
// The SessionHealthManager should have pinged before the request,
|
|
3415
3412
|
// but if we still get this error, the subscription dropped after the ping
|
|
3416
|
-
logger$
|
|
3413
|
+
logger$g.warn('WalletConnect SDK empty error - relay subscription may have been stale', {
|
|
3417
3414
|
topic: params.topic?.substring(0, 16) + '...',
|
|
3418
3415
|
hint: 'This can happen when the relay WebSocket connection drops',
|
|
3419
3416
|
});
|
|
@@ -3423,7 +3420,7 @@ class HederaSigner {
|
|
|
3423
3420
|
'please check your transaction history as it may have been executed successfully.');
|
|
3424
3421
|
}
|
|
3425
3422
|
const errorMsg = extractErrorMessage$1(error);
|
|
3426
|
-
logger$
|
|
3423
|
+
logger$g.error('Submit failed', { error: errorMsg });
|
|
3427
3424
|
throw new Error(`Hedera submit failed: ${errorMsg}`);
|
|
3428
3425
|
}
|
|
3429
3426
|
}
|
|
@@ -3480,13 +3477,13 @@ class HederaSigner {
|
|
|
3480
3477
|
Object.keys(error).length === 0 &&
|
|
3481
3478
|
!(error instanceof Error);
|
|
3482
3479
|
if (isEmptyError) {
|
|
3483
|
-
logger$
|
|
3480
|
+
logger$g.warn('WalletConnect SDK empty error - relay subscription may have been stale', {
|
|
3484
3481
|
topic: params.topic?.substring(0, 16) + '...',
|
|
3485
3482
|
});
|
|
3486
3483
|
throw new Error('WalletConnect connection issue - please try again');
|
|
3487
3484
|
}
|
|
3488
3485
|
const errorMsg = extractErrorMessage$1(error);
|
|
3489
|
-
logger$
|
|
3486
|
+
logger$g.error('Sign message failed', { error: errorMsg });
|
|
3490
3487
|
throw new Error(`Hedera sign message failed: ${errorMsg}`);
|
|
3491
3488
|
}
|
|
3492
3489
|
}
|
|
@@ -3504,15 +3501,15 @@ class HederaSigner {
|
|
|
3504
3501
|
*/
|
|
3505
3502
|
parseAccounts(namespace, targetNetworkId) {
|
|
3506
3503
|
if (!namespace) {
|
|
3507
|
-
logger$
|
|
3504
|
+
logger$g.warn('Namespace is null or undefined');
|
|
3508
3505
|
return [];
|
|
3509
3506
|
}
|
|
3510
3507
|
if (!namespace.accounts) {
|
|
3511
|
-
logger$
|
|
3508
|
+
logger$g.warn('Namespace has no accounts property');
|
|
3512
3509
|
return [];
|
|
3513
3510
|
}
|
|
3514
3511
|
if (!Array.isArray(namespace.accounts)) {
|
|
3515
|
-
logger$
|
|
3512
|
+
logger$g.warn('Namespace accounts is not an array', {
|
|
3516
3513
|
type: typeof namespace.accounts,
|
|
3517
3514
|
});
|
|
3518
3515
|
return [];
|
|
@@ -3522,7 +3519,7 @@ class HederaSigner {
|
|
|
3522
3519
|
// HIP-30 format: hedera:testnet:0.0.12345
|
|
3523
3520
|
const parts = account.split(':');
|
|
3524
3521
|
if (parts.length < 3) {
|
|
3525
|
-
logger$
|
|
3522
|
+
logger$g.warn('Invalid account format', { account, partsLength: parts.length });
|
|
3526
3523
|
return { address: account, chainId: 'hedera:testnet' };
|
|
3527
3524
|
}
|
|
3528
3525
|
return {
|
|
@@ -3535,7 +3532,7 @@ class HederaSigner {
|
|
|
3535
3532
|
const targetNetwork = targetNetworkId.split(':')[1]?.toLowerCase(); // e.g., 'mainnet'
|
|
3536
3533
|
if (targetNetwork) {
|
|
3537
3534
|
const filteredAccounts = allAccounts.filter((acc) => acc.chainId.toLowerCase().includes(targetNetwork));
|
|
3538
|
-
logger$
|
|
3535
|
+
logger$g.debug('Filtered accounts by target network', {
|
|
3539
3536
|
targetNetworkId,
|
|
3540
3537
|
targetNetwork,
|
|
3541
3538
|
totalAccounts: allAccounts.length,
|
|
@@ -3543,7 +3540,7 @@ class HederaSigner {
|
|
|
3543
3540
|
});
|
|
3544
3541
|
// If no accounts match the target network, log a warning
|
|
3545
3542
|
if (filteredAccounts.length === 0 && allAccounts.length > 0) {
|
|
3546
|
-
logger$
|
|
3543
|
+
logger$g.warn('No accounts found for target network', {
|
|
3547
3544
|
targetNetwork,
|
|
3548
3545
|
availableNetworks: [...new Set(allAccounts.map((a) => a.chainId))],
|
|
3549
3546
|
});
|
|
@@ -3571,7 +3568,7 @@ class HederaSigner {
|
|
|
3571
3568
|
* Implements the IWalletConnectSigner interface for XRPL ledger.
|
|
3572
3569
|
* Handles XRPL-specific JSON-RPC methods and transaction formats.
|
|
3573
3570
|
*/
|
|
3574
|
-
const logger$
|
|
3571
|
+
const logger$f = getLogger().scoped?.('XrplSigner') ?? getLogger();
|
|
3575
3572
|
/**
|
|
3576
3573
|
* Extract a meaningful error message from various error shapes.
|
|
3577
3574
|
* WalletConnect SDK throws errors that are not standard Error instances.
|
|
@@ -3589,7 +3586,7 @@ const logger$g = getLogger().scoped?.('XrplSigner') ?? getLogger();
|
|
|
3589
3586
|
*/
|
|
3590
3587
|
function extractErrorMessage(error) {
|
|
3591
3588
|
// Log raw error for debugging
|
|
3592
|
-
logger$
|
|
3589
|
+
logger$f.debug('Raw error object', {
|
|
3593
3590
|
errorType: typeof error,
|
|
3594
3591
|
isError: error instanceof Error,
|
|
3595
3592
|
errorKeys: typeof error === 'object' && error !== null ? Object.keys(error) : [],
|
|
@@ -3725,7 +3722,7 @@ class XrplSigner {
|
|
|
3725
3722
|
*/
|
|
3726
3723
|
async signTransaction(params) {
|
|
3727
3724
|
// Decode base64 payload to JSON transaction
|
|
3728
|
-
logger$
|
|
3725
|
+
logger$f.debug('Decoding XRPL transaction payload', {
|
|
3729
3726
|
payloadLength: params.payload?.length,
|
|
3730
3727
|
networkId: params.networkId,
|
|
3731
3728
|
topic: params.topic?.substring(0, 16) + '...',
|
|
@@ -3733,19 +3730,19 @@ class XrplSigner {
|
|
|
3733
3730
|
let transaction;
|
|
3734
3731
|
try {
|
|
3735
3732
|
transaction = XrplTransactionEncoder.decodeTransaction(params.payload);
|
|
3736
|
-
logger$
|
|
3733
|
+
logger$f.debug('Transaction decoded successfully', {
|
|
3737
3734
|
transactionType: transaction?.TransactionType,
|
|
3738
3735
|
account: transaction?.Account,
|
|
3739
3736
|
});
|
|
3740
3737
|
}
|
|
3741
3738
|
catch (decodeError) {
|
|
3742
|
-
logger$
|
|
3739
|
+
logger$f.error('Failed to decode transaction payload', {
|
|
3743
3740
|
error: decodeError instanceof Error ? decodeError.message : String(decodeError),
|
|
3744
3741
|
});
|
|
3745
3742
|
throw decodeError;
|
|
3746
3743
|
}
|
|
3747
3744
|
try {
|
|
3748
|
-
logger$
|
|
3745
|
+
logger$f.debug('Sending xrpl_signTransaction request to wallet', {
|
|
3749
3746
|
method: 'xrpl_signTransaction',
|
|
3750
3747
|
chainId: params.networkId,
|
|
3751
3748
|
topic: params.topic?.substring(0, 16) + '...',
|
|
@@ -3762,7 +3759,7 @@ class XrplSigner {
|
|
|
3762
3759
|
},
|
|
3763
3760
|
expiry: 300, // 5 minutes in seconds
|
|
3764
3761
|
});
|
|
3765
|
-
logger$
|
|
3762
|
+
logger$f.debug('Received response from wallet', {
|
|
3766
3763
|
hasResult: !!result,
|
|
3767
3764
|
resultKeys: result ? Object.keys(result) : [],
|
|
3768
3765
|
});
|
|
@@ -3778,13 +3775,13 @@ class XrplSigner {
|
|
|
3778
3775
|
Object.keys(error).length === 0 &&
|
|
3779
3776
|
!(error instanceof Error);
|
|
3780
3777
|
if (isEmptyError) {
|
|
3781
|
-
logger$
|
|
3778
|
+
logger$f.warn('WalletConnect SDK empty error - relay subscription may have been stale', {
|
|
3782
3779
|
topic: params.topic?.substring(0, 16) + '...',
|
|
3783
3780
|
});
|
|
3784
3781
|
throw new Error('WalletConnect connection issue - please try again');
|
|
3785
3782
|
}
|
|
3786
3783
|
const errorMsg = extractErrorMessage(error);
|
|
3787
|
-
logger$
|
|
3784
|
+
logger$f.error('Sign failed', { error: errorMsg });
|
|
3788
3785
|
throw new Error(`XRPL sign failed: ${errorMsg}`);
|
|
3789
3786
|
}
|
|
3790
3787
|
}
|
|
@@ -3799,7 +3796,7 @@ class XrplSigner {
|
|
|
3799
3796
|
// Decode base64 payload to JSON transaction
|
|
3800
3797
|
const transaction = XrplTransactionEncoder.decodeTransaction(params.payload);
|
|
3801
3798
|
try {
|
|
3802
|
-
logger$
|
|
3799
|
+
logger$f.debug('Sending xrpl_signAndSubmit request to wallet', {
|
|
3803
3800
|
method: 'xrpl_signAndSubmit',
|
|
3804
3801
|
chainId: params.networkId,
|
|
3805
3802
|
topic: params.topic?.substring(0, 16) + '...',
|
|
@@ -3816,7 +3813,7 @@ class XrplSigner {
|
|
|
3816
3813
|
},
|
|
3817
3814
|
expiry: 300, // 5 minutes in seconds
|
|
3818
3815
|
});
|
|
3819
|
-
logger$
|
|
3816
|
+
logger$f.debug('Received xrpl_signAndSubmit response', {
|
|
3820
3817
|
hasResult: !!result,
|
|
3821
3818
|
resultKeys: result ? Object.keys(result) : [],
|
|
3822
3819
|
});
|
|
@@ -3838,14 +3835,14 @@ class XrplSigner {
|
|
|
3838
3835
|
if (isEmptyError) {
|
|
3839
3836
|
// Empty error object is a known WalletConnect SDK issue
|
|
3840
3837
|
// It usually means the relay subscription was stale
|
|
3841
|
-
logger$
|
|
3838
|
+
logger$f.warn('WalletConnect SDK empty error - relay subscription may have been stale', {
|
|
3842
3839
|
topic: params.topic?.substring(0, 16) + '...',
|
|
3843
3840
|
hint: 'This can happen when the relay WebSocket connection drops',
|
|
3844
3841
|
});
|
|
3845
3842
|
throw new Error('WalletConnect connection issue - please try again');
|
|
3846
3843
|
}
|
|
3847
3844
|
const errorMsg = extractErrorMessage(error);
|
|
3848
|
-
logger$
|
|
3845
|
+
logger$f.error('Submit failed', { error: errorMsg });
|
|
3849
3846
|
throw new Error(`XRPL submit failed: ${errorMsg}`);
|
|
3850
3847
|
}
|
|
3851
3848
|
}
|
|
@@ -3895,13 +3892,13 @@ class XrplSigner {
|
|
|
3895
3892
|
Object.keys(error).length === 0 &&
|
|
3896
3893
|
!(error instanceof Error);
|
|
3897
3894
|
if (isEmptyError) {
|
|
3898
|
-
logger$
|
|
3895
|
+
logger$f.warn('WalletConnect SDK empty error - relay subscription may have been stale', {
|
|
3899
3896
|
topic: params.topic?.substring(0, 16) + '...',
|
|
3900
3897
|
});
|
|
3901
3898
|
throw new Error('WalletConnect connection issue - please try again');
|
|
3902
3899
|
}
|
|
3903
3900
|
const errorMsg = extractErrorMessage(error);
|
|
3904
|
-
logger$
|
|
3901
|
+
logger$f.error('Sign message failed', { error: errorMsg });
|
|
3905
3902
|
throw new Error(`XRPL sign message failed: ${errorMsg}`);
|
|
3906
3903
|
}
|
|
3907
3904
|
}
|
|
@@ -3926,7 +3923,7 @@ class XrplSigner {
|
|
|
3926
3923
|
// XRPL format: xrpl:testnet:rN7n7otQDd6FczFgLdlqtyMVrn3WnFBrDB
|
|
3927
3924
|
const parts = account.split(':');
|
|
3928
3925
|
if (parts.length < 3) {
|
|
3929
|
-
logger$
|
|
3926
|
+
logger$f.warn('Invalid account format', { account });
|
|
3930
3927
|
return { address: account, chainId: 'xrpl:testnet' };
|
|
3931
3928
|
}
|
|
3932
3929
|
return {
|
|
@@ -3939,7 +3936,7 @@ class XrplSigner {
|
|
|
3939
3936
|
const targetNetwork = targetNetworkId.split(':')[1]?.toLowerCase(); // e.g., 'mainnet'
|
|
3940
3937
|
if (targetNetwork) {
|
|
3941
3938
|
const filteredAccounts = allAccounts.filter((acc) => acc.chainId.toLowerCase().includes(targetNetwork));
|
|
3942
|
-
logger$
|
|
3939
|
+
logger$f.debug('Filtered accounts by target network', {
|
|
3943
3940
|
targetNetworkId,
|
|
3944
3941
|
targetNetwork,
|
|
3945
3942
|
totalAccounts: allAccounts.length,
|
|
@@ -3947,7 +3944,7 @@ class XrplSigner {
|
|
|
3947
3944
|
});
|
|
3948
3945
|
// If no accounts match the target network, log a warning
|
|
3949
3946
|
if (filteredAccounts.length === 0 && allAccounts.length > 0) {
|
|
3950
|
-
logger$
|
|
3947
|
+
logger$f.warn('No accounts found for target network', {
|
|
3951
3948
|
targetNetwork,
|
|
3952
3949
|
availableNetworks: [...new Set(allAccounts.map((a) => a.chainId))],
|
|
3953
3950
|
});
|
|
@@ -3979,7 +3976,7 @@ class XrplSigner {
|
|
|
3979
3976
|
* 1. Implementing IWalletConnectSigner interface
|
|
3980
3977
|
* 2. Registering the signer with SignerFactory
|
|
3981
3978
|
*/
|
|
3982
|
-
const logger$
|
|
3979
|
+
const logger$e = getLogger().scoped?.('SignerFactory') ?? getLogger();
|
|
3983
3980
|
/**
|
|
3984
3981
|
* Factory class for creating and managing WalletConnect signers.
|
|
3985
3982
|
*
|
|
@@ -4021,13 +4018,13 @@ class SignerFactory {
|
|
|
4021
4018
|
*/
|
|
4022
4019
|
static registerSigner(ledgerId, signer) {
|
|
4023
4020
|
if (signer.ledgerId !== ledgerId) {
|
|
4024
|
-
logger$
|
|
4021
|
+
logger$e.warn('Signer ledgerId does not match registration key', {
|
|
4025
4022
|
signerLedgerId: signer.ledgerId,
|
|
4026
4023
|
registrationKey: ledgerId,
|
|
4027
4024
|
});
|
|
4028
4025
|
}
|
|
4029
4026
|
this.signers.set(ledgerId, signer);
|
|
4030
|
-
logger$
|
|
4027
|
+
logger$e.debug('Registered signer for ledger', { ledgerId });
|
|
4031
4028
|
}
|
|
4032
4029
|
/**
|
|
4033
4030
|
* Check if a signer is registered for a ledger.
|
|
@@ -4056,7 +4053,7 @@ class SignerFactory {
|
|
|
4056
4053
|
static unregisterSigner(ledgerId) {
|
|
4057
4054
|
const removed = this.signers.delete(ledgerId);
|
|
4058
4055
|
if (removed) {
|
|
4059
|
-
logger$
|
|
4056
|
+
logger$e.debug('Unregistered signer for ledger', { ledgerId });
|
|
4060
4057
|
}
|
|
4061
4058
|
return removed;
|
|
4062
4059
|
}
|
|
@@ -4085,7 +4082,7 @@ class SignerFactory {
|
|
|
4085
4082
|
* - Automatic ping cache management
|
|
4086
4083
|
* - Subscription refresh capability
|
|
4087
4084
|
*/
|
|
4088
|
-
const logger$
|
|
4085
|
+
const logger$d = getLogger().scoped?.('WCSessionHealth') ?? getLogger();
|
|
4089
4086
|
/**
|
|
4090
4087
|
* Manages WalletConnect session health to prevent stale relay subscription issues.
|
|
4091
4088
|
*
|
|
@@ -4116,7 +4113,7 @@ class SessionHealthManager {
|
|
|
4116
4113
|
constructor(client) {
|
|
4117
4114
|
this.client = client;
|
|
4118
4115
|
this.setupRelayMonitoring();
|
|
4119
|
-
logger$
|
|
4116
|
+
logger$d.info('SessionHealthManager initialized');
|
|
4120
4117
|
}
|
|
4121
4118
|
/**
|
|
4122
4119
|
* Ensure session is healthy before making a request.
|
|
@@ -4134,14 +4131,14 @@ class SessionHealthManager {
|
|
|
4134
4131
|
const now = Date.now();
|
|
4135
4132
|
// Skip if we pinged recently
|
|
4136
4133
|
if (now - lastPing <= this.PING_INTERVAL_MS) {
|
|
4137
|
-
logger$
|
|
4134
|
+
logger$d.debug('Skipping ping - recent ping exists', {
|
|
4138
4135
|
topic: topic.substring(0, 16) + '...',
|
|
4139
4136
|
lastPingAge: now - lastPing,
|
|
4140
4137
|
});
|
|
4141
4138
|
return;
|
|
4142
4139
|
}
|
|
4143
4140
|
try {
|
|
4144
|
-
logger$
|
|
4141
|
+
logger$d.debug('Pinging session to ensure relay subscription', {
|
|
4145
4142
|
topic: topic.substring(0, 16) + '...',
|
|
4146
4143
|
});
|
|
4147
4144
|
// Race ping against timeout
|
|
@@ -4150,14 +4147,14 @@ class SessionHealthManager {
|
|
|
4150
4147
|
new Promise((_, reject) => setTimeout(() => reject(new Error('Ping timeout')), this.PING_TIMEOUT_MS)),
|
|
4151
4148
|
]);
|
|
4152
4149
|
this.lastPingTime.set(topic, now);
|
|
4153
|
-
logger$
|
|
4150
|
+
logger$d.debug('Session ping successful', {
|
|
4154
4151
|
topic: topic.substring(0, 16) + '...',
|
|
4155
4152
|
});
|
|
4156
4153
|
}
|
|
4157
4154
|
catch (err) {
|
|
4158
4155
|
// Log warning but don't throw - let the request attempt proceed
|
|
4159
4156
|
// The request might still succeed if the subscription is actually active
|
|
4160
|
-
logger$
|
|
4157
|
+
logger$d.warn('Session ping failed - relay subscription may be stale', {
|
|
4161
4158
|
topic: topic.substring(0, 16) + '...',
|
|
4162
4159
|
error: err instanceof Error ? err.message : String(err),
|
|
4163
4160
|
});
|
|
@@ -4179,16 +4176,16 @@ class SessionHealthManager {
|
|
|
4179
4176
|
await relayer.subscribe(topic);
|
|
4180
4177
|
// Clear ping cache so next ensureSessionHealth will ping
|
|
4181
4178
|
this.lastPingTime.delete(topic);
|
|
4182
|
-
logger$
|
|
4179
|
+
logger$d.info('Refreshed relay subscription', {
|
|
4183
4180
|
topic: topic.substring(0, 16) + '...',
|
|
4184
4181
|
});
|
|
4185
4182
|
}
|
|
4186
4183
|
else {
|
|
4187
|
-
logger$
|
|
4184
|
+
logger$d.warn('Relayer.subscribe not available');
|
|
4188
4185
|
}
|
|
4189
4186
|
}
|
|
4190
4187
|
catch (err) {
|
|
4191
|
-
logger$
|
|
4188
|
+
logger$d.warn('Failed to refresh subscription', {
|
|
4192
4189
|
topic: topic.substring(0, 16) + '...',
|
|
4193
4190
|
error: err instanceof Error ? err.message : String(err),
|
|
4194
4191
|
});
|
|
@@ -4221,22 +4218,22 @@ class SessionHealthManager {
|
|
|
4221
4218
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- WalletConnect internal API not typed
|
|
4222
4219
|
const relayer = this.client.core?.relayer;
|
|
4223
4220
|
if (!relayer) {
|
|
4224
|
-
logger$
|
|
4221
|
+
logger$d.warn('Could not access relayer for monitoring');
|
|
4225
4222
|
return;
|
|
4226
4223
|
}
|
|
4227
4224
|
relayer.on('connect', () => {
|
|
4228
|
-
logger$
|
|
4225
|
+
logger$d.info('Relay WebSocket connected');
|
|
4229
4226
|
});
|
|
4230
4227
|
relayer.on('disconnect', () => {
|
|
4231
|
-
logger$
|
|
4228
|
+
logger$d.warn('Relay WebSocket disconnected - clearing ping cache');
|
|
4232
4229
|
this.lastPingTime.clear();
|
|
4233
4230
|
});
|
|
4234
4231
|
relayer.on('error', (err) => {
|
|
4235
|
-
logger$
|
|
4232
|
+
logger$d.error('Relay error', {
|
|
4236
4233
|
error: err?.message || String(err),
|
|
4237
4234
|
});
|
|
4238
4235
|
});
|
|
4239
|
-
logger$
|
|
4236
|
+
logger$d.debug('Relay monitoring setup complete');
|
|
4240
4237
|
}
|
|
4241
4238
|
}
|
|
4242
4239
|
|
|
@@ -4261,7 +4258,7 @@ class SessionHealthManager {
|
|
|
4261
4258
|
*
|
|
4262
4259
|
* Extracted from WalletConnectV2Provider to reduce file size.
|
|
4263
4260
|
*/
|
|
4264
|
-
const logger$
|
|
4261
|
+
const logger$c = getLogger().scoped?.('WCClientManager') ?? getLogger();
|
|
4265
4262
|
/**
|
|
4266
4263
|
* Storage key for persisted projectId
|
|
4267
4264
|
*/
|
|
@@ -4288,7 +4285,7 @@ class WalletConnectClientManager {
|
|
|
4288
4285
|
if (this.client && this.projectId === projectId) {
|
|
4289
4286
|
return this.client;
|
|
4290
4287
|
}
|
|
4291
|
-
logger$
|
|
4288
|
+
logger$c.debug('Initializing SignClient', { projectId: projectId.substring(0, 8) });
|
|
4292
4289
|
// Store projectId for session restoration
|
|
4293
4290
|
this.projectId = projectId;
|
|
4294
4291
|
this.persistProjectId(projectId);
|
|
@@ -4300,7 +4297,7 @@ class WalletConnectClientManager {
|
|
|
4300
4297
|
});
|
|
4301
4298
|
// Initialize session health manager for relay subscription management
|
|
4302
4299
|
this.sessionHealth = new SessionHealthManager(this.client);
|
|
4303
|
-
logger$
|
|
4300
|
+
logger$c.info('SignClient initialized with session health manager');
|
|
4304
4301
|
return this.client;
|
|
4305
4302
|
}
|
|
4306
4303
|
/**
|
|
@@ -4329,14 +4326,14 @@ class WalletConnectClientManager {
|
|
|
4329
4326
|
async restoreClient(metadata) {
|
|
4330
4327
|
const storedProjectId = this.getStoredProjectId();
|
|
4331
4328
|
if (!storedProjectId) {
|
|
4332
|
-
logger$
|
|
4329
|
+
logger$c.debug('No stored projectId, skipping client restoration');
|
|
4333
4330
|
return undefined;
|
|
4334
4331
|
}
|
|
4335
4332
|
try {
|
|
4336
4333
|
return await this.initialize(storedProjectId, metadata);
|
|
4337
4334
|
}
|
|
4338
4335
|
catch (error) {
|
|
4339
|
-
logger$
|
|
4336
|
+
logger$c.error('Failed to restore client', {
|
|
4340
4337
|
error: error instanceof Error ? error.message : String(error),
|
|
4341
4338
|
});
|
|
4342
4339
|
return undefined;
|
|
@@ -4403,7 +4400,7 @@ class WalletConnectClientManager {
|
|
|
4403
4400
|
if (sessionProperties) {
|
|
4404
4401
|
connectParams.sessionProperties = sessionProperties;
|
|
4405
4402
|
}
|
|
4406
|
-
logger$
|
|
4403
|
+
logger$c.debug('Connecting with params', {
|
|
4407
4404
|
namespaces: Object.keys(optionalNamespaces),
|
|
4408
4405
|
hasSessionProperties: !!sessionProperties,
|
|
4409
4406
|
});
|
|
@@ -4469,7 +4466,7 @@ class WalletConnectClientManager {
|
|
|
4469
4466
|
const startKeepAlive = () => {
|
|
4470
4467
|
keepAliveInterval = setInterval(async () => {
|
|
4471
4468
|
try {
|
|
4472
|
-
logger$
|
|
4469
|
+
logger$c.debug('Keep-alive ping during request', {
|
|
4473
4470
|
topic: params.topic?.substring(0, 16) + '...',
|
|
4474
4471
|
method: params.request.method,
|
|
4475
4472
|
});
|
|
@@ -4482,7 +4479,7 @@ class WalletConnectClientManager {
|
|
|
4482
4479
|
}
|
|
4483
4480
|
catch (err) {
|
|
4484
4481
|
// Log but don't throw - ping failure during wait is not critical
|
|
4485
|
-
logger$
|
|
4482
|
+
logger$c.debug('Keep-alive ping failed (non-critical)', {
|
|
4486
4483
|
error: err instanceof Error ? err.message : String(err),
|
|
4487
4484
|
});
|
|
4488
4485
|
}
|
|
@@ -4524,7 +4521,7 @@ class WalletConnectClientManager {
|
|
|
4524
4521
|
window.localStorage?.setItem(STORAGE_KEY_PROJECT_ID, projectId);
|
|
4525
4522
|
}
|
|
4526
4523
|
catch {
|
|
4527
|
-
logger$
|
|
4524
|
+
logger$c.warn('Failed to persist projectId');
|
|
4528
4525
|
}
|
|
4529
4526
|
}
|
|
4530
4527
|
getStoredProjectId() {
|
|
@@ -4569,7 +4566,7 @@ class WalletConnectClientManager {
|
|
|
4569
4566
|
* - Aggregate accounts across sessions
|
|
4570
4567
|
* - Find sessions by account address
|
|
4571
4568
|
*/
|
|
4572
|
-
const logger$
|
|
4569
|
+
const logger$b = getLogger().scoped?.('WCSessionStore') ?? getLogger();
|
|
4573
4570
|
/**
|
|
4574
4571
|
* WalletConnect Session Store
|
|
4575
4572
|
*
|
|
@@ -4607,7 +4604,7 @@ class WalletConnectSessionStore {
|
|
|
4607
4604
|
*/
|
|
4608
4605
|
setSession(sessionKey, data) {
|
|
4609
4606
|
this.sessions.set(sessionKey, data);
|
|
4610
|
-
logger$
|
|
4607
|
+
logger$b.debug('Session stored', { sessionKey, accountCount: data.accounts.length });
|
|
4611
4608
|
}
|
|
4612
4609
|
/**
|
|
4613
4610
|
* Delete a session by key.
|
|
@@ -4618,7 +4615,7 @@ class WalletConnectSessionStore {
|
|
|
4618
4615
|
deleteSession(sessionKey) {
|
|
4619
4616
|
const deleted = this.sessions.delete(sessionKey);
|
|
4620
4617
|
if (deleted) {
|
|
4621
|
-
logger$
|
|
4618
|
+
logger$b.debug('Session deleted', { sessionKey });
|
|
4622
4619
|
}
|
|
4623
4620
|
return deleted;
|
|
4624
4621
|
}
|
|
@@ -4642,7 +4639,7 @@ class WalletConnectSessionStore {
|
|
|
4642
4639
|
clear() {
|
|
4643
4640
|
this.sessions.clear();
|
|
4644
4641
|
this._accounts.set([]);
|
|
4645
|
-
logger$
|
|
4642
|
+
logger$b.debug('All sessions cleared');
|
|
4646
4643
|
}
|
|
4647
4644
|
/**
|
|
4648
4645
|
* Get all session entries.
|
|
@@ -4683,7 +4680,7 @@ class WalletConnectSessionStore {
|
|
|
4683
4680
|
for (const sessionData of this.sessions.values()) {
|
|
4684
4681
|
allAccounts.push(...sessionData.accounts);
|
|
4685
4682
|
}
|
|
4686
|
-
logger$
|
|
4683
|
+
logger$b.debug('Aggregated accounts', {
|
|
4687
4684
|
sessionCount: this.sessions.size,
|
|
4688
4685
|
totalAccounts: allAccounts.length,
|
|
4689
4686
|
});
|
|
@@ -4719,7 +4716,7 @@ class WalletConnectSessionStore {
|
|
|
4719
4716
|
for (const [sessionKey, sessionData] of this.sessions.entries()) {
|
|
4720
4717
|
if (sessionData.session.topic === topic) {
|
|
4721
4718
|
this.sessions.delete(sessionKey);
|
|
4722
|
-
logger$
|
|
4719
|
+
logger$b.info('Session removed by topic', { sessionKey, topic: topic.substring(0, 16) });
|
|
4723
4720
|
return { sessionKey, data: sessionData };
|
|
4724
4721
|
}
|
|
4725
4722
|
}
|
|
@@ -4767,7 +4764,7 @@ class WalletConnectSessionStore {
|
|
|
4767
4764
|
*
|
|
4768
4765
|
* Extracted from WalletConnectV2Provider to reduce file size.
|
|
4769
4766
|
*/
|
|
4770
|
-
const logger$
|
|
4767
|
+
const logger$a = getLogger().scoped?.('WCSigningOrchestrator') ?? getLogger();
|
|
4771
4768
|
/**
|
|
4772
4769
|
* Signing Orchestrator
|
|
4773
4770
|
*
|
|
@@ -4798,7 +4795,7 @@ class WalletConnectSigningOrchestrator {
|
|
|
4798
4795
|
const sessionInfo = this.findAndValidateSession(options.accountAddress, 'signTransaction');
|
|
4799
4796
|
// Use user's selected network from session, with fallback to options.networkId
|
|
4800
4797
|
const networkId = this.resolveNetworkId(sessionInfo, options.networkId);
|
|
4801
|
-
logger$
|
|
4798
|
+
logger$a.debug('Routing sign to signer', {
|
|
4802
4799
|
ledgerId: sessionInfo.signer.ledgerId,
|
|
4803
4800
|
topic: sessionInfo.session.topic.substring(0, 16) + '...',
|
|
4804
4801
|
networkId,
|
|
@@ -4821,7 +4818,7 @@ class WalletConnectSigningOrchestrator {
|
|
|
4821
4818
|
const sessionInfo = this.findAndValidateSession(options.accountAddress, 'submitTransaction');
|
|
4822
4819
|
// Use user's selected network from session, with fallback to options.networkId
|
|
4823
4820
|
const networkId = this.resolveNetworkId(sessionInfo, options.networkId);
|
|
4824
|
-
logger$
|
|
4821
|
+
logger$a.debug('Routing submit to signer', {
|
|
4825
4822
|
ledgerId: sessionInfo.signer.ledgerId,
|
|
4826
4823
|
topic: sessionInfo.session.topic.substring(0, 16) + '...',
|
|
4827
4824
|
networkId,
|
|
@@ -4844,7 +4841,7 @@ class WalletConnectSigningOrchestrator {
|
|
|
4844
4841
|
const sessionInfo = this.findAndValidateSession(options.accountAddress, 'signAndExecuteTransaction');
|
|
4845
4842
|
// Use user's selected network from session, with fallback to options.networkId
|
|
4846
4843
|
const networkId = this.resolveNetworkId(sessionInfo, options.networkId);
|
|
4847
|
-
logger$
|
|
4844
|
+
logger$a.debug('Routing signAndExecute to signer', {
|
|
4848
4845
|
ledgerId: sessionInfo.signer.ledgerId,
|
|
4849
4846
|
topic: sessionInfo.session.topic.substring(0, 16) + '...',
|
|
4850
4847
|
networkId,
|
|
@@ -4885,7 +4882,7 @@ class WalletConnectSigningOrchestrator {
|
|
|
4885
4882
|
const sessionInfo = this.findAndValidateSession(options.accountAddress, 'signMessage');
|
|
4886
4883
|
// Use user's selected network from session, with fallback to options.networkId
|
|
4887
4884
|
const networkId = this.resolveNetworkId(sessionInfo, options.networkId);
|
|
4888
|
-
logger$
|
|
4885
|
+
logger$a.debug('Routing signMessage to signer', {
|
|
4889
4886
|
ledgerId: sessionInfo.signer.ledgerId,
|
|
4890
4887
|
topic: sessionInfo.session.topic.substring(0, 16) + '...',
|
|
4891
4888
|
networkId,
|
|
@@ -4926,7 +4923,7 @@ class WalletConnectSigningOrchestrator {
|
|
|
4926
4923
|
if (optionsNetworkId &&
|
|
4927
4924
|
sessionInfo.userSelectedNetwork &&
|
|
4928
4925
|
optionsNetworkId !== sessionInfo.userSelectedNetwork) {
|
|
4929
|
-
logger$
|
|
4926
|
+
logger$a.warn('Network mismatch: using session network over caller-provided network', {
|
|
4930
4927
|
callerNetwork: optionsNetworkId,
|
|
4931
4928
|
sessionNetwork: sessionInfo.userSelectedNetwork,
|
|
4932
4929
|
using: resolvedNetwork,
|
|
@@ -4946,7 +4943,7 @@ class WalletConnectSigningOrchestrator {
|
|
|
4946
4943
|
}
|
|
4947
4944
|
// Validate session exists in WC SDK
|
|
4948
4945
|
if (!this.validateSessionInSdk(sessionInfo.session.topic)) {
|
|
4949
|
-
logger$
|
|
4946
|
+
logger$a.error('Session not found in WC SDK', {
|
|
4950
4947
|
topic: sessionInfo.session.topic.substring(0, 16) + '...',
|
|
4951
4948
|
account: accountAddress,
|
|
4952
4949
|
});
|
|
@@ -4973,7 +4970,7 @@ class WalletConnectSigningOrchestrator {
|
|
|
4973
4970
|
return !!session;
|
|
4974
4971
|
}
|
|
4975
4972
|
catch (error) {
|
|
4976
|
-
logger$
|
|
4973
|
+
logger$a.warn('Session validation failed', {
|
|
4977
4974
|
topic: topic.substring(0, 16) + '...',
|
|
4978
4975
|
error: error instanceof Error ? error.message : String(error),
|
|
4979
4976
|
});
|
|
@@ -5009,7 +5006,7 @@ class WalletConnectSigningOrchestrator {
|
|
|
5009
5006
|
* - Testable (mock signers for unit tests)
|
|
5010
5007
|
* - Maintainable (ledger logic is isolated)
|
|
5011
5008
|
*/
|
|
5012
|
-
const logger$
|
|
5009
|
+
const logger$9 = getLogger().scoped?.('WalletConnectV2Provider') ?? getLogger();
|
|
5013
5010
|
/**
|
|
5014
5011
|
* Storage key prefix for persisting user's network selection per session topic.
|
|
5015
5012
|
* This is critical for proper session restoration after page reload.
|
|
@@ -5073,7 +5070,7 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5073
5070
|
clientManager: this.clientManager,
|
|
5074
5071
|
eventBus: this.eventBus,
|
|
5075
5072
|
});
|
|
5076
|
-
logger$
|
|
5073
|
+
logger$9.info('Initializing - will attempt session restoration');
|
|
5077
5074
|
void this.restoreSession();
|
|
5078
5075
|
}
|
|
5079
5076
|
/**
|
|
@@ -5100,7 +5097,7 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5100
5097
|
*/
|
|
5101
5098
|
async restoreSession() {
|
|
5102
5099
|
try {
|
|
5103
|
-
logger$
|
|
5100
|
+
logger$9.debug('Attempting to restore sessions...');
|
|
5104
5101
|
// Restore client from stored projectId
|
|
5105
5102
|
const client = await this.clientManager.restoreClient({
|
|
5106
5103
|
name: 'HSuite Demo',
|
|
@@ -5115,7 +5112,7 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5115
5112
|
this.registerSessionDeleteListener();
|
|
5116
5113
|
// Get all active sessions
|
|
5117
5114
|
const activeSessions = this.clientManager.getActiveSessions();
|
|
5118
|
-
logger$
|
|
5115
|
+
logger$9.info('Found active sessions', { count: activeSessions.length });
|
|
5119
5116
|
if (activeSessions.length === 0) {
|
|
5120
5117
|
return;
|
|
5121
5118
|
}
|
|
@@ -5125,7 +5122,7 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5125
5122
|
await this.restoreSingleSession(session);
|
|
5126
5123
|
}
|
|
5127
5124
|
catch (error) {
|
|
5128
|
-
logger$
|
|
5125
|
+
logger$9.error('Failed to restore session', {
|
|
5129
5126
|
topic: session.topic,
|
|
5130
5127
|
error: error instanceof Error ? error.message : String(error),
|
|
5131
5128
|
});
|
|
@@ -5135,11 +5132,11 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5135
5132
|
this.sessionStore.updateAggregatedAccounts();
|
|
5136
5133
|
if (this.sessionStore.size > 0) {
|
|
5137
5134
|
this._status.set('connected');
|
|
5138
|
-
logger$
|
|
5135
|
+
logger$9.info('Restored sessions', { count: this.sessionStore.size });
|
|
5139
5136
|
}
|
|
5140
5137
|
}
|
|
5141
5138
|
catch (error) {
|
|
5142
|
-
logger$
|
|
5139
|
+
logger$9.error('Failed to restore sessions', {
|
|
5143
5140
|
error: error instanceof Error ? error.message : String(error),
|
|
5144
5141
|
});
|
|
5145
5142
|
}
|
|
@@ -5154,23 +5151,23 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5154
5151
|
* @param session - WalletConnect session object from IndexedDB
|
|
5155
5152
|
*/
|
|
5156
5153
|
async restoreSingleSession(session) {
|
|
5157
|
-
logger$
|
|
5158
|
-
logger$
|
|
5154
|
+
logger$9.debug('Restoring session', { topic: session.topic });
|
|
5155
|
+
logger$9.debug('Session namespaces', { namespaces: Object.keys(session.namespaces) });
|
|
5159
5156
|
// Determine ledger from session namespaces
|
|
5160
5157
|
let ledgerId;
|
|
5161
5158
|
let walletReportedNetwork;
|
|
5162
5159
|
if (session.namespaces.hedera) {
|
|
5163
5160
|
ledgerId = 'hedera';
|
|
5164
5161
|
walletReportedNetwork = session.namespaces.hedera.chains?.[0] || 'hedera:testnet';
|
|
5165
|
-
logger$
|
|
5162
|
+
logger$9.debug('Found Hedera namespace', { chains: session.namespaces.hedera.chains });
|
|
5166
5163
|
}
|
|
5167
5164
|
else if (session.namespaces.xrpl) {
|
|
5168
5165
|
ledgerId = 'xrpl';
|
|
5169
5166
|
walletReportedNetwork = session.namespaces.xrpl.chains?.[0] || 'xrpl:testnet';
|
|
5170
|
-
logger$
|
|
5167
|
+
logger$9.debug('Found XRPL namespace', { chains: session.namespaces.xrpl.chains });
|
|
5171
5168
|
}
|
|
5172
5169
|
if (!ledgerId || !walletReportedNetwork) {
|
|
5173
|
-
logger$
|
|
5170
|
+
logger$9.warn('Could not determine ledger for session', {
|
|
5174
5171
|
topic: session.topic,
|
|
5175
5172
|
availableNamespaces: Object.keys(session.namespaces),
|
|
5176
5173
|
});
|
|
@@ -5181,14 +5178,14 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5181
5178
|
const userSelectedNetwork = this.getUserNetworkSelection(session.topic);
|
|
5182
5179
|
const networkId = userSelectedNetwork || walletReportedNetwork;
|
|
5183
5180
|
if (userSelectedNetwork) {
|
|
5184
|
-
logger$
|
|
5181
|
+
logger$9.debug('Restored user network selection', {
|
|
5185
5182
|
userSelectedNetwork,
|
|
5186
5183
|
walletReportedNetwork,
|
|
5187
5184
|
topic: session.topic.substring(0, 16),
|
|
5188
5185
|
});
|
|
5189
5186
|
}
|
|
5190
5187
|
else {
|
|
5191
|
-
logger$
|
|
5188
|
+
logger$9.warn('No stored network selection found, using wallet-reported network', {
|
|
5192
5189
|
walletReportedNetwork,
|
|
5193
5190
|
topic: session.topic.substring(0, 16),
|
|
5194
5191
|
});
|
|
@@ -5199,18 +5196,18 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5199
5196
|
const sessionKey = this.sessionStore.generateSessionKey(ledgerId, networkId, session.topic);
|
|
5200
5197
|
// Parse accounts from session, filtering by user's selected network
|
|
5201
5198
|
const namespace = session.namespaces[ledgerId];
|
|
5202
|
-
logger$
|
|
5199
|
+
logger$9.debug('Namespace for restoration', {
|
|
5203
5200
|
ledgerId,
|
|
5204
5201
|
accountCount: namespace?.accounts?.length || 0,
|
|
5205
5202
|
});
|
|
5206
5203
|
// Pass the user's selected network to filter accounts appropriately
|
|
5207
5204
|
const parsedAccounts = signer.parseAccounts(namespace, userSelectedNetwork);
|
|
5208
|
-
logger$
|
|
5205
|
+
logger$9.debug('Parsed accounts from restored session', {
|
|
5209
5206
|
count: parsedAccounts.length,
|
|
5210
5207
|
userSelectedNetwork,
|
|
5211
5208
|
});
|
|
5212
5209
|
if (parsedAccounts.length === 0) {
|
|
5213
|
-
logger$
|
|
5210
|
+
logger$9.warn('Restored session has no accounts for selected network', {
|
|
5214
5211
|
userSelectedNetwork,
|
|
5215
5212
|
walletReportedNetwork,
|
|
5216
5213
|
});
|
|
@@ -5242,7 +5239,7 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5242
5239
|
signer,
|
|
5243
5240
|
accounts,
|
|
5244
5241
|
});
|
|
5245
|
-
logger$
|
|
5242
|
+
logger$9.info('Restored session', {
|
|
5246
5243
|
sessionKey,
|
|
5247
5244
|
ledgerId,
|
|
5248
5245
|
networkId,
|
|
@@ -5269,13 +5266,13 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5269
5266
|
storeUserNetworkSelection(sessionTopic, networkId) {
|
|
5270
5267
|
try {
|
|
5271
5268
|
localStorage.setItem(`${NETWORK_SELECTION_STORAGE_KEY}${sessionTopic}`, networkId);
|
|
5272
|
-
logger$
|
|
5269
|
+
logger$9.debug('Stored user network selection', {
|
|
5273
5270
|
topic: sessionTopic.substring(0, 16),
|
|
5274
5271
|
networkId,
|
|
5275
5272
|
});
|
|
5276
5273
|
}
|
|
5277
5274
|
catch (e) {
|
|
5278
|
-
logger$
|
|
5275
|
+
logger$9.warn('Failed to store network selection', { error: e.message });
|
|
5279
5276
|
}
|
|
5280
5277
|
}
|
|
5281
5278
|
/**
|
|
@@ -5289,7 +5286,7 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5289
5286
|
return localStorage.getItem(`${NETWORK_SELECTION_STORAGE_KEY}${sessionTopic}`) || undefined;
|
|
5290
5287
|
}
|
|
5291
5288
|
catch (e) {
|
|
5292
|
-
logger$
|
|
5289
|
+
logger$9.warn('Failed to retrieve network selection', { error: e.message });
|
|
5293
5290
|
return undefined;
|
|
5294
5291
|
}
|
|
5295
5292
|
}
|
|
@@ -5335,7 +5332,7 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5335
5332
|
}
|
|
5336
5333
|
// Get the appropriate signer for this ledger (Strategy Pattern)
|
|
5337
5334
|
const signer = SignerFactory.getSigner(wcConfig.ledgerId);
|
|
5338
|
-
logger$
|
|
5335
|
+
logger$9.debug('Using signer for ledger', { ledgerId: wcConfig.ledgerId });
|
|
5339
5336
|
// Initialize client via manager
|
|
5340
5337
|
await this.clientManager.initialize(projectId, {
|
|
5341
5338
|
name: wcConfig.appName || 'HSuite Demo',
|
|
@@ -5349,14 +5346,14 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5349
5346
|
// Build namespace configuration using signer
|
|
5350
5347
|
const namespaceConfig = signer.buildNamespace(wcConfig.networkId);
|
|
5351
5348
|
const optionalNamespaces = { [wcConfig.ledgerId]: namespaceConfig };
|
|
5352
|
-
logger$
|
|
5349
|
+
logger$9.debug('Namespace config', { ledgerId: wcConfig.ledgerId });
|
|
5353
5350
|
// Build session properties to pass user's preferred network to wallet
|
|
5354
5351
|
// This tells the wallet which network accounts to show in the picker
|
|
5355
5352
|
const sessionProperties = {
|
|
5356
5353
|
preferredNetwork: wcConfig.networkId,
|
|
5357
5354
|
preferredLedger: wcConfig.ledgerId,
|
|
5358
5355
|
};
|
|
5359
|
-
logger$
|
|
5356
|
+
logger$9.info('Connecting with preferred network', {
|
|
5360
5357
|
preferredNetwork: wcConfig.networkId,
|
|
5361
5358
|
preferredLedger: wcConfig.ledgerId,
|
|
5362
5359
|
});
|
|
@@ -5366,10 +5363,10 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5366
5363
|
await modal.openModal({ uri });
|
|
5367
5364
|
}
|
|
5368
5365
|
// Wait for wallet approval
|
|
5369
|
-
logger$
|
|
5366
|
+
logger$9.info('Waiting for wallet approval...');
|
|
5370
5367
|
const session = await approval();
|
|
5371
5368
|
this.clientManager.closeModal();
|
|
5372
|
-
logger$
|
|
5369
|
+
logger$9.info('[WC:DAPP:APPROVED] Session approved by wallet', {
|
|
5373
5370
|
topic: session.topic.substring(0, 16) + '...',
|
|
5374
5371
|
fullTopic: session.topic,
|
|
5375
5372
|
namespaces: Object.keys(session.namespaces),
|
|
@@ -5379,12 +5376,12 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5379
5376
|
const sessionKey = this.sessionStore.generateSessionKey(wcConfig.ledgerId, wcConfig.networkId, session.topic);
|
|
5380
5377
|
// Parse accounts from session
|
|
5381
5378
|
const sessionNamespace = session.namespaces[wcConfig.ledgerId];
|
|
5382
|
-
logger$
|
|
5379
|
+
logger$9.debug('Session namespace for ledger', {
|
|
5383
5380
|
ledgerId: wcConfig.ledgerId,
|
|
5384
5381
|
accountCount: sessionNamespace?.accounts?.length || 0,
|
|
5385
5382
|
});
|
|
5386
5383
|
if (!sessionNamespace) {
|
|
5387
|
-
logger$
|
|
5384
|
+
logger$9.error('No namespace found for ledger', {
|
|
5388
5385
|
ledgerId: wcConfig.ledgerId,
|
|
5389
5386
|
availableNamespaces: Object.keys(session.namespaces),
|
|
5390
5387
|
});
|
|
@@ -5393,12 +5390,12 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5393
5390
|
// Parse accounts from session namespace, filtering by user's selected network
|
|
5394
5391
|
// This ensures we only show accounts that match the network the user selected
|
|
5395
5392
|
const parsedAccounts = signer.parseAccounts(sessionNamespace, wcConfig.networkId);
|
|
5396
|
-
logger$
|
|
5393
|
+
logger$9.debug('Parsed accounts', {
|
|
5397
5394
|
count: parsedAccounts.length,
|
|
5398
5395
|
userSelectedNetwork: wcConfig.networkId,
|
|
5399
5396
|
});
|
|
5400
5397
|
if (parsedAccounts.length === 0) {
|
|
5401
|
-
logger$
|
|
5398
|
+
logger$9.warn('No accounts returned from wallet - possible causes:', {
|
|
5402
5399
|
reason1: 'Wallet has no accounts for the requested network',
|
|
5403
5400
|
reason2: 'Wallet denied account sharing',
|
|
5404
5401
|
reason3: 'Wallet returned accounts in unexpected format',
|
|
@@ -5437,7 +5434,7 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5437
5434
|
this.storeUserNetworkSelection(session.topic, wcConfig.networkId);
|
|
5438
5435
|
// Verify session exists in WC SDK after storing
|
|
5439
5436
|
const sdkSession = this.clientManager.getSession(session.topic);
|
|
5440
|
-
logger$
|
|
5437
|
+
logger$9.info('[WC:DAPP:STORED] Session stored locally', {
|
|
5441
5438
|
sessionKey,
|
|
5442
5439
|
topic: session.topic.substring(0, 16) + '...',
|
|
5443
5440
|
fullTopic: session.topic,
|
|
@@ -5466,7 +5463,7 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5466
5463
|
catch (error) {
|
|
5467
5464
|
this._status.set('error');
|
|
5468
5465
|
this._error.set(error instanceof Error ? error.message : 'Connection failed');
|
|
5469
|
-
logger$
|
|
5466
|
+
logger$9.error('Connection failed', {
|
|
5470
5467
|
error: error instanceof Error ? error.message : String(error),
|
|
5471
5468
|
});
|
|
5472
5469
|
// Emit provider error event
|
|
@@ -5531,14 +5528,14 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5531
5528
|
// WalletConnect events arrive outside Angular's zone
|
|
5532
5529
|
this.clientManager.on('session_delete', (event) => {
|
|
5533
5530
|
this.zone.run(() => {
|
|
5534
|
-
logger$
|
|
5531
|
+
logger$9.info('� Session deleted by wallet (session_delete event)', {
|
|
5535
5532
|
topic: event.topic,
|
|
5536
5533
|
});
|
|
5537
5534
|
this.removeSessionByTopic(event.topic);
|
|
5538
5535
|
});
|
|
5539
5536
|
});
|
|
5540
5537
|
this.sessionDeleteListenerRegistered = true;
|
|
5541
|
-
logger$
|
|
5538
|
+
logger$9.debug('session_delete listener registered');
|
|
5542
5539
|
}
|
|
5543
5540
|
/**
|
|
5544
5541
|
* Disconnect from WalletConnect sessions.
|
|
@@ -5548,7 +5545,7 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5548
5545
|
*/
|
|
5549
5546
|
async disconnect(sessionKey) {
|
|
5550
5547
|
if (!this.clientManager.isInitialized()) {
|
|
5551
|
-
logger$
|
|
5548
|
+
logger$9.warn('No client to disconnect');
|
|
5552
5549
|
return;
|
|
5553
5550
|
}
|
|
5554
5551
|
if (sessionKey) {
|
|
@@ -5560,10 +5557,10 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5560
5557
|
code: 6000,
|
|
5561
5558
|
message: 'User disconnected session',
|
|
5562
5559
|
});
|
|
5563
|
-
logger$
|
|
5560
|
+
logger$9.info('Disconnected session', { sessionKey });
|
|
5564
5561
|
}
|
|
5565
5562
|
catch (e) {
|
|
5566
|
-
logger$
|
|
5563
|
+
logger$9.error('Disconnect error for session', {
|
|
5567
5564
|
sessionKey,
|
|
5568
5565
|
error: e instanceof Error ? e.message : String(e),
|
|
5569
5566
|
});
|
|
@@ -5588,14 +5585,14 @@ class WalletConnectV2Provider extends BaseWalletProvider {
|
|
|
5588
5585
|
code: 6000,
|
|
5589
5586
|
message: 'User disconnected all sessions',
|
|
5590
5587
|
})
|
|
5591
|
-
.catch((err) => logger$
|
|
5588
|
+
.catch((err) => logger$9.error('Disconnect error', {
|
|
5592
5589
|
error: err.message,
|
|
5593
5590
|
})));
|
|
5594
5591
|
}
|
|
5595
5592
|
await Promise.all(disconnectPromises);
|
|
5596
5593
|
this.sessionStore.clear();
|
|
5597
5594
|
this._status.set('disconnected');
|
|
5598
|
-
logger$
|
|
5595
|
+
logger$9.info('Disconnected all sessions');
|
|
5599
5596
|
}
|
|
5600
5597
|
this.clientManager.closeModal();
|
|
5601
5598
|
}
|
|
@@ -5698,7 +5695,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
5698
5695
|
* - RPC communication over best available transport
|
|
5699
5696
|
* - Session ownership remains with the wallet
|
|
5700
5697
|
*/
|
|
5701
|
-
const logger$
|
|
5698
|
+
const logger$8 = getLogger().scoped?.('P2PSessionManager') ?? getLogger();
|
|
5702
5699
|
/**
|
|
5703
5700
|
* Mobile Native Session Manager
|
|
5704
5701
|
*
|
|
@@ -5767,7 +5764,7 @@ class P2PSessionManager {
|
|
|
5767
5764
|
* @returns Promise resolving to offer result with QR data
|
|
5768
5765
|
*/
|
|
5769
5766
|
async createPairingOffer(options) {
|
|
5770
|
-
logger$
|
|
5767
|
+
logger$8.info('Creating pairing offer (Nostr-first)', { options });
|
|
5771
5768
|
try {
|
|
5772
5769
|
this.runInZone(() => this._connectionState.set('creating_offer'));
|
|
5773
5770
|
// Clean up any existing client
|
|
@@ -5780,12 +5777,12 @@ class P2PSessionManager {
|
|
|
5780
5777
|
this.client = new ChannelClient({
|
|
5781
5778
|
p2p: { enabled: true },
|
|
5782
5779
|
onStateChange: (state) => {
|
|
5783
|
-
logger$
|
|
5780
|
+
logger$8.debug('ChannelClient state callback', { state });
|
|
5784
5781
|
const accounts = this.client?.accounts ?? [];
|
|
5785
5782
|
this.handleStateChange(state, accounts);
|
|
5786
5783
|
},
|
|
5787
5784
|
onAccountsChange: (accounts) => {
|
|
5788
|
-
logger$
|
|
5785
|
+
logger$8.debug('ChannelClient accounts callback', { count: accounts.length });
|
|
5789
5786
|
const state = this.client?.state ?? 'idle';
|
|
5790
5787
|
this.handleStateChange(state, accounts);
|
|
5791
5788
|
},
|
|
@@ -5810,7 +5807,7 @@ class P2PSessionManager {
|
|
|
5810
5807
|
// Encode invite for QR code
|
|
5811
5808
|
const qrData = encodeChannelInvite(invite);
|
|
5812
5809
|
this.runInZone(() => this._connectionState.set('awaiting_connection'));
|
|
5813
|
-
logger$
|
|
5810
|
+
logger$8.info('Pairing offer created', {
|
|
5814
5811
|
sessionId: invite.id.slice(0, 8),
|
|
5815
5812
|
qrDataLength: qrData.length,
|
|
5816
5813
|
});
|
|
@@ -5819,7 +5816,7 @@ class P2PSessionManager {
|
|
|
5819
5816
|
return { qrData, sessionId: invite.id };
|
|
5820
5817
|
}
|
|
5821
5818
|
catch (error) {
|
|
5822
|
-
logger$
|
|
5819
|
+
logger$8.error('Failed to create pairing offer', { error });
|
|
5823
5820
|
this.runInZone(() => this._connectionState.set('error'));
|
|
5824
5821
|
this.notifyError(error instanceof Error ? error : new Error('Failed to create offer'));
|
|
5825
5822
|
throw error;
|
|
@@ -5837,7 +5834,7 @@ class P2PSessionManager {
|
|
|
5837
5834
|
if (!this.client || !this.currentInvite) {
|
|
5838
5835
|
throw new Error('No active pairing offer - call createPairingOffer first');
|
|
5839
5836
|
}
|
|
5840
|
-
logger$
|
|
5837
|
+
logger$8.info('Waiting for wallet to connect and approve session...');
|
|
5841
5838
|
return new Promise((resolve, reject) => {
|
|
5842
5839
|
this.sessionApprovalPromise = { resolve, reject };
|
|
5843
5840
|
});
|
|
@@ -5848,7 +5845,7 @@ class P2PSessionManager {
|
|
|
5848
5845
|
* Cleans up the transport without fully disconnecting.
|
|
5849
5846
|
*/
|
|
5850
5847
|
async cancelPairingOffer() {
|
|
5851
|
-
logger$
|
|
5848
|
+
logger$8.debug('Cancelling pairing offer');
|
|
5852
5849
|
if (this.sessionApprovalPromise) {
|
|
5853
5850
|
this.sessionApprovalPromise.reject(new Error('Pairing cancelled'));
|
|
5854
5851
|
this.sessionApprovalPromise = undefined;
|
|
@@ -5890,7 +5887,7 @@ class P2PSessionManager {
|
|
|
5890
5887
|
*/
|
|
5891
5888
|
async signTransaction(options) {
|
|
5892
5889
|
this.requireSession();
|
|
5893
|
-
logger$
|
|
5890
|
+
logger$8.info('Signing transaction', { account: options.accountAddress });
|
|
5894
5891
|
if (!this.client) {
|
|
5895
5892
|
throw new Error('Not connected');
|
|
5896
5893
|
}
|
|
@@ -5912,7 +5909,7 @@ class P2PSessionManager {
|
|
|
5912
5909
|
*/
|
|
5913
5910
|
async submitTransaction(options) {
|
|
5914
5911
|
this.requireSession();
|
|
5915
|
-
logger$
|
|
5912
|
+
logger$8.info('Submitting transaction', { account: options.accountAddress });
|
|
5916
5913
|
if (!this.client) {
|
|
5917
5914
|
throw new Error('Not connected');
|
|
5918
5915
|
}
|
|
@@ -5937,7 +5934,7 @@ class P2PSessionManager {
|
|
|
5937
5934
|
*/
|
|
5938
5935
|
async signMessage(options) {
|
|
5939
5936
|
this.requireSession();
|
|
5940
|
-
logger$
|
|
5937
|
+
logger$8.info('Signing message', { account: options.accountAddress });
|
|
5941
5938
|
if (!this.client) {
|
|
5942
5939
|
throw new Error('Not connected');
|
|
5943
5940
|
}
|
|
@@ -5962,7 +5959,7 @@ class P2PSessionManager {
|
|
|
5962
5959
|
* Terminate the current session
|
|
5963
5960
|
*/
|
|
5964
5961
|
async terminateSession() {
|
|
5965
|
-
logger$
|
|
5962
|
+
logger$8.info('Terminating session');
|
|
5966
5963
|
if (this.client) {
|
|
5967
5964
|
await this.client.disconnect();
|
|
5968
5965
|
}
|
|
@@ -6063,7 +6060,6 @@ class P2PSessionManager {
|
|
|
6063
6060
|
accounts: accounts.map((acc, index) => ({
|
|
6064
6061
|
id: `p2p-${acc.address}`,
|
|
6065
6062
|
address: acc.address,
|
|
6066
|
-
publicKey: acc.publicKey,
|
|
6067
6063
|
label: acc.alias || `Account ${index + 1}`,
|
|
6068
6064
|
ledgerId: acc.ledgerId,
|
|
6069
6065
|
networkId: acc.networkId,
|
|
@@ -6082,7 +6078,7 @@ class P2PSessionManager {
|
|
|
6082
6078
|
* @param reason
|
|
6083
6079
|
*/
|
|
6084
6080
|
handleDisconnection(reason) {
|
|
6085
|
-
logger$
|
|
6081
|
+
logger$8.info('Handling disconnection', { reason });
|
|
6086
6082
|
this.cleanup();
|
|
6087
6083
|
this.runInZone(() => {
|
|
6088
6084
|
this._currentSession.set(null);
|
|
@@ -6134,7 +6130,7 @@ class P2PSessionManager {
|
|
|
6134
6130
|
callback(session);
|
|
6135
6131
|
}
|
|
6136
6132
|
catch (error) {
|
|
6137
|
-
logger$
|
|
6133
|
+
logger$8.error('Connected callback error', { error });
|
|
6138
6134
|
}
|
|
6139
6135
|
}
|
|
6140
6136
|
}
|
|
@@ -6147,7 +6143,7 @@ class P2PSessionManager {
|
|
|
6147
6143
|
callback();
|
|
6148
6144
|
}
|
|
6149
6145
|
catch (error) {
|
|
6150
|
-
logger$
|
|
6146
|
+
logger$8.error('Disconnected callback error', { error });
|
|
6151
6147
|
}
|
|
6152
6148
|
}
|
|
6153
6149
|
}
|
|
@@ -6161,7 +6157,7 @@ class P2PSessionManager {
|
|
|
6161
6157
|
callback(error);
|
|
6162
6158
|
}
|
|
6163
6159
|
catch (err) {
|
|
6164
|
-
logger$
|
|
6160
|
+
logger$8.error('Error callback error', { err });
|
|
6165
6161
|
}
|
|
6166
6162
|
}
|
|
6167
6163
|
}
|
|
@@ -6203,7 +6199,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
6203
6199
|
* 4. User approves session in wallet
|
|
6204
6200
|
* 5. P2P upgrade happens automatically in background
|
|
6205
6201
|
*/
|
|
6206
|
-
const logger$
|
|
6202
|
+
const logger$7 = getLogger().scoped?.('P2PNativeProvider') ?? getLogger();
|
|
6207
6203
|
/**
|
|
6208
6204
|
* Storage key for mobile session metadata (separate from hsuite-native)
|
|
6209
6205
|
*/
|
|
@@ -6228,10 +6224,10 @@ class P2PSessionPersistence {
|
|
|
6228
6224
|
timestamp: Date.now(),
|
|
6229
6225
|
};
|
|
6230
6226
|
window.localStorage.setItem(P2P_SESSION_STORAGE_KEY, JSON.stringify(payload));
|
|
6231
|
-
logger$
|
|
6227
|
+
logger$7.debug('Mobile session persisted', { sessionId: session.sessionId });
|
|
6232
6228
|
}
|
|
6233
6229
|
catch (error) {
|
|
6234
|
-
logger$
|
|
6230
|
+
logger$7.warn('Failed to persist mobile session', { error });
|
|
6235
6231
|
}
|
|
6236
6232
|
}
|
|
6237
6233
|
/**
|
|
@@ -6249,11 +6245,11 @@ class P2PSessionPersistence {
|
|
|
6249
6245
|
this.clear();
|
|
6250
6246
|
return null;
|
|
6251
6247
|
}
|
|
6252
|
-
logger$
|
|
6248
|
+
logger$7.info('Restored mobile session metadata', { sessionId: stored.sessionId });
|
|
6253
6249
|
return stored;
|
|
6254
6250
|
}
|
|
6255
6251
|
catch (error) {
|
|
6256
|
-
logger$
|
|
6252
|
+
logger$7.warn('Failed to restore mobile session', { error });
|
|
6257
6253
|
return null;
|
|
6258
6254
|
}
|
|
6259
6255
|
}
|
|
@@ -6265,10 +6261,10 @@ class P2PSessionPersistence {
|
|
|
6265
6261
|
if (typeof window === 'undefined')
|
|
6266
6262
|
return;
|
|
6267
6263
|
window.localStorage.removeItem(P2P_SESSION_STORAGE_KEY);
|
|
6268
|
-
logger$
|
|
6264
|
+
logger$7.debug('Mobile session cleared');
|
|
6269
6265
|
}
|
|
6270
6266
|
catch (error) {
|
|
6271
|
-
logger$
|
|
6267
|
+
logger$7.warn('Failed to clear mobile session', { error });
|
|
6272
6268
|
}
|
|
6273
6269
|
}
|
|
6274
6270
|
/**
|
|
@@ -6388,7 +6384,7 @@ class P2PNativeProvider extends BaseWalletProvider {
|
|
|
6388
6384
|
restorePersistedSession() {
|
|
6389
6385
|
const stored = this.sessionPersistence.restore();
|
|
6390
6386
|
if (stored) {
|
|
6391
|
-
logger$
|
|
6387
|
+
logger$7.info('Restoring persisted mobile session', {
|
|
6392
6388
|
sessionId: stored.sessionId,
|
|
6393
6389
|
accountCount: stored.accounts?.length ?? 0,
|
|
6394
6390
|
});
|
|
@@ -6399,7 +6395,7 @@ class P2PNativeProvider extends BaseWalletProvider {
|
|
|
6399
6395
|
}
|
|
6400
6396
|
// Note: We don't set connected status because WebRTC needs re-pairing
|
|
6401
6397
|
// The persisted data is for account info only
|
|
6402
|
-
logger$
|
|
6398
|
+
logger$7.debug('Mobile session metadata restored (requires re-pairing for connection)');
|
|
6403
6399
|
}
|
|
6404
6400
|
}
|
|
6405
6401
|
/**
|
|
@@ -6422,7 +6418,7 @@ class P2PNativeProvider extends BaseWalletProvider {
|
|
|
6422
6418
|
* @throws {Error} If offer generation fails
|
|
6423
6419
|
*/
|
|
6424
6420
|
async createPairingOffer(config) {
|
|
6425
|
-
logger$
|
|
6421
|
+
logger$7.info('Creating pairing offer', { config });
|
|
6426
6422
|
try {
|
|
6427
6423
|
this._connectionState.set('generating_offer');
|
|
6428
6424
|
this._error.set(null);
|
|
@@ -6445,14 +6441,14 @@ class P2PNativeProvider extends BaseWalletProvider {
|
|
|
6445
6441
|
this._pairingOffer.set(offerResult);
|
|
6446
6442
|
this._connectionState.set('awaiting_scan');
|
|
6447
6443
|
this._status.set('connecting');
|
|
6448
|
-
logger$
|
|
6444
|
+
logger$7.info('Pairing offer created', {
|
|
6449
6445
|
qrDataLength: result.qrData.length,
|
|
6450
6446
|
expiresAt: offerResult.expiresAt,
|
|
6451
6447
|
});
|
|
6452
6448
|
return offerResult;
|
|
6453
6449
|
}
|
|
6454
6450
|
catch (error) {
|
|
6455
|
-
logger$
|
|
6451
|
+
logger$7.error('Failed to create pairing offer', { error });
|
|
6456
6452
|
this._connectionState.set('error');
|
|
6457
6453
|
this._status.set('error');
|
|
6458
6454
|
this._error.set(error instanceof Error ? error.message : 'Failed to create pairing offer');
|
|
@@ -6466,7 +6462,7 @@ class P2PNativeProvider extends BaseWalletProvider {
|
|
|
6466
6462
|
* @returns Promise resolving to new pairing offer
|
|
6467
6463
|
*/
|
|
6468
6464
|
async refreshPairingOffer(config) {
|
|
6469
|
-
logger$
|
|
6465
|
+
logger$7.debug('Refreshing pairing offer');
|
|
6470
6466
|
// Cancel any existing offer
|
|
6471
6467
|
await this.sessionManager.cancelPairingOffer();
|
|
6472
6468
|
return this.createPairingOffer(config);
|
|
@@ -6502,7 +6498,7 @@ class P2PNativeProvider extends BaseWalletProvider {
|
|
|
6502
6498
|
* @throws {Error} If no pairing offer was created
|
|
6503
6499
|
*/
|
|
6504
6500
|
async waitForSessionApproval() {
|
|
6505
|
-
logger$
|
|
6501
|
+
logger$7.info('Waiting for wallet to connect and approve session');
|
|
6506
6502
|
this._connectionState.set('pending_approval');
|
|
6507
6503
|
try {
|
|
6508
6504
|
// This blocks until wallet connects via Nostr and user approves
|
|
@@ -6520,7 +6516,7 @@ class P2PNativeProvider extends BaseWalletProvider {
|
|
|
6520
6516
|
return session;
|
|
6521
6517
|
}
|
|
6522
6518
|
catch (error) {
|
|
6523
|
-
logger$
|
|
6519
|
+
logger$7.error('Session approval failed', { error });
|
|
6524
6520
|
this._connectionState.set('error');
|
|
6525
6521
|
throw error;
|
|
6526
6522
|
}
|
|
@@ -6545,10 +6541,10 @@ class P2PNativeProvider extends BaseWalletProvider {
|
|
|
6545
6541
|
* @throws {Error} If connection times out (2 minutes)
|
|
6546
6542
|
*/
|
|
6547
6543
|
async connect(config) {
|
|
6548
|
-
logger$
|
|
6544
|
+
logger$7.info('Connect called', { config });
|
|
6549
6545
|
// If already connected, no-op
|
|
6550
6546
|
if (this._status() === 'connected') {
|
|
6551
|
-
logger$
|
|
6547
|
+
logger$7.debug('Already connected');
|
|
6552
6548
|
return;
|
|
6553
6549
|
}
|
|
6554
6550
|
// Create pairing offer and wait for connection
|
|
@@ -6576,7 +6572,7 @@ class P2PNativeProvider extends BaseWalletProvider {
|
|
|
6576
6572
|
* persisted session data. The wallet is notified of the disconnection.
|
|
6577
6573
|
*/
|
|
6578
6574
|
async disconnect() {
|
|
6579
|
-
logger$
|
|
6575
|
+
logger$7.info('Disconnecting');
|
|
6580
6576
|
try {
|
|
6581
6577
|
await this.sessionManager.terminateSession();
|
|
6582
6578
|
}
|
|
@@ -6608,7 +6604,7 @@ class P2PNativeProvider extends BaseWalletProvider {
|
|
|
6608
6604
|
if (this._status() !== 'connected') {
|
|
6609
6605
|
throw new Error('Not connected to wallet');
|
|
6610
6606
|
}
|
|
6611
|
-
logger$
|
|
6607
|
+
logger$7.info('Signing transaction', { account: options.accountAddress });
|
|
6612
6608
|
const result = await this.sessionManager.signTransaction({
|
|
6613
6609
|
accountAddress: options.accountAddress,
|
|
6614
6610
|
payload: options.payload,
|
|
@@ -6639,7 +6635,7 @@ class P2PNativeProvider extends BaseWalletProvider {
|
|
|
6639
6635
|
if (this._status() !== 'connected') {
|
|
6640
6636
|
throw new Error('Not connected to wallet');
|
|
6641
6637
|
}
|
|
6642
|
-
logger$
|
|
6638
|
+
logger$7.info('Submitting transaction', { account: options.accountAddress });
|
|
6643
6639
|
const result = await this.sessionManager.submitTransaction({
|
|
6644
6640
|
accountAddress: options.accountAddress,
|
|
6645
6641
|
payload: options.payload,
|
|
@@ -6691,7 +6687,7 @@ class P2PNativeProvider extends BaseWalletProvider {
|
|
|
6691
6687
|
if (this._status() !== 'connected') {
|
|
6692
6688
|
throw new Error('Not connected to wallet');
|
|
6693
6689
|
}
|
|
6694
|
-
logger$
|
|
6690
|
+
logger$7.info('Signing message', { account: options.accountAddress });
|
|
6695
6691
|
const result = await this.sessionManager.signMessage({
|
|
6696
6692
|
accountAddress: options.accountAddress,
|
|
6697
6693
|
message: options.message,
|
|
@@ -6726,7 +6722,7 @@ class P2PNativeProvider extends BaseWalletProvider {
|
|
|
6726
6722
|
// Connection established — wrap in NgZone to ensure Angular change
|
|
6727
6723
|
// detection picks up signal updates from Nostr/WebSocket callbacks
|
|
6728
6724
|
this.sessionManager.onConnected((session) => {
|
|
6729
|
-
logger$
|
|
6725
|
+
logger$7.info('Session connected', { sessionId: session?.id });
|
|
6730
6726
|
this.ngZone.run(() => {
|
|
6731
6727
|
this._connectionState.set('connected');
|
|
6732
6728
|
this._status.set('connected');
|
|
@@ -6744,7 +6740,7 @@ class P2PNativeProvider extends BaseWalletProvider {
|
|
|
6744
6740
|
});
|
|
6745
6741
|
// Session terminated
|
|
6746
6742
|
this.sessionManager.onDisconnected(() => {
|
|
6747
|
-
logger$
|
|
6743
|
+
logger$7.info('Session disconnected');
|
|
6748
6744
|
this.ngZone.run(() => {
|
|
6749
6745
|
this._connectionState.set('disconnected');
|
|
6750
6746
|
this._status.set('disconnected');
|
|
@@ -6755,7 +6751,7 @@ class P2PNativeProvider extends BaseWalletProvider {
|
|
|
6755
6751
|
});
|
|
6756
6752
|
// Error occurred
|
|
6757
6753
|
this.sessionManager.onError((error) => {
|
|
6758
|
-
logger$
|
|
6754
|
+
logger$7.error('Session error', { error });
|
|
6759
6755
|
this.ngZone.run(() => {
|
|
6760
6756
|
this._connectionState.set('error');
|
|
6761
6757
|
this._status.set('error');
|
|
@@ -6764,7 +6760,7 @@ class P2PNativeProvider extends BaseWalletProvider {
|
|
|
6764
6760
|
});
|
|
6765
6761
|
// Accounts updated
|
|
6766
6762
|
this.sessionManager.onAccountsChanged((accounts) => {
|
|
6767
|
-
logger$
|
|
6763
|
+
logger$7.debug('Accounts updated', { count: accounts.length });
|
|
6768
6764
|
this.ngZone.run(() => {
|
|
6769
6765
|
const accountsWithProvider = this.ensureProviderIdOnAccounts(accounts);
|
|
6770
6766
|
this._accounts.set(accountsWithProvider);
|
|
@@ -6834,7 +6830,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
6834
6830
|
* +-------------------------------------------------------------------+
|
|
6835
6831
|
* ```
|
|
6836
6832
|
*/
|
|
6837
|
-
const logger$
|
|
6833
|
+
const logger$6 = getLogger().scoped?.('UnifiedWalletService') ?? getLogger();
|
|
6838
6834
|
/**
|
|
6839
6835
|
* Central service for managing wallet connections across multiple protocols.
|
|
6840
6836
|
*
|
|
@@ -6972,7 +6968,7 @@ class UnifiedWalletService {
|
|
|
6972
6968
|
return await reconnect.call(provider);
|
|
6973
6969
|
}
|
|
6974
6970
|
catch (error) {
|
|
6975
|
-
logger$
|
|
6971
|
+
logger$6.warn('Provider reconnect failed', { providerId, error });
|
|
6976
6972
|
return false;
|
|
6977
6973
|
}
|
|
6978
6974
|
}
|
|
@@ -7036,7 +7032,7 @@ class UnifiedWalletService {
|
|
|
7036
7032
|
*/
|
|
7037
7033
|
registerProvider(provider) {
|
|
7038
7034
|
if (this.providers.has(provider.id)) {
|
|
7039
|
-
logger$
|
|
7035
|
+
logger$6.warn('Provider already registered', { providerId: provider.id });
|
|
7040
7036
|
return;
|
|
7041
7037
|
}
|
|
7042
7038
|
this.providers.set(provider.id, provider);
|
|
@@ -7491,7 +7487,7 @@ class UnifiedWalletService {
|
|
|
7491
7487
|
switchAccount(accountId) {
|
|
7492
7488
|
const account = this.getAccountById(accountId);
|
|
7493
7489
|
if (!account) {
|
|
7494
|
-
logger$
|
|
7490
|
+
logger$6.warn('Account not found', { accountId });
|
|
7495
7491
|
return false;
|
|
7496
7492
|
}
|
|
7497
7493
|
this.setActiveAccount(account);
|
|
@@ -7546,7 +7542,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
7546
7542
|
* - Keyboard navigation support
|
|
7547
7543
|
* - Toast/alert integration
|
|
7548
7544
|
*/
|
|
7549
|
-
const logger$
|
|
7545
|
+
const logger$5 = getLogger().scoped?.('AccountSelectorService') ?? getLogger();
|
|
7550
7546
|
/**
|
|
7551
7547
|
* @service AccountSelectorService
|
|
7552
7548
|
* Business logic service for account selector component.
|
|
@@ -7635,7 +7631,7 @@ class AccountSelectorService {
|
|
|
7635
7631
|
return null;
|
|
7636
7632
|
}
|
|
7637
7633
|
catch (error) {
|
|
7638
|
-
logger$
|
|
7634
|
+
logger$5.error('Error getting currently connected account', { error });
|
|
7639
7635
|
return null;
|
|
7640
7636
|
}
|
|
7641
7637
|
}, ...(ngDevMode ? [{ debugName: "currentlyConnectedAccount" }] : []));
|
|
@@ -7663,7 +7659,7 @@ class AccountSelectorService {
|
|
|
7663
7659
|
return others;
|
|
7664
7660
|
}
|
|
7665
7661
|
catch (error) {
|
|
7666
|
-
logger$
|
|
7662
|
+
logger$5.error('Error getting other accounts', { error });
|
|
7667
7663
|
return [];
|
|
7668
7664
|
}
|
|
7669
7665
|
}, ...(ngDevMode ? [{ debugName: "otherAccounts" }] : []));
|
|
@@ -7692,10 +7688,10 @@ class AccountSelectorService {
|
|
|
7692
7688
|
// Modal mode: show toast and dismiss
|
|
7693
7689
|
if (mode === 'modal') {
|
|
7694
7690
|
await this.showSuccessToast(`Switched to ${account.label || 'Account'}`);
|
|
7695
|
-
logger$
|
|
7691
|
+
logger$5.info('[Modal] Account changed and modal dismissed', { ...accountData });
|
|
7696
7692
|
}
|
|
7697
7693
|
else {
|
|
7698
|
-
logger$
|
|
7694
|
+
logger$5.info('[Inline] Account changed', { ...accountData });
|
|
7699
7695
|
}
|
|
7700
7696
|
return accountData;
|
|
7701
7697
|
}
|
|
@@ -7747,7 +7743,7 @@ class AccountSelectorService {
|
|
|
7747
7743
|
*/
|
|
7748
7744
|
async disconnectAll(_mode) {
|
|
7749
7745
|
if (!this.alertController) {
|
|
7750
|
-
logger$
|
|
7746
|
+
logger$5.warn('AlertController not available for disconnect confirmation');
|
|
7751
7747
|
return false;
|
|
7752
7748
|
}
|
|
7753
7749
|
return new Promise((resolve) => {
|
|
@@ -7772,7 +7768,7 @@ class AccountSelectorService {
|
|
|
7772
7768
|
await this.wallet.disconnectSession(session.providerId, session.metadata?.sessionKey);
|
|
7773
7769
|
}
|
|
7774
7770
|
catch (error) {
|
|
7775
|
-
logger$
|
|
7771
|
+
logger$5.error('Failed to disconnect session', {
|
|
7776
7772
|
providerId: session.providerId,
|
|
7777
7773
|
error,
|
|
7778
7774
|
});
|
|
@@ -7782,7 +7778,7 @@ class AccountSelectorService {
|
|
|
7782
7778
|
resolve(true);
|
|
7783
7779
|
}
|
|
7784
7780
|
catch (error) {
|
|
7785
|
-
logger$
|
|
7781
|
+
logger$5.error('Failed to disconnect all sessions', { error });
|
|
7786
7782
|
this.error.set('Failed to disconnect all wallets');
|
|
7787
7783
|
resolve(false);
|
|
7788
7784
|
}
|
|
@@ -7867,11 +7863,11 @@ class AccountSelectorService {
|
|
|
7867
7863
|
if (mode === 'modal') {
|
|
7868
7864
|
await this.showSuccessToast('Wallet disconnected successfully');
|
|
7869
7865
|
}
|
|
7870
|
-
logger$
|
|
7866
|
+
logger$5.info('Session disconnected', { providerId, sessionKey, mode });
|
|
7871
7867
|
return true;
|
|
7872
7868
|
}
|
|
7873
7869
|
catch (error) {
|
|
7874
|
-
logger$
|
|
7870
|
+
logger$5.error('Failed to disconnect session', { providerId, error });
|
|
7875
7871
|
if (mode === 'modal') {
|
|
7876
7872
|
await this.showErrorToast('Failed to disconnect wallet. Please try again.');
|
|
7877
7873
|
}
|
|
@@ -8813,6 +8809,84 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
8813
8809
|
args: [{ providedIn: 'root' }]
|
|
8814
8810
|
}] });
|
|
8815
8811
|
|
|
8812
|
+
/**
|
|
8813
|
+
* HSuite Native Connect
|
|
8814
|
+
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
8815
|
+
*
|
|
8816
|
+
* SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
8817
|
+
*
|
|
8818
|
+
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
8819
|
+
* visit https://hsuite.finance/licensing
|
|
8820
|
+
*/
|
|
8821
|
+
/**
|
|
8822
|
+
* @file SDK-local clipboard helper. Behavior-identical port of
|
|
8823
|
+
* `copyToClipboard` from `@hsuite/native-connect-ui` (logging dropped): the
|
|
8824
|
+
* connection modal's QR step was the ONLY thing pulling the entire ui
|
|
8825
|
+
* design-system package into dApp builds — a utility function is not a
|
|
8826
|
+
* reason to depend on 80+ components. Standalone dApps (ecosystem DEX) can
|
|
8827
|
+
* now build without ui entirely.
|
|
8828
|
+
*/
|
|
8829
|
+
/**
|
|
8830
|
+
* Copy text to the clipboard: modern Clipboard API first, `execCommand`
|
|
8831
|
+
* textarea fallback second (covers non-secure contexts and some PWA cases).
|
|
8832
|
+
*
|
|
8833
|
+
* @param text - Text to copy
|
|
8834
|
+
* @returns True if the copy succeeded
|
|
8835
|
+
*/
|
|
8836
|
+
async function copyToClipboard(text) {
|
|
8837
|
+
if (navigator.clipboard?.writeText) {
|
|
8838
|
+
try {
|
|
8839
|
+
await navigator.clipboard.writeText(text);
|
|
8840
|
+
return true;
|
|
8841
|
+
}
|
|
8842
|
+
catch {
|
|
8843
|
+
// Clipboard API failed (permission denied, not in a secure context,
|
|
8844
|
+
// etc.) — fall through to the legacy method.
|
|
8845
|
+
}
|
|
8846
|
+
}
|
|
8847
|
+
return copyToClipboardFallback(text);
|
|
8848
|
+
}
|
|
8849
|
+
function copyToClipboardFallback(text) {
|
|
8850
|
+
if (typeof document === 'undefined') {
|
|
8851
|
+
return false;
|
|
8852
|
+
}
|
|
8853
|
+
const textarea = document.createElement('textarea');
|
|
8854
|
+
// Style to make it invisible but still selectable.
|
|
8855
|
+
textarea.value = text;
|
|
8856
|
+
textarea.style.position = 'fixed';
|
|
8857
|
+
textarea.style.left = '-9999px';
|
|
8858
|
+
textarea.style.top = '-9999px';
|
|
8859
|
+
textarea.style.opacity = '0';
|
|
8860
|
+
textarea.style.pointerEvents = 'none';
|
|
8861
|
+
textarea.setAttribute('readonly', ''); // Prevent mobile keyboard
|
|
8862
|
+
textarea.setAttribute('aria-hidden', 'true');
|
|
8863
|
+
document.body.appendChild(textarea);
|
|
8864
|
+
try {
|
|
8865
|
+
// iOS requires special handling: select via a range instead of select().
|
|
8866
|
+
const isIOS = /ipad|iphone|ipod/i.test(navigator.userAgent);
|
|
8867
|
+
if (isIOS) {
|
|
8868
|
+
const range = document.createRange();
|
|
8869
|
+
range.selectNodeContents(textarea);
|
|
8870
|
+
const selection = window.getSelection();
|
|
8871
|
+
if (selection) {
|
|
8872
|
+
selection.removeAllRanges();
|
|
8873
|
+
selection.addRange(range);
|
|
8874
|
+
}
|
|
8875
|
+
textarea.setSelectionRange(0, text.length);
|
|
8876
|
+
}
|
|
8877
|
+
else {
|
|
8878
|
+
textarea.select();
|
|
8879
|
+
}
|
|
8880
|
+
return document.execCommand('copy');
|
|
8881
|
+
}
|
|
8882
|
+
catch {
|
|
8883
|
+
return false;
|
|
8884
|
+
}
|
|
8885
|
+
finally {
|
|
8886
|
+
document.body.removeChild(textarea);
|
|
8887
|
+
}
|
|
8888
|
+
}
|
|
8889
|
+
|
|
8816
8890
|
/**
|
|
8817
8891
|
* HSuite Native Connect
|
|
8818
8892
|
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
@@ -9418,7 +9492,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
9418
9492
|
* - HSuite Native + Mobile QR: Network → Protocol → Method → QR Pairing (4 steps)
|
|
9419
9493
|
* - WalletConnect: Network → Protocol → Ledger → Connect (4 steps)
|
|
9420
9494
|
*/
|
|
9421
|
-
const logger$
|
|
9495
|
+
const logger$4 = getLogger().scoped?.('WalletConnectionModal') ?? getLogger();
|
|
9422
9496
|
/**
|
|
9423
9497
|
* Connection step enumeration for the wizard flow
|
|
9424
9498
|
*/
|
|
@@ -9943,7 +10017,7 @@ class WalletConnectionModalComponent {
|
|
|
9943
10017
|
await this.modalController.dismiss({ connected: true });
|
|
9944
10018
|
}
|
|
9945
10019
|
catch (error) {
|
|
9946
|
-
logger$
|
|
10020
|
+
logger$4.error('Connection failed', {
|
|
9947
10021
|
error: error instanceof Error ? error.message : String(error),
|
|
9948
10022
|
});
|
|
9949
10023
|
this.connectionError.set(error instanceof Error ? error.message : 'Connection failed. Please try again.');
|
|
@@ -9988,7 +10062,7 @@ class WalletConnectionModalComponent {
|
|
|
9988
10062
|
this.waitForWalletApproval();
|
|
9989
10063
|
}
|
|
9990
10064
|
catch (error) {
|
|
9991
|
-
logger$
|
|
10065
|
+
logger$4.error('Failed to create pairing offer', { error });
|
|
9992
10066
|
this.connectionError.set(error instanceof Error ? error.message : 'Failed to generate QR code');
|
|
9993
10067
|
this.isGeneratingOffer.set(false);
|
|
9994
10068
|
}
|
|
@@ -10001,7 +10075,7 @@ class WalletConnectionModalComponent {
|
|
|
10001
10075
|
try {
|
|
10002
10076
|
// This blocks until wallet scans QR, connects via Nostr, and user approves
|
|
10003
10077
|
const session = await this.p2pNativeProvider.waitForSessionApproval();
|
|
10004
|
-
logger$
|
|
10078
|
+
logger$4.info('Session approved by wallet', {
|
|
10005
10079
|
sessionId: session?.sessionId,
|
|
10006
10080
|
accounts: session?.accounts?.length,
|
|
10007
10081
|
});
|
|
@@ -10010,7 +10084,7 @@ class WalletConnectionModalComponent {
|
|
|
10010
10084
|
catch (error) {
|
|
10011
10085
|
// Only show error if we're still on the QR pairing step (not cancelled)
|
|
10012
10086
|
if (this.currentStep() === ConnectionStep.QrPairing) {
|
|
10013
|
-
logger$
|
|
10087
|
+
logger$4.error('Session approval failed', { error });
|
|
10014
10088
|
this.connectionError.set(error instanceof Error ? error.message : 'Session approval failed or rejected');
|
|
10015
10089
|
}
|
|
10016
10090
|
this.isWaitingForWallet.set(false);
|
|
@@ -10021,7 +10095,7 @@ class WalletConnectionModalComponent {
|
|
|
10021
10095
|
* Handle QR code expiry
|
|
10022
10096
|
*/
|
|
10023
10097
|
onQrExpired() {
|
|
10024
|
-
logger$
|
|
10098
|
+
logger$4.debug('QR code expired');
|
|
10025
10099
|
this.pairingOffer.set('');
|
|
10026
10100
|
this.isWaitingForWallet.set(false);
|
|
10027
10101
|
}
|
|
@@ -10037,7 +10111,7 @@ class WalletConnectionModalComponent {
|
|
|
10037
10111
|
* Handle successful mobile connection
|
|
10038
10112
|
*/
|
|
10039
10113
|
onMobileConnected() {
|
|
10040
|
-
logger$
|
|
10114
|
+
logger$4.info('Mobile wallet connected');
|
|
10041
10115
|
this.connected.emit({ protocol: 'mobile-native', method: 'qr' });
|
|
10042
10116
|
void this.modalController.dismiss({ connected: true });
|
|
10043
10117
|
}
|
|
@@ -10088,7 +10162,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
10088
10162
|
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
10089
10163
|
* visit https://hsuite.finance/licensing
|
|
10090
10164
|
*/
|
|
10091
|
-
const logger$
|
|
10165
|
+
const logger$3 = getLogger().scoped?.('WalletConnectButton') ?? getLogger();
|
|
10092
10166
|
/**
|
|
10093
10167
|
* @component WalletConnectButtonComponent
|
|
10094
10168
|
* Ready-to-use wallet connection button for dApps with multi-protocol support.
|
|
@@ -10193,7 +10267,7 @@ class WalletConnectButtonComponent {
|
|
|
10193
10267
|
catch (err) {
|
|
10194
10268
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
10195
10269
|
this.error.emit(error);
|
|
10196
|
-
logger$
|
|
10270
|
+
logger$3.error('Connection failed', { error: error.message });
|
|
10197
10271
|
}
|
|
10198
10272
|
finally {
|
|
10199
10273
|
this.isConnecting = false;
|
|
@@ -10239,7 +10313,7 @@ class WalletConnectButtonComponent {
|
|
|
10239
10313
|
catch (err) {
|
|
10240
10314
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
10241
10315
|
this.error.emit(error);
|
|
10242
|
-
logger$
|
|
10316
|
+
logger$3.error('Disconnect failed', { error: error.message });
|
|
10243
10317
|
}
|
|
10244
10318
|
}
|
|
10245
10319
|
/**
|
|
@@ -11634,7 +11708,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
11634
11708
|
* }
|
|
11635
11709
|
* ```
|
|
11636
11710
|
*/
|
|
11637
|
-
const logger$
|
|
11711
|
+
const logger$2 = getLogger().scoped?.('TransactionService') ?? getLogger();
|
|
11638
11712
|
/**
|
|
11639
11713
|
* High-level transaction service with automatic state management.
|
|
11640
11714
|
*
|
|
@@ -11686,7 +11760,7 @@ class TransactionService {
|
|
|
11686
11760
|
async signTransaction(payload) {
|
|
11687
11761
|
return this.executeTransaction(async () => {
|
|
11688
11762
|
const result = (await this.walletService.signTransaction(payload));
|
|
11689
|
-
logger$
|
|
11763
|
+
logger$2.info('Transaction signed', {
|
|
11690
11764
|
hasSignature: !!result.signedTransaction,
|
|
11691
11765
|
});
|
|
11692
11766
|
await this.showSuccessToast('Transaction Signed', 'Your transaction has been signed successfully.');
|
|
@@ -11707,7 +11781,7 @@ class TransactionService {
|
|
|
11707
11781
|
async submitTransaction(payload) {
|
|
11708
11782
|
return this.executeTransaction(async () => {
|
|
11709
11783
|
const result = (await this.walletService.submitTransaction(payload));
|
|
11710
|
-
logger$
|
|
11784
|
+
logger$2.info('Transaction submitted', { transactionId: result.transactionId });
|
|
11711
11785
|
await this.showSuccessToast('Transaction Submitted', `Transaction ID: ${result.transactionId || 'Success'}`);
|
|
11712
11786
|
return result;
|
|
11713
11787
|
});
|
|
@@ -11726,7 +11800,7 @@ class TransactionService {
|
|
|
11726
11800
|
// Use the wallet's signAndExecuteTransaction method directly
|
|
11727
11801
|
// This uses hedera_signAndExecuteTransaction for WalletConnect (one prompt!)
|
|
11728
11802
|
const result = (await this.walletService.signAndExecuteTransaction(payload));
|
|
11729
|
-
logger$
|
|
11803
|
+
logger$2.info('Transaction signed and submitted', { transactionId: result.transactionId });
|
|
11730
11804
|
await this.showSuccessToast('Transaction Complete', `Transaction ID: ${result.transactionId || 'Success'}`);
|
|
11731
11805
|
return result;
|
|
11732
11806
|
});
|
|
@@ -11750,7 +11824,7 @@ class TransactionService {
|
|
|
11750
11824
|
batchKey: options.batchKey,
|
|
11751
11825
|
innerTransactions: options.innerTransactions,
|
|
11752
11826
|
}));
|
|
11753
|
-
logger$
|
|
11827
|
+
logger$2.info('Batch transaction submitted', { transactionId: result.transactionId });
|
|
11754
11828
|
await this.showSuccessToast('Batch Transaction Complete', `Transaction ID: ${result.transactionId || 'Success'}`);
|
|
11755
11829
|
return result;
|
|
11756
11830
|
});
|
|
@@ -11763,8 +11837,8 @@ class TransactionService {
|
|
|
11763
11837
|
*/
|
|
11764
11838
|
async signMessage(message) {
|
|
11765
11839
|
return this.executeTransaction(async () => {
|
|
11766
|
-
const result = await this.walletService.signMessage(message);
|
|
11767
|
-
logger$
|
|
11840
|
+
const result = (await this.walletService.signMessage(message));
|
|
11841
|
+
logger$2.info('Message signed', { hasSignature: !!result.signature });
|
|
11768
11842
|
await this.showSuccessToast('Message Signed', 'Your message has been signed successfully.');
|
|
11769
11843
|
return result;
|
|
11770
11844
|
});
|
|
@@ -11887,378 +11961,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
11887
11961
|
args: [{ providedIn: 'root' }]
|
|
11888
11962
|
}] });
|
|
11889
11963
|
|
|
11890
|
-
/**
|
|
11891
|
-
* HSuite Native Connect
|
|
11892
|
-
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
11893
|
-
*
|
|
11894
|
-
* SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
11895
|
-
*
|
|
11896
|
-
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
11897
|
-
* visit https://hsuite.finance/licensing
|
|
11898
|
-
*/
|
|
11899
|
-
/**
|
|
11900
|
-
* @file Smart-host customer session helper.
|
|
11901
|
-
*
|
|
11902
|
-
* @module services/smart-session
|
|
11903
|
-
*
|
|
11904
|
-
* @description
|
|
11905
|
-
* SmartSessionService automates the smart-host authentication handshake for
|
|
11906
|
-
* HSuite dApps. It discovers the host's `appId`, requests a challenge, signs it
|
|
11907
|
-
* with the active wallet account, and exchanges the signed challenge for a
|
|
11908
|
-
* short-lived bearer token.
|
|
11909
|
-
*
|
|
11910
|
-
* **Typical flow:**
|
|
11911
|
-
* ```typescript
|
|
11912
|
-
* const session = inject(SmartSessionService);
|
|
11913
|
-
* await session.login();
|
|
11914
|
-
* const bearer = session.getBearer();
|
|
11915
|
-
* ```
|
|
11916
|
-
*
|
|
11917
|
-
* The service also exposes {@link withSession} for automatic 401 recovery:
|
|
11918
|
-
* operations that fail with HTTP 401 are retried once after a fresh login.
|
|
11919
|
-
*/
|
|
11920
|
-
const logger$2 = getLogger().scoped?.('SmartSessionService') ?? getLogger();
|
|
11921
|
-
/**
|
|
11922
|
-
* Configuration token for {@link SmartSessionService}.
|
|
11923
|
-
*/
|
|
11924
|
-
const SMART_SESSION_CONFIG = new InjectionToken('SMART_SESSION_CONFIG', {
|
|
11925
|
-
factory: () => ({}),
|
|
11926
|
-
});
|
|
11927
|
-
/**
|
|
11928
|
-
* Smart-host customer session helper.
|
|
11929
|
-
*
|
|
11930
|
-
* @service SmartSessionService
|
|
11931
|
-
*
|
|
11932
|
-
* @description
|
|
11933
|
-
* Encapsulates the full challenge → sign → verify → store JWT flow required by
|
|
11934
|
-
* HSuite smart hosts. The service is intentionally thin: it delegates signing to
|
|
11935
|
-
* {@link TransactionService} and relies on standard Angular `HttpClient` for the
|
|
11936
|
-
* host HTTP calls.
|
|
11937
|
-
*
|
|
11938
|
-
* @providedIn root
|
|
11939
|
-
*/
|
|
11940
|
-
class SmartSessionService {
|
|
11941
|
-
http = inject(HttpClient);
|
|
11942
|
-
walletService = inject(UnifiedWalletService);
|
|
11943
|
-
transactionService = inject(TransactionService);
|
|
11944
|
-
config = inject(SMART_SESSION_CONFIG);
|
|
11945
|
-
get baseUrl() {
|
|
11946
|
-
return this.config.baseUrl ?? '';
|
|
11947
|
-
}
|
|
11948
|
-
get healthEndpoint() {
|
|
11949
|
-
return this.config.healthEndpoint ?? '/api/health';
|
|
11950
|
-
}
|
|
11951
|
-
get challengeEndpoint() {
|
|
11952
|
-
return this.config.challengeEndpoint ?? '/api/auth/challenge';
|
|
11953
|
-
}
|
|
11954
|
-
get verifyEndpoint() {
|
|
11955
|
-
return this.config.verifyEndpoint ?? '/api/auth/verify';
|
|
11956
|
-
}
|
|
11957
|
-
get storageKey() {
|
|
11958
|
-
return this.config.storageKey ?? 'hsuite.smart-session';
|
|
11959
|
-
}
|
|
11960
|
-
/**
|
|
11961
|
-
* Returns the currently stored bearer token, or `null` if there is no session.
|
|
11962
|
-
*
|
|
11963
|
-
* @returns Bearer token string or null
|
|
11964
|
-
*/
|
|
11965
|
-
getBearer() {
|
|
11966
|
-
const stored = this.readStoredSession();
|
|
11967
|
-
return stored && stored.expiresAt > Date.now() ? stored.bearer : null;
|
|
11968
|
-
}
|
|
11969
|
-
/**
|
|
11970
|
-
* Checks whether a non-expired session is available.
|
|
11971
|
-
*
|
|
11972
|
-
* @returns true if logged in and the bearer has not expired
|
|
11973
|
-
*/
|
|
11974
|
-
isLoggedIn() {
|
|
11975
|
-
return this.getBearer() !== null;
|
|
11976
|
-
}
|
|
11977
|
-
/**
|
|
11978
|
-
* Performs the full smart-host login handshake.
|
|
11979
|
-
*
|
|
11980
|
-
* @description
|
|
11981
|
-
* 1. Discovers `appId` from the health endpoint.
|
|
11982
|
-
* 2. Fetches a challenge from the challenge endpoint.
|
|
11983
|
-
* 3. Signs the challenge with the active wallet account.
|
|
11984
|
-
* 4. Exchanges the signed challenge for a bearer token.
|
|
11985
|
-
* 5. Stores the bearer and expiry in `sessionStorage`.
|
|
11986
|
-
*
|
|
11987
|
-
* @returns The verify response from the host
|
|
11988
|
-
*
|
|
11989
|
-
* @throws {Error} If no active account is available
|
|
11990
|
-
* @throws {Error} If the health endpoint does not return an `appId`
|
|
11991
|
-
* @throws {Error} If the challenge endpoint does not return a `challenge`
|
|
11992
|
-
* @throws {Error} If the verify call fails
|
|
11993
|
-
*/
|
|
11994
|
-
async login() {
|
|
11995
|
-
const account = this.walletService.activeAccount();
|
|
11996
|
-
if (!account) {
|
|
11997
|
-
throw new Error('No active account');
|
|
11998
|
-
}
|
|
11999
|
-
logger$2.info('Starting smart-host login handshake', {
|
|
12000
|
-
accountAddress: account.address,
|
|
12001
|
-
});
|
|
12002
|
-
const health = await this.fetchHealth();
|
|
12003
|
-
if (!health.appId) {
|
|
12004
|
-
throw new Error('Smart host health endpoint did not return appId');
|
|
12005
|
-
}
|
|
12006
|
-
const challengeResponse = await this.fetchChallenge(health.appId);
|
|
12007
|
-
if (!challengeResponse.challenge) {
|
|
12008
|
-
throw new Error('Smart host challenge endpoint did not return challenge');
|
|
12009
|
-
}
|
|
12010
|
-
const signResult = await this.transactionService.signMessage(challengeResponse.challenge);
|
|
12011
|
-
const verifyResponse = await this.verifyChallenge(health.appId, account, challengeResponse.challenge, signResult);
|
|
12012
|
-
if (!verifyResponse.bearer) {
|
|
12013
|
-
throw new Error('Smart host verify endpoint did not return bearer');
|
|
12014
|
-
}
|
|
12015
|
-
const expiresAt = this.resolveExpiry(verifyResponse);
|
|
12016
|
-
this.storeSession({ bearer: verifyResponse.bearer, expiresAt });
|
|
12017
|
-
logger$2.info('Smart-host login successful', {
|
|
12018
|
-
appId: health.appId,
|
|
12019
|
-
expiresAt,
|
|
12020
|
-
});
|
|
12021
|
-
return verifyResponse;
|
|
12022
|
-
}
|
|
12023
|
-
/**
|
|
12024
|
-
* Clears the stored session.
|
|
12025
|
-
*/
|
|
12026
|
-
logout() {
|
|
12027
|
-
this.clearStoredSession();
|
|
12028
|
-
logger$2.info('Smart-host session cleared');
|
|
12029
|
-
}
|
|
12030
|
-
/**
|
|
12031
|
-
* Runs an HTTP operation with automatic 401 recovery.
|
|
12032
|
-
*
|
|
12033
|
-
* @description
|
|
12034
|
-
* Executes the provided operation. If it rejects with an HTTP 401 error,
|
|
12035
|
-
* the service clears the current bearer, performs a fresh login, and retries
|
|
12036
|
-
* the operation once. Any other error is propagated immediately.
|
|
12037
|
-
*
|
|
12038
|
-
* @param operation - Async operation that needs a valid session
|
|
12039
|
-
* @returns The result of the operation
|
|
12040
|
-
*
|
|
12041
|
-
* @throws {Error} The original error if retry is not possible or fails
|
|
12042
|
-
*/
|
|
12043
|
-
async withSession(operation) {
|
|
12044
|
-
try {
|
|
12045
|
-
return await operation();
|
|
12046
|
-
}
|
|
12047
|
-
catch (error) {
|
|
12048
|
-
if (this.isUnauthorizedError(error)) {
|
|
12049
|
-
logger$2.warn('Operation received 401; attempting single session refresh');
|
|
12050
|
-
this.logout();
|
|
12051
|
-
await this.login();
|
|
12052
|
-
return await operation();
|
|
12053
|
-
}
|
|
12054
|
-
throw error;
|
|
12055
|
-
}
|
|
12056
|
-
}
|
|
12057
|
-
async fetchHealth() {
|
|
12058
|
-
return firstValueFrom(this.http.get(`${this.baseUrl}${this.healthEndpoint}`));
|
|
12059
|
-
}
|
|
12060
|
-
async fetchChallenge(appId) {
|
|
12061
|
-
return firstValueFrom(this.http.post(`${this.baseUrl}${this.challengeEndpoint}`, { appId }));
|
|
12062
|
-
}
|
|
12063
|
-
async verifyChallenge(appId, account, challenge, signResult) {
|
|
12064
|
-
const payload = {
|
|
12065
|
-
appId,
|
|
12066
|
-
accountAddress: account.address,
|
|
12067
|
-
publicKey: signResult.publicKey ?? account.publicKey,
|
|
12068
|
-
signature: signResult.signature,
|
|
12069
|
-
algorithm: signResult.algorithm,
|
|
12070
|
-
message: challenge,
|
|
12071
|
-
caipChainId: signResult.caipChainId,
|
|
12072
|
-
ledgerId: account.ledgerId,
|
|
12073
|
-
networkId: account.networkId,
|
|
12074
|
-
};
|
|
12075
|
-
return firstValueFrom(this.http.post(`${this.baseUrl}${this.verifyEndpoint}`, payload));
|
|
12076
|
-
}
|
|
12077
|
-
resolveExpiry(response) {
|
|
12078
|
-
if (response.expiresAt) {
|
|
12079
|
-
return response.expiresAt;
|
|
12080
|
-
}
|
|
12081
|
-
if (response.expiresIn) {
|
|
12082
|
-
return Date.now() + response.expiresIn * 1000;
|
|
12083
|
-
}
|
|
12084
|
-
// Default to 5 minutes if no expiry is provided
|
|
12085
|
-
return Date.now() + 5 * 60 * 1000;
|
|
12086
|
-
}
|
|
12087
|
-
readStoredSession() {
|
|
12088
|
-
try {
|
|
12089
|
-
const raw = sessionStorage.getItem(this.storageKey);
|
|
12090
|
-
if (!raw) {
|
|
12091
|
-
return null;
|
|
12092
|
-
}
|
|
12093
|
-
const parsed = JSON.parse(raw);
|
|
12094
|
-
if (!parsed.bearer || typeof parsed.expiresAt !== 'number') {
|
|
12095
|
-
return null;
|
|
12096
|
-
}
|
|
12097
|
-
return parsed;
|
|
12098
|
-
}
|
|
12099
|
-
catch {
|
|
12100
|
-
return null;
|
|
12101
|
-
}
|
|
12102
|
-
}
|
|
12103
|
-
storeSession(session) {
|
|
12104
|
-
try {
|
|
12105
|
-
sessionStorage.setItem(this.storageKey, JSON.stringify(session));
|
|
12106
|
-
}
|
|
12107
|
-
catch (error) {
|
|
12108
|
-
logger$2.warn('Failed to store smart session', { error });
|
|
12109
|
-
}
|
|
12110
|
-
}
|
|
12111
|
-
clearStoredSession() {
|
|
12112
|
-
try {
|
|
12113
|
-
sessionStorage.removeItem(this.storageKey);
|
|
12114
|
-
}
|
|
12115
|
-
catch (error) {
|
|
12116
|
-
logger$2.warn('Failed to clear smart session', { error });
|
|
12117
|
-
}
|
|
12118
|
-
}
|
|
12119
|
-
isUnauthorizedError(error) {
|
|
12120
|
-
if (!error || typeof error !== 'object') {
|
|
12121
|
-
return false;
|
|
12122
|
-
}
|
|
12123
|
-
const status = error.status;
|
|
12124
|
-
if (typeof status === 'number') {
|
|
12125
|
-
return status === 401;
|
|
12126
|
-
}
|
|
12127
|
-
const message = String(error.message ?? '');
|
|
12128
|
-
return /\b401\b|unauthorized/i.test(message);
|
|
12129
|
-
}
|
|
12130
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: SmartSessionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
12131
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: SmartSessionService, providedIn: 'root' });
|
|
12132
|
-
}
|
|
12133
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: SmartSessionService, decorators: [{
|
|
12134
|
-
type: Injectable,
|
|
12135
|
-
args: [{ providedIn: 'root' }]
|
|
12136
|
-
}] });
|
|
12137
|
-
|
|
12138
|
-
/**
|
|
12139
|
-
* HSuite Native Connect
|
|
12140
|
-
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
12141
|
-
*
|
|
12142
|
-
* SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
12143
|
-
*
|
|
12144
|
-
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
12145
|
-
* visit https://hsuite.finance/licensing
|
|
12146
|
-
*/
|
|
12147
|
-
/**
|
|
12148
|
-
* @file HTTP interceptor that attaches wallet-attributed auth headers.
|
|
12149
|
-
*
|
|
12150
|
-
* @module services/hsuite-auth-interceptor
|
|
12151
|
-
*
|
|
12152
|
-
* @description
|
|
12153
|
-
* `HsuiteAuthInterceptor` automatically adds the active smart-host bearer token
|
|
12154
|
-
* and wallet ledger identifier to outgoing HTTP requests. When a request fails
|
|
12155
|
-
* with HTTP 401, it delegates recovery to {@link SmartSessionService} for a
|
|
12156
|
-
* single re-login and retry.
|
|
12157
|
-
*
|
|
12158
|
-
* **Registration (standalone apps):**
|
|
12159
|
-
* ```typescript
|
|
12160
|
-
* provideHttpClient(withInterceptors([provideHsuiteAuthInterceptor()]))
|
|
12161
|
-
* ```
|
|
12162
|
-
*
|
|
12163
|
-
* **Registration (module-based apps):**
|
|
12164
|
-
* ```typescript
|
|
12165
|
-
* { provide: HTTP_INTERCEPTORS, useClass: HsuiteAuthInterceptor, multi: true }
|
|
12166
|
-
* ```
|
|
12167
|
-
*/
|
|
12168
|
-
/**
|
|
12169
|
-
* Headers injected by the interceptor.
|
|
12170
|
-
*/
|
|
12171
|
-
const HSUITE_AUTH_HEADER = 'Authorization';
|
|
12172
|
-
const HSUITE_LEDGER_HEADER = 'X-Ledger-Id';
|
|
12173
|
-
/**
|
|
12174
|
-
* Functional HTTP interceptor that attaches wallet-attributed auth headers.
|
|
12175
|
-
*
|
|
12176
|
-
* @description
|
|
12177
|
-
* Adds:
|
|
12178
|
-
* - `Authorization: Bearer <token>` when {@link SmartSessionService.getBearer} returns a token
|
|
12179
|
-
* - `X-Ledger-Id: <ledgerId>` when a wallet account is active
|
|
12180
|
-
*
|
|
12181
|
-
* On 401 responses, clears the stale bearer and retries once after re-login.
|
|
12182
|
-
*
|
|
12183
|
-
* @param req - The outgoing HTTP request
|
|
12184
|
-
* @param next - The downstream request handler
|
|
12185
|
-
* @returns Observable of HTTP events
|
|
12186
|
-
*/
|
|
12187
|
-
const hsuiteAuthInterceptor = (req, next) => {
|
|
12188
|
-
const session = inject(SmartSessionService);
|
|
12189
|
-
const wallet = inject(UnifiedWalletService);
|
|
12190
|
-
const authenticated = appendAuthHeaders(req, session, wallet);
|
|
12191
|
-
return next(authenticated).pipe(catchError((error) => {
|
|
12192
|
-
if (error instanceof HttpErrorResponse && error.status === 401) {
|
|
12193
|
-
session.logout();
|
|
12194
|
-
return from(session.login()).pipe(switchMap(() => next(appendAuthHeaders(req, session, wallet))), catchError((loginError) => throwError(() => loginError)));
|
|
12195
|
-
}
|
|
12196
|
-
return throwError(() => error);
|
|
12197
|
-
}));
|
|
12198
|
-
};
|
|
12199
|
-
/**
|
|
12200
|
-
* Class-based HTTP interceptor for module-based Angular apps.
|
|
12201
|
-
*
|
|
12202
|
-
* @description
|
|
12203
|
-
* Provides the same behavior as {@link hsuiteAuthInterceptor} in a class form
|
|
12204
|
-
* suitable for registration via `HTTP_INTERCEPTORS`.
|
|
12205
|
-
*/
|
|
12206
|
-
class HsuiteAuthInterceptor {
|
|
12207
|
-
session = inject(SmartSessionService);
|
|
12208
|
-
wallet = inject(UnifiedWalletService);
|
|
12209
|
-
/**
|
|
12210
|
-
* Intercepts outgoing HTTP requests to attach wallet-attributed auth headers.
|
|
12211
|
-
*
|
|
12212
|
-
* @param req - The outgoing HTTP request
|
|
12213
|
-
* @param next - The downstream request handler
|
|
12214
|
-
* @returns Observable of HTTP events
|
|
12215
|
-
*/
|
|
12216
|
-
intercept(req, next) {
|
|
12217
|
-
const authenticated = appendAuthHeaders(req, this.session, this.wallet);
|
|
12218
|
-
return next.handle(authenticated).pipe(catchError((error) => {
|
|
12219
|
-
if (error instanceof HttpErrorResponse && error.status === 401) {
|
|
12220
|
-
this.session.logout();
|
|
12221
|
-
return from(this.session.login()).pipe(switchMap(() => next.handle(appendAuthHeaders(req, this.session, this.wallet))), catchError((loginError) => throwError(() => loginError)));
|
|
12222
|
-
}
|
|
12223
|
-
return throwError(() => error);
|
|
12224
|
-
}));
|
|
12225
|
-
}
|
|
12226
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: HsuiteAuthInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
12227
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: HsuiteAuthInterceptor, providedIn: 'root' });
|
|
12228
|
-
}
|
|
12229
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: HsuiteAuthInterceptor, decorators: [{
|
|
12230
|
-
type: Injectable,
|
|
12231
|
-
args: [{ providedIn: 'root' }]
|
|
12232
|
-
}] });
|
|
12233
|
-
/**
|
|
12234
|
-
* Helper that clones a request with the active auth headers attached.
|
|
12235
|
-
*
|
|
12236
|
-
* @param req - The outgoing HTTP request
|
|
12237
|
-
* @param session - Smart session service for bearer lookup
|
|
12238
|
-
* @param wallet - Unified wallet service for ledger ID lookup
|
|
12239
|
-
* @returns The request cloned with Authorization and/or X-Ledger-Id headers
|
|
12240
|
-
*/
|
|
12241
|
-
function appendAuthHeaders(req, session, wallet) {
|
|
12242
|
-
const bearer = session.getBearer();
|
|
12243
|
-
const activeAccount = wallet.activeAccount();
|
|
12244
|
-
const ledgerId = activeAccount?.ledgerId;
|
|
12245
|
-
// Avoid mutating requests that already carry an Authorization header
|
|
12246
|
-
if (!bearer && !ledgerId) {
|
|
12247
|
-
return req;
|
|
12248
|
-
}
|
|
12249
|
-
const headers = {};
|
|
12250
|
-
if (bearer && !req.headers.has(HSUITE_AUTH_HEADER)) {
|
|
12251
|
-
headers[HSUITE_AUTH_HEADER] = `Bearer ${bearer}`;
|
|
12252
|
-
}
|
|
12253
|
-
if (ledgerId && !req.headers.has(HSUITE_LEDGER_HEADER)) {
|
|
12254
|
-
headers[HSUITE_LEDGER_HEADER] = ledgerId;
|
|
12255
|
-
}
|
|
12256
|
-
if (Object.keys(headers).length === 0) {
|
|
12257
|
-
return req;
|
|
12258
|
-
}
|
|
12259
|
-
return req.clone({ setHeaders: headers });
|
|
12260
|
-
}
|
|
12261
|
-
|
|
12262
11964
|
/**
|
|
12263
11965
|
* HSuite Native Connect
|
|
12264
11966
|
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
@@ -15199,5 +14901,5 @@ function provideWalletErrorHandler(config) {
|
|
|
15199
14901
|
* Generated bundle index. Do not edit.
|
|
15200
14902
|
*/
|
|
15201
14903
|
|
|
15202
|
-
export { ACTIVE_ACCOUNT_SOURCE, AccountActionsComponent, AccountFilterComponent, AccountFormattingService, AccountGroupingService, AccountListComponent, AccountSelectorComponent, AccountSelectorService, BaseWalletProvider, ChannelClientService, ChromeExtensionTransport, DEFAULT_LEDGER_ICONS, DEFAULT_WALLET_URL,
|
|
14904
|
+
export { ACTIVE_ACCOUNT_SOURCE, AccountActionsComponent, AccountFilterComponent, AccountFormattingService, AccountGroupingService, AccountListComponent, AccountSelectorComponent, AccountSelectorService, BaseWalletProvider, ChannelClientService, ChromeExtensionTransport, DEFAULT_LEDGER_ICONS, DEFAULT_WALLET_URL, HederaSigner, HederaTransactionBuilderService, HsuiteNativeProvider, HsuiteWalletModule, LEDGER_COLORS, LEDGER_ICON_NAMES, LEDGER_NAMES, LedgerUIRegistry, LoggerService, P2PNativeProvider, P2PSessionManager, SignerFactory, TransactionService, UnifiedWalletService, WalletAccountDisplayComponent, WalletConnectButtonComponent, WalletConnectClientManager, WalletConnectPromptComponent, WalletConnectSessionStore, WalletConnectSigningOrchestrator, WalletConnectV2Provider, WalletConnectedDirective, WalletConnectedGuardComponent, WalletConnectionModalComponent, WalletContextDirective, WalletContextService, WalletErrorHandler, WalletEventBus, WalletEventsDirective, WalletSessionDisplayComponent, WalletTransactionStatusComponent, XrplSigner, XrplTransactionBuilderService, getExtensionVersion, getLedgerColor, getLedgerIcon, getLedgerName, getTokenIcon, isExtensionInstalled, isHsuiteNativeConfig, isWalletConnectV2Config, provideWalletErrorHandler, registerLedgerIcons, scaleHederaAmountToBaseUnits };
|
|
15203
14905
|
//# sourceMappingURL=hsuite-native-connect-angular.mjs.map
|