constructor_with_metas.sol 948 B

12345678910111213141516171819202122232425262728293031
  1. // RUN: --target solana --emit cfg
  2. import 'solana';
  3. contract creator {
  4. Child public c;
  5. // BEGIN-CHECK: creator::creator::function::create_child_with_meta__address_address
  6. function create_child_with_meta(address child, address payer) external {
  7. AccountMeta[2] metas = [
  8. AccountMeta({pubkey: child, is_signer: false, is_writable: false}),
  9. AccountMeta({pubkey: payer, is_signer: true, is_writable: true})
  10. ];
  11. // CHECK: constructor(no: 4) salt: value: gas:uint64 0 address: seeds: Child encoded buffer: %abi_encoded.temp.17 accounts: %metas
  12. c = new Child{accounts: metas}(payer);
  13. c.say_hello();
  14. }
  15. }
  16. @program_id("Chi1d5XD6nTAp2EyaNGqMxZzUjh6NvhXRxbGHP3D1RaT")
  17. contract Child {
  18. @payer(payer)
  19. @space(511 + 7)
  20. constructor(address payer) {
  21. print("In child constructor");
  22. }
  23. function say_hello() pure public {
  24. print("Hello there");
  25. }
  26. }