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

Release 12/2024 #27

Merged
merged 33 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0d27988
Add button padding for mobile on safari
lealobanov Dec 12, 2023
a0ba2cd
Update recipe repos
lealobanov Dec 17, 2024
b9c3288
Merge branch 'main' into release-2024
lealobanov Dec 17, 2024
90e0a37
Update commit hashes
lealobanov Dec 17, 2024
4021bb6
Merge branch 'release-2024' of github.com:lealobanov/cadence-cookbook…
lealobanov Dec 17, 2024
8e7bd6a
Update tests command
lealobanov Dec 20, 2024
1f31a9d
Update tests command
lealobanov Dec 20, 2024
f33ca0f
Update tests command
lealobanov Dec 20, 2024
71fd286
Update tests command
lealobanov Dec 20, 2024
a609ff5
Update tests command
lealobanov Dec 20, 2024
a0f7202
Update tests command
lealobanov Dec 20, 2024
ecaa753
Update tests command
lealobanov Dec 20, 2024
aca961b
Update tests command
lealobanov Dec 20, 2024
c30f689
Update tests command
lealobanov Dec 20, 2024
cabeb3f
Update tests command
lealobanov Dec 20, 2024
94da8ea
Update tests command
lealobanov Dec 20, 2024
63ec826
Update tests command
lealobanov Dec 20, 2024
660728d
Update tests command
lealobanov Dec 20, 2024
56f62d2
Update commit hashes
lealobanov Dec 20, 2024
95be79c
Build settings
lealobanov Dec 20, 2024
0c3ddf2
Update build structure
lealobanov Dec 20, 2024
b3a0518
Hide test cases
lealobanov Dec 20, 2024
50e9385
Add fallback for old recipe structure
lealobanov Dec 20, 2024
fba06ce
Fall back to old recipe config
lealobanov Dec 20, 2024
548a6a0
Simplify explanations import
lealobanov Dec 20, 2024
152e6ab
Simplify explanations import
lealobanov Dec 20, 2024
5122904
Remove submodule link
lealobanov Jan 7, 2025
24ae855
Remove TS submodule links
lealobanov Jan 7, 2025
7ddc250
Unlink set series submodules
lealobanov Jan 8, 2025
5aa8cd4
Update recipe imports
lealobanov Jan 9, 2025
654b849
Update recipe imports
lealobanov Jan 9, 2025
89b77fd
Pull latest commit hash
lealobanov Jan 9, 2025
bec40df
Update commit ref
lealobanov Jan 9, 2025
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
61 changes: 53 additions & 8 deletions .github/workflows/cadence.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,61 @@ jobs:
submodules: 'true'
- name: Install Flow CLI
run: |
if test -f ${{ env.RECIPE_REPO }}/cadence/tests.cdc; then
brew update
brew install flow-cli
flow init --reset
fi
- name: Trigger recipe test
cd ${{ env.RECIPE_REPO }}
brew update
brew install flow-cli

- name: Start Flow Emulator
run: |
cd ${{ env.RECIPE_REPO }}
if test -f "flow.json"; then
flow dependencies install
echo "Starting Flow emulator in the background..."
nohup flow emulator start > emulator.log 2>&1 &
sleep 5 # Wait for the emulator to start
flow project deploy --network=emulator # Deploy the recipe contracts indicated in flow.json
else
echo "No flow.json found."
fi

- name: Run Cadence Lint
run: |
if test -f ${{ env.RECIPE_REPO }}/cadence/tests.cdc; then
flow test ${{ env.RECIPE_REPO }}/cadence/tests.cdc
cd ${{ env.RECIPE_REPO }}
if test -f "flow.json"; then
echo "Running Cadence linter on .cdc files in the current repository"
flow cadence lint ./cadence/**/*.cdc
else
echo "No flow.json found."
fi

- name: Run All Transactions
run: |
cd ${{ env.RECIPE_REPO }}
if test -f "flow.json"; then
for file in ./cadence/transactions/*.cdc; do
echo "Running transaction: $file"
TRANSACTION_OUTPUT=$(flow transactions send "$file" --signer emulator-account)
echo "$TRANSACTION_OUTPUT"
if echo "$TRANSACTION_OUTPUT" | grep -q "Transaction Error"; then
echo "Transaction Error detected in $file, failing the action..."
exit 1
fi
done
else
echo "No flow.json found."
fi


- name: Trigger recipe tests
run: |
cd ${{ env.RECIPE_REPO }}
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




12 changes: 0 additions & 12 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "src/data/recipes/add-a-play-to-topshot-set"]
path = src/data/recipes/add-a-play-to-topshot-set
url = https://github.com/lealobanov/add-a-play-to-topshot-set
[submodule "src/data/recipes/mint-nft"]
path = src/data/recipes/mint-nft
url = https://github.com/lealobanov/mint-nft
Expand Down Expand Up @@ -46,15 +43,6 @@
[submodule "src/data/recipes/add-admin-resource-to-account"]
path = src/data/recipes/add-admin-resource-to-account
url = https://github.com/lealobanov/add-admin-resource-to-account
[submodule "src/data/recipes/create-a-topshot-play"]
path = src/data/recipes/create-a-topshot-play
url = https://github.com/lealobanov/create-a-topshot-play
[submodule "src/data/recipes/create-a-topshot-set"]
path = src/data/recipes/create-a-topshot-set
url = https://github.com/lealobanov/create-a-topshot-set
[submodule "src/data/recipes/minting-a-moment-in-topshot-set"]
path = src/data/recipes/minting-a-moment-in-topshot-set
url = https://github.com/lealobanov/minting-a-moment-in-topshot-set
[submodule "src/data/recipes/create-a-marketplace"]
path = src/data/recipes/create-a-marketplace
url = https://github.com/lealobanov/create-a-marketplace
Expand Down
157 changes: 121 additions & 36 deletions src/data/recipeUtils.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,132 @@
import * as fs from "node:fs";
import { recipes } from "./recipes";
const path = require("path");
import { randomIntFromInterval } from "../utils/random_interval";

const recipesByModule = recipes;

export function fetchExternalRecipe(recipe) {
const contractPath = recipe.smartContractCode;
const transactionPath = recipe.transactionCode;
const testPath = recipe.testCasesCode;

const contractExplanationPath = recipe.smartContractExplanation;
const transactionExplanationPath = recipe.transactionExplanation;
const testExplanationPath = recipe.testCasesExplanation;

const contractCode =
contractPath !== undefined && contractPath !== null
? fs.readFileSync(`./src/data/recipes/${contractPath}`, "utf8")
: null;
const transactionCode =
transactionPath !== undefined && transactionPath !== null
? fs.readFileSync(`./src/data/recipes/${transactionPath}`, "utf8")
: null;
const testCasesCode =
testPath !== undefined && testPath !== null
? fs.readFileSync(`./src/data/recipes/${testPath}`, "utf8")
: null;

const contractExplanation =
contractExplanationPath !== undefined && contractExplanationPath !== null
? fs.readFileSync(`./src/data/recipes/${contractExplanationPath}`, "utf8")
: null;
const transactionExplanation =
transactionExplanationPath !== undefined &&
transactionExplanationPath !== null
? fs.readFileSync(
`./src/data/recipes/${transactionExplanationPath}`,
const contractFolder = `./src/data/recipes/${recipe.slug}/cadence/contracts`;
const transactionFolder = `./src/data/recipes/${recipe.slug}/cadence/transactions`;
const testFolder = `./src/data/recipes/${recipe.slug}/cadence/tests`;

// Dynamically find Recipe.cdc in the contracts folder
const contractCode = (() => {
try {
const files = fs.readdirSync(contractFolder);
const recipeContract = files.find((file) => file === "Recipe.cdc");
if (recipeContract) {
return fs.readFileSync(
path.join(contractFolder, recipeContract),
"utf8"
)
: null;
const testCasesExplanation =
testExplanationPath !== undefined && testExplanationPath !== null
? fs.readFileSync(`./src/data/recipes/${testExplanationPath}`, "utf8")
: null;
);
} else {
return null;
}
} catch (err) {
// Check if the recipe still follows old structure
const oldContractPath = `./src/data/recipes/${recipe.slug}/cadence/contract.cdc`;
try {
if (fs.existsSync(oldContractPath)) {
console.log("Using /cadence/contract.cdc configuration for: " + oldContractPath)
return fs.readFileSync(oldContractPath, "utf8");
} else {
return null;
}
} catch (oldErr) {
return null;
}
}
})();

// Dynamically find any transaction file in the transactions folder
const transactionCode = (() => {
try {
const files = fs.readdirSync(transactionFolder);
const transactionFile = files.length > 0 ? files[0] : null; // Pick the first file
if (transactionFile) {
return fs.readFileSync(
path.join(transactionFolder, transactionFile),
"utf8"
);
} else {
return null;
}
} catch (err) {
// Check if the recipe still follows old structure
const oldTransactionPath = `./src/data/recipes/${recipe.slug}/cadence/transaction.cdc`;
try {
if (fs.existsSync(oldTransactionPath)) {
return fs.readFileSync(oldTransactionPath, "utf8");
} else {
return null;
}
} catch (oldErr) {
return null;
}
}
})();

// Dynamically find Recipe.cdc in the contracts folder
const testCasesCode = (() => {
try {
const files = fs.readdirSync(testFolder);
const recipeContractTests = files.find(
(file) => file === "Recipe_test.cdc"
);
if (recipeContractTests) {
return fs.readFileSync(
path.join(testFolder, recipeContractTests),
"utf8"
);
} else {
return null;
}
} catch (err) {
return null
}
})();


const contractExplanation = (() => {
const explanationPath = `./src/data/recipes/${recipe.slug}/explanations/contract.txt`;
try {
if (fs.existsSync(explanationPath)) {
return fs.readFileSync(explanationPath, "utf8");
} else {
return null;
}
} catch (err) {
return null;
}
})();

const transactionExplanation = (() => {
const explanationPath = `./src/data/recipes/${recipe.slug}/explanations/transaction.txt`;
try {
if (fs.existsSync(explanationPath)) {
return fs.readFileSync(explanationPath, "utf8");
} else {
return null;
}
} catch (err) {
return null;
}
})();

const testCasesExplanation = (() => {
const explanationPath = `./src/data/recipes/${recipe.slug}/explanations/tests.txt`;
try {
if (fs.existsSync(explanationPath)) {
return fs.readFileSync(explanationPath, "utf8");
} else {
return null;
}
} catch (err) {
return null;
}
})();


const setCoverUrl =
recipe.coverUrl === undefined
Expand Down
1 change: 0 additions & 1 deletion src/data/recipes/add-a-play-to-topshot-set
Submodule add-a-play-to-topshot-set deleted from 6d6cef
2 changes: 1 addition & 1 deletion src/data/recipes/admin-resource
2 changes: 1 addition & 1 deletion src/data/recipes/create-a-marketplace
1 change: 0 additions & 1 deletion src/data/recipes/create-a-topshot-play
Submodule create-a-topshot-play deleted from 2a7661
1 change: 0 additions & 1 deletion src/data/recipes/create-a-topshot-set
Submodule create-a-topshot-set deleted from 02db2b
2 changes: 1 addition & 1 deletion src/data/recipes/create-an-nft-listing
2 changes: 1 addition & 1 deletion src/data/recipes/creating-a-set-in-series
2 changes: 1 addition & 1 deletion src/data/recipes/creating-a-vault
2 changes: 1 addition & 1 deletion src/data/recipes/metadata-views
2 changes: 1 addition & 1 deletion src/data/recipes/mint-nft
1 change: 0 additions & 1 deletion src/data/recipes/minting-a-moment-in-topshot-set
Submodule minting-a-moment-in-topshot-set deleted from 87d974
2 changes: 1 addition & 1 deletion src/data/recipes/minting-nfts-in-a-set
2 changes: 1 addition & 1 deletion src/data/recipes/multiple-metadata-views
2 changes: 1 addition & 1 deletion src/data/recipes/nft-with-metadata
2 changes: 1 addition & 1 deletion src/data/recipes/token-vault
2 changes: 1 addition & 1 deletion src/data/recipes/vault-minter
2 changes: 1 addition & 1 deletion src/data/recipes/withdrawing-tokens
Loading