Created
          October 20, 2018 16:32 
        
      - 
      
 - 
        
Save TrillCyborg/d5c04440c4151eff7e3eaf0782871f2d to your computer and use it in GitHub Desktop.  
Revisions
- 
        
TrillCyborg created this gist
Oct 20, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ import ScatterJS from 'scatterjs-core' import ScatterEOS from 'scatterjs-plugin-eosjs' import EOS from 'eosjs' const isDev = process.env.NODE_ENV === 'development' const APP_NAME = 'Test App' const NETWORK = { protocol: "http", blockchain: "eos", host: "127.0.0.1", port: 8888, chainId: "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f" } ScatterJS.plugins(new ScatterEOS()); export const initScatter = () => ScatterJS.scatter.connect(APP_NAME).then(async (connected: any) => { // User does not have Scatter Desktop, Mobile or Classic installed. if(!connected) { throw Error('Scatter not connected'); } try { const requiredFields = { accounts: [ NETWORK ] }; const scatter = ScatterJS.scatter const eos: any = scatter.eos(NETWORK, EOS, {}, NETWORK.protocol); const identity = await scatter.getIdentity(requiredFields) const account = identity.accounts.find((a: any) => a.blockchain === 'eos'); // Save to application store // save({ scatter, eos, identity, account }) if (isDev) { (window as any).Scatter = scatter (window as any).EOS = eos (window as any).EOSIdentity = identity (window as any).EOSAccount = account } } catch (e) { console.error(e, "Identity Crisis!") } });