add contract for shard

This commit is contained in:
CounterFire2023 2023-12-25 11:30:40 +08:00
parent 6ddbd8017e
commit 2de2605e9b
5 changed files with 34 additions and 29 deletions

View File

@ -62,7 +62,6 @@ contract ShardAssembler is Ownable, TimeChecker, HasSignature, MallBase {
hero.batchMint(user, params.tokenId.asSingletonArray()); hero.batchMint(user, params.tokenId.asSingletonArray());
_useSignature(signature); _useSignature(signature);
// transfer token to this contract
IERC20(params.payToken).transferFrom(user, feeToAddress, params.tokenAmount); IERC20(params.payToken).transferFrom(user, feeToAddress, params.tokenAmount);
emit ShardAssembled(user, params.tokenId, params.payToken, params.tokenAmount); emit ShardAssembled(user, params.tokenId, params.payToken, params.tokenAmount);

View File

@ -3,126 +3,126 @@
"name": "BEBadge", "name": "BEBadge",
"type": "erc721", "type": "erc721",
"json": "assets/contracts/BEBadge.json", "json": "assets/contracts/BEBadge.json",
"address": "0x22FDaF881f724E2c9F93271a94A47725D217F77e" "address": "0x593161235c0Fa9c7b65050C87701761e0Def0d80"
}, },
{ {
"name": "BEMultiSigWallet", "name": "BEMultiSigWallet",
"type": "logic", "type": "logic",
"json": "assets/contracts/BEMultiSigWallet.json", "json": "assets/contracts/BEMultiSigWallet.json",
"address": "0xfeD8697704b43C630f97F5178f6A89D2567E578b" "address": "0x6C1E6cD9e00946FE5DF95e032d979c4e29126d9D"
}, },
{ {
"name": "NftDistributor", "name": "NftDistributor",
"type": "logic", "type": "logic",
"json": "assets/contracts/NftDistributor.json", "json": "assets/contracts/NftDistributor.json",
"address": "0x579fa19F24e3Be4cC311541B027030C793A25ee4" "address": "0x56c721a710CE4689e8d0342581241fB9E8e4eF13"
}, },
{ {
"name": "CEC", "name": "CEC",
"type": "erc20", "type": "erc20",
"json": "assets/contracts/FT.json", "json": "assets/contracts/FT.json",
"address": "0x31F0ed70DBAA0Ec06Bb215218FF40ab0e95b7B47" "address": "0x7f7202BBA83D9492486F4483AAA47F5084d6a106"
}, },
{ {
"name": "CEG", "name": "CEG",
"type": "erc20", "type": "erc20",
"json": "assets/contracts/FT.json", "json": "assets/contracts/FT.json",
"address": "0x16d3e5B6C5d4BF1d4494592c3bA13882Ff5Df3b7" "address": "0x12990e7b5DFBdf2517Ae3C98A4E4F7F49AC198CD"
}, },
{ {
"name": "BEUSDC", "name": "BEUSDC",
"type": "erc20", "type": "erc20",
"json": "assets/contracts/FT.json", "json": "assets/contracts/FT.json",
"address": "0xd573a6D24dB1625504Ea380FeC911C48Fc649Ae3" "address": "0x7eAF1AF1d270EAdee93949393a045869319a7FCC"
}, },
{ {
"name": "BEUSDT", "name": "BEUSDT",
"type": "erc20", "type": "erc20",
"json": "assets/contracts/FT.json", "json": "assets/contracts/FT.json",
"address": "0x7d2B633c78e4d52807a6615CB6092BA1173Bd88A" "address": "0x3E72de30b9060adcD17e65eb33D1088A96059b73"
}, },
{ {
"name": "HERO", "name": "HERO",
"type": "erc721", "type": "erc721",
"json": "assets/contracts/NFT.json", "json": "assets/contracts/NFT.json",
"address": "0xbaFCbd63E5C21997138b2F20BD66180E5523Dc2f" "address": "0x641dE351a05B2beD8be2790A49Ec7Dc70e16ef5C"
}, },
{ {
"name": "PLANET", "name": "PLANET",
"type": "erc721", "type": "erc721",
"json": "assets/contracts/NFT.json", "json": "assets/contracts/NFT.json",
"address": "0xF7f7bedAb92e44e88620654df63f7D409743a07e" "address": "0x0C4a182E5600A2E48D819b3c13cBBc95eA79859F"
}, },
{ {
"name": "TestHERO", "name": "TestHERO",
"type": "erc721", "type": "erc721",
"json": "assets/contracts/NFT.json", "json": "assets/contracts/NFT.json",
"address": "0x2eFD5d3Ed0E2fd7fe17EC997110274f8cA968649" "address": "0xd7403aB3bd6B4500f639c535191B11Ff76d9aA72"
}, },
{ {
"name": "UserMinterFactory", "name": "UserMinterFactory",
"type": "logic", "type": "logic",
"json": "assets/contracts/UserMinterFactory.json", "json": "assets/contracts/UserMinterFactory.json",
"address": "0xa56f6d75EE57a5969C0c05C19C064a4bCd7706C9" "address": "0x2169c87E7F4C2b48BEC5CD2F15b82B1369b9A37D"
}, },
{ {
"name": "BENftMarket", "name": "BENftMarket",
"type": "logic", "type": "logic",
"json": "assets/contracts/BENftMarket.json", "json": "assets/contracts/BENftMarket.json",
"address": "0xC5f17FBe7C9cD403F8b3799615F7550634422304" "address": "0x9b3a5b43C8531E769531F98492544DbFCb2B12e5"
}, },
{ {
"name": "BENftMall", "name": "BENftMall",
"type": "logic", "type": "logic",
"json": "assets/contracts/BENftMall.json", "json": "assets/contracts/BENftMall.json",
"address": "0xC5145E44b8CD72B583DEc18A1fb3b3B2510863F3" "address": "0xaB5be652418D3bE53F4700c64C2e3cE0B1F24BC2"
}, },
{ {
"name": "BETokenMall", "name": "BETokenMall",
"type": "logic", "type": "logic",
"json": "assets/contracts/BETokenMall.json", "json": "assets/contracts/BETokenMall.json",
"address": "0xE3DC8F2c717C4cCb01913916a5274d1923d3C284" "address": "0xFDA19e10995D0F53905Edc12407f059809B1Ec55"
}, },
{ {
"name": "GameItemMarket", "name": "GameItemMarket",
"type": "logic", "type": "logic",
"json": "assets/contracts/GameItemMarket.json", "json": "assets/contracts/GameItemMarket.json",
"address": "0xF7f49D559b8544cda8F7a2825e3d22daab8Eb976" "address": "0x66adEa9eFc0520dd2b235692e815983c41064987"
}, },
{ {
"name": "GameItemMall", "name": "GameItemMall",
"type": "logic", "type": "logic",
"json": "assets/contracts/GameItemMall.json", "json": "assets/contracts/GameItemMall.json",
"address": "0x6ca9e3df42C6A5e9F62385436A88b5b237Ec0bac" "address": "0xf1A0b8b92a41C21Dd001eaC97c7eD87E7b943342"
}, },
{ {
"name": "Gacha", "name": "Gacha",
"type": "erc721", "type": "erc721",
"json": "assets/contracts/BEBadge.json", "json": "assets/contracts/BEBadge.json",
"address": "0x078276663CDAC67aF17f88A749C2aD03690176A2" "address": "0xDFdA43A126FD0F5A693994dDc38a59588e4Bd98d"
}, },
{ {
"name": "ClaimGachaFactory", "name": "ClaimGachaFactory",
"type": "logic", "type": "logic",
"json": "assets/contracts/ClaimBoxFactory.json", "json": "assets/contracts/ClaimBoxFactory.json",
"address": "0x566aD19DbC9C1f2aED80DA37d9cca40Dc31A9f9A" "address": "0xC943a8FD378B1892dE1062dEF0d004AAaAC3bBB4"
}, },
{ {
"name": "JSONMetadata", "name": "JSONMetadata",
"type": "logic", "type": "logic",
"json": "assets/contracts/JSONMetadata.json", "json": "assets/contracts/JSONMetadata.json",
"address": "0xa779f75B02b66731B60be0f01EE60Cbd3ec939F3" "address": "0xcF3773Dc743cC4314127842C9C40dd7E7315bAF8"
}, },
{ {
"name": "ERC721Staking", "name": "ERC721Staking",
"type": "logic", "type": "logic",
"json": "assets/contracts/ERC721Staking.json", "json": "assets/contracts/ERC721Staking.json",
"address": "0xc1CF4029ba66950EdC24E62acF276dBFbdEE3358" "address": "0xeB601449167b8DB327ee5529cbf52B692Bf4DCd5"
}, },
{ {
"name": "EvolveProxy", "name": "EvolveProxy",
"type": "logic", "type": "logic",
"json": "assets/contracts/EvolveProxy.json", "json": "assets/contracts/EvolveProxy.json",
"address": "0x38A716384689150B47cB63Ade766a9fdf6C9BF18" "address": "0x7eD68250Efe1028fc64Fe2Ef4c67b6474D172051"
} }
] ]

