diff --git a/jest.config.cjs b/jest.config.cjs index aa952fda00..8f24cbf5ca 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -3,7 +3,8 @@ const config = require('@polkadot/dev/config/jest.cjs'); -module.exports = Object.assign({}, config, { +module.exports = { + ...config, moduleNameMapper: { '@polkadot/api-(contract|derive)(.*)$': '/packages/api-$1/src/$2', // eslint-disable-next-line sort-keys @@ -27,4 +28,4 @@ module.exports = Object.assign({}, config, { '/packages/types-known/build' ], transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)'] -}); +}; diff --git a/packages/types/src/interfaces/contracts/definitions.ts b/packages/types/src/interfaces/contracts/definitions.ts index 86beec74bb..a20932b820 100644 --- a/packages/types/src/interfaces/contracts/definitions.ts +++ b/packages/types/src/interfaces/contracts/definitions.ts @@ -231,6 +231,7 @@ export default { instantiatePerCodeByte: 'Weight', instantiatePerInputByte: 'Weight', instantiatePerOutputByte: 'Weight', + instantiatePerSaltByte: 'Weight', hashSha2256: 'Weight', hashSha2256PerByte: 'Weight', hashKeccak256: 'Weight', diff --git a/packages/types/src/interfaces/contracts/types.ts b/packages/types/src/interfaces/contracts/types.ts index bc68b00255..2012d150cf 100644 --- a/packages/types/src/interfaces/contracts/types.ts +++ b/packages/types/src/interfaces/contracts/types.ts @@ -157,6 +157,7 @@ export interface HostFnWeights extends Struct { readonly instantiatePerCodeByte: Weight; readonly instantiatePerInputByte: Weight; readonly instantiatePerOutputByte: Weight; + readonly instantiatePerSaltByte: Weight; readonly hashSha2256: Weight; readonly hashSha2256PerByte: Weight; readonly hashKeccak256: Weight; diff --git a/packages/types/src/interfaces/system/definitions.ts b/packages/types/src/interfaces/system/definitions.ts index 374a6f83c7..7e3c901805 100644 --- a/packages/types/src/interfaces/system/definitions.ts +++ b/packages/types/src/interfaces/system/definitions.ts @@ -134,7 +134,7 @@ export default { } }, types: { - AccountInfo: 'AccountInfoWithRefCount', + AccountInfo: 'AccountInfoWithTripleRefCount', AccountInfoWithRefCount: { nonce: 'Index', refcount: 'RefCount', diff --git a/packages/types/src/interfaces/system/types.ts b/packages/types/src/interfaces/system/types.ts index 92d2e18880..843ba9cd52 100644 --- a/packages/types/src/interfaces/system/types.ts +++ b/packages/types/src/interfaces/system/types.ts @@ -7,7 +7,7 @@ import type { AccountData } from '@polkadot/types/interfaces/balances'; import type { AccountId, BlockNumber, Digest, Hash, Index, Pays, Weight } from '@polkadot/types/interfaces/runtime'; /** @name AccountInfo */ -export interface AccountInfo extends AccountInfoWithRefCount {} +export interface AccountInfo extends AccountInfoWithTripleRefCount {} /** @name AccountInfoWithDualRefCount */ export interface AccountInfoWithDualRefCount extends Struct { diff --git a/packages/types/src/primitive/StorageKey.ts b/packages/types/src/primitive/StorageKey.ts index 7fbbc3f632..7e41e56367 100644 --- a/packages/types/src/primitive/StorageKey.ts +++ b/packages/types/src/primitive/StorageKey.ts @@ -85,6 +85,7 @@ function decodeStorageKey (value?: AnyU8a | StorageKey | StorageEntry | [Storage throw new Error(`Unable to convert input ${value as string} to StorageKey`); } +/** @internal */ function decodeHashers (registry: Registry, value: Uint8Array, hashers: [StorageHasher, string][]): A { // the storage entry is xxhashAsU8a(prefix, 128) + xxhashAsU8a(method, 128), 256 bits total let offset = 32; @@ -124,6 +125,39 @@ function decodeArgsFromMeta (registry: Registry, value: Uin ]); } +/** @internal */ +function getMeta (value: StorageKey | StorageEntry | [StorageEntry, any]): StorageEntryMetadataLatest | undefined { + if (value instanceof StorageKey) { + return value.meta; + } else if (isFunction(value)) { + return value.meta; + } else if (Array.isArray(value)) { + const [fn] = value; + + return fn.meta; + } + + return undefined; +} + +/** @internal */ +function getType (value: StorageKey | StorageEntry | [StorageEntry, any]): string { + if (value instanceof StorageKey) { + return value.outputType; + } else if (isFunction(value)) { + return unwrapStorageType(value.meta.type); + } else if (Array.isArray(value)) { + const [fn] = value; + + if (fn.meta) { + return unwrapStorageType(fn.meta.type); + } + } + + // If we have no type set, default to Raw + return 'Raw'; +} + /** * @name StorageKey * @description @@ -148,41 +182,10 @@ export class StorageKey extends Bytes implements super(registry, key); - this._outputType = StorageKey.getType(value as StorageKey); + this._outputType = getType(value as StorageKey); // decode the args (as applicable based on the key and the hashers, after all init) - this.setMeta(StorageKey.getMeta(value as StorageKey), override.section || section, override.method || method); - } - - public static getMeta (value: StorageKey | StorageEntry | [StorageEntry, any]): StorageEntryMetadataLatest | undefined { - if (value instanceof StorageKey) { - return value.meta; - } else if (isFunction(value)) { - return value.meta; - } else if (Array.isArray(value)) { - const [fn] = value; - - return fn.meta; - } - - return undefined; - } - - public static getType (value: StorageKey | StorageEntry | [StorageEntry, any]): string { - if (value instanceof StorageKey) { - return value.outputType; - } else if (isFunction(value)) { - return unwrapStorageType(value.meta.type); - } else if (Array.isArray(value)) { - const [fn] = value; - - if (fn.meta) { - return unwrapStorageType(fn.meta.type); - } - } - - // If we have no type set, default to Raw - return 'Raw'; + this.setMeta(getMeta(value as StorageKey), override.section || section, override.method || method); } /**