#object-store #smart-contracts #blockchain #finance #defi #figure-tech

os-gateway-contract-attributes

一个简单的Rust库,用于向CosmWasm响应添加属性

2个稳定版本

1.0.1 2022年9月22日

#13 in #defi

Apache-2.0

28KB
260

对象存储网关合约属性

此库包含用于在基于CosmWasm的智能合约中添加事件属性的辅助函数。

这要与对象存储网关的事件流监控能力一起使用。

要通过网关生成访问权限授予和撤销,请在响应声明中包含OsGatewayAttributeGenerator,并使用所需的值

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",
               )
           )
   }
}

无运行时依赖