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

  1. create a WalletUserProxy contract with the provider set to the app provider’s party

  2. setup 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.

Signatory: provider

Field

Type

Description

provider

Party

The app provider whose featured app right should be triggered

providerWeight

Decimal

Reward weight for the provider

userWeight

Decimal

Reward weight for the user, set to 0.0 if the user should not receive a reward

extraBeneficiaries

[AppRewardBeneficiary]

Extra beneficiaries to add

optAllowList

Optional [Party]

An optional allow list of parties that can use the proxy

Data Types

data ProxyArg arg

Generic argument to the proxy choices.

ProxyArg

Field

Type

Description

user

Party

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)

instance SetField "user" (ProxyArg arg) Party

data ProxyResult r

Generic result of the proxy choices.

ProxyResult

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)

Functions

exerciseProxyChoice

: HasExercise t ch r => WalletUserProxy -> ContractId t -> ProxyArg ch -> (ContractId t -> Update Party) -> Update (ProxyResult r)

Shared code to execute the proxied choice.

proxyBeneficiaries

: WalletUserProxy -> Party -> [AppRewardBeneficiary]

Get the list of beneficiaries for the featured app marker.

validProxy

: WalletUserProxy -> Bool

require

: CanAssert m => Text -> Bool -> m ()

Check whether a required condition is true. If it’s not, abort the transaction with a message saying that the requirement was not met.

Comments