@@ -4,6 +4,8 @@ import { exit } from 'process'
4
4
import { isSimpleWallet , isV3Wallet } from '../../service/identity'
5
5
import { Identity } from '../../service/identity/types'
6
6
import { pickStamp } from '../../service/stamp'
7
+ import { getFieldOrNull } from '../../utils'
8
+ import { createSpinner } from '../../utils/spinner'
7
9
import { createKeyValue } from '../../utils/text'
8
10
import { FeedCommand } from './feed-command'
9
11
@@ -26,26 +28,39 @@ export class Print extends FeedCommand implements LeafCommand {
26
28
await super . init ( )
27
29
28
30
const topic = this . topic || this . bee . makeFeedTopic ( this . topicString )
29
- this . console . info ( 'Looking up feed topic ' + topic + '...' )
30
- const addressString = this . address || ( await this . getAddressString ( ) )
31
- const reader = this . bee . makeFeedReader ( 'sequence' , topic , addressString )
32
- const { reference, feedIndex, feedIndexNext } = await reader . download ( )
31
+ const spinner = createSpinner ( `Looking up feed topic ${ topic } ` )
32
+ spinner . start ( )
33
+ try {
34
+ const addressString = this . address || ( await this . getAddressString ( ) )
35
+ const reader = this . bee . makeFeedReader ( 'sequence' , topic , addressString )
36
+ const { reference, feedIndex, feedIndexNext } = await reader . download ( )
37
+
38
+ if ( ! this . stamp ) {
39
+ spinner . stop ( )
40
+ this . stamp = await pickStamp ( this . beeDebug , this . console )
41
+ spinner . start ( )
42
+ }
33
43
34
- if ( ! this . stamp ) {
35
- this . stamp = await pickStamp ( this . beeDebug , this . console )
44
+ const { reference : manifest } = await this . bee . createFeedManifest ( this . stamp , 'sequence' , topic , addressString )
45
+
46
+ spinner . stop ( )
47
+ this . console . verbose ( createKeyValue ( 'Chunk Reference' , reference ) )
48
+ this . console . verbose ( createKeyValue ( 'Chunk Reference URL' , `${ this . bee . url } /bzz/${ reference } /` ) )
49
+ this . console . verbose ( createKeyValue ( 'Feed Index' , feedIndex ) )
50
+ this . console . verbose ( createKeyValue ( 'Next Index' , feedIndexNext ) )
51
+ this . console . verbose ( createKeyValue ( 'Feed Manifest' , manifest ) )
52
+
53
+ this . console . quiet ( manifest )
54
+ this . console . log ( createKeyValue ( 'Topic' , `${ topic } ` ) )
55
+ this . console . log ( createKeyValue ( 'Feed Manifest URL' , `${ this . bee . url } /bzz/${ manifest } /` ) )
56
+ this . console . log ( createKeyValue ( 'Number of Updates' , parseInt ( feedIndex , 10 ) + 1 ) )
57
+ } catch ( error ) {
58
+ spinner . stop ( )
59
+ const message = getFieldOrNull ( error , 'message' )
60
+ throw Error ( `Feed topic lookup error: ${ message || 'unknown' } ` )
61
+ } finally {
62
+ spinner . stop ( )
36
63
}
37
-
38
- const { reference : manifest } = await this . bee . createFeedManifest ( this . stamp , 'sequence' , topic , addressString )
39
-
40
- this . console . verbose ( createKeyValue ( 'Chunk Reference' , reference ) )
41
- this . console . verbose ( createKeyValue ( 'Chunk Reference URL' , `${ this . bee . url } /bzz/${ reference } /` ) )
42
- this . console . verbose ( createKeyValue ( 'Feed Index' , feedIndex ) )
43
- this . console . verbose ( createKeyValue ( 'Next Index' , feedIndexNext ) )
44
- this . console . verbose ( createKeyValue ( 'Feed Manifest' , manifest ) )
45
-
46
- this . console . quiet ( manifest )
47
- this . console . log ( createKeyValue ( 'Feed Manifest URL' , `${ this . bee . url } /bzz/${ manifest } /` ) )
48
- this . console . log ( createKeyValue ( 'Number of Updates' , parseInt ( feedIndex , 10 ) + 1 ) )
49
64
}
50
65
51
66
private async getAddressString ( ) : Promise < string > {
@@ -80,7 +95,8 @@ export class Print extends FeedCommand implements LeafCommand {
80
95
81
96
return wallet . address
82
97
} else if ( isSimpleWallet ( wallet , identityType ) ) {
83
- const ethereumWallet = Wallet . fromPrivateKey ( Buffer . from ( wallet . privateKey , 'hex' ) )
98
+ const privateKey = wallet . privateKey . replace ( '0x' , '' )
99
+ const ethereumWallet = Wallet . fromPrivateKey ( Buffer . from ( privateKey , 'hex' ) )
84
100
85
101
return ethereumWallet . getAddressString ( )
86
102
} else {
0 commit comments