@vleap/warps-adapter-solana 0.1.0-beta.1 → 0.1.0-beta.3
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 +69 -87
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -50,8 +50,11 @@ __export(index_exports, {
|
|
|
50
50
|
});
|
|
51
51
|
module.exports = __toCommonJS(index_exports);
|
|
52
52
|
|
|
53
|
+
// src/chains/solana.ts
|
|
54
|
+
var import_warps7 = require("@vleap/warps");
|
|
55
|
+
|
|
53
56
|
// src/WarpSolanaDataLoader.ts
|
|
54
|
-
var
|
|
57
|
+
var import_warps2 = require("@vleap/warps");
|
|
55
58
|
var import_web3 = require("@solana/web3.js");
|
|
56
59
|
var import_spl_token = require("@solana/spl-token");
|
|
57
60
|
|
|
@@ -111,7 +114,8 @@ var SolanaExplorerNames = {
|
|
|
111
114
|
var SolanaExplorerUrls = ExplorerUrls;
|
|
112
115
|
|
|
113
116
|
// src/tokens/solana.ts
|
|
114
|
-
var
|
|
117
|
+
var import_warps = require("@vleap/warps");
|
|
118
|
+
var SolanaChain = import_warps.WarpChainName.Solana;
|
|
115
119
|
var SolanaTokens = [
|
|
116
120
|
{
|
|
117
121
|
chain: SolanaChain,
|
|
@@ -168,9 +172,9 @@ var WarpSolanaDataLoader = class {
|
|
|
168
172
|
constructor(config, chain) {
|
|
169
173
|
this.config = config;
|
|
170
174
|
this.chain = chain;
|
|
171
|
-
const providerConfig = (0,
|
|
175
|
+
const providerConfig = (0, import_warps2.getProviderConfig)(this.config, this.chain.name, this.config.env, this.chain.defaultApiUrl);
|
|
172
176
|
this.connection = new import_web3.Connection(providerConfig.url, "confirmed");
|
|
173
|
-
this.cache = new
|
|
177
|
+
this.cache = new import_warps2.WarpCache(config.cache?.type);
|
|
174
178
|
}
|
|
175
179
|
async getAccount(address) {
|
|
176
180
|
try {
|
|
@@ -213,7 +217,7 @@ var WarpSolanaDataLoader = class {
|
|
|
213
217
|
if (identifier === this.chain.nativeToken.identifier || identifier === "SOL") {
|
|
214
218
|
return this.chain.nativeToken;
|
|
215
219
|
}
|
|
216
|
-
const cacheKey =
|
|
220
|
+
const cacheKey = import_warps2.WarpCacheKey.Asset(this.config.env, this.chain.name, identifier);
|
|
217
221
|
const cachedAsset = this.cache.get(cacheKey);
|
|
218
222
|
if (cachedAsset) {
|
|
219
223
|
return cachedAsset;
|
|
@@ -241,7 +245,7 @@ var WarpSolanaDataLoader = class {
|
|
|
241
245
|
decimals: metadata.decimals,
|
|
242
246
|
logoUrl: metadata.logoUrl
|
|
243
247
|
};
|
|
244
|
-
this.cache.set(cacheKey, asset,
|
|
248
|
+
this.cache.set(cacheKey, asset, import_warps2.CacheTtl.OneHour);
|
|
245
249
|
return asset;
|
|
246
250
|
} catch (error) {
|
|
247
251
|
return null;
|
|
@@ -372,21 +376,21 @@ var WarpSolanaDataLoader = class {
|
|
|
372
376
|
};
|
|
373
377
|
|
|
374
378
|
// src/WarpSolanaExecutor.ts
|
|
375
|
-
var import_warps4 = require("@vleap/warps");
|
|
376
|
-
var import_web34 = require("@solana/web3.js");
|
|
377
379
|
var import_spl_token2 = require("@solana/spl-token");
|
|
380
|
+
var import_web34 = require("@solana/web3.js");
|
|
381
|
+
var import_warps5 = require("@vleap/warps");
|
|
378
382
|
|
|
379
383
|
// src/WarpSolanaOutput.ts
|
|
380
|
-
var
|
|
384
|
+
var import_warps4 = require("@vleap/warps");
|
|
381
385
|
var import_web33 = require("@solana/web3.js");
|
|
382
386
|
|
|
383
387
|
// src/WarpSolanaSerializer.ts
|
|
384
|
-
var
|
|
388
|
+
var import_warps3 = require("@vleap/warps");
|
|
385
389
|
var import_web32 = require("@solana/web3.js");
|
|
386
390
|
var import_bs58 = __toESM(require("bs58"), 1);
|
|
387
391
|
var WarpSolanaSerializer = class {
|
|
388
392
|
constructor() {
|
|
389
|
-
this.coreSerializer = new
|
|
393
|
+
this.coreSerializer = new import_warps3.WarpSerializer();
|
|
390
394
|
}
|
|
391
395
|
typedToString(value) {
|
|
392
396
|
if (value && typeof value === "object" && "toBase58" in value && typeof value.toBase58 === "function") {
|
|
@@ -431,15 +435,15 @@ var WarpSolanaSerializer = class {
|
|
|
431
435
|
if (typeof value === "object" && value !== null && "identifier" in value && "amount" in value) {
|
|
432
436
|
const asset = value;
|
|
433
437
|
if (asset.decimals !== void 0) {
|
|
434
|
-
return `asset:${asset.identifier}${
|
|
438
|
+
return `asset:${asset.identifier}${import_warps3.WarpConstants.ArgCompositeSeparator}${asset.amount.toString()}${import_warps3.WarpConstants.ArgCompositeSeparator}${asset.decimals}`;
|
|
435
439
|
}
|
|
436
|
-
return `asset:${asset.identifier}${
|
|
440
|
+
return `asset:${asset.identifier}${import_warps3.WarpConstants.ArgCompositeSeparator}${asset.amount.toString()}`;
|
|
437
441
|
}
|
|
438
442
|
if (Array.isArray(value)) {
|
|
439
443
|
if (value.length === 0) return `list:string:`;
|
|
440
|
-
const types = value.map((item) => this.typedToString(item).split(
|
|
444
|
+
const types = value.map((item) => this.typedToString(item).split(import_warps3.WarpConstants.ArgParamsSeparator)[0]);
|
|
441
445
|
const type = types[0];
|
|
442
|
-
const values = value.map((item) => this.typedToString(item).split(
|
|
446
|
+
const values = value.map((item) => this.typedToString(item).split(import_warps3.WarpConstants.ArgParamsSeparator)[1]);
|
|
443
447
|
return `list:${type}:${values.join(",")}`;
|
|
444
448
|
}
|
|
445
449
|
if (value === null || value === void 0) {
|
|
@@ -449,8 +453,8 @@ var WarpSolanaSerializer = class {
|
|
|
449
453
|
}
|
|
450
454
|
typedToNative(value) {
|
|
451
455
|
const stringValue = this.typedToString(value);
|
|
452
|
-
const [type, ...valueParts] = stringValue.split(
|
|
453
|
-
const nativeValue = valueParts.join(
|
|
456
|
+
const [type, ...valueParts] = stringValue.split(import_warps3.WarpConstants.ArgParamsSeparator);
|
|
457
|
+
const nativeValue = valueParts.join(import_warps3.WarpConstants.ArgParamsSeparator);
|
|
454
458
|
return [type, this.parseNativeValue(type, nativeValue)];
|
|
455
459
|
}
|
|
456
460
|
nativeToTyped(type, value) {
|
|
@@ -506,7 +510,7 @@ var WarpSolanaSerializer = class {
|
|
|
506
510
|
}
|
|
507
511
|
}
|
|
508
512
|
stringToTyped(value) {
|
|
509
|
-
const parts = value.split(
|
|
513
|
+
const parts = value.split(import_warps3.WarpConstants.ArgParamsSeparator, 2);
|
|
510
514
|
if (parts.length < 2) {
|
|
511
515
|
return value;
|
|
512
516
|
}
|
|
@@ -528,7 +532,7 @@ var WarpSolanaSerializer = class {
|
|
|
528
532
|
case "hex":
|
|
529
533
|
return stringValue;
|
|
530
534
|
case "asset":
|
|
531
|
-
const assetParts = stringValue.split(
|
|
535
|
+
const assetParts = stringValue.split(import_warps3.WarpConstants.ArgCompositeSeparator);
|
|
532
536
|
const identifier = assetParts[0] || "";
|
|
533
537
|
const amount = assetParts[1] ? BigInt(assetParts[1]) : 0n;
|
|
534
538
|
const decimals = assetParts[2] ? parseInt(assetParts[2], 10) : void 0;
|
|
@@ -571,13 +575,13 @@ var WarpSolanaOutput = class {
|
|
|
571
575
|
this.config = config;
|
|
572
576
|
this.chain = chain;
|
|
573
577
|
this.serializer = new WarpSolanaSerializer();
|
|
574
|
-
const providerConfig = (0,
|
|
578
|
+
const providerConfig = (0, import_warps4.getProviderConfig)(this.config, this.chain.name, this.config.env, this.chain.defaultApiUrl);
|
|
575
579
|
this.connection = new import_web33.Connection(providerConfig.url, "confirmed");
|
|
576
|
-
this.cache = new
|
|
580
|
+
this.cache = new import_warps4.WarpCache(config.cache?.type);
|
|
577
581
|
}
|
|
578
582
|
async getActionExecution(warp, actionIndex, tx) {
|
|
579
|
-
const inputs = this.cache.get(
|
|
580
|
-
const resolvedInputs = (0,
|
|
583
|
+
const inputs = this.cache.get(import_warps4.WarpCacheKey.WarpExecutable(this.config.env, warp.meta?.hash || "", actionIndex)) ?? [];
|
|
584
|
+
const resolvedInputs = (0, import_warps4.extractResolvedInputValues)(inputs);
|
|
581
585
|
if (!tx) {
|
|
582
586
|
return this.createFailedExecution(warp, actionIndex, resolvedInputs);
|
|
583
587
|
}
|
|
@@ -594,7 +598,7 @@ var WarpSolanaOutput = class {
|
|
|
594
598
|
status: "error",
|
|
595
599
|
warp,
|
|
596
600
|
action: actionIndex,
|
|
597
|
-
user: (0,
|
|
601
|
+
user: (0, import_warps4.getWarpWalletAddressFromConfig)(this.config, this.chain.name),
|
|
598
602
|
txHash: "",
|
|
599
603
|
tx: null,
|
|
600
604
|
next: null,
|
|
@@ -616,7 +620,7 @@ var WarpSolanaOutput = class {
|
|
|
616
620
|
status: success ? "success" : "error",
|
|
617
621
|
warp,
|
|
618
622
|
action: actionIndex,
|
|
619
|
-
user: (0,
|
|
623
|
+
user: (0, import_warps4.getWarpWalletAddressFromConfig)(this.config, this.chain.name),
|
|
620
624
|
txHash: transactionHash,
|
|
621
625
|
tx,
|
|
622
626
|
next: null,
|
|
@@ -646,7 +650,7 @@ var WarpSolanaOutput = class {
|
|
|
646
650
|
status: success ? "success" : "error",
|
|
647
651
|
warp,
|
|
648
652
|
action: actionIndex,
|
|
649
|
-
user: (0,
|
|
653
|
+
user: (0, import_warps4.getWarpWalletAddressFromConfig)(this.config, this.chain.name),
|
|
650
654
|
txHash: signature,
|
|
651
655
|
tx: {
|
|
652
656
|
signature,
|
|
@@ -683,8 +687,8 @@ var WarpSolanaOutput = class {
|
|
|
683
687
|
return value;
|
|
684
688
|
};
|
|
685
689
|
for (const [key, path] of Object.entries(warp.output)) {
|
|
686
|
-
if (path.startsWith(
|
|
687
|
-
const currentActionIndex = (0,
|
|
690
|
+
if (path.startsWith(import_warps4.WarpConstants.Transform.Prefix)) continue;
|
|
691
|
+
const currentActionIndex = (0, import_warps4.parseOutputOutIndex)(path);
|
|
688
692
|
if (currentActionIndex !== null && currentActionIndex !== actionIndex) {
|
|
689
693
|
output[key] = null;
|
|
690
694
|
continue;
|
|
@@ -695,7 +699,7 @@ var WarpSolanaOutput = class {
|
|
|
695
699
|
output[key] = path;
|
|
696
700
|
}
|
|
697
701
|
}
|
|
698
|
-
return { values, output: await (0,
|
|
702
|
+
return { values, output: await (0, import_warps4.evaluateOutputCommon)(warp, output, actionIndex, inputs, this.serializer.coreSerializer, this.config) };
|
|
699
703
|
}
|
|
700
704
|
async getTransactionStatus(txHash) {
|
|
701
705
|
try {
|
|
@@ -743,12 +747,12 @@ var WarpSolanaExecutor = class {
|
|
|
743
747
|
this.config = config;
|
|
744
748
|
this.chain = chain;
|
|
745
749
|
this.serializer = new WarpSolanaSerializer();
|
|
746
|
-
const providerConfig = (0,
|
|
750
|
+
const providerConfig = (0, import_warps5.getProviderConfig)(this.config, chain.name, this.config.env, this.chain.defaultApiUrl);
|
|
747
751
|
this.connection = new import_web34.Connection(providerConfig.url, "confirmed");
|
|
748
752
|
this.output = new WarpSolanaOutput(config, this.chain);
|
|
749
753
|
}
|
|
750
754
|
async createTransaction(executable) {
|
|
751
|
-
const action = (0,
|
|
755
|
+
const action = (0, import_warps5.getWarpActionByIndex)(executable.warp, executable.action);
|
|
752
756
|
let tx = null;
|
|
753
757
|
if (action.type === "transfer") {
|
|
754
758
|
tx = await this.createTransferTransaction(executable);
|
|
@@ -763,7 +767,7 @@ var WarpSolanaExecutor = class {
|
|
|
763
767
|
return tx;
|
|
764
768
|
}
|
|
765
769
|
async createTransferTransaction(executable) {
|
|
766
|
-
const userWallet = (0,
|
|
770
|
+
const userWallet = (0, import_warps5.getWarpWalletAddressFromConfig)(this.config, executable.chain.name);
|
|
767
771
|
if (!userWallet) throw new Error("WarpSolanaExecutor: createTransfer - user address not set");
|
|
768
772
|
let destinationPubkey;
|
|
769
773
|
try {
|
|
@@ -804,9 +808,9 @@ var WarpSolanaExecutor = class {
|
|
|
804
808
|
return this.setTransactionDefaults(transaction, fromPubkey);
|
|
805
809
|
}
|
|
806
810
|
async createContractCallTransaction(executable) {
|
|
807
|
-
const userWallet = (0,
|
|
811
|
+
const userWallet = (0, import_warps5.getWarpWalletAddressFromConfig)(this.config, executable.chain.name);
|
|
808
812
|
if (!userWallet) throw new Error("WarpSolanaExecutor: createContractCall - user address not set");
|
|
809
|
-
const action = (0,
|
|
813
|
+
const action = (0, import_warps5.getWarpActionByIndex)(executable.warp, executable.action);
|
|
810
814
|
if (!action || !("func" in action) || !action.func) throw new Error("WarpSolanaExecutor: Contract action must have a function name");
|
|
811
815
|
let programId;
|
|
812
816
|
try {
|
|
@@ -861,14 +865,14 @@ var WarpSolanaExecutor = class {
|
|
|
861
865
|
try {
|
|
862
866
|
const data = Buffer.alloc(8);
|
|
863
867
|
if (instructionDef.discriminator && Buffer.isBuffer(instructionDef.discriminator)) {
|
|
864
|
-
instructionDef.discriminator.
|
|
868
|
+
data.set(instructionDef.discriminator.subarray(0, Math.min(8, instructionDef.discriminator.length)), 0);
|
|
865
869
|
} else {
|
|
866
|
-
const hash = Buffer.from(funcName).
|
|
867
|
-
|
|
870
|
+
const hash = Buffer.from(funcName).subarray(0, 8);
|
|
871
|
+
data.set(hash, 0);
|
|
868
872
|
}
|
|
869
873
|
if (args.length > 0 && instructionDef.args) {
|
|
870
874
|
const encodedArgs = this.encodeArgs(args, instructionDef.args);
|
|
871
|
-
return Buffer.
|
|
875
|
+
return Buffer.from([...data, ...encodedArgs]);
|
|
872
876
|
}
|
|
873
877
|
return data;
|
|
874
878
|
} catch {
|
|
@@ -876,9 +880,9 @@ var WarpSolanaExecutor = class {
|
|
|
876
880
|
}
|
|
877
881
|
}
|
|
878
882
|
encodeBasicInstructionData(args, funcName) {
|
|
879
|
-
const funcHash = Buffer.from(funcName).
|
|
883
|
+
const funcHash = Buffer.from(funcName).subarray(0, 8);
|
|
880
884
|
const data = Buffer.alloc(8);
|
|
881
|
-
|
|
885
|
+
data.set(funcHash, 0);
|
|
882
886
|
if (args.length > 0) {
|
|
883
887
|
const encodedArgs = args.map((arg) => {
|
|
884
888
|
if (typeof arg === "string") {
|
|
@@ -895,7 +899,7 @@ var WarpSolanaExecutor = class {
|
|
|
895
899
|
}
|
|
896
900
|
return Buffer.from(String(arg), "utf8");
|
|
897
901
|
});
|
|
898
|
-
return Buffer.
|
|
902
|
+
return Buffer.from([...data, ...encodedArgs]);
|
|
899
903
|
}
|
|
900
904
|
return data;
|
|
901
905
|
}
|
|
@@ -909,7 +913,7 @@ var WarpSolanaExecutor = class {
|
|
|
909
913
|
const size = def.type === "u128" ? 16 : 8;
|
|
910
914
|
const buf = Buffer.alloc(size);
|
|
911
915
|
if (size === 16) {
|
|
912
|
-
buf.writeBigUInt64LE(num &
|
|
916
|
+
buf.writeBigUInt64LE(num & 0xffffffffffffffffn, 0);
|
|
913
917
|
buf.writeBigUInt64LE(num >> 64n, 8);
|
|
914
918
|
} else {
|
|
915
919
|
buf.writeBigUInt64LE(num, 0);
|
|
@@ -928,7 +932,7 @@ var WarpSolanaExecutor = class {
|
|
|
928
932
|
buffers.push(Buffer.from(String(arg), "utf8"));
|
|
929
933
|
}
|
|
930
934
|
}
|
|
931
|
-
return Buffer.
|
|
935
|
+
return Buffer.from(buffers.flatMap((buf) => Array.from(buf)));
|
|
932
936
|
}
|
|
933
937
|
buildInstructionAccounts(action, executable, fromPubkey, programId) {
|
|
934
938
|
const accounts = [
|
|
@@ -999,27 +1003,13 @@ var WarpSolanaExecutor = class {
|
|
|
999
1003
|
}
|
|
1000
1004
|
const destinationAccountInfo = await this.connection.getAccountInfo(destinationTokenAccount);
|
|
1001
1005
|
if (!destinationAccountInfo) {
|
|
1002
|
-
transaction.add(
|
|
1003
|
-
(0, import_spl_token2.createAssociatedTokenAccountInstruction)(
|
|
1004
|
-
fromPubkey,
|
|
1005
|
-
destinationTokenAccount,
|
|
1006
|
-
destinationPubkey,
|
|
1007
|
-
mintAddress
|
|
1008
|
-
)
|
|
1009
|
-
);
|
|
1006
|
+
transaction.add((0, import_spl_token2.createAssociatedTokenAccountInstruction)(fromPubkey, destinationTokenAccount, destinationPubkey, mintAddress));
|
|
1010
1007
|
}
|
|
1011
|
-
transaction.add(
|
|
1012
|
-
(0, import_spl_token2.createTransferInstruction)(
|
|
1013
|
-
sourceTokenAccount,
|
|
1014
|
-
destinationTokenAccount,
|
|
1015
|
-
fromPubkey,
|
|
1016
|
-
Number(transfer.amount)
|
|
1017
|
-
)
|
|
1018
|
-
);
|
|
1008
|
+
transaction.add((0, import_spl_token2.createTransferInstruction)(sourceTokenAccount, destinationTokenAccount, fromPubkey, Number(transfer.amount)));
|
|
1019
1009
|
return this.setTransactionDefaults(transaction, fromPubkey);
|
|
1020
1010
|
}
|
|
1021
1011
|
async executeQuery(executable) {
|
|
1022
|
-
const action = (0,
|
|
1012
|
+
const action = (0, import_warps5.getWarpActionByIndex)(executable.warp, executable.action);
|
|
1023
1013
|
if (action.type !== "query") throw new Error(`WarpSolanaExecutor: Invalid action type for executeQuery: ${action.type}`);
|
|
1024
1014
|
if (!action.func) throw new Error("WarpSolanaExecutor: Query action must have a function name");
|
|
1025
1015
|
let queryAddress;
|
|
@@ -1071,38 +1061,34 @@ var WarpSolanaExecutor = class {
|
|
|
1071
1061
|
executable.action,
|
|
1072
1062
|
executable.resolvedInputs
|
|
1073
1063
|
);
|
|
1074
|
-
const next = (0,
|
|
1075
|
-
const destinationInput = executable.resolvedInputs.find(
|
|
1076
|
-
(i) => i.input.position === "receiver" || i.input.position === "destination"
|
|
1077
|
-
);
|
|
1064
|
+
const next = (0, import_warps5.getNextInfo)(this.config, [], executable.warp, executable.action, output);
|
|
1065
|
+
const destinationInput = executable.resolvedInputs.find((i) => i.input.position === "receiver" || i.input.position === "destination");
|
|
1078
1066
|
const destination = destinationInput?.value || executable.destination;
|
|
1079
|
-
const resolvedInputs = (0,
|
|
1067
|
+
const resolvedInputs = (0, import_warps5.extractResolvedInputValues)(executable.resolvedInputs);
|
|
1080
1068
|
return {
|
|
1081
1069
|
status: isSuccess ? "success" : "error",
|
|
1082
1070
|
warp: executable.warp,
|
|
1083
1071
|
action: executable.action,
|
|
1084
|
-
user: (0,
|
|
1072
|
+
user: (0, import_warps5.getWarpWalletAddressFromConfig)(this.config, executable.chain.name),
|
|
1085
1073
|
txHash: null,
|
|
1086
1074
|
tx: null,
|
|
1087
1075
|
next,
|
|
1088
1076
|
values,
|
|
1089
1077
|
output: { ...output, _DATA: decodedResult },
|
|
1090
|
-
messages: (0,
|
|
1078
|
+
messages: (0, import_warps5.applyOutputToMessages)(executable.warp, output, this.config),
|
|
1091
1079
|
destination,
|
|
1092
1080
|
resolvedInputs
|
|
1093
1081
|
};
|
|
1094
1082
|
} catch (error) {
|
|
1095
1083
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1096
|
-
const destinationInput = executable.resolvedInputs.find(
|
|
1097
|
-
(i) => i.input.position === "receiver" || i.input.position === "destination"
|
|
1098
|
-
);
|
|
1084
|
+
const destinationInput = executable.resolvedInputs.find((i) => i.input.position === "receiver" || i.input.position === "destination");
|
|
1099
1085
|
const destination = destinationInput?.value || executable.destination;
|
|
1100
|
-
const resolvedInputs = (0,
|
|
1086
|
+
const resolvedInputs = (0, import_warps5.extractResolvedInputValues)(executable.resolvedInputs);
|
|
1101
1087
|
return {
|
|
1102
1088
|
status: "error",
|
|
1103
1089
|
warp: executable.warp,
|
|
1104
1090
|
action: executable.action,
|
|
1105
|
-
user: (0,
|
|
1091
|
+
user: (0, import_warps5.getWarpWalletAddressFromConfig)(this.config, executable.chain.name),
|
|
1106
1092
|
txHash: null,
|
|
1107
1093
|
tx: null,
|
|
1108
1094
|
next: null,
|
|
@@ -1131,12 +1117,8 @@ var WarpSolanaExecutor = class {
|
|
|
1131
1117
|
transaction.feePayer = fromPubkey;
|
|
1132
1118
|
}
|
|
1133
1119
|
const instructions = transaction.instructions;
|
|
1134
|
-
const hasTransfer = instructions.some(
|
|
1135
|
-
|
|
1136
|
-
);
|
|
1137
|
-
const hasTokenTransfer = instructions.some(
|
|
1138
|
-
(ix) => ix.programId.toBase58() === WarpSolanaConstants.Programs.TokenProgram
|
|
1139
|
-
);
|
|
1120
|
+
const hasTransfer = instructions.some((ix) => ix.programId.equals(import_web34.SystemProgram.programId) && ix.data.length === 4);
|
|
1121
|
+
const hasTokenTransfer = instructions.some((ix) => ix.programId.toBase58() === WarpSolanaConstants.Programs.TokenProgram);
|
|
1140
1122
|
let computeUnits = WarpSolanaConstants.ComputeUnitLimit.Default;
|
|
1141
1123
|
if (hasTransfer && !hasTokenTransfer) {
|
|
1142
1124
|
computeUnits = WarpSolanaConstants.ComputeUnitLimit.Transfer;
|
|
@@ -1289,7 +1271,7 @@ var WarpSolanaExplorer = class {
|
|
|
1289
1271
|
};
|
|
1290
1272
|
|
|
1291
1273
|
// src/WarpSolanaWallet.ts
|
|
1292
|
-
var
|
|
1274
|
+
var import_warps6 = require("@vleap/warps");
|
|
1293
1275
|
var import_web35 = require("@solana/web3.js");
|
|
1294
1276
|
var bip39 = __toESM(require("@scure/bip39"), 1);
|
|
1295
1277
|
var import_english = require("@scure/bip39/wordlists/english");
|
|
@@ -1298,7 +1280,7 @@ var WarpSolanaWallet = class {
|
|
|
1298
1280
|
constructor(config, chain) {
|
|
1299
1281
|
this.config = config;
|
|
1300
1282
|
this.chain = chain;
|
|
1301
|
-
const providerConfig = (0,
|
|
1283
|
+
const providerConfig = (0, import_warps6.getProviderConfig)(config, chain.name, config.env, chain.defaultApiUrl);
|
|
1302
1284
|
this.connection = new import_web35.Connection(providerConfig.url, "confirmed");
|
|
1303
1285
|
}
|
|
1304
1286
|
async signTransaction(tx) {
|
|
@@ -1438,7 +1420,7 @@ var WarpSolanaWallet = class {
|
|
|
1438
1420
|
}
|
|
1439
1421
|
}
|
|
1440
1422
|
getKeypair() {
|
|
1441
|
-
const privateKey = (0,
|
|
1423
|
+
const privateKey = (0, import_warps6.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
|
|
1442
1424
|
if (privateKey) {
|
|
1443
1425
|
try {
|
|
1444
1426
|
const secretKey = import_bs582.default.decode(privateKey);
|
|
@@ -1456,7 +1438,7 @@ var WarpSolanaWallet = class {
|
|
|
1456
1438
|
throw new Error("Invalid private key format");
|
|
1457
1439
|
}
|
|
1458
1440
|
}
|
|
1459
|
-
const mnemonic = (0,
|
|
1441
|
+
const mnemonic = (0, import_warps6.getWarpWalletMnemonicFromConfig)(this.config, this.chain.name);
|
|
1460
1442
|
if (mnemonic) {
|
|
1461
1443
|
const seed = bip39.mnemonicToSeedSync(mnemonic);
|
|
1462
1444
|
return import_web35.Keypair.fromSeed(seed.slice(0, 32));
|
|
@@ -1487,16 +1469,16 @@ var createSolanaAdapter = (chainName, chainInfos) => {
|
|
|
1487
1469
|
|
|
1488
1470
|
// src/chains/solana.ts
|
|
1489
1471
|
var NativeTokenSol = {
|
|
1490
|
-
chain:
|
|
1472
|
+
chain: import_warps7.WarpChainName.Solana,
|
|
1491
1473
|
identifier: "SOL",
|
|
1492
1474
|
symbol: "SOL",
|
|
1493
1475
|
name: "Solana",
|
|
1494
1476
|
decimals: 9,
|
|
1495
1477
|
logoUrl: "https://vleap.ai/images/tokens/sol.svg"
|
|
1496
1478
|
};
|
|
1497
|
-
var getSolanaAdapter = createSolanaAdapter(
|
|
1479
|
+
var getSolanaAdapter = createSolanaAdapter(import_warps7.WarpChainName.Solana, {
|
|
1498
1480
|
mainnet: {
|
|
1499
|
-
name:
|
|
1481
|
+
name: import_warps7.WarpChainName.Solana,
|
|
1500
1482
|
displayName: "Solana Mainnet",
|
|
1501
1483
|
chainId: "101",
|
|
1502
1484
|
blockTime: 400,
|
|
@@ -1506,7 +1488,7 @@ var getSolanaAdapter = createSolanaAdapter("solana", {
|
|
|
1506
1488
|
nativeToken: NativeTokenSol
|
|
1507
1489
|
},
|
|
1508
1490
|
testnet: {
|
|
1509
|
-
name:
|
|
1491
|
+
name: import_warps7.WarpChainName.Solana,
|
|
1510
1492
|
displayName: "Solana Testnet",
|
|
1511
1493
|
chainId: "103",
|
|
1512
1494
|
blockTime: 400,
|
|
@@ -1516,7 +1498,7 @@ var getSolanaAdapter = createSolanaAdapter("solana", {
|
|
|
1516
1498
|
nativeToken: NativeTokenSol
|
|
1517
1499
|
},
|
|
1518
1500
|
devnet: {
|
|
1519
|
-
name:
|
|
1501
|
+
name: import_warps7.WarpChainName.Solana,
|
|
1520
1502
|
displayName: "Solana Devnet",
|
|
1521
1503
|
chainId: "103",
|
|
1522
1504
|
blockTime: 400,
|