diff --git a/codemods/0001_add_actions_array.ts b/codemods/0001_add_actions_array.ts new file mode 100644 index 00000000..1c740833 --- /dev/null +++ b/codemods/0001_add_actions_array.ts @@ -0,0 +1,50 @@ +import { JSCodeshift } from 'jscodeshift'; + +module.exports = function (fileInfo, api) { + const j: JSCodeshift = api.jscodeshift; + const root = j(fileInfo.source); + + const findTransactionContextVariableId = (path) => { + const firstVariableId = path.value.right.properties + .find((property) => property.key.name === 'variables') + .value.properties?.find((property2) => { + return property2.value?.properties?.some( + (property3) => property3.key.name === 'id', + ); + }); + + return firstVariableId + ? firstVariableId.value.properties.find((p) => p.key.name === 'id')?.value + : null; + }; + + root + .find(j.AssignmentExpression, { + left: { + object: { name: 'transaction' }, + property: { name: 'context' }, + }, + }) + .forEach((path) => { + const t = findTransactionContextVariableId(path); + const newValue = t + ? t.type === 'MemberExpression' + ? j.memberExpression(t.object, t.property) + : j.templateLiteral( + t.quasis.map((q) => j.templateElement(q.value, q.tail)), + t.expressions.map((e) => + j.memberExpression(e.object, e.property), + ), + ) + : null; + if (newValue) { + const actionsPropertyAssignment = j.objectProperty( + j.identifier('actions'), + j.arrayExpression([newValue]), + ); + path.value.right['properties'].unshift(actionsPropertyAssignment); + } + }); + + return root.toSource(); +}; diff --git a/package-lock.json b/package-lock.json index dec5f10d..59d8d9d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@once-upon/evm-context", - "version": "1.0.48", + "version": "1.1.0-5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@once-upon/evm-context", - "version": "1.0.48", + "version": "1.1.0-5", "license": "MIT", "dependencies": { "axios": "^1.6.8", diff --git a/package.json b/package.json index cc1f13b1..9175423d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@once-upon/evm-context", - "version": "1.0.48", + "version": "1.1.0-5", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/contextualizers/bridges/acrossProtocol/destination.ts b/src/contextualizers/bridges/acrossProtocol/destination.ts index c7e4df75..fef7213c 100644 --- a/src/contextualizers/bridges/acrossProtocol/destination.ts +++ b/src/contextualizers/bridges/acrossProtocol/destination.ts @@ -5,6 +5,7 @@ import { Transaction, HeuristicContextActionEnum, Log, + HeuristicPrefix, } from '../../../types'; import { ACROSS_PROTOCOL_RELAYER_ABI, @@ -73,6 +74,11 @@ export function generate(transaction: Transaction): Transaction { const chainId = Number(filledRelayEvent.args['originChainId'] as bigint); const amount = formatEther(filledRelayEvent.args['amount'] as bigint); transaction.context = { + actions: [ + HeuristicContextActionEnum.BRIDGED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.BRIDGED}`, + ], + summaries: { category: 'MULTICHAIN', en: { @@ -80,6 +86,7 @@ export function generate(transaction: Transaction): Transaction { default: '[[subject]][[bridged]][[amount]]from[[originChainId]]', }, }, + variables: { subject: { type: 'address', @@ -96,6 +103,7 @@ export function generate(transaction: Transaction): Transaction { }, bridged: { type: 'contextAction', + id: HeuristicContextActionEnum.BRIDGED, value: HeuristicContextActionEnum.BRIDGED, }, }, diff --git a/src/contextualizers/bridges/acrossProtocol/source.ts b/src/contextualizers/bridges/acrossProtocol/source.ts index 4924eed6..af4cdf16 100644 --- a/src/contextualizers/bridges/acrossProtocol/source.ts +++ b/src/contextualizers/bridges/acrossProtocol/source.ts @@ -5,6 +5,7 @@ import { Transaction, HeuristicContextActionEnum, Log, + HeuristicPrefix, } from '../../../types'; import { ACROSS_PROTOCOL_RELAYER_ABI, @@ -75,6 +76,11 @@ export function generate(transaction: Transaction): Transaction { ); const amount = formatEther(fundsDepositedEvent.args['amount'] as bigint); transaction.context = { + actions: [ + HeuristicContextActionEnum.BRIDGED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.BRIDGED}`, + ], + summaries: { category: 'MULTICHAIN', en: { @@ -82,6 +88,7 @@ export function generate(transaction: Transaction): Transaction { default: '[[subject]][[bridged]][[amount]]to[[chainID]]', }, }, + variables: { subject: { type: 'address', @@ -98,6 +105,7 @@ export function generate(transaction: Transaction): Transaction { }, bridged: { type: 'contextAction', + id: HeuristicContextActionEnum.BRIDGED, value: HeuristicContextActionEnum.BRIDGED, }, }, diff --git a/src/contextualizers/bridges/degen/destination.ts b/src/contextualizers/bridges/degen/destination.ts index fe2a5b4c..39760db6 100644 --- a/src/contextualizers/bridges/degen/destination.ts +++ b/src/contextualizers/bridges/degen/destination.ts @@ -8,6 +8,7 @@ import { ContextSummaryVariableType, HeuristicContextActionEnum, AssetTransfer, + HeuristicPrefix, } from '../../../types'; import { DEGEN_BRIDGES } from './constants'; @@ -85,6 +86,11 @@ export function generate(transaction: Transaction): Transaction { } transaction.context = { + actions: [ + HeuristicContextActionEnum.BRIDGED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.BRIDGED}`, + ], + summaries: { category: 'MULTICHAIN', en: { @@ -93,6 +99,7 @@ export function generate(transaction: Transaction): Transaction { '[[person]][[bridged]]via[[address]]and[[asset]]was transferred', }, }, + variables: { person: { type: 'address', @@ -105,6 +112,7 @@ export function generate(transaction: Transaction): Transaction { asset, bridged: { type: 'contextAction', + id: HeuristicContextActionEnum.BRIDGED, value: HeuristicContextActionEnum.BRIDGED, }, }, diff --git a/src/contextualizers/bridges/degen/source.ts b/src/contextualizers/bridges/degen/source.ts index 5ed90f68..a93fd0e7 100644 --- a/src/contextualizers/bridges/degen/source.ts +++ b/src/contextualizers/bridges/degen/source.ts @@ -8,6 +8,7 @@ import { ContextETHType, AssetTransfer, ContextSummaryVariableType, + HeuristicPrefix, } from '../../../types'; import { DEGEN_BRIDGES } from './constants'; @@ -88,6 +89,11 @@ export function generate(transaction: Transaction): Transaction { } transaction.context = { + actions: [ + HeuristicContextActionEnum.BRIDGED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.BRIDGED}`, + ], + summaries: { category: 'MULTICHAIN', en: { @@ -96,6 +102,7 @@ export function generate(transaction: Transaction): Transaction { '[[person]][[bridged]]via[[address]]and[[asset]]was transferred', }, }, + variables: { person: { type: 'address', @@ -108,6 +115,7 @@ export function generate(transaction: Transaction): Transaction { asset, bridged: { type: 'contextAction', + id: HeuristicContextActionEnum.BRIDGED, value: HeuristicContextActionEnum.BRIDGED, }, }, diff --git a/src/contextualizers/bridges/hopTransferToL1/destination.ts b/src/contextualizers/bridges/hopTransferToL1/destination.ts index dbd7d128..9a4e718b 100644 --- a/src/contextualizers/bridges/hopTransferToL1/destination.ts +++ b/src/contextualizers/bridges/hopTransferToL1/destination.ts @@ -3,6 +3,7 @@ import { AssetType, EventLogTopics, HeuristicContextActionEnum, + HeuristicPrefix, Transaction, } from '../../../types'; import { HOP_WITHDRAWAL_BONDED_EVENT_ABI, HOP_RELAYERS } from './constants'; @@ -74,6 +75,11 @@ export function generate(transaction: Transaction): Transaction { ); transaction.context = { + actions: [ + HeuristicContextActionEnum.BRIDGED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.BRIDGED}`, + ], + summaries: { category: 'MULTICHAIN', en: { @@ -81,6 +87,7 @@ export function generate(transaction: Transaction): Transaction { default: '[[subject]][[bridged]][[amount]]from[[chainID]]', }, }, + variables: { subject: { type: 'address', @@ -97,6 +104,7 @@ export function generate(transaction: Transaction): Transaction { }, bridged: { type: 'contextAction', + id: HeuristicContextActionEnum.BRIDGED, value: HeuristicContextActionEnum.BRIDGED, }, }, diff --git a/src/contextualizers/bridges/hopTransferToL1/source.ts b/src/contextualizers/bridges/hopTransferToL1/source.ts index 2c9c0ddf..0f2f6ded 100644 --- a/src/contextualizers/bridges/hopTransferToL1/source.ts +++ b/src/contextualizers/bridges/hopTransferToL1/source.ts @@ -3,6 +3,7 @@ import { AssetType, EventLogTopics, HeuristicContextActionEnum, + HeuristicPrefix, Transaction, } from '../../../types'; import { HOP_TRANSFER_SENT_EVENT_ABI, HOP_RELAYERS } from './constants'; @@ -70,6 +71,11 @@ export function generate(transaction: Transaction): Transaction { const amount = formatEther(decodedTransferSentLog.args['amount'] as bigint); transaction.context = { + actions: [ + HeuristicContextActionEnum.BRIDGED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.BRIDGED}`, + ], + summaries: { category: 'MULTICHAIN', en: { @@ -77,6 +83,7 @@ export function generate(transaction: Transaction): Transaction { default: '[[subject]][[bridged]][[amount]]to[[chainID]]', }, }, + variables: { subject: { type: 'address', @@ -93,6 +100,7 @@ export function generate(transaction: Transaction): Transaction { }, bridged: { type: 'contextAction', + id: HeuristicContextActionEnum.BRIDGED, value: HeuristicContextActionEnum.BRIDGED, }, }, diff --git a/src/contextualizers/bridges/hopTransferToL2/destination.ts b/src/contextualizers/bridges/hopTransferToL2/destination.ts index 22f7a76c..16d78032 100644 --- a/src/contextualizers/bridges/hopTransferToL2/destination.ts +++ b/src/contextualizers/bridges/hopTransferToL2/destination.ts @@ -3,6 +3,7 @@ import { AssetType, EventLogTopics, HeuristicContextActionEnum, + HeuristicPrefix, Transaction, } from '../../../types'; import { @@ -77,6 +78,11 @@ export function generate(transaction: Transaction): Transaction { ); transaction.context = { + actions: [ + HeuristicContextActionEnum.BRIDGED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.BRIDGED}`, + ], + summaries: { category: 'MULTICHAIN', en: { @@ -84,6 +90,7 @@ export function generate(transaction: Transaction): Transaction { default: '[[subject]][[bridged]][[amount]]from[[chainID]]', }, }, + variables: { subject: { type: 'address', @@ -100,6 +107,7 @@ export function generate(transaction: Transaction): Transaction { }, bridged: { type: 'contextAction', + id: HeuristicContextActionEnum.BRIDGED, value: HeuristicContextActionEnum.BRIDGED, }, }, diff --git a/src/contextualizers/bridges/hopTransferToL2/source.ts b/src/contextualizers/bridges/hopTransferToL2/source.ts index 492ec45e..2de01df0 100644 --- a/src/contextualizers/bridges/hopTransferToL2/source.ts +++ b/src/contextualizers/bridges/hopTransferToL2/source.ts @@ -3,6 +3,7 @@ import { AssetType, EventLogTopics, HeuristicContextActionEnum, + HeuristicPrefix, Transaction, } from '../../../types'; import { HOP_TRANSFER_SENT_TO_L2_EVENT_ABI, HOP_RELAYERS } from './constants'; @@ -73,6 +74,11 @@ export function generate(transaction: Transaction): Transaction { decodedTransferSentToL2Log.args['amount'] as bigint, ); transaction.context = { + actions: [ + HeuristicContextActionEnum.BRIDGED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.BRIDGED}`, + ], + variables: { subject: { type: 'address', @@ -89,9 +95,11 @@ export function generate(transaction: Transaction): Transaction { }, bridged: { type: 'contextAction', + id: HeuristicContextActionEnum.BRIDGED, value: HeuristicContextActionEnum.BRIDGED, }, }, + summaries: { category: 'MULTICHAIN', en: { diff --git a/src/contextualizers/bridges/opStack/destination.ts b/src/contextualizers/bridges/opStack/destination.ts index 28cda52d..73ed0e50 100644 --- a/src/contextualizers/bridges/opStack/destination.ts +++ b/src/contextualizers/bridges/opStack/destination.ts @@ -8,6 +8,7 @@ import { ContextERC1155Type, AssetTransfer, HeuristicContextActionEnum, + HeuristicPrefix, } from '../../../types'; export function contextualize(transaction: Transaction): Transaction { @@ -73,6 +74,11 @@ export function generate(transaction: Transaction): Transaction { // TODO; not sure why we didn't set context here for optimism transaction.context = { + actions: [ + HeuristicContextActionEnum.BRIDGED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.BRIDGED}`, + ], + summaries: { category: 'MULTICHAIN', en: { @@ -80,6 +86,7 @@ export function generate(transaction: Transaction): Transaction { default: '[[sender]][[bridged]][[asset]]from[[chainID]]', }, }, + variables: { sender: { type: 'address', @@ -91,6 +98,7 @@ export function generate(transaction: Transaction): Transaction { }, bridged: { type: 'contextAction', + id: HeuristicContextActionEnum.BRIDGED, value: HeuristicContextActionEnum.BRIDGED, }, asset, diff --git a/src/contextualizers/bridges/opStack/source.ts b/src/contextualizers/bridges/opStack/source.ts index 8cdfbfad..0884559f 100644 --- a/src/contextualizers/bridges/opStack/source.ts +++ b/src/contextualizers/bridges/opStack/source.ts @@ -12,6 +12,7 @@ import { ContextERC1155Type, EventLogTopics, HeuristicContextActionEnum, + HeuristicPrefix, } from '../../../types'; import { GATEWAY_CHAIN_ID_MAPPING, @@ -100,6 +101,11 @@ export function generate(transaction: Transaction): Transaction { } transaction.context = { + actions: [ + HeuristicContextActionEnum.BRIDGED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.BRIDGED}`, + ], + summaries: { category: 'MULTICHAIN', en: { @@ -107,6 +113,7 @@ export function generate(transaction: Transaction): Transaction { default: '[[sender]][[bridged]][[asset]]', }, }, + variables: { sender: { type: 'address', @@ -114,6 +121,7 @@ export function generate(transaction: Transaction): Transaction { }, bridged: { type: 'contextAction', + id: HeuristicContextActionEnum.BRIDGED, value: HeuristicContextActionEnum.BRIDGED, }, asset, diff --git a/src/contextualizers/bridges/reservoir/destination.ts b/src/contextualizers/bridges/reservoir/destination.ts index 98404282..e78ff0f2 100644 --- a/src/contextualizers/bridges/reservoir/destination.ts +++ b/src/contextualizers/bridges/reservoir/destination.ts @@ -81,6 +81,8 @@ export function generate(transaction: Transaction): Transaction { } transaction.context = { + actions: [BridgeContextActionEnum.COMPLETED_A_CROSS_CHAIN_INTERACTION], + summaries: { category: 'MULTICHAIN', en: { @@ -89,6 +91,7 @@ export function generate(transaction: Transaction): Transaction { '[[person]][[completedACrossChainInteraction]]via[[address]]and[[asset]]was transferred', }, }, + variables: { person: { type: 'address', @@ -101,6 +104,7 @@ export function generate(transaction: Transaction): Transaction { asset, completedACrossChainInteraction: { type: 'contextAction', + id: BridgeContextActionEnum.COMPLETED_A_CROSS_CHAIN_INTERACTION, value: BridgeContextActionEnum.COMPLETED_A_CROSS_CHAIN_INTERACTION, }, }, diff --git a/src/contextualizers/bridges/reservoir/source.ts b/src/contextualizers/bridges/reservoir/source.ts index 4da31bc3..bc4fbaa6 100644 --- a/src/contextualizers/bridges/reservoir/source.ts +++ b/src/contextualizers/bridges/reservoir/source.ts @@ -61,6 +61,8 @@ export function generate(transaction: Transaction): Transaction { } transaction.context = { + actions: [BridgeContextActionEnum.INITIATED_A_CROSS_CHAIN_INTERACTION], + summaries: { category: 'MULTICHAIN', en: { @@ -68,6 +70,7 @@ export function generate(transaction: Transaction): Transaction { default: '[[person]][[initiated]]via[[address]]', }, }, + variables: { person: { type: 'address', @@ -79,6 +82,7 @@ export function generate(transaction: Transaction): Transaction { }, initiated: { type: 'contextAction', + id: BridgeContextActionEnum.INITIATED_A_CROSS_CHAIN_INTERACTION, value: BridgeContextActionEnum.INITIATED_A_CROSS_CHAIN_INTERACTION, }, }, diff --git a/src/contextualizers/bridges/starGate/destination.ts b/src/contextualizers/bridges/starGate/destination.ts index 694ce1e9..11968aab 100644 --- a/src/contextualizers/bridges/starGate/destination.ts +++ b/src/contextualizers/bridges/starGate/destination.ts @@ -8,6 +8,7 @@ import { ContextSummaryVariableType, EventLogTopics, HeuristicContextActionEnum, + HeuristicPrefix, Log, Transaction, } from '../../../types'; @@ -135,6 +136,11 @@ export function generate(transaction: Transaction): Transaction { } transaction.context = { + actions: [ + HeuristicContextActionEnum.BRIDGED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.BRIDGED}`, + ], + variables: { subject: { type: 'address', @@ -147,9 +153,11 @@ export function generate(transaction: Transaction): Transaction { }, bridged: { type: 'contextAction', + id: HeuristicContextActionEnum.BRIDGED, value: HeuristicContextActionEnum.BRIDGED, }, }, + summaries: { category: 'MULTICHAIN', en: { diff --git a/src/contextualizers/bridges/starGate/source.ts b/src/contextualizers/bridges/starGate/source.ts index 7b4c3f17..629ff74d 100644 --- a/src/contextualizers/bridges/starGate/source.ts +++ b/src/contextualizers/bridges/starGate/source.ts @@ -3,6 +3,7 @@ import { AssetType, EventLogTopics, HeuristicContextActionEnum, + HeuristicPrefix, Log, Transaction, } from '../../../types'; @@ -106,6 +107,11 @@ export function generate(transaction: Transaction): Transaction { const amount = formatEther(decodedSwapLog.args['amountSD'] as bigint); transaction.context = { + actions: [ + HeuristicContextActionEnum.BRIDGED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.BRIDGED}`, + ], + variables: { subject: { type: 'address', @@ -122,9 +128,11 @@ export function generate(transaction: Transaction): Transaction { }, bridged: { type: 'contextAction', + id: HeuristicContextActionEnum.BRIDGED, value: HeuristicContextActionEnum.BRIDGED, }, }, + summaries: { category: 'MULTICHAIN', en: { diff --git a/src/contextualizers/catchall/catchall.ts b/src/contextualizers/catchall/catchall.ts index 0ae5d0c7..c4c4a353 100644 --- a/src/contextualizers/catchall/catchall.ts +++ b/src/contextualizers/catchall/catchall.ts @@ -5,6 +5,7 @@ import { ERC721Asset, ETHAsset, HeuristicContextActionEnum, + HeuristicPrefix, Transaction, } from '../../types'; @@ -30,6 +31,11 @@ export function generate(transaction: Transaction): Transaction { const functionName = transaction?.decoded?.name || ''; transaction.context = { + actions: [ + HeuristicContextActionEnum.INTERACTED_WITH, + `${HeuristicPrefix}.${HeuristicContextActionEnum.INTERACTED_WITH}`, + ], + variables: { address: { type: 'address', @@ -46,13 +52,16 @@ export function generate(transaction: Transaction): Transaction { }, interactedWith: { type: 'contextAction', + id: HeuristicContextActionEnum.INTERACTED_WITH, value: HeuristicContextActionEnum.INTERACTED_WITH, }, called: { type: 'contextAction', + id: HeuristicContextActionEnum.CALLED, value: HeuristicContextActionEnum.CALLED, }, }, + summaries: { category: 'UNKNOWN', en: { diff --git a/src/contextualizers/heuristics/cancelPendingTransaction/cancelPendingTransaction.ts b/src/contextualizers/heuristics/cancelPendingTransaction/cancelPendingTransaction.ts index 93baf58a..680a0735 100644 --- a/src/contextualizers/heuristics/cancelPendingTransaction/cancelPendingTransaction.ts +++ b/src/contextualizers/heuristics/cancelPendingTransaction/cancelPendingTransaction.ts @@ -1,4 +1,8 @@ -import { HeuristicContextActionEnum, Transaction } from '../../../types'; +import { + HeuristicContextActionEnum, + HeuristicPrefix, + Transaction, +} from '../../../types'; export function contextualize(transaction: Transaction): Transaction { const isCanceledPendingTransaction = detect(transaction); @@ -23,6 +27,11 @@ export function detect(transaction: Transaction): boolean { export function generate(transaction: Transaction): Transaction { transaction.context = { + actions: [ + HeuristicContextActionEnum.CANCELED_A_PENDING_TRANSACTION, + `${HeuristicPrefix}.${HeuristicContextActionEnum.CANCELED_A_PENDING_TRANSACTION}`, + ], + variables: { subject: { type: 'address', @@ -30,6 +39,7 @@ export function generate(transaction: Transaction): Transaction { }, canceled: { type: 'contextAction', + id: HeuristicContextActionEnum.CANCELED_A_PENDING_TRANSACTION, value: HeuristicContextActionEnum.CANCELED_A_PENDING_TRANSACTION, }, nonce: { @@ -37,6 +47,7 @@ export function generate(transaction: Transaction): Transaction { value: transaction.nonce, }, }, + summaries: { category: 'DEV', en: { diff --git a/src/contextualizers/heuristics/contractDeployment/contractDeployment.ts b/src/contextualizers/heuristics/contractDeployment/contractDeployment.ts index 05626037..ed1011a0 100644 --- a/src/contextualizers/heuristics/contractDeployment/contractDeployment.ts +++ b/src/contextualizers/heuristics/contractDeployment/contractDeployment.ts @@ -1,4 +1,8 @@ -import { HeuristicContextActionEnum, Transaction } from '../../../types'; +import { + HeuristicContextActionEnum, + HeuristicPrefix, + Transaction, +} from '../../../types'; export function contextualize(transaction: Transaction): Transaction { const isContractDeployment = detect(transaction); @@ -21,6 +25,11 @@ function generate(transaction: Transaction): Transaction { } transaction.context = { + actions: [ + HeuristicContextActionEnum.DEPLOYED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.DEPLOYED}`, + ], + variables: { deployerAddress: { type: 'address', @@ -32,9 +41,11 @@ function generate(transaction: Transaction): Transaction { }, deployed: { type: 'contextAction', + id: HeuristicContextActionEnum.DEPLOYED, value: HeuristicContextActionEnum.DEPLOYED, }, }, + summaries: { category: 'DEV', en: { diff --git a/src/contextualizers/heuristics/erc1155Mint/erc1155Mint.ts b/src/contextualizers/heuristics/erc1155Mint/erc1155Mint.ts index 2fa1d15f..16903840 100644 --- a/src/contextualizers/heuristics/erc1155Mint/erc1155Mint.ts +++ b/src/contextualizers/heuristics/erc1155Mint/erc1155Mint.ts @@ -4,6 +4,7 @@ import { ERC20Asset, ERC1155AssetTransfer, HeuristicContextActionEnum, + HeuristicPrefix, } from '../../../types'; import { KNOWN_ADDRESSES } from '../../../helpers/constants'; import { @@ -101,6 +102,11 @@ export function generate(transaction: Transaction): Transaction { Object.keys(totalERC20Payment).length > 0; transaction.context = { + actions: [ + HeuristicContextActionEnum.MINTED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.MINTED}`, + ], + variables: { token: { type: AssetType.ERC1155, @@ -118,6 +124,7 @@ export function generate(transaction: Transaction): Transaction { }, minted: { type: 'contextAction', + id: HeuristicContextActionEnum.MINTED, value: HeuristicContextActionEnum.MINTED, }, }, diff --git a/src/contextualizers/heuristics/erc1155Purchase/erc1155Purchase.ts b/src/contextualizers/heuristics/erc1155Purchase/erc1155Purchase.ts index a8a49c9e..05f3a1b1 100644 --- a/src/contextualizers/heuristics/erc1155Purchase/erc1155Purchase.ts +++ b/src/contextualizers/heuristics/erc1155Purchase/erc1155Purchase.ts @@ -8,6 +8,7 @@ import { AssetType, ERC20Asset, HeuristicContextActionEnum, + HeuristicPrefix, Transaction, } from '../../../types'; @@ -106,6 +107,11 @@ export function generate(transaction: Transaction): Transaction { (totalETHPayment > BigInt(0) ? 1 : 0); transaction.context = { + actions: [ + HeuristicContextActionEnum.BOUGHT, + `${HeuristicPrefix}.${HeuristicContextActionEnum.BOUGHT}`, + ], + variables: { userOrUsers: receivingAddresses.length > 1 @@ -171,9 +177,11 @@ export function generate(transaction: Transaction): Transaction { }, bought: { type: 'contextAction', + id: HeuristicContextActionEnum.BOUGHT, value: HeuristicContextActionEnum.BOUGHT, }, }, + summaries: { category: 'NFT', en: { diff --git a/src/contextualizers/heuristics/erc20Mint/erc20Mint.ts b/src/contextualizers/heuristics/erc20Mint/erc20Mint.ts index 1594f86e..dff38088 100644 --- a/src/contextualizers/heuristics/erc20Mint/erc20Mint.ts +++ b/src/contextualizers/heuristics/erc20Mint/erc20Mint.ts @@ -4,6 +4,7 @@ import { Transaction, ERC20AssetTransfer, HeuristicContextActionEnum, + HeuristicPrefix, } from '../../../types'; import { KNOWN_ADDRESSES, WETH_ADDRESSES } from '../../../helpers/constants'; @@ -100,6 +101,11 @@ export function generate(transaction: Transaction): Transaction { : '0'; transaction.context = { + actions: [ + HeuristicContextActionEnum.MINTED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.MINTED}`, + ], + variables: { token: { type: AssetType.ERC20, @@ -117,9 +123,11 @@ export function generate(transaction: Transaction): Transaction { }, minted: { type: 'contextAction', + id: HeuristicContextActionEnum.MINTED, value: HeuristicContextActionEnum.MINTED, }, }, + summaries: { category: 'FUNGIBLE_TOKEN', en: { diff --git a/src/contextualizers/heuristics/erc20Swap/erc20Swap.ts b/src/contextualizers/heuristics/erc20Swap/erc20Swap.ts index 747702e7..f6aa49e4 100644 --- a/src/contextualizers/heuristics/erc20Swap/erc20Swap.ts +++ b/src/contextualizers/heuristics/erc20Swap/erc20Swap.ts @@ -7,6 +7,7 @@ import { ETHAsset, ContextETHType, HeuristicContextActionEnum, + HeuristicPrefix, } from '../../../types'; export function contextualize(transaction: Transaction): Transaction { @@ -111,15 +112,22 @@ export function generate(transaction: Transaction): Transaction { // Net asset transfers calls the token contract 'asset' instead of 'token' transaction.context = { + actions: [ + HeuristicContextActionEnum.SWAPPED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.SWAPPED}`, + ], + variables: { swapper, swapFrom, swapTo, swapped: { type: 'contextAction', + id: HeuristicContextActionEnum.SWAPPED, value: HeuristicContextActionEnum.SWAPPED, }, }, + summaries: { category: 'FUNGIBLE_TOKEN', en: { diff --git a/src/contextualizers/heuristics/erc721Mint/erc721Mint.ts b/src/contextualizers/heuristics/erc721Mint/erc721Mint.ts index 84f3acce..5b2ca6af 100644 --- a/src/contextualizers/heuristics/erc721Mint/erc721Mint.ts +++ b/src/contextualizers/heuristics/erc721Mint/erc721Mint.ts @@ -3,6 +3,7 @@ import { ERC20Asset, ERC721AssetTransfer, HeuristicContextActionEnum, + HeuristicPrefix, Transaction, } from '../../../types'; import { KNOWN_ADDRESSES } from '../../../helpers/constants'; @@ -100,6 +101,11 @@ export function generate(transaction: Transaction): Transaction { Object.keys(totalERC20Payment).length > 0; transaction.context = { + actions: [ + HeuristicContextActionEnum.MINTED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.MINTED}`, + ], + variables: { recipient: { type: 'address', @@ -111,9 +117,11 @@ export function generate(transaction: Transaction): Transaction { }, minted: { type: 'contextAction', + id: HeuristicContextActionEnum.MINTED, value: HeuristicContextActionEnum.MINTED, }, }, + summaries: { category: 'NFT', en: { diff --git a/src/contextualizers/heuristics/erc721Purchase/erc721Purchase.ts b/src/contextualizers/heuristics/erc721Purchase/erc721Purchase.ts index 9339cb1b..d4bc35ec 100644 --- a/src/contextualizers/heuristics/erc721Purchase/erc721Purchase.ts +++ b/src/contextualizers/heuristics/erc721Purchase/erc721Purchase.ts @@ -8,6 +8,7 @@ import { AssetType, ERC20Asset, HeuristicContextActionEnum, + HeuristicPrefix, Transaction, } from '../../../types'; @@ -107,6 +108,11 @@ export function generate(transaction: Transaction): Transaction { (totalETHPayment > BigInt(0) ? 1 : 0); transaction.context = { + actions: [ + HeuristicContextActionEnum.BOUGHT, + `${HeuristicPrefix}.${HeuristicContextActionEnum.BOUGHT}`, + ], + variables: { userOrUsers: receivingAddresses.length > 1 @@ -173,9 +179,11 @@ export function generate(transaction: Transaction): Transaction { }, bought: { type: 'contextAction', + id: HeuristicContextActionEnum.BOUGHT, value: HeuristicContextActionEnum.BOUGHT, }, }, + summaries: { category: 'NFT', en: { diff --git a/src/contextualizers/heuristics/ethTransfer/ethTransfer.ts b/src/contextualizers/heuristics/ethTransfer/ethTransfer.ts index 911a3b3c..5560d9d2 100644 --- a/src/contextualizers/heuristics/ethTransfer/ethTransfer.ts +++ b/src/contextualizers/heuristics/ethTransfer/ethTransfer.ts @@ -2,6 +2,7 @@ import { grabLogsFromTransaction } from '../../../helpers/utils'; import { AssetType, HeuristicContextActionEnum, + HeuristicPrefix, Transaction, } from '../../../types'; @@ -33,6 +34,11 @@ export function generate(transaction: Transaction): Transaction { } transaction.context = { + actions: [ + HeuristicContextActionEnum.SENT, + `${HeuristicPrefix}.${HeuristicContextActionEnum.SENT}`, + ], + variables: { sender: { type: 'address', @@ -50,9 +56,11 @@ export function generate(transaction: Transaction): Transaction { }, sent: { type: 'contextAction', + id: HeuristicContextActionEnum.SENT, value: HeuristicContextActionEnum.SENT, }, }, + summaries: { category: 'CORE', en: { diff --git a/src/contextualizers/heuristics/idm/idm.ts b/src/contextualizers/heuristics/idm/idm.ts index 34c3a933..4ecde868 100644 --- a/src/contextualizers/heuristics/idm/idm.ts +++ b/src/contextualizers/heuristics/idm/idm.ts @@ -1,4 +1,8 @@ -import { HeuristicContextActionEnum, Transaction } from '../../../types'; +import { + HeuristicContextActionEnum, + HeuristicPrefix, + Transaction, +} from '../../../types'; import { hexToString, countValidChars } from '../../../helpers/utils'; export function contextualize(transaction: Transaction): Transaction { @@ -29,6 +33,11 @@ function generate(transaction: Transaction): Transaction { if (!transaction.to) return transaction; transaction.context = { + actions: [ + HeuristicContextActionEnum.SENT_MESSAGE, + `${HeuristicPrefix}.${HeuristicContextActionEnum.SENT_MESSAGE}`, + ], + variables: { messageSender: { type: 'address', @@ -40,6 +49,7 @@ function generate(transaction: Transaction): Transaction { }, sentMessage: { type: 'contextAction', + id: HeuristicContextActionEnum.SENT_MESSAGE, value: HeuristicContextActionEnum.SENT_MESSAGE, }, receiver: { @@ -47,6 +57,7 @@ function generate(transaction: Transaction): Transaction { value: transaction.to, }, }, + summaries: { category: 'OTHER', en: { diff --git a/src/contextualizers/heuristics/tokenAirdrop/tokenAirdrop.ts b/src/contextualizers/heuristics/tokenAirdrop/tokenAirdrop.ts index dda199f8..b8b3947c 100644 --- a/src/contextualizers/heuristics/tokenAirdrop/tokenAirdrop.ts +++ b/src/contextualizers/heuristics/tokenAirdrop/tokenAirdrop.ts @@ -5,6 +5,7 @@ import { ERC20AssetTransfer, ERC721AssetTransfer, HeuristicContextActionEnum, + HeuristicPrefix, } from '../../../types'; import { KNOWN_ADDRESSES } from '../../../helpers/constants'; import { zeroAddress } from 'viem'; @@ -118,6 +119,11 @@ export function generate(transaction: Transaction): Transaction { firstAssetTransfer.type === 'erc721' ? 'NFT' : 'FUNGIBLE_TOKEN'; transaction.context = { + actions: [ + HeuristicContextActionEnum.RECEIVED_AIRDROP, + `${HeuristicPrefix}.${HeuristicContextActionEnum.RECEIVED_AIRDROP}`, + ], + variables: { recipient: recipients.length === 1 @@ -159,9 +165,11 @@ export function generate(transaction: Transaction): Transaction { }, receivedAirdrop: { type: 'contextAction', + id: HeuristicContextActionEnum.RECEIVED_AIRDROP, value: HeuristicContextActionEnum.RECEIVED_AIRDROP, }, }, + summaries: { category, en: { diff --git a/src/contextualizers/heuristics/tokenApproval/tokenApproval.ts b/src/contextualizers/heuristics/tokenApproval/tokenApproval.ts index f302ec51..12496b18 100644 --- a/src/contextualizers/heuristics/tokenApproval/tokenApproval.ts +++ b/src/contextualizers/heuristics/tokenApproval/tokenApproval.ts @@ -1,5 +1,9 @@ import { Hex } from 'viem'; -import { HeuristicContextActionEnum, Transaction } from '../../../types'; +import { + HeuristicContextActionEnum, + HeuristicPrefix, + Transaction, +} from '../../../types'; import approveAbi from './abis/Approve'; import setApprovalForAllAbi from './abis/SetApprovalForAll'; import { decodeTransactionInput } from '../../../helpers/utils'; @@ -75,6 +79,11 @@ export function generate(transaction: Transaction): Transaction { switch (decoded.functionName) { case 'approve': transaction.context = { + actions: [ + HeuristicContextActionEnum.GAVE_ACCESS, + `${HeuristicPrefix}.${HeuristicContextActionEnum.GAVE_ACCESS}`, + ], + variables: { approver: { type: 'address', @@ -90,9 +99,11 @@ export function generate(transaction: Transaction): Transaction { }, gaveAccess: { type: 'contextAction', + id: HeuristicContextActionEnum.GAVE_ACCESS, value: HeuristicContextActionEnum.GAVE_ACCESS, }, }, + summaries: { category: 'FUNGIBLE_TOKEN', en: { @@ -106,6 +117,11 @@ export function generate(transaction: Transaction): Transaction { const approved = args[1]; if (approved === true) { transaction.context = { + actions: [ + HeuristicContextActionEnum.GAVE_ACCESS, + `${HeuristicPrefix}.${HeuristicContextActionEnum.GAVE_ACCESS}`, + ], + variables: { approver: { type: 'address', @@ -121,9 +137,11 @@ export function generate(transaction: Transaction): Transaction { }, gaveAccess: { type: 'contextAction', + id: HeuristicContextActionEnum.GAVE_ACCESS, value: HeuristicContextActionEnum.GAVE_ACCESS, }, }, + summaries: { category: 'FUNGIBLE_TOKEN', en: { @@ -134,6 +152,11 @@ export function generate(transaction: Transaction): Transaction { }; } else { transaction.context = { + actions: [ + HeuristicContextActionEnum.REVOKED_ACCESS, + `${HeuristicPrefix}.${HeuristicContextActionEnum.REVOKED_ACCESS}`, + ], + variables: { approver: { type: 'address', @@ -149,9 +172,11 @@ export function generate(transaction: Transaction): Transaction { }, revokedAccess: { type: 'contextAction', + id: HeuristicContextActionEnum.REVOKED_ACCESS, value: HeuristicContextActionEnum.REVOKED_ACCESS, }, }, + summaries: { category: 'FUNGIBLE_TOKEN', en: { diff --git a/src/contextualizers/heuristics/tokenTransfer/tokenTransfer.ts b/src/contextualizers/heuristics/tokenTransfer/tokenTransfer.ts index bd35d1b9..5279590f 100644 --- a/src/contextualizers/heuristics/tokenTransfer/tokenTransfer.ts +++ b/src/contextualizers/heuristics/tokenTransfer/tokenTransfer.ts @@ -3,6 +3,7 @@ import { AssetType, ContextSummaryVariableType, HeuristicContextActionEnum, + HeuristicPrefix, Transaction, } from '../../../types'; import ERC20ERC721transferABI from './abis/combined'; @@ -68,6 +69,11 @@ export function generate(transaction: Transaction): Transaction { } transaction.context = { + actions: [ + HeuristicContextActionEnum.SENT, + `${HeuristicPrefix}.${HeuristicContextActionEnum.SENT}`, + ], + variables: { sender: { type: 'address', @@ -80,9 +86,11 @@ export function generate(transaction: Transaction): Transaction { }, sent: { type: 'contextAction', + id: HeuristicContextActionEnum.SENT, value: HeuristicContextActionEnum.SENT, }, }, + summaries: { category: 'FUNGIBLE_TOKEN', en: { diff --git a/src/contextualizers/protocol/basepaint/basepaint.ts b/src/contextualizers/protocol/basepaint/basepaint.ts index 7b225f0f..63a8ec09 100644 --- a/src/contextualizers/protocol/basepaint/basepaint.ts +++ b/src/contextualizers/protocol/basepaint/basepaint.ts @@ -5,6 +5,8 @@ import { BasepaintActionEnum, ContextVariable, ETHAsset, + ProtocolMap, + Protocols, Transaction, } from '../../../types'; import { BASEPAINT_CONTRACT, BRUSHES_CONTRACT, ABIs } from './constants'; @@ -61,9 +63,11 @@ export const generate = (transaction: Transaction): Transaction => { const pixels = pixelData.slice(2).length / 3; transaction.context = { + actions: [`${Protocols.BASEPAINT}.${BasepaintActionEnum.PAINTED}`], variables: { contextAction: { type: 'contextAction', + id: `${Protocols.BASEPAINT}.${BasepaintActionEnum.PAINTED}`, value: BasepaintActionEnum.PAINTED, }, subject: { @@ -88,7 +92,7 @@ export const generate = (transaction: Transaction): Transaction => { summaries: { category: 'PROTOCOL_1', en: { - title: 'Basepaint', + title: ProtocolMap[Protocols.BASEPAINT], default: '[[subject]][[contextAction]][[pixels]]pixels to day[[day]]using[[brush]]', }, @@ -112,6 +116,7 @@ export const generate = (transaction: Transaction): Transaction => { const variables: ContextVariable = { contextAction: { type: 'contextAction', + id: `${Protocols.BASEPAINT}.${BasepaintActionEnum.WITHDREW_REWARDS}`, value: BasepaintActionEnum.WITHDREW_REWARDS, }, subject: { @@ -133,11 +138,14 @@ export const generate = (transaction: Transaction): Transaction => { if (!transaction.to) return transaction; transaction.context = { + actions: [ + `${Protocols.BASEPAINT}.${BasepaintActionEnum.WITHDREW_REWARDS}`, + ], variables, summaries: { category: 'PROTOCOL_1', en: { - title: 'Basepaint', + title: ProtocolMap[Protocols.BASEPAINT], default: `[[subject]][[contextAction]]of[[amount]]for[[days]]day${ days.length === 1 ? "'s" : "s'" } contributions`, diff --git a/src/contextualizers/protocol/bns/registrar.ts b/src/contextualizers/protocol/bns/registrar.ts index f2a22d09..4e978e93 100644 --- a/src/contextualizers/protocol/bns/registrar.ts +++ b/src/contextualizers/protocol/bns/registrar.ts @@ -1,5 +1,10 @@ import { Hex } from 'viem'; -import { BNSContextActionEnum, Transaction } from '../../../types'; +import { + BNSContextActionEnum, + ProtocolMap, + Protocols, + Transaction, +} from '../../../types'; import { BNS_ADDRESSES, BNS_CONTRACTS } from './constants'; import { decodeTransactionInput } from '../../../helpers/utils'; @@ -46,13 +51,16 @@ export const generate = (transaction: Transaction): Transaction => { const durationInDays = Math.trunc(duration / 60 / 60 / 24); transaction.context = { + actions: [`${Protocols.BNS}.${BNSContextActionEnum.REGISTERED}`], + summaries: { category: 'IDENTITY', en: { - title: 'BNS', + title: ProtocolMap[Protocols.BNS], default: `[[registerer]][[registered]][[name]]for[[duration]]`, }, }, + variables: { registerer: { type: 'address', @@ -71,6 +79,7 @@ export const generate = (transaction: Transaction): Transaction => { }, registered: { type: 'contextAction', + id: `${Protocols.BNS}.${BNSContextActionEnum.REGISTERED}`, value: BNSContextActionEnum.REGISTERED, }, }, @@ -85,13 +94,16 @@ export const generate = (transaction: Transaction): Transaction => { const durationInDays = Math.trunc(duration / 60 / 60 / 24); transaction.context = { + actions: [`${Protocols.BNS}.${BNSContextActionEnum.RENEWED}`], + summaries: { category: 'IDENTITY', en: { - title: 'BNS', + title: ProtocolMap[Protocols.BNS], default: `[[renewer]][[renewed]][[name]]for[[duration]]`, }, }, + variables: { renewer: { type: 'address', @@ -110,6 +122,7 @@ export const generate = (transaction: Transaction): Transaction => { }, renewed: { type: 'contextAction', + id: `${Protocols.BNS}.${BNSContextActionEnum.RENEWED}`, value: BNSContextActionEnum.RENEWED, }, }, diff --git a/src/contextualizers/protocol/bns/resolver.ts b/src/contextualizers/protocol/bns/resolver.ts index bab7abd3..7e3f9b90 100644 --- a/src/contextualizers/protocol/bns/resolver.ts +++ b/src/contextualizers/protocol/bns/resolver.ts @@ -1,5 +1,10 @@ import { Hex } from 'viem'; -import { BNSContextActionEnum, Transaction } from '../../../types'; +import { + BNSContextActionEnum, + ProtocolMap, + Protocols, + Transaction, +} from '../../../types'; import { BNS_ADDRESSES, BNS_CONTRACTS } from './constants'; import { decodeTransactionInput } from '../../../helpers/utils'; @@ -44,13 +49,16 @@ export const generate = (transaction: Transaction): Transaction => { switch (decode.functionName) { case 'multicall': { transaction.context = { + actions: [`${Protocols.BNS}.${BNSContextActionEnum.UPDATED_RECORDS}`], + summaries: { category: 'IDENTITY', en: { - title: 'BNS', + title: ProtocolMap[Protocols.BNS], default: `[[owner]][[updated]]`, }, }, + variables: { owner: { type: 'address', @@ -58,6 +66,7 @@ export const generate = (transaction: Transaction): Transaction => { }, updated: { type: 'contextAction', + id: `${Protocols.BNS}.${BNSContextActionEnum.UPDATED_RECORDS}`, value: BNSContextActionEnum.UPDATED_RECORDS, }, }, @@ -67,13 +76,16 @@ export const generate = (transaction: Transaction): Transaction => { } case 'setAddr': { transaction.context = { + actions: [`${Protocols.BNS}.${BNSContextActionEnum.UPDATED_ADDRESS}`], + summaries: { category: 'IDENTITY', en: { - title: 'BNS', + title: ProtocolMap[Protocols.BNS], default: `[[owner]][[updated]]`, }, }, + variables: { owner: { type: 'address', @@ -81,6 +93,7 @@ export const generate = (transaction: Transaction): Transaction => { }, updated: { type: 'contextAction', + id: `${Protocols.BNS}.${BNSContextActionEnum.UPDATED_ADDRESS}`, value: BNSContextActionEnum.UPDATED_ADDRESS, }, }, @@ -91,13 +104,16 @@ export const generate = (transaction: Transaction): Transaction => { case 'setText': { transaction.context = { + actions: [`${Protocols.BNS}.${BNSContextActionEnum.UPDATED_TEXT}`], + summaries: { category: 'IDENTITY', en: { - title: 'BNS', + title: ProtocolMap[Protocols.BNS], default: `[[owner]][[updated]]`, }, }, + variables: { owner: { type: 'address', @@ -105,6 +121,7 @@ export const generate = (transaction: Transaction): Transaction => { }, updated: { type: 'contextAction', + id: `${Protocols.BNS}.${BNSContextActionEnum.UPDATED_TEXT}`, value: BNSContextActionEnum.UPDATED_TEXT, }, }, @@ -115,13 +132,18 @@ export const generate = (transaction: Transaction): Transaction => { case 'setContenthash': { transaction.context = { + actions: [ + `${Protocols.BNS}.${BNSContextActionEnum.UPDATED_CONTENTHASH}`, + ], + summaries: { category: 'IDENTITY', en: { - title: 'BNS', + title: ProtocolMap[Protocols.BNS], default: `[[owner]][[updated]]`, }, }, + variables: { owner: { type: 'address', @@ -129,6 +151,7 @@ export const generate = (transaction: Transaction): Transaction => { }, updated: { type: 'contextAction', + id: `${Protocols.BNS}.${BNSContextActionEnum.UPDATED_CONTENTHASH}`, value: BNSContextActionEnum.UPDATED_CONTENTHASH, }, }, diff --git a/src/contextualizers/protocol/bns/reverse.ts b/src/contextualizers/protocol/bns/reverse.ts index 9c875501..c4f3131e 100644 --- a/src/contextualizers/protocol/bns/reverse.ts +++ b/src/contextualizers/protocol/bns/reverse.ts @@ -1,5 +1,10 @@ import { Hex } from 'viem'; -import { BNSContextActionEnum, Transaction } from '../../../types'; +import { + BNSContextActionEnum, + ProtocolMap, + Protocols, + Transaction, +} from '../../../types'; import { BNS_CONTRACTS, BNS_ADDRESSES } from './constants'; import { decodeTransactionInput } from '../../../helpers/utils'; @@ -41,13 +46,18 @@ export const generate = (transaction: Transaction): Transaction => { case 'setName': { const name = decode.args[0]; transaction.context = { + actions: [ + `${Protocols.BNS}.${BNSContextActionEnum.SET_REVERSE_BNS_TO}`, + ], + summaries: { category: 'IDENTITY', en: { - title: 'BNS', + title: ProtocolMap[Protocols.BNS], default: `[[setter]][[reversed]][[name]]`, }, }, + variables: { setter: { type: 'address', @@ -60,6 +70,7 @@ export const generate = (transaction: Transaction): Transaction => { }, reversed: { type: 'contextAction', + id: `${Protocols.BNS}.${BNSContextActionEnum.SET_REVERSE_BNS_TO}`, value: BNSContextActionEnum.SET_REVERSE_BNS_TO, }, }, diff --git a/src/contextualizers/protocol/bns/wrapper.ts b/src/contextualizers/protocol/bns/wrapper.ts index b56cbfaa..961d808d 100644 --- a/src/contextualizers/protocol/bns/wrapper.ts +++ b/src/contextualizers/protocol/bns/wrapper.ts @@ -1,5 +1,10 @@ import { Hex } from 'viem'; -import { BNSContextActionEnum, Transaction } from '../../../types'; +import { + BNSContextActionEnum, + ProtocolMap, + Protocols, + Transaction, +} from '../../../types'; import { BNS_ADDRESSES, BNS_CONTRACTS } from './constants'; import { decodeTransactionInput } from '../../../helpers/utils'; @@ -42,13 +47,16 @@ export const generate = (transaction: Transaction): Transaction => { switch (decode.functionName) { case 'safeTransferFrom': { transaction.context = { + actions: [`${Protocols.BNS}.${BNSContextActionEnum.TRANSFERED_NAME}`], + summaries: { category: 'IDENTITY', en: { - title: 'BNS', + title: ProtocolMap[Protocols.BNS], default: `[[sender]][[transfered]]to[[receiver]]`, }, }, + variables: { sender: { type: 'address', @@ -56,6 +64,7 @@ export const generate = (transaction: Transaction): Transaction => { }, transfered: { type: 'contextAction', + id: `${Protocols.BNS}.${BNSContextActionEnum.TRANSFERED_NAME}`, value: BNSContextActionEnum.TRANSFERED_NAME, }, receiver: { @@ -70,13 +79,16 @@ export const generate = (transaction: Transaction): Transaction => { case 'safeBatchTransferFrom': { transaction.context = { + actions: [`${Protocols.BNS}.${BNSContextActionEnum.TRANSFERED_NAMES}`], + summaries: { category: 'IDENTITY', en: { - title: 'BNS', + title: ProtocolMap[Protocols.BNS], default: `[[sender]][[transfered]]to[[receiver]]`, }, }, + variables: { sender: { type: 'address', @@ -84,6 +96,7 @@ export const generate = (transaction: Transaction): Transaction => { }, transfered: { type: 'contextAction', + id: `${Protocols.BNS}.${BNSContextActionEnum.TRANSFERED_NAMES}`, value: BNSContextActionEnum.TRANSFERED_NAMES, }, receiver: { diff --git a/src/contextualizers/protocol/boombox/boombox.ts b/src/contextualizers/protocol/boombox/boombox.ts index 00a68287..97ebe627 100644 --- a/src/contextualizers/protocol/boombox/boombox.ts +++ b/src/contextualizers/protocol/boombox/boombox.ts @@ -1,5 +1,10 @@ import { Abi, Hex, hexToBigInt } from 'viem'; -import { BoomboxContextActionEnum, Transaction } from '../../../types'; +import { + BoomboxContextActionEnum, + ProtocolMap, + Protocols, + Transaction, +} from '../../../types'; import { BOOMBOX_ABI, BOOMBOX_ARTIST_SPOTIFY_LINK, @@ -54,6 +59,8 @@ export const generate = (transaction: Transaction): Transaction => { decoded.args && decoded.args.length > 1 ? decoded.args[1] : []; transaction.context = { + actions: [`${Protocols.BOOMBOX}.${BoomboxContextActionEnum.ADDED}`], + variables: { sender: { type: 'address', @@ -71,13 +78,15 @@ export const generate = (transaction: Transaction): Transaction => { }, contextAction: { type: 'contextAction', + id: `${Protocols.BOOMBOX}.${BoomboxContextActionEnum.ADDED}`, value: BoomboxContextActionEnum.ADDED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Boombox', + title: ProtocolMap[Protocols.BOOMBOX], default: '[[sender]][[contextAction]][[artist]]on Spotify', }, }, @@ -92,6 +101,8 @@ export const generate = (transaction: Transaction): Transaction => { decoded.args && decoded.args.length > 1 ? decoded.args[2] : BigInt(0); transaction.context = { + actions: [`${Protocols.BOOMBOX}.${BoomboxContextActionEnum.SIGNED}`], + variables: { user: { type: 'address', @@ -109,13 +120,15 @@ export const generate = (transaction: Transaction): Transaction => { }, contextAction: { type: 'contextAction', + id: `${Protocols.BOOMBOX}.${BoomboxContextActionEnum.SIGNED}`, value: BoomboxContextActionEnum.SIGNED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Boombox', + title: ProtocolMap[Protocols.BOOMBOX], default: '[[user]][[contextAction]][[artist]]', }, }, @@ -137,6 +150,10 @@ export const generate = (transaction: Transaction): Transaction => { ? hexToBigInt(distributeLogs[0].topic1 as Hex).toString() : ''; transaction.context = { + actions: [ + `${Protocols.BOOMBOX}.${BoomboxContextActionEnum.DISTRIBUTED}`, + ], + variables: { sender: { type: 'address', @@ -158,13 +175,15 @@ export const generate = (transaction: Transaction): Transaction => { }, contextAction: { type: 'contextAction', + id: `${Protocols.BOOMBOX}.${BoomboxContextActionEnum.DISTRIBUTED}`, value: BoomboxContextActionEnum.DISTRIBUTED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Boombox', + title: ProtocolMap[Protocols.BOOMBOX], default: '[[sender]][[contextAction]][[amount]]for[[artist]]', }, }, diff --git a/src/contextualizers/protocol/claimCampaigns/claimTokens.ts b/src/contextualizers/protocol/claimCampaigns/claimTokens.ts index 62780825..ba07dcb8 100644 --- a/src/contextualizers/protocol/claimCampaigns/claimTokens.ts +++ b/src/contextualizers/protocol/claimCampaigns/claimTokens.ts @@ -2,6 +2,8 @@ import { Hex } from 'viem'; import { AssetType, ClaimCampaignsActionEnum, + ProtocolMap, + Protocols, Transaction, } from '../../../types'; import { @@ -56,6 +58,10 @@ export const generate = (transaction: Transaction): Transaction => { switch (decoded.functionName) { case 'claimTokens': { transaction.context = { + actions: [ + `${Protocols.CLAIM_CAMPAIGNS}.${ClaimCampaignsActionEnum.CLAIMED}`, + ], + variables: { receiver: { type: 'address', @@ -63,6 +69,7 @@ export const generate = (transaction: Transaction): Transaction => { }, contextAction: { type: 'contextAction', + id: `${Protocols.CLAIM_CAMPAIGNS}.${ClaimCampaignsActionEnum.CLAIMED}`, value: ClaimCampaignsActionEnum.CLAIMED, }, numTokens: { @@ -71,10 +78,11 @@ export const generate = (transaction: Transaction): Transaction => { token: ENJOY_CONTRACT_ADDRESS, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Claim', + title: ProtocolMap[Protocols.CLAIM_CAMPAIGNS], default: '[[receiver]][[contextAction]][[numTokens]]', }, }, diff --git a/src/contextualizers/protocol/cryptopunks/cryptopunks.ts b/src/contextualizers/protocol/cryptopunks/cryptopunks.ts index 063df263..4f348c3c 100644 --- a/src/contextualizers/protocol/cryptopunks/cryptopunks.ts +++ b/src/contextualizers/protocol/cryptopunks/cryptopunks.ts @@ -4,6 +4,8 @@ import { ContextSummaryVariableType, CryptoPunksContextActionEnum, ETHAssetTransfer, + ProtocolMap, + Protocols, Transaction, } from '../../../types'; import { CryptopunksContracts, CRYPTOPUNK_ABIS } from './constants'; @@ -84,36 +86,48 @@ export const generate = (transaction: Transaction): Transaction => { }; if (transaction.receipt?.status) { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.MINTED_PUNK}`, + ], + variables: { punk, minter, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.MINTED_PUNK}`, value: CryptoPunksContextActionEnum.MINTED_PUNK, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: '[[minter]][[contextAction]][[punk]]', }, }, }; } else { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.MINTED_PUNK}`, + ], + variables: { punk, minter, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.MINTED_PUNK}`, value: CryptoPunksContextActionEnum.MINTED_PUNK, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: 'Failed:[[minter]][[contextAction]][[punk]]', }, }, @@ -138,38 +152,50 @@ export const generate = (transaction: Transaction): Transaction => { }; if (transaction.receipt?.status) { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.LISTED_PUNK}`, + ], + variables: { seller, punk, price, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.LISTED_PUNK}`, value: CryptoPunksContextActionEnum.LISTED_PUNK, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: '[[seller]][[contextAction]][[punk]]for[[price]]', }, }, }; } else { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.LISTED_PUNK}`, + ], + variables: { seller, punk, price, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.LISTED_PUNK}`, value: CryptoPunksContextActionEnum.LISTED_PUNK, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: 'Failed:[[seller]][[contextAction]][[punk]]for[[price]]', }, }, @@ -198,38 +224,50 @@ export const generate = (transaction: Transaction): Transaction => { }; if (transaction.receipt?.status) { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.WITHDREW_BID_FOR}`, + ], + variables: { bidder, punk, price, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.WITHDREW_BID_FOR}`, value: CryptoPunksContextActionEnum.WITHDREW_BID_FOR, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: '[[bidder]][[contextAction]][[punk]]for[[price]]', }, }, }; } else { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.WITHDREW_BID_FOR}`, + ], + variables: { bidder, punk, price, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.WITHDREW_BID_FOR}`, value: CryptoPunksContextActionEnum.WITHDREW_BID_FOR, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: 'Failed:[[bidder]][[contextAction]][[punk]]for[[price]]', }, }, @@ -254,38 +292,50 @@ export const generate = (transaction: Transaction): Transaction => { }; if (transaction.receipt?.status) { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.BID_ON_PUNK}`, + ], + variables: { buyer, punk, price, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.BID_ON_PUNK}`, value: CryptoPunksContextActionEnum.BID_ON_PUNK, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: '[[buyer]][[contextAction]][[punk]]for[[price]]', }, }, }; } else { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.BID_ON_PUNK}`, + ], + variables: { buyer, punk, price, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.BID_ON_PUNK}`, value: CryptoPunksContextActionEnum.BID_ON_PUNK, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: 'Failed:[[buyer]][[contextAction]][[punk]]for[[price]]', }, }, @@ -307,36 +357,48 @@ export const generate = (transaction: Transaction): Transaction => { }; if (transaction.receipt?.status) { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.WITHDREW_FROM_CONTRACT}`, + ], + variables: { withdrawer, amount, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.WITHDREW_FROM_CONTRACT}`, value: CryptoPunksContextActionEnum.WITHDREW_FROM_CONTRACT, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: '[[withdrawer]][[contextAction]][[amount]]', }, }, }; } else { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.WITHDREW_FROM_CONTRACT}`, + ], + variables: { withdrawer, amount, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.WITHDREW_FROM_CONTRACT}`, value: CryptoPunksContextActionEnum.WITHDREW_FROM_CONTRACT, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: 'Failed:[[withdrawer]][[contextAction]][[amount]]', }, }, @@ -373,6 +435,10 @@ export const generate = (transaction: Transaction): Transaction => { value: transferTopic.decoded.decoded[0].decoded, }; transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.BOUGHT_PUNK}`, + ], + variables: { buyer, punk, @@ -380,13 +446,15 @@ export const generate = (transaction: Transaction): Transaction => { seller, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.BOUGHT_PUNK}`, value: CryptoPunksContextActionEnum.BOUGHT_PUNK, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: '[[buyer]][[contextAction]][[punk]]from[[seller]]for[[price]]', }, @@ -394,19 +462,25 @@ export const generate = (transaction: Transaction): Transaction => { }; } else { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.BOUGHT_PUNK}`, + ], + variables: { buyer, punk, price, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.BOUGHT_PUNK}`, value: CryptoPunksContextActionEnum.BOUGHT_PUNK, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: 'Failed:[[buyer]][[contextAction]][[punk]]for[[price]]', }, }, @@ -430,38 +504,50 @@ export const generate = (transaction: Transaction): Transaction => { }; if (transaction.receipt?.status) { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.TRANSFERRED_PUNK}`, + ], + variables: { sender, punk, receiver, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.TRANSFERRED_PUNK}`, value: CryptoPunksContextActionEnum.TRANSFERRED_PUNK, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: '[[sender]][[contextAction]][[punk]]to[[receiver]]', }, }, }; } else { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.TRANSFERRED_PUNK}`, + ], + variables: { sender, punk, receiver, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.TRANSFERRED_PUNK}`, value: CryptoPunksContextActionEnum.TRANSFERRED_PUNK, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: 'Failed:[[sender]][[contextAction]][[punk]]to[[receiver]]', }, @@ -482,36 +568,48 @@ export const generate = (transaction: Transaction): Transaction => { }; if (transaction.receipt?.status) { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.UNLISTED_PUNK}`, + ], + variables: { seller, punk, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.UNLISTED_PUNK}`, value: CryptoPunksContextActionEnum.UNLISTED_PUNK, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: '[[seller]][[contextAction]][[punk]]', }, }, }; } else { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.UNLISTED_PUNK}`, + ], + variables: { seller, punk, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.UNLISTED_PUNK}`, value: CryptoPunksContextActionEnum.UNLISTED_PUNK, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: 'Failed:[[seller]][[contextAction]][[punk]]', }, }, @@ -541,6 +639,10 @@ export const generate = (transaction: Transaction): Transaction => { }; if (transaction.receipt?.status) { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.LISTED_PUNK}`, + ], + variables: { seller, punk, @@ -548,13 +650,15 @@ export const generate = (transaction: Transaction): Transaction => { buyer, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.LISTED_PUNK}`, value: CryptoPunksContextActionEnum.LISTED_PUNK, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: '[[seller]][[contextAction]][[punk]]to[[buyer]]for[[price]]', }, @@ -562,6 +666,10 @@ export const generate = (transaction: Transaction): Transaction => { }; } else { transaction.context = { + actions: [ + `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.LISTED_PUNK}`, + ], + variables: { seller, punk, @@ -569,13 +677,15 @@ export const generate = (transaction: Transaction): Transaction => { buyer, contextAction: { type: 'contextAction', + id: `${Protocols.CRYPTOPUNKS}.${CryptoPunksContextActionEnum.LISTED_PUNK}`, value: CryptoPunksContextActionEnum.LISTED_PUNK, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'CryptoPunks', + title: ProtocolMap[Protocols.CRYPTOPUNKS], default: 'Failed:[[seller]][[contextAction]][[punk]]to[[buyer]]for[[price]]', }, diff --git a/src/contextualizers/protocol/disperse/disperse.ts b/src/contextualizers/protocol/disperse/disperse.ts index 555bb371..c33eb398 100644 --- a/src/contextualizers/protocol/disperse/disperse.ts +++ b/src/contextualizers/protocol/disperse/disperse.ts @@ -3,6 +3,8 @@ import { AssetType, DisperseActionEnum, ETHAssetTransfer, + ProtocolMap, + Protocols, Transaction, } from '../../../types'; import { @@ -77,6 +79,8 @@ export const generate = (transaction: Transaction): Transaction => { if (!tipTransfer) return transaction; transaction.context = { + actions: [`${Protocols.DISPERSE}.${DisperseActionEnum.TIPPED}`], + variables: { subject: { type: 'address', @@ -84,6 +88,7 @@ export const generate = (transaction: Transaction): Transaction => { }, contextAction: { type: 'contextAction', + id: `${Protocols.DISPERSE}.${DisperseActionEnum.TIPPED}`, value: DisperseActionEnum.TIPPED, }, receiver: { @@ -96,10 +101,11 @@ export const generate = (transaction: Transaction): Transaction => { unit: 'wei', }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Disperse', + title: ProtocolMap[Protocols.DISPERSE], default: '[[subject]][[contextAction]][[receiver]][[numOfEth]]', }, }, diff --git a/src/contextualizers/protocol/eas/eas.ts b/src/contextualizers/protocol/eas/eas.ts index d497addd..8f455caa 100644 --- a/src/contextualizers/protocol/eas/eas.ts +++ b/src/contextualizers/protocol/eas/eas.ts @@ -4,6 +4,8 @@ import { Transaction, EventLogTopics, EASContextActionEnum, + ProtocolMap, + Protocols, } from '../../../types'; import { decodeTransactionInput, @@ -106,6 +108,8 @@ export const generate = (transaction: Transaction): Transaction => { const attestationID = getAttestationID(transaction); transaction.context = { + actions: [`${Protocols.EAS}.${EASContextActionEnum.ATTESTED}`], + variables: { from: { type: 'address', @@ -134,13 +138,15 @@ export const generate = (transaction: Transaction): Transaction => { }, attested: { type: 'contextAction', + id: `${Protocols.EAS}.${EASContextActionEnum.ATTESTED}`, value: EASContextActionEnum.ATTESTED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'EAS', + title: ProtocolMap[Protocols.EAS], default: recipient ? '[[from]][[attested]]to[[recipient]]with schema[[schema]]🔗[[attestation]]' : '[[from]][[attested]]with schema[[schema]]🔗[[attestation]]', @@ -158,6 +164,8 @@ export const generate = (transaction: Transaction): Transaction => { const attestationID = getAttestationID(transaction); transaction.context = { + actions: [`${Protocols.EAS}.${EASContextActionEnum.ATTESTED}`], + variables: { from: { type: 'address', @@ -191,13 +199,15 @@ export const generate = (transaction: Transaction): Transaction => { }, attested: { type: 'contextAction', + id: `${Protocols.EAS}.${EASContextActionEnum.ATTESTED}`, value: EASContextActionEnum.ATTESTED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'EAS', + title: ProtocolMap[Protocols.EAS], default: recipient ? '[[attester]][[attested]]to[[recipient]]with schema[[schema]]by delegation via[[from]]🔗[[attestation]]' : '[[attester]][[attested]]with schema[[schema]]by delegation via[[from]]🔗[[attestation]]', @@ -213,6 +223,8 @@ export const generate = (transaction: Transaction): Transaction => { const count = arg.map((v) => v.data).flat().length; transaction.context = { + actions: [`${Protocols.EAS}.${EASContextActionEnum.ATTESTED}`], + variables: { from: { type: 'address', @@ -232,13 +244,15 @@ export const generate = (transaction: Transaction): Transaction => { }, attested: { type: 'contextAction', + id: `${Protocols.EAS}.${EASContextActionEnum.ATTESTED}`, value: EASContextActionEnum.ATTESTED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'EAS', + title: ProtocolMap[Protocols.EAS], default: `[[from]][[attested]][[count]]with[[schemas]]`, }, }, @@ -253,6 +267,8 @@ export const generate = (transaction: Transaction): Transaction => { const count = arg.map((v) => v.data).flat().length; transaction.context = { + actions: [`${Protocols.EAS}.${EASContextActionEnum.ATTESTED}`], + variables: { from: { type: 'address', @@ -278,13 +294,15 @@ export const generate = (transaction: Transaction): Transaction => { }, attested: { type: 'contextAction', + id: `${Protocols.EAS}.${EASContextActionEnum.ATTESTED}`, value: EASContextActionEnum.ATTESTED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'EAS', + title: ProtocolMap[Protocols.EAS], default: `[[attesters]][[attested]][[count]]with[[schemas]]by delegation via[[from]]`, }, }, @@ -301,6 +319,8 @@ export const generate = (transaction: Transaction): Transaction => { const attestationID = getAttestationID(transaction); transaction.context = { + actions: [`${Protocols.EAS}.${EASContextActionEnum.REVOKED}`], + variables: { from: { type: 'address', @@ -326,13 +346,15 @@ export const generate = (transaction: Transaction): Transaction => { }, revoked: { type: 'contextAction', + id: `${Protocols.EAS}.${EASContextActionEnum.REVOKED}`, value: EASContextActionEnum.REVOKED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'EAS', + title: ProtocolMap[Protocols.EAS], default: '[[from]][[revoked]]an attestation with schema[[schema]]🔗[[attestation]]', }, @@ -349,6 +371,8 @@ export const generate = (transaction: Transaction): Transaction => { const attestationID = getAttestationID(transaction); transaction.context = { + actions: [`${Protocols.EAS}.${EASContextActionEnum.REVOKED}`], + variables: { from: { type: 'address', @@ -378,13 +402,15 @@ export const generate = (transaction: Transaction): Transaction => { }, revoked: { type: 'contextAction', + id: `${Protocols.EAS}.${EASContextActionEnum.REVOKED}`, value: EASContextActionEnum.REVOKED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'EAS', + title: ProtocolMap[Protocols.EAS], default: '[[revoker]][[revoked]]an attestation with schema[[schema]]by delegation via[[from]]🔗[[attestation]]', }, @@ -399,6 +425,8 @@ export const generate = (transaction: Transaction): Transaction => { const count = arg.map((v) => v.data).flat().length; transaction.context = { + actions: [`${Protocols.EAS}.${EASContextActionEnum.REVOKED}`], + variables: { from: { type: 'address', @@ -418,13 +446,15 @@ export const generate = (transaction: Transaction): Transaction => { }, revoked: { type: 'contextAction', + id: `${Protocols.EAS}.${EASContextActionEnum.REVOKED}`, value: EASContextActionEnum.REVOKED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'EAS', + title: ProtocolMap[Protocols.EAS], default: `[[from]][[revoked]][[count]]with[[schemas]]`, }, }, @@ -439,6 +469,8 @@ export const generate = (transaction: Transaction): Transaction => { const count = arg.map((v) => v.data).flat().length; transaction.context = { + actions: [`${Protocols.EAS}.${EASContextActionEnum.REVOKED}`], + variables: { from: { type: 'address', @@ -462,13 +494,15 @@ export const generate = (transaction: Transaction): Transaction => { }, revoked: { type: 'contextAction', + id: `${Protocols.EAS}.${EASContextActionEnum.REVOKED}`, value: EASContextActionEnum.REVOKED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'EAS', + title: ProtocolMap[Protocols.EAS], default: `[[revokers]][[revoked]]${pluralize( 'account', revokers, @@ -481,6 +515,8 @@ export const generate = (transaction: Transaction): Transaction => { case 'timestamp': { transaction.context = { + actions: [`${Protocols.EAS}.${EASContextActionEnum.TIMESTAMPED}`], + variables: { from: { type: 'address', @@ -488,13 +524,15 @@ export const generate = (transaction: Transaction): Transaction => { }, timestamped: { type: 'contextAction', + id: `${Protocols.EAS}.${EASContextActionEnum.TIMESTAMPED}`, value: EASContextActionEnum.TIMESTAMPED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'EAS', + title: ProtocolMap[Protocols.EAS], default: '[[from]][[timestamped]]data', }, }, @@ -505,6 +543,8 @@ export const generate = (transaction: Transaction): Transaction => { case 'multiTimestamp': { const data = decoded.args[0]; transaction.context = { + actions: [`${Protocols.EAS}.${EASContextActionEnum.TIMESTAMPED}`], + variables: { from: { type: 'address', @@ -517,13 +557,15 @@ export const generate = (transaction: Transaction): Transaction => { }, timestamped: { type: 'contextAction', + id: `${Protocols.EAS}.${EASContextActionEnum.TIMESTAMPED}`, value: EASContextActionEnum.TIMESTAMPED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'EAS', + title: ProtocolMap[Protocols.EAS], default: '[[from]][[timestamped]][[count]]data', }, }, @@ -533,6 +575,8 @@ export const generate = (transaction: Transaction): Transaction => { case 'revokeOffchain': { transaction.context = { + actions: [`${Protocols.EAS}.${EASContextActionEnum.REVOKED}`], + variables: { from: { type: 'address', @@ -540,13 +584,15 @@ export const generate = (transaction: Transaction): Transaction => { }, revoked: { type: 'contextAction', + id: `${Protocols.EAS}.${EASContextActionEnum.REVOKED}`, value: EASContextActionEnum.REVOKED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'EAS', + title: ProtocolMap[Protocols.EAS], default: '[[from]][[revoked]]offchain data', }, }, @@ -557,6 +603,8 @@ export const generate = (transaction: Transaction): Transaction => { case 'multiRevokeOffchain': { const data = decoded.args[0]; transaction.context = { + actions: [`${Protocols.EAS}.${EASContextActionEnum.REVOKED}`], + variables: { from: { type: 'address', @@ -569,13 +617,15 @@ export const generate = (transaction: Transaction): Transaction => { }, revoked: { type: 'contextAction', + id: `${Protocols.EAS}.${EASContextActionEnum.REVOKED}`, value: EASContextActionEnum.REVOKED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'EAS', + title: ProtocolMap[Protocols.EAS], default: '[[from]][[revoked]][[count]]offchain data', }, }, diff --git a/src/contextualizers/protocol/eas/schemaRegistry.ts b/src/contextualizers/protocol/eas/schemaRegistry.ts index 0ff0224e..4959ad84 100644 --- a/src/contextualizers/protocol/eas/schemaRegistry.ts +++ b/src/contextualizers/protocol/eas/schemaRegistry.ts @@ -2,6 +2,8 @@ import { Hex } from 'viem'; import { EASContextActionEnum, EventLogTopics, + ProtocolMap, + Protocols, Transaction, } from '../../../types'; import { @@ -94,6 +96,8 @@ export const generate = (transaction: Transaction): Transaction => { const code = decoded.args[0]; transaction.context = { + actions: [`${Protocols.EAS}.${EASContextActionEnum.REGISTERED}`], + variables: { from: { type: 'address', @@ -113,13 +117,15 @@ export const generate = (transaction: Transaction): Transaction => { }, registered: { type: 'contextAction', + id: `${Protocols.EAS}.${EASContextActionEnum.REGISTERED}`, value: EASContextActionEnum.REGISTERED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'EAS', + title: ProtocolMap[Protocols.EAS], default: '[[from]][[registered]]new schema with id[[id]]', long: '[[from]][[registered]]new schema with id[[id]]and schema[[schema]]', }, diff --git a/src/contextualizers/protocol/ens/registrar.ts b/src/contextualizers/protocol/ens/registrar.ts index 74711866..2f7c7a71 100644 --- a/src/contextualizers/protocol/ens/registrar.ts +++ b/src/contextualizers/protocol/ens/registrar.ts @@ -2,6 +2,8 @@ import { Hex } from 'viem'; import { ENSContextActionEnum, EventLogTopics, + ProtocolMap, + Protocols, Transaction, } from '../../../types'; import { ENS_CONTRACTS, ENS_ADDRESSES } from './constants'; @@ -80,13 +82,16 @@ export const generate = (transaction: Transaction): Transaction => { const expireDate = convertDate(expires); transaction.context = { + actions: [`${Protocols.ENS}.${ENSContextActionEnum.REGISTERED}`], + summaries: { category: 'IDENTITY', en: { - title: 'ENS', + title: ProtocolMap[Protocols.ENS], default: `[[registerer]][[registered]][[name]]with an expiration of[[expireDate]]`, }, }, + variables: { registerer: { type: 'address', @@ -104,6 +109,7 @@ export const generate = (transaction: Transaction): Transaction => { }, registered: { type: 'contextAction', + id: `${Protocols.ENS}.${ENSContextActionEnum.REGISTERED}`, value: ENSContextActionEnum.REGISTERED, }, }, @@ -118,13 +124,16 @@ export const generate = (transaction: Transaction): Transaction => { const expireDate = convertDate(expires); transaction.context = { + actions: [`${Protocols.ENS}.${ENSContextActionEnum.RENEWED}`], + summaries: { category: 'IDENTITY', en: { - title: 'ENS', + title: ProtocolMap[Protocols.ENS], default: `[[renewer]][[renewed]][[name]]with an expiration of[[expireDate]]`, }, }, + variables: { renewer: { type: 'address', @@ -142,6 +151,7 @@ export const generate = (transaction: Transaction): Transaction => { }, renewed: { type: 'contextAction', + id: `${Protocols.ENS}.${ENSContextActionEnum.RENEWED}`, value: ENSContextActionEnum.RENEWED, }, }, diff --git a/src/contextualizers/protocol/ens/reverse.ts b/src/contextualizers/protocol/ens/reverse.ts index b8d19477..3938f044 100644 --- a/src/contextualizers/protocol/ens/reverse.ts +++ b/src/contextualizers/protocol/ens/reverse.ts @@ -1,5 +1,10 @@ import { Hex } from 'viem'; -import { ENSContextActionEnum, Transaction } from '../../../types'; +import { + ENSContextActionEnum, + ProtocolMap, + Protocols, + Transaction, +} from '../../../types'; import { ENS_CONTRACTS, ENS_ADDRESSES } from './constants'; import { decodeTransactionInput } from '../../../helpers/utils'; @@ -41,13 +46,18 @@ export const generate = (transaction: Transaction): Transaction => { case 'setName': { const name = decode.args[0]; transaction.context = { + actions: [ + `${Protocols.ENS}.${ENSContextActionEnum.SET_REVERSE_ENS_TO}`, + ], + summaries: { category: 'IDENTITY', en: { - title: 'ENS', + title: ProtocolMap[Protocols.ENS], default: `[[setter]][[reversed]][[name]]`, }, }, + variables: { setter: { type: 'address', @@ -60,6 +70,7 @@ export const generate = (transaction: Transaction): Transaction => { }, reversed: { type: 'contextAction', + id: `${Protocols.ENS}.${ENSContextActionEnum.SET_REVERSE_ENS_TO}`, value: ENSContextActionEnum.SET_REVERSE_ENS_TO, }, }, diff --git a/src/contextualizers/protocol/farcaster/bundler.ts b/src/contextualizers/protocol/farcaster/bundler.ts index 60fcda9a..3764ded9 100644 --- a/src/contextualizers/protocol/farcaster/bundler.ts +++ b/src/contextualizers/protocol/farcaster/bundler.ts @@ -4,6 +4,8 @@ import { ContextSummaryVariableType, EventLogTopics, FarcasterContextActionEnum, + ProtocolMap, + Protocols, Transaction, } from '../../../types'; import { FarcasterContracts } from './constants'; @@ -85,6 +87,10 @@ export const generate = (transaction: Transaction): Transaction => { } transaction.context = { + actions: [ + `${Protocols.FARCASTER}.${FarcasterContextActionEnum.REGISTERED_FARCASTER_ID}`, + ], + variables: { caller: { type: 'address', @@ -101,13 +107,15 @@ export const generate = (transaction: Transaction): Transaction => { cost, registered: { type: 'contextAction', + id: `${Protocols.FARCASTER}.${FarcasterContextActionEnum.REGISTERED_FARCASTER_ID}`, value: FarcasterContextActionEnum.REGISTERED_FARCASTER_ID, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Farcaster', + title: ProtocolMap[Protocols.FARCASTER], default: callerIsOwner ? '[[caller]][[registered]][[fid]]for[[cost]]' : '[[caller]][[registered]][[fid]]for[[owner]]for[[cost]]', diff --git a/src/contextualizers/protocol/farcaster/idGateway.ts b/src/contextualizers/protocol/farcaster/idGateway.ts index a859aea2..f8f2753f 100644 --- a/src/contextualizers/protocol/farcaster/idGateway.ts +++ b/src/contextualizers/protocol/farcaster/idGateway.ts @@ -2,6 +2,8 @@ import { Hex } from 'viem'; import { EventLogTopics, FarcasterContextActionEnum, + ProtocolMap, + Protocols, Transaction, } from '../../../types'; import { FarcasterContracts } from './constants'; @@ -71,6 +73,10 @@ export const generate = (transaction: Transaction): Transaction => { switch (decoded.functionName) { case 'register': { transaction.context = { + actions: [ + `${Protocols.FARCASTER}.${FarcasterContextActionEnum.REGISTERED_FARCASTER_ID}`, + ], + variables: { owner: { type: 'address', @@ -82,13 +88,15 @@ export const generate = (transaction: Transaction): Transaction => { }, registered: { type: 'contextAction', + id: `${Protocols.FARCASTER}.${FarcasterContextActionEnum.REGISTERED_FARCASTER_ID}`, value: FarcasterContextActionEnum.REGISTERED_FARCASTER_ID, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Farcaster', + title: ProtocolMap[Protocols.FARCASTER], default: `[[owner]][[registered]][[fid]]`, }, }, @@ -98,6 +106,10 @@ export const generate = (transaction: Transaction): Transaction => { case 'registerFor': { transaction.context = { + actions: [ + `${Protocols.FARCASTER}.${FarcasterContextActionEnum.REGISTERED_FARCASTER_ID}`, + ], + variables: { caller: { type: 'address', @@ -113,13 +125,15 @@ export const generate = (transaction: Transaction): Transaction => { }, registered: { type: 'contextAction', + id: `${Protocols.FARCASTER}.${FarcasterContextActionEnum.REGISTERED_FARCASTER_ID}`, value: FarcasterContextActionEnum.REGISTERED_FARCASTER_ID, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Farcaster', + title: ProtocolMap[Protocols.FARCASTER], default: '[[caller]][[registered]][[fid]]for[[owner]]', }, }, diff --git a/src/contextualizers/protocol/farcaster/idRegistry.ts b/src/contextualizers/protocol/farcaster/idRegistry.ts index bdef6557..eda71b27 100644 --- a/src/contextualizers/protocol/farcaster/idRegistry.ts +++ b/src/contextualizers/protocol/farcaster/idRegistry.ts @@ -1,5 +1,10 @@ import { Hex } from 'viem'; -import { FarcasterContextActionEnum, Transaction } from '../../../types'; +import { + FarcasterContextActionEnum, + ProtocolMap, + Protocols, + Transaction, +} from '../../../types'; import { FarcasterContracts } from './constants'; import { decodeTransactionInput } from '../../../helpers/utils'; @@ -47,6 +52,10 @@ export const generate = (transaction: Transaction): Transaction => { switch (decoded.functionName) { case 'changeRecoveryAddressFor': { transaction.context = { + actions: [ + `${Protocols.FARCASTER}.${FarcasterContextActionEnum.CHANGED_RECOVERY_ADDRESS}`, + ], + variables: { owner: { type: 'address', @@ -58,13 +67,15 @@ export const generate = (transaction: Transaction): Transaction => { }, changedRecoveryAddress: { type: 'contextAction', + id: `${Protocols.FARCASTER}.${FarcasterContextActionEnum.CHANGED_RECOVERY_ADDRESS}`, value: FarcasterContextActionEnum.CHANGED_RECOVERY_ADDRESS, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Farcaster', + title: ProtocolMap[Protocols.FARCASTER], default: '[[owner]][[changedRecoveryAddress]]to[[recoveryAddress]]', }, }, @@ -74,6 +85,10 @@ export const generate = (transaction: Transaction): Transaction => { case 'transfer': { transaction.context = { + actions: [ + `${Protocols.FARCASTER}.${FarcasterContextActionEnum.TRANSFERRED_FARCASTER_ID}`, + ], + variables: { owner: { type: 'address', @@ -85,13 +100,15 @@ export const generate = (transaction: Transaction): Transaction => { }, transferredId: { type: 'contextAction', + id: `${Protocols.FARCASTER}.${FarcasterContextActionEnum.TRANSFERRED_FARCASTER_ID}`, value: FarcasterContextActionEnum.TRANSFERRED_FARCASTER_ID, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Farcaster', + title: ProtocolMap[Protocols.FARCASTER], default: '[[owner]][[transferredId]]to[[to]]', }, }, diff --git a/src/contextualizers/protocol/farcaster/keyGateway.ts b/src/contextualizers/protocol/farcaster/keyGateway.ts index 6d58064a..d8c300bb 100644 --- a/src/contextualizers/protocol/farcaster/keyGateway.ts +++ b/src/contextualizers/protocol/farcaster/keyGateway.ts @@ -1,5 +1,10 @@ import { Hex } from 'viem'; -import { FarcasterContextActionEnum, Transaction } from '../../../types'; +import { + FarcasterContextActionEnum, + ProtocolMap, + Protocols, + Transaction, +} from '../../../types'; import { FarcasterContracts } from './constants'; import { decodeTransactionInput } from '../../../helpers/utils'; @@ -37,6 +42,10 @@ export const generate = (transaction: Transaction): Transaction => { switch (decoded.functionName) { case 'add': { transaction.context = { + actions: [ + `${Protocols.FARCASTER}.${FarcasterContextActionEnum.ADDED_A_KEY}`, + ], + variables: { owner: { type: 'address', @@ -44,13 +53,15 @@ export const generate = (transaction: Transaction): Transaction => { }, addedKey: { type: 'contextAction', + id: `${Protocols.FARCASTER}.${FarcasterContextActionEnum.ADDED_A_KEY}`, value: FarcasterContextActionEnum.ADDED_A_KEY, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Farcaster', + title: ProtocolMap[Protocols.FARCASTER], default: '[[owner]][[addedKey]]', }, }, @@ -60,6 +71,10 @@ export const generate = (transaction: Transaction): Transaction => { case 'addFor': { transaction.context = { + actions: [ + `${Protocols.FARCASTER}.${FarcasterContextActionEnum.ADDED_A_KEY}`, + ], + variables: { caller: { type: 'address', @@ -71,13 +86,15 @@ export const generate = (transaction: Transaction): Transaction => { }, addedKey: { type: 'contextAction', + id: `${Protocols.FARCASTER}.${FarcasterContextActionEnum.ADDED_A_KEY}`, value: FarcasterContextActionEnum.ADDED_A_KEY, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Farcaster', + title: ProtocolMap[Protocols.FARCASTER], default: '[[caller]][[addedKey]]for[[owner]]', }, }, diff --git a/src/contextualizers/protocol/farcaster/keyRegistry.ts b/src/contextualizers/protocol/farcaster/keyRegistry.ts index 26a6441b..5b90d647 100644 --- a/src/contextualizers/protocol/farcaster/keyRegistry.ts +++ b/src/contextualizers/protocol/farcaster/keyRegistry.ts @@ -1,5 +1,10 @@ import { Hex } from 'viem'; -import { FarcasterContextActionEnum, Transaction } from '../../../types'; +import { + FarcasterContextActionEnum, + ProtocolMap, + Protocols, + Transaction, +} from '../../../types'; import { FarcasterContracts } from './constants'; import { decodeTransactionInput } from '../../../helpers/utils'; @@ -39,6 +44,10 @@ export const generate = (transaction: Transaction): Transaction => { switch (decoded.functionName) { case 'remove': { transaction.context = { + actions: [ + `${Protocols.FARCASTER}.${FarcasterContextActionEnum.REMOVED_A_KEY}`, + ], + variables: { owner: { type: 'address', @@ -46,13 +55,15 @@ export const generate = (transaction: Transaction): Transaction => { }, removedKey: { type: 'contextAction', + id: `${Protocols.FARCASTER}.${FarcasterContextActionEnum.REMOVED_A_KEY}`, value: FarcasterContextActionEnum.REMOVED_A_KEY, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Farcaster', + title: ProtocolMap[Protocols.FARCASTER], default: '[[owner]][[removedKey]]', }, }, @@ -62,6 +73,10 @@ export const generate = (transaction: Transaction): Transaction => { case 'removeFor': { transaction.context = { + actions: [ + `${Protocols.FARCASTER}.${FarcasterContextActionEnum.REMOVED_A_KEY}`, + ], + variables: { caller: { type: 'address', @@ -73,13 +88,15 @@ export const generate = (transaction: Transaction): Transaction => { }, removedKey: { type: 'contextAction', + id: `${Protocols.FARCASTER}.${FarcasterContextActionEnum.REMOVED_A_KEY}`, value: FarcasterContextActionEnum.REMOVED_A_KEY, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Farcaster', + title: ProtocolMap[Protocols.FARCASTER], default: '[[caller]][[removedKey]]for[[owner]]', }, }, diff --git a/src/contextualizers/protocol/farcaster/storageRegistry.ts b/src/contextualizers/protocol/farcaster/storageRegistry.ts index 639078a1..efc63176 100644 --- a/src/contextualizers/protocol/farcaster/storageRegistry.ts +++ b/src/contextualizers/protocol/farcaster/storageRegistry.ts @@ -1,5 +1,10 @@ import { Hex } from 'viem'; -import { FarcasterContextActionEnum, Transaction } from '../../../types'; +import { + FarcasterContextActionEnum, + ProtocolMap, + Protocols, + Transaction, +} from '../../../types'; import { FarcasterContracts } from './constants'; import { decodeTransactionInput } from '../../../helpers/utils'; @@ -40,9 +45,14 @@ export const generate = (transaction: Transaction): Transaction => { case 'rent': { const units = Number(decoded.args[1]); transaction.context = { + actions: [ + `${Protocols.FARCASTER}.${FarcasterContextActionEnum.RENTED}`, + ], + variables: { rented: { type: 'contextAction', + id: `${Protocols.FARCASTER}.${FarcasterContextActionEnum.RENTED}`, value: FarcasterContextActionEnum.RENTED, }, caller: { @@ -60,10 +70,11 @@ export const generate = (transaction: Transaction): Transaction => { unit: `storage unit${units > 1 ? 's' : ''}`, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Farcaster', + title: ProtocolMap[Protocols.FARCASTER], default: `[[caller]][[rented]][[units]]for Farcaster ID[[fid]]`, }, }, @@ -77,9 +88,14 @@ export const generate = (transaction: Transaction): Transaction => { const unitsArg = decoded.args[1]; const units = unitsArg.reduce((acc, curr) => acc + curr); transaction.context = { + actions: [ + `${Protocols.FARCASTER}.${FarcasterContextActionEnum.RENTED}`, + ], + variables: { rented: { type: 'contextAction', + id: `${Protocols.FARCASTER}.${FarcasterContextActionEnum.RENTED}`, value: FarcasterContextActionEnum.RENTED, }, caller: { @@ -99,10 +115,11 @@ export const generate = (transaction: Transaction): Transaction => { unit: `storage unit${units > 1 ? 's' : ''}`, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Farcaster', + title: ProtocolMap[Protocols.FARCASTER], default: `[[caller]][[rented]][[units]]for[[fids]]`, }, }, diff --git a/src/contextualizers/protocol/frenpet/gameplay.ts b/src/contextualizers/protocol/frenpet/gameplay.ts index 9950da42..ffead1ff 100644 --- a/src/contextualizers/protocol/frenpet/gameplay.ts +++ b/src/contextualizers/protocol/frenpet/gameplay.ts @@ -10,6 +10,9 @@ import { ContextERC721Type, ERC721Asset, FrenpetContextActionEnum, + ProtocolMap, + Protocols, + HeuristicContextActionEnum, } from '../../../types'; import { decodeFunction, @@ -68,37 +71,49 @@ export const generate = (transaction: Transaction): Transaction => { value: asset.value, }; transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.BOUGHT_ACCESSORY}`, + ], + variables: { buyer, pet, purchasePrice, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.BOUGHT_ACCESSORY}`, value: FrenpetContextActionEnum.BOUGHT_ACCESSORY, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `[[buyer]][[contextAction]]${accessory} for[[pet]]for[[purchasePrice]]`, }, }, }; } else { transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.BOUGHT_ACCESSORY}`, + ], + variables: { buyer, pet, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.BOUGHT_ACCESSORY}`, value: FrenpetContextActionEnum.BOUGHT_ACCESSORY, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `Failed:[[buyer]][[contextAction]]${accessory} for[[pet]]`, }, }, @@ -150,36 +165,48 @@ export const generate = (transaction: Transaction): Transaction => { const scoresWon = (scoresWonArg / BigInt(100000000000)).toString(); const winOrLose = attackerArg === winnerArg ? 'won' : 'lost'; transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.ATTACKED}`, + ], + variables: { attacker, attacked, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.ATTACKED}`, value: FrenpetContextActionEnum.ATTACKED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `[[attacker]][[contextAction]][[attacked]]and ${winOrLose} ${scoresWon} points`, }, }, }; } else { transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.ATTACKED}`, + ], + variables: { attacker, attacked, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.ATTACKED}`, value: FrenpetContextActionEnum.ATTACKED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `Failed:[[attacker]][[contextAction]][[attacked]]`, }, }, @@ -213,36 +240,50 @@ export const generate = (transaction: Transaction): Transaction => { value: assetSent.value, }; transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.MINTED}`, + HeuristicContextActionEnum.MINTED, + ], + variables: { minter, pet, cost, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.MINTED}`, value: FrenpetContextActionEnum.MINTED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `[[minter]][[contextAction]][[pet]]for[[cost]]`, }, }, }; } else { transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.MINTED}`, + HeuristicContextActionEnum.MINTED, + ], + variables: { minter, contextAction: { type: 'contextAction', - value: FrenpetContextActionEnum.MINTED, // TODO: Make a Frenpet version of this + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.MINTED}`, + value: FrenpetContextActionEnum.MINTED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `Failed:[[minter]][[contextAction]]a Fren Pet`, }, }, @@ -267,18 +308,24 @@ export const generate = (transaction: Transaction): Transaction => { }; const name = parsed.args[1]; transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.SET_PET_NAME}`, + ], + variables: { user, pet, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.SET_PET_NAME}`, value: FrenpetContextActionEnum.SET_PET_NAME, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `[[user]][[contextAction]]for[[pet]]to ${name}`, }, }, @@ -293,34 +340,46 @@ export const generate = (transaction: Transaction): Transaction => { }; if (transaction.receipt?.status) { transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.WHEEL_COMMITTED}`, + ], + variables: { user, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.WHEEL_COMMITTED}`, value: FrenpetContextActionEnum.WHEEL_COMMITTED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `[[user]][[contextAction]]`, }, }, }; } else { transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.WHEEL_COMMITTED}`, + ], + variables: { user, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.WHEEL_COMMITTED}`, value: FrenpetContextActionEnum.WHEEL_COMMITTED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `[[user]][[contextAction]]`, }, }, @@ -348,18 +407,24 @@ export const generate = (transaction: Transaction): Transaction => { }; if (!transaction.receipt?.status) { transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.REDEEMED}`, + ], + variables: { user, pet, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.REDEEMED}`, value: FrenpetContextActionEnum.REDEEMED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `[[user]][[contextAction]]for[[pet]]`, }, }, @@ -387,19 +452,25 @@ export const generate = (transaction: Transaction): Transaction => { value: redeemedAmountString, }; transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.REDEEMED}`, + ], + variables: { user, pet, redeemedAmount, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.REDEEMED}`, value: FrenpetContextActionEnum.REDEEMED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `[[user]][[contextAction]][[redeemedAmount]]for[[pet]]`, }, }, @@ -432,19 +503,25 @@ export const generate = (transaction: Transaction): Transaction => { }; transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.COMMITTED_TO_ATTACKING}`, + ], + variables: { user, attacker, target, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.COMMITTED_TO_ATTACKING}`, value: FrenpetContextActionEnum.COMMITTED_TO_ATTACKING, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `[[user]][[contextAction]]with[[attacker]]attacking[[target]]`, }, }, @@ -483,18 +560,24 @@ export const generate = (transaction: Transaction): Transaction => { ) { // bonkTooSlowEvent transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.TOO_SLOW_TO_ATTACK}`, + ], + variables: { user, attacker, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.TOO_SLOW_TO_ATTACK}`, value: FrenpetContextActionEnum.TOO_SLOW_TO_ATTACK, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `[[user]][[contextAction]]with[[attacker]]`, }, }, @@ -531,6 +614,10 @@ export const generate = (transaction: Transaction): Transaction => { scoresWon / BigInt(100000000000) ).toString(); transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.ATTACKED}`, + ], + variables: { user, attacker, @@ -548,13 +635,15 @@ export const generate = (transaction: Transaction): Transaction => { }, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.ATTACKED}`, value: FrenpetContextActionEnum.ATTACKED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `[[user]][[contextAction]]with[[attacker]]attacking[[loser]]and ${winOrLose} ${scoresWonFormatted} points`, }, }, @@ -562,18 +651,24 @@ export const generate = (transaction: Transaction): Transaction => { } } else { transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.ATTACKED}`, + ], + variables: { user, attacker, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.ATTACKED}`, value: FrenpetContextActionEnum.ATTACKED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `[[user]][[contextAction]]with[[attacker]]`, }, }, @@ -604,19 +699,23 @@ export const generate = (transaction: Transaction): Transaction => { tokenId: (parsed.args[1] as bigint).toString(), }; transaction.context = { + actions: [`${Protocols.FRENPET}.${FrenpetContextActionEnum.KILLED}`], + variables: { user, dead, killer, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.KILLED}`, value: FrenpetContextActionEnum.KILLED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `[[user]][[contextAction]][[dead]]with[[killer]]`, }, }, @@ -641,18 +740,24 @@ export const generate = (transaction: Transaction): Transaction => { tokenId: (parsed.args[0] as bigint).toString(), }; transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.WHEEL_COMMITTED}`, + ], + variables: { user, pet, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.WHEEL_COMMITTED}`, value: FrenpetContextActionEnum.WHEEL_COMMITTED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `[[user]][[contextAction]]with[[pet]]`, }, }, @@ -677,18 +782,24 @@ export const generate = (transaction: Transaction): Transaction => { tokenId: (parsed.args[0] as bigint).toString(), }; transaction.context = { + actions: [ + `${Protocols.FRENPET}.${FrenpetContextActionEnum.WHEEL_REVEALED}`, + ], + variables: { user, pet, contextAction: { type: 'contextAction', + id: `${Protocols.FRENPET}.${FrenpetContextActionEnum.WHEEL_REVEALED}`, value: FrenpetContextActionEnum.WHEEL_REVEALED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Fren Pet', + title: ProtocolMap[Protocols.FRENPET], default: `[[user]][[contextAction]]with[[pet]]`, }, }, diff --git a/src/contextualizers/protocol/friendTech/friendTech.ts b/src/contextualizers/protocol/friendTech/friendTech.ts index cd9ef576..f2f41305 100644 --- a/src/contextualizers/protocol/friendTech/friendTech.ts +++ b/src/contextualizers/protocol/friendTech/friendTech.ts @@ -3,6 +3,8 @@ import { AssetType, EventLogTopics, FriendTechContextActionEnum, + ProtocolMap, + Protocols, Transaction, } from '../../../types'; import { ABIs } from './constants'; @@ -36,6 +38,10 @@ export const generate = (transaction: Transaction): Transaction => { const subject = parsedTx.args[0].toString(); const shareAmount = Number(parsedTx.args[1]); transaction.context = { + actions: [ + `${Protocols.FRIENDTECH}.${FriendTechContextActionEnum.FAILED_TO_BUY_KEYS}`, + ], + variables: { price: { type: AssetType.ETH, @@ -57,13 +63,15 @@ export const generate = (transaction: Transaction): Transaction => { }, failedToBuyKeys: { type: 'contextAction', + id: `${Protocols.FRIENDTECH}.${FriendTechContextActionEnum.FAILED_TO_BUY_KEYS}`, value: FriendTechContextActionEnum.FAILED_TO_BUY_KEYS, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'friend.tech', + title: ProtocolMap[Protocols.FRIENDTECH], default: '[[buyer]][[failedToBuyKeys]][[numOfKeys]]of[[subject]]for[[price]]', }, @@ -95,13 +103,18 @@ export const generate = (transaction: Transaction): Transaction => { // Check if this is a user signing up if (trader === subject && ethAmount === '0' && supply === 1) { transaction.context = { + actions: [ + `${Protocols.FRIENDTECH}.${FriendTechContextActionEnum.SIGNED_UP}`, + ], + summaries: { category: 'PROTOCOL_1', en: { - title: 'friend.tech', + title: ProtocolMap[Protocols.FRIENDTECH], default: '[[subject]][[signedUp]]', }, }, + variables: { subject: { type: 'address', @@ -109,6 +122,7 @@ export const generate = (transaction: Transaction): Transaction => { }, signedUp: { type: 'contextAction', + id: `${Protocols.FRIENDTECH}.${FriendTechContextActionEnum.SIGNED_UP}`, value: FriendTechContextActionEnum.SIGNED_UP, }, }, @@ -117,6 +131,10 @@ export const generate = (transaction: Transaction): Transaction => { } transaction.context = { + actions: [ + `${Protocols.FRIENDTECH}.${FriendTechContextActionEnum.BOUGHT_KEYS}`, + ], + variables: { price: { type: AssetType.ETH, @@ -138,13 +156,15 @@ export const generate = (transaction: Transaction): Transaction => { }, boughtKeys: { type: 'contextAction', + id: `${Protocols.FRIENDTECH}.${FriendTechContextActionEnum.BOUGHT_KEYS}`, value: FriendTechContextActionEnum.BOUGHT_KEYS, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'friend.tech', + title: ProtocolMap[Protocols.FRIENDTECH], default: '[[buyer]][[boughtKeys]][[numOfKeys]]of[[subject]]for[[price]]', }, @@ -177,6 +197,10 @@ export const generate = (transaction: Transaction): Transaction => { const shareAmount = Number(parsedLog.args['shareAmount']); transaction.context = { + actions: [ + `${Protocols.FRIENDTECH}.${FriendTechContextActionEnum.SOLD_KEYS}`, + ], + variables: { price: { type: AssetType.ETH, @@ -198,13 +222,15 @@ export const generate = (transaction: Transaction): Transaction => { }, soldKeys: { type: 'contextAction', + id: `${Protocols.FRIENDTECH}.${FriendTechContextActionEnum.SOLD_KEYS}`, value: FriendTechContextActionEnum.SOLD_KEYS, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'friend.tech', + title: ProtocolMap[Protocols.FRIENDTECH], default: '[[trader]][[soldKeys]][[numOfKeys]]of[[subject]]for[[price]]', }, diff --git a/src/contextualizers/protocol/highlight/highlight.ts b/src/contextualizers/protocol/highlight/highlight.ts index 34731b95..c7bdbe33 100644 --- a/src/contextualizers/protocol/highlight/highlight.ts +++ b/src/contextualizers/protocol/highlight/highlight.ts @@ -1,5 +1,11 @@ import { Abi, Hex } from 'viem'; -import { AssetType, EventLogTopics, Transaction } from '../../../types'; +import { + AssetType, + EventLogTopics, + HighlightContextActionEnum, + Protocols, + Transaction, +} from '../../../types'; import { MINT_MANAGER_ABI, MINT_MANAGER_CONTRACT } from './constants'; import { decodeLog, grabLogsFromTransaction } from '../../../helpers/utils'; import { generate as erc721Generate } from '../../heuristics/erc721Mint/erc721Mint'; @@ -56,6 +62,11 @@ export const generate = (transaction: Transaction): Transaction => { const mintReferralAmount = decodedLog.args['amount'].toString(); const mintReferralCurrency = decodedLog.args['currency'].toLowerCase(); + transaction.context.actions = [ + `${Protocols.HIGHLIGHT}.${HighlightContextActionEnum.MINTED}`, + ...(transaction.context.actions || []), + ]; + transaction.context.variables = { ...transaction.context.variables, vectorId: { diff --git a/src/contextualizers/protocol/leeroy/leeroy.ts b/src/contextualizers/protocol/leeroy/leeroy.ts index 9f638242..e4b792d5 100644 --- a/src/contextualizers/protocol/leeroy/leeroy.ts +++ b/src/contextualizers/protocol/leeroy/leeroy.ts @@ -4,6 +4,8 @@ import { ContextSummaryVariableType, ETHAsset, LeeroyContextActionEnum, + ProtocolMap, + Protocols, Transaction, } from '../../../types'; import { LeeroyContracts } from './constants'; @@ -59,34 +61,42 @@ export const generate = (transaction: Transaction): Transaction => { }; if (transaction.receipt?.status) { transaction.context = { + actions: [`${Protocols.LEEROY}.${LeeroyContextActionEnum.POSTED}`], + variables: { poster, contextAction: { type: 'contextAction', + id: `${Protocols.LEEROY}.${LeeroyContextActionEnum.POSTED}`, value: LeeroyContextActionEnum.POSTED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Leeroy', + title: ProtocolMap[Protocols.LEEROY], default: `[[poster]][[contextAction]]${post.text}`, }, }, }; } else { transaction.context = { + actions: [`${Protocols.LEEROY}.${LeeroyContextActionEnum.POSTED}`], + variables: { poster, contextAction: { type: 'contextAction', + id: `${Protocols.LEEROY}.${LeeroyContextActionEnum.POSTED}`, value: LeeroyContextActionEnum.POSTED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Leeroy', + title: ProtocolMap[Protocols.LEEROY], default: `Failed:[[poster]][[contextAction]]${post.text}`, }, }, @@ -112,34 +122,42 @@ export const generate = (transaction: Transaction): Transaction => { }); if (transaction.receipt?.status) { transaction.context = { + actions: [`${Protocols.LEEROY}.${LeeroyContextActionEnum.FOLLOWED}`], + variables: { user, contextAction: { type: 'contextAction', + id: `${Protocols.LEEROY}.${LeeroyContextActionEnum.FOLLOWED}`, value: LeeroyContextActionEnum.FOLLOWED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Leeroy', + title: ProtocolMap[Protocols.LEEROY], default: `[[user]][[contextAction]]${username}`, }, }, }; } else { transaction.context = { + actions: [`${Protocols.LEEROY}.${LeeroyContextActionEnum.FOLLOWED}`], + variables: { user, contextAction: { type: 'contextAction', + id: `${Protocols.LEEROY}.${LeeroyContextActionEnum.FOLLOWED}`, value: LeeroyContextActionEnum.FOLLOWED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Leeroy', + title: ProtocolMap[Protocols.LEEROY], default: `Failed:[[user]][[contextAction]]${username}`, }, }, @@ -165,34 +183,46 @@ export const generate = (transaction: Transaction): Transaction => { }); if (transaction.receipt?.status) { transaction.context = { + actions: [ + `${Protocols.LEEROY}.${LeeroyContextActionEnum.UNFOLLOWED}`, + ], + variables: { user, contextAction: { type: 'contextAction', + id: `${Protocols.LEEROY}.${LeeroyContextActionEnum.UNFOLLOWED}`, value: LeeroyContextActionEnum.UNFOLLOWED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Leeroy', + title: ProtocolMap[Protocols.LEEROY], default: `[[user]][[contextAction]]${username}`, }, }, }; } else { transaction.context = { + actions: [ + `${Protocols.LEEROY}.${LeeroyContextActionEnum.UNFOLLOWED}`, + ], + variables: { user, contextAction: { type: 'contextAction', + id: `${Protocols.LEEROY}.${LeeroyContextActionEnum.UNFOLLOWED}`, value: LeeroyContextActionEnum.UNFOLLOWED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Leeroy', + title: ProtocolMap[Protocols.LEEROY], default: `Failed:[[user]][[contextAction]]${username}`, }, }, @@ -234,37 +264,45 @@ export const generate = (transaction: Transaction): Transaction => { unit: 'wei', }; transaction.context = { + actions: [`${Protocols.LEEROY}.${LeeroyContextActionEnum.TIPPED}`], + variables: { tipper, tipAmount, leeroyTake, contextAction: { type: 'contextAction', + id: `${Protocols.LEEROY}.${LeeroyContextActionEnum.TIPPED}`, value: LeeroyContextActionEnum.TIPPED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Leeroy', + title: ProtocolMap[Protocols.LEEROY], default: `[[tipper]][[contextAction]]${username}[[tipAmount]](Leeroy fee:[[leeroyTake]])`, }, }, }; } else { transaction.context = { + actions: [`${Protocols.LEEROY}.${LeeroyContextActionEnum.TIPPED}`], + variables: { tipper, tipAmount, contextAction: { type: 'contextAction', + id: `${Protocols.LEEROY}.${LeeroyContextActionEnum.TIPPED}`, value: LeeroyContextActionEnum.TIPPED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Leeroy', + title: ProtocolMap[Protocols.LEEROY], default: `Failed:[[tipper]][[contextAction]]${username}[[tipAmount]]`, }, }, @@ -288,17 +326,23 @@ export const generate = (transaction: Transaction): Transaction => { } catch (e) {} if (transaction.receipt?.status) { transaction.context = { + actions: [ + `${Protocols.LEEROY}.${LeeroyContextActionEnum.UPDATED_USER_DETAILS}`, + ], + variables: { user, contextAction: { type: 'contextAction', + id: `${Protocols.LEEROY}.${LeeroyContextActionEnum.UPDATED_USER_DETAILS}`, value: LeeroyContextActionEnum.UPDATED_USER_DETAILS, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Leeroy', + title: ProtocolMap[Protocols.LEEROY], default: `[[user]][[contextAction]]${JSON.stringify( userDetails, )}`, @@ -307,17 +351,23 @@ export const generate = (transaction: Transaction): Transaction => { }; } else { transaction.context = { + actions: [ + `${Protocols.LEEROY}.${LeeroyContextActionEnum.UPDATED_USER_DETAILS}`, + ], + variables: { user, contextAction: { type: 'contextAction', + id: `${Protocols.LEEROY}.${LeeroyContextActionEnum.UPDATED_USER_DETAILS}`, value: LeeroyContextActionEnum.UPDATED_USER_DETAILS, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Leeroy', + title: ProtocolMap[Protocols.LEEROY], default: `Failed:[[user]][[contextAction]]${JSON.stringify( userDetails, )}`, @@ -347,36 +397,48 @@ export const generate = (transaction: Transaction): Transaction => { } catch (e) {} if (transaction.receipt?.status) { transaction.context = { + actions: [ + `${Protocols.LEEROY}.${LeeroyContextActionEnum.REPLIED_TO}`, + ], + variables: { user, transactionHash, contextAction: { type: 'contextAction', + id: `${Protocols.LEEROY}.${LeeroyContextActionEnum.REPLIED_TO}`, value: LeeroyContextActionEnum.REPLIED_TO, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Leeroy', + title: ProtocolMap[Protocols.LEEROY], default: `[[user]][[contextAction]][[transactionHash]]${post.text}`, }, }, }; } else { transaction.context = { + actions: [ + `${Protocols.LEEROY}.${LeeroyContextActionEnum.REPLIED_TO}`, + ], + variables: { user, transactionHash, contextAction: { type: 'contextAction', + id: `${Protocols.LEEROY}.${LeeroyContextActionEnum.REPLIED_TO}`, value: LeeroyContextActionEnum.REPLIED_TO, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Leeroy', + title: ProtocolMap[Protocols.LEEROY], default: `Failed:[[user]][[contextAction]][[transactionHash]]${post.text}`, }, }, @@ -400,36 +462,44 @@ export const generate = (transaction: Transaction): Transaction => { }; if (transaction.receipt?.status) { transaction.context = { + actions: [`${Protocols.LEEROY}.${LeeroyContextActionEnum.REPOSTED}`], + variables: { user, transactionHash, contextAction: { type: 'contextAction', + id: `${Protocols.LEEROY}.${LeeroyContextActionEnum.REPOSTED}`, value: LeeroyContextActionEnum.REPOSTED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Leeroy', + title: ProtocolMap[Protocols.LEEROY], default: `[[user]][[contextAction]][[transactionHash]]`, }, }, }; } else { transaction.context = { + actions: [`${Protocols.LEEROY}.${LeeroyContextActionEnum.REPOSTED}`], + variables: { user, transactionHash, contextAction: { type: 'contextAction', + id: `${Protocols.LEEROY}.${LeeroyContextActionEnum.REPOSTED}`, value: LeeroyContextActionEnum.REPOSTED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Leeroy', + title: ProtocolMap[Protocols.LEEROY], default: `Failed:[[user]][[contextAction]][[transactionHash]]`, }, }, @@ -455,34 +525,46 @@ export const generate = (transaction: Transaction): Transaction => { }); if (transaction.receipt?.status) { transaction.context = { + actions: [ + `${Protocols.LEEROY}.${LeeroyContextActionEnum.REGISTERED_USERNAME}`, + ], + variables: { user, contextAction: { type: 'contextAction', + id: `${Protocols.LEEROY}.${LeeroyContextActionEnum.REGISTERED_USERNAME}`, value: LeeroyContextActionEnum.REGISTERED_USERNAME, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Leeroy', + title: ProtocolMap[Protocols.LEEROY], default: `[[user]][[contextAction]]${username}`, }, }, }; } else { transaction.context = { + actions: [ + `${Protocols.LEEROY}.${LeeroyContextActionEnum.REGISTERED_USERNAME}`, + ], + variables: { user, contextAction: { type: 'contextAction', + id: `${Protocols.LEEROY}.${LeeroyContextActionEnum.REGISTERED_USERNAME}`, value: LeeroyContextActionEnum.REGISTERED_USERNAME, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Leeroy', + title: ProtocolMap[Protocols.LEEROY], default: `Failed:[[user]][[contextAction]]${username}`, }, }, diff --git a/src/contextualizers/protocol/nouns/auctionHouse.ts b/src/contextualizers/protocol/nouns/auctionHouse.ts index 93f58f0a..1dbcff75 100644 --- a/src/contextualizers/protocol/nouns/auctionHouse.ts +++ b/src/contextualizers/protocol/nouns/auctionHouse.ts @@ -3,6 +3,8 @@ import { AssetType, EventLogTopics, NounsAuctionHouseActionEnum, + ProtocolMap, + Protocols, Transaction, } from '../../../types'; import { NounsContracts, ABIs } from './constants'; @@ -67,9 +69,14 @@ export const generate = (transaction: Transaction): Transaction => { switch (decoded.functionName) { case 'createBid': { transaction.context = { + actions: [ + `${Protocols.NOUNS_AUCTION_HOUSE}.${NounsAuctionHouseActionEnum.BID}`, + ], + variables: { contextAction: { type: 'contextAction', + id: `${Protocols.NOUNS_AUCTION_HOUSE}.${NounsAuctionHouseActionEnum.BID}`, value: NounsAuctionHouseActionEnum.BID, }, subject: { @@ -87,10 +94,11 @@ export const generate = (transaction: Transaction): Transaction => { unit: 'wei', }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Nouns', + title: ProtocolMap[Protocols.NOUNS_AUCTION_HOUSE], default: '[[subject]][[contextAction]][[amount]]on[[noun]]', }, }, @@ -139,9 +147,14 @@ export const generate = (transaction: Transaction): Transaction => { } transaction.context = { + actions: [ + `${Protocols.NOUNS_AUCTION_HOUSE}.${NounsAuctionHouseActionEnum.SETTLED}`, + ], + variables: { contextAction: { type: 'contextAction', + id: `${Protocols.NOUNS_AUCTION_HOUSE}.${NounsAuctionHouseActionEnum.SETTLED}`, value: NounsAuctionHouseActionEnum.SETTLED, }, subject: { @@ -158,10 +171,11 @@ export const generate = (transaction: Transaction): Transaction => { value: winner, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Nouns', + title: ProtocolMap[Protocols.NOUNS_AUCTION_HOUSE], default: '[[subject]][[contextAction]]auction for[[noun]]won by[[winner]]', }, diff --git a/src/contextualizers/protocol/nouns/daoLogic.ts b/src/contextualizers/protocol/nouns/daoLogic.ts index a0445d50..ac60644c 100644 --- a/src/contextualizers/protocol/nouns/daoLogic.ts +++ b/src/contextualizers/protocol/nouns/daoLogic.ts @@ -2,6 +2,8 @@ import { Hex } from 'viem'; import { EventLogTopics, NounsGovernorActionEnum, + ProtocolMap, + Protocols, Transaction, } from '../../../types'; import { NounsContracts, ABIs } from './constants'; @@ -114,9 +116,13 @@ export const generate = (transaction: Transaction): Transaction => { } transaction.context = { + actions: [ + `${Protocols.NOUNS_GOVERNOR}.${NounsGovernorActionEnum.CREATED_PROPOSAL}`, + ], variables: { contextAction: { type: 'contextAction', + id: `${Protocols.NOUNS_GOVERNOR}.${NounsGovernorActionEnum.CREATED_PROPOSAL}`, value: NounsGovernorActionEnum.CREATED_PROPOSAL, }, subject: { @@ -136,7 +142,7 @@ export const generate = (transaction: Transaction): Transaction => { summaries: { category: 'PROTOCOL_1', en: { - title: 'Nouns', + title: ProtocolMap[Protocols.NOUNS_GOVERNOR], default: `[[subject]][[contextAction]][[proposalId]]`, }, }, @@ -185,9 +191,13 @@ export const generate = (transaction: Transaction): Transaction => { } transaction.context = { + actions: [ + `${Protocols.NOUNS_GOVERNOR}.${NounsGovernorActionEnum.CREATED_PROPOSAL}`, + ], variables: { contextAction: { type: 'contextAction', + id: `${Protocols.NOUNS_GOVERNOR}.${NounsGovernorActionEnum.CREATED_PROPOSAL}`, value: NounsGovernorActionEnum.CREATED_PROPOSAL, }, subject: { @@ -207,7 +217,7 @@ export const generate = (transaction: Transaction): Transaction => { summaries: { category: 'PROTOCOL_1', en: { - title: 'Nouns', + title: ProtocolMap[Protocols.NOUNS_GOVERNOR], default: `[[subject]][[contextAction]][[proposalId]]`, }, }, @@ -233,9 +243,11 @@ export const generate = (transaction: Transaction): Transaction => { } transaction.context = { + actions: [`${Protocols.NOUNS_GOVERNOR}.${action}`], variables: { contextAction: { type: 'contextAction', + id: `${Protocols.NOUNS_GOVERNOR}.${action}`, value: action, }, subject: { @@ -259,7 +271,7 @@ export const generate = (transaction: Transaction): Transaction => { summaries: { category: 'PROTOCOL_1', en: { - title: 'Nouns', + title: ProtocolMap[Protocols.NOUNS_GOVERNOR], default: `[[subject]][[contextAction]]${ action === NounsGovernorActionEnum.ABSTAINED ? 'from voting on ' @@ -320,9 +332,11 @@ export const generate = (transaction: Transaction): Transaction => { } transaction.context = { + actions: [`${Protocols.NOUNS_GOVERNOR}.${action}`], variables: { contextAction: { type: 'contextAction', + id: `${Protocols.NOUNS_GOVERNOR}.${action}`, value: action, }, voter: { @@ -338,7 +352,7 @@ export const generate = (transaction: Transaction): Transaction => { summaries: { category: 'PROTOCOL_1', en: { - title: 'Nouns', + title: ProtocolMap[Protocols.NOUNS_GOVERNOR], default: `[[voter]][[contextAction]]${ action === NounsGovernorActionEnum.ABSTAINED ? 'from voting on ' @@ -361,9 +375,11 @@ export const generate = (transaction: Transaction): Transaction => { FUNCTION_CONTEXT_ACTION_MAPPING[decoded.functionName]; transaction.context = { + actions: [`${Protocols.NOUNS_GOVERNOR}.${contextAction}`], variables: { contextAction: { type: 'contextAction', + id: `${Protocols.NOUNS_GOVERNOR}.${contextAction}`, value: contextAction, }, subject: { @@ -379,7 +395,7 @@ export const generate = (transaction: Transaction): Transaction => { summaries: { category: 'PROTOCOL_1', en: { - title: 'Nouns', + title: ProtocolMap[Protocols.NOUNS_GOVERNOR], default: `[[subject]][[contextAction]]proposal[[proposalId]]`, }, }, diff --git a/src/contextualizers/protocol/nounsBuilder/auction.ts b/src/contextualizers/protocol/nounsBuilder/auction.ts index c5015695..786cc3a8 100644 --- a/src/contextualizers/protocol/nounsBuilder/auction.ts +++ b/src/contextualizers/protocol/nounsBuilder/auction.ts @@ -4,6 +4,7 @@ import { ContextVariable, EventLogTopics, NounsAuctionHouseActionEnum, + Protocols, Transaction, } from '../../../types'; import { ABIs, NOUNS_BUILDER_INSTANCES } from './constants'; @@ -71,6 +72,7 @@ export const generate = (transaction: Transaction): Transaction => { const variables: ContextVariable = { contextAction: { type: 'contextAction', + id: `${Protocols.NOUNS_AUCTION_HOUSE}.${NounsAuctionHouseActionEnum.BID}`, value: NounsAuctionHouseActionEnum.BID, }, subject: { @@ -175,6 +177,7 @@ export const generate = (transaction: Transaction): Transaction => { const variables: ContextVariable = { contextAction: { type: 'contextAction', + id: `${Protocols.NOUNS_AUCTION_HOUSE}.${NounsAuctionHouseActionEnum.SETTLED}`, value: NounsAuctionHouseActionEnum.SETTLED, }, subject: { diff --git a/src/contextualizers/protocol/nounsBuilder/governor.ts b/src/contextualizers/protocol/nounsBuilder/governor.ts index 6fb39809..2b462185 100644 --- a/src/contextualizers/protocol/nounsBuilder/governor.ts +++ b/src/contextualizers/protocol/nounsBuilder/governor.ts @@ -4,6 +4,7 @@ import { ContextStringType, EventLogTopics, NounsGovernorActionEnum, + Protocols, Transaction, } from '../../../types'; import { @@ -163,10 +164,14 @@ export const generate = (transaction: Transaction): Transaction => { } transaction.context = { + actions: [ + `${Protocols.NOUNS_GOVERNOR}.${NounsGovernorActionEnum.CREATED_PROPOSAL}`, + ], variables: { ...getDynamicVariables(proposalId), contextAction: { type: 'contextAction', + id: `${Protocols.NOUNS_GOVERNOR}.${NounsGovernorActionEnum.CREATED_PROPOSAL}`, value: NounsGovernorActionEnum.CREATED_PROPOSAL, }, subject: { @@ -205,10 +210,12 @@ export const generate = (transaction: Transaction): Transaction => { } transaction.context = { + actions: [`${Protocols.NOUNS_GOVERNOR}.${action}`], variables: { ...getDynamicVariables(proposalId), contextAction: { type: 'contextAction', + id: `${Protocols.NOUNS_GOVERNOR}.${action}`, value: action, }, subject: { @@ -246,10 +253,12 @@ export const generate = (transaction: Transaction): Transaction => { const action = translateSupport(support); transaction.context = { + actions: [`${Protocols.NOUNS_GOVERNOR}.${action}`], variables: { ...getDynamicVariables(proposalId), contextAction: { type: 'contextAction', + id: `${Protocols.NOUNS_GOVERNOR}.${action}`, value: action, }, voter: { @@ -310,10 +319,14 @@ export const generate = (transaction: Transaction): Transaction => { } } transaction.context = { + actions: [ + `${Protocols.NOUNS_GOVERNOR}.${NounsGovernorActionEnum.EXECUTED}`, + ], variables: { ...getDynamicVariables(proposalId), contextAction: { type: 'contextAction', + id: `${Protocols.NOUNS_GOVERNOR}.${NounsGovernorActionEnum.EXECUTED}`, value: NounsGovernorActionEnum.EXECUTED, }, subject: { @@ -344,10 +357,12 @@ export const generate = (transaction: Transaction): Transaction => { FUNCTION_CONTEXT_ACTION_MAPPING[decoded.functionName]; transaction.context = { + actions: [`${Protocols.NOUNS_GOVERNOR}.${contextAction}`], variables: { ...getDynamicVariables(proposalId), contextAction: { type: 'contextAction', + id: `${Protocols.NOUNS_GOVERNOR}.${contextAction}`, value: contextAction, }, subject: { diff --git a/src/contextualizers/protocol/rodeo/rodeo.ts b/src/contextualizers/protocol/rodeo/rodeo.ts index 5da7a2f6..373fd709 100644 --- a/src/contextualizers/protocol/rodeo/rodeo.ts +++ b/src/contextualizers/protocol/rodeo/rodeo.ts @@ -1,5 +1,12 @@ import { Hex } from 'viem'; -import { AssetType, EventLogTopics, Transaction, Log } from '../../../types'; +import { + AssetType, + EventLogTopics, + Transaction, + Log, + RodeoContextActionEnum, + Protocols, +} from '../../../types'; import { MULTI_TOKEN_DROP_MARKET_ABI, MULTI_TOKEN_DROP_MARKET_CONTRACT, @@ -59,6 +66,10 @@ export const generate = (transaction: Transaction): Transaction => { ) return transaction; + transaction.context.actions = [ + `${Protocols.RODEO}.${RodeoContextActionEnum.MINTED}`, + ...(transaction.context.actions || []), + ]; transaction.context.variables = { ...transaction.context.variables, numOfEth: { diff --git a/src/contextualizers/protocol/skyoneer/README.md b/src/contextualizers/protocol/skyoneer/README.md index ad31c459..f62024c9 100644 --- a/src/contextualizers/protocol/skyoneer/README.md +++ b/src/contextualizers/protocol/skyoneer/README.md @@ -1,7 +1,7 @@ -### Gold contract +### Skyoneer contract | Contract | Address | Chain ID | | ------------------------- | ---------------------------------------------------------------------------------------------------------------------- | -------- | | PackActivationSource | [0xde1bc6e9164af5a48c45111b811c61f11ce58d91](https://www.onceupon.xyz/0xde1bc6e9164af5a48c45111b811c61f11ce58d91:8453) | Base | -| PackActivationDestination | [0x21170f8bd35d0afa8ad55719ce29d6489a8585db](https://www.onceupon.xyz/0x21170f8bd35d0afa8ad55719ce29d6489a8585db:4653) | Gold | -| PlotAction | [0xb45805566a842efb6329c11e092158f3e0eddaa2](https://www.onceupon.xyz/0xb45805566a842efb6329c11e092158f3e0eddaa2:4653) | Gold | +| PackActivationDestination | [0x21170f8bd35d0afa8ad55719ce29d6489a8585db](https://www.onceupon.xyz/0x21170f8bd35d0afa8ad55719ce29d6489a8585db:4653) | Skyoneer | +| PlotAction | [0xb45805566a842efb6329c11e092158f3e0eddaa2](https://www.onceupon.xyz/0xb45805566a842efb6329c11e092158f3e0eddaa2:4653) | Skyoneer | diff --git a/src/contextualizers/protocol/skyoneer/destination.ts b/src/contextualizers/protocol/skyoneer/destination.ts index 04aff9f0..044e0b11 100644 --- a/src/contextualizers/protocol/skyoneer/destination.ts +++ b/src/contextualizers/protocol/skyoneer/destination.ts @@ -11,6 +11,9 @@ import { SkyoneerContextActionEnum, AssetType, ContextNumberType, + Protocols, + ProtocolMap, + HeuristicContextActionEnum, } from '../../../types'; import { PACK_ACTIVATION_DESTINATION_ABI, @@ -151,10 +154,15 @@ export function generate(transaction: Transaction): Transaction { }; transaction.context = { + actions: [ + `${Protocols.SKYONEER}.${SkyoneerContextActionEnum.RECEIVED}`, + HeuristicContextActionEnum.RECEIVED, + ], + summaries: { category: 'PROTOCOL_1', en: { - title: `Skyoneer`, + title: ProtocolMap[Protocols.SKYONEER], default: plotIds?.length === 2 ? '[[activator]][[received]]plots[[plotId0]]and[[plotId1]]and[[zGold]]' @@ -163,6 +171,7 @@ export function generate(transaction: Transaction): Transaction { : '[[activator]][[received]][[plots]]and[[zGold]]', }, }, + variables: { activator: { type: 'address', @@ -175,6 +184,7 @@ export function generate(transaction: Transaction): Transaction { }, received: { type: 'contextAction', + id: `${Protocols.SKYONEER}.${SkyoneerContextActionEnum.RECEIVED}`, value: SkyoneerContextActionEnum.RECEIVED, }, }, diff --git a/src/contextualizers/protocol/skyoneer/plotAction.ts b/src/contextualizers/protocol/skyoneer/plotAction.ts index 5644a4cb..300603be 100644 --- a/src/contextualizers/protocol/skyoneer/plotAction.ts +++ b/src/contextualizers/protocol/skyoneer/plotAction.ts @@ -3,6 +3,7 @@ import { EventLogTopics, SkyoneerContextActionEnum, AssetType, + Protocols, } from '../../../types'; import { PLOT_ACTION_CONTRACT_ADDRESS, PLOT_ACTION_ABI } from './constants'; import { @@ -113,6 +114,7 @@ export function generate(transaction: Transaction): Transaction { }, harvested: { type: 'contextAction', + id: `${Protocols.SKYONEER}.${SkyoneerContextActionEnum.HARVESTED}`, value: SkyoneerContextActionEnum.HARVESTED, }, }, @@ -140,6 +142,7 @@ export function generate(transaction: Transaction): Transaction { }, clearedHarvest: { type: 'contextAction', + id: `${Protocols.SKYONEER}.${SkyoneerContextActionEnum.CLEARED_DEAD_CROPS}`, value: SkyoneerContextActionEnum.CLEARED_DEAD_CROPS, }, }, @@ -167,6 +170,7 @@ export function generate(transaction: Transaction): Transaction { }, clearedHarvest: { type: 'contextAction', + id: `${Protocols.SKYONEER}.${SkyoneerContextActionEnum.CLEARED_GROWING_CROPS}`, value: SkyoneerContextActionEnum.CLEARED_GROWING_CROPS, }, }, @@ -199,6 +203,7 @@ export function generate(transaction: Transaction): Transaction { }, planted: { type: 'contextAction', + id: `${Protocols.SKYONEER}.${SkyoneerContextActionEnum.PLANTED}`, value: SkyoneerContextActionEnum.PLANTED, }, }, diff --git a/src/contextualizers/protocol/skyoneer/source.ts b/src/contextualizers/protocol/skyoneer/source.ts index b5de11ed..fc61c02f 100644 --- a/src/contextualizers/protocol/skyoneer/source.ts +++ b/src/contextualizers/protocol/skyoneer/source.ts @@ -2,6 +2,8 @@ import { Transaction, EventLogTopics, SkyoneerContextActionEnum, + ProtocolMap, + Protocols, } from '../../../types'; import { PACK_ACTIVATION_SOURCE_CONTRACT, @@ -76,13 +78,18 @@ export function generate(transaction: Transaction): Transaction { : ''; transaction.context = { + actions: [ + `${Protocols.SKYONEER}.${SkyoneerContextActionEnum.ACTIVATED_A_STARTER_PACK}`, + ], + summaries: { category: 'PROTOCOL_1', en: { - title: `Skyoneer`, + title: ProtocolMap[Protocols.SKYONEER], default: '[[activator]][[activated]]', }, }, + variables: { activator: { type: 'address', @@ -90,6 +97,7 @@ export function generate(transaction: Transaction): Transaction { }, activated: { type: 'contextAction', + id: `${Protocols.SKYONEER}.${SkyoneerContextActionEnum.ACTIVATED_A_STARTER_PACK}`, value: SkyoneerContextActionEnum.ACTIVATED_A_STARTER_PACK, }, }, diff --git a/src/contextualizers/protocol/superchainFaucet/superchainFaucet.ts b/src/contextualizers/protocol/superchainFaucet/superchainFaucet.ts index a5953c32..39aaad6f 100644 --- a/src/contextualizers/protocol/superchainFaucet/superchainFaucet.ts +++ b/src/contextualizers/protocol/superchainFaucet/superchainFaucet.ts @@ -2,6 +2,7 @@ import { AssetType, ETHAssetTransfer, HeuristicContextActionEnum, + HeuristicPrefix, Transaction, } from '../../../types'; @@ -30,6 +31,11 @@ export function generate(transaction: Transaction): Transaction { const ethTransfer = transaction.assetTransfers[1] as ETHAssetTransfer; // Pull out relevant data for faucet transaction transaction.context = { + actions: [ + HeuristicContextActionEnum.RECEIVED, + `${HeuristicPrefix}.${HeuristicContextActionEnum.RECEIVED}`, + ], + variables: { depositer: { type: 'address', @@ -46,9 +52,11 @@ export function generate(transaction: Transaction): Transaction { }, received: { type: 'contextAction', + id: HeuristicContextActionEnum.RECEIVED, value: HeuristicContextActionEnum.RECEIVED, // TODO: Make a Superchain version of this }, }, + summaries: { category: 'CORE', en: { diff --git a/src/contextualizers/protocol/uniswapV2/uniswapV2Router.ts b/src/contextualizers/protocol/uniswapV2/uniswapV2Router.ts index 5329258f..121b0ae9 100644 --- a/src/contextualizers/protocol/uniswapV2/uniswapV2Router.ts +++ b/src/contextualizers/protocol/uniswapV2/uniswapV2Router.ts @@ -1,6 +1,8 @@ import { Hex } from 'viem'; import { AssetType, + ProtocolMap, + Protocols, Transaction, UniswapV2RouterActionEnum, } from '../../../types'; @@ -55,6 +57,10 @@ export const generate = (transaction: Transaction): Transaction => { switch (decoded.functionName) { case 'addLiquidityETH': { transaction.context = { + actions: [ + `${Protocols.UNISWAP_V2_ROUTER}.${UniswapV2RouterActionEnum.ADDED_LIQUIDITY}`, + ], + variables: { lp: { type: 'address', @@ -62,6 +68,7 @@ export const generate = (transaction: Transaction): Transaction => { }, contextAction: { type: 'contextAction', + id: `${Protocols.UNISWAP_V2_ROUTER}.${UniswapV2RouterActionEnum.ADDED_LIQUIDITY}`, value: UniswapV2RouterActionEnum.ADDED_LIQUIDITY, }, numETH: { @@ -75,10 +82,11 @@ export const generate = (transaction: Transaction): Transaction => { token: ENJOY_CONTRACT_ADDRESS, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Uniswap', + title: ProtocolMap[Protocols.UNISWAP_V2_ROUTER], default: '[[lp]][[contextAction]]with[[numETH]]and[[numENJOY]]', }, }, diff --git a/src/contextualizers/protocol/uniswapV3/uniswapV3Pair.ts b/src/contextualizers/protocol/uniswapV3/uniswapV3Pair.ts index c94aedb6..c5c68750 100644 --- a/src/contextualizers/protocol/uniswapV3/uniswapV3Pair.ts +++ b/src/contextualizers/protocol/uniswapV3/uniswapV3Pair.ts @@ -4,7 +4,10 @@ import { ERC20Asset, EventLogTopics, HeuristicContextActionEnum, + ProtocolMap, + Protocols, Transaction, + UniswapV3PairActionEnum, } from '../../../types'; import { UNISWAP_V3_PAIR_ABI, UNIVERSAL_ROUTERS } from './constants'; import { decodeLog, grabLogsFromTransaction } from '../../../helpers/utils'; @@ -79,6 +82,11 @@ export const generate = (transaction: Transaction): Transaction => { ) as ERC20Asset; transaction.context = { + actions: [ + `${Protocols.UNISWAP_V3_PAIR}.${UniswapV3PairActionEnum.SWAPPED}`, + HeuristicContextActionEnum.SWAPPED, + ], + variables: { sender: { type: 'address', @@ -100,13 +108,15 @@ export const generate = (transaction: Transaction): Transaction => { }, contextAction: { type: 'contextAction', - value: HeuristicContextActionEnum.SWAPPED, // TODO: Make a Uniswap version of this + id: `${Protocols.UNISWAP_V3_PAIR}.${UniswapV3PairActionEnum.SWAPPED}`, + value: UniswapV3PairActionEnum.SWAPPED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Uniswap', + title: ProtocolMap[Protocols.UNISWAP_V3_PAIR], default: '[[sender]]swapped[[tokenIn]]for[[tokenOut]]', }, }, diff --git a/src/contextualizers/protocol/warpcast/mintWithWarps.ts b/src/contextualizers/protocol/warpcast/mintWithWarps.ts index e377f0bc..bca2935a 100644 --- a/src/contextualizers/protocol/warpcast/mintWithWarps.ts +++ b/src/contextualizers/protocol/warpcast/mintWithWarps.ts @@ -4,7 +4,10 @@ import { ERC721Asset, ETHAsset, HeuristicContextActionEnum, + ProtocolMap, + Protocols, Transaction, + WarpcastContextActionEnum, } from '../../../types'; const WARPCAST_MINT_ADDRESSES = [ @@ -87,6 +90,11 @@ export function generate(transaction: Transaction): Transaction { if (!sent) return transaction; transaction.context = { + actions: [ + `${Protocols.WARPCAST}.${WarpcastContextActionEnum.MINTED}`, + HeuristicContextActionEnum.MINTED, + ], + variables: { buyer: { type: 'address', @@ -100,13 +108,15 @@ export function generate(transaction: Transaction): Transaction { minted, contextAction: { type: 'contextAction', - value: HeuristicContextActionEnum.MINTED, + id: `${Protocols.WARPCAST}.${WarpcastContextActionEnum.MINTED}`, + value: WarpcastContextActionEnum.MINTED, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Warpcast', + title: ProtocolMap[Protocols.WARPCAST], default: '[[buyer]][[contextAction]][[minted]]with Warps for[[cost]]', }, }, diff --git a/src/contextualizers/protocol/warpcast/warpcast.ts b/src/contextualizers/protocol/warpcast/warpcast.ts index cb67922f..dda55c7d 100644 --- a/src/contextualizers/protocol/warpcast/warpcast.ts +++ b/src/contextualizers/protocol/warpcast/warpcast.ts @@ -2,6 +2,9 @@ import { AssetType, ERC20Asset, Transaction, + ProtocolMap, + Protocols, + FarcasterContextActionEnum, HeuristicContextActionEnum, } from '../../../types'; @@ -87,6 +90,11 @@ export function generate(transaction: Transaction): Transaction { // Pull out relevant data for faucet transaction transaction.context = { + actions: [ + `${Protocols.FARCASTER}.${FarcasterContextActionEnum.BOUGHT}`, + HeuristicContextActionEnum.BOUGHT, + ], + variables: { buyer: { type: 'address', @@ -102,13 +110,15 @@ export function generate(transaction: Transaction): Transaction { }, bought: { type: 'contextAction', - value: HeuristicContextActionEnum.BOUGHT, + id: `${Protocols.FARCASTER}.${FarcasterContextActionEnum.BOUGHT}`, + value: FarcasterContextActionEnum.BOUGHT, }, }, + summaries: { category: 'PROTOCOL_1', en: { - title: 'Farcaster', + title: ProtocolMap[Protocols.FARCASTER], default: '[[buyer]][[bought]][[costInUSDC]]of Warps for[[cost]]', }, }, diff --git a/src/contextualizers/protocol/weth/weth.ts b/src/contextualizers/protocol/weth/weth.ts index d56250ba..2c58d6d2 100644 --- a/src/contextualizers/protocol/weth/weth.ts +++ b/src/contextualizers/protocol/weth/weth.ts @@ -2,6 +2,8 @@ import { Hex } from 'viem'; import { AssetType, ContextSummaryVariableType, + ProtocolMap, + Protocols, Transaction, WETHContextActionEnum, } from '../../../types'; @@ -47,13 +49,16 @@ export const generate = (transaction: Transaction): Transaction => { switch (decode.functionName) { case 'deposit': { transaction.context = { + actions: [`${Protocols.WETH}.${WETHContextActionEnum.WRAPPED}`], + summaries: { category: 'FUNGIBLE_TOKEN', en: { - title: 'WETH', + title: ProtocolMap[Protocols.WETH], default: `[[from]][[wrapped]][[value]]`, }, }, + variables: { value: { type: AssetType.ERC20, @@ -66,6 +71,7 @@ export const generate = (transaction: Transaction): Transaction => { }, wrapped: { type: 'contextAction', + id: `${Protocols.WETH}.${WETHContextActionEnum.WRAPPED}`, value: WETHContextActionEnum.WRAPPED, }, }, @@ -88,18 +94,22 @@ export const generate = (transaction: Transaction): Transaction => { unit: 'wei', }; transaction.context = { + actions: [`${Protocols.WETH}.${WETHContextActionEnum.UNWRAPPED}`], + summaries: { category: 'FUNGIBLE_TOKEN', en: { - title: 'WETH', + title: ProtocolMap[Protocols.WETH], default: `[[withdrawer]][[unwrapped]][[withdrawalAmount]]`, }, }, + variables: { withdrawalAmount, withdrawer, unwrapped: { type: 'contextAction', + id: `${Protocols.WETH}.${WETHContextActionEnum.UNWRAPPED}`, value: WETHContextActionEnum.UNWRAPPED, }, }, diff --git a/src/contextualizers/protocol/zoraCreator/zoraCreator.ts b/src/contextualizers/protocol/zoraCreator/zoraCreator.ts index c150d9ff..63864a84 100644 --- a/src/contextualizers/protocol/zoraCreator/zoraCreator.ts +++ b/src/contextualizers/protocol/zoraCreator/zoraCreator.ts @@ -1,5 +1,11 @@ import { Hex } from 'viem'; -import { AssetType, EventLogTopics, Transaction } from '../../../types'; +import { + AssetType, + EventLogTopics, + Protocols, + Transaction, + ZoraContextActionEnum, +} from '../../../types'; import { PROTOCOL_REWARDS_ABI, PROTOCOL_REWARDS_CONTRACT, @@ -65,6 +71,10 @@ export const generate = (transaction: Transaction): Transaction => { ) return transaction; + transaction.context.actions = [ + `${Protocols.ZORA}.${ZoraContextActionEnum.MINTED}`, + ...(transaction.context.actions || []), + ]; transaction.context.variables = { ...transaction.context.variables, numOfEth: { diff --git a/src/types/context.ts b/src/types/context.ts index 936a4405..c83a1aa7 100644 --- a/src/types/context.ts +++ b/src/types/context.ts @@ -1,4 +1,4 @@ -import { ContextAction } from './contextAction'; +import { ContextAction, ContextActionID } from './contextAction'; import { AssetType } from './asset'; export type ContextStringType = { @@ -30,6 +30,7 @@ export type ContextCodeType = { export type ContextActionType = { type: 'contextAction'; + id: ContextActionID; value: ContextAction; indexed?: boolean; emphasis?: boolean; diff --git a/src/types/contextAction/heuristicContextAction.ts b/src/types/contextAction/heuristicContextAction.ts index f72179fe..1f969cf6 100644 --- a/src/types/contextAction/heuristicContextAction.ts +++ b/src/types/contextAction/heuristicContextAction.ts @@ -15,6 +15,8 @@ export type HeuristicContextAction = | HeuristicContextActionEnum.SENT_MESSAGE | HeuristicContextActionEnum.CANCELED_A_PENDING_TRANSACTION; +export const HeuristicPrefix = 'HEURISTIC' as const; + export enum HeuristicContextActionEnum { BOUGHT = 'BOUGHT', BRIDGED = 'BRIDGED', diff --git a/src/types/contextAction/index.ts b/src/types/contextAction/index.ts index b34abe96..4dc39b8c 100644 --- a/src/types/contextAction/index.ts +++ b/src/types/contextAction/index.ts @@ -1,5 +1,8 @@ -import { HeuristicContextAction } from './heuristicContextAction'; -import { ProtocolContextAction } from './protocolContextAction'; +import { + HeuristicContextAction, + HeuristicPrefix, +} from './heuristicContextAction'; +import { ProtocolContextAction, Protocols } from './protocolContextAction'; import { BridgeContextAction } from './bridge'; export type ContextAction = @@ -7,6 +10,12 @@ export type ContextAction = | ProtocolContextAction | BridgeContextAction; +export type ContextActionID = + | `${Protocols}.${ProtocolContextAction}` + | `${typeof HeuristicPrefix}.${HeuristicContextAction | BridgeContextAction}` + | HeuristicContextAction + | BridgeContextAction; + export * from './heuristicContextAction'; export * from './protocolContextAction'; export * from './bridge'; diff --git a/src/types/contextAction/protocolContextAction.ts b/src/types/contextAction/protocolContextAction.ts index 3ec244de..d9257a0b 100644 --- a/src/types/contextAction/protocolContextAction.ts +++ b/src/types/contextAction/protocolContextAction.ts @@ -101,6 +101,8 @@ export enum FarcasterContextActionEnum { RENTED = 'RENTED', REMOVED_A_KEY = 'REMOVED_A_KEY', ADDED_A_KEY = 'ADDED_A_KEY', + MINTED = 'MINTED', + BOUGHT = 'BOUGHT', } export type FarcasterContextAction = @@ -109,7 +111,15 @@ export type FarcasterContextAction = | FarcasterContextActionEnum.TRANSFERRED_FARCASTER_ID | FarcasterContextActionEnum.RENTED | FarcasterContextActionEnum.REMOVED_A_KEY - | FarcasterContextActionEnum.ADDED_A_KEY; + | FarcasterContextActionEnum.ADDED_A_KEY + | FarcasterContextActionEnum.MINTED + | FarcasterContextActionEnum.BOUGHT; + +export enum WarpcastContextActionEnum { + MINTED = 'MINTED', +} + +export type WarpcastContextAction = WarpcastContextActionEnum.MINTED; export enum EASContextActionEnum { ATTESTED = 'ATTESTED', @@ -193,6 +203,11 @@ export enum UniswapV2RouterActionEnum { export type UniswapV2RouterAction = UniswapV2RouterActionEnum.ADDED_LIQUIDITY; +export enum UniswapV3PairActionEnum { + SWAPPED = 'SWAPPED', +} +export type UniswapV3PairAction = UniswapV3PairActionEnum.SWAPPED; + export enum ClaimCampaignsActionEnum { CLAIMED = 'CLAIMED', } @@ -264,41 +279,90 @@ export type SkyoneerContextAction = | SkyoneerContextActionEnum.CLEARED_DEAD_CROPS | SkyoneerContextActionEnum.PLANTED; -export enum Protocols { - WETH = 'WETH', - ENS = 'ENS', - CRYPTOPUNKS = 'CRYPTOPUNKS', - LEEROY = 'LEEROY', - FRENPET = 'FRENPET', - FARCASTER = 'FARCASTER', - EAS = 'EAS', - FRIENDTECH = 'FRIENDTECH', - NOUNS_AUCTION_HOUSE = 'NOUNS_AUCTION_HOUSE', - NOUNS_GOVERNOR = 'NOUNS_GOVERNOR', - UNISWAP_V2_ROUTER = 'UNISWAP_V2_ROUTER', - CLAIM_CAMPAIGNS = 'CLAIM_CAMPAIGNS', - BASEPAINT = 'BASEPAINT', - DISPERSE = 'DISPERSE', - BNS = 'BNS', - BOOMBOX = 'BOOMBOX', - GOLD = 'GOLD', +// Zora-pattern minting contracts +export enum ZoraContextActionEnum { + MINTED = 'MINTED', } +export type ZoraContextAction = ZoraContextActionEnum.MINTED; +export enum HighlightContextActionEnum { + MINTED = 'MINTED', +} +export type HighlightContextAction = HighlightContextActionEnum.MINTED; +export enum RodeoContextActionEnum { + MINTED = 'MINTED', +} +export type RodeoContextAction = RodeoContextActionEnum.MINTED; export type ProtocolContextAction = + | ZoraContextAction + | HighlightContextAction + | RodeoContextAction | WETHContextAction | ENSContextAction | CryptoPunksContextAction | LeeroyContextAction | FrenpetContextAction | FarcasterContextAction + | WarpcastContextAction | EASContextAction | FriendTechContextAction | NounsAuctionHouseAction | NounsGovernorAction | UniswapV2RouterAction + | UniswapV3PairAction | ClaimCampaignsAction | BasepaintAction | DisperseAction | BNSContextAction | BoomboxContextAction | SkyoneerContextAction; + +export enum Protocols { + ZORA = 'ZORA', + HIGHLIGHT = 'HIGHLIGHT', + RODEO = 'RODEO', + WETH = 'WETH', + ENS = 'ENS', + CRYPTOPUNKS = 'CRYPTOPUNKS', + LEEROY = 'LEEROY', + FRENPET = 'FRENPET', + FARCASTER = 'FARCASTER', + WARPCAST = 'WARPCAST', + EAS = 'EAS', + FRIENDTECH = 'FRIENDTECH', + NOUNS_AUCTION_HOUSE = 'NOUNS_AUCTION_HOUSE', + NOUNS_GOVERNOR = 'NOUNS_GOVERNOR', + UNISWAP_V2_ROUTER = 'UNISWAP_V2_ROUTER', + UNISWAP_V3_PAIR = 'UNISWAP_V3_PAIR', + CLAIM_CAMPAIGNS = 'CLAIM_CAMPAIGNS', + BASEPAINT = 'BASEPAINT', + DISPERSE = 'DISPERSE', + BNS = 'BNS', + BOOMBOX = 'BOOMBOX', + SKYONEER = 'SKYONEER', +} + +export const ProtocolMap = { + [Protocols.BASEPAINT]: 'Basepaint', + [Protocols.BNS]: 'BNS', + [Protocols.BOOMBOX]: 'Boombox', + [Protocols.CLAIM_CAMPAIGNS]: 'Claim', + [Protocols.CRYPTOPUNKS]: 'CryptoPunks', + [Protocols.DISPERSE]: 'Disperse', + [Protocols.EAS]: 'EAS', + [Protocols.ENS]: 'ENS', + [Protocols.FARCASTER]: 'Farcaster', + [Protocols.HIGHLIGHT]: 'Highlight', + [Protocols.WARPCAST]: 'Warpcast', + [Protocols.FRENPET]: 'Fren Pet', + [Protocols.FRIENDTECH]: 'friend.tech', + [Protocols.SKYONEER]: 'Skyoneer', + [Protocols.LEEROY]: 'Leeroy', + [Protocols.NOUNS_GOVERNOR]: 'Nouns', + [Protocols.NOUNS_AUCTION_HOUSE]: 'Nouns', + [Protocols.RODEO]: 'Rodeo', + [Protocols.UNISWAP_V2_ROUTER]: 'Uniswap', + [Protocols.UNISWAP_V3_PAIR]: 'Uniswap', + [Protocols.WETH]: 'WETH', + [Protocols.ZORA]: 'Zora', +}; diff --git a/src/types/transaction.ts b/src/types/transaction.ts index c2243a40..3fba0d7b 100644 --- a/src/types/transaction.ts +++ b/src/types/transaction.ts @@ -7,6 +7,7 @@ import { } from 'viem'; import { Log, RawReceipt } from './log'; import { ContextVariable, ContextSummaryType } from './context'; +import { ContextActionID } from './contextAction'; import { NetAssetTransfers, AssetTransfer } from './asset'; import { InternalHashType, StdObj } from './shared'; import { Contract } from './contract'; @@ -71,10 +72,10 @@ export type Receipt = TransactionReceipt & { }; export type TransactionContextType = { + actions?: ContextActionID[]; variables?: ContextVariable; summaries?: ContextSummaryType; crossChainTx?: Transaction[]; - actions?: ContextAction[]; }; // MongoDB document @@ -194,3 +195,52 @@ export type RawNeighbor = { export type TxContext = { type: string; }; + +/** + * @note These `/v3/transactions` endpoint types are currently in alpha and may change. + */ +export type TransactionQueryResponse = { + transactions: TransactionEnriched[]; + nextCursor: string | null; + partiesEnriched?: { [key: string]: PartyEnriched }; + assetsEnriched?: { [key: string]: AssetEnriched }; +}; +export type TransactionEnriched = { + parties: string[]; + context: TransactionContextType; + netAssetTransfers: NetAssetTransfers; + assetTransfers: AssetTransfer[]; + pseudotransactions?: PseudoTransaction[]; +} & Transaction; + +type HandleAvatar = { + handle: string | null; + avatar: string | null; +}; + +type FarcasterDetails = HandleAvatar & { + fid: string | null; +}; + +export type PartyEnriched = { + chainId: number; + label: { + public: string; + }; + isContract: boolean; + tokenStandard: string; + imgUrl: string; + decimals: number; + symbol: string; + ensNew: HandleAvatar; + bns: HandleAvatar; + farcaster: FarcasterDetails; +}; + +export type AssetEnriched = { + contract: string; + tokenId: string; + type: string; + value: string; + imageUrl: string | null; +}; diff --git a/tsconfig.build.json b/tsconfig.build.json index be63aacf..6ecb79f6 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,4 +1,4 @@ { "extends": "./tsconfig.json", - "exclude": ["node_modules", "test", "dist", "**/*spec.ts", "src/contextualizers/test", "src/transformers/test", "src/helpers/dev.ts", "src/transformers/helpers/dev.ts"] + "exclude": ["node_modules", "codemods", "test", "dist", "**/*spec.ts", "src/contextualizers/test", "src/transformers/test", "src/helpers/dev.ts", "src/transformers/helpers/dev.ts"] }