@@ -15,6 +15,7 @@ module Cardano.Wallet.WalletLayer
15
15
, RedeemAdaError (.. )
16
16
, CreateAddressError (.. )
17
17
, ValidateAddressError (.. )
18
+ , ImportAddressError (.. )
18
19
, CreateAccountError (.. )
19
20
, GetAccountError (.. )
20
21
, GetAccountsError (.. )
@@ -47,12 +48,12 @@ import Cardano.Wallet.API.Request.Filter (FilterOperations (..))
47
48
import Cardano.Wallet.API.Request.Sort (SortOperations (.. ))
48
49
import Cardano.Wallet.API.Response (SliceOf (.. ), WalletResponse )
49
50
import Cardano.Wallet.API.V1.Types (Account , AccountBalance ,
50
- AccountIndex , AccountUpdate , Address , ForceNtpCheck ,
51
- NewAccount , NewAddress , NewWallet , NodeInfo , NodeSettings ,
52
- PasswordUpdate , Payment , Redemption , SignedTransaction ,
53
- SpendingPassword , Transaction , UnsignedTransaction ,
54
- V1 (.. ), Wallet , WalletAddress , WalletId , WalletImport ,
55
- WalletUpdate )
51
+ AccountIndex , AccountUpdate , Address , BatchImportResult ,
52
+ ForceNtpCheck , NewAccount , NewAddress , NewWallet ,
53
+ NodeInfo , NodeSettings , PasswordUpdate , Payment ,
54
+ Redemption , SignedTransaction , SpendingPassword ,
55
+ Transaction , UnsignedTransaction , V1 (.. ), Wallet ,
56
+ WalletAddress , WalletId , WalletImport , WalletUpdate )
56
57
import qualified Cardano.Wallet.Kernel.Accounts as Kernel
57
58
import qualified Cardano.Wallet.Kernel.Addresses as Kernel
58
59
import Cardano.Wallet.Kernel.CoinSelection.FromGeneric
@@ -231,6 +232,31 @@ instance Buildable ValidateAddressError where
231
232
build (ValidateAddressDecodingFailed rawText) =
232
233
bprint (" ValidateAddressDecodingFailed " % build) rawText
233
234
235
+ data ImportAddressError =
236
+ ImportAddressError Kernel. ImportAddressError
237
+ | ImportAddressAddressDecodingFailed Text
238
+ -- ^ Decoding the input 'Text' as an 'Address' failed.
239
+ deriving Eq
240
+
241
+ -- | Unsound show instance needed for the 'Exception' instance.
242
+ instance Show ImportAddressError where
243
+ show = formatToString build
244
+
245
+ instance Exception ImportAddressError
246
+
247
+ instance Arbitrary ImportAddressError where
248
+ arbitrary = oneof [ ImportAddressError <$> arbitrary
249
+ , pure (ImportAddressAddressDecodingFailed " Ae2tdPwUPEZ18ZjTLnLVr9CEvUEUX4eW1LBHbxxx" )
250
+ ]
251
+
252
+ instance Buildable ImportAddressError where
253
+ build (ImportAddressError kernelError) =
254
+ bprint (" ImportAddressError " % build) kernelError
255
+ build (ImportAddressAddressDecodingFailed txt) =
256
+ bprint (" ImportAddressAddressDecodingFailed " % build) txt
257
+
258
+
259
+
234
260
------------------------------------------------------------
235
261
-- Errors when dealing with Accounts
236
262
------------------------------------------------------------
@@ -431,6 +457,10 @@ data PassiveWalletLayer m = PassiveWalletLayer
431
457
, getAddresses :: RequestParams -> m (SliceOf WalletAddress )
432
458
, validateAddress :: Text
433
459
-> m (Either ValidateAddressError WalletAddress )
460
+ , importAddresses :: WalletId
461
+ -> AccountIndex
462
+ -> [V1 Address ]
463
+ -> m (Either ImportAddressError (BatchImportResult (V1 Address )))
434
464
435
465
-- transactions
436
466
, getTransactions :: Maybe WalletId
0 commit comments