-
Notifications
You must be signed in to change notification settings - Fork 0
Tchain Client against devnet #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 24 commits
Commits
Show all changes
123 commits
Select commit
Hold shift + click to select a range
84d4e25
add tfchain client pkg
AlaaElattar e93fcc2
add query contracts class
AlaaElattar d83f218
add queryClient modules
AlaaElattar f38dbd2
ignore generated dir in workflow
AlaaElattar bfe677a
exclude generated dir from linting
AlaaElattar 2414e97
fin path
AlaaElattar 462a181
fix build workflow
AlaaElattar 301cf65
fix workflow
AlaaElattar 2fbef97
fix build
AlaaElattar a63dd22
fix command
AlaaElattar 215b1c2
remove test dir in tfchain as it's empty
AlaaElattar 45ac438
add test for keypair from address
AlaaElattar a3645fc
remove unused import
AlaaElattar ba95fb6
add tfchain client
AlaaElattar b727132
support sr25519 and add dao model
AlaaElattar d60005c
improve client && balances module && linting workflow
AlaaElattar dbcd69d
add twins && T&C modules
AlaaElattar cce80f7
fix tests
AlaaElattar a2f5afa
fix bug in signer pkg
AlaaElattar 6ed2bee
remove await from sign&verify with hex seed test
AlaaElattar a151814
remove seed and hex seed tests
AlaaElattar 93eef89
add kvStore module
AlaaElattar b7fe839
add listall and delete all for kvStore
AlaaElattar 111c0c4
update git ignore
AlaaElattar 67fffdc
Merge branch 'main' of https://github.com/codescalers/tfgrid-sdk-dart…
AlaaElattar b4f4e54
add .vscode to gitignore
AlaaElattar 70cabcf
Delete .vscode directory
AlaaElattar 08bf396
remove gitignore from tfchain dir
AlaaElattar 2ffc52f
Merge branch 'main_signer_workflows_tfchain' of https://github.com/co…
AlaaElattar d7604d5
Delete packages/tfchain_client/build directory
AlaaElattar 60343bd
fix format in analysis options
AlaaElattar a36851a
remove anlysis options from inside tfchain dir
AlaaElattar 7ca24c2
fix melos analyze
AlaaElattar d88a34d
remove models && add parameters from function directly
AlaaElattar d069ed5
remove keypair from address function && test
AlaaElattar f8446d1
ignore pubspec
AlaaElattar 2600abe
fix getting balance add integration tests
AlaaElattar 5d5cab7
add tests to farms && nodes && pricing policies
AlaaElattar c9aa57c
add tests for query contracts
AlaaElattar 65ba465
add decoding events and transaction && fix transfer && working on con…
AlaaElattar 789b9c6
Fix creating name contracts
AhmedHanafy725 520a13e
Add method to filter my events
AhmedHanafy725 15a0192
Throw error in case of extrinsic failed
AhmedHanafy725 0b6c458
Validate that the extrisic success
AhmedHanafy725 5172d07
Wait for the extrinsic result
AhmedHanafy725 a5389e0
Fix twin class construction
AhmedHanafy725 8ac5388
Remove useless method
AhmedHanafy725 c86e675
Fix get my balance method
AhmedHanafy725 cec9065
Update bin script
AhmedHanafy725 682e7f1
Merge pull request #22 from codescalers/main_tfchain
AhmedHanafy725 30c2376
Apply better client interface using getters
AhmedHanafy725 4f0f1cc
Fix bin script to use the new client interface
AhmedHanafy725 946a56d
modify all methods with Client client
AlaaElattar 64dcd80
Merge branch 'main_signer_workflows_tfchain' into main_tfchain_interface
AhmedHanafy725 ad93da2
Merge pull request #23 from codescalers/main_tfchain_interface
AhmedHanafy725 21b3529
Add method to convert from dynamic list to unit8 list
AhmedHanafy725 aa1d83f
Add module error mapper
AhmedHanafy725 1524871
Use error mapper to have nicer code error
AhmedHanafy725 50ed15d
add integration tests for extrinsics except for contracts module
AlaaElattar 23ce369
Merge pull request #24 from codescalers/main_tfchain_errors
AhmedHanafy725 d949bfa
Add else statment for the extrinsic error in case it wasn't a module …
AhmedHanafy725 ff8d7ce
Fix balance transfer
AhmedHanafy725 2738d33
add contracts and balances tests
AlaaElattar 1b58439
Apply formatting on the repo
AhmedHanafy725 e9f7fd7
Merge branch 'main_signer_workflows_tfchain' into main_tfchain_fix_tr…
AhmedHanafy725 9d20db7
Exclude pubspec.yaml from the analysis options
AhmedHanafy725 71aeede
Merge pull request #25 from codescalers/main_tfchain_fix_transfer
AhmedHanafy725 0fb9a0e
fix tests
AlaaElattar 92249d7
fix Test Get Twin Id with account Id
AlaaElattar 5982488
fix workflow tests
AlaaElattar 952dea2
fix swap to stellar test
AlaaElattar 457eef7
add url, types and mnemonic in env vars
AlaaElattar acbfebf
add env vars in github workflows
AlaaElattar d5ef456
debug env vars
AlaaElattar c9497ca
fix workflow
AlaaElattar cec5123
fix workflow
AlaaElattar 8fb54a0
remove redundancy from coverage workflow file
AlaaElattar 879f7f5
remove printing secrets
AlaaElattar 64b4e75
add delay between create contract and cancel it && add tearDown in al…
AlaaElattar f121cc5
replace teardown with teardownAll
AlaaElattar 0d61bb0
remove provider=null in disconnect
AlaaElattar 813574b
fix swap to stellar test
AlaaElattar 31a5593
comment create contract then cancel it
AlaaElattar 5ce4437
add test for disconnect method
AlaaElattar 7794c62
change inblock to finalized
AlaaElattar 010b316
update tests with deleting contracts in teardownAll
AlaaElattar 24b95aa
update readme file
AlaaElattar c226c23
apply comments on code
AlaaElattar dedd5dd
apply comments on tests && fix liniting
AlaaElattar 38081e8
add shared data for all tests
AlaaElattar db2116e
make env vars in sharedSetup
AlaaElattar 490f818
fix linting
AlaaElattar 3eae9bf
update transfer test && add condition when connecting
AlaaElattar c8b4e5d
fix tests
AlaaElattar e7fccbe
remove my mnemonic from sharedSetup
AlaaElattar 0be5d2f
update generateRandomName function
AlaaElattar f1fc5c3
add generation types in readme
AlaaElattar b93141a
support hexseed when creating keypair
AlaaElattar 9e18500
improve coditions of signerType
AlaaElattar 303443b
apply pr comments
AlaaElattar 4adb732
return isValidSeed and use it
AlaaElattar 0b5c43f
make all feilds private
AlaaElattar d9b5a9c
fix bug
AlaaElattar 400e5e4
fix bug
AlaaElattar 0648c84
remove mnemonic from sharedSetup
AlaaElattar 6982bb0
modify tests to be against docker image of chain
AlaaElattar 5ae795b
remove network host
AlaaElattar 261f3ec
fix running image from workflow
AlaaElattar c2e8810
add -d to the docker command
AlaaElattar 29bf301
make setupAll at the beginning of file
AlaaElattar ede3f8a
apply pr comments
AlaaElattar 8b4ee0b
add null check on twin
AlaaElattar 2165a79
fix ip creation
AlaaElattar e7a5ba3
make setup manager singelton
AlaaElattar 3e6f10c
fix balances test
AlaaElattar 686b393
remove stopping docker from workflow
AlaaElattar d6bc18a
change tearDown to tearDownAll
AlaaElattar a8b12d4
support both initialization of clients from setupManager
AlaaElattar 0dfb3a6
update allowed public ips
AlaaElattar 10b4f49
set subnet mask to 24
AlaaElattar a4544f4
remove debugging logs
AlaaElattar fdc63cf
change condition to include Bob && remove commented code
AlaaElattar 6294c22
remove commented code from tests
AlaaElattar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -4,3 +4,4 @@ coverage/ | |
.dart_tool/ | ||
*.iml | ||
.idea/ | ||
package_config.json |
AlaaElattar marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,3 @@ | ||
{ | ||
"cSpell.words": ["keypair", "polkadot", "sublist", "tfchain", "TFKV", "twoxx"] | ||
} |
This file contains hidden or 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 hidden or 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,4 @@ | ||
include: package:lints/recommended.yaml | ||
|
||
analyzer: | ||
- exclude: packages/tfchain_client/lib/generated/** | ||
AlaaElattar marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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 hidden or 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 hidden or 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
Binary file modified
BIN
+456 Bytes
(100%)
...ages/signer/build/test_cache/build/c075001b96339384a97db4862b8ab8db.cache.dill.track.dill
Binary file not shown.
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -1,55 +1,94 @@ | ||
part of '../signer.dart'; | ||
// TODO: should return keypair or not ? | ||
|
||
|
||
class Signer { | ||
KeyPair? _keypair; | ||
KeyPair? keypair; | ||
KPType? _type; | ||
|
||
Future<void> fromMnemonic(String mnemonic) async { | ||
Future<KeyPair?> fromMnemonic(String mnemonic, KPType type) async { | ||
try { | ||
_keypair = await KeyPair.fromMnemonic(mnemonic); | ||
if (type.value == KPType.sr25519.value) { | ||
keypair = await KeyPair.sr25519.fromMnemonic(mnemonic); | ||
_type = KPType.sr25519; | ||
return keypair; | ||
} else if (type.value == KPType.ed25519.value) { | ||
keypair = await KeyPair.ed25519.fromMnemonic(mnemonic); | ||
_type = KPType.ed25519; | ||
return keypair; | ||
} else { | ||
throw Exception("Wrong KeyPair type !"); | ||
} | ||
} catch (e) { | ||
throw Exception("Failed to create keyPair from mnemonic. Error: $e"); | ||
} | ||
} | ||
|
||
Future<void> fromSeed(Uint8List seed) async { | ||
Future<KeyPair?> fromSeed(Uint8List seed, KPType type) async { | ||
try { | ||
_keypair = KeyPair.fromSeed(seed); | ||
if (type.value == KPType.sr25519.value) { | ||
keypair = await KeyPair.sr25519.fromSeed(seed); | ||
_type = KPType.sr25519; | ||
return keypair; | ||
} else if (type.value == KPType.ed25519.value) { | ||
keypair = await KeyPair.ed25519.fromSeed(seed); | ||
_type = KPType.ed25519; | ||
return keypair; | ||
} else { | ||
throw Exception("Wrong KeyPair type !"); | ||
} | ||
} catch (e) { | ||
throw Exception("Failed to create keyPair from seed. Error: $e"); | ||
} | ||
} | ||
|
||
Future<void> fromHexSeed(String hexSeed) async { | ||
void fromHexSeed(String hexSeed, KPType type) { | ||
try { | ||
final seed = HEX.decode(hexSeed.replaceAll('0x', '')); | ||
_keypair = KeyPair.fromSeed(Uint8List.fromList(seed)); | ||
if (type.value == KPType.sr25519.value) { | ||
keypair = KeyPair.sr25519.fromSeed(Uint8List.fromList(seed)); | ||
_type = KPType.sr25519; | ||
} else if (type.value == KPType.ed25519.value) { | ||
keypair = KeyPair.ed25519.fromSeed(Uint8List.fromList(seed)); | ||
_type = KPType.ed25519; | ||
} else { | ||
throw Exception("Wrong KeyPair type !"); | ||
} | ||
} catch (e) { | ||
throw Exception("Failed to create keyPair from hex seed. Error: $e"); | ||
} | ||
} | ||
|
||
Future<Uint8List> sign(String data) async { | ||
if (_keypair == null) { | ||
Uint8List sign(String data) { | ||
if (keypair == null) { | ||
throw Exception("keypair not initialized."); | ||
} | ||
try { | ||
final dataBytes = Uint8List.fromList(utf8.encode(data)); | ||
final signature = _keypair!.sign(dataBytes); | ||
final signature = keypair!.sign(dataBytes); | ||
return signature; | ||
} catch (e) { | ||
throw Exception("Failed to sign data. Error: $e"); | ||
} | ||
} | ||
|
||
Future<bool> verify(Uint8List signature, String data) async { | ||
if (_keypair == null) { | ||
bool verify(Uint8List signature, String data) { | ||
if (keypair == null) { | ||
throw Exception("keypair not initialized."); | ||
} | ||
try { | ||
final dataBytes = Uint8List.fromList(utf8.encode(data)); | ||
return _keypair!.verify(dataBytes, signature); | ||
return keypair!.verify(dataBytes, signature); | ||
} catch (e) { | ||
throw Exception("Failed to verify signature. Error: $e"); | ||
} | ||
} | ||
|
||
KeyPair keypairFromAddress(String address) { | ||
final keyring = Keyring(); | ||
|
||
keyring.add(keypair!); | ||
final pair = keyring.getByAddress(address); | ||
return pair; | ||
} | ||
AlaaElattar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
This file contains hidden or 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,17 @@ | ||
part of '../signer.dart'; | ||
|
||
enum KPType { | ||
sr25519, | ||
ed25519, | ||
} | ||
|
||
extension KPTypeExtension on KPType { | ||
String get value { | ||
switch (this) { | ||
case KPType.sr25519: | ||
return 'sr25519'; | ||
case KPType.ed25519: | ||
return 'ed25519'; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.