Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

Commit 584a294

Browse files
committed
Add support for signer sponsorship events
1 parent b952a75 commit 584a294

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ As this project is pre 1.0, breaking changes may happen for minor version bumps.
44

55
## Next version
66

7+
## 0.19.1
8+
9+
- [#389](https://github.com/Synesso/scala-stellar-sdk/issues/389) Adds support for Signer Sponsorship state snapshot events.
10+
711
## 0.19.0
812

913
- A wide-ranging review of the SDK resulted in realignments to SDK/Network interactions and some data types. This has

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Add the JitPack & jcenter resolvers and the [latest dependency](https://jitpack.
1818
```scala
1919
resolvers += "jitpack" at "https://jitpack.io"
2020
resolvers += Resolver.jcenterRepo
21-
libraryDependencies += "com.github.synesso" %% "scala-stellar-sdk" % "0.19.0"
21+
libraryDependencies += "com.github.synesso" %% "scala-stellar-sdk" % "0.19.1"
2222
```
2323

2424
From there, it is a simple affair to create and fund a new account on the test network.

src/main/scala/stellar/sdk/model/response/EffectResponse.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ case class EffectSignerUpdated(id: String, createdAt: ZonedDateTime, account: Pu
4545

4646
case class EffectSignerRemoved(id: String, createdAt: ZonedDateTime, account: PublicKeyOps, publicKey: String) extends EffectResponse
4747

48+
case class EffectSignerSponsorshipCreated(id: String, createdAt: ZonedDateTime, account: PublicKeyOps, signer: PublicKeyOps, newSponsor: PublicKeyOps) extends EffectResponse
49+
50+
case class EffectSignerSponsorshipRemoved(id: String, createdAt: ZonedDateTime, account: PublicKeyOps, signer: PublicKeyOps, formerSponsor: PublicKeyOps) extends EffectResponse
51+
52+
case class EffectSignerSponsorshipUpdated(id: String, createdAt: ZonedDateTime, account: PublicKeyOps, signer: PublicKeyOps, formerSponsor: PublicKeyOps, newSponsor: PublicKeyOps) extends EffectResponse
53+
4854
case class EffectTrustLineCreated(id: String, createdAt: ZonedDateTime, account: PublicKeyOps, limit: IssuedAmount) extends EffectResponse {
4955
val asset: NonNativeAsset = limit.asset
5056
}
@@ -120,6 +126,19 @@ object EffectResponseDeserializer extends ResponseParser[EffectResponse]({ o: JO
120126
case "signer_created" => EffectSignerCreated(id, createdAt, account(), weight, (o \ "public_key").extract[String])
121127
case "signer_updated" => EffectSignerUpdated(id, createdAt, account(), weight, (o \ "public_key").extract[String])
122128
case "signer_removed" => EffectSignerRemoved(id, createdAt, account(), (o \ "public_key").extract[String])
129+
case "signer_sponsorship_created" => EffectSignerSponsorshipCreated(id, createdAt, account(),
130+
signer = account("signer"),
131+
newSponsor = account("sponsor")
132+
)
133+
case "signer_sponsorship_removed" => EffectSignerSponsorshipRemoved(id, createdAt, account(),
134+
signer = account("signer"),
135+
formerSponsor = account("former_sponsor")
136+
)
137+
case "signer_sponsorship_updated" => EffectSignerSponsorshipUpdated(id, createdAt, account(),
138+
signer = account("signer"),
139+
formerSponsor = account("former_sponsor"),
140+
newSponsor = account("new_sponsor")
141+
)
123142
case "trustline_created" => EffectTrustLineCreated(id, createdAt, account(), amount(key = "limit").asInstanceOf[IssuedAmount])
124143
case "trustline_updated" => EffectTrustLineUpdated(id, createdAt, account(), amount(key = "limit").asInstanceOf[IssuedAmount])
125144
case "trustline_removed" => EffectTrustLineRemoved(id, createdAt, account(), asset().asInstanceOf[NonNativeAsset])

src/test/scala/stellar/sdk/model/response/SignerEffectResponseSpec.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,27 @@ class SignerEffectResponseSpec extends Specification with ArbitraryInput with Js
3737
}.setGen1(Gen.identifier).setGen4(Gen.identifier)
3838
}
3939

40+
"a signer sponsorship created effect document" should {
41+
"parse to a signer sponsorship created effect" >> prop { (id: String, created: ZonedDateTime, kp: KeyPair, signer: KeyPair, sponsor: KeyPair) =>
42+
val json = doc(id, created, kp, "signer_sponsorship_created", 0, "signer" -> signer.accountId, "sponsor" -> sponsor.accountId)
43+
parse(json).extract[EffectResponse] mustEqual EffectSignerSponsorshipCreated(id, created, kp.asPublicKey, signer.asPublicKey, sponsor.asPublicKey)
44+
}.setGen1(Gen.identifier)
45+
}
46+
47+
"a signer sponsorship removed effect document" should {
48+
"parse to a signer sponsorship removed effect" >> prop { (id: String, created: ZonedDateTime, kp: KeyPair, signer: KeyPair, sponsor: KeyPair) =>
49+
val json = doc(id, created, kp, "signer_sponsorship_removed", 0, "signer" -> signer.accountId, "former_sponsor" -> sponsor.accountId)
50+
parse(json).extract[EffectResponse] mustEqual EffectSignerSponsorshipRemoved(id, created, kp.asPublicKey, signer.asPublicKey, sponsor.asPublicKey)
51+
}.setGen1(Gen.identifier)
52+
}
53+
54+
"a signer sponsorship updated effect document" should {
55+
"parse to a signer sponsorship updated effect" >> prop { (id: String, created: ZonedDateTime, kp: KeyPair, signer: KeyPair, oldSponsor: KeyPair, newSponsor: KeyPair) =>
56+
val json = doc(id, created, kp, "signer_sponsorship_updated", 0, "signer" -> signer.accountId, "former_sponsor" -> oldSponsor.accountId, "new_sponsor" -> newSponsor.accountId)
57+
parse(json).extract[EffectResponse] mustEqual EffectSignerSponsorshipUpdated(id, created, kp.asPublicKey, signer.asPublicKey, oldSponsor.asPublicKey, newSponsor.asPublicKey)
58+
}.setGen1(Gen.identifier)
59+
}
60+
4061
def doc(id: String, created: ZonedDateTime, kp: KeyPair, tpe: String, weight: Short, extra: (String, Any)*) =
4162
s"""
4263
|{

0 commit comments

Comments
 (0)