Skip to content

Commit

Permalink
Merge pull request #56 from KintoXYZ/increase-test-coverage-3
Browse files Browse the repository at this point in the history
increase coverage
  • Loading branch information
fedealconada authored Jan 30, 2024
2 parents a9bb547 + 7d5918c commit 21dfc41
Show file tree
Hide file tree
Showing 41 changed files with 1,556 additions and 852 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/forge-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,29 @@ jobs:
- uses: ./.github/actions/install

- name: Run tests
run: forge test

run: forge test --gas-report > gasreport.ansi
env:
# make fuzzing semi-deterministic to avoid noisy gas cost estimation
# due to non-deterministic fuzzing (but still use pseudo-random fuzzing seeds)
FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }}

- name: Compare gas reports
uses: Rubilmax/foundry-gas-diff@v3.16
with:
summaryQuantile: 0.9 # only display the 10% most significant gas diffs in the summary (defaults to 20%)
sortCriteria: avg,max # sort diff rows by criteria
sortOrders: desc,asc # and directions
ignore: test-foundry/**/* # filter out gas reports from specific paths (test/ is included by default)
id: gas_diff

- name: Add gas diff to sticky comment
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: marocchino/sticky-pull-request-comment@v2
with:
# delete the comment in case changes no longer impact gas costs
delete: ${{ !steps.gas_diff.outputs.markdown }}
message: ${{ steps.gas_diff.outputs.markdown }}

coverage:
needs:
- test
Expand Down
57 changes: 0 additions & 57 deletions .github/workflows/gas-diff.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,4 @@ jobs:
name: Slither analysis
uses: ./.github/workflows/slither.yml
secrets: inherit

gas-diff:
name: Gas diff
uses: ./.github/workflows/gas-diff.yml
secrets: inherit

20 changes: 10 additions & 10 deletions script/deploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract KintoInitialDeployScript is Create2Helper, ArtifactsReader {
SponsorPaymaster _sponsorPaymasterImpl;
SponsorPaymaster _sponsorPaymaster;
KintoID _implementation;
KintoID _kintoIDv1;
KintoID _kintoID;
UUPSProxy _proxy;
IKintoWallet _walletImpl;
IKintoWallet _kintoWalletv1;
Expand Down Expand Up @@ -62,17 +62,17 @@ contract KintoInitialDeployScript is Create2Helper, ArtifactsReader {
if (isContract(kintoProxyAddr)) {
_proxy = UUPSProxy(payable(kintoProxyAddr));
console.log("Already deployed Kinto ID proxy at", address(kintoProxyAddr));
_kintoIDv1 = KintoID(address(_proxy));
_kintoID = KintoID(address(_proxy));
} else {
// deploy proxy contract and point it to implementation
_proxy = new UUPSProxy{salt: 0}(address(_implementation), "");
// wrap in ABI to support easier calls
_kintoIDv1 = KintoID(address(_proxy));
console.log("Kinto ID proxy deployed at ", address(_kintoIDv1));
_kintoID = KintoID(address(_proxy));
console.log("Kinto ID proxy deployed at ", address(_kintoID));
// Initialize proxy
_kintoIDv1.initialize();
_kintoID.initialize();
}
_kintoIDv1 = KintoID(address(_proxy));
_kintoID = KintoID(address(_proxy));

// Entry Point
address entryPointAddr = computeAddress(1, abi.encodePacked(type(EntryPoint).creationCode));
Expand All @@ -88,14 +88,14 @@ contract KintoInitialDeployScript is Create2Helper, ArtifactsReader {

// Wallet Implementation for the beacon
address walletImplementationAddr = computeAddress(
0, abi.encodePacked(type(KintoWallet).creationCode, abi.encode(address(_entryPoint), address(_kintoIDv1)))
0, abi.encodePacked(type(KintoWallet).creationCode, abi.encode(address(_entryPoint), address(_kintoID)))
);
if (isContract(walletImplementationAddr)) {
_walletImpl = KintoWallet(payable(walletImplementationAddr));
console.log("Wallet Implementation already deployed at", address(walletImplementationAddr));
} else {
// Deploy Wallet Implementation
_walletImpl = new KintoWallet{salt: 0}(_entryPoint, _kintoIDv1, IKintoAppRegistry(address(0)));
_walletImpl = new KintoWallet{salt: 0}(_entryPoint, _kintoID, IKintoAppRegistry(address(0)));
console.log("Wallet Implementation deployed at", address(_walletImpl));
}

Expand Down Expand Up @@ -129,7 +129,7 @@ contract KintoInitialDeployScript is Create2Helper, ArtifactsReader {
_walletFactory = KintoWalletFactory(address(_proxy));
console.log("Wallet Factory proxy deployed at ", address(_walletFactory));
// Initialize proxy
_walletFactory.initialize(_kintoIDv1);
_walletFactory.initialize(_kintoID);
}

address walletFactory = _entryPoint.walletFactory();
Expand Down Expand Up @@ -207,7 +207,7 @@ contract KintoInitialDeployScript is Create2Helper, ArtifactsReader {

// Writes the addresses to a file
vm.writeFile(_getAddressesFile(), "{\n");
vm.writeLine(_getAddressesFile(), string.concat('"KintoID": "', vm.toString(address(_kintoIDv1)), '",'));
vm.writeLine(_getAddressesFile(), string.concat('"KintoID": "', vm.toString(address(_kintoID)), '",'));
vm.writeLine(
_getAddressesFile(), string.concat('"KintoID-impl": "', vm.toString(address(_implementation)), '",')
);
Expand Down
23 changes: 12 additions & 11 deletions script/migrations/03-mint_nft_admin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,33 @@ import "forge-std/console.sol";
contract KintoMigration3DeployScript is Create2Helper, KYCSignature, ArtifactsReader {
using ECDSAUpgradeable for bytes32;

KintoID _kintoIDv1;
KintoID _kintoID;

function setUp() public {}

function run() public {
console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid));
// If not using ledger, replace

// if not using ledger, replace
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address deployer = vm.rememberKey(deployerPrivateKey);
vm.startBroadcast(deployerPrivateKey);

console.log("Executing with address", deployer);
// vm.startBroadcast();
address walletFactoryAddr = _getChainDeployment("KintoWalletFactory");
if (walletFactoryAddr == address(0)) {
console.log("Need to execute main deploy script first", walletFactoryAddr);
return;
}
// Mint an nft to the owner
_kintoIDv1 = KintoID(_getChainDeployment("KintoID"));

// mint an nft to the owner
_kintoID = KintoID(_getChainDeployment("KintoID"));
IKintoID.SignatureData memory sigdata =
_auxCreateSignature(_kintoIDv1, deployer, deployer, deployerPrivateKey, block.timestamp + 1000);
vm.stopBroadcast();
vm.startBroadcast();
_auxCreateSignature(_kintoID, deployer, deployerPrivateKey, block.timestamp + 1000);

uint16[] memory traits = new uint16[](1);
traits[0] = 0; // ADMIN
_kintoIDv1.mintIndividualKyc(sigdata, traits);
vm.stopBroadcast();

vm.broadcast();
_kintoID.mintIndividualKyc(sigdata, traits);
}
}
2 changes: 1 addition & 1 deletion script/migrations/04-deploy_admin_wallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract KintoMigration4DeployScript is Create2Helper, ArtifactsReader {

KintoWalletFactory _walletFactory;
KintoWallet _kintoWalletv1;
KintoID _kintoIDv1;
KintoID _kintoID;
UUPSProxy _proxy;

function setUp() public {}
Expand Down
2 changes: 1 addition & 1 deletion script/migrations/12-create_engen_app.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import "../../test/helpers/UserOp.sol";
contract KintoMigration12DeployScript is ArtifactsReader, UserOp {
KintoWalletFactory _walletFactory;
KintoWallet _kintoWalletv1;
KintoID _kintoIDv1;
KintoID _kintoID;
UUPSProxy _proxy;

function setUp() public {}
Expand Down
27 changes: 27 additions & 0 deletions script/migrations/22-wallet_v5.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.18;

import "../../src/wallet/KintoWallet.sol";
import "./utils/MigrationHelper.sol";

// NOTE: this is a sample migration script with the new refactors
// contract KintoMigration22DeployScript is MigrationHelper {
// using ECDSAUpgradeable for bytes32;

// function run() public {
// run2();

// // generate bytecode for KintoWalletV5
// bytes memory bytecode = abi.encodePacked(
// type(KintoWalletV5).creationCode,
// abi.encode(
// _getChainDeployment("EntryPoint"),
// IKintoID(_getChainDeployment("KintoID")),
// IKintoAppRegistry(_getChainDeployment("KintoAppRegistry"))
// )
// );

// // upgrade KintoWallet to V5
// deployAndUpgrade("KintoWallet", "V5", bytecode);
// }
// }
Loading

0 comments on commit 21dfc41

Please sign in to comment.