}
signMessage(sendResponse, payload) {
- if(payload.address === undefined){
+ var requestBody = payload.value
+
+ if(requestBody.address === undefined){
sendResponse(Error.typeMissed('address'));
return false;
}
- if(payload.message === undefined){
+ if(requestBody.message === undefined){
sendResponse(Error.typeMissed('message'));
return false;
}
- const {domain, ...txAttrs} = payload;
-
- txAttrs.type = 'message'
+ const {domain} = payload;
+ const data={
+ value: requestBody,
+ type: 'message'
+ }
- NotificationService.open(new Prompt(PromptTypes.REQUEST_PROMPT, domain, txAttrs ,approved => {
+ NotificationService.open(new Prompt(PromptTypes.REQUEST_PROMPT, domain, data ,approved => {
sendResponse(camelize(approved));
}));
}
transfer(sendResponse, payload) {
- var requestBody = payload
+ var requestBody = payload.value
if(requestBody.from === undefined){
sendResponse(Error.typeMissed('from'));
return false;
}
- const {domain, ...txAttrs} = payload;
-
- txAttrs.type = 'transfer'
+ const {domain} = payload;
+ const data={
+ value: requestBody,
+ type: 'transfer'
+ }
- NotificationService.open(new Prompt(PromptTypes.REQUEST_PROMPT, domain, txAttrs ,approved => {
+ NotificationService.open(new Prompt(PromptTypes.REQUEST_PROMPT, domain, data ,approved => {
sendResponse(camelize(approved));
}));
}
advancedTransfer(sendResponse, payload) {
+ var requestBody = payload.value
- if(payload.input === undefined){
+ if(requestBody.input === undefined){
sendResponse(Error.typeMissed('input'));
return false;
}
- if(payload.output === undefined){
+ if(requestBody.output === undefined){
sendResponse(Error.typeMissed('output'));
return false;
}
- if(payload.gas === undefined){
+ if(requestBody.gas === undefined){
sendResponse(Error.typeMissed('gas'));
return false;
}
- const {domain, ...txAttrs} = payload;
+ const {domain} = payload;
- txAttrs.type = 'advTransfer'
+ const data={
+ value: requestBody,
+ type: 'advTransfer'
+ }
- NotificationService.open(new Prompt(PromptTypes.REQUEST_PROMPT, domain, txAttrs ,approved => {
+ NotificationService.open(new Prompt(PromptTypes.REQUEST_PROMPT, domain, data ,approved => {
sendResponse(camelize(approved));
}));
}
signTransaction(sendResponse, payload) {
- const {domain, ...txAttrs} = payload;
+ const {domain, value} = payload;
- txAttrs.type = 'signTransaction'
+ const data={
+ value: value,
+ type: 'signTransaction'
+ }
- NotificationService.open(new Prompt(PromptTypes.REQUEST_PROMPT, domain, txAttrs ,approved => {
+ NotificationService.open(new Prompt(PromptTypes.REQUEST_PROMPT, domain, data ,approved => {
sendResponse(camelize(approved));
}));
}
} else if(this.prompt.data.type ==='transfer'){
transaction.transfer(this.transaction, this.password, this.address, this).then(result => {
loader.hide();
+ this.prompt.responder(result);
+ this.$toast.success(
+ this.$t("transfer.success")
+ );
NotificationService.close();
}).catch(error => {
);
});
} else if(this.prompt.data.type ==='signTransaction'){
- transaction.signTransaction(this.address, this.prompt.data, this.password, this).then( (result) => {
- loader.hide();
- this.prompt.responder(result);
- this.$toast.success(this.$t("transfer.success"));
- NotificationService.close();
- }).catch(error => {
- loader.hide();
+ const data = this.prompt.data.value
+
+ if(Array.isArray(data)){
+ Promise.all(data.map( (rawdata) => transaction.signTransaction(this.address, rawdata, this.password, this)))
+ .then( (result) => {
+ loader.hide();
+ this.prompt.responder(result);
+ this.$toast.success(this.$t("transfer.success"));
+ NotificationService.close();
+ }).catch(error => {
+ loader.hide();
+
+ this.$toast.error(
+ getLang(error.message) || error.message || error
+ );
+ });
+ }else{
+ transaction.signTransaction(this.address, data, this.password, this).then( (result) => {
+ loader.hide();
+ this.prompt.responder(result);
+ this.$toast.success(this.$t("transfer.success"));
+
+ NotificationService.close();
+ }).catch(error => {
+ loader.hide();
+
+ this.$toast.error(
+ getLang(error.message) || error.message || error
+ );
+ });
+ }
- this.$toast.error(
- getLang(error.message) || error.message || error
- );
- });
} else if(this.prompt.data.type ==='message'){
transaction.signMessage(this.transaction.message, this.password, this.address, this).then((resp) => {
loader.hide();
this.prompt = window.data || apis.extension.getBackgroundPage().notification || null;
console.log(this.prompt)
- const data = this.prompt.data
- if (data !== undefined) {
- switch(data.type){
+ const params = this.prompt.data
+ if (params !== undefined) {
+ const data = params.value
+ switch(params.type){
case "advTransfer":{
const inout = data
if (inout.input !== undefined) {