-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 🔧 Fix KV Delete Bug * 🔨 Build KvMap * 🔨 Add Keys and KvMap Functions * 🔧 Fix Unit Tests * 🔧 Fix Linting Issues in UnitTest * chore: Set to boolean * 🔨 Add Push0 Opcode * 🔨 Add Invalid Opcode * 🔧 Fix CODECOPY opcode * 🔧 Fix Kv Get Functionality * 🔧 Fix Linting Errors * 🔧 Fix Linting Errors * 🔧 Fix Napi Binding --------- Co-authored-by: andreespirela <[email protected]>
- Loading branch information
1 parent
6faa281
commit cdbc27c
Showing
9 changed files
with
419 additions
and
270 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export async function handle(state, action) { | ||
const input = action.input; | ||
|
||
if (input.function === "put") { | ||
const { key, value } = input; | ||
state.puts.push({ key, value }); // write to state | ||
SmartWeave.kv.put(key, value); // write to KVS | ||
return { result: JSON.stringify(SmartWeave.kv.getAll()) }; // state | ||
} | ||
if (input.function === "get") { | ||
const { key } = input; | ||
|
||
const res = SmartWeave.kv.get(key); | ||
state.gets.push(res) | ||
return { state }; | ||
} | ||
|
||
if (input.function === "del") { | ||
const { key } = input; | ||
SmartWeave.kv.del(key); | ||
return { state }; | ||
} | ||
} | ||
|