sunshine-protocol / sunshine

Governance + Bounty Platform
Other
43 stars 16 forks source link

slight client light work #89

Closed 4meta5 closed 4 years ago

4meta5 commented 4 years ago

module stuff

client stuff

examples

Might tackle this in a future PR but I want the examples folder to make calls to client AND wait for relevant event emission. The current examples/org makes the issue_shares call but doesn't listen for event emission...

4meta5 commented 4 years ago

At this point, I'm consistently getting EventNotFound for every call to the client despite the fact that all the event structs exist in srml/org.rs and are imported to sunshine.rs. I have a feeling that the calls to the client no longer return events or rather that they shouldn't because that is not how it is done in substrate-identity...

So right now, we have

/// Issue shares
pub async fn issue_shares(
    &self,
    organization: u64,
    who: AccountId32,
    shares: u64,
) -> Result<SharesIssuedEvent<Runtime>> {
    let signer = self.signer()?;
    self.client
        .clone()
        .issue_shares_and_watch(&signer, organization, &who, shares)
        .await?
        .shares_issued()
        .map_err(|e| substrate_subxt::Error::Codec(e))?
        .ok_or(Error::EventNotFound)
}

and we need to make it like this to match the norms of substrate-identity

/// Issue shares
pub async fn issue_shares(
    &self,
    organization: u64,
    who: AccountId32,
    shares: u64,
) -> Result<()> {
    let signer = self.signer()?;
    self.client
        .issue_shares_and_watch(&signer, organization, &who, shares)
        .await?
        .shares_issued()
        .map_err(|e| substrate_subxt::Error::Codec(e))?;
    Ok(())
}

The annoying part is that this new form does not emit the event. So I feel like the and_watch isn't accurate...

4meta5 commented 4 years ago

This PR has good stuff in it so I will merge it. The client still doesn't work as mentioned in greater detail in the previous comment.

4meta5 commented 4 years ago

For clarification, #95 was NOT resolved in this PR. The issue is still open for this reason.