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

C1 migration #1

Open
wants to merge 2 commits into
base: main
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
30 changes: 30 additions & 0 deletions .github/workflows/cadence_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Run Cadence Lint
on: push

jobs:
run-cadence-lint:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'true'

- name: Install Flow CLI
run: |
brew update
brew install flow-cli

- name: Initialize Flow
run: |
if [ ! -f flow.json ]; then
echo "Initializing Flow project..."
flow init
else
echo "Flow project already initialized."
fi

- name: Run Cadence Lint
run: |
echo "Running Cadence linter on all .cdc files in the current repository"
flow cadence lint **/*.cdc
34 changes: 34 additions & 0 deletions .github/workflows/cadence_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Run Cadence Tests
on: push

jobs:
run-cadence-tests:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'true'

- name: Install Flow CLI
run: |
brew update
brew install flow-cli

- name: Initialize Flow
run: |
if [ ! -f flow.json ]; then
echo "Initializing Flow project..."
flow init
else
echo "Flow project already initialized."
fi

- name: Run Cadence Tests
run: |
if test -f "cadence/tests.cdc"; then
echo "Running Cadence tests in the current repository"
flow test cadence/tests.cdc
else
echo "No Cadence tests found. Skipping tests."
fi
33 changes: 21 additions & 12 deletions cadence/contract.cdc
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
pub resource NFT: NonFungibleToken.INFT, MetadataViews.Resolver {
pub let id: UInt64
access(all)
resource NFT: NonFungibleToken.INFT, MetadataViews.Resolver {
access(all)
let id: UInt64

pub let name: String
pub let thumbnail: String
pub let description: String
pub let power: String
pub let will: String
pub let determination: String
access(all)
let name: String
access(all)
let thumbnail: String
access(all)
let description: String
access(all)
let power: String
access(all)
let will: String
access(all)
let determination: String


pub fun getViews(): [Type] {
access(all)
fun getViews(): [Type] {
return [
Type<MetadataViews.Display>(),
Type<NewExampleNFT.Traits>()
]
}

pub fun resolveView(_ view: Type): AnyStruct? {
access(all)
fun resolveView(_ view: Type): AnyStruct? {
switch view {
case Type<MetadataViews.Display>():
return MetadataViews.Display(
Expand Down Expand Up @@ -52,6 +61,6 @@ pub resource NFT: NonFungibleToken.INFT, MetadataViews.Resolver {
self.description = description
self.power = power
self.will = will
self.determination= determination
self.determination = determination
}
}
19 changes: 10 additions & 9 deletions cadence/transaction.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@ import NewExampleNFT from 0x02
// It must be run with the account that has the minter resource
// stored in /storage/NFTMinter

transaction{
transaction {

// local variable for storing the minter reference
let minter: &NewExampleNFT.NFTMinter
// Local variable for storing the minter reference
let minter: auth(MinterEntitlement) &NewExampleNFT.NFTMinter

prepare(signer: AuthAccount) {
// borrow a reference to the NFTMinter resource in storage
self.minter = signer.borrow<&NewExampleNFT.NFTMinter>(from: NewExampleNFT.MinterStoragePath)
?? panic("Could not borrow a reference to the NFT minter")
prepare(signer: auth(Storage, Capabilities) &Account) {
// Borrow a reference to the NFTMinter resource in storage
self.minter = signer.capabilities.storage.borrow<&NewExampleNFT.NFTMinter>(
from: NewExampleNFT.MinterStoragePath
) ?? panic("Could not borrow a reference to the NFT minter")
}

execute {
// Borrow the recipient's public NFT collection reference
let receiver = getAccount(0x02)
.getCapability(NewExampleNFT.CollectionPublicPath)
.borrow<&{NonFungibleToken.CollectionPublic}>()
.capabilities
.borrow<&{NonFungibleToken.CollectionPublic}>(NewExampleNFT.CollectionPublicPath)
?? panic("Could not get receiver reference to the NFT Collection")

// Mint the NFT and deposit it to the recipient's collection
Expand Down
16 changes: 16 additions & 0 deletions flow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"contracts": {
"Counter": {
"source": "cadence/contracts/Counter.cdc",
"aliases": {
"testing": "0000000000000007"
}
}
},
"networks": {
"emulator": "127.0.0.1:3569",
"mainnet": "access.mainnet.nodes.onflow.org:9000",
"testing": "127.0.0.1:3569",
"testnet": "access.devnet.nodes.onflow.org:9000"
}
}
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ export const nftWithMetdata = {
transactionCode: transactionPath,
transactionExplanation: transactionExplanationPath,
filters: {
difficulty: "beginner"
}
difficulty: "beginner",
},
};
Loading