Skip to content

Commit 7834648

Browse files
authored
Fix wrong controller in WalletUserProxy_TransferInstruction_Withdraw (#3216)
fixes #3215 [ci] Signed-off-by: Simon Meier <simon@digitalasset.com>
1 parent 285c5a7 commit 7834648

File tree

7 files changed

+87
-4
lines changed

7 files changed

+87
-4
lines changed

daml/dars.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ splice-util 0.1.4 b7356fbb2cf8a3b22194d8c743c3c216d9c7527b257c8c38b257eb22942be3
7575
splice-util-featured-app-proxies 1.0.0 48e0c4fe4ea05e3b740404ebe37004ddd741efbdcd665c1c3199a5d6d9d944d7
7676
splice-util-featured-app-proxies 1.1.0 81dd5a9e5c02d0de03208522a895fb85eeb12fbea4aca7c4ad0ad106f3b0bfce
7777
splice-util-featured-app-proxies 1.2.0 653c48879064332d34af5008bdfd8e349493460e67e62b85e8e7e3392831c842
78-
splice-util-featured-app-proxies-test 1.0.4 ef633c6eff2d786cc571e58f572c5a0c72d31b7ffc1eeeedc420791c50b9a7f1
78+
splice-util-featured-app-proxies 1.2.1 06bab917848ef275317c2539b75c23b94e03ceb55b4a1346936f7832084cd7a6
79+
splice-util-featured-app-proxies-test 1.0.5 c743b3ede62dfa5a1587548ae6498b4ace7be6028fb191bbb4ffdbbf1b971d90
7980
splice-util-token-standard-wallet 1.0.0 1da198cb7968fa478cfa12aba9fdf128a63a8af6ab284ea6be238cf92a3733ac
8081
splice-util-token-standard-wallet-test 1.0.0 ee328d4744bce339f040078d7271a3d73c932d23589cfa1cfbd99aaf6408c3c2
8182
splice-validator-lifecycle 0.1.0 cef96fac957362f1fc097120bd13686cac7f84fbc8053afa994a1f9214d9570c
401 KB
Binary file not shown.

daml/splice-util-featured-app-proxies-test/daml.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ description: |
1111
are normal .dar files and can be shared by copying the .dars.
1212
(TODO(#594): remove this limitation)
1313
source: daml
14-
version: 1.0.4
14+
version: 1.0.5
1515
dependencies:
1616
- daml-prim
1717
- daml-stdlib

daml/splice-util-featured-app-proxies-test/daml/Splice/Util/FeaturedApp/IntegrationTests/TestWalletUserProxy.daml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,81 @@ test_two_step_featured_app_markers = do
154154
WalletClient.checkBalanceApprox alice registry.instrumentId 990.0
155155
WalletClient.checkBalance bob registry.instrumentId 10.0
156156

157+
test_transfer_withdraw_and_reject : Script ()
158+
test_transfer_withdraw_and_reject = do
159+
registry <- AmuletRegistry.initialize AmuletRegistry.defaultAmuletRegistryConfig with
160+
noTransferFee = True
161+
162+
-- Setup a wallet provider that will host alice
163+
aliceProvider <- setupWalletProvider registry "aliceWalletProvider" None
164+
bobProvider <- setupWalletProvider registry "bobWalletProvider" None
165+
166+
alice <- allocatePartyExact "alice"
167+
bob <- allocatePartyExact "bob"
168+
169+
-- setup alice with 1000 Amulet tokens
170+
AmuletRegistry.tapLockedAndUnlockedFunds registry alice 1000.0
171+
172+
let mkTransferOffer = do
173+
aliceHoldings <- WalletClient.listHoldingCids alice registry.instrumentId
174+
transfer <- mkImmediateTransfer registry alice bob 20.0 aliceHoldings
175+
176+
-- alice's wallet frontend also gets the WalletProviderData from the wallet provider's backend
177+
-- and creates a transaction that creates featured app activity markers for both alice and the wallet provider
178+
_ <- submitWithDisclosures' alice (aliceProvider.extraDisclosuresForProxy <> transfer.disclosures) $ exerciseCmd
179+
(aliceProvider.proxyCid)
180+
WalletUserProxy_TransferFactory_Transfer with
181+
cid = transfer.value.factoryCid
182+
proxyArg = ProxyArg with
183+
user = alice
184+
choiceArg = transfer.value.choiceArg
185+
featuredAppRightCid = aliceProvider.featuredAppRightCid
186+
187+
[(bobInstrCid,_)] <- WalletClient.listTransferOffers bob registry.instrumentId
188+
pure bobInstrCid
189+
190+
-- test withdraw by sender
191+
offerCid <- mkTransferOffer
192+
context <- RegistryApi.getTransferInstruction_RejectContext registry offerCid emptyMetadata
193+
194+
-- submit via proxy to create featured app markers
195+
result0 <- submitWithDisclosures' alice (aliceProvider.extraDisclosuresForProxy <> context.disclosures) $ exerciseCmd
196+
(aliceProvider.proxyCid)
197+
WalletUserProxy_TransferInstruction_Withdraw with
198+
cid = offerCid
199+
proxyArg = ProxyArg with
200+
user = alice
201+
choiceArg = TransferInstruction_Withdraw with
202+
extraArgs = ExtraArgs with
203+
context = context.choiceContext
204+
meta = emptyMetadata
205+
featuredAppRightCid = aliceProvider.featuredAppRightCid
206+
207+
let result = result0.choiceResult
208+
TransferInstructionResult_Failed <- pure result.output
209+
210+
-- test rejection by receiver
211+
offerCid <- mkTransferOffer
212+
context <- RegistryApi.getTransferInstruction_RejectContext registry offerCid emptyMetadata
213+
214+
-- submit via proxy to create featured app markers
215+
result0 <- submitWithDisclosures' bob (bobProvider.extraDisclosuresForProxy <> context.disclosures) $ exerciseCmd
216+
(bobProvider.proxyCid)
217+
WalletUserProxy_TransferInstruction_Reject with
218+
cid = offerCid
219+
proxyArg = ProxyArg with
220+
user = bob
221+
choiceArg = TransferInstruction_Reject with
222+
extraArgs = ExtraArgs with
223+
context = context.choiceContext
224+
meta = emptyMetadata
225+
featuredAppRightCid = bobProvider.featuredAppRightCid
226+
227+
let result = result0.choiceResult
228+
TransferInstructionResult_Failed <- pure result.output
229+
230+
pure ()
231+
157232

158233
-- Testing batch transfer via wallet proxy
159234
--------------------------------------------

daml/splice-util-featured-app-proxies/daml.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
sdk-version: 3.3.0-snapshot.20250502.13767.0.v2fc6c7e2
22
name: splice-util-featured-app-proxies
33
source: daml
4-
version: 1.2.0
4+
version: 1.2.1
55
dependencies:
66
- daml-prim
77
- daml-stdlib

daml/splice-util-featured-app-proxies/daml/Splice/Util/FeaturedApp/WalletUserProxy.daml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ template WalletUserProxy with
114114
do
115115
exerciseProxyChoice this cid proxyArg $ \cid -> do
116116
instr <- fetch cid
117-
pure (view instr).transfer.receiver
117+
pure (view instr).transfer.sender
118118

119119
nonconsuming choice WalletUserProxy_AllocationFactory_Allocate
120120
: ProxyResult AllocationInstructionResult

docs/src/release_notes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ Upcoming
3232
and are now set to zero to avoid consensus problems when an SV reads aggregates
3333
from the rest of the network when first joining.
3434

35+
- Daml
36+
37+
- Fixed a bug in ``WalletUserProxy_TransferInstruction_Withdraw``, where the controller was
38+
required to be the ``receiver`` instead of the ``sender`` of the transfer instruction. Upgrade
39+
to ``splice-util-featured-app-proxies`` version ``1.2.1`` or newer to get the fix.
40+
41+
3542
0.5.1
3643
-----
3744

0 commit comments

Comments
 (0)