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

@layerzerolabs/lz-definitions

Package Overview
Dependencies
Maintainers
6
Versions
245
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@layerzerolabs/lz-definitions - npm Package Compare versions

Comparing version 1.5.2 to 1.5.3-robintest.1

dist/codec/index.d.ts

10

dist/constants/environment.js

@@ -36,2 +36,4 @@ "use strict";

[enums_1.EndpointId.SOLANA_MAINNET]: enums_1.Environment.MAINNET,
// v2
[enums_1.EndpointId.ETHEREUM_V2_MAINNET]: enums_1.Environment.MAINNET,
[enums_1.EndpointId.ETHEREUM_TESTNET]: enums_1.Environment.TESTNET,

@@ -69,2 +71,8 @@ [enums_1.EndpointId.BSC_TESTNET]: enums_1.Environment.TESTNET,

// [EndpointId.CANTO_TESTNET]: Environment.TESTNET,
// v2
[enums_1.EndpointId.ETHEREUM_V2_TESTNET]: enums_1.Environment.TESTNET,
[enums_1.EndpointId.POLYGON_V2_TESTNET]: enums_1.Environment.TESTNET,
[enums_1.EndpointId.SOLANA_V2_TESTNET]: enums_1.Environment.TESTNET,
[enums_1.EndpointId.ARBITRUM_V2_TESTNET]: enums_1.Environment.TESTNET,
[enums_1.EndpointId.OPTIMISM_V2_TESTNET]: enums_1.Environment.TESTNET,
[enums_1.EndpointId.ETHEREUM_SANDBOX]: enums_1.Environment.TESTNET,

@@ -75,3 +83,5 @@ [enums_1.EndpointId.BSC_SANDBOX]: enums_1.Environment.TESTNET,

[enums_1.EndpointId.APTOS_SANDBOX]: enums_1.Environment.DEVNET,
// v2
[enums_1.EndpointId.ETHEREUM_V2_SANDBOX]: enums_1.Environment.TESTNET,
};
//# sourceMappingURL=environment.js.map

22

dist/enums/endpoint-id.d.ts

@@ -72,4 +72,24 @@ export declare enum MainnetEndpointId {

}
export declare enum MainnetV2EndpointId {
ETHEREUM_V2_MAINNET = 30101
}
export declare enum TestnetV2EndpointId {
ETHEREUM_V2_TESTNET = 40121,
POLYGON_V2_TESTNET = 40109,
SOLANA_V2_TESTNET = 40168,
ARBITRUM_V2_TESTNET = 40143,
OPTIMISM_V2_TESTNET = 40132
}
export declare enum SandboxV2EndpointId {
ETHEREUM_V2_SANDBOX = 50121
}
export declare const EndpointId: {
[x: number]: string;
ETHEREUM_V2_SANDBOX: SandboxV2EndpointId.ETHEREUM_V2_SANDBOX;
ETHEREUM_V2_TESTNET: TestnetV2EndpointId.ETHEREUM_V2_TESTNET;
POLYGON_V2_TESTNET: TestnetV2EndpointId.POLYGON_V2_TESTNET;
SOLANA_V2_TESTNET: TestnetV2EndpointId.SOLANA_V2_TESTNET;
ARBITRUM_V2_TESTNET: TestnetV2EndpointId.ARBITRUM_V2_TESTNET;
OPTIMISM_V2_TESTNET: TestnetV2EndpointId.OPTIMISM_V2_TESTNET;
ETHEREUM_V2_MAINNET: MainnetV2EndpointId.ETHEREUM_V2_MAINNET;
BSC_SANDBOX: SandboxEndpointId.BSC_SANDBOX;

@@ -141,3 +161,3 @@ AVALANCHE_SANDBOX: SandboxEndpointId.AVALANCHE_SANDBOX;

};
export type EndpointId = MainnetEndpointId | TestnetEndpointId | SandboxEndpointId;
export type EndpointId = MainnetEndpointId | TestnetEndpointId | SandboxEndpointId | MainnetV2EndpointId | TestnetV2EndpointId | SandboxV2EndpointId;
//# sourceMappingURL=endpoint-id.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EndpointId = exports.SandboxEndpointId = exports.TestnetEndpointId = exports.MainnetEndpointId = void 0;
exports.EndpointId = exports.SandboxV2EndpointId = exports.TestnetV2EndpointId = exports.MainnetV2EndpointId = exports.SandboxEndpointId = exports.TestnetEndpointId = exports.MainnetEndpointId = void 0;
var MainnetEndpointId;

