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

feat: add network method to get user bridge transactions #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@maticnetwork/lxlyjs",
"version": "2.2.1",
"version": "2.3.0",
"description": "Javascript developer library for interacting with Polygon LxLy Bridge",
"main": "dist/lxly.node.js",
"types": "dist/ts/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions src/lxly/bridge_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class BridgeUtil {
return Promise.resolve(result);
}

private getBridgeLogData_(transactionHash: string, networkId: number, bridgeIndex = 0) {
private getBridgeLogData_(transactionHash: string, networkId: number, bridgeIndex: number = 0) {
const client = this.client_.providers[networkId].provider;
return client.getTransactionReceipt(transactionHash)
.then(receipt => {
Expand All @@ -91,7 +91,7 @@ export class BridgeUtil {
});
}

getBridgeLogData(transactionHash: string, networkId: number, bridgeIndex = 0) {
getBridgeLogData(transactionHash: string, networkId: number, bridgeIndex: number = 0) {
return this.getBridgeLogData_(transactionHash, networkId, bridgeIndex);
}

Expand All @@ -103,7 +103,7 @@ export class BridgeUtil {
}
}

buildPayloadForClaim(transactionHash: string, networkId: number, bridgeIndex = 0) {
buildPayloadForClaim(transactionHash: string, networkId: number, bridgeIndex: number = 0) {
return this.getBridgeLogData_(transactionHash, networkId, bridgeIndex).then((data: IBridgeEventInfo) => {
const {
originNetwork,
Expand Down
20 changes: 12 additions & 8 deletions src/services/network_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@ export class NetworkService {
return `${url}`;
}

getMerkleProof(networkID: number, depositCount: number) {
async getMerkleProof(networkID: number, depositCount: number) {
const url = this.createUrl(`merkle-proof?networkId=${networkID}&depositCount=${depositCount}`);
return this.httpRequest.get<any>(url).then(result => {
return result.proof;
});
const result = await this.httpRequest.get<any>(url);
return result.proof;
}

getBridgeTransactionDetails(networkID: number, depositCount: number) {
async getBridgeTransactionDetails(networkID: number, depositCount: number) {
const url = this.createUrl(`bridge?net_id=${networkID}&deposit_cnt=${depositCount}`);
return this.httpRequest.get<any>(url).then(result => {
return result.deposit;
});
const result = await this.httpRequest.get<any>(url);
return result.deposit;
}

async getUserBridgeTransactions(userAddress: string, pageIndex: number = 0) {
const url = this.createUrl(`transactions?userAddress=${userAddress}&page=${pageIndex}`);
const result = await this.httpRequest.get<any>(url);
return result.result;
}
}
4 changes: 2 additions & 2 deletions src/utils/bridge_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class BridgeClient {
* @returns
* @memberof BridgeClient
*/
isBridgeClaimable(txHash: string, sourceNetwork: number, bridgeIndex = 0) {
isBridgeClaimable(txHash: string, sourceNetwork: number, bridgeIndex: number = 0) {
return this.bridgeUtil.getBridgeLogData(
txHash, sourceNetwork, bridgeIndex
).then(result => {
Expand All @@ -42,7 +42,7 @@ export class BridgeClient {
* @returns
* @memberof BridgeClient
*/
isBridged(txHash: string, sourceNetwork: number, destinationNetwork: number, bridgeIndex = 0) {
isBridged(txHash: string, sourceNetwork: number, destinationNetwork: number, bridgeIndex: number = 0) {
return this.bridgeUtil.getBridgeLogData(
txHash, sourceNetwork, bridgeIndex
).then(result => {
Expand Down