apow-cli 0.6.1 → 0.6.2

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.
@@ -125,18 +125,31 @@ async function getSplTokenBalance(publicKeyBase58, mintAddress) {
125
125
  const parsed = accounts.value[0].account.data.parsed;
126
126
  return parsed?.info?.tokenAmount?.uiAmount ?? 0;
127
127
  }
128
- /** Deserialize, sign, and submit a base64-encoded Solana transaction. */
129
- async function signAndSendTransaction(serializedTxBase64, keypair) {
130
- const { Connection, VersionedTransaction } = await Promise.resolve().then(() => __importStar(require("@solana/web3.js")));
128
+ /** Deserialize, sign, and submit a serialized Solana transaction (hex or base64). */
129
+ async function signAndSendTransaction(serializedTx, keypair) {
130
+ const { Connection, VersionedTransaction, Transaction } = await Promise.resolve().then(() => __importStar(require("@solana/web3.js")));
131
131
  const connection = new Connection(getSolanaRpcUrl(), "confirmed");
132
- const txBuffer = Buffer.from(serializedTxBase64, "base64");
133
- const tx = VersionedTransaction.deserialize(txBuffer);
134
- tx.sign([keypair]);
135
- const signature = await connection.sendTransaction(tx, {
136
- skipPreflight: false,
137
- preflightCommitment: "confirmed",
138
- });
132
+ // deBridge returns hex (0x...), other bridges may return base64
133
+ const txBuffer = serializedTx.startsWith("0x")
134
+ ? Buffer.from(serializedTx.slice(2), "hex")
135
+ : Buffer.from(serializedTx, "base64");
136
+ // Get fresh blockhash (deBridge-generated txs may have stale ones)
139
137
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
138
+ // Try versioned transaction first, fall back to legacy.
139
+ // Skip preflight: deBridge Jupiter routes may fail simulation but succeed on-chain.
140
+ let signature;
141
+ try {
142
+ const tx = VersionedTransaction.deserialize(txBuffer);
143
+ tx.message.recentBlockhash = blockhash;
144
+ tx.sign([keypair]);
145
+ signature = await connection.sendTransaction(tx, { skipPreflight: true });
146
+ }
147
+ catch {
148
+ const tx = Transaction.from(txBuffer);
149
+ tx.recentBlockhash = blockhash;
150
+ tx.sign(keypair);
151
+ signature = await connection.sendRawTransaction(tx.serialize(), { skipPreflight: true });
152
+ }
140
153
  await connection.confirmTransaction({ signature, blockhash, lastValidBlockHeight }, "confirmed");
141
154
  return signature;
142
155
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apow-cli",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Mine AGENT tokens on Base L2 with Agentic Proof of Work",
5
5
  "keywords": [
6
6
  "apow",