diff --git a/packages/engine/paima-funnel/src/cde/erc1155.ts b/packages/engine/paima-funnel/src/cde/erc1155.ts index 7e4fbb7c..368ac7c1 100644 --- a/packages/engine/paima-funnel/src/cde/erc1155.ts +++ b/packages/engine/paima-funnel/src/cde/erc1155.ts @@ -57,6 +57,7 @@ function transferSingleToDatum( }, contractAddress: extension.contractAddress, scheduledPrefix: extension.scheduledPrefix, + burnScheduledPrefix: extension.burnScheduledPrefix, network, }; } @@ -79,6 +80,7 @@ function transferBatchToDatum( }, contractAddress: extension.contractAddress, scheduledPrefix: extension.scheduledPrefix, + burnScheduledPrefix: extension.burnScheduledPrefix, network, }; } diff --git a/packages/engine/paima-sm/src/cde-erc1155-transfer.ts b/packages/engine/paima-sm/src/cde-erc1155-transfer.ts index 58355bf8..a97cfeec 100644 --- a/packages/engine/paima-sm/src/cde-erc1155-transfer.ts +++ b/packages/engine/paima-sm/src/cde-erc1155-transfer.ts @@ -17,10 +17,7 @@ export default async function processErc1155TransferDatum( cdeDatum: CdeErc1155TransferDatum, inPresync: boolean ): Promise { - const { cdeId, scheduledPrefix, payload, blockNumber } = cdeDatum; - if (!scheduledPrefix) { - return []; - } + const { cdeId, scheduledPrefix, burnScheduledPrefix, payload, blockNumber } = cdeDatum; const { operator, from, to, ids, values } = payload; const isMint = from == '0x0000000000000000000000000000000000000000'; const isBurn = /^0x0+(dead)?$/i.test(to); @@ -29,15 +26,29 @@ export default async function processErc1155TransferDatum( // Always schedule the plain old transfer event. const scheduledBlockHeight = inPresync ? ENV.SM_START_BLOCKHEIGHT + 1 : blockNumber; - const scheduledInputData = [ - scheduledPrefix, - operator, - from.toLowerCase(), - to.toLowerCase(), - JSON.stringify(ids), - JSON.stringify(values), - ].join('|'); - updateList.push(createScheduledData(scheduledInputData, scheduledBlockHeight)); + if (scheduledPrefix) { + const scheduledInputData = [ + scheduledPrefix, + operator, + from.toLowerCase(), + to.toLowerCase(), + JSON.stringify(ids), + JSON.stringify(values), + ].join('|'); + updateList.push(createScheduledData(scheduledInputData, scheduledBlockHeight)); + } + + if (isBurn && burnScheduledPrefix) { + const burnData = [ + burnScheduledPrefix, + operator, + from.toLowerCase(), + // to is excluded because it's presumed 0 + JSON.stringify(ids), + JSON.stringify(values), + ].join('|'); + updateList.push(createScheduledData(burnData, scheduledBlockHeight)); + } // Update balance + burn tables. for (let i = 0; i < ids.length; ++i) { diff --git a/packages/engine/paima-sm/src/types.ts b/packages/engine/paima-sm/src/types.ts index 4db2c1de..7ba42768 100644 --- a/packages/engine/paima-sm/src/types.ts +++ b/packages/engine/paima-sm/src/types.ts @@ -198,7 +198,8 @@ export interface CdeErc1155TransferDatum extends CdeDatumBase { cdeDatumType: ChainDataExtensionDatumType.Erc1155Transfer; payload: CdeDatumErc1155TransferPayload; contractAddress: string; - scheduledPrefix: string; + scheduledPrefix?: string | undefined; + burnScheduledPrefix?: string | undefined; } export interface CdeGenericDatum extends CdeDatumBase { @@ -344,7 +345,8 @@ export const ChainDataExtensionErc1155Config = Type.Intersect([ Type.Object({ type: Type.Literal(CdeEntryTypeName.ERC1155), contractAddress: EvmAddress, - scheduledPrefix: Type.String(), + scheduledPrefix: Type.Optional(Type.String()), + burnScheduledPrefix: Type.Optional(Type.String()), }), ]); export type ChainDataExtensionErc1155 = ChainDataExtensionBase &