Specify wallet provider within an inpage message

This commit is contained in:
Ivan Grachev 2022-02-04 22:18:54 +03:00
parent c86ea9678e
commit 53ae306f5d
4 changed files with 8 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -332,7 +332,7 @@ class TokenaryEthereum extends EventEmitter {
networkId: this.net_version(),
host: window.location.host
};
window.tokenary.postMessage(object);
window.tokenary.postMessage(object, "ethereum");
} else {
// don't forget to verify in the app
this.sendError(id, new ProviderRpcError(4100, "provider is not ready"));

View File

@ -7,8 +7,9 @@ import TokenaryEthereum from "./ethereum";
import TokenarySolana from "./solana";
window.tokenary = {};
window.tokenary.postMessage = (jsonString) => {
window.postMessage({direction: "from-page-script", message: jsonString}, "*");
window.tokenary.postMessage = (message, provider) => {
message.provider = provider;
window.postMessage({direction: "from-page-script", message: message}, "*");
};
window.ethereum = new TokenaryEthereum();

View File

@ -165,7 +165,7 @@ class TokenarySolana extends EventEmitter {
networkId: "", // won't be there for solana
host: window.location.host
};
window.tokenary.postMessage(object);
window.tokenary.postMessage(object, "solana");
}
/**