Skip to content

Commit

Permalink
fix: replace decomissioned cloudflare-ipfs.com with gateway.pinata.cl…
Browse files Browse the repository at this point in the history
…oud (#11401)

## **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.
  • Loading branch information
legobeat authored Oct 4, 2024
1 parent 0cc4aa0 commit ac79785
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 26 deletions.
2 changes: 1 addition & 1 deletion app/components/Base/RemoteImage/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/AssetIcon/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/Swaps/components/TokenIcon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('TokenIcon component', () => {
const icon = shallow(
<TokenIcon
symbol="DAI"
icon="https://cloudflare-ipfs.com/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ"
icon="https://gateway.pinata.cloud/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ"
/>,
);
expect(icon).toMatchSnapshot();
Expand All @@ -27,7 +27,7 @@ describe('TokenIcon component', () => {
<TokenIcon
medium
symbol="DAI"
icon="https://cloudflare-ipfs.com/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ"
icon="https://gateway.pinata.cloud/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ"
/>,
);
expect(iconMedium).toMatchSnapshot();
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/Swaps/components/TokenSelectButton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ describe('TokenSelectButton component', () => {
<TokenSelectButton
label="Select a token"
symbol="DAI"
icon="https://cloudflare-ipfs.com/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ"
icon="https://gateway.pinata.cloud/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ"
/>,
);
expect(icon).toMatchSnapshot();
const onPress = shallow(
<TokenSelectButton
label="Select a token"
symbol="DAI"
icon="https://cloudflare-ipfs.com/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ"
icon="https://gateway.pinata.cloud/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ"
onPress={dummyHandler}
/>,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand Down Expand Up @@ -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={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ exports[`TokenSelectButton component should Render correctly 4`] = `
}
>
<TokenIcon
icon="https://cloudflare-ipfs.com/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ"
icon="https://gateway.pinata.cloud/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ"
symbol="DAI"
/>
</View>
Expand All @@ -95,7 +95,7 @@ exports[`TokenSelectButton component should Render correctly 5`] = `
}
>
<TokenIcon
icon="https://cloudflare-ipfs.com/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ"
icon="https://gateway.pinata.cloud/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ"
symbol="DAI"
/>
</View>
Expand Down
2 changes: 1 addition & 1 deletion app/components/Views/confirmations/Send/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const initialState: DeepPartial<RootState> = {
},
PreferencesController: {
featureFlags: {},
ipfsGateway: 'https://cloudflare-ipfs.com/ipfs/',
ipfsGateway: 'https://gateway.pinata.cloud/ipfs/',
lostIdentities: {},
selectedAddress: MOCK_ADDRESS_2,
useTokenDetection: true,
Expand Down
2 changes: 1 addition & 1 deletion app/constants/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions app/core/AppConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/store/sagas/xmlHttpRequestOverride.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
Expand Down
5 changes: 0 additions & 5 deletions app/util/ipfs-gateways.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/util/sentry/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
Expand Down
2 changes: 1 addition & 1 deletion app/util/test/initial-background-state.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"PreferencesController": {
"featureFlags": {},
"identities": {},
"ipfsGateway": "https://cloudflare-ipfs.com/ipfs/",
"ipfsGateway": "https://gateway.pinata.cloud/ipfs/",
"lostIdentities": {},
"selectedAddress": "",
"useTokenDetection": true,
Expand Down
4 changes: 2 additions & 2 deletions e2e/fixtures/fixture-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion e2e/resources/blacklistURLs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/.*",
Expand Down

0 comments on commit ac79785

Please sign in to comment.