sdk-triggerx 0.1.32 → 0.1.34

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.
package/dist/api/jobs.js CHANGED
@@ -423,6 +423,8 @@ async function createJob(client, params) {
423
423
  noOfExecutions = Math.max(1, Math.floor(jobInput.timeFrame / customInterval));
424
424
  }
425
425
  }
426
+ let requiredETH;
427
+ let maxtotalFeeRaw;
426
428
  // Prepare parameters for /api/fees
427
429
  const ipfs_url = jobInput.dynamicArgumentsScriptUrl || '';
428
430
  const task_definition_id = jobType; // use inferred jobType as task definition id
@@ -446,12 +448,13 @@ async function createJob(client, params) {
446
448
  });
447
449
  // The API returns total fee in wei: { total_fee: "<wei>" } or nested under data
448
450
  let totalFeeRaw;
449
- if (feeRes && feeRes.total_fee !== undefined) {
450
- totalFeeRaw = feeRes.total_fee;
451
+ if (feeRes && feeRes.current_total_fee !== undefined) {
452
+ totalFeeRaw = feeRes.current_total_fee;
451
453
  }
452
- else if (feeRes && feeRes.data && feeRes.data.total_fee !== undefined) {
453
- totalFeeRaw = feeRes.data.total_fee;
454
+ else if (feeRes && feeRes.data && feeRes.data.current_total_fee !== undefined) {
455
+ totalFeeRaw = feeRes.data.current_total_fee;
454
456
  }
457
+ maxtotalFeeRaw = feeRes.total_fee;
455
458
  if (totalFeeRaw === undefined) {
456
459
  return (0, errors_1.createErrorResponse)(new errors_1.ApiError('Invalid response from /api/fees: missing total_fee', { response: feeRes }), 'API error');
457
460
  }
@@ -507,7 +510,9 @@ async function createJob(client, params) {
507
510
  }
508
511
  else {
509
512
  // autotopupETH is true, automatically top up
510
- const requiredETH = requiredETHwei;
513
+ // Calculate requiredETH as 1.2x the predicted job cost (in wei) using bigint math to avoid precision loss,
514
+ // ensuring requiredETH is returned in the JobResponse (see types.ts).
515
+ requiredETH = (requiredETHwei * 12n) / 10n; // 1.2x in bigint
511
516
  try {
512
517
  const topupResult = await (0, topup_1.depositEth)(requiredETHwei, signer);
513
518
  if (!topupResult.success) {
@@ -567,6 +572,8 @@ async function createJob(client, params) {
567
572
  const res = await client.post('/api/jobs', [jobDataForApi], {
568
573
  headers: { 'Content-Type': 'application/json', 'X-API-KEY': apiKey },
569
574
  });
575
+ res.requiredETH = requiredETH;
576
+ res.maxtotalFeeRaw = maxtotalFeeRaw;
570
577
  return { success: true, data: res };
571
578
  }
572
579
  catch (error) {
package/dist/config.js CHANGED
@@ -53,6 +53,8 @@ exports.CONTRACT_ADDRESSES_BY_CHAIN = {
53
53
  '42161': {
54
54
  gasRegistry: '0xe2AC670F7D66c69D547A44D08F9bA1Fc0Fc0f991',
55
55
  jobRegistry: '0xAf1189aFd1F1880F09AeC3Cbc32cf415c735C710',
56
+ safeFactory: '0x93528Df5984231059Cf5c5f2CE9b85c59250D096',
57
+ safeModule: '0x100656372C821539651f5905Ca39b7C95f9AA433',
56
58
  multisendCallOnly: '0x9641d764fc13c8B624c04430C7356C1C7C8102e2',
57
59
  rpcUrl: 'https://arb1.arbitrum.io/rpc',
58
60
  },
package/dist/types.d.ts CHANGED
@@ -218,6 +218,8 @@ export interface CreateJobData {
218
218
  export interface JobResponse {
219
219
  success: boolean;
220
220
  data?: any;
221
+ requiredETH?: bigint;
222
+ maxtotalFeeRaw?: bigint;
221
223
  error?: string;
222
224
  errorCode?: ApiErrorCode;
223
225
  httpStatusCode?: HttpStatusCode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdk-triggerx",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "SDK for interacting with the TriggerX backend and smart contracts.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",