Skip to content

Commit eeaf7af

Browse files
author
d.kotwal
committed
OP eco-system tools for scalability and maintenance, support, service of public infrastructure
1 parent 722ad8a commit eeaf7af

29 files changed

+25435
-0
lines changed
0 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
3+
#Hardhat files
4+
cache
5+
artifacts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Free OP transactions for public infrastructure support and maintenance
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//SPDX-License-Identifier: Unlicense
2+
pragma solidity ^0.8.0;
3+
4+
import "@opengsn/contracts/src/BaseRelayRecipient.sol";
5+
6+
contract Greeter is BaseRelayRecipient {
7+
string greeting;
8+
address lastGreeter;
9+
10+
event LogEntry(address indexed _soliditySender,
11+
address _gsnSender,
12+
address _trustedForwarder,
13+
address _lastGreeter,
14+
bytes _data);
15+
16+
17+
constructor(string memory _greeting, address _trustedForwarderAddr) {
18+
greeting = _greeting;
19+
_setTrustedForwarder(_trustedForwarderAddr);
20+
lastGreeter = _msgSender();
21+
}
22+
23+
function versionRecipient() external virtual view override returns (string memory) {
24+
return "v. 1.0.0";
25+
}
26+
27+
function greet() public view returns (string memory) {
28+
return greeting;
29+
}
30+
31+
function lastGreeterAddr() public view returns (address) {
32+
return lastGreeter;
33+
}
34+
35+
function setGreeting(string memory _greeting) public {
36+
37+
emit LogEntry(msg.sender,
38+
_msgSender(),
39+
trustedForwarder(),
40+
lastGreeter,
41+
msg.data );
42+
43+
greeting = _greeting;
44+
lastGreeter = _msgSender();
45+
}
46+
47+
48+
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
pragma experimental ABIEncoderV2;
4+
5+
import "@opengsn/contracts/src/BasePaymaster.sol";
6+
7+
/**
8+
* a paymaster for a single recipient contract.
9+
* - reject requests if destination is not the target contract.
10+
* - reject any request if the target contract reverts.
11+
*/
12+
contract SingleRecipientPaymaster is BasePaymaster {
13+
14+
address public target;
15+
16+
event TargetChanged(address oldTarget, address newTarget);
17+
18+
constructor(address _target) {
19+
target=_target;
20+
}
21+
22+
function versionPaymaster() external view override virtual returns (string memory){
23+
return "2.2.0+opengsn.recipient.ipaymaster";
24+
}
25+
26+
function setTarget(address _target) external onlyOwner {
27+
emit TargetChanged(target, _target);
28+
target=_target;
29+
}
30+
31+
function preRelayedCall(
32+
GsnTypes.RelayRequest calldata relayRequest,
33+
bytes calldata signature,
34+
bytes calldata approvalData,
35+
uint256 maxPossibleGas
36+
)
37+
external
38+
override
39+
virtual
40+
returns (bytes memory context, bool revertOnRecipientRevert) {
41+
(relayRequest, signature, approvalData, maxPossibleGas);
42+
require(relayRequest.request.to==target, "wrong target");
43+
//returning "true" means this paymaster accepts all requests that
44+
// are not rejected by the recipient contract.
45+
return ("", true);
46+
}
47+
48+
function postRelayedCall(
49+
bytes calldata context,
50+
bool success,
51+
uint256 gasUseWithoutPost,
52+
GsnTypes.RelayData calldata relayData
53+
) external override virtual {
54+
(context, success, gasUseWithoutPost, relayData);
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Plugins
2+
require('@nomiclabs/hardhat-ethers')
3+
4+
// No need for a real mnemonic when you send free transactions
5+
junkMnemonic = 'test test test test test test test test test test test junk'
6+
7+
8+
module.exports = {
9+
networks: {
10+
hardhat: {
11+
accounts: {
12+
mnemonic: junkMnemonic
13+
}
14+
},
15+
'optimistic-kovan-orig': {
16+
chainId: 69,
17+
url: 'https://kovan.optimism.io',
18+
accounts: {
19+
mnemonic: junkMnemonic
20+
}
21+
},
22+
'optimistic-mainnet': {
23+
chainId: 10,
24+
url: 'https://mainnet.optimism.io',
25+
accounts: {
26+
mnemonic: junkMnemonic
27+
}
28+
},
29+
},
30+
solidity: '0.8.9',
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "hardhat-project",
3+
"devDependencies": {
4+
"@nomiclabs/hardhat-ethers": "^2.0.5",
5+
"@nomiclabs/hardhat-waffle": "^2.0.3",
6+
"chai": "^4.3.6",
7+
"ethereum-waffle": "^3.4.4",
8+
"ethers": "^5.6.1",
9+
"hardhat": "^2.9.1"
10+
},
11+
"dependencies": {
12+
"@opengsn/contracts": "^2.2.6",
13+
"@opengsn/provider": "^2.2.6",
14+
"dotenv": "^16.0.0",
15+
"web3-eth-contract": "^1.7.1",
16+
"web3-providers-http": "^1.7.1"
17+
}
18+
}

Asset-Management-Spare-Parts/free-OP-Tx-public-infra-opengsn/scripts/use-gsn.js

+194
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)