Skip to content

Commit cddc451

Browse files
committed
chore: upgrade typescript & fix type errors
1 parent 2092279 commit cddc451

File tree

6 files changed

+26
-34
lines changed

6 files changed

+26
-34
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"e2e:test:android-release": "detox test --configuration android.release",
2020
"lint:check": "biome check ./src/**/*.{js,jsx,ts,tsx}",
2121
"lint:fix": "biome check --write ./src/**/*.{js,jsx,ts,tsx}",
22-
"tsc:check": "tsc -p tsconfig.json --noEmit",
22+
"tsc:check": "tsc",
2323
"clean": "yarn clean:rn && yarn clean:ios && yarn clean:android && yarn start --reset-cache",
2424
"clean:rn": "watchman watch-del-all && npx del-cli node_modules && yarn && npx del-cli /tmp/metro-*",
2525
"clean:android": "cd android && npx del-cli build app/build app/release",
@@ -135,7 +135,6 @@
135135
"@react-native/babel-preset": "^0.76.7",
136136
"@react-native/metro-config": "^0.76.7",
137137
"@react-native/typescript-config": "^0.76.7",
138-
"@types/b4a": "^1.6.4",
139138
"@types/bip21": "^2.0.3",
140139
"@types/jest": "^29.5.12",
141140
"@types/lodash": "^4.17.0",
@@ -162,7 +161,7 @@
162161
"reactotron-react-native": "^5.1.10",
163162
"reactotron-react-native-mmkv": "^0.2.7",
164163
"reactotron-redux": "^3.1.9",
165-
"typescript": "5.4.5"
164+
"typescript": "5.7.3"
166165
},
167166
"react-native": {
168167
"net": "react-native-tcp-socket",

src/components/SlashtagsProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import SlashtagsProfile from '@synonymdev/slashtags-profile';
33
import { format, parse } from '@synonymdev/slashtags-url';
44
import type { Client as IWebRelayClient } from '@synonymdev/web-relay';
55
import { Client, Store } from '@synonymdev/web-relay/lib/client';
6-
import b4a from 'b4a';
76
import React, { ReactElement, useEffect, useState } from 'react';
87
import { createContext } from 'react';
98

@@ -59,7 +58,8 @@ export const SlashtagsProvider = ({
5958
});
6059
return;
6160
}
62-
const primaryKey = b4a.from(primaryKeyRes.value, 'hex');
61+
const primaryKeyBuffer = Buffer.from(primaryKeyRes.value, 'hex');
62+
const primaryKey = new Uint8Array(primaryKeyBuffer);
6363
const keyPair = KeyChain.createKeyPair(primaryKey);
6464

