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

Luizoamorim/from ilyas browser fixes 2 #670

Merged
merged 21 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b5e7fbe
feat: flexible link to correct etherscan based on the current network
luizoamorim May 17, 2022
cc2dea6
feat: setting the l1 transcation hash in our tx to be saved in database
luizoamorim May 17, 2022
f94bd6f
fix: eslint problems
luizoamorim May 18, 2022
ab20506
fix: eslint problems and warnings
luizoamorim May 18, 2022
e3eabc9
fix: fixing the mas button getting the elementId of bridge input base…
luizoamorim May 18, 2022
9e4dfc3
fix: eslint problems
luizoamorim May 18, 2022
40688d1
fix: doing all verifications for deposit and withdraws transfers
luizoamorim May 18, 2022
90ab92a
fix: eslint problems
luizoamorim May 18, 2022
255fa22
fix: send modal verifications and max button
luizoamorim May 19, 2022
9d885a5
fix: eslint problems
luizoamorim May 19, 2022
fda14b0
fix: eslint problems
luizoamorim May 19, 2022
113512a
fix: eslint problems
luizoamorim May 19, 2022
03e3f10
feat: sending the user for transactions after deposit or withdraw con…
luizoamorim May 20, 2022
f0e3cc6
fix: eslint problems creating a function for continue transfer in sen…
luizoamorim May 20, 2022
f64825b
fix: eslint problems
luizoamorim May 20, 2022
e702705
fix: removing hardcoded amount restriction for deposit
luizoamorim May 25, 2022
d638fbd
fix: eslint problems
luizoamorim May 25, 2022
cb575f7
fix: verifying the l2 address correcty with decompressKey function
luizoamorim May 26, 2022
0e8a9c9
fix: eslint problems
luizoamorim May 26, 2022
2476cb4
fix: eslint problems
luizoamorim May 26, 2022
3d21c57
fix: eslint
luizoamorim May 26, 2022
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
189 changes: 91 additions & 98 deletions wallet/package-lock.json

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

1 change: 1 addition & 0 deletions wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
},
"scripts": {
"start": "LOCAL_PROPOSER=true PUBLIC_URL='/nightfall/' USE_STUBS=true REACT_APP_MODE=local node scripts/start.js",
"start:testnet": "LOCAL_PROPOSER=false PUBLIC_URL='/nightfall/' USE_STUBS=false REACT_APP_MODE=testnet node scripts/start.js",
"build": "LOCAL_PROPOSER=false USE_STUBS=false REACT_APP_MODE=production PUBLIC_URL='https://wallet-beta.polygon.technology/nightfall/' node scripts/build.js",
"deploy": "npm run build && aws s3 sync build s3://pnf-dev-browser --cache-control max-age=172800 --delete && aws configure set preview.cloudfront true && aws cloudfront create-invalidation --distribution-id ENV3X13MLR5YT --paths \"/*\"",
"test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'tests/**/*.ts'",
Expand Down
81 changes: 59 additions & 22 deletions wallet/src/components/BridgeComponent/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,17 @@ const BridgeComponent = () => {
console.log('readyTx', readyTx);
try {
switch (readyTx.type) {
case 'onchain':
await submitTransaction(readyTx.rawTransaction, shieldContractAddress, 150000, 0); // 150k is enough gasLimit for a deposit
case 'onchain': {
const txL1Hash = await submitTransaction(
readyTx.rawTransaction,
shieldContractAddress,
150000,
0,
); // 150k is enough gasLimit for a deposit
readyTx.transaction.l1Hash = txL1Hash;
break;
case 'offchain':
}
case 'offchain': {
luizoamorim marked this conversation as resolved.
Show resolved Hide resolved
await axios
.post(
`${proposerUrl}/proposer/offchain-transaction`,
Expand All @@ -205,8 +212,10 @@ const BridgeComponent = () => {
throw new Error(err);
});
break;
default:
}
default: {
luizoamorim marked this conversation as resolved.
Show resolved Hide resolved
console.log('Error when sending');
}
}
await saveTransaction(readyTx.transaction);
handleClose();
Expand Down Expand Up @@ -311,10 +320,35 @@ const BridgeComponent = () => {
(txType === 'deposit' &&
new BigFloat(transferValue, token.decimals).toBigInt() > l1Balance) ||
(txType === 'withdraw' && new BigFloat(transferValue, token.decimals).toBigInt() > l2Balance)
)
) {
toast.error("Input value can't be greater than balance!");
else if (!transferValue) toast.warn('Input a value for transfer, please.');
else if (transferValue === 0) toast.warn("Input a value can't be zero.");
return;
}

if (
txType === 'deposit' &&
new BigFloat(transferValue, token.decimals).toBigInt() >
parseInt(token.restrictions[txType], 10)
) {
toast.error(
`Input value can't be greater than ${
parseInt(token.restrictions[txType], 10) /
parseInt(new BigFloat('1', token.decimals).toBigInt().toString(), 10)
}`,
);
return;
}

if (!transferValue) {
toast.warn('Input a value for transfer, please.');
return;
}

if (transferValue === '0') {
toast.warn("Input a value can't be zero.");
return;
}

setShow(true);
};

Expand Down Expand Up @@ -344,13 +378,22 @@ const BridgeComponent = () => {
}, [token, txType, accountInstance]);

const updateInputValue = () => {
const inputElement = document
.querySelector('nightfall-app')
.shadowRoot.getElementById('inputValue');
if (txType === 'deposit') {
document.getElementById('inputValue').value = l1Balance;
setTransferValue(l1Balance);
inputElement.value = new BigFloat(l1Balance, token.decimals).toFixed(4);
setTransferValue(new BigFloat(l1Balance, token.decimals).toFixed(4).toString());
return;
}
document.getElementById('inputValue').value = l2Balance;
setTransferValue(l2Balance);
inputElement.value = new BigFloat(l2Balance, token.decimals).toFixed(4);
setTransferValue(new BigFloat(l2Balance, token.decimals).toFixed(4).toString());
};

const continueTransfer = async () => {
if (await submitTx()) {
history.push('/transactionPage');
}
};

return (
Expand Down Expand Up @@ -527,15 +570,9 @@ const BridgeComponent = () => {

{/* TRANSFER BUTTON */}
<div>
{Number(transferValue) > 0 ? (
<button type="button" className="transfer_button" onClick={handleShow}>
<p>Transfer</p>
</button>
) : (
<button type="button" className="transfer_button">
<p>Transfer</p>
</button>
)}
<button type="button" className="transfer_button" onClick={handleShow}>
<p>Transfer</p>
</button>
</div>
</div>
{show && (
Expand Down Expand Up @@ -625,9 +662,9 @@ const BridgeComponent = () => {
<ContinueTransferButton
type="button"
id="Bridge_modal_continueTransferButton"
onClick={() => {
onClick={async () => {
setSendingState(true);
submitTx();
continueTransfer();
}}
>
{sending ? (
Expand Down
Loading