fix(docs): Add proper descriptions to module READMEs (#2490)

This commit is contained in:
T145
2025-12-02 02:47:08 +01:00
committed by GitHub
parent a3774ae5c0
commit 3e4409d2ba
14 changed files with 475 additions and 244 deletions
+53 -29
View File
@@ -1,39 +1,63 @@
<!--
This README describes the package. If you publish this package to pub.dev,
this README's contents appear on the landing page for your package.
## cw_polygon
For information about how to write a good package README, see the guide for
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).
Polygon (PoS) wallet module built on the shared EVM base (`cw_evm`). Supports native MATIC and ERC‑20 tokens with PolygonScan-backed history.
For general information about developing packages, see the Dart guide for
[creating packages](https://dart.dev/guides/libraries/create-library-packages)
and the Flutter guide for
[developing packages and plugins](https://flutter.dev/developing-packages).
-->
### Features
TODO: Put a short description of the package here that helps potential users
know whether this package might be useful for them.
- EVM chain integration (chainId 137) with `web3dart`.
- Default ERC‑20 token list and per‑wallet token box.
- History via Etherscan v2 API (Polygon chain id) and internal tx support.
- Fee handling tuned for Polygon (priority fee floor, legacy gasPrice when needed).
- Create/sign native and ERC‑20 transfers; approvals; send/broadcast.
- Manage tokens (enable/disable, add/remove) and balances.
- Message signing and verification.
## Features
### Getting started
TODO: List what your package can do. Maybe include images, gifs, or videos.
## Getting started
TODO: List prerequisites and provide or point to information on how to
start using the package.
## Usage
TODO: Include short and useful examples for package users. Add longer examples
to `/example` folder.
Provide secrets used by the shared EVM layer in `cw_evm/lib/.secrets.g.dart`:
```dart
const like = 'sample';
// cw_evm/lib/.secrets.g.dart (DO NOT COMMIT)
const String etherScanApiKey = 'YOUR_ETHERSCAN_KEY';
const String nowNodesApiKey = 'YOUR_NOWNODES_KEY'; // if using matic.nownodes.io
const String moralisApiKey = 'YOUR_MORALIS_KEY'; // optional: ERC20 metadata
```
## Additional information
Connect and sync:
TODO: Tell users more about the package: where to find more information, how to
contribute to the package, how to file issues, what response they can expect
from the package authors, and more.
```dart
final service = PolygonWalletService(walletInfoBox, true, client: PolygonClient());
final wallet = await service.create(EVMChainNewWalletCredentials(name: 'My POL', password: 'secret'));
await wallet.connectToNode(node: Node(uriRaw: 'polygon-rpc.com', isSSL: true));
await wallet.startSync();
```
### Usage
Send MATIC:
```dart
final pending = await wallet.createTransaction(
EVMChainTransactionCredentials.single(
address: '0x...',
cryptoAmount: '0.2',
currency: CryptoCurrency.maticpoly,
priority: EVMChainTransactionPriority.medium,
),
);
final hash = await pending.commit();
```
Add an ERC‑20 token and refresh balance:
```dart
final token = await wallet.getErc20Token('0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174', 'polygon'); // USDC
if (token != null) {
await wallet.addErc20Token(token);
}
```
### Additional information
- Toggle PolygonScan usage via shared preferences key `use_polygonscan`.
- See `lib/` for APIs: `PolygonClient`, `PolygonWallet`, `PolygonWalletService`.