@hardkas/kaspa-rpc 0.6.1-alpha → 0.7.0-alpha
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/index.js +17 -14
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -765,7 +765,7 @@ var JsonWrpcKaspaClient = class {
|
|
|
765
765
|
try {
|
|
766
766
|
const dagResponse = await this.safeRequest(["getBlockDagInfo", "getBlockDagInfoRequest", "GetBlockDagInfo", "get_block_dag_info"]);
|
|
767
767
|
const dagData = dagResponse?.params || dagResponse;
|
|
768
|
-
if (dagData
|
|
768
|
+
if (dagData && typeof dagData === "object" && "virtualDaaScore" in dagData) {
|
|
769
769
|
info.virtualDaaScore = BigInt(dagData.virtualDaaScore);
|
|
770
770
|
}
|
|
771
771
|
} catch (e) {
|
|
@@ -819,9 +819,10 @@ var JsonWrpcKaspaClient = class {
|
|
|
819
819
|
{ txId, transactionId: txId }
|
|
820
820
|
);
|
|
821
821
|
if (!response) return null;
|
|
822
|
+
const resObj = response;
|
|
822
823
|
return {
|
|
823
824
|
txId,
|
|
824
|
-
acceptedAt:
|
|
825
|
+
acceptedAt: resObj.acceptedAt || resObj.accepted_at
|
|
825
826
|
};
|
|
826
827
|
} catch (e) {
|
|
827
828
|
return null;
|
|
@@ -870,16 +871,17 @@ var JsonWrpcKaspaClient = class {
|
|
|
870
871
|
try {
|
|
871
872
|
let actualParams = params;
|
|
872
873
|
const lowerMethod = method.toLowerCase();
|
|
874
|
+
const pObj = params;
|
|
873
875
|
if (lowerMethod.includes("addresses") || lowerMethod.endsWith("s")) {
|
|
874
|
-
if (
|
|
875
|
-
actualParams = { addresses: [
|
|
876
|
-
} else if (
|
|
877
|
-
actualParams = { addresses:
|
|
876
|
+
if (pObj.address && !pObj.addresses) {
|
|
877
|
+
actualParams = { addresses: [pObj.address] };
|
|
878
|
+
} else if (pObj.addresses) {
|
|
879
|
+
actualParams = { addresses: pObj.addresses };
|
|
878
880
|
}
|
|
879
|
-
} else if (
|
|
880
|
-
actualParams = { address:
|
|
881
|
-
} else if (
|
|
882
|
-
actualParams = { address:
|
|
881
|
+
} else if (pObj.addresses && !pObj.address) {
|
|
882
|
+
actualParams = { address: pObj.addresses[0] };
|
|
883
|
+
} else if (pObj.address) {
|
|
884
|
+
actualParams = { address: pObj.address };
|
|
883
885
|
}
|
|
884
886
|
try {
|
|
885
887
|
return await this.request(method, actualParams);
|
|
@@ -1017,19 +1019,20 @@ function mapKaspaRpcUtxos(result, address) {
|
|
|
1017
1019
|
entries = result.entries || result.utxos || result;
|
|
1018
1020
|
}
|
|
1019
1021
|
if (!Array.isArray(entries)) return [];
|
|
1020
|
-
return entries.map((
|
|
1022
|
+
return entries.map((entryRaw) => {
|
|
1023
|
+
const entry = entryRaw;
|
|
1021
1024
|
const utxoEntry = entry.utxoEntry || entry.utxo_entry || entry.utxo || entry;
|
|
1022
1025
|
const outpoint = entry.outpoint || entry;
|
|
1023
1026
|
return {
|
|
1024
1027
|
outpoint: {
|
|
1025
|
-
transactionId: outpoint.transactionId || outpoint.transaction_id || outpoint.txId || outpoint.tx_id || outpoint.transaction_hash || "",
|
|
1028
|
+
transactionId: String(outpoint.transactionId || outpoint.transaction_id || outpoint.txId || outpoint.tx_id || outpoint.transaction_hash || ""),
|
|
1026
1029
|
index: Number(outpoint.index !== void 0 ? outpoint.index : outpoint.outputIndex !== void 0 ? outpoint.outputIndex : outpoint.output_index)
|
|
1027
1030
|
},
|
|
1028
1031
|
address: entry.address || address,
|
|
1029
1032
|
amountSompi: BigInt(utxoEntry.amount || utxoEntry.amountSompi || utxoEntry.amount_sompi || 0),
|
|
1030
|
-
scriptPublicKey: utxoEntry.scriptPublicKey || utxoEntry.script_public_key,
|
|
1033
|
+
scriptPublicKey: String(utxoEntry.scriptPublicKey || utxoEntry.script_public_key || ""),
|
|
1031
1034
|
blockDaaScore: utxoEntry.blockDaaScore || utxoEntry.block_daa_score,
|
|
1032
|
-
isCoinbase: utxoEntry.isCoinbase || utxoEntry.is_coinbase,
|
|
1035
|
+
isCoinbase: Boolean(utxoEntry.isCoinbase || utxoEntry.is_coinbase),
|
|
1033
1036
|
raw: entry
|
|
1034
1037
|
};
|
|
1035
1038
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hardkas/kaspa-rpc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-alpha",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"ws": "^8.18.0",
|
|
12
|
-
"@hardkas/core": "0.
|
|
13
|
-
"@hardkas/tx-builder": "0.
|
|
12
|
+
"@hardkas/core": "0.7.0-alpha",
|
|
13
|
+
"@hardkas/tx-builder": "0.7.0-alpha"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/ws": "^8.5.13",
|