Skip to content

Commit

Permalink
[skip-ci] wip: rFOX RUNE rewards parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre committed Jun 14, 2024
1 parent 3e08ec9 commit cb7b3ab
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Parser implements SubParser<Tx> {
const outboundMemoEvent = Object.values(tx.events).find(event => !!event['outbound']?.['memo'])
const outboundMemo = outboundMemoEvent?.['outbound']?.['memo']

const memo = messageMemo || outboundMemo
const memo = messageMemo || outboundMemo || tx.memo

if (!memo) return

Expand Down
5 changes: 5 additions & 0 deletions packages/unchained-client/src/parser/thorchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ export interface ParserArgs {
midgardUrl: string
}

// TODO(gomes): obviously revert me and use actual memo from rewards
const RFOX_REWARDS_MEMO = "beep boop I'm a memo"
const streamingSwapRegex = /:(\d+|(\d+(?:e[+-]?\d+)?))\/\d+\/\d+:/

const getLiquidityType = (pool: string): LiquidityType => (pool.includes('/') ? 'Savers' : 'LP')
Expand All @@ -129,6 +131,9 @@ export class Parser {
async parse(memo: string): Promise<TxSpecific | undefined> {
const [type] = memo.split(':')

if (memo.includes(RFOX_REWARDS_MEMO))
return { data: { parser: 'thorchain', memo, method: 'rfoxRewards' } }

switch (type.toLowerCase()) {
case 'swap':
case '=':
Expand Down
3 changes: 2 additions & 1 deletion src/assets/translations/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,8 @@
"swapRefund": "Swap Refund",
"withdraw": "Withdraw Requested",
"withdrawNative": "Withdraw",
"withdrawOut": "Withdraw Received"
"withdrawOut": "Withdraw Received",
"rfoxRewards": "Rewards Received"
},
"foxy": {
"stake": "Stake",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const TransactionMethod = ({
case Method.Unstake:
case Method.WithdrawDelegatorReward:
case Method.WithdrawOut:
case Method.RfoxRewards:
return TransferType.Receive
case Method.Approve:
case Method.Revoke:
Expand Down
12 changes: 12 additions & 0 deletions src/components/TransactionHistoryRows/TransactionTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ type TransactionTagProps = {
txDetails: TxDetails
transfersByType: Record<TransferType, Transfer[]>
}

// TODO(gomes): obviously revert me and use actual memo from rewards
const RFOX_REWARDS_MEMO = "beep boop I'm a memo"

export const TransactionTag: React.FC<TransactionTagProps> = ({ txDetails, transfersByType }) => {
const txData = useMemo(() => txDetails?.tx.data, [txDetails?.tx.data])
const isNft = useMemo(() => {
Expand All @@ -29,6 +33,14 @@ export const TransactionTag: React.FC<TransactionTagProps> = ({ txDetails, trans
</Tag>
)
}

if (txData && txData.parser === 'thorchain' && txData.memo === RFOX_REWARDS_MEMO) {
return (
<Tag size='sm' colorScheme='green' variant='subtle' lineHeight={1}>
rFOX
</Tag>
)
}
if (txData && txData.parser === 'thorchain' && txData.liquidity) {
return (
<Tag size='sm' colorScheme='green' variant='subtle' lineHeight={1}>
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useTxDetails/useTxDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export enum Method {
RecvPacket = 'recv_packet',
Refund = 'refund',
RemoveLiquidityEth = 'removeLiquidityETH',
RfoxRewards = 'rfoxRewards',
Revoke = 'revoke',
Stake = 'stake',
SwapOut = 'swapOut',
Expand Down

0 comments on commit cb7b3ab

Please sign in to comment.