Skip to content

Commit afadd12

Browse files
Merge branch 'develop' into feature/2025-07-21-mempool-clean-2
2 parents 0c79ead + 9a3477e commit afadd12

File tree

15 files changed

+167
-556
lines changed

15 files changed

+167
-556
lines changed

src/assets/assets.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ static long long issueAsset(const m256i& issuerPublicKey, const char name[7], ch
245245
AssetIssuance assetIssuance;
246246
assetIssuance.issuerPublicKey = issuerPublicKey;
247247
assetIssuance.numberOfShares = numberOfShares;
248+
assetIssuance.managingContractIndex = managingContractIndex; // any SC can call issueAsset now (eg: QBOND) not just QX
248249
*((unsigned long long*) assetIssuance.name) = *((unsigned long long*) name); // Order must be preserved!
249250
assetIssuance.numberOfDecimalPlaces = numberOfDecimalPlaces; // Order must be preserved!
250251
*((unsigned long long*) assetIssuance.unitOfMeasurement) = *((unsigned long long*) unitOfMeasurement); // Order must be preserved!

src/contract_core/qpi_asset_impl.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,13 @@ bool QPI::QpiContextProcedureCall::distributeDividends(long long amountPerShare)
486486
return false;
487487
}
488488

489+
// this part of code doesn't perform completed QuTransfers, instead it `decreaseEnergy` all QUs at once and `increaseEnergy` multiple times.
490+
// Meanwhile, a QUTransfer requires a pair of both decrease & increase calls.
491+
// This behavior will produce different numberOfOutgoingTransfers for the SC index.
492+
// 3rd party software needs to catch the HINT message to know the distribute dividends operation
493+
DummyCustomMessage dcm{ CUSTOM_MESSAGE_OP_START_DISTRIBUTE_DIVIDENDS };
494+
logger.logCustomMessage(dcm);
495+
489496
if (decreaseEnergy(index, amountPerShare * NUMBER_OF_COMPUTORS))
490497
{
491498
ACQUIRE(universeLock);
@@ -523,7 +530,8 @@ bool QPI::QpiContextProcedureCall::distributeDividends(long long amountPerShare)
523530

524531
RELEASE(universeLock);
525532
}
526-
533+
dcm = DummyCustomMessage{ CUSTOM_MESSAGE_OP_END_DISTRIBUTE_DIVIDENDS };
534+
logger.logCustomMessage(dcm);
527535
return true;
528536
}
529537

src/contracts/MsVault.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,7 @@ struct MSVAULT : public ContractBase
594594
isValidVaultId_input iv_in;
595595
isValidVaultId_output iv_out;
596596
isValidVaultId_locals iv_locals;
597-
QX::TransferShareOwnershipAndPossession_input qx_in;
598-
QX::TransferShareOwnershipAndPossession_output qx_out;
597+
sint64 remainingShares;
599598
sint64 releaseResult;
600599
};
601600

