Skip to content

FigureTechnologies/os-gateway-contract-attributes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Object Store Gateway Contract Attributes

Status

Latest Release crates.io Apache 2.0 License

Usage

This library includes helper functions for appending event attributes in a CosmWasm-based smart contract.

This is to be used in tandem with the event-stream-watching capabilities of Object Store Gateway.

To generate access grants and revokes via the gateway, include the OsGatewayAttributeGenerator in your Response declaration with the desired values:

mod some_mod {
   use cosmwasm_std::Response;
   use os_gateway_contract_attributes::OsGatewayAttributeGenerator;

   fn gen_grant_response() -> Response<String> {
       Response::new()
           .add_attributes(
               OsGatewayAttributeGenerator::access_grant(
                   // Scope Address
                   "scope1qzn7jghj8puprmdcvunm3330jutsj803zz",
                   // Grantee Address
                   "tp12vu3ww5tfta78fl3fvehacunrud4gtqqcpfwnr",
               )
               // An optional access grant id may be appended to requests to enable referral
               // to grants after the event is processed.  Fluent functions that are not
               // required by the constructor function are completely optional and only have
               // additional impacts on resulting grants when processed by Object Store Gateway.
               .with_access_grant_id("my_unique_id")
           )
   }

   fn gen_revoke_response() -> Response<String> {
       Response::new()
           .add_attributes(
               OsGatewayAttributeGenerator::access_revoke(
                   // Scope Address
                   "scope1qzn7jghj8puprmdcvunm3330jutsj803zz",
                   // Grantee Address
                   "tp12vu3ww5tfta78fl3fvehacunrud4gtqqcpfwnr",
               )
           )
   }
}

About

Attribute generator for object store gateway in cosmos smart contracts

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages