@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.js +44 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -101,10 +101,10 @@ var SolanaExplorerMap = {
|
|
|
101
101
|
var ExplorerUrls = {
|
|
102
102
|
["solscan" /* Solscan */]: "https://solscan.io",
|
|
103
103
|
["solscan_mainnet" /* SolscanMainnet */]: "https://solscan.io",
|
|
104
|
-
["solscan_devnet" /* SolscanDevnet */]: "https://solscan.io
|
|
104
|
+
["solscan_devnet" /* SolscanDevnet */]: "https://solscan.io",
|
|
105
105
|
["solana_explorer" /* SolanaExplorer */]: "https://explorer.solana.com",
|
|
106
106
|
["solana_explorer_mainnet" /* SolanaExplorerMainnet */]: "https://explorer.solana.com",
|
|
107
|
-
["solana_explorer_devnet" /* SolanaExplorerDevnet */]: "https://explorer.solana.com
|
|
107
|
+
["solana_explorer_devnet" /* SolanaExplorerDevnet */]: "https://explorer.solana.com"
|
|
108
108
|
};
|
|
109
109
|
var SolanaExplorerNames = {
|
|
110
110
|
mainnet: ["solscan_mainnet" /* SolscanMainnet */, "solana_explorer_mainnet" /* SolanaExplorerMainnet */],
|
|
@@ -769,12 +769,12 @@ var WarpSolanaExecutor = class {
|
|
|
769
769
|
async createTransferTransaction(executable) {
|
|
770
770
|
const userWallet = (0, import_warps5.getWarpWalletAddressFromConfig)(this.config, executable.chain.name);
|
|
771
771
|
if (!userWallet) throw new Error("WarpSolanaExecutor: createTransfer - user address not set");
|
|
772
|
+
if (!executable.destination) throw new Error("WarpSolanaExecutor: Destination address is required");
|
|
772
773
|
let destinationPubkey;
|
|
773
774
|
try {
|
|
774
|
-
if (!executable.destination) throw new Error("WarpSolanaExecutor: Destination address is required");
|
|
775
775
|
destinationPubkey = new import_web34.PublicKey(executable.destination);
|
|
776
|
-
} catch {
|
|
777
|
-
throw new Error(
|
|
776
|
+
} catch (error) {
|
|
777
|
+
throw new Error("WarpSolanaExecutor: Invalid destination address");
|
|
778
778
|
}
|
|
779
779
|
if (executable.transfers && executable.transfers.length > 0) {
|
|
780
780
|
return this.createTokenTransferTransaction(executable, userWallet, destinationPubkey);
|
|
@@ -782,13 +782,7 @@ var WarpSolanaExecutor = class {
|
|
|
782
782
|
const fromPubkey = new import_web34.PublicKey(userWallet);
|
|
783
783
|
const transaction = new import_web34.Transaction();
|
|
784
784
|
if (executable.value > 0n) {
|
|
785
|
-
transaction.add(
|
|
786
|
-
import_web34.SystemProgram.transfer({
|
|
787
|
-
fromPubkey,
|
|
788
|
-
toPubkey: destinationPubkey,
|
|
789
|
-
lamports: Number(executable.value)
|
|
790
|
-
})
|
|
791
|
-
);
|
|
785
|
+
transaction.add(import_web34.SystemProgram.transfer({ fromPubkey, toPubkey: destinationPubkey, lamports: Number(executable.value) }));
|
|
792
786
|
}
|
|
793
787
|
if (executable.data) {
|
|
794
788
|
const data = this.serializer.stringToTyped(executable.data);
|
|
@@ -812,13 +806,8 @@ var WarpSolanaExecutor = class {
|
|
|
812
806
|
if (!userWallet) throw new Error("WarpSolanaExecutor: createContractCall - user address not set");
|
|
813
807
|
const action = (0, import_warps5.getWarpActionByIndex)(executable.warp, executable.action);
|
|
814
808
|
if (!action || !("func" in action) || !action.func) throw new Error("WarpSolanaExecutor: Contract action must have a function name");
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
if (!executable.destination) throw new Error("WarpSolanaExecutor: Contract address is required");
|
|
818
|
-
programId = new import_web34.PublicKey(executable.destination);
|
|
819
|
-
} catch {
|
|
820
|
-
throw new Error(`WarpSolanaExecutor: Invalid contract address: ${executable.destination}`);
|
|
821
|
-
}
|
|
809
|
+
if (!executable.destination) throw new Error("WarpSolanaExecutor: Contract address is required");
|
|
810
|
+
const programId = new import_web34.PublicKey(executable.destination);
|
|
822
811
|
const fromPubkey = new import_web34.PublicKey(userWallet);
|
|
823
812
|
const transaction = new import_web34.Transaction();
|
|
824
813
|
try {
|
|
@@ -847,13 +836,7 @@ var WarpSolanaExecutor = class {
|
|
|
847
836
|
});
|
|
848
837
|
transaction.add(instruction);
|
|
849
838
|
if (executable.value > 0n) {
|
|
850
|
-
transaction.add(
|
|
851
|
-
import_web34.SystemProgram.transfer({
|
|
852
|
-
fromPubkey,
|
|
853
|
-
toPubkey: programId,
|
|
854
|
-
lamports: Number(executable.value)
|
|
855
|
-
})
|
|
856
|
-
);
|
|
839
|
+
transaction.add(import_web34.SystemProgram.transfer({ fromPubkey, toPubkey: programId, lamports: Number(executable.value) }));
|
|
857
840
|
}
|
|
858
841
|
return this.setTransactionDefaults(transaction, fromPubkey);
|
|
859
842
|
} catch (error) {
|
|
@@ -872,7 +855,7 @@ var WarpSolanaExecutor = class {
|
|
|
872
855
|
}
|
|
873
856
|
if (args.length > 0 && instructionDef.args) {
|
|
874
857
|
const encodedArgs = this.encodeArgs(args, instructionDef.args);
|
|
875
|
-
return Buffer.
|
|
858
|
+
return Buffer.concat([data, encodedArgs]);
|
|
876
859
|
}
|
|
877
860
|
return data;
|
|
878
861
|
} catch {
|
|
@@ -899,7 +882,7 @@ var WarpSolanaExecutor = class {
|
|
|
899
882
|
}
|
|
900
883
|
return Buffer.from(String(arg), "utf8");
|
|
901
884
|
});
|
|
902
|
-
return Buffer.
|
|
885
|
+
return Buffer.concat([data, ...encodedArgs]);
|
|
903
886
|
}
|
|
904
887
|
return data;
|
|
905
888
|
}
|
|
@@ -932,7 +915,7 @@ var WarpSolanaExecutor = class {
|
|
|
932
915
|
buffers.push(Buffer.from(String(arg), "utf8"));
|
|
933
916
|
}
|
|
934
917
|
}
|
|
935
|
-
return Buffer.
|
|
918
|
+
return Buffer.concat(buffers);
|
|
936
919
|
}
|
|
937
920
|
buildInstructionAccounts(action, executable, fromPubkey, programId) {
|
|
938
921
|
const accounts = [
|
|
@@ -1127,16 +1110,13 @@ var WarpSolanaExecutor = class {
|
|
|
1127
1110
|
} else {
|
|
1128
1111
|
computeUnits = WarpSolanaConstants.ComputeUnitLimit.ContractCall;
|
|
1129
1112
|
}
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
microLamports: WarpSolanaConstants.PriorityFee.Default
|
|
1138
|
-
})
|
|
1139
|
-
);
|
|
1113
|
+
const computeUnitLimitIx = import_web34.ComputeBudgetProgram.setComputeUnitLimit({
|
|
1114
|
+
units: computeUnits
|
|
1115
|
+
});
|
|
1116
|
+
const computeUnitPriceIx = import_web34.ComputeBudgetProgram.setComputeUnitPrice({
|
|
1117
|
+
microLamports: WarpSolanaConstants.PriorityFee.Default
|
|
1118
|
+
});
|
|
1119
|
+
transaction.instructions = [computeUnitLimitIx, computeUnitPriceIx, ...transaction.instructions];
|
|
1140
1120
|
return transaction;
|
|
1141
1121
|
} catch (error) {
|
|
1142
1122
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -1178,26 +1158,46 @@ var WarpSolanaExplorer = class {
|
|
|
1178
1158
|
}
|
|
1179
1159
|
getAccountUrl(address, explorer) {
|
|
1180
1160
|
const baseUrl = this.getExplorerUrlByName(explorer);
|
|
1161
|
+
if (baseUrl.includes("?")) {
|
|
1162
|
+
const cluster2 = this.config.env === "mainnet" ? "" : `&cluster=${this.config.env}`;
|
|
1163
|
+
return `${baseUrl}/account/${address}${cluster2}`;
|
|
1164
|
+
}
|
|
1181
1165
|
const cluster = this.config.env === "mainnet" ? "" : `?cluster=${this.config.env}`;
|
|
1182
1166
|
return `${baseUrl}/account/${address}${cluster}`;
|
|
1183
1167
|
}
|
|
1184
1168
|
getTransactionUrl(hash, explorer) {
|
|
1185
1169
|
const baseUrl = this.getExplorerUrlByName(explorer);
|
|
1170
|
+
if (baseUrl.includes("?")) {
|
|
1171
|
+
const cluster2 = this.config.env === "mainnet" ? "" : `&cluster=${this.config.env}`;
|
|
1172
|
+
return `${baseUrl}/tx/${hash}${cluster2}`;
|
|
1173
|
+
}
|
|
1186
1174
|
const cluster = this.config.env === "mainnet" ? "" : `?cluster=${this.config.env}`;
|
|
1187
1175
|
return `${baseUrl}/tx/${hash}${cluster}`;
|
|
1188
1176
|
}
|
|
1189
1177
|
getBlockUrl(blockNumber, explorer) {
|
|
1190
1178
|
const baseUrl = this.getExplorerUrlByName(explorer);
|
|
1179
|
+
if (baseUrl.includes("?")) {
|
|
1180
|
+
const cluster2 = this.config.env === "mainnet" ? "" : `&cluster=${this.config.env}`;
|
|
1181
|
+
return `${baseUrl}/block/${blockNumber}${cluster2}`;
|
|
1182
|
+
}
|
|
1191
1183
|
const cluster = this.config.env === "mainnet" ? "" : `?cluster=${this.config.env}`;
|
|
1192
1184
|
return `${baseUrl}/block/${blockNumber}${cluster}`;
|
|
1193
1185
|
}
|
|
1194
1186
|
getAssetUrl(identifier, explorer) {
|
|
1195
1187
|
const baseUrl = this.getExplorerUrlByName(explorer);
|
|
1188
|
+
if (baseUrl.includes("?")) {
|
|
1189
|
+
const cluster2 = this.config.env === "mainnet" ? "" : `&cluster=${this.config.env}`;
|
|
1190
|
+
return `${baseUrl}/token/${identifier}${cluster2}`;
|
|
1191
|
+
}
|
|
1196
1192
|
const cluster = this.config.env === "mainnet" ? "" : `?cluster=${this.config.env}`;
|
|
1197
1193
|
return `${baseUrl}/token/${identifier}${cluster}`;
|
|
1198
1194
|
}
|
|
1199
1195
|
getContractUrl(address, explorer) {
|
|
1200
1196
|
const baseUrl = this.getExplorerUrlByName(explorer);
|
|
1197
|
+
if (baseUrl.includes("?")) {
|
|
1198
|
+
const cluster2 = this.config.env === "mainnet" ? "" : `&cluster=${this.config.env}`;
|
|
1199
|
+
return `${baseUrl}/account/${address}${cluster2}`;
|
|
1200
|
+
}
|
|
1201
1201
|
const cluster = this.config.env === "mainnet" ? "" : `?cluster=${this.config.env}`;
|
|
1202
1202
|
return `${baseUrl}/account/${address}${cluster}`;
|
|
1203
1203
|
}
|
|
@@ -1274,7 +1274,7 @@ var WarpSolanaExplorer = class {
|
|
|
1274
1274
|
var import_warps6 = require("@vleap/warps");
|
|
1275
1275
|
var import_web35 = require("@solana/web3.js");
|
|
1276
1276
|
var bip39 = __toESM(require("@scure/bip39"), 1);
|
|
1277
|
-
var import_english = require("@scure/bip39/wordlists/english");
|
|
1277
|
+
var import_english = require("@scure/bip39/wordlists/english.js");
|
|
1278
1278
|
var import_bs582 = __toESM(require("bs58"), 1);
|
|
1279
1279
|
var WarpSolanaWallet = class {
|
|
1280
1280
|
constructor(config, chain) {
|
|
@@ -1474,7 +1474,7 @@ var NativeTokenSol = {
|
|
|
1474
1474
|
symbol: "SOL",
|
|
1475
1475
|
name: "Solana",
|
|
1476
1476
|
decimals: 9,
|
|
1477
|
-
logoUrl: "https://
|
|
1477
|
+
logoUrl: "https://joai.ai/images/tokens/sol.svg"
|
|
1478
1478
|
};
|
|
1479
1479
|
var getSolanaAdapter = createSolanaAdapter(import_warps7.WarpChainName.Solana, {
|
|
1480
1480
|
mainnet: {
|
|
@@ -1484,7 +1484,7 @@ var getSolanaAdapter = createSolanaAdapter(import_warps7.WarpChainName.Solana, {
|
|
|
1484
1484
|
blockTime: 400,
|
|
1485
1485
|
addressHrp: "",
|
|
1486
1486
|
defaultApiUrl: "https://api.mainnet-beta.solana.com",
|
|
1487
|
-
logoUrl: "https://
|
|
1487
|
+
logoUrl: "https://joai.ai/images/chains/solana.svg",
|
|
1488
1488
|
nativeToken: NativeTokenSol
|
|
1489
1489
|
},
|
|
1490
1490
|
testnet: {
|
|
@@ -1494,7 +1494,7 @@ var getSolanaAdapter = createSolanaAdapter(import_warps7.WarpChainName.Solana, {
|
|
|
1494
1494
|
blockTime: 400,
|
|
1495
1495
|
addressHrp: "",
|
|
1496
1496
|
defaultApiUrl: "https://api.testnet.solana.com",
|
|
1497
|
-
logoUrl: "https://
|
|
1497
|
+
logoUrl: "https://joai.ai/images/chains/solana.svg",
|
|
1498
1498
|
nativeToken: NativeTokenSol
|
|
1499
1499
|
},
|
|
1500
1500
|
devnet: {
|
|
@@ -1504,7 +1504,7 @@ var getSolanaAdapter = createSolanaAdapter(import_warps7.WarpChainName.Solana, {
|
|
|
1504
1504
|
blockTime: 400,
|
|
1505
1505
|
addressHrp: "",
|
|
1506
1506
|
defaultApiUrl: "https://api.devnet.solana.com",
|
|
1507
|
-
logoUrl: "https://
|
|
1507
|
+
logoUrl: "https://joai.ai/images/chains/solana.svg",
|
|
1508
1508
|
nativeToken: NativeTokenSol
|
|
1509
1509
|
}
|
|
1510
1510
|
});
|