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

docs: add examples to some modules #213

Merged
merged 7 commits into from
Oct 10, 2023
Merged

docs: add examples to some modules #213

merged 7 commits into from
Oct 10, 2023

Conversation

gnkz
Copy link
Contributor

@gnkz gnkz commented Oct 6, 2023

No description provided.

Copy link
Contributor

@vdrg vdrg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!


### Formatting decimals

This example shows how to use the `{uint:dx}` placeholder to format numbers with decimals
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should mention something about shorthand variations (u:d18)

function test() external {
RequestClient memory client = request.create();

Response memory jsonRes = client.post("https://httpbin.org/post").json("{ \"foo\": \"bar\" }").send().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Response memory jsonRes = client.post("https://httpbin.org/post").json("{ \"foo\": \"bar\" }").send().unwrap();
Response memory jsonRes = client.post("https://httpbin.org/post").json('{ "foo": "bar" }').send().unwrap();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cannot be done. The contract parser fails when using single quotes for strings

## Examples
### Use different matchers

This example shows how to use the `expect` function and its different matchers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the "This example shows blah blah" From ALL examples, feels repetitive and doesn't really add information.

This one, for example could become:

Use the expect function and its different matchers to assert conditions.


import {Test, expect, request, Response} from "vulcan/test.sol";

contract RequestExample01 is Test {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the suffix number from the example, doesn't seem necessary


contract ExpectExample01 is Test {
function test() external {
expect(string("foo")).toEqual(string("foo"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it is better to store the variable, otherwise users might think that you always need to cast it.

Suggested change
expect(string("foo")).toEqual(string("foo"));
string memory foo = "foo";
expect(foo).toEqual("foo");

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I think the casting is not necessary in the matcher, as matchers are different for each expect(...)

* chore!: update forge-std to v1.7.1

This is a breaking change because v.1.7.0 introduced a breaking change.

Details here foundry-rs/forge-std#458

* chore: remove ad-hoc SerializeJson interface

* chore: update functions mutability
@gnkz gnkz marked this pull request as ready for review October 10, 2023 20:16
@gnkz gnkz merged commit 835a938 into main Oct 10, 2023
2 checks passed
@gnkz gnkz deleted the docs/examples branch October 10, 2023 21:53
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 this pull request may close these issues.

None yet

2 participants