Skip to content

Commit

Permalink
small
Browse files Browse the repository at this point in the history
  • Loading branch information
yu23ki14 committed Dec 26, 2024
1 parent eb2eb1f commit fd1640f
Show file tree
Hide file tree
Showing 4 changed files with 283 additions and 49 deletions.
211 changes: 211 additions & 0 deletions pkgs/contract/.openzeppelin/sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,217 @@
]
}
}
},
"dd12bf6e75fb0acd68de953a2d3bb52bb98ef7fc45c7771ef4b96e40a51ea298": {
"address": "0x30Ee73482782dA4300C60B1DcD30b429a9C5f1eA",
"txHash": "0xb0055890b9abcbb62d1763d3fdf5d97615985dd3e6759714092a954c9840cd10",
"layout": {
"solcVersion": "0.8.24",
"storage": [
{
"label": "TOKEN_SUPPLY",
"offset": 0,
"slot": "0",
"type": "t_uint256",
"contract": "FractionToken",
"src": "contracts/fractiontoken/FractionToken.sol:15"
},
{
"label": "tokenRecipients",
"offset": 0,
"slot": "1",
"type": "t_mapping(t_uint256,t_array(t_address)dyn_storage)",
"contract": "FractionToken",
"src": "contracts/fractiontoken/FractionToken.sol:17"
},
{
"label": "hatsContract",
"offset": 0,
"slot": "2",
"type": "t_contract(IHats)17350",
"contract": "FractionToken",
"src": "contracts/fractiontoken/FractionToken.sol:19"
}
],
"types": {
"t_address": {
"label": "address",
"numberOfBytes": "20"
},
"t_bool": {
"label": "bool",
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
"label": "mapping(address => bool)",
"numberOfBytes": "32"
},
"t_mapping(t_address,t_mapping(t_address,t_bool))": {
"label": "mapping(address => mapping(address => bool))",
"numberOfBytes": "32"
},
"t_mapping(t_address,t_uint256)": {
"label": "mapping(address => uint256)",
"numberOfBytes": "32"
},
"t_mapping(t_uint256,t_mapping(t_address,t_uint256))": {
"label": "mapping(uint256 => mapping(address => uint256))",
"numberOfBytes": "32"
},
"t_mapping(t_uint256,t_uint256)": {
"label": "mapping(uint256 => uint256)",
"numberOfBytes": "32"
},
"t_string_storage": {
"label": "string",
"numberOfBytes": "32"
},
"t_struct(ERC1155Storage)166_storage": {
"label": "struct ERC1155Upgradeable.ERC1155Storage",
"members": [
{
"label": "_balances",
"type": "t_mapping(t_uint256,t_mapping(t_address,t_uint256))",
"offset": 0,
"slot": "0"
},
{
"label": "_operatorApprovals",
"type": "t_mapping(t_address,t_mapping(t_address,t_bool))",
"offset": 0,
"slot": "1"
},
{
"label": "_uri",
"type": "t_string_storage",
"offset": 0,
"slot": "2"
}
],
"numberOfBytes": "96"
},
"t_struct(ERC1155SupplyStorage)449_storage": {
"label": "struct ERC1155SupplyUpgradeable.ERC1155SupplyStorage",
"members": [
{
"label": "_totalSupply",
"type": "t_mapping(t_uint256,t_uint256)",
"offset": 0,
"slot": "0"
},
{
"label": "_totalSupplyAll",
"type": "t_uint256",
"offset": 0,
"slot": "1"
}
],
"numberOfBytes": "64"
},
"t_struct(InitializableStorage)73_storage": {
"label": "struct Initializable.InitializableStorage",
"members": [
{
"label": "_initialized",
"type": "t_uint64",
"offset": 0,
"slot": "0"
},
{
"label": "_initializing",
"type": "t_bool",
"offset": 8,
"slot": "0"
}
],
"numberOfBytes": "32"
},
"t_uint256": {
"label": "uint256",
"numberOfBytes": "32"
},
"t_uint64": {
"label": "uint64",
"numberOfBytes": "8"
},
"t_array(t_address)dyn_storage": {
"label": "address[]",
"numberOfBytes": "32"
},
"t_contract(IHats)17350": {
"label": "contract IHats",
"numberOfBytes": "20"
},
"t_mapping(t_uint256,t_array(t_address)dyn_storage)": {
"label": "mapping(uint256 => address[])",
"numberOfBytes": "32"
}
},
"namespaces": {
"erc7201:openzeppelin.storage.ERC1155Supply": [
{
"contract": "ERC1155SupplyUpgradeable",
"label": "_totalSupply",
"type": "t_mapping(t_uint256,t_uint256)",
"src": "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol:25",
"offset": 0,
"slot": "0"
},
{
"contract": "ERC1155SupplyUpgradeable",
"label": "_totalSupplyAll",
"type": "t_uint256",
"src": "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol:26",
"offset": 0,
"slot": "1"
}
],
"erc7201:openzeppelin.storage.ERC1155": [
{
"contract": "ERC1155Upgradeable",
"label": "_balances",
"type": "t_mapping(t_uint256,t_mapping(t_address,t_uint256))",
"src": "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol:27",
"offset": 0,
"slot": "0"
},
{
"contract": "ERC1155Upgradeable",
"label": "_operatorApprovals",
"type": "t_mapping(t_address,t_mapping(t_address,t_bool))",
"src": "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol:29",
"offset": 0,
"slot": "1"
},
{
"contract": "ERC1155Upgradeable",
"label": "_uri",
"type": "t_string_storage",
"src": "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol:32",
"offset": 0,
"slot": "2"
}
],
"erc7201:openzeppelin.storage.Initializable": [
{
"contract": "Initializable",
"label": "_initialized",
"type": "t_uint64",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:69",
"offset": 0,
"slot": "0"
},
{
"contract": "Initializable",
"label": "_initializing",
"type": "t_bool",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:73",
"offset": 8,
"slot": "0"
}
]
}
}
}
}
}
49 changes: 38 additions & 11 deletions pkgs/contract/test/SplitsCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ describe("CreateSplit", () => {
let address1WoreTime: bigint;
let address2WoreTime: bigint;
let address3WoreTime: bigint;
let address1_additional_woreTime: number = 500000;
let address1_additional_woreTime: number = 2592000;

let publicClient: PublicClient;

Expand Down Expand Up @@ -311,7 +311,9 @@ describe("CreateSplit", () => {

SplitsCreatorFactory = _SplitsCreatorFactory;

SplitsCreatorFactory.write.setBigBang([bigBangAddress.account?.address!]);
await SplitsCreatorFactory.write.setBigBang([
bigBangAddress.account?.address!,
]);

let txHash =
await SplitsCreatorFactory.write.createSplitCreatorDeterministic(
Expand Down Expand Up @@ -494,13 +496,25 @@ describe("CreateSplit", () => {
account: address1.account!,
}
);
await FractionToken.write.safeTransferFrom(
[
address1.account?.address!,
address3.account?.address!,
tokenId,
1000n,
"0x",
],
{
account: address1.account!,
}
);

const address1Balance = await FractionToken.read.balanceOf([
address1.account?.address!,
address1.account?.address!,
hat1_id,
]);
expect(address1Balance).to.equal(7000n);
expect(address1Balance).to.equal(6000n);

// address2のbalance
const address2Balance = await FractionToken.read.balanceOf([
Expand Down Expand Up @@ -571,7 +585,7 @@ describe("CreateSplit", () => {
}
}

expect(shareHolders.length).to.equal(4);
expect(shareHolders.length).to.equal(5);

const address1Time = endWoreTime - address1WoreTime;
const address2Time = endWoreTime - address2WoreTime;
Expand All @@ -586,7 +600,13 @@ describe("CreateSplit", () => {
address1.account?.address!,
hat1_id,
]);
expect(address1Balance).to.equal(7000n);
expect(address1Balance).to.equal(6000n);

const address3_address1Balance = await FractionToken.read.balanceOf([
address3.account?.address!,
address1.account?.address!,
hat1_id,
]);

const address4Balance = await FractionToken.read.balanceOf([
address4.account?.address!,
Expand All @@ -608,17 +628,20 @@ describe("CreateSplit", () => {
]);
expect(address3Balance).to.equal(10000n);

expect(allocations.length).to.equal(4);
expect(allocations.length).to.equal(5);
expect(allocations[0]).to.equal(
((address1Balance * 1000000n) / 20000n) * 1n * sqrtAddress1Time
);
expect(allocations[1]).to.equal(
((address4Balance * 1000000n) / 20000n) * 1n * sqrtAddress1Time
);
expect(allocations[2]).to.equal(
((address2Balance * 1000000n) / 20000n) * 1n * sqrtAddress2Time
((address3_address1Balance * 1000000n) / 20000n) * 1n * sqrtAddress1Time
);
expect(allocations[3]).to.equal(
((address2Balance * 1000000n) / 20000n) * 1n * sqrtAddress2Time
);
expect(allocations[4]).to.equal(
((address3Balance * 1000000n) / 10000n) * 2n * sqrtAddress3Time
);

Expand Down Expand Up @@ -777,11 +800,12 @@ describe("CreateSplit", () => {
allocation3,
];

expect(shareHolders.length).to.equal(4);
expect(shareHolders.length).to.equal(5);

const expectedShareHolders = [
address1.account?.address!,
address4.account?.address!,
address3.account?.address!,
address2.account?.address!,
address3.account?.address!,
];
Expand All @@ -799,12 +823,15 @@ describe("CreateSplit", () => {
expect(shareHolders[3].toLowerCase()).to.equal(
expectedShareHolders[3].toLowerCase()
);
expect(shareHolders[4].toLowerCase()).to.equal(
expectedShareHolders[4].toLowerCase()
);

expect(allocations.length).to.equal(4);
expect(allocations.length).to.equal(5);

expect(allocations[0]).to.equal(expectedAllocations[0]);
expect(allocations[1]).to.equal(expectedAllocations[1]);
expect(allocations[2]).to.equal(expectedAllocations[2]);
expect(allocations[3]).to.equal(expectedAllocations[3]);
expect(allocations[3]).to.equal(expectedAllocations[2]);
expect(allocations[4]).to.equal(expectedAllocations[3]);
});
});
7 changes: 6 additions & 1 deletion pkgs/frontend/abi/splits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,14 @@ export const SPLITS_CREATOR_ABI = [
},
{
internalType: "uint256[]",
name: "percentages",
name: "allocations",
type: "uint256[]",
},
{
internalType: "uint256",
name: "totalAllocation",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
Expand Down
Loading

0 comments on commit fd1640f

Please sign in to comment.