Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding buffer to the quote amount #99

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 12 additions & 7 deletions src/components/TabsFile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default function TabsFile({
console.log('balance wmatic: ', balanceData)
// Mocked data quote
const [quote, setQuote] = useState<any>()
const [quoteWithBuffer, setQuoteWithBuffer] = useState<string>()
const [uploadStatusResponse, setUploadStatusResponse] = useState<any>('')
const [ddoLink, setDDOLink] = useState('')

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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
})
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -560,7 +565,7 @@ export default function TabsFile({
{step === 'wrapMatic' ? (
<WrapMatic
setStep={setStep}
amount={BigInt(quote.tokenAmount)}
amount={BigInt(quoteWithBuffer as string)}
name={item.type}
handleFileChange={handleFileChange}
handleUpload={handleUpload}
Expand Down
Loading