-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid repeated global strings #1377
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
// RUN: --target solana --emit llvm-ir | ||
// READ: ServiceRegistrySolana.ll | ||
|
||
|
||
// BEGIN-CHECK: "math overflow,\0A" | ||
// NOT-CHECK: "math overflow,\0A" | ||
|
||
import "solana"; | ||
contract ServiceRegistrySolana { | ||
struct Service { | ||
address serviceOwner; | ||
uint64 securityDeposit; | ||
address multisig; | ||
bytes32 configHash; | ||
uint32 threshold; | ||
uint32 maxNumAgentInstances; | ||
uint32 numAgentInstances; | ||
uint8 state; | ||
uint32[] agentIds; | ||
uint32[] slots; | ||
uint64[] bonds; | ||
address[] operators; | ||
address[] agentInstances; | ||
uint32[] agentIdForAgentInstances; | ||
} | ||
|
||
address public owner; | ||
address public escrow; | ||
string public baseURI; | ||
uint32 public totalSupply; | ||
string public constant CID_PREFIX = "f01701220"; | ||
uint64 public slashedFunds; | ||
address public drainer; | ||
string public constant VERSION = "1.0.0"; | ||
mapping(bytes32 => uint64) public mapOperatorAndServiceIdOperatorBalances; | ||
mapping (address => address) public mapAgentInstanceOperators; | ||
mapping (address => bool) public mapMultisigs; | ||
Service public services; | ||
|
||
|
||
|
||
constructor(address a, string memory _baseURI) | ||
{ | ||
|
||
} | ||
|
||
function changeOwner(address newOwner) external { | ||
|
||
} | ||
|
||
function changeDrainer(address newDrainer) external { | ||
|
||
} | ||
|
||
function transfer(uint32 serviceId, address newServiceOwner) public { | ||
|
||
} | ||
|
||
function create( | ||
address serviceOwner, | ||
bytes32 configHash, | ||
uint32[] memory agentIds, | ||
uint32[] memory slots, | ||
uint64[] memory bonds, | ||
uint32 threshold | ||
) external returns (uint32 serviceId) | ||
{ | ||
|
||
} | ||
|
||
function update( | ||
bytes32 configHash, | ||
uint32[] memory agentIds, | ||
uint32[] memory slots, | ||
uint64[] memory bonds, | ||
uint32 threshold, | ||
uint32 serviceId | ||
) external returns (bool success) | ||
{ | ||
} | ||
|
||
function activateRegistration(uint32 serviceId) external payable returns (bool success) | ||
{ | ||
|
||
} | ||
|
||
function registerAgents( | ||
address operator, | ||
uint32 serviceId, | ||
address[] memory agentInstances, | ||
uint32[] agentIds | ||
) external payable returns (bool success) | ||
{ | ||
|
||
} | ||
|
||
function deploy( | ||
uint32 serviceId, | ||
address multisigImplementation, | ||
bytes memory data | ||
) external returns (address multisig) | ||
{ | ||
|
||
} | ||
|
||
function slash(address[] memory agentInstances, uint64[] memory amounts, uint32 serviceId) external | ||
returns (bool success) | ||
{ | ||
|
||
} | ||
|
||
function terminate(uint32 serviceId) external returns (bool success, uint64 refund) | ||
{ | ||
} | ||
|
||
function unbond(address operator, uint32 serviceId) external returns (bool success, uint64 refund) { | ||
|
||
} | ||
|
||
function getService(uint32 serviceId) external view returns (Service memory service) { | ||
|
||
} | ||
|
||
function getAgentParams(uint32 serviceId) external view | ||
returns (uint32 numAgentIds, uint32[] memory slots, uint64[] memory bonds) | ||
{ | ||
|
||
} | ||
|
||
function getAgentInstances(uint32 serviceId) external view | ||
returns (uint32 numAgentInstances, address[] memory agentInstances) | ||
{ | ||
|
||
} | ||
|
||
function getOperatorBalance(address operator, uint32 serviceId) external view returns (uint64 balance) | ||
{ | ||
} | ||
|
||
function changeMultisigPermission(address multisig, bool permission) external returns (bool success) { | ||
|
||
} | ||
|
||
function drain() external returns (uint64 amount) { | ||
|
||
} | ||
|
||
function ownerOf(uint32 id) public view returns (address addr) { | ||
|
||
} | ||
|
||
function exists() public view {} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the contract need all those empty functions for this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can shorten the contract, but I left it as it is because it used to generate 1008 definitions of
math overflow
.What is your opinion in shortening it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's not the end of the world. I'll leave that up to you. I just thought that if in the end only 1 single
math overflow
string instead of 1008 should be generated, the test code could be more to the point.