From 2b054fe5b670a543b627041f809b1139e59eb140 Mon Sep 17 00:00:00 2001 From: Hammad-Mubeen Date: Wed, 15 Dec 2021 02:23:34 +0500 Subject: [PATCH] listener removed from router, listener, webhook and addpaircontractandpackagehash code added --- .env | 34 +- JsClients/ERC20/keys/public_key.pem | 2 +- JsClients/ERC20/keys/public_key_hex | 2 +- JsClients/ERC20/keys/secret_key.pem | 2 +- JsClients/ERC20/test/installed.ts | 171 ++-- JsClients/FACTORY/keys/public_key.pem | 2 +- JsClients/FACTORY/keys/public_key_hex | 2 +- JsClients/FACTORY/keys/secret_key.pem | 2 +- JsClients/PAIR/keys/public_key.pem | 2 +- JsClients/PAIR/keys/public_key_hex | 2 +- JsClients/PAIR/keys/secret_key.pem | 2 +- JsClients/PAIR/src/constants.ts | 1 + JsClients/PAIR/test/installed.ts | 52 +- JsClients/ROUTER/dist/constants.js | 24 - JsClients/ROUTER/dist/constants.js.map | 1 - JsClients/ROUTER/dist/index.js | 32 - JsClients/ROUTER/dist/index.js.map | 1 - .../ROUTER/dist/uniswap-router-client.js | 959 ------------------ .../ROUTER/dist/uniswap-router-client.js.map | 1 - JsClients/ROUTER/dist/utils.js | 177 ---- JsClients/ROUTER/dist/utils.js.map | 1 - JsClients/ROUTER/keys/public_key.pem | 2 +- JsClients/ROUTER/keys/public_key_hex | 2 +- JsClients/ROUTER/keys/secret_key.pem | 2 +- JsClients/ROUTER/src/uniswap-router-client.ts | 3 - JsClients/ROUTER/test/installed.ts | 439 +------- app.js | 2 + models/pairs.js | 12 + package-lock.json | 73 +- package.json | 2 +- routes/listenerroutes.js | 423 ++++++++ test.js | 6 +- 32 files changed, 671 insertions(+), 1767 deletions(-) delete mode 100644 JsClients/ROUTER/dist/constants.js delete mode 100644 JsClients/ROUTER/dist/constants.js.map delete mode 100644 JsClients/ROUTER/dist/index.js delete mode 100644 JsClients/ROUTER/dist/index.js.map delete mode 100644 JsClients/ROUTER/dist/uniswap-router-client.js delete mode 100644 JsClients/ROUTER/dist/uniswap-router-client.js.map delete mode 100644 JsClients/ROUTER/dist/utils.js delete mode 100644 JsClients/ROUTER/dist/utils.js.map create mode 100644 models/pairs.js create mode 100644 routes/listenerroutes.js diff --git a/.env b/.env index dfb245a8..2eef41ad 100644 --- a/.env +++ b/.env @@ -2,19 +2,19 @@ NODE_MODE=deployed DATABASE_URL_LOCAL=mongodb://localhost:27017/V2-graphQL DATABASE_URL_ONLINE=mongodb+srv://admin:scytalelabs@cluster0-9yop5.mongodb.net/V2-graphQL-backend-demo?retryWrites=true&w=majority -FACTORY_CONTRACT=46505F2A814CC8Ee77E963a9dB101bEE4C9f96b47acAD65eE1084588b3e8e822 -PAIR_CONTRACT=83c4d036f0912794cfb5896210298E6E9F228BE41626ddcf74583D16a26D7eD6 -PAIR_CONTRACT_PACKAGE=984C671dF3c19563B760AF45586e913ab3C3C649BD8AFddbfd60807325803EAD +FACTORY_CONTRACT=BE48B5C9cfb0901A57db92fCB1b97d31Bfe536439efdC54a94f4C8bd1508Fc3C +PAIR_CONTRACT=Cfc208B9cd2fb35918D621D4002e378579382131d9D3011ff5A47aF36e603b2F +PAIR_CONTRACT_PACKAGE=1A89d4cDC6735c6c68D206b1C6c5c5c62ED96954F893A028Fa33E54C556B99AB CALLEE_CONTRACT=fbfeda8b97f056f526f20c2fc2b486d9bdbfb3e46b9a164527e57c0c86e68612 -TOKEN0_CONTRACT=7387033a0A3619caf217d8dF5E78D0814Fe6e3fa5Bd5DCfCe98C201851a97725 -TOKEN0_CONTRACT_PACKAGE=03356D719373cB3E5A83c10548fED58919E7B4AFF23C7449d97b17e89d7D8727 -TOKEN1_CONTRACT=f2dF436817e881ca2D9e945FD62680C546591A6ecb4E3b9Ec05E6e4BC2385B23 -TOKEN1_CONTRACT_PACKAGE=6c2Fe8b6728Ce1C0320bF92867236e9d94aC41FD6997492B25422e4baa0E3c3f +TOKEN0_CONTRACT=E3F80775fddda7872185705BAAcc07aae66cFa5a07D5445D64D0C01642428D2d +TOKEN0_CONTRACT_PACKAGE=De0Ea05d65072DE515d6400f3Cf0FD2169A45938902C56B109BBAe62c4677955 +TOKEN1_CONTRACT=f3c553Bed5D57B87FB1e7fDe02eC2a0355d64c0faD2fE872cB6DcC115197c1fe +TOKEN1_CONTRACT_PACKAGE=555282981d63c7fD7b66A4cDd747Ee30f9cdfC024b3bd2d918314e8b9A25b25C GRAPHQL=http://localhost:3000/graphql CHAIN_NAME=casper-test -NODE_ADDRESS=http://65.21.237.153:7777/rpc -EVENT_STREAM_ADDRESS=http://65.21.237.153:9999/events/main +NODE_ADDRESS=http://159.65.118.250:7777/rpc +EVENT_STREAM_ADDRESS=http://159.65.118.250:9999/events/main RECEIVER_ACCOUNT_ONE=017e82abcc9539a01cfd9d63ae8c9c8b3a752a6f75ba1ab148714eea03e9be69a7 ERC20_WASM_PATH=JsClients/ERC20/wasm/erc20-token.wasm @@ -43,7 +43,7 @@ FACTORY_CONTRACT_NAME=Factory ERC20_INSTALL_PAYMENT_AMOUNT=200000000000 FACTORY_INSTALL_PAYMENT_AMOUNT=110000000000 -PAIR_INSTALL_PAYMENT_AMOUNT=350000000000 +PAIR_INSTALL_PAYMENT_AMOUNT=250000000000 MINT_PAYMENT_AMOUNT=5000000000 MINT_AMOUNT=2000 @@ -80,13 +80,13 @@ TOKEN_NAME=uniswap-router TOKEN_SYMBOL=DRAG TOKEN_META=origin fire,lifetime infinite -FACTORY=46505F2A814CC8Ee77E963a9dB101bEE4C9f96b47acAD65eE1084588b3e8e822 +FACTORY=BE48B5C9cfb0901A57db92fCB1b97d31Bfe536439efdC54a94f4C8bd1508Fc3C WCSPR=bA8f6a73B6D548E2CAe2d572aA2F824BC46A3C06a3BBA10e3d12B015931D3f85 LIBRARY=e0Dae7571C3dc5C957a36422c56BA0ccb8AECEC833F35e32874b75A8Ea8Ac4Db CONTRACT_NAME=UniSwapRouter -CONTRACT_HASH=58e35630F1ef3797C28dc93a8e6Fb3F5980154e4793ee142D47eE95Cd48Feb62 -PACKAGE_HASH=3b401aAfC1CCd3707DEaB6B39a3Bb42670487130c9EAB0b5BaCb2248900A88CA +CONTRACT_HASH=10c1405f84E629D0678620BaFCbaf0EDdE598e8717007B33A401458224c46dE7 +PACKAGE_HASH=C8B976d8d1e122B1baEc32dd06c9DAA89f5277C1eB11ADd2414a23a273741258 INSTALL_PAYMENT_AMOUNT=200000000000 MINT_ONE_PAYMENT_AMOUNT=2000000000 MINT_COPIES_PAYMENT_AMOUNT=100000000000 @@ -97,12 +97,12 @@ MINT_COPIES_COUNT=20 MINT_MANY_META_SIZE=5 MINT_MANY_META_COUNT=5 -TO = 7387033a0A3619caf217d8dF5E78D0814Fe6e3fa5Bd5DCfCe98C201851a97725 -DEADLINE = 1699140435324 +TO = E3F80775fddda7872185705BAAcc07aae66cFa5a07D5445D64D0C01642428D2d +DEADLINE = 1639403428465 # add_liquidity -TOKEN_A = 7387033a0A3619caf217d8dF5E78D0814Fe6e3fa5Bd5DCfCe98C201851a97725 -TOKEN_B = f2dF436817e881ca2D9e945FD62680C546591A6ecb4E3b9Ec05E6e4BC2385B23 +TOKEN_A = E3F80775fddda7872185705BAAcc07aae66cFa5a07D5445D64D0C01642428D2d +TOKEN_B = f3c553Bed5D57B87FB1e7fDe02eC2a0355d64c0faD2fE872cB6DcC115197c1fe AMOUNT_A_DESIRED = 500 AMOUNT_B_DESIRED = 600 AMOUNT_A_MIN = 250 diff --git a/JsClients/ERC20/keys/public_key.pem b/JsClients/ERC20/keys/public_key.pem index f7d405dd..82ad859f 100644 --- a/JsClients/ERC20/keys/public_key.pem +++ b/JsClients/ERC20/keys/public_key.pem @@ -1,3 +1,3 @@ -----BEGIN PUBLIC KEY----- -MCowBQYDK2VwAyEA+Gwj5LQ3PmnfmVjkxFcmZnD6FktIUMI0JRu823ZRpnE= +MCowBQYDK2VwAyEAs0KvzrC+3c3b48+M5hiTCBzTc1HVJZtYE+7n/r9r+dU= -----END PUBLIC KEY----- diff --git a/JsClients/ERC20/keys/public_key_hex b/JsClients/ERC20/keys/public_key_hex index ae3c3a30..a4a43f97 100644 --- a/JsClients/ERC20/keys/public_key_hex +++ b/JsClients/ERC20/keys/public_key_hex @@ -1 +1 @@ -01f86c23e4b4373e69df9958e4c457266670fa164b4850c234251bbcdb7651a671 \ No newline at end of file +01b342afceb0beddcddbe3cf8ce61893081cd37351d5259b5813eee7febf6bf9d5 \ No newline at end of file diff --git a/JsClients/ERC20/keys/secret_key.pem b/JsClients/ERC20/keys/secret_key.pem index 0df3c5ed..7115f864 100644 --- a/JsClients/ERC20/keys/secret_key.pem +++ b/JsClients/ERC20/keys/secret_key.pem @@ -1,3 +1,3 @@ -----BEGIN PRIVATE KEY----- -MC4CAQAwBQYDK2VwBCIEILXBMhV7E1w2R3bgTAbiYmAju2yKUF5ZUuS2I0moHO2I +MC4CAQAwBQYDK2VwBCIEIEAEVlLDzYh9hwBwLu3H2fsQVUrEZKJs+UblNZ9N0WhS -----END PRIVATE KEY----- diff --git a/JsClients/ERC20/test/installed.ts b/JsClients/ERC20/test/installed.ts index 56c8c2b0..23d1036c 100644 --- a/JsClients/ERC20/test/installed.ts +++ b/JsClients/ERC20/test/installed.ts @@ -2,7 +2,8 @@ import { config } from "dotenv"; config(); import { ERC20Client ,utils, constants} from "../src"; import { sleep, getDeploy } from "./utils"; -//import { ERC20Events } from '../src/constants'; +import { request } from 'graphql-request'; + import { CLValueBuilder, Keys, @@ -38,7 +39,8 @@ const { AMOUNT_A_DESIRED, AMOUNT_B_DESIRED, MASTER_KEY_PAIR_PATH, - PAIR_CONTRACT_PACKAGE + PAIR_CONTRACT_PACKAGE, + GRAPHQL } = process.env; @@ -52,6 +54,13 @@ const ROUTERKEYS = Keys.Ed25519.parseKeyFiles( `${MASTER_KEY_PAIR_PATH}/secret_key.pem` ); +function splitdata(data:string) +{ + var temp=data.split('('); + var result=temp[1].split(')'); + return result[0]; +} + const erc20 = new ERC20Client( NODE_ADDRESS!, CHAIN_NAME!, @@ -59,54 +68,81 @@ 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())); - - 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 { - console.log(`Failed deploy of ${eventName}, deployHash: ${deploy.deployHash}`); - console.log(`Error: ${deploy.error}`); - } - } - ); - console.log("listener: ",listener); - - await sleep(5 * 1000); - - let accountInfo = await utils.getAccountInfo(NODE_ADDRESS!, KEYS.publicKey); - console.log(`... Account Info: `); - console.log(JSON.stringify(accountInfo, null, 2)); - - const contractHash = await utils.getAccountNamedKeyValue( - accountInfo, - `${ERC20_CONTRACT_NAME!}_contract_hash` - ); - - console.log(`... Contract Hash: ${contractHash}`); + // 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); - // // We don't need hash- prefix so i'm removing it - //await erc20.setContractHash(contractHash.slice(5)); await erc20.setContractHash(TOKEN1_CONTRACT!); // // //name @@ -139,18 +175,18 @@ const test = async () => { // // // console.log(`... Allowance: ${allowance}`); //mint - // const mintDeployHash = await erc20.mint( - // ROUTERKEYS, - // ROUTERKEYS.publicKey, - // MINT_AMOUNT!, - // MINT_PAYMENT_AMOUNT! - // ); - // console.log("... Mint deploy hash: ", mintDeployHash); + const mintDeployHash = await erc20.mint( + ROUTERKEYS, + ROUTERKEYS.publicKey, + MINT_AMOUNT!, + MINT_PAYMENT_AMOUNT! + ); + console.log("... Mint deploy hash: ", mintDeployHash); - // await getDeploy(NODE_ADDRESS!, mintDeployHash); - // console.log("... Token minted successfully."); + await getDeploy(NODE_ADDRESS!, mintDeployHash); + console.log("... Token minted successfully."); - //balanceof + // balanceof // let balance = await erc20.balanceOfcontract(PAIR_CONTRACT!); // console.log(`... Balance: ${balance}`); @@ -171,16 +207,16 @@ const test = async () => { // // console.log(`... Total supply: ${totalSupply}`); //approve - const approveDeployHash = await erc20.approve( - ROUTERKEYS, - PACKAGE_HASH!, - AMOUNT_B_DESIRED!, - APPROVE_PAYMENT_AMOUNT! - ); - console.log("... Approve deploy hash: ", approveDeployHash); + // const approveDeployHash = await erc20.approve( + // ROUTERKEYS, + // PACKAGE_HASH!, + // AMOUNT_A_DESIRED!, + // APPROVE_PAYMENT_AMOUNT! + // ); + // console.log("... Approve deploy hash: ", approveDeployHash); - await getDeploy(NODE_ADDRESS!, approveDeployHash); - console.log("... Token approved successfully"); + // await getDeploy(NODE_ADDRESS!, approveDeployHash); + // console.log("... Token approved successfully"); // // //transfer // // const transferDeployHash = await erc20.transfer( @@ -209,6 +245,7 @@ const test = async () => { }; + test(); export const getName = async (contractHash:string) => { diff --git a/JsClients/FACTORY/keys/public_key.pem b/JsClients/FACTORY/keys/public_key.pem index 72ba8185..75fb062f 100644 --- a/JsClients/FACTORY/keys/public_key.pem +++ b/JsClients/FACTORY/keys/public_key.pem @@ -1,3 +1,3 @@ -----BEGIN PUBLIC KEY----- -MCowBQYDK2VwAyEATkKacKRbXO7m8cL0EqIk1eo8YV9QRtdhhKIATP8NkEY= +MCowBQYDK2VwAyEA4Uucv/tdlBPn+RuHu0L5ihGGJlO2MwC85wbbjmCC1so= -----END PUBLIC KEY----- diff --git a/JsClients/FACTORY/keys/public_key_hex b/JsClients/FACTORY/keys/public_key_hex index c1bb7241..22ca4807 100644 --- a/JsClients/FACTORY/keys/public_key_hex +++ b/JsClients/FACTORY/keys/public_key_hex @@ -1 +1 @@ -014e429a70a45b5ceee6f1c2f412a224d5ea3c615f5046d76184a2004cff0d9046 \ No newline at end of file +01e14b9cbffb5d9413e7f91b87bb42f98a11862653b63300bce706db8e6082d6ca \ No newline at end of file diff --git a/JsClients/FACTORY/keys/secret_key.pem b/JsClients/FACTORY/keys/secret_key.pem index 797870b2..846426d7 100644 --- a/JsClients/FACTORY/keys/secret_key.pem +++ b/JsClients/FACTORY/keys/secret_key.pem @@ -1,3 +1,3 @@ -----BEGIN PRIVATE KEY----- -MC4CAQAwBQYDK2VwBCIEIN9+mOCy+hYO+yItDcRuHawnIUKq+HvOml4qExk8ITfT +MC4CAQAwBQYDK2VwBCIEIBptGPvy3geNeR1+Ses6LnNP9+dYYRtSy9I2jnr2N+V7 -----END PRIVATE KEY----- diff --git a/JsClients/PAIR/keys/public_key.pem b/JsClients/PAIR/keys/public_key.pem index 1b0a23f4..3a73e3ff 100644 --- a/JsClients/PAIR/keys/public_key.pem +++ b/JsClients/PAIR/keys/public_key.pem @@ -1,3 +1,3 @@ -----BEGIN PUBLIC KEY----- -MCowBQYDK2VwAyEAMfyQQNEYSp6VQcd9N2GpRmGcx+1+Wl6myTehyxbCLP4= +MCowBQYDK2VwAyEAWCo4o5U2zNgRQan9mjlKj0AfjdVcyN1tigR0wnRMPTs= -----END PUBLIC KEY----- diff --git a/JsClients/PAIR/keys/public_key_hex b/JsClients/PAIR/keys/public_key_hex index 553e3132..b6701a0f 100644 --- a/JsClients/PAIR/keys/public_key_hex +++ b/JsClients/PAIR/keys/public_key_hex @@ -1 +1 @@ -0131fc9040d1184a9e9541c77d3761a946619cc7ed7e5a5ea6c937a1cb16c22cfe \ No newline at end of file +01582a38a39536ccd81141a9fd9a394a8f401f8dd55cc8dd6d8a0474c2744c3d3b \ No newline at end of file diff --git a/JsClients/PAIR/keys/secret_key.pem b/JsClients/PAIR/keys/secret_key.pem index bc1e2856..c8ad94bd 100644 --- a/JsClients/PAIR/keys/secret_key.pem +++ b/JsClients/PAIR/keys/secret_key.pem @@ -1,3 +1,3 @@ -----BEGIN PRIVATE KEY----- -MC4CAQAwBQYDK2VwBCIEIO4zMC4Rx+Mnh5sCLc0E5jhAhLZDPmHN1JDC0NGTD8ti +MC4CAQAwBQYDK2VwBCIEIFCrU4+IUFtE+Clin5T6gCH05T11RteCOhbzNRzezBl9 -----END PRIVATE KEY----- diff --git a/JsClients/PAIR/src/constants.ts b/JsClients/PAIR/src/constants.ts index 188a6e6d..fda55428 100644 --- a/JsClients/PAIR/src/constants.ts +++ b/JsClients/PAIR/src/constants.ts @@ -1,6 +1,7 @@ export enum PAIREvents { Approval = 'approve', Transfer = 'transfer', + Erc20Transfer = 'erc20_transfer', Mint = 'mint', Burn = 'burn', Sync = 'sync', diff --git a/JsClients/PAIR/test/installed.ts b/JsClients/PAIR/test/installed.ts index 24e48ce5..e7889405 100644 --- a/JsClients/PAIR/test/installed.ts +++ b/JsClients/PAIR/test/installed.ts @@ -80,8 +80,56 @@ const test = async () => { console.log("... Block hash: ", block_hash); console.log("result.value(): ",result.value()); let newData = JSON.parse(JSON.stringify(result.value())); - - if(eventName=="transfer") + 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 if(eventName=="transfer") { console.log(eventName+ " Event result: "); console.log(newData[0][0].data + " = " + newData[0][1].data); diff --git a/JsClients/ROUTER/dist/constants.js b/JsClients/ROUTER/dist/constants.js deleted file mode 100644 index cb0d16e5..00000000 --- a/JsClients/ROUTER/dist/constants.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.RouterEvents = void 0; -var RouterEvents; -(function (RouterEvents) { - RouterEvents["AddLiquidity"] = "uniswap_router_add_liquidity"; - RouterEvents["AddLiquidityCSPR"] = "uniswap_router_add_liquidity_cspr"; - RouterEvents["RemoveLiquidity"] = "uniswap_router_remove_liquidity"; - RouterEvents["RemoveLiquidityCSPR"] = "uniswap_router_remove_liquidity_cspr"; - RouterEvents["RemoveLiquidityWithPermit"] = "uniswap_router_remove_liquidity_with_permit"; - RouterEvents["RemoveLiquidityCSPRWithPermit"] = "uniswap_router_remove_liquidity_cspr_with_permit"; - RouterEvents["SwapExactTokensForTokens"] = "swap_exact_tokens_for_tokens"; - RouterEvents["SwapTokensForExactTokens"] = "swap_tokens_for_exact_tokens"; - RouterEvents["SwapExactCSPRForTokens"] = "swap_exact_cspr_for_tokens"; - RouterEvents["SwapTokensForExactCSPR"] = "swap_tokens_for_exact_cspr"; - RouterEvents["SwapExactTokensForCSPR"] = "swap_exact_cspr_for_tokens"; - RouterEvents["SwapCSPRForExactTokens"] = "swap_tokens_for_exact_cspr"; - RouterEvents["Quote"] = "quote"; - RouterEvents["GetAmountOut"] = "get_amount_out"; - RouterEvents["GetAmountIn"] = "get_amount_in"; - RouterEvents["GetAmountsOut"] = "get_amounts_out"; - RouterEvents["GetAmountsIn"] = "get_amounts_in"; -})(RouterEvents = exports.RouterEvents || (exports.RouterEvents = {})); -//# sourceMappingURL=constants.js.map \ No newline at end of file diff --git a/JsClients/ROUTER/dist/constants.js.map b/JsClients/ROUTER/dist/constants.js.map deleted file mode 100644 index 3cfad295..00000000 --- a/JsClients/ROUTER/dist/constants.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,YAkBX;AAlBD,WAAY,YAAY;IACtB,6DAA6C,CAAA;IAC7C,sEAAsD,CAAA;IACtD,mEAAmD,CAAA;IACnD,4EAA4D,CAAA;IAC5D,yFAAyE,CAAA;IACzE,kGAAkF,CAAA;IAClF,yEAAyD,CAAA;IACzD,yEAAyD,CAAA;IACzD,qEAAqD,CAAA;IACrD,qEAAqD,CAAA;IACrD,qEAAqD,CAAA;IACrD,qEAAqD,CAAA;IACrD,+BAAe,CAAA;IACf,+CAA+B,CAAA;IAC/B,6CAA6B,CAAA;IAC7B,iDAAiC,CAAA;IACjC,+CAA+B,CAAA;AACjC,CAAC,EAlBW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAkBvB"} \ No newline at end of file diff --git a/JsClients/ROUTER/dist/index.js b/JsClients/ROUTER/dist/index.js deleted file mode 100644 index 5676f11a..00000000 --- a/JsClients/ROUTER/dist/index.js +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.constants = exports.utils = exports.UniswapRouterClient = void 0; -var uniswap_router_client_1 = __importDefault(require("./uniswap-router-client")); -exports.UniswapRouterClient = uniswap_router_client_1.default; -var utils = __importStar(require("./utils")); -exports.utils = utils; -var constants = __importStar(require("./constants")); -exports.constants = constants; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/JsClients/ROUTER/dist/index.js.map b/JsClients/ROUTER/dist/index.js.map deleted file mode 100644 index 0d0e9cd0..00000000 --- a/JsClients/ROUTER/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kFAA0D;AAKtD,8BALG,+BAAmB,CAKH;AAJvB,6CAAiC;AAK7B,sBAAK;AAJT,qDAAyC;AAKrC,8BAAS"} \ No newline at end of file diff --git a/JsClients/ROUTER/dist/uniswap-router-client.js b/JsClients/ROUTER/dist/uniswap-router-client.js deleted file mode 100644 index c516640b..00000000 --- a/JsClients/ROUTER/dist/uniswap-router-client.js +++ /dev/null @@ -1,959 +0,0 @@ -"use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var casper_js_sdk_1 = require("casper-js-sdk"); -var constants_1 = require("./constants"); -var utils = __importStar(require("./utils")); -var UniswapRouterClient = /** @class */ (function () { - function UniswapRouterClient(nodeAddress, chainName, eventStreamAddress) { - this.nodeAddress = nodeAddress; - this.chainName = chainName; - this.eventStreamAddress = eventStreamAddress; - this.contractName = "uniswap_router"; - this.isListening = false; - this.pendingDeploys = []; - } - UniswapRouterClient.prototype.install = function (keys, // Have Public/Private Key Pair - tokenName, factory, libraryHash, paymentAmount, wasmPath) { - return __awaiter(this, void 0, void 0, function () { - var runtimeArgs, deployHash; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - this.contractHash; - runtimeArgs = casper_js_sdk_1.RuntimeArgs.fromMap({ - token_name: casper_js_sdk_1.CLValueBuilder.string(tokenName), - _factory: casper_js_sdk_1.CLValueBuilder.string(factory), - library_hash: casper_js_sdk_1.CLValueBuilder.string(libraryHash), - }); - return [4 /*yield*/, installWasmFile({ - chainName: this.chainName, - paymentAmount: paymentAmount, - nodeAddress: this.nodeAddress, - keys: keys, - pathToContract: wasmPath, - runtimeArgs: runtimeArgs, - })]; - case 1: - deployHash = _a.sent(); - if (deployHash !== null) { - return [2 /*return*/, deployHash]; - } - else { - throw Error("Problem with installation"); - } - return [2 /*return*/]; - } - }); - }); - }; - UniswapRouterClient.prototype.setContractHash = function (hash) { - return __awaiter(this, void 0, void 0, function () { - var stateRootHash, contractData, _a, contractPackageHash, namedKeys, LIST_OF_NAMED_KEYS; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, utils.getStateRootHash(this.nodeAddress)]; - case 1: - stateRootHash = _b.sent(); - return [4 /*yield*/, utils.getContractData(this.nodeAddress, stateRootHash, hash)]; - case 2: - contractData = _b.sent(); - _a = contractData.Contract, contractPackageHash = _a.contractPackageHash, namedKeys = _a.namedKeys; - this.contractHash = hash; - this.contractPackageHash = contractPackageHash.replace("contract-package-wasm", ""); - LIST_OF_NAMED_KEYS = [ - this.contractName + "_package_hash", - this.contractName + "_package_hash_wrapped", - this.contractName + "_contract_hash", - this.contractName + "_contract_hash_wrapped", - this.contractName + "_package_access_token", - ]; - // @ts-ignore - this.namedKeys = namedKeys.reduce(function (acc, val) { - var _a; - if (LIST_OF_NAMED_KEYS.includes(val.name)) { - return __assign(__assign({}, acc), (_a = {}, _a[utils.camelCased(val.name)] = val.key, _a)); - } - return acc; - }, {}); - return [2 /*return*/]; - } - }); - }); - }; - UniswapRouterClient.prototype.add_liquidity = function (keys, token_a, token_b, amount_a_desired, // using string instead of 'number' because number is 64 bit in TS, we need 256 bits - amount_b_desired, amount_a_min, amount_b_min, to, deadline, paymentAmount) { - return __awaiter(this, void 0, void 0, function () { - var runtimeArgs, deployHash; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - runtimeArgs = casper_js_sdk_1.RuntimeArgs.fromMap({ - token_a: utils.createRecipientAddress(token_a), - token_b: utils.createRecipientAddress(token_b), - amount_a_desired: casper_js_sdk_1.CLValueBuilder.u256(amount_a_desired), - amount_b_desired: casper_js_sdk_1.CLValueBuilder.u256(amount_b_desired), - amount_a_min: casper_js_sdk_1.CLValueBuilder.u256(amount_a_min), - amount_b_min: casper_js_sdk_1.CLValueBuilder.u256(amount_b_min), - to: utils.createRecipientAddress(to), - deadline: casper_js_sdk_1.CLValueBuilder.u256(deadline) - }); - return [4 /*yield*/, contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "add_liquidity", - keys: keys, - nodeAddress: this.nodeAddress, - paymentAmount: paymentAmount, - runtimeArgs: runtimeArgs, - })]; - case 1: - deployHash = _a.sent(); - if (deployHash !== null) { - this.addPendingDeploy(constants_1.RouterEvents.AddLiquidity, deployHash); - return [2 /*return*/, deployHash]; - } - else { - throw Error("Invalid Deploy"); - } - return [2 /*return*/]; - } - }); - }); - }; - UniswapRouterClient.prototype.add_liquidity_cspr = function (keys, token, amount_token_desired, amount_cspr_desired, amount_token_min, amount_cspr_min, to, deadline, paymentAmount) { - return __awaiter(this, void 0, void 0, function () { - var runtimeArgs, deployHash; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - runtimeArgs = casper_js_sdk_1.RuntimeArgs.fromMap({ - token: utils.createRecipientAddress(token), - amount_token_desired: casper_js_sdk_1.CLValueBuilder.u256(amount_token_desired), - amount_cspr_desired: casper_js_sdk_1.CLValueBuilder.u256(amount_cspr_desired), - amount_token_min: casper_js_sdk_1.CLValueBuilder.u256(amount_token_min), - amount_cspr_min: casper_js_sdk_1.CLValueBuilder.u256(amount_cspr_min), - to: utils.createRecipientAddress(to), - deadline: casper_js_sdk_1.CLValueBuilder.u256(deadline) - }); - return [4 /*yield*/, contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "add_liquidity_cspr", - keys: keys, - nodeAddress: this.nodeAddress, - paymentAmount: paymentAmount, - runtimeArgs: runtimeArgs, - })]; - case 1: - deployHash = _a.sent(); - if (deployHash !== null) { - this.addPendingDeploy(constants_1.RouterEvents.AddLiquidityCSPR, deployHash); - return [2 /*return*/, deployHash]; - } - else { - throw Error("Invalid Deploy"); - } - return [2 /*return*/]; - } - }); - }); - }; - UniswapRouterClient.prototype.remove_liquidity = function (keys, token_a, token_b, liquidity, amount_a_min, amount_b_min, to, deadline, paymentAmount) { - return __awaiter(this, void 0, void 0, function () { - var runtimeArgs, deployHash; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - runtimeArgs = casper_js_sdk_1.RuntimeArgs.fromMap({ - token_a: utils.createRecipientAddress(token_a), - token_b: utils.createRecipientAddress(token_b), - liquidity: casper_js_sdk_1.CLValueBuilder.u256(liquidity), - amount_a_min: casper_js_sdk_1.CLValueBuilder.u256(amount_a_min), - amount_b_min: casper_js_sdk_1.CLValueBuilder.u256(amount_b_min), - to: utils.createRecipientAddress(to), - deadline: casper_js_sdk_1.CLValueBuilder.u256(deadline) - }); - return [4 /*yield*/, contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "remove_liquidity", - keys: keys, - nodeAddress: this.nodeAddress, - paymentAmount: paymentAmount, - runtimeArgs: runtimeArgs, - })]; - case 1: - deployHash = _a.sent(); - if (deployHash !== null) { - this.addPendingDeploy(constants_1.RouterEvents.RemoveLiquidity, deployHash); - return [2 /*return*/, deployHash]; - } - else { - throw Error("Invalid Deploy"); - } - return [2 /*return*/]; - } - }); - }); - }; - UniswapRouterClient.prototype.remove_liquidity_cspr = function (keys, token, liquidity, amount_token_min, amount_cspr_min, to, deadline, paymentAmount) { - return __awaiter(this, void 0, void 0, function () { - var runtimeArgs, deployHash; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - runtimeArgs = casper_js_sdk_1.RuntimeArgs.fromMap({ - token: utils.createRecipientAddress(token), - liquidity: casper_js_sdk_1.CLValueBuilder.u256(liquidity), - amount_token_min: casper_js_sdk_1.CLValueBuilder.u256(amount_token_min), - amount_cspr_min: casper_js_sdk_1.CLValueBuilder.u256(amount_cspr_min), - to: utils.createRecipientAddress(to), - deadline: casper_js_sdk_1.CLValueBuilder.u256(deadline) - }); - return [4 /*yield*/, contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "remove_liquidity_cspr", - keys: keys, - nodeAddress: this.nodeAddress, - paymentAmount: paymentAmount, - runtimeArgs: runtimeArgs, - })]; - case 1: - deployHash = _a.sent(); - if (deployHash !== null) { - this.addPendingDeploy(constants_1.RouterEvents.RemoveLiquidityCSPR, deployHash); - return [2 /*return*/, deployHash]; - } - else { - throw Error("Invalid Deploy"); - } - return [2 /*return*/]; - } - }); - }); - }; - // Buffer.from(string) but it converts the string - // We want the actual bytes value from something.. - UniswapRouterClient.prototype.remove_liquidity_with_permit = function (keys, token_a, token_b, liquidity, amount_a_min, amount_b_min, to, deadline, approve_max, v, r, s, paymentAmount) { - return __awaiter(this, void 0, void 0, function () { - var r_bytes, s_bytes, runtimeArgs, deployHash; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - r_bytes = r.map(casper_js_sdk_1.CLValueBuilder.u8); - s_bytes = s.map(casper_js_sdk_1.CLValueBuilder.u8); - runtimeArgs = casper_js_sdk_1.RuntimeArgs.fromMap({ - token_a: utils.createRecipientAddress(token_a), - token_b: utils.createRecipientAddress(token_b), - liquidity: casper_js_sdk_1.CLValueBuilder.u256(liquidity), - amount_a_min: casper_js_sdk_1.CLValueBuilder.u256(amount_a_min), - amount_b_min: casper_js_sdk_1.CLValueBuilder.u256(amount_b_min), - to: utils.createRecipientAddress(to), - deadline: casper_js_sdk_1.CLValueBuilder.u256(deadline), - approve_max: casper_js_sdk_1.CLValueBuilder.bool(approve_max), - v: casper_js_sdk_1.CLValueBuilder.u8(v), - r: casper_js_sdk_1.CLValueBuilder.list(r_bytes), - s: casper_js_sdk_1.CLValueBuilder.list(s_bytes) - }); - return [4 /*yield*/, contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "remove_liquidity_with_permit", - keys: keys, - nodeAddress: this.nodeAddress, - paymentAmount: paymentAmount, - runtimeArgs: runtimeArgs, - })]; - case 1: - deployHash = _a.sent(); - if (deployHash !== null) { - this.addPendingDeploy(constants_1.RouterEvents.RemoveLiquidityWithPermit, deployHash); - return [2 /*return*/, deployHash]; - } - else { - throw Error("Invalid Deploy"); - } - return [2 /*return*/]; - } - }); - }); - }; - UniswapRouterClient.prototype.remove_liquidity_cspr_with_permit = function (keys, token, liquidity, amount_token_min, amount_cspr_min, to, deadline, approve_max, v, r, s, paymentAmount) { - return __awaiter(this, void 0, void 0, function () { - var r_bytes, s_bytes, runtimeArgs, deployHash; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - r_bytes = r.map(casper_js_sdk_1.CLValueBuilder.u8); - s_bytes = s.map(casper_js_sdk_1.CLValueBuilder.u8); - runtimeArgs = casper_js_sdk_1.RuntimeArgs.fromMap({ - token: utils.createRecipientAddress(token), - liquidity: casper_js_sdk_1.CLValueBuilder.u256(liquidity), - amount_token_min: casper_js_sdk_1.CLValueBuilder.u256(amount_token_min), - amount_cspr_min: casper_js_sdk_1.CLValueBuilder.u256(amount_cspr_min), - to: utils.createRecipientAddress(to), - deadline: casper_js_sdk_1.CLValueBuilder.u256(deadline), - approve_max: casper_js_sdk_1.CLValueBuilder.bool(approve_max), - v: casper_js_sdk_1.CLValueBuilder.u8(v), - r: casper_js_sdk_1.CLValueBuilder.list(r_bytes), - s: casper_js_sdk_1.CLValueBuilder.list(s_bytes) - }); - return [4 /*yield*/, contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "remove_liquidity_cspr_with_permit", - keys: keys, - nodeAddress: this.nodeAddress, - paymentAmount: paymentAmount, - runtimeArgs: runtimeArgs, - })]; - case 1: - deployHash = _a.sent(); - if (deployHash !== null) { - this.addPendingDeploy(constants_1.RouterEvents.RemoveLiquidityCSPRWithPermit, deployHash); - return [2 /*return*/, deployHash]; - } - else { - throw Error("Invalid Deploy"); - } - return [2 /*return*/]; - } - }); - }); - }; - UniswapRouterClient.prototype.swap_exact_tokens_for_tokens = function (keys, amount_in, amount_out_min, path, to, deadline, paymentAmount) { - return __awaiter(this, void 0, void 0, function () { - var _paths, i, runtimeArgs, deployHash; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _paths = []; - for (i = 0; i < path.length; i++) { - _paths.push(utils.createRecipientAddress(path[i])); - } - runtimeArgs = casper_js_sdk_1.RuntimeArgs.fromMap({ - amount_in: casper_js_sdk_1.CLValueBuilder.u256(amount_in), - amount_out_min: casper_js_sdk_1.CLValueBuilder.u256(amount_out_min), - path: casper_js_sdk_1.CLValueBuilder.list(_paths), - to: utils.createRecipientAddress(to), - deadline: casper_js_sdk_1.CLValueBuilder.u256(deadline) - }); - return [4 /*yield*/, contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "swap_exact_tokens_for_tokens", - keys: keys, - nodeAddress: this.nodeAddress, - paymentAmount: paymentAmount, - runtimeArgs: runtimeArgs, - })]; - case 1: - deployHash = _a.sent(); - if (deployHash !== null) { - this.addPendingDeploy(constants_1.RouterEvents.SwapExactTokensForTokens, deployHash); - return [2 /*return*/, deployHash]; - } - else { - throw Error("Invalid Deploy"); - } - return [2 /*return*/]; - } - }); - }); - }; - UniswapRouterClient.prototype.swap_tokens_for_exact_tokens = function (keys, amount_out, amount_in_max, path, to, deadline, paymentAmount) { - return __awaiter(this, void 0, void 0, function () { - var _paths, i, runtimeArgs, deployHash; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _paths = []; - for (i = 0; i < path.length; i++) { - _paths.push(utils.createRecipientAddress(path[i])); - } - runtimeArgs = casper_js_sdk_1.RuntimeArgs.fromMap({ - amount_out: casper_js_sdk_1.CLValueBuilder.u256(amount_out), - amount_in_max: casper_js_sdk_1.CLValueBuilder.u256(amount_in_max), - path: casper_js_sdk_1.CLValueBuilder.list(_paths), - deadline: casper_js_sdk_1.CLValueBuilder.u256(deadline), - to: utils.createRecipientAddress(to) - }); - return [4 /*yield*/, contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "swap_tokens_for_exact_tokens", - keys: keys, - nodeAddress: this.nodeAddress, - paymentAmount: paymentAmount, - runtimeArgs: runtimeArgs, - })]; - case 1: - deployHash = _a.sent(); - if (deployHash !== null) { - this.addPendingDeploy(constants_1.RouterEvents.SwapTokensForExactTokens, deployHash); - return [2 /*return*/, deployHash]; - } - else { - throw Error("Invalid Deploy"); - } - return [2 /*return*/]; - } - }); - }); - }; - UniswapRouterClient.prototype.swap_exact_cspr_for_tokens = function (keys, amount_out_min, amount_in, path, to, deadline, paymentAmount) { - return __awaiter(this, void 0, void 0, function () { - var _path, i, runtimeArgs, deployHash; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _path = []; - for (i = 0; i < path.length; i++) { - _path.push(utils.createRecipientAddress(path[i])); - } - runtimeArgs = casper_js_sdk_1.RuntimeArgs.fromMap({ - amount_out_min: casper_js_sdk_1.CLValueBuilder.u256(amount_out_min), - amount_in: casper_js_sdk_1.CLValueBuilder.u256(amount_in), - path: casper_js_sdk_1.CLValueBuilder.list(_path), - to: utils.createRecipientAddress(to), - deadline: casper_js_sdk_1.CLValueBuilder.u256(deadline), - }); - return [4 /*yield*/, contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "swap_exact_cspr_for_tokens", - keys: keys, - nodeAddress: this.nodeAddress, - paymentAmount: paymentAmount, - runtimeArgs: runtimeArgs, - })]; - case 1: - deployHash = _a.sent(); - if (deployHash !== null) { - this.addPendingDeploy(constants_1.RouterEvents.SwapExactCSPRForTokens, deployHash); - return [2 /*return*/, deployHash]; - } - else { - throw Error("Invalid Deploy"); - } - return [2 /*return*/]; - } - }); - }); - }; - UniswapRouterClient.prototype.swap_tokens_for_exact_cspr = function (keys, amount_out, amount_in_max, path, to, deadline, paymentAmount) { - return __awaiter(this, void 0, void 0, function () { - var _paths, i, runtimeArgs, deployHash; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _paths = []; - for (i = 0; i < path.length; i++) { - _paths.push(utils.createRecipientAddress(path[i])); - } - runtimeArgs = casper_js_sdk_1.RuntimeArgs.fromMap({ - amount_out: casper_js_sdk_1.CLValueBuilder.u256(amount_out), - amount_in_max: casper_js_sdk_1.CLValueBuilder.u256(amount_in_max), - path: casper_js_sdk_1.CLValueBuilder.list(_paths), - to: utils.createRecipientAddress(to), - deadline: casper_js_sdk_1.CLValueBuilder.u256(deadline) - }); - return [4 /*yield*/, contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "swap_tokens_for_exact_cspr", - keys: keys, - nodeAddress: this.nodeAddress, - paymentAmount: paymentAmount, - runtimeArgs: runtimeArgs, - })]; - case 1: - deployHash = _a.sent(); - if (deployHash !== null) { - this.addPendingDeploy(constants_1.RouterEvents.SwapTokensForExactCSPR, deployHash); - return [2 /*return*/, deployHash]; - } - else { - throw Error("Invalid Deploy"); - } - return [2 /*return*/]; - } - }); - }); - }; - UniswapRouterClient.prototype.swap_exact_tokens_for_cspr = function (keys, amount_in, amount_out_min, path, to, deadline, paymentAmount) { - return __awaiter(this, void 0, void 0, function () { - var _paths, i, runtimeArgs, deployHash; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _paths = []; - for (i = 0; i < path.length; i++) { - _paths.push(utils.createRecipientAddress(path[i])); - } - runtimeArgs = casper_js_sdk_1.RuntimeArgs.fromMap({ - amount_in: casper_js_sdk_1.CLValueBuilder.u256(amount_in), - amount_out_min: casper_js_sdk_1.CLValueBuilder.u256(amount_out_min), - path: casper_js_sdk_1.CLValueBuilder.list(_paths), - to: utils.createRecipientAddress(to), - deadline: casper_js_sdk_1.CLValueBuilder.u256(deadline) - }); - return [4 /*yield*/, contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "swap_exact_tokens_for_cspr", - keys: keys, - nodeAddress: this.nodeAddress, - paymentAmount: paymentAmount, - runtimeArgs: runtimeArgs, - })]; - case 1: - deployHash = _a.sent(); - if (deployHash !== null) { - this.addPendingDeploy(constants_1.RouterEvents.SwapExactTokensForCSPR, deployHash); - return [2 /*return*/, deployHash]; - } - else { - throw Error("Invalid Deploy"); - } - return [2 /*return*/]; - } - }); - }); - }; - UniswapRouterClient.prototype.swap_cspr_for_exact_tokens = function (keys, amount_out, amount_in_max, path, to, deadline, paymentAmount) { - return __awaiter(this, void 0, void 0, function () { - var _paths, i, runtimeArgs, deployHash; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _paths = []; - for (i = 0; i < path.length; i++) { - _paths.push(utils.createRecipientAddress(path[i])); - } - runtimeArgs = casper_js_sdk_1.RuntimeArgs.fromMap({ - amount_out: casper_js_sdk_1.CLValueBuilder.u256(amount_out), - amount_in_max: casper_js_sdk_1.CLValueBuilder.u256(amount_in_max), - path: casper_js_sdk_1.CLValueBuilder.list(_paths), - to: utils.createRecipientAddress(to), - deadline: casper_js_sdk_1.CLValueBuilder.u256(deadline) - }); - return [4 /*yield*/, contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "swap_cspr_for_exact_tokens", - keys: keys, - nodeAddress: this.nodeAddress, - paymentAmount: paymentAmount, - runtimeArgs: runtimeArgs, - })]; - case 1: - deployHash = _a.sent(); - if (deployHash !== null) { - this.addPendingDeploy(constants_1.RouterEvents.SwapCSPRForExactTokens, deployHash); - return [2 /*return*/, deployHash]; - } - else { - throw Error("Invalid Deploy"); - } - return [2 /*return*/]; - } - }); - }); - }; - /* - public async quote( - keys: Keys.AsymmetricKey, - amount_a: string, - reserve_a: string, - reserve_b: string, - paymentAmount: string - ) { - - const runtimeArgs = RuntimeArgs.fromMap({ - amount_a: CLValueBuilder.u256(amount_a), - reserve_a: CLValueBuilder.u256(reserve_a), - reserve_b: CLValueBuilder.u256(reserve_b), - }); - - const deployHash = await contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "quote", - keys, - nodeAddress: this.nodeAddress, - paymentAmount, - runtimeArgs, - }); - - if (deployHash !== null) { - this.addPendingDeploy(RouterEvents.Quote, deployHash); - return deployHash; - } else { - throw Error("Invalid Deploy"); - } - - } - - public async get_amount_out( - keys: Keys.AsymmetricKey, - amount_in: string, - reserve_in: string, - reserve_out: string, - paymentAmount: string - ) { - - const runtimeArgs = RuntimeArgs.fromMap({ - amount_in: CLValueBuilder.u256(amount_in), - reserve_in: CLValueBuilder.u256(reserve_in), - reserve_out: CLValueBuilder.u256(reserve_out), - }); - - const deployHash = await contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "get_amount_out", - keys, - nodeAddress: this.nodeAddress, - paymentAmount, - runtimeArgs, - }); - - if (deployHash !== null) { - this.addPendingDeploy(RouterEvents.GetAmountOut, deployHash); - return deployHash; - } else { - throw Error("Invalid Deploy"); - } - - } - - public async get_amount_in( - keys: Keys.AsymmetricKey, - amount_out: string, - reserve_in: string, - reserve_out: string, - paymentAmount: string - ) { - - const runtimeArgs = RuntimeArgs.fromMap({ - amount_out: CLValueBuilder.u256(amount_out), - reserve_in: CLValueBuilder.u256(reserve_in), - reserve_out: CLValueBuilder.u256(reserve_out), - }); - - const deployHash = await contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "get_amount_in", - keys, - nodeAddress: this.nodeAddress, - paymentAmount, - runtimeArgs, - }); - - if (deployHash !== null) { - this.addPendingDeploy(RouterEvents.GetAmountIn, deployHash); - return deployHash; - } else { - throw Error("Invalid Deploy"); - } - - } - - public async get_amounts_out( - keys: Keys.AsymmetricKey, - amount_in: string, - path: RecipientType[], - paymentAmount: string - ) { - - // MAPPED THIS ACCORDING TO UTIL createRecipientAddress function - let _paths:CLKey[] = []; - for(let i = 0; i < path.length; i++){ - _paths.push(utils.createRecipientAddress(path[i])); - } - - const runtimeArgs = RuntimeArgs.fromMap({ - amount_in: CLValueBuilder.u256(amount_in), - path: CLValueBuilder.list(_paths) - }); - - const deployHash = await contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "get_amounts_out", - keys, - nodeAddress: this.nodeAddress, - paymentAmount, - runtimeArgs, - }); - - if (deployHash !== null) { - this.addPendingDeploy(RouterEvents.GetAmountsOut, deployHash); - return deployHash; - } else { - throw Error("Invalid Deploy"); - } - - } - - public async get_amounts_in( - keys: Keys.AsymmetricKey, - amount_out: string, - path: RecipientType[], - paymentAmount: string - ) { - - // MAPPED THIS ACCORDING TO UTIL createRecipientAddress function - let _paths:CLKey[] = []; - for(let i = 0; i < path.length; i++){ - _paths.push(utils.createRecipientAddress(path[i])); - } - - const runtimeArgs = RuntimeArgs.fromMap({ - amount_out: CLValueBuilder.u256(amount_out), - path: CLValueBuilder.list(_paths) - }); - - const deployHash = await contractCall({ - chainName: this.chainName, - contractHash: this.contractHash, - entryPoint: "get_amounts_in", - keys, - nodeAddress: this.nodeAddress, - paymentAmount, - runtimeArgs, - }); - - if (deployHash !== null) { - this.addPendingDeploy(RouterEvents.GetAmountsIn, deployHash); - return deployHash; - } else { - throw Error("Invalid Deploy"); - } - - } - */ - UniswapRouterClient.prototype.onEvent = function (eventNames, callback) { - var _this = this; - if (!this.eventStreamAddress) { - throw Error("Please set eventStreamAddress before!"); - } - if (this.isListening) { - throw Error("Only one event listener can be create at a time. Remove the previous one and start new."); - } - var es = new casper_js_sdk_1.EventStream(this.eventStreamAddress); - this.isListening = true; - es.subscribe(casper_js_sdk_1.EventName.DeployProcessed, function (value) { - var deployHash = value.body.DeployProcessed.deploy_hash; - var pendingDeploy = _this.pendingDeploys.find(function (pending) { return pending.deployHash === deployHash; }); - if (!pendingDeploy) { - return; - } - if (!value.body.DeployProcessed.execution_result.Success && - value.body.DeployProcessed.execution_result.Failure) { - callback(pendingDeploy.deployType, { - deployHash: deployHash, - error: value.body.DeployProcessed.execution_result.Failure.error_message, - success: false, - }, null); - } - else { - var transforms = value.body.DeployProcessed.execution_result.Success.effect.transforms; - var cep47Events = transforms.reduce(function (acc, val) { - if (val.transform.hasOwnProperty("WriteCLValue") && - typeof val.transform.WriteCLValue.parsed === "object" && - val.transform.WriteCLValue.parsed !== null) { - var maybeCLValue = casper_js_sdk_1.CLValueParsers.fromJSON(val.transform.WriteCLValue); - var clValue = maybeCLValue.unwrap(); - if (clValue && clValue instanceof casper_js_sdk_1.CLMap) { - var hash = clValue.get(casper_js_sdk_1.CLValueBuilder.string("contract_package_hash")); - var event_1 = clValue.get(casper_js_sdk_1.CLValueBuilder.string("event_type")); - if (hash && - hash.value() === _this.contractPackageHash && - event_1 && - eventNames.includes(event_1.value())) { - acc = __spreadArray(__spreadArray([], acc, true), [{ name: event_1.value(), clValue: clValue }], false); - } - } - } - return acc; - }, []); - cep47Events.forEach(function (d) { - return callback(d.name, { deployHash: deployHash, error: null, success: true }, d.clValue); - }); - } - _this.pendingDeploys = _this.pendingDeploys.filter(function (pending) { return pending.deployHash !== deployHash; }); - }); - es.start(); - return { - stopListening: function () { - es.unsubscribe(casper_js_sdk_1.EventName.DeployProcessed); - es.stop(); - _this.isListening = false; - _this.pendingDeploys = []; - }, - }; - }; - UniswapRouterClient.prototype.addPendingDeploy = function (deployType, deployHash) { - this.pendingDeploys = __spreadArray(__spreadArray([], this.pendingDeploys, true), [{ deployHash: deployHash, deployType: deployType }], false); - }; - return UniswapRouterClient; -}()); -var installWasmFile = function (_a) { - var nodeAddress = _a.nodeAddress, keys = _a.keys, chainName = _a.chainName, pathToContract = _a.pathToContract, runtimeArgs = _a.runtimeArgs, paymentAmount = _a.paymentAmount; - return __awaiter(void 0, void 0, void 0, function () { - var client, deploy; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - client = new casper_js_sdk_1.CasperClient(nodeAddress); - deploy = casper_js_sdk_1.DeployUtil.makeDeploy(new casper_js_sdk_1.DeployUtil.DeployParams(casper_js_sdk_1.CLPublicKey.fromHex(keys.publicKey.toHex()), chainName), casper_js_sdk_1.DeployUtil.ExecutableDeployItem.newModuleBytes(utils.getBinary(pathToContract), runtimeArgs), casper_js_sdk_1.DeployUtil.standardPayment(paymentAmount)); - // Sign deploy. - deploy = client.signDeploy(deploy, keys); - return [4 /*yield*/, client.putDeploy(deploy)]; - case 1: - // Dispatch deploy to node. - return [2 /*return*/, _b.sent()]; - } - }); - }); -}; -var contractCall = function (_a) { - var nodeAddress = _a.nodeAddress, keys = _a.keys, chainName = _a.chainName, contractHash = _a.contractHash, entryPoint = _a.entryPoint, runtimeArgs = _a.runtimeArgs, paymentAmount = _a.paymentAmount; - return __awaiter(void 0, void 0, void 0, function () { - var client, contractHashAsByteArray, deploy, deployHash; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - client = new casper_js_sdk_1.CasperClient(nodeAddress); - contractHashAsByteArray = utils.contractHashToByteArray(contractHash); - deploy = casper_js_sdk_1.DeployUtil.makeDeploy(new casper_js_sdk_1.DeployUtil.DeployParams(keys.publicKey, chainName), casper_js_sdk_1.DeployUtil.ExecutableDeployItem.newStoredContractByHash(contractHashAsByteArray, entryPoint, runtimeArgs), casper_js_sdk_1.DeployUtil.standardPayment(paymentAmount)); - // Sign deploy. - deploy = client.signDeploy(deploy, keys); - return [4 /*yield*/, client.putDeploy(deploy)]; - case 1: - deployHash = _b.sent(); - return [2 /*return*/, deployHash]; - } - }); - }); -}; -var contractSimpleGetter = function (nodeAddress, contractHash, key) { return __awaiter(void 0, void 0, void 0, function () { - var stateRootHash, clValue; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, utils.getStateRootHash(nodeAddress)]; - case 1: - stateRootHash = _a.sent(); - return [4 /*yield*/, utils.getContractData(nodeAddress, stateRootHash, contractHash, key)]; - case 2: - clValue = _a.sent(); - if (clValue && clValue.CLValue instanceof casper_js_sdk_1.CLValue) { - return [2 /*return*/, clValue.CLValue]; - } - else { - throw Error("Invalid stored value"); - } - return [2 /*return*/]; - } - }); -}); }; -var toCLMap = function (map) { - var clMap = casper_js_sdk_1.CLValueBuilder.map([ - casper_js_sdk_1.CLTypeBuilder.string(), - casper_js_sdk_1.CLTypeBuilder.string(), - ]); - for (var _i = 0, _a = Array.from(map.entries()); _i < _a.length; _i++) { - var _b = _a[_i], key = _b[0], value = _b[1]; - clMap.set(casper_js_sdk_1.CLValueBuilder.string(key), casper_js_sdk_1.CLValueBuilder.string(value)); - } - return clMap; -}; -var fromCLMap = function (map) { - var jsMap = new Map(); - for (var _i = 0, _a = Array.from(map.entries()); _i < _a.length; _i++) { - var _b = _a[_i], key = _b[0], value = _b[1]; - jsMap.set(key.value(), value.value()); - } - return jsMap; -}; -exports.default = UniswapRouterClient; -//# sourceMappingURL=uniswap-router-client.js.map \ No newline at end of file diff --git a/JsClients/ROUTER/dist/uniswap-router-client.js.map b/JsClients/ROUTER/dist/uniswap-router-client.js.map deleted file mode 100644 index 50f1e73d..00000000 --- a/JsClients/ROUTER/dist/uniswap-router-client.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"uniswap-router-client.js","sourceRoot":"","sources":["../src/uniswap-router-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAiBuB;AAEvB,yCAA2C;AAC3C,6CAAiC;AAIjC;IAcE,6BACU,WAAmB,EACnB,SAAiB,EACjB,kBAA2B;QAF3B,gBAAW,GAAX,WAAW,CAAQ;QACnB,cAAS,GAAT,SAAS,CAAQ;QACjB,uBAAkB,GAAlB,kBAAkB,CAAS;QAhB7B,iBAAY,GAAW,gBAAgB,CAAC;QAUxC,gBAAW,GAAG,KAAK,CAAC;QACpB,mBAAc,GAAqB,EAAE,CAAC;IAM3C,CAAC;IAES,qCAAO,GAApB,UACE,IAAwB,EAAQ,+BAA+B;IAC/D,SAAiB,EACjB,OAAe,EACf,WAAmB,EACnB,aAAqB,EACrB,QAAgB;;;;;;wBAEhB,IAAI,CAAC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A2B,UAAyB,EAAzB,KAAA,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,EAAzB,cAAyB,EAAzB,IAAyB,EAAE;QAA3C,IAAA,WAAY,EAAX,GAAG,QAAA,EAAE,KAAK,QAAA;QACpB,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;KACvC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,kBAAe,mBAAmB,CAAC"} \ No newline at end of file diff --git a/JsClients/ROUTER/dist/utils.js b/JsClients/ROUTER/dist/utils.js deleted file mode 100644 index b0a6aea2..00000000 --- a/JsClients/ROUTER/dist/utils.js +++ /dev/null @@ -1,177 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.sleep = exports.contractHashToByteArray = exports.contractDictionaryGetter = exports.getContractData = exports.getAccountNamedKeyValue = exports.getAccountInfo = exports.getStateRootHash = exports.getBinary = exports.getKeyPairOfContract = exports.createRecipientAddress = exports.camelCased = void 0; -var casper_js_sdk_1 = require("casper-js-sdk"); -var fs_1 = __importDefault(require("fs")); -var camelCased = function (myString) { - return myString.replace(/_([a-z])/g, function (g) { return g[1].toUpperCase(); }); -}; -exports.camelCased = camelCased; -var createRecipientAddress = function (recipient) { - if (recipient instanceof casper_js_sdk_1.CLPublicKey) { - return new casper_js_sdk_1.CLKey(new casper_js_sdk_1.CLAccountHash(recipient.toAccountHash())); - } - else { - return new casper_js_sdk_1.CLKey(recipient); - } -}; -exports.createRecipientAddress = createRecipientAddress; -/** - * Returns an ECC key pair mapped to an NCTL faucet account. - * @param pathToFaucet - Path to NCTL faucet directory. - */ -var getKeyPairOfContract = function (pathToFaucet) { - return casper_js_sdk_1.Keys.Ed25519.parseKeyFiles(pathToFaucet + "/public_key.pem", pathToFaucet + "/secret_key.pem"); -}; -exports.getKeyPairOfContract = getKeyPairOfContract; -/** - * Returns a binary as u8 array. - * @param pathToBinary - Path to binary file to be loaded into memory. - * @return Uint8Array Byte array. - */ -var getBinary = function (pathToBinary) { - return new Uint8Array(fs_1.default.readFileSync(pathToBinary, null).buffer); -}; -exports.getBinary = getBinary; -/** - * Returns global state root hash at current block. - * @param {Object} client - JS SDK client for interacting with a node. - * @return {String} Root hash of global state at most recent block. - */ -var getStateRootHash = function (nodeAddress) { return __awaiter(void 0, void 0, void 0, function () { - var client, block; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - client = new casper_js_sdk_1.CasperServiceByJsonRPC(nodeAddress); - return [4 /*yield*/, client.getLatestBlockInfo()]; - case 1: - block = (_a.sent()).block; - if (block) { - return [2 /*return*/, block.header.state_root_hash]; - } - else { - throw Error("Problem when calling getLatestBlockInfo"); - } - return [2 /*return*/]; - } - }); -}); }; -exports.getStateRootHash = getStateRootHash; -var getAccountInfo = function (nodeAddress, publicKey) { return __awaiter(void 0, void 0, void 0, function () { - var stateRootHash, client, accountHash, blockState; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, (0, exports.getStateRootHash)(nodeAddress)]; - case 1: - stateRootHash = _a.sent(); - client = new casper_js_sdk_1.CasperServiceByJsonRPC(nodeAddress); - accountHash = publicKey.toAccountHashStr(); - return [4 /*yield*/, client.getBlockState(stateRootHash, accountHash, [])]; - case 2: - blockState = _a.sent(); - return [2 /*return*/, blockState.Account]; - } - }); -}); }; -exports.getAccountInfo = getAccountInfo; -/** - * Returns a value under an on-chain account's storage. - * @param accountInfo - On-chain account's info. - * @param namedKey - A named key associated with an on-chain account. - */ -var getAccountNamedKeyValue = function (accountInfo, namedKey) { - var found = accountInfo.namedKeys.find(function (i) { return i.name === namedKey; }); - if (found) { - return found.key; - } - return undefined; -}; -exports.getAccountNamedKeyValue = getAccountNamedKeyValue; -var getContractData = function (nodeAddress, stateRootHash, contractHash, path) { - if (path === void 0) { path = []; } - return __awaiter(void 0, void 0, void 0, function () { - var client, blockState; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - client = new casper_js_sdk_1.CasperServiceByJsonRPC(nodeAddress); - return [4 /*yield*/, client.getBlockState(stateRootHash, "hash-" + contractHash, path)]; - case 1: - blockState = _a.sent(); - return [2 /*return*/, blockState]; - } - }); - }); -}; -exports.getContractData = getContractData; -var contractDictionaryGetter = function (nodeAddress, dictionaryItemKey, seedUref) { return __awaiter(void 0, void 0, void 0, function () { - var stateRootHash, client, storedValue; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, (0, exports.getStateRootHash)(nodeAddress)]; - case 1: - stateRootHash = _a.sent(); - client = new casper_js_sdk_1.CasperServiceByJsonRPC(nodeAddress); - return [4 /*yield*/, client.getDictionaryItemByURef(stateRootHash, dictionaryItemKey, seedUref)]; - case 2: - storedValue = _a.sent(); - if (storedValue && storedValue.CLValue instanceof casper_js_sdk_1.CLValue) { - return [2 /*return*/, storedValue.CLValue]; - } - else { - throw Error("Invalid stored value"); - } - return [2 /*return*/]; - } - }); -}); }; -exports.contractDictionaryGetter = contractDictionaryGetter; -var contractHashToByteArray = function (contractHash) { - return Uint8Array.from(Buffer.from(contractHash, "hex")); -}; -exports.contractHashToByteArray = contractHashToByteArray; -var sleep = function (num) { - return new Promise(function (resolve) { return setTimeout(resolve, num); }); -}; -exports.sleep = sleep; -//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/JsClients/ROUTER/dist/utils.js.map b/JsClients/ROUTER/dist/utils.js.map deleted file mode 100644 index 42ca967b..00000000 --- a/JsClients/ROUTER/dist/utils.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAOuB;AACvB,0CAAoB;AAIb,IAAM,UAAU,GAAG,UAAC,QAAgB;IACzC,OAAA,QAAQ,CAAC,OAAO,CAAC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,EAAA;;gBAAnD,aAAa,GAAG,SAAmC;gBAEnD,MAAM,GAAG,IAAI,sCAAsB,CAAC,WAAW,CAAC,CAAC;gBAEnC,qBAAM,MAAM,CAAC,uBAAuB,CACtD,aAAa,EACb,iBAAiB,EACjB,QAAQ,CACT,EAAA;;gBAJK,WAAW,GAAG,SAInB;gBAED,IAAI,WAAW,IAAI,WAAW,CAAC,OAAO,YAAY,uBAAO,EAAE;oBACzD,sBAAO,WAAW,CAAC,OAAQ,EAAC;iBAC7B;qBAAM;oBACL,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAC;iBACrC;;;;KACF,CAAC;AApBW,QAAA,wBAAwB,4BAoBnC;AAGK,IAAM,uBAAuB,GAAG,UAAC,YAAoB;IAC1D,OAAA,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;AAAjD,CAAiD,CAAC;AADvC,QAAA,uBAAuB,2BACgB;AAE7C,IAAM,KAAK,GAAG,UAAC,GAAW;IAC/B,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,IAAK,OAAA,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,EAAxB,CAAwB,CAAC,CAAC;AAC5D,CAAC,CAAC;AAFW,QAAA,KAAK,SAEhB"} \ No newline at end of file diff --git a/JsClients/ROUTER/keys/public_key.pem b/JsClients/ROUTER/keys/public_key.pem index ef71a6fb..f8820b36 100644 --- a/JsClients/ROUTER/keys/public_key.pem +++ b/JsClients/ROUTER/keys/public_key.pem @@ -1,3 +1,3 @@ -----BEGIN PUBLIC KEY----- -MCowBQYDK2VwAyEAOx2Lh372bKru6Ob727qg2J+53UC1VQOAo3flgNWTXY8= +MCowBQYDK2VwAyEAisk1o1Ahn6RwyosEG9ryFSjKyUPlZdBlAK1atB5zc54= -----END PUBLIC KEY----- diff --git a/JsClients/ROUTER/keys/public_key_hex b/JsClients/ROUTER/keys/public_key_hex index 3c562076..22ec15d6 100644 --- a/JsClients/ROUTER/keys/public_key_hex +++ b/JsClients/ROUTER/keys/public_key_hex @@ -1 +1 @@ -013b1d8b877ef66caaeee8e6fbdbbaa0d89fb9dd40b5550380a377e580d5935d8f \ No newline at end of file +018ac935a350219fa470ca8b041bdaf21528cac943e565d06500ad5ab41e73739e \ No newline at end of file diff --git a/JsClients/ROUTER/keys/secret_key.pem b/JsClients/ROUTER/keys/secret_key.pem index ecfe7bf5..b1d32bdc 100644 --- a/JsClients/ROUTER/keys/secret_key.pem +++ b/JsClients/ROUTER/keys/secret_key.pem @@ -1,3 +1,3 @@ -----BEGIN PRIVATE KEY----- -MC4CAQAwBQYDK2VwBCIEINHgUlwQkPmO7tZIxmYxz0fUcSxJ9GpDl54v+YPm4zWy +MC4CAQAwBQYDK2VwBCIEIG6psKFljoJdMK/HvjRVt50w7+DrrivkvHf7ICB9KM3s -----END PRIVATE KEY----- diff --git a/JsClients/ROUTER/src/uniswap-router-client.ts b/JsClients/ROUTER/src/uniswap-router-client.ts index d3848f2c..2a72eaff 100644 --- a/JsClients/ROUTER/src/uniswap-router-client.ts +++ b/JsClients/ROUTER/src/uniswap-router-client.ts @@ -113,9 +113,6 @@ class UniswapRouterClient { "" ); const LIST_OF_NAMED_KEYS = [ - 'balances', - 'nonces', - 'allowances', `${this.contractName}_package_hash`, `${this.contractName}_package_hash_wrapped`, `${this.contractName}_contract_hash`, diff --git a/JsClients/ROUTER/test/installed.ts b/JsClients/ROUTER/test/installed.ts index beba8f73..556d604f 100644 --- a/JsClients/ROUTER/test/installed.ts +++ b/JsClients/ROUTER/test/installed.ts @@ -122,8 +122,7 @@ const { SCFET_AMOUNT_IN_MAX, SCFET_PATH, SCFET_TO, - - GRAPHQL + } = process.env; const KEYS = Keys.Ed25519.parseKeyFiles( @@ -469,449 +468,18 @@ const swap_cspr_for_exact_tokens = async ( console.log(`swap_cspr_for_exact_tokens function called successfully`); }; -function splitdata(data:string) -{ - var temp=data.split('('); - var result=temp[1].split(')'); - return result[0]; -} - const uniswapRouter = new UniswapRouterClient( NODE_ADDRESS!, CHAIN_NAME!, EVENT_STREAM_ADDRESS! ); -// const test1 = async () => { - -// const listener = uniswapRouter.onEvent( -// [ -// RouterEvents.PairCreated, -// RouterEvents.Erc20Transfer, -// RouterEvents.Transfer, -// RouterEvents.Approval, -// RouterEvents.Mint, -// RouterEvents.Burn, -// RouterEvents.Sync, -// RouterEvents.Swap -// ], -// async (eventName, deploy, result) => { -// if (deploy.success) { -// console.log(`Successfull deploy of event : ${eventName}, deployHash: ${deploy.deployHash}`); -// // const [timestamp,block_hash]= await getDeploy(NODE_ADDRESS!, deploy.deployHash); -// // console.log("... Deployhash: ", 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())); - -// // if(eventName =="pair_created") -// // { -// // 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 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 if(eventName=="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); -// // console.log(newData[5][0].data + " = " + newData[5][1].data); - -// // var from=splitdata(newData[2][1].data); -// // var to=splitdata(newData[4][1].data); -// // var value=parseInt(newData[5][1].data); -// // var pair=splitdata(newData[3][1].data); - -// // console.log("from: ", from); -// // console.log("to: ", to); -// // console.log("value: ",value); -// // console.log("pair: ", pair); - -// // 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: pair, deployHash:deploy.deployHash,timeStamp:timestamp.toString(), blockHash:block_hash}) -// // .then(data => console.log(data)) -// // .catch(error => console.error(error)); -// // } -// // else if (eventName=="mint") -// // { - -// // 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 amount0=parseInt(newData[0][1].data); -// // var amount1=parseInt(newData[1][1].data); -// // var pair=splitdata(newData[4][1].data); -// // var sender=splitdata(newData[5][1].data); - -// // console.log("amount0: ", amount0); -// // console.log("amount1: ", amount1); -// // console.log("pair: ",pair); -// // console.log("sender: ", sender); - -// // request(GRAPHQL!, -// // `mutation handleMint( $amount0: Int!, $amount1: Int!, $sender: String!,$logIndex: Int!, $pairAddress: String!, $deployHash: String!, $timeStamp: String!, $blockHash: String!){ -// // handleMint( amount0: $amount0, amount1: $amount1, sender: $sender, logIndex: $logIndex, pairAddress: $pairAddress, deployHash: $deployHash, timeStamp: $timeStamp, blockHash: $blockHash) { -// // result -// // } - -// // }`, -// // {amount0:amount0, amount1: amount1, sender: sender,logIndex:0, pairAddress: pair, deployHash:deploy.deployHash,timeStamp:timestamp.toString(), blockHash:block_hash}) -// // .then(data => console.log(data)) -// // .catch(error => console.error(error)); -// // } -// // else if (eventName=="burn") -// // { - -// // 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); -// // console.log(newData[6][0].data + " = " + newData[6][1].data); - -// // var amount0=parseInt(newData[0][1].data); -// // var amount1=parseInt(newData[1][1].data); -// // var pair=splitdata(newData[4][1].data); -// // var sender=splitdata(newData[5][1].data); -// // var to=splitdata(newData[6][1].data); - -// // console.log("amount0: ", amount0); -// // console.log("amount1: ", amount1); -// // console.log("pair: ",pair); -// // console.log("sender: ", sender); -// // console.log("to: ", to); - -// // request(GRAPHQL!, -// // `mutation handleBurn( $amount0: Int!, $amount1: Int!, $sender: String!,$logIndex: Int!,$to: String!, $pairAddress: String!, $deployHash: String!, $timeStamp: String!, $blockHash: String!){ -// // handleBurn( amount0: $amount0, amount1: $amount1, sender: $sender, logIndex: $logIndex, to:$to, pairAddress: $pairAddress, deployHash: $deployHash, timeStamp: $timeStamp, blockHash: $blockHash) { -// // result -// // } - -// // }`, -// // {amount0:amount0, amount1: amount1, sender: sender,logIndex:0, to:to,pairAddress: pair, deployHash:deploy.deployHash,timeStamp:timestamp.toString(), blockHash:block_hash}) -// // .then(data => console.log(data)) -// // .catch(error => console.error(error)); -// // } -// // else if (eventName=="sync") -// // { - -// // 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 reserve0=parseInt(newData[3][1].data); -// // var reserve1=parseInt(newData[4][1].data); -// // var pair=splitdata(newData[2][1].data); - -// // console.log("reserve0: ", reserve0); -// // console.log("reserve1: ", reserve1); -// // console.log("pair: ",pair); - - -// // request(GRAPHQL!, -// // `mutation handleSync( $reserve0: Int!, $reserve1: Int!, $pairAddress: String!){ -// // handleSync( reserve0: $reserve0, reserve1: $reserve1, pairAddress: $pairAddress) { -// // result -// // } - -// // }`, -// // {reserve0:reserve0, reserve1: reserve1, pairAddress: pair}) -// // .then(data => console.log(data)) -// // .catch(error => console.error(error)); -// // } -// // else if (eventName=="swap") -// // { - -// // 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); -// // console.log(newData[6][0].data + " = " + newData[6][1].data); -// // console.log(newData[7][0].data + " = " + newData[7][1].data); -// // console.log(newData[8][0].data + " = " + newData[8][1].data); -// // console.log(newData[9][0].data + " = " + newData[9][1].data); - -// // var amount0In=parseInt(newData[0][1].data); -// // var amount1In=parseInt(newData[1][1].data); -// // var amount0Out=parseInt(newData[2][1].data); -// // var amount1Out=parseInt(newData[3][1].data); -// // var from=splitdata(newData[6][1].data); -// // var pair=splitdata(newData[7][1].data); -// // var sender=splitdata(newData[8][1].data); -// // var to=splitdata(newData[9][1].data); - -// // console.log("amount0In: ", amount0In); -// // console.log("amount1In: ", amount1In); -// // console.log("amount0Out: ", amount0Out); -// // console.log("amount1Out: ", amount1Out); -// // console.log("from: ",from); -// // console.log("pair: ",pair); -// // console.log("sender: ", sender); -// // console.log("to: ", to); - -// // request(GRAPHQL!, -// // `mutation handleSwap( $amount0In: Int!, $amount1In: Int!, $amount0Out: Int!, $amount1Out: Int!, $to: String!,$from: String!,$sender: String!,$logIndex: Int!, $pairAddress: String!, $deployHash: String!, $timeStamp: String!, $blockHash: String!){ -// // handleSwap( amount0In: $amount0In, amount1In: $amount1In, amount0Out: $amount0Out, amount1Out: $amount1Out, to:$to, from:$from,sender: $sender,logIndex: $logIndex, pairAddress: $pairAddress, deployHash: $deployHash, timeStamp: $timeStamp, blockHash: $blockHash) { -// // result -// // } - -// // }`, -// // {amount0In:amount0In, amount1In: amount1In,amount0Out:amount0Out, amount1Out: amount1Out,to:to,from:from, sender: sender,logIndex:0,pairAddress: pair, 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 event ${eventName}, deployHash: ${deploy.deployHash}` -// ); -// console.log(`Error: ${deploy.error}`); -// } -// } -// ); -// console.log("listener: ",listener); - -// await sleep(5 * 1000); - -// let accountInfo = await utils.getAccountInfo(NODE_ADDRESS!, KEYS.publicKey); - -// console.log(`... Account Info: `); -// console.log(JSON.stringify(accountInfo, null, 2)); - -// const contractHash = await utils.getAccountNamedKeyValue( -// accountInfo, -// "UniSwapRouter_contract_hash" -// ); - -// console.log(`... Contract Hash: ${contractHash}`); - -// //await uniswapRouter.setContractHash(contractHash.slice(5)); -// await uniswapRouter.setContractHash(CONTRACT_HASH!); - -// // Test add_liquidity -// //await add_liquidity(uniswapRouter); -// // const addLiquidityDeployHash = await uniswapRouter.add_liquidity( -// // KEYS, -// // TOKEN_A!, -// // TOKEN_B!, -// // AMOUNT_A_DESIRED!, -// // AMOUNT_B_DESIRED!, -// // AMOUNT_A_MIN!, -// // AMOUNT_B_MIN!, -// // TO!, -// // DEADLINE!, -// // PAIR_CONTRACT!, -// // ADD_LIQUIDITY_PAYMENT_AMOUNT! -// // ); -// // console.log("... Add Liquidity deploy hash: ", addLiquidityDeployHash); - -// // await getDeploy(NODE_ADDRESS!, addLiquidityDeployHash); -// // console.log("... Add Liquidity successfully called."); - -// // Test add_liquidity_cspr -// //add_liquidity_cspr(uniswapRouter); - -// // Test remove_liquidity -// // remove_liquidity(uniswapRouter); - -// // Test remove_liquidity_cspr -// //remove_liquidity_cspr(uniswapRouter); - -// // Test remove_liquidity_with_permit -// //remove_liquidity_with_permit(uniswapRouter); - -// // Test remove_liquidity_cspr_with_permit -// //remove_liquidity_cspr_with_permit(uniswapRouter); - -// // Test swap_exact_tokens_for_tokens -// //swap_exact_tokens_for_tokens(uniswapRouter); - -// // Test swap_tokens_for_exact_tokens -// //swap_tokens_for_exact_tokens(uniswapRouter); - -// // Test swap_exact_cspr_for_tokens -// //swap_exact_cspr_for_tokens(uniswapRouter); - -// // Test swap_tokens_for_exact_cspr -// //swap_tokens_for_exact_cspr(uniswapRouter); - -// // Test swap_exact_tokens_for_cspr -// //swap_exact_tokens_for_cspr(uniswapRouter); - -// //Test swap_cspr_for_exact_tokens -// // swap_cspr_for_exact_tokens(uniswapRouter); - -// // let register = await uniswapRouter.registerWebHook( -// // "http://localhost:5000/", -// // "http://localhost:5000/mockserver" -// // ); -// // console.log(`... Register Endpoint: ${register}`); - -// // let createPair = await uniswapRouter.CreatePairApi( -// // "c9d0268ecea8c57ed456bf56e4fba4bf285a4588fd817832230b8fd86b71c30f", -// // "fbfeda8b97f056f526f20c2fc2b486d9bdbfb3e46b9a164527e57c0c86e68612" -// // ); -// // console.log(`... Create Pair Endpoint: ${createPair}`); -// }; - const test = async () => { - const listener =uniswapRouter.onEvent( - [ - RouterEvents.PairCreated, - RouterEvents.Erc20Transfer, - RouterEvents.Transfer, - RouterEvents.Approval, - RouterEvents.Mint, - RouterEvents.Burn, - RouterEvents.Sync, - RouterEvents.Swap - ], - async (eventName, deploy, result) => { - if (deploy.success) { - console.log(`Successfull deploy of: ${eventName}, deployHash: ${deploy.deployHash}`); - - } else { - console.log(`Failed deploy of ${eventName}, deployHash: ${deploy.deployHash}`); - console.log(`Error: ${deploy.error}`); - } - } - ); - console.log("listener: ",listener); - - await sleep(5 * 1000); - - let accountInfo = await utils.getAccountInfo(NODE_ADDRESS!, KEYS.publicKey); - - console.log(`... Account Info: `); - console.log(JSON.stringify(accountInfo, null, 2)); - - const contractHash = await utils.getAccountNamedKeyValue( - accountInfo, - "UniSwapRouter_contract_hash" - ); - - console.log(`... Contract Hash: ${contractHash}`); - - //await uniswapRouter.setContractHash(contractHash.slice(5)); await uniswapRouter.setContractHash(CONTRACT_HASH!); // Test add_liquidity - //await add_liquidity(uniswapRouter); - const addLiquidityDeployHash = await uniswapRouter.add_liquidity( - KEYS, - TOKEN_A!, - TOKEN_B!, - AMOUNT_A_DESIRED!, - AMOUNT_B_DESIRED!, - AMOUNT_A_MIN!, - AMOUNT_B_MIN!, - TO!, - DEADLINE!, - PAIR_CONTRACT!, - ADD_LIQUIDITY_PAYMENT_AMOUNT! - ); - console.log("... Add Liquidity deploy hash: ", addLiquidityDeployHash); - - await getDeploy(NODE_ADDRESS!, addLiquidityDeployHash); - console.log("... Add Liquidity successfully called."); + await add_liquidity(uniswapRouter); // Test add_liquidity_cspr //add_liquidity_cspr(uniswapRouter); @@ -960,5 +528,4 @@ const test = async () => { }; -test(); -//test1(); +//test(); diff --git a/app.js b/app.js index 23452811..a4d1f296 100644 --- a/app.js +++ b/app.js @@ -9,6 +9,7 @@ const mongoose = require("mongoose"); require("dotenv").config(); const { graphqlHTTP } = require("express-graphql"); const schema = require("./graphql/schema"); +var listenerRouter = require('./routes/listenerroutes'); // view engine setup app.set('views', path.join(__dirname, 'views')); @@ -63,6 +64,7 @@ app.use((req, res, next) => { app.get("/", (req, res) => { res.json({ msg: "Uniswap V2 GraphQL Server" }); }); +app.use('/listener', listenerRouter); app.use('/graphql', graphqlHTTP({ schema: schema, diff --git a/models/pairs.js b/models/pairs.js new file mode 100644 index 00000000..3cea0e91 --- /dev/null +++ b/models/pairs.js @@ -0,0 +1,12 @@ +var mongoose = require('mongoose'); +var Schema = mongoose.Schema; + +const pairsSchema = new Schema({ + + id: {type: String, default: 'pair'}, + data: [{type: String}] + +}); + +var pairs = mongoose.model("pairs", pairsSchema); +module.exports = pairs; diff --git a/package-lock.json b/package-lock.json index 06a7d3e0..d39a5d59 100644 --- a/package-lock.json +++ b/package-lock.json @@ -254,6 +254,14 @@ "@types/webidl-conversions": "*" } }, + "@types/ws": { + "version": "8.2.2", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.2.tgz", + "integrity": "sha512-NOn5eIcgWLOo6qW8AcuLZ7G8PycXu0xTxxkS6Q18VWFxgPUSOwV0pBj2a/4viNZVu25i7RIB7GttdkAIUUXOOg==", + "requires": { + "@types/node": "*" + } + }, "@webassemblyjs/ast": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", @@ -688,12 +696,12 @@ } }, "browserslist": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.18.1.tgz", - "integrity": "sha512-8ScCzdpPwR2wQh8IT82CA2VgDwjHyqMovPBZSNH54+tm4Jk2pCuv90gmAdH6J84OCRWi0b4gMe6O6XPXuJnjgQ==", + "version": "4.19.1", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.19.1.tgz", + "integrity": "sha512-u2tbbG5PdKRTUoctO3NBD8FQ5HdPh1ZXPHzp1rwaa5jTc+RV9/+RlWiAIKmjRPQF+xbGM9Kklj5bZQFa2s/38A==", "requires": { - "caniuse-lite": "^1.0.30001280", - "electron-to-chromium": "^1.3.896", + "caniuse-lite": "^1.0.30001286", + "electron-to-chromium": "^1.4.17", "escalade": "^3.1.1", "node-releases": "^2.0.1", "picocolors": "^1.0.0" @@ -789,20 +797,21 @@ "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=" }, "caniuse-lite": { - "version": "1.0.30001285", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001285.tgz", - "integrity": "sha512-KAOkuUtcQ901MtmvxfKD+ODHH9YVDYnBt+TGYSz2KIfnq22CiArbUxXPN9067gNbgMlnNYRSwho8OPXZPALB9Q==" + "version": "1.0.30001286", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001286.tgz", + "integrity": "sha512-zaEMRH6xg8ESMi2eQ3R4eZ5qw/hJiVsO/HlLwniIwErij0JDr9P+8V4dtx1l+kLq6j3yy8l8W4fst1lBnat5wQ==" }, "casper-js-sdk": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/casper-js-sdk/-/casper-js-sdk-2.4.1.tgz", - "integrity": "sha512-89EZdwL8OAWP/SROWC7p6YzDKaCErOHlPRrkxvTnFw65QB2r4ow7BKNkYqJ8j69PBhKjPAk43mYRED3dIPM2Sg==", + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/casper-js-sdk/-/casper-js-sdk-2.7.3.tgz", + "integrity": "sha512-LChaBRgeSb0B3yQ9akppQLxbb+JdrpF35+YkE0Cndqho5v28MclVejxayD/Put0xSfwDMBRxKLh/ILNKUFsaTg==", "requires": { "@ethersproject/bignumber": "^5.0.8", "@ethersproject/bytes": "^5.0.5", "@ethersproject/constants": "^5.0.5", "@open-rpc/client-js": "^1.6.2", "@types/eccrypto": "^1.1.2", + "@types/ws": "^8.2.2", "blakejs": "^1.1.0", "eccrypto": "^1.1.6", "eslint-plugin-prettier": "^3.4.0", @@ -1202,9 +1211,9 @@ "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" }, "electron-to-chromium": { - "version": "1.4.12", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.12.tgz", - "integrity": "sha512-zjfhG9Us/hIy8AlQ5OzfbR/C4aBv1Dg/ak4GX35CELYlJ4tDAtoEcQivXvyBdqdNQ+R6PhlgQqV8UNPJmhkJog==" + "version": "1.4.17", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.17.tgz", + "integrity": "sha512-zhk1MravPtq/KBhmGB7TLBILmXTgRG9TFSI3qS3DbgyfHzIl72iiTE37r/BHIbPCJJlWIo5rySyxiH4vWhu2ZA==" }, "elliptic": { "version": "6.5.4", @@ -1548,9 +1557,9 @@ } }, "follow-redirects": { - "version": "1.14.5", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.5.tgz", - "integrity": "sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==" + "version": "1.14.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.6.tgz", + "integrity": "sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==" }, "form-data": { "version": "3.0.1", @@ -1930,9 +1939,9 @@ } }, "jest-worker": { - "version": "27.4.2", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.4.2.tgz", - "integrity": "sha512-0QMy/zPovLfUPyHuOuuU4E+kGACXXE84nRnq6lBVI9GJg5DCBiA97SATi+ZP8CpiJwEQy1oCPjRBf8AnLjN+Ag==", + "version": "27.4.5", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.4.5.tgz", + "integrity": "sha512-f2s8kEdy15cv9r7q4KkzGXvlY0JTcmCbMHZBfSQDwW77REr45IDWwd0lksDFeVHH2jJ5pqb90T77XscrjeGzzg==", "requires": { "@types/node": "*", "merge-stream": "^2.0.0", @@ -2166,20 +2175,20 @@ } }, "mongodb": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.1.4.tgz", - "integrity": "sha512-Cv/sk8on/tpvvqbEvR1h03mdyNdyvvO+WhtFlL4jrZ+DSsN/oSQHVqmJQI/sBCqqbOArFcYCAYDfyzqFwV4GSQ==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.2.1.tgz", + "integrity": "sha512-nDC+ulM/Ea3Q2VG5eemuGfB7T4ORwrtKegH2XW9OLlUBgQF6OTNrzFCS1Z3SJGVA+T0Sr1xBYV6DMnp0A7us0g==", "requires": { - "bson": "^4.5.4", + "bson": "^4.6.0", "denque": "^2.0.1", - "mongodb-connection-string-url": "^2.1.0", + "mongodb-connection-string-url": "^2.2.0", "saslprep": "^1.0.3" } }, "mongodb-connection-string-url": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.2.0.tgz", - "integrity": "sha512-U0cDxLUrQrl7DZA828CA+o69EuWPWEJTwdMPozyd7cy/dbtncUZczMw7wRHcwMD7oKOn0NM2tF9jdf5FFVW9CA==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.3.2.tgz", + "integrity": "sha512-2LkmS0ny7LamAyhEs2Q+zuFFxeGNSc2DaGHBevjqkoPt7bgh+67mg1sFU6awnMsdLKpdEt7zUy466K9x7RsYcQ==", "requires": { "@types/whatwg-url": "^8.2.1", "whatwg-url": "^11.0.0" @@ -2210,13 +2219,13 @@ } }, "mongoose": { - "version": "6.0.15", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.0.15.tgz", - "integrity": "sha512-Lr53MKrJ4XNTdsMkhOYxeBJClsV7pgwr2VFf7E8TK9Xh5hs2kzFF49jJv9i4CWcshmydcF8uDfaQ9sQlqzZoYw==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.1.1.tgz", + "integrity": "sha512-9IODOeFDxW0hzvGmE2Yvy/TaFGLIXQWgE/L1D/x3lKVo8PGyokklgnvX0/Qia7lxiZvxe6+na1aA7v0gT+TN+g==", "requires": { "bson": "^4.2.2", "kareem": "2.3.2", - "mongodb": "4.1.4", + "mongodb": "4.2.1", "mpath": "0.8.4", "mquery": "4.0.0", "ms": "2.1.2", diff --git a/package.json b/package.json index 307c66a0..f33490d6 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ }, "dependencies": { "axios": "^0.24.0", - "casper-js-sdk": "2.4.1", + "casper-js-sdk": "^2.7.2", "cookie-parser": "~1.4.4", "debug": "~2.6.9", "dotenv": "^10.0.0", diff --git a/routes/listenerroutes.js b/routes/listenerroutes.js new file mode 100644 index 00000000..c527d8f1 --- /dev/null +++ b/routes/listenerroutes.js @@ -0,0 +1,423 @@ +require('dotenv').config() +var express = require('express'); +var router = express.Router(); +const axios = require('axios').default; +var {request} = require('graphql-request'); +var pairsModel=require('../models/pairs'); + +function splitdata(data) +{ + var temp=data.split('('); + var result=temp[1].split(')'); + return result[0]; +} +router.route("/addpaircontractandpackageHash").post(async function (req, res, next) { + try { + + if(!req.body.ContractHash) + { + return res.status(400).json({ + success: false, + message: "There is no contractHash specified in the req body.", + }); + } + if(!req.body.PackageHash) + { + return res.status(400).json({ + success: false, + message: "There is no PackageHash specified in the req body.", + }); + } + var pairsresult=await pairsModel.findOne({id:"pair"}); + var temp = pairsresult.data; + temp[req.body.PackageHash] = req.body.ContractHash; + + if(pairsresult==null) + { + var newpair = new pairsModel({ + data:temp + }); + + await pairsModel.create(newpair); + } + else{ + pairsresult.data=temp; + await pairsresult.save(); + } + + + return res.status(200).json({ + success: true, + message: "Pair's Contract and Package Hash are Succefully stored.", + }); + + } catch (error) { + console.log("error (try-catch) : " + error); + return res.status(500).json({ + success: false, + err: error, + }); + } +}); + +router.route("/startListener").post(async function (req, res, next) { + try { + + if(!req.body.contractPackageHashes) + { + return res.status(400).json({ + success: false, + message: "There is no contractPackageHash specified in the req body.", + }); + } + + axios.post('http://localhost:3001/initiateListener', { + contractPackageHashes: req.body.contractPackageHashes + }) + .then(function (response) { + console.log(response); + return res.status(200).json({ + success: true, + message: response.data.message, + status: response.data.status + }); + + }) + .catch(function (error) { + console.log(error); + }); + + } catch (error) { + console.log("error (try-catch) : " + error); + return res.status(500).json({ + success: false, + err: error, + }); + } +}); + +router.route("/geteventsdata").post(async function (req, res, next) { + try { + + if(!req.body.deployHash) + { + return res.status(400).json({ + success: false, + message: "There is no deployHash specified in the req body.", + }); + } + if(!req.body.timestamp) + { + return res.status(400).json({ + success: false, + message: "There is no timestamp specified in the req body.", + }); + } + if(!req.body.block_hash) + { + return res.status(400).json({ + success: false, + message: "There is no blockHash specified in the req body.", + }); + } + if(!req.body.eventname) + { + return res.status(400).json({ + success: false, + message: "There is no eventname specified in the req body.", + }); + } + if(!req.body.eventdata) + { + return res.status(400).json({ + success: false, + message: "There is no eventdata specified in the req body.", + }); + } + + let newData=req.body.eventdata; + let deployHash=req.body.deployHash; + let timestamp=req.body.timestamp; + let block_hash=req.body.block_hash; + let eventName=req.body.eventname; + console.log("... Deployhash: ", deployHash); + console.log("... Timestamp: ", timestamp); + console.log("... Block hash: ", block_hash); + console.log("Event Data: ",newData); + + if(eventName =="pair_created") + { + 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(process.env.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 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) + { + var pairsresult=await pairsModel.findOne({id:"pair"}); + var to_contractHash=pairsresult.data[to]; + if(to_contractHash==null) + { + console.log("contract hash did not find at this package hash."); + return; + } + request(process.env.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_contractHash, deployHash:deployHash,timeStamp:timestamp.toString(), blockHash:block_hash}) + .then(data => console.log(data)) + .catch(error => console.error(error)); + } + + } + else if(eventName=="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); + console.log(newData[5][0].data + " = " + newData[5][1].data); + + var from=splitdata(newData[2][1].data); + var to=splitdata(newData[4][1].data); + var value=parseInt(newData[5][1].data); + var pair=splitdata(newData[3][1].data); + + console.log("from: ", from); + console.log("to: ", to); + console.log("value: ",value); + console.log("pair: ", pair); + + request(process.env.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: pair, deployHash:deployHash,timeStamp:timestamp.toString(), blockHash:block_hash}) + .then(data => console.log(data)) + .catch(error => console.error(error)); + } + else if (eventName=="mint") + { + + 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 amount0=parseInt(newData[0][1].data); + var amount1=parseInt(newData[1][1].data); + var pair=splitdata(newData[4][1].data); + var sender=splitdata(newData[5][1].data); + + console.log("amount0: ", amount0); + console.log("amount1: ", amount1); + console.log("pair: ",pair); + console.log("sender: ", sender); + + request(process.env.GRAPHQL, + `mutation handleMint( $amount0: Int!, $amount1: Int!, $sender: String!,$logIndex: Int!, $pairAddress: String!, $deployHash: String!, $timeStamp: String!, $blockHash: String!){ + handleMint( amount0: $amount0, amount1: $amount1, sender: $sender, logIndex: $logIndex, pairAddress: $pairAddress, deployHash: $deployHash, timeStamp: $timeStamp, blockHash: $blockHash) { + result + } + + }`, + {amount0:amount0, amount1: amount1, sender: sender,logIndex:0, pairAddress: pair, deployHash:deployHash,timeStamp:timestamp.toString(), blockHash:block_hash}) + .then(data => console.log(data)) + .catch(error => console.error(error)); + } + else if (eventName=="burn") + { + + 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); + console.log(newData[6][0].data + " = " + newData[6][1].data); + + var amount0=parseInt(newData[0][1].data); + var amount1=parseInt(newData[1][1].data); + var pair=splitdata(newData[4][1].data); + var sender=splitdata(newData[5][1].data); + var to=splitdata(newData[6][1].data); + + console.log("amount0: ", amount0); + console.log("amount1: ", amount1); + console.log("pair: ",pair); + console.log("sender: ", sender); + console.log("to: ", to); + + request(process.env.GRAPHQL, + `mutation handleBurn( $amount0: Int!, $amount1: Int!, $sender: String!,$logIndex: Int!,$to: String!, $pairAddress: String!, $deployHash: String!, $timeStamp: String!, $blockHash: String!){ + handleBurn( amount0: $amount0, amount1: $amount1, sender: $sender, logIndex: $logIndex, to:$to, pairAddress: $pairAddress, deployHash: $deployHash, timeStamp: $timeStamp, blockHash: $blockHash) { + result + } + + }`, + {amount0:amount0, amount1: amount1, sender: sender,logIndex:0, to:to,pairAddress: pair, deployHash:deployHash,timeStamp:timestamp.toString(), blockHash:block_hash}) + .then(data => console.log(data)) + .catch(error => console.error(error)); + } + else if (eventName=="sync") + { + + 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 reserve0=parseInt(newData[3][1].data); + var reserve1=parseInt(newData[4][1].data); + var pair=splitdata(newData[2][1].data); + + console.log("reserve0: ", reserve0); + console.log("reserve1: ", reserve1); + console.log("pair: ",pair); + + + request(process.env.GRAPHQL, + `mutation handleSync( $reserve0: Int!, $reserve1: Int!, $pairAddress: String!){ + handleSync( reserve0: $reserve0, reserve1: $reserve1, pairAddress: $pairAddress) { + result + } + + }`, + {reserve0:reserve0, reserve1: reserve1, pairAddress: pair}) + .then(data => console.log(data)) + .catch(error => console.error(error)); + } + else if (eventName=="swap") + { + + 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); + console.log(newData[6][0].data + " = " + newData[6][1].data); + console.log(newData[7][0].data + " = " + newData[7][1].data); + console.log(newData[8][0].data + " = " + newData[8][1].data); + console.log(newData[9][0].data + " = " + newData[9][1].data); + + var amount0In=parseInt(newData[0][1].data); + var amount1In=parseInt(newData[1][1].data); + var amount0Out=parseInt(newData[2][1].data); + var amount1Out=parseInt(newData[3][1].data); + var from=splitdata(newData[6][1].data); + var pair=splitdata(newData[7][1].data); + var sender=splitdata(newData[8][1].data); + var to=splitdata(newData[9][1].data); + + console.log("amount0In: ", amount0In); + console.log("amount1In: ", amount1In); + console.log("amount0Out: ", amount0Out); + console.log("amount1Out: ", amount1Out); + console.log("from: ",from); + console.log("pair: ",pair); + console.log("sender: ", sender); + console.log("to: ", to); + + request(process.env.GRAPHQL, + `mutation handleSwap( $amount0In: Int!, $amount1In: Int!, $amount0Out: Int!, $amount1Out: Int!, $to: String!,$from: String!,$sender: String!,$logIndex: Int!, $pairAddress: String!, $deployHash: String!, $timeStamp: String!, $blockHash: String!){ + handleSwap( amount0In: $amount0In, amount1In: $amount1In, amount0Out: $amount0Out, amount1Out: $amount1Out, to:$to, from:$from,sender: $sender,logIndex: $logIndex, pairAddress: $pairAddress, deployHash: $deployHash, timeStamp: $timeStamp, blockHash: $blockHash) { + result + } + + }`, + {amount0In:amount0In, amount1In: amount1In,amount0Out:amount0Out, amount1Out: amount1Out,to:to,from:from, sender: sender,logIndex:0,pairAddress: pair, deployHash:deployHash,timeStamp:timestamp.toString(), blockHash:block_hash}) + .then(data => console.log(data)) + .catch(error => console.error(error)); + } + + return res.status(200).json({ + success: true, + message: "Mutation called according to received event." + }); + + } catch (error) { + console.log("error (try-catch) : " + error); + return res.status(500).json({ + success: false, + err: error, + }); + } +}); + +module.exports = router; diff --git a/test.js b/test.js index 7776121f..2e27a1a9 100644 --- a/test.js +++ b/test.js @@ -3,4 +3,8 @@ function splitdata(data) var temp=data.split('('); var result=temp[1].split(')'); return result[0]; -} \ No newline at end of file +} + +var date = new Date("2021-12-14T18:42:24.445Z"); +var seconds = date.getTime(); +console.log("time: ",seconds);