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

Commit f011f01

Browse files
committed
removereserves function updated
1 parent 7aaf5d7 commit f011f01

File tree

3 files changed

+65
-46
lines changed

3 files changed

+65
-46
lines changed

JsClients/ERC20/src/erc20.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -328,44 +328,15 @@ class ERC20Client {
328328
throw Error("Invalid Deploy");
329329
}
330330
}
331-
public async mint(
332-
keys: Keys.AsymmetricKey,
333-
to: RecipientType,
334-
amount: string,
335-
paymentAmount: string
336-
) {
337-
338-
const runtimeArgs = RuntimeArgs.fromMap({
339-
to:utils.createRecipientAddress(to),
340-
amount: CLValueBuilder.u256(amount)
341-
});
342-
343-
const deployHash = await contractCall({
344-
chainName: this.chainName,
345-
contractHash: this.contractHash,
346-
entryPoint: "mint",
347-
keys,
348-
nodeAddress: this.nodeAddress,
349-
paymentAmount,
350-
runtimeArgs,
351-
});
352-
353-
if (deployHash !== null) {
354-
355-
return deployHash;
356-
} else {
357-
throw Error("Invalid Deploy");
358-
}
359-
}
360331
// public async mint(
361332
// keys: Keys.AsymmetricKey,
362-
// to: string,
333+
// to: RecipientType,
363334
// amount: string,
364335
// paymentAmount: string
365336
// ) {
366-
// const tobytearray = new CLByteArray(Uint8Array.from(Buffer.from(to, 'hex')));
337+
367338
// const runtimeArgs = RuntimeArgs.fromMap({
368-
// to: CLValueBuilder.key(tobytearray),
339+
// to:utils.createRecipientAddress(to),
369340
// amount: CLValueBuilder.u256(amount)
370341
// });
371342

@@ -380,12 +351,41 @@ class ERC20Client {
380351
// });
381352

382353
// if (deployHash !== null) {
383-
354+
384355
// return deployHash;
385356
// } else {
386357
// throw Error("Invalid Deploy");
387358
// }
388359
// }
360+
public async mint(
361+
keys: Keys.AsymmetricKey,
362+
to: string,
363+
amount: string,
364+
paymentAmount: string
365+
) {
366+
const tobytearray = new CLByteArray(Uint8Array.from(Buffer.from(to, 'hex')));
367+
const runtimeArgs = RuntimeArgs.fromMap({
368+
to: CLValueBuilder.key(tobytearray),
369+
amount: CLValueBuilder.u256(amount)
370+
});
371+
372+
const deployHash = await contractCall({
373+
chainName: this.chainName,
374+
contractHash: this.contractHash,
375+
entryPoint: "mint",
376+
keys,
377+
nodeAddress: this.nodeAddress,
378+
paymentAmount,
379+
runtimeArgs,
380+
});
381+
382+
if (deployHash !== null) {
383+
384+
return deployHash;
385+
} else {
386+
throw Error("Invalid Deploy");
387+
}
388+
}
389389
public async burn(
390390
keys: Keys.AsymmetricKey,
391391
from: RecipientType,

JsClients/ERC20/test/installed.ts

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ const erc20 = new ERC20Client(
7070

7171
const test = async () => {
7272

73-
await erc20.setContractHash(TOKEN0_CONTRACT!);
73+
await erc20.setContractHash(TOKEN1_CONTRACT!);
74+
console.log("contract:"+ TOKEN1_CONTRACT!);
7475
//getTotalSupply(TOKEN1_CONTRACT!);
7576
// // //name
7677
// // const name = await erc20.name();
@@ -89,7 +90,8 @@ const test = async () => {
8990
// // console.log(`... Total supply: ${totalSupply}`);
9091

9192
// // // //balanceof
92-
// let balance = await erc20.balanceOf("7b217a09296d5ce360847a7d20f623476157c5f022333c4e988a464035cadd80");
93+
// console.log("user: 0d72ccd15e717fde4afc91fab70cb20e9986da52c670976386efc91b375f52a8");
94+
// let balance = await erc20.balanceOf("0d72ccd15e717fde4afc91fab70cb20e9986da52c670976386efc91b375f52a8");
9395
// console.log(`... Balance: ${balance}`);
9496

9597
// // //nonce
@@ -100,17 +102,29 @@ const test = async () => {
100102
//let allowance = await erc20.allowance(KEYS.publicKey,KEYS.publicKey);
101103
// console.log(`... Allowance: ${allowance}`);
102104

105+
// //mint
106+
// const mintDeployHash = await erc20.mint(
107+
// ROUTERKEYS,
108+
// ROUTERKEYS.publicKey,
109+
// MINT_AMOUNT!,
110+
// MINT_PAYMENT_AMOUNT!
111+
// );
112+
// console.log("... Mint deploy hash: ", mintDeployHash);
113+
114+
// await getDeploy(NODE_ADDRESS!, mintDeployHash);
115+
// console.log("... Token minted successfully.");
116+
103117
//mint
104-
const mintDeployHash = await erc20.mint(
105-
ROUTERKEYS,
106-
ROUTERKEYS.publicKey,
107-
MINT_AMOUNT!,
108-
MINT_PAYMENT_AMOUNT!
109-
);
110-
console.log("... Mint deploy hash: ", mintDeployHash);
111-
112-
await getDeploy(NODE_ADDRESS!, mintDeployHash);
113-
console.log("... Token minted successfully.");
118+
// const mintDeployHash = await erc20.mint(
119+
// ROUTERKEYS,
120+
// "0d72ccd15e717fde4afc91fab70cb20e9986da52c670976386efc91b375f52a8",
121+
// MINT_AMOUNT!,
122+
// MINT_PAYMENT_AMOUNT!
123+
// );
124+
// console.log("... Mint deploy hash: ", mintDeployHash);
125+
126+
// await getDeploy(NODE_ADDRESS!, mintDeployHash);
127+
// console.log("... Token minted successfully.");
114128

115129
// balanceof
116130
// let balance = await erc20.balanceOfcontract(PAIR_CONTRACT!);

routes/listenerroutes.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,13 @@ router.route("/geteventsdata").post(async function (req, res, next) {
790790
message: "There is no pair against this user to remove reserves.",
791791
});
792792
} else {
793+
794+
let data = await allcontractsDataModel.findOne({
795+
packageHash: pairagainstuserresult.pair,
796+
});
797+
793798
let liquidity = await paircontract.balanceOf(
794-
pairagainstuserresult.pair,
799+
data.contractHash,
795800
pairagainstuserresult.id.toLowerCase()
796801
);
797802
if (liquidity == "0") {

0 commit comments

Comments
 (0)