Module std-policies: Reference and API
std-policies is a module that contains pure only helpers to deal with
standard policies. The module is intended to be used by wallets, market-places, tokens creators
to simplify development. It avoids manipulating modrefs directly, but instead allows manipulating simple strings.
Helpers
to-policy
name string → module{token-policy-ng-v1
Convert a policy name to the corresponding policy modref.
(use marmalade-ng.std-policies)
(to-policy "INSTANT-MINT")
> marmalade-ng.std-policies.instant-mint
list-to-policies
name [string] → [module{token-policy-ng-v1}]
Convert a list of policy names to a list of policies.
(use marmalade-ng.std-policies)
(list-to-policies ["INSTANT-MINT", "ROYALTY"])
> [marmalade-ng.std-policies.instant-mint marmalade-ng.std-policies.roaylty]
to-policies
names string → [module{token-policy-ng-v1}]
Convert a list of names concatenated in a single string to a list of policies.
(use marmalade-ng.std-policies)
(to-policies "INSTANT-MINT ROYALTY")
> [marmalade-ng.std-policies.instant-mint, marmalade-ng.std-policies.roaylty]
from-policy
policy module{token-policy-ng-v1} → string
Convert a policy name to the corresponding policy modref.
In case of a non-standard policy, the string UNKNOWN_xxxxxxxxxxxxxxxx is returned. where xxxxxxxxxxxxxxxx is a unique 16 hexadecimal characters derived from the hash of the policy
(use marmalade-ng.std-policies)
(from-policy marmalade-ng.std-policies.instant-mint)
> "INSTANT MINT"
(from-policy private-ns.my-own-policy)
> "UNKNOWN_AB147ECB247D648"
policies-to-list
policies
[module{token-policy-ng-v1}]→[string]
Convert a list of policies to a list of policy names.
(use marmalade-ng.std-policies)
(policies-to-list [marmalade-ng.std-policies.instant-mint, marmalade-ng.std-policies.roaylty])
> ["INSTANT-MINT", "ROYALTY"]
from-policies
policies
[module{token-policy-ng-v1}]→string
Convert a list of policies to a concatenated string.
(use marmalade-ng.std-policies)
(from-policies [marmalade-ng.std-policies.instant-mint, private-ns.my-own-policy, marmalade-ng.std-policies.roaylty ])
> "INSTANT-MINT UNKNOWN_AB147D ROYALTY"