-
Notifications
You must be signed in to change notification settings - Fork 1
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
3f9b859
commit b9cbec1
Showing
8 changed files
with
665 additions
and
93 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
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
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
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,15 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.10; | ||
|
||
/** | ||
* @notice Errors that can occur within the paymaster. | ||
*/ | ||
interface IPaymasterErrors { | ||
error ForwarderNotTrusted(address); | ||
error InterfaceNotSupported(string); | ||
error InvalidPaymasterDataLength(); | ||
error InvalidApprovalDataLength(); | ||
error RelayHubAddressNotSet(); | ||
error RequiresRelayHubCaller(); | ||
error ValueTransferNotSupported(); | ||
} |
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
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,79 @@ | ||
import { ethers } from "hardhat"; | ||
import { MockContract } from "@defi-wonderland/smock"; | ||
import { FixtureFunc } from "hardhat-deploy/dist/types"; | ||
import { deploymentSalt, ZERO_ADDRESS } from "../../src/utils"; | ||
import { facetMock } from "../utils"; | ||
import { | ||
PaymasterTopFacet, | ||
PaymasterInitFacet, | ||
PaymasterTopFacet__factory, | ||
} from "../../typechain"; | ||
import { PAYMASTER_FACETS } from "../../tasks/paymaster"; | ||
import { Paymaster } from "../../typechain/hardhat-diamond-abi/HardhatDiamondABI.sol"; | ||
|
||
export const PAYMASTER_INIT_DEFAULTS: PaymasterInitFacet.InitializerParamsStruct = | ||
{ | ||
marketplace: ZERO_ADDRESS, | ||
}; | ||
|
||
interface PaymasterFixtureResult { | ||
paymaster: Paymaster; | ||
topMock: MockContract<PaymasterTopFacet>; | ||
} | ||
interface PaymasterFixtureOpts { | ||
readonly name: string; | ||
readonly deployer: string; | ||
readonly afterDeploy: (result: PaymasterFixtureResult) => void; | ||
} | ||
interface PaymasterFixtureFuncArgs { | ||
readonly initWith: {}; | ||
readonly opts: PaymasterFixtureOpts; | ||
} | ||
|
||
export const paymasterFixtureFunc: FixtureFunc< | ||
PaymasterFixtureResult, | ||
PaymasterFixtureFuncArgs | ||
> = async (hre, opts) => { | ||
// opts could be `undefined`. | ||
if (!opts) throw Error("You must provide Paymaster fixture options."); | ||
const { | ||
opts: { deployer, name, afterDeploy }, | ||
initWith, | ||
} = opts; | ||
// Deploy diamond. | ||
const { address: paymasterAddr } = await hre.deployments.diamond.deploy( | ||
name, | ||
{ | ||
from: deployer, | ||
owner: deployer, | ||
facets: [...PAYMASTER_FACETS, "PaymasterInitFacet"], | ||
execute: { | ||
contract: "PaymasterInitFacet", | ||
methodName: "initialize", | ||
args: [{ ...PAYMASTER_INIT_DEFAULTS, ...initWith }], | ||
}, | ||
deterministicSalt: deploymentSalt(hre), | ||
excludeSelectors: { | ||
"PaymasterTopFacet": ["supportsInterface"] | ||
} | ||
} | ||
); | ||
|
||
// Get a Paymaster typed pointer. | ||
const paymaster = await ethers.getContractAt<Paymaster>( | ||
"Paymaster", | ||
paymasterAddr | ||
); | ||
// Build result. | ||
const result: PaymasterFixtureResult = { | ||
paymaster, | ||
topMock: await facetMock<PaymasterTopFacet__factory>( | ||
paymaster, | ||
"PaymasterTopFacet" | ||
), | ||
}; | ||
// Callback! | ||
await afterDeploy.apply(this, [result]); | ||
// Final return. | ||
return result; | ||
}; |
Oops, something went wrong.