@cosmwasm/ts-codegen 1.12.0 → 1.13.0
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.
- package/README.md +115 -121
- package/builder/builder.js +26 -24
- package/bundler/bundler.js +27 -17
- package/cli.js +2 -2
- package/commands/create-boilerplate.js +30 -19
- package/commands/generate.js +26 -35
- package/commands/install.js +22 -18
- package/esm/builder/builder.js +10 -18
- package/esm/bundler/bundler.js +10 -10
- package/esm/cli.js +2 -2
- package/esm/commands/create-boilerplate.js +12 -11
- package/esm/commands/generate.js +26 -35
- package/esm/commands/install.js +23 -19
- package/esm/file.js +4 -3
- package/esm/plugins/client.js +1 -1
- package/esm/plugins/message-builder.js +4 -4
- package/esm/plugins/message-composer.js +1 -1
- package/esm/plugins/plugin-base.js +3 -2
- package/esm/plugins/provider-bundle.js +1 -1
- package/esm/plugins/provider.js +1 -1
- package/esm/plugins/react-query.js +8 -7
- package/esm/plugins/recoil.js +4 -4
- package/esm/plugins/types.js +3 -3
- package/esm/ts-codegen.js +2 -1
- package/esm/utils/clean.js +1 -1
- package/esm/utils/cleanse.js +9 -5
- package/esm/utils/package.js +1 -1
- package/esm/utils/parse.js +5 -7
- package/esm/utils/prompt.js +2 -2
- package/esm/utils/schemas.js +32 -19
- package/esm/utils/unused.js +3 -4
- package/file.js +7 -3
- package/package.json +13 -13
- package/plugins/client.js +18 -8
- package/plugins/message-builder.js +20 -10
- package/plugins/message-composer.js +18 -8
- package/plugins/plugin-base.js +19 -8
- package/plugins/provider-bundle.js +17 -7
- package/plugins/provider.js +17 -7
- package/plugins/react-query.js +24 -13
- package/plugins/recoil.js +20 -10
- package/plugins/types.js +19 -9
- package/ts-codegen.js +5 -1
- package/utils/clean.js +1 -1
- package/utils/cleanse.d.ts +1 -0
- package/utils/cleanse.js +12 -7
- package/utils/files.js +17 -7
- package/utils/package.js +2 -3
- package/utils/parse.js +5 -7
- package/utils/prompt.js +2 -2
- package/utils/schemas.d.ts +5 -1
- package/utils/schemas.js +34 -20
- package/utils/unused.js +20 -11
package/esm/utils/schemas.js
CHANGED
@@ -1,37 +1,50 @@
|
|
1
1
|
import { compile } from '@pyramation/json-schema-to-typescript';
|
2
2
|
import { readFileSync } from 'fs';
|
3
|
-
import {
|
3
|
+
import { globSync as glob } from 'glob';
|
4
4
|
import { cleanse } from './cleanse';
|
5
5
|
import { parser } from './parse';
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
/**
|
7
|
+
* Takes a schema directory and returns a list of relevant file paths
|
8
|
+
*/
|
9
|
+
export const findSchemaFiles = async (schemaDir) => {
|
9
10
|
const files = glob(schemaDir + '/**/*.json')
|
10
|
-
.filter(file => !file.
|
11
|
-
|
12
|
-
.
|
13
|
-
|
11
|
+
.filter((file) => !file.includes('/raw/')) // raw JSON Schema files that are also included in the main <contract_name>.json
|
12
|
+
.filter((file) => !file.includes('/cw_schema/')) // sub-folder for the new schema format for CosmWasm 3+
|
13
|
+
.sort();
|
14
|
+
return files;
|
15
|
+
};
|
16
|
+
export const readSchemas = async ({ schemaDir, clean = true, }) => {
|
17
|
+
const fn = clean
|
18
|
+
? cleanse
|
19
|
+
: (schema) => schema;
|
20
|
+
const files = (await findSchemaFiles(schemaDir)).map((path) => readFileSync(path, 'utf-8'));
|
21
|
+
if (files.length > 1) {
|
14
22
|
// legacy
|
15
23
|
// TODO add console.warn here
|
24
|
+
console.warn('Found a multiple schema files. This mode will be removed in the next major version. Please migrate the schemas that contain a single <contract_name>.json IDL file (CosmWasm 1.1+).');
|
25
|
+
const schemas = files.map((file) => JSON.parse(file));
|
16
26
|
return {
|
17
|
-
schemas: fn(schemas)
|
27
|
+
schemas: fn(schemas),
|
18
28
|
};
|
19
29
|
}
|
20
|
-
if (
|
30
|
+
if (files.length === 0) {
|
21
31
|
throw new Error('Error [too few files]: requires one schema file per contract');
|
22
32
|
}
|
23
|
-
if (
|
33
|
+
if (files.length !== 1) {
|
24
34
|
throw new Error('Error [too many files]: CosmWasm v1.1 schemas supports one file');
|
25
35
|
}
|
26
|
-
const idlObject =
|
36
|
+
const idlObject = JSON.parse(files[0]);
|
27
37
|
const {
|
28
38
|
// contract_name,
|
29
39
|
// contract_version,
|
30
|
-
idl_version, responses, instantiate, execute, query, migrate, sudo } = idlObject;
|
40
|
+
idl_version, responses, instantiate, execute, query, migrate, sudo, } = idlObject;
|
31
41
|
if (typeof idl_version !== 'string') {
|
32
42
|
// legacy
|
43
|
+
// fall back to a single JSON Schema file
|
44
|
+
console.warn('Found a single schema file with missing idl_version. This mode will be removed in the next major version. Please migrate the schemas that contain a single <contract_name>.json IDL file (CosmWasm 1.1+).');
|
45
|
+
const schema = JSON.parse(files[0]);
|
33
46
|
return {
|
34
|
-
schemas: fn(
|
47
|
+
schemas: fn([schema]),
|
35
48
|
};
|
36
49
|
}
|
37
50
|
// TODO use contract_name, etc.
|
@@ -40,23 +53,23 @@ export const readSchemas = async ({ schemaDir, clean = true }) => {
|
|
40
53
|
execute,
|
41
54
|
query,
|
42
55
|
migrate,
|
43
|
-
sudo
|
56
|
+
sudo,
|
44
57
|
};
|
45
58
|
return {
|
46
59
|
schemas: [
|
47
60
|
...Object.values(fn(idl)).filter(Boolean),
|
48
|
-
...Object.values(fn({ ...responses })).filter(Boolean)
|
61
|
+
...Object.values(fn({ ...responses })).filter(Boolean),
|
49
62
|
],
|
50
63
|
responses,
|
51
|
-
idlObject
|
64
|
+
idlObject,
|
52
65
|
};
|
53
66
|
};
|
54
67
|
export const findQueryMsg = (schemas) => {
|
55
|
-
const queryMsg = schemas.find(schema => schema.title === 'QueryMsg');
|
68
|
+
const queryMsg = schemas.find((schema) => schema.title === 'QueryMsg');
|
56
69
|
return queryMsg;
|
57
70
|
};
|
58
71
|
export const findExecuteMsg = (schemas) => {
|
59
|
-
const executeMsg = schemas.find(schema => schema.title.startsWith('ExecuteMsg'));
|
72
|
+
const executeMsg = schemas.find((schema) => schema.title.startsWith('ExecuteMsg'));
|
60
73
|
return executeMsg;
|
61
74
|
};
|
62
75
|
export const findAndParseTypes = async (schemas) => {
|
package/esm/utils/unused.js
CHANGED
@@ -13,8 +13,7 @@ export const unused = {
|
|
13
13
|
const importName = source.node.value;
|
14
14
|
if (!t.isStringLiteral(source))
|
15
15
|
continue;
|
16
|
-
const key = `${importName}(${source.node.loc &&
|
17
|
-
source.node.loc.start.line})`;
|
16
|
+
const key = `${importName}(${source.node.loc && source.node.loc.start.line})`;
|
18
17
|
if (!UnRefBindings.has(key)) {
|
19
18
|
UnRefBindings.set(key, binding);
|
20
19
|
}
|
@@ -42,6 +41,6 @@ export const unused = {
|
|
42
41
|
binding.path.parentPath.remove();
|
43
42
|
}
|
44
43
|
});
|
45
|
-
}
|
46
|
-
}
|
44
|
+
},
|
45
|
+
},
|
47
46
|
};
|
package/file.js
CHANGED
@@ -1,17 +1,21 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
"use strict";
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
5
|
+
};
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
7
|
const fs_1 = require("fs");
|
8
|
+
const minimist_1 = __importDefault(require("minimist"));
|
5
9
|
const cli_1 = require("./cli");
|
6
10
|
const prompt_1 = require("./utils/prompt");
|
7
|
-
const argv =
|
11
|
+
const argv = (0, minimist_1.default)(process.argv.slice(2));
|
8
12
|
const question = [
|
9
13
|
{
|
10
14
|
_: true,
|
11
15
|
type: 'string',
|
12
16
|
name: 'file',
|
13
|
-
message: 'file'
|
14
|
-
}
|
17
|
+
message: 'file',
|
18
|
+
},
|
15
19
|
];
|
16
20
|
(async () => {
|
17
21
|
const { file } = await (0, prompt_1.prompt)(question, argv);
|
package/package.json
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"name": "@cosmwasm/ts-codegen",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.13.0",
|
4
4
|
"description": "@cosmwasm/ts-codegen converts your CosmWasm smart contracts into dev-friendly TypeScript classes so you can focus on shipping code.",
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
6
|
-
"homepage": "https://github.com/
|
6
|
+
"homepage": "https://github.com/hyperweb-io/ts-codegen",
|
7
7
|
"license": "SEE LICENSE IN LICENSE",
|
8
8
|
"main": "index.js",
|
9
9
|
"module": "esm/index.js",
|
@@ -20,31 +20,31 @@
|
|
20
20
|
"copy": "copyfiles -f LICENSE-Apache LICENSE-MIT README.md package.json dist",
|
21
21
|
"clean": "rimraf dist/**",
|
22
22
|
"prepare": "npm run build",
|
23
|
-
"cmds": "
|
23
|
+
"cmds": "tsx ./scripts/cmds.ts",
|
24
24
|
"build": "npm run clean; tsc; tsc -p tsconfig.esm.json; npm run copy",
|
25
25
|
"lint": "eslint . --fix",
|
26
|
+
"format": "prettier --write --log-level warn \"./**/*.ts\"",
|
26
27
|
"test": "jest",
|
27
28
|
"test:watch": "jest --watch",
|
28
|
-
"dev": "
|
29
|
-
"file": "
|
29
|
+
"dev": "tsx src/ts-codegen",
|
30
|
+
"file": "tsx src/file"
|
30
31
|
},
|
31
32
|
"repository": {
|
32
33
|
"type": "git",
|
33
|
-
"url": "https://github.com/
|
34
|
+
"url": "https://github.com/hyperweb-io/ts-codegen"
|
34
35
|
},
|
35
36
|
"bugs": {
|
36
|
-
"url": "https://github.com/
|
37
|
+
"url": "https://github.com/hyperweb-io/ts-codegen/issues"
|
37
38
|
},
|
38
39
|
"devDependencies": {
|
39
|
-
"@cosmjs/cosmwasm-stargate": "0.32.3"
|
40
|
-
"ast-stringify": "0.1.0"
|
40
|
+
"@cosmjs/cosmwasm-stargate": "0.32.3"
|
41
41
|
},
|
42
42
|
"dependencies": {
|
43
43
|
"@babel/generator": "7.24.4",
|
44
44
|
"@babel/traverse": "7.24.1",
|
45
45
|
"@babel/types": "7.24.0",
|
46
|
-
"@cosmwasm/ts-codegen-ast": "^1.
|
47
|
-
"@cosmwasm/ts-codegen-types": "^1.
|
46
|
+
"@cosmwasm/ts-codegen-ast": "^1.9.0",
|
47
|
+
"@cosmwasm/ts-codegen-types": "^1.4.0",
|
48
48
|
"@pyramation/json-schema-to-typescript": " 11.0.4",
|
49
49
|
"@types/rimraf": "3.0.2",
|
50
50
|
"@types/shelljs": "0.8.15",
|
@@ -52,7 +52,7 @@
|
|
52
52
|
"dargs": "7.0.0",
|
53
53
|
"deepmerge": "4.2.2",
|
54
54
|
"fuzzy": "0.1.3",
|
55
|
-
"glob": "
|
55
|
+
"glob": "^10",
|
56
56
|
"inquirerer": "0.1.3",
|
57
57
|
"minimist": "1.2.6",
|
58
58
|
"mkdirp": "1.0.4",
|
@@ -67,5 +67,5 @@
|
|
67
67
|
"smart contracts",
|
68
68
|
"codegen"
|
69
69
|
],
|
70
|
-
"gitHead": "
|
70
|
+
"gitHead": "bbc6af3d780a810a8bdb8d905ef5413f1ab08d4b"
|
71
71
|
}
|
package/plugins/client.js
CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
15
15
|
}) : function(o, v) {
|
16
16
|
o["default"] = v;
|
17
17
|
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
};
|
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
|
+
})();
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
36
|
exports.ClientPlugin = void 0;
|
27
37
|
const w = __importStar(require("@cosmwasm/ts-codegen-ast"));
|
@@ -69,7 +79,7 @@ class ClientPlugin extends plugin_base_1.BuilderPluginBase {
|
|
69
79
|
context.addProviderInfo(name, w.PROVIDER_TYPES.SIGNING_CLIENT_TYPE, Client, localname);
|
70
80
|
}
|
71
81
|
}
|
72
|
-
if (
|
82
|
+
if (Object.prototype.hasOwnProperty.call(typeHash, 'Coin')) {
|
73
83
|
// @ts-ignore
|
74
84
|
delete context.utils.Coin;
|
75
85
|
}
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
15
15
|
}) : function(o, v) {
|
16
16
|
o["default"] = v;
|
17
17
|
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
};
|
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
|
+
})();
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
36
|
exports.MessageBuilderPlugin = void 0;
|
27
37
|
const w = __importStar(require("@cosmwasm/ts-codegen-ast"));
|
@@ -63,7 +73,7 @@ class MessageBuilderPlugin extends plugin_base_1.BuilderPluginBase {
|
|
63
73
|
body.push(w.createMessageBuilderClass(context, className, QueryMsg));
|
64
74
|
}
|
65
75
|
}
|
66
|
-
if (
|
76
|
+
if (Object.prototype.hasOwnProperty.call(typeHash, 'Coin')) {
|
67
77
|
// @ts-ignore
|
68
78
|
delete context.utils.Coin;
|
69
79
|
}
|
@@ -71,8 +81,8 @@ class MessageBuilderPlugin extends plugin_base_1.BuilderPluginBase {
|
|
71
81
|
{
|
72
82
|
type: 'message-builder',
|
73
83
|
localname,
|
74
|
-
body
|
75
|
-
}
|
84
|
+
body,
|
85
|
+
},
|
76
86
|
];
|
77
87
|
}
|
78
88
|
}
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
15
15
|
}) : function(o, v) {
|
16
16
|
o["default"] = v;
|
17
17
|
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
};
|
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
|
+
})();
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
36
|
exports.MessageComposerPlugin = void 0;
|
27
37
|
const w = __importStar(require("@cosmwasm/ts-codegen-ast"));
|
@@ -56,7 +66,7 @@ class MessageComposerPlugin extends plugin_base_1.BuilderPluginBase {
|
|
56
66
|
context.addProviderInfo(name, w.PROVIDER_TYPES.MESSAGE_COMPOSER_TYPE, TheClass, localname);
|
57
67
|
}
|
58
68
|
}
|
59
|
-
if (
|
69
|
+
if (Object.prototype.hasOwnProperty.call(typeHash, 'Coin')) {
|
60
70
|
// @ts-ignore
|
61
71
|
delete context.utils.Coin;
|
62
72
|
}
|
package/plugins/plugin-base.js
CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
15
15
|
}) : function(o, v) {
|
16
16
|
o["default"] = v;
|
17
17
|
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
};
|
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
|
+
})();
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
37
|
};
|
@@ -70,8 +80,9 @@ class BuilderPluginBase {
|
|
70
80
|
}
|
71
81
|
return results.map((result) => {
|
72
82
|
const imports = context.getImports(this.utils, result.localname);
|
83
|
+
const nodes = [...imports, ...result.body];
|
73
84
|
// @ts-ignore
|
74
|
-
const code = header_1.header + (0, generator_1.default)(t.program(
|
85
|
+
const code = header_1.header + (0, generator_1.default)(t.program(nodes)).code;
|
75
86
|
(0, mkdirp_1.sync)(outPath);
|
76
87
|
const filename = (0, path_1.join)(outPath, result.localname);
|
77
88
|
(0, fs_1.writeFileSync)(filename, code);
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
15
15
|
}) : function(o, v) {
|
16
16
|
o["default"] = v;
|
17
17
|
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
};
|
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
|
+
})();
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
36
|
exports.ContractsProviderBundlePlugin = void 0;
|
27
37
|
const w = __importStar(require("@cosmwasm/ts-codegen-ast"));
|
package/plugins/provider.js
CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
15
15
|
}) : function(o, v) {
|
16
16
|
o["default"] = v;
|
17
17
|
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
};
|
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
|
+
})();
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
36
|
exports.ContractsContextProviderPlugin = exports.GetLocalBaseNameByContractName = exports.GetLocalNameByContractName = void 0;
|
27
37
|
const w = __importStar(require("@cosmwasm/ts-codegen-ast"));
|
package/plugins/react-query.js
CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
15
15
|
}) : function(o, v) {
|
16
16
|
o["default"] = v;
|
17
17
|
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
};
|
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
|
+
})();
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
36
|
exports.ReactQueryPlugin = void 0;
|
27
37
|
const w = __importStar(require("@cosmwasm/ts-codegen-ast"));
|
@@ -50,7 +60,8 @@ class ReactQueryPlugin extends plugin_base_1.BuilderPluginBase {
|
|
50
60
|
const QueryClient = (0, case_1.pascal)(`${name}QueryClient`);
|
51
61
|
const body = [];
|
52
62
|
const clientImports = [];
|
53
|
-
|
63
|
+
if (QueryMsg)
|
64
|
+
clientImports.push(QueryClient);
|
54
65
|
// check that there are commands within the exec msg
|
55
66
|
const shouldGenerateMutationHooks = ExecuteMsg &&
|
56
67
|
options?.version === 'v4' &&
|
@@ -69,7 +80,7 @@ class ReactQueryPlugin extends plugin_base_1.BuilderPluginBase {
|
|
69
80
|
context,
|
70
81
|
queryMsg: QueryMsg,
|
71
82
|
contractName: name,
|
72
|
-
QueryClient
|
83
|
+
QueryClient,
|
73
84
|
}));
|
74
85
|
}
|
75
86
|
if (shouldGenerateMutationHooks) {
|
@@ -77,10 +88,10 @@ class ReactQueryPlugin extends plugin_base_1.BuilderPluginBase {
|
|
77
88
|
context,
|
78
89
|
execMsg: ExecuteMsg,
|
79
90
|
contractName: name,
|
80
|
-
ExecuteClient
|
91
|
+
ExecuteClient,
|
81
92
|
}));
|
82
93
|
}
|
83
|
-
if (
|
94
|
+
if (Object.prototype.hasOwnProperty.call(typeHash, 'Coin')) {
|
84
95
|
// @ts-ignore
|
85
96
|
delete context.utils.Coin;
|
86
97
|
}
|
@@ -88,8 +99,8 @@ class ReactQueryPlugin extends plugin_base_1.BuilderPluginBase {
|
|
88
99
|
{
|
89
100
|
type: 'react-query',
|
90
101
|
localname,
|
91
|
-
body
|
92
|
-
}
|
102
|
+
body,
|
103
|
+
},
|
93
104
|
];
|
94
105
|
}
|
95
106
|
}
|
package/plugins/recoil.js
CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
15
15
|
}) : function(o, v) {
|
16
16
|
o["default"] = v;
|
17
17
|
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
};
|
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
|
+
})();
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
36
|
exports.RecoilPlugin = void 0;
|
27
37
|
const w = __importStar(require("@cosmwasm/ts-codegen-ast"));
|
@@ -62,7 +72,7 @@ class RecoilPlugin extends plugin_base_1.BuilderPluginBase {
|
|
62
72
|
const selectors = w.createRecoilSelectors(context, name, QueryClient, QueryMsg);
|
63
73
|
body.push(...selectors);
|
64
74
|
}
|
65
|
-
if (
|
75
|
+
if (Object.prototype.hasOwnProperty.call(typeHash, 'Coin')) {
|
66
76
|
// @ts-ignore
|
67
77
|
delete context.utils.Coin;
|
68
78
|
}
|
@@ -70,8 +80,8 @@ class RecoilPlugin extends plugin_base_1.BuilderPluginBase {
|
|
70
80
|
{
|
71
81
|
type: 'recoil',
|
72
82
|
localname,
|
73
|
-
body
|
74
|
-
}
|
83
|
+
body,
|
84
|
+
},
|
75
85
|
];
|
76
86
|
}
|
77
87
|
}
|
package/plugins/types.js
CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
15
15
|
}) : function(o, v) {
|
16
16
|
o["default"] = v;
|
17
17
|
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
};
|
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
|
+
})();
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
36
|
exports.TypesPlugin = void 0;
|
27
37
|
const t = __importStar(require("@babel/types"));
|
@@ -57,8 +67,8 @@ class TypesPlugin extends plugin_base_1.BuilderPluginBase {
|
|
57
67
|
{
|
58
68
|
type: 'type',
|
59
69
|
localname,
|
60
|
-
body
|
61
|
-
}
|
70
|
+
body,
|
71
|
+
},
|
62
72
|
];
|
63
73
|
}
|
64
74
|
}
|
package/ts-codegen.js
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
"use strict";
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
5
|
+
};
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
7
|
+
const minimist_1 = __importDefault(require("minimist"));
|
4
8
|
const cli_1 = require("./cli");
|
5
|
-
let argv =
|
9
|
+
let argv = (0, minimist_1.default)(process.argv.slice(2));
|
6
10
|
(async () => {
|
7
11
|
await (0, cli_1.cli)(argv);
|
8
12
|
})();
|
package/utils/clean.js
CHANGED
@@ -24,7 +24,7 @@ const clean = (obj) => {
|
|
24
24
|
if (obj instanceof Object || typeof obj === 'object') {
|
25
25
|
copy = {};
|
26
26
|
for (let attr in obj) {
|
27
|
-
if (
|
27
|
+
if (Object.prototype.hasOwnProperty.call(obj, attr)) {
|
28
28
|
switch (attr) {
|
29
29
|
case 'leadingComments':
|
30
30
|
case 'trailingComments':
|
package/utils/cleanse.d.ts
CHANGED