"use strict";
/* istanbul ignore file */
/* eslint-disable @typescript-eslint/naming-convention */
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTickerReservationInstance = exports.getDefaultPortfolioIsEqualStub = exports.getDefaultPortfolioGetCustodianStub = exports.getDefaultPortfolioIsCustodiedByStub = exports.getNumberedPortfolioIsEqualStub = exports.getNumberedPortfolioGetCustodianStub = exports.getNumberedPortfolioIsCustodiedByStub = exports.getAccountHasPermissionsStub = exports.getAccountIsEqualStub = exports.getAccountGetTransactionHistoryStub = exports.getAccountGetIdentityStub = exports.getAccountGetBalanceStub = exports.getAccountIsFrozenStub = exports.getAccountInstance = exports.getIdentityIsEqualStub = exports.getIdentityTokenPermissionsGetGroupStub = exports.getIdentityGetScopeIdStub = exports.getIdentityGetVenuesStub = exports.getIdentityAuthorizationsGetSentStub = exports.getIdentityAuthorizationsGetReceivedStub = exports.getIdentityGetPrimaryKeyStub = exports.getIdentityHasValidCddStub = exports.getIdentityTokenPermissionsHasPermissionsStub = exports.getIdentityHasRoleStub = exports.getIdentityHasRolesStub = exports.getIdentityConstructorStub = exports.getIdentityInstance = exports.reset = exports.cleanup = exports.initMocks = exports.configureMocks = exports.mockAgentModule = exports.mockKnownPermissionGroupModule = exports.mockCustomPermissionGroupModule = exports.mockDividendDistributionModule = exports.mockCorporateActionModule = exports.mockCheckpointScheduleModule = exports.mockCheckpointModule = exports.mockStoModule = exports.mockDefaultPortfolioModule = exports.mockNumberedPortfolioModule = exports.mockInstructionModule = exports.mockVenueModule = exports.mockProposalModule = exports.mockPermissionGroupModule = exports.mockAuthorizationRequestModule = exports.mockSecurityTokenModule = exports.mockTickerReservationModule = exports.mockAccountModule = exports.mockIdentityModule = void 0;
exports.getDividendDistributionGetParticipantStub = exports.getDividendDistributionConstructorStub = exports.getDividendDistributionCheckpointStub = exports.getDividendDistributionInstance = exports.getCorporateActionConstructorStub = exports.getCorporateActionExistsStub = exports.getCorporateActionInstance = exports.getCheckpointScheduleDetailsStub = exports.getCheckpointScheduleConstructorStub = exports.getCheckpointScheduleInstance = exports.getCheckpointConstructorStub = exports.getCheckpointBalanceStub = exports.getCheckpointAllBalancesStub = exports.getCheckpointExistsStub = exports.getCheckpointTotalSupplyStub = exports.getCheckpointCreatedAtStub = exports.getCheckpointInstance = exports.getStoConstructorStub = exports.getStoDetailsStub = exports.getStoInstance = exports.getInstructionGetLegsStub = exports.getInstructionDetailsStub = exports.getInstructionInstance = exports.getKnownPermissionGroupIsEqualStub = exports.getKnownPermissionGroupGetPermissionsStub = exports.getKnownPermissionGroupInstance = exports.getCustomPermissionIsEqualStub = exports.getCustomPermissionGroupGetPermissionsStub = exports.getCustomPermissionGroupInstance = exports.getDefaultPortfolioInstance = exports.getNumberedPortfolioInstance = exports.getVenueDetailsStub = exports.getVenueInstance = exports.getAuthorizationRequestInstance = exports.getSecurityTokenPermissionsGetAgentsStub = exports.getSecurityTokenPermissionsGetGroupsStub = exports.getSecurityTokenCorporateActionsGetDefaultsStub = exports.getSecurityTokenCorporateActionsGetAgentsStub = exports.getSecurityTokenTransferRestrictionsPercentageGetStub = exports.getSecurityTokenTransferRestrictionsCountGetStub = exports.getSecurityTokenTransfersCanTransferStub = exports.getSecurityTokenGetIdentifiersStub = exports.getSecurityTokenIsFrozenStub = exports.getSecurityTokenCurrentFundingRoundStub = exports.getSecurityTokenDetailsStub = exports.getSecurityTokenInstance = exports.getTickerReservationDetailsStub = void 0;
const bignumber_js_1 = __importDefault(require("bignumber.js"));
const lodash_1 = require("lodash");
const sinon_1 = __importDefault(require("sinon"));
const types_1 = require("../../types");
const mockInstanceContainer = {
    identity: {},
    tickerReservation: {},
    securityToken: {},
    authorizationRequest: {},
    permissionGroup: {},
    // NOTE uncomment in Governance v2 upgrade
    // proposal: {} as MockProposal,
    account: {},
    venue: {},
    instruction: {},
    numberedPortfolio: {},
    defaultPortfolio: {},
    customPermissionGroup: {},
    knownPermissionGroup: {},
    sto: {},
    checkpoint: {},
    checkpointSchedule: {},
    corporateAction: {},
    dividendDistribution: {},
};
let identityConstructorStub;
let accountConstructorStub;
let tickerReservationConstructorStub;
let securityTokenConstructorStub;
let authorizationRequestConstructorStub;
let permissionGroupConstructorStub;
let proposalConstructorStub;
let venueConstructorStub;
let instructionConstructorStub;
let numberedPortfolioConstructorStub;
let defaultPortfolioConstructorStub;
let stoConstructorStub;
let checkpointConstructorStub;
let checkpointScheduleConstructorStub;
let corporateActionConstructorStub;
let dividendDistributionConstructorStub;
let customPermissionGroupConstructorStub;
let knownPermissionGroupConstructorStub;
let agentConstructorStub;
let securityTokenDetailsStub;
let securityTokenCurrentFundingRoundStub;
let securityTokenIsFrozenStub;
let securityTokenTransfersCanTransferStub;
let securityTokenGetIdentifiersStub;
let securityTokenTransferRestrictionsCountGetStub;
let securityTokenTransferRestrictionsPercentageGetStub;
let securityTokenCorporateActionsGetAgentsStub;
let securityTokenCorporateActionsGetDefaultsStub;
let securityTokenPermissionsGetGroupsStub;
let securityTokenPermissionsGetAgentsStub;
let securityTokenIsEqualStub;
let securityTokenExistsStub;
let securityTokenToJsonStub;
let authorizationRequestExistsStub;
let identityHasRolesStub;
let identityHasRoleStub;
let identityCheckRolesStub;
let identityHasValidCddStub;
let identityGetPrimaryKeyStub;
let identityAuthorizationsGetReceivedStub;
let identityAuthorizationsGetSentStub;
let identityGetVenuesStub;
let identityGetScopeIdStub;
let identityGetTokenBalanceStub;
let identityGetSecondaryKeysStub;
let identityAreSecondaryKeysFrozenStub;
let identityIsEqualStub;
let identityTokenPermissionsHasPermissionsStub;
let identityTokenPermissionsCheckPermissionsStub;
let identityTokenPermissionsGetStub;
let identityTokenPermissionsGetGroupStub;
let identityExistsStub;
let accountGetBalanceStub;
let accountGetIdentityStub;
let accountGetTransactionHistoryStub;
let accountIsFrozenStub;
let accountIsEqualStub;
let accountExistsStub;
let accountHasPermissionsStub;
let accountCheckPermissionsStub;
let tickerReservationDetailsStub;
let tickerReservationExistsStub;
let venueDetailsStub;
let venueExistsStub;
let instructionDetailsStub;
let instructionGetLegsStub;
let instructionIsPendigStub;
let instructionExistsStub;
let numberedPortfolioIsOwnedByStub;
let numberedPortfolioGetTokenBalancesStub;
let numberedPortfolioExistsStub;
let numberedPortfolioGetCustodianStub;
let numberedPortfolioIsCustodiedByStub;
let numberedPortfolioIsEqualStub;
let defaultPortfolioIsOwnedByStub;
let defaultPortfolioGetTokenBalancesStub;
let defaultPortfolioGetCustodianStub;
let defaultPortfolioIsCustodiedByStub;
let defaultPortfolioIsEqualStub;
let defaultPortfolioExistsStub;
let stoDetailsStub;
let stoExistsStub;
let checkpointCreatedAtStub;
let checkpointTotalSupplyStub;
let checkpointExistsStub;
let checkpointAllBalancesStub;
let checkpointBalanceStub;
let corporateActionExistsStub;
let checkpointScheduleDetailsStub;
let checkpointScheduleExistsStub;
let dividendDistributionDetailsStub;
let dividendDistributionGetParticipantStub;
let dividendDistributionCheckpointStub;
let dividendDistributionExistsStub;
let customPermissionGroupGetPermissionsStub;
let customPermissionGroupIsEqualStub;
let customPermissionGroupExistsStub;
let knownPermissionGroupGetPermissionsStub;
let knownPermissionGroupIsEqualStub;
let knownPermissionGroupExistsStub;
const MockIdentityClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return identityConstructorStub(...args);
    }
};
const MockAccountClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return accountConstructorStub(...args);
    }
};
const MockTickerReservationClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return tickerReservationConstructorStub(...args);
    }
};
const MockSecurityTokenClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return securityTokenConstructorStub(...args);
    }
};
const MockAuthorizationRequestClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return authorizationRequestConstructorStub(...args);
    }
};
const MockPermissionGroupClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return permissionGroupConstructorStub(...args);
    }
};
const MockProposalClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return proposalConstructorStub(...args);
    }
};
const MockVenueClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return venueConstructorStub(...args);
    }
};
const MockNumberedPortfolioClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return numberedPortfolioConstructorStub(...args);
    }
};
const MockDefaultPortfolioClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return defaultPortfolioConstructorStub(...args);
    }
};
const MockInstructionClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return instructionConstructorStub(...args);
    }
};
const MockStoClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return stoConstructorStub(...args);
    }
};
const MockCheckpointClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return checkpointConstructorStub(...args);
    }
};
const MockCheckpointScheduleClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return checkpointScheduleConstructorStub(...args);
    }
};
const MockCorporateActionClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return corporateActionConstructorStub(...args);
    }
};
const MockDividendDistributionClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return dividendDistributionConstructorStub(...args);
    }
};
const MockCustomPermissionGroupClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return customPermissionGroupConstructorStub(...args);
    }
};
const MockKnownPermissionGroupClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return knownPermissionGroupConstructorStub(...args);
    }
};
const MockAgentClass = class {
    /**
     * @hidden
     */
    constructor(...args) {
        return agentConstructorStub(...args);
    }
};
const mockIdentityModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { Identity: MockIdentityClass }));
exports.mockIdentityModule = mockIdentityModule;
const mockAccountModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { Account: MockAccountClass }));
exports.mockAccountModule = mockAccountModule;
const mockTickerReservationModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { TickerReservation: MockTickerReservationClass }));
exports.mockTickerReservationModule = mockTickerReservationModule;
const mockSecurityTokenModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { SecurityToken: MockSecurityTokenClass }));
exports.mockSecurityTokenModule = mockSecurityTokenModule;
const mockAuthorizationRequestModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { AuthorizationRequest: MockAuthorizationRequestClass }));
exports.mockAuthorizationRequestModule = mockAuthorizationRequestModule;
const mockPermissionGroupModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { PermissionGroup: MockPermissionGroupClass }));
exports.mockPermissionGroupModule = mockPermissionGroupModule;
const mockProposalModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { Proposal: MockProposalClass }));
exports.mockProposalModule = mockProposalModule;
const mockVenueModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { Venue: MockVenueClass }));
exports.mockVenueModule = mockVenueModule;
const mockInstructionModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { Instruction: MockInstructionClass }));
exports.mockInstructionModule = mockInstructionModule;
const mockNumberedPortfolioModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { NumberedPortfolio: MockNumberedPortfolioClass }));
exports.mockNumberedPortfolioModule = mockNumberedPortfolioModule;
const mockDefaultPortfolioModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { DefaultPortfolio: MockDefaultPortfolioClass }));
exports.mockDefaultPortfolioModule = mockDefaultPortfolioModule;
const mockStoModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { Sto: MockStoClass }));
exports.mockStoModule = mockStoModule;
const mockCheckpointModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { Checkpoint: MockCheckpointClass }));
exports.mockCheckpointModule = mockCheckpointModule;
const mockCheckpointScheduleModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { CheckpointSchedule: MockCheckpointScheduleClass }));
exports.mockCheckpointScheduleModule = mockCheckpointScheduleModule;
const mockCorporateActionModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { CorporateAction: MockCorporateActionClass }));
exports.mockCorporateActionModule = mockCorporateActionModule;
const mockDividendDistributionModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { DividendDistribution: MockDividendDistributionClass }));
exports.mockDividendDistributionModule = mockDividendDistributionModule;
const mockCustomPermissionGroupModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { CustomPermissionGroup: MockCustomPermissionGroupClass }));
exports.mockCustomPermissionGroupModule = mockCustomPermissionGroupModule;
const mockKnownPermissionGroupModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { KnownPermissionGroup: MockKnownPermissionGroupClass }));
exports.mockKnownPermissionGroupModule = mockKnownPermissionGroupModule;
const mockAgentModule = (path) => () => (Object.assign(Object.assign({}, jest.requireActual(path)), { Agent: MockAgentClass }));
exports.mockAgentModule = mockAgentModule;
const defaultIdentityOptions = {
    did: 'someDid',
    hasValidCdd: true,
    authorizations: {
        getReceived: [],
        getSent: { data: [], next: null },
    },
    getVenues: [],
    getScopeId: 'someScopeId',
    getTokenBalance: new bignumber_js_1.default(100),
    getSecondaryKeys: [],
    areScondaryKeysFrozen: false,
    isEqual: true,
    tokenPermissionsGet: [],
    tokenPermissionsCheckPermissions: {
        result: true,
    },
    tokenPermissionsHasPermissions: true,
    exists: true,
};
let identityOptions = defaultIdentityOptions;
const defaultAccountOptions = {
    address: 'someAddress',
    key: 'someKey',
    getBalance: {
        free: new bignumber_js_1.default(100),
        locked: new bignumber_js_1.default(10),
        total: new bignumber_js_1.default(110),
    },
    getTransactionHistory: [],
    isEqual: true,
    exists: true,
    isFrozen: false,
    hasPermissions: true,
    checkPermissions: {
        result: true,
    },
};
let accountOptions = defaultAccountOptions;
const defaultTickerReservationOptions = {
    ticker: 'SOME_TICKER',
    details: {
        expiryDate: new Date(),
        status: types_1.TickerReservationStatus.Reserved,
    },
    exists: true,
};
let tickerReservationOptions = defaultTickerReservationOptions;
const defaultSecurityTokenOptions = {
    ticker: 'SOME_TICKER',
    details: {
        name: 'TOKEN_NAME',
        totalSupply: new bignumber_js_1.default(1000000),
        isDivisible: false,
        primaryIssuanceAgents: [],
        fullAgents: [],
    },
    currentFundingRound: 'Series A',
    isFrozen: false,
    transfersCanTransfer: types_1.TransferStatus.Success,
    getIdentifiers: [],
    transferRestrictionsCountGet: {
        restrictions: [],
        availableSlots: 3,
    },
    transferRestrictionsPercentageGet: {
        restrictions: [],
        availableSlots: 3,
    },
    corporateActionsGetAgents: [],
    corporateActionsGetDefaults: {
        targets: { identities: [], treatment: types_1.TargetTreatment.Exclude },
        defaultTaxWithholding: new bignumber_js_1.default(10),
        taxWithholdings: [],
    },
    permissionsGetAgents: [],
    permissionsGetGroups: {
        known: [],
        custom: [],
    },
    isEqual: false,
    exists: true,
    toJson: 'SOME_TICKER',
};
let securityTokenOptions = defaultSecurityTokenOptions;
const defaultAuthorizationRequestOptions = {
    target: { did: 'targetDid' },
    issuer: { did: 'issuerDid' },
    data: { type: types_1.AuthorizationType.TransferAssetOwnership, value: 'UNWANTED_TOKEN' },
    expiry: null,
    exists: true,
};
let authorizationRequestOptions = defaultAuthorizationRequestOptions;
const defaultVenueOptions = {
    id: new bignumber_js_1.default(1),
    details: {
        type: types_1.VenueType.Distribution,
        description: 'someDescription',
    },
    exists: true,
};
let venueOptions = defaultVenueOptions;
const defaultNumberedPortfolioOptions = {
    id: new bignumber_js_1.default(1),
    isOwnedBy: true,
    tokenBalances: [
        {
            token: 'someToken',
            total: new bignumber_js_1.default(1),
            locked: new bignumber_js_1.default(0),
            free: new bignumber_js_1.default(1),
        },
    ],
    did: 'someDid',
    exists: true,
    custodian: 'identity',
    isCustodiedBy: true,
    isEqual: true,
};
let numberedPortfolioOptions = defaultNumberedPortfolioOptions;
const defaultDefaultPortfolioOptions = {
    isOwnedBy: true,
    tokenBalances: [
        {
            token: 'someToken',
            total: new bignumber_js_1.default(1),
            locked: new bignumber_js_1.default(0),
            free: new bignumber_js_1.default(1),
        },
    ],
    did: 'someDid',
    custodian: 'identity',
    isCustodiedBy: true,
    isEqual: true,
    exists: true,
};
let defaultPortfolioOptions = defaultDefaultPortfolioOptions;
const defaultCustomPermissionGroupOptions = {
    ticker: 'SOME_TICKER',
    id: new bignumber_js_1.default(1),
    getPermissions: {
        transactions: null,
        transactionGroups: [],
    },
    isEqual: true,
    exists: true,
};
let customPermissionGroupOptions = defaultCustomPermissionGroupOptions;
const defaultKnownPermissionGroupOptions = {
    ticker: 'SOME_TICKER',
    type: 'someType',
    getPermissions: {
        transactions: null,
        transactionGroups: [],
    },
    isEqual: true,
    exists: true,
};
let knownPermissionGroupOptions = defaultKnownPermissionGroupOptions;
const defaultInstructionOptions = {
    id: new bignumber_js_1.default(1),
    details: {
        status: types_1.InstructionStatus.Pending,
        createdAt: new Date(new Date().getTime() + 365 * 24 * 60 * 60 * 1000),
        tradeDate: null,
        valueDate: null,
        type: types_1.InstructionType.SettleOnAffirmation,
    },
    isPending: false,
    exists: true,
};
let instructionOptions = defaultInstructionOptions;
const defaultStoOptions = {
    details: {
        end: null,
        start: new Date('10/14/1987'),
        status: {
            timing: types_1.StoTimingStatus.Started,
            balance: types_1.StoBalanceStatus.Available,
            sale: types_1.StoSaleStatus.Live,
        },
        tiers: [
            {
                price: new bignumber_js_1.default(100000000),
                remaining: new bignumber_js_1.default(700000000),
                amount: new bignumber_js_1.default(1000000000),
            },
        ],
        totalAmount: new bignumber_js_1.default(1000000000),
        totalRemaining: new bignumber_js_1.default(700000000),
        raisingCurrency: 'USD',
        minInvestment: new bignumber_js_1.default(100000000),
    },
    ticker: 'SOME_TICKER',
    id: new bignumber_js_1.default(1),
    exists: true,
};
let stoOptions = defaultStoOptions;
const defaultCheckpointOptions = {
    totalSupply: new bignumber_js_1.default(10000),
    createdAt: new Date('10/14/1987'),
    ticker: 'SOME_TICKER',
    id: new bignumber_js_1.default(1),
    exists: true,
};
let checkpointOptions = defaultCheckpointOptions;
const defaultCheckpointScheduleOptions = {
    id: new bignumber_js_1.default(1),
    ticker: 'SOME_TICKER',
    start: new Date(new Date().getTime() + 24 * 60 * 60 * 1000),
    period: {
        unit: types_1.CalendarUnit.Month,
        amount: 1,
    },
    expiryDate: new Date(new Date().getTime() + 60 * 24 * 60 * 60 * 1000),
    complexity: 2,
    details: {
        remainingCheckpoints: 1,
        nextCheckpointDate: new Date('10/10/2030'),
    },
    exists: true,
};
let checkpointScheduleOptions = defaultCheckpointScheduleOptions;
const defaultCorporateActionOptions = {
    id: new bignumber_js_1.default(1),
    ticker: 'SOME_TICKER',
    kind: types_1.CorporateActionKind.UnpredictableBenefit,
    declarationDate: new Date('10/14/1987'),
    description: 'someDescription',
    targets: {
        identities: [],
        treatment: types_1.TargetTreatment.Include,
    },
    defaultTaxWithholding: new bignumber_js_1.default(10),
    taxWithholdings: [],
    exists: true,
};
let corporateActionOptions = defaultCorporateActionOptions;
const defaultDividendDistributionOptions = {
    id: new bignumber_js_1.default(1),
    ticker: 'SOME_TICKER',
    declarationDate: new Date('10/14/1987'),
    description: 'someDescription',
    targets: {
        identities: [],
        treatment: types_1.TargetTreatment.Include,
    },
    defaultTaxWithholding: new bignumber_js_1.default(10),
    taxWithholdings: [],
    currency: 'USD',
    perShare: new bignumber_js_1.default(100),
    maxAmount: new bignumber_js_1.default(1000000),
    expiryDate: null,
    paymentDate: new Date(new Date().getTime() + 60 * 24 * 60 * 60 * 1000),
    details: {
        remainingFunds: new bignumber_js_1.default(100),
        fundsReclaimed: false,
    },
    getParticipant: {
        amount: new bignumber_js_1.default(100),
        paid: false,
    },
    exists: true,
};
let dividendDistributionOptions = defaultDividendDistributionOptions;
// NOTE uncomment in Governance v2 upgrade
// const defaultProposalOptions: ProposalOptions = {
//   pipId: new BigNumber(1),
//   getDetails: {
//     lastState: ProposalState.Referendum,
//     transaction: TxTags.treasury.Disbursement,
//   } as ProposalDetails,
//   getStage: ProposalStage.Open,
//   identityHasVoted: false,
// };
// let proposalOptions = defaultProposalOptions;
/**
 * @hidden
 * Configure the Proposal instance
 */
