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 example to provider.ts in utils #1114

Closed
wants to merge 7 commits into from

Conversation

vibenedict
Copy link

@vibenedict vibenedict commented May 1, 2024

Motivation and Resolution

Closes #1090
...

RPC version (if applicable)

...

Usage related changes

  • Change 1.
  • ...

Development related changes

  • Change 1.
  • ...

Checklist:

  • Performed a self-review of the code
  • Rebased to the last commit of the target branch (or merged it into my branch)
  • Linked the issues which this PR resolves
  • Documented the changes in code (API docs will be generated automatically)
  • Updated the tests
  • All tests are passing

@ivpavici ivpavici changed the base branch from develop to next-version May 2, 2024 12:39
@ivpavici
Copy link
Collaborator

ivpavici commented May 2, 2024

also, please locally retarget to next-version to resolve conflicts 🙏

@vibenedict
Copy link
Author

Done

@ivpavici
Copy link
Collaborator

ivpavici commented May 3, 2024

@vibenedict thanks for resolving conflicts, but my previous comment is not yet addressed, regarding adding missing @param on all functions?

@tabaktoni tabaktoni added the Type: documentation Improvements or additions to documentation label May 3, 2024
@ivpavici ivpavici requested a review from PhilippeR26 May 6, 2024 13:16
Copy link
Collaborator

@PhilippeR26 PhilippeR26 left a comment

Choose a reason for hiding this comment

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

As explained in Telegram https://t.me/c/2066195975/59 ,
please follow very rigorously the template of this PR #1100, especially for the examples : result always in a result variable, result displayed in a comment (//);

@vibenedict
Copy link
Author

@ivpavici @PhilippeR26

@@ -51,6 +76,25 @@ export function createSierraContractClass(contract: CompiledSierra): SierraContr
* Create Contract Class from a given CompiledContract or string
*
* (CompiledContract or string) -> ContractClass
*
* @param {CompiledContract | string} contract - Compiled contract or string
*
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing returns

@@ -37,6 +43,25 @@ export function wait(delay: number) {
* Create Sierra Contract Class from a given Compiled Sierra
*
* CompiledSierra -> SierraContractClass
*
* @param {CompiledSierra} contract - Compiled sierra code
*
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing returns

@@ -26,6 +26,12 @@ import type { GetTransactionReceiptResponse } from './transactionReceipt';

/**
* Helper - Async Sleep for 'delay' time
*
* @param {number} delay - Number of milliseconds to delay.
* @example
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing returns

Copy link
Collaborator

@PhilippeR26 PhilippeR26 left a comment

Choose a reason for hiding this comment

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

Some work remains.

@@ -34,7 +34,15 @@ export function computePoseidonHash(a: BigNumberish, b: BigNumberish): string {

/**
* Compute pedersen hash from data
*
* @param {BigNumberish[]} data - Data to compute hash on
* @returns format: hex-string - pedersen hash
Copy link
Collaborator

Choose a reason for hiding this comment

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

As explained here : https://jsdoc.app/tags-returns
The return format has to be wrapped in {}. Here it was not made properly.
A correct typing is :

@returns {string} Hex string

To be verified everywhere.

*
* @example
* ```typescript
* const result = computeHashOnElements(['0xabc', '0x123', '0xabc123'])
Copy link
Collaborator

Choose a reason for hiding this comment

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

All the functions of this file are accessible only in the hash namespace.
You have to add hash. before each function.

@@ -89,6 +107,11 @@ function nullSkipReplacer(key: string, value: any) {
* Format json-string to conform starknet json-string
* @param json json-string
Copy link
Collaborator

Choose a reason for hiding this comment

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

You have to verify also that parameters types are wrapped in {}.
Here :

@param {string} json 

* @example
* ```typescript
* const result = formatSpaces("{'onchain': true, 'isStarknet': true}")
* // result = {'onchain': true, 'isStarknet': true}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here we can think that the result is an object.
To avoid this error, wrap the result in " "

@@ -89,6 +107,11 @@ function nullSkipReplacer(key: string, value: any) {
* Format json-string to conform starknet json-string
* @param json json-string
* @returns format: json-string
* @example
* ```typescript
* const result = formatSpaces("{'onchain': true, 'isStarknet': true}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

In this project we like to add a ; at the end of TS line of code.
To add everywhere.

* ```typescript
* const result = formatSpaces("{'onchain': true, 'isStarknet': true}")
* // result = {'onchain': true, 'isStarknet': true}
* ```
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why other functions until the end haven't been modified?

* @param {number} delay - Number of milliseconds to delay.
* @example
* ```typescript
* wait(1000) // 1000 milliseconds == 1 second
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's an async function.
You have to add the await prefix.
All the functions of this file are in the provider space. To correct.

"0x65",
"0x52616e6765436865636b",...})
* // result = {sierra_program: 'H4sIAAAAAAAAA6x9WZbsrI7uVGqd53qgb8ZynwzYY7jDv5JAAmxHZuQ+96yq/L0jIzEINZ8axP/5j/q/+j//+z/wH9f/o/p/zPbh+Iot49+u9v8G3//rTdDhDDF4Z0MKPthQ+m+S2v6n1S//638VvdXW2PQ6RvxuDG+jiybCXKJ7Hef6ZRi9E+Q89WmKLilfqbrsL6PUCf8...}
* ```
Copy link
Collaborator

Choose a reason for hiding this comment

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

Last function hasn't been made.

"0x65",
"0x52616e6765436865636b",...})
* // result = {sierra_program: 'H4sIAAAAAAAAA6x9WZbsrI7uVGqd53qgb8ZynwzYY7jDv5JAAmxHZuQ+96yq/L0jIzEINZ8axP/5j/q/+j//+z/wH9f/o/p/zPbh+Iot49+u9v8G3//rTdDhDDF4Z0MKPthQ+m+S2v6n1S//638VvdXW2PQ6RvxuDG+jiybCXKJ7Hef6ZRi9E+Q89WmKLilfqbrsL6PUCf8...}
* ```
Copy link
Collaborator

Choose a reason for hiding this comment

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

createSierraContractClass and parseContract are performing the opposite action of the other, but you have the same example and result for both cases.
You should re-test these examples ; you will quickly find your error.

@ivpavici ivpavici closed this May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants