-
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.
- Loading branch information
1 parent
1831c73
commit 36e2359
Showing
27 changed files
with
6,466 additions
and
0 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,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 |
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,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 |
Validating CODEOWNERS rules …
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 @@ | ||
* @DimaStebaev | ||
|
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,13 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "npm" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
day: "saturday" | ||
|
||
- package-ecosystem: "pip" | ||
directory: "/scripts/" | ||
schedule: | ||
interval: "weekly" | ||
day: "saturday" |
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,76 @@ | ||
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/paymaster-interfaces $SOURCE_BRANCH |
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,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 |
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 |
---|---|---|
|
@@ -128,3 +128,10 @@ dist | |
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
# Hardhat files | ||
cache | ||
artifacts | ||
|
||
# python | ||
venv |
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,3 @@ | ||
[submodule "dictionary"] | ||
path = dictionary | ||
url = https://github.com/skalenetwork/dictionary.git |
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,22 @@ | ||
{ | ||
"extends": "solhint:all", | ||
"rules": { | ||
"foundry-test-functions": ["off"], | ||
|
||
"compiler-version": ["error","^0.8.0"], | ||
"state-visibility": "error", | ||
"no-empty-blocks": "error", | ||
"check-send-result": "error", | ||
"private-vars-leading-underscore": "error", | ||
"code-complexity": "error", | ||
"visibility-modifier-order": "error", | ||
"func-name-mixedcase": "error", | ||
"function-max-lines": "error", | ||
"no-unused-vars": "error", | ||
"no-inline-assembly": "error", | ||
"contract-name-camelcase": "error", | ||
"ordering": "error", | ||
"avoid-tx-origin": "error", | ||
"max-states-count": "error" | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
yarnPath: .yarn/releases/yarn-4.2.2.cjs | ||
nodeLinker: "pnpm" # remove after this issue is solved: https://github.com/crytic/crytic-compile/issues/331 |
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,30 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
/* | ||
IDateTimeUtils.sol - Paymaster | ||
Copyright (C) 2024-Present SKALE Labs | ||
@author Dmytro Stebaiev | ||
Paymaster 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. | ||
Paymaster 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 Paymaster. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
pragma solidity ^0.8.20; | ||
|
||
|
||
type Seconds is uint256; | ||
type Day is uint256; | ||
type Month is uint256; | ||
type Months is uint256; | ||
type Year is uint256; | ||
|
||
type Timestamp is uint256; |
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,77 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
/* | ||
IPaymaster.sol - Paymaster | ||
Copyright (C) 2024-Present SKALE Labs | ||
@author Dmytro Stebaiev | ||
Paymaster 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. | ||
Paymaster 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 Paymaster. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
pragma solidity ^0.8.20; | ||
|
||
// cspell:words IERC20 | ||
|
||
import {Months, Seconds, Timestamp} from "./IDateTimeUtils.sol"; | ||
import {SKL, USD} from "./Types.sol"; | ||
|
||
|
||
type SchainHash is bytes32; | ||
type ValidatorId is uint256; | ||
|
||
interface IPaymaster { | ||
function initialize(address initialAuthority) external; | ||
function addSchain(string calldata name) external; | ||
function removeSchain(SchainHash schainHash) external; | ||
function addValidator(ValidatorId id, address validatorAddress) external; | ||
function removeValidator(ValidatorId id) external; | ||
function setNodesAmount(ValidatorId id, uint256 amount) external; | ||
function setActiveNodes(ValidatorId id, uint256 amount) external; | ||
function setMaxReplenishmentPeriod(Months months) external; | ||
function setSchainPrice(USD price) external; | ||
function setSklPrice(USD price) external; | ||
function setAllowedSklPriceLag(Seconds lagSeconds) external; | ||
function setSkaleToken(address token) external; | ||
function setVersion(string calldata newVersion) external; | ||
function clearHistory(Timestamp before) external; | ||
function pay(SchainHash schainHash, Months duration) external; | ||
function claim(address to) external; | ||
function claimFor(ValidatorId validatorId, address to) external; | ||
function getSchainExpirationTimestamp( | ||
SchainHash schainHash | ||
) | ||
external | ||
view | ||
returns (Timestamp expiration); | ||
function getRewardAmount(ValidatorId validatorId) external view returns (SKL reward); | ||
function getNodesNumber(ValidatorId validatorId) external view returns (uint256 number); | ||
function getActiveNodesNumber(ValidatorId validatorId) external view returns (uint256 number); | ||
function getHistoricalActiveNodesNumber( | ||
ValidatorId validatorId, | ||
Timestamp when | ||
) | ||
external | ||
view | ||
returns (uint256 number); | ||
function getHistoricalTotalActiveNodesNumber( | ||
Timestamp when | ||
) | ||
external | ||
view | ||
returns (uint256 number); | ||
function getValidatorsNumber() external view returns (uint256 number); | ||
function getSchainsNames() external view returns (string[] memory names); | ||
function getSchainsNumber() external view returns (uint256 number); | ||
function getTotalReward(Timestamp from, Timestamp to) external view returns (SKL reward); | ||
} |
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,29 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
/* | ||
IPaymasterAccessManager.sol - Paymaster | ||
Copyright (C) 2024-Present SKALE Labs | ||
@author Dmytro Stebaiev | ||
Paymaster 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. | ||
Paymaster 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 Paymaster. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
pragma solidity ^0.8.20; | ||
|
||
import {IAccessManager} from "@openzeppelin/contracts/access/manager/IAccessManager.sol"; | ||
|
||
|
||
interface IPaymasterAccessManager is IAccessManager { | ||
function initialize(address initialAdmin) external; | ||
} |
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,25 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
/* | ||
Types.sol - Paymaster | ||
Copyright (C) 2024-Present SKALE Labs | ||
@author Dmytro Stebaiev | ||
Paymaster 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. | ||
Paymaster 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 Paymaster. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
pragma solidity ^0.8.20; | ||
|
||
|
||
type SKL is uint256; | ||
type USD is uint256; |
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,14 @@ | ||
{ | ||
"name": "@skalenetwork/paymaster-interfaces", | ||
"version": "0.0.0", | ||
"description": "Definitions of interfaces needed to integrate with paymaster smart contract", | ||
"repository": "[email protected]:skalenetwork/paymaster-interfaces.git", | ||
"author": "Dmytro Stebaiev <[email protected]>", | ||
"license": "AGPL-3.0", | ||
"files": [ | ||
"**/*.sol", | ||
"/artifacts/contracts/*.json" | ||
], | ||
"dependencies": {}, | ||
"devDependencies": {} | ||
} |
Oops, something went wrong.