Git Product home page Git Product logo

terra-money / wallet-provider Goto Github PK

View Code? Open in Web Editor NEW
89.0 22.0 64.0 6.81 MB

Library to make React dApps easier using Terra Station Extension or Terra Station Mobile.

Home Page: https://www.npmjs.com/package/@terra-money/wallet-provider

License: Apache License 2.0

JavaScript 10.24% Shell 0.09% HTML 1.70% TypeScript 82.89% CSS 0.37% Vue 2.41% Svelte 2.30%
terrajs dapp react blockchain

wallet-provider's People

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

Watchers

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

wallet-provider's Issues

[React.js] Webpack < 5 used to include polyfills for node.js

The latest version of create-react-app uses react-scripts: 5.0.0 which causes issues with dependencies used in the wallet-provider package.

When I run using react-scripts: 5.0.0, I get the following

ERROR in ./node_modules/cipher-base/index.js 3:16-43

Module not found: Error: Can't resolve 'stream' in '.../node_modules/cipher-base'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
	- install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "stream": false }

To Reproduce

  1. Clone example project.
npx terra-templates get wallet-provider:create-react-app your-app-name
  1. Change react-scripts from version 4.x to version 5.x install and run.
yarn add --exact [email protected]
yarn install
yarn start

From what I saw, the other dependencies affected by this upgrade are readable-stream and safe-buffer. For now, the app and packages will run by downgrading to react-scripts: 4.0.3.

Wallet Cannot Connected

Hello
I am new to terra.js and your library.
I want to access the wallet for transactions. When I follow your example, I get wallet is not connected, and neither can I use your react-template.
Screenshot from 2021-08-18 16-25-07

Screenshot from 2021-08-18 16-23-05

Use a different mainnet node

Hi, I'm trying to use a different mainnet network instead of the public node. What I'm trying is changing the lcd field to a different url in the options passed to the WalletProvider, however the terra station extension doesn't appear to respect the changes and still uses lcd.terra.dev when I'm inspecting network requests. Is it possible to change the node used by Terra Station programmatically?

Bombay Network Connection

The docs say:

"The network rules passed by the Terra Station Mobile are 0 is testnet, 1 is mainnet.

Always set testnet for 0 and mainnet for 1."

What do we do if we want to use bombay?

CRITICAL BUG ISSUE - BREAKS WALLET POST MESSAGE.

Because typeof is forgotten, posting transactions and getting TXHash result is no longer possible. That really breaks flow.

function isValidResult({ error, ...payload }: any): boolean {
  if (payload.success !== 'boolean') { // FORGOT TYPEOF
    return false;
  } else if (
    typeof payload.result === 'undefined' &&
    typeof error === 'undefined'
  ) {
    return false;
  }
  return true;
}

The proposition to avoid such scenarios: After this update, running simple yarn command updated the dependencies and caused our application to break. We suggest using proper versioning, so things like this could have been easily revertable (would have been nice, if update here would have been versioned as wallet-provider 3.6.1.)
Plus, we recommend start practicing PR reviews.

Thank you for attention, please fix this bug as soon as possible :)
TeFiLuck team relies on you guys, as well as many more applications on Terra.

Signing multiple messages in one transaction on Ledger

Hello there!

When trying to sign a transaction with multiple messages from Ledger I get an error saying "Data is invalid: JSON. Too many tokens.". Any idea for when signing a transaction with multiple messages will be supported by Ledger? This really limits a lot of use cases.

Signing a transaction fails

Hello there!

Today connectedWallet.sign started failing for me without any changes to my code.

image

Is this due to a breaking change in the chrome extension? Any advice for how to resolve this?

[plugin server-bare-modules] Package subpath './package.json' is not defined by "exports" when using remix.run

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch @terra-money/[email protected] for the project I'm working on.

this fix this error
[plugin server-bare-modules] Package subpath './package.json' is not defined by "exports"
when using remix.run

Here is the diff that solved my problem:

