cosmos-sdk/contrib/rosetta/configuration/staking.ros

148 lines
4.2 KiB
Plaintext
Raw Normal View History

request_funds(1){
find_account{
currency = {"symbol":"stake", "decimals":0};
random_account = find_balance({
"minimum_balance":{
"value": "0",
"currency": {{currency}}
},
"create_limit":1
});
},
send_funds{
account_identifier = {{random_account.account_identifier}};
address = {{account_identifier.address}};
idk = http_request({
"method": "POST",
"url": "http:\/\/faucet:8000",
"timeout": 10,
"body": {{random_account.account_identifier.address}}
});
},
// Create a separate scenario to request funds so that
// the address we are using to request funds does not
// get rolled back if funds do not yet exist.
request{
loaded_account = find_balance({
"account_identifier": {{random_account.account_identifier}},
"minimum_balance":{
"value": "100",
"currency": {{currency}}
}
});
}
}
create_account(1){
create{
network = {"network":"network", "blockchain":"app"};
key = generate_key({"curve_type": "secp256k1"});
account = derive({
"network_identifier": {{network}},
"public_key": {{key.public_key}}
});
// If the account is not saved, the key will be lost!
save_account({
"account_identifier": {{account.account_identifier}},
"keypair": {{key}}
});
}
}
staking(1){
stake{
stake.network = {"network":"network", "blockchain":"app"};
currency = {"symbol":"stake", "decimals":0};
sender = find_balance({
"minimum_balance":{
"value": "100",
"currency": {{currency}}
}
});
// Set the recipient_amount as some value <= sender.balance-max_fee
max_fee = "0";
fee_amount = "1";
fee_value = 0 - {{fee_amount}};
available_amount = {{sender.balance.value}} - {{max_fee}};
recipient_amount = "1";
print_message({"recipient_amount":{{recipient_amount}}});
// Find recipient and construct operations
recipient = {{sender.account_identifier}};
sender_amount = 0 - {{recipient_amount}};
stake.confirmation_depth = "1";
stake.operations = [
{
"operation_identifier":{"index":0},
"type":"fee",
"account":{{sender.account_identifier}},
"amount":{
"value":{{fee_value}},
"currency":{{currency}}
}
},
{
"operation_identifier":{"index":1},
"type":"cosmos.staking.v1beta1.MsgDelegate",
"account":{{sender.account_identifier}},
"amount":{
"value":{{sender_amount}},
"currency":{{currency}}
}
},
{
"operation_identifier":{"index":2},
"type":"cosmos.staking.v1beta1.MsgDelegate",
"account": {
"address": "staking_account",
"sub_account": {
"address" : "cosmosvaloper158nkd0l9tyemv2crp579rmj8dg37qty86kaut5"
}
},
"amount":{
"value":{{recipient_amount}},
"currency":{{currency}}
}
}
];
},
undelegate{
print_message({"undelegate":{{sender}}});
undelegate.network = {"network":"network", "blockchain":"app"};
undelegate.confirmation_depth = "1";
undelegate.operations = [
{
"operation_identifier":{"index":0},
"type":"fee",
"account":{{sender.account_identifier}},
"amount":{
"value":{{fee_value}},
"currency":{{currency}}
}
},
{
"operation_identifier":{"index":1},
"type":"cosmos.staking.v1beta1.MsgUndelegate",
"account":{{sender.account_identifier}},
"amount":{
"value":{{recipient_amount}},
"currency":{{currency}}
}
},
{
"operation_identifier":{"index":2},
"type":"cosmos.staking.v1beta1.MsgUndelegate",
"account": {
"address": "staking_account",
"sub_account": {
"address" : "cosmosvaloper158nkd0l9tyemv2crp579rmj8dg37qty86kaut5"
}
},
"amount":{
"value":{{sender_amount}},
"currency":{{currency}}
}
}
];
}
}