@@ -23,7 +23,9 @@ use lnpbp::bp;
23
23
use lnpbp:: bp:: psbt:: ProprietaryKeyMap ;
24
24
use lnpbp:: lnp:: presentation:: Encode ;
25
25
use lnpbp:: lnp:: { Session , Unmarshall } ;
26
- use lnpbp:: rgb:: { AtomicValue , Consignment , ContractId , PSBT_OUT_PUBKEY } ;
26
+ use lnpbp:: rgb:: {
27
+ AtomicValue , Consignment , ContractId , Genesis , PSBT_OUT_PUBKEY ,
28
+ } ;
27
29
28
30
use super :: { Error , Runtime } ;
29
31
use crate :: api:: {
@@ -141,7 +143,7 @@ impl Runtime {
141
143
let out_file = File :: create ( & transaction_file)
142
144
. expect ( "can't create output transaction file" ) ;
143
145
transfer. psbt . consensus_encode ( out_file) ?;
144
- println ! (
146
+ info ! (
145
147
"Transfer succeeded, consignment data are written to {:?}, partially signed witness transaction to {:?}" ,
146
148
consignment_file, transaction_file
147
149
) ;
@@ -165,8 +167,7 @@ impl Runtime {
165
167
match & * self . command ( Request :: Accept ( api) ) ? {
166
168
Reply :: Failure ( failure) => Err ( Error :: Reply ( failure. clone ( ) ) ) ,
167
169
Reply :: Success => {
168
- println ! ( "Accept succeeded" ) ;
169
-
170
+ info ! ( "Accept command succeeded" ) ;
170
171
Ok ( ( ) )
171
172
}
172
173
_ => Err ( Error :: UnexpectedResponse ) ,
@@ -177,8 +178,7 @@ impl Runtime {
177
178
match & * self . command ( Request :: Validate ( consignment) ) ? {
178
179
Reply :: Failure ( failure) => Err ( Error :: Reply ( failure. clone ( ) ) ) ,
179
180
Reply :: Success => {
180
- println ! ( "Validate succeeded" ) ;
181
-
181
+ info ! ( "Validation succeeded" ) ;
182
182
Ok ( ( ) )
183
183
}
184
184
_ => Err ( Error :: UnexpectedResponse ) ,
@@ -191,11 +191,7 @@ impl Runtime {
191
191
) -> Result < BTreeMap < OutPoint , Vec < AtomicValue > > , Error > {
192
192
match & * self . command ( Request :: Allocations ( contract_id) ) ? {
193
193
Reply :: Failure ( failure) => Err ( Error :: Reply ( failure. clone ( ) ) ) ,
194
- Reply :: Allocations ( response) => {
195
- println ! ( "Asset allocations succeeded" ) ;
196
-
197
- Ok ( response. clone ( ) )
198
- }
194
+ Reply :: Allocations ( response) => Ok ( response. clone ( ) ) ,
199
195
_ => Err ( Error :: UnexpectedResponse ) ,
200
196
}
201
197
}
@@ -206,22 +202,40 @@ impl Runtime {
206
202
) -> Result < BTreeMap < ContractId , Vec < AtomicValue > > , Error > {
207
203
match & * self . command ( Request :: Assets ( outpoint) ) ? {
208
204
Reply :: Failure ( failure) => Err ( Error :: Reply ( failure. clone ( ) ) ) ,
209
- Reply :: Assets ( response) => {
210
- println ! ( "Outpoint assets succeeded" ) ;
205
+ Reply :: Assets ( response) => Ok ( response. clone ( ) ) ,
206
+ _ => Err ( Error :: UnexpectedResponse ) ,
207
+ }
208
+ }
211
209
212
- Ok ( response. clone ( ) )
210
+ pub fn export_asset (
211
+ & mut self ,
212
+ asset_id : ContractId ,
213
+ ) -> Result < Genesis , Error > {
214
+ match & * self . command ( Request :: ExportAsset ( asset_id) ) ? {
215
+ Reply :: Failure ( failure) => Err ( Error :: Reply ( failure. clone ( ) ) ) ,
216
+ Reply :: Genesis ( response) => Ok ( response. clone ( ) ) ,
217
+ _ => Err ( Error :: UnexpectedResponse ) ,
218
+ }
219
+ }
220
+
221
+ pub fn import_asset ( & mut self , genesis : Genesis ) -> Result < ( ) , Error > {
222
+ match & * self . command ( Request :: ImportAsset ( genesis) ) ? {
223
+ Reply :: Failure ( failure) => Err ( Error :: Reply ( failure. clone ( ) ) ) ,
224
+ Reply :: Success => {
225
+ info ! ( "Asset import succeeded" ) ;
226
+ Ok ( ( ) )
213
227
}
214
228
_ => Err ( Error :: UnexpectedResponse ) ,
215
229
}
216
230
}
217
231
218
- pub fn sync (
232
+ pub fn list_assets (
219
233
& mut self ,
220
234
data_format : DataFormat ,
221
235
) -> Result < reply:: SyncFormat , Error > {
222
236
match & * self . command ( Request :: Sync ( data_format) ) ? {
223
- Reply :: Sync ( data ) => Ok ( data . clone ( ) ) ,
224
- Reply :: Failure ( failmsg ) => Err ( Error :: Reply ( failmsg . clone ( ) ) ) ,
237
+ Reply :: Failure ( failure ) => Err ( Error :: Reply ( failure . clone ( ) ) ) ,
238
+ Reply :: Sync ( response ) => Ok ( response . clone ( ) ) ,
225
239
_ => Err ( Error :: UnexpectedResponse ) ,
226
240
}
227
241
}
0 commit comments