Skip to content

Commit

Permalink
NFT Dev Branch (#142)
Browse files Browse the repository at this point in the history
* NFT Transfers (#130)

* basic transfer logic

* wip

* allow account level delegation

* token-level approvals

* singular to batched state apis (#133)

* rename account-level authorization methods

* use vector of ActorIDs to record operators

* NFT Receiver Hooks (#135)

* add receiver hook support to state level

* batch for minting

* structure tests with logical blocks

* generate return value from current state (#138)

* State Invariant Checker for NFTs (#140)

* added a state invariant checker for NFTs

* delete map entries where possible during burn operations

* update toolchain during build jobs

* cargo clippy --fix

* Multi actor integration tests (#141)

* added a state invariant checker for NFTs

* delete map entries where possible during burn operations

* update toolchain during build jobs

* cargo clippy --fix

* metadataid to metadata

* separate traits for testing frc46 and nft testing fixtures

* rename test_actor to frc46_test_actor

* test nft actor

* actor to actor transfer tests

* fix bug in operator burn

* NFT Integration Tests (#143)

* separate testing modules into separate files

* mint to alice - alice rejects

* mint to token contract itself

* alice mints to herself - burns

* mint to alice, hook transfers to bob

* alice mints to bob who rejects

* token contract transfer tests

* two actor tests completed

* fix dependencies

* don't link nft_actor into integration tests

* NFT improvements (#145)

* add OwnerOf

* annotate tests with post-run state

* make metadata a string instead of a cid

* use bitfield to store operators

* temporary fix for yanked funty1.2.0
  • Loading branch information
alexytsu committed Nov 17, 2022
1 parent 89f1fd2 commit 9c7aa8b
Show file tree
Hide file tree
Showing 41 changed files with 3,390 additions and 758 deletions.
9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,10 @@ members = [
"testing/fil_token_integration/actors/basic_receiving_actor",
"testing/fil_token_integration/actors/basic_token_actor",
"testing/fil_token_integration/actors/basic_transfer_actor",
"testing/fil_token_integration/actors/test_actor"
]
"testing/fil_token_integration/actors/frc46_test_actor",
"testing/fil_token_integration/actors/frcxx_test_actor"
]

[patch.crates-io]
# tracking issue: https://github.com/bitvecto-rs/funty/issues/7
funty = { git = "https://github.com/bitvecto-rs/funty/", rev = "7ef0d890fbcd8b3def1635ac1a877fc298488446" }
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ test-coverage: install-toolchain
--exclude basic_receiving_actor \
--exclude basic_nft_actor \
--exclude basic_transfer_actor \
--exclude test_actor
--exclude frc46_test_actor \
--exclude frcxx_test_actor

# separate actor testing stage to run from CI without coverage support
test-actors: install-toolchain
Expand Down
2 changes: 1 addition & 1 deletion dispatch_examples/greeter/tests/greet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fn test_greeter() {
let return_data = ret_val.msg_receipt.return_data;
let greeting: String = return_data.deserialize().unwrap();
// display the result - run `cargo test -- --nocapture` to see output
println!("greeting: {}", greeting);
println!("greeting: {greeting}");

assert_eq!(greeting, "Hello, World!")
}
2 changes: 1 addition & 1 deletion frc42_dispatch/hasher/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<T: Hasher> MethodResolver<T> {
return Ok(Self::CONSTRUCTOR_METHOD_NUMBER);
}

let method_name = format!("1|{}", method_name);
let method_name = format!("1|{method_name}");
let digest = self.hasher.hash(method_name.as_bytes());

for chunk in digest.chunks(Self::DIGEST_CHUNK_LENGTH) {
Expand Down
2 changes: 1 addition & 1 deletion frc42_dispatch/macros/example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use frc42_macros::method_hash;

fn main() {
let str_hash = method_hash!("Method");
println!("String hash: {:x}", str_hash);
println!("String hash: {str_hash:x}");

// this one breaks naming rules and will fail to compile
//println!("error hash: {}", method_hash!("some_function"));
Expand Down
2 changes: 1 addition & 1 deletion frc46_token/src/token/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ mod test {
let msg = error.to_string();
let exit_code = ExitCode::from(&error);
// taking the exit code doesn't consume the error
println!("{}: {:?}", msg, exit_code);
println!("{msg}: {exit_code:?}");
assert_eq!(exit_code, ExitCode::USR_ILLEGAL_STATE);
}
}
18 changes: 9 additions & 9 deletions frc46_token/src/token/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,7 @@ mod test {
assert_eq!(allowance, TokenAmount::zero());
assert_eq!(delta, TokenAmount::from_atto(10));
}
e => panic!("Unexpected error {:?}", e),
e => panic!("Unexpected error {e:?}"),
}
// balances unchanged
assert_eq!(token.balance_of(secp_address).unwrap(), TokenAmount::zero());
Expand Down Expand Up @@ -2100,7 +2100,7 @@ mod test {
assert_eq!(allowance, TokenAmount::zero());
assert_eq!(delta, TokenAmount::zero());
}
e => panic!("Unexpected error {:?}", e),
e => panic!("Unexpected error {e:?}"),
}
// balances unchanged
assert_eq!(token.balance_of(secp_address).unwrap(), TokenAmount::zero());
Expand Down Expand Up @@ -2165,7 +2165,7 @@ mod test {
assert_eq!(allowance, TokenAmount::zero());
assert_eq!(delta, burn_amount);
}
e => panic!("unexpected error {:?}", e),
e => panic!("unexpected error {e:?}"),
};

// balances didn't change
Expand Down Expand Up @@ -2222,7 +2222,7 @@ mod test {
assert_eq!(allowance, TokenAmount::zero());
assert_eq!(delta, burn_amount);
}
e => panic!("unexpected error {:?}", e),
e => panic!("unexpected error {e:?}"),
};
// balances unchanged
assert_eq!(token.total_supply(), TokenAmount::from_atto(400_000));
Expand Down Expand Up @@ -2273,7 +2273,7 @@ mod test {
assert_eq!(allowance, TokenAmount::zero());
assert_eq!(delta, burn_amount);
}
e => panic!("unexpected error {:?}", e),
e => panic!("unexpected error {e:?}"),
};
// balances unchanged
assert_eq!(token.total_supply(), mint_amount);
Expand All @@ -2295,7 +2295,7 @@ mod test {
assert_eq!(allowance, TokenAmount::zero());
assert_eq!(delta, TokenAmount::zero());
}
e => panic!("unexpected error {:?}", e),
e => panic!("unexpected error {e:?}"),
};
// balances unchanged
assert_eq!(token.total_supply(), mint_amount);
Expand Down Expand Up @@ -2645,7 +2645,7 @@ mod test {
assert_eq!(a, TokenAmount::from_atto(allowance));
assert_eq!(delta, TokenAmount::from_atto(transfer));
} else {
panic!("unexpected error {:?}", err);
panic!("unexpected error {err:?}");
}
}
"BALANCE_ERR" => {
Expand All @@ -2659,7 +2659,7 @@ mod test {
assert_eq!(delta, TokenAmount::from_atto(transfer).neg());
assert_eq!(b, TokenAmount::from_atto(balance));
} else {
panic!("unexpected error {:?}", err);
panic!("unexpected error {err:?}");
}
}
"ADDRESS_ERR" => {
Expand All @@ -2668,7 +2668,7 @@ mod test {
{
assert!((addr == *operator) || (addr == *from));
} else {
panic!("unexpected error {:?}", err);
panic!("unexpected error {err:?}");
}
}
_ => panic!("test case not implemented"),
Expand Down
1 change: 1 addition & 0 deletions frcxx_nft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2021"
cid = { version = "0.8.3", default-features = false, features = ["serde-codec"] }
frc42_dispatch = { path = "../frc42_dispatch" }
fvm_actor_utils = { version = "0.1.0", path = "../fvm_actor_utils" }
fvm_ipld_bitfield = "0.5.4"
fvm_ipld_blockstore = "0.1.1"
fvm_ipld_hamt = "0.5.1"
fvm_ipld_amt = { version = "0.4.2", features = ["go-interop"] }
Expand Down
Loading

0 comments on commit 9c7aa8b

Please sign in to comment.