Skip to content

Commit 0eb975f

Browse files
feat/starknet-core-abi-exports
1 parent c517e5c commit 0eb975f

21 files changed

Lines changed: 813 additions & 7 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hyperlane-xyz/starknet-core': major
3+
---
4+
5+
feat: Add Starknet contract ABI fetching and contract artifact generation

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ COPY typescript/github-proxy/package.json ./typescript/github-proxy/
2222
COPY typescript/cosmos-types/package.json ./typescript/cosmos-types/
2323
COPY typescript/cosmos-sdk/package.json ./typescript/cosmos-sdk/
2424
COPY solidity/package.json ./solidity/
25+
COPY starknet/package.json ./starknet/
2526

2627
RUN yarn install && yarn cache clean
2728

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
},
4141
"workspaces": [
4242
"solidity",
43-
"typescript/*"
43+
"typescript/*",
44+
"starknet"
4445
],
4546
"resolutions": {
4647
"async": "^2.6.4",

starknet/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.env
2+
dist
3+
release

starknet/README.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Hyperlane Starknet Core
2+
3+
The Hyperlane Starknet Core package provides TypeScript tooling for interacting with Hyperlane's Cairo contracts on Starknet. It includes TypeScript artifacts autogenerated from Cairo contracts developed in collaboration with Astraly Labs.
4+
5+
## Features
6+
7+
- Pre-compiled Cairo contract ABI artifacts
8+
- TypeScript bindings for Starknet contracts
9+
10+
## Installation
11+
12+
```bash
13+
# Install with NPM
14+
npm install @hyperlane-xyz/starknet-core
15+
16+
# Or with Yarn
17+
yarn add @hyperlane-xyz/starknet-core
18+
```
19+
20+
## Requirements
21+
22+
- Node.js 18 or newer
23+
- For development: `curl`, `jq`, and `unzip` utilities
24+
25+
## Usage
26+
27+
```typescript
28+
import {
29+
ContractType,
30+
getCompiledContract,
31+
} from '@hyperlane-xyz/starknet-core';
32+
33+
// Get the Hyperlane mailbox contract
34+
const mailboxContract = getCompiledContract('mailbox');
35+
36+
// Get token contracts
37+
const tokenContract = getCompiledContract('erc20', ContractType.TOKEN);
38+
39+
// Get mock contracts
40+
const mockContract = getCompiledContract('mock_validator', ContractType.MOCK);
41+
```
42+
43+
## Contract Categories
44+
45+
Contracts are organized into three categories:
46+
47+
- `contracts`: Core Hyperlane protocol contracts
48+
- `tokens`: Token implementation contracts
49+
- `mocks`: Test and mock contracts
50+
51+
## Development
52+
53+
### Setup
54+
55+
1. Clone the repository
56+
2. Install dependencies: `yarn install`
57+
58+
### Build Process
59+
60+
The build process combines multiple steps in a specific order:
61+
62+
```bash
63+
yarn build
64+
```
65+
66+
This command runs:
67+
68+
1. TypeScript compilation (`tsc`)
69+
2. Fetching contract artifacts from GitHub (`fetch-contracts`)
70+
3. Generating TypeScript ABI artifacts from Cairo contracts (`generate-artifacts`)
71+
72+
All build output is placed in the `dist` directory.
73+
74+
### Individual Build Steps
75+
76+
You can also run the individual build steps separately:
77+
78+
#### Fetching Contract Artifacts
79+
80+
```bash
81+
yarn fetch-contracts
82+
```
83+
84+
This downloads the contract artifacts from the [Hyperlane Starknet repository](https://github.com/hyperlane-xyz/hyperlane_starknet).
85+
86+
#### Generating TypeScript Artifacts
87+
88+
```bash
89+
yarn generate-artifacts
90+
```
91+
92+
This creates JavaScript and TypeScript declaration files in the `dist/artifacts` directory.
93+
94+
## License
95+
96+
Apache 2.0

starknet/eslint.config.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import MonorepoDefaults from '../eslint.config.mjs';
2+
3+
export default [
4+
...MonorepoDefaults,
5+
{
6+
files: ['**/*.ts'],
7+
rules: {
8+
'no-console': 'off',
9+
'no-restricted-imports': 'off',
10+
},
11+
},
12+
{
13+
ignores: ['scripts/**/*'],
14+
},
15+
];

starknet/package.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "@hyperlane-xyz/starknet-core",
3+
"description": "Core cairo contracts for Hyperlane",
4+
"version": "1.0.0",
5+
"type": "module",
6+
"homepage": "https://www.hyperlane.xyz",
7+
"license": "Apache-2.0",
8+
"scripts": {
9+
"fetch-contracts": "./scripts/fetch-contracts-release.sh",
10+
"generate-artifacts": "tsx ./scripts/generate-artifacts.ts",
11+
"build": "tsc && yarn fetch-contracts && yarn generate-artifacts",
12+
"clean": "rm -rf ./dist ./release",
13+
"lint": "eslint -c ./eslint.config.mjs .",
14+
"prettier": "prettier --write ./src ./package.json"
15+
},
16+
"exports": {
17+
".": {
18+
"types": "./dist/index.d.ts",
19+
"default": "./dist/index.js"
20+
}
21+
},
22+
"types": "./dist/index.d.ts",
23+
"files": [
24+
"dist"
25+
],
26+
"keywords": [
27+
"Hyperlane",
28+
"Cairo",
29+
"Starknet"
30+
],
31+
"dependencies": {
32+
"starknet": "^6.24.1"
33+
},
34+
"devDependencies": {
35+
"@eslint/js": "^9.15.0",
36+
"@typescript-eslint/eslint-plugin": "^8.1.6",
37+
"@typescript-eslint/parser": "^8.1.6",
38+
"eslint": "^9.15.0",
39+
"eslint-config-prettier": "^9.1.0",
40+
"eslint-import-resolver-typescript": "^3.6.3",
41+
"eslint-plugin-import": "^2.31.0",
42+
"globby": "^14.1.0",
43+
"prettier": "^3.5.3",
44+
"tsx": "^4.19.1",
45+
"typescript": "5.3.3"
46+
}
47+
}

0 commit comments

Comments
 (0)