Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
Start extracting WormholeGUID lib
Browse files Browse the repository at this point in the history
  • Loading branch information
krzkaczor committed Nov 12, 2021
1 parent 4bfeba3 commit a3c9129
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
11 changes: 11 additions & 0 deletions contracts/common/LibWormholeGUID.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pragma solidity >=0.7.6;

struct WormholeGUID {
bytes32 sourceDomain;
bytes32 targetDomain;
address receiver;
address operator;
uint128 amount;
uint64 nonce;
uint64 timestamp;
}
25 changes: 25 additions & 0 deletions contracts/l1/L1DAITokenWormholeBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,33 @@ contract L1DAIWormholeBridge is OVM_CrossDomainEnabled {
}

function finalizeFlush(bytes32 targetDomain, uint256 daiToFlush) external {
// can be called only by l2 counterpart
// settle on join
// update state root
// emit event
}

function prove(
WormholeGUID calldata guid,
uint256 maxFee,
L2MessageInclusionProof calldata proof
) external {
// Optimism State Inclusion Proof
require(
ovmStateCommitmentChain.insideFraudProofWindow(proof.stateRootBatchHeader) == false &&
ovmStateCommitmentChain.verifyStateCommitment(
proof.stateRoot,
proof.stateRootBatchHeader,
proof.stateRootProof
),
"WormholeOptimismStorageAuth/state-inclusion"
);
bytes32 hash = // Validate storage was set on L2 bridge
require(
verifyStorageProof(guid.getHash(), proof),
"WormholeOptimismStorageAuth/storage-inclusion"
);

join.mint(guid, msg.sender, maxFee);
}
}
10 changes: 0 additions & 10 deletions contracts/l2/L2DAIWormholeBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ interface IL1WormholeBridge {
function finalizeFlush(bytes32 targetDomain, uint256 daiToFlush) external;
}

struct WormholeGUID {
bytes32 sourceDomain;
bytes32 targetDomain;
address receiver;
address operator;
uint128 amount;
uint64 nonce;
uint64 timestamp;
}

// Mint tokens on L2 after locking funds on L1.
// Burn tokens on L1 and send a message to unlock tokens on L1 to L1 counterpart
// Note: when bridge is closed it will still process in progress messages
Expand Down

0 comments on commit a3c9129

Please sign in to comment.