Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
r-near committed Dec 16, 2024
1 parent 1f264c2 commit ce4786a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { ethers } from "ethers"
import type { Account } from "near-api-js"
import { EthereumDeployer } from "./chains/ethereum"
import { NearDeployer } from "./chains/near"
import type { ChainDeployer } from "./types"
import { ChainKind } from "./types"

/**
Expand All @@ -19,7 +18,7 @@ import { ChainKind } from "./types"
* const txHash = await deployer.initDeployToken("near:token.near");
* ```
*/
export function getDeployer<TWallet>(chain: ChainKind, wallet: TWallet): ChainDeployer<TWallet> {
export function getDeployer<TWallet>(chain: ChainKind, wallet: TWallet) {
switch (chain) {
case ChainKind.Near:
return new NearDeployer(wallet as Account)
Expand Down
12 changes: 6 additions & 6 deletions tests/chains/near.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ describe("NearDeployer", () => {
})
})

describe("initDeployToken", () => {
describe("logMetadata", () => {
it("should throw error if token address is not on NEAR", async () => {
await expect(deployer.initDeployToken("eth:0x123")).rejects.toThrow(
await expect(deployer.logMetadata("eth:0x123")).rejects.toThrow(
"Token address must be on NEAR",
)
})

it("should call log_metadata with correct arguments", async () => {
const tokenAddress = "near:test-token.near"
const txHash = await deployer.initDeployToken(tokenAddress)
const txHash = await deployer.logMetadata(tokenAddress)

expect(mockWallet.functionCall).toHaveBeenCalledWith({
contractId: mockLockerAddress,
Expand All @@ -74,12 +74,12 @@ describe("NearDeployer", () => {
})
})

describe("finDeployToken", () => {
describe("deployToken", () => {
it("should call deploy_token with correct arguments", async () => {
const destinationChain = ChainKind.Eth
const mockVaa = "mock-vaa"

const txHash = await deployer.finDeployToken(destinationChain, mockVaa)
const txHash = await deployer.deployToken(destinationChain, mockVaa)

expect(mockWallet.functionCall).toHaveBeenCalledWith({
contractId: mockLockerAddress,
Expand Down Expand Up @@ -118,7 +118,7 @@ describe("NearDeployer", () => {
const error = new Error("NEAR error")
mockWallet.functionCall = vi.fn().mockRejectedValue(error)

await expect(deployer.initDeployToken("near:test-token.near")).rejects.toThrow("NEAR error")
await expect(deployer.logMetadata("near:test-token.near")).rejects.toThrow("NEAR error")
})
})
})

0 comments on commit ce4786a

Please sign in to comment.