Render and approve inscription intents
This commit is contained in:
1 parent
35bac92c35
commit
c727c91897
1 file changed
+32
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
const id = new URLSearchParams(location.search).get('id');
|
||||
const labels = { origin:'Site', network:'Network', contentType:'Content', size:'Size', metadata:'Metadata', metaprotocol:'Metaprotocol', parent:'Parent', delegate:'Delegate', pointer:'Pointer', reinscribe:'Reinscribe', postage:'Postage', fees:'Fees' };
|
||||
const summary = document.querySelector('#summary');
|
||||
function render(data) {
|
||||
summary.replaceChildren();
|
||||
for (const [key,label] of Object.entries(labels)) {
|
||||
const dt=document.createElement('dt'), dd=document.createElement('dd');
|
||||
dt.textContent=label;
|
||||
let value=data[key];
|
||||
if(key==='size') value=`${value} bytes`;
|
||||
if(key==='metadata') value=value?'yes':'no';
|
||||
if(key==='postage'||key==='fees') value=`${value} sats`;
|
||||
dd.textContent=value ?? 'none';
|
||||
summary.append(dt,dd);
|
||||
}
|
||||
}
|
||||
chrome.runtime.sendMessage({type:'approval:get',id}, response => {
|
||||
if (response?.ok) render(response.summary);
|
||||
else document.querySelector('#error').textContent=response?.error||'Request unavailable.';
|
||||
});
|
||||
document.querySelector('#reject').onclick=()=>chrome.runtime.sendMessage({type:'approval:reject',id},()=>window.close());
|
||||
document.querySelector('#approve').onclick=()=>{
|
||||
document.querySelector('#approve').disabled=true;
|
||||
chrome.runtime.sendMessage({type:'approval:approve',id},response=>{
|
||||
if(response?.ok) window.close();
|
||||
else {
|
||||
document.querySelector('#approve').disabled=false;
|
||||
document.querySelector('#error').textContent=response?.error||'Signing failed.';
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user