Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
surinder83singh committed Mar 9, 2024
1 parent 29685de commit a4937eb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 75 deletions.
12 changes: 6 additions & 6 deletions extensions/chrome/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ async function apiBuilder(uuid, eventKey){
}
}

//temporary, just for testing via console
window.kaspa = kaspa;
// // testing ...
kaspa.signTransaction({tx_info:"xyz"}).then(result=>{
console.log("kaspa.signTransaction", result)
})
// //temporary, just for testing via console
// window.kaspa = kaspa;
// // // testing ...
// kaspa.signTransaction({tx_info:"xyz"}).then(result=>{
// console.log("kaspa.signTransaction", result)
// })
}

export {apiBuilder};
51 changes: 2 additions & 49 deletions extensions/chrome/background.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,5 @@
import {apiBuilder} from "./api.js";

// chrome.runtime.onMessage.addListener(async (message, sender, reply)=>{
// console.log("message:", message)
// console.log("sender:", sender)
// if (sender.id != chrome.runtime.id)
// return

// let {id, op, data} = message;
// if (op == "inject-page-script"){
// chrome.scripting.executeScript({
// args: message.args||[],
// target: {tabId: sender.tab.id},
// world: "MAIN",
// func: apiBuilder
// });
// }

// // if (op == "sign-transaction"){
// // reply({id, error:"TODO"})
// // }

// // if (op == "connect"){
// // reply({id, })
// // }

// // if (message.target !== "background")
// // return

// // console.log("message, sender")
// // console.log(message, sender, reply)
// // reply("from background");
// });

import init from '/kaspa-ng.js';
(async () => {

Expand Down Expand Up @@ -60,24 +28,9 @@ import init from '/kaspa-ng.js';
globalThis.openPopup = openPopup;

let kaspa_ng = await init('/kaspa-ng_bg.wasm');
console.log("init", init);
console.log("kaspa_ng", kaspa_ng);

// //TODO: move to rust
// chrome.runtime.onConnect.addListener(function(port) {
// console.log("BG: runtime.onConnect:port", port);
// if (port.sender.id != chrome.runtime.id)
// return

// let type = port.name || "CONTENT";
// port.onMessage.addListener(async function(msg) {
// console.log("BG: msg", msg)
// console.log("init", init);
// console.log("kaspa_ng", kaspa_ng);

// let response = await kaspa_ng.handle_port_message(type, msg);
// if (response){
// port.postMessage(response);
// }
// });
// });
await kaspa_ng.kaspa_ng_background();
})();
20 changes: 0 additions & 20 deletions extensions/chrome/content-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@
}

log("event.detail", event.detail);

// //forward msg to extension
// let response = await chrome.runtime.sendMessage(event.detail);
// log("sendMessage: response", response)
// //window.open(chrome.runtime.getURL("popup.html"), self, "width=400,left=100,height=800,frame=0")
// if (!response)
// return true
// //reply to page
// replyToPage(response)
port.postMessage({type: "WEBAPI", data:event.detail})
}, false);

Expand All @@ -42,15 +33,4 @@
})

port.postMessage({type: "WEBAPI", data:{action:"inject-page-script", data:[chrome.runtime.id, EVENT_KEY]}});


// //listen extension and forward message to page
// chrome.runtime.onMessage.addListener(async (msg, sender, sendResponse) => {
// log("extension message", msg, sender)
// if (sender.id !== chrome.runtime.id)
// return;

// replyToPage(msg)
// });


0 comments on commit a4937eb

Please sign in to comment.