-
Notifications
You must be signed in to change notification settings - Fork 0
Guard
enoloo edited this page May 23, 2024
·
3 revisions
Guard provides consensus protection for wowok-related operations by setting one or more on-chain conditions. Once an operation has a guard set, the operator must provide a passport record of the actual on-chain conditions met to proceed. For example, if a service provider does not complete the service within 3 days (on-chain data condition), the consumer can claim a 30% compensation, etc.
Definition
// Constant for guard
struct Constant has drop, copy, store {
identifier: u8, // id
type: u8, // futrue value?
value: vector<u8>,
}
// Guard Object
struct Guard has key {
id: UID,
description: String,
Constants: vector<Constant>, // constant table
input: BCS, // Guard bytecode
}
// Guard.input.maximum length
const MAX_INPUT_SIZE:u64 = 2048;
Operations
Create a new guard
new(description:String, bcsInput:vector<u8>, ctx:&mut TxContext) :Guard
Launch guard (freeze object), once the guard is launched, it will no longer be modifiable
create(guard: Guard) : address
Launch a new guard, only the signer of the transaction can pass this guard
signer_guard(ctx: &mut TxContext) : address
Launch a new guard, any operation can pass
everyone_guard(ctx: &mut TxContext) : address
Set description
description_set(guard: &mut Guard, description: String)
Add, remove, and clear Constants
variable_add(guard: &mut Guard, identifier: u8, type: u8, value: vector<u8>, bModifyIfExist: bool)
variable_remove(guard: &mut Guard, identifier: u8)
variable_remove_all(guard: &mut Guard)
Errors
101002: Invalid Sense binder value
101004: Invalid Variable type value
All Guard queries
// All Guard Queries:
[MODULES.permission, 'builder', 1, [], ValueType.TYPE_ADDRESS],
[MODULES.permission, 'is_admin', 2, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.permission, 'has_rights', 3, [ValueType.TYPE_ADDRESS, ValueType.TYPE_U64], ValueType.TYPE_BOOL],
[MODULES.permission, 'contains_address', 4, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.permission, 'contains_index', 5, [ValueType.TYPE_ADDRESS, ValueType.TYPE_U64], ValueType.TYPE_BOOL],
[MODULES.permission, 'contains_guard', 6, [ValueType.TYPE_ADDRESS, ValueType.TYPE_U64], ValueType.TYPE_BOOL],
[MODULES.permission, 'contains_guard', 7, [ValueType.TYPE_ADDRESS, ValueType.TYPE_U64], ValueType.TYPE_ADDRESS],
[MODULES.permission, 'entity_count', 8, [], ValueType.TYPE_U64],
[MODULES.permission, 'admin_count', 9, [], ValueType.TYPE_U64],
[MODULES.repository, 'permission', 11, [], ValueType.TYPE_ADDRESS],
[MODULES.repository, 'policy_contains', 12, [ValueType.TYPE_VEC_U8], ValueType.TYPE_BOOL],
[MODULES.repository, 'policy_has_permission_index', 13, [ValueType.TYPE_VEC_U8], ValueType.TYPE_BOOL],
[MODULES.repository, 'policy_permission_index', 14, [ValueType.TYPE_VEC_U8], ValueType.TYPE_U64],
[MODULES.repository, 'policy_value_type', 15, [ValueType.TYPE_VEC_U8], ValueType.TYPE_U8],
[MODULES.repository, 'contains_id', 16, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.repository, 'contains_value', 17, [ValueType.TYPE_ADDRESS, ValueType.TYPE_VEC_U8], ValueType.TYPE_BOOL],
[MODULES.repository, 'value_without_type', 18, [ValueType.TYPE_ADDRESS, ValueType.TYPE_VEC_U8], ValueType.TYPE_VEC_U8],
[MODULES.repository, 'value', 19, [ValueType.TYPE_ADDRESS, ValueType.TYPE_VEC_U8], ValueType.TYPE_VEC_U8],
[MODULES.repository, 'type', 20, [], ValueType.TYPE_U8],
[MODULES.repository, 'policy_mode', 21, [], ValueType.TYPE_U8],
[MODULES.repository, 'reference_count', 22, [], ValueType.TYPE_U64],
[MODULES.repository, 'has_reference', 23, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.machine, 'permission', 31, [], ValueType.TYPE_ADDRESS],
[MODULES.machine, 'has_paused', 32, [], ValueType.TYPE_BOOL],
[MODULES.machine, 'has_published', 33, [], ValueType.TYPE_BOOL],
[MODULES.machine, 'consensus_repositories_contains', 34, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.machine, 'has_endpoint', 35, [], ValueType.TYPE_BOOL],
[MODULES.machine, 'endpoint', 36, [], ValueType.TYPE_VEC_U8],
[MODULES.progress, 'machine', 51, [], ValueType.TYPE_ADDRESS],
[MODULES.progress, 'current', 52, [], ValueType.TYPE_VEC_U8],
[MODULES.progress, 'has_parent', 53, [], ValueType.TYPE_BOOL],
[MODULES.progress, 'parent', 54, [], ValueType.TYPE_ADDRESS],
[MODULES.progress, 'has_task', 55, [], ValueType.TYPE_BOOL],
[MODULES.progress, 'task', 56, [], ValueType.TYPE_ADDRESS],
[MODULES.progress, 'has_namedOperator', 57, [ValueType.TYPE_VEC_U8], ValueType.TYPE_BOOL],
[MODULES.progress, 'namedOperator_contains', 58, [ValueType.TYPE_VEC_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.progress, 'has_context_repository', 59, [], ValueType.TYPE_BOOL],
[MODULES.progress, 'context_repository', 60, [], ValueType.TYPE_ADDRESS],
[MODULES.demand, 'permission', 71, [], ValueType.TYPE_ADDRESS],
[MODULES.demand, 'has_time_expire', 72, [], ValueType.TYPE_BOOL],
[MODULES.demand, 'time_expire', 73, [], ValueType.TYPE_U64],
[MODULES.demand, 'earnest_count', 74, [], ValueType.TYPE_U64],
[MODULES.demand, 'has_guard', 75, [], ValueType.TYPE_BOOL],
[MODULES.demand, 'guard', 76, [], ValueType.TYPE_ADDRESS],
[MODULES.demand, 'has_yes', 77, [], ValueType.TYPE_BOOL],
[MODULES.demand, 'yes', 78, [], ValueType.TYPE_ADDRESS],
[MODULES.demand, 'presenters_count', 79, [], ValueType.TYPE_U64],
[MODULES.demand, 'has_presenter', 80, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.demand, 'persenter', 81, [ValueType.TYPE_ADDRESS], ValueType.TYPE_ADDRESS],
[MODULES.order, 'amount', 91, [], ValueType.TYPE_U64],
[MODULES.order, 'payer', 92, [], ValueType.TYPE_ADDRESS],
[MODULES.order, 'service', 93, [], ValueType.TYPE_ADDRESS],
[MODULES.order, 'has_progress', 94, [], ValueType.TYPE_BOOL],
[MODULES.order, 'progress', 95, [], ValueType.TYPE_ADDRESS],
[MODULES.order, 'has_requred_info', 96, [], ValueType.TYPE_BOOL],
[MODULES.order, 'requred_info_service_pubkey', 97, [], ValueType.TYPE_VEC_U8],
[MODULES.order, 'requred_info_customer_pubkey', 98, [], ValueType.TYPE_VEC_U8],
[MODULES.order, 'requred_info_info', 99, [], ValueType.TYPE_VEC_VEC_U8],
[MODULES.order, 'has_discount', 100, [], ValueType.TYPE_BOOL],
[MODULES.order, 'discount', 101, [], ValueType.TYPE_ADDRESS],
[MODULES.order, 'balance', 102, [], ValueType.TYPE_U64],
[MODULES.order, 'bRefunded', 103, [], ValueType.TYPE_U8],
[MODULES.order, 'bWithdrawed', 104, [], ValueType.TYPE_U8],
[MODULES.service, 'permission', 111, [], ValueType.TYPE_ADDRESS],
[MODULES.service, 'payee', 112, [], ValueType.TYPE_ADDRESS],
[MODULES.service, 'has_buy_guard', 113, [], ValueType.TYPE_BOOL],
[MODULES.service, 'buy_guard', 114, [], ValueType.TYPE_ADDRESS],
[MODULES.service, 'repository_contains', 115, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.service, 'has_withdraw_guard', 116, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.service, 'withdraw_guard_percent', 117, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
[MODULES.service, 'has_refund_guard', 118, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.service, 'refund_guard_percent', 119, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
[MODULES.service, 'has_sale', 120, [ValueType.TYPE_VEC_U8], ValueType.TYPE_BOOL],
[MODULES.service, 'sale_price', 121, [ValueType.TYPE_VEC_U8], ValueType.TYPE_U64],
[MODULES.service, 'sale_stock', 122, [ValueType.TYPE_VEC_U8], ValueType.TYPE_U64],
[MODULES.service, 'has_machine', 123, [], ValueType.TYPE_BOOL],
[MODULES.service, 'machine', 124, [], ValueType.TYPE_ADDRESS],
[MODULES.service, 'bPaused', 125, [], ValueType.TYPE_BOOL],
[MODULES.service, 'bPublished', 126, [], ValueType.TYPE_BOOL],
[MODULES.service, 'has_required', 127, [], ValueType.TYPE_BOOL],
[MODULES.service, 'requrired_pubkey', 128, [], ValueType.TYPE_VEC_U8],
[MODULES.service, 'requrired_info', 129, [], ValueType.TYPE_VEC_VEC_U8],
[MODULES.reward, 'permission', 151, [], ValueType.TYPE_ADDRESS],
[MODULES.reward, 'rewards_count_remain', 152, [], ValueType.TYPE_U64],
[MODULES.reward, 'rewards_count_supplied', 153, [], ValueType.TYPE_U64],
[MODULES.reward, 'guard_count', 154, [], ValueType.TYPE_U64],
[MODULES.reward, 'has_guard', 155, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.reward, 'guard_portions', 156, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
[MODULES.reward, 'time_expire', 157, [], ValueType.TYPE_U64],
[MODULES.reward, 'has_claimed', 158, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.reward, 'claimed', 159, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
[MODULES.reward, 'has_claimed_count', 160, [], ValueType.TYPE_U64],
[MODULES.reward, 'is_sponsor', 161, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.reward, 'sponsor', 162, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
[MODULES.reward, 'sponsor_count', 163, [], ValueType.TYPE_U64],
[MODULES.reward, 'bAllowRepeatClaim', 164, [], ValueType.TYPE_BOOL],
[MODULES.reward, 'claimed_potions_count', 165, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
[MODULES.vote, 'permission', 171, [], ValueType.TYPE_ADDRESS],
[MODULES.vote, 'bOptions_locked_for_voting', 172, [], ValueType.TYPE_BOOL],
[MODULES.vote, 'bdeadline_locked', 173, [], ValueType.TYPE_BOOL],
[MODULES.vote, 'bLockedGuard', 174, [], ValueType.TYPE_BOOL],
[MODULES.vote, 'max_choice_count', 175, [], ValueType.TYPE_U8],
[MODULES.vote, 'deadline', 176, [], ValueType.TYPE_U64],
[MODULES.vote, 'has_reference', 177, [], ValueType.TYPE_BOOL],
[MODULES.vote, 'reference', 178, [], ValueType.TYPE_ADDRESS],
[MODULES.vote, 'has_guard', 179, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.vote, 'guard', 180, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
[MODULES.vote, 'voted', 181, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.vote, 'voted_weight', 182, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
[MODULES.vote, 'has_agree', 183, [ValueType.TYPE_VEC_U8], ValueType.TYPE_BOOL],
[MODULES.vote, 'agree_has_object', 184, [ValueType.TYPE_VEC_U8], ValueType.TYPE_BOOL],
[MODULES.vote, 'agree_object', 185, [ValueType.TYPE_VEC_U8], ValueType.TYPE_ADDRESS],
[MODULES.vote, 'agree_count', 186, [ValueType.TYPE_VEC_U8], ValueType.TYPE_U64],
[MODULES.vote, 'agree_votes', 187, [ValueType.TYPE_VEC_U8], ValueType.TYPE_U64],
[MODULES.vote, 'voted_count', 188, [], ValueType.TYPE_U64],
[MODULES.vote, 'top1_name_by_count', 189, [], ValueType.TYPE_VEC_U8],
[MODULES.vote, 'top1_count', 190, [], ValueType.TYPE_U64],
[MODULES.vote, 'top1_name_by_votes', 191, [], ValueType.TYPE_VEC_U8],
[MODULES.vote, 'top1_votes', 192, [], ValueType.TYPE_U64],
[MODULES.wowok, 'initor', 210, [], ValueType.TYPE_ADDRESS],
[MODULES.wowok, 'everyone_guard', 211, [], ValueType.TYPE_ADDRESS],
[MODULES.wowok, 'entities', 212, [], ValueType.TYPE_ADDRESS],
[MODULES.wowok, 'grantor_count', 213, [], ValueType.TYPE_U64],
[MODULES.wowok, 'has_grantor', 214, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.wowok, 'grantor_name', 215, [ValueType.TYPE_ADDRESS], ValueType.TYPE_VEC_U8],
[MODULES.wowok, 'grantor_register_time', 216, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
[MODULES.wowok, 'grantor_expired_time', 217, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
[MODULES.wowok, 'grantor_grantee', 218, [ValueType.TYPE_ADDRESS], ValueType.TYPE_ADDRESS],
[MODULES.entity, 'has_entity', 230, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
[MODULES.entity, 'entity_like', 231, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
[MODULES.entity, 'entity_unlike', 232, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
[MODULES.entity, 'entity_infomation', 233, [ValueType.TYPE_ADDRESS], ValueType.TYPE_VEC_U8],