Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Qubic.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<ClInclude Include="contracts\QRaffle.h" />
<ClInclude Include="contracts\QBond.h" />
<ClInclude Include="contracts\QIP.h" />
<ClInclude Include="contracts\SupplyWatcher_old.h" />
<ClInclude Include="contracts\QReservePool.h" />
<ClInclude Include="contracts\QThirtyFour.h" />
<ClInclude Include="contracts\TestExampleA.h" />
Expand Down
3 changes: 0 additions & 3 deletions src/Qubic.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,6 @@
<ClInclude Include="contracts\qRWA.h">
<Filter>contracts</Filter>
</ClInclude>
<ClInclude Include="contracts\SupplyWatcher_old.h">
<Filter>contracts</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="platform">
Expand Down
40 changes: 3 additions & 37 deletions src/contract_core/contract_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,7 @@
#define CONTRACT_INDEX SWATCH_CONTRACT_INDEX
#define CONTRACT_STATE_TYPE SWATCH
#define CONTRACT_STATE2_TYPE SWATCH2
#ifdef OLD_SWATCH
#include "contracts/SupplyWatcher_old.h"
#else
#include "contracts/SupplyWatcher.h"
#endif

#undef CONTRACT_INDEX
#undef CONTRACT_STATE_TYPE
Expand Down Expand Up @@ -215,54 +211,36 @@
#define CONTRACT_STATE2_TYPE QRWA2
#include "contracts/qRWA.h"

#ifndef NO_QRP

constexpr unsigned short qrpContractIndex = CONTRACT_INDEX + 1;

#undef CONTRACT_INDEX
#undef CONTRACT_STATE_TYPE
#undef CONTRACT_STATE2_TYPE

#define QRP_CONTRACT_INDEX qrpContractIndex
#define QRP_CONTRACT_INDEX 21
#define CONTRACT_INDEX QRP_CONTRACT_INDEX
#define CONTRACT_STATE_TYPE QRP
#define CONTRACT_STATE2_TYPE QRP2
#include "contracts/QReservePool.h"

#endif // NO_QRP

#ifndef NO_QTF

constexpr unsigned short qtfContractIndex = CONTRACT_INDEX + 1;

#undef CONTRACT_INDEX
#undef CONTRACT_STATE_TYPE
#undef CONTRACT_STATE2_TYPE

#define QTF_CONTRACT_INDEX qtfContractIndex
#define QTF_CONTRACT_INDEX 22
#define CONTRACT_INDEX QTF_CONTRACT_INDEX
#define CONTRACT_STATE_TYPE QTF
#define CONTRACT_STATE2_TYPE QTF2
#include "contracts/QThirtyFour.h"

#endif // NO_QTF

#ifndef NO_QDUEL

constexpr unsigned short qduelContractIndex = CONTRACT_INDEX + 1;

#undef CONTRACT_INDEX
#undef CONTRACT_STATE_TYPE
#undef CONTRACT_STATE2_TYPE

#define QDUEL_CONTRACT_INDEX qduelContractIndex
#define QDUEL_CONTRACT_INDEX 23
#define CONTRACT_INDEX QDUEL_CONTRACT_INDEX
#define CONTRACT_STATE_TYPE QDUEL
#define CONTRACT_STATE2_TYPE QDUEL2
#include "contracts/QDuel.h"

#endif // NO_QDUEL

// new contracts should be added above this line

#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
Expand Down Expand Up @@ -371,15 +349,9 @@ constexpr struct ContractDescription
{"QIP", 189, 10000, sizeof(QIP)}, // proposal in epoch 187, IPO in 188, construction and first use in 189
{"QRAFFLE", 192, 10000, sizeof(QRAFFLE)}, // proposal in epoch 190, IPO in 191, construction and first use in 192
{"QRWA", 197, 10000, sizeof(QRWA)}, // proposal in epoch 195, IPO in 196, construction and first use in 197
#ifndef NO_QRP
{"QRP", 199, 10000, sizeof(IPO)}, // proposal in epoch 197, IPO in 198, construction and first use in 199
#endif
#ifndef NO_QTF
{"QTF", 199, 10000, sizeof(QTF)}, // proposal in epoch 197, IPO in 198, construction and first use in 199
#endif
#ifndef NO_QDUEL
{"QDUEL", 199, 10000, sizeof(QDUEL)}, // proposal in epoch 197, IPO in 198, construction and first use in 199
#endif
// new contracts should be added above this line
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
{"TESTEXA", 138, 10000, sizeof(TESTEXA)},
Expand Down Expand Up @@ -496,15 +468,9 @@ static void initializeContracts()
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QIP);
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QRAFFLE);
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QRWA);
#ifndef NO_QRP
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QRP);
#endif
#ifndef NO_QTF
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QTF);
#endif
#ifndef NO_QDUEL
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QDUEL);
#endif
// new contracts should be added above this line
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(TESTEXA);
Expand Down
42 changes: 42 additions & 0 deletions src/contracts/QIP.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ struct QIP : public ContractBase
{
if (input.indexOfICO >= state.numberOfICO)
{
if (qpi.invocationReward() > 0)
{
qpi.transfer(qpi.invocator(), qpi.invocationReward());
}
locals.log._contractIndex = SELF_INDEX;
locals.log._type = QIPLogInfo::QIP_ICONotFound;
locals.log.dst = qpi.invocator();
Expand All @@ -306,6 +310,10 @@ struct QIP : public ContractBase
}
else
{
if (qpi.invocationReward() > 0)
{
qpi.transfer(qpi.invocator(), qpi.invocationReward());
}
locals.log._contractIndex = SELF_INDEX;
locals.log._type = QIPLogInfo::QIP_invalidAmount;
locals.log.dst = qpi.invocator();
Expand All @@ -324,6 +332,10 @@ struct QIP : public ContractBase
}
else
{
if (qpi.invocationReward() > 0)
{
qpi.transfer(qpi.invocator(), qpi.invocationReward());
}
locals.log._contractIndex = SELF_INDEX;
locals.log._type = QIPLogInfo::QIP_invalidAmount;
locals.log.dst = qpi.invocator();
Expand All @@ -342,6 +354,10 @@ struct QIP : public ContractBase
}
else
{
if (qpi.invocationReward() > 0)
{
qpi.transfer(qpi.invocator(), qpi.invocationReward());
}
locals.log._contractIndex = SELF_INDEX;
locals.log._type = QIPLogInfo::QIP_invalidAmount;
locals.log.dst = qpi.invocator();
Expand All @@ -353,6 +369,10 @@ struct QIP : public ContractBase
}
else
{
if (qpi.invocationReward() > 0)
{
qpi.transfer(qpi.invocator(), qpi.invocationReward());
}
locals.log._contractIndex = SELF_INDEX;
locals.log._type = QIPLogInfo::QIP_invalidEpoch;
locals.log.dst = qpi.invocator();
Expand All @@ -363,6 +383,10 @@ struct QIP : public ContractBase
}
if (input.amount * locals.price > (uint64)qpi.invocationReward())
{
if (qpi.invocationReward() > 0)
{
qpi.transfer(qpi.invocator(), qpi.invocationReward());
}
locals.log._contractIndex = SELF_INDEX;
locals.log._type = QIPLogInfo::QIP_insufficientInvocationReward;
locals.log.dst = qpi.invocator();
Expand Down Expand Up @@ -479,6 +503,24 @@ struct QIP : public ContractBase
state.transferRightsFee = 100;
}

struct BEGIN_EPOCH_locals
{
id address1;
id address2;
};

BEGIN_EPOCH_WITH_LOCALS()
{
locals.address1 = ID(_K, _D, _F, _D, _H, _J, _F, _E, _B, _J, _W, _E, _Z, _D, _F, _I, _C, _T, _P, _Z, _N, _N, _D, _T, _A, _Z, _S, _A, _H, _F, _G, _Q, _H, _D, _O, _C, _X, _R, _P, _G, _D, _D, _I, _B, _F, _P, _D, _D, _Q, _Z, _H, _O, _V, _H, _V, _D);
locals.address2 = ID(_Z, _V, _V, _C, _R, _T, _G, _Y, _W, _B, _K, _H, _X, _D, _F, _M, _Q, _D, _X, _F, _V, _B, _D, _N, _N, _L, _I, _D, _K, _Q, _F, _N, _B, _Q, _K, _V, _U, _L, _R, _N, _H, _F, _E, _Z, _K, _C, _K, _B, _H, _X, _I, _B, _E, _N, _S, _E);

if (qpi.epoch() == 199)
{
qpi.transfer(locals.address1, 30000000);
qpi.transfer(locals.address2, 100000000);
}
}

struct END_EPOCH_locals
{
ICOInfo ico;
Expand Down
11 changes: 4 additions & 7 deletions src/contracts/QThirtyFour.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ constexpr uint8 QTF_DEFAULT_SCHEDULE = 1 << SATURDAY | 1u << WEDNESDAY;
constexpr uint8 QTF_DEFAULT_DRAW_HOUR = 11; // 11:00 UTC
constexpr uint32 QTF_DEFAULT_INIT_TIME = 22u << 9 | 4u << 5 | 13u; // RL_DEFAULT_INIT_TIME

const id QTF_ADDRESS_DEV_TEAM = ID(_Z, _T, _Z, _E, _A, _Q, _G, _U, _P, _I, _K, _T, _X, _F, _Y, _X, _Y, _E, _I, _T, _L, _A, _K, _F, _T, _D, _X, _C, _R,
_L, _W, _E, _T, _H, _N, _G, _H, _D, _Y, _U, _W, _E, _Y, _Q, _N, _Q, _S, _R, _H, _O, _W, _M, _U, _J, _L, _E);
const id QTF_RANDOM_LOTTERY_CONTRACT_ID = id(RL_CONTRACT_INDEX, 0, 0, 0);
constexpr uint64 QTF_RANDOM_LOTTERY_ASSET_NAME = 19538; // RL
const id QTF_RESERVE_POOL_CONTRACT_ID = id(QRP_CONTRACT_INDEX, 0, 0, 0);

struct QTF2
{
Expand Down Expand Up @@ -691,7 +687,8 @@ struct QTF : ContractBase
// Contract lifecycle methods
INITIALIZE()
{
state.teamAddress = QTF_ADDRESS_DEV_TEAM;
state.teamAddress = ID(_Z, _T, _Z, _E, _A, _Q, _G, _U, _P, _I, _K, _T, _X, _F, _Y, _X, _Y, _E, _I, _T, _L, _A, _K, _F, _T, _D, _X, _C, _R,
_L, _W, _E, _T, _H, _N, _G, _H, _D, _Y, _U, _W, _E, _Y, _Q, _N, _Q, _S, _R, _H, _O, _W, _M, _U, _J, _L, _E);
state.ownerAddress = state.teamAddress;
state.ticketPrice = QTF_TICKET_PRICE;
state.targetJackpot = QTF_DEFAULT_TARGET_JACKPOT;
Expand Down Expand Up @@ -1501,7 +1498,7 @@ struct QTF : ContractBase
// Transfer reserve overflow to QReservePool
if (locals.reserveAdd > 0)
{
qpi.transfer(QTF_RESERVE_POOL_CONTRACT_ID, locals.reserveAdd);
qpi.transfer(id(QRP_CONTRACT_INDEX, 0, 0, 0), locals.reserveAdd);
}

if (locals.devPayout > 0)
Expand Down Expand Up @@ -1534,7 +1531,7 @@ struct QTF : ContractBase
locals.rlPayback = locals.distPayout - smul(locals.dividendPerShare, locals.rlTotalShares);
if (locals.rlPayback > 0)
{
qpi.transfer(QTF_RANDOM_LOTTERY_CONTRACT_ID, locals.rlPayback);
qpi.transfer(id(RL_CONTRACT_INDEX, 0, 0, 0), locals.rlPayback);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/contracts/QUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct QUTILSendToManyBenchmarkLog
uint32 logType;
id startId;
sint64 dstCount;
sint64 numTransfersEach;
sint8 _terminator; // Only data before "_terminator" are logged
};

Expand Down Expand Up @@ -848,6 +849,7 @@ struct QUTIL : public ContractBase
locals.logBenchmark.startId = qpi.invocator();
locals.logBenchmark.logType = QUTIL_STMB_LOG_TYPE;
locals.logBenchmark.dstCount = input.dstCount;
locals.logBenchmark.numTransfersEach = input.numTransfersEach;
LOG_INFO(locals.logBenchmark);

LOG_PAUSE();
Expand Down
Loading
Loading