@rarible/types
Version:
`@rarible/types` is a TypeScript library that provides type definitions and interfaces for the Rarible ecosystem. This package is designed to facilitate seamless integration with Rarible's APIs and services, ensuring type safety and improved developer exp
16 lines (15 loc) • 524 B
JavaScript
import { EVM_ZERO_ADDRESS, isRealBlockchainSpecified } from "../../blockchains/index.js";
/**
* Convert string to {@link CurrencyId}. Examples:
*
* - "ETHEREUM:native" for ETH
* - "ETHEREUM:0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" for WETH
* - "POLYGON:native" for Matic
* @param value string value to convert
*/
export function toCurrencyId(value) {
if (!isRealBlockchainSpecified(value)) {
throw new Error(`Not an CurrencyId: ${value}`);
}
return value.replace("native", EVM_ZERO_ADDRESS);
}