-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
205 additions
and
0 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
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,9 @@ | ||
from typing_extensions import TypedDict | ||
|
||
|
||
class CheatcodeNetworkConfig(TypedDict): | ||
wait_for_acceptance: bool | ||
|
||
|
||
def get_default_network_config() -> CheatcodeNetworkConfig: | ||
return CheatcodeNetworkConfig(wait_for_acceptance=False) |
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,35 @@ | ||
import asyncio | ||
from typing import Callable, Dict, Any, Optional | ||
|
||
from starknet_py.net.models import AddressRepresentation | ||
|
||
from protostar.starknet.cheatcode import Cheatcode | ||
from protostar.starknet_gateway import GatewayFacade | ||
|
||
|
||
class MigratorCallCheatcode(Cheatcode): | ||
def __init__( | ||
self, | ||
syscall_dependencies: Cheatcode.SyscallDependencies, | ||
gateway_facade: GatewayFacade, | ||
): | ||
super().__init__(syscall_dependencies) | ||
self._gateway_facade = gateway_facade | ||
|
||
@property | ||
def name(self) -> str: | ||
return "call" | ||
|
||
def build(self) -> Callable: | ||
return self.call | ||
|
||
def call(self, address: AddressRepresentation, function_name: str, inputs: Optional[Dict[str, Any]] = None): | ||
|
||
output = asyncio.run( | ||
self._gateway_facade.call( | ||
address=address, | ||
function_name=function_name, | ||
inputs=inputs, | ||
) | ||
) | ||
|
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
37 changes: 37 additions & 0 deletions
37
protostar/migrator/cheatcodes/migrator_invoke_cheatcode.py
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,37 @@ | ||
import asyncio | ||
from typing import Callable, Dict, Any, Optional | ||
|
||
from starknet_py.net.models import AddressRepresentation | ||
|
||
from protostar.starknet.cheatcode import Cheatcode | ||
from protostar.starknet_gateway import GatewayFacade | ||
|
||
|
||
class MigratorInvokeCheatcode(Cheatcode): | ||
def __init__( | ||
self, | ||
syscall_dependencies: Cheatcode.SyscallDependencies, | ||
gateway_facade: GatewayFacade, | ||
): | ||
super().__init__(syscall_dependencies) | ||
self._gateway_facade = gateway_facade | ||
|
||
@property | ||
def name(self) -> str: | ||
return "invoke" | ||
|
||
def build(self) -> Callable: | ||
return self.invoke | ||
|
||
# TODO: consider CheatcodeNetworkConfig instead of wait_for_acceptance | ||
async def invoke(self, address: AddressRepresentation, function_name: str, inputs: Optional[Dict[str, Any]] = None, wait_for_acceptance: bool = False): | ||
|
||
asyncio.run( | ||
self._gateway_facade.invoke( | ||
address=address, | ||
function_name=function_name, | ||
inputs=inputs, | ||
wait_for_acceptance=wait_for_acceptance | ||
) | ||
) | ||
|
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