Skip to content

Contract will throw errors without these changes #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions src/nft-contract/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,33 +49,33 @@ export class Contract extends NearContract {
/*
MINT
*/
@call
@call({ payableFunction: true })
nft_mint({ token_id, metadata, receiver_id, perpetual_royalties }) {
return internalMint({ contract: this, tokenId: token_id, metadata: metadata, receiverId: receiver_id, perpetualRoyalties: perpetual_royalties });
}

/*
CORE
*/
@view
@view({})
//get the information for a specific token ID
nft_token({ token_id }) {
return internalNftToken({ contract: this, tokenId: token_id });
}

@call
@call({})
//implementation of the nft_transfer method. This transfers the NFT from the current owner to the receiver.
nft_transfer({ receiver_id, token_id, approval_id, memo }) {
return internalNftTransfer({ contract: this, receiverId: receiver_id, tokenId: token_id, approvalId: approval_id, memo: memo });
}

@call
@call({})
//implementation of the transfer call method. This will transfer the NFT and call a method on the receiver_id contract
nft_transfer_call({ receiver_id, token_id, approval_id, memo, msg }) {
return internalNftTransferCall({ contract: this, receiverId: receiver_id, tokenId: token_id, approvalId: approval_id, memo: memo, msg: msg });
}

@call
@call({})
//resolves the cross contract call when calling nft_on_transfer in the nft_transfer_call method
//returns true if the token was successfully transferred to the receiver_id
nft_resolve_transfer({ authorized_id, owner_id, receiver_id, token_id, approved_account_ids, memo }) {
Expand All @@ -85,13 +85,13 @@ export class Contract extends NearContract {
/*
APPROVALS
*/
@view
@view({})
//check if the passed in account has access to approve the token ID
nft_is_approved({ token_id, approved_account_id, approval_id }) {
return internalNftIsApproved({ contract: this, tokenId: token_id, approvedAccountId: approved_account_id, approvalId: approval_id });
}

@call
@call({})
//approve an account ID to transfer a token on your behalf
nft_approve({ token_id, account_id, msg }) {
return internalNftApprove({ contract: this, tokenId: token_id, accountId: account_id, msg: msg });
Expand All @@ -100,25 +100,25 @@ export class Contract extends NearContract {
/*
ROYALTY
*/
@view
@view({})
//calculates the payout for a token given the passed in balance. This is a view method
nft_payout({ token_id, balance, max_len_payout }) {
return internalNftPayout({ contract: this, tokenId: token_id, balance: balance, maxLenPayout: max_len_payout });
}

@call
@call({})
//transfers the token to the receiver ID and returns the payout object that should be payed given the passed in balance.
nft_transfer_payout({ receiver_id, token_id, approval_id, memo, balance, max_len_payout }) {
return internalNftTransferPayout({ contract: this, receiverId: receiver_id, tokenId: token_id, approvalId: approval_id, memo: memo, balance: balance, maxLenPayout: max_len_payout });
}

@call
@call({})
//approve an account ID to transfer a token on your behalf
nft_revoke({ token_id, account_id }) {
return internalNftRevoke({ contract: this, tokenId: token_id, accountId: account_id });
}

@call
@call({})
//approve an account ID to transfer a token on your behalf
nft_revoke_all({ token_id }) {
return internalNftRevokeAll({ contract: this, tokenId: token_id });
Expand All @@ -127,25 +127,25 @@ export class Contract extends NearContract {
/*
ENUMERATION
*/
@view
@view({})
//Query for the total supply of NFTs on the contract
nft_total_supply() {
return internalTotalSupply({ contract: this });
}

@view
@view({})
//Query for nft tokens on the contract regardless of the owner using pagination
nft_tokens({ from_index, limit }) {
return internalNftTokens({ contract: this, fromIndex: from_index, limit: limit });
}

@view
@view({})
//get the total supply of NFTs for a given owner
nft_tokens_for_owner({ account_id, from_index, limit }) {
return internalTokensForOwner({ contract: this, accountId: account_id, fromIndex: from_index, limit: limit });
}

@view
@view({})
//Query for all the tokens for an owner
nft_supply_for_owner({ account_id }) {
return internalSupplyForOwner({ contract: this, accountId: account_id });
Expand All @@ -154,9 +154,9 @@ export class Contract extends NearContract {
/*
METADATA
*/
@view
@view({})
//Query for all the tokens for an owner
nft_metadata() {
return internalNftMetadata({ contract: this });
}
}
}
Loading