How to use the @polkadot/types/codec.Option function in @polkadot/types

To help you get started, we’ve selected a few @polkadot/types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dappforce / dappforce-subsocial-ui / src / components / posts / EditComment.tsx View on Github external
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 [];
    }
  };
github polkadot-js / api / packages / metadata / src / Metadata / v0 / toV1.ts View on Github external
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'));
}
github polkadot-js / api / packages / metadata / src / Metadata / v0 / toV1.ts View on Github external
function toV1Storage (registry: Registry, { storage }: RuntimeModuleMetadataV0): Option {
  return storage.isSome
    ? new Option(registry, 'Vec', storage.unwrap().functions)
    : new Option(registry, 'Vec');
}
github polkadot-js / api / packages / metadata / src / Metadata / v0 / toV1.ts View on Github external
function toV1Storage (registry: Registry, { storage }: RuntimeModuleMetadataV0): Option {
  return storage.isSome
    ? new Option(registry, 'Vec', storage.unwrap().functions)
    : new Option(registry, 'Vec');
}
github polkadot-js / api / packages / metadata / src / Metadata / v0 / toV1.ts View on Github external
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'));
}
github polkadot-js / api / packages / metadata / src / Metadata / v3 / toV4.ts View on Github external
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
      })
    )