@@ -80,3 +80,26 @@ (function (MainnetEndpointId) {

})(SandboxEndpointId = exports.SandboxEndpointId || (exports.SandboxEndpointId = {}));
exports.EndpointId = { ...MainnetEndpointId, ...TestnetEndpointId, ...SandboxEndpointId };
var MainnetV2EndpointId;
(function (MainnetV2EndpointId) {
MainnetV2EndpointId[MainnetV2EndpointId["ETHEREUM_V2_MAINNET"] = 30101] = "ETHEREUM_V2_MAINNET";
})(MainnetV2EndpointId = exports.MainnetV2EndpointId || (exports.MainnetV2EndpointId = {}));
var TestnetV2EndpointId;
(function (TestnetV2EndpointId) {
TestnetV2EndpointId[TestnetV2EndpointId["ETHEREUM_V2_TESTNET"] = 40121] = "ETHEREUM_V2_TESTNET";
TestnetV2EndpointId[TestnetV2EndpointId["POLYGON_V2_TESTNET"] = 40109] = "POLYGON_V2_TESTNET";
TestnetV2EndpointId[TestnetV2EndpointId["SOLANA_V2_TESTNET"] = 40168] = "SOLANA_V2_TESTNET";
TestnetV2EndpointId[TestnetV2EndpointId["ARBITRUM_V2_TESTNET"] = 40143] = "ARBITRUM_V2_TESTNET";
TestnetV2EndpointId[TestnetV2EndpointId["OPTIMISM_V2_TESTNET"] = 40132] = "OPTIMISM_V2_TESTNET";
})(TestnetV2EndpointId = exports.TestnetV2EndpointId || (exports.TestnetV2EndpointId = {}));
var SandboxV2EndpointId;
(function (SandboxV2EndpointId) {
SandboxV2EndpointId[SandboxV2EndpointId["ETHEREUM_V2_SANDBOX"] = 50121] = "ETHEREUM_V2_SANDBOX";
})(SandboxV2EndpointId = exports.SandboxV2EndpointId || (exports.SandboxV2EndpointId = {}));
exports.EndpointId = {
...MainnetEndpointId,
...TestnetEndpointId,
...SandboxEndpointId,
...MainnetV2EndpointId,
...TestnetV2EndpointId,
...SandboxV2EndpointId,
};
//# sourceMappingURL=endpoint-id.js.map

5

dist/enums/network.d.ts
import { Chain } from './chain';
import { Stage } from './stage';
export type Network = `${Chain}-${Stage}` | `${Chain}-${Stage}-local`;
type NetworkV1 = `${Chain}-${Stage}` | `${Chain}-${Stage}-local`;
type NetworkV2 = `${Chain}-v2-${Stage}` | `${Chain}-v2-${Stage}-local`;
export type Network = NetworkV1 | NetworkV2;
export {};
//# sourceMappingURL=network.d.ts.map

@@ -1,7 +0,7 @@

import { Chain, ChainType, Environment, Stage } from '../enums';
export declare function networkToEndpointId(network: string): number;
export declare function networkToEnv(network: string): Environment;
import { Chain, ChainType, EndpointVersion, Environment, Stage } from '../enums';
export declare function networkToEndpointId(network: string, version: EndpointVersion): number;
export declare function networkToEnv(network: string, version: EndpointVersion): Environment;
export declare function networkToStage(network: string): Stage;
export declare function endpointIdToNetwork(endpointId: number): string;
export declare function chainAndStageToEndpointId(chain: Chain, stage: Stage): number;
export declare function chainAndStageToEndpointId(chain: Chain, stage: Stage, version: EndpointVersion): number;
export declare function chainAndStageToNetwork(chain: Chain, stage: Stage, env?: Environment): string;

