Skip to content

Commit

Permalink
contract fixes and deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewliu08 committed Dec 2, 2024
1 parent b243336 commit 66f938a
Show file tree
Hide file tree
Showing 7 changed files with 380 additions and 108 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/contract/script/deployV2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SCRIPTS=(
# "script/pay/DeployDaimoPayBridger.s.sol"
# "script/pay/DeployPayIntentFactory.s.sol"
# "script/pay/DeployDaimoPay.s.sol"
"script/pay/DeployDaimoPayRelayer.s.sol" # The deployer must be the LP that calls this contract.
# "script/pay/DeployDaimoPayRelayer.s.sol" # The deployer must be the LP that calls this contract.

# DAv2
# "script/DeployFlexSwapperUniOnly.s.sol"
Expand Down Expand Up @@ -50,7 +50,7 @@ CHAINS=(

# TESTNETS
# "$ETHERSCAN_API_KEY_L1,https://eth-sepolia.g.alchemy.com/v2/$ALCHEMY_API_KEY"
"$ETHERSCAN_API_KEY_BASE,https://sepolia.base.org"
# "$ETHERSCAN_API_KEY_BASE,https://sepolia.base.org"

)

Expand Down
6 changes: 5 additions & 1 deletion packages/contract/script/pay/DeployDaimoPayRelayer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ contract DeployDaimoPayRelayer is Script {
vm.startBroadcast();

address daimoPayRelayer = CREATE3.deploy(
keccak256("DaimoPayRelayer-5"),
keccak256("DaimoPayRelayer-8"),
abi.encodePacked(
type(DaimoPayRelayer).creationCode,
abi.encode(owner)
Expand All @@ -23,6 +23,10 @@ contract DeployDaimoPayRelayer is Script {

console.log("daimoPayRelayer deployed at address:", daimoPayRelayer);

address relayer = 0x723A63fb50dA50A26997Fb99A2Eb151E4F8c5227;
DaimoPayRelayer(payable(daimoPayRelayer)).grantRelayerRole(relayer);
console.log("Relayer role granted to", relayer);

vm.stopBroadcast();
}

Expand Down
14 changes: 2 additions & 12 deletions packages/contract/src/pay/DaimoPayRelayer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,9 @@ contract DaimoPayRelayer is AccessControl {
TokenAmount calldata tokenIn,
Call[] calldata calls
) public onlyRole(RELAYER_ROLE) {
TokenUtils.transferFrom({
TokenUtils.transfer({
token: tokenIn.token,
from: msg.sender,
to: address(dp),
recipient: payable(address(dp)),
amount: tokenIn.amount
});
dp.fastFinishIntent(intent, calls);
Expand Down Expand Up @@ -226,15 +225,6 @@ contract DaimoPayRelayer is AccessControl {
(bool success, ) = call.to.call{value: call.value}(call.data);
require(success, "DPR: postCall failed");
}

// Transfer any bridgeTokenOut balance back to the owner
uint256 n = intent.bridgeTokenOutOptions.length;
for (uint256 i = 0; i < n; ++i) {
TokenUtils.transferBalance(
intent.bridgeTokenOutOptions[i].token,
payable(msg.sender)
);
}
}

receive() external payable {}
Expand Down
184 changes: 154 additions & 30 deletions packages/daimo-contract/src/codegen/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4761,16 +4761,23 @@ export const daimoPayCctpBridgerAbi = [
export const daimoPayRelayerAbi = [
{
type: 'constructor',
inputs: [{ name: '_owner', internalType: 'address', type: 'address' }],
inputs: [{ name: 'admin', internalType: 'address', type: 'address' }],
stateMutability: 'nonpayable',
},
{ type: 'receive', stateMutability: 'payable' },
{
type: 'function',
inputs: [],
name: 'acceptOwnership',
outputs: [],
stateMutability: 'nonpayable',
name: 'DEFAULT_ADMIN_ROLE',
outputs: [{ name: '', internalType: 'bytes32', type: 'bytes32' }],
stateMutability: 'view',
},
{
type: 'function',
inputs: [],
name: 'RELAYER_ROLE',
outputs: [{ name: '', internalType: 'bytes32', type: 'bytes32' }],
stateMutability: 'view',
},
{
type: 'function',
Expand Down Expand Up @@ -4935,22 +4942,55 @@ export const daimoPayRelayerAbi = [
},
{
type: 'function',
inputs: [],
name: 'owner',
outputs: [{ name: '', internalType: 'address', type: 'address' }],
inputs: [{ name: 'role', internalType: 'bytes32', type: 'bytes32' }],
name: 'getRoleAdmin',
outputs: [{ name: '', internalType: 'bytes32', type: 'bytes32' }],
stateMutability: 'view',
},
{
type: 'function',
inputs: [],
name: 'pendingOwner',
outputs: [{ name: '', internalType: 'address', type: 'address' }],
inputs: [{ name: 'relayer', internalType: 'address', type: 'address' }],
name: 'grantRelayerRole',
outputs: [],
stateMutability: 'nonpayable',
},
{
type: 'function',
inputs: [
{ name: 'role', internalType: 'bytes32', type: 'bytes32' },
{ name: 'account', internalType: 'address', type: 'address' },
],
name: 'grantRole',
outputs: [],
stateMutability: 'nonpayable',
},
{
type: 'function',
inputs: [
{ name: 'role', internalType: 'bytes32', type: 'bytes32' },
{ name: 'account', internalType: 'address', type: 'address' },
],
name: 'hasRole',
outputs: [{ name: '', internalType: 'bool', type: 'bool' }],
stateMutability: 'view',
},
{
type: 'function',
inputs: [],
name: 'renounceOwnership',
inputs: [
{ name: 'role', internalType: 'bytes32', type: 'bytes32' },
{ name: 'callerConfirmation', internalType: 'address', type: 'address' },
],
name: 'renounceRole',
outputs: [],
stateMutability: 'nonpayable',
},
{
type: 'function',
inputs: [
{ name: 'role', internalType: 'bytes32', type: 'bytes32' },
{ name: 'account', internalType: 'address', type: 'address' },
],
name: 'revokeRole',
outputs: [],
stateMutability: 'nonpayable',
},
Expand Down Expand Up @@ -5041,6 +5081,13 @@ export const daimoPayRelayerAbi = [
outputs: [],
stateMutability: 'payable',
},
{
type: 'function',
inputs: [{ name: 'interfaceId', internalType: 'bytes4', type: 'bytes4' }],
name: 'supportsInterface',
outputs: [{ name: '', internalType: 'bool', type: 'bool' }],
stateMutability: 'view',
},
{
type: 'function',
inputs: [
Expand All @@ -5067,7 +5114,8 @@ export const daimoPayRelayerAbi = [
{ name: 'amount', internalType: 'uint256', type: 'uint256' },
],
},
{ name: 'maxTip', internalType: 'uint256', type: 'uint256' },
{ name: 'maxPreTip', internalType: 'uint256', type: 'uint256' },
{ name: 'maxPostTip', internalType: 'uint256', type: 'uint256' },
{
name: 'innerSwap',
internalType: 'struct Call',
Expand All @@ -5085,70 +5133,146 @@ export const daimoPayRelayerAbi = [
},
{
type: 'function',
inputs: [{ name: 'newOwner', internalType: 'address', type: 'address' }],
name: 'transferOwnership',
inputs: [
{ name: 'token', internalType: 'contract IERC20', type: 'address' },
{ name: 'amount', internalType: 'uint256', type: 'uint256' },
],
name: 'withdrawAmount',
outputs: [],
stateMutability: 'nonpayable',
},
{
type: 'function',
inputs: [
{ name: 'token', internalType: 'contract IERC20', type: 'address' },
],
name: 'withdrawBalance',
outputs: [],
stateMutability: 'nonpayable',
},
{
type: 'event',
anonymous: false,
inputs: [
{ name: 'role', internalType: 'bytes32', type: 'bytes32', indexed: true },
{
name: 'previousOwner',
name: 'previousAdminRole',
internalType: 'bytes32',
type: 'bytes32',
indexed: true,
},
{
name: 'newAdminRole',
internalType: 'bytes32',
type: 'bytes32',
indexed: true,
},
],
name: 'RoleAdminChanged',
},
{
type: 'event',
anonymous: false,
inputs: [
{ name: 'role', internalType: 'bytes32', type: 'bytes32', indexed: true },
{
name: 'account',
internalType: 'address',
type: 'address',
indexed: true,
},
{
name: 'newOwner',
name: 'sender',
internalType: 'address',
type: 'address',
indexed: true,
},
],
name: 'OwnershipTransferStarted',
name: 'RoleGranted',
},
{
type: 'event',
anonymous: false,
inputs: [
{ name: 'role', internalType: 'bytes32', type: 'bytes32', indexed: true },
{
name: 'previousOwner',
name: 'account',
internalType: 'address',
type: 'address',
indexed: true,
},
{
name: 'newOwner',
name: 'sender',
internalType: 'address',
type: 'address',
indexed: true,
},
],
name: 'OwnershipTransferred',
name: 'RoleRevoked',
},
{
type: 'error',
inputs: [{ name: 'target', internalType: 'address', type: 'address' }],
name: 'AddressEmptyCode',
type: 'event',
anonymous: false,
inputs: [
{
name: 'requiredTokenIn',
internalType: 'address',
type: 'address',
indexed: true,
},
{
name: 'suppliedAmountIn',
internalType: 'uint256',
type: 'uint256',
indexed: false,
},
{
name: 'requiredTokenOut',
internalType: 'address',
type: 'address',
indexed: true,
},
{
name: 'swapAmountOut',
internalType: 'uint256',
type: 'uint256',
indexed: false,
},
{
name: 'maxPreTip',
internalType: 'uint256',
type: 'uint256',
indexed: false,
},
{
name: 'maxPostTip',
internalType: 'uint256',
type: 'uint256',
indexed: false,
},
],
name: 'SwapAndTip',
},
{ type: 'error', inputs: [], name: 'AccessControlBadConfirmation' },
{
type: 'error',
inputs: [{ name: 'account', internalType: 'address', type: 'address' }],
name: 'AddressInsufficientBalance',
inputs: [
{ name: 'account', internalType: 'address', type: 'address' },
{ name: 'neededRole', internalType: 'bytes32', type: 'bytes32' },
],
name: 'AccessControlUnauthorizedAccount',
},
{ type: 'error', inputs: [], name: 'FailedInnerCall' },
{
type: 'error',
inputs: [{ name: 'owner', internalType: 'address', type: 'address' }],
name: 'OwnableInvalidOwner',
inputs: [{ name: 'target', internalType: 'address', type: 'address' }],
name: 'AddressEmptyCode',
},
{
type: 'error',
inputs: [{ name: 'account', internalType: 'address', type: 'address' }],
name: 'OwnableUnauthorizedAccount',
name: 'AddressInsufficientBalance',
},
{ type: 'error', inputs: [], name: 'FailedInnerCall' },
{
type: 'error',
inputs: [{ name: 'token', internalType: 'address', type: 'address' }],
Expand Down
2 changes: 1 addition & 1 deletion packages/daimo-contract/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const daimoPayAxelarBridgerAddress =
export const payIntentFactoryAddress =
"0x90498530e2FddcD937faB0Ab56cF6a7c1FB08b62";
export const daimoPayRelayerAddress =
"0xc46614d2E324Bfe5c0707D0b61d61d280FDcf65B";
"0xD238901E410A67e63ba8A55ed3A74BE5d2e2f161";

// Utils
export const daimoPayBatchReadUtilsAddress =
Expand Down

0 comments on commit 66f938a

Please sign in to comment.