Skip to content

Commit

Permalink
fix: Switch scriptURI to use cached discovery API
Browse files Browse the repository at this point in the history
  • Loading branch information
micwallace committed Nov 23, 2023
1 parent d8c4df7 commit aca32cd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions javascript/engine-js/src/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ export class TokenScriptEngine {
}

public async getScriptUri(chain: string, contractAddr: string) {
const provider = await this.getWalletAdapter();

// Direct RPC gets too hammered by opensea view (that doesn't allow localStorage to cache XML)
/*const provider = await this.getWalletAdapter();
let uri: string|string[]|null;
try {
Expand All @@ -237,6 +239,11 @@ export class TokenScriptEngine {
if (uri && Array.isArray(uri))
uri = uri.length ? uri[0] : null
return <string>uri;
return <string>uri;*/

const res = await fetch(`https://api.token-discovery.tokenscript.org/script-uri?chain=${chain}&contract=${contractAddr}`);
const scriptUris = await res.json();

return <string>scriptUris[0];
}
}

0 comments on commit aca32cd

Please sign in to comment.