Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle the account after create account. #254

Open
superhero2007 opened this issue Sep 27, 2019 · 11 comments
Open

How to handle the account after create account. #254

superhero2007 opened this issue Sep 27, 2019 · 11 comments

Comments

@superhero2007
Copy link

superhero2007 commented Sep 27, 2019

const abc = require('edge-core-js');
const context = await abc.makeEdgeContext({
apiKey: API_KEY,
appId: APP_ID,
});
const { username, password } = user;
const re = await abcContext.loginWithPassword(
username,
password
);
console.log("Result:", re);

But I can't get edgeaccount after login though there is a new folder called edge wallet created and login account file is created.

@superhero2007
Copy link
Author

I have tried to use as follows.

context.on('login', async (account) => console.log(account));

But there is no console log output and it seems there is no connection via login emit.

How can handle logged accounts as a response?
async/await, then, and socket on are not working.

@swansontec
Copy link
Contributor

The re in your first example should either be the EdgeAccount, or it should be an error explaining the problem. The loginWithPassword method returns a promise of an EdgeAccount.

For your second point, the on('login', ...) event is related to barcode login, specifically. It would not fire for password login.

@superhero2007
Copy link
Author

superhero2007 commented Sep 28, 2019

@swansontec
Thanks for your response to my request.

I tried to use 3 methods.

  • abcContext.createAccount
  • abcContext.loginWithPasword
  • abcContext.loginWithPIN

It seems all these 3 methods are working, but I can't get any response.
Just getting usernames by calling abcContext.localUsers.

I wonder how to handle EageAccount to createWallet or getWalletInfo.
Is there any method to use EdgeAccount?

@swansontec
Copy link
Contributor

Is there any method to use EdgeAccount?

EdgeAccount has many methods. Take a look at the Flow types to see their definitions:

export type EdgeAccount = {

If you call createCurrencyWallet('wallet:ethereum', { name: 'My Wallet' }), the account will create an Ethereum wallet (assuming you have the Ethereum plugin installed). The createCurrencyWallet will return an EdgeCurrencyWallet object, which you can use to check balances and send / receive money. Take a look at the types to see which methods are available.

All the wallets you create will go into the EdgeAccount.activeWalletIds array which tells you how many wallets you have and what order they are in. This array will be loaded instantly when the account logs in. Then, once login finishes, the core will start actually loading wallets (this can take a long time, so we don't want it to delay login). As the wallets load, they will appear in the EdgeAccount.currencyWallets table. If you would like to grab a particular wallet, you can either wait for it to appear in the EdgeAccount.currencyWallets table, or you can call EdgeAccount.waitForCurrencyWallet(walletId), to get the wallet back in a promise.

@superhero2007
Copy link
Author

superhero2007 commented Sep 28, 2019

@swansontec
Sorry, but we are not on the same page right now.

I know that there are several methods for wallet using EdgeAccount.

But I think there is no method to handle EdgeAccount.

  • abcContext.createAccount
  • abcContext.loginWithPasword
  • abcContext.loginWithPIN

I tried to use the above 3 methods but can't get any response.

@superhero2007
Copy link
Author

@swansontec

Also regarding createCurrencyWallet,
Plugins such as Bitcoin, Ethereum and Ripple plugins are working on airbitz-core-js but on edge-core-js, it seems plugins are not installing, and there is no currency info on the account.

@superhero2007
Copy link
Author

{ init:
[ { pluginType: 'currency',
pluginName: 'ethereum',
makePlugin: [AsyncFunction: makePlugin] } ],
locked: false,
currency: {},
rate: {},
swap: {},
currencyTools: {} }

@swansontec
Copy link
Contributor

swansontec commented Oct 1, 2019

Just for future reference, we found that the problem was lockEdgeCorePlugins. The edge-core-js library is designed to allow plugins to load in parallel, so code like this needs to run at some point during setup:

addEdgeCorePlugins(...)
addEdgeCorePlugins(...)
lockEdgeCorePlugins(...)

Once the lockEdgeCorePlugins call takes place, the plugin list is complete and login can proceed. If lockEdgeCorePlugins isn't called anywere, logging in will wait forever for the plugins to finish loading.

Also, addEdgeCorePlugins just makes the plugins available. To actually use them, you need to pass them to makeEdgeContext as a plugins option, like makeEdgeContext{ ...otherStuff, plugins: { pluginName: true } }

@superhero2007
Copy link
Author

superhero2007 commented Oct 5, 2019

Thanks for your note, @swansontec

After login, I logout using account.logout(), then, I got a connection lost error and my project is broken.

Is there any way to log out safety?

And sometimes, I got an web socket connection error before make transactions using makespend method.

I think this is the same problem.

@swansontec
Copy link
Contributor

The account.logout() method should be safe, and the Edge wallet uses it with no problems. Logging out completely shuts down all wallets & account-related objects. Is that what you mean when you say "my project is broken"? If so, don't log out until you are done using the account and all its contents.

@harshnebhvani
Copy link

harshnebhvani commented Jan 10, 2022

@swansontec Sorry, but we are not on the same page right now.

I know that there are several methods for wallet using EdgeAccount.

But I think there is no method to handle EdgeAccount.

  • abcContext.createAccount
  • abcContext.loginWithPasword
  • abcContext.loginWithPIN

I tried to use the above 3 methods but can't get any response.

Hello @superhero2007,
I am having same issue, Can you please describe how did you get account information after login?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants