Comments (3)
interface Signer {
getPublicKey(): Promise<Uint8Array>;
signEd25519(data: Uint8Array): Promise<Uint8Array>;
}
interface Account extends Signer {
getName(): Promise<string>;
_setName(name: string); // Private method of extension
getDescription(): Promise<string>;
_setDescription(name: string); // Private method of extension
getAddress(): Promise<string>;
isCompromised(): bool // in case we want to filter out compromised keys
// Private method of extension
_lockSigner(); // locks the account, disabling Signer.signEd25519 method
_unlockSigner(); // unlocks the account, makes all the Signer methods available
}
interface Wallet() {
async enable(): Account[];
async addAccount({name: string, description: string, phrase?: string}); // generates a new account and sets name and description, if phrase is available then it is used to restore the private key
}
The sample flow (inspired by Metamask low level flow:
import { Wallet } from "orbs-wallet-javascript";
import { Client, argUint64 } from "orbs-client-javascript";
const wallet = new Wallet({ configOptions });
let accounts;
try {
accounts = await wallet.enable(); // should open a separate extension window that asks for the password
} catch (e) {
console.log("Could not initialize wallet: " + e.toString();
throw e;
}
const account = accounts[0];
const client = new Client("http://localhost:8080", 42, account);
const query = await client.createQuery("ReadOnlyContract", "readInfo");
const queryResult = await client.runQuery(query);
console.log(queryResult.OutputArguments[0]);
const [txid, tx] = client.createTransaction("ModifyStateContract", "add", [argUint64(1)]);
const txResult = await client.SendTransaction(tx);
console.log(txResult.OutputArguments[0]);
I understand that unlocking the singer every time might be a bit of an overkill, so we should discuss if we even need this feature. Metamask does not have it.
I thought we might add it to separate read-only usecase from read-write usecase. I think it's definitely up for discussion, maybe @lbeder could give us a tip if it makes sense.
from orbs-client-sdk-javascript.
Updated flow after a meeting with @gilamran
from orbs-client-sdk-javascript.
Some basic implementation of the flow here: https://github.com/orbs-network/wallet/blob/master/firefox/test/test.js
from orbs-client-sdk-javascript.
Related Issues (19)
- Add support for Firefox HOT 1
- Add support for Safari/iOS
- SDK does not generates addresses with checksum
- Extract membuffers to a separate dependency HOT 1
- Add a test-kit for easy external testing
- argument->build->protocol seems a bit complicated.
- GetBlock fails on blocks with trigger transactions HOT 1
- Fix the Deploy E2E test scenario to actually transact with deployed contract
- Provide proper error for HTTP timeouts (502, 503, 504)
- Add .toJSON() and .fromJSON() to Address objects
- add a way to get the current block height of vchain
- add reference to block in transaction
- uint8ArrayToHexString should be removed in favour of encodeHex
- better error message on unsupported return type HOT 1
- add transaction id to `sendTransaction` result
- expose internal tools
- install is full with warnings HOT 1
- Client.deployContract method is missing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orbs-client-sdk-javascript.