Skip to content

Commit

Permalink
Merge pull request #252 from G7DAO/feat/update-bridge-sdk
Browse files Browse the repository at this point in the history
fix bug of setting init. amount
  • Loading branch information
elclandestin0 authored Dec 16, 2024
2 parents 6fbb53d + b3b1a0f commit aa8fbbb
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,10 @@ const BridgeView = ({
try {
console.log('fetching allowances')
const bridgeTokenAllowance = await _bridger.getAllowance(direction === 'DEPOSIT' ? selectedLowNetwork.rpcs[0] : selectedHighNetwork.rpcs[0], connectedAccount)
console.log('bridgeTokenAllowance', bridgeTokenAllowance)
bridgeTokenAllowance && console.log('bridgeTokenAllowance', ethers.utils.formatUnits(bridgeTokenAllowance, selectedBridgeToken.decimals))
const nativeTokenAllowance = await _bridger.getNativeAllowance(direction === 'DEPOSIT' ? selectedLowNetwork.rpcs[0] : selectedHighNetwork.rpcs[0], connectedAccount)
console.log('nativeTokenAllowance', nativeTokenAllowance)
if (bridgeTokenAllowance && nativeTokenAllowance) {
console.log(
ethers.utils.formatUnits(bridgeTokenAllowance!, selectedBridgeToken.decimals),
ethers.utils.formatEther(nativeTokenAllowance!)
)
}
nativeTokenAllowance && console.log('nativeTokenAllowance', ethers.utils.formatEther(nativeTokenAllowance))

setBridgeTokenAllowance(bridgeTokenAllowance as ethers.BigNumber | null)
setNativeTokenAllowance(nativeTokenAllowance as ethers.BigNumber | null)
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ export const MultiTokenApproval: React.FC<MultiTokenApprovalProps> = ({ showAppr
}

const currentToken = tokens[currentTokenIndex];
const initialAmount = currentTokenIndex === 1
? ethers.utils.parseUnits(gasFees[1] || '0', currentToken.decimals || 18)
: currentTokenIndex === 0
? ethers.utils.parseUnits(amount || '0', decimals || 18)
: ethers.utils.parseUnits(amount || '0', currentToken.decimals || 18)

setNewAllowance(initialAmount);
if (!newAllowance) {
const initialAmount = currentTokenIndex === 1
? ethers.utils.parseUnits(gasFees[1] || '0', currentToken.decimals || 18)
: currentTokenIndex === 0
? ethers.utils.parseUnits(amount || '0', decimals || 18)
: ethers.utils.parseUnits(amount || '0', currentToken.decimals || 18)
setNewAllowance(initialAmount);
}
}, [currentTokenIndex, tokens, amount, decimals, gasFees]);

const approve = useMutation(
Expand Down
2 changes: 1 addition & 1 deletion webapps/world-builder-dashboard/src/hooks/useBridger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const useBridger = () => {

const destinationProvider = direction === 'DEPOSIT' ?
selectedHighNetwork.rpcs[0] :
undefined
selectedLowNetwork.rpcs[0]

console.log("Destination provider:", destinationProvider)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
width: 100vw;
position: relative;
font-family: Inter, sans-serif;
background: url('../../../src/assets/background.jpeg') lightgray 0px -1.156px / 100% 100.23% no-repeat;
}

.sideBar {
Expand All @@ -18,6 +19,7 @@
min-width: 280px;
border-right: 1px solid var(--Gray-200, #eaecf0);
background: var(--Base-White, #fff);
backdrop-filter: blur(2px);
}

.sideBarTop {
Expand Down Expand Up @@ -76,7 +78,8 @@
font-size: 16px;
font-style: normal;
font-weight: 600;
line-height: 24px; /* 150% */
line-height: 24px;
/* 150% */

text-transform: capitalize;
}
Expand Down Expand Up @@ -119,7 +122,8 @@
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 20px; /* 142.857% */
line-height: 20px;
/* 142.857% */
}

.iconButton {
Expand All @@ -138,6 +142,7 @@
flex-direction: column;
min-width: 100vw;
}

.logoContainer {
padding: 0;
}
Expand Down Expand Up @@ -166,7 +171,8 @@
font-size: 14px;
font-style: normal;
font-weight: 600;
line-height: 20px; /* 142.857% */
line-height: 20px;
/* 142.857% */
}

.connectingWalletText {
Expand All @@ -176,7 +182,8 @@
font-size: 14px;
font-style: normal;
font-weight: 600;
line-height: 20px; /* 142.857% */
line-height: 20px;
/* 142.857% */
}

.icon {
Expand Down Expand Up @@ -239,4 +246,4 @@
width: var(--20px, 20px);
height: var(--20px, 20px);
stroke: var(--Selected-Theme-Icon, #fff);
}
}

0 comments on commit aa8fbbb

Please sign in to comment.