Skip to content

Commit

Permalink
SmartContracts now builds! Testing tomorrow...
Browse files Browse the repository at this point in the history
Signed-off-by: FellowTraveler <F3llowTraveler@gmail.com>
  • Loading branch information
FellowTraveler committed Nov 25, 2011
1 parent 1bad0dc commit 65e743c
Show file tree
Hide file tree
Showing 45 changed files with 6,340 additions and 392 deletions.
272 changes: 195 additions & 77 deletions Makefile

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions OTLib/OTAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ bool OTAccount::Credit(const long & lAmount)
}


const OTIdentifier & OTAccount::GetAssetTypeID()
const OTIdentifier & OTAccount::GetAssetTypeID() const
{
return m_AcctAssetTypeID;
}
Expand Down Expand Up @@ -398,7 +398,7 @@ OTAccount::~OTAccount()
// Verify Contract ID first, THEN Verify Owner.
// Because we use the ID in this function, so make sure that it is verified before calling this.
//
bool OTAccount::VerifyOwner(OTPseudonym & theCandidate)
bool OTAccount::VerifyOwner(const OTPseudonym & theCandidate) const
{
OTIdentifier ID_CANDIDATE;
theCandidate.GetIdentifier(ID_CANDIDATE); // ID_CANDIDATE now contains the ID of the Nym we're testing.
Expand Down Expand Up @@ -956,7 +956,7 @@ int OTAccount::ProcessXMLNode(IrrXMLReader*& xml)
if (!strStashTransNum.Exists() || ((lTransNum = atol(strStashTransNum.Get())) <= 0))
{
m_lStashTransNum = 0;
OTLog::Error("OTAccount::ProcessXMLNode: Error: Bad transaction number for supposed corresponding cron item: %ld \n",
OTLog::vError("OTAccount::ProcessXMLNode: Error: Bad transaction number for supposed corresponding cron item: %ld \n",
lTransNum);
return (-1);
}
Expand Down Expand Up @@ -1040,7 +1040,7 @@ bool OTAccount::IsOwnedByUser() const
return bReturnVal;
}

bool OTAccount::IsOwnedByEntity const
bool OTAccount::IsOwnedByEntity() const
{
return false;
}
Expand Down Expand Up @@ -1110,8 +1110,8 @@ void OTAcctList::Serialize(OTString & strAppend)

FOR_EACH(mapOfStrings, m_mapAcctIDs)
{
const std::string str_asset_type_id = (*ii).first;
const std::string str_account_id = (*ii).second;
const std::string str_asset_type_id = (*it).first;
const std::string str_account_id = (*it).second;
OT_ASSERT((str_asset_type_id.size()>0) && (str_account_id.size()>0));

strAppend.Concatenate("<accountEntry assetTypeID=\"%s\" accountID=\"%s\" />\n\n",
Expand Down Expand Up @@ -1214,9 +1214,11 @@ OTAccount_SharedPtr OTAcctList::GetOrCreateAccount(OTPseudonym & theServerNym,
// ------------------------------------------------
// First, we'll see if there's already an account ID available for the requested asset type ID.
//
const OTString strAssetTypeID(ASSET_TYPE_ID), strAcctType;
const OTString strAssetTypeID(ASSET_TYPE_ID);
const std::string str_asset_type_id = strAssetTypeID.Get();

// ------------------------------------
OTString strAcctType;
TranslateAccountTypeToString(m_AcctType, strAcctType);
// ----------------------------------------------------------------

Expand Down
14 changes: 7 additions & 7 deletions OTLib/OTAccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class OTAccount : public OTTransactionType
bool IsInternalServerAcct() const;

bool IsOwnedByUser() const;
bool IsOwnedByEntity const;
bool IsOwnedByEntity() const;

bool IsAllowedToGoNegative() const;

Expand Down Expand Up @@ -237,15 +237,15 @@ class OTAccount : public OTTransactionType
OTLedger * LoadOutbox(OTPseudonym & theNym); // Caller responsible to delete.

// gives you the asset type ID of this account. (the asset contract hash.)
const OTIdentifier & GetAssetTypeID();
const OTIdentifier & GetAssetTypeID() const;

long GetBalance() const;

bool Debit(const long & lAmount); // Debit a certain amount from the account (presumably the same amount is being added somewhere)
bool Credit(const long & lAmount); // Credit a certain amount from the account (presumably the same amount is being subtracted somewhere)

// Compares the NymID loaded from the account file with whatever Nym the programmer wants to verify.
bool VerifyOwner(OTPseudonym & theCandidate);
bool VerifyOwner(const OTPseudonym & theCandidate) const;
bool VerifyOwnerByID(const OTIdentifier & theNymID) const;

virtual bool LoadContract(); // overriding this so I can set the filename automatically inside based on ID.
Expand All @@ -270,7 +270,7 @@ class OTAccount : public OTTransactionType


typedef std::list <OTAccount *> listOfAccounts;
typedef std::map<std::string, OTAccount *> mapOfAccounts;
//typedef std::map<std::string, OTAccount *> mapOfAccounts; // Now in OTBylaw.h


// -------------------------------------------------------------
Expand All @@ -292,14 +292,14 @@ typedef std::map<std::string, OTAccount_WeakPtr> mapOfWeakAccounts; // mapped by
//
class OTAcctList
{
AccountType m_AcctType;
OTAccount::AccountType m_AcctType;

mapOfStrings m_mapAcctIDs; // AcctIDs as second mapped by ASSET TYPE ID as first.
mapOfWeakAccounts m_mapWeakAccts; // If someone calls GetAccount(), we pass them a shared pointer.
// We store the weak pointer here to make sure account doesn't get loaded twice.
public:
OTAcctList();
OTAcctList(AccountType eAcctType);
OTAcctList(OTAccount::AccountType eAcctType);
~OTAcctList();

int GetCountAccountIDs() const { return m_mapAcctIDs.size(); }
Expand All @@ -309,7 +309,7 @@ class OTAcctList
void Serialize(OTString & strAppend);
int ReadFromXMLNode(irr::io::IrrXMLReader*& xml, const OTString & strAcctType, const OTString & strAcctCount);

void SetType(AccountType eAcctType) { m_AcctType = eAcctType; }
void SetType(OTAccount::AccountType eAcctType) { m_AcctType = eAcctType; }

OTAccount_SharedPtr GetOrCreateAccount(OTPseudonym & theServerNym,
const OTIdentifier & ACCOUNT_OWNER_ID,
Expand Down
5 changes: 4 additions & 1 deletion OTLib/OTAgreement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@
#include "OTPseudonym.h"
#include "OTCron.h"
#include "OTAgreement.h"

#include "OTAccount.h"

#include "OTLog.h"


Expand All @@ -154,7 +157,7 @@ bool OTAgreement::VerifyNymAsAgent(const OTPseudonym & theNym,

// This is an override. See note above.
//
bool OTAgreement::VerifyNymAsAgentForAccount(const OTPseudonym & theNym, const OTAccount & theAccount)
bool OTAgreement::VerifyNymAsAgentForAccount(OTPseudonym & theNym, const OTAccount & theAccount)
{
return theAccount.VerifyOwner(theNym);
}
Expand Down
2 changes: 1 addition & 1 deletion OTLib/OTAgreement.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ class OTAgreement : public OTCronItem
OTPseudonym & theSignerNym,
mapOfNyms * pmap_ALREADY_LOADED=NULL);

virtual bool VerifyNymAsAgentForAccount(const OTPseudonym & theNym, const OTAccount & theAccount);
virtual bool VerifyNymAsAgentForAccount(OTPseudonym & theNym, const OTAccount & theAccount);

/*
From OTContract, I have:
Expand Down
Loading

0 comments on commit 65e743c

Please sign in to comment.