Skip to content

Commit 00bc749

Browse files
committed
fix: buffer issue, updating bip39 to use scure/bip32 - canary
1 parent d0208fa commit 00bc749

File tree

5 files changed

+3222
-8903
lines changed

5 files changed

+3222
-8903
lines changed

.husky/pre-push

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,76 @@
11
set -e
22

3+
# Check if local branch is behind remote and block push if so
4+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
5+
REMOTE="origin"
6+
7+
# Fetch latest from remote (only refs, no objects - much faster)
8+
git fetch --depth=1 --no-tags $REMOTE $BRANCH 2>/dev/null || true
9+
10+
# Check if remote branch exists
11+
if git rev-parse --verify $REMOTE/$BRANCH >/dev/null 2>&1; then
12+
LOCAL=$(git rev-parse HEAD)
13+
REMOTE_HEAD=$(git rev-parse $REMOTE/$BRANCH)
14+
BASE=$(git merge-base HEAD $REMOTE/$BRANCH)
15+
16+
if [ "$LOCAL" != "$REMOTE_HEAD" ] && [ "$BASE" = "$LOCAL" ]; then
17+
echo ""
18+
echo "ERROR: Your branch '$BRANCH' is behind '$REMOTE/$BRANCH'."
19+
echo ""
20+
echo "Please run: git pull --rebase"
21+
echo ""
22+
echo "This will replay your commits on top of the latest remote commits."
23+
echo "If there are conflicts, resolve them and run: git rebase --continue"
24+
echo ""
25+
exit 1
26+
fi
27+
28+
if [ "$LOCAL" != "$REMOTE_HEAD" ] && [ "$BASE" = "$REMOTE_HEAD" ]; then
29+
# Local is ahead, this is fine - we're pushing new commits
30+
:
31+
elif [ "$LOCAL" != "$REMOTE_HEAD" ] && [ "$BASE" != "$LOCAL" ] && [ "$BASE" != "$REMOTE_HEAD" ]; then
32+
echo ""
33+
echo "ERROR: Your branch '$BRANCH' has diverged from '$REMOTE/$BRANCH'."
34+
echo ""
35+
echo "Please run: git pull --rebase"
36+
echo ""
37+
echo "This will replay your commits on top of the latest remote commits."
38+
echo "If there are conflicts, resolve them and run: git rebase --continue"
39+
echo ""
40+
exit 1
41+
fi
42+
fi
43+
44+
# --- UNCOMMENT BELOW FOR AUTO-REBASE (instead of manual check above) ---
45+
# # Automatically run git pull --rebase if behind remote
46+
# BRANCH=$(git rev-parse --abbrev-ref HEAD)
47+
# REMOTE="origin"
48+
#
49+
# git fetch --depth=1 --no-tags $REMOTE $BRANCH 2>/dev/null || true
50+
#
51+
# if git rev-parse --verify $REMOTE/$BRANCH >/dev/null 2>&1; then
52+
# LOCAL=$(git rev-parse HEAD)
53+
# REMOTE_HEAD=$(git rev-parse $REMOTE/$BRANCH)
54+
# BASE=$(git merge-base HEAD $REMOTE/$BRANCH)
55+
#
56+
# if [ "$LOCAL" != "$REMOTE_HEAD" ] && [ "$BASE" != "$REMOTE_HEAD" ]; then
57+
# echo ""
58+
# echo "Your branch is behind or has diverged. Running git pull --rebase..."
59+
# echo ""
60+
# if ! git pull --rebase $REMOTE $BRANCH; then
61+
# echo ""
62+
# echo "ERROR: Rebase failed due to conflicts."
63+
# echo "Please resolve conflicts and run: git rebase --continue"
64+
# echo "Then try pushing again."
65+
# echo ""
66+
# exit 1
67+
# fi
68+
# echo ""
69+
# echo "Rebase successful. Continuing with push..."
70+
# echo ""
71+
# fi
72+
# fi
73+
# --- END AUTO-REBASE ---
74+
375
pnpm lint
476
pnpm build

packages/sdk-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@
340340
"@protobuf-ts/runtime": "^2.11.1",
341341
"@protobuf-ts/runtime-rpc": "^2.11.1",
342342
"@scure/base": "catalog:",
343+
"@scure/bip39": "catalog:",
343344
"axios": "catalog:",
344-
"bip39": "^3.1.0",
345345
"cosmjs-types": "0.9.0",
346346
"ethers": "catalog:",
347347
"http-status-codes": "catalog:",

packages/sdk-ts/src/core/accounts/PrivateKey.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { generateMnemonic } from 'bip39'
1+
import { generateMnemonic } from '@scure/bip39'
22
import { secp256k1 } from '@noble/curves/secp256k1'
33
import { toBytes, keccak256, hashTypedData } from 'viem'
4+
import { wordlist } from '@scure/bip39/wordlists/english'
45
import { GeneralException } from '@injectivelabs/exceptions'
56
import { ChainId, EvmChainId } from '@injectivelabs/ts-types'
67
import { Wallet, concat, getBytes, Signature, HDNodeWallet } from 'ethers'
@@ -39,7 +40,7 @@ export class PrivateKey {
3940
* @returns { privateKey: PrivateKey, mnemonic: string }
4041
*/
4142
static generate(): { privateKey: PrivateKey; mnemonic: string } {
42-
const mnemonic = generateMnemonic()
43+
const mnemonic = generateMnemonic(wordlist)
4344
const privateKey = PrivateKey.fromMnemonic(mnemonic)
4445

4546
return {

0 commit comments

Comments
 (0)