Splice.Util.FeaturedApp.WalletUserProxy
Utility template for proxying token standard choices so that featured app markers are created for a wallet app provider by their users when they are using token standard workflows.
You can either use this template directly, or copy the code under a different package name and a different module name.
Note: use the DelegateProxy if you are building an app that uses multiple parties
for its own operations.
Templates
template WalletUserProxy
A proxy to attribute the activity of a wallet user to the wallet app provider.
The intended usage is for the wallet app provider to
create a
WalletUserProxycontract with theproviderset to the app provider’s partysetup their wallet frontend such that users call the proxy’s choices instead of the original token standard choices.
Note that the weights are specified on the proxy contract, so that they are under the providers control. If they were specified on the choices, then the user could in principle change them, and grant themselves a higher reward than intended.
Note also that the batch transfer support can be used without having a featured app right.
Signatory: provider
Field
Type
Description
provider
The app provider whose featured app right should be triggered
providerWeight
Reward weight for the provider
userWeight
Reward weight for the user, set to 0.0 if the user should not receive a reward
extraBeneficiaries
[AppRewardBeneficiary]
Extra beneficiaries to add
optAllowList
An optional allow list of parties that can use the proxy
Choice Archive
Controller: provider
Returns: ()
(no fields)
Choice WalletUserProxy_AllocationFactory_Allocate
Controller: (DA.Internal.Record.getField @"user" proxyArg)
Returns: ProxyResult AllocationInstructionResult
Field
Type
Description
cid
ContractId AllocationFactory
proxyArg
ProxyArg AllocationFactory_Allocate
Choice WalletUserProxy_Allocation_Withdraw
Controller: (DA.Internal.Record.getField @"user" proxyArg)
Returns: ProxyResult Allocation_WithdrawResult
Field
Type
Description
cid
ContractId Allocation
proxyArg
ProxyArg Allocation_Withdraw
Choice WalletUserProxy_BatchTransfer
Controller: getFirstSender transferCalls
Returns: WalletUserProxy_BatchTransferResult
Field
Type
Description
transferCalls
Transfers to execute via their respective transfer factories. Input holdings are properly threaded through for all instrument-ids. The sender change is always added back as an additional input to follow-up transfers for the same instrument-ids. Note that we accept fully specified calls to factories for maximum flexibility. Some token admins may actually use different factories for different recipients, e.g., to implement preapprovals.
optFeaturedAppRightCid
Optional (ContractId FeaturedAppRight)
The featured app right contract of the provider to use on every transfer. Optional so the batched choice can be used without a featured app right.
Choice WalletUserProxy_PublicFetch
Controller: actor
Returns: WalletUserProxy
Field
Type
Description
actor
Choice WalletUserProxy_TransferFactory_Transfer
Controller: (DA.Internal.Record.getField @"user" proxyArg)
Returns: ProxyResult TransferInstructionResult
Field
Type
Description
cid
ContractId TransferFactory
proxyArg
ProxyArg TransferFactory_Transfer
Choice WalletUserProxy_TransferInstruction_Accept
Controller: (DA.Internal.Record.getField @"user" proxyArg)
Returns: ProxyResult TransferInstructionResult
Field
Type
Description
cid
ContractId TransferInstruction
proxyArg
ProxyArg TransferInstruction_Accept
Choice WalletUserProxy_TransferInstruction_Reject
Controller: (DA.Internal.Record.getField @"user" proxyArg)
Returns: ProxyResult TransferInstructionResult
Field
Type
Description
cid
ContractId TransferInstruction
proxyArg
ProxyArg TransferInstruction_Reject
Choice WalletUserProxy_TransferInstruction_Withdraw
Controller: (DA.Internal.Record.getField @"user" proxyArg)
Returns: ProxyResult TransferInstructionResult
Field
Type
Description
cid
ContractId TransferInstruction
proxyArg
ProxyArg TransferInstruction_Withdraw
Data Types
- type InstrumentHoldingMap
= Map InstrumentId [ContractId Holding]
instance GetField "senderChangeMap" WalletUserProxy_BatchTransferResult InstrumentHoldingMap
instance SetField "senderChangeMap" WalletUserProxy_BatchTransferResult InstrumentHoldingMap
data ProxyArg arg
Generic argument to the proxy choices.
Field
Type
Description
user
The wallet user that is using the wallet to exercise a choice.
choiceArg
arg
The argument to the choice that the user is exercising.
featuredAppRightCid
ContractId FeaturedAppRight
The featured app right contract of the provider.
instance Eq arg => Eq (ProxyArg arg)
instance Show arg => Show (ProxyArg arg)
instance GetField "choiceArg" (ProxyArg arg) arg
instance GetField "featuredAppRightCid" (ProxyArg arg) (ContractId FeaturedAppRight)
instance GetField "proxyArg" WalletUserProxy_AllocationFactory_Allocate (ProxyArg AllocationFactory_Allocate)
instance GetField "proxyArg" WalletUserProxy_Allocation_Withdraw (ProxyArg Allocation_Withdraw)
instance GetField "proxyArg" WalletUserProxy_TransferFactory_Transfer (ProxyArg TransferFactory_Transfer)
instance GetField "proxyArg" WalletUserProxy_TransferInstruction_Accept (ProxyArg TransferInstruction_Accept)
instance GetField "proxyArg" WalletUserProxy_TransferInstruction_Reject (ProxyArg TransferInstruction_Reject)
instance GetField "proxyArg" WalletUserProxy_TransferInstruction_Withdraw (ProxyArg TransferInstruction_Withdraw)
instance GetField "user" (ProxyArg arg) Party
instance SetField "choiceArg" (ProxyArg arg) arg
instance SetField "featuredAppRightCid" (ProxyArg arg) (ContractId FeaturedAppRight)
instance SetField "proxyArg" WalletUserProxy_AllocationFactory_Allocate (ProxyArg AllocationFactory_Allocate)
instance SetField "proxyArg" WalletUserProxy_Allocation_Withdraw (ProxyArg Allocation_Withdraw)
instance SetField "proxyArg" WalletUserProxy_TransferFactory_Transfer (ProxyArg TransferFactory_Transfer)
instance SetField "proxyArg" WalletUserProxy_TransferInstruction_Accept (ProxyArg TransferInstruction_Accept)
instance SetField "proxyArg" WalletUserProxy_TransferInstruction_Reject (ProxyArg TransferInstruction_Reject)
instance SetField "proxyArg" WalletUserProxy_TransferInstruction_Withdraw (ProxyArg TransferInstruction_Withdraw)
data ProxyResult r
Generic result of the proxy choices.
Field
Type
Description
markerResult
FeaturedAppRight_CreateActivityMarkerResult
choiceResult
r
instance GetField "choiceResult" (ProxyResult r) r
instance GetField "markerResult" (ProxyResult r) FeaturedAppRight_CreateActivityMarkerResult
instance SetField "choiceResult" (ProxyResult r) r
instance SetField "markerResult" (ProxyResult r) FeaturedAppRight_CreateActivityMarkerResult
instance HasExercise WalletUserProxy WalletUserProxy_AllocationFactory_Allocate (ProxyResult AllocationInstructionResult)
instance HasExercise WalletUserProxy WalletUserProxy_Allocation_Withdraw (ProxyResult Allocation_WithdrawResult)
instance HasExercise WalletUserProxy WalletUserProxy_TransferFactory_Transfer (ProxyResult TransferInstructionResult)
instance HasExercise WalletUserProxy WalletUserProxy_TransferInstruction_Accept (ProxyResult TransferInstructionResult)
instance HasExercise WalletUserProxy WalletUserProxy_TransferInstruction_Reject (ProxyResult TransferInstructionResult)
instance HasExercise WalletUserProxy WalletUserProxy_TransferInstruction_Withdraw (ProxyResult TransferInstructionResult)
instance HasFromAnyChoice WalletUserProxy WalletUserProxy_AllocationFactory_Allocate (ProxyResult AllocationInstructionResult)
instance HasFromAnyChoice WalletUserProxy WalletUserProxy_Allocation_Withdraw (ProxyResult Allocation_WithdrawResult)
instance HasFromAnyChoice WalletUserProxy WalletUserProxy_TransferFactory_Transfer (ProxyResult TransferInstructionResult)
instance HasFromAnyChoice WalletUserProxy WalletUserProxy_TransferInstruction_Accept (ProxyResult TransferInstructionResult)
instance HasFromAnyChoice WalletUserProxy WalletUserProxy_TransferInstruction_Reject (ProxyResult TransferInstructionResult)
instance HasFromAnyChoice WalletUserProxy WalletUserProxy_TransferInstruction_Withdraw (ProxyResult TransferInstructionResult)
instance HasToAnyChoice WalletUserProxy WalletUserProxy_AllocationFactory_Allocate (ProxyResult AllocationInstructionResult)
instance HasToAnyChoice WalletUserProxy WalletUserProxy_Allocation_Withdraw (ProxyResult Allocation_WithdrawResult)
instance HasToAnyChoice WalletUserProxy WalletUserProxy_TransferFactory_Transfer (ProxyResult TransferInstructionResult)
instance HasToAnyChoice WalletUserProxy WalletUserProxy_TransferInstruction_Accept (ProxyResult TransferInstructionResult)
instance HasToAnyChoice WalletUserProxy WalletUserProxy_TransferInstruction_Reject (ProxyResult TransferInstructionResult)
instance HasToAnyChoice WalletUserProxy WalletUserProxy_TransferInstruction_Withdraw (ProxyResult TransferInstructionResult)
data TransferFactoryCall
A call to the token standard factory to initiate a token standard transfer. Specialized because it is used in the batch transfer choice below.
Field
Type
Description
factoryCid
ContractId TransferFactory
choiceArg
TransferFactory_Transfer
instance Eq TransferFactoryCall
instance Show TransferFactoryCall
instance GetField "choiceArg" TransferFactoryCall TransferFactory_Transfer
instance GetField "factoryCid" TransferFactoryCall (ContractId TransferFactory)
instance GetField "transferCalls" WalletUserProxy_BatchTransfer [TransferFactoryCall]
instance SetField "choiceArg" TransferFactoryCall TransferFactory_Transfer
instance SetField "factoryCid" TransferFactoryCall (ContractId TransferFactory)
instance SetField "transferCalls" WalletUserProxy_BatchTransfer [TransferFactoryCall]
data WalletUserProxy_BatchTransferResult
WalletUserProxy_BatchTransferResult
Field
Type
Description
transferResults
[TransferInstructionResult]
senderChangeMap
instance Eq WalletUserProxy_BatchTransferResult
instance Show WalletUserProxy_BatchTransferResult
instance GetField "senderChangeMap" WalletUserProxy_BatchTransferResult InstrumentHoldingMap
instance GetField "transferResults" WalletUserProxy_BatchTransferResult [TransferInstructionResult]
instance SetField "senderChangeMap" WalletUserProxy_BatchTransferResult InstrumentHoldingMap
instance SetField "transferResults" WalletUserProxy_BatchTransferResult [TransferInstructionResult]
instance HasExercise WalletUserProxy WalletUserProxy_BatchTransfer WalletUserProxy_BatchTransferResult
instance HasFromAnyChoice WalletUserProxy WalletUserProxy_BatchTransfer WalletUserProxy_BatchTransferResult
instance HasToAnyChoice WalletUserProxy WalletUserProxy_BatchTransfer WalletUserProxy_BatchTransferResult
Functions
- getFirstSender
: [TransferFactoryCall] -> Party
Determine the sender of the transfer in the first call.
- runBatch
: WalletUserProxy -> WalletUserProxy_BatchTransfer -> Update WalletUserProxy_BatchTransferResult
Validate the batch call and run it
- executeTransferCalls
: WalletUserProxy -> Party -> Optional (ContractId FeaturedAppRight) -> [TransferFactoryCall] -> InstrumentHoldingMap -> [TransferInstructionResult] -> Update WalletUserProxy_BatchTransferResult
Run the individual transfer calls in the batch with proper threading of input holdings.
- exerciseProxyChoice
: HasExercise t ch r => WalletUserProxy -> ContractId t -> ProxyArg ch -> (ContractId t -> Update Party) -> Update (ProxyResult r)
Shared code to execute the proxied choice.
- validateAppRight
: WalletUserProxy -> ContractId FeaturedAppRight -> Update ()
- createAppMarker
: WalletUserProxy -> Party -> ContractId FeaturedAppRight -> Update FeaturedAppRight_CreateActivityMarkerResult
- proxyBeneficiaries
: WalletUserProxy -> Party -> [AppRewardBeneficiary]
Get the list of beneficiaries for the featured app marker.
Comments