View File

@ -123,6 +123,6 @@
"name": "EvolveProxy", "name": "EvolveProxy",
"type": "logic", "type": "logic",
"json": "assets/contracts/EvolveProxy.json", "json": "assets/contracts/EvolveProxy.json",
"address": "0x988B6CFBf3332FF98FFBdED665b1F53a61f92612" "address": "0x2c5f3c004878923f55A2a255F89Fe29393177509"
} }
] ]

View File

@ -14,6 +14,7 @@
"deploy:22": "truffle migrate --network lan22 --compile-none", "deploy:22": "truffle migrate --network lan22 --compile-none",
"deploy:bsctest": "truffle migrate --network bsc_testnet --compile-none", "deploy:bsctest": "truffle migrate --network bsc_testnet --compile-none",
"deploy:kcctest": "truffle migrate --network kcc_testnet --compile-none", "deploy:kcctest": "truffle migrate --network kcc_testnet --compile-none",
"deploy:combo_testnet": "truffle migrate --network combo_testnet --compile-none",
"deploy:polygon_testnet": "truffle migrate --network polygon_testnet --compile-none", "deploy:polygon_testnet": "truffle migrate --network polygon_testnet --compile-none",
"deploy:dev:arbitrum_testnet": "DEPLOY_ENV=dev truffle migrate --network arbitrum_testnet --compile-none", "deploy:dev:arbitrum_testnet": "DEPLOY_ENV=dev truffle migrate --network arbitrum_testnet --compile-none",
"deploy:dev:zk_testnet": "DEPLOY_ENV=dev truffle migrate --network zk_testnet --compile-none", "deploy:dev:zk_testnet": "DEPLOY_ENV=dev truffle migrate --network zk_testnet --compile-none",

