@lawrenceliang-btc/atel-sdk 1.1.39 → 1.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/atel.mjs +20 -12
  2. package/package.json +1 -1
package/bin/atel.mjs CHANGED
@@ -3642,15 +3642,22 @@ Format:
3642
3642
  // When executor receives the final milestone_verified for a fast-coop order,
3643
3643
  // sign and submit Escrow::Submit on Fast staging so the Platform can Complete.
3644
3644
  if (event === 'milestone_verified' && payload.allComplete === true) {
3645
- const orderChain = payload.chain || body.chain || '';
3646
- const isExecutor = payload.executorDid === id.did || (payload.orderDescription && payload.requesterDid !== id.did);
3647
- if (orderChain === 'fast-coop' && isExecutor) {
3648
- const fastOrderId = body.orderId || payload.orderId || '';
3649
- log({ event: 'fast_submit_triggered', orderId: fastOrderId, chain: orderChain });
3650
- // Fire-and-forget: submit deliverable hash to Fast escrow
3651
- submitFastDeliverable(fastOrderId, id).catch(e => {
3652
- log({ event: 'fast_submit_error', orderId: fastOrderId, error: e.message });
3653
- });
3645
+ const fastOrderId = body.orderId || payload.orderId || '';
3646
+ if (fastOrderId) {
3647
+ // Payload may not include chain — fetch order to check
3648
+ try {
3649
+ const _resp = await fetch(`${PLATFORM_URL}/trade/v1/order/${fastOrderId}`, { signal: AbortSignal.timeout(10000) });
3650
+ const orderInfo = _resp.ok ? await _resp.json() : null;
3651
+ const orderChain = orderInfo?.chain || orderInfo?.Chain || '';
3652
+ if (orderChain === 'fast-coop') {
3653
+ log({ event: 'fast_submit_triggered', orderId: fastOrderId, chain: orderChain });
3654
+ submitFastDeliverable(fastOrderId, id).catch(e => {
3655
+ log({ event: 'fast_submit_error', orderId: fastOrderId, error: e.message });
3656
+ });
3657
+ }
3658
+ } catch (e) {
3659
+ log({ event: 'fast_submit_check_error', orderId: fastOrderId, error: e.message });
3660
+ }
3654
3661
  }
3655
3662
  }
3656
3663
 
@@ -8391,9 +8398,10 @@ async function cmdAliasRemove(args) {
8391
8398
  // private key (= Fast Ed25519 account key).
8392
8399
  async function submitFastDeliverable(orderId, identity) {
8393
8400
  try {
8394
- // 1. Get order info to find the escrow job_id
8395
- const orderInfo = await fetchOrderState(orderId);
8396
- if (!orderInfo) throw new Error('cannot fetch order');
8401
+ // 1. Get order info
8402
+ const orderResp = await fetch(`${PLATFORM_URL}/trade/v1/order/${orderId}`, { signal: AbortSignal.timeout(10000) });
8403
+ if (!orderResp.ok) throw new Error(`order fetch failed: ${orderResp.status}`);
8404
+ const orderInfo = await orderResp.json();
8397
8405
  const chain = orderInfo.chain || orderInfo.Chain || '';
8398
8406
  if (chain !== 'fast-coop') return;
8399
8407
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lawrenceliang-btc/atel-sdk",
3
- "version": "1.1.39",
3
+ "version": "1.1.41",
4
4
  "description": "ATEL Protocol SDK - Agent Trust & Exchange Layer",
5
5
  "repository": {
6
6
  "type": "git",