Skip to content
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

Solang should not ask functions that contain address.call to be declared as view #997

Closed
LucasSte opened this issue Aug 31, 2022 · 0 comments · Fixed by #1338
Closed

Solang should not ask functions that contain address.call to be declared as view #997

LucasSte opened this issue Aug 31, 2022 · 0 comments · Fixed by #1338
Labels
bug Something isn't working

Comments

@LucasSte
Copy link
Contributor

Functions that modify the state, like the SPL-token mint_to, are not view functions, but the compiler warns that they can be declared as view.

Example:

	function mint_to(address mint, address account, address authority, uint64 amount) internal {
		bytes instr = new bytes(9);

		instr[0] = uint8(TokenInstruction.MintTo);
		instr.writeUint64LE(amount, 1);

		AccountMeta[3] metas = [
			AccountMeta({pubkey: mint, is_writable: true, is_signer: false}),
			AccountMeta({pubkey: account, is_writable: true, is_signer: false}),
			AccountMeta({pubkey: authority, is_writable: true, is_signer: true})
		];

		tokenProgramId.call{accounts: metas}(instr);
	}

Warning:

warning: function can be declared 'view'
   ┌─ /solang/solana-library/spl_token.sol:46:2
   │
46 │     function mint_to(address mint, address account, address authority, uint64 amount) internal {
   │
@LucasSte LucasSte added the bug Something isn't working label Aug 31, 2022
@LucasSte LucasSte changed the title Solang should not ask functions that contain 'address.call' to be declared as view Solang should not ask functions that contain address.call to be declared as view Mar 16, 2023
seanyoung added a commit to seanyoung/solang that referenced this issue May 29, 2023
…ult mutability

Neither option should produce a diagnostic.

Fixes hyperledger-solang#997

Signed-off-by: Sean Young <[email protected]>
seanyoung added a commit to seanyoung/solang that referenced this issue May 31, 2023
…ult mutability

Neither option should produce a diagnostic.

Fixes hyperledger-solang#997

Signed-off-by: Sean Young <[email protected]>
seanyoung added a commit to seanyoung/solang that referenced this issue Jun 1, 2023
…ult mutability

Neither option should produce a diagnostic.

Fixes hyperledger-solang#997

Signed-off-by: Sean Young <[email protected]>
seanyoung added a commit to seanyoung/solang that referenced this issue Jun 1, 2023
…ult mutability

Neither option should produce a diagnostic.

Fixes hyperledger-solang#997

Signed-off-by: Sean Young <[email protected]>
seanyoung added a commit to seanyoung/solang that referenced this issue Jun 1, 2023
…ult mutability

Neither option should produce a diagnostic.

Fixes hyperledger-solang#997

Signed-off-by: Sean Young <[email protected]>
seanyoung added a commit to seanyoung/solang that referenced this issue Jun 1, 2023
…ult mutability

Neither option should produce a diagnostic.

Fixes hyperledger-solang#997

Signed-off-by: Sean Young <[email protected]>
seanyoung added a commit to seanyoung/solang that referenced this issue Jun 1, 2023
…ult mutability

Neither option should produce a diagnostic.

Fixes hyperledger-solang#997

Signed-off-by: Sean Young <[email protected]>
seanyoung added a commit to seanyoung/solang that referenced this issue Jun 1, 2023
…ult mutability

Neither option should produce a diagnostic.

Fixes hyperledger-solang#997

Signed-off-by: Sean Young <[email protected]>
seanyoung added a commit to seanyoung/solang that referenced this issue Jun 2, 2023
…ult mutability

Neither option should produce a diagnostic.

Fixes hyperledger-solang#997

Signed-off-by: Sean Young <[email protected]>
seanyoung added a commit to seanyoung/solang that referenced this issue Jun 2, 2023
…ult mutability

Neither option should produce a diagnostic.

Fixes hyperledger-solang#997

Signed-off-by: Sean Young <[email protected]>
seanyoung added a commit to seanyoung/solang that referenced this issue Jun 15, 2023
…ult mutability

Neither option should produce a diagnostic.

Fixes hyperledger-solang#997

Signed-off-by: Sean Young <[email protected]>
seanyoung added a commit to seanyoung/solang that referenced this issue Jun 15, 2023
…ult mutability

Neither option should produce a diagnostic.

Fixes hyperledger-solang#997

Signed-off-by: Sean Young <[email protected]>
seanyoung added a commit that referenced this issue Jun 16, 2023
…ult mutability (#1338)

Neither option should produce a diagnostic.

Fixes #997

Signed-off-by: Sean Young <[email protected]>
stainless-app bot pushed a commit to 2lambda123/hyperledger-solang that referenced this issue Feb 4, 2024
…ult mutability (#1338)

Neither option should produce a diagnostic.

Fixes hyperledger-solang/solang#997

Signed-off-by: Sean Young <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant