Skip to content

Commit

Permalink
Truffle <> relay compatibility (#379)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
natanasow committed Jul 26, 2022
1 parent c19b937 commit acc4c9e
Show file tree
Hide file tree
Showing 9 changed files with 20,751 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/truffle-compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Truffle Compatibility

on:
pull_request:
branches: [ main, release/** ]
push:
branches: [ main, release/** ]
tags: [ v* ]

jobs:
setup-local-hedera:
name: Truffle Compatibility
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 16

- name: Checkout repo
uses: actions/checkout@v2

- name: Install packages
run: npm ci

- name: Create .env file
run: |
cp ./tools/truffle-example/.env.example ./tools/truffle-example/.env
cp ./packages/server/tests/localAcceptance.env .env
- name: Lerna Bootstrap
run: npm run setup

- name: Install pnpm
run: npm install -g pnpm

- name: Build Typescript
run: npx lerna run build

- name: Run RPC Server
run: npm run integration:prerequisite &

- name: Install truffle dependencies
run: cd ./tools/truffle-example/ && npm ci

- name: Run the truffle tests
uses: nick-fields/retry@v2
with:
max_attempts: 10
timeout_minutes: 10
retry_wait_seconds: 45
command: cd ./tools/truffle-example/ && npx truffle test
5 changes: 5 additions & 0 deletions tools/truffle-example/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# all available private keys and addresses can be found here https://github.com/hashgraph/hedera-local-node#commands
OPERATOR_PRIVATE_KEY=0x105d050185ccb907fba04dd92d8de9e32c18305e097ab41dadda21489a211524
RECEIVER_PRIVATE_KEY=0x2e1d968b041d84dd120a5860cee60cd83f9374ef527ca86996317ada3d0d03e7
RELAY_URL='http://localhost'
RELAY_PORT=7546
9 changes: 9 additions & 0 deletions tools/truffle-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types

#Truffle files
build
18 changes: 18 additions & 0 deletions tools/truffle-example/contracts/Greeter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

contract Greeter {
string private greeting;

constructor(string memory _greeting) {
greeting = _greeting;
}

function greet() public view returns (string memory) {
return greeting;
}

function setGreeting(string memory _greeting) public {
greeting = _greeting;
}
}
25 changes: 25 additions & 0 deletions tools/truffle-example/migrations/1_deploy_greeter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*-
*
* Hedera JSON RPC Relay - Truffle Example
*
* Copyright (C) 2022 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

const Greeter = artifacts.require('Greeter');

module.exports = function (deployer) {
deployer.deploy(Greeter, 'initial_msg');
};
Loading

0 comments on commit acc4c9e

Please sign in to comment.