// NOTE uncomment in Governance v2 upgrade
// function configureProposal(opts: ProposalOptions): void {
//   const proposal = ({
//     pipId: opts.pipId,
//     getDetails: sinon.stub().returns(opts.getDetails),
//     getStage: sinon.stub().returns(opts.getStage),
//     identityHasVoted: sinon.stub().returns(opts.identityHasVoted),
//   } as unknown) as MockProposal;
//   Object.assign(mockInstanceContainer.proposal, proposal);
//   proposalConstructorStub.callsFake(args => {
//     return merge({}, proposal, args);
//   });
// }
/**
 * @hidden
 * Initialize the Proposal instance
 */
// NOTE uncomment in Governance v2 upgrade
// function initProposal(opts?: ProposalOptions): void {
//   proposalConstructorStub = sinon.stub();
//   proposalOptions = { ...defaultProposalOptions, ...opts };
//   configureProposal(proposalOptions);
// }
/**
 * @hidden
 * Configure the Authorization Request instance
 */
function configureVenue(opts) {
    const details = Object.assign({ owner: mockInstanceContainer.identity }, opts.details);
    const venue = {
        uuid: 'venue',
        id: opts.id,
        details: venueDetailsStub.resolves(details),
        exists: venueExistsStub.resolves(opts.exists),
    };
    Object.assign(mockInstanceContainer.venue, venue);
    venueConstructorStub.callsFake(args => {
        const value = lodash_1.merge({}, venue, args);
        // eslint-disable-next-line @typescript-eslint/no-var-requires
        const entities = require("../../internal");
        Object.setPrototypeOf(entities.Venue.prototype, entities.Entity.prototype);
        Object.setPrototypeOf(value, entities.Venue.prototype);
        return value;
    });
}
/**
 * @hidden
 * Initialize the Venue instance
 */
