@equilab/network
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -26,3 +26,3 @@ declare const _default: { | ||
readonly args: readonly [{ | ||
readonly V1: { | ||
readonly V2: { | ||
readonly parents: "1"; | ||
@@ -36,3 +36,3 @@ readonly interior: { | ||
}, { | ||
readonly V1: { | ||
readonly V2: { | ||
readonly parents: 0; | ||
@@ -49,3 +49,3 @@ readonly interior: { | ||
}, { | ||
readonly V1: readonly [{ | ||
readonly V2: readonly [{ | ||
readonly id: { | ||
@@ -52,0 +52,0 @@ readonly Concrete: { |
@@ -26,3 +26,3 @@ import type { BigDecimals } from "../../util/math"; | ||
readonly args: readonly [{ | ||
readonly V1: { | ||
readonly V2: { | ||
readonly parents: "1"; | ||
@@ -36,3 +36,3 @@ readonly interior: { | ||
}, { | ||
readonly V1: { | ||
readonly V2: { | ||
readonly parents: 0; | ||
@@ -49,3 +49,3 @@ readonly interior: { | ||
}, { | ||
readonly V1: readonly [{ | ||
readonly V2: readonly [{ | ||
readonly id: { | ||
@@ -52,0 +52,0 @@ readonly Concrete: { |
@@ -34,6 +34,6 @@ "use strict"; | ||
{ | ||
V1: { parents: "1", interior: { X1: { Parachain: "2011" } } }, | ||
V2: { parents: "1", interior: { X1: { Parachain: "2011" } } }, | ||
}, | ||
{ | ||
V1: { | ||
V2: { | ||
parents: 0, | ||
@@ -46,3 +46,3 @@ interior: { | ||
{ | ||
V1: [ | ||
V2: [ | ||
{ | ||
@@ -49,0 +49,0 @@ id: { |
@@ -28,3 +28,3 @@ import * as tokens from "./tokens"; | ||
readonly args: readonly [{ | ||
readonly V1: { | ||
readonly V2: { | ||
readonly parents: "1"; | ||
@@ -38,3 +38,3 @@ readonly interior: { | ||
}, { | ||
readonly V1: { | ||
readonly V2: { | ||
readonly parents: 0; | ||
@@ -51,3 +51,3 @@ readonly interior: { | ||
}, { | ||
readonly V1: readonly [{ | ||
readonly V2: readonly [{ | ||
readonly id: { | ||
@@ -54,0 +54,0 @@ readonly Concrete: { |
@@ -9,29 +9,29 @@ "use strict"; | ||
const check_1 = require("../util/check"); | ||
const serializeFunction = (fn) => { | ||
return { | ||
func$: fn.toString(), | ||
}; | ||
}; | ||
console.log(JSON.stringify(config_1.default, (_, v) => { | ||
if (typeof v === "function") { | ||
return serializeFunction(v); | ||
} | ||
return v; | ||
}, 2)); | ||
const serialized = JSON.stringify(config_1.default.chains.statemint, (_, v) => { | ||
if (typeof v === "function") { | ||
return serializeFunction(v); | ||
} | ||
return v; | ||
}, 2); | ||
const deserialized = JSON.parse(serialized, (_, v) => { | ||
if ((0, check_1.hasKey)("func$", v)) { | ||
return new Function(`return ${v.func$}`)(); | ||
} | ||
return v; | ||
}); | ||
assert_1.default.deepStrictEqual(deserialized.getBalance("0x00", { asset: 1984 }), { | ||
section: "assets", | ||
method: "account", | ||
args: [1984, "0x00"], | ||
}); | ||
const serialize_1 = require("../util/serialize"); | ||
const typed_1 = require("../util/typed"); | ||
console.info("checking serialize -> deserialize consistency"); | ||
const BALANCE_METHOD = "getBalance"; | ||
const BALANCE_ARGS = ["0x00"]; | ||
(0, assert_1.default)((0, typed_1.getEntries)(config_1.default.tokens.crosschain).every(([chainName, tokens]) => { | ||
const chain = config_1.default.chains[chainName]; | ||
const serialized = JSON.stringify(chain, (_, v) => { | ||
if (typeof v === "function") { | ||
return (0, serialize_1.serializeFunction)(v); | ||
} | ||
return v; | ||
}, 2); | ||
const deserialized = JSON.parse(serialized, (_, v) => { | ||
if ((0, check_1.hasKey)("func$", v)) { | ||
return (0, serialize_1.deserializeFunction)({ func$: v.func$ }); | ||
} | ||
return v; | ||
}); | ||
return (0, typed_1.getEntries)(tokens).every(([tokenName, token]) => { | ||
const { context } = token; | ||
console.info(`chain ${chainName}, token ${tokenName}, context: ${JSON.stringify(context)}`); | ||
return [{ method: BALANCE_METHOD, args: BALANCE_ARGS }].every(({ method, args }) => { | ||
assert_1.default.deepStrictEqual(chain[method](...args, context), deserialized[method](...args, context), `chain[${method}](...${JSON.stringify(args)}) !== deserialized[${method}](...${JSON.stringify(args)})`); | ||
return true; | ||
}); | ||
}); | ||
})); |
{ | ||
"name": "@equilab/network", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"main": "./dist/index.js", | ||
@@ -5,0 +5,0 @@ "license": "none", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
675318
56
13701
0