-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add events module feat: Enhance events module, usage of IntoKey trait fix: Fix the "publish" event bug ResourceLimitExceeded: Must put the wasm_hash instead of the wasm_binary in the event data
- Loading branch information
1 parent
76a8d23
commit 0da8582
Showing
6 changed files
with
121 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use crate::{ | ||
metadata::ContractMetadata, | ||
version::{Update, Version}, | ||
}; | ||
use loam_sdk::soroban_sdk::{self, contracttype, Address, Env, IntoVal, String, Val}; | ||
use loam_sdk::IntoKey; | ||
|
||
#[contracttype] | ||
#[derive(IntoKey)] | ||
pub struct Publish { | ||
pub published_name: String, | ||
pub author: Address, | ||
pub hash: soroban_sdk::BytesN<32>, | ||
pub repo: ContractMetadata, | ||
pub kind: Update, | ||
} | ||
|
||
#[contracttype] | ||
#[derive(IntoKey)] | ||
pub struct Deploy { | ||
pub published_name: String, | ||
pub deployed_name: String, | ||
pub version: Version, | ||
pub deployer: Address, | ||
pub contract_id: Address, | ||
} | ||
|
||
pub trait EventPublishable { | ||
/// Publish an event on the blockchain | ||
fn publish_event(self, env: &Env); | ||
} | ||
|
||
impl<T> EventPublishable for T | ||
where | ||
T: soroban_sdk::IntoKey + IntoVal<Env, Val>, | ||
{ | ||
fn publish_event(self, env: &Env) { | ||
env.events().publish((T::into_key(),), self); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ use registry::{ | |
}; | ||
|
||
pub mod error; | ||
pub mod events; | ||
pub mod metadata; | ||
pub mod registry; | ||
pub mod util; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters