Skip to content

Commit

Permalink
Refactor contract to include MinimalAttestValue constant and update a…
Browse files Browse the repository at this point in the history
…ttest logic
  • Loading branch information
Laisky committed Sep 10, 2024
1 parent 2e0d2d7 commit ed7eeac
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions blockchain/ton/contracts/attest/contracts/attest.tact
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "./messages.tact";


const MinimalOracleStakeValue: Int = ton("0.01");
const MinimalAttestValue: Int = ton("0.01");

// =====================================
// Some utility functions
Expand Down Expand Up @@ -152,7 +153,6 @@ contract Attest with Common {
let botAddr = contractAddress(bot);

nativeThrowUnless(codeSenderAddressInvalid, botAddr == sender());
nativeThrowUnless(codeInflowValueNotSufficient, ctx.value >= msg.attestValue + self.staticTaxFee);

// publish the attest task via emit.
// the task will be picked by the distributed verifier oracle.
Expand Down Expand Up @@ -271,29 +271,27 @@ contract Bot with Common {
nativeThrowUnless(codeManifestNotSet, self.manifestUrl != "");
nativeThrowUnless(codeInflowValueNotSufficient, ctx.value >= msg.attestValue);
nativeThrowUnless(codeBalanceNotSufficient, myBalance() >= self.lockedValue + msg.attestValue);
nativeThrowUnless(codeAttestValueNotSufficient, msg.attestValue >= ton("0.05"));
nativeThrowUnless(codeAttestValueNotSufficient, msg.attestValue >= MinimalAttestValue);

// forward the task to the master contract
let pubMsg = PublishAttestTask{
queryId: msg.queryId,
taskId: self.attestTaskId,
status: "pending",
botOwner: self.owner,
proofUrl: msg.proofUrl,
attestValue: msg.attestValue
};
self.attestTaskId = self.attestTaskId + 1;

self.reserveValue(msg.attestValue);
send(SendParameters{
to: self.master,
value: 0,
mode: SendRemainingBalance,
bounce: true,
body: pubMsg.toCell()
body: PublishAttestTask{
queryId: msg.queryId,
taskId: self.attestTaskId,
status: "pending",
botOwner: self.owner,
proofUrl: msg.proofUrl,
attestValue: msg.attestValue
}.toCell()
}
);

self.attestTaskId = self.attestTaskId + 1;
// save the incentive of the task
self.attestTaskIncentives.set(self.attestTaskId, msg.attestValue);
// lock the incentive of the task for the verifier
Expand Down

0 comments on commit ed7eeac

Please sign in to comment.