solana_base_versus_external.sol 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // RUN: --target solana --emit cfg
  2. import 'solana';
  3. @program_id("6qEm4QUJGFvqKNJGjTrAEiFhbVBY4ashpBjDHEFvEUmW")
  4. contract Foo {
  5. uint b;
  6. constructor(uint a) {
  7. b = a;
  8. }
  9. function get_b(address id) public returns (uint) {
  10. return b;
  11. }
  12. function get_b2(address id) public returns (uint) {
  13. return b;
  14. }
  15. }
  16. @program_id("9VLAw4to9KsX9DvyzJUJwfUeQCouX79szENj78sZKiqA")
  17. contract Other is Foo {
  18. uint c;
  19. constructor(uint d) Foo(d) {
  20. c = d;
  21. }
  22. // BEGIN-CHECK: Other::Other::function::call_foo__address
  23. function call_foo(address id) external {
  24. // internal calls
  25. Foo.get_b(id);
  26. // CHECK: call Other::Foo::function::get_b__address (arg #0)
  27. Foo.get_b2({id: id});
  28. // CHECK: call Other::Foo::function::get_b2__address (arg #0)
  29. }
  30. // BEGIN-CHECK: Other::Other::function::call_foo2__address_address
  31. function call_foo2(address id, address acc) external {
  32. AccountMeta[1] meta = [
  33. AccountMeta({pubkey: acc, is_writable: false, is_signer: false})
  34. ];
  35. // external calls
  36. Foo.get_b{program_id: id, accounts: meta}(id);
  37. // CHECK: external call::regular address:(arg #0) payload:%abi_encoded.temp.35 value:uint64 0 gas:uint64 0 accounts:%meta seeds: contract|function:(0, 3) flags:
  38. Foo.get_b2{program_id: id, accounts: meta}(id);
  39. // CHECK: external call::regular address:(arg #0) payload:%abi_encoded.temp.36 value:uint64 0 gas:uint64 0 accounts:%meta seeds: contract|function:(0, 4) flags:
  40. }
  41. }