@@ -16,2 +16,3 @@ export declare function networkToChain(network: string): Chain;

export declare function endpointIdToChain(endpointId: number): Chain;
export declare function endpointIdToStage(endpointId: number): Stage;
export declare function endpointIdToChainType(endpointId: number): ChainType;

@@ -18,0 +19,0 @@ export declare function getNetworksForStage(stage: Stage): string[];

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getNetworkForChainId = exports.getChainIdForNetwork = exports.getNetworksForStage = exports.endpointIdToChainType = exports.endpointIdToChain = exports.getChainType = exports.networkToChainType = exports.networkToChain = exports.chainAndStageToNetwork = exports.chainAndStageToEndpointId = exports.endpointIdToNetwork = exports.networkToStage = exports.networkToEnv = exports.networkToEndpointId = void 0;
exports.getNetworkForChainId = exports.getChainIdForNetwork = exports.getNetworksForStage = exports.endpointIdToChainType = exports.endpointIdToStage = exports.endpointIdToChain = exports.getChainType = exports.networkToChainType = exports.networkToChain = exports.chainAndStageToNetwork = exports.chainAndStageToEndpointId = exports.endpointIdToNetwork = exports.networkToStage = exports.networkToEnv = exports.networkToEndpointId = void 0;
const tiny_invariant_1 = __importDefault(require("tiny-invariant"));

@@ -12,5 +12,8 @@ const constants_1 = require("../constants");

const enums_1 = require("../enums");
function networkToEndpointId(network) {
function networkToEndpointId(network, version) {
const name = network.replace('-local', '');
const key = name.toUpperCase().replace('-', '_');
const [chain, stage] = name.split('-');
const key = version === enums_1.EndpointVersion.V1
? `${chain.toUpperCase()}_${stage.toUpperCase()}`
: `${chain.toUpperCase()}_V2_${stage.toUpperCase()}`;
const endpointId = enums_1.EndpointId[key];

@@ -21,7 +24,7 @@ (0, tiny_invariant_1.default)(endpointId, `Invalid network name: ${network}`);

exports.networkToEndpointId = networkToEndpointId;
function networkToEnv(network) {
function networkToEnv(network, version) {
if (network.includes('local') || network === 'hardhat') {
return enums_1.Environment.LOCAL;
}
const endpointId = networkToEndpointId(network);
const endpointId = networkToEndpointId(network, version);
return constants_1.ENVIRONMENT[endpointId];

@@ -39,9 +42,11 @@ }

(0, tiny_invariant_1.default)(key, `Invalid endpointId: ${endpointId}`);
return key.toLowerCase().replace('_', '-');
return key.toLowerCase().replace(/_/g, '-').replace('-v2', '');
}
exports.endpointIdToNetwork = endpointIdToNetwork;
function chainAndStageToEndpointId(chain, stage) {
const key = `${chain.toUpperCase()}_${stage.toUpperCase()}`;
function chainAndStageToEndpointId(chain, stage, version) {
const key = version === enums_1.EndpointVersion.V2
? `${chain.toUpperCase()}_V2_${stage.toUpperCase()}`
: `${chain.toUpperCase()}_${stage.toUpperCase()}`;
const endpointId = enums_1.EndpointId[key];
(0, tiny_invariant_1.default)(endpointId, `Invalid chain and stage: ${chain} ${stage}`);
(0, tiny_invariant_1.default)(endpointId, `Invalid key: ${key}`);
return endpointId;

@@ -92,2 +97,9 @@ }

exports.endpointIdToChain = endpointIdToChain;
function endpointIdToStage(endpointId) {
let key = enums_1.EndpointId[endpointId];
(0, tiny_invariant_1.default)(key, `Invalid endpointId: ${endpointId}`);
key = key.replace('_V2', '');
return key.split('_')[1].toLowerCase();
}
exports.endpointIdToStage = endpointIdToStage;
function endpointIdToChainType(endpointId) {

@@ -114,3 +126,3 @@ const chain = endpointIdToChain(endpointId);

function getChainIdForNetwork(chain, stage, ulnVersion) {
const endpointId = chainAndStageToEndpointId(chain, stage);
const endpointId = chainAndStageToEndpointId(chain, stage, enums_1.EndpointVersion.V1);
return (ulnVersion == '1' ? endpointId - ULN_V1_BIAS : endpointId).toString();

@@ -117,0 +129,0 @@ }

@@ -6,3 +6,4 @@ "use strict";

const utils_1 = require("./utils");
describe('ChainType', () => {
describe('Utility', () => {
// getChainType
globals_1.test.each([

@@ -18,3 +19,38 @@ // Chain, ChainFamily

});
// test chainAndStageToNetwork
globals_1.test.each([
// Chain, Stage, Network
[[enums_1.Chain.ETHEREUM, enums_1.Stage.MAINNET, enums_1.EndpointVersion.V1], 'ethereum-mainnet'],
[[enums_1.Chain.ETHEREUM, enums_1.Stage.MAINNET, enums_1.EndpointVersion.V2], 'ethereum-mainnet'],
[[enums_1.Chain.ETHEREUM, enums_1.Stage.MAINNET, enums_1.EndpointVersion.V1, enums_1.Environment.LOCAL], 'ethereum-mainnet-local'],
[[enums_1.Chain.ETHEREUM, enums_1.Stage.MAINNET, enums_1.EndpointVersion.V2, enums_1.Environment.LOCAL], 'ethereum-mainnet-local'],
])('chainAndStageToNetwork(%s, %s)', (params, network) => {
const valChain = params[0];
const valStage = params[1];
const valEnv = params.length > 3 ? params[3] : undefined;
const rv = (0, utils_1.chainAndStageToNetwork)(valChain, valStage, valEnv);
(0, globals_1.expect)(rv).toEqual(network);
});
// test chainAndStageToEndpointId
globals_1.test.each([
// Chain, Stage, EndpointId
[[enums_1.Chain.ETHEREUM, enums_1.Stage.MAINNET, enums_1.EndpointVersion.V1], enums_1.EndpointId.ETHEREUM_MAINNET],
[[enums_1.Chain.ETHEREUM, enums_1.Stage.MAINNET, enums_1.EndpointVersion.V2], enums_1.EndpointId.ETHEREUM_V2_MAINNET],
])('chainAndStageToEndpointId(%s, %s)', (params, endpointId) => {
const valChain = params[0];
const valStage = params[1];
const valVersion = params[2];
const rv = (0, utils_1.chainAndStageToEndpointId)(valChain, valStage, valVersion);
(0, globals_1.expect)(rv).toEqual(endpointId);
});
// test endpointIdToStage
globals_1.test.each([
// EndpointId, Stage
[enums_1.EndpointId.ETHEREUM_MAINNET, enums_1.Stage.MAINNET],
[enums_1.EndpointId.ETHEREUM_V2_MAINNET, enums_1.Stage.MAINNET],
])('endpointIdToStage(%s, %s)', (endpointId, stage) => {
const rv = (0, utils_1.endpointIdToStage)(endpointId);
(0, globals_1.expect)(rv).toEqual(stage);
});
});
//# sourceMappingURL=utils.test.js.map
{
"name": "@layerzerolabs/lz-definitions",
"version": "1.5.2",
"version": "1.5.3-robintest.1",
"description": "LayerZero Utility",

@@ -31,3 +31,4 @@ "license": "MIT",

"typescript": "^4.9.5"
}
},
"stableVersion": "1.5.3"
}

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

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

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