Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "remove injective support from advanced tools" #1169

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/docs/faqs/liquid-markets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import EthAptos from './_liquid-markets/eth-aptos.md'
import EthAlgorand from './_liquid-markets/eth-algorand.md'
import SolAlgorand from './_liquid-markets/sol-algorand.md'
import AvaxAlgorand from './_liquid-markets/avax-algorand.md'
import SolInjective from './_liquid-markets/sol-injective.md'
import EthInjective from './_liquid-markets/eth-injective.md'
import EthSui from './_liquid-markets/eth-sui.md'
import SolSui from './_liquid-markets/sol-sui.md'
import AptosOsmosis from './_liquid-markets/aptos-osmosis.md'
Expand Down Expand Up @@ -199,6 +201,17 @@ Check out the [Wormhole Token list](https://github.com/certusone/wormhole-token-
</TabItem>
</Tabs>

## Target chain: Injective

<Tabs>
<TabItem value="SOL -> INJECTIVE" label="SOL -> INJECTIVE" default>
<SolInjective />
</TabItem>
<TabItem value="ETH -> INJECTIVE" label="ETH -> INJECTIVE" >
<EthInjective />
</TabItem>
</Tabs>

## Target chain: Sui

<Tabs>
Expand Down
4 changes: 4 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"@certusone/wormhole-sdk": "^0.10.17",
"@cosmjs/cosmwasm-stargate": "^0.32.3",
"@cosmjs/tendermint-rpc": "^0.32.3",
"@injectivelabs/networks": "^1.14.4",
"@injectivelabs/sdk-ts": "^1.14.4",
"@injectivelabs/ts-types": "^1.14.4",
"@injectivelabs/wallet-ts": "^1.14.4",
"@manahippo/aptos-wallet-adapter": "^1.0.2",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.11.2",
Expand Down
2 changes: 2 additions & 0 deletions src/components/KeyAndBalance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
ChainId,
CHAIN_ID_ALGORAND,
CHAIN_ID_APTOS,
CHAIN_ID_INJECTIVE,
CHAIN_ID_NEAR,
CHAIN_ID_SOLANA,
CHAIN_ID_XPLA,
Expand All @@ -21,6 +22,7 @@ function isChainAllowed(chainId: ChainId) {
chainId === CHAIN_ID_NEAR ||
chainId === CHAIN_ID_XPLA ||
chainId === CHAIN_ID_APTOS ||
chainId === CHAIN_ID_INJECTIVE ||
chainId === CHAIN_ID_SUI ||
chainId === CHAIN_ID_SEI
);
Expand Down
66 changes: 65 additions & 1 deletion src/components/Recovery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CHAIN_ID_ACALA,
CHAIN_ID_ALGORAND,
CHAIN_ID_APTOS,
CHAIN_ID_INJECTIVE,
CHAIN_ID_KARURA,
CHAIN_ID_NEAR,
CHAIN_ID_SOLANA,
Expand All @@ -11,6 +12,7 @@ import {
CHAIN_ID_SEI,
getEmitterAddressAlgorand,
getEmitterAddressEth,
getEmitterAddressInjective,
getEmitterAddressSolana,
getEmitterAddressTerra,
getEmitterAddressXpla,
Expand All @@ -23,12 +25,14 @@ import {
parseNFTPayload,
parseSequenceFromLogAlgorand,
parseSequenceFromLogEth,
parseSequenceFromLogInjective,
parseSequenceFromLogSolana,
parseSequenceFromLogTerra,
parseSequenceFromLogXpla,
parseTransferPayload,
parseVaa,
queryExternalId,
queryExternalIdInjective,
TerraChainId,
uint8ArrayToHex,
CHAIN_ID_SUI,
Expand Down Expand Up @@ -111,6 +115,10 @@ import {
getEmitterAddressAndSequenceFromResult,
} from "../utils/aptos";
import { Types } from "aptos";
import {
getInjectiveTxClient,
getInjectiveWasmClient,
} from "../utils/injective";
import { getSuiProvider } from "../utils/sui";
import {
getEmitterAddressAndSequenceFromResponseSui,
Expand Down Expand Up @@ -377,6 +385,26 @@ async function xpla(tx: string, enqueueSnackbar: any) {
}
}

async function injective(txHash: string, enqueueSnackbar: any) {
try {
const client = getInjectiveTxClient();
const tx = await client.fetchTx(txHash);
if (!tx) {
throw new Error("Unable to fetch transaction");
}
const sequence = parseSequenceFromLogInjective(tx);
if (!sequence) {
throw new Error("Sequence not found");
}
const emitterAddress = await getEmitterAddressInjective(
getTokenBridgeAddressForChain(CHAIN_ID_INJECTIVE)
);
return await fetchSignedVAA(CHAIN_ID_INJECTIVE, emitterAddress, sequence);
} catch (e) {
return handleError(e, enqueueSnackbar);
}
}

async function sui(digest: string, enqueueSnackbar: any) {
try {
const provider = getSuiProvider();
Expand Down Expand Up @@ -621,6 +649,21 @@ export default function Recovery() {
}
})();
}
if (parsedPayload && parsedPayload.targetChain === CHAIN_ID_INJECTIVE) {
(async () => {
const client = getInjectiveWasmClient();
const tokenBridgeAddress =
getTokenBridgeAddressForChain(CHAIN_ID_INJECTIVE);
const tokenId = await queryExternalIdInjective(
client as any,
tokenBridgeAddress,
parsedPayload.originAddress
);
if (!cancelled) {
setTokenId(tokenId || "");
}
})();
}

if (parsedPayload && parsedPayload.targetChain === CHAIN_ID_SUI) {
(async () => {
Expand Down Expand Up @@ -802,6 +845,26 @@ export default function Recovery() {
setIsVAAPending(isPending);
}
})();
} else if (recoverySourceChain === CHAIN_ID_INJECTIVE) {
setRecoverySourceTxError("");
setRecoverySourceTxIsLoading(true);
setTokenId("");
(async () => {
const { vaa, isPending, error } = await injective(
recoverySourceTx,
enqueueSnackbar
);
if (!cancelled) {
setRecoverySourceTxIsLoading(false);
if (vaa) {
setRecoverySignedVAA(vaa);
}
if (error) {
setRecoverySourceTxError(error);
}
setIsVAAPending(isPending);
}
})();
} else if (recoverySourceChain === CHAIN_ID_SUI) {
setRecoverySourceTxError("");
setRecoverySourceTxIsLoading(true);
Expand Down Expand Up @@ -1166,7 +1229,8 @@ export default function Recovery() {
value={
parsedPayload
? parsedPayload.targetChain === CHAIN_ID_TERRA2 ||
parsedPayload.targetChain === CHAIN_ID_XPLA
parsedPayload.targetChain === CHAIN_ID_XPLA ||
parsedPayload.targetChain === CHAIN_ID_INJECTIVE
? tokenId
: hexToNativeAssetString(
parsedPayload.originAddress,
Expand Down
5 changes: 5 additions & 0 deletions src/components/ShowTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
CHAIN_ID_XPLA,
CHAIN_ID_APTOS,
CHAIN_ID_ARBITRUM,
CHAIN_ID_INJECTIVE,
CHAIN_ID_OPTIMISM,
CHAIN_ID_SUI,
CHAIN_ID_BASE,
Expand Down Expand Up @@ -168,6 +169,10 @@ export default function ShowTx({
? `https://${
CLUSTER === "testnet" ? "goerli." : ""
}arbiscan.io/tx/${tx?.id}`
: chainId === CHAIN_ID_INJECTIVE
? `https://${
CLUSTER === "testnet" ? "testnet." : ""
}explorer.injective.network/transaction/${tx.id}`
: chainId === CHAIN_ID_OPTIMISM
? `https://${
CLUSTER === "testnet" ? "goerli-optimism." : "optimistic."
Expand Down
9 changes: 9 additions & 0 deletions src/components/SmartAddress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
CHAIN_ID_APTOS,
isValidAptosType,
CHAIN_ID_ARBITRUM,
CHAIN_ID_INJECTIVE,
terra,
CHAIN_ID_OPTIMISM,
CHAIN_ID_SUI,
Expand Down Expand Up @@ -229,6 +230,14 @@ export default function SmartAddress({
? `https://${CLUSTER === "testnet" ? "goerli." : ""}arbiscan.io/${
isAsset ? "token" : "address"
}/${useableAddress}`
: chainId === CHAIN_ID_INJECTIVE
? `https://${
CLUSTER === "testnet" ? "testnet." : ""
}explorer.injective.network/${
isAsset
? `asset/?tokenType=${isNative ? "native" : "cw20"}&tokenIdentifier=`
: "account/"
}${useableAddress}`
: chainId === CHAIN_ID_OPTIMISM
? `https://${
CLUSTER === "testnet" ? "goerli-optimism." : "optimistic."
Expand Down
Loading
Loading