Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: automatic update of HederaResponseCodes.sol #1220

Merged
merged 29 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8388f54
chore: test ci
natanasow Feb 4, 2025
0e87a9e
chore: test ci
natanasow Feb 4, 2025
efffdcf
chore: test ci
natanasow Feb 4, 2025
0c861f6
chore: add latest hedera response codes
natanasow Feb 4, 2025
85f3db4
chore: rename .yml
natanasow Feb 4, 2025
a344eef
chore: rename .yml
natanasow Feb 4, 2025
53d6390
Merge branch 'main' into 1219-test-new-ci
natanasow Feb 5, 2025
bd5c180
chore: resolve comments
natanasow Feb 5, 2025
11865a3
chore: resolve comments
natanasow Feb 5, 2025
b9a8d71
chore: resolve comments
natanasow Feb 5, 2025
e3a0da4
chore: resolve comments
natanasow Feb 5, 2025
d588cfe
chore: resolve comments
natanasow Feb 5, 2025
74a2a64
chore: resolve comments
natanasow Feb 5, 2025
92c3ffd
chore: resolve comments
natanasow Feb 5, 2025
530e475
chore: resolve comments
natanasow Feb 5, 2025
3fc847d
chore: resolve comments
natanasow Feb 5, 2025
009f168
chore: resolve comments
natanasow Feb 5, 2025
82bb13b
chore: resolve comments
natanasow Feb 5, 2025
400977e
chore: resolve comments
natanasow Feb 5, 2025
72ff221
chore: resolve comments
natanasow Feb 5, 2025
aad9671
chore: resolve comments
natanasow Feb 5, 2025
358737b
chore: resolve comments
natanasow Feb 5, 2025
98f4c8b
chore: resolve comments
natanasow Feb 5, 2025
cd992b1
chore: resolve comments
natanasow Feb 5, 2025
bfb365f
chore: resolve comments
natanasow Feb 5, 2025
1a2f2c8
chore: resolve comments
natanasow Feb 5, 2025
51feb04
chore: resolve comments
natanasow Feb 5, 2025
848ba25
chore: push the latest contract
natanasow Feb 5, 2025
8d6e963
chore: resolve comments
natanasow Feb 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/scripts/hedera-response-codes-protobuf-parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const hederaProto = require('@hashgraph/proto');
natanasow marked this conversation as resolved.
Show resolved Hide resolved
natanasow marked this conversation as resolved.
Show resolved Hide resolved
natanasow marked this conversation as resolved.
Show resolved Hide resolved
const fs = require('fs');
const shell = require('shelljs');

async function main() {
let contract =
'// SPDX-License-Identifier: Apache-2.0\n' +
'pragma solidity >=0.4.9 <0.9.0;\n' +
'\n// this contract is auto-generated by a manual triggered script in utils/hedera-response-codes-protobuf-parser.js' +
'\n// documentation for each code can be found here https://github.com/hashgraph/hedera-services/blob/main/hapi/hedera-protobufs/services/response_code.proto\n\n' +
'library HederaResponseCodes {\n';

for (const [name, code] of Object.entries(hederaProto.proto.ResponseCodeEnum)) {
contract += ` int32 internal constant ${name} = ${code};\n`;
}

contract += '}\n';

fs.writeFileSync('./contracts/system-contracts/HederaResponseCodes.sol', contract);
shell.exec('npx hardhat compile');
natanasow marked this conversation as resolved.
Show resolved Hide resolved
}

main();
65 changes: 65 additions & 0 deletions .github/workflows/update-hedera-response-codes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Update HederaResponseCodes.sol

on:
workflow_dispatch:

jobs:
parse-and-update:
natanasow marked this conversation as resolved.
Show resolved Hide resolved
name: Make HederaResponseCodes up-to-date with the latest protobufs
runs-on: smart-contracts-linux-large

steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit

- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: recursive

- name: Use Node.js [20]
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: 20

- name: Install Dependencies
run: npm install

- name: Install Foundry
uses: step-security/foundry-toolchain@01e2d127ea061e2ce8fa34340de71ca8518f093e # v1.2.1
with:
version: nightly

- name: Parse and update response codes
run: node .github/scripts/hedera-response-codes-protobuf-parser.js

- name: Import GPG Key
id: gpg_importer
uses: step-security/ghaction-import-gpg@6c8fe4d0126a59d57c21f87c9ae5dd3451fa3cca # v6.1.0
with:
git_commit_gpgsign: true
git_tag_gpgsign: true
git_user_signingkey: true
gpg_private_key: ${{ secrets.GPG_KEY_CONTENTS }}
passphrase: ${{ secrets.GPG_KEY_PASSPHRASE }}

- name: Create Pull Request Target hedera-smart-contracts Repository
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # v7.0.6
with:
branch: HederaResponseCodes-Periodical-Update/${{ github.run_id }}
natanasow marked this conversation as resolved.
Show resolved Hide resolved
commit-message: 'chore: update HederaResponseContract.sol with the latest protobufs'
committer: ${{ steps.gpg_importer.outputs.name }} <${{ steps.gpg_importer.outputs.email }}>
add-paths: contracts/system-contracts/HederaResponseCodes.sol
author: ${{ steps.gpg_importer.outputs.name }} <${{ steps.gpg_importer.outputs.email }}>
token: ${{ secrets.GH_ACCESS_TOKEN }}
delete-branch: true
signoff: true
title: 'chore: update HederaResponseContract.sol with the latest protobufs'
body: >
**Description**:

This PR updates HederaResponseCodes.sol with these from https://github.com/hashgraph/hedera-services/blob/main/hapi/hedera-protobufs/services/response_code.proto.
natanasow marked this conversation as resolved.
Show resolved Hide resolved
labels: 'internal'
assignees: 'swirlds-automation'
Loading
Loading