Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Commit

Permalink
Update formatting and dependencies (#294)
Browse files Browse the repository at this point in the history
* feat: cleanup and update dependencies, add git hooks

* feat: remove typescript and eslint

* fix: solidity pragma intellisense

Co-authored-by: Justin Greenberg <[email protected]>
  • Loading branch information
dangerousfood and justingreenberg authored Jan 3, 2023
1 parent c1c78dd commit 4006567
Show file tree
Hide file tree
Showing 38 changed files with 712 additions and 15,747 deletions.
14 changes: 1 addition & 13 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,8 @@ module.exports = {
mocha: true,
node: true,
},
plugins: ["@typescript-eslint"],
extends: [
"standard",
"plugin:prettier/recommended",
"plugin:node/recommended",
],
parser: "@typescript-eslint/parser",
extends: ["plugin:prettier/recommended"],
parserOptions: {
ecmaVersion: 12,
},
rules: {
"node/no-unsupported-features/es-syntax": [
"error",
{ ignores: ["modules"] },
],
},
};
13 changes: 5 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ node_modules
coverage
coverage.json
typechain
.DS_Store

abi
dist
#Hardhat files
cache
artifacts

out

lcov.info


.idea
.DS_Store

lcov.info
yarn-error.log

scripts/loanProofGenerator.js
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
3 changes: 0 additions & 3 deletions .npmignore

This file was deleted.

5 changes: 2 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"solidity.defaultCompiler": "localFile",
"solidity.defaultCompiler": "remote",

"solidity.packageDefaultDependenciesContractsDirectory": "src",
"solidity.packageDefaultDependenciesDirectory": "lib",

"solidity.compileUsingRemoteVersion": "v0.8.13"