diff --git a/node_modules/@terra-money/wallet-provider/package.json b/node_modules/@terra-money/wallet-provider/package.json
index 57e3943..5916362 100644
--- a/node_modules/@terra-money/wallet-provider/package.json
+++ b/node_modules/@terra-money/wallet-provider/package.json
@@ -25,6 +25,7 @@
     "react": ">=17.0.0"
   },
   "exports": {
+    "./package.json": "./package.json",
     ".": {
       "import": "./index.js",
       "require": "./_commonjs/index.js",

This issue body was partially generated by patch-package.

No signature constructor using wallet connect

Please help, how can we generate signature using wallet connection (Connect wallet mobile)?
For @terra-money/wallet-provider library, signature generation in extension is supported but wallet connection is not supported.

How do we debug problems with terra station mobile transactions?

I am sending transactions to a smart contract. With the chrome extension everything works fine, but when using terra station mobile I get a 401 error. What is the best approach for debugging this? I can't find a way to get any information about the failed request aside from the status code.

How to get cw20tokens

Hi there,

I'm trying to fetch cw20tokens, however, I can't find an example, where this is actually supported.
Does this app support at all cw20tokens?

[Next.js] Uncaught SyntaxError: Unexpected template string

After updating packages dependencies to:

@terra-money/terra.js": "^3.0.1",
@terra-money/wallet-provider": "^3.1.0",

I'm getting an error Uncaught SyntaxError: Unexpected template string (It seems to be from:
`sha${Bg}` ) after running npm run export. This error is only visible on production


Temporary solution:

Set swcMinify: false in next.config.js


So I'm not sure if this issue is coming from the new compiler swcMinify from next.js or we could avoid this error by using a different syntax somewhere?

wallet doesn't update when changing network

When changing the selected network in the Terra Station chrome extension, the useWallet result doesn't update, so frontend app always uses the "last connected" wallet.

Could it be changed so that if the user changes the network, it starts over with the INITIALIZING -> WALLET_NOT_CONNECTED -> WALLET_CONNECTED cycle?

wallet-controller will not work on react-native

I am not sure if we are supporting react-native or not if we are then the wallet-controller doesn't work on react-native most probably because localStorage is being used.

are you guys going to provide this support for react-native?

`signBytes` seems to hang on ledger

When using signBytes with a ledger wallet, the terra station extension shows that it is broadcasting a transaction and the ledger doesn't seem to be prompted for anything:
image

Will ledger be supported for signBytes?

Popup with XDefi

When prompting users to connect the wallet and hitting terra station, both terra station and xdefi wallet pops up. Closing both windows and clicking terra station again, only xdefi window pops up

I have both terra station and xdefi extensions installed on brave

Brave: [Version 1.40.113 Chromium: 103.0.5060.114 (Official Build) (arm64)]

Screen Shot 2022-07-14 at 12 52 24 PM

[TERRA] No handler found event: SYN

showing this error in console

dependencies are
"@terra-money/terra.js": "^3.0.2",
"@terra-money/wallet-provider": "^3.6.5",
"react": "^17.0.2",

Add examples

  • <WalletProvider> configuration example
  • useWallet() example (wallet button)
  • useConnectedWallet() example (post Tx)
  • publish examples to Vercel

Can't Get Template on Local Machine.

Running the command (npx terra-templates get wallet-provider:vue your-app-name) i get this error

npx: installed 91 in 18.099s
Cannot use import statement outside a module

wallet connect from chrome mobile fails

hi, I am trying to connect from mobile and I get this
photo_2021-10-26 13 03 45
any suggestion on what I should do to make it work?
If I try wallet connect from the desktop it works, but when I try it on mobile it opens the station but it loads forever and throws that error.

Change network to Classic in the web wallet

Hello Team,

Can you add the change of network on the web version of the wallet. Without this addition, it is impossible to manage validators (on classic) for ledger users.

Thanks

`verifySign` function

wallet-provider includes an awesome function verifyBytes for verifying the authenticity of a SignBytesResult from using signBytes().

Could it also please support a verifySign function for verifying the authenticity of a transaction signed using sign()?

Terra Station Wallet signing problem for Classic

Hi.

When I test MsgExecuteContract throw Chrome wallet, I got some errors as below.

image

Also I did test with set 'isClassic: true' on my LocalTerra environment as well and got below error, either.

signature verification failed; please verify account number (27) and chain-id (localterra): unauthorized

But, the TerraStation Desktop was succcess for this action.

image

Could you please help on this and make sure compatibility Chrome wallet and Terra classic?
I think, it look like major issue for Classic project users in now.

Thanks.

Distribute bundled/minified js

Would be possible to distribute a bundled/minified version of the lib, like terra.js?

<script
  crossorigin
  src="https://unpkg.com/@terra-money/terra.js/dist/bundle.js"
></script>

docs for interfacing with extension?

The "non-react" examples here all bundle react, and ultimately the codebase here adds a lot to a non-react project!

I realize it might be a bit too much to ask for a more framework-agnostic refactor, but is there documentation somewhere to show how to do only the extension-interface flow?

I'd imagine that it doesn't use its own UI, just that of the extension, and should be able to do more cleanly?

(as an aside - I couldn't get the provider to build in rollup at all)

`connectedWallet.sign` typing is incorrect

When signing a transaction with ledger, the value returned by connectedWallet.sign does not match the expected return type of SignResult.

Instead of the result containing a public key of type string as SignResult indicates, an object is returned of the type {type: string; value: string}
image

Is there any package which is not tightly coupled with React ?

Hello there!

Great job for the Good work for the Wallet provider!

I am not a React user and i prefer to use WebComponents instead or pure JS is there any Generic version of the wallet provider for there compatible with different frameworks ?

Since i want to implement it with framework that i build based on Lit Html with this starter https://github.com/rxdi/starter-client-side-lit-html

I am trying to reverse engineer this code but it looks like really tightly coupled with React Hooks and it is not easily extendable for other platforms even using it with pure JS is a pure nightmare.

Any ideas how to accomplish my idea ?

I will try to replicate everything here in order to make it work more generic but i am not sure when this will happen so this is why i am asking if someone have something in mind.

Cheers!

[question] Testing best practices?

When rendering components outside of the context of the WalletProvider component (e.g. when testing):

  • the useWallet() hook returns undefined
  • the useConnectedWallet() hook raises an exception as it attempts to destructure the result of the useWallet() hook which is undefined

Is best practice to wrap any component under test in a WalletProvider, or are users best served by mocking this component in some format?

Get result of Tx (e.g. for uploading contract)?

The flow from the terra.js docs is something like this for uploading a contract

What would be the equivalent using post() or any other of the provider methods, so that I can get the final result back?

//returns a Promise<string> containing the contract code id if successful
function upload_contract(bytes) {
  const storeCode = new MsgStoreCode(wallet.key.accAddress, bytes);
  return wallet.createAndSignTx({ msgs: [storeCode], })
    .then(storeCodeTx => terra.tx.broadcast(storeCodeTx))
    .then(storeCodeTxResult => {
        if (isTxError(storeCodeTxResult)) {
          return Promise.reject(`store code failed. code: ${storeCodeTxResult.code}, codespace: ${storeCodeTxResult.codespace}, raw_log: ${storeCodeTxResult.raw_log}`);
        }

        const {
          store_code: { code_id },
        } = storeCodeTxResult.logs[0].eventsByType;

        return Promise.resolve(code_id[0]);
    });
}

error "Legacy extension only support the desktop chrome" when using Chrome Simulate Device mode

Issue Summary

When developing on Chrome, with Simulate Mobile Device mode, the library stoped working (could not connect to any wallet, it kept hanging on INITIALIZING state) with this error shown.

Screen Shot 2565-01-27 at 00 33 26

Error Message:

Uncaught (in promise) Error: [ExtensionRouter] Legacy extension only support the desktop chrome
    at ExtensionRouter.createConnector (ExtensionRouter.ts:301:1)
    at new ExtensionRouter (ExtensionRouter.ts:86:1)
    at controller.ts:218:1

Reproduction Steps:

  1. Open Wallet Provider + Create-React-App CodeSandbox from README.md
  2. Download all the files to local machine
  3. Install dependencies and run it
  4. Open it on Chrome, toggle Simulate Device, choose mobile device (I'm choosing iPhone XR)
  5. Refresh

Unable to start the application

Hello,

I am fairly new to npm and React but I have built simple applications in the past and I wanted to play around with the Terra Wallet options.

I followed the 4 simple steps described in the README file but when I try to start the application I get compiling errors

Any idea why this is happening?

`signBytes` on mobile

Will signBytes ever be supported on mobile, or will it only ever be supported by the terra station chrome extension?

Vue.js Support

Is there support for Vue.js in the future? Or should I just copy paste the relevant files into my project?

Module not found: Can't resolve `styled-components`

Using @terra-money/wallet-provider module on the frontend, and getting this issue

error - ./node_modules/@terra-money/wallet-provider/modules/extension-router/defaultSelectModal.js:5:0
Module not found: Can't resolve 'styled-components'

Import trace for requested module:
./node_modules/@terra-money/wallet-provider/modules/extension-router/ExtensionRouter.js
./node_modules/@terra-money/wallet-provider/modules/extension-router/index.js
./node_modules/@terra-money/wallet-provider/controller.js
./node_modules/@terra-money/wallet-provider/index.js

FYI, node version is v14.17.5, npm version is 6.14.14

[Feature request] Liquality wallet integration

Hello, could we integrate liquality wallet to the list with supported wallets, I tried to open a PR but got 403 when trying to push. This is the link for the extension: https://chrome.google.com/webstore/detail/liquality-wallet/kpfopkelmapcoipemfendmdcghnegimn?hl=en

Injection scripts on our side are ready for Anchor and Mirror, they have been tested just is all locally. For the tests I set in the Anchor protocol:

dangerously__chromeExtensionCompatibleBrowserCheck={(userAgent) =>
    true
 }

Just one question, should we add something like prefix for example LiqualityWallet to the user agent because I can see regex test if userAgent contains MathWallet for example

StaticWalletProvider provider doesn't provide value after updgrade from v2.0.0

Had this test in my project and completely working on v2.0.0

render(
      <StaticWalletProvider
        defaultNetwork={testnet}
        status={WalletStatus.WALLET_CONNECTED}
      >
      <Component_under_test/>
      </StaticWalletProvider>
    </MemoryRouter>
    );

<Component_under_test/> uses useWallet

after I upgraded to wallet-provider v2.2.0, and terrajs v.2.0.14
I got these errors

TypeError: Cannot destructure property 'status' of '(0 , _useWallet.useWallet)(...)' as it is undefined.
      at useConnectedWallet (src/@terra-dev/use-wallet/useConnectedWallet.ts:23:11)

Trying to make an example with Remix.run

Hey there,

I'm trying to create an example with Remix.run. But I'm experiencing issues with important terra.js on browser.

PublicKey.ts:12 Uncaught ReferenceError: Buffer is not defined

GET /node_modules/@terra-money/terra.js/src/core/staking/msgs/index.ts 404 - - 25.690 ms
GET /node_modules/@terra-money/terra.js/src/core/PublicKey.ts 404 - - 7.521 ms
GET /node_modules/@terra-money/terra.js/src/index.ts 404 - - 8.063 ms

Any idea?

WalletConnect hanging

Hi,

Just testing out the create react app sample
Working well with Chrome extension connect, but with the wallet connect with mobile station app I get "ready to connect" screen hanging indefinitely .

Is this a known issue?

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.