Skip to content

Instantly share code, notes, and snippets.

View Perseverance's full-sized avatar
🪄

George Spasov Perseverance

🪄
View GitHub Profile
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/GSN/Context.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol";
// Shortened for brievety
// Message format keccak256 of packed `SellerAddress`,`BuyerAddress`,`ItemAddress`,`ConfirmedValue`
contract Bargain {
function transferItemWithEthers(address itemAddress, bytes _signedDataByOwner) public payable {
address itemOwner = Item(itemAddress).owner()
bytes32 bytes32Message = keccak256(abi.encodePacked(itemOwner, msg.sender, itemAddress, msg.value));
address recoveredSigner = recover(bytes32Message, _signedDataByOwner);
const mocha = require('mocha');
const Base = mocha.reporters.Base;
const ethers = require('ethers');
const shell = require('shelljs');
const parser = require('solidity-parser-antlr');
const fs = require('fs');
// const stats = require('./gasStats.js');
function EtherlimeReporterCreator(port) {
0xeE3693fdd0F3BCee6B12B8Ee0047c8fD6Ff6A0c8
0xf907a78085174876e8008344aa208080b90754608060405234801561001057600080fd5b5060405161065438038061065483398101806040528101908080519060200190929190805190602001909291908051906020019092919080518201929190505050600080856000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f7b2ec0d85856040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180836000191660001916815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561014c578082015181840152602081019050610131565b50505050905090810190601f1680156101795780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b15801561019957600080fd5b505af11580156101ad573d6000803e3d6000fd5b505050506040513d60208110156101c357600080fd5b8101908080519060200190929190505050915081604051602001808273ffffffffffffffffffffff
_counterfactualizeSignedTransaction(signedTransaction) {
const signedTransNoRSV = signedTransaction.substring(0, signedTransaction.length - 134);
let randomS = utils.keccak256(utils.randomBytes(3));
randomS = '0' + randomS.substring(3, randomS.length);
const counterfactualMagic = `1ba079be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798a0`;
return `${signedTransNoRSV}${counterfactualMagic}${randomS}`;
}
1ba079be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798a0
0xf907a78085174876e8008344aa208080b90754608060405234801561001057600080fd5b5060405161065438038061065483398101806040528101908080519060200190929190805190602001909291908051906020019092919080518201929190505050600080856000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f7b2ec0d85856040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180836000191660001916815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561014c578082015181840152602081019050610131565b50505050905090810190601f1680156101795780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b15801561019957600080fd5b505af11580156101ad573d6000803e3d6000fd5b505050506040513d60208110156101c357600080fd5b8101908080519060200190929190505050915081604051602001808273ffffffffffffffffffffff
_createDeployTransaction(addressHash, addressSig) {
return ethers.Contract.getDeployTransaction(IdentityProxy.bytecode, IdentityProxy.abi, settings.implementationAddress, connection.wallet.address, addressHash, addressSig);
}
_setupDeployTransaction(deployTransaction) {
deployTransaction.gasLimit = this.deploymentGasNeeded;
deployTransaction.gasPrice = this.deploymentGasPrice;
return deployTransaction;
}
contract IdentityContract {
uint256 public nonce;
function getSigner(bytes32 raw, bytes sig) public view returns(address signer) {
return ECTools.prefixedRecover(raw, sig);
}
modifier onlyValidSignature(uint256 relayerReward, address target, uint256 value, bytes data, bytes dataHashSignature) {
bytes32 dataHash = keccak256(abi.encodePacked(data, relayerReward, value, target, nonce));