Some checks failed
deploy / deploy (push) Failing after 34s
Proof: npm test (147 passing); npm run operator-dashboard:build; git diff --cached --check. Assumptions: Bridge recent_deposits created_at is the authoritative source time for deposit activity; rows without created_at must be deduped to their earliest observed status instead of the latest replay ingestion. Still fake: No fund movement or bridge migration was performed; ntfy messages already sent before this fix cannot be unsent.
65 lines
1.6 KiB
JavaScript
65 lines
1.6 KiB
JavaScript
export function intentsAssetIdFromNearTokenId(nearTokenId) {
|
|
const normalized = String(nearTokenId || '').trim();
|
|
if (!normalized) return null;
|
|
if (normalized.startsWith('nep141:')) return normalized;
|
|
return `nep141:${normalized}`;
|
|
}
|
|
|
|
export function bridgeDepositAssetId(deposit, {
|
|
assetRegistry = new Map(),
|
|
fallbackAssetId = null,
|
|
} = {}) {
|
|
const candidates = [
|
|
deposit?.intents_token_id,
|
|
intentsAssetIdFromNearTokenId(deposit?.near_token_id),
|
|
deposit?.defuse_asset_identifier,
|
|
fallbackAssetId,
|
|
].filter(Boolean);
|
|
|
|
for (const candidate of candidates) {
|
|
if (!assetRegistry?.size || assetRegistry.has(candidate)) return candidate;
|
|
}
|
|
|
|
return fallbackAssetId || candidates[0] || null;
|
|
}
|
|
|
|
export function bridgeDepositObservedAt(deposit) {
|
|
const candidates = [
|
|
deposit?.created_at,
|
|
deposit?.updated_at,
|
|
deposit?.observed_at,
|
|
deposit?.timestamp,
|
|
];
|
|
|
|
for (const candidate of candidates) {
|
|
const timestamp = toIsoTimestamp(candidate);
|
|
if (timestamp) return timestamp;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
export function uniqueChainsForAssets(assets = []) {
|
|
return [...new Set(
|
|
assets
|
|
.map((asset) => asset?.chain)
|
|
.filter(Boolean),
|
|
)];
|
|
}
|
|
|
|
export function assetsByChain(assets = []) {
|
|
const byChain = new Map();
|
|
for (const asset of assets) {
|
|
if (!asset?.chain) continue;
|
|
const chainAssets = byChain.get(asset.chain) || [];
|
|
chainAssets.push(asset);
|
|
byChain.set(asset.chain, chainAssets);
|
|
}
|
|
return byChain;
|
|
}
|
|
|
|
function toIsoTimestamp(value) {
|
|
if (!value) return null;
|
|
const date = new Date(value);
|
|
return Number.isNaN(date.getTime()) ? null : date.toISOString();
|
|
}
|