Skip to content

Commit

Permalink
Support sepolia<>pangoro-tanssi eth
Browse files Browse the repository at this point in the history
  • Loading branch information
JayJay1024 committed Apr 30, 2024
1 parent 6d5045a commit 35920cc
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 5 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions packages/xtoken-ui/src/bridges/xtoken-next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ export class XTokenNextBridge extends BaseBridge {
) {
backing = "0x2B496f19A420C02490dB859fefeCCD71eDc2c046";
issuing = "0xDc0C760c0fB4672D06088515F6446a71Df0c64C1";
} else if (
(this.sourceChain?.network === "pangoro-dvm" && this.targetChain?.network === "sepolia") ||
(this.sourceChain?.network === "sepolia" && this.targetChain?.network === "pangoro-dvm")
) {
backing = "0xcCD7B9cA36CC65AfCA2bB06EF9df73980F8E2eC4";
issuing = "0xA22BfbAD733772e7e6a9402faa0fbE0e4db06aDE";
}
this.initContractByBackingIssuing(backing, issuing);
}
Expand Down Expand Up @@ -87,6 +93,10 @@ export class XTokenNextBridge extends BaseBridge {
const source = this.sourceToken?.type === "native" ? "0x004D0dE211BC148c3Ce696C51Cbc85BD421727E9" : undefined;
const target = this.targetToken?.type === "native" ? "0xA8d0E9a45249Ec839C397fa0F371f5F64eCAB7F7" : undefined;
this.convertor = { source, target };
} else if (this.sourceChain?.network === "sepolia" && this.targetChain?.network === "pangoro-dvm") {
this.convertor = { source: "0x510A820E41BB6d828a29332dB551B6B3cf7232D3", target: undefined };
} else if (this.sourceChain?.network === "pangoro-dvm" && this.targetChain?.network === "sepolia") {
this.convertor = { source: undefined, target: "0x510A820E41BB6d828a29332dB551B6B3cf7232D3" };
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/xtoken-ui/src/config/chains/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export * from "./scroll";
export * from "./zksync";
export * from "./zksync-sepolia";
export * from "./gnosis";
export * from "./pangoro";
72 changes: 72 additions & 0 deletions packages/xtoken-ui/src/config/chains/pangoro.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { ChainConfig, ChainID } from "@/types/chain";

export const pangoroChain: ChainConfig = {
/**
* Chain
*/
id: ChainID.PANGORO_TANSSI,
network: "pangoro-dvm",
name: "Pangoro Tanssi",
nativeCurrency: {
name: "ORING",
symbol: "ORING",
decimals: 18,
},
rpcUrls: {
default: {
http: ["https://fraa-flashbox-2871-rpc.a.stagenet.tanssi.network"],
webSocket: [],
},
public: {
http: ["https://fraa-flashbox-2871-rpc.a.stagenet.tanssi.network"],
webSocket: [],
},
},
blockExplorers: {
default: {
name: "EvmExplorer",
url: "https://evmexplorer.tanssi-chains.network/",
},
},
testnet: true,

/**
* Custom
*/
logo: "pangoro.png",
tokens: [
{
decimals: 18,
symbol: "ORING",
name: "ORING",
type: "native",
address: "0x0000000000000000000000000000000000000000",
outer: "0x0000000000000000000000000000000000000000",
inner: "0x617E55f692FA2feFfdD5D9C513782A479cC1FF57", // TODO
logo: "ring.png",
cross: [],
category: "ring",
},
{
decimals: 18,
symbol: "xETH",
name: "xETH",
type: "erc20",
address: "0x191121eC17587C3cE0BF689AFA36386F8D9C538F",
outer: "0x191121eC17587C3cE0BF689AFA36386F8D9C538F",
inner: "0x191121eC17587C3cE0BF689AFA36386F8D9C538F",
logo: "eth.png",
cross: [
{
target: { network: "sepolia", symbol: "ETH" },
bridge: { category: "xtoken-pangoro-sepolia" },
action: "redeem",
},
],
category: "eth",
},
],
messager: {
msgline: "0x093652d52464B6E00d6D95abB7Dc16b4546D83Ca",
},
};
12 changes: 9 additions & 3 deletions packages/xtoken-ui/src/config/chains/sepolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ export const sepoliaChain: ChainConfig = {
type: "native",
address: "0x0000000000000000000000000000000000000000",
outer: "0x0000000000000000000000000000000000000000",
inner: "0x0000000000000000000000000000000000000000",
inner: "0xfB025B0e2FadF33C644fCe3f5409c0cD4a3045dE",
logo: "eth.png",
cross: [],
cross: [
{
target: { network: "pangoro-dvm", symbol: "xETH" },
bridge: { category: "xtoken-sepolia-pangoro" },
action: "issue",
},
],
category: "eth",
},
{
Expand All @@ -56,6 +62,6 @@ export const sepoliaChain: ChainConfig = {
},
],
messager: {
msgline: "0xf7F461728DC89de5EF6615715678b5f5b12bb98A",
msgline: "0x2f868b52407b6886214Eb21dF6456c0b308Cc4ce",
},
};
4 changes: 3 additions & 1 deletion packages/xtoken-ui/src/types/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export type XTokenBridgeCategory =
| "xtoken-darwinia-ethereum"
| "xtoken-ethereum-darwinia"
| "xtoken-pangolin-sepolia"
| "xtoken-sepolia-pangolin";
| "xtoken-sepolia-pangolin"
| "xtoken-pangoro-sepolia"
| "xtoken-sepolia-pangoro";
export type BridgeCategory =
| L2BridgeCategory
| HelixLpBridgeCategory
Expand Down
2 changes: 2 additions & 0 deletions packages/xtoken-ui/src/types/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export enum ChainID {
DARWINIA = 46,
CRAB = 44,
PANGOLIN = 43,
PANGORO_TANSSI = 45,

ETHEREUM = 1,
SEPOLIA = 11155111,
Expand Down Expand Up @@ -32,6 +33,7 @@ export type Network =
| "darwinia-dvm"
| "crab-dvm"
| "pangolin-dvm"
| "pangoro-dvm"
| "ethereum"
| "sepolia"
| "arbitrum"
Expand Down
2 changes: 2 additions & 0 deletions packages/xtoken-ui/src/types/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type TokenSymbol =
| "USDT"
| "PRING"
| "ORING"
| "ORING"
| "CRAB"
| "KTON"
| "WRING"
Expand All @@ -18,6 +19,7 @@ export type TokenSymbol =
| "xRING"
| "xWCRAB"
| "xPRING"
| "xETH"
| "MNT"
| "MATIC"
| "BNB"
Expand Down
5 changes: 5 additions & 0 deletions packages/xtoken-ui/src/utils/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
lineaChain,
mantleChain,
pangolinChain,
pangoroChain,
polygonChain,
polygonZkEvmChain,
scrollChain,
Expand Down Expand Up @@ -77,6 +78,9 @@ export function getChainConfig(chainIdOrNetwork?: ChainID | Network | null): Cha
case ChainID.SEPOLIA:
case "sepolia":
return sepoliaChain;
case ChainID.PANGORO_TANSSI:
case "pangoro-dvm":
return pangoroChain;
default:
return;
}
Expand All @@ -102,6 +106,7 @@ export function getChainConfigs(askAll?: boolean) {
bscChain,
optimismChain,
gnosisChain,
pangoroChain,
].sort((a, b) => a.name.localeCompare(b.name));

if (askAll) {
Expand Down
4 changes: 3 additions & 1 deletion packages/xtoken-ui/src/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ export async function fetchMsglineFeeAndParams(
sender: Address,
payload: Hex,
) {
// const endpoint = 'https://msgport-api.darwinia.network/ormp/fee'
const endpoint = "http://g2.generic.darwinia.network:3378/ormp/fee";
const feeData = await fetch(
`https://msgport-api.darwinia.network/ormp/fee?from_chain_id=${fromChainId}&to_chain_id=${toChainId}&payload=${payload}&from_address=${fromMessager}&to_address=${toMessager}&refund_address=${sender}`,
`${endpoint}?from_chain_id=${fromChainId}&to_chain_id=${toChainId}&payload=${payload}&from_address=${fromMessager}&to_address=${toMessager}&refund_address=${sender}`,
);
const feeJson = await feeData.json();
if (feeData.ok && feeJson.code === 0) {
Expand Down

0 comments on commit 35920cc

Please sign in to comment.