Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set address for provider in iframes #140

Merged
merged 1 commit into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
};