mirror of
https://github.com/Qortal/chrome-extension.git
synced 2025-06-03 07:06:57 +00:00
updated to primary name logic
This commit is contained in:
parent
be60211365
commit
7b61a4a153
@ -977,28 +977,31 @@ const forceCloseWebSocket = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
async function getNameInfo() {
|
export async function getNameInfo() {
|
||||||
const wallet = await getSaveWallet();
|
const wallet = await getSaveWallet();
|
||||||
const address = wallet.address0;
|
const address = wallet.address0;
|
||||||
const validApi = await getBaseApi();
|
const validApi = await getBaseApi();
|
||||||
const response = await fetch(validApi + "/names/address/" + address);
|
const response = await fetch(validApi + '/names/primary/' + address);
|
||||||
const nameData = await response.json();
|
const nameData = await response.json();
|
||||||
if (nameData?.length > 0) {
|
if (nameData?.name) {
|
||||||
return nameData[0].name;
|
return nameData[0].name;
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getNameInfoForOthers(address) {
|
export async function getNameInfoForOthers(address) {
|
||||||
|
if (!address) return '';
|
||||||
const validApi = await getBaseApi();
|
const validApi = await getBaseApi();
|
||||||
const response = await fetch(validApi + "/names/address/" + address);
|
const response = await fetch(validApi + '/names/primary/' + address);
|
||||||
const nameData = await response.json();
|
const nameData = await response.json();
|
||||||
if (nameData?.length > 0) {
|
if (nameData?.name) {
|
||||||
return nameData[0].name;
|
return nameData?.name;
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAddressInfo(address) {
|
export async function getAddressInfo(address) {
|
||||||
const validApi = await getBaseApi();
|
const validApi = await getBaseApi();
|
||||||
const response = await fetch(validApi + "/addresses/" + address);
|
const response = await fetch(validApi + "/addresses/" + address);
|
||||||
|
@ -46,16 +46,16 @@ async function getSaveWallet() {
|
|||||||
throw new Error("No wallet saved");
|
throw new Error("No wallet saved");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export async function getNameInfo() {
|
export async function getNameInfo() {
|
||||||
const wallet = await getSaveWallet();
|
const wallet = await getSaveWallet();
|
||||||
const address = wallet.address0;
|
const address = wallet.address0;
|
||||||
const validApi = await getBaseApi()
|
const validApi = await getBaseApi();
|
||||||
const response = await fetch(validApi + "/names/address/" + address);
|
const response = await fetch(validApi + '/names/primary/' + address);
|
||||||
const nameData = await response.json();
|
const nameData = await response.json();
|
||||||
if (nameData?.length > 0) {
|
if (nameData?.name) {
|
||||||
return nameData[0].name;
|
return nameData?.name;
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ const UIQortalRequests = [
|
|||||||
'CANCEL_SELL_NAME',
|
'CANCEL_SELL_NAME',
|
||||||
'BUY_NAME', 'MULTI_ASSET_PAYMENT_WITH_PRIVATE_DATA',
|
'BUY_NAME', 'MULTI_ASSET_PAYMENT_WITH_PRIVATE_DATA',
|
||||||
'TRANSFER_ASSET',
|
'TRANSFER_ASSET',
|
||||||
'SIGN_FOREIGN_FEES',
|
'SIGN_FOREIGN_FEES', 'GET_PRIMARY_NAME',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
@ -324,13 +324,13 @@ export const getDataPublishesFunc = async (groupId, type) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export async function getNameInfo(address: string) {
|
export async function getNameInfo(address: string) {
|
||||||
const response = await fetch(`${getBaseApiReact()}/names/address/` + address);
|
const response = await fetch(`${getBaseApiReact()}/names/primary/` + address);
|
||||||
const nameData = await response.json();
|
const nameData = await response.json();
|
||||||
|
|
||||||
if (nameData?.length > 0) {
|
if (nameData?.name) {
|
||||||
return nameData[0]?.name;
|
return nameData?.name;
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,14 +89,14 @@ export const Minting = ({
|
|||||||
const getName = async (address) => {
|
const getName = async (address) => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`${getBaseApiReact()}/names/address/${address}`
|
`${getBaseApiReact()}/names/primary/${address}`
|
||||||
);
|
);
|
||||||
const nameData = await response.json();
|
const nameData = await response.json();
|
||||||
if (nameData?.length > 0) {
|
if (nameData?.name) {
|
||||||
setNames((prev) => {
|
setNames((prev) => {
|
||||||
return {
|
return {
|
||||||
...prev,
|
...prev,
|
||||||
[address]: nameData[0].name,
|
[address]: nameData?.name,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -108,7 +108,7 @@ export const Minting = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// error
|
console.log(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ export const publishData = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const file = data;
|
const file = data;
|
||||||
// const urlCheck = `/arbitrary/check-tmp-space?totalSize=${file.size}`;
|
// const urlCheck = `/arbitrary/check/tmp?totalSize=${file.size}`;
|
||||||
|
|
||||||
// const checkEndpoint = await createEndpoint(urlCheck);
|
// const checkEndpoint = await createEndpoint(urlCheck);
|
||||||
// const checkRes = await fetch(checkEndpoint);
|
// const checkRes = await fetch(checkEndpoint);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { banFromGroup, gateways, getApiKeyFromStorage } from "./background";
|
import { banFromGroup, gateways, getApiKeyFromStorage, getNameInfoForOthers } from "./background";
|
||||||
import { addForeignServer, addGroupAdminRequest, addListItems, adminAction, banFromGroupRequest, buyNameRequest, cancelGroupBanRequest, cancelGroupInviteRequest, cancelSellNameRequest, cancelSellOrder, createBuyOrder, createGroupRequest, createPoll, createSellOrder, decryptAESGCMRequest, decryptData, decryptDataWithSharingKey, decryptQortalGroupData, deleteHostedData, deleteListItems, deployAt, encryptData, encryptDataWithSharingKey, encryptQortalGroupData, getArrrSyncStatus, getCrossChainServerInfo, getDaySummary, getForeignFee, getHostedData, getListItems, getNodeInfo, getNodeStatus, getServerConnectionHistory, getTxActivitySummary, getUserAccount, getUserWallet, getUserWalletInfo, getUserWalletTransactions, getWalletBalance, inviteToGroupRequest, joinGroup, kickFromGroupRequest, leaveGroupRequest, multiPaymentWithPrivateData, publishMultipleQDNResources, publishQDNResource, registerNameRequest, removeForeignServer, removeGroupAdminRequest, saveFile, sellNameRequest, sendChatMessage, sendCoin, setCurrentForeignServer, showPdfReader, signForeignFees, signTransaction, transferAssetRequest, updateForeignFee, updateGroupRequest, updateNameRequest, voteOnPoll } from "./qortalRequests/get";
|
import { addForeignServer, addGroupAdminRequest, addListItems, adminAction, banFromGroupRequest, buyNameRequest, cancelGroupBanRequest, cancelGroupInviteRequest, cancelSellNameRequest, cancelSellOrder, createBuyOrder, createGroupRequest, createPoll, createSellOrder, decryptAESGCMRequest, decryptData, decryptDataWithSharingKey, decryptQortalGroupData, deleteHostedData, deleteListItems, deployAt, encryptData, encryptDataWithSharingKey, encryptQortalGroupData, getArrrSyncStatus, getCrossChainServerInfo, getDaySummary, getForeignFee, getHostedData, getListItems, getNodeInfo, getNodeStatus, getServerConnectionHistory, getTxActivitySummary, getUserAccount, getUserWallet, getUserWalletInfo, getUserWalletTransactions, getWalletBalance, inviteToGroupRequest, joinGroup, kickFromGroupRequest, leaveGroupRequest, multiPaymentWithPrivateData, publishMultipleQDNResources, publishQDNResource, registerNameRequest, removeForeignServer, removeGroupAdminRequest, saveFile, sellNameRequest, sendChatMessage, sendCoin, setCurrentForeignServer, showPdfReader, signForeignFees, signTransaction, transferAssetRequest, updateForeignFee, updateGroupRequest, updateNameRequest, voteOnPoll } from "./qortalRequests/get";
|
||||||
|
|
||||||
export const listOfAllQortalRequests = [
|
export const listOfAllQortalRequests = [
|
||||||
@ -89,6 +89,7 @@ import { addForeignServer, addGroupAdminRequest, addListItems, adminAction, banF
|
|||||||
'BUY_NAME', 'MULTI_ASSET_PAYMENT_WITH_PRIVATE_DATA',
|
'BUY_NAME', 'MULTI_ASSET_PAYMENT_WITH_PRIVATE_DATA',
|
||||||
'TRANSFER_ASSET',
|
'TRANSFER_ASSET',
|
||||||
'SIGN_FOREIGN_FEES',
|
'SIGN_FOREIGN_FEES',
|
||||||
|
'GET_PRIMARY_NAME',
|
||||||
]
|
]
|
||||||
|
|
||||||
// Promisify chrome.storage.local.get
|
// Promisify chrome.storage.local.get
|
||||||
@ -943,7 +944,19 @@ chrome?.runtime?.onMessage.addListener((request, sender, sendResponse) => {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "GET_PRIMARY_NAME": {
|
||||||
|
const data = request.payload;
|
||||||
|
|
||||||
|
getNameInfoForOthers(data)
|
||||||
|
.then((res) => {
|
||||||
|
const resData = res ? res : null;
|
||||||
|
sendResponse(resData);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
sendResponse({ error: error.message });
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user