diff --git a/public/content.js b/public/content.js index 4bbebe2..c6ecad0 100644 --- a/public/content.js +++ b/public/content.js @@ -1 +1 @@ -(function(){"use strict";var Z=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},X={exports:{}};(function(u,H){(function(D,p){u.exports=p()})(Z,function(){var D=1e3,p=6e4,L=36e5,k="millisecond",O="second",m="minute",M="hour",y="day",_="week",w="month",q="quarter",v="year",x="date",K="Invalid Date",$t=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,yt=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,wt={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(r){var e=["th","st","nd","rd"],t=r%100;return"["+r+(e[(t-20)%10]||e[t]||e[0])+"]"}},I=function(r,e,t){var i=String(r);return!i||i.length>=e?r:""+Array(e+1-i.length).join(t)+r},gt={s:I,z:function(r){var e=-r.utcOffset(),t=Math.abs(e),i=Math.floor(t/60),n=t%60;return(e<=0?"+":"-")+I(i,2,"0")+":"+I(n,2,"0")},m:function r(e,t){if(e.date()1)return r(s[0])}else{var o=e.name;A[o]=e,n=o}return!i&&n&&(C=n),n||!i&&C},l=function(r,e){if(U(r))return r.clone();var t=typeof e=="object"?e:{};return t.date=r,t.args=arguments,new B(t)},c=gt;c.l=W,c.i=U,c.w=function(r,e){return l(r,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var B=function(){function r(t){this.$L=W(t.locale,null,!0),this.parse(t)}var e=r.prototype;return e.parse=function(t){this.$d=function(i){var n=i.date,a=i.utc;if(n===null)return new Date(NaN);if(c.u(n))return new Date;if(n instanceof Date)return new Date(n);if(typeof n=="string"&&!/Z$/i.test(n)){var s=n.match($t);if(s){var o=s[2]-1||0,h=(s[7]||"0").substring(0,3);return a?new Date(Date.UTC(s[1],o,s[3]||1,s[4]||0,s[5]||0,s[6]||0,h)):new Date(s[1],o,s[3]||1,s[4]||0,s[5]||0,s[6]||0,h)}}return new Date(n)}(t),this.$x=t.x||{},this.init()},e.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},e.$utils=function(){return c},e.isValid=function(){return this.$d.toString()!==K},e.isSame=function(t,i){var n=l(t);return this.startOf(i)<=n&&n<=this.endOf(i)},e.isAfter=function(t,i){return l(t){let H="";const D="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(let p=0;p{const M=y=>{var _,w,q,v;if(!(y.source!==window||((_=y.data)==null?void 0:_.channel)!=="from-metaidwallet")){if(((w=y.data)==null?void 0:w.nonce)===L){if(window.removeEventListener("message",M),(v=(q=y.data)==null?void 0:q.res)!=null&&v.error)throw new Error(y.data.res.error);m&&typeof m=="function"&&m(y.data)}return!0}};window.addEventListener("message",M)};return await new Promise(m=>{O(M=>{m(M.res)})})}async function G(){return await d("Connect")}async function j(){return await d("Disconnect")}async function R(){return await d("IsConnected","query")}async function tt(){return await d("GetNetwork","query")}async function nt(){return await d("SwitchNetwork")}async function et(u){return await d("GetAddress","query",u)}async function rt(u){return await d("GetPublicKey","query",u)}async function it(){return await d("GetXPublicKey","query")}async function F(u){return await d("GetBalance","query",u)}async function st(u){return await d("GetUtxos","query",u)}async function at(u){return await d("EciesEncrypt","authorize",u)}async function ut(u){return await d("EciesDecrypt","authorize",u)}async function ot(u){return await d("SignMessage","authorize",u)}async function ct(u){return await d("VerifySignature","query",u)}async function ft(u){return await d("SignTransaction","authorize",u)}async function ht(u){return await d("Transfer","authorize",u)}async function dt(u){return await d("Merge","authorize",u)}async function J(u){return await d("GetTokenBalance","query",u)}const lt={connect:G,isConnected:R,disconnect:j,getNetwork:tt,switchNetwork:nt,getAddress:et,getPublicKey:rt,getXPublicKey:it,getBalance:F,getUtxos:st,transfer:ht,merge:dt,signTransaction:ft,signMessage:ot,verifySignature:ct,eciesEncrypt:at,eciesDecrypt:ut,token:{getBalance:J},nft:{},requestAccount:G,getAccount:G,exitAccount:j,getMvcBalance:F,getSensibleFtBalance:J};window.metaidwallet=lt})(); +(function(){"use strict";var Z=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},X={exports:{}};(function(u,H){(function(D,p){u.exports=p()})(Z,function(){var D=1e3,p=6e4,L=36e5,k="millisecond",O="second",m="minute",M="hour",y="day",_="week",w="month",q="quarter",v="year",x="date",K="Invalid Date",yt=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,wt=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,gt={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(r){var e=["th","st","nd","rd"],t=r%100;return"["+r+(e[(t-20)%10]||e[t]||e[0])+"]"}},I=function(r,e,t){var i=String(r);return!i||i.length>=e?r:""+Array(e+1-i.length).join(t)+r},mt={s:I,z:function(r){var e=-r.utcOffset(),t=Math.abs(e),i=Math.floor(t/60),n=t%60;return(e<=0?"+":"-")+I(i,2,"0")+":"+I(n,2,"0")},m:function r(e,t){if(e.date()1)return r(s[0])}else{var o=e.name;A[o]=e,n=o}return!i&&n&&(z=n),n||!i&&z},l=function(r,e){if(U(r))return r.clone();var t=typeof e=="object"?e:{};return t.date=r,t.args=arguments,new B(t)},c=mt;c.l=W,c.i=U,c.w=function(r,e){return l(r,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var B=function(){function r(t){this.$L=W(t.locale,null,!0),this.parse(t)}var e=r.prototype;return e.parse=function(t){this.$d=function(i){var n=i.date,a=i.utc;if(n===null)return new Date(NaN);if(c.u(n))return new Date;if(n instanceof Date)return new Date(n);if(typeof n=="string"&&!/Z$/i.test(n)){var s=n.match(yt);if(s){var o=s[2]-1||0,h=(s[7]||"0").substring(0,3);return a?new Date(Date.UTC(s[1],o,s[3]||1,s[4]||0,s[5]||0,s[6]||0,h)):new Date(s[1],o,s[3]||1,s[4]||0,s[5]||0,s[6]||0,h)}}return new Date(n)}(t),this.$x=t.x||{},this.init()},e.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},e.$utils=function(){return c},e.isValid=function(){return this.$d.toString()!==K},e.isSame=function(t,i){var n=l(t);return this.startOf(i)<=n&&n<=this.endOf(i)},e.isAfter=function(t,i){return l(t){let H="";const D="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(let p=0;p{const M=y=>{var _,w,q,v;if(!(y.source!==window||((_=y.data)==null?void 0:_.channel)!=="from-metaidwallet")){if(((w=y.data)==null?void 0:w.nonce)===L){if(window.removeEventListener("message",M),(v=(q=y.data)==null?void 0:q.res)!=null&&v.error)throw new Error(y.data.res.error);m&&typeof m=="function"&&m(y.data)}return!0}};window.addEventListener("message",M)};return await new Promise(m=>{O(M=>{m(M.res)})})}async function G(){return await d("Connect")}async function j(){return await d("Disconnect")}async function R(){return await d("IsConnected","query")}async function tt(){return await d("GetNetwork","query")}async function nt(){return await d("SwitchNetwork")}async function et(u){return await d("GetAddress","query",u)}async function rt(u){return await d("GetPublicKey","query",u)}async function it(){return await d("GetXPublicKey","query")}async function F(u){return await d("GetBalance","query",u)}async function st(u){return await d("GetUtxos","query",u)}async function at(u){return await d("EciesEncrypt","authorize",u)}async function ut(u){return await d("EciesDecrypt","authorize",u)}async function ot(u){return await d("SignMessage","authorize",u)}async function ct(u){return await d("VerifySignature","query",u)}async function ft(u){return await d("SignTransaction","authorize",u)}async function ht(u){return await d("SignTransactions","authorize",u)}async function dt(u){return await d("Transfer","authorize",u)}async function lt(u){return await d("Merge","authorize",u)}async function J(u){return await d("GetTokenBalance","query",u)}const $t={connect:G,isConnected:R,disconnect:j,getNetwork:tt,switchNetwork:nt,getAddress:et,getPublicKey:rt,getXPublicKey:it,getBalance:F,getUtxos:st,transfer:dt,merge:lt,signTransaction:ft,signTransactions:ht,signMessage:ot,verifySignature:ct,eciesEncrypt:at,eciesDecrypt:ut,token:{getBalance:J},nft:{},requestAccount:G,getAccount:G,exitAccount:j,getMvcBalance:F,getSensibleFtBalance:J};window.metaidwallet=$t})(); diff --git a/src/content-script/actions.ts b/src/content-script/actions.ts index 79ee4cb..a89195b 100644 --- a/src/content-script/actions.ts +++ b/src/content-script/actions.ts @@ -120,6 +120,9 @@ type SigningTransaction = { export async function signTransaction(params: { transaction: SigningTransaction }) { return await createAction('SignTransaction', 'authorize', params) } +export async function signTransactions(params: { transactions: SigningTransaction[] }) { + return await createAction('SignTransactions', 'authorize', params) +} type TransferTask = { genesis?: string diff --git a/src/content-script/main.ts b/src/content-script/main.ts index ead4868..36797d2 100644 --- a/src/content-script/main.ts +++ b/src/content-script/main.ts @@ -17,6 +17,7 @@ import { signMessage, verifySignature, signTransaction, + signTransactions, } from './actions' type Metalet = { @@ -31,6 +32,7 @@ type Metalet = { getBalance: any merge: any signTransaction: any + signTransactions: any signMessage: any verifySignature: any getUtxos: any @@ -77,6 +79,7 @@ const metalet: Metalet = { transfer, merge, signTransaction, + signTransactions, signMessage, verifySignature, diff --git a/src/data/authorize-actions.ts b/src/data/authorize-actions.ts index 467840f..f714834 100644 --- a/src/data/authorize-actions.ts +++ b/src/data/authorize-actions.ts @@ -6,6 +6,7 @@ import * as SwitchNetwork from '../lib/actions/switch-network' import * as EciesEncrypt from '../lib/actions/ecies-encrypt' import * as EciesDecrypt from '../lib/actions/ecies-decrypt' import * as SignTransaction from '../lib/actions/sign-transaction' +import * as SignTransactions from '../lib/actions/sign-transactions' import * as SignMessage from '../lib/actions/sign-message' import * as Merge from '../lib/actions/merge' @@ -81,6 +82,15 @@ export default { closeAfterProcess: true, }, + SignTransactions: { + name: 'Sign Transactions', + title: 'Sign Multiple Transactions', + description: ['Sign multiple transactions with my wallet as once'], + process: SignTransactions.process, + estimate: doNothing, + closeAfterProcess: true, + }, + EciesEncrypt: { name: 'ECIES Encrypt', title: 'ECIES Encrypt', diff --git a/src/lib/actions/sign-transactions.ts b/src/lib/actions/sign-transactions.ts new file mode 100644 index 0000000..14c7a3b --- /dev/null +++ b/src/lib/actions/sign-transactions.ts @@ -0,0 +1,17 @@ +import { getAddress, getCurrentAccount, privateKey } from '../account' +import connector from '../connector' +import { signTransaction } from '../crypto' + +export async function process(params: any, host: string) { + const wif = await getCurrentAccount().then((account) => privateKey.value) + + const signingTransactions = params.transactions + + const signatures = signingTransactions.map((transaction: any) => { + const signature = signTransaction(wif, transaction) + + return signature + }) + + return { signatures } +} diff --git a/src/pages/authorize/Index.vue b/src/pages/authorize/Index.vue index 53da62a..5bdd932 100644 --- a/src/pages/authorize/Index.vue +++ b/src/pages/authorize/Index.vue @@ -14,6 +14,7 @@ import SwitchNetwork from './SwitchNetwork.vue' import EciesEncrypt from './EciesEncrypt.vue' import EciesDecrypt from './EciesDecrypt.vue' import SignTransaction from './SignTransaction.vue' +import SignTransactions from './SignTransactions.vue' import SignMessage from './SignMessage.vue' import Merge from './Merge.vue' import { getBrowserHost } from '@/lib/host' @@ -178,6 +179,7 @@ const cancelAction = async () => { + diff --git a/src/pages/authorize/SignTransactions.vue b/src/pages/authorize/SignTransactions.vue new file mode 100644 index 0000000..433ef8a --- /dev/null +++ b/src/pages/authorize/SignTransactions.vue @@ -0,0 +1,29 @@ + + +