-
Notifications
You must be signed in to change notification settings - Fork 7
/
sc2-pay.min.js
1 lines (1 loc) · 1.95 KB
/
sc2-pay.min.js
1
var sc2_pay=function(){var b=null,g={check_transfer:!0};var e=!1;function v(u,l,d,a,w,m,f){if(e||60<f)return e=!1,b=null,void(m&&m(null));console.log("Checking Steem Transfer..."+a+", amount: "+l+" "+d),steem.api.getAccountHistory(u,-1,10,function(e,n){for(var t,i=!1,o=0;o<n.length;o++){var r=n[o],c=r[1].op,s=new Date(r[1].timestamp+"Z");if(w<s&&c[1].memo==a&&"transfer"==c[0]&&c[1].to==u&&parseFloat(c[1].amount)==l&&(t=c[1].amount).substr(t.indexOf(" ")+1)==d){i=!0,b&&b.close(),m&&m(r);break}}i||setTimeout(function(){v(u,l,d,a,w,m,f+1)},2e3)})}return{requestPayment:function(e,n,t,i,o,r){if("STEEM"==i||"SBD"==i){var c=sc2.sign("transfer",{to:n,amount:t.toFixed(3)+" "+i,memo:o});s=c,u="sc2-pay-test",l=500,d=560,a=null!=window.screenLeft?window.screenLeft:screen.left,w=null!=window.screenTop?window.screenTop:screen.top,m=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,f=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height,h=m/2-l/2+a,p=f/2-d/2+w,S=window.open(s,u,"scrollbars=yes, width="+l+", height="+d+", top="+p+", left="+h),window.focus&&S.focus(),b=S,g.check_transfer&&v(n,t,i,o,new Date,r)}else console.log('Unsupported currency "'+i+'". Supported currencies are "STEEM" or "SBD".');var s,u,l,d,a,w,m,f,h,p,S},requestPaymentVessel:function(e,n,t,i,o,r){if("STEEM"==i||"SBD"==i){var c=JSON.stringify([["transfer",{from:"",to:n,amount:t.toFixed(3)+" "+i,memo:o}]]),s="steem://sign/tx/"+btoa(c)+"#eyJhbW91bnQiOnsicHJvbXB0IjpmYWxzZSwidHlwZSI6ImFzc2V0IiwibGFiZWwiOiJEb25hdGlvbiJ9LCJtZW1vIjp7InByb21wdCI6ZmFsc2UsInR5cGUiOiJ0ZXh0IiwibGFiZWwiOiJNZXNzYWdlIChPcHRpb25hbCkifSwidG8iOnsicHJvbXB0IjpmYWxzZSwidHlwZSI6InRleHQifX0=";window.location=s,g.check_transfer&&v(n,t,i,o,new Date,r,0)}else console.log('Unsupported currency "'+i+'". Supported currencies are "STEEM" or "SBD".')},setOptions:function(e){g=e},close:function(){b&&b.close()}}}();