From 6ddc4693fafff74ec4cdcbc8badfbf9deaf900dd Mon Sep 17 00:00:00 2001 From: blockplus Date: Tue, 10 Nov 2020 08:36:54 -0800 Subject: [PATCH 1/3] Implement SIP-3, swipe cards contract with unregister function --- Improvement Proposals/SIP-1/README.md | 6 +- Improvement Proposals/SIP-2/README.md | 6 +- Improvement Proposals/SIP-3/README.md | 97 ++++++ Improvement Proposals/SIP-3/SIP-3.js | 1 + Improvement Proposals/SIP-3/SwipeCards.sol | 1 + .../SIP-3/SwipeCardsEvent.sol | 1 + .../SIP-3/SwipeCardsProxy.sol | 1 + .../SIP-3/SwipeCardsStorage.sol | 1 + Improvement Proposals/SIP-3/SwipeCardsTest.js | 1 + contracts/card/SwipeCards.sol | 39 +++ contracts/card/SwipeCardsEvent.sol | 5 + test/SIP-3.js | 281 ++++++++++++++++++ test/StakingV3Test.js | 106 +++---- test/SwipeCardsTest.js | 135 +++++++-- 14 files changed, 603 insertions(+), 78 deletions(-) create mode 100644 Improvement Proposals/SIP-3/README.md create mode 120000 Improvement Proposals/SIP-3/SIP-3.js create mode 120000 Improvement Proposals/SIP-3/SwipeCards.sol create mode 120000 Improvement Proposals/SIP-3/SwipeCardsEvent.sol create mode 120000 Improvement Proposals/SIP-3/SwipeCardsProxy.sol create mode 120000 Improvement Proposals/SIP-3/SwipeCardsStorage.sol create mode 120000 Improvement Proposals/SIP-3/SwipeCardsTest.js create mode 100755 test/SIP-3.js diff --git a/Improvement Proposals/SIP-1/README.md b/Improvement Proposals/SIP-1/README.md index 8e9f183..d7b9cfd 100644 --- a/Improvement Proposals/SIP-1/README.md +++ b/Improvement Proposals/SIP-1/README.md @@ -64,9 +64,9 @@ calldata - 1800, 400000000000000000000, 604800 // a week ``` ## Changes -- [StakingV2.js](https://github.com/SwipeWallet/Swipe-Network/blob/master/contracts/staking/StakingV2.sol) -- [StakingStorageV2.js](https://github.com/SwipeWallet/Swipe-Network/blob/master/contracts/staking/StakingStorageV3.sol) -- [StakingEventV2.js](https://github.com/SwipeWallet/Swipe-Network/blob/master/contracts/staking/StakingEventV2.sol) +- [StakingV2.sol](https://github.com/SwipeWallet/Swipe-Network/blob/master/contracts/staking/StakingV2.sol) +- [StakingStorageV2.sol](https://github.com/SwipeWallet/Swipe-Network/blob/master/contracts/staking/StakingStorageV3.sol) +- [StakingEventV2.sol](https://github.com/SwipeWallet/Swipe-Network/blob/master/contracts/staking/StakingEventV2.sol) ## Tests - [SIP-1.js](https://github.com/SwipeWallet/Swipe-Network/blob/master/test/SIP-1.js) diff --git a/Improvement Proposals/SIP-2/README.md b/Improvement Proposals/SIP-2/README.md index af2e048..314756e 100644 --- a/Improvement Proposals/SIP-2/README.md +++ b/Improvement Proposals/SIP-2/README.md @@ -39,9 +39,9 @@ calldata - 11520 // 2 days ``` ## Changes -- [StakingV3.js](https://github.com/SwipeWallet/Swipe-Network/blob/master/contracts/staking/StakingV3.sol) -- [StakingStorageV3.js](https://github.com/SwipeWallet/Swipe-Network/blob/master/contracts/staking/StakingStorageV3.sol) -- [StakingEventV3.js](https://github.com/SwipeWallet/Swipe-Network/blob/master/contracts/staking/StakingEventV3.sol) +- [StakingV3.sol](https://github.com/SwipeWallet/Swipe-Network/blob/master/contracts/staking/StakingV3.sol) +- [StakingStorageV3.sol](https://github.com/SwipeWallet/Swipe-Network/blob/master/contracts/staking/StakingStorageV3.sol) +- [StakingEventV3.sol](https://github.com/SwipeWallet/Swipe-Network/blob/master/contracts/staking/StakingEventV3.sol) ## Tests - [SIP-2.js](https://github.com/SwipeWallet/Swipe-Network/blob/master/test/SIP-2.js) diff --git a/Improvement Proposals/SIP-3/README.md b/Improvement Proposals/SIP-3/README.md new file mode 100644 index 0000000..ea6f60c --- /dev/null +++ b/Improvement Proposals/SIP-3/README.md @@ -0,0 +1,97 @@ +# SIP-3 + +## Description + +This proposal is to add swipe card list into swipe cards contract. +- Transfer staking's ownership and guardianship to governance timelock contract +- Register 4 swipe cards, Swipe Saffron, Swipe Sky, Swipe Steel, Swipe Slate + +## Proposal + +### Mainnet +``` +Action1 +address - Swipe Cards Proxy contract address +value - 0 +signature - assumeOwnership() +calldata - void + +Action2: +address - Swipe Cards Proxy contract address +value - 0 +signature - assumeGuardianship() +calldata - void + +Action3: +address - Swipe Cards Proxy contract address +value - 0 +signature - registerCard(string,uint256,uint256,string,string) +calldata - Swipe Saffron, 0, 0, 0, 0 + +Action4: +address - Swipe Cards Proxy contract address +value - 0 +signature - registerCard(string,uint256,uint256,string,string) +calldata - Swipe Sky, 3000000000000000000000, 15552000, 0, 0 + +Action5: +address - Swipe Cards Proxy contract address +value - 0 +signature - registerCard(string,uint256,uint256,string,string) +calldata - Swipe Steel, 3000000000000000000000, 15552000, 0, 0 + +Action6: +address - Swipe Cards Proxy contract address +value - 0 +signature - registerCard(string,uint256,uint256,string,string) +calldata - Swipe Slate, 30000000000000000000000, 15552000, 0, 0 +``` + +### Ropsten +``` +Action1 +address - Swipe Cards Proxy contract address +value - 0 +signature - assumeOwnership() +calldata - void + +Action2: +address - Swipe Cards Proxy contract address +value - 0 +signature - assumeGuardianship() +calldata - void + +Action3: +address - Swipe Cards Proxy contract address +value - 0 +signature - registerCard(string,uint256,uint256,string,string) +calldata - Swipe Saffron, 0, 0, 0, 0 + +Action4: +address - Swipe Cards Proxy contract address +value - 0 +signature - registerCard(string,uint256,uint256,string,string) +calldata - Swipe Sky, 3000000000000000000000, 15552000, 0, 0 + +Action5: +address - Swipe Cards Proxy contract address +value - 0 +signature - registerCard(string,uint256,uint256,string,string) +calldata - Swipe Steel, 3000000000000000000000, 15552000, 0, 0 + +Action6: +address - Swipe Cards Proxy contract address +value - 0 +signature - registerCard(string,uint256,uint256,string,string) +calldata - Swipe Slate, 30000000000000000000000, 15552000, 0, 0 +``` + +## Changes +- [SwipeCardsProxy.sol](https://github.com/SwipeWallet/Swipe-Network/blob/master/contracts/card/SwipeCardsProxy.sol) +- [SwipeCards.sol](https://github.com/SwipeWallet/Swipe-Network/blob/master/contracts/card/SwipeCards.sol) +- [SwipeCardsStorage.sol](https://github.com/SwipeWallet/Swipe-Network/blob/master/contracts/card/SwipeCardsStorage.sol) +- [SwipeCardsEvent.sol](https://github.com/SwipeWallet/Swipe-Network/blob/master/contracts/card/SwipeCardsEvent.sol) + +## Tests +- [SIP-3.js](https://github.com/SwipeWallet/Swipe-Network/blob/master/test/SIP-3.js) +- [SwipeCardsTest.js](https://github.com/SwipeWallet/Swipe-Network/blob/master/test/SwipeCardsTest.js) diff --git a/Improvement Proposals/SIP-3/SIP-3.js b/Improvement Proposals/SIP-3/SIP-3.js new file mode 120000 index 0000000..37d6159 --- /dev/null +++ b/Improvement Proposals/SIP-3/SIP-3.js @@ -0,0 +1 @@ +../../test/SIP-3.js \ No newline at end of file diff --git a/Improvement Proposals/SIP-3/SwipeCards.sol b/Improvement Proposals/SIP-3/SwipeCards.sol new file mode 120000 index 0000000..4479e2b --- /dev/null +++ b/Improvement Proposals/SIP-3/SwipeCards.sol @@ -0,0 +1 @@ +../../contracts/card/SwipeCards.sol \ No newline at end of file diff --git a/Improvement Proposals/SIP-3/SwipeCardsEvent.sol b/Improvement Proposals/SIP-3/SwipeCardsEvent.sol new file mode 120000 index 0000000..b363550 --- /dev/null +++ b/Improvement Proposals/SIP-3/SwipeCardsEvent.sol @@ -0,0 +1 @@ +../../contracts/card/SwipeCardsEvent.sol \ No newline at end of file diff --git a/Improvement Proposals/SIP-3/SwipeCardsProxy.sol b/Improvement Proposals/SIP-3/SwipeCardsProxy.sol new file mode 120000 index 0000000..4e0acc2 --- /dev/null +++ b/Improvement Proposals/SIP-3/SwipeCardsProxy.sol @@ -0,0 +1 @@ +../../contracts/card/SwipeCardsProxy.sol \ No newline at end of file diff --git a/Improvement Proposals/SIP-3/SwipeCardsStorage.sol b/Improvement Proposals/SIP-3/SwipeCardsStorage.sol new file mode 120000 index 0000000..dbc6723 --- /dev/null +++ b/Improvement Proposals/SIP-3/SwipeCardsStorage.sol @@ -0,0 +1 @@ +../../contracts/card/SwipeCardsStorage.sol \ No newline at end of file diff --git a/Improvement Proposals/SIP-3/SwipeCardsTest.js b/Improvement Proposals/SIP-3/SwipeCardsTest.js new file mode 120000 index 0000000..256e33f --- /dev/null +++ b/Improvement Proposals/SIP-3/SwipeCardsTest.js @@ -0,0 +1 @@ +../../test/SwipeCardsTest.js \ No newline at end of file diff --git a/contracts/card/SwipeCards.sol b/contracts/card/SwipeCards.sol index dfb1002..ea89525 100644 --- a/contracts/card/SwipeCards.sol +++ b/contracts/card/SwipeCards.sol @@ -73,6 +73,10 @@ contract SwipeCards is NamedContract, SwipeCardsStorage, SwipeCardsEvent { string calldata fee, string calldata feeSplitPercentage ) external returns (uint256) { + require( + _cardCount < uint256(-1), + "Card count exceeds maximum" + ); require( bytes(cardName).length > 0, "Invalid card name" @@ -122,6 +126,41 @@ contract SwipeCards is NamedContract, SwipeCardsStorage, SwipeCardsEvent { return newCard.cardId; } + /// @notice Unregisters a existing card + /// @dev Removes a card that card id is the provided id, and rearrange card list with new id + function unregisterCard( + uint256 cardId + ) external { + require( + cardId > 0, + "Invalid card id" + ); + require( + _cardCount >= cardId && bytes(_cards[cardId].cardName).length > 0, + "Not found card" + ); + + require( + msg.sender == _guardian, + "Only the guardian can register new card" + ); + + Card memory unregisteredCard = _cards[cardId]; + + for (; cardId < _cardCount; cardId++) { + Card storage card = _cards[cardId + 1]; + card.cardId = cardId; + _cards[cardId] = card; + } + + delete _cards[_cardCount--]; + + emit CardUnregistration( + unregisteredCard.cardId, + unregisteredCard.cardName + ); + } + /// @notice Updates card /// @dev Updates the card with the provided configurations function setCard( diff --git a/contracts/card/SwipeCardsEvent.sol b/contracts/card/SwipeCardsEvent.sol index 67949b4..e21855f 100644 --- a/contracts/card/SwipeCardsEvent.sol +++ b/contracts/card/SwipeCardsEvent.sol @@ -25,6 +25,11 @@ contract SwipeCardsEvent { string feeSplitPercentage ); + event CardUnregistration( + uint256 indexed cardId, + string cardName + ); + event CardUpdate( uint256 indexed cardId, string cardName, diff --git a/test/SIP-3.js b/test/SIP-3.js new file mode 100755 index 0000000..cc1d2fe --- /dev/null +++ b/test/SIP-3.js @@ -0,0 +1,281 @@ +require('dotenv').config() +const {use, expect} = require('chai') +const {MockProvider, deployContract, solidity} = require('ethereum-waffle') +const ethers = require('ethers') + +use(solidity) + +const getCalldata = require('./helpers/getCalldata') +const encodeParameters = require('./helpers/encodeParameters') +const timeTravel = require('./helpers/timeTravel') + +const SWIPETOKEN = require("../build/SwipeToken") +const STAKINGPROXY = require('../build/StakingProxy') +const STAKING = require('../build/Staking') +const STAKINGV2 = require('../build/StakingV2') +const SWIPECARDSPROXY = require('../build/SwipeCardsProxy') +const SWIPECARDS = require('../build/SwipeCards') +const GOVERNANCEPROXY = require('../build/GovernanceProxy') +const GOVERNANCE = require('../build/Governance') +const GOVERNANCETIMELOCKPROXY = require('../build/GovernanceTimelockProxy') +const GOVERNANCETIMELOCK = require('../build/GovernanceTimelock') + +describe('SIP-3 Tests', () => { + const provider = new MockProvider({ total_accounts: 4 }) + const [walletGuardian, walletRewardProvider, proposer, voter] = provider.getWallets() + let swipeToken + let stakingProxy + let staking + let stakingV2 + let swipeCardsProxy + let governanceTimelockProxy + let governanceTimelock + let governanceProxy + let governance + let votingDelay + let votingPeriod + let timelockDelay + let proposerStakingAmount + let voterStakingAmount + + const swipeCardList = [{ + cardName: 'Swipe Saffron', + lockUp: '0', + lockUpTime: '0', + fee: '0', + feeSplitPercentage: '0' + }, { + cardName: 'Swipe Sky', + lockUp: '300000000000000000000', + lockUpTime: '15552000', + fee: '0', + feeSplitPercentage: '0' + }, { + cardName: 'Swipe Steel', + lockUp: '3000000000000000000000', + lockUpTime: '15552000', + fee: '0', + feeSplitPercentage: '0' + }, { + cardName: 'Swipe Slate', + lockUp: '30000000000000000000000', + lockUpTime: '15552000', + fee: '0', + feeSplitPercentage: '0' + }] + + beforeEach(async () => { + // Deploy all contracts + swipeToken = await deployContract(proposer, SWIPETOKEN, []) + stakingProxy = await deployContract(walletGuardian, STAKINGPROXY, []) + staking = await deployContract(walletGuardian, STAKING, []) + stakingV2 = await deployContract(walletGuardian, STAKINGV2, []) + swipeCardsProxy = await deployContract(walletGuardian, SWIPECARDSPROXY, []) + const swipeCards = await deployContract(walletGuardian, SWIPECARDS, []) + governanceTimelockProxy = await deployContract(walletGuardian, GOVERNANCETIMELOCKPROXY, []) + governanceTimelock = await deployContract(walletGuardian, GOVERNANCETIMELOCK, []) + governanceProxy = await deployContract(walletGuardian, GOVERNANCEPROXY, []) + governance = await deployContract(walletGuardian, GOVERNANCE, [], { gasLimit: 4712388 }) + let calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, swipeToken.address, walletRewardProvider.address]) + await stakingProxy.setImplementationAndCall(staking.address, calldata) + calldata = getCalldata('initialize', ['address'], [walletGuardian.address]) + await swipeCardsProxy.setImplementationAndCall(swipeCards.address, calldata) + timelockDelay = 3600 + calldata = getCalldata('initialize', ['address', 'uint256'], [governanceProxy.address, timelockDelay]) + await governanceTimelockProxy.setImplementationAndCall(governanceTimelock.address, calldata) + calldata = getCalldata('initialize', ['address', 'address', 'address'], [governanceTimelockProxy.address, stakingProxy.address, walletGuardian.address]) + await governanceProxy.setImplementationAndCall(governance.address, calldata) + + // Setting + const governanceImplementation = new ethers.Contract(governanceProxy.address, GOVERNANCE.interface, walletGuardian) + await governanceImplementation.setProposalMaxOperations(10) + await governanceImplementation.setVotingDelay(0) + await governanceImplementation.setVotingPeriod(1) + + // Stake + proposerStakingAmount = '2000000000000000000000' + await swipeToken.approve(stakingProxy.address, proposerStakingAmount) + const stakingImplementationByProposer = new ethers.Contract(stakingProxy.address, STAKING.interface, proposer) + await stakingImplementationByProposer.stake(proposerStakingAmount) + voterStakingAmount = '1000000000000000000000' + await swipeToken.transfer(voter.address, voterStakingAmount) + await swipeToken.connect(voter).approve(stakingProxy.address, voterStakingAmount) + const stakingImplementationByVoter = new ethers.Contract(stakingProxy.address, STAKING.interface, voter) + await stakingImplementationByVoter.stake(voterStakingAmount) + + // Authorize staking ownership transfer to governance timelock + await stakingProxy.authorizeOwnershipTransfer(governanceTimelockProxy.address) + const stakingImplementation = new ethers.Contract(stakingProxy.address, STAKING.interface, walletGuardian) + await stakingImplementation.authorizeGuardianshipTransfer(governanceTimelockProxy.address) + + // Authorize swipe cards ownership transfer to governance timelock + await swipeCardsProxy.authorizeOwnershipTransfer(governanceTimelockProxy.address) + const swipeCardsImplementation = new ethers.Contract(swipeCardsProxy.address, SWIPECARDS.interface, walletGuardian) + await swipeCardsImplementation.authorizeGuardianshipTransfer(governanceTimelockProxy.address) + + // Get config + votingDelay = await governanceImplementation._votingDelay() + votingPeriod = await governanceImplementation._votingPeriod() + + // Execute SIP-1 + await fnSip1() + }) + + const fnSip1 = async () => { + const stakingImplementation = new ethers.Contract(stakingProxy.address, STAKINGV2.interface, proposer) + const rewardCycle = await stakingImplementation._rewardCycle() + const rewardAmount = await stakingImplementation._rewardAmount() + const rewardPendingPeriod = '604800' + + const proposalDescription = '# SIP-1' + + // 0. Assume staking ownership + // 1. Assume staking guardianship + // 2. Upgrade staking to v2 + // 3. Set reward policy + const targets = [ + stakingProxy.address, + stakingProxy.address, + stakingProxy.address, + stakingProxy.address + ] + const values = [ + '0', + '0', + '0', + '0' + ] + const signatures = [ + 'assumeOwnership()', + 'assumeGuardianship()', + 'setImplementation(address)', + 'setRewardPolicy(uint256,uint256,uint256)' + ] + const calldatas = [ + encodeParameters([], []), + encodeParameters([], []), + encodeParameters(['address'], [stakingV2.address]), + encodeParameters(['uint256', 'uint256', 'uint256'], [rewardCycle, rewardAmount, rewardPendingPeriod]) + ] + + const governanceImplementationByProposer = new ethers.Contract(governanceProxy.address, GOVERNANCE.interface, proposer) + await governanceImplementationByProposer.propose(targets, values, signatures, calldatas, proposalDescription) + + const governanceImplementationByVoter = new ethers.Contract(governanceProxy.address, GOVERNANCE.interface, voter) + await governanceImplementationByVoter.castVote('1', true) + + await governanceImplementationByProposer.queue('1') + + await timeTravel(provider.provider, timelockDelay) + await governanceImplementationByProposer.execute('1') + } + + const fnPropose = async () => { + const proposalDescription = '# SIP-3' + + // 0. Assume swipe cards ownership + // 1. Assume swipe cards guardianship + // 2. Add Swipe Saffron card + // 3. Add Swipe Sky card + // 4. Add Swipe Steel card + // 5. Add Swipe Slate card + const targets = [ + swipeCardsProxy.address, + swipeCardsProxy.address + ] + const values = [ + '0', + '0' + ] + const signatures = [ + 'assumeOwnership()', + 'assumeGuardianship()' + ] + const calldatas = [ + encodeParameters([], []), + encodeParameters([], []) + ] + swipeCardList.forEach(card => { + targets.push(swipeCardsProxy.address) + values.push('0') + signatures.push('registerCard(string,uint256,uint256,string,string)') + calldatas.push(encodeParameters(['string', 'uint256', 'uint256', 'string', 'string'], [ + card.cardName, + card.lockUp, + card.lockUpTime, + card.fee, + card.feeSplitPercentage + ])) + }) + + const currentBlock = await provider.getBlock(await provider.getBlockNumber()) + const governanceImplementation = new ethers.Contract(governanceProxy.address, GOVERNANCE.interface, proposer) + await expect(governanceImplementation.propose(targets, values, signatures, calldatas, proposalDescription)).to.emit(governanceImplementation, 'ProposalCreation').withArgs('2', proposer.address, targets, values, signatures, calldatas, currentBlock.number + 1 + Number(votingDelay), currentBlock.number + 1 + Number(votingDelay) + Number(votingPeriod), proposalDescription) + } + + it('Propose', async () => { + await fnPropose() + }) + + const fnVote = async () => { + const governanceImplementation = new ethers.Contract(governanceProxy.address, GOVERNANCE.interface, voter) + await expect(governanceImplementation.castVote('2', true)).to.emit(governanceImplementation, 'Vote').withArgs(voter.address, '2', true, voterStakingAmount) + } + + it('Vote', async () => { + await fnPropose() + await fnVote() + }) + + const fnQueue = async () => { + const governanceImplementation = new ethers.Contract(governanceProxy.address, GOVERNANCE.interface, proposer) + await governanceImplementation.queue('2') + const currentBlock = await provider.getBlock(await provider.getBlockNumber()) + const proposal = await governanceImplementation.getProposal('2') + expect(proposal.eta).to.be.equal(currentBlock.timestamp + timelockDelay) + } + + it('Queue', async () => { + await fnPropose() + await fnVote() + await fnQueue() + }) + + const fnExecute = async () => { + await timeTravel(provider.provider, timelockDelay) + const governanceImplementation = new ethers.Contract(governanceProxy.address, GOVERNANCE.interface, proposer) + await expect(governanceImplementation.execute('2')).to.emit(governanceImplementation, 'ProposalExecution').withArgs('2') + } + + it('Execute', async () => { + await fnPropose() + await fnVote() + await fnQueue() + await fnExecute() + }) + + const fnCheck = async () => { + const swipeCardsImplementation = new ethers.Contract(swipeCardsProxy.address, SWIPECARDS.interface, proposer) + + const cardCount = await swipeCardsImplementation._cardCount() + expect(cardCount).to.be.equal(swipeCardList.length) + for (let i = 0; i < swipeCardList.length; i++) { + const cardData = swipeCardList[i] + const card = await swipeCardsImplementation._cards(i + 1) + expect(card.cardId).to.be.equal(i + 1) + expect(card.cardName).to.be.equal(cardData.cardName) + expect(card.lockUp).to.be.equal(cardData.lockUp) + expect(card.lockUpTime).to.be.equal(cardData.lockUpTime) + expect(card.fee).to.be.equal(cardData.fee) + expect(card.feeSplitPercentage).to.be.equal(cardData.feeSplitPercentage) + } + } + + it('Check', async () => { + await fnPropose() + await fnVote() + await fnQueue() + await fnExecute() + await fnCheck() + }) +}) \ No newline at end of file diff --git a/test/StakingV3Test.js b/test/StakingV3Test.js index 382d8e9..69ebe1e 100755 --- a/test/StakingV3Test.js +++ b/test/StakingV3Test.js @@ -8,7 +8,7 @@ use(solidity) const getCalldata = require('./helpers/getCalldata') const mineBlocks = require('./helpers/mineBlocks') -const LOCALSXPTOKEN = require("../build/LocalSXPToken") +const SXPTOKEN = require("../build/SwipeToken") const PROXY = require('../build/StakingProxy') const STAKINGV2 = require('../build/StakingV2') const STAKINGV3 = require('../build/StakingV3') @@ -16,13 +16,13 @@ const STAKINGV3 = require('../build/StakingV3') describe('StakingV3 Tests', () => { const provider = new MockProvider({ total_accounts: 5 }) const [walletGuardian, walletNewGuardian, walletRewardProvider, walletNewRewardProvider, tokenHolder] = provider.getWallets() - let localSxpToken + let sxpToken let proxy let stakingV2 let stakingV3 beforeEach(async () => { - localSxpToken = await deployContract(tokenHolder, LOCALSXPTOKEN, []) + sxpToken = await deployContract(tokenHolder, SXPTOKEN, []) proxy = await deployContract(walletGuardian, PROXY, []) stakingV2 = await deployContract(walletGuardian, STAKINGV2, []) stakingV3 = await deployContract(walletGuardian, STAKINGV3, []) @@ -30,7 +30,7 @@ describe('StakingV3 Tests', () => { describe('Upgrade', () => { beforeEach(async () => { - const calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, localSxpToken.address, walletRewardProvider.address]) + const calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, sxpToken.address, walletRewardProvider.address]) await proxy.setImplementationAndCall(stakingV2.address, calldata) }) @@ -49,34 +49,34 @@ describe('StakingV3 Tests', () => { await expect(proxy.setImplementationAndCall(stakingV3.address, calldata)).to.be.reverted const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, walletGuardian) expect(await implementation._guardian()).to.be.equal(walletGuardian.address) - expect(await implementation._sxpTokenAddress()).to.be.equal(localSxpToken.address) + expect(await implementation._sxpTokenAddress()).to.be.equal(sxpToken.address) expect(await implementation._rewardProvider()).to.be.equal(walletRewardProvider.address) }) it('Storage is saved after upgrade', async () => { const implementationOld = new ethers.Contract(proxy.address, STAKINGV2.interface, walletGuardian) expect(await implementationOld._guardian()).to.be.equal(walletGuardian.address) - expect(await implementationOld._sxpTokenAddress()).to.be.equal(localSxpToken.address) + expect(await implementationOld._sxpTokenAddress()).to.be.equal(sxpToken.address) await proxy.setImplementation(stakingV3.address) expect(await proxy.getImplementation()).to.be.equal(stakingV3.address) const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, walletGuardian) expect(await implementation._guardian()).to.be.equal(walletGuardian.address) - expect(await implementation._sxpTokenAddress()).to.be.equal(localSxpToken.address) + expect(await implementation._sxpTokenAddress()).to.be.equal(sxpToken.address) expect(await implementation._rewardPendingPeriod()).to.be.equal('86400') }) it('Storage with new updates after upgrade', async () => { const implementationOld = new ethers.Contract(proxy.address, STAKINGV2.interface, walletGuardian) expect(await implementationOld._guardian()).to.be.equal(walletGuardian.address) - expect(await implementationOld._sxpTokenAddress()).to.be.equal(localSxpToken.address) + expect(await implementationOld._sxpTokenAddress()).to.be.equal(sxpToken.address) await proxy.setImplementation(stakingV3.address) expect(await proxy.getImplementation()).to.be.equal(stakingV3.address) const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, walletGuardian) expect(await implementation._guardian()).to.be.equal(walletGuardian.address) - expect(await implementation._sxpTokenAddress()).to.be.equal(localSxpToken.address) + expect(await implementation._sxpTokenAddress()).to.be.equal(sxpToken.address) expect(await implementation._rewardPendingPeriod()).to.be.equal('86400') await implementation.setRewardPolicy('3600', '50000000000000000000000', '604800') @@ -94,7 +94,7 @@ describe('StakingV3 Tests', () => { }) it('Get stakingV3 contract name', async () => { - const calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, localSxpToken.address, walletRewardProvider.address]) + const calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, sxpToken.address, walletRewardProvider.address]) await proxy.setImplementationAndCall(stakingV3.address, calldata) const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, walletGuardian) expect(await implementation.name()).to.be.equal('Swipe Staking Proxy') @@ -103,7 +103,7 @@ describe('StakingV3 Tests', () => { describe('Settings', () => { beforeEach(async () => { - const calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, localSxpToken.address, walletRewardProvider.address]) + const calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, sxpToken.address, walletRewardProvider.address]) await proxy.setImplementationAndCall(stakingV3.address, calldata) }) @@ -186,31 +186,31 @@ describe('StakingV3 Tests', () => { describe('Reward Pool', () => { beforeEach(async () => { - const calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, localSxpToken.address, walletRewardProvider.address]) + const calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, sxpToken.address, walletRewardProvider.address]) await proxy.setImplementationAndCall(stakingV3.address, calldata) }) it('Deposit SXP by wrong reward provider', async () => { const amount = '1000000000000000000000' - await localSxpToken.transfer(walletGuardian.address, amount) - await localSxpToken.connect(walletGuardian).approve(proxy.address, amount) + await sxpToken.transfer(walletGuardian.address, amount) + await sxpToken.connect(walletGuardian).approve(proxy.address, amount) const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, walletGuardian) - const beforeBalance = await localSxpToken.balanceOf(walletGuardian.address) + const beforeBalance = await sxpToken.balanceOf(walletGuardian.address) expect(beforeBalance).to.be.equal(amount) await expect(implementation.depositRewardPool(amount)).to.be.reverted - const afterBalance = await localSxpToken.balanceOf(walletGuardian.address) + const afterBalance = await sxpToken.balanceOf(walletGuardian.address) expect(afterBalance).to.be.equal(amount) }) it('Deposit SXP', async () => { const amount = '1000000000000000000000' - await localSxpToken.transfer(walletRewardProvider.address, amount) - await localSxpToken.connect(walletRewardProvider).approve(proxy.address, amount) + await sxpToken.transfer(walletRewardProvider.address, amount) + await sxpToken.connect(walletRewardProvider).approve(proxy.address, amount) const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, walletRewardProvider) const beforeRewardPoolAmount = await implementation._rewardPoolAmount() expect(beforeRewardPoolAmount).to.be.equal('0') await expect(implementation.depositRewardPool(amount)).to.emit(implementation, 'DepositRewardPool').withArgs(walletRewardProvider.address, amount) - const afterBalance = await localSxpToken.balanceOf(proxy.address) + const afterBalance = await sxpToken.balanceOf(proxy.address) expect(afterBalance).to.be.equal(amount) const afterRewardPoolAmount = await implementation._rewardPoolAmount() expect(afterRewardPoolAmount).to.be.equal(amount) @@ -218,52 +218,52 @@ describe('StakingV3 Tests', () => { it('Withdraw SXP by wrong reward provider', async () => { const depositAmount = '1000000000000000000000' - await localSxpToken.transfer(walletRewardProvider.address, depositAmount) - await localSxpToken.connect(walletRewardProvider).approve(proxy.address, depositAmount) + await sxpToken.transfer(walletRewardProvider.address, depositAmount) + await sxpToken.connect(walletRewardProvider).approve(proxy.address, depositAmount) const implementationWithRewardProvider = new ethers.Contract(proxy.address, STAKINGV3.interface, walletRewardProvider) await implementationWithRewardProvider.depositRewardPool(depositAmount) const amount = '300000000000000000000' const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, walletGuardian) - const beforeBalance = await localSxpToken.balanceOf(proxy.address) + const beforeBalance = await sxpToken.balanceOf(proxy.address) expect(beforeBalance).to.be.equal(depositAmount) await expect(implementation.withdrawRewardPool(amount)).to.be.reverted - const afterBalance = await localSxpToken.balanceOf(proxy.address) + const afterBalance = await sxpToken.balanceOf(proxy.address) expect(afterBalance).to.be.equal(depositAmount) expect(await implementation._rewardPoolAmount()).to.be.equal(depositAmount) }) it('Withdraw SXP', async () => { const depositAmount = '1000000000000000000000' - await localSxpToken.transfer(walletRewardProvider.address, depositAmount) - await localSxpToken.connect(walletRewardProvider).approve(proxy.address, depositAmount) + await sxpToken.transfer(walletRewardProvider.address, depositAmount) + await sxpToken.connect(walletRewardProvider).approve(proxy.address, depositAmount) const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, walletRewardProvider) await implementation.depositRewardPool(depositAmount) const amount = '300000000000000000000' const remainAmount = '700000000000000000000' - const beforeRewardProviderBalance = await localSxpToken.balanceOf(walletRewardProvider.address) + const beforeRewardProviderBalance = await sxpToken.balanceOf(walletRewardProvider.address) expect(beforeRewardProviderBalance).to.be.equal('0') await expect(implementation.withdrawRewardPool(amount)).to.emit(implementation, 'WithdrawRewardPool').withArgs(walletRewardProvider.address, amount) - const afterBalance = await localSxpToken.balanceOf(proxy.address) + const afterBalance = await sxpToken.balanceOf(proxy.address) expect(afterBalance).to.be.equal(remainAmount) const afterRewardPoolAmount = await implementation._rewardPoolAmount() expect(afterRewardPoolAmount).to.be.equal(remainAmount) - const afterRewardProviderBalance = await localSxpToken.balanceOf(walletRewardProvider.address) + const afterRewardProviderBalance = await sxpToken.balanceOf(walletRewardProvider.address) expect(afterRewardProviderBalance).to.be.equal(beforeRewardProviderBalance.add(amount)) }) }) describe('Stake', () => { beforeEach(async () => { - const calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, localSxpToken.address, walletRewardProvider.address]) + const calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, sxpToken.address, walletRewardProvider.address]) await proxy.setImplementationAndCall(stakingV3.address, calldata) }) it('Stake SXP', async () => { const amount = '1000000000000000000000' - await localSxpToken.approve(proxy.address, amount) - const beforeBalance = await localSxpToken.balanceOf(proxy.address) + await sxpToken.approve(proxy.address, amount) + const beforeBalance = await sxpToken.balanceOf(proxy.address) expect(beforeBalance).to.be.equal('0') const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, tokenHolder) const beforeTotalStaked = await implementation._totalStaked() @@ -271,7 +271,7 @@ describe('StakingV3 Tests', () => { const beforeStaked = await implementation.getStakedAmount(tokenHolder.address) expect(beforeStaked).to.be.equal('0') await expect(implementation.stake(amount)).to.emit(implementation, 'Stake').withArgs(tokenHolder.address, amount) - const afterBalance = await localSxpToken.balanceOf(proxy.address) + const afterBalance = await sxpToken.balanceOf(proxy.address) expect(afterBalance).to.be.equal(amount) const afterTotalStaked = await implementation._totalStaked() expect(afterTotalStaked).to.be.equal(amount) @@ -281,16 +281,16 @@ describe('StakingV3 Tests', () => { it('Withdraw SXP by wrong staker', async () => { const stakeAmount = '1000000000000000000000' - await localSxpToken.approve(proxy.address, stakeAmount) + await sxpToken.approve(proxy.address, stakeAmount) const implementationWithTokenHolder = new ethers.Contract(proxy.address, STAKINGV3.interface, tokenHolder) await implementationWithTokenHolder.stake(stakeAmount) const amount = '300000000000000000000' const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, walletGuardian) - const beforeWithdrawerBalance = await localSxpToken.balanceOf(walletGuardian.address) + const beforeWithdrawerBalance = await sxpToken.balanceOf(walletGuardian.address) expect(beforeWithdrawerBalance).to.be.equal('0') await expect(implementation.withdraw(amount)).to.be.reverted - const afterBalance = await localSxpToken.balanceOf(proxy.address) + const afterBalance = await sxpToken.balanceOf(proxy.address) expect(afterBalance).to.be.equal(stakeAmount) const afterTotalStaked = await implementation._totalStaked() expect(afterTotalStaked).to.be.equal(stakeAmount) @@ -298,21 +298,21 @@ describe('StakingV3 Tests', () => { it('Withdraw SXP', async () => { const stakeAmount = '1000000000000000000000' - await localSxpToken.approve(proxy.address, stakeAmount) + await sxpToken.approve(proxy.address, stakeAmount) const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, tokenHolder) await implementation.stake(stakeAmount) const amount = '300000000000000000000' const remainAmount = '700000000000000000000' - const beforeHolderBalance = await localSxpToken.balanceOf(tokenHolder.address) + const beforeHolderBalance = await sxpToken.balanceOf(tokenHolder.address) await expect(implementation.withdraw(amount)).to.emit(implementation, 'Withdraw').withArgs(tokenHolder.address, amount) - const afterBalance = await localSxpToken.balanceOf(proxy.address) + const afterBalance = await sxpToken.balanceOf(proxy.address) expect(afterBalance).to.be.equal(remainAmount) const afterTotalStaked = await implementation._totalStaked() expect(afterTotalStaked).to.be.equal(remainAmount) const afterStaked = await implementation.getStakedAmount(tokenHolder.address) expect(afterStaked).to.be.equal(remainAmount) - const afterHolderBalance = await localSxpToken.balanceOf(tokenHolder.address) + const afterHolderBalance = await sxpToken.balanceOf(tokenHolder.address) expect(afterHolderBalance).to.be.equal(beforeHolderBalance.add(amount)) }) @@ -322,10 +322,10 @@ describe('StakingV3 Tests', () => { const implementationByGuardian = new ethers.Contract(proxy.address, STAKINGV3.interface, walletGuardian) await implementationByGuardian.setMinimumWithdrawableAge('2') - await localSxpToken.approve(proxy.address, stakeAmount) + await sxpToken.approve(proxy.address, stakeAmount) const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, tokenHolder) await implementation.stake(stakeAmount) - await localSxpToken.approve(proxy.address, stakeAmount) + await sxpToken.approve(proxy.address, stakeAmount) await implementation.stake(stakeAmount) // double stake const amount = '2000000000000000000000' @@ -338,25 +338,25 @@ describe('StakingV3 Tests', () => { const implementationByGuardian = new ethers.Contract(proxy.address, STAKINGV3.interface, walletGuardian) await implementationByGuardian.setMinimumWithdrawableAge('2') - await localSxpToken.approve(proxy.address, stakeAmount) + await sxpToken.approve(proxy.address, stakeAmount) const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, tokenHolder) await implementation.stake(stakeAmount) - await localSxpToken.approve(proxy.address, stakeAmount) + await sxpToken.approve(proxy.address, stakeAmount) await implementation.stake(stakeAmount) // double stake await mineBlocks(provider.provider, 1) const amount = '2000000000000000000000' const remainAmount = '0' - const beforeHolderBalance = await localSxpToken.balanceOf(tokenHolder.address) + const beforeHolderBalance = await sxpToken.balanceOf(tokenHolder.address) await expect(implementation.withdraw(amount)).to.emit(implementation, 'Withdraw').withArgs(tokenHolder.address, amount) - const afterBalance = await localSxpToken.balanceOf(proxy.address) + const afterBalance = await sxpToken.balanceOf(proxy.address) expect(afterBalance).to.be.equal(remainAmount) const afterTotalStaked = await implementation._totalStaked() expect(afterTotalStaked).to.be.equal(remainAmount) const afterStaked = await implementation.getStakedAmount(tokenHolder.address) expect(afterStaked).to.be.equal(remainAmount) - const afterHolderBalance = await localSxpToken.balanceOf(tokenHolder.address) + const afterHolderBalance = await sxpToken.balanceOf(tokenHolder.address) expect(afterHolderBalance).to.be.equal(beforeHolderBalance.add(amount)) }) @@ -367,7 +367,7 @@ describe('StakingV3 Tests', () => { const amountToStake = '2200000000000000000000' const stakedAmountAfterWithdraw = '2000000000000000000000' - await localSxpToken.approve(proxy.address, amountToStake) + await sxpToken.approve(proxy.address, amountToStake) const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, tokenHolder) const beforeBlockNumber = await provider.getBlockNumber() @@ -400,7 +400,7 @@ describe('StakingV3 Tests', () => { const implementationByGuardian = new ethers.Contract(proxy.address, STAKINGV3.interface, walletGuardian) await implementationByGuardian.setMinimumWithdrawableAge('1') - await localSxpToken.approve(proxy.address, amountToStake) + await sxpToken.approve(proxy.address, amountToStake) const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, tokenHolder) await implementation.stake(amount) @@ -419,12 +419,12 @@ describe('StakingV3 Tests', () => { describe('Claim Reward', () => { beforeEach(async () => { - const calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, localSxpToken.address, walletRewardProvider.address]) + const calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, sxpToken.address, walletRewardProvider.address]) await proxy.setImplementationAndCall(stakingV3.address, calldata) const amount = '1000000000000000000000' - await localSxpToken.transfer(walletRewardProvider.address, amount) - await localSxpToken.connect(walletRewardProvider).approve(proxy.address, amount) + await sxpToken.transfer(walletRewardProvider.address, amount) + await sxpToken.connect(walletRewardProvider).approve(proxy.address, amount) const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, walletRewardProvider) await implementation.depositRewardPool(amount) }) @@ -506,14 +506,14 @@ describe('StakingV3 Tests', () => { }) it('Get stakingV3 guardian', async () => { - const calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, localSxpToken.address, walletRewardProvider.address]) + const calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, sxpToken.address, walletRewardProvider.address]) await proxy.setImplementationAndCall(stakingV3.address, calldata) const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, walletGuardian) expect(await implementation._guardian()).to.be.equal(walletGuardian.address) }) it('Transfer stakingV3 guardianship to another address', async () => { - const calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, localSxpToken.address, walletRewardProvider.address]) + const calldata = getCalldata('initialize', ['address', 'address', 'address'], [walletGuardian.address, sxpToken.address, walletRewardProvider.address]) await proxy.setImplementationAndCall(stakingV3.address, calldata) const implementation = new ethers.Contract(proxy.address, STAKINGV3.interface, walletGuardian) await expect(implementation.authorizeGuardianshipTransfer(walletNewGuardian.address)).to.emit(implementation, 'GuardianshipTransferAuthorization').withArgs(walletNewGuardian.address) diff --git a/test/SwipeCardsTest.js b/test/SwipeCardsTest.js index 0e2bc03..dbb0bad 100644 --- a/test/SwipeCardsTest.js +++ b/test/SwipeCardsTest.js @@ -25,7 +25,14 @@ describe('Swipe Cards Tests', async () => { const defaultLockUpTime = 10000 const defaultFee = '0.25' const defaultFeeSplitPercentage = '5' - + + const default2CardId = 2 + const default2CardName = 'Venus' + const default2LockUp = 1300 + const default2LockUpTime = 110000 + const default2Fee = '0.95' + const default2FeeSplitPercentage = '15' + beforeEach(async() => { proxy = await deployContract(walletOwner, PROXY, []) cards = await deployContract(walletOwner, CARDS, []) @@ -50,25 +57,56 @@ describe('Swipe Cards Tests', async () => { await proxy.setImplementationAndCall(cards.address, calldata) }) - it('Register card', async () => { - const implementation = new ethers.Contract(proxy.address, CARDS.interface, votingContract) - await expect(implementation.registerCard( - defaultCardName, - defaultLockUp, - defaultLockUpTime, - defaultFee, - defaultFeeSplitPercentage)) - .to.emit(implementation, 'CardRegistration') - .withArgs( - 1, - defaultCardName, - defaultLockUp, - defaultLockUpTime, - defaultFee, - defaultFeeSplitPercentage) + describe('Register', async () => { + it('Register card', async () => { + const implementation = new ethers.Contract(proxy.address, CARDS.interface, votingContract) + await expect(implementation.registerCard( + defaultCardName, + defaultLockUp, + defaultLockUpTime, + defaultFee, + defaultFeeSplitPercentage)) + .to.emit(implementation, 'CardRegistration') + .withArgs( + defaultCardId, + defaultCardName, + defaultLockUp, + defaultLockUpTime, + defaultFee, + defaultFeeSplitPercentage) + + await expect(implementation.registerCard( + default2CardName, + default2LockUp, + default2LockUpTime, + default2Fee, + default2FeeSplitPercentage)) + .to.emit(implementation, 'CardRegistration') + .withArgs( + default2CardId, + default2CardName, + default2LockUp, + default2LockUpTime, + default2Fee, + default2FeeSplitPercentage) + + const cardCount = await implementation._cardCount() + expect(cardCount).to.be.equal(default2CardId) + }) + + it('Register card by wrong guardian', async () => { + const implementation = new ethers.Contract(proxy.address, CARDS.interface, otherWallet) + await expect(implementation.registerCard( + defaultCardName, + defaultLockUp, + defaultLockUpTime, + defaultFee, + defaultFeeSplitPercentage)) + .to.be.reverted + }) }) - describe('Swipe cards configuration', async () => { + describe('Unregister', async () => { beforeEach(async () => { const implementation = new ethers.Contract(proxy.address, CARDS.interface, votingContract) await implementation.registerCard( @@ -77,7 +115,58 @@ describe('Swipe Cards Tests', async () => { defaultLockUpTime, defaultFee, defaultFeeSplitPercentage) + await implementation.registerCard( + default2CardName, + default2LockUp, + default2LockUpTime, + default2Fee, + default2FeeSplitPercentage) + }) + + it('Unregister card', async () => { + const implementation = new ethers.Contract(proxy.address, CARDS.interface, votingContract) + await expect(implementation.unregisterCard( + defaultCardId)) + .to.emit(implementation, 'CardUnregistration') + .withArgs( + defaultCardId, + defaultCardName) + + const cardCount = await implementation._cardCount() + expect(cardCount).to.be.equal(defaultCardId) + const card = await implementation._cards(defaultCardId) + expect(card.cardId).to.be.equal(defaultCardId) + expect(card.cardName).to.be.equal(default2CardName) + expect(card.lockUp).to.be.equal(default2LockUp) + expect(card.lockUpTime).to.be.equal(default2LockUpTime) + expect(card.fee).to.be.equal(default2Fee) + expect(card.feeSplitPercentage).to.be.equal(default2FeeSplitPercentage) + }) + + it('Unregister card by wrong guardian', async () => { + const implementation = new ethers.Contract(proxy.address, CARDS.interface, otherWallet) + await expect(implementation.unregisterCard( + defaultCardId)) + .to.be.reverted }) + }) + + describe('Swipe cards configuration', async () => { + beforeEach(async () => { + const implementation = new ethers.Contract(proxy.address, CARDS.interface, votingContract) + await implementation.registerCard( + defaultCardName, + defaultLockUp, + defaultLockUpTime, + defaultFee, + defaultFeeSplitPercentage) + await implementation.registerCard( + default2CardName, + default2LockUp, + default2LockUpTime, + default2Fee, + default2FeeSplitPercentage) + }) it('Get card', async () => { const implementation = new ethers.Contract(proxy.address, CARDS.interface, votingContract) @@ -88,6 +177,14 @@ describe('Swipe Cards Tests', async () => { expect(card.lockUpTime).to.be.equal(defaultLockUpTime) expect(card.fee).to.be.equal(defaultFee) expect(card.feeSplitPercentage).to.be.equal(defaultFeeSplitPercentage) + + const card2 = await implementation._cards(default2CardId) + expect(card2.cardId).to.be.equal(default2CardId) + expect(card2.cardName).to.be.equal(default2CardName) + expect(card2.lockUp).to.be.equal(default2LockUp) + expect(card2.lockUpTime).to.be.equal(default2LockUpTime) + expect(card2.fee).to.be.equal(default2Fee) + expect(card2.feeSplitPercentage).to.be.equal(default2FeeSplitPercentage) }) it('Set card', async () => { @@ -125,7 +222,7 @@ describe('Swipe Cards Tests', async () => { }) it('Set not-registered card', async () => { - const wrongCardId = 2 + const wrongCardId = 3 const newCardName = 'SwipeMaster' const newLockUp = 200 const newLockUpTime = 20000 From c32cc0c47ac474c764a66c261b56b305a4069724 Mon Sep 17 00:00:00 2001 From: blockplus Date: Tue, 10 Nov 2020 08:38:07 -0800 Subject: [PATCH 2/3] Update readme --- Improvement Proposals/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Improvement Proposals/README.md b/Improvement Proposals/README.md index 4f25e87..3c4fb8b 100644 --- a/Improvement Proposals/README.md +++ b/Improvement Proposals/README.md @@ -7,3 +7,4 @@ Swipe issues imprevement proposals, which are listed here. ## Proposals - [SIP-1](https://github.com/SwipeWallet/Swipe-Network/tree/master/Improvement%20Proposals/SIP-1) - [SIP-2](https://github.com/SwipeWallet/Swipe-Network/tree/master/Improvement%20Proposals/SIP-2) +- [SIP-3](https://github.com/SwipeWallet/Swipe-Network/tree/master/Improvement%20Proposals/SIP-3) From 0be32ed908df9d93f806eb5344cb1e22fd998e7b Mon Sep 17 00:00:00 2001 From: blockplus Date: Wed, 11 Nov 2020 02:35:17 -0800 Subject: [PATCH 3/3] Update readme --- Improvement Proposals/SIP-3/README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Improvement Proposals/SIP-3/README.md b/Improvement Proposals/SIP-3/README.md index ea6f60c..ea3231b 100644 --- a/Improvement Proposals/SIP-3/README.md +++ b/Improvement Proposals/SIP-3/README.md @@ -3,7 +3,7 @@ ## Description This proposal is to add swipe card list into swipe cards contract. -- Transfer staking's ownership and guardianship to governance timelock contract +- Transfer swipe cards contract's ownership and guardianship to governance timelock contract - Register 4 swipe cards, Swipe Saffron, Swipe Sky, Swipe Steel, Swipe Slate ## Proposal @@ -32,7 +32,7 @@ Action4: address - Swipe Cards Proxy contract address value - 0 signature - registerCard(string,uint256,uint256,string,string) -calldata - Swipe Sky, 3000000000000000000000, 15552000, 0, 0 +calldata - Swipe Sky, 300000000000000000000, 15552000, 0, 0 Action5: address - Swipe Cards Proxy contract address @@ -50,37 +50,37 @@ calldata - Swipe Slate, 30000000000000000000000, 15552000, 0, 0 ### Ropsten ``` Action1 -address - Swipe Cards Proxy contract address +address - 0xB23Fa86E875F4276D672f600b1Fe51B24A296c1b // Swipe Cards Proxy contract address value - 0 signature - assumeOwnership() calldata - void Action2: -address - Swipe Cards Proxy contract address +address - 0xB23Fa86E875F4276D672f600b1Fe51B24A296c1b // Swipe Cards Proxy contract address value - 0 signature - assumeGuardianship() calldata - void Action3: -address - Swipe Cards Proxy contract address +address - 0xB23Fa86E875F4276D672f600b1Fe51B24A296c1b // Swipe Cards Proxy contract address value - 0 signature - registerCard(string,uint256,uint256,string,string) calldata - Swipe Saffron, 0, 0, 0, 0 Action4: -address - Swipe Cards Proxy contract address +address - 0xB23Fa86E875F4276D672f600b1Fe51B24A296c1b // Swipe Cards Proxy contract address value - 0 signature - registerCard(string,uint256,uint256,string,string) -calldata - Swipe Sky, 3000000000000000000000, 15552000, 0, 0 +calldata - Swipe Sky, 300000000000000000000, 15552000, 0, 0 Action5: -address - Swipe Cards Proxy contract address +address - 0xB23Fa86E875F4276D672f600b1Fe51B24A296c1b // Swipe Cards Proxy contract address value - 0 signature - registerCard(string,uint256,uint256,string,string) calldata - Swipe Steel, 3000000000000000000000, 15552000, 0, 0 Action6: -address - Swipe Cards Proxy contract address +address - 0xB23Fa86E875F4276D672f600b1Fe51B24A296c1b // Swipe Cards Proxy contract address value - 0 signature - registerCard(string,uint256,uint256,string,string) calldata - Swipe Slate, 30000000000000000000000, 15552000, 0, 0