Skip to content

Commit

Permalink
fix: amend fix near-contract standards event emission
Browse files Browse the repository at this point in the history
  • Loading branch information
fospring committed Mar 17, 2024
1 parent 61460a9 commit 8c038f1
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 6 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/near-contract-standards/lib/util.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/near-contract-standards/lib/util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { NearEvent } from "../event";
import { TokenId } from "./token";
import { toSnakeCase } from "../util";

export type Nep171EventKind = NftMint[] | NftTransfer[] | NftBurn[];
export type Nep171EventKind = NftMint[] | NftTransfer[] | NftBurn[] | NftContractMetadataUpdate[];

export class Nep171Event extends NearEvent {
standard: string;
Expand Down Expand Up @@ -102,6 +102,25 @@ export class NftBurn {
}
}

/** Data to log for an NFT contract metadata updates. To log this event, call [`.emit()`](NftContractMetadataUpdate.emit). */
export class NftContractMetadataUpdate {
constructor(
public memo?: string
) {}

/** Logs the event to the host. This is required to ensure that the event is triggered
* and to consume the event. */
emit() {
NftContractMetadataUpdate.emit_many([this]);
}

/** Emits an contract metadata update event, through `near.log`,
* where each [`NftBurn`] represents the data of each burn. */
static emit_many(data: NftContractMetadataUpdate[]) {
new_171_v1(data).emit();
}
}

function new_171(version: string, event_kind: Nep171EventKind): NearEvent {
return new Nep171Event(version, event_kind);
}
Expand Down

0 comments on commit 8c038f1

Please sign in to comment.