From 75b08a17fff8e8b0ca07d303b8d29b55390d6588 Mon Sep 17 00:00:00 2001 From: Steve Goodman <39279277+stoobie@users.noreply.github.com> Date: Sun, 10 Mar 2024 16:03:39 +0200 Subject: [PATCH] fix: Fix example in emit_events (#1169) * Fix example in emit_events * Update event example in starknet-events.adoc. --- .../pages/Smart_Contracts/starknet-events.adoc | 12 +++--------- .../pages/Smart_Contracts/system-calls-cairo1.adoc | 11 +++-------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/starknet-events.adoc b/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/starknet-events.adoc index 977a772ca6..466a0ed2fb 100644 --- a/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/starknet-events.adoc +++ b/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/starknet-events.adoc @@ -35,18 +35,12 @@ To emit custom keys, one should use the low level `emit_event` system call: ---- use starknet::syscalls::emit_event_syscall; -let keys = ArrayTrait::new(); -keys.append('key'); -keys.append('deposit'); -let values = ArrayTrait::new(); -values.append(1); -values.append(2); -values.append(3); +let keys = array!['key', 'deposit']; +let values = array![1, 2, 3]; emit_event_syscall(keys, values).unwrap_syscall(); ---- - -The above code emits an event with two keys, the https://www.cairo-lang.org/docs/how_cairo_works/consts.html#short-string-literals[strings] "status" and "deposit" (think of those as identifiers of the event that can be used for indexing) and three data elements 1, 2, 3. +The above code emits an event with two keys, the https://www.cairo-lang.org/docs/how_cairo_works/consts.html#short-string-literals[strings] `key` and `deposit` (think of those as identifiers of the event that can be used for indexing) and three data elements 1, 2, 3. [TIP] diff --git a/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/system-calls-cairo1.adoc b/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/system-calls-cairo1.adoc index 169cfa855c..e3dcdaa404 100644 --- a/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/system-calls-cairo1.adoc +++ b/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/system-calls-cairo1.adoc @@ -209,17 +209,12 @@ link:https://github.com/starkware-libs/cairo/blob/cca08c898f0eb3e58797674f20994d [discrete] ==== Example -The following example emits an event with two keys, the strings `status` and `deposit` and three data elements: `1`, `2`, and `3`. +The following example emits an event with two keys, the strings `key` and `deposit` and three data elements: `1`, `2`, and `3`. [source,cairo] ---- -let keys = ArrayTrait::new(); -keys.append('key'); -keys.append('deposit'); -let values = ArrayTrait::new(); -values.append(1); -values.append(2); -values.append(3); +let keys = array!['key', 'deposit']; +let values = array![1, 2, 3]; emit_event_syscall(keys, values).unwrap_syscall(); ----