github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/session/pingpong/event/event.go (about) 1 /* 2 * Copyright (C) 2020 The "MysteriumNetwork/node" Authors. 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 package event 19 20 import ( 21 "math/big" 22 23 "github.com/ethereum/go-ethereum/common" 24 25 "github.com/mysteriumnetwork/node/identity" 26 "github.com/mysteriumnetwork/payments/crypto" 27 ) 28 29 const ( 30 // AppTopicHermesPromise represents a topic to which we send hermes promise events. 31 AppTopicHermesPromise = "hermes_promise_received" 32 // AppTopicBalanceChanged represents the balance change topic 33 AppTopicBalanceChanged = "balance_change" 34 // AppTopicEarningsChanged represents the earnings change topic 35 AppTopicEarningsChanged = "earnings_change" 36 // AppTopicInvoicePaid is a topic for publish events exchange message send to provider as a consumer. 37 AppTopicInvoicePaid = "invoice_paid" 38 // AppTopicSettlementRequest forces the settlement of promises for given provider/hermes. 39 AppTopicSettlementRequest = "settlement_request" 40 // AppTopicSettlementComplete topic for events related to completed settlement. 41 AppTopicSettlementComplete = "provider_settlement_complete" 42 // AppTopicWithdrawalRequested topic for succesfull withdrawal requests. 43 AppTopicWithdrawalRequested = "provider_withdrawal_requested" 44 ) 45 46 // AppEventSettlementRequest represents the payload that is sent on the AppTopicSettlementRequest topic. 47 type AppEventSettlementRequest struct { 48 HermesID common.Address 49 ProviderID identity.Identity 50 ChainID int64 51 } 52 53 // AppEventHermesPromise represents the payload that is sent on the AppTopicHermesPromise. 54 type AppEventHermesPromise struct { 55 Promise crypto.Promise 56 HermesID common.Address 57 ProviderID identity.Identity 58 } 59 60 // AppEventBalanceChanged represents a balance change event 61 type AppEventBalanceChanged struct { 62 Identity identity.Identity 63 Previous *big.Int 64 Current *big.Int 65 } 66 67 // AppEventEarningsChanged represents a balance change event 68 type AppEventEarningsChanged struct { 69 Identity identity.Identity 70 Previous EarningsDetailed 71 Current EarningsDetailed 72 } 73 74 // EarningsDetailed returns total and split per hermes earnings 75 type EarningsDetailed struct { 76 Total Earnings 77 PerHermes map[common.Address]Earnings 78 } 79 80 // Earnings represents current identity earnings 81 type Earnings struct { 82 LifetimeBalance *big.Int 83 UnsettledBalance *big.Int 84 } 85 86 // AppEventInvoicePaid is an update on paid invoices during current session 87 type AppEventInvoicePaid struct { 88 UUID string 89 ConsumerID identity.Identity 90 SessionID string 91 Invoice crypto.Invoice 92 } 93 94 // AppTopicGrandTotalChanged represents a topic to which we send grand total change messages. 95 const AppTopicGrandTotalChanged = "consumer_grand_total_change" 96 97 // AppEventGrandTotalChanged represents the grand total changed event. 98 type AppEventGrandTotalChanged struct { 99 Current *big.Int 100 ChainID int64 101 HermesID common.Address 102 ConsumerID identity.Identity 103 } 104 105 // AppEventSettlementComplete represent a completed settlement. 106 type AppEventSettlementComplete struct { 107 ProviderID identity.Identity 108 HermesID common.Address 109 ChainID int64 110 } 111 112 // AppEventWithdrawalRequested represents a request for withdrawal. 113 type AppEventWithdrawalRequested struct { 114 ProviderID identity.Identity 115 HermesID common.Address 116 FromChain, ToChain int64 117 }