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

Fix built-in contract imports #78

Merged
merged 2 commits into from
Sep 18, 2024

Conversation

bartolomej
Copy link
Contributor

@bartolomej bartolomej commented Sep 5, 2024

Description

Flix generate command was failing on scripts/transactions that import built-in contracts like Crypto.

Example of such script:

import Crypto

transaction(key: String, signatureAlgorithm: UInt8, hashAlgorithm: UInt8, weight: UFix64) {
	prepare(signer: auth(BorrowValue, Storage) &Account) {
		pre {
			signatureAlgorithm >= 1 && signatureAlgorithm <= 3: "Must provide a signature algorithm raw value that is 1, 2, or 3"
			hashAlgorithm >= 1 && hashAlgorithm <= 6: "Must provide a hash algorithm raw value that is between 1 and 6"
			weight <= 1000.0: "The key weight must be between 0 and 1000"
		}

		let publicKey = PublicKey(
			publicKey: key.decodeHex(),
			signatureAlgorithm: SignatureAlgorithm(rawValue: signatureAlgorithm)!
		)

		let account = Account(payer: signer)

		account.keys.add(publicKey: publicKey, hashAlgorithm: HashAlgorithm(rawValue: hashAlgorithm)!, weight: weight)
	}
}

Example output in Flow CLI:

❌ Command Error: could not generate flix no contract name found in string

@bartolomej bartolomej marked this pull request as ready for review September 5, 2024 23:02
@bartolomej
Copy link
Contributor Author

@jribbink Thanks for the approval! Can we merge this (I don't have permission to do that)?

@jribbink jribbink merged commit d3bdc58 into onflow:main Sep 18, 2024
2 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.

2 participants