mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-26 03:25:09 +00:00
added more comment consistancy fix
Signed-off-by: Ali Shahverdi <ali@Alis-MacBook-Pro.local>
This commit is contained in:
parent
0959261d07
commit
615f2fe6f9
19 changed files with 138 additions and 139 deletions
|
|
@ -28,7 +28,7 @@ func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface,
|
|||
// Demonstrate the use of Attribute-Based Access Control (ABAC) by checking
|
||||
// to see if the caller has the "abac.creator" attribute with a value of true;
|
||||
// if not, return an error.
|
||||
//
|
||||
|
||||
err := ctx.GetClientIdentity().AssertAttributeValue("abac.creator", "true")
|
||||
if err != nil {
|
||||
return fmt.Errorf("submitting client not authorized to create asset, does not have abac.creator role")
|
||||
|
|
|
|||
|
|
@ -231,9 +231,9 @@ async function findSoftHSMPKCS11Lib() {
|
|||
if (typeof process.env.PKCS11_LIB === 'string' && process.env.PKCS11_LIB !== '') {
|
||||
pkcsLibPath = process.env.PKCS11_LIB;
|
||||
} else {
|
||||
//
|
||||
|
||||
// Check common locations for PKCS library
|
||||
//
|
||||
|
||||
for (const pathnameToTry of commonSoftHSMPathNames) {
|
||||
if (fs.existsSync(pathnameToTry)) {
|
||||
pkcsLibPath = pathnameToTry;
|
||||
|
|
|
|||
|
|
@ -47,11 +47,10 @@ const org1UserId = 'appUser';
|
|||
*/
|
||||
// Delete the /fabric-samples/asset-transfer-basic/application-typescript/wallet directory
|
||||
// and retry this application.
|
||||
//
|
||||
|
||||
// The certificate authority must have been restarted and the saved certificates for the
|
||||
// admin and application user are not valid. Deleting the wallet store will force these to be reset
|
||||
// with the new certificate authority.
|
||||
//
|
||||
|
||||
/**
|
||||
* A test application to show basic queries operations with any of the asset-transfer-basic chaincodes
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ func (s *SmartContract) DeleteAsset(ctx contractapi.TransactionContextInterface)
|
|||
return fmt.Errorf("failed to infer private collection name for the org: %v", err)
|
||||
}
|
||||
|
||||
//check the asset is in the caller org's private collection
|
||||
// Check the asset is in the caller org's private collection
|
||||
valAsbytes, err = ctx.GetStub().GetPrivateData(ownerCollection, assetDeleteInput.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read asset from owner's Collection: %v", err)
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ type ToID struct {
|
|||
// This function emits a TransferSingle event.
|
||||
func (s *SmartContract) Mint(ctx contractapi.TransactionContextInterface, account string, id uint64, amount uint64) error {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -153,7 +153,7 @@ func (s *SmartContract) Mint(ctx contractapi.TransactionContextInterface, accoun
|
|||
// This function emits a TransferBatch event.
|
||||
func (s *SmartContract) MintBatch(ctx contractapi.TransactionContextInterface, account string, ids []uint64, amounts []uint64) error {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -209,7 +209,7 @@ func (s *SmartContract) MintBatch(ctx contractapi.TransactionContextInterface, a
|
|||
// This function triggers a TransferSingle event.
|
||||
func (s *SmartContract) Burn(ctx contractapi.TransactionContextInterface, account string, id uint64, amount uint64) error {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -248,7 +248,7 @@ func (s *SmartContract) Burn(ctx contractapi.TransactionContextInterface, accoun
|
|||
// This function emits a TransferBatch event.
|
||||
func (s *SmartContract) BurnBatch(ctx contractapi.TransactionContextInterface, account string, ids []uint64, amounts []uint64) error {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -291,7 +291,7 @@ func (s *SmartContract) BurnBatch(ctx contractapi.TransactionContextInterface, a
|
|||
// This function triggers a TransferSingle event
|
||||
func (s *SmartContract) TransferFrom(ctx contractapi.TransactionContextInterface, sender string, recipient string, id uint64, amount uint64) error {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -347,7 +347,7 @@ func (s *SmartContract) TransferFrom(ctx contractapi.TransactionContextInterface
|
|||
// This function triggers a TransferBatch event
|
||||
func (s *SmartContract) BatchTransferFrom(ctx contractapi.TransactionContextInterface, sender string, recipient string, ids []uint64, amounts []uint64) error {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -422,7 +422,7 @@ func (s *SmartContract) BatchTransferFrom(ctx contractapi.TransactionContextInte
|
|||
// This function triggers a TransferBatchMultiRecipient event
|
||||
func (s *SmartContract) BatchTransferFromMultiRecipient(ctx contractapi.TransactionContextInterface, sender string, recipients []string, ids []uint64, amounts []uint64) error {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -504,7 +504,7 @@ func (s *SmartContract) IsApprovedForAll(ctx contractapi.TransactionContextInter
|
|||
// _isApprovedForAll returns true if operator is approved to transfer account's tokens.
|
||||
func _isApprovedForAll(ctx contractapi.TransactionContextInterface, account string, operator string) (bool, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -539,7 +539,7 @@ func _isApprovedForAll(ctx contractapi.TransactionContextInterface, account stri
|
|||
// SetApprovalForAll returns true if operator is approved to transfer account's tokens.
|
||||
func (s *SmartContract) SetApprovalForAll(ctx contractapi.TransactionContextInterface, operator string, approved bool) error {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -589,7 +589,7 @@ func (s *SmartContract) SetApprovalForAll(ctx contractapi.TransactionContextInte
|
|||
// BalanceOf returns the balance of the given account
|
||||
func (s *SmartContract) BalanceOf(ctx contractapi.TransactionContextInterface, account string, id uint64) (uint64, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -604,7 +604,7 @@ func (s *SmartContract) BalanceOf(ctx contractapi.TransactionContextInterface, a
|
|||
// BalanceOfBatch returns the balance of multiple account/token pairs
|
||||
func (s *SmartContract) BalanceOfBatch(ctx contractapi.TransactionContextInterface, accounts []string, ids []uint64) ([]uint64, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -633,7 +633,7 @@ func (s *SmartContract) BalanceOfBatch(ctx contractapi.TransactionContextInterfa
|
|||
// ClientAccountBalance returns the balance of the requesting client's account
|
||||
func (s *SmartContract) ClientAccountBalance(ctx contractapi.TransactionContextInterface, id uint64) (uint64, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -656,7 +656,7 @@ func (s *SmartContract) ClientAccountBalance(ctx contractapi.TransactionContextI
|
|||
// Users can use this function to get their own account id, which they can then give to others as the payment address
|
||||
func (s *SmartContract) ClientAccountID(ctx contractapi.TransactionContextInterface) (string, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -678,7 +678,7 @@ func (s *SmartContract) ClientAccountID(ctx contractapi.TransactionContextInterf
|
|||
// This function triggers URI event for each token id
|
||||
func (s *SmartContract) SetURI(ctx contractapi.TransactionContextInterface, uri string) error {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -708,7 +708,7 @@ func (s *SmartContract) SetURI(ctx contractapi.TransactionContextInterface, uri
|
|||
// URI returns the URI
|
||||
func (s *SmartContract) URI(ctx contractapi.TransactionContextInterface, id uint64) (string, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -731,7 +731,7 @@ func (s *SmartContract) URI(ctx contractapi.TransactionContextInterface, id uint
|
|||
|
||||
func (s *SmartContract) BroadcastTokenExistance(ctx contractapi.TransactionContextInterface, id uint64) error {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -762,7 +762,7 @@ func (s *SmartContract) BroadcastTokenExistance(ctx contractapi.TransactionConte
|
|||
|
||||
func (s *SmartContract) Name(ctx contractapi.TransactionContextInterface) (string, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -784,7 +784,7 @@ func (s *SmartContract) Name(ctx contractapi.TransactionContextInterface) (strin
|
|||
|
||||
func (s *SmartContract) Symbol(ctx contractapi.TransactionContextInterface) (string, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -815,7 +815,7 @@ func (s *SmartContract) Initialize(ctx contractapi.TransactionContextInterface,
|
|||
return false, fmt.Errorf("client is not authorized to initialize contract")
|
||||
}
|
||||
|
||||
//check contract options are not already set, client is not authorized to change them once intitialized
|
||||
// Check contract options are not already set, client is not authorized to change them once intitialized
|
||||
bytes, err := ctx.GetStub().GetState(nameKey)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to get Name: %v", err)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ type event struct {
|
|||
// This function triggers a Transfer event
|
||||
func (s *SmartContract) Mint(ctx contractapi.TransactionContextInterface, amount int) error {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -135,7 +135,7 @@ func (s *SmartContract) Mint(ctx contractapi.TransactionContextInterface, amount
|
|||
// This function triggers a Transfer event
|
||||
func (s *SmartContract) Burn(ctx contractapi.TransactionContextInterface, amount int) error {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -231,7 +231,7 @@ func (s *SmartContract) Burn(ctx contractapi.TransactionContextInterface, amount
|
|||
// This function triggers a Transfer event
|
||||
func (s *SmartContract) Transfer(ctx contractapi.TransactionContextInterface, recipient string, amount int) error {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -268,7 +268,7 @@ func (s *SmartContract) Transfer(ctx contractapi.TransactionContextInterface, re
|
|||
// BalanceOf returns the balance of the given account
|
||||
func (s *SmartContract) BalanceOf(ctx contractapi.TransactionContextInterface, account string) (int, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -293,7 +293,7 @@ func (s *SmartContract) BalanceOf(ctx contractapi.TransactionContextInterface, a
|
|||
// ClientAccountBalance returns the balance of the requesting client's account
|
||||
func (s *SmartContract) ClientAccountBalance(ctx contractapi.TransactionContextInterface) (int, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -326,7 +326,7 @@ func (s *SmartContract) ClientAccountBalance(ctx contractapi.TransactionContextI
|
|||
// Users can use this function to get their own account id, which they can then give to others as the payment address
|
||||
func (s *SmartContract) ClientAccountID(ctx contractapi.TransactionContextInterface) (string, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -347,7 +347,7 @@ func (s *SmartContract) ClientAccountID(ctx contractapi.TransactionContextInterf
|
|||
// TotalSupply returns the total token supply
|
||||
func (s *SmartContract) TotalSupply(ctx contractapi.TransactionContextInterface) (int, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -381,7 +381,7 @@ func (s *SmartContract) TotalSupply(ctx contractapi.TransactionContextInterface)
|
|||
// This function triggers an Approval event
|
||||
func (s *SmartContract) Approve(ctx contractapi.TransactionContextInterface, spender string, value int) error {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -427,7 +427,7 @@ func (s *SmartContract) Approve(ctx contractapi.TransactionContextInterface, spe
|
|||
// Allowance returns the amount still available for the spender to withdraw from the owner
|
||||
func (s *SmartContract) Allowance(ctx contractapi.TransactionContextInterface, owner string, spender string) (int, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -466,7 +466,7 @@ func (s *SmartContract) Allowance(ctx contractapi.TransactionContextInterface, o
|
|||
// This function triggers a Transfer event
|
||||
func (s *SmartContract) TransferFrom(ctx contractapi.TransactionContextInterface, from string, to string, value int) error {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -539,7 +539,7 @@ func (s *SmartContract) TransferFrom(ctx contractapi.TransactionContextInterface
|
|||
|
||||
func (s *SmartContract) Name(ctx contractapi.TransactionContextInterface) (string, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -561,7 +561,7 @@ func (s *SmartContract) Name(ctx contractapi.TransactionContextInterface) (strin
|
|||
|
||||
func (s *SmartContract) Symbol(ctx contractapi.TransactionContextInterface) (string, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -593,7 +593,7 @@ func (s *SmartContract) Initialize(ctx contractapi.TransactionContextInterface,
|
|||
return false, fmt.Errorf("client is not authorized to initialize contract")
|
||||
}
|
||||
|
||||
//check contract options are not already set, client is not authorized to change them once intitialized
|
||||
// Check contract options are not already set, client is not authorized to change them once intitialized
|
||||
bytes, err := ctx.GetStub().GetState(nameKey)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to get Name: %v", err)
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public final class ERC20TokenContract implements ContractInterface {
|
|||
"Client is not authorized to mint new tokens", UNAUTHORIZED_SENDER.toString());
|
||||
}
|
||||
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
|
||||
// Get ID of submitting client identity
|
||||
|
|
@ -132,7 +132,7 @@ public final class ERC20TokenContract implements ContractInterface {
|
|||
"Client is not authorized to burn tokens", UNAUTHORIZED_SENDER.toString());
|
||||
}
|
||||
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
|
||||
String minter = ctx.getClientIdentity().getId();
|
||||
|
|
@ -181,7 +181,7 @@ public final class ERC20TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.SUBMIT)
|
||||
public void Transfer(final Context ctx, final String to, final long value) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
String from = ctx.getClientIdentity().getId();
|
||||
this.transferHelper(ctx, from, to, value);
|
||||
|
|
@ -198,7 +198,7 @@ public final class ERC20TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public long BalanceOf(final Context ctx, final String owner) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
ChaincodeStub stub = ctx.getStub();
|
||||
CompositeKey balanceKey = stub.createCompositeKey(BALANCE_PREFIX.getValue(), owner);
|
||||
|
|
@ -219,7 +219,7 @@ public final class ERC20TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public long ClientAccountBalance(final Context ctx) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
// Get ID of submitting client identity
|
||||
ChaincodeStub stub = ctx.getStub();
|
||||
|
|
@ -244,7 +244,7 @@ public final class ERC20TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public String ClientAccountID(final Context ctx) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
// Get ID of submitting client identity
|
||||
return ctx.getClientIdentity().getId();
|
||||
|
|
@ -258,7 +258,7 @@ public final class ERC20TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public long TotalSupply(final Context ctx) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
String totalSupply = ctx.getStub().getStringState(TOTAL_SUPPLY_KEY.getValue());
|
||||
if (stringIsNullOrEmpty(totalSupply)) {
|
||||
|
|
@ -277,7 +277,7 @@ public final class ERC20TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.SUBMIT)
|
||||
public void Approve(final Context ctx, final String spender, final long value) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
ChaincodeStub stub = ctx.getStub();
|
||||
String owner = ctx.getClientIdentity().getId();
|
||||
|
|
@ -302,7 +302,7 @@ public final class ERC20TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.SUBMIT)
|
||||
public long Allowance(final Context ctx, final String owner, final String spender) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
ChaincodeStub stub = ctx.getStub();
|
||||
CompositeKey allowanceKey =
|
||||
|
|
@ -330,7 +330,7 @@ public final class ERC20TokenContract implements ContractInterface {
|
|||
@Transaction(intent = Transaction.TYPE.SUBMIT)
|
||||
public void TransferFrom(
|
||||
final Context ctx, final String from, final String to, final long value) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
String spender = ctx.getClientIdentity().getId();
|
||||
ChaincodeStub stub = ctx.getStub();
|
||||
|
|
@ -437,7 +437,7 @@ public final class ERC20TokenContract implements ContractInterface {
|
|||
"Client is not authorized to initialize contract", UNAUTHORIZED_SENDER.toString());
|
||||
}
|
||||
|
||||
//check contract options are not already set, client is not authorized to change them once intitialized
|
||||
// Check contract options are not already set, client is not authorized to change them once intitialized
|
||||
String tokenName = stub.getStringState(ContractConstants.NAME_KEY.getValue());
|
||||
if (!stringIsNullOrEmpty(tokenName)) {
|
||||
throw new ChaincodeException("contract options are already set, client is not authorized to change them");
|
||||
|
|
@ -458,7 +458,7 @@ public final class ERC20TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public String TokenName(final Context ctx) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
String tokenName = ctx.getStub().getStringState(ContractConstants.NAME_KEY.getValue());
|
||||
if (stringIsNullOrEmpty(tokenName)) {
|
||||
|
|
@ -475,7 +475,7 @@ public final class ERC20TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public String TokenSymbol(final Context ctx) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
String tokenSymbol = ctx.getStub().getStringState(SYMBOL_KEY.getValue());
|
||||
if (stringIsNullOrEmpty(tokenSymbol)) {
|
||||
|
|
@ -493,7 +493,7 @@ public final class ERC20TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public int Decimals(final Context ctx) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
String decimals = ctx.getStub().getStringState(DECIMALS_KEY.getValue());
|
||||
if (stringIsNullOrEmpty(decimals)) {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class TokenERC20Contract extends Contract {
|
|||
*/
|
||||
async TokenName(ctx) {
|
||||
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const nameBytes = await ctx.stub.getState(nameKey);
|
||||
|
|
@ -47,7 +47,7 @@ class TokenERC20Contract extends Contract {
|
|||
*/
|
||||
async Symbol(ctx) {
|
||||
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const symbolBytes = await ctx.stub.getState(symbolKey);
|
||||
|
|
@ -63,7 +63,7 @@ class TokenERC20Contract extends Contract {
|
|||
*/
|
||||
async Decimals(ctx) {
|
||||
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const decimalsBytes = await ctx.stub.getState(decimalsKey);
|
||||
|
|
@ -79,7 +79,7 @@ class TokenERC20Contract extends Contract {
|
|||
*/
|
||||
async TotalSupply(ctx) {
|
||||
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const totalSupplyBytes = await ctx.stub.getState(totalSupplyKey);
|
||||
|
|
@ -96,7 +96,7 @@ class TokenERC20Contract extends Contract {
|
|||
*/
|
||||
async BalanceOf(ctx, owner) {
|
||||
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const balanceKey = ctx.stub.createCompositeKey(balancePrefix, [owner]);
|
||||
|
|
@ -121,7 +121,7 @@ class TokenERC20Contract extends Contract {
|
|||
*/
|
||||
async Transfer(ctx, to, value) {
|
||||
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const from = ctx.clientIdentity.getID();
|
||||
|
|
@ -149,7 +149,7 @@ class TokenERC20Contract extends Contract {
|
|||
*/
|
||||
async TransferFrom(ctx, from, to, value) {
|
||||
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const spender = ctx.clientIdentity.getID();
|
||||
|
|
@ -253,7 +253,7 @@ class TokenERC20Contract extends Contract {
|
|||
*/
|
||||
async Approve(ctx, spender, value) {
|
||||
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const owner = ctx.clientIdentity.getID();
|
||||
|
|
@ -281,7 +281,7 @@ class TokenERC20Contract extends Contract {
|
|||
*/
|
||||
async Allowance(ctx, owner, spender) {
|
||||
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const allowanceKey = ctx.stub.createCompositeKey(allowancePrefix, [owner, spender]);
|
||||
|
|
@ -313,7 +313,7 @@ class TokenERC20Contract extends Contract {
|
|||
throw new Error('client is not authorized to initialize contract');
|
||||
}
|
||||
|
||||
//check contract options are not already set, client is not authorized to change them once intitialized
|
||||
// Check contract options are not already set, client is not authorized to change them once intitialized
|
||||
const nameBytes = await ctx.stub.getState(nameKey);
|
||||
if (nameBytes && nameBytes.length > 0) {
|
||||
throw new Error('contract options are already set, client is not authorized to change them');
|
||||
|
|
@ -336,7 +336,7 @@ class TokenERC20Contract extends Contract {
|
|||
*/
|
||||
async Mint(ctx, amount) {
|
||||
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
// Check minter authorization - this sample assumes Org1 is the central banker with privilege to mint new tokens
|
||||
|
|
@ -396,7 +396,7 @@ class TokenERC20Contract extends Contract {
|
|||
*/
|
||||
async Burn(ctx, amount) {
|
||||
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
// Check minter authorization - this sample assumes Org1 is the central banker with privilege to burn tokens
|
||||
|
|
@ -444,7 +444,7 @@ class TokenERC20Contract extends Contract {
|
|||
*/
|
||||
async ClientAccountBalance(ctx) {
|
||||
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
// Get ID of submitting client identity
|
||||
|
|
@ -465,7 +465,7 @@ class TokenERC20Contract extends Contract {
|
|||
// Users can use this function to get their own account id, which they can then give to others as the payment address
|
||||
async ClientAccountID(ctx) {
|
||||
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
// Get ID of submitting client identity
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func _nftExists(ctx contractapi.TransactionContextInterface, tokenId string) boo
|
|||
// returns {int} The number of non-fungible tokens owned by the owner, possibly zero
|
||||
func (c *TokenERC721Contract) BalanceOf(ctx contractapi.TransactionContextInterface, owner string) int {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
panic("failed to check if contract ia already initialized:" + err.Error())
|
||||
|
|
@ -96,7 +96,7 @@ func (c *TokenERC721Contract) BalanceOf(ctx contractapi.TransactionContextInterf
|
|||
// returns {String} Return the owner of the non-fungible token
|
||||
func (c *TokenERC721Contract) OwnerOf(ctx contractapi.TransactionContextInterface, tokenId string) (string, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -119,7 +119,7 @@ func (c *TokenERC721Contract) OwnerOf(ctx contractapi.TransactionContextInterfac
|
|||
// returns {Boolean} Return whether the approval was successful or not
|
||||
func (c *TokenERC721Contract) Approve(ctx contractapi.TransactionContextInterface, operator string, tokenId string) (bool, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -182,7 +182,7 @@ func (c *TokenERC721Contract) Approve(ctx contractapi.TransactionContextInterfac
|
|||
// returns {Boolean} Return whether the approval was successful or not
|
||||
func (c *TokenERC721Contract) SetApprovalForAll(ctx contractapi.TransactionContextInterface, operator string, approved bool) (bool, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -237,7 +237,7 @@ func (c *TokenERC721Contract) SetApprovalForAll(ctx contractapi.TransactionConte
|
|||
// returns {Boolean} Return true if the operator is an approved operator for the owner, false otherwise
|
||||
func (c *TokenERC721Contract) IsApprovedForAll(ctx contractapi.TransactionContextInterface, owner string, operator string) (bool, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -274,7 +274,7 @@ func (c *TokenERC721Contract) IsApprovedForAll(ctx contractapi.TransactionContex
|
|||
// returns {Object} Return the approved client for this non-fungible token, or null if there is none
|
||||
func (c *TokenERC721Contract) GetApproved(ctx contractapi.TransactionContextInterface, tokenId string) (string, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return "false", fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -299,7 +299,7 @@ func (c *TokenERC721Contract) GetApproved(ctx contractapi.TransactionContextInte
|
|||
|
||||
func (c *TokenERC721Contract) TransferFrom(ctx contractapi.TransactionContextInterface, from string, to string, tokenId string) (bool, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -406,7 +406,7 @@ func (c *TokenERC721Contract) TransferFrom(ctx contractapi.TransactionContextInt
|
|||
|
||||
func (c *TokenERC721Contract) Name(ctx contractapi.TransactionContextInterface) (string, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -428,7 +428,7 @@ func (c *TokenERC721Contract) Name(ctx contractapi.TransactionContextInterface)
|
|||
|
||||
func (c *TokenERC721Contract) Symbol(ctx contractapi.TransactionContextInterface) (string, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -451,7 +451,7 @@ func (c *TokenERC721Contract) Symbol(ctx contractapi.TransactionContextInterface
|
|||
|
||||
func (c *TokenERC721Contract) TokenURI(ctx contractapi.TransactionContextInterface, tokenId string) (string, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -476,7 +476,7 @@ func (c *TokenERC721Contract) TokenURI(ctx contractapi.TransactionContextInterfa
|
|||
|
||||
func (c *TokenERC721Contract) TotalSupply(ctx contractapi.TransactionContextInterface) int {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
panic("failed to check if contract ia already initialized:" + err.Error())
|
||||
|
|
@ -550,7 +550,7 @@ func (c *TokenERC721Contract) Initialize(ctx contractapi.TransactionContextInter
|
|||
|
||||
func (c *TokenERC721Contract) MintWithTokenURI(ctx contractapi.TransactionContextInterface, tokenId string, tokenURI string) (*Nft, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -646,7 +646,7 @@ func (c *TokenERC721Contract) MintWithTokenURI(ctx contractapi.TransactionContex
|
|||
// returns {Boolean} Return whether the burn was successful or not
|
||||
func (c *TokenERC721Contract) Burn(ctx contractapi.TransactionContextInterface, tokenId string) (bool, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -720,7 +720,7 @@ func (c *TokenERC721Contract) Burn(ctx contractapi.TransactionContextInterface,
|
|||
// returns {Number} Returns the account balance
|
||||
func (c *TokenERC721Contract) ClientAccountBalance(ctx contractapi.TransactionContextInterface) (int, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
@ -751,7 +751,7 @@ func (c *TokenERC721Contract) ClientAccountBalance(ctx contractapi.TransactionCo
|
|||
|
||||
func (c *TokenERC721Contract) ClientAccountID(ctx contractapi.TransactionContextInterface) (string, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class ERC721TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public long BalanceOf(final Context ctx, final String owner) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
final ChaincodeStub stub = ctx.getStub();
|
||||
final CompositeKey balanceKey =
|
||||
|
|
@ -78,7 +78,7 @@ public class ERC721TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public String OwnerOf(final Context ctx, final String tokenId) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
final NFT nft = this._readNft(ctx, tokenId);
|
||||
if (stringIsNullOrEmpty(nft.getOwner())) {
|
||||
|
|
@ -98,7 +98,7 @@ public class ERC721TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public boolean IsApprovedForAll(final Context ctx, final String owner, final String operator) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
final ChaincodeStub stub = ctx.getStub();
|
||||
final CompositeKey approvalKey =
|
||||
|
|
@ -122,7 +122,7 @@ public class ERC721TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.SUBMIT)
|
||||
public void Approve(final Context ctx, final String operator, final String tokenId) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
final ChaincodeStub stub = ctx.getStub();
|
||||
final String sender = ctx.getClientIdentity().getId();
|
||||
|
|
@ -152,7 +152,7 @@ public class ERC721TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.SUBMIT)
|
||||
public void SetApprovalForAll(final Context ctx, final String operator, final boolean approved) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
final String sender = ctx.getClientIdentity().getId();
|
||||
final ChaincodeStub stub = ctx.getStub();
|
||||
|
|
@ -173,7 +173,7 @@ public class ERC721TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public String GetApproved(final Context ctx, final String tokenId) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
final NFT nft = this._readNft(ctx, tokenId);
|
||||
return nft.getApproved();
|
||||
|
|
@ -190,7 +190,7 @@ public class ERC721TokenContract implements ContractInterface {
|
|||
@Transaction(intent = Transaction.TYPE.SUBMIT)
|
||||
public void TransferFrom(
|
||||
final Context ctx, final String from, final String to, final String tokenId) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
final String sender = ctx.getClientIdentity().getId();
|
||||
final ChaincodeStub stub = ctx.getStub();
|
||||
|
|
@ -249,7 +249,7 @@ public class ERC721TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public String Name(final Context ctx) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
return ctx.getStub().getStringState(ContractConstants.NAMEKEY.getValue());
|
||||
}
|
||||
|
|
@ -262,7 +262,7 @@ public class ERC721TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public String Symbol(final Context ctx) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
return ctx.getStub().getStringState(ContractConstants.SYMBOLKEY.getValue());
|
||||
}
|
||||
|
|
@ -276,7 +276,7 @@ public class ERC721TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public String TokenURI(final Context ctx, final String tokenId) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
final NFT nft = this._readNft(ctx, tokenId);
|
||||
return nft.getTokenURI();
|
||||
|
|
@ -295,7 +295,7 @@ public class ERC721TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public long TotalSupply(final Context ctx) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
final ChaincodeStub stub = ctx.getStub();
|
||||
final CompositeKey nftKey = stub.createCompositeKey(ContractConstants.NFT.getValue());
|
||||
|
|
@ -331,7 +331,7 @@ public class ERC721TokenContract implements ContractInterface {
|
|||
"Client is not authorized to initialize the contract (set the name and symbol of the token)");
|
||||
}
|
||||
|
||||
//check contract options are not already set, client is not authorized to change them once intitialized
|
||||
// Check contract options are not already set, client is not authorized to change them once intitialized
|
||||
String tokenName = stub.getStringState(ContractConstants.NAMEKEY.getValue());
|
||||
if (!stringIsNullOrEmpty(tokenName)) {
|
||||
throw new ChaincodeException("contract options are already set, client is not authorized to change them");
|
||||
|
|
@ -351,7 +351,7 @@ public class ERC721TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.SUBMIT)
|
||||
public NFT MintWithTokenURI(final Context ctx, final String tokenId, final String tokenURI) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
final String clientMSPID = ctx.getClientIdentity().getMSPID();
|
||||
final ChaincodeStub stub = ctx.getStub();
|
||||
|
|
@ -392,7 +392,7 @@ public class ERC721TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.SUBMIT)
|
||||
public void Burn(final Context ctx, final String tokenId) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
final ChaincodeStub stub = ctx.getStub();
|
||||
final String owner = ctx.getClientIdentity().getId();
|
||||
|
|
@ -424,7 +424,7 @@ public class ERC721TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public long ClientAccountBalance(final Context ctx) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
return this.BalanceOf(ctx, ctx.getClientIdentity().getId());
|
||||
}
|
||||
|
|
@ -439,7 +439,7 @@ public class ERC721TokenContract implements ContractInterface {
|
|||
*/
|
||||
@Transaction(intent = Transaction.TYPE.EVALUATE)
|
||||
public String ClientAccountID(final Context ctx) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
this.checkInitialized(ctx);
|
||||
return ctx.getClientIdentity().getId();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class TokenERC721Contract extends Contract {
|
|||
* @returns {Number} The number of non-fungible tokens owned by the owner, possibly zero
|
||||
*/
|
||||
async BalanceOf(ctx, owner) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
// There is a key record for every non-fungible token in the format of balancePrefix.owner.tokenId.
|
||||
|
|
@ -50,7 +50,7 @@ class TokenERC721Contract extends Contract {
|
|||
* @returns {String} Return the owner of the non-fungible token
|
||||
*/
|
||||
async OwnerOf(ctx, tokenId) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const nft = await this._readNFT(ctx, tokenId);
|
||||
|
|
@ -73,7 +73,7 @@ class TokenERC721Contract extends Contract {
|
|||
* @returns {Boolean} Return whether the transfer was successful or not
|
||||
*/
|
||||
async TransferFrom(ctx, from, to, tokenId) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const sender = ctx.clientIdentity.getID();
|
||||
|
|
@ -127,7 +127,7 @@ class TokenERC721Contract extends Contract {
|
|||
* @returns {Boolean} Return whether the approval was successful or not
|
||||
*/
|
||||
async Approve(ctx, approved, tokenId) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const sender = ctx.clientIdentity.getID();
|
||||
|
|
@ -165,7 +165,7 @@ class TokenERC721Contract extends Contract {
|
|||
* @returns {Boolean} Return whether the approval was successful or not
|
||||
*/
|
||||
async SetApprovalForAll(ctx, operator, approved) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const sender = ctx.clientIdentity.getID();
|
||||
|
|
@ -189,7 +189,7 @@ class TokenERC721Contract extends Contract {
|
|||
* @returns {Object} Return the approved client for this non-fungible token, or null if there is none
|
||||
*/
|
||||
async GetApproved(ctx, tokenId) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const nft = await this._readNFT(ctx, tokenId);
|
||||
|
|
@ -205,7 +205,7 @@ class TokenERC721Contract extends Contract {
|
|||
* @returns {Boolean} Return true if the operator is an approved operator for the owner, false otherwise
|
||||
*/
|
||||
async IsApprovedForAll(ctx, owner, operator) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const approvalKey = ctx.stub.createCompositeKey(approvalPrefix, [owner, operator]);
|
||||
|
|
@ -230,7 +230,7 @@ class TokenERC721Contract extends Contract {
|
|||
* @returns {String} Returns the name of the token
|
||||
*/
|
||||
async Name(ctx) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const nameAsBytes = await ctx.stub.getState(nameKey);
|
||||
|
|
@ -244,7 +244,7 @@ class TokenERC721Contract extends Contract {
|
|||
* @returns {String} Returns the symbol of the token
|
||||
*/
|
||||
async Symbol(ctx) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const symbolAsBytes = await ctx.stub.getState(symbolKey);
|
||||
|
|
@ -259,7 +259,7 @@ class TokenERC721Contract extends Contract {
|
|||
* @returns {String} Returns the URI of the token
|
||||
*/
|
||||
async TokenURI(ctx, tokenId) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
const nft = await this._readNFT(ctx, tokenId);
|
||||
|
|
@ -276,7 +276,7 @@ class TokenERC721Contract extends Contract {
|
|||
* where each one of them has an assigned and queryable owner.
|
||||
*/
|
||||
async TotalSupply(ctx) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
// There is a key record for every non-fungible token in the format of nftPrefix.tokenId.
|
||||
|
|
@ -310,7 +310,7 @@ class TokenERC721Contract extends Contract {
|
|||
throw new Error('client is not authorized to set the name and symbol of the token');
|
||||
}
|
||||
|
||||
//check contract options are not already set, client is not authorized to change them once intitialized
|
||||
// Check contract options are not already set, client is not authorized to change them once intitialized
|
||||
const nameBytes = await ctx.stub.getState(nameKey);
|
||||
if (nameBytes && nameBytes.length > 0) {
|
||||
throw new Error('contract options are already set, client is not authorized to change them');
|
||||
|
|
@ -330,7 +330,7 @@ class TokenERC721Contract extends Contract {
|
|||
* @returns {Object} Return the non-fungible token object
|
||||
*/
|
||||
async MintWithTokenURI(ctx, tokenId, tokenURI) {
|
||||
//check contract options are already set first to execute the function
|
||||
// Check contract options are already set first to execute the function
|
||||
await this.CheckInitialized(ctx);
|
||||
|
||||
// Check minter authorization - this sample assumes Org1 is the issuer with privilege to mint a new token
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ func (s *SmartContract) Name(ctx contractapi.TransactionContextInterface) (strin
|
|||
|
||||
func (s *SmartContract) Symbol(ctx contractapi.TransactionContextInterface) (string, error) {
|
||||
|
||||
//check if contract has been intilized first
|
||||
// Check if contract has been intilized first
|
||||
initialized, err := checkInitialized(ctx)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to check if contract ia already initialized: %v", err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue