Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const buildTxParams = () => {
if (!isValid) return [];
if (!struct) {
const parentCommentId = new Option(CommentId, parentId);
return [ postId, parentCommentId, ipfsCid ];
} else if (dirty) {
const update = new CommentUpdate({
ipfs_hash: new Text(ipfsCid)
});
return [ struct.id, update ];
} else {
console.log('Nothing to update in a comment');
return [];
}
};
function toV1Calls (registry: Registry, { module: { call: { functions } } }: RuntimeModuleMetadataV0): Option {
return functions.length
? new Option(registry, Vec.with('FunctionMetadataV1'), functions)
: new Option(registry, Vec.with('FunctionMetadataV1'));
}
function toV1Storage (registry: Registry, { storage }: RuntimeModuleMetadataV0): Option {
return storage.isSome
? new Option(registry, 'Vec', storage.unwrap().functions)
: new Option(registry, 'Vec');
}
function toV1Storage (registry: Registry, { storage }: RuntimeModuleMetadataV0): Option {
return storage.isSome
? new Option(registry, 'Vec', storage.unwrap().functions)
: new Option(registry, 'Vec');
}
function toV1Events (registry: Registry, metadataV0: MetadataV0, prefix: Text): Option {
const events = metadataV0.outerEvent.events.find((event): boolean => event[0].eq(prefix));
return events
? new Option(registry, Vec.with('EventMetadataV1'), events[1])
: new Option(registry, Vec.with('EventMetadataV1'));
}
modules: modules.map(({ calls, events, name, prefix, storage }): ModuleMetadataV4 =>
new ModuleMetadataV4(registry, {
calls,
events,
name,
prefix,
storage: storage.isSome
? new Option(
registry,
Vec.with(StorageFunctionMetadata),
storage.unwrap().map((v): StorageFunctionMetadata => toV4StorageFunction(registry, v))
)
: undefined
})
)