// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
// File: AssetRegistry.sol
contract AssetRegistry {
// assetChoices records the proportions of different output assets
// that a Union member would like to split their bribes between.
// There is a maximum of 16 available assets, although not all may be
// used. Any uint16 can be used to express the weights, which are
// meant to be normalized afterwards.
// So weights of [2, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
// and [50, 25, 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
// would be equivalent.
mapping(address => uint16[16]) public assetAllocations;
function recordAllocation(uint16[16] calldata choices) external {
assetAllocations[msg.sender] = choices;
}
function getAllocations(address[] calldata members)
external
view
returns (uint16[16][] memory)
{
uint256 n = members.length;
uint16[16][] memory allocations = new uint16[16][](n);
for (uint256 i = 0; i < n; i++) {
allocations[i] = assetAllocations[members[i]];
}
return allocations;
}
}
{
"compilationTarget": {
"AssetRegistry.sol": "AssetRegistry"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"assetAllocations","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"members","type":"address[]"}],"name":"getAllocations","outputs":[{"internalType":"uint16[16][]","name":"","type":"uint16[16][]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16[16]","name":"choices","type":"uint16[16]"}],"name":"recordAllocation","outputs":[],"stateMutability":"nonpayable","type":"function"}]