File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import Geohash from 'latlon-geohash';
66import thirdParties from '../../static/thirdparties.json' ;
77import currencyDict from '../../static/assets/currencies.json' ;
88import defaultFederation from '../../static/federation.json' ;
9+ import hashStringToInteger from './stringToInteger' ;
910
1011const eventToPublicOrder = (
1112 event : Event ,
@@ -48,7 +49,6 @@ const eventToPublicOrder = (
4849
4950 publicOrder . coordinatorShortAlias = coordinator ?. shortAlias ;
5051 publicOrder . federated = coordinator ?. federated ?? false ;
51- publicOrder . id = parseInt ( dTag [ 1 ] , 16 ) ;
5252
5353 event . tags . forEach ( ( tag ) => {
5454 switch ( tag [ 0 ] ) {
@@ -99,6 +99,8 @@ const eventToPublicOrder = (
9999 if ( platform [ 1 ] === 'robosats' ) {
100100 const orderUrl = tag [ 1 ] . split ( '/' ) ;
101101 publicOrder . id = parseInt ( orderUrl [ orderUrl . length - 1 ] ?? '0' ) ;
102+ } else {
103+ publicOrder . id = hashStringToInteger ( tag [ 1 ] + dTag [ 1 ] ) ;
102104 }
103105
104106 if ( tag [ 1 ] !== '' ) publicOrder . link = tag [ 1 ] ;
Original file line number Diff line number Diff line change 1+ export default function hashStringToInteger ( input : string ) : number {
2+ let hash = 0 ;
3+
4+ for ( let i = 0 ; i < input . length ; i ++ ) {
5+ hash = ( hash << 5 ) - hash + input . charCodeAt ( i ) ; // Hashing algorithm
6+ hash |= 0 ; // Convert to 32-bit integer
7+ }
8+
9+ return Math . abs ( hash ) ; // Return a positive integer
10+ }
You can’t perform that action at this time.
0 commit comments