walletlink
Advanced tools
Comparing version 2.1.5 to 2.1.6
@@ -28,2 +28,3 @@ import { AddressString, Callback } from "../types"; | ||
private hasMadeFirstChainChangedEmission; | ||
private isChainOverridden; | ||
constructor(options: Readonly<WalletLinkProviderOptions>); | ||
@@ -43,2 +44,3 @@ get selectedAddress(): AddressString | undefined; | ||
setProviderInfo(jsonRpcUrl: string, chainId: number): void; | ||
private updateProviderInfo; | ||
setAppInfo(appName: string, appLogoUrl: string | null): void; | ||
@@ -45,0 +47,0 @@ enable(): Promise<AddressString[]>; |
@@ -27,4 +27,18 @@ "use strict"; | ||
this.hasMadeFirstChainChangedEmission = false; | ||
// true if mobile client has sent message to override jsonRpcUrl+chainId | ||
this.isChainOverridden = false; | ||
this._send = this.send; | ||
this._sendAsync = this.sendAsync; | ||
this.setProviderInfo = this.setProviderInfo.bind(this); | ||
this.updateProviderInfo = this.updateProviderInfo.bind(this); | ||
this.setAppInfo = this.setAppInfo.bind(this); | ||
this.enable = this.enable.bind(this); | ||
this.close = this.close.bind(this); | ||
this.send = this.send.bind(this); | ||
this.sendAsync = this.sendAsync.bind(this); | ||
this.request = this.request.bind(this); | ||
this._setAddresses = this._setAddresses.bind(this); | ||
this.scanQRCode = this.scanQRCode.bind(this); | ||
this.arbitraryRequest = this.arbitraryRequest.bind(this); | ||
this.childRequestEthereumAccounts = this.childRequestEthereumAccounts.bind(this); | ||
this._chainId = util_1.ensureIntNumber(options.chainId || 1); | ||
@@ -86,6 +100,13 @@ this._jsonRpcUrl = options.jsonRpcUrl; | ||
setProviderInfo(jsonRpcUrl, chainId) { | ||
this._jsonRpcUrl = jsonRpcUrl; | ||
if (this.isChainOverridden) | ||
return; | ||
this.updateProviderInfo(jsonRpcUrl, chainId, false); | ||
} | ||
updateProviderInfo(jsonRpcUrl, chainId, fromRelay) { | ||
if (fromRelay) | ||
this.isChainOverridden = true; | ||
const originalChainId = this._chainId; | ||
this._chainId = util_1.ensureIntNumber(chainId); | ||
const chainChanged = this._chainId !== originalChainId; | ||
this._jsonRpcUrl = jsonRpcUrl; | ||
if (chainChanged || !this.hasMadeFirstChainChangedEmission) { | ||
@@ -615,4 +636,8 @@ this.emit("chainChanged", this._chainId); | ||
return this._relayProvider().then(relay => { | ||
relay.setChainIdCallback((chainId) => this.setProviderInfo(this._jsonRpcUrl, parseInt(chainId, 10))); | ||
relay.setJsonRpcUrlCallback((jsonRpcUrl) => this.setProviderInfo(jsonRpcUrl, this._chainId)); | ||
relay.setChainIdCallback((chainId) => { | ||
this.updateProviderInfo(this._jsonRpcUrl, parseInt(chainId, 10), true); | ||
}); | ||
relay.setJsonRpcUrlCallback((jsonRpcUrl) => { | ||
this.updateProviderInfo(jsonRpcUrl, this._chainId, true); | ||
}); | ||
this._relay = relay; | ||
@@ -619,0 +644,0 @@ return relay; |
{ | ||
"name": "walletlink", | ||
"version": "2.1.5", | ||
"version": "2.1.6", | ||
"description": "WalletLink JavaScript SDK", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
292219
5748