Skip to content

Commit 291e5fd

Browse files
[ci] Remove /v0/total-amulet-balance and /v0/wallet-balance endpoints
Signed-off-by: Raymond Roestenburg <raymond.roestenburg@digitalasset.com>
1 parent eab4e21 commit 291e5fd

File tree

18 files changed

+20
-813
lines changed

18 files changed

+20
-813
lines changed

apps/app/src/main/scala/org/lfdecentralizedtrust/splice/console/ScanAppReference.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,6 @@ abstract class ScanAppReference(
249249
httpCommand(HttpScanAppClient.LookupFeaturedAppRight(providerPartyId))
250250
}
251251

252-
@Help.Summary("Get the total balance of Amulet in the network")
253-
def getTotalAmuletBalance(asOfEndOfRound: Long): Option[BigDecimal] =
254-
consoleEnvironment.run {
255-
httpCommand(HttpScanAppClient.GetTotalAmuletBalance(asOfEndOfRound))
256-
}
257-
258252
@Help.Summary("Get the Amulet config parameters for a given round")
259253
def getAmuletConfigForRound(
260254
round: Long
@@ -607,6 +601,11 @@ abstract class ScanAppReference(
607601
httpCommand(HttpScanAppClient.LookupInstrument(instrumentId))
608602
}
609603

604+
def getTotalAmuletBalance(): Option[BigDecimal] = {
605+
lookupInstrument("Amulet")
606+
.flatMap(_.totalSupply.map(s => BigDecimal(s)))
607+
}
608+
610609
def listInstruments() =
611610
consoleEnvironment.run {
612611
httpCommand(HttpScanAppClient.ListInstruments(pageSize = None, pageToken = None))

apps/app/src/test/resources/include/scans/_scan.conf

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@
4444
ttl = 1s
4545
max-size = 1
4646
}
47-
total-amulet-balance {
48-
ttl = 1s
49-
max-size = 1
50-
}
5147
amulet-rules {
5248
ttl = 1s
5349
max-size = 1
@@ -64,10 +60,6 @@
6460
ttl = 1s
6561
max-size = 1
6662
}
67-
wallet-balance {
68-
ttl = 1s
69-
max-size = 1
70-
}
7163
amulet-config-for-round {
7264
ttl = 1s
7365
max-size = 1

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/ScanFrontendTimeBasedIntegrationTest.scala

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -440,16 +440,6 @@ class ScanFrontendTimeBasedIntegrationTest
440440
"Wait for round to close in scan",
441441
_ => sv1ScanBackend.getRoundOfLatestData()._1 shouldBe (firstRound + 1),
442442
)
443-
// We do not check the backend computation here, nor do we want to rely on the exact amulet balance created in other tests,
444-
// so here we simply test that:
445-
// The total balance increased as a result of our tap by the tap amount minus some amount to account for holding fees
446-
// The frontend shows the balance from the backend
447-
sv1ScanBackend
448-
.getTotalAmuletBalance(firstRound + 1)
449-
.valueOrFail("Amulet balance not yet computed") should
450-
(be > (sv1ScanBackend
451-
.getTotalAmuletBalance(firstRound)
452-
.valueOrFail("Amulet balance not yet computed") + 99.0))
453443

454444
withFrontEnd("scan-ui") { implicit webDriver =>
455445
actAndCheck(

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/ScanIntegrationTest.scala

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -689,29 +689,6 @@ class ScanIntegrationTest extends IntegrationTest with WalletTestUtil with TimeT
689689
}
690690
}
691691

692-
"getWalletBalance should return 400 for invalid party ID" in { implicit env =>
693-
implicit val sys = env.actorSystem
694-
registerHttpConnectionPoolsCleanup(env)
695-
696-
val response = Http()
697-
.singleRequest(
698-
Get(
699-
s"${sv1ScanBackend.httpClientConfig.url}/api/scan/v0/wallet-balance?party_id=None&asOfEndOfRound=0"
700-
)
701-
)
702-
.futureValue
703-
704-
inside(response) {
705-
case _ if response.status == StatusCodes.BadRequest =>
706-
inside(Unmarshal(response.entity).to[String].value.value) {
707-
case Success(successfullResponse) =>
708-
successfullResponse should include(
709-
"Invalid unique identifier `None` with missing namespace"
710-
)
711-
}
712-
}
713-
}
714-
715692
"getUpdateHistory should return 400 for invalid after timestamp" in { implicit env =>
716693
import env.{actorSystem, executionContext}
717694
registerHttpConnectionPoolsCleanup(env)

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/ScanTimeBasedIntegrationTest.scala

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -290,89 +290,6 @@ class ScanTimeBasedIntegrationTest
290290
)
291291
}
292292

293-
"get total amulet balance" in { implicit env =>
294-
val (_, _) = onboardAliceAndBob()
295-
296-
def roundNum() =
297-
sv1ScanBackend.getLatestOpenMiningRound(getLedgerTime).contract.payload.round.number
298-
roundNum() shouldBe (firstRound + 1)
299-
300-
val tapRound1Amount = BigDecimal(500.0)
301-
clue(s"Tap in round ${firstRound + 1}") {
302-
aliceWalletClient.tap(tapRound1Amount)
303-
}
304-
305-
advanceRoundsToNextRoundOpening
306-
307-
roundNum() shouldBe (firstRound + 2)
308-
309-
val tapRound2Amount = BigDecimal(500.0)
310-
clue(s"Tap in round ${firstRound + 2}") {
311-
bobWalletClient.tap(tapRound2Amount)
312-
}
313-
314-
actAndCheck(
315-
s"advance to close round ${firstRound + 2}",
316-
(0 to 4).foreach(_ => advanceRoundsToNextRoundOpening),
317-
)(
318-
s"check round ${firstRound + 2} is closed",
319-
_ => {
320-
sv1ScanBackend.automation.trigger[ScanAggregationTrigger].runOnce().futureValue
321-
sv1ScanBackend.getRoundOfLatestData()._1 shouldBe firstRound + 2
322-
sv1ScanBackend.getAggregatedRounds().value shouldBe ScanAggregator.RoundRange(
323-
firstRound + 0,
324-
firstRound + 2,
325-
)
326-
},
327-
)
328-
329-
clue(
330-
s"Get total balances for round ${firstRound + 0}, ${firstRound + 1} and ${firstRound + 2}"
331-
) {
332-
val total0 =
333-
sv1ScanBackend
334-
.getTotalAmuletBalance(firstRound + 0)
335-
.getOrElse(BigDecimal(0))
336-
val total1 =
337-
sv1ScanBackend
338-
.getTotalAmuletBalance(firstRound + 1)
339-
.getOrElse(BigDecimal(0))
340-
val total2 =
341-
sv1ScanBackend
342-
.getTotalAmuletBalance(firstRound + 2)
343-
.valueOrFail("Amulet balance not yet computed")
344-
345-
val holdingFeeAfterOneRound = 1 * defaultHoldingFeeAmulet
346-
val holdingFeeAfterTwoRounds = 2 * defaultHoldingFeeAmulet
347-
348-
total0 shouldBe 0.0
349-
total1 shouldBe (walletUsdToAmulet(tapRound1Amount) - holdingFeeAfterOneRound)
350-
total2 shouldBe (
351-
walletUsdToAmulet(tapRound1Amount) - holdingFeeAfterTwoRounds +
352-
walletUsdToAmulet(tapRound2Amount) - holdingFeeAfterOneRound
353-
)
354-
sv1ScanBackend.getAggregatedRounds().value shouldBe ScanAggregator.RoundRange(
355-
firstRound + 0,
356-
firstRound + 2,
357-
)
358-
sv1ScanBackend
359-
.listRoundTotals(firstRound + 0, firstRound + 2)
360-
.map(rt => (rt.closedRound, BigDecimal(rt.totalAmuletBalance))) shouldBe List(
361-
firstRound + 0L -> total0,
362-
firstRound + 1L -> total1,
363-
firstRound + 2L -> total2,
364-
)
365-
assertThrowsAndLogsCommandFailures(
366-
sv1ScanBackend.listRoundTotals(firstRound + 1, firstRound + 3),
367-
_.errorMessage should include("is outside of the available rounds range"),
368-
)
369-
assertThrowsAndLogsCommandFailures(
370-
sv1ScanBackend.listRoundPartyTotals(firstRound + 1, firstRound + 3),
371-
_.errorMessage should include("is outside of the available rounds range"),
372-
)
373-
}
374-
}
375-
376293
"Not get aggregates for incorrect ranges" in { implicit env =>
377294
clue("Try to get round totals for negative rounds") {
378295
val startRounds = List(-1L, 0L, -1L, 1L, -1L)

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/ScanWithGradualStartsTimeBasedIntegrationTest.scala

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import org.lfdecentralizedtrust.splice.config.ConfigTransforms.{
77
import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition
88
import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.IntegrationTest
99
import org.lfdecentralizedtrust.splice.sv.automation.singlesv.LocalSequencerConnectionsTrigger
10-
import org.lfdecentralizedtrust.splice.util.SpliceUtil.defaultIssuanceCurve
1110
import org.lfdecentralizedtrust.splice.util.{SvTestUtil, TimeTestUtil, WalletTestUtil}
1211

1312
import scala.util.Try
@@ -139,39 +138,6 @@ class ScanWithGradualStartsTimeBasedIntegrationTest
139138
}
140139

141140
val validatorLivenessActivityRecordAmount = 2.85
142-
clue("Aggregated total amulet balance on both scan apps should match") {
143-
val svRewardPerRound =
144-
BigDecimal(
145-
computeSvRewardInRound0(
146-
defaultIssuanceCurve.initialValue,
147-
defaultTickDuration,
148-
dsoSize = 2,
149-
)
150-
)
151-
forEvery(
152-
Table(
153-
("round", "total floor", "total ceiling"),
154-
// Alice has 23 USD in Amulet, Bob has 3 USD, all minus holding fees
155-
(2L, walletUsdToAmulet(25.9), walletUsdToAmulet(26.0)),
156-
// sv2 did not start up it's validator app (thus wallet), so it won't claim any coupons.
157-
(
158-
3L,
159-
// validator liveness activity record: SV1, Alice, Bob
160-
walletUsdToAmulet(
161-
26.0 + validatorLivenessActivityRecordAmount * 3 - smallAmount
162-
) + svRewardPerRound,
163-
walletUsdToAmulet(26.0 + validatorLivenessActivityRecordAmount * 3) + svRewardPerRound,
164-
),
165-
)
166-
) { (round, floor, ceil) =>
167-
val total1 =
168-
sv1ScanBackend.getTotalAmuletBalance(round).valueOrFail("Amulet balance not yet computed")
169-
val total2 =
170-
sv2ScanBackend.getTotalAmuletBalance(round).valueOrFail("Amulet balance not yet computed")
171-
total1 shouldBe total2
172-
total1 should beWithin(floor, ceil)
173-
}
174-
}
175141

176142
clue("Aggregated rewards collected on both scan apps should match") {
177143
forEvery(

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/TokenStandardMetadataTimeBasedIntegrationTest.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,13 @@ class TokenStandardMetadataTimeBasedIntegrationTest
106106
)(
107107
"rounds are defined and include tapped amulet",
108108
_ => {
109-
val (roundNumber, _) = sv1ScanBackend.getRoundOfLatestData()
110-
val totalBalance = sv1ScanBackend
111-
.getTotalAmuletBalance(roundNumber)
112-
.getOrElse(fail("total balance not yet defined"))
109+
val totalBalance = BigDecimal(
110+
sv1ScanBackend
111+
.lookupInstrument("Amulet")
112+
.flatMap(_.totalSupply)
113+
.valueOrFail("total balance not yet defined")
114+
)
115+
113116
totalBalance should be >= walletUsdToAmulet(99.0)
114117
},
115118
)

apps/scan/src/main/openapi/scan.yaml

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,70 +1174,6 @@ paths:
11741174
"500":
11751175
$ref: "../../../../common/src/main/openapi/common-external.yaml#/components/responses/500"
11761176

1177-
/v0/total-amulet-balance:
1178-
get:
1179-
deprecated: true
1180-
tags: [deprecated, scan]
1181-
x-jvm-package: scan
1182-
operationId: "getTotalAmuletBalance"
1183-
description: |
1184-
**Deprecated**, use /registry/metadata/v1/instruments/Amulet token standard metadata API endpoint, see
1185-
https://docs.sync.global/app_dev/token_standard/openapi/token_metadata.html.
1186-
1187-
**This endpoint will be removed in a future release**
1188-
1189-
Get the total balance of Amulet in the network.
1190-
parameters:
1191-
- in: query
1192-
name: asOfEndOfRound
1193-
required: true
1194-
schema:
1195-
type: integer
1196-
format: int64
1197-
responses:
1198-
"200":
1199-
description: ok
1200-
content:
1201-
application/json:
1202-
schema:
1203-
"$ref": "#/components/schemas/GetTotalAmuletBalanceResponse"
1204-
"404":
1205-
$ref: "../../../../common/src/main/openapi/common-external.yaml#/components/responses/404"
1206-
1207-
/v0/wallet-balance:
1208-
get:
1209-
deprecated: true
1210-
tags: [deprecated]
1211-
x-jvm-package: scan
1212-
operationId: "getWalletBalance"
1213-
description: |
1214-
**Deprecated**, use /v0/holdings/summary with /v0/state/acs/snapshot-timestamp instead.
1215-
1216-
**This endpoint will be removed in a future release**
1217-
1218-
Get the Amulet balance for a specific party at the end of a closed round.
1219-
parameters:
1220-
- in: query
1221-
name: party_id
1222-
required: true
1223-
schema:
1224-
type: string
1225-
- in: query
1226-
name: asOfEndOfRound
1227-
required: true
1228-
schema:
1229-
type: integer
1230-
format: int64
1231-
responses:
1232-
"200":
1233-
description: ok
1234-
content:
1235-
application/json:
1236-
schema:
1237-
"$ref": "#/components/schemas/GetWalletBalanceResponse"
1238-
"404":
1239-
$ref: "../../../../common/src/main/openapi/common-external.yaml#/components/responses/404"
1240-
12411177
/v0/amulet-config-for-round:
12421178
get:
12431179
deprecated: true
@@ -1790,18 +1726,6 @@ components:
17901726
properties:
17911727
featured_app_right:
17921728
$ref: "../../../../common/src/main/openapi/common-external.yaml#/components/schemas/Contract"
1793-
GetWalletBalanceResponse:
1794-
type: object
1795-
required: ["wallet_balance"]
1796-
properties:
1797-
wallet_balance:
1798-
type: string
1799-
GetTotalAmuletBalanceResponse:
1800-
type: object
1801-
required: ["total_balance"]
1802-
properties:
1803-
total_balance:
1804-
type: string
18051729
GetAmuletConfigForRoundResponse:
18061730
type: object
18071731
required:

apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/ScanApp.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,6 @@ class ScanApp(
323323
store,
324324
acsSnapshotStore,
325325
config.spliceInstanceNames,
326-
packageVersionSupport,
327-
clock,
328326
loggerFactory,
329327
)
330328

apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/admin/api/client/commands/HttpScanAppClient.scala

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -557,23 +557,6 @@ object HttpScanAppClient {
557557
}
558558
}
559559

560-
case class GetTotalAmuletBalance(asOfEndOfRound: Long)
561-
extends InternalBaseCommand[http.GetTotalAmuletBalanceResponse, Option[BigDecimal]] {
562-
563-
override def submitRequest(
564-
client: ScanClient,
565-
headers: List[HttpHeader],
566-
): EitherT[Future, Either[Throwable, HttpResponse], http.GetTotalAmuletBalanceResponse] =
567-
client.getTotalAmuletBalance(asOfEndOfRound, headers)
568-
569-
override def handleOk()(implicit decoder: TemplateJsonDecoder) = {
570-
case http.GetTotalAmuletBalanceResponse.OK(response) =>
571-
Codec.decode(Codec.BigDecimal)(response.totalBalance).map(Some(_))
572-
case http.GetTotalAmuletBalanceResponse.NotFound(_) =>
573-
Right(None)
574-
}
575-
}
576-
577560
final case class RateStep(
578561
amount: BigDecimal,
579562
rate: BigDecimal,

0 commit comments

Comments
 (0)