Skip to content

Commit cf5a70f

Browse files
Merge pull request #2973 from pyth-network/remove-truffle
feat(contracts): remove truffle and replace with foundry
2 parents f9362fc + 68b3d81 commit cf5a70f

31 files changed

+780
-4413
lines changed

.github/workflows/ci-turbo-build.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@ jobs:
2626
# precompiled binary isn't found.
2727
- name: Install libusb
2828
run: sudo apt-get update && sudo apt-get install -y libusb-1.0-0-dev libudev-dev
29+
# Install Foundry for Ethereum contract builds
30+
- name: Install Foundry
31+
uses: foundry-rs/foundry-toolchain@v1
32+
with:
33+
version: v0.3.0
2934
- uses: pnpm/action-setup@v4
3035
name: Install pnpm
3136
with:
3237
run_install: true
38+
- name: Install Forge dependencies
39+
run: cd target_chains/ethereum/contracts && pnpm run install-forge-deps
3340
- name: Cache for Turbo
3441
uses: rharkor/[email protected]
3542
- name: Build

.github/workflows/ci-turbo-test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v4
20+
- uses: actions-rust-lang/setup-rust-toolchain@v1
2021
- uses: actions/setup-node@v4
2122
with:
2223
node-version-file: "package.json"
@@ -25,10 +26,17 @@ jobs:
2526
# precompiled binary isn't found.
2627
- name: Install libusb
2728
run: sudo apt-get update && sudo apt-get install -y libusb-1.0-0-dev libudev-dev
29+
# Install Foundry for Ethereum contract tests
30+
- name: Install Foundry
31+
uses: foundry-rs/foundry-toolchain@v1
32+
with:
33+
version: v0.3.0
2834
- uses: pnpm/action-setup@v4
2935
name: Install pnpm
3036
with:
3137
run_install: true
38+
- name: Install Forge dependencies
39+
run: cd target_chains/ethereum/contracts && pnpm run install-forge-deps
3240
- name: Cache for Turbo
3341
uses: rharkor/[email protected]
3442
- name: Test

.github/workflows/publish-js.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ jobs:
99
name: Publish Javascript Packages to NPM
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v4
13+
- uses: actions-rust-lang/setup-rust-toolchain@v1
1314
- uses: actions/setup-node@v4
1415
with:
1516
node-version-file: "package.json"
@@ -18,10 +19,17 @@ jobs:
1819
# precompiled binary isn't found.
1920
- name: Install libusb
2021
run: sudo apt-get update && sudo apt-get install -y libusb-1.0-0-dev libudev-dev
22+
# Install Foundry for Ethereum contract builds
23+
- name: Install Foundry
24+
uses: foundry-rs/foundry-toolchain@v1
25+
with:
26+
version: v0.3.0
2127
- uses: pnpm/action-setup@v4
2228
name: Install pnpm
2329
with:
2430
run_install: true
31+
- name: Install Forge dependencies
32+
run: cd target_chains/ethereum/contracts && pnpm run install-forge-deps
2533
- name: Set publishing config
2634
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
2735
env:

apps/developer-hub/next-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3+
/// <reference path="./.next/types/routes.d.ts" />
34

45
// NOTE: This file should not be edited
56
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

contract_manager/scripts/common.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ export async function deployIfNotCached(
3535
const key = cacheKey ?? `${chain.getId()}-${artifactName}`;
3636
return runIfNotCached(key, async () => {
3737
const artifact = JSON.parse(
38-
readFileSync(join(config.jsonOutputDir, `${artifactName}.json`), "utf8"),
38+
readFileSync(
39+
join(
40+
config.jsonOutputDir,
41+
`${artifactName}.sol`,
42+
`${artifactName}.json`,
43+
),
44+
"utf8",
45+
),
3946
);
4047

4148
// Handle bytecode which can be either a string or an object with an 'object' property
@@ -74,7 +81,10 @@ export function getWeb3Contract(
7481
address: string,
7582
): Contract {
7683
const artifact = JSON.parse(
77-
readFileSync(join(jsonOutputDir, `${artifactName}.json`), "utf8"),
84+
readFileSync(
85+
join(jsonOutputDir, `${artifactName}.sol`, `${artifactName}.json`),
86+
"utf8",
87+
),
7888
);
7989
const web3 = new Web3();
8090
return new web3.eth.Contract(artifact["abi"], address);
@@ -84,7 +94,7 @@ export const COMMON_DEPLOY_OPTIONS = {
8494
"std-output-dir": {
8595
type: "string",
8696
demandOption: true,
87-
desc: "Path to the standard JSON output of the contracts (build artifact) directory",
97+
desc: "Path to the Foundry output directory (contains Contract.sol/Contract.json structure)",
8898
},
8999
"private-key": {
90100
type: "string",

contract_manager/scripts/deploy_evm_lazer_contracts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ export async function main() {
323323
console.log(`\n✅ Contract deployed at: ${deployedAddress}`);
324324
console.log(`Trusted signer updated: ${argv["update-signer"]}`);
325325
console.log(
326-
`Expires at: ${new Date(argv["expires-at"]! * 1000).toISOString()}`,
326+
`Expires at: ${new Date((argv["expires-at"] ?? 0) * 1000).toISOString()}`,
327327
);
328328
} else if (argv.deploy) {
329329
console.log(`Contract deployed at ${deployedAddress}`);

contract_manager/scripts/transfer_balance_entropy_chains.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ async function transferOnChain(
157157
transferAmountEth = transferAmount;
158158
} else {
159159
// transferRatio is guaranteed to be defined at this point
160-
transferAmountEth = (balanceEth - gasCostEth) * transferRatio!;
160+
if (transferRatio === undefined) {
161+
throw new Error(
162+
"Transfer ratio must be defined when amount is not specified",
163+
);
164+
}
165+
transferAmountEth = (balanceEth - gasCostEth) * transferRatio;
161166
}
162167

163168
// Round to 10 decimal places to avoid Web3 conversion errors
@@ -299,7 +304,12 @@ function getSelectedChains(argv: {
299304
);
300305
selectedChains = [];
301306

302-
for (const chainId of argv.chain!) {
307+
if (!argv.chain) {
308+
throw new Error(
309+
"Chain argument must be defined for specific chain selection",
310+
);
311+
}
312+
for (const chainId of argv.chain) {
303313
if (!entropyChainIds.has(chainId)) {
304314
throw new Error(
305315
`Chain ${chainId} does not have entropy contracts deployed`,
@@ -360,7 +370,10 @@ async function main() {
360370
if (argv.amount !== undefined) {
361371
transferMethod = `${argv.amount} ETH (fixed amount)`;
362372
} else {
363-
transferMethod = `${(argv.ratio! * 100).toFixed(1)}% of available balance`;
373+
if (argv.ratio === undefined) {
374+
throw new Error("Ratio must be defined when amount is not specified");
375+
}
376+
transferMethod = `${(argv.ratio * 100).toFixed(1)}% of available balance`;
364377
}
365378

366379
console.log(`\nConfiguration:`);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3+
/// <reference path="./.next/types/routes.d.ts" />
34

45
// NOTE: This file should not be edited
56
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.

0 commit comments

Comments
 (0)