Use custom hasher for Map (#857)
* Use blake2 instead of two_x * Add v4 * Update to new v4 static * Update json * Revert * Use hasher enum * Fix metadata v4 test * Fix metadata v4 test * Fix versioned metadata * refactor & clean * Use consistent naming * Make jsons consistent * Add backward compat * Fix tests * Start working on type-storage * Fix output * Grumble * Update to latest static * Clean code * Fix imports * Remove useless imports * Fix tests * Use prettier output for toJSON in metadata * Implement different hashers * Remove generic storageKey * Bump version * Add backwards-compat * Fix hashing function, use Twox128 * Grumbles * Add tests
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-core",
|
||||
"version": "0.77.0-beta.7",
|
||||
"version": "0.77.0",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -30,9 +30,9 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.3",
|
||||
"@polkadot/jsonrpc": "^0.77.0-beta.7",
|
||||
"@polkadot/rpc-provider": "^0.77.0-beta.7",
|
||||
"@polkadot/types": "^0.77.0-beta.7",
|
||||
"@polkadot/jsonrpc": "^0.77.0",
|
||||
"@polkadot/rpc-provider": "^0.77.0",
|
||||
"@polkadot/types": "^0.77.0",
|
||||
"@polkadot/util": "^0.76.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ export default class Rpc implements RpcInterface {
|
||||
const key = params[0] as StorageKey;
|
||||
const type = key.outputType || 'Data';
|
||||
const Clazz = createClass(type);
|
||||
const meta = key.meta || { default: undefined, modifier: { isOptional: true } };
|
||||
const meta = key.meta || { fallback: undefined, modifier: { isOptional: true } };
|
||||
|
||||
if (key.meta && key.meta.type.isMap && key.meta.type.asMap.isLinked) {
|
||||
// linked map
|
||||
@@ -218,11 +218,11 @@ export default class Rpc implements RpcInterface {
|
||||
const { value } = (base as StorageChangeSet).changes.find((item) =>
|
||||
item.key.toHex() === hexKey
|
||||
) || { value: null };
|
||||
const meta = key.meta || { default: undefined, modifier: { isOptional: true } };
|
||||
const meta = key.meta || { fallback: undefined, modifier: { isOptional: true } };
|
||||
|
||||
if (!value) {
|
||||
// if we don't have a value, do not fill in the entry, it will be up to the
|
||||
// caller to sort this out, either ignoring or having a cache for older values
|
||||
// caller to sort this out, either ignoring or having a cache for older values
|
||||
result.push(undefined);
|
||||
} else {
|
||||
if (key.meta && key.meta.type.isMap && key.meta.type.asMap.isLinked) {
|
||||
@@ -236,7 +236,7 @@ export default class Rpc implements RpcInterface {
|
||||
} else {
|
||||
// for `null` we fallback to the default value, or create an empty type,
|
||||
// otherwise we return the actual value as retrieved
|
||||
result.push(new Clazz(value.unwrapOr(meta.default)));
|
||||
result.push(new Clazz(value.unwrapOr(meta.fallback)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user