@magnaflow/merchant-utils 1.0.2 → 1.0.3

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.
@@ -1,4 +1,4 @@
1
- import type { PayoutOrderType } from '@/types/merchant';
1
+ import type { PayoutOrderType } from './types/merchant';
2
2
  /**
3
3
  * Check if the chain is Tron-like
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"tron.d.ts","sourceRoot":"","sources":["../src/tron.ts"],"names":[],"mappings":"AAkDA;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE;QACR,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IACF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,sCAAsC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mCAAmC;IACnC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mCAAmC;IACnC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CAC7C;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,sBAAsB,CAAC,CAkFjC;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,GAAG,EACZ,MAAM,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;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,sBAAsB,CAAC,CAkFjC;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,sBAAsB,CAAC,CA0HjC;AAED,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IACP,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,mCAAmC;IACnC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mCAAmC;IACnC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CACxC,gBAoDP"}
package/dist/tron.js CHANGED
@@ -40,6 +40,9 @@ function parseContractError(contractResult) {
40
40
  }
41
41
  return 'Unable to parse error information';
42
42
  }
43
+ function isTronTransactionSuccessful(transactionReceipt) {
44
+ return transactionReceipt?.receipt?.result === 'SUCCESS';
45
+ }
43
46
  /**
44
47
  * Poll Tron transaction status, wait for transaction confirmation
45
48
  * @param tronWeb TronWeb instance
@@ -73,7 +76,7 @@ export async function pollTronTransaction(tronWeb, txHash, options = {}) {
73
76
  throw new Error(timeoutMessage);
74
77
  }
75
78
  const contractRet = transactionReceipt?.receipt;
76
- const isSuccess = Boolean(contractRet && transactionReceipt?.blockNumber);
79
+ const isSuccess = isTronTransactionSuccessful(transactionReceipt);
77
80
  if (throwOnFailure && !isSuccess) {
78
81
  let errorDetails = '';
79
82
  let parsedError = '';
@@ -176,7 +179,7 @@ export async function pollTronTransaction2(tronWeb, txHash, options = {}) {
176
179
  throw new Error(timeoutMessage);
177
180
  }
178
181
  const contractRet = transactionReceipt?.receipt;
179
- const isSuccess = Boolean(contractRet && transactionReceipt?.blockNumber);
182
+ const isSuccess = isTronTransactionSuccessful(transactionReceipt);
180
183
  if (throwOnFailure && !isSuccess) {
181
184
  let errorDetails = '';
182
185
  let parsedError = '';
@@ -241,10 +244,10 @@ export async function pollTronTransactionWithBackoff(tronWeb, txHash, options =
241
244
  }
242
245
  const info = await tronWeb.trx.getTransactionInfo(txHash);
243
246
  if (info?.blockNumber) {
244
- if (info.receipt) {
247
+ if (isTronTransactionSuccessful(info)) {
245
248
  return info;
246
249
  }
247
- // explicit failure (REVERT / OUT_OF_ENERGY / etc)
250
+ // explicit failure (REVERT / OUT_OF_ENERGY / missing SUCCESS result)
248
251
  throw new Error(failureMessage(txHash));
249
252
  }
250
253
  // convergent backoff (e.g. 10 → 8 → 6 → 4 → 3)
@@ -1,5 +1,5 @@
1
1
  import { TronWeb } from 'tronweb';
2
- import type { ChainConfig } from '@/types/merchant';
2
+ import type { ChainConfig } from './types/merchant';
3
3
  export interface CreateTronWebOptions {
4
4
  privateKey?: string;
5
5
  defaultAddress?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magnaflow/merchant-utils",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Merchant shared utilities",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",