@layerzerolabs/evm-sdks-core 3.0.16 → 3.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/index.cjs +4 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +4 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -35,15 +35,13 @@ var LayerZeroErrorParser = class {
|
|
|
35
35
|
try {
|
|
36
36
|
const interf = new ethers.utils.Interface(this.abi);
|
|
37
37
|
const parsed = interf.parseError(data);
|
|
38
|
-
if (!parsed)
|
|
39
|
-
return null;
|
|
38
|
+
if (!parsed) return null;
|
|
40
39
|
const { name: cause, args } = parsed;
|
|
41
40
|
const formattedArgs = [];
|
|
42
41
|
let message = `${cause}, `;
|
|
43
42
|
parsed.errorFragment.inputs.forEach(({ name: argName, type }, i) => {
|
|
44
43
|
formattedArgs.push({ param: argName, type, value: args[i]?.toString() ?? args[i] });
|
|
45
|
-
if (argName)
|
|
46
|
-
message += `${argName} `;
|
|
44
|
+
if (argName) message += `${argName} `;
|
|
47
45
|
message += `${args[i]}, `;
|
|
48
46
|
});
|
|
49
47
|
return { message: message.slice(0, -2), name: "LayerZeroContractError", cause, args: formattedArgs };
|
|
@@ -70,8 +68,7 @@ var LayerZeroErrorParser = class {
|
|
|
70
68
|
const error = this.parseContractError(data);
|
|
71
69
|
if (error) {
|
|
72
70
|
const lzErr = new LayerZeroContractError(error.message, error.cause, error.args);
|
|
73
|
-
if (cleanUpStackTrace)
|
|
74
|
-
Error.captureStackTrace(lzErr, cleanUpStackTrace);
|
|
71
|
+
if (cleanUpStackTrace) Error.captureStackTrace(lzErr, cleanUpStackTrace);
|
|
75
72
|
throw lzErr;
|
|
76
73
|
}
|
|
77
74
|
}
|
|
@@ -79,5 +76,5 @@ var LayerZeroErrorParser = class {
|
|
|
79
76
|
|
|
80
77
|
exports.LayerZeroContractError = LayerZeroContractError;
|
|
81
78
|
exports.LayerZeroErrorParser = LayerZeroErrorParser;
|
|
82
|
-
//# sourceMappingURL=
|
|
79
|
+
//# sourceMappingURL=index.cjs.map
|
|
83
80
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/error-parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/error-parser.ts"],"names":["utils"],"mappings":";;;;;AAmDa,IAAA,sBAAA,GAAN,cAAqC,KAAuB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgB/D,WAAA,CAAY,OAAiB,EAAA,KAAA,EAAe,IAA2B,EAAA;AACnE,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAO,GAAA,wBAAA;AACZ,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA;AACb,IAAA,IAAA,CAAK,IAAO,GAAA,IAAA;AAAA;AAEpB;AAKO,IAAM,uBAAN,MAA2B;AAAA;AAAA;AAAA;AAAA;AAAA,EAK9B,YAAmB,GAAU,EAAA;AAAV,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA;AAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQtB,mBAAmB,IAA2C,EAAA;AAClE,IAAI,IAAA;AACA,MAAA,MAAM,MAAS,GAAA,IAAIA,YAAM,CAAA,SAAA,CAAU,KAAK,GAAG,CAAA;AAC3C,MAAM,MAAA,MAAA,GAAS,MAAO,CAAA,UAAA,CAAW,IAAI,CAAA;AACrC,MAAI,IAAA,CAAC,QAAe,OAAA,IAAA;AACpB,MAAA,MAAM,EAAE,IAAA,EAAM,KAAO,EAAA,IAAA,EAAS,GAAA,MAAA;AAC9B,MAAA,MAAM,gBAAqC,EAAC;AAC5C,MAAI,IAAA,OAAA,GAAU,GAAG,KAAK,CAAA,EAA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,MAAM,MAAA,KAAA;AAAA;AACV;AAER","file":"index.cjs","sourcesContent":["import { utils } from 'ethers'\n\n/**\n * Interface representing a parsed LayerZero error.\n */\nexport interface LayerZeroParsedError {\n /**\n * The error message.\n */\n message: string\n /**\n * The name of the error.\n */\n name: string\n /**\n * The cause of the error.\n */\n cause: string\n /**\n * The arguments associated with the error.\n * @see {@link FormattedErrorArg}\n */\n args: FormattedErrorArg[]\n}\n\n/**\n * Type representing the ABI of a contract.\n */\nexport type Abi = ConstructorParameters<typeof utils.Interface>[0]\n\n/**\n * Interface representing a formatted error argument.\n */\nexport interface FormattedErrorArg {\n /**\n * The parameter name.\n */\n param: string | null\n /**\n * The type of the parameter.\n */\n type: string\n /**\n * The value of the parameter.\n */\n value: string\n}\n\n/**\n * Class representing a LayerZero contract error.\n */\nexport class LayerZeroContractError extends Error implements Error {\n /**\n * The arguments associated with the error.\n * @see {@link FormattedErrorArg}\n */\n public args: FormattedErrorArg[]\n /**\n * The cause of the error.\n */\n public cause: string\n /**\n * Creates an instance of LayerZeroContractError.\n * @param message The error message.\n * @param cause The cause of the error.\n * @param args The arguments associated with the error. {@link FormattedErrorArg}\n */\n constructor(message: string, cause: string, args: FormattedErrorArg[]) {\n super(message)\n this.name = 'LayerZeroContractError'\n this.cause = cause\n this.args = args\n }\n}\n\n/**\n * Class responsible for parsing errors related to LayerZero operations.\n */\nexport class LayerZeroErrorParser {\n /**\n * Creates an instance of LayerZeroErrorParser.\n * @param abi The error abi of the contracts that are interacted with.\n */\n constructor(public abi: Abi) {}\n\n /**\n * Parses a contract error from a given data string.\n * @param data The error data string to parse.\n * @returns The parsed error information or null if parsing fails.\n * @private\n */\n private parseContractError(data: string): LayerZeroParsedError | null {\n try {\n const interf = new utils.Interface(this.abi)\n const parsed = interf.parseError(data)\n if (!parsed) return null\n const { name: cause, args } = parsed\n const formattedArgs: FormattedErrorArg[] = []\n let message = `${cause}, `\n parsed.errorFragment.inputs.forEach(({ name: argName, type }, i) => {\n formattedArgs.push({ param: argName, type, value: args[i]?.toString() ?? args[i] })\n if (argName) message += `${argName} `\n message += `${args[i]}, `\n })\n return { message: message.slice(0, -2), name: 'LayerZeroContractError', cause, args: formattedArgs }\n } catch (error) {\n return null\n }\n }\n\n /**\n * Parses an error from a given data string.\n * @param data The error data string to parse.\n * @returns The parsed error information or null if the error is unrecognized.\n */\n public parse(data: string): LayerZeroParsedError | null {\n const error = this.parseContractError(data)\n // add more error parsers here as needed, for now only contract errors are supported\n return error\n }\n\n /**\n * Checks for a contract error in the given data string, throwing a `LayerZeroContractError` if one is found.\n * @param data The error data string to check.\n * @param cleanUpStackTrace An optional function to clean up the stack. This function and all function above in the stack will be excluded from the trace.\n * @throws {LayerZeroContractError} Throws a LayerZeroContractError if an error is found corresponding to the data string.\n */\n public check(data: string, cleanUpStackTrace?: (...args: any) => any): void {\n const error = this.parseContractError(data)\n if (error) {\n const lzErr = new LayerZeroContractError(error.message, error.cause, error.args)\n if (cleanUpStackTrace) Error.captureStackTrace(lzErr, cleanUpStackTrace)\n throw lzErr\n }\n }\n}\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -33,15 +33,13 @@ var LayerZeroErrorParser = class {
|
|
|
33
33
|
try {
|
|
34
34
|
const interf = new utils.Interface(this.abi);
|
|
35
35
|
const parsed = interf.parseError(data);
|
|
36
|
-
if (!parsed)
|
|
37
|
-
return null;
|
|
36
|
+
if (!parsed) return null;
|
|
38
37
|
const { name: cause, args } = parsed;
|
|
39
38
|
const formattedArgs = [];
|
|
40
39
|
let message = `${cause}, `;
|
|
41
40
|
parsed.errorFragment.inputs.forEach(({ name: argName, type }, i) => {
|
|
42
41
|
formattedArgs.push({ param: argName, type, value: args[i]?.toString() ?? args[i] });
|
|
43
|
-
if (argName)
|
|
44
|
-
message += `${argName} `;
|
|
42
|
+
if (argName) message += `${argName} `;
|
|
45
43
|
message += `${args[i]}, `;
|
|
46
44
|
});
|
|
47
45
|
return { message: message.slice(0, -2), name: "LayerZeroContractError", cause, args: formattedArgs };
|
|
@@ -68,13 +66,12 @@ var LayerZeroErrorParser = class {
|
|
|
68
66
|
const error = this.parseContractError(data);
|
|
69
67
|
if (error) {
|
|
70
68
|
const lzErr = new LayerZeroContractError(error.message, error.cause, error.args);
|
|
71
|
-
if (cleanUpStackTrace)
|
|
72
|
-
Error.captureStackTrace(lzErr, cleanUpStackTrace);
|
|
69
|
+
if (cleanUpStackTrace) Error.captureStackTrace(lzErr, cleanUpStackTrace);
|
|
73
70
|
throw lzErr;
|
|
74
71
|
}
|
|
75
72
|
}
|
|
76
73
|
};
|
|
77
74
|
|
|
78
75
|
export { LayerZeroContractError, LayerZeroErrorParser };
|
|
79
|
-
//# sourceMappingURL=
|
|
76
|
+
//# sourceMappingURL=index.mjs.map
|
|
80
77
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/error-parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/error-parser.ts"],"names":[],"mappings":";;;AAmDa,IAAA,sBAAA,GAAN,cAAqC,KAAuB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgB/D,WAAA,CAAY,OAAiB,EAAA,KAAA,EAAe,IAA2B,EAAA;AACnE,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAO,GAAA,wBAAA;AACZ,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA;AACb,IAAA,IAAA,CAAK,IAAO,GAAA,IAAA;AAAA;AAEpB;AAKO,IAAM,uBAAN,MAA2B;AAAA;AAAA;AAAA;AAAA;AAAA,EAK9B,YAAmB,GAAU,EAAA;AAAV,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA;AAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQtB,mBAAmB,IAA2C,EAAA;AAClE,IAAI,IAAA;AACA,MAAA,MAAM,MAAS,GAAA,I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AAiD,EAAA;AACxE,IAAM,MAAA,KAAA,GAAQ,IAAK,CAAA,kBAAA,CAAmB,IAAI,CAAA;AAC1C,IAAA,IAAI,KAAO,EAAA;AACP,MAAM,MAAA,KAAA,GAAQ,IAAI,sBAAuB,CAAA,KAAA,CAAM,SAAS,KAAM,CAAA,KAAA,EAAO,MAAM,IAAI,CAAA;AAC/E,MAAA,IAAI,iBAAmB,EAAA,KAAA,CAAM,iBAAkB,CAAA,KAAA,EAAO,iBAAiB,CAAA;AACvE,MAAM,MAAA,KAAA;AAAA;AACV;AAER","file":"index.mjs","sourcesContent":["import { utils } from 'ethers'\n\n/**\n * Interface representing a parsed LayerZero error.\n */\nexport interface LayerZeroParsedError {\n /**\n * The error message.\n */\n message: string\n /**\n * The name of the error.\n */\n name: string\n /**\n * The cause of the error.\n */\n cause: string\n /**\n * The arguments associated with the error.\n * @see {@link FormattedErrorArg}\n */\n args: FormattedErrorArg[]\n}\n\n/**\n * Type representing the ABI of a contract.\n */\nexport type Abi = ConstructorParameters<typeof utils.Interface>[0]\n\n/**\n * Interface representing a formatted error argument.\n */\nexport interface FormattedErrorArg {\n /**\n * The parameter name.\n */\n param: string | null\n /**\n * The type of the parameter.\n */\n type: string\n /**\n * The value of the parameter.\n */\n value: string\n}\n\n/**\n * Class representing a LayerZero contract error.\n */\nexport class LayerZeroContractError extends Error implements Error {\n /**\n * The arguments associated with the error.\n * @see {@link FormattedErrorArg}\n */\n public args: FormattedErrorArg[]\n /**\n * The cause of the error.\n */\n public cause: string\n /**\n * Creates an instance of LayerZeroContractError.\n * @param message The error message.\n * @param cause The cause of the error.\n * @param args The arguments associated with the error. {@link FormattedErrorArg}\n */\n constructor(message: string, cause: string, args: FormattedErrorArg[]) {\n super(message)\n this.name = 'LayerZeroContractError'\n this.cause = cause\n this.args = args\n }\n}\n\n/**\n * Class responsible for parsing errors related to LayerZero operations.\n */\nexport class LayerZeroErrorParser {\n /**\n * Creates an instance of LayerZeroErrorParser.\n * @param abi The error abi of the contracts that are interacted with.\n */\n constructor(public abi: Abi) {}\n\n /**\n * Parses a contract error from a given data string.\n * @param data The error data string to parse.\n * @returns The parsed error information or null if parsing fails.\n * @private\n */\n private parseContractError(data: string): LayerZeroParsedError | null {\n try {\n const interf = new utils.Interface(this.abi)\n const parsed = interf.parseError(data)\n if (!parsed) return null\n const { name: cause, args } = parsed\n const formattedArgs: FormattedErrorArg[] = []\n let message = `${cause}, `\n parsed.errorFragment.inputs.forEach(({ name: argName, type }, i) => {\n formattedArgs.push({ param: argName, type, value: args[i]?.toString() ?? args[i] })\n if (argName) message += `${argName} `\n message += `${args[i]}, `\n })\n return { message: message.slice(0, -2), name: 'LayerZeroContractError', cause, args: formattedArgs }\n } catch (error) {\n return null\n }\n }\n\n /**\n * Parses an error from a given data string.\n * @param data The error data string to parse.\n * @returns The parsed error information or null if the error is unrecognized.\n */\n public parse(data: string): LayerZeroParsedError | null {\n const error = this.parseContractError(data)\n // add more error parsers here as needed, for now only contract errors are supported\n return error\n }\n\n /**\n * Checks for a contract error in the given data string, throwing a `LayerZeroContractError` if one is found.\n * @param data The error data string to check.\n * @param cleanUpStackTrace An optional function to clean up the stack. This function and all function above in the stack will be excluded from the trace.\n * @throws {LayerZeroContractError} Throws a LayerZeroContractError if an error is found corresponding to the data string.\n */\n public check(data: string, cleanUpStackTrace?: (...args: any) => any): void {\n const error = this.parseContractError(data)\n if (error) {\n const lzErr = new LayerZeroContractError(error.message, error.cause, error.args)\n if (cleanUpStackTrace) Error.captureStackTrace(lzErr, cleanUpStackTrace)\n throw lzErr\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/evm-sdks-core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.17",
|
|
4
4
|
"license": "BUSL-1.1",
|
|
5
5
|
"exports": {
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"ethers": "^5.7.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@layerzerolabs/tsup-config-next": "^3.0.
|
|
27
|
-
"@layerzerolabs/typescript-config-next": "^3.0.
|
|
26
|
+
"@layerzerolabs/tsup-config-next": "^3.0.17",
|
|
27
|
+
"@layerzerolabs/typescript-config-next": "^3.0.17",
|
|
28
28
|
"@types/jest": "^29.5.10",
|
|
29
29
|
"@types/node": "^20.10.5",
|
|
30
30
|
"jest": "^29.7.0",
|
|
31
31
|
"rimraf": "^5.0.5",
|
|
32
32
|
"ts-jest": "^29.1.1",
|
|
33
|
-
"tsup": "^8.
|
|
33
|
+
"tsup": "^8.3.5",
|
|
34
34
|
"typescript": "~5.2.2"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|