@vleap/warps-adapter-solana 0.1.0-beta.3 → 0.1.0-beta.5

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 CHANGED
@@ -54,10 +54,10 @@ var SolanaExplorerMap = {
54
54
  var ExplorerUrls = {
55
55
  ["solscan" /* Solscan */]: "https://solscan.io",
56
56
  ["solscan_mainnet" /* SolscanMainnet */]: "https://solscan.io",
57
- ["solscan_devnet" /* SolscanDevnet */]: "https://solscan.io/?cluster=devnet",
57
+ ["solscan_devnet" /* SolscanDevnet */]: "https://solscan.io",
58
58
  ["solana_explorer" /* SolanaExplorer */]: "https://explorer.solana.com",
59
59
  ["solana_explorer_mainnet" /* SolanaExplorerMainnet */]: "https://explorer.solana.com",
60
- ["solana_explorer_devnet" /* SolanaExplorerDevnet */]: "https://explorer.solana.com/?cluster=devnet"
60
+ ["solana_explorer_devnet" /* SolanaExplorerDevnet */]: "https://explorer.solana.com"
61
61
  };
62
62
  var SolanaExplorerNames = {
63
63
  mainnet: ["solscan_mainnet" /* SolscanMainnet */, "solana_explorer_mainnet" /* SolanaExplorerMainnet */],
@@ -741,12 +741,12 @@ var WarpSolanaExecutor = class {
741
741
  async createTransferTransaction(executable) {
742
742
  const userWallet = getWarpWalletAddressFromConfig2(this.config, executable.chain.name);
743
743
  if (!userWallet) throw new Error("WarpSolanaExecutor: createTransfer - user address not set");
744
+ if (!executable.destination) throw new Error("WarpSolanaExecutor: Destination address is required");
744
745
  let destinationPubkey;
745
746
  try {
746
- if (!executable.destination) throw new Error("WarpSolanaExecutor: Destination address is required");
747
747
  destinationPubkey = new PublicKey3(executable.destination);
748
- } catch {
749
- throw new Error(`WarpSolanaExecutor: Invalid destination address: ${executable.destination}`);
748
+ } catch (error) {
749
+ throw new Error("WarpSolanaExecutor: Invalid destination address");
750
750
  }
751
751
  if (executable.transfers && executable.transfers.length > 0) {
752
752
  return this.createTokenTransferTransaction(executable, userWallet, destinationPubkey);
@@ -754,13 +754,7 @@ var WarpSolanaExecutor = class {
754
754
  const fromPubkey = new PublicKey3(userWallet);
755
755
  const transaction = new Transaction();
756
756
  if (executable.value > 0n) {
757
- transaction.add(
758
- SystemProgram.transfer({
759
- fromPubkey,
760
- toPubkey: destinationPubkey,
761
- lamports: Number(executable.value)
762
- })
763
- );
757
+ transaction.add(SystemProgram.transfer({ fromPubkey, toPubkey: destinationPubkey, lamports: Number(executable.value) }));
764
758
  }
765
759
  if (executable.data) {
766
760
  const data = this.serializer.stringToTyped(executable.data);
@@ -784,13 +778,8 @@ var WarpSolanaExecutor = class {
784
778
  if (!userWallet) throw new Error("WarpSolanaExecutor: createContractCall - user address not set");
785
779
  const action = getWarpActionByIndex(executable.warp, executable.action);
786
780
  if (!action || !("func" in action) || !action.func) throw new Error("WarpSolanaExecutor: Contract action must have a function name");
787
- let programId;
788
- try {
789
- if (!executable.destination) throw new Error("WarpSolanaExecutor: Contract address is required");
790
- programId = new PublicKey3(executable.destination);
791
- } catch {
792
- throw new Error(`WarpSolanaExecutor: Invalid contract address: ${executable.destination}`);
793
- }
781
+ if (!executable.destination) throw new Error("WarpSolanaExecutor: Contract address is required");
782
+ const programId = new PublicKey3(executable.destination);
794
783
  const fromPubkey = new PublicKey3(userWallet);
795
784
  const transaction = new Transaction();
796
785
  try {
@@ -819,13 +808,7 @@ var WarpSolanaExecutor = class {
819
808
  });
820
809
  transaction.add(instruction);
821
810
  if (executable.value > 0n) {
822
- transaction.add(
823
- SystemProgram.transfer({
824
- fromPubkey,
825
- toPubkey: programId,
826
- lamports: Number(executable.value)
827
- })
828
- );
811
+ transaction.add(SystemProgram.transfer({ fromPubkey, toPubkey: programId, lamports: Number(executable.value) }));
829
812
  }
830
813
  return this.setTransactionDefaults(transaction, fromPubkey);
831
814
  } catch (error) {
@@ -844,7 +827,7 @@ var WarpSolanaExecutor = class {
844
827
  }
845
828
  if (args.length > 0 && instructionDef.args) {
846
829
  const encodedArgs = this.encodeArgs(args, instructionDef.args);
847
- return Buffer.from([...data, ...encodedArgs]);
830
+ return Buffer.concat([data, encodedArgs]);
848
831
  }
849
832
  return data;
850
833
  } catch {
@@ -871,7 +854,7 @@ var WarpSolanaExecutor = class {
871
854
  }
872
855
  return Buffer.from(String(arg), "utf8");
873
856
  });
874
- return Buffer.from([...data, ...encodedArgs]);
857
+ return Buffer.concat([data, ...encodedArgs]);
875
858
  }
876
859
  return data;
877
860
  }
@@ -904,7 +887,7 @@ var WarpSolanaExecutor = class {
904
887
  buffers.push(Buffer.from(String(arg), "utf8"));
905
888
  }
906
889
  }
907
- return Buffer.from(buffers.flatMap((buf) => Array.from(buf)));
890
+ return Buffer.concat(buffers);
908
891
  }
909
892
  buildInstructionAccounts(action, executable, fromPubkey, programId) {
910
893
  const accounts = [
@@ -1099,16 +1082,13 @@ var WarpSolanaExecutor = class {
1099
1082
  } else {
1100
1083
  computeUnits = WarpSolanaConstants.ComputeUnitLimit.ContractCall;
1101
1084
  }
1102
- transaction.add(
1103
- ComputeBudgetProgram.setComputeUnitLimit({
1104
- units: computeUnits
1105
- })
1106
- );
1107
- transaction.add(
1108
- ComputeBudgetProgram.setComputeUnitPrice({
1109
- microLamports: WarpSolanaConstants.PriorityFee.Default
1110
- })
1111
- );
1085
+ const computeUnitLimitIx = ComputeBudgetProgram.setComputeUnitLimit({
1086
+ units: computeUnits
1087
+ });
1088
+ const computeUnitPriceIx = ComputeBudgetProgram.setComputeUnitPrice({
1089
+ microLamports: WarpSolanaConstants.PriorityFee.Default
1090
+ });
1091
+ transaction.instructions = [computeUnitLimitIx, computeUnitPriceIx, ...transaction.instructions];
1112
1092
  return transaction;
1113
1093
  } catch (error) {
1114
1094
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -1150,26 +1130,46 @@ var WarpSolanaExplorer = class {
1150
1130
  }
1151
1131
  getAccountUrl(address, explorer) {
1152
1132
  const baseUrl = this.getExplorerUrlByName(explorer);
1133
+ if (baseUrl.includes("?")) {
1134
+ const cluster2 = this.config.env === "mainnet" ? "" : `&cluster=${this.config.env}`;
1135
+ return `${baseUrl}/account/${address}${cluster2}`;
1136
+ }
1153
1137
  const cluster = this.config.env === "mainnet" ? "" : `?cluster=${this.config.env}`;
1154
1138
  return `${baseUrl}/account/${address}${cluster}`;
1155
1139
  }
1156
1140
  getTransactionUrl(hash, explorer) {
1157
1141
  const baseUrl = this.getExplorerUrlByName(explorer);
1142
+ if (baseUrl.includes("?")) {
1143
+ const cluster2 = this.config.env === "mainnet" ? "" : `&cluster=${this.config.env}`;
1144
+ return `${baseUrl}/tx/${hash}${cluster2}`;
1145
+ }
1158
1146
  const cluster = this.config.env === "mainnet" ? "" : `?cluster=${this.config.env}`;
1159
1147
  return `${baseUrl}/tx/${hash}${cluster}`;
1160
1148
  }
1161
1149
  getBlockUrl(blockNumber, explorer) {
1162
1150
  const baseUrl = this.getExplorerUrlByName(explorer);
1151
+ if (baseUrl.includes("?")) {
1152
+ const cluster2 = this.config.env === "mainnet" ? "" : `&cluster=${this.config.env}`;
1153
+ return `${baseUrl}/block/${blockNumber}${cluster2}`;
1154
+ }
1163
1155
  const cluster = this.config.env === "mainnet" ? "" : `?cluster=${this.config.env}`;
1164
1156
  return `${baseUrl}/block/${blockNumber}${cluster}`;
1165
1157
  }
1166
1158
  getAssetUrl(identifier, explorer) {
1167
1159
  const baseUrl = this.getExplorerUrlByName(explorer);
1160
+ if (baseUrl.includes("?")) {
1161
+ const cluster2 = this.config.env === "mainnet" ? "" : `&cluster=${this.config.env}`;
1162
+ return `${baseUrl}/token/${identifier}${cluster2}`;
1163
+ }
1168
1164
  const cluster = this.config.env === "mainnet" ? "" : `?cluster=${this.config.env}`;
1169
1165
  return `${baseUrl}/token/${identifier}${cluster}`;
1170
1166
  }
1171
1167
  getContractUrl(address, explorer) {
1172
1168
  const baseUrl = this.getExplorerUrlByName(explorer);
1169
+ if (baseUrl.includes("?")) {
1170
+ const cluster2 = this.config.env === "mainnet" ? "" : `&cluster=${this.config.env}`;
1171
+ return `${baseUrl}/account/${address}${cluster2}`;
1172
+ }
1173
1173
  const cluster = this.config.env === "mainnet" ? "" : `?cluster=${this.config.env}`;
1174
1174
  return `${baseUrl}/account/${address}${cluster}`;
1175
1175
  }
@@ -1250,7 +1250,7 @@ import {
1250
1250
  } from "@vleap/warps";
1251
1251
  import { Connection as Connection4, Keypair, Transaction as Transaction2, VersionedTransaction } from "@solana/web3.js";
1252
1252
  import * as bip39 from "@scure/bip39";
1253
- import { wordlist } from "@scure/bip39/wordlists/english";
1253
+ import { wordlist } from "@scure/bip39/wordlists/english.js";
1254
1254
  import bs582 from "bs58";
1255
1255
  var WarpSolanaWallet = class {
1256
1256
  constructor(config, chain) {
@@ -1450,7 +1450,7 @@ var NativeTokenSol = {
1450
1450
  symbol: "SOL",
1451
1451
  name: "Solana",
1452
1452
  decimals: 9,
1453
- logoUrl: "https://vleap.ai/images/tokens/sol.svg"
1453
+ logoUrl: "https://joai.ai/images/tokens/sol.svg"
1454
1454
  };
1455
1455
  var getSolanaAdapter = createSolanaAdapter(WarpChainName2.Solana, {
1456
1456
  mainnet: {
@@ -1460,7 +1460,7 @@ var getSolanaAdapter = createSolanaAdapter(WarpChainName2.Solana, {
1460
1460
  blockTime: 400,
1461
1461
  addressHrp: "",
1462
1462
  defaultApiUrl: "https://api.mainnet-beta.solana.com",
1463
- logoUrl: "https://vleap.ai/images/chains/solana.svg",
1463
+ logoUrl: "https://joai.ai/images/chains/solana.svg",
1464
1464
  nativeToken: NativeTokenSol
1465
1465
  },
1466
1466
  testnet: {
@@ -1470,7 +1470,7 @@ var getSolanaAdapter = createSolanaAdapter(WarpChainName2.Solana, {
1470
1470
  blockTime: 400,
1471
1471
  addressHrp: "",
1472
1472
  defaultApiUrl: "https://api.testnet.solana.com",
1473
- logoUrl: "https://vleap.ai/images/chains/solana.svg",
1473
+ logoUrl: "https://joai.ai/images/chains/solana.svg",
1474
1474
  nativeToken: NativeTokenSol
1475
1475
  },
1476
1476
  devnet: {
@@ -1480,7 +1480,7 @@ var getSolanaAdapter = createSolanaAdapter(WarpChainName2.Solana, {
1480
1480
  blockTime: 400,
1481
1481
  addressHrp: "",
1482
1482
  defaultApiUrl: "https://api.devnet.solana.com",
1483
- logoUrl: "https://vleap.ai/images/chains/solana.svg",
1483
+ logoUrl: "https://joai.ai/images/chains/solana.svg",
1484
1484
  nativeToken: NativeTokenSol
1485
1485
  }
1486
1486
  });