mirror of
https://github.com/Qortal/chrome-extension.git
synced 2025-02-11 17:55:49 +00:00
update sendqort logic
This commit is contained in:
parent
0b8db25b24
commit
81742c7ca0
@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Vite + React + TS</title>
|
<title>Qortal Extension</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
@ -120,8 +120,8 @@ async function getBalanceInfo() {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const processTransactionVersion2 = async (body: any) => {
|
const processTransactionVersion2 = async (body: any, validApi: string) => {
|
||||||
const validApi = await findUsableApi();
|
// const validApi = await findUsableApi();
|
||||||
const url = validApi + "/transactions/process?apiVersion=2";
|
const url = validApi + "/transactions/process?apiVersion=2";
|
||||||
return fetch(url, {
|
return fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@ -137,7 +137,7 @@ const processTransactionVersion2 = async (body: any) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const transaction = async ({ type, params, apiVersion, keyPair }: any) => {
|
const transaction = async ({ type, params, apiVersion, keyPair }: any, validApi) => {
|
||||||
|
|
||||||
const tx = createTransaction(type, keyPair, params);
|
const tx = createTransaction(type, keyPair, params);
|
||||||
console.log({ tx });
|
console.log({ tx });
|
||||||
@ -145,7 +145,7 @@ const transaction = async ({ type, params, apiVersion, keyPair }: any) => {
|
|||||||
|
|
||||||
if (apiVersion && apiVersion === 2) {
|
if (apiVersion && apiVersion === 2) {
|
||||||
const signedBytes = Base58.encode(tx.signedBytes);
|
const signedBytes = Base58.encode(tx.signedBytes);
|
||||||
res = await processTransactionVersion2(signedBytes);
|
res = await processTransactionVersion2(signedBytes, validApi);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -158,7 +158,8 @@ const makeTransactionRequest = async (
|
|||||||
lastRef,
|
lastRef,
|
||||||
amount,
|
amount,
|
||||||
fee,
|
fee,
|
||||||
keyPair
|
keyPair,
|
||||||
|
validApi
|
||||||
) => {
|
) => {
|
||||||
// let recipientName = await getName(receiver)
|
// let recipientName = await getName(receiver)
|
||||||
// let myTxnrequest = await parentEpml.request('transaction', {
|
// let myTxnrequest = await parentEpml.request('transaction', {
|
||||||
@ -186,7 +187,7 @@ const makeTransactionRequest = async (
|
|||||||
},
|
},
|
||||||
apiVersion: 2,
|
apiVersion: 2,
|
||||||
keyPair,
|
keyPair,
|
||||||
});
|
}, validApi);
|
||||||
return myTxnrequest;
|
return myTxnrequest;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -246,15 +247,18 @@ async function sendCoin({ password, amount, receiver }) {
|
|||||||
console.log({ lastRef });
|
console.log({ lastRef });
|
||||||
const fee = await sendQortFee();
|
const fee = await sendQortFee();
|
||||||
console.log({ fee });
|
console.log({ fee });
|
||||||
|
const validApi = await findUsableApi();
|
||||||
|
|
||||||
const res = await makeTransactionRequest(
|
const res = await makeTransactionRequest(
|
||||||
confirmReceiver,
|
confirmReceiver,
|
||||||
lastRef,
|
lastRef,
|
||||||
amount,
|
amount,
|
||||||
fee,
|
fee,
|
||||||
wallet2._addresses[0].keyPair
|
wallet2._addresses[0].keyPair,
|
||||||
|
validApi
|
||||||
);
|
);
|
||||||
console.log({ res });
|
console.log({ res });
|
||||||
return res;
|
return {res, validApi};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log({ error });
|
console.log({ error });
|
||||||
throw new Error(error.message);
|
throw new Error(error.message);
|
||||||
@ -598,7 +602,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
action: "SET_COUNTDOWN",
|
action: "SET_COUNTDOWN",
|
||||||
payload: request.timeout ? 0.9 * request.timeout : 20,
|
payload: request.timeout ? 0.85 * request.timeout : 15,
|
||||||
});
|
});
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
action: "UPDATE_STATE_CONFIRM_SEND_QORT",
|
action: "UPDATE_STATE_CONFIRM_SEND_QORT",
|
||||||
@ -661,6 +665,9 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
|||||||
sendResponse(true);
|
sendResponse(true);
|
||||||
// Use the sendResponse callback to respond to the original message
|
// Use the sendResponse callback to respond to the original message
|
||||||
originalSendResponse(res);
|
originalSendResponse(res);
|
||||||
|
chrome.runtime.sendMessage({
|
||||||
|
action: "closePopup",
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(error.message);
|
console.error(error.message);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user