Skip to content

Commit eab799c

Browse files
authored
Create contracts package (#774)
* Create contracts package * Generate changeset
1 parent 6707a4e commit eab799c

15 files changed

+2525
-0
lines changed

.changeset/grumpy-cats-swim.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@helixbridge/contracts": minor
3+
---
4+
5+
Add contracts package

packages/contracts/.eslintrc.cjs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/** @type {import("eslint").Linter.Config} */
2+
module.exports = {
3+
root: true,
4+
extends: ["@helixbridge/eslint-config/index.js"],
5+
parser: "@typescript-eslint/parser",
6+
parserOptions: {
7+
project: true,
8+
},
9+
};

packages/contracts/package.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "@helixbridge/contracts",
3+
"version": "0.0.0",
4+
"main": "./dist/index.js",
5+
"module": "./dist/index.mjs",
6+
"types": "./dist/index.d.ts",
7+
"files": [
8+
"dist/**"
9+
],
10+
"scripts": {
11+
"clean": "rm -rf node_modules .turbo dist",
12+
"build": "tsup",
13+
"dev": "tsup --watch",
14+
"lint": "eslint src/",
15+
"typecheck": "tsc --noEmit"
16+
},
17+
"license": "MIT",
18+
"publishConfig": {
19+
"access": "public"
20+
},
21+
"dependencies": {
22+
"viem": "^1.21.4"
23+
},
24+
"devDependencies": {
25+
"@helixbridge/eslint-config": "workspace:*",
26+
"@helixbridge/tsconfig": "workspace:*",
27+
"@types/node": "^20",
28+
"eslint": "^8.57.0",
29+
"tsup": "^8.2.3",
30+
"typescript": "^5.2.2"
31+
}
32+
}

packages/contracts/src/erc20.ts

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
import { Abi, getContract } from "viem";
2+
import { TFunction } from "./types";
3+
4+
const abi = [
5+
{
6+
inputs: [
7+
{ internalType: "string", name: "name_", type: "string" },
8+
{ internalType: "string", name: "symbol_", type: "string" },
9+
{ internalType: "uint8", name: "decimals_", type: "uint8" },
10+
{ internalType: "uint256", name: "initialBalance_", type: "uint256" },
11+
{ internalType: "address payable", name: "feeReceiver_", type: "address" },
12+
],
13+
stateMutability: "payable",
14+
type: "constructor",
15+
},
16+
{
17+
anonymous: false,
18+
inputs: [
19+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
20+
{ indexed: true, internalType: "address", name: "spender", type: "address" },
21+
{ indexed: false, internalType: "uint256", name: "value", type: "uint256" },
22+
],
23+
name: "Approval",
24+
type: "event",
25+
},
26+
{
27+
anonymous: false,
28+
inputs: [
29+
{ indexed: true, internalType: "address", name: "from", type: "address" },
30+
{ indexed: true, internalType: "address", name: "to", type: "address" },
31+
{ indexed: false, internalType: "uint256", name: "value", type: "uint256" },
32+
],
33+
name: "Transfer",
34+
type: "event",
35+
},
36+
{
37+
inputs: [
38+
{ internalType: "address", name: "owner", type: "address" },
39+
{ internalType: "address", name: "spender", type: "address" },
40+
],
41+
name: "allowance",
42+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
43+
stateMutability: "view",
44+
type: "function",
45+
},
46+
{
47+
inputs: [
48+
{ internalType: "address", name: "spender", type: "address" },
49+
{ internalType: "uint256", name: "amount", type: "uint256" },
50+
],
51+
name: "approve",
52+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
53+
stateMutability: "nonpayable",
54+
type: "function",
55+
},
56+
{
57+
inputs: [{ internalType: "address", name: "account", type: "address" }],
58+
name: "balanceOf",
59+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
60+
stateMutability: "view",
61+
type: "function",
62+
},
63+
{
64+
inputs: [],
65+
name: "decimals",
66+
outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
67+
stateMutability: "view",
68+
type: "function",
69+
},
70+
{
71+
inputs: [
72+
{ internalType: "address", name: "spender", type: "address" },
73+
{ internalType: "uint256", name: "subtractedValue", type: "uint256" },
74+
],
75+
name: "decreaseAllowance",
76+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
77+
stateMutability: "nonpayable",
78+
type: "function",
79+
},
80+
{
81+
inputs: [
82+
{ internalType: "address", name: "spender", type: "address" },
83+
{ internalType: "uint256", name: "addedValue", type: "uint256" },
84+
],
85+
name: "increaseAllowance",
86+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
87+
stateMutability: "nonpayable",
88+
type: "function",
89+
},
90+
{
91+
inputs: [],
92+
name: "name",
93+
outputs: [{ internalType: "string", name: "", type: "string" }],
94+
stateMutability: "view",
95+
type: "function",
96+
},
97+
{
98+
inputs: [],
99+
name: "symbol",
100+
outputs: [{ internalType: "string", name: "", type: "string" }],
101+
stateMutability: "view",
102+
type: "function",
103+
},
104+
{
105+
inputs: [],
106+
name: "totalSupply",
107+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
108+
stateMutability: "view",
109+
type: "function",
110+
},
111+
{
112+
inputs: [
113+
{ internalType: "address", name: "recipient", type: "address" },
114+
{ internalType: "uint256", name: "amount", type: "uint256" },
115+
],
116+
name: "transfer",
117+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
118+
stateMutability: "nonpayable",
119+
type: "function",
120+
},
121+
{
122+
inputs: [
123+
{ internalType: "address", name: "sender", type: "address" },
124+
{ internalType: "address", name: "recipient", type: "address" },
125+
{ internalType: "uint256", name: "amount", type: "uint256" },
126+
],
127+
name: "transferFrom",
128+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
129+
stateMutability: "nonpayable",
130+
type: "function",
131+
},
132+
] as const satisfies Abi;
133+
134+
export const getErc20Contract: TFunction<typeof abi> = ({ address, publicClient, walletClient }) => {
135+
return getContract({ abi, address, publicClient, walletClient });
136+
};

