Skip to content
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

Add Swift example for managing NFT allowances #400

Merged
merged 6 commits into from
Nov 7, 2024

Conversation

b-l-u-e
Copy link
Contributor

@b-l-u-e b-l-u-e commented Oct 22, 2024

Description:

By adding an example to demonstrate how to manage NFT allowances in the Swift SDK.

The example includes step-by-step processes for:

  • Setting up the SDK client with the necessary operator account and key.
  • Creating a unique NFT and minting tokens with metadata.
  • Creating spender and receiver accounts.
  • Associating spender and receiver accounts with the NFT.
  • Granting allowance for specific NFT serials to a spender account.
  • Executing an NFT transfer using the approved allowance.
  • Revoking the allowance for certain NFT serials.
  • Attempting a transfer after revocation to confirm permission removal.
  • Cleaning up resources by deleting tokens and accounts.

Testing:

  • Due to not having access to a macOS or iOS environment, I am unable to run the example locally.
  • I have followed the requirements and provided the steps as per the Swift SDK documentation.
  • I request assistance from the maintainers or anyone with access to a macOS environment to test this example and verify that it functions as expected.

Related issue(s):

Fixes #385: Add example: Add and remove NFT allowances

Notes for reviewer:

Checklist

  • Documented (Code comments,)
  • Tested (unit, integration, etc.)

@b-l-u-e b-l-u-e requested review from a team as code owners October 22, 2024 07:45
@b-l-u-e
Copy link
Contributor Author

b-l-u-e commented Oct 22, 2024

Requesting for assistance on testing this one @hendrikebbers

@b-l-u-e
Copy link
Contributor Author

b-l-u-e commented Oct 24, 2024

Hello need help with testing. Anyone please @kenthejr @dalvizu @mehcode

@RickyLB
Copy link
Contributor

RickyLB commented Oct 24, 2024

Hello need help with testing. Anyone please @kenthejr @dalvizu @mehcode

Hi @b-l-u-e, thank you for your PR.

In Package.swift, add AddNftAllowance to the list of exampleTargets so the SDK detects the executable. Then run swift run AddNftAllowanceExample in the terminal.

Note: Run task format to pass the CI format check

@b-l-u-e
Copy link
Contributor Author

b-l-u-e commented Oct 24, 2024

@RickyLB thank you for reaching out to me.. let me add AddNftAllowance in exampleTargets

@b-l-u-e
Copy link
Contributor Author

b-l-u-e commented Oct 24, 2024

@RickyLB just made changes

@b-l-u-e
Copy link
Contributor Author

b-l-u-e commented Oct 28, 2024

@RickyLB @mehcode @dalvizu @kenthejr requesting for a review.

@b-l-u-e b-l-u-e force-pushed the add-nft-allowance-swift-example branch from 829b83c to c3f7033 Compare October 28, 2024 11:02
Signed-off-by: b-l-u-e <[email protected]>
Examples/AddNftAllowance/main.swift Outdated Show resolved Hide resolved
Examples/AddNftAllowance/main.swift Outdated Show resolved Hide resolved
Examples/AddNftAllowance/main.swift Outdated Show resolved Hide resolved
Examples/AddNftAllowance/main.swift Outdated Show resolved Hide resolved
Examples/AddNftAllowance/main.swift Outdated Show resolved Hide resolved
Examples/AddNftAllowance/main.swift Outdated Show resolved Hide resolved
Examples/AddNftAllowance/main.swift Outdated Show resolved Hide resolved
Examples/AddNftAllowance/main.swift Show resolved Hide resolved
Examples/AddNftAllowance/main.swift Show resolved Hide resolved
Examples/AddNftAllowance/main.swift Show resolved Hide resolved
@RickyLB
Copy link
Contributor

RickyLB commented Oct 28, 2024

@b-l-u-e

A good way to test the example would be to create a testnet account in hedera portal account, and fill a new .env file in the SDK with the following ECDSA values from portal:

OPERATOR_ID=<Account Id>
# Default private key to use to sign for all transactions and queries
OPERATOR_KEY=<DER Encoded Private Key>

# Network names: `"localhost"`, `"testnet"`, `"previewnet"`, `"mainnet"`
HEDERA_NETWORK=testnet

Apologize, I should have included this earlier to help you with testing your example.

@b-l-u-e b-l-u-e requested a review from RickyLB October 29, 2024 00:28
@b-l-u-e
Copy link
Contributor Author

b-l-u-e commented Oct 29, 2024

@RickyLB requesting for a review made some changes based on your review

@b-l-u-e
Copy link
Contributor Author

b-l-u-e commented Oct 29, 2024

@RickyLB any updates?

@RickyLB
Copy link
Contributor

RickyLB commented Oct 30, 2024

@b-l-u-e please check the CI build errors; they will tell you why it's failing. Also, it may help to install Swift 6.0.2 on your local machine (Windows or linux) so you can view these errors quicker.

Examples/AddNftAllowance/main.swift Outdated Show resolved Hide resolved
Examples/AddNftAllowance/main.swift Outdated Show resolved Hide resolved
Examples/AddNftAllowance/main.swift Outdated Show resolved Hide resolved
Examples/AddNftAllowance/main.swift Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Nov 7, 2024

Copy link
Contributor

@RickyLB RickyLB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Merging!

@RickyLB RickyLB merged commit 8e27288 into hashgraph:main Nov 7, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add example: Add and remove NFT Allowances
2 participants