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

[Bridge] Frontend Development #1908

Open
wants to merge 99 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
70d18a1
fix:
Jennievon May 30, 2024
044a343
Fix import in 500.tsx and remove unused import
Jennievon May 30, 2024
7cec3aa
update wrong import path
Jennievon May 30, 2024
f4bc8a9
Fix form receiver value bug
Jennievon May 30, 2024
4c0838d
refactor: contract instance
Jennievon Jun 2, 2024
581cb74
Fix loading state and add transaction hash to
Jennievon Jun 3, 2024
45ce9d4
Add Ten Bridge deployment workflow and Dockerfile
Jennievon Jun 11, 2024
52ceab6
Update bridge example env variables
Jennievon Jun 11, 2024
2475db4
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Jun 20, 2024
7735df6
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Jun 20, 2024
5dbeb83
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Jun 26, 2024
f18157f
Fix favicon link and meta tags
Jennievon Jul 1, 2024
4d8fdd2
wip: refactor provider
Jennievon Jul 2, 2024
b46d582
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Jul 18, 2024
6db7193
wip: L2>L1 bridge withdrawal
Jennievon Jul 19, 2024
a9e5733
wip: L2>L1 bridge withdrawal
Jennievon Jul 22, 2024
f355d32
Add new contract files
Jennievon Jul 22, 2024
f824f5c
refactor: contract store
Jennievon Jul 25, 2024
32ced69
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Jul 25, 2024
46271a6
update manifest and favicon files
Jennievon Jul 31, 2024
5634bd9
add dashboard sub components
Jennievon Jul 31, 2024
2e00fd8
add nvmrc file
Jennievon Jul 31, 2024
73b208d
update env example file
Jennievon Jul 31, 2024
bdd1067
refactor config method to get contracts
Jennievon Jul 31, 2024
375c7c5
update component format
Jennievon Jul 31, 2024
eb2b9c4
Update API endpoint and switchNetwork function
Jennievon Jul 31, 2024
2b7928c
Add utility functions for wallet and event
Jennievon Jul 31, 2024
4f39d03
Refactor destination address form
Jennievon Jul 31, 2024
71d9665
wip: refactor bridge implementation
Jennievon Aug 5, 2024
60554ff
fix: token and chain select defaultValue bug
Jennievon Aug 5, 2024
c8a3132
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Aug 5, 2024
28d57ec
Delete unused contract files
Jennievon Aug 5, 2024
3257e49
rm logs
Jennievon Aug 5, 2024
2c5d2ed
update chain and token selection logic
Jennievon Aug 6, 2024
75aaf89
Update environment variables in Dockerfile and
Jennievon Aug 6, 2024
56ffa28
Add privateKey constant and display toast messages
Jennievon Aug 6, 2024
e419680
Fix wallet connection and balance validation
Jennievon Aug 6, 2024
a03bb1c
Update siteMetadata description in Ten Bridge
Jennievon Aug 6, 2024
12df673
Update environment variable and API host URLs
Jennievon Aug 7, 2024
2f1da92
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Aug 7, 2024
a369f72
feat: state mgt - add contract and wallet stores
Jennievon Aug 13, 2024
421af27
Fix import statements and add missing dependencies
Jennievon Aug 13, 2024
4cdd296
Fix switchNetwork method call
Jennievon Aug 13, 2024
bd0738f
Update API host and remove unused import
Jennievon Aug 14, 2024
8b236ae
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Aug 14, 2024
1ec1146
updat build error
Jennievon Aug 14, 2024
1fcfbdc
fix network config request
zkokelj Aug 14, 2024
97fa89a
Merge branch 'jennifer/3248-bridge-develop-bridge-frontend' of https:…
zkokelj Aug 14, 2024
86939a5
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Aug 14, 2024
720bc1a
Merge branch 'jennifer/3248-bridge-develop-bridge-frontend' of https:…
Jennievon Aug 14, 2024
483e548
Refactor API routes and service functions
Jennievon Aug 15, 2024
cc10014
refactor contract store
Jennievon Aug 15, 2024
fbb57b6
rm logs
Jennievon Aug 15, 2024
ec2de17
add a polling interval for balance
Jennievon Aug 15, 2024
abd96c2
add estimated gas fee
Jennievon Aug 15, 2024
51db0e8
Fix balance fetching bug and remove unused code
Jennievon Aug 15, 2024
1ece8e8
Refactor contract-store to use IContractState
Jennievon Aug 20, 2024
3e3cf48
refactor type names in bridge components
Jennievon Aug 20, 2024
57bedf5
refactor wallet store and provider
Jennievon Aug 20, 2024
d24c71b
- add TruncatedAddress to header
Jennievon Aug 21, 2024
670d013
- add showCopy prop to TruncatedAddress component to hide copy button
Jennievon Aug 21, 2024
92f5d1c
fix: `isL1ToL2` assignment in wallet store
Jennievon Aug 21, 2024
2105123
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Aug 21, 2024
da45a87
move bridge frontend folder to tools folder
Jennievon Aug 21, 2024
a4d5bb7
update node and react dependencies
Jennievon Aug 21, 2024
cebf589
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Aug 21, 2024
8ea863c
- handle unknown account error
Jennievon Aug 21, 2024
7cbc078
update contract hooks name
Jennievon Aug 22, 2024
b9f2ae7
Add `bridgeAddress` to contract service
Jennievon Aug 23, 2024
70f097a
feat: bridge txn logs
Jennievon Aug 25, 2024
ea2fa6d
add noPagination prop to TransactionsComponent
Jennievon Aug 25, 2024
7303f5f
fix: balance display issue-`transfer-from-section`
Jennievon Aug 26, 2024
679c533
refactor: move contract utility methods to utils file
Jennievon Aug 26, 2024
389430e
rm log statements
Jennievon Aug 26, 2024
5215482
add status to bridge txn columns
Jennievon Aug 26, 2024
6c5844e
Fix linting issues causing build error
Jennievon Aug 26, 2024
9f881b7
improve bridge txn handling and provider setup
Jennievon Aug 26, 2024
345012e
- add useQuery hook for fetching token balance
Jennievon Aug 27, 2024
5feb07a
refactor wallet initialization and provider
Jennievon Aug 27, 2024
98dd217
- add Infura key to env example
Jennievon Aug 28, 2024
f9014a3
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Sep 2, 2024
8213b4b
refactor:
Jennievon Aug 30, 2024
131486e
feat: error handling and value transfer extraction
Jennievon Sep 2, 2024
e85e8dc
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Sep 3, 2024
c996099
update setupEventListeners
Jennievon Sep 4, 2024
38f00d2
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Sep 5, 2024
e8d7d59
add gateway to test
badgersrus Sep 5, 2024
ee01c81
Merge branch 'will/tenscan-with-gateway-test' of https://github.com/t…
Jennievon Sep 5, 2024
feeff8c
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Sep 6, 2024
c781f43
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Sep 6, 2024
543be2c
- increase gas estimation timeout
Jennievon Sep 6, 2024
6b184fd
feat: Implement multi-step txn resumption w state mgt
Jennievon Sep 9, 2024
9bf2ec4
chore: rm tenscan_test local integrations/helper to enable local testing
Jennievon Sep 9, 2024
07ffad7
feat: allow user to refresh their balance manually
Jennievon Sep 10, 2024
e05fefe
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Sep 10, 2024
87056db
refactor: add retry logic to accommodate gas estimation errors and av…
Jennievon Sep 10, 2024
a022729
- rm API version from routes
Jennievon Sep 18, 2024
b473386
invalidate bridge txn queries after succesful txn
Jennievon Sep 18, 2024
2bb506f
fix: signer initialisation
Jennievon Sep 19, 2024
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 tools/bridge-frontend/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.11.0
2 changes: 2 additions & 0 deletions tools/bridge-frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ WORKDIR /home/obscuro/go-obscuro/tools/bridge-frontend
ARG API_HOST
ARG API_HOST_ENVIRONMENT
ARG GOOGLE_ANALYTICS_ID
ARG INFURA_KEY

