Skip to content

Commit

Permalink
Add Noble native token support (#931)
Browse files Browse the repository at this point in the history
* Add Noble native token support

* PR Feedback

* same ntt manager for mainnet for Noble
  • Loading branch information
valentinoConti authored Jan 31, 2025
1 parent 539581f commit 39dae9e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/pages/Tx/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,8 @@ const Tx = () => {

if (nttInfo?.targetTokenAddress) {
data.content.standarizedProperties.wrappedTokenAddress = nttInfo.targetTokenAddress;
data.content.standarizedProperties.wrappedTokenSymbol = targetTokenInfo.symbol;
data.content.standarizedProperties.wrappedTokenSymbol =
nttInfo.targetTokenSymbol || targetTokenInfo.symbol;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const parseAddress = ({
.map(a => toChainId(a))
.includes(chainId)
) {
let raw = encoding.bech32.decodeToBytes(value);
const raw = encoding.bech32.decodeToBytes(value);
if (raw.bytes.slice(0, 12).every(item => item === 0)) {
parsedValue = encoding.bech32.encodeFromBytes(raw.prefix, raw.bytes.slice(12));
}
Expand Down
37 changes: 31 additions & 6 deletions src/utils/wh-ntt-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,40 @@ import { ethers } from "ethers";
import { Environment, getChainInfo, getEthersProvider } from "./environment";
import { GetOperationsOutput } from "src/api/guardian-network/types";

// SOLANA MANAGER <--> TOKEN
// MANAGER <--> TOKEN
const NTT_MANAGER_TOKENS = {
Mainnet: {
// SOLANA MANAGERS
// W
NTtAaoDJhkeHeaVUHnyhwbPNAN6WgBpHkHBTc6d7vLK: "85VBFQZC9TZkfaptBWjvUw7YbZjy52A6mjtPGjstQAmQ",
NTtAaoDJhkeHeaVUHnyhwbPNAN6WgBpHkHBTc6d7vLK: {
tokenAddress: "85VBFQZC9TZkfaptBWjvUw7YbZjy52A6mjtPGjstQAmQ",
symbol: "", // same as source
},
// BORG
NttBm3HouTCFnUBz32fEs5joQFRjFoJPA8AyhtgjFrw: "3dQTr7ror2QPKQ3GbBCokJUmjErGg8kTJzdnYjNfvi3Z",
NttBm3HouTCFnUBz32fEs5joQFRjFoJPA8AyhtgjFrw: {
tokenAddress: "3dQTr7ror2QPKQ3GbBCokJUmjErGg8kTJzdnYjNfvi3Z",
symbol: "", // same as source
},

// NOBLE MANAGERS
noble1qqqqqqqqqqqqqqqqqqqzapv4q6az98qc87yct420uussjglmn09qvcl7xx: {
tokenAddress: "uusdn",
symbol: "USDN",
},
},
Testnet: {
// SOLANA MANAGERS
// W
NTtAaoDJhkeHeaVUHnyhwbPNAN6WgBpHkHBTc6d7vLK: "EetppHswYvV1jjRWoQKC1hejdeBDHR9NNzNtCyRQfrrQ",
NTtAaoDJhkeHeaVUHnyhwbPNAN6WgBpHkHBTc6d7vLK: {
tokenAddress: "EetppHswYvV1jjRWoQKC1hejdeBDHR9NNzNtCyRQfrrQ",
symbol: "", // same as source
},

// NOBLE MANAGERS
noble1qqqqqqqqqqqqqqqqqqqzapv4q6az98qc87yct420uussjglmn09qvcl7xx: {
tokenAddress: "uusdn",
symbol: "USDN",
},
},
} as any;

Expand All @@ -26,11 +49,12 @@ export async function getNttInfo(env: Environment, data: GetOperationsOutput, pa

if (NTT_MANAGER_TOKENS[env.network]?.[contractAddress]) {
return {
targetTokenAddress: NTT_MANAGER_TOKENS[env.network][contractAddress],
targetTokenAddress: NTT_MANAGER_TOKENS[env.network][contractAddress].tokenAddress,
targetTokenSymbol: NTT_MANAGER_TOKENS[env.network][contractAddress].symbol,
};
}

console.log("ntt token not found in solana list managers list");
console.log("ntt token not found in managers list, trying rpc");

if (targetChain !== chainToChainId("Solana")) {
const contractProvider = getEthersProvider(getChainInfo(env, targetChain as ChainId));
Expand All @@ -41,6 +65,7 @@ export async function getNttInfo(env: Environment, data: GetOperationsOutput, pa

return {
targetTokenAddress,
targetTokenSymbol: null,
};
}

Expand Down
6 changes: 6 additions & 0 deletions src/utils/wormhole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,12 @@ const WORMHOLE_CHAINS: any = {
},
getExplorerBaseURL: function ({ network = "Mainnet", value, base }: ExplorerBaseURLInput) {
if (base === "address") return this.explorer?.[network] + "/address/" + value;
if (base === "token") {
if (value.length <= 5) {
return this.explorer?.[network] + "/assets/native/" + btoa(value);
}
return this.explorer?.[network] + "/assets/ibc/" + btoa(value.replace("ibc/", ""));
}
if (base === "block") return this.explorer?.[network] + "/block/" + value;
return this.explorer?.[network] + "/tx/" + value;
},
Expand Down

0 comments on commit 39dae9e

Please sign in to comment.