github.com/Finschia/finschia-sdk@v0.48.1/contrib/rosetta/configuration/transfer.ros (about)

     1  request_funds(1){
     2    find_account{
     3      currency = {"symbol":"stake", "decimals":0};
     4      random_account = find_balance({
     5        "minimum_balance":{
     6          "value": "0",
     7          "currency": {{currency}}
     8        },
     9        "create_limit":1
    10      });
    11    },
    12    send_funds{
    13      account_identifier = {{random_account.account_identifier}};
    14      address = {{account_identifier.address}};
    15      idk = http_request({
    16        "method": "POST",
    17        "url": "http:\/\/faucet:8000",
    18        "timeout": 10,
    19        "body": {{random_account.account_identifier.address}}
    20      });
    21    },
    22    // Create a separate scenario to request funds so that
    23    // the address we are using to request funds does not
    24    // get rolled back if funds do not yet exist.
    25    request{
    26      loaded_account = find_balance({
    27        "account_identifier": {{random_account.account_identifier}},
    28        "minimum_balance":{
    29          "value": "50",
    30          "currency": {{currency}}
    31        }
    32      });
    33    }
    34  }
    35  create_account(1){
    36    create{
    37      network = {"network":"network", "blockchain":"app"};
    38      key = generate_key({"curve_type": "secp256k1"});
    39      account = derive({
    40        "network_identifier": {{network}},
    41        "public_key": {{key.public_key}}
    42      });
    43      // If the account is not saved, the key will be lost!
    44      save_account({
    45        "account_identifier": {{account.account_identifier}},
    46        "keypair": {{key}}
    47      });
    48    }
    49  }
    50  transfer(3){
    51    transfer{
    52      transfer.network = {"network":"network", "blockchain":"app"};
    53      currency = {"symbol":"stake", "decimals":0};
    54      sender = find_balance({
    55        "minimum_balance":{
    56          "value": "100",
    57          "currency": {{currency}}
    58        }
    59      });
    60      acc_identifier = {{sender.account_identifier}};
    61      sender_address = {{acc_identifier.address}};
    62      // Set the recipient_amount as some value <= sender.balance-max_fee
    63      max_fee = "0";
    64      fee_amount = "1";
    65      fee_value = 0 - {{fee_amount}};
    66      available_amount = {{sender.balance.value}} - {{max_fee}};
    67      recipient_amount = random_number({"minimum": "1", "maximum": {{available_amount}}});
    68      print_message({"recipient_amount":{{recipient_amount}}});
    69      // Find recipient and construct operations
    70      sender_amount = 0 - {{recipient_amount}};
    71      recipient = find_balance({
    72        "not_account_identifier":[{{sender.account_identifier}}],
    73        "minimum_balance":{
    74          "value": "0",
    75          "currency": {{currency}}
    76        },
    77        "create_limit": 100,
    78        "create_probability": 50
    79      });
    80      transfer.confirmation_depth = "1";
    81      recipient_account_identifier = {{recipient.account_identifier}};
    82      recipient_address = {{recipient_account_identifier.address}};
    83      transfer.operations = [
    84        {
    85          "operation_identifier":{"index":0},
    86          "type":"/cosmos.bank.v1beta1.MsgSend",
    87          "account":{{sender.account_identifier}},
    88          "metadata": {
    89            "amount": [
    90              {
    91                "amount": {{recipient_amount}},
    92                "denom":  {{currency.symbol}}
    93              }
    94            ],
    95            "from_address": {{sender_address}},
    96             "to_address": {{recipient_address}}
    97          }
    98        }
    99      ];
   100      transfer.preprocess_metadata = {
   101          "gas_price": "1stake",
   102          "gas_limit": 250000
   103      };
   104    }
   105  }