@vleap/warps-adapter-solana 0.1.0-beta.3 → 0.1.0-beta.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.js +40 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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
|
|
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
|
|
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(
|
|
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
|
-
|
|
788
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
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) {
|