From 55b8d73a19cf662df36377c33249781f7f8c70fe Mon Sep 17 00:00:00 2001 From: cdt Date: Tue, 28 May 2024 13:41:04 -0400 Subject: [PATCH 1/6] add and export new v3 tx types --- src/types/transaction.ts | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/types/transaction.ts b/src/types/transaction.ts index 2010569e..82e18be0 100644 --- a/src/types/transaction.ts +++ b/src/types/transaction.ts @@ -172,3 +172,57 @@ export type RawNeighbor = { export type TxContext = { type: string; }; + +// v3 types +export type TransactionQueryResponse = { + transactions: TransactionEnriched[]; + cursor: string | null; + partiesEnriched?: { [key: string]: PartyEnriched }; + assetsEnriched?: { [key: string]: AssetEnriched }; +}; + +export type TransactionEnriched = { + parties: string[]; + context: TransactionContextType; + netAssetTransfers: { + [address: string]: { + received: [{ type; contract; value; tokenId? }]; + sent: [{ type; contract; value; tokenId? }]; + }; + }; + assetTransfers: { from; to; value; type; contract; tokenId }[]; + pseudotransactions?: PseudoTransaction[]; +} & Transaction; + +export type PartyEnriched = { + chainId: number; + label: { + public: string; + }; + isContract: boolean; + tokenStandard: string; + imgUrl: string; + decimals: number; + symbol: string; + ensNew: { + handle: string | null; + avatar: string | null; + }; + bns: { + handle: string | null; + avatar: string | null; + }; + farcaster: { + handle: string | null; + avatar: string | null; + fid: string | null; + }; +}; + +export type AssetEnriched = { + contract: string; + tokenId: string; + type: string; + value: string; + imageUrl: string | null; +}; From a9e66a8b1a38b3c7ce3642304c1f131ed6d9f324 Mon Sep 17 00:00:00 2001 From: cdt Date: Tue, 28 May 2024 14:14:01 -0400 Subject: [PATCH 2/6] add subtypes, add warning --- src/types/transaction.ts | 53 ++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/src/types/transaction.ts b/src/types/transaction.ts index 82e18be0..d85ee605 100644 --- a/src/types/transaction.ts +++ b/src/types/transaction.ts @@ -173,7 +173,9 @@ export type TxContext = { type: string; }; -// v3 types +/** + * @note These `/v3/transactions` endpoint types are currently in alpha and may change. + */ export type TransactionQueryResponse = { transactions: TransactionEnriched[]; cursor: string | null; @@ -186,14 +188,39 @@ export type TransactionEnriched = { context: TransactionContextType; netAssetTransfers: { [address: string]: { - received: [{ type; contract; value; tokenId? }]; - sent: [{ type; contract; value; tokenId? }]; + received: TransferDetails[]; + sent: TransferDetails[]; }; }; - assetTransfers: { from; to; value; type; contract; tokenId }[]; - pseudotransactions?: PseudoTransaction[]; + assetTransfers: AssetTransfer[]; + pseudotransactions?: PseudoTransaction[]; } & Transaction; +type TransferDetails = { + type: string; + contract: string; + value: string; + tokenId?: string; +}; + +type AssetTransfer = { + from: string; + to: string; + value: string; + type: string; + contract: string; + tokenId?: string; +}; + +type HandleAvatar = { + handle: string | null; + avatar: string | null; +}; + +type FarcasterDetails = HandleAvatar & { + fid: string | null; +}; + export type PartyEnriched = { chainId: number; label: { @@ -204,19 +231,9 @@ export type PartyEnriched = { imgUrl: string; decimals: number; symbol: string; - ensNew: { - handle: string | null; - avatar: string | null; - }; - bns: { - handle: string | null; - avatar: string | null; - }; - farcaster: { - handle: string | null; - avatar: string | null; - fid: string | null; - }; + ensNew: HandleAvatar; + bns: HandleAvatar; + farcaster: FarcasterDetails }; export type AssetEnriched = { From 55a2ce40fbf1351e791dd951fd4bd7452ea03f0b Mon Sep 17 00:00:00 2001 From: cdt Date: Tue, 28 May 2024 14:15:10 -0400 Subject: [PATCH 3/6] space --- src/types/transaction.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/transaction.ts b/src/types/transaction.ts index d85ee605..f22b690d 100644 --- a/src/types/transaction.ts +++ b/src/types/transaction.ts @@ -192,7 +192,7 @@ export type TransactionEnriched = { sent: TransferDetails[]; }; }; - assetTransfers: AssetTransfer[]; + assetTransfers: AssetTransfer[]; pseudotransactions?: PseudoTransaction[]; } & Transaction; From 14495aeb8e9c4470a726342a4036d030a1795af9 Mon Sep 17 00:00:00 2001 From: cdt Date: Tue, 28 May 2024 14:18:48 -0400 Subject: [PATCH 4/6] duplicate asset transfer --- src/types/transaction.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/types/transaction.ts b/src/types/transaction.ts index f22b690d..215cf498 100644 --- a/src/types/transaction.ts +++ b/src/types/transaction.ts @@ -203,15 +203,6 @@ type TransferDetails = { tokenId?: string; }; -type AssetTransfer = { - from: string; - to: string; - value: string; - type: string; - contract: string; - tokenId?: string; -}; - type HandleAvatar = { handle: string | null; avatar: string | null; From a596b82cd511438b7872ca2e114ddbd1493896eb Mon Sep 17 00:00:00 2001 From: cdt Date: Tue, 28 May 2024 14:21:24 -0400 Subject: [PATCH 5/6] eslint --- src/types/transaction.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/types/transaction.ts b/src/types/transaction.ts index 215cf498..634ba757 100644 --- a/src/types/transaction.ts +++ b/src/types/transaction.ts @@ -174,26 +174,25 @@ export type TxContext = { }; /** - * @note These `/v3/transactions` endpoint types are currently in alpha and may change. - */ + * @note These `/v3/transactions` endpoint types are currently in alpha and may change. + */ export type TransactionQueryResponse = { transactions: TransactionEnriched[]; cursor: string | null; partiesEnriched?: { [key: string]: PartyEnriched }; assetsEnriched?: { [key: string]: AssetEnriched }; }; - export type TransactionEnriched = { parties: string[]; context: TransactionContextType; netAssetTransfers: { [address: string]: { received: TransferDetails[]; - sent: TransferDetails[]; + sent: TransferDetails[]; }; }; - assetTransfers: AssetTransfer[]; - pseudotransactions?: PseudoTransaction[]; + assetTransfers: AssetTransfer[]; + pseudotransactions?: PseudoTransaction[]; } & Transaction; type TransferDetails = { @@ -204,12 +203,12 @@ type TransferDetails = { }; type HandleAvatar = { - handle: string | null; - avatar: string | null; + handle: string | null; + avatar: string | null; }; type FarcasterDetails = HandleAvatar & { - fid: string | null; + fid: string | null; }; export type PartyEnriched = { @@ -223,8 +222,8 @@ export type PartyEnriched = { decimals: number; symbol: string; ensNew: HandleAvatar; - bns: HandleAvatar; - farcaster: FarcasterDetails + bns: HandleAvatar; + farcaster: FarcasterDetails; }; export type AssetEnriched = { From 0dc0678199f5db648919c9dca8fee6e9474bcd50 Mon Sep 17 00:00:00 2001 From: cdt Date: Tue, 28 May 2024 16:10:20 -0400 Subject: [PATCH 6/6] add net asset transfer type --- src/types/transaction.ts | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/types/transaction.ts b/src/types/transaction.ts index 634ba757..a6ebf532 100644 --- a/src/types/transaction.ts +++ b/src/types/transaction.ts @@ -185,23 +185,11 @@ export type TransactionQueryResponse = { export type TransactionEnriched = { parties: string[]; context: TransactionContextType; - netAssetTransfers: { - [address: string]: { - received: TransferDetails[]; - sent: TransferDetails[]; - }; - }; + netAssetTransfers: NetAssetTransfers; assetTransfers: AssetTransfer[]; pseudotransactions?: PseudoTransaction[]; } & Transaction; -type TransferDetails = { - type: string; - contract: string; - value: string; - tokenId?: string; -}; - type HandleAvatar = { handle: string | null; avatar: string | null;