소스 검색

refactor(express-relay): Update execution params hash data (#1476)

Dani Mehrjerdi 1 년 전
부모
커밋
bdc2e967b0
2개의 변경된 파일33개의 추가작업 그리고 45개의 파일을 삭제
  1. 11 16
      express_relay/sdk/js/src/index.ts
  2. 22 29
      express_relay/sdk/python/express_relay/client.py

+ 11 - 16
express_relay/sdk/js/src/index.ts

@@ -300,17 +300,14 @@ export class Client {
     privateKey: Hex
   ): Promise<OpportunityBid> {
     const types = {
-      SignedParams: [
-        { name: "executionParams", type: "ExecutionParams" },
-        { name: "signer", type: "address" },
-        { name: "deadline", type: "uint256" },
-      ],
       ExecutionParams: [
         { name: "sellTokens", type: "TokenAmount[]" },
         { name: "buyTokens", type: "TokenAmount[]" },
+        { name: "executor", type: "address" },
         { name: "targetContract", type: "address" },
         { name: "targetCalldata", type: "bytes" },
         { name: "targetCallValue", type: "uint256" },
+        { name: "validUntil", type: "uint256" },
         { name: "bidAmount", type: "uint256" },
       ],
       TokenAmount: [
@@ -327,18 +324,16 @@ export class Client {
         chainId: Number(opportunity.eip712Domain.chainId),
       },
       types,
-      primaryType: "SignedParams",
+      primaryType: "ExecutionParams",
       message: {
-        executionParams: {
-          sellTokens: opportunity.sellTokens,
-          buyTokens: opportunity.buyTokens,
-          targetContract: opportunity.targetContract,
-          targetCalldata: opportunity.targetCalldata,
-          targetCallValue: opportunity.targetCallValue,
-          bidAmount: bidParams.amount,
-        },
-        signer: account.address,
-        deadline: bidParams.validUntil,
+        sellTokens: opportunity.sellTokens,
+        buyTokens: opportunity.buyTokens,
+        executor: account.address,
+        targetContract: opportunity.targetContract,
+        targetCalldata: opportunity.targetCalldata,
+        targetCallValue: opportunity.targetCallValue,
+        validUntil: bidParams.validUntil,
+        bidAmount: bidParams.amount,
       },
     });
 

+ 22 - 29
express_relay/sdk/python/express_relay/client.py

@@ -411,17 +411,14 @@ def sign_bid(
         "verifyingContract": opportunity.eip_712_domain.verifying_contract,
     }
     message_types = {
-        "SignedParams": [
-            {"name": "executionParams", "type": "ExecutionParams"},
-            {"name": "signer", "type": "address"},
-            {"name": "deadline", "type": "uint256"},
-        ],
         "ExecutionParams": [
             {"name": "sellTokens", "type": "TokenAmount[]"},
             {"name": "buyTokens", "type": "TokenAmount[]"},
+            {"name": "executor", "type": "address"},
             {"name": "targetContract", "type": "address"},
             {"name": "targetCalldata", "type": "bytes"},
             {"name": "targetCallValue", "type": "uint256"},
+            {"name": "validUntil", "type": "uint256"},
             {"name": "bidAmount", "type": "uint256"},
         ],
         "TokenAmount": [
@@ -432,30 +429,26 @@ def sign_bid(
 
     # the data to be signed
     message_data = {
-        "executionParams": {
-            "sellTokens": [
-                {
-                    "token": token.token,
-                    "amount": int(token.amount),
-                }
-                for token in opportunity.sell_tokens
-            ],
-            "buyTokens": [
-                {
-                    "token": token.token,
-                    "amount": int(token.amount),
-                }
-                for token in opportunity.buy_tokens
-            ],
-            "targetContract": opportunity.target_contract,
-            "targetCalldata": bytes.fromhex(
-                opportunity.target_calldata.replace("0x", "")
-            ),
-            "targetCallValue": opportunity.target_call_value,
-            "bidAmount": bid_amount,
-        },
-        "signer": executor,
-        "deadline": valid_until,
+        "sellTokens": [
+            {
+                "token": token.token,
+                "amount": int(token.amount),
+            }
+            for token in opportunity.sell_tokens
+        ],
+        "buyTokens": [
+            {
+                "token": token.token,
+                "amount": int(token.amount),
+            }
+            for token in opportunity.buy_tokens
+        ],
+        "executor": executor,
+        "targetContract": opportunity.target_contract,
+        "targetCalldata": bytes.fromhex(opportunity.target_calldata.replace("0x", "")),
+        "targetCallValue": opportunity.target_call_value,
+        "validUntil": valid_until,
+        "bidAmount": bid_amount,
     }
 
     signed_typed_data = Account.sign_typed_data(