@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.d.cts
CHANGED
|
@@ -175,6 +175,9 @@ declare class WarpEvmExecutor implements AdapterWarpExecutor {
|
|
|
175
175
|
executeQuery(executable: WarpExecutable): Promise<WarpActionExecutionResult>;
|
|
176
176
|
private estimateGasAndSetDefaults;
|
|
177
177
|
verifyMessage(message: string, signature: string): Promise<string>;
|
|
178
|
+
private getPayableValue;
|
|
179
|
+
private findNativeTokenAsset;
|
|
180
|
+
private prepareNativeArgs;
|
|
178
181
|
}
|
|
179
182
|
|
|
180
183
|
declare class WarpEvmExplorer implements AdapterWarpExplorer {
|
package/dist/index.d.ts
CHANGED
|
@@ -175,6 +175,9 @@ declare class WarpEvmExecutor implements AdapterWarpExecutor {
|
|
|
175
175
|
executeQuery(executable: WarpExecutable): Promise<WarpActionExecutionResult>;
|
|
176
176
|
private estimateGasAndSetDefaults;
|
|
177
177
|
verifyMessage(message: string, signature: string): Promise<string>;
|
|
178
|
+
private getPayableValue;
|
|
179
|
+
private findNativeTokenAsset;
|
|
180
|
+
private prepareNativeArgs;
|
|
178
181
|
}
|
|
179
182
|
|
|
180
183
|
declare class WarpEvmExplorer implements AdapterWarpExplorer {
|
package/dist/index.js
CHANGED
|
@@ -599,7 +599,7 @@ var WarpEvmConstants = {
|
|
|
599
599
|
Swap: 2e5
|
|
600
600
|
},
|
|
601
601
|
GasPrice: {
|
|
602
|
-
Default: "
|
|
602
|
+
Default: "1200010"
|
|
603
603
|
},
|
|
604
604
|
Validation: {
|
|
605
605
|
MinGasLimit: 21e3,
|
|
@@ -732,7 +732,8 @@ var WarpEvmSerializer = class {
|
|
|
732
732
|
case "address":
|
|
733
733
|
return String(value);
|
|
734
734
|
case "hex":
|
|
735
|
-
|
|
735
|
+
const hexValue = String(value);
|
|
736
|
+
return hexValue.startsWith("0x") ? hexValue : `0x${hexValue}`;
|
|
736
737
|
default:
|
|
737
738
|
if (type.startsWith("list:")) {
|
|
738
739
|
const [, itemType, itemsStr] = type.split(":");
|
|
@@ -784,7 +785,7 @@ var WarpEvmSerializer = class {
|
|
|
784
785
|
case "address":
|
|
785
786
|
return stringValue;
|
|
786
787
|
case "hex":
|
|
787
|
-
return stringValue
|
|
788
|
+
return stringValue.startsWith("0x") ? stringValue : `0x${stringValue}`;
|
|
788
789
|
default:
|
|
789
790
|
if (type.startsWith("list:")) {
|
|
790
791
|
const [, itemType, itemsStr] = type.split(":");
|
|
@@ -1019,11 +1020,17 @@ var WarpEvmExecutor = class {
|
|
|
1019
1020
|
} catch {
|
|
1020
1021
|
iface = new import_ethers4.ethers.Interface([action.abi]);
|
|
1021
1022
|
}
|
|
1022
|
-
const
|
|
1023
|
+
const funcFragment = iface.getFunction(action.func);
|
|
1024
|
+
if (!funcFragment) throw new Error(`WarpEvmExecutor: Function ${action.func} not found in ABI`);
|
|
1025
|
+
const nativeArgs = this.prepareNativeArgs(executable.args, funcFragment);
|
|
1026
|
+
console.log("Native args:", nativeArgs);
|
|
1023
1027
|
const encodedData = iface.encodeFunctionData(action.func, nativeArgs);
|
|
1028
|
+
const value = this.getPayableValue(executable, funcFragment);
|
|
1029
|
+
console.log("Encoded data:", encodedData);
|
|
1030
|
+
console.log("Value:", value);
|
|
1024
1031
|
const tx = {
|
|
1025
1032
|
to: executable.destination,
|
|
1026
|
-
value
|
|
1033
|
+
value,
|
|
1027
1034
|
data: encodedData
|
|
1028
1035
|
};
|
|
1029
1036
|
return this.estimateGasAndSetDefaults(tx, userWallet);
|
|
@@ -1077,7 +1084,9 @@ var WarpEvmExecutor = class {
|
|
|
1077
1084
|
} catch {
|
|
1078
1085
|
iface = new import_ethers4.ethers.Interface([action.abi]);
|
|
1079
1086
|
}
|
|
1080
|
-
const
|
|
1087
|
+
const funcFragment = iface.getFunction(action.func);
|
|
1088
|
+
if (!funcFragment) throw new Error(`WarpEvmExecutor: Function ${action.func} not found in ABI`);
|
|
1089
|
+
const nativeArgs = this.prepareNativeArgs(executable.args, funcFragment);
|
|
1081
1090
|
const encodedData = iface.encodeFunctionData(action.func, nativeArgs);
|
|
1082
1091
|
const result = await this.provider.call({
|
|
1083
1092
|
to: executable.destination,
|
|
@@ -1092,9 +1101,7 @@ var WarpEvmExecutor = class {
|
|
|
1092
1101
|
executable.resolvedInputs
|
|
1093
1102
|
);
|
|
1094
1103
|
const next = (0, import_warps11.getNextInfo)(this.config, [], executable.warp, executable.action, output);
|
|
1095
|
-
const destinationInput = executable.resolvedInputs.find(
|
|
1096
|
-
(i) => i.input.position === "receiver" || i.input.position === "destination"
|
|
1097
|
-
);
|
|
1104
|
+
const destinationInput = executable.resolvedInputs.find((i) => i.input.position === "receiver" || i.input.position === "destination");
|
|
1098
1105
|
const destination = destinationInput?.value || executable.destination;
|
|
1099
1106
|
const resolvedInputs = (0, import_warps11.extractResolvedInputValues)(executable.resolvedInputs);
|
|
1100
1107
|
return {
|
|
@@ -1112,9 +1119,7 @@ var WarpEvmExecutor = class {
|
|
|
1112
1119
|
resolvedInputs
|
|
1113
1120
|
};
|
|
1114
1121
|
} catch (error) {
|
|
1115
|
-
const destinationInput = executable.resolvedInputs.find(
|
|
1116
|
-
(i) => i.input.position === "receiver" || i.input.position === "destination"
|
|
1117
|
-
);
|
|
1122
|
+
const destinationInput = executable.resolvedInputs.find((i) => i.input.position === "receiver" || i.input.position === "destination");
|
|
1118
1123
|
const destination = destinationInput?.value || executable.destination;
|
|
1119
1124
|
const resolvedInputs = (0, import_warps11.extractResolvedInputValues)(executable.resolvedInputs);
|
|
1120
1125
|
return {
|
|
@@ -1192,6 +1197,53 @@ var WarpEvmExecutor = class {
|
|
|
1192
1197
|
throw new Error(`Failed to verify message: ${error}`);
|
|
1193
1198
|
}
|
|
1194
1199
|
}
|
|
1200
|
+
getPayableValue(executable, funcFragment) {
|
|
1201
|
+
if (funcFragment.stateMutability !== "payable") {
|
|
1202
|
+
return executable.value;
|
|
1203
|
+
}
|
|
1204
|
+
const nativeTokenId = this.chain.nativeToken?.identifier;
|
|
1205
|
+
const zeroAddress = "0x0000000000000000000000000000000000000000";
|
|
1206
|
+
const nativeTokenTransfer = nativeTokenId ? executable.transfers.find((transfer) => transfer.identifier === nativeTokenId || transfer.identifier === zeroAddress) : void 0;
|
|
1207
|
+
if (nativeTokenTransfer) {
|
|
1208
|
+
return nativeTokenTransfer.amount;
|
|
1209
|
+
}
|
|
1210
|
+
const nativeTokenAsset = this.findNativeTokenAsset(executable.resolvedInputs, nativeTokenId, zeroAddress);
|
|
1211
|
+
if (nativeTokenAsset) {
|
|
1212
|
+
return nativeTokenAsset.amount;
|
|
1213
|
+
}
|
|
1214
|
+
return executable.value;
|
|
1215
|
+
}
|
|
1216
|
+
findNativeTokenAsset(resolvedInputs, nativeTokenId, zeroAddress) {
|
|
1217
|
+
for (const input of resolvedInputs) {
|
|
1218
|
+
if (input.input.type === "asset" && input.value) {
|
|
1219
|
+
const [, assetValue] = this.serializer.coreSerializer.stringToNative(input.value);
|
|
1220
|
+
const asset = assetValue;
|
|
1221
|
+
if (asset && "amount" in asset) {
|
|
1222
|
+
if (asset.identifier === nativeTokenId || asset.identifier === zeroAddress) {
|
|
1223
|
+
return asset;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
return null;
|
|
1229
|
+
}
|
|
1230
|
+
prepareNativeArgs(args, funcFragment) {
|
|
1231
|
+
return args.map((arg, index) => {
|
|
1232
|
+
const nativeValue = this.serializer.coreSerializer.stringToNative(arg)[1];
|
|
1233
|
+
const paramType = funcFragment.inputs[index]?.type;
|
|
1234
|
+
if (paramType === "bytes32" && typeof nativeValue === "string") {
|
|
1235
|
+
let hexValue = nativeValue;
|
|
1236
|
+
if (!hexValue.startsWith("0x")) {
|
|
1237
|
+
hexValue = "0x" + hexValue;
|
|
1238
|
+
}
|
|
1239
|
+
if (hexValue.length !== 66) {
|
|
1240
|
+
hexValue = import_ethers4.ethers.zeroPadValue(hexValue, 32);
|
|
1241
|
+
}
|
|
1242
|
+
return hexValue;
|
|
1243
|
+
}
|
|
1244
|
+
return nativeValue;
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1195
1247
|
};
|
|
1196
1248
|
|
|
1197
1249
|
// src/WarpEvmExplorer.ts
|