Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Reverse using read-bigint, because of #48
  • Loading branch information
wk3368 committed May 15, 2022
1 parent 82a2daa commit 840fe13
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -54,7 +54,6 @@
"js-sha3": "^0.8.0",
"jssha": "^3.2.0",
"lodash": "^4.17.21",
"read-bigint": "^0.1.6",
"ws": "7.2.3"
},
"devDependencies": {
Expand Down
7 changes: 2 additions & 5 deletions src/onchain_events/index.ts
@@ -1,4 +1,3 @@
import { readBigUInt64LE } from "read-bigint";
import { arrayify, BytesLike } from '@ethersproject/bytes';
import {
AccountAddress,
Expand Down Expand Up @@ -149,13 +148,11 @@ export function decodeEventKey(
const bytes = arrayify(eventKey);
if (bytes.byteLength !== EVENT_KEY_LENGTH) {
throw new Error(
`invalid eventkey data, expect byte length to be ${EVENT_KEY_LENGTH}, actual: ${bytes.byteLength}`
`invalid eventkey data, expect byte length to be ${ EVENT_KEY_LENGTH }, actual: ${ bytes.byteLength }`
);
}
const saltBytes = bytes.slice(0, EVENT_KEY_LENGTH - ACCOUNT_ADDRESS_LENGTH);
const buff = Buffer.from(saltBytes);
// const salt = buff.readBigUInt64LE();
const salt = readBigUInt64LE(buff);
const salt = Buffer.from(saltBytes).readBigUInt64LE();
const addressBytes = bytes.slice(EVENT_KEY_LENGTH - ACCOUNT_ADDRESS_LENGTH);
const address = toHexString(addressBytes);
return { address, salt };
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Expand Up @@ -6469,11 +6469,6 @@ react-is@^17.0.1:
resolved "https://registry.npm.taobao.org/react-is/download/react-is-17.0.2.tgz"
integrity "sha1-5pHUqOnHiTZWVVOas3J2Kw77VPA= sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="

read-bigint@^0.1.6:
version "0.1.6"
resolved "https://registry.npmjs.org/read-bigint/-/read-bigint-0.1.6.tgz#451fdb5ef5a9bb425fba1f92511038e2a54e5f26"
integrity sha512-WHfCMBWes972LRSGYb1/mTW6yy83DQ28Lj94TfVM1HIhFf2I7Di09bUoc8+pPsx4JXgEge2r0d9y+7lj6x3j4g==

read-pkg-up@^2.0.0:
version "2.0.0"
resolved "https://registry.npm.taobao.org/read-pkg-up/download/read-pkg-up-2.0.0.tgz"
Expand Down

0 comments on commit 840fe13

Please sign in to comment.