From 665225e223783520b87beca76fd565890121b651 Mon Sep 17 00:00:00 2001 From: Ulisses Ferreira Date: Thu, 27 Aug 2026 18:40:41 +0100 Subject: [PATCH 1/2] refactor(stellar-wallet-snap): replace TypeScript enums with as const objects Convert all locally-declared enums to const objects with derived union types, matching the Bitcoin/Solana/Tron enum migration pattern. Co-authored-by: Cursor --- .../stellar-wallet-snap/snap.manifest.json | 2 +- packages/stellar-wallet-snap/src/api/asset.ts | 18 ++--- .../src/api/environment.ts | 12 ++-- .../stellar-wallet-snap/src/api/network.ts | 11 +-- .../src/handlers/accountResolver.ts | 11 +-- .../src/handlers/clientRequest/api.ts | 46 +++++++----- .../handlers/clientRequest/changeTrustOpt.ts | 4 +- .../clientRequest/onAmountInput.test.ts | 2 +- .../src/handlers/cronjob/api.ts | 15 ++-- .../cronjob/refreshConfirmationContext/api.ts | 13 ++-- .../src/handlers/keyring/api.ts | 13 ++-- .../src/handlers/keyring/exceptions.ts | 15 ++-- .../src/services/network/MultiCall.ts | 11 +-- .../src/services/network/api.ts | 28 ++++---- .../src/services/transaction-scan/api.ts | 54 ++++++++------ .../transaction/KeyringTransactionBuilder.ts | 47 ++++++------ .../services/transaction/TransactionMapper.ts | 4 +- .../transaction/TransactionSimulator.ts | 17 +++-- .../src/services/transaction/api.ts | 72 ++++++++++--------- .../src/services/transaction/utils.ts | 14 ++-- .../src/services/transaction/xdrParser.ts | 15 ++-- .../src/ui/confirmation/api.ts | 34 +++++---- .../src/ui/confirmation/controller.tsx | 12 ++-- .../src/ui/confirmation/utils.ts | 13 ++-- .../views/ConfirmSendTransaction/events.tsx | 11 +-- .../views/ConfirmSignAuthEntry/events.tsx | 11 +-- .../ConfirmSignChangeTrustOptIn/events.tsx | 11 +-- .../ConfirmSignChangeTrustOptOut/events.tsx | 11 +-- .../views/ConfirmSignMessage/events.tsx | 11 +-- .../views/ConfirmSignTransaction/events.tsx | 11 +-- .../MaliciousAcknowledgement/constants.ts | 15 ++-- .../stellar-wallet-snap/src/utils/snap.ts | 54 ++++++++------ 32 files changed, 359 insertions(+), 259 deletions(-) diff --git a/packages/stellar-wallet-snap/snap.manifest.json b/packages/stellar-wallet-snap/snap.manifest.json index 4c877cf20..551994fa7 100644 --- a/packages/stellar-wallet-snap/snap.manifest.json +++ b/packages/stellar-wallet-snap/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/internal-snaps.git" }, "source": { - "shasum": "XmHWNIVVLlhvKq+iksu3PyMYqx95Zj7lQAB/s1cOFlk=", + "shasum": "i8XzrvzKRiP6L8dp7cr7LVqprs3sX5rOs8JJ59VQyoo=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/stellar-wallet-snap/src/api/asset.ts b/packages/stellar-wallet-snap/src/api/asset.ts index 335b5ae29..d51c69dfa 100644 --- a/packages/stellar-wallet-snap/src/api/asset.ts +++ b/packages/stellar-wallet-snap/src/api/asset.ts @@ -8,15 +8,17 @@ import { KnownCaip2ChainId } from './network'; /** Stellar Asset namespace */ /** Please see https://namespaces.chainagnostic.org/stellar/caip19#asset-namespaces */ -export enum AssetType { - Native = 'slip44', - Token = 'asset', - Sep41 = 'sep41', -} +export const AssetType = { + Native: 'slip44', + Token: 'asset', + Sep41: 'sep41', +} as const; + +export type AssetType = (typeof AssetType)[keyof typeof AssetType]; /** Known CAIP-19 IDs */ export const KnownCaip19Slip44IdStruct = - definePattern<`${KnownCaip2ChainId}/${AssetType.Native}:${typeof STELLAR_COIN_TYPE}`>( + definePattern<`${KnownCaip2ChainId}/${typeof AssetType.Native}:${typeof STELLAR_COIN_TYPE}`>( 'KnownCaip19Slip44Id', /^stellar:(?:pubnet|testnet)\/slip44:148$/u, ); @@ -35,13 +37,13 @@ export const KnownCaip19Slip44IdMap: Record< * @see https://namespaces.chainagnostic.org/stellar/caip19#asset-namespaces */ export const KnownCaip19ClassicAssetStruct = - definePattern<`${KnownCaip2ChainId}/${AssetType.Token}:${string}-${string}`>( + definePattern<`${KnownCaip2ChainId}/${typeof AssetType.Token}:${string}-${string}`>( 'KnownCaip19ClassicAsset', /^stellar:(?:pubnet|testnet)\/asset:[A-Za-z0-9]{1,12}-G[A-Z2-7]{55}$/u, ); export const KnownCaip19Sep41AssetStruct = - definePattern<`${KnownCaip2ChainId}/${AssetType.Sep41}:${string}`>( + definePattern<`${KnownCaip2ChainId}/${typeof AssetType.Sep41}:${string}`>( 'KnownCaip19Sep41Asset', /^stellar:(?:pubnet|testnet)\/sep41:C[A-Z2-7]{55}$/u, ); diff --git a/packages/stellar-wallet-snap/src/api/environment.ts b/packages/stellar-wallet-snap/src/api/environment.ts index 1b6b05118..c251b4183 100644 --- a/packages/stellar-wallet-snap/src/api/environment.ts +++ b/packages/stellar-wallet-snap/src/api/environment.ts @@ -1,5 +1,7 @@ -export enum Environment { - Local = 'local', - Test = 'test', - Production = 'production', -} +export const Environment = { + Local: 'local', + Test: 'test', + Production: 'production', +} as const; + +export type Environment = (typeof Environment)[keyof typeof Environment]; diff --git a/packages/stellar-wallet-snap/src/api/network.ts b/packages/stellar-wallet-snap/src/api/network.ts index c7dc201c4..94cb217c1 100644 --- a/packages/stellar-wallet-snap/src/api/network.ts +++ b/packages/stellar-wallet-snap/src/api/network.ts @@ -5,9 +5,12 @@ import { KnownCaipNamespace } from '@metamask/utils'; /** Known CAIP-2 IDs */ /** Please see https://namespaces.chainagnostic.org/stellar/caip2 */ -export enum KnownCaip2ChainId { - Mainnet = `${KnownCaipNamespace.Stellar}:pubnet`, - Testnet = `${KnownCaipNamespace.Stellar}:testnet`, -} +export const KnownCaip2ChainId = { + Mainnet: `${KnownCaipNamespace.Stellar}:pubnet`, + Testnet: `${KnownCaipNamespace.Stellar}:testnet`, +} as const; + +export type KnownCaip2ChainId = + (typeof KnownCaip2ChainId)[keyof typeof KnownCaip2ChainId]; export const KnownCaip2ChainIdStruct = enums(Object.values(KnownCaip2ChainId)); diff --git a/packages/stellar-wallet-snap/src/handlers/accountResolver.ts b/packages/stellar-wallet-snap/src/handlers/accountResolver.ts index 852e4933d..341da5985 100644 --- a/packages/stellar-wallet-snap/src/handlers/accountResolver.ts +++ b/packages/stellar-wallet-snap/src/handlers/accountResolver.ts @@ -11,10 +11,13 @@ import { OnChainAccount } from '../services/on-chain-account'; import type { WalletService } from '../services/wallet'; import { Wallet } from '../services/wallet'; -export enum ResolveAccountSource { - OnChain = 'on-chain', - State = 'state', -} +export const ResolveAccountSource = { + OnChain: 'on-chain', + State: 'state', +} as const; + +export type ResolveAccountSource = + (typeof ResolveAccountSource)[keyof typeof ResolveAccountSource]; export type ResolveAccountOptions = { /** Whether to load the activated on-chain account. */ diff --git a/packages/stellar-wallet-snap/src/handlers/clientRequest/api.ts b/packages/stellar-wallet-snap/src/handlers/clientRequest/api.ts index fd1bec48a..c067fbf61 100644 --- a/packages/stellar-wallet-snap/src/handlers/clientRequest/api.ts +++ b/packages/stellar-wallet-snap/src/handlers/clientRequest/api.ts @@ -40,33 +40,41 @@ import { isSep41Id } from '../../utils'; /** * Enum for the client request method. */ -export enum ClientRequestMethod { +export const ClientRequestMethod = { /** -------------------------------- Wallet Standard -------------------------------- */ - OnAddressInput = 'onAddressInput', - OnAmountInput = 'onAmountInput', - ConfirmSend = 'confirmSend', + OnAddressInput: 'onAddressInput', + OnAmountInput: 'onAmountInput', + ConfirmSend: 'confirmSend', // Standard multichain workflow for bridge - SignAndSendTransaction = 'signAndSendTransaction', - ComputeFee = 'computeFee', + SignAndSendTransaction: 'signAndSendTransaction', + ComputeFee: 'computeFee', /** -------------------------------- Stellar Specific -------------------------------- */ - ChangeTrustOpt = 'changeTrustOpt', -} + ChangeTrustOpt: 'changeTrustOpt', +} as const; -export enum MultiChainSendErrorCodes { - // eslint-disable-next-line @typescript-eslint/no-shadow - Required = 'Required', - Invalid = 'Invalid', - InsufficientBalance = 'InsufficientBalance', - InsufficientBalanceToCoverFee = 'InsufficientBalanceToCoverFee', -} +export type ClientRequestMethod = + (typeof ClientRequestMethod)[keyof typeof ClientRequestMethod]; + +export const MultiChainSendErrorCodes = { + Required: 'Required', + Invalid: 'Invalid', + InsufficientBalance: 'InsufficientBalance', + InsufficientBalanceToCoverFee: 'InsufficientBalanceToCoverFee', +} as const; + +export type MultiChainSendErrorCodes = + (typeof MultiChainSendErrorCodes)[keyof typeof MultiChainSendErrorCodes]; /** * Trustline change intent for {@link ClientRequestMethod.ChangeTrustOpt}. */ -export enum ChangeTrustOptAction { - Add = 'add', - Delete = 'delete', -} +export const ChangeTrustOptAction = { + Add: 'add', + Delete: 'delete', +} as const; + +export type ChangeTrustOptAction = + (typeof ChangeTrustOptAction)[keyof typeof ChangeTrustOptAction]; /** * Validation struct for the client request method. diff --git a/packages/stellar-wallet-snap/src/handlers/clientRequest/changeTrustOpt.ts b/packages/stellar-wallet-snap/src/handlers/clientRequest/changeTrustOpt.ts index 1d35a3ee5..c6f4cee52 100644 --- a/packages/stellar-wallet-snap/src/handlers/clientRequest/changeTrustOpt.ts +++ b/packages/stellar-wallet-snap/src/handlers/clientRequest/changeTrustOpt.ts @@ -342,8 +342,8 @@ export class ChangeTrustOptHandler extends BaseClientRequestHandler< fee: string; transaction: Transaction; confirmationInterfaceKey: - | ConfirmationInterfaceKey.ChangeTrustlineOptIn - | ConfirmationInterfaceKey.ChangeTrustlineOptOut; + | typeof ConfirmationInterfaceKey.ChangeTrustlineOptIn + | typeof ConfirmationInterfaceKey.ChangeTrustlineOptOut; }): Promise { const { request, diff --git a/packages/stellar-wallet-snap/src/handlers/clientRequest/onAmountInput.test.ts b/packages/stellar-wallet-snap/src/handlers/clientRequest/onAmountInput.test.ts index 64be0260a..3926f386c 100644 --- a/packages/stellar-wallet-snap/src/handlers/clientRequest/onAmountInput.test.ts +++ b/packages/stellar-wallet-snap/src/handlers/clientRequest/onAmountInput.test.ts @@ -201,7 +201,7 @@ describe('OnAmountInputHandler', () => { }); it('resolves on-chain account using scope derived from assetId', async () => { - const testnetAssetId = `${KnownCaip2ChainId.Testnet}/slip44:148`; + const testnetAssetId = `${KnownCaip2ChainId.Testnet}/slip44:148` as const; const { handler, account, diff --git a/packages/stellar-wallet-snap/src/handlers/cronjob/api.ts b/packages/stellar-wallet-snap/src/handlers/cronjob/api.ts index 34e57e725..3d12dd624 100644 --- a/packages/stellar-wallet-snap/src/handlers/cronjob/api.ts +++ b/packages/stellar-wallet-snap/src/handlers/cronjob/api.ts @@ -35,12 +35,15 @@ export type ICronjobRequestHandler = { handle: (request: JsonRpcRequest) => Promise; }; -export enum BackgroundEventMethod { - SynchronizeAssets = 'synchronizeAssets', - SynchronizeAccounts = 'synchronizeAccounts', - TrackTransaction = 'trackTransaction', - RefreshConfirmationContext = 'refreshConfirmationContext', -} +export const BackgroundEventMethod = { + SynchronizeAssets: 'synchronizeAssets', + SynchronizeAccounts: 'synchronizeAccounts', + TrackTransaction: 'trackTransaction', + RefreshConfirmationContext: 'refreshConfirmationContext', +} as const; + +export type BackgroundEventMethod = + (typeof BackgroundEventMethod)[keyof typeof BackgroundEventMethod]; export const BackgroundEventMethodStruct = enums( Object.values(BackgroundEventMethod), diff --git a/packages/stellar-wallet-snap/src/handlers/cronjob/refreshConfirmationContext/api.ts b/packages/stellar-wallet-snap/src/handlers/cronjob/refreshConfirmationContext/api.ts index 28f1fe523..eed3851f1 100644 --- a/packages/stellar-wallet-snap/src/handlers/cronjob/refreshConfirmationContext/api.ts +++ b/packages/stellar-wallet-snap/src/handlers/cronjob/refreshConfirmationContext/api.ts @@ -4,11 +4,14 @@ import type { Json } from '@metamask/utils'; import type { ContextWithPrices } from '../../../ui/confirmation/api'; /** Identifies which confirmation context refreshers to run for a cron cycle. */ -export enum ConfirmationContextRefresherKey { - Prices = 'prices', - Scan = 'scan', - Transaction = 'transaction', -} +export const ConfirmationContextRefresherKey = { + Prices: 'prices', + Scan: 'scan', + Transaction: 'transaction', +} as const; + +export type ConfirmationContextRefresherKey = + (typeof ConfirmationContextRefresherKey)[keyof typeof ConfirmationContextRefresherKey]; export const ConfirmationContextRefresherKeyStruct = enums( Object.values(ConfirmationContextRefresherKey), diff --git a/packages/stellar-wallet-snap/src/handlers/keyring/api.ts b/packages/stellar-wallet-snap/src/handlers/keyring/api.ts index e0bd78183..c03192f62 100644 --- a/packages/stellar-wallet-snap/src/handlers/keyring/api.ts +++ b/packages/stellar-wallet-snap/src/handlers/keyring/api.ts @@ -32,11 +32,14 @@ import { HashIdPreimageXdrStruct, XdrStruct } from '../../api/xdr'; import { networkToCaip2ChainId } from '../../services/network/utils'; /** JSON-RPC methods supported by this snap's multichain keyring. */ -export enum MultichainMethod { - SignMessage = 'signMessage', - SignTransaction = 'signTransaction', - SignAuthEntry = 'signAuthEntry', -} +export const MultichainMethod = { + SignMessage: 'signMessage', + SignTransaction: 'signTransaction', + SignAuthEntry: 'signAuthEntry', +} as const; + +export type MultichainMethod = + (typeof MultichainMethod)[keyof typeof MultichainMethod]; /** Superstruct validator for {@link MultichainMethod} string values. */ export const MultichainMethodStruct = enums(Object.values(MultichainMethod)); diff --git a/packages/stellar-wallet-snap/src/handlers/keyring/exceptions.ts b/packages/stellar-wallet-snap/src/handlers/keyring/exceptions.ts index 4fec7fdaf..430b6bdfe 100644 --- a/packages/stellar-wallet-snap/src/handlers/keyring/exceptions.ts +++ b/packages/stellar-wallet-snap/src/handlers/keyring/exceptions.ts @@ -23,16 +23,19 @@ export class KeyringException extends StellarSnapException {} * * @see https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0043.md */ -export enum Sep43ErrorCode { +export const Sep43ErrorCode = { /** Internal wallet error (JS runtime, programmer error, etc.). */ - Internal = -1, + Internal: -1, /** External service (Horizon, RPC, …) returned an error. */ - ExternalService = -2, + ExternalService: -2, /** Client app request is invalid (bad params, malformed XDR, unsupported option). */ - InvalidRequest = -3, + InvalidRequest: -3, /** User declined the confirmation. */ - UserRejected = -4, -} + UserRejected: -4, +} as const; + +export type Sep43ErrorCode = + (typeof Sep43ErrorCode)[keyof typeof Sep43ErrorCode]; /** * Generic SEP-43 message that's user-safe to forward to the dapp. diff --git a/packages/stellar-wallet-snap/src/services/network/MultiCall.ts b/packages/stellar-wallet-snap/src/services/network/MultiCall.ts index e024bc43e..ccbe82f4d 100644 --- a/packages/stellar-wallet-snap/src/services/network/MultiCall.ts +++ b/packages/stellar-wallet-snap/src/services/network/MultiCall.ts @@ -29,10 +29,13 @@ export const SIMULATION_ACCOUNT: string = * it is recommended by Stellar official site. * @see https://developers.stellar.org/docs/tools/sdks/contract-sdks#stellar-multicall--router-sdk */ -export enum StellarRouterContract { - V0 = 'CBZV3HBP672BV7FF3ZILVT4CNPW3N5V2WTJ2LAGOAYW5R7L2D5SLUDFZ', - V1 = 'CCM23MFAJHDWUMF3IM3UPUI4ZUFFKX6OWJNJRUKO2W6MUTQNQWWFH7DC', -} +export const StellarRouterContract = { + V0: 'CBZV3HBP672BV7FF3ZILVT4CNPW3N5V2WTJ2LAGOAYW5R7L2D5SLUDFZ', + V1: 'CCM23MFAJHDWUMF3IM3UPUI4ZUFFKX6OWJNJRUKO2W6MUTQNQWWFH7DC', +} as const; + +export type StellarRouterContract = + (typeof StellarRouterContract)[keyof typeof StellarRouterContract]; export type StellarRouterParams = { rpcClient: rpc.Server; diff --git a/packages/stellar-wallet-snap/src/services/network/api.ts b/packages/stellar-wallet-snap/src/services/network/api.ts index 9cb281f38..0faa9fd76 100644 --- a/packages/stellar-wallet-snap/src/services/network/api.ts +++ b/packages/stellar-wallet-snap/src/services/network/api.ts @@ -6,19 +6,21 @@ import type { KnownCaip19AssetId } from '../../api'; * * @see https://developers.stellar.org/docs/data/apis/horizon/api-reference/errors/result-codes/transactions */ -export enum KnownRpcError { - TxBadSeq = 'txBadSeq', - TxBadAuth = 'txBadAuth', - TxTooEarly = 'txTooEarly', - TxTooLate = 'txTooLate', - TxInsufficientFee = 'txInsufficientFee', - TxInsufficientBalance = 'txInsufficientBalance', - TxInsufficientReserve = 'txInsufficientReserve', - TxFailed = 'txFailed', - TxMissingOperation = 'txMissingOperation', - TxInternalError = 'txInternalError', - TxBadAuthExtra = 'txBadAuthExtra', -} +export const KnownRpcError = { + TxBadSeq: 'txBadSeq', + TxBadAuth: 'txBadAuth', + TxTooEarly: 'txTooEarly', + TxTooLate: 'txTooLate', + TxInsufficientFee: 'txInsufficientFee', + TxInsufficientBalance: 'txInsufficientBalance', + TxInsufficientReserve: 'txInsufficientReserve', + TxFailed: 'txFailed', + TxMissingOperation: 'txMissingOperation', + TxInternalError: 'txInternalError', + TxBadAuthExtra: 'txBadAuthExtra', +} as const; + +export type KnownRpcError = (typeof KnownRpcError)[keyof typeof KnownRpcError]; /** * Asset data for a Stellar classic asset. diff --git a/packages/stellar-wallet-snap/src/services/transaction-scan/api.ts b/packages/stellar-wallet-snap/src/services/transaction-scan/api.ts index 032e41a57..760e9972a 100644 --- a/packages/stellar-wallet-snap/src/services/transaction-scan/api.ts +++ b/packages/stellar-wallet-snap/src/services/transaction-scan/api.ts @@ -28,33 +28,45 @@ import { KnownCaip2ChainId, XdrStruct } from '../../api'; * * @see packages/snap/src/ui/confirmation/components/TransactionAlert.tsx */ -export enum TransactionScanErrorId { - InsufficientBalance = 'insufficientbalance', - InsufficientFunds = 'insufficientfunds', - InvalidTransaction = 'invalidtransaction', - InvalidAddress = 'invalidaddress', - NoTrustline = 'notrustline', - TransactionExpired = 'transactionexpired', -} +export const TransactionScanErrorId = { + InsufficientBalance: 'insufficientbalance', + InsufficientFunds: 'insufficientfunds', + InvalidTransaction: 'invalidtransaction', + InvalidAddress: 'invalidaddress', + NoTrustline: 'notrustline', + TransactionExpired: 'transactionexpired', +} as const; + +export type TransactionScanErrorId = + (typeof TransactionScanErrorId)[keyof typeof TransactionScanErrorId]; /** TransactionScanOption - Options for the transaction scan. */ -export enum TransactionScanOption { - Simulation = 'simulation', - Validation = 'validation', -} +export const TransactionScanOption = { + Simulation: 'simulation', + Validation: 'validation', +} as const; + +export type TransactionScanOption = + (typeof TransactionScanOption)[keyof typeof TransactionScanOption]; /** TransactionScanValidationType */ -export enum TransactionScanValidationType { - Benign = 'Benign', - Warning = 'Warning', - Malicious = 'Malicious', -} +export const TransactionScanValidationType = { + Benign: 'Benign', + Warning: 'Warning', + Malicious: 'Malicious', +} as const; + +export type TransactionScanValidationType = + (typeof TransactionScanValidationType)[keyof typeof TransactionScanValidationType]; /** AssetChangeDirection - Direction of an estimated balance change relative to the signer. */ -export enum AssetChangeDirection { - In = 'in', - Out = 'out', -} +export const AssetChangeDirection = { + In: 'in', + Out: 'out', +} as const; + +export type AssetChangeDirection = + (typeof AssetChangeDirection)[keyof typeof AssetChangeDirection]; /** Security Alerts API chain identifier. */ export type SecurityAlertsChain = 'pubnet' | 'testnet' | 'futurenet'; diff --git a/packages/stellar-wallet-snap/src/services/transaction/KeyringTransactionBuilder.ts b/packages/stellar-wallet-snap/src/services/transaction/KeyringTransactionBuilder.ts index 6d50c8d81..32af82149 100644 --- a/packages/stellar-wallet-snap/src/services/transaction/KeyringTransactionBuilder.ts +++ b/packages/stellar-wallet-snap/src/services/transaction/KeyringTransactionBuilder.ts @@ -12,20 +12,23 @@ import { getSlip44AssetId, toDisplayBalance } from '../../utils'; import type { StellarKeyringAccount } from '../account/api'; import { KeyringTransactionBuilderException } from './exceptions'; -export enum KeyringTransactionType { - Swap = 'swap', - BridgeSend = 'bridgeSend', - ChangeTrustOptIn = 'changeTrustOptIn', - ChangeTrustOptOut = 'changeTrustOptOut', - Send = 'send', - Pending = 'pending', - Unknown = 'unknown', -} +export const KeyringTransactionType = { + Swap: 'swap', + BridgeSend: 'bridgeSend', + ChangeTrustOptIn: 'changeTrustOptIn', + ChangeTrustOptOut: 'changeTrustOptOut', + Send: 'send', + Pending: 'pending', + Unknown: 'unknown', +} as const; -enum KeyringTransactionTypeLabel { - ChangeTrustOptIn = 'trustline-approve', - ChangeTrustOptOut = 'trustline-disapprove', -} +export type KeyringTransactionType = + (typeof KeyringTransactionType)[keyof typeof KeyringTransactionType]; + +const KeyringTransactionTypeLabel = { + ChangeTrustOptIn: 'trustline-approve', + ChangeTrustOptOut: 'trustline-disapprove', +} as const; export type KeyringTransactionAsset = { unit: string; @@ -102,31 +105,31 @@ export type UnknownTransactionRequest = { export type KeyringTransactionRequest = | { - type: KeyringTransactionType.ChangeTrustOptIn; + type: typeof KeyringTransactionType.ChangeTrustOptIn; request: ChangeTrustTransactionRequest; } | { - type: KeyringTransactionType.ChangeTrustOptOut; + type: typeof KeyringTransactionType.ChangeTrustOptOut; request: ChangeTrustTransactionRequest; } | { - type: KeyringTransactionType.Send; + type: typeof KeyringTransactionType.Send; request: SendTransactionRequest; } | { - type: KeyringTransactionType.Pending; + type: typeof KeyringTransactionType.Pending; request: PendingTransactionRequest; } | { - type: KeyringTransactionType.Unknown; + type: typeof KeyringTransactionType.Unknown; request: UnknownTransactionRequest; } | { - type: KeyringTransactionType.Swap; + type: typeof KeyringTransactionType.Swap; request: SwapTransactionRequest; } | { - type: KeyringTransactionType.BridgeSend; + type: typeof KeyringTransactionType.BridgeSend; request: UnknownTransactionRequest; }; @@ -170,8 +173,8 @@ export class KeyringTransactionBuilder { #createChangeTrustTransaction( request: ChangeTrustTransactionRequest, optInOrOut: - | KeyringTransactionType.ChangeTrustOptIn - | KeyringTransactionType.ChangeTrustOptOut, + | typeof KeyringTransactionType.ChangeTrustOptIn + | typeof KeyringTransactionType.ChangeTrustOptOut, ): KeyringTransaction { const { txId, diff --git a/packages/stellar-wallet-snap/src/services/transaction/TransactionMapper.ts b/packages/stellar-wallet-snap/src/services/transaction/TransactionMapper.ts index 01db45cd4..2098c3d38 100644 --- a/packages/stellar-wallet-snap/src/services/transaction/TransactionMapper.ts +++ b/packages/stellar-wallet-snap/src/services/transaction/TransactionMapper.ts @@ -364,8 +364,8 @@ export class TransactionMapper { transaction: Transaction, keyringAccount: StellarKeyringAccount, type: - | KeyringTransactionType.ChangeTrustOptIn - | KeyringTransactionType.ChangeTrustOptOut, + | typeof KeyringTransactionType.ChangeTrustOptIn + | typeof KeyringTransactionType.ChangeTrustOptOut, ): KeyringTransaction { const operationTypes = transaction.transactionOperations; const { scope } = transaction; diff --git a/packages/stellar-wallet-snap/src/services/transaction/TransactionSimulator.ts b/packages/stellar-wallet-snap/src/services/transaction/TransactionSimulator.ts index 58afc70da..5e146d01b 100644 --- a/packages/stellar-wallet-snap/src/services/transaction/TransactionSimulator.ts +++ b/packages/stellar-wallet-snap/src/services/transaction/TransactionSimulator.ts @@ -51,13 +51,16 @@ type SupportedOPType = /** * Stellar operation kinds used when validating or simulating transactions. */ -export enum SupportedOperations { - Payment = 'payment', - PathPayment = 'pathPayment', - CreateAccount = 'createAccount', - ChangeTrust = 'changeTrust', - InvokeHostFunction = 'invokeHostFunction', -} +export const SupportedOperations = { + Payment: 'payment', + PathPayment: 'pathPayment', + CreateAccount: 'createAccount', + ChangeTrust: 'changeTrust', + InvokeHostFunction: 'invokeHostFunction', +} as const; + +export type SupportedOperations = + (typeof SupportedOperations)[keyof typeof SupportedOperations]; /** * Optional settings for {@link TransactionSimulator.simulate}. diff --git a/packages/stellar-wallet-snap/src/services/transaction/api.ts b/packages/stellar-wallet-snap/src/services/transaction/api.ts index b23892bfe..c45ffc278 100644 --- a/packages/stellar-wallet-snap/src/services/transaction/api.ts +++ b/packages/stellar-wallet-snap/src/services/transaction/api.ts @@ -11,42 +11,48 @@ export type StellarKeyringTransaction = KeyringTransaction & { /** * The order of onChain transactions to fetch. */ -export enum TransactionOrder { - ASC = 'asc', - DESC = 'desc', -} +export const TransactionOrder = { + ASC: 'asc', + DESC: 'desc', +} as const; + +export type TransactionOrder = + (typeof TransactionOrder)[keyof typeof TransactionOrder]; /** * The type of Stellar operation. * * @see https://stellar.org/developers/guides/concepts/list-of-operations.html */ -export enum StellarOperationType { - AccountMerge = 'accountMerge', - AllowTrust = 'allowTrust', - BeginSponsoringFutureReserves = 'beginSponsoringFutureReserves', - BumpSequence = 'bumpSequence', - ChangeTrust = 'changeTrust', - ClaimClaimableBalance = 'claimClaimableBalance', - Clawback = 'clawback', - ClawbackClaimableBalance = 'clawbackClaimableBalance', - CreateAccount = 'createAccount', - CreateClaimableBalance = 'createClaimableBalance', - CreatePassiveSellOffer = 'createPassiveSellOffer', - EndSponsoringFutureReserves = 'endSponsoringFutureReserves', - ExtendFootprintTtl = 'extendFootprintTtl', - Inflation = 'inflation', - InvokeHostFunction = 'invokeHostFunction', - LiquidityPoolDeposit = 'liquidityPoolDeposit', - LiquidityPoolWithdraw = 'liquidityPoolWithdraw', - ManageBuyOffer = 'manageBuyOffer', - ManageData = 'manageData', - ManageSellOffer = 'manageSellOffer', - PathPaymentStrictReceive = 'pathPaymentStrictReceive', - PathPaymentStrictSend = 'pathPaymentStrictSend', - Payment = 'payment', - RestoreFootprint = 'restoreFootprint', - RevokeSponsorship = 'revokeSponsorship', - SetOptions = 'setOptions', - SetTrustLineFlags = 'setTrustLineFlags', -} +export const StellarOperationType = { + AccountMerge: 'accountMerge', + AllowTrust: 'allowTrust', + BeginSponsoringFutureReserves: 'beginSponsoringFutureReserves', + BumpSequence: 'bumpSequence', + ChangeTrust: 'changeTrust', + ClaimClaimableBalance: 'claimClaimableBalance', + Clawback: 'clawback', + ClawbackClaimableBalance: 'clawbackClaimableBalance', + CreateAccount: 'createAccount', + CreateClaimableBalance: 'createClaimableBalance', + CreatePassiveSellOffer: 'createPassiveSellOffer', + EndSponsoringFutureReserves: 'endSponsoringFutureReserves', + ExtendFootprintTtl: 'extendFootprintTtl', + Inflation: 'inflation', + InvokeHostFunction: 'invokeHostFunction', + LiquidityPoolDeposit: 'liquidityPoolDeposit', + LiquidityPoolWithdraw: 'liquidityPoolWithdraw', + ManageBuyOffer: 'manageBuyOffer', + ManageData: 'manageData', + ManageSellOffer: 'manageSellOffer', + PathPaymentStrictReceive: 'pathPaymentStrictReceive', + PathPaymentStrictSend: 'pathPaymentStrictSend', + Payment: 'payment', + RestoreFootprint: 'restoreFootprint', + RevokeSponsorship: 'revokeSponsorship', + SetOptions: 'setOptions', + SetTrustLineFlags: 'setTrustLineFlags', +} as const; + +export type StellarOperationType = + (typeof StellarOperationType)[keyof typeof StellarOperationType]; diff --git a/packages/stellar-wallet-snap/src/services/transaction/utils.ts b/packages/stellar-wallet-snap/src/services/transaction/utils.ts index 767a95fe3..29d710cff 100644 --- a/packages/stellar-wallet-snap/src/services/transaction/utils.ts +++ b/packages/stellar-wallet-snap/src/services/transaction/utils.ts @@ -362,12 +362,14 @@ export function isBridgeSendTransaction( if ( operationTypes.length === 1 && firstOperation && - [ - StellarOperationType.InvokeHostFunction, - StellarOperationType.Payment, - StellarOperationType.PathPaymentStrictSend, - StellarOperationType.PathPaymentStrictReceive, - ].includes(firstOperation.type as StellarOperationType) + ( + [ + StellarOperationType.InvokeHostFunction, + StellarOperationType.Payment, + StellarOperationType.PathPaymentStrictSend, + StellarOperationType.PathPaymentStrictReceive, + ] as readonly StellarOperationType[] + ).includes(firstOperation.type as StellarOperationType) ) { return true; } diff --git a/packages/stellar-wallet-snap/src/services/transaction/xdrParser.ts b/packages/stellar-wallet-snap/src/services/transaction/xdrParser.ts index 9708d9256..1d59757c4 100644 --- a/packages/stellar-wallet-snap/src/services/transaction/xdrParser.ts +++ b/packages/stellar-wallet-snap/src/services/transaction/xdrParser.ts @@ -26,10 +26,13 @@ import { import { bufferToUint8Array } from '../../utils/buffer'; import { XdrParseException } from './exceptions'; -export enum TransactionResultType { - PathPaymentStrictSendSuccess = 'pathPaymentStrictSendSuccess', - PathPaymentStrictReceiveSuccess = 'pathPaymentStrictReceiveSuccess', -} +export const TransactionResultType = { + PathPaymentStrictSendSuccess: 'pathPaymentStrictSendSuccess', + PathPaymentStrictReceiveSuccess: 'pathPaymentStrictReceiveSuccess', +} as const; + +export type TransactionResultType = + (typeof TransactionResultType)[keyof typeof TransactionResultType]; type TransactionResultAsset = | KnownCaip19ClassicAssetId @@ -51,13 +54,13 @@ type AssetAndAmount = { */ type OperationResult = | { - type: TransactionResultType.PathPaymentStrictSendSuccess; + type: typeof TransactionResultType.PathPaymentStrictSendSuccess; amount: string; asset: TransactionResultAsset; destination: string | undefined; } | { - type: TransactionResultType.PathPaymentStrictReceiveSuccess; + type: typeof TransactionResultType.PathPaymentStrictReceiveSuccess; amount: string; asset: TransactionResultAsset; destination: string | undefined; diff --git a/packages/stellar-wallet-snap/src/ui/confirmation/api.ts b/packages/stellar-wallet-snap/src/ui/confirmation/api.ts index 44a45acde..a098a98ca 100644 --- a/packages/stellar-wallet-snap/src/ui/confirmation/api.ts +++ b/packages/stellar-wallet-snap/src/ui/confirmation/api.ts @@ -44,13 +44,14 @@ export type FeeData = { amount: string; }; -export enum FetchStatus { - Initial = 'initial', - Fetching = 'fetching', - Fetched = 'fetched', - // eslint-disable-next-line @typescript-eslint/no-shadow - Error = 'error', -} +export const FetchStatus = { + Initial: 'initial', + Fetching: 'fetching', + Fetched: 'fetched', + Error: 'error', +} as const; + +export type FetchStatus = (typeof FetchStatus)[keyof typeof FetchStatus]; export const ContextWithPricesStruct = type({ tokenPrices: record( @@ -109,14 +110,17 @@ export type ContextWithTransactionValidation = Infer< typeof ContextWithTransactionValidationStruct >; -export enum ConfirmationInterfaceKey { - ChangeTrustlineOptIn = 'ChangeTrustlineOptIn', - ChangeTrustlineOptOut = 'ChangeTrustlineOptOut', - SignMessage = 'SignMessage', - SignTransaction = 'SignTransaction', - SignAuthEntry = 'SignAuthEntry', - ConfirmSendTransaction = 'ConfirmSendTransaction', -} +export const ConfirmationInterfaceKey = { + ChangeTrustlineOptIn: 'ChangeTrustlineOptIn', + ChangeTrustlineOptOut: 'ChangeTrustlineOptOut', + SignMessage: 'SignMessage', + SignTransaction: 'SignTransaction', + SignAuthEntry: 'SignAuthEntry', + ConfirmSendTransaction: 'ConfirmSendTransaction', +} as const; + +export type ConfirmationInterfaceKey = + (typeof ConfirmationInterfaceKey)[keyof typeof ConfirmationInterfaceKey]; export const ConfirmationInterfaceKeyStruct = enums( Object.values(ConfirmationInterfaceKey), diff --git a/packages/stellar-wallet-snap/src/ui/confirmation/controller.tsx b/packages/stellar-wallet-snap/src/ui/confirmation/controller.tsx index a78e4a9ed..b83e35109 100644 --- a/packages/stellar-wallet-snap/src/ui/confirmation/controller.tsx +++ b/packages/stellar-wallet-snap/src/ui/confirmation/controller.tsx @@ -24,8 +24,8 @@ import { updateInterfaceIfExists, } from '../../utils'; import { xlmIcon } from '../images'; -import { FetchStatus } from './api'; -import type { ConfirmationInterfaceKey, ContextWithPrices } from './api'; +import { ConfirmationInterfaceKey, FetchStatus } from './api'; +import type { ContextWithPrices } from './api'; import { formatFeeData, formatOrigin, @@ -74,10 +74,10 @@ type RenderConfirmationDialogCommon = { }; type ConfirmationDialogWithFee = - | ConfirmationInterfaceKey.SignTransaction - | ConfirmationInterfaceKey.ChangeTrustlineOptIn - | ConfirmationInterfaceKey.ChangeTrustlineOptOut - | ConfirmationInterfaceKey.ConfirmSendTransaction; + | typeof ConfirmationInterfaceKey.SignTransaction + | typeof ConfirmationInterfaceKey.ChangeTrustlineOptIn + | typeof ConfirmationInterfaceKey.ChangeTrustlineOptOut + | typeof ConfirmationInterfaceKey.ConfirmSendTransaction; /** * Discriminated union: confirmations that have a fee (example: sign transaction) * MUST provide one; fee-less confirmations (sign message, etc.) MUST NOT. diff --git a/packages/stellar-wallet-snap/src/ui/confirmation/utils.ts b/packages/stellar-wallet-snap/src/ui/confirmation/utils.ts index 901db6057..612254f2e 100644 --- a/packages/stellar-wallet-snap/src/ui/confirmation/utils.ts +++ b/packages/stellar-wallet-snap/src/ui/confirmation/utils.ts @@ -298,11 +298,14 @@ export function shouldDisableConfirmation(params: { * The transaction-validation banner and the Blockaid scan banner are mutually * exclusive: only one is ever rendered, and validation takes priority. */ -export enum ConfirmationBanner { - None = 'none', - TransactionValidation = 'transaction-validation', - TransactionScan = 'transaction-scan', -} +export const ConfirmationBanner = { + None: 'none', + TransactionValidation: 'transaction-validation', + TransactionScan: 'transaction-scan', +} as const; + +export type ConfirmationBanner = + (typeof ConfirmationBanner)[keyof typeof ConfirmationBanner]; /** * Resolves which top-of-screen banner the confirmation should display. diff --git a/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSendTransaction/events.tsx b/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSendTransaction/events.tsx index 9506d178c..64408e299 100644 --- a/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSendTransaction/events.tsx +++ b/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSendTransaction/events.tsx @@ -30,10 +30,13 @@ async function onConfirmButtonClick( await resolveInterface(id, true); } -export enum ConfirmSendTransactionFormNames { - Cancel = 'confirm-send-transaction-cancel', - Confirm = 'confirm-send-transaction-confirm', -} +export const ConfirmSendTransactionFormNames = { + Cancel: 'confirm-send-transaction-cancel', + Confirm: 'confirm-send-transaction-confirm', +} as const; + +export type ConfirmSendTransactionFormNames = + (typeof ConfirmSendTransactionFormNames)[keyof typeof ConfirmSendTransactionFormNames]; /** * Create event handlers bound to a SnapClient instance. diff --git a/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignAuthEntry/events.tsx b/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignAuthEntry/events.tsx index 8e7e0b10b..ad6a18886 100644 --- a/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignAuthEntry/events.tsx +++ b/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignAuthEntry/events.tsx @@ -30,10 +30,13 @@ async function onConfirmButtonClick( await resolveInterface(id, true); } -export enum ConfirmSignAuthEntryFormNames { - Cancel = 'confirm-sign-auth-entry-cancel', - Confirm = 'confirm-sign-auth-entry-confirm', -} +export const ConfirmSignAuthEntryFormNames = { + Cancel: 'confirm-sign-auth-entry-cancel', + Confirm: 'confirm-sign-auth-entry-confirm', +} as const; + +export type ConfirmSignAuthEntryFormNames = + (typeof ConfirmSignAuthEntryFormNames)[keyof typeof ConfirmSignAuthEntryFormNames]; /** * Create event handlers bound to a SnapClient instance. diff --git a/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignChangeTrustOptIn/events.tsx b/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignChangeTrustOptIn/events.tsx index 9d2ff861a..14ee52a74 100644 --- a/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignChangeTrustOptIn/events.tsx +++ b/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignChangeTrustOptIn/events.tsx @@ -30,10 +30,13 @@ async function onConfirmButtonClick( await resolveInterface(id, true); } -export enum ConfirmSignChangeTrustOptInFormNames { - Cancel = 'confirm-sign-change-trust-opt-in-cancel', - Confirm = 'confirm-sign-change-trust-opt-in-confirm', -} +export const ConfirmSignChangeTrustOptInFormNames = { + Cancel: 'confirm-sign-change-trust-opt-in-cancel', + Confirm: 'confirm-sign-change-trust-opt-in-confirm', +} as const; + +export type ConfirmSignChangeTrustOptInFormNames = + (typeof ConfirmSignChangeTrustOptInFormNames)[keyof typeof ConfirmSignChangeTrustOptInFormNames]; /** * Create event handlers bound to a SnapClient instance. diff --git a/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignChangeTrustOptOut/events.tsx b/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignChangeTrustOptOut/events.tsx index 213170596..3286501f3 100644 --- a/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignChangeTrustOptOut/events.tsx +++ b/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignChangeTrustOptOut/events.tsx @@ -30,10 +30,13 @@ async function onConfirmButtonClick( await resolveInterface(id, true); } -export enum ConfirmSignChangeTrustOptOutFormNames { - Cancel = 'confirm-sign-change-trust-opt-out-cancel', - Confirm = 'confirm-sign-change-trust-opt-out-confirm', -} +export const ConfirmSignChangeTrustOptOutFormNames = { + Cancel: 'confirm-sign-change-trust-opt-out-cancel', + Confirm: 'confirm-sign-change-trust-opt-out-confirm', +} as const; + +export type ConfirmSignChangeTrustOptOutFormNames = + (typeof ConfirmSignChangeTrustOptOutFormNames)[keyof typeof ConfirmSignChangeTrustOptOutFormNames]; /** * Create event handlers bound to a SnapClient instance. diff --git a/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignMessage/events.tsx b/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignMessage/events.tsx index 127eae459..924323c9c 100644 --- a/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignMessage/events.tsx +++ b/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignMessage/events.tsx @@ -30,10 +30,13 @@ async function onConfirmButtonClick( await resolveInterface(id, true); } -export enum ConfirmSignMessageFormNames { - Cancel = 'confirm-sign-message-cancel', - Confirm = 'confirm-sign-message-confirm', -} +export const ConfirmSignMessageFormNames = { + Cancel: 'confirm-sign-message-cancel', + Confirm: 'confirm-sign-message-confirm', +} as const; + +export type ConfirmSignMessageFormNames = + (typeof ConfirmSignMessageFormNames)[keyof typeof ConfirmSignMessageFormNames]; /** * Create event handlers bound to a SnapClient instance. diff --git a/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignTransaction/events.tsx b/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignTransaction/events.tsx index 9a32db64d..8b8b4b736 100644 --- a/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignTransaction/events.tsx +++ b/packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignTransaction/events.tsx @@ -30,10 +30,13 @@ async function onConfirmButtonClick( await resolveInterface(id, true); } -export enum ConfirmSignTransactionFormNames { - Cancel = 'confirm-sign-transaction-cancel', - Confirm = 'confirm-sign-transaction-confirm', -} +export const ConfirmSignTransactionFormNames = { + Cancel: 'confirm-sign-transaction-cancel', + Confirm: 'confirm-sign-transaction-confirm', +} as const; + +export type ConfirmSignTransactionFormNames = + (typeof ConfirmSignTransactionFormNames)[keyof typeof ConfirmSignTransactionFormNames]; /** * Create event handlers bound to a SnapClient instance. diff --git a/packages/stellar-wallet-snap/src/ui/confirmation/views/MaliciousAcknowledgement/constants.ts b/packages/stellar-wallet-snap/src/ui/confirmation/views/MaliciousAcknowledgement/constants.ts index 949b9bc51..2485936e0 100644 --- a/packages/stellar-wallet-snap/src/ui/confirmation/views/MaliciousAcknowledgement/constants.ts +++ b/packages/stellar-wallet-snap/src/ui/confirmation/views/MaliciousAcknowledgement/constants.ts @@ -4,9 +4,12 @@ * The screen is reused across every scanned confirmation flow, so these names * live in one place and are handled by a single set of event handlers. */ -export enum MaliciousAcknowledgementFormNames { - Review = 'malicious-acknowledgement-review', - Acknowledge = 'malicious-acknowledgement-checkbox', - Proceed = 'malicious-acknowledgement-proceed', - Back = 'malicious-acknowledgement-back', -} +export const MaliciousAcknowledgementFormNames = { + Review: 'malicious-acknowledgement-review', + Acknowledge: 'malicious-acknowledgement-checkbox', + Proceed: 'malicious-acknowledgement-proceed', + Back: 'malicious-acknowledgement-back', +} as const; + +export type MaliciousAcknowledgementFormNames = + (typeof MaliciousAcknowledgementFormNames)[keyof typeof MaliciousAcknowledgementFormNames]; diff --git a/packages/stellar-wallet-snap/src/utils/snap.ts b/packages/stellar-wallet-snap/src/utils/snap.ts index 126366ed3..89ad2c127 100644 --- a/packages/stellar-wallet-snap/src/utils/snap.ts +++ b/packages/stellar-wallet-snap/src/utils/snap.ts @@ -19,37 +19,45 @@ import { logger } from './logger'; import { serialize, deserialize } from './serialization'; import type { Serializable } from './serialization'; -export enum Duration { - OneSecond = 'PT1S', - TwoSeconds = 'PT2S', - FiveSeconds = 'PT5S', - TwentySeconds = 'PT20S', - ThirtySeconds = 'PT30S', - OneMinute = 'PT1M', - FiveMinutes = 'PT5M', - TenMinutes = 'PT10M', - ThirtyMinutes = 'PT30M', - OneHour = 'PT1H', -} +export const Duration = { + OneSecond: 'PT1S', + TwoSeconds: 'PT2S', + FiveSeconds: 'PT5S', + TwentySeconds: 'PT20S', + ThirtySeconds: 'PT30S', + OneMinute: 'PT1M', + FiveMinutes: 'PT5M', + TenMinutes: 'PT10M', + ThirtyMinutes: 'PT30M', + OneHour: 'PT1H', +} as const; + +export type Duration = (typeof Duration)[keyof typeof Duration]; /** * Enum for transaction tracking event types. */ -export enum TransactionEventType { - TransactionAdded = 'Transaction Added', - TransactionRejected = 'Transaction Rejected', - TransactionApproved = 'Transaction Approved', - TransactionSubmitted = 'Transaction Submitted', - TransactionFinalized = 'Transaction Finalized', -} +export const TransactionEventType = { + TransactionAdded: 'Transaction Added', + TransactionRejected: 'Transaction Rejected', + TransactionApproved: 'Transaction Approved', + TransactionSubmitted: 'Transaction Submitted', + TransactionFinalized: 'Transaction Finalized', +} as const; + +export type TransactionEventType = + (typeof TransactionEventType)[keyof typeof TransactionEventType]; /** * Enum for security alert tracking event types. */ -export enum SecurityEventType { - SecurityAlertDetected = 'Security Alert Detected', - SecurityScanCompleted = 'Security Scan Completed', -} +export const SecurityEventType = { + SecurityAlertDetected: 'Security Alert Detected', + SecurityScanCompleted: 'Security Scan Completed', +} as const; + +export type SecurityEventType = + (typeof SecurityEventType)[keyof typeof SecurityEventType]; /** * Returns the Snap provider. From 521475b32bcc009b2d30ca00b07957fe32070a9e Mon Sep 17 00:00:00 2001 From: Ulisses Ferreira Date: Fri, 28 Aug 2026 11:01:02 +0100 Subject: [PATCH 2/2] chore(stellar-wallet-snap): update snap manifest shasum --- packages/stellar-wallet-snap/snap.manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stellar-wallet-snap/snap.manifest.json b/packages/stellar-wallet-snap/snap.manifest.json index 551994fa7..6683b258f 100644 --- a/packages/stellar-wallet-snap/snap.manifest.json +++ b/packages/stellar-wallet-snap/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/internal-snaps.git" }, "source": { - "shasum": "i8XzrvzKRiP6L8dp7cr7LVqprs3sX5rOs8JJ59VQyoo=", + "shasum": "caN9ku7+kU6FA935tMmSPElKb+qOqHvnG/drqSdfMv0=", "location": { "npm": { "filePath": "dist/bundle.js",