From 5c308cbe3c8b9a77f376d87f14b7967aa6d2f50e Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Fri, 20 Oct 2023 12:51:37 +0300 Subject: [PATCH 1/2] Adding buffer to the quote amount --- src/components/TabsFile/index.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/components/TabsFile/index.tsx b/src/components/TabsFile/index.tsx index 893b8c2..ab0abf1 100644 --- a/src/components/TabsFile/index.tsx +++ b/src/components/TabsFile/index.tsx @@ -70,6 +70,7 @@ export default function TabsFile({ console.log('balance wmatic: ', balanceData) // Mocked data quote const [quote, setQuote] = useState() + const [quoteWithBuffer, setQuoteWithBuffer] = useState() const [uploadStatusResponse, setUploadStatusResponse] = useState('') const [ddoLink, setDDOLink] = useState('') @@ -222,9 +223,14 @@ export default function TabsFile({ console.log('quoteResult.tokenAmount', quoteResult.tokenAmount) console.log('quote tokenAmount', quote) + // Add buffer to the quote amount + const newQuoteFee = + BigInt(quoteResult.tokenAmount) + BigInt(50000000000000000) + + setQuoteWithBuffer(String(newQuoteFee)) + // Check if user has wrapped matic in their wallet - const quotePrice = BigInt(quoteResult.tokenAmount) - if (wmaticBalance < quotePrice) { + if (wmaticBalance < newQuoteFee) { console.log('User does not have enough wMatic') setStep('wrapMatic') } else { @@ -290,11 +296,10 @@ export default function TabsFile({ try { console.log('uploading: ', { quoteId, payment, quoteFee, files, type }) console.log('String(quoteFee)', String(quoteFee)) - const newQuoteFee = BigInt(quoteFee) + BigInt(3000000000000000) const quoteAndUploadResult: any = await uploaderClient.uploadBrowser( quoteId, payment, - String(newQuoteFee), + String(quoteFee), files as FileList, type ) @@ -366,7 +371,7 @@ export default function TabsFile({ await getUpload({ quoteId: quote.quoteId, payment: quote.tokenAddress, - quoteFee: String(quote.tokenAmount), + quoteFee: String(quoteWithBuffer), files: [file] as unknown as FileList, type: items[tabIndex].type }) @@ -512,7 +517,7 @@ export default function TabsFile({ }} disabled={false} > - {`${formatEther(`${quote.tokenAmount}`)} ${ + {`${formatEther(`${quoteWithBuffer}`)} ${ items[tabIndex].payment .filter( (item: any) => item.chainId === chain?.id.toString() @@ -560,7 +565,7 @@ export default function TabsFile({ {step === 'wrapMatic' ? ( Date: Fri, 20 Oct 2023 13:05:20 +0300 Subject: [PATCH 2/2] updating uploader.js package --- package-lock.json | 12 ++++++------ package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 31594a4..5dac75f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,17 @@ { "name": "@oceanprotocol/uploader-ui-lib", - "version": "0.2.0", + "version": "0.2.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@oceanprotocol/uploader-ui-lib", - "version": "0.2.0", + "version": "0.2.2", "license": "Apache-2.0", "dependencies": { "@ethersproject/units": "^5.7.0", "@oceanprotocol/typographies": "^0.1.0", - "@oceanprotocol/uploader": "^0.0.2-alpha.33", + "@oceanprotocol/uploader": "^0.0.2-alpha.34", "@tippyjs/react": "^4.2.6", "@types/react": "^17.0.59", "ajv": "^8.12.0", @@ -3946,9 +3946,9 @@ "integrity": "sha512-kMsZsqvzpz9KzVbVZzllwhPoIC3zbqsdRrClagZL/C2PHzgLrKGC1kYn3gPt0RMIFg9ZjrwieKaxlgIK9i9zzg==" }, "node_modules/@oceanprotocol/uploader": { - "version": "0.0.2-alpha.33", - "resolved": "https://registry.npmjs.org/@oceanprotocol/uploader/-/uploader-0.0.2-alpha.33.tgz", - "integrity": "sha512-V9uhIM8A/hDpIznhNzul2I0nUi1f+PRbKUNtOGvEZBS//QUZKUeiG3jJF+CmgioIqoUKCRdbUQ+OB9Z+AMIYtg==", + "version": "0.0.2-alpha.34", + "resolved": "https://registry.npmjs.org/@oceanprotocol/uploader/-/uploader-0.0.2-alpha.34.tgz", + "integrity": "sha512-cWpLsr/pl6jnVnCIPAXlJ9L2vIfZefZW1uNFVw9i73BjDE5Cjc+uTwhsipFFCyb3V9A8z03DOPMzZx7o9ttrNw==", "dependencies": { "arweave": "^1.14.4", "axios": "^1.4.0", diff --git a/package.json b/package.json index 4001678..2936eb9 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "dependencies": { "@ethersproject/units": "^5.7.0", "@oceanprotocol/typographies": "^0.1.0", - "@oceanprotocol/uploader": "^0.0.2-alpha.33", + "@oceanprotocol/uploader": "^0.0.2-alpha.34", "@tippyjs/react": "^4.2.6", "@types/react": "^17.0.59", "ajv": "^8.12.0",