@rhea-finance/cross-chain-aggregation-dex 2.1.6 → 2.1.7
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/executors/aptos.d.mts +1 -1
- package/dist/executors/aptos.d.ts +1 -1
- package/dist/executors/bitcoin.d.mts +1 -1
- package/dist/executors/bitcoin.d.ts +1 -1
- package/dist/executors/evm.d.mts +1 -1
- package/dist/executors/evm.d.ts +1 -1
- package/dist/executors/near.d.mts +1 -1
- package/dist/executors/near.d.ts +1 -1
- package/dist/executors/solana.d.mts +1 -1
- package/dist/executors/solana.d.ts +1 -1
- package/dist/executors/sui.d.mts +1 -1
- package/dist/executors/sui.d.ts +1 -1
- package/dist/executors/tron.d.mts +8 -2
- package/dist/executors/tron.d.ts +8 -2
- package/dist/executors/tron.js +155 -39
- package/dist/executors/tron.js.map +1 -1
- package/dist/executors/tron.mjs +155 -39
- package/dist/executors/tron.mjs.map +1 -1
- package/dist/executors/zcash.d.mts +1 -1
- package/dist/executors/zcash.d.ts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +92 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -13
- package/dist/index.mjs.map +1 -1
- package/dist/{shared-DpC8G2U4.d.mts → shared-v1w63b8X.d.mts} +20 -1
- package/dist/{shared-DpC8G2U4.d.ts → shared-v1w63b8X.d.ts} +20 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -653,10 +653,23 @@ var transferBaseSchema = z.object({
|
|
|
653
653
|
amount: decimalStringSchema,
|
|
654
654
|
depositAddress: nonEmptyStringSchema
|
|
655
655
|
});
|
|
656
|
-
var
|
|
656
|
+
var tronTransferSchema = transferBaseSchema.extend({
|
|
657
657
|
tokenAddress: z.string().optional(),
|
|
658
658
|
standard: z.string().optional()
|
|
659
659
|
});
|
|
660
|
+
var tronUnsignedTxSchema = z.object({
|
|
661
|
+
txID: nonEmptyStringSchema,
|
|
662
|
+
raw_data: z.record(z.string(), z.unknown()),
|
|
663
|
+
raw_data_hex: nonEmptyStringSchema,
|
|
664
|
+
visible: z.boolean().optional()
|
|
665
|
+
}).passthrough();
|
|
666
|
+
var tronRawDataTxSchema = tronUnsignedTxSchema.extend({
|
|
667
|
+
format: z.string().optional(),
|
|
668
|
+
approveTxID: z.string().optional(),
|
|
669
|
+
approve_raw_data: z.record(z.string(), z.unknown()).optional(),
|
|
670
|
+
approve_raw_data_hex: z.string().optional(),
|
|
671
|
+
approveVisible: z.boolean().optional()
|
|
672
|
+
}).passthrough();
|
|
660
673
|
var bitcoinTxSchema = transferBaseSchema.extend({
|
|
661
674
|
feeRate: z.number().positive().optional()
|
|
662
675
|
});
|
|
@@ -739,18 +752,8 @@ function normalizeExecution(raw, lane, chain) {
|
|
|
739
752
|
transactions: Array.isArray(transactions) ? transactions : [transactions]
|
|
740
753
|
};
|
|
741
754
|
}
|
|
742
|
-
case "tron":
|
|
743
|
-
|
|
744
|
-
assertKind(tx.kind, ["tron_transfer"]);
|
|
745
|
-
return {
|
|
746
|
-
kind: "tron-transfer",
|
|
747
|
-
chain,
|
|
748
|
-
amount: tx.amount,
|
|
749
|
-
depositAddress: tx.depositAddress,
|
|
750
|
-
...tx.tokenAddress ? { tokenAddress: tx.tokenAddress } : {},
|
|
751
|
-
...tx.standard ? { standard: tx.standard } : {}
|
|
752
|
-
};
|
|
753
|
-
}
|
|
755
|
+
case "tron":
|
|
756
|
+
return normalizeTronExecution(raw, chain);
|
|
754
757
|
case "bitcoin": {
|
|
755
758
|
const tx = bitcoinTxSchema.parse(raw.tx);
|
|
756
759
|
assertKind(tx.kind, ["btc_transfer", "utxo_transfer"]);
|
|
@@ -822,6 +825,82 @@ function normalizeEvmApproval(raw, chain) {
|
|
|
822
825
|
}
|
|
823
826
|
return void 0;
|
|
824
827
|
}
|
|
828
|
+
function normalizeTronExecution(raw, chain) {
|
|
829
|
+
if (isTronRawDataTx(raw.tx)) {
|
|
830
|
+
const tx2 = tronRawDataTxSchema.parse(raw.tx);
|
|
831
|
+
const transaction = toTronUnsignedTransaction(tx2);
|
|
832
|
+
const approval = normalizeTronApproval(tx2, raw);
|
|
833
|
+
return {
|
|
834
|
+
kind: "tron-transaction",
|
|
835
|
+
chain,
|
|
836
|
+
format: normalizeTronFormat(tx2.format),
|
|
837
|
+
transaction,
|
|
838
|
+
...approval ? { approval } : {}
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
const tx = tronTransferSchema.parse(raw.tx);
|
|
842
|
+
assertKind(tx.kind, ["tron_transfer"]);
|
|
843
|
+
return {
|
|
844
|
+
kind: "tron-transfer",
|
|
845
|
+
chain,
|
|
846
|
+
amount: tx.amount,
|
|
847
|
+
depositAddress: tx.depositAddress,
|
|
848
|
+
...tx.tokenAddress ? { tokenAddress: tx.tokenAddress } : {},
|
|
849
|
+
...tx.standard ? { standard: tx.standard } : {}
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
function isTronRawDataTx(value) {
|
|
853
|
+
if (typeof value !== "object" || value === null) return false;
|
|
854
|
+
const format = Reflect.get(value, "format");
|
|
855
|
+
if (typeof format === "string" && format.toLowerCase() === "tron-raw-data") {
|
|
856
|
+
return true;
|
|
857
|
+
}
|
|
858
|
+
return typeof Reflect.get(value, "txID") === "string" && typeof Reflect.get(value, "raw_data_hex") === "string" && typeof Reflect.get(value, "raw_data") === "object" && Reflect.get(value, "raw_data") !== null;
|
|
859
|
+
}
|
|
860
|
+
function normalizeTronFormat(format) {
|
|
861
|
+
const normalized = format?.trim();
|
|
862
|
+
return normalized && normalized.length > 0 ? normalized : "tron-raw-data";
|
|
863
|
+
}
|
|
864
|
+
function toTronUnsignedTransaction(value) {
|
|
865
|
+
const {
|
|
866
|
+
txID,
|
|
867
|
+
raw_data,
|
|
868
|
+
raw_data_hex,
|
|
869
|
+
visible,
|
|
870
|
+
format: _format,
|
|
871
|
+
approveTxID: _approveTxID,
|
|
872
|
+
approve_raw_data: _approveRawData,
|
|
873
|
+
approve_raw_data_hex: _approveRawDataHex,
|
|
874
|
+
approveVisible: _approveVisible,
|
|
875
|
+
approve_payload: _approvePayload,
|
|
876
|
+
approveTxId: _approveTxId,
|
|
877
|
+
...rest
|
|
878
|
+
} = value;
|
|
879
|
+
return {
|
|
880
|
+
...rest,
|
|
881
|
+
txID,
|
|
882
|
+
raw_data,
|
|
883
|
+
raw_data_hex,
|
|
884
|
+
...visible === void 0 ? {} : { visible }
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
function normalizeTronApproval(tx, raw) {
|
|
888
|
+
if (typeof tx.approveTxID === "string" && tx.approveTxID.trim() && tx.approve_raw_data && typeof tx.approve_raw_data_hex === "string" && tx.approve_raw_data_hex.trim()) {
|
|
889
|
+
return {
|
|
890
|
+
transaction: {
|
|
891
|
+
txID: tx.approveTxID.trim(),
|
|
892
|
+
raw_data: tx.approve_raw_data,
|
|
893
|
+
raw_data_hex: tx.approve_raw_data_hex.trim(),
|
|
894
|
+
visible: tx.approveVisible ?? false
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
if (raw.approve?.tx && isTronRawDataTx(raw.approve.tx)) {
|
|
899
|
+
const approveTx = tronUnsignedTxSchema.parse(raw.approve.tx);
|
|
900
|
+
return { transaction: toTronUnsignedTransaction(approveTx) };
|
|
901
|
+
}
|
|
902
|
+
return void 0;
|
|
903
|
+
}
|
|
825
904
|
function readErc20ApproveSpender(data) {
|
|
826
905
|
const normalized = data.toLowerCase();
|
|
827
906
|
if (!normalized.startsWith("0x095ea7b3") || normalized.length < 10 + 64) {
|