-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* omniTransfer for NEAR * Clean up types
- Loading branch information
Showing
5 changed files
with
201 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,35 @@ | ||
import type { Signer as SolWallet } from "@solana/web3.js" | ||
import { Wallet as EthWallet } from "ethers" | ||
import { Account as NearAccount } from "near-api-js" | ||
import type { ChainKind, Fee, OmniAddress, OmniTransfer, Status, TransferMessage } from "./types" | ||
import { NearDeployer } from "./deployer/near" | ||
import type { OmniTransferMessage, OmniTransferResult } from "./types" | ||
|
||
export class OmniClient { | ||
private wallet: EthWallet | NearAccount | SolWallet | ||
|
||
constructor(wallet: EthWallet | NearAccount | SolWallet) { | ||
this.wallet = wallet | ||
export async function omniTransfer( | ||
wallet: EthWallet | NearAccount | SolWallet, | ||
transfer: OmniTransferMessage, | ||
): Promise<OmniTransferResult> { | ||
if (wallet instanceof EthWallet) { | ||
throw new Error("Ethereum wallet not supported") | ||
} | ||
|
||
async omniTransfer(transferMessage: TransferMessage): Promise<OmniTransfer> { | ||
if (this.wallet instanceof EthWallet) { | ||
// TODO: Transfer ETH | ||
// Not implemented yet, return a placeholder | ||
return { | ||
txId: "0x123", | ||
nonce: BigInt(1), | ||
transferMessage, | ||
} | ||
} | ||
if (this.wallet instanceof NearAccount) { | ||
// TODO: Transfer NEAR | ||
// Not implemented yet, return a placeholder | ||
return { | ||
txId: "near_tx_hash", | ||
nonce: BigInt(1), | ||
transferMessage, | ||
} | ||
if (wallet instanceof NearAccount) { | ||
const deployer = new NearDeployer(wallet, "omni-locker.testnet") // TODO: Get from config | ||
const { nonce, hash } = await deployer.initTransfer( | ||
transfer.tokenAddress, | ||
transfer.recipient, | ||
transfer.amount, | ||
) | ||
return { | ||
txId: hash, | ||
nonce: BigInt(nonce), | ||
} | ||
|
||
// Handle other wallet types... | ||
throw new Error("Unsupported wallet type") | ||
} | ||
|
||
// biome-ignore lint/correctness/noUnusedVariables: This is a placeholder | ||
async findOmniTransfers(sender: OmniAddress): Promise<OmniTransfer[]> { | ||
// Query transfers from API | ||
// This would need to be implemented based on how transfers are stored | ||
throw new Error("Not implemented") | ||
if ("publicKey" in wallet) { | ||
// Solana wallet check | ||
// Solana transfer implementation | ||
throw new Error("Solana wallet not supported") | ||
} | ||
|
||
// biome-ignore lint/correctness/noUnusedVariables: This is a placeholder | ||
async getFee(sender: OmniAddress, recipient: OmniAddress): Promise<Fee> { | ||
// Query fee from API | ||
// This would need to be implemented based on how fees are determined | ||
throw new Error("Not implemented") | ||
} | ||
|
||
// biome-ignore lint/correctness/noUnusedVariables: This is a placeholder | ||
async getTransferStatus(originChain: ChainKind, nonce: bigint): Promise<Status> { | ||
// Query transfer status from API | ||
// This would need to be implemented based on how transfers are stored | ||
throw new Error("Not implemented") | ||
} | ||
throw new Error("Unsupported wallet type") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters