Skip to content

Commit

Permalink
feat(@mud/utils): add keccak256 hash function that accepts string inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
alvrs committed May 17, 2022
1 parent 233c4b5 commit ca1a4e0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 26 deletions.
4 changes: 3 additions & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-typescript": "^8.3.1",
"@types/jest": "^27.4.1",
"ethers": "^5.6.6",
"jest": "^27.5.1",
"mobx": "^6.5.0",
"proxy-deep": "^3.1.1",
Expand All @@ -27,6 +28,7 @@
"peerDependencies": {
"mobx": "^6.5.0",
"proxy-deep": "^3.1.1",
"rxjs": "^7.5.5"
"rxjs": "^7.5.5",
"ethers": "^5.6.6"
}
}
5 changes: 5 additions & 0 deletions packages/utils/src/hash.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { keccak256 as keccak256Bytes, toUtf8Bytes } from "ethers/lib/utils";

export function keccak256(data: string) {
return keccak256Bytes(toUtf8Bytes(data));
}
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ export * from "./promise";
export * from "./sleep";
export * from "./iterable";
export * from "./area";
export * from "./hash";

export type { Cached, PromiseValue, ValueOf, Area, Coord } from "./types";
33 changes: 8 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2530,12 +2530,12 @@
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf"
integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==

"@types/react-dom@^17.0.14":
version "17.0.17"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.17.tgz#2e3743277a793a96a99f1bf87614598289da68a1"
integrity sha512-VjnqEmqGnasQKV0CWLevqMTXBYG9GbwuE6x3VetERLh0cq2LTptFE73MrQi2S7GkKXCf2GgwItB/melLnxfnsg==
"@types/react-dom@^18.0.4":
version "18.0.4"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.0.4.tgz#dcbcadb277bcf6c411ceff70069424c57797d375"
integrity sha512-FgTtbqPOCI3dzZPZoC2T/sx3L34qxy99ITWn4eoSA95qPyXDMH0ALoAqUp49ITniiJFsXUVBtalh/KffMpg21Q==
dependencies:
"@types/react" "^17"
"@types/react" "*"

"@types/react@*":
version "18.0.9"
Expand All @@ -2546,7 +2546,7 @@
"@types/scheduler" "*"
csstype "^3.0.2"

"@types/react@^17", "@types/react@^17.0.43":
"@types/react@^17.0.43":
version "17.0.45"
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.45.tgz#9b3d5b661fd26365fefef0e766a1c6c30ccf7b3f"
integrity sha512-YfhQ22Lah2e3CHPsb93tRwIGNiSwkuz1/blk4e6QrWS0jQzCSNbGLtOEYhPg02W0yGTTmpajp7dCTbBAMN3qsg==
Expand Down Expand Up @@ -3360,14 +3360,6 @@ buffer@^5.5.0, buffer@^5.6.0:
base64-js "^1.3.1"
ieee754 "^1.1.13"

buffer@^6.0.3:
version "6.0.3"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6"
integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==
dependencies:
base64-js "^1.3.1"
ieee754 "^1.2.1"

builtin-modules@^3.0.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.3.0.tgz#cae62812b89801e9656336e46223e030386be7b6"
Expand Down Expand Up @@ -6039,7 +6031,7 @@ iconv-lite@^0.6.2:
dependencies:
safer-buffer ">= 2.1.2 < 3.0.0"

ieee754@^1.1.13, ieee754@^1.2.1:
ieee754@^1.1.13:
version "1.2.1"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==
Expand Down Expand Up @@ -7122,16 +7114,7 @@ jsprim@^2.0.2:
json-schema "0.4.0"
verror "1.10.0"

keccak256@^1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/keccak256/-/keccak256-1.0.6.tgz#dd32fb771558fed51ce4e45a035ae7515573da58"
integrity sha512-8GLiM01PkdJVGUhR1e6M/AvWnSqYS0HaERI+K/QtStGDGlSTx2B1zTqZk4Zlqu5TxHJNTxWAdP9Y+WI50OApUw==
dependencies:
bn.js "^5.2.0"
buffer "^6.0.3"
keccak "^3.0.2"

keccak@^3.0.0, keccak@^3.0.2:
keccak@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.2.tgz#4c2c6e8c54e04f2670ee49fa734eb9da152206e0"
integrity sha512-PyKKjkH53wDMLGrvmRGSNWgmSxZOUqbnXwKL9tmgbFYA1iAYqW21kfR7mZXV0MlESiefxQQE9X9fTa3X+2MPDQ==
Expand Down

0 comments on commit ca1a4e0

Please sign in to comment.