Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaStebaev committed May 30, 2024
1 parent ae0bd4d commit 5dfee17
Show file tree
Hide file tree
Showing 25 changed files with 6,447 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -e

if [[ $(yarn exec cspell -- --no-summary $1 2> /dev/null) ]]
then
echo "It looks like you have spell-checking errors in your commit message."
yarn exec cspell -- --no-summary $1
exit 1
fi
16 changes: 16 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# cSpell:words gpgsign

set -e

GPG_SIGN_ENABLED=$(git config commit.gpgsign || true)
if ! [[ "$GPG_SIGN_ENABLED" == "true" ]]
then
echo "Enable GPG signature for new commits";
exit 1;
fi

exec git diff --cached --name-only | yarn exec cspell --no-summary --no-progress --no-must-find-files --file-list stdin

yarn fullCheck
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* @DimaStebaev

19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
day: "saturday"

- package-ecosystem: "npm"
directory: "/contracts/"
schedule:
interval: "weekly"
day: "saturday"

- package-ecosystem: "pip"
directory: "/scripts/"
schedule:
interval: "weekly"
day: "saturday"
78 changes: 78 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# spell-checker:words ncipollo

name: Build and publish
on:
push:
branches-ignore:
- stable
- beta
- develop
pull_request:
types: [closed]
branches:
- stable
- beta
- develop
env:
NODE_VERSION: 20

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'

- name: Install project
run: yarn

- name: Build contracts
run: yarn compile

- name: Determine version
run: |
export BRANCH=${GITHUB_REF##*/}
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
echo "Branch $BRANCH"
export VERSION=$(bash ./scripts/calculate_version.sh)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Version $VERSION"
( test $BRANCH = "stable" && export PRERELEASE=false ) || export PRERELEASE=true
echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV
- name: Publish NPM package
run: ./scripts/publish_package.sh
env:
BRANCH: ${{ env.BRANCH }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create Release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.VERSION }}
prerelease: ${{ env.PRERELEASE }}

clean:
runs-on: ubuntu-latest
if: github.event.pull_request.merged
steps:
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'

- name: Remove feature tag
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
export SOURCE_BRANCH=${GITHUB_HEAD_REF##*/}
echo "Source branch: $SOURCE_BRANCH"
npm dist-tag rm @skalenetwork/marionette-interfaces $SOURCE_BRANCH
43 changes: 43 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build and test
on: [push, pull_request]

env:
NODE_VERSION: 20
PYTHON_VERSION: 3.11

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: scripts/requirements.txt

- name: Install project
run: yarn

- name: Install slither
run: pip3 install -r scripts/requirements.txt

- name: Show slither version
run: slither --version

- name: Check spelling
run: yarn cspell

- name: lint
run: yarn fullCheck
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,10 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# Hardhat files
cache
artifacts

# python
venv
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "dictionary"]
path = dictionary
url = https://github.com/skalenetwork/dictionary.git
25 changes: 25 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": "solhint:all",
"rules": {
"foundry-test-functions": ["off"],

"avoid-tx-origin": "error",
"check-send-result": "error",
"code-complexity": "error",
"compiler-version": ["error","^0.8.0"],
"contract-name-camelcase": "error",
"explicit-types": "error",
"func-name-mixedcase": "error",
"function-max-lines": "error",
"gas-named-return-values": "error",
"max-states-count": "error",
"no-empty-blocks": "error",
"no-global-import": "error",
"no-inline-assembly": "error",
"no-unused-vars": "error",
"ordering": "error",
"private-vars-leading-underscore": "error",
"state-visibility": "error",
"visibility-modifier-order": "error"
}
}
894 changes: 894 additions & 0 deletions .yarn/releases/yarn-4.2.2.cjs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
yarnPath: .yarn/releases/yarn-4.2.2.cjs
nodeLinker: "node-modules" # remove after this issue is solved: https://github.com/crytic/crytic-compile/issues/331
52 changes: 52 additions & 0 deletions contracts/Encoder.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: AGPL-3.0-only

/*
Encoder.sol - Marionette
Copyright (C) 2021-Present SKALE Labs
@author Dmytro Stebaiev
Marionette is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Marionette is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Marionette. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity ^0.8.0;


library Encoder {
struct FunctionCall {
address receiver;
uint256 value;
bytes data;
}

// Functions are used by the library users
// slither-disable-start dead-code

function encodeFunctionCall(
address receiver,
uint256 value,
bytes calldata data
)
internal
pure
returns (bytes memory encodedFunctionCall)
{
return abi.encode(receiver, value, data);
}

function decodeFunctionCall(bytes calldata data) private pure returns (FunctionCall memory functionCall) {
(functionCall.receiver, functionCall.value, functionCall.data) = abi.decode(data, (address, uint256, bytes));
}

// slither-disable-end dead-code
}
48 changes: 48 additions & 0 deletions contracts/IMarionette.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-License-Identifier: AGPL-3.0-only

/*
IMarionette.sol - Marionette
Copyright (C) 2021-Present SKALE Labs
@author Dmytro Stebaiev
Marionette is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Marionette is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Marionette. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity ^0.8.0;

import {IMessageReceiver} from "@skalenetwork/ima-interfaces/IMessageReceiver.sol";


interface IMarionette is IMessageReceiver {
receive() external payable;
function execute(
address payable target,
uint256 value,
bytes calldata data
)
external
payable
returns (bytes memory returnValue);
function initialize(address owner, address ima) external;
function setVersion(string calldata newVersion) external;
function sendSFuel(address payable target, uint256 value) external payable;
function encodeFunctionCall(
address receiver,
uint256 value,
bytes calldata data
)
external
pure
returns (bytes memory encodedFunctionCall);
}
15 changes: 15 additions & 0 deletions contracts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@skalenetwork/marionette-interfaces",
"version": "0.0.0",
"description": "Definitions of interfaces needed to integrate with marionette smart contract",
"repository": "[email protected]:skalenetwork/marionette-interfaces.git",
"author": "Dmytro Stebaiev <[email protected]>",
"license": "AGPL-3.0",
"files": [
"*.sol",
"**/*.sol"
],
"dependencies": {
"@skalenetwork/ima-interfaces": "^2.0.0"
}
}
21 changes: 21 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": "0.2",
"language": "en",
"ignorePaths": [
".gitignore",
".solhint.json",
".yarn/**",
"artifacts/**",
"cache/**",
"typechain-types/**",
"**/venv/**"
],
"dictionaries": ["domain-terms", "libraries", "names", "skale-terms", "solidity"],
"dictionaryDefinitions": [
{ "name": "skale-terms", "path": "dictionary/skale-terms.txt"},
{ "name": "libraries", "path": "dictionary/libraries.txt"},
{ "name": "domain-terms", "path": "dictionary/domain-terms.txt"},
{ "name": "names", "path": "dictionary/names.txt"},
{ "name": "solidity", "path": "dictionary/solidity.txt"}
]
}
1 change: 1 addition & 0 deletions dictionary
Submodule dictionary added at 76852f
7 changes: 7 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { HardhatUserConfig } from "hardhat/config";

const config: HardhatUserConfig = {
solidity: "0.8.26",
};

export default config;
Loading

0 comments on commit 5dfee17

Please sign in to comment.