@@ -1482,15 +1481,15 @@ struct MSVAULT : public ContractBase
14821481
// Re-check balance before transfer
14831482
if (locals.assetVault.assetBalances.get(locals.assetIndex).balance >= input.amount)
14841483
{
1485-
locals.qx_out.transferredNumberOfShares = qpi.transferShareOwnershipAndPossession(
1484+
locals.remainingShares = qpi.transferShareOwnershipAndPossession(
14861485
input.asset.assetName,
14871486
input.asset.issuer,
14881487
SELF, // owner
14891488
SELF, // possessor
14901489
input.amount,
14911490
input.destination // new owner & possessor
14921491
);
1493-
if (locals.qx_out.transferredNumberOfShares > 0)
1492+
if (locals.remainingShares >= 0)
14941493
{
14951494
// Update internal asset balance
14961495
locals.ab = locals.assetVault.assetBalances.get(locals.assetIndex);

src/contracts/QBond.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ struct QBOND : public ContractBase
193193
struct TableEntry
194194
{
195195
sint64 epoch;
196+
sint64 totalStakedQBond;
197+
sint64 totalStakedQEarn;
196198
uint64 apy;
197199
};
198200
Array<TableEntry, 512> info;
@@ -1093,6 +1095,8 @@ struct QBOND : public ContractBase
10931095
locals.tempInput.Epoch = (uint32) locals.epoch;
10941096
CALL_OTHER_CONTRACT_FUNCTION(QEARN, getLockInfoPerEpoch, locals.tempInput, locals.tempOutput);
10951097
locals.tempTableEntry.epoch = locals.epoch;
1098+
locals.tempTableEntry.totalStakedQBond = locals.tempMBondInfo.totalStaked * QBOND_MBOND_PRICE;
1099+
locals.tempTableEntry.totalStakedQEarn = locals.tempOutput.currentLockedAmount;
10961100
locals.tempTableEntry.apy = locals.tempOutput.yield;
10971101
output.info.set(locals.index, locals.tempTableEntry);
10981102
locals.index++;

src/contracts/QUtil.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,7 @@ struct QUTIL : public ContractBase
472472
github_link.get(15) == 99 && // 'c'
473473
github_link.get(16) == 111 && // 'o'
474474
github_link.get(17) == 109 && // 'm'
475-
github_link.get(18) == 47 && // '/'
476-
github_link.get(19) == 113 && // 'q'
477-
github_link.get(20) == 117 && // 'u'
478-
github_link.get(21) == 98 && // 'b'
479-
github_link.get(22) == 105 && // 'i'
480-
github_link.get(23) == 99; // 'c'
475+
github_link.get(18) == 47; // '/'
481476
}
482477

483478
/**************************************/
@@ -1177,7 +1172,7 @@ struct QUTIL : public ContractBase
11771172
output.count = 0;
11781173
for (locals.idx = 0; locals.idx < QUTIL_MAX_POLL; locals.idx++)
11791174
{
1180-
if (state.polls.get(locals.idx).is_active != 0 && state.polls.get(locals.idx).creator == input.creator)
1175+
if (state.polls.get(locals.idx).creator != NULL_ID && state.polls.get(locals.idx).creator == input.creator)
11811176
{
11821177
output.poll_ids.set(output.count, state.poll_ids.get(locals.idx));
11831178
output.count++;

src/contracts/RandomLottery.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,17 @@ struct RL : public ContractBase
368368
if (state.players.contains(qpi.invocator()))
369369
{
370370
output.returnCode = static_cast<uint8>(EReturnCode::TICKET_ALREADY_PURCHASED);
371+
qpi.transfer(qpi.invocator(), qpi.invocationReward());
372+
371373
return;
372374
}
373375

374376
// Capacity full
375377
if (state.players.add(qpi.invocator()) == NULL_INDEX)
376378
{
377379
output.returnCode = static_cast<uint8>(EReturnCode::TICKET_ALL_SOLD_OUT);
380+
qpi.transfer(qpi.invocator(), qpi.invocationReward());
381+
378382
return;
379383
}
380384

src/logging/logging.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ struct Peer;
5858
#define ASSET_POSSESSION_MANAGING_CONTRACT_CHANGE 12
5959
#define CUSTOM_MESSAGE 255
6060

61+
#define CUSTOM_MESSAGE_OP_START_DISTRIBUTE_DIVIDENDS 6217575821008262227ULL // STA_DDIV
62+
#define CUSTOM_MESSAGE_OP_END_DISTRIBUTE_DIVIDENDS 6217575821008457285ULL //END_DDIV
63+
6164
/*
6265
* STRUCTS FOR LOGGING
6366
*/
@@ -73,6 +76,7 @@ struct AssetIssuance
7376
{
7477
m256i issuerPublicKey;
7578
long long numberOfShares;
79+
long long managingContractIndex;
7680
char name[7];
7781
char numberOfDecimalPlaces;
7882
char unitOfMeasurement[7];

0 commit comments

Comments
 (0)