fn replace_ethers_crates(stream: TokenStream) -> TokenStream {
    let mut new_stream = TokenStream::new();

    for v in stream {
        match v {
            TokenTree::Group(group) => {
                let group_stream = replace_ethers_crates(group.stream());

                new_stream.extend([TokenTree::Group(Group::new(
                    group.delimiter(),
                    group_stream,
                ))]);
            }
            TokenTree::Ident(ident) => {
                if ident == "ethers" {
                    new_stream.extend([
                        TokenTree::Ident(Ident::new(
                            "offchain_core",
                            Span::call_site(),
                        )),
                        TokenTree::Punct(Punct::new(':', Spacing::Joint)),
                        TokenTree::Punct(Punct::new(':', Spacing::Alone)),
                    ]);
                }

                new_stream.extend([TokenTree::Ident(ident)]);
            }
            tree => new_stream.extend([tree]),
        }
    }

    new_stream
}
/// Changes ethers crates to the offchain_core reexport.
///
/// This way, updating the ethers version is trivial, and we make sure every
/// contract bindings use it.
Changes ethers crates to the offchain_core reexport.
This way, updating the ethers version is trivial, and we make sure every
contract bindings use it.
Changes ethers crates to the offchain_core reexport . This way updating the ethers version is trivial and we make sure every contract bindings use it .
fn replace_ethers_crates(stream: TokenStream) -> TokenStream {
    let mut new_stream = TokenStream::new();
    for v in stream {
        match v {
            TokenTree::Group(group) => {
                let group_stream = replace_ethers_crates(group.stream());
                new_stream.extend([TokenTree::Group(Group::new(
                    group.delimiter(),
                    group_stream,
                ))]);
            }
            TokenTree::Ident(ident) => {
                if ident == "ethers" {
                    new_stream.extend([
                        TokenTree::Ident(Ident::new(
                            "offchain_core",
                            Span::call_site(),
                        )),
                        TokenTree::Punct(Punct::new(':', Spacing::Joint)),
                        TokenTree::Punct(Punct::new(':', Spacing::Alone)),
                    ]);
                }
                new_stream.extend([TokenTree::Ident(ident)]);
            }
            tree => new_stream.extend([tree]),
        }
    }
    new_stream
}
fn replace_ethers_crates ( stream : TokenStream ) -> TokenStream { let mut new_stream = TokenStream :: new ( ) ; for v in stream { match v { TokenTree :: Group ( group ) => { let group_stream = replace_ethers_crates ( group . stream ( ) ) ; new_stream . extend ( [ TokenTree :: Group ( Group :: new ( group . delimiter ( ) , group_stream , ) ) ] ) ; } TokenTree :: Ident ( ident ) => { if ident == " " { new_stream . extend ( [ TokenTree :: Ident ( Ident :: new ( " " , Span :: call_site ( ) , ) ) , TokenTree :: Punct ( Punct :: new ( ':' , Spacing :: Joint ) ) , TokenTree :: Punct ( Punct :: new ( ':' , Spacing :: Alone ) ) , ] ) ; } new_stream . extend ( [ TokenTree :: Ident ( ident ) ] ) ; } tree => new_stream . extend ( [ tree ] ) , } } new_stream }
Changes ethers crates to the offchain_core reexport.
Changes ethers crates to the offchain_core reexport .
stream
TokenStream