@vleap/warps-adapter-evm 0.2.0-beta.51 → 0.2.0-beta.53
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.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +64 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -561,7 +561,7 @@ var WarpEvmConstants = {
|
|
|
561
561
|
Swap: 2e5
|
|
562
562
|
},
|
|
563
563
|
GasPrice: {
|
|
564
|
-
Default: "
|
|
564
|
+
Default: "1200010"
|
|
565
565
|
},
|
|
566
566
|
Validation: {
|
|
567
567
|
MinGasLimit: 21e3,
|
|
@@ -706,7 +706,8 @@ var WarpEvmSerializer = class {
|
|
|
706
706
|
case "address":
|
|
707
707
|
return String(value);
|
|
708
708
|
case "hex":
|
|
709
|
-
|
|
709
|
+
const hexValue = String(value);
|
|
710
|
+
return hexValue.startsWith("0x") ? hexValue : `0x${hexValue}`;
|
|
710
711
|
default:
|
|
711
712
|
if (type.startsWith("list:")) {
|
|
712
713
|
const [, itemType, itemsStr] = type.split(":");
|
|
@@ -758,7 +759,7 @@ var WarpEvmSerializer = class {
|
|
|
758
759
|
case "address":
|
|
759
760
|
return stringValue;
|
|
760
761
|
case "hex":
|
|
761
|
-
return stringValue
|
|
762
|
+
return stringValue.startsWith("0x") ? stringValue : `0x${stringValue}`;
|
|
762
763
|
default:
|
|
763
764
|
if (type.startsWith("list:")) {
|
|
764
765
|
const [, itemType, itemsStr] = type.split(":");
|
|
@@ -993,11 +994,17 @@ var WarpEvmExecutor = class {
|
|
|
993
994
|
} catch {
|
|
994
995
|
iface = new ethers4.Interface([action.abi]);
|
|
995
996
|
}
|
|
996
|
-
const
|
|
997
|
+
const funcFragment = iface.getFunction(action.func);
|
|
998
|
+
if (!funcFragment) throw new Error(`WarpEvmExecutor: Function ${action.func} not found in ABI`);
|
|
999
|
+
const nativeArgs = this.prepareNativeArgs(executable.args, funcFragment);
|
|
1000
|
+
console.log("Native args:", nativeArgs);
|
|
997
1001
|
const encodedData = iface.encodeFunctionData(action.func, nativeArgs);
|
|
1002
|
+
const value = this.getPayableValue(executable, funcFragment);
|
|
1003
|
+
console.log("Encoded data:", encodedData);
|
|
1004
|
+
console.log("Value:", value);
|
|
998
1005
|
const tx = {
|
|
999
1006
|
to: executable.destination,
|
|
1000
|
-
value
|
|
1007
|
+
value,
|
|
1001
1008
|
data: encodedData
|
|
1002
1009
|
};
|
|
1003
1010
|
return this.estimateGasAndSetDefaults(tx, userWallet);
|
|
@@ -1051,7 +1058,9 @@ var WarpEvmExecutor = class {
|
|
|
1051
1058
|
} catch {
|
|
1052
1059
|
iface = new ethers4.Interface([action.abi]);
|
|
1053
1060
|
}
|
|
1054
|
-
const
|
|
1061
|
+
const funcFragment = iface.getFunction(action.func);
|
|
1062
|
+
if (!funcFragment) throw new Error(`WarpEvmExecutor: Function ${action.func} not found in ABI`);
|
|
1063
|
+
const nativeArgs = this.prepareNativeArgs(executable.args, funcFragment);
|
|
1055
1064
|
const encodedData = iface.encodeFunctionData(action.func, nativeArgs);
|
|
1056
1065
|
const result = await this.provider.call({
|
|
1057
1066
|
to: executable.destination,
|
|
@@ -1066,9 +1075,7 @@ var WarpEvmExecutor = class {
|
|
|
1066
1075
|
executable.resolvedInputs
|
|
1067
1076
|
);
|
|
1068
1077
|
const next = getNextInfo(this.config, [], executable.warp, executable.action, output);
|
|
1069
|
-
const destinationInput = executable.resolvedInputs.find(
|
|
1070
|
-
(i) => i.input.position === "receiver" || i.input.position === "destination"
|
|
1071
|
-
);
|
|
1078
|
+
const destinationInput = executable.resolvedInputs.find((i) => i.input.position === "receiver" || i.input.position === "destination");
|
|
1072
1079
|
const destination = destinationInput?.value || executable.destination;
|
|
1073
1080
|
const resolvedInputs = extractResolvedInputValues2(executable.resolvedInputs);
|
|
1074
1081
|
return {
|
|
@@ -1086,9 +1093,7 @@ var WarpEvmExecutor = class {
|
|
|
1086
1093
|
resolvedInputs
|
|
1087
1094
|
};
|
|
1088
1095
|
} catch (error) {
|
|
1089
|
-
const destinationInput = executable.resolvedInputs.find(
|
|
1090
|
-
(i) => i.input.position === "receiver" || i.input.position === "destination"
|
|
1091
|
-
);
|
|
1096
|
+
const destinationInput = executable.resolvedInputs.find((i) => i.input.position === "receiver" || i.input.position === "destination");
|
|
1092
1097
|
const destination = destinationInput?.value || executable.destination;
|
|
1093
1098
|
const resolvedInputs = extractResolvedInputValues2(executable.resolvedInputs);
|
|
1094
1099
|
return {
|
|
@@ -1166,6 +1171,53 @@ var WarpEvmExecutor = class {
|
|
|
1166
1171
|
throw new Error(`Failed to verify message: ${error}`);
|
|
1167
1172
|
}
|
|
1168
1173
|
}
|
|
1174
|
+
getPayableValue(executable, funcFragment) {
|
|
1175
|
+
if (funcFragment.stateMutability !== "payable") {
|
|
1176
|
+
return executable.value;
|
|
1177
|
+
}
|
|
1178
|
+
const nativeTokenId = this.chain.nativeToken?.identifier;
|
|
1179
|
+
const zeroAddress = "0x0000000000000000000000000000000000000000";
|
|
1180
|
+
const nativeTokenTransfer = nativeTokenId ? executable.transfers.find((transfer) => transfer.identifier === nativeTokenId || transfer.identifier === zeroAddress) : void 0;
|
|
1181
|
+
if (nativeTokenTransfer) {
|
|
1182
|
+
return nativeTokenTransfer.amount;
|
|
1183
|
+
}
|
|
1184
|
+
const nativeTokenAsset = this.findNativeTokenAsset(executable.resolvedInputs, nativeTokenId, zeroAddress);
|
|
1185
|
+
if (nativeTokenAsset) {
|
|
1186
|
+
return nativeTokenAsset.amount;
|
|
1187
|
+
}
|
|
1188
|
+
return executable.value;
|
|
1189
|
+
}
|
|
1190
|
+
findNativeTokenAsset(resolvedInputs, nativeTokenId, zeroAddress) {
|
|
1191
|
+
for (const input of resolvedInputs) {
|
|
1192
|
+
if (input.input.type === "asset" && input.value) {
|
|
1193
|
+
const [, assetValue] = this.serializer.coreSerializer.stringToNative(input.value);
|
|
1194
|
+
const asset = assetValue;
|
|
1195
|
+
if (asset && "amount" in asset) {
|
|
1196
|
+
if (asset.identifier === nativeTokenId || asset.identifier === zeroAddress) {
|
|
1197
|
+
return asset;
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
return null;
|
|
1203
|
+
}
|
|
1204
|
+
prepareNativeArgs(args, funcFragment) {
|
|
1205
|
+
return args.map((arg, index) => {
|
|
1206
|
+
const nativeValue = this.serializer.coreSerializer.stringToNative(arg)[1];
|
|
1207
|
+
const paramType = funcFragment.inputs[index]?.type;
|
|
1208
|
+
if (paramType === "bytes32" && typeof nativeValue === "string") {
|
|
1209
|
+
let hexValue = nativeValue;
|
|
1210
|
+
if (!hexValue.startsWith("0x")) {
|
|
1211
|
+
hexValue = "0x" + hexValue;
|
|
1212
|
+
}
|
|
1213
|
+
if (hexValue.length !== 66) {
|
|
1214
|
+
hexValue = ethers4.zeroPadValue(hexValue, 32);
|
|
1215
|
+
}
|
|
1216
|
+
return hexValue;
|
|
1217
|
+
}
|
|
1218
|
+
return nativeValue;
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1169
1221
|
};
|
|
1170
1222
|
|
|
1171
1223
|
// src/WarpEvmExplorer.ts
|