Skip to content

Commit

Permalink
💥 change badge locked status from unlock to lock by default
Browse files Browse the repository at this point in the history
  • Loading branch information
bal7hazar committed Sep 14, 2022
1 parent da3187e commit 0538860
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion scripts/configs/testnet.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ACCOUNT=carbonable
WALLET=starkware.starknet.wallets.open_zeppelin.OpenZeppelinAccount

# ERC-1155 settings
ERC1155_URI="ipfs://bafybeignr4tutoraenal42bjlpn35yfiy5pe3acu7scx7hnsbwshp3dt7e/{id}.json"
ERC1155_URI="ipfs://bafybeignr4tutoraenal42bjlpn35yfiy5pe3acu7scx7hnsbwshp3dt7e/"
ERC1155_NAME="Carbonable ERC-1155 Test"

# ERC-721 settings
Expand Down
10 changes: 5 additions & 5 deletions src/badge/library.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ end
#
@storage_var
func CarbonableBadge_locked(id : Uint256) -> (locked : felt):
func CarbonableBadge_unlocked(id : Uint256) -> (unlocked : felt):
end
@storage_var
Expand Down Expand Up @@ -91,8 +91,8 @@ namespace CarbonableBadge:
) -> (is_locked : felt):
uint256_check(id)

let (is_locked) = CarbonableBadge_locked.read(id)
return (is_locked)
let (is_unlocked) = CarbonableBadge_unlocked.read(id)
return (1 - is_unlocked)
end

#
Expand All @@ -117,7 +117,7 @@ namespace CarbonableBadge:
) -> ():
uint256_check(id)

CarbonableBadge_locked.write(id, TRUE)
CarbonableBadge_unlocked.write(id, FALSE)
Locked.emit(id)

return ()
Expand All @@ -128,7 +128,7 @@ namespace CarbonableBadge:
) -> ():
uint256_check(id)

CarbonableBadge_locked.write(id, FALSE)
CarbonableBadge_unlocked.write(id, TRUE)
Unlocked.emit(id)

return ()
Expand Down
4 changes: 2 additions & 2 deletions tests/integrations/badge/test_nominal_cases.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ func test_mint_and_transfer{syscall_ptr : felt*, pedersen_ptr : HashBuiltin*, ra
let (admin_address) = admin.get_address()

admin.mint(to=anyone_address, id=0, amount=2)
anyone.transfer(to=admin_address, id=0, amount=1)
admin.lock(id=0)
%{ expect_revert("TRANSACTION_FAILED", "CarbonableBadge: transfer is locked") %}
anyone.transfer(to=admin_address, id=0, amount=1)
admin.unlock(id=0)
anyone.transfer(to=admin_address, id=0, amount=1)
return ()
end

Expand Down
16 changes: 8 additions & 8 deletions tests/units/badge/test_assert_unlocked.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ func test_assert_unlocked{
# run scenario
%{ stop=start_prank(context.signers.admin) %}

%{ expect_revert("TRANSACTION_FAILED", "CarbonableBadge: transfer is locked") %}
CarbonableBadge.assert_unlocked(zero)
CarbonableBadge.set_locked(zero)

%{ expect_revert("TRANSACTION_FAILED", "CarbonableBadge: transfer is locked") %}
CarbonableBadge.set_unlocked(zero)
CarbonableBadge.assert_unlocked(zero)

%{ stop() %}
Expand Down Expand Up @@ -70,23 +70,23 @@ func test_assert_unlocked_batch{
# run scenario
%{ stop=start_prank(context.signers.admin) %}

CarbonableBadge.assert_unlocked_batch(2, ids)
CarbonableBadge.set_locked(zero)

%{ expect_revert("TRANSACTION_FAILED", "CarbonableBadge: transfer is locked") %}
CarbonableBadge.assert_unlocked_batch(2, ids)

CarbonableBadge.set_locked(one)
CarbonableBadge.set_unlocked(zero)

%{ expect_revert("TRANSACTION_FAILED", "CarbonableBadge: transfer is locked") %}
CarbonableBadge.assert_unlocked_batch(2, ids)

CarbonableBadge.set_unlocked(zero)
CarbonableBadge.set_unlocked(one)
CarbonableBadge.assert_unlocked_batch(2, ids)

CarbonableBadge.set_locked(zero)
%{ expect_revert("TRANSACTION_FAILED", "CarbonableBadge: transfer is locked") %}
CarbonableBadge.assert_unlocked_batch(2, ids)

CarbonableBadge.set_unlocked(one)
CarbonableBadge.set_locked(one)
%{ expect_revert("TRANSACTION_FAILED", "CarbonableBadge: transfer is locked") %}
CarbonableBadge.assert_unlocked_batch(2, ids)

%{ stop() %}
Expand Down
32 changes: 16 additions & 16 deletions tests/units/badge/test_locked.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ func test_set_locked{
%{ stop=start_prank(context.signers.admin) %}

let (locked_status) = CarbonableBadge.locked(zero)
assert locked_status = FALSE
assert locked_status = TRUE

CarbonableBadge.set_locked(zero)
CarbonableBadge.set_unlocked(zero)

let (locked_status) = CarbonableBadge.locked(zero)
assert locked_status = TRUE
assert locked_status = FALSE

CarbonableBadge.set_locked(zero)
CarbonableBadge.set_unlocked(zero)

let (locked_status) = CarbonableBadge.locked(zero)
assert locked_status = TRUE
assert locked_status = FALSE

let (locked_status) = CarbonableBadge.locked(one)
assert locked_status = FALSE
assert locked_status = TRUE

%{ stop() %}

Expand All @@ -78,30 +78,30 @@ func test_set_unlocked{
%{ stop=start_prank(context.signers.admin) %}

let (locked_status) = CarbonableBadge.locked(zero)
assert locked_status = FALSE
assert locked_status = TRUE

CarbonableBadge.set_unlocked(zero)
CarbonableBadge.set_locked(zero)

let (locked_status) = CarbonableBadge.locked(zero)
assert locked_status = FALSE
assert locked_status = TRUE

CarbonableBadge.set_locked(zero)
CarbonableBadge.set_unlocked(zero)

let (locked_status) = CarbonableBadge.locked(zero)
assert locked_status = TRUE
assert locked_status = FALSE

CarbonableBadge.set_locked(one)
CarbonableBadge.set_unlocked(one)

let (locked_status) = CarbonableBadge.locked(one)
assert locked_status = TRUE
assert locked_status = FALSE

CarbonableBadge.set_unlocked(zero)
CarbonableBadge.set_locked(zero)

let (locked_status) = CarbonableBadge.locked(zero)
assert locked_status = FALSE
assert locked_status = TRUE

let (locked_status) = CarbonableBadge.locked(one)
assert locked_status = TRUE
assert locked_status = FALSE

%{ stop() %}

Expand Down

0 comments on commit 0538860

Please sign in to comment.