Skip to content

Commit

Permalink
Chains: Add Native Coin
Browse files Browse the repository at this point in the history
  • Loading branch information
imsk17 committed Apr 16, 2024
1 parent 6f8012c commit 93a423d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/chains/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,8 @@ export interface GetCoinPrice {

export interface ChainName {
chainName: () => string;
}

export interface NativeCoinName {
nativeCoin: () => string;
}
5 changes: 4 additions & 1 deletion src/chains/ton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
GetCoinPrice,
GetProvider,
GetTokenBalance,
NativeCoinName,
SendInstallment,
ValidateAddress,
} from ".";
Expand All @@ -35,7 +36,8 @@ export type TonHelper = GetBalance &
CalculateCoinFees &
CalculateDestinationTransactionFees &
GetCoinPrice &
ChainName;
ChainName &
NativeCoinName;

export interface TonParams {
client: TonClient;
Expand Down Expand Up @@ -183,6 +185,7 @@ export function tonHandler({
}

return {
nativeCoin: () => "TON",
chainName: () => chainName,
getCoinPrice:async (coin) => {
const pf = await oracleContract.getPriceFeed();
Expand Down
7 changes: 5 additions & 2 deletions src/chains/web3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
GetCoinPrice,
GetProvider,
GetTokenBalance,
NativeCoinName,
PreTransfer,
SendInstallment,
ValidateAddress,
Expand All @@ -33,24 +34,26 @@ export type Web3Helper = GetBalance &
PreTransfer<Signer, PayableOverrides> &
CalculateCoinFees &
CalculateDestinationTransactionFees & GetCoinPrice &
ChainName;
ChainName & NativeCoinName;

export interface Web3Params {
provider: Provider;
contract: string;
oracle: string;
chainName: string;
nativeCoin: string;
}

export function web3Helper({
provider,
contract,
oracle,
chainName
chainName,nativeCoin
}: Web3Params): Web3Helper {
const bridge = FTBridge__factory.connect(contract, provider);
const orac = IEmmetFeeOracle__factory.connect(oracle, provider);
return {
nativeCoin: () => nativeCoin,
chainName: () => chainName,
getCoinPrice: (c) => orac.getCoinPrice(c),
calculateCoinFees: (coinName, amt) => orac.calculateCoinFees(coinName, amt),
Expand Down
3 changes: 2 additions & 1 deletion src/factory/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export namespace ChainFactoryConfigs {
),
provider: new JsonRpcProvider(TestNetRpcUri.POLYGON),
oracle: ethers.getAddress("0x95DB799744A5b36D6E7BE9AD3b451dBC5b8De673"),
chainName: "polygon"
chainName: "polygon",
nativeCoin: "MATIC"
},
} satisfies Partial<ChainParams>;
}
Expand Down

0 comments on commit 93a423d

Please sign in to comment.