Skip to content

Commit 2a503e0

Browse files
committed
feat: integrate helia verified fetch
1 parent ea47b92 commit 2a503e0

6 files changed

Lines changed: 1084 additions & 7 deletions

File tree

.env.mainnet

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ VITE_WORLD_ADDRESS =
33
VITE_WORLD_BLOCK_NUMBER =
44
VITE_GRAPH_URI = https://gateway-arbitrum.network.thegraph.com/api/9841726d5ed39b747fd9b31078e67c3b/subgraphs/id/4DC8D9kNX7sw8ayCNgsWUNcHtJvQiDTwKTkWudWDowKC
55
VITE_ANNUALRATE = 0.1
6-
VITE_IPFS_GATEWAY = https://trustless-gateway.link
76
VITE_LIVEPEER_API_KEY=8cdf71bd-3f27-46e8-991b-411a0f75b91f

.env.testnet

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ VITE_WORLD_ADDRESS = 0x943e0b3F1926008f2e1bEFCBc55FA2A75CeC2452
33
VITE_WORLD_BLOCK_NUMBER = 6992231
44
VITE_GRAPH_URI = https://gateway-arbitrum.network.thegraph.com/api/9841726d5ed39b747fd9b31078e67c3b/subgraphs/id/Dv2u1QabAxCxjN59putrh24pLPuBCy8PidbEc4fZBFAo
55
VITE_ANNUALRATE = 0.1
6-
VITE_IPFS_GATEWAY = https://trustless-gateway.link
76
VITE_LIVEPEER_API_KEY=8cdf71bd-3f27-46e8-991b-411a0f75b91f

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"@geo-web/sdk": "^4.4.0",
1212
"@geo-web/types": "^0.2.0",
1313
"@google/model-viewer": "^3.2.1",
14+
"@helia/verified-fetch": "^1.3.14",
1415
"@livepeer/react": "^2.8.3",
1516
"@material-ui/core": "^4.11.3",
1617
"@material-ui/icons": "^4.11.2",

src/container/GeoWebSystem/GWS.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {
77
RPC_URLS_HTTP,
88
RPC_URLS_WS,
99
NETWORK_ID,
10-
IPFS_GATEWAY,
1110
WORLD,
11+
IPFS_GATEWAYS,
1212
} from "../../lib/constants";
1313
import { getGeoId, getParcelInfo } from "../../lib/api";
1414
import { useWorld } from "../../lib/world";
@@ -22,6 +22,7 @@ import {
2222
import { createPublicClient, getContract, http, Address } from "viem";
2323
import { MUDChain } from "@latticexyz/common/chains";
2424
import { useSearchParams } from "react-router-dom";
25+
import { createVerifiedFetch } from "@helia/verified-fetch";
2526

2627
type BasicProfile = {
2728
name: string;
@@ -112,9 +113,10 @@ export default function GWS() {
112113
])) as string;
113114

114115
if (tokenURI) {
115-
const basicProfileRes = await fetch(
116-
`${IPFS_GATEWAY}/ipfs/${tokenURI.slice(7)}`
117-
);
116+
const verifiedFetch = await createVerifiedFetch({
117+
gateways: IPFS_GATEWAYS,
118+
});
119+
const basicProfileRes = await verifiedFetch(tokenURI);
118120
const basicProfile = await basicProfileRes.json();
119121

120122
setBasicProfile({

src/lib/constants.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ export const WORLD = {
66
};
77
export const SUBGRAPH_URL = import.meta.env.VITE_GRAPH_URI;
88
export const GRAPH_URL = import.meta.env.VITE_GRAPH_URI;
9-
export const IPFS_GATEWAY = import.meta.env.VITE_IPFS_GATEWAY;
9+
export const IPFS_GATEWAYS = [
10+
"https://trustless-gateway.link",
11+
"https://gateway.pinata.cloud",
12+
"https://storry.tv",
13+
"https://cloudflare-ipfs.com",
14+
"https://4everland.io",
15+
"https://ipfs.runfission.com",
16+
];
17+
export const IPFS_GATEWAY = "https://cloudflare-ipfs.com";
1018
export const PINATA_API_ENDPOINT = "https://api.pinata.cloud/psa";
1119
export const STORAGE_WORKER_ENDPOINT =
1220
"https://storage-workers.geo-web.workers.dev";

0 commit comments

Comments
 (0)