【发布时间】:2021-09-23 11:00:14
【问题描述】:
我正在尝试使用 FRAME V2 调色板模板来实现 offchain-worker。 但是,Runtime/lib.rs 的 CreateSignedTransaction 实现给出了编译错误,无法解决。 请帮帮我。
环境
- 节点模板正在使用最新版本。 "git clone -b latest --depth 1 https://github.com/substrate-developer-hub/substrate-node-template"
- 生锈的环境
installed toolchains
--------------------
stable-x86_64-apple-darwin (default)
nightly-2020-04-06-x86_64-apple-darwin
nightly-x86_64-apple-darwin
1.51.0-x86_64-apple-darwin
installed targets for active toolchain
--------------------------------------
wasm32-unknown-unknown
x86_64-apple-darwin
active toolchain
----------------
stable-x86_64-apple-darwin (default)
rustc 1.55.0 (c8dfcfe04 2021-09-06)
- 下面的示例实现是模仿和实现的。并且托盘已经编译成功。 “https://github.com/paritytech/substrate/tree/master/frame/example-offchain-worker”
问题
- 我遇到了麻烦,因为我无法通过在 Runtime / lib.rs 中实现“frame_system :: offchain :: CreateSignedTransaction”来解决编译错误。
- 问题部分源码如下。
-- snip --
let raw_payload = SignedPayload::new(call, extra)
.map_err(|e| {
log::warn!("Unable to create signed payload: {:?}", e);
})
.ok()?;
// let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
let signature = codec::Encode::using_encoded(&raw_payload, |payload| C::sign(payload, public));
let address = Indices::unlookup(account);
let (call, extra, _) = raw_payload.deconstruct();
Some((call, (address, signature.into(), extra)))
--snip--
- 错误信息如下。
error[E0308]: mismatched types
--> /Users/shin.takahashi/develop/substrate/latest_node_template/substrate-node-template/runtime/src/lib.rs:329:16
|
329 | Some((call, (address, signature.into(), extra)))
| ^^^^^^^ expected `()`, found `u32`
|
= note: expected enum `MultiAddress<_, ()>`
found enum `MultiAddress<_, u32>`
error[E0277]: the trait bound `MultiSignature: From<Option<MultiSignature>>` is not satisfied
--> /Users/shin.takahashi/develop/substrate/latest_node_template/substrate-node-template/runtime/src/lib.rs:329:8
|
329 | Some((call, (address, signature.into(), extra)))
| ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<Option<MultiSignature>>` is not implemented for `MultiSignature`
| |
| required by a bound introduced by this call
|
= help: the following implementations were found:
<MultiSignature as From<sp_core::ecdsa::Signature>>
<MultiSignature as From<sp_core::ed25519::Signature>>
<MultiSignature as From<sp_core::sr25519::Signature>>
= note: required because of the requirements on the impl of `Into<MultiSignature>` for `Option<MultiSignature>`
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
warning: `node-template-runtime` (lib) generated 1 warning
error: could not compile `node-template-runtime` due to 2 previous errors; 1 warning emitted
【问题讨论】:
-
希望对您有所帮助,github.com/saintfeng/slides/blob/…
-
@ClarkLee 感谢您的帮助。第一个错误已解决。但是,无法解决第二个错误“来自
-
第二个错误是我的错误。感谢您的建议,我可以解决这些错误。非常感谢!
-
很高兴看到这一点。我也是新手。
标签: substrate