-
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
426f5d3
commit bed7d8c
Showing
6 changed files
with
118 additions
and
16 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,41 @@ | ||
use loam_sdk::soroban_sdk::{ | ||
self, contracttype, Env, Address, IntoVal, Val, String | ||
}; | ||
use loam_sdk::IntoKey; | ||
use crate::{ | ||
version::{ Version, Update }, | ||
metadata::ContractMetadata | ||
}; | ||
|
||
#[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
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