Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CU-864efmq36 - Change NWD to use wallet-connect-sdk-wallet-react #2498

Merged
merged 1 commit into from
Jun 27, 2023

Conversation

raulduartep
Copy link
Contributor

What current issue(s) from Trello/Github does this address?

What problem does this PR solve?

How did you solve this problem?

How did you make sure your solution works?

Are there any special changes in the code that we should be aware of?

Is there anything else we should know?

  • Unit tests written?

@lllwvlvwlll
Copy link
Member

Copy link
Contributor

@comountainclimber comountainclimber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not combine the scope of this task with the renaming of the import of neon-js

@melanke
Copy link
Contributor

melanke commented Jun 16, 2023

Max, just a warning, let's not merge this, Raul needs to fix something related to ledger first

Done

@raulduartep raulduartep force-pushed the CU-864efmq36 branch 4 times, most recently from 61bd289 to 409dbe6 Compare June 21, 2023 21:56
@raulduartep raulduartep force-pushed the CU-864efmq36 branch 3 times, most recently from 481e3fd to 13edd57 Compare June 22, 2023 19:44
const { network: proposalNetwork } = getNetworkFromProposal(proposal)

if (proposalNetwork !== net) {
showModal(MODAL_TYPES.NETWORK_SWITCH, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
showModal(MODAL_TYPES.NETWORK_SWITCH, {
return showModal(MODAL_TYPES.NETWORK_SWITCH, {
dAppName: metadata.name,
onSwitch: () => approveSession(proposalNetwork),
onCancel: rejectSession,
proposalNetwork,
})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick suggestion ☝️

@@ -0,0 +1,73 @@
// @flow

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@@ -0,0 +1,250 @@
/* eslint-disable no-nested-ternary */
// @flow

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@@ -0,0 +1,61 @@
/* eslint-disable no-nested-ternary */
// @flow

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@@ -0,0 +1,28 @@
import { withRouter } from 'react-router-dom'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { withRouter } from 'react-router-dom'
// @flow
import { withRouter } from 'react-router-dom'

@@ -0,0 +1,39 @@
// @flow

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@@ -0,0 +1,144 @@
/* eslint-disable no-nested-ternary */
// @flow

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@@ -0,0 +1,144 @@
/* eslint-disable no-nested-ternary */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* eslint-disable no-nested-ternary */

setLoading(false)
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (loading) return <ConnectionLoader />

}
}

return loading ? (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return loading ? (
return success ? (
<MessageSuccess isVerify={false} />
) :

async () => {
try {
setLoading(true)
const account = new n3Wallet.Account(isHardwareLogin ? publicKey : wif)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could be wrong but I dont think we ever need to instantiate the account with wif when performing invokeFunction 👀

@@ -0,0 +1,162 @@
/* eslint-disable no-nested-ternary */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets follow the pattern in the above file and keep the rule in place

})()
},
[rejectRequest, Component, request, showErrorNotification, history],
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is some pretty weird looking syntax, I think something like this would be cleaner:

useEffect(() => {
  async function checkUnsupportedMethod() {
    if (!Component) {
      showErrorNotification({
        message: 'unsupportedMethod',
      });
      await rejectRequest(request, {
        code: 1,
        message: 'unsupportedMethod',
      });
      history.push(ROUTES.DASHBOARD);
    }
  };

  checkUnsupportedMethod();
}, [rejectRequest, Component, request, showErrorNotification, history]);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I would even put the checkUnsupportedMethod on a separated useCallback

const { method } = request.params.request
const { rejectRequest } = useWalletConnectWallet()

const Component = useMemo(() => componentsByMethod[method], [method])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this 💪 nice work @raulduartep

const id = showInfoNotification({
message: 'Please sign the transaction on your hardware device',
autoDismiss: 0,
})(store.dispatch)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested this change?? We already dispatch this notification from other places in the application so adding it here is probably going to cause it to render twice

export const walletConnectOptions: TOptions = {
clientOptions: {
metadata: {
name: 'CoZ Wallet Prototype',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldnt this be Neon Walletnot CoZ Wallet Prototype

@melanke melanke merged commit 2800340 into dev Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants