状态

Genesis state 定义了模块的初始状态,用于设置和初始化该模块。

// GenesisState defines the permissions module's genesis state.
type GenesisState struct {
	// params defines the parameters of the module.
	Params     Params      `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
	Namespaces []Namespace `protobuf:"bytes,2,rep,name=namespaces,proto3" json:"namespaces"`
}

Params

权限模块不使用任何参数

// Params defines the parameters for the permissions module.
type Params struct {
	WasmHookQueryMaxGas uint64 `protobuf:"varint,1,opt,name=wasm_hook_query_max_gas,json=wasmHookQueryMaxGas,proto3" json:"wasm_hook_query_max_gas,omitempty"`
}

Namespaces

地址可以创建具有新代币名称(denom)的权限命名空间。命名空间定义了角色和操作,以控制命名空间内的用户被允许或禁止执行的操作或扮演的角色。

// Namespace defines a permissions namespace
type Namespace struct {
	Denom           string            `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"`
	WasmHook        string            `protobuf:"bytes,2,opt,name=wasm_hook,json=wasmHook,proto3" json:"wasm_hook,omitempty"`
	MintsPaused     bool              `protobuf:"varint,3,opt,name=mints_paused,json=mintsPaused,proto3" json:"mints_paused,omitempty"`
	SendsPaused     bool              `protobuf:"varint,4,opt,name=sends_paused,json=sendsPaused,proto3" json:"sends_paused,omitempty"`
	BurnsPaused     bool              `protobuf:"varint,5,opt,name=burns_paused,json=burnsPaused,proto3" json:"burns_paused,omitempty"`
	RolePermissions map[string]uint32 `protobuf:"bytes,6,rep,name=role_permissions,json=rolePermissions,proto3" json:"role_permissions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
	AddressRoles    map[string]*Roles `protobuf:"bytes,7,rep,name=address_roles,json=addressRoles,proto3" json:"address_roles,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}

在命名空间内,MintsPausedSendsPausedBurnsPaused 决定了新代币是否可以铸造、发送或销毁。这些设置只能由 Denom 管理员更新。

Roles

角色是在命名空间内的字符串,每个角色都具有特定的权限。

type Roles struct {
	Roles []string `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"`
}

Actions

操作(Actions)使用二的幂来表示不同类型的操作,其中:

Action_UNSPECIFIED = 0  
Action_MINT = 1  
Action_RECEIVE = 2  
Action_BURN = 4  
// each Action enum value should be a power of two
type Action int32

Role

Role 存储角色名称及其被允许执行的操作。

// Role is only used for storage
type Role struct {
	Name        string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Permissions uint32 `protobuf:"varint,2,opt,name=permissions,proto3" json:"permissions,omitempty"`
}

RoleIDs

RoleIDs 存储角色的 ID。

// used in storage
type RoleIDs struct {
	RoleIds []uint32 `protobuf:"varint,1,rep,packed,name=role_ids,json=roleIds,proto3" json:"role_ids,omitempty"`
}

Voucher

Voucher 用于存储因交易失败而暂存的代币,直到原始接收者获得 RECEIVE 权限。

  • Vouchers: 0x06 | Address | denom -> ProtocolBuffer(Coin)

Last updated