Skip to content

Commit acc4c9e

Browse files
authored
Truffle <> relay compatibility (#379)
* Add truffle-relay compatibility Signed-off-by: nikolay <[email protected]> * Add license headers Signed-off-by: nikolay <[email protected]> * Edit package.json Signed-off-by: nikolay <[email protected]> * Edit tests Signed-off-by: nikolay <[email protected]> * Add note Signed-off-by: nikolay <[email protected]>
1 parent c19b937 commit acc4c9e

File tree

9 files changed

+20751
-0
lines changed

9 files changed

+20751
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Truffle Compatibility
2+
3+
on:
4+
pull_request:
5+
branches: [ main, release/** ]
6+
push:
7+
branches: [ main, release/** ]
8+
tags: [ v* ]
9+
10+
jobs:
11+
setup-local-hedera:
12+
name: Truffle Compatibility
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
steps:
17+
- name: Setup node
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: 16
21+
22+
- name: Checkout repo
23+
uses: actions/checkout@v2
24+
25+
- name: Install packages
26+
run: npm ci
27+
28+
- name: Create .env file
29+
run: |
30+
cp ./tools/truffle-example/.env.example ./tools/truffle-example/.env
31+
cp ./packages/server/tests/localAcceptance.env .env
32+
33+
- name: Lerna Bootstrap
34+
run: npm run setup
35+
36+
- name: Install pnpm
37+
run: npm install -g pnpm
38+
39+
- name: Build Typescript
40+
run: npx lerna run build
41+
42+
- name: Run RPC Server
43+
run: npm run integration:prerequisite &
44+
45+
- name: Install truffle dependencies
46+
run: cd ./tools/truffle-example/ && npm ci
47+
48+
- name: Run the truffle tests
49+
uses: nick-fields/retry@v2
50+
with:
51+
max_attempts: 10
52+
timeout_minutes: 10
53+
retry_wait_seconds: 45
54+
command: cd ./tools/truffle-example/ && npx truffle test

tools/truffle-example/.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# all available private keys and addresses can be found here https://github.com/hashgraph/hedera-local-node#commands
2+
OPERATOR_PRIVATE_KEY=0x105d050185ccb907fba04dd92d8de9e32c18305e097ab41dadda21489a211524
3+
RECEIVER_PRIVATE_KEY=0x2e1d968b041d84dd120a5860cee60cd83f9374ef527ca86996317ada3d0d03e7
4+
RELAY_URL='http://localhost'
5+
RELAY_PORT=7546

tools/truffle-example/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
.env
3+
coverage
4+
coverage.json
5+
typechain
6+
typechain-types
7+
8+
#Truffle files
9+
build
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//SPDX-License-Identifier: Unlicense
2+
pragma solidity ^0.8.0;
3+
4+
contract Greeter {
5+
string private greeting;
6+
7+
constructor(string memory _greeting) {
8+
greeting = _greeting;
9+
}
10+
11+
function greet() public view returns (string memory) {
12+
return greeting;
13+
}
14+
15+
function setGreeting(string memory _greeting) public {
16+
greeting = _greeting;
17+
}
18+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*-
2+
*
3+
* Hedera JSON RPC Relay - Truffle Example
4+
*
5+
* Copyright (C) 2022 Hedera Hashgraph, LLC
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
*/
20+
21+
const Greeter = artifacts.require('Greeter');
22+
23+
module.exports = function (deployer) {
24+
deployer.deploy(Greeter, 'initial_msg');
25+
};

0 commit comments

Comments
 (0)