-
Notifications
You must be signed in to change notification settings - Fork 11
map mycelium to twin identity #1037
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
Open
Omarabdul3ziz
wants to merge
3
commits into
development
Choose a base branch
from
development_TwinMycPK
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,3 +201,43 @@ pub async fn get_balance( | |
.fetch(¤t::storage().system().account(account)) | ||
.await?) | ||
} | ||
|
||
pub async fn set_mycelium_twin( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you are updating the rs client, you need to re-generate the client scale file |
||
cl: &Client, | ||
kp: &KeyPair, | ||
mycelium_pk: Vec<u8>, | ||
twin_id: u32, | ||
) -> Result<H256, Error> { | ||
let set_mycelium_tx = current::tx().tfgrid_module().set_mycelium_twin( | ||
BoundedVec(mycelium_pk), | ||
twin_id, | ||
); | ||
|
||
let signer = kp.signer(); | ||
|
||
let set_mycelium = cl | ||
.api | ||
.tx() | ||
.sign_and_submit_then_watch_default(&set_mycelium_tx, &signer) | ||
.await? | ||
.wait_for_finalized_success() | ||
.await?; | ||
|
||
Ok(set_mycelium.block_hash()) | ||
} | ||
|
||
pub async fn get_mycelium_twin( | ||
cl: &Client, | ||
mycelium_pk: Vec<u8>, | ||
) -> Result<Option<u32>, Error> { | ||
// Query the storage directly using the mycelium pk to get twin ID | ||
let twin_id = cl | ||
.api | ||
.storage() | ||
.at_latest() | ||
.await? | ||
.fetch(¤t::storage().tfgrid_module().mycelium_twin(BoundedVec(mycelium_pk))) | ||
.await?; | ||
|
||
Ok(twin_id) | ||
} |
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,32 @@ | ||
module github.com/threefoldtech/tfchain/activate | ||
|
||
go 1.21 | ||
|
||
require github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-00010101000000-000000000000 | ||
|
||
require ( | ||
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect | ||
github.com/cenkalti/backoff v2.2.1+incompatible // indirect | ||
github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.12 // indirect | ||
github.com/cosmos/go-bip39 v1.0.0 // indirect | ||
github.com/deckarep/golang-set v1.8.0 // indirect | ||
github.com/decred/base58 v1.0.4 // indirect | ||
github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect | ||
github.com/ethereum/go-ethereum v1.10.20 // indirect | ||
github.com/go-stack/stack v1.8.1 // indirect | ||
github.com/gorilla/websocket v1.5.0 // indirect | ||
github.com/gtank/merlin v0.1.1 // indirect | ||
github.com/gtank/ristretto255 v0.1.2 // indirect | ||
github.com/jbenet/go-base58 v0.0.0-20150317085156-6237cf65f3a6 // indirect | ||
github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b // indirect | ||
github.com/pierrec/xxHash v0.1.5 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/rs/cors v1.8.2 // indirect | ||
github.com/rs/zerolog v1.26.0 // indirect | ||
github.com/vedhavyas/go-subkey v1.0.3 // indirect | ||
golang.org/x/crypto v0.7.0 // indirect | ||
golang.org/x/sys v0.6.0 // indirect | ||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect | ||
) | ||
|
||
replace github.com/threefoldtech/tfchain/clients/tfchain-client-go => ../../clients/tfchain-client-go |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add tests to the client