Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
!.eslintrc.js
build
config
contracts
/config
/contracts
flow-typed
flow-typed/npm
migrations
node_modules
public
scripts
src/assets
src/config
src/types/contracts
test
4 changes: 2 additions & 2 deletions src/config/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('Config Services', () => {
jest.mock('src/utils/constants', () => ({
NODE_ENV: 'production',
NETWORK: 'MAINNET',
APP_ENV: 'production'
APP_ENV: 'production',
}))
const { getTxServiceUrl, getGnosisSafeAppsUrl } = require('src/config')
const TX_SERVICE_URL = mainnet.environment.production.txServiceUrl
Expand All @@ -100,7 +100,7 @@ describe('Config Services', () => {
jest.mock('src/utils/constants', () => ({
NODE_ENV: 'production',
NETWORK: 'XDAI',
APP_ENV: 'production'
APP_ENV: 'production',
}))
const { getTxServiceUrl, getGnosisSafeAppsUrl } = require('src/config')
const TX_SERVICE_URL = xdai.environment.production.txServiceUrl
Expand Down
16 changes: 8 additions & 8 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ const getCurrentEnvironment = (): string => {
}

type NetworkSpecificConfiguration = EnvironmentSettings & {
network: NetworkSettings,
disabledFeatures?: SafeFeatures,
disabledWallets?: Wallets,
network: NetworkSettings
disabledFeatures?: SafeFeatures
disabledWallets?: Wallets
}

const configuration = (): NetworkSpecificConfiguration => {
Expand All @@ -60,7 +60,7 @@ const configuration = (): NetworkSpecificConfiguration => {
...networkBaseConfig,
network: configFile.network,
disabledFeatures: configFile.disabledFeatures,
disabledWallets: configFile.disabledWallets
disabledWallets: configFile.disabledWallets,
}
}

Expand Down Expand Up @@ -137,18 +137,18 @@ const fetchContractABI = memoize(
(url, contractAddress) => `${url}_${contractAddress}`,
)

const getNetworkExplorerApiKey = (networkExplorerName: string): string | undefined=> {
const getNetworkExplorerApiKey = (networkExplorerName: string): string | undefined => {
switch (networkExplorerName.toLowerCase()) {
case 'etherscan': {
return ETHERSCAN_API_KEY
return ETHERSCAN_API_KEY
}
default: {
return undefined
}
}
}

export const getContractABI = async (contractAddress: string) =>{
export const getContractABI = async (contractAddress: string) => {
const { apiUrl, name } = getNetworkExplorerInfo()

const apiKey = getNetworkExplorerApiKey(name)
Expand Down Expand Up @@ -181,7 +181,7 @@ export const getExplorerInfo = (hash: string): BlockScanInfo => {
const type = hash.length > 42 ? 'tx' : 'address'
return () => ({
url: `${url}/${type}/${hash}`,
alt: name || '',
alt: name || '',
})
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/config/networks/__tests__/networks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ describe('Networks config files test', () => {
return
}

const environmentConfigKeys = Object
.keys(networkConfigElement)
.filter((environmentConfigKey) =>
environmentConfigKey.endsWith('Uri') && !!networkConfigElement[environmentConfigKey]
)
const environmentConfigKeys = Object.keys(networkConfigElement).filter(
(environmentConfigKey) =>
environmentConfigKey.endsWith('Uri') && !!networkConfigElement[environmentConfigKey],
)

// Then
environmentConfigKeys.forEach((environmentConfigKey) => {
const networkConfigElementUri = networkConfigElement[environmentConfigKey]
const isValid = isValidURL(networkConfigElementUri)

if (!isValid) {
console.log(`Invalid URI in "${networkFileName}" at ${environment}.${environmentConfigKey}:`, networkConfigElementUri)
console.log(
`Invalid URI in "${networkFileName}" at ${environment}.${environmentConfigKey}:`,
networkConfigElementUri,
)
}

expect(isValid).toBeTruthy()
Expand Down
2 changes: 1 addition & 1 deletion src/config/networks/energy_web_chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const mainnet: NetworkConfig = {
WALLETS.WALLET_LINK,
WALLETS.AUTHEREUM,
WALLETS.LATTICE,
]
],
}

export default mainnet
2 changes: 1 addition & 1 deletion src/config/networks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export default {
rinkeby,
xdai,
energy_web_chain,
volta
volta,
}
2 changes: 1 addition & 1 deletion src/config/networks/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const mainnet: NetworkConfig = {
decimals: 18,
logoUri: EtherLogo,
},
}
},
}

export default mainnet
30 changes: 16 additions & 14 deletions src/config/networks/network.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ export enum ETHEREUM_NETWORK {

export type NetworkSettings = {
// TODO: id now seems to be unnecessary
id: ETHEREUM_NETWORK,
backgroundColor: string,
textColor: string,
label: string,
isTestNet: boolean,
nativeCoin: Token,
id: ETHEREUM_NETWORK
backgroundColor: string
textColor: string
label: string
isTestNet: boolean
nativeCoin: Token
}

// something around this to display or not some critical sections in the app, depending on the network support
Expand All @@ -73,14 +73,16 @@ export type GasPriceOracle = {
gasParameter: string
}

type GasPrice = {
gasPrice: number
gasPriceOracle?: GasPriceOracle
} | {
gasPrice?: number
// for infura there's a REST API Token required stored in: `REACT_APP_INFURA_TOKEN`
gasPriceOracle: GasPriceOracle
}
type GasPrice =
| {
gasPrice: number
gasPriceOracle?: GasPriceOracle
}
| {
gasPrice?: number
// for infura there's a REST API Token required stored in: `REACT_APP_INFURA_TOKEN`
gasPriceOracle: GasPriceOracle
}

export type EnvironmentSettings = GasPrice & {
txServiceUrl: string
Expand Down
7 changes: 2 additions & 5 deletions src/config/networks/xdai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ const baseConfig: EnvironmentSettings = {
const xDai: NetworkConfig = {
environment: {
staging: {
...baseConfig
...baseConfig,
},
production: {
...baseConfig,
safeAppsUrl: 'https://apps-xdai.gnosis-safe.io',

},
},
network: {
Expand Down Expand Up @@ -52,9 +51,7 @@ const xDai: NetworkConfig = {
WALLETS.AUTHEREUM,
WALLETS.LATTICE,
],
disabledFeatures: [
FEATURES.ENS_LOOKUP,
],
disabledFeatures: [FEATURES.ENS_LOOKUP],
}

export default xDai
47 changes: 47 additions & 0 deletions src/logic/contracts/api/masterCopies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import axios from 'axios'
import { getTxServiceUrl } from 'src/config'
import memoize from 'lodash.memoize'

export enum MasterCopyDeployer {
GNOSIS = 'Gnosis',
CIRCLES = 'Circles',
}

type MasterCopyFetch = {
address: string
version: string
}

export type MasterCopy = {
address: string
version: string
deployer: MasterCopyDeployer
deployerRepoUrl: string
}

const extractMasterCopyInfo = (mc: MasterCopyFetch): MasterCopy => {
const isCircles = mc.version.toLowerCase().includes(MasterCopyDeployer.CIRCLES.toLowerCase())
const dashIndex = mc.version.indexOf('-')

const masterCopy = {
address: mc.address,
version: !isCircles ? mc.version : mc.version.substring(0, dashIndex),
deployer: !isCircles ? MasterCopyDeployer.GNOSIS : MasterCopyDeployer.CIRCLES,
deployerRepoUrl: !isCircles
? 'https://github.com/gnosis/safe-contracts/releases'
: 'https://github.com/CirclesUBI/safe-contracts/releases',
}
return masterCopy
}

export const fetchMasterCopies = memoize(
async (): Promise<MasterCopy[] | undefined> => {
const url = `${getTxServiceUrl()}/about/master-copies/`
try {
const res = await axios.get<{ address: string; version: string }[]>(url)
return res.data.map(extractMasterCopyInfo)
} catch (error) {
console.error('Fetching data from master-copies errored', error)
}
},
)
20 changes: 14 additions & 6 deletions src/logic/contracts/generateBatchRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,33 @@ import { AbiItem } from 'web3-utils'
*/
type MethodsArgsType = Array<string | number>

interface Props {
interface Props {
abi: AbiItem[]
address: string
batch?: BatchRequest
context?: unknown
methods: Array<string | {method: string, type?: string, args: MethodsArgsType }>
}
methods: Array<string | { method: string; type?: string; args: MethodsArgsType }>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why shouldn't we use the simple coma here , ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was prettier who changed it

}

const generateBatchRequests = <ReturnValues>({ abi, address, batch, context, methods }: Props): Promise<ReturnValues> => {
const generateBatchRequests = <ReturnValues>({
abi,
address,
batch,
context,
methods,
}: Props): Promise<ReturnValues> => {
const contractInstance = new web3.eth.Contract(abi, address)
const localBatch = new web3.BatchRequest()

const values = methods.map((methodObject) => {
let method, type, args: MethodsArgsType = []
let method,
type,
args: MethodsArgsType = []

if (typeof methodObject === 'string') {
method = methodObject
} else {
({ method, type, args } = methodObject)
;({ method, type, args } = methodObject)
}

return new Promise((resolve) => {
Expand Down
2 changes: 1 addition & 1 deletion src/logic/contracts/historicProxyCode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//

// Code of the safe v1.0.0
const proxyCodeV10 =
Expand Down
Loading