-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from oscarpascualbakker/feature/overall-improve…
…ments Feature/overall-improvements Merge because the only problem is the Web3 component (it gives problems in my local environment as well).
- Loading branch information
Showing
18 changed files
with
17,497 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Tests and Slither | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Checkout the code from the repository | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
# Install project dependencies | ||
- name: Install dependencies | ||
run: npm install | ||
|
||
# Build and start the Docker environment | ||
# Wait 10 seconds for ganache to be ready | ||
- name: Build environment | ||
run: | | ||
docker compose up -d | ||
sleep 10 | ||
# Run unit tests (forcing compilation) | ||
- name: Run tests | ||
run: | | ||
docker compose run --rm --user root txoco mkdir -p /app/build | ||
docker compose run --rm txoco chown -R node:node /app/build | ||
docker compose run --rm txoco truffle test --compile-all | ||
# Execute Slither for smart contract analysis | ||
- name: Run Slither | ||
run: | | ||
docker compose run --rm slither slither . --exclude-dependencies --exclude-informational --exclude-low --exclude-optimization || echo "SLITHER_EXIT_CODE=$?" >> $GITHUB_ENV | ||
# Check the exit code of the Slither command | ||
- name: Check Slither output | ||
run: | | ||
SLITHER_EXIT_CODE=${SLITHER_EXIT_CODE:-0} | ||
if [ -z "$SLITHER_EXIT_CODE" ]; then | ||
echo "SLITHER_EXIT_CODE is not set or is empty" | ||
else | ||
if [ "$SLITHER_EXIT_CODE" -ne 0 ]; then | ||
exit 1 | ||
fi | ||
fi | ||
# Archive Slither results if the job fails | ||
- name: Archive Slither results on failure | ||
if: failure() | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: slither-results | ||
path: slither-results.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
contracts_to_exclude: | ||
- "node_modules/@openzeppelin/contracts/*.sol" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM python:3.8 | ||
|
||
# Download slither code | ||
RUN git clone https://github.com/crytic/slither.git | ||
|
||
# Install slither | ||
WORKDIR /slither | ||
RUN python3 setup.py install | ||
|
||
# Install node, npm and npx | ||
RUN apt-get update | ||
RUN apt-get install -y curl dirmngr apt-transport-https lsb-release ca-certificates | ||
RUN curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - | ||
RUN sh -c 'echo "deb https://deb.nodesource.com/node_18.x $(lsb_release -sc) main" > /etc/apt/sources.list.d/nodesource.list' | ||
RUN apt-get update | ||
RUN apt-get install nodejs | ||
|
||
# Install Truffle globally | ||
RUN npm install -g truffle | ||
|
||
# Install Truffle tools and other stuff | ||
RUN npm install @truffle/hdwallet-provider truffle-plugin-verify truffle-assertions | ||
RUN npm install @openzeppelin/contracts | ||
RUN npm install chai dotenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
require 'vendor/autoload.php'; | ||
use Web3\Web3; | ||
|
||
$apiKey = 'MkCoC6RmzJXTJryxG7iFXvRvX9zIr4aA'; | ||
$endpoint = 'https://polygon-mainnet.g.alchemy.com/v2/' . $apiKey; | ||
$contractAddress = '0xf6fe664d0D61297fBfBb829A1FF77286b887a9Fd'; | ||
|
||
// Inicializar Web3 | ||
$web3 = new Web3($endpoint); | ||
|
||
// La ABI del contrato (simplificada para este ejemplo) | ||
$contractAbi = [ | ||
[ | ||
'constant' => true, | ||
'inputs' => [], | ||
'name' => 'baseURI', | ||
'outputs' => [ | ||
['name' => '', 'type' => 'string'] | ||
], | ||
'payable' => false, | ||
'stateMutability' => 'view', | ||
'type' => 'function', | ||
] | ||
]; | ||
|
||
$contract = new \Web3\Contract($contractAbi, $contractAddress, $web3->provider); | ||
|
||
// Obtener baseURI | ||
$contract->call('baseURI', [], function ($err, $result) use (&$baseURI) { | ||
if ($err !== null) { | ||
echo 'Error: ' . $err->getMessage(); | ||
return; | ||
} | ||
$baseURI = $result[0]; | ||
echo 'El valor de baseURI es: ' . $baseURI; | ||
}); | ||
?> |
Oops, something went wrong.