Skip to content
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

How to build Claimable Balance Predicate on txbuild? #3000

Closed
abuiles opened this issue Sep 11, 2020 · 5 comments · Fixed by #3026
Closed

How to build Claimable Balance Predicate on txbuild? #3000

abuiles opened this issue Sep 11, 2020 · 5 comments · Fixed by #3026
Assignees

Comments

@abuiles
Copy link
Contributor

abuiles commented Sep 11, 2020

We should offer some high level helpers in txnbuild to make it easy for people to create claimable balances predicates.

Following the spirit of txnbuild users, final users should need access to the XDR library.

We could have some helpers like:

txnbuild.AndPredicate(left, right)
txnbuild.OrPredicate(left, right)
txnbuild.NotPredicate(left, right)
txnbuild.AbsBeforePredicate(int64)
txnbuild.RelBeforePredicate(int64)
@Shaptic Shaptic self-assigned this Sep 12, 2020
@abuiles
Copy link
Contributor Author

abuiles commented Sep 14, 2020

@Shaptic I added some initial helper here to help us write the integration tests abuiles@6d3d8e8 -- we can use this for now internally, while we define the final interface for txnbuild.

@abuiles
Copy link
Contributor Author

abuiles commented Sep 14, 2020

@2opremio @tamirms can you check the interface here abuiles@6d3d8e8#diff-53889a0fa496ed0e06224eaebe4319d7R25 -- this is just an initial version to help us write integration tests.

@Shaptic
Copy link
Contributor

Shaptic commented Sep 15, 2020

I cherry-picked the above commit as part of my predicate-tests branch (see exact file), and added some things as I needed them for the tests.

@abuiles
Copy link
Contributor Author

abuiles commented Sep 15, 2020

We had a conversation and decided to move forward with the factory methods to create xdr.ClaimPredicateand keep a txnbuild struct to wrap the destination as a string and then the predicate as an xdr struct.

We'll have the following in txnbuild

type Claimant struct {
	Destination string
	Predicate   xdr.ClaimPredicate
}

func (c *Claimant) BuildXDR() (xdr.Claimant, error) {
  ...
}
func (c *Claimant) FromXDR(xdrClaimant xdr.Claimant) error {
  ...
}

And then people can create new claimants combining the struct above and the factory methods

txnbuild.Claimant{
  Destination: "GGGG",
  Predicate:  txnbuild.AbsBeforePredicate(200000000)
}

@Shaptic
Copy link
Contributor

Shaptic commented Sep 17, 2020

This was implemented & merged in the above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants