diff --git a/.npmignore b/.npmignore index d34b6c1..a574881 100644 --- a/.npmignore +++ b/.npmignore @@ -4,4 +4,4 @@ .eslintrc.json .gitattribute .gitignore -.jsbeautyrc +.jsbeautifyrc diff --git a/package-lock.json b/package-lock.json index 137e64e..4d2e79b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,9 +1,383 @@ { "name": "@internetofpeers/mom-js", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { + "@ethersproject/abi": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.0.2.tgz", + "integrity": "sha512-Z+5f7xOgtRLu/W2l9Ry5xF7ehh9QVQ0m1vhynmTcS7DMfHgqTd1/PDFC62aw91ZPRCRZsYdZJu8ymokC5e1JSw==", + "requires": { + "@ethersproject/address": "^5.0.0", + "@ethersproject/bignumber": "^5.0.0", + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/constants": "^5.0.0", + "@ethersproject/hash": "^5.0.0", + "@ethersproject/keccak256": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "@ethersproject/properties": "^5.0.0", + "@ethersproject/strings": "^5.0.0" + } + }, + "@ethersproject/abstract-provider": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.0.2.tgz", + "integrity": "sha512-U1s60+nG02x8FKNMoVNI6MG8SguWCoG9HJtwOqWZ38LBRMsDV4c0w4izKx98kcsN3wXw4U2/YAyJ9LlH7+/hkg==", + "requires": { + "@ethersproject/bignumber": "^5.0.0", + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "@ethersproject/networks": "^5.0.0", + "@ethersproject/properties": "^5.0.0", + "@ethersproject/transactions": "^5.0.0", + "@ethersproject/web": "^5.0.0" + } + }, + "@ethersproject/abstract-signer": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.0.2.tgz", + "integrity": "sha512-CzzXbeqKlgayE4YTnvvreGBG3n+HxakGXrxaGM6LjBZnOOIVSYi6HMFG8ZXls7UspRY4hvMrtnKEJKDCOngSBw==", + "requires": { + "@ethersproject/abstract-provider": "^5.0.0", + "@ethersproject/bignumber": "^5.0.0", + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "@ethersproject/properties": "^5.0.0" + } + }, + "@ethersproject/address": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/address/-/address-5.0.2.tgz", + "integrity": "sha512-+rz26RKj7ujGfQynys4V9VJRbR+wpC6eL8F22q3raWMH3152Ha31GwJPWzxE/bEA+43M/zTNVwY0R53gn53L2Q==", + "requires": { + "@ethersproject/bignumber": "^5.0.0", + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/keccak256": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "@ethersproject/rlp": "^5.0.0", + "bn.js": "^4.4.0" + } + }, + "@ethersproject/base64": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.0.2.tgz", + "integrity": "sha512-0FE5RH5cUDddOiQEDpWtyHjkSW4D5/rdJzA3KTZo8Fk5ab/Y8vdzqbamsXPyPsXU3gS+zCE5Qq4EKVOWlWLLTA==", + "requires": { + "@ethersproject/bytes": "^5.0.0" + } + }, + "@ethersproject/basex": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.0.2.tgz", + "integrity": "sha512-p4m2CeQqI9vma3XipRbP2iDf6zTsbroE0MEXBAYXidsoJQSvePKrC6MVRKfTzfcHej1b9wfmjVBzqhqn3FRhIA==", + "requires": { + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/properties": "^5.0.0" + } + }, + "@ethersproject/bignumber": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.0.5.tgz", + "integrity": "sha512-24ln7PV0g8ZzjcVZiLW9Wod0i+XCmK6zKkAaxw5enraTIT1p7gVOcSXFSzNQ9WYAwtiFQPvvA+TIO2oEITZNJA==", + "requires": { + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "bn.js": "^4.4.0" + } + }, + "@ethersproject/bytes": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.0.3.tgz", + "integrity": "sha512-AyPMAlY+Amaw4Zfp8OAivm1xYPI8mqiUYmEnSUk1CnS2NrQGHEMmFJFiOJdS3gDDpgSOFhWIjZwxKq2VZpqNTA==", + "requires": { + "@ethersproject/logger": "^5.0.0" + } + }, + "@ethersproject/constants": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.0.2.tgz", + "integrity": "sha512-nNoVlNP6bgpog7pQ2EyD1xjlaXcy1Cl4kK5v1KoskHj58EtB6TK8M8AFGi3GgHTdMldfT4eN3OsoQ/CdOTVNFA==", + "requires": { + "@ethersproject/bignumber": "^5.0.0" + } + }, + "@ethersproject/contracts": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.0.2.tgz", + "integrity": "sha512-Ud3oW8mBNIWE+WHRjvwVEwfvshn7lfYWSSKG0fPSb6baRN9mLOoNguX+VIv3W5Sne9w2utnBmxLF2ESXitw64A==", + "requires": { + "@ethersproject/abi": "^5.0.0", + "@ethersproject/abstract-provider": "^5.0.0", + "@ethersproject/abstract-signer": "^5.0.0", + "@ethersproject/address": "^5.0.0", + "@ethersproject/bignumber": "^5.0.0", + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/constants": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "@ethersproject/properties": "^5.0.0" + } + }, + "@ethersproject/hash": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.0.2.tgz", + "integrity": "sha512-dWGvNwmVRX2bxoQQ3ciMw46Vzl1nqfL+5R8+2ZxsRXD3Cjgw1dL2mdjJF7xMMWPvPdrlhKXWSK0gb8VLwHZ8Cw==", + "requires": { + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/keccak256": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "@ethersproject/strings": "^5.0.0" + } + }, + "@ethersproject/hdnode": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/hdnode/-/hdnode-5.0.2.tgz", + "integrity": "sha512-QAUI5tfseTFqv00Vnbwzofqse81wN9TaL+x5GufTHIHJXgVdguxU+l39E3VYDCmO+eVAA6RCn5dJgeyra+PU2g==", + "requires": { + "@ethersproject/abstract-signer": "^5.0.0", + "@ethersproject/basex": "^5.0.0", + "@ethersproject/bignumber": "^5.0.0", + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "@ethersproject/pbkdf2": "^5.0.0", + "@ethersproject/properties": "^5.0.0", + "@ethersproject/sha2": "^5.0.0", + "@ethersproject/signing-key": "^5.0.0", + "@ethersproject/strings": "^5.0.0", + "@ethersproject/transactions": "^5.0.0", + "@ethersproject/wordlists": "^5.0.0" + } + }, + "@ethersproject/json-wallets": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/@ethersproject/json-wallets/-/json-wallets-5.0.3.tgz", + "integrity": "sha512-VfDXn5ylugkfiM6SrvQfhX9oAHVU5dsNpRw8PjjTCn4k5E2JuVRO5A8sibkYXDhcBmRISZIWqclIxka6FI/chg==", + "requires": { + "@ethersproject/abstract-signer": "^5.0.0", + "@ethersproject/address": "^5.0.0", + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/hdnode": "^5.0.0", + "@ethersproject/keccak256": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "@ethersproject/pbkdf2": "^5.0.0", + "@ethersproject/properties": "^5.0.0", + "@ethersproject/random": "^5.0.0", + "@ethersproject/strings": "^5.0.0", + "@ethersproject/transactions": "^5.0.0", + "aes-js": "3.0.0", + "scrypt-js": "3.0.1" + } + }, + "@ethersproject/keccak256": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.0.2.tgz", + "integrity": "sha512-MbroXutc0gPNYIrUjS4Aw0lDuXabdzI7+l7elRWr1G6G+W0v00e/3gbikWkCReGtt2Jnt4lQSgnflhDwQGcIhA==", + "requires": { + "@ethersproject/bytes": "^5.0.0", + "js-sha3": "0.5.7" + } + }, + "@ethersproject/logger": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.0.4.tgz", + "integrity": "sha512-alA2LiAy1LdQ/L1SA9ajUC7MvGAEQLsICEfKK4erX5qhkXE1LwLSPIzobtOWFsMHf2yrXGKBLnnpuVHprI3sAw==" + }, + "@ethersproject/networks": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.0.2.tgz", + "integrity": "sha512-T7HVd62D4izNU2tDHf6xUDo7k4JOGX4Lk7vDmVcDKrepSWwL2OmGWrqSlkRe2a1Dnz4+1VPE6fb6+KsmSRe82g==", + "requires": { + "@ethersproject/logger": "^5.0.0" + } + }, + "@ethersproject/pbkdf2": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/pbkdf2/-/pbkdf2-5.0.2.tgz", + "integrity": "sha512-OJFxdX/VtGI5M04lAzXKEOb76XBzjCOzGyko3/bMWat3ePAw7RveBOLyhm79SBs2fh21MSYgdG6JScEMHoSImw==", + "requires": { + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/sha2": "^5.0.0" + } + }, + "@ethersproject/properties": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.0.2.tgz", + "integrity": "sha512-FxAisPGAOACQjMJzewl9OJG6lsGCPTm5vpUMtfeoxzAlAb2lv+kHzQPUh9h4jfAILzE8AR1jgXMzRmlhwyra1Q==", + "requires": { + "@ethersproject/logger": "^5.0.0" + } + }, + "@ethersproject/providers": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.0.5.tgz", + "integrity": "sha512-ZR3yFg/m8qDl7317yXOHE7tKeGfoyZIZ/imhVC4JqAH+SX1rb6bdZcSjhJfet7rLmnJSsnYLTgIiVIT85aVLgg==", + "requires": { + "@ethersproject/abstract-provider": "^5.0.0", + "@ethersproject/abstract-signer": "^5.0.0", + "@ethersproject/address": "^5.0.0", + "@ethersproject/bignumber": "^5.0.0", + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/constants": "^5.0.0", + "@ethersproject/hash": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "@ethersproject/networks": "^5.0.0", + "@ethersproject/properties": "^5.0.0", + "@ethersproject/random": "^5.0.0", + "@ethersproject/rlp": "^5.0.0", + "@ethersproject/strings": "^5.0.0", + "@ethersproject/transactions": "^5.0.0", + "@ethersproject/web": "^5.0.0", + "ws": "7.2.3" + } + }, + "@ethersproject/random": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/random/-/random-5.0.2.tgz", + "integrity": "sha512-kLeS+6bwz37WR2zbe69gudyoGVoUzljQO0LhifnATsZ7rW0JZ9Zgt0h5aXY7tqFDo9TvdqeCwUFdp1t3T5Fkhg==", + "requires": { + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/logger": "^5.0.0" + } + }, + "@ethersproject/rlp": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.0.2.tgz", + "integrity": "sha512-oE0M5jqQ67fi2SuMcrpoewOpEuoXaD8M9JeR9md1bXRMvDYgKXUtDHs22oevpEOdnO2DPIRabp6MVHa4aDuWmw==", + "requires": { + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/logger": "^5.0.0" + } + }, + "@ethersproject/sha2": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.0.2.tgz", + "integrity": "sha512-VFl4qSStjQZaygpqoAHswaCY59qBm1Sm0rf8iv0tmgVsRf0pBg2nJaNf9NXXvcuJ9AYPyXl57dN8kozdC4z5Cg==", + "requires": { + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "hash.js": "1.1.3" + }, + "dependencies": { + "hash.js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", + "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.0" + } + } + } + }, + "@ethersproject/signing-key": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.0.3.tgz", + "integrity": "sha512-5QPZaBRGCLzfVMbFb3LcVjNR0UbTXnwDHASnQYfbzwUOnFYHKxHsrcbl/5ONGoppgi8yXgOocKqlPCFycJJVWQ==", + "requires": { + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "@ethersproject/properties": "^5.0.0", + "elliptic": "6.5.3" + } + }, + "@ethersproject/solidity": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/solidity/-/solidity-5.0.2.tgz", + "integrity": "sha512-RygurUe1hPW1LDYAPXy4471AklGWNnxgFWc3YUE6H11gzkit26jr6AyZH4Yyjw38eBBL6j0AOfQzMWm+NhxZ9g==", + "requires": { + "@ethersproject/bignumber": "^5.0.0", + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/keccak256": "^5.0.0", + "@ethersproject/sha2": "^5.0.0", + "@ethersproject/strings": "^5.0.0" + } + }, + "@ethersproject/strings": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.0.2.tgz", + "integrity": "sha512-oNa+xvSqsFU96ndzog0IBTtsRFGOqGpzrXJ7shXLBT7juVeSEyZA/sYs0DMZB5mJ9FEjHdZKxR/rTyBY91vuXg==", + "requires": { + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/constants": "^5.0.0", + "@ethersproject/logger": "^5.0.0" + } + }, + "@ethersproject/transactions": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.0.2.tgz", + "integrity": "sha512-jZp0ZbbJlq4JLZY6qoMzNtp2HQsX6USQposi3ns0MPUdn3OdZJBDtrcO15r/2VS5t/K1e1GE5MI1HmMKlcTbbQ==", + "requires": { + "@ethersproject/address": "^5.0.0", + "@ethersproject/bignumber": "^5.0.0", + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/constants": "^5.0.0", + "@ethersproject/keccak256": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "@ethersproject/properties": "^5.0.0", + "@ethersproject/rlp": "^5.0.0", + "@ethersproject/signing-key": "^5.0.0" + } + }, + "@ethersproject/units": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/units/-/units-5.0.2.tgz", + "integrity": "sha512-PSuzycBA1zmRysTtKtp+XYZ3HIJfbmfRdZchOUxdyeGo5siUi9H6mYQcxdJHv82oKp/FniMj8qS8qtLQThhOEg==", + "requires": { + "@ethersproject/bignumber": "^5.0.0", + "@ethersproject/constants": "^5.0.0", + "@ethersproject/logger": "^5.0.0" + } + }, + "@ethersproject/wallet": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/wallet/-/wallet-5.0.2.tgz", + "integrity": "sha512-gg86ynLV5k5caNnYpJoYc6WyIUHKMTjOITCk5zXGyVbbkXE07y/fGql4A51W0C6mWkeb5Mzz8AKqzHZECdH30w==", + "requires": { + "@ethersproject/abstract-provider": "^5.0.0", + "@ethersproject/abstract-signer": "^5.0.0", + "@ethersproject/address": "^5.0.0", + "@ethersproject/bignumber": "^5.0.0", + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/hash": "^5.0.0", + "@ethersproject/hdnode": "^5.0.0", + "@ethersproject/json-wallets": "^5.0.0", + "@ethersproject/keccak256": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "@ethersproject/properties": "^5.0.0", + "@ethersproject/random": "^5.0.0", + "@ethersproject/signing-key": "^5.0.0", + "@ethersproject/transactions": "^5.0.0", + "@ethersproject/wordlists": "^5.0.0" + } + }, + "@ethersproject/web": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.0.2.tgz", + "integrity": "sha512-uAlcxdrAWB9PXZlb5NPzbOOt5/m9EJP2c6eLw15/PXPkNNohEIKvdXXOWdcQgTjZ0pcAaD/9mnJ6HXg7NbqXiw==", + "requires": { + "@ethersproject/base64": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "@ethersproject/properties": "^5.0.0", + "@ethersproject/strings": "^5.0.0" + } + }, + "@ethersproject/wordlists": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethersproject/wordlists/-/wordlists-5.0.2.tgz", + "integrity": "sha512-6vKDQcjjpnfdSCr0+jNxpFH3ieKxUPkm29tQX2US7a3zT/sJU/BGlKBR7D8oOpwdE0hpkHhJyMlypRBK+A2avA==", + "requires": { + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/hash": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "@ethersproject/properties": "^5.0.0", + "@ethersproject/strings": "^5.0.0" + } + }, + "aes-js": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", + "integrity": "sha1-4h3xCtbCBTKVvLuNq0Cwnb6ofk0=" + }, "ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", @@ -86,6 +460,11 @@ "integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ==", "dev": true }, + "bn.js": { + "version": "4.11.9", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", + "integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==" + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -105,6 +484,11 @@ "fill-range": "^7.0.1" } }, + "brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" + }, "browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", @@ -286,6 +670,20 @@ "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true }, + "elliptic": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", + "integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", + "requires": { + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.0" + } + }, "emoji-regex": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", @@ -355,6 +753,42 @@ "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true }, + "ethers": { + "version": "5.0.7", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.0.7.tgz", + "integrity": "sha512-1Zu9s+z4BgsDAZcGIYACJdWBB6mVtCCmUonj68Njul7STcSdgwOyj0sCAxCUr2Nsmsamckr4E12q3ecvZPGAUw==", + "requires": { + "@ethersproject/abi": "^5.0.0", + "@ethersproject/abstract-provider": "^5.0.0", + "@ethersproject/abstract-signer": "^5.0.0", + "@ethersproject/address": "^5.0.0", + "@ethersproject/base64": "^5.0.0", + "@ethersproject/bignumber": "^5.0.0", + "@ethersproject/bytes": "^5.0.0", + "@ethersproject/constants": "^5.0.0", + "@ethersproject/contracts": "^5.0.0", + "@ethersproject/hash": "^5.0.0", + "@ethersproject/hdnode": "^5.0.0", + "@ethersproject/json-wallets": "^5.0.0", + "@ethersproject/keccak256": "^5.0.0", + "@ethersproject/logger": "^5.0.0", + "@ethersproject/networks": "^5.0.0", + "@ethersproject/pbkdf2": "^5.0.0", + "@ethersproject/properties": "^5.0.0", + "@ethersproject/providers": "^5.0.0", + "@ethersproject/random": "^5.0.0", + "@ethersproject/rlp": "^5.0.0", + "@ethersproject/sha2": "^5.0.0", + "@ethersproject/signing-key": "^5.0.0", + "@ethersproject/solidity": "^5.0.0", + "@ethersproject/strings": "^5.0.0", + "@ethersproject/transactions": "^5.0.0", + "@ethersproject/units": "^5.0.0", + "@ethersproject/wallet": "^5.0.0", + "@ethersproject/web": "^5.0.0", + "@ethersproject/wordlists": "^5.0.0" + } + }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -463,12 +897,31 @@ "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", "dev": true }, + "hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, "he": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, + "hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", + "requires": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, "ieee754": { "version": "1.1.13", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", @@ -487,8 +940,7 @@ "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "is-arguments": { "version": "1.0.4", @@ -614,6 +1066,11 @@ "iterate-iterator": "^1.0.1" } }, + "js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=" + }, "js-yaml": { "version": "3.13.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", @@ -648,6 +1105,16 @@ "chalk": "^2.4.2" } }, + "minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + }, + "minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=" + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -840,6 +1307,11 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" }, + "scrypt-js": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", + "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==" + }, "serialize-javascript": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-3.0.0.tgz", @@ -1014,6 +1486,11 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, + "ws": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.2.3.tgz", + "integrity": "sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ==" + }, "y18n": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", diff --git a/package.json b/package.json index f056aea..2e3b410 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@internetofpeers/mom-js", - "version": "1.0.1", + "version": "1.0.2", "description": "", "main": "src/index.js", "scripts": { @@ -18,6 +18,7 @@ "homepage": "https://github.com/InternetOfPeers/mom-js#readme", "dependencies": { "chai": "^4.2.0", + "ethers": "^5.0.7", "multihashes": "^1.0.1" }, "devDependencies": { diff --git a/src/constants.js b/src/constants.js index 5570f5b..4e12848 100644 --- a/src/constants.js +++ b/src/constants.js @@ -2,13 +2,14 @@ exports.operations = Object.freeze({ ADD: 0x0, - DELETE: 0x1, - UPDATE: 0x2, - REPLY: 0x3, - ENDORSE: 0x4, - DISAPPROVE: 0x5, - ENDORSE_AND_REPLY: 0x6, - DISAPPROVE_AND_REPLY: 0x7, + ADD_AND_REFER: 0x1, + DELETE: 0x2, + UPDATE: 0x3, + REPLY: 0x4, + ENDORSE: 0x5, + DISAPPROVE: 0x6, + ENDORSE_AND_REPLY: 0x7, + DISAPPROVE_AND_REPLY: 0x8, CLOSE_ACCOUNT: 0xFD, RAW: 0xFF }); diff --git a/src/index.js b/src/index.js index 212313f..3134d5f 100644 --- a/src/index.js +++ b/src/index.js @@ -8,6 +8,7 @@ "use strict"; const cs = require("./constants"); +const ethers = require("ethers"); const multihashes = require("multihashes"); const { assert } = require("chai"); @@ -24,6 +25,22 @@ function encodeAddMessage(multiHash) { return Buffer.concat([Buffer.from([cs.operations.ADD]), multiHash]); } +/** + * + * @param {*} multiHash + * @param {*} address + */ +function encodeAddAndReferMessage(multiHash, address) { + try { + multihashes.decode(multiHash); + } catch (error) { + throw new Error(`message is not a valid multiHash: ${error}`); + } + if (!ethers.utils.isAddress(address)) + throw new Error(`address '${address}' is not a valid Ethereum address.`); + return Buffer.concat([Buffer.from([cs.operations.ADD_AND_REFER]), multiHash, Buffer.from(address)]); +} + /** * * @param {*} multiHash @@ -180,6 +197,15 @@ exports.createAddTransaction = function createAddTransaction(address, multiHash) return { to: address, value: 0, data: encodeAddMessage(multiHash) }; }; +/** + * + * @param {*} address + * @param {*} multiHash + */ +exports.createAddAndReferTransaction = function createAddAndReferTransaction(address, multiHash, referencedAddress) { + return { to: address, value: 0, data: encodeAddAndReferMessage(multiHash, referencedAddress) }; +}; + /** * * @param {*} address diff --git a/test/index.test.js b/test/index.test.js index 7afd99b..5e807d9 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -22,10 +22,21 @@ describe("MOM", function() { expect(() => mom.createAddTransaction(expectedAddress, Buffer.from("test"))).to.throw(); }); + it('should create a correct ADD & REFER message payload', function() { + const messageHash = "QmbHQieckNGj2KwBhpzkGSLDgezGnArL6eeuvb87YLX665"; + const messageMultiHash = multihashes.fromB58String(messageHash); + const address = "0xF22E75d6d61D33aE38f8360574A8b72816176D20"; + const expectedData = Buffer.concat([Buffer.from([1]), messageMultiHash, Buffer.from(address)]); + const expectedPayload = { to: expectedAddress, value: 0, data: expectedData }; + mom.createAddAndReferTransaction(expectedAddress, messageMultiHash, address).should.jsonEqual(expectedPayload); + expect(() => mom.createAddAndReferTransaction(expectedAddress, Buffer.from("test"), address)).to.throw(); + expect(() => mom.createAddAndReferTransaction(expectedAddress, messageMultiHash, "test")).to.throw(); + }); + it('should create a correct DELETE message payload', function() { const messageHash = "QmbHQieckNGj2KwBhpzkGSLDgezGnArL6eeuvb87YLX665"; const messageMultiHash = multihashes.fromB58String(messageHash); - const expectedData = Buffer.concat([Buffer.from([1]), messageMultiHash]); + const expectedData = Buffer.concat([Buffer.from([2]), messageMultiHash]); const expectedPayload = { to: expectedAddress, value: 0, data: expectedData }; mom.createDeleteTransaction(expectedAddress, messageMultiHash).should.jsonEqual(expectedPayload); expect(() => mom.createDeleteTransaction(expectedAddress, Buffer.from("test"))).to.throw(); @@ -36,10 +47,11 @@ describe("MOM", function() { const originalMessageMultiHash = multihashes.fromB58String(originalMessageHash); const updatedMessageHash = "QmQpHt3EoEppWrVt2tAV22VFKTZ9NrMwfAWSsGcBZv6WKw"; const updatedMessageMultiHash = multihashes.fromB58String(updatedMessageHash); - const expectedData = Buffer.concat([Buffer.from([2]), originalMessageMultiHash, updatedMessageMultiHash]); + const expectedData = Buffer.concat([Buffer.from([3]), originalMessageMultiHash, updatedMessageMultiHash]); const expectedPayload = { to: expectedAddress, value: 0, data: expectedData }; mom.createUpdateTransaction(expectedAddress, originalMessageMultiHash, updatedMessageMultiHash).should.jsonEqual(expectedPayload); - expect(() => mom.createUpdateTransaction(expectedAddress, Buffer.from("test"), Buffer.from("test"))).to.throw(); + expect(() => mom.createUpdateTransaction(expectedAddress, Buffer.from("test"), updatedMessageMultiHash)).to.throw(); + expect(() => mom.createUpdateTransaction(expectedAddress, originalMessageMultiHash, Buffer.from("test"))).to.throw(); }); it('should create a correct REPLY message payload', function() { @@ -47,16 +59,17 @@ describe("MOM", function() { const originalMessageMultiHash = multihashes.fromB58String(originalMessageHash); const replyMessageHash = "QmQpHt3EoEppWrVt2tAV22VFKTZ9NrMwfAWSsGcBZv6WKw"; const replyMessageMultiHash = multihashes.fromB58String(replyMessageHash); - const expectedData = Buffer.concat([Buffer.from([3]), originalMessageMultiHash, replyMessageMultiHash]); + const expectedData = Buffer.concat([Buffer.from([4]), originalMessageMultiHash, replyMessageMultiHash]); const expectedPayload = { to: expectedAddress, value: 0, data: expectedData }; mom.createReplyTransaction(expectedAddress, originalMessageMultiHash, replyMessageMultiHash).should.jsonEqual(expectedPayload); - expect(() => mom.createReplyTransaction(expectedAddress, Buffer.from("test"), Buffer.from("test"))).to.throw(); + expect(() => mom.createReplyTransaction(expectedAddress, Buffer.from("test"), replyMessageMultiHash)).to.throw(); + expect(() => mom.createReplyTransaction(expectedAddress, originalMessageMultiHash, Buffer.from("test"))).to.throw(); }); it('should create a correct ENDORSE message payload', function() { const messageHash = "QmbHQieckNGj2KwBhpzkGSLDgezGnArL6eeuvb87YLX665"; const messageMultiHash = multihashes.fromB58String(messageHash); - const expectedData = Buffer.concat([Buffer.from([4]), messageMultiHash]); + const expectedData = Buffer.concat([Buffer.from([5]), messageMultiHash]); const expectedPayload = { to: expectedAddress, value: 0, data: expectedData }; mom.createEndorseTransaction(expectedAddress, messageMultiHash).should.jsonEqual(expectedPayload); expect(() => mom.createEndorseTransaction(expectedAddress, Buffer.from("test"))).to.throw(); @@ -65,7 +78,7 @@ describe("MOM", function() { it('should create a correct DISAPPROVE message payload', function() { const messageHash = "QmbHQieckNGj2KwBhpzkGSLDgezGnArL6eeuvb87YLX665"; const messageMultiHash = multihashes.fromB58String(messageHash); - const expectedData = Buffer.concat([Buffer.from([5]), messageMultiHash]); + const expectedData = Buffer.concat([Buffer.from([6]), messageMultiHash]); const expectedPayload = { to: expectedAddress, value: 0, data: expectedData }; mom.createDisapproveTransaction(expectedAddress, messageMultiHash).should.jsonEqual(expectedPayload); expect(() => mom.createDisapproveTransaction(expectedAddress, Buffer.from("test"))).to.throw(); @@ -76,10 +89,11 @@ describe("MOM", function() { const originalMessageMultiHash = multihashes.fromB58String(originalMessageHash); const replyMessageHash = "QmQpHt3EoEppWrVt2tAV22VFKTZ9NrMwfAWSsGcBZv6WKw"; const replyMessageMultiHash = multihashes.fromB58String(replyMessageHash); - const expectedData = Buffer.concat([Buffer.from([6]), originalMessageMultiHash, replyMessageMultiHash]); + const expectedData = Buffer.concat([Buffer.from([7]), originalMessageMultiHash, replyMessageMultiHash]); const expectedPayload = { to: expectedAddress, value: 0, data: expectedData }; mom.createEndorseAndReplyTransaction(expectedAddress, originalMessageMultiHash, replyMessageMultiHash).should.jsonEqual(expectedPayload); - expect(() => mom.createEndorseAndReplyTransaction(expectedAddress, Buffer.from("test"), Buffer.from("test"))).to.throw(); + expect(() => mom.createEndorseAndReplyTransaction(expectedAddress, Buffer.from("test"), replyMessageMultiHash)).to.throw(); + expect(() => mom.createEndorseAndReplyTransaction(expectedAddress, originalMessageMultiHash, Buffer.from("test"))).to.throw(); }); it('should create a correct DISAPPROVE & REPLY message payload', function() { @@ -87,10 +101,11 @@ describe("MOM", function() { const originalMessageMultiHash = multihashes.fromB58String(originalMessageHash); const replyMessageHash = "QmQpHt3EoEppWrVt2tAV22VFKTZ9NrMwfAWSsGcBZv6WKw"; const replyMessageMultiHash = multihashes.fromB58String(replyMessageHash); - const expectedData = Buffer.concat([Buffer.from([7]), originalMessageMultiHash, replyMessageMultiHash]); + const expectedData = Buffer.concat([Buffer.from([8]), originalMessageMultiHash, replyMessageMultiHash]); const expectedPayload = { to: expectedAddress, value: 0, data: expectedData }; mom.createDisapproveAndReplyTransaction(expectedAddress, originalMessageMultiHash, replyMessageMultiHash).should.jsonEqual(expectedPayload); - expect(() => mom.createDisapproveAndReplyTransaction(expectedAddress, Buffer.from("test"), Buffer.from("test"))).to.throw(); + expect(() => mom.createDisapproveAndReplyTransaction(expectedAddress, Buffer.from("test"), replyMessageMultiHash)).to.throw(); + expect(() => mom.createDisapproveAndReplyTransaction(expectedAddress, originalMessageMultiHash, Buffer.from("test"))).to.throw(); }); it('should create a correct CLOSE ACCOUNT message payload', function() {