Skip to content

Commit

Permalink
added missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
quetool committed Sep 11, 2024
1 parent 3747571 commit c89a80b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 15 deletions.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,26 @@ The communications protocol for web3, Reown brings the ecosystem together by ena

## License

Reown is released under the Apache 2.0 license. [See LICENSE](/LICENSE) for details.
Reown is released under the Apache 2.0 license. [See LICENSE](/LICENSE) for details.

### Run

1. Run `sh scripts/generate_all.sh` in the root folder to generate dependencies.
2. Run `cd packages/reown_walletkit/example`
3. Run `flutter run --dart-define=PROJECT_ID=0123... --flavor internal --debug`

You can add your own keys for testing purposes as follows:

`--dart-define=ETH_SECRET_KEY=your mnemonic phrase....`

`--dart-define=KADENA_SECRET_KEY=5fgQC1.........`

`--dart-define=KADENA_ADDRESS=5fgQC1.........`

`--dart-define=SOLANA_SECRET_KEY=5fgQC1.........`

`--dart-define=SOLANA_ADDRESS=DbfmtKwL.........`

`--dart-define=POLKADOT_MNEMONIC=your mnemonic phrase....`

`--dart-define=POLKADOT_ADDRESS=DbfmtKwL.........`
11 changes: 7 additions & 4 deletions packages/reown_appkit/lib/modal/constants/string_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ class UIConstants {

class StorageConstants {
// Storage
static const String recentWalletId = 'w3m_recentWallet';
static const String connectedWalletData = 'w3m_walletData';
static const String selectedChainId = 'w3m_selectedChainId';
static const String modalSession = 'w3m_session';
static const String recentWalletId =
'${CoreConstants.X_SDK_TYPE}_recentWallet';
static const String connectedWalletData =
'${CoreConstants.X_SDK_TYPE}_walletData';
static const String selectedChainId =
'${CoreConstants.X_SDK_TYPE}_selectedChainId';
static const String modalSession = '${CoreConstants.X_SDK_TYPE}_session';
}

class UrlConstants {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class KeyService extends IKeyService {
final prefs = await SharedPreferences.getInstance();
final keys = prefs.getKeys();
for (var key in keys) {
if (key.startsWith('w3w_')) {
if (key.startsWith('rwkt_')) {
await prefs.remove(key);
}
}
Expand All @@ -33,7 +33,7 @@ class KeyService extends IKeyService {
// ⚠️ WARNING: SharedPreferences is not the best way to store your keys! This is just for example purposes!
final prefs = await SharedPreferences.getInstance();
try {
final savedKeys = prefs.getStringList('w3w_chain_keys')!;
final savedKeys = prefs.getStringList('rwkt_chain_keys')!;
final chainKeys = savedKeys.map((e) => ChainKey.fromJson(jsonDecode(e)));
_keys = List<ChainKey>.from(chainKeys.toList());
//
Expand Down Expand Up @@ -77,22 +77,21 @@ class KeyService extends IKeyService {
@override
Future<String> getMnemonic() async {
final prefs = await SharedPreferences.getInstance();
return prefs.getString('w3w_mnemonic') ?? '';
return prefs.getString('rwkt_mnemonic') ?? '';
}

// ** bip39/bip32 - EIP155 **

@override
Future<void> loadDefaultWallet() async {
const mnemonic =
'spoil video deputy round immense setup wasp secret maze slight bag what';
const mnemonic = DartDefines.ethereumSecretKey;
await restoreWalletFromSeed(mnemonic: mnemonic);
}

@override
Future<void> createAddressFromSeed() async {
final prefs = await SharedPreferences.getInstance();
final mnemonic = prefs.getString('w3w_mnemonic')!;
final mnemonic = prefs.getString('rwkt_mnemonic')!;

final chainKeys = getKeysForChain('eip155');
final index = chainKeys.length;
Expand All @@ -109,8 +108,8 @@ class KeyService extends IKeyService {
Future<void> restoreWalletFromSeed({required String mnemonic}) async {
// ⚠️ WARNING: SharedPreferences is not the best way to store your keys! This is just for example purposes!
final prefs = await SharedPreferences.getInstance();
await prefs.remove('w3w_chain_keys');
await prefs.setString('w3w_mnemonic', mnemonic);
await prefs.remove('rwkt_chain_keys');
await prefs.setString('rwkt_mnemonic', mnemonic);

final keyPair = _keyPairFromMnemonic(mnemonic);
final chainKey = _eip155ChainKey(keyPair);
Expand All @@ -127,7 +126,7 @@ class KeyService extends IKeyService {
.where((k) => k.namespace == 'eip155')
.map((e) => jsonEncode(e.toJson()))
.toList();
await prefs.setStringList('w3w_chain_keys', chainKeys);
await prefs.setStringList('rwkt_chain_keys', chainKeys);
}

CryptoKeyPair _keyPairFromMnemonic(String mnemonic, {int index = 0}) {
Expand Down
8 changes: 7 additions & 1 deletion packages/reown_walletkit/example/lib/utils/dart_defines.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
class DartDefines {
static const projectId = String.fromEnvironment('PROJECT_ID');
// HARDCODED TEST KEYS
// ETHEREUM
static const ethereumSecretKey = String.fromEnvironment(
'ETH_SECRET_KEY',
defaultValue:
'spoil video deputy round immense setup wasp secret maze slight bag what',
);
// KADENA
static const kadenaSecretKey = String.fromEnvironment(
'KADENA_SECRET_KEY',
Expand All @@ -26,7 +32,7 @@ class DartDefines {
static const polkadotMnemonic = String.fromEnvironment(
'POLKADOT_MNEMONIC',
defaultValue:
'shove trumpet draw priority either tonight million worry dust vivid twelve solid',
'spoil video deputy round immense setup wasp secret maze slight bag what',
);
static const polkadotAddress = String.fromEnvironment(
'POLKADOT_ADDRESS',
Expand Down

0 comments on commit c89a80b

Please sign in to comment.