constructor_with_metas.sol 1007 B

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