Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sepolia testnet prod #5947

Merged
merged 4 commits into from
Mar 30, 2024
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
4 changes: 4 additions & 0 deletions packages/agents/sdk-wrapper/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Next Release

## v2.5.0-alpha.0

- Sepolia moved to testnet prod

## v2.3.0-alpha.2

- Mainnet support for mode
Expand Down
2 changes: 1 addition & 1 deletion packages/agents/sdk-wrapper/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@connext/sdk",
"version": "2.4.1",
"version": "2.5.0-alpha.0",
"description": "Client-side package for interacting with the Connext protocol",
"author": "Connext",
"license": "MIT",
Expand Down
35 changes: 25 additions & 10 deletions packages/agents/sdk-wrapper/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
///NXTP Config Generator based on vector/modules/router/src/config.ts
import { Type, Static } from "@sinclair/typebox";
import { ajv, ChainData, TAddress, TLogLevel } from "@connext/nxtp-utils";

import { ConnextContractDeployments, ContractPostfix } from "./txservice-types";

import { getChainData } from "./lib/helpers";

export const TAssetDescription = Type.Object({
Expand Down Expand Up @@ -121,7 +121,7 @@ export const getEnvConfig = (
chainConfig.deployments?.connext ??
(() => {
if (chainDataForChain) {
const res = deployments.connext(chainDataForChain.chainId, contractPostfix);
const res = deployments.connext(chainDataForChain.chainId, contractPostfix, nxtpConfig.network);
if (res) {
return res.address;
}
Expand Down Expand Up @@ -192,8 +192,16 @@ export const domainsToChainNames: Record<string, string> = {
"6450786": "bsc",
"6778479": "xdai",
"1818848877": "linea",
"1835365481": "metis",
"1650553709": "base",
"1836016741": "mode",
"1935897199": "scroll",
"1936027759": "sepolia",
"1869640549": "op-sepolia",
"1633842021": "arb-sepolia"
};

// Need to add more domains here.
export const XERC20REGISTRY_DOMAIN_ADDRESS: Record<string, string> = {
"6648936": "0xbf29a2d67efb6766e44c163b19c6f4118b164702",
"1869640809": "0x5543eafd20e25fbbbd66e2c154ff8ff8407e3a57",
Expand All @@ -202,12 +210,16 @@ export const XERC20REGISTRY_DOMAIN_ADDRESS: Record<string, string> = {
"6450786": "0x222af8c1411dc8b125338cf876547b03467bb3d1",
"6778479": "0x2056c11b071ae4cdd55007136c2493f3d4c1b678",
"1818848877": "0x11984dc4465481512eb5b777e44061c158cf2259",
"1735353714": "0x8aB29a37E7780F6230B4D951fcd69CA8f1014c55",
"1936027759": "",
"1735356532": "0xaB591adE0D0e08F117086c2b3159e50e2746AcA6",
"9991": "0xE4e98Bd63F134FFf3DD54BF29cCa024538D836f5",
"1835365481": "0xbe57a0A92C33dB065D8Db102e27805C1526e0E99", // metis
"1650553709": "0xcc1ce162fb1d70a377d1542873b1db57f5ff14d1", // base
"1836016741": "0x689cCB572262e0ca66146FE5Ed5D998543d3AA3B", // mode
"1935897199": "0x397aEEEDd44f40326f9eB583a1DFB8A7A673C40B", // scroll
"1936027759": "0x2a3fe9a49fb50536f1ed099192c2ae2404de7bb5", // sepolia
"1869640549": "0x18b5b08b10a2e351180f07e31f4fef94d14e28f6", // op-sepolia
"1633842021": "0x343d827d5109e8038bbb71e9ba4f3fd0d546b9ff" // arb-sepolia
};

// Need to add more domains here.
export const LOCKBOX_ADAPTER_DOMAIN_ADDRESS: Record<string, string> = {
"6648936": "0x45bf3c737e57b059a5855280ca1adb8e9606ac68",
"1869640809": "0x81dADc774d2ae44Eb30D2290d076Ae67F9800bd5",
Expand All @@ -216,8 +228,11 @@ export const LOCKBOX_ADAPTER_DOMAIN_ADDRESS: Record<string, string> = {
"6450786": "0xB71D06f2e73918386B75c24dD26c95DD938f7912",
"6778479": "0x3Cb55bFBB1f4973FCb9705Bab4aBb7E72BF85eAF",
"1818848877": "0x4895aa5d666c81a04ebcc7a9aa47f249b1c46aa6",
"1735353714": "0x8528d3B173a149CB0eae5e2d7335123bcF888c9f",
"1936027759": "",
"1735356532": "0x55fc076b9b0618a657f8986c83a97bd06e8a80f2",
"9991": "0xec531b272fa2b82efe49ef6d830c2d848753642a",
"1835365481": "0x5bB83e95f63217CDa6aE3D181BA580Ef377D2109", // metis
"1650553709": "0x542AaB88B14055e47222791276967Db5f9B840f6", // base
"1836016741": "0x981A06E33b228299f33a45a892d7AA61d0b95a83", // mode
"1935897199": "", // scroll (TODO)
"1936027759": "0xcF021fCFB9bd72E5aA7ab390cFA4fCfDF895c7Cf", // sepolia
"1869640549": "0x20b4789065DE09c71848b9A4FcAABB2c10006FA2", // op-sepolia
"1633842021": "0x0f4Fe4903d01E0deb067A7297453fBEFdC36D189" // arb-sepolia
};
24 changes: 21 additions & 3 deletions packages/agents/sdk-wrapper/src/txservice-types/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,44 @@ import { utils } from "ethers";
import { Connext as TConnext, ConnextAbi } from "../typechain-types";

export type ContractPostfix = "Staging" | "";
export type Network = "mainnet" | "testnet" | "local" | "devnet";

export type ConnextContractDeploymentGetter = (
chainId: number,
postfix?: ContractPostfix,
proxy?: boolean,
network?: Network,
) => { address: string; abi: any } | undefined;

export type SpokeConnectorDeploymentGetter = (
chainId: number,
prefix: string,
postfix?: ContractPostfix,
network?: Network,
) => { address: string; abi: any } | undefined;

export type HubConnectorDeploymentGetter = (
chainId: number,
prefix: string,
postfix?: ContractPostfix,
network?: Network,
) => { address: string; abi: any } | undefined;

export type MultisendContractDeploymentGetter = (chainId: number) => { address: string; abi: any } | undefined;
export type UnwrapperContractDeploymentGetter = (chainId: number) => { address: string; abi: any } | undefined;
export type RootManagerPropagateWrapperGetter = (
chainId: number,
postfix?: ContractPostfix,
network?: Network,
) => { address: string; abi: any } | undefined;

export type MultisendContractDeploymentGetter = (
chainId: number,
network?: Network,
) => { address: string; abi: any } | undefined;

export type UnwrapperContractDeploymentGetter = (
chainId: number,
postfix?: ContractPostfix,
network?: Network,
) => { address: string; abi: any } | undefined;

export type ConnextContractDeployments = {
connext: ConnextContractDeploymentGetter;
Expand All @@ -34,6 +51,7 @@ export type ConnextContractDeployments = {
hubConnector: HubConnectorDeploymentGetter;
multisend: MultisendContractDeploymentGetter;
unwrapper: UnwrapperContractDeploymentGetter;
rootManager: RootManagerPropagateWrapperGetter;
};

export const getConnextInterface = () => new utils.Interface(ConnextAbi) as TConnext["interface"];
Expand Down
170 changes: 8 additions & 162 deletions packages/agents/sdk-wrapper/test/sdkShared.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,13 @@ describe("#SDKShared", () => {
});

describe("#getProvider", async () => {
it("happy: should send request with correct params", async () => {
const expectedEndpoint = "/getProvider";
it("happy: should result in a provider", async () => {
const expectedArgs: SdkGetProviderParams = {
domainId: mock.domain.A,
};
const expectedRes = new providers.StaticJsonRpcProvider("http://localhost:8545");

axiosGetStub.resolves({
data: expectedRes,
status: 200,
});

const res = await sdkShared.getProvider(expectedArgs.domainId);

expect(axiosGetStub).to.have.been.calledWithExactly(
expectedBaseUri + expectedEndpoint + `/${expectedArgs.domainId}`,
);
expect(res).to.be.deep.eq(expectedRes);
expect(res).to.not.be.undefined;
});
});

Expand Down Expand Up @@ -155,8 +144,7 @@ describe("#SDKShared", () => {
});

describe("#getConnext", async () => {
it("happy: should send request with correct params", async () => {
const expectedEndpoint = "/getConnext";
it("happy: should result in a contract address", async () => {
const expectedArgs: SdkGetConnextParams = {
domainId: mock.domain.A,
options: {
Expand All @@ -166,54 +154,19 @@ describe("#SDKShared", () => {
};
const expectedRes = mkAddress("0x1234");

axiosPostStub.resolves({
axiosGetStub.resolves({
data: expectedRes,
status: 200,
});

const res = await sdkShared.getConnext(expectedArgs.domainId);

expect(axiosPostStub).to.have.been.calledWithExactly(expectedBaseUri + expectedEndpoint, expectedArgs);
expect(res).to.be.deep.eq(expectedRes);
});

it("happy: should send request with overridden options", async () => {
const expectedEndpoint = "/getConnext";
const expectedArgs: SdkGetConnextParams = {
domainId: mock.domain.A,
options: {
chains: mockConfig.chains,
signerAddress: mockConfig.signerAddress,
},
};
const options: Options = {
signerAddress: mkAddress("0xabc"),
chains: {
"999": {
providers: ["https://some-fake-provider.io"],
},
},
};
const expectedRes = mkAddress("0x1234");

axiosPostStub.resolves({
data: expectedRes,
status: 200,
});

const res = await sdkShared.getConnext(expectedArgs.domainId, options);

expect(axiosPostStub).to.have.been.calledWithExactly(expectedBaseUri + expectedEndpoint, {
...expectedArgs,
options: options,
});
expect(res).to.be.deep.eq(expectedRes);
expect(res).to.not.be.undefined;
});
});

describe("#getERC20", async () => {
it("happy: should send request with correct params", async () => {
const expectedEndpoint = "/getERC20";
it("happy: should result in a contract address", async () => {
const expectedArgs: SdkGetERC20Params = {
domainId: mock.domain.A,
tokenAddress: mock.asset.A.address,
Expand All @@ -224,49 +177,14 @@ describe("#SDKShared", () => {
};
const expectedRes = mkAddress("0x1234");

axiosPostStub.resolves({
axiosGetStub.resolves({
data: expectedRes,
status: 200,
});

const res = await sdkShared.getERC20(expectedArgs.domainId, expectedArgs.tokenAddress);

expect(axiosPostStub).to.have.been.calledWithExactly(expectedBaseUri + expectedEndpoint, expectedArgs);
expect(res).to.be.deep.eq(expectedRes);
});

it("happy: should send request with overridden options", async () => {
const expectedEndpoint = "/getERC20";
const expectedArgs: SdkGetERC20Params = {
domainId: mock.domain.A,
tokenAddress: mock.asset.A.address,
options: {
chains: mockConfig.chains,
signerAddress: mockConfig.signerAddress,
},
};
const options: Options = {
signerAddress: mkAddress("0xabc"),
chains: {
"999": {
providers: ["https://some-fake-provider.io"],
},
},
};
const expectedRes = mkAddress("0x1234");

axiosPostStub.resolves({
data: expectedRes,
status: 200,
});

const res = await sdkShared.getERC20(expectedArgs.domainId, expectedArgs.tokenAddress, options);

expect(axiosPostStub).to.have.been.calledWithExactly(expectedBaseUri + expectedEndpoint, {
...expectedArgs,
options: options,
});
expect(res).to.be.deep.eq(expectedRes);
expect(res).to.not.be.undefined;
});
});

Expand Down Expand Up @@ -323,78 +241,6 @@ describe("#SDKShared", () => {
});
});

describe("#approveIfNeeded", async () => {
it("happy: should send request with correct params", async () => {
const expectedEndpoint = "/approveIfNeeded";
const expectedArgs: SdkApproveIfNeededParams = {
domainId: mock.domain.A,
assetId: "1",
amount: "100",
infiniteApprove: true,
options: {
chains: mockConfig.chains,
signerAddress: mockConfig.signerAddress,
},
};

axiosPostStub.resolves({
data: mockGenericTxRequest,
status: 200,
});

const res = await sdkShared.approveIfNeeded(
expectedArgs.domainId,
expectedArgs.assetId,
expectedArgs.amount,
expectedArgs.infiniteApprove,
);

expect(axiosPostStub).to.have.been.calledWithExactly(expectedBaseUri + expectedEndpoint, expectedArgs);
expect(res).to.be.deep.eq(mockGenericTxRequest);
});

it("happy: should send request with overridden options", async () => {
const expectedEndpoint = "/approveIfNeeded";
const expectedArgs: SdkApproveIfNeededParams = {
domainId: mock.domain.A,
assetId: "1",
amount: "100",
infiniteApprove: true,
options: {
chains: mockConfig.chains,
signerAddress: mockConfig.signerAddress,
},
};
const options: Options = {
signerAddress: mkAddress("0xabc"),
chains: {
"999": {
providers: ["https://some-fake-provider.io"],
},
},
};

axiosPostStub.resolves({
data: mockGenericTxRequest,
status: 200,
});

const res = await sdkShared.approveIfNeeded(
expectedArgs.domainId,
expectedArgs.assetId,
expectedArgs.amount,
expectedArgs.infiniteApprove,
options,
);

expect(axiosPostStub).to.have.been.calledWithExactly(expectedBaseUri + expectedEndpoint, {
...expectedArgs,
options: options,
});
expect(res).to.be.deep.eq(mockGenericTxRequest);
});
});

describe("#getAssetsData", async () => {
it("happy: should send request with correct params", async () => {
const expectedEndpoint = "/getAssetsData";
Expand Down
4 changes: 4 additions & 0 deletions packages/agents/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Next Release

## v2.5.0-alpha.0

- Sepolia moved to testnet prod

## v2.3.0-alpha.2

- Mainnet support for mode
Expand Down
2 changes: 1 addition & 1 deletion packages/agents/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@connext/sdk-core",
"version": "2.4.1",
"version": "2.5.0-alpha.0",
"description": "Client-side package for interacting with the Connext protocol",
"author": "Connext",
"license": "MIT",
Expand Down
Loading
Loading