@@ -7,58 +7,134 @@ order: 2
7
7
layout : full
8
8
---
9
9
10
- # Policy Manager
10
+ # Policy Manager in Marmalade V2
11
11
12
- Marmalade V2 introduces the
13
- [ Policy manager] ( https://github.com/kadena-io/marmalade/blob/v2/pact/policy-manager/policy-manager.pact ) ,
14
- a powerful tool that revolutionizes how policies are managed, but also enabling
15
- stacking of policies for non-fungible tokens (NFTs). The Policy Manager serves
16
- as the repository for these policies. If a general-purpose policy gains
17
- widespread acceptance, it could be incorporated as a concrete policy. This
18
- allows dApps, marketplaces, or wallets to readily identify token properties,
19
- such as collections, non-fungibility, or royalty specifications, by leveraging
20
- the concrete policies stored in the Policy Manager.
12
+ Marmalade V2 introduces a groundbreaking Policy Manager, a tool that transforms
13
+ how policies for non-fungible tokens (NFTs) are curated and implemented. With
14
+ this innovation, dApps, marketplaces, and wallets can seamlessly identify token
15
+ properties like collections, non-fungibility, and royalty specifications,
16
+ leveraging the concrete policies within the Policy Manager.
21
17
22
- ## Key Features of the Policy Manager
18
+ ## Overview
23
19
24
- ** 1. Policies Tailored to You**
20
+ The Policy Manager stands as a central repository for these policies, supporting
21
+ both general-purpose policies and concrete policies. When a general-purpose
22
+ policy becomes widely accepted, it has the potential to be assimilated as a
23
+ concrete policy, contributing to the stability and uniformity of token
24
+ attributes.
25
25
26
- With the Policy Manager, you can add (manage) policies that match your unique
27
- use cases. These policies define the behavior and attributes of your NFTs.
26
+ ** Key Features of the Policy Manager:**
28
27
29
- ** 2. Dynamic Implementation with Concrete Policies and Custom Policies**
28
+ 1 . ** Tailored Policies** : Customize and manage policies to define your NFTs'
29
+ behavior and attributes.
30
+ 2 . ** Dynamic Implementation** : Utilize both immutable Concrete Policies
31
+ (provided by Marmalade's creators) and Custom Policies (created by anyone)
32
+ for additional, unique functionalities.
33
+ 3 . ** Policy Stacking** : Stack multiple policies with tokens, resulting in
34
+ dynamic and intricate NFTs.
35
+ 4 . ** Standardized Enforcement** : Policies are consistently enforced across the
36
+ Marmalade ecosystem through the
37
+ [ ` kip.token-policy-v2 ` ] ( https://github.com/kadena-io/marmalade/blob/v2/pact/kip/token-policy-v2.pact )
38
+ interface.
30
39
31
- ** Concrete Policies ** : These are the default policies provided by Marmalade's
32
- creators, representing the most commonly used functionalities in token creation.
33
- They are immutable and written and maintained by the Marmalade team .
40
+ Venturing further into the realm of Marmalade V2, token creators gain the
41
+ flexibility to program tokens by selecting multiple policies, encompassing rules
42
+ for creation, mints, transfers, burns, sales, and more .
34
43
35
- ** Custom Policies** : In addition to concrete policies, you can create custom
36
- policies that provide additional functionality. Once established, these policies
37
- are also immutable and can be added during token creation.
44
+ ## Technical Details
38
45
39
- With the Policy Manager, you can stack multiple policies and associate them with
40
- tokens. This unprecedented flexibility allows NFTs to accommodate N number of
41
- policies, enabling you to create dynamic and sophisticated tokens.
46
+ ### Policy Manager and Quotes
42
47
43
- ** 3. Type Checking for Policy Validation**
48
+ The Policy Manager promotes a standard for collecting and distributing
49
+ fungibles. In the predecessor, Marmalade V1, the fixed-quote-policy managed
50
+ fungible transfers during sales. Now, with Marmalade V2, every token optionally
51
+ benefits from this feature via the Policy Manager.
44
52
45
- To ensure the correctness of your policies, the Policy Manager provides
46
- type-checking functionality. This feature identifies any inconsistencies or
47
- discrepancies between abstract policies and their concrete implementations,
48
- safeguarding the integrity of your NFT ecosystem.
53
+ ### Components
49
54
50
- ** 4. Policy Enforcement via
51
- [ kip.token-policy-v2] ( https://github.com/kadena-io/marmalade/blob/v2/pact/kip/token-policy-v2.pact )
52
- Interface**
55
+ - ** Ledgers Table** : Ensures functions are initiated only from the ledger.
56
+ - ** Concrete Policies Table** : Maintains concrete policy information for each
57
+ token.
58
+ - ** Sale Whitelist Table** : Lists valid whitelisted sale contracts.
59
+ - ** Quotes Table** : Archives quotes for quoted sales.
60
+ - ** Ledger Schema** : Contains the module reference governed by the policy
61
+ manager, adhering strictly to the ledger-v1 interface.
62
+ - ** Concrete Policies Schema** : Includes the module reference, strictly using
63
+ the token-policy-v2 interface.
53
64
54
- Each policy is enforced by the Policy Manager following the
55
- ` kip.token-policy-v2 ` interface. This standardized interface ensures consistent
56
- and reliable enforcement of policies across the Marmalade ecosystem.
65
+ ### Capabilities
57
66
58
- ---
67
+ The Policy Manager supports a comprehensive set of capabilities to cover a wide
68
+ array of functionalities:
69
+
70
+ - ` GOVERNANCE `
71
+ - ` QUOTE @event `
72
+ - ` ESCROW `
73
+ - ` INIT-CALL `
74
+ - ` TRANSFER-CALL `
75
+ - ` MINT-CALL `
76
+ - ` BURN-CALL `
77
+ - ` OFFER-CALL `
78
+ - ` WITHDRAW-CALL `
79
+ - ` BUY-CALL `
80
+ - ` SALE-GUARD-CALL `
81
+ - ` FUNGIBLE-TRANSFER-CALL `
82
+ - ` UPDATE-QUOTE-PRICE @event `
83
+ - ` SALE-WHITELIST @event `
84
+ - ` CONCRETE-POLICY @event `
85
+ - ` OFFER `
86
+ - ` BUY `
87
+ - ` WITHDRAW `
88
+
89
+ ### Policy Functions
90
+
91
+ ** General Principle** : The ` enforce-** ` functions require the ` ledger::**-CALL `
92
+ capability to be in scope, ensuring functions are initiated from the ledger.
93
+ These functions then extract the policy list from the token input, which lists
94
+ the associated policies.
95
+
96
+ - ** enforce-init** : Initiates ` policies::enforce-init ` at
97
+ ` marmalade-v2.ledger.create-token ` .
98
+ - ** enforce-mint** : Executes ` policies::enforce-mint ` at
99
+ ` marmalade-v2.ledger.mint ` .
100
+ - ** enforce-burn** : Activates ` policies::enforce-burn ` at
101
+ ` marmalade-v2.ledger.burn ` .
102
+ - ** enforce-offer** : Runs ` policies::enforce-offer ` at
103
+ ` marmalade-v2.ledger.offer ` (step 0 of ` marmalade-v2.ledger.sale ` ). Here, an
104
+ optional parameter "quote" can be accessed in the ` env-data ` field. If a quote
105
+ is identified, the offer saves this quote, and escrow accounts are generated.
106
+ Otherwise, the offer continues without quotes.
107
+ - ** enforce-withdraw** : Operates ` policies::enforce-withdraw ` at
108
+ ` marmalade-v2.ledger.withdraw ` (step 1 rollback of
109
+ ` marmalade-v2.ledger.sale ` ).
110
+ - ** enforce-buy** : Engages ` policies::enforce-buy ` at ` marmalade-v2.ledger.buy `
111
+ (step 1 of ` marmalade-v2.ledger.sale ` ).
112
+ - ** write-concrete-policy** : This function registers a concrete policy modref
113
+ into the concrete policies table.
114
+
115
+ - ** get-escrow-account** : Returns the fungible escrow account created for quoted
116
+ sales at enforce-offer. The escrow account receives the fungible from the
117
+ buyer and distributes the fungibles to the policies and the seller at buy
118
+ step.
119
+
120
+ - ** write-concrete-policy** : Registers concrete policy modref into the
121
+ concrete-policies table.
122
+
123
+ Required Capability
124
+ Capability: (CONCRETE-POLICY policy-field policy)
125
+ Signer: (keyset-ref-guard marmalade-v2.marmalade-admin)
126
+
127
+ - ** get-concrete-policy** : Returns the modref of the concrete policy.
128
+ - ** enforce-sale-pact** : Ensures that the sale parameter provided to the
129
+ function is equal to the ID of the currently executing pact. It does this by
130
+ calling the pact-id function to retrieve the ID of the currently executing
131
+ pact and comparing it to the provided sale parameter. If they are not equal,
132
+ an exception will be thrown".
59
133
60
134
With the Policy Manager and its support for policy stacking, you can craft
61
135
sophisticated and innovative NFTs that push the boundaries of creativity and
62
136
functionality. As you embark on this exciting journey, we await your innovative
63
137
ideas and creativity to further enrich the NFT experience within Kadena's
64
138
Marmalade ecosystem. Happy crafting!
139
+
140
+ [ Policy manager code] ( https://github.com/kadena-io/marmalade/blob/v2/pact/policy-manager/policy-manager.pact )
0 commit comments