zoa-wallet 0.3.2 → 0.3.4
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.mjs +50 -8
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -36072,17 +36072,35 @@ var BaseEVMAdapter = class {
|
|
|
36072
36072
|
});
|
|
36073
36073
|
}
|
|
36074
36074
|
async signAndSendNativeTransfer(params) {
|
|
36075
|
+
this.initClient();
|
|
36075
36076
|
const account = privateKeyToAccount(params.privateKey);
|
|
36077
|
+
const viemChain = this.getViemChain();
|
|
36078
|
+
const balance = await this.client.getBalance({ address: account.address });
|
|
36079
|
+
let sendValue = params.value;
|
|
36080
|
+
if (sendValue > 0n && sendValue >= balance) {
|
|
36081
|
+
try {
|
|
36082
|
+
const feeData = await this.client.estimateFeesPerGas();
|
|
36083
|
+
const maxFeePerGas = feeData.maxFeePerGas ?? 0n;
|
|
36084
|
+
const gasCost = 21000n * maxFeePerGas;
|
|
36085
|
+
if (balance <= gasCost) {
|
|
36086
|
+
throw new Error(`Insufficient balance. You have ${formatEther(balance)} ${this.config.nativeCurrency.symbol} which is not enough to cover gas fees.`);
|
|
36087
|
+
}
|
|
36088
|
+
sendValue = balance - gasCost;
|
|
36089
|
+
} catch (err3) {
|
|
36090
|
+
if (err3 instanceof Error && err3.message.includes("Insufficient balance"))
|
|
36091
|
+
throw err3;
|
|
36092
|
+
}
|
|
36093
|
+
}
|
|
36076
36094
|
const walletClient = createWalletClient({
|
|
36077
36095
|
account,
|
|
36078
|
-
chain:
|
|
36096
|
+
chain: viemChain,
|
|
36079
36097
|
transport: http(this.config.rpcUrls[0])
|
|
36080
36098
|
});
|
|
36081
36099
|
const hash3 = await walletClient.sendTransaction({
|
|
36082
36100
|
account,
|
|
36083
36101
|
to: params.to,
|
|
36084
|
-
value:
|
|
36085
|
-
chain:
|
|
36102
|
+
value: sendValue,
|
|
36103
|
+
chain: viemChain
|
|
36086
36104
|
});
|
|
36087
36105
|
return { hash: hash3 };
|
|
36088
36106
|
}
|
|
@@ -47983,13 +48001,33 @@ var SolanaAdapter = class {
|
|
|
47983
48001
|
async signAndSendNativeTransfer(params) {
|
|
47984
48002
|
const secretBytes = Uint8Array.from((params.privateKey.startsWith("0x") ? params.privateKey.slice(2) : params.privateKey).match(/.{1,2}/g).map((byte) => Number.parseInt(byte, 16)));
|
|
47985
48003
|
const keypair = Keypair.fromSecretKey(secretBytes);
|
|
48004
|
+
const balance = await this.connection.getBalance(keypair.publicKey);
|
|
48005
|
+
let lamports = Number(params.value);
|
|
48006
|
+
const estimatedFee = 5e3;
|
|
48007
|
+
if (balance < estimatedFee + 1) {
|
|
48008
|
+
throw new Error(`Insufficient SOL balance. You have ${(balance / LAMPORTS_PER_SOL).toFixed(6)} SOL which is not enough to cover the transaction fee.`);
|
|
48009
|
+
}
|
|
48010
|
+
if (lamports + estimatedFee > balance) {
|
|
48011
|
+
lamports = balance - estimatedFee;
|
|
48012
|
+
}
|
|
47986
48013
|
const transaction = new Transaction().add(SystemProgram.transfer({
|
|
47987
48014
|
fromPubkey: keypair.publicKey,
|
|
47988
48015
|
toPubkey: new PublicKey(params.to),
|
|
47989
|
-
lamports
|
|
48016
|
+
lamports
|
|
47990
48017
|
}));
|
|
47991
|
-
|
|
47992
|
-
|
|
48018
|
+
try {
|
|
48019
|
+
const signature = await sendAndConfirmTransaction(this.connection, transaction, [keypair], { commitment: "confirmed" });
|
|
48020
|
+
return { hash: signature };
|
|
48021
|
+
} catch (error) {
|
|
48022
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
48023
|
+
if (msg.includes("Simulation failed")) {
|
|
48024
|
+
throw new Error(`Transaction simulation failed. This usually means insufficient balance to cover the transfer amount plus network fees (~0.000005 SOL).`);
|
|
48025
|
+
}
|
|
48026
|
+
if (msg.includes("blockhash")) {
|
|
48027
|
+
throw new Error("Transaction expired. The network may be congested \u2014 please try again.");
|
|
48028
|
+
}
|
|
48029
|
+
throw error;
|
|
48030
|
+
}
|
|
47993
48031
|
}
|
|
47994
48032
|
async getTransactionReceipt(_hash) {
|
|
47995
48033
|
return null;
|
|
@@ -49959,6 +49997,10 @@ function registerSendCommand(program2) {
|
|
|
49959
49997
|
} else {
|
|
49960
49998
|
lines.push(kvLine("Service Fee", colors.success("FREE")));
|
|
49961
49999
|
}
|
|
50000
|
+
if (isNativeTransfer && value === selectedToken.balance) {
|
|
50001
|
+
lines.push("");
|
|
50002
|
+
lines.push(colors.warning(" \u26A0 Sending entire balance \u2014 some will be reserved for gas fees."));
|
|
50003
|
+
}
|
|
49962
50004
|
console.log();
|
|
49963
50005
|
console.log(infoBox("Transaction Details", lines));
|
|
49964
50006
|
console.log();
|
|
@@ -50554,7 +50596,7 @@ var zoaGradient2 = gradient2([
|
|
|
50554
50596
|
"#c77dff"
|
|
50555
50597
|
]);
|
|
50556
50598
|
var subtleGradient = gradient2(["#6b7280", "#9ca3af", "#6b7280"]);
|
|
50557
|
-
var VERSION = "0.3.
|
|
50599
|
+
var VERSION = "0.3.4";
|
|
50558
50600
|
async function displayBanner() {
|
|
50559
50601
|
const banner = figlet.textSync("ZOA-wallet", { font: "ANSI Shadow" });
|
|
50560
50602
|
console.log();
|
|
@@ -50592,7 +50634,7 @@ program.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
50592
50634
|
}
|
|
50593
50635
|
}
|
|
50594
50636
|
});
|
|
50595
|
-
program.name("zoa").description("ZOA Wallet \u2014 API-First Crypto Wallet for Power-traders, Developers, & AI Agents").version("0.3.
|
|
50637
|
+
program.name("zoa").description("ZOA Wallet \u2014 API-First Crypto Wallet for Power-traders, Developers, & AI Agents").version("0.3.4");
|
|
50596
50638
|
registerWalletCommand(program);
|
|
50597
50639
|
registerBalanceCommand(program);
|
|
50598
50640
|
registerSendCommand(program);
|
package/package.json
CHANGED