Skip to content

Commit 9d7b775

Browse files
Release 0.2.1 (#26)
* Fix/list transactions order param (#19) * list transactions query params * Task/psgs 55 improve coverage (#20) * Task/improve api params body spec (#21) * Testing api body, plus bug fix #PSGS-55 * Task/psgs 58 (#22) * Task/psgs 51 (#23) * Re examine the command line help PSGS-51 * nullable codecs fixes. (#24) * Pretty print PSGS-63 Co-authored-by: Maciej Bąk <maciej.bak.85@gmail.com>
1 parent 8b9a204 commit 9d7b775

20 files changed

Lines changed: 1274 additions & 445 deletions

.github/workflows/publish.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
name: Publish to Maven
22

3-
env:
4-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5-
SONA_USER: ${{ secrets.SONA_USER }}
6-
SONA_PASS: ${{ secrets.SONA_PASS }}
7-
83
on:
94
push:
105
tags:
@@ -14,13 +9,18 @@ jobs:
149
package:
1510
runs-on: ubuntu-latest
1611
steps:
12+
- name: Load Variables
13+
id: load_envvars
14+
run: |
15+
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
16+
echo "GPG_SIGNING_KEY=${{ secrets.GPG_SIGNING_KEY }}" >> $GITHUB_ENV
17+
echo "SONA_USER=${{ secrets.SONA_USER }}" >> $GITHUB_ENV
18+
echo "SONA_PASS=${{ secrets.SONA_PASS }}" >> $GITHUB_ENV
1719
- name: Configure GPG Key
1820
run: |
1921
mkdir -p ~/.gnupg/
2022
printf "$GPG_SIGNING_KEY" | base64 --decode > ~/.gnupg/private.key
2123
gpg --import --no-tty --batch --yes ~/.gnupg/private.key
22-
env:
23-
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
2424
- uses: actions/checkout@v2
2525
- name: Package
2626
uses: actions/setup-java@v1.4.2

.github/workflows/test.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: Clean, build, test, coverage
22

3-
env:
4-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5-
63
on:
74
push:
85
branches:
@@ -17,21 +14,23 @@ jobs:
1714
test:
1815
runs-on: ubuntu-latest
1916
steps:
17+
- name: Load Variables
18+
id: load_envvars
19+
run: |
20+
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
21+
echo "BASE_URL=${{ secrets.BASE_URL }}" >> $GITHUB_ENV
22+
echo "CARDANO_API_WALLET_1_PASSPHRASE=${{ secrets.CARDANO_API_WALLET_1_PASSPHRASE }}" >> $GITHUB_ENV
23+
echo "CARDANO_API_WALLET_1_MNEMONIC=${{ secrets.CARDANO_API_WALLET_1_MNEMONIC }}" >> $GITHUB_ENV
24+
echo "CARDANO_API_WALLET_2_MNEMONIC=${{ secrets.CARDANO_API_WALLET_2_MNEMONIC }}" >> $GITHUB_ENV
25+
echo "CARDANO_API_WALLET_3_MNEMONIC=${{ secrets.CARDANO_API_WALLET_3_MNEMONIC }}" >> $GITHUB_ENV
26+
echo "CARDANO_API_WALLET_3_MNEMONIC_SECONDARY=${{ secrets.CARDANO_API_WALLET_3_MNEMONIC_SECONDARY }}" >> $GITHUB_ENV
27+
echo "CARDANO_API_WALLET_3_PASSPHRASE=${{ secrets.CARDANO_API_WALLET_3_PASSPHRASE }}" >> $GITHUB_ENV
2028
- uses: actions/checkout@v2
2129
- name: Run tests
22-
uses: actions/setup-java@v1.4.2
30+
uses: actions/setup-java@v1.4.3
2331
with:
2432
java-version: '11.0.8'
2533
- run: sbt coverage test it:test coverageReport
26-
env:
27-
BASE_URL: ${{ secrets.BASE_URL }}
28-
CARDANO_API_WALLET_1_PASSPHRASE: ${{ secrets.CARDANO_API_WALLET_1_PASSPHRASE }}
29-
CARDANO_API_WALLET_1_MNEMONIC: ${{ secrets.CARDANO_API_WALLET_1_MNEMONIC }}
30-
CARDANO_API_WALLET_2_MNEMONIC: ${{ secrets.CARDANO_API_WALLET_2_MNEMONIC }}
31-
CARDANO_API_WALLET_3_MNEMONIC: ${{ secrets.CARDANO_API_WALLET_3_MNEMONIC }}
32-
CARDANO_API_WALLET_3_MNEMONIC_SECONDARY: ${{ secrets.CARDANO_API_WALLET_3_MNEMONIC_SECONDARY }}
33-
CARDANO_API_WALLET_3_PASSPHRASE: ${{ secrets.CARDANO_API_WALLET_3_PASSPHRASE }}
34-
3534
- name: Archive code coverage results
3635
uses: actions/upload-artifact@v2
3736
with:

build.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ lazy val rootProject = (project in file("."))
2323
licenses := Seq("APL2" -> url("https://www.apache.org/licenses/LICENSE-2.0.txt")),
2424
description := "A java/scala wrapper for the cardano wallet backend API",
2525
usePgpKeyHex("75E12F006A3F08C757EE8343927AE95EEEF4A02F"),
26+
isSnapshot := false,
2627
publishTo := Some {
2728
// publish to the sonatype repository
2829
val sonaUrl = "https://oss.sonatype.org/"
@@ -51,4 +52,4 @@ lazy val rootProject = (project in file("."))
5152
"commons-codec" % "commons-codec" % commonsCodecVersion,
5253
"org.scalatest" %% "scalatest" % scalaTestVersion % "it, test",
5354
)
54-
)
55+
)

cmdline.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ VER=0.1.3-SNAPSHOT
55
#BASE_URL="http://localhost:8090/v2/"
66

77
#run sbt assembly to create this jar
8-
exec java -jar target/scala-2.13/psg-cardano-wallet-api-assembly-${VER}.jar -baseUrl ${BASE_URL} "$@"
8+
NEWEST_JAR_NAME=`ls target/scala-2.13/ -Frt | egrep 'psg-cardano-wallet-api-assembly.+(jar)$' | tail -n 1`
9+
#-baseUrl ${BASE_URL}
10+
exec java -jar target/scala-2.13/${NEWEST_JAR_NAME} "$@"

src/it/scala/iog/psg/cardano/CardanoApiMainITSpec.scala

Lines changed: 231 additions & 139 deletions
Large diffs are not rendered by default.

src/main/java/iog/psg/cardano/jpi/CardanoApi.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,15 @@ public CompletionStage<CardanoApiCodec.FundPaymentsResponse> fundPayments(
247247
*/
248248
public CompletionStage<List<CardanoApiCodec.WalletAddressId>> listAddresses(
249249
String walletId, AddressFilter addressFilter) throws CardanoApiException {
250-
Enumeration.Value v = CardanoApiCodec.AddressFilter$.MODULE$.Value(addressFilter.name().toLowerCase());
250+
251+
Optional<Enumeration.Value> addressFilterOpt = Optional.empty();
252+
if (addressFilter != null) {
253+
Enumeration.Value v = CardanoApiCodec.AddressFilter$.MODULE$.Value(addressFilter.name().toLowerCase());
254+
addressFilterOpt = Optional.of(v);
255+
}
256+
251257
return helpExecute.execute(
252-
api.listAddresses(walletId, scala.Option.apply(v))).thenApply(CollectionConverters::asJava);
258+
api.listAddresses(walletId, option(addressFilterOpt))).thenApply(CollectionConverters::asJava);
253259
}
254260

255261
/**

src/main/scala/iog/psg/cardano/CardanoApi.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,11 @@ class CardanoApi(baseUriWithPort: String)(implicit ec: ExecutionContext, as: Act
222222
val queries =
223223
Seq("start", "end", "order", "minWithdrawal").zip(Seq(start, end, order, minWithdrawal))
224224
.collect {
225-
case (queryParamName, Some(o: Order)) => queryParamName -> o.toString
225+
case (queryParamName, order: Order) => queryParamName -> order.toString
226226
case (queryParamName, Some(dt: ZonedDateTime)) => queryParamName -> zonedDateToString(dt)
227227
case (queryParamName, Some(minWith: Int)) => queryParamName -> minWith.toString
228228
}
229229

230-
231230
val uriWithQueries = baseUri.withQuery(Query(queries: _*))
232231

233232
CardanoApiRequest(

src/main/scala/iog/psg/cardano/CardanoApiCodec.scala

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,18 @@ object CardanoApiCodec {
6363
private[cardano] implicit val decodeDelegationStatus: Decoder[DelegationStatus] = Decoder.decodeString.map(DelegationStatus.withName)
6464
private[cardano] implicit val encodeDelegationStatus: Encoder[DelegationStatus] = (a: DelegationStatus) => Json.fromString(a.toString)
6565

66-
private[cardano] implicit val decodeTxMetadataOut: Decoder[TxMetadataOut] = Decoder.decodeJson.map(TxMetadataOut)
66+
private[cardano] implicit val decodeTxMetadataOut: Decoder[TxMetadataOut] = Decoder.decodeJson.map(TxMetadataOut.apply)
6767
private[cardano] implicit val decodeKeyMetadata: KeyDecoder[MetadataKey] = (key: String) => Some(MetadataValueStr(key))
6868

69+
private[cardano] implicit val encodeDelegationNext: Encoder[DelegationNext] = dropNulls(deriveConfiguredEncoder)
70+
private[cardano] implicit val encodeDelegationActive: Encoder[DelegationActive] = dropNulls(deriveConfiguredEncoder)
71+
private[cardano] implicit val encodeNetworkTip: Encoder[NetworkTip] = dropNulls(deriveConfiguredEncoder)
72+
private[cardano] implicit val encodeNodeTip: Encoder[NodeTip] = dropNulls(deriveConfiguredEncoder)
73+
private[cardano] implicit val encodeSyncStatus: Encoder[SyncStatus] = dropNulls(deriveConfiguredEncoder)
74+
private[cardano] implicit val encodeCreateTransactionResponse: Encoder[CreateTransactionResponse] = dropNulls(deriveConfiguredEncoder)
75+
private[cardano] implicit val encodeWallet: Encoder[Wallet] = dropNulls(deriveConfiguredEncoder)
76+
private[cardano] implicit val encodeBlock: Encoder[Block] = dropNulls(deriveConfiguredEncoder)
77+
6978
sealed trait MetadataValue
7079

7180
sealed trait MetadataKey extends MetadataValue
@@ -130,7 +139,7 @@ object CardanoApiCodec {
130139

131140
}
132141

133-
case class SyncStatus(status: SyncState, progress: Option[QuantityUnit])
142+
final case class SyncStatus(status: SyncState, progress: Option[QuantityUnit])
134143

135144
object SyncState extends Enumeration {
136145
type SyncState = Value
@@ -145,17 +154,17 @@ object CardanoApiCodec {
145154
val delegating: DelegationStatus = Value("delegating")
146155
val notDelegating: DelegationStatus = Value("not_delegating")
147156
}
148-
final case class DelegationActive(status: DelegationStatus, target: Option[String])
149-
@ConfiguredJsonCodec final case class DelegationNext(status: DelegationStatus, changesAt: Option[NextEpoch])
150-
final case class Delegation(active: DelegationActive, next: List[DelegationNext])
157+
@ConfiguredJsonCodec(decodeOnly = true) final case class DelegationActive(status: DelegationStatus, target: Option[String])
158+
@ConfiguredJsonCodec(decodeOnly = true) final case class DelegationNext(status: DelegationStatus, changesAt: Option[NextEpoch])
159+
@ConfiguredJsonCodec final case class Delegation(active: DelegationActive, next: List[DelegationNext])
151160

152-
@ConfiguredJsonCodec case class NetworkTip(
161+
@ConfiguredJsonCodec(decodeOnly = true) final case class NetworkTip(
153162
epochNumber: Long,
154163
slotNumber: Long,
155164
height: Option[QuantityUnit],
156165
absoluteSlotNumber: Option[Long])
157166

158-
@ConfiguredJsonCodec case class NodeTip(height: QuantityUnit, slotNumber: Long, epochNumber: Long, absoluteSlotNumber: Option[Long])
167+
@ConfiguredJsonCodec(decodeOnly = true) final case class NodeTip(height: QuantityUnit, slotNumber: Long, epochNumber: Long, absoluteSlotNumber: Option[Long])
159168

160169
case class WalletAddressId(id: String, state: Option[AddressFilter])
161170

@@ -211,7 +220,7 @@ object CardanoApiCodec {
211220
nextEpoch: NextEpoch
212221
)
213222

214-
@ConfiguredJsonCodec
223+
@ConfiguredJsonCodec(decodeOnly = true)
215224
case class CreateRestore(
216225
name: String,
217226
passphrase: String,
@@ -283,7 +292,7 @@ object CardanoApiCodec {
283292
outputs: Seq[OutAddress]
284293
)
285294

286-
@ConfiguredJsonCodec
295+
@ConfiguredJsonCodec(decodeOnly = true)
287296
case class Block(
288297
slotNumber: Int,
289298
epochNumber: Int,
@@ -304,7 +313,7 @@ object CardanoApiCodec {
304313
estimatedMax: QuantityUnit
305314
)
306315

307-
@ConfiguredJsonCodec
316+
@ConfiguredJsonCodec(decodeOnly = true)
308317
case class CreateTransactionResponse(
309318
id: String,
310319
amount: QuantityUnit,
@@ -322,7 +331,7 @@ object CardanoApiCodec {
322331
@ConfiguredJsonCodec
323332
final case class Passphrase(lastUpdatedAt: ZonedDateTime)
324333

325-
@ConfiguredJsonCodec
334+
@ConfiguredJsonCodec(decodeOnly = true)
326335
case class Wallet(
327336
id: String,
328337
addressPoolGap: Int,

0 commit comments

Comments
 (0)