Skip to content

Commit

Permalink
Bump
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Oct 29, 2024
1 parent 1d661a6 commit bfde181
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/thorin-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ens-tools/thorin-core",
"version": "0.1.4-3",
"version": "0.1.4-4",
"type": "module",
"main": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
Expand Down
27 changes: 23 additions & 4 deletions packages/thorin-core/src/components/connect-modal/connected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ type ENSData = {
records: Record<string, string>;
};

type ENSDataError = {
address: Address;
};

@customElement('thorin-connect-modal-connected')
export class ThorinConnectModalConnected extends LitElement {
@property({ type: String, reflect: true })
Expand Down Expand Up @@ -114,7 +118,17 @@ export class ThorinConnectModalConnected extends LitElement {
@state()
ensdata: ENSData | undefined;

@state()
ensdata_error: ENSDataError | undefined;

override updated() {
if (!this.address) return;

if (this.ensdata && this.ensdata.address === this.address) return;

if (this.ensdata_error && this.ensdata_error.address === this.address)
return;

this._fetchENS(this.address);
}

Expand Down Expand Up @@ -212,11 +226,16 @@ export class ThorinConnectModalConnected extends LitElement {
async _fetchENS(address: Address | undefined) {
if (!address || this.ensdata?.address == address) return;

const data = await fetch('https://enstate.rs/a/' + address);
const json = await data.json();
try {
const data = await fetch('https://enstate.rs/a/' + address);
const json = await data.json();

console.log(json);
this.ensdata = json;
console.log(json);
this.ensdata = json;
} catch (error) {
console.log('Failed to fetch ens data for', error);
this.ensdata_error = { address };
}
}
}

Expand Down

0 comments on commit bfde181

Please sign in to comment.