Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds noves tx types #2873

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/shared/src/lib/auxiliary/noves/enums/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
export * from './eth-rpc-method.enum'
export * from './noves-tx-type-cross-chain.enum'
export * from './noves-tx-type-dex.enum'
export * from './noves-tx-type-domain.enum'
export * from './noves-tx-type-governance.enum'
export * from './noves-tx-type-infrastructure.enum'
export * from './noves-tx-type-lending.enum'
export * from './noves-tx-type-miscellaneous.enum'
export * from './noves-tx-type-nft.enum'
export * from './noves-tx-type-special.enum'
export * from './noves-tx-type-token.enum'
export * from './noves-tx-type-yield.enum'
export * from './supported-noves-chain.enum'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// https://docs.noves.fi/reference/cross-chain
export enum NovesTxTypeCrossChain {
ReceiveFromBridge = 'receiveFromBridge',
SendToBridge = 'sendToBridge',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// https://docs.noves.fi/reference/dex-transactions
export enum NovesTxTypeDEX {
AddLiquidity = 'addLiquidity',
CancelOrderTransaction = 'cancelOrderTransaction',
CustodiedRemoveLiquidity = 'custodiedRemoveLiquidity',
DepositToExchange = 'depositToExchange',
FillOrderTransaction = 'fillOrderTransaction',
PlaceOrderTransaction = 'placeOrderTransaction',
Swap = 'swap',
RemoveLiquidity = 'removeLiquidity',
WithdrawFromExchange = 'withdrawFromExchange',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// https://docs.noves.fi/reference/domain-services
export enum NovesTxTypeDomain {
RegisterDomain = 'registerDomain',
RenewDomain = 'renewDomain',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// https://docs.noves.fi/reference/governance
export enum NovesTxTypeGovernance {
Delegate = 'delegate',
SignMultisig = 'signMultisig',
Vote = 'vote',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// https://docs.noves.fi/reference/infrastructure
export enum NovesTxTypeInfrastructure {
CreateContract = 'createContract',
DeployContract = 'deployContract',
SystemTransaction = 'systemTransaction',
ProtocolTransaction = 'protocolTransaction',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// https://docs.noves.fi/reference/lending
export enum NovesTxTypeLending {
Borrow = 'borrow',
DepositCollateral = 'depositCollateral',
Liquidate = 'liquidate',
RepayLoan = 'repayLoan',
WithdrawCollateral = 'withdrawCollateral',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// https://docs.noves.fi/reference/miscellaneous
export enum NovesTxTypeMiscellaneous {
Admin = 'admin',
MEVTransaction = 'MEVTransaction',
GamblingTransaction = 'gamblingTransaction',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// https://docs.noves.fi/reference/nft
export enum NovesTxTypeNFT {
ApproveNFTCollection = 'approveNFTCollection',
ApproveSingleNFT = 'approveSingleNFT',
BurnNFT = 'burnNFT',
BuyNFT = 'buyNFT',
CancelNFTListing = 'cancelNFTListing',
CreateNFTListing = 'createNFTListing',
MintNFT = 'mintNFT',
PlaceNFTBid = 'placeNFTBid',
ReceiveNFT = 'receiveNFT',
SendNFT = 'sendNFT',
ReceiveNFTAirdrop = 'receiveNFTAirdrop',
SendNFTAirdrop = 'sendNFTAirdrop',
ReceiveNFTRoyalty = 'receiveNFTRoyalty',
ReceiveSpamNFT = 'receiveSpamNFT',
RevokeNFTCollectionApproval = 'revokeNFTCollectionApproval',
SellNFT = 'sellNFT',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// https://docs.noves.fi/reference/special-types
export enum NovesTxTypeSpecial {
Composite = 'composite',
Failed = 'failed',
Unclassified = 'unclassified',
UnverifiedContract = 'unverifiedContract',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// https://docs.noves.fi/reference/token
export enum NovesTxTypeToken {
ApproveToken = 'approveToken',
BurnToken = 'burnToken',
MigrateToken = 'migrateToken',
SendToken = 'sendToken',
SendTokenAirdrop = 'sendTokenAirdrop',
ReceiveSpamToken = 'receiveSpamToken',
ReceiveToken = 'receiveToken',
ReceiveTokenAirdrop = 'receiveTokenAirdrop',
Refund = 'refund',
RevokeTokenApproval = 'revokeTokenApproval',
Unwrap = 'unwrap',
Wrap = 'wrap',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// https://docs.noves.fi/reference/yield
export enum NovesTxTypeYield {
ClaimRewards = 'claimRewards',
ClaimAndStake = 'claimAndStake',
LeveragedFarming = 'leveragedFarming',
RebalancePosition = 'rebalancePosition',
Lock = 'lock',
StakeNFT = 'stakeNFT',
StakeToken = 'stakeToken',
UnstakeNFT = 'unstakeNFT',
UnstakeToken = 'unstakeToken',
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { NovesTxType } from '../types/noves-tx-type.type'
import { NovesToken } from './noves-token.interface'

export interface NovesTxResponse {
Expand Down Expand Up @@ -30,7 +31,7 @@ interface Protocol {
}

interface ClassificationData {
type: string
type: NovesTxType
source: ClassificationSource
description: string
protocol: Protocol
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {
NovesTxTypeCrossChain,
NovesTxTypeDEX,
NovesTxTypeToken,
NovesTxTypeNFT,
NovesTxTypeLending,
NovesTxTypeYield,
NovesTxTypeDomain,
NovesTxTypeGovernance,
NovesTxTypeInfrastructure,
NovesTxTypeSpecial,
NovesTxTypeMiscellaneous,
} from '../enums'

export type NovesTxType =
| NovesTxTypeCrossChain
| NovesTxTypeDEX
| NovesTxTypeToken
| NovesTxTypeNFT
| NovesTxTypeLending
| NovesTxTypeYield
| NovesTxTypeDomain
| NovesTxTypeGovernance
| NovesTxTypeInfrastructure
| NovesTxTypeSpecial
| NovesTxTypeMiscellaneous
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ActivityDirection } from '@core/activity/enums'
import { generateBaseEvmActivity } from './generateBaseEvmActivity'
import { LocalEvmTransaction } from '@core/transactions/types'
import { generateEvmActivityFromLocalEvmTransaction } from './generateEvmActivityFromLocalEvmTransaction'
import { NovesTxTypeToken } from '@auxiliary/noves/enums'

export async function generateEvmActivityFromNovesTransaction(
novesTx: NovesTxResponse,
Expand All @@ -24,12 +25,10 @@ export async function generateEvmActivityFromNovesTransaction(
account
)

switch (
novesTx.classificationData.type // What are all the types and interfaces for this?
) {
case 'sendToken': // TODO: this string should be an enum
switch (novesTx.classificationData.type) {
case NovesTxTypeToken.SendToken:
return generateEvmActivityFromSendTokenClassification(baseActivity, novesTx, account)
case 'receiveToken':
case NovesTxTypeToken.ReceiveToken:
return generateEvmActivityFromReceiveTokenClassification(baseActivity, novesTx, account)
default:
return localTransaction
Expand Down
Loading