You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: support for Stacks 2.1 stx-transfer event memo field (#1285)
* feat: support for Stacks 2.1 stx-transfer event memo field (the `stx-transfer-memo` Clarity2 function)
* fix: remove null memo field from different asset transfer events
* test: unit tests for Stacks 2.1 stx-transfer event memo field
'stx_lock' as asset_type, event_index, tx_id, microblock_sequence, tx_index, block_height, canonical, 0 as asset_event_type_id,
2202
-
locked_address as sender, '' as recipient, '<stx>' as asset_identifier, locked_amount as amount, unlock_height, null::bytea as value
2212
+
locked_address as sender, '' as recipient, '<stx>' as asset_identifier, locked_amount as amount, unlock_height, null::bytea as value, null::bytea as memo
2203
2213
FROM stx_lock_events
2204
2214
WHERE canonical = true AND microblock_canonical = true AND locked_address = ${stxAddress} AND block_height <= ${blockHeight}
2205
2215
UNION ALL
2206
2216
SELECT
2207
2217
'stx' as asset_type, event_index, tx_id, microblock_sequence, tx_index, block_height, canonical, asset_event_type_id,
2208
-
sender, recipient, '<stx>' as asset_identifier, amount::numeric, null::numeric as unlock_height, null::bytea as value
2218
+
sender, recipient, '<stx>' as asset_identifier, amount::numeric, null::numeric as unlock_height, null::bytea as value, memo
2209
2219
FROM stx_events
2210
2220
WHERE canonical = true AND microblock_canonical = true AND (sender = ${stxAddress} OR recipient = ${stxAddress}) AND block_height <= ${blockHeight}
2211
2221
UNION ALL
2212
2222
SELECT
2213
2223
'ft' as asset_type, event_index, tx_id, microblock_sequence, tx_index, block_height, canonical, asset_event_type_id,
2214
-
sender, recipient, asset_identifier, amount, null::numeric as unlock_height, null::bytea as value
2224
+
sender, recipient, asset_identifier, amount, null::numeric as unlock_height, null::bytea as value, null::bytea as memo
2215
2225
FROM ft_events
2216
2226
WHERE canonical = true AND microblock_canonical = true AND (sender = ${stxAddress} OR recipient = ${stxAddress}) AND block_height <= ${blockHeight}
2217
2227
UNION ALL
2218
2228
SELECT
2219
2229
'nft' as asset_type, event_index, tx_id, microblock_sequence, tx_index, block_height, canonical, asset_event_type_id,
2220
-
sender, recipient, asset_identifier, null::numeric as amount, null::numeric as unlock_height, value
2230
+
sender, recipient, asset_identifier, null::numeric as amount, null::numeric as unlock_height, value, null::bytea as memo
2221
2231
FROM nft_events
2222
2232
WHERE canonical = true AND microblock_canonical = true AND (sender = ${stxAddress} OR recipient = ${stxAddress}) AND block_height <= ${blockHeight}
2223
2233
) asset_events
@@ -2253,6 +2263,9 @@ export class PgStore {
2253
2263
event_type: DbEventTypeId.StxAsset,
2254
2264
amount: BigInt(row.amount??0),
2255
2265
};
2266
+
if(row.memo){
2267
+
event.memo=row.memo;
2268
+
}
2256
2269
returnevent;
2257
2270
}elseif(row.asset_type==='ft'){
2258
2271
constevent: DbFtEvent={
@@ -2468,6 +2481,7 @@ export class PgStore {
2468
2481
event_amount?: string;
2469
2482
event_sender?: string;
2470
2483
event_recipient?: string;
2484
+
event_memo?: string;
2471
2485
})[]
2472
2486
>`
2473
2487
WITH transactions AS (
@@ -2508,6 +2522,7 @@ export class PgStore {
2508
2522
events.amount as event_amount,
2509
2523
events.sender as event_sender,
2510
2524
events.recipient as event_recipient,
2525
+
events.memo as event_memo,
2511
2526
${this.sql.unsafe(abiColumn('transactions'))}
2512
2527
FROM transactions
2513
2528
LEFT JOIN events ON transactions.tx_id = events.tx_id
0 commit comments