fixed bugs related to retrieving LINK balance
This commit is contained in:
parent
83bd3a2f12
commit
ae3807fc34
@ -68,6 +68,7 @@ namespace FemboyBanking {
|
||||
/// </summary>
|
||||
void InitializeComponent(void)
|
||||
{
|
||||
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(EthAddressPrompt::typeid));
|
||||
this->doneBtn = (gcnew System::Windows::Forms::Button());
|
||||
this->cancelBtn = (gcnew System::Windows::Forms::Button());
|
||||
this->ethTextBox = (gcnew System::Windows::Forms::TextBox());
|
||||
@ -102,7 +103,7 @@ namespace FemboyBanking {
|
||||
//
|
||||
this->ethTextBox->AllowDrop = true;
|
||||
this->ethTextBox->Location = System::Drawing::Point(12, 42);
|
||||
this->ethTextBox->MaxLength = 66;
|
||||
this->ethTextBox->MaxLength = 42;
|
||||
this->ethTextBox->Name = L"ethTextBox";
|
||||
this->ethTextBox->Size = System::Drawing::Size(298, 20);
|
||||
this->ethTextBox->TabIndex = 2;
|
||||
@ -163,13 +164,13 @@ namespace FemboyBanking {
|
||||
this->Controls->Add(this->cancelBtn);
|
||||
this->Controls->Add(this->doneBtn);
|
||||
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog;
|
||||
this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
|
||||
this->MaximizeBox = false;
|
||||
this->Name = L"EthAddressPrompt";
|
||||
this->ShowInTaskbar = false;
|
||||
this->Text = L"Enter LINK Address";
|
||||
this->TopMost = true;
|
||||
this->ResumeLayout(false);
|
||||
this->PerformLayout();
|
||||
|
||||
}
|
||||
#pragma endregion
|
||||
private:
|
||||
@ -200,9 +201,11 @@ namespace FemboyBanking {
|
||||
e->Result = Etherscan::FetchLinkBalance( e->Argument->ToString(), worker, e );
|
||||
}
|
||||
System::Void etherscanWorker_RunWorkerCompleted(System::Object^ sender, System::ComponentModel::RunWorkerCompletedEventArgs^ e) {
|
||||
if (e->Result != -1)
|
||||
{
|
||||
MessageBox::Show(this, e->Result->ToString(), "Wallet Balance Retrieved", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
||||
if ((UInt64) e->Result != -1)
|
||||
{
|
||||
Double balance = (UInt64) e->Result / 1e18;
|
||||
String^ balanceMsg = String::Format("You have {0} LINK", balance);
|
||||
MessageBox::Show(this, balanceMsg, "Wallet Balance Retrieved", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
||||
}
|
||||
}
|
||||
System::Void etherscanWorker_ProgressChanged(System::Object^ sender, System::ComponentModel::ProgressChangedEventArgs^ e) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -45,14 +45,27 @@ UInt64 Etherscan::FetchLinkBalance(String^ address, BackgroundWorker^ worker, Do
|
||||
response.Parse(DataReceived);
|
||||
worker->ReportProgress(90);
|
||||
|
||||
if (response.HasMember("error"))
|
||||
if (strcmp(response["status"].GetString(), "1") != 0)
|
||||
{
|
||||
if (response.HasMember("result"))
|
||||
{
|
||||
const char* error = response["result"].GetString();
|
||||
MessageBox::Show( dynamic_cast<Form^>(worker->Container), gcnew String(error), "API Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox::Show( dynamic_cast<Form^>(worker->Container), "Unknown error", "API Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
InternetCloseHandle(OpenAddress);
|
||||
InternetCloseHandle(connect);
|
||||
|
||||
const char* result = response["result"].GetString();
|
||||
String^ balanceStr = gcnew String(result);
|
||||
UInt64 balance = UInt64::Parse(balanceStr);
|
||||
|
||||
worker->ReportProgress(100);
|
||||
String^ balance = gcnew String(response["result"].GetString());
|
||||
return UInt64::Parse(balance);
|
||||
return balance;
|
||||
}
|
||||
|
@ -8,6 +8,6 @@ namespace FemboyBanking
|
||||
static System::UInt64 FetchLinkBalance( System::String^, System::ComponentModel::BackgroundWorker^, System::ComponentModel::DoWorkEventArgs^ );
|
||||
private:
|
||||
static const char* BALANCE_URL_FMT = "http://api.etherscan.io/api?module=account&action=tokenbalance&contractaddress=%s&address=%s&tag=latest";
|
||||
static const char* LINK_CONTRACT = "0x57d90b64a1a57749b0f932f1a3395792e12e7055";
|
||||
static const char* LINK_CONTRACT = "0x514910771af9ca656af840dff83e8264ecf986ca";
|
||||
};
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ namespace FemboyBanking {
|
||||
/// </summary>
|
||||
void InitializeComponent(void)
|
||||
{
|
||||
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Main::typeid));
|
||||
this->label1 = (gcnew System::Windows::Forms::Label());
|
||||
this->balLbl = (gcnew System::Windows::Forms::Label());
|
||||
this->depBtn = (gcnew System::Windows::Forms::Button());
|
||||
@ -133,6 +134,7 @@ namespace FemboyBanking {
|
||||
this->Controls->Add(this->balLbl);
|
||||
this->Controls->Add(this->label1);
|
||||
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle;
|
||||
this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
|
||||
this->MaximizeBox = false;
|
||||
this->Name = L"Main";
|
||||
this->Text = L"FemboyBanking";
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user