github.com/status-im/status-go@v1.1.0/signal/events_community_tokens.go (about)

     1  package signal
     2  
     3  import (
     4  	"github.com/ethereum/go-ethereum/common"
     5  	"github.com/status-im/status-go/protocol/communities/token"
     6  	"github.com/status-im/status-go/protocol/protobuf"
     7  )
     8  
     9  const (
    10  
    11  	// EventCommunityTokenTransactionStatusChanged is triggered when community token contract
    12  	// transaction changed its status
    13  	EventCommunityTokenTransactionStatusChanged = "communityToken.communityTokenTransactionStatusChanged"
    14  
    15  	// EventCommunityTokenAction is triggered when the app receives a message that
    16  	// owner or some other token master did some token action, like: airdrop, burn, remote destruct
    17  	EventCommunityTokenAction = "communityToken.communityTokenAction"
    18  )
    19  
    20  type CommunityTokenTransactionSignal struct {
    21  	TransactionType string                `json:"transactionType"`
    22  	Success         bool                  `json:"success"`                  // transaction's status
    23  	Hash            common.Hash           `json:"hash"`                     // transaction hash
    24  	CommunityToken  *token.CommunityToken `json:"communityToken,omitempty"` // community token changed by transaction
    25  	OwnerToken      *token.CommunityToken `json:"ownerToken,omitempty"`     // owner token emitted by deployment transaction
    26  	MasterToken     *token.CommunityToken `json:"masterToken,omitempty"`    // master token emitted by deployment transaction
    27  	ErrorString     string                `json:"errorString"`              // information about failed operation
    28  }
    29  
    30  func SendCommunityTokenTransactionStatusSignal(transactionType string, success bool, hash common.Hash,
    31  	communityToken *token.CommunityToken, ownerToken *token.CommunityToken, masterToken *token.CommunityToken, errorString string) {
    32  	send(EventCommunityTokenTransactionStatusChanged, CommunityTokenTransactionSignal{
    33  		TransactionType: transactionType,
    34  		Success:         success,
    35  		Hash:            hash,
    36  		CommunityToken:  communityToken,
    37  		OwnerToken:      ownerToken,
    38  		MasterToken:     masterToken,
    39  		ErrorString:     errorString,
    40  	})
    41  }
    42  
    43  type CommunityTokenActionSignal struct {
    44  	CommunityToken *token.CommunityToken                    `json:"communityToken"` // community token changed by the other owner/master
    45  	ActionType     protobuf.CommunityTokenAction_ActionType `json:"actionType"`     // type od action made by the other owner/master
    46  }
    47  
    48  func SendCommunityTokenActionSignal(communityToken *token.CommunityToken, actionType protobuf.CommunityTokenAction_ActionType) {
    49  	send(EventCommunityTokenAction, CommunityTokenActionSignal{
    50  		CommunityToken: communityToken,
    51  		ActionType:     actionType,
    52  	})
    53  }