"use strict";
// Copyright 2017-2020 @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.
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Struct_1 = __importDefault(require("../../../codec/Struct"));
const util_1 = require("../util");
/**
 * @name GenericExtrinsicPayloadV2
 * @description
 * A signing payload for an [[Extrinsic]]. For the final encoding, it is variable length based
 * on the contents included
 */
class ExtrinsicPayloadV2 extends Struct_1.default {
    constructor(registry, value) {
        super(registry, {
            method: 'Bytes',
            era: 'ExtrinsicEra',
            nonce: 'Compact<Index>',
            tip: 'Compact<Balance>',
            blockHash: 'Hash'
        }, value);
    }
    /**
     * @description The block [[Hash]] the signature applies to (mortal/immortal)
     */
    get blockHash() {
        return this.get('blockHash');
    }
    /**
     * @description The [[ExtrinsicEra]]
     */
    get era() {
        return this.get('era');
    }
    /**
     * @description The [[Bytes]] contained in the payload
     */
    get method() {
        return this.get('method');
    }
    /**
     * @description The [[Index]]
     */
    get nonce() {
        return this.get('nonce');
    }
    /**
     * @description The tip [[Balance]]
     */
    get tip() {
        return this.get('tip');
    }
    /**
     * @description Sign the payload with the keypair
     */
    sign(signerPair) {
        return util_1.sign(signerPair, this.toU8a({ method: true }));
    }
}
exports.default = ExtrinsicPayloadV2;
