Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m3s
CI/CD Pipeline / Security Scanning (push) Successful in 2m18s
CI/CD Pipeline / Lint and Format (push) Failing after 34s
CI/CD Pipeline / Terraform Validation (push) Failing after 20s
CI/CD Pipeline / Kubernetes Validation (push) Successful in 22s
Deploy ChainID 138 / Deploy ChainID 138 (push) Failing after 40s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Failing after 49s
OMNL reconcile anchor / Run omnl:reconcile and upload artifacts (push) Failing after 21s
Validation / validate-genesis (push) Successful in 25s
Validation / validate-terraform (push) Failing after 21s
Validation / validate-kubernetes (push) Failing after 8s
Validation / validate-smart-contracts (push) Failing after 8s
Validation / validate-security (push) Failing after 1m11s
Validation / validate-documentation (push) Failing after 14s
Verify Deployment / Verify Deployment (push) Failing after 45s
Ship AddressActivityRegistry V1/V2, ISO20022IntakeGateway, Chain138ParticipantSurface, checkpoint hub contracts, checkpoint-core package, aggregator/indexer/sdk services, relay profile guards, M00 diamond bridge facet, and OMNL compliance contracts. Co-authored-by: Cursor <cursoragent@cursor.com>
96 lines
4.0 KiB
JavaScript
96 lines
4.0 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.mapPaymentLeafToCanonical = mapPaymentLeafToCanonical;
|
|
exports.canonicalToPacs008Xml = canonicalToPacs008Xml;
|
|
const ethers_1 = require("ethers");
|
|
const types_1 = require("./types");
|
|
const hashes_1 = require("./hashes");
|
|
/** Map Chain 138 payment leaf → MT-103 / pacs.008 equivalent canonical message. */
|
|
function mapPaymentLeafToCanonical(leaf) {
|
|
const txHash = leaf.txHash;
|
|
const instrBytes32 = (0, hashes_1.instructionIdFromTxHash)(txHash);
|
|
const instrDisplay = `CHAIN138-${txHash.slice(2, 34)}`;
|
|
const e2e = `E2E-${txHash.slice(2, 18)}`;
|
|
const uetr = (0, hashes_1.uetrFromTxHash)(txHash);
|
|
const usd = leaf.totalTransfersUsd ?? leaf.valueUsd ?? leaf.nativeValueUsd ?? '0';
|
|
const currencyCode = leaf.tokenSymbol === 'ETH' || !leaf.token ? 'ETH' : 'USD';
|
|
const purpose = `Chain138 settlement batch attestation; native value ${ethers_1.ethers.formatEther(leaf.value)} ETH; USD ref ${usd}`;
|
|
const canonical = {
|
|
msgType: 'chain138.synthetic',
|
|
msgTypeCode: types_1.MSG_TYPE.CHAIN138_SYNTH,
|
|
instructionId: instrDisplay,
|
|
instructionIdBytes32: instrBytes32,
|
|
endToEndId: e2e,
|
|
endToEndIdHash: (0, hashes_1.hashShortUtf8)(e2e),
|
|
msgId: `MSG-${txHash.slice(2, 14)}`,
|
|
uetr,
|
|
uetrBytes32: (0, hashes_1.uetrBytes32FromTxHash)(txHash),
|
|
accountRefId: leaf.from,
|
|
counterpartyRefId: leaf.to,
|
|
debtorId: leaf.from,
|
|
creditorId: leaf.to,
|
|
purpose,
|
|
settlementMethod: 'CLRG',
|
|
categoryPurpose: 'CBFF',
|
|
currencyCode,
|
|
amountRaw: ethers_1.ethers.formatEther(leaf.value),
|
|
amountSmallestUnit: leaf.value.toString(),
|
|
tokenAddress: leaf.token,
|
|
debtorRefHash: (0, hashes_1.hashShortUtf8)(`${leaf.from}|${leaf.from}`),
|
|
creditorRefHash: (0, hashes_1.hashShortUtf8)(`${leaf.to}|${leaf.to}`),
|
|
purposeHash: (0, hashes_1.hashShortUtf8)(purpose),
|
|
chain138TxHash: txHash,
|
|
valueDateIso: new Date(leaf.blockTimestamp * 1000).toISOString().slice(0, 10),
|
|
};
|
|
const payloadHash = ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(JSON.stringify({
|
|
...canonical,
|
|
blockNumber: leaf.blockNumber,
|
|
blockTimestamp: leaf.blockTimestamp,
|
|
receiptHash: leaf.receiptHash ?? null,
|
|
logCount: leaf.logCount ?? 0,
|
|
})));
|
|
return { ...canonical, payloadHash };
|
|
}
|
|
/** Minimal pacs.008.001 XML for OMNL store / audit (not full MX validation). */
|
|
function canonicalToPacs008Xml(c) {
|
|
const cre = new Date().toISOString();
|
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.08">
|
|
<FIToFICstmrCdtTrf>
|
|
<GrpHdr>
|
|
<MsgId>${escapeXml(c.msgId)}</MsgId>
|
|
<CreDtTm>${escapeXml(cre)}</CreDtTm>
|
|
<NbOfTxs>1</NbOfTxs>
|
|
</GrpHdr>
|
|
<CdtTrfTxInf>
|
|
<PmtId>
|
|
<InstrId>${escapeXml(c.instructionId)}</InstrId>
|
|
<EndToEndId>${escapeXml(c.endToEndId)}</EndToEndId>
|
|
<TxId>${escapeXml(c.chain138TxHash)}</TxId>
|
|
</PmtId>
|
|
<IntrBkSttlmAmt Ccy="${escapeXml(c.currencyCode)}">${escapeXml(c.amountRaw)}</IntrBkSttlmAmt>
|
|
<Dbtr><Nm>${escapeXml(c.debtorId)}</Nm></Dbtr>
|
|
<DbtrAcct><Id><Othr><Id>${escapeXml(c.accountRefId)}</Id></Othr></Id></DbtrAcct>
|
|
<Cdtr><Nm>${escapeXml(c.creditorId)}</Nm></Cdtr>
|
|
<CdtrAcct><Id><Othr><Id>${escapeXml(c.counterpartyRefId)}</Id></Othr></Id></CdtrAcct>
|
|
<RmtInf><Ustrd>${escapeXml(c.purpose)}</Ustrd></RmtInf>
|
|
<SplmtryData>
|
|
<PlcAndNm>Chain138Attestation</PlcAndNm>
|
|
<Envlp>
|
|
<UETR>${escapeXml(c.uetr)}</UETR>
|
|
<PayloadHash>${escapeXml(c.payloadHash)}</PayloadHash>
|
|
<MsgTypeCode>${c.msgTypeCode}</MsgTypeCode>
|
|
</Envlp>
|
|
</SplmtryData>
|
|
</CdtTrfTxInf>
|
|
</FIToFICstmrCdtTrf>
|
|
</Document>`;
|
|
}
|
|
function escapeXml(s) {
|
|
return s
|
|
.replace(/&/g, '&')
|
|
.replace(/</g, '<')
|
|
.replace(/>/g, '>')
|
|
.replace(/"/g, '"');
|
|
}
|