Skip to content

Commit ff7c589

Browse files
authored
Merge pull request #8 from SocketDotTech/update-testnet
Update to work with latest socket-protocol testnet
2 parents 8628c65 + 1c1b85e commit ff7c589

11 files changed

Lines changed: 46 additions & 99 deletions

.env.sample

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ BASE_SEPOLIA_RPC="https://sepolia.base.org"
88
# EVMx key addresses
99
# Find the most up to date addresses at:
1010
# https://github.com/SocketDotTech/socket-protocol/blob/master/deployments/stage_addresses.json
11-
ADDRESS_RESOLVER="0x4846430BB142385e581C894AE92a4CF0722aEC21"
12-
FEES_MANAGER="0x9745623Aaa299500F93d2B1B4Efb7b3EC5e60FFc"
13-
ARBITRUM_FEES_PLUG="0x9E263f6c7C199d9c147E30764A8cae1175184CB8"
11+
ADDRESS_RESOLVER="0x21a9AFDfbEb0399D4a12f3AA1324042Be2B57F8e"
12+
FEES_MANAGER="0x30e07016eB24570629Bc8765CA307394Af90B27C"
13+
ARBITRUM_FEES_PLUG="0xDfE94B9b14de382Ed13C8A7F387884808D0f7E0b"
14+
ARBITRUM_TEST_USDC="0xa03Cbf13f331aF7c0fD7F2E28E6Cbc13F879E3F3"
1415

1516
# Add your deployer private key here
1617
# or remove it from this file if it is already an env var

lib/socket-protocol

script/counter/DeployEVMxCounterApp.s.sol

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ pragma solidity ^0.8.0;
33

44
import {Script} from "forge-std/Script.sol";
55
import {console} from "forge-std/console.sol";
6-
import {Fees} from "socket-protocol/contracts/protocol/utils/common/Structs.sol";
7-
import {ETH_ADDRESS} from "socket-protocol/contracts/protocol/utils/common/Constants.sol";
86

97
import {CounterAppGateway} from "../../src/counter/CounterAppGateway.sol";
108

@@ -32,10 +30,7 @@ contract CounterDeploy is Script {
3230
vm.startBroadcast(deployerPrivateKey);
3331

3432
// Setting fee payment on Arbitrum Sepolia
35-
// amount: Minimum fee required in contract and maximum user is willing to pay
36-
// User must have deposited >= amount, ensuring transmitter gets compensated for including this tx in a batch
37-
// Current Counter example costs 0.000105 eth
38-
Fees memory fees = Fees({feePoolChain: 421614, feePoolToken: ETH_ADDRESS, amount: 0.0005 ether});
33+
uint256 fees = 10 ether;
3934

4035
CounterAppGateway appGateway = new CounterAppGateway(addressResolver, fees);
4136

script/counter/DeployOnchainCounters.s.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pragma solidity ^0.8.0;
33

44
import {Script} from "forge-std/Script.sol";
55
import {console} from "forge-std/console.sol";
6-
import {ETH_ADDRESS} from "socket-protocol/contracts/protocol/utils/common/Constants.sol";
76

87
import {CounterAppGateway} from "../../src/counter/CounterAppGateway.sol";
98

script/counter/WithdrawFeesArbitrumFeesPlug.s.sol

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ pragma solidity ^0.8.0;
33

44
import {Script} from "forge-std/Script.sol";
55
import {console} from "forge-std/console.sol";
6-
import {FeesManager} from "socket-protocol/contracts/protocol/payload-delivery/FeesManager.sol";
7-
import {ETH_ADDRESS} from "socket-protocol/contracts/protocol/utils/common/Constants.sol";
6+
import {FeesManager} from "socket-protocol/contracts/evmx/payload-delivery/FeesManager.sol";
7+
import {TestUSDC} from "socket-protocol/contracts/evmx/helpers/TestUSDC.sol";
88

99
import {CounterAppGateway} from "../../src/counter/CounterAppGateway.sol";
1010

@@ -35,9 +35,10 @@ contract WithdrawFees is Script {
3535
vm.createSelectFork(vm.envString("EVMX_RPC"));
3636
FeesManager feesManager = FeesManager(payable(vm.envAddress("FEES_MANAGER")));
3737
address appGatewayAddress = vm.envAddress("APP_GATEWAY");
38+
TestUSDC testUSDCContract = TestUSDC(vm.envAddress("ARBITRUM_TEST_USDC"));
3839

3940
CounterAppGateway appGateway = CounterAppGateway(appGatewayAddress);
40-
uint256 availableFees = feesManager.getAvailableFees(421614, appGatewayAddress, ETH_ADDRESS);
41+
uint256 availableFees = feesManager.getMaxCreditsAvailableForWithdraw(appGatewayAddress);
4142
console.log("Available fees:", availableFees);
4243

4344
if (availableFees > 0) {
@@ -48,7 +49,7 @@ contract WithdrawFees is Script {
4849

4950
// Gas price from Arbitrum
5051
uint256 arbitrumGasPrice = block.basefee + 0.1 gwei; // With buffer
51-
uint256 gasLimit = 3_000_000; // Estimate
52+
uint256 gasLimit = 50_000_000_000; // Estimate
5253
uint256 estimatedGasCost = gasLimit * arbitrumGasPrice;
5354

5455
console.log("Arbitrum gas price (wei):", arbitrumGasPrice);
@@ -63,12 +64,8 @@ contract WithdrawFees is Script {
6364
vm.createSelectFork(vm.envString("EVMX_RPC"));
6465
vm.startBroadcast(privateKey);
6566
console.log("Withdrawing amount:", amountToWithdraw);
66-
appGateway.withdrawFeeTokens(421614, ETH_ADDRESS, amountToWithdraw, sender);
67+
appGateway.withdrawFeeTokens(421614, address(testUSDCContract), amountToWithdraw, sender);
6768
vm.stopBroadcast();
68-
69-
// Switch back to Arbitrum Sepolia to check final balance
70-
vm.createSelectFork(vm.envString("ARBITRUM_SEPOLIA_RPC"));
71-
console.log("Final sender balance:", sender.balance);
7269
} else {
7370
console.log("Available fees less than estimated gas cost");
7471
}

script/helpers/AppGatewayFeeBalance.s.sol

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,20 @@ pragma solidity ^0.8.0;
33

44
import {Script} from "forge-std/Script.sol";
55
import {console} from "forge-std/console.sol";
6-
import {FeesManager} from "socket-protocol/contracts/protocol/payload-delivery/FeesManager.sol";
7-
import {Fees} from "socket-protocol/contracts/protocol/utils/common/Structs.sol";
8-
import {ETH_ADDRESS} from "socket-protocol/contracts/protocol/utils/common/Constants.sol";
6+
import {FeesManager} from "socket-protocol/contracts/evmx/payload-delivery/FeesManager.sol";
97

108
contract CheckDepositedFees is Script {
119
function run() external {
1210
vm.createSelectFork(vm.envString("EVMX_RPC"));
1311
FeesManager feesManager = FeesManager(payable(vm.envAddress("FEES_MANAGER")));
1412
address appGateway = vm.envAddress("APP_GATEWAY");
1513

16-
(uint256 deposited, uint256 blocked) = feesManager.appGatewayFeeBalances(appGateway, 421614, ETH_ADDRESS);
14+
(uint256 deposited, uint256 blocked) = feesManager.userCredits(appGateway);
1715
console.log("AppGateway:", appGateway);
1816
console.log("Total balance of available fees for this AppGateway: %s", deposited);
1917
console.log("Fees being locked due to existing transactions: %s", blocked);
2018

21-
uint256 availableFees = feesManager.getAvailableFees(421614, appGateway, ETH_ADDRESS);
19+
uint256 availableFees = feesManager.getAvailableCredits(appGateway);
2220
console.log("Fees available to be spent on transactions: %s", availableFees);
2321
}
2422
}

script/helpers/CheckAppEVMxLimits.s.sol

Lines changed: 0 additions & 52 deletions
This file was deleted.

script/helpers/PayFeesInArbitrumETH.s.sol renamed to script/helpers/PayFeesInArbitrumTestUSDC.s.sol

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,32 @@ pragma solidity ^0.8.0;
33

44
import {Script} from "forge-std/Script.sol";
55
import {console} from "forge-std/console.sol";
6-
import {FeesPlug} from "socket-protocol/contracts/protocol/payload-delivery/FeesPlug.sol";
7-
import {Fees} from "socket-protocol/contracts/protocol/utils/common/Structs.sol";
8-
import {ETH_ADDRESS} from "socket-protocol/contracts/protocol/utils/common/Constants.sol";
6+
import {FeesPlug} from "socket-protocol/contracts/evmx/payload-delivery/FeesPlug.sol";
7+
import {TestUSDC} from "socket-protocol/contracts/evmx/helpers/TestUSDC.sol";
98

109
contract DepositFees is Script {
1110
function run() external {
1211
vm.createSelectFork(vm.envString("ARBITRUM_SEPOLIA_RPC"));
1312

1413
uint256 privateKey = vm.envUint("PRIVATE_KEY");
15-
vm.startBroadcast(privateKey);
14+
address sender = vm.addr(privateKey);
15+
16+
uint256 feesAmount = 100000000; // 10 USDC
1617
FeesPlug feesPlug = FeesPlug(payable(vm.envAddress("ARBITRUM_FEES_PLUG")));
1718
address appGateway = vm.envAddress("APP_GATEWAY");
19+
TestUSDC testUSDCContract = TestUSDC(vm.envAddress("ARBITRUM_TEST_USDC"));
1820

19-
address sender = vm.addr(privateKey);
20-
uint256 balance = sender.balance;
21+
vm.startBroadcast(privateKey);
22+
// mint test USDC to sender
23+
testUSDCContract.mint(sender, feesAmount);
24+
// approve fees plug to spend test USDC
25+
testUSDCContract.approve(address(feesPlug), feesAmount);
26+
27+
uint256 balance = testUSDCContract.balanceOf(sender);
2128
console.log("Using address %s with %s balance in wei", sender, balance);
2229

23-
uint256 feesAmount = 0.001 ether;
24-
console.log("Depositing 0.001 ether on Arbitrum FeesPlug %s", address(feesPlug));
25-
feesPlug.deposit{value: feesAmount}(ETH_ADDRESS, appGateway, feesAmount);
30+
console.log("Depositing 10 TestUSDC on Arbitrum FeesPlug %s", address(feesPlug));
31+
feesPlug.depositToFeeAndNative(address(testUSDCContract), appGateway, feesAmount);
2632
console.log("Added fee balance for AppGateway %s", feesAmount, appGateway);
2733
}
2834
}

src/counter/Counter.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pragma solidity >=0.7.0 <0.9.0;
33

44
import "solady/auth/Ownable.sol";
5-
import "socket-protocol/contracts/base/PlugBase.sol";
5+
import "socket-protocol/contracts/protocol/base/PlugBase.sol";
66

77
/**
88
* @title Counter

src/counter/CounterAppGateway.sol

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// SPDX-License-Identifier: GPL-3.0
22
pragma solidity >=0.7.0 <0.9.0;
33

4-
import "socket-protocol/contracts/base/AppGatewayBase.sol";
5-
import "socket-protocol/contracts/interfaces/IForwarder.sol";
6-
import "socket-protocol/contracts/interfaces/IPromise.sol";
4+
import "socket-protocol/contracts/evmx/base/AppGatewayBase.sol";
5+
import "socket-protocol/contracts/evmx/interfaces/IForwarder.sol";
6+
import "socket-protocol/contracts/evmx/interfaces/IPromise.sol";
77
import "./Counter.sol";
88
import "./ICounter.sol";
99

@@ -29,9 +29,9 @@ contract CounterAppGateway is AppGatewayBase, Ownable {
2929
* @param addressResolver_ Address of the SOCKET Protocol's AddressResolver contract
3030
* @param fees_ Fee configuration for multi-chain operations
3131
*/
32-
constructor(address addressResolver_, Fees memory fees_) AppGatewayBase(addressResolver_) {
32+
constructor(address addressResolver_, uint256 fees_) AppGatewayBase(addressResolver_) {
3333
creationCodeWithArgs[counter] = abi.encodePacked(type(Counter).creationCode);
34-
_setOverrides(fees_);
34+
_setMaxFees(fees_);
3535
_initializeOwner(msg.sender);
3636
}
3737

@@ -42,7 +42,7 @@ contract CounterAppGateway is AppGatewayBase, Ownable {
4242
* https://docs.socket.tech/writing-apps#onchain-contract-deployment-with-the-appgateway-contract
4343
* @param chainSlug_ The identifier of the target chain
4444
*/
45-
function deployContracts(uint32 chainSlug_) external async {
45+
function deployContracts(uint32 chainSlug_) external async(bytes("")) {
4646
_deploy(counter, chainSlug_, IsPlug.YES);
4747
}
4848

@@ -62,7 +62,7 @@ contract CounterAppGateway is AppGatewayBase, Ownable {
6262
* @dev Calls the increase function on each counter instance provided
6363
* @param instances_ Array of counter contract addresses to increment
6464
*/
65-
function incrementCounters(address[] memory instances_) public async {
65+
function incrementCounters(address[] memory instances_) public async(bytes("")) {
6666
for (uint256 i = 0; i < instances_.length; i++) {
6767
ICounter(instances_[i]).increase();
6868
}
@@ -73,8 +73,8 @@ contract CounterAppGateway is AppGatewayBase, Ownable {
7373
* @dev Allows the owner to modify fee settings for multi-chain operations
7474
* @param fees_ New fee configuration
7575
*/
76-
function setFees(Fees memory fees_) public {
77-
fees = fees_;
76+
function setMaxFees(uint256 fees_) public {
77+
maxFees = fees_;
7878
}
7979

8080
/**

0 commit comments

Comments
 (0)