diff --git a/.env b/.env index 2ca2190d..377fd30a 100644 --- a/.env +++ b/.env @@ -1,13 +1,14 @@ 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?retryWrites=true&w=majority +DATABASE_URL_ONLINE=mongodb+srv://admin:scytalelabs@cluster0-9yop5.mongodb.net/V2-graphQL-backend-demo?retryWrites=true&w=majority -FACTORY_CONTRACT=735edd4bb553cb8ef4408becbce9e5564a92d97094245c9d2d6ff2bbe6ceda43 -PAIR_CONTRACT=c667c7c29947b3500406a79ec47947d7eb320e92a00c68351eaa7c7bc96e3d31 -PAIR_CONTRACT_PACKAGE=106dbf09aac7eb0ed2d41f4026fe2d8cd5f492b17c5050db9c519591c6dd7d7c +FACTORY_CONTRACT=A1536f887a6dFB2B2fa00C9beAc21324AaD0F880d36926010e355A1F4C1616ee +PAIR_CONTRACT=8A56313004fFa242eB9D197A232aFf6eE19507847F3151064e5ff334935cf02D +PAIR_CONTRACT_PACKAGE=57f8a52b960485c9c5111b33660cdF29FB543A754ec341caB5829CC49EB644c3 CALLEE_CONTRACT=fbfeda8b97f056f526f20c2fc2b486d9bdbfb3e46b9a164527e57c0c86e68612 -TOKEN0_CONTRACT=f5b45ffd5273c94befa572ca4b3f05a57892611aa7c668a021eed2be93e9b76e -TOKEN1_CONTRACT=c5afe9ac0deddaf3090603b1cc1b71b9c030218ff97f7c4067a48402803fea16 +TOKEN0_CONTRACT=39cc3cEE8D8Be3A1B0cDE77d857cAa1d28f3061A54c053da2585CfDFF486b0E1 +TOKEN1_CONTRACT=464AB6d2Fad52DB31cD2e11D7F30Ce4E998bd37b4321243925D9846011e0b13B +TOKEN1_CONTRACT_PACKAGE=7D379F70A50458Bd1593E9c1317A7110B1AebBd926E331618f45bFbd4e119B0B GRAPHQL=http://localhost:3000/graphql CHAIN_NAME=casper-test @@ -26,7 +27,7 @@ PAIR_MASTER_KEY_PAIR_PATH=JsClients/PAIR/keys/ MASTER_KEY_PAIR_PATH=JsClients/ROUTER/keys/ ERC20_CONTRACT_NAME=erc20 -ERC20_TOKEN_NAME=token0 +ERC20_TOKEN_NAME=token1 ERC20_TOKEN_SYMBOL=erc ERC20_DECIMALS=18 ERC20_TOTAL_SUPPLY=0 @@ -41,10 +42,10 @@ FACTORY_CONTRACT_NAME=Factory ERC20_INSTALL_PAYMENT_AMOUNT=170000000000 FACTORY_INSTALL_PAYMENT_AMOUNT=110000000000 -PAIR_INSTALL_PAYMENT_AMOUNT=230000000000 +PAIR_INSTALL_PAYMENT_AMOUNT=300000000000 MINT_PAYMENT_AMOUNT=5000000000 -MINT_AMOUNT=100 +MINT_AMOUNT=1000 BURN_PAYMENT_AMOUNT=5000000000 BURN_AMOUNT=5 @@ -78,12 +79,13 @@ TOKEN_NAME=uniswap-router TOKEN_SYMBOL=DRAG TOKEN_META=origin fire,lifetime infinite -FACTORY=c2b7c5cd223a6bdf18ac363ff0d808c92cf3eb95ca3f54264d7285a0aa1a74fe -WCSPR=f08f486ae224a551e0a383e195fa9504d0a70686a11c462f0a8599a75a45bc04 -LIBRARY=301167268ec00eeb7edf7d12d9419921e15dbd7b145e454d94540aa91c260edb -CONTRACT_NAME=UniswapRouter +FACTORY=A1536f887a6dFB2B2fa00C9beAc21324AaD0F880d36926010e355A1F4C1616ee +WCSPR=bA8f6a73B6D548E2CAe2d572aA2F824BC46A3C06a3BBA10e3d12B015931D3f85 +LIBRARY=e0Dae7571C3dc5C957a36422c56BA0ccb8AECEC833F35e32874b75A8Ea8Ac4Db +CONTRACT_NAME=UniSwapRouter -CONTRACT_HASH=8ce941b03b71dfbf65261e662fd5b47c78e9156ed4b048acdd33ef1934b26e79 +CONTRACT_HASH=2634C8f75Db583C65b9Beb55aBf8339294F2728Cf05c478fe13B239E7916aa36 +PACKAGE_HASH=B51E1CE9a31f948119e5699D24C943Bc16024C81caD1A7dFD9119aFD791eD5C5 INSTALL_PAYMENT_AMOUNT=200000000000 MINT_ONE_PAYMENT_AMOUNT=2000000000 MINT_COPIES_PAYMENT_AMOUNT=100000000000 @@ -94,13 +96,13 @@ MINT_COPIES_COUNT=20 MINT_MANY_META_SIZE=5 MINT_MANY_META_COUNT=5 -TO = 301167268ec00eeb7edf7d12d9419921e15dbd7b145e454d94540aa91c260edb -DEADLINE = 1642699999000 +TO = 39cc3cEE8D8Be3A1B0cDE77d857cAa1d28f3061A54c053da2585CfDFF486b0E1 +DEADLINE = 1638974538161 # add_liquidity -TOKEN_A = 301167268ec00eeb7edf7d12d9419921e15dbd7b145e454d94540aa91c260edb -TOKEN_B = 301167268ec00eeb7edf7d12d9419921e15dbd7b145e454d94540aa91c260edb +TOKEN_A = 39cc3cEE8D8Be3A1B0cDE77d857cAa1d28f3061A54c053da2585CfDFF486b0E1 +TOKEN_B = 464AB6d2Fad52DB31cD2e11D7F30Ce4E998bd37b4321243925D9846011e0b13B AMOUNT_A_DESIRED = 500 AMOUNT_B_DESIRED = 600 AMOUNT_A_MIN = 250 @@ -113,7 +115,7 @@ AMOUNT_TOKEN_DESIRED = 500 AMOUNT_CSPR_DESIRED = 600 AMOUNT_TOKEN_MIN = 250 AMOUNT_CSPR_MIN = 300 - +ADD_LIQUIDITY_PAYMENT_AMOUNT=20000000000 # remove_liquidiy diff --git a/JsClients/ERC20/keys/public_key.pem b/JsClients/ERC20/keys/public_key.pem index 5ca809ed..fa54c859 100644 --- a/JsClients/ERC20/keys/public_key.pem +++ b/JsClients/ERC20/keys/public_key.pem @@ -1,3 +1,3 @@ -----BEGIN PUBLIC KEY----- -MCowBQYDK2VwAyEAmYl/IwN4hACVTqvQyFqUb6Xz3ewXk8Kkvq+pnmMtLLw= +MCowBQYDK2VwAyEA9iX2/XqEmzD9Oxj78Pgk5No8MMtqPOVslG73VeXB7wA= -----END PUBLIC KEY----- diff --git a/JsClients/ERC20/keys/public_key_hex b/JsClients/ERC20/keys/public_key_hex index 22471566..5c1e875c 100644 --- a/JsClients/ERC20/keys/public_key_hex +++ b/JsClients/ERC20/keys/public_key_hex @@ -1 +1 @@ -0199897f2303788400954eabd0c85a946fa5f3ddec1793c2a4beafa99e632d2cbc \ No newline at end of file +01f625f6fd7a849b30fd3b18fbf0f824e4da3c30cb6a3ce56c946ef755e5c1ef00 \ No newline at end of file diff --git a/JsClients/ERC20/keys/secret_key.pem b/JsClients/ERC20/keys/secret_key.pem index 8e10de51..94c511d3 100644 --- a/JsClients/ERC20/keys/secret_key.pem +++ b/JsClients/ERC20/keys/secret_key.pem @@ -1,3 +1,3 @@ -----BEGIN PRIVATE KEY----- -MC4CAQAwBQYDK2VwBCIEIHNb3AdH407fuI6D2jQSVh4xwPIl5V2RNr2hB5Ynd3ST +MC4CAQAwBQYDK2VwBCIEIN7jOxtBNk251SUMGNb3UScLr35+K9ehtphiKYPqaxDW -----END PRIVATE KEY----- diff --git a/JsClients/ERC20/src/erc20.ts b/JsClients/ERC20/src/erc20.ts index 2a44e04d..92ca2840 100644 --- a/JsClients/ERC20/src/erc20.ts +++ b/JsClients/ERC20/src/erc20.ts @@ -209,13 +209,16 @@ class ERC20Client { public async approve( keys: Keys.AsymmetricKey, - spender: RecipientType, + spender: string, amount: string, paymentAmount: string ) { + const _spender = new CLByteArray( + Uint8Array.from(Buffer.from(spender, "hex")) + ); const runtimeArgs = RuntimeArgs.fromMap({ - spender: utils.createRecipientAddress(spender), + spender: utils.createRecipientAddress(_spender), amount: CLValueBuilder.u256(amount) }); diff --git a/JsClients/ERC20/test/install.ts b/JsClients/ERC20/test/install.ts index 6b6915ed..1b2a01c7 100644 --- a/JsClients/ERC20/test/install.ts +++ b/JsClients/ERC20/test/install.ts @@ -33,22 +33,22 @@ const test = async () => { EVENT_STREAM_ADDRESS! ); - const installDeployHash = await erc20.install( - KEYS, - ERC20_TOKEN_NAME!, - ERC20_TOKEN_SYMBOL!, - ERC20_DECIMALS!, - ERC20_TOTAL_SUPPLY!, - ERC20_CONTRACT_NAME!, - ERC20_INSTALL_PAYMENT_AMOUNT!, - ERC20_WASM_PATH! - ); + // const installDeployHash = await erc20.install( + // KEYS, + // ERC20_TOKEN_NAME!, + // ERC20_TOKEN_SYMBOL!, + // ERC20_DECIMALS!, + // ERC20_TOTAL_SUPPLY!, + // ERC20_CONTRACT_NAME!, + // ERC20_INSTALL_PAYMENT_AMOUNT!, + // ERC20_WASM_PATH! + // ); - console.log(`... Contract installation deployHash: ${installDeployHash}`); + // console.log(`... Contract installation deployHash: ${installDeployHash}`); - await getDeploy(NODE_ADDRESS!, installDeployHash); + // await getDeploy(NODE_ADDRESS!, installDeployHash); - console.log(`... Contract installed successfully.`); + // console.log(`... Contract installed successfully.`); let accountInfo = await utils.getAccountInfo(NODE_ADDRESS!, KEYS.publicKey); @@ -62,6 +62,12 @@ const test = async () => { console.log(`... Contract Hash: ${contractHash}`); + const packageHash = await utils.getAccountNamedKeyValue( + accountInfo, + `${ERC20_CONTRACT_NAME!}_package_hash` + ); + + console.log(`... Contract Hash: ${packageHash}`); }; //test(); diff --git a/JsClients/ERC20/test/installed.ts b/JsClients/ERC20/test/installed.ts index 86dfd4ea..968e01c2 100644 --- a/JsClients/ERC20/test/installed.ts +++ b/JsClients/ERC20/test/installed.ts @@ -32,7 +32,11 @@ const { TRANSFER_FROM_AMOUNT, TOKEN0_CONTRACT, TOKEN1_CONTRACT, - PAIR_CONTRACT + TOKEN1_CONTRACT_PACKAGE, + PAIR_CONTRACT, + PACKAGE_HASH, + AMOUNT_A_DESIRED, + AMOUNT_B_DESIRED } = process.env; @@ -127,20 +131,20 @@ const test = async () => { // // // let allowance = await erc20.allowance(KEYS.publicKey,KEYS.publicKey); // // // console.log(`... Allowance: ${allowance}`); - // //mint - // // const mintDeployHash = await erc20.mint( - // // KEYS, - // // PAIR_CONTRACT!, - // // MINT_AMOUNT!, - // // MINT_PAYMENT_AMOUNT! - // // ); - // // console.log("... Mint deploy hash: ", mintDeployHash); + //mint + const mintDeployHash = await erc20.mint( + KEYS, + PACKAGE_HASH!, + MINT_AMOUNT!, + MINT_PAYMENT_AMOUNT! + ); + console.log("... Mint deploy hash: ", mintDeployHash); - // // await getDeploy(NODE_ADDRESS!, mintDeployHash); + await getDeploy(NODE_ADDRESS!, mintDeployHash); - // // //balanceof - // // let balance = await erc20.balanceOfcontract(PAIR_CONTRACT!); - // // console.log(`... Balance: ${balance}`); + //balanceof + // let balance = await erc20.balanceOfcontract(PAIR_CONTRACT!); + // console.log(`... Balance: ${balance}`); // // //burn // // const burnDeployHash = await erc20.burn( @@ -159,16 +163,16 @@ const test = async () => { // // console.log(`... Total supply: ${totalSupply}`); //approve - const approveDeployHash = await erc20.approve( - KEYS, - KEYS.publicKey, - APPROVE_AMOUNT!, - APPROVE_PAYMENT_AMOUNT! - ); - console.log("... Approve deploy hash: ", approveDeployHash); - - await getDeploy(NODE_ADDRESS!, approveDeployHash); - console.log("... Token approved successfully"); + // const approveDeployHash = await erc20.approve( + // KEYS, + // PACKAGE_HASH!, + // AMOUNT_B_DESIRED!, + // APPROVE_PAYMENT_AMOUNT! + // ); + // console.log("... Approve deploy hash: ", approveDeployHash); + + // await getDeploy(NODE_ADDRESS!, approveDeployHash); + // console.log("... Token approved successfully"); // // //transfer // // const transferDeployHash = await erc20.transfer( diff --git a/JsClients/ERC20/wasm/erc20-token.wasm b/JsClients/ERC20/wasm/erc20-token.wasm index dc7d747b..f5a5d7a8 100755 Binary files a/JsClients/ERC20/wasm/erc20-token.wasm and b/JsClients/ERC20/wasm/erc20-token.wasm differ diff --git a/JsClients/FACTORY/wasm/factory.wasm b/JsClients/FACTORY/wasm/factory.wasm index 611c315e..77570a0f 100755 Binary files a/JsClients/FACTORY/wasm/factory.wasm and b/JsClients/FACTORY/wasm/factory.wasm differ diff --git a/JsClients/PAIR/wasm/pair-token.wasm b/JsClients/PAIR/wasm/pair-token.wasm index d62bcc42..4edc4bea 100755 Binary files a/JsClients/PAIR/wasm/pair-token.wasm and b/JsClients/PAIR/wasm/pair-token.wasm differ diff --git a/JsClients/ROUTER/keys/public_key.pem b/JsClients/ROUTER/keys/public_key.pem index b029671b..3284ec13 100644 --- a/JsClients/ROUTER/keys/public_key.pem +++ b/JsClients/ROUTER/keys/public_key.pem @@ -1,3 +1,3 @@ -----BEGIN PUBLIC KEY----- -MCowBQYDK2VwAyEAwrapZ6QuZF+X1hsNluiXmdCWRAc+syfKTmQ9Tau9NPE= +MCowBQYDK2VwAyEAthNmFRj3BJMomJHAxiMgeSxjVjCUIWeyYhJ7lmQAEVA= -----END PUBLIC KEY----- diff --git a/JsClients/ROUTER/keys/public_key_hex b/JsClients/ROUTER/keys/public_key_hex index 781fa1fa..ab6c1294 100644 --- a/JsClients/ROUTER/keys/public_key_hex +++ b/JsClients/ROUTER/keys/public_key_hex @@ -1 +1 @@ -01c2b6a967a42e645f97d61b0d96e89799d09644073eb327ca4e643d4dabbd34f1 \ No newline at end of file +01b613661518f70493289891c0c62320792c635630942167b262127b9664001150 \ No newline at end of file diff --git a/JsClients/ROUTER/keys/secret_key.pem b/JsClients/ROUTER/keys/secret_key.pem index d6d1434c..cd75b517 100644 --- a/JsClients/ROUTER/keys/secret_key.pem +++ b/JsClients/ROUTER/keys/secret_key.pem @@ -1,3 +1,3 @@ -----BEGIN PRIVATE KEY----- -MC4CAQAwBQYDK2VwBCIEIH+6suzRo2fHjw2YK+ffdBcIxoFYrugGW6smkIxCFNH0 +MC4CAQAwBQYDK2VwBCIEIN8sMjQ9ZVBJcdk/Gvx/HK+pj14d/5XhrTYk8ZxrGB2J -----END PRIVATE KEY----- diff --git a/JsClients/ROUTER/src/constants.ts b/JsClients/ROUTER/src/constants.ts index cbee4de5..b8c698e3 100644 --- a/JsClients/ROUTER/src/constants.ts +++ b/JsClients/ROUTER/src/constants.ts @@ -1,6 +1,7 @@ export enum RouterEvents { PairCreated="pair_created", Approval = 'approve', + Erc20Transfer='erc20_transfer', Transfer = 'transfer', Mint = 'mint', Burn = 'burn', diff --git a/JsClients/ROUTER/src/uniswap-router-client.ts b/JsClients/ROUTER/src/uniswap-router-client.ts index 1ac1c1bb..3e0badd4 100644 --- a/JsClients/ROUTER/src/uniswap-router-client.ts +++ b/JsClients/ROUTER/src/uniswap-router-client.ts @@ -19,6 +19,8 @@ import { CLKeyType, CLList, CLBoolBytesParser, + CLOption, + CLOptionType } from "casper-js-sdk"; import { Some, None } from "ts-results"; import { RouterEvents } from "./constants"; @@ -29,8 +31,8 @@ const axios = require("axios").default; class UniswapRouterClient { private contractName: string = "uniswap_router"; - private contractHash: string; // Hash type is string - private contractPackageHash: string; + private contractHash: string= "uniswap_router"; // Hash type is string + private contractPackageHash: string= "uniswap_router"; private namedKeys: { balances: string; metadata: string; @@ -45,7 +47,15 @@ class UniswapRouterClient { private nodeAddress: string, private chainName: string, private eventStreamAddress?: string - ) {} + ) { + this.namedKeys= { + balances:"null", + metadata: "null", + ownedTokens: "null", + owners: "null", + paused: "null" + }; + } public async install( keys: Keys.AsymmetricKey, // Have Public/Private Key Pair @@ -130,6 +140,7 @@ class UniswapRouterClient { amount_b_min: string, to: string, deadline: string, + pair_hash:string, paymentAmount: string ) { const _token_a = new CLByteArray( @@ -140,6 +151,10 @@ class UniswapRouterClient { ); const _to = new CLByteArray(Uint8Array.from(Buffer.from(to, "hex"))); + const pair = new CLByteArray( + Uint8Array.from(Buffer.from(pair_hash, "hex")) + ); + const runtimeArgs = RuntimeArgs.fromMap({ token_a: new CLKey(_token_a), token_b: new CLKey(_token_b), @@ -149,12 +164,13 @@ class UniswapRouterClient { amount_b_min: CLValueBuilder.u256(amount_b_min), to: utils.createRecipientAddress(_to), deadline: CLValueBuilder.u256(deadline), + pair: new CLOption(Some(new CLKey(pair))) }); const deployHash = await contractCall({ chainName: this.chainName, contractHash: this.contractHash, - entryPoint: "add_liquidity", + entryPoint: "add_liquidity_js_client", keys, nodeAddress: this.nodeAddress, paymentAmount, @@ -163,6 +179,7 @@ class UniswapRouterClient { if (deployHash !== null) { this.addPendingDeploy(RouterEvents.PairCreated, deployHash); + this.addPendingDeploy(RouterEvents.Erc20Transfer, deployHash); this.addPendingDeploy(RouterEvents.Transfer, deployHash); this.addPendingDeploy(RouterEvents.Sync, deployHash); this.addPendingDeploy(RouterEvents.Mint, deployHash); diff --git a/JsClients/ROUTER/test/install.ts b/JsClients/ROUTER/test/install.ts index 6db58e63..f02a7616 100644 --- a/JsClients/ROUTER/test/install.ts +++ b/JsClients/ROUTER/test/install.ts @@ -85,10 +85,17 @@ const test = async () => { const contractHash = await utils.getAccountNamedKeyValue( accountInfo, - `${TOKEN_NAME!}_contract` + `${CONTRACT_NAME!}_contract_hash` ); console.log(`... Contract Hash: ${contractHash}`); + + const packageHash = await utils.getAccountNamedKeyValue( + accountInfo, + `${CONTRACT_NAME!}_package_hash` + ); + + console.log(`... Package Hash: ${packageHash}`); }; //test(); diff --git a/JsClients/ROUTER/test/installed.ts b/JsClients/ROUTER/test/installed.ts index 632ea407..0fe2523f 100644 --- a/JsClients/ROUTER/test/installed.ts +++ b/JsClients/ROUTER/test/installed.ts @@ -11,6 +11,7 @@ import { CLAccountHash, CLPublicKeyType, } from "casper-js-sdk"; +import { isCombinedNodeFlagSet } from "tslint"; const { RouterEvents } = constants; @@ -28,7 +29,7 @@ const { CONTRACT_NAME, CONTRACT_HASH, INSTALL_PAYMENT_AMOUNT, - + PAIR_CONTRACT, TO, DEADLINE, @@ -39,6 +40,7 @@ const { AMOUNT_B_DESIRED, AMOUNT_A_MIN, AMOUNT_B_MIN, + ADD_LIQUIDITY_PAYMENT_AMOUNT, // add_liquidity_cspr TOKEN, @@ -274,7 +276,8 @@ const add_liquidity_test = async (uniswapRouter: UniswapRouterClient) => { AMOUNT_B_MIN!, TO!, DEADLINE!, - INSTALL_PAYMENT_AMOUNT! + PAIR_CONTRACT!, + ADD_LIQUIDITY_PAYMENT_AMOUNT! ); }; @@ -483,6 +486,7 @@ const test = async () => { const listener = uniswapRouter.onEvent( [ RouterEvents.PairCreated, + RouterEvents.Erc20Transfer, RouterEvents.Transfer, RouterEvents.Approval, RouterEvents.Mint, @@ -540,6 +544,46 @@ const test = async () => { 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: "); @@ -721,24 +765,25 @@ const test = async () => { } } ); - // await sleep(5 * 1000); + await sleep(5 * 1000); - // let accountInfo = await utils.getAccountInfo(NODE_ADDRESS!, KEYS.publicKey); + let accountInfo = await utils.getAccountInfo(NODE_ADDRESS!, KEYS.publicKey); - // console.log(`... Account Info: `); - // console.log(JSON.stringify(accountInfo, null, 2)); + 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}`); + const contractHash = await utils.getAccountNamedKeyValue( + accountInfo, + "UniSwapRouter_contract_hash" + ); - // await uniswapRouter.setContractHash(contractHash.slice(5)); + console.log(`... Contract Hash: ${contractHash}`); + //await uniswapRouter.setContractHash(contractHash.slice(5)); + await uniswapRouter.setContractHash(CONTRACT_HASH!); + // Test add_liquidity - //add_liquidity(uniswapRouter); + add_liquidity(uniswapRouter); // Test add_liquidity_cspr //add_liquidity_cspr(uniswapRouter); diff --git a/JsClients/ROUTER/wasm/uniswap-v2-router.wasm b/JsClients/ROUTER/wasm/uniswap-v2-router.wasm new file mode 100644 index 00000000..e71bd0b1 Binary files /dev/null and b/JsClients/ROUTER/wasm/uniswap-v2-router.wasm differ diff --git a/package-lock.json b/package-lock.json index 0e10c652..06a7d3e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -187,9 +187,9 @@ } }, "@types/eslint": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.2.0.tgz", - "integrity": "sha512-74hbvsnc+7TEDa1z5YLSe4/q8hGYB3USNvCuzHUJrjPV6hXaq8IXcngCrHkuvFt0+8rFz7xYXrHgNayIX0UZvQ==", + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.2.1.tgz", + "integrity": "sha512-UP9rzNn/XyGwb5RQ2fok+DzcIRIYwc16qTXse5+Smsy8MOIccCChT15KAwnsgQx4PzJkaMq4myFyZ4CL5TjhIQ==", "requires": { "@types/estree": "*", "@types/json-schema": "*" @@ -220,9 +220,9 @@ "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==" }, "@types/node": { - "version": "16.11.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.11.tgz", - "integrity": "sha512-KB0sixD67CeecHC33MYn+eYARkqTheIRNuu97y2XMjR7Wu3XibO1vaY6VBV6O/a89SPI81cEUIYT87UqUWlZNw==" + "version": "16.11.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.12.tgz", + "integrity": "sha512-+2Iggwg7PxoO5Kyhvsq9VarmPbIelXP070HMImEpbtGCoyWNINQj4wzjbQCXzdHTRXnqufutJb5KAURZANNBAw==" }, "@types/pbkdf2": { "version": "3.1.0", @@ -539,6 +539,14 @@ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, + "axios": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", + "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", + "requires": { + "follow-redirects": "^1.14.4" + } + }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -781,9 +789,9 @@ "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=" }, "caniuse-lite": { - "version": "1.0.30001284", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001284.tgz", - "integrity": "sha512-t28SKa7g6kiIQi6NHeOcKrOrGMzCRrXvlasPwWC26TH2QNdglgzQIRUuJ0cR3NeQPH+5jpuveeeSFDLm2zbkEw==" + "version": "1.0.30001285", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001285.tgz", + "integrity": "sha512-KAOkuUtcQ901MtmvxfKD+ODHH9YVDYnBt+TGYSz2KIfnq22CiArbUxXPN9067gNbgMlnNYRSwho8OPXZPALB9Q==" }, "casper-js-sdk": { "version": "2.4.1", @@ -1194,9 +1202,9 @@ "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" }, "electron-to-chromium": { - "version": "1.4.10", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.10.tgz", - "integrity": "sha512-tFgA40Iq2oy4k2PnZrLJowbgpij+lD6ZLxkw8Ht1NKTYyN8dvSvC5xlo8X0WW2jqhKSzITrbr5mpB4/AZ/8OUA==" + "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==" }, "elliptic": { "version": "6.5.4", @@ -1539,6 +1547,11 @@ "unpipe": "~1.0.0" } }, + "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==" + }, "form-data": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", @@ -1646,14 +1659,14 @@ "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=" }, "graphql": { - "version": "15.7.2", - "resolved": "https://registry.npmjs.org/graphql/-/graphql-15.7.2.tgz", - "integrity": "sha512-AnnKk7hFQFmU/2I9YSQf3xw44ctnSFCfp3zE0N6W174gqe9fWG/2rKaKxROK7CcI3XtERpjEKFqts8o319Kf7A==" + "version": "15.8.0", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-15.8.0.tgz", + "integrity": "sha512-5gghUc24tP9HRznNpV2+FIoq3xKkj5dTQqf4v0CpdPbFVwFkWoxOM+o+2OC9ZSvjEMTjfmG9QT+gcvggTwW1zw==" }, "graphql-request": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/graphql-request/-/graphql-request-3.6.1.tgz", - "integrity": "sha512-Nm1EasrAQVZllyNTlHDLnLZjlhC6eRWnWP6KH//ytnAL08pjlLkdI2K+s6OV92p45hn5b/kUlLbDwACmRoLwrQ==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/graphql-request/-/graphql-request-3.7.0.tgz", + "integrity": "sha512-dw5PxHCgBneN2DDNqpWu8QkbbJ07oOziy8z+bK/TAXufsOLaETuVO4GkXrbs0WjhdKhBMN3BkpN/RIvUHkmNUQ==", "requires": { "cross-fetch": "^3.0.6", "extract-files": "^9.0.0", @@ -1731,9 +1744,9 @@ } }, "humanize-duration": { - "version": "3.27.0", - "resolved": "https://registry.npmjs.org/humanize-duration/-/humanize-duration-3.27.0.tgz", - "integrity": "sha512-qLo/08cNc3Tb0uD7jK0jAcU5cnqCM0n568918E7R2XhMr/+7F37p4EY062W/stg7tmzvknNn9b/1+UhVRzsYrQ==" + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/humanize-duration/-/humanize-duration-3.27.1.tgz", + "integrity": "sha512-jCVkMl+EaM80rrMrAPl96SGG4NRac53UyI1o/yAzebDntEY6K6/Fj2HOjdPg8omTqIe5Y0wPBai2q5xXrIbarA==" }, "iconv-lite": { "version": "0.4.23", @@ -2197,9 +2210,9 @@ } }, "mongoose": { - "version": "6.0.14", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.0.14.tgz", - "integrity": "sha512-SZ0kBlHrz/G70yWdVXLfM/gH4NsY85+as4MZRdtWxBTDEcmoE3rCFAz1/Ho2ycg5mJAeOBwdGZw4a5sn/WrwUA==", + "version": "6.0.15", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.0.15.tgz", + "integrity": "sha512-Lr53MKrJ4XNTdsMkhOYxeBJClsV7pgwr2VFf7E8TK9Xh5hs2kzFF49jJv9i4CWcshmydcF8uDfaQ9sQlqzZoYw==", "requires": { "bson": "^4.2.2", "kareem": "2.3.2", @@ -2467,9 +2480,9 @@ "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=" }, "prettier": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.0.tgz", - "integrity": "sha512-FM/zAKgWTxj40rH03VxzIPdXmj39SwSjwG0heUcNFwI+EMZJnY93yAiKXM3dObIKAM5TA88werc8T/EwhB45eg==" + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz", + "integrity": "sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==" }, "prettier-linter-helpers": { "version": "1.0.0", @@ -3259,9 +3272,9 @@ "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=" }, "watchpack": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.3.0.tgz", - "integrity": "sha512-MnN0Q1OsvB/GGHETrFeZPQaOelWh/7O+EiFlj8sM9GPjtQkis7k01aAxrg/18kTfoIVcLL+haEVFlXDaSRwKRw==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.3.1.tgz", + "integrity": "sha512-x0t0JuydIo8qCNctdDrn1OzH/qDzk2+rdCOC3YzumZ42fiMqmQ7T3xQurykYMhYfHaPHTp4ZxAx2NfUo1K6QaA==", "requires": { "glob-to-regexp": "^0.4.1", "graceful-fs": "^4.1.2" @@ -3273,9 +3286,9 @@ "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=" }, "webpack": { - "version": "5.64.4", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.64.4.tgz", - "integrity": "sha512-LWhqfKjCLoYJLKJY8wk2C3h77i8VyHowG3qYNZiIqD6D0ZS40439S/KVuc/PY48jp2yQmy0mhMknq8cys4jFMw==", + "version": "5.65.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.65.0.tgz", + "integrity": "sha512-Q5or2o6EKs7+oKmJo7LaqZaMOlDWQse9Tm5l1WAfU/ujLGN5Pb0SqGeVkN/4bpPmEqEP5RnVhiqsOtWtUVwGRw==", "requires": { "@types/eslint-scope": "^3.7.0", "@types/estree": "^0.0.50", @@ -3299,7 +3312,7 @@ "schema-utils": "^3.1.0", "tapable": "^2.1.1", "terser-webpack-plugin": "^5.1.3", - "watchpack": "^2.3.0", + "watchpack": "^2.3.1", "webpack-sources": "^3.2.2" }, "dependencies": { diff --git a/package.json b/package.json index e596514c..307c66a0 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,18 @@ "version": "0.0.0", "private": true, "scripts": { - "start": "ts-node ./bin/www" + "start": "ts-node ./bin/www", + "test:erc20install": "ts-node JsClients/ERC20/test/install.ts", + "test:erc20installed": "ts-node JsClients/ERC20/test/installed.ts", + "test:pairinstall": "ts-node JsClients/PAIR/test/install.ts", + "test:pairinstalled": "ts-node JsClients/PAIR/test/installed.ts", + "test:factoryinstall": "ts-node JsClients/FACTORY/test/install.ts", + "test:factoryinstalled": "ts-node JsClients/FACTORY/test/installed.ts", + "test:routerinstall": "ts-node JsClients/ROUTER/test/install.ts", + "test:routerinstalled": "ts-node JsClients/ROUTER/test/installed.ts" }, "dependencies": { + "axios": "^0.24.0", "casper-js-sdk": "2.4.1", "cookie-parser": "~1.4.4", "debug": "~2.6.9", diff --git a/test.js b/test.js index e69de29b..7776121f 100644 --- a/test.js +++ b/test.js @@ -0,0 +1,6 @@ +function splitdata(data) +{ + var temp=data.split('('); + var result=temp[1].split(')'); + return result[0]; +} \ No newline at end of file