1
+ /* eslint-disable no-underscore-dangle */
1
2
import type { FeeMarginPercentage } from '../types' ;
2
3
import { ETransactionVersion , RPCSPEC08 } from '../types/api' ;
4
+ import { ValuesType } from '../types/helpers/valuesType' ;
3
5
import type { LogLevel } from './logger.type' ;
4
6
5
7
export { IS_BROWSER } from '../utils/encode' ;
@@ -32,29 +34,6 @@ export const RANGE_FELT = range(ZERO, PRIME - 1n);
32
34
export const RANGE_I128 = range ( - ( 2n ** 127n ) , 2n ** 127n - 1n ) ;
33
35
export const RANGE_U128 = range ( ZERO , 2n ** 128n - 1n ) ;
34
36
35
- export enum BaseUrl {
36
- SN_MAIN = 'https://alpha-mainnet.starknet.io' ,
37
- SN_SEPOLIA = 'https://alpha-sepolia.starknet.io' ,
38
- }
39
-
40
- export enum NetworkName {
41
- SN_MAIN = 'SN_MAIN' ,
42
- SN_SEPOLIA = 'SN_SEPOLIA' ,
43
- }
44
-
45
- export enum StarknetChainId {
46
- SN_MAIN = '0x534e5f4d41494e' , // encodeShortString('SN_MAIN'),
47
- SN_SEPOLIA = '0x534e5f5345504f4c4941' , // encodeShortString('SN_SEPOLIA')
48
- }
49
-
50
- export enum TransactionHashPrefix {
51
- DECLARE = '0x6465636c617265' , // encodeShortString('declare'),
52
- DEPLOY = '0x6465706c6f79' , // encodeShortString('deploy'),
53
- DEPLOY_ACCOUNT = '0x6465706c6f795f6163636f756e74' , // encodeShortString('deploy_account'),
54
- INVOKE = '0x696e766f6b65' , // encodeShortString('invoke'),
55
- L1_HANDLER = '0x6c315f68616e646c6572' , // encodeShortString('l1_handler'),
56
- }
57
-
58
37
export const UDC = {
59
38
ADDRESS : '0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf' ,
60
39
ENTRYPOINT : 'deployContract' ,
@@ -72,14 +51,48 @@ export const HARDENING_BYTE = 128;
72
51
// 0x80000000
73
52
export const HARDENING_4BYTES = 2147483648n ;
74
53
54
+ // NOTE: the enum alias exports are made so both the 'const' and 'type' are reachable in the published '.d.ts' file,
55
+ // otherwise the last export hides the preceding export with the same name in this file
56
+ const _BaseUrl = {
57
+ SN_MAIN : 'https://alpha-mainnet.starknet.io' ,
58
+ SN_SEPOLIA : 'https://alpha-sepolia.starknet.io' ,
59
+ } as const ;
60
+ type _BaseUrl = ValuesType < typeof _BaseUrl > ;
61
+ export { _BaseUrl as BaseUrl } ;
62
+
63
+ const _NetworkName = {
64
+ SN_MAIN : 'SN_MAIN' ,
65
+ SN_SEPOLIA : 'SN_SEPOLIA' ,
66
+ } as const ;
67
+ type _NetworkName = ValuesType < typeof _NetworkName > ;
68
+ export { _NetworkName as NetworkName } ;
69
+
70
+ const _StarknetChainId = {
71
+ SN_MAIN : '0x534e5f4d41494e' , // encodeShortString('SN_MAIN'),
72
+ SN_SEPOLIA : '0x534e5f5345504f4c4941' , // encodeShortString('SN_SEPOLIA')
73
+ } as const ;
74
+ type _StarknetChainId = ValuesType < typeof _StarknetChainId > ;
75
+ export { _StarknetChainId as StarknetChainId } ;
76
+
77
+ const _TransactionHashPrefix = {
78
+ DECLARE : '0x6465636c617265' , // encodeShortString('declare'),
79
+ DEPLOY : '0x6465706c6f79' , // encodeShortString('deploy'),
80
+ DEPLOY_ACCOUNT : '0x6465706c6f795f6163636f756e74' , // encodeShortString('deploy_account'),
81
+ INVOKE : '0x696e766f6b65' , // encodeShortString('invoke'),
82
+ L1_HANDLER : '0x6c315f68616e646c6572' , // encodeShortString('l1_handler'),
83
+ } as const ;
84
+ type _TransactionHashPrefix = ValuesType < typeof _TransactionHashPrefix > ;
85
+ export { _TransactionHashPrefix as TransactionHashPrefix } ;
86
+
75
87
/**
76
- * dot formate rpc versions
88
+ * dot format rpc versions
77
89
*/
78
- export const SupportedRpcVersion = {
90
+ const _SupportedRpcVersion = {
79
91
0.7 : '0.7' ,
80
92
0.8 : '0.8' ,
81
93
} as const ;
82
- export type SupportedRpcVersion = ( typeof SupportedRpcVersion ) [ keyof typeof SupportedRpcVersion ] ;
94
+ type _SupportedRpcVersion = ValuesType < typeof _SupportedRpcVersion > ;
95
+ export { _SupportedRpcVersion as SupportedRpcVersion } ;
83
96
84
97
export type SupportedTransactionVersion =
85
98
| typeof ETransactionVersion . V2
@@ -89,7 +102,7 @@ export type SupportedTransactionVersion =
89
102
export const DEFAULT_GLOBAL_CONFIG : {
90
103
legacyMode : boolean ;
91
104
logLevel : LogLevel ;
92
- rpcVersion : SupportedRpcVersion ;
105
+ rpcVersion : _SupportedRpcVersion ;
93
106
transactionVersion : SupportedTransactionVersion ;
94
107
feeMarginPercentage : FeeMarginPercentage ;
95
108
} = {
0 commit comments