Skip to content

Commit

Permalink
Add Wormholescan API mock
Browse files Browse the repository at this point in the history
  • Loading branch information
area committed Dec 16, 2024
1 parent 7a6f26f commit 4824a04
Show file tree
Hide file tree
Showing 18 changed files with 8,364 additions and 129 deletions.
5 changes: 5 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ step_compile_mock_spy: &step_compile_mock_spy
cd ./../.. && npx hardhat compile
cp ./packages/wormhole-relayer/config.example.js ./packages/wormhole-relayer/config.js
npx tsc
step_generate_wormhole_types: &step_generate_wormhole_types
run:
name: "Generate wormhole API types for mock endpoint"
command: sudo apt install default-jre && cd ./helpers/wormholescanMock && pnpm i && npm run generate-types

jobs:
build-checks:
Expand Down Expand Up @@ -342,6 +346,7 @@ jobs:
- <<: *step_setup_global_packages
- <<: *step_install_lsof
- <<: *step_compile_mock_spy
- <<: *step_generate_wormhole_types
- run:
name: "Installing the safe-contracts dependencies"
command: cd ./lib/safe-contracts && pnpm i --ignore-scripts
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ keys/*
lib/*
packages/**/node_modules
scripts/mockGuardianSpy.js
helpers/wormholescanMock/dist/*
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"error",
"ignorePackages",
{
"": "never",
"js": "never",
"jsx": "never",
"ts": "never",
Expand Down
8 changes: 8 additions & 0 deletions contracts/bridging/WormholeBridgeForColony.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { CallWithGuards } from "../common/CallWithGuards.sol";
import { DSAuth } from "../../lib/dappsys/auth.sol";

contract WormholeBridgeForColony is DSAuth, IColonyBridge, CallWithGuards {
event WormholeMessageReceived(uint16 emitterChainId, bytes32 emitterAddress, uint64 sequence);

address public colonyNetwork;
IWormhole public wormhole;

Expand Down Expand Up @@ -125,6 +127,12 @@ contract WormholeBridgeForColony is DSAuth, IColonyBridge, CallWithGuards {
if (!success) {
revert(abi.decode(returndata, (string)));
}

emit WormholeMessageReceived(
wormholeMessage.emitterChainId,
wormholeMessage.emitterAddress,
wormholeMessage.sequence
);
}

function sendMessage(
Expand Down
2 changes: 1 addition & 1 deletion contracts/testHelpers/WormholeMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ contract WormholeMock is IWormhole {
require(bridgeEnabled, "bridge-disabled");
cumulativeSequence += 1;

emit LogMessagePublished(msg.sender, sequence, nonce, payload, consistencyLevel);
emit LogMessagePublished(msg.sender, cumulativeSequence, nonce, payload, consistencyLevel);
return cumulativeSequence;
}

Expand Down
5 changes: 5 additions & 0 deletions helpers/wormholescanMock/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
wwwroot/*.js
node_modules
typings
dist
openapi-generated-types
5 changes: 5 additions & 0 deletions helpers/wormholescanMock/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"watch": ["src"],
"ext": "ts",
"exec": "concurrently 'npx tsc --watch' 'ts-node src/index.ts'"
}
14 changes: 14 additions & 0 deletions helpers/wormholescanMock/openapitools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "7.10.0",
"generators": {
"typescript-fetch": {
"generatorName": "typescript-fetch",
"inputSpec": "https://api.wormholescan.io/swagger.json",
"output": "#{cwd}/openapi-generated-types"
}
}
}
}
Loading

0 comments on commit 4824a04

Please sign in to comment.