-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4c3c9d
commit 0bbf32a
Showing
7 changed files
with
186 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,52 +11,60 @@ jobs: | |
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Clone the repository | ||
uses: actions/checkout@v1 | ||
- name: Clone the Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Tools | ||
run: sudo apt update && sudo apt install lcov | ||
|
||
- name: Clone the Flutter repository | ||
uses: actions/checkout@v1 | ||
with: | ||
repository: flutter/flutter | ||
ref: 3.3.0 | ||
path: flutter | ||
|
||
- name: Add the flutter tool to the path | ||
run: | | ||
ls -al "$GITHUB_WORKSPACE/../flutter/bin" | ||
echo "$GITHUB_WORKSPACE/../flutter/bin" >> $GITHUB_PATH | ||
echo "$GITHUB_WORKSPACE/../flutter/bin/cache/dart-sdk/bin" >> $GITHUB_PATH | ||
- name: Populate the Flutter tool's cache of binary artifacts | ||
run: | | ||
flutter config --no-analytics | ||
flutter precache | ||
run: sudo apt update && sudo apt install lcov -y | ||
|
||
- name: Reconfigure git to use HTTP authentication | ||
- name: Reconfigure git to Use HTTP Authentication | ||
run: > | ||
git config --global url."https://github.com/".insteadOf '[email protected]:' | ||
- name: Get Flutter packages | ||
- name: Setup Flutter SDK | ||
uses: flutter-actions/setup-flutter@v3 | ||
with: | ||
channel: stable | ||
version: 3.19.6 | ||
|
||
- name: Enable Flutter Desktop | ||
run: flutter config --enable-linux-desktop | ||
shell: bash | ||
|
||
- name: Get Flutter Packages | ||
run: flutter pub get | ||
|
||
|
||
- name: Flutter Create | ||
run: flutter create . | ||
|
||
- name: Clone Mozilla's CA cert bundle module into root directory | ||
run: git clone https://github.com/Chia-Network/mozilla-ca.git | ||
|
||
- name: Run simulator tests | ||
run: bash ./integration_test/run_tests.sh | ||
- name: Configure Linux Build | ||
run: | | ||
sudo apt install libgtk-3-dev libgtk-3-0 libblkid1 liblzma5 ninja-build libmpv-dev mpv -y | ||
sudo mkdir -p /usr/local/chia_crypto_utils && sudo chmod 777 /usr/local/chia_crypto_utils | ||
- name: Check Flutter Readiness | ||
run: flutter doctor | ||
|
||
- name: Run Integration Tests | ||
run: | | ||
export DISPLAY=:99 | ||
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & | ||
sudo apt install network-manager | ||
./integration_test/run_tests.sh | ||
shell: bash | ||
|
||
- name: Run unit tests | ||
- name: Run Unit Tests | ||
run: flutter test test --coverage --coverage-path=coverage/test.info | ||
|
||
- name: Merge coverage files | ||
- name: Merge Coverage Files | ||
run: | | ||
lcov --add-tracefile coverage/test.info --add-tracefile coverage/integration_test.info --output-file coverage/merged_coverage.info | ||
rm -rf coverage/*test.info | ||
- name: Generate coverage report | ||
- name: Generate Coverage Report | ||
run: genhtml coverage/merged_coverage.info -o coverage | ||
|
||
- name: Upload code coverage to GitHub | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# Changelog | ||
|
||
## 1.0.21 | ||
|
||
- Updated to latest version of Dart | ||
|
||
## 1.0.20 | ||
|
||
- Fixes for pub.dev | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,125 +1,129 @@ | ||
import 'package:chia_crypto_utils/chia_crypto_utils.dart'; | ||
|
||
void main() { | ||
final coreSecret = KeychainCoreSecret.fromMnemonic( | ||
'goat club mountain ritual rack same bar put fall anxiety minor theme enter card dog lawsuit rather pigeon manual tribe shield decline gentle install' | ||
.split(' '), | ||
); | ||
final keychain = WalletKeychain.fromCoreSecret(coreSecret); | ||
|
||
final inputMetadata = NftMetadata( | ||
dataUris: const [ | ||
'https://www.chia.net/img/branding/chia-logo.svg', | ||
], | ||
dataHash: Program.fromInt(0).hash(), | ||
); | ||
|
||
final did = Program.fromInt(3).hash(); | ||
|
||
final senderWalletVector = keychain.unhardenedWalletVectors.first; | ||
final receiverWalletVector = keychain.unhardenedWalletVectors.last; | ||
|
||
final launcherCoin = CoinPrototype( | ||
parentCoinInfo: Program.fromInt(0).hash(), | ||
puzzlehash: Program.fromInt(1).hash(), | ||
amount: 1, | ||
); | ||
|
||
final senderP2Puzzle = getPuzzleFromPk(senderWalletVector.childPublicKey); | ||
|
||
final ownershipLayer = NftWalletService.createOwnershipLayerPuzzle( | ||
launcherId: launcherCoin.id, | ||
did: did, | ||
p2Puzzle: senderP2Puzzle, | ||
royaltyPercentage: 200, | ||
); | ||
|
||
final fullPuzzle = NftWalletService.createFullPuzzle( | ||
singletonId: launcherCoin.id, | ||
metadata: inputMetadata, | ||
metadataUpdaterPuzzlehash: nftMetadataUpdaterDefault.hash(), | ||
innerPuzzle: ownershipLayer, | ||
); | ||
|
||
final uncurriedNft = UncurriedNftPuzzle.fromProgramSync(fullPuzzle); | ||
|
||
// solution | ||
|
||
final standardInnerSolution = BaseWalletService.makeSolutionFromConditions([ | ||
CreateCoinCondition( | ||
receiverWalletVector.puzzlehash, | ||
1, | ||
memos: [senderWalletVector.puzzlehash], | ||
), | ||
]); | ||
|
||
final magicCondition = NftDidMagicConditionCondition(); | ||
|
||
final innerSolution = Program.list([ | ||
Program.list([ | ||
Program.list([]), | ||
Program.cons( | ||
Program.fromInt(1), | ||
Program.cons( | ||
magicCondition.toProgram(), | ||
standardInnerSolution.rest().first().rest(), | ||
), | ||
), | ||
Program.list([]), | ||
]), | ||
]); | ||
|
||
final nftLayerSolution = Program.list([innerSolution]); | ||
final singletonSolution = Program.list([ | ||
LineageProof( | ||
parentCoinInfo: launcherCoin.id, | ||
innerPuzzlehash: uncurriedNft!.stateLayer.hash(), | ||
amount: 1, | ||
).toProgram(), | ||
Program.fromInt(1), | ||
nftLayerSolution, | ||
]); | ||
|
||
print(fullPuzzle.run(singletonSolution).program); | ||
|
||
final innerResult = uncurriedNft.getInnerResult(singletonSolution); | ||
|
||
// get new p2 puzzle hash from resulting conditions | ||
final createCoinConditions = BaseWalletService.extractConditionsFromResult( | ||
innerResult, | ||
CreateCoinCondition.isThisCondition, | ||
CreateCoinCondition.fromProgram, | ||
); | ||
|
||
final nftOutputConditions = createCoinConditions.where( | ||
(element) => | ||
element.amount == 1 && | ||
element.memos != null && | ||
element.memos!.isNotEmpty, | ||
); | ||
|
||
if (nftOutputConditions.isEmpty) { | ||
throw Exception('No nft output condtions to find inner puzzle hash with'); | ||
} | ||
@Skip('Not tested yet') | ||
|
||
if (nftOutputConditions.length > 1) { | ||
throw Exception('more than one nft output condition'); | ||
} | ||
|
||
// get new did from resulting conditions | ||
final didMagicConditions = BaseWalletService.extractConditionsFromResult( | ||
innerResult, | ||
NftDidMagicConditionCondition.isThisCondition, | ||
NftDidMagicConditionCondition.fromProgram, | ||
); | ||
import 'package:chia_crypto_utils/chia_crypto_utils.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
if (didMagicConditions.length > 1) { | ||
throw Exception('more than one nft didMagicConditions condition'); | ||
void main() async { | ||
if (!(await SimulatorUtils.checkIfSimulatorIsRunning())) { | ||
print(SimulatorUtils.simulatorNotRunningWarning); | ||
return; | ||
} | ||
|
||
// final innerPuzzleReveal = NftWalletService.constructOwnershipLayer( | ||
// currentOwnerDid: null, | ||
// transferProgram: uncurriedNft.ownershipLayerInfo!.transferProgram, | ||
// innerPuzzle: ownershipInfo.ownershipLayerP2Puzzle, | ||
// ); | ||
test('basic nft test', () async { | ||
final coreSecret = KeychainCoreSecret.fromMnemonic( | ||
'goat club mountain ritual rack same bar put fall anxiety minor theme enter card dog lawsuit rather pigeon manual tribe shield decline gentle install' | ||
.split(' '), | ||
); | ||
final keychain = WalletKeychain.fromCoreSecret(coreSecret); | ||
|
||
final inputMetadata = NftMetadata( | ||
dataUris: const [ | ||
'https://www.chia.net/wp-content/uploads/2023/01/chia-logo-dark.svg', | ||
], | ||
dataHash: Program.fromInt(0).hash(), | ||
); | ||
|
||
final did = Program.fromInt(3).hash(); | ||
|
||
final senderWalletVector = keychain.unhardenedWalletVectors.first; | ||
final receiverWalletVector = keychain.unhardenedWalletVectors.last; | ||
|
||
final launcherCoin = CoinPrototype( | ||
parentCoinInfo: Program.fromInt(0).hash(), | ||
puzzlehash: Program.fromInt(1).hash(), | ||
amount: 1, | ||
); | ||
|
||
final senderP2Puzzle = getPuzzleFromPk(senderWalletVector.childPublicKey); | ||
|
||
final ownershipLayer = NftWalletService.createOwnershipLayerPuzzle( | ||
launcherId: launcherCoin.id, | ||
did: did, | ||
p2Puzzle: senderP2Puzzle, | ||
royaltyPercentage: 200, | ||
); | ||
|
||
final fullPuzzle = NftWalletService.createFullPuzzle( | ||
singletonId: launcherCoin.id, | ||
metadata: inputMetadata, | ||
metadataUpdaterPuzzlehash: nftMetadataUpdaterDefault.hash(), | ||
innerPuzzle: ownershipLayer, | ||
); | ||
|
||
final uncurriedNft = UncurriedNftPuzzle.fromProgramSync(fullPuzzle); | ||
|
||
// solution | ||
|
||
final standardInnerSolution = BaseWalletService.makeSolutionFromConditions([ | ||
CreateCoinCondition( | ||
receiverWalletVector.puzzlehash, | ||
1, | ||
memos: [senderWalletVector.puzzlehash], | ||
), | ||
]); | ||
|
||
final magicCondition = NftDidMagicConditionCondition(); | ||
|
||
final innerSolution = Program.list([ | ||
Program.list([ | ||
Program.list([]), | ||
Program.cons( | ||
Program.fromInt(1), | ||
Program.cons( | ||
magicCondition.toProgram(), | ||
standardInnerSolution.rest().first().rest(), | ||
), | ||
), | ||
Program.list([]), | ||
]), | ||
]); | ||
|
||
final nftLayerSolution = Program.list([innerSolution]); | ||
final singletonSolution = Program.list([ | ||
LineageProof( | ||
parentCoinInfo: launcherCoin.id, | ||
innerPuzzlehash: uncurriedNft!.stateLayer.hash(), | ||
amount: 1, | ||
).toProgram(), | ||
Program.fromInt(1), | ||
nftLayerSolution, | ||
]); | ||
|
||
print(fullPuzzle.run(singletonSolution).program); | ||
|
||
final innerResult = uncurriedNft.getInnerResult(singletonSolution); | ||
|
||
// get new p2 puzzle hash from resulting conditions | ||
final createCoinConditions = BaseWalletService.extractConditionsFromResult( | ||
innerResult, | ||
CreateCoinCondition.isThisCondition, | ||
CreateCoinCondition.fromProgram, | ||
); | ||
|
||
final nftOutputConditions = createCoinConditions.where( | ||
(element) => | ||
element.amount == 1 && | ||
element.memos != null && | ||
element.memos!.isNotEmpty, | ||
); | ||
|
||
if (nftOutputConditions.isEmpty) { | ||
throw Exception('No nft output condtions to find inner puzzle hash with'); | ||
} | ||
|
||
if (nftOutputConditions.length > 1) { | ||
throw Exception('more than one nft output condition'); | ||
} | ||
|
||
// get new did from resulting conditions | ||
final didMagicConditions = BaseWalletService.extractConditionsFromResult( | ||
innerResult, | ||
NftDidMagicConditionCondition.isThisCondition, | ||
NftDidMagicConditionCondition.fromProgram, | ||
); | ||
|
||
if (didMagicConditions.length > 1) { | ||
throw Exception('more than one nft didMagicConditions condition'); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.