Skip to content

Commit

Permalink
fix: expose RPC URL to token view
Browse files Browse the repository at this point in the history
  • Loading branch information
micwallace committed Sep 26, 2023
1 parent 8968645 commit 1f081ee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion javascript/engine-js/src/view/TokenViewData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ export class TokenViewData {
console.log("Loading view with data:");
console.log(tokenData);

const walletAdapter = await this.tokenScript.getEngine().getWalletAdapter();

return `
const _currentTokenInstance = JSON.parse('${JSON.stringify(tokenData).replace("^\\'", "\\'")}');
const walletAddress = '${tokenData.ownerAddress}'
const addressHex = "${tokenData.ownerAddress}";
const rpcURL = "https://public-node-api.klaytnapi.com/v1/cypress"; // TODO: provide RPC URL
const rpcURL = "${walletAdapter.getRpcUrl(tokenData.chainId)}";
const chainID = "${tokenData.chainId}";
window.web3CallBacks = {}
Expand Down
2 changes: 1 addition & 1 deletion javascript/engine-js/src/wallet/EthersAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class EthersAdapter implements IWalletAdapter {
return new Contract(contractAddr, [abiData], provider);
}

private getRpcUrl(chainId: number){
public getRpcUrl(chainId: number){

if (!this.chainConfig[chainId])
throw new Error("RPC URL is not configured for ethereum chain: " + chainId);
Expand Down
1 change: 1 addition & 0 deletions javascript/engine-js/src/wallet/IWalletAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ export interface IWalletAdapter {
listener?: ITransactionListener
): Promise<any>;
getChain(): Promise<number>;
getRpcUrl(chainId: number): string;
}

0 comments on commit 1f081ee

Please sign in to comment.