@mimicprotocol/cli 0.0.1-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +96 -0
  2. package/bin/run.cmd +3 -0
  3. package/bin/run.js +6 -0
  4. package/dist/commands/codegen.js +100 -0
  5. package/dist/commands/compile.js +91 -0
  6. package/dist/commands/deploy.js +122 -0
  7. package/dist/commands/init.js +102 -0
  8. package/dist/commands/test.js +63 -0
  9. package/dist/errors.js +32 -0
  10. package/dist/helpers.js +17 -0
  11. package/dist/index.js +2 -0
  12. package/dist/lib/AbisInterfaceGenerator/AbiTypeConverter.js +137 -0
  13. package/dist/lib/AbisInterfaceGenerator/ArrayHandler.js +67 -0
  14. package/dist/lib/AbisInterfaceGenerator/ContractClassGenerator.js +70 -0
  15. package/dist/lib/AbisInterfaceGenerator/FunctionHandler.js +173 -0
  16. package/dist/lib/AbisInterfaceGenerator/ImportManager.js +17 -0
  17. package/dist/lib/AbisInterfaceGenerator/NameManager.js +98 -0
  18. package/dist/lib/AbisInterfaceGenerator/TupleHandler.js +251 -0
  19. package/dist/lib/AbisInterfaceGenerator/index.js +11 -0
  20. package/dist/lib/AbisInterfaceGenerator/types.js +4 -0
  21. package/dist/lib/InputsInterfaceGenerator.js +96 -0
  22. package/dist/lib/ManifestHandler.js +134 -0
  23. package/dist/lib/index.js +12 -0
  24. package/dist/log.js +13 -0
  25. package/dist/templates/eslint.config.mjs +89 -0
  26. package/dist/templates/manifest.yaml +9 -0
  27. package/dist/templates/package.json +30 -0
  28. package/dist/templates/src/task.ts +7 -0
  29. package/dist/templates/tests/Task.spec.ts +47 -0
  30. package/dist/templates/tests/tsconfig.json +21 -0
  31. package/dist/templates/tsconfig.json +6 -0
  32. package/dist/types.js +25 -0
  33. package/dist/validators.js +26 -0
  34. package/package.json +58 -0
@@ -0,0 +1,47 @@
1
+ import { Context, runTask, Transfer } from '@mimicprotocol/test-ts'
2
+ import { expect } from 'chai'
3
+
4
+ describe('Task', () => {
5
+ it('produces the expected intents', async () => {
6
+ const taskDir = './'
7
+
8
+ const context: Context = {
9
+ user: '0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0',
10
+ settlers: [
11
+ {
12
+ address: '0xdcf1d9d12a0488dfb70a8696f44d6d3bc303963d',
13
+ chainId: 10,
14
+ },
15
+ ],
16
+ configSig: '682ec8210b1ce912da4d2952',
17
+ }
18
+
19
+ const inputs = {
20
+ chainId: 10,
21
+ token: '0x7f5c764cbc14f9669b88837ca1490cca17c31607',
22
+ amount: '10000000',
23
+ recipient: context.user!,
24
+ fee: '100',
25
+ }
26
+
27
+ const intents = await runTask(taskDir, context, { inputs })
28
+
29
+ expect(intents).to.be.an('array').that.is.not.empty
30
+ expect(intents).to.have.lengthOf(1)
31
+
32
+ const intent = intents[0]
33
+ expect(intent.type).to.be.equal('transfer')
34
+ expect(intent.settler).to.be.equal(context.settlers![0].address)
35
+ expect(intent.user).to.be.equal(context.user)
36
+
37
+ const transferIntent = intent as Transfer
38
+ expect(transferIntent.chainId).to.be.equal(inputs.chainId)
39
+ expect(transferIntent.feeToken).to.be.equal(inputs.token)
40
+ expect(transferIntent.feeAmount).to.be.equal(inputs.fee)
41
+
42
+ expect(transferIntent.transfers).to.have.lengthOf(1)
43
+ expect(transferIntent.transfers[0].token).to.be.equal(inputs.token)
44
+ expect(transferIntent.transfers[0].amount).to.be.equal(inputs.amount)
45
+ expect(transferIntent.transfers[0].recipient).to.be.equal(inputs.recipient)
46
+ })
47
+ })
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "moduleResolution": "node",
6
+ "esModuleInterop": true,
7
+ "allowSyntheticDefaultImports": true,
8
+ "strict": true,
9
+ "declaration": true,
10
+ "composite": true,
11
+ "outDir": "./dist",
12
+ "rootDir": "./",
13
+ "resolveJsonModule": true,
14
+ "skipLibCheck": true,
15
+ "forceConsistentCasingInFileNames": true,
16
+ "lib": ["ES2020", "DOM"],
17
+ "types": ["mocha", "chai", "node"]
18
+ },
19
+ "include": ["./**/*.ts"],
20
+ "exclude": ["node_modules", "dist"]
21
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "assemblyscript/std/assembly.json",
3
+ "include": ["./src/**/*.ts"],
4
+ "exclude": ["tests/**/*"],
5
+ "references": [{ "path": "./tests" }]
6
+ }
package/dist/types.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AssemblyPrimitiveTypes = exports.LibTypes = void 0;
4
+ var LibTypes;
5
+ (function (LibTypes) {
6
+ LibTypes["BigInt"] = "BigInt";
7
+ LibTypes["Address"] = "Address";
8
+ LibTypes["Bytes"] = "Bytes";
9
+ LibTypes["ChainId"] = "ChainId";
10
+ LibTypes["TokenAmount"] = "TokenAmount";
11
+ })(LibTypes || (exports.LibTypes = LibTypes = {}));
12
+ var AssemblyPrimitiveTypes;
13
+ (function (AssemblyPrimitiveTypes) {
14
+ AssemblyPrimitiveTypes["u8"] = "u8";
15
+ AssemblyPrimitiveTypes["u16"] = "u16";
16
+ AssemblyPrimitiveTypes["u32"] = "u32";
17
+ AssemblyPrimitiveTypes["u64"] = "u64";
18
+ AssemblyPrimitiveTypes["i8"] = "i8";
19
+ AssemblyPrimitiveTypes["i16"] = "i16";
20
+ AssemblyPrimitiveTypes["i32"] = "i32";
21
+ AssemblyPrimitiveTypes["i64"] = "i64";
22
+ AssemblyPrimitiveTypes["bool"] = "bool";
23
+ AssemblyPrimitiveTypes["string"] = "string";
24
+ AssemblyPrimitiveTypes["Date"] = "Date";
25
+ })(AssemblyPrimitiveTypes || (exports.AssemblyPrimitiveTypes = AssemblyPrimitiveTypes = {}));
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ManifestValidator = exports.SEM_VER_REGEX = void 0;
4
+ const zod_1 = require("zod");
5
+ const SOLIDITY_TYPE_REGEX = /^(u?int(8|16|32|64|128|256)?|bool|address|bytes([1-9]|[1-2][0-9]|3[0-2])?|string)$/;
6
+ // https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
7
+ exports.SEM_VER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
8
+ const String = zod_1.z.string().min(1);
9
+ const SolidityType = String.regex(SOLIDITY_TYPE_REGEX, 'Must be a valid solidity type');
10
+ const InputValue = zod_1.z.union([
11
+ SolidityType,
12
+ zod_1.z.object({
13
+ type: SolidityType,
14
+ description: String.optional(),
15
+ }),
16
+ ]);
17
+ exports.ManifestValidator = zod_1.z.object({
18
+ version: String.regex(exports.SEM_VER_REGEX, 'Must be a valid semver'),
19
+ name: String,
20
+ description: String,
21
+ inputs: zod_1.z.record(String, InputValue),
22
+ abis: zod_1.z.record(String, String),
23
+ metadata: zod_1.z.object({
24
+ libVersion: String.regex(exports.SEM_VER_REGEX, 'Must be a valid semver'),
25
+ }),
26
+ });
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@mimicprotocol/cli",
3
+ "version": "0.0.1-rc.10",
4
+ "license": "GPL-3.0",
5
+ "private": false,
6
+ "type": "commonjs",
7
+ "bin": {
8
+ "mimic": "./bin/run.js"
9
+ },
10
+ "scripts": {
11
+ "prepare": "yarn build",
12
+ "build": "rm -rf dist && tsc && cp -r src/templates dist/templates",
13
+ "start": "yarn build && node ./bin/run.js",
14
+ "test": "yarn build && ts-mocha ./tests --recursive --extension .spec.ts --exit --timeout 5000",
15
+ "lint": "eslint ."
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "bin"
20
+ ],
21
+ "dependencies": {
22
+ "@inquirer/prompts": "^7.2.4",
23
+ "@oclif/core": "^4.2.2",
24
+ "@oclif/plugin-not-found": "^3.2.38",
25
+ "axios": "^1.7.9",
26
+ "ethers": "^6.13.5",
27
+ "form-data": "^4.0.1",
28
+ "js-yaml": "^4.1.0",
29
+ "lodash": "^4.17.21",
30
+ "zod": "^3.24.1"
31
+ },
32
+ "devDependencies": {
33
+ "@oclif/test": "^4.1.7",
34
+ "@types/chai": "^4.3.5",
35
+ "@types/express": "4.17.17",
36
+ "@types/js-yaml": "^4.0.9",
37
+ "@types/lodash": "^4.17.15",
38
+ "@types/mocha": "^10.0.1",
39
+ "@types/node": "^22.10.5",
40
+ "axios-mock-adapter": "^2.1.0",
41
+ "chai": "^4.3.7",
42
+ "eslint-config-mimic": "^0.0.3",
43
+ "mocha": "^10.2.0",
44
+ "sinon": "^18.0.0",
45
+ "ts-mocha": "^10.0.0",
46
+ "ts-node": "^10.9.2",
47
+ "typescript": "^5.8.3"
48
+ },
49
+ "oclif": {
50
+ "bin": "mimic",
51
+ "commands": "./dist/commands",
52
+ "dirname": "mimic",
53
+ "topicSeparator": " ",
54
+ "plugins": [
55
+ "@oclif/plugin-not-found"
56
+ ]
57
+ }
58
+ }