@magnaflow/merchant-utils 1.0.1 → 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.
- package/LICENSE +21 -0
- package/README.md +3 -1
- package/dist/payout-order-utils.d.ts +1 -1
- package/dist/tron.d.ts.map +1 -1
- package/dist/tron.js +7 -4
- package/dist/tronweb-manager.d.ts +1 -1
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MagnaFlow Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
package/dist/tron.d.ts.map
CHANGED
|
@@ -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;
|
|
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;AAQD;;;;;;;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 =
|
|
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 =
|
|
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
|
|
247
|
+
if (isTronTransactionSuccessful(info)) {
|
|
245
248
|
return info;
|
|
246
249
|
}
|
|
247
|
-
// explicit failure (REVERT / OUT_OF_ENERGY /
|
|
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)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magnaflow/merchant-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Merchant shared utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"tron",
|
|
32
32
|
"evm"
|
|
33
33
|
],
|
|
34
|
-
"author": "",
|
|
34
|
+
"author": "MagnaFlow Labs",
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|