6565
webRelayClient = new Client({

src/utils/slashtags/slashpay.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import Client from '@synonymdev/web-relay/types/lib/client/index';
44
import { default as Ajv } from 'ajv';
5-
import b4a from 'b4a';
65

76
import { SlashPayConfig } from '../../store/types/slashtags';
87

@@ -130,7 +129,7 @@ export default class SlashpayConfig {
130129
* @returns {Uint8Array}
131130
*/
132131
function encode(config: SlashPayConfig): Uint8Array {
133-
return b4a.from(JSON.stringify(config));
132+
return Uint8Array.from(Buffer.from(JSON.stringify(config)));
134133
}
135134

136135
/**
@@ -142,8 +141,10 @@ function encode(config: SlashPayConfig): Uint8Array {
142141
*/
143142
function decode(buf: Uint8Array): SlashPayConfig | null {
144143
try {
145-
return JSON.parse(b4a.toString(buf));
146-
} catch {
144+
const text = Buffer.from(buf).toString();
145+
return JSON.parse(text);
146+
} catch (e) {
147+
console.log('Error decoding slashpay config', e);
147148
return null;
148149
}
149150
}

src/utils/wallet/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,10 @@ const setKeychainSlashtagsPrimaryKey = async (seed: Buffer): Promise<void> => {
356356
};
357357

358358
export const seedHash = (seed: Buffer): string => {
359-
return bitcoin.crypto
360-
.sha256(Buffer.concat([BITKIT_WALLET_SEED_HASH_PREFIX, seed]))
361-
.toString('hex');
359+
const prefix = new Uint8Array(BITKIT_WALLET_SEED_HASH_PREFIX);
360+
const seedArray = new Uint8Array(seed);
361+
const buffer = Buffer.concat([prefix, seedArray]);
362+
return bitcoin.crypto.sha256(buffer).toString('hex');
362363
};
363364

364365
export const ldkSeed = async (

tsconfig.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
"alwaysStrict": true,
66
"forceConsistentCasingInFileNames": true,
77
"lib": ["esnext"],
8+
"module": "esnext",
9+
"noEmit": true,
810
"noImplicitThis": true,
9-
"removeComments": true,
1011
"strictNullChecks": true,
1112
"strictFunctionTypes": true,
1213
"strictPropertyInitialization": true,
@@ -17,6 +18,6 @@
1718
// TODO: remove these rules & add types
1819
"noImplicitAny": false,
1920
"useUnknownInCatchVariables": false,
20-
"module": "esnext",
21-
}
21+
},
22+
"exclude": ["**/node_modules", "**/.*/"],
2223
}

yarn.lock

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4762,15 +4762,6 @@ __metadata:
47624762
languageName: node
47634763
linkType: hard
47644764

4765-
"@types/b4a@npm:^1.6.4":
4766-
version: 1.6.4
4767-
resolution: "@types/b4a@npm:1.6.4"
4768-
dependencies:
4769-
"@types/node": "*"
4770-
checksum: 2ed2cd7befc50576a4dba036b45210ee12bba52a412f1f3365d2f286eb58e838ef9e23b97edb9703ef7d8fca0aa090d007d9680eff46bc434947b736fbb27537
4771-
languageName: node
4772-
linkType: hard
4773-
47744765
"@types/babel__core@npm:^7.1.14":
47754766
version: 7.20.1
47764767
resolution: "@types/babel__core@npm:7.20.1"
@@ -5933,7 +5924,6 @@ __metadata:
59335924
"@synonymdev/slashtags-profile": 2.0.0
59345925
"@synonymdev/slashtags-url": 1.0.1
59355926
"@synonymdev/web-relay": 1.0.7
5936-
"@types/b4a": ^1.6.4
59375927
"@types/bip21": ^2.0.3
59385928
"@types/jest": ^29.5.12
59395929
"@types/lodash": ^4.17.0
@@ -6020,7 +6010,7 @@ __metadata:
60206010
rn-qr-generator: 1.4.3
60216011
sodium-react-native-direct: 0.4.4
60226012
styled-components: 5.3.11
6023-
typescript: 5.4.5
6013+
typescript: 5.7.3
60246014
url-parse: 1.5.10
60256015
uuid: 9.0.1
60266016
web-streams-polyfill: 3.3.3
@@ -14754,23 +14744,23 @@ __metadata:
1475414744
languageName: node
1475514745
linkType: hard
1475614746

14757-
"typescript@npm:5.4.5":
14758-
version: 5.4.5
14759-
resolution: "typescript@npm:5.4.5"
14747+
"typescript@npm:5.7.3":
14748+
version: 5.7.3
14749+
resolution: "typescript@npm:5.7.3"
1476014750
bin:
1476114751
tsc: bin/tsc
1476214752
tsserver: bin/tsserver
14763-
checksum: 53c879c6fa1e3bcb194b274d4501ba1985894b2c2692fa079db03c5a5a7140587a1e04e1ba03184605d35f439b40192d9e138eb3279ca8eee313c081c8bcd9b0
14753+
checksum: 6c38b1e989918e576f0307e6ee013522ea480dfce5f3ca85c9b2d8adb1edeffd37f4f30cd68de0c38a44563d12ba922bdb7e36aa2dac9c51de5d561e6e9a2e9c
1476414754
languageName: node
1476514755
linkType: hard
1476614756

14767-
"typescript@patch:typescript@5.4.5#~builtin<compat/typescript>":
14768-
version: 5.4.5
14769-
resolution: "typescript@patch:typescript@npm%3A5.4.5#~builtin<compat/typescript>::version=5.4.5&hash=29ae49"
14757+
"typescript@patch:typescript@5.7.3#~builtin<compat/typescript>":
14758+
version: 5.7.3
14759+
resolution: "typescript@patch:typescript@npm%3A5.7.3#~builtin<compat/typescript>::version=5.7.3&hash=29ae49"
1477014760
bin:
1477114761
tsc: bin/tsc
1477214762
tsserver: bin/tsserver
14773-
checksum: 2373c693f3b328f3b2387c3efafe6d257b057a142f9a79291854b14ff4d5367d3d730810aee981726b677ae0fd8329b23309da3b6aaab8263dbdccf1da07a3ba
14763+
checksum: 633cd749d6cd7bc842c6b6245847173bba99742a60776fae3c0fbcc0d1733cd51a733995e5f4dadd8afb0e64e57d3c7dbbeae953a072ee303940eca69e22f311
1477414764
languageName: node
1477514765
linkType: hard
1477614766

0 commit comments

Comments
 (0)