mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-11-26 23:27:14 +03:00
Merge pull request #308 from kinode-dao/bp/appstore-rpc
hotfix: app_store rpc
This commit is contained in:
commit
1757bdfaea
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
94
kinode/packages/app_store/pkg/ui/assets/index-gbdFSfOw.js
Normal file
94
kinode/packages/app_store/pkg/ui/assets/index-gbdFSfOw.js
Normal file
File diff suppressed because one or more lines are too long
@ -15,8 +15,8 @@
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1.00001, viewport-fit=cover" />
|
||||
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet'>
|
||||
<script type="module" crossorigin src="/main:app_store:sys/assets/index-LQNA9SRw.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/main:app_store:sys/assets/index-avBSgupm.css">
|
||||
<script type="module" crossorigin src="/main:app_store:sys/assets/index-gbdFSfOw.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/main:app_store:sys/assets/index-Ou0_iUYW.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -55,22 +55,24 @@ function App() {
|
||||
const provider = useProvider();
|
||||
const [nodeConnected, setNodeConnected] = useState(true); // eslint-disable-line
|
||||
|
||||
const [packageAbi, setPackageAbi] = useState<PackageStore>(
|
||||
PackageStore__factory.connect(
|
||||
PACKAGE_STORE_ADDRESSES[ChainId.OPTIMISM],
|
||||
new ethers.providers.JsonRpcProvider(RPC_URL)) // TODO: get the RPC URL from the wallet
|
||||
);
|
||||
const [packageAbi, setPackageAbi] = useState<PackageStore | undefined>(undefined);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
provider?.getNetwork().then(network => {
|
||||
// TODO: don't have this fire 20 times on load
|
||||
if (!provider) return;
|
||||
|
||||
const updatePackageAbi = async () => {
|
||||
const network = await provider.getNetwork();
|
||||
if (network.chainId === ChainId.OPTIMISM) {
|
||||
setPackageAbi(PackageStore__factory.connect(
|
||||
PACKAGE_STORE_ADDRESSES[ChainId.OPTIMISM],
|
||||
provider!.getSigner())
|
||||
)
|
||||
provider.getSigner())
|
||||
);
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
updatePackageAbi();
|
||||
|
||||
}, [provider])
|
||||
|
||||
useEffect(() => {
|
||||
@ -113,9 +115,9 @@ function App() {
|
||||
<Web3ReactProvider connectors={connectors}>
|
||||
<Router basename={BASE_URL}>
|
||||
<Routes>
|
||||
<Route path="/" element={<StorePage {...props} />} />
|
||||
<Route path={MY_APPS_PATH} element={<MyAppsPage {...props} />} />
|
||||
<Route path="/app-details/:id" element={<AppPage {...props} />} />
|
||||
<Route path="/" element={<StorePage />} />
|
||||
<Route path={MY_APPS_PATH} element={<MyAppsPage />} />
|
||||
<Route path="/app-details/:id" element={<AppPage />} />
|
||||
<Route path="/publish" element={<PublishPage {...props} />} />
|
||||
</Routes>
|
||||
</Router>
|
||||
|
@ -11,7 +11,7 @@ import { appId } from "../utils/app";
|
||||
|
||||
interface AppPageProps extends PageProps { }
|
||||
|
||||
export default function AppPage(props: AppPageProps) {
|
||||
export default function AppPage() {
|
||||
// eslint-disable-line
|
||||
const { myApps, listedApps, getListedApp } = useAppsStore();
|
||||
const navigate = useNavigate();
|
||||
|
@ -11,7 +11,7 @@ import { appId } from "../utils/app";
|
||||
|
||||
interface MyAppsPageProps extends PageProps { }
|
||||
|
||||
export default function MyAppsPage(props: MyAppsPageProps) { // eslint-disable-line
|
||||
export default function MyAppsPage() { // eslint-disable-line
|
||||
const { myApps, getMyApps } = useAppsStore()
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
@ -112,7 +112,7 @@ export default function PublishPage({
|
||||
// TODO: have a checkbox to show if it's an update of an existing package
|
||||
|
||||
const tx = await (isUpdate
|
||||
? packageAbi.updateMetadata(
|
||||
? packageAbi?.updateMetadata(
|
||||
BigNumber.from(
|
||||
utils.solidityKeccak256(
|
||||
["string", "bytes"],
|
||||
@ -122,7 +122,7 @@ export default function PublishPage({
|
||||
metadataUrl,
|
||||
metadata
|
||||
)
|
||||
: packageAbi.registerApp(
|
||||
: packageAbi?.registerApp(
|
||||
packageName,
|
||||
publisherIdDnsWireFormat,
|
||||
metadataUrl,
|
||||
@ -132,7 +132,7 @@ export default function PublishPage({
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||
|
||||
setLoading("Publishing package...");
|
||||
await tx.wait();
|
||||
await tx?.wait();
|
||||
setPublishSuccess({ packageName, publisherId });
|
||||
setPackageName("");
|
||||
setPublisherId(window.our?.node || publisherId);
|
||||
@ -170,7 +170,7 @@ export default function PublishPage({
|
||||
await setChain(OPTIMISM_OPT_HEX);
|
||||
|
||||
const tx = await
|
||||
packageAbi.unlistPacakge(
|
||||
packageAbi?.unlistPacakge(
|
||||
utils.keccak256(utils.solidityPack(
|
||||
["string", "bytes"],
|
||||
[packageName, toDNSWireFormat(publisherName)]
|
||||
@ -180,7 +180,7 @@ export default function PublishPage({
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||
|
||||
setLoading("Unlisting package...");
|
||||
await tx.wait();
|
||||
await tx?.wait();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
window.alert(
|
||||
|
@ -11,7 +11,7 @@ import classNames from 'classnames';
|
||||
|
||||
interface StorePageProps extends PageProps { }
|
||||
|
||||
export default function StorePage(props: StorePageProps) {
|
||||
export default function StorePage() {
|
||||
// eslint-disable-line
|
||||
const { listedApps, getListedApps } = useAppsStore();
|
||||
|
||||
|
@ -3,5 +3,5 @@ import { PackageStore } from "../abis/types";
|
||||
|
||||
export interface PageProps {
|
||||
provider?: ethers.providers.Web3Provider;
|
||||
packageAbi: PackageStore
|
||||
packageAbi?: PackageStore
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user