UNPKG

@ethereum-waffle/chai

Version:

A sweet set of chai matchers for your blockchain testing needs.

28 lines 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateFnName = exports.validateMockProvider = exports.validateContract = void 0; const error_1 = require("./error"); const utils_1 = require("./utils"); function validateContract(contract) { const possiblyContract = contract; (0, utils_1.ensure)(!!possiblyContract.address && !!possiblyContract.functions && !!possiblyContract.interface, TypeError, 'argument must be a contract'); } exports.validateContract = validateContract; function validateMockProvider(provider) { (0, utils_1.ensure)((!!provider.callHistory && provider.callHistory instanceof Array), error_1.ProviderWithHistoryExpected); } exports.validateMockProvider = validateMockProvider; function validateFnName(fnName, contract) { (0, utils_1.ensure)(typeof fnName === 'string', TypeError, 'function name must be a string'); function isFunction(name) { try { return !!contract.interface.getFunction(name); } catch (e) { return false; } } (0, utils_1.ensure)(isFunction(fnName), TypeError, 'function must exist in provided contract'); } exports.validateFnName = validateFnName; //# sourceMappingURL=calledOnContractValidators.js.map