Convert sub-objects (other than arrays) in YAML to JSON strings automatically. (#38)
This allows us to support attributes in YAML like this: ``` meta: foo: bar bar: baz: boz ``` Which will automatically become: ``` "meta": "{\"foo\":\"bar\",\"bar\":{\"baz\":\"boz\"}}" ``` > Note: cosmos-sdk's protobuf code does not support maps (https://github.com/cosmos/cosmos-sdk/issues/15254), or else we would just use a map. Reviewed-on: cerc-io/laconic-registry-cli#38 Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com> Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
This commit is contained in:
parent
37b69da3bb
commit
129019105d
@ -36,6 +36,14 @@ export const handler = async (argv: Arguments) => {
|
||||
}
|
||||
|
||||
const { record } = await yaml.load(fs.readFileSync(file, 'utf-8')) as any;
|
||||
|
||||
// Convert sub-objects (other than arrays) to a JSON automatically.
|
||||
for (const [k, v] of Object.entries(record)) {
|
||||
if (v && typeof v === "object" && !Array.isArray(v)) {
|
||||
record[k] = JSON.stringify(v);
|
||||
}
|
||||
}
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.setRecord({ privateKey: userKey, record, bondId }, txKey as string, fee);
|
||||
|
Loading…
Reference in New Issue
Block a user