diff --git a/src/cmds/cns-cmds/record-cmds/publish.ts b/src/cmds/cns-cmds/record-cmds/publish.ts index beb01f9..f8c1b91 100644 --- a/src/cmds/cns-cmds/record-cmds/publish.ts +++ b/src/cmds/cns-cmds/record-cmds/publish.ts @@ -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);