archway-network / archway

Archway Network
https://archway.io
Other
72 stars 99 forks source link

feat(x/callback): Implement state for callback struct storage #484

Closed spoo-bar closed 9 months ago

spoo-bar commented 10 months ago

Implementation of Keeper's Set methods and associated tests for the following types:

The store path needs to be height + contractAddr + jobId

message Callback {
    // contract_address is the address of the contract which is requesting the callback (bech32 encoded).
    string contract_address = 1;
    // job_id is an identifier the callback requestor can pass in to identify the callback when it happens. 
    uint64 job_id = 2;
    // callback_height is the height at which the callback is executed.
    uint64 callback_height = 3;
    // fee_split is the breakdown of the fees paid by the contract to reserve the callback
    CallbackFeesFeeSplit fee_split = 4;
    // reserved_by is the address which reserved the callback (bech32 encoded).
    string reserved_by = 5;
}

The Set() should fail when

  1. contract_address does not exist
  2. job id for that contract_address already exists at that callback height
  3. callback height is not in the future
  4. reserved by is not contract/owner

Implementation of Keeper's Get

Two get methods.

  1. lists all the registered callbacks
  2. Lists all callbacks at given height

implementation of Keeper's Delete

Deletes an individual callback. It should fail when

  1. callback at that height and job id does not exist
  2. the sender is not contract/owner
spoo-bar commented 9 months ago

Implemented with https://github.com/archway-network/archway/pull/500