Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
TtheBC01 committed Nov 6, 2023
1 parent 1692002 commit 6febd15
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"homepage": "https://erc7529.snickerdoodle.com",
"private": true,
"dependencies": {
"@snickerdoodlelabs/contracts-sdk": "^1.5.0",
"@snickerdoodlelabs/erc7529": "1.0.2",
"@snickerdoodlelabs/objects": "^1.1.5",
"@testing-library/jest-dom": "^5.17.0",
Expand Down
4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
content="ERC-7529 Demonstration App"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
Expand All @@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>ERC-7529 Demo</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
Binary file modified public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 24 additions & 11 deletions src/DomainInput.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,51 @@
import { useState, useEffect, KeyboardEvent, ChangeEvent } from 'react';
//import { ethers, Provider } from 'ethers';
import { ethers, Provider } from 'ethers';
import { staticUtils } from '@snickerdoodlelabs/erc7529';
import { ChainId, DomainName } from '@snickerdoodlelabs/objects';
import { ERC7529Contract } from '@snickerdoodlelabs/contracts-sdk';
import { ChainId, DomainName, EVMContractAddress } from '@snickerdoodlelabs/objects';
import "reflect-metadata";
import './App.css';

export default function DomainInput() {

// Set some useful chain ids to use later

const label: string = "Enter a Domain Name:"
const [label, setLabel] = useState<string>("Enter a Domain Name:");
const [value, setValue] = useState<string>("");
const [fieldName, setFieldName] = useState<string>('field');
const [domain, setDomain] = useState<DomainName>(DomainName(''));
const [chain, setChain] = useState<ChainId>(ChainId(43113));
const [results, setResult] = useState<EVMContractAddress[]>([]);

/*
let provider: Provider;
if (window.ethereum == null) {
console.log("No ethereum provider found.");
provider = ethers.getDefaultProvider("mainnet");
} else {
provider = new ethers.BrowserProvider(window.ethereum);
console.log("Found window ethereum provider!")
}*/
}

useEffect(() => {
(async () => {
const results = await staticUtils.getContractsFromDomain(domain,chain);
if (results.isOk()) {
console.log("Contracts:", results.value);
setValue(results.value[0]);
}
try {
const results = await staticUtils.getContractsFromDomain(domain, chain);
if (results.isOk()) {
console.log("Contracts:", results.value);
if (results.value.length > 0) {
setResult(results.value);
setLabel("Found Something! Keep searching:");
}
console.log("value:", value);
if ((results.value.length === 0 || null) && (value === "Searching...")) {
setLabel("Try a different domain:");
}
}
} finally {
setValue("");
}
})();
}, [domain, chain]);
}, [domain, chain]);

function changeValue(event: ChangeEvent) {
const target = event.target;
Expand All @@ -46,6 +58,7 @@ export default function DomainInput() {
console.log(event)
if (target) {
const domainName: DomainName = DomainName((target as HTMLButtonElement).value);
setValue("Searching...");
setDomain(domainName);
}
}
Expand Down

0 comments on commit 6febd15

Please sign in to comment.