generated from peersky/bootstrap_solidity
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* code inspection fixes * code inspection fixes * happy linter - happy life * added doc strings, cleaned up unused files * added doc strings, cleaned up unused files * docs generation * tracer and docs generation config * elaborated changeset * happy linter - happy life * notes and gas improvements
- Loading branch information
Showing
45 changed files
with
863 additions
and
277 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
"@peeramid-labs/eds": patch | ||
--- | ||
|
||
### Changes | ||
|
||
- Added documentation strings. | ||
- Made minor logic improvements. | ||
- Implemented documentation generation from docstrings. | ||
- Performed gas optimizations. | ||
- Unified code style. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -275,4 +275,5 @@ types | |
|
||
|
||
abi/ | ||
.secrets/ | ||
.secrets/ | ||
docs/contracts |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
{{#if (isVisible visibility)}} | ||
{{h 2}} {{name}} | ||
|
||
{{substituteAnchors natspec.notice}} | ||
|
||
{{#if signature}} | ||
```solidity | ||
{{{signature}}} | ||
``` | ||
{{/if}} | ||
{{/if}} | ||
|
||
{{#if natspec.params}} | ||
| Input | Type | Description | | ||
|:----- | ---- | ----------- | | ||
{{#each params}} | ||
| `{{{name}}}` | `{{{type}}}` | {{{joinLines (substituteAnchors natspec)}}} | | ||
{{/each}} | ||
{{#if natspec.returns}} | ||
| **Output** | | | ||
{{#each returns}} | ||
| {{#if name}} `{{name}}` {{else}} `{{@index}}` {{/if}} | `{{type}}` | {{{joinLines (substituteAnchors natspec)}}} | | ||
{{/each}} | ||
{{/if}} | ||
{{else}} | ||
{{#if natspec.returns}} | ||
| Output | Type | Description | | ||
| ------ | ---- | ----------- | | ||
{{#each returns}} | ||
| {{#if name}} `{{{name}}}` {{else}} `{{{@index}}}` {{/if}} | `{{type}}` | {{{joinLines (substituteAnchors natspec)}}} | | ||
{{/each}} | ||
{{/if}} | ||
{{/if}} | ||
|
||
{{#if natspec.dev}} | ||
{{{transformDev (substituteAnchors natspec.dev)}}} | ||
{{/if}} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{{natspec.notice}}} | ||
|
||
{{{transformDev (substituteAnchors natspec.dev)}}} | ||
|
||
|
||
{{#each items}} | ||
{{>item}} | ||
{{/each}} | ||
<!--CONTRACT_END--> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{>common}} | ||
|
||
```solidity | ||
enum {{name}} { | ||
{{#each members}} | ||
{{name}}{{#unless @last}},{{/unless}} | ||
{{/each}} | ||
} | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{>common}} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{>common}} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{>common}} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import { HelperOptions, Utils } from "handlebars"; | ||
|
||
/** | ||
* Returns a Markdown heading marker. An optional number increases the heading level. | ||
* | ||
* Input Output | ||
* {{h}} {{name}} # Name | ||
* {{h 2}} {{name}} ## Name | ||
*/ | ||
export function h(opts: HelperOptions): string; | ||
export function h(hsublevel: number, opts: HelperOptions): string; | ||
export function h(hsublevel: number | HelperOptions, opts?: HelperOptions) { | ||
const { hlevel } = getHLevel(hsublevel, opts); | ||
return new Array(hlevel).fill("#").join(""); | ||
} | ||
|
||
/** | ||
* Delineates a section where headings should be increased by 1 or a custom number. | ||
* | ||
* {{#hsection}} | ||
* {{>partial-with-headings}} | ||
* {{/hsection}} | ||
*/ | ||
export function hsection(opts: HelperOptions): string; | ||
export function hsection(hsublevel: number, opts: HelperOptions): string; | ||
export function hsection(this: unknown, hsublevel: number | HelperOptions, opts?: HelperOptions) { | ||
let hlevel; | ||
({ hlevel, opts } = getHLevel(hsublevel, opts)); | ||
opts.data = Utils.createFrame(opts.data); | ||
opts.data.hlevel = hlevel; | ||
return opts.fn(this as unknown, opts); | ||
} | ||
|
||
/** | ||
* Helper for dealing with the optional hsublevel argument. | ||
*/ | ||
function getHLevel(hsublevel: number | HelperOptions, opts?: HelperOptions) { | ||
if (typeof hsublevel === "number") { | ||
opts = opts!; | ||
hsublevel = Math.max(1, hsublevel); | ||
} else { | ||
opts = hsublevel; | ||
hsublevel = 1; | ||
} | ||
const contextHLevel: number = opts.data?.hlevel ?? 0; | ||
return { opts, hlevel: contextHLevel + hsublevel }; | ||
} | ||
|
||
export function trim(text: string) { | ||
if (typeof text === "string") { | ||
return text.trim(); | ||
} | ||
} | ||
|
||
export function toLowerCase(text: string) { | ||
return text.toLowerCase(); | ||
} | ||
|
||
export function joinLines(text?: string) { | ||
if (typeof text === "string") { | ||
return text.replace(/\n+/g, " "); | ||
} | ||
} | ||
|
||
export function transformDev(comment: string): string { | ||
// Split the comment into lines | ||
const lines = comment?.split("\n") ?? []; | ||
|
||
// Initialize variables to store the transformed text | ||
let transformedText = ""; | ||
let isWarning = false; | ||
let isFirstNotice = true; | ||
let noticeBlock = ""; | ||
|
||
// Iterate over each line | ||
lines.forEach((line) => { | ||
const trimmedLine = line.trim(); | ||
|
||
// Check if the line starts with WARNING: | ||
if (trimmedLine.startsWith("WARNING:")) { | ||
// Add the WARNING prefix | ||
if (noticeBlock) { | ||
transformedText += `\n\n!!! NOTICE\n\n\t${noticeBlock.trim().replace(/\n/g, "\n\t")}`; | ||
noticeBlock = ""; | ||
} | ||
transformedText += `\n\n!!! WARNING\n\n\t${trimmedLine.replace("WARNING:", "").trim()}`; | ||
isWarning = true; | ||
} else if (trimmedLine) { | ||
// Add the line to the NOTICE block | ||
if (isWarning) { | ||
transformedText += `\n\t${trimmedLine}`; | ||
} else { | ||
noticeBlock += `\n${trimmedLine}`; | ||
} | ||
} else { | ||
// Handle empty lines | ||
if (noticeBlock) { | ||
transformedText += `\n\n!!! NOTICE\n\n\t${noticeBlock.trim().replace(/\n/g, "\n\t")}`; | ||
noticeBlock = ""; | ||
} | ||
isWarning = false; | ||
} | ||
}); | ||
|
||
// Add any remaining notice block | ||
if (noticeBlock) { | ||
transformedText += `\n\n!!! NOTICE\n\n\t${noticeBlock.trim().replace(/\n/g, "\n\t")}`; | ||
} | ||
|
||
// Return the transformed text | ||
return transformedText.trim(); | ||
} | ||
|
||
export const isVisible = (type: string) => { | ||
return type !== "internal" && type !== "private"; | ||
}; | ||
|
||
export const substituteAnchors = (text: string) => { | ||
if (typeof text === "string") { | ||
return text.replace(/{([^}]+)}/g, (match: string, p1: string) => { | ||
// Split the reference into parts | ||
const parts = p1.split("."); | ||
const anchor = parts.length > 1 ? `#${parts.slice(1).join(".").toLocaleLowerCase()}` : ""; | ||
const reference = parts[0]; | ||
const displayText = reference.charAt(0).toUpperCase() + reference.slice(1); | ||
|
||
// Handle different depth levels | ||
const path = reference.startsWith("../") ? reference : `./${reference}`; | ||
|
||
return `[${displayText}${anchor}](../${path}${anchor})`; | ||
}); | ||
} | ||
return text; | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{>common}} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
{{#each items}} | ||
{{h 1}} {{{natspec.title}}} | ||
{{#hsection}} | ||
{{>item}} | ||
{{/hsection}} | ||
|
||
{{/each}} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{>common}} | ||
|
||
```solidity | ||
struct {{name}} { | ||
{{#each members}} | ||
{{{typeName.typeDescriptions.typeString}}} {{name}}; | ||
{{/each}} | ||
} | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{>common}} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{>common}} |
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.