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

Refactor Nearlib #39

Closed
9 tasks
ilblackdragon opened this issue Jun 4, 2019 · 7 comments
Closed
9 tasks

Refactor Nearlib #39

ilblackdragon opened this issue Jun 4, 2019 · 7 comments
Labels
Epic Milestone or collection of like issues

Comments

@ilblackdragon
Copy link
Member

There are few things we want to improve:

Configuration search:

  • For Node.js use cases, search for .near/ folder with config and keys. Main uses cases:
    • local to project (so go up to folder with node_modules / package.json and check for .near). This can be official TestNet and custom network.
    • running node connected to official TestNet (~/.near/ for configs). Want to use it, but need to use contract helper for account creation.
    • running custom network with local node (~/.near/ for configs). Want to use local key pair for account creation.
  • Create various types of transactions functions that support creating and signing transactions (without having connection).
  • ConnectProvider interface that various providers like RPC, RPCv2, Network, WebSockets can implement (e.g. current NearClient is RPC provider). Provides sendTransaction(txBytes, [timeout]) -> Promise<FinalTransactionResult> and query(path, data) -> Promise<QueryResult> interfaces.
  • AccountCreatorProvider - interface, that either uses helper or given keys to create accounts.
  • connect that is configured / or searches for configuration and uses given ConnectProvider, AccountCreatorProvider and KeyStore.
  • Account abstraction, that provides accessors to account state (balance, etc), access keys (with permissions per key), etc. Allows to initialize Contract with it to send Tx from it.
  • Wallet API is defined via 2 URLs: "Authorize App" API and "Sign Tx" API.
  • Contract handles itself sending to Wallet if currently signed Tx is not allowed by access key or access key is missing.
  • KeyStore should have some form of Wallet to provide what are current accounts available for given network, and allow to change accounts and networks. Also this should use Wallet API to "login" to retrieve current account id if unavailable.
@ilblackdragon ilblackdragon added the Epic Milestone or collection of like issues label Jun 4, 2019
@vans163
Copy link

vans163 commented Jun 12, 2019

setItem for localstorage tokens/secretket is kinda inbetween nearwallet and nearlib. The secretket is set in nearlib and the account id and tokens are set in nearwallet. Should these be all set in nearlib, or shipping to wallet?

@vgrichina
Copy link
Contributor

@vans163 it's perfectly valid use case not not use wallet at all. From our POV wallet is basically a special type of Signer.

@vans163
Copy link

vans163 commented Jun 13, 2019

Yea I am thinking that thin API in wallet repo should be moved into nearlib

@DanielRX
Copy link
Contributor

Could "Create various types of transactions functions that support creating and signing transactions (without having connection)" be made into an issue alone? I can do it if you want (basically we really need the ability to sign a tx, then send it on a different machine)

@bowenwang1996
Copy link
Contributor

@DanielRX feel free to do it

@DanielRX
Copy link
Contributor

After thinking about it, "Create various types of transactions functions that support creating and signing transactions (without having connection)" is impossible, so I'm not sure what you want to do about that? Do you want to scrap the idea of doing so without a connection?

@ilblackdragon
Copy link
Member Author

This actually have been mostly done back in June/July. Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Epic Milestone or collection of like issues
Projects
None yet
Development

No branches or pull requests

5 participants