Skip to content

Commit 3a53133

Browse files
committed
updated the library reed me
1 parent 510b4ed commit 3a53133

File tree

6 files changed

+140
-47
lines changed

6 files changed

+140
-47
lines changed

README.md

Lines changed: 103 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ CNGnManager is a Python library for interacting with a CNGN API. It provides a s
77
- [Installation](#installation)
88
- [Usage](#usage)
99
- [Available Methods](#available-methods)
10+
- [cNGNManager Methods](#cngnmanager-methods)
11+
- [WalletManager Methods](#walletmanager-methods)
1012
- [Testing](#testing)
1113
- [Error Handling](#error-handling)
1214
- [Types](#types)
@@ -25,10 +27,10 @@ pip install cngn-manager
2527

2628
## Usage
2729

28-
First, import the `CNGnManager` class using it namespace WrappedCBDC\CNGNManager: and all necessary constants.
30+
First, import the `CNGnManager` `WalletManager` class using and all necessary constants.
2931

3032
```python
31-
from cngn_manager import CNGnManager, Network, ProviderType
33+
from cngn_manager import CNGnManager, WalletManager, Network, ProviderType, AssetType
3234
```
3335

3436
Then, create an instance of `CNGnManager` with your secrets:
@@ -51,52 +53,70 @@ balance = manager.get_balance()
5153
print(balance)
5254
```
5355

56+
## Networks
57+
58+
The library supports multiple blockchain networks:
59+
60+
- `Network.bsc` - Binance Smart Chain
61+
- `Network.atc` - Asset Chain
62+
- `Network.xbn` - Bantu Chain
63+
- `Network.eth` - Ethereum
64+
- `Network.matic` - Polygon (Matic)
65+
- `Network.trx` - Tron
66+
- `Network.base` - Base
67+
5468
## Available Methods
5569

56-
### Get Balance
70+
### cNGNManager Methods
71+
72+
#### Get Balance
5773

5874
```python
5975
balance = manager.get_balance()
6076
print(balance)
6177
```
6278

63-
### Get Transaction History
79+
#### Get Transaction History
6480

6581
```python
6682
transactions = manager.get_transaction_history()
6783
print(transactions)
6884

6985
```
7086

71-
### Swap Between Chains
87+
#### Swap Between Chains
7288

7389
```python
7490
swap_params = {
7591
"amount": 100,
7692
"address": "0x1234...",
77-
"network": Network.BSC
93+
"network": Network.BSC,
94+
"shouldSaveAddress": True
7895
}
7996

8097
swap_result = manager.swap_between_chains(swap_params)
8198
print(swap_result)
8299

83100
```
84101

85-
### Deposit for Redemption
102+
#### Redeem Asset
86103

87104
```python
88105
deposit_params = {
89106
"amount": 1000,
90-
"bank": "Example Bank",
91-
"accountNumber": "1234567890"
107+
"bankCode": "123",
108+
"accountNumber": "1234567890",
109+
"saveDetails": True
92110
}
93111

94112
deposit_result = manager.deposit_for_redemption(deposit_params)
95113
print(deposit_result)
96114

97115
```
98116

99-
### Create Virtual Account
117+
NOTE: to get bank codes please use the getBanks method to fetch the list of banks and ther codes
118+
119+
#### Create Virtual Account
100120

101121
```python
102122
mint_params = {
@@ -108,7 +128,9 @@ print(virtual_account)
108128

109129
```
110130

111-
### Generate Wallet Address
131+
NOTE: before creating the virtual account you need to have updated your BVN on the dashboard
132+
133+
#### Generate Wallet Address
112134

113135
```python
114136

@@ -117,20 +139,65 @@ print(wallet_address)
117139

118140
```
119141

120-
### Whitelist Address
142+
#### Update Business
143+
144+
Address Options:
145+
"xbnAddress": "string";
146+
"bscAddress": "string";
147+
"atcAddress": "string";
148+
"polygonAddress": "string";
149+
"ethAddress": "string";
150+
"tronAddress": "string";
151+
"baseAddress": "string";
152+
"bantuUserId": "string";
153+
121154

122155
```python
123-
whitelist_params = {
124-
"bscAddress": "0x1234...",
125-
"bankName": "Example Bank",
126-
"bankAccountNumber": "1234567890"
156+
updateData = {
157+
"walletAddress": {
158+
"bscAddress": "0x1234...",
159+
#other chain addresses...
160+
},
161+
"bankDetails": {
162+
"bankName": 'Test Bank',
163+
"bankAccountName": 'Test Account',
164+
"bankAccountNumber": '1234567890'
165+
}
127166
}
128167

129-
whitelist_result = manager.whitelist_address(whitelist_params)
130-
print(whitelist_result)
168+
updateResult = manager.update_external_accounts(updateData)
169+
print(updateResult)
170+
171+
```
172+
173+
#### Get banks
174+
```python
175+
176+
banklist = manager.get_banks(updateData)
177+
print(banklist)
131178

132179
```
133180

181+
182+
### WalletManager Methods
183+
184+
#### Generate Wallet Address
185+
```python
186+
wallet = WalletManager.generate_wallet_address(Network.bsc);
187+
```
188+
189+
Response format:
190+
```python
191+
{
192+
"mnemonic" : "string";
193+
"address": "string";
194+
"network": Network;
195+
"privateKey": "string";
196+
}
197+
```
198+
199+
200+
134201
## Testing
135202

136203
This project uses Jest for testing. To run the tests, follow these steps:
@@ -156,21 +223,34 @@ The tests are located in the `tests` directory. They cover various aspects of th
156223

157224
The library uses a custom error handling mechanism. All API errors are caught and thrown as `Error` objects with descriptive messages.
158225

159-
## Types
226+
## Constants
227+
228+
The library includes python constant classes for all parameters:
160229

161-
The library includes python definitions for all parameters and return types. Please refer to the type definitions in the source code for more details.
230+
- `Network` - token network
231+
- `AssetType` - Asset constants
232+
- `ProviderType` - provider constants
162233

163234
## Security
164235

165-
This library uses AES encryption for request payloads and Ed25519 decryption for response data. Ensure that your `encryptionKey` and `privateKey` are kept secure.
236+
- Uses AES encryption for request data
237+
- Implements Ed25519 decryption for responses
238+
- Requires secure storage of API credentials
166239

167240
## Contributing
168241

169-
Contributions, issues, and feature requests are welcome. Feel free to check [issues page](https://github.com/wrappedcbdc/cngn-python-library/issues) if you want to contribute.
242+
To contribute:
243+
1. Fork the repository
244+
2. Create a feature branch
245+
3. Commit your changes
246+
4. Create a Pull Request
170247

171248
## Support
172249

173-
If you have any questions or need help using the library, please open an issue in the GitHub repository.
250+
For support, please:
251+
- Open an issue in the GitHub repository
252+
- Check existing documentation
253+
- Contact the support team
174254

175255
## License
176256

cngn_manager/WalletManager.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from .CryptoWallet import CryptoWallet
2+
3+
class WalletManager:
4+
5+
def generate_wallet_address(self, network: str) -> str:
6+
response = CryptoWallet.generate_wallet_with_mnemonic_details(network)
7+
return {
8+
"success": True,
9+
"data": response
10+
}
11+
12+
def validate_address(self, address, network):
13+
return CryptoWallet.validate_address(address, network)

cngn_manager/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@
1212
1313
"""
1414

15-
from .main import CNGnManager
15+
from .main import CNGnManager
1616
from .constants import Network, ProviderType
17+
from .WalletManager import WalletManager
18+

cngn_manager/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
__title__ = "cngn_manager"
1111
__description__ = "Python HTTP for Humans."
1212
__url__ = "https://docs.cngn.co"
13-
__version__ = "0.0.5"
13+
__version__ = "1.0.0"
1414
__author__ = "Emmanuel Onyo"
1515
__author_email__ = "[email protected]"
1616
__license__ = "MIT License"

cngn_manager/constants.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ class Network:
55
MATIC = "matic"
66
TRX = "trx"
77
XBN = "xbn"
8+
BASE = "base"
89

9-
# Add other network options if necessary
10+
class AssetType:
11+
FIAT = "fiat"
12+
WRAPPED = "wrapped"
13+
ENAIRA = "enaira"
14+
15+
1016

1117
class ProviderType:
1218
KORAPAY = "korapay"
13-
FLUTTERWAVE = "Flutterwave"
19+
BUDPAY = "budpay"
1420
# Add other provider types as needed

cngn_manager/main.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
from requests.exceptions import RequestException, HTTPError
1414
from .AESCrypto import AESCrypto
1515
from .Ed25519Crypto import Ed25519Crypto
16-
from .CryptoWallet import CryptoWallet
17-
1816

1917
"""
2018
CNGnManager class is a wrapper around the CNGn API.
@@ -46,7 +44,7 @@ def __make_calls(self, method: str, endpoint: str, data: Optional[Dict[str, Any]
4644
ed_crypto = Ed25519Crypto()
4745

4846
try:
49-
url = f'{self.api_url}/{self.API_CURRENT_VERSION}{endpoint}'
47+
url = f'{self.api_url}/{self.API_CURRENT_VERSION}/api{endpoint}'
5048
request_data = self._prepare_request_data(data, aes_crypto)
5149
response = self._send_request(method, url, request_data)
5250
return self._process_response(response, ed_crypto)
@@ -91,29 +89,23 @@ def _handle_unexpected_error(self, error: Exception) -> Dict[str, Any]:
9189
}
9290

9391
def get_balance(self) -> str:
94-
return self.__make_calls("GET", "/api/balance")
92+
return self.__make_calls("GET", "/balance")
9593

9694
def get_transaction_history(self) -> str:
97-
return self.__make_calls("GET", "/api/transactions")
95+
return self.__make_calls("GET", "/transactions")
9896

9997
def swap_between_chains(self, data: dict) -> str:
100-
return self.__make_calls("POST", "/api/swap", data)
98+
return self.__make_calls("POST", "/swap", data)
10199

102-
def deposit_for_redemption(self, data: dict) -> str:
103-
return self.__make_calls("POST", "/api/deposit", data)
100+
def redeem_assets(self, data: dict) -> str:
101+
return self.__make_calls("POST", "/redeemAsset", data)
104102

105103
def create_virtual_account(self, data: dict) -> str:
106-
return self.__make_calls("POST", "/api/createVirtualAccount", data)
104+
return self.__make_calls("POST", "/createVirtualAccount", data)
107105

108-
def whitelist_address(self, data: dict) -> str:
109-
return self.__make_calls("POST", "/api/whiteListAddress", data)
106+
def update_external_accounts(self, data: dict) -> str:
107+
return self.__make_calls("POST", "/updateBusiness", data)
110108

111-
def generate_wallet_address(self, network: str) -> str:
112-
response = CryptoWallet.generate_wallet_with_mnemonic_details(network)
113-
return {
114-
"success": True,
115-
"data": response
116-
}
117-
118-
def validate_address(self, address, network):
119-
return CryptoWallet.validate_address(address, network)
109+
def get_banks(self):
110+
return self.__make_calls("GET", "/banks")
111+

0 commit comments

Comments
 (0)