Skip to content

Commit d9e608f

Browse files
committed
Merge branch 'develop' into 3.0.0
2 parents 11c8dd7 + 7f2e734 commit d9e608f

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/abi/contract.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ABIMethod, ABIMethodParams, getMethodByName } from './method.js';
2+
import { ARC28Event } from './event.js';
23

34
export interface ABIContractNetworkInfo {
45
appID: number;
@@ -13,13 +14,16 @@ export interface ABIContractParams {
1314
desc?: string;
1415
networks?: ABIContractNetworks;
1516
methods: ABIMethodParams[];
17+
events?: ARC28Event[];
1618
}
1719

1820
export class ABIContract {
1921
public readonly name: string;
2022
public readonly description?: string;
2123
public readonly networks: ABIContractNetworks;
2224
public readonly methods: ABIMethod[];
25+
/** [ARC-28](https://arc.algorand.foundation/ARCs/arc-0028) events that MAY be emitted by this contract */
26+
public readonly events?: ARC28Event[];
2327

2428
constructor(params: ABIContractParams) {
2529
if (
@@ -34,6 +38,7 @@ export class ABIContract {
3438
this.description = params.desc;
3539
this.networks = params.networks ? { ...params.networks } : {};
3640
this.methods = params.methods.map((method) => new ABIMethod(method));
41+
this.events = params.events;
3742
}
3843

3944
toJSON(): ABIContractParams {
@@ -42,6 +47,7 @@ export class ABIContract {
4247
desc: this.description,
4348
networks: this.networks,
4449
methods: this.methods.map((method) => method.toJSON()),
50+
events: this.events,
4551
};
4652
}
4753

src/abi/event.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/** [ARC-28](https://arc.algorand.foundation/ARCs/arc-0028) event description */
2+
export interface ARC28Event {
3+
/** The name of the event */
4+
name: string;
5+
/** Optional, user-friendly description for the event */
6+
desc?: string;
7+
/** The arguments of the event, in order */
8+
args: Array<{
9+
/** The type of the argument */
10+
type: string;
11+
/** Optional, user-friendly name for the argument */
12+
name?: string;
13+
/** Optional, user-friendly description for the argument */
14+
desc?: string;
15+
}>;
16+
}

src/abi/method.ts

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { genericHash } from '../nacl/naclWrappers.js';
22
import { ABIType, ABITupleType } from './abi_type.js';
33
import { ABITransactionType, abiTypeIsTransaction } from './transaction.js';
44
import { ABIReferenceType, abiTypeIsReference } from './reference.js';
5+
import { ARC28Event } from './event.js';
56

67
function parseMethodSignature(signature: string): {
78
name: string;
@@ -63,6 +64,10 @@ export interface ABIMethodParams {
6364
desc?: string;
6465
args: ABIMethodArgParams[];
6566
returns: ABIMethodReturnParams;
67+
/** Optional, is it a read-only method (according to [ARC-22](https://arc.algorand.foundation/ARCs/arc-0022)) */
68+
readonly?: boolean;
69+
/** [ARC-28](https://arc.algorand.foundation/ARCs/arc-0028) events that MAY be emitted by this method */
70+
events?: ARC28Event[];
6671
}
6772

6873
export type ABIArgumentType = ABIType | ABITransactionType | ABIReferenceType;
@@ -79,6 +84,8 @@ export class ABIMethod {
7984
}>;
8085

8186
public readonly returns: { type: ABIReturnType; description?: string };
87+
public readonly events?: ARC28Event[];
88+
public readonly readonly?: boolean;
8289

8390
constructor(params: ABIMethodParams) {
8491
if (
@@ -113,6 +120,9 @@ export class ABIMethod {
113120
: ABIType.from(params.returns.type),
114121
description: params.returns.desc,
115122
};
123+
124+
this.events = params.events;
125+
this.readonly = params.readonly;
116126
}
117127

118128
getSignature(): string {
@@ -149,6 +159,8 @@ export class ABIMethod {
149159
type: this.returns.type.toString(),
150160
desc: this.returns.description,
151161
},
162+
events: this.events,
163+
readonly: this.readonly,
152164
};
153165
}
154166

0 commit comments

Comments
 (0)