"solidity.compileUsingRemoteVersion": "v0.8.17+commit.8df45f5f"
}
55 changes: 12 additions & 43 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,27 @@
{
"name": "@astaria/astaria-core",
"name": "@astaria/core",
"version": "0.0.6-rc",
"author": "Astaria Labs, Inc.",
"license": "BUSL-1.1",
"private": true,
"main": "index.js",
"dependencies": {
"@astariaxyz/sdk": "1.0.0-alpha.9",
"global": "^4.4.0",
"hardhat": "^2.9.3",
"hardhat-preprocessor": "^0.1.4",
"hardhat-typechain": "^0.3.5",
"keccak256": "^1.0.6",
"merkletreejs": "^0.2.31",
"solidity-metrics": "^0.0.5",
"ts-generator": "^0.1.1",
"ts-node": "^10.9.1"
},
"engines": {
"node": "^16.0.0"
},
"scripts": {
"lint": "eslint src/**/*.sol",
"lint:fix": "prettier --write src/**/*.sol",
"write-headers": "node scripts/writeHeaders.js",
"postinstall": "bash scripts/postinstall.sh"
"postinstall": "husky install"
},
"lint-staged": {
"*.sol": "prettier --write"
},
"devDependencies": {
"@dethcrypto/eth-sdk": "^0.3.3",
"@dethcrypto/eth-sdk-client": "^0.1.6",
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-etherscan": "^3.0.0",
"@nomiclabs/hardhat-waffle": "^2.0.0",
"@typechain/ethers-v5": "^7.0.1",
"@typechain/hardhat": "^2.3.0",
"@types/node": "^12.0.0",
"@typescript-eslint/eslint-plugin": "^4.29.1",
"@typescript-eslint/parser": "^4.29.1",
"dotenv": "^10.0.0",
"eslint": "^7.29.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-promise": "^5.1.0",
"ethereum-waffle": "^3.0.0",
"@astariaxyz/sdk": "1.0.0-alpha.9",
"@types/node": "^18.11.18",
"ethers": "^5.7.2",
"hardhat-gas-reporter": "^1.0.4",
"prettier": "^2.3.2",
"prettier-plugin-solidity": "^1.0.0-beta.24",
"solhint": "^3.3.7",
"solidity-coverage": "^0.7.16",
"typechain": "^8.1.0",
"typescript": "^4.7.4"
"husky": "^8.0.3",
"lint-staged": "^13.1.0",
"prettier": "^2.8.1",
"prettier-plugin-solidity": "^1.1.1",
"solhint": "^3.3.7"
}
}
6 changes: 3 additions & 3 deletions scripts/typechain.sh → scripts/fetch-abi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ accepted_file_names=("CollateralToken.sol" "LienToken.sol" "MultiRolesAuthority.

forge build
# loop through the array and generate types for each contract
rm -rf typechainabi && mkdir -p typechainabi
rm -rf abi && mkdir -p abi
for i in ./out/*;
do
file=$(basename "${i}")
if [[ ${accepted_file_names[(ie)$file]} -le ${#accepted_file_names} ]]; then
cp -r "$i"/*.json "typechainabi/"
cp -r "$i"/*.json "abi/"
fi
done
typechain --target=ethers-v5 typechainabi/**/**.json --out-dir=typechain --show-stack-traces

52 changes: 24 additions & 28 deletions scripts/loanProofGenerator.ts → scripts/loan-proof-generator.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import {
StrategyTree,
signRootLocal,
getTypedData,
Strategy,
} from "@astariaxyz/sdk";
import { utils, BigNumber, Wallet } from "ethers";
const sdk = require("@astariaxyz/sdk");
const { utils, BigNumber, Wallet } = require("ethers");

const { defaultAbiCoder } = utils;

const main = async () => {
const args = process.argv.slice(2);
const detailsType = parseInt(BigNumber.from(args.shift()).toString());
const leaves = [];
let mapping: any = [];

let mapping = [];

if (detailsType === 0) {
mapping = [
"uint8",
Expand Down Expand Up @@ -55,47 +53,45 @@ const main = async () => {
"uint256",
];
}
// Create tree

const termData: string[] = defaultAbiCoder
// @ts-ignore
.decode(mapping, args.shift())
.map((x) => {
if (x instanceof BigNumber) {
return x.toString();
}
return x;
});
// Create tree
const termData = defaultAbiCoder.decode(mapping, args.shift()).map((x) => {
if (x instanceof BigNumber) {
return x.toString();
}
return x;
});

const pk: string = args.shift() as string;
const pk = args.shift();

const wallet = new Wallet(pk);

const strategyData: any = defaultAbiCoder.decode(
const strategyData = defaultAbiCoder.decode(
["uint8", "uint256", "address"],
args.shift() as string
args.shift()
);

const strategy: Strategy = {
const strategy = {
version: strategyData[0],
expiration: strategyData[1],
vault: strategyData[2],
nonce: BigNumber.from(0),
delegate: wallet.address,
};
// @ts-ignore

leaves.push(termData);
const output: string = leaves.reduce((acc, cur) => {

const output = leaves.reduce((acc, cur) => {
return acc + cur.join(",") + "\n";
}, "");

const merkleTree = new StrategyTree(output);
const merkleTree = new sdk.StrategyTree(output);

const rootHash: string = merkleTree.getHexRoot();
const rootHash = merkleTree.getHexRoot();
const proof = merkleTree.getHexProof(merkleTree.getLeaf(0));

const signature = await signRootLocal(
await getTypedData(strategy, rootHash, strategy.vault, 31337),
const signature = await sdk.signRootLocal(
await sdk.getTypedData(strategy, rootHash, strategy.vault, 31337),
wallet
);

Expand Down
9 changes: 0 additions & 9 deletions scripts/postinstall.sh

This file was deleted.

59 changes: 0 additions & 59 deletions scripts/writeHeaders.js

This file was deleted.

29 changes: 18 additions & 11 deletions src/AstariaRouter.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// SPDX-License-Identifier: BUSL-1.1

/**
* █████╗ ███████╗████████╗ █████╗ ██████╗ ██╗ █████╗
* ██╔══██╗██╔════╝╚══██╔══╝██╔══██╗██╔══██╗██║██╔══██╗
* ███████║███████╗ ██║ ███████║██████╔╝██║███████║
* ██╔══██║╚════██║ ██║ ██╔══██║██╔══██╗██║██╔══██║
* ██║ ██║███████║ ██║ ██║ ██║██║ ██║██║██║ ██║
* ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═╝
*
* Astaria Labs, Inc
*/
/**
* █████╗ ███████╗████████╗ █████╗ ██████╗ ██╗ █████╗
* ██╔══██╗██╔════╝╚══██╔══╝██╔══██╗██╔══██╗██║██╔══██╗
* ███████║███████╗ ██║ ███████║██████╔╝██║███████║
* ██╔══██║╚════██║ ██║ ██╔══██║██╔══██╗██║██╔══██║
* ██║ ██║███████║ ██║ ██║ ██║██║ ██║██║██║ ██║
* ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═╝
*
* Astaria Labs, Inc
*/

pragma solidity =0.8.17;

Expand Down Expand Up @@ -761,7 +761,14 @@ contract AstariaRouter is
function _executeCommitment(
RouterStorage storage s,
IAstariaRouter.Commitment memory c
) internal returns (uint256, ILienToken.Stack[] memory stack, uint256 payout) {
)
internal
returns (
uint256,
ILienToken.Stack[] memory stack,
uint256 payout
)
{
uint256 collateralId = c.tokenContract.computeId(c.tokenId);

if (msg.sender != s.COLLATERAL_TOKEN.ownerOf(collateralId)) {
Expand Down
14 changes: 14 additions & 0 deletions src/AstariaVaultBase.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
// SPDX-License-Identifier: BUSL-1.1

/**
* █████╗ ███████╗████████╗ █████╗ ██████╗ ██╗ █████╗
* ██╔══██╗██╔════╝╚══██╔══╝██╔══██╗██╔══██╗██║██╔══██╗
* ███████║███████╗ ██║ ███████║██████╔╝██║███████║
* ██╔══██║╚════██║ ██║ ██╔══██║██╔══██╗██║██╔══██║
* ██║ ██║███████║ ██║ ██║ ██║██║ ██║██║██║ ██║
* ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═╝
*
* Astaria Labs, Inc
*/

pragma solidity =0.8.17;

import {IAstariaVaultBase} from "core/interfaces/IAstariaVaultBase.sol";
import {Clone} from "clones-with-immutable-args/Clone.sol";
import {IERC4626} from "core/interfaces/IERC4626.sol";
Expand Down
15 changes: 14 additions & 1 deletion src/AuthInitializable.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: BUSL-1.1

/**
* █████╗ ███████╗████████╗ █████╗ ██████╗ ██╗ █████╗
* ██╔══██╗██╔════╝╚══██╔══╝██╔══██╗██╔══██╗██║██╔══██╗
* ███████║███████╗ ██║ ███████║██████╔╝██║███████║
* ██╔══██║╚════██║ ██║ ██╔══██║██╔══██╗██║██╔══██║
* ██║ ██║███████║ ██║ ██║ ██║██║ ██║██║██║ ██║
* ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═╝
*
* Astaria Labs, Inc
*/

pragma solidity =0.8.17;

import {Authority} from "solmate/auth/Auth.sol";

/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.
Expand Down
Loading

0 comments on commit 4006567

Please sign in to comment.