Skip to content

Commit 299547d

Browse files
cip-82: add listActiveDevelopmentFundCoupons to Wallet API
Signed-off-by: Jose Velasco <jose.velasco@intellecteu.com>
1 parent 09b8ac9 commit 299547d

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,20 @@ abstract class WalletAppReference(
629629
)
630630
)
631631
}
632+
633+
@Help.Summary("List active development fund coupons")
634+
@Help.Description(
635+
"List all active development fund coupons for the configured user acting as a beneficiary or development fund manager"
636+
)
637+
def listActiveDevelopmentFundCoupons(): Seq[
638+
Contract[
639+
amuletCodegen.DevelopmentFundCoupon.ContractId,
640+
amuletCodegen.DevelopmentFundCoupon,
641+
]
642+
] =
643+
consoleEnvironment.run {
644+
httpCommand(HttpWalletAppClient.ListActiveDevelopmentFundCoupons)
645+
}
632646
}
633647

634648
/** Client (aka remote) reference to a wallet app in the style of ParticipantClientReference, i.e.,

apps/wallet/src/main/openapi/wallet-internal.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,23 @@ paths:
896896
"500":
897897
$ref: "../../../../common/src/main/openapi/common-external.yaml#/components/responses/500"
898898

899+
/v0/wallet/development-fund-coupons:
900+
get:
901+
tags: [ wallet ]
902+
x-jvm-package: wallet
903+
operationId: "listActiveDevelopmentFundCoupons"
904+
responses:
905+
"200":
906+
description: ok
907+
content:
908+
application/json:
909+
schema:
910+
$ref: "#/components/schemas/ListActiveDevelopmentFundCouponsResponse"
911+
"404":
912+
$ref: "../../../../common/src/main/openapi/common-external.yaml#/components/responses/404"
913+
"500":
914+
$ref: "../../../../common/src/main/openapi/common-external.yaml#/components/responses/500"
915+
899916

900917
components:
901918
schemas:
@@ -1673,3 +1690,14 @@ components:
16731690
type: string
16741691
unclaimed_development_fund_coupon_contract_id:
16751692
type: string
1693+
1694+
ListActiveDevelopmentFundCouponsResponse:
1695+
type: object
1696+
description: Includes only up to 1000 elements.
1697+
required:
1698+
- active_development_fund_coupons
1699+
properties:
1700+
active_development_fund_coupons:
1701+
type: array
1702+
items:
1703+
$ref: "../../../../common/src/main/openapi/common-external.yaml#/components/schemas/Contract"

apps/wallet/src/main/scala/org/lfdecentralizedtrust/splice/wallet/admin/api/client/commands/HttpWalletAppClient.scala

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,4 +1391,32 @@ object HttpWalletAppClient {
13911391
}
13921392
}
13931393

1394+
case object ListActiveDevelopmentFundCoupons
1395+
extends InternalBaseCommand[
1396+
http.ListActiveDevelopmentFundCouponsResponse,
1397+
Seq[
1398+
Contract[
1399+
amuletCodegen.DevelopmentFundCoupon.ContractId,
1400+
amuletCodegen.DevelopmentFundCoupon,
1401+
]
1402+
],
1403+
] {
1404+
def submitRequest(
1405+
client: Client,
1406+
headers: List[HttpHeader],
1407+
): EitherT[Future, Either[
1408+
Throwable,
1409+
HttpResponse,
1410+
], http.ListActiveDevelopmentFundCouponsResponse] =
1411+
client.listActiveDevelopmentFundCoupons(headers = headers)
1412+
1413+
override def handleOk()(implicit
1414+
decoder: TemplateJsonDecoder
1415+
) = { case http.ListActiveDevelopmentFundCouponsResponse.OK(response) =>
1416+
response.activeDevelopmentFundCoupons
1417+
.traverse(req => Contract.fromHttp(amuletCodegen.DevelopmentFundCoupon.COMPANION)(req))
1418+
.leftMap(_.toString)
1419+
}
1420+
}
1421+
13941422
}

apps/wallet/src/main/scala/org/lfdecentralizedtrust/splice/wallet/admin/http/HttpWalletHandler.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,4 +1362,17 @@ class HttpWalletHandler(
13621362
)
13631363
}
13641364
}
1365+
1366+
override def listActiveDevelopmentFundCoupons(
1367+
respond: v0.WalletResource.ListActiveDevelopmentFundCouponsResponse.type
1368+
)()(
1369+
tuser: WalletUserRequest
1370+
): Future[v0.WalletResource.ListActiveDevelopmentFundCouponsResponse] = {
1371+
implicit val WalletUserRequest(user, userWallet, traceContext) = tuser
1372+
listContracts(
1373+
amuletCodegen.DevelopmentFundCoupon.COMPANION,
1374+
userWallet.store,
1375+
d0.ListActiveDevelopmentFundCouponsResponse(_),
1376+
)
1377+
}
13651378
}

0 commit comments

Comments
 (0)