/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
import { web3, Contract, toApiVals, binToHex, contractIdFromAddress, fromApiArray, fromApiVals, subscribeToEvents, } from "@alephium/web3";
var Governance = /** @class */ (function () {
    function Governance(address, contractId, groupIndex, deployResult) {
        this.address = address;
        this.contractId = contractId;
        this.groupIndex = groupIndex;
        this.deployResult = deployResult;
    }
    Governance.deploy = function (signer, chainId, governanceChainId, governanceEmitterAddress, receivedSequence, messageFee, guardianSets, guardianSetIndexes, previousGuardianSetExpirationTimeMS, _extraParams) {
        return __awaiter(this, void 0, void 0, function () {
            var _deployResult;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, Governance.contract.deploy(signer, {
                            initialFields: {
                                chainId: chainId,
                                governanceChainId: governanceChainId,
                                governanceEmitterAddress: governanceEmitterAddress,
                                receivedSequence: receivedSequence,
                                messageFee: messageFee,
                                guardianSets: guardianSets,
                                guardianSetIndexes: guardianSetIndexes,
                                previousGuardianSetExpirationTimeMS: previousGuardianSetExpirationTimeMS,
                            },
                            initialAttoAlphAmount: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAttoAlphAmount,
                            initialTokenAmounts: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialTokenAmounts,
                            issueTokenAmount: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.issueTokenAmount,
                            gasAmount: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.gasAmount,
                            gasPrice: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.gasPrice,
                        })];
                    case 1:
                        _deployResult = _a.sent();
                        return [2 /*return*/, new Governance(_deployResult.contractAddress, _deployResult.contractId, _deployResult.fromGroup, _deployResult)];
                }
            });
        });
    };
    Governance.connect = function (address, deployResult) {
        var contractId = binToHex(contractIdFromAddress(address));
        var groupIndex = parseInt(contractId.slice(-2));
        return new Governance(address, contractId, groupIndex, deployResult);
    };
    Governance.prototype.fetchState = function () {
        return __awaiter(this, void 0, void 0, function () {
            var state;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, Governance.contract.fetchState(this.address, this.groupIndex)];
                    case 1:
                        state = _a.sent();
                        return [2 /*return*/, __assign(__assign({}, state), { chainId: state.fields["chainId"], governanceChainId: state.fields["governanceChainId"], governanceEmitterAddress: state.fields["governanceEmitterAddress"], receivedSequence: state.fields["receivedSequence"], messageFee: state.fields["messageFee"], guardianSets: state.fields["guardianSets"], guardianSetIndexes: state.fields["guardianSetIndexes"], previousGuardianSetExpirationTimeMS: state.fields["previousGuardianSetExpirationTimeMS"] })];
                }
            });
        });
    };
    Governance.prototype.decodeWormholeMessage = function (event) {
        if (event.eventIndex !== 0) {
            throw new Error("Invalid event index: " + event.eventIndex + ", expected: 0");
        }
        var fields = fromApiVals(event.fields, [
            "sender",
            "targetChainId",
            "sequence",
            "nonce",
            "payload",
            "consistencyLevel",
        ], ["ByteVec", "U256", "U256", "ByteVec", "ByteVec", "U256"]);
        return {
            blockHash: event.blockHash,
            txId: event.txId,
            eventIndex: event.eventIndex,
            sender: fields["sender"],
            targetChainId: fields["targetChainId"],
            sequence: fields["sequence"],
            nonce: fields["nonce"],
            payload: fields["payload"],
            consistencyLevel: fields["consistencyLevel"],
        };
    };
    Governance.prototype.subscribeWormholeMessage = function (options, fromCount) {
        var _this = this;
        var messageCallback = function (event) {
            if (event.eventIndex !== 0) {
                return Promise.resolve();
            }
            return options.messageCallback(_this.decodeWormholeMessage(event));
        };
        var errorCallback = function (err, subscription) {
            return options.errorCallback(err, subscription);
        };
        var opt = {
            pollingInterval: options.pollingInterval,
            messageCallback: messageCallback,
            errorCallback: errorCallback,
        };
        return subscribeToEvents(opt, this.address, fromCount);
    };
    // This is used for testing contract functions
    Governance.stateForTest = function (chainId, governanceChainId, governanceEmitterAddress, receivedSequence, messageFee, guardianSets, guardianSetIndexes, previousGuardianSetExpirationTimeMS, asset, address) {
        var _a;
        var newAsset = {
            alphAmount: (_a = asset === null || asset === void 0 ? void 0 : asset.alphAmount) !== null && _a !== void 0 ? _a : BigInt("1000000000000000000"),
            tokens: asset === null || asset === void 0 ? void 0 : asset.tokens,
        };
        return Governance.contract.toState({
            chainId: chainId,
            governanceChainId: governanceChainId,
            governanceEmitterAddress: governanceEmitterAddress,
            receivedSequence: receivedSequence,
            messageFee: messageFee,
            guardianSets: guardianSets,
            guardianSetIndexes: guardianSetIndexes,
            previousGuardianSetExpirationTimeMS: previousGuardianSetExpirationTimeMS,
        }, newAsset, address);
    };
    Governance.testParseConractUpgrade = function (args, _initFields, _extraParams) {
        var _a, _b, _c;
        return __awaiter(this, void 0, void 0, function () {
            var _initialAsset, _testParams, _testResult;
            return __generator(this, function (_d) {
                switch (_d.label) {
                    case 0:
                        _initialAsset = {
                            alphAmount: (_b = (_a = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _a === void 0 ? void 0 : _a.alphAmount) !== null && _b !== void 0 ? _b : BigInt("1000000000000000000"),
                            tokens: (_c = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _c === void 0 ? void 0 : _c.tokens,
                        };
                        _testParams = __assign(__assign({}, _extraParams), { testMethodIndex: 0, testArgs: args, initialFields: _initFields, initialAsset: _initialAsset });
                        return [4 /*yield*/, Governance.contract.testPrivateMethod("parseConractUpgrade", _testParams)];
                    case 1:
                        _testResult = _d.sent();
                        return [2 /*return*/, __assign(__assign({}, _testResult), { returns: _testResult.returns })];
                }
            });
        });
    };
    Governance.testGetMessageFee = function (_initFields, _extraParams) {
        var _a, _b, _c;
        return __awaiter(this, void 0, void 0, function () {
            var _initialAsset, _testParams, _testResult;
            return __generator(this, function (_d) {
                switch (_d.label) {
                    case 0:
                        _initialAsset = {
                            alphAmount: (_b = (_a = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _a === void 0 ? void 0 : _a.alphAmount) !== null && _b !== void 0 ? _b : BigInt("1000000000000000000"),
                            tokens: (_c = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _c === void 0 ? void 0 : _c.tokens,
                        };
                        _testParams = __assign(__assign({}, _extraParams), { testMethodIndex: 1, testArgs: {}, initialFields: _initFields, initialAsset: _initialAsset });
                        return [4 /*yield*/, Governance.contract.testPublicMethod("getMessageFee", _testParams)];
                    case 1:
                        _testResult = _d.sent();
                        return [2 /*return*/, __assign(__assign({}, _testResult), { returns: _testResult.returns })];
                }
            });
        });
    };
    Governance.testPublishWormholeMessage = function (args, _initFields, _extraParams) {
        var _a, _b, _c;
        return __awaiter(this, void 0, void 0, function () {
            var _initialAsset, _testParams, _testResult;
            return __generator(this, function (_d) {
                switch (_d.label) {
                    case 0:
                        _initialAsset = {
                            alphAmount: (_b = (_a = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _a === void 0 ? void 0 : _a.alphAmount) !== null && _b !== void 0 ? _b : BigInt("1000000000000000000"),
                            tokens: (_c = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _c === void 0 ? void 0 : _c.tokens,
                        };
                        _testParams = __assign(__assign({}, _extraParams), { testMethodIndex: 2, testArgs: args, initialFields: _initFields, initialAsset: _initialAsset });
                        return [4 /*yield*/, Governance.contract.testPublicMethod("publishWormholeMessage", _testParams)];
                    case 1:
                        _testResult = _d.sent();
                        return [2 /*return*/, __assign(__assign({}, _testResult), { returns: _testResult.returns })];
                }
            });
        });
    };
    Governance.testParseAndVerifyVAA = function (args, _initFields, _extraParams) {
        var _a, _b, _c;
        return __awaiter(this, void 0, void 0, function () {
            var _initialAsset, _testParams, _testResult;
            return __generator(this, function (_d) {
                switch (_d.label) {
                    case 0:
                        _initialAsset = {
                            alphAmount: (_b = (_a = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _a === void 0 ? void 0 : _a.alphAmount) !== null && _b !== void 0 ? _b : BigInt("1000000000000000000"),
                            tokens: (_c = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _c === void 0 ? void 0 : _c.tokens,
                        };
                        _testParams = __assign(__assign({}, _extraParams), { testMethodIndex: 3, testArgs: args, initialFields: _initFields, initialAsset: _initialAsset });
                        return [4 /*yield*/, Governance.contract.testPublicMethod("parseAndVerifyVAA", _testParams)];
                    case 1:
                        _testResult = _d.sent();
                        return [2 /*return*/, __assign(__assign({}, _testResult), { returns: _testResult.returns })];
                }
            });
        });
    };
    Governance.testParseAndVerifyGovernanceVAAGeneric = function (args, _initFields, _extraParams) {
        var _a, _b, _c;
        return __awaiter(this, void 0, void 0, function () {
            var _initialAsset, _testParams, _testResult;
            return __generator(this, function (_d) {
                switch (_d.label) {
                    case 0:
                        _initialAsset = {
                            alphAmount: (_b = (_a = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _a === void 0 ? void 0 : _a.alphAmount) !== null && _b !== void 0 ? _b : BigInt("1000000000000000000"),
                            tokens: (_c = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _c === void 0 ? void 0 : _c.tokens,
                        };
                        _testParams = __assign(__assign({}, _extraParams), { testMethodIndex: 4, testArgs: args, initialFields: _initFields, initialAsset: _initialAsset });
                        return [4 /*yield*/, Governance.contract.testPublicMethod("parseAndVerifyGovernanceVAAGeneric", _testParams)];
                    case 1:
                        _testResult = _d.sent();
                        return [2 /*return*/, __assign(__assign({}, _testResult), { returns: _testResult.returns })];
                }
            });
        });
    };
    Governance.testParseAndVerifyGovernanceVAA = function (args, _initFields, _extraParams) {
        var _a, _b, _c;
        return __awaiter(this, void 0, void 0, function () {
            var _initialAsset, _testParams, _testResult;
            return __generator(this, function (_d) {
                switch (_d.label) {
                    case 0:
                        _initialAsset = {
                            alphAmount: (_b = (_a = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _a === void 0 ? void 0 : _a.alphAmount) !== null && _b !== void 0 ? _b : BigInt("1000000000000000000"),
                            tokens: (_c = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _c === void 0 ? void 0 : _c.tokens,
                        };
                        _testParams = __assign(__assign({}, _extraParams), { testMethodIndex: 5, testArgs: args, initialFields: _initFields, initialAsset: _initialAsset });
                        return [4 /*yield*/, Governance.contract.testPrivateMethod("parseAndVerifyGovernanceVAA", _testParams)];
                    case 1:
                        _testResult = _d.sent();
                        return [2 /*return*/, __assign(__assign({}, _testResult), { returns: _testResult.returns })];
                }
            });
        });
    };
    Governance.testGetGuardiansInfo = function (args, _initFields, _extraParams) {
        var _a, _b, _c;
        return __awaiter(this, void 0, void 0, function () {
            var _initialAsset, _testParams, _testResult;
            return __generator(this, function (_d) {
                switch (_d.label) {
                    case 0:
                        _initialAsset = {
                            alphAmount: (_b = (_a = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _a === void 0 ? void 0 : _a.alphAmount) !== null && _b !== void 0 ? _b : BigInt("1000000000000000000"),
                            tokens: (_c = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _c === void 0 ? void 0 : _c.tokens,
                        };
                        _testParams = __assign(__assign({}, _extraParams), { testMethodIndex: 6, testArgs: args, initialFields: _initFields, initialAsset: _initialAsset });
                        return [4 /*yield*/, Governance.contract.testPrivateMethod("getGuardiansInfo", _testParams)];
                    case 1:
                        _testResult = _d.sent();
                        return [2 /*return*/, __assign(__assign({}, _testResult), { returns: _testResult.returns })];
                }
            });
        });
    };
    Governance.testSubmitContractUpgrade = function (args, _initFields, _extraParams) {
        var _a, _b, _c;
        return __awaiter(this, void 0, void 0, function () {
            var _initialAsset, _testParams, _testResult;
            return __generator(this, function (_d) {
                switch (_d.label) {
                    case 0:
                        _initialAsset = {
                            alphAmount: (_b = (_a = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _a === void 0 ? void 0 : _a.alphAmount) !== null && _b !== void 0 ? _b : BigInt("1000000000000000000"),
                            tokens: (_c = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _c === void 0 ? void 0 : _c.tokens,
                        };
                        _testParams = __assign(__assign({}, _extraParams), { testMethodIndex: 7, testArgs: args, initialFields: _initFields, initialAsset: _initialAsset });
                        return [4 /*yield*/, Governance.contract.testPublicMethod("submitContractUpgrade", _testParams)];
                    case 1:
                        _testResult = _d.sent();
                        return [2 /*return*/, __assign(__assign({}, _testResult), { returns: _testResult.returns })];
                }
            });
        });
    };
    Governance.testUpdatePreviousGuardianSet = function (_initFields, _extraParams) {
        var _a, _b, _c;
        return __awaiter(this, void 0, void 0, function () {
            var _initialAsset, _testParams, _testResult;
            return __generator(this, function (_d) {
                switch (_d.label) {
                    case 0:
                        _initialAsset = {
                            alphAmount: (_b = (_a = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _a === void 0 ? void 0 : _a.alphAmount) !== null && _b !== void 0 ? _b : BigInt("1000000000000000000"),
                            tokens: (_c = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _c === void 0 ? void 0 : _c.tokens,
                        };
                        _testParams = __assign(__assign({}, _extraParams), { testMethodIndex: 8, testArgs: {}, initialFields: _initFields, initialAsset: _initialAsset });
                        return [4 /*yield*/, Governance.contract.testPrivateMethod("updatePreviousGuardianSet", _testParams)];
                    case 1:
                        _testResult = _d.sent();
                        return [2 /*return*/, __assign(__assign({}, _testResult), { returns: _testResult.returns })];
                }
            });
        });
    };
    Governance.testSubmitNewGuardianSet = function (args, _initFields, _extraParams) {
        var _a, _b, _c;
        return __awaiter(this, void 0, void 0, function () {
            var _initialAsset, _testParams, _testResult;
            return __generator(this, function (_d) {
                switch (_d.label) {
                    case 0:
                        _initialAsset = {
                            alphAmount: (_b = (_a = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _a === void 0 ? void 0 : _a.alphAmount) !== null && _b !== void 0 ? _b : BigInt("1000000000000000000"),
                            tokens: (_c = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _c === void 0 ? void 0 : _c.tokens,
                        };
                        _testParams = __assign(__assign({}, _extraParams), { testMethodIndex: 9, testArgs: args, initialFields: _initFields, initialAsset: _initialAsset });
                        return [4 /*yield*/, Governance.contract.testPublicMethod("submitNewGuardianSet", _testParams)];
                    case 1:
                        _testResult = _d.sent();
                        return [2 /*return*/, __assign(__assign({}, _testResult), { returns: _testResult.returns })];
                }
            });
        });
    };
    Governance.testSubmitSetMessageFee = function (args, _initFields, _extraParams) {
        var _a, _b, _c;
        return __awaiter(this, void 0, void 0, function () {
            var _initialAsset, _testParams, _testResult;
            return __generator(this, function (_d) {
                switch (_d.label) {
                    case 0:
                        _initialAsset = {
                            alphAmount: (_b = (_a = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _a === void 0 ? void 0 : _a.alphAmount) !== null && _b !== void 0 ? _b : BigInt("1000000000000000000"),
                            tokens: (_c = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _c === void 0 ? void 0 : _c.tokens,
                        };
                        _testParams = __assign(__assign({}, _extraParams), { testMethodIndex: 10, testArgs: args, initialFields: _initFields, initialAsset: _initialAsset });
                        return [4 /*yield*/, Governance.contract.testPublicMethod("submitSetMessageFee", _testParams)];
                    case 1:
                        _testResult = _d.sent();
                        return [2 /*return*/, __assign(__assign({}, _testResult), { returns: _testResult.returns })];
                }
            });
        });
    };
    Governance.testSubmitTransferFees = function (args, _initFields, _extraParams) {
        var _a, _b, _c;
        return __awaiter(this, void 0, void 0, function () {
            var _initialAsset, _testParams, _testResult;
            return __generator(this, function (_d) {
                switch (_d.label) {
                    case 0:
                        _initialAsset = {
                            alphAmount: (_b = (_a = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _a === void 0 ? void 0 : _a.alphAmount) !== null && _b !== void 0 ? _b : BigInt("1000000000000000000"),
                            tokens: (_c = _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.initialAsset) === null || _c === void 0 ? void 0 : _c.tokens,
                        };
                        _testParams = __assign(__assign({}, _extraParams), { testMethodIndex: 11, testArgs: args, initialFields: _initFields, initialAsset: _initialAsset });
                        return [4 /*yield*/, Governance.contract.testPublicMethod("submitTransferFees", _testParams)];
                    case 1:
                        _testResult = _d.sent();
                        return [2 /*return*/, __assign(__assign({}, _testResult), { returns: _testResult.returns })];
                }
            });
        });
    };
    Governance.prototype.getMessageFeeCall = function (_extraParams) {
        return __awaiter(this, void 0, void 0, function () {
            var _callResult;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, web3
                            .getCurrentNodeProvider()
                            .contracts.postContractsCallContract({
                            group: this.groupIndex,
                            worldStateBlockHash: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.worldStateBlockHash,
                            txId: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.txId,
                            address: this.address,
                            methodIndex: 1,
                            args: [],
                            existingContracts: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.existingContracts,
                            inputAssets: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.inputAssets,
                        })];
                    case 1:
                        _callResult = _a.sent();
                        return [2 /*return*/, fromApiArray(_callResult.returns, ["U256"])[0]];
                }
            });
        });
    };
    Governance.prototype.parseAndVerifyVAACall = function (data, isGovernanceVAA, _extraParams) {
        return __awaiter(this, void 0, void 0, function () {
            var _callResult;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, web3
                            .getCurrentNodeProvider()
                            .contracts.postContractsCallContract({
                            group: this.groupIndex,
                            worldStateBlockHash: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.worldStateBlockHash,
                            txId: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.txId,
                            address: this.address,
                            methodIndex: 3,
                            args: toApiVals({ data: data, isGovernanceVAA: isGovernanceVAA }, ["data", "isGovernanceVAA"], ["ByteVec", "Bool"]),
                            existingContracts: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.existingContracts,
                            inputAssets: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.inputAssets,
                        })];
                    case 1:
                        _callResult = _a.sent();
                        return [2 /*return*/, fromApiArray(_callResult.returns, [
                                "U256",
                                "U256",
                                "ByteVec",
                                "U256",
                                "ByteVec",
                            ])];
                }
            });
        });
    };
    Governance.prototype.parseAndVerifyGovernanceVAAGenericCall = function (vaa, targetSequence, coreModule, action, _extraParams) {
        return __awaiter(this, void 0, void 0, function () {
            var _callResult;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, web3
                            .getCurrentNodeProvider()
                            .contracts.postContractsCallContract({
                            group: this.groupIndex,
                            worldStateBlockHash: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.worldStateBlockHash,
                            txId: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.txId,
                            address: this.address,
                            methodIndex: 4,
                            args: toApiVals({
                                vaa: vaa,
                                targetSequence: targetSequence,
                                coreModule: coreModule,
                                action: action,
                            }, ["vaa", "targetSequence", "coreModule", "action"], ["ByteVec", "U256", "U256", "ByteVec"]),
                            existingContracts: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.existingContracts,
                            inputAssets: _extraParams === null || _extraParams === void 0 ? void 0 : _extraParams.inputAssets,
                        })];
                    case 1:
                        _callResult = _a.sent();
                        return [2 /*return*/, fromApiArray(_callResult.returns, ["U256", "U256", "ByteVec"])];
                }
            });
        });
    };
    Governance.contract = Contract.fromJson(JSON.parse("{\n  \"version\": \"v1.7.0\",\n  \"name\": \"Governance\",\n  \"bytecode\": \"0a0c40a340ac40c441f942434268428f42e242f9435e438f43d70000010a04405e160013211323626d1701132316012a17021600132316026217031600431704160416022f4c0516031400140014000216001602160213202a621705160213202a17021600160216020e2a626d170616020e2a170216001602160216062a621707160216062a17021600160216020e2a626d170816020e2a170216001602160216082a621709160216082a1702160416022f0e7b160316051607160902010000000102a0010201010606000b1600a001a905b31601160216031604160574010002180540b916000c0d621401014113067b16000d11626e170216014c051602a0052f13077b1600111306626c170316020006170416040c0d626c170516050c3013087b16050e2c0f2d0d2a1706160616033213097b1600130616031340422c2a16004362170716074f4f1708130617090b170a0c170b160b1603314c40481600160916090d2a626c170c160c3f170d160d160a28130a7b160d170a160016090d2a16091340422a62170e160e134040134041626c131b2a170f160e0c13404062160f664417100d160c13142c2a171116041611161113142a6217121612160816107241130b7b16091340422a1709160b0d2a170b4a7fb416071308130a626d17131607130a130c626d17141607130c132c6217151607132c1334626f17161607133516074362171716131614161516161617020100040903402c1600030003170817071706170517041604ce012f0c7b1606ce02410d7b16071601340f7b16080c1320627116022f107b16081320132162160341117b160716051608020000020e020f1600a00013c0436f72651601000417041703170216020d2aa10016031604020000010101161600a0052f4c02a003021600a0042f4c0756a00632130c7ba002021307047c7b180100010800402d16001401010005170217011601ce002f130d7b16020000170617051704170316041400414c031603ba4a16a0006ba0016b44a0046b44a0056b441707160416074e41130e7b160316051606bb000000000008a003a102a005a104561385265c002aa1060100010600403a000816001401020005170217011601ce002f16010c2f1b130d7b160213211325626e17031603a0050d2a2f13077b160213251326626c170416040c3313087b1326160413142c2a170516024316052f0e7b1603a10516021325160562a10301000104001816001401030005170217011601ce002f130d7b16021321134041627117031602431340412f0e7b1603a1010102010500402516001401040005170217011601ce002f16010c2f1b130d7b160213211340416271170316021340411340616217041602431340612f0e7b140100160444631603a8\",\n  \"codeHash\": \"59e000edbf5739884298899e54a4d2e34c6ebf30ac8273b7b1b00740248cf4cb\",\n  \"fieldsSig\": {\n    \"names\": [\n      \"chainId\",\n      \"governanceChainId\",\n      \"governanceEmitterAddress\",\n      \"receivedSequence\",\n      \"messageFee\",\n      \"guardianSets\",\n      \"guardianSetIndexes\",\n      \"previousGuardianSetExpirationTimeMS\"\n    ],\n    \"types\": [\n      \"U256\",\n      \"U256\",\n      \"ByteVec\",\n      \"U256\",\n      \"U256\",\n      \"[ByteVec;2]\",\n      \"[U256;2]\",\n      \"U256\"\n    ],\n    \"isMutable\": [\n      false,\n      false,\n      false,\n      true,\n      true,\n      true,\n      true,\n      true\n    ]\n  },\n  \"eventsSig\": [\n    {\n      \"name\": \"WormholeMessage\",\n      \"fieldNames\": [\n        \"sender\",\n        \"targetChainId\",\n        \"sequence\",\n        \"nonce\",\n        \"payload\",\n        \"consistencyLevel\"\n      ],\n      \"fieldTypes\": [\n        \"ByteVec\",\n        \"U256\",\n        \"U256\",\n        \"ByteVec\",\n        \"ByteVec\",\n        \"U256\"\n      ]\n    }\n  ],\n  \"functions\": [\n    {\n      \"name\": \"parseConractUpgrade\",\n      \"usePreapprovedAssets\": false,\n      \"useAssetsInContract\": false,\n      \"isPublic\": false,\n      \"paramNames\": [\n        \"payload\"\n      ],\n      \"paramTypes\": [\n        \"ByteVec\"\n      ],\n      \"paramIsMutable\": [\n        false\n      ],\n      \"returnTypes\": [\n        \"ByteVec\",\n        \"ByteVec\",\n        \"ByteVec\",\n        \"ByteVec\"\n      ]\n    },\n    {\n      \"name\": \"getMessageFee\",\n      \"usePreapprovedAssets\": false,\n      \"useAssetsInContract\": false,\n      \"isPublic\": true,\n      \"paramNames\": [],\n      \"paramTypes\": [],\n      \"paramIsMutable\": [],\n      \"returnTypes\": [\n        \"U256\"\n      ]\n    },\n    {\n      \"name\": \"publishWormholeMessage\",\n      \"usePreapprovedAssets\": true,\n      \"useAssetsInContract\": true,\n      \"isPublic\": true,\n      \"paramNames\": [\n        \"payer\",\n        \"targetChainId\",\n        \"sequence\",\n        \"nonce\",\n        \"payload\",\n        \"consistencyLevel\"\n      ],\n      \"paramTypes\": [\n        \"Address\",\n        \"U256\",\n        \"U256\",\n        \"ByteVec\",\n        \"ByteVec\",\n        \"U256\"\n      ],\n      \"paramIsMutable\": [\n        false,\n        false,\n        false,\n        false,\n        false,\n        false\n      ],\n      \"returnTypes\": []\n    },\n    {\n      \"name\": \"parseAndVerifyVAA\",\n      \"usePreapprovedAssets\": false,\n      \"useAssetsInContract\": false,\n      \"isPublic\": true,\n      \"paramNames\": [\n        \"data\",\n        \"isGovernanceVAA\"\n      ],\n      \"paramTypes\": [\n        \"ByteVec\",\n        \"Bool\"\n      ],\n      \"paramIsMutable\": [\n        false,\n        false\n      ],\n      \"returnTypes\": [\n        \"U256\",\n        \"U256\",\n        \"ByteVec\",\n        \"U256\",\n        \"ByteVec\"\n      ]\n    },\n    {\n      \"name\": \"parseAndVerifyGovernanceVAAGeneric\",\n      \"usePreapprovedAssets\": false,\n      \"useAssetsInContract\": false,\n      \"isPublic\": true,\n      \"paramNames\": [\n        \"vaa\",\n        \"targetSequence\",\n        \"coreModule\",\n        \"action\"\n      ],\n      \"paramTypes\": [\n        \"ByteVec\",\n        \"U256\",\n        \"U256\",\n        \"ByteVec\"\n      ],\n      \"paramIsMutable\": [\n        false,\n        false,\n        false,\n        false\n      ],\n      \"returnTypes\": [\n        \"U256\",\n        \"U256\",\n        \"ByteVec\"\n      ]\n    },\n    {\n      \"name\": \"parseAndVerifyGovernanceVAA\",\n      \"usePreapprovedAssets\": false,\n      \"useAssetsInContract\": false,\n      \"isPublic\": false,\n      \"paramNames\": [\n        \"vaa\",\n        \"action\"\n      ],\n      \"paramTypes\": [\n        \"ByteVec\",\n        \"ByteVec\"\n      ],\n      \"paramIsMutable\": [\n        false,\n        false\n      ],\n      \"returnTypes\": [\n        \"U256\",\n        \"ByteVec\"\n      ]\n    },\n    {\n      \"name\": \"getGuardiansInfo\",\n      \"usePreapprovedAssets\": false,\n      \"useAssetsInContract\": false,\n      \"isPublic\": false,\n      \"paramNames\": [\n        \"guardianSetIndex\"\n      ],\n      \"paramTypes\": [\n        \"U256\"\n      ],\n      \"paramIsMutable\": [\n        false\n      ],\n      \"returnTypes\": [\n        \"ByteVec\"\n      ]\n    },\n    {\n      \"name\": \"submitContractUpgrade\",\n      \"usePreapprovedAssets\": false,\n      \"useAssetsInContract\": false,\n      \"isPublic\": true,\n      \"paramNames\": [\n        \"vaa\"\n      ],\n      \"paramTypes\": [\n        \"ByteVec\"\n      ],\n      \"paramIsMutable\": [\n        false\n      ],\n      \"returnTypes\": []\n    },\n    {\n      \"name\": \"updatePreviousGuardianSet\",\n      \"usePreapprovedAssets\": false,\n      \"useAssetsInContract\": false,\n      \"isPublic\": false,\n      \"paramNames\": [],\n      \"paramTypes\": [],\n      \"paramIsMutable\": [],\n      \"returnTypes\": []\n    },\n    {\n      \"name\": \"submitNewGuardianSet\",\n      \"usePreapprovedAssets\": false,\n      \"useAssetsInContract\": false,\n      \"isPublic\": true,\n      \"paramNames\": [\n        \"vaa\"\n      ],\n      \"paramTypes\": [\n        \"ByteVec\"\n      ],\n      \"paramIsMutable\": [\n        false\n      ],\n      \"returnTypes\": []\n    },\n    {\n      \"name\": \"submitSetMessageFee\",\n      \"usePreapprovedAssets\": false,\n      \"useAssetsInContract\": false,\n      \"isPublic\": true,\n      \"paramNames\": [\n        \"vaa\"\n      ],\n      \"paramTypes\": [\n        \"ByteVec\"\n      ],\n      \"paramIsMutable\": [\n        false\n      ],\n      \"returnTypes\": []\n    },\n    {\n      \"name\": \"submitTransferFees\",\n      \"usePreapprovedAssets\": false,\n      \"useAssetsInContract\": true,\n      \"isPublic\": true,\n      \"paramNames\": [\n        \"vaa\"\n      ],\n      \"paramTypes\": [\n        \"ByteVec\"\n      ],\n      \"paramIsMutable\": [\n        false\n      ],\n      \"returnTypes\": []\n    }\n  ]\n}"));
    return Governance;
}());
export { Governance };