packages/contracts/src/faucet.ts

+206
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
import { Abi, getContract } from "viem";
2+
import { TFunction } from "./types";
3+
4+
const abi = [
5+
{
6+
inputs: [
7+
{ internalType: "string", name: "_name", type: "string" },
8+
{ internalType: "string", name: "_symbol", type: "string" },
9+
{ internalType: "uint8", name: "_decimals", type: "uint8" },
10+
],
11+
stateMutability: "nonpayable",
12+
type: "constructor",
13+
},
14+
{
15+
anonymous: false,
16+
inputs: [
17+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
18+
{ indexed: true, internalType: "address", name: "spender", type: "address" },
19+
{ indexed: false, internalType: "uint256", name: "value", type: "uint256" },
20+
],
21+
name: "Approval",
22+
type: "event",
23+
},
24+
{
25+
anonymous: false,
26+
inputs: [
27+
{ indexed: true, internalType: "address", name: "previousOwner", type: "address" },
28+
{ indexed: true, internalType: "address", name: "newOwner", type: "address" },
29+
],
30+
name: "OwnershipTransferred",
31+
type: "event",
32+
},
33+
{
34+
anonymous: false,
35+
inputs: [
36+
{ indexed: true, internalType: "address", name: "from", type: "address" },
37+
{ indexed: true, internalType: "address", name: "to", type: "address" },
38+
{ indexed: false, internalType: "uint256", name: "value", type: "uint256" },
39+
],
40+
name: "Transfer",
41+
type: "event",
42+
},
43+
{
44+
inputs: [{ internalType: "address", name: "", type: "address" }],
45+
name: "allowFaucet",
46+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
47+
stateMutability: "view",
48+
type: "function",
49+
},
50+
{
51+
inputs: [
52+
{ internalType: "address", name: "owner", type: "address" },
53+
{ internalType: "address", name: "spender", type: "address" },
54+
],
55+
name: "allowance",
56+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
57+
stateMutability: "view",
58+
type: "function",
59+
},
60+
{
61+
inputs: [
62+
{ internalType: "address", name: "spender", type: "address" },
63+
{ internalType: "uint256", name: "amount", type: "uint256" },
64+
],
65+
name: "approve",
66+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
67+
stateMutability: "nonpayable",
68+
type: "function",
69+
},
70+
{
71+
inputs: [{ internalType: "address", name: "account", type: "address" }],
72+
name: "balanceOf",
73+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
74+
stateMutability: "view",
75+
type: "function",
76+
},
77+
{
78+
inputs: [
79+
{ internalType: "address", name: "account", type: "address" },
80+
{ internalType: "uint256", name: "amount", type: "uint256" },
81+
],
82+
name: "burn",
83+
outputs: [],
84+
stateMutability: "nonpayable",
85+
type: "function",
86+
},
87+
{
88+
inputs: [],
89+
name: "decimals",
90+
outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
91+
stateMutability: "view",
92+
type: "function",
93+
},
94+
{
95+
inputs: [
96+
{ internalType: "address", name: "spender", type: "address" },
97+
{ internalType: "uint256", name: "subtractedValue", type: "uint256" },
98+
],
99+
name: "decreaseAllowance",
100+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
101+
stateMutability: "nonpayable",
102+
type: "function",
103+
},
104+
{
105+
inputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
106+
name: "faucet",
107+
outputs: [],
108+
stateMutability: "nonpayable",
109+
type: "function",
110+
},
111+
{
112+
inputs: [
113+
{ internalType: "address", name: "spender", type: "address" },
114+
{ internalType: "uint256", name: "addedValue", type: "uint256" },
115+
],
116+
name: "increaseAllowance",
117+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
118+
stateMutability: "nonpayable",
119+
type: "function",
120+
},
121+
{
122+
inputs: [],
123+
name: "maxFaucetAllowed",
124+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
125+
stateMutability: "view",
126+
type: "function",
127+
},
128+
{
129+
inputs: [
130+
{ internalType: "address", name: "account", type: "address" },
131+
{ internalType: "uint256", name: "amount", type: "uint256" },
132+
],
133+
name: "mint",
134+
outputs: [],
135+
stateMutability: "nonpayable",
136+
type: "function",
137+
},
138+
{
139+
inputs: [],
140+
name: "name",
141+
outputs: [{ internalType: "string", name: "", type: "string" }],
142+
stateMutability: "view",
143+
type: "function",
144+
},
145+
{
146+
inputs: [],
147+
name: "owner",
148+
outputs: [{ internalType: "address", name: "", type: "address" }],
149+
stateMutability: "view",
150+
type: "function",
151+
},
152+
{ inputs: [], name: "renounceOwnership", outputs: [], stateMutability: "nonpayable", type: "function" },
153+
{
154+
inputs: [{ internalType: "uint256", name: "allowed", type: "uint256" }],
155+
name: "setMaxFaucetAllowed",
156+
outputs: [],
157+
stateMutability: "nonpayable",
158+
type: "function",
159+
},
160+
{
161+
inputs: [],
162+
name: "symbol",
163+
outputs: [{ internalType: "string", name: "", type: "string" }],
164+
stateMutability: "view",
165+
type: "function",
166+
},
167+
{
168+
inputs: [],
169+
name: "totalSupply",
170+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
171+
stateMutability: "view",
172+
type: "function",
173+
},
174+
{
175+
inputs: [
176+
{ internalType: "address", name: "recipient", type: "address" },
177+
{ internalType: "uint256", name: "amount", type: "uint256" },
178+
],
179+
name: "transfer",
180+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
181+
stateMutability: "nonpayable",
182+
type: "function",
183+
},
184+
{
185+
inputs: [
186+
{ internalType: "address", name: "sender", type: "address" },
187+
{ internalType: "address", name: "recipient", type: "address" },
188+
{ internalType: "uint256", name: "amount", type: "uint256" },
189+
],
190+
name: "transferFrom",
191+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
192+
stateMutability: "nonpayable",
193+
type: "function",
194+
},
195+
{
196+
inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
197+
name: "transferOwnership",
198+
outputs: [],
199+
stateMutability: "nonpayable",
200+
type: "function",
201+
},
202+
] as const satisfies Abi;
203+
204+
export const getFaucetContract: TFunction<typeof abi> = ({ address, publicClient, walletClient }) => {
205+
return getContract({ abi, address, publicClient, walletClient });
206+
};

0 commit comments

Comments
 (0)