Git Product home page Git Product logo

Comments (3)

netoneko avatar netoneko commented on June 22, 2024
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.

netoneko avatar netoneko commented on June 22, 2024

Updated flow after a meeting with @gilamran

from orbs-client-sdk-javascript.

netoneko avatar netoneko commented on June 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.