function initVenue(opts) {
    venueConstructorStub = sinon_1.default.stub();
    venueDetailsStub = sinon_1.default.stub();
    venueExistsStub = sinon_1.default.stub();
    venueOptions = Object.assign(Object.assign({}, defaultVenueOptions), opts);
    configureVenue(venueOptions);
}
/**
 * @hidden
 * Configure the Numbered Portfolio instance
 */
function configureNumberedPortfolio(opts) {
    const numberedPortfolio = {
        uuid: 'numberedPorfolio',
        id: opts.id,
        isOwnedBy: numberedPortfolioIsOwnedByStub.resolves(opts.isOwnedBy),
        getTokenBalances: numberedPortfolioGetTokenBalancesStub.resolves(opts.tokenBalances),
        getCustodian: numberedPortfolioGetCustodianStub.resolves(opts.custodian),
        owner: { did: opts.did },
        exists: numberedPortfolioExistsStub.resolves(opts.exists),
        isCustodiedBy: numberedPortfolioIsCustodiedByStub.resolves(opts.isCustodiedBy),
        isEqual: numberedPortfolioIsEqualStub.returns(opts.isEqual),
    };
    Object.assign(mockInstanceContainer.numberedPortfolio, numberedPortfolio);
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    numberedPortfolioConstructorStub.callsFake((_a = {}) => {
        var { did } = _a, args = __rest(_a, ["did"]);
        const value = lodash_1.merge({}, numberedPortfolio, args);
        // eslint-disable-next-line @typescript-eslint/no-var-requires
        const entities = require("../../internal");
        Object.setPrototypeOf(entities.Portfolio.prototype, entities.Entity.prototype);
        Object.setPrototypeOf(entities.NumberedPortfolio.prototype, entities.Portfolio.prototype);
        Object.setPrototypeOf(value, entities.NumberedPortfolio.prototype);
        return value;
    });
}
/**
 * @hidden
 * Initialize the NumberedPortfolio instance
 */
function initNumberedPortfolio(opts) {
    numberedPortfolioConstructorStub = sinon_1.default.stub();
    numberedPortfolioIsOwnedByStub = sinon_1.default.stub();
    numberedPortfolioGetTokenBalancesStub = sinon_1.default.stub();
    numberedPortfolioGetCustodianStub = sinon_1.default.stub();
    numberedPortfolioExistsStub = sinon_1.default.stub();
    numberedPortfolioGetCustodianStub = sinon_1.default.stub();
    numberedPortfolioIsCustodiedByStub = sinon_1.default.stub();
    numberedPortfolioIsEqualStub = sinon_1.default.stub();
    numberedPortfolioOptions = Object.assign(Object.assign({}, defaultNumberedPortfolioOptions), opts);
    configureNumberedPortfolio(numberedPortfolioOptions);
}
/**
 * @hidden
 * Configure the Default Portfolio instance
 */
function configureDefaultPortfolio(opts) {
    const defaultPortfolio = {
        uuid: 'defaultPortfolio',
        isOwnedBy: defaultPortfolioIsOwnedByStub.resolves(opts.isOwnedBy),
        getTokenBalances: defaultPortfolioGetTokenBalancesStub.resolves(opts.tokenBalances),
        owner: { did: opts.did },
        getCustodian: defaultPortfolioGetCustodianStub.resolves(opts.custodian),
        isCustodiedBy: defaultPortfolioIsCustodiedByStub.resolves(opts.isCustodiedBy),
        isEqual: defaultPortfolioIsEqualStub.returns(opts.isEqual),
        exists: defaultPortfolioExistsStub.resolves(opts.exists),
    };
    Object.assign(mockInstanceContainer.defaultPortfolio, defaultPortfolio);
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    defaultPortfolioConstructorStub.callsFake((_a = {}) => {
        var { did } = _a, args = __rest(_a, ["did"]);
        const value = lodash_1.merge({}, defaultPortfolio, args);
        // eslint-disable-next-line @typescript-eslint/no-var-requires
        const entities = require("../../internal");
        Object.setPrototypeOf(entities.Portfolio.prototype, entities.Entity.prototype);
        Object.setPrototypeOf(entities.DefaultPortfolio.prototype, entities.Portfolio.prototype);
        Object.setPrototypeOf(value, entities.DefaultPortfolio.prototype);
        return value;
    });
}
/**
 * @hidden
 * Initialize the DefaultPortfolio instance
 */
function initDefaultPortfolio(opts) {
    defaultPortfolioConstructorStub = sinon_1.default.stub();
    defaultPortfolioIsOwnedByStub = sinon_1.default.stub();
    defaultPortfolioGetTokenBalancesStub = sinon_1.default.stub();
    defaultPortfolioGetCustodianStub = sinon_1.default.stub();
    defaultPortfolioIsCustodiedByStub = sinon_1.default.stub();
    defaultPortfolioIsEqualStub = sinon_1.default.stub();
    defaultPortfolioExistsStub = sinon_1.default.stub();
    defaultPortfolioOptions = Object.assign(Object.assign({}, defaultDefaultPortfolioOptions), opts);
    configureDefaultPortfolio(defaultPortfolioOptions);
}
/**
 * @hidden
 * Configure the Custom Permission Group instance
 */
function configureCustomPermissionGroup(opts) {
    const customPermissionGroup = {
        uuid: 'customPermissionGroup',
        id: opts.id,
        token: Object.assign(Object.assign({}, mockInstanceContainer.securityToken), { ticker: opts.ticker }),
        getPermissions: customPermissionGroupGetPermissionsStub.resolves(opts.getPermissions),
        isEqual: customPermissionGroupIsEqualStub.returns(opts.isEqual),
        exists: customPermissionGroupExistsStub.resolves(opts.exists),
    };
    Object.assign(mockInstanceContainer.customPermissionGroup, customPermissionGroup);
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    customPermissionGroupConstructorStub.callsFake((_a = {}) => {
        var { ticker } = _a, args = __rest(_a, ["ticker"]);
        const value = lodash_1.merge({}, customPermissionGroup, args);
        // eslint-disable-next-line @typescript-eslint/no-var-requires
        const entities = require("../../internal");
        Object.setPrototypeOf(entities.PermissionGroup.prototype, entities.Entity.prototype);
        Object.setPrototypeOf(entities.CustomPermissionGroup.prototype, entities.PermissionGroup.prototype);
        Object.setPrototypeOf(value, entities.CustomPermissionGroup.prototype);
        return value;
    });
}
/**
 * @hidden
 * Initialize the CustomPermissionGroup instance
 */
function initCustomPermissionGroup(opts) {
    customPermissionGroupConstructorStub = sinon_1.default.stub();
    customPermissionGroupGetPermissionsStub = sinon_1.default.stub();
    customPermissionGroupIsEqualStub = sinon_1.default.stub();
    customPermissionGroupExistsStub = sinon_1.default.stub();
    customPermissionGroupOptions = Object.assign(Object.assign({}, defaultCustomPermissionGroupOptions), opts);
    configureCustomPermissionGroup(customPermissionGroupOptions);
}
/**
 * @hidden
 * Configure the Known Permission Group instance
 */
function configureKnownPermissionGroup(opts) {
    const knownPermissionGroup = {
        uuid: 'knownPermissionGroup',
        token: Object.assign(Object.assign({}, mockInstanceContainer.securityToken), { ticker: opts.ticker }),
        type: opts.type,
        getPermissions: knownPermissionGroupGetPermissionsStub.resolves(opts.getPermissions),
        isEqual: knownPermissionGroupIsEqualStub.returns(opts.isEqual),
        exists: knownPermissionGroupExistsStub.resolves(opts.exists),
    };
    Object.assign(mockInstanceContainer.knownPermissionGroup, knownPermissionGroup);
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    knownPermissionGroupConstructorStub.callsFake((_a = {}) => {
        var { ticker } = _a, args = __rest(_a, ["ticker"]);
        const value = lodash_1.merge({}, knownPermissionGroup, args);
        // eslint-disable-next-line @typescript-eslint/no-var-requires
        const entities = require("../../internal");
        Object.setPrototypeOf(entities.PermissionGroup.prototype, entities.Entity.prototype);
        Object.setPrototypeOf(entities.KnownPermissionGroup.prototype, entities.PermissionGroup.prototype);
        Object.setPrototypeOf(value, entities.KnownPermissionGroup.prototype);
        return value;
    });
}
/**
 * @hidden
 * Initialize the KnownPermissionGroup instance
 */
function initKnownPermissionGroup(opts) {
    knownPermissionGroupConstructorStub = sinon_1.default.stub();
    knownPermissionGroupGetPermissionsStub = sinon_1.default.stub();
    knownPermissionGroupIsEqualStub = sinon_1.default.stub();
    knownPermissionGroupExistsStub = sinon_1.default.stub();
    knownPermissionGroupOptions = Object.assign(Object.assign({}, defaultKnownPermissionGroupOptions), opts);
    configureKnownPermissionGroup(knownPermissionGroupOptions);
}
/**
 * @hidden
 * Configure the Authorization Request instance
 */
function configureAuthorizationRequest(opts) {
    const authorizationRequest = {
        uuid: 'authorizationRequest',
        authId: opts.authId,
        issuer: opts.issuer,
        target: opts.target,
        expiry: opts.expiry,
        data: opts.data,
        exists: authorizationRequestExistsStub.resolves(opts.data),
    };
    Object.assign(mockInstanceContainer.authorizationRequest, authorizationRequest);
    authorizationRequestConstructorStub.callsFake(args => {
        const value = lodash_1.merge({}, authorizationRequest, args);
        // eslint-disable-next-line @typescript-eslint/no-var-requires
        const entities = require("../../internal");
        Object.setPrototypeOf(entities.AuthorizationRequest.prototype, entities.Entity.prototype);
        Object.setPrototypeOf(value, entities.AuthorizationRequest.prototype);
        return value;
    });
}
/**
 * @hidden
 * Initialize the Authorization Request instance
 */
function initAuthorizationRequest(opts) {
    authorizationRequestConstructorStub = sinon_1.default.stub();
    authorizationRequestExistsStub = sinon_1.default.stub();
    authorizationRequestOptions = Object.assign(Object.assign({}, defaultAuthorizationRequestOptions), opts);
    configureAuthorizationRequest(authorizationRequestOptions);
}
/**
 * @hidden
 * Configure the Security Token instance
 */
function configureSecurityToken(opts) {
    const details = Object.assign({ owner: mockInstanceContainer.identity }, opts.details);
    const securityToken = {
        uuid: 'securityToken',
        ticker: opts.ticker,
        details: securityTokenDetailsStub.resolves(details),
        currentFundingRound: securityTokenCurrentFundingRoundStub.resolves(opts.currentFundingRound),
        isFrozen: securityTokenIsFrozenStub.resolves(opts.isFrozen),
        transfers: {
            canTransfer: securityTokenTransfersCanTransferStub.resolves(opts.transfersCanTransfer),
        },
        getIdentifiers: securityTokenGetIdentifiersStub.resolves(opts.getIdentifiers),
        transferRestrictions: {
            count: {
                get: securityTokenTransferRestrictionsCountGetStub.resolves(opts.transferRestrictionsCountGet),
            },
            percentage: {
                get: securityTokenTransferRestrictionsPercentageGetStub.resolves(opts.transferRestrictionsPercentageGet),
            },
        },
        corporateActions: {
            getAgents: securityTokenCorporateActionsGetAgentsStub.resolves(opts.corporateActionsGetAgents),
            getDefaults: securityTokenCorporateActionsGetDefaultsStub.resolves(opts.corporateActionsGetDefaults),
        },
        permissions: {
            getGroups: securityTokenPermissionsGetGroupsStub.resolves(opts.permissionsGetGroups),
            getAgents: securityTokenPermissionsGetAgentsStub.resolves(opts.permissionsGetAgents),
        },
        isEqual: securityTokenIsEqualStub.returns(opts.isEqual),
        exists: securityTokenExistsStub.resolves(opts.exists),
        toJson: securityTokenToJsonStub.returns(opts.toJson),
    };
    Object.assign(mockInstanceContainer.securityToken, securityToken);
    securityTokenConstructorStub.callsFake(args => {
        const value = lodash_1.merge({}, securityToken, args);
        // eslint-disable-next-line @typescript-eslint/no-var-requires
        const entities = require("../../internal");
        Object.setPrototypeOf(entities.SecurityToken.prototype, entities.Entity.prototype);
        Object.setPrototypeOf(value, entities.SecurityToken.prototype);
        return value;
    });
}
/**
 * @hidden
 * Initialize the Security Token instance
 */
function initSecurityToken(opts) {
    securityTokenConstructorStub = sinon_1.default.stub();
    securityTokenDetailsStub = sinon_1.default.stub();
    securityTokenCurrentFundingRoundStub = sinon_1.default.stub();
    securityTokenIsFrozenStub = sinon_1.default.stub();
    securityTokenTransfersCanTransferStub = sinon_1.default.stub();
    securityTokenGetIdentifiersStub = sinon_1.default.stub();
    securityTokenTransferRestrictionsCountGetStub = sinon_1.default.stub();
    securityTokenTransferRestrictionsPercentageGetStub = sinon_1.default.stub();
    securityTokenCorporateActionsGetAgentsStub = sinon_1.default.stub();
    securityTokenCorporateActionsGetDefaultsStub = sinon_1.default.stub();
    securityTokenPermissionsGetGroupsStub = sinon_1.default.stub();
    securityTokenPermissionsGetAgentsStub = sinon_1.default.stub();
    securityTokenIsEqualStub = sinon_1.default.stub();
    securityTokenExistsStub = sinon_1.default.stub();
    securityTokenToJsonStub = sinon_1.default.stub();
    securityTokenOptions = lodash_1.merge({}, defaultSecurityTokenOptions, opts);
    configureSecurityToken(securityTokenOptions);
}
/**
 * @hidden
 * Configure the Ticker Reservation instance
 */
function configureTickerReservation(opts) {
    const details = Object.assign({ owner: mockInstanceContainer.identity }, opts.details);
    const tickerReservation = {
        uuid: 'tickerReservation',
        ticker: opts.ticker,
        details: tickerReservationDetailsStub.resolves(details),
        exists: tickerReservationExistsStub.resolves(opts.exists),
    };
    Object.assign(mockInstanceContainer.tickerReservation, tickerReservation);
    tickerReservationConstructorStub.callsFake(args => {
        const value = lodash_1.merge({}, tickerReservation, args);
        // eslint-disable-next-line @typescript-eslint/no-var-requires
        const entities = require("../../internal");
        Object.setPrototypeOf(entities.TickerReservation.prototype, entities.Entity.prototype);
        Object.setPrototypeOf(value, entities.TickerReservation.prototype);
        return value;
    });
}
/**
 * @hidden
 * Initialize the Ticker Reservation instance
 */
function initTickerReservation(opts) {
    tickerReservationConstructorStub = sinon_1.default.stub();
    tickerReservationDetailsStub = sinon_1.default.stub();
    tickerReservationExistsStub = sinon_1.default.stub();
    tickerReservationOptions = Object.assign(Object.assign({}, defaultTickerReservationOptions), opts);
    configureTickerReservation(tickerReservationOptions);
}
/**
 * @hidden
 * Configure the identity instance
 */
function configureIdentity(opts) {
    var _a, _b;
    const identity = {
        uuid: 'identity',
        did: opts.did,
        hasRoles: identityHasRolesStub.resolves(opts.hasRoles),
        checkRoles: identityCheckRolesStub.resolves(opts.checkRoles),
        hasRole: identityHasRoleStub.resolves(opts.hasRole),
        hasValidCdd: identityHasValidCddStub.resolves(opts.hasValidCdd),
        getPrimaryKey: identityGetPrimaryKeyStub.resolves(opts.getPrimaryKey),
        portfolios: {},
        authorizations: {
            getReceived: identityAuthorizationsGetReceivedStub.resolves((_a = opts.authorizations) === null || _a === void 0 ? void 0 : _a.getReceived),
            getSent: identityAuthorizationsGetSentStub.resolves((_b = opts.authorizations) === null || _b === void 0 ? void 0 : _b.getSent),
        },
        tokenPermissions: {
            get: identityTokenPermissionsGetStub.resolves(opts.tokenPermissionsGet),
            getGroup: identityTokenPermissionsGetGroupStub.resolves(opts.tokenPermissionsGetGroup),
            hasPermissions: identityTokenPermissionsHasPermissionsStub.resolves(opts.tokenPermissionsHasPermissions),
            checkPermissions: identityTokenPermissionsCheckPermissionsStub.resolves(opts.tokenPermissionsCheckPermissions),
        },
        getVenues: identityGetVenuesStub.resolves(opts.getVenues),
        getScopeId: identityGetScopeIdStub.resolves(opts.getScopeId),
        getTokenBalance: identityGetTokenBalanceStub.resolves(opts.getTokenBalance),
        getSecondaryKeys: identityGetSecondaryKeysStub.resolves(opts.getSecondaryKeys),
        areSecondaryKeysFrozen: identityAreSecondaryKeysFrozenStub.resolves(opts.areScondaryKeysFrozen),
        isEqual: identityIsEqualStub.returns(opts.isEqual),
        exists: identityExistsStub.resolves(opts.exists),
    };
    Object.assign(mockInstanceContainer.identity, identity);
    identityConstructorStub.callsFake(args => {
        const value = lodash_1.merge({}, identity, args);
        // eslint-disable-next-line @typescript-eslint/no-var-requires
        const entities = require("../../internal");
        Object.setPrototypeOf(entities.Identity.prototype, entities.Entity.prototype);
        Object.setPrototypeOf(value, entities.Identity.prototype);
        return value;
    });
}
/**
 * @hidden
 * Initialize the Identity instance
 */
function initIdentity(opts) {
    identityConstructorStub = sinon_1.default.stub();
    identityHasRolesStub = sinon_1.default.stub();
    identityHasRoleStub = sinon_1.default.stub();
    identityCheckRolesStub = sinon_1.default.stub();
    identityHasValidCddStub = sinon_1.default.stub();
    identityGetPrimaryKeyStub = sinon_1.default.stub();
    identityAuthorizationsGetReceivedStub = sinon_1.default.stub();
    identityAuthorizationsGetSentStub = sinon_1.default.stub();
    identityGetVenuesStub = sinon_1.default.stub();
    identityGetScopeIdStub = sinon_1.default.stub();
    identityGetTokenBalanceStub = sinon_1.default.stub();
    identityGetSecondaryKeysStub = sinon_1.default.stub();
    identityAreSecondaryKeysFrozenStub = sinon_1.default.stub();
    identityIsEqualStub = sinon_1.default.stub();
    identityTokenPermissionsGetStub = sinon_1.default.stub();
    identityTokenPermissionsGetGroupStub = sinon_1.default.stub();
    identityTokenPermissionsHasPermissionsStub = sinon_1.default.stub();
    identityTokenPermissionsCheckPermissionsStub = sinon_1.default.stub();
    identityExistsStub = sinon_1.default.stub();
    identityOptions = Object.assign(Object.assign({}, defaultIdentityOptions), opts);
    configureIdentity(identityOptions);
}
/**
 * @hidden
 * Configure the Instruction instance
 */
function configureInstruction(opts) {
    const details = Object.assign({ venue: mockInstanceContainer.venue }, opts.details);
    const legs = opts.getLegs || {
        data: [
            {
                from: mockInstanceContainer.numberedPortfolio,
                to: mockInstanceContainer.numberedPortfolio,
                token: mockInstanceContainer.securityToken,
                amount: new bignumber_js_1.default(100),
            },
        ],
        next: null,
    };
    const instruction = {
        uuid: 'instruction',
        id: opts.id,
        details: instructionDetailsStub.resolves(details),
        getLegs: instructionGetLegsStub.resolves(legs),
        isPending: instructionIsPendigStub.resolves(opts.isPending),
        exists: instructionExistsStub.resolves(opts.exists),
    };
    Object.assign(mockInstanceContainer.instruction, instruction);
    instructionConstructorStub.callsFake(args => {
        const value = lodash_1.merge({}, instruction, args);
        // eslint-disable-next-line @typescript-eslint/no-var-requires
        const entities = require("../../internal");
        Object.setPrototypeOf(entities.Instruction.prototype, entities.Entity.prototype);
        Object.setPrototypeOf(value, entities.Instruction.prototype);
        return value;
    });
}
/**
 * @hidden
 * Initialize the Instruction instance
 */
function initInstruction(opts) {
    instructionConstructorStub = sinon_1.default.stub();
    instructionDetailsStub = sinon_1.default.stub();
    instructionGetLegsStub = sinon_1.default.stub();
    instructionIsPendigStub = sinon_1.default.stub();
    instructionExistsStub = sinon_1.default.stub();
    instructionOptions = Object.assign(Object.assign({}, defaultInstructionOptions), opts);
    configureInstruction(instructionOptions);
}
/**
 * @hidden
 * Configure the Account instance
 */
