Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion evm/src/NttManager/NttManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract NttManager is INttManager, RateLimiter, ManagerBase {
using TrimmedAmountLib for uint256;
using TrimmedAmountLib for TrimmedAmount;

string public constant NTT_MANAGER_VERSION = "1.3.1";
string public constant NTT_MANAGER_VERSION = "2.0.0";

// =============== Setup =================================================================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import "./WormholeTransceiverState.sol";
contract WormholeTransceiver is IWormholeTransceiver, WormholeTransceiverState {
using BytesParsing for bytes;

string public constant WORMHOLE_TRANSCEIVER_VERSION = "1.4.0";
string public constant WORMHOLE_TRANSCEIVER_VERSION = "2.0.0";

constructor(
address nttManager,
Expand Down
28 changes: 26 additions & 2 deletions evm/ts/__tests__/versions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,26 @@ import { Wormhole } from "@wormhole-foundation/sdk";
import { EvmPlatform } from "@wormhole-foundation/sdk-evm";
import { EvmNtt } from "../src/index.js";

const wh = new Wormhole("Testnet", [EvmPlatform]);
const fallbackRpc = "https://sepolia.drpc.org";

// Try default SDK RPC first, fallback to drpc if it fails
async function getWormholeInstance() {
const wh = new Wormhole("Testnet", [EvmPlatform]);
try {
const ctx = wh.getChain("Sepolia");
const rpc = await ctx.getRpc();
await rpc.getBlockNumber();
return wh;
} catch {
return new Wormhole("Testnet", [EvmPlatform], {
chains: {
Sepolia: {
rpc: fallbackRpc,
},
},
});
}
}

const overrides = {
Sepolia: {
Expand All @@ -15,8 +34,9 @@ const overrides = {
};

describe("ABI Versions Test", function () {
const ctx = wh.getChain("Sepolia");
test("It initializes from Rpc", async function () {
const wh = await getWormholeInstance();
const ctx = wh.getChain("Sepolia");
const ntt = await EvmNtt.fromRpc(await ctx.getRpc(), {
Sepolia: {
...ctx.config,
Expand All @@ -27,6 +47,8 @@ describe("ABI Versions Test", function () {
});

test("It initializes from constructor", async function () {
const wh = await getWormholeInstance();
const ctx = wh.getChain("Sepolia");
const ntt = new EvmNtt("Testnet", "Sepolia", await ctx.getRpc(), {
...ctx.config.contracts,
...{ ntt: overrides["Sepolia"] },
Expand All @@ -35,6 +57,8 @@ describe("ABI Versions Test", function () {
});

test("It gets the correct version", async function () {
const wh = await getWormholeInstance();
const ctx = wh.getChain("Sepolia");
const version = await EvmNtt.getVersion(await ctx.getRpc(), {
ntt: overrides["Sepolia"],
});
Expand Down
15 changes: 9 additions & 6 deletions evm/ts/src/bindings.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import { Provider } from "ethers";

import { _0_1_0, _1_0_0, _1_1_0 } from "./ethers-contracts/index.js";
import { _0_1_0, _1_0_0, _1_1_0, _2_0_0 } from "./ethers-contracts/index.js";
import { Ntt } from "@wormhole-foundation/sdk-definitions-ntt";

// This is a descending list of all ABI versions the SDK is aware of.
// We check for the first match in descending order, allowing for higher minor and patch versions
// being used by the live contract (these are supposed to still be compatible with older ABIs).
export const abiVersions = [
["2.0.0", _2_0_0],
["1.1.0", _1_1_0],
["1.0.0", _1_0_0],
["0.1.0", _0_1_0],
] as const;
export type AbiVersion = (typeof abiVersions)[number][0];

type AbiBindings = (typeof abiVersions)[number][1];

export interface NttBindings {
NttManager: NttManagerBindings;
NttTransceiver: NttTransceiverBindings;
}

export namespace NttTransceiverBindings {
// Note: this is hardcoded to 0.1.0 so we should be warned if there are changes
// that would affect the interface
export type NttTransceiver = ReturnType<typeof _0_1_0.NttTransceiver.connect>;
export type NttTransceiver = ReturnType<
AbiBindings["NttTransceiver"]["connect"]
>;
}

export interface NttTransceiverBindings {
Expand All @@ -32,14 +35,14 @@ export interface NttTransceiverBindings {
}

export namespace NttManagerBindings {
export type NttManager = ReturnType<typeof _0_1_0.NttManager.connect>;
export type NttManager = ReturnType<AbiBindings["NttManager"]["connect"]>;
}

export interface NttManagerBindings {
connect(address: string, provider: Provider): NttManagerBindings.NttManager;
}

export function loadAbiVersion(targetVersion: string) {
export function loadAbiVersion(targetVersion: string): NttBindings {
for (const [abiVersion, abi] of abiVersions) {
if (Ntt.abiVersionMatches(targetVersion, abiVersion)) {
return abi;
Expand Down
Loading
Loading