Skip to content

Commit 9887172

Browse files
committed
feat(wallet): add multiple new operations for custom actions and account management
- Implement custom operation broadcasting with active and regular authority support - Add delete operations for content and proposals - Introduce committee worker request creation, cancellation, and voting operations - Support invite creation, claiming, registration, and usage operations - Add award and fixed_award operations with beneficiary support - Implement paid subscription setup and subscription operations - Add account sale features including setting price, subaccount price, buying, and target sale - Ensure all operations create and validate signed transactions before broadcasting - Extend FC_API with new operation interfaces for wallet API integration
1 parent 2cfe69b commit 9887172

2 files changed

Lines changed: 720 additions & 0 deletions

File tree

libraries/wallet/include/graphene/wallet/wallet.hpp

Lines changed: 332 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,318 @@ namespace graphene { namespace wallet {
954954
const std::string& from, time_point newest, uint16_t limit, std::uint64_t offset);
955955

956956
message_body try_decrypt_message( const message_api_obj& mo );
957+
958+
/**
959+
* Broadcast a custom operation.
960+
*
961+
* @param required_active_auths Accounts requiring active authority
962+
* @param required_regular_auths Accounts requiring regular authority
963+
* @param id Custom operation type identifier
964+
* @param json JSON data for the custom operation
965+
* @param broadcast true if you wish to broadcast the transaction
966+
*/
967+
annotated_signed_transaction custom(
968+
flat_set<string> required_active_auths,
969+
flat_set<string> required_regular_auths,
970+
string id,
971+
string json,
972+
bool broadcast = false
973+
);
974+
975+
/**
976+
* Delete a content.
977+
*
978+
* @param author The author of the content
979+
* @param permlink The permlink of the content
980+
* @param broadcast true if you wish to broadcast the transaction
981+
*/
982+
annotated_signed_transaction delete_content(
983+
string author,
984+
string permlink,
985+
bool broadcast = false
986+
);
987+
988+
/**
989+
* Delete a proposal.
990+
*
991+
* @param author The author of the proposal
992+
* @param title The title of the proposal
993+
* @param requester The account requesting deletion
994+
* @param broadcast true if you wish to broadcast the transaction
995+
*/
996+
annotated_signed_transaction delete_proposal(
997+
string author,
998+
string title,
999+
string requester,
1000+
bool broadcast = false
1001+
);
1002+
1003+
/**
1004+
* Create a committee worker request.
1005+
*
1006+
* @param creator The account creating the request
1007+
* @param url URL with information about the request
1008+
* @param worker The worker account that will receive payment
1009+
* @param required_amount_min Minimum amount requested
1010+
* @param required_amount_max Maximum amount requested
1011+
* @param duration Duration of the request in seconds
1012+
* @param broadcast true if you wish to broadcast the transaction
1013+
*/
1014+
annotated_signed_transaction committee_worker_create_request(
1015+
string creator,
1016+
string url,
1017+
string worker,
1018+
asset required_amount_min,
1019+
asset required_amount_max,
1020+
uint32_t duration,
1021+
bool broadcast = false
1022+
);
1023+
1024+
/**
1025+
* Cancel a committee worker request.
1026+
*
1027+
* @param creator The account that created the request
1028+
* @param request_id The ID of the request to cancel
1029+
* @param broadcast true if you wish to broadcast the transaction
1030+
*/
1031+
annotated_signed_transaction committee_worker_cancel_request(
1032+
string creator,
1033+
uint32_t request_id,
1034+
bool broadcast = false
1035+
);
1036+
1037+
/**
1038+
* Vote on a committee worker request.
1039+
*
1040+
* @param voter The account voting
1041+
* @param request_id The ID of the request to vote on
1042+
* @param vote_percent The vote percentage (-10000 to 10000)
1043+
* @param broadcast true if you wish to broadcast the transaction
1044+
*/
1045+
annotated_signed_transaction committee_vote_request(
1046+
string voter,
1047+
uint32_t request_id,
1048+
int16_t vote_percent,
1049+
bool broadcast = false
1050+
);
1051+
1052+
/**
1053+
* Create an invite with a balance.
1054+
*
1055+
* @param creator The account creating the invite
1056+
* @param balance The balance to put in the invite
1057+
* @param invite_key The public key for the invite
1058+
* @param broadcast true if you wish to broadcast the transaction
1059+
*/
1060+
annotated_signed_transaction create_invite(
1061+
string creator,
1062+
asset balance,
1063+
public_key_type invite_key,
1064+
bool broadcast = false
1065+
);
1066+
1067+
/**
1068+
* Claim an invite balance.
1069+
*
1070+
* @param initiator The account initiating the claim
1071+
* @param receiver The account receiving the balance
1072+
* @param invite_secret The secret key of the invite
1073+
* @param broadcast true if you wish to broadcast the transaction
1074+
*/
1075+
annotated_signed_transaction claim_invite_balance(
1076+
string initiator,
1077+
string receiver,
1078+
string invite_secret,
1079+
bool broadcast = false
1080+
);
1081+
1082+
/**
1083+
* Register a new account using an invite.
1084+
*
1085+
* @param initiator The account initiating the registration
1086+
* @param new_account_name The name of the new account
1087+
* @param invite_secret The secret key of the invite
1088+
* @param new_account_key The public key for the new account
1089+
* @param broadcast true if you wish to broadcast the transaction
1090+
*/
1091+
annotated_signed_transaction invite_registration(
1092+
string initiator,
1093+
string new_account_name,
1094+
string invite_secret,
1095+
public_key_type new_account_key,
1096+
bool broadcast = false
1097+
);
1098+
1099+
/**
1100+
* Use invite balance to transfer to vesting.
1101+
*
1102+
* @param initiator The account initiating the use
1103+
* @param receiver The account receiving the vesting
1104+
* @param invite_secret The secret key of the invite
1105+
* @param broadcast true if you wish to broadcast the transaction
1106+
*/
1107+
annotated_signed_transaction use_invite_balance(
1108+
string initiator,
1109+
string receiver,
1110+
string invite_secret,
1111+
bool broadcast = false
1112+
);
1113+
1114+
/**
1115+
* Award an account (energy-based reward).
1116+
*
1117+
* @param initiator The account giving the award
1118+
* @param receiver The account receiving the award
1119+
* @param energy The energy amount to use (0-10000)
1120+
* @param custom_sequence Custom sequence number
1121+
* @param memo Memo for the award
1122+
* @param beneficiaries List of beneficiaries with weights
1123+
* @param broadcast true if you wish to broadcast the transaction
1124+
*/
1125+
annotated_signed_transaction award(
1126+
string initiator,
1127+
string receiver,
1128+
uint16_t energy,
1129+
uint64_t custom_sequence,
1130+
string memo,
1131+
vector<beneficiary_route_type> beneficiaries,
1132+
bool broadcast = false
1133+
);
1134+
1135+
/**
1136+
* Fixed award an account (fixed amount reward).
1137+
*
1138+
* @param initiator The account giving the award
1139+
* @param receiver The account receiving the award
1140+
* @param reward_amount The fixed reward amount
1141+
* @param max_energy Maximum energy to use
1142+
* @param custom_sequence Custom sequence number
1143+
* @param memo Memo for the award
1144+
* @param beneficiaries List of beneficiaries with weights
1145+
* @param broadcast true if you wish to broadcast the transaction
1146+
*/
1147+
annotated_signed_transaction fixed_award(
1148+
string initiator,
1149+
string receiver,
1150+
asset reward_amount,
1151+
uint16_t max_energy,
1152+
uint64_t custom_sequence,
1153+
string memo,
1154+
vector<beneficiary_route_type> beneficiaries,
1155+
bool broadcast = false
1156+
);
1157+
1158+
/**
1159+
* Set up a paid subscription.
1160+
*
1161+
* @param account The account setting up the subscription
1162+
* @param url URL with subscription information
1163+
* @param levels Number of subscription levels
1164+
* @param amount Cost per level
1165+
* @param period Subscription period in seconds
1166+
* @param broadcast true if you wish to broadcast the transaction
1167+
*/
1168+
annotated_signed_transaction set_paid_subscription(
1169+
string account,
1170+
string url,
1171+
uint16_t levels,
1172+
asset amount,
1173+
uint16_t period,
1174+
bool broadcast = false
1175+
);
1176+
1177+
/**
1178+
* Subscribe to a paid subscription.
1179+
*
1180+
* @param subscriber The subscribing account
1181+
* @param account The account with the subscription
1182+
* @param level Subscription level
1183+
* @param amount Payment amount
1184+
* @param period Subscription period
1185+
* @param auto_renewal Enable auto renewal
1186+
* @param broadcast true if you wish to broadcast the transaction
1187+
*/
1188+
annotated_signed_transaction paid_subscribe(
1189+
string subscriber,
1190+
string account,
1191+
uint16_t level,
1192+
asset amount,
1193+
uint16_t period,
1194+
bool auto_renewal,
1195+
bool broadcast = false
1196+
);
1197+
1198+
/**
1199+
* Set an account up for sale.
1200+
*
1201+
* @param account The account being sold
1202+
* @param account_seller The seller account
1203+
* @param account_offer_price The sale price
1204+
* @param account_on_sale Whether the account is on sale
1205+
* @param broadcast true if you wish to broadcast the transaction
1206+
*/
1207+
annotated_signed_transaction set_account_price(
1208+
string account,
1209+
string account_seller,
1210+
asset account_offer_price,
1211+
bool account_on_sale,
1212+
bool broadcast = false
1213+
);
1214+
1215+
/**
1216+
* Set subaccount creation for sale.
1217+
*
1218+
* @param account The parent account
1219+
* @param subaccount_seller The seller account
1220+
* @param subaccount_offer_price The price for subaccount creation
1221+
* @param subaccount_on_sale Whether subaccounts are on sale
1222+
* @param broadcast true if you wish to broadcast the transaction
1223+
*/
1224+
annotated_signed_transaction set_subaccount_price(
1225+
string account,
1226+
string subaccount_seller,
1227+
asset subaccount_offer_price,
1228+
bool subaccount_on_sale,
1229+
bool broadcast = false
1230+
);
1231+
1232+
/**
1233+
* Buy an account.
1234+
*
1235+
* @param buyer The buying account
1236+
* @param account The account being bought
1237+
* @param account_offer_price The purchase price
1238+
* @param account_authorities_key New public key for the account
1239+
* @param tokens_to_shares Amount to convert to shares
1240+
* @param broadcast true if you wish to broadcast the transaction
1241+
*/
1242+
annotated_signed_transaction buy_account(
1243+
string buyer,
1244+
string account,
1245+
asset account_offer_price,
1246+
public_key_type account_authorities_key,
1247+
asset tokens_to_shares,
1248+
bool broadcast = false
1249+
);
1250+
1251+
/**
1252+
* Set an account for sale to a specific target buyer.
1253+
*
1254+
* @param account The account being sold
1255+
* @param account_seller The seller account
1256+
* @param target_buyer The target buyer account
1257+
* @param account_offer_price The sale price
1258+
* @param account_on_sale Whether the account is on sale
1259+
* @param broadcast true if you wish to broadcast the transaction
1260+
*/
1261+
annotated_signed_transaction target_account_sale(
1262+
string account,
1263+
string account_seller,
1264+
string target_buyer,
1265+
asset account_offer_price,
1266+
bool account_on_sale,
1267+
bool broadcast = false
1268+
);
9571269
};
9581270

9591271
struct plain_keys {
@@ -1036,6 +1348,26 @@ FC_API( graphene::wallet::wallet_api,
10361348
(get_encrypted_memo)
10371349
(decrypt_memo)
10381350

1351+
/// new operations
1352+
(custom)
1353+
(delete_content)
1354+
(delete_proposal)
1355+
(committee_worker_create_request)
1356+
(committee_worker_cancel_request)
1357+
(committee_vote_request)
1358+
(create_invite)
1359+
(claim_invite_balance)
1360+
(invite_registration)
1361+
(use_invite_balance)
1362+
(award)
1363+
(fixed_award)
1364+
(set_paid_subscription)
1365+
(paid_subscribe)
1366+
(set_account_price)
1367+
(set_subaccount_price)
1368+
(buy_account)
1369+
(target_account_sale)
1370+
10391371
/// helper api
10401372
(begin_builder_transaction)
10411373
(add_operation_to_builder_transaction)

0 commit comments

Comments
 (0)