From a3612bf943604db09ded015264050ac57d1cd662 Mon Sep 17 00:00:00 2001 From: Erik van den Brink Date: Wed, 21 Aug 2024 21:23:38 +0200 Subject: [PATCH] add support for System.Runtime.CurrentSigners SYSCALL --- boa3/builtin/interop/runtime/__init__.py | 12 +++++++++++- boa3/internal/model/builtin/interop/interop.py | 5 ++++- .../interop/runtime/getcurrentsignersmethod.py | 11 +++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 boa3/internal/model/builtin/interop/runtime/getcurrentsignersmethod.py diff --git a/boa3/builtin/interop/runtime/__init__.py b/boa3/builtin/interop/runtime/__init__.py index 520aa36ad..fa45c14bd 100644 --- a/boa3/builtin/interop/runtime/__init__.py +++ b/boa3/builtin/interop/runtime/__init__.py @@ -19,13 +19,14 @@ 'invocation_counter', 'entry_script_hash', 'script_container', + 'get_current_signers', ] from collections.abc import Sequence from typing import Any -from boa3.builtin.interop.blockchain import Transaction +from boa3.builtin.interop.blockchain import Transaction, Signer from boa3.builtin.interop.contract.callflagstype import CallFlags from boa3.builtin.interop.runtime.notification import Notification from boa3.builtin.interop.runtime.triggertype import TriggerType @@ -82,6 +83,15 @@ def log(message: str): """ pass +def get_current_signers() -> list[Signer]: + """ + Get the Signers of the current transaction. + + :return: Return an array of all signers of the transaction. + :rtype: list[Signer] + """ + pass + def get_trigger() -> TriggerType: """ diff --git a/boa3/internal/model/builtin/interop/interop.py b/boa3/internal/model/builtin/interop/interop.py index 046f00bd1..e34237c11 100644 --- a/boa3/internal/model/builtin/interop/interop.py +++ b/boa3/internal/model/builtin/interop/interop.py @@ -11,6 +11,7 @@ from boa3.internal.model.builtin.interop.policy import * from boa3.internal.model.builtin.interop.role import * from boa3.internal.model.builtin.interop.runtime import * +from boa3.internal.model.builtin.interop.runtime.getcurrentsignersmethod import GetCurrentSignersMethod from boa3.internal.model.builtin.interop.stdlib import * from boa3.internal.model.builtin.interop.storage import * from boa3.internal.model.event import Event @@ -164,6 +165,7 @@ def interop_events(cls) -> list[Event]: GasLeft = GasLeftProperty() GetNetwork = GetNetworkMethod() GetNotifications = GetNotificationsMethod(NotificationType) + GetCurrentSigners = GetCurrentSignersMethod(SignerType) GetRandom = GetRandomMethod() GetTrigger = GetTriggerMethod(TriggerType) InvocationCounter = InvocationCounterProperty() @@ -396,7 +398,8 @@ def interop_events(cls) -> list[Event]: GetTrigger, LoadScript, Log, - Notify + Notify, + GetCurrentSigners ], packages=[NotificationModule, TriggerTypeModule diff --git a/boa3/internal/model/builtin/interop/runtime/getcurrentsignersmethod.py b/boa3/internal/model/builtin/interop/runtime/getcurrentsignersmethod.py new file mode 100644 index 000000000..e6ba76960 --- /dev/null +++ b/boa3/internal/model/builtin/interop/runtime/getcurrentsignersmethod.py @@ -0,0 +1,11 @@ +from boa3.internal.model.builtin.interop.blockchain import SignerType +from boa3.internal.model.builtin.interop.interopmethod import InteropMethod +from boa3.internal.model.variable import Variable + +class GetCurrentSignersMethod(InteropMethod): + def __init__(self, signer_type: SignerType): + from boa3.internal.model.type.type import Type + identifier = 'get_current_signers' + syscall = 'System.Runtime.CurrentSigners' + args: dict[str, Variable] = {} + super().__init__(identifier, syscall, args, return_type=Type.list.build([signer_type]))