Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// single return value (via state.getStorage), decode the value based on the
// outputType that we have specified. Fallback to Raw on nothing
const type = key.outputType || 'Raw';
const meta = key.meta || EMPTY_META;
const isEmpty = isNull(value);
// we convert to Uint8Array since it maps to the raw encoding, all
// data will be correctly encoded (incl. numbers, excl. :code)
const input = isEmpty
? null
: this.treatAsHex(key)
? value
: u8aToU8a(value);
if (meta.modifier.isOptional) {
return new Option(
this.registry,
createClass(this.registry, type),
isEmpty
? null
: createTypeUnsafe(this.registry, type, [input], true)
);
}
return createTypeUnsafe(this.registry, type, [isEmpty ? meta.fallback : input], true);
}
const buildTxParams = () => {
if (!isValid) return [];
if (!profile) {
return [ username, ipfsCid ];
} else {
// TODO update only dirty values.
const update = new ProfileUpdate({
username: new Option(Text, username),
ipfs_hash: new Option(Text, ipfsCid)
});
return [ update ];
}
};
const buildTxParams = () => {
if (!isValid) return [];
if (!struct) {
return [ slug, ipfsCid ];
} else {
// TODO update only dirty values.
const update = new BlogUpdate({
// TODO get updated writers from the form
writers: new Option(VecAccountId,(struct.writers)),
slug: new Option(Text, slug),
ipfs_hash: new Option(Text, ipfsCid)
});
return [ struct.id, update ];
}
};
const buildTxParams = () => {
if (!isValid) return [];
if (!struct) {
return [ slug, ipfsCid ];
} else {
// TODO update only dirty values.
const update = new BlogUpdate({
// TODO get updated writers from the form
writers: new Option(VecAccountId,(struct.writers)),
slug: new Option(Text, slug),
ipfs_hash: new Option(Text, ipfsCid)
});
return [ struct.id, update ];
}
};
const buildTxParams = () => {
if (!isValid) return [];
if (!profile) {
return [ username, ipfsCid ];
} else {
// TODO update only dirty values.
const update = new ProfileUpdate({
username: new Option(Text, username),
ipfs_hash: new Option(Text, ipfsCid)
});
return [ update ];
}
};
const buildTxParams = () => {
if (!isValid) return [];
if (!struct) {
return [ slug, ipfsCid ];
} else {
// TODO update only dirty values.
const update = new BlogUpdate({
// TODO get updated writers from the form
writers: new Option(VecAccountId,(struct.writers)),
slug: new Option(Text, slug),
ipfs_hash: new Option(Text, ipfsCid)
});
return [ struct.id, update ];
}
};
export function constructInfo (api: ApiInterfaceRx, index: BN | number, optionInfo?: Option): Option {
const info = optionInfo
? optionInfo.unwrapOr(null)
: null;
return new Option(
api.registry,
ReferendumInfoExtended,
isNull(info)
? null
: new ReferendumInfoExtended(api.registry, info, index)
);
}
export function formatData (registry: Registry, data: Raw, { info, type }: TypeDef): Codec {
if (info === TypeDefInfo.Option) {
return new Option(
registry,
createClass(registry, type),
createTypeUnsafe(registry, type, [data], true)
);
}
return createTypeUnsafe(registry, type, [data], true);
}