mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-06-13 19:41:22 +00:00
added crosschain txs qortal request
This commit is contained in:
parent
b4cc55b6e9
commit
3273fac1f2
@ -210,6 +210,7 @@ export const listOfAllQortalRequests = [
|
|||||||
'SEARCH_TRANSACTIONS',
|
'SEARCH_TRANSACTIONS',
|
||||||
'GET_PRICE',
|
'GET_PRICE',
|
||||||
'SHOW_ACTIONS',
|
'SHOW_ACTIONS',
|
||||||
|
'GET_USER_WALLET_TRANSACTIONS'
|
||||||
]
|
]
|
||||||
|
|
||||||
export const UIQortalRequests = [
|
export const UIQortalRequests = [
|
||||||
@ -219,7 +220,7 @@ export const UIQortalRequests = [
|
|||||||
'GET_WALLET_BALANCE', 'GET_USER_WALLET_INFO', 'GET_CROSSCHAIN_SERVER_INFO',
|
'GET_WALLET_BALANCE', 'GET_USER_WALLET_INFO', 'GET_CROSSCHAIN_SERVER_INFO',
|
||||||
'GET_TX_ACTIVITY_SUMMARY', 'GET_FOREIGN_FEE', 'UPDATE_FOREIGN_FEE',
|
'GET_TX_ACTIVITY_SUMMARY', 'GET_FOREIGN_FEE', 'UPDATE_FOREIGN_FEE',
|
||||||
'GET_SERVER_CONNECTION_HISTORY', 'SET_CURRENT_FOREIGN_SERVER',
|
'GET_SERVER_CONNECTION_HISTORY', 'SET_CURRENT_FOREIGN_SERVER',
|
||||||
'ADD_FOREIGN_SERVER', 'REMOVE_FOREIGN_SERVER', 'GET_DAY_SUMMARY', 'CREATE_TRADE_BUY_ORDER', 'CREATE_TRADE_SELL_ORDER', 'CANCEL_TRADE_SELL_ORDER', 'IS_USING_PUBLIC_NODE', 'ADMIN_ACTION', 'SIGN_TRANSACTION', 'OPEN_NEW_TAB', 'CREATE_AND_COPY_EMBED_LINK', 'DECRYPT_QORTAL_GROUP_DATA', 'DECRYPT_DATA_WITH_SHARING_KEY', 'DELETE_HOSTED_DATA', 'GET_HOSTED_DATA', 'SHOW_ACTIONS', 'REGISTER_NAME', 'UPDATE_NAME', 'LEAVE_GROUP', 'INVITE_TO_GROUP', 'KICK_FROM_GROUP', 'BAN_FROM_GROUP', 'CANCEL_GROUP_BAN', 'ADD_GROUP_ADMIN', 'REMOVE_GROUP_ADMIN', 'DECRYPT_AESGCM', 'CANCEL_GROUP_INVITE', 'CREATE_GROUP'
|
'ADD_FOREIGN_SERVER', 'REMOVE_FOREIGN_SERVER', 'GET_DAY_SUMMARY', 'CREATE_TRADE_BUY_ORDER', 'CREATE_TRADE_SELL_ORDER', 'CANCEL_TRADE_SELL_ORDER', 'IS_USING_PUBLIC_NODE', 'ADMIN_ACTION', 'SIGN_TRANSACTION', 'OPEN_NEW_TAB', 'CREATE_AND_COPY_EMBED_LINK', 'DECRYPT_QORTAL_GROUP_DATA', 'DECRYPT_DATA_WITH_SHARING_KEY', 'DELETE_HOSTED_DATA', 'GET_HOSTED_DATA', 'SHOW_ACTIONS', 'REGISTER_NAME', 'UPDATE_NAME', 'LEAVE_GROUP', 'INVITE_TO_GROUP', 'KICK_FROM_GROUP', 'BAN_FROM_GROUP', 'CANCEL_GROUP_BAN', 'ADD_GROUP_ADMIN', 'REMOVE_GROUP_ADMIN', 'DECRYPT_AESGCM', 'CANCEL_GROUP_INVITE', 'CREATE_GROUP', 'GET_USER_WALLET_TRANSACTIONS'
|
||||||
];
|
];
|
||||||
// TODO listOfAllQortalRequests
|
// TODO listOfAllQortalRequests
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { gateways, getApiKeyFromStorage } from "./background";
|
import { gateways, getApiKeyFromStorage } from "./background";
|
||||||
import { listOfAllQortalRequests } from "./components/Apps/useQortalMessageListener";
|
import { listOfAllQortalRequests } from "./components/Apps/useQortalMessageListener";
|
||||||
import { addForeignServer, addGroupAdminRequest, addListItems, adminAction, banFromGroupRequest, cancelGroupBanRequest, cancelGroupInviteRequest, cancelSellOrder, createAndCopyEmbedLink, createBuyOrder, createGroupRequest, createPoll, createSellOrder, decryptAESGCMRequest, decryptData, decryptDataWithSharingKey, decryptQortalGroupData, deleteHostedData, deleteListItems, deployAt, encryptData, encryptDataWithSharingKey, encryptQortalGroupData, getCrossChainServerInfo, getDaySummary, getForeignFee, getHostedData, getListItems, getServerConnectionHistory, getTxActivitySummary, getUserAccount, getUserWallet, getUserWalletInfo, getWalletBalance, inviteToGroupRequest, joinGroup, kickFromGroupRequest, leaveGroupRequest, openNewTab, publishMultipleQDNResources, publishQDNResource, registerNameRequest, removeForeignServer, removeGroupAdminRequest, saveFile, sendChatMessage, sendCoin, setCurrentForeignServer, signTransaction, updateForeignFee, updateNameRequest, voteOnPoll } from "./qortalRequests/get";
|
import { addForeignServer, addGroupAdminRequest, addListItems, adminAction, banFromGroupRequest, cancelGroupBanRequest, cancelGroupInviteRequest, cancelSellOrder, createAndCopyEmbedLink, createBuyOrder, createGroupRequest, createPoll, createSellOrder, decryptAESGCMRequest, decryptData, decryptDataWithSharingKey, decryptQortalGroupData, deleteHostedData, deleteListItems, deployAt, encryptData, encryptDataWithSharingKey, encryptQortalGroupData, getCrossChainServerInfo, getDaySummary, getForeignFee, getHostedData, getListItems, getServerConnectionHistory, getTxActivitySummary, getUserAccount, getUserWallet, getUserWalletInfo, getUserWalletTransactions, getWalletBalance, inviteToGroupRequest, joinGroup, kickFromGroupRequest, leaveGroupRequest, openNewTab, publishMultipleQDNResources, publishQDNResource, registerNameRequest, removeForeignServer, removeGroupAdminRequest, saveFile, sendChatMessage, sendCoin, setCurrentForeignServer, signTransaction, updateForeignFee, updateNameRequest, voteOnPoll } from "./qortalRequests/get";
|
||||||
import { getData, storeData } from "./utils/chromeStorage";
|
import { getData, storeData } from "./utils/chromeStorage";
|
||||||
|
|
||||||
|
|
||||||
@ -414,6 +414,26 @@ export const isRunningGateway = async ()=> {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "GET_USER_WALLET_TRANSACTIONS": {
|
||||||
|
try {
|
||||||
|
const res = await getUserWalletTransactions(request.payload, isFromExtension, appInfo);
|
||||||
|
event.source.postMessage({
|
||||||
|
requestId: request.requestId,
|
||||||
|
action: request.action,
|
||||||
|
payload: res,
|
||||||
|
type: "backgroundMessageResponse",
|
||||||
|
}, event.origin);
|
||||||
|
} catch (error) {
|
||||||
|
event.source.postMessage({
|
||||||
|
requestId: request.requestId,
|
||||||
|
action: request.action,
|
||||||
|
error: error.message,
|
||||||
|
type: "backgroundMessageResponse",
|
||||||
|
}, event.origin);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case "GET_USER_WALLET_INFO": {
|
case "GET_USER_WALLET_INFO": {
|
||||||
try {
|
try {
|
||||||
|
@ -2357,6 +2357,99 @@ if (resPermission) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getUserWalletTransactions = async (data, isFromExtension, appInfo) => {
|
||||||
|
const requiredFields = ["coin"];
|
||||||
|
const missingFields: string[] = [];
|
||||||
|
requiredFields.forEach((field) => {
|
||||||
|
if (!data[field]) {
|
||||||
|
missingFields.push(field);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (missingFields.length > 0) {
|
||||||
|
const missingFieldsString = missingFields.join(", ");
|
||||||
|
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||||
|
throw new Error(errorMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
const value =
|
||||||
|
(await getPermission(
|
||||||
|
`getUserWalletTransactions-${appInfo?.name}-${data.coin}`
|
||||||
|
)) || false;
|
||||||
|
let skip = false;
|
||||||
|
if (value) {
|
||||||
|
skip = true;
|
||||||
|
}
|
||||||
|
let resPermission;
|
||||||
|
|
||||||
|
if (!skip) {
|
||||||
|
|
||||||
|
resPermission = await getUserPermission(
|
||||||
|
{
|
||||||
|
text1:
|
||||||
|
"Do you give this application permission to retrieve your wallet transactions",
|
||||||
|
highlightedText: `coin: ${data.coin}`,
|
||||||
|
checkbox1: {
|
||||||
|
value: true,
|
||||||
|
label: "Always allow wallet txs to be retrieved automatically",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
isFromExtension
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const { accepted = false, checkbox1 = false } = resPermission || {};
|
||||||
|
|
||||||
|
if (resPermission) {
|
||||||
|
setPermission(
|
||||||
|
`getUserWalletTransactions-${appInfo?.name}-${data.coin}`,
|
||||||
|
checkbox1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (accepted || skip) {
|
||||||
|
const coin = data.coin;
|
||||||
|
const walletKeys = await getUserWalletFunc(coin);
|
||||||
|
let publicKey
|
||||||
|
if(data?.coin === 'ARRR'){
|
||||||
|
const resKeyPair = await getKeyPair();
|
||||||
|
const parsedData = resKeyPair;
|
||||||
|
publicKey = parsedData.arrrSeed58;
|
||||||
|
} else {
|
||||||
|
publicKey = walletKeys["publickey"]
|
||||||
|
}
|
||||||
|
|
||||||
|
const _url = await createEndpoint(
|
||||||
|
`/crosschain/` + data.coin.toLowerCase() + `/wallettransactions`
|
||||||
|
);
|
||||||
|
const _body = publicKey;
|
||||||
|
try {
|
||||||
|
const response = await fetch(_url, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Accept: "*/*",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: _body,
|
||||||
|
});
|
||||||
|
if (!response?.ok) throw new Error("Unable to fetch wallet transactions");
|
||||||
|
let res;
|
||||||
|
try {
|
||||||
|
res = await response.clone().json();
|
||||||
|
} catch (e) {
|
||||||
|
res = await response.text();
|
||||||
|
}
|
||||||
|
if (res?.error && res?.message) {
|
||||||
|
throw new Error(res.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(error?.message || "Fetch Wallet Transactions Failed");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error("User declined request");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const getCrossChainServerInfo = async (data) => {
|
export const getCrossChainServerInfo = async (data) => {
|
||||||
const requiredFields = ["coin"];
|
const requiredFields = ["coin"];
|
||||||
const missingFields: string[] = [];
|
const missingFields: string[] = [];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user