mirror of
https://github.com/status-im/keycard-redeem.git
synced 2025-01-14 14:15:53 +00:00
close #13
This commit is contained in:
parent
e118c153f9
commit
6a243df6e1
@ -26,6 +26,8 @@ abstract contract Bucket {
|
||||
bytes32 code;
|
||||
}
|
||||
|
||||
event Redeemed(address indexed recipient, uint256 indexed data);
|
||||
|
||||
mapping(address => Redeemable) public redeemables;
|
||||
|
||||
modifier onlyOwner() {
|
||||
@ -79,6 +81,7 @@ abstract contract Bucket {
|
||||
redeemable.data = 0;
|
||||
|
||||
transferRedeemable(data, _redeem);
|
||||
emit Redeemed(recipient, data);
|
||||
}
|
||||
|
||||
function kill() external onlyOwner {
|
||||
|
@ -276,11 +276,13 @@ contract("ERC20Bucket", function () {
|
||||
const sig = await signRedeem(ERC20Bucket._address, signer, message);
|
||||
const redeem = ERC20Bucket.methods.redeem(message, sig);
|
||||
const redeemGas = await redeem.estimateGas();
|
||||
await redeem.send({
|
||||
let receipt = await redeem.send({
|
||||
from: relayer,
|
||||
gas: redeemGas,
|
||||
});
|
||||
|
||||
assert.equal(receipt.events.Redeemed.returnValues.recipient, recipient);
|
||||
assert.equal(receipt.events.Redeemed.returnValues.data, redeemable.data);
|
||||
|
||||
let expectedBucketBalance = parseInt(initialBucketBalance) - amount;
|
||||
let bucketBalance = await TestToken.methods.balanceOf(ERC20Bucket._address).call();
|
||||
|
@ -221,11 +221,14 @@ contract("NFTBucket", function () {
|
||||
const sig = await signRedeem(NFTBucket._address, signer, message);
|
||||
const redeem = NFTBucket.methods.redeem(message, sig);
|
||||
const redeemGas = await redeem.estimateGas();
|
||||
await redeem.send({
|
||||
let receipt = await redeem.send({
|
||||
from: relayer,
|
||||
gas: redeemGas,
|
||||
});
|
||||
|
||||
assert.equal(receipt.events.Redeemed.returnValues.recipient, recipient);
|
||||
assert.equal(receipt.events.Redeemed.returnValues.data, tokenID);
|
||||
|
||||
let tokenOwner = await TestNFT.methods.ownerOf(tokenID).call();
|
||||
assert.equal(tokenOwner, receiver, `Token owner is ${tokenOwner} instead of the expected ${receiver}`);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user