Skip to content

Commit

Permalink
Address Serhii's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ailisp committed Nov 4, 2022
1 parent f8b4fce commit 36708b2
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 49 deletions.
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
yarn.lock linguist-generated=true -diff
lib/**/*.js linguist-generated=true -diff
lib/**/*.d.ts linguist-generated=true -diff
lib/**/*.d.ts linguist-generated=true -diff
near-contract-standards/lib/**/*.js linguist-generated=true -diff
near-contract-standards/lib/**/*.d.ts linguist-generated=true -diff
6 changes: 3 additions & 3 deletions near-contract-standards/lib/event.d.ts

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.

16 changes: 8 additions & 8 deletions near-contract-standards/lib/non_fungible_token/events.d.ts

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

16 changes: 8 additions & 8 deletions near-contract-standards/lib/non_fungible_token/events.js

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

2 changes: 1 addition & 1 deletion near-contract-standards/lib/non_fungible_token/impl.d.ts

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

2 changes: 1 addition & 1 deletion near-contract-standards/lib/non_fungible_token/impl.js

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

8 changes: 4 additions & 4 deletions near-contract-standards/lib/non_fungible_token/utils.d.ts

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

6 changes: 3 additions & 3 deletions near-contract-standards/src/event.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { near } from "near-sdk-js";

