diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 238601a..f6de9ac 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -12,8 +12,8 @@ "@massalabs/eslint-config": "^0.0.11", "@massalabs/massa-web3": "^4.0.1", "@massalabs/prettier-config-as": "^0.0.2", - "@massalabs/react-ui-kit": "0.0.4-dev.20240429153446", - "@massalabs/wallet-provider": "^2.0.1-dev.20240423112601", + "@massalabs/react-ui-kit": "^0.0.5-dev", + "@massalabs/wallet-provider": "^2.0.1-dev", "axios": "^1.7.2", "dot-object": "^2.1.5", "eslint-plugin-html": "^8.1.1", @@ -1229,12 +1229,12 @@ } }, "node_modules/@massalabs/massa-web3": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@massalabs/massa-web3/-/massa-web3-4.0.1.tgz", - "integrity": "sha512-zkJgIt/iOr4E+a4dKOWHBF6Tx7Ov8vbNqG0OWyY1Pufq6TZY6BsoCTPiSUtJYHhgZYA+KCpogOeGmlG14MvtYA==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@massalabs/massa-web3/-/massa-web3-4.0.3.tgz", + "integrity": "sha512-W1TtxMrTiqLfUgvIqO641M/2do6Z2Kvvq44JYhiUbteXI5S+VvCJ+HaRtIZ23r9k2wTSlSikE6j6U5bkKDMABA==", "dependencies": { "@massalabs/wallet-provider": "^2.0.0", - "@massalabs/web3-utils": "^1.4.9", + "@massalabs/web3-utils": "^1.4.11", "@noble/ed25519": "^1.7.3", "@noble/hashes": "^1.2.0", "@types/ws": "^8.5.4", @@ -1301,13 +1301,14 @@ } }, "node_modules/@massalabs/react-ui-kit": { - "version": "0.0.4-dev.20240429153446", - "resolved": "https://registry.npmjs.org/@massalabs/react-ui-kit/-/react-ui-kit-0.0.4-dev.20240429153446.tgz", - "integrity": "sha512-8eIxfHAEZ1hKHfY7NotdNYALnVAiE0ykWxT5ry8kaM14fVnyxFKW9/q1E/Xuqgn6RwOZIQ/t5ygDVfwwCy4aTg==", + "version": "0.0.5-next.20240516213908", + "resolved": "https://registry.npmjs.org/@massalabs/react-ui-kit/-/react-ui-kit-0.0.5-next.20240516213908.tgz", + "integrity": "sha512-JUnGdtQm2jRHqneYmfHGMJsZffgC8wXipzAVDRN6ypnUaDB6CEv9pdFLlO7LJf+Qpjkq9A+I14nA8FLBbIM00Q==", "dependencies": { "@headlessui/react": "^1.7.15", "copy-to-clipboard": "^3.3.3", "currency.js": "^2.0.4", + "dot-object": "^2.1.5", "minidenticons": "^4.2.1", "react": "^18.2.0", "react-currency-input-field": "^3.6.11", @@ -1317,7 +1318,12 @@ "react-number-format": "^5.2.2", "tw-colors": "^1.2.5", "viem": "^1.5.2", - "vite-plugin-svgr": "^3.2.0" + "vite-plugin-svgr": "^3.2.0", + "zustand": "^4.5.2" + }, + "peerDependencies": { + "@massalabs/massa-web3": "^4.0.2-dev", + "@massalabs/wallet-provider": "^2.0.1-dev" } }, "node_modules/@massalabs/react-ui-kit/node_modules/@esbuild/android-arm": { @@ -1834,9 +1840,9 @@ } }, "node_modules/@massalabs/web3-utils": { - "version": "1.4.9", - "resolved": "https://registry.npmjs.org/@massalabs/web3-utils/-/web3-utils-1.4.9.tgz", - "integrity": "sha512-8G91gs6HqpPpR860QDUOzugr81WJTGkBgXQS1gq/oXqt16fPkw2xlsq4c2CFHDjRF9/ftE/JaybiNZ4ilcbEyg==", + "version": "1.4.11", + "resolved": "https://registry.npmjs.org/@massalabs/web3-utils/-/web3-utils-1.4.11.tgz", + "integrity": "sha512-9iUoSc9OZxrvx8UbDor934z0cetenEU3PlDqTa9Hsh3EuZJ9jalcEU8Q9Z+hjLn2S9Ojmqu2ldcOAxVzYeNCbw==", "dependencies": { "bignumber.js": "^9.1.2", "buffer": "^6.0.3", diff --git a/frontend/src/ExplorerApiClient.ts b/frontend/src/ExplorerApiClient.ts index 1d3bec7..2326ee1 100644 --- a/frontend/src/ExplorerApiClient.ts +++ b/frontend/src/ExplorerApiClient.ts @@ -1,10 +1,6 @@ -import axios from "axios"; - - +import axios from 'axios'; export class ExplorerApiClient { - - private url_api: string; constructor() { @@ -13,23 +9,27 @@ export class ExplorerApiClient { async getDomainOwnedByAddress(address: string): Promise { return new Promise((resolve, reject) => { - axios.post(this.url_api + '/dns/addresses/owner', { addresses: [address] }).then((response) => { - resolve(response.data[address]); - }).catch((error) => { - console.error(error); - reject(error); - }); + axios.get(this.url_api + '/dns/addresses/owner', { params: { addresses: [address] } }) + .then((response) => { + resolve(response.data[address]); + }) + .catch((error) => { + console.error(error); + reject(error); + }); }); } async getDomainsInfo(domains: string[]): Promise { return new Promise((resolve, reject) => { - axios.post(this.url_api + '/dns/info', { dns: domains }).then((response) => { - resolve(response.data); - }).catch((error) => { - console.error(error); - reject(error); - }); + axios.get(this.url_api + '/dns/info', { params: { dns: domains } }) + .then((response) => { + resolve(response.data); + }) + .catch((error) => { + console.error(error); + reject(error); + }); }); } -} \ No newline at end of file +} diff --git a/frontend/src/utils/write-mns-sc.tsx b/frontend/src/utils/write-mns-sc.tsx index 849d062..e97c8cf 100644 --- a/frontend/src/utils/write-mns-sc.tsx +++ b/frontend/src/utils/write-mns-sc.tsx @@ -68,7 +68,7 @@ export function useWriteMNS(client?: Client) { const [opId, setOpId] = useState(undefined); const [list, setList] = useState([]); const [listSpinning, setListSpinning] = useState(false); - const explorer_api = new ExplorerApiClient(); + const explorerApi = new ExplorerApiClient(); async function getAllocCost( params: DnsAllocParams, @@ -308,7 +308,6 @@ export function useWriteMNS(client?: Client) { params: DnsUserEntryListParams, ): Promise { setListSpinning(true); - // let map_list_asked: Map = new Map(); let resultBalance = await client?.smartContracts().readSmartContract({ targetAddress: SC_ADDRESS, targetFunction: 'balanceOf', @@ -322,15 +321,15 @@ export function useWriteMNS(client?: Client) { let list: DnsUserEntryListResult[] = []; - let domains = await explorer_api.getDomainOwnedByAddress(params.address); + let domains = await explorerApi.getDomainOwnedByAddress(params.address); - let dns_infos = await explorer_api.getDomainsInfo(domains); + let dnsInfos = await explorerApi.getDomainsInfo(domains); - for (const domain in dns_infos) { + for (const domain in dnsInfos) { list.push({ domain: domain, - targetAddress: dns_infos[domain].target_address, - tokenId: dns_infos[domain].tokenId, + targetAddress: dnsInfos[domain].target_address, + tokenId: dnsInfos[domain].tokenId, }); }