|
| 1 | +import BigNumber from "bignumber.js"; |
| 2 | +import { utils } from "casper-js-client-helper"; |
| 3 | +import { createRecipientAddress } from "casper-js-client-helper/dist/helpers/lib"; |
| 4 | +import { |
| 5 | + CLKey, |
| 6 | + CLKeyParameters, |
| 7 | + CLPublicKey, |
| 8 | + CLU256, |
| 9 | + CLValue, |
| 10 | + CLValueBuilder, |
| 11 | + EventName, |
| 12 | + EventStream, |
| 13 | + Keys, |
| 14 | +} from "casper-js-sdk"; |
| 15 | +import { Option, Result } from "ts-results"; |
| 16 | + |
| 17 | +if (process.env.NODE_ENV !== "ci") { |
| 18 | + require("dotenv").config({ path: "./.env", debug: true }); |
| 19 | +} |
| 20 | + |
| 21 | +import { |
| 22 | + createInstallReputationContractDeploy, |
| 23 | + ReputationContractEventParser, |
| 24 | + ReputationContractEvents, |
| 25 | + GenericContractJSClient, |
| 26 | +} from "../src"; |
| 27 | +import { createRpcClient } from "../src/common/rpc-client"; |
| 28 | +import { |
| 29 | + getAccountInfo, |
| 30 | + getAccountNamedKeyValue, |
| 31 | + waitForDeploy, |
| 32 | + assert, |
| 33 | +} from "./utils"; |
| 34 | + |
| 35 | +const { |
| 36 | + NODE_ENV, |
| 37 | + CHAIN_NAME, |
| 38 | + NODE_ADDRESS, |
| 39 | + EVENT_STREAM_ADDRESS, |
| 40 | + WASM_RELEASE_PATH, |
| 41 | + NCTL_USERS_FOLDER_PATH, |
| 42 | + INSTALL_PAYMENT_AMOUNT, |
| 43 | + DEPLOY_PAYMENT_AMOUNT, |
| 44 | +} = process.env; |
| 45 | + |
| 46 | +console.log("testing env variables", { |
| 47 | + NODE_ENV, |
| 48 | + CHAIN_NAME, |
| 49 | + NODE_ADDRESS, |
| 50 | + EVENT_STREAM_ADDRESS, |
| 51 | + WASM_RELEASE_PATH, |
| 52 | + NCTL_USERS_FOLDER_PATH, |
| 53 | + INSTALL_PAYMENT_AMOUNT, |
| 54 | + DEPLOY_PAYMENT_AMOUNT, |
| 55 | +}); |
| 56 | + |
| 57 | +const ownerKeys = Keys.Ed25519.parseKeyFiles( |
| 58 | + `${NCTL_USERS_FOLDER_PATH}/user-1/public_key.pem`, |
| 59 | + `${NCTL_USERS_FOLDER_PATH}/user-1/secret_key.pem` |
| 60 | +); |
| 61 | +const recipientKeys = Keys.Ed25519.parseKeyFiles( |
| 62 | + `${NCTL_USERS_FOLDER_PATH}/user-2/public_key.pem`, |
| 63 | + `${NCTL_USERS_FOLDER_PATH}/user-2/secret_key.pem` |
| 64 | +); |
| 65 | +const test = async () => { |
| 66 | + /** SCHEMA */ |
| 67 | + |
| 68 | + const reputationContractSchema = { |
| 69 | + entry_points: { |
| 70 | + mint: [ |
| 71 | + { name: "recipient", cl_type: "Address" }, |
| 72 | + { name: "amount", cl_type: "U256" }, |
| 73 | + ], |
| 74 | + add_to_whitelist: [{ name: "address", cl_type: "Address" }], |
| 75 | + }, |
| 76 | + named_keys: { |
| 77 | + owner: { |
| 78 | + named_key: "owner_owner_access_control_contract", |
| 79 | + cl_type: [{ name: "Option", inner: "Address" }], |
| 80 | + }, |
| 81 | + total_supply: { |
| 82 | + named_key: "total_supply_token_token_contract", |
| 83 | + cl_type: "U256", |
| 84 | + }, |
| 85 | + balance: { |
| 86 | + named_key: "balances_token_token_contract", |
| 87 | + cl_type: [{ name: "Mapping", key: "Address", value: "U256" }], |
| 88 | + }, |
| 89 | + whitelist: { |
| 90 | + named_key: "whitelist_whitelist_access_control_contract", |
| 91 | + cl_type: [{ name: "Mapping", key: "Address", value: "Bool" }], |
| 92 | + }, |
| 93 | + stakes: { |
| 94 | + named_key: "token_stakes", |
| 95 | + cl_type: [{ name: "Mapping", key: "Address", value: "U256" }], |
| 96 | + }, |
| 97 | + }, |
| 98 | + }; |
| 99 | + |
| 100 | + const contractHashWithHashPrefix = |
| 101 | + "hash-10539a97a58adf60498ecd0e7be1f7284c6dcc01a09154f45f97c8fc5d395a7e"; |
| 102 | + const contractPackageHash = |
| 103 | + "hash-49f5fc30a7888b74508a1ee4365353e858a4fc26ff1cdd3d7a81a7aff36d5276"; |
| 104 | + |
| 105 | + // Initialize contract client |
| 106 | + const reputationContract = new GenericContractJSClient( |
| 107 | + NODE_ADDRESS, |
| 108 | + CHAIN_NAME, |
| 109 | + EVENT_STREAM_ADDRESS, |
| 110 | + contractHashWithHashPrefix, |
| 111 | + contractPackageHash, |
| 112 | + reputationContractSchema |
| 113 | + ); |
| 114 | + |
| 115 | + console.log(`\n`); |
| 116 | + console.log(`... Testing deploys ...`); |
| 117 | + |
| 118 | +}; |
| 119 | + |
| 120 | +test().then(() => { |
| 121 | + process.exit(0); |
| 122 | +}); |
0 commit comments