File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
packages/automation/src/lib Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -140,10 +140,34 @@ export class StateMachine {
140140 return stateMachine ;
141141 }
142142
143+ /**
144+ * Indicates if the state machine is running
145+ */
143146 get isRunning ( ) {
144147 return this . status === 'running' ;
145148 }
146149
150+ /**
151+ * Returns an ethers Wallet the state machine can use
152+ */
153+ get signer ( ) {
154+ if ( ! this . privateKey ) {
155+ throw new AutomationError (
156+ {
157+ info : { } ,
158+ } ,
159+ `Cannot use state machine signer without a private key. Pass a PK to the machine when creating it`
160+ ) ;
161+ }
162+
163+ return new ethers . Wallet (
164+ this . privateKey ,
165+ new ethers . providers . JsonRpcProvider (
166+ RPC_URL_BY_NETWORK [ this . litNodeClient . config . litNetwork ]
167+ )
168+ ) ;
169+ }
170+
147171 /**
148172 * Adds a custom state to the state machine.
149173 * @param params The parameters for the state.
@@ -722,7 +746,9 @@ export class StateMachine {
722746 ) ;
723747 }
724748 if ( this . currentState === nextState ) {
725- console . warn ( `State ${ stateKey } is already active. Skipping transition.` ) ;
749+ console . warn (
750+ `State ${ stateKey } is already active. Skipping state change.`
751+ ) ;
726752 return ;
727753 }
728754
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ type Values = (unknown | undefined)[];
1010 */
1111export interface BaseTransitionParams {
1212 debug ?: boolean ;
13- listeners ?: Listener < any > [ ] ; // should be unknown but that makes callers to cast listeners
13+ listeners ?: Listener < any > [ ] ; // should be unknown but that demands callers to cast listeners to their correct type
1414 check ?: CheckFn ;
1515 onMatch : resultFn ;
1616 onMismatch ?: resultFn ;
You can’t perform that action at this time.
0 commit comments