Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collections: changes after merge #8

Merged
merged 25 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9db7549
refactor as per PR
gangov Aug 14, 2024
f8a9be8
refactors the key used to store the balance of nfts
gangov Aug 14, 2024
9071b64
adds upgrade entrypoint
gangov Aug 14, 2024
ed7f96a
update
gangov Aug 14, 2024
fadde09
adds is_initialized check and tests for it
gangov Aug 15, 2024
2222893
refactor as per PR comments
gangov Aug 15, 2024
7f1e3ab
failing path for batch_balance_of
gangov Aug 15, 2024
ff8dc8c
failing test case for when the user tries to authorize himself
gangov Aug 15, 2024
29320e1
adds tests for when the user doesn't have enough to spend
gangov Aug 15, 2024
8d73640
adds a test for safe_transfer
gangov Aug 15, 2024
cd380b2
removes a test and refactors the logic on how we handle transfer
gangov Aug 15, 2024
80d7efa
safe batch transfer test
gangov Aug 15, 2024
dd84a14
more tests for the failing path when dealing with safe_batch_transfer
gangov Aug 15, 2024
9ffe070
adds a failing test case for when the user is not authorized to mint
gangov Aug 15, 2024
250dbf5
more tests for failing test case when batch_minting
gangov Aug 15, 2024
263c4fe
test for when burn fails
gangov Aug 15, 2024
7f0aedd
more tests for when batch_burn fails
gangov Aug 15, 2024
15e6afc
test for when set_uri fails
gangov Aug 15, 2024
ada922a
test for set collection uri
gangov Aug 15, 2024
bc06a71
test case for when looking for a uri when such is not set
gangov Aug 15, 2024
8b6f972
adds a few tarpaulin macros to ignore test cases which we cannot cover
gangov Aug 15, 2024
55a32ed
adds events
gangov Aug 16, 2024
08603cc
removes unnecessary comment
gangov Aug 16, 2024
10bb2dc
adds README.md
gangov Aug 16, 2024
f131f66
changes to a test
gangov Aug 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/auctions/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![no_std]

use soroban_sdk::{contract, contractimpl, contracttype, Address, BytesN, Env, Vec};
use soroban_sdk::{contract, contractimpl, contracttype, Address, Env, Vec};

#[derive(Clone)]
#[contracttype]
Expand Down
1 change: 1 addition & 0 deletions contracts/collections/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ soroban-sdk = { workspace = true }

[dev_dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
test-case = "3.3.1"
258 changes: 258 additions & 0 deletions contracts/collections/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@

# Collections

## Main functionality
This is a contract for managing collections of tokens, similar to the ERC-1155 standard. It allows for the creation, transfer, and management of multiple token types within a single contract.

## Messages:

`initialize`

Params:
- `admin`: `Address` of the administrator for the collection
- `name`: `String` name of the collection
- `symbol`: `String` symbol for the collection

Return type:
`Result<(), ContractError>`

Description:
Initializes the collection contract with an admin, name, and symbol.

<hr>

`balance_of`

Params:
- `account`: `Address` of the account to check
- `id`: `u64` ID of the token type

Return type:
`Result<u64, ContractError>`

Description:
Returns the balance of a specific token type for a given account.

<hr>

`balance_of_batch`

Params:
- `accounts`: `Vec<Address>` list of accounts to check
- `ids`: `Vec<u64>` list of token type IDs

Return type:
`Result<Vec<u64>, ContractError>`

Description:
Returns the balances of multiple token types for multiple accounts.

<hr>

`set_approval_for_all`

Params:
- `sender`: `Address` of the account granting approval
- `operator`: `Address` of the account being approved
- `approved`: `bool` approval status

Return type:
`Result<(), ContractError>`

Description:
Grants or revokes permission for an operator to manage the sender's tokens.

<hr>

`is_approved_for_all`

Params:
- `owner`: `Address` of the token owner
- `operator`: `Address` of the potential operator

Return type:
`Result<bool, ContractError>`

Description:
Checks if an operator is approved to manage an owner's tokens.

<hr>

`safe_transfer_from`

Params:
- `from`: `Address` of the sender
- `to`: `Address` of the recipient
- `id`: `u64` ID of the token type
- `transfer_amount`: `u64` amount to transfer

Return type:
`Result<(), ContractError>`

Description:
Transfers tokens of a specific type from one address to another.

<hr>

`safe_batch_transfer_from`

Params:
- `from`: `Address` of the sender
- `to`: `Address` of the recipient
- `ids`: `Vec<u64>` list of token type IDs
- `amounts`: `Vec<u64>` list of amounts to transfer

Return type:
`Result<(), ContractError>`

Description:
Transfers multiple types and amounts of tokens from one address to another.

<hr>

`mint`

Params:
- `sender`: `Address` of the minting authority
- `to`: `Address` of the recipient
- `id`: `u64` ID of the token type
- `amount`: `u64` amount to mint

Return type:
`Result<(), ContractError>`

Description:
Mints new tokens of a specific type to a recipient.

<hr>

`mint_batch`

Params:
- `sender`: `Address` of the minting authority
- `to`: `Address` of the recipient
- `ids`: `Vec<u64>` list of token type IDs
- `amounts`: `Vec<u64>` list of amounts to mint

Return type:
`Result<(), ContractError>`

Description:
Mints multiple types and amounts of tokens to a recipient.

<hr>

`burn`

Params:
- `from`: `Address` of the token holder
- `id`: `u64` ID of the token type
- `amount`: `u64` amount to burn

Return type:
`Result<(), ContractError>`

Description:
Burns (destroys) tokens of a specific type from an address.

<hr>

`burn_batch`

Params:
- `from`: `Address` of the token holder
- `ids`: `Vec<u64>` list of token type IDs
- `amounts`: `Vec<u64>` list of amounts to burn

Return type:
`Result<(), ContractError>`

Description:
Burns multiple types and amounts of tokens from an address.

<hr>

`set_uri`

Params:
- `sender`: `Address` of the authority
- `id`: `u64` ID of the token type
- `uri`: `Bytes` URI for the token type

Return type:
`Result<(), ContractError>`

Description:
Sets the URI for a specific token type.

<hr>

`set_collection_uri`

Params:
- `uri`: `Bytes` URI for the collection

Return type:
`Result<(), ContractError>`

Description:
Sets the main image (logo) URI for the entire collection.

<hr>

`uri`

Params:
- `id`: `u64` ID of the token type

Return type:
`Result<URIValue, ContractError>`

Description:
Retrieves the URI for a specific token type.

<hr>

`collection_uri`

Params:
None

Return type:
`Result<URIValue, ContractError>`

Description:
Retrieves the URI for the entire collection.

<hr>

`upgrade`

Params:
- `new_wasm_hash`: `BytesN<32>` hash of the new contract WASM

Return type:
`Result<(), ContractError>`

Description:
Upgrades the contract to a new WASM implementation.

<hr>

## Internal Structs

```rust
pub struct Config {
pub name: String,
pub symbol: String,
}

pub struct URIValue {
pub uri: Bytes,
}

pub struct OperatorApprovalKey {
pub owner: Address,
pub operator: Address,
}
```
Loading
Loading