@metamask-previews/money-account-upgrade-controller 3.0.2-preview-00a181c → 3.0.2-preview-cfd35b8dd
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 +11 -0
- package/dist/MoneyAccountUpgradeController-method-action-types.cjs.map +1 -1
- package/dist/MoneyAccountUpgradeController-method-action-types.d.cts +4 -0
- package/dist/MoneyAccountUpgradeController-method-action-types.d.cts.map +1 -1
- package/dist/MoneyAccountUpgradeController-method-action-types.d.mts +4 -0
- package/dist/MoneyAccountUpgradeController-method-action-types.d.mts.map +1 -1
- package/dist/MoneyAccountUpgradeController-method-action-types.mjs.map +1 -1
- package/dist/MoneyAccountUpgradeController.cjs +194 -40
- package/dist/MoneyAccountUpgradeController.cjs.map +1 -1
- package/dist/MoneyAccountUpgradeController.d.cts +90 -18
- package/dist/MoneyAccountUpgradeController.d.cts.map +1 -1
- package/dist/MoneyAccountUpgradeController.d.mts +90 -18
- package/dist/MoneyAccountUpgradeController.d.mts.map +1 -1
- package/dist/MoneyAccountUpgradeController.mjs +195 -41
- package/dist/MoneyAccountUpgradeController.mjs.map +1 -1
- package/dist/errors.cjs +13 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +8 -0
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts +8 -0
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +11 -0
- package/dist/errors.mjs.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoneyAccountUpgradeController.mjs","sourceRoot":"","sources":["../src/MoneyAccountUpgradeController.ts"],"names":[],"mappings":";;;;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MAAM,CAAC,gBAAgB;QACvB,MAAM,CAAC,kBAAkB;QACzB,MAAM,CAAC,uBAAuB;QAC9B,MAAM,CAAC,oBAAoB;QAC3B,MAAM,CAAC,2BAA2B;QAClC,MAAM,CAAC,gBAAgB;QACvB,MAAM,CAAC,gBAAgB;KACxB;SACE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;SACnC,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC","sourcesContent":["import type {\n AuthenticatedUserStorageServiceCreateDelegationAction,\n AuthenticatedUserStorageServiceListDelegationsAction,\n} from '@metamask/authenticated-user-storage';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangedEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type {\n ChompApiServiceAssociateAddressAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceCreateUpgradeAction,\n ChompApiServiceGetAssociatedAddressesAction,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceGetServiceDetailsAction,\n ChompApiServiceVerifyDelegationAction,\n} from '@metamask/chomp-api-service';\nimport type { DelegationControllerSignDelegationAction } from '@metamask/delegation-controller';\nimport { DELEGATOR_CONTRACTS } from '@metamask/delegation-deployments';\nimport type {\n KeyringControllerSignEip7702AuthorizationAction,\n KeyringControllerSignPersonalMessageAction,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n} from '@metamask/network-controller';\nimport { hexToNumber } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { MoneyAccountUpgradeStepError } from './errors.js';\nimport type { MoneyAccountUpgradeControllerMethodActions } from './MoneyAccountUpgradeController-method-action-types.js';\nimport { associateAddressStep } from './steps/associate-address.js';\nimport { buildDelegationStep } from './steps/build-delegations.js';\nimport { eip7702AuthorizationStep } from './steps/eip-7702-authorization.js';\nimport { registerIntentsStep } from './steps/register-intents.js';\nimport type { Step } from './steps/step.js';\nimport type { UpgradeConfig } from './types.js';\n\n/**\n * The Delegation Framework deployment version we resolve contract addresses\n * against in `@metamask/delegation-deployments`.\n */\nconst DELEGATION_FRAMEWORK_VERSION = '1.3.0';\n\nexport const controllerName = 'MoneyAccountUpgradeController';\n\n/**\n * Record of a Money Account upgrade sequence that ran to completion.\n */\nexport type MoneyAccountUpgradeStatus = {\n /**\n * Fingerprint of the upgrade config the sequence completed under. The\n * record is only trusted while the active config produces the same\n * fingerprint — if the chain, CHOMP contracts, or Delegation Framework\n * version change, the sequence re-runs.\n */\n configFingerprint: string;\n /** Unix timestamp (in milliseconds) when the sequence completed. */\n completedAt: number;\n};\n\nexport type MoneyAccountUpgradeControllerState = {\n /**\n * Accounts whose upgrade sequence has fully completed, keyed by lowercased\n * account address.\n */\n upgradedAccounts: { [address: Hex]: MoneyAccountUpgradeStatus };\n};\n\nconst moneyAccountUpgradeControllerMetadata = {\n upgradedAccounts: {\n includeInDebugSnapshot: false,\n includeInStateLogs: false,\n persist: true,\n usedInUi: false,\n },\n} satisfies StateMetadata<MoneyAccountUpgradeControllerState>;\n\n/**\n * Constructs the default {@link MoneyAccountUpgradeController} state. This\n * allows consumers to provide a partial state object when initializing the\n * controller and also helps in constructing complete state objects for this\n * controller in tests.\n *\n * @returns The default {@link MoneyAccountUpgradeController} state.\n */\nexport function getDefaultMoneyAccountUpgradeControllerState(): MoneyAccountUpgradeControllerState {\n return {\n upgradedAccounts: {},\n };\n}\n\nconst MESSENGER_EXPOSED_METHODS = ['upgradeAccount'] as const;\n\nexport type MoneyAccountUpgradeControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n MoneyAccountUpgradeControllerState\n >;\n\nexport type MoneyAccountUpgradeControllerActions =\n | MoneyAccountUpgradeControllerGetStateAction\n | MoneyAccountUpgradeControllerMethodActions;\n\ntype AllowedActions =\n | AuthenticatedUserStorageServiceCreateDelegationAction\n | AuthenticatedUserStorageServiceListDelegationsAction\n | ChompApiServiceAssociateAddressAction\n | ChompApiServiceCreateIntentsAction\n | ChompApiServiceCreateUpgradeAction\n | ChompApiServiceGetAssociatedAddressesAction\n | ChompApiServiceGetIntentsByAddressAction\n | ChompApiServiceGetServiceDetailsAction\n | ChompApiServiceVerifyDelegationAction\n | DelegationControllerSignDelegationAction\n | KeyringControllerSignEip7702AuthorizationAction\n | KeyringControllerSignPersonalMessageAction\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetNetworkClientByIdAction;\n\nexport type MoneyAccountUpgradeControllerStateChangedEvent =\n ControllerStateChangedEvent<\n typeof controllerName,\n MoneyAccountUpgradeControllerState\n >;\n\nexport type MoneyAccountUpgradeControllerEvents =\n MoneyAccountUpgradeControllerStateChangedEvent;\n\ntype AllowedEvents = never;\n\nexport type MoneyAccountUpgradeControllerMessenger = Messenger<\n typeof controllerName,\n MoneyAccountUpgradeControllerActions | AllowedActions,\n MoneyAccountUpgradeControllerEvents | AllowedEvents\n>;\n\n/**\n * Controller that orchestrates the Money Account upgrade sequence.\n */\nexport class MoneyAccountUpgradeController extends BaseController<\n typeof controllerName,\n MoneyAccountUpgradeControllerState,\n MoneyAccountUpgradeControllerMessenger\n> {\n #config?: UpgradeConfig & { chainId: Hex };\n\n readonly #steps: Step[] = [\n associateAddressStep,\n eip7702AuthorizationStep,\n buildDelegationStep,\n registerIntentsStep,\n ];\n\n /**\n * Constructor for the MoneyAccountUpgradeController.\n *\n * @param options - The options for constructing the controller.\n * @param options.messenger - The messenger to use for inter-controller communication.\n * @param options.state - The initial state, merged with the defaults.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: MoneyAccountUpgradeControllerMessenger;\n state?: Partial<MoneyAccountUpgradeControllerState>;\n }) {\n super({\n messenger,\n metadata: moneyAccountUpgradeControllerMetadata,\n name: controllerName,\n state: {\n ...getDefaultMoneyAccountUpgradeControllerState(),\n ...state,\n },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Fetches service details and validates the controller can operate on the\n * given chain. Resolves the Delegation Framework contract addresses for the\n * chain from `@metamask/delegation-deployments`.\n *\n * @param params - The parameters for initialization.\n * @param params.chainId - The chain to initialize for.\n * @param params.boringVaultAddress - The Veda boring vault contract\n * (vmUSD) for the given chain. Used as the withdrawal-side delegation\n * token. Supplied by the consumer until the CHOMP service-details API\n * exposes it.\n */\n async init({\n chainId,\n boringVaultAddress,\n }: {\n chainId: Hex;\n boringVaultAddress: Hex;\n }): Promise<void> {\n const contracts =\n DELEGATOR_CONTRACTS[DELEGATION_FRAMEWORK_VERSION][hexToNumber(chainId)];\n if (!contracts) {\n throw new Error(\n `Delegation Framework ${DELEGATION_FRAMEWORK_VERSION} is not deployed on chain ${chainId}`,\n );\n }\n\n const response = await this.messenger.call(\n 'ChompApiService:getServiceDetails',\n [chainId],\n );\n\n const chain = response.chains[chainId];\n if (!chain) {\n throw new Error(`Chain ${chainId} not found in service details response`);\n }\n\n const { vedaProtocol } = chain.protocol;\n if (!vedaProtocol) {\n throw new Error(\n `vedaProtocol not found for chain ${chainId} in service details response`,\n );\n }\n\n if (vedaProtocol.supportedTokens.length === 0) {\n throw new Error(\n `No supported tokens found for vedaProtocol on chain ${chainId}`,\n );\n }\n\n this.#config = {\n chainId,\n delegateAddress: chain.autoDepositDelegate,\n musdTokenAddress: vedaProtocol.supportedTokens[0].tokenAddress,\n boringVaultAddress,\n vedaVaultAdapterAddress: vedaProtocol.adapterAddress,\n delegatorImplAddress: contracts.EIP7702StatelessDeleGatorImpl,\n erc20TransferAmountEnforcer: contracts.ERC20TransferAmountEnforcer,\n redeemerEnforcer: contracts.RedeemerEnforcer,\n valueLteEnforcer: contracts.ValueLteEnforcer,\n };\n }\n\n /**\n * Runs each step in the upgrade sequence in order. A step that reports\n * `'already-done'` is skipped without performing any action; a step that\n * reports `'completed'` has performed its action. An error thrown by any\n * step halts the sequence and is re-thrown wrapped in a\n * {@link MoneyAccountUpgradeStepError} that records which step failed (the\n * original error is preserved as `cause`).\n *\n * A run that completes is recorded in state (keyed by lowercased address,\n * fingerprinted against the active config); subsequent calls for a\n * recorded account return immediately without running any steps. If the\n * active config no longer matches the recorded fingerprint, the sequence\n * re-runs.\n *\n * @param address - The Money Account address to upgrade.\n */\n async upgradeAccount(address: Hex): Promise<void> {\n if (!this.#config) {\n throw new Error(\n 'MoneyAccountUpgradeController must be initialized via init() before upgradeAccount() can be called',\n );\n }\n const config = this.#config;\n\n const accountKey = address.toLowerCase() as Hex;\n const configFingerprint = computeConfigFingerprint(config);\n if (\n this.state.upgradedAccounts[accountKey]?.configFingerprint ===\n configFingerprint\n ) {\n return;\n }\n\n for (const step of this.#steps) {\n try {\n await step.run({\n messenger: this.messenger,\n address,\n ...config,\n });\n } catch (error) {\n throw new MoneyAccountUpgradeStepError(step.name, error);\n }\n }\n\n this.update((state) => {\n state.upgradedAccounts[accountKey] = {\n configFingerprint,\n completedAt: Date.now(),\n };\n });\n }\n}\n\n/**\n * Derives a stable fingerprint of the config fields that define what\n * \"upgraded\" means for an account. A recorded upgrade is only trusted while\n * the active config produces the same fingerprint.\n *\n * @param config - The active upgrade config.\n * @returns A canonical string over the config's identifying fields.\n */\nfunction computeConfigFingerprint(\n config: UpgradeConfig & { chainId: Hex },\n): string {\n return [\n DELEGATION_FRAMEWORK_VERSION,\n config.chainId,\n config.delegateAddress,\n config.musdTokenAddress,\n config.boringVaultAddress,\n config.vedaVaultAdapterAddress,\n config.delegatorImplAddress,\n config.erc20TransferAmountEnforcer,\n config.redeemerEnforcer,\n config.valueLteEnforcer,\n ]\n .map((value) => value.toLowerCase())\n .join('|');\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MoneyAccountUpgradeController.mjs","sourceRoot":"","sources":["../src/MoneyAccountUpgradeController.ts"],"names":[],"mappings":";;;;;;;;;;;;AASA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAW3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AC,CAAC;AACf,CAAC","sourcesContent":["import type {\n AuthenticatedUserStorageServiceCreateDelegationAction,\n AuthenticatedUserStorageServiceListDelegationsAction,\n} from '@metamask/authenticated-user-storage';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangedEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type {\n ChompApiServiceAssociateAddressAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceCreateUpgradeAction,\n ChompApiServiceGetAssociatedAddressesAction,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceGetServiceDetailsAction,\n ChompApiServiceVerifyDelegationAction,\n} from '@metamask/chomp-api-service';\nimport type { DelegationControllerSignDelegationAction } from '@metamask/delegation-controller';\nimport { DELEGATOR_CONTRACTS } from '@metamask/delegation-deployments';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerSignEip7702AuthorizationAction,\n KeyringControllerSignPersonalMessageAction,\n KeyringControllerState,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport {\n areMoneyAccountVaultConfigsEqual,\n getMoneyAccountVaultConfig,\n} from '@metamask/money-account-utils';\nimport type { MoneyAccountVaultConfig } from '@metamask/money-account-utils';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n} from '@metamask/network-controller';\nimport type {\n FeatureFlags,\n RemoteFeatureFlagControllerGetStateAction,\n RemoteFeatureFlagControllerState,\n} from '@metamask/remote-feature-flag-controller';\nimport { hexToNumber } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\nimport {\n MissingMoneyAccountVaultConfigError,\n MoneyAccountUpgradeStepError,\n} from './errors.js';\nimport type { MoneyAccountUpgradeControllerMethodActions } from './MoneyAccountUpgradeController-method-action-types.js';\nimport { associateAddressStep } from './steps/associate-address.js';\nimport { buildDelegationStep } from './steps/build-delegations.js';\nimport { eip7702AuthorizationStep } from './steps/eip-7702-authorization.js';\nimport { registerIntentsStep } from './steps/register-intents.js';\nimport type { Step } from './steps/step.js';\nimport type { UpgradeConfig } from './types.js';\n\n/**\n * The Delegation Framework deployment version we resolve contract addresses\n * against in `@metamask/delegation-deployments`.\n */\nconst DELEGATION_FRAMEWORK_VERSION = '1.3.0';\n\nexport const controllerName = 'MoneyAccountUpgradeController';\n\n/**\n * Record of a Money Account upgrade sequence that ran to completion.\n */\nexport type MoneyAccountUpgradeStatus = {\n /**\n * Fingerprint of the upgrade config the sequence completed under. The\n * record is only trusted while the active config produces the same\n * fingerprint — if the chain, CHOMP contracts, or Delegation Framework\n * version change, the sequence re-runs.\n */\n configFingerprint: string;\n /** Unix timestamp (in milliseconds) when the sequence completed. */\n completedAt: number;\n};\n\nexport type MoneyAccountUpgradeControllerState = {\n /**\n * Accounts whose upgrade sequence has fully completed, keyed by lowercased\n * account address.\n */\n upgradedAccounts: { [address: Hex]: MoneyAccountUpgradeStatus };\n};\n\nconst moneyAccountUpgradeControllerMetadata = {\n upgradedAccounts: {\n includeInDebugSnapshot: false,\n includeInStateLogs: false,\n persist: true,\n usedInUi: false,\n },\n} satisfies StateMetadata<MoneyAccountUpgradeControllerState>;\n\n/**\n * Constructs the default {@link MoneyAccountUpgradeController} state. This\n * allows consumers to provide a partial state object when initializing the\n * controller and also helps in constructing complete state objects for this\n * controller in tests.\n *\n * @returns The default {@link MoneyAccountUpgradeController} state.\n */\nexport function getDefaultMoneyAccountUpgradeControllerState(): MoneyAccountUpgradeControllerState {\n return {\n upgradedAccounts: {},\n };\n}\n\nconst MESSENGER_EXPOSED_METHODS = ['upgradeAccount'] as const;\n\nexport type MoneyAccountUpgradeControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n MoneyAccountUpgradeControllerState\n >;\n\nexport type MoneyAccountUpgradeControllerActions =\n | MoneyAccountUpgradeControllerGetStateAction\n | MoneyAccountUpgradeControllerMethodActions;\n\ntype AllowedActions =\n | AuthenticatedUserStorageServiceCreateDelegationAction\n | AuthenticatedUserStorageServiceListDelegationsAction\n | ChompApiServiceAssociateAddressAction\n | ChompApiServiceCreateIntentsAction\n | ChompApiServiceCreateUpgradeAction\n | ChompApiServiceGetAssociatedAddressesAction\n | ChompApiServiceGetIntentsByAddressAction\n | ChompApiServiceGetServiceDetailsAction\n | ChompApiServiceVerifyDelegationAction\n | DelegationControllerSignDelegationAction\n | KeyringControllerGetStateAction\n | KeyringControllerSignEip7702AuthorizationAction\n | KeyringControllerSignPersonalMessageAction\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetNetworkClientByIdAction\n | RemoteFeatureFlagControllerGetStateAction;\n\nexport type MoneyAccountUpgradeControllerStateChangedEvent =\n ControllerStateChangedEvent<\n typeof controllerName,\n MoneyAccountUpgradeControllerState\n >;\n\nexport type MoneyAccountUpgradeControllerEvents =\n MoneyAccountUpgradeControllerStateChangedEvent;\n\ntype AllowedEvents =\n | ControllerStateChangedEvent<'KeyringController', KeyringControllerState>\n | ControllerStateChangedEvent<\n 'RemoteFeatureFlagController',\n RemoteFeatureFlagControllerState\n >;\n\nexport type MoneyAccountUpgradeControllerMessenger = Messenger<\n typeof controllerName,\n MoneyAccountUpgradeControllerActions | AllowedActions,\n MoneyAccountUpgradeControllerEvents | AllowedEvents\n>;\n\n/**\n * These hooks must be provided by the client - they provide functions that required to bootstrap\n * the controller, which rely on client specific information.\n */\nexport type MoneyAccountUpgradeControllerHooks = {\n /**\n * Whether the Money Account feature is enabled for this client.\n *\n * The controller will call the function with the current state of\n * the remote feature flags. It gets caleld on every sync, and re-checked\n * when the bootstrap `awaits`.\n *\n * The isEnabled function should re-read any client state it depends\n * on (e.g. a version-gated flag, a \"basic functionality\" toggle) rather\n * than caching it. Returning `false` after a successful bootstrap disarms\n * the controller: `upgradeAccount` refuses to run until a later sync\n * re-bootstraps.\n */\n isEnabled: (remoteFeatureFlags: FeatureFlags) => boolean;\n\n /**\n * An asynchronous client gate checked once per bootstrap run, before any\n * network is added or external service is called — e.g. a fail-closed\n * geolocation check. A run skipped here is forgotten and retried on the\n * next sync trigger. If the function is not provided we assume the client is eligible.\n */\n isEligible?: () => Promise<boolean>;\n\n /**\n * Ensure the vault chain exists in the client's NetworkController before\n * the bootstrap validates it. Adding a network is client-specific, so\n * the controller awaits this before calling\n * `NetworkController:findNetworkClientIdByChainId` consumers. Defaults to a\n * no-op.\n */\n ensureChainConfigured?: (\n vaultConfig: MoneyAccountVaultConfig,\n ) => Promise<void>;\n\n /**\n * Called when a bootstrap run fails or cannot be scheduled. Receives a\n * {@link MissingMoneyAccountVaultConfigError} (once per controller\n * lifetime) when the enable flag is on but `moneyAccountVaultConfig` is\n * unserved or malformed.\n */\n onBootstrapError?: (error: unknown) => void;\n};\n\n/**\n * Controller that owns the Money Account upgrade sequence and its own\n * bootstrap.\n *\n * After {@link MoneyAccountUpgradeController.init} is called, the controller watches\n * `RemoteFeatureFlagController` and `KeyringController` state and bootstraps\n * itself when:\n *\n * 1. the client's `isEnabled` hook returns `true` for the current flags,\n * 2. the wallet is unlocked with an HD keyring,\n * 3. the client's `isEligible` hook (if any) resolves `true`, and\n * 4. the `moneyAccountVaultConfig` flag parses.\n *\n * The bootstrap awaits the client's `ensureChainConfigured` hook and then\n * fetches CHOMP service details to get the upgrade config. We recheck points\n * 1–2 when awaiting in the bootstrap so a lock or an `isEnabled` will stop the process.\n *\n * The bootstrap re-runs whenever the vault config changes.\n * `isEnabled` going `false` disables the controller.\n */\nexport class MoneyAccountUpgradeController extends BaseController<\n typeof controllerName,\n MoneyAccountUpgradeControllerState,\n MoneyAccountUpgradeControllerMessenger\n> {\n #config?: UpgradeConfig & { chainId: Hex };\n\n readonly #isEnabled: MoneyAccountUpgradeControllerHooks['isEnabled'];\n\n readonly #isEligible: NonNullable<\n MoneyAccountUpgradeControllerHooks['isEligible']\n >;\n\n readonly #ensureChainConfigured: NonNullable<\n MoneyAccountUpgradeControllerHooks['ensureChainConfigured']\n >;\n\n readonly #onBootstrapError: NonNullable<\n MoneyAccountUpgradeControllerHooks['onBootstrapError']\n >;\n\n #initialized = false;\n\n #bootstrap?: Promise<void>;\n\n #bootstrappedConfig?: MoneyAccountVaultConfig;\n\n #missingConfigReported = false;\n\n readonly #steps: Step[] = [\n associateAddressStep,\n eip7702AuthorizationStep,\n buildDelegationStep,\n registerIntentsStep,\n ];\n\n /**\n * Constructor for the MoneyAccountUpgradeController.\n *\n * @param options - The options for constructing the controller.\n * @param options.messenger - The messenger to use for inter-controller communication.\n * @param options.state - The initial state, merged with the defaults.\n * @param options.hooks - The client hooks for the bootstrap; see\n * {@link MoneyAccountUpgradeControllerHooks}.\n */\n constructor({\n messenger,\n state,\n hooks,\n }: {\n messenger: MoneyAccountUpgradeControllerMessenger;\n state?: Partial<MoneyAccountUpgradeControllerState>;\n hooks: MoneyAccountUpgradeControllerHooks;\n }) {\n super({\n messenger,\n metadata: moneyAccountUpgradeControllerMetadata,\n name: controllerName,\n state: {\n ...getDefaultMoneyAccountUpgradeControllerState(),\n ...state,\n },\n });\n\n this.#isEnabled = hooks.isEnabled;\n this.#isEligible = hooks.isEligible ?? (async (): Promise<boolean> => true);\n this.#ensureChainConfigured =\n hooks.ensureChainConfigured ?? (async (): Promise<void> => undefined);\n this.#onBootstrapError = hooks.onBootstrapError ?? ((): void => undefined);\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Start the controller's bootstrap: subscribe to the feature-flag and\n * keyring triggers and run an initial sync. Call once, after all\n * controllers and services the messenger reaches are constructed — this is\n * the only method that may be called before the controller is bootstrapped,\n * and it is the reason the constructor performs no messenger calls.\n */\n init(): void {\n if (this.#initialized) {\n return;\n }\n this.#initialized = true;\n\n this.messenger.subscribe('RemoteFeatureFlagController:stateChanged', () =>\n this.sync(),\n );\n this.messenger.subscribe('KeyringController:stateChanged', () =>\n this.sync(),\n );\n this.sync();\n }\n\n /**\n * Re-evaluate the bootstrap checks against live state and schedule a\n * bootstrap run when they are open and the vault config is new. Runs on\n * every feature-flag and keyring state change.\n *\n * If sync fails a failure is reported through `onBootstrapError` and retried\n * on the next trigger.\n */\n sync(): void {\n try {\n const { remoteFeatureFlags } = this.messenger.call(\n 'RemoteFeatureFlagController:getState',\n );\n\n if (!this.#isEnabled(remoteFeatureFlags)) {\n // Disarm so a later `upgradeAccount` cannot run against a config\n // armed while the feature was still enabled. Re-enabling re-runs the\n // bootstrap from scratch.\n this.#config = undefined;\n this.#bootstrappedConfig = undefined;\n return;\n }\n\n if (!this.#isWalletReady()) {\n return;\n }\n\n const vaultConfig = getMoneyAccountVaultConfig(remoteFeatureFlags);\n if (!vaultConfig) {\n this.#reportMissingConfig();\n return;\n }\n\n if (\n this.#bootstrappedConfig &&\n areMoneyAccountVaultConfigsEqual(vaultConfig, this.#bootstrappedConfig)\n ) {\n return;\n }\n\n this.#scheduleBootstrap(vaultConfig);\n } catch (error) {\n this.#onBootstrapError(error);\n }\n }\n\n /**\n * Whether the wallet can sign right now: unlocked with an HD keyring. The\n * keyring list matters because during a vault restore the unlock flips\n * before the keyrings land in state.\n *\n * @returns Whether the wallet is ready.\n */\n #isWalletReady(): boolean {\n const { isUnlocked, keyrings } = this.messenger.call(\n 'KeyringController:getState',\n );\n return (\n isUnlocked && keyrings.some((keyring) => keyring.type === KeyringTypes.hd)\n );\n }\n\n /**\n * Whether the synchronous bootstrap gates are open right now. Re-read from\n * live state on every call because the bootstrap re-validates them across\n * its `await` points.\n *\n * @returns Whether the bootstrap may proceed.\n */\n #areGatesOpen(): boolean {\n const { remoteFeatureFlags } = this.messenger.call(\n 'RemoteFeatureFlagController:getState',\n );\n return this.#isEnabled(remoteFeatureFlags) && this.#isWalletReady();\n }\n\n #scheduleBootstrap(vaultConfig: MoneyAccountVaultConfig): void {\n this.#bootstrappedConfig = vaultConfig;\n\n // Scheduling means the served vault config no longer matches whatever is\n // armed, so disarm now: until this run succeeds, `upgradeAccount` must\n // wait for it (or refuse if it fails) rather than sign delegations\n // against the superseded vault.\n this.#config = undefined;\n\n const run = async (): Promise<void> => {\n // The gates were checked when this run was scheduled, but it may start\n // much later, chained behind an in-flight bootstrap. Eligibility comes\n // after the gates so a disabled client also skips the (possibly\n // external) eligibility lookup.\n if (!this.#areGatesOpen() || !(await this.#isEligible())) {\n this.#forget(vaultConfig);\n return;\n }\n\n await this.#ensureChainConfigured(vaultConfig);\n\n // Configuring the chain can suspend for a while, so re-check the gates\n // before the external CHOMP call.\n if (!this.#areGatesOpen()) {\n this.#forget(vaultConfig);\n return;\n }\n\n await this.#applyVaultConfig(vaultConfig);\n };\n\n const bootstrap = this.#bootstrap\n ? this.#bootstrap.catch(() => undefined).then(run)\n : run();\n this.#bootstrap = bootstrap;\n\n bootstrap.catch((error) => {\n this.#onBootstrapError(error);\n this.#forget(vaultConfig);\n });\n }\n\n /**\n * Forget a scheduled bootstrap that was skipped or failed, so the next\n * trigger re-runs it — but only if no newer config has been scheduled\n * meanwhile: a newer config supersedes this run, success or failure.\n *\n * @param vaultConfig - The config the abandoned run was scheduled with.\n */\n #forget(vaultConfig: MoneyAccountVaultConfig): void {\n if (this.#bootstrappedConfig === vaultConfig) {\n this.#bootstrappedConfig = undefined;\n }\n }\n\n /**\n * Report a served enable flag without a usable `moneyAccountVaultConfig` —\n * a flag misconfiguration that silently disables upgrades. Reported once\n * per controller lifetime; flag refreshes arrive continuously and would\n * otherwise spam.\n */\n #reportMissingConfig(): void {\n if (!this.#missingConfigReported) {\n this.#missingConfigReported = true;\n this.#onBootstrapError(new MissingMoneyAccountVaultConfigError());\n }\n }\n\n /**\n * Fetches service details and validates the controller can operate on the\n * vault's chain, arming the upgrade config `upgradeAccount` runs against.\n * Resolves the Delegation Framework contract addresses for the chain from\n * `@metamask/delegation-deployments`.\n *\n * @param vaultConfig - The vault config to arm; its `boringVault` is the\n * withdrawal-side delegation token (vmUSD), supplied via the flag until\n * the CHOMP service-details API exposes it.\n */\n async #applyVaultConfig(vaultConfig: MoneyAccountVaultConfig): Promise<void> {\n const { chainId, boringVault: boringVaultAddress } = vaultConfig;\n\n const contracts =\n DELEGATOR_CONTRACTS[DELEGATION_FRAMEWORK_VERSION][hexToNumber(chainId)];\n if (!contracts) {\n throw new Error(\n `Delegation Framework ${DELEGATION_FRAMEWORK_VERSION} is not deployed on chain ${chainId}`,\n );\n }\n\n const response = await this.messenger.call(\n 'ChompApiService:getServiceDetails',\n [chainId],\n );\n\n const chain = response.chains[chainId];\n if (!chain) {\n throw new Error(`Chain ${chainId} not found in service details response`);\n }\n\n const { vedaProtocol } = chain.protocol;\n if (!vedaProtocol) {\n throw new Error(\n `vedaProtocol not found for chain ${chainId} in service details response`,\n );\n }\n\n if (vedaProtocol.supportedTokens.length === 0) {\n throw new Error(\n `No supported tokens found for vedaProtocol on chain ${chainId}`,\n );\n }\n\n // A disarm (isEnabled flipping off) or a newer scheduled config during\n // the CHOMP call supersedes this run: arming now would resurrect a config\n // the controller just dropped, or briefly shadow the newer one.\n if (this.#bootstrappedConfig !== vaultConfig) {\n return;\n }\n\n this.#config = {\n chainId,\n delegateAddress: chain.autoDepositDelegate,\n musdTokenAddress: vedaProtocol.supportedTokens[0].tokenAddress,\n boringVaultAddress,\n vedaVaultAdapterAddress: vedaProtocol.adapterAddress,\n delegatorImplAddress: contracts.EIP7702StatelessDeleGatorImpl,\n erc20TransferAmountEnforcer: contracts.ERC20TransferAmountEnforcer,\n redeemerEnforcer: contracts.RedeemerEnforcer,\n valueLteEnforcer: contracts.ValueLteEnforcer,\n };\n }\n\n /**\n * Runs each step in the upgrade sequence in order. A step that reports\n * `'already-done'` is skipped without performing any action; a step that\n * reports `'completed'` has performed its action. An error thrown by any\n * step halts the sequence and is re-thrown wrapped in a\n * {@link MoneyAccountUpgradeStepError} that records which step failed (the\n * original error is preserved as `cause`).\n *\n * A run that completes is recorded in state (keyed by lowercased address,\n * fingerprinted against the active config); subsequent calls for a\n * recorded account return immediately without running any steps. If the\n * active config no longer matches the recorded fingerprint, the sequence\n * re-runs.\n *\n * A call that arrives while the bootstrap chain is still in flight —\n * including runs scheduled while waiting — waits for it to settle rather\n * than failing, so the upgrade always runs against the latest armed\n * config. Scheduling a bootstrap for a changed vault config disarms the\n * previous one, so it only throws when no bootstrap has armed a config:\n * feature disabled, wallet locked, or the last bootstrap failed.\n *\n * @param address - The Money Account address to upgrade.\n */\n async upgradeAccount(address: Hex): Promise<void> {\n let bootstrap = this.#bootstrap;\n while (bootstrap) {\n await bootstrap.catch(() => undefined);\n // A newer run may have been chained on while we waited; wait for that\n // one too, until the chain settles.\n bootstrap = this.#bootstrap === bootstrap ? undefined : this.#bootstrap;\n }\n if (!this.#config) {\n throw new Error(\n 'MoneyAccountUpgradeController is not bootstrapped: upgradeAccount() requires the feature flag on, the wallet unlocked, and a successful bootstrap',\n );\n }\n const config = this.#config;\n\n const accountKey = address.toLowerCase() as Hex;\n const configFingerprint = computeConfigFingerprint(config);\n if (\n this.state.upgradedAccounts[accountKey]?.configFingerprint ===\n configFingerprint\n ) {\n return;\n }\n\n for (const step of this.#steps) {\n try {\n await step.run({\n messenger: this.messenger,\n address,\n ...config,\n });\n } catch (error) {\n throw new MoneyAccountUpgradeStepError(step.name, error);\n }\n }\n\n this.update((state) => {\n state.upgradedAccounts[accountKey] = {\n configFingerprint,\n completedAt: Date.now(),\n };\n });\n }\n}\n\n/**\n * Derives a stable fingerprint of the config fields that define what\n * \"upgraded\" means for an account. A recorded upgrade is only trusted while\n * the active config produces the same fingerprint.\n *\n * @param config - The active upgrade config.\n * @returns A canonical string over the config's identifying fields.\n */\nfunction computeConfigFingerprint(\n config: UpgradeConfig & { chainId: Hex },\n): string {\n return [\n DELEGATION_FRAMEWORK_VERSION,\n config.chainId,\n config.delegateAddress,\n config.musdTokenAddress,\n config.boringVaultAddress,\n config.vedaVaultAdapterAddress,\n config.delegatorImplAddress,\n config.erc20TransferAmountEnforcer,\n config.redeemerEnforcer,\n config.valueLteEnforcer,\n ]\n .map((value) => value.toLowerCase())\n .join('|');\n}\n"]}
|
package/dist/errors.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isTerminalMoneyAccountUpgradeError = exports.isMoneyAccountUpgradeStepError = exports.TerminalUpgradeError = exports.MoneyAccountUpgradeStepError = void 0;
|
|
3
|
+
exports.isTerminalMoneyAccountUpgradeError = exports.isMoneyAccountUpgradeStepError = exports.MissingMoneyAccountVaultConfigError = exports.TerminalUpgradeError = exports.MoneyAccountUpgradeStepError = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Error thrown by `MoneyAccountUpgradeController.upgradeAccount` when one of
|
|
6
6
|
* the upgrade steps fails.
|
|
@@ -40,6 +40,18 @@ class TerminalUpgradeError extends Error {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
exports.TerminalUpgradeError = TerminalUpgradeError;
|
|
43
|
+
/**
|
|
44
|
+
* Error reported through the `onBootstrapError` hook when the Money Account
|
|
45
|
+
* enable flag is on but the `moneyAccountVaultConfig` flag is unserved or
|
|
46
|
+
* malformed.
|
|
47
|
+
*/
|
|
48
|
+
class MissingMoneyAccountVaultConfigError extends Error {
|
|
49
|
+
constructor() {
|
|
50
|
+
super('Money Account upgrade bootstrap skipped: vault configuration is unavailable');
|
|
51
|
+
this.name = 'MissingMoneyAccountVaultConfigError';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.MissingMoneyAccountVaultConfigError = MissingMoneyAccountVaultConfigError;
|
|
43
55
|
/**
|
|
44
56
|
* Type guard for {@link MoneyAccountUpgradeStepError}.
|
|
45
57
|
*
|
package/dist/errors.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,MAAa,4BAA6B,SAAQ,KAAK;IAcrD,YAAY,IAAY,EAAE,KAAc;QACtC,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,KAAK,CAAC,yCAAyC,IAAI,MAAM,YAAY,EAAE,CAAC,CAAC;QAEzE,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ;YACX,KAAK,YAAY,KAAK;gBACrB,KAAgC,CAAC,QAAQ,KAAK,IAAI,CAAC;IACxD,CAAC;CACF;AAzBD,oEAyBC;AAED;;;;;;;GAOG;AACH,MAAa,oBAAqB,SAAQ,KAAK;IAI7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QAJjB,0CAA0C;QACjC,aAAQ,GAAG,IAAI,CAAC;QAIvB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AARD,oDAQC;AAED;;;;;;;;;GASG;AACH,SAAgB,8BAA8B,CAC5C,KAAc;IAEd,OAAO,CACL,KAAK,YAAY,KAAK;QACtB,KAAK,CAAC,IAAI,KAAK,8BAA8B;QAC7C,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ,CACvD,CAAC;AACJ,CAAC;AARD,wEAQC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,kCAAkC,CAChD,KAAc;IAEd,OAAO,CACL,8BAA8B,CAAC,KAAK,CAAC;QACpC,KAAgC,CAAC,QAAQ,KAAK,IAAI,CACpD,CAAC;AACJ,CAAC;AAPD,gFAOC","sourcesContent":["/**\n * Error thrown by `MoneyAccountUpgradeController.upgradeAccount` when one of\n * the upgrade steps fails.\n *\n * Wraps the underlying error (preserved as `cause`) and records the name of\n * the step that was running, so consumers can attribute the failure to a\n * specific step — e.g. when tagging an error report — without parsing the\n * message.\n */\nexport class MoneyAccountUpgradeStepError extends Error {\n /** The name of the step that threw. */\n readonly step: string;\n\n /** The underlying error thrown by the step. */\n readonly cause: unknown;\n\n /**\n * Whether the failure is terminal — the condition will not resolve on its\n * own, so retrying the upgrade sequence cannot succeed. Derived from the\n * cause (see {@link TerminalUpgradeError}).\n */\n readonly terminal: boolean;\n\n constructor(step: string, cause: unknown) {\n const causeMessage = cause instanceof Error ? cause.message : String(cause);\n super(`Money Account upgrade failed at step \"${step}\": ${causeMessage}`);\n\n this.name = 'MoneyAccountUpgradeStepError';\n this.step = step;\n this.cause = cause;\n this.terminal =\n cause instanceof Error &&\n (cause as { terminal?: unknown }).terminal === true;\n }\n}\n\n/**\n * Error a step throws to mark a failure as terminal: the condition will not\n * resolve on its own, so retrying the upgrade sequence is pointless — e.g.\n * the account is already delegated to a third-party implementation.\n *\n * Detected structurally via the `terminal` property (rather than\n * `instanceof`) so the marking survives module-realm duplication.\n */\nexport class TerminalUpgradeError extends Error {\n /** Marks the failure as not retryable. */\n readonly terminal = true;\n\n constructor(message: string) {\n super(message);\n this.name = 'TerminalUpgradeError';\n }\n}\n\n/**\n * Type guard for {@link MoneyAccountUpgradeStepError}.\n *\n * Uses a structural check rather than `instanceof` so it holds across module\n * realm boundaries — e.g. when the controller is consumed from a bundled host\n * app where a duplicate copy of this class may exist.\n *\n * @param error - The value to test.\n * @returns Whether `error` is a `MoneyAccountUpgradeStepError`.\n */\nexport function isMoneyAccountUpgradeStepError(\n error: unknown,\n): error is MoneyAccountUpgradeStepError {\n return (\n error instanceof Error &&\n error.name === 'MoneyAccountUpgradeStepError' &&\n typeof (error as { step?: unknown }).step === 'string'\n );\n}\n\n/**\n * Whether `error` is a {@link MoneyAccountUpgradeStepError} marked as\n * terminal — a failure that will not resolve on its own, so retrying the\n * upgrade sequence cannot succeed.\n *\n * Uses the same structural checks as {@link isMoneyAccountUpgradeStepError}\n * so it holds across module realm boundaries.\n *\n * @param error - The value to test.\n * @returns Whether `error` is a terminal `MoneyAccountUpgradeStepError`.\n */\nexport function isTerminalMoneyAccountUpgradeError(\n error: unknown,\n): error is MoneyAccountUpgradeStepError {\n return (\n isMoneyAccountUpgradeStepError(error) &&\n (error as { terminal?: unknown }).terminal === true\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"errors.cjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,MAAa,4BAA6B,SAAQ,KAAK;IAcrD,YAAY,IAAY,EAAE,KAAc;QACtC,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,KAAK,CAAC,yCAAyC,IAAI,MAAM,YAAY,EAAE,CAAC,CAAC;QAEzE,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ;YACX,KAAK,YAAY,KAAK;gBACrB,KAAgC,CAAC,QAAQ,KAAK,IAAI,CAAC;IACxD,CAAC;CACF;AAzBD,oEAyBC;AAED;;;;;;;GAOG;AACH,MAAa,oBAAqB,SAAQ,KAAK;IAI7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QAJjB,0CAA0C;QACjC,aAAQ,GAAG,IAAI,CAAC;QAIvB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AARD,oDAQC;AAED;;;;GAIG;AACH,MAAa,mCAAoC,SAAQ,KAAK;IAC5D;QACE,KAAK,CACH,6EAA6E,CAC9E,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,qCAAqC,CAAC;IACpD,CAAC;CACF;AAPD,kFAOC;AAED;;;;;;;;;GASG;AACH,SAAgB,8BAA8B,CAC5C,KAAc;IAEd,OAAO,CACL,KAAK,YAAY,KAAK;QACtB,KAAK,CAAC,IAAI,KAAK,8BAA8B;QAC7C,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ,CACvD,CAAC;AACJ,CAAC;AARD,wEAQC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,kCAAkC,CAChD,KAAc;IAEd,OAAO,CACL,8BAA8B,CAAC,KAAK,CAAC;QACpC,KAAgC,CAAC,QAAQ,KAAK,IAAI,CACpD,CAAC;AACJ,CAAC;AAPD,gFAOC","sourcesContent":["/**\n * Error thrown by `MoneyAccountUpgradeController.upgradeAccount` when one of\n * the upgrade steps fails.\n *\n * Wraps the underlying error (preserved as `cause`) and records the name of\n * the step that was running, so consumers can attribute the failure to a\n * specific step — e.g. when tagging an error report — without parsing the\n * message.\n */\nexport class MoneyAccountUpgradeStepError extends Error {\n /** The name of the step that threw. */\n readonly step: string;\n\n /** The underlying error thrown by the step. */\n readonly cause: unknown;\n\n /**\n * Whether the failure is terminal — the condition will not resolve on its\n * own, so retrying the upgrade sequence cannot succeed. Derived from the\n * cause (see {@link TerminalUpgradeError}).\n */\n readonly terminal: boolean;\n\n constructor(step: string, cause: unknown) {\n const causeMessage = cause instanceof Error ? cause.message : String(cause);\n super(`Money Account upgrade failed at step \"${step}\": ${causeMessage}`);\n\n this.name = 'MoneyAccountUpgradeStepError';\n this.step = step;\n this.cause = cause;\n this.terminal =\n cause instanceof Error &&\n (cause as { terminal?: unknown }).terminal === true;\n }\n}\n\n/**\n * Error a step throws to mark a failure as terminal: the condition will not\n * resolve on its own, so retrying the upgrade sequence is pointless — e.g.\n * the account is already delegated to a third-party implementation.\n *\n * Detected structurally via the `terminal` property (rather than\n * `instanceof`) so the marking survives module-realm duplication.\n */\nexport class TerminalUpgradeError extends Error {\n /** Marks the failure as not retryable. */\n readonly terminal = true;\n\n constructor(message: string) {\n super(message);\n this.name = 'TerminalUpgradeError';\n }\n}\n\n/**\n * Error reported through the `onBootstrapError` hook when the Money Account\n * enable flag is on but the `moneyAccountVaultConfig` flag is unserved or\n * malformed.\n */\nexport class MissingMoneyAccountVaultConfigError extends Error {\n constructor() {\n super(\n 'Money Account upgrade bootstrap skipped: vault configuration is unavailable',\n );\n this.name = 'MissingMoneyAccountVaultConfigError';\n }\n}\n\n/**\n * Type guard for {@link MoneyAccountUpgradeStepError}.\n *\n * Uses a structural check rather than `instanceof` so it holds across module\n * realm boundaries — e.g. when the controller is consumed from a bundled host\n * app where a duplicate copy of this class may exist.\n *\n * @param error - The value to test.\n * @returns Whether `error` is a `MoneyAccountUpgradeStepError`.\n */\nexport function isMoneyAccountUpgradeStepError(\n error: unknown,\n): error is MoneyAccountUpgradeStepError {\n return (\n error instanceof Error &&\n error.name === 'MoneyAccountUpgradeStepError' &&\n typeof (error as { step?: unknown }).step === 'string'\n );\n}\n\n/**\n * Whether `error` is a {@link MoneyAccountUpgradeStepError} marked as\n * terminal — a failure that will not resolve on its own, so retrying the\n * upgrade sequence cannot succeed.\n *\n * Uses the same structural checks as {@link isMoneyAccountUpgradeStepError}\n * so it holds across module realm boundaries.\n *\n * @param error - The value to test.\n * @returns Whether `error` is a terminal `MoneyAccountUpgradeStepError`.\n */\nexport function isTerminalMoneyAccountUpgradeError(\n error: unknown,\n): error is MoneyAccountUpgradeStepError {\n return (\n isMoneyAccountUpgradeStepError(error) &&\n (error as { terminal?: unknown }).terminal === true\n );\n}\n"]}
|
package/dist/errors.d.cts
CHANGED
|
@@ -33,6 +33,14 @@ export declare class TerminalUpgradeError extends Error {
|
|
|
33
33
|
readonly terminal = true;
|
|
34
34
|
constructor(message: string);
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Error reported through the `onBootstrapError` hook when the Money Account
|
|
38
|
+
* enable flag is on but the `moneyAccountVaultConfig` flag is unserved or
|
|
39
|
+
* malformed.
|
|
40
|
+
*/
|
|
41
|
+
export declare class MissingMoneyAccountVaultConfigError extends Error {
|
|
42
|
+
constructor();
|
|
43
|
+
}
|
|
36
44
|
/**
|
|
37
45
|
* Type guard for {@link MoneyAccountUpgradeStepError}.
|
|
38
46
|
*
|
package/dist/errors.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.cts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,+CAA+C;IAC/C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;gBAEf,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAWzC;AAED;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,QAAQ;gBAEb,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,4BAA4B,CAMvC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,4BAA4B,CAKvC"}
|
|
1
|
+
{"version":3,"file":"errors.d.cts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,+CAA+C;IAC/C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;gBAEf,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAWzC;AAED;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,QAAQ;gBAEb,OAAO,EAAE,MAAM;CAI5B;AAED;;;;GAIG;AACH,qBAAa,mCAAoC,SAAQ,KAAK;;CAO7D;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,4BAA4B,CAMvC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,4BAA4B,CAKvC"}
|
package/dist/errors.d.mts
CHANGED
|
@@ -33,6 +33,14 @@ export declare class TerminalUpgradeError extends Error {
|
|
|
33
33
|
readonly terminal = true;
|
|
34
34
|
constructor(message: string);
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Error reported through the `onBootstrapError` hook when the Money Account
|
|
38
|
+
* enable flag is on but the `moneyAccountVaultConfig` flag is unserved or
|
|
39
|
+
* malformed.
|
|
40
|
+
*/
|
|
41
|
+
export declare class MissingMoneyAccountVaultConfigError extends Error {
|
|
42
|
+
constructor();
|
|
43
|
+
}
|
|
36
44
|
/**
|
|
37
45
|
* Type guard for {@link MoneyAccountUpgradeStepError}.
|
|
38
46
|
*
|
package/dist/errors.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.mts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,+CAA+C;IAC/C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;gBAEf,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAWzC;AAED;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,QAAQ;gBAEb,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,4BAA4B,CAMvC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,4BAA4B,CAKvC"}
|
|
1
|
+
{"version":3,"file":"errors.d.mts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,+CAA+C;IAC/C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;gBAEf,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAWzC;AAED;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,QAAQ;gBAEb,OAAO,EAAE,MAAM;CAI5B;AAED;;;;GAIG;AACH,qBAAa,mCAAoC,SAAQ,KAAK;;CAO7D;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,4BAA4B,CAMvC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,4BAA4B,CAKvC"}
|
package/dist/errors.mjs
CHANGED
|
@@ -35,6 +35,17 @@ export class TerminalUpgradeError extends Error {
|
|
|
35
35
|
this.name = 'TerminalUpgradeError';
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Error reported through the `onBootstrapError` hook when the Money Account
|
|
40
|
+
* enable flag is on but the `moneyAccountVaultConfig` flag is unserved or
|
|
41
|
+
* malformed.
|
|
42
|
+
*/
|
|
43
|
+
export class MissingMoneyAccountVaultConfigError extends Error {
|
|
44
|
+
constructor() {
|
|
45
|
+
super('Money Account upgrade bootstrap skipped: vault configuration is unavailable');
|
|
46
|
+
this.name = 'MissingMoneyAccountVaultConfigError';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
38
49
|
/**
|
|
39
50
|
* Type guard for {@link MoneyAccountUpgradeStepError}.
|
|
40
51
|
*
|
package/dist/errors.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IAcrD,YAAY,IAAY,EAAE,KAAc;QACtC,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,KAAK,CAAC,yCAAyC,IAAI,MAAM,YAAY,EAAE,CAAC,CAAC;QAEzE,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ;YACX,KAAK,YAAY,KAAK;gBACrB,KAAgC,CAAC,QAAQ,KAAK,IAAI,CAAC;IACxD,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAI7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QAJjB,0CAA0C;QACjC,aAAQ,GAAG,IAAI,CAAC;QAIvB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,8BAA8B,CAC5C,KAAc;IAEd,OAAO,CACL,KAAK,YAAY,KAAK;QACtB,KAAK,CAAC,IAAI,KAAK,8BAA8B;QAC7C,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ,CACvD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kCAAkC,CAChD,KAAc;IAEd,OAAO,CACL,8BAA8B,CAAC,KAAK,CAAC;QACpC,KAAgC,CAAC,QAAQ,KAAK,IAAI,CACpD,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Error thrown by `MoneyAccountUpgradeController.upgradeAccount` when one of\n * the upgrade steps fails.\n *\n * Wraps the underlying error (preserved as `cause`) and records the name of\n * the step that was running, so consumers can attribute the failure to a\n * specific step — e.g. when tagging an error report — without parsing the\n * message.\n */\nexport class MoneyAccountUpgradeStepError extends Error {\n /** The name of the step that threw. */\n readonly step: string;\n\n /** The underlying error thrown by the step. */\n readonly cause: unknown;\n\n /**\n * Whether the failure is terminal — the condition will not resolve on its\n * own, so retrying the upgrade sequence cannot succeed. Derived from the\n * cause (see {@link TerminalUpgradeError}).\n */\n readonly terminal: boolean;\n\n constructor(step: string, cause: unknown) {\n const causeMessage = cause instanceof Error ? cause.message : String(cause);\n super(`Money Account upgrade failed at step \"${step}\": ${causeMessage}`);\n\n this.name = 'MoneyAccountUpgradeStepError';\n this.step = step;\n this.cause = cause;\n this.terminal =\n cause instanceof Error &&\n (cause as { terminal?: unknown }).terminal === true;\n }\n}\n\n/**\n * Error a step throws to mark a failure as terminal: the condition will not\n * resolve on its own, so retrying the upgrade sequence is pointless — e.g.\n * the account is already delegated to a third-party implementation.\n *\n * Detected structurally via the `terminal` property (rather than\n * `instanceof`) so the marking survives module-realm duplication.\n */\nexport class TerminalUpgradeError extends Error {\n /** Marks the failure as not retryable. */\n readonly terminal = true;\n\n constructor(message: string) {\n super(message);\n this.name = 'TerminalUpgradeError';\n }\n}\n\n/**\n * Type guard for {@link MoneyAccountUpgradeStepError}.\n *\n * Uses a structural check rather than `instanceof` so it holds across module\n * realm boundaries — e.g. when the controller is consumed from a bundled host\n * app where a duplicate copy of this class may exist.\n *\n * @param error - The value to test.\n * @returns Whether `error` is a `MoneyAccountUpgradeStepError`.\n */\nexport function isMoneyAccountUpgradeStepError(\n error: unknown,\n): error is MoneyAccountUpgradeStepError {\n return (\n error instanceof Error &&\n error.name === 'MoneyAccountUpgradeStepError' &&\n typeof (error as { step?: unknown }).step === 'string'\n );\n}\n\n/**\n * Whether `error` is a {@link MoneyAccountUpgradeStepError} marked as\n * terminal — a failure that will not resolve on its own, so retrying the\n * upgrade sequence cannot succeed.\n *\n * Uses the same structural checks as {@link isMoneyAccountUpgradeStepError}\n * so it holds across module realm boundaries.\n *\n * @param error - The value to test.\n * @returns Whether `error` is a terminal `MoneyAccountUpgradeStepError`.\n */\nexport function isTerminalMoneyAccountUpgradeError(\n error: unknown,\n): error is MoneyAccountUpgradeStepError {\n return (\n isMoneyAccountUpgradeStepError(error) &&\n (error as { terminal?: unknown }).terminal === true\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IAcrD,YAAY,IAAY,EAAE,KAAc;QACtC,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,KAAK,CAAC,yCAAyC,IAAI,MAAM,YAAY,EAAE,CAAC,CAAC;QAEzE,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ;YACX,KAAK,YAAY,KAAK;gBACrB,KAAgC,CAAC,QAAQ,KAAK,IAAI,CAAC;IACxD,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAI7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QAJjB,0CAA0C;QACjC,aAAQ,GAAG,IAAI,CAAC;QAIvB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,mCAAoC,SAAQ,KAAK;IAC5D;QACE,KAAK,CACH,6EAA6E,CAC9E,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,qCAAqC,CAAC;IACpD,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,8BAA8B,CAC5C,KAAc;IAEd,OAAO,CACL,KAAK,YAAY,KAAK;QACtB,KAAK,CAAC,IAAI,KAAK,8BAA8B;QAC7C,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ,CACvD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kCAAkC,CAChD,KAAc;IAEd,OAAO,CACL,8BAA8B,CAAC,KAAK,CAAC;QACpC,KAAgC,CAAC,QAAQ,KAAK,IAAI,CACpD,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Error thrown by `MoneyAccountUpgradeController.upgradeAccount` when one of\n * the upgrade steps fails.\n *\n * Wraps the underlying error (preserved as `cause`) and records the name of\n * the step that was running, so consumers can attribute the failure to a\n * specific step — e.g. when tagging an error report — without parsing the\n * message.\n */\nexport class MoneyAccountUpgradeStepError extends Error {\n /** The name of the step that threw. */\n readonly step: string;\n\n /** The underlying error thrown by the step. */\n readonly cause: unknown;\n\n /**\n * Whether the failure is terminal — the condition will not resolve on its\n * own, so retrying the upgrade sequence cannot succeed. Derived from the\n * cause (see {@link TerminalUpgradeError}).\n */\n readonly terminal: boolean;\n\n constructor(step: string, cause: unknown) {\n const causeMessage = cause instanceof Error ? cause.message : String(cause);\n super(`Money Account upgrade failed at step \"${step}\": ${causeMessage}`);\n\n this.name = 'MoneyAccountUpgradeStepError';\n this.step = step;\n this.cause = cause;\n this.terminal =\n cause instanceof Error &&\n (cause as { terminal?: unknown }).terminal === true;\n }\n}\n\n/**\n * Error a step throws to mark a failure as terminal: the condition will not\n * resolve on its own, so retrying the upgrade sequence is pointless — e.g.\n * the account is already delegated to a third-party implementation.\n *\n * Detected structurally via the `terminal` property (rather than\n * `instanceof`) so the marking survives module-realm duplication.\n */\nexport class TerminalUpgradeError extends Error {\n /** Marks the failure as not retryable. */\n readonly terminal = true;\n\n constructor(message: string) {\n super(message);\n this.name = 'TerminalUpgradeError';\n }\n}\n\n/**\n * Error reported through the `onBootstrapError` hook when the Money Account\n * enable flag is on but the `moneyAccountVaultConfig` flag is unserved or\n * malformed.\n */\nexport class MissingMoneyAccountVaultConfigError extends Error {\n constructor() {\n super(\n 'Money Account upgrade bootstrap skipped: vault configuration is unavailable',\n );\n this.name = 'MissingMoneyAccountVaultConfigError';\n }\n}\n\n/**\n * Type guard for {@link MoneyAccountUpgradeStepError}.\n *\n * Uses a structural check rather than `instanceof` so it holds across module\n * realm boundaries — e.g. when the controller is consumed from a bundled host\n * app where a duplicate copy of this class may exist.\n *\n * @param error - The value to test.\n * @returns Whether `error` is a `MoneyAccountUpgradeStepError`.\n */\nexport function isMoneyAccountUpgradeStepError(\n error: unknown,\n): error is MoneyAccountUpgradeStepError {\n return (\n error instanceof Error &&\n error.name === 'MoneyAccountUpgradeStepError' &&\n typeof (error as { step?: unknown }).step === 'string'\n );\n}\n\n/**\n * Whether `error` is a {@link MoneyAccountUpgradeStepError} marked as\n * terminal — a failure that will not resolve on its own, so retrying the\n * upgrade sequence cannot succeed.\n *\n * Uses the same structural checks as {@link isMoneyAccountUpgradeStepError}\n * so it holds across module realm boundaries.\n *\n * @param error - The value to test.\n * @returns Whether `error` is a terminal `MoneyAccountUpgradeStepError`.\n */\nexport function isTerminalMoneyAccountUpgradeError(\n error: unknown,\n): error is MoneyAccountUpgradeStepError {\n return (\n isMoneyAccountUpgradeStepError(error) &&\n (error as { terminal?: unknown }).terminal === true\n );\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDefaultMoneyAccountUpgradeControllerState = exports.MoneyAccountUpgradeController = exports.isTerminalMoneyAccountUpgradeError = exports.isMoneyAccountUpgradeStepError = exports.TerminalUpgradeError = exports.MoneyAccountUpgradeStepError = void 0;
|
|
3
|
+
exports.getDefaultMoneyAccountUpgradeControllerState = exports.MoneyAccountUpgradeController = exports.isTerminalMoneyAccountUpgradeError = exports.isMoneyAccountUpgradeStepError = exports.TerminalUpgradeError = exports.MoneyAccountUpgradeStepError = exports.MissingMoneyAccountVaultConfigError = void 0;
|
|
4
4
|
var errors_js_1 = require("./errors.cjs");
|
|
5
|
+
Object.defineProperty(exports, "MissingMoneyAccountVaultConfigError", { enumerable: true, get: function () { return errors_js_1.MissingMoneyAccountVaultConfigError; } });
|
|
5
6
|
Object.defineProperty(exports, "MoneyAccountUpgradeStepError", { enumerable: true, get: function () { return errors_js_1.MoneyAccountUpgradeStepError; } });
|
|
6
7
|
Object.defineProperty(exports, "TerminalUpgradeError", { enumerable: true, get: function () { return errors_js_1.TerminalUpgradeError; } });
|
|
7
8
|
Object.defineProperty(exports, "isMoneyAccountUpgradeStepError", { enumerable: true, get: function () { return errors_js_1.isMoneyAccountUpgradeStepError; } });
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,0CAMqB;AALnB,gIAAA,mCAAmC,OAAA;AACnC,yHAAA,4BAA4B,OAAA;AAC5B,iHAAA,oBAAoB,OAAA;AACpB,2HAAA,8BAA8B,OAAA;AAC9B,+HAAA,kCAAkC,OAAA;AAEpC,wFAG4C;AAF1C,iJAAA,6BAA6B,OAAA;AAC7B,gKAAA,4CAA4C,OAAA","sourcesContent":["export type { UpgradeConfig } from './types.js';\nexport {\n MissingMoneyAccountVaultConfigError,\n MoneyAccountUpgradeStepError,\n TerminalUpgradeError,\n isMoneyAccountUpgradeStepError,\n isTerminalMoneyAccountUpgradeError,\n} from './errors.js';\nexport {\n MoneyAccountUpgradeController,\n getDefaultMoneyAccountUpgradeControllerState,\n} from './MoneyAccountUpgradeController.js';\nexport type {\n MoneyAccountUpgradeControllerState,\n MoneyAccountUpgradeControllerGetStateAction,\n MoneyAccountUpgradeControllerActions,\n MoneyAccountUpgradeControllerHooks,\n MoneyAccountUpgradeControllerStateChangedEvent,\n MoneyAccountUpgradeControllerEvents,\n MoneyAccountUpgradeControllerMessenger,\n MoneyAccountUpgradeStatus,\n} from './MoneyAccountUpgradeController.js';\nexport type { MoneyAccountUpgradeControllerUpgradeAccountAction } from './MoneyAccountUpgradeController-method-action-types.js';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { UpgradeConfig } from "./types.cjs";
|
|
2
|
-
export { MoneyAccountUpgradeStepError, TerminalUpgradeError, isMoneyAccountUpgradeStepError, isTerminalMoneyAccountUpgradeError, } from "./errors.cjs";
|
|
2
|
+
export { MissingMoneyAccountVaultConfigError, MoneyAccountUpgradeStepError, TerminalUpgradeError, isMoneyAccountUpgradeStepError, isTerminalMoneyAccountUpgradeError, } from "./errors.cjs";
|
|
3
3
|
export { MoneyAccountUpgradeController, getDefaultMoneyAccountUpgradeControllerState, } from "./MoneyAccountUpgradeController.cjs";
|
|
4
|
-
export type { MoneyAccountUpgradeControllerState, MoneyAccountUpgradeControllerGetStateAction, MoneyAccountUpgradeControllerActions, MoneyAccountUpgradeControllerStateChangedEvent, MoneyAccountUpgradeControllerEvents, MoneyAccountUpgradeControllerMessenger, MoneyAccountUpgradeStatus, } from "./MoneyAccountUpgradeController.cjs";
|
|
4
|
+
export type { MoneyAccountUpgradeControllerState, MoneyAccountUpgradeControllerGetStateAction, MoneyAccountUpgradeControllerActions, MoneyAccountUpgradeControllerHooks, MoneyAccountUpgradeControllerStateChangedEvent, MoneyAccountUpgradeControllerEvents, MoneyAccountUpgradeControllerMessenger, MoneyAccountUpgradeStatus, } from "./MoneyAccountUpgradeController.cjs";
|
|
5
5
|
export type { MoneyAccountUpgradeControllerUpgradeAccountAction } from "./MoneyAccountUpgradeController-method-action-types.cjs";
|
|
6
6
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,oBAAmB;AAChD,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,8BAA8B,EAC9B,kCAAkC,GACnC,qBAAoB;AACrB,OAAO,EACL,6BAA6B,EAC7B,4CAA4C,GAC7C,4CAA2C;AAC5C,YAAY,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,oCAAoC,EACpC,8CAA8C,EAC9C,mCAAmC,EACnC,sCAAsC,EACtC,yBAAyB,GAC1B,4CAA2C;AAC5C,YAAY,EAAE,iDAAiD,EAAE,gEAA+D"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,oBAAmB;AAChD,OAAO,EACL,mCAAmC,EACnC,4BAA4B,EAC5B,oBAAoB,EACpB,8BAA8B,EAC9B,kCAAkC,GACnC,qBAAoB;AACrB,OAAO,EACL,6BAA6B,EAC7B,4CAA4C,GAC7C,4CAA2C;AAC5C,YAAY,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,oCAAoC,EACpC,kCAAkC,EAClC,8CAA8C,EAC9C,mCAAmC,EACnC,sCAAsC,EACtC,yBAAyB,GAC1B,4CAA2C;AAC5C,YAAY,EAAE,iDAAiD,EAAE,gEAA+D"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { UpgradeConfig } from "./types.mjs";
|
|
2
|
-
export { MoneyAccountUpgradeStepError, TerminalUpgradeError, isMoneyAccountUpgradeStepError, isTerminalMoneyAccountUpgradeError, } from "./errors.mjs";
|
|
2
|
+
export { MissingMoneyAccountVaultConfigError, MoneyAccountUpgradeStepError, TerminalUpgradeError, isMoneyAccountUpgradeStepError, isTerminalMoneyAccountUpgradeError, } from "./errors.mjs";
|
|
3
3
|
export { MoneyAccountUpgradeController, getDefaultMoneyAccountUpgradeControllerState, } from "./MoneyAccountUpgradeController.mjs";
|
|
4
|
-
export type { MoneyAccountUpgradeControllerState, MoneyAccountUpgradeControllerGetStateAction, MoneyAccountUpgradeControllerActions, MoneyAccountUpgradeControllerStateChangedEvent, MoneyAccountUpgradeControllerEvents, MoneyAccountUpgradeControllerMessenger, MoneyAccountUpgradeStatus, } from "./MoneyAccountUpgradeController.mjs";
|
|
4
|
+
export type { MoneyAccountUpgradeControllerState, MoneyAccountUpgradeControllerGetStateAction, MoneyAccountUpgradeControllerActions, MoneyAccountUpgradeControllerHooks, MoneyAccountUpgradeControllerStateChangedEvent, MoneyAccountUpgradeControllerEvents, MoneyAccountUpgradeControllerMessenger, MoneyAccountUpgradeStatus, } from "./MoneyAccountUpgradeController.mjs";
|
|
5
5
|
export type { MoneyAccountUpgradeControllerUpgradeAccountAction } from "./MoneyAccountUpgradeController-method-action-types.mjs";
|
|
6
6
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,oBAAmB;AAChD,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,8BAA8B,EAC9B,kCAAkC,GACnC,qBAAoB;AACrB,OAAO,EACL,6BAA6B,EAC7B,4CAA4C,GAC7C,4CAA2C;AAC5C,YAAY,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,oCAAoC,EACpC,8CAA8C,EAC9C,mCAAmC,EACnC,sCAAsC,EACtC,yBAAyB,GAC1B,4CAA2C;AAC5C,YAAY,EAAE,iDAAiD,EAAE,gEAA+D"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,oBAAmB;AAChD,OAAO,EACL,mCAAmC,EACnC,4BAA4B,EAC5B,oBAAoB,EACpB,8BAA8B,EAC9B,kCAAkC,GACnC,qBAAoB;AACrB,OAAO,EACL,6BAA6B,EAC7B,4CAA4C,GAC7C,4CAA2C;AAC5C,YAAY,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,oCAAoC,EACpC,kCAAkC,EAClC,8CAA8C,EAC9C,mCAAmC,EACnC,sCAAsC,EACtC,yBAAyB,GAC1B,4CAA2C;AAC5C,YAAY,EAAE,iDAAiD,EAAE,gEAA+D"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { MoneyAccountUpgradeStepError, TerminalUpgradeError, isMoneyAccountUpgradeStepError, isTerminalMoneyAccountUpgradeError } from "./errors.mjs";
|
|
1
|
+
export { MissingMoneyAccountVaultConfigError, MoneyAccountUpgradeStepError, TerminalUpgradeError, isMoneyAccountUpgradeStepError, isTerminalMoneyAccountUpgradeError } from "./errors.mjs";
|
|
2
2
|
export { MoneyAccountUpgradeController, getDefaultMoneyAccountUpgradeControllerState } from "./MoneyAccountUpgradeController.mjs";
|
|
3
3
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,8BAA8B,EAC9B,kCAAkC,EACnC,qBAAoB;AACrB,OAAO,EACL,6BAA6B,EAC7B,4CAA4C,EAC7C,4CAA2C","sourcesContent":["export type { UpgradeConfig } from './types.js';\nexport {\n MoneyAccountUpgradeStepError,\n TerminalUpgradeError,\n isMoneyAccountUpgradeStepError,\n isTerminalMoneyAccountUpgradeError,\n} from './errors.js';\nexport {\n MoneyAccountUpgradeController,\n getDefaultMoneyAccountUpgradeControllerState,\n} from './MoneyAccountUpgradeController.js';\nexport type {\n MoneyAccountUpgradeControllerState,\n MoneyAccountUpgradeControllerGetStateAction,\n MoneyAccountUpgradeControllerActions,\n MoneyAccountUpgradeControllerStateChangedEvent,\n MoneyAccountUpgradeControllerEvents,\n MoneyAccountUpgradeControllerMessenger,\n MoneyAccountUpgradeStatus,\n} from './MoneyAccountUpgradeController.js';\nexport type { MoneyAccountUpgradeControllerUpgradeAccountAction } from './MoneyAccountUpgradeController-method-action-types.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mCAAmC,EACnC,4BAA4B,EAC5B,oBAAoB,EACpB,8BAA8B,EAC9B,kCAAkC,EACnC,qBAAoB;AACrB,OAAO,EACL,6BAA6B,EAC7B,4CAA4C,EAC7C,4CAA2C","sourcesContent":["export type { UpgradeConfig } from './types.js';\nexport {\n MissingMoneyAccountVaultConfigError,\n MoneyAccountUpgradeStepError,\n TerminalUpgradeError,\n isMoneyAccountUpgradeStepError,\n isTerminalMoneyAccountUpgradeError,\n} from './errors.js';\nexport {\n MoneyAccountUpgradeController,\n getDefaultMoneyAccountUpgradeControllerState,\n} from './MoneyAccountUpgradeController.js';\nexport type {\n MoneyAccountUpgradeControllerState,\n MoneyAccountUpgradeControllerGetStateAction,\n MoneyAccountUpgradeControllerActions,\n MoneyAccountUpgradeControllerHooks,\n MoneyAccountUpgradeControllerStateChangedEvent,\n MoneyAccountUpgradeControllerEvents,\n MoneyAccountUpgradeControllerMessenger,\n MoneyAccountUpgradeStatus,\n} from './MoneyAccountUpgradeController.js';\nexport type { MoneyAccountUpgradeControllerUpgradeAccountAction } from './MoneyAccountUpgradeController-method-action-types.js';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/money-account-upgrade-controller",
|
|
3
|
-
"version": "3.0.2-preview-
|
|
3
|
+
"version": "3.0.2-preview-cfd35b8dd",
|
|
4
4
|
"description": "MetaMask Money account upgrade controller",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|
|
@@ -63,7 +63,9 @@
|
|
|
63
63
|
"@metamask/delegation-deployments": "^1.4.0",
|
|
64
64
|
"@metamask/keyring-controller": "^27.1.1",
|
|
65
65
|
"@metamask/messenger": "^2.0.0",
|
|
66
|
+
"@metamask/money-account-utils": "^1.1.0",
|
|
66
67
|
"@metamask/network-controller": "^36.0.0",
|
|
68
|
+
"@metamask/remote-feature-flag-controller": "^6.1.0",
|
|
67
69
|
"@metamask/utils": "^11.11.0"
|
|
68
70
|
},
|
|
69
71
|
"devDependencies": {
|