Skip to content

Commit

Permalink
[package] fix: bug with register contract and index ucm tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Envoy-VC committed Dec 28, 2023
1 parent f471549 commit 4ddc63b
Show file tree
Hide file tree
Showing 9 changed files with 4,850 additions and 221 deletions.
4 changes: 4 additions & 0 deletions apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
"@ant-design/cssinjs": "^1.18.1",
"@irys/sdk": "^0.1.1",
"@t3-oss/env-nextjs": "^0.7.1",
"@thirdweb-dev/chains": "^0.1.62",
"@thirdweb-dev/react": "^4.1.17",
"@thirdweb-dev/sdk": "^4.0.23",
"@vercel/og": "^0.6.1",
"antd": "^5.12.2",
"arweave": "^1.14.4",
"arweave-wallet-kit": "^1.0.3",
"arweavekit": "^1.5.1",
"atomic-toolkit": "workspace:*",
"clsx": "^2.0.0",
"ethers": "^5",
"next": "^14.0.4",
"next-seo": "^6.4.0",
"react": "18.2.0",
Expand Down
50 changes: 34 additions & 16 deletions apps/demo/src/components/common/navbar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,57 @@
import React from 'react';
import Image from 'next/image';

import { ConnectButton } from 'arweave-wallet-kit';
import { AtomicToolkitWeb } from 'atomic-toolkit';
import ConnectButton from '../connect-button';

// @ts-ignore
import { WebIrys } from '@irys/sdk';
import { providers } from 'ethers';

// Hooks
import { useAtomicToolkit } from '~/stores';
import { useAddress } from '@thirdweb-dev/react';
import { useConnection } from 'arweave-wallet-kit';

// Icons
import AtomicToolkitLogo from '~/assets/light.svg';

const Navbar = () => {
const { setAtomicToolkit } = useAtomicToolkit();
const { connected } = useConnection();
const { connected: arConnected } = useConnection();
const ethAddress = useAddress();

React.useEffect(() => {
const get = () => {
const toolkit = new AtomicToolkitWeb({});
setAtomicToolkit(toolkit);
const getIrys = async () => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const provider = new providers.Web3Provider(window.ethereum);
const wallet = { name: 'ethersv5', provider: provider };
const url = 'https://node2.irys.xyz';
const token = 'matic';
const webIrys = new WebIrys({ url, token, wallet });

await webIrys.ready();
return webIrys;
};

const get = async () => {
try {
let toolkit: AtomicToolkitWeb;
if (arConnected) {
toolkit = new AtomicToolkitWeb({});
} else {
const irys = await getIrys();
toolkit = new AtomicToolkitWeb({ irys });
}
setAtomicToolkit(toolkit);
} catch (error) {
console.log(error);
}
};

if (connected) {
if (arConnected || ethAddress !== undefined) {
get();
}
}, [connected]);
}, [arConnected, ethAddress]);

return (
<div className='fixed z-[11] h-[8vh] w-full border-b-2 border-[#E5E7EB] bg-white p-4 px-6'>
Expand All @@ -39,14 +64,7 @@ const Navbar = () => {
height={100}
/>
</div>
<ConnectButton
showBalance={false}
showProfilePicture={false}
useAns
profileModal
accent='#fff'
className='ConnectBtn !border-2 !border-black !p-0 !text-xs !text-black sm:!text-[1rem]'
/>
<ConnectButton />
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/components/common/wrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface Props {
const Wrapper = ({ children }: Props) => {
const { atomicToolkit, setAtomicToolkit } = useAtomicToolkit();
const activeAddress = useActiveAddress();
if (atomicToolkit && activeAddress) {
if (atomicToolkit) {
return <>{children}</>;
} else {
return (
Expand Down
61 changes: 33 additions & 28 deletions apps/demo/src/components/layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import React from 'react';
import { AntDesignConfigProvider, NotificationProvider } from '~/providers';
import {
AntDesignConfigProvider,
NotificationProvider,
Web3Provider,
} from '~/providers';

import { ArweaveWalletKit } from 'arweave-wallet-kit';

Expand All @@ -18,34 +22,35 @@ const Layout = ({ children }: Props) => {
return (
<>
<SEO />

<AntDesignConfigProvider>
<NotificationProvider>
<ArweaveWalletKit
theme={{
displayTheme: 'light',
}}
config={{
permissions: [
'ACCESS_ALL_ADDRESSES',
'ACCESS_ADDRESS',
'ACCESS_PUBLIC_KEY',
'ACCESS_ARWEAVE_CONFIG',
'SIGNATURE',
'DISPATCH',
],
}}
>
<div className={clsx(inter.className)}>
<Navbar />
<div className='flex flex-col pt-[8vh] lg:flex-row'>
<Sidebar />
<div className='w-full lg:ml-[16rem]'>{children}</div>
<Web3Provider>
<AntDesignConfigProvider>
<NotificationProvider>
<ArweaveWalletKit
theme={{
displayTheme: 'light',
}}
config={{
permissions: [
'ACCESS_ALL_ADDRESSES',
'ACCESS_ADDRESS',
'ACCESS_PUBLIC_KEY',
'ACCESS_ARWEAVE_CONFIG',
'SIGNATURE',
'DISPATCH',
],
}}
>
<div className={clsx(inter.className)}>
<Navbar />
<div className='flex flex-col pt-[8vh] lg:flex-row'>
<Sidebar />
<div className='w-full lg:ml-[16rem]'>{children}</div>
</div>
</div>
</div>
</ArweaveWalletKit>
</NotificationProvider>
</AntDesignConfigProvider>
</ArweaveWalletKit>
</NotificationProvider>
</AntDesignConfigProvider>
</Web3Provider>
</>
);
};
Expand Down
8 changes: 6 additions & 2 deletions apps/demo/src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ export const env = createEnv({
/**
* Client Side Environment Variables (prefixed with `NEXT_PUBLIC_`)
*/
client: {},
client: {
NEXT_PUBLIC_TW_ID: z.string().min(1),
},
/**
* Runtime Environment Variables (prefixed with `NEXT_PUBLIC_`)
*/
experimental__runtimeEnv: {},
experimental__runtimeEnv: {
NEXT_PUBLIC_TW_ID: process.env.NEXT_PUBLIC_TW_ID,
},
/**
* Skip validation of environment variables, for building without verifying the environment variables.
*/
Expand Down
3 changes: 2 additions & 1 deletion apps/demo/src/providers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import AntDesignConfigProvider from './ant-design';
import NotificationProvider from './notification';
import Web3Provider from './web3';

export { AntDesignConfigProvider, NotificationProvider };
export { AntDesignConfigProvider, NotificationProvider, Web3Provider };
2 changes: 1 addition & 1 deletion packages/atomic-toolkit/src/lib/assets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AtomicAssets extends AtomicToolkitBase {
tags,
});

const node = this.arweaveInstance ? 'arweave' : this.getIrysNode();
const node = this.irys ? this.getIrysNode() : 'arweave';
const result = retryOperation(
() => this.warp.register(tx.id, node),
maxAttempts,
Expand Down
2 changes: 1 addition & 1 deletion packages/atomic-toolkit/src/lib/tags/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export const buildTradableAssetTags = (
});
}

const { indexWithUCM = true } = opts;
const { indexWithUCM } = opts;

if (indexWithUCM) {
tags.push({ name: 'Indexed-By', value: 'ucm' });
Expand Down
Loading

0 comments on commit 4ddc63b

Please sign in to comment.