# ENV for URL to be used in the app
ENV NEXT_PUBLIC_BRIDGE_API_HOST=${API_HOST}
ENV NEXT_PUBLIC_BRIDGE_API_HOST_ENVIRONMENT=${API_HOST_ENVIRONMENT}
ENV NEXT_PUBLIC_BRIDGE_GOOGLE_ANALYTICS_ID=${GOOGLE_ANALYTICS_ID}
ENV NEXT_PUBLIC_BRIDGE_INFURA_KEY=${INFURA_KEY}

RUN npm install

Expand Down
20 changes: 20 additions & 0 deletions tools/bridge-frontend/api/general.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { INetworkConfig, ResponseDataInterface } from "@/src/types";
import { httpRequest } from "@/api";
import { pathToUrl } from "@/src/routes/router";
import { apiRoutes } from "@/src/routes";

export const fetchTestnetStatus = async (): Promise<
ResponseDataInterface<boolean>
> => {
return await httpRequest<ResponseDataInterface<boolean>>({
method: "get",
url: pathToUrl(apiRoutes.getHealthStatus),
});
};

export const fetchNetworkConfig = async (): Promise<INetworkConfig> => {
return await httpRequest<INetworkConfig>({
method: "get",
url: apiRoutes.getNetworkConfig,
});
};
90 changes: 90 additions & 0 deletions tools/bridge-frontend/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { apiHost } from "@/src/lib/constants";
import axios, { AxiosInstance, AxiosRequestConfig } from "axios";

