Created
October 22, 2018 12:32
-
-
Save johnX9/0215b56caea6c76510bb29aeea1c9c37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void RobotFactory::create(account_name account, robot newRobot) { | |
robotIndex robots(_self, _self); | |
auto iterator = robots.find(newRobot.series_number); | |
eosio_assert(iterator == robots.end(), "Robot with this series number already exists"); | |
robots.emplace(account, [&](auto& robot) { | |
robot.series_number = newRobot.series_number; | |
robot.model = newRobot.model; | |
robot.operating_system = newRobot.operating_system; | |
robot.profession = newRobot.profession; | |
robot.owner = name{account}.to_string(); | |
robot.manufactured = now(); | |
}); | |
// Execute inline action from another contract | |
// action({permission_level}, {contract_deployer}, {contract_action}, {data_to_pass}).send(); | |
action(permission_level(account, N(active)), N(market), N(forsale), make_tuple(account, | |
newRobot.series_number, | |
newRobot.model, | |
newRobot.manufactured | |
)).send(); | |
// Execute DEFERRED ACTION from another contract | |
eosio::transaction tx; | |
tx.actions.emplace_back(permission_level{account, N(active)}, N(messenger), N(printmessage), make_tuple(newRobot.model)); | |
tx.delay_sec = 12; | |
tx.send(N(newRobot.model), account); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment