MCPcopy Create free account
hub / github.com/ICBNetwork/web3-Wallet / constructor

Method constructor

app/core/Engine.ts:375–1357  ·  view source on GitHub ↗
(
    initialState: Partial<EngineState> = {},
    initialKeyringState?: KeyringControllerState | null,
  )

Source from the content-addressed store, hash-verified

373 */
374 // eslint-disable-next-line @typescript-eslint/default-param-last
375 constructor(
376 initialState: Partial<EngineState> = {},
377 initialKeyringState?: KeyringControllerState | null,
378 ) {
379 this.controllerMessenger = new ControllerMessenger();
380
381 /**
382 * Subscribes a listener to the state change events of Preferences Controller.
383 *
384 * @param listener - The callback function to execute when the state changes.
385 */
386 const onPreferencesStateChange = (
387 // preferencesState is typed as any because if not will give an ts error on every assets-controllers using this function
388 // because assets-controllers preferences controller version is misaligned with the app repo (v8 != v4)
389 // and because of that preferencesState would be two different objects
390 listener: (preferencesState: PreferencesState) => void,
391 ) => {
392 const eventName = `PreferencesController:stateChange`;
393
394 this.controllerMessenger.subscribe(eventName, listener);
395 };
396
397 const approvalController = new ApprovalController({
398 // @ts-expect-error TODO: Resolve/patch mismatch between base-controller versions. Before: never, never. Now: string, string, which expects 3rd and 4th args to be informed for restrictedControllerMessengers
399 messenger: this.controllerMessenger.getRestricted<
400 'ApprovalController',
401 never,
402 never
403 >({
404 name: 'ApprovalController',
405 allowedEvents: [],
406 allowedActions: [],
407 }),
408 showApprovalRequest: () => undefined,
409 typesExcludedFromRateLimiting: [
410 // TODO: Replace with ApprovalType enum from @metamask/controller-utils when breaking change is fixed
411 'eth_sign',
412 'personal_sign',
413 'eth_signTypedData',
414 'transaction',
415 'wallet_watchAsset',
416 ],
417 });
418
419 const preferencesController = new PreferencesController({
420 messenger: this.controllerMessenger.getRestricted<
421 'PreferencesController',
422 never,
423 'KeyringController:stateChange'
424 >({
425 name: 'PreferencesController',
426 allowedEvents: ['KeyringController:stateChange'],
427 }),
428 state: {
429 ipfsGateway: AppConstants.IPFS_DEFAULT_GATEWAY_URL,
430 useTokenDetection:
431 initialState?.PreferencesController?.useTokenDetection ?? true,
432 useNftDetection: false,

Callers 1

tameFunctionConstructorsFunction · 0.45

Calls 15

startPollingMethod · 0.95
handleVaultBackupMethod · 0.95
isMainnetByChainIdFunction · 0.90
addHexPrefixFunction · 0.90
toHexadecimalFunction · 0.90
getCaveatSpecificationsFunction · 0.90
detectSnapLocationFunction · 0.90
getDecimalChainIdFunction · 0.90
isBlockaidFeatureEnabledFunction · 0.90
deprecatedGetNetworkIdFunction · 0.90

Tested by

no test coverage detected