Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

(Feature) [xDai] - Use parametrized network values#1437

Merged
fernandomg merged 8 commits intofeature/#1353-xDai-compatibilityfrom
feature/#1416-paremeterize-network-selection
Oct 8, 2020
Merged

(Feature) [xDai] - Use parametrized network values#1437
fernandomg merged 8 commits intofeature/#1353-xDai-compatibilityfrom
feature/#1416-paremeterize-network-selection

Conversation

@fernandomg
Copy link
Contributor

@fernandomg fernandomg commented Oct 6, 2020

This PR closes #1416, by:

  • using parameterized network values for wallet connection
  • standardizing contract addresses lookup

@fernandomg fernandomg self-assigned this Oct 6, 2020
@github-actions
Copy link

github-actions bot commented Oct 6, 2020

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions
Copy link

github-actions bot commented Oct 6, 2020

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 23 0
Ignored 3 N/A
  • Result: ✅ success

  • Annotations: 23 total


[warning] @typescript-eslint/explicit-module-boundary-types

Require explicit return and argument types on exported functions' and classes' public class methods


Report generated by eslint-plus-action

@ghost
Copy link

ghost commented Oct 6, 2020

Travis automatic deployment:
https://pr1437--safereact.review.gnosisdev.com/app

…in the truffle artifact

- also migrated safeMaster contract instance from truffle-contract to web3
@ghost
Copy link

ghost commented Oct 7, 2020

Travis automatic deployment:
https://pr1437--safereact.review.gnosisdev.com/app

@fernandomg fernandomg marked this pull request as ready for review October 7, 2020 01:07
Copy link
Contributor

@matextrem matextrem left a comment

Choose a reason for hiding this comment

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

LGTM👍

const openSafeProps = await createSafe(form, accounts[0])

return openSafeProps.safeAddress
return createSafe(form, accounts[0]).then((receipt) => receipt.events?.ProxyCreation.returnValues.proxy)
Copy link
Contributor

Choose a reason for hiding this comment

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

why are you doing this? createSafe already returns the safeAddress. https://github.com/gnosis/safe-react/pull/1437/files#diff-b5f8a9922c89630abeb184e2ec4d2539R75

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, originally was returning the safeAddress.

But then, somewhere in the middle createSafe return value was changed to return the promiEvent instead (probably because of https://github.com/gnosis/safe-react/blob/29d3b2ca3211d4d0252d61616bdab5206b6356b9/src/routes/open/container/Open.tsx#L134)

In fact, I'm not sure why the whole then block (https://github.com/gnosis/safe-react/blob/29d3b2ca3211d4d0252d61616bdab5206b6356b9/src/routes/open/container/Open.tsx#L70-L75) remained there, as it was useless.

What I wanted, was to fix the typing errors that arose after typing the contracts. If we all agree that the then block is useless, I can remove it.

Copy link
Contributor

Choose a reason for hiding this comment

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

the promise is returning return { safeAddress: safeProps.address, safeTx: receipt } so in the then you should be able to get an object with {safeAddress and safeTx} isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For that end, it should have been

return promiEvent.on(/*...*/).then(/*...*/).catch(/*...*/)

instead of

promiEvent.on(/*...*/).then(/*...*/).catch(/*...*/)
return promiEvent

as it's now.

But if you do the first, you lose the promiEvent that is needed in https://github.com/gnosis/safe-react/blob/29d3b2ca3211d4d0252d61616bdab5206b6356b9/src/routes/opening/index.tsx#L171-L177

Copy link
Contributor

Choose a reason for hiding this comment

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

make sense, feel free to remove the code in the then in Open.tsx

Copy link
Contributor

@nicosampler nicosampler left a comment

Choose a reason for hiding this comment

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

@fernandomg
LGTM, just left a commnet!

@ghost
Copy link

ghost commented Oct 7, 2020

Travis automatic deployment:
https://pr1437--safereact.review.gnosisdev.com/app

@ghost
Copy link

ghost commented Oct 7, 2020

Travis automatic deployment:
https://pr1437--safereact.review.gnosisdev.com/app

@fernandomg
Copy link
Contributor Author

The a7be1fe (#1437) is to fix the domain extraction.

image

@ghost
Copy link

ghost commented Oct 7, 2020

Travis automatic deployment:
https://pr1437--safereact.review.gnosisdev.com/app

* @param {Web3} web3
* @param {ETHEREUM_NETWORK} networkId
*/
const createGnosisSafeContract = (web3: Web3, networkId: ETHEREUM_NETWORK) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be typed to return GnosisSafe ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the returned type is inferred in this case, shall we add it anyway? I truly don't remember.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes you are right, I think it's not needed

export const NODE_ENV = process.env.NODE_ENV
export const NETWORK = process.env.REACT_APP_NETWORK?.toUpperCase() || 'RINKEBY'
export const INTERCOM_ID = APP_ENV === 'production' ? process.env.REACT_APP_INTERCOM_ID : 'plssl1fl'
export const GOOGLE_ANALYTICS_ID = {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we already discussed this, but just to be sure, I think would be a good idea to create a ticket to discuss a better way to make this config scalable without us to edit this file every time we need to support another network on analytics

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, yesterday I added a description in the setup/deployment/CI task on that regard: #1421 (comment)

TREZOR: 'TREZOR',
}

export enum ExplorerTypes {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest doing a mix between the current implementation

export const getExplorerInfo = (hash: string): BlockScanInfo => {
  const { name, url } = getNetworkExplorerInfo()

  const blockScanInfo = () => {
    const type = hash.length > 42 ? 'tx' : 'address'

    return  {
      url: `${url}${type}/${hash}`,
      alt:  name || '',
    }
  }

  return blockScanInfo
}

and deleted one.

I think is a good idea to define ExplorerTypes per network explorer. (etherscan uses /tx but blockscout could use /transaction instead)

Then we could define strategies per each type explorer (belonging to a network) and regarding the current network returning the link to the explorer

Copy link
Contributor Author

@fernandomg fernandomg Oct 8, 2020

Choose a reason for hiding this comment

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

Sorry @nicosampler, I followed the discussion where you started it, in private. Let's continue there and summarize here if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created #1450 to do this

return blockScanInfo
}

// With some wallets from web3connect you have to use their provider instance only for signing
Copy link
Contributor

Choose a reason for hiding this comment

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

regarding your concern about moving this block of code to this file, a simple solution could be to move this to another file and export it as a function that receives the rpcUrl.

Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps, a better solution is to write it as a hook.

@ghost
Copy link

ghost commented Oct 8, 2020

Travis automatic deployment:
https://pr1437--safereact.review.gnosisdev.com/app

@fernandomg fernandomg merged commit 7d28efd into feature/#1353-xDai-compatibility Oct 8, 2020
@fernandomg fernandomg deleted the feature/#1416-paremeterize-network-selection branch October 8, 2020 17:53
@github-actions github-actions bot locked and limited conversation to collaborators Oct 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants