Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion sdk/localsdk/multichain/configs/chainProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,10 @@ export const chainProviders = {
testnet: "https://fullnode.testnet.aptoslabs.com/v1",
devnet: "https://fullnode.devnet.aptoslabs.com/v1",
},
}
tron: {
mainnet: "https://api.trongrid.io",
testnet: "https://api.shasta.trongrid.io",
shasta: "https://api.shasta.trongrid.io",
nile: "https://nile.trongrid.io",
},
}
4 changes: 4 additions & 0 deletions src/features/multichain/routines/executors/pay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export default async function handlePayOperation(
result = await handleAptosPayRest(operation)
break

case "tron":
result = await genericJsonRpcPay(multichain.TRON, rpcUrl, operation)
break

default:
result = {
result: "error",
Expand Down
9 changes: 6 additions & 3 deletions src/libs/blockchain/gcr/gcr_routines/identityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
NEAR,
SOLANA,
TON,
TRON,
XRPL,
BTC,
} from "@kynesyslabs/demosdk/xm-localsdk"
Expand Down Expand Up @@ -42,6 +43,7 @@ const chains: { [key: string]: typeof DefaultChain } = {
evm: EVM,
egld: MULTIVERSX,
ton: TON,
tron: TRON,
xrpl: XRPL,
ibc: IBC,
atom: IBC,
Expand Down Expand Up @@ -141,9 +143,10 @@ export default class IdentityManager {
// }
// }

// SECTION: SOLANA Checks
// INFO: Check if the subchain is mainnet
if (chain === "solana" && subchain !== "mainnet") {
// SECTION: Mainnet-only chain checks
// INFO: Some chains only support mainnet for identity management
const mainnetOnlyChains = ["solana", "tron"]
if (mainnetOnlyChains.includes(chain) && subchain !== "mainnet") {
return {
...response,
message: "Failed: Testnet addresses are not supported",
Expand Down
6 changes: 6 additions & 0 deletions src/utilities/validateUint8Array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export default function validateIfUint8Array(input: unknown): Uint8Array | unkno

// Type guard: check if input is a record-like object with numeric integer keys and number values
if (typeof input === "object" && input !== null) {
// Skip conversion for transaction objects that are not meant to be Uint8Arrays
const isSerializedTx = 'signature' in input && 'txID' in input && 'raw_data' in input
if (isSerializedTx) {
return input
}
Comment on lines +20 to +24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Make the transaction object detection more explicit and robust.

The current guard uses duck typing to identify serialized transaction objects, which is fragile and could match unintended objects. Consider:

  1. The check doesn't validate that the properties have the expected types
  2. There's no documentation indicating this is TRON-specific
  3. Other chains might have similar property names, causing false positives
🔎 Proposed improvements
-        // Skip conversion for transaction objects that are not meant to be Uint8Arrays
-        const isSerializedTx = 'signature' in input && 'txID' in input && 'raw_data' in input
-        if (isSerializedTx) {
-            return input
-        }
+        // Skip conversion for TRON serialized transaction objects
+        // TRON transactions contain signature (array), txID (string), and raw_data (object)
+        const isTronSerializedTx = 
+            'signature' in input && 
+            'txID' in input && 
+            'raw_data' in input &&
+            Array.isArray((input as any).signature) &&
+            typeof (input as any).txID === 'string' &&
+            typeof (input as any).raw_data === 'object'
+        if (isTronSerializedTx) {
+            return input
+        }

This adds:

  • Explicit documentation that this is for TRON transactions
  • Type validation for the three properties to reduce false positives
  • Clear intent for future maintainers
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Skip conversion for transaction objects that are not meant to be Uint8Arrays
const isSerializedTx = 'signature' in input && 'txID' in input && 'raw_data' in input
if (isSerializedTx) {
return input
}
// Skip conversion for TRON serialized transaction objects
// TRON transactions contain signature (array), txID (string), and raw_data (object)
const isTronSerializedTx =
'signature' in input &&
'txID' in input &&
'raw_data' in input &&
Array.isArray((input as any).signature) &&
typeof (input as any).txID === 'string' &&
typeof (input as any).raw_data === 'object'
if (isTronSerializedTx) {
return input
}
🤖 Prompt for AI Agents
In @src/utilities/validateUint8Array.ts around lines 20-24, The duck-typing
guard in validateUint8Array.ts (the isSerializedTx check inside the function
handling input) is too fragile; update it to explicitly document that it targets
TRON serialized transaction objects and strengthen it by validating types for
'signature' (e.g., Array or Uint8Array), 'txID' (string), and 'raw_data'
(object) rather than just checking property presence, so the function only
returns input when it confidently matches a TRON tx and avoids false positives
for other chains.


// Safely cast to indexable type after basic validation
const record = input as Record<string, unknown>
const entries = Object.entries(record)
Expand Down