Skip to content

Commit

Permalink
Merge pull request #5756 from connext/sequencer-handles-pseudocanonic…
Browse files Browse the repository at this point in the history
…al-domain

feat: sequencer can pass xerc20 assets into gelato conversion
  • Loading branch information
wanglonghong authored Feb 24, 2024
2 parents 7553ff7 + 4a9a535 commit 18c3c41
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/agents/sequencer/test/lib/helpers/relayerfee.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,15 @@ describe("Helpers:RelayerFee", () => {
const res = await canSubmitToRelayer(transfer);
expect(res).to.be.deep.eq({ canSubmit: false, needed: "8000000003203" });
});

it("should return true if asset is registered with the pseudo-canonical domain", async () => {
const transfer = mock.entity.xtransfer({
canonicalDomain: "11111",
relayerFees: { [constants.AddressZero]: "3", [localAsset]: "8" },
}) as OriginTransfer;
safeCalculateRelayerFeeStub.resolves(BigNumber.from("1000000000000"));
const res = await canSubmitToRelayer(transfer);
expect(res).to.be.deep.eq({ canSubmit: true, needed: "800000000000" });
});
});
});
6 changes: 6 additions & 0 deletions packages/utils/src/helpers/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,18 @@ const devnetChainIdToDomainMapping: Map<number, number> = new Map([
[31339, 31339],
]);

const specialChainIdToDomainMapping: Map<number, number> = new Map([
// special pseudo-canonical domain for xERC20s
[11111, 11111],
]);

// Hex domains calculated using `getHexDomainFromString`
// alternative: ethers.BigNumber.from(ethers.utils.toUtf8Bytes("some string")).toNumber()
export const chainIdToDomainMapping: Map<number, number> = new Map([
...mainnetChainIdToDomainMapping.entries(),
...testnetChainIdToDomainMapping.entries(),
...devnetChainIdToDomainMapping.entries(),
...specialChainIdToDomainMapping.entries(),
]);

/**
Expand Down

0 comments on commit 18c3c41

Please sign in to comment.