|
| 1 | +package integration |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + |
| 6 | + transactionpb "github.com/code-payments/ocp-protobuf-api/generated/go/transaction/v1" |
| 7 | + |
| 8 | + "github.com/code-payments/ocp-server/ocp/common" |
| 9 | + "github.com/code-payments/ocp-server/ocp/data/swap" |
| 10 | +) |
| 11 | + |
| 12 | +// Antispam is an antispam guard integration that apps can implement to check |
| 13 | +// whether operations of interest are allowed to be performed. |
| 14 | +type Antispam interface { |
| 15 | + AllowOpenAccounts(ctx context.Context, owner *common.Account, accountSet transactionpb.OpenAccountsMetadata_AccountSet) (bool, string, error) |
| 16 | + |
| 17 | + AllowSendPayment(ctx context.Context, owner, destination *common.Account, isPublic bool) (bool, string, error) |
| 18 | + |
| 19 | + AllowReceivePayments(ctx context.Context, owner *common.Account, isPublic bool) (bool, string, error) |
| 20 | + |
| 21 | + AllowDistribution(ctx context.Context, owner *common.Account, isPublic bool) (bool, string, error) |
| 22 | + |
| 23 | + AllowSwap(ctx context.Context, fundingSource swap.FundingSource, owner, fromMint, toMint *common.Account, amount uint64, initializesMint bool) (bool, string, error) |
| 24 | + |
| 25 | + AllowCurrencyLaunch(ctx context.Context, owner *common.Account, name, symbol string) (bool, string, error) |
| 26 | +} |
| 27 | + |
| 28 | +type allowEverythingAntispamIntegration struct { |
| 29 | +} |
| 30 | + |
| 31 | +// NewAllowEverythingAntispamIntegration returns a default antispam integration that allows everything |
| 32 | +func NewAllowEverythingAntispamIntegration() Antispam { |
| 33 | + return &allowEverythingAntispamIntegration{} |
| 34 | +} |
| 35 | + |
| 36 | +func (i *allowEverythingAntispamIntegration) AllowOpenAccounts(ctx context.Context, owner *common.Account, accountSet transactionpb.OpenAccountsMetadata_AccountSet) (bool, string, error) { |
| 37 | + return true, "", nil |
| 38 | +} |
| 39 | + |
| 40 | +func (i *allowEverythingAntispamIntegration) AllowSendPayment(ctx context.Context, owner, destination *common.Account, isPublic bool) (bool, string, error) { |
| 41 | + return true, "", nil |
| 42 | +} |
| 43 | + |
| 44 | +func (i *allowEverythingAntispamIntegration) AllowReceivePayments(ctx context.Context, owner *common.Account, isPublic bool) (bool, string, error) { |
| 45 | + return true, "", nil |
| 46 | +} |
| 47 | + |
| 48 | +func (i *allowEverythingAntispamIntegration) AllowDistribution(ctx context.Context, owner *common.Account, isPublic bool) (bool, string, error) { |
| 49 | + return true, "", nil |
| 50 | +} |
| 51 | + |
| 52 | +func (i *allowEverythingAntispamIntegration) AllowSwap(ctx context.Context, fundingSource swap.FundingSource, owner, fromMint, toMint *common.Account, amount uint64, initializesMint bool) (bool, string, error) { |
| 53 | + return true, "", nil |
| 54 | +} |
| 55 | + |
| 56 | +func (i *allowEverythingAntispamIntegration) AllowCurrencyLaunch(ctx context.Context, owner *common.Account, name, symbol string) (bool, string, error) { |
| 57 | + return true, "", nil |
| 58 | +} |
0 commit comments