wallet icon indicating copy to clipboard operation
wallet copied to clipboard

NEAR and Liquality Wallet dApp integration

Open kujtimprenkuSQA opened this issue 2 years ago • 1 comments

Description

Hi,

I am trying to use Liquality Wallet with a NEAR account from a dApp you can see the example here:

https://github.com/kujtimprenkuSQA/liquality-near-example/

There are a few things I would like to point out that could really improve the experience and fix some potential bugs/weird behaviors.

(issue) window.near conflicts with other extension wallets

The window.near namespace conflicts with another wallet SenderWallet if both wallets are installed then the window.near will always return the injected options from the SenderWallet and not LiqualityWallet

(bug) window.near.enable() method works only if you confirm the connection.

In the above example if you click the Connect with Near button which in the end calls:

await window.near.enable();

The liquality wallet opens a window to confirm the connection if we confirm it it works perfectly but the issue is if we Cancel or close the window in X at this moment I am not sure why but if we try to call window.near.enable(); for the second time it returns undefined and the popup never opens until you close the Browser and reopen it.

(bug) Actions propertynot being passed down

When trying to call wallet_sendTransaction method through window.near.request() from my understanding I think the actions key/property is not being sent to the sendTransaction function which is exposed by near-js-wallet-provider

const signAndSendTransaction = await window.near.request({
  method: "wallet_sendTransaction",
  params: [
    {
      to: "kujtim.testnet",
      value: "0",
      data: "", 
      actions: [
          "this is an invalid action but does not get triggered"
      ] 
    },
  ],
});

It looks like you are not passing the actions to the sendTransaction method. In the PermissionSend.vue component you make a call to this method replyPermission (vue store action)

And the replyPermission then dispatches another event executeRequest

Which in the end executes this check, and you can see there's no actions key in the payload for sendTransaction event.

What happens is that in the end this if block is executed since in this case options.actions would be undefined at this point a Transfer action is being created by default.

(issue) there's no way to disconnect/ logout once you're connected.

If you call await window.near.enable(); and confirm the connection then there's no way how you can logout or disconnect from the dApp unles you close the browser window.

kujtimprenkuSQA avatar Mar 21 '22 16:03 kujtimprenkuSQA

Hi @kujtimprenkuSQA Thanks for reporting this, The main issue is that we haven't implemented real NEAR connection for the wallet yet. The current window.near is a custom interface that all chains in the wallet have by default. We are now evaluating for this to be implemented. Is there a standard API for near wallets and applications that we should be implementing?

monokh avatar Mar 23 '22 11:03 monokh