{"_id":"@3test/wanchain-utils","_rev":"1-fdff948d50486d9ea9b2720eae0ea9b0","name":"@3test/wanchain-utils","dist-tags":{"latest":"1.2.0"},"versions":{"1.2.0":{"name":"@3test/wanchain-utils","version":"1.2.0","description":"General Wanchain utility module with helper functions for the Wanchain blockchain.","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"npm run clean && npx tsc","clean":"rm -Rf ./dist","lint":"npx tslint 'src/**/*.ts?(x)'","test":"npm run lint && npx nyc npx hayspec test"},"hayspec":{"require":["ts-node/register"],"match":["./src/tests/**/*.test.ts"]},"nyc":{"extension":[".ts"],"require":["ts-node/register"],"exclude":["src/tests"]},"repository":{"type":"git","url":"git+https://github.com/0xcert/framework.git"},"bugs":{"url":"https://github.com/0xcert/framework/issues"},"homepage":"https://github.com/0xcert/framework#readme","keywords":["0xcert","framework","protocol","asset","value","values","currency","token","non-fungible","fungible","erc-721","erc-20","blockchain","javascript","typescript","nodejs","vuejs","nuxtjs","npm","libraries","smart-contract","wanchain","zxc"],"license":"MIT","devDependencies":{"@hayspec/cli":"^0.8.3","@hayspec/spec":"^0.8.3","ts-node":"^7.0.1","tslint":"^5.12.1","typescript":"^3.1.1"},"dependencies":{"ethers":"4.0.0-beta.1","@3test/ethereum-utils":"1.2.0"},"_id":"@3test/wanchain-utils@1.2.0","_npmVersion":"6.4.1","_nodeVersion":"11.1.0","_npmUser":{"name":"moman","email":"vengust.tadej@gmail.com"},"dist":{"integrity":"sha512-vqbijgJmdSSPOkJ/FViJ3J0VYvlX6uPCh3DZKd6jaeBKAm/JbezIKJinmdij6HMc45cIwqbei8dvrqh7BBamBQ==","shasum":"9d6732f91a9f6a635613e5f9e36cee941e0ed3af","tarball":"https://registry.npmjs.org/@3test/wanchain-utils/-/wanchain-utils-1.2.0.tgz","fileCount":21,"unpackedSize":19638,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcrdimCRA9TVsSAnZWagAAD5EQAIF0TIHb9Yol/ceH7tjY\nZORcvFdNlb/LJntDH1TB6SgDh2moDp53CfShs//AiEvfTPSIi7jyfDPTBG9+\no9taX3JkYage2JVoP5TLaVVQqx5FF9tsPSgjl+TeAOT6dlZwxNnN9kojyyym\n4uxmKjcEl+t36B+eX/6EBjyPVpox5Da20rVlR2J7JPaSASkKU8wSp7Lwqkno\nJyn+/3ZMjFGCJ6cC//Xqy5Y4J1BmUTZqs9LRCiI9QiSZ6tk0d84KJnkfDyOG\nDQEmsmxb8Rag0nkRnhLQcyCiEi5s2ma2lpciH0RGAIA+CSH5Uu3/rABhh1CN\n7QWI/kU6isimo72JukOmimDsAjNqAO1WK+yZmnNQqXiDBp+mQWN/ZTwdyDhO\nNZTozneto5RAKXQeuGJ2GMh0XFDGABPD6W+oTn/OrUvMX3Btz77VkO40+Ygi\n3Xq62xaSU4uRAimNhvGeCn05WJSK2S9sg3ALpXCYz2R1omv7cQdk+xluPdC0\nuP94+vEl+6NTQmmA9XhnzxpXFjipp6IKNUz7bC5SUos3jJ13jfU4Ho48kPGm\nzHQK6IdUKrHFc6ZV4SLgQwFyPw+fBZ4vTGw5bIDNwvNvCyoU9sVmPo3U+C+W\n4DP2zlfDv6qsn/ebWTIj2/nEPZtDx0AGIDfmrafNHQXvDU5Z4A3LnBbD6EXT\nC7PP\r\n=uoaS\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDLR0CWGR9I8cj7zPPNR0GZ6cR/Yc4DfRb1GNf2PQY12AiAAnuz9aC7lIZt7ep4sgkbGFoHIrYwgRqtHcUCglXB3EQ=="}]},"maintainers":[{"name":"moman","email":"vengust.tadej@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/wanchain-utils_1.2.0_1554897061990_0.38082942459654867"},"_hasShrinkwrap":false}},"time":{"created":"2019-04-10T11:51:01.807Z","1.2.0":"2019-04-10T11:51:02.196Z","modified":"2022-04-04T10:45:27.118Z"},"maintainers":[{"name":"moman","email":"vengust.tadej@gmail.com"}],"description":"General Wanchain utility module with helper functions for the Wanchain blockchain.","homepage":"https://github.com/0xcert/framework#readme","keywords":["0xcert","framework","protocol","asset","value","values","currency","token","non-fungible","fungible","erc-721","erc-20","blockchain","javascript","typescript","nodejs","vuejs","nuxtjs","npm","libraries","smart-contract","wanchain","zxc"],"repository":{"type":"git","url":"git+https://github.com/0xcert/framework.git"},"bugs":{"url":"https://github.com/0xcert/framework/issues"},"license":"MIT","readme":"<img src=\"https://github.com/0xcert/framework/raw/master/assets/cover-sub.png\" />\n\n> General Ethereum utility module with helper functions for the Ethereum blockchain.\n\nThe [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.\n\nThis module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).\n\n# Ethereum Utilities\n\nThis module wraps several useful Ethereum functions which will be useful through the 0xcert Framework. Currently supported are these functions and classes from [ethers.js](https://github.com/ethers-io/ethers.js):\n\n## ABI coder\n\nThis converts value to and from the packed [Ethereum ABI encoding](https://solidity.readthedocs.io/en/develop/abi-spec.html#formal-specification-of-the-encoding).\n\n* `encodeParameters`(types: `any`, values: `Array<any>`): `string`\n* `decodeParameters`(types: `any`, data: `any`): `any`\n\n**Encoding example:**\n\n```ts\nimport { decodeParameters, encodeParameters } from '0xcert/ethereum-utils/abi';\n\nconst types = ['tuple(uint256, uint256[])'];\nconst values = [[ 42, [ 45 ] ]];\nconst encodedValues = encodeParameters(types, values);\n```\n\n**Decoding example:**\n\n```ts\nimport { decodeParameters, encodeParameters } from '0xcert/ethereum-utils/abi';\n\nconst types = ['tuple(uint256, uint256[])'];\nconst encoded = '0x' +\n  '0000000000000000000000000000000000000000000000000000000000000020' +\n  '000000000000000000000000000000000000000000000000000000000000002a' +\n  '0000000000000000000000000000000000000000000000000000000000000040' +\n  '0000000000000000000000000000000000000000000000000000000000000001' +\n  '000000000000000000000000000000000000000000000000000000000000002d';\nconst values = decodeParameters(types, values);\n```\n\n## BigNumber and bigNumberify\n\nHere is a basic example adapted from [the ethers.js documentation](https://docs.ethers.io/ethers.js/html/api-utils.html?highlight=bignumberify#big-numbers).\n\n```ts\nimport { BigNumber, bigNumberify } from '0xcert/ethereum-utils/big-number';\n\nlet gasPriceWei = bigNumberify(\"20902747399\");\nlet gasLimit = bigNumberify(3000000);\n\nlet maxCostWei = gasPriceWei.mul(gasLimit)\nconsole.log(\"Max Cost: \" + maxCostWei.toString());\n// \"Max Cost: 62708242197000000\"\n\nconsole.log(\"Number: \" + maxCostWei.toNumber());\n// throws an Error, the value is too large for JavaScript to handle safely\n```\n\n## Address normalization\n\nThe ethers.js [address normalization function](https://docs.ethers.io/ethers.js/html/api-utils.html?highlight=getaddress#addresses) implements [EIP-55 Mixed-case checksum address encoding](https://eips.ethereum.org/EIPS/eip-55).\n\n\n```ts\nimport { getAddress } from '0xcert/ethereum-utils/normalize-address';\n\nlet zxcTokenAddress = '0x83e2be8d114f9661221384b3a50d24b96a5653f5';\nlet zxcTokenAddressNormalized = normalizeAddress(zxcToenAddress);\n// 0x83e2BE8d114F9661221384B3a50d24B96a5653F5\n```","readmeFilename":"README.md"}