fix(antd-elixir): print cost-estimate fields in examples to avoid stringification crash#75
Open
Nic-dorman wants to merge 1 commit into
Open
fix(antd-elixir): print cost-estimate fields in examples to avoid stringification crash#75Nic-dorman wants to merge 1 commit into
Nic-dorman wants to merge 1 commit into
Conversation
…ingification crash
The examples interpolated a whole UploadCostEstimate struct into a string,
which raises Protocol.UndefinedError (String.Chars not implemented for the
struct):
** (Protocol.UndefinedError) protocol String.Chars not implemented for
Antd.UploadCostEstimate (a struct)
02_data.exs:19: (file)
Print individual fields (matching what the Python/Rust/PHP examples do).
For 02_data.exs the example is also reordered to estimate-then-store and
gains a round-trip assertion + OK marker.
Affected examples:
- 02_data.exs (rewritten end-to-end, mirrors antd-py/antd-rust shape)
- 04_files.exs (single-line interpolation fix)
- 05_graph.exs (single-line interpolation fix)
Closes #67
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #67.
The Elixir examples interpolated whole
Antd.UploadCostEstimatestructs into strings, which raisesProtocol.UndefinedError(the struct has noString.Charsimpl):Same shape as the PHP fix in #74. The SDK return types are correct (
data_cost/2etc. correctly return{:ok, %UploadCostEstimate{}}); only the example interpolations are wrong.Changes
02_data.exs— rewritten end-to-end to match the Python / Rust / PHP examples: estimate-then-store ordering, print individual estimate fields, add a round-trip assertion and an "OK" marker so the example self-verifies.04_files.exs:28— single-line fix on thefile_costprint.05_graph.exs:30— single-line fix on thegraph_entry_costprint.Test plan
cd antd-elixir/examples && elixir 02_data.exsagainst a local devnet — exits 0, prints estimate fields, address, "Public data round-trip OK!"file_cost/4but the SDK exportsfile_cost/3) that should be addressed separatelySample output
```
Estimate: 16 bytes in 3 chunks, storage 0 atto, gas 0 wei, mode single
Stored at address: 01b06330e4f4a8c565087e4087caabf860bdadbe96b7b8f0447493b0081c2335
Actual cost: atto tokens
Retrieved: Hello, Autonomi!
Public data round-trip OK!
```
(Several pre-existing compile warnings about
Antd.V1.FileService.Stub.get_file_cost/2being undefined surface during the run — that's unrelated to this PR and worth its own ticket.)