function configureAccount(opts) {
    const account = {
        uuid: 'account',
        address: opts.address,
        key: opts.key,
        isFrozen: accountIsFrozenStub.resolves(opts.isFrozen),
        getBalance: accountGetBalanceStub.resolves(opts.getBalance),
        getIdentity: accountGetIdentityStub.resolves(opts.getIdentity === undefined ? mockInstanceContainer.identity : opts.getIdentity),
        getTransactionHistory: accountGetTransactionHistoryStub.resolves(opts.getTransactionHistory),
        isEqual: accountIsEqualStub.returns(opts.isEqual),
        exists: accountExistsStub.resolves(opts.exists),
        hasPermissions: accountHasPermissionsStub.returns(opts.hasPermissions),
        checkPermissions: accountCheckPermissionsStub.returns(opts.checkPermissions),
    };
    Object.assign(mockInstanceContainer.account, account);
    accountConstructorStub.callsFake(args => {
        const value = lodash_1.merge({}, account, args);
        // eslint-disable-next-line @typescript-eslint/no-var-requires
        const entities = require("../../internal");
        Object.setPrototypeOf(entities.Account.prototype, entities.Entity.prototype);
        Object.setPrototypeOf(value, entities.Account.prototype);
        return value;
    });
}
/**
 * @hidden
 * Initialize the Account instance
 */
function initAccount(opts) {
    accountConstructorStub = sinon_1.default.stub();
    accountIsFrozenStub = sinon_1.default.stub();
    accountGetBalanceStub = sinon_1.default.stub();
    accountGetIdentityStub = sinon_1.default.stub();
    accountGetTransactionHistoryStub = sinon_1.default.stub();
    accountIsEqualStub = sinon_1.default.stub();
    accountExistsStub = sinon_1.default.stub();
    accountHasPermissionsStub = sinon_1.default.stub();
    accountCheckPermissionsStub = sinon_1.default.stub();
    accountOptions = Object.assign(Object.assign({}, defaultAccountOptions), opts);
    configureAccount(accountOptions);
}
/**
 * @hidden
 * Configure the Security Token Offering instance
 */
function configureSto(opts) {
    const details = Object.assign({ creator: mockInstanceContainer.identity, venue: mockInstanceContainer.venue, offeringPortfolio: mockInstanceContainer.defaultPortfolio, raisingPorfolio: mockInstanceContainer.numberedPortfolio }, opts.details);
    const sto = {
        uuid: 'sto',
        details: stoDetailsStub.resolves(details),
        token: Object.assign(Object.assign({}, mockInstanceContainer.securityToken), { ticker: opts.ticker }),
        id: opts.id,
        exists: stoExistsStub.resolves(opts.exists),
    };
    Object.assign(mockInstanceContainer.sto, sto);
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    stoConstructorStub.callsFake((_a = {}) => {
        var { ticker } = _a, args = __rest(_a, ["ticker"]);
        const value = lodash_1.merge({}, sto, args);
        // eslint-disable-next-line @typescript-eslint/no-var-requires
        const entities = require("../../internal");
        Object.setPrototypeOf(entities.Sto.prototype, entities.Entity.prototype);
        Object.setPrototypeOf(value, entities.Sto.prototype);
        return value;
    });
}
/**
 * @hidden
 * Initialize the Sto instance
 */
function initSto(opts) {
    stoConstructorStub = sinon_1.default.stub();
    stoDetailsStub = sinon_1.default.stub();
    stoExistsStub = sinon_1.default.stub();
    stoOptions = lodash_1.merge({}, defaultStoOptions, opts);
    configureSto(stoOptions);
}
/**
 * @hidden
 * Configure the Checkpoint instance
 */
function configureCheckpoint(opts) {
    const allBalances = opts.allBalances || {
        data: [
            {
                identity: mockInstanceContainer.identity,
                balance: new bignumber_js_1.default(10000),
            },
        ],
        next: null,
    };
    const checkpoint = {
        uuid: 'checkpoint',
        createdAt: checkpointCreatedAtStub.returns(opts.createdAt),
        totalSupply: checkpointTotalSupplyStub.returns(opts.totalSupply),
        token: Object.assign(Object.assign({}, mockInstanceContainer.securityToken), { ticker: opts.ticker }),
        id: opts.id,
        exists: checkpointExistsStub.resolves(opts.exists),
        allBalances: checkpointAllBalancesStub.resolves(allBalances),
        balance: checkpointBalanceStub.resolves(opts.balance),
    };
    Object.assign(mockInstanceContainer.checkpoint, checkpoint);
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    checkpointConstructorStub.callsFake((_a = {}) => {
        var { ticker } = _a, args = __rest(_a, ["ticker"]);
        const value = lodash_1.merge({}, checkpoint, args);
        // eslint-disable-next-line @typescript-eslint/no-var-requires
        const entities = require("../../internal");
        Object.setPrototypeOf(entities.Checkpoint.prototype, entities.Entity.prototype);
        Object.setPrototypeOf(value, entities.Checkpoint.prototype);
        return value;
    });
}
/**
 * @hidden
 * Initialize the Checkpoint instance
 */
function initCheckpoint(opts) {
    checkpointConstructorStub = sinon_1.default.stub();
    checkpointCreatedAtStub = sinon_1.default.stub();
    checkpointTotalSupplyStub = sinon_1.default.stub();
    checkpointExistsStub = sinon_1.default.stub();
    checkpointAllBalancesStub = sinon_1.default.stub();
    checkpointBalanceStub = sinon_1.default.stub();
    checkpointOptions = lodash_1.merge({}, defaultCheckpointOptions, opts);
    configureCheckpoint(checkpointOptions);
}
/**
 * @hidden
 * Configure the CheckpointSchedule instance
 */
function configureCheckpointSchedule(opts) {
    const checkpointSchedule = {
        uuid: 'checkpointSchedule',
        id: opts.id,
        token: Object.assign(Object.assign({}, mockInstanceContainer.securityToken), { ticker: opts.ticker }),
        start: opts.start,
        period: opts.period,
        expiryDate: opts.expiryDate,
        complexity: opts.complexity,
        details: checkpointScheduleDetailsStub.resolves(opts.details),
        exists: checkpointScheduleExistsStub.resolves(opts.exists),
    };
    Object.assign(mockInstanceContainer.checkpointSchedule, checkpointSchedule);
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    checkpointScheduleConstructorStub.callsFake((_a = {}) => {
        var { ticker } = _a, args = __rest(_a, ["ticker"]);
        const value = lodash_1.merge({}, checkpointSchedule, args);
        // eslint-disable-next-line @typescript-eslint/no-var-requires
        const entities = require("../../internal");
        Object.setPrototypeOf(entities.CheckpointSchedule.prototype, entities.Entity.prototype);
        Object.setPrototypeOf(value, entities.CheckpointSchedule.prototype);
        return value;
    });
}
/**
 * @hidden
 * Initialize the CheckpointSchedule instance
 */
function initCheckpointSchedule(opts) {
    checkpointScheduleConstructorStub = sinon_1.default.stub();
    checkpointScheduleDetailsStub = sinon_1.default.stub();
    checkpointScheduleExistsStub = sinon_1.default.stub();
    checkpointScheduleOptions = lodash_1.merge({}, defaultCheckpointScheduleOptions, opts);
    configureCheckpointSchedule(checkpointScheduleOptions);
}
/**
 * @hidden
 * Configure the CorporateAction instance
 */
function configureCorporateAction(opts) {
    const corporateAction = {
        uuid: 'corporateAction',
        id: opts.id,
        token: Object.assign(Object.assign({}, mockInstanceContainer.securityToken), { ticker: opts.ticker }),
        kind: opts.kind,
        declarationDate: opts.declarationDate,
        description: opts.description,
        targets: opts.targets,
        defaultTaxWithholding: opts.defaultTaxWithholding,
        taxWithholdings: opts.taxWithholdings,
        exists: corporateActionExistsStub.resolves(opts.exists),
    };
    Object.assign(mockInstanceContainer.corporateAction, corporateAction);
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    corporateActionConstructorStub.callsFake((_a = {}) => {
        var { ticker } = _a, args = __rest(_a, ["ticker"]);
        const value = lodash_1.merge({}, corporateAction, args);
        // eslint-disable-next-line @typescript-eslint/no-var-requires
        const entities = require("../../internal");
        Object.setPrototypeOf(entities.CorporateActionBase.prototype, entities.Entity.prototype);
        Object.setPrototypeOf(entities.CorporateAction.prototype, entities.CorporateActionBase.prototype);
        Object.setPrototypeOf(value, entities.CorporateAction.prototype);
        return value;
    });
}
/**
 * @hidden
 * Initialize the CorporateAction instance
 */
function initCorporateAction(opts) {
    corporateActionConstructorStub = sinon_1.default.stub();
    corporateActionExistsStub = sinon_1.default.stub();
    corporateActionOptions = lodash_1.merge({}, defaultCorporateActionOptions, opts);
    configureCorporateAction(corporateActionOptions);
}
/**
 * @hidden
 * Configure the CorporateAction instance
 */
function configureDividendDistribution(opts) {
    const details = Object.assign({ owner: mockInstanceContainer.identity }, opts.details);
    const checkpoint = opts.checkpoint || mockInstanceContainer.checkpoint;
    const getParticipant = opts.getParticipant
        ? Object.assign(Object.assign({}, defaultDividendDistributionOptions.getParticipant), opts.getParticipant) : null;
    const dividendDistribution = {
        uuid: 'dividendDistribution',
        id: opts.id,
        token: Object.assign(Object.assign({}, mockInstanceContainer.securityToken), { ticker: opts.ticker }),
        kind: types_1.CorporateActionKind.UnpredictableBenefit,
        declarationDate: opts.declarationDate,
        description: opts.description,
        targets: opts.targets,
        defaultTaxWithholding: opts.defaultTaxWithholding,
        taxWithholdings: opts.taxWithholdings,
        origin: mockInstanceContainer.defaultPortfolio,
        currency: opts.currency,
        perShare: opts.perShare,
        maxAmount: opts.maxAmount,
        expiryDate: opts.expiryDate,
        paymentDate: opts.paymentDate,
        details: dividendDistributionDetailsStub.resolves(details),
        getParticipant: dividendDistributionGetParticipantStub.resolves(getParticipant),
        checkpoint: dividendDistributionCheckpointStub.resolves(checkpoint),
        exists: dividendDistributionExistsStub.resolves(opts.exists),
    };
    Object.assign(mockInstanceContainer.dividendDistribution, dividendDistribution);
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    dividendDistributionConstructorStub.callsFake((_a = {}) => {
        var { ticker } = _a, args = __rest(_a, ["ticker"]);
        const value = lodash_1.merge({}, dividendDistribution, args);
        // eslint-disable-next-line @typescript-eslint/no-var-requires
        const entities = require("../../internal");
        Object.setPrototypeOf(entities.CorporateActionBase.prototype, entities.Entity.prototype);
        Object.setPrototypeOf(entities.DividendDistribution.prototype, entities.CorporateActionBase.prototype);
        Object.setPrototypeOf(value, entities.DividendDistribution.prototype);
        return value;
    });
}
/**
 * @hidden
 * Initialize the DividendDistribution instance
 */
function initDividendDistribution(opts) {
    dividendDistributionConstructorStub = sinon_1.default.stub();
    dividendDistributionDetailsStub = sinon_1.default.stub();
    dividendDistributionGetParticipantStub = sinon_1.default.stub();
    dividendDistributionCheckpointStub = sinon_1.default.stub();
    dividendDistributionExistsStub = sinon_1.default.stub();
    dividendDistributionOptions = lodash_1.merge({}, defaultDividendDistributionOptions, opts);
    configureDividendDistribution(dividendDistributionOptions);
}
/**
 * @hidden
 *
 * Temporarily change instance mock configuration (calling .reset will go back to the configuration passed in `initMocks`)
 */
