Skip to content

Commit

Permalink
Merge pull request #1113 from Itheum/stg
Browse files Browse the repository at this point in the history
1.8.0 STG -> MAIN
  • Loading branch information
damienen authored Nov 20, 2023
2 parents f9f26d4 + b307e1b commit b0032f7
Show file tree
Hide file tree
Showing 39 changed files with 5,466 additions and 5,623 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
}
],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error"],
"@typescript-eslint/no-unused-vars": ["warn"],
"@typescript-eslint/indent": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
Expand Down
8,878 changes: 3,551 additions & 5,327 deletions package-lock.json

Large diffs are not rendered by default.

61 changes: 31 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
{
"name": "data-dex",
"version": "1.7.6",
"version": "1.8.0",
"description": "The Itheum Data DEX enables you to trade your data using web3 tech",
"dependencies": {
"@chakra-ui/icons": "2.1.1",
"@chakra-ui/react": "2.8.1",
"@chakra-ui/react": "2.8.2",
"@emotion/react": "11.11.1",
"@emotion/styled": "11.11.0",
"@hookform/resolvers": "3.3.1",
"@itheum/sdk-mx-data-nft": "2.1.5",
"@multiversx/sdk-core": "12.9.0",
"@multiversx/sdk-dapp": "2.22.1",
"@hookform/resolvers": "3.3.2",
"@itheum/sdk-mx-data-nft": "2.4.0",
"@itheum/sdk-mx-enterprise": "0.0.7",
"@multiversx/sdk-core": "12.13.0",
"@multiversx/sdk-dapp": "2.23.0",
"@multiversx/sdk-native-auth-client": "1.0.5",
"@multiversx/sdk-network-providers": "2.0.0",
"@sentry/react": "7.72.0",
"@multiversx/sdk-native-auth-server": "1.0.10",
"@multiversx/sdk-network-providers": "2.1.0",
"@sentry/react": "7.80.0",
"@tanstack/match-sorter-utils": "8.8.4",
"@tanstack/react-table": "8.10.3",
"@testing-library/jest-dom": "6.1.3",
"@testing-library/react": "14.0.0",
"@tanstack/react-table": "8.10.7",
"@testing-library/jest-dom": "6.1.4",
"@testing-library/react": "14.1.0",
"@testing-library/user-event": "14.5.1",
"axios": "1.5.1",
"axios": "1.6.1",
"dotenv": "16.3.1",
"framer-motion": "10.16.4",
"mime": "3.0.0",
Expand All @@ -28,19 +30,18 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"react-dropzone": "14.2.3",
"react-hook-form": "7.46.2",
"react-hook-form": "7.48.2",
"react-icons": "4.11.0",
"react-router-dom": "6.16.0",
"react-scripts": "5.0.1",
"react-router-dom": "6.18.0",
"web-vitals": "3.5.0",
"yup": "1.3.2",
"zustand": "4.4.1"
"zustand": "4.4.6"
},
"scripts": {
"start": "REACT_APP_VERSION=$(node -pe 'require(\"./package.json\").version') react-scripts start",
"build": "REACT_APP_VERSION=$(node -pe 'require(\"./package.json\").version') react-scripts build",
"winStart": "set \"REACT_APP_VERSION=$(node -pe \"require('./package.json').version\")\" && react-scripts start",
"winBuild": "set \"REACT_APP_VERSION=$(node -pe \"require('./package.json').version\")\" && react-scripts build",
"start": "REACT_APP_VERSION=$npm_package_version react-scripts start",
"build": "REACT_APP_VERSION=$npm_package_version react-scripts build",
"winStart": "cross-env REACT_APP_VERSION=$npm_package_version react-scripts start",
"winBuild": "cross-env REACT_APP_VERSION=$npm_package_version react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"start-flat": "npx http-server -o /flat",
Expand All @@ -65,29 +66,29 @@
]
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "7.21.11",
"@types/node": "18.18.0",
"@types/react": "18.2.23",
"@types/react-dom": "18.2.8",
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15",
"@types/react-router-dom": "5.3.3",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"eslint": "8.50.0",
"@typescript-eslint/eslint-plugin": "6.10.0",
"@typescript-eslint/parser": "6.10.0",
"cross-env": "7.0.3",
"eslint": "8.53.0",
"eslint-config-prettier": "9.0.0",
"eslint-config-react-app": "7.0.1",
"eslint-config-standard": "17.1.0",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-prettier": "5.0.0",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-prettier": "5.0.1",
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0",
"prettier": "3.0.3",
"prettier": "3.1.0",
"react-error-overlay": "6.0.11",
"react-scripts": "5.0.1",
"typescript": "4.9.5"
},
"engines": {
"node": "18.18.0"
"node": "18.18.2"
}
}
3 changes: 2 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
<title>Itheum Data DEX : Trade your Data as Data NFTs</title>

