状态转换

本文档描述了以下与状态转换相关的操作:

  • 创建命名空间(Create namespace)

  • 删除命名空间(Delete namespace)

  • 更新命名空间(Update namespace)

  • 更新命名空间角色(Update namespace roles)

  • 撤销命名空间角色(Revoke namespace roles)

  • 领取 Voucher(Claim Voucher)

  • 更新参数(Update params)

Create Namespace

命名空间可用于实现不同的角色和操作。

message MsgCreateNamespace {
  option (cosmos.msg.v1.signer) = "sender";
  string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];

  Namespace namespace = 2 [ (gogoproto.nullable) = false ];
}

// Namespace defines a permissions namespace
message Namespace {
  string denom = 1; // tokenfactory denom to which this namespace applies to
  string wasm_hook =
      2; // address of smart contract to apply code-based restrictions

  bool mints_paused = 3;
  bool sends_paused = 4;
  bool burns_paused = 5;

  repeated Role role_permissions = 6; // permissions for each role

  repeated AddressRoles address_roles = 7;
}

message AddressRoles {
  string address = 1;
  repeated string roles = 2;
}

message Role {
  string role = 1;
  uint32 permissions = 2;
}

步骤

  1. 创建新的 Denom

  2. 创建 MsgCreateNamespace 消息,其中包含 DenomRolePermissionsAddressRoles

  3. 验证 MsgCreateNamespace 对象。

  4. 发送创建命名空间消息。

Delete Namespace

删除命名空间将移除该命名空间及其关联的角色和权限。

message MsgDeleteNamespace {
  option (cosmos.msg.v1.signer) = "sender";
  string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];

  string namespace_denom = 2;
}

步骤

  1. 创建 MsgDeleteNamespace 消息,指定要删除的命名空间 NamespaceDenom

  2. 验证 MsgDeleteNamespace 对象。

  3. 发送删除命名空间消息。

Update Namespace

更新命名空间允许修改其关联的角色和权限。

message MsgUpdateNamespace {
  option (cosmos.msg.v1.signer) = "sender";
  string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];

  string namespace_denom =
      2; // namespace denom to which this updates are applied

  message MsgSetWasmHook { string new_value = 1; }
  MsgSetWasmHook wasm_hook =
      3; // address of smart contract to apply code-based restrictions

  message MsgSetMintsPaused { bool new_value = 1; }
  MsgSetMintsPaused mints_paused = 4;

  message MsgSetSendsPaused { bool new_value = 1; }
  MsgSetSendsPaused sends_paused = 5;

  message MsgSetBurnsPaused { bool new_value = 1; }
  MsgSetBurnsPaused burns_paused = 6;
}

步骤

  1. 创建 MsgUpdateNamespace 消息,包含 NamespaceDenom 以及新的 MintsPausedBurnsPausedSendsPaused 值。

  2. 验证 MsgUpdateNamespace 对象。

  3. 发送更新命名空间消息。

Update Namespace Roles

更新命名空间角色允许修改命名空间内的角色及其权限。

message MsgUpdateNamespaceRoles {
  option (cosmos.msg.v1.signer) = "sender";
  string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];

  string namespace_denom =
      2; // namespace denom to which this updates are applied

  repeated Role role_permissions =
      3; // new role definitions or updated permissions for existing roles
  repeated AddressRoles address_roles =
      4; // new addresses to add or new roles for existing addresses to
  // overwrite current roles
}

步骤

  1. 创建 MsgUpdateNamespaceRoles 消息,包含 NamespaceDenom、新的 RolePermissionsAddressRoles

  2. 验证 MsgUpdateNamespaceRoles 对象。

  3. 发送更新命名空间角色消息。

Revoke Namespace Roles

撤销命名空间角色将移除命名空间内地址的某些角色。

message MsgRevokeNamespaceRoles {
  option (cosmos.msg.v1.signer) = "sender";
  string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];

  string namespace_denom =
      2; // namespace denom to which this updates are applied
  repeated AddressRoles address_roles_to_revoke =
      3; // {"address" => array of roles to revoke from this address}
}

步骤

  1. 创建 MsgRevokeNamespaceRoles 消息,包含 NamespaceDenomAddressRolesToRevoke

  2. 验证 MsgRevokeNamespaceRoles 对象。

  3. 发送撤销命名空间角色消息。

Claim Voucher

message MsgClaimVoucher {
  option (amino.name) = "permissions/MsgClaimVoucher";
  option (cosmos.msg.v1.signer) = "sender";
  string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];

  string denom = 2;
}

Update Params

message MsgUpdateParams {
  option (cosmos.msg.v1.signer) = "authority";

  // authority is the address of the governance account.
  string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

  // params defines the permissions parameters to update.
  //
  // NOTE: All parameters must be supplied.
  Params params = 2 [ (gogoproto.nullable) = false ];
}

message Params {
  option (gogoproto.equal) = true;

  uint64 wasm_hook_query_max_gas = 1;
}

Last updated