Allow index calc as fallback (#391)
This commit is contained in:
@@ -30,9 +30,9 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-storage#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.1.2",
|
||||
"@polkadot/keyring": "^0.32.12",
|
||||
"@polkadot/keyring": "^0.32.13",
|
||||
"@polkadot/types": "^0.31.108",
|
||||
"@polkadot/util": "^0.32.12",
|
||||
"@polkadot/util-crypto": "^0.32.12"
|
||||
"@polkadot/util": "^0.32.13",
|
||||
"@polkadot/util-crypto": "^0.32.13"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ export default function fromMetadata (metadata: Metadata): Storage {
|
||||
|
||||
const prefix = moduleMetadata.storage.prefix;
|
||||
|
||||
// For access, we change the index names, i.e. Balances.FreeBalance -> balances.freeBalance
|
||||
result[stringLowerFirst(prefix.toString())] = moduleMetadata.storage.functions.reduce((newModule, func) => {
|
||||
// Lowercase the 'f' in storage.balances.freeBalance
|
||||
newModule[stringLowerFirst(func.name.toString())] = createFunction(prefix, func.name, func);
|
||||
|
||||
return newModule;
|
||||
|
||||
@@ -7,7 +7,7 @@ import { createType } from '@polkadot/types/codec';
|
||||
import { StorageFunctionMetadata } from '@polkadot/types/Metadata';
|
||||
import { StorageFunction } from '@polkadot/types/StorageKey';
|
||||
import { Text } from '@polkadot/types/index';
|
||||
import { isNull, isUndefined, stringLowerFirst, stringToU8a, u8aConcat } from '@polkadot/util';
|
||||
import { assert, isNull, isUndefined, stringLowerFirst, stringToU8a, u8aConcat } from '@polkadot/util';
|
||||
import { xxhashAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
export interface CreateItemOptions {
|
||||
@@ -54,9 +54,7 @@ export default function createFunction (
|
||||
);
|
||||
}
|
||||
|
||||
if (isUndefined(arg) || isNull(arg)) {
|
||||
throw new Error(`${meta.name} expects one argument`);
|
||||
}
|
||||
assert(!isUndefined(arg) && !isNull(arg), `${meta.name} expects one argument`);
|
||||
|
||||
const type = meta.type.asMap.key.toString(); // Argument type, as string
|
||||
|
||||
|
||||
Reference in New Issue
Block a user