{"name":"caip","description":"CAIP standard utils","version":"1.0.0-beta.0","author":{"name":"Pedro Gomes","email":"github.com/pedrouid"},"license":"MIT","keywords":["caip","blockchain","standard","chain-agnostic","parse","format","chainId","accountId","assetId"],"main":"dist/cjs/index.js","module":"dist/esm/index.js","browser":"dist/esm/index.js","types":"dist/cjs/index.d.ts","unpkg":"dist/umd/index.min.js","homepage":"https://github.com/pedrouid/caip-js","repository":{"type":"git","url":"git+https://github.com/pedrouid/caip-js.git"},"bugs":{"url":"https://github.com/pedrouid/caip-js/issues"},"scripts":{"start":"tsdx watch","clean":"rm -rf dist","build:cjs":"./node_modules/.bin/tsc -p tsconfig.cjs.json","build:umd":"webpack","build":"yarn clean && yarn build:cjs && yarn build:umd","test":"tsdx test ./test","lint":"tsdx lint src test","prepare":"yarn lint && yarn build && yarn test"},"devDependencies":{"@types/jest":"25.1.1","@types/node":"13.7.0","husky":"4.2.1","tsdx":"0.12.3","tslib":"1.10.0","typescript":"3.7.5","webpack":"4.41.6","webpack-cli":"3.3.11"},"husky":{"hooks":{"pre-commit":"yarn lint"}},"prettier":{"printWidth":80,"semi":true,"singleQuote":false,"trailingComma":"es5"},"readmeFilename":"README.md","readme":"# caip [![npm version](https://badge.fury.io/js/caip.svg)](https://badge.fury.io/js/caip)\n\nCAIP standard utils\n\n## ChainId (CAIP-2)\n\n### Object-oriented\n\n```typescript\nimport { ChainId } from \"caip\";\n\nconst chainId = new ChainId(\"eip155:1\");\n\n// OR\n\nconst chainId = new ChainId({ namespace: \"eip155\", reference: \"1\" });\n\n// THEN\n\nchainId.toString();\n// \"eip155:1\"\n\nchainId.toJson();\n// { namespace: \"eip155\", reference: \"1\" }\n```\n\n### Functional\n\n```typescript\nimport { ChainId } from \"caip\";\n\nChainId.parse(\"eip155:1\");\n// { namespace: \"eip155\", reference: \"1\" }\n\n// AND\n\nChainId.format({ namespace: \"eip155\", reference: \"1\" });\n// \"eip155:1\"\n```\n\n## AccountId (CAIP-10)\n\n### Object-oriented\n\n```typescript\nimport { AccountId } from \"caip\";\n\nconst accountId = new AccountId(\n  \"eip155:1:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\"\n);\n\n// OR\n\nconst accountId = new AccountId({\n  chainId: { namespace: \"eip155\", reference: \"1\" },\n  address: \"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\",\n});\n\n// ALSO\n\nconst accountId = new AccountId({\n  chainId: \"eip155:1\",\n  address: \"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\",\n});\n\n// THEN\n\naccountId.toString();\n// \"eip155:1:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\"\n\naccountId.toJson();\n// { address: \"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\", chainId: { namespace: \"eip155\", reference: \"1\" } }\n```\n\n### Functional\n\n```typescript\nimport { AccountId } from \"caip\";\n\nAccountId.parse(\"eip155:1:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\");\n// { address: \"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\", chainId: { namespace: \"eip155\", reference: \"1\" } }\n\n// AND\n\nAccountId.format({\n  chainId: { namespace: \"eip155\", reference: \"1\" },\n  address: \"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\",\n});\n//\"eip155:1:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\"\n\n// OR\n\nAccountId.format({\n  chainId: \"eip155:1\",\n  address: \"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\",\n});\n//\"eip155:1:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\"\n```\n\n## AssetId (CAIP-19)\n\n### Object-oriented\n\n```typescript\nimport { AssetId } from \"caip\";\n\nconst assetId = new AssetId(\n  \"eip155:1/erc721:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb/1\"\n);\n\n// OR\n\nconst assetId = new AssetId({\n  chainId: { namespace: \"eip155\", reference: \"1\" },\n  assetName: {\n    namespace: \"erc721\",\n    reference: \"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\",\n  },\n  tokenId: \"1\",\n});\n\n// ALSO\n\nconst assetId = new AssetId({\n  chainId: \"eip155:1\",\n  address: \"erc721:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\",\n  tokenId: \"1\",\n});\n\n// THEN\n\nassetId.toString();\n// \"eip155:1/erc721:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb/1\"\n\nassetId.toJson();\n// {\n//   chainId: { namespace: \"eip155\", reference: \"1\" },\n//   assetName: { namespace: \"erc721\", reference: \"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\" },\n//   tokenId: \"1\",\n// }\n```\n\n### Functional\n\n```typescript\nimport { AssetId } from \"caip\";\n\nAssetId.parse(\"eip155:1/erc721:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb/1\");\n// {\n//   chainId: { namespace: \"eip155\", reference: \"1\" },\n//   assetName: { namespace: \"erc721\", reference: \"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\" },\n//   tokenId: \"1\",\n// }\n\n// AND\n\nAssetId.format({\n  chainId: { namespace: \"eip155\", reference: \"1\" },\n  assetName: {\n    namespace: \"erc721\",\n    reference: \"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\",\n  },\n  tokenId: \"1\",\n});\n// \"eip155:1/erc721:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb/1\"\n\n// OR\n\nAssetId.format({\n  chainId: \"eip155:1\",\n  address: \"erc721:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\",\n  tokenId: \"1\",\n});\n// \"eip155:1/erc721:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb/1\"\n```\n\n## AssetType (CAIP-19)\n\n### Object-oriented\n\n```typescript\nimport { AssetType } from \"caip\";\n\nconst assetType = new AssetType(\n  \"eip155:1/erc721:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\"\n);\n\n// OR\n\nconst assetType = new AssetType({\n  chainId: { namespace: \"eip155\", reference: \"1\" },\n  assetName: {\n    namespace: \"erc721\",\n    reference: \"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\",\n  },\n});\n\n// ALSO\n\nconst assetType = new AssetType({\n  chainId: \"eip155:1\",\n  address: \"erc721:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\",\n});\n\n// THEN\n\nassetType.toString();\n// \"eip155:1/erc721:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\"\n\nassetType.toJson();\n// {\n//   chainId: { namespace: \"eip155\", reference: \"1\" },\n//   assetName: { namespace: \"erc721\", reference: \"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\" },\n// }\n```\n\n### Functional\n\n```typescript\nimport { AssetType } from \"caip\";\n\nAssetType.parse(\"eip155:1/erc721:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb/1\");\n// {\n//   chainId: { namespace: \"eip155\", reference: \"1\" },\n//   assetName: { namespace: \"erc721\", reference: \"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\" },\n// }\n\n// AND\n\nAssetType.format({\n  chainId: { namespace: \"eip155\", reference: \"1\" },\n  assetName: {\n    namespace: \"erc721\",\n    reference: \"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\",\n  },\n});\n// \"eip155:1/erc721:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\"\n\n// OR\n\nAssetType.format({\n  chainId: \"eip155:1\",\n  address: \"erc721:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\",\n});\n// \"eip155:1/erc721:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb\"\n```\n","licenseText":"MIT License\n\nCopyright (c) 2020 Pedro Gomes\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","_id":"caip@1.0.0-beta.0","dist":{"shasum":"3433399ebeb840d67c9c70d9c503fe51c210a8db","integrity":"sha512-bjJDXitV6qV9az8ybeCMLOAgkrktinx7O5vlmk/0z0c4P8YjW/bxMwPvkytuRlWG5zNQd4IRYMEq7Gr9k3rQVA==","tarball":"https://registry.npmjs.org/caip/-/caip-1.0.0-beta.0.tgz","fileCount":45,"unpackedSize":150016,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhDDoTCRA9TVsSAnZWagAAPX8P/29yTMwnW3qn/rb4162b\n8ykc+8g2CXCRnrj4ltlV5KIh58v0c9FBy0JRH5WzYyYlpYTht6QxxcndB4u7\n7lcrqehZzVvrDTJQsyYl494WpSG3pqj0mNaUd4tcBlV17Yk25qAk/YE4GdS5\nqdg4BoPv9lsFR1H2XO1uh8U6sP9VXRd7RsDbTcXrf+dpznzf3fCvnpPQkTYD\nWA//B5QClmWxOwYJPZxhtN5EcVzoAmNCmhdLFIvePdSs4sJg43Yr/CPL0mhr\nrDJCeD1QDv1vl4VEqXz3fIMDIbYyZQGbrW3YlzRQ61HGOuMILlL866VFIYOM\nJQVLcEwGKxjjDK4iXsUMUGWQVpbfk5jTUMvi0HgizADxXIoOFxYZQmUjbfUY\nHod6a6C/5ykcGymBtYDXU06jxBaOQHuHulkg1gbSFk4cjaBacmUn28D3V5+q\nN0bXTAjFoUpup1v5f8F0+81374HPbnH1ZlkRilgz481ftbxANC7mKuOyHl6U\nhXNc1atCtLof3ab70l4vnoXlWAFkBZwAo5xGnYE7euyCA/uHe7lQMvyjS5Qz\nZwlIFCmVn6CQ7PAXTTn6Hk8p1euNSKY0uAiEiKkdzO0qAl/p+8Q8J/g1KjWc\n+vSSSSkosqZ71aTo2Tep7G1B1LV/HQH6y5pubcmkF0eiOACxcIfnhJLvZyBt\nnqsc\r\n=hxHz\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHVItBf4jGDdoAgpyvZCe03Q0w8v2w+RWOC1PeYt7Z3JAiEA1OyUXotqtVfV7BfqORHkbGfcWfSxXDeT23q5pkytPig="}]},"_npmUser":{"name":"pedrouid","email":"pedrogomes94@gmail.com"},"directories":{},"maintainers":[{"name":"pedrouid","email":"pedrogomes94@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/caip_1.0.0-beta.0_1628191251009_0.06260678674506837"},"_hasShrinkwrap":false}