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

Migration #421

Merged
merged 2 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@maticnetwork/maticjs",
"version": "3.6.7",
"version": "3.7.7",
"description": "Javascript developer library for interacting with Matic Network",
"main": "dist/npm.export.js",
"types": "dist/ts/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions src/pos/exit_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class ExitUtil {
private getRootBlockInfoFromAPI(txBlockNumber: number) {
this.maticClient_.logger.log("block info from API 1");
return service.network.getBlockIncluded(
this.config.network,
this.config.version,
txBlockNumber
).then(headerBlock => {
this.maticClient_.logger.log("block info from API 2", headerBlock);
Expand All @@ -203,7 +203,7 @@ export class ExitUtil {
private getBlockProofFromAPI(txBlockNumber: number, rootBlockInfo: { start, end }) {

return service.network.getProof(
this.config.network,
this.config.version,
rootBlockInfo.start,
rootBlockInfo.end,
txBlockNumber
Expand All @@ -221,7 +221,7 @@ export class ExitUtil {
private getExitProofFromAPI(burnHash: string, eventSignature: string) {

return service.network.getExitProof(
this.config.network, burnHash, eventSignature
this.config.version, burnHash, eventSignature
).then(exitProof => {
if (!exitProof) {
throw Error('Network API Error');
Expand Down
28 changes: 14 additions & 14 deletions src/services/network_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ export class NetworkService {
this.httpRequest = new HttpRequest(baseUrl);
}

private createUrlForPos(network: string, url: string) {
return `${network === 'mainnet' ? 'matic' : 'mumbai'}${url}`;
private createUrlForPos(version: string, url: string) {
return `${version === 'v1' ? 'matic' : version}${url}`;
}

private createUrlForZkEvm(network: string, url: string) {
return `${network}/${url}`;
private createUrlForZkEvm(version: string, url: string) {
return `${version}/${url}`;
}

getBlockIncluded(network: string, blockNumber: number) {
const url = this.createUrlForPos(network, `/block-included/${blockNumber}`);
getBlockIncluded(version: string, blockNumber: number) {
const url = this.createUrlForPos(version, `/block-included/${blockNumber}`);
return this.httpRequest.get<{
start: string;
end: string;
Expand All @@ -32,29 +32,29 @@ export class NetworkService {
});
}

getExitProof(network: string, burnTxHash: string, eventSignature:string) {
const url = this.createUrlForPos(network, `/exit-payload/${burnTxHash}?eventSignature=${eventSignature}`);
getExitProof(version: string, burnTxHash: string, eventSignature: string) {
const url = this.createUrlForPos(version, `/exit-payload/${burnTxHash}?eventSignature=${eventSignature}`);
return this.httpRequest.get<any>(url).then(result => {
return result.result;
});
}

getProof(network: string, start, end, blockNumber) {
const url = this.createUrlForPos(network, `/fast-merkle-proof?start=${start}&end=${end}&number=${blockNumber}`);
getProof(version: string, start, end, blockNumber) {
const url = this.createUrlForPos(version, `/fast-merkle-proof?start=${start}&end=${end}&number=${blockNumber}`);
return this.httpRequest.get<any>(url).then(result => {
return result.proof;
});
}

getMerkleProofForZkEvm(network: string, networkID: number, depositCount: number) {
const url = this.createUrlForZkEvm(network, `merkle-proof?net_id=${networkID}&deposit_cnt=${depositCount}`);
getMerkleProofForZkEvm(version: string, networkID: number, depositCount: number) {
const url = this.createUrlForZkEvm(version, `merkle-proof?net_id=${networkID}&deposit_cnt=${depositCount}`);
return this.httpRequest.get<any>(url).then(result => {
return result.proof;
});
}

getBridgeTransactionDetails(network: string, networkID: number, depositCount: number) {
const url = this.createUrlForZkEvm(network, `bridge?net_id=${networkID}&deposit_cnt=${depositCount}`);
getBridgeTransactionDetails(version: string, networkID: number, depositCount: number) {
const url = this.createUrlForZkEvm(version, `bridge?net_id=${networkID}&deposit_cnt=${depositCount}`);
return this.httpRequest.get<any>(url).then(result => {
return result.deposit;
});
Expand Down
3 changes: 3 additions & 0 deletions src/utils/web3_side_chain_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import { utils } from "..";
const chainIdToConfigPath = {
1: 'Main',
5: 'Main',
11155111: 'Main',
137: 'Matic',
80001: 'Matic',
80002: 'Matic',
1442: 'zkEVM',
2442: 'zkEVM',
1101: 'zkEVM'
};

Expand Down
5 changes: 2 additions & 3 deletions src/utils/zkevm_bridge_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export class ZkEvmBridgeClient {
rootChainBridge: ZkEvmBridge;
childChainBridge: ZkEvmBridge;


/**
* check whether a txHash is synced with child chain
*
Expand All @@ -23,7 +22,7 @@ export class ZkEvmBridgeClient {
txHash, true
)]).then(result => {
return service.zkEvmNetwork.getBridgeTransactionDetails(
this.client.config.network,
this.client.config.version,
result[0],
result[1].depositCount
);
Expand All @@ -44,7 +43,7 @@ export class ZkEvmBridgeClient {
txHash, false
)]).then(result => {
return service.zkEvmNetwork.getBridgeTransactionDetails(
this.client.config.network,
this.client.config.version,
result[0],
result[1].depositCount
);
Expand Down
2 changes: 1 addition & 1 deletion src/zkevm/bridge_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class BridgeUtil {

private getProof_(networkId: number, depositCount: number) {
return service.zkEvmNetwork.getMerkleProofForZkEvm(
this.client_.config.network,
this.client_.config.version,
networkId,
depositCount,
).then(proof => {
Expand Down
Loading