Skip to content

Commit 8224a95

Browse files
committed
Merge branch 'main' into dependabot/npm_and_yarn/npm_and_yarn-675ef9a19c
2 parents 973f993 + 85a92d2 commit 8224a95

30 files changed

+878
-383
lines changed

.github/workflows/npm-publish.yml

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,43 @@ name: NPM Publish
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
dry-run-enabled:
7+
description: 'Enable dry run for publishing (does not publish to npmjs)'
8+
required: false
9+
default: false
10+
type: boolean
511

612
permissions:
13+
id-token: write
714
contents: read
815

916
jobs:
10-
publish:
11-
name: Publish NPM package
17+
build-npm-package:
18+
name: Build NPM package
1219
runs-on: smart-contracts-linux-medium
20+
outputs:
21+
npm-artifact-name: ${{ steps.set-publish-data.outputs.artifact-name }}
1322
steps:
14-
- name: Harden Runner
15-
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
23+
- name: Harden the runner (Audit all outbound calls)
24+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
1625
with:
1726
egress-policy: audit
1827

19-
- name: Checkout Code
20-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
28+
- name: Prepare Runner
29+
uses: pandaswhocode/initialize-github-job@ed4a98646fe0235e6ecf3af5414b355d2abe3bf3 # v1.0.3
2130
with:
22-
submodules: recursive
31+
checkout: 'true'
32+
checkout-ref: '${{ github.ref }}'
33+
checkout-token: '${{ secrets.GITHUB_TOKEN }}'
34+
checkout-fetch-depth: '1'
35+
setup-node: 'true'
36+
node-version: '20'
2337

24-
- name: Set up Node.js
25-
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
38+
- name: Setup JQ
39+
uses: dcarbone/install-jq-action@b7ef57d46ece78760b4019dbc4080a1ba2a40b45 # v3.2.0
2640
with:
27-
node-version: '20'
28-
registry-url: 'https://registry.npmjs.org'
41+
version: 1.7
2942

3043
- name: Install Foundry
3144
uses: step-security/foundry-toolchain@01e2d127ea061e2ce8fa34340de71ca8518f093e # v1.2.1
@@ -41,7 +54,60 @@ jobs:
4154
- name: Run Unit Tests
4255
run: npm run test
4356

44-
- name: Publish NPM package
45-
run: npm publish --access public
46-
env:
47-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
57+
- name: Set Publish Data
58+
id: set-publish-data
59+
run: |
60+
VERSION=$(jq -r '.version' './package.json')
61+
NPM_PACKAGE_NAME="hashgraph-system-contracts-forking-${VERSION}.tgz"
62+
echo "artifact-name=${NPM_PACKAGE_NAME}" >> "${GITHUB_OUTPUT}"
63+
64+
- name: Build NPM package
65+
run: npm pack
66+
67+
- name: Upload Hedera Custodians Library Package Artifact
68+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
69+
with:
70+
name: npm-package
71+
path: ./${{ steps.set-publish-data.outputs.artifact-name }}
72+
if-no-files-found: error
73+
74+
publish-npm-package:
75+
runs-on: ubuntu-latest
76+
needs:
77+
- build-npm-package
78+
steps:
79+
- name: Harden the runner (Audit all outbound calls)
80+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
81+
with:
82+
egress-policy: audit
83+
84+
- name: Prepare Runner
85+
uses: pandaswhocode/initialize-github-job@ed4a98646fe0235e6ecf3af5414b355d2abe3bf3 # v1.0.3
86+
with:
87+
checkout: 'true'
88+
checkout-ref: '${{ github.ref }}'
89+
checkout-fetch-depth: '1'
90+
checkout-token: '${{ secrets.GITHUB_TOKEN }}'
91+
setup-node: 'true'
92+
node-version: '20'
93+
node-registry: 'https://registry.npmjs.org'
94+
95+
- name: Install NPM latest
96+
run: npm install -g npm@11.7.0
97+
98+
- name: Download Hedera Custodians Library NPM Package
99+
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
100+
with:
101+
name: npm-package
102+
103+
- name: Publish NPM Package
104+
run: |
105+
args="--access=public"
106+
if [[ "${{ inputs.dry-run-enabled || 'false' }}" == "true" ]]; then
107+
args="${args} --dry-run"
108+
fi
109+
110+
package="${{ needs.build-npm-package.outputs.npm-artifact-name }}"
111+
echo "::group::Publishing package: ${package} with args: ${args}"
112+
npm publish ${package} ${args}
113+
echo "::endgroup::"

.github/workflows/test.yml

Lines changed: 100 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,35 @@ jobs:
284284
slug: hashgraph/hedera-forking
285285

286286
foundry-example-tests:
287-
name: 'Foundry example tests w/mainnet'
287+
name: 'Foundry example tests'
288+
strategy:
289+
fail-fast: false
290+
matrix:
291+
solc: [
292+
# Ensures we use the `override` specifier
293+
# https://soliditylang.org/blog/2021/09/27/solidity-0.8.8-release-announcement/
294+
'0.8.7',
295+
296+
# Ensures we do not use `string.concat`
297+
# > General: string.concat now properly takes strings as arguments and returns string memory.
298+
# > It was accidentally introduced as a copy of bytes.concat before.
299+
# https://soliditylang.org/blog/2022/02/16/solidity-0.8.12-release-announcement/
300+
'0.8.11',
301+
302+
# Ensures we do not overload/use free functions
303+
# https://soliditylang.org/blog/2022/03/16/solidity-0.8.13-release-announcement/
304+
'0.8.12',
305+
306+
# Ensures we do not use "named parameters in mapping types"
307+
# See _Language Features_ https://soliditylang.org/blog/2023/02/01/solidity-0.8.18-release-announcement/
308+
'0.8.17',
309+
310+
# Ensures we do not use "qualified access to events from other contracts"
311+
# See _Qualified access to foreign events_ https://soliditylang.org/blog/2023/07/19/solidity-0.8.21-release-announcement/
312+
'0.8.19',
313+
314+
'0.8.24',
315+
]
288316
runs-on: smart-contracts-linux-medium
289317
steps:
290318
- name: Harden Runner
@@ -302,14 +330,16 @@ jobs:
302330
with:
303331
version: stable
304332

