-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
3,992 additions
and
1,903 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { | ||
AccountTrackerController, | ||
AddressBookController, | ||
BlockHistoryController, | ||
ComposableController, | ||
CurrencyRateController, | ||
KeyringController, | ||
NetworkController, | ||
NetworkStatusController, | ||
PhishingController, | ||
PreferencesController, | ||
ShapeShiftController, | ||
TokenRatesController | ||
} from 'gaba'; | ||
|
||
import BlockTracker from 'eth-block-tracker'; | ||
|
||
/** | ||
* Core controller responsible for composing other GABA controllers together | ||
* and exposing convenience methods for common wallet operations. | ||
*/ | ||
export class Engine { | ||
/** | ||
* Child controller instances keyed by controller name | ||
*/ | ||
api = { | ||
accountTracker: new AccountTrackerController(), | ||
addressBook: new AddressBookController(), | ||
blockHistory: new BlockHistoryController(), | ||
currencyRate: new CurrencyRateController(), | ||
keyring: new KeyringController(), | ||
network: new NetworkController(undefined, { | ||
providerConfig: {} | ||
}), | ||
networkStatus: new NetworkStatusController(), | ||
phishing: new PhishingController(), | ||
preferences: new PreferencesController(), | ||
shapeShift: new ShapeShiftController(), | ||
tokenRates: new TokenRatesController() | ||
}; | ||
|
||
/** | ||
* ComposableController reference containing all child controllers | ||
*/ | ||
datamodel; | ||
|
||
/** | ||
* Creates a CoreController instance | ||
*/ | ||
constructor() { | ||
this.datamodel = new ComposableController(this.api); | ||
this.api.network.subscribe(this.refreshNetwork); | ||
this.refreshNetwork(); | ||
} | ||
|
||
/** | ||
* Refreshes all controllers that depend on the network | ||
*/ | ||
refreshNetwork = () => { | ||
const { | ||
accountTracker, | ||
blockHistory, | ||
network: { provider } | ||
} = this.api; | ||
provider.sendAsync = provider.sendAsync.bind(provider); | ||
const blockTracker = new BlockTracker({ provider }); | ||
blockHistory.configure({ provider, blockTracker }); | ||
accountTracker.configure({ provider, blockTracker }); | ||
blockTracker.start(); | ||
}; | ||
} | ||
|
||
export default Engine; |
Oops, something went wrong.