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

Feature: Retrieve Safe Apps only guaranteed to work on the current client #3273

Merged
merged 7 commits into from Jan 14, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/release-mainnet-desktop.yml
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
max-parallel: 15
matrix:
os: [macos-latest, windows-latest, ubuntu-18.04]
os: [macos-10.15, windows-latest, ubuntu-18.04]

steps:
- name: Check out Git repository
Expand Down Expand Up @@ -70,18 +70,18 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: Desktop OSX
path: ./dist/Safe[ ]Multisig*.dmg
path: ./dist/Safe*.dmg

- name: 'Upload Artifacts Linux'
if: startsWith(matrix.os, 'ubuntu')
uses: actions/upload-artifact@v2
with:
name: Desktop Linux
path: ./dist/Safe[ ]Multisig*.AppImage
path: ./dist/Safe*.AppImage

- name: 'Upload Artifacts Windows'
if: startsWith(matrix.os, 'windows')
uses: actions/upload-artifact@v2
with:
name: Desktop Windows
path: ./dist/Safe[ ]Multisig*.exe
path: ./dist/Safe*.exe
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -170,7 +170,7 @@
"@gnosis.pm/safe-core-sdk": "^1.1.1",
"@gnosis.pm/safe-deployments": "^1.5.0",
"@gnosis.pm/safe-react-components": "^0.9.0",
"@gnosis.pm/safe-react-gateway-sdk": "2.7.5",
"@gnosis.pm/safe-react-gateway-sdk": "2.8.1",
"@ledgerhq/hw-transport-node-hid-singleton": "6.20.0",
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.0",
Expand Down
1 change: 0 additions & 1 deletion src/config/index.ts
Expand Up @@ -8,7 +8,6 @@ import {
} from '@gnosis.pm/safe-react-gateway-sdk'

import {
GATEWAY_URL,
DEFAULT_CHAIN_ID,
ETHERSCAN_API_KEY,
INFURA_TOKEN,
Expand Down
4 changes: 3 additions & 1 deletion src/logic/safe/api/fetchSafeApps.ts
Expand Up @@ -4,5 +4,7 @@ import { _getChainId } from 'src/config'
import { GATEWAY_URL } from 'src/utils/constants'

export const fetchSafeAppsList = async (): Promise<SafeAppData[]> => {
return getSafeApps(GATEWAY_URL, _getChainId())
return getSafeApps(GATEWAY_URL, _getChainId(), {
client_url: window.location.origin,
})
}
53 changes: 53 additions & 0 deletions src/logic/safe/utils/mocks/remoteConfig.json
Expand Up @@ -64,6 +64,59 @@
"SPENDING_LIMIT"
]
},
{
"transactionService": "https://safe-transaction.xdai.gnosis.io",
"chainId": "100",
"chainName": "Gnosis Chain",
"shortName": "gno",
"l2": true,
"description": "Gnosis Chain",
"rpcUri": {
"authentication": "NO_AUTHENTICATION",
"value": "https://rpc.xdaichain.com/oe-only/"
},
"safeAppsRpcUri": {
"authentication": "NO_AUTHENTICATION",
"value": "https://rpc.xdaichain.com/oe-only/"
},
"publicRpcUri": {
"authentication": "NO_AUTHENTICATION",
"value": "https://rpc.xdaichain.com/oe-only/"
},
"blockExplorerUriTemplate": {
"address": "https://blockscout.com/xdai/mainnet/address/{{address}}/transactions",
"txHash": "https://blockscout.com/xdai/mainnet/tx/{{txHash}}/",
"api": "https://blockscout.com/poa/xdai/api?module={{module}}&action={{action}}&address={{address}}&apiKey={{apiKey}}"
},
"nativeCurrency": {
"name": "xDai",
"symbol": "XDAI",
"decimals": 18,
"logoUri": "https://safe-transaction-assets.staging.gnosisdev.com/chains/100/currency_logo.png"
},
"theme": {
"textColor": "#ffffff",
"backgroundColor": "#48A9A6"
},
"gasPrice": [
{
"type": "FIXED",
"weiValue": "4000000000"
}
],
"disabledWallets": [
"metamask",
"walletConnect"
],
"features": [
"CONTRACT_INTERACTION",
"EIP1559",
"ERC721",
"SAFE_APPS",
"SAFE_TX_GAS_OPTIONAL",
"SPENDING_LIMIT"
]
},
{
"transactionService": "https://safe-transaction-polygon.staging.gnosisdev.com",
"chainId": "137",
Expand Down
@@ -1,3 +1,4 @@
import { SafeAppAccessPolicyTypes } from '@gnosis.pm/safe-react-gateway-sdk'
import { FETCH_STATUS } from 'src/utils/requests'
import { getEmptySafeApp } from '../../utils'
import { AppCard, AddCustomAppCard } from './index'
Expand All @@ -22,6 +23,9 @@ export const LoadedApp = (): React.ReactElement => (
description: 'Gnosis safe app',
fetchStatus: FETCH_STATUS.SUCCESS,
chainIds: ['4'],
accessControl: {
type: SafeAppAccessPolicyTypes.NoRestrictions,
},
}}
/>
)
23 changes: 21 additions & 2 deletions src/routes/safe/components/Apps/components/AppsList.test.tsx
@@ -1,11 +1,13 @@
import AppsList, { PINNED_APPS_LIST_TEST_ID, ALL_APPS_LIST_TEST_ID } from './AppsList'
import { render, screen, fireEvent, within, act, waitFor } from 'src/utils/test-utils'
import { SafeAppAccessPolicyTypes } from '@gnosis.pm/safe-react-gateway-sdk'

import { render, screen, fireEvent, within, act, waitFor } from 'src/utils/test-utils'
import * as appUtils from 'src/routes/safe/components/Apps/utils'
import { FETCH_STATUS } from 'src/utils/requests'
import { loadFromStorage, saveToStorage } from 'src/utils/storage'
import * as googleAnalytics from 'src/utils/googleAnalytics'

import AppsList, { PINNED_APPS_LIST_TEST_ID, ALL_APPS_LIST_TEST_ID } from './AppsList'

jest.mock('src/routes/routes', () => {
const original = jest.requireActual('src/routes/routes')
return {
Expand All @@ -30,6 +32,9 @@ jest.mock('@gnosis.pm/safe-react-gateway-sdk', () => ({
fetchStatus: 'SUCCESS',
chainIds: ['1', '4'],
provider: null,
accessControl: {
type: 'NO_RESTRICTIONS',
iamacook marked this conversation as resolved.
Show resolved Hide resolved
},
},
{
id: 3,
Expand All @@ -41,6 +46,10 @@ jest.mock('@gnosis.pm/safe-react-gateway-sdk', () => ({
fetchStatus: 'SUCCESS',
chainIds: ['1', '4'],
provider: null,
accessControl: {
type: 'DOMAIN_ALLOWLIST',
value: ['https://gnosis-safe.io'],
},
},
{
id: 14,
Expand All @@ -51,6 +60,9 @@ jest.mock('@gnosis.pm/safe-react-gateway-sdk', () => ({
fetchStatus: 'SUCCESS',
chainIds: ['1', '4'],
provider: null,
accessControl: {
type: 'NO_RESTRICTIONS',
},
},
{
id: 24,
Expand All @@ -61,6 +73,10 @@ jest.mock('@gnosis.pm/safe-react-gateway-sdk', () => ({
fetchStatus: 'SUCCESS',
chainIds: ['1', '4', '56', '100', '137', '246', '73799'],
provider: null,
accessControl: {
type: 'DOMAIN_ALLOWLIST',
value: ['https://gnosis-safe.io'],
},
},
]),
}))
Expand Down Expand Up @@ -92,6 +108,9 @@ beforeEach(() => {
chainIds: ['4'],
provider: undefined,
fetchStatus: FETCH_STATUS.SUCCESS,
accessControl: {
type: SafeAppAccessPolicyTypes.NoRestrictions,
},
}),
)
})
Expand Down
4 changes: 4 additions & 0 deletions src/routes/safe/components/Apps/utils.ts
Expand Up @@ -4,6 +4,7 @@ import memoize from 'lodash/memoize'
import { getContentFromENS } from 'src/logic/wallets/getWeb3'
import appsIconSvg from 'src/assets/icons/apps.svg'
import { FETCH_STATUS } from 'src/utils/requests'
import { SafeAppAccessPolicyTypes } from '@gnosis.pm/safe-react-gateway-sdk'

import { SafeApp } from './types'

Expand Down Expand Up @@ -47,6 +48,9 @@ export const getEmptySafeApp = (url = ''): SafeApp => {
description: '',
fetchStatus: FETCH_STATUS.LOADING,
chainIds: [],
accessControl: {
usame-algan marked this conversation as resolved.
Show resolved Hide resolved
type: SafeAppAccessPolicyTypes.NoRestrictions,
},
}
}

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -2163,10 +2163,10 @@
react-media "^1.10.0"
web3-utils "^1.6.0"

"@gnosis.pm/safe-react-gateway-sdk@2.7.5":
version "2.7.5"
resolved "https://registry.yarnpkg.com/@gnosis.pm/safe-react-gateway-sdk/-/safe-react-gateway-sdk-2.7.5.tgz#5640fc8c3972397ea1135f1e552d0c3333acb8fa"
integrity sha512-kY2aOLqfm9fxZbeMa8JkyKr7S3RYdxL/B0n2rU2fRAoPULleq+a6wZ2Y+zHC+XrHpjsNi6QIA183apP+XcRYIQ==
"@gnosis.pm/safe-react-gateway-sdk@2.8.1":
version "2.8.1"
resolved "https://registry.yarnpkg.com/@gnosis.pm/safe-react-gateway-sdk/-/safe-react-gateway-sdk-2.8.1.tgz#3ed166fb49fa19837c9ce8d9ba4f29a14755e9c4"
integrity sha512-J6gJT6sbXvEPqhrWepEEgwYseo4UVUU3wNS9GNIpGMuh0zi7ZU0Gld+yXqSAoZWtS3hCntg7lyuM8W31AEjQLQ==
dependencies:
isomorphic-unfetch "^3.1.0"

Expand Down