@cosmwasm/ts-codegen 0.35.6 → 1.0.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/LICENSE-Apache +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +15 -7
- package/{types/src/builder → builder}/builder.d.ts +2 -2
- package/builder/builder.js +172 -0
- package/builder/index.js +17 -0
- package/bundler/bundler.d.ts +8 -0
- package/bundler/bundler.js +79 -0
- package/bundler/index.js +17 -0
- package/cli.d.ts +2 -0
- package/cli.js +24 -0
- package/cmds.d.ts +2 -0
- package/cmds.js +14 -0
- package/commands/create-boilerplate.d.ts +3 -0
- package/commands/create-boilerplate.js +132 -0
- package/commands/generate.d.ts +3 -0
- package/commands/generate.js +175 -0
- package/commands/install.d.ts +3 -0
- package/commands/install.js +107 -0
- package/{src/builder/builder.ts → esm/builder/builder.js} +39 -139
- package/esm/builder/index.js +1 -0
- package/esm/bundler/bundler.js +47 -0
- package/esm/bundler/index.js +1 -0
- package/esm/cli.js +20 -0
- package/{src → esm}/cmds.js +0 -1
- package/{src/commands/create-boilerplate.ts → esm/commands/create-boilerplate.js} +35 -70
- package/{src/commands/generate.ts → esm/commands/generate.js} +19 -24
- package/{src/commands/install.ts → esm/commands/install.js} +22 -35
- package/esm/file.js +18 -0
- package/esm/generators/client.js +67 -0
- package/esm/generators/create-helpers.js +36 -0
- package/esm/generators/message-composer.js +55 -0
- package/esm/generators/msg-builder.js +58 -0
- package/esm/generators/react-query.js +76 -0
- package/esm/generators/recoil.js +58 -0
- package/esm/generators/types.js +58 -0
- package/{src/index.ts → esm/index.js} +3 -6
- package/esm/plugins/client.js +59 -0
- package/esm/plugins/message-builder.js +52 -0
- package/esm/plugins/message-composer.js +46 -0
- package/esm/plugins/plugin-base.js +47 -0
- package/esm/plugins/provider-bundle.js +58 -0
- package/esm/plugins/provider.js +73 -0
- package/esm/plugins/react-query.js +69 -0
- package/esm/plugins/recoil.js +51 -0
- package/esm/plugins/types.js +38 -0
- package/{src → esm}/ts-codegen.js +1 -2
- package/{src/utils/clean.ts → esm/utils/clean.js} +7 -7
- package/{src/utils/cleanse.ts → esm/utils/cleanse.js} +18 -22
- package/esm/utils/files.js +42 -0
- package/{src/utils/parse.ts → esm/utils/parse.js} +4 -13
- package/esm/utils/prompt.js +59 -0
- package/{src/utils/schemas.ts → esm/utils/schemas.js} +16 -44
- package/esm/utils/unused.js +47 -0
- package/file.js +20 -0
- package/generators/client.js +95 -0
- package/generators/create-helpers.js +43 -0
- package/generators/message-composer.js +83 -0
- package/generators/msg-builder.js +86 -0
- package/generators/react-query.js +104 -0
- package/generators/recoil.js +86 -0
- package/generators/types.js +86 -0
- package/{module/helpers → helpers}/contractContextBase.js +5 -2
- package/{module/helpers → helpers}/contractContextBaseShortHandCtor.js +5 -2
- package/{module/helpers → helpers}/contractsContextTSX.js +5 -2
- package/{module/helpers/index.js → helpers/index.d.ts} +1 -1
- package/helpers/index.js +19 -0
- package/index.js +39 -0
- package/package.json +27 -51
- package/plugins/client.js +86 -0
- package/plugins/index.d.ts +1 -0
- package/plugins/index.js +17 -0
- package/plugins/message-builder.js +79 -0
- package/plugins/message-composer.js +73 -0
- package/{types/src/plugins → plugins}/plugin-base.d.ts +1 -1
- package/plugins/plugin-base.js +77 -0
- package/plugins/provider-bundle.js +85 -0
- package/{types/src/plugins → plugins}/provider.d.ts +2 -2
- package/plugins/provider.js +102 -0
- package/plugins/react-query.js +96 -0
- package/plugins/recoil.js +78 -0
- package/plugins/types.js +65 -0
- package/ts-codegen.js +8 -0
- package/utils/clean.js +49 -0
- package/utils/cleanse.js +89 -0
- package/utils/files.js +73 -0
- package/utils/header.js +14 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +17 -0
- package/utils/parse.d.ts +1 -0
- package/utils/parse.js +43 -0
- package/utils/prompt.d.ts +3 -0
- package/utils/prompt.js +65 -0
- package/utils/schemas.d.ts +11 -0
- package/utils/schemas.js +81 -0
- package/utils/unused.js +73 -0
- package/main/builder/builder.js +0 -308
- package/main/builder/index.js +0 -16
- package/main/bundler/bundler.js +0 -61
- package/main/bundler/index.js +0 -16
- package/main/cli.js +0 -51
- package/main/cmds.js +0 -15
- package/main/commands/create-boilerplate.js +0 -166
- package/main/commands/generate.js +0 -196
- package/main/commands/install.js +0 -138
- package/main/file.js +0 -35
- package/main/generators/client.js +0 -90
- package/main/generators/create-helpers.js +0 -38
- package/main/generators/message-composer.js +0 -77
- package/main/generators/msg-builder.js +0 -84
- package/main/generators/react-query.js +0 -102
- package/main/generators/recoil.js +0 -81
- package/main/generators/types.js +0 -82
- package/main/helpers/contractContextBase.js +0 -8
- package/main/helpers/contractContextBaseShortHandCtor.js +0 -8
- package/main/helpers/contractsContextTSX.js +0 -8
- package/main/helpers/index.js +0 -38
- package/main/index.js +0 -119
- package/main/plugins/client.js +0 -112
- package/main/plugins/index.js +0 -16
- package/main/plugins/message-builder.js +0 -102
- package/main/plugins/message-composer.js +0 -98
- package/main/plugins/plugin-base.js +0 -103
- package/main/plugins/provider-bundle.js +0 -108
- package/main/plugins/provider.js +0 -126
- package/main/plugins/react-query.js +0 -120
- package/main/plugins/recoil.js +0 -108
- package/main/plugins/types.js +0 -89
- package/main/ts-codegen.js +0 -20
- package/main/utils/clean.js +0 -53
- package/main/utils/cleanse.js +0 -87
- package/main/utils/files.js +0 -57
- package/main/utils/header.js +0 -11
- package/main/utils/index.js +0 -16
- package/main/utils/parse.js +0 -44
- package/main/utils/prompt.js +0 -98
- package/main/utils/schemas.js +0 -144
- package/main/utils/unused.js +0 -57
- package/module/builder/builder.js +0 -143
- package/module/builder/index.js +0 -1
- package/module/bundler/bundler.js +0 -36
- package/module/bundler/index.js +0 -1
- package/module/cli.js +0 -19
- package/module/cmds.js +0 -8
- package/module/commands/create-boilerplate.js +0 -102
- package/module/commands/generate.js +0 -163
- package/module/commands/install.js +0 -98
- package/module/file.js +0 -18
- package/module/generators/client.js +0 -65
- package/module/generators/create-helpers.js +0 -33
- package/module/generators/message-composer.js +0 -52
- package/module/generators/msg-builder.js +0 -58
- package/module/generators/react-query.js +0 -75
- package/module/generators/recoil.js +0 -53
- package/module/generators/types.js +0 -55
- package/module/index.js +0 -14
- package/module/plugins/client.js +0 -63
- package/module/plugins/index.js +0 -1
- package/module/plugins/message-builder.js +0 -55
- package/module/plugins/message-composer.js +0 -49
- package/module/plugins/plugin-base.js +0 -66
- package/module/plugins/provider-bundle.js +0 -56
- package/module/plugins/provider.js +0 -68
- package/module/plugins/react-query.js +0 -72
- package/module/plugins/recoil.js +0 -57
- package/module/plugins/types.js +0 -42
- package/module/ts-codegen.js +0 -6
- package/module/utils/clean.js +0 -44
- package/module/utils/cleanse.js +0 -78
- package/module/utils/files.js +0 -40
- package/module/utils/header.js +0 -8
- package/module/utils/index.js +0 -1
- package/module/utils/parse.js +0 -35
- package/module/utils/prompt.js +0 -63
- package/module/utils/schemas.js +0 -85
- package/module/utils/unused.js +0 -43
- package/src/builder/index.ts +0 -1
- package/src/bundler/bundler.ts +0 -67
- package/src/bundler/index.ts +0 -1
- package/src/cli.js +0 -21
- package/src/file.js +0 -20
- package/src/generators/client.ts +0 -109
- package/src/generators/create-helpers.ts +0 -71
- package/src/generators/message-composer.ts +0 -86
- package/src/generators/msg-builder.ts +0 -78
- package/src/generators/react-query.ts +0 -102
- package/src/generators/recoil.ts +0 -92
- package/src/generators/types.ts +0 -94
- package/src/helpers/index.ts +0 -3
- package/src/plugins/client.ts +0 -124
- package/src/plugins/index.ts +0 -1
- package/src/plugins/message-builder.ts +0 -85
- package/src/plugins/message-composer.ts +0 -89
- package/src/plugins/plugin-base.ts +0 -122
- package/src/plugins/provider-bundle.ts +0 -98
- package/src/plugins/provider.ts +0 -115
- package/src/plugins/react-query.ts +0 -115
- package/src/plugins/recoil.ts +0 -89
- package/src/plugins/types.ts +0 -74
- package/src/utils/files.ts +0 -73
- package/src/utils/index.ts +0 -1
- package/src/utils/prompt.js +0 -65
- package/src/utils/unused.ts +0 -52
- package/types/src/bundler/bundler.d.ts +0 -4
- package/types/src/cli.d.ts +0 -1
- package/types/src/cmds.d.ts +0 -1
- package/types/src/commands/create-boilerplate.d.ts +0 -2
- package/types/src/commands/generate.d.ts +0 -2
- package/types/src/commands/install.d.ts +0 -2
- package/types/src/generators/msg-builder.ts +0 -5
- package/types/src/plugins/msg-builder.d.ts +0 -12
- package/types/src/plugins/use-contracts.d.ts +0 -12
- package/types/src/types.d.ts +0 -16
- package/types/src/utils/parse.d.ts +0 -1
- package/types/src/utils/prompt.d.ts +0 -3
- package/types/src/utils/schemas.d.ts +0 -10
- /package/{types/src/builder → builder}/index.d.ts +0 -0
- /package/{types/src/bundler → bundler}/index.d.ts +0 -0
- /package/{src/helpers/contractContextBase.ts → esm/helpers/contractContextBase.js} +0 -0
- /package/{src/helpers/contractContextBaseShortHandCtor.ts → esm/helpers/contractContextBaseShortHandCtor.js} +0 -0
- /package/{src/helpers/contractsContextTSX.ts → esm/helpers/contractsContextTSX.js} +0 -0
- /package/{types/src/helpers/index.d.ts → esm/helpers/index.js} +0 -0
- /package/{types/src/plugins/index.d.ts → esm/plugins/index.js} +0 -0
- /package/{src/utils/header.ts → esm/utils/header.js} +0 -0
- /package/{types/src/utils/index.d.ts → esm/utils/index.js} +0 -0
- /package/{types/src/file.d.ts → file.d.ts} +0 -0
- /package/{types/src/generators → generators}/client.d.ts +0 -0
- /package/{types/src/generators → generators}/create-helpers.d.ts +0 -0
- /package/{types/src/generators → generators}/message-composer.d.ts +0 -0
- /package/{types/src/generators → generators}/msg-builder.d.ts +0 -0
- /package/{types/src/generators → generators}/react-query.d.ts +0 -0
- /package/{types/src/generators → generators}/recoil.d.ts +0 -0
- /package/{types/src/generators → generators}/types.d.ts +0 -0
- /package/{types/src/helpers → helpers}/contractContextBase.d.ts +0 -0
- /package/{types/src/helpers → helpers}/contractContextBaseShortHandCtor.d.ts +0 -0
- /package/{types/src/helpers → helpers}/contractsContextTSX.d.ts +0 -0
- /package/{types/src/index.d.ts → index.d.ts} +0 -0
- /package/{types/src/plugins → plugins}/client.d.ts +0 -0
- /package/{types/src/plugins → plugins}/message-builder.d.ts +0 -0
- /package/{types/src/plugins → plugins}/message-composer.d.ts +0 -0
- /package/{types/src/plugins → plugins}/provider-bundle.d.ts +0 -0
- /package/{types/src/plugins → plugins}/react-query.d.ts +0 -0
- /package/{types/src/plugins → plugins}/recoil.d.ts +0 -0
- /package/{types/src/plugins → plugins}/types.d.ts +0 -0
- /package/{types/src/ts-codegen.d.ts → ts-codegen.d.ts} +0 -0
- /package/{types/src/utils → utils}/clean.d.ts +0 -0
- /package/{types/src/utils → utils}/cleanse.d.ts +0 -0
- /package/{types/src/utils → utils}/files.d.ts +0 -0
- /package/{types/src/utils → utils}/header.d.ts +0 -0
- /package/{types/src/utils → utils}/unused.d.ts +0 -0
@@ -1,163 +0,0 @@
|
|
1
|
-
import { prompt } from '../utils/prompt';
|
2
|
-
import codegen from '../index';
|
3
|
-
export default (async argv => {
|
4
|
-
const questions = [{
|
5
|
-
_: true,
|
6
|
-
type: 'path',
|
7
|
-
name: 'schema',
|
8
|
-
message: 'which directory contains the the Rust contracts?',
|
9
|
-
default: './schema'
|
10
|
-
}, {
|
11
|
-
_: true,
|
12
|
-
type: 'path',
|
13
|
-
name: 'out',
|
14
|
-
message: 'where is the output directory?',
|
15
|
-
default: './ts'
|
16
|
-
}, {
|
17
|
-
_: true,
|
18
|
-
type: 'string',
|
19
|
-
name: 'name',
|
20
|
-
message: 'contract name?'
|
21
|
-
}, {
|
22
|
-
type: 'checkbox',
|
23
|
-
name: 'plugin',
|
24
|
-
message: 'which plugins?',
|
25
|
-
choices: ['client', 'recoil', 'react-query', 'message-composer']
|
26
|
-
}, {
|
27
|
-
type: 'confirm',
|
28
|
-
name: 'bundle',
|
29
|
-
message: 'enable bundle?',
|
30
|
-
default: true
|
31
|
-
}];
|
32
|
-
if (argv.typesOnly) {
|
33
|
-
argv.plugin = 'types';
|
34
|
-
}
|
35
|
-
let {
|
36
|
-
schema,
|
37
|
-
out,
|
38
|
-
name,
|
39
|
-
plugin,
|
40
|
-
bundle
|
41
|
-
} = await prompt(questions, argv);
|
42
|
-
if (!Array.isArray(plugin)) plugin = [plugin];
|
43
|
-
|
44
|
-
///////// REACT QUERY
|
45
|
-
const questions2 = [];
|
46
|
-
if (plugin.includes('react-query')) {
|
47
|
-
[].push.apply(questions2, [{
|
48
|
-
type: 'confirm',
|
49
|
-
name: 'optionalClient',
|
50
|
-
message: 'optionalClient?',
|
51
|
-
default: false
|
52
|
-
}, {
|
53
|
-
type: 'list',
|
54
|
-
name: 'version',
|
55
|
-
message: 'which react-query version?',
|
56
|
-
default: 'v4',
|
57
|
-
choices: ['v3', 'v4']
|
58
|
-
}, {
|
59
|
-
type: 'confirm',
|
60
|
-
name: 'queryKeys',
|
61
|
-
message: 'queryKeys?',
|
62
|
-
default: false
|
63
|
-
}]);
|
64
|
-
}
|
65
|
-
;
|
66
|
-
const {
|
67
|
-
optionalClient,
|
68
|
-
version,
|
69
|
-
queryKeys
|
70
|
-
} = await prompt(questions2, argv);
|
71
|
-
const questions3 = [];
|
72
|
-
if (version === 'v4') {
|
73
|
-
[].push.apply(questions3, [
|
74
|
-
// currently we only support v4 for useMutation
|
75
|
-
{
|
76
|
-
type: 'confirm',
|
77
|
-
name: 'mutations',
|
78
|
-
message: 'Generate useMutation hooks?',
|
79
|
-
default: false
|
80
|
-
}]);
|
81
|
-
}
|
82
|
-
;
|
83
|
-
const {
|
84
|
-
mutations
|
85
|
-
} = await prompt(questions3, argv);
|
86
|
-
const queryFactoryQuestions = [];
|
87
|
-
if (queryKeys) {
|
88
|
-
[].push.apply(queryFactoryQuestions, [
|
89
|
-
// Only can use queryFactory if queryKeys is enabled
|
90
|
-
{
|
91
|
-
type: 'confirm',
|
92
|
-
name: 'queryFactory',
|
93
|
-
message: 'queryFactory? ',
|
94
|
-
default: false
|
95
|
-
}]);
|
96
|
-
}
|
97
|
-
;
|
98
|
-
const {
|
99
|
-
queryFactory
|
100
|
-
} = await prompt(queryFactoryQuestions, argv);
|
101
|
-
///////// END REACT QUERY
|
102
|
-
|
103
|
-
///////// BUNDLE
|
104
|
-
const questions4 = [];
|
105
|
-
if (bundle) {
|
106
|
-
[].push.apply(questions4, [{
|
107
|
-
type: 'string',
|
108
|
-
name: 'bundleFile',
|
109
|
-
message: 'bundleFile?',
|
110
|
-
default: 'index.ts'
|
111
|
-
}, {
|
112
|
-
type: 'string',
|
113
|
-
name: 'bundleScope',
|
114
|
-
message: 'bundleScope?',
|
115
|
-
default: 'contracts'
|
116
|
-
}]);
|
117
|
-
}
|
118
|
-
;
|
119
|
-
const {
|
120
|
-
bundleFile,
|
121
|
-
bundleScope
|
122
|
-
} = await prompt(questions4, argv);
|
123
|
-
///////// END BUNDLE
|
124
|
-
|
125
|
-
const options = {
|
126
|
-
types: {
|
127
|
-
enabled: true
|
128
|
-
},
|
129
|
-
client: {
|
130
|
-
enabled: plugin.includes('client') || plugin.includes('recoil') || plugin.includes('react-query')
|
131
|
-
},
|
132
|
-
reactQuery: {
|
133
|
-
enabled: plugin.includes('react-query'),
|
134
|
-
optionalClient,
|
135
|
-
queryKeys,
|
136
|
-
version,
|
137
|
-
mutations,
|
138
|
-
queryFactory
|
139
|
-
},
|
140
|
-
recoil: {
|
141
|
-
enabled: plugin.includes('recoil')
|
142
|
-
},
|
143
|
-
messageComposer: {
|
144
|
-
enabled: plugin.includes('message-composer')
|
145
|
-
},
|
146
|
-
messageBuilder: {
|
147
|
-
enabled: plugin.includes('message-builder')
|
148
|
-
},
|
149
|
-
bundle: {
|
150
|
-
enabled: bundle,
|
151
|
-
scope: bundleScope,
|
152
|
-
bundleFile
|
153
|
-
}
|
154
|
-
};
|
155
|
-
await codegen({
|
156
|
-
contracts: [{
|
157
|
-
name,
|
158
|
-
dir: schema
|
159
|
-
}],
|
160
|
-
outPath: out,
|
161
|
-
options
|
162
|
-
});
|
163
|
-
});
|
@@ -1,98 +0,0 @@
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
2
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
4
|
-
import { resolve, join, dirname, basename, extname } from 'path';
|
5
|
-
import { sync as mkdirp } from 'mkdirp';
|
6
|
-
import { sync as glob } from 'glob';
|
7
|
-
import { sync as rimraf } from 'rimraf';
|
8
|
-
import { exec } from 'shelljs';
|
9
|
-
import { prompt } from '../utils/prompt';
|
10
|
-
import { parse } from 'parse-package-name';
|
11
|
-
import { tmpdir } from 'os';
|
12
|
-
import { readFileSync, writeFileSync } from 'fs';
|
13
|
-
const TMPDIR = tmpdir();
|
14
|
-
const rnd = () => Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
15
|
-
const getPackages = names => {
|
16
|
-
return names.map(pkg => {
|
17
|
-
const {
|
18
|
-
name,
|
19
|
-
version
|
20
|
-
} = parse(pkg);
|
21
|
-
return `${name}@${version}`;
|
22
|
-
}).join(' ');
|
23
|
-
};
|
24
|
-
export default (async argv => {
|
25
|
-
// don't prompt if we got this...
|
26
|
-
if (argv._.length) {
|
27
|
-
argv.pkg = argv._;
|
28
|
-
}
|
29
|
-
|
30
|
-
// current dir/package
|
31
|
-
const cur = process.cwd();
|
32
|
-
let thisPackage;
|
33
|
-
try {
|
34
|
-
thisPackage = JSON.parse(readFileSync(join(cur, 'package.json'), 'utf-8'));
|
35
|
-
} catch (e) {
|
36
|
-
throw new Error('make sure you are inside of a telescope package!');
|
37
|
-
}
|
38
|
-
|
39
|
-
// what are we installing?
|
40
|
-
let {
|
41
|
-
pkg
|
42
|
-
} = await prompt([{
|
43
|
-
type: 'checkbox',
|
44
|
-
name: 'pkg',
|
45
|
-
message: 'which chain contracts do you want to support?',
|
46
|
-
choices: ['stargaze-base-factory', 'stargaze-base-minter', 'stargaze-sg721-base', 'stargaze-sg721-metdata-onchain', 'stargaze-sg721-nt', 'stargaze-splits', 'stargaze-vending-factory', 'stargaze-vending-minter', 'stargaze-whitelist', 'wasmswap'].map(name => {
|
47
|
-
return {
|
48
|
-
name,
|
49
|
-
value: `@cosmjson/${name}`
|
50
|
-
};
|
51
|
-
})
|
52
|
-
}], argv);
|
53
|
-
|
54
|
-
// install
|
55
|
-
if (!Array.isArray(pkg)) pkg = [pkg];
|
56
|
-
const tmp = join(TMPDIR, rnd());
|
57
|
-
mkdirp(tmp);
|
58
|
-
process.chdir(tmp);
|
59
|
-
exec(`npm install ${getPackages(pkg)} --production --prefix ./smart-contracts`);
|
60
|
-
|
61
|
-
// protos
|
62
|
-
const pkgs = glob('./smart-contracts/**/package.json');
|
63
|
-
const cmds = pkgs.filter(f => {
|
64
|
-
return f !== './smart-contracts/package.json';
|
65
|
-
}).map(f => resolve(join(tmp, f))).map(conf => {
|
66
|
-
const extDir = dirname(conf);
|
67
|
-
const dir = extDir.split('node_modules/')[1];
|
68
|
-
const dst = basename(dir);
|
69
|
-
const files = glob(`${extDir}/**/*`, {
|
70
|
-
nodir: true
|
71
|
-
});
|
72
|
-
files.forEach(f => {
|
73
|
-
if (extname(f) === '.json' || f === 'package.json' || /license/i.test(f) || /readme/i.test(f)) return;
|
74
|
-
rimraf(f);
|
75
|
-
});
|
76
|
-
return [extDir, resolve(join(cur, 'contracts', dst)), dir];
|
77
|
-
});
|
78
|
-
|
79
|
-
// move protos
|
80
|
-
for (const [src, dst, pkg] of cmds) {
|
81
|
-
rimraf(dst);
|
82
|
-
console.log(`installing ${pkg}...`);
|
83
|
-
mkdirp(dirname(dst));
|
84
|
-
exec(`mv ${src} ${dst}`);
|
85
|
-
}
|
86
|
-
|
87
|
-
// package
|
88
|
-
const packageInfo = JSON.parse(readFileSync('./smart-contracts/package.json', 'utf-8'));
|
89
|
-
const deps = packageInfo.dependencies ?? {};
|
90
|
-
thisPackage.devDependencies = thisPackage.devDependencies ?? {};
|
91
|
-
thisPackage.devDependencies = _objectSpread(_objectSpread({}, thisPackage.devDependencies), deps);
|
92
|
-
thisPackage.devDependencies = Object.fromEntries(Object.entries(thisPackage.devDependencies).sort());
|
93
|
-
writeFileSync(join(cur, 'package.json'), JSON.stringify(thisPackage, null, 2));
|
94
|
-
|
95
|
-
// cleanup
|
96
|
-
rimraf(tmp);
|
97
|
-
process.chdir(cur);
|
98
|
-
});
|
package/module/file.js
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
import { prompt } from './utils/prompt';
|
3
|
-
import { cli } from './cli';
|
4
|
-
import { readFileSync } from 'fs';
|
5
|
-
const argv = require('minimist')(process.argv.slice(2));
|
6
|
-
const question = [{
|
7
|
-
_: true,
|
8
|
-
type: 'string',
|
9
|
-
name: 'file',
|
10
|
-
message: 'file'
|
11
|
-
}];
|
12
|
-
(async () => {
|
13
|
-
const {
|
14
|
-
file
|
15
|
-
} = await prompt(question, argv);
|
16
|
-
const argvv = JSON.parse(readFileSync(file, 'utf-8'));
|
17
|
-
await cli(argvv);
|
18
|
-
})();
|
@@ -1,65 +0,0 @@
|
|
1
|
-
import { pascal } from "case";
|
2
|
-
import { header } from '../utils/header';
|
3
|
-
import { join } from "path";
|
4
|
-
import { sync as mkdirp } from "mkdirp";
|
5
|
-
import * as w from 'wasm-ast-types';
|
6
|
-
import * as t from '@babel/types';
|
7
|
-
import { writeFileSync } from 'fs';
|
8
|
-
import generate from "@babel/generator";
|
9
|
-
import { getMessageProperties } from "wasm-ast-types";
|
10
|
-
import { findAndParseTypes, findExecuteMsg, findQueryMsg } from '../utils';
|
11
|
-
import { RenderContext } from "wasm-ast-types";
|
12
|
-
export default (async (name, contractInfo, outPath, tsClientOptions) => {
|
13
|
-
const {
|
14
|
-
schemas
|
15
|
-
} = contractInfo;
|
16
|
-
const context = new RenderContext(contractInfo, {
|
17
|
-
client: tsClientOptions ?? {}
|
18
|
-
});
|
19
|
-
// const options = context.options.client;
|
20
|
-
|
21
|
-
const localname = pascal(name) + '.client.ts';
|
22
|
-
const TypesFile = pascal(name) + '.types';
|
23
|
-
const QueryMsg = findQueryMsg(schemas);
|
24
|
-
const ExecuteMsg = findExecuteMsg(schemas);
|
25
|
-
const typeHash = await findAndParseTypes(schemas);
|
26
|
-
let Client = null;
|
27
|
-
let Instance = null;
|
28
|
-
let QueryClient = null;
|
29
|
-
let ReadOnlyInstance = null;
|
30
|
-
const body = [];
|
31
|
-
body.push(w.importStmt(Object.keys(typeHash), `./${TypesFile}`));
|
32
|
-
|
33
|
-
// query messages
|
34
|
-
if (QueryMsg) {
|
35
|
-
QueryClient = pascal(`${name}QueryClient`);
|
36
|
-
ReadOnlyInstance = pascal(`${name}ReadOnlyInterface`);
|
37
|
-
body.push(w.createQueryInterface(context, ReadOnlyInstance, QueryMsg));
|
38
|
-
body.push(w.createQueryClass(context, QueryClient, ReadOnlyInstance, QueryMsg));
|
39
|
-
}
|
40
|
-
|
41
|
-
// execute messages
|
42
|
-
if (ExecuteMsg) {
|
43
|
-
const children = getMessageProperties(ExecuteMsg);
|
44
|
-
if (children.length > 0) {
|
45
|
-
Client = pascal(`${name}Client`);
|
46
|
-
Instance = pascal(`${name}Interface`);
|
47
|
-
body.push(w.createExecuteInterface(context, Instance, context.options.client.execExtendsQuery ? ReadOnlyInstance : null, ExecuteMsg));
|
48
|
-
body.push(w.createExecuteClass(context, Client, Instance, context.options.client.execExtendsQuery ? QueryClient : null, ExecuteMsg));
|
49
|
-
}
|
50
|
-
}
|
51
|
-
if (typeHash.hasOwnProperty('Coin')) {
|
52
|
-
// @ts-ignore
|
53
|
-
delete context.utils.Coin;
|
54
|
-
}
|
55
|
-
const imports = context.getImports();
|
56
|
-
const code = header + generate(t.program([...imports, ...body])).code;
|
57
|
-
mkdirp(outPath);
|
58
|
-
writeFileSync(join(outPath, localname), code);
|
59
|
-
return [{
|
60
|
-
type: 'client',
|
61
|
-
contract: name,
|
62
|
-
localname,
|
63
|
-
filename: join(outPath, localname)
|
64
|
-
}];
|
65
|
-
});
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import { join, dirname, basename, extname } from "path";
|
2
|
-
import { sync as mkdirp } from "mkdirp";
|
3
|
-
import pkg from "../../package.json";
|
4
|
-
import { writeContentToFile } from "../utils/files";
|
5
|
-
import { contractContextBase, contractContextBaseShortHandCtor, contractsContextTSX } from "../helpers";
|
6
|
-
const version = process.env.NODE_ENV === "test" ? "latest" : pkg.version;
|
7
|
-
const header = `/**
|
8
|
-
* This file and any referenced files were automatically generated by ${pkg.name}@${version}
|
9
|
-
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
|
10
|
-
* and run the transpile command or yarn proto command to regenerate this bundle.
|
11
|
-
*/
|
12
|
-
\n`;
|
13
|
-
const write = (outPath, file, content, varname) => {
|
14
|
-
const outFile = join(outPath, file);
|
15
|
-
mkdirp(dirname(outFile));
|
16
|
-
writeContentToFile(outPath, header + content, outFile);
|
17
|
-
return {
|
18
|
-
type: "plugin",
|
19
|
-
pluginType: "helper",
|
20
|
-
contract: varname ?? basename(file, extname(file)),
|
21
|
-
localname: file,
|
22
|
-
filename: outFile
|
23
|
-
};
|
24
|
-
};
|
25
|
-
export const createHelpers = (input, builderContext) => {
|
26
|
-
const files = [];
|
27
|
-
if (input.options?.useContractsHooks?.enabled && Object.keys(builderContext.providers)?.length) {
|
28
|
-
const useShorthandCtor = input.options?.useShorthandCtor;
|
29
|
-
files.push(write(input.outPath, "contractContextBase.ts", useShorthandCtor ? contractContextBaseShortHandCtor : contractContextBase));
|
30
|
-
files.push(write(input.outPath, "contracts-context.tsx", contractsContextTSX, "contractsContext"));
|
31
|
-
}
|
32
|
-
return files;
|
33
|
-
};
|
@@ -1,52 +0,0 @@
|
|
1
|
-
import { pascal } from "case";
|
2
|
-
import { header } from '../utils/header';
|
3
|
-
import { join } from "path";
|
4
|
-
import { sync as mkdirp } from "mkdirp";
|
5
|
-
import * as w from 'wasm-ast-types';
|
6
|
-
import * as t from '@babel/types';
|
7
|
-
import { writeFileSync } from 'fs';
|
8
|
-
import generate from "@babel/generator";
|
9
|
-
import { getMessageProperties } from "wasm-ast-types";
|
10
|
-
import { findAndParseTypes, findExecuteMsg } from "../utils";
|
11
|
-
import { RenderContext } from "wasm-ast-types";
|
12
|
-
export default (async (name, contractInfo, outPath, messageComposerOptions) => {
|
13
|
-
const {
|
14
|
-
schemas
|
15
|
-
} = contractInfo;
|
16
|
-
const context = new RenderContext(contractInfo, {
|
17
|
-
messageComposer: messageComposerOptions ?? {}
|
18
|
-
});
|
19
|
-
// const options = context.options.messageComposer;
|
20
|
-
|
21
|
-
const localname = pascal(name) + '.message-composer.ts';
|
22
|
-
const TypesFile = pascal(name) + '.types';
|
23
|
-
const ExecuteMsg = findExecuteMsg(schemas);
|
24
|
-
const typeHash = await findAndParseTypes(schemas);
|
25
|
-
const body = [];
|
26
|
-
body.push(w.importStmt(Object.keys(typeHash), `./${TypesFile}`));
|
27
|
-
|
28
|
-
// execute messages
|
29
|
-
if (ExecuteMsg) {
|
30
|
-
const children = getMessageProperties(ExecuteMsg);
|
31
|
-
if (children.length > 0) {
|
32
|
-
const TheClass = pascal(`${name}MessageComposer`);
|
33
|
-
const Interface = pascal(`${name}Message`);
|
34
|
-
body.push(w.createMessageComposerInterface(context, Interface, ExecuteMsg));
|
35
|
-
body.push(w.createMessageComposerClass(context, TheClass, Interface, ExecuteMsg));
|
36
|
-
}
|
37
|
-
}
|
38
|
-
if (typeHash.hasOwnProperty('Coin')) {
|
39
|
-
// @ts-ignore
|
40
|
-
delete context.utils.Coin;
|
41
|
-
}
|
42
|
-
const imports = context.getImports();
|
43
|
-
const code = header + generate(t.program([...imports, ...body])).code;
|
44
|
-
mkdirp(outPath);
|
45
|
-
writeFileSync(join(outPath, localname), code);
|
46
|
-
return [{
|
47
|
-
type: 'message-composer',
|
48
|
-
contract: name,
|
49
|
-
localname,
|
50
|
-
filename: join(outPath, localname)
|
51
|
-
}];
|
52
|
-
});
|
@@ -1,58 +0,0 @@
|
|
1
|
-
import { pascal } from "case";
|
2
|
-
import { header } from "../utils/header";
|
3
|
-
import { join } from "path";
|
4
|
-
import { sync as mkdirp } from "mkdirp";
|
5
|
-
import * as w from "wasm-ast-types";
|
6
|
-
import * as t from "@babel/types";
|
7
|
-
import { writeFileSync } from "fs";
|
8
|
-
import generate from "@babel/generator";
|
9
|
-
import { getMessageProperties } from "wasm-ast-types";
|
10
|
-
import { findAndParseTypes, findExecuteMsg, findQueryMsg } from '../utils';
|
11
|
-
import { RenderContext } from 'wasm-ast-types';
|
12
|
-
export default (async (name, contractInfo, outPath, messageBuilderOptions) => {
|
13
|
-
const {
|
14
|
-
schemas
|
15
|
-
} = contractInfo;
|
16
|
-
const context = new RenderContext(contractInfo, {
|
17
|
-
messageBuilder: messageBuilderOptions ?? {}
|
18
|
-
});
|
19
|
-
const localname = pascal(name) + ".message-builder.ts";
|
20
|
-
const TypesFile = pascal(name) + ".types";
|
21
|
-
const ExecuteMsg = findExecuteMsg(schemas);
|
22
|
-
const typeHash = await findAndParseTypes(schemas);
|
23
|
-
const body = [];
|
24
|
-
body.push(w.importStmt(Object.keys(typeHash), `./${TypesFile}`));
|
25
|
-
body.push(w.importStmt(["CamelCasedProperties"], "type-fest"));
|
26
|
-
|
27
|
-
// execute messages
|
28
|
-
if (ExecuteMsg) {
|
29
|
-
const children = getMessageProperties(ExecuteMsg);
|
30
|
-
if (children.length > 0) {
|
31
|
-
const className = pascal(`${name}ExecuteMsgBuilder`);
|
32
|
-
body.push(w.createMessageBuilderClass(context, className, ExecuteMsg));
|
33
|
-
}
|
34
|
-
}
|
35
|
-
const QueryMsg = findQueryMsg(schemas);
|
36
|
-
// query messages
|
37
|
-
if (QueryMsg) {
|
38
|
-
const children = getMessageProperties(QueryMsg);
|
39
|
-
if (children.length > 0) {
|
40
|
-
const className = pascal(`${name}QueryMsgBuilder`);
|
41
|
-
body.push(w.createMessageBuilderClass(context, className, QueryMsg));
|
42
|
-
}
|
43
|
-
}
|
44
|
-
if (typeHash.hasOwnProperty("Coin")) {
|
45
|
-
// @ts-ignore
|
46
|
-
delete context.utils.Coin;
|
47
|
-
}
|
48
|
-
const imports = context.getImports();
|
49
|
-
const code = header + generate(t.program([...imports, ...body])).code;
|
50
|
-
mkdirp(outPath);
|
51
|
-
writeFileSync(join(outPath, localname), code);
|
52
|
-
return [{
|
53
|
-
type: "message-builder",
|
54
|
-
contract: name,
|
55
|
-
localname,
|
56
|
-
filename: join(outPath, localname)
|
57
|
-
}];
|
58
|
-
});
|
@@ -1,75 +0,0 @@
|
|
1
|
-
import { pascal } from "case";
|
2
|
-
import { header } from '../utils/header';
|
3
|
-
import { join } from "path";
|
4
|
-
import { sync as mkdirp } from "mkdirp";
|
5
|
-
import * as w from 'wasm-ast-types';
|
6
|
-
import { RenderContext } from 'wasm-ast-types';
|
7
|
-
import * as t from '@babel/types';
|
8
|
-
import { writeFileSync } from 'fs';
|
9
|
-
import generate from "@babel/generator";
|
10
|
-
import { findAndParseTypes, findExecuteMsg, findQueryMsg } from '../utils';
|
11
|
-
import { getMessageProperties } from "wasm-ast-types";
|
12
|
-
export default (async (contractName, contractInfo, outPath, reactQueryOptions) => {
|
13
|
-
const {
|
14
|
-
schemas
|
15
|
-
} = contractInfo;
|
16
|
-
const context = new RenderContext(contractInfo, {
|
17
|
-
reactQuery: reactQueryOptions ?? {}
|
18
|
-
});
|
19
|
-
const options = context.options.reactQuery;
|
20
|
-
const localname = pascal(`${contractName}`) + '.react-query.ts';
|
21
|
-
const ContractFile = pascal(`${contractName}`) + '.client';
|
22
|
-
const TypesFile = pascal(`${contractName}`) + '.types';
|
23
|
-
const QueryMsg = findQueryMsg(schemas);
|
24
|
-
const ExecuteMsg = findExecuteMsg(schemas);
|
25
|
-
const typeHash = await findAndParseTypes(schemas);
|
26
|
-
const ExecuteClient = pascal(`${contractName}Client`);
|
27
|
-
const QueryClient = pascal(`${contractName}QueryClient`);
|
28
|
-
const body = [];
|
29
|
-
const clientImports = [];
|
30
|
-
QueryMsg && clientImports.push(QueryClient);
|
31
|
-
|
32
|
-
// check that there are commands within the exec msg
|
33
|
-
const shouldGenerateMutationHooks = ExecuteMsg && options?.version === 'v4' && options?.mutations && getMessageProperties(ExecuteMsg).length > 0;
|
34
|
-
if (shouldGenerateMutationHooks) {
|
35
|
-
clientImports.push(ExecuteClient);
|
36
|
-
}
|
37
|
-
|
38
|
-
// general contract imports
|
39
|
-
body.push(w.importStmt(Object.keys(typeHash), `./${TypesFile}`));
|
40
|
-
|
41
|
-
// client imports
|
42
|
-
body.push(w.importStmt(clientImports, `./${ContractFile}`));
|
43
|
-
|
44
|
-
// query messages
|
45
|
-
if (QueryMsg) {
|
46
|
-
[].push.apply(body, w.createReactQueryHooks({
|
47
|
-
context,
|
48
|
-
queryMsg: QueryMsg,
|
49
|
-
contractName: contractName,
|
50
|
-
QueryClient
|
51
|
-
}));
|
52
|
-
}
|
53
|
-
if (shouldGenerateMutationHooks) {
|
54
|
-
[].push.apply(body, w.createReactQueryMutationHooks({
|
55
|
-
context,
|
56
|
-
execMsg: ExecuteMsg,
|
57
|
-
contractName: contractName,
|
58
|
-
ExecuteClient
|
59
|
-
}));
|
60
|
-
}
|
61
|
-
if (typeHash.hasOwnProperty('Coin')) {
|
62
|
-
// @ts-ignore
|
63
|
-
delete context.utils.Coin;
|
64
|
-
}
|
65
|
-
const imports = context.getImports();
|
66
|
-
const code = header + generate(t.program([...imports, ...body])).code;
|
67
|
-
mkdirp(outPath);
|
68
|
-
writeFileSync(join(outPath, localname), code);
|
69
|
-
return [{
|
70
|
-
type: 'react-query',
|
71
|
-
contract: contractName,
|
72
|
-
localname,
|
73
|
-
filename: join(outPath, localname)
|
74
|
-
}];
|
75
|
-
});
|
@@ -1,53 +0,0 @@
|
|
1
|
-
import { pascal } from "case";
|
2
|
-
import { header } from '../utils/header';
|
3
|
-
import { join } from "path";
|
4
|
-
import { sync as mkdirp } from "mkdirp";
|
5
|
-
import * as w from 'wasm-ast-types';
|
6
|
-
import * as t from '@babel/types';
|
7
|
-
import { writeFileSync } from 'fs';
|
8
|
-
import generate from "@babel/generator";
|
9
|
-
import { findAndParseTypes, findQueryMsg } from "../utils";
|
10
|
-
import { RenderContext } from "wasm-ast-types";
|
11
|
-
export default (async (name, contractInfo, outPath, recoilOptions) => {
|
12
|
-
const {
|
13
|
-
schemas
|
14
|
-
} = contractInfo;
|
15
|
-
const context = new RenderContext(contractInfo, {
|
16
|
-
recoil: recoilOptions ?? {}
|
17
|
-
});
|
18
|
-
const options = context.options.recoil;
|
19
|
-
const localname = pascal(name) + '.recoil.ts';
|
20
|
-
const ContractFile = pascal(name) + '.client';
|
21
|
-
const TypesFile = pascal(name) + '.types';
|
22
|
-
const QueryMsg = findQueryMsg(schemas);
|
23
|
-
const typeHash = await findAndParseTypes(schemas);
|
24
|
-
let QueryClient = null;
|
25
|
-
let ReadOnlyInstance = null;
|
26
|
-
const body = [];
|
27
|
-
body.push(w.importStmt(['cosmWasmClient'], './chain'));
|
28
|
-
body.push(w.importStmt(Object.keys(typeHash), `./${TypesFile}`));
|
29
|
-
|
30
|
-
// query messages
|
31
|
-
if (QueryMsg) {
|
32
|
-
QueryClient = pascal(`${name}QueryClient`);
|
33
|
-
ReadOnlyInstance = pascal(`${name}ReadOnlyInterface`);
|
34
|
-
body.push(w.importStmt([QueryClient], `./${ContractFile}`));
|
35
|
-
body.push(w.createRecoilQueryClientType());
|
36
|
-
body.push(w.createRecoilQueryClient(context, name, QueryClient));
|
37
|
-
[].push.apply(body, w.createRecoilSelectors(context, name, QueryClient, QueryMsg));
|
38
|
-
}
|
39
|
-
if (typeHash.hasOwnProperty('Coin')) {
|
40
|
-
// @ts-ignore
|
41
|
-
delete context.utils.Coin;
|
42
|
-
}
|
43
|
-
const imports = context.getImports();
|
44
|
-
const code = header + generate(t.program([...imports, ...body])).code;
|
45
|
-
mkdirp(outPath);
|
46
|
-
writeFileSync(join(outPath, localname), code);
|
47
|
-
return [{
|
48
|
-
type: 'recoil',
|
49
|
-
contract: name,
|
50
|
-
localname,
|
51
|
-
filename: join(outPath, localname)
|
52
|
-
}];
|
53
|
-
});
|
@@ -1,55 +0,0 @@
|
|
1
|
-
import { pascal } from "case";
|
2
|
-
import { header } from '../utils/header';
|
3
|
-
import { join } from "path";
|
4
|
-
import { sync as mkdirp } from "mkdirp";
|
5
|
-
import * as t from '@babel/types';
|
6
|
-
import { writeFileSync } from 'fs';
|
7
|
-
import generate from "@babel/generator";
|
8
|
-
import { clean } from "../utils/clean";
|
9
|
-
import { findAndParseTypes, findExecuteMsg, findQueryMsg } from '../utils';
|
10
|
-
import { RenderContext } from "wasm-ast-types";
|
11
|
-
export default (async (name, contractInfo, outPath, tsTypesOptions) => {
|
12
|
-
const {
|
13
|
-
schemas
|
14
|
-
} = contractInfo;
|
15
|
-
const context = new RenderContext(contractInfo, {
|
16
|
-
types: tsTypesOptions ?? {}
|
17
|
-
});
|
18
|
-
const options = context.options.types;
|
19
|
-
const localname = pascal(name) + '.types.ts';
|
20
|
-
const ExecuteMsg = findExecuteMsg(schemas);
|
21
|
-
const typeHash = await findAndParseTypes(schemas);
|
22
|
-
const body = [];
|
23
|
-
|
24
|
-
// TYPES
|
25
|
-
Object.values(typeHash).forEach(type => {
|
26
|
-
body.push(clean(type));
|
27
|
-
});
|
28
|
-
|
29
|
-
// alias the ExecuteMsg (deprecated option)
|
30
|
-
if (options.aliasExecuteMsg && ExecuteMsg) {
|
31
|
-
body.push(t.exportNamedDeclaration(t.tsTypeAliasDeclaration(t.identifier(`${name}ExecuteMsg`), null, t.tsTypeReference(t.identifier('ExecuteMsg')))));
|
32
|
-
}
|
33
|
-
function addEntryPointAlias(msgName) {
|
34
|
-
body.push(t.exportNamedDeclaration(t.tsTypeAliasDeclaration(t.identifier(`${name}${msgName}`), null, t.tsTypeReference(t.identifier(msgName)))));
|
35
|
-
}
|
36
|
-
if (options.aliasEntryPoints) {
|
37
|
-
if (ExecuteMsg) {
|
38
|
-
addEntryPointAlias('ExecuteMsg');
|
39
|
-
}
|
40
|
-
if (findQueryMsg(schemas)) {
|
41
|
-
addEntryPointAlias('QueryMsg');
|
42
|
-
}
|
43
|
-
}
|
44
|
-
const imports = context.getImports();
|
45
|
-
const code = header + generate(t.program([...imports, ...body])).code;
|
46
|
-
mkdirp(outPath);
|
47
|
-
const filename = join(outPath, localname);
|
48
|
-
writeFileSync(filename, code);
|
49
|
-
return [{
|
50
|
-
type: 'type',
|
51
|
-
contract: name,
|
52
|
-
localname,
|
53
|
-
filename
|
54
|
-
}];
|
55
|
-
});
|
package/module/index.js
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
import { TSBuilder } from './builder';
|
2
|
-
export { default as generateTypes } from './generators/types';
|
3
|
-
export { default as generateClient } from './generators/client';
|
4
|
-
export { default as generateMessageComposer } from './generators/message-composer';
|
5
|
-
export { default as generateReactQuery } from './generators/react-query';
|
6
|
-
export { default as generateRecoil } from './generators/recoil';
|
7
|
-
export * from './utils';
|
8
|
-
export * from './builder';
|
9
|
-
export * from './bundler';
|
10
|
-
export * from './plugins';
|
11
|
-
export default (async input => {
|
12
|
-
const builder = new TSBuilder(input);
|
13
|
-
await builder.build();
|
14
|
-
});
|