Hello Everyone,
Greetings !
We are facing some errors related to Rust Language that is used to create the Shopify Tokengating App Discount Extension. We are working with the reference of official shopify documentation.
This is the doc:
https://shopify.dev/docs/apps/blockchain/tokengating
This is the last step of the token-gating app. We are trying to deploy the code using
npm run deploy
command. We have followed the documentation carefully and also tried different versions for Cargo wasi and Rust etc but still we are facing the errors. We normally don’t work in Rust. If someone could point to us to JS example app for similar functionality that would be great
These are the screenshots of the errors:
We have fixed multiple errors but after fixing new errors start showing as well.
Just for reference this is the error log
Error coming from `cargo wasi build`
Command failed with exit code 101: cargo wasi build
Compiling tokengating-function v1.0.0 (/home/Desktop/token-gating/extensions/tokengating-function)
error: Failed to generate GraphQLQuery impl: Parser error: schema parse error: Parse error at 1:1
Unexpected `GraphQL[Name]`
Expected `schema`, `extend`, `scalar`, `type`, `interface`, `union`, `enum`, `input` or `directive`
--> src/main.rs:12:1
|
12 | / generate_types!(
13 | | query_path = "./input.graphql",
14 | | schema_path = "./schema.graphql"
15 | | );
| |_^
|
= note: this error originates in the macro `generate_types` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: use of undeclared crate or module `output`
--> src/main.rs:73:20
|
73 | const NO_DISCOUNT: output::FunctionResult = output::FunctionResult {
| ^^^^^^ use of undeclared crate or module `output`
error[E0433]: failed to resolve: use of undeclared crate or module `output`
--> src/main.rs:73:45
|
73 | const NO_DISCOUNT: output::FunctionResult = output::FunctionResult {
| ^^^^^^ use of undeclared crate or module `output`
error[E0433]: failed to resolve: use of undeclared crate or module `output`
--> src/main.rs:75:36
|
75 | discount_application_strategy: output::DiscountApplicationStrategy::MAXIMUM,
| ^^^^^^ use of undeclared crate or module `output`
error[E0433]: failed to resolve: use of undeclared crate or module `input`
--> src/main.rs:79:20
|
79 | fn function(input: input::ResponseData) -> Result<output::FunctionResult> {
| ^^^^^ use of undeclared crate or module `input`
error[E0433]: failed to resolve: use of undeclared crate or module `output`
--> src/main.rs:79:51
|
79 | fn function(input: input::ResponseData) -> Result<output::FunctionResult> {
| ^^^^^^ use of undeclared crate or module `output`
error[E0433]: failed to resolve: use of undeclared crate or module `output`
--> src/main.rs:88:26
|
88 | let mut targets: Vec<output::Target> = vec![];
| ^^^^^^ use of undeclared crate or module `output`
error[E0433]: failed to resolve: use of undeclared crate or module `input`
--> src/main.rs:94:13
|
94 | input::InputCartLinesMerchandise::ProductVariant(variant) => Some(variant),
| ^^^^^ use of undeclared crate or module `input`
error[E0433]: failed to resolve: use of undeclared crate or module `output`
--> src/main.rs:117:30
|
117 | targets.push(output::Target::ProductVariant(
| ^^^^^^ use of undeclared crate or module `output`
error[E0433]: failed to resolve: use of undeclared crate or module `output`
--> src/main.rs:118:21
|
118 | output::ProductVariantTarget {
| ^^^^^^ use of undeclared crate or module `output`
error[E0433]: failed to resolve: use of undeclared crate or module `output`
--> src/main.rs:134:8
|
134 | Ok(output::FunctionResult {
| ^^^^^^ use of undeclared crate or module `output`
error[E0433]: failed to resolve: use of undeclared crate or module `output`
--> src/main.rs:135:25
|
135 | discounts: vec![output::Discount {
| ^^^^^^ use of undeclared crate or module `output`
error[E0433]: failed to resolve: use of undeclared crate or module `output`
--> src/main.rs:140:40
|
140 | discount_application_strategy: output::DiscountApplicationStrategy::MAXIMUM,
| ^^^^^^ use of undeclared crate or module `output`
error[E0433]: failed to resolve: use of undeclared crate or module `input`
--> src/main.rs:145:24
|
145 | attribute: &Option<input::InputCartAttribute>,
| ^^^^^ use of undeclared crate or module `input`
error[E0433]: failed to resolve: use of undeclared crate or module `input`
--> src/main.rs:156:10
|
156 | &input::InputCartLinesMerchandiseOnProductVariantProductGatesConfigurationMetafield,
| ^^^^^ use of undeclared crate or module `input`
error[E0433]: failed to resolve: use of undeclared crate or module `input`
--> src/main.rs:166:26
|
166 | gate_configuration: &input::InputCartLinesMerchandiseOnProductVariantProductGatesConfiguration,
| ^^^^^ use of undeclared crate or module `input`
error[E0433]: failed to resolve: use of undeclared crate or module `output`
--> src/main.rs:190:46
|
190 | fn reaction_value(reaction: GateReaction) -> output::Value {
| ^^^^^^ use of undeclared crate or module `output`
error[E0433]: failed to resolve: use of undeclared crate or module `output`
--> src/main.rs:193:46
|
193 | return output::Value::Percentage(output::Percentage {
| ^^^^^^ use of undeclared crate or module `output`
error[E0433]: failed to resolve: use of undeclared crate or module `output`
--> src/main.rs:198:47
|
198 | return output::Value::FixedAmount(output::FixedAmount {
| ^^^^^^ use of undeclared crate or module `output`
error[E0433]: failed to resolve: use of undeclared crate or module `output`
--> src/main.rs:193:20
|
193 | return output::Value::Percentage(output::Percentage {
| ^^^^^^ use of undeclared crate or module `output`
|
help: consider importing this enum
|
1 + use serde_json::Value;
|
help: if you import `Value`, refer to it directly
|
193 - return output::Value::Percentage(output::Percentage {
193 + return Value::Percentage(output::Percentage {
|
error[E0433]: failed to resolve: use of undeclared crate or module `output`
--> src/main.rs:198:20
|
198 | return output::Value::FixedAmount(output::FixedAmount {
| ^^^^^^ use of undeclared crate or module `output`
|
help: consider importing this enum
|
1 + use serde_json::Value;
|
help: if you import `Value`, refer to it directly
|
198 - return output::Value::FixedAmount(output::FixedAmount {
198 + return Value::FixedAmount(output::FixedAmount {
|
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> src/main.rs:150:15
|
150 | .map(|value| serde_json::from_str(&value).unwrap_or_default())
| ^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
help: function arguments must have a statically known size, borrowed types always have a known size
|
150 | .map(|&value| serde_json::from_str(&value).unwrap_or_default())
| +
warning: unused import: `Serialize`
--> src/main.rs:9:26
|
9 | use serde::{Deserialize, Serialize};
| ^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
Some errors have detailed explanations: E0277, E0433.
For more information about an error, try `rustc --explain E0277`.
warning: `tokengating-function` (bin "tokengating-function") generated 1 warning
error: could not compile `tokengating-function` (bin "tokengating-function") due to 22 previous errors; 1 warning emitted
If someone has any idea about this please reach out to us.
Thank You

