From ac7978596566f148fa6892940fb5678170ba0351 Mon Sep 17 00:00:00 2001
From: legobeat <109787230+legobeat@users.noreply.github.com>
Date: Fri, 4 Oct 2024 00:44:10 +0000
Subject: [PATCH] fix: replace decomissioned cloudflare-ipfs.com with
gateway.pinata.cloud (#11401)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## **Description**
The default IPFS gateway cloudflare-ipfs.com was decomissioned on August
14 2024.
https://blog.cloudflare.com/cloudflares-public-ipfs-gateways-and-supporting-interplanetary-shipyard/
- Change default IPFS gateway from `cloudflare-ipfs.com` to
`gateway.pinata.cloud`
- Remove `cloudflare-ipfs.com` from IPFS gateways
## **Related issues**
## **Manual testing steps**
1. Set up wallet on previous version, keeping default IPFS gateway
2. Observe IPFS gateway requests failing
2. Upgrade metamask-mobile with this patch
3. Observe IPFS gateway requests succeeding
## **Screenshots/Recordings**
### **Before**
### **After**
## **Pre-merge author checklist**
- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
---
app/components/Base/RemoteImage/index.test.tsx | 2 +-
app/components/UI/AssetIcon/index.test.tsx | 4 ++--
app/components/UI/Swaps/components/TokenIcon.test.js | 4 ++--
app/components/UI/Swaps/components/TokenSelectButton.test.js | 4 ++--
.../UI/Swaps/components/__snapshots__/TokenIcon.test.js.snap | 4 ++--
.../components/__snapshots__/TokenSelectButton.test.js.snap | 4 ++--
app/components/Views/confirmations/Send/index.test.tsx | 2 +-
app/constants/network.js | 2 +-
app/core/AppConstants.ts | 4 ++--
app/store/sagas/xmlHttpRequestOverride.test.ts | 2 +-
app/util/ipfs-gateways.json | 5 -----
app/util/sentry/utils.test.ts | 2 +-
app/util/test/initial-background-state.json | 2 +-
e2e/fixtures/fixture-builder.js | 4 ++--
e2e/resources/blacklistURLs.json | 2 +-
15 files changed, 21 insertions(+), 26 deletions(-)
diff --git a/app/components/Base/RemoteImage/index.test.tsx b/app/components/Base/RemoteImage/index.test.tsx
index 64e352fa413..429dfeb7ca5 100644
--- a/app/components/Base/RemoteImage/index.test.tsx
+++ b/app/components/Base/RemoteImage/index.test.tsx
@@ -6,7 +6,7 @@ jest.mock('react-redux', () => ({
...jest.requireActual('react-redux'),
useSelector: jest
.fn()
- .mockImplementation(() => 'https://cloudflare-ipfs.com/ipfs/'),
+ .mockImplementation(() => 'https://gateway.pinata.cloud/ipfs/'),
}));
jest.mock('../../../components/hooks/useIpfsGateway', () => jest.fn());
diff --git a/app/components/UI/AssetIcon/index.test.tsx b/app/components/UI/AssetIcon/index.test.tsx
index a553d618e34..f0451a2a5f5 100644
--- a/app/components/UI/AssetIcon/index.test.tsx
+++ b/app/components/UI/AssetIcon/index.test.tsx
@@ -10,7 +10,7 @@ const mockInitialState = {
...backgroundState,
PreferencesController: {
featureFlags: {},
- ipfsGateway: 'https://cloudflare-ipfs.com/ipfs/',
+ ipfsGateway: 'https://gateway.pinata.cloud/ipfs/',
lostIdentities: {},
selectedAddress: '0x76cf1CdD1fcC252442b50D6e97207228aA4aefC3',
useTokenDetection: true,
@@ -24,7 +24,7 @@ const mockInitialState = {
_W: {
featureFlags: {},
frequentRpcList: [],
- ipfsGateway: 'https://cloudflare-ipfs.com/ipfs/',
+ ipfsGateway: 'https://gateway.pinata.cloud/ipfs/',
lostIdentities: {},
selectedAddress: '0x76cf1CdD1fcC252442b50D6e97207228aA4aefC3',
useTokenDetection: true,
diff --git a/app/components/UI/Swaps/components/TokenIcon.test.js b/app/components/UI/Swaps/components/TokenIcon.test.js
index 015b0328237..f8f0bc4adb3 100644
--- a/app/components/UI/Swaps/components/TokenIcon.test.js
+++ b/app/components/UI/Swaps/components/TokenIcon.test.js
@@ -13,7 +13,7 @@ describe('TokenIcon component', () => {
const icon = shallow(
,
);
expect(icon).toMatchSnapshot();
@@ -27,7 +27,7 @@ describe('TokenIcon component', () => {
,
);
expect(iconMedium).toMatchSnapshot();
diff --git a/app/components/UI/Swaps/components/TokenSelectButton.test.js b/app/components/UI/Swaps/components/TokenSelectButton.test.js
index 421d84de6fd..328501a798a 100644
--- a/app/components/UI/Swaps/components/TokenSelectButton.test.js
+++ b/app/components/UI/Swaps/components/TokenSelectButton.test.js
@@ -19,7 +19,7 @@ describe('TokenSelectButton component', () => {
,
);
expect(icon).toMatchSnapshot();
@@ -27,7 +27,7 @@ describe('TokenSelectButton component', () => {
,
);
diff --git a/app/components/UI/Swaps/components/__snapshots__/TokenIcon.test.js.snap b/app/components/UI/Swaps/components/__snapshots__/TokenIcon.test.js.snap
index 7d76d1bfc00..8b00e7564fd 100644
--- a/app/components/UI/Swaps/components/__snapshots__/TokenIcon.test.js.snap
+++ b/app/components/UI/Swaps/components/__snapshots__/TokenIcon.test.js.snap
@@ -57,7 +57,7 @@ exports[`TokenIcon component should Render correctly 4`] = `
onError={[Function]}
source={
{
- "uri": "https://cloudflare-ipfs.com/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ",
+ "uri": "https://gateway.pinata.cloud/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ",
}
}
style={
@@ -146,7 +146,7 @@ exports[`TokenIcon component should Render correctly 8`] = `
onError={[Function]}
source={
{
- "uri": "https://cloudflare-ipfs.com/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ",
+ "uri": "https://gateway.pinata.cloud/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ",
}
}
style={
diff --git a/app/components/UI/Swaps/components/__snapshots__/TokenSelectButton.test.js.snap b/app/components/UI/Swaps/components/__snapshots__/TokenSelectButton.test.js.snap
index 56f38e96af9..8c6472bfbac 100644
--- a/app/components/UI/Swaps/components/__snapshots__/TokenSelectButton.test.js.snap
+++ b/app/components/UI/Swaps/components/__snapshots__/TokenSelectButton.test.js.snap
@@ -71,7 +71,7 @@ exports[`TokenSelectButton component should Render correctly 4`] = `
}
>
@@ -95,7 +95,7 @@ exports[`TokenSelectButton component should Render correctly 5`] = `
}
>
diff --git a/app/components/Views/confirmations/Send/index.test.tsx b/app/components/Views/confirmations/Send/index.test.tsx
index 299548370c8..a1d650918ef 100644
--- a/app/components/Views/confirmations/Send/index.test.tsx
+++ b/app/components/Views/confirmations/Send/index.test.tsx
@@ -65,7 +65,7 @@ const initialState: DeepPartial = {
},
PreferencesController: {
featureFlags: {},
- ipfsGateway: 'https://cloudflare-ipfs.com/ipfs/',
+ ipfsGateway: 'https://gateway.pinata.cloud/ipfs/',
lostIdentities: {},
selectedAddress: MOCK_ADDRESS_2,
useTokenDetection: true,
diff --git a/app/constants/network.js b/app/constants/network.js
index cc86e8e7ce9..5a804714de8 100644
--- a/app/constants/network.js
+++ b/app/constants/network.js
@@ -11,7 +11,7 @@ export const RPC = NetworkType.rpc;
export const NO_RPC_BLOCK_EXPLORER = 'NO_BLOCK_EXPLORER';
export const PRIVATENETWORK = 'PRIVATENETWORK';
export const DEFAULT_MAINNET_CUSTOM_NAME = 'Ethereum Main Custom';
-export const IPFS_DEFAULT_GATEWAY_URL = 'https://cloudflare-ipfs.com/ipfs/';
+export const IPFS_DEFAULT_GATEWAY_URL = 'https://gateway.pinata.cloud/ipfs/';
/**
* @enum {string}
diff --git a/app/core/AppConstants.ts b/app/core/AppConstants.ts
index e9a3ee64d44..798e07e00b8 100644
--- a/app/core/AppConstants.ts
+++ b/app/core/AppConstants.ts
@@ -12,8 +12,8 @@ export default {
DEFAULT_SEARCH_ENGINE: 'DuckDuckGo',
TX_CHECK_BACKGROUND_FREQUENCY: 30000,
IPFS_OVERRIDE_PARAM: 'mm_override',
- IPFS_DEFAULT_GATEWAY_URL: 'https://cloudflare-ipfs.com/ipfs/',
- IPNS_DEFAULT_GATEWAY_URL: 'https://cloudflare-ipfs.com/ipns/',
+ IPFS_DEFAULT_GATEWAY_URL: 'https://gateway.pinata.cloud/ipfs/',
+ IPNS_DEFAULT_GATEWAY_URL: 'https://gateway.pinata.cloud/ipns/',
SWARM_DEFAULT_GATEWAY_URL: 'https://swarm-gateways.net/bzz:/',
supportedTLDs: ['eth', 'xyz', 'test'],
MAX_PUSH_NOTIFICATION_PROMPT_TIMES: 2,
diff --git a/app/store/sagas/xmlHttpRequestOverride.test.ts b/app/store/sagas/xmlHttpRequestOverride.test.ts
index 2656b047fe0..fa2b4ed5ccb 100644
--- a/app/store/sagas/xmlHttpRequestOverride.test.ts
+++ b/app/store/sagas/xmlHttpRequestOverride.test.ts
@@ -14,7 +14,7 @@ const blockedURLs = [
];
const notBlockedURLs = [
'https://proxy.metafi.codefi.network/opensea/api/v2',
- 'https://cloudflare-ipfs.com/',
+ 'https://gateway.pinata.cloud/',
'https://api.etherscan.io/',
'https://api2.branch.io/',
'https://cdn.branch.io/',
diff --git a/app/util/ipfs-gateways.json b/app/util/ipfs-gateways.json
index 1e4c5b816e4..20e6d4f8b11 100644
--- a/app/util/ipfs-gateways.json
+++ b/app/util/ipfs-gateways.json
@@ -14,11 +14,6 @@
"key": 2,
"label": "https://ipfs.infura.io/ipfs/"
},
- {
- "value": "https://cloudflare-ipfs.com/ipfs/",
- "key": 17,
- "label": "https://cloudflare-ipfs.com/ipfs/"
- },
{
"value": "https://gateway.pinata.cloud/ipfs/",
"key": 24,
diff --git a/app/util/sentry/utils.test.ts b/app/util/sentry/utils.test.ts
index a0b5fceb3ef..30b8c835388 100644
--- a/app/util/sentry/utils.test.ts
+++ b/app/util/sentry/utils.test.ts
@@ -252,7 +252,7 @@ describe('captureSentryFeedback', () => {
name: 'Account 1',
},
},
- ipfsGateway: 'https://cloudflare-ipfs.com/ipfs/',
+ ipfsGateway: 'https://gateway.pinata.cloud/ipfs/',
isIpfsGatewayEnabled: true,
isMultiAccountBalancesEnabled: true,
lostIdentities: {},
diff --git a/app/util/test/initial-background-state.json b/app/util/test/initial-background-state.json
index 9cf1471581a..43b772a055b 100644
--- a/app/util/test/initial-background-state.json
+++ b/app/util/test/initial-background-state.json
@@ -76,7 +76,7 @@
"PreferencesController": {
"featureFlags": {},
"identities": {},
- "ipfsGateway": "https://cloudflare-ipfs.com/ipfs/",
+ "ipfsGateway": "https://gateway.pinata.cloud/ipfs/",
"lostIdentities": {},
"selectedAddress": "",
"useTokenDetection": true,
diff --git a/e2e/fixtures/fixture-builder.js b/e2e/fixtures/fixture-builder.js
index 374b63e76fb..76ac9c29eec 100644
--- a/e2e/fixtures/fixture-builder.js
+++ b/e2e/fixtures/fixture-builder.js
@@ -224,7 +224,7 @@ class FixtureBuilder {
importTime: 1684232000456,
},
},
- ipfsGateway: 'https://cloudflare-ipfs.com/ipfs/',
+ ipfsGateway: 'https://gateway.pinata.cloud/ipfs/',
lostIdentities: {},
selectedAddress: '0x76cf1CdD1fcC252442b50D6e97207228aA4aefC3',
useTokenDetection: true,
@@ -245,7 +245,7 @@ class FixtureBuilder {
importTime: 1684232000456,
},
},
- ipfsGateway: 'https://cloudflare-ipfs.com/ipfs/',
+ ipfsGateway: 'https://gateway.pinata.cloud/ipfs/',
lostIdentities: {},
selectedAddress: '0x76cf1CdD1fcC252442b50D6e97207228aA4aefC3',
useTokenDetection: true,
diff --git a/e2e/resources/blacklistURLs.json b/e2e/resources/blacklistURLs.json
index cfa117ffc65..e8b620c8ca8 100644
--- a/e2e/resources/blacklistURLs.json
+++ b/e2e/resources/blacklistURLs.json
@@ -8,7 +8,7 @@
".*static.cx.metamask.io/.*",
".*rpc.tenderly.co/.*",
".*api-goerli.etherscan.io/.*",
- ".*cloudflare-ipfs.com/.*",
+ ".*gateway.pinata.cloud/.*",
".*stale.*",
".*phishing-detection.metafi.codefi.network/.*",
".*phishing-detection.cx.metamask.io/.*",