Skip to content
Open
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
33 changes: 29 additions & 4 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const bridge = new Messaging();
* @property {string} [bridgeUrl] Override wallet.myalgo.com default frame url.
* @property {number} [timeout] Number of msec to wait the popup response, default value: 1600000 msec.
* @property {boolean} [disableLedgerNano] It will disable ledger nano accounts and returns only mnemonic accounts.
* @property {HTMLIFrameElement} [iframe] Render "popups" in this iframe rather than a new window
*/

/**
Expand Down Expand Up @@ -248,6 +249,12 @@ class MyAlgoConnect {
* @type {boolean}
*/
this.disableLedgerNano = (options && options.disableLedgerNano) ? options.disableLedgerNano : false;

/**
* @access private
* @type {HTMLIFrameElement}
*/
this.iframe = options.iframe;
}

/**
Expand All @@ -269,7 +276,12 @@ class MyAlgoConnect {
}

try {
this.currentConnectPopup = openPopup(this.url + "/connect.html");
if(this.iframe) {
this.iframe.src = this.url + "/connect.html"
this.currentConnectPopup = this.iframe.contentWindow
} else {
this.currentConnectPopup = openPopup(this.url + "/connect.html");
}

await this.waitForWindowToLoad(this.currentConnectPopup);

Expand Down Expand Up @@ -321,7 +333,12 @@ class MyAlgoConnect {
txn = prepareTxn(transaction);

try {
this.currentSigntxPopup = openPopup(this.url + "/signtx.html");
if(this.iframe) {
this.iframe.src = this.url + "/signtx.html"
this.currentSigntxPopup = this.iframe.contentWindow
} else {
this.currentSigntxPopup = openPopup(this.url + "/signtx.html");
}

await this.waitForWindowToLoad(this.currentSigntxPopup);

Expand Down Expand Up @@ -380,7 +397,13 @@ class MyAlgoConnect {
}

try {
this.currentSignLogicSigPopup = openPopup(this.url + "/logicsigtx.html");
if(this.iframe) {
this.iframe.src = this.url + "/logicsigtx.html"
this.currentSignLogicSigPopup = this.iframe.contentWindow
} else {
this.currentSignLogicSigPopup = openPopup(this.url + "/logicsigtx.html");
}

await this.waitForWindowToLoad(this.currentSignLogicSigPopup);

// Send program
Expand Down Expand Up @@ -439,7 +462,9 @@ class MyAlgoConnect {
* @returns {void}
*/
closeWindow(window) {
if (window && !window.closed && window.close) {
if (this.iframe) {
this.iframe.src = ''
} else if (window && !window.closed && window.close) {
window.close();
}
}
Expand Down