@taqueria/protocol 0.0.0-pr-910-e5bd3ded → 0.0.0-pr-861-c12bca08
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/Config.ts +5 -0
- package/Contract.ts +35 -0
- package/SanitizedArgs.ts +44 -0
- package/TaqError.ts +2 -0
- package/i18n.ts +6 -0
- package/package.json +1 -1
package/Config.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import createType, { Flatten } from '@taqueria/protocol/Base';
|
|
2
|
+
import * as Contract from '@taqueria/protocol/Contract';
|
|
2
3
|
import * as Environment from '@taqueria/protocol/Environment';
|
|
3
4
|
import * as InstalledPlugin from '@taqueria/protocol/InstalledPlugin';
|
|
4
5
|
import * as NetworkConfig from '@taqueria/protocol/NetworkConfig';
|
|
@@ -89,6 +90,9 @@ const commonSchema = z.object({
|
|
|
89
90
|
z.string({ description: 'config.artifactsDir' })
|
|
90
91
|
.min(1, 'config.artifactsDir must have a value'),
|
|
91
92
|
),
|
|
93
|
+
contracts: z.record(
|
|
94
|
+
Contract.rawSchema,
|
|
95
|
+
).optional(),
|
|
92
96
|
}).describe('config');
|
|
93
97
|
|
|
94
98
|
export const internalSchema = commonSchema.extend({
|
|
@@ -96,6 +100,7 @@ export const internalSchema = commonSchema.extend({
|
|
|
96
100
|
sandbox: sandboxMap,
|
|
97
101
|
environment: environmentMap,
|
|
98
102
|
accounts: accountsMap,
|
|
103
|
+
contracts: z.record(Contract.schemas.schema).optional(),
|
|
99
104
|
});
|
|
100
105
|
|
|
101
106
|
export const rawSchema = commonSchema.extend({
|
package/Contract.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import createType, { Flatten } from '@taqueria/protocol/Base';
|
|
2
|
+
import * as SHA256 from '@taqueria/protocol/SHA256';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
export const rawSchema = z.object({
|
|
6
|
+
sourceFile: z.string().min(1),
|
|
7
|
+
hash: SHA256.rawSchema,
|
|
8
|
+
// TODO: Should plugin also be provided here?
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const internalSchema = z.object({
|
|
12
|
+
sourceFile: z.string().min(1),
|
|
13
|
+
hash: SHA256.schemas.schema,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
type RawInput = z.infer<typeof rawSchema>;
|
|
17
|
+
type Input = z.infer<typeof internalSchema>;
|
|
18
|
+
|
|
19
|
+
const { schemas: generatedSchemas, factory } = createType<RawInput, Input>({
|
|
20
|
+
rawSchema,
|
|
21
|
+
internalSchema,
|
|
22
|
+
parseErrMsg: (value: unknown) => `${value} is not a valid contract`,
|
|
23
|
+
unknownErrMsg: 'Something went wrong trying to parse a contract',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export type Contract = z.infer<typeof generatedSchemas.schema>;
|
|
27
|
+
|
|
28
|
+
export type t = Contract;
|
|
29
|
+
|
|
30
|
+
export const { create, of, make } = factory;
|
|
31
|
+
|
|
32
|
+
export const schemas = {
|
|
33
|
+
...generatedSchemas,
|
|
34
|
+
schema: generatedSchemas.schema.transform(val => val as Contract),
|
|
35
|
+
};
|
package/SanitizedArgs.ts
CHANGED
|
@@ -86,11 +86,33 @@ export const versionRawSchema = rawSchema.extend({
|
|
|
86
86
|
version: z.boolean().default(true),
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
+
export const addContractsRawSchema = z.preprocess(
|
|
90
|
+
val => {
|
|
91
|
+
const obj: {
|
|
92
|
+
contractName?: string;
|
|
93
|
+
sourceFile?: string;
|
|
94
|
+
} = typeof val === 'object' ? Object(val) : ({ contractName: '', sourceFile: '' });
|
|
95
|
+
return !obj.contractName && obj.sourceFile
|
|
96
|
+
? { ...obj, contractName: obj['sourceFile'] }
|
|
97
|
+
: obj;
|
|
98
|
+
},
|
|
99
|
+
rawSchema.extend({
|
|
100
|
+
sourceFile: z.string().min(1),
|
|
101
|
+
contractName: z.string().min(1),
|
|
102
|
+
}),
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
export const removeContractsRawSchema = rawSchema.extend({
|
|
106
|
+
contractName: z.string().min(1),
|
|
107
|
+
});
|
|
108
|
+
|
|
89
109
|
type RawInput = z.infer<typeof rawSchema>;
|
|
90
110
|
type RawScaffoldInput = z.infer<typeof scaffoldRawSchema>;
|
|
91
111
|
type RawProvisionInput = z.infer<typeof provisionRawSchema>;
|
|
92
112
|
type RawManagePluginInput = z.infer<typeof managePluginRawSchema>;
|
|
93
113
|
type RawVersionInput = z.infer<typeof versionRawSchema>;
|
|
114
|
+
type RawAddContractsInput = z.infer<typeof addContractsRawSchema>;
|
|
115
|
+
type RawRemoveContractsInput = z.infer<typeof removeContractsRawSchema>;
|
|
94
116
|
|
|
95
117
|
export const { schemas: generatedSchemas, factory } = createType<RawInput, RawInput>({
|
|
96
118
|
rawSchema,
|
|
@@ -132,10 +154,24 @@ export const uninstallTaskArgs = createType<RawManagePluginInput, RawManagePlugi
|
|
|
132
154
|
unknownErrMsg: 'Something went wrong parsing the arguments for the uninstall task',
|
|
133
155
|
});
|
|
134
156
|
|
|
157
|
+
export const addContractArgs = createType<RawAddContractsInput, RawAddContractsInput>({
|
|
158
|
+
rawSchema: addContractsRawSchema,
|
|
159
|
+
parseErrMsg: 'Please specify the source file to register.',
|
|
160
|
+
unknownErrMsg: 'Something went wrong parsing the arguments for registering a contract.',
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
export const removeContractsArgs = createType<RawRemoveContractsInput, RawRemoveContractsInput>({
|
|
164
|
+
rawSchema: removeContractsRawSchema,
|
|
165
|
+
parseErrMsg: 'Please specify the contract name to unregister.',
|
|
166
|
+
unknownErrMsg: 'Something went wrong parsing the arguments to unregister a contract.',
|
|
167
|
+
});
|
|
168
|
+
|
|
135
169
|
export type ScaffoldTaskArgs = z.infer<typeof scaffoldTaskArgs.schemas.schema>;
|
|
136
170
|
export type ProvisionTaskArgs = z.infer<typeof provisionTaskArgs.schemas.schema>;
|
|
137
171
|
export type InstallTaskArgs = z.infer<typeof installTaskArgs.schemas.schema>;
|
|
138
172
|
export type UninstallTaskArgs = z.infer<typeof uninstallTaskArgs.schemas.schema>;
|
|
173
|
+
export type AddContractArgs = z.infer<typeof addContractArgs.schemas.schema>;
|
|
174
|
+
export type RemoveContractArgs = z.infer<typeof removeContractsArgs.schemas.schema>;
|
|
139
175
|
|
|
140
176
|
export const createScaffoldTaskArgs = scaffoldTaskArgs.factory.from;
|
|
141
177
|
export const makeScaffoldTaskArgs = scaffoldTaskArgs.factory.make;
|
|
@@ -152,3 +188,11 @@ export const ofInstallTaskArgs = installTaskArgs.factory.of;
|
|
|
152
188
|
export const createUninstallTaskArgs = uninstallTaskArgs.factory.create;
|
|
153
189
|
export const makeUninstallTaskArgs = uninstallTaskArgs.factory.make;
|
|
154
190
|
export const ofUninstallTaskArgs = uninstallTaskArgs.factory.of;
|
|
191
|
+
|
|
192
|
+
export const createAddContractArgs = addContractArgs.factory.create;
|
|
193
|
+
export const makeAddContractArgs = addContractArgs.factory.make;
|
|
194
|
+
export const ofAddContractArgs = addContractArgs.factory.of;
|
|
195
|
+
|
|
196
|
+
export const createRemoveContractsArgs = removeContractsArgs.factory.create;
|
|
197
|
+
export const makeRemoveContractsArgs = removeContractsArgs.factory.make;
|
|
198
|
+
export const ofRemoveContractsArgs = removeContractsArgs.factory.of;
|
package/TaqError.ts
CHANGED
package/i18n.ts
CHANGED
|
@@ -54,6 +54,12 @@ export default async (): Promise<i18n> => {
|
|
|
54
54
|
'buildDesc': 'Display build information about the current version',
|
|
55
55
|
'pluginOption': "Use to specify what plugin you'd like when running this task.",
|
|
56
56
|
'yesOptionDesc': 'Select "yes" to any prompt',
|
|
57
|
+
'addContractDesc': 'Add a contract to the contract registry',
|
|
58
|
+
'addSourceFileDesc': 'Source file to add to the contract registry',
|
|
59
|
+
'removeContractDesc': 'Remove a contract from the contract registry',
|
|
60
|
+
'removeContractNameDesc': 'The name of the contract to remove',
|
|
61
|
+
'noContractsRegistered': 'No registered contracts found',
|
|
62
|
+
'listContractsDesc': 'List registered contracts',
|
|
57
63
|
},
|
|
58
64
|
},
|
|
59
65
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taqueria/protocol",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-861-c12bca08",
|
|
4
4
|
"description": "A TypeScript package which contains types that are to be shared between @taqueria/node-sdk and @taqueria/taqueria.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|