-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontract-interact.js
75 lines (67 loc) · 2.01 KB
/
contract-interact.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import fs from "fs";
import path from "path";
import logger from "./utils/logger.js";
import { getEnvironmentVariables } from "./utils/env.js";
import { deriveWalletsAndDetails } from "./utils/wallet.js";
import {
mintTokens,
decryptMintedTokens,
fetchTokenDetails,
transferTokens,
// reencryptUserBalance,
approveTransaction,
} from "./test/encrypted-erc20.js";
let { networkUrl, mnemonic } = getEnvironmentVariables();
let { privateKeyTest } = deriveWalletsAndDetails(mnemonic);
let contractName = "EncryptedERC20.sol";
let filename = contractName.split(".")[0];
async function interactWithContract() {
try {
const contractAddress = fs.readFileSync(
path.join(process.cwd(), "data", "contractAddress.txt"),
"utf8",
);
const mintResult = await mintTokens(
filename,
networkUrl,
privateKeyTest,
contractAddress,
);
logger.info(`Mint Result: ${mintResult}`);
await new Promise((resolve) => setTimeout(resolve, 3000));
await decryptMintedTokens(
filename,
networkUrl,
privateKeyTest,
contractAddress,
);
await new Promise((resolve) => setTimeout(resolve, 3000));
await fetchTokenDetails(
filename,
networkUrl,
privateKeyTest,
contractAddress,
);
await new Promise((resolve) => setTimeout(resolve, 2000));
await transferTokens(filename, networkUrl, privateKeyTest, contractAddress);
await new Promise((resolve) => setTimeout(resolve, 2000));
// await reencryptUserBalance(
// filename,
// networkUrl,
// privateKeyTest,
// contractAddress,
// );
// await new Promise((resolve) => setTimeout(resolve, 2000));
const approveResult = await approveTransaction(
filename,
networkUrl,
privateKeyTest,
contractAddress,
);
logger.info(`Approve Result: ${approveResult}`);
await new Promise((resolve) => setTimeout(resolve, 2000));
} catch (error) {
logger.error("Error during tests:", error);
}
}
interactWithContract();