305-
- name: Patch Foundry's config file to run only Foundry HTS examples
306-
run: echo 'test="examples/foundry-hts"' >> foundry.toml
307-
308-
- name: Run Forge build with custom remappings
309-
run: forge build --remappings hedera-forking=.
333+
- name: Run Forge build on Foundry HTS example
334+
run: forge build
335+
working-directory: examples/foundry-hts
336+
env:
337+
# https://book.getfoundry.sh/reference/config/solidity-compiler#solc_version
338+
FOUNDRY_SOLC_VERSION: ${{ matrix.solc }}
310339

311-
- name: Run Forge example tests using remote network with a pinned block number
312-
run: forge test --remappings hedera-forking=. -vv --fork-url https://mainnet.hashio.io/api --fork-block-number 72433403
340+
- name: Run Forge HTS example tests using remote network with a pinned block number
341+
run: forge test -vv --fork-url mainnet --fork-block-number 72433403
342+
working-directory: examples/foundry-hts
313343

314344
hardhat-example-tests:
315345
name: 'Hardhat example tests w/mainnet'
@@ -349,6 +379,68 @@ jobs:
349379
run: npm run test
350380
working-directory: examples/hardhat-hts
351381

382+
foundry-example-scripts:
383+
name: Foundry example scripts w/local node
384+
runs-on: smart-contracts-linux-medium
385+
steps:
386+
- name: Harden Runner
387+
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
388+
with:
389+
egress-policy: audit
390+
391+
- name: Checkout Code
392+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
393+
with:
394+
submodules: recursive
395+
396+
- name: Set up Node.js
397+
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
398+
with:
399+
node-version: 20
400+
401+
- name: Install Foundry
402+
uses: step-security/foundry-toolchain@01e2d127ea061e2ce8fa34340de71ca8518f093e # v1.2.1
403+
with:
404+
version: stable
405+
406+
- name: Run Forge build
407+
run: forge build
408+
409+
- name: Install Dependencies
410+
run: npm ci
411+
412+
- name: Start the local node
413+
run: npx hedera start --detach --verbose=trace
414+
timeout-minutes: 5
415+
416+
- name: Run Forge build on Foundry HTS example
417+
run: forge build
418+
working-directory: examples/foundry-hts
419+
420+
# Uses a local node's account private key
421+
# https://github.com/hiero-ledger/hiero-local-node?tab=readme-ov-file#hedera-start-options
422+
- name: Set up Local Node's account Private Key
423+
run: echo "PRIVATE_KEY=0x105d050185ccb907fba04dd92d8de9e32c18305e097ab41dadda21489a211524" > .env
424+
working-directory: examples/foundry-hts
425+
426+
- name: Run Foundry script on local node
427+
run: forge script script/CreateToken.s.sol -vvv --rpc-url localnode --skip-simulation --broadcast
428+
working-directory: examples/foundry-hts
429+
430+
# https://book.getfoundry.sh/guides/scripting-with-solidity
431+
- name: Verify the token was created
432+
run: |
433+
TOKEN_ADDR=`cat broadcast/CreateToken.s.sol/298/run-latest.json | jq '.receipts[0].contractAddress' --raw-output`
434+
echo "Token Address: $TOKEN_ADDR"
435+
TOKEN_CODE=`cast code --rpc-url localnode $TOKEN_ADDR`
436+
echo "Token Code: $TOKEN_CODE"
437+
test $TOKEN_CODE != "0x"
438+
working-directory: examples/foundry-hts
439+
440+
- name: Stop the local node
441+
if: ${{ !cancelled() }}
442+
run: npx hedera stop
443+
352444
e2e-test:
353445
name: 'NPM e2e validation tests'
354446
runs-on: smart-contracts-linux-medium

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@
1818
# `reports-dir`: directory where coverage reports will be output to
1919
# https://github.com/bcoe/c8?tab=readme-ov-file#cli-options--configuration
2020
/coverage/
21+
22+
# IDEA
23+
**/.DS_Store
24+
**/.idea/

FAQ.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,26 @@ That is why when trying to get the code, for example using `cast code --rpc-url
2626
address of the HTS System Contract, you get `0xfe`.
2727
That leads to the error `EvmError: InvalidFEOpcode` mentioned in the question.
2828

29+
### Why am I getting error "`Member "keyExistsJson" not found or not visible`" when compiling my project?
30+
31+
If you get the following error when compiling your project
32+
33+
```console
34+
$ forge build
35+
[...]
36+
Error: Compiler run failed:
37+
Error (9582): Member "keyExistsJson" not found or not visible after argument-dependent lookup in contract Vm.
38+
```
39+
40+
it is because your `forge-std` dependency is outdated.
41+
You can [update](https://book.getfoundry.sh/reference/forge/forge-update) `forge-std` with
42+
43+
```sh
44+
forge update lib/forge-std
45+
```
46+
47+
See [_§ Requirements_](./README.md#requirements) for the full list of requirements needed to compile your project.
48+
2949
## Hardhat
3050

3151
### What causes the error `ProviderError: No known hardfork for execution`

0 commit comments

Comments
 (0)