contract.test.ts.md•8.87 kB
# Snapshot report for `src/contract.test.ts`
The actual snapshot is saved in `contract.test.ts.snap`.
Generated by [AVA](https://avajs.dev).
## contract basics
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Stylus ^0.2.0␊
␊
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]␊
extern crate alloc;␊
␊
use stylus_sdk::prelude::*;␊
␊
#[entrypoint]␊
#[storage]␊
struct Foo;␊
␊
#[public]␊
impl Foo {}␊
`
## contract with function
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Stylus ^0.2.0␊
␊
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]␊
extern crate alloc;␊
␊
use stylus_sdk::prelude::*;␊
␊
#[entrypoint]␊
#[storage]␊
struct Foo;␊
␊
#[public]␊
impl Foo {␊
fn some_function(&self) {␊
todo!()␊
}␊
}␊
`
## contract with function and code before
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Stylus ^0.2.0␊
␊
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]␊
extern crate alloc;␊
␊
use stylus_sdk::prelude::*;␊
␊
#[entrypoint]␊
#[storage]␊
struct Foo;␊
␊
#[public]␊
impl Foo {␊
fn some_function(&self) {␊
before();␊
todo!()␊
}␊
}␊
`
## contract with parent
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Stylus ^0.2.0␊
␊
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]␊
extern crate alloc;␊
␊
use mod_ext::{IErc20, Parent};␊
use stylus_sdk::prelude::*;␊
␊
#[entrypoint]␊
#[storage]␊
struct Foo {␊
parent: Parent,␊
}␊
␊
#[public]␊
#[implements(IErc20)]␊
impl Foo {}␊
␊
#[public]␊
impl IErc20 for Foo {␊
fn some_function(&self) {␊
self.parent.some_function()␊
}␊
}␊
`
## contract with parent and associated error
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Stylus ^0.2.0␊
␊
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]␊
extern crate alloc;␊
␊
use mod_ext::{self, IErc20, Parent};␊
use stylus_sdk::prelude::*;␊
␊
#[entrypoint]␊
#[storage]␊
struct Foo {␊
parent: Parent,␊
}␊
␊
#[public]␊
#[implements(IErc20<Error = mod_ext::Error>)]␊
impl Foo {}␊
␊
#[public]␊
impl IErc20 for Foo {␊
type Error = mod_ext::Error;␊
␊
fn some_function(&self) -> Result<(), Self::Error> {␊
Ok(self.parent.some_function()?)␊
}␊
}␊
`
## contract with parent and with function
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Stylus ^0.2.0␊
␊
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]␊
extern crate alloc;␊
␊
use mod_ext::{IErc20, Parent};␊
use stylus_sdk::prelude::*;␊
␊
#[entrypoint]␊
#[storage]␊
struct Foo {␊
parent: Parent,␊
}␊
␊
#[public]␊
#[implements(IErc20)]␊
impl Foo {␊
fn my_function(&self) {␊
todo!()␊
}␊
}␊
␊
#[public]␊
impl IErc20 for Foo {␊
fn some_function(&self) {␊
self.parent.some_function()␊
}␊
}␊
`
## contract with parent and with function with code before
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Stylus ^0.2.0␊
␊
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]␊
extern crate alloc;␊
␊
use mod_ext::{IErc20, Parent};␊
use stylus_sdk::prelude::*;␊
␊
#[entrypoint]␊
#[storage]␊
struct Foo {␊
parent: Parent,␊
}␊
␊
#[public]␊
#[implements(IErc20)]␊
impl Foo {␊
fn my_function(&self) {␊
before();␊
todo!()␊
}␊
}␊
␊
#[public]␊
impl IErc20 for Foo {␊
fn some_function(&self) {␊
before();␊
self.parent.some_function()␊
}␊
}␊
`
## contract with standalone import
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Stylus ^0.2.0␊
␊
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]␊
extern crate alloc;␊
␊
use some::library::SomeLibrary;␊
use stylus_sdk::prelude::*;␊
␊
#[entrypoint]␊
#[storage]␊
struct Foo;␊
␊
#[public]␊
impl Foo {}␊
`
## contract with grouped imports
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Stylus ^0.2.0␊
␊
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]␊
extern crate alloc;␊
␊
use some::library::{Misc, SomeLibrary};␊
use stylus_sdk::prelude::*;␊
␊
#[entrypoint]␊
#[storage]␊
struct Foo;␊
␊
#[public]␊
impl Foo {}␊
`
## contract with sorted use clauses
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Stylus ^0.2.0␊
␊
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]␊
extern crate alloc;␊
␊
use another::library::{AnotherLibrary, Foo as Custom1, Foo as Custom2};␊
use some::library::SomeLibrary;␊
use stylus_sdk::prelude::*;␊
␊
#[entrypoint]␊
#[storage]␊
struct Foo;␊
␊
#[public]␊
impl Foo {}␊
`
## contract with sorted traits
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Stylus ^0.2.0␊
␊
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]␊
extern crate alloc;␊
␊
use mod_a::{A, IErc20};␊
use mod_b::{B, IErc721};␊
use mod_special::{IErc1155, Special};␊
use mod_z::{IErc165, Z};␊
use stylus_sdk::prelude::*;␊
␊
#[entrypoint]␊
#[storage]␊
struct Foo {␊
special: Special,␊
z: Z,␊
a: A,␊
b: B,␊
}␊
␊
#[public]␊
#[implements(IErc1155, IErc165, IErc20, IErc721)]␊
impl Foo {}␊
␊
#[public]␊
impl IErc1155 for Foo {␊
fn func_special() {␊
todo!()␊
}␊
}␊
␊
#[public]␊
impl IErc165 for Foo {␊
fn func_z() {␊
todo!()␊
}␊
}␊
␊
#[public]␊
impl IErc20 for Foo {␊
fn func_a() {␊
todo!()␊
}␊
}␊
␊
#[public]␊
impl IErc721 for Foo {␊
fn func_b() {␊
todo!()␊
}␊
}␊
`
## contract with documentation
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Stylus ^0.2.0␊
//! Some documentation␊
␊
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]␊
extern crate alloc;␊
␊
use stylus_sdk::prelude::*;␊
␊
#[entrypoint]␊
#[storage]␊
struct Foo;␊
␊
#[public]␊
impl Foo {}␊
`
## contract with security info
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Stylus ^0.2.0␊
␊
//! # Security␊
//!␊
//! For security issues, please contact: security@example.com␊
␊
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]␊
extern crate alloc;␊
␊
use stylus_sdk::prelude::*;␊
␊
#[entrypoint]␊
#[storage]␊
struct Foo;␊
␊
#[public]␊
impl Foo {}␊
`
## contract with security info and documentation
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Stylus ^0.2.0␊
//! Some documentation␊
␊
//! # Security␊
//!␊
//! For security issues, please contact: security@example.com␊
␊
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]␊
extern crate alloc;␊
␊
use stylus_sdk::prelude::*;␊
␊
#[entrypoint]␊
#[storage]␊
struct Foo;␊
␊
#[public]␊
impl Foo {}␊
`