Skip to content

Commit

Permalink
milestone: template contracts compiling successfully with this develo…
Browse files Browse the repository at this point in the history
…pment environment (truffle version)
  • Loading branch information
geor-ma committed Sep 25, 2021
1 parent a4acfe7 commit 3ee44f0
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 25 deletions.
6 changes: 5 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ ENV PATH="/usr/local/bin/node-v14.15.1-linux-x64/bin:${PATH}"

RUN npm install -g truffle --unsafe-perm

RUN npm install -g ganache-cli --unsafe-perm
RUN npm install -g ganache-cli --unsafe-perm

# RUN npm install --save [email protected]
# RUN npm install --save [email protected]
# RUN npm audit fix
20 changes: 19 additions & 1 deletion DEV-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### Setup

```
Commands:
Reference Commands:
Compile: truffle compile
Migrate: truffle migrate
Expand All @@ -12,3 +12,21 @@ Commands:
Build for production: cd app && npm run build
```

# Openzeppelin and hdwallet versions

```bash
npm install --save [email protected]
npm install --save [email protected]
```

```bash

$ truffle version

Truffle v5.4.9 (core: 5.4.9)
Solidity v0.5.16 (solc-js)
Node v14.15.1
Web3.js v1.5.2

```
16 changes: 7 additions & 9 deletions flight-surety/contracts/FlightSuretyApp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ pragma solidity >=0.4.21 <0.7.0;
// OpenZeppelin's SafeMath library, when used correctly, protects agains such bugs
// More info: https://www.nccgroup.trust/us/about-us/newsroom-and-events/blog/2018/november/smart-contract-insecurity-bad-arithmetic/

//import "../node_modules/openzeppelin-solidity/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";

//import "github.com/OpenZeppelin/openzeppelin-contracts/contracts/utils/math/SafeMath.sol";
import "../node_modules/openzeppelin-solidity/contracts/math/SafeMath.sol";
//import "@openzeppelin/contracts/utils/math/SafeMath.sol";

/************************************************** */
/* FlightSurety Smart Contract */
Expand Down Expand Up @@ -120,7 +118,7 @@ contract FlightSuretyApp {
// Generate a request for oracles to fetch flight information
function fetchFlightStatus(
address airline,
string flight,
string calldata flight,
uint256 timestamp
) external {
uint8 index = getRandomIndex(msg.sender);
Expand Down Expand Up @@ -204,7 +202,7 @@ contract FlightSuretyApp {
oracles[msg.sender] = Oracle({isRegistered: true, indexes: indexes});
}

function getMyIndexes() external view returns (uint8[3]) {
function getMyIndexes() external view returns (uint8[3] memory) {
require(
oracles[msg.sender].isRegistered,
"Not registered as an oracle"
Expand All @@ -220,7 +218,7 @@ contract FlightSuretyApp {
function submitOracleResponse(
uint8 index,
address airline,
string flight,
string calldata flight,
uint256 timestamp,
uint8 statusCode
) external {
Expand Down Expand Up @@ -256,14 +254,14 @@ contract FlightSuretyApp {

function getFlightKey(
address airline,
string flight,
string memory flight,
uint256 timestamp
) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(airline, flight, timestamp));
}

// Returns array of three non-duplicating integers from 0-9
function generateIndexes(address account) internal returns (uint8[3]) {
function generateIndexes(address account) internal returns (uint8[3] memory) {
uint8[3] memory indexes;
indexes[0] = getRandomIndex(account);

Expand Down
7 changes: 2 additions & 5 deletions flight-surety/contracts/FlightSuretyData.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.21 <0.7.0;

//import "../node_modules/openzeppelin-solidity/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";

//import "github.com/OpenZeppelin/openzeppelin-contracts/contracts/utils/math/SafeMath.sol";
//import "github.com/OpenZeppelin/openzeppelin-contracts/contracts/token/ERC721/ERC721.sol";
import "../node_modules/openzeppelin-solidity/contracts/math/SafeMath.sol";
//import "@openzeppelin/contracts/utils/math/SafeMath.sol";

contract FlightSuretyData {
using SafeMath for uint256;
Expand Down
16 changes: 8 additions & 8 deletions flight-surety/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flight-surety/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"author": "mg",
"license": "ISC",
"dependencies": {
"@openzeppelin/contracts": "^4.3.2",
"openzeppelin-solidity": "^2.3.0",
"truffle-hdwallet-provider": "^1.0.17"
}
}

0 comments on commit 3ee44f0

Please sign in to comment.