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

fix(bridge-ui): update abis #13705

Merged
merged 31 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3f5c2bd
Update ABIs
jscriptcoder May 4, 2023
a58a527
Update ABIs
jscriptcoder May 4, 2023
b7bd6bf
Minor change
jscriptcoder May 4, 2023
fd3b747
Minor change
jscriptcoder May 4, 2023
4f07e10
Fix abi imports
jscriptcoder May 4, 2023
bd5da3f
Improvements
jscriptcoder May 5, 2023
48edaf1
Merge branch 'main' into update_abis
jscriptcoder May 5, 2023
c559c98
lock file got behind
jscriptcoder May 5, 2023
757ed7f
improve copy-abi script
jscriptcoder May 6, 2023
8c6e824
add some comments
jscriptcoder May 6, 2023
779e26b
Minor change
jscriptcoder May 6, 2023
d15f1d2
minor change
jscriptcoder May 6, 2023
e1751f2
fix and improve recommendedProcessingFee test
jscriptcoder May 7, 2023
a8ef9b4
Merge branch 'main' into update_abis
dantaik May 8, 2023
84bdde3
updated env vars to new values
jscriptcoder May 8, 2023
eb61329
Merge branch 'update_abis' of https://github.com/taikoxyz/taiko-mono …
jscriptcoder May 8, 2023
718b004
updated erc20 tokens
jscriptcoder May 8, 2023
f8f2388
use wagmi cli to grab the abis instead
jscriptcoder May 9, 2023
4c97f89
Minor change
jscriptcoder May 9, 2023
61bb0d8
ignore wagmi.config.ts
jscriptcoder May 9, 2023
6126122
ignore wagmi.config.ts
jscriptcoder May 9, 2023
44603ba
minor change
jscriptcoder May 9, 2023
6640dd0
test new config
jscriptcoder May 9, 2023
1dfd9e7
Minor change
jscriptcoder May 9, 2023
52cfb69
Another minor change
jscriptcoder May 9, 2023
0fefbfe
use Bridge.sol instead
jscriptcoder May 9, 2023
6d37071
Merge branch 'main' into update_abis
jscriptcoder May 9, 2023
599ff96
Merge branch 'main' into update_abis
jscriptcoder May 9, 2023
a036815
Merge branch 'main' into update_abis
jscriptcoder May 11, 2023
f9cdf06
update abis, again!!
jscriptcoder May 11, 2023
94650cb
Merge branch 'update_abis' of https://github.com/taikoxyz/taiko-mono …
jscriptcoder May 11, 2023
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
1 change: 1 addition & 0 deletions packages/bridge-ui/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ dist
build
coverage
node_modules
scripts
example
LICENSES
public
1 change: 1 addition & 0 deletions packages/bridge-ui/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ dist
build
coverage
node_modules
scripts
example
LICENSES
public
Expand Down
4 changes: 3 additions & 1 deletion packages/bridge-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"prettier:check": "pnpm run prettier '**/*.{js,ts,svelte}' --check",
"lint": "pnpm exec eslint './**/*.{js,ts,svelte}' --ignore-path .eslintignore",
"lint:fix": "pnpm exec eslint --fix './**/*.{js,ts,svelte}' --ignore-path .eslintignore",
"lint-staged": "lint-staged --allow-empty"
"lint-staged": "lint-staged --allow-empty",
"copy-abi": "node ./scripts/copy-abi.js"
},
"devDependencies": {
"@babel/preset-env": "^7.16.0",
Expand All @@ -36,6 +37,7 @@
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-svelte3": "^4.0.0",
"fs-extra": "^11.1.1",
"jest": "^27.5.1",
"lint-staged": "^12.3.4",
"node-sass": "^7.0.1",
Expand Down
36 changes: 36 additions & 0 deletions packages/bridge-ui/scripts/copy-abi.js
jscriptcoder marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import fs from 'fs-extra';
import path from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
jscriptcoder marked this conversation as resolved.
Show resolved Hide resolved

const protocolAbiPath = path.resolve(__dirname, '../../protocol/abi');
const abiOutputPath = path.resolve(__dirname, '../src/constants/abi');

const jsonFilesMap = {
Bridge: '/contracts/bridge/Bridge.sol/Bridge.json',
ERC20: '/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.json',
TokenVault: '/contracts/bridge/TokenVault.sol/TokenVault.json',
CrossChainSync: '/contracts/common/ICrossChainSync.sol/ICrossChainSync.json',
FreeMintERC20: '/contracts/test/erc20/FreeMintERC20.sol/FreeMintERC20.json',
};

// Remove all files within the directory but not the directory itself
fs.emptyDirSync(abiOutputPath);

Object.entries(jsonFilesMap).forEach(([name, jsonPath]) => {
try {
const jsonStr = fs.readFileSync(protocolAbiPath + jsonPath, {
encoding: 'utf8',
});

fs.writeFileSync(`${abiOutputPath}/${name}.json`, jsonStr, 'utf8');
} catch (e) {
if (e.code === 'ENOENT') {
console.error(`File not found: ${e.path}`);
} else {
console.error('Something really bad happened 😱', e);
}
}
});
2 changes: 1 addition & 1 deletion packages/bridge-ui/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import SwitchEthereumChainModal from './components/modals/SwitchEthereumChainModal.svelte';
import { ethers } from 'ethers';
import { MessageStatus } from './domain/message';
import BridgeABI from './constants/abi/Bridge';
import BridgeABI from './constants/abi/Bridge.json';
import { userTokens } from './store/userToken';
import { RelayerAPIService } from './relayer-api/RelayerAPIService';
import {
Expand Down
14 changes: 7 additions & 7 deletions packages/bridge-ui/src/bridge/ERC20Bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import type {
ClaimOpts,
ReleaseOpts,
} from '../domain/bridge';
import TokenVault from '../constants/abi/TokenVault';
import ERC20 from '../constants/abi/ERC20';
import TokenVaultABI from '../constants/abi/TokenVault.json';
import ERC20_ABI from '../constants/abi/ERC20.json';
import type { Prover } from '../domain/proof';
import { MessageStatus } from '../domain/message';
import BridgeABI from '../constants/abi/Bridge';
import BridgeABI from '../constants/abi/Bridge.json';
import { chains } from '../chain/chains';

export class ERC20Bridge implements Bridge {
Expand All @@ -24,7 +24,7 @@ export class ERC20Bridge implements Bridge {
static async prepareTransaction(opts: BridgeOpts) {
const contract: Contract = new Contract(
opts.tokenVaultAddress,
TokenVault,
TokenVaultABI,
opts.signer,
);

Expand Down Expand Up @@ -58,7 +58,7 @@ export class ERC20Bridge implements Bridge {
amount: BigNumber,
bridgeAddress: string,
): Promise<boolean> {
const contract: Contract = new Contract(tokenAddress, ERC20, signer);
const contract: Contract = new Contract(tokenAddress, ERC20_ABI, signer);
const owner = await signer.getAddress();
const allowance: BigNumber = await contract.allowance(owner, bridgeAddress);

Expand Down Expand Up @@ -88,7 +88,7 @@ export class ERC20Bridge implements Bridge {

const contract: Contract = new Contract(
opts.contractAddress,
ERC20,
ERC20_ABI,
opts.signer,
);

Expand Down Expand Up @@ -250,7 +250,7 @@ export class ERC20Bridge implements Bridge {

const srcTokenVaultContract: Contract = new Contract(
opts.srcTokenVaultAddress,
TokenVault,
TokenVaultABI,
opts.signer,
);

Expand Down
2 changes: 1 addition & 1 deletion packages/bridge-ui/src/bridge/ETHBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
ReleaseOpts,
} from '../domain/bridge';
import type { Prover } from '../domain/proof';
import BridgeABI from '../constants/abi/Bridge';
import BridgeABI from '../constants/abi/Bridge.json';
import { chains } from '../chain/chains';
import { type Message, MessageStatus } from '../domain/message';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

import { LottiePlayer } from '@lottiefiles/svelte-lottie-player';
import { errorToast, successToast } from '../Toast.svelte';
import HeaderSyncABI from '../../constants/abi/ICrossChainSync';
import BridgeABI from '../../constants/abi/Bridge';
import CrossChainSyncABI from '../../constants/abi/CrossChainSync.json';
import BridgeABI from '../../constants/abi/Bridge.json';
import ButtonWithTooltip from '../ButtonWithTooltip.svelte';
import TokenVaultABI from '../../constants/abi/TokenVault';
import TokenVaultABI from '../../constants/abi/TokenVault.json';
import { chains } from '../../chain/chains';
import { providers } from '../../provider/providers';
import { bridges } from '../../bridge/bridges';
Expand Down Expand Up @@ -176,7 +176,7 @@

const contract = new Contract(
chains[transaction.toChainId].crossChainSyncAddress,
HeaderSyncABI,
CrossChainSyncABI,
providers[chains[transaction.toChainId].id],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { BridgeType, type HTMLBridgeForm } from '../../domain/bridge';
import { ChevronDown, PlusCircle } from 'svelte-heros-v2';
import { ethers } from 'ethers';
import ERC20_ABI from '../../constants/abi/ERC20';
import ERC20_ABI from '../../constants/abi/ERC20.json';
import { signer } from '../../store/signer';
import { userTokens } from '../../store/userToken';
import { fromChain, toChain } from '../../store/chain';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Modal from '../modals/Modal.svelte';
import { LottiePlayer } from '@lottiefiles/svelte-lottie-player';
import { ethers } from 'ethers';
import ERC20 from '../../constants/abi/ERC20';
import ERC20 from '../../constants/abi/ERC20.json';
import { ETHToken } from '../../token/tokens';
import { errorToast } from '../Toast.svelte';
import { tokenService } from '../../storage/services';
Expand Down
4 changes: 2 additions & 2 deletions packages/bridge-ui/src/components/form/BridgeForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
transactions as transactionsStore,
} from '../../store/transactions';
import Memo from './Memo.svelte';
import ERC20_ABI from '../../constants/abi/ERC20';
import TokenVaultABI from '../../constants/abi/TokenVault';
import ERC20_ABI from '../../constants/abi/ERC20.json';
import TokenVaultABI from '../../constants/abi/TokenVault.json';
import type { BridgeTransaction } from '../../domain/transactions';
import { MessageStatus } from '../../domain/message';
import { Funnel } from 'svelte-heros-v2';
Expand Down
6 changes: 3 additions & 3 deletions packages/bridge-ui/src/components/modals/FaucetModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { pendingTransactions } from '../../store/transactions';
import { signer } from '../../store/signer';
import { _ } from 'svelte-i18n';
import MintableERC20 from '../../constants/abi/MintableERC20';
import FreeMintERC20_ABI from '../../constants/abi/FreeMintERC20.json';
import { fromChain } from '../../store/chain';
import { fetchSigner, switchNetwork } from '@wagmi/core';
import Modal from './Modal.svelte';
Expand Down Expand Up @@ -35,7 +35,7 @@

const contract = new ethers.Contract(
$token.addresses[0].address,
MintableERC20,
FreeMintERC20_ABI,
$signer,
);

Expand Down Expand Up @@ -70,7 +70,7 @@
}
const contract = new ethers.Contract(
$token.addresses[0].address,
MintableERC20,
FreeMintERC20_ABI,
$signer,
);

Expand Down
Loading