@polkadot/types/interfaces#StorageEntryTypeLatest TypeScript Examples

The following examples show how to use @polkadot/types/interfaces#StorageEntryTypeLatest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Modules.tsx    From crust-apps with Apache License 2.0 6 votes vote down vote up
function expandParams (st: StorageEntryTypeLatest, isIterable: boolean): ParamsType {
  let types: string[] = [];

  if (st.isDoubleMap) {
    types = [st.asDoubleMap.key1.toString(), st.asDoubleMap.key2.toString()];
  } else if (st.isMap) {
    types = [st.asMap.key.toString()];
  }

  return types.map((str, index) => {
    let type: TypeDefExt;

    if (isIterable && index === (types.length - 1)) {
      type = getTypeDef(`Option<${str}>`);
      type.withOptionActive = true;
    } else {
      type = getTypeDef(str);
    }

    return { type };
  });
}
Example #2
Source File: Modules.tsx    From crust-apps with Apache License 2.0 6 votes vote down vote up
function checkIterable (type: StorageEntryTypeLatest): boolean {
  const def = type.isMap
    ? getTypeDef(type.asMap.key.toString())
    : type.isDoubleMap
      ? getTypeDef(type.asDoubleMap.key2.toString())
      : null;

  // in the case of Option<type> keys, we don't allow map iteration, in this case
  // we would have option for the iterable and then option for the key value
  return !!def && def.info !== TypeDefInfo.Option;
}