-
Notifications
You must be signed in to change notification settings - Fork 0
Passport
Wowok Protocol edited this page May 23, 2024
·
4 revisions
Passport is used to pass one or more guards. Definition
// Each passport becomes invalid after a PTB transaction. Therefore, when a PTB transaction includes multiple guard verifications, a single passport can be used to verify all guards that need to be passed. GuardData records information for each guard that needs to be passed: including bytecode (bcs), and the constant table(constants)
struct GuardData has store, drop, copy {
guard_id: address,
constants: vector<constant>,
bcs: BCS,
}
// PTB collects future witness information for Guards and completes the witness information verification before passport verification. For example, verifying that the information of a future order of a service meets the conditions, verifying that a future progress of a machine meets the conditions of running to a certain node, etc.
struct Witness has drop, store {
future: address,
witness: address
}
// Passport object
struct Passport has key {
id: UID,
guard: TableVec<GuardData>, // guards info
process: vector<vector<u8>>, // vector< vector<type(u8) | raw-data >
tx_hash: vector<u8>, // current tx_hash
futures: vector<Witness>, // real witness record
guard_cursor: u64, // guard cursor for verifying
exception: bool,
result: bool, // result for verifing
}
// The maximum number of guards a passport can pass
const MAX_GUARD_COUNT: u64 = 8;
Operations
Create a new passport
new() : Passport
Add a guard
guard_add(passport: &mut Passport, guard: &Guard) : bool
Destroy passport (after passing through a guard, reclaim the passport's storage space, recommended)
destroy(passport: Passport)
Solidify passport (for querying details that have been verified, used for debugging and observation)
fun freezen(passport: Passport)
Verify passport, returns the object information required by the guard for the query
passport_verify(passport:&mut Passport, clock:&Clock) : address
Used to inform the passport after the witness has completed the verification of the object relationship (for example, when a guard requires information about a machine's future progress instances, etc.)
public(friend) fun WITNESS(passport:&mut Passport, value:&address, witness:&address)
On-chain query of the repository for the guard object
none
Errors
102004: Passport has not completed all conditions verification
102006: Passport has been completed
102008: Passport result is Invalid
102010: Invalid data type
102014: Environment constant does not match
102018: Passport is invalid or has been used
102020: Passport verification failed
102022: Passport result type is invalid
102028: Passport has initiated verification
102030: Incorrect call argument
102066: Query object does not match
102067: Invalid query command
102068: Passport is required