Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onflow/util-template

Package Overview
Dependencies
Maintainers
11
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onflow/util-template - npm Package Compare versions

Comparing version 1.1.0-alpha.2 to 1.1.0

12

CHANGELOG.md
# @onflow/util-template
## 1.1.0
### Minor Changes
- [#1577](https://github.com/onflow/fcl-js/pull/1577) [`d9a49531`](https://github.com/onflow/fcl-js/commit/d9a495316cd03ed0de99e0f01d1b8850a1f0eec4) Thanks [@chasefleming](https://github.com/chasefleming)! - Add npmignore file for build
### Patch Changes
- [#1663](https://github.com/onflow/fcl-js/pull/1663) [`62dfafa9`](https://github.com/onflow/fcl-js/commit/62dfafa9c7adc3933822b0d3171d6eb025f1719e) Thanks [@nialexsan](https://github.com/nialexsan)! - Upgrade jest to v29.5 and update tests accordingly. Change build to transpile with ESM modules.
- [#1658](https://github.com/onflow/fcl-js/pull/1658) [`2512b5c5`](https://github.com/onflow/fcl-js/commit/2512b5c53dff708fca97cd8afdbb1f4a46b2f106) Thanks [@nialexsan](https://github.com/nialexsan)! - Align jest version
## 1.1.0-alpha.2

@@ -4,0 +16,0 @@

377

dist/template.js

@@ -9,3 +9,4 @@ 'use strict';

let promise;
var queueMicrotask_1 = typeof queueMicrotask === 'function' ? queueMicrotask.bind(typeof window !== 'undefined' ? window : commonjsGlobal) // reuse resolved promise, and allocate it lazily
var queueMicrotask_1 = typeof queueMicrotask === 'function' ? queueMicrotask.bind(typeof window !== 'undefined' ? window : commonjsGlobal)
// reuse resolved promise, and allocate it lazily
: cb => (promise || (promise = Promise.resolve())).then(cb).catch(err => setTimeout(() => {

@@ -21,3 +22,2 @@ throw err;

queue.push(msg);
if (next) {

@@ -28,3 +28,2 @@ next(queue.shift());

},
receive() {

@@ -37,6 +36,4 @@ return new Promise(function innerReceive(resolve) {

}
};
};
const INIT = "INIT";

@@ -52,3 +49,2 @@ const SUBSCRIBE = "SUBSCRIBE";

const DEFAULT_TIMEOUT = 5000;
const send = function (addr, tag, data) {

@@ -59,7 +55,5 @@ let opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};

const timeout = opts.timeout != null ? opts.timeout : DEFAULT_TIMEOUT;
if (expectReply && timeout) {
setTimeout(() => reject(new Error(`Timeout: ${timeout}ms passed without a response.`)), timeout);
}
const payload = {

@@ -74,3 +68,2 @@ to: addr,

};
try {

@@ -84,7 +77,5 @@ root.FCL_REGISTRY[addr] && root.FCL_REGISTRY[addr].mailbox.deliver(payload);

};
const kill = addr => {
delete root.FCL_REGISTRY[addr];
};
const fromHandlers = function () {

@@ -94,6 +85,4 @@ let handlers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

if (typeof handlers[INIT] === "function") await handlers[INIT](ctx);
__loop: while (1) {
const letter = await ctx.receive();
try {

@@ -104,6 +93,4 @@ if (letter.tag === EXIT) {

}
break __loop;
}
await handlers[letter.tag](ctx, letter, letter.data || {});

@@ -118,3 +105,2 @@ } catch (error) {

};
const spawn = function (fn) {

@@ -145,3 +131,2 @@ let addr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;

opts.from = addr;
for (let to of root.FCL_REGISTRY[addr].subs) send(to, tag, data, opts);

@@ -174,3 +159,4 @@ },

return Object.keys(root.FCL_REGISTRY[addr].kvs).reduce((acc, key) => {
return pattern.test(key) ? { ...acc,
return pattern.test(key) ? {
...acc,
[key]: root.FCL_REGISTRY[addr].kvs[key]

@@ -186,3 +172,2 @@ } : acc;

root.FCL_REGISTRY[addr].error = error;
for (let to of root.FCL_REGISTRY[addr].subs) send(to, UPDATED$2);

@@ -197,3 +182,5 @@ }

return addr;
}; // Returns an unsubscribe function
};
// Returns an unsubscribe function
// A SUBSCRIBE handler will need to be created to handle the subscription event

@@ -206,4 +193,2 @@ //

//
function subscriber(address, spawnFn, callback) {

@@ -214,7 +199,5 @@ spawnFn(address);

ctx.send(address, SUBSCRIBE);
while (1) {
const letter = await ctx.receive();
const error = root.FCL_REGISTRY[address].error;
if (letter.tag === EXIT) {

@@ -224,3 +207,2 @@ ctx.send(address, UNSUBSCRIBE);

}
if (error) {

@@ -231,3 +213,2 @@ callback(null, error);

}
callback(letter.data, null);

@@ -237,3 +218,3 @@ }

return () => send(self, EXIT);
} // Returns a promise that returns a result
}

@@ -247,3 +228,2 @@ /**

*/
function invariant$1(fact, msg) {

@@ -253,7 +233,5 @@ if (!fact) {

error.stack = error.stack.split("\n").filter(d => !/at invariant/.test(d)).join("\n");
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
rest[_key - 2] = arguments[_key];
}
console.error("\n\n---\n\n", error, "\n\n", ...rest, "\n\n---\n\n");

@@ -263,3 +241,2 @@ throw error;

}
const pipe$1 = function () {

@@ -269,3 +246,2 @@ for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {

}
return v => {

@@ -277,2 +253,3 @@ return funcs.reduce((res, func) => {

};
/***

@@ -283,4 +260,2 @@ * Merge multiple functions returning objects into one object.

*/
const mergePipe$1 = function () {

@@ -290,6 +265,6 @@ for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {

}
return v => {
return funcs.reduce((res, func) => {
return { ...res,
return {
...res,
...func(v)

@@ -300,2 +275,3 @@ };

};
/**

@@ -306,5 +282,4 @@ * @description Object check

*/
const isObject$1 = value => value && typeof value === "object" && !Array.isArray(value);
const isObject$1 = value => value && typeof value === "object" && !Array.isArray(value);
/**

@@ -316,4 +291,2 @@ * @description Deep merge multiple objects.

*/
const mergeDeep$1 = function (target) {

@@ -323,6 +296,4 @@ for (var _len3 = arguments.length, sources = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {

}
if (!sources.length) return target;
const source = sources.shift();
if (isObject$1(target) && isObject$1(source)) {

@@ -342,5 +313,5 @@ for (const key in source) {

}
return mergeDeep$1(target, ...sources);
};
/**

@@ -351,5 +322,4 @@ * @description Deep merge multiple Flow JSON.

*/
const mergeFlowJSONs$1 = value => Array.isArray(value) ? mergeDeep$1({}, ...value) : value;
const mergeFlowJSONs$1 = value => Array.isArray(value) ? mergeDeep$1({}, ...value) : value;
/**

@@ -360,5 +330,4 @@ * @description Filter out contracts section of flow.json.

*/
const filterContracts$1 = obj => obj.contracts ? obj.contracts : {};
const filterContracts$1 = obj => obj.contracts ? obj.contracts : {};
/**

@@ -369,19 +338,12 @@ * @description Gathers contract addresses by network

*/
const mapContractAliasesToNetworkAddress$1 = network => contracts => {
return Object.entries(contracts).reduce((c, _ref) => {
var _value$aliases;
let [key, value] = _ref;
const networkContractAlias = value === null || value === void 0 ? void 0 : (_value$aliases = value.aliases) === null || _value$aliases === void 0 ? void 0 : _value$aliases[network];
const networkContractAlias = value?.aliases?.[network];
if (networkContractAlias) {
c[key] = networkContractAlias;
}
return c;
}, {});
};
const mapDeploymentsToNetworkAddress$1 = network => _ref2 => {

@@ -392,14 +354,14 @@ let {

} = _ref2;
const networkDeployment = deployments === null || deployments === void 0 ? void 0 : deployments[network];
const networkDeployment = deployments?.[network];
if (!networkDeployment) return {};
return Object.entries(networkDeployment).reduce((c, _ref3) => {
var _accounts$key;
let [key, value] = _ref3;
// Resolve account address
const accountAddress = accounts[key]?.address;
if (!accountAddress) return c;
let [key, value] = _ref3; // Resolve account address
const accountAddress = (_accounts$key = accounts[key]) === null || _accounts$key === void 0 ? void 0 : _accounts$key.address;
if (!accountAddress) return c; // Create an object assigning the address to the contract name.
// Create an object assigning the address to the contract name.
return value.reduce((c, contract) => {
return { ...c,
return {
...c,
[contract]: accountAddress

@@ -410,2 +372,3 @@ };

};
/**

@@ -417,7 +380,6 @@ * @description Take in flow.json files and return contract to address mapping by network

*/
const getContracts$1 = (jsons, network) => {
return pipe$1(mergeFlowJSONs$1, mergePipe$1(mapDeploymentsToNetworkAddress$1(network), pipe$1(filterContracts$1, mapContractAliasesToNetworkAddress$1(network))))(jsons);
};
/**

@@ -428,4 +390,2 @@ * @description Checks if string is hexidecimal

*/
const isHexidecimal$1 = str => {

@@ -436,2 +396,3 @@ // Check that it is a string

};
/**

@@ -442,11 +403,10 @@ * @description Checks flow.json file for private keys

*/
const hasPrivateKeys$1 = flowJSON => {
return Object.entries(flowJSON === null || flowJSON === void 0 ? void 0 : flowJSON.accounts).reduce((hasPrivateKey, _ref4) => {
return Object.entries(flowJSON?.accounts).reduce((hasPrivateKey, _ref4) => {
let [key, value] = _ref4;
if (hasPrivateKey) return true;
return (value === null || value === void 0 ? void 0 : value.hasOwnProperty("key")) && isHexidecimal$1(value === null || value === void 0 ? void 0 : value.key);
return value?.hasOwnProperty("key") && isHexidecimal$1(value?.key);
}, false);
};
/**

@@ -457,4 +417,2 @@ * @description Take in flow.json or array of flow.json files and checks for private keys

*/
const anyHasPrivateKeys$1 = value => {

@@ -464,2 +422,3 @@ if (isObject$1(value)) return hasPrivateKeys$1(value);

};
/**

@@ -470,6 +429,3 @@ * @description Format network to always be 'emulator', 'testnet', or 'mainnet'

*/
const cleanNetwork$1 = network => (network === null || network === void 0 ? void 0 : network.toLowerCase()) === "local" ? "emulator" : network === null || network === void 0 ? void 0 : network.toLowerCase();
const cleanNetwork$1 = network => network?.toLowerCase() === "local" ? "emulator" : network?.toLowerCase();
const NAME$1 = "config";

@@ -484,5 +440,3 @@ const PUT$1 = "PUT_CONFIG";

const UPDATED$1 = "CONFIG/UPDATED";
const identity$1 = v => v;
const HANDLERS$1 = {

@@ -496,3 +450,4 @@ [PUT$1]: (ctx, _letter, _ref) => {

ctx.put(key, value);
ctx.broadcast(UPDATED$1, { ...ctx.all()
ctx.broadcast(UPDATED$1, {
...ctx.all()
});

@@ -509,3 +464,4 @@ },

[GET_ALL$1]: (ctx, letter) => {
letter.reply({ ...ctx.all()
letter.reply({
...ctx.all()
});

@@ -520,3 +476,4 @@ },

ctx.update(key, fn || identity$1);
ctx.broadcast(UPDATED$1, { ...ctx.all()
ctx.broadcast(UPDATED$1, {
...ctx.all()
});

@@ -530,3 +487,4 @@ },

ctx.delete(key);
ctx.broadcast(UPDATED$1, { ...ctx.all()
ctx.broadcast(UPDATED$1, {
...ctx.all()
});

@@ -536,6 +494,5 @@ },

let keys = Object.keys(ctx.all());
for (let key of keys) ctx.delete(key);
ctx.broadcast(UPDATED$1, { ...ctx.all()
ctx.broadcast(UPDATED$1, {
...ctx.all()
});

@@ -552,3 +509,4 @@ },

ctx.subscribe(letter.from);
ctx.send(letter.from, UPDATED$1, { ...ctx.all()
ctx.send(letter.from, UPDATED$1, {
...ctx.all()
});

@@ -561,2 +519,3 @@ },

spawn(HANDLERS$1, NAME$1);
/**

@@ -568,3 +527,2 @@ * @description Adds a key-value pair to the config

*/
function put$1(key, value) {

@@ -577,2 +535,3 @@ send(NAME$1, PUT$1, {

}
/**

@@ -584,4 +543,2 @@ * @description Gets a key-value pair with a fallback from the config

*/
function get$1(key, fallback) {

@@ -596,2 +553,3 @@ return send(NAME$1, GET$1, {

}
/**

@@ -603,4 +561,2 @@ * @description Returns the first non null config value or the fallback

*/
async function first$1() {

@@ -615,2 +571,3 @@ let wants = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];

}
/**

@@ -620,4 +577,2 @@ * @description Returns the current config

*/
function all$1() {

@@ -629,2 +584,3 @@ return send(NAME$1, GET_ALL$1, null, {

}
/**

@@ -636,4 +592,2 @@ * @description Updates a key-value pair in the config

*/
function update$1(key) {

@@ -647,2 +601,3 @@ let fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity$1;

}
/**

@@ -653,4 +608,2 @@ * @description Deletes a key-value pair from the config

*/
function _delete$1(key) {

@@ -662,2 +615,3 @@ send(NAME$1, DELETE$1, {

}
/**

@@ -668,4 +622,2 @@ * @description Returns a subset of the config based on a pattern

*/
function where$1(pattern) {

@@ -679,2 +631,3 @@ return send(NAME$1, WHERE$1, {

}
/**

@@ -685,7 +638,6 @@ * @description Subscribes to config updates

*/
function subscribe$1(callback) {
return subscriber(NAME$1, () => spawn(HANDLERS$1, NAME$1), callback);
}
/**

@@ -695,7 +647,6 @@ * @description Clears the config

*/
function clearConfig$1() {
return send(NAME$1, CLEAR$1);
}
/**

@@ -706,7 +657,6 @@ * @description Resets the config to a previous state

*/
function resetConfig$1(oldConfig) {
return clearConfig$1().then(config$1(oldConfig));
}
/**

@@ -717,4 +667,2 @@ * @description Takes in flow.json or array of flow.json files and creates contract placeholders

*/
async function load$1(data) {

@@ -728,3 +676,2 @@ const network = await get$1("flow.network");

invariant$1(cleanedNetwork, `Flow Network Required -- In order for FCL to load your contracts please define "flow.network" to "emulator", "local", "testnet", or "mainnet" in your config. See more here: https://developers.flow.com/tools/fcl-js/reference/configure-fcl`);
if (anyHasPrivateKeys$1(flowJSON)) {

@@ -739,7 +686,5 @@ const isEmulator = cleanedNetwork === "emulator";

}
for (const [key, value] of Object.entries(getContracts$1(flowJSON, cleanedNetwork))) {
const contractConfigKey = `0x${key}`;
const existingContractConfigKey = await get$1(contractConfigKey);
if (existingContractConfigKey && existingContractConfigKey !== value) {

@@ -754,6 +699,4 @@ log$1({

}
const systemContractConfigKey = `system.contracts.${key}`;
const systemExistingContractConfigKeyValue = await get$1(systemContractConfigKey);
if (systemExistingContractConfigKeyValue && systemExistingContractConfigKeyValue !== value) {

@@ -769,4 +712,5 @@ log$1({

}
} // eslint-disable-next-line jsdoc/require-returns
}
// eslint-disable-next-line jsdoc/require-returns
/**

@@ -776,4 +720,2 @@ * @description Sets the config

*/
function config$1(values) {

@@ -783,3 +725,2 @@ if (values != null && typeof values === "object") {

}
return {

@@ -798,3 +739,2 @@ put: put$1,

}
config$1.put = put$1;

@@ -810,5 +750,3 @@ config$1.get = get$1;

config$1.load = load$1;
const noop$1 = v => v;
function overload$1() {

@@ -819,3 +757,2 @@ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

const oldConfig = await all$1();
try {

@@ -832,2 +769,3 @@ config$1(opts);

}
/**

@@ -844,4 +782,2 @@ * The levels of the logger

*/
const LEVELS$1 = Object.freeze({

@@ -854,2 +790,3 @@ debug: 5,

});
/**

@@ -866,3 +803,2 @@ * Builds a message formatted for the logger

*/
const buildLoggerMessageArgs$1 = _ref => {

@@ -882,2 +818,3 @@ let {

};
/**

@@ -897,4 +834,2 @@ * Logs messages based on the level of the message and the level set in the config

*/
const log$1 = async _ref2 => {

@@ -907,4 +842,5 @@ let {

} = _ref2;
const configLoggerLevel = await config$1.get("logger.level", LEVELS$1.warn); // If config level is below message level then don't show it
const configLoggerLevel = await config$1.get("logger.level", LEVELS$1.warn);
// If config level is below message level then don't show it
if (!always && configLoggerLevel < level) return;

@@ -915,3 +851,2 @@ const loggerMessageArgs = buildLoggerMessageArgs$1({

});
switch (level) {

@@ -921,15 +856,11 @@ case LEVELS$1.debug:

break;
case LEVELS$1.info:
console.info(...loggerMessageArgs);
break;
case LEVELS$1.warn:
console.warn(...loggerMessageArgs);
break;
case LEVELS$1.error:
console.error(...loggerMessageArgs);
break;
default:

@@ -939,2 +870,3 @@ console.log(...loggerMessageArgs);

};
/**

@@ -956,4 +888,2 @@ * Logs a deprecation notice

*/
log$1.deprecate = _ref3 => {

@@ -968,7 +898,5 @@ let {

} = _ref3;
const capitalizeFirstLetter = string => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
const logMessage = () => log$1({

@@ -981,3 +909,2 @@ title: `${pkg ? pkg + " " : ""}Deprecation Notice`,

});
if (typeof callback === "function") {

@@ -989,5 +916,5 @@ return async function () {

}
return logMessage();
};
/**

@@ -1000,4 +927,2 @@ * Asserts fact is true, otherwise throw an error with invariant message

*/
function invariant(fact, msg) {

@@ -1007,7 +932,5 @@ if (!fact) {

error.stack = error.stack.split("\n").filter(d => !/at invariant/.test(d)).join("\n");
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
rest[_key - 2] = arguments[_key];
}
console.error("\n\n---\n\n", error, "\n\n", ...rest, "\n\n---\n\n");

@@ -1017,3 +940,2 @@ throw error;

}
const pipe = function () {

@@ -1023,3 +945,2 @@ for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {

}
return v => {

@@ -1031,2 +952,3 @@ return funcs.reduce((res, func) => {

};
/***

@@ -1037,4 +959,2 @@ * Merge multiple functions returning objects into one object.

*/
const mergePipe = function () {

@@ -1044,6 +964,6 @@ for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {

}
return v => {
return funcs.reduce((res, func) => {
return { ...res,
return {
...res,
...func(v)

@@ -1054,2 +974,3 @@ };

};
/**

@@ -1060,5 +981,4 @@ * @description Object check

*/
const isObject = value => value && typeof value === "object" && !Array.isArray(value);
const isObject = value => value && typeof value === "object" && !Array.isArray(value);
/**

@@ -1070,4 +990,2 @@ * @description Deep merge multiple objects.

*/
const mergeDeep = function (target) {

@@ -1077,6 +995,4 @@ for (var _len3 = arguments.length, sources = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {

}
if (!sources.length) return target;
const source = sources.shift();
if (isObject(target) && isObject(source)) {

@@ -1096,5 +1012,5 @@ for (const key in source) {

}
return mergeDeep(target, ...sources);
};
/**

@@ -1105,5 +1021,4 @@ * @description Deep merge multiple Flow JSON.

*/
const mergeFlowJSONs = value => Array.isArray(value) ? mergeDeep({}, ...value) : value;
const mergeFlowJSONs = value => Array.isArray(value) ? mergeDeep({}, ...value) : value;
/**

@@ -1114,5 +1029,4 @@ * @description Filter out contracts section of flow.json.

*/
const filterContracts = obj => obj.contracts ? obj.contracts : {};
const filterContracts = obj => obj.contracts ? obj.contracts : {};
/**

@@ -1123,19 +1037,12 @@ * @description Gathers contract addresses by network

*/
const mapContractAliasesToNetworkAddress = network => contracts => {
return Object.entries(contracts).reduce((c, _ref) => {
var _value$aliases;
let [key, value] = _ref;
const networkContractAlias = value === null || value === void 0 ? void 0 : (_value$aliases = value.aliases) === null || _value$aliases === void 0 ? void 0 : _value$aliases[network];
const networkContractAlias = value?.aliases?.[network];
if (networkContractAlias) {
c[key] = networkContractAlias;
}
return c;
}, {});
};
const mapDeploymentsToNetworkAddress = network => _ref2 => {

@@ -1146,14 +1053,14 @@ let {

} = _ref2;
const networkDeployment = deployments === null || deployments === void 0 ? void 0 : deployments[network];
const networkDeployment = deployments?.[network];
if (!networkDeployment) return {};
return Object.entries(networkDeployment).reduce((c, _ref3) => {
var _accounts$key;
let [key, value] = _ref3;
// Resolve account address
const accountAddress = accounts[key]?.address;
if (!accountAddress) return c;
let [key, value] = _ref3; // Resolve account address
const accountAddress = (_accounts$key = accounts[key]) === null || _accounts$key === void 0 ? void 0 : _accounts$key.address;
if (!accountAddress) return c; // Create an object assigning the address to the contract name.
// Create an object assigning the address to the contract name.
return value.reduce((c, contract) => {
return { ...c,
return {
...c,
[contract]: accountAddress

@@ -1164,2 +1071,3 @@ };

};
/**

@@ -1171,7 +1079,6 @@ * @description Take in flow.json files and return contract to address mapping by network

*/
const getContracts = (jsons, network) => {
return pipe(mergeFlowJSONs, mergePipe(mapDeploymentsToNetworkAddress(network), pipe(filterContracts, mapContractAliasesToNetworkAddress(network))))(jsons);
};
/**

@@ -1182,4 +1089,2 @@ * @description Checks if string is hexidecimal

*/
const isHexidecimal = str => {

@@ -1190,2 +1095,3 @@ // Check that it is a string

};
/**

@@ -1196,11 +1102,10 @@ * @description Checks flow.json file for private keys

*/
const hasPrivateKeys = flowJSON => {
return Object.entries(flowJSON === null || flowJSON === void 0 ? void 0 : flowJSON.accounts).reduce((hasPrivateKey, _ref4) => {
return Object.entries(flowJSON?.accounts).reduce((hasPrivateKey, _ref4) => {
let [key, value] = _ref4;
if (hasPrivateKey) return true;
return (value === null || value === void 0 ? void 0 : value.hasOwnProperty("key")) && isHexidecimal(value === null || value === void 0 ? void 0 : value.key);
return value?.hasOwnProperty("key") && isHexidecimal(value?.key);
}, false);
};
/**

@@ -1211,4 +1116,2 @@ * @description Take in flow.json or array of flow.json files and checks for private keys

*/
const anyHasPrivateKeys = value => {

@@ -1218,2 +1121,3 @@ if (isObject(value)) return hasPrivateKeys(value);

};
/**

@@ -1224,6 +1128,3 @@ * @description Format network to always be 'emulator', 'testnet', or 'mainnet'

*/
const cleanNetwork = network => (network === null || network === void 0 ? void 0 : network.toLowerCase()) === "local" ? "emulator" : network === null || network === void 0 ? void 0 : network.toLowerCase();
const cleanNetwork = network => network?.toLowerCase() === "local" ? "emulator" : network?.toLowerCase();
const NAME = "config";

@@ -1238,5 +1139,3 @@ const PUT = "PUT_CONFIG";

const UPDATED = "CONFIG/UPDATED";
const identity = v => v;
const HANDLERS = {

@@ -1250,3 +1149,4 @@ [PUT]: (ctx, _letter, _ref) => {

ctx.put(key, value);
ctx.broadcast(UPDATED, { ...ctx.all()
ctx.broadcast(UPDATED, {
...ctx.all()
});

@@ -1263,3 +1163,4 @@ },

[GET_ALL]: (ctx, letter) => {
letter.reply({ ...ctx.all()
letter.reply({
...ctx.all()
});

@@ -1274,3 +1175,4 @@ },

ctx.update(key, fn || identity);
ctx.broadcast(UPDATED, { ...ctx.all()
ctx.broadcast(UPDATED, {
...ctx.all()
});

@@ -1284,3 +1186,4 @@ },

ctx.delete(key);
ctx.broadcast(UPDATED, { ...ctx.all()
ctx.broadcast(UPDATED, {
...ctx.all()
});

@@ -1290,6 +1193,5 @@ },

let keys = Object.keys(ctx.all());
for (let key of keys) ctx.delete(key);
ctx.broadcast(UPDATED, { ...ctx.all()
ctx.broadcast(UPDATED, {
...ctx.all()
});

@@ -1306,3 +1208,4 @@ },

ctx.subscribe(letter.from);
ctx.send(letter.from, UPDATED, { ...ctx.all()
ctx.send(letter.from, UPDATED, {
...ctx.all()
});

@@ -1315,2 +1218,3 @@ },

spawn(HANDLERS, NAME);
/**

@@ -1322,3 +1226,2 @@ * @description Adds a key-value pair to the config

*/
function put(key, value) {

@@ -1331,2 +1234,3 @@ send(NAME, PUT, {

}
/**

@@ -1338,4 +1242,2 @@ * @description Gets a key-value pair with a fallback from the config

*/
function get(key, fallback) {

@@ -1350,2 +1252,3 @@ return send(NAME, GET, {

}
/**

@@ -1357,4 +1260,2 @@ * @description Returns the first non null config value or the fallback

*/
async function first() {

@@ -1369,2 +1270,3 @@ let wants = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];

}
/**

@@ -1374,4 +1276,2 @@ * @description Returns the current config

*/
function all() {

@@ -1383,2 +1283,3 @@ return send(NAME, GET_ALL, null, {

}
/**

@@ -1390,4 +1291,2 @@ * @description Updates a key-value pair in the config

*/
function update(key) {

@@ -1401,2 +1300,3 @@ let fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity;

}
/**

@@ -1407,4 +1307,2 @@ * @description Deletes a key-value pair from the config

*/
function _delete(key) {

@@ -1416,2 +1314,3 @@ send(NAME, DELETE, {

}
/**

@@ -1422,4 +1321,2 @@ * @description Returns a subset of the config based on a pattern

*/
function where(pattern) {

@@ -1433,2 +1330,3 @@ return send(NAME, WHERE, {

}
/**

@@ -1439,7 +1337,6 @@ * @description Subscribes to config updates

*/
function subscribe(callback) {
return subscriber(NAME, () => spawn(HANDLERS, NAME), callback);
}
/**

@@ -1449,7 +1346,6 @@ * @description Clears the config

*/
function clearConfig() {
return send(NAME, CLEAR);
}
/**

@@ -1460,7 +1356,6 @@ * @description Resets the config to a previous state

*/
function resetConfig(oldConfig) {
return clearConfig().then(config(oldConfig));
}
/**

@@ -1471,4 +1366,2 @@ * @description Takes in flow.json or array of flow.json files and creates contract placeholders

*/
async function load(data) {

@@ -1482,3 +1375,2 @@ const network = await get("flow.network");

invariant(cleanedNetwork, `Flow Network Required -- In order for FCL to load your contracts please define "flow.network" to "emulator", "local", "testnet", or "mainnet" in your config. See more here: https://developers.flow.com/tools/fcl-js/reference/configure-fcl`);
if (anyHasPrivateKeys(flowJSON)) {

@@ -1493,7 +1385,5 @@ const isEmulator = cleanedNetwork === "emulator";

}
for (const [key, value] of Object.entries(getContracts(flowJSON, cleanedNetwork))) {
const contractConfigKey = `0x${key}`;
const existingContractConfigKey = await get(contractConfigKey);
if (existingContractConfigKey && existingContractConfigKey !== value) {

@@ -1508,6 +1398,4 @@ log$1({

}
const systemContractConfigKey = `system.contracts.${key}`;
const systemExistingContractConfigKeyValue = await get(systemContractConfigKey);
if (systemExistingContractConfigKeyValue && systemExistingContractConfigKeyValue !== value) {

@@ -1523,4 +1411,5 @@ log$1({

}
} // eslint-disable-next-line jsdoc/require-returns
}
// eslint-disable-next-line jsdoc/require-returns
/**

@@ -1530,4 +1419,2 @@ * @description Sets the config

*/
function config(values) {

@@ -1537,3 +1424,2 @@ if (values != null && typeof values === "object") {

}
return {

@@ -1552,3 +1438,2 @@ put,

}
config.put = put;

@@ -1564,5 +1449,3 @@ config.get = get;

config.load = load;
const noop = v => v;
function overload() {

@@ -1573,3 +1456,2 @@ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

const oldConfig = await all();
try {

@@ -1598,3 +1480,2 @@ config(opts);

*/
const LEVELS = Object.freeze({

@@ -1607,2 +1488,3 @@ debug: 5,

});
/**

@@ -1619,3 +1501,2 @@ * Builds a message formatted for the logger

*/
const buildLoggerMessageArgs = _ref => {

@@ -1635,2 +1516,3 @@ let {

};
/**

@@ -1650,4 +1532,2 @@ * Logs messages based on the level of the message and the level set in the config

*/
const log = async _ref2 => {

@@ -1660,4 +1540,5 @@ let {

} = _ref2;
const configLoggerLevel = await config.get("logger.level", LEVELS.warn); // If config level is below message level then don't show it
const configLoggerLevel = await config.get("logger.level", LEVELS.warn);
// If config level is below message level then don't show it
if (!always && configLoggerLevel < level) return;

@@ -1668,3 +1549,2 @@ const loggerMessageArgs = buildLoggerMessageArgs({

});
switch (level) {

@@ -1674,15 +1554,11 @@ case LEVELS.debug:

break;
case LEVELS.info:
console.info(...loggerMessageArgs);
break;
case LEVELS.warn:
console.warn(...loggerMessageArgs);
break;
case LEVELS.error:
console.error(...loggerMessageArgs);
break;
default:

@@ -1692,2 +1568,3 @@ console.log(...loggerMessageArgs);

};
/**

@@ -1709,4 +1586,2 @@ * Logs a deprecation notice

*/
log.deprecate = _ref3 => {

@@ -1721,7 +1596,5 @@ let {

} = _ref3;
const capitalizeFirstLetter = string => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
const logMessage = () => log({

@@ -1734,3 +1607,2 @@ title: `${pkg ? pkg + " " : ""}Deprecation Notice`,

});
if (typeof callback === "function") {

@@ -1742,3 +1614,2 @@ return async function () {

}
return logMessage();

@@ -1760,3 +1631,2 @@ };

}
function recApply(d) {

@@ -1772,6 +1642,6 @@ return function (arg1) {

}
return String(arg1);
};
}
/**

@@ -1782,4 +1652,2 @@ * @param {(string|Array.<*>)} head

*/
function template(head) {

@@ -1789,9 +1657,6 @@ for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

}
if (typeof head === "string") return () => head;
if (Array.isArray(head)) {
return d => interleave(head, rest.map(recApply(d))).join("").trim();
}
return head;

@@ -1798,0 +1663,0 @@ }

@@ -5,3 +5,4 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

let promise;
var queueMicrotask_1 = typeof queueMicrotask === 'function' ? queueMicrotask.bind(typeof window !== 'undefined' ? window : commonjsGlobal) // reuse resolved promise, and allocate it lazily
var queueMicrotask_1 = typeof queueMicrotask === 'function' ? queueMicrotask.bind(typeof window !== 'undefined' ? window : commonjsGlobal)
// reuse resolved promise, and allocate it lazily
: cb => (promise || (promise = Promise.resolve())).then(cb).catch(err => setTimeout(() => {

@@ -17,3 +18,2 @@ throw err;

queue.push(msg);
if (next) {

@@ -24,3 +24,2 @@ next(queue.shift());

},
receive() {

@@ -33,6 +32,4 @@ return new Promise(function innerReceive(resolve) {

}
};
};
const INIT = "INIT";

@@ -48,3 +45,2 @@ const SUBSCRIBE = "SUBSCRIBE";

const DEFAULT_TIMEOUT = 5000;
const send = function (addr, tag, data) {

@@ -55,7 +51,5 @@ let opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};

const timeout = opts.timeout != null ? opts.timeout : DEFAULT_TIMEOUT;
if (expectReply && timeout) {
setTimeout(() => reject(new Error(`Timeout: ${timeout}ms passed without a response.`)), timeout);
}
const payload = {

@@ -70,3 +64,2 @@ to: addr,

};
try {

@@ -80,7 +73,5 @@ root.FCL_REGISTRY[addr] && root.FCL_REGISTRY[addr].mailbox.deliver(payload);

};
const kill = addr => {
delete root.FCL_REGISTRY[addr];
};
const fromHandlers = function () {

@@ -90,6 +81,4 @@ let handlers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

if (typeof handlers[INIT] === "function") await handlers[INIT](ctx);
__loop: while (1) {
const letter = await ctx.receive();
try {

@@ -100,6 +89,4 @@ if (letter.tag === EXIT) {

}
break __loop;
}
await handlers[letter.tag](ctx, letter, letter.data || {});

@@ -114,3 +101,2 @@ } catch (error) {

};
const spawn = function (fn) {

@@ -141,3 +127,2 @@ let addr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;

opts.from = addr;
for (let to of root.FCL_REGISTRY[addr].subs) send(to, tag, data, opts);

@@ -170,3 +155,4 @@ },

return Object.keys(root.FCL_REGISTRY[addr].kvs).reduce((acc, key) => {
return pattern.test(key) ? { ...acc,
return pattern.test(key) ? {
...acc,
[key]: root.FCL_REGISTRY[addr].kvs[key]

@@ -182,3 +168,2 @@ } : acc;

root.FCL_REGISTRY[addr].error = error;
for (let to of root.FCL_REGISTRY[addr].subs) send(to, UPDATED$2);

@@ -193,3 +178,5 @@ }

return addr;
}; // Returns an unsubscribe function
};
// Returns an unsubscribe function
// A SUBSCRIBE handler will need to be created to handle the subscription event

@@ -202,4 +189,2 @@ //

//
function subscriber(address, spawnFn, callback) {

@@ -210,7 +195,5 @@ spawnFn(address);

ctx.send(address, SUBSCRIBE);
while (1) {
const letter = await ctx.receive();
const error = root.FCL_REGISTRY[address].error;
if (letter.tag === EXIT) {

@@ -220,3 +203,2 @@ ctx.send(address, UNSUBSCRIBE);

}
if (error) {

@@ -227,3 +209,2 @@ callback(null, error);

}
callback(letter.data, null);

@@ -233,3 +214,3 @@ }

return () => send(self, EXIT);
} // Returns a promise that returns a result
}

@@ -243,3 +224,2 @@ /**

*/
function invariant$1(fact, msg) {

@@ -249,7 +229,5 @@ if (!fact) {

error.stack = error.stack.split("\n").filter(d => !/at invariant/.test(d)).join("\n");
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
rest[_key - 2] = arguments[_key];
}
console.error("\n\n---\n\n", error, "\n\n", ...rest, "\n\n---\n\n");

@@ -259,3 +237,2 @@ throw error;

}
const pipe$1 = function () {

@@ -265,3 +242,2 @@ for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {

}
return v => {

@@ -273,2 +249,3 @@ return funcs.reduce((res, func) => {

};
/***

@@ -279,4 +256,2 @@ * Merge multiple functions returning objects into one object.

*/
const mergePipe$1 = function () {

@@ -286,6 +261,6 @@ for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {

}
return v => {
return funcs.reduce((res, func) => {
return { ...res,
return {
...res,
...func(v)

@@ -296,2 +271,3 @@ };

};
/**

@@ -302,5 +278,4 @@ * @description Object check

*/
const isObject$1 = value => value && typeof value === "object" && !Array.isArray(value);
const isObject$1 = value => value && typeof value === "object" && !Array.isArray(value);
/**

@@ -312,4 +287,2 @@ * @description Deep merge multiple objects.

*/
const mergeDeep$1 = function (target) {

@@ -319,6 +292,4 @@ for (var _len3 = arguments.length, sources = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {

}
if (!sources.length) return target;
const source = sources.shift();
if (isObject$1(target) && isObject$1(source)) {

@@ -338,5 +309,5 @@ for (const key in source) {

}
return mergeDeep$1(target, ...sources);
};
/**

@@ -347,5 +318,4 @@ * @description Deep merge multiple Flow JSON.

*/
const mergeFlowJSONs$1 = value => Array.isArray(value) ? mergeDeep$1({}, ...value) : value;
const mergeFlowJSONs$1 = value => Array.isArray(value) ? mergeDeep$1({}, ...value) : value;
/**

@@ -356,5 +326,4 @@ * @description Filter out contracts section of flow.json.

*/
const filterContracts$1 = obj => obj.contracts ? obj.contracts : {};
const filterContracts$1 = obj => obj.contracts ? obj.contracts : {};
/**

@@ -365,19 +334,12 @@ * @description Gathers contract addresses by network

*/
const mapContractAliasesToNetworkAddress$1 = network => contracts => {
return Object.entries(contracts).reduce((c, _ref) => {
var _value$aliases;
let [key, value] = _ref;
const networkContractAlias = value === null || value === void 0 ? void 0 : (_value$aliases = value.aliases) === null || _value$aliases === void 0 ? void 0 : _value$aliases[network];
const networkContractAlias = value?.aliases?.[network];
if (networkContractAlias) {
c[key] = networkContractAlias;
}
return c;
}, {});
};
const mapDeploymentsToNetworkAddress$1 = network => _ref2 => {

@@ -388,14 +350,14 @@ let {

} = _ref2;
const networkDeployment = deployments === null || deployments === void 0 ? void 0 : deployments[network];
const networkDeployment = deployments?.[network];
if (!networkDeployment) return {};
return Object.entries(networkDeployment).reduce((c, _ref3) => {
var _accounts$key;
let [key, value] = _ref3;
// Resolve account address
const accountAddress = accounts[key]?.address;
if (!accountAddress) return c;
let [key, value] = _ref3; // Resolve account address
const accountAddress = (_accounts$key = accounts[key]) === null || _accounts$key === void 0 ? void 0 : _accounts$key.address;
if (!accountAddress) return c; // Create an object assigning the address to the contract name.
// Create an object assigning the address to the contract name.
return value.reduce((c, contract) => {
return { ...c,
return {
...c,
[contract]: accountAddress

@@ -406,2 +368,3 @@ };

};
/**

@@ -413,7 +376,6 @@ * @description Take in flow.json files and return contract to address mapping by network

*/
const getContracts$1 = (jsons, network) => {
return pipe$1(mergeFlowJSONs$1, mergePipe$1(mapDeploymentsToNetworkAddress$1(network), pipe$1(filterContracts$1, mapContractAliasesToNetworkAddress$1(network))))(jsons);
};
/**

@@ -424,4 +386,2 @@ * @description Checks if string is hexidecimal

*/
const isHexidecimal$1 = str => {

@@ -432,2 +392,3 @@ // Check that it is a string

};
/**

@@ -438,11 +399,10 @@ * @description Checks flow.json file for private keys

*/
const hasPrivateKeys$1 = flowJSON => {
return Object.entries(flowJSON === null || flowJSON === void 0 ? void 0 : flowJSON.accounts).reduce((hasPrivateKey, _ref4) => {
return Object.entries(flowJSON?.accounts).reduce((hasPrivateKey, _ref4) => {
let [key, value] = _ref4;
if (hasPrivateKey) return true;
return (value === null || value === void 0 ? void 0 : value.hasOwnProperty("key")) && isHexidecimal$1(value === null || value === void 0 ? void 0 : value.key);
return value?.hasOwnProperty("key") && isHexidecimal$1(value?.key);
}, false);
};
/**

@@ -453,4 +413,2 @@ * @description Take in flow.json or array of flow.json files and checks for private keys

*/
const anyHasPrivateKeys$1 = value => {

@@ -460,2 +418,3 @@ if (isObject$1(value)) return hasPrivateKeys$1(value);

};
/**

@@ -466,6 +425,3 @@ * @description Format network to always be 'emulator', 'testnet', or 'mainnet'

*/
const cleanNetwork$1 = network => (network === null || network === void 0 ? void 0 : network.toLowerCase()) === "local" ? "emulator" : network === null || network === void 0 ? void 0 : network.toLowerCase();
const cleanNetwork$1 = network => network?.toLowerCase() === "local" ? "emulator" : network?.toLowerCase();
const NAME$1 = "config";

@@ -480,5 +436,3 @@ const PUT$1 = "PUT_CONFIG";

const UPDATED$1 = "CONFIG/UPDATED";
const identity$1 = v => v;
const HANDLERS$1 = {

@@ -492,3 +446,4 @@ [PUT$1]: (ctx, _letter, _ref) => {

ctx.put(key, value);
ctx.broadcast(UPDATED$1, { ...ctx.all()
ctx.broadcast(UPDATED$1, {
...ctx.all()
});

@@ -505,3 +460,4 @@ },

[GET_ALL$1]: (ctx, letter) => {
letter.reply({ ...ctx.all()
letter.reply({
...ctx.all()
});

@@ -516,3 +472,4 @@ },

ctx.update(key, fn || identity$1);
ctx.broadcast(UPDATED$1, { ...ctx.all()
ctx.broadcast(UPDATED$1, {
...ctx.all()
});

@@ -526,3 +483,4 @@ },

ctx.delete(key);
ctx.broadcast(UPDATED$1, { ...ctx.all()
ctx.broadcast(UPDATED$1, {
...ctx.all()
});

@@ -532,6 +490,5 @@ },

let keys = Object.keys(ctx.all());
for (let key of keys) ctx.delete(key);
ctx.broadcast(UPDATED$1, { ...ctx.all()
ctx.broadcast(UPDATED$1, {
...ctx.all()
});

@@ -548,3 +505,4 @@ },

ctx.subscribe(letter.from);
ctx.send(letter.from, UPDATED$1, { ...ctx.all()
ctx.send(letter.from, UPDATED$1, {
...ctx.all()
});

@@ -557,2 +515,3 @@ },

spawn(HANDLERS$1, NAME$1);
/**

@@ -564,3 +523,2 @@ * @description Adds a key-value pair to the config

*/
function put$1(key, value) {

@@ -573,2 +531,3 @@ send(NAME$1, PUT$1, {

}
/**

@@ -580,4 +539,2 @@ * @description Gets a key-value pair with a fallback from the config

*/
function get$1(key, fallback) {

@@ -592,2 +549,3 @@ return send(NAME$1, GET$1, {

}
/**

@@ -599,4 +557,2 @@ * @description Returns the first non null config value or the fallback

*/
async function first$1() {

@@ -611,2 +567,3 @@ let wants = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];

}
/**

@@ -616,4 +573,2 @@ * @description Returns the current config

*/
function all$1() {

@@ -625,2 +580,3 @@ return send(NAME$1, GET_ALL$1, null, {

}
/**

@@ -632,4 +588,2 @@ * @description Updates a key-value pair in the config

*/
function update$1(key) {

@@ -643,2 +597,3 @@ let fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity$1;

}
/**

@@ -649,4 +604,2 @@ * @description Deletes a key-value pair from the config

*/
function _delete$1(key) {

@@ -658,2 +611,3 @@ send(NAME$1, DELETE$1, {

}
/**

@@ -664,4 +618,2 @@ * @description Returns a subset of the config based on a pattern

*/
function where$1(pattern) {

@@ -675,2 +627,3 @@ return send(NAME$1, WHERE$1, {

}
/**

@@ -681,7 +634,6 @@ * @description Subscribes to config updates

*/
function subscribe$1(callback) {
return subscriber(NAME$1, () => spawn(HANDLERS$1, NAME$1), callback);
}
/**

@@ -691,7 +643,6 @@ * @description Clears the config

*/
function clearConfig$1() {
return send(NAME$1, CLEAR$1);
}
/**

@@ -702,7 +653,6 @@ * @description Resets the config to a previous state

*/
function resetConfig$1(oldConfig) {
return clearConfig$1().then(config$1(oldConfig));
}
/**

@@ -713,4 +663,2 @@ * @description Takes in flow.json or array of flow.json files and creates contract placeholders

*/
async function load$1(data) {

@@ -724,3 +672,2 @@ const network = await get$1("flow.network");

invariant$1(cleanedNetwork, `Flow Network Required -- In order for FCL to load your contracts please define "flow.network" to "emulator", "local", "testnet", or "mainnet" in your config. See more here: https://developers.flow.com/tools/fcl-js/reference/configure-fcl`);
if (anyHasPrivateKeys$1(flowJSON)) {

@@ -735,7 +682,5 @@ const isEmulator = cleanedNetwork === "emulator";

}
for (const [key, value] of Object.entries(getContracts$1(flowJSON, cleanedNetwork))) {
const contractConfigKey = `0x${key}`;
const existingContractConfigKey = await get$1(contractConfigKey);
if (existingContractConfigKey && existingContractConfigKey !== value) {

@@ -750,6 +695,4 @@ log$1({

}
const systemContractConfigKey = `system.contracts.${key}`;
const systemExistingContractConfigKeyValue = await get$1(systemContractConfigKey);
if (systemExistingContractConfigKeyValue && systemExistingContractConfigKeyValue !== value) {

@@ -765,4 +708,5 @@ log$1({

}
} // eslint-disable-next-line jsdoc/require-returns
}
// eslint-disable-next-line jsdoc/require-returns
/**

@@ -772,4 +716,2 @@ * @description Sets the config

*/
function config$1(values) {

@@ -779,3 +721,2 @@ if (values != null && typeof values === "object") {

}
return {

@@ -794,3 +735,2 @@ put: put$1,

}
config$1.put = put$1;

@@ -806,5 +746,3 @@ config$1.get = get$1;

config$1.load = load$1;
const noop$1 = v => v;
function overload$1() {

@@ -815,3 +753,2 @@ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

const oldConfig = await all$1();
try {

@@ -828,2 +765,3 @@ config$1(opts);

}
/**

@@ -840,4 +778,2 @@ * The levels of the logger

*/
const LEVELS$1 = Object.freeze({

@@ -850,2 +786,3 @@ debug: 5,

});
/**

@@ -862,3 +799,2 @@ * Builds a message formatted for the logger

*/
const buildLoggerMessageArgs$1 = _ref => {

@@ -878,2 +814,3 @@ let {

};
/**

@@ -893,4 +830,2 @@ * Logs messages based on the level of the message and the level set in the config

*/
const log$1 = async _ref2 => {

@@ -903,4 +838,5 @@ let {

} = _ref2;
const configLoggerLevel = await config$1.get("logger.level", LEVELS$1.warn); // If config level is below message level then don't show it
const configLoggerLevel = await config$1.get("logger.level", LEVELS$1.warn);
// If config level is below message level then don't show it
if (!always && configLoggerLevel < level) return;

@@ -911,3 +847,2 @@ const loggerMessageArgs = buildLoggerMessageArgs$1({

});
switch (level) {

@@ -917,15 +852,11 @@ case LEVELS$1.debug:

break;
case LEVELS$1.info:
console.info(...loggerMessageArgs);
break;
case LEVELS$1.warn:
console.warn(...loggerMessageArgs);
break;
case LEVELS$1.error:
console.error(...loggerMessageArgs);
break;
default:

@@ -935,2 +866,3 @@ console.log(...loggerMessageArgs);

};
/**

@@ -952,4 +884,2 @@ * Logs a deprecation notice

*/
log$1.deprecate = _ref3 => {

@@ -964,7 +894,5 @@ let {

} = _ref3;
const capitalizeFirstLetter = string => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
const logMessage = () => log$1({

@@ -977,3 +905,2 @@ title: `${pkg ? pkg + " " : ""}Deprecation Notice`,

});
if (typeof callback === "function") {

@@ -985,5 +912,5 @@ return async function () {

}
return logMessage();
};
/**

@@ -996,4 +923,2 @@ * Asserts fact is true, otherwise throw an error with invariant message

*/
function invariant(fact, msg) {

@@ -1003,7 +928,5 @@ if (!fact) {

error.stack = error.stack.split("\n").filter(d => !/at invariant/.test(d)).join("\n");
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
rest[_key - 2] = arguments[_key];
}
console.error("\n\n---\n\n", error, "\n\n", ...rest, "\n\n---\n\n");

@@ -1013,3 +936,2 @@ throw error;

}
const pipe = function () {

@@ -1019,3 +941,2 @@ for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {

}
return v => {

@@ -1027,2 +948,3 @@ return funcs.reduce((res, func) => {

};
/***

@@ -1033,4 +955,2 @@ * Merge multiple functions returning objects into one object.

*/
const mergePipe = function () {

@@ -1040,6 +960,6 @@ for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {

}
return v => {
return funcs.reduce((res, func) => {
return { ...res,
return {
...res,
...func(v)

@@ -1050,2 +970,3 @@ };

};
/**

@@ -1056,5 +977,4 @@ * @description Object check

*/
const isObject = value => value && typeof value === "object" && !Array.isArray(value);
const isObject = value => value && typeof value === "object" && !Array.isArray(value);
/**

@@ -1066,4 +986,2 @@ * @description Deep merge multiple objects.

*/
const mergeDeep = function (target) {

@@ -1073,6 +991,4 @@ for (var _len3 = arguments.length, sources = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {

}
if (!sources.length) return target;
const source = sources.shift();
if (isObject(target) && isObject(source)) {

@@ -1092,5 +1008,5 @@ for (const key in source) {

}
return mergeDeep(target, ...sources);
};
/**

@@ -1101,5 +1017,4 @@ * @description Deep merge multiple Flow JSON.

*/
const mergeFlowJSONs = value => Array.isArray(value) ? mergeDeep({}, ...value) : value;
const mergeFlowJSONs = value => Array.isArray(value) ? mergeDeep({}, ...value) : value;
/**

@@ -1110,5 +1025,4 @@ * @description Filter out contracts section of flow.json.

*/
const filterContracts = obj => obj.contracts ? obj.contracts : {};
const filterContracts = obj => obj.contracts ? obj.contracts : {};
/**

@@ -1119,19 +1033,12 @@ * @description Gathers contract addresses by network

*/
const mapContractAliasesToNetworkAddress = network => contracts => {
return Object.entries(contracts).reduce((c, _ref) => {
var _value$aliases;
let [key, value] = _ref;
const networkContractAlias = value === null || value === void 0 ? void 0 : (_value$aliases = value.aliases) === null || _value$aliases === void 0 ? void 0 : _value$aliases[network];
const networkContractAlias = value?.aliases?.[network];
if (networkContractAlias) {
c[key] = networkContractAlias;
}
return c;
}, {});
};
const mapDeploymentsToNetworkAddress = network => _ref2 => {

@@ -1142,14 +1049,14 @@ let {

} = _ref2;
const networkDeployment = deployments === null || deployments === void 0 ? void 0 : deployments[network];
const networkDeployment = deployments?.[network];
if (!networkDeployment) return {};
return Object.entries(networkDeployment).reduce((c, _ref3) => {
var _accounts$key;
let [key, value] = _ref3;
// Resolve account address
const accountAddress = accounts[key]?.address;
if (!accountAddress) return c;
let [key, value] = _ref3; // Resolve account address
const accountAddress = (_accounts$key = accounts[key]) === null || _accounts$key === void 0 ? void 0 : _accounts$key.address;
if (!accountAddress) return c; // Create an object assigning the address to the contract name.
// Create an object assigning the address to the contract name.
return value.reduce((c, contract) => {
return { ...c,
return {
...c,
[contract]: accountAddress

@@ -1160,2 +1067,3 @@ };

};
/**

@@ -1167,7 +1075,6 @@ * @description Take in flow.json files and return contract to address mapping by network

*/
const getContracts = (jsons, network) => {
return pipe(mergeFlowJSONs, mergePipe(mapDeploymentsToNetworkAddress(network), pipe(filterContracts, mapContractAliasesToNetworkAddress(network))))(jsons);
};
/**

@@ -1178,4 +1085,2 @@ * @description Checks if string is hexidecimal

*/
const isHexidecimal = str => {

@@ -1186,2 +1091,3 @@ // Check that it is a string

};
/**

@@ -1192,11 +1098,10 @@ * @description Checks flow.json file for private keys

*/
const hasPrivateKeys = flowJSON => {
return Object.entries(flowJSON === null || flowJSON === void 0 ? void 0 : flowJSON.accounts).reduce((hasPrivateKey, _ref4) => {
return Object.entries(flowJSON?.accounts).reduce((hasPrivateKey, _ref4) => {
let [key, value] = _ref4;
if (hasPrivateKey) return true;
return (value === null || value === void 0 ? void 0 : value.hasOwnProperty("key")) && isHexidecimal(value === null || value === void 0 ? void 0 : value.key);
return value?.hasOwnProperty("key") && isHexidecimal(value?.key);
}, false);
};
/**

@@ -1207,4 +1112,2 @@ * @description Take in flow.json or array of flow.json files and checks for private keys

*/
const anyHasPrivateKeys = value => {

@@ -1214,2 +1117,3 @@ if (isObject(value)) return hasPrivateKeys(value);

};
/**

@@ -1220,6 +1124,3 @@ * @description Format network to always be 'emulator', 'testnet', or 'mainnet'

*/
const cleanNetwork = network => (network === null || network === void 0 ? void 0 : network.toLowerCase()) === "local" ? "emulator" : network === null || network === void 0 ? void 0 : network.toLowerCase();
const cleanNetwork = network => network?.toLowerCase() === "local" ? "emulator" : network?.toLowerCase();
const NAME = "config";

@@ -1234,5 +1135,3 @@ const PUT = "PUT_CONFIG";

const UPDATED = "CONFIG/UPDATED";
const identity = v => v;
const HANDLERS = {

@@ -1246,3 +1145,4 @@ [PUT]: (ctx, _letter, _ref) => {

ctx.put(key, value);
ctx.broadcast(UPDATED, { ...ctx.all()
ctx.broadcast(UPDATED, {
...ctx.all()
});

@@ -1259,3 +1159,4 @@ },

[GET_ALL]: (ctx, letter) => {
letter.reply({ ...ctx.all()
letter.reply({
...ctx.all()
});

@@ -1270,3 +1171,4 @@ },

ctx.update(key, fn || identity);
ctx.broadcast(UPDATED, { ...ctx.all()
ctx.broadcast(UPDATED, {
...ctx.all()
});

@@ -1280,3 +1182,4 @@ },

ctx.delete(key);
ctx.broadcast(UPDATED, { ...ctx.all()
ctx.broadcast(UPDATED, {
...ctx.all()
});

@@ -1286,6 +1189,5 @@ },

let keys = Object.keys(ctx.all());
for (let key of keys) ctx.delete(key);
ctx.broadcast(UPDATED, { ...ctx.all()
ctx.broadcast(UPDATED, {
...ctx.all()
});

@@ -1302,3 +1204,4 @@ },

ctx.subscribe(letter.from);
ctx.send(letter.from, UPDATED, { ...ctx.all()
ctx.send(letter.from, UPDATED, {
...ctx.all()
});

@@ -1311,2 +1214,3 @@ },

spawn(HANDLERS, NAME);
/**

@@ -1318,3 +1222,2 @@ * @description Adds a key-value pair to the config

*/
function put(key, value) {

@@ -1327,2 +1230,3 @@ send(NAME, PUT, {

}
/**

@@ -1334,4 +1238,2 @@ * @description Gets a key-value pair with a fallback from the config

*/
function get(key, fallback) {

@@ -1346,2 +1248,3 @@ return send(NAME, GET, {

}
/**

@@ -1353,4 +1256,2 @@ * @description Returns the first non null config value or the fallback

*/
async function first() {

@@ -1365,2 +1266,3 @@ let wants = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];

}
/**

@@ -1370,4 +1272,2 @@ * @description Returns the current config

*/
function all() {

@@ -1379,2 +1279,3 @@ return send(NAME, GET_ALL, null, {

}
/**

@@ -1386,4 +1287,2 @@ * @description Updates a key-value pair in the config

*/
function update(key) {

@@ -1397,2 +1296,3 @@ let fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity;

}
/**

@@ -1403,4 +1303,2 @@ * @description Deletes a key-value pair from the config

*/
function _delete(key) {

@@ -1412,2 +1310,3 @@ send(NAME, DELETE, {

}
/**

@@ -1418,4 +1317,2 @@ * @description Returns a subset of the config based on a pattern

*/
function where(pattern) {

@@ -1429,2 +1326,3 @@ return send(NAME, WHERE, {

}
/**

@@ -1435,7 +1333,6 @@ * @description Subscribes to config updates

*/
function subscribe(callback) {
return subscriber(NAME, () => spawn(HANDLERS, NAME), callback);
}
/**

@@ -1445,7 +1342,6 @@ * @description Clears the config

*/
function clearConfig() {
return send(NAME, CLEAR);
}
/**

@@ -1456,7 +1352,6 @@ * @description Resets the config to a previous state

*/
function resetConfig(oldConfig) {
return clearConfig().then(config(oldConfig));
}
/**

@@ -1467,4 +1362,2 @@ * @description Takes in flow.json or array of flow.json files and creates contract placeholders

*/
async function load(data) {

@@ -1478,3 +1371,2 @@ const network = await get("flow.network");

invariant(cleanedNetwork, `Flow Network Required -- In order for FCL to load your contracts please define "flow.network" to "emulator", "local", "testnet", or "mainnet" in your config. See more here: https://developers.flow.com/tools/fcl-js/reference/configure-fcl`);
if (anyHasPrivateKeys(flowJSON)) {

@@ -1489,7 +1381,5 @@ const isEmulator = cleanedNetwork === "emulator";

}
for (const [key, value] of Object.entries(getContracts(flowJSON, cleanedNetwork))) {
const contractConfigKey = `0x${key}`;
const existingContractConfigKey = await get(contractConfigKey);
if (existingContractConfigKey && existingContractConfigKey !== value) {

@@ -1504,6 +1394,4 @@ log$1({

}
const systemContractConfigKey = `system.contracts.${key}`;
const systemExistingContractConfigKeyValue = await get(systemContractConfigKey);
if (systemExistingContractConfigKeyValue && systemExistingContractConfigKeyValue !== value) {

@@ -1519,4 +1407,5 @@ log$1({

}
} // eslint-disable-next-line jsdoc/require-returns
}
// eslint-disable-next-line jsdoc/require-returns
/**

@@ -1526,4 +1415,2 @@ * @description Sets the config

*/
function config(values) {

@@ -1533,3 +1420,2 @@ if (values != null && typeof values === "object") {

}
return {

@@ -1548,3 +1434,2 @@ put,

}
config.put = put;

@@ -1560,5 +1445,3 @@ config.get = get;

config.load = load;
const noop = v => v;
function overload() {

@@ -1569,3 +1452,2 @@ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

const oldConfig = await all();
try {

@@ -1594,3 +1476,2 @@ config(opts);

*/
const LEVELS = Object.freeze({

@@ -1603,2 +1484,3 @@ debug: 5,

});
/**

@@ -1615,3 +1497,2 @@ * Builds a message formatted for the logger

*/
const buildLoggerMessageArgs = _ref => {

@@ -1631,2 +1512,3 @@ let {

};
/**

@@ -1646,4 +1528,2 @@ * Logs messages based on the level of the message and the level set in the config

*/
const log = async _ref2 => {

@@ -1656,4 +1536,5 @@ let {

} = _ref2;
const configLoggerLevel = await config.get("logger.level", LEVELS.warn); // If config level is below message level then don't show it
const configLoggerLevel = await config.get("logger.level", LEVELS.warn);
// If config level is below message level then don't show it
if (!always && configLoggerLevel < level) return;

@@ -1664,3 +1545,2 @@ const loggerMessageArgs = buildLoggerMessageArgs({

});
switch (level) {

@@ -1670,15 +1550,11 @@ case LEVELS.debug:

break;
case LEVELS.info:
console.info(...loggerMessageArgs);
break;
case LEVELS.warn:
console.warn(...loggerMessageArgs);
break;
case LEVELS.error:
console.error(...loggerMessageArgs);
break;
default:

@@ -1688,2 +1564,3 @@ console.log(...loggerMessageArgs);

};
/**

@@ -1705,4 +1582,2 @@ * Logs a deprecation notice

*/
log.deprecate = _ref3 => {

@@ -1717,7 +1592,5 @@ let {

} = _ref3;
const capitalizeFirstLetter = string => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
const logMessage = () => log({

@@ -1730,3 +1603,2 @@ title: `${pkg ? pkg + " " : ""}Deprecation Notice`,

});
if (typeof callback === "function") {

@@ -1738,3 +1610,2 @@ return async function () {

}
return logMessage();

@@ -1756,3 +1627,2 @@ };

}
function recApply(d) {

@@ -1768,6 +1638,6 @@ return function (arg1) {

}
return String(arg1);
};
}
/**

@@ -1778,4 +1648,2 @@ * @param {(string|Array.<*>)} head

*/
function template(head) {

@@ -1785,9 +1653,6 @@ for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

}
if (typeof head === "string") return () => head;
if (Array.isArray(head)) {
return d => interleave(head, rest.map(recApply(d))).join("").trim();
}
return head;

@@ -1794,0 +1659,0 @@ }

@@ -11,3 +11,4 @@ (function (global, factory) {

let promise;
var queueMicrotask_1 = typeof queueMicrotask === 'function' ? queueMicrotask.bind(typeof window !== 'undefined' ? window : commonjsGlobal) // reuse resolved promise, and allocate it lazily
var queueMicrotask_1 = typeof queueMicrotask === 'function' ? queueMicrotask.bind(typeof window !== 'undefined' ? window : commonjsGlobal)
// reuse resolved promise, and allocate it lazily
: cb => (promise || (promise = Promise.resolve())).then(cb).catch(err => setTimeout(() => {

@@ -23,3 +24,2 @@ throw err;

queue.push(msg);
if (next) {

@@ -30,3 +30,2 @@ next(queue.shift());

},
receive() {

@@ -39,6 +38,4 @@ return new Promise(function innerReceive(resolve) {

}
};
};
const INIT = "INIT";

@@ -54,3 +51,2 @@ const SUBSCRIBE = "SUBSCRIBE";

const DEFAULT_TIMEOUT = 5000;
const send = function (addr, tag, data) {

@@ -61,7 +57,5 @@ let opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};

const timeout = opts.timeout != null ? opts.timeout : DEFAULT_TIMEOUT;
if (expectReply && timeout) {
setTimeout(() => reject(new Error(`Timeout: ${timeout}ms passed without a response.`)), timeout);
}
const payload = {

@@ -76,3 +70,2 @@ to: addr,

};
try {

@@ -86,7 +79,5 @@ root.FCL_REGISTRY[addr] && root.FCL_REGISTRY[addr].mailbox.deliver(payload);

};
const kill = addr => {
delete root.FCL_REGISTRY[addr];
};
const fromHandlers = function () {

@@ -96,6 +87,4 @@ let handlers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

if (typeof handlers[INIT] === "function") await handlers[INIT](ctx);
__loop: while (1) {
const letter = await ctx.receive();
try {

@@ -106,6 +95,4 @@ if (letter.tag === EXIT) {

}
break __loop;
}
await handlers[letter.tag](ctx, letter, letter.data || {});

@@ -120,3 +107,2 @@ } catch (error) {

};
const spawn = function (fn) {

@@ -147,3 +133,2 @@ let addr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;

opts.from = addr;
for (let to of root.FCL_REGISTRY[addr].subs) send(to, tag, data, opts);

@@ -176,3 +161,4 @@ },

return Object.keys(root.FCL_REGISTRY[addr].kvs).reduce((acc, key) => {
return pattern.test(key) ? { ...acc,
return pattern.test(key) ? {
...acc,
[key]: root.FCL_REGISTRY[addr].kvs[key]

@@ -188,3 +174,2 @@ } : acc;

root.FCL_REGISTRY[addr].error = error;
for (let to of root.FCL_REGISTRY[addr].subs) send(to, UPDATED$2);

@@ -199,3 +184,5 @@ }

return addr;
}; // Returns an unsubscribe function
};
// Returns an unsubscribe function
// A SUBSCRIBE handler will need to be created to handle the subscription event

@@ -208,4 +195,2 @@ //

//
function subscriber(address, spawnFn, callback) {

@@ -216,7 +201,5 @@ spawnFn(address);

ctx.send(address, SUBSCRIBE);
while (1) {
const letter = await ctx.receive();
const error = root.FCL_REGISTRY[address].error;
if (letter.tag === EXIT) {

@@ -226,3 +209,2 @@ ctx.send(address, UNSUBSCRIBE);

}
if (error) {

@@ -233,3 +215,2 @@ callback(null, error);

}
callback(letter.data, null);

@@ -239,3 +220,3 @@ }

return () => send(self, EXIT);
} // Returns a promise that returns a result
}

@@ -249,3 +230,2 @@ /**

*/
function invariant$1(fact, msg) {

@@ -255,7 +235,5 @@ if (!fact) {

error.stack = error.stack.split("\n").filter(d => !/at invariant/.test(d)).join("\n");
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
rest[_key - 2] = arguments[_key];
}
console.error("\n\n---\n\n", error, "\n\n", ...rest, "\n\n---\n\n");

@@ -265,3 +243,2 @@ throw error;

}
const pipe$1 = function () {

@@ -271,3 +248,2 @@ for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {

}
return v => {

@@ -279,2 +255,3 @@ return funcs.reduce((res, func) => {

};
/***

@@ -285,4 +262,2 @@ * Merge multiple functions returning objects into one object.

*/
const mergePipe$1 = function () {

@@ -292,6 +267,6 @@ for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {

}
return v => {
return funcs.reduce((res, func) => {
return { ...res,
return {
...res,
...func(v)

@@ -302,2 +277,3 @@ };

};
/**

@@ -308,5 +284,4 @@ * @description Object check

*/
const isObject$1 = value => value && typeof value === "object" && !Array.isArray(value);
const isObject$1 = value => value && typeof value === "object" && !Array.isArray(value);
/**

@@ -318,4 +293,2 @@ * @description Deep merge multiple objects.

*/
const mergeDeep$1 = function (target) {

@@ -325,6 +298,4 @@ for (var _len3 = arguments.length, sources = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {

}
if (!sources.length) return target;
const source = sources.shift();
if (isObject$1(target) && isObject$1(source)) {

@@ -344,5 +315,5 @@ for (const key in source) {

}
return mergeDeep$1(target, ...sources);
};
/**

@@ -353,5 +324,4 @@ * @description Deep merge multiple Flow JSON.

*/
const mergeFlowJSONs$1 = value => Array.isArray(value) ? mergeDeep$1({}, ...value) : value;
const mergeFlowJSONs$1 = value => Array.isArray(value) ? mergeDeep$1({}, ...value) : value;
/**

@@ -362,5 +332,4 @@ * @description Filter out contracts section of flow.json.

*/
const filterContracts$1 = obj => obj.contracts ? obj.contracts : {};
const filterContracts$1 = obj => obj.contracts ? obj.contracts : {};
/**

@@ -371,19 +340,12 @@ * @description Gathers contract addresses by network

*/
const mapContractAliasesToNetworkAddress$1 = network => contracts => {
return Object.entries(contracts).reduce((c, _ref) => {
var _value$aliases;
let [key, value] = _ref;
const networkContractAlias = value === null || value === void 0 ? void 0 : (_value$aliases = value.aliases) === null || _value$aliases === void 0 ? void 0 : _value$aliases[network];
const networkContractAlias = value?.aliases?.[network];
if (networkContractAlias) {
c[key] = networkContractAlias;
}
return c;
}, {});
};
const mapDeploymentsToNetworkAddress$1 = network => _ref2 => {

@@ -394,14 +356,14 @@ let {

} = _ref2;
const networkDeployment = deployments === null || deployments === void 0 ? void 0 : deployments[network];
const networkDeployment = deployments?.[network];
if (!networkDeployment) return {};
return Object.entries(networkDeployment).reduce((c, _ref3) => {
var _accounts$key;
let [key, value] = _ref3;
// Resolve account address
const accountAddress = accounts[key]?.address;
if (!accountAddress) return c;
let [key, value] = _ref3; // Resolve account address
const accountAddress = (_accounts$key = accounts[key]) === null || _accounts$key === void 0 ? void 0 : _accounts$key.address;
if (!accountAddress) return c; // Create an object assigning the address to the contract name.
// Create an object assigning the address to the contract name.
return value.reduce((c, contract) => {
return { ...c,
return {
...c,
[contract]: accountAddress

@@ -412,2 +374,3 @@ };

};
/**

@@ -419,7 +382,6 @@ * @description Take in flow.json files and return contract to address mapping by network

*/
const getContracts$1 = (jsons, network) => {
return pipe$1(mergeFlowJSONs$1, mergePipe$1(mapDeploymentsToNetworkAddress$1(network), pipe$1(filterContracts$1, mapContractAliasesToNetworkAddress$1(network))))(jsons);
};
/**

@@ -430,4 +392,2 @@ * @description Checks if string is hexidecimal

*/
const isHexidecimal$1 = str => {

@@ -438,2 +398,3 @@ // Check that it is a string

};
/**

@@ -444,11 +405,10 @@ * @description Checks flow.json file for private keys

*/
const hasPrivateKeys$1 = flowJSON => {
return Object.entries(flowJSON === null || flowJSON === void 0 ? void 0 : flowJSON.accounts).reduce((hasPrivateKey, _ref4) => {
return Object.entries(flowJSON?.accounts).reduce((hasPrivateKey, _ref4) => {
let [key, value] = _ref4;
if (hasPrivateKey) return true;
return (value === null || value === void 0 ? void 0 : value.hasOwnProperty("key")) && isHexidecimal$1(value === null || value === void 0 ? void 0 : value.key);
return value?.hasOwnProperty("key") && isHexidecimal$1(value?.key);
}, false);
};
/**

@@ -459,4 +419,2 @@ * @description Take in flow.json or array of flow.json files and checks for private keys

*/
const anyHasPrivateKeys$1 = value => {

@@ -466,2 +424,3 @@ if (isObject$1(value)) return hasPrivateKeys$1(value);

};
/**

@@ -472,6 +431,3 @@ * @description Format network to always be 'emulator', 'testnet', or 'mainnet'

*/
const cleanNetwork$1 = network => (network === null || network === void 0 ? void 0 : network.toLowerCase()) === "local" ? "emulator" : network === null || network === void 0 ? void 0 : network.toLowerCase();
const cleanNetwork$1 = network => network?.toLowerCase() === "local" ? "emulator" : network?.toLowerCase();
const NAME$1 = "config";

@@ -486,5 +442,3 @@ const PUT$1 = "PUT_CONFIG";

const UPDATED$1 = "CONFIG/UPDATED";
const identity$1 = v => v;
const HANDLERS$1 = {

@@ -498,3 +452,4 @@ [PUT$1]: (ctx, _letter, _ref) => {

ctx.put(key, value);
ctx.broadcast(UPDATED$1, { ...ctx.all()
ctx.broadcast(UPDATED$1, {
...ctx.all()
});

@@ -511,3 +466,4 @@ },

[GET_ALL$1]: (ctx, letter) => {
letter.reply({ ...ctx.all()
letter.reply({
...ctx.all()
});

@@ -522,3 +478,4 @@ },

ctx.update(key, fn || identity$1);
ctx.broadcast(UPDATED$1, { ...ctx.all()
ctx.broadcast(UPDATED$1, {
...ctx.all()
});

@@ -532,3 +489,4 @@ },

ctx.delete(key);
ctx.broadcast(UPDATED$1, { ...ctx.all()
ctx.broadcast(UPDATED$1, {
...ctx.all()
});

@@ -538,6 +496,5 @@ },

let keys = Object.keys(ctx.all());
for (let key of keys) ctx.delete(key);
ctx.broadcast(UPDATED$1, { ...ctx.all()
ctx.broadcast(UPDATED$1, {
...ctx.all()
});

@@ -554,3 +511,4 @@ },

ctx.subscribe(letter.from);
ctx.send(letter.from, UPDATED$1, { ...ctx.all()
ctx.send(letter.from, UPDATED$1, {
...ctx.all()
});

@@ -563,2 +521,3 @@ },

spawn(HANDLERS$1, NAME$1);
/**

@@ -570,3 +529,2 @@ * @description Adds a key-value pair to the config

*/
function put$1(key, value) {

@@ -579,2 +537,3 @@ send(NAME$1, PUT$1, {

}
/**

@@ -586,4 +545,2 @@ * @description Gets a key-value pair with a fallback from the config

*/
function get$1(key, fallback) {

@@ -598,2 +555,3 @@ return send(NAME$1, GET$1, {

}
/**

@@ -605,4 +563,2 @@ * @description Returns the first non null config value or the fallback

*/
async function first$1() {

@@ -617,2 +573,3 @@ let wants = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];

}
/**

@@ -622,4 +579,2 @@ * @description Returns the current config

*/
function all$1() {

@@ -631,2 +586,3 @@ return send(NAME$1, GET_ALL$1, null, {

}
/**

@@ -638,4 +594,2 @@ * @description Updates a key-value pair in the config

*/
function update$1(key) {

@@ -649,2 +603,3 @@ let fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity$1;

}
/**

@@ -655,4 +610,2 @@ * @description Deletes a key-value pair from the config

*/
function _delete$1(key) {

@@ -664,2 +617,3 @@ send(NAME$1, DELETE$1, {

}
/**

@@ -670,4 +624,2 @@ * @description Returns a subset of the config based on a pattern

*/
function where$1(pattern) {

@@ -681,2 +633,3 @@ return send(NAME$1, WHERE$1, {

}
/**

@@ -687,7 +640,6 @@ * @description Subscribes to config updates

*/
function subscribe$1(callback) {
return subscriber(NAME$1, () => spawn(HANDLERS$1, NAME$1), callback);
}
/**

@@ -697,7 +649,6 @@ * @description Clears the config

*/
function clearConfig$1() {
return send(NAME$1, CLEAR$1);
}
/**

@@ -708,7 +659,6 @@ * @description Resets the config to a previous state

*/
function resetConfig$1(oldConfig) {
return clearConfig$1().then(config$1(oldConfig));
}
/**

@@ -719,4 +669,2 @@ * @description Takes in flow.json or array of flow.json files and creates contract placeholders

*/
async function load$1(data) {

@@ -730,3 +678,2 @@ const network = await get$1("flow.network");

invariant$1(cleanedNetwork, `Flow Network Required -- In order for FCL to load your contracts please define "flow.network" to "emulator", "local", "testnet", or "mainnet" in your config. See more here: https://developers.flow.com/tools/fcl-js/reference/configure-fcl`);
if (anyHasPrivateKeys$1(flowJSON)) {

@@ -741,7 +688,5 @@ const isEmulator = cleanedNetwork === "emulator";

}
for (const [key, value] of Object.entries(getContracts$1(flowJSON, cleanedNetwork))) {
const contractConfigKey = `0x${key}`;
const existingContractConfigKey = await get$1(contractConfigKey);
if (existingContractConfigKey && existingContractConfigKey !== value) {

@@ -756,6 +701,4 @@ log$1({

}
const systemContractConfigKey = `system.contracts.${key}`;
const systemExistingContractConfigKeyValue = await get$1(systemContractConfigKey);
if (systemExistingContractConfigKeyValue && systemExistingContractConfigKeyValue !== value) {

@@ -771,4 +714,5 @@ log$1({

}
} // eslint-disable-next-line jsdoc/require-returns
}
// eslint-disable-next-line jsdoc/require-returns
/**

@@ -778,4 +722,2 @@ * @description Sets the config

*/
function config$1(values) {

@@ -785,3 +727,2 @@ if (values != null && typeof values === "object") {

}
return {

@@ -800,3 +741,2 @@ put: put$1,

}
config$1.put = put$1;

@@ -812,5 +752,3 @@ config$1.get = get$1;

config$1.load = load$1;
const noop$1 = v => v;
function overload$1() {

@@ -821,3 +759,2 @@ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

const oldConfig = await all$1();
try {

@@ -834,2 +771,3 @@ config$1(opts);

}
/**

@@ -846,4 +784,2 @@ * The levels of the logger

*/
const LEVELS$1 = Object.freeze({

@@ -856,2 +792,3 @@ debug: 5,

});
/**

@@ -868,3 +805,2 @@ * Builds a message formatted for the logger

*/
const buildLoggerMessageArgs$1 = _ref => {

@@ -884,2 +820,3 @@ let {

};
/**

@@ -899,4 +836,2 @@ * Logs messages based on the level of the message and the level set in the config

*/
const log$1 = async _ref2 => {

@@ -909,4 +844,5 @@ let {

} = _ref2;
const configLoggerLevel = await config$1.get("logger.level", LEVELS$1.warn); // If config level is below message level then don't show it
const configLoggerLevel = await config$1.get("logger.level", LEVELS$1.warn);
// If config level is below message level then don't show it
if (!always && configLoggerLevel < level) return;

@@ -917,3 +853,2 @@ const loggerMessageArgs = buildLoggerMessageArgs$1({

});
switch (level) {

@@ -923,15 +858,11 @@ case LEVELS$1.debug:

break;
case LEVELS$1.info:
console.info(...loggerMessageArgs);
break;
case LEVELS$1.warn:
console.warn(...loggerMessageArgs);
break;
case LEVELS$1.error:
console.error(...loggerMessageArgs);
break;
default:

@@ -941,2 +872,3 @@ console.log(...loggerMessageArgs);

};
/**

@@ -958,4 +890,2 @@ * Logs a deprecation notice

*/
log$1.deprecate = _ref3 => {

@@ -970,7 +900,5 @@ let {

} = _ref3;
const capitalizeFirstLetter = string => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
const logMessage = () => log$1({

@@ -983,3 +911,2 @@ title: `${pkg ? pkg + " " : ""}Deprecation Notice`,

});
if (typeof callback === "function") {

@@ -991,5 +918,5 @@ return async function () {

}
return logMessage();
};
/**

@@ -1002,4 +929,2 @@ * Asserts fact is true, otherwise throw an error with invariant message

*/
function invariant(fact, msg) {

@@ -1009,7 +934,5 @@ if (!fact) {

error.stack = error.stack.split("\n").filter(d => !/at invariant/.test(d)).join("\n");
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
rest[_key - 2] = arguments[_key];
}
console.error("\n\n---\n\n", error, "\n\n", ...rest, "\n\n---\n\n");

@@ -1019,3 +942,2 @@ throw error;

}
const pipe = function () {

@@ -1025,3 +947,2 @@ for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {

}
return v => {

@@ -1033,2 +954,3 @@ return funcs.reduce((res, func) => {

};
/***

@@ -1039,4 +961,2 @@ * Merge multiple functions returning objects into one object.

*/
const mergePipe = function () {

@@ -1046,6 +966,6 @@ for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {

}
return v => {
return funcs.reduce((res, func) => {
return { ...res,
return {
...res,
...func(v)

@@ -1056,2 +976,3 @@ };

};
/**

@@ -1062,5 +983,4 @@ * @description Object check

*/
const isObject = value => value && typeof value === "object" && !Array.isArray(value);
const isObject = value => value && typeof value === "object" && !Array.isArray(value);
/**

@@ -1072,4 +992,2 @@ * @description Deep merge multiple objects.

*/
const mergeDeep = function (target) {

@@ -1079,6 +997,4 @@ for (var _len3 = arguments.length, sources = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {

}
if (!sources.length) return target;
const source = sources.shift();
if (isObject(target) && isObject(source)) {

@@ -1098,5 +1014,5 @@ for (const key in source) {

}
return mergeDeep(target, ...sources);
};
/**

@@ -1107,5 +1023,4 @@ * @description Deep merge multiple Flow JSON.

*/
const mergeFlowJSONs = value => Array.isArray(value) ? mergeDeep({}, ...value) : value;
const mergeFlowJSONs = value => Array.isArray(value) ? mergeDeep({}, ...value) : value;
/**

@@ -1116,5 +1031,4 @@ * @description Filter out contracts section of flow.json.

*/
const filterContracts = obj => obj.contracts ? obj.contracts : {};
const filterContracts = obj => obj.contracts ? obj.contracts : {};
/**

@@ -1125,19 +1039,12 @@ * @description Gathers contract addresses by network

*/
const mapContractAliasesToNetworkAddress = network => contracts => {
return Object.entries(contracts).reduce((c, _ref) => {
var _value$aliases;
let [key, value] = _ref;
const networkContractAlias = value === null || value === void 0 ? void 0 : (_value$aliases = value.aliases) === null || _value$aliases === void 0 ? void 0 : _value$aliases[network];
const networkContractAlias = value?.aliases?.[network];
if (networkContractAlias) {
c[key] = networkContractAlias;
}
return c;
}, {});
};
const mapDeploymentsToNetworkAddress = network => _ref2 => {

@@ -1148,14 +1055,14 @@ let {

} = _ref2;
const networkDeployment = deployments === null || deployments === void 0 ? void 0 : deployments[network];
const networkDeployment = deployments?.[network];
if (!networkDeployment) return {};
return Object.entries(networkDeployment).reduce((c, _ref3) => {
var _accounts$key;
let [key, value] = _ref3;
// Resolve account address
const accountAddress = accounts[key]?.address;
if (!accountAddress) return c;
let [key, value] = _ref3; // Resolve account address
const accountAddress = (_accounts$key = accounts[key]) === null || _accounts$key === void 0 ? void 0 : _accounts$key.address;
if (!accountAddress) return c; // Create an object assigning the address to the contract name.
// Create an object assigning the address to the contract name.
return value.reduce((c, contract) => {
return { ...c,
return {
...c,
[contract]: accountAddress

@@ -1166,2 +1073,3 @@ };

};
/**

@@ -1173,7 +1081,6 @@ * @description Take in flow.json files and return contract to address mapping by network

*/
const getContracts = (jsons, network) => {
return pipe(mergeFlowJSONs, mergePipe(mapDeploymentsToNetworkAddress(network), pipe(filterContracts, mapContractAliasesToNetworkAddress(network))))(jsons);
};
/**

@@ -1184,4 +1091,2 @@ * @description Checks if string is hexidecimal

*/
const isHexidecimal = str => {

@@ -1192,2 +1097,3 @@ // Check that it is a string

};
/**

@@ -1198,11 +1104,10 @@ * @description Checks flow.json file for private keys

*/
const hasPrivateKeys = flowJSON => {
return Object.entries(flowJSON === null || flowJSON === void 0 ? void 0 : flowJSON.accounts).reduce((hasPrivateKey, _ref4) => {
return Object.entries(flowJSON?.accounts).reduce((hasPrivateKey, _ref4) => {
let [key, value] = _ref4;
if (hasPrivateKey) return true;
return (value === null || value === void 0 ? void 0 : value.hasOwnProperty("key")) && isHexidecimal(value === null || value === void 0 ? void 0 : value.key);
return value?.hasOwnProperty("key") && isHexidecimal(value?.key);
}, false);
};
/**

@@ -1213,4 +1118,2 @@ * @description Take in flow.json or array of flow.json files and checks for private keys

*/
const anyHasPrivateKeys = value => {

@@ -1220,2 +1123,3 @@ if (isObject(value)) return hasPrivateKeys(value);

};
/**

@@ -1226,6 +1130,3 @@ * @description Format network to always be 'emulator', 'testnet', or 'mainnet'

*/
const cleanNetwork = network => (network === null || network === void 0 ? void 0 : network.toLowerCase()) === "local" ? "emulator" : network === null || network === void 0 ? void 0 : network.toLowerCase();
const cleanNetwork = network => network?.toLowerCase() === "local" ? "emulator" : network?.toLowerCase();
const NAME = "config";

@@ -1240,5 +1141,3 @@ const PUT = "PUT_CONFIG";

const UPDATED = "CONFIG/UPDATED";
const identity = v => v;
const HANDLERS = {

@@ -1252,3 +1151,4 @@ [PUT]: (ctx, _letter, _ref) => {

ctx.put(key, value);
ctx.broadcast(UPDATED, { ...ctx.all()
ctx.broadcast(UPDATED, {
...ctx.all()
});

@@ -1265,3 +1165,4 @@ },

[GET_ALL]: (ctx, letter) => {
letter.reply({ ...ctx.all()
letter.reply({
...ctx.all()
});

@@ -1276,3 +1177,4 @@ },

ctx.update(key, fn || identity);
ctx.broadcast(UPDATED, { ...ctx.all()
ctx.broadcast(UPDATED, {
...ctx.all()
});

@@ -1286,3 +1188,4 @@ },

ctx.delete(key);
ctx.broadcast(UPDATED, { ...ctx.all()
ctx.broadcast(UPDATED, {
...ctx.all()
});

@@ -1292,6 +1195,5 @@ },

let keys = Object.keys(ctx.all());
for (let key of keys) ctx.delete(key);
ctx.broadcast(UPDATED, { ...ctx.all()
ctx.broadcast(UPDATED, {
...ctx.all()
});

@@ -1308,3 +1210,4 @@ },

ctx.subscribe(letter.from);
ctx.send(letter.from, UPDATED, { ...ctx.all()
ctx.send(letter.from, UPDATED, {
...ctx.all()
});

@@ -1317,2 +1220,3 @@ },

spawn(HANDLERS, NAME);
/**

@@ -1324,3 +1228,2 @@ * @description Adds a key-value pair to the config

*/
function put(key, value) {

@@ -1333,2 +1236,3 @@ send(NAME, PUT, {

}
/**

@@ -1340,4 +1244,2 @@ * @description Gets a key-value pair with a fallback from the config

*/
function get(key, fallback) {

@@ -1352,2 +1254,3 @@ return send(NAME, GET, {

}
/**

@@ -1359,4 +1262,2 @@ * @description Returns the first non null config value or the fallback

*/
async function first() {

@@ -1371,2 +1272,3 @@ let wants = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];

}
/**

@@ -1376,4 +1278,2 @@ * @description Returns the current config

*/
function all() {

@@ -1385,2 +1285,3 @@ return send(NAME, GET_ALL, null, {

}
/**

@@ -1392,4 +1293,2 @@ * @description Updates a key-value pair in the config

*/
function update(key) {

@@ -1403,2 +1302,3 @@ let fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity;

}
/**

@@ -1409,4 +1309,2 @@ * @description Deletes a key-value pair from the config

*/
function _delete(key) {

@@ -1418,2 +1316,3 @@ send(NAME, DELETE, {

}
/**

@@ -1424,4 +1323,2 @@ * @description Returns a subset of the config based on a pattern

*/
function where(pattern) {

@@ -1435,2 +1332,3 @@ return send(NAME, WHERE, {

}
/**

@@ -1441,7 +1339,6 @@ * @description Subscribes to config updates

*/
function subscribe(callback) {
return subscriber(NAME, () => spawn(HANDLERS, NAME), callback);
}
/**

@@ -1451,7 +1348,6 @@ * @description Clears the config

*/
function clearConfig() {
return send(NAME, CLEAR);
}
/**

@@ -1462,7 +1358,6 @@ * @description Resets the config to a previous state

*/
function resetConfig(oldConfig) {
return clearConfig().then(config(oldConfig));
}
/**

@@ -1473,4 +1368,2 @@ * @description Takes in flow.json or array of flow.json files and creates contract placeholders

*/
async function load(data) {

@@ -1484,3 +1377,2 @@ const network = await get("flow.network");

invariant(cleanedNetwork, `Flow Network Required -- In order for FCL to load your contracts please define "flow.network" to "emulator", "local", "testnet", or "mainnet" in your config. See more here: https://developers.flow.com/tools/fcl-js/reference/configure-fcl`);
if (anyHasPrivateKeys(flowJSON)) {

@@ -1495,7 +1387,5 @@ const isEmulator = cleanedNetwork === "emulator";

}
for (const [key, value] of Object.entries(getContracts(flowJSON, cleanedNetwork))) {
const contractConfigKey = `0x${key}`;
const existingContractConfigKey = await get(contractConfigKey);
if (existingContractConfigKey && existingContractConfigKey !== value) {

@@ -1510,6 +1400,4 @@ log$1({

}
const systemContractConfigKey = `system.contracts.${key}`;
const systemExistingContractConfigKeyValue = await get(systemContractConfigKey);
if (systemExistingContractConfigKeyValue && systemExistingContractConfigKeyValue !== value) {

@@ -1525,4 +1413,5 @@ log$1({

}
} // eslint-disable-next-line jsdoc/require-returns
}
// eslint-disable-next-line jsdoc/require-returns
/**

@@ -1532,4 +1421,2 @@ * @description Sets the config

*/
function config(values) {

@@ -1539,3 +1426,2 @@ if (values != null && typeof values === "object") {

}
return {

@@ -1554,3 +1440,2 @@ put,

}
config.put = put;

@@ -1566,5 +1451,3 @@ config.get = get;

config.load = load;
const noop = v => v;
function overload() {

@@ -1575,3 +1458,2 @@ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

const oldConfig = await all();
try {

@@ -1600,3 +1482,2 @@ config(opts);

*/
const LEVELS = Object.freeze({

@@ -1609,2 +1490,3 @@ debug: 5,

});
/**

@@ -1621,3 +1503,2 @@ * Builds a message formatted for the logger

*/
const buildLoggerMessageArgs = _ref => {

@@ -1637,2 +1518,3 @@ let {

};
/**

@@ -1652,4 +1534,2 @@ * Logs messages based on the level of the message and the level set in the config

*/
const log = async _ref2 => {

@@ -1662,4 +1542,5 @@ let {

} = _ref2;
const configLoggerLevel = await config.get("logger.level", LEVELS.warn); // If config level is below message level then don't show it
const configLoggerLevel = await config.get("logger.level", LEVELS.warn);
// If config level is below message level then don't show it
if (!always && configLoggerLevel < level) return;

@@ -1670,3 +1551,2 @@ const loggerMessageArgs = buildLoggerMessageArgs({

});
switch (level) {

@@ -1676,15 +1556,11 @@ case LEVELS.debug:

break;
case LEVELS.info:
console.info(...loggerMessageArgs);
break;
case LEVELS.warn:
console.warn(...loggerMessageArgs);
break;
case LEVELS.error:
console.error(...loggerMessageArgs);
break;
default:

@@ -1694,2 +1570,3 @@ console.log(...loggerMessageArgs);

};
/**

@@ -1711,4 +1588,2 @@ * Logs a deprecation notice

*/
log.deprecate = _ref3 => {

@@ -1723,7 +1598,5 @@ let {

} = _ref3;
const capitalizeFirstLetter = string => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
const logMessage = () => log({

@@ -1736,3 +1609,2 @@ title: `${pkg ? pkg + " " : ""}Deprecation Notice`,

});
if (typeof callback === "function") {

@@ -1744,3 +1616,2 @@ return async function () {

}
return logMessage();

@@ -1762,3 +1633,2 @@ };

}
function recApply(d) {

@@ -1774,6 +1644,6 @@ return function (arg1) {

}
return String(arg1);
};
}
/**

@@ -1784,4 +1654,2 @@ * @param {(string|Array.<*>)} head

*/
function template(head) {

@@ -1791,9 +1659,6 @@ for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

}
if (typeof head === "string") return () => head;
if (Array.isArray(head)) {
return d => interleave(head, rest.map(recApply(d))).join("").trim();
}
return head;

@@ -1800,0 +1665,0 @@ }

{
"name": "@onflow/util-template",
"version": "1.1.0-alpha.2",
"version": "1.1.0",
"description": "Template Literal used for Cadence Interop",

@@ -16,3 +16,3 @@ "license": "Apache-2.0",

"devDependencies": {
"@onflow/fcl-bundle": "^1.3.0-alpha.0",
"@onflow/fcl-bundle": "^1.3.0",
"jest": "^29.5.0"

@@ -19,0 +19,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc