From a32ebd6bd216d73d90e6c5e0e644fc91d0e7623a Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Tue, 3 Jan 2023 14:28:40 -0400 Subject: [PATCH] fix: bigint --- lefthook.yml | 4 ---- package-lock.json | 10 +++++---- package.json | 55 ++++++++++++++++++++++++----------------------- src/index.tsx | 9 ++++---- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/lefthook.yml b/lefthook.yml index 065a491..96308c5 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -1,10 +1,6 @@ pre-commit: parallel: true commands: - lint: - files: git diff --name-only @{push} - glob: "*.{js,ts,jsx,tsx}" - run: npx eslint {files} types: files: git diff --name-only @{push} glob: "*.{js,ts, jsx, tsx}" diff --git a/package-lock.json b/package-lock.json index 5a9aab9..6df36f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,8 @@ "version": "0.0.9", "license": "MIT", "dependencies": { - "base-64": "^1.0.0" + "base-64": "^1.0.0", + "big-integer": "^1.6.51" }, "devDependencies": { "@arkweid/lefthook": "^0.7.7", @@ -5212,8 +5213,8 @@ }, "node_modules/big-integer": { "version": "1.6.51", - "dev": true, - "license": "Unlicense", + "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz", + "integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==", "engines": { "node": ">=0.6" } @@ -19921,7 +19922,8 @@ }, "big-integer": { "version": "1.6.51", - "dev": true + "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz", + "integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==" }, "bl": { "version": "5.0.0", diff --git a/package.json b/package.json index 1bddf82..0900818 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@waku/react-native", - "version": "0.0.9", + "version": "0.0.10", "description": "Waku React Native", "author": "Status Research & Development GMBH", "authors": [ @@ -54,31 +54,31 @@ "registry": "https://registry.npmjs.org/" }, "devDependencies": { - "@arkweid/lefthook": "^0.7.7", - "@babel/eslint-parser": "^7.18.2", - "@commitlint/config-conventional": "^17.0.2", - "@react-native-community/eslint-config": "^3.0.2", - "@release-it/conventional-changelog": "^5.0.0", - "@types/base-64": "^1.0.0", - "@types/jest": "^28.1.2", - "@types/react": "~17.0.21", - "@types/react-native": "0.68.0", - "commitlint": "^17.0.2", - "eslint": "^8.4.1", - "eslint-config-prettier": "^8.5.0", - "eslint-plugin-prettier": "^4.0.0", - "jest": "^28.1.1", - "pod-install": "^0.1.0", - "prettier": "^2.0.5", - "react": "17.0.2", - "react-native": "0.68.2", - "react-native-builder-bob": "^0.18.3", - "release-it": "^15.0.0", - "typescript": "^4.5.2" - }, - "resolutions": { - "@types/react": "17.0.21" - }, + "@arkweid/lefthook": "^0.7.7", + "@babel/eslint-parser": "^7.18.2", + "@commitlint/config-conventional": "^17.0.2", + "@react-native-community/eslint-config": "^3.0.2", + "@release-it/conventional-changelog": "^5.0.0", + "@types/base-64": "^1.0.0", + "@types/jest": "^28.1.2", + "@types/react": "~17.0.21", + "@types/react-native": "0.68.0", + "commitlint": "^17.0.2", + "eslint": "^8.4.1", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-prettier": "^4.0.0", + "jest": "^28.1.1", + "pod-install": "^0.1.0", + "prettier": "^2.0.5", + "react": "17.0.2", + "react-native": "0.68.2", + "react-native-builder-bob": "^0.18.3", + "release-it": "^15.0.0", + "typescript": "^4.5.2" + }, + "resolutions": { + "@types/react": "17.0.21" + }, "peerDependencies": { "react": "*", "react-native": "*" @@ -158,6 +158,7 @@ ] }, "dependencies": { - "base-64": "^1.0.0" + "base-64": "^1.0.0", + "big-integer": "^1.6.51" } } diff --git a/src/index.tsx b/src/index.tsx index 93d64c2..6055d55 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,5 +1,6 @@ import { NativeModules, Platform, NativeEventEmitter } from 'react-native'; import { decode, encode } from 'base-64'; +import bigInt from 'big-integer'; const LINKING_ERROR = `The package '@waku/react-native' doesn't seem to be linked. Make sure: \n\n` + @@ -22,7 +23,7 @@ export function multiply(a: number, b: number): Promise { return ReactNative.multiply(a, b); } -const OneMillion = BigInt(1_000_000); +const OneMillion = bigInt(1_000_000); export class WakuMessage { payload: Uint8Array = new Uint8Array(); @@ -36,7 +37,7 @@ export class WakuMessage { contentTopic: this.contentTopic, version: this.version, timestamp: this.timestamp - ? (BigInt(this.timestamp.valueOf()) * OneMillion).toString(10) + ? bigInt(this.timestamp.valueOf()).multiply(OneMillion).toString(10) : 0, payload: b64encoded, }; @@ -715,10 +716,10 @@ export function storeQuery( pubsubTopic: query.pubsubTopic, contentFilters: query.contentFilters, startTime: query.startTime - ? (BigInt(query.startTime.valueOf()) * OneMillion).toString(10) + ? bigInt(query.startTime.valueOf()).multiply(OneMillion).toString(10) : 0, endTime: query.endTime - ? (BigInt(query.endTime.valueOf()) * OneMillion).toString(10) + ? bigInt(query.endTime.valueOf()).multiply(OneMillion).toString(10) : 0, pagingOptions: query.pagingOptions, });