Search Apps Documentation Source Content File Folder Download Copy Actions Download

init.gno

1.03 Kb ยท 52 lines
 1package v1
 2
 3import (
 4	"gno.land/r/gnoswap/protocol_fee"
 5)
 6
 7func init() {
 8	registerProtocolFeeV1()
 9}
10
11func registerProtocolFeeV1() {
12	protocol_fee.RegisterInitializer(cross, func(protocolFeeStore protocol_fee.IProtocolFeeStore) protocol_fee.IProtocolFee {
13		err := initStoreData(protocolFeeStore)
14		if err != nil {
15			panic(err)
16		}
17
18		return NewProtocolFeeV1(protocolFeeStore)
19	})
20}
21
22func initStoreData(protocolFeeStore protocol_fee.IProtocolFeeStore) error {
23	if !protocolFeeStore.HasDevOpsPctStoreKey() {
24		err := protocolFeeStore.InitializeDevOpsPct()
25		if err != nil {
26			return err
27		}
28	}
29
30	if !protocolFeeStore.HasAccuToGovStakerStoreKey() {
31		err := protocolFeeStore.InitializeAccuToGovStaker()
32		if err != nil {
33			return err
34		}
35	}
36
37	if !protocolFeeStore.HasAccuToDevOpsStoreKey() {
38		err := protocolFeeStore.InitializeAccuToDevOps()
39		if err != nil {
40			return err
41		}
42	}
43
44	if !protocolFeeStore.HasTokenListWithAmountsStoreKey() {
45		err := protocolFeeStore.InitializeTokenListWithAmount()
46		if err != nil {
47			return err
48		}
49	}
50
51	return nil
52}