Skip to content

Commit

Permalink
Rename Custom -> Sigleton
Browse files Browse the repository at this point in the history
  • Loading branch information
nlordell committed Nov 23, 2023
1 parent e5d32c7 commit ec9424d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity >=0.8.0;

import {ISignatureValidator} from "@safe-global/safe-contracts/contracts/interfaces/ISignatureValidator.sol";

contract TestCustomSigner is ISignatureValidator {
contract TestSingletonSigner is ISignatureValidator {
struct Key {
uint256 _dummy;
uint256 value;
Expand All @@ -28,15 +28,15 @@ contract TestCustomSigner is ISignatureValidator {
}
}

contract TestCustomSignerFactory {
bytes32 public constant SIGNER_CODE_HASH = keccak256(type(TestCustomSigner).creationCode);
contract TestSingletonSignerFactory {
bytes32 public constant SIGNER_CODE_HASH = keccak256(type(TestSingletonSigner).creationCode);

function getSigner(uint256 index) public view returns (address) {
return address(uint160(uint256(keccak256(abi.encodePacked(hex"ff", address(this), index, SIGNER_CODE_HASH)))));
}

function deploySigner(uint256 index) external {
TestCustomSigner signer = new TestCustomSigner{salt: bytes32(index)}();
TestSingletonSigner signer = new TestSingletonSigner{salt: bytes32(index)}();
require(address(signer) == getSigner(index));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { buildSignatureBytes } from '../../src/utils/execution'
import { buildUserOperationFromSafeUserOperation, buildSafeUserOpTransaction } from '../../src/utils/userOp'
import { bundlerRpc, encodeMultiSendTransactions, prepareAccounts, waitForUserOp } from '../utils/e2e'

describe('E2E - Custom Signers', () => {
describe('E2E - Singleton Signers', () => {
before(function () {
if (network.name !== 'localhost') {
this.skip()
Expand Down Expand Up @@ -32,13 +32,13 @@ describe('E2E - Custom Signers', () => {
})
.then((tx) => tx.wait())

const TestCustomSignerFactory = await ethers.getContractFactory('TestCustomSignerFactory')
const signerFactory = await TestCustomSignerFactory.deploy()
const TestSingletonSignerFactory = await ethers.getContractFactory('TestSingletonSignerFactory')
const signerFactory = await TestSingletonSignerFactory.deploy()
const customSigners = []
for (let i = 0; i < 3; i++) {
await signerFactory.deploySigner(i).then((tx) => tx.wait())
customSigners.push({
signer: await ethers.getContractAt('TestCustomSigner', await signerFactory.getSigner(i)),
signer: await ethers.getContractAt('TestSingletonSigner', await signerFactory.getSigner(i)),
key: BigInt(ethers.keccak256(ethers.toBeHex(i, 1))),
})
}
Expand Down

0 comments on commit ec9424d

Please sign in to comment.