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
55 changes: 0 additions & 55 deletions .github/ISSUE_TEMPLATE/workflows/release.yml

This file was deleted.

27 changes: 13 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
workflow_dispatch

env:
REACT_APP_BLOCKNATIVE_KEY: ${{ secrets.REACT_APP_BLOCKNATIVE_KEY }}
REACT_APP_FORTMATIC_KEY: ${{ secrets.REACT_APP_FORTMATIC_KEY }}
REACT_APP_GOOGLE_ANALYTICS_ID_MAINNET: ${{ secrets.REACT_APP_GOOGLE_ANALYTICS_ID_MAINNET }}
REACT_APP_INFURA_TOKEN: ${{ secrets.REACT_APP_INFURA_TOKEN }}
Expand All @@ -21,24 +20,24 @@ jobs:
fail-fast: false
max-parallel: 15
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
os: [macos-latest, windows-latest, ubuntu-20.04]

steps:
- name: Check out Git repository
uses: actions/checkout@v2

# Add cache for yarn directory
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
# - name: Get yarn cache directory path
# id: yarn-cache-dir-path
# run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# - uses: actions/cache@v2
# id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
# with:
# path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
# key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-yarn-

- name: Patch node gyp on windows to support Visual Studio 2019
if: startsWith(matrix.os, 'windows')
Expand All @@ -52,9 +51,9 @@ jobs:
yarn global add node-gyp
yarn config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: 12
node-version: 14
- run: yarn install --frozen-lockfile --network-concurrency 1
- name: Build/Release Desktop App
env:
Expand Down
2 changes: 0 additions & 2 deletions docs/networks.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ export type GasPriceOracle = {
- **REACT_APP_GOOGLE_ANALYTICS**: Used for enabling google analytics
- **REACT_APP_PORTIS_ID**: Portis ID for enabling it on given network
- **REACT_APP_FORTMATIC_KEY**: Formatic yey for given network
- **REACT_APP_BLOCKNATIVE_KEY**: Blocknative key for given network

---
## How to add a network
Expand Down Expand Up @@ -190,7 +189,6 @@ export enum ETHEREUM_NETWORK {
* REACT_APP_GOOGLE_ANALYTICS
* REACT_APP_PORTIS_ID
* REACT_APP_FORTMATIC_KEY
* REACT_APP_BLOCKNATIVE_KEY

3) Add the **NetworkSettings** in [`src/config/networks`](/src/config/networks) as `<network_name>.ts`:

Expand Down
20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "safe-react",
"version": "2.17.0",
"version": "2.18.0",
"description": "Allowing crypto users manage funds in a safer way",
"website": "https://github.com/gnosis/safe-react#readme",
"bugs": {
Expand Down Expand Up @@ -94,21 +94,23 @@
}
]
},
"files": [
"build/",
"files": [
"build",
"patches",
"public",
"scripts",
"dev-app-update.yml",
"package.json"
],
"directories": {
"buildResources": "public/build"
"buildResources": "public/resources"
},
"mac": {
"category": "public.app-category.productivity",
"hardenedRuntime": true,
"entitlements": "public/build/entitlements.mac.plist",
"entitlements": "public/resources/entitlements.mac.plist",
"gatekeeperAssess": false,
"entitlementsInherit": "public/build/entitlements.mac.plist",
"entitlementsInherit": "public/resources/entitlements.mac.plist",
"target": [
"dmg",
"zip"
Expand Down Expand Up @@ -136,7 +138,7 @@
"target": [
"nsis"
],
"icon": "public/build/icon.ico"
"icon": "public/resources/icon.ico"
}
},
"resolutions": {
Expand All @@ -161,7 +163,7 @@
"@gnosis.pm/safe-contracts": "1.1.1-dev.2",
"@gnosis.pm/safe-react-components": "https://github.com/gnosis/safe-react-components.git#bf3a84486b7353bd25447ddff39c406f6fafecc6",
"@gnosis.pm/util-contracts": "2.0.6",
"@ledgerhq/hw-transport-node-hid-singleton": "5.36.0",
"@ledgerhq/hw-transport-node-hid-singleton": "5.38.0",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.11.0",
"@material-ui/lab": "4.0.0-alpha.56",
Expand Down Expand Up @@ -249,7 +251,7 @@
"cross-env": "^7.0.3",
"dotenv": "^8.2.0",
"dotenv-expand": "^5.1.0",
"electron": "^9.3.5",
"electron": "^9.4.0",
"electron-builder": "22.9.1",
"electron-notarize": "1.0.0",
"eslint": "^7.11.0",
Expand Down
5 changes: 3 additions & 2 deletions public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ function createWindow(port = DEFAULT_PORT) {
webPreferences: {
preload: path.join(__dirname, '../scripts/preload.js'),
allowRunningInsecureContent: true,
enableRemoteModule: true,
nativeWindowOpen: true, // need to be set in order to display modal
},
icon: electron.nativeImage.createFromPath(path.join(__dirname, '/public/build/safe.png')),
icon: electron.nativeImage.createFromPath(path.join(__dirname, '../build/resources/safe.png')),
})

mainWindow.once('ready-to-show', () => {
Expand Down Expand Up @@ -141,7 +142,7 @@ process.on('uncaughtException', function (error) {
})

app.userAgentFallback =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) old-airport-include/1.0.0 Chrome Electron/9.3.1 Safari/537.36'
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) old-airport-include/1.0.0 Chrome Electron/9.4.1 Safari/537.36'

// We have one non-context-aware module in node_modules/usb. This is used by @ledgerhq/hw-transport-node-hid
// This type of modules will be impossible to use after electron 10
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
11 changes: 11 additions & 0 deletions src/components/TransactionsFees/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { EstimationStatus } from 'src/logic/hooks/useEstimateTransactionGas'
import Paragraph from 'src/components/layout/Paragraph'
import { getNetworkInfo } from 'src/config'
import { TransactionFailText } from 'src/components/TransactionFailText'
import { useSelector } from 'react-redux'
import { providerNameSelector } from 'src/logic/wallets/store/selectors'
import { sameString } from 'src/utils/strings'
import { WALLETS } from 'src/config/networks/network.d'

type TransactionFailTextProps = {
txEstimationExecutionStatus: EstimationStatus
Expand All @@ -20,6 +24,8 @@ export const TransactionFees = ({
isOffChainSignature,
txEstimationExecutionStatus,
}: TransactionFailTextProps): React.ReactElement | null => {
const providerName = useSelector(providerNameSelector)

let transactionAction
if (isCreation) {
transactionAction = 'create'
Expand All @@ -29,6 +35,11 @@ export const TransactionFees = ({
transactionAction = 'approve'
}

// FIXME this should be removed when estimating with WalletConnect correctly
if (!providerName || sameString(providerName, WALLETS.WALLET_CONNECT)) {
return null
}

return (
<>
<Paragraph>
Expand Down
6 changes: 5 additions & 1 deletion src/logic/contracts/safeContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ export const estimateGasForDeployingSafe = async (
const proxyFactoryData = proxyFactoryMaster.methods
.createProxyWithNonce(safeMaster.options.address, gnosisSafeData, safeCreationSalt)
.encodeABI()
const gas = await calculateGasOf(proxyFactoryData, userAccount, proxyFactoryMaster.options.address)
const gas = await calculateGasOf({
data: proxyFactoryData,
from: userAccount,
to: proxyFactoryMaster.options.address,
})
const gasPrice = await calculateGasPrice()

return gas * parseInt(gasPrice, 10)
Expand Down
34 changes: 25 additions & 9 deletions src/logic/hooks/useEstimateTransactionGas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,28 @@ import { List } from 'immutable'
import { Confirmation } from 'src/logic/safe/store/models/types/confirmation'
import { checkIfOffChainSignatureIsPossible } from 'src/logic/safe/safeTxSigner'
import { ZERO_ADDRESS } from 'src/logic/wallets/ethAddresses'
import { sameString } from 'src/utils/strings'
import { WALLETS } from 'src/config/networks/network.d'

export enum EstimationStatus {
LOADING = 'LOADING',
FAILURE = 'FAILURE',
SUCCESS = 'SUCCESS',
}

const checkIfTxIsExecution = (threshold: number, preApprovingOwner?: string, txConfirmations?: number): boolean =>
txConfirmations === threshold || !!preApprovingOwner || threshold === 1
const checkIfTxIsExecution = (
threshold: number,
preApprovingOwner?: string,
txConfirmations?: number,
txType?: string,
): boolean =>
txConfirmations === threshold || !!preApprovingOwner || threshold === 1 || sameString(txType, 'spendingLimit')

const checkIfTxIsApproveAndExecution = (threshold: number, txConfirmations: number): boolean =>
txConfirmations + 1 === threshold
const checkIfTxIsApproveAndExecution = (threshold: number, txConfirmations: number, txType?: string): boolean =>
txConfirmations + 1 === threshold || sameString(txType, 'spendingLimit')

const checkIfTxIsCreation = (txConfirmations: number): boolean => txConfirmations === 0
const checkIfTxIsCreation = (txConfirmations: number, txType?: string): boolean =>
txConfirmations === 0 && !sameString(txType, 'spendingLimit')

type TransactionEstimationProps = {
txData: string
Expand Down Expand Up @@ -115,6 +123,7 @@ type UseEstimateTransactionGasProps = {
preApprovingOwner?: string
operation?: number
safeTxGas?: number
txType?: string
}

type TransactionGasEstimationResult = {
Expand All @@ -136,6 +145,7 @@ export const useEstimateTransactionGas = ({
preApprovingOwner,
operation,
safeTxGas,
txType,
}: UseEstimateTransactionGasProps): TransactionGasEstimationResult => {
const [gasEstimation, setGasEstimation] = useState<TransactionGasEstimationResult>({
txEstimationExecutionStatus: EstimationStatus.LOADING,
Expand All @@ -151,17 +161,21 @@ export const useEstimateTransactionGas = ({
const safeAddress = useSelector(safeParamAddressFromStateSelector)
const threshold = useSelector(safeThresholdSelector)
const safeVersion = useSelector(safeCurrentVersionSelector)
const { account: from, smartContractWallet } = useSelector(providerSelector)
const { account: from, smartContractWallet, name: providerName } = useSelector(providerSelector)

useEffect(() => {
const estimateGas = async () => {
if (!txData.length) {
return
}
// FIXME this should be removed when estimating with WalletConnect correctly
if (!providerName || sameString(providerName, WALLETS.WALLET_CONNECT)) {
return null
}

const isExecution = checkIfTxIsExecution(Number(threshold), preApprovingOwner, txConfirmations?.size)
const isCreation = checkIfTxIsCreation(txConfirmations?.size || 0)
const approvalAndExecution = checkIfTxIsApproveAndExecution(Number(threshold), txConfirmations?.size || 0)
const isExecution = checkIfTxIsExecution(Number(threshold), preApprovingOwner, txConfirmations?.size, txType)
const isCreation = checkIfTxIsCreation(txConfirmations?.size || 0, txType)
const approvalAndExecution = checkIfTxIsApproveAndExecution(Number(threshold), txConfirmations?.size || 0, txType)

try {
const isOffChainSignature = checkIfOffChainSignatureIsPossible(isExecution, smartContractWallet, safeVersion)
Expand Down Expand Up @@ -235,6 +249,8 @@ export const useEstimateTransactionGas = ({
safeVersion,
smartContractWallet,
safeTxGas,
txType,
providerName,
])

return gasEstimation
Expand Down
4 changes: 3 additions & 1 deletion src/logic/safe/store/actions/processTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface ProcessTransactionArgs {
safeAddress: string
tx: Transaction
userAddress: string
thresholdReached: boolean
}

type ProcessTransactionAction = ThunkAction<Promise<void | string>, AppReduxState, DispatchReturn, AnyAction>
Expand All @@ -42,6 +43,7 @@ export const processTransaction = ({
safeAddress,
tx,
userAddress,
thresholdReached,
}: ProcessTransactionArgs): ProcessTransactionAction => async (
dispatch: Dispatch,
getState: () => AppReduxState,
Expand All @@ -56,7 +58,7 @@ export const processTransaction = ({
const isExecution = approveAndExecute || (await shouldExecuteTransaction(safeInstance, nonce, lastTx))
const safeVersion = await getCurrentSafeVersion(safeInstance)

const preApprovingOwner = approveAndExecute ? userAddress : undefined
const preApprovingOwner = approveAndExecute && !thresholdReached ? userAddress : undefined
let sigs = generateSignaturesFromTxConfirmations(tx.confirmations, preApprovingOwner)

if (!sigs) {
Expand Down
Binary file modified src/logic/safe/transactions/__tests__/gas.test.ts
Binary file not shown.
Loading