"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = toV7;

var _v = _interopRequireDefault(require("../v7"));

var _Metadata = require("../v7/Metadata");

var _Storage = require("../v7/Storage");

// Copyright 2017-2019 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

/**
 * Convert from MetadataV6 to MetadataV7
 */
function toV7(_ref) {
  let {
    modules
  } = _ref;
  return new _v.default({
    modules: modules.map((_ref2) => {
      let {
        calls,
        constants,
        events,
        name,
        prefix,
        storage
      } = _ref2;
      return new _Metadata.ModuleMetadataV7({
        calls,
        constants,
        events,
        name,
        storage: storage.isSome ? new _Storage.StorageMetadata({
          prefix,
          items: storage.unwrap()
        }) : null
      });
    })
  });
}