Skip to content

Commit

Permalink
deployment config and update hardhat etherscan
Browse files Browse the repository at this point in the history
  • Loading branch information
livingrockrises committed Mar 22, 2024
1 parent 4b0a5ae commit ccf51fc
Show file tree
Hide file tree
Showing 9 changed files with 286 additions and 612 deletions.
113 changes: 0 additions & 113 deletions contracts/test/helpers/MockChainlinkAggregator.sol

This file was deleted.

32 changes: 32 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ const config: HardhatUserConfig = {
? [process.env.PRIVATE_KEY]
: walletUtils.makeKeyList(),
},
polygon_amoy: {
url:
process.env.POLYGON_AMOY_URL || "https://rpc-amoy.polygon.technology/",
chainId: 80002,
accounts:
process.env.PRIVATE_KEY !== undefined
? [process.env.PRIVATE_KEY]
: walletUtils.makeKeyList(),
},
bnb_mainnet: {
url: "https://bsc-dataseed2.binance.org",
chainId: 56,
Expand All @@ -109,6 +118,11 @@ const config: HardhatUserConfig = {
: walletUtils.makeKeyList(),
gasPrice: 50e9,
},
blastMainnet: {
url: process.env.BLAST_MAINNET_URL || "",
accounts: hardhatAccounts,
chainId: 81457,
},
baseGoerli: {
url:
process.env.BASE_TESTNET_URL ||
Expand Down Expand Up @@ -220,6 +234,15 @@ const config: HardhatUserConfig = {
gasPrice: 10e9,
chainId: 420,
},
optimismSepolia: {
url: `https://sepolia.optimism.io/`,
accounts:
process.env.PRIVATE_KEY !== undefined
? [process.env.PRIVATE_KEY]
: walletUtils.makeKeyList(),
gasPrice: 1e9,
chainId: 11155420,
},
optimismMainnet: {
url: `https://mainnet.optimism.io`,
accounts:
Expand Down Expand Up @@ -318,6 +341,7 @@ const config: HardhatUserConfig = {
arbitrumTestnet: process.env.ARBITRUM_API_KEY || "",
arbitrumOne: process.env.ARBITRUM_API_KEY || "",
optimisticGoerli: process.env.OPTIMISTIC_API_KEY || "",
optimismSepolia: process.env.OPTIMISTIC_API_KEY || "",
optimisticEthereum: process.env.OPTIMISTIC_API_KEY || "",
"base-goerli": "PLACEHOLDER_STRING",
"linea-goerli": "PLACEHOLDER_STRING",
Expand Down Expand Up @@ -445,6 +469,14 @@ const config: HardhatUserConfig = {
browserURL: "https://testnet-zkevm.polygonscan.com",
},
},
{
network: "optimismSepolia",
chainId: 11155420,
urls: {
apiURL: "https://api-sepolia-optimism.etherscan.io/api",
browserURL: "https://sepolia-optimism.etherscan.io/",
},
},
],
},
};
Expand Down
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts
Submodule openzeppelin-contracts added at fd81a9
2 changes: 1 addition & 1 deletion lib/scw-contracts
Submodule scw-contracts updated 56 files
+1 −4 .env.example
+0 −2 .eslintignore
+0 −0 .github/.github/ISSUE_TEMPLATE/bug_report.md
+0 −0 .github/.github/ISSUE_TEMPLATE/feature_request.md
+0 −0 .github/.github/pull_request_template.md
+0 −0 .github/.github/workflows/check_branch_name.yml
+0 −0 .github/.github/workflows/mark_stale.yml
+4 −7 .github/.github/workflows/push_check.yml
+0 −1 .prettierignore
+5 −11 .solhint.json
+0 −1 .solhintignore
+0 −64 CONTRIBUTING.md
+12 −7 contracts/smart-account/BaseSmartAccount.sol
+6 −10 contracts/smart-account/SmartAccount.sol
+1 −1 contracts/smart-account/base/Executor.sol
+8 −7 contracts/smart-account/base/FallbackManager.sol
+4 −3 contracts/smart-account/base/ModuleManager.sol
+5 −5 contracts/smart-account/common/ReentrancyGuard.sol
+10 −12 contracts/smart-account/deployer/Create3.sol
+225 −225 contracts/smart-account/estimation/SmartAccountNoAuth.sol
+33 −32 contracts/smart-account/factory/SmartAccountFactory.sol
+0 −2 contracts/smart-account/handler/DefaultCallbackHandler.sol
+24 −29 contracts/smart-account/interfaces/IERC1155TokenReceiver.sol
+1 −9 contracts/smart-account/interfaces/IERC165.sol
+1 −0 contracts/smart-account/interfaces/ISessionKeyManager.sol
+2 −4 contracts/smart-account/modules/BaseAuthorizationModule.sol
+149 −0 contracts/smart-account/modules/BatchedSessionRouterModule.sol
+2 −4 contracts/smart-account/modules/EcdsaOwnershipRegistryModule.sol
+1 −2 contracts/smart-account/modules/Exotic/EcdsaEthSignSupportOwnershipRegistryModule.sol
+31 −32 contracts/smart-account/modules/ForwardFlowModule.sol
+1 −1 contracts/smart-account/modules/MultichainECDSAValidator.sol
+18 −18 contracts/smart-account/modules/PasskeyValidationModules/Secp256r1.sol
+1 −1 contracts/smart-account/modules/SessionKeyManagerModule.sol
+3 −13 contracts/smart-account/modules/SessionValidationModules/ERC20SessionValidationModule.sol
+1 −2 contracts/smart-account/modules/SessionValidationModules/ISessionValidationModule.sol
+1 −2 contracts/smart-account/modules/SmartContractOwnershipRegistryModule.sol
+14 −11 contracts/smart-account/paymasters/BasePaymaster.sol
+2 −0 contracts/smart-account/paymasters/PaymasterHelpers.sol
+19 −16 contracts/smart-account/paymasters/verifying/singleton/VerifyingSingletonPaymaster.sol
+1 −1 contracts/smart-account/test/ForbiddenOpcodeInvokingAuthModule.sol
+1 −1 contracts/smart-account/test/WrongStorageAccessValidationModule.sol
+1 −2 contracts/smart-account/test/mocks/MockAuthModule.sol
+1 −2 contracts/smart-account/test/mocks/MockInvalidInitialAuthModule copy.sol
+1 −1 contracts/smart-account/test/mocks/MockSessionValidationModule.sol
+2 −2 contracts/smart-account/test/upgrades/ModuleManagerNew.sol
+2 −2 contracts/smart-account/test/upgrades/v1/ModuleManagerV1.sol
+2 −2 contracts/smart-account/test/upgrades/v1/SmartAccountV1.sol
+9 −6 contracts/smart-account/utils/GasEstimatorSmartAccount.sol
+11 −20 hardhat.config.ts
+0 −30,138 package-lock.json
+14 −22 scripts/deploy.ts
+4 −10 scripts/utils/index.ts
+291 −0 test/bundler-integration/module/BatchedSessionRouter.Module.specs.ts
+847 −0 test/module/BatchedSessionRouter.Module.specs.ts
+0 −163 test/module/SessionValidationModules/ERC20SessionValidation.Module.specs.ts
+1,416 −1,196 yarn.lock
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@nomicfoundation/hardhat-network-helpers": "^1.0.8",
"@nomicfoundation/hardhat-toolbox": "^2.0.2",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@nomiclabs/hardhat-etherscan": "^3.1.7",
"@nomiclabs/hardhat-etherscan": "^3.1.8",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@typechain/ethers-v5": "^10.2.0",
"@typechain/hardhat": "^6.1.5",
Expand Down Expand Up @@ -94,6 +94,7 @@
"@ethersproject/abstract-signer": "^5.6.2",
"@ethersproject/constants": "^5.6.1",
"@mean-finance/uniswap-v3-oracle": "^1.0.3",
"@nomicfoundation/hardhat-verify": "^2.0.5",
"@openzeppelin/contracts": "4.8.1",
"@openzeppelin/contracts-upgradeable": "4.8.1",
"@pimlico/erc20-paymaster": "^0.0.1",
Expand All @@ -112,4 +113,4 @@
"solidity-bytes-utils": "^0.8.0",
"source-map-support": "^0.5.19"
}
}
}
4 changes: 2 additions & 2 deletions scripts/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ export const deployContract = async (
// TODO
// Review gas price
const { hash, wait } = await deployerInstance.deploy(salt, contractByteCode, {
maxFeePerGas: 3e9,
maxPriorityFeePerGas: 2e9,
maxFeePerGas: 1e9,
maxPriorityFeePerGas: 1e6,
});

console.log(`Submitted transaction ${hash} for deployment`);
Expand Down
135 changes: 0 additions & 135 deletions test/bundler-integration/token-paymaster/oracle-aggregator-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ import {
BiconomyTokenPaymaster__factory,
ChainlinkOracleAggregator,
ChainlinkOracleAggregator__factory,
MockChainlinkOracleAggregator__factory,
MockPriceFeed,
MockStalePriceFeed__factory,
MockStalePriceFeed,
MockPriceFeed__factory,
MockToken,
MockChainlinkOracleAggregator,
} from "../../../typechain-types";
import {
EcdsaOwnershipRegistryModule,
Expand Down Expand Up @@ -97,7 +93,6 @@ describe("Biconomy Token Paymaster (With Bundler)", function () {

let sampleTokenPaymaster: BiconomyTokenPaymaster;
let oracleAggregator: ChainlinkOracleAggregator;
let staleOracleAggregator: MockChainlinkOracleAggregator;

// Could also use published package or added submodule (for Account Implementation and Factory)
let smartWalletImp: BiconomyAccountImplementation;
Expand Down Expand Up @@ -130,9 +125,6 @@ describe("Biconomy Token Paymaster (With Bundler)", function () {
oracleAggregator = await new ChainlinkOracleAggregator__factory(
deployer
).deploy(walletOwnerAddress);
staleOracleAggregator = await new MockChainlinkOracleAggregator__factory(
deployer
).deploy(walletOwnerAddress);

ecdsaModule = await new EcdsaOwnershipRegistryModule__factory(
deployer
Expand Down Expand Up @@ -174,14 +166,6 @@ describe("Biconomy Token Paymaster (With Bundler)", function () {
const priceFeedTxStale: any =
await priceFeedStale.populateTransaction.getThePrice();

await staleOracleAggregator.setTokenOracle(
token.address,
stalePriceFeedMock.address,
18,
priceFeedTxStale.data,
true
);

const priceResult = await oracleAggregator.getTokenValueOfOneNativeToken(
token.address
);
Expand Down Expand Up @@ -250,125 +234,6 @@ describe("Biconomy Token Paymaster (With Bundler)", function () {
});

describe("Token Paymaster with good and bad oracle aggregator", () => {
it("succeed with fallback exchange rate in case price feed reverts", async () => {
const userSCW: any = BiconomyAccountImplementation__factory.connect(
walletAddress,
deployer
);

await token
.connect(deployer)
.transfer(walletAddress, ethers.utils.parseEther("100"));

const owner = await walletOwner.getAddress();
const AccountFactory = await ethers.getContractFactory(
"SmartAccountFactory"
);
const ecdsaOwnershipSetupData = ecdsaModule.interface.encodeFunctionData(
"initForSmartAccount",
[owner]
);

const smartAccountDeploymentIndex = 0;

const deploymentData = AccountFactory.interface.encodeFunctionData(
"deployCounterFactualAccount",
[
ecdsaModule.address,
ecdsaOwnershipSetupData,
smartAccountDeploymentIndex,
]
);

const userOp1 = await fillAndSign(
{
sender: walletAddress,
verificationGasLimit: 200000,
preVerificationGas: 50000,
callData: encodeERC20Approval(
userSCW,
token,
paymasterAddress,
ethers.constants.MaxUint256
),
},
walletOwner,
entryPoint,
"nonce"
);

const hash = await sampleTokenPaymaster.getHash(
userOp1,
ethers.utils.hexlify(1).slice(2, 4),
MOCK_VALID_UNTIL,
MOCK_VALID_AFTER,
token.address,
staleOracleAggregator.address,
MOCK_FX,
DEFAULT_FEE_MARKUP
);
const sig = await offchainSigner.signMessage(arrayify(hash));
const userOp = await fillAndSign(
{
...userOp1,
paymasterAndData: ethers.utils.hexConcat([
paymasterAddress,
ethers.utils.hexlify(1).slice(0, 4),
encodePaymasterData(
token.address,
staleOracleAggregator.address,
MOCK_FX,
DEFAULT_FEE_MARKUP
),
sig,
]),
},
walletOwner,
entryPoint,
"nonce"
);

const signatureWithModuleAddress = ethers.utils.defaultAbiCoder.encode(
["bytes", "address"],
[userOp.signature, ecdsaModule.address]
);

userOp.signature = signatureWithModuleAddress;

const { result: userOpHash } = await environment.sendUserOperation(
userOp,
entryPoint.address
);

const {
result: {
receipt: { transactionHash },
},
} = await environment.getUserOperationReceipt(userOpHash);
const receipt = await ethers.provider.getTransactionReceipt(
transactionHash
);

const ev = await getUserOpEvent(entryPoint);
expect(ev.args.success).to.be.true;

const BiconomyTokenPaymaster = await ethers.getContractFactory(
"BiconomyTokenPaymaster"
);

const eventLogs = BiconomyTokenPaymaster.interface.decodeEventLog(
"TokenPaymasterOperation",
receipt.logs[3].data
);

// Confirming that it's using backup (external) exchange rate in case oracle aggregator / price feed is stale / anything goes wrong
expect(eventLogs.exchangeRate.toString()).to.be.equal(MOCK_FX);

await expect(
entryPoint.handleOps([userOp], await offchainSigner.getAddress())
).to.be.reverted;
});

it("succeed with exchange rate based on prcie feed in case everything goes well", async () => {
const userSCW: any = BiconomyAccountImplementation__factory.connect(
walletAddress,
Expand Down
Loading

0 comments on commit ccf51fc

Please sign in to comment.