diff --git a/Makefile b/Makefile index 146e5390..444c68ad 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ CARGO_TEST = cargo test --features=test-support --no-default-features prepare: rustup target add wasm32-unknown-unknown - cargo install cargo-expand --version 1.0.17 + # cargo install cargo-expand build-proxy-getter: $(CARGO_BUILD) -p casper-dao-utils --bin getter_proxy diff --git a/README.md b/README.md index 22ce80bc..db3d6d9b 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Reusable smart contracts for building DAOs on top of Casper. Repository contains following modules: - `dao-contracts` and `dao-modules` provides smart contracts implementation, +- `dao-erc20` and `dao-erc721` allows to use those standards, - `dao-utils` and `dao-macros` makes writing code easier, - `client` implements a JavaScript client for smart contracts interactions. diff --git a/client/README.md b/client/README.md index 9e20f052..e57a371c 100644 --- a/client/README.md +++ b/client/README.md @@ -1,6 +1,6 @@ # `dao-contracts-js-client` -This JavaScript client gives you an easy way to install and interact with the DAO Reputation contract. +This JavaScript client gives you an easy way to install and interact with all the DAO contracts. ## Installation @@ -15,24 +15,29 @@ npm i dao-contracts-js-client ### Install the contract on the network ```ts -const installDeployHash = await installReputationContract( +// create deploy +const deploy = createInstallReputationContractDeploy( CHAIN_NAME, NODE_ADDRESS, - KEYS, // Key pair used for signing 200000000000, // Payment amount "../target/wasm32-unknown-unknown/release/reputation_contract.wasm" // Path to WASM file + OWNER_KEYS, // Key pair used for signing deploy ); + +// send deploy to network +const installDeployHash = await installDeploy.send(NODE_ADDRESS); ``` -### Create an instance to interact with the contract +### Create a client instance to interact with the contract ```ts -const reputationContract = new ReputationContractJSClient( +const reputationContract = new GenericContractJSClient( http://localhost:11101, // RPC address "casper-net-1", // Network name "http://localhost:18101/events/main", // Event stream address "hash-XXXXXXXXXXXXXXXXXXXXx", // contractPackageHash "hash-XXXXXXXXXXXXXXXXXXXXx", // contractHash + 'path-to-contract-yaml-schema-file' ); ``` @@ -43,8 +48,11 @@ const reputationContract = new ReputationContractJSClient( Use getter methods to retrieve values: ```ts -const owner = await reputationContract.getOwner(); -const total_supply = await reputationContract.getTotalSupply(); +const total_supply = + await reputationContract.getNamedKey("total_supply"); + +const isWhitelisted = + await reputationContract.getNamedKey("whitelist", publicKey); ``` ### Deploys @@ -54,12 +62,21 @@ Use deploys to interact with contract: ```ts const mintAmount = "200000000000"; -const deployHashMint = await reputationContract.mint( +const mintResult: Result = await reputationContract.callEntryPoint( + "mint", ownerKeys, - ownerKeys.publicKey, - mintAmount, - DEPLOY_PAYMENT_AMOUNT + DEPLOY_PAYMENT_AMOUNT, + createRecipientAddress(ownerKeys.publicKey), // import { createRecipientAddress } from "casper-js-client-helper/dist/helpers/lib"; + CLValueBuilder.u256(mintAmount) ); + +if (mintResult.ok) { + // handle success + mintResult.val +} else { + // handle error + mintResult.val +} ``` ## Development diff --git a/client/e2e/e2e-generic-client-local.ts b/client/e2e/e2e-generic-client-local.ts new file mode 100644 index 00000000..ffef66d7 --- /dev/null +++ b/client/e2e/e2e-generic-client-local.ts @@ -0,0 +1,122 @@ +import BigNumber from "bignumber.js"; +import { utils } from "casper-js-client-helper"; +import { createRecipientAddress } from "casper-js-client-helper/dist/helpers/lib"; +import { + CLKey, + CLKeyParameters, + CLPublicKey, + CLU256, + CLValue, + CLValueBuilder, + EventName, + EventStream, + Keys, +} from "casper-js-sdk"; +import { Option, Result } from "ts-results"; + +if (process.env.NODE_ENV !== "ci") { + require("dotenv").config({ path: "./.env", debug: true }); +} + +import { + createInstallReputationContractDeploy, + ReputationContractEventParser, + ReputationContractEvents, + GenericContractJSClient, +} from "../src"; +import { createRpcClient } from "../src/common/rpc-client"; +import { + getAccountInfo, + getAccountNamedKeyValue, + waitForDeploy, + assert, +} from "./utils"; + +const { + NODE_ENV, + CHAIN_NAME, + NODE_ADDRESS, + EVENT_STREAM_ADDRESS, + WASM_RELEASE_PATH, + NCTL_USERS_FOLDER_PATH, + INSTALL_PAYMENT_AMOUNT, + DEPLOY_PAYMENT_AMOUNT, +} = process.env; + +console.log("testing env variables", { + NODE_ENV, + CHAIN_NAME, + NODE_ADDRESS, + EVENT_STREAM_ADDRESS, + WASM_RELEASE_PATH, + NCTL_USERS_FOLDER_PATH, + INSTALL_PAYMENT_AMOUNT, + DEPLOY_PAYMENT_AMOUNT, +}); + +const ownerKeys = Keys.Ed25519.parseKeyFiles( + `${NCTL_USERS_FOLDER_PATH}/user-1/public_key.pem`, + `${NCTL_USERS_FOLDER_PATH}/user-1/secret_key.pem` +); +const recipientKeys = Keys.Ed25519.parseKeyFiles( + `${NCTL_USERS_FOLDER_PATH}/user-2/public_key.pem`, + `${NCTL_USERS_FOLDER_PATH}/user-2/secret_key.pem` +); +const test = async () => { + /** SCHEMA */ + + const reputationContractSchema = { + entry_points: { + mint: [ + { name: "recipient", cl_type: "Address" }, + { name: "amount", cl_type: "U256" }, + ], + add_to_whitelist: [{ name: "address", cl_type: "Address" }], + }, + named_keys: { + owner: { + named_key: "owner_owner_access_control_contract", + cl_type: [{ name: "Option", inner: "Address" }], + }, + total_supply: { + named_key: "total_supply_token_token_contract", + cl_type: "U256", + }, + balance: { + named_key: "balances_token_token_contract", + cl_type: [{ name: "Mapping", key: "Address", value: "U256" }], + }, + whitelist: { + named_key: "whitelist_whitelist_access_control_contract", + cl_type: [{ name: "Mapping", key: "Address", value: "Bool" }], + }, + stakes: { + named_key: "token_stakes", + cl_type: [{ name: "Mapping", key: "Address", value: "U256" }], + }, + }, + }; + + const contractHashWithHashPrefix = + "hash-10539a97a58adf60498ecd0e7be1f7284c6dcc01a09154f45f97c8fc5d395a7e"; + const contractPackageHash = + "hash-49f5fc30a7888b74508a1ee4365353e858a4fc26ff1cdd3d7a81a7aff36d5276"; + + // Initialize contract client + const reputationContract = new GenericContractJSClient( + NODE_ADDRESS, + CHAIN_NAME, + EVENT_STREAM_ADDRESS, + contractHashWithHashPrefix, + contractPackageHash, + reputationContractSchema + ); + + console.log(`\n`); + console.log(`... Testing deploys ...`); + +}; + +test().then(() => { + process.exit(0); +}); diff --git a/client/e2e/e2e-generic-client.ts b/client/e2e/e2e-generic-client.ts new file mode 100644 index 00000000..ffb47df6 --- /dev/null +++ b/client/e2e/e2e-generic-client.ts @@ -0,0 +1,208 @@ +import BigNumber from "bignumber.js"; +import { utils } from "casper-js-client-helper"; +import { createRecipientAddress } from "casper-js-client-helper/dist/helpers/lib"; +import { + CLKey, + CLKeyParameters, + CLU256, + CLValue, + CLValueBuilder, + EventName, + EventStream, + Keys, +} from "casper-js-sdk"; +import { Option, Result } from "ts-results"; + +if (process.env.NODE_ENV !== "ci") { + require("dotenv").config({ path: "./.env", debug: true }); +} + +import { + createInstallReputationContractDeploy, + ReputationContractEventParser, + ReputationContractEvents, + GenericContractJSClient, +} from "../src"; +import { createRpcClient } from "../src/common/rpc-client"; +import { + getAccountInfo, + getAccountNamedKeyValue, + waitForDeploy, + assert, +} from "./utils"; + +const { + NODE_ENV, + CHAIN_NAME, + NODE_ADDRESS, + EVENT_STREAM_ADDRESS, + WASM_RELEASE_PATH, + NCTL_USERS_FOLDER_PATH, + INSTALL_PAYMENT_AMOUNT, + DEPLOY_PAYMENT_AMOUNT, +} = process.env; + +console.log("testing env variables", { + NODE_ENV, + CHAIN_NAME, + NODE_ADDRESS, + EVENT_STREAM_ADDRESS, + WASM_RELEASE_PATH, + NCTL_USERS_FOLDER_PATH, + INSTALL_PAYMENT_AMOUNT, + DEPLOY_PAYMENT_AMOUNT, +}); + +const ownerKeys = Keys.Ed25519.parseKeyFiles( + `${NCTL_USERS_FOLDER_PATH}/user-1/public_key.pem`, + `${NCTL_USERS_FOLDER_PATH}/user-1/secret_key.pem` +); +const recipientKeys = Keys.Ed25519.parseKeyFiles( + `${NCTL_USERS_FOLDER_PATH}/user-2/public_key.pem`, + `${NCTL_USERS_FOLDER_PATH}/user-2/secret_key.pem` +); + +const wasmContractPath = WASM_RELEASE_PATH + "/reputation_contract.wasm"; +const wasmContractSchemaPath = + WASM_RELEASE_PATH + "/reputation_contract_schema.yaml"; + +const test = async () => { + console.log(`\n`); + console.log(`... Testing install ...`); + console.log(`\n`); + + const installDeploy = createInstallReputationContractDeploy( + CHAIN_NAME, + NODE_ADDRESS, + INSTALL_PAYMENT_AMOUNT, + wasmContractPath, + ownerKeys + ); + + const installDeployHash = await installDeploy.send(NODE_ADDRESS); + await waitForDeploy(NODE_ADDRESS, installDeployHash); + let accountInfo = await getAccountInfo(NODE_ADDRESS, ownerKeys.publicKey); + const contractPackageHash = await getAccountNamedKeyValue( + accountInfo, + `reputation_contract_package_hash` + ); + if (!contractPackageHash) { + throw Error("Contract not installed correctly!"); + } + + console.log(`... Contract installed successfully.`); + console.log(` - Contract Package Hash: ${contractPackageHash}`); + + const stateRootHash = await utils.getStateRootHash(NODE_ADDRESS); + const rpcClient = createRpcClient(NODE_ADDRESS); + const res = await rpcClient.fetchStateGetItem( + stateRootHash, + contractPackageHash, + [] + ); + const contractHash = res.ContractPackage.versions[0].contract_hash; + const contractHashWithHashPrefix = contractHash.replace("contract-", "hash-"); + console.log(` - Contract Hash: ${contractHashWithHashPrefix}`); + + /** SCHEMA */ + + // Initialize contract client + const reputationContract = new GenericContractJSClient( + NODE_ADDRESS, + CHAIN_NAME, + EVENT_STREAM_ADDRESS, + contractHashWithHashPrefix, + contractPackageHash, + wasmContractSchemaPath + ); + + console.log(`\n`); + console.log(`... Testing deploys ...`); + + /** MINT DEPLOY */ + + console.log(`\n`); + console.log(" - Trying to create and send a mint deploy"); + + const mintAmount = "200000000000"; + const mintResult: Result = + await reputationContract.callEntryPoint( + "mint", + ownerKeys, + DEPLOY_PAYMENT_AMOUNT, + createRecipientAddress(ownerKeys.publicKey), + CLValueBuilder.u256(mintAmount) + ); + // console.log('mintDeployResult',JSON.stringify(mintResult, null, 2)); + + if (mintResult.ok) { + await waitForDeploy(NODE_ADDRESS, mintResult.val); + const total_supply_after_mint = (await reputationContract.getNamedKey( + "total_supply" + )) as BigNumber; // should be CLU256 but sdk returns BigNumber, need to fix in casper-js-sdk + console.log( + ` - Requested Mint Amount: `, + mintAmount + ); + console.log( + ` - Total Supply After Mint: `, + total_supply_after_mint.toString() + ); + const totalSupplyEqMint = total_supply_after_mint.eq(mintAmount); + + console.log( + ` - Total supply equals mint: ${ + totalSupplyEqMint ? "SUCCESS!" : "FAILED!" + }` + ); + assert(totalSupplyEqMint); + } else { + console.error(mintResult.val); + process.exit(1); + } + + /** WHITELIST DEPLOY */ + + console.log(`\n`); + console.log(" - Trying to create and send a add to whitelist deploy"); + + const isWhitelistedBefore = (await reputationContract.getNamedKey( + "whitelist", + recipientKeys.publicKey + )) as Boolean; + console.log(` - Whitelist Value Before Deploy: ${isWhitelistedBefore}`); + + const whitelistResult: Result = + await reputationContract.callEntryPoint( + "add_to_whitelist", + ownerKeys, + DEPLOY_PAYMENT_AMOUNT, + createRecipientAddress(recipientKeys.publicKey) + ); + // console.log("whitelistResult", JSON.stringify(whitelistResult, null, 2)); + + if (whitelistResult.ok) { + await waitForDeploy(NODE_ADDRESS, whitelistResult.val); + const isWhitelisted = await reputationContract.getNamedKey( + "whitelist", + recipientKeys.publicKey + ); + console.log(` - Whitelist Value After Deploy: ${isWhitelisted}`); + + const recipientAddedToTheWhitelist = "true" === isWhitelisted; + + console.log( + ` - Recipient is added to the whitelist: ${ + recipientAddedToTheWhitelist ? "SUCCESS!" : "FAILED!" + }` + ); + assert(recipientAddedToTheWhitelist); + } else { + console.error(whitelistResult.val); + process.exit(1); + } +}; + +test().then(() => { + process.exit(0); +}); diff --git a/client/e2e/utils.ts b/client/e2e/utils.ts index 81d0d940..0bd59e08 100644 --- a/client/e2e/utils.ts +++ b/client/e2e/utils.ts @@ -1,7 +1,10 @@ import { CasperClient, CasperServiceByJsonRPC, + CLKey, + CLKeyParameters, CLPublicKey, + CLValue, } from "casper-js-sdk"; export const sleep = (ms: number) => { @@ -89,7 +92,8 @@ export const createDictionaryGetter = async ( path: string, account: CLPublicKey ) => { - const key = encodeAccountHashStrAsKey(account.toAccountHashStr()); + const accountHashStr = account.toAccountHashStr(); + const key = encodeAccountHashStrAsKey(accountHashStr); try { const result = await contractClient.queryContractDictionary(path, key); return result.value().toString(); diff --git a/client/package.json b/client/package.json index 93e4c7a0..53486b87 100644 --- a/client/package.json +++ b/client/package.json @@ -12,11 +12,14 @@ ], "dependencies": { "@open-rpc/client-js": "1.7.1", - "casper-js-client-helper": "1.0.0", - "casper-js-sdk": "2.8.0" + "bignumber.js": "9.0.2", + "casper-js-client-helper": "1.0.1", + "casper-js-sdk": "2.9.1", + "ts-results": "3.3.0", + "yaml": "2.1.1" }, "devDependencies": { - "dotenv": "16.0.0", + "dotenv": "16.0.1", "ts-node": "10.5.0", "typescript": "4.5.5" }, @@ -27,6 +30,8 @@ "dist": "npm run clean && npm run build", "clean": "rm -rf dist/", "build": "tsc -p tsconfig.build.json", - "e2e:reputation": "ts-node ./e2e/e2e-reputation.ts" + "e2e:reputation": "ts-node ./e2e/e2e-reputation.ts", + "e2e:generic-client": "ts-node ./e2e/e2e-generic-client.ts", + "e2e:generic-client-local": "ts-node ./e2e/e2e-generic-client-local.ts" } } diff --git a/client/src/generic-client/generic-client.ts b/client/src/generic-client/generic-client.ts new file mode 100644 index 00000000..b20ff495 --- /dev/null +++ b/client/src/generic-client/generic-client.ts @@ -0,0 +1,214 @@ +import { CasperContractClient } from "casper-js-client-helper"; +import { + CasperClient, + CLBool, + CLKey, + CLPublicKey, + CLU128, + CLU256, + CLU32, + CLU512, + CLU64, + CLU8, + CLValueBuilder, + Contracts, + Keys, + RuntimeArgs, +} from "casper-js-sdk"; +import fs from "fs"; +import { Err, Ok, Result } from "ts-results"; +import YAML from "yaml"; + +import { createDictionaryGetter } from "../../e2e/utils"; +import { DEFAULT_TTL } from "../common/constants"; +import { createRpcClient } from "../common/rpc-client"; + +/** TYPES */ + +export type GenericContractSchema = { + entry_points: Record; + named_keys: Record< + string, + { + named_key: string; + cl_type: GenericContractSchemaClType; + } + >; +}; + +export type GenericContractSchemaArguments = { + name: string; + cl_type: string; +}[]; + +export type GenericContractSchemaClType = + | string + | Array< + | { name: string; inner: string } + | { name: string; key: string; value: string } + >; + +/** CONSTANTS */ +const CLTypeDict = { + Address: CLKey, + U8: CLU8, + U32: CLU32, + U64: CLU64, + U128: CLU128, + U256: CLU256, + U512: CLU512, + Bool: CLBool, +}; + +/** MAIN */ + +export class GenericContractJSClient< + T extends GenericContractSchema +> extends CasperContractClient { + protected rpcClient: ReturnType; + protected contractClient: Contracts.Contract; + + constructor( + nodeAddress: string, + chainName: string, + eventStreamAddress: string, + contractHash: string, + contractPackageHash: string, + schemaPath: string + ) { + super(nodeAddress, chainName, eventStreamAddress); + this.contractClient = new Contracts.Contract(new CasperClient(nodeAddress)); + this.contractClient.setContractHash(contractHash, contractPackageHash); + this.rpcClient = createRpcClient(nodeAddress); + + const file = fs.readFileSync(schemaPath, "utf8"); + const parsed: { + entry_points: Array<{ + name: string; + arguments: Array<{ name: string; cl_type: string }>; + }>; + named_keys: Array<{ + name: string; + named_key: string; + cl_type: GenericContractSchemaClType; + }>; + } = YAML.parse(file); + + const schema: GenericContractSchema = { + entry_points: parsed.entry_points.reduce((result, val) => { + result[val.name] = { arguments: val.arguments }; + return result; + }, {} as GenericContractSchema['entry_points']), + named_keys: parsed.named_keys.reduce((result, val) => { + result[val.name] = { named_key: val.named_key, cl_type: val.cl_type }; + return result; + }, {} as GenericContractSchema['named_keys']), + }; + + const { entry_points, named_keys } = schema; + + // create entry_points deploy creator methods and attach to the class instance + for (const key in entry_points) { + const argsSchema = entry_points[key].arguments; + this[`${key}`] = this.createEntryPointMethod(argsSchema); + } + + // create named_keys getters methods and attach to the class instance + for (const key in named_keys) { + const { named_key: name, cl_type } = named_keys[key]; + this[`${key}`] = this.createNamedKeyGetterMethod(name, cl_type); + } + } + + public callEntryPoint( + name: string, + keys: Keys.AsymmetricKey = undefined, + paymentAmount: string, + ...args + ): Promise> { + return this[name](name, keys, paymentAmount, ...args); + } + + createEntryPointMethod( + argsSchema: { + name: string; + cl_type: string; + }[] + ) { + return async ( + name: string, + keys: Keys.AsymmetricKey = undefined, + paymentAmount: string, + ...args + ) => { + const runtimeArgs = RuntimeArgs.fromMap({}); + // prepare runtime args + for (let index = 0; index < argsSchema.length; index++) { + const argDefinition = argsSchema[index]; + // argument cl type validation + const arg = args[index]; + if (!(arg instanceof CLTypeDict[argDefinition.cl_type])) { + return Err( + `Invalid type for ${argDefinition.name} argument, expected ${argDefinition.cl_type}` + ); + } + runtimeArgs.insert(argDefinition.name, arg); + } + + const deploy = this.contractClient.callEntrypoint( + name, + runtimeArgs, + keys.publicKey, + this.chainName, + paymentAmount, + [keys] + ); + const deployHash = await deploy.send(this.nodeAddress); + + return Ok(deployHash); // new is optional here + }; + } + + public async getNamedKey(name: string, ...args: any[]): Promise { + return await this[name](...args); + } + + private createNamedKeyGetterMethod( + name: string, + schemaClType: GenericContractSchemaClType + ) { + return async (...args: any[]) => { + if (typeof schemaClType === "string") { + const CLTypeClass = CLTypeDict[schemaClType]; + if (CLTypeClass) { + // this method returns parsed cltype value from sdk + const value = await this.contractClient.queryContractData([name]); + // console.log(` - sdk: ${JSON.stringify(value, null, 2)}`); + return value; + } + } else if (Array.isArray(schemaClType) && schemaClType[0]) { + const clTypeObj = schemaClType[0]; + if ("inner" in clTypeObj) { + // this method returns parsed cltype value from sdk + const value = await this.contractClient.queryContractData([name]); + // console.log(` - sdk: ${JSON.stringify(value, null, 2)}`); + return value; + } else if ("key" in clTypeObj && "value" in clTypeObj) { + if (clTypeObj.name === "Mapping") { + const ArgumentClass = CLTypeDict[clTypeObj.key]; + const value = await createDictionaryGetter( + this.contractClient, + name, + args[0] + // new ArgumentClass(args[0]) + ); + // console.log(` sdk value: ${JSON.stringify(value, null, 2)}`); + return value; + } + } + } + + throw Error("Unknown CLType, possibly the library is outdated."); + }; + } +} diff --git a/client/src/index.ts b/client/src/index.ts index 47308015..61480287 100644 --- a/client/src/index.ts +++ b/client/src/index.ts @@ -4,10 +4,12 @@ import { } from "./reputation/events"; import { ReputationContractJSClient } from "./reputation/client"; import { createInstallReputationContractDeploy } from "./reputation/install"; +import { GenericContractJSClient } from "./generic-client/generic-client"; export { createInstallReputationContractDeploy, ReputationContractJSClient, ReputationContractEvents, ReputationContractEventParser, + GenericContractJSClient }; diff --git a/client/wasm/reputation_contract.wasm b/client/wasm/reputation_contract.wasm new file mode 100755 index 00000000..f086e2c6 Binary files /dev/null and b/client/wasm/reputation_contract.wasm differ diff --git a/client/wasm/reputation_contract_schema.yaml b/client/wasm/reputation_contract_schema.yaml new file mode 100644 index 00000000..24517168 --- /dev/null +++ b/client/wasm/reputation_contract_schema.yaml @@ -0,0 +1,140 @@ +name: "reputation_contract" + +entry_points: + - name: "mint" + arguments: + - name: "recipient" + cl_type: "Address" + - name: "amount" + cl_type: "U256" + + - name: "burn" + arguments: + - name: "owner" + cl_type: "Address" + - name: "amount" + cl_type: "U256" + + - name: "transfer_from" + arguments: + - name: "owner" + cl_type: "Address" + - name: "recipient" + cl_type: "Address" + - name: "amount" + cl_type: "U256" + + - name: "change_ownership" + arguments: + - name: "owner" + cl_type: "Address" + + - name: "add_to_whitelist" + arguments: + - name: "address" + cl_type: "Address" + + - name: "remove_from_whitelist" + arguments: + - name: "address" + cl_type: "Address" + + - name: "stake" + arguments: + - name: "address" + cl_type: "Address" + - name: "amount" + cl_type: "U256" + + - name: "unstake" + arguments: + - name: "address" + cl_type: "Address" + - name: "amount" + cl_type: "U256" + +events: + - name: "Transfer" + fields: + - name: "from" + cl_type: "Address" + - name: "to" + cl_type: "Address" + - name: "value" + cl_type: "U256" + + - name: "Mint" + fields: + - name: "recipient" + cl_type: "Address" + - name: "value" + cl_type: "U256" + + - name: "Burn" + fields: + - name: "owner" + cl_type: "Address" + - name: "value" + cl_type: "U256" + + - name: "OwnerChanged" + fields: + - name: "new_owner" + cl_type: "Address" + + - name: "AddedToWhitelist" + fields: + - name: "address" + cl_type: "Address" + + - name: "RemovedFromWhitelist" + fields: + - name: "address" + cl_type: "Address" + + - name: "TokensStaked" + fields: + - name: "address" + cl_type: "Address" + - name: "amount" + cl_type: "U256" + + - name: "TokensUnstaked" + fields: + - name: "address" + cl_type: "Address" + - name: "amount" + cl_type: "U256" + +named_keys: + - name: "owner" + named_key: "owner" + cl_type: + - name: "Option" + inner: "Address" + + - name: "total_supply" + named_key: "total_supply" + cl_type: "U256" + + - name: "balance" + named_key: "balances" + cl_type: + - name: "Mapping" + key: "Address" + value: "U256" + + - name: "whitelist" + named_key: "whitelist" + cl_type: + - name: "Mapping" + key: "Address" + value: "Bool" + + - name: "stakes" + named_key: "token_stakes" + cl_type: + - name: "Mapping" + key: "Address" + value: "U256" + diff --git a/resources/reputation_contract_schema.yaml b/resources/reputation_contract_schema.yaml index 0cee1019..74d2e036 100644 --- a/resources/reputation_contract_schema.yaml +++ b/resources/reputation_contract_schema.yaml @@ -4,58 +4,54 @@ entry_points: - name: "mint" arguments: - name: "recipient" - cl_type: "casper_dao_utils::Address" + cl_type: "Address" - name: "amount" - cl_type: "casper_types::U256" + cl_type: "U256" - name: "burn" arguments: - name: "owner" - cl_type: "casper_dao_utils::Address" + cl_type: "Address" - name: "amount" - cl_type: "casper_types::U256" + cl_type: "U256" - name: "transfer_from" arguments: - name: "owner" - cl_type: "casper_dao_utils::Address" + cl_type: "Address" - name: "recipient" - cl_type: "casper_dao_utils::Address" + cl_type: "Address" - name: "amount" - cl_type: "casper_types::U256" + cl_type: "U256" - name: "change_ownership" arguments: - name: "owner" - cl_type: "casper_dao_utils::Address" + cl_type: "Address" - name: "add_to_whitelist" arguments: - name: "address" - cl_type: "casper_dao_utils::Address" + cl_type: "Address" - name: "remove_from_whitelist" arguments: - name: "address" - cl_type: "casper_dao_utils::Address" + cl_type: "Address" - name: "stake" arguments: - name: "address" - cl_type: "casper_dao_utils::Address" + cl_type: "Address" - name: "amount" - cl_type: "casper_types::U256" + cl_type: "U256" - name: "unstake" arguments: - name: "address" - cl_type: "casper_dao_utils::Address" + cl_type: "Address" - name: "amount" - cl_type: "casper_types::U256" - -events_config: - dictionary_named_key: "events" - length_named_key: "events_length" + cl_type: "U256" events: - name: "Transfer" @@ -112,21 +108,33 @@ events: named_keys: - name: "owner" - named_key: "owner" - cl_type: "Option
" + named_key: "owner_owner_access_control_contract" + cl_type: + - name: "Option" + inner: "Address" - name: "total_supply" - named_key: "total_supply" + named_key: "total_supply_token_token_contract" cl_type: "U256" - - name: "balances" - named_key: "balances" - cl_type: "Mapping" + - name: "balance" + named_key: "balances_token_token_contract" + cl_type: + - name: "Mapping" + key: "Address" + value: "U256" - name: "whitelist" - named_key: "whitelist" - cl_type: "Mapping" + named_key: "whitelist_whitelist_access_control_contract" + cl_type: + - name: "Mapping" + key: "Address" + value: "Bool" - name: "stakes" - named_key: "stakes" - cl_type: "Mapping" + named_key: "token_stakes" + cl_type: + - name: "Mapping" + key: "Address" + value: "U256" + diff --git a/resources/variable_repository_contract_schema.yaml b/resources/variable_repository_contract_schema.yaml index 0fad0bc1..7c667bfb 100644 --- a/resources/variable_repository_contract_schema.yaml +++ b/resources/variable_repository_contract_schema.yaml @@ -1,20 +1,6 @@ name: "variable_repository_contract" entry_points: - - name: "set_or_update" - arguments: - - name: "key" - cl_type: "String" - - name: "value" - cl_type: "Bytes" - - - name: "get" - arguments: - - name: "key" - cl_type: "String" - returns: - - cl_type: "Bytes" - - name: "change_ownership" arguments: - name: "owner" @@ -30,26 +16,20 @@ entry_points: - name: "address" cl_type: "Address" -events_config: - dictionary_named_key: "events" - length_named_key: "events_length" - -events: - - name: "ValueSet" - fields: + - name: "update_at" + arguments: - name: "key" cl_type: "String" - name: "value" cl_type: "Bytes" - -- name: "ValueRemoved" - fields: - - name: "key" - cl_type: "String" + - name: "activation_time" + cl_type: + - name: "Option" + inner: "U64" named_keys: - name: "owner" - named_key: "owner" + named_key: "accessowner" cl_type: "Option
" - name: "whitelist" @@ -67,3 +47,41 @@ named_keys: - name: "keys_length" named_key: "keys_length" cl_type: "Variable" + +named_keys: + - name: "owner" + named_key: "access_control_owner_owner" + cl_type: + - name: "Option" + inner: "Address" + + - name: "whitelist" + named_key: "access_control_whitelist_whitelist" + cl_type: + - name: "Mapping" + key: "Address" + value: "Bool" + + - name: "data" + named_key: "repository_storage" + cl_type: + - name: "Mapping" + key: "String" + value: + - name: "Tuple" + first: "Bytes" + second: + - name: "Option" + inner: + - name: "Tuple" + first: "Bytes" + second: "U64" + + - name: "keys" + named_key: "repository_keys_values_mapping" + cl_type: + - name: "Mapping" + key: "U32" + value: + - name: "Option" + inner: "String"