/* eslint-disable eqeqeq */
// Find Left Boundry of the Screen/Monitor
function FindLeftScreenBoundry() {
// Check if the window is off the primary monitor in a positive axis
// X,Y X,Y S = Screen, W = Window
// 0,0 ---------- 1280,0 ----------
if (window.leftWindowBoundry() > window.screen.width) {
return window.leftWindowBoundry() - (window.leftWindowBoundry() - window.screen.width);
// Check if the window is off the primary monitor in a negative axis
// X,Y X,Y S = Screen, W = Window
// 0,0 ---------- -1280,0 ----------
// This only works in Firefox at the moment due to a bug in Internet Explorer opening new windows into a negative axis
// However, you can move opened windows into a negative axis as a workaround
if (window.leftWindowBoundry() < 0 && window.leftWindowBoundry() > window.screen.width * -1) {
return window.screen.width * -1;
// If neither of the above, the monitor is on the primary monitor whose's screen X should be 0
window.leftScreenBoundry = FindLeftScreenBoundry;
function PopupCenter(url, title, w, h) {
const newWindow = window.open(
"resizable=1, scrollbars=1, fullscreen=0, height=" +
window.leftScreenBoundry +
window.leftScreenBoundry +
", toolbar=0, menubar=0, status=1"
function openWindowV1(type, payload, account = "", self) {
console.log(`open ${self.client}`);
// The account parameter is required for users having multiple keychain accounts.
encodeURIComponent(account) +
encodeURIComponent(self.client) +
encodeURIComponent(self.lcd) +
encodeURIComponent(self.path) +
encodeURIComponent(JSON.stringify(payload)),
function openWindowV2(type, payload, account = "", self) {
console.log(`open ${self.client}`);
// The account parameter is required for users having multiple keychain accounts.
apiUrl = "ai_request/set";
const network = "Oraichain";
encodeURIComponent(self.lcd) +
encodeURIComponent(JSON.stringify(payload)) +
export default class Keystation {
const { client, lcd, path, keystationUrl } = params;
this.keystationUrl = keystationUrl;
openWindow(type, payload, account = "") {
return process.env.REACT_APP_WALLET_VERSION == 2 ? openWindowV2(type, payload, account, self) : openWindowV1(type, payload, account, self);
export const myKeystation = new Keystation({
client: "https://api.wallet.orai.io",
lcd: "https://lcd.orai.io",
keystationUrl: "https://api.wallet.orai.io",