@vleap/warps-adapter-evm 0.2.0-beta.51 → 0.2.0-beta.52
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 +60 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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,
|
|
@@ -993,11 +993,16 @@ var WarpEvmExecutor = class {
|
|
|
993
993
|
} catch {
|
|
994
994
|
iface = new ethers4.Interface([action.abi]);
|
|
995
995
|
}
|
|
996
|
-
const
|
|
996
|
+
const funcFragment = iface.getFunction(action.func);
|
|
997
|
+
if (!funcFragment) throw new Error(`WarpEvmExecutor: Function ${action.func} not found in ABI`);
|
|
998
|
+
const nativeArgs = this.prepareNativeArgs(executable.args, funcFragment);
|
|
997
999
|
const encodedData = iface.encodeFunctionData(action.func, nativeArgs);
|
|
1000
|
+
const value = this.getPayableValue(executable, funcFragment);
|
|
1001
|
+
console.log("Encoded data:", encodedData);
|
|
1002
|
+
console.log("Value:", value);
|
|
998
1003
|
const tx = {
|
|
999
1004
|
to: executable.destination,
|
|
1000
|
-
value
|
|
1005
|
+
value,
|
|
1001
1006
|
data: encodedData
|
|
1002
1007
|
};
|
|
1003
1008
|
return this.estimateGasAndSetDefaults(tx, userWallet);
|
|
@@ -1051,7 +1056,9 @@ var WarpEvmExecutor = class {
|
|
|
1051
1056
|
} catch {
|
|
1052
1057
|
iface = new ethers4.Interface([action.abi]);
|
|
1053
1058
|
}
|
|
1054
|
-
const
|
|
1059
|
+
const funcFragment = iface.getFunction(action.func);
|
|
1060
|
+
if (!funcFragment) throw new Error(`WarpEvmExecutor: Function ${action.func} not found in ABI`);
|
|
1061
|
+
const nativeArgs = this.prepareNativeArgs(executable.args, funcFragment);
|
|
1055
1062
|
const encodedData = iface.encodeFunctionData(action.func, nativeArgs);
|
|
1056
1063
|
const result = await this.provider.call({
|
|
1057
1064
|
to: executable.destination,
|
|
@@ -1066,9 +1073,7 @@ var WarpEvmExecutor = class {
|
|
|
1066
1073
|
executable.resolvedInputs
|
|
1067
1074
|
);
|
|
1068
1075
|
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
|
-
);
|
|
1076
|
+
const destinationInput = executable.resolvedInputs.find((i) => i.input.position === "receiver" || i.input.position === "destination");
|
|
1072
1077
|
const destination = destinationInput?.value || executable.destination;
|
|
1073
1078
|
const resolvedInputs = extractResolvedInputValues2(executable.resolvedInputs);
|
|
1074
1079
|
return {
|
|
@@ -1086,9 +1091,7 @@ var WarpEvmExecutor = class {
|
|
|
1086
1091
|
resolvedInputs
|
|
1087
1092
|
};
|
|
1088
1093
|
} catch (error) {
|
|
1089
|
-
const destinationInput = executable.resolvedInputs.find(
|
|
1090
|
-
(i) => i.input.position === "receiver" || i.input.position === "destination"
|
|
1091
|
-
);
|
|
1094
|
+
const destinationInput = executable.resolvedInputs.find((i) => i.input.position === "receiver" || i.input.position === "destination");
|
|
1092
1095
|
const destination = destinationInput?.value || executable.destination;
|
|
1093
1096
|
const resolvedInputs = extractResolvedInputValues2(executable.resolvedInputs);
|
|
1094
1097
|
return {
|
|
@@ -1166,6 +1169,53 @@ var WarpEvmExecutor = class {
|
|
|
1166
1169
|
throw new Error(`Failed to verify message: ${error}`);
|
|
1167
1170
|
}
|
|
1168
1171
|
}
|
|
1172
|
+
getPayableValue(executable, funcFragment) {
|
|
1173
|
+
if (funcFragment.stateMutability !== "payable") {
|
|
1174
|
+
return executable.value;
|
|
1175
|
+
}
|
|
1176
|
+
const nativeTokenId = this.chain.nativeToken?.identifier;
|
|
1177
|
+
const zeroAddress = "0x0000000000000000000000000000000000000000";
|
|
1178
|
+
const nativeTokenTransfer = nativeTokenId ? executable.transfers.find((transfer) => transfer.identifier === nativeTokenId || transfer.identifier === zeroAddress) : void 0;
|
|
1179
|
+
if (nativeTokenTransfer) {
|
|
1180
|
+
return nativeTokenTransfer.amount;
|
|
1181
|
+
}
|
|
1182
|
+
const nativeTokenAsset = this.findNativeTokenAsset(executable.resolvedInputs, nativeTokenId, zeroAddress);
|
|
1183
|
+
if (nativeTokenAsset) {
|
|
1184
|
+
return nativeTokenAsset.amount;
|
|
1185
|
+
}
|
|
1186
|
+
return executable.value;
|
|
1187
|
+
}
|
|
1188
|
+
findNativeTokenAsset(resolvedInputs, nativeTokenId, zeroAddress) {
|
|
1189
|
+
for (const input of resolvedInputs) {
|
|
1190
|
+
if (input.input.type === "asset" && input.value) {
|
|
1191
|
+
const [, assetValue] = this.serializer.coreSerializer.stringToNative(input.value);
|
|
1192
|
+
const asset = assetValue;
|
|
1193
|
+
if (asset && "amount" in asset) {
|
|
1194
|
+
if (asset.identifier === nativeTokenId || asset.identifier === zeroAddress) {
|
|
1195
|
+
return asset;
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
return null;
|
|
1201
|
+
}
|
|
1202
|
+
prepareNativeArgs(args, funcFragment) {
|
|
1203
|
+
return args.map((arg, index) => {
|
|
1204
|
+
const nativeValue = this.serializer.coreSerializer.stringToNative(arg)[1];
|
|
1205
|
+
const paramType = funcFragment.inputs[index]?.type;
|
|
1206
|
+
if (paramType === "bytes32" && typeof nativeValue === "string") {
|
|
1207
|
+
let hexValue = nativeValue;
|
|
1208
|
+
if (!hexValue.startsWith("0x")) {
|
|
1209
|
+
hexValue = "0x" + hexValue;
|
|
1210
|
+
}
|
|
1211
|
+
if (hexValue.length !== 66) {
|
|
1212
|
+
hexValue = ethers4.zeroPadValue(hexValue, 32);
|
|
1213
|
+
}
|
|
1214
|
+
return hexValue;
|
|
1215
|
+
}
|
|
1216
|
+
return nativeValue;
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1169
1219
|
};
|
|
1170
1220
|
|
|
1171
1221
|
// src/WarpEvmExplorer.ts
|