Commit 4c64a581 authored by Mark Tyneway's avatar Mark Tyneway

ctp: update AttestationStation to 1.1.0

Adds a new interface to the AttestationStation for single
attestations. Previously only an array of attestations
was able to be sent. This overloaded function makes it
more simple for smart contracts that want to attest to
data.
parent c1d44d70
---
'@eth-optimism/contracts-periphery': patch
---
Update the attestation station impl to 1.1.0
...@@ -10,22 +10,23 @@ AssetReceiverTest:test_withdrawERC20withAmount() (gas: 182146) ...@@ -10,22 +10,23 @@ AssetReceiverTest:test_withdrawERC20withAmount() (gas: 182146)
AssetReceiverTest:test_withdrawERC721() (gas: 49097) AssetReceiverTest:test_withdrawERC721() (gas: 49097)
AssetReceiverTest:test_withdrawETH() (gas: 26179) AssetReceiverTest:test_withdrawETH() (gas: 26179)
AssetReceiverTest:test_withdrawETHwithAmount() (gas: 26108) AssetReceiverTest:test_withdrawETHwithAmount() (gas: 26108)
AssetReceiverTest:test_attest_bulk() (gas: 592013) AssetReceiverTest:test_attest_bulk() (gas: 614443)
AssetReceiverTest:test_attest_single() (gas: 539644) AssetReceiverTest:test_attest_individual() (gas: 541558)
OptimistTest:test_optimist_baseURI() (gas: 117016) AssetReceiverTest:test_attest_single() (gas: 561966)
OptimistTest:test_optimist_burn() (gas: 77691) OptimistTest:test_optimist_baseURI() (gas: 116809)
OptimistTest:test_optimist_burn() (gas: 77525)
OptimistTest:test_optimist_initialize() (gas: 23095) OptimistTest:test_optimist_initialize() (gas: 23095)
OptimistTest:test_optimist_is_on_allow_list() (gas: 52822) OptimistTest:test_optimist_is_on_allow_list() (gas: 52615)
OptimistTest:test_optimist_mint_already_minted() (gas: 99125) OptimistTest:test_optimist_mint_already_minted() (gas: 98910)
OptimistTest:test_optimist_mint_happy_path() (gas: 99381) OptimistTest:test_optimist_mint_happy_path() (gas: 99174)
OptimistTest:test_optimist_mint_no_attestation() (gas: 15897) OptimistTest:test_optimist_mint_no_attestation() (gas: 15897)
OptimistTest:test_optimist_mint_secondary_minter() (gas: 100782) OptimistTest:test_optimist_mint_secondary_minter() (gas: 100575)
OptimistTest:test_optimist_sbt_approve() (gas: 97490) OptimistTest:test_optimist_sbt_approve() (gas: 97283)
OptimistTest:test_optimist_sbt_transfer() (gas: 102537) OptimistTest:test_optimist_sbt_transfer() (gas: 102330)
OptimistTest:test_optimist_set_approval_for_all() (gas: 101119) OptimistTest:test_optimist_set_approval_for_all() (gas: 100906)
OptimistTest:test_optimist_supports_interface() (gas: 5797) OptimistTest:test_optimist_supports_interface() (gas: 5797)
OptimistTest:test_optimist_token_id_of_owner() (gas: 95251) OptimistTest:test_optimist_token_id_of_owner() (gas: 95044)
OptimistTest:test_optimist_token_uri() (gas: 214371) OptimistTest:test_optimist_token_uri() (gas: 213949)
TransactorTest:testFail_CALL() (gas: 15658) TransactorTest:testFail_CALL() (gas: 15658)
TransactorTest:testFail_DELEGATECALLL() (gas: 15632) TransactorTest:testFail_DELEGATECALLL() (gas: 15632)
TransactorTest:test_CALL() (gas: 26977) TransactorTest:test_CALL() (gas: 26977)
......
...@@ -26,6 +26,23 @@ contract AssetReceiverTest is AssetReceiver_Initializer { ...@@ -26,6 +26,23 @@ contract AssetReceiverTest is AssetReceiver_Initializer {
super._setUp(); super._setUp();
} }
event AttestationCreated(
address indexed creator,
address indexed about,
bytes32 indexed key,
bytes val
);
function test_attest_individual() external {
AttestationStation attestationStation = new AttestationStation();
vm.expectEmit(true, true, true, true);
emit AttestationCreated(alice_attestor, bob, bytes32("foo"), bytes("bar"));
vm.prank(alice_attestor);
attestationStation.attest({ _about: bob, _key: bytes32("foo"), _val: bytes("bar") });
}
function test_attest_single() external { function test_attest_single() external {
AttestationStation attestationStation = new AttestationStation(); AttestationStation attestationStation = new AttestationStation();
......
...@@ -44,31 +44,57 @@ contract AttestationStation is Semver { ...@@ -44,31 +44,57 @@ contract AttestationStation is Semver {
); );
/** /**
* @custom:semver 1.0.0 * @custom:semver 1.1.0
*/ */
constructor() Semver(1, 0, 0) {} constructor() Semver(1, 1, 0) {}
/**
* @notice Allows anyone to create an attestation.
*
* @param _about Address that the attestation is about.
* @param _key A key used to namespace the attestation.
* @param _val An arbitrary value stored as part of the attestation.
*/
function attest(
address _about,
bytes32 _key,
bytes memory _val
) external {
_attest(_about, _key, _val);
}
/** /**
* @notice Allows anyone to create attestations. * @notice Allows anyone to create attestations.
* *
* @param _attestations An array of attestation data. * @param _attestations An array of attestation data.
*/ */
function attest(AttestationData[] memory _attestations) public { function attest(AttestationData[] calldata _attestations) external {
uint256 length = _attestations.length; uint256 length = _attestations.length;
for (uint256 i = 0; i < length; ) { for (uint256 i = 0; i < length; ) {
AttestationData memory attestation = _attestations[i]; AttestationData memory attestation = _attestations[i];
attestations[msg.sender][attestation.about][attestation.key] = attestation.val;
emit AttestationCreated( _attest(attestation.about, attestation.key, attestation.val);
msg.sender,
attestation.about,
attestation.key,
attestation.val
);
unchecked { unchecked {
++i; ++i;
} }
} }
} }
/**
* @notice Internal function that stores the attestation in a mapping.
*
* @param _about Address that the attestation is about.
* @param _key A key used to namespace the attestation.
* @param _val An arbitrary value stored as part of the attestation.
*/
function _attest(
address _about,
bytes32 _key,
bytes memory _val
) internal {
attestations[msg.sender][_about][_key] = _val;
emit AttestationCreated(msg.sender, _about, _key, _val);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment