generated from owlprotocol/starter-monorepo
-
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.
Merge pull request #1 from owlprotocol/feat/hyperlane-sdk
Feat/hyperlane sdk
- Loading branch information
Showing
38 changed files
with
4,257 additions
and
10 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
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,6 @@ | ||
ignores: [ | ||
"@types/node", | ||
"vite", | ||
"zod", | ||
"@openzeppelin/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,4 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ['@owlprotocol/eslint-config'], | ||
}; |
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,77 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
cache/ | ||
|
||
# dependencies | ||
node_modules | ||
.pnp | ||
.pnp.js | ||
|
||
# testing | ||
coverage | ||
|
||
# build outputs | ||
.next/ | ||
out/ | ||
build | ||
.build | ||
.esbuild | ||
dist | ||
dist-ssr | ||
lib | ||
.serverless | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
.idea | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
logs | ||
*.log | ||
|
||
# local env files | ||
.env.local | ||
.env.development | ||
.env.test | ||
.env.production | ||
.env | ||
|
||
# turbo | ||
.turbo | ||
|
||
# local | ||
*.local | ||
|
||
# ipfs | ||
.ipfs | ||
.datastore | ||
.datastore_fs | ||
.datastore_level | ||
.datastore_s3 | ||
|
||
# hardhat | ||
typechain | ||
cache | ||
factory | ||
/src/typechain | ||
/src/artifacts | ||
/src/zsol | ||
/artifacts | ||
/docs-contracts-reference/* | ||
!/docs-contracts-reference/index.md | ||
/scripts | ||
traceOutputDir | ||
src/deployments | ||
|
||
# forge | ||
forge-cache/ | ||
out/ | ||
soljson-v*.js | ||
.openzeppelin/unknown-*.json | ||
*.py | ||
!.env.example |
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,5 @@ | ||
{ | ||
"*.+(js|jsx)": ["eslint --fix"], | ||
"*.+(ts|tsx)": ["eslint --fix"], | ||
"*.+(json|css|md)": ["prettier --write"] | ||
} |
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,3 @@ | ||
module.exports = { | ||
...require("@owlprotocol/prettier-config"), | ||
}; |
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,7 @@ | ||
Copyright 2024 Owl Protocol | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, libribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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 @@ | ||
# Hyperlane 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,23 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
//Re-export & recompile contracts with increased optimization | ||
|
||
//interfaces | ||
import {IInterchainSecurityModule} from "@hyperlane-xyz/core/contracts/interfaces/IInterchainSecurityModule.sol"; | ||
import {IMailbox} from "@hyperlane-xyz/core/contracts/interfaces/IMailbox.sol"; | ||
import {IMessageRecipient} from "@hyperlane-xyz/core/contracts/interfaces/IMessageRecipient.sol"; | ||
import {IRouter} from "@hyperlane-xyz/core/contracts/interfaces/IRouter.sol"; | ||
|
||
import {IRoutingIsm} from "@hyperlane-xyz/core/contracts/interfaces/isms/IRoutingIsm.sol"; | ||
|
||
//implementations | ||
import {Mailbox} from "@hyperlane-xyz/core/contracts/Mailbox.sol"; | ||
import {MailboxClient} from "@hyperlane-xyz/core/contracts/client/MailboxClient.sol"; | ||
import {Router} from "@hyperlane-xyz/core/contracts/client/Router.sol"; | ||
|
||
import {InterchainAccountRouter} from "@hyperlane-xyz/core/contracts/middleware/InterchainAccountRouter.sol"; | ||
import {InterchainQueryRouter} from "@hyperlane-xyz/core/contracts/middleware/InterchainQueryRouter.sol"; | ||
import {OwnableMulticall} from "@hyperlane-xyz/core/contracts/middleware/libs/OwnableMulticall.sol"; | ||
|
||
import {TrustedRelayerIsm} from "@hyperlane-xyz/core/contracts/isms/TrustedRelayerIsm.sol"; |
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,30 @@ | ||
{{h}} {{name}} | ||
|
||
{{#if signature}} | ||
```solidity | ||
{{{signature}}} | ||
``` | ||
{{/if}} | ||
|
||
{{{natspec.notice}}} | ||
|
||
{{#if natspec.dev}} | ||
{{#formatLinks}}{{{natspec.dev}}}{{/formatLinks}} | ||
{{/if}} | ||
|
||
{{#if natspec.params}} | ||
| Name | Type | Description | | ||
| ---- | ---- | ----------- | | ||
{{#each params}} | ||
| {{name}} | {{type}} | {{#formatLinks}}{{{joinLines natspec}}}{{/formatLinks}} | | ||
{{/each}} | ||
{{/if}} | ||
|
||
{{#if natspec.returns}} | ||
| Name | Type | Description | | ||
| ---- | ---- | ----------- | | ||
{{#each returns}} | ||
| {{#if name}}{{name}}{{else}}[{{@index}}]{{/if}} | {{type}} | {{#formatLinks}}{{{joinLines natspec}}}{{/formatLinks}} | | ||
{{/each}} | ||
{{/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,8 @@ | ||
{{>common}} | ||
|
||
{{#each items}} | ||
{{#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 | ||
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,163 @@ | ||
import { HelperOptions, Utils } from 'handlebars'; | ||
|
||
// import { TypeName } from 'solidity-ast'; | ||
// import { DocItemWithContext } from '../../site'; | ||
|
||
/** | ||
* 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 joinLines(text?: string) { | ||
if (typeof text === 'string') { | ||
return text.replace(/\n+/g, ' '); | ||
} | ||
} | ||
|
||
// Regular expression -> match all function names, contract names, and # to separate | ||
const re = /{([\-#a-zA-Z0-9_]*)}/gm; | ||
const path = './'; // todo - set this somewhere else | ||
export function formatLinks(this: unknown, opts: HelperOptions) { | ||
// Render our text | ||
let rendered = opts.fn(this as unknown, opts); | ||
// Find all occurrences | ||
const matches = rendered.match(re); | ||
if (!matches) return rendered; | ||
|
||
// Iterate through links and format | ||
for (const match of matches) { | ||
// {ContractA#mint} => ContractA#mint | ||
let name = match.slice(1, match.length - 1); | ||
|
||
// Standardize how it's formatted | ||
// {ContractA-mint} => {ContractA#Mint} | ||
if (name.includes('-')) name = name.replace('-', '#'); | ||
|
||
const link = getLink(name, path); | ||
|
||
// Set md link and update | ||
rendered = rendered.replace(match, link); | ||
} | ||
|
||
return rendered; | ||
} | ||
|
||
/** | ||
* Returns displayName and resource for a given artifact name | ||
*/ | ||
function getLink(name: string, path: string) { | ||
|
||
let displayName = name; | ||
let resource = ''; | ||
let link = ''; | ||
|
||
// ContractA#mint => Contract.mint(...) | ||
displayName = displayName.replace('#', '.'); | ||
|
||
// Split up what we're referencing | ||
// 'CrafterMint#deposit'.split('#') => ['CrafterMint', 'deposit'] | ||
const components = name.split('#'); | ||
|
||
// Add function display: deposit => deposit(...) | ||
if (isFunction(components[components.length - 1])) | ||
displayName += '(...)'; | ||
|
||
// Either an external contract (CaseSensitive) or a local function (alllowercase) | ||
if (components.length == 1) { | ||
// Check if we need to be lowercase (is an anchor) | ||
if (isFunction(components[0])) { | ||
components[0] = components[0].toLowerCase(); | ||
resource = '#' + components[0]; | ||
} else { | ||
// Link to another page | ||
resource = path + components[0]; | ||
} | ||
} else if (components.length == 2) { | ||
// Always an anchor, which must always be lower | ||
components[1] = components[1].toLowerCase(); | ||
|
||
// See if we found an anchor type | ||
if (isAnchor(name)) { | ||
// Special local {#Anchor} type | ||
displayName = displayName.slice(1); // slice off . | ||
// We don't want to path anywhere else | ||
path = ''; | ||
} | ||
|
||
// Put everything back together to a link | ||
resource = path + components.join('#'); | ||
} else { | ||
// Unsupported format, just return | ||
return name; | ||
} | ||
|
||
// Generate link | ||
link = `[\`${displayName}\`](${resource})`; | ||
|
||
return link; | ||
|
||
} | ||
|
||
/** | ||
* Determines whether a specified text string is referencing a local function or | ||
* a separate contract. | ||
* {Contract#function} is not local | ||
* {function} is local | ||
*/ | ||
function isFunction(name: string) { | ||
return (!name.includes('#') && name.length > 0 && name[0] === name[0].toLowerCase()); | ||
} | ||
|
||
/** | ||
* Identify local anchors by #Item | ||
*/ | ||
function isAnchor(name: string) { | ||
return (name[0] === '#'); | ||
} |
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,6 @@ | ||
{{#each items}} | ||
{{#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}} | ||
} | ||
``` |
1 change: 1 addition & 0 deletions
1
packages/hyperlane-contracts/docs-templates/user-defined-value-type.hbs
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}} |
Oops, something went wrong.