From 5cd84407330773f0ded19a52ac5c01a049f202c0 Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Wed, 26 Jun 2024 17:24:24 +0200 Subject: [PATCH] fix(client): send forms as json fix(verify): encode `sourceCode` as embeddable JSON fix(verify): use GET for `checkverifystatus` --- src/lib.rs | 2 +- src/verify.rs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9fbea12..55580d1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -214,7 +214,7 @@ impl Client { let response = self .client .post(self.etherscan_api_url.clone()) - .form(form) + .json(form) .send() .await? .text() diff --git a/src/verify.rs b/src/verify.rs index ee52e3c..c7fe0af 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -1,6 +1,7 @@ use crate::{Client, Response, Result}; use alloy_primitives::Address; use serde::{Deserialize, Serialize}; +use serde_json::Value; use std::collections::HashMap; /// Arguments for verifying contracts @@ -10,7 +11,7 @@ pub struct VerifyContract { #[serde(rename = "contractaddress")] pub address: Address, #[serde(rename = "sourceCode")] - pub source: String, + pub source: Value, #[serde(rename = "codeformat")] pub code_format: CodeFormat, /// if codeformat=solidity-standard-json-input, then expected as @@ -54,7 +55,7 @@ impl VerifyContract { pub fn new( address: Address, contract_name: String, - source: String, + source: Value, compiler_version: String, ) -> Self { Self { @@ -179,7 +180,7 @@ impl Client { "checkverifystatus", HashMap::from([("guid", guid.as_ref())]), ); - self.post_form(&body).await + self.get(&body).await.and_then(|res| self.sanitize_response(res)) } /// Submit Proxy Contract for Verification