Skip to content

Commit

Permalink
chore: extract event emitter types into separate file; fix export err…
Browse files Browse the repository at this point in the history
…or for utils-ts-debug (#325)

* chore: adding missing export

* refactor: move out generic event interfaces into separate type file
  • Loading branch information
aorumbayev authored Oct 10, 2024
1 parent 510899b commit 155a2cd
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 90 deletions.
1 change: 1 addition & 0 deletions docs/code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
- [types/expand](modules/types_expand.md)
- [types/indexer](modules/types_indexer.md)
- [types/kmd-account-manager](modules/types_kmd_account_manager.md)
- [types/lifecycle-events](modules/types_lifecycle_events.md)
- [types/logging](modules/types_logging.md)
- [types/logic-error](modules/types_logic_error.md)
- [types/network-client](modules/types_network_client.md)
Expand Down
32 changes: 16 additions & 16 deletions docs/code/classes/types_async_event_emitter.AsyncEventEmitter.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

#### Defined in

[src/types/async-event-emitter.ts:18](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L18)
[src/types/async-event-emitter.ts:7](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L7)

___

Expand All @@ -51,7 +51,7 @@ ___

#### Defined in

[src/types/async-event-emitter.ts:17](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L17)
[src/types/async-event-emitter.ts:6](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L6)

___

Expand All @@ -76,7 +76,7 @@ ___

#### Defined in

[src/types/async-event-emitter.ts:66](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L66)
[src/types/async-event-emitter.ts:55](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L55)

## Methods

Expand All @@ -88,22 +88,22 @@ ___

| Name | Type |
| :------ | :------ |
| `K` | extends [`EventType`](../enums/types_async_event_emitter.EventType.md) |
| `K` | extends [`EventType`](../enums/types_lifecycle_events.EventType.md) |

#### Parameters

| Name | Type |
| :------ | :------ |
| `eventName` | `K` |
| `event` | [`EventDataMap`](../modules/types_async_event_emitter.md#eventdatamap)[`K`] |
| `event` | [`EventDataMap`](../modules/types_lifecycle_events.md#eventdatamap)[`K`] |

#### Returns

`Promise`\<`void`\>

#### Defined in

[src/types/async-event-emitter.ts:20](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L20)
[src/types/async-event-emitter.ts:9](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L9)

**emitAsync**(`eventName`, `event`): `Promise`\<`void`\>

Expand All @@ -120,7 +120,7 @@ ___

#### Defined in

[src/types/async-event-emitter.ts:21](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L21)
[src/types/async-event-emitter.ts:10](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L10)

___

Expand All @@ -132,22 +132,22 @@ ___

| Name | Type |
| :------ | :------ |
| `K` | extends [`EventType`](../enums/types_async_event_emitter.EventType.md) |
| `K` | extends [`EventType`](../enums/types_lifecycle_events.EventType.md) |

#### Parameters

| Name | Type |
| :------ | :------ |
| `eventName` | `K` |
| `listener` | [`AsyncEventListener`](../modules/types_async_event_emitter.md#asynceventlistener)\<[`EventDataMap`](../modules/types_async_event_emitter.md#eventdatamap)[`K`]\> |
| `listener` | [`AsyncEventListener`](../modules/types_async_event_emitter.md#asynceventlistener)\<[`EventDataMap`](../modules/types_lifecycle_events.md#eventdatamap)[`K`]\> |

#### Returns

[`AsyncEventEmitter`](types_async_event_emitter.AsyncEventEmitter.md)

#### Defined in

[src/types/async-event-emitter.ts:28](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L28)
[src/types/async-event-emitter.ts:17](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L17)

**on**\<`T`\>(`eventName`, `listener`): [`AsyncEventEmitter`](types_async_event_emitter.AsyncEventEmitter.md)

Expand All @@ -170,7 +170,7 @@ ___

#### Defined in

[src/types/async-event-emitter.ts:29](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L29)
[src/types/async-event-emitter.ts:18](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L18)

___

Expand All @@ -182,22 +182,22 @@ ___

| Name | Type |
| :------ | :------ |
| `K` | extends [`EventType`](../enums/types_async_event_emitter.EventType.md) |
| `K` | extends [`EventType`](../enums/types_lifecycle_events.EventType.md) |

#### Parameters

| Name | Type |
| :------ | :------ |
| `eventName` | `K` |
| `listener` | [`AsyncEventListener`](../modules/types_async_event_emitter.md#asynceventlistener)\<[`EventDataMap`](../modules/types_async_event_emitter.md#eventdatamap)[`K`]\> |
| `listener` | [`AsyncEventListener`](../modules/types_async_event_emitter.md#asynceventlistener)\<[`EventDataMap`](../modules/types_lifecycle_events.md#eventdatamap)[`K`]\> |

#### Returns

[`AsyncEventEmitter`](types_async_event_emitter.AsyncEventEmitter.md)

#### Defined in

[src/types/async-event-emitter.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L36)
[src/types/async-event-emitter.ts:25](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L25)

**once**\<`T`\>(`eventName`, `listener`): [`AsyncEventEmitter`](types_async_event_emitter.AsyncEventEmitter.md)

Expand All @@ -220,7 +220,7 @@ ___

#### Defined in

[src/types/async-event-emitter.ts:37](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L37)
[src/types/async-event-emitter.ts:26](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L26)

___

Expand All @@ -241,4 +241,4 @@ ___

#### Defined in

[src/types/async-event-emitter.ts:50](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L50)
[src/types/async-event-emitter.ts:39](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L39)
32 changes: 0 additions & 32 deletions docs/code/enums/types_async_event_emitter.EventType.md

This file was deleted.

32 changes: 32 additions & 0 deletions docs/code/enums/types_lifecycle_events.EventType.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[@algorandfoundation/algokit-utils](../README.md) / [types/lifecycle-events](../modules/types_lifecycle_events.md) / EventType

# Enumeration: EventType

[types/lifecycle-events](../modules/types_lifecycle_events.md).EventType

## Table of contents

### Enumeration Members

- [AppCompiled](types_lifecycle_events.EventType.md#appcompiled)
- [TxnGroupSimulated](types_lifecycle_events.EventType.md#txngroupsimulated)

## Enumeration Members

### AppCompiled

**AppCompiled** = ``"AppCompiled"``

#### Defined in

[src/types/lifecycle-events.ts:5](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/lifecycle-events.ts#L5)

___

### TxnGroupSimulated

**TxnGroupSimulated** = ``"TxnGroupSimulated"``

#### Defined in

[src/types/lifecycle-events.ts:4](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/lifecycle-events.ts#L4)
14 changes: 14 additions & 0 deletions docs/code/modules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
- [AVMTracesEventData](index.md#avmtraceseventdata)
- [AlgorandClient](index.md#algorandclient)
- [DEFAULT\_MAX\_SEARCH\_DEPTH](index.md#default_max_search_depth)
- [EventDataMap](index.md#eventdatamap)
- [EventType](index.md#eventtype)
- [SOURCES\_DIR](index.md#sources_dir)
- [TEAL\_FILE\_EXT](index.md#teal_file_ext)
- [TEAL\_SOURCEMAP\_EXT](index.md#teal_sourcemap_ext)
Expand Down Expand Up @@ -158,6 +160,18 @@ Re-exports [DEFAULT_MAX_SEARCH_DEPTH](types_debugging.md#default_max_search_dept

___

### EventDataMap

Re-exports [EventDataMap](types_lifecycle_events.md#eventdatamap)

___

### EventType

Re-exports [EventType](../enums/types_lifecycle_events.EventType.md)

___

### SOURCES\_DIR

Re-exports [SOURCES_DIR](types_debugging.md#sources_dir)
Expand Down
28 changes: 1 addition & 27 deletions docs/code/modules/types_async_event_emitter.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@

## Table of contents

### Enumerations

- [EventType](../enums/types_async_event_emitter.EventType.md)

### Classes

- [AsyncEventEmitter](../classes/types_async_event_emitter.AsyncEventEmitter.md)

### Type Aliases

- [AsyncEventListener](types_async_event_emitter.md#asynceventlistener)
- [EventDataMap](types_async_event_emitter.md#eventdatamap)

## Type Aliases

Expand Down Expand Up @@ -46,25 +41,4 @@

#### Defined in

[src/types/async-event-emitter.ts:14](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L14)

___

### EventDataMap

Ƭ **EventDataMap**: `Object`

#### Index signature

[key: `string`]: `unknown`

#### Type declaration

| Name | Type |
| :------ | :------ |
| `AppCompiled` | [`TealSourcesDebugEventData`](../interfaces/types_debugging.TealSourcesDebugEventData.md) |
| `TxnGroupSimulated` | [`AVMTracesEventData`](../interfaces/types_debugging.AVMTracesEventData.md) |

#### Defined in

[src/types/async-event-emitter.ts:8](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L8)
[src/types/async-event-emitter.ts:3](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/async-event-emitter.ts#L3)
34 changes: 34 additions & 0 deletions docs/code/modules/types_lifecycle_events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[@algorandfoundation/algokit-utils](../README.md) / types/lifecycle-events

# Module: types/lifecycle-events

## Table of contents

### Enumerations

- [EventType](../enums/types_lifecycle_events.EventType.md)

### Type Aliases

- [EventDataMap](types_lifecycle_events.md#eventdatamap)

## Type Aliases

### EventDataMap

Ƭ **EventDataMap**: `Object`

#### Index signature

[key: `string`]: `unknown`

#### Type declaration

| Name | Type |
| :------ | :------ |
| `AppCompiled` | [`TealSourcesDebugEventData`](../interfaces/types_debugging.TealSourcesDebugEventData.md) |
| `TxnGroupSimulated` | [`AVMTracesEventData`](../interfaces/types_debugging.AVMTracesEventData.md) |

#### Defined in

[src/types/lifecycle-events.ts:8](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/lifecycle-events.ts#L8)
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export * as indexer from './indexer-lookup'
export * from './transaction'
export { AlgorandClient } from './types/algorand-client'
export * from './types/debugging'
export * from './types/lifecycle-events'
2 changes: 1 addition & 1 deletion src/transaction/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Buffer } from 'buffer'
import { Config } from '../config'
import { AlgoAmount } from '../types/amount'
import { ABIReturn } from '../types/app'
import { EventType } from '../types/async-event-emitter'
import { EventType } from '../types/lifecycle-events'
import {
AtomicTransactionComposerToSend,
SendAtomicTransactionComposerResults,
Expand Down
2 changes: 1 addition & 1 deletion src/types/app-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import {
import { AppLookup } from './app-deployer'
import { AppManager, BoxIdentifier } from './app-manager'
import { AppSpec, arc32ToArc56 } from './app-spec'
import { EventType } from './async-event-emitter'
import AlgoKitComposer, {
AppCallMethodCall,
AppCallParams,
Expand All @@ -71,6 +70,7 @@ import AlgoKitComposer, {
PaymentParams,
} from './composer'
import { Expand } from './expand'
import { EventType } from './lifecycle-events'
import { LogicError } from './logic-error'
import { SendParams, SendTransactionFrom, SendTransactionParams, TransactionNote } from './transaction'
import ABIMethod = algosdk.ABIMethod
Expand Down
13 changes: 1 addition & 12 deletions src/types/async-event-emitter.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
import { AVMTracesEventData, TealSourcesDebugEventData } from './debugging'

export enum EventType {
TxnGroupSimulated = 'TxnGroupSimulated',
AppCompiled = 'AppCompiled',
}

export type EventDataMap = {
[EventType.TxnGroupSimulated]: AVMTracesEventData
[EventType.AppCompiled]: TealSourcesDebugEventData
[key: string]: unknown
}
import { EventDataMap, EventType } from './lifecycle-events'

export type AsyncEventListener<T = unknown> = (event: T, eventName: string | symbol) => Promise<void> | void

Expand Down
2 changes: 1 addition & 1 deletion src/types/composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { TransactionSignerAccount } from './account'
import { AlgoAmount } from './amount'
import { APP_PAGE_MAX_SIZE } from './app'
import { AppManager, BoxIdentifier, BoxReference } from './app-manager'
import { EventType } from './async-event-emitter'
import { Expand } from './expand'
import { EventType } from './lifecycle-events'
import { genesisIdIsLocalNet } from './network-client'
import { Arc2TransactionNote, SendAtomicTransactionComposerResults, SendParams } from './transaction'
import AtomicTransactionComposer = algosdk.AtomicTransactionComposer
Expand Down
12 changes: 12 additions & 0 deletions src/types/lifecycle-events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { AVMTracesEventData, TealSourcesDebugEventData } from './debugging'

export enum EventType {
TxnGroupSimulated = 'TxnGroupSimulated',
AppCompiled = 'AppCompiled',
}

export type EventDataMap = {
[EventType.TxnGroupSimulated]: AVMTracesEventData
[EventType.AppCompiled]: TealSourcesDebugEventData
[key: string]: unknown
}

0 comments on commit 155a2cd

Please sign in to comment.