Skip to content

Commit 703b98a

Browse files
authored
Merge pull request #28 from KintoXYZ/kintoapps
Kinto App Registry
2 parents 87dd6e7 + 1f8cd4b commit 703b98a

34 files changed

+1553
-784
lines changed

.env.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ KINTO_RPC_URL="https://kinto-mainnet.calderachain.xyz/http"
44
MAINNET_NETWORK_ID="7887"
55
TESTNET_NETWORK_ID="7887000"
66
KINTO_EXPLORER_URL="https://kinto-mainnet.calderaexplorer.xyz/"
7+
LEDGER_ADMIN=""

script/deploy.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pragma solidity ^0.8.13;
33

44
import "forge-std/Script.sol";
55
import "../src/KintoID.sol";
6+
import {KintoWalletV3 as KintoWallet} from "../src/wallet/KintoWallet.sol";
67
import "../src/viewers/KYCViewer.sol";
78
import "../src/interfaces/IKintoID.sol";
89
import "../src/sample/Counter.sol";
@@ -105,7 +106,7 @@ contract KintoInitialDeployScript is Create2Helper, ArtifactsReader {
105106
console.log("Wallet Implementation already deployed at", address(walletImplementationAddr));
106107
} else {
107108
// Deploy Wallet Implementation
108-
_walletImpl = new KintoWallet{salt: 0}(_entryPoint, _kintoIDv1);
109+
_walletImpl = new KintoWallet{salt: 0}(_entryPoint, _kintoIDv1, IKintoAppRegistry(address(0)));
109110
console.log("Wallet Implementation deployed at", address(_walletImpl));
110111
}
111112

script/migrations/02-upgrade_wallet.sol

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pragma solidity ^0.8.13;
33

44
import "forge-std/Script.sol";
55
import "../../src/wallet/KintoWalletFactory.sol";
6-
import {KintoWalletV2} from "../../src/wallet/KintoWallet.sol";
6+
import {KintoWallet} from "../../src/wallet/KintoWallet.sol";
77
import {Create2Helper} from "../../test/helpers/Create2Helper.sol";
88
import {ArtifactsReader} from "../../test/helpers/ArtifactsReader.sol";
99
import {UUPSProxy} from "../../test/helpers/UUPSProxy.sol";
@@ -12,6 +12,13 @@ import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
1212
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
1313
import "forge-std/console.sol";
1414

15+
// Upgradeable version of KintoWallet
16+
contract KintoWalletV2 is KintoWallet {
17+
constructor(IEntryPoint _entryPoint, IKintoID _kintoID)
18+
KintoWallet(_entryPoint, _kintoID, IKintoAppRegistry(address(0)))
19+
{}
20+
}
21+
1522
contract KintoMigration2DeployScript is Create2Helper, ArtifactsReader {
1623
using ECDSAUpgradeable for bytes32;
1724

script/migrations/04-deploy_admin_wallet.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pragma solidity ^0.8.13;
44
import "forge-std/Script.sol";
55
import "../../src/wallet/KintoWalletFactory.sol";
66
import "../../src/KintoID.sol";
7-
import {KintoWalletV2} from "../../src/wallet/KintoWallet.sol";
7+
import "../../src/wallet/KintoWallet.sol";
88
import {Create2Helper} from "../../test/helpers/Create2Helper.sol";
99
import {ArtifactsReader} from "../../test/helpers/ArtifactsReader.sol";
1010
import {UUPSProxy} from "../../test/helpers/UUPSProxy.sol";

script/migrations/05-deploy_faucet.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pragma solidity ^0.8.13;
33

44
import "forge-std/Script.sol";
55
import "../../src/Faucet.sol";
6-
import {KintoWalletV2} from "../../src/wallet/KintoWallet.sol";
76
import {Create2Helper} from "../../test/helpers/Create2Helper.sol";
87
import {ArtifactsReader} from "../../test/helpers/ArtifactsReader.sol";
98
import {UUPSProxy} from "../../test/helpers/UUPSProxy.sol";

script/migrations/06-counter_advance.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pragma solidity ^0.8.13;
33

44
import "forge-std/Script.sol";
55
import "../../src/sample/Counter.sol";
6-
import {KintoWalletV2} from "../../src/wallet/KintoWallet.sol";
76
import {Create2Helper} from "../../test/helpers/Create2Helper.sol";
87
import {ArtifactsReader} from "../../test/helpers/ArtifactsReader.sol";
98
import {UUPSProxy} from "../../test/helpers/UUPSProxy.sol";
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
import "forge-std/Script.sol";
5+
import "../../src/apps/KintoAppRegistry.sol";
6+
import "../../src/paymasters/SponsorPaymaster.sol";
7+
import "../../src/interfaces/IKintoWalletFactory.sol";
8+
import {Create2Helper} from "../../test/helpers/Create2Helper.sol";
9+
import {ArtifactsReader} from "../../test/helpers/ArtifactsReader.sol";
10+
import {UUPSProxy} from "../../test/helpers/UUPSProxy.sol";
11+
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
12+
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
13+
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
14+
import "forge-std/console.sol";
15+
16+
contract KintoMigration7DeployScript is Create2Helper, ArtifactsReader {
17+
using ECDSAUpgradeable for bytes32;
18+
19+
KintoAppRegistry _kintoApp;
20+
21+
function setUp() public {}
22+
23+
// solhint-disable code-complexity
24+
function run() public {
25+
console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid));
26+
// If not using ledger, replace
27+
// Execute this script with the admin
28+
// uint256 deployerPrivateKey = vm.envUint('PRIVATE_KEY');
29+
// vm.startBroadcast(deployerPrivateKey);
30+
vm.startBroadcast();
31+
console.log("Executing with address", msg.sender);
32+
address appAddr = _getChainDeployment("KintoAppRegistry");
33+
if (appAddr != address(0)) {
34+
console.log("KintoAppRegistry already deployed", appAddr);
35+
return;
36+
}
37+
address walletFactoryAddr = _getChainDeployment("KintoWalletFactory");
38+
IKintoWalletFactory _walletFactory = IKintoWalletFactory(walletFactoryAddr);
39+
_kintoApp = KintoAppRegistry(
40+
_walletFactory.deployContract(
41+
msg.sender, 0, abi.encodePacked(type(KintoAppRegistry).creationCode), bytes32(0)
42+
)
43+
);
44+
address credits = _getChainDeployment("EngenCredits");
45+
// Fund in the paymaster
46+
SponsorPaymaster _paymaster = SponsorPaymaster(payable(_getChainDeployment("SponsorPaymaster")));
47+
_paymaster.addDepositFor{value: 1e17}(credits);
48+
vm.stopBroadcast();
49+
// Writes the addresses to a file
50+
console.log("Add these new addresses to the artifacts file");
51+
console.log(string.concat('"KintoAppRegistry": "', vm.toString(address(_kintoApp)), '"'));
52+
}
53+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
import "forge-std/Script.sol";
5+
import "../../src/wallet/KintoWalletFactory.sol";
6+
import "../../src/wallet/KintoWallet.sol";
7+
import {Create2Helper} from "../../test/helpers/Create2Helper.sol";
8+
import {ArtifactsReader} from "../../test/helpers/ArtifactsReader.sol";
9+
import {UUPSProxy} from "../../test/helpers/UUPSProxy.sol";
10+
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
11+
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
12+
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
13+
import "forge-std/console.sol";
14+
15+
contract KintoMigration8DeployScript is Create2Helper, ArtifactsReader {
16+
using ECDSAUpgradeable for bytes32;
17+
18+
KintoWalletFactory _walletFactory;
19+
KintoWalletV3 _kintoWalletImpl;
20+
UUPSProxy _proxy;
21+
22+
function setUp() public {}
23+
24+
// solhint-disable code-complexity
25+
function run() public {
26+
console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid));
27+
// Execute this script with the ledger admin
28+
console.log("Executing with address", msg.sender);
29+
vm.startBroadcast();
30+
address walletFactoryAddr = _getChainDeployment("KintoWalletFactory");
31+
if (walletFactoryAddr == address(0)) {
32+
console.log("Need to execute main deploy script first", walletFactoryAddr);
33+
return;
34+
}
35+
address kintoAppAddr = _getChainDeployment("KintoAppRegistry");
36+
if (kintoAppAddr == address(0)) {
37+
console.log("Need to deploy kinto app registry first", kintoAppAddr);
38+
return;
39+
}
40+
_walletFactory = KintoWalletFactory(payable(walletFactoryAddr));
41+
42+
bytes memory bytecode = abi.encodePacked(
43+
abi.encodePacked(type(KintoWalletV3).creationCode),
44+
abi.encode(
45+
_getChainDeployment("EntryPoint"),
46+
IKintoID(_getChainDeployment("KintoID")),
47+
IKintoAppRegistry(_getChainDeployment("KintoAppRegistry"))
48+
) // Encoded constructor arguments
49+
);
50+
51+
// Deploy new wallet implementation
52+
_kintoWalletImpl = KintoWalletV3(payable(_walletFactory.deployContract(msg.sender, 0, bytecode, bytes32(0))));
53+
// Upgrade all implementations
54+
_walletFactory.upgradeAllWalletImplementations(_kintoWalletImpl);
55+
vm.stopBroadcast();
56+
// Writes the addresses to a file
57+
console.log("Add these new addresses to the artifacts file");
58+
console.log(string.concat('"KintoWalletV3-impl": "', vm.toString(address(_kintoWalletImpl)), '"'));
59+
}
60+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
import "forge-std/Script.sol";
5+
import "../../src/wallet/KintoWalletFactory.sol";
6+
import "../../src/paymasters/SponsorPaymaster.sol";
7+
import {KintoWallet} from "../../src/wallet/KintoWallet.sol";
8+
import {Create2Helper} from "../../test/helpers/Create2Helper.sol";
9+
import {ArtifactsReader} from "../../test/helpers/ArtifactsReader.sol";
10+
import {UUPSProxy} from "../../test/helpers/UUPSProxy.sol";
11+
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
12+
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
13+
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
14+
import "forge-std/console.sol";
15+
16+
contract KintoMigration9DeployScript is Create2Helper, ArtifactsReader {
17+
using ECDSAUpgradeable for bytes32;
18+
19+
SponsorPaymaster _paymaster;
20+
KintoWalletFactory _walletFactory;
21+
SponsorPaymasterV2 _paymasterImpl;
22+
UUPSProxy _proxy;
23+
24+
function setUp() public {}
25+
26+
// solhint-disable code-complexity
27+
function run() public {
28+
console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid));
29+
// Execute this script with the ledger admin
30+
console.log("Executing with address", msg.sender);
31+
vm.startBroadcast();
32+
address sponsorAddr = _getChainDeployment("SponsorPaymaster");
33+
if (sponsorAddr == address(0)) {
34+
console.log("Need to execute main deploy script first", sponsorAddr);
35+
return;
36+
}
37+
_paymaster = SponsorPaymaster(payable(sponsorAddr));
38+
39+
_walletFactory = KintoWalletFactory(payable(_getChainDeployment("KintoWalletFactory")));
40+
bytes memory bytecode = abi.encodePacked(
41+
abi.encodePacked(type(SponsorPaymasterV2).creationCode),
42+
abi.encode(_getChainDeployment("EntryPoint")) // Encoded constructor arguments
43+
);
44+
45+
// Deploy new paymaster implementation
46+
_paymasterImpl = SponsorPaymasterV2(payable(_walletFactory.deployContract(msg.sender, 0, bytecode, bytes32(0))));
47+
// Upgrade
48+
_paymaster.upgradeTo(address(_paymasterImpl));
49+
vm.stopBroadcast();
50+
// Writes the addresses to a file
51+
console.log("Add these new addresses to the artifacts file");
52+
console.log(string.concat('"SponsorPaymasterV2-impl": "', vm.toString(address(_paymasterImpl)), '"'));
53+
}
54+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
import "forge-std/Script.sol";
5+
import "../../src/wallet/KintoWalletFactory.sol";
6+
import {KintoWallet} from "../../src/wallet/KintoWallet.sol";
7+
import {Create2Helper} from "../../test/helpers/Create2Helper.sol";
8+
import {ArtifactsReader} from "../../test/helpers/ArtifactsReader.sol";
9+
import {UUPSProxy} from "../../test/helpers/UUPSProxy.sol";
10+
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
11+
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
12+
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
13+
import "forge-std/console.sol";
14+
15+
contract KintoMigration9DeployScript is Create2Helper, ArtifactsReader {
16+
using ECDSAUpgradeable for bytes32;
17+
18+
KintoWalletFactory _walletFactory;
19+
KintoWalletFactoryV2 _factoryImpl;
20+
UUPSProxy _proxy;
21+
22+
function setUp() public {}
23+
24+
// solhint-disable code-complexity
25+
function run() public {
26+
console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid));
27+
// Execute this script with the ledger admin
28+
console.log("Executing with address", msg.sender);
29+
vm.startBroadcast();
30+
address factoryAddr = _getChainDeployment("KintoWalletFactory");
31+
if (factoryAddr == address(0)) {
32+
console.log("Need to execute main deploy script first", factoryAddr);
33+
return;
34+
}
35+
_walletFactory = KintoWalletFactory(payable(_getChainDeployment("KintoWalletFactory")));
36+
37+
address newImpl = _getChainDeployment("KintoWalletV3-impl");
38+
if (newImpl == address(0)) {
39+
console.log("Need to deploy the new wallet first", newImpl);
40+
return;
41+
}
42+
bytes memory bytecode = abi.encodePacked(
43+
abi.encodePacked(type(KintoWalletFactoryV2).creationCode),
44+
abi.encode(_getChainDeployment("KintoWalletV3-impl")) // Encoded constructor arguments
45+
);
46+
47+
// Deploy new paymaster implementation
48+
_factoryImpl = KintoWalletFactoryV2(payable(_walletFactory.deployContract(msg.sender, 0, bytecode, bytes32(0))));
49+
// Upgrade
50+
_walletFactory.upgradeTo(address(_factoryImpl));
51+
vm.stopBroadcast();
52+
// Writes the addresses to a file
53+
console.log("Add these new addresses to the artifacts file");
54+
console.log(string.concat('"KintoWalletFactoryV2-impl": "', vm.toString(address(_factoryImpl)), '"'));
55+
}
56+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
import "forge-std/Script.sol";
5+
import "../../src/wallet/KintoWalletFactory.sol";
6+
import "../../src/KintoID.sol";
7+
import "../../src/wallet/KintoWallet.sol";
8+
import {Create2Helper} from "../../test/helpers/Create2Helper.sol";
9+
import {ArtifactsReader} from "../../test/helpers/ArtifactsReader.sol";
10+
import {UUPSProxy} from "../../test/helpers/UUPSProxy.sol";
11+
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
12+
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
13+
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
14+
import "forge-std/console.sol";
15+
16+
contract KintoMigration11DeployScript is Create2Helper, ArtifactsReader {
17+
using ECDSAUpgradeable for bytes32;
18+
19+
KintoWalletFactory _walletFactory;
20+
KintoWallet _kintoWalletv1;
21+
KintoID _kintoIDv1;
22+
UUPSProxy _proxy;
23+
24+
function setUp() public {}
25+
26+
// solhint-disable code-complexity
27+
function run() public {
28+
console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid));
29+
// If not using ledger, replace
30+
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
31+
address deployer = vm.rememberKey(deployerPrivateKey);
32+
vm.startBroadcast(deployerPrivateKey);
33+
console.log("Executing with address", deployer);
34+
address walletFactoryAddr = _getChainDeployment("KintoWalletFactory");
35+
if (walletFactoryAddr == address(0)) {
36+
console.log("Need to execute main deploy script first", walletFactoryAddr);
37+
return;
38+
}
39+
address credits = _getChainDeployment("EngenCredits");
40+
IKintoAppRegistry _kintoApp = IKintoAppRegistry(_getChainDeployment("KintoAppRegistry"));
41+
42+
// TODO: This needs to go through the entry point and the wallet we created in 4
43+
// Create Engen App
44+
_kintoApp.registerApp("Engen", credits, new address[](0), [uint256(0), uint256(0), uint256(0), uint256(0)]);
45+
46+
vm.stopBroadcast();
47+
48+
// Writes the addresses to a file
49+
console.log("Engen APP created and minted");
50+
}
51+
}

0 commit comments

Comments
 (0)