type HttpMethod = "get" | "post" | "put" | "patch" | "delete";

interface HttpOptions {
method?: HttpMethod;
url: string;
data?: Record<string, any>;
params?: Record<string, any>;
headers?: Record<string, any>;
timeout?: number;
responseType?:
| "json"
| "arraybuffer"
| "blob"
| "document"
| "text"
| undefined;
download?: boolean;
searchParams?: Record<string, any>;
}

const baseConfig: AxiosRequestConfig = {
baseURL: apiHost,
timeout: 10000,
};

const https: AxiosInstance = axios.create(baseConfig);

export const httpRequest = async <ResponseData>(
options: HttpOptions,
config: AxiosRequestConfig = {}
): Promise<ResponseData> => {
const {
method = "get",
url,
data,
params,
headers,
timeout,
responseType,
searchParams,
} = options;
let query = "";
if (searchParams) {
const filteredParams = Object.fromEntries(
Object.entries(searchParams).filter(
([, value]) => value !== undefined && value !== null && value !== ""
)
);
if (Object.keys(filteredParams).length) {
query = new URLSearchParams(filteredParams).toString();
}
}

const httpConfig: AxiosRequestConfig = {
method,
url: query ? `${url}?${query}` : url,
data,
params,
headers: { ...(headers || {}) },
timeout,
responseType: responseType,
...config,
};
try {
const response = await https(httpConfig);
return response.data as ResponseData;
} catch (error) {
handleHttpError(error);
throw error;
}
};

// Centralized error handling function
const handleHttpError = (error: any) => {
// if the error is a server error (status code 5xx) before handling
if (isAxiosError(error) && error.response && error.response.status >= 500) {
console.error("Server error:", error);
} else {
// other errors
console.error("An error occurred:", error);
}
};

// Type guard to check if the error is an AxiosError
const isAxiosError = (error: any): error is import("axios").AxiosError => {
return error.isAxiosError === true;
};
4 changes: 4 additions & 0 deletions tools/bridge-frontend/artifacts/IBridge.sol/IBridge.dbg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../build-info/a4921f6681a364e2d509435b886be59f.json"
}
70 changes: 70 additions & 0 deletions tools/bridge-frontend/artifacts/IBridge.sol/IBridge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "IBridge",
"sourceName": "src/bridge/IBridge.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "address",
"name": "receiver",
"type": "address"
}
],
"name": "receiveAssets",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "address",
"name": "receiver",
"type": "address"
}
],
"name": "sendERC20",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "receiver",
"type": "address"
}
],
"name": "sendNative",
"outputs": [],
"stateMutability": "payable",
"type": "function"
}
],
"bytecode": "0x",
"deployedBytecode": "0x",
"linkReferences": {},
"deployedLinkReferences": {}
}
Loading
Loading