Skip to content

Commit

Permalink
fix op request wsteth plugin test
Browse files Browse the repository at this point in the history
  • Loading branch information
luketchang committed Sep 14, 2023
1 parent 64f15ce commit cb943b0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
8 changes: 4 additions & 4 deletions packages/op-request-plugins/src/WstethAdapterPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
} from "@nocturne-xyz/core";
import { WstethAdapter__factory } from "@nocturne-xyz/contracts";

const WETH_NAME = "weth";
const WSTETH_NAME = "wsteth";
const WSTETH_ADAPTER_NAME = "wstethAdapter";

export interface WstethAdapterPluginMethods {
Expand Down Expand Up @@ -47,16 +49,14 @@ export function WstethAdapterPlugin<EInner extends BaseOpRequestBuilder>(
);
}

const wethAddress =
this.config.erc20s.get(WSTETH_ADAPTER_NAME)?.address;
const wethAddress = this.config.erc20s.get(WETH_NAME)?.address;
if (!wethAddress) {
throw new Error(
`Weth not supported on chain with id: ${this._op.chainId}`
);
}

const wstethAddress =
this.config.erc20s.get(WSTETH_ADAPTER_NAME)?.address;
const wstethAddress = this.config.erc20s.get(WSTETH_NAME)?.address;
if (!wstethAddress) {
throw new Error(
`Wsteth not supported on chain with id: ${this._op.chainId}`
Expand Down
32 changes: 28 additions & 4 deletions packages/op-request-plugins/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { loadNocturneConfigBuiltin } from "@nocturne-xyz/config";
import {
NocturneConfig,
loadNocturneConfigBuiltin,
} from "@nocturne-xyz/config";
import { Asset, AssetTrait } from "@nocturne-xyz/core";
import { AssetType } from "@nocturne-xyz/core/src";
import { ethers } from "ethers";

export const DUMMY_CONFIG = loadNocturneConfigBuiltin("example-network");

export const WETH_ADDRESS = ethers.utils.getAddress(
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
);
export const WSTETH_ADAPTER_ADDRESS = ethers.utils.getAddress(
"0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
); // TODO: fill with real address
);
export const WSTETH_ADDRESS = ethers.utils.getAddress(
"0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
);
Expand All @@ -27,3 +28,26 @@ export const shitcoin: Asset = {
id: 0n,
};
export const encodedShitcoin = AssetTrait.encode(shitcoin);

const config = loadNocturneConfigBuiltin("example-network");
config.erc20s.set("weth", {
address: WETH_ADDRESS,
globalCapWholeTokens: 100_000_000n,
maxDepositSizeWholeTokens: 100_000_000n,
resetWindowHours: 24n,
precision: 18n,
isGasAsset: true,
});
config.erc20s.set("wsteth", {
address: WSTETH_ADDRESS,
globalCapWholeTokens: 100_000_000n,
maxDepositSizeWholeTokens: 100_000_000n,
resetWindowHours: 24n,
precision: 18n,
isGasAsset: false,
});
config.protocolAllowlist.set("wstethAdapter", {
address: WSTETH_ADAPTER_ADDRESS,
functionSignatures: ["convert(uint256)"],
});
export const DUMMY_CONFIG: NocturneConfig = config;

0 comments on commit cb943b0

Please sign in to comment.