gpt4 book ai didi

nearprotocol - 无法从最新的 sdk 编译独立的 ft_example

转载 作者:行者123 更新时间:2023-12-04 08:00:20 25 4
gpt4 key购买 nike

我试图得到这个例子
https://github.com/near/near-sdk-rs/tree/master/examples/fungible-token
从 sdk 作为独立文件夹在本地构建,所以我将所有 3 个 Cargo.toml 更改为使用

near-sdk = { git = "https://github.com/near/near-sdk-rs.git" }
near-contract-standards = { git = "https://github.com/near/near-sdk-rs.git" }
并得到这个错误
error[E0424]: expected value, found module `self`
--> ft/src/lib.rs:63:1
|
63 | near_contract_standards::impl_fungible_token_core!(Contract, token, on_tokens_burned);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `self` value is a keyword only available in methods with a `self` parameter
| this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find value `sender_id` in this scope
--> ft/src/lib.rs:63:1
|
63 | near_contract_standards::impl_fungible_token_core!(Contract, token, on_tokens_burned);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find value `burned_amount` in this scope
--> ft/src/lib.rs:63:1
|
63 | near_contract_standards::impl_fungible_token_core!(Contract, token, on_tokens_burned);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0424]: expected value, found module `self`
--> ft/src/lib.rs:65:1
|
65 | near_contract_standards::impl_fungible_token_ar!(Contract, token, on_account_closed);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `self` value is a keyword only available in methods with a `self` parameter
| this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find value `account_id` in this scope
--> ft/src/lib.rs:65:1
|
65 | near_contract_standards::impl_fungible_token_ar!(Contract, token, on_account_closed);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find value `balance` in this scope
--> ft/src/lib.rs:65:1
|
65 | near_contract_standards::impl_fungible_token_ar!(Contract, token, on_account_closed);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
--> ft/src/lib.rs:48:57
|
48 | let mut this = Self { token: FungibleToken::new(b"a"), reference, reference_hash };
| ^^^^
| |
| expected struct `Vec`, found `&[u8; 1]`
| help: try using a conversion method: `b"a".to_vec()`
|
= note: expected struct `Vec<u8>`
found reference `&'static [u8; 1]`

error[E0308]: mismatched types
--> ft/src/lib.rs:77:24
|
77 | reference: self.reference.clone(),
| ^^^^^^^^^^^^^^^^^^^^^^
| |
| expected enum `std::option::Option`, found struct `std::string::String`
| help: try using a variant of the expected enum: `Some(self.reference.clone())`
|
= note: expected enum `std::option::Option<std::string::String>`
found struct `std::string::String`

error[E0308]: mismatched types
--> ft/src/lib.rs:78:29
|
78 | reference_hash: self.reference_hash.clone(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| expected enum `std::option::Option`, found struct `Base64VecU8`
| help: try using a variant of the expected enum: `Some(self.reference_hash.clone())`
|
= note: expected enum `std::option::Option<Base64VecU8>`
found struct `Base64VecU8`

error: aborting due to 9 previous errors

Some errors have detailed explanations: E0308, E0424, E0425.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `fungible-token`

当我尝试使用以下版本的 crate 时
near-sdk = { version = "=3.0.0-pre.2" }
near-contract-standards = { version = "=0.1.0-pre.2"}

我收到这个错误
error: no rules expected the token ,
--> ft/src/lib.rs:63:67
|
63 | near_contract_standards::impl_fungible_token_core!(Contract, token, on_tokens_burned);
| ^ no rules expected this token in macro call

error[E0432]: unresolved import near_contract_standards::fungible_token::metadata::FT_METADATA_SPEC
--> ft/src/lib.rs:19:59
|
19 | FungibleTokenMetadata, FungibleTokenMetadataProvider, FT_METADATA_SPEC,
| ^^^^^^^^^^^^^^^^ no FT_METADATA_SPEC in fungible_token::metadata

error[E0433]: failed to resolve: could not find impl_fungible_token_ar in near_contract_standards
--> ft/src/lib.rs:65:26
|
65 | near_contract_standards::impl_fungible_token_ar!(Contract, token, on_account_closed);
| ^^^^^^^^^^^^^^^^^^^^^^ could not find impl_fungible_token_ar in near_contract_standards

warning: unused import: PromiseOrValue
--> ft/src/lib.rs:24:76
|
24 | use near_sdk::{env, log, near_bindgen, AccountId, Balance, PanicOnDefault, PromiseOrValue};
| ^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default

error[E0560]: struct FungibleTokenMetadata has no field named spec
--> ft/src/lib.rs:71:13
|
71 | spec: FT_METADATA_SPEC.to_string(),
| ^^^^ FungibleTokenMetadata does not have this field
|
= note: available fields are: version, name, symbol, reference, decimals

error[E0560]: struct FungibleTokenMetadata has no field named icon
--> ft/src/lib.rs:74:13
|
74 | icon: Some(
| ^^^^ FungibleTokenMetadata does not have this field
|
= note: available fields are: version, name, symbol, reference, decimals

error[E0560]: struct FungibleTokenMetadata has no field named reference_hash
--> ft/src/lib.rs:78:13
|
78 | reference_hash: self.reference_hash.clone(),
| ^^^^^^^^^^^^^^ FungibleTokenMetadata does not have this field
|
= note: available fields are: version, name, symbol, reference, decimals

error: aborting due to 6 previous errors; 1 warning emitted
我也不得不注释掉 # source ../flags.shbuild.sh ,这是我在 ./build.sh 时遇到的错误
这个问题的原因可能是什么?请就如何进行提供建议,我将不胜感激,因为我仍在弄清楚这个新的可爱的生态系统:)

最佳答案

感谢您的关注并解释您的尝试。在您发布此消息时,可替代代币的示例在媒体上很火爆。 crate 尚未发布,因为有一些依赖性需要解决。
为了确保我了解您的流程,您是否复制/粘贴了 fungible-token其他地方的目录?
如果您运行 build.sh那个目录中的文件,它编译吗?这应该。如果您运行 rustc --version我们能得到那个值吗?对我来说是 rustc 1.47.0 (18bf6b4f0 2020-10-07) .另外,请确保您已为目标执行此操作:

rustup target add wasm32-unknown-unknown
也许你可以浏览一下这个介绍以确保基础知识正常工作: https://docs.near.org/docs/develop/contracts/rust/intro
此外,请随时联系 https://near.chat我们尽最大努力回答可能需要多一点来回的问题。很高兴你这么快找到了那个例子!它是如此新鲜,它仍然在窗台上,冒着热气。

关于nearprotocol - 无法从最新的 sdk 编译独立的 ft_example,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66510878/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com