diff --git a/package-lock.json b/package-lock.json index 699ae0c4..cff177b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@emotion/react": "^11.4.1", "@emotion/styled": "^11.3.0", "@fairdatasociety/blossom": "^0.5.0", - "@fairdatasociety/fdp-storage": "^0.11.0", + "@fairdatasociety/fdp-storage": "^0.12.0", "@headlessui/react": "^1.7.14", "@metamask/sdk": "^0.5.6", "@types/react-blockies": "^1.4.1", @@ -3055,21 +3055,37 @@ "@fairdatasociety/fdp-storage": "^0.11.0" } }, + "node_modules/@fairdatasociety/blossom/node_modules/@fairdatasociety/fdp-storage": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@fairdatasociety/fdp-storage/-/fdp-storage-0.11.0.tgz", + "integrity": "sha512-Na56ZOmb2cBpm1Z4RaIn0ASJXlLrN/FBg3IfI9ExPDBVxd1jdeMg7P4YY2pQkHRp3fKOtHK/bB4v0nB+tHZIKQ==", + "dependencies": { + "@ethersphere/bee-js": "^6.2.0", + "@fairdatasociety/fdp-contracts-js": "^3.7.1", + "crypto-js": "^4.1.1", + "ethers": "^5.5.2", + "js-sha3": "^0.8.0" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=8.0.0" + } + }, "node_modules/@fairdatasociety/fdp-contracts-js": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@fairdatasociety/fdp-contracts-js/-/fdp-contracts-js-3.7.1.tgz", - "integrity": "sha512-G1TMIAJPIsfxEvubZh2qiiQb4XJx07jdmwUIvBNR2+PCdN2KnCNYQo1b4xkSFxk8BzY7hnXtricmIlNUmv3N0w==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@fairdatasociety/fdp-contracts-js/-/fdp-contracts-js-3.8.0.tgz", + "integrity": "sha512-Lfr/kxCBZ4IYWwAkeRa2fSi9suYd5DxTG5xunfuwMm32FeB99fL7tI19sb5tjPyRj6bphJPaRWmFCdPJ+yfZsg==", "peerDependencies": { "ethers": ">=5.6.4" } }, "node_modules/@fairdatasociety/fdp-storage": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@fairdatasociety/fdp-storage/-/fdp-storage-0.11.0.tgz", - "integrity": "sha512-Na56ZOmb2cBpm1Z4RaIn0ASJXlLrN/FBg3IfI9ExPDBVxd1jdeMg7P4YY2pQkHRp3fKOtHK/bB4v0nB+tHZIKQ==", + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@fairdatasociety/fdp-storage/-/fdp-storage-0.12.0.tgz", + "integrity": "sha512-MFFEjTUedvUAUvz+a1pp6/vtq8/3igy173dCx8BM2Bh7YLs+KK5ytbxgBokUDldZM9vxiEHD4Miwi5bq60gN5w==", "dependencies": { "@ethersphere/bee-js": "^6.2.0", - "@fairdatasociety/fdp-contracts-js": "^3.7.1", + "@fairdatasociety/fdp-contracts-js": "^3.8.0", "crypto-js": "^4.1.1", "ethers": "^5.5.2", "js-sha3": "^0.8.0" @@ -24969,21 +24985,35 @@ "integrity": "sha512-IoKkn2GEuD95yJ763AWuUA153oZEjKH5DOJgGTf48QFkiyuLlLc1OCGveh9tj5fE0LavK0M78x4ZqMKVlmT8BQ==", "requires": { "@fairdatasociety/fdp-storage": "^0.11.0" + }, + "dependencies": { + "@fairdatasociety/fdp-storage": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@fairdatasociety/fdp-storage/-/fdp-storage-0.11.0.tgz", + "integrity": "sha512-Na56ZOmb2cBpm1Z4RaIn0ASJXlLrN/FBg3IfI9ExPDBVxd1jdeMg7P4YY2pQkHRp3fKOtHK/bB4v0nB+tHZIKQ==", + "requires": { + "@ethersphere/bee-js": "^6.2.0", + "@fairdatasociety/fdp-contracts-js": "^3.7.1", + "crypto-js": "^4.1.1", + "ethers": "^5.5.2", + "js-sha3": "^0.8.0" + } + } } }, "@fairdatasociety/fdp-contracts-js": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@fairdatasociety/fdp-contracts-js/-/fdp-contracts-js-3.7.1.tgz", - "integrity": "sha512-G1TMIAJPIsfxEvubZh2qiiQb4XJx07jdmwUIvBNR2+PCdN2KnCNYQo1b4xkSFxk8BzY7hnXtricmIlNUmv3N0w==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@fairdatasociety/fdp-contracts-js/-/fdp-contracts-js-3.8.0.tgz", + "integrity": "sha512-Lfr/kxCBZ4IYWwAkeRa2fSi9suYd5DxTG5xunfuwMm32FeB99fL7tI19sb5tjPyRj6bphJPaRWmFCdPJ+yfZsg==", "requires": {} }, "@fairdatasociety/fdp-storage": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@fairdatasociety/fdp-storage/-/fdp-storage-0.11.0.tgz", - "integrity": "sha512-Na56ZOmb2cBpm1Z4RaIn0ASJXlLrN/FBg3IfI9ExPDBVxd1jdeMg7P4YY2pQkHRp3fKOtHK/bB4v0nB+tHZIKQ==", + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@fairdatasociety/fdp-storage/-/fdp-storage-0.12.0.tgz", + "integrity": "sha512-MFFEjTUedvUAUvz+a1pp6/vtq8/3igy173dCx8BM2Bh7YLs+KK5ytbxgBokUDldZM9vxiEHD4Miwi5bq60gN5w==", "requires": { "@ethersphere/bee-js": "^6.2.0", - "@fairdatasociety/fdp-contracts-js": "^3.7.1", + "@fairdatasociety/fdp-contracts-js": "^3.8.0", "crypto-js": "^4.1.1", "ethers": "^5.5.2", "js-sha3": "^0.8.0" diff --git a/package.json b/package.json index d3c19caa..4e5a09e6 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "@emotion/react": "^11.4.1", "@emotion/styled": "^11.3.0", "@fairdatasociety/blossom": "^0.5.0", - "@fairdatasociety/fdp-storage": "^0.11.0", + "@fairdatasociety/fdp-storage": "^0.12.0", "@headlessui/react": "^1.7.14", "@metamask/sdk": "^0.5.6", "@types/react-blockies": "^1.4.1", diff --git a/src/components/Dialogs/MetamaskMigrationDialog/MetamaskCreateAccount.tsx b/src/components/Dialogs/MetamaskMigrationDialog/MetamaskCreateAccount.tsx index 665bf1d7..646a5f8c 100644 --- a/src/components/Dialogs/MetamaskMigrationDialog/MetamaskCreateAccount.tsx +++ b/src/components/Dialogs/MetamaskMigrationDialog/MetamaskCreateAccount.tsx @@ -130,15 +130,7 @@ export default function MetamaskCreateAccount({ }; const getFeePrice = async () => { - const { address } = fdpClientRef.current.account.wallet; - const { publicKey } = fdpClientRef.current.account; - - const price = await estimateRegistrationPrice( - username, - address, - publicKey, - network - ); + const price = await estimateRegistrationPrice(network); setMinBalance(price); }; @@ -190,7 +182,7 @@ export default function MetamaskCreateAccount({ <>
{intl.get('YOUR_ACCOUNT_IS')}
- + {address} diff --git a/src/utils/ens.ts b/src/utils/ens.ts index ff944c68..c54aa1d1 100644 --- a/src/utils/ens.ts +++ b/src/utils/ens.ts @@ -5,26 +5,11 @@ import { BigNumber, providers } from 'ethers'; const FDS_DOMAIN = 'fds'; export async function estimateRegistrationPrice( - username: string, - address: string, - publicKey: string, network: Network ): Promise { const provider = new providers.JsonRpcProvider(network.config.rpcUrl); - const ens = new ENS( - // A workaround for gas estimation on sepolia - network.id === Environments.SEPOLIA - ? { ...network.config, rpcUrl: 'http://rpc.sepolia.org' } - : network.config, - provider, - FDS_DOMAIN - ); - const [gasAmount, gasPrice] = await Promise.all([ - ens.registerUsernameEstimateGas(username, address, publicKey), - provider.getFeeData(), - ]); - - return gasPrice.maxFeePerGas.mul(gasAmount); + const ens = new ENS(network.config, provider, FDS_DOMAIN); + return ens.registerUsernameApproximatePrice(); } export function getAccountBalance(