-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restructurin' config, testin' Infura, & debuggin' load 🏂🏿
- Loading branch information
Showing
12 changed files
with
235 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
HOST='mimis.infura-ipfs.io' | ||
CID='QmPY47Dp1PcD7x1xdK7kxypUyRJfHKkPh4eVtNYBQPk5gj' | ||
FILE='metadata.2022-05-11T19:13:08.420Z.json' | ||
CIDV1="$(ipfs cid format "$CID" -v=1 -b=base32)" | ||
URL="https://$HOST/ipfs/$CID/$(urlencode "$FILE")" | ||
ROOT="$(realpath --relative-to=. "${0%/*}/../")" | ||
ENV="$ROOT/packages/ui/.env.local" | ||
USER="$(grep IPFS_AUTH_USERNAME "$ENV" | sed -e 's/.*=//' | tr -d [:space:])" | ||
PASS="$(grep IPFS_AUTH_PASSWORD "$ENV" | sed -e 's/.*=//' | tr -d [:space:])" | ||
AUTH="Basic $(echo -n "$USER:$PASS" | base64 -w100)" | ||
APIURL="https://ipfs.infura.io:5001/api/v0/cat?arg=$CID/$(urlencode "$FILE")" | ||
DWEBURL="https://$CIDV1.ipfs.dweb.link/$(urlencode "$FILE")" | ||
|
||
echo "Read \$USER = \"$USER\" & \$PASS = \"$PASS\" from $ENV" | ||
echo "Retrieving: $URL" | ||
curl -D - "$URL" | ||
echo ' ————————————————————————————————————————————————————————————————————' | ||
echo "Retrieving: $URL with Authorization" | ||
curl -D - -H "Authorization: $AUTH" "$URL" | ||
echo ' ————————————————————————————————————————————————————————————————————' | ||
echo "Retrieving: $APIURL with \`curl\` \`-u\`" | ||
curl -D - -X POST -u "$USER:$PASS" "$APIURL" | ||
echo ' ————————————————————————————————————————————————————————————————————' | ||
echo "Retrieving: $DWEBURL" | ||
curl -D - "$DWEBURL" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,95 @@ | ||
import { create as ipfsHTTPClient } from 'ipfs-http-client' | ||
import { Buffer } from 'buffer' | ||
|
||
export const CONFIG = { | ||
infuraId: ( | ||
process.env.NEXT_PUBLIC_INFURA_ID | ||
?? '781d8466252d47508e177b8637b1c2fd' | ||
), | ||
ceramicURL: ( | ||
process.env.NEXT_PUBLIC_CERAMIC_URL | ||
?? 'https://ceramic.metagame.wtf' // mainnet | ||
?? 'https://ceramic-clay.3boxlabs.com' // testnet | ||
), | ||
ceramicNetwork: ( | ||
process.env.NEXT_PUBLIC_CERAMIC_NETWORK | ||
?? 'mainnet' ?? 'testnet-clay' | ||
), | ||
contractNetwork: ( | ||
process.env.NEXT_PUBLIC_CHAIN_NAME || 'polygon' | ||
export const infuraId = ( | ||
process.env.INFURA_ID | ||
?? import.meta.env.VITE_INFURA_ID | ||
?? '12345678900987654321' | ||
) | ||
|
||
export const ceramicURL = ( | ||
process.env.CERAMIC_URL | ||
?? import.meta.env.CERAMIC_URL | ||
?? 'https://ceramic.metagame.wtf' // mainnet | ||
?? 'https://ceramic-clay.3boxlabs.com' // testnet | ||
) | ||
|
||
export const ceramicNetwork = ( | ||
process.env.CERAMIC_NETWORK | ||
?? import.meta.env.CERAMIC_NETWORK | ||
?? 'mainnet' ?? 'testnet-clay' | ||
) | ||
|
||
export const contractNetwork = ( | ||
process.env.CHAIN_NAME | ||
?? import.meta.env.VITE_CHAIN_NAME | ||
?? 'polygon' | ||
) | ||
|
||
export const ipfsLinkPattern = ( | ||
process.env.IPFS_LINK_PATTERN | ||
?? import.meta.env.IPFS_LINK_PATTERN | ||
?? 'https://{v1cid}.ipfs.dweb.link/{path}' | ||
?? 'https://mimis.infura-ipfs.io/ipfs/{cid}/{path}' | ||
) | ||
|
||
export const ipfsAuth = { | ||
username: ( | ||
process.env.IPFS_AUTH_USERNAME | ||
?? import.meta.env.VITE_IPFS_AUTH_USERNAME | ||
), | ||
ipfs: ipfsHTTPClient({ | ||
host: 'ipfs.infura.io', port: 5001, protocol: 'https' | ||
}), | ||
nftGraph: ( | ||
process.env.NEXT_PUBLIC_NFT_GRAPH | ||
?? 'https://api.thegraph.com/subgraphs/name/alberthaotan/nft-matic' | ||
password: ( | ||
process.env.IPFS_AUTH_PASSWORD | ||
?? import.meta.env.VITE_IPFS_AUTH_PASSWORD | ||
), | ||
rolePermissions: { | ||
Superuser: 'Can perform all actions on the token.', | ||
Minter: 'Can mint new instances of the token.', | ||
Caster: 'Can assign roles for the token.', | ||
Transferer: 'Can transfer the token to another account.', | ||
Configurer: 'Can change the token’s metadata URI.', | ||
Maintainer: 'Can update the token contract.', | ||
Creator: 'Can create new token types.', | ||
Limiter: 'Can set the maximum mintable allowance for a token.', | ||
Burner: 'Can destroy an instance of a token.', | ||
Destroyer: 'Can destroy a token type.', | ||
Oracle: 'Provides information about the off-chain world.', | ||
} | ||
} | ||
|
||
export default CONFIG | ||
export const Authorization = ( | ||
(ipfsAuth.username && ipfsAuth.password) ? ( | ||
`Basic ${Buffer.from(`${ipfsAuth.username}:${ipfsAuth.password}`).toString('base64')}` | ||
) : ( | ||
null | ||
) | ||
) | ||
|
||
const ipfsAPIHost = ( | ||
process.env.IPFS_API_HOST | ||
?? import.meta.env.IPFS_API_HOST | ||
?? 'ipfs.infura.io' | ||
) | ||
|
||
const ipfsAPIPort = ( | ||
process.env.IPFS_API_PORT | ||
?? import.meta.env.IPFS_API_PORT | ||
?? 5001 | ||
) | ||
|
||
export const ipfs = ipfsHTTPClient({ | ||
host: ipfsAPIHost, | ||
port: ipfsAPIPort, | ||
protocol: 'https', | ||
headers: Authorization ? { Authorization } : {}, | ||
}) | ||
|
||
export const nftGraph = ( | ||
process.env.NFT_GRAPH | ||
?? 'https://api.thegraph.com/subgraphs/name/alberthaotan/nft-matic' | ||
) | ||
|
||
export const rolePermissions = { | ||
Superuser: 'Can perform all actions on the token.', | ||
Minter: 'Can mint new instances of the token.', | ||
Caster: 'Can assign roles for the token.', | ||
Transferer: 'Can transfer the token to another account.', | ||
Configurer: 'Can change the token’s metadata URI.', | ||
Maintainer: 'Can update the token contract.', | ||
Creator: 'Can create new token types.', | ||
Limiter: 'Can set the maximum mintable allowance for a token.', | ||
Burner: 'Can destroy an instance of a token.', | ||
Destroyer: 'Can destroy a token type.', | ||
Oracle: 'Provides information about the off-chain world.', | ||
} | ||
|
||
export const nftHomepageBase = ( | ||
'https://chiev.es/#/view' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.