Skip to content

Commit e126a9e

Browse files
areakronosapiens
authored andcommitted
Changes following review
1 parent 5d51122 commit e126a9e

File tree

6 files changed

+29
-33
lines changed

6 files changed

+29
-33
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"assert": true,
1111
"contract": true
1212
},
13-
"settings" :{
13+
"settings": {
1414
"import/resolver": {
1515
"typescript": {
1616
"project" : "./tsconfig.json"

helpers/test-helper.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,24 @@ exports.deployCreateXIfNeeded = async function deployCreateXIfNeeded() {
13691369
}
13701370
};
13711371

1372+
exports.evmChainIdToWormholeChainId = function evmChainIdToWormholeChainId(_chainId) {
1373+
let chainId = _chainId;
1374+
if (typeof chainId === "string") {
1375+
if (chainId.startsWith("0x")) {
1376+
chainId = parseInt(chainId, 16);
1377+
} else {
1378+
chainId = parseInt(chainId, 10);
1379+
}
1380+
}
1381+
if (chainId === FORKED_XDAI_CHAINID) {
1382+
return 10003;
1383+
}
1384+
if (chainId === FORKED_XDAI_CHAINID + 1) {
1385+
return 10002;
1386+
}
1387+
throw new Error("Unsupported chainId");
1388+
};
1389+
13721390
class TestAdapter {
13731391
constructor() {
13741392
this.outputs = [];

packages/package-utils/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ exports.DiscordAdapter = require("./adapters/discord");
44
exports.SlackAdapter = require("./adapters/slack");
55
exports.ConsoleAdapter = require("./adapters/console");
66
exports.TruffleLoader = require("./TruffleLoader");
7-
exports.RetryProvider = require("./retryProvider");
7+
exports.RetryProvider = require("./RetryProvider");
88
exports.ExtendedNonceManager = require("./ExtendedNonceManager");

scripts/mockGuardianSpy.ts

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
SubscribeSignedVAARequest,
1313
SubscribeSignedVAAResponse,
1414
} from "../lib/wormhole/sdk/js-proto-node/src/spy/v1/spy";
15-
import { FORKED_XDAI_CHAINID } from "../helpers/constants";
15+
import { evmChainIdToWormholeChainId } from "../helpers/test-helper";
1616

1717
// Random key
1818

@@ -46,15 +46,15 @@ class MockGuardianSpy {
4646

4747
foreignWormholeBridgeForColony: ethers.Contract;
4848

49-
skipCount: number = 0;
49+
skipCount = 0;
5050

5151
queue: QueueEntry[] = [];
5252

5353
skipped: QueueEntry[] = [];
5454

55-
locked: boolean = false;
55+
locked = false;
5656

57-
bridgingPromiseCount: number = 0;
57+
bridgingPromiseCount = 0;
5858

5959
resolveBridgingPromise: (tx: ethers.Transaction) => void;
6060

@@ -204,14 +204,7 @@ class MockGuardianSpy {
204204
// So I've decreed that for chainId 256669100, we use 10003 (which is really arbitrum sepolia)
205205
// and for chainId 256669101, we use 10002 (which is really sepolia).
206206
// This isn't ideal, but it's the best solution I have for now
207-
let wormholeChainId;
208-
if (chainId === FORKED_XDAI_CHAINID) {
209-
wormholeChainId = 10003;
210-
} else if (chainId === FORKED_XDAI_CHAINID + 1) {
211-
wormholeChainId = 10002;
212-
} else {
213-
throw new Error("Unsupported chainId");
214-
}
207+
const wormholeChainId = evmChainIdToWormholeChainId(chainId);
215208

216209
if (this.skipCount > 0) {
217210
this.skipped.push([this.foreignWormholeBridgeForColony, sender, sequence, nonce, payload, consistencyLevel, wormholeChainId]);
@@ -228,14 +221,7 @@ class MockGuardianSpy {
228221
// So I've decreed that for chainId 256669100, we use 10003 (which is really arbitrum sepolia)
229222
// and for chainId 256669101, we use 10002 (which is really sepolia).
230223
// This isn't ideal, but it's the best solution I have for now
231-
let wormholeChainId;
232-
if (chainId === FORKED_XDAI_CHAINID) {
233-
wormholeChainId = 10003;
234-
} else if (chainId === FORKED_XDAI_CHAINID + 1) {
235-
wormholeChainId = 10002;
236-
} else {
237-
throw new Error("Unsupported chainId");
238-
}
224+
const wormholeChainId = evmChainIdToWormholeChainId(chainId);
239225

240226
if (this.skipCount > 0) {
241227
this.skipped.push([this.homeWormholeBridgeForColony, sender, sequence, nonce, payload, consistencyLevel, wormholeChainId]);

test/cross-chain/cross-chain.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const WormholeBridgeForColony = artifacts.require("WormholeBridgeForColony");
3434
const { setupBridging, deployBridge } = require("../../scripts/setup-bridging-contracts");
3535

3636
const { MINING_CYCLE_DURATION, CHALLENGE_RESPONSE_WINDOW_DURATION, ROOT_ROLE, CURR_VERSION, CREATEX_ADDRESS } = require("../../helpers/constants");
37-
const { forwardTime, checkErrorRevertEthers, revert, snapshot } = require("../../helpers/test-helper");
37+
const { forwardTime, checkErrorRevertEthers, revert, snapshot, evmChainIdToWormholeChainId } = require("../../helpers/test-helper");
3838
const ReputationMinerTestWrapper = require("../../packages/reputation-miner/test/ReputationMinerTestWrapper");
3939
const { TruffleLoader } = require("../../packages/package-utils");
4040

@@ -136,19 +136,11 @@ contract("Cross-chain", (accounts) => {
136136
// and for chainId 256669101, we use 10002 (which is really sepolia).
137137
// This isn't ideal, but it's the best solution I have for now
138138
homeChainId = await ethersHomeSigner.provider.send("eth_chainId", []);
139-
if (homeChainId === "0xfd5c9ec") {
140-
wormholeHomeChainId = 10003;
141-
} else {
142-
wormholeHomeChainId = 10002;
143-
}
139+
wormholeHomeChainId = evmChainIdToWormholeChainId(homeChainId);
144140

145141
// const foreignNetworkId = await ethersForeignSigner.provider.send("net_version", []);
146142
foreignChainId = await ethersForeignSigner.provider.send("eth_chainId", []);
147-
if (foreignChainId === "0xfd5c9ec") {
148-
wormholeForeignChainId = 10003;
149-
} else {
150-
wormholeForeignChainId = 10002;
151-
}
143+
wormholeForeignChainId = evmChainIdToWormholeChainId(foreignChainId);
152144

153145
// Deploy colonyNetwork to whichever chain truffle hasn't already deployed to.
154146
try {

0 commit comments

Comments
 (0)