@@ -13,7 +13,7 @@ import * as _ from "lodash";
1313import { Transaction } from "sequelize" ;
1414import models from "../index" ;
1515import { TransferAssetInstance } from "../transferAsset" ;
16- import { createAddressLog } from "./addressLog " ;
16+ import { createAssetAddressLog } from "./assetAddressLog " ;
1717import {
1818 createAssetTransferOutput ,
1919 getOutputOwner
@@ -237,12 +237,6 @@ export async function createTransferAsset(
237237 ) ,
238238 ..._ . uniq ( resultOutputs . filter ( o => o . owner ) . map ( o => o . owner ! ) )
239239 ] ) ;
240- await Promise . all (
241- addresses . map ( address =>
242- createAddressLog ( transaction , address , "AssetOwner" , options )
243- )
244- ) ;
245- // FIXME: Log the addresses in orders.
246240 const assetTypes : string [ ] = _ . uniq ( [
247241 ..._ . uniq ( resultInputs . map ( i => i . assetType ) ) ,
248242 ..._ . uniq ( resultBurns . map ( b => b . assetType ) ) ,
@@ -253,5 +247,25 @@ export async function createTransferAsset(
253247 createAssetTypeLog ( transaction , assetType , options )
254248 )
255249 ) ;
250+ // NOTE: TransferAsset can have many inputs and outputs, and some addresses
251+ // may not be related to a specific asset type if it's a
252+ // CoinJoin(https://en.bitcoin.it/wiki/CoinJoin) transaction. However, it
253+ // creates combinations of all the asset addresses and the asset types
254+ // because there is no clear way to tell which addresses are not related to
255+ // which asset types.
256+ await Promise . all (
257+ addresses . map ( address =>
258+ Promise . all (
259+ assetTypes . map ( assetType =>
260+ createAssetAddressLog (
261+ transaction ,
262+ address ,
263+ assetType ,
264+ options
265+ )
266+ )
267+ )
268+ )
269+ ) ;
256270 return result ;
257271}
0 commit comments