From ba625b1cd303f318e75defb43bcd8a5faf2df958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Schie=C3=9Fl?= Date: Sun, 29 Jul 2018 07:43:14 +0200 Subject: [PATCH] remove contains only, and add attibute_assert --- bsip-0040.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bsip-0040.md b/bsip-0040.md index fd7df57..fff721a 100644 --- a/bsip-0040.md +++ b/bsip-0040.md @@ -81,11 +81,11 @@ List of possible asserts are: | `lt, le, gt, ge` | `comparative` | stateless | | `limit` | [`max_cumsum`, `interval_in_sec`] | [`current_cumsum`, `interval_began`] | | `limit_monthly` | [`max_cumsum`, `interval_in_months`] | [`current_cumsum`, `interval_began`] | -| `contains_only` | [`list`, `of`, `allowed`, `fields`] | stateless | +| `may_mutate` | `attribute_to_assert` = [{`attribute_identifier`: `any of above assert_objects`}] | stateless | There is no implicit type conversion when attempting to assert, incompatible type means assert failure. -In the following we list possible `asserts`. Mentioning `argument value` refers to the value of the argument of the operation specified `argument` in `assert_object`. +In the following we list possible `asserts`. Mentioning `argument value` refers to the value of the argument of the operation specified `argument` in `assert_object`. The logic does not differentiate if an `argument` is optional or mandatory. All asserts imply: If the `argument` is given, it must pass the `assert`. If the `argument` is not given, assert is implicitly passed. #### `any` Stateless assert, all argument types. `Argument value` must be equal to one of values in the data list @@ -113,8 +113,11 @@ The assert that needs to pass is now `current_cumsum + incoming value <= max_cum #### `limit_monthly` Statefull assert, only `int` type arguments. Analogue to `limit`, but `interval_began` is initially set to `month(valid_from)` and set to `month(now)` on update, additionally the time assert is `month(now) >= interval_began + interval_in_months` (include logic for month overflow when year changes). -#### `contains_only` -Stateless assert, only for dictionary type objects like `options`. The `argument` of the operation is a dictionary type objects and is only allowed to contain the attributes in the data list. +#### `attribute_assert` +Stateless assert, only for dictionary type objects. The `attribute_to_assert` list contains mappings between attributes and asserts that they must fulfill, if present in the dictionary. + +Note: +- Assume `asset_update_operation`. All attributes of its `options` must be filled on update call. This assert can not be used to realize a "may only change attribute xzy of `options`". This would require that the logic knows which of the arguments are reflected on-chain and it knows how to query it for every operation that contains `options`. If `options` are to be restricted with this assert, all values that should not change would need be fixated by defining a `any` assert for those attributes, while having e.g. a `lt` assert for the one attribute that is allowed to change. #### Example: Simple transfer Assume account A and B and some unrelated key K. Furthermore A has a custom active authority in the following way: