@manifoldxyz/js-ts-utils
v9.0.2
Published
JS and TS Utils for Manifold Devs
Keywords
Readme
@manifoldxyz/js-ts-utils
Useful functions and constants for Manifold devs in JS/TS.
Features
- Manifold eslint/prettier
- vitest w/ coverage reporting
- @ path alias
import { gm } from '@/gm' - ci github workflow + badges for build, lint, test status
Commands
npm run test # run the test suite in watch mode
npm run build # build the library in ./dist
npm run format # run prettier on the filesContributing
Please make a Pull Request for all proposed changes. Your pull request should always include unit test additions or modifications. Your pull request must pass all unit tests and linting tests. Once reviewed and passing, you can merge.
An example PR: https://github.com/manifoldxyz/js-ts-utils/pull/1
Releasing
- Bump the version in package.json
- Any merge or commit of that change to main will trigger the CI release action
- This will create a new version on npm matching the package.json (will not overwrite) and will create a new GH release for the version (will overwrite).
Coverage
If you run npm run coverage and the file you are modifying now has either less coverage or does not have near 90 coverage, please add the missing coverage.
Migration
7.1.0 -> 7.2.0
- Breaking:
getInstanceLink's first argument is now an object withpreviewandworkspaceSlugproperties - Breaking: PLATFORM_MAP[Platform.Manifold].url function generates new Manifold.xyz links if contract id, workspace identifier are provided
3.0.x to 4.0.0
- Breaking:
getNetworkNameForNetworkIdis nowgetDisplayNameForNetworkId
2.0.0 -> 2.1.0
- New: Added
Telemetrymodule - New: Added
Appsmodule
1.3.2 to 1.4.0
- Breaking:
getManifoldGalleryBaseURLis nowgetManifoldMarketplaceBaseURL - Breaking:
getManifoldGalleryTokenURLis nowgetManifoldMarketplaceTokenURL - Breaking:
getNetworkNameforNetworkId(sic) is nowgetNetworkNameForNetworkId - Breaking: PLATFORM_MAP[Platform.Manifold].url function generates new Manifold.gallery links
<1.0.0 to 1.0.0
If you are not using "type: module" in your package.json, you will have to use the CommonJS builds of this library which are only available in version 1.0.0 and greater.
<= 0.3.2 to 0.3.5
FIXED ESM build should be working properly in >= 0.3.5.
NEW You can import parts of the library now:
import { StringUtils } from '@manifoldxyz/js-ts-utils';
const addressAbbreviated = StringUtils.abbreviateAddress(
'0x1234567890abcdef1234567890abcdef1234567890',
);
// or you can do
import { abbreviateAddress } from '@manifoldxyz/js-ts-utils/StringUtils';
const addressAbbreviated = abbreviateAddress('0x1234567890abcdef1234567890abcdef1234567890');0.2.x to 0.3.x
This library now is using ESM.
networkmodule:- Breaking: types are now
PascalCaseand singular instead ofALL_CAPS_SNAKE_CASEand pluralSUPPORTED_NETWORKSis nowSupportedNetwork
- Breaking:
SUPPORTED_NETWORKS_ARRAYis now aconstarray, meaning that the types can be properly inferred- Subsequently,
SupportedNetworkproperly returns a limited set ofNetworkIdenum values (instead ofnumberpreviously), andisSupportedNetworknarrows the network types properly
- Subsequently,
- Breaking: the
NETWORK_IDSandNETWORK_NAMESenums have been replaced byNetworkIdenum with two inferred types,NetworkNameandCapitalizedNetworkName.NetworkIdvalues are alsoPascalCase.- New: Added additional testnet ids to
NetworkIdenum
- New: Added additional testnet ids to
- New: Added
MAIN_NETWORKSandTEST_NETWORKSconstant arrays with corresponding typesMainNetworkandTestNetwork - Adjusted:
isTestnetdepends on whether the network is inTEST_NETWORKSarray - New: Added
resolveChainIdByNamefunction to map from a network name to a network id
- Breaking: types are now
