-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for erc20 token approvals (#2565)
* add token approval activity * show approval activity in activity list * show smart contract data for approval activities * fix title * fix: get confirmations from blockscout transaction * rvert coin transfer generation * revert rename --------- Co-authored-by: Nicole O'Brien <[email protected]>
- Loading branch information
1 parent
2410a89
commit 6c3163b
Showing
14 changed files
with
138 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 11 additions & 2 deletions
13
packages/shared/src/components/activities/evm/info/EvmSmartContractInformation.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/shared/src/lib/core/activity/types/evm/evm-token-approval-activity.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { EvmActivityType } from '@core/activity/enums/evm' | ||
import { TokenStandard } from '@core/token' | ||
import { NftStandard } from '@core/nfts' | ||
import { BaseEvmActivity } from './base-evm-activity.type' | ||
import { IParsedInput } from '@core/layer-2/interfaces' | ||
|
||
export type EvmTokenApprovalActivity = BaseEvmActivity & { | ||
type: EvmActivityType.TokenApproval | ||
tokenTransfer: { | ||
standard: TokenStandard.Erc20 | TokenStandard.Irc30 | NftStandard.Irc27 | NftStandard.Erc721 | ||
tokenId: string | ||
rawAmount: bigint | ||
} | ||
rawData: string | ||
|
||
methodId?: string | ||
method?: string | ||
inputs?: IParsedInput[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 13 additions & 2 deletions
15
packages/shared/src/lib/core/activity/utils/isEvmTokenActivity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
import { NetworkNamespace } from '@core/network/enums' | ||
import { EvmActivityType } from '../enums/evm' | ||
import { Activity, EvmBalanceChangeActivity, EvmTokenMintingActivity, EvmTokenTransferActivity } from '../types' | ||
import { | ||
Activity, | ||
EvmBalanceChangeActivity, | ||
EvmTokenApprovalActivity, | ||
EvmTokenMintingActivity, | ||
EvmTokenTransferActivity, | ||
} from '../types' | ||
|
||
export function isEvmTokenActivity( | ||
activity: Activity | ||
): activity is EvmBalanceChangeActivity | EvmTokenMintingActivity | EvmTokenTransferActivity { | ||
): activity is | ||
| EvmBalanceChangeActivity | ||
| EvmTokenMintingActivity | ||
| EvmTokenTransferActivity | ||
| EvmTokenApprovalActivity { | ||
return ( | ||
activity.namespace === NetworkNamespace.Evm && | ||
(activity.type === EvmActivityType.TokenTransfer || | ||
activity.type === EvmActivityType.TokenMinting || | ||
activity.type === EvmActivityType.TokenApproval || | ||
activity.type === EvmActivityType.BalanceChange) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters