File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,13 @@ and this project adheres to
66
77## [ Unreleased]
88
9+ ### Fixed
10+
11+ - @cosmjs/faucet : ` isValidAddress ` now accepts addresses up to 128 bytes (e.g.
12+ for Penumbra). ([ #1674 ] )
13+
14+ [ #1674 ] : https://github.com/cosmos/cosmjs/pull/1674
15+
916### Added
1017
1118- @cosmjs/tendermint-rpc : ` Comet38Client ` is now used to connect to CometBFT
Original file line number Diff line number Diff line change @@ -11,6 +11,15 @@ describe("isValidAddress", () => {
1111 ) ;
1212 } ) ;
1313
14+ it ( "accepts a Penumbra compat address" , ( ) => {
15+ expect (
16+ isValidAddress (
17+ "penumbracompat11ld2kghffzgwq4597ejpgmnwxa7ju0cndytuxtsjh8qhjyfuwq0rwd5flnw4a3fgclw7m5puh50nskn2c88flhne2hzchnpxru609d5wgmqqvhdf0sy2tktqfcm2p2tmxeuc86n" ,
18+ "penumbracompat1" ,
19+ ) ,
20+ ) . toBe ( true ) ;
21+ } ) ;
22+
1423 it ( "rejects an invalid address" , ( ) => {
1524 expect ( isValidAddress ( "cosmos1fail" , "cosmos" ) ) . toBe ( false ) ;
1625 } ) ;
Original file line number Diff line number Diff line change 11import { fromBech32 } from "@cosmjs/encoding" ;
22
3+ // Penumbra are up to 150 chars. ibc-go has a limit of 2048.
4+ // See https://github.com/cosmos/cosmjs/pull/1674
5+ const lengthLimit = 512 ;
6+
37export function isValidAddress ( input : string , requiredPrefix : string ) : boolean {
48 try {
5- const { prefix, data } = fromBech32 ( input ) ;
9+ const { prefix, data } = fromBech32 ( input , lengthLimit ) ;
610 if ( prefix !== requiredPrefix ) {
711 return false ;
812 }
9- return data . length >= 20 && data . length <= 32 ;
13+ return data . length >= 20 && data . length <= 128 ;
1014 } catch {
1115 return false ;
1216 }
You can’t perform that action at this time.
0 commit comments