diff --git a/example/package.json b/example/package.json index cb16b69..40aa7c6 100644 --- a/example/package.json +++ b/example/package.json @@ -12,7 +12,8 @@ "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", - "eject": "react-scripts eject" + "eject": "react-scripts eject", + "up": "rm -rf ./node-modules && cd .. && yarn build && cd example && yarn && yarn start" }, "eslintConfig": { "extends": "react-app" @@ -34,4 +35,4 @@ "semi": false, "singleQuote": true } -} +} \ No newline at end of file diff --git a/example/src/App.js b/example/src/App.js index b34af25..a06c083 100644 --- a/example/src/App.js +++ b/example/src/App.js @@ -6,11 +6,10 @@ import { LibraClient, LibraNetwork, LibraWallet } from 'libra-web' class App extends React.Component { onTransfer = async () => { - const client = new LibraClient({ network: LibraNetwork.Testnet }) - const wallet = new LibraWallet({ - mnemonic: - 'silk rural awake receive timber bronze mutual message squeeze rug result shoot settle guide wheat believe dune fall share syrup picture true offer slow', - }) + const client = new LibraClient() + const wallet = new LibraWallet( + 'silk rural awake receive timber bronze mutual message squeeze rug result shoot settle guide wheat believe dune fall share syrup picture true offer slow', + ) // TEST ACCOUNT CREATION const account1 = wallet.getAccount() diff --git a/example/yarn.lock b/example/yarn.lock index 0a97cf8..c8a8865 100644 --- a/example/yarn.lock +++ b/example/yarn.lock @@ -2078,14 +2078,6 @@ asap@~2.0.6: resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY= -ascli@~1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/ascli/-/ascli-1.0.1.tgz#bcfa5974a62f18e81cabaeb49732ab4a88f906bc" - integrity sha1-vPpZdKYvGOgcq660lzKrSoj5Brw= - dependencies: - colour "~0.7.1" - optjs "~3.2.2" - asn1.js@^4.0.0: version "4.10.1" resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.10.1.tgz#b9c2bf5805f1e64aadeed6df3a2bfafb5a73f5a0" @@ -2388,6 +2380,13 @@ big.js@^5.2.2: resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== +bigint-buffer@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/bigint-buffer/-/bigint-buffer-1.1.2.tgz#b7edfaf3a88d0767aed7edc671d6bae4b1021575" + integrity sha512-gof9NgbodUgCXD2aUHfUKk5KUDk6/zPlwE+YYpRM2t7zS0K/6WipJFWfziIY+EavxFDuGUnuuQQzzvNcckPKNA== + dependencies: + bindings "^1.3.0" + bignumber.js@^9.0.0: version "9.0.0" resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.0.tgz#805880f84a329b5eac6e7cb6f8274b6d82bdf075" @@ -2398,6 +2397,13 @@ binary-extensions@^1.0.0: resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.13.0.tgz#9523e001306a32444b907423f1de2164222f6ab1" integrity sha512-EgmjVLMn22z7eGGv3kcnHwSnJXmFHjISTY9E/S5lIcTD3Oxw05QTcBLNkJFzcb3cNueUdF/IN4U+d78V0zO8Hw== +bindings@^1.3.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" + integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== + dependencies: + file-uri-to-path "1.0.0" + bip39@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/bip39/-/bip39-3.0.2.tgz#2baf42ff3071fc9ddd5103de92e8f80d9257ee32" @@ -2622,13 +2628,6 @@ builtin-status-codes@^3.0.0: resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" integrity sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug= -bytebuffer@~5: - version "5.0.1" - resolved "https://registry.yarnpkg.com/bytebuffer/-/bytebuffer-5.0.1.tgz#582eea4b1a873b6d020a48d58df85f0bba6cfddd" - integrity sha1-WC7qSxqHO20CCkjVjfhfC7ps/d0= - dependencies: - long "~3" - bytes@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" @@ -2706,11 +2705,6 @@ camel-case@3.0.x: no-case "^2.2.0" upper-case "^1.1.1" -camelcase@^2.0.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" - integrity sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8= - camelcase@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" @@ -2885,15 +2879,6 @@ cli-width@^2.0.0: resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk= -cliui@^3.0.3: - version "3.2.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d" - integrity sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0= - dependencies: - string-width "^1.0.1" - strip-ansi "^3.0.1" - wrap-ansi "^2.0.0" - cliui@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.1.0.tgz#348422dbe82d800b3022eef4f6ac10bf2e4d1b49" @@ -2984,11 +2969,6 @@ color@^3.0.0: color-convert "^1.9.1" color-string "^1.5.2" -colour@~0.7.1: - version "0.7.1" - resolved "https://registry.yarnpkg.com/colour/-/colour-0.7.1.tgz#9cb169917ec5d12c0736d3e8685746df1cadf778" - integrity sha1-nLFpkX7F0SwHNtPoaFdG3xyt93g= - combined-stream@^1.0.6, combined-stream@~1.0.6: version "1.0.7" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.7.tgz#2d1d24317afb8abe95d6d2c0b07b57813539d828" @@ -3534,7 +3514,7 @@ debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: dependencies: ms "^2.1.1" -decamelize@^1.1.1, decamelize@^1.2.0: +decamelize@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= @@ -4409,6 +4389,11 @@ file-loader@3.0.1: loader-utils "^1.0.2" schema-utils "^1.0.0" +file-uri-to-path@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" + integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== + filesize@3.6.1: version "3.6.1" resolved "https://registry.yarnpkg.com/filesize/-/filesize-3.6.1.tgz#090bb3ee01b6f801a8a8be99d31710b3422bb317" @@ -4731,18 +4716,6 @@ glob@^7.0.3, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.0.5: - version "7.1.4" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.4.tgz#aa608a2f6c577ad357e1ae5a5c26d9a8d1969255" - integrity sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - global-modules@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/global-modules/-/global-modules-2.0.0.tgz#997605ad2345f27f51539bea26574421215c7780" @@ -4808,17 +4781,6 @@ grpc-web@^1.0.4: resolved "https://registry.yarnpkg.com/grpc-web/-/grpc-web-1.0.4.tgz#dac13f3a1b42092595a8807f724aeaa5f5d6487a" integrity sha512-CjIA05C1G9n0/aT5YrQ8SAYNh5foHZRVK+1yN81Ez9vpNQCmrvXCWQBOHlQK7tJg3EqC5m8F99XQRfAi+K8CyA== -grpc@^1.21.1: - version "1.21.1" - resolved "https://registry.yarnpkg.com/grpc/-/grpc-1.21.1.tgz#541c0f4bccffcf6aef200536179594633d4579cf" - integrity sha512-PFsZQazf62nP05a0xm23mlImMuw5oVlqF/0zakmsdqJgvbABe+d6VThY2PfhqJmWEL/FhQ6QNYsxS5EAM6++7g== - dependencies: - lodash.camelcase "^4.3.0" - lodash.clone "^4.5.0" - nan "^2.13.2" - node-pre-gyp "^0.13.0" - protobufjs "^5.0.3" - gzip-size@5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-5.0.0.tgz#a55ecd99222f4c48fd8c01c625ce3b349d0a0e80" @@ -5313,11 +5275,6 @@ invariant@^2.2.2, invariant@^2.2.4: dependencies: loose-envify "^1.0.0" -invert-kv@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" - integrity sha1-EEqOSqym09jNFXqO+L+rLXo//bY= - invert-kv@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02" @@ -6068,6 +6025,11 @@ js-levenshtein@^1.1.3: resolved "https://registry.yarnpkg.com/js-levenshtein/-/js-levenshtein-1.1.6.tgz#c6cee58eb3550372df8deb85fad5ce66ce01d59d" integrity sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g== +js-sha3@^0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" + integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== + "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -6312,13 +6274,6 @@ lazy-cache@^1.0.3: resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" integrity sha1-odePw6UEdMuAhF07O24dpJpEbo4= -lcid@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" - integrity sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU= - dependencies: - invert-kv "^1.0.0" - lcid@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/lcid/-/lcid-2.0.0.tgz#6ef5d2df60e52f82eb228a4c373e8d1f397253cf" @@ -6348,14 +6303,15 @@ levn@^0.3.0, levn@~0.3.0: version "0.1.0" dependencies: axios "^0.19.0" + bigint-buffer "^1.1.2" bignumber.js "^9.0.0" bip39 "^3.0.2" elliptic "^6.4.1" futoin-hkdf "^1.0.3" google-protobuf "^3.8.0" - grpc "^1.21.1" grpc-web "^1.0.4" int64-buffer "^0.99.1007" + js-sha3 "^0.8.0" protobufjs "^6.8.8" sha3 "^2.0.4" @@ -6422,16 +6378,6 @@ lodash._reinterpolate@~3.0.0: resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0= -lodash.camelcase@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" - integrity sha1-soqmKIorn8ZRA1x3EfZathkDMaY= - -lodash.clone@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.clone/-/lodash.clone-4.5.0.tgz#195870450f5a13192478df4bc3d23d2dea1907b6" - integrity sha1-GVhwRQ9aExkkeN9Lw9I9LeoZB7Y= - lodash.get@^4.4.2: version "4.4.2" resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" @@ -6492,11 +6438,6 @@ long@^4.0.0: resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== -long@~3: - version "3.2.0" - resolved "https://registry.yarnpkg.com/long/-/long-3.2.0.tgz#d821b7138ca1cb581c172990ef14db200b5c474b" - integrity sha1-2CG3E4yhy1gcFymQ7xTbIAtcR0s= - loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" @@ -6828,11 +6769,6 @@ mute-stream@0.0.7: resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" integrity sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s= -nan@^2.13.2: - version "2.14.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c" - integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg== - nan@^2.9.2: version "2.12.1" resolved "https://registry.yarnpkg.com/nan/-/nan-2.12.1.tgz#7b1aa193e9aa86057e3c7bbd0ac448e770925552" @@ -6967,22 +6903,6 @@ node-pre-gyp@^0.10.0: semver "^5.3.0" tar "^4" -node-pre-gyp@^0.13.0: - version "0.13.0" - resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.13.0.tgz#df9ab7b68dd6498137717838e4f92a33fc9daa42" - integrity sha512-Md1D3xnEne8b/HGVQkZZwV27WUi1ZRuZBij24TNaZwUPU3ZAFtvT6xxJGaUVillfmMKnn5oD1HoGsp2Ftik7SQ== - dependencies: - detect-libc "^1.0.2" - mkdirp "^0.5.1" - needle "^2.2.1" - nopt "^4.0.1" - npm-packlist "^1.1.6" - npmlog "^4.0.2" - rc "^1.2.7" - rimraf "^2.6.1" - semver "^5.3.0" - tar "^4" - node-releases@^1.1.13, node-releases@^1.1.23: version "1.1.25" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.25.tgz#0c2d7dbc7fed30fbe02a9ee3007b8c90bf0133d3" @@ -7241,11 +7161,6 @@ optionator@^0.8.1, optionator@^0.8.2: type-check "~0.3.2" wordwrap "~1.0.0" -optjs@~3.2.2: - version "3.2.2" - resolved "https://registry.yarnpkg.com/optjs/-/optjs-3.2.2.tgz#69a6ce89c442a44403141ad2f9b370bd5bb6f4ee" - integrity sha1-aabOicRCpEQDFBrS+bNwvVu29O4= - original@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/original/-/original-1.0.2.tgz#e442a61cffe1c5fd20a65f3261c26663b303f25f" @@ -7263,13 +7178,6 @@ os-homedir@^1.0.0: resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= -os-locale@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-1.4.0.tgz#20f9f17ae29ed345e8bde583b13d2009803c14d9" - integrity sha1-IPnxeuKe00XoveWDsT0gCYA8FNk= - dependencies: - lcid "^1.0.0" - os-locale@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-3.1.0.tgz#a802a6ee17f24c10483ab9935719cef4ed16bf1a" @@ -8341,16 +8249,6 @@ property-information@^5.0.0, property-information@^5.0.1: dependencies: xtend "^4.0.1" -protobufjs@^5.0.3: - version "5.0.3" - resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-5.0.3.tgz#e4dfe9fb67c90b2630d15868249bcc4961467a17" - integrity sha512-55Kcx1MhPZX0zTbVosMQEO5R6/rikNXd9b6RQK4KSPcrSIIwoXTtebIczUrXlwaSrbz4x8XUVThGPob1n8I4QA== - dependencies: - ascli "~1" - bytebuffer "~5" - glob "^7.0.5" - yargs "^3.10.0" - protobufjs@^6.8.8: version "6.8.8" resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.8.8.tgz#c8b4f1282fd7a90e6f5b109ed11c84af82908e7c" @@ -10472,11 +10370,6 @@ wide-align@^1.1.0: dependencies: string-width "^1.0.2 || 2" -window-size@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.4.tgz#f8e1aa1ee5a53ec5bf151ffa09742a6ad7697876" - integrity sha1-+OGqHuWlPsW/FR/6CXQqatdpeHY= - wordwrap@~0.0.2: version "0.0.3" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" @@ -10704,11 +10597,6 @@ xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1: resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" integrity sha1-pcbVMr5lbiPbgg77lDofBJmNY68= -y18n@^3.2.0: - version "3.2.1" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" - integrity sha1-bRX7qITAhnnA136I53WegR4H+kE= - "y18n@^3.2.1 || ^4.0.0", y18n@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" @@ -10769,16 +10657,3 @@ yargs@^12.0.2: which-module "^2.0.0" y18n "^3.2.1 || ^4.0.0" yargs-parser "^11.1.1" - -yargs@^3.10.0: - version "3.32.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.32.0.tgz#03088e9ebf9e756b69751611d2a5ef591482c995" - integrity sha1-AwiOnr+edWtpdRYR0qXvWRSCyZU= - dependencies: - camelcase "^2.0.1" - cliui "^3.0.3" - decamelize "^1.1.1" - os-locale "^1.4.0" - string-width "^1.0.1" - window-size "^0.1.4" - y18n "^3.2.0" diff --git a/package.json b/package.json index f671fcb..1d976d8 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "libra-web", "version": "0.1.0", "description": "A library for connecting with libra from browser and Node.js", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "build/libra-web/index.js", + "types": "build/libra-web/index.d.ts", "files": [ "build/**/*", "packages/**/*" @@ -13,14 +13,14 @@ "url": "https://github.com/bandprotocol/libra-web.git" }, "scripts": { - "build": "NODE_ENV=production tsc", + "build": "NODE_ENV=production tsc --build", "format": "prettier --write \"packages/**/*.ts\" \"test/**/*.ts\"", "lint": "tslint -p tsconfig.json", "lint:fix": "tslint -p tsconfig.json --fix", "prepare": "npm run build", "prepublishOnly": "npm test && npm run lint", - "test": "NODE_ENV=test jest --verbose", - "test-prod": "NODE_ENV=production jest --verbose", + "test": "NODE_ENV=test jest --verbose false", + "test-prod": "NODE_ENV=production jest --verbose false", "proxy": "cd ./scripts/proxy && ./run_proxy.sh" }, "keywords": [ @@ -33,6 +33,7 @@ "license": "MIT", "dependencies": { "axios": "^0.19.0", + "bigint-buffer": "^1.1.2", "bignumber.js": "^9.0.0", "bip39": "^3.0.2", "elliptic": "^6.4.1", @@ -64,4 +65,4 @@ "semi": false, "singleQuote": true } -} +} \ No newline at end of file diff --git a/packages/libra-web-account/Accounts.ts b/packages/libra-web-account/Accounts.ts index 9076097..4a0fa14 100644 --- a/packages/libra-web-account/Accounts.ts +++ b/packages/libra-web-account/Accounts.ts @@ -1,8 +1,8 @@ import BigNumber from 'bignumber.js' import { SHA3 } from 'sha3' -import { CursorBuffer } from 'libra-web-core-utils/common/CursorBuffer' -import Addresses from 'libra-web-core-utils/constants/Addresses' -import { KeyPair } from 'libra-web-core-utils/crypto/Eddsa' +import { CursorBuffer } from '../libra-web-core-utils/common/CursorBuffer' +import Addresses from '../libra-web-core-utils/constants/Addresses' +import { KeyPair } from '../libra-web-core-utils/crypto/Eddsa' export type AccountStates = AccountState[] diff --git a/packages/libra-web-account/KeyFactory.ts b/packages/libra-web-account/KeyFactory.ts index aaac215..c5bdecb 100644 --- a/packages/libra-web-account/KeyFactory.ts +++ b/packages/libra-web-account/KeyFactory.ts @@ -1,7 +1,8 @@ -import KeyPrefixes from 'libra-web-core-utils/constants/KeyPrefixes' -import { KeyPair } from 'libra-web-core-utils/crypto/Eddsa' -import { Hkdf } from 'libra-web-core-utils/crypto/Hkdf' -import { Pbkdf } from 'libra-web-core-utils/crypto/Pbkdf' +import { toBufferLE } from 'bigint-buffer' +import KeyPrefixes from '../libra-web-core-utils/constants/KeyPrefixes' +import { KeyPair } from '../libra-web-core-utils/crypto/Eddsa' +import { Hkdf } from '../libra-web-core-utils/crypto/Hkdf' +import { Pbkdf } from '../libra-web-core-utils/crypto/Pbkdf' import { Mnemonic } from './Mnemonic' /** @@ -13,10 +14,10 @@ export class Seed { public static fromMnemonic(words: string[] | Mnemonic, salt: string = 'LIBRA'): Seed { const mnemonic: Mnemonic = Array.isArray(words) ? new Mnemonic(words) : words const bytes = new Pbkdf('sha3-256').sha3256Pbkdf2( - Buffer.from(mnemonic.toBytes()), - Buffer.from(`${KeyPrefixes.MnemonicSalt}${salt}`), - 2048, - 32, + Buffer.from(mnemonic.toBytes()), + Buffer.from(`${KeyPrefixes.MnemonicSalt}${salt}`), + 2048, + 32, ) return new Seed(bytes) } @@ -49,12 +50,19 @@ export class KeyFactory { * */ public generateKey(childDepth: number): KeyPair { - const childDepthBuffer = Buffer.alloc(8) - childDepthBuffer.writeBigUInt64LE(BigInt(childDepth)) - const info = Buffer.concat([ - Uint8Array.from(Buffer.from(KeyPrefixes.DerivedKey)), - Uint8Array.from(childDepthBuffer), - ]); + // const childDepthBuffer = toBufferLE(BigInt(childDepth), 8) + const childDepthBuffer = Buffer.from( + BigInt(childDepth) + .toString(16) + .padStart(16, '0') + .slice(0, 16), + 'hex', + ) + childDepthBuffer.reverse() + const info = Buffer.from([ + ...Uint8Array.from(Buffer.from(KeyPrefixes.DerivedKey)), + ...Uint8Array.from(childDepthBuffer), + ]) const secretKey = this.hkdf.expand(this.masterPrk, info, 32) return KeyPair.fromSecretKey(secretKey) diff --git a/packages/libra-web-account/Mnemonic.ts b/packages/libra-web-account/Mnemonic.ts index 8d27f26..0f29192 100644 --- a/packages/libra-web-account/Mnemonic.ts +++ b/packages/libra-web-account/Mnemonic.ts @@ -1,6 +1,6 @@ import { generateMnemonic } from 'bip39' -import CollectionUtil from 'libra-web-core-utils/common/CollectionUtil' -import MnemonicWords from 'libra-web-core-utils/constants/MnemonicWords' +import CollectionUtil from '../libra-web-core-utils/common/CollectionUtil' +import MnemonicWords from '../libra-web-core-utils/constants/MnemonicWords' /** * Handles logic for loading, writing and encoding mnemonic strings diff --git a/packages/libra-web-core/index.ts b/packages/libra-web-core/index.ts index adce872..0ed93cc 100644 --- a/packages/libra-web-core/index.ts +++ b/packages/libra-web-core/index.ts @@ -15,11 +15,11 @@ import { UpdateToLatestLedgerRequest, RawTransaction, SignedTransaction, -} from 'libra-web-net' -import { CursorBuffer } from 'libra-web-core-utils/common/CursorBuffer' -import PathValues from 'libra-web-core-utils/constants/PathValues' -import { LibraTransaction, LibraTransactionFactory } from 'libra-web-transaction' -import { Account, AccountAddress, AccountState, AccountStates } from 'libra-web-account' +} from '../libra-web-net' +import { CursorBuffer } from '../libra-web-core-utils/common/CursorBuffer' +import PathValues from '../libra-web-core-utils/constants/PathValues' +import { LibraTransaction, LibraTransactionFactory } from '../libra-web-transaction' +import { Account, AccountAddress, AccountState, AccountStates } from '../libra-web-account' export enum LibraNetwork { Testnet = 'testnet', diff --git a/packages/libra-web-transaction/index.ts b/packages/libra-web-transaction/index.ts index 34ec357..371f711 100644 --- a/packages/libra-web-transaction/index.ts +++ b/packages/libra-web-transaction/index.ts @@ -1,7 +1,7 @@ import BigNumber from 'bignumber.js' import { Uint64LE } from 'int64-buffer' -import { AccountAddress } from 'libra-web-account' -import { Program, TransactionArgument } from 'libra-web-net' +import { AccountAddress } from '../libra-web-account' +import { Program, TransactionArgument } from '../libra-web-net' interface LibraGasConstraint { maxGasAmount: BigNumber diff --git a/packages/libra-web/index.ts b/packages/libra-web/index.ts index 8c124c9..d0e773d 100644 --- a/packages/libra-web/index.ts +++ b/packages/libra-web/index.ts @@ -1,3 +1,3 @@ -export { LibraClient, LibraNetwork } from 'libra-web-core' -export { LibraWallet, AccountAddress, Account, AccountState } from 'libra-web-account' -export { LibraTransactionFactory } from 'libra-web-transaction' +export { LibraClient, LibraNetwork } from '../libra-web-core' +export { LibraWallet, AccountAddress, Account, AccountState } from '../libra-web-account' +export { LibraTransactionFactory } from '../libra-web-transaction' diff --git a/test/query.test.ts b/test/query.test.ts index f199004..3394999 100644 --- a/test/query.test.ts +++ b/test/query.test.ts @@ -1,4 +1,4 @@ -import { LibraClient, LibraWallet } from 'libra-web' +import { LibraClient, LibraWallet } from '../packages/libra-web' describe('LibraClient.query*()', () => { describe('queryBalance()', () => { diff --git a/test/wallet.test.ts b/test/wallet.test.ts index 2b31b5d..4ec9754 100644 --- a/test/wallet.test.ts +++ b/test/wallet.test.ts @@ -1,4 +1,4 @@ -import { Mnemonic } from 'libra-web-account' +import { Mnemonic } from '../packages/libra-web-account' describe('LibraWallet', () => { describe('generateMnemonic()', () => { diff --git a/tsconfig.json b/tsconfig.json index a8b28fa..11b1b55 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,8 +7,7 @@ "strict": true, - "moduleResolution": "node", - "baseUrl": "./packages", + "baseUrl": ".", "esModuleInterop": true }, "include": ["packages/**/*", "packages/libra-web-net/__grpc_web_generated__/*", "test/**/*"], diff --git a/yarn.lock b/yarn.lock index 1b25088..d723cb2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -946,11 +946,25 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" +bigint-buffer@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/bigint-buffer/-/bigint-buffer-1.1.2.tgz#b7edfaf3a88d0767aed7edc671d6bae4b1021575" + integrity sha512-gof9NgbodUgCXD2aUHfUKk5KUDk6/zPlwE+YYpRM2t7zS0K/6WipJFWfziIY+EavxFDuGUnuuQQzzvNcckPKNA== + dependencies: + bindings "^1.3.0" + bignumber.js@^9.0.0: version "9.0.0" resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.0.tgz#805880f84a329b5eac6e7cb6f8274b6d82bdf075" integrity sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A== +bindings@^1.3.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" + integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== + dependencies: + file-uri-to-path "1.0.0" + bip39@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/bip39/-/bip39-3.0.2.tgz#2baf42ff3071fc9ddd5103de92e8f80d9257ee32" @@ -1100,7 +1114,7 @@ ci-info@^2.0.0: resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== -cipher-base@^1.0.1, cipher-base@^1.0.3, cipher-base@^1.0.4: +cipher-base@^1.0.1, cipher-base@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de" integrity sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q== @@ -1625,6 +1639,11 @@ fb-watchman@^2.0.0: dependencies: bser "^2.0.0" +file-uri-to-path@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" + integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== + fill-range@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" @@ -2073,7 +2092,7 @@ info-symbol@^0.1.0: resolved "https://registry.yarnpkg.com/info-symbol/-/info-symbol-0.1.0.tgz#27841d72867ddb4242cd612d79c10633881c6a78" integrity sha1-J4QdcoZ920JCzWEtecEGM4gcang= -inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.3: +inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==