<!-- <script>
if (window?.location?.hostname === "datadex.itheum.io") {
if (window?.location?.hostname === "datadex.itheum.io")
{
document.write(
'<script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" data-cbid="4a49c2f1-03fe-4446-b95b-9a6a03bc894d" data-blockingmode="auto" type="text/javascript"></' +
"script>"
Expand Down
Binary file added src/assets/img/enterprise/dataDexLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/enterprise/xoxnoLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/MyListedDataNFT.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const MyListedDataNFT: FC<MyListedDataNFTProps> = (props) => {

{address && address == offer.owner && (
<Badge borderRadius="full" px="2" colorScheme="teal">
<Text>You are the Owner</Text>
<Text>You are Owner</Text>
</Badge>
)}

Expand Down
4 changes: 2 additions & 2 deletions src/components/ProcureDataNFTModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export default function ProcureDataNFTModal({ isOpen, onClose, buyerFee, nftData

const sessionInfo = sessionStorage.getItem("web-wallet-tx");
if (sessionInfo) {
const { type, index, amount } = JSON.parse(sessionInfo);
const { type, index, amount: amountt } = JSON.parse(sessionInfo);
if (type == "purchase-tx") {
updateOfferOnBackend(index, amount);
updateOfferOnBackend(index, amountt);
sessionStorage.removeItem("web-wallet-tx");
}
}
Expand Down
87 changes: 0 additions & 87 deletions src/components/Tables/Components/tableUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,93 +52,6 @@ export type ClaimsInTable = {
amount: number;
};

export class DataNftOnNetwork {
static addOfferIndex = 0;
static ids: number[] = [];
static token_identifier? = "";

id = 0;
hash = "";
timestamp = 0;
from = "";
to = "";
method = "";
methodArgs = [""];
value = "";
transfers: TransactionMetadataTransfer[] = [new TransactionMetadataTransfer()];

constructor(init?: Partial<DataNftOnNetwork>) {
Object.assign(this, init);
}

static fromTransactionOnNetwork(payload: TransactionOnNetwork): DataNftOnNetwork {
const metadata = new TransactionDecoder().getTransactionMetadata({
sender: payload.sender.bech32(),
receiver: payload.receiver.bech32(),
data: payload.data.toString("base64"),
value: payload.value,
});

const result = new DataNftOnNetwork();

result.hash = payload["hash"] || "";
result.timestamp = payload["timestamp"] || 0;
result.to = payload.receiver.bech32() || "";
result.from = payload.sender.bech32() || "";
result.method = metadata["functionName"] || "";
result.methodArgs = metadata["functionArgs"] || [""];
result.value = payload["value"] || "";
result.transfers = metadata["transfers"] || [new TransactionMetadataTransfer()];

if (result.method === "addOffer") {
DataNftOnNetwork.addOfferIndex += 1;
result.id = DataNftOnNetwork.addOfferIndex;
if (result.transfers[0].properties?.identifier === DataNftOnNetwork.token_identifier) {
DataNftOnNetwork.ids.push(result.id);
}
}
return result;
}
}

export const buildHistory = (payload: DataNftOnNetwork[], buyer_fee?: number): TransactionInTable[] => {
const result: TransactionInTable[] = [];

payload.forEach((item) => {
let value = "";
const { identifier } = item.transfers[0].properties || {};
const identifierSplited = (identifier || "").split("-")[0];
switch (item.method) {
case "addOffer":
value = `${item.transfers[0].value.toString()} x ${convertWeiToEsdt(
new BigNumber(parseInt(item.methodArgs[2], 16)).multipliedBy((buyer_fee ?? 0) / 10000).plus(parseInt(item.methodArgs[2], 16))
).toString()} ${StringValue.fromHex(item.methodArgs[0]).valueOf().split("-")[0]}`;
break;
case "acceptOffer":
value = convertWeiToEsdt(Number(item.transfers[0].value)).toString() + " " + identifierSplited;
break;
case "changeOfferPrice":
value = `${convertWeiToEsdt(parseInt(item.methodArgs[1], 16)).toString()}`;
break;
case "cancelOffer":
value = parseInt(item.methodArgs[1], 16).toString();
break;
case "burn":
value = item.transfers[0].value.toString();
break;
}
result.push({
hash: item.hash,
timestamp: item.timestamp,
from: item.from,
to: item.to,
method: item.method,
value: value,
});
});
return result.sort((a: TransactionInTable, b: TransactionInTable) => b.timestamp - a.timestamp);
};

export const fuzzyFilter: FilterFn<any> = (row, columnId, value, addMeta) => {
const itemRank = rankItem(row.getValue(columnId), value);
addMeta({ itemRank });
Expand Down
108 changes: 73 additions & 35 deletions src/components/Tables/TokenTxTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { CHAIN_TX_VIEWER } from "libs/config";
import { getApi } from "libs/MultiversX/api";
import { DataNftMarketContract } from "libs/MultiversX/dataNftMarket";
import { DataTable } from "./Components/DataTable";
import { buildHistory, DataNftOnNetwork, timeSince, TokenTableProps, TransactionInTable } from "./Components/tableUtils";
import { timeSince, TokenTableProps, TransactionInTable } from "./Components/tableUtils";
import { backendApi } from "libs/utils";

export default function TokenTxTable(props: TokenTableProps) {
const { chainID } = useGetNetworkConfig();
Expand Down Expand Up @@ -87,17 +88,78 @@ export default function TokenTxTable(props: TokenTableProps) {
);

useEffect(() => {
const apiUrl = getApi(chainID);
async function getInteractions() {
const api = backendApi(chainID);

Promise.all([
axios.get(`https://${apiUrl}/transactions?token=${props.tokenId}&status=success&size=1000&function=burn&order=asc`),
axios.get(`https://${apiUrl}/accounts/${marketContract.dataNftMarketContractAddress}/transactions?status=success&size=10000&order=asc`),
]).then((responses) => {
const mergedTransactions = getHistory(responses, props.tokenId);
const history = buildHistory(mergedTransactions, props.buyer_fee);
setData(history);
setLoadingData(false);
});
const response = await axios.get(`${api}/interactions/${props.tokenId}`);

const interactions = response.data;

const data: TransactionInTable[] = [];

for (const interaction of interactions) {
switch (interaction.method) {
case "addOffer":
data.push({
hash: interaction.txHash,
timestamp: interaction.timestamp,
from: interaction.from,
to: interaction.to,
method: interaction.method,
value: `${interaction.quantity} x ${interaction.price} ${interaction.priceTokenIdentifier}`,
});
break;
case "acceptOffer":
data.push({
hash: interaction.txHash,
timestamp: interaction.timestamp,
from: interaction.from,
to: interaction.to,
method: interaction.method,
value: `${interaction.quantity} x ${interaction.price} ${interaction.priceTokenIdentifier}`,
});

break;

case "cancelOffer":
data.push({
hash: interaction.txHash,
timestamp: interaction.timestamp,
from: interaction.from,
to: interaction.to,
method: interaction.method,
value: `${interaction.quantity} x ${interaction.tokenIdentifier}`,
});

break;

case "changeOfferPrice":
data.push({
hash: interaction.txHash,
timestamp: interaction.timestamp,
from: interaction.from,
to: interaction.to,
method: interaction.method,
value: `${interaction.price} ${interaction.priceTokenIdentifier}`,
});
break;
default:
data.push({
hash: interaction.txHash,
timestamp: interaction.timestamp,
from: interaction.from,
to: interaction.to,
method: interaction.method,
value: `${interaction.quantity} x ${interaction.tokenIdentifier}`,
});
break;
}
}
setData(data);
}

getInteractions();
setLoadingData(false);
}, []);

return (
Expand All @@ -110,27 +172,3 @@ export default function TokenTxTable(props: TokenTableProps) {
</>
);
}

function getHistory(responses: any[], tokenId?: string) {
DataNftOnNetwork.ids = [];
DataNftOnNetwork.token_identifier = tokenId;
DataNftOnNetwork.addOfferIndex = 1;
const transactionsWithId: DataNftOnNetwork[] = [];

responses.forEach((response: any) => {
const txs = response.data;
const transactions = txs.map((tx: any) => {
if (["burn", "addOffer", "acceptOffer", "cancelOffer", "changeOfferPrice"].includes(tx.function)) {
const transaction = TransactionOnNetwork.fromProxyHttpResponse(tx.txHash, tx);
return DataNftOnNetwork.fromTransactionOnNetwork(transaction);
}
});

const filteredTransactions = transactions.filter((data: DataNftOnNetwork) => {
return data?.transfers[0]?.properties?.identifier === tokenId || DataNftOnNetwork.ids.includes(parseInt(data?.methodArgs[0], 16));
});

transactionsWithId.push(...filteredTransactions);
});
return transactionsWithId;
}
10 changes: 6 additions & 4 deletions src/components/UtilComps/DataNFTLiveUptime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ const DataNFTLiveUptime = (props: DataNFTLiveUptimeProps) => {
setLiveUptimeFAILMsg(labels.ERR_PROCURE_UPTIME_CHECK_DOWN);
}
} catch (e) {
setLiveUptimeFAILMsg(labels.ERR_PROCURE_UPTIME_CHECK_DOWN);
props.handleFlagAsFailed(false);
_isLiveUptimeSuccessful = true;
setLiveUptimeFAILMsg(labels.ERR_PROCURE_UPTIME_CHECK_DOWN_NON_HTTP);
} finally {
setLiveUptimeCheckInProgress(false);
props.setIsLiveUptimeSuccessful(_isLiveUptimeSuccessful);
}

setLiveUptimeCheckInProgress(false);
props.setIsLiveUptimeSuccessful(_isLiveUptimeSuccessful);
}

return (
Expand Down
Loading

0 comments on commit b0032f7

Please sign in to comment.