Skip to content

Commit

Permalink
add arbitrary event function (#38)
Browse files Browse the repository at this point in the history
* add arbitrary event function

* add nodesale event

* update event, func name
  • Loading branch information
webelf101 authored Aug 2, 2024
1 parent a24d673 commit 86fd182
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions contracts/Compass.vy
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

MAX_VALIDATORS: constant(uint256) = 200
MAX_PAYLOAD: constant(uint256) = 10240
MAX_EVENT: constant(uint256) = 1024
MAX_BATCH: constant(uint256) = 64

POWER_THRESHOLD: constant(uint256) = 2_863_311_530 # 2/3 of 2^32, Validator powers will be normalized to sum to 2 ^ 32 in every valset update.
Expand Down Expand Up @@ -76,6 +77,15 @@ event ERC20DeployedEvent:
decimals: uint8
event_id: uint256

event NodeSaleEvent:
contract_address: address
buyer: address
paloma: bytes32
node_count: uint256
grain_amount: uint256
nonce: uint256
event_id: uint256

last_checkpoint: public(bytes32)
last_valset_id: public(uint256)
last_event_id: public(uint256)
Expand Down Expand Up @@ -225,6 +235,14 @@ def submit_batch(consensus: Consensus, token: address, args: TokenSendArgs, batc
self.last_batch_id[token] = batch_id
log BatchSendEvent(token, batch_id, _nonce, _event_id)

@external
def emit_nodesale_event(buyer: address, paloma: bytes32, node_count: uint256, grain_amount: uint256):
event_id: uint256 = unsafe_add(self.last_event_id, 1)
self.last_event_id = event_id
_nonce: uint256 = unsafe_add(self.last_gravity_nonce, 1)
self.last_gravity_nonce = _nonce
log NodeSaleEvent(msg.sender, buyer, paloma, node_count, grain_amount, _nonce, event_id)

@external
def deploy_erc20(_paloma_denom: String[64], _name: String[64], _symbol: String[32], _decimals: uint8, _blueprint: address):
assert msg.sender == self, "Invalid"
Expand Down

0 comments on commit 86fd182

Please sign in to comment.