Skip to content

Commit

Permalink
feat(nfts): taikoon-ui adaptation for TaikoonTokenV2 (#17593)
Browse files Browse the repository at this point in the history
  • Loading branch information
bearni95 authored Jun 14, 2024
1 parent df855a5 commit af33b3b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
19 changes: 18 additions & 1 deletion packages/taikoon-ui/src/generated/abi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/**
* - [__View Contract on Holesky Etherscan__](https://holesky.etherscan.io/address/0xe0c018615A074967db263abD4a98B4862dB4101f)
* -
* - [__View Contract on Taiko Mainnet Taikoscan__](https://taikoscan.network/address/0x4A045C5016B200F7E08a4caBB2cdA6E85bF53295)
*/
export const taikoonTokenAbi = [
{
Expand Down Expand Up @@ -38,6 +39,13 @@ export const taikoonTokenAbi = [
outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
stateMutability: 'view',
},
{
type: 'function',
inputs: [],
name: 'baseURI',
outputs: [{ name: '', internalType: 'string', type: 'string' }],
stateMutability: 'view',
},
{
type: 'function',
inputs: [],
Expand Down Expand Up @@ -292,6 +300,13 @@ export const taikoonTokenAbi = [
outputs: [],
stateMutability: 'nonpayable',
},
{
type: 'function',
inputs: [{ name: '_rootURI', internalType: 'string', type: 'string' }],
name: 'updateBaseURI',
outputs: [],
stateMutability: 'nonpayable',
},
{
type: 'function',
inputs: [
Expand Down Expand Up @@ -590,16 +605,18 @@ export const taikoonTokenAbi = [
/**
* - [__View Contract on Holesky Etherscan__](https://holesky.etherscan.io/address/0xe0c018615A074967db263abD4a98B4862dB4101f)
* -
* - [__View Contract on Taiko Mainnet Taikoscan__](https://taikoscan.network/address/0x4A045C5016B200F7E08a4caBB2cdA6E85bF53295)
*/
export const taikoonTokenAddress = {
17000: '0xe0c018615A074967db263abD4a98B4862dB4101f',
31337: '0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9',
31337: '0xa513E6E4b8f2a923D98304ec87F64353C4D5C853',
167000: '0x4A045C5016B200F7E08a4caBB2cdA6E85bF53295',
} as const;

/**
* - [__View Contract on Holesky Etherscan__](https://holesky.etherscan.io/address/0xe0c018615A074967db263abD4a98B4862dB4101f)
* -
* - [__View Contract on Taiko Mainnet Taikoscan__](https://taikoscan.network/address/0x4A045C5016B200F7E08a4caBB2cdA6E85bF53295)
*/
export const taikoonTokenConfig = {
address: taikoonTokenAddress,
Expand Down
6 changes: 2 additions & 4 deletions packages/taikoon-ui/src/lib/ipfs/get.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { PUBLIC_IPFS_GATEWAY } from './config';

export default async function get(hash: string, json?: boolean): Promise<any> {
const response = await fetch(`${PUBLIC_IPFS_GATEWAY}${hash}`);
export default async function get(url: string, json?: boolean): Promise<any> {
const response = await fetch(url);
return json ? response.json() : response.text();
}
16 changes: 2 additions & 14 deletions packages/taikoon-ui/src/lib/ipfs/getMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { IpfsError } from '../error';
import Token from '../token';
import { PUBLIC_IPFS_GATEWAY } from './config';
import get from './get';

export interface ITokenMetadata {
Expand All @@ -10,16 +8,6 @@ export interface ITokenMetadata {
}
export default async function getMetadata(tokenId: number): Promise<ITokenMetadata> {
const tokenURI = await Token.tokenURI(tokenId);
const hash = tokenURI.split('ipfs://').pop();
if (!hash) throw new IpfsError('Invalid token URI:' + tokenURI);
const metadata = (await get(hash, true)) as ITokenMetadata;

const imageHash = metadata.image.split('ipfs://').pop();

if (!imageHash) throw new IpfsError('Invalid image URI:' + metadata.image);

return {
...metadata,
image: `${PUBLIC_IPFS_GATEWAY}${imageHash}`,
};
const metadata = (await get(tokenURI, true)) as ITokenMetadata;
return metadata;
}
4 changes: 2 additions & 2 deletions packages/taikoon-ui/src/wagmi.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { injected, walletConnect } from '@wagmi/connectors';
import { createConfig, http, reconnect } from '@wagmi/core';

//import { hardhat, holesky } from '@wagmi/core/chains';
// import { hardhat, holesky } from '@wagmi/core/chains';
import { PUBLIC_WALLETCONNECT_PROJECT_ID } from '$env/static/public';

const projectId = PUBLIC_WALLETCONNECT_PROJECT_ID;
Expand All @@ -23,7 +23,7 @@ const baseConfig = {
multicall: true,
},
transports: {
// [hardhat.id]: http('http://localhost:8545'),
// [hardhat.id]: http('http://localhost:8545'),
[taiko.id]: http('https://rpc.mainnet.taiko.xyz'),
// [holesky.id]: http('https://1rpc.io/holesky'),
},
Expand Down

0 comments on commit af33b3b

Please sign in to comment.