@rozoai/intent-common 0.1.8-beta.3 → 0.1.8
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/dist/assert.d.ts +24 -0
- package/dist/assert.js +24 -0
- package/dist/assert.js.map +1 -1
- package/dist/validation.js +13 -8
- package/dist/validation.js.map +1 -1
- package/package.json +1 -1
package/dist/assert.d.ts
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given condition is true, otherwise throws an error with a message.
|
|
3
|
+
*
|
|
4
|
+
* @param condition The condition to assert.
|
|
5
|
+
* @param args Optional additional messages or a function returning a message.
|
|
6
|
+
* @throws {Error} If the condition is falsy.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* assert(x > 0, "x must be positive");
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* assert(isValid(), () => `Validation failed for input`);
|
|
13
|
+
*/
|
|
1
14
|
export declare function assert(condition: boolean, ...args: any[]): asserts condition;
|
|
15
|
+
/**
|
|
16
|
+
* Asserts that the given value is neither null nor undefined.
|
|
17
|
+
*
|
|
18
|
+
* @param value The value to check.
|
|
19
|
+
* @param args Optional additional messages or a function returning a message.
|
|
20
|
+
* @returns The non-null, non-undefined value.
|
|
21
|
+
* @throws {Error} If the value is null or undefined.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const val = assertNotNull(maybeVal, "Value must not be null");
|
|
25
|
+
*/
|
|
2
26
|
export declare function assertNotNull<T>(value: T | null | undefined, ...args: any[]): T;
|
|
3
27
|
export declare function assertEqual<T>(a: T, b: T, ...args: any[]): void;
|
|
4
28
|
/** Used to compile-time check that switch statements are exhaustive, etc. */
|
package/dist/assert.js
CHANGED
|
@@ -5,6 +5,19 @@ exports.assertNotNull = assertNotNull;
|
|
|
5
5
|
exports.assertEqual = assertEqual;
|
|
6
6
|
exports.assertUnreachable = assertUnreachable;
|
|
7
7
|
const debug_1 = require("./debug");
|
|
8
|
+
/**
|
|
9
|
+
* Checks if the given condition is true, otherwise throws an error with a message.
|
|
10
|
+
*
|
|
11
|
+
* @param condition The condition to assert.
|
|
12
|
+
* @param args Optional additional messages or a function returning a message.
|
|
13
|
+
* @throws {Error} If the condition is falsy.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* assert(x > 0, "x must be positive");
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* assert(isValid(), () => `Validation failed for input`);
|
|
20
|
+
*/
|
|
8
21
|
function assert(condition, ...args) {
|
|
9
22
|
if (condition)
|
|
10
23
|
return;
|
|
@@ -17,6 +30,17 @@ function assert(condition, ...args) {
|
|
|
17
30
|
}
|
|
18
31
|
throw new Error("Assertion failed: " + msg);
|
|
19
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Asserts that the given value is neither null nor undefined.
|
|
35
|
+
*
|
|
36
|
+
* @param value The value to check.
|
|
37
|
+
* @param args Optional additional messages or a function returning a message.
|
|
38
|
+
* @returns The non-null, non-undefined value.
|
|
39
|
+
* @throws {Error} If the value is null or undefined.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* const val = assertNotNull(maybeVal, "Value must not be null");
|
|
43
|
+
*/
|
|
20
44
|
function assertNotNull(value, ...args) {
|
|
21
45
|
assert(value !== null && value !== undefined, ...args);
|
|
22
46
|
return value;
|
package/dist/assert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":";;AAeA,wBASC;AAaD,sCAMC;AAED,kCAEC;AAGD,8CAEC;AApDD,mCAAoC;AAEpC;;;;;;;;;;;;GAYG;AACH,SAAgB,MAAM,CAAC,SAAkB,EAAE,GAAG,IAAW;IACvD,IAAI,SAAS;QAAE,OAAO;IACtB,IAAI,GAAW,CAAC;IAChB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,EAAE,CAAC;QACvD,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IAClB,CAAC;SAAM,CAAC;QACN,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,iBAAS,EAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,aAAa,CAC3B,KAA2B,EAC3B,GAAG,IAAW;IAEd,MAAM,CAAC,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IACvD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,WAAW,CAAI,CAAI,EAAE,CAAI,EAAE,GAAG,IAAW;IACvD,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,6EAA6E;AAC7E,SAAgB,iBAAiB,CAAC,CAAQ;IACxC,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;AACjC,CAAC"}
|
package/dist/validation.js
CHANGED
|
@@ -33,15 +33,20 @@ function isValidStellarAddress(address) {
|
|
|
33
33
|
* Validates that an address matches the expected format for a given chain
|
|
34
34
|
*/
|
|
35
35
|
function validateAddressForChain(chainId, address) {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
try {
|
|
37
|
+
if (isChainSupported(chainId, "evm")) {
|
|
38
|
+
return !!(0, viem_1.getAddress)(address);
|
|
39
|
+
}
|
|
40
|
+
else if (isChainSupported(chainId, "solana")) {
|
|
41
|
+
return isValidSolanaAddress(address);
|
|
42
|
+
}
|
|
43
|
+
else if (isChainSupported(chainId, "stellar")) {
|
|
44
|
+
return isValidStellarAddress(address);
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
38
47
|
}
|
|
39
|
-
|
|
40
|
-
return
|
|
48
|
+
catch (error) {
|
|
49
|
+
return false;
|
|
41
50
|
}
|
|
42
|
-
else if (isChainSupported(chainId, "stellar")) {
|
|
43
|
-
return isValidStellarAddress(address);
|
|
44
|
-
}
|
|
45
|
-
return false;
|
|
46
51
|
}
|
|
47
52
|
//# sourceMappingURL=validation.js.map
|
package/dist/validation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":";;AAOA,4CAQC;AAED,4CAKC;AAGD,8CAEC;AAED,oDAGC;AAED,sDAEC;AAKD,
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":";;AAOA,4CAQC;AAED,4CAKC;AAGD,8CAEC;AAED,oDAGC;AAED,sDAEC;AAKD,0DAgBC;AAzDD,6CAA4C;AAC5C,sDAA+C;AAC/C,+BAAkC;AAClC,mCAAiD;AACjD,mCAAwC;AAExC,cAAc;AACd,SAAgB,gBAAgB,CAC9B,OAAe,EACf,IAAmC;IAEnC,OAAO,uBAAe,CAAC,IAAI,CACzB,CAAC,KAAY,EAAE,EAAE,CACf,KAAK,CAAC,OAAO,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CACnE,CAAC;AACJ,CAAC;AAED,SAAgB,gBAAgB,CAC9B,OAAe,EACf,YAAoB;IAEpB,OAAO,CAAC,CAAC,IAAA,qBAAa,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AAChD,CAAC;AAED,qBAAqB;AACrB,SAAgB,iBAAiB,CAAC,OAAe;IAC/C,OAAO,CAAC,C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