sdk/js: add XPLA to sdk (#1689)

* sdk/js: add XPLA to sdk

* sdk/js: use axpla as denom
This commit is contained in:
Paul Noel 2022-10-07 13:20:00 +00:00 committed by GitHub
parent 9609c4e7e0
commit d65def86e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -3,6 +3,7 @@ import { isNativeDenom } from "../terra";
import {
CHAIN_ID_INJECTIVE,
CHAIN_ID_TERRA,
CHAIN_ID_XPLA,
coalesceCosmWasmChainId,
CosmWasmChainId,
CosmWasmChainName,
@ -10,6 +11,7 @@ import {
} from "../utils";
export const isNativeDenomInjective = (string = "") => string === "inj";
export const isNativeDenomXpla = (string = "") => string === "axpla";
export function isNativeCosmWasmDenom(
chainId: CosmWasmChainId,
@ -17,7 +19,8 @@ export function isNativeCosmWasmDenom(
) {
return (
(isTerraChain(chainId) && isNativeDenom(address)) ||
(chainId === CHAIN_ID_INJECTIVE && isNativeDenomInjective(address))
(chainId === CHAIN_ID_INJECTIVE && isNativeDenomInjective(address)) ||
(chainId === CHAIN_ID_XPLA && isNativeDenomXpla(address))
);
}

View File

@ -98,10 +98,10 @@ export const tryUint8ArrayToNative = (
} else if (chainId == CHAIN_ID_WORMHOLE_CHAIN) {
// wormhole-chain addresses are always 20 bytes.
return humanAddress("wormhole", a.slice(-20));
} else if (chainId === CHAIN_ID_XPLA) {
return humanAddress("xpla", a.slice(-20));
} else if (chainId === CHAIN_ID_NEAR) {
throw Error("uint8ArrayToNative: Use tryHexToNativeStringNear instead.");
} else if (chainId === CHAIN_ID_XPLA) {
throw Error("uint8ArrayToNative: XPLA not supported yet.");
} else if (chainId === CHAIN_ID_OSMOSIS) {
throw Error("uint8ArrayToNative: Osmosis not supported yet.");
} else if (chainId === CHAIN_ID_SUI) {
@ -224,7 +224,11 @@ export const tryNativeToHexString = (
} else {
return uint8ArrayToHex(zeroPad(canonicalAddress(address), 32));
}
} else if (chainId === CHAIN_ID_TERRA2 || chainId === CHAIN_ID_INJECTIVE) {
} else if (
chainId === CHAIN_ID_TERRA2 ||
chainId === CHAIN_ID_INJECTIVE ||
chainId === CHAIN_ID_XPLA
) {
return buildTokenId(chainId, address);
} else if (chainId === CHAIN_ID_ALGORAND) {
return nativeStringToHexAlgorand(address);
@ -234,8 +238,6 @@ export const tryNativeToHexString = (
return uint8ArrayToHex(arrayify(sha256(Buffer.from(address))));
} else if (chainId === CHAIN_ID_OSMOSIS) {
throw Error("hexToNativeString: Osmosis not supported yet.");
} else if (chainId === CHAIN_ID_XPLA) {
throw Error("hexToNativeString: XPLA not supported yet.");
} else if (chainId === CHAIN_ID_SUI) {
throw Error("hexToNativeString: Sui not supported yet.");
} else if (chainId === CHAIN_ID_APTOS) {