@mimicprotocol/cli 0.0.1-rc.21 → 0.0.1-rc.23

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.
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const core_1 = require("@oclif/core");
7
+ const codegen_1 = __importDefault(require("./codegen"));
8
+ const compile_1 = __importDefault(require("./compile"));
9
+ class Build extends core_1.Command {
10
+ async run() {
11
+ const { flags } = await this.parse(Build);
12
+ const { manifest, task, output, types, clean } = flags;
13
+ const codegenArgs = ['--manifest', manifest, '--output', types];
14
+ if (clean)
15
+ codegenArgs.push('--clean');
16
+ await codegen_1.default.run(codegenArgs);
17
+ const compileArgs = ['--task', task, '--manifest', manifest, '--output', output];
18
+ await compile_1.default.run(compileArgs);
19
+ }
20
+ }
21
+ Build.description = 'Runs code generation and then compiles the task';
22
+ Build.examples = [
23
+ '<%= config.bin %> <%= command.id %> --manifest ./manifest.yaml --task src/task.ts --output ./build --types ./src/types',
24
+ ];
25
+ Build.flags = {
26
+ manifest: core_1.Flags.string({ char: 'm', description: 'manifest to use', default: 'manifest.yaml' }),
27
+ task: core_1.Flags.string({ char: 't', description: 'task to compile', default: 'src/task.ts' }),
28
+ output: core_1.Flags.string({ char: 'o', description: 'output directory for build artifacts', default: './build' }),
29
+ types: core_1.Flags.string({ char: 'y', description: 'output directory for generated types', default: './src/types' }),
30
+ clean: core_1.Flags.boolean({
31
+ char: 'c',
32
+ description: 'remove existing generated types before generating new files',
33
+ default: false,
34
+ }),
35
+ };
36
+ exports.default = Build;
@@ -37,10 +37,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  const core_1 = require("@oclif/core");
40
- const child_process_1 = require("child_process");
41
40
  const fs = __importStar(require("fs"));
42
41
  const path = __importStar(require("path"));
43
42
  const ManifestHandler_1 = __importDefault(require("../lib/ManifestHandler"));
43
+ const packageManager_1 = require("../lib/packageManager");
44
44
  const log_1 = __importDefault(require("../log"));
45
45
  class Compile extends core_1.Command {
46
46
  async run() {
@@ -54,7 +54,6 @@ class Compile extends core_1.Command {
54
54
  const manifest = ManifestHandler_1.default.load(this, manifestDir);
55
55
  log_1.default.startAction('Compiling');
56
56
  const ascArgs = [
57
- 'asc',
58
57
  absTaskFile,
59
58
  '--target',
60
59
  'release',
@@ -65,7 +64,7 @@ class Compile extends core_1.Command {
65
64
  '--transform',
66
65
  'json-as/transform',
67
66
  ];
68
- const result = (0, child_process_1.spawnSync)('yarn', ascArgs, { stdio: 'inherit' });
67
+ const result = (0, packageManager_1.execBinCommand)('asc', ascArgs, process.cwd());
69
68
  if (result.status !== 0) {
70
69
  this.error('AssemblyScript compilation failed', {
71
70
  code: 'BuildError',
@@ -38,11 +38,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  const core_1 = require("@oclif/core");
40
40
  const axios_1 = __importStar(require("axios"));
41
- const child_process_1 = require("child_process");
42
41
  const form_data_1 = __importDefault(require("form-data"));
43
42
  const fs = __importStar(require("fs"));
44
43
  const path_1 = require("path");
45
44
  const errors_1 = require("../errors");
45
+ const packageManager_1 = require("../lib/packageManager");
46
46
  const log_1 = __importDefault(require("../log"));
47
47
  const MIMIC_REGISTRY_DEFAULT = 'https://api-protocol.mimic.fi';
48
48
  class Deploy extends core_1.Command {
@@ -52,10 +52,10 @@ class Deploy extends core_1.Command {
52
52
  const fullInputDir = (0, path_1.resolve)(inputDir);
53
53
  const fullOutputDir = (0, path_1.resolve)(outputDir);
54
54
  if (!skipCompile) {
55
- const codegen = (0, child_process_1.spawnSync)('yarn', ['mimic', 'codegen'], { stdio: 'inherit' });
55
+ const codegen = (0, packageManager_1.execBinCommand)('mimic', ['codegen'], process.cwd());
56
56
  if (codegen.status !== 0)
57
57
  this.error('Code generation failed', { code: 'CodegenError', suggestions: ['Fix manifest and ABI files'] });
58
- const compile = (0, child_process_1.spawnSync)('yarn', ['mimic', 'compile', '--output', fullInputDir], { stdio: 'inherit' });
58
+ const compile = (0, packageManager_1.execBinCommand)('mimic', ['compile', '--output', fullInputDir], process.cwd());
59
59
  if (compile.status !== 0)
60
60
  this.error('Compilation failed', { code: 'BuildError', suggestions: ['Check the task source code'] });
61
61
  }
@@ -38,16 +38,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  const prompts_1 = require("@inquirer/prompts");
40
40
  const core_1 = require("@oclif/core");
41
- const child_process_1 = require("child_process");
42
41
  const fs = __importStar(require("fs"));
43
42
  const path = __importStar(require("path"));
43
+ const simple_git_1 = __importDefault(require("simple-git"));
44
+ const packageManager_1 = require("../lib/packageManager");
44
45
  const log_1 = __importDefault(require("../log"));
45
46
  class Init extends core_1.Command {
46
47
  async run() {
47
48
  const { flags } = await this.parse(Init);
48
49
  const { directory, force } = flags;
49
50
  const fullDirectory = path.resolve(directory);
50
- const templateDirectory = path.join(__dirname, '../templates');
51
+ const originalCwd = process.cwd();
52
+ const needsCwdChange = originalCwd === fullDirectory || originalCwd.startsWith(fullDirectory + path.sep);
53
+ if (needsCwdChange) {
54
+ const parentDir = path.dirname(fullDirectory);
55
+ process.chdir(parentDir);
56
+ }
51
57
  if (force && fs.existsSync(fullDirectory) && fs.readdirSync(fullDirectory).length > 0) {
52
58
  const shouldDelete = process.env.NODE_ENV === 'test'
53
59
  ? true
@@ -73,7 +79,22 @@ class Init extends core_1.Command {
73
79
  ],
74
80
  });
75
81
  }
76
- fs.cpSync(templateDirectory, fullDirectory, { recursive: true });
82
+ if (fs.existsSync(fullDirectory) && fs.readdirSync(fullDirectory).length === 0) {
83
+ fs.rmSync(fullDirectory, { recursive: true });
84
+ }
85
+ if (!fs.existsSync(fullDirectory)) {
86
+ fs.mkdirSync(fullDirectory, { recursive: true });
87
+ }
88
+ try {
89
+ await (0, simple_git_1.default)().clone('https://github.com/mimic-protocol/init-template.git', fullDirectory);
90
+ }
91
+ catch (error) {
92
+ this.error(`Failed to clone template repository. Details: ${error}`);
93
+ }
94
+ // Remove .git to make it a fresh project repo
95
+ const gitDir = path.join(fullDirectory, '.git');
96
+ if (fs.existsSync(gitDir))
97
+ fs.rmSync(gitDir, { recursive: true, force: true });
77
98
  this.installDependencies(fullDirectory);
78
99
  this.runCodegen(fullDirectory);
79
100
  log_1.default.stopAction();
@@ -82,16 +103,12 @@ class Init extends core_1.Command {
82
103
  installDependencies(fullDirectory) {
83
104
  if (process.env.NODE_ENV === 'test')
84
105
  return;
85
- (0, child_process_1.spawnSync)('yarn', ['install'], {
86
- cwd: fullDirectory,
87
- stdio: 'inherit',
88
- });
106
+ (0, packageManager_1.installDependencies)(fullDirectory);
89
107
  }
90
108
  runCodegen(fullDirectory) {
91
- (0, child_process_1.spawnSync)('yarn', ['codegen'], {
92
- cwd: fullDirectory,
93
- stdio: 'inherit',
94
- });
109
+ if (process.env.NODE_ENV === 'test')
110
+ return;
111
+ (0, packageManager_1.execBinCommand)('mimic', ['codegen'], fullDirectory);
95
112
  }
96
113
  }
97
114
  Init.description = 'Initializes a new Mimic-compatible project structure in the specified directory';
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  const core_1 = require("@oclif/core");
37
37
  const child_process_1 = require("child_process");
38
38
  const path = __importStar(require("path"));
39
+ const packageManager_1 = require("../lib/packageManager");
39
40
  class Test extends core_1.Command {
40
41
  runOrExit(cmd, args, cwd) {
41
42
  const result = (0, child_process_1.spawnSync)(cmd, args, { cwd, stdio: 'inherit' });
@@ -47,13 +48,14 @@ class Test extends core_1.Command {
47
48
  const baseDir = path.resolve(flags.directory);
48
49
  const testPath = path.join(baseDir, 'tests');
49
50
  if (!flags.skipCompile) {
50
- this.runOrExit('yarn', ['mimic', 'codegen'], baseDir);
51
- this.runOrExit('yarn', ['mimic', 'compile'], baseDir);
51
+ const cg = (0, packageManager_1.execBinCommand)('mimic', ['codegen'], baseDir);
52
+ if (cg.status !== 0)
53
+ this.exit(cg.status ?? 1);
54
+ const cp = (0, packageManager_1.execBinCommand)('mimic', ['compile'], baseDir);
55
+ if (cp.status !== 0)
56
+ this.exit(cp.status ?? 1);
52
57
  }
53
- const result = (0, child_process_1.spawnSync)('yarn', ['tsx', './node_modules/mocha/bin/mocha.js', `${testPath}/**/*.spec.ts`], {
54
- cwd: baseDir,
55
- stdio: 'inherit',
56
- });
58
+ const result = (0, packageManager_1.execBinCommand)('tsx', ['./node_modules/mocha/bin/mocha.js', `${testPath}/**/*.spec.ts`], baseDir);
57
59
  this.exit(result.status ?? 1);
58
60
  }
59
61
  }
@@ -57,7 +57,7 @@ class FunctionHandler {
57
57
  }
58
58
  static getReturnType(fn, tupleDefinitions, abiTypeConverter) {
59
59
  if (this.isWriteFunction(fn))
60
- return 'CallBuilder';
60
+ return 'EvmCallBuilder';
61
61
  if (!fn.outputs || fn.outputs.length === 0)
62
62
  return 'void';
63
63
  if (fn.outputs.length === 1)
@@ -90,11 +90,15 @@ class FunctionHandler {
90
90
  const returnType = this.getReturnType(fn, tupleDefinitions, abiTypeConverter);
91
91
  const methodName = fn.escapedName || fn.name;
92
92
  const capitalizedName = this.getCapitalizedName(fn);
93
- lines.push(` ${methodName}(${methodParams}): ${returnType} {`);
93
+ const isPayable = fn.stateMutability === 'payable';
94
+ const fullMethodParams = methodParams.concat(isPayable ? `${methodParams.length > 0 ? ', ' : ''}value: ${types_1.LibTypes.BigInt}` : '');
95
+ lines.push(` ${methodName}(${fullMethodParams}): ${returnType} {`);
94
96
  lines.push(` const encodedData = ${contractName}Utils.encode${capitalizedName}(${inputs.map((p) => p.escapedName).join(', ')})`);
95
97
  importManager.addType(types_1.LibTypes.Bytes);
96
- importManager.addType('CallBuilder');
97
- lines.push(` return CallBuilder.forChain(this._chainId).addCall(this._address, encodedData)`);
98
+ importManager.addType('EvmCallBuilder');
99
+ if (isPayable)
100
+ importManager.addType(types_1.LibTypes.BigInt);
101
+ lines.push(` return EvmCallBuilder.forChain(this._chainId).addCall(this._address, encodedData${isPayable ? ', value' : ''})`);
98
102
  lines.push(` }`);
99
103
  lines.push('');
100
104
  }
@@ -33,15 +33,21 @@ function convertInputs(inputs) {
33
33
  }));
34
34
  }
35
35
  function generateImports(inputs) {
36
- const typesToImport = new Set(Object.values(inputs).filter((e) => e === 'Address' || e === 'Bytes' || e === 'BigInt'));
37
- if (typesToImport.size === 0)
36
+ const IMPORTABLE_TYPES = new Set(['Address', 'Bytes', 'BigInt', 'TokenAmount', 'BlockchainToken']);
37
+ const imports = new Set(Object.values(inputs).filter((type) => IMPORTABLE_TYPES.has(type)));
38
+ if (imports.size === 0)
38
39
  return '';
39
- return `import { ${[...typesToImport].sort().join(', ')} } from '@mimicprotocol/lib-ts'`;
40
+ return `import { ${[...imports].sort().join(', ')} } from '@mimicprotocol/lib-ts'`;
40
41
  }
41
42
  function generateInputsMapping(inputs, originalInputs) {
42
43
  return Object.entries(inputs)
43
44
  .map(([name, type]) => {
44
- const declaration = type === 'string' || type === 'Address' || type === 'Bytes' || type === 'BigInt'
45
+ const declaration = type === 'string' ||
46
+ type === 'Address' ||
47
+ type === 'Bytes' ||
48
+ type === 'BigInt' ||
49
+ type === 'BlockchainToken' ||
50
+ type === 'TokenAmount'
45
51
  ? `var ${name}: string | null`
46
52
  : `const ${name}: ${type}`;
47
53
  const originalInput = originalInputs[name];
@@ -75,6 +81,10 @@ function convertType(type) {
75
81
  return 'Address';
76
82
  if (type.includes('bytes'))
77
83
  return 'Bytes';
84
+ if (type === 'Token')
85
+ return 'BlockchainToken';
86
+ if (type === 'TokenAmount')
87
+ return 'TokenAmount';
78
88
  return type;
79
89
  }
80
90
  function generateGetter(name, type) {
@@ -88,6 +98,10 @@ function generateGetter(name, type) {
88
98
  returnStr = `Bytes.fromHexString(${str}!)`;
89
99
  else if (type === 'BigInt')
90
100
  returnStr = `BigInt.fromString(${str}!)`;
101
+ else if (type === 'BlockchainToken')
102
+ returnStr = `BlockchainToken.fromSerializable(${str}!)`;
103
+ else if (type === 'TokenAmount')
104
+ returnStr = `TokenAmount.fromSerializable(${str}!)`;
91
105
  else
92
106
  returnStr = str;
93
107
  return `static get ${name}(): ${type} {
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.execBinCommand = exports.installDependencies = exports.detectPackageManager = void 0;
37
+ const child_process_1 = require("child_process");
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ const detectFromUserAgent = () => {
41
+ const ua = process.env.npm_config_user_agent || '';
42
+ if (ua.includes('pnpm/'))
43
+ return 'pnpm';
44
+ if (ua.includes('yarn/'))
45
+ return 'yarn';
46
+ if (ua.includes('bun/'))
47
+ return 'bun';
48
+ if (ua.includes('npm/'))
49
+ return 'npm';
50
+ return undefined;
51
+ };
52
+ const detectFromLockfiles = (cwd) => {
53
+ const files = [
54
+ ['pnpm', 'pnpm-lock.yaml'],
55
+ ['yarn', 'yarn.lock'],
56
+ ['npm', 'package-lock.json'],
57
+ ['bun', 'bun.lockb'],
58
+ ];
59
+ for (const [pm, file] of files) {
60
+ if (fs.existsSync(path.join(cwd, file)))
61
+ return pm;
62
+ }
63
+ return undefined;
64
+ };
65
+ const detectPackageManager = (cwd) => {
66
+ return detectFromUserAgent() || detectFromLockfiles(cwd) || 'npm';
67
+ };
68
+ exports.detectPackageManager = detectPackageManager;
69
+ const installDependencies = (cwd) => {
70
+ const pm = (0, exports.detectPackageManager)(cwd);
71
+ if (pm === 'npm')
72
+ return (0, child_process_1.spawnSync)('npm', ['install'], { cwd, stdio: 'inherit' });
73
+ if (pm === 'pnpm')
74
+ return (0, child_process_1.spawnSync)('pnpm', ['install'], { cwd, stdio: 'inherit' });
75
+ if (pm === 'yarn')
76
+ return (0, child_process_1.spawnSync)('yarn', ['install'], { cwd, stdio: 'inherit' });
77
+ if (pm === 'bun')
78
+ return (0, child_process_1.spawnSync)('bun', ['install'], { cwd, stdio: 'inherit' });
79
+ return (0, child_process_1.spawnSync)('npm', ['install'], { cwd, stdio: 'inherit' });
80
+ };
81
+ exports.installDependencies = installDependencies;
82
+ const execBinCommand = (bin, args, cwd) => {
83
+ const localBin = path.join(cwd, 'node_modules', '.bin', bin);
84
+ if (fs.existsSync(localBin)) {
85
+ return (0, child_process_1.spawnSync)(localBin, args, { cwd, stdio: 'inherit' });
86
+ }
87
+ // Fallback to spawning the bin directly (global or resolved in PATH)
88
+ return (0, child_process_1.spawnSync)(bin, args, { cwd, stdio: 'inherit' });
89
+ };
90
+ exports.execBinCommand = execBinCommand;
@@ -3,17 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ManifestValidator = exports.SEM_VER_REGEX = void 0;
4
4
  const zod_1 = require("zod");
5
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
+ const TOKEN_TYPE_REGEX = /^(Token|TokenAmount)$/;
6
7
  // https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
7
8
  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
9
  const String = zod_1.z.string().min(1);
9
10
  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
- ]);
11
+ const TokenType = String.regex(TOKEN_TYPE_REGEX, 'Must be a valid token type');
12
+ const InputType = zod_1.z.union([SolidityType, TokenType]);
13
+ const InputValue = zod_1.z.union([InputType, zod_1.z.object({ type: InputType, description: String.optional() })]);
17
14
  exports.ManifestValidator = zod_1.z.object({
18
15
  version: String.regex(exports.SEM_VER_REGEX, 'Must be a valid semver'),
19
16
  name: String,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mimicprotocol/cli",
3
- "version": "0.0.1-rc.21",
3
+ "version": "0.0.1-rc.23",
4
4
  "license": "GPL-3.0",
5
5
  "private": false,
6
6
  "type": "commonjs",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "scripts": {
11
11
  "prepare": "yarn build",
12
- "build": "rm -rf dist && tsc && cp -r src/templates dist/templates",
12
+ "build": "rm -rf dist && tsc",
13
13
  "start": "yarn build && node ./bin/run.js",
14
14
  "test": "yarn build && ts-mocha ./tests --recursive --extension .spec.ts --exit --timeout 5000",
15
15
  "lint": "eslint ."
@@ -27,6 +27,7 @@
27
27
  "form-data": "^4.0.1",
28
28
  "js-yaml": "^4.1.0",
29
29
  "lodash": "^4.17.21",
30
+ "simple-git": "^3.30.0",
30
31
  "zod": "^3.24.1"
31
32
  },
32
33
  "devDependencies": {
@@ -1,89 +0,0 @@
1
- import eslintPluginTypeScript from "@typescript-eslint/eslint-plugin"
2
- import eslintParserTypeScript from "@typescript-eslint/parser"
3
- import eslintPluginImport from "eslint-plugin-import"
4
- import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort"
5
- import eslintConfigPrettier from "eslint-config-prettier"
6
- import eslintPluginPrettier from "eslint-plugin-prettier"
7
-
8
- export default [
9
- {
10
- ignores: ["node_modules/**", "**/dist/**", "**/build/**", "**/.prettierrc.*", "./src/types/**"]
11
- },
12
- {
13
- files: ["**/*.{ts,tsx}"],
14
- languageOptions: {
15
- ecmaVersion: "latest",
16
- sourceType: "module",
17
- parser: eslintParserTypeScript,
18
- parserOptions: {
19
- project: "./tsconfig.json"
20
- }
21
- },
22
- plugins: {
23
- "@typescript-eslint": eslintPluginTypeScript,
24
- prettier: eslintPluginPrettier,
25
- import: eslintPluginImport,
26
- "simple-import-sort": eslintPluginSimpleImportSort
27
- },
28
- rules: {
29
- ...eslintPluginTypeScript.configs.recommended.rules,
30
- "@typescript-eslint/no-namespace": "off",
31
- "@typescript-eslint/no-unused-vars": ["error"],
32
- "@typescript-eslint/explicit-function-return-type": "error",
33
- "@typescript-eslint/no-explicit-any": "error",
34
-
35
- "prettier/prettier": [
36
- "error",
37
- {
38
- "semi": false,
39
- "singleQuote": true,
40
- "trailingComma": "es5",
41
- "arrowParens": "always",
42
- "bracketSpacing": true,
43
- "printWidth": 120,
44
- "tabWidth": 2,
45
- "useTabs": false
46
- }
47
- ],
48
-
49
- "simple-import-sort/imports": [
50
- "error",
51
- {
52
- groups: [
53
- ["^@?\\w"],
54
- ["^\\.\\.(?!/?$)", "^\\.\\./?$"],
55
- ["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"]
56
- ]
57
- }
58
- ],
59
- "simple-import-sort/exports": "error",
60
-
61
- "comma-spacing": ["error", { before: false, after: true }],
62
- "no-multiple-empty-lines": ["error", { max: 1, maxEOF: 1 }]
63
- },
64
- settings: {
65
- "import/resolver": {
66
- typescript: {
67
- alwaysTryTypes: true,
68
- project: "./tsconfig.json"
69
- }
70
- }
71
- }
72
- },
73
- // configuration for test files
74
- {
75
- files: ["tests/**/*.{ts,tsx}", "**/*.spec.{ts,tsx}", "**/*.test.{ts,tsx}"],
76
- languageOptions: {
77
- ecmaVersion: "latest",
78
- sourceType: "module",
79
- parser: eslintParserTypeScript,
80
- parserOptions: {
81
- project: "./tests/tsconfig.json"
82
- }
83
- },
84
- rules: {
85
- "@typescript-eslint/no-unused-expressions": "off"
86
- }
87
- },
88
- eslintConfigPrettier
89
- ]
@@ -1,9 +0,0 @@
1
- version: 1.0.0
2
- name: Example Task
3
- description: Autogenerated example task
4
- inputs:
5
- - chainId: uint32
6
- - token: address
7
- - amount: uint256
8
- - recipient: address
9
- - maxFee: uint256
@@ -1,30 +0,0 @@
1
- {
2
- "name": "mimic-task",
3
- "version": "0.0.1",
4
- "license": "Unlicensed",
5
- "private": true,
6
- "type": "module",
7
- "scripts": {
8
- "build": "yarn codegen && yarn compile",
9
- "codegen": "mimic codegen",
10
- "compile": "mimic compile",
11
- "test": "mimic test",
12
- "lint": "eslint ."
13
- },
14
- "devDependencies": {
15
- "@mimicprotocol/cli": "^0.0.1-rc.0",
16
- "@mimicprotocol/lib-ts": "^0.0.1-rc.0",
17
- "@mimicprotocol/test-ts": "^0.0.1-rc.0",
18
- "@types/chai": "^5.2.2",
19
- "@types/mocha": "^10.0.10",
20
- "@types/node": "^22.10.5",
21
- "assemblyscript": "0.27.36",
22
- "chai": "^4.3.7",
23
- "eslint": "^9.10.0",
24
- "json-as": "1.1.7",
25
- "mocha": "^10.2.0",
26
- "tsx": "^4.20.3",
27
- "typescript": "^5.8.3",
28
- "visitor-as": "0.11.4"
29
- }
30
- }
@@ -1,8 +0,0 @@
1
- import { ERC20Token, Transfer } from '@mimicprotocol/lib-ts'
2
-
3
- import { inputs } from './types'
4
-
5
- export default function main(): void {
6
- const token = ERC20Token.fromAddress(inputs.token, inputs.chainId)
7
- Transfer.create(token, inputs.amount, inputs.recipient, inputs.maxFee).send()
8
- }
@@ -1,40 +0,0 @@
1
- import { runTask, Transfer } from '@mimicprotocol/test-ts'
2
- import { expect } from 'chai'
3
-
4
- describe('Task', () => {
5
- const taskDir = './'
6
-
7
- const context = {
8
- user: '0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0',
9
- settlers: [{ address: '0xdcf1d9d12a0488dfb70a8696f44d6d3bc303963d', chainId: 10 }],
10
- timestamp: Date.now(),
11
- }
12
-
13
- const inputs = {
14
- chainId: 10, // Optimism
15
- token: '0x7f5c764cbc14f9669b88837ca1490cca17c31607', // USDC
16
- amount: '1000000', // 1 USDC
17
- recipient: '0xbce3248ede29116e4bd18416dcc2dfca668eeb84',
18
- maxFee: '100000', // 0.1 USDC
19
- }
20
-
21
- it('produces the expected intents', async () => {
22
- const intents = (await runTask(taskDir, context, { inputs })) as Transfer[]
23
-
24
- expect(intents).to.be.an('array')
25
- expect(intents).to.have.lengthOf(1)
26
-
27
- expect(intents[0].type).to.be.equal('transfer')
28
- expect(intents[0].settler).to.be.equal(context.settlers[0].address)
29
- expect(intents[0].user).to.be.equal(context.user)
30
- expect(intents[0].chainId).to.be.equal(inputs.chainId)
31
- expect(intents[0].maxFees).to.have.lengthOf(1)
32
- expect(intents[0].maxFees[0].token).to.be.equal(inputs.token)
33
- expect(intents[0].maxFees[0].amount).to.be.equal(inputs.maxFee)
34
-
35
- expect(intents[0].transfers).to.have.lengthOf(1)
36
- expect(intents[0].transfers[0].token).to.be.equal(inputs.token)
37
- expect(intents[0].transfers[0].amount).to.be.equal(inputs.amount)
38
- expect(intents[0].transfers[0].recipient).to.be.equal(inputs.recipient)
39
- })
40
- })
@@ -1,21 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- {
2
- "extends": "assemblyscript/std/assembly.json",
3
- "include": ["./src/**/*.ts"],
4
- "exclude": ["tests/**/*"],
5
- "references": [{ "path": "./tests" }]
6
- }