-
Notifications
You must be signed in to change notification settings - Fork 90
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
Set explorer_url
in private Tangle example
#454
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -22,7 +22,11 @@ async fn main() -> Result<()> { | |||||
// As an example we are treating the devnet as a `private-tangle`, so we use `dev`. | ||||||
// Replace this with `tangle` if you run this against a one-click private tangle. | ||||||
let network_name = "dev"; | ||||||
let network = Network::try_from_name(network_name)?; | ||||||
let mut network = Network::try_from_name(network_name)?; | ||||||
|
||||||
// If you deployed an explorer, set its url here. | ||||||
network.set_explorer_url("http://127.0.0.1:8082/".parse()?)?; | ||||||
|
||||||
// In a locally running one-click tangle, this would often be `http://127.0.0.1:14265/` | ||||||
let private_node_url = "https://api.lb-0.h.chrysalis-devnet.iota.cafe"; | ||||||
|
||||||
|
@@ -46,7 +50,7 @@ async fn main() -> Result<()> { | |||||
}) | ||||||
// Configure a client for the private network, here `dev` | ||||||
// Also set the URL that points to the REST API of the node | ||||||
.client(network, |builder| { | ||||||
.client(network.clone(), |builder| { | ||||||
// unwrap is safe, we provided a valid node URL | ||||||
builder.node(private_node_url).unwrap() | ||||||
}) | ||||||
|
@@ -71,7 +75,7 @@ async fn main() -> Result<()> { | |||||
// Prints the Identity Resolver Explorer URL, the entire history can be observed on this page by "Loading History". | ||||||
println!( | ||||||
"[Example] Explore the DID Document = {}/{}", | ||||||
iota_did.network()?.explorer_url().unwrap().to_string(), | ||||||
network.explorer_url().expect("explorer url was set").to_string(), | ||||||
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.
Suggested change
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. I've never quite understood how 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. Oh, I always read I rate the error messages are more important for debugging when it actually panics, so I try write them for that. |
||||||
iota_did.to_string() | ||||||
); | ||||||
|
||||||
|
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.
The explorer URL does not match the default node URL in this example, does that matter?
Maybe specify the default explorer URL for the devnet and add the example for the private Tangle case in the comment, as per
private_node_url
?E.g.
On a related note, doesprivate_node_url
use the deprecateddevnet
URL intentionally so publishing fails?I was looking at old code,
devnet
replacedtestnet
.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.
Yeah, makes more sense that way.
I agree that the url should be moved out of the
Network
, but I don't really know where. When we do that, we should think about renaming the explorer url to resolver url, now that we no longer point to the actual explorer? Would be a bit more accurate.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.
The identity-resolver is still part of the explorer so I'm not too bothered by the current name. The only concern I have with the
resolverUrl
name is that it might conflict with the actualResolver
API.We could have a newtype wrapper---
ExplorerUrl
/ResolverUrl
---around aUrl
that offers methods to create it yourself or from an existing network.E.g. something like
and still implement
FromStr
etc. In this case I would keep the name asExplorerUrl
since there's a dedicated method to append "identity-resolver" to it.This may be over-engineering it, however.
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.
That's one way to do it, and I'm not opposed to it. As you say, though, it might be over-engineering it, since it's really just a URL. A very simple solution would be to export
const
orstatic
Url
s for main and devnet, and everything else is up to the app developer.