@sudobility/types 1.9.53 → 1.9.55
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/types/blockchain/index.cjs +30 -0
- package/dist/types/blockchain/index.d.ts +14 -0
- package/dist/types/blockchain/index.d.ts.map +1 -0
- package/dist/types/blockchain/index.js +30 -0
- package/dist/types/blockchain/index.js.map +1 -0
- package/dist/types/blockchain/validation.cjs +57 -1
- package/dist/types/blockchain/validation.d.ts +57 -1
- package/dist/types/blockchain/validation.d.ts.map +1 -1
- package/dist/types/blockchain/validation.js +57 -1
- package/dist/types/blockchain/validation.js.map +1 -1
- package/dist/types/business/enums.cjs +110 -25
- package/dist/types/business/enums.d.ts +110 -2
- package/dist/types/business/enums.d.ts.map +1 -1
- package/dist/types/business/enums.js +110 -25
- package/dist/types/business/enums.js.map +1 -1
- package/dist/types/common.cjs +7 -1
- package/dist/types/common.d.ts +134 -20
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js +7 -1
- package/dist/types/common.js.map +1 -1
- package/dist/utils/async-helpers.cjs +124 -10
- package/dist/utils/async-helpers.d.ts +129 -8
- package/dist/utils/async-helpers.d.ts.map +1 -1
- package/dist/utils/async-helpers.js +124 -10
- package/dist/utils/async-helpers.js.map +1 -1
- package/dist/utils/formatting/currency.cjs +5 -2
- package/dist/utils/formatting/currency.d.ts +5 -1
- package/dist/utils/formatting/currency.d.ts.map +1 -1
- package/dist/utils/formatting/currency.js +5 -2
- package/dist/utils/formatting/currency.js.map +1 -1
- package/dist/utils/formatting/date.cjs +67 -8
- package/dist/utils/formatting/date.d.ts +67 -8
- package/dist/utils/formatting/date.d.ts.map +1 -1
- package/dist/utils/formatting/date.js +67 -8
- package/dist/utils/formatting/date.js.map +1 -1
- package/dist/utils/formatting/string.cjs +150 -17
- package/dist/utils/formatting/string.d.ts +150 -17
- package/dist/utils/formatting/string.d.ts.map +1 -1
- package/dist/utils/formatting/string.js +150 -17
- package/dist/utils/formatting/string.js.map +1 -1
- package/dist/utils/validation/type-validation.cjs +94 -11
- package/dist/utils/validation/type-validation.d.ts +94 -11
- package/dist/utils/validation/type-validation.d.ts.map +1 -1
- package/dist/utils/validation/type-validation.js +94 -11
- package/dist/utils/validation/type-validation.js.map +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Blockchain types entry point.
|
|
4
|
+
*
|
|
5
|
+
* Import from `@sudobility/types/blockchain` to load only blockchain-
|
|
6
|
+
* related types, interfaces, enums, and validators without pulling in
|
|
7
|
+
* the rest of the library.
|
|
8
|
+
*
|
|
9
|
+
* @since 1.9.54
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.validateMessage = exports.validateDomain = exports.validateAmount = exports.validateAddress = exports.isSolanaRecipient = exports.isSolanaAddress = exports.isEvmRecipient = exports.isEvmAddress = exports.TransactionStatus = exports.PROTOCOL_CONSTANTS = exports.MessageType = void 0;
|
|
13
|
+
// Enums and constants
|
|
14
|
+
var common_1 = require("./common");
|
|
15
|
+
Object.defineProperty(exports, "MessageType", { enumerable: true, get: function () { return common_1.MessageType; } });
|
|
16
|
+
Object.defineProperty(exports, "PROTOCOL_CONSTANTS", { enumerable: true, get: function () { return common_1.PROTOCOL_CONSTANTS; } });
|
|
17
|
+
Object.defineProperty(exports, "TransactionStatus", { enumerable: true, get: function () { return common_1.TransactionStatus; } });
|
|
18
|
+
// Type guards
|
|
19
|
+
var common_2 = require("./common");
|
|
20
|
+
Object.defineProperty(exports, "isEvmAddress", { enumerable: true, get: function () { return common_2.isEvmAddress; } });
|
|
21
|
+
Object.defineProperty(exports, "isEvmRecipient", { enumerable: true, get: function () { return common_2.isEvmRecipient; } });
|
|
22
|
+
Object.defineProperty(exports, "isSolanaAddress", { enumerable: true, get: function () { return common_2.isSolanaAddress; } });
|
|
23
|
+
Object.defineProperty(exports, "isSolanaRecipient", { enumerable: true, get: function () { return common_2.isSolanaRecipient; } });
|
|
24
|
+
// Validators
|
|
25
|
+
var validation_1 = require("./validation");
|
|
26
|
+
Object.defineProperty(exports, "validateAddress", { enumerable: true, get: function () { return validation_1.validateAddress; } });
|
|
27
|
+
Object.defineProperty(exports, "validateAmount", { enumerable: true, get: function () { return validation_1.validateAmount; } });
|
|
28
|
+
Object.defineProperty(exports, "validateDomain", { enumerable: true, get: function () { return validation_1.validateDomain; } });
|
|
29
|
+
Object.defineProperty(exports, "validateMessage", { enumerable: true, get: function () { return validation_1.validateMessage; } });
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Blockchain types entry point.
|
|
3
|
+
*
|
|
4
|
+
* Import from `@sudobility/types/blockchain` to load only blockchain-
|
|
5
|
+
* related types, interfaces, enums, and validators without pulling in
|
|
6
|
+
* the rest of the library.
|
|
7
|
+
*
|
|
8
|
+
* @since 1.9.54
|
|
9
|
+
*/
|
|
10
|
+
export type { ChainConfig, ClaimableRevenue, ClientConfig, DeploymentAddresses, FeeStructure, Message, MessageFilter, MessageRecipient, OperationError, PreparedMessage, RpcConfig, SendMessageOptions, TransactionResult, } from './common';
|
|
11
|
+
export { MessageType, PROTOCOL_CONSTANTS, TransactionStatus, } from './common';
|
|
12
|
+
export { isEvmAddress, isEvmRecipient, isSolanaAddress, isSolanaRecipient, } from './common';
|
|
13
|
+
export { validateAddress, validateAmount, validateDomain, validateMessage, } from './validation';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/blockchain/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,eAAe,EACf,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,GAChB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Blockchain types entry point.
|
|
4
|
+
*
|
|
5
|
+
* Import from `@sudobility/types/blockchain` to load only blockchain-
|
|
6
|
+
* related types, interfaces, enums, and validators without pulling in
|
|
7
|
+
* the rest of the library.
|
|
8
|
+
*
|
|
9
|
+
* @since 1.9.54
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.validateMessage = exports.validateDomain = exports.validateAmount = exports.validateAddress = exports.isSolanaRecipient = exports.isSolanaAddress = exports.isEvmRecipient = exports.isEvmAddress = exports.TransactionStatus = exports.PROTOCOL_CONSTANTS = exports.MessageType = void 0;
|
|
13
|
+
// Enums and constants
|
|
14
|
+
var common_1 = require("./common");
|
|
15
|
+
Object.defineProperty(exports, "MessageType", { enumerable: true, get: function () { return common_1.MessageType; } });
|
|
16
|
+
Object.defineProperty(exports, "PROTOCOL_CONSTANTS", { enumerable: true, get: function () { return common_1.PROTOCOL_CONSTANTS; } });
|
|
17
|
+
Object.defineProperty(exports, "TransactionStatus", { enumerable: true, get: function () { return common_1.TransactionStatus; } });
|
|
18
|
+
// Type guards
|
|
19
|
+
var common_2 = require("./common");
|
|
20
|
+
Object.defineProperty(exports, "isEvmAddress", { enumerable: true, get: function () { return common_2.isEvmAddress; } });
|
|
21
|
+
Object.defineProperty(exports, "isEvmRecipient", { enumerable: true, get: function () { return common_2.isEvmRecipient; } });
|
|
22
|
+
Object.defineProperty(exports, "isSolanaAddress", { enumerable: true, get: function () { return common_2.isSolanaAddress; } });
|
|
23
|
+
Object.defineProperty(exports, "isSolanaRecipient", { enumerable: true, get: function () { return common_2.isSolanaRecipient; } });
|
|
24
|
+
// Validators
|
|
25
|
+
var validation_1 = require("./validation");
|
|
26
|
+
Object.defineProperty(exports, "validateAddress", { enumerable: true, get: function () { return validation_1.validateAddress; } });
|
|
27
|
+
Object.defineProperty(exports, "validateAmount", { enumerable: true, get: function () { return validation_1.validateAmount; } });
|
|
28
|
+
Object.defineProperty(exports, "validateDomain", { enumerable: true, get: function () { return validation_1.validateDomain; } });
|
|
29
|
+
Object.defineProperty(exports, "validateMessage", { enumerable: true, get: function () { return validation_1.validateMessage; } });
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/blockchain/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAmBH,sBAAsB;AACtB,mCAIkB;AAHhB,qGAAA,WAAW,OAAA;AACX,4GAAA,kBAAkB,OAAA;AAClB,2GAAA,iBAAiB,OAAA;AAGnB,cAAc;AACd,mCAKkB;AAJhB,sGAAA,YAAY,OAAA;AACZ,wGAAA,cAAc,OAAA;AACd,yGAAA,eAAe,OAAA;AACf,2GAAA,iBAAiB,OAAA;AAGnB,aAAa;AACb,2CAKsB;AAJpB,6GAAA,eAAe,OAAA;AACf,4GAAA,cAAc,OAAA;AACd,4GAAA,cAAc,OAAA;AACd,6GAAA,eAAe,OAAA"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Validation utilities for multi-chain operations
|
|
3
|
+
* Validation utilities for multi-chain operations.
|
|
4
|
+
* All validators throw on invalid input.
|
|
5
|
+
*
|
|
6
|
+
* @since 1.0.0
|
|
4
7
|
*/
|
|
5
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
9
|
exports.validateDomain = validateDomain;
|
|
@@ -8,6 +11,20 @@ exports.validateMessage = validateMessage;
|
|
|
8
11
|
exports.validateAddress = validateAddress;
|
|
9
12
|
exports.validateAmount = validateAmount;
|
|
10
13
|
const address_1 = require("../../utils/blockchain/address");
|
|
14
|
+
/**
|
|
15
|
+
* Validate a domain name format.
|
|
16
|
+
*
|
|
17
|
+
* @param domain - Domain string to validate
|
|
18
|
+
* @returns True if valid
|
|
19
|
+
* @throws Error if domain is empty, too long, or has invalid format
|
|
20
|
+
* @since 1.0.0
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* validateDomain('example.com'); // true
|
|
25
|
+
* validateDomain(''); // throws "Domain cannot be empty"
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
11
28
|
function validateDomain(domain) {
|
|
12
29
|
if (!domain || domain.length === 0) {
|
|
13
30
|
throw new Error('Domain cannot be empty');
|
|
@@ -22,6 +39,15 @@ function validateDomain(domain) {
|
|
|
22
39
|
}
|
|
23
40
|
return true;
|
|
24
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Validate a message subject and body against length constraints.
|
|
44
|
+
*
|
|
45
|
+
* @param subject - Message subject (max 200 chars)
|
|
46
|
+
* @param body - Message body (max 10000 chars)
|
|
47
|
+
* @returns True if valid
|
|
48
|
+
* @throws Error if subject or body is empty or exceeds limits
|
|
49
|
+
* @since 1.0.0
|
|
50
|
+
*/
|
|
25
51
|
function validateMessage(subject, body) {
|
|
26
52
|
if (!subject || subject.length === 0) {
|
|
27
53
|
throw new Error('Message subject cannot be empty');
|
|
@@ -37,6 +63,20 @@ function validateMessage(subject, body) {
|
|
|
37
63
|
}
|
|
38
64
|
return true;
|
|
39
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Validate a wallet address for a specific chain type.
|
|
68
|
+
*
|
|
69
|
+
* @param address - Wallet address to validate
|
|
70
|
+
* @param chainType - Target blockchain type (EVM or Solana)
|
|
71
|
+
* @returns True if valid
|
|
72
|
+
* @throws Error if address is empty or has invalid format
|
|
73
|
+
* @since 1.0.0
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* validateAddress('0x742d35Cc6634C0532925a3b844e2', ChainType.EVM);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
40
80
|
function validateAddress(address, chainType) {
|
|
41
81
|
if (!address || address.length === 0) {
|
|
42
82
|
throw new Error('Address cannot be empty');
|
|
@@ -46,6 +86,22 @@ function validateAddress(address, chainType) {
|
|
|
46
86
|
}
|
|
47
87
|
return true;
|
|
48
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Validate and convert an amount to a non-negative bigint.
|
|
91
|
+
* Accepts string, number, or bigint input.
|
|
92
|
+
*
|
|
93
|
+
* @param amount - Amount value to validate
|
|
94
|
+
* @returns The validated amount as bigint
|
|
95
|
+
* @throws Error if amount is invalid, non-numeric, or negative
|
|
96
|
+
* @since 1.0.0
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* validateAmount('1000'); // 1000n
|
|
101
|
+
* validateAmount(500); // 500n
|
|
102
|
+
* validateAmount(-1); // throws "Amount cannot be negative"
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
49
105
|
function validateAmount(amount) {
|
|
50
106
|
// Check for null, undefined, or empty string
|
|
51
107
|
if (amount === null ||
|
|
@@ -1,9 +1,65 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Validation utilities for multi-chain operations
|
|
2
|
+
* Validation utilities for multi-chain operations.
|
|
3
|
+
* All validators throw on invalid input.
|
|
4
|
+
*
|
|
5
|
+
* @since 1.0.0
|
|
3
6
|
*/
|
|
4
7
|
import { ChainType } from '../business/enums';
|
|
8
|
+
/**
|
|
9
|
+
* Validate a domain name format.
|
|
10
|
+
*
|
|
11
|
+
* @param domain - Domain string to validate
|
|
12
|
+
* @returns True if valid
|
|
13
|
+
* @throws Error if domain is empty, too long, or has invalid format
|
|
14
|
+
* @since 1.0.0
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* validateDomain('example.com'); // true
|
|
19
|
+
* validateDomain(''); // throws "Domain cannot be empty"
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
5
22
|
export declare function validateDomain(domain: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Validate a message subject and body against length constraints.
|
|
25
|
+
*
|
|
26
|
+
* @param subject - Message subject (max 200 chars)
|
|
27
|
+
* @param body - Message body (max 10000 chars)
|
|
28
|
+
* @returns True if valid
|
|
29
|
+
* @throws Error if subject or body is empty or exceeds limits
|
|
30
|
+
* @since 1.0.0
|
|
31
|
+
*/
|
|
6
32
|
export declare function validateMessage(subject: string, body: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Validate a wallet address for a specific chain type.
|
|
35
|
+
*
|
|
36
|
+
* @param address - Wallet address to validate
|
|
37
|
+
* @param chainType - Target blockchain type (EVM or Solana)
|
|
38
|
+
* @returns True if valid
|
|
39
|
+
* @throws Error if address is empty or has invalid format
|
|
40
|
+
* @since 1.0.0
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* validateAddress('0x742d35Cc6634C0532925a3b844e2', ChainType.EVM);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
7
47
|
export declare function validateAddress(address: string, chainType: ChainType): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Validate and convert an amount to a non-negative bigint.
|
|
50
|
+
* Accepts string, number, or bigint input.
|
|
51
|
+
*
|
|
52
|
+
* @param amount - Amount value to validate
|
|
53
|
+
* @returns The validated amount as bigint
|
|
54
|
+
* @throws Error if amount is invalid, non-numeric, or negative
|
|
55
|
+
* @since 1.0.0
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* validateAmount('1000'); // 1000n
|
|
60
|
+
* validateAmount(500); // 500n
|
|
61
|
+
* validateAmount(-1); // throws "Amount cannot be negative"
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
8
64
|
export declare function validateAmount(amount: string | number | bigint): bigint;
|
|
9
65
|
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/types/blockchain/validation.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/types/blockchain/validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CActD;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CActE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,SAAS,GACnB,OAAO,CAUT;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAwCvE"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Validation utilities for multi-chain operations
|
|
3
|
+
* Validation utilities for multi-chain operations.
|
|
4
|
+
* All validators throw on invalid input.
|
|
5
|
+
*
|
|
6
|
+
* @since 1.0.0
|
|
4
7
|
*/
|
|
5
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
9
|
exports.validateDomain = validateDomain;
|
|
@@ -8,6 +11,20 @@ exports.validateMessage = validateMessage;
|
|
|
8
11
|
exports.validateAddress = validateAddress;
|
|
9
12
|
exports.validateAmount = validateAmount;
|
|
10
13
|
const address_1 = require("../../utils/blockchain/address");
|
|
14
|
+
/**
|
|
15
|
+
* Validate a domain name format.
|
|
16
|
+
*
|
|
17
|
+
* @param domain - Domain string to validate
|
|
18
|
+
* @returns True if valid
|
|
19
|
+
* @throws Error if domain is empty, too long, or has invalid format
|
|
20
|
+
* @since 1.0.0
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* validateDomain('example.com'); // true
|
|
25
|
+
* validateDomain(''); // throws "Domain cannot be empty"
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
11
28
|
function validateDomain(domain) {
|
|
12
29
|
if (!domain || domain.length === 0) {
|
|
13
30
|
throw new Error('Domain cannot be empty');
|
|
@@ -22,6 +39,15 @@ function validateDomain(domain) {
|
|
|
22
39
|
}
|
|
23
40
|
return true;
|
|
24
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Validate a message subject and body against length constraints.
|
|
44
|
+
*
|
|
45
|
+
* @param subject - Message subject (max 200 chars)
|
|
46
|
+
* @param body - Message body (max 10000 chars)
|
|
47
|
+
* @returns True if valid
|
|
48
|
+
* @throws Error if subject or body is empty or exceeds limits
|
|
49
|
+
* @since 1.0.0
|
|
50
|
+
*/
|
|
25
51
|
function validateMessage(subject, body) {
|
|
26
52
|
if (!subject || subject.length === 0) {
|
|
27
53
|
throw new Error('Message subject cannot be empty');
|
|
@@ -37,6 +63,20 @@ function validateMessage(subject, body) {
|
|
|
37
63
|
}
|
|
38
64
|
return true;
|
|
39
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Validate a wallet address for a specific chain type.
|
|
68
|
+
*
|
|
69
|
+
* @param address - Wallet address to validate
|
|
70
|
+
* @param chainType - Target blockchain type (EVM or Solana)
|
|
71
|
+
* @returns True if valid
|
|
72
|
+
* @throws Error if address is empty or has invalid format
|
|
73
|
+
* @since 1.0.0
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* validateAddress('0x742d35Cc6634C0532925a3b844e2', ChainType.EVM);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
40
80
|
function validateAddress(address, chainType) {
|
|
41
81
|
if (!address || address.length === 0) {
|
|
42
82
|
throw new Error('Address cannot be empty');
|
|
@@ -46,6 +86,22 @@ function validateAddress(address, chainType) {
|
|
|
46
86
|
}
|
|
47
87
|
return true;
|
|
48
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Validate and convert an amount to a non-negative bigint.
|
|
91
|
+
* Accepts string, number, or bigint input.
|
|
92
|
+
*
|
|
93
|
+
* @param amount - Amount value to validate
|
|
94
|
+
* @returns The validated amount as bigint
|
|
95
|
+
* @throws Error if amount is invalid, non-numeric, or negative
|
|
96
|
+
* @since 1.0.0
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* validateAmount('1000'); // 1000n
|
|
101
|
+
* validateAmount(500); // 500n
|
|
102
|
+
* validateAmount(-1); // throws "Amount cannot be negative"
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
49
105
|
function validateAmount(amount) {
|
|
50
106
|
// Check for null, undefined, or empty string
|
|
51
107
|
if (amount === null ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/types/blockchain/validation.ts"],"names":[],"mappings":";AAAA;;
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/types/blockchain/validation.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAmBH,wCAcC;AAWD,0CAcC;AAgBD,0CAaC;AAkBD,wCAwCC;AA9ID,4DAAsE;AAEtE;;;;;;;;;;;;;GAaG;AACH,SAAgB,cAAc,CAAC,MAAc;IAC3C,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnC,MAAM,I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,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,YAAY,GAAG,EAAE,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -1,24 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Platform-agnostic enums for discrete states
|
|
4
|
-
* These replace string literals throughout the application
|
|
3
|
+
* Platform-agnostic enums for discrete states.
|
|
4
|
+
* These replace string literals throughout the application.
|
|
5
|
+
*
|
|
6
|
+
* @since 1.0.0
|
|
5
7
|
*/
|
|
6
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
9
|
exports.Currency = exports.ErrorType = exports.FeatureFlag = exports.EmailValidationState = exports.PlatformType = exports.ConnectionState = exports.ConnectionType = exports.EmailSortCriteria = exports.SortOrder = exports.EmailAddressType = exports.InfoType = exports.NotificationType = exports.RequestStatus = exports.SubscriptionAction = exports.EmailAction = exports.MediumView = exports.MobileView = exports.EmailComposeType = exports.FontSize = exports.Theme = exports.Chain = exports.ChainType = exports.AuthStatus = void 0;
|
|
8
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Authentication status of a wallet connection.
|
|
12
|
+
* @since 1.0.0
|
|
13
|
+
*/
|
|
9
14
|
var AuthStatus;
|
|
10
15
|
(function (AuthStatus) {
|
|
16
|
+
/** Wallet is connected but not yet verified via signature */
|
|
11
17
|
AuthStatus["CONNECTED"] = "connected";
|
|
18
|
+
/** Wallet is not connected */
|
|
12
19
|
AuthStatus["DISCONNECTED"] = "disconnected";
|
|
20
|
+
/** Wallet is connected and ownership is verified via signature */
|
|
13
21
|
AuthStatus["VERIFIED"] = "verified";
|
|
14
22
|
})(AuthStatus || (exports.AuthStatus = AuthStatus = {}));
|
|
15
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Blockchain family classification.
|
|
25
|
+
* @since 1.0.0
|
|
26
|
+
*/
|
|
16
27
|
var ChainType;
|
|
17
28
|
(function (ChainType) {
|
|
29
|
+
/** Ethereum Virtual Machine compatible chains */
|
|
18
30
|
ChainType["EVM"] = "evm";
|
|
31
|
+
/** Solana blockchain */
|
|
19
32
|
ChainType["SOLANA"] = "solana";
|
|
20
33
|
})(ChainType || (exports.ChainType = ChainType = {}));
|
|
21
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Supported blockchain networks across EVM and Solana ecosystems.
|
|
36
|
+
* Includes mainnets, testnets, and local development chains.
|
|
37
|
+
* @since 1.0.0
|
|
38
|
+
*/
|
|
22
39
|
var Chain;
|
|
23
40
|
(function (Chain) {
|
|
24
41
|
// Ethereum
|
|
@@ -110,21 +127,33 @@ var Chain;
|
|
|
110
127
|
Chain["EVM_LOCAL"] = "evm-local";
|
|
111
128
|
Chain["SOLANA_LOCAL"] = "solana-local";
|
|
112
129
|
})(Chain || (exports.Chain = Chain = {}));
|
|
113
|
-
|
|
130
|
+
/**
|
|
131
|
+
* UI theme preference.
|
|
132
|
+
* @since 1.0.0
|
|
133
|
+
*/
|
|
114
134
|
var Theme;
|
|
115
135
|
(function (Theme) {
|
|
136
|
+
/** Light color scheme */
|
|
116
137
|
Theme["LIGHT"] = "light";
|
|
138
|
+
/** Dark color scheme */
|
|
117
139
|
Theme["DARK"] = "dark";
|
|
140
|
+
/** Follow OS/system preference */
|
|
118
141
|
Theme["SYSTEM"] = "system";
|
|
119
142
|
})(Theme || (exports.Theme = Theme = {}));
|
|
120
|
-
|
|
143
|
+
/**
|
|
144
|
+
* UI font size preference.
|
|
145
|
+
* @since 1.2.0
|
|
146
|
+
*/
|
|
121
147
|
var FontSize;
|
|
122
148
|
(function (FontSize) {
|
|
123
149
|
FontSize["SMALL"] = "small";
|
|
124
150
|
FontSize["MEDIUM"] = "medium";
|
|
125
151
|
FontSize["LARGE"] = "large";
|
|
126
152
|
})(FontSize || (exports.FontSize = FontSize = {}));
|
|
127
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Email composition mode.
|
|
155
|
+
* @since 1.0.0
|
|
156
|
+
*/
|
|
128
157
|
var EmailComposeType;
|
|
129
158
|
(function (EmailComposeType) {
|
|
130
159
|
EmailComposeType["NEW"] = "new";
|
|
@@ -132,7 +161,10 @@ var EmailComposeType;
|
|
|
132
161
|
EmailComposeType["REPLY_ALL"] = "replyAll";
|
|
133
162
|
EmailComposeType["FORWARD"] = "forward";
|
|
134
163
|
})(EmailComposeType || (exports.EmailComposeType = EmailComposeType = {}));
|
|
135
|
-
|
|
164
|
+
/**
|
|
165
|
+
* Mobile navigation view states.
|
|
166
|
+
* @since 1.0.0
|
|
167
|
+
*/
|
|
136
168
|
var MobileView;
|
|
137
169
|
(function (MobileView) {
|
|
138
170
|
MobileView["EMAIL_ADDRESSES"] = "emailAddresses";
|
|
@@ -140,13 +172,19 @@ var MobileView;
|
|
|
140
172
|
MobileView["EMAILS"] = "emails";
|
|
141
173
|
MobileView["EMAIL_BODY"] = "emailBody";
|
|
142
174
|
})(MobileView || (exports.MobileView = MobileView = {}));
|
|
143
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Medium-screen (tablet) navigation pane selection.
|
|
177
|
+
* @since 1.0.0
|
|
178
|
+
*/
|
|
144
179
|
var MediumView;
|
|
145
180
|
(function (MediumView) {
|
|
146
181
|
MediumView["LEFT"] = "left";
|
|
147
182
|
MediumView["RIGHT"] = "right";
|
|
148
183
|
})(MediumView || (exports.MediumView = MediumView = {}));
|
|
149
|
-
|
|
184
|
+
/**
|
|
185
|
+
* Actions that can be performed on an email message.
|
|
186
|
+
* @since 1.0.0
|
|
187
|
+
*/
|
|
150
188
|
var EmailAction;
|
|
151
189
|
(function (EmailAction) {
|
|
152
190
|
EmailAction["OPEN"] = "open";
|
|
@@ -158,7 +196,10 @@ var EmailAction;
|
|
|
158
196
|
EmailAction["MARK_READ"] = "mark_read";
|
|
159
197
|
EmailAction["MARK_UNREAD"] = "mark_unread";
|
|
160
198
|
})(EmailAction || (exports.EmailAction = EmailAction = {}));
|
|
161
|
-
|
|
199
|
+
/**
|
|
200
|
+
* Subscription lifecycle actions.
|
|
201
|
+
* @since 1.3.0
|
|
202
|
+
*/
|
|
162
203
|
var SubscriptionAction;
|
|
163
204
|
(function (SubscriptionAction) {
|
|
164
205
|
SubscriptionAction["VIEW"] = "view";
|
|
@@ -166,15 +207,25 @@ var SubscriptionAction;
|
|
|
166
207
|
SubscriptionAction["CANCEL"] = "cancel";
|
|
167
208
|
SubscriptionAction["RESTORE"] = "restore";
|
|
168
209
|
})(SubscriptionAction || (exports.SubscriptionAction = SubscriptionAction = {}));
|
|
169
|
-
|
|
210
|
+
/**
|
|
211
|
+
* Network request lifecycle states.
|
|
212
|
+
* @since 1.0.0
|
|
213
|
+
*/
|
|
170
214
|
var RequestStatus;
|
|
171
215
|
(function (RequestStatus) {
|
|
216
|
+
/** No request in progress */
|
|
172
217
|
RequestStatus["IDLE"] = "idle";
|
|
218
|
+
/** Request is in flight */
|
|
173
219
|
RequestStatus["LOADING"] = "loading";
|
|
220
|
+
/** Request completed successfully */
|
|
174
221
|
RequestStatus["SUCCESS"] = "success";
|
|
222
|
+
/** Request failed */
|
|
175
223
|
RequestStatus["ERROR"] = "error";
|
|
176
224
|
})(RequestStatus || (exports.RequestStatus = RequestStatus = {}));
|
|
177
|
-
|
|
225
|
+
/**
|
|
226
|
+
* UI notification severity levels.
|
|
227
|
+
* @since 1.0.0
|
|
228
|
+
*/
|
|
178
229
|
var NotificationType;
|
|
179
230
|
(function (NotificationType) {
|
|
180
231
|
NotificationType["INFO"] = "info";
|
|
@@ -182,7 +233,10 @@ var NotificationType;
|
|
|
182
233
|
NotificationType["WARNING"] = "warning";
|
|
183
234
|
NotificationType["ERROR"] = "error";
|
|
184
235
|
})(NotificationType || (exports.NotificationType = NotificationType = {}));
|
|
185
|
-
|
|
236
|
+
/**
|
|
237
|
+
* Info-level UI feedback types.
|
|
238
|
+
* @since 1.0.0
|
|
239
|
+
*/
|
|
186
240
|
var InfoType;
|
|
187
241
|
(function (InfoType) {
|
|
188
242
|
InfoType["INFO"] = "info";
|
|
@@ -190,7 +244,10 @@ var InfoType;
|
|
|
190
244
|
InfoType["WARNING"] = "warning";
|
|
191
245
|
InfoType["ERROR"] = "error";
|
|
192
246
|
})(InfoType || (exports.InfoType = InfoType = {}));
|
|
193
|
-
|
|
247
|
+
/**
|
|
248
|
+
* Email address resolution types.
|
|
249
|
+
* @since 1.0.0
|
|
250
|
+
*/
|
|
194
251
|
var EmailAddressType;
|
|
195
252
|
(function (EmailAddressType) {
|
|
196
253
|
EmailAddressType["DIRECT"] = "direct";
|
|
@@ -198,13 +255,19 @@ var EmailAddressType;
|
|
|
198
255
|
EmailAddressType["SNS"] = "sns";
|
|
199
256
|
EmailAddressType["CUSTOM"] = "custom";
|
|
200
257
|
})(EmailAddressType || (exports.EmailAddressType = EmailAddressType = {}));
|
|
201
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Sort order direction.
|
|
260
|
+
* @since 1.0.0
|
|
261
|
+
*/
|
|
202
262
|
var SortOrder;
|
|
203
263
|
(function (SortOrder) {
|
|
204
264
|
SortOrder["ASC"] = "asc";
|
|
205
265
|
SortOrder["DESC"] = "desc";
|
|
206
266
|
})(SortOrder || (exports.SortOrder = SortOrder = {}));
|
|
207
|
-
|
|
267
|
+
/**
|
|
268
|
+
* Fields by which emails can be sorted.
|
|
269
|
+
* @since 1.0.0
|
|
270
|
+
*/
|
|
208
271
|
var EmailSortCriteria;
|
|
209
272
|
(function (EmailSortCriteria) {
|
|
210
273
|
EmailSortCriteria["DATE"] = "date";
|
|
@@ -212,7 +275,10 @@ var EmailSortCriteria;
|
|
|
212
275
|
EmailSortCriteria["FROM"] = "from";
|
|
213
276
|
EmailSortCriteria["SIZE"] = "size";
|
|
214
277
|
})(EmailSortCriteria || (exports.EmailSortCriteria = EmailSortCriteria = {}));
|
|
215
|
-
|
|
278
|
+
/**
|
|
279
|
+
* Network connection type (WiFi, cellular, etc.).
|
|
280
|
+
* @since 1.1.0
|
|
281
|
+
*/
|
|
216
282
|
var ConnectionType;
|
|
217
283
|
(function (ConnectionType) {
|
|
218
284
|
ConnectionType["UNKNOWN"] = "unknown";
|
|
@@ -224,7 +290,11 @@ var ConnectionType;
|
|
|
224
290
|
ConnectionType["CELLULAR_5G"] = "5g";
|
|
225
291
|
ConnectionType["ETHERNET"] = "ethernet";
|
|
226
292
|
})(ConnectionType || (exports.ConnectionType = ConnectionType = {}));
|
|
227
|
-
|
|
293
|
+
/**
|
|
294
|
+
* Wallet/network connection lifecycle states.
|
|
295
|
+
* Consolidated from WalletConnectionState, NetworkStatus, and ConnectionState.
|
|
296
|
+
* @since 1.0.0
|
|
297
|
+
*/
|
|
228
298
|
var ConnectionState;
|
|
229
299
|
(function (ConnectionState) {
|
|
230
300
|
ConnectionState["UNKNOWN"] = "unknown";
|
|
@@ -236,14 +306,20 @@ var ConnectionState;
|
|
|
236
306
|
ConnectionState["LIMITED"] = "limited";
|
|
237
307
|
ConnectionState["ERROR"] = "error";
|
|
238
308
|
})(ConnectionState || (exports.ConnectionState = ConnectionState = {}));
|
|
239
|
-
|
|
309
|
+
/**
|
|
310
|
+
* Runtime platform identification.
|
|
311
|
+
* @since 1.0.0
|
|
312
|
+
*/
|
|
240
313
|
var PlatformType;
|
|
241
314
|
(function (PlatformType) {
|
|
242
315
|
PlatformType["WEB"] = "web";
|
|
243
316
|
PlatformType["REACT_NATIVE"] = "react_native";
|
|
244
317
|
PlatformType["DESKTOP"] = "desktop";
|
|
245
318
|
})(PlatformType || (exports.PlatformType = PlatformType = {}));
|
|
246
|
-
|
|
319
|
+
/**
|
|
320
|
+
* Email address validation status.
|
|
321
|
+
* @since 1.0.0
|
|
322
|
+
*/
|
|
247
323
|
var EmailValidationState;
|
|
248
324
|
(function (EmailValidationState) {
|
|
249
325
|
EmailValidationState["VALID"] = "valid";
|
|
@@ -251,7 +327,10 @@ var EmailValidationState;
|
|
|
251
327
|
EmailValidationState["PENDING"] = "pending";
|
|
252
328
|
EmailValidationState["UNKNOWN"] = "unknown";
|
|
253
329
|
})(EmailValidationState || (exports.EmailValidationState = EmailValidationState = {}));
|
|
254
|
-
|
|
330
|
+
/**
|
|
331
|
+
* Feature flags for gating experimental or premium features.
|
|
332
|
+
* @since 1.2.0
|
|
333
|
+
*/
|
|
255
334
|
var FeatureFlag;
|
|
256
335
|
(function (FeatureFlag) {
|
|
257
336
|
FeatureFlag["AI_SEARCH"] = "ai_search";
|
|
@@ -261,7 +340,10 @@ var FeatureFlag;
|
|
|
261
340
|
FeatureFlag["NOTIFICATIONS"] = "notifications";
|
|
262
341
|
FeatureFlag["ANALYTICS"] = "analytics";
|
|
263
342
|
})(FeatureFlag || (exports.FeatureFlag = FeatureFlag = {}));
|
|
264
|
-
|
|
343
|
+
/**
|
|
344
|
+
* High-level error category classification.
|
|
345
|
+
* @since 1.0.0
|
|
346
|
+
*/
|
|
265
347
|
var ErrorType;
|
|
266
348
|
(function (ErrorType) {
|
|
267
349
|
ErrorType["NETWORK"] = "network";
|
|
@@ -270,7 +352,10 @@ var ErrorType;
|
|
|
270
352
|
ErrorType["PERMISSION"] = "permission";
|
|
271
353
|
ErrorType["UNKNOWN"] = "unknown";
|
|
272
354
|
})(ErrorType || (exports.ErrorType = ErrorType = {}));
|
|
273
|
-
|
|
355
|
+
/**
|
|
356
|
+
* Fiat currency codes for subscription pricing.
|
|
357
|
+
* @since 1.3.0
|
|
358
|
+
*/
|
|
274
359
|
var Currency;
|
|
275
360
|
(function (Currency) {
|
|
276
361
|
Currency["USD"] = "USD";
|