-
Notifications
You must be signed in to change notification settings - Fork 766
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: conf. TxV in Account, conf. string auto. all methods, fix unbdef… (
#1311) * fix: conf. TxV in Account, conf. string auto. all methods, fix unbdefined for known, docs * docs: docs * docs: adjust heading structure --------- Co-authored-by: Petar Penovic <[email protected]>
- Loading branch information
Showing
7 changed files
with
124 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--- | ||
sidebar_position: 2.1 | ||
--- | ||
|
||
# Configuration | ||
|
||
Starknet.js has behaviors that can be adjusted through its configurations: `config` and `logger`. | ||
|
||
## Config | ||
|
||
The core global configuration is a singleton object containing case-sensitive global default properties. | ||
Each property can be configured before the rest of the code is run to modify their corresponding behavior. | ||
When they overlap, constructor and method parameters have higher precedence over the global configuration defaults. | ||
Custom keys can also be used to store and use arbitrary values during runtime. | ||
|
||
```ts | ||
import { config } from 'starknet'; | ||
|
||
// Set existing or custom global property | ||
config.set('mode', 'DEFAULT'); | ||
|
||
// Retrieve entire configuration | ||
config.getAll(); | ||
|
||
// Retrieve single global property | ||
config.get('legacyMode'); | ||
|
||
// Update (merge) existing configuration with modified or custom property | ||
config.update({ logLevel: 'DEBUG', newKey: 'value' }); | ||
|
||
// Reset config to initial global configuration | ||
config.reset(); | ||
|
||
// Delete existing global property | ||
config.delete('newKey'); | ||
|
||
// Check existence of the global property | ||
config.hasKey('newKey'); | ||
``` | ||
|
||
### Global parameters and Default Global Configuration | ||
|
||
Default global configuration is the initial state that global configuration starts with. | ||
|
||
Details can be found in [global/constants.ts](https://github.com/starknet-io/starknet.js/blob/develop/src/global/constants.ts) | ||
|
||
```ts | ||
logLevel: 'INFO', // verbosity levels of the system logger, more details under logger | ||
accountTxVersion: ETransactionVersion.V2, // by default use V2 transactions in Account class instances | ||
legacyMode: false, // enable legacy transaction types (note: this could break the code depending on the Starknet version used by the network) | ||
``` | ||
|
||
## Logger | ||
|
||
Logger is a singleton object through which the Starknet.js logs are managed. | ||
|
||
Supported log levels: | ||
|
||
| | | | | ||
| :-----: | --- | ----------------------------- | | ||
| `DEBUG` | 5 | show all logs | | ||
| `INFO` | 4 | show INFO, WARN, ERROR, FATAL | | ||
| `WARN` | 3 | show WARN, ERROR, FATAL | | ||
| `ERROR` | 2 | show ERROR, FATAL | | ||
| `FATAL` | 1 | show only FATAL | | ||
| `OFF` | 0 | disable logs | | ||
|
||
```ts | ||
import { logger } from 'starknet'; | ||
|
||
// set custom log level (can also be done using global config) | ||
logger.setLogLevel('WARN'); | ||
|
||
// get current log level | ||
logger.getLogLevel(); | ||
|
||
// get a list of all verbosity modes that would be displayed with the current log level | ||
logger.getEnabledLogLevels(); | ||
``` | ||
|
||
Developers can also use it to add custom logs. | ||
|
||
```ts | ||
import { logger } from 'starknet'; | ||
|
||
logger.debug('Debug message', additionalDataObject); | ||
logger.info('Info message', additionalDataObject); | ||
logger.warn('Warn message', additionalDataObject); | ||
logger.error('Error message', additionalDataObject); | ||
logger.fatal('Fatal message', additionalDataObject); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters