Skip to content

Commit

Permalink
pay contract: add pre and post calls. new dprelayer deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewliu08 committed Nov 4, 2024
1 parent db7213f commit fe746d7
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 100 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 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-options1"),
keccak256("DaimoPayRelayer-options2"),
abi.encodePacked(
type(DaimoPayRelayer).creationCode,
abi.encode(owner)
Expand Down
43 changes: 33 additions & 10 deletions packages/contract/src/pay/DaimoPayRelayer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,29 @@ contract DaimoPayRelayer is Ownable2Step {
Call[] calldata preCalls,
DaimoPay dp,
PayIntent calldata intent,
Call[] calldata calls,
bytes calldata bridgeExtraData
Call[] calldata startCalls,
bytes calldata bridgeExtraData,
Call[] calldata postCalls
) public payable onlyOwner {
// Make pre-start calls
for (uint256 i = 0; i < preCalls.length; ++i) {
Call calldata call = preCalls[i];
(bool success, ) = call.to.call{value: call.value}(call.data);
require(success, "DPR: preCall failed");
}
dp.startIntent(intent, calls, bridgeExtraData);

dp.startIntent({
intent: intent,
calls: startCalls,
bridgeExtraData: bridgeExtraData
});

// Make post-start calls
for (uint256 i = 0; i < postCalls.length; ++i) {
Call calldata call = postCalls[i];
(bool success, ) = call.to.call{value: call.value}(call.data);
require(success, "DPR: postCall failed");
}
}

function fastFinish(
Expand All @@ -148,18 +162,27 @@ contract DaimoPayRelayer is Ownable2Step {
}

function claimAndKeep(
Call calldata mintCall,
Call[] calldata preCalls,
DaimoPay dp,
PayIntent calldata intent,
Call[] calldata calls
Call[] calldata claimCalls,
Call[] calldata postCalls
) public onlyOwner {
if (mintCall.data.length > 0) {
(bool success, ) = mintCall.to.call{value: mintCall.value}(
mintCall.data
);
// Make pre-claim calls
for (uint256 i = 0; i < preCalls.length; ++i) {
Call calldata call = preCalls[i];
(bool success, ) = call.to.call{value: call.value}(call.data);
require(success, "DPR: preCall failed");
}

dp.claimIntent({intent: intent, calls: calls});
dp.claimIntent({intent: intent, calls: claimCalls});

// Make post-claim calls
for (uint256 i = 0; i < postCalls.length; ++i) {
Call calldata call = postCalls[i];
(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;
Expand Down
30 changes: 25 additions & 5 deletions packages/daimo-contract/src/codegen/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4604,9 +4604,9 @@ export const daimoPayRelayerAbi = [
type: 'function',
inputs: [
{
name: 'mintCall',
internalType: 'struct Call',
type: 'tuple',
name: 'preCalls',
internalType: 'struct Call[]',
type: 'tuple[]',
components: [
{ name: 'to', internalType: 'address', type: 'address' },
{ name: 'value', internalType: 'uint256', type: 'uint256' },
Expand Down Expand Up @@ -4662,7 +4662,17 @@ export const daimoPayRelayerAbi = [
],
},
{
name: 'calls',
name: 'claimCalls',
internalType: 'struct Call[]',
type: 'tuple[]',
components: [
{ name: 'to', internalType: 'address', type: 'address' },
{ name: 'value', internalType: 'uint256', type: 'uint256' },
{ name: 'data', internalType: 'bytes', type: 'bytes' },
],
},
{
name: 'postCalls',
internalType: 'struct Call[]',
type: 'tuple[]',
components: [
Expand Down Expand Up @@ -4834,7 +4844,7 @@ export const daimoPayRelayerAbi = [
],
},
{
name: 'calls',
name: 'startCalls',
internalType: 'struct Call[]',
type: 'tuple[]',
components: [
Expand All @@ -4844,6 +4854,16 @@ export const daimoPayRelayerAbi = [
],
},
{ name: 'bridgeExtraData', internalType: 'bytes', type: 'bytes' },
{
name: 'postCalls',
internalType: 'struct Call[]',
type: 'tuple[]',
components: [
{ name: 'to', internalType: 'address', type: 'address' },
{ name: 'value', internalType: 'uint256', type: 'uint256' },
{ name: 'data', internalType: 'bytes', type: 'bytes' },
],
},
],
name: 'startIntent',
outputs: [],
Expand Down
4 changes: 2 additions & 2 deletions packages/daimo-contract/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ export const daimoPayBridgerAddress =
"0x6b052F3A28eA1078c431FBface949559568ef960";
/** Daimo Pay Axelar bridger address */
export const daimoPayAxelarBridgerAddress =
"0xd0838A173e6a246928642Ed94b30Ae481Af545a3";
"0x32F372328ac108fDbf9009A9729f28699E1919f3";
/** Daimo Pay intent factory address */
export const payIntentFactoryAddress =
"0xF46F51c7855bDa3bFB48161fcAf40484923BeCee";
/** Daimo Pay relayer address */
export const daimoPayRelayerAddress =
"0x5a648289c56DBF5b3A1F5af838261Bda6e9D0375";
"0x9f85421578bd7bd6eC5684cbABB4C77B90575F05";

// DAv2
export const entryPointV07Address =
Expand Down

0 comments on commit fe746d7

Please sign in to comment.