Giter Site home page Giter Site logo

sol-wallet-adapter's People

Contributors

armaniferrante avatar arrowana avatar beautyfree avatar criesofcarrots avatar dr497 avatar fragosti avatar garywang avatar jhlx avatar jstarry avatar macalinao avatar nishadsingh1 avatar paulbernier avatar yuzhiyou1990 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sol-wallet-adapter's Issues

When connecting, no event is emitted on failure

When using the web version, if the popup is blocked by the browser or closed by the user, the connect call will hang and never emit an event or reject its promise.

Similarly for the extension, if the user declines permission to connect or closes the extension popup, the connect call will never emit an event. It also resolves its promise immediately (#24).

Dapps can listen for a connect event but cannot reliably detect the connection failure and are left in an unknown state.

create stake acccount

hey,
i wonder how to create stakeAccount using this wallet adapter, since the current signTransaction wallet method expect TransactionInstruction type while create stakeAccount is Transaction type, so it already signed

any ideas?

SyntaxError: Cannot use import statement outside a module

C:\Users\Bloctech\Documents\solana\solr-token-sale\js\node_modules@project-serum\sol-wallet-adapter\dist\cjs\index.js:79
import EventEmitter from 'eventemitter3';
^^^^^^

SyntaxError: Cannot use import statement outside a module

Firefox issues

The adapter on Firefox has a couple of usability issues that I've found so far.

  1. Whenever you connect the wallet, or approve a transaction, a new empty tab is opened on the dApp window.

  2. If you send an approval request from the dApp the wallet popup doesn't focus so you don't realize you need to perform an action on this popup as it's hidden behind the main window.

The steps to reproduce these issues are pretty simple, but if you have any question please let me know.

Solana Staking account not activated

After creating the staking account, I tried to retrieve it using let stakeState = await connection.getStakeActivation(stakeAccount.publicKey);.
But it gives an error as follows
Invalid param: stake account not initialized.

When I search for the address on the solana explorer I can see the account as a staking account. How long will it take to get activated? I am using the devnet at the moment

How to know that popup was closed during connect?

For example, client set the "Loading" flag before call connect, but if user closes the popup and doesn't connect, there is no way to even figure out that it was closed and set "Loading" to false.

Cannot import correctly under TypeScript Node 16 module resolution

Under TypeScript Node 16 module resolution (has type: module in the package.json and moduleResolution: Node16 in tsconfig.json), this package cannot be imported correctly.

image

import Wallet from '@project-serum/sol-wallet-adapter'
new Wallet()
// type error!
new Wallet.default(provider, 'network')
// runtime error!

TypeError: Cannot read property toString of undefined while trying to signTransaction

I'm running the code below with some logs and at the point of running wallet.signTransaction it fails with the error given in the title. The entire error below. The code to get connections and setup and connect the wallet all work. As does the setup of the Transaction itself.

I am running:
devnet
solana: 1.6.6
sol-wallet-adapter: 0.2.0
web3.js: 1.9.1

react_devtools_backend.js:2557 Failed TypeError: Cannot read property 'toString' of undefined
at transaction.ts:271
at Array.forEach ()
at Transaction.compileMessage (transaction.ts:270)
at Transaction._compile (transaction.ts:376)
at Transaction.serializeMessage (transaction.ts:402)
at Wallet.signTransaction (index.js:184)
at sendTransaction (wallet.js:33)

`
import Wallet from "@project-serum/sol-wallet-adapter";
import {
Connection,
SystemProgram,
Transaction,
clusterApiUrl,
sendAndConfirmTransaction,
} from "@solana/web3.js";

const network = clusterApiUrl("devnet");
const connection = new Connection("https://devnet.solana.com", "confirmed");
const wallet = new Wallet("https://www.sollet.io", network);

export async function sendTransaction() {
try {
await wallet.connect();
console.log("network", network);
console.log("connection", connection);
console.log("wallet", wallet);

let transaction = new Transaction().add(
  SystemProgram.transfer({
    fromPubkey: wallet.publickey,
    toPubkey: wallet.publicKey,
    lamports: 100,
  })
);
transaction.recentBlockhash = (
  await connection.getRecentBlockhash()
).blockhash;
transaction.feePayer = wallet.publicKey;
console.log("finished setting up transaction");

let signed = await wallet.signTransaction(transaction);
console.log("signed transaction");
let signature = await connection.sendRawTransaction(signed.serialize());
console.log("sent raw transaction");
await connection.confirmTransaction(signature, "singleGossip");
console.log("transaction attempt confirm");

} catch (e) {
console.warn("Failed", e);
}
}
`

Needs a trusted site / signature feature

Resigning transactions using a popup is tedious to users who are using it for the same action over and over, ie interacting with a dApp that requires multiple transactions in a short period of time.

Would be great to have a checkmark that adds the site to a temporary (1 hr?) whitelist allows the site's function signs to bypass manual popup signs.

master is broken for yarn start local usage

It seems like the following PR #15
Completely broke local development, or even more.

I did cd example && yarn install && yarn start

I get errors all over the place
image

I checked out commit 63a823f then yarn start leads to a functional page again.

Remove auto approve from api

API consumers shouldn't have access to this knowledge, this should be strictly on the wallet side.

Why? Today I was investigation a couple of phishing websites, and both of them check if the user has auto approved or not.
Both were acting differently, but both were abusing this information.

Built sol-wallet-adapter still includes import statements

When this package is built into a CommonJS file, it still contains ES6 imports. From the latest version (0.2.4), the following lines will cause runners such as Jest (which assume node_modules as built CommonJS) to break:

import EventEmitter from 'eventemitter3';
import { PublicKey } from '@solana/web3.js';
import bs58 from 'bs58';

In the meantime, a workaround for anyone experiencing this is to add the following to your Jest configuration:

    "transform": {
      "(@project-serum/sol-wallet-adapter).+\\.js$": "babel-jest"
    },
    "transformIgnorePatterns": [
      "/node_modules/(?!@project-serum/sol-wallet-adapter)"
    ]

Wallet adapter never fires wallet.on('connect', ... event without any error

https://www.sollet.io vs https://sollet.io

How to reproduce:
Use sol-wallet-adapter example,
choose wallet provider: https://sollet.io yes, without the www
then click on Connect to wallet
sollet popup open, click Connect.
Connect event never occurs at the other side (example side)

I am not certain what side is causing the problem but it took me a while to find out. I find out running the example and noticing that it just works.

Working example with Anchor SDK

Are there any working examples of integrating the @project-serum/anchor library with this adapter or with the @solana/wallet-adapter components?

There seems to be a misalignment in the type definitions for the interface of a wallet adapter/provider and can't get them to work together properly.

image

Injected Interface Design

We need an injected interface design so dapps can interact with browser extension wallets (MathWallet, eDeFi, etc.)

Goals:

  • Dapp should work with any browser extension, without knowing which is installed on the user browser.
  • It's a plus if dapp knows the name of the browser extension, but just for display, not functionality.

Ethereum dapps rely on a single injection point (window.ethereum) for wallet interaction. All wallet extensions (MetaMask, ezDeFi, etc.) must compete for the chance to get injected since there's only 1 extension is active at a time. This is very simple for dapp to use but dapp also doesn't know which wallet is used (for display).

Solution 1: single interface - single wallet (same with Ethereum with extra info)

  • Dapp uses the same window.solana for all wallet extensions. The name of the wallet can be queried in window.solana.name and window.solana.desc, but they're optional for both dapp and wallets.
  • Dapp UI will show only 1 entry for the injected wallet (since there's only 1 can active at a time), the name of the wallet can be queried from window.solana.name or just injected.

Solution 2: single interface - multiple wallets

  • Wallets inject into window.solana[walletname], and dapps can use any of the wallets in the array they preferred, using the same interface as the current window.solana. Or just select the first one if they don't care.
  • Dapp UI will show each wallet as an entry, and multiple wallets can be installed together.

Solution 3: single dispatcher - multiple wallets

  • window.solana is injected to be a dispatcher, so it can be used just like window.ethereum
  • window.solana.wallet[name] is injected by each extensions.
  • window.solana.selectWallet(name) tells the dispatcher to redirect all requests to window.solana.wallets[name]. If none is set, the first wallet will be used.
  • window.solana.getWallets() returns all injected wallets.

Please discuss.

Related PRs: #11 #8

Unable to verify signed message

Having created a signed message I'm unsure how to use the resulting signature to verify the message using the publicKey.

My use case is: I'm wanting to use a Solana Wallet to login to an API server with a pattern like:

  1. GET message: String (from API server)
  2. sign message with privateKey
  3. POST signature (to API server)
  4. verify signature with stored publicKey

I've attempted to use crypto.verify to decode the signed message on the API side but am a bit out of my depth digging into Buffers and elliptic curves:

// Front-end code
const toHexString = (buffer: Buffer) =>
  buffer.reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");

const data = new TextEncoder().encode('message to verify');
const signed = await wallet.sign(data, "hex");
await setLogin({ // sends API post call to backend
  variables: {
    publicAddress: walletPublicKey,
    signature: toHexString(signed.signature),
  },
});

// Current WIP for backend code
const ALGORITHM = "ed25519";
const fromHexString = (hexString) =>
  new Uint8Array(hexString.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
const signature = fromHexString(args.signature);
const nonceUint8 = new TextEncoder().encode('message to verify');
const verified = crypto.verify(
  ALGORITHM,
  nonceUint8,
  `-----BEGIN PUBLIC KEY-----\n${user.publicAddress}\n-----END PUBLIC KEY-----`,
  signature
);
console.log("isVerified: ", verified);

I'm pretty sure I'm going about this the wrong way and there must be an obvious method I'm missing.

Ideally it seems like there should be a verify function to consume the output of const signed = await wallet.sign(data, "hex");

Something like:

import { VerifyMessage } from '@solana/web3.js';

const verified = VerifyMessage(message, publicKey, signature, 'hex');

But after 3 days of pushing hard I'm starting to hit my limits and my brain is failing. Any help or direction where to look much appreciated ๐Ÿ™

`esbuild` is not working out of the box.

I have a simple client.js

import Wallet from '@project-serum/sol-wallet-adapter';

And create a bundle using

esbuild ./client.js --bundle --outfile=./build/js/client.js

When including the bundled file on a simple page I am getting a bunch of bundling issues and can not use the output bundle.

Uncaught ReferenceError: process is not defined

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.