UNPKG

@open-web3/api-mobx

Version:
39 lines (29 loc) 866 B
"use strict"; exports.__esModule = true; exports.getType = getType; var _StorageKey = require("@polkadot/types/primitive/StorageKey"); var _util = require("@polkadot/util"); // Copyright 2017-2021 @polkadot/types authors & contributors // SPDX-License-Identifier: Apache-2.0 function getStorageType(type) { if (type.isPlain) { return type.asPlain.toString(); } else if (type.isMap) { return type.asMap.value.toString(); } return 'Raw'; } /** @internal */ function getType(value) { if (value instanceof _StorageKey.StorageKey) { return value.outputType; } else if ((0, _util.isFunction)(value)) { return getStorageType(value.meta.type); } else if (Array.isArray(value)) { const [fn] = value; if (fn.meta) { return getStorageType(fn.meta.type); } } // If we have no type set, default to Raw return 'Raw'; }