Skip to content

Commit

Permalink
set address for iframes (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
hewigovens authored Apr 7, 2021
1 parent 5b2850f commit 9339593
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions dist/trust-min.js
Git LFS file not shown
6 changes: 3 additions & 3 deletions ios/TrustWeb3Provider/DAppWebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ class DAppWebViewController: UIViewController {
@IBOutlet weak var urlField: UITextField!

var homepage: String {
return "https://chainlist.org"
return "https://bscscan.com/address/0x05ff2b0db69458a0750badebc4f9e13add608c7f"
}

let privateKey = PrivateKey(data: Data(hexString: "0x4646464646464646464646464646464646464646464646464646464646464646")!)!

lazy var scriptConfig: WKUserScriptConfig = {
return WKUserScriptConfig(
address: address,
chainId: 1,
rpcUrl: "https://mainnet.infura.io/v3/6e822818ec644335be6f0ed231f48310"
chainId: 56,
rpcUrl: "https://bsc-dataseed2.binance.org"
)
}()

Expand Down
12 changes: 10 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,16 @@ class TrustWeb3Provider extends EventEmitter {
}

setAddress(address) {
this.address = (address || "").toLowerCase();
const lowerAddress = (address || "").toLowerCase();
this.address = lowerAddress;
this.ready = !!address;
for (var i = 0; i < window.frames.length; i++) {
const frame = window.frames[i];
if (frame.ethereum.isTrust) {
frame.ethereum.address = lowerAddress;
frame.ethereum.ready = !!address;
}
}
}

setConfig(config) {
Expand Down Expand Up @@ -345,5 +353,5 @@ class TrustWeb3Provider extends EventEmitter {
window.trustwallet = {
Provider: TrustWeb3Provider,
Web3: Web3,
postMessage: null
postMessage: null,
};

0 comments on commit 9339593

Please sign in to comment.