eosnewyork / eos-transit Goto Github PK
View Code? Open in Web Editor NEWTransit Wallet Access Layer for EOS blockchain networks
License: MIT License
Transit Wallet Access Layer for EOS blockchain networks
License: MIT License
Hi eos, Firstly great work on the project!
I've managed to get my react app and the demo app working with scatter and authenticating a wallet on a testnet. But I noticed on refresh on the react-basic-demo you need to login again. I was wondering what is the best practice for persisting the logged in wallet so if I refresh I am already authenticated. Would storing WAL
into localStorage on login success be enough then retrieving on refresh and somehow associating that with the session? A change to AccessContextSubscribe
?
Just noticed that version got bumped from 2.x to 3.x and not long ago it went from 1.x to 2.x. It would be great if there was a changelog detailing what APIs are being broken with the major releases (assuming you're following semver).
Failed to compile.
/home/steve/Documents/GitHub/aikon/eos-transit/examples/transit-react-basic/src/initDefaultAccessContext.ts
(29,10): Argument of type '{ exchangeTimeout: number; transport: "TransportWebusb"; name: string; shortName: string; id: string; }' is not assignable to parameter of type 'ledgerWalletProviderOptions'.
Types of property 'transport' are incompatible.
Type '"TransportWebusb"' is not assignable to type '"TransportWebAuthn" | "TransportU2F" | "TransportWebBLE" | undefined'.
Hi, I'm running the transit-react-basic example and have connected to Scatter Desktop successfully, having set up scatter to connect to my local test EOS blockchain node. After logging in via scatter on one of my test accounts (alice2) I am trying to transfer 1 SYS to another test account, but encounter this error:
"transaction declares authority '{"actor":"alice2","permission":"active"}', but does not have signatures for it."
Here is how I initialise the wallet context:
const walContext = initDefaultAccessContext({
appName,
network: {
host: 'localhost',
port: 8888,
protocol: 'http',
chainId: "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f", // Localhost
},
walletProviders: [ scatter() ]
});
Here is what my dev console outputs:
And the request for get_required_keys that comes back with a 401 unauthorized:
In the last screenshot we can see that available_keys
is sent as an empty array. Shouldn't this contain the public key for alice2 (the user that I'm logged in as)?
I suspect that could be the reason but I don't know how to fix it. Is it a configuration error in my scatter (I seem to have imported alice2's private key correctly though and linked that key to the alice2 account)? Or is transit or scatterjs failing to retrieve the public key for alice2 from my scatter?
Any help or advice is greatly appreciated.
I'm using the scatter example and the AccountInfo returned from wallet.login
does not have the name
type.
I can access it through account_name
only.
const accountInfo = await wallet.login();
console.log(accountInfo.name) // undefined
Hello, the latest version of the Trezor firmware has support for EOS, and is compatible with CLEOS. What is the best way to integrate a provider with transit?
Please specify a new functionality to encrypt and decrypt an arbitrary text with EOS private key and other EOS public key.
It's a very needed functionality for dapps that wan't to encrypt data without asking for the private key, as expressed by other developers in the issue bellow.
I approached Scatter, but it's not implemented yet, I think this project may push for a standard interface for this new functionality, so that different wallets implement it.
There is already a proposed implementation for scatter, not in production yet, please check the related issue:
GetScatter/ScatterDesktop#43
I've setup a simple login/transact/logout setup in a react page.
The login / transact works fine, but I cannot seem to get the logout functionality working.
After calling terminate()
on the WalletAccessContext
and/or destroy()
on the accessContext
, I am still able to call the transact function and push a transfer.
Dependency Versions:
"eos-transit": "0.0.8"
"eos-transit-scatter-provider": "0.0.8",
"eosjs": "^20.0.0-beta3"
Scatter Version: Scatter Desktop v10.1.1
Here is my code:
import { initAccessContext } from 'eos-transit';
import scatter from 'eos-transit-scatter-provider';
state = {
wallet: null, // to use terminate
accessContext: null // to use destroy
}
async login() {
const accessContext = initAccessContext({
appName: 'appName',
network: {
// Jungle 2.0
},
walletProviders: [
scatter()
]
});
const walletProviders = accessContext.getWalletProviders();
const selectedProvider = walletProviders[0];
const wallet = accessContext.initWallet(selectedProvider);
await wallet.connect().then(() => {
console.log('Successfully connected!');
});
await wallet.login().then(() => {
console.log(`Successfully logged in as ${wallet.auth.accountName}!`);
});
this.setState({wallet: wallet}) // to use terminate
this.setState({accessContext: accessContext}) // to use destroy
}
async logout() {
this.state.accessContext.destroy();
// tried logoutAll, disconnectAll, terminateAll
await this.state.wallet.terminate().then(() => {
console.log(`Successfully terminated!`);
});
// tried logout, disconnect, terminate
// after calling still allows transact function below
}
transact = () => {
// transact logic for .0001 EOS transfer, broadcast: false
}
I've tried calling destroy/terminate within my login function as well before setting state, yet I'm still able to transact under all circumstances. I've also placed the transact logic within the login function to see if that made a difference, but I was still able to transact.
Any help would be appreciated, thank you and great tool!
It's unclear without looking at code that you need to provide a "session id" to anchor's constructor when setting up the access context's wallet providers. Nor does anchor()
throw any errors if you don't specify the session id. You just get an obscure error if you don't.
e.g.
walletProviders: [
anchor(`discussions`),
scatter()
]
The discovery feature is very helpful. But it would be ideal if the discover results also included the parent permission of each discovered permission/authority. This could enable other use cases like keeping a cache of the permissions and keys stored across different wallets. This data could be discovered by querying the public chain - it is public info after all, but it would be great if it could be returned with the results of discover.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.