Skip to content

Commit

Permalink
chore(bridge-ui): follow JS convention for method name (#13430)
Browse files Browse the repository at this point in the history
Co-authored-by: jeff <[email protected]>
Co-authored-by: shadab-taiko <[email protected]>
Co-authored-by: dave | d1onys1us <[email protected]>
  • Loading branch information
4 people authored Mar 27, 2023
1 parent a10d1fe commit 8ef5ce2
Show file tree
Hide file tree
Showing 19 changed files with 73 additions and 67 deletions.
10 changes: 5 additions & 5 deletions packages/bridge-ui/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@
if (store) {
const userAddress = await store.getAddress();
const apiTxs = await $relayerApi.GetAllBridgeTransactionByAddress(
const apiTxs = await $relayerApi.getAllBridgeTransactionByAddress(
userAddress,
);
const blockInfoMap = await $relayerApi.GetBlockInfo();
const blockInfoMap = await $relayerApi.getBlockInfo();
relayerBlockInfoMap.set(blockInfoMap);
const txs = await $transactioner.GetAllByAddress(userAddress);
const txs = await $transactioner.getAllByAddress(userAddress);
const hashToApiTxsMap = new Map(
apiTxs.map((tx) => {
return [tx.hash.toLowerCase(), 1];
Expand All @@ -118,11 +118,11 @@
// return true;
// });
$transactioner.UpdateStorageByAddress(userAddress, updatedStorageTxs);
$transactioner.updateStorageByAddress(userAddress, updatedStorageTxs);
transactions.set([...updatedStorageTxs, ...apiTxs]);
const tokens = $tokenService.GetTokens(userAddress);
const tokens = $tokenService.getTokens(userAddress);
userTokens.set(tokens);
}
});
Expand Down
18 changes: 9 additions & 9 deletions packages/bridge-ui/src/bridge/ERC20Bridge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const mockContract = {
};

const mockProver = {
GenerateProof: jest.fn(),
GenerateReleaseProof: jest.fn(),
generateProof: jest.fn(),
generateReleaseProof: jest.fn(),
};

jest.mock('ethers', () => ({
Expand Down Expand Up @@ -340,7 +340,7 @@ describe('bridge tests', () => {

expect(mockContract.processMessage).not.toHaveBeenCalled();

expect(mockProver.GenerateProof).not.toHaveBeenCalled();
expect(mockProver.generateProof).not.toHaveBeenCalled();

await bridge.Claim({
message: {
Expand All @@ -356,7 +356,7 @@ describe('bridge tests', () => {
signer: wallet,
});

expect(mockProver.GenerateProof).toHaveBeenCalled();
expect(mockProver.generateProof).toHaveBeenCalled();

expect(mockContract.processMessage).toHaveBeenCalled();
});
Expand All @@ -376,7 +376,7 @@ describe('bridge tests', () => {

expect(mockContract.retryMessage).not.toHaveBeenCalled();

expect(mockProver.GenerateProof).not.toHaveBeenCalled();
expect(mockProver.generateProof).not.toHaveBeenCalled();

await bridge.Claim({
message: {
Expand All @@ -392,7 +392,7 @@ describe('bridge tests', () => {
signer: wallet,
});

expect(mockProver.GenerateProof).not.toHaveBeenCalled();
expect(mockProver.generateProof).not.toHaveBeenCalled();

expect(mockContract.retryMessage).toHaveBeenCalled();
});
Expand All @@ -412,7 +412,7 @@ describe('bridge tests', () => {

expect(mockContract.releaseERC20).not.toHaveBeenCalled();

expect(mockProver.GenerateReleaseProof).not.toHaveBeenCalled();
expect(mockProver.generateReleaseProof).not.toHaveBeenCalled();

await expect(
bridge.ReleaseTokens({
Expand Down Expand Up @@ -448,7 +448,7 @@ describe('bridge tests', () => {

expect(mockContract.releaseERC20).not.toHaveBeenCalled();

expect(mockProver.GenerateReleaseProof).not.toHaveBeenCalled();
expect(mockProver.generateReleaseProof).not.toHaveBeenCalled();

await bridge.ReleaseTokens({
message: {
Expand All @@ -466,7 +466,7 @@ describe('bridge tests', () => {
srcTokenVaultAddress: '0x',
});

expect(mockProver.GenerateReleaseProof).toHaveBeenCalled();
expect(mockProver.generateReleaseProof).toHaveBeenCalled();

expect(mockContract.releaseERC20).toHaveBeenCalled();
});
Expand Down
4 changes: 2 additions & 2 deletions packages/bridge-ui/src/bridge/ERC20Bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class ERC20Bridge implements Bridge {
}

if (messageStatus === MessageStatus.New) {
const proof = await this.prover.GenerateProof({
const proof = await this.prover.generateProof({
srcChain: opts.message.srcChainId.toNumber(),
msgHash: opts.msgHash,
sender: opts.srcBridgeAddress,
Expand Down Expand Up @@ -245,7 +245,7 @@ export class ERC20Bridge implements Bridge {
chains[opts.message.srcChainId.toNumber()].headerSyncAddress,
};

const proof = await this.prover.GenerateReleaseProof(proofOpts);
const proof = await this.prover.generateReleaseProof(proofOpts);

const srcTokenVaultContract: Contract = new Contract(
opts.srcTokenVaultAddress,
Expand Down
18 changes: 9 additions & 9 deletions packages/bridge-ui/src/bridge/ETHBridge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const mockContract = {
};

const mockProver = {
GenerateProof: jest.fn(),
GenerateReleaseProof: jest.fn(),
generateProof: jest.fn(),
generateReleaseProof: jest.fn(),
};

jest.mock('ethers', () => ({
Expand Down Expand Up @@ -224,7 +224,7 @@ describe('bridge tests', () => {

expect(mockContract.processMessage).not.toHaveBeenCalled();

expect(mockProver.GenerateProof).not.toHaveBeenCalled();
expect(mockProver.generateProof).not.toHaveBeenCalled();

await bridge.Claim({
message: {
Expand All @@ -240,7 +240,7 @@ describe('bridge tests', () => {
signer: wallet,
});

expect(mockProver.GenerateProof).toHaveBeenCalled();
expect(mockProver.generateProof).toHaveBeenCalled();

expect(mockContract.processMessage).toHaveBeenCalled();
});
Expand All @@ -260,7 +260,7 @@ describe('bridge tests', () => {

expect(mockContract.retryMessage).not.toHaveBeenCalled();

expect(mockProver.GenerateProof).not.toHaveBeenCalled();
expect(mockProver.generateProof).not.toHaveBeenCalled();

await bridge.Claim({
message: {
Expand All @@ -276,7 +276,7 @@ describe('bridge tests', () => {
signer: wallet,
});

expect(mockProver.GenerateProof).not.toHaveBeenCalled();
expect(mockProver.generateProof).not.toHaveBeenCalled();

expect(mockContract.retryMessage).toHaveBeenCalled();
});
Expand All @@ -296,7 +296,7 @@ describe('bridge tests', () => {

expect(mockContract.releaseEther).not.toHaveBeenCalled();

expect(mockProver.GenerateReleaseProof).not.toHaveBeenCalled();
expect(mockProver.generateReleaseProof).not.toHaveBeenCalled();

await expect(
bridge.ReleaseTokens({
Expand Down Expand Up @@ -332,7 +332,7 @@ describe('bridge tests', () => {

expect(mockContract.releaseEther).not.toHaveBeenCalled();

expect(mockProver.GenerateReleaseProof).not.toHaveBeenCalled();
expect(mockProver.generateReleaseProof).not.toHaveBeenCalled();

await bridge.ReleaseTokens({
message: {
Expand All @@ -350,7 +350,7 @@ describe('bridge tests', () => {
srcTokenVaultAddress: '0x',
});

expect(mockProver.GenerateReleaseProof).toHaveBeenCalled();
expect(mockProver.generateReleaseProof).toHaveBeenCalled();

expect(mockContract.releaseEther).toHaveBeenCalled();
});
Expand Down
4 changes: 2 additions & 2 deletions packages/bridge-ui/src/bridge/ETHBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class ETHBridge implements Bridge {
chains[opts.message.srcChainId.toNumber()].signalServiceAddress,
};

const proof = await this.prover.GenerateProof(proofOpts);
const proof = await this.prover.generateProof(proofOpts);
let processMessageTx;
try {
processMessageTx = await contract.processMessage(opts.message, proof);
Expand Down Expand Up @@ -180,7 +180,7 @@ export class ETHBridge implements Bridge {
chains[opts.message.srcChainId.toNumber()].headerSyncAddress,
};

const proof = await this.prover.GenerateReleaseProof(proofOpts);
const proof = await this.prover.generateReleaseProof(proofOpts);

const srcBridgeContract: Contract = new Contract(
opts.srcBridgeAddress,
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge-ui/src/components/buttons/Connect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
const wagmiSigner = await setSigner();
if (wagmiSigner) {
const signerAddress = await wagmiSigner.getAddress();
const signerTransactions = await $transactioner.GetAllByAddress(
const signerTransactions = await $transactioner.getAllByAddress(
signerAddress,
);
transactions.set(signerTransactions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
logoComponent: null,
} as Token;
const updateTokensList = $tokenService.StoreToken(token, userAddress);
const updateTokensList = $tokenService.storeToken(token, userAddress);
select(token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
async function remove(token) {
const address = await $signer.getAddress();
const updatedTokensList = $tokenService.RemoveToken(token, address);
const updatedTokensList = $tokenService.removeToken(token, address);
userTokens.set(updatedTokensList);
tokenStore.set(ETHToken);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/bridge-ui/src/components/form/BridgeForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
tx.chainId = $fromChain.id;
const userAddress = await $signer.getAddress();
let transactions: BridgeTransaction[] =
await $transactioner.GetAllByAddress(userAddress);
await $transactioner.getAllByAddress(userAddress);
let bridgeTransaction: BridgeTransaction = {
fromChainId: $fromChain.id,
Expand All @@ -290,7 +290,7 @@
transactions.push(bridgeTransaction);
}
$transactioner.UpdateStorageByAddress(userAddress, transactions);
$transactioner.updateStorageByAddress(userAddress, transactions);
pendingTransactions.update((store) => {
store.push(tx);
Expand All @@ -300,7 +300,7 @@
const allTransactions = $transactionsStore;
// get full BridgeTransaction object
bridgeTransaction = await $transactioner.GetTransactionByHash(
bridgeTransaction = await $transactioner.getTransactionByHash(
userAddress,
tx.hash,
);
Expand Down
4 changes: 2 additions & 2 deletions packages/bridge-ui/src/domain/proof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ export type GenerateReleaseProofOpts = {
};

export interface Prover {
GenerateProof(opts: GenerateProofOpts): Promise<string>;
GenerateReleaseProof(opts: GenerateReleaseProofOpts): Promise<string>;
generateProof(opts: GenerateProofOpts): Promise<string>;
generateReleaseProof(opts: GenerateReleaseProofOpts): Promise<string>;
}
4 changes: 2 additions & 2 deletions packages/bridge-ui/src/domain/relayerApi.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { BridgeTransaction } from './transactions';

export interface RelayerAPI {
GetAllBridgeTransactionByAddress(
getAllBridgeTransactionByAddress(
address: string,
chainID?: number,
): Promise<BridgeTransaction[]>;

GetBlockInfo(): Promise<Map<number, RelayerBlockInfo>>;
getBlockInfo(): Promise<Map<number, RelayerBlockInfo>>;
}

export type APIResponseTransaction = {
Expand Down
6 changes: 3 additions & 3 deletions packages/bridge-ui/src/domain/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type TokenDetails = {
};

export interface TokenService {
StoreToken(token: Token, address: string): Token[];
GetTokens(address: string): Token[];
RemoveToken(token: Token, address: string): Token[];
storeToken(token: Token, address: string): Token[];
getTokens(address: string): Token[];
removeToken(token: Token, address: string): Token[];
}
12 changes: 9 additions & 3 deletions packages/bridge-ui/src/domain/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ export type BridgeTransaction = {
fromChainId: number;
toChainId: number;
};

export interface Transactioner {
GetAllByAddress(
getAllByAddress(
address: string,
chainID?: number,
): Promise<BridgeTransaction[]>;

GetTransactionByHash(
getTransactionByHash(
address: string,
hash: string,
): Promise<BridgeTransaction>;

UpdateStorageByAddress(address: string, txs: BridgeTransaction[]): void;
updateStorageByAddress(address: string, txs: BridgeTransaction[]): void;
}

export enum ReceiptStatus {
Failed = 0,
Successful = 1,
}
12 changes: 6 additions & 6 deletions packages/bridge-ui/src/proof/ProofService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('prover tests', () => {
const prover: ProofService = new ProofService(map);

await expect(
prover.GenerateProof({
prover.generateProof({
msgHash: ethers.constants.HashZero,
sender: ethers.constants.AddressZero,
srcBridgeAddress: ethers.constants.AddressZero,
Expand All @@ -167,7 +167,7 @@ describe('prover tests', () => {

const prover: ProofService = new ProofService(map);

const proof = await prover.GenerateProof({
const proof = await prover.generateProof({
msgHash: ethers.constants.HashZero,
sender: ethers.constants.AddressZero,
srcBridgeAddress: ethers.constants.AddressZero,
Expand Down Expand Up @@ -196,7 +196,7 @@ describe('prover tests', () => {

const prover: ProofService = new ProofService(map);

const proof = await prover.GenerateProof({
const proof = await prover.generateProof({
msgHash: ethers.constants.HashZero,
sender: ethers.constants.AddressZero,
srcBridgeAddress: ethers.constants.AddressZero,
Expand Down Expand Up @@ -231,7 +231,7 @@ describe('generate release proof tests', () => {
const prover: ProofService = new ProofService(map);

await expect(
prover.GenerateReleaseProof({
prover.generateReleaseProof({
msgHash: ethers.constants.HashZero,
sender: ethers.constants.AddressZero,
destBridgeAddress: ethers.constants.AddressZero,
Expand All @@ -258,7 +258,7 @@ describe('generate release proof tests', () => {

const prover: ProofService = new ProofService(map);

const proof = await prover.GenerateReleaseProof({
const proof = await prover.generateReleaseProof({
msgHash: ethers.constants.HashZero,
sender: ethers.constants.AddressZero,
destBridgeAddress: ethers.constants.AddressZero,
Expand Down Expand Up @@ -287,7 +287,7 @@ describe('generate release proof tests', () => {

const prover: ProofService = new ProofService(map);

const proof = await prover.GenerateReleaseProof({
const proof = await prover.generateReleaseProof({
msgHash: ethers.constants.HashZero,
sender: ethers.constants.AddressZero,
destBridgeAddress: ethers.constants.AddressZero,
Expand Down
Loading

0 comments on commit 8ef5ce2

Please sign in to comment.