Compare commits

..
Author SHA1 Message Date
Bill He e2bdebe53c Add memo to transactions for onchain tracking 2024-02-05 17:59:58 -08:00
5 changed files with 25 additions and 26 deletions
+7 -18
View File
@@ -95,10 +95,7 @@ export type ElementProps<TableRowData extends object | CustomRowConfig, TableRow
selectionBehavior?: 'replace' | 'toggle'; selectionBehavior?: 'replace' | 'toggle';
onRowAction?: (key: TableRowKey, row: TableRowData) => void; onRowAction?: (key: TableRowKey, row: TableRowData) => void;
slotEmpty?: React.ReactNode; slotEmpty?: React.ReactNode;
viewMoreConfig?: { initialNumRowsToShow?: number;
initialNumRowsToShow: number;
numRowsPerPage?: number;
};
// collection: TableCollection<string>; // collection: TableCollection<string>;
// children: React.ReactNode; // children: React.ReactNode;
}; };
@@ -128,7 +125,7 @@ export const Table = <TableRowData extends object, TableRowKey extends Key>({
selectionMode = 'single', selectionMode = 'single',
selectionBehavior = 'toggle', selectionBehavior = 'toggle',
slotEmpty, slotEmpty,
viewMoreConfig, initialNumRowsToShow,
// shouldRowRender, // shouldRowRender,
// collection, // collection,
@@ -144,18 +141,8 @@ export const Table = <TableRowData extends object, TableRowKey extends Key>({
style, style,
}: ElementProps<TableRowData, TableRowKey> & StyleProps) => { }: ElementProps<TableRowData, TableRowKey> & StyleProps) => {
const [selectedKeys, setSelectedKeys] = useState(new Set<TableRowKey>()); const [selectedKeys, setSelectedKeys] = useState(new Set<TableRowKey>());
const [numRowsToShow, setNumRowsToShow] = useState(viewMoreConfig?.initialNumRowsToShow); const [numRowsToShow, setNumRowsToShow] = useState(initialNumRowsToShow);
const enableViewMore = viewMoreConfig !== undefined; const enableViewMore = numRowsToShow !== undefined;
const onViewMoreClick = () => {
if (!viewMoreConfig) return;
const { numRowsPerPage } = viewMoreConfig;
if (numRowsPerPage) {
setNumRowsToShow((prev) => (prev ?? 0) + numRowsPerPage);
} else {
setNumRowsToShow(data.length);
}
};
const currentBreakpoints = useBreakpoints(); const currentBreakpoints = useBreakpoints();
const shownColumns = columns.filter( const shownColumns = columns.filter(
@@ -231,7 +218,9 @@ export const Table = <TableRowData extends object, TableRowKey extends Key>({
} }
numColumns={shownColumns.length} numColumns={shownColumns.length}
onViewMoreClick={ onViewMoreClick={
enableViewMore && numRowsToShow! < data.length ? onViewMoreClick : undefined enableViewMore && numRowsToShow < data.length
? () => setNumRowsToShow(data.length)
: undefined
} }
// shouldRowRender={shouldRowRender} // shouldRowRender={shouldRowRender}
hideHeader={hideHeader} hideHeader={hideHeader}
+2
View File
@@ -173,3 +173,5 @@ export type AnalyticsEventData<T extends AnalyticsEvent> =
validatorUrl: string; validatorUrl: string;
} }
: never; : never;
export const DEFAULT_TRANSACTION_MEMO = 'dYdX Frontend (web)';
+3 -1
View File
@@ -16,6 +16,7 @@ import {
import type { ResolutionString } from 'public/tradingview/charting_library'; import type { ResolutionString } from 'public/tradingview/charting_library';
import type { ConnectNetworkEvent, NetworkConfig } from '@/constants/abacus'; import type { ConnectNetworkEvent, NetworkConfig } from '@/constants/abacus';
import { DEFAULT_TRANSACTION_MEMO } from '@/constants/analytics';
import { type Candle, RESOLUTION_MAP } from '@/constants/candles'; import { type Candle, RESOLUTION_MAP } from '@/constants/candles';
import { ENVIRONMENT_CONFIG_MAP } from '@/constants/networks'; import { ENVIRONMENT_CONFIG_MAP } from '@/constants/networks';
import { DydxChainAsset } from '@/constants/wallets'; import { DydxChainAsset } from '@/constants/wallets';
@@ -83,7 +84,8 @@ const useDydxClientContext = () => {
{ {
broadcastPollIntervalMs: 3_000, broadcastPollIntervalMs: 3_000,
broadcastTimeoutMs: 60_000, broadcastTimeoutMs: 60_000,
} },
DEFAULT_TRANSACTION_MEMO
) )
) )
); );
+12 -6
View File
@@ -31,6 +31,7 @@ import {
type HumanReadableTransferPayload, type HumanReadableTransferPayload,
} from '@/constants/abacus'; } from '@/constants/abacus';
import { DEFAULT_TRANSACTION_MEMO } from '@/constants/analytics';
import { DialogTypes } from '@/constants/dialogs'; import { DialogTypes } from '@/constants/dialogs';
import { UNCOMMITTED_ORDER_TIMEOUT_MS } from '@/constants/trade'; import { UNCOMMITTED_ORDER_TIMEOUT_MS } from '@/constants/trade';
import { ENVIRONMENT_CONFIG_MAP, DydxNetwork, isTestnet } from '@/constants/networks'; import { ENVIRONMENT_CONFIG_MAP, DydxNetwork, isTestnet } from '@/constants/networks';
@@ -115,7 +116,8 @@ class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
{ {
broadcastPollIntervalMs: 3_000, broadcastPollIntervalMs: 3_000,
broadcastTimeoutMs: 60_000, broadcastTimeoutMs: 60_000,
} },
DEFAULT_TRANSACTION_MEMO
) )
) )
); );
@@ -370,8 +372,8 @@ class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
value: { value: {
...params.msg, ...params.msg,
timeoutTimestamp: params.msg.timeoutTimestamp timeoutTimestamp: params.msg.timeoutTimestamp
// Squid returns timeoutTimestamp as Long, but the signer expects BigInt ? // Squid returns timeoutTimestamp as Long, but the signer expects BigInt
? BigInt(Long.fromValue(params.msg.timeoutTimestamp).toString()) BigInt(Long.fromValue(params.msg.timeoutTimestamp).toString())
: undefined, : undefined,
}, },
}; };
@@ -387,7 +389,11 @@ class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
} }
ibcMsg.value.token.amount = amount.toString(); ibcMsg.value.token.amount = amount.toString();
const tx = await this.nobleClient.send([ibcMsg]); const tx = await this.nobleClient.send(
[ibcMsg],
undefined,
`${DEFAULT_TRANSACTION_MEMO} | ${this.nobleWallet?.address}`
);
const parsedTx = this.parseToPrimitives(tx); const parsedTx = this.parseToPrimitives(tx);
@@ -426,8 +432,8 @@ class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
value: { value: {
...parsedIbcPayload.msg, ...parsedIbcPayload.msg,
timeoutTimestamp: parsedIbcPayload.msg.timeoutTimestamp timeoutTimestamp: parsedIbcPayload.msg.timeoutTimestamp
// Squid returns timeoutTimestamp as Long, but the signer expects BigInt ? // Squid returns timeoutTimestamp as Long, but the signer expects BigInt
? BigInt(Long.fromValue(parsedIbcPayload.msg.timeoutTimestamp).toString()) BigInt(Long.fromValue(parsedIbcPayload.msg.timeoutTimestamp).toString())
: undefined, : undefined,
}, },
}; };
@@ -121,7 +121,7 @@ export const TradingRewardHistoryTable = ({
selectionBehavior="replace" selectionBehavior="replace"
withOuterBorder={withOuterBorder} withOuterBorder={withOuterBorder}
withInnerBorders={withInnerBorders} withInnerBorders={withInnerBorders}
viewMoreConfig={{ initialNumRowsToShow: 5, numRowsPerPage: 10 }} initialNumRowsToShow={5}
withScrollSnapColumns withScrollSnapColumns
withScrollSnapRows withScrollSnapRows
/> />