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

Stellar::Memo.new should validate memo length #90

Open
jimdanz opened this issue Oct 30, 2018 · 1 comment
Open

Stellar::Memo.new should validate memo length #90

jimdanz opened this issue Oct 30, 2018 · 1 comment

Comments

@jimdanz
Copy link
Contributor

jimdanz commented Oct 30, 2018

Stellar::Memo.new seems to validate that the memo provided is the right data type:

[36] pry(main)> Stellar::Memo.new(:memo_text, {foo: 'bar'})
XDR::InvalidValueError: XDR::InvalidValueError
from .../gems/xdr-3.0.0/lib/xdr/union.rb:86:in `set'

But it does not look at the value itself to validate length:

[37] pry(main)> Stellar::Memo.new(:memo_text, 'x' * 10000)
=> #<Stellar::Memo:0x007fdc5f3a7198
 @arm=:text,
 @switch=#<Stellar::MemoType:0x007fdc5d80e800 @name="memo_text", @value=1>,
 .....

From my perspective it'd be great if the contract were that if Stellar::Memo.new returns a value, that value will be able to be serialized into XDR successfully.

@ramontayag
Copy link
Contributor

@jimdanz thanks for mentioning this. We'd love a PR!

@nebolsin nebolsin transferred this issue from astroband/ruby-stellar-base May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@nebolsin @ramontayag @jimdanz and others