View File

@ -2,6 +2,8 @@ const ShardAssembler = artifacts.require("ShardAssembler");
const NFT = artifacts.require("NFT"); const NFT = artifacts.require("NFT");
const Shard = artifacts.require("BEShard"); const Shard = artifacts.require("BEShard");
const FT = artifacts.require("FT"); const FT = artifacts.require("FT");
const { BN,expectEvent } = require("@openzeppelin/test-helpers");
const { expect } = require("chai");
contract("ShardAssembler", (accounts) => { contract("ShardAssembler", (accounts) => {
const admin = accounts[0]; const admin = accounts[0];
@ -58,19 +60,22 @@ contract("ShardAssembler", (accounts) => {
signature = signature.replace(/00$/, "1b").replace(/01$/, "1c"); signature = signature.replace(/00$/, "1b").replace(/01$/, "1c");
await payToken.approve(shardAssembler.address, tokenAmount, { from: user }); await payToken.approve(shardAssembler.address, tokenAmount, { from: user });
await shard.setApprovalForAll(shardAssembler.address, true, { from: user }); await shard.setApprovalForAll(shardAssembler.address, true, { from: user });
await shardAssembler.assembleShard( const receipt = await shardAssembler.assembleShard(
[tokenId, payToken.address, tokenAmount, startTime, saltNonce], [tokenId, payToken.address, tokenAmount, startTime, saltNonce],
ids, ids,
amounts, amounts,
signature, signature,
{ from: user } { from: user }
); );
expectEvent(receipt, "ShardAssembled", {
to: user,
tokenId: tokenId,
payToken: payToken.address,
tokenAmount: new BN(tokenAmount),
});
// Get the user's hero balance // Get the user's hero balance
const userHeroBalance = await hero.balanceOf(user); const userHeroBalance = await hero.balanceOf(user);
expect(userHeroBalance).to.be.bignumber.equal(new BN(1));
// Assert that the user's hero balance has increased by 1
assert.equal(userHeroBalance, 1, "User's hero balance is incorrect");
}); });
// Add more test cases as needed // Add more test cases as needed