Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
WCSPR Jsclient removed and ERC20, PAIR, FACTORY and ROUTER Jsclient c…
Browse files Browse the repository at this point in the history
…ode cleaned
  • Loading branch information
Hammad-Mubeen committed Dec 30, 2021
1 parent b394c23 commit bc9fbd8
Show file tree
Hide file tree
Showing 18 changed files with 29 additions and 1,666 deletions.
14 changes: 7 additions & 7 deletions JsClients/ERC20/src/erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class ERC20Client {
});

if (deployHash !== null) {
this.addPendingDeploy(ERC20Events.Approval, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down Expand Up @@ -264,7 +264,7 @@ class ERC20Client {
});

if (deployHash !== null) {
this.addPendingDeploy(ERC20Events.Transfer, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down Expand Up @@ -296,7 +296,7 @@ class ERC20Client {
});

if (deployHash !== null) {
this.addPendingDeploy(ERC20Events.Transfer, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down Expand Up @@ -325,7 +325,7 @@ class ERC20Client {
});

if (deployHash !== null) {
this.addPendingDeploy(ERC20Events.Transfer, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down Expand Up @@ -355,7 +355,7 @@ class ERC20Client {
// });

// if (deployHash !== null) {
// this.addPendingDeploy(ERC20Events.Transfer, deployHash);

// return deployHash;
// } else {
// throw Error("Invalid Deploy");
Expand Down Expand Up @@ -385,7 +385,7 @@ class ERC20Client {
});

if (deployHash !== null) {
this.addPendingDeploy(ERC20Events.Transfer, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down Expand Up @@ -423,7 +423,7 @@ class ERC20Client {
});

if (deployHash !== null) {
this.addPendingDeploy(ERC20Events.Approval, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down
74 changes: 0 additions & 74 deletions JsClients/ERC20/test/installed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,80 +69,6 @@ const erc20 = new ERC20Client(

const test = async () => {

// const listener = erc20.onEvent(
// [
// ERC20Events.Approval,
// ERC20Events.Transfer
// ],
// async (eventName, deploy, result) => {
// if (deploy.success) {
// console.log(`Successfull deploy of: ${eventName}, deployHash: ${deploy.deployHash}`);
// const [timestamp,gasPrice,block_hash]= await getDeploy(NODE_ADDRESS!, deploy.deployHash);
// console.log("... Deployhash: ", deploy.deployHash);
// console.log("... Timestamp: ", timestamp);
// //console.log("... GasPrice: ", gasPrice);
// console.log("... Block hash: ", block_hash);

// let newData = JSON.parse(JSON.stringify(result.value()));

// if(eventName=="approve")
// {
// console.log(eventName+ " Event result: ");
// console.log(newData[0][0].data + " = " + newData[0][1].data);
// console.log(newData[1][0].data + " = " + newData[1][1].data);
// console.log(newData[2][0].data + " = " + newData[2][1].data);
// console.log(newData[3][0].data + " = " + newData[3][1].data);
// console.log(newData[4][0].data + " = " + newData[4][1].data);
// }
// else if(eventName=="erc20_transfer")
// {
// console.log(eventName+ " Event result: ");
// console.log(newData[0][0].data + " = " + newData[0][1].data);
// console.log(newData[1][0].data + " = " + newData[1][1].data);

// console.log(newData[2][0].data + " = " + newData[2][1].data);
// console.log(newData[3][0].data + " = " + newData[3][1].data);
// console.log(newData[4][0].data + " = " + newData[4][1].data);

// var flag=0;
// var temp=(newData[3][1].data).split('(');
// console.log("temp[0]: ",temp[0]);
// if(temp[0] == "Key::Account(")
// {
// flag=1;
// }
// var from=splitdata(newData[2][1].data);
// var to=splitdata(newData[3][1].data);
// var value=parseInt(newData[4][1].data);

// console.log("from: ", from);
// console.log("to: ", to);
// console.log("value: ",value);

// if(flag==0)
// {
// request(GRAPHQL!,
// `mutation handleTransfer( $from: String!, $to: String!, $value: Int!, $pairAddress: String!, $deployHash: String!, $timeStamp: String!, $blockHash: String!){
// handleTransfer( from: $from, to: $to, value: $value, pairAddress: $pairAddress, deployHash: $deployHash, timeStamp: $timeStamp, blockHash: $blockHash) {
// result
// }

// }`,
// {from:from, to: to, value: value, pairAddress: to, deployHash:deploy.deployHash,timeStamp:timestamp.toString(), blockHash:block_hash})
// .then(data => console.log(data))
// .catch(error => console.error(error));
// }

// }

// } else {
// console.log(`Failed deploy of ${eventName}, deployHash: ${deploy.deployHash}`);
// console.log(`Error: ${deploy.error}`);
// }
// }
// );
// console.log("listener: ",listener);

await erc20.setContractHash(TOKEN1_CONTRACT!);

// // //name
Expand Down
2 changes: 1 addition & 1 deletion JsClients/FACTORY/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class FACTORYClient {
});

if (deployHash !== null) {
this.addPendingDeploy(FACTORYEvents.PairCreated, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down
49 changes: 0 additions & 49 deletions JsClients/FACTORY/test/installed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,55 +51,6 @@ function splitdata(data:string)

const test = async () => {

// const listener = factory.onEvent(
// [
// FACTORYEvents.PairCreated
// ],
// async (eventName, deploy, result) => {
// if (deploy.success) {
// console.log(`Successfull deploy of: ${eventName}, deployHash: ${deploy.deployHash}`);
// const [timestamp,block_hash]= await getDeploy(NODE_ADDRESS!, deploy.deployHash);
// console.log("... Timestamp: ", timestamp);
// console.log("... Block hash: ", block_hash);
// console.log("result.value(): ", result.value());
// let newData = JSON.parse(JSON.stringify(result.value()));

// console.log(eventName+ " Event result: ");
// console.log(newData[0][0].data + " = " + newData[0][1].data);
// console.log(newData[1][0].data + " = " + newData[1][1].data);
// console.log(newData[2][0].data + " = " + newData[2][1].data);
// console.log(newData[3][0].data + " = " + newData[3][1].data);
// console.log(newData[4][0].data + " = " + newData[4][1].data);
// console.log(newData[5][0].data + " = " + newData[5][1].data);

// var allpairslength=parseInt(newData[0][1].data);
// var pair=splitdata(newData[3][1].data);
// var token0=splitdata(newData[4][1].data);
// var token1=splitdata(newData[5][1].data);

// console.log("allpairslength: ", allpairslength);
// console.log("pair splited: ", pair);
// console.log("token0 splited: ", token0);
// console.log("token1 splited: ", token1);

// request(GRAPHQL!,
// `mutation handleNewPair( $token0: String!, $token1: String!, $pair: String!, $all_pairs_length: Int!, $timeStamp: String!, $blockHash: String!){
// handleNewPair( token0: $token0, token1: $token1, pair: $pair, all_pairs_length: $all_pairs_length, timeStamp: $timeStamp, blockHash: $blockHash) {
// result
// }

// }`,
// {token0:token0, token1:token1, pair: pair, all_pairs_length: allpairslength, timeStamp:timestamp.toString(), blockHash:block_hash})
// .then(data => console.log(data))
// .catch(error => console.error(error));

// } else {
// console.log(`Failed deploy of ${eventName}, deployHash: ${deploy.deployHash}`);
// console.log(`Error: ${deploy.error}`);
// }
// }
// );

await sleep(5 * 1000);

let accountInfo = await utils.getAccountInfo(NODE_ADDRESS!, KEYS.publicKey);
Expand Down
25 changes: 11 additions & 14 deletions JsClients/PAIR/src/pair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class PAIRClient {
});

if (deployHash !== null) {
this.addPendingDeploy(PAIREvents.Approval, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down Expand Up @@ -297,7 +297,7 @@ class PAIRClient {
});

if (deployHash !== null) {
this.addPendingDeploy(PAIREvents.Transfer, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down Expand Up @@ -329,7 +329,7 @@ class PAIRClient {
});

if (deployHash !== null) {
this.addPendingDeploy(PAIREvents.Transfer, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down Expand Up @@ -357,8 +357,7 @@ class PAIRClient {
});

if (deployHash !== null) {
this.addPendingDeploy(PAIREvents.Sync, deployHash);
this.addPendingDeploy(PAIREvents.Mint, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand All @@ -385,8 +384,7 @@ class PAIRClient {
});

if (deployHash !== null) {
this.addPendingDeploy(PAIREvents.Sync, deployHash);
this.addPendingDeploy(PAIREvents.Burn, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down Expand Up @@ -424,7 +422,7 @@ class PAIRClient {
});

if (deployHash !== null) {
this.addPendingDeploy(PAIREvents.Approval, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down Expand Up @@ -481,7 +479,7 @@ class PAIRClient {
});

if (deployHash !== null) {
this.addPendingDeploy(PAIREvents.Transfer, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down Expand Up @@ -512,7 +510,7 @@ class PAIRClient {
});

if (deployHash !== null) {
this.addPendingDeploy(PAIREvents.Transfer, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down Expand Up @@ -540,7 +538,7 @@ class PAIRClient {
});

if (deployHash !== null) {
this.addPendingDeploy(PAIREvents.Sync, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down Expand Up @@ -574,8 +572,7 @@ class PAIRClient {
});

if (deployHash !== null) {
this.addPendingDeploy(PAIREvents.Sync, deployHash);
this.addPendingDeploy(PAIREvents.Swap, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down Expand Up @@ -641,7 +638,7 @@ class PAIRClient {
});

if (deployHash !== null) {
this.addPendingDeploy(PAIREvents.Transfer, deployHash);

return deployHash;
} else {
throw Error("Invalid Deploy");
Expand Down
Loading

0 comments on commit bc9fbd8

Please sign in to comment.