@metamask/snaps-simulation 3.3.0 → 3.4.1
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 +17 -1
- package/dist/methods/hooks/end-trace.cjs +29 -0
- package/dist/methods/hooks/end-trace.cjs.map +1 -0
- package/dist/methods/hooks/end-trace.d.cts +9 -0
- package/dist/methods/hooks/end-trace.d.cts.map +1 -0
- package/dist/methods/hooks/end-trace.d.mts +9 -0
- package/dist/methods/hooks/end-trace.d.mts.map +1 -0
- package/dist/methods/hooks/end-trace.mjs +25 -0
- package/dist/methods/hooks/end-trace.mjs.map +1 -0
- package/dist/methods/hooks/get-snap.cjs +52 -0
- package/dist/methods/hooks/get-snap.cjs.map +1 -0
- package/dist/methods/hooks/get-snap.d.cts +11 -0
- package/dist/methods/hooks/get-snap.d.cts.map +1 -0
- package/dist/methods/hooks/get-snap.d.mts +11 -0
- package/dist/methods/hooks/get-snap.d.mts.map +1 -0
- package/dist/methods/hooks/get-snap.mjs +48 -0
- package/dist/methods/hooks/get-snap.mjs.map +1 -0
- package/dist/methods/hooks/index.cjs +5 -0
- package/dist/methods/hooks/index.cjs.map +1 -1
- package/dist/methods/hooks/index.d.cts +5 -0
- package/dist/methods/hooks/index.d.cts.map +1 -1
- package/dist/methods/hooks/index.d.mts +5 -0
- package/dist/methods/hooks/index.d.mts.map +1 -1
- package/dist/methods/hooks/index.mjs +5 -0
- package/dist/methods/hooks/index.mjs.map +1 -1
- package/dist/methods/hooks/start-trace.cjs +34 -0
- package/dist/methods/hooks/start-trace.cjs.map +1 -0
- package/dist/methods/hooks/start-trace.d.cts +9 -0
- package/dist/methods/hooks/start-trace.d.cts.map +1 -0
- package/dist/methods/hooks/start-trace.d.mts +9 -0
- package/dist/methods/hooks/start-trace.d.mts.map +1 -0
- package/dist/methods/hooks/start-trace.mjs +30 -0
- package/dist/methods/hooks/start-trace.mjs.map +1 -0
- package/dist/methods/hooks/track-error.cjs +31 -0
- package/dist/methods/hooks/track-error.cjs.map +1 -0
- package/dist/methods/hooks/track-error.d.cts +9 -0
- package/dist/methods/hooks/track-error.d.cts.map +1 -0
- package/dist/methods/hooks/track-error.d.mts +9 -0
- package/dist/methods/hooks/track-error.d.mts.map +1 -0
- package/dist/methods/hooks/track-error.mjs +27 -0
- package/dist/methods/hooks/track-error.mjs.map +1 -0
- package/dist/methods/hooks/track-event.cjs +29 -0
- package/dist/methods/hooks/track-event.cjs.map +1 -0
- package/dist/methods/hooks/track-event.d.cts +13 -0
- package/dist/methods/hooks/track-event.d.cts.map +1 -0
- package/dist/methods/hooks/track-event.d.mts +13 -0
- package/dist/methods/hooks/track-event.d.mts.map +1 -0
- package/dist/methods/hooks/track-event.mjs +25 -0
- package/dist/methods/hooks/track-event.mjs.map +1 -0
- package/dist/request.cjs +21 -1
- package/dist/request.cjs.map +1 -1
- package/dist/request.d.cts.map +1 -1
- package/dist/request.d.mts.map +1 -1
- package/dist/request.mjs +22 -2
- package/dist/request.mjs.map +1 -1
- package/dist/simulation.cjs +6 -1
- package/dist/simulation.cjs.map +1 -1
- package/dist/simulation.d.cts +34 -2
- package/dist/simulation.d.cts.map +1 -1
- package/dist/simulation.d.mts +34 -2
- package/dist/simulation.d.mts.map +1 -1
- package/dist/simulation.mjs +7 -2
- package/dist/simulation.mjs.map +1 -1
- package/dist/store/index.cjs +1 -0
- package/dist/store/index.cjs.map +1 -1
- package/dist/store/index.d.cts +1 -0
- package/dist/store/index.d.cts.map +1 -1
- package/dist/store/index.d.mts +1 -0
- package/dist/store/index.d.mts.map +1 -1
- package/dist/store/index.mjs +1 -0
- package/dist/store/index.mjs.map +1 -1
- package/dist/store/mocks.d.cts +1 -0
- package/dist/store/mocks.d.cts.map +1 -1
- package/dist/store/mocks.d.mts +1 -0
- package/dist/store/mocks.d.mts.map +1 -1
- package/dist/store/notifications.d.cts +1 -0
- package/dist/store/notifications.d.cts.map +1 -1
- package/dist/store/notifications.d.mts +1 -0
- package/dist/store/notifications.d.mts.map +1 -1
- package/dist/store/state.d.cts +2 -0
- package/dist/store/state.d.cts.map +1 -1
- package/dist/store/state.d.mts +2 -0
- package/dist/store/state.d.mts.map +1 -1
- package/dist/store/store.cjs +2 -0
- package/dist/store/store.cjs.map +1 -1
- package/dist/store/store.d.cts +1 -0
- package/dist/store/store.d.cts.map +1 -1
- package/dist/store/store.d.mts +1 -0
- package/dist/store/store.d.mts.map +1 -1
- package/dist/store/store.mjs +2 -0
- package/dist/store/store.mjs.map +1 -1
- package/dist/store/trackables.cjs +70 -0
- package/dist/store/trackables.cjs.map +1 -0
- package/dist/store/trackables.d.cts +98 -0
- package/dist/store/trackables.d.cts.map +1 -0
- package/dist/store/trackables.d.mts +98 -0
- package/dist/store/trackables.d.mts.map +1 -0
- package/dist/store/trackables.mjs +67 -0
- package/dist/store/trackables.mjs.map +1 -0
- package/dist/store/ui.d.cts +1 -0
- package/dist/store/ui.d.cts.map +1 -1
- package/dist/store/ui.d.mts +1 -0
- package/dist/store/ui.d.mts.map +1 -1
- package/dist/structs.cjs +17 -0
- package/dist/structs.cjs.map +1 -1
- package/dist/structs.d.cts +182 -12
- package/dist/structs.d.cts.map +1 -1
- package/dist/structs.d.mts +182 -12
- package/dist/structs.d.mts.map +1 -1
- package/dist/structs.mjs +18 -1
- package/dist/structs.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +11 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +11 -1
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +8 -7
package/dist/simulation.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { getSnapFile } from "./files.mjs";
|
|
|
11
11
|
import { getHelpers } from "./helpers.mjs";
|
|
12
12
|
import { resolveWithSaga } from "./interface.mjs";
|
|
13
13
|
import { asyncResolve, getEndowments } from "./methods/index.mjs";
|
|
14
|
-
import { getPermittedClearSnapStateMethodImplementation, getPermittedGetSnapStateMethodImplementation, getPermittedUpdateSnapStateMethodImplementation, getGetEntropySourcesImplementation, getGetMnemonicImplementation } from "./methods/hooks/index.mjs";
|
|
14
|
+
import { getPermittedClearSnapStateMethodImplementation, getPermittedGetSnapStateMethodImplementation, getPermittedUpdateSnapStateMethodImplementation, getGetEntropySourcesImplementation, getGetMnemonicImplementation, getGetSnapImplementation, getTrackEventImplementation, getTrackErrorImplementation, getEndTraceImplementation, getStartTraceImplementation } from "./methods/hooks/index.mjs";
|
|
15
15
|
import { getGetMnemonicSeedImplementation } from "./methods/hooks/get-mnemonic-seed.mjs";
|
|
16
16
|
import { createJsonRpcEngine } from "./middleware/index.mjs";
|
|
17
17
|
import { getOptions } from "./options.mjs";
|
|
@@ -76,7 +76,7 @@ export async function installSnap(snapId, { executionService, executionServiceOp
|
|
|
76
76
|
// Error function is difficult to test, so we ignore it.
|
|
77
77
|
/* istanbul ignore next 2 */
|
|
78
78
|
pipeline(stream, providerStream, stream, (error) => {
|
|
79
|
-
if (error) {
|
|
79
|
+
if (error && !error.message?.match('Premature close')) {
|
|
80
80
|
logError(`Provider stream failure.`, error);
|
|
81
81
|
}
|
|
82
82
|
});
|
|
@@ -150,6 +150,11 @@ export function getPermittedHooks(snapId, snapFiles, controllerMessenger, runSag
|
|
|
150
150
|
getSnapState: getPermittedGetSnapStateMethodImplementation(runSaga),
|
|
151
151
|
updateSnapState: getPermittedUpdateSnapStateMethodImplementation(runSaga),
|
|
152
152
|
clearSnapState: getPermittedClearSnapStateMethodImplementation(runSaga),
|
|
153
|
+
getSnap: getGetSnapImplementation(true),
|
|
154
|
+
trackError: getTrackErrorImplementation(runSaga),
|
|
155
|
+
trackEvent: getTrackEventImplementation(runSaga),
|
|
156
|
+
startTrace: getStartTraceImplementation(runSaga),
|
|
157
|
+
endTrace: getEndTraceImplementation(runSaga),
|
|
153
158
|
};
|
|
154
159
|
}
|
|
155
160
|
/**
|
package/dist/simulation.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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} from '@metamask/base-controller';\nimport { Messenger } from '@metamask/base-controller';\nimport { createEngineStream } from '@metamask/json-rpc-middleware-stream';\nimport type { CryptographicFunctions } from '@metamask/key-tree';\nimport { PhishingDetectorResultType } from '@metamask/phishing-controller';\nimport type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport {\n detectSnapLocation,\n fetchSnap,\n NodeThreadExecutionService,\n setupMultiplex,\n} from '@metamask/snaps-controllers/node';\nimport { DIALOG_APPROVAL_TYPES } from '@metamask/snaps-rpc-methods';\nimport {\n type AuxiliaryFileEncoding,\n type Component,\n type InterfaceState,\n type InterfaceContext,\n type SnapId,\n type EntropySource,\n} from '@metamask/snaps-sdk';\nimport type { FetchedSnapFiles } from '@metamask/snaps-utils';\nimport { logError } from '@metamask/snaps-utils';\nimport type { CaipAssetType, Json } from '@metamask/utils';\nimport type { Duplex } from 'readable-stream';\nimport { pipeline } from 'readable-stream';\nimport type { SagaIterator } from 'redux-saga';\nimport { select } from 'redux-saga/effects';\n\nimport type { RootControllerMessenger } from './controllers';\nimport { getControllers, registerSnap } from './controllers';\nimport { getSnapFile } from './files';\nimport type { SnapHelpers } from './helpers';\nimport { getHelpers } from './helpers';\nimport { resolveWithSaga } from './interface';\nimport { asyncResolve, getEndowments } from './methods';\nimport {\n getPermittedClearSnapStateMethodImplementation,\n getPermittedGetSnapStateMethodImplementation,\n getPermittedUpdateSnapStateMethodImplementation,\n getGetEntropySourcesImplementation,\n getGetMnemonicImplementation,\n} from './methods/hooks';\nimport { getGetMnemonicSeedImplementation } from './methods/hooks/get-mnemonic-seed';\nimport { createJsonRpcEngine } from './middleware';\nimport type { SimulationOptions, SimulationUserOptions } from './options';\nimport { getOptions } from './options';\nimport type { Interface, RunSagaFunction, Store } from './store';\nimport { createStore, getCurrentInterface } from './store';\nimport { addSnapMetadataToAccount } from './utils/account';\n\n/**\n * Options for the execution service, without the options that are shared\n * between all execution services.\n *\n * @template Service - The type of the execution service, i.e., the class that\n * creates the execution service.\n */\nexport type ExecutionServiceOptions<\n Service extends new (...args: any[]) => any,\n> = Omit<\n ConstructorParameters<Service>[0],\n keyof ConstructorParameters<typeof AbstractExecutionService<unknown>>[0]\n>;\n\n/**\n * The options for running a Snap in a simulated environment.\n *\n * @property executionService - The execution service to use.\n * @property executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @property options - The simulation options.\n * @template Service - The type of the execution service.\n */\nexport type InstallSnapOptions<\n Service extends new (\n ...args: any[]\n ) => InstanceType<typeof AbstractExecutionService<unknown>>,\n> =\n ExecutionServiceOptions<Service> extends Record<string, never>\n ? {\n executionService: Service;\n executionServiceOptions?: ExecutionServiceOptions<Service>;\n options?: SimulationUserOptions;\n }\n : {\n executionService: Service;\n executionServiceOptions: ExecutionServiceOptions<Service>;\n options?: SimulationUserOptions;\n };\n\nexport type InstalledSnap = {\n snapId: SnapId;\n store: Store;\n executionService: InstanceType<typeof AbstractExecutionService>;\n controllerMessenger: Messenger<ActionConstraint, EventConstraint>;\n runSaga: RunSagaFunction;\n};\n\nexport type RestrictedMiddlewareHooks = {\n /**\n * A hook that returns the user's secret recovery phrase.\n *\n * @param source - The entropy source to get the mnemonic from.\n * @returns The user's secret recovery phrase.\n */\n getMnemonic: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * A hook that returns the seed derived from the user's secret recovery phrase.\n *\n * @param source - The entropy source to get the seed from.\n * @returns The seed.\n */\n getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * A hook that returns whether the client is locked or not.\n *\n * @returns A boolean flag signaling whether the client is locked.\n */\n getIsLocked: () => boolean;\n\n /**\n * Get the cryptographic functions to use for the client. This may return an\n * empty object to fall back to the default cryptographic functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions;\n};\n\nexport type PermittedMiddlewareHooks = {\n /**\n * A hook that gets whether the requesting origin has a given permission.\n *\n * @param permissionName - The name of the permission to check.\n * @returns Whether the origin has the permission.\n */\n hasPermission: (permissionName: string) => boolean;\n\n /**\n * A hook that returns the entropy sources available to the Snap.\n *\n * @returns The entropy sources available to the Snap.\n */\n getEntropySources: () => EntropySource[];\n\n /**\n * A hook that returns a promise that resolves once the extension is unlocked.\n *\n * @param shouldShowUnlockRequest - Whether to show the unlock request.\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n\n /**\n * A hook that returns whether the client is locked or not.\n *\n * @returns A boolean flag signaling whether the client is locked.\n */\n getIsLocked: () => boolean;\n\n /**\n * A hook that returns whether the client is active or not.\n *\n * @returns A boolean flag signaling whether the client is opened.\n */\n getIsActive: () => boolean;\n\n /**\n * A hook that returns the Snap's auxiliary file for the given path. This hook\n * is bound to the Snap ID.\n *\n * @param path - The path of the auxiliary file to get.\n * @param encoding - The encoding to use when returning the file.\n * @returns The Snap's auxiliary file for the given path.\n */\n getSnapFile: (\n path: string,\n encoding: AuxiliaryFileEncoding,\n ) => Promise<string | null>;\n\n /**\n * A hook that gets the state of the Snap. This hook is bound to the Snap ID.\n *\n * @param encrypted - Whether to get the encrypted or unencrypted state.\n * @returns The current state of the Snap.\n */\n getSnapState: (encrypted: boolean) => Promise<Record<string, Json>>;\n\n /**\n * A hook that updates the state of the Snap. This hook is bound to the Snap\n * ID.\n *\n * @param newState - The new state.\n * @param encrypted - Whether to update the encrypted or unencrypted state.\n */\n updateSnapState: (\n newState: Record<string, Json>,\n encrypted: boolean,\n ) => Promise<void>;\n\n /**\n * A hook that clears the state of the Snap. This hook is bound to the Snap\n * ID.\n *\n * @param encrypted - Whether to clear the encrypted or unencrypted state.\n */\n clearSnapState: (encrypted: boolean) => Promise<void>;\n\n /**\n * A hook that creates an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param content - The content of the interface.\n * @param context - The context of the interface.\n * @returns The ID of the created interface.\n */\n createInterface: (\n content: Component,\n context?: InterfaceContext,\n ) => Promise<string>;\n\n /**\n * A hook that updates an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param id - The ID of the interface to update.\n * @param content - The content of the interface.\n */\n updateInterface: (id: string, content: Component) => Promise<void>;\n\n /**\n * A hook that gets the state of an interface for the Snap. This hook is bound\n * to the Snap ID.\n *\n * @param id - The ID of the interface to get.\n * @returns The state of the interface.\n */\n getInterfaceState: (id: string) => InterfaceState;\n\n /**\n * A hook that gets the context of an interface for the Snap. This hook is\n * bound to the Snap ID.\n *\n * @param id - The ID of the interface to get.\n * @returns The context of the interface.\n */\n getInterfaceContext: (id: string) => InterfaceContext | null;\n\n /**\n * A hook that resolves an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param id - The ID of the interface to resolve.\n * @param value - The value to resolve the interface with.\n */\n resolveInterface: (id: string, value: Json) => Promise<void>;\n};\n\n/**\n * Install a Snap in a simulated environment. This will fetch the Snap files,\n * create a Redux store, set up the controllers and JSON-RPC stack, register the\n * Snap, and run the Snap code in the execution service.\n *\n * @param snapId - The ID of the Snap to install.\n * @param options - The options to use when installing the Snap.\n * @param options.executionService - The execution service to use.\n * @param options.executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @param options.options - The simulation options.\n * @returns The installed Snap object.\n * @template Service - The type of the execution service.\n */\nexport async function installSnap<\n Service extends new (\n ...args: any[]\n ) => InstanceType<typeof AbstractExecutionService>,\n>(\n snapId: SnapId,\n {\n executionService,\n executionServiceOptions,\n options: rawOptions = {},\n }: Partial<InstallSnapOptions<Service>> = {},\n): Promise<InstalledSnap & SnapHelpers> {\n const options = getOptions(rawOptions);\n\n // Fetch Snap files.\n const location = detectSnapLocation(snapId, {\n allowLocal: true,\n });\n\n const snapFiles = await fetchSnap(snapId, location);\n\n // Create Redux store.\n const { store, runSaga } = createStore(options);\n\n const controllerMessenger = new Messenger<any, any>();\n\n registerActions(controllerMessenger, runSaga, options, snapId);\n\n // Set up controllers and JSON-RPC stack.\n const restrictedHooks = getRestrictedHooks(options);\n const permittedHooks = getPermittedHooks(\n snapId,\n snapFiles,\n controllerMessenger,\n runSaga,\n );\n\n const { subjectMetadataController, permissionController } = getControllers({\n controllerMessenger,\n hooks: restrictedHooks,\n runSaga,\n options,\n });\n\n const engine = createJsonRpcEngine({\n store,\n restrictedHooks,\n permittedHooks,\n permissionMiddleware: permissionController.createPermissionMiddleware({\n origin: snapId,\n }),\n });\n\n // Create execution service.\n const ExecutionService = executionService ?? NodeThreadExecutionService;\n const service = new ExecutionService({\n ...executionServiceOptions,\n messenger: controllerMessenger.getRestricted({\n name: 'ExecutionService',\n allowedActions: [],\n allowedEvents: [],\n }),\n setupSnapProvider: (_snapId: string, rpcStream: Duplex) => {\n const mux = setupMultiplex(rpcStream, 'snapStream');\n const stream = mux.createStream('metamask-provider');\n const providerStream = createEngineStream({ engine });\n\n // Error function is difficult to test, so we ignore it.\n /* istanbul ignore next 2 */\n pipeline(stream, providerStream, stream, (error: unknown) => {\n if (error) {\n logError(`Provider stream failure.`, error);\n }\n });\n },\n });\n\n // Register the Snap. This sets up the Snap's permissions and subject\n // metadata.\n await registerSnap(snapId, snapFiles.manifest.result, {\n permissionController,\n subjectMetadataController,\n });\n\n // Run the Snap code in the execution service.\n await service.executeSnap({\n snapId,\n sourceCode: snapFiles.sourceCode.toString('utf8'),\n endowments: await getEndowments(permissionController, snapId),\n });\n\n const helpers = getHelpers({\n snapId,\n store,\n controllerMessenger,\n runSaga,\n executionService: service,\n options,\n });\n\n return {\n snapId,\n store,\n executionService: service,\n controllerMessenger,\n runSaga,\n ...helpers,\n };\n}\n\n/**\n * Get the hooks for the simulation.\n *\n * @param options - The simulation options.\n * @returns The hooks for the simulation.\n */\nexport function getRestrictedHooks(\n options: SimulationOptions,\n): RestrictedMiddlewareHooks {\n return {\n getMnemonic: getGetMnemonicImplementation(options.secretRecoveryPhrase),\n getMnemonicSeed: getGetMnemonicSeedImplementation(\n options.secretRecoveryPhrase,\n ),\n getIsLocked: () => false,\n getClientCryptography: () => ({}),\n };\n}\n\n/**\n * Get the permitted hooks for the simulation.\n *\n * @param snapId - The ID of the Snap.\n * @param snapFiles - The fetched Snap files.\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n * @returns The permitted hooks for the simulation.\n */\nexport function getPermittedHooks(\n snapId: SnapId,\n snapFiles: FetchedSnapFiles,\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n): PermittedMiddlewareHooks {\n return {\n hasPermission: () => true,\n getUnlockPromise: asyncResolve(),\n getIsLocked: () => false,\n getIsActive: () => true,\n\n getSnapFile: async (path: string, encoding: AuxiliaryFileEncoding) =>\n await getSnapFile(snapFiles.auxiliaryFiles, path, encoding),\n\n createInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n ...args,\n ),\n updateInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterface',\n snapId,\n ...args,\n ),\n getInterfaceState: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n ...args,\n ).state,\n getInterfaceContext: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n ...args,\n ).context,\n resolveInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:resolveInterface',\n snapId,\n ...args,\n ),\n\n getEntropySources: getGetEntropySourcesImplementation(),\n getSnapState: getPermittedGetSnapStateMethodImplementation(runSaga),\n updateSnapState: getPermittedUpdateSnapStateMethodImplementation(runSaga),\n clearSnapState: getPermittedClearSnapStateMethodImplementation(runSaga),\n };\n}\n\n/**\n * Register mocked action handlers.\n *\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n * @param options - The simulation options.\n * @param snapId - The ID of the Snap.\n */\nexport function registerActions(\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n options: SimulationOptions,\n snapId: SnapId,\n) {\n controllerMessenger.registerActionHandler(\n 'PhishingController:testOrigin',\n () => ({ result: false, type: PhishingDetectorResultType.All }),\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:getAccountByAddress',\n // @ts-expect-error - This is a partial account with only the necessary\n // data used by the interface controller.\n (address) => {\n const matchingAccount = options.accounts.find(\n (account) => address === account.address,\n );\n\n if (!matchingAccount) {\n return undefined;\n }\n\n return addSnapMetadataToAccount(matchingAccount, snapId);\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:getSelectedMultichainAccount',\n // @ts-expect-error - This is a partial account with only the necessary\n // data used by the interface controller.\n () => {\n const selectedAccount = options.accounts.find(\n (account) => account.selected,\n );\n\n if (!selectedAccount) {\n return undefined;\n }\n\n return addSnapMetadataToAccount(selectedAccount, snapId);\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:listMultichainAccounts',\n\n () =>\n // @ts-expect-error - These are partial accounts with only the necessary\n // data used by the interface controller.\n options.accounts.map((account) =>\n addSnapMetadataToAccount(account, snapId),\n ),\n );\n\n controllerMessenger.registerActionHandler(\n 'MultichainAssetsController:getState',\n () => ({\n // @ts-expect-error - These are partial assets with only the\n // necessary data used by the interface controller.\n assetsMetadata: options.assets,\n accountsAssets: options.accounts.reduce<Record<string, CaipAssetType[]>>(\n (acc, account) => {\n acc[account.id] = account.assets ?? [];\n return acc;\n },\n {},\n ),\n }),\n );\n\n controllerMessenger.registerActionHandler(\n 'ApprovalController:hasRequest',\n (opts) => {\n /**\n * Get the current interface from the store.\n *\n * @yields Selects the current interface from the store.\n * @returns The current interface.\n */\n function* getCurrentInterfaceSaga(): SagaIterator {\n const currentInterface: Interface = yield select(getCurrentInterface);\n return currentInterface;\n }\n\n const currentInterface: Interface | undefined = runSaga(\n getCurrentInterfaceSaga,\n ).result();\n return (\n currentInterface?.type === DIALOG_APPROVAL_TYPES.default &&\n currentInterface?.id === opts?.id\n );\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'ApprovalController:acceptRequest',\n async (_id: string, value: unknown) => {\n await runSaga(resolveWithSaga, value).toPromise();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L,gBAAgB,EAAE,IAAI,KAAK,qBAAqB,CAAC,OAAO;YACxD,gBAAgB,EAAE,EAAE,KAAK,IAAI,EAAE,EAAE,CAClC,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,mBAAmB,CAAC,qBAAqB,CACvC,kCAAkC,EAClC,KAAK,EAAE,GAAW,EAAE,KAAc,EAAE,EAAE;QACpC,MAAM,OAAO,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,SAAS,EAAE,CAAC;QAElD,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n} from '@metamask/base-controller';\nimport { Messenger } from '@metamask/base-controller';\nimport { createEngineStream } from '@metamask/json-rpc-middleware-stream';\nimport type { CryptographicFunctions } from '@metamask/key-tree';\nimport { PhishingDetectorResultType } from '@metamask/phishing-controller';\nimport type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport {\n detectSnapLocation,\n fetchSnap,\n NodeThreadExecutionService,\n setupMultiplex,\n} from '@metamask/snaps-controllers/node';\nimport { DIALOG_APPROVAL_TYPES } from '@metamask/snaps-rpc-methods';\nimport type {\n TrackEventParams,\n AuxiliaryFileEncoding,\n Component,\n InterfaceState,\n InterfaceContext,\n SnapId,\n EntropySource,\n TraceRequest,\n EndTraceRequest,\n TraceContext,\n} from '@metamask/snaps-sdk';\nimport type { FetchedSnapFiles, Snap } from '@metamask/snaps-utils';\nimport { logError } from '@metamask/snaps-utils';\nimport type { CaipAssetType, Json } from '@metamask/utils';\nimport type { Duplex } from 'readable-stream';\nimport { pipeline } from 'readable-stream';\nimport type { SagaIterator } from 'redux-saga';\nimport { select } from 'redux-saga/effects';\n\nimport type { RootControllerMessenger } from './controllers';\nimport { getControllers, registerSnap } from './controllers';\nimport { getSnapFile } from './files';\nimport type { SnapHelpers } from './helpers';\nimport { getHelpers } from './helpers';\nimport { resolveWithSaga } from './interface';\nimport { asyncResolve, getEndowments } from './methods';\nimport {\n getPermittedClearSnapStateMethodImplementation,\n getPermittedGetSnapStateMethodImplementation,\n getPermittedUpdateSnapStateMethodImplementation,\n getGetEntropySourcesImplementation,\n getGetMnemonicImplementation,\n getGetSnapImplementation,\n getTrackEventImplementation,\n getTrackErrorImplementation,\n getEndTraceImplementation,\n getStartTraceImplementation,\n} from './methods/hooks';\nimport { getGetMnemonicSeedImplementation } from './methods/hooks/get-mnemonic-seed';\nimport { createJsonRpcEngine } from './middleware';\nimport type { SimulationOptions, SimulationUserOptions } from './options';\nimport { getOptions } from './options';\nimport type { Interface, RunSagaFunction, Store } from './store';\nimport { createStore, getCurrentInterface } from './store';\nimport { addSnapMetadataToAccount } from './utils/account';\n\n/**\n * Options for the execution service, without the options that are shared\n * between all execution services.\n *\n * @template Service - The type of the execution service, i.e., the class that\n * creates the execution service.\n */\nexport type ExecutionServiceOptions<\n Service extends new (...args: any[]) => any,\n> = Omit<\n ConstructorParameters<Service>[0],\n keyof ConstructorParameters<typeof AbstractExecutionService<unknown>>[0]\n>;\n\n/**\n * The options for running a Snap in a simulated environment.\n *\n * @property executionService - The execution service to use.\n * @property executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @property options - The simulation options.\n * @template Service - The type of the execution service.\n */\nexport type InstallSnapOptions<\n Service extends new (\n ...args: any[]\n ) => InstanceType<typeof AbstractExecutionService<unknown>>,\n> =\n ExecutionServiceOptions<Service> extends Record<string, never>\n ? {\n executionService: Service;\n executionServiceOptions?: ExecutionServiceOptions<Service>;\n options?: SimulationUserOptions;\n }\n : {\n executionService: Service;\n executionServiceOptions: ExecutionServiceOptions<Service>;\n options?: SimulationUserOptions;\n };\n\nexport type InstalledSnap = {\n snapId: SnapId;\n store: Store;\n executionService: InstanceType<typeof AbstractExecutionService>;\n controllerMessenger: Messenger<ActionConstraint, EventConstraint>;\n runSaga: RunSagaFunction;\n};\n\nexport type RestrictedMiddlewareHooks = {\n /**\n * A hook that returns the user's secret recovery phrase.\n *\n * @param source - The entropy source to get the mnemonic from.\n * @returns The user's secret recovery phrase.\n */\n getMnemonic: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * A hook that returns the seed derived from the user's secret recovery phrase.\n *\n * @param source - The entropy source to get the seed from.\n * @returns The seed.\n */\n getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * A hook that returns whether the client is locked or not.\n *\n * @returns A boolean flag signaling whether the client is locked.\n */\n getIsLocked: () => boolean;\n\n /**\n * Get the cryptographic functions to use for the client. This may return an\n * empty object to fall back to the default cryptographic functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions;\n};\n\nexport type PermittedMiddlewareHooks = {\n /**\n * A hook that gets whether the requesting origin has a given permission.\n *\n * @param permissionName - The name of the permission to check.\n * @returns Whether the origin has the permission.\n */\n hasPermission: (permissionName: string) => boolean;\n\n /**\n * A hook that returns the entropy sources available to the Snap.\n *\n * @returns The entropy sources available to the Snap.\n */\n getEntropySources: () => EntropySource[];\n\n /**\n * A hook that returns a promise that resolves once the extension is unlocked.\n *\n * @param shouldShowUnlockRequest - Whether to show the unlock request.\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n\n /**\n * A hook that returns whether the client is locked or not.\n *\n * @returns A boolean flag signaling whether the client is locked.\n */\n getIsLocked: () => boolean;\n\n /**\n * A hook that returns whether the client is active or not.\n *\n * @returns A boolean flag signaling whether the client is opened.\n */\n getIsActive: () => boolean;\n\n /**\n * A hook that returns the Snap's auxiliary file for the given path. This hook\n * is bound to the Snap ID.\n *\n * @param path - The path of the auxiliary file to get.\n * @param encoding - The encoding to use when returning the file.\n * @returns The Snap's auxiliary file for the given path.\n */\n getSnapFile: (\n path: string,\n encoding: AuxiliaryFileEncoding,\n ) => Promise<string | null>;\n\n /**\n * A hook that gets the state of the Snap. This hook is bound to the Snap ID.\n *\n * @param encrypted - Whether to get the encrypted or unencrypted state.\n * @returns The current state of the Snap.\n */\n getSnapState: (encrypted: boolean) => Promise<Record<string, Json>>;\n\n /**\n * A hook that updates the state of the Snap. This hook is bound to the Snap\n * ID.\n *\n * @param newState - The new state.\n * @param encrypted - Whether to update the encrypted or unencrypted state.\n */\n updateSnapState: (\n newState: Record<string, Json>,\n encrypted: boolean,\n ) => Promise<void>;\n\n /**\n * A hook that clears the state of the Snap. This hook is bound to the Snap\n * ID.\n *\n * @param encrypted - Whether to clear the encrypted or unencrypted state.\n */\n clearSnapState: (encrypted: boolean) => Promise<void>;\n\n /**\n * A hook that creates an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param content - The content of the interface.\n * @param context - The context of the interface.\n * @returns The ID of the created interface.\n */\n createInterface: (\n content: Component,\n context?: InterfaceContext,\n ) => Promise<string>;\n\n /**\n * A hook that updates an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param id - The ID of the interface to update.\n * @param content - The content of the interface.\n */\n updateInterface: (id: string, content: Component) => Promise<void>;\n\n /**\n * A hook that gets the state of an interface for the Snap. This hook is bound\n * to the Snap ID.\n *\n * @param id - The ID of the interface to get.\n * @returns The state of the interface.\n */\n getInterfaceState: (id: string) => InterfaceState;\n\n /**\n * A hook that gets the context of an interface for the Snap. This hook is\n * bound to the Snap ID.\n *\n * @param id - The ID of the interface to get.\n * @returns The context of the interface.\n */\n getInterfaceContext: (id: string) => InterfaceContext | null;\n\n /**\n * A hook that resolves an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param id - The ID of the interface to resolve.\n * @param value - The value to resolve the interface with.\n */\n resolveInterface: (id: string, value: Json) => Promise<void>;\n\n /**\n * A hook that gets the Snap's metadata.\n *\n * @param snapId - The ID of the Snap to get.\n * @returns The Snap's metadata.\n */\n getSnap(snapId: string): Snap;\n\n /**\n * A hook that tracks an error.\n *\n * @param error - The error object containing error details and properties.\n */\n trackError(error: Error): void;\n\n /**\n * A hook that tracks an event.\n *\n * @param event - The event object containing event details and properties.\n */\n trackEvent(event: TrackEventParams['event']): void;\n\n /**\n * A hook that starts a performance trace.\n *\n * @param request - The trace request object containing trace details.\n */\n startTrace(request: TraceRequest): TraceContext;\n\n /**\n * A hook that ends a performance trace.\n *\n * @param request - The trace request object containing trace details.\n * @returns The trace data.\n */\n endTrace(request: EndTraceRequest): void;\n};\n\n/**\n * Install a Snap in a simulated environment. This will fetch the Snap files,\n * create a Redux store, set up the controllers and JSON-RPC stack, register the\n * Snap, and run the Snap code in the execution service.\n *\n * @param snapId - The ID of the Snap to install.\n * @param options - The options to use when installing the Snap.\n * @param options.executionService - The execution service to use.\n * @param options.executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @param options.options - The simulation options.\n * @returns The installed Snap object.\n * @template Service - The type of the execution service.\n */\nexport async function installSnap<\n Service extends new (\n ...args: any[]\n ) => InstanceType<typeof AbstractExecutionService>,\n>(\n snapId: SnapId,\n {\n executionService,\n executionServiceOptions,\n options: rawOptions = {},\n }: Partial<InstallSnapOptions<Service>> = {},\n): Promise<InstalledSnap & SnapHelpers> {\n const options = getOptions(rawOptions);\n\n // Fetch Snap files.\n const location = detectSnapLocation(snapId, {\n allowLocal: true,\n });\n\n const snapFiles = await fetchSnap(snapId, location);\n\n // Create Redux store.\n const { store, runSaga } = createStore(options);\n\n const controllerMessenger = new Messenger<any, any>();\n\n registerActions(controllerMessenger, runSaga, options, snapId);\n\n // Set up controllers and JSON-RPC stack.\n const restrictedHooks = getRestrictedHooks(options);\n const permittedHooks = getPermittedHooks(\n snapId,\n snapFiles,\n controllerMessenger,\n runSaga,\n );\n\n const { subjectMetadataController, permissionController } = getControllers({\n controllerMessenger,\n hooks: restrictedHooks,\n runSaga,\n options,\n });\n\n const engine = createJsonRpcEngine({\n store,\n restrictedHooks,\n permittedHooks,\n permissionMiddleware: permissionController.createPermissionMiddleware({\n origin: snapId,\n }),\n });\n\n // Create execution service.\n const ExecutionService = executionService ?? NodeThreadExecutionService;\n const service = new ExecutionService({\n ...executionServiceOptions,\n messenger: controllerMessenger.getRestricted({\n name: 'ExecutionService',\n allowedActions: [],\n allowedEvents: [],\n }),\n setupSnapProvider: (_snapId: string, rpcStream: Duplex) => {\n const mux = setupMultiplex(rpcStream, 'snapStream');\n const stream = mux.createStream('metamask-provider');\n const providerStream = createEngineStream({ engine });\n\n // Error function is difficult to test, so we ignore it.\n /* istanbul ignore next 2 */\n pipeline(stream, providerStream, stream, (error) => {\n if (error && !error.message?.match('Premature close')) {\n logError(`Provider stream failure.`, error);\n }\n });\n },\n });\n\n // Register the Snap. This sets up the Snap's permissions and subject\n // metadata.\n await registerSnap(snapId, snapFiles.manifest.result, {\n permissionController,\n subjectMetadataController,\n });\n\n // Run the Snap code in the execution service.\n await service.executeSnap({\n snapId,\n sourceCode: snapFiles.sourceCode.toString('utf8'),\n endowments: await getEndowments(permissionController, snapId),\n });\n\n const helpers = getHelpers({\n snapId,\n store,\n controllerMessenger,\n runSaga,\n executionService: service,\n options,\n });\n\n return {\n snapId,\n store,\n executionService: service,\n controllerMessenger,\n runSaga,\n ...helpers,\n };\n}\n\n/**\n * Get the hooks for the simulation.\n *\n * @param options - The simulation options.\n * @returns The hooks for the simulation.\n */\nexport function getRestrictedHooks(\n options: SimulationOptions,\n): RestrictedMiddlewareHooks {\n return {\n getMnemonic: getGetMnemonicImplementation(options.secretRecoveryPhrase),\n getMnemonicSeed: getGetMnemonicSeedImplementation(\n options.secretRecoveryPhrase,\n ),\n getIsLocked: () => false,\n getClientCryptography: () => ({}),\n };\n}\n\n/**\n * Get the permitted hooks for the simulation.\n *\n * @param snapId - The ID of the Snap.\n * @param snapFiles - The fetched Snap files.\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n * @returns The permitted hooks for the simulation.\n */\nexport function getPermittedHooks(\n snapId: SnapId,\n snapFiles: FetchedSnapFiles,\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n): PermittedMiddlewareHooks {\n return {\n hasPermission: () => true,\n getUnlockPromise: asyncResolve(),\n getIsLocked: () => false,\n getIsActive: () => true,\n\n getSnapFile: async (path: string, encoding: AuxiliaryFileEncoding) =>\n await getSnapFile(snapFiles.auxiliaryFiles, path, encoding),\n\n createInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n ...args,\n ),\n updateInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterface',\n snapId,\n ...args,\n ),\n getInterfaceState: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n ...args,\n ).state,\n getInterfaceContext: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n ...args,\n ).context,\n resolveInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:resolveInterface',\n snapId,\n ...args,\n ),\n\n getEntropySources: getGetEntropySourcesImplementation(),\n getSnapState: getPermittedGetSnapStateMethodImplementation(runSaga),\n updateSnapState: getPermittedUpdateSnapStateMethodImplementation(runSaga),\n clearSnapState: getPermittedClearSnapStateMethodImplementation(runSaga),\n\n getSnap: getGetSnapImplementation(true),\n trackError: getTrackErrorImplementation(runSaga),\n trackEvent: getTrackEventImplementation(runSaga),\n startTrace: getStartTraceImplementation(runSaga),\n endTrace: getEndTraceImplementation(runSaga),\n };\n}\n\n/**\n * Register mocked action handlers.\n *\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n * @param options - The simulation options.\n * @param snapId - The ID of the Snap.\n */\nexport function registerActions(\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n options: SimulationOptions,\n snapId: SnapId,\n) {\n controllerMessenger.registerActionHandler(\n 'PhishingController:testOrigin',\n () => ({ result: false, type: PhishingDetectorResultType.All }),\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:getAccountByAddress',\n // @ts-expect-error - This is a partial account with only the necessary\n // data used by the interface controller.\n (address) => {\n const matchingAccount = options.accounts.find(\n (account) => address === account.address,\n );\n\n if (!matchingAccount) {\n return undefined;\n }\n\n return addSnapMetadataToAccount(matchingAccount, snapId);\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:getSelectedMultichainAccount',\n // @ts-expect-error - This is a partial account with only the necessary\n // data used by the interface controller.\n () => {\n const selectedAccount = options.accounts.find(\n (account) => account.selected,\n );\n\n if (!selectedAccount) {\n return undefined;\n }\n\n return addSnapMetadataToAccount(selectedAccount, snapId);\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:listMultichainAccounts',\n\n () =>\n // @ts-expect-error - These are partial accounts with only the necessary\n // data used by the interface controller.\n options.accounts.map((account) =>\n addSnapMetadataToAccount(account, snapId),\n ),\n );\n\n controllerMessenger.registerActionHandler(\n 'MultichainAssetsController:getState',\n () => ({\n // @ts-expect-error - These are partial assets with only the\n // necessary data used by the interface controller.\n assetsMetadata: options.assets,\n accountsAssets: options.accounts.reduce<Record<string, CaipAssetType[]>>(\n (acc, account) => {\n acc[account.id] = account.assets ?? [];\n return acc;\n },\n {},\n ),\n }),\n );\n\n controllerMessenger.registerActionHandler(\n 'ApprovalController:hasRequest',\n (opts) => {\n /**\n * Get the current interface from the store.\n *\n * @yields Selects the current interface from the store.\n * @returns The current interface.\n */\n function* getCurrentInterfaceSaga(): SagaIterator {\n const currentInterface: Interface = yield select(getCurrentInterface);\n return currentInterface;\n }\n\n const currentInterface: Interface | undefined = runSaga(\n getCurrentInterfaceSaga,\n ).result();\n return (\n currentInterface?.type === DIALOG_APPROVAL_TYPES.default &&\n currentInterface?.id === opts?.id\n );\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'ApprovalController:acceptRequest',\n async (_id: string, value: unknown) => {\n await runSaga(resolveWithSaga, value).toPromise();\n\n return { value };\n },\n );\n}\n"]}
|
package/dist/store/index.cjs
CHANGED
|
@@ -18,5 +18,6 @@ __exportStar(require("./mocks.cjs"), exports);
|
|
|
18
18
|
__exportStar(require("./notifications.cjs"), exports);
|
|
19
19
|
__exportStar(require("./state.cjs"), exports);
|
|
20
20
|
__exportStar(require("./store.cjs"), exports);
|
|
21
|
+
__exportStar(require("./trackables.cjs"), exports);
|
|
21
22
|
__exportStar(require("./ui.cjs"), exports);
|
|
22
23
|
//# sourceMappingURL=index.cjs.map
|
package/dist/store/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAAwB;AACxB,sDAAgC;AAChC,8CAAwB;AACxB,8CAAwB;AACxB,2CAAqB","sourcesContent":["export * from './mocks';\nexport * from './notifications';\nexport * from './state';\nexport * from './store';\nexport * from './ui';\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAAwB;AACxB,sDAAgC;AAChC,8CAAwB;AACxB,8CAAwB;AACxB,mDAA6B;AAC7B,2CAAqB","sourcesContent":["export * from './mocks';\nexport * from './notifications';\nexport * from './state';\nexport * from './store';\nexport * from './trackables';\nexport * from './ui';\n"]}
|
package/dist/store/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,oCAAgC;AAChC,4BAAwB;AACxB,4BAAwB;AACxB,yBAAqB"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,oCAAgC;AAChC,4BAAwB;AACxB,4BAAwB;AACxB,iCAA6B;AAC7B,yBAAqB"}
|
package/dist/store/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,oCAAgC;AAChC,4BAAwB;AACxB,4BAAwB;AACxB,yBAAqB"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,oCAAgC;AAChC,4BAAwB;AACxB,4BAAwB;AACxB,iCAA6B;AAC7B,yBAAqB"}
|
package/dist/store/index.mjs
CHANGED
package/dist/store/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,oCAAgC;AAChC,4BAAwB;AACxB,4BAAwB;AACxB,yBAAqB","sourcesContent":["export * from './mocks';\nexport * from './notifications';\nexport * from './state';\nexport * from './store';\nexport * from './ui';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,oCAAgC;AAChC,4BAAwB;AACxB,4BAAwB;AACxB,iCAA6B;AAC7B,yBAAqB","sourcesContent":["export * from './mocks';\nexport * from './notifications';\nexport * from './state';\nexport * from './store';\nexport * from './trackables';\nexport * from './ui';\n"]}
|
package/dist/store/mocks.d.cts
CHANGED
|
@@ -27,6 +27,7 @@ export declare const getJsonRpcMock: ((state: {
|
|
|
27
27
|
mocks: MocksState;
|
|
28
28
|
notifications: import("./notifications.cjs").NotificationsState;
|
|
29
29
|
state: import("./state.cjs").State;
|
|
30
|
+
trackables: import("./trackables.cjs").TrackablesState;
|
|
30
31
|
ui: import("./ui.cjs").UiState;
|
|
31
32
|
}, method: string) => Json) & import("reselect").OutputSelectorFields<(args_0: Record<string, Json>, args_1: string) => Json, {
|
|
32
33
|
clearCache: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.d.cts","sourceRoot":"","sources":["../../src/store/mocks.ts"],"names":[],"mappings":"AAAA,OAAO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ACH,eAAO,MAAM,cAAc;;;;;;;;;;CAI1B,CAAC"}
|
package/dist/store/mocks.d.mts
CHANGED
|
@@ -27,6 +27,7 @@ export declare const getJsonRpcMock: ((state: {
|
|
|
27
27
|
mocks: MocksState;
|
|
28
28
|
notifications: import("./notifications.mjs").NotificationsState;
|
|
29
29
|
state: import("./state.mjs").State;
|
|
30
|
+
trackables: import("./trackables.mjs").TrackablesState;
|
|
30
31
|
ui: import("./ui.mjs").UiState;
|
|
31
32
|
}, method: string) => Json) & import("reselect").OutputSelectorFields<(args_0: Record<string, Json>, args_1: string) => Json, {
|
|
32
33
|
clearCache: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.d.mts","sourceRoot":"","sources":["../../src/store/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAGtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAgB;AAEhD,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,IAAI,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CAC/B,CAAC;AASF,eAAO,MAAM,UAAU;gGAIa,cAAc,WAAW,CAAC;mGAKvB,cAAc,MAAM,CAAC;WAI1D,CAAC;AAEH,eAAO,MAAQ,cAAc,4FAAE,iBAAiB,wFAAuB,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UAAW,gBAAgB,yBAAwB,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"mocks.d.mts","sourceRoot":"","sources":["../../src/store/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAGtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAgB;AAEhD,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,IAAI,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CAC/B,CAAC;AASF,eAAO,MAAM,UAAU;gGAIa,cAAc,WAAW,CAAC;mGAKvB,cAAc,MAAM,CAAC;WAI1D,CAAC;AAEH,eAAO,MAAQ,cAAc,4FAAE,iBAAiB,wFAAuB,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UAAW,gBAAgB,yBAAwB,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;CAI1B,CAAC"}
|
|
@@ -45,6 +45,7 @@ export declare const getNotifications: ((state: {
|
|
|
45
45
|
mocks: import("./mocks.cjs").MocksState;
|
|
46
46
|
notifications: NotificationsState;
|
|
47
47
|
state: import("./state.cjs").State;
|
|
48
|
+
trackables: import("./trackables.cjs").TrackablesState;
|
|
48
49
|
ui: import("./ui.cjs").UiState;
|
|
49
50
|
}) => Notification[]) & import("reselect").OutputSelectorFields<(args_0: NotificationsState) => Notification[], {
|
|
50
51
|
clearCache: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.d.cts","sourceRoot":"","sources":["../../src/store/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,4BAA4B;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAKtD;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf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AAM,gBAAgB;;;;;;;;;;CAG5B,CAAC"}
|
|
@@ -45,6 +45,7 @@ export declare const getNotifications: ((state: {
|
|
|
45
45
|
mocks: import("./mocks.mjs").MocksState;
|
|
46
46
|
notifications: NotificationsState;
|
|
47
47
|
state: import("./state.mjs").State;
|
|
48
|
+
trackables: import("./trackables.mjs").TrackablesState;
|
|
48
49
|
ui: import("./ui.mjs").UiState;
|
|
49
50
|
}) => Notification[]) & import("reselect").OutputSelectorFields<(args_0: NotificationsState) => Notification[], {
|
|
50
51
|
clearCache: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.d.mts","sourceRoot":"","sources":["../../src/store/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,4BAA4B;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAKtD;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,aAAa,EAAE,YAAY,EAAE,CAAC;CAC/B,CAAC;AASF,eAAO,MAAM,kBAAkB;yGAIM,cAAc,YAAY,CAAC;4GAGxB,cAAc,MAAM,CAAC;;mBAS3D,CAAC;AAEH,eAAO,MAAQ,eAAe,sGAAE,kBAAkB,mGAAE,kBAAkB,4FAC1C,CAAC;AAE7B;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"notifications.d.mts","sourceRoot":"","sources":["../../src/store/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,4BAA4B;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAKtD;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,aAAa,EAAE,YAAY,EAAE,CAAC;CAC/B,CAAC;AASF,eAAO,MAAM,kBAAkB;yGAIM,cAAc,YAAY,CAAC;4GAGxB,cAAc,MAAM,CAAC;;mBAS3D,CAAC;AAEH,eAAO,MAAQ,eAAe,sGAAE,kBAAkB,mGAAE,kBAAkB,4FAC1C,CAAC;AAE7B;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;CAG5B,CAAC"}
|
package/dist/store/state.d.cts
CHANGED
|
@@ -42,11 +42,13 @@ export declare function getState(encrypted: boolean): ((state: {
|
|
|
42
42
|
mocks: import("./mocks.cjs").MocksState;
|
|
43
43
|
notifications: import("./notifications.cjs").NotificationsState;
|
|
44
44
|
state: State;
|
|
45
|
+
trackables: import("./trackables.cjs").TrackablesState;
|
|
45
46
|
ui: import("./ui.cjs").UiState;
|
|
46
47
|
}) => string | null) & import("reselect").OutputSelectorFields<(args_0: {
|
|
47
48
|
mocks: import("./mocks.cjs").MocksState;
|
|
48
49
|
notifications: import("./notifications.cjs").NotificationsState;
|
|
49
50
|
state: State;
|
|
51
|
+
trackables: import("./trackables.cjs").TrackablesState;
|
|
50
52
|
ui: import("./ui.cjs").UiState;
|
|
51
53
|
}) => string | null, {
|
|
52
54
|
clearCache: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.cts","sourceRoot":"","sources":["../../src/store/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAKtD;;;;;;;GAOG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAUF;;GAEG;AACH,eAAO,MAAM,UAAU;;;mBAMc,MAAM,GAAG,IAAI;uBAAa,OAAO;;;;uFAUtC,cAAc;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;WAUnE,CAAC;AAEH,eAAO,MAAQ,QAAQ;WAtBc,MAAM,GAAG,IAAI;eAAa,OAAO;sBAsB7C,UAAU;eAZwB,OAAO;sBAYR,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,OAAO
|
|
1
|
+
{"version":3,"file":"state.d.cts","sourceRoot":"","sources":["../../src/store/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAKtD;;;;;;;GAOG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAUF;;GAEG;AACH,eAAO,MAAM,UAAU;;;mBAMc,MAAM,GAAG,IAAI;uBAAa,OAAO;;;;uFAUtC,cAAc;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;WAUnE,CAAC;AAEH,eAAO,MAAQ,QAAQ;WAtBc,MAAM,GAAG,IAAI;eAAa,OAAO;sBAsB7C,UAAU;eAZwB,OAAO;sBAYR,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,OAAO;;;;;;;;;;;;;;;;EAW1C"}
|
package/dist/store/state.d.mts
CHANGED
|
@@ -42,11 +42,13 @@ export declare function getState(encrypted: boolean): ((state: {
|
|
|
42
42
|
mocks: import("./mocks.mjs").MocksState;
|
|
43
43
|
notifications: import("./notifications.mjs").NotificationsState;
|
|
44
44
|
state: State;
|
|
45
|
+
trackables: import("./trackables.mjs").TrackablesState;
|
|
45
46
|
ui: import("./ui.mjs").UiState;
|
|
46
47
|
}) => string | null) & import("reselect").OutputSelectorFields<(args_0: {
|
|
47
48
|
mocks: import("./mocks.mjs").MocksState;
|
|
48
49
|
notifications: import("./notifications.mjs").NotificationsState;
|
|
49
50
|
state: State;
|
|
51
|
+
trackables: import("./trackables.mjs").TrackablesState;
|
|
50
52
|
ui: import("./ui.mjs").UiState;
|
|
51
53
|
}) => string | null, {
|
|
52
54
|
clearCache: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.mts","sourceRoot":"","sources":["../../src/store/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAKtD;;;;;;;GAOG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAUF;;GAEG;AACH,eAAO,MAAM,UAAU;;;mBAMc,MAAM,GAAG,IAAI;uBAAa,OAAO;;;;uFAUtC,cAAc;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;WAUnE,CAAC;AAEH,eAAO,MAAQ,QAAQ;WAtBc,MAAM,GAAG,IAAI;eAAa,OAAO;sBAsB7C,UAAU;eAZwB,OAAO;sBAYR,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,OAAO
|
|
1
|
+
{"version":3,"file":"state.d.mts","sourceRoot":"","sources":["../../src/store/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAKtD;;;;;;;GAOG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAUF;;GAEG;AACH,eAAO,MAAM,UAAU;;;mBAMc,MAAM,GAAG,IAAI;uBAAa,OAAO;;;;uFAUtC,cAAc;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;WAUnE,CAAC;AAEH,eAAO,MAAQ,QAAQ;WAtBc,MAAM,GAAG,IAAI;eAAa,OAAO;sBAsB7C,UAAU;eAZwB,OAAO;sBAYR,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,OAAO;;;;;;;;;;;;;;;;EAW1C"}
|
package/dist/store/store.cjs
CHANGED
|
@@ -9,6 +9,7 @@ const redux_saga_1 = __importDefault(require("redux-saga"));
|
|
|
9
9
|
const mocks_1 = require("./mocks.cjs");
|
|
10
10
|
const notifications_1 = require("./notifications.cjs");
|
|
11
11
|
const state_1 = require("./state.cjs");
|
|
12
|
+
const trackables_1 = require("./trackables.cjs");
|
|
12
13
|
const ui_1 = require("./ui.cjs");
|
|
13
14
|
/**
|
|
14
15
|
* Create a Redux store.
|
|
@@ -25,6 +26,7 @@ function createStore({ state, unencryptedState }) {
|
|
|
25
26
|
mocks: mocks_1.mocksSlice.reducer,
|
|
26
27
|
notifications: notifications_1.notificationsSlice.reducer,
|
|
27
28
|
state: state_1.stateSlice.reducer,
|
|
29
|
+
trackables: trackables_1.trackablesSlice.reducer,
|
|
28
30
|
ui: ui_1.uiSlice.reducer,
|
|
29
31
|
},
|
|
30
32
|
middleware: (getDefaultMiddleware) => getDefaultMiddleware({ thunk: false }).concat(sagaMiddleware),
|
package/dist/store/store.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.cjs","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAkD;AAClD,4DAA8C;AAE9C,uCAAqC;AACrC,uDAAqD;AACrD,uCAA+C;AAC/C,iCAA+B;AAG/B;;;;;;;GAOG;AACH,SAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAqB;IACxE,MAAM,cAAc,GAAG,IAAA,oBAAoB,GAAE,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAA,wBAAc,EAAC;QAC3B,OAAO,EAAE;YACP,KAAK,EAAE,kBAAU,CAAC,OAAO;YACzB,aAAa,EAAE,kCAAkB,CAAC,OAAO;YACzC,KAAK,EAAE,kBAAU,CAAC,OAAO;YACzB,EAAE,EAAE,YAAO,CAAC,OAAO;SACpB;QACD,UAAU,EAAE,CAAC,oBAAoB,EAAE,EAAE,CACnC,oBAAoB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;KAChE,CAAC,CAAC;IAEH,kCAAkC;IAClC,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,CAAC,QAAQ,CACZ,IAAA,gBAAQ,EAAC;YACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAC5B,SAAS,EAAE,IAAI;SAChB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,IAAI,gBAAgB,EAAE,CAAC;QACrB,KAAK,CAAC,QAAQ,CACZ,IAAA,gBAAQ,EAAC;YACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;YACvC,SAAS,EAAE,KAAK;SACjB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,OAAO;QACL,KAAK;QACL,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC;KACjD,CAAC;AACJ,CAAC;
|
|
1
|
+
{"version":3,"file":"store.cjs","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAkD;AAClD,4DAA8C;AAE9C,uCAAqC;AACrC,uDAAqD;AACrD,uCAA+C;AAC/C,iDAA+C;AAC/C,iCAA+B;AAG/B;;;;;;;GAOG;AACH,SAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAqB;IACxE,MAAM,cAAc,GAAG,IAAA,oBAAoB,GAAE,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAA,wBAAc,EAAC;QAC3B,OAAO,EAAE;YACP,KAAK,EAAE,kBAAU,CAAC,OAAO;YACzB,aAAa,EAAE,kCAAkB,CAAC,OAAO;YACzC,KAAK,EAAE,kBAAU,CAAC,OAAO;YACzB,UAAU,EAAE,4BAAe,CAAC,OAAO;YACnC,EAAE,EAAE,YAAO,CAAC,OAAO;SACpB;QACD,UAAU,EAAE,CAAC,oBAAoB,EAAE,EAAE,CACnC,oBAAoB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;KAChE,CAAC,CAAC;IAEH,kCAAkC;IAClC,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,CAAC,QAAQ,CACZ,IAAA,gBAAQ,EAAC;YACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAC5B,SAAS,EAAE,IAAI;SAChB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,IAAI,gBAAgB,EAAE,CAAC;QACrB,KAAK,CAAC,QAAQ,CACZ,IAAA,gBAAQ,EAAC;YACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;YACvC,SAAS,EAAE,KAAK;SACjB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,OAAO;QACL,KAAK;QACL,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC;KACjD,CAAC;AACJ,CAAC;AArCD,kCAqCC","sourcesContent":["import { configureStore } from '@reduxjs/toolkit';\nimport createSagaMiddleware from 'redux-saga';\n\nimport { mocksSlice } from './mocks';\nimport { notificationsSlice } from './notifications';\nimport { setState, stateSlice } from './state';\nimport { trackablesSlice } from './trackables';\nimport { uiSlice } from './ui';\nimport type { SimulationOptions } from '../options';\n\n/**\n * Create a Redux store.\n *\n * @param options - The simulation options.\n * @param options.state - The initial state for the Snap.\n * @param options.unencryptedState - The initial unencrypted state for the Snap.\n * @returns A Redux store with the default state.\n */\nexport function createStore({ state, unencryptedState }: SimulationOptions) {\n const sagaMiddleware = createSagaMiddleware();\n const store = configureStore({\n reducer: {\n mocks: mocksSlice.reducer,\n notifications: notificationsSlice.reducer,\n state: stateSlice.reducer,\n trackables: trackablesSlice.reducer,\n ui: uiSlice.reducer,\n },\n middleware: (getDefaultMiddleware) =>\n getDefaultMiddleware({ thunk: false }).concat(sagaMiddleware),\n });\n\n // Set initial state for the Snap.\n if (state) {\n store.dispatch(\n setState({\n state: JSON.stringify(state),\n encrypted: true,\n }),\n );\n }\n\n if (unencryptedState) {\n store.dispatch(\n setState({\n state: JSON.stringify(unencryptedState),\n encrypted: false,\n }),\n );\n }\n\n return {\n store,\n runSaga: sagaMiddleware.run.bind(sagaMiddleware),\n };\n}\n\nexport type Store = ReturnType<typeof createStore>['store'];\nexport type ApplicationState = ReturnType<Store['getState']>;\nexport type RunSagaFunction = ReturnType<typeof createStore>['runSaga'];\n"]}
|
package/dist/store/store.d.cts
CHANGED
|
@@ -12,6 +12,7 @@ export declare function createStore({ state, unencryptedState }: SimulationOptio
|
|
|
12
12
|
mocks: import("./mocks.cjs").MocksState;
|
|
13
13
|
notifications: import("./notifications.cjs").NotificationsState;
|
|
14
14
|
state: import("./state.cjs").State;
|
|
15
|
+
trackables: import("./trackables.cjs").TrackablesState;
|
|
15
16
|
ui: import("./ui.cjs").UiState;
|
|
16
17
|
}, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<[import("redux-saga").SagaMiddleware<object>]>>;
|
|
17
18
|
runSaga: <S extends import("redux-saga").Saga>(saga: S, ...args: Parameters<S>) => import("redux-saga").Task<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.cts","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"store.d.cts","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAmB;AAEpD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,iBAAiB;;;;;;;;;EAqCzE;AAED,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAC7D,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC"}
|
package/dist/store/store.d.mts
CHANGED
|
@@ -12,6 +12,7 @@ export declare function createStore({ state, unencryptedState }: SimulationOptio
|
|
|
12
12
|
mocks: import("./mocks.mjs").MocksState;
|
|
13
13
|
notifications: import("./notifications.mjs").NotificationsState;
|
|
14
14
|
state: import("./state.mjs").State;
|
|
15
|
+
trackables: import("./trackables.mjs").TrackablesState;
|
|
15
16
|
ui: import("./ui.mjs").UiState;
|
|
16
17
|
}, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<[import("redux-saga").SagaMiddleware<object>]>>;
|
|
17
18
|
runSaga: <S extends import("redux-saga").Saga>(saga: S, ...args: Parameters<S>) => import("redux-saga").Task<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.mts","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"store.d.mts","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAmB;AAEpD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,iBAAiB;;;;;;;;;EAqCzE;AAED,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAC7D,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC"}
|
package/dist/store/store.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import createSagaMiddleware from "redux-saga";
|
|
|
4
4
|
import { mocksSlice } from "./mocks.mjs";
|
|
5
5
|
import { notificationsSlice } from "./notifications.mjs";
|
|
6
6
|
import { setState, stateSlice } from "./state.mjs";
|
|
7
|
+
import { trackablesSlice } from "./trackables.mjs";
|
|
7
8
|
import { uiSlice } from "./ui.mjs";
|
|
8
9
|
/**
|
|
9
10
|
* Create a Redux store.
|
|
@@ -20,6 +21,7 @@ export function createStore({ state, unencryptedState }) {
|
|
|
20
21
|
mocks: mocksSlice.reducer,
|
|
21
22
|
notifications: notificationsSlice.reducer,
|
|
22
23
|
state: stateSlice.reducer,
|
|
24
|
+
trackables: trackablesSlice.reducer,
|
|
23
25
|
ui: uiSlice.reducer,
|
|
24
26
|
},
|
|
25
27
|
middleware: (getDefaultMiddleware) => getDefaultMiddleware({ thunk: false }).concat(sagaMiddleware),
|
package/dist/store/store.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.mjs","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":";;AACA,OAAO,oBAAoB,mBAAmB;AAE9C,OAAO,EAAE,UAAU,EAAE,oBAAgB;AACrC,OAAO,EAAE,kBAAkB,EAAE,4BAAwB;AACrD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,oBAAgB;AAC/C,OAAO,EAAE,OAAO,EAAE,iBAAa;AAG/B;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAqB;IACxE,MAAM,cAAc,GAAG,oBAAoB,EAAE,CAAC;IAC9C,MAAM,KAAK,GAAG,cAAc,CAAC;QAC3B,OAAO,EAAE;YACP,KAAK,EAAE,UAAU,CAAC,OAAO;YACzB,aAAa,EAAE,kBAAkB,CAAC,OAAO;YACzC,KAAK,EAAE,UAAU,CAAC,OAAO;YACzB,EAAE,EAAE,OAAO,CAAC,OAAO;SACpB;QACD,UAAU,EAAE,CAAC,oBAAoB,EAAE,EAAE,CACnC,oBAAoB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;KAChE,CAAC,CAAC;IAEH,kCAAkC;IAClC,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,CAAC,QAAQ,CACZ,QAAQ,CAAC;YACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAC5B,SAAS,EAAE,IAAI;SAChB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,IAAI,gBAAgB,EAAE,CAAC;QACrB,KAAK,CAAC,QAAQ,CACZ,QAAQ,CAAC;YACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;YACvC,SAAS,EAAE,KAAK;SACjB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,OAAO;QACL,KAAK;QACL,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC;KACjD,CAAC;AACJ,CAAC","sourcesContent":["import { configureStore } from '@reduxjs/toolkit';\nimport createSagaMiddleware from 'redux-saga';\n\nimport { mocksSlice } from './mocks';\nimport { notificationsSlice } from './notifications';\nimport { setState, stateSlice } from './state';\nimport { uiSlice } from './ui';\nimport type { SimulationOptions } from '../options';\n\n/**\n * Create a Redux store.\n *\n * @param options - The simulation options.\n * @param options.state - The initial state for the Snap.\n * @param options.unencryptedState - The initial unencrypted state for the Snap.\n * @returns A Redux store with the default state.\n */\nexport function createStore({ state, unencryptedState }: SimulationOptions) {\n const sagaMiddleware = createSagaMiddleware();\n const store = configureStore({\n reducer: {\n mocks: mocksSlice.reducer,\n notifications: notificationsSlice.reducer,\n state: stateSlice.reducer,\n ui: uiSlice.reducer,\n },\n middleware: (getDefaultMiddleware) =>\n getDefaultMiddleware({ thunk: false }).concat(sagaMiddleware),\n });\n\n // Set initial state for the Snap.\n if (state) {\n store.dispatch(\n setState({\n state: JSON.stringify(state),\n encrypted: true,\n }),\n );\n }\n\n if (unencryptedState) {\n store.dispatch(\n setState({\n state: JSON.stringify(unencryptedState),\n encrypted: false,\n }),\n );\n }\n\n return {\n store,\n runSaga: sagaMiddleware.run.bind(sagaMiddleware),\n };\n}\n\nexport type Store = ReturnType<typeof createStore>['store'];\nexport type ApplicationState = ReturnType<Store['getState']>;\nexport type RunSagaFunction = ReturnType<typeof createStore>['runSaga'];\n"]}
|
|
1
|
+
{"version":3,"file":"store.mjs","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":";;AACA,OAAO,oBAAoB,mBAAmB;AAE9C,OAAO,EAAE,UAAU,EAAE,oBAAgB;AACrC,OAAO,EAAE,kBAAkB,EAAE,4BAAwB;AACrD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,oBAAgB;AAC/C,OAAO,EAAE,eAAe,EAAE,yBAAqB;AAC/C,OAAO,EAAE,OAAO,EAAE,iBAAa;AAG/B;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAqB;IACxE,MAAM,cAAc,GAAG,oBAAoB,EAAE,CAAC;IAC9C,MAAM,KAAK,GAAG,cAAc,CAAC;QAC3B,OAAO,EAAE;YACP,KAAK,EAAE,UAAU,CAAC,OAAO;YACzB,aAAa,EAAE,kBAAkB,CAAC,OAAO;YACzC,KAAK,EAAE,UAAU,CAAC,OAAO;YACzB,UAAU,EAAE,eAAe,CAAC,OAAO;YACnC,EAAE,EAAE,OAAO,CAAC,OAAO;SACpB;QACD,UAAU,EAAE,CAAC,oBAAoB,EAAE,EAAE,CACnC,oBAAoB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;KAChE,CAAC,CAAC;IAEH,kCAAkC;IAClC,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,CAAC,QAAQ,CACZ,QAAQ,CAAC;YACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAC5B,SAAS,EAAE,IAAI;SAChB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,IAAI,gBAAgB,EAAE,CAAC;QACrB,KAAK,CAAC,QAAQ,CACZ,QAAQ,CAAC;YACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;YACvC,SAAS,EAAE,KAAK;SACjB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,OAAO;QACL,KAAK;QACL,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC;KACjD,CAAC;AACJ,CAAC","sourcesContent":["import { configureStore } from '@reduxjs/toolkit';\nimport createSagaMiddleware from 'redux-saga';\n\nimport { mocksSlice } from './mocks';\nimport { notificationsSlice } from './notifications';\nimport { setState, stateSlice } from './state';\nimport { trackablesSlice } from './trackables';\nimport { uiSlice } from './ui';\nimport type { SimulationOptions } from '../options';\n\n/**\n * Create a Redux store.\n *\n * @param options - The simulation options.\n * @param options.state - The initial state for the Snap.\n * @param options.unencryptedState - The initial unencrypted state for the Snap.\n * @returns A Redux store with the default state.\n */\nexport function createStore({ state, unencryptedState }: SimulationOptions) {\n const sagaMiddleware = createSagaMiddleware();\n const store = configureStore({\n reducer: {\n mocks: mocksSlice.reducer,\n notifications: notificationsSlice.reducer,\n state: stateSlice.reducer,\n trackables: trackablesSlice.reducer,\n ui: uiSlice.reducer,\n },\n middleware: (getDefaultMiddleware) =>\n getDefaultMiddleware({ thunk: false }).concat(sagaMiddleware),\n });\n\n // Set initial state for the Snap.\n if (state) {\n store.dispatch(\n setState({\n state: JSON.stringify(state),\n encrypted: true,\n }),\n );\n }\n\n if (unencryptedState) {\n store.dispatch(\n setState({\n state: JSON.stringify(unencryptedState),\n encrypted: false,\n }),\n );\n }\n\n return {\n store,\n runSaga: sagaMiddleware.run.bind(sagaMiddleware),\n };\n}\n\nexport type Store = ReturnType<typeof createStore>['store'];\nexport type ApplicationState = ReturnType<Store['getState']>;\nexport type RunSagaFunction = ReturnType<typeof createStore>['runSaga'];\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getTraces = exports.getEvents = exports.getErrors = exports.clearTrackables = exports.endTrace = exports.startTrace = exports.trackEvent = exports.trackError = exports.trackablesSlice = void 0;
|
|
5
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
+
const immer_1 = require("immer");
|
|
7
|
+
/**
|
|
8
|
+
* The initial events state.
|
|
9
|
+
*/
|
|
10
|
+
const INITIAL_STATE = {
|
|
11
|
+
events: [],
|
|
12
|
+
errors: [],
|
|
13
|
+
traces: [],
|
|
14
|
+
pendingTraces: [],
|
|
15
|
+
};
|
|
16
|
+
exports.trackablesSlice = (0, toolkit_1.createSlice)({
|
|
17
|
+
name: 'trackables',
|
|
18
|
+
initialState: INITIAL_STATE,
|
|
19
|
+
reducers: {
|
|
20
|
+
trackError: (state, action) => {
|
|
21
|
+
state.errors.push((0, immer_1.castDraft)(action.payload));
|
|
22
|
+
},
|
|
23
|
+
trackEvent: (state, action) => {
|
|
24
|
+
state.events.push((0, immer_1.castDraft)(action.payload));
|
|
25
|
+
},
|
|
26
|
+
startTrace: (state, action) => {
|
|
27
|
+
const trace = (0, immer_1.castDraft)(action.payload);
|
|
28
|
+
state.pendingTraces.push(trace);
|
|
29
|
+
},
|
|
30
|
+
endTrace: (state, action) => {
|
|
31
|
+
const endTrace = (0, immer_1.castDraft)(action.payload);
|
|
32
|
+
const index = state.pendingTraces.findLastIndex((pendingTrace) => pendingTrace.id === endTrace.id &&
|
|
33
|
+
pendingTrace.name === endTrace.name);
|
|
34
|
+
if (index !== -1) {
|
|
35
|
+
const pendingTrace = state.pendingTraces[index];
|
|
36
|
+
state.pendingTraces.splice(index, 1);
|
|
37
|
+
state.traces.push(pendingTrace);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
clearTrackables: (state) => {
|
|
41
|
+
state.events = [];
|
|
42
|
+
state.errors = [];
|
|
43
|
+
state.traces = [];
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
_a = exports.trackablesSlice.actions, exports.trackError = _a.trackError, exports.trackEvent = _a.trackEvent, exports.startTrace = _a.startTrace, exports.endTrace = _a.endTrace, exports.clearTrackables = _a.clearTrackables;
|
|
48
|
+
/**
|
|
49
|
+
* Get the errors from the state.
|
|
50
|
+
*
|
|
51
|
+
* @param state - The application state.
|
|
52
|
+
* @returns An array of errors.
|
|
53
|
+
*/
|
|
54
|
+
exports.getErrors = (0, toolkit_1.createSelector)((state) => state.trackables, ({ errors }) => errors);
|
|
55
|
+
/**
|
|
56
|
+
* Get the events from the state.
|
|
57
|
+
*
|
|
58
|
+
* @param state - The application state.
|
|
59
|
+
* @returns An array of events.
|
|
60
|
+
*/
|
|
61
|
+
exports.getEvents = (0, toolkit_1.createSelector)((state) => state.trackables, ({ events }) => events);
|
|
62
|
+
/**
|
|
63
|
+
* Get the traces from the state. This only includes traces that have been
|
|
64
|
+
* ended, not pending traces.
|
|
65
|
+
*
|
|
66
|
+
* @param state - The application state.
|
|
67
|
+
* @returns An array of traces.
|
|
68
|
+
*/
|
|
69
|
+
exports.getTraces = (0, toolkit_1.createSelector)((state) => state.trackables, ({ traces }) => traces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n} from '@metamask/snaps-sdk';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport { createSelector, createSlice } from '@reduxjs/toolkit';\nimport { castDraft } from 'immer';\n\nimport type { ApplicationState } from './store';\n\nexport type TrackedEvent = TrackEventParams['event'];\n\nexport type TrackedError = TrackErrorParams['error'];\n\n/**\n * The trackables state.\n */\nexport type TrackablesState = {\n /**\n * An array of tracked events.\n */\n events: TrackedEvent[];\n\n /**\n * An array of tracked errors.\n */\n errors: TrackedError[];\n\n /**\n * An array of performance traces.\n */\n traces: TraceRequest[];\n\n /**\n * An array of pending traces that have not yet been ended.\n */\n pendingTraces: TraceRequest[];\n};\n\n/**\n * The initial events state.\n */\nconst INITIAL_STATE: TrackablesState = {\n events: [],\n errors: [],\n traces: [],\n pendingTraces: [],\n};\n\nexport const trackablesSlice = createSlice({\n name: 'trackables',\n initialState: INITIAL_STATE,\n reducers: {\n trackError: (state, action: PayloadAction<TrackedError>) => {\n state.errors.push(castDraft(action.payload));\n },\n trackEvent: (state, action: PayloadAction<TrackedEvent>) => {\n state.events.push(castDraft(action.payload));\n },\n startTrace: (state, action: PayloadAction<TraceRequest>) => {\n const trace = castDraft(action.payload);\n state.pendingTraces.push(trace);\n },\n endTrace: (state, action: PayloadAction<EndTraceParams>) => {\n const endTrace = castDraft(action.payload);\n const index = state.pendingTraces.findLastIndex(\n (pendingTrace) =>\n pendingTrace.id === endTrace.id &&\n pendingTrace.name === endTrace.name,\n );\n\n if (index !== -1) {\n const pendingTrace = state.pendingTraces[index];\n state.pendingTraces.splice(index, 1);\n state.traces.push(pendingTrace);\n }\n },\n clearTrackables: (state) => {\n state.events = [];\n state.errors = [];\n state.traces = [];\n },\n },\n});\n\nexport const { trackError, trackEvent, startTrace, endTrace, clearTrackables } =\n trackablesSlice.actions;\n\n/**\n * Get the errors from the state.\n *\n * @param state - The application state.\n * @returns An array of errors.\n */\nexport const getErrors = createSelector(\n (state: ApplicationState) => state.trackables,\n ({ errors }) => errors,\n);\n\n/**\n * Get the events from the state.\n *\n * @param state - The application state.\n * @returns An array of events.\n */\nexport const getEvents = createSelector(\n (state: ApplicationState) => state.trackables,\n ({ events }) => events,\n);\n\n/**\n * Get the traces from the state. This only includes traces that have been\n * ended, not pending traces.\n *\n * @param state - The application state.\n * @returns An array of traces.\n */\nexport const getTraces = createSelector(\n (state: ApplicationState) => state.trackables,\n ({ traces }) => traces,\n);\n"]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { EndTraceParams, TraceRequest, TrackErrorParams, TrackEventParams } from "@metamask/snaps-sdk";
|
|
2
|
+
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
3
|
+
export type TrackedEvent = TrackEventParams['event'];
|
|
4
|
+
export type TrackedError = TrackErrorParams['error'];
|
|
5
|
+
/**
|
|
6
|
+
* The trackables state.
|
|
7
|
+
*/
|
|
8
|
+
export type TrackablesState = {
|
|
9
|
+
/**
|
|
10
|
+
* An array of tracked events.
|
|
11
|
+
*/
|
|
12
|
+
events: TrackedEvent[];
|
|
13
|
+
/**
|
|
14
|
+
* An array of tracked errors.
|
|
15
|
+
*/
|
|
16
|
+
errors: TrackedError[];
|
|
17
|
+
/**
|
|
18
|
+
* An array of performance traces.
|
|
19
|
+
*/
|
|
20
|
+
traces: TraceRequest[];
|
|
21
|
+
/**
|
|
22
|
+
* An array of pending traces that have not yet been ended.
|
|
23
|
+
*/
|
|
24
|
+
pendingTraces: TraceRequest[];
|
|
25
|
+
};
|
|
26
|
+
export declare const trackablesSlice: import("@reduxjs/toolkit").Slice<TrackablesState, {
|
|
27
|
+
trackError: (state: import("immer/dist/internal.js").WritableDraft<TrackablesState>, action: PayloadAction<TrackedError>) => void;
|
|
28
|
+
trackEvent: (state: import("immer/dist/internal.js").WritableDraft<TrackablesState>, action: PayloadAction<TrackedEvent>) => void;
|
|
29
|
+
startTrace: (state: import("immer/dist/internal.js").WritableDraft<TrackablesState>, action: PayloadAction<TraceRequest>) => void;
|
|
30
|
+
endTrace: (state: import("immer/dist/internal.js").WritableDraft<TrackablesState>, action: PayloadAction<EndTraceParams>) => void;
|
|
31
|
+
clearTrackables: (state: import("immer/dist/internal.js").WritableDraft<TrackablesState>) => void;
|
|
32
|
+
}, "trackables">;
|
|
33
|
+
export declare const trackError: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("@metamask/snaps-sdk").TrackableError, "trackables/trackError">, trackEvent: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
34
|
+
event: string;
|
|
35
|
+
properties?: Record<string, import("@metamask/snaps-sdk").Json> | undefined;
|
|
36
|
+
sensitiveProperties?: Record<string, import("@metamask/snaps-sdk").Json> | undefined;
|
|
37
|
+
}, "trackables/trackEvent">, startTrace: import("@reduxjs/toolkit").ActionCreatorWithPayload<TraceRequest, "trackables/startTrace">, endTrace: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("@metamask/snaps-sdk").EndTraceRequest, "trackables/endTrace">, clearTrackables: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"trackables/clearTrackables">;
|
|
38
|
+
/**
|
|
39
|
+
* Get the errors from the state.
|
|
40
|
+
*
|
|
41
|
+
* @param state - The application state.
|
|
42
|
+
* @returns An array of errors.
|
|
43
|
+
*/
|
|
44
|
+
export declare const getErrors: ((state: {
|
|
45
|
+
mocks: import("./mocks.cjs").MocksState;
|
|
46
|
+
notifications: import("./notifications.cjs").NotificationsState;
|
|
47
|
+
state: import("./state.cjs").State;
|
|
48
|
+
trackables: TrackablesState;
|
|
49
|
+
ui: import("./ui.cjs").UiState;
|
|
50
|
+
}) => import("@metamask/snaps-sdk").TrackableError[]) & import("reselect").OutputSelectorFields<(args_0: TrackablesState) => import("@metamask/snaps-sdk").TrackableError[], {
|
|
51
|
+
clearCache: () => void;
|
|
52
|
+
}> & {
|
|
53
|
+
clearCache: () => void;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Get the events from the state.
|
|
57
|
+
*
|
|
58
|
+
* @param state - The application state.
|
|
59
|
+
* @returns An array of events.
|
|
60
|
+
*/
|
|
61
|
+
export declare const getEvents: ((state: {
|
|
62
|
+
mocks: import("./mocks.cjs").MocksState;
|
|
63
|
+
notifications: import("./notifications.cjs").NotificationsState;
|
|
64
|
+
state: import("./state.cjs").State;
|
|
65
|
+
trackables: TrackablesState;
|
|
66
|
+
ui: import("./ui.cjs").UiState;
|
|
67
|
+
}) => {
|
|
68
|
+
event: string;
|
|
69
|
+
properties?: Record<string, import("@metamask/snaps-sdk").Json> | undefined;
|
|
70
|
+
sensitiveProperties?: Record<string, import("@metamask/snaps-sdk").Json> | undefined;
|
|
71
|
+
}[]) & import("reselect").OutputSelectorFields<(args_0: TrackablesState) => {
|
|
72
|
+
event: string;
|
|
73
|
+
properties?: Record<string, import("@metamask/snaps-sdk").Json> | undefined;
|
|
74
|
+
sensitiveProperties?: Record<string, import("@metamask/snaps-sdk").Json> | undefined;
|
|
75
|
+
}[], {
|
|
76
|
+
clearCache: () => void;
|
|
77
|
+
}> & {
|
|
78
|
+
clearCache: () => void;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Get the traces from the state. This only includes traces that have been
|
|
82
|
+
* ended, not pending traces.
|
|
83
|
+
*
|
|
84
|
+
* @param state - The application state.
|
|
85
|
+
* @returns An array of traces.
|
|
86
|
+
*/
|
|
87
|
+
export declare const getTraces: ((state: {
|
|
88
|
+
mocks: import("./mocks.cjs").MocksState;
|
|
89
|
+
notifications: import("./notifications.cjs").NotificationsState;
|
|
90
|
+
state: import("./state.cjs").State;
|
|
91
|
+
trackables: TrackablesState;
|
|
92
|
+
ui: import("./ui.cjs").UiState;
|
|
93
|
+
}) => TraceRequest[]) & import("reselect").OutputSelectorFields<(args_0: TrackablesState) => TraceRequest[], {
|
|
94
|
+
clearCache: () => void;
|
|
95
|
+
}> & {
|
|
96
|
+
clearCache: () => void;
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=trackables.d.cts.map
|