fix: bigint

This commit is contained in:
Richard Ramos 2023-01-03 14:28:40 -04:00
parent f7022b9c7b
commit a32ebd6bd2
No known key found for this signature in database
GPG Key ID: 1CE87DB518195760
4 changed files with 39 additions and 39 deletions

View File

@ -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}"

10
package-lock.json generated
View File

@ -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",

View File

@ -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"
}
}

View File

@ -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<number> {
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,
});