Skip to content

Commit

Permalink
add accounts controller to context
Browse files Browse the repository at this point in the history
  • Loading branch information
owencraston committed Mar 7, 2024
1 parent c94db55 commit f5a7717
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion app/components/Nav/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,11 @@ const App = ({ userLoggedIn }) => {
}
};

// TODO remove this useEffect before merging
useEffect(() => {
console.log(
'Accounts/ AccountController',
JSON.stringify(Engine.context.AccountsController, null, 2),
JSON.stringify(Engine.context.AccountsController.state, null, 2),
);
console.log(
'Accounts/ PreferencesController',
Expand Down
8 changes: 5 additions & 3 deletions app/core/Engine.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/no-shadow */
/* eslint-disable @typescript-eslint/no-shadow */
import Crypto from 'react-native-quick-crypto';
import {
AccountTrackerController,
Expand Down Expand Up @@ -607,15 +606,16 @@ class Engine {
],
});

const defaultAccountControllerState: AccountsControllerState = {
const defaultAccountsControllerState: AccountsControllerState = {
internalAccounts: {
accounts: {},
selectedAccount: '',
},
};

const accountsController = new AccountsController({
messenger: accountsControllerMessenger,
state: initialState.AccountsController ?? defaultAccountControllerState,
state: initialState.AccountsController ?? defaultAccountsControllerState,
});

const qrKeyringBuilder = () => new QRHardwareKeyring();
Expand Down Expand Up @@ -1673,6 +1673,7 @@ export default {
PermissionController,
ApprovalController,
LoggingController,
AccountsController,
} = instance.datamodel.state;

// normalize `null` currencyRate to `0`
Expand Down Expand Up @@ -1712,6 +1713,7 @@ export default {
PermissionController,
ApprovalController,
LoggingController,
AccountsController,
};
},
get datamodel() {
Expand Down
2 changes: 1 addition & 1 deletion app/store/migrations/033.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,4 @@ describe('Migration #032', () => {
});
});
});
});
});
2 changes: 1 addition & 1 deletion app/util/number/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('Number utils :: toWei', () => {
expect(() => toWei(new BN(1.337e18))).toThrow(Error);
expect(() => toWei(new BN(1337000000000000000))).toThrow(Error);
// For some reason this returns 8338418000000000000000000 wei
expect(toWei(new BN('1.337e18'))).not.toEqual(
expect(() => toWei(new BN('1.337e18'))).not.toEqual(
'1337000000000000000000000000000000000',
);
});
Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Base64: cecfb41a004124895a7bcee567a89bae5a89d49b
boost: 7dcd2de282d72e344012f7d6564d024930a6a440
boost: 57d2868c099736d80fcd648bf211b4431e51a558
Branch: 4ac024cb3c29b0ef628048694db3c4cfa679beb0
BVLinearGradient: e3aad03778a456d77928f594a649e96995f1c872
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
Expand Down

0 comments on commit f5a7717

Please sign in to comment.