var bytom
getById('transferButton').addEventListener('click', () => {
- bytom.transfer(getById('to').value, getById('amount').value)
+ bytom.transfer(getById('to').value, getById('amount').value).then(
+ resp =>{
+ console.log(resp)
+ }
+ )
})
// 监听Bytom插件加载成功事件
transfer(sendResponse, payload) {
var promptURL = chrome.extension.getURL('pages/prompt.html')
- var queryString = new URLSearchParams(payload).toString()
+ var requestBody = payload
+ requestBody.type = "popup"
+ var queryString = new URLSearchParams(requestBody).toString()
console.log(promptURL, queryString)
chrome.windows.create(
{
top: 0,
left: 0
},
- () => {
- sendResponse(true)
+ (window) => {
+ chrome.runtime.onMessage.addListener(function(request, sender) {
+ if(sender.tab.windowId === window.id){
+ switch (request.method){
+ case 'transfer':
+ sendResponse(request);
+ break
+ }
+ }
+ });
+ console.log(window)
}
)
}
import transaction from "@/models/transaction";
import getLang from "@/assets/language/sdk";
import Confirm from "./transferConfirm";
+import { LocalStream } from 'extension-streams';
+
export default {
components: {
Confirm
this.$router.go(-1)
this.transaction.to = "";
this.transaction.amount = "";
+ if(this.$route.query.type == 'popup'){
+ LocalStream.send({method:'transfer',action:'reject'});
+ window.close();
+ }
},
send: function () {
if (this.transaction.to == "") {
transaction.build(this.account.guid, this.transaction.to, this.transaction.asset, this.transaction.amount, this.transaction.fee).then(ret => {
loader.hide();
this.transaction.fee = Number(ret.result.data.fee / 100000000);
- this.$router.push({ name: 'transfer-confirm', params: { account: this.account, transaction: this.transaction, rawData: ret.result.data } })
+ this.$router.push({ name: 'transfer-confirm', params: { account: this.account, transaction: this.transaction, rawData: ret.result.data, type: this.$route.query.type } })
}).catch(error => {
loader.hide();
this.$dialog.show({
</template>
<script>
-import address from "@/utils/address";
import transaction from "@/models/transaction";
import modalPasswd from "@/components/modal-passwd";
import getLang from "@/assets/language/sdk";
+import { LocalStream } from 'extension-streams';
export default {
components: {
modalPasswd
transaction.transfer(this.account.guid, this.rawData, this.password)
.then(ret => {
loader.hide();
+ if(this.$route.params.type == 'popup'){
+ LocalStream.send({method:'transfer',action:'success', message:ret});
+ }
this.$dialog.show({
type: 'success',
body: this.$t("transfer.success")