Skip to content

Commit a829079

Browse files
committed
chore: fmt
1 parent a82feb2 commit a829079

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/automation/README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,33 @@ yarn add @lit-protocol/automation
2424
## Core Concepts
2525

2626
### State Machine
27+
2728
A state machine consists of states, and transitions between those states which are triggered based on a collection of Listeners.
2829

2930
### States
31+
3032
States represent different phases of your automation. Each state can:
33+
3134
- Execute code when entered and/or exited
3235
- Configure PKPs and Capacity Credits for the machine
3336
- Run Lit Actions
3437
- Send blockchain transactions
3538
- Run custom code
3639

3740
### Transitions
41+
3842
Transitions define how the machine moves between states. They can be triggered automatically or by any combination of:
43+
3944
- Blockchain events
4045
- Token balance changes
4146
- Timers and intervals
4247
- HTTP requests (polling)
4348
- Custom conditions
4449

4550
### Listeners
51+
4652
Listeners monitor various events and feed data to transitions:
53+
4754
- EVMBlockListener: Monitors new blocks
4855
- EVMContractEventListener: Monitors EVM smart contract events
4956
- TimerListener: Triggers based on time
@@ -122,13 +129,12 @@ runLitActionInterval().catch(console.error);
122129

123130
There care cases where such a declarative interface won't be enough for your use case. When that happens, the machines can also accept generic states, transitions and listeners where it is possible to write any logic.
124131

125-
126132
Here is an example that listens to Ethereum blocks looking one whose numbers ends in 0
127133

128134
```typescript
129135
async function monitorEthereumBlocksWithHashEndingWithZero() {
130136
const litNodeClient = new LitNodeClient({
131-
litNetwork: 'datil-dev'
137+
litNetwork: 'datil-dev',
132138
});
133139
const litContracts = new LitContracts({
134140
network: 'datil-dev',
@@ -144,7 +150,8 @@ async function monitorEthereumBlocksWithHashEndingWithZero() {
144150
// Add each state individually
145151
stateMachine.addState({
146152
key: 'listenBlocks',
147-
onEnter: async () => console.log('Waiting for a block with a hash ending in 0'),
153+
onEnter: async () =>
154+
console.log('Waiting for a block with a hash ending in 0'),
148155
onExit: async () => console.log('Found a block whose hash ends in 0!'),
149156
});
150157
stateMachine.addState({
@@ -191,6 +198,7 @@ Last machine could have been implemented with just the `listenBlocks` state and
191198
Each State Machine has its own information repository called `context`.
192199

193200
When using the defined states in the declarative interface, some values are already populated and then used later
201+
194202
- `StateDefinition.usePkp` populates `context.activePkp` with the minted PKP data
195203
- `StateDefinition.useCapacityNFT` populates `context.activeCapacityTokenId` with the minted Capacity Token Id
196204
- `StateDefinition.litAction` populates `context.lastLitActionResponse` with the lit action response
@@ -292,7 +300,8 @@ async function bridgeBaseSepoliaUSDCToEthereumSepolia() {
292300
eventName: 'Transfer',
293301
// Filter events using params for just listening the pkp.ethAddress as destination
294302
eventParams: [null, pkp.ethAddress],
295-
contextUpdates: [ // The transition can perform some updates to the context
303+
contextUpdates: [
304+
// The transition can perform some updates to the context
296305
{
297306
contextPath: 'transfer.sender', // The context path to update
298307
dataPath: 'event.args[0]', // The value from the event to save in the context

0 commit comments

Comments
 (0)