@metamask/snap-networks-utils 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +63 -1
- package/README.md +4 -10
- package/dist/index.cjs +102 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +51 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +32 -1
- package/dist/index.mjs.map +1 -1
- package/dist/providers/assets/AssetsProvider.cjs +36 -18
- package/dist/providers/assets/AssetsProvider.cjs.map +1 -1
- package/dist/providers/assets/AssetsProvider.d.cts +30 -2
- package/dist/providers/assets/AssetsProvider.d.cts.map +1 -1
- package/dist/providers/assets/AssetsProvider.d.mts +30 -2
- package/dist/providers/assets/AssetsProvider.d.mts.map +1 -1
- package/dist/providers/assets/AssetsProvider.mjs +36 -18
- package/dist/providers/assets/AssetsProvider.mjs.map +1 -1
- package/dist/providers/remote-feature-flags/RemoteFeatureFlagsProvider.cjs +4 -17
- package/dist/providers/remote-feature-flags/RemoteFeatureFlagsProvider.cjs.map +1 -1
- package/dist/providers/remote-feature-flags/RemoteFeatureFlagsProvider.mjs +4 -17
- package/dist/providers/remote-feature-flags/RemoteFeatureFlagsProvider.mjs.map +1 -1
- package/dist/services/analytics/AnalyticsService.cjs +225 -0
- package/dist/services/analytics/AnalyticsService.cjs.map +1 -0
- package/dist/services/analytics/AnalyticsService.d.cts +175 -0
- package/dist/services/analytics/AnalyticsService.d.cts.map +1 -0
- package/dist/services/analytics/AnalyticsService.d.mts +175 -0
- package/dist/services/analytics/AnalyticsService.d.mts.map +1 -0
- package/dist/services/analytics/AnalyticsService.mjs +221 -0
- package/dist/services/analytics/AnalyticsService.mjs.map +1 -0
- package/dist/ui/ActionHeader/ActionHeader.cjs +23 -0
- package/dist/ui/ActionHeader/ActionHeader.cjs.map +1 -0
- package/dist/ui/ActionHeader/ActionHeader.d.cts +27 -0
- package/dist/ui/ActionHeader/ActionHeader.d.cts.map +1 -0
- package/dist/ui/ActionHeader/ActionHeader.d.mts +27 -0
- package/dist/ui/ActionHeader/ActionHeader.d.mts.map +1 -0
- package/dist/ui/ActionHeader/ActionHeader.mjs +19 -0
- package/dist/ui/ActionHeader/ActionHeader.mjs.map +1 -0
- package/dist/ui/Asset/Asset.cjs +68 -0
- package/dist/ui/Asset/Asset.cjs.map +1 -0
- package/dist/ui/Asset/Asset.d.cts +83 -0
- package/dist/ui/Asset/Asset.d.cts.map +1 -0
- package/dist/ui/Asset/Asset.d.mts +83 -0
- package/dist/ui/Asset/Asset.d.mts.map +1 -0
- package/dist/ui/Asset/Asset.mjs +60 -0
- package/dist/ui/Asset/Asset.mjs.map +1 -0
- package/dist/ui/Asset/question-mark.svg +3 -0
- package/dist/ui/EstimatedChanges/EstimatedChanges.cjs +57 -0
- package/dist/ui/EstimatedChanges/EstimatedChanges.cjs.map +1 -0
- package/dist/ui/EstimatedChanges/EstimatedChanges.d.cts +50 -0
- package/dist/ui/EstimatedChanges/EstimatedChanges.d.cts.map +1 -0
- package/dist/ui/EstimatedChanges/EstimatedChanges.d.mts +50 -0
- package/dist/ui/EstimatedChanges/EstimatedChanges.d.mts.map +1 -0
- package/dist/ui/EstimatedChanges/EstimatedChanges.mjs +53 -0
- package/dist/ui/EstimatedChanges/EstimatedChanges.mjs.map +1 -0
- package/dist/ui/TransactionAlert/TransactionAlert.cjs +72 -0
- package/dist/ui/TransactionAlert/TransactionAlert.cjs.map +1 -0
- package/dist/ui/TransactionAlert/TransactionAlert.d.cts +58 -0
- package/dist/ui/TransactionAlert/TransactionAlert.d.cts.map +1 -0
- package/dist/ui/TransactionAlert/TransactionAlert.d.mts +58 -0
- package/dist/ui/TransactionAlert/TransactionAlert.d.mts.map +1 -0
- package/dist/ui/TransactionAlert/TransactionAlert.mjs +68 -0
- package/dist/ui/TransactionAlert/TransactionAlert.mjs.map +1 -0
- package/dist/utils/async/async.cjs +95 -0
- package/dist/utils/async/async.cjs.map +1 -0
- package/dist/utils/async/async.d.cts +51 -0
- package/dist/utils/async/async.d.cts.map +1 -0
- package/dist/utils/async/async.d.mts +51 -0
- package/dist/utils/async/async.d.mts.map +1 -0
- package/dist/utils/async/async.mjs +88 -0
- package/dist/utils/async/async.mjs.map +1 -0
- package/dist/utils/buildUrl/buildUrl.cjs +54 -0
- package/dist/utils/buildUrl/buildUrl.cjs.map +1 -0
- package/dist/utils/buildUrl/buildUrl.d.cts +15 -0
- package/dist/utils/buildUrl/buildUrl.d.cts.map +1 -0
- package/dist/utils/buildUrl/buildUrl.d.mts +15 -0
- package/dist/utils/buildUrl/buildUrl.d.mts.map +1 -0
- package/dist/utils/buildUrl/buildUrl.mjs +51 -0
- package/dist/utils/buildUrl/buildUrl.mjs.map +1 -0
- package/dist/utils/cache/InMemoryCache.cjs +134 -0
- package/dist/utils/cache/InMemoryCache.cjs.map +1 -0
- package/dist/utils/cache/InMemoryCache.d.cts +29 -0
- package/dist/utils/cache/InMemoryCache.d.cts.map +1 -0
- package/dist/utils/cache/InMemoryCache.d.mts +29 -0
- package/dist/utils/cache/InMemoryCache.d.mts.map +1 -0
- package/dist/utils/cache/InMemoryCache.mjs +130 -0
- package/dist/utils/cache/InMemoryCache.mjs.map +1 -0
- package/dist/utils/cache/StateCache.cjs +193 -0
- package/dist/utils/cache/StateCache.cjs.map +1 -0
- package/dist/utils/cache/StateCache.d.cts +96 -0
- package/dist/utils/cache/StateCache.d.cts.map +1 -0
- package/dist/utils/cache/StateCache.d.mts +96 -0
- package/dist/utils/cache/StateCache.d.mts.map +1 -0
- package/dist/utils/cache/StateCache.mjs +189 -0
- package/dist/utils/cache/StateCache.mjs.map +1 -0
- package/dist/utils/cache/types.cjs +3 -0
- package/dist/utils/cache/types.cjs.map +1 -0
- package/dist/utils/cache/types.d.cts +99 -0
- package/dist/utils/cache/types.d.cts.map +1 -0
- package/dist/utils/cache/types.d.mts +99 -0
- package/dist/utils/cache/types.d.mts.map +1 -0
- package/dist/utils/cache/types.mjs +2 -0
- package/dist/utils/cache/types.mjs.map +1 -0
- package/dist/utils/cache/useCache.cjs +82 -0
- package/dist/utils/cache/useCache.cjs.map +1 -0
- package/dist/utils/cache/useCache.d.cts +57 -0
- package/dist/utils/cache/useCache.d.cts.map +1 -0
- package/dist/utils/cache/useCache.d.mts +57 -0
- package/dist/utils/cache/useCache.d.mts.map +1 -0
- package/dist/utils/cache/useCache.mjs +78 -0
- package/dist/utils/cache/useCache.mjs.map +1 -0
- package/dist/utils/cache/useCacheUntil.cjs +80 -0
- package/dist/utils/cache/useCacheUntil.cjs.map +1 -0
- package/dist/utils/cache/useCacheUntil.d.cts +54 -0
- package/dist/utils/cache/useCacheUntil.d.cts.map +1 -0
- package/dist/utils/cache/useCacheUntil.d.mts +54 -0
- package/dist/utils/cache/useCacheUntil.d.mts.map +1 -0
- package/dist/utils/cache/useCacheUntil.mjs +76 -0
- package/dist/utils/cache/useCacheUntil.mjs.map +1 -0
- package/dist/utils/config/BaseConfigProvider.cjs +62 -0
- package/dist/utils/config/BaseConfigProvider.cjs.map +1 -0
- package/dist/utils/config/BaseConfigProvider.d.cts +54 -0
- package/dist/utils/config/BaseConfigProvider.d.cts.map +1 -0
- package/dist/utils/config/BaseConfigProvider.d.mts +54 -0
- package/dist/utils/config/BaseConfigProvider.d.mts.map +1 -0
- package/dist/utils/config/BaseConfigProvider.mjs +58 -0
- package/dist/utils/config/BaseConfigProvider.mjs.map +1 -0
- package/dist/utils/config/envStructs.cjs +69 -0
- package/dist/utils/config/envStructs.cjs.map +1 -0
- package/dist/utils/config/envStructs.d.cts +57 -0
- package/dist/utils/config/envStructs.d.cts.map +1 -0
- package/dist/utils/config/envStructs.d.mts +57 -0
- package/dist/utils/config/envStructs.d.mts.map +1 -0
- package/dist/utils/config/envStructs.mjs +61 -0
- package/dist/utils/config/envStructs.mjs.map +1 -0
- package/dist/utils/config/environmentStruct.cjs +19 -0
- package/dist/utils/config/environmentStruct.cjs.map +1 -0
- package/dist/utils/config/environmentStruct.d.cts +20 -0
- package/dist/utils/config/environmentStruct.d.cts.map +1 -0
- package/dist/utils/config/environmentStruct.d.mts +20 -0
- package/dist/utils/config/environmentStruct.d.mts.map +1 -0
- package/dist/utils/config/environmentStruct.mjs +16 -0
- package/dist/utils/config/environmentStruct.mjs.map +1 -0
- package/dist/utils/config/logLevelStruct.cjs +14 -0
- package/dist/utils/config/logLevelStruct.cjs.map +1 -0
- package/dist/utils/config/logLevelStruct.d.cts +17 -0
- package/dist/utils/config/logLevelStruct.d.cts.map +1 -0
- package/dist/utils/config/logLevelStruct.d.mts +17 -0
- package/dist/utils/config/logLevelStruct.d.mts.map +1 -0
- package/dist/utils/config/logLevelStruct.mjs +11 -0
- package/dist/utils/config/logLevelStruct.mjs.map +1 -0
- package/dist/utils/config/parseEnv.cjs +30 -0
- package/dist/utils/config/parseEnv.cjs.map +1 -0
- package/dist/utils/config/parseEnv.d.cts +19 -0
- package/dist/utils/config/parseEnv.d.cts.map +1 -0
- package/dist/utils/config/parseEnv.d.mts +19 -0
- package/dist/utils/config/parseEnv.d.mts.map +1 -0
- package/dist/utils/config/parseEnv.mjs +26 -0
- package/dist/utils/config/parseEnv.mjs.map +1 -0
- package/dist/utils/dedupe/InFlightCoalescer.cjs +28 -0
- package/dist/utils/dedupe/InFlightCoalescer.cjs.map +1 -0
- package/dist/utils/dedupe/InFlightCoalescer.d.cts +12 -0
- package/dist/utils/dedupe/InFlightCoalescer.d.cts.map +1 -0
- package/dist/utils/dedupe/InFlightCoalescer.d.mts +12 -0
- package/dist/utils/dedupe/InFlightCoalescer.d.mts.map +1 -0
- package/dist/utils/dedupe/InFlightCoalescer.mjs +24 -0
- package/dist/utils/dedupe/InFlightCoalescer.mjs.map +1 -0
- package/dist/utils/errors/errors.cjs +44 -0
- package/dist/utils/errors/errors.cjs.map +1 -0
- package/dist/utils/errors/errors.d.cts +37 -0
- package/dist/utils/errors/errors.d.cts.map +1 -0
- package/dist/utils/errors/errors.d.mts +37 -0
- package/dist/utils/errors/errors.d.mts.map +1 -0
- package/dist/utils/errors/errors.mjs +40 -0
- package/dist/utils/errors/errors.mjs.map +1 -0
- package/dist/utils/errors/index.cjs +18 -0
- package/dist/utils/errors/index.cjs.map +1 -0
- package/dist/utils/errors/index.d.cts +10 -0
- package/dist/utils/errors/index.d.cts.map +1 -0
- package/dist/utils/errors/index.d.mts +10 -0
- package/dist/utils/errors/index.d.mts.map +1 -0
- package/dist/utils/errors/index.mjs +6 -0
- package/dist/utils/errors/index.mjs.map +1 -0
- package/dist/utils/errors/snapRpcError.cjs +33 -0
- package/dist/utils/errors/snapRpcError.cjs.map +1 -0
- package/dist/utils/errors/snapRpcError.d.cts +11 -0
- package/dist/utils/errors/snapRpcError.d.cts.map +1 -0
- package/dist/utils/errors/snapRpcError.d.mts +11 -0
- package/dist/utils/errors/snapRpcError.d.mts.map +1 -0
- package/dist/utils/errors/snapRpcError.mjs +30 -0
- package/dist/utils/errors/snapRpcError.mjs.map +1 -0
- package/dist/utils/errors/stringifyReason.cjs +36 -0
- package/dist/utils/errors/stringifyReason.cjs.map +1 -0
- package/dist/utils/errors/stringifyReason.d.cts +15 -0
- package/dist/utils/errors/stringifyReason.d.cts.map +1 -0
- package/dist/utils/errors/stringifyReason.d.mts +15 -0
- package/dist/utils/errors/stringifyReason.d.mts.map +1 -0
- package/dist/utils/errors/stringifyReason.mjs +33 -0
- package/dist/utils/errors/stringifyReason.mjs.map +1 -0
- package/dist/utils/errors/syncError.cjs +98 -0
- package/dist/utils/errors/syncError.cjs.map +1 -0
- package/dist/utils/errors/syncError.d.cts +60 -0
- package/dist/utils/errors/syncError.d.cts.map +1 -0
- package/dist/utils/errors/syncError.d.mts +60 -0
- package/dist/utils/errors/syncError.d.mts.map +1 -0
- package/dist/utils/errors/syncError.mjs +92 -0
- package/dist/utils/errors/syncError.mjs.map +1 -0
- package/dist/utils/errors/trackError.cjs +76 -0
- package/dist/utils/errors/trackError.cjs.map +1 -0
- package/dist/utils/errors/trackError.d.cts +64 -0
- package/dist/utils/errors/trackError.d.cts.map +1 -0
- package/dist/utils/errors/trackError.d.mts +64 -0
- package/dist/utils/errors/trackError.d.mts.map +1 -0
- package/dist/utils/errors/trackError.mjs +72 -0
- package/dist/utils/errors/trackError.mjs.map +1 -0
- package/dist/utils/handlers/wrapSnapHandlers.cjs +57 -0
- package/dist/utils/handlers/wrapSnapHandlers.cjs.map +1 -0
- package/dist/utils/handlers/wrapSnapHandlers.d.cts +74 -0
- package/dist/utils/handlers/wrapSnapHandlers.d.cts.map +1 -0
- package/dist/utils/handlers/wrapSnapHandlers.d.mts +74 -0
- package/dist/utils/handlers/wrapSnapHandlers.d.mts.map +1 -0
- package/dist/utils/handlers/wrapSnapHandlers.mjs +53 -0
- package/dist/utils/handlers/wrapSnapHandlers.mjs.map +1 -0
- package/dist/utils/keyringAccount/keyringAccount.cjs +25 -0
- package/dist/utils/keyringAccount/keyringAccount.cjs.map +1 -0
- package/dist/utils/keyringAccount/keyringAccount.d.cts +29 -0
- package/dist/utils/keyringAccount/keyringAccount.d.cts.map +1 -0
- package/dist/utils/keyringAccount/keyringAccount.d.mts +29 -0
- package/dist/utils/keyringAccount/keyringAccount.d.mts.map +1 -0
- package/dist/utils/keyringAccount/keyringAccount.mjs +22 -0
- package/dist/utils/keyringAccount/keyringAccount.mjs.map +1 -0
- package/dist/utils/logger/Logger.cjs +140 -0
- package/dist/utils/logger/Logger.cjs.map +1 -0
- package/dist/utils/logger/Logger.d.cts +118 -0
- package/dist/utils/logger/Logger.d.cts.map +1 -0
- package/dist/utils/logger/Logger.d.mts +118 -0
- package/dist/utils/logger/Logger.d.mts.map +1 -0
- package/dist/utils/logger/Logger.mjs +136 -0
- package/dist/utils/logger/Logger.mjs.map +1 -0
- package/dist/utils/logger/__mocks__/Logger.cjs +26 -0
- package/dist/utils/logger/__mocks__/Logger.cjs.map +1 -0
- package/dist/utils/logger/__mocks__/Logger.d.cts +3 -0
- package/dist/utils/logger/__mocks__/Logger.d.cts.map +1 -0
- package/dist/utils/logger/__mocks__/Logger.d.mts +3 -0
- package/dist/utils/logger/__mocks__/Logger.d.mts.map +1 -0
- package/dist/utils/logger/__mocks__/Logger.mjs +23 -0
- package/dist/utils/logger/__mocks__/Logger.mjs.map +1 -0
- package/dist/utils/originPermissions/createOriginPermissions.cjs +30 -0
- package/dist/utils/originPermissions/createOriginPermissions.cjs.map +1 -0
- package/dist/utils/originPermissions/createOriginPermissions.d.cts +24 -0
- package/dist/utils/originPermissions/createOriginPermissions.d.cts.map +1 -0
- package/dist/utils/originPermissions/createOriginPermissions.d.mts +24 -0
- package/dist/utils/originPermissions/createOriginPermissions.d.mts.map +1 -0
- package/dist/utils/originPermissions/createOriginPermissions.mjs +26 -0
- package/dist/utils/originPermissions/createOriginPermissions.mjs.map +1 -0
- package/dist/utils/originPermissions/validateOrigin.cjs +23 -0
- package/dist/utils/originPermissions/validateOrigin.cjs.map +1 -0
- package/dist/utils/originPermissions/validateOrigin.d.cts +10 -0
- package/dist/utils/originPermissions/validateOrigin.d.cts.map +1 -0
- package/dist/utils/originPermissions/validateOrigin.d.mts +10 -0
- package/dist/utils/originPermissions/validateOrigin.d.mts.map +1 -0
- package/dist/utils/originPermissions/validateOrigin.mjs +19 -0
- package/dist/utils/originPermissions/validateOrigin.mjs.map +1 -0
- package/dist/utils/proofOfOwnership/proofOfOwnership.cjs +89 -0
- package/dist/utils/proofOfOwnership/proofOfOwnership.cjs.map +1 -0
- package/dist/utils/proofOfOwnership/proofOfOwnership.d.cts +143 -0
- package/dist/utils/proofOfOwnership/proofOfOwnership.d.cts.map +1 -0
- package/dist/utils/proofOfOwnership/proofOfOwnership.d.mts +143 -0
- package/dist/utils/proofOfOwnership/proofOfOwnership.d.mts.map +1 -0
- package/dist/utils/proofOfOwnership/proofOfOwnership.mjs +85 -0
- package/dist/utils/proofOfOwnership/proofOfOwnership.mjs.map +1 -0
- package/dist/utils/safeMerge/safeMerge.cjs +26 -0
- package/dist/utils/safeMerge/safeMerge.cjs.map +1 -0
- package/dist/utils/safeMerge/safeMerge.d.cts +17 -0
- package/dist/utils/safeMerge/safeMerge.d.cts.map +1 -0
- package/dist/utils/safeMerge/safeMerge.d.mts +17 -0
- package/dist/utils/safeMerge/safeMerge.d.mts.map +1 -0
- package/dist/utils/safeMerge/safeMerge.mjs +22 -0
- package/dist/utils/safeMerge/safeMerge.mjs.map +1 -0
- package/dist/utils/sanitize/sanitize.cjs +42 -0
- package/dist/utils/sanitize/sanitize.cjs.map +1 -0
- package/dist/utils/sanitize/sanitize.d.cts +15 -0
- package/dist/utils/sanitize/sanitize.d.cts.map +1 -0
- package/dist/utils/sanitize/sanitize.d.mts +15 -0
- package/dist/utils/sanitize/sanitize.d.mts.map +1 -0
- package/dist/utils/sanitize/sanitize.mjs +38 -0
- package/dist/utils/sanitize/sanitize.mjs.map +1 -0
- package/dist/utils/serialization/serialization.cjs +73 -0
- package/dist/utils/serialization/serialization.cjs.map +1 -0
- package/dist/utils/serialization/serialization.d.cts +19 -0
- package/dist/utils/serialization/serialization.d.cts.map +1 -0
- package/dist/utils/serialization/serialization.d.mts +19 -0
- package/dist/utils/serialization/serialization.d.mts.map +1 -0
- package/dist/utils/serialization/serialization.mjs +69 -0
- package/dist/utils/serialization/serialization.mjs.map +1 -0
- package/dist/utils/serialization/types.cjs +3 -0
- package/dist/utils/serialization/types.cjs.map +1 -0
- package/dist/utils/serialization/types.d.cts +8 -0
- package/dist/utils/serialization/types.d.cts.map +1 -0
- package/dist/utils/serialization/types.d.mts +8 -0
- package/dist/utils/serialization/types.d.mts.map +1 -0
- package/dist/utils/serialization/types.mjs +2 -0
- package/dist/utils/serialization/types.mjs.map +1 -0
- package/dist/utils/state/IStateManager.cjs +3 -0
- package/dist/utils/state/IStateManager.cjs.map +1 -0
- package/dist/utils/state/IStateManager.d.cts +69 -0
- package/dist/utils/state/IStateManager.d.cts.map +1 -0
- package/dist/utils/state/IStateManager.d.mts +69 -0
- package/dist/utils/state/IStateManager.d.mts.map +1 -0
- package/dist/utils/state/IStateManager.mjs +2 -0
- package/dist/utils/state/IStateManager.mjs.map +1 -0
- package/dist/utils/state/InMemoryState.cjs +41 -0
- package/dist/utils/state/InMemoryState.cjs.map +1 -0
- package/dist/utils/state/InMemoryState.d.cts +18 -0
- package/dist/utils/state/InMemoryState.d.cts.map +1 -0
- package/dist/utils/state/InMemoryState.d.mts +18 -0
- package/dist/utils/state/InMemoryState.d.mts.map +1 -0
- package/dist/utils/state/InMemoryState.mjs +38 -0
- package/dist/utils/state/InMemoryState.mjs.map +1 -0
- package/dist/utils/state/State.cjs +159 -0
- package/dist/utils/state/State.cjs.map +1 -0
- package/dist/utils/state/State.d.cts +25 -0
- package/dist/utils/state/State.d.cts.map +1 -0
- package/dist/utils/state/State.d.mts +25 -0
- package/dist/utils/state/State.d.mts.map +1 -0
- package/dist/utils/state/State.mjs +156 -0
- package/dist/utils/state/State.mjs.map +1 -0
- package/dist/utils/transactionType/transactionType.cjs +32 -0
- package/dist/utils/transactionType/transactionType.cjs.map +1 -0
- package/dist/utils/transactionType/transactionType.d.cts +17 -0
- package/dist/utils/transactionType/transactionType.d.cts.map +1 -0
- package/dist/utils/transactionType/transactionType.d.mts +17 -0
- package/dist/utils/transactionType/transactionType.d.mts.map +1 -0
- package/dist/utils/transactionType/transactionType.mjs +28 -0
- package/dist/utils/transactionType/transactionType.mjs.map +1 -0
- package/dist/utils/urlStruct/urlStruct.cjs +96 -0
- package/dist/utils/urlStruct/urlStruct.cjs.map +1 -0
- package/dist/utils/urlStruct/urlStruct.d.cts +25 -0
- package/dist/utils/urlStruct/urlStruct.d.cts.map +1 -0
- package/dist/utils/urlStruct/urlStruct.d.mts +25 -0
- package/dist/utils/urlStruct/urlStruct.d.mts.map +1 -0
- package/dist/utils/urlStruct/urlStruct.mjs +93 -0
- package/dist/utils/urlStruct/urlStruct.mjs.map +1 -0
- package/dist/utils/uuidStruct/uuidStruct.cjs +12 -0
- package/dist/utils/uuidStruct/uuidStruct.cjs.map +1 -0
- package/dist/utils/uuidStruct/uuidStruct.d.cts +8 -0
- package/dist/utils/uuidStruct/uuidStruct.d.cts.map +1 -0
- package/dist/utils/uuidStruct/uuidStruct.d.mts +8 -0
- package/dist/utils/uuidStruct/uuidStruct.d.mts.map +1 -0
- package/dist/utils/uuidStruct/uuidStruct.mjs +9 -0
- package/dist/utils/uuidStruct/uuidStruct.mjs.map +1 -0
- package/package.json +33 -13
- package/dist/logger.cjs +0 -57
- package/dist/logger.cjs.map +0 -1
- package/dist/logger.d.cts +0 -30
- package/dist/logger.d.cts.map +0 -1
- package/dist/logger.d.mts +0 -30
- package/dist/logger.d.mts.map +0 -1
- package/dist/logger.mjs +0 -53
- package/dist/logger.mjs.map +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ComponentOrElement } from "@metamask/snaps-sdk";
|
|
2
|
+
export type ActionHeaderProps = {
|
|
3
|
+
title: string;
|
|
4
|
+
/** Muted text shown below the title. */
|
|
5
|
+
subtitle?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Asset icon URL; when set, an extra-large asset icon is shown below the
|
|
8
|
+
* title. A blank URL shows the question-mark icon.
|
|
9
|
+
*/
|
|
10
|
+
iconUrl?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Renders the centered header at the top of a confirmation: a large title,
|
|
14
|
+
* then an optional subtitle and asset icon.
|
|
15
|
+
*
|
|
16
|
+
* @param props - The component props.
|
|
17
|
+
* @param props.title - The title.
|
|
18
|
+
* @param props.subtitle - The subtitle.
|
|
19
|
+
* @param props.iconUrl - The asset icon URL.
|
|
20
|
+
* @returns The header element.
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <ActionHeader title={translate('confirmation.signMessage.title')} />;
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare const ActionHeader: ({ title, subtitle, iconUrl, }: ActionHeaderProps) => ComponentOrElement;
|
|
27
|
+
//# sourceMappingURL=ActionHeader.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionHeader.d.cts","sourceRoot":"","sources":["../../../src/ui/ActionHeader/ActionHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,4BAA4B;AAK9D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,GAAI,+BAI1B,iBAAiB,KAAG,kBAgBtB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ComponentOrElement } from "@metamask/snaps-sdk";
|
|
2
|
+
export type ActionHeaderProps = {
|
|
3
|
+
title: string;
|
|
4
|
+
/** Muted text shown below the title. */
|
|
5
|
+
subtitle?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Asset icon URL; when set, an extra-large asset icon is shown below the
|
|
8
|
+
* title. A blank URL shows the question-mark icon.
|
|
9
|
+
*/
|
|
10
|
+
iconUrl?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Renders the centered header at the top of a confirmation: a large title,
|
|
14
|
+
* then an optional subtitle and asset icon.
|
|
15
|
+
*
|
|
16
|
+
* @param props - The component props.
|
|
17
|
+
* @param props.title - The title.
|
|
18
|
+
* @param props.subtitle - The subtitle.
|
|
19
|
+
* @param props.iconUrl - The asset icon URL.
|
|
20
|
+
* @returns The header element.
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <ActionHeader title={translate('confirmation.signMessage.title')} />;
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare const ActionHeader: ({ title, subtitle, iconUrl, }: ActionHeaderProps) => ComponentOrElement;
|
|
27
|
+
//# sourceMappingURL=ActionHeader.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionHeader.d.mts","sourceRoot":"","sources":["../../../src/ui/ActionHeader/ActionHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,4BAA4B;AAK9D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,GAAI,+BAI1B,iBAAiB,KAAG,kBAgBtB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@metamask/snaps-sdk/jsx-runtime";
|
|
2
|
+
import { Box, Heading, Text as SnapText } from "@metamask/snaps-sdk/jsx";
|
|
3
|
+
import { AssetIcon } from "../Asset/Asset.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Renders the centered header at the top of a confirmation: a large title,
|
|
6
|
+
* then an optional subtitle and asset icon.
|
|
7
|
+
*
|
|
8
|
+
* @param props - The component props.
|
|
9
|
+
* @param props.title - The title.
|
|
10
|
+
* @param props.subtitle - The subtitle.
|
|
11
|
+
* @param props.iconUrl - The asset icon URL.
|
|
12
|
+
* @returns The header element.
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <ActionHeader title={translate('confirmation.signMessage.title')} />;
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export const ActionHeader = ({ title, subtitle, iconUrl, }) => (_jsxs(Box, { alignment: "center", center: true, children: [_jsx(Box, { children: null }), _jsx(Heading, { size: "lg", children: title }), subtitle ? (_jsx(SnapText, { color: "muted", alignment: "center", children: subtitle })) : null, iconUrl === undefined ? null : (_jsx(Box, { children: _jsx(AssetIcon, { iconUrl: iconUrl, size: "xl" }) })), _jsx(Box, { children: null })] }));
|
|
19
|
+
//# sourceMappingURL=ActionHeader.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionHeader.mjs","sourceRoot":"","sources":["../../../src/ui/ActionHeader/ActionHeader.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,gCAAgC;AAEzE,OAAO,EAAE,SAAS,EAAE,2BAAuB;AAa3C;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAC3B,KAAK,EACL,QAAQ,EACR,OAAO,GACW,EAAsB,EAAE,CAAC,CAC3C,MAAC,GAAG,IAAC,SAAS,EAAC,QAAQ,EAAC,MAAM,mBAC5B,KAAC,GAAG,cAAE,IAAI,GAAO,EACjB,KAAC,OAAO,IAAC,IAAI,EAAC,IAAI,YAAE,KAAK,GAAW,EACnC,QAAQ,CAAC,CAAC,CAAC,CACV,KAAC,QAAQ,IAAC,KAAK,EAAC,OAAO,EAAC,SAAS,EAAC,QAAQ,YACvC,QAAQ,GACA,CACZ,CAAC,CAAC,CAAC,IAAI,EACP,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC9B,KAAC,GAAG,cACF,KAAC,SAAS,IAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,IAAI,GAAG,GACrC,CACP,EACD,KAAC,GAAG,cAAE,IAAI,GAAO,IACb,CACP,CAAC","sourcesContent":["import type { ComponentOrElement } from '@metamask/snaps-sdk';\nimport { Box, Heading, Text as SnapText } from '@metamask/snaps-sdk/jsx';\n\nimport { AssetIcon } from '../Asset/Asset';\n\nexport type ActionHeaderProps = {\n title: string;\n /** Muted text shown below the title. */\n subtitle?: string;\n /**\n * Asset icon URL; when set, an extra-large asset icon is shown below the\n * title. A blank URL shows the question-mark icon.\n */\n iconUrl?: string;\n};\n\n/**\n * Renders the centered header at the top of a confirmation: a large title,\n * then an optional subtitle and asset icon.\n *\n * @param props - The component props.\n * @param props.title - The title.\n * @param props.subtitle - The subtitle.\n * @param props.iconUrl - The asset icon URL.\n * @returns The header element.\n * @example\n * ```tsx\n * <ActionHeader title={translate('confirmation.signMessage.title')} />;\n * ```\n */\nexport const ActionHeader = ({\n title,\n subtitle,\n iconUrl,\n}: ActionHeaderProps): ComponentOrElement => (\n <Box alignment=\"center\" center>\n <Box>{null}</Box>\n <Heading size=\"lg\">{title}</Heading>\n {subtitle ? (\n <SnapText color=\"muted\" alignment=\"center\">\n {subtitle}\n </SnapText>\n ) : null}\n {iconUrl === undefined ? null : (\n <Box>\n <AssetIcon iconUrl={iconUrl} size=\"xl\" />\n </Box>\n )}\n <Box>{null}</Box>\n </Box>\n);\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Asset = exports.AssetIcon = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("@metamask/snaps-sdk/jsx-runtime");
|
|
8
|
+
const jsx_1 = require("@metamask/snaps-sdk/jsx");
|
|
9
|
+
const question_mark_svg_1 = __importDefault(require("./question-mark.svg"));
|
|
10
|
+
const IconSize = {
|
|
11
|
+
sm: 16,
|
|
12
|
+
md: 24,
|
|
13
|
+
lg: 32,
|
|
14
|
+
xl: 48,
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Renders a round asset icon, falling back to a question mark.
|
|
18
|
+
*
|
|
19
|
+
* @param props - The component props.
|
|
20
|
+
* @param props.iconUrl - The icon URL.
|
|
21
|
+
* @param props.size - The icon size, `sm` (16px) by default.
|
|
22
|
+
* @returns The icon image.
|
|
23
|
+
*/
|
|
24
|
+
const AssetIcon = ({ iconUrl, size = 'sm', }) => ((0, jsx_runtime_1.jsx)(jsx_1.Image, { borderRadius: "full", src: iconUrl?.trim() ? iconUrl : question_mark_svg_1.default, height: IconSize[size], width: IconSize[size] }));
|
|
25
|
+
exports.AssetIcon = AssetIcon;
|
|
26
|
+
/**
|
|
27
|
+
* Renders an inline asset: optional fiat value (or a loading skeleton), the
|
|
28
|
+
* asset icon, then the amount and symbol, optionally as an explorer link.
|
|
29
|
+
*
|
|
30
|
+
* @param props - The component props.
|
|
31
|
+
* @param props.symbol - The asset symbol.
|
|
32
|
+
* @param props.amount - The display-ready amount.
|
|
33
|
+
* @param props.iconUrl - The icon URL.
|
|
34
|
+
* @param props.iconName - A Snaps icon shown instead of the image.
|
|
35
|
+
* @param props.hideIcon - Whether to render no icon.
|
|
36
|
+
* @param props.link - The explorer link.
|
|
37
|
+
* @param props.fiat - The display-ready fiat value.
|
|
38
|
+
* @param props.isFiatLoading - Whether the fiat value is loading.
|
|
39
|
+
* @returns The asset element.
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* const price = preferences.useExternalPricingData
|
|
43
|
+
* ? tokenPrices[assetId]
|
|
44
|
+
* : null;
|
|
45
|
+
*
|
|
46
|
+
* <Asset
|
|
47
|
+
* symbol="XLM"
|
|
48
|
+
* amount="1.5"
|
|
49
|
+
* iconUrl={iconUrl}
|
|
50
|
+
* fiat={
|
|
51
|
+
* price
|
|
52
|
+
* ? formatFiat(
|
|
53
|
+
* tokenToFiat('1.5', price),
|
|
54
|
+
* preferences.currency,
|
|
55
|
+
* preferences.locale,
|
|
56
|
+
* )
|
|
57
|
+
* : null
|
|
58
|
+
* }
|
|
59
|
+
* isFiatLoading={tokenPricesFetchStatus === 'fetching'}
|
|
60
|
+
* />;
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
const Asset = ({ symbol, amount, iconUrl, iconName, hideIcon = false, link, fiat, isFiatLoading = false, }) => {
|
|
64
|
+
const text = amount === undefined ? symbol : `${amount} ${symbol}`;
|
|
65
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_1.Box, { direction: "horizontal", alignment: "end", children: [isFiatLoading ? (0, jsx_runtime_1.jsx)(jsx_1.Skeleton, { width: 80 }) : null, !isFiatLoading && fiat ? ((0, jsx_runtime_1.jsx)(jsx_1.Text, { color: "muted", children: fiat })) : null, hideIcon ? null : ((0, jsx_runtime_1.jsx)(jsx_1.Box, { alignment: "center", center: true, children: iconName ? ((0, jsx_runtime_1.jsx)(jsx_1.Icon, { name: iconName, size: "md" })) : ((0, jsx_runtime_1.jsx)(exports.AssetIcon, { iconUrl: iconUrl })) })), link ? (0, jsx_runtime_1.jsx)(jsx_1.Link, { href: link, children: text }) : (0, jsx_runtime_1.jsx)(jsx_1.Text, { children: text })] }));
|
|
66
|
+
};
|
|
67
|
+
exports.Asset = Asset;
|
|
68
|
+
//# sourceMappingURL=Asset.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Asset.cjs","sourceRoot":"","sources":["../../../src/ui/Asset/Asset.tsx"],"names":[],"mappings":";;;;;;;AACA,iDAOiC;AAGjC,4EAAmD;AAEnD,MAAM,QAAQ,GAAG;IACf,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;CACE,CAAC;AA8BX;;;;;;;GAOG;AACI,MAAM,SAAS,GAAG,CAAC,EACxB,OAAO,EACP,IAAI,GAAG,IAAI,GACI,EAAsB,EAAE,CAAC,CACxC,uBAAC,WAAK,IACJ,YAAY,EAAC,MAAM,EACnB,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,2BAAgB,EACjD,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,EACtB,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,GACrB,CACH,CAAC;AAVW,QAAA,SAAS,aAUpB;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACI,MAAM,KAAK,GAAG,CAAC,EACpB,MAAM,EACN,MAAM,EACN,OAAO,EACP,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,IAAI,EACJ,IAAI,EACJ,aAAa,GAAG,KAAK,GACV,EAAsB,EAAE;IACnC,MAAM,IAAI,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;IAEnE,OAAO,CACL,wBAAC,SAAG,IAAC,SAAS,EAAC,YAAY,EAAC,SAAS,EAAC,KAAK,aACxC,aAAa,CAAC,CAAC,CAAC,uBAAC,cAAQ,IAAC,KAAK,EAAE,EAAE,GAAI,CAAC,CAAC,CAAC,IAAI,EAC9C,CAAC,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,CACxB,uBAAC,UAAQ,IAAC,KAAK,EAAC,OAAO,YAAE,IAAI,GAAY,CAC1C,CAAC,CAAC,CAAC,IAAI,EACP,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACjB,uBAAC,SAAG,IAAC,SAAS,EAAC,QAAQ,EAAC,MAAM,kBAC3B,QAAQ,CAAC,CAAC,CAAC,CACV,uBAAC,UAAI,IAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,IAAI,GAAG,CACnC,CAAC,CAAC,CAAC,CACF,uBAAC,iBAAS,IAAC,OAAO,EAAE,OAAO,GAAI,CAChC,GACG,CACP,EACA,IAAI,CAAC,CAAC,CAAC,uBAAC,UAAI,IAAC,IAAI,EAAE,IAAI,YAAG,IAAI,GAAQ,CAAC,CAAC,CAAC,uBAAC,UAAQ,cAAE,IAAI,GAAY,IACjE,CACP,CAAC;AACJ,CAAC,CAAC;AA9BW,QAAA,KAAK,SA8BhB","sourcesContent":["import type { ComponentOrElement } from '@metamask/snaps-sdk';\nimport {\n Box,\n Icon,\n Image,\n Link,\n Skeleton,\n Text as SnapText,\n} from '@metamask/snaps-sdk/jsx';\nimport type { IconProps } from '@metamask/snaps-sdk/jsx';\n\nimport questionMarkIcon from './question-mark.svg';\n\nconst IconSize = {\n sm: 16,\n md: 24,\n lg: 32,\n xl: 48,\n} as const;\n\nexport type AssetIconProps = {\n /** Icon URL; a question-mark icon is shown when missing or blank. */\n iconUrl?: string | null;\n size?: keyof typeof IconSize;\n};\n\nexport type AssetProps = {\n symbol: string;\n /** Display-ready amount shown before the symbol; omit to show the symbol only. */\n amount?: string;\n /** Icon URL; a question-mark icon is shown when missing or blank. */\n iconUrl?: string | null;\n /** Snaps icon shown instead of the image, e.g. for network resources. */\n iconName?: IconProps['name'];\n /** Whether to render the asset without any icon. */\n hideIcon?: boolean;\n /** Explorer link; when set, the asset text is rendered as a link. */\n link?: string;\n /**\n * Display-ready fiat value shown before the asset. The caller decides whether\n * fiat applies (e.g. `useExternalPricingData`) and formats it with the user's\n * currency and locale; pass `null` to show no fiat.\n */\n fiat?: string | null;\n /** Whether the fiat value is loading; shows a skeleton in its place. */\n isFiatLoading?: boolean;\n};\n\n/**\n * Renders a round asset icon, falling back to a question mark.\n *\n * @param props - The component props.\n * @param props.iconUrl - The icon URL.\n * @param props.size - The icon size, `sm` (16px) by default.\n * @returns The icon image.\n */\nexport const AssetIcon = ({\n iconUrl,\n size = 'sm',\n}: AssetIconProps): ComponentOrElement => (\n <Image\n borderRadius=\"full\"\n src={iconUrl?.trim() ? iconUrl : questionMarkIcon}\n height={IconSize[size]}\n width={IconSize[size]}\n />\n);\n\n/**\n * Renders an inline asset: optional fiat value (or a loading skeleton), the\n * asset icon, then the amount and symbol, optionally as an explorer link.\n *\n * @param props - The component props.\n * @param props.symbol - The asset symbol.\n * @param props.amount - The display-ready amount.\n * @param props.iconUrl - The icon URL.\n * @param props.iconName - A Snaps icon shown instead of the image.\n * @param props.hideIcon - Whether to render no icon.\n * @param props.link - The explorer link.\n * @param props.fiat - The display-ready fiat value.\n * @param props.isFiatLoading - Whether the fiat value is loading.\n * @returns The asset element.\n * @example\n * ```tsx\n * const price = preferences.useExternalPricingData\n * ? tokenPrices[assetId]\n * : null;\n *\n * <Asset\n * symbol=\"XLM\"\n * amount=\"1.5\"\n * iconUrl={iconUrl}\n * fiat={\n * price\n * ? formatFiat(\n * tokenToFiat('1.5', price),\n * preferences.currency,\n * preferences.locale,\n * )\n * : null\n * }\n * isFiatLoading={tokenPricesFetchStatus === 'fetching'}\n * />;\n * ```\n */\nexport const Asset = ({\n symbol,\n amount,\n iconUrl,\n iconName,\n hideIcon = false,\n link,\n fiat,\n isFiatLoading = false,\n}: AssetProps): ComponentOrElement => {\n const text = amount === undefined ? symbol : `${amount} ${symbol}`;\n\n return (\n <Box direction=\"horizontal\" alignment=\"end\">\n {isFiatLoading ? <Skeleton width={80} /> : null}\n {!isFiatLoading && fiat ? (\n <SnapText color=\"muted\">{fiat}</SnapText>\n ) : null}\n {hideIcon ? null : (\n <Box alignment=\"center\" center>\n {iconName ? (\n <Icon name={iconName} size=\"md\" />\n ) : (\n <AssetIcon iconUrl={iconUrl} />\n )}\n </Box>\n )}\n {link ? <Link href={link}>{text}</Link> : <SnapText>{text}</SnapText>}\n </Box>\n );\n};\n"]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { ComponentOrElement } from "@metamask/snaps-sdk";
|
|
2
|
+
import type { IconProps } from "@metamask/snaps-sdk/jsx";
|
|
3
|
+
declare const IconSize: {
|
|
4
|
+
readonly sm: 16;
|
|
5
|
+
readonly md: 24;
|
|
6
|
+
readonly lg: 32;
|
|
7
|
+
readonly xl: 48;
|
|
8
|
+
};
|
|
9
|
+
export type AssetIconProps = {
|
|
10
|
+
/** Icon URL; a question-mark icon is shown when missing or blank. */
|
|
11
|
+
iconUrl?: string | null;
|
|
12
|
+
size?: keyof typeof IconSize;
|
|
13
|
+
};
|
|
14
|
+
export type AssetProps = {
|
|
15
|
+
symbol: string;
|
|
16
|
+
/** Display-ready amount shown before the symbol; omit to show the symbol only. */
|
|
17
|
+
amount?: string;
|
|
18
|
+
/** Icon URL; a question-mark icon is shown when missing or blank. */
|
|
19
|
+
iconUrl?: string | null;
|
|
20
|
+
/** Snaps icon shown instead of the image, e.g. for network resources. */
|
|
21
|
+
iconName?: IconProps['name'];
|
|
22
|
+
/** Whether to render the asset without any icon. */
|
|
23
|
+
hideIcon?: boolean;
|
|
24
|
+
/** Explorer link; when set, the asset text is rendered as a link. */
|
|
25
|
+
link?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Display-ready fiat value shown before the asset. The caller decides whether
|
|
28
|
+
* fiat applies (e.g. `useExternalPricingData`) and formats it with the user's
|
|
29
|
+
* currency and locale; pass `null` to show no fiat.
|
|
30
|
+
*/
|
|
31
|
+
fiat?: string | null;
|
|
32
|
+
/** Whether the fiat value is loading; shows a skeleton in its place. */
|
|
33
|
+
isFiatLoading?: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Renders a round asset icon, falling back to a question mark.
|
|
37
|
+
*
|
|
38
|
+
* @param props - The component props.
|
|
39
|
+
* @param props.iconUrl - The icon URL.
|
|
40
|
+
* @param props.size - The icon size, `sm` (16px) by default.
|
|
41
|
+
* @returns The icon image.
|
|
42
|
+
*/
|
|
43
|
+
export declare const AssetIcon: ({ iconUrl, size, }: AssetIconProps) => ComponentOrElement;
|
|
44
|
+
/**
|
|
45
|
+
* Renders an inline asset: optional fiat value (or a loading skeleton), the
|
|
46
|
+
* asset icon, then the amount and symbol, optionally as an explorer link.
|
|
47
|
+
*
|
|
48
|
+
* @param props - The component props.
|
|
49
|
+
* @param props.symbol - The asset symbol.
|
|
50
|
+
* @param props.amount - The display-ready amount.
|
|
51
|
+
* @param props.iconUrl - The icon URL.
|
|
52
|
+
* @param props.iconName - A Snaps icon shown instead of the image.
|
|
53
|
+
* @param props.hideIcon - Whether to render no icon.
|
|
54
|
+
* @param props.link - The explorer link.
|
|
55
|
+
* @param props.fiat - The display-ready fiat value.
|
|
56
|
+
* @param props.isFiatLoading - Whether the fiat value is loading.
|
|
57
|
+
* @returns The asset element.
|
|
58
|
+
* @example
|
|
59
|
+
* ```tsx
|
|
60
|
+
* const price = preferences.useExternalPricingData
|
|
61
|
+
* ? tokenPrices[assetId]
|
|
62
|
+
* : null;
|
|
63
|
+
*
|
|
64
|
+
* <Asset
|
|
65
|
+
* symbol="XLM"
|
|
66
|
+
* amount="1.5"
|
|
67
|
+
* iconUrl={iconUrl}
|
|
68
|
+
* fiat={
|
|
69
|
+
* price
|
|
70
|
+
* ? formatFiat(
|
|
71
|
+
* tokenToFiat('1.5', price),
|
|
72
|
+
* preferences.currency,
|
|
73
|
+
* preferences.locale,
|
|
74
|
+
* )
|
|
75
|
+
* : null
|
|
76
|
+
* }
|
|
77
|
+
* isFiatLoading={tokenPricesFetchStatus === 'fetching'}
|
|
78
|
+
* />;
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare const Asset: ({ symbol, amount, iconUrl, iconName, hideIcon, link, fiat, isFiatLoading, }: AssetProps) => ComponentOrElement;
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=Asset.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Asset.d.cts","sourceRoot":"","sources":["../../../src/ui/Asset/Asset.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,4BAA4B;AAS9D,OAAO,KAAK,EAAE,SAAS,EAAE,gCAAgC;AAIzD,QAAA,MAAM,QAAQ;;;;;CAKJ,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG;IAC3B,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,OAAO,QAAQ,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qEAAqE;IACrE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,wEAAwE;IACxE,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,oBAGvB,cAAc,KAAG,kBAOnB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,KAAK,GAAI,6EASnB,UAAU,KAAG,kBAqBf,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { ComponentOrElement } from "@metamask/snaps-sdk";
|
|
2
|
+
import type { IconProps } from "@metamask/snaps-sdk/jsx";
|
|
3
|
+
declare const IconSize: {
|
|
4
|
+
readonly sm: 16;
|
|
5
|
+
readonly md: 24;
|
|
6
|
+
readonly lg: 32;
|
|
7
|
+
readonly xl: 48;
|
|
8
|
+
};
|
|
9
|
+
export type AssetIconProps = {
|
|
10
|
+
/** Icon URL; a question-mark icon is shown when missing or blank. */
|
|
11
|
+
iconUrl?: string | null;
|
|
12
|
+
size?: keyof typeof IconSize;
|
|
13
|
+
};
|
|
14
|
+
export type AssetProps = {
|
|
15
|
+
symbol: string;
|
|
16
|
+
/** Display-ready amount shown before the symbol; omit to show the symbol only. */
|
|
17
|
+
amount?: string;
|
|
18
|
+
/** Icon URL; a question-mark icon is shown when missing or blank. */
|
|
19
|
+
iconUrl?: string | null;
|
|
20
|
+
/** Snaps icon shown instead of the image, e.g. for network resources. */
|
|
21
|
+
iconName?: IconProps['name'];
|
|
22
|
+
/** Whether to render the asset without any icon. */
|
|
23
|
+
hideIcon?: boolean;
|
|
24
|
+
/** Explorer link; when set, the asset text is rendered as a link. */
|
|
25
|
+
link?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Display-ready fiat value shown before the asset. The caller decides whether
|
|
28
|
+
* fiat applies (e.g. `useExternalPricingData`) and formats it with the user's
|
|
29
|
+
* currency and locale; pass `null` to show no fiat.
|
|
30
|
+
*/
|
|
31
|
+
fiat?: string | null;
|
|
32
|
+
/** Whether the fiat value is loading; shows a skeleton in its place. */
|
|
33
|
+
isFiatLoading?: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Renders a round asset icon, falling back to a question mark.
|
|
37
|
+
*
|
|
38
|
+
* @param props - The component props.
|
|
39
|
+
* @param props.iconUrl - The icon URL.
|
|
40
|
+
* @param props.size - The icon size, `sm` (16px) by default.
|
|
41
|
+
* @returns The icon image.
|
|
42
|
+
*/
|
|
43
|
+
export declare const AssetIcon: ({ iconUrl, size, }: AssetIconProps) => ComponentOrElement;
|
|
44
|
+
/**
|
|
45
|
+
* Renders an inline asset: optional fiat value (or a loading skeleton), the
|
|
46
|
+
* asset icon, then the amount and symbol, optionally as an explorer link.
|
|
47
|
+
*
|
|
48
|
+
* @param props - The component props.
|
|
49
|
+
* @param props.symbol - The asset symbol.
|
|
50
|
+
* @param props.amount - The display-ready amount.
|
|
51
|
+
* @param props.iconUrl - The icon URL.
|
|
52
|
+
* @param props.iconName - A Snaps icon shown instead of the image.
|
|
53
|
+
* @param props.hideIcon - Whether to render no icon.
|
|
54
|
+
* @param props.link - The explorer link.
|
|
55
|
+
* @param props.fiat - The display-ready fiat value.
|
|
56
|
+
* @param props.isFiatLoading - Whether the fiat value is loading.
|
|
57
|
+
* @returns The asset element.
|
|
58
|
+
* @example
|
|
59
|
+
* ```tsx
|
|
60
|
+
* const price = preferences.useExternalPricingData
|
|
61
|
+
* ? tokenPrices[assetId]
|
|
62
|
+
* : null;
|
|
63
|
+
*
|
|
64
|
+
* <Asset
|
|
65
|
+
* symbol="XLM"
|
|
66
|
+
* amount="1.5"
|
|
67
|
+
* iconUrl={iconUrl}
|
|
68
|
+
* fiat={
|
|
69
|
+
* price
|
|
70
|
+
* ? formatFiat(
|
|
71
|
+
* tokenToFiat('1.5', price),
|
|
72
|
+
* preferences.currency,
|
|
73
|
+
* preferences.locale,
|
|
74
|
+
* )
|
|
75
|
+
* : null
|
|
76
|
+
* }
|
|
77
|
+
* isFiatLoading={tokenPricesFetchStatus === 'fetching'}
|
|
78
|
+
* />;
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare const Asset: ({ symbol, amount, iconUrl, iconName, hideIcon, link, fiat, isFiatLoading, }: AssetProps) => ComponentOrElement;
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=Asset.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Asset.d.mts","sourceRoot":"","sources":["../../../src/ui/Asset/Asset.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,4BAA4B;AAS9D,OAAO,KAAK,EAAE,SAAS,EAAE,gCAAgC;AAIzD,QAAA,MAAM,QAAQ;;;;;CAKJ,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG;IAC3B,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,OAAO,QAAQ,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qEAAqE;IACrE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,wEAAwE;IACxE,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,oBAGvB,cAAc,KAAG,kBAOnB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,KAAK,GAAI,6EASnB,UAAU,KAAG,kBAqBf,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@metamask/snaps-sdk/jsx-runtime";
|
|
2
|
+
import { Box, Icon, Image, Link, Skeleton, Text as SnapText } from "@metamask/snaps-sdk/jsx";
|
|
3
|
+
import questionMarkIcon from "./question-mark.svg";
|
|
4
|
+
const IconSize = {
|
|
5
|
+
sm: 16,
|
|
6
|
+
md: 24,
|
|
7
|
+
lg: 32,
|
|
8
|
+
xl: 48,
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Renders a round asset icon, falling back to a question mark.
|
|
12
|
+
*
|
|
13
|
+
* @param props - The component props.
|
|
14
|
+
* @param props.iconUrl - The icon URL.
|
|
15
|
+
* @param props.size - The icon size, `sm` (16px) by default.
|
|
16
|
+
* @returns The icon image.
|
|
17
|
+
*/
|
|
18
|
+
export const AssetIcon = ({ iconUrl, size = 'sm', }) => (_jsx(Image, { borderRadius: "full", src: iconUrl?.trim() ? iconUrl : questionMarkIcon, height: IconSize[size], width: IconSize[size] }));
|
|
19
|
+
/**
|
|
20
|
+
* Renders an inline asset: optional fiat value (or a loading skeleton), the
|
|
21
|
+
* asset icon, then the amount and symbol, optionally as an explorer link.
|
|
22
|
+
*
|
|
23
|
+
* @param props - The component props.
|
|
24
|
+
* @param props.symbol - The asset symbol.
|
|
25
|
+
* @param props.amount - The display-ready amount.
|
|
26
|
+
* @param props.iconUrl - The icon URL.
|
|
27
|
+
* @param props.iconName - A Snaps icon shown instead of the image.
|
|
28
|
+
* @param props.hideIcon - Whether to render no icon.
|
|
29
|
+
* @param props.link - The explorer link.
|
|
30
|
+
* @param props.fiat - The display-ready fiat value.
|
|
31
|
+
* @param props.isFiatLoading - Whether the fiat value is loading.
|
|
32
|
+
* @returns The asset element.
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* const price = preferences.useExternalPricingData
|
|
36
|
+
* ? tokenPrices[assetId]
|
|
37
|
+
* : null;
|
|
38
|
+
*
|
|
39
|
+
* <Asset
|
|
40
|
+
* symbol="XLM"
|
|
41
|
+
* amount="1.5"
|
|
42
|
+
* iconUrl={iconUrl}
|
|
43
|
+
* fiat={
|
|
44
|
+
* price
|
|
45
|
+
* ? formatFiat(
|
|
46
|
+
* tokenToFiat('1.5', price),
|
|
47
|
+
* preferences.currency,
|
|
48
|
+
* preferences.locale,
|
|
49
|
+
* )
|
|
50
|
+
* : null
|
|
51
|
+
* }
|
|
52
|
+
* isFiatLoading={tokenPricesFetchStatus === 'fetching'}
|
|
53
|
+
* />;
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export const Asset = ({ symbol, amount, iconUrl, iconName, hideIcon = false, link, fiat, isFiatLoading = false, }) => {
|
|
57
|
+
const text = amount === undefined ? symbol : `${amount} ${symbol}`;
|
|
58
|
+
return (_jsxs(Box, { direction: "horizontal", alignment: "end", children: [isFiatLoading ? _jsx(Skeleton, { width: 80 }) : null, !isFiatLoading && fiat ? (_jsx(SnapText, { color: "muted", children: fiat })) : null, hideIcon ? null : (_jsx(Box, { alignment: "center", center: true, children: iconName ? (_jsx(Icon, { name: iconName, size: "md" })) : (_jsx(AssetIcon, { iconUrl: iconUrl })) })), link ? _jsx(Link, { href: link, children: text }) : _jsx(SnapText, { children: text })] }));
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=Asset.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Asset.mjs","sourceRoot":"","sources":["../../../src/ui/Asset/Asset.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,IAAI,IAAI,QAAQ,EACjB,gCAAgC;AAGjC,OAAO,gBAAgB,4BAA4B;AAEnD,MAAM,QAAQ,GAAG;IACf,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;CACE,CAAC;AA8BX;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EACxB,OAAO,EACP,IAAI,GAAG,IAAI,GACI,EAAsB,EAAE,CAAC,CACxC,KAAC,KAAK,IACJ,YAAY,EAAC,MAAM,EACnB,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,EACjD,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,EACtB,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,GACrB,CACH,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EACpB,MAAM,EACN,MAAM,EACN,OAAO,EACP,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,IAAI,EACJ,IAAI,EACJ,aAAa,GAAG,KAAK,GACV,EAAsB,EAAE;IACnC,MAAM,IAAI,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;IAEnE,OAAO,CACL,MAAC,GAAG,IAAC,SAAS,EAAC,YAAY,EAAC,SAAS,EAAC,KAAK,aACxC,aAAa,CAAC,CAAC,CAAC,KAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,GAAI,CAAC,CAAC,CAAC,IAAI,EAC9C,CAAC,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,CACxB,KAAC,QAAQ,IAAC,KAAK,EAAC,OAAO,YAAE,IAAI,GAAY,CAC1C,CAAC,CAAC,CAAC,IAAI,EACP,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACjB,KAAC,GAAG,IAAC,SAAS,EAAC,QAAQ,EAAC,MAAM,kBAC3B,QAAQ,CAAC,CAAC,CAAC,CACV,KAAC,IAAI,IAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,IAAI,GAAG,CACnC,CAAC,CAAC,CAAC,CACF,KAAC,SAAS,IAAC,OAAO,EAAE,OAAO,GAAI,CAChC,GACG,CACP,EACA,IAAI,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,YAAG,IAAI,GAAQ,CAAC,CAAC,CAAC,KAAC,QAAQ,cAAE,IAAI,GAAY,IACjE,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { ComponentOrElement } from '@metamask/snaps-sdk';\nimport {\n Box,\n Icon,\n Image,\n Link,\n Skeleton,\n Text as SnapText,\n} from '@metamask/snaps-sdk/jsx';\nimport type { IconProps } from '@metamask/snaps-sdk/jsx';\n\nimport questionMarkIcon from './question-mark.svg';\n\nconst IconSize = {\n sm: 16,\n md: 24,\n lg: 32,\n xl: 48,\n} as const;\n\nexport type AssetIconProps = {\n /** Icon URL; a question-mark icon is shown when missing or blank. */\n iconUrl?: string | null;\n size?: keyof typeof IconSize;\n};\n\nexport type AssetProps = {\n symbol: string;\n /** Display-ready amount shown before the symbol; omit to show the symbol only. */\n amount?: string;\n /** Icon URL; a question-mark icon is shown when missing or blank. */\n iconUrl?: string | null;\n /** Snaps icon shown instead of the image, e.g. for network resources. */\n iconName?: IconProps['name'];\n /** Whether to render the asset without any icon. */\n hideIcon?: boolean;\n /** Explorer link; when set, the asset text is rendered as a link. */\n link?: string;\n /**\n * Display-ready fiat value shown before the asset. The caller decides whether\n * fiat applies (e.g. `useExternalPricingData`) and formats it with the user's\n * currency and locale; pass `null` to show no fiat.\n */\n fiat?: string | null;\n /** Whether the fiat value is loading; shows a skeleton in its place. */\n isFiatLoading?: boolean;\n};\n\n/**\n * Renders a round asset icon, falling back to a question mark.\n *\n * @param props - The component props.\n * @param props.iconUrl - The icon URL.\n * @param props.size - The icon size, `sm` (16px) by default.\n * @returns The icon image.\n */\nexport const AssetIcon = ({\n iconUrl,\n size = 'sm',\n}: AssetIconProps): ComponentOrElement => (\n <Image\n borderRadius=\"full\"\n src={iconUrl?.trim() ? iconUrl : questionMarkIcon}\n height={IconSize[size]}\n width={IconSize[size]}\n />\n);\n\n/**\n * Renders an inline asset: optional fiat value (or a loading skeleton), the\n * asset icon, then the amount and symbol, optionally as an explorer link.\n *\n * @param props - The component props.\n * @param props.symbol - The asset symbol.\n * @param props.amount - The display-ready amount.\n * @param props.iconUrl - The icon URL.\n * @param props.iconName - A Snaps icon shown instead of the image.\n * @param props.hideIcon - Whether to render no icon.\n * @param props.link - The explorer link.\n * @param props.fiat - The display-ready fiat value.\n * @param props.isFiatLoading - Whether the fiat value is loading.\n * @returns The asset element.\n * @example\n * ```tsx\n * const price = preferences.useExternalPricingData\n * ? tokenPrices[assetId]\n * : null;\n *\n * <Asset\n * symbol=\"XLM\"\n * amount=\"1.5\"\n * iconUrl={iconUrl}\n * fiat={\n * price\n * ? formatFiat(\n * tokenToFiat('1.5', price),\n * preferences.currency,\n * preferences.locale,\n * )\n * : null\n * }\n * isFiatLoading={tokenPricesFetchStatus === 'fetching'}\n * />;\n * ```\n */\nexport const Asset = ({\n symbol,\n amount,\n iconUrl,\n iconName,\n hideIcon = false,\n link,\n fiat,\n isFiatLoading = false,\n}: AssetProps): ComponentOrElement => {\n const text = amount === undefined ? symbol : `${amount} ${symbol}`;\n\n return (\n <Box direction=\"horizontal\" alignment=\"end\">\n {isFiatLoading ? <Skeleton width={80} /> : null}\n {!isFiatLoading && fiat ? (\n <SnapText color=\"muted\">{fiat}</SnapText>\n ) : null}\n {hideIcon ? null : (\n <Box alignment=\"center\" center>\n {iconName ? (\n <Icon name={iconName} size=\"md\" />\n ) : (\n <AssetIcon iconUrl={iconUrl} />\n )}\n </Box>\n )}\n {link ? <Link href={link}>{text}</Link> : <SnapText>{text}</SnapText>}\n </Box>\n );\n};\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="16" height="16">
|
|
2
|
+
<path fill="#999999" d="M42.75 24c0 10.59375-8.53125 19.21875-19.125 19.21875-10.6875 0-19.21875-8.625-19.21875-19.21875 0-10.59375 8.53125-19.21875 19.21875-19.21875 10.59375 0 19.125 8.625 19.125 19.21875zM23.625 14.0625c-3.09375 0-5.90625 2.25-5.90625 5.4375 0 0.84375 0.75 1.59375 1.59375 1.59375 0.84375 0 1.59375-0.75 1.59375-1.59375 0-1.125 1.03125-2.25 2.71875-2.25 1.59375 0 2.625 1.125 2.625 2.25 0 0.5625-0.375 1.03125-1.3125 1.59375l0 0c-1.125 0.75-3 1.96875-3 4.5l0 0.46875c0 0.84375 0.75 1.59375 1.6875 1.59375 0.84375 0 1.59375-0.75 1.59375-1.59375l0-0.46875c0-0.65625 0.28125-1.125 1.40625-1.78125 1.03125-0.65625 2.8125-1.875 2.8125-4.3125 0-3.1875-2.8125-5.4375-5.8125-5.4375zM23.53125 31.875c-0.84375 0-1.59375 0.65625-1.59375 1.59375 0 0.84375 0.75 1.59375 1.59375 1.59375l0.09375 0c0.84375 0 1.59375-0.75 1.59375-1.59375 0-0.9375-0.75-1.59375-1.59375-1.59375z"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EstimatedChanges = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("@metamask/snaps-sdk/jsx-runtime");
|
|
5
|
+
const jsx_1 = require("@metamask/snaps-sdk/jsx");
|
|
6
|
+
const Header = ({ labels, }) => ((0, jsx_runtime_1.jsxs)(jsx_1.Box, { direction: "horizontal", alignment: "start", children: [(0, jsx_runtime_1.jsx)(jsx_1.Text, { fontWeight: "medium", children: labels.title }), (0, jsx_runtime_1.jsx)(jsx_1.Tooltip, { content: labels.tooltip, children: (0, jsx_runtime_1.jsx)(jsx_1.Icon, { name: "info" }) })] }));
|
|
7
|
+
const MessageSection = ({ labels, message, }) => ((0, jsx_runtime_1.jsxs)(jsx_1.Section, { direction: "vertical", children: [(0, jsx_runtime_1.jsx)(Header, { labels: labels }), (0, jsx_runtime_1.jsx)(jsx_1.Text, { color: "alternative", children: message })] }));
|
|
8
|
+
const AssetRow = ({ asset, }) => {
|
|
9
|
+
const isOut = asset.type === 'out';
|
|
10
|
+
const isUnknownValue = asset.value === null;
|
|
11
|
+
let label;
|
|
12
|
+
if (isUnknownValue) {
|
|
13
|
+
label = `– ${asset.symbol}`;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const sign = isOut ? '-' : '+';
|
|
17
|
+
label = `${sign}${asset.value} ${asset.symbol}`;
|
|
18
|
+
}
|
|
19
|
+
const successOrError = isOut ? 'error' : 'success';
|
|
20
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_1.Box, { direction: "vertical", crossAlignment: "end", children: [(0, jsx_runtime_1.jsxs)(jsx_1.Box, { direction: "horizontal", alignment: "end", center: true, children: [asset.logo ? ((0, jsx_runtime_1.jsx)(jsx_1.Image, { src: asset.logo, borderRadius: "full", height: 16, width: 16 })) : null, (0, jsx_runtime_1.jsx)(jsx_1.Text, { color: isUnknownValue ? 'alternative' : successOrError, children: label })] }), asset.fiat ? (0, jsx_runtime_1.jsx)(jsx_1.Text, { color: "muted", children: asset.fiat }) : null] }));
|
|
21
|
+
};
|
|
22
|
+
const AssetGroup = ({ title, assets, }) => assets.length > 0 ? ((0, jsx_runtime_1.jsxs)(jsx_1.Box, { alignment: "space-between", direction: "horizontal", children: [(0, jsx_runtime_1.jsx)(jsx_1.Text, { fontWeight: "medium", color: "alternative", children: title }), (0, jsx_runtime_1.jsx)(jsx_1.Box, { direction: "vertical", alignment: "end", children: assets.map((asset, index) => ((0, jsx_runtime_1.jsx)(jsx_1.Box, { children: (0, jsx_runtime_1.jsx)(AssetRow, { asset: asset }) }, `${asset.type}-${asset.symbol}-${index}`))) })] })) : null;
|
|
23
|
+
/**
|
|
24
|
+
* Renders the estimated balance changes of a transaction, grouped into
|
|
25
|
+
* "send" and "receive" rows, with loading, error and empty states.
|
|
26
|
+
*
|
|
27
|
+
* The header is always rendered. The body depends on the props:
|
|
28
|
+
*
|
|
29
|
+
* 1. No assets and `isFetching` → loading skeleton (takes precedence over
|
|
30
|
+
* `isUnavailable`).
|
|
31
|
+
* 2. No assets and `isUnavailable` → "not available" message.
|
|
32
|
+
* 3. No assets otherwise → "no changes" message (an empty result means the
|
|
33
|
+
* transaction does not change any balance).
|
|
34
|
+
* 4. Assets present → "send" and/or "receive" groups; a group with no assets
|
|
35
|
+
* is omitted. `isFetching` and `isUnavailable` are ignored in this case, as
|
|
36
|
+
* rows seeded locally by the caller are final.
|
|
37
|
+
*
|
|
38
|
+
* @param props - The component props.
|
|
39
|
+
* @param props.assets - The display-ready asset changes.
|
|
40
|
+
* @param props.labels - The translated labels.
|
|
41
|
+
* @param props.isFetching - Whether the estimate is still being fetched.
|
|
42
|
+
* @param props.isUnavailable - Whether the estimate could not be produced.
|
|
43
|
+
* @returns The estimated changes section.
|
|
44
|
+
*/
|
|
45
|
+
const EstimatedChanges = ({ assets, labels, isFetching, isUnavailable, }) => {
|
|
46
|
+
// Rows seeded locally by the caller are final, so they are never replaced by
|
|
47
|
+
// the loading/unavailable states.
|
|
48
|
+
if (assets.length === 0) {
|
|
49
|
+
if (isFetching) {
|
|
50
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_1.Section, { direction: "vertical", children: [(0, jsx_runtime_1.jsx)(Header, { labels: labels }), (0, jsx_runtime_1.jsxs)(jsx_1.Box, { alignment: "space-between", direction: "horizontal", children: [(0, jsx_runtime_1.jsx)(jsx_1.Skeleton, { width: 60 }), (0, jsx_runtime_1.jsx)(jsx_1.Skeleton, { width: 100 })] })] }));
|
|
51
|
+
}
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)(MessageSection, { labels: labels, message: isUnavailable ? labels.notAvailable : labels.noChanges }));
|
|
53
|
+
}
|
|
54
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_1.Section, { children: [(0, jsx_runtime_1.jsx)(Header, { labels: labels }), (0, jsx_runtime_1.jsx)(AssetGroup, { title: labels.send, assets: assets.filter((asset) => asset.type === 'out') }), (0, jsx_runtime_1.jsx)(AssetGroup, { title: labels.receive, assets: assets.filter((asset) => asset.type === 'in') })] }));
|
|
55
|
+
};
|
|
56
|
+
exports.EstimatedChanges = EstimatedChanges;
|
|
57
|
+
//# sourceMappingURL=EstimatedChanges.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EstimatedChanges.cjs","sourceRoot":"","sources":["../../../src/ui/EstimatedChanges/EstimatedChanges.tsx"],"names":[],"mappings":"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","sourcesContent":["import type { ComponentOrElement } from '@metamask/snaps-sdk';\nimport {\n Box,\n Icon,\n Image,\n Section,\n Skeleton,\n Text as SnapText,\n Tooltip,\n} from '@metamask/snaps-sdk/jsx';\n\nexport type EstimatedChangesAsset = {\n type: 'in' | 'out';\n /** Display-ready amount, or `null` when the amount is unknown. */\n value: string | null;\n symbol: string;\n logo: string | null;\n /** Display-ready fiat value shown under the amount. */\n fiat?: string | null;\n};\n\nexport type EstimatedChangesLabels = {\n title: string;\n tooltip: string;\n send: string;\n receive: string;\n notAvailable: string;\n noChanges: string;\n};\n\nexport type EstimatedChangesProps = {\n assets: EstimatedChangesAsset[];\n labels: EstimatedChangesLabels;\n /** Whether the estimate is still being fetched. */\n isFetching: boolean;\n /** Whether the estimate could not be produced (e.g. fetch or simulation failure). */\n isUnavailable: boolean;\n};\n\nconst Header = ({\n labels,\n}: {\n labels: EstimatedChangesLabels;\n}): ComponentOrElement => (\n <Box direction=\"horizontal\" alignment=\"start\">\n <SnapText fontWeight=\"medium\">{labels.title}</SnapText>\n <Tooltip content={labels.tooltip}>\n <Icon name=\"info\" />\n </Tooltip>\n </Box>\n);\n\nconst MessageSection = ({\n labels,\n message,\n}: {\n labels: EstimatedChangesLabels;\n message: string;\n}): ComponentOrElement => (\n <Section direction=\"vertical\">\n <Header labels={labels} />\n <SnapText color=\"alternative\">{message}</SnapText>\n </Section>\n);\n\nconst AssetRow = ({\n asset,\n}: {\n asset: EstimatedChangesAsset;\n}): ComponentOrElement => {\n const isOut = asset.type === 'out';\n const isUnknownValue = asset.value === null;\n let label: string;\n if (isUnknownValue) {\n label = `– ${asset.symbol}`;\n } else {\n const sign = isOut ? '-' : '+';\n label = `${sign}${asset.value} ${asset.symbol}`;\n }\n const successOrError = isOut ? 'error' : 'success';\n\n return (\n <Box direction=\"vertical\" crossAlignment=\"end\">\n <Box direction=\"horizontal\" alignment=\"end\" center>\n {asset.logo ? (\n <Image src={asset.logo} borderRadius=\"full\" height={16} width={16} />\n ) : null}\n <SnapText color={isUnknownValue ? 'alternative' : successOrError}>\n {label}\n </SnapText>\n </Box>\n {asset.fiat ? <SnapText color=\"muted\">{asset.fiat}</SnapText> : null}\n </Box>\n );\n};\n\nconst AssetGroup = ({\n title,\n assets,\n}: {\n title: string;\n assets: EstimatedChangesAsset[];\n}): ComponentOrElement | null =>\n assets.length > 0 ? (\n <Box alignment=\"space-between\" direction=\"horizontal\">\n <SnapText fontWeight=\"medium\" color=\"alternative\">\n {title}\n </SnapText>\n <Box direction=\"vertical\" alignment=\"end\">\n {assets.map((asset, index) => (\n <Box key={`${asset.type}-${asset.symbol}-${index}`}>\n <AssetRow asset={asset} />\n </Box>\n ))}\n </Box>\n </Box>\n ) : null;\n\n/**\n * Renders the estimated balance changes of a transaction, grouped into\n * \"send\" and \"receive\" rows, with loading, error and empty states.\n *\n * The header is always rendered. The body depends on the props:\n *\n * 1. No assets and `isFetching` → loading skeleton (takes precedence over\n * `isUnavailable`).\n * 2. No assets and `isUnavailable` → \"not available\" message.\n * 3. No assets otherwise → \"no changes\" message (an empty result means the\n * transaction does not change any balance).\n * 4. Assets present → \"send\" and/or \"receive\" groups; a group with no assets\n * is omitted. `isFetching` and `isUnavailable` are ignored in this case, as\n * rows seeded locally by the caller are final.\n *\n * @param props - The component props.\n * @param props.assets - The display-ready asset changes.\n * @param props.labels - The translated labels.\n * @param props.isFetching - Whether the estimate is still being fetched.\n * @param props.isUnavailable - Whether the estimate could not be produced.\n * @returns The estimated changes section.\n */\nexport const EstimatedChanges = ({\n assets,\n labels,\n isFetching,\n isUnavailable,\n}: EstimatedChangesProps): ComponentOrElement => {\n // Rows seeded locally by the caller are final, so they are never replaced by\n // the loading/unavailable states.\n if (assets.length === 0) {\n if (isFetching) {\n return (\n <Section direction=\"vertical\">\n <Header labels={labels} />\n <Box alignment=\"space-between\" direction=\"horizontal\">\n <Skeleton width={60} />\n <Skeleton width={100} />\n </Box>\n </Section>\n );\n }\n\n return (\n <MessageSection\n labels={labels}\n message={isUnavailable ? labels.notAvailable : labels.noChanges}\n />\n );\n }\n\n return (\n <Section>\n <Header labels={labels} />\n <AssetGroup\n title={labels.send}\n assets={assets.filter((asset) => asset.type === 'out')}\n />\n <AssetGroup\n title={labels.receive}\n assets={assets.filter((asset) => asset.type === 'in')}\n />\n </Section>\n );\n};\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ComponentOrElement } from "@metamask/snaps-sdk";
|
|
2
|
+
export type EstimatedChangesAsset = {
|
|
3
|
+
type: 'in' | 'out';
|
|
4
|
+
/** Display-ready amount, or `null` when the amount is unknown. */
|
|
5
|
+
value: string | null;
|
|
6
|
+
symbol: string;
|
|
7
|
+
logo: string | null;
|
|
8
|
+
/** Display-ready fiat value shown under the amount. */
|
|
9
|
+
fiat?: string | null;
|
|
10
|
+
};
|
|
11
|
+
export type EstimatedChangesLabels = {
|
|
12
|
+
title: string;
|
|
13
|
+
tooltip: string;
|
|
14
|
+
send: string;
|
|
15
|
+
receive: string;
|
|
16
|
+
notAvailable: string;
|
|
17
|
+
noChanges: string;
|
|
18
|
+
};
|
|
19
|
+
export type EstimatedChangesProps = {
|
|
20
|
+
assets: EstimatedChangesAsset[];
|
|
21
|
+
labels: EstimatedChangesLabels;
|
|
22
|
+
/** Whether the estimate is still being fetched. */
|
|
23
|
+
isFetching: boolean;
|
|
24
|
+
/** Whether the estimate could not be produced (e.g. fetch or simulation failure). */
|
|
25
|
+
isUnavailable: boolean;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Renders the estimated balance changes of a transaction, grouped into
|
|
29
|
+
* "send" and "receive" rows, with loading, error and empty states.
|
|
30
|
+
*
|
|
31
|
+
* The header is always rendered. The body depends on the props:
|
|
32
|
+
*
|
|
33
|
+
* 1. No assets and `isFetching` → loading skeleton (takes precedence over
|
|
34
|
+
* `isUnavailable`).
|
|
35
|
+
* 2. No assets and `isUnavailable` → "not available" message.
|
|
36
|
+
* 3. No assets otherwise → "no changes" message (an empty result means the
|
|
37
|
+
* transaction does not change any balance).
|
|
38
|
+
* 4. Assets present → "send" and/or "receive" groups; a group with no assets
|
|
39
|
+
* is omitted. `isFetching` and `isUnavailable` are ignored in this case, as
|
|
40
|
+
* rows seeded locally by the caller are final.
|
|
41
|
+
*
|
|
42
|
+
* @param props - The component props.
|
|
43
|
+
* @param props.assets - The display-ready asset changes.
|
|
44
|
+
* @param props.labels - The translated labels.
|
|
45
|
+
* @param props.isFetching - Whether the estimate is still being fetched.
|
|
46
|
+
* @param props.isUnavailable - Whether the estimate could not be produced.
|
|
47
|
+
* @returns The estimated changes section.
|
|
48
|
+
*/
|
|
49
|
+
export declare const EstimatedChanges: ({ assets, labels, isFetching, isUnavailable, }: EstimatedChangesProps) => ComponentOrElement;
|
|
50
|
+
//# sourceMappingURL=EstimatedChanges.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EstimatedChanges.d.cts","sourceRoot":"","sources":["../../../src/ui/EstimatedChanges/EstimatedChanges.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,4BAA4B;AAW9D,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,IAAI,GAAG,KAAK,CAAC;IACnB,kEAAkE;IAClE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAChC,MAAM,EAAE,sBAAsB,CAAC;IAC/B,mDAAmD;IACnD,UAAU,EAAE,OAAO,CAAC;IACpB,qFAAqF;IACrF,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAiFF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,gBAAgB,GAAI,gDAK9B,qBAAqB,KAAG,kBAqC1B,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ComponentOrElement } from "@metamask/snaps-sdk";
|
|
2
|
+
export type EstimatedChangesAsset = {
|
|
3
|
+
type: 'in' | 'out';
|
|
4
|
+
/** Display-ready amount, or `null` when the amount is unknown. */
|
|
5
|
+
value: string | null;
|
|
6
|
+
symbol: string;
|
|
7
|
+
logo: string | null;
|
|
8
|
+
/** Display-ready fiat value shown under the amount. */
|
|
9
|
+
fiat?: string | null;
|
|
10
|
+
};
|
|
11
|
+
export type EstimatedChangesLabels = {
|
|
12
|
+
title: string;
|
|
13
|
+
tooltip: string;
|
|
14
|
+
send: string;
|
|
15
|
+
receive: string;
|
|
16
|
+
notAvailable: string;
|
|
17
|
+
noChanges: string;
|
|
18
|
+
};
|
|
19
|
+
export type EstimatedChangesProps = {
|
|
20
|
+
assets: EstimatedChangesAsset[];
|
|
21
|
+
labels: EstimatedChangesLabels;
|
|
22
|
+
/** Whether the estimate is still being fetched. */
|
|
23
|
+
isFetching: boolean;
|
|
24
|
+
/** Whether the estimate could not be produced (e.g. fetch or simulation failure). */
|
|
25
|
+
isUnavailable: boolean;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Renders the estimated balance changes of a transaction, grouped into
|
|
29
|
+
* "send" and "receive" rows, with loading, error and empty states.
|
|
30
|
+
*
|
|
31
|
+
* The header is always rendered. The body depends on the props:
|
|
32
|
+
*
|
|
33
|
+
* 1. No assets and `isFetching` → loading skeleton (takes precedence over
|
|
34
|
+
* `isUnavailable`).
|
|
35
|
+
* 2. No assets and `isUnavailable` → "not available" message.
|
|
36
|
+
* 3. No assets otherwise → "no changes" message (an empty result means the
|
|
37
|
+
* transaction does not change any balance).
|
|
38
|
+
* 4. Assets present → "send" and/or "receive" groups; a group with no assets
|
|
39
|
+
* is omitted. `isFetching` and `isUnavailable` are ignored in this case, as
|
|
40
|
+
* rows seeded locally by the caller are final.
|
|
41
|
+
*
|
|
42
|
+
* @param props - The component props.
|
|
43
|
+
* @param props.assets - The display-ready asset changes.
|
|
44
|
+
* @param props.labels - The translated labels.
|
|
45
|
+
* @param props.isFetching - Whether the estimate is still being fetched.
|
|
46
|
+
* @param props.isUnavailable - Whether the estimate could not be produced.
|
|
47
|
+
* @returns The estimated changes section.
|
|
48
|
+
*/
|
|
49
|
+
export declare const EstimatedChanges: ({ assets, labels, isFetching, isUnavailable, }: EstimatedChangesProps) => ComponentOrElement;
|
|
50
|
+
//# sourceMappingURL=EstimatedChanges.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EstimatedChanges.d.mts","sourceRoot":"","sources":["../../../src/ui/EstimatedChanges/EstimatedChanges.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,4BAA4B;AAW9D,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,IAAI,GAAG,KAAK,CAAC;IACnB,kEAAkE;IAClE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAChC,MAAM,EAAE,sBAAsB,CAAC;IAC/B,mDAAmD;IACnD,UAAU,EAAE,OAAO,CAAC;IACpB,qFAAqF;IACrF,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAiFF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,gBAAgB,GAAI,gDAK9B,qBAAqB,KAAG,kBAqC1B,CAAC"}
|