/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import { Governance, LocalTokenPool, RemoteTokenPool, TokenBridgeForChain, AttestTokenHandler, UnexecutedSequence, TokenBridgeFactory, TokenBridge, TestToken, } from ".";
import { default as devnetDeployments } from "../.deployments.devnet.json";
function toDeployments(json) {
    const contracts = {
        Governance: Object.assign(Object.assign({}, json.contracts.Governance), { contractInstance: Governance.at(json.contracts.Governance.contractInstance.address) }),
        LocalTokenPool: Object.assign(Object.assign({}, json.contracts.LocalTokenPool), { contractInstance: LocalTokenPool.at(json.contracts.LocalTokenPool.contractInstance.address) }),
        RemoteTokenPool: Object.assign(Object.assign({}, json.contracts.RemoteTokenPool), { contractInstance: RemoteTokenPool.at(json.contracts.RemoteTokenPool.contractInstance.address) }),
        TokenBridgeForChain: Object.assign(Object.assign({}, json.contracts.TokenBridgeForChain), { contractInstance: TokenBridgeForChain.at(json.contracts.TokenBridgeForChain.contractInstance.address) }),
        AttestTokenHandler: Object.assign(Object.assign({}, json.contracts.AttestTokenHandler), { contractInstance: AttestTokenHandler.at(json.contracts.AttestTokenHandler.contractInstance.address) }),
        UnexecutedSequence: Object.assign(Object.assign({}, json.contracts.UnexecutedSequence), { contractInstance: UnexecutedSequence.at(json.contracts.UnexecutedSequence.contractInstance.address) }),
        TokenBridgeFactory: Object.assign(Object.assign({}, json.contracts.TokenBridgeFactory), { contractInstance: TokenBridgeFactory.at(json.contracts.TokenBridgeFactory.contractInstance.address) }),
        TokenBridge: Object.assign(Object.assign({}, json.contracts.TokenBridge), { contractInstance: TokenBridge.at(json.contracts.TokenBridge.contractInstance.address) }),
        TestToken: Object.assign(Object.assign({}, json.contracts.TestToken), { contractInstance: TestToken.at(json.contracts.TestToken.contractInstance.address) }),
    };
    return Object.assign(Object.assign({}, json), { contracts: contracts });
}
export function loadDeployments(networkId, deployerAddress) {
    const deployments = networkId === "devnet" ? devnetDeployments : undefined;
    if (deployments === undefined) {
        throw Error("The contract has not been deployed to the " + networkId);
    }
    const allDeployments = Array.isArray(deployments)
        ? deployments
        : [deployments];
    if (deployerAddress === undefined) {
        if (allDeployments.length > 1) {
            throw Error("The contract has been deployed multiple times on " +
                networkId +
                ", please specify the deployer address");
        }
        else {
            return toDeployments(allDeployments[0]);
        }
    }
    const result = allDeployments.find((d) => d.deployerAddress === deployerAddress);
    if (result === undefined) {
        throw Error("The contract deployment result does not exist");
    }
    return toDeployments(result);
}