export class NearEvent {
internal_to_json_string(): string {
export abstract class NearEvent {
private internal_to_json_string(): string {
return JSON.stringify(this);
}

internal_to_json_event_string(): string {
private internal_to_json_event_string(): string {
return `EVENT_JSON: ${this.internal_to_json_string()}`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PromiseOrValue } from "near-sdk-js/lib";
import { AccountId } from "near-sdk-js/lib/types";
import { TokenId } from "../token";

/** Approval receiver is the trait for the method called (or attempted to be called) when an NFT contract adds an approval for an account. */
/** Approval receiver is the interface for the method called (or attempted to be called) when an NFT contract adds an approval for an account. */
export interface NonFungibleTokenApprovalReceiver {
/** Respond to notification that contract has been granted approval for a token.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PromiseOrValue } from "near-sdk-js/lib";
import { AccountId } from "near-sdk-js/lib/types";
import { TokenId } from "../token";

/** Used when an NFT is transferred using `nft_transfer_call`. This trait is implemented on the receiving contract, not on the NFT contract. */
/** Used when an NFT is transferred using `nft_transfer_call`. This interface is implemented on the receiving contract, not on the NFT contract. */
export interface NonFungibleTokenReceiver {
/** Take some action after receiving a non-fungible token
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AccountId } from "../../../../lib/types";
import { TokenId } from "../token";
import { Option } from "../utils";

/** Used when an NFT is transferred using `nft_transfer_call`. This is the method that's called after `nft_on_transfer`. This trait is implemented on the NFT contract. */
/** Used when an NFT is transferred using `nft_transfer_call`. This is the method that's called after `nft_on_transfer`. This interface is implemented on the NFT contract. */
export interface NonFungibleTokenResolver {
/** Finalize an `nft_transfer_call` chain of cross-contract calls.
*
Expand Down
16 changes: 8 additions & 8 deletions near-contract-standards/src/non_fungible_token/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* The three events in this standard are [`NftMint`], [`NftTransfer`], and [`NftBurn`].
*
* These events can be logged by calling `.emit()` on them if a single event, or calling
* [`NftMint::emit_many`], [`NftTransfer::emit_many`],
* or [`NftBurn::emit_many`] respectively.
* [`NftMint.emit_many`], [`NftTransfer.emit_many`],
* or [`NftBurn.emit_many`] respectively.
*/
import { NearEvent } from "../event";
import { Option } from "./utils";
Expand All @@ -29,7 +29,7 @@ export class Nep171Event extends NearEvent {
}
}

/** Data to log for an NFT mint event. To log this event, call [`.emit()`](NftMint::emit). */
/** Data to log for an NFT mint event. To log this event, call `.emit()` */
export class NftMint {
constructor(
public owner_id: string,
Expand All @@ -43,15 +43,15 @@ export class NftMint {
NftMint.emit_many([this]);
}

/** Emits an nft mint event, through [`env::log_str`](near_sdk::env::log_str),
/** Emits an nft mint event, through `near.log`,
* where each [`NftMint`] represents the data of each mint. */
static emit_many(data: NftMint[]) {
new_171_v1(data).emit();
}
}

/** Data to log for an NFT transfer event. To log this event,
* call [`.emit()`](NftTransfer::emit). */
* call [`.emit()`](NftTransfer.emit). */
export class NftTransfer {
constructor(
public old_owner_id: string,
Expand All @@ -67,14 +67,14 @@ export class NftTransfer {
NftTransfer.emit_many([this]);
}

/** Emits an nft transfer event, through [`env::log_str`](near_sdk::env::log_str),
/** Emits an nft transfer event, through `near.log`,
* where each [`NftTransfer`] represents the data of each transfer. */
static emit_many(data: NftTransfer[]) {
new_171_v1(data).emit();
}
}

/** Data to log for an NFT burn event. To log this event, call [`.emit()`](NftBurn::emit). */
/** Data to log for an NFT burn event. To log this event, call [`.emit()`](NftBurn.emit). */
export class NftBurn {
constructor(
public owner_id: string,
Expand All @@ -89,7 +89,7 @@ export class NftBurn {
NftBurn.emit_many([this]);
}

/** Emits an nft burn event, through [`env::log_str`](near_sdk::env::log_str),
/** Emits an nft burn event, through `near.log`,
* where each [`NftBurn`] represents the data of each burn. */
static emit_many(data: NftBurn[]) {
new_171_v1(data).emit();
Expand Down
2 changes: 1 addition & 1 deletion near-contract-standards/src/non_fungible_token/impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function expect_approval<T>(option: Option<T>): T {

/** Implementation of the non-fungible token standard.
* Allows to include NEP-171 compatible token to any contract.
* There are next traits that any contract may implement:
* There are next interfaces that any contract may implement:
* - NonFungibleTokenCore -- interface with nft_transfer methods. NonFungibleToken provides methods for it.
* - NonFungibleTokenApproval -- interface with nft_approve methods. NonFungibleToken provides methods for it.
* - NonFungibleTokenEnumeration -- interface for getting lists of tokens. NonFungibleToken provides methods for it.
Expand Down
10 changes: 5 additions & 5 deletions near-contract-standards/src/non_fungible_token/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export function bytes_for_approved_account_id(account_id: string): number {
}

export function refund_approved_account_ids_iter(
account_id: string,
approved_account_ids: string[]
account_id: AccountId,
approved_account_ids: AccountId[]
): void {
const storage_released = approved_account_ids
.map(bytes_for_approved_account_id)
Expand All @@ -23,7 +23,7 @@ export function refund_approved_account_ids_iter(

export function refund_approved_account_ids(
account_id: AccountId,
approved_account_ids: { [approvals: string]: bigint }
approved_account_ids: { [approvals: AccountId]: bigint }
) {
refund_approved_account_ids_iter(
account_id,
Expand All @@ -33,7 +33,7 @@ export function refund_approved_account_ids(

export function refund_deposit_to_account(
storage_used: bigint,
account_id: string
account_id: AccountId
): void {
const required_cost = near.storageByteCost() * storage_used;
const attached_deposit = near.attachedDeposit();
Expand All @@ -56,7 +56,7 @@ export function refund_deposit(storage_used: bigint): void {
refund_deposit_to_account(storage_used, near.predecessorAccountId());
}

export function hash_account_id(account_id: string): Bytes {
export function hash_account_id(account_id: AccountId): Bytes {
return near.sha256(account_id);
}

Expand Down

0 comments on commit 36708b2

Please sign in to comment.