function configureMocks(opts) {
    const tempIdentityOptions = Object.assign(Object.assign({}, defaultIdentityOptions), opts === null || opts === void 0 ? void 0 : opts.identityOptions);
    configureIdentity(tempIdentityOptions);
    const tempAccountOptions = Object.assign(Object.assign({}, defaultAccountOptions), opts === null || opts === void 0 ? void 0 : opts.accountOptions);
    configureAccount(tempAccountOptions);
    const tempTickerReservationOptions = Object.assign(Object.assign({}, defaultTickerReservationOptions), opts === null || opts === void 0 ? void 0 : opts.tickerReservationOptions);
    configureTickerReservation(tempTickerReservationOptions);
    const tempSecuritytokenOptions = lodash_1.merge({}, defaultSecurityTokenOptions, opts === null || opts === void 0 ? void 0 : opts.securityTokenOptions);
    configureSecurityToken(tempSecuritytokenOptions);
    const tempAuthorizationRequestOptions = Object.assign(Object.assign({}, defaultAuthorizationRequestOptions), opts === null || opts === void 0 ? void 0 : opts.authorizationRequestOptions);
    configureAuthorizationRequest(tempAuthorizationRequestOptions);
    // NOTE uncomment in Governance v2 upgrade
    // const tempProposalOptions = {
    //   ...defaultProposalOptions,
    //   ...opts?.proposalOptions,
    // };
    // NOTE uncomment in Governance v2 upgrade
    // configureProposal(tempProposalOptions);
    const tempVenueOptions = Object.assign(Object.assign({}, defaultVenueOptions), opts === null || opts === void 0 ? void 0 : opts.venueOptions);
    configureVenue(tempVenueOptions);
    const tempNumberedPortfolioOptions = Object.assign(Object.assign({}, defaultNumberedPortfolioOptions), opts === null || opts === void 0 ? void 0 : opts.numberedPortfolioOptions);
    configureNumberedPortfolio(tempNumberedPortfolioOptions);
    const tempDefaultPortfolioOptions = Object.assign(Object.assign({}, defaultDefaultPortfolioOptions), opts === null || opts === void 0 ? void 0 : opts.defaultPortfolioOptions);
    configureDefaultPortfolio(tempDefaultPortfolioOptions);
    const tempCustomPermissionGroupOptions = Object.assign(Object.assign({}, defaultCustomPermissionGroupOptions), opts === null || opts === void 0 ? void 0 : opts.customPermissionGroupOptions);
    configureCustomPermissionGroup(tempCustomPermissionGroupOptions);
    const tempKnownPermissionGroupOptions = Object.assign(Object.assign({}, defaultKnownPermissionGroupOptions), opts === null || opts === void 0 ? void 0 : opts.knownPermissionGroupOptions);
    configureKnownPermissionGroup(tempKnownPermissionGroupOptions);
    const tempInstructionOptions = Object.assign(Object.assign({}, defaultInstructionOptions), opts === null || opts === void 0 ? void 0 : opts.instructionOptions);
    configureInstruction(tempInstructionOptions);
    const tempStoOptions = Object.assign(Object.assign({}, stoOptions), opts === null || opts === void 0 ? void 0 : opts.stoOptions);
    configureSto(tempStoOptions);
    const tempCheckpointOptions = Object.assign(Object.assign({}, checkpointOptions), opts === null || opts === void 0 ? void 0 : opts.checkpointOptions);
    configureCheckpoint(tempCheckpointOptions);
    const tempCheckpointScheduleOptions = Object.assign(Object.assign({}, checkpointScheduleOptions), opts === null || opts === void 0 ? void 0 : opts.checkpointScheduleOptions);
    configureCheckpointSchedule(tempCheckpointScheduleOptions);
    const tempCorporateActionOptions = Object.assign(Object.assign({}, corporateActionOptions), opts === null || opts === void 0 ? void 0 : opts.corporateActionOptions);
    configureCorporateAction(tempCorporateActionOptions);
    const tempDividendDistributionOptions = Object.assign(Object.assign({}, dividendDistributionOptions), opts === null || opts === void 0 ? void 0 : opts.dividendDistributionOptions);
    configureDividendDistribution(tempDividendDistributionOptions);
}
exports.configureMocks = configureMocks;
/**
 * @hidden
 *
 * Initialize the factory by adding default all-purpose functionality to the mock manager
 */
function initMocks(opts) {
    // Identity
    initIdentity(opts === null || opts === void 0 ? void 0 : opts.identityOptions);
    // Account
    initAccount(opts === null || opts === void 0 ? void 0 : opts.accountOptions);
    // Ticker Reservation
    initTickerReservation(opts === null || opts === void 0 ? void 0 : opts.tickerReservationOptions);
    // Security Token
    initSecurityToken(opts === null || opts === void 0 ? void 0 : opts.securityTokenOptions);
    // Authorization Request
    initAuthorizationRequest(opts === null || opts === void 0 ? void 0 : opts.authorizationRequestOptions);
    // Instruction Request
    initInstruction(opts === null || opts === void 0 ? void 0 : opts.instructionOptions);
    // Proposal
    // NOTE uncomment in Governance v2 upgrade
    // initProposal(opts?.proposalOptions);
    // Venue
    initVenue(opts === null || opts === void 0 ? void 0 : opts.venueOptions);
    // NumberedPortfolio
    initNumberedPortfolio(opts === null || opts === void 0 ? void 0 : opts.numberedPortfolioOptions);
    // DefaultPortfolio
    initDefaultPortfolio(opts === null || opts === void 0 ? void 0 : opts.defaultPortfolioOptions);
    // CustomPermissionGroup
    initCustomPermissionGroup(opts === null || opts === void 0 ? void 0 : opts.customPermissionGroupOptions);
    // KnownPermissionGroup
    initKnownPermissionGroup(opts === null || opts === void 0 ? void 0 : opts.knownPermissionGroupOptions);
    // Instruction
    initInstruction(opts === null || opts === void 0 ? void 0 : opts.instructionOptions);
    // Sto
    initSto(opts === null || opts === void 0 ? void 0 : opts.stoOptions);
    // Checkpoint
    initCheckpoint(opts === null || opts === void 0 ? void 0 : opts.checkpointOptions);
    // CheckpointSchedule
    initCheckpointSchedule(opts === null || opts === void 0 ? void 0 : opts.checkpointScheduleOptions);
    // CorporateAction
    initCorporateAction(opts === null || opts === void 0 ? void 0 : opts.corporateActionOptions);
    // DividendDistribution
    initDividendDistribution(opts === null || opts === void 0 ? void 0 : opts.dividendDistributionOptions);
}
exports.initMocks = initMocks;
/**
 * @hidden
 * Restore instances to their original state
 */
function cleanup() {
    mockInstanceContainer.identity = {};
    mockInstanceContainer.account = {};
    mockInstanceContainer.tickerReservation = {};
    mockInstanceContainer.securityToken = {};
    mockInstanceContainer.authorizationRequest = {};
    mockInstanceContainer.permissionGroup = {};
    // NOTE uncomment in Governance v2 upgrade
    // mockInstanceContainer.proposal = {} as MockProposal;
    mockInstanceContainer.venue = {};
    mockInstanceContainer.instruction = {};
    mockInstanceContainer.sto = {};
    mockInstanceContainer.checkpoint = {};
    mockInstanceContainer.checkpointSchedule = {};
    mockInstanceContainer.corporateAction = {};
    mockInstanceContainer.dividendDistribution = {};
}
exports.cleanup = cleanup;
/**
 * @hidden
 * Reinitialize mocks
 */
function reset() {
    cleanup();
    initMocks({
        identityOptions,
        accountOptions,
        tickerReservationOptions,
        securityTokenOptions,
        authorizationRequestOptions,
        // NOTE uncomment in Governance v2 upgrade
        // proposalOptions,
        venueOptions,
        instructionOptions,
        numberedPortfolioOptions,
        defaultPortfolioOptions,
        stoOptions,
        checkpointOptions,
        checkpointScheduleOptions,
        corporateActionOptions,
        dividendDistributionOptions,
        customPermissionGroupOptions,
        knownPermissionGroupOptions,
    });
}
exports.reset = reset;
/**
 * @hidden
 * Retrieve an Identity instance
 */
function getIdentityInstance(opts) {
    if (opts) {
        configureIdentity(Object.assign(Object.assign({}, defaultIdentityOptions), opts));
    }
    return new MockIdentityClass();
}
exports.getIdentityInstance = getIdentityInstance;
/**
 * @hidden
 * Retrieve the Identity constructor stub
 */
function getIdentityConstructorStub() {
    return identityConstructorStub;
}
exports.getIdentityConstructorStub = getIdentityConstructorStub;
/**
 * @hidden
 * Retrieve the stub of the `Identity.hasRoles` method
 */
function getIdentityHasRolesStub() {
    return identityHasRolesStub;
}
exports.getIdentityHasRolesStub = getIdentityHasRolesStub;
/**
 * @hidden
 * Retrieve the stub of the `Identity.hasRoles` method
 */
function getIdentityHasRoleStub() {
    return identityHasRoleStub;
}
exports.getIdentityHasRoleStub = getIdentityHasRoleStub;
/**
 * @hidden
 * Retrieve the stub of the `Identity.tokenPermissions.hasPermissions` method
 */
function getIdentityTokenPermissionsHasPermissionsStub() {
    return identityTokenPermissionsHasPermissionsStub;
}
exports.getIdentityTokenPermissionsHasPermissionsStub = getIdentityTokenPermissionsHasPermissionsStub;
/**
 * @hidden
 * Retrieve the stub of the `Identity.hasValidCdd` method
 */
function getIdentityHasValidCddStub() {
    return identityHasValidCddStub;
}
exports.getIdentityHasValidCddStub = getIdentityHasValidCddStub;
/**
 * @hidden
 * Retrieve the stub of the `Identity.getPrimaryKey` method
 */
function getIdentityGetPrimaryKeyStub() {
    return identityGetPrimaryKeyStub;
}
exports.getIdentityGetPrimaryKeyStub = getIdentityGetPrimaryKeyStub;
/**
 * @hidden
 * Retrieve the stub of the `Identity.authorizations.getReceived` method
 */
function getIdentityAuthorizationsGetReceivedStub() {
    return identityAuthorizationsGetReceivedStub;
}
exports.getIdentityAuthorizationsGetReceivedStub = getIdentityAuthorizationsGetReceivedStub;
/**
 * @hidden
 * Retrieve the stub of the `Identity.authorizations.getSent` method
 */
function getIdentityAuthorizationsGetSentStub() {
    return identityAuthorizationsGetSentStub;
}
exports.getIdentityAuthorizationsGetSentStub = getIdentityAuthorizationsGetSentStub;
/**
 * @hidden
 * Retrieve the stub of the `Identity.getVenues` method
 */
function getIdentityGetVenuesStub() {
    return identityGetVenuesStub;
}
exports.getIdentityGetVenuesStub = getIdentityGetVenuesStub;
/**
 * @hidden
 * Retrieve the stub of the `Identity.getScopeId` method
 */
function getIdentityGetScopeIdStub() {
    return identityGetScopeIdStub;
}
exports.getIdentityGetScopeIdStub = getIdentityGetScopeIdStub;
/**
 * @hidden
 * Retrieve the stub of the `Identity.tokenPermissions.getGroup` method
 */
function getIdentityTokenPermissionsGetGroupStub(group) {
    if (group) {
        return identityTokenPermissionsGetGroupStub.resolves(group);
    }
    return identityTokenPermissionsGetGroupStub;
}
exports.getIdentityTokenPermissionsGetGroupStub = getIdentityTokenPermissionsGetGroupStub;
/**
 * @hidden
 * Retrieve the stub of the `Identity.isEqual` method
 */
function getIdentityIsEqualStub() {
    return identityIsEqualStub;
}
exports.getIdentityIsEqualStub = getIdentityIsEqualStub;
/**
 * @hidden
 * Retrieve an Account instance
 */
function getAccountInstance(opts) {
    if (opts) {
        configureAccount(Object.assign(Object.assign({}, defaultAccountOptions), opts));
    }
    return new MockAccountClass();
}
exports.getAccountInstance = getAccountInstance;
/**
 * @hidden
 * Retrieve the stub of the `Account.isFrozen` method
 */
function getAccountIsFrozenStub() {
    return accountIsFrozenStub;
}
exports.getAccountIsFrozenStub = getAccountIsFrozenStub;
/**
 * @hidden
 * Retrieve the stub of the `Account.getBalance` method
 */
function getAccountGetBalanceStub() {
    return accountGetBalanceStub;
}
exports.getAccountGetBalanceStub = getAccountGetBalanceStub;
/**
 * @hidden
 * Retrieve the stub of the `Account.getIdentity` method
 */
function getAccountGetIdentityStub() {
    return accountGetIdentityStub;
}
exports.getAccountGetIdentityStub = getAccountGetIdentityStub;
/**
 * @hidden
 * Retrieve the stub of the `Account.getTransactionHistory` method
 */
function getAccountGetTransactionHistoryStub() {
    return accountGetTransactionHistoryStub;
}
exports.getAccountGetTransactionHistoryStub = getAccountGetTransactionHistoryStub;
/**
 * @hidden
 * Retrieve the stub of the `Account.isEqual` method
 */
function getAccountIsEqualStub() {
    return accountIsEqualStub;
}
exports.getAccountIsEqualStub = getAccountIsEqualStub;
/**
 * @hidden
 * Retrieve the stub of the `Account.isEqual` method
 */
function getAccountHasPermissionsStub() {
    return accountHasPermissionsStub;
}
exports.getAccountHasPermissionsStub = getAccountHasPermissionsStub;
/**
 * @hidden
 * Retrieve the stub of the `NumberedPortfolio.isCustodiedBy` method
 */
function getNumberedPortfolioIsCustodiedByStub() {
    return numberedPortfolioIsCustodiedByStub;
}
exports.getNumberedPortfolioIsCustodiedByStub = getNumberedPortfolioIsCustodiedByStub;
/**
 * @hidden
 * Retrieve the stub of the `NumberedPortfolio.getCustodian` method
 */
function getNumberedPortfolioGetCustodianStub() {
    return numberedPortfolioGetCustodianStub;
}
exports.getNumberedPortfolioGetCustodianStub = getNumberedPortfolioGetCustodianStub;
/**
 * @hidden
 * Retrieve the stub of the `NumberedPortfolio.isEqual` method
 */
function getNumberedPortfolioIsEqualStub() {
    return numberedPortfolioIsEqualStub;
}
exports.getNumberedPortfolioIsEqualStub = getNumberedPortfolioIsEqualStub;
/**
 * @hidden
 * Retrieve the stub of the `DefaultPortfolio.isCustodiedBy` method
 */
function getDefaultPortfolioIsCustodiedByStub() {
    return defaultPortfolioIsCustodiedByStub;
}
exports.getDefaultPortfolioIsCustodiedByStub = getDefaultPortfolioIsCustodiedByStub;
/**
 * @hidden
 * Retrieve the stub of the `DefaultPortfolio.getCustodian` method
 */
function getDefaultPortfolioGetCustodianStub() {
    return defaultPortfolioGetCustodianStub;
}
exports.getDefaultPortfolioGetCustodianStub = getDefaultPortfolioGetCustodianStub;
/**
 * @hidden
 * Retrieve the stub of the `DefaultPortfolio.isEqual` method
 */
function getDefaultPortfolioIsEqualStub() {
    return defaultPortfolioIsEqualStub;
}
exports.getDefaultPortfolioIsEqualStub = getDefaultPortfolioIsEqualStub;
/**
 * @hidden
 * Retrieve a Ticker Reservation instance
 */
function getTickerReservationInstance(opts) {
    if (opts) {
        configureTickerReservation(Object.assign(Object.assign({}, defaultTickerReservationOptions), opts));
    }
    return new MockTickerReservationClass();
}
exports.getTickerReservationInstance = getTickerReservationInstance;
/**
 * @hidden
 * Retrieve the stub of the `TickerReservation.details` method
 */
function getTickerReservationDetailsStub(details) {
    if (details) {
        return tickerReservationDetailsStub.resolves(Object.assign(Object.assign({}, defaultTickerReservationOptions.details), details));
    }
    return tickerReservationDetailsStub;
}
exports.getTickerReservationDetailsStub = getTickerReservationDetailsStub;
/**
 * @hidden
 * Retrieve a Security Token instance
 */
function getSecurityTokenInstance(opts) {
    if (opts) {
        configureSecurityToken(Object.assign(Object.assign({}, defaultSecurityTokenOptions), opts));
    }
    return new MockSecurityTokenClass();
}
exports.getSecurityTokenInstance = getSecurityTokenInstance;
/**
 * @hidden
 * Retrieve the stub of the `SecurityToken.details` method
 */
function getSecurityTokenDetailsStub(details) {
    if (details) {
        return securityTokenDetailsStub.resolves(Object.assign(Object.assign({}, defaultSecurityTokenOptions.details), details));
    }
    return securityTokenDetailsStub;
}
exports.getSecurityTokenDetailsStub = getSecurityTokenDetailsStub;
/**
 * @hidden
 * Retrieve the stub of the `SecurityToken.currentFundingRound` method
 */
function getSecurityTokenCurrentFundingRoundStub(currentFundingRound) {
    if (currentFundingRound) {
        return securityTokenCurrentFundingRoundStub.resolves(currentFundingRound);
    }
    return securityTokenCurrentFundingRoundStub;
}
exports.getSecurityTokenCurrentFundingRoundStub = getSecurityTokenCurrentFundingRoundStub;
/**
 * @hidden
 * Retrieve the stub of the `SecurityToken.isFrozen` method
 */
function getSecurityTokenIsFrozenStub(frozen) {
    if (frozen !== undefined) {
        return securityTokenIsFrozenStub.resolves(frozen);
    }
    return securityTokenIsFrozenStub;
}
exports.getSecurityTokenIsFrozenStub = getSecurityTokenIsFrozenStub;
/**
 * @hidden
 * Retrieve the stub of the `SecurityToken.getIdentifiers` method
 */
function getSecurityTokenGetIdentifiersStub(identifiers) {
    if (identifiers !== undefined) {
        return securityTokenGetIdentifiersStub.resolves(identifiers);
    }
    return securityTokenGetIdentifiersStub;
}
exports.getSecurityTokenGetIdentifiersStub = getSecurityTokenGetIdentifiersStub;
/**
 * @hidden
 * Retrieve the stub of the `SecurityToken.Transfers.canTransfer` method
 */
function getSecurityTokenTransfersCanTransferStub(status) {
    if (status) {
        return securityTokenTransfersCanTransferStub.resolves(status);
    }
    return securityTokenTransfersCanTransferStub;
}
exports.getSecurityTokenTransfersCanTransferStub = getSecurityTokenTransfersCanTransferStub;
/**
 * @hidden
 * Retrieve the stub of the `SecurityToken.transferRestictions.count.get` method
 */
function getSecurityTokenTransferRestrictionsCountGetStub(restrictions) {
    if (restrictions) {
        return securityTokenTransferRestrictionsCountGetStub.resolves(restrictions);
    }
    return securityTokenTransferRestrictionsCountGetStub;
}
exports.getSecurityTokenTransferRestrictionsCountGetStub = getSecurityTokenTransferRestrictionsCountGetStub;
/**
 * @hidden
 * Retrieve the stub of the `SecurityToken.transferRestictions.pecentage.get` method
 */
function getSecurityTokenTransferRestrictionsPercentageGetStub(restrictions) {
    if (restrictions) {
        return securityTokenTransferRestrictionsPercentageGetStub.resolves(restrictions);
    }
    return securityTokenTransferRestrictionsPercentageGetStub;
}
exports.getSecurityTokenTransferRestrictionsPercentageGetStub = getSecurityTokenTransferRestrictionsPercentageGetStub;
/**
 * @hidden
 * Retrieve the stub of the `SecurityToken.corporateActions.getAgents` method
 */
function getSecurityTokenCorporateActionsGetAgentsStub(agent) {
    if (agent) {
        return securityTokenCorporateActionsGetAgentsStub.resolves(agent);
    }
    return securityTokenCorporateActionsGetAgentsStub;
}
exports.getSecurityTokenCorporateActionsGetAgentsStub = getSecurityTokenCorporateActionsGetAgentsStub;
/**
 * @hidden
 * Retrieve the stub of the `SecurityToken.corporateActions.getDefaults` method
 */
function getSecurityTokenCorporateActionsGetDefaultsStub(defaults) {
    if (defaults) {
        return securityTokenCorporateActionsGetDefaultsStub.resolves(defaults);
    }
    return securityTokenCorporateActionsGetDefaultsStub;
}
exports.getSecurityTokenCorporateActionsGetDefaultsStub = getSecurityTokenCorporateActionsGetDefaultsStub;
/**
 * @hidden
 * Retrieve the stub of the `SecurityToken.permissions.getGroups` method
 */
function getSecurityTokenPermissionsGetGroupsStub(groups) {
    if (groups) {
        return securityTokenPermissionsGetGroupsStub.resolves(groups);
    }
    return securityTokenPermissionsGetGroupsStub;
}
exports.getSecurityTokenPermissionsGetGroupsStub = getSecurityTokenPermissionsGetGroupsStub;
/**
 * @hidden
 * Retrieve the stub of the `SecurityToken.permissions.getAgents` method
 */
function getSecurityTokenPermissionsGetAgentsStub(agents) {
    if (agents) {
        return securityTokenPermissionsGetAgentsStub.resolves(agents);
    }
    return securityTokenPermissionsGetAgentsStub;
}
exports.getSecurityTokenPermissionsGetAgentsStub = getSecurityTokenPermissionsGetAgentsStub;
/**
 * @hidden
 * Retrieve an Authorization Request instance
 */
function getAuthorizationRequestInstance(opts) {
    if (opts) {
        configureAuthorizationRequest(Object.assign(Object.assign({}, defaultAuthorizationRequestOptions), opts));
    }
    return new MockAuthorizationRequestClass();
}
exports.getAuthorizationRequestInstance = getAuthorizationRequestInstance;
/**
 * @hidden
 * Retrieve a Proposal instance
 */
// NOTE uncomment in Governance v2 upgrade
// export function getProposalInstance(opts?: ProposalOptions): MockProposal {
//   if (opts) {
//     configureProposal(opts);
//   }
//   return mockInstanceContainer.proposal;
// }
/**
 * @hidden
 * Retrieve a Venue instance
 */
function getVenueInstance(opts) {
    if (opts) {
        configureVenue(Object.assign(Object.assign({}, defaultVenueOptions), opts));
    }
    return new MockVenueClass();
}
exports.getVenueInstance = getVenueInstance;
/**
 * @hidden
 * Retrieve the stub of the `Venue.details` method
 */
function getVenueDetailsStub(details) {
    if (details) {
        return venueDetailsStub.resolves(Object.assign(Object.assign({}, defaultVenueOptions.details), details));
    }
    return venueDetailsStub;
}
exports.getVenueDetailsStub = getVenueDetailsStub;
/**
 * @hidden
 * Retrieve a NumberedPortfolio instance
 */
function getNumberedPortfolioInstance(opts) {
    if (opts) {
        configureNumberedPortfolio(Object.assign(Object.assign({}, defaultNumberedPortfolioOptions), opts));
    }
    return new MockNumberedPortfolioClass();
}
exports.getNumberedPortfolioInstance = getNumberedPortfolioInstance;
/**
 * @hidden
 * Retrieve a DefaultPortfolio instance
 */
function getDefaultPortfolioInstance(opts) {
    if (opts) {
        configureDefaultPortfolio(Object.assign(Object.assign({}, defaultDefaultPortfolioOptions), opts));
    }
    return new MockDefaultPortfolioClass();
}
exports.getDefaultPortfolioInstance = getDefaultPortfolioInstance;
/**
 * @hidden
 * Retrieve a CustomPermissionGroup instance
 */
function getCustomPermissionGroupInstance(opts) {
    if (opts) {
        configureCustomPermissionGroup(Object.assign(Object.assign({}, defaultCustomPermissionGroupOptions), opts));
    }
    return new MockCustomPermissionGroupClass();
}
exports.getCustomPermissionGroupInstance = getCustomPermissionGroupInstance;
/**
 * @hidden
 * Retrieve the stub of the `CustomPermissionGroup.getPermissions` method
 */
function getCustomPermissionGroupGetPermissionsStub(getPermissions) {
    if (getPermissions) {
        return customPermissionGroupGetPermissionsStub.resolves(getPermissions);
    }
    return customPermissionGroupGetPermissionsStub;
}
exports.getCustomPermissionGroupGetPermissionsStub = getCustomPermissionGroupGetPermissionsStub;
/**
 * @hidden
 * Retrieve the stub of the `CustomPermissionGroup.isEqual` method
 */
function getCustomPermissionIsEqualStub() {
    return customPermissionGroupIsEqualStub;
}
exports.getCustomPermissionIsEqualStub = getCustomPermissionIsEqualStub;
/**
 * @hidden
 * Retrieve a KnownPermissionGroup instance
 */
function getKnownPermissionGroupInstance(opts) {
    if (opts) {
        configureKnownPermissionGroup(Object.assign(Object.assign({}, defaultKnownPermissionGroupOptions), opts));
    }
    return new MockKnownPermissionGroupClass();
}
exports.getKnownPermissionGroupInstance = getKnownPermissionGroupInstance;
/**
 * @hidden
 * Retrieve the stub of the `KnownPermissionGroup.getPermissions` method
 */
function getKnownPermissionGroupGetPermissionsStub(getPermissions) {
    if (getPermissions) {
        return knownPermissionGroupGetPermissionsStub.resolves(getPermissions);
    }
    return knownPermissionGroupGetPermissionsStub;
}
exports.getKnownPermissionGroupGetPermissionsStub = getKnownPermissionGroupGetPermissionsStub;
/**
 * @hidden
 * Retrieve the stub of the `KnownPermissionGroup.isEqual` method
 */
function getKnownPermissionGroupIsEqualStub() {
    return knownPermissionGroupIsEqualStub;
}
exports.getKnownPermissionGroupIsEqualStub = getKnownPermissionGroupIsEqualStub;
/**
 * @hidden
 * Retrieve an Instruction instance
 */
function getInstructionInstance(opts) {
    if (opts) {
        configureInstruction(Object.assign(Object.assign({}, defaultInstructionOptions), opts));
    }
    return new MockInstructionClass();
}
exports.getInstructionInstance = getInstructionInstance;
/**
 * @hidden
 * Retrieve the stub of the `Instruction.details` method
 */
function getInstructionDetailsStub(details) {
    if (details) {
        return instructionDetailsStub.resolves(Object.assign(Object.assign({}, defaultInstructionOptions.details), details));
    }
    return instructionDetailsStub;
}
exports.getInstructionDetailsStub = getInstructionDetailsStub;
/**
 * @hidden
 * Retrieve the stub of the `Instruction.getLegs` method
 */
function getInstructionGetLegsStub(legs) {
    if (legs) {
        return instructionGetLegsStub.resolves(Object.assign(Object.assign({}, defaultInstructionOptions.getLegs), legs));
    }
    return instructionGetLegsStub;
}
exports.getInstructionGetLegsStub = getInstructionGetLegsStub;
/**
 * @hidden
 * Retrieve an Sto instance
 */
function getStoInstance(opts) {
    if (opts) {
        configureSto(Object.assign(Object.assign({}, defaultStoOptions), opts));
    }
    return new MockStoClass();
}
exports.getStoInstance = getStoInstance;
/**
 * @hidden
 * Retrieve the stub of the `Sto.details` method
 */
function getStoDetailsStub(details) {
    if (details) {
        return stoDetailsStub.resolves(Object.assign(Object.assign({}, defaultStoOptions.details), details));
    }
    return stoDetailsStub;
}
exports.getStoDetailsStub = getStoDetailsStub;
/**
 * @hidden
 * Retrieve the Sto constructor stub
 */
function getStoConstructorStub() {
    return stoConstructorStub;
}
exports.getStoConstructorStub = getStoConstructorStub;
/**
 * @hidden
 * Retrieve a Checkpoint instance
 */
function getCheckpointInstance(opts) {
    if (opts) {
        configureCheckpoint(Object.assign(Object.assign({}, defaultCheckpointOptions), opts));
    }
    return new MockCheckpointClass();
}
exports.getCheckpointInstance = getCheckpointInstance;
/**
 * @hidden
 * Retrieve the stub of the `Checkpoint.createdAt` method
 */
function getCheckpointCreatedAtStub(createdAt) {
    if (createdAt) {
        return checkpointCreatedAtStub.resolves(createdAt);
    }
    return checkpointCreatedAtStub;
}
exports.getCheckpointCreatedAtStub = getCheckpointCreatedAtStub;
/**
 * @hidden
 * Retrieve the stub of the `Checkpoint.totalSupply` method
 */
function getCheckpointTotalSupplyStub(totalSupply) {
    if (totalSupply) {
        return checkpointTotalSupplyStub.resolves(totalSupply);
    }
    return checkpointTotalSupplyStub;
}
exports.getCheckpointTotalSupplyStub = getCheckpointTotalSupplyStub;
/**
 * @hidden
 * Retrieve the stub of the `Checkpoint.exists` method
 */
function getCheckpointExistsStub(exists) {
    if (exists) {
        return checkpointExistsStub.resolves(exists);
    }
    return checkpointExistsStub;
}
exports.getCheckpointExistsStub = getCheckpointExistsStub;
/**
 * @hidden
 * Retrieve the stub of the `Checkpoint.allBalances` method
 */
function getCheckpointAllBalancesStub(allBalances) {
    if (allBalances) {
        return checkpointAllBalancesStub.resolves(allBalances);
    }
    return checkpointAllBalancesStub;
}
exports.getCheckpointAllBalancesStub = getCheckpointAllBalancesStub;
/**
 * @hidden
 * Retrieve the stub of the `Checkpoint.balance` method
 */
function getCheckpointBalanceStub(balance) {
    if (balance) {
        return checkpointBalanceStub.resolves(balance);
    }
    return checkpointBalanceStub;
}
exports.getCheckpointBalanceStub = getCheckpointBalanceStub;
/**
 * @hidden
 * Retrieve the Checkpoint constructor stub
 */
function getCheckpointConstructorStub() {
    return checkpointConstructorStub;
}
exports.getCheckpointConstructorStub = getCheckpointConstructorStub;
/**
 * @hidden
 * Retrieve a CheckpointSchedule instance
 */
function getCheckpointScheduleInstance(opts) {
    if (opts) {
        configureCheckpointSchedule(Object.assign(Object.assign({}, defaultCheckpointScheduleOptions), opts));
    }
    return new MockCheckpointScheduleClass();
}
exports.getCheckpointScheduleInstance = getCheckpointScheduleInstance;
/**
 * @hidden
 * Retrieve the CheckpointSchedule constructor stub
 */
function getCheckpointScheduleConstructorStub() {
    return checkpointScheduleConstructorStub;
}
exports.getCheckpointScheduleConstructorStub = getCheckpointScheduleConstructorStub;
/**
 * @hidden
 * Retrieve the stub of the `CheckpointSchedule.details` method
 */
function getCheckpointScheduleDetailsStub(details) {
    if (details) {
        return checkpointScheduleDetailsStub.resolves(Object.assign(Object.assign({}, defaultCheckpointScheduleOptions.details), details));
    }
    return checkpointScheduleDetailsStub;
}
exports.getCheckpointScheduleDetailsStub = getCheckpointScheduleDetailsStub;
/**
 * @hidden
 * Retrieve a CorporateAction instance
 */
function getCorporateActionInstance(opts) {
    if (opts) {
        configureCorporateAction(Object.assign(Object.assign({}, defaultCorporateActionOptions), opts));
    }
    return new MockCorporateActionClass();
}
exports.getCorporateActionInstance = getCorporateActionInstance;
/**
 * @hidden
 * Retrieve the stub of the `CorporateAction.exists` method
 */
function getCorporateActionExistsStub(exists) {
    if (exists) {
        return corporateActionExistsStub.resolves(exists);
    }
    return corporateActionExistsStub;
}
exports.getCorporateActionExistsStub = getCorporateActionExistsStub;
/**
 * @hidden
 * Retrieve the CorporateAction constructor stub
 */
function getCorporateActionConstructorStub() {
    return corporateActionConstructorStub;
}
exports.getCorporateActionConstructorStub = getCorporateActionConstructorStub;
/**
 * @hidden
 * Retrieve a DividendDistribution instance
 */
function getDividendDistributionInstance(opts) {
    if (opts) {
        configureDividendDistribution(Object.assign(Object.assign({}, defaultDividendDistributionOptions), opts));
    }
    return new MockDividendDistributionClass();
}
exports.getDividendDistributionInstance = getDividendDistributionInstance;
/**
 * @hidden
 * Retrieve the stub of the `DividendDistribution.checkpoint` method
 */
function getDividendDistributionCheckpointStub(checkpoint) {
    if (checkpoint) {
        return dividendDistributionCheckpointStub.resolves(checkpoint);
    }
    return dividendDistributionCheckpointStub;
}
exports.getDividendDistributionCheckpointStub = getDividendDistributionCheckpointStub;
/**
 * @hidden
 * Retrieve the DividendDistribution constructor stub
 */
function getDividendDistributionConstructorStub() {
    return dividendDistributionConstructorStub;
}
exports.getDividendDistributionConstructorStub = getDividendDistributionConstructorStub;
/**
 * @hidden
 * Retrieve the stub of the `DividendDistribution.getParticipant` method
 */
function getDividendDistributionGetParticipantStub(getParticipant) {
    if (getParticipant) {
        return dividendDistributionGetParticipantStub.resolves(Object.assign(Object.assign({}, defaultDividendDistributionOptions.getParticipant), getParticipant));
    }
    return dividendDistributionGetParticipantStub.resolves(getParticipant);
}
exports.getDividendDistributionGetParticipantStub = getDividendDistributionGetParticipantStub;
//# sourceMappingURL=entities.js.map