Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ SET(FILES ${CMAKE_SOURCE_DIR}/asset_utils.cpp
${CMAKE_SOURCE_DIR}/test_utils.cpp
${CMAKE_SOURCE_DIR}/wallet_utils.cpp
${CMAKE_SOURCE_DIR}/utils.cpp
${CMAKE_SOURCE_DIR}/qsb.cpp
)
SET(HEADER_FILES
argparser.h
Expand Down Expand Up @@ -55,6 +56,7 @@ SET(HEADER_FILES
test_utils.h
utils.h
wallet_utils.h
qsb.h
)

if(MSVC)
Expand Down
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,39 @@ Commands:
-qbondgetusermbonds <OWNER>
Get MBonds owned by the <OWNER>.
-qbondgetcfa
Get list of commission free addresses.
Get list of commission free addresses.

[QSB (QUBIC SOLANA BRIDGE) COMMANDS]
-qsblock <AMOUNT> <RELAYER_FEE> <TO_ADDRESS_HEX> <NETWORK_OUT> <NONCE>
Lock QU to bridge to Solana. <AMOUNT> is the amount to lock, <RELAYER_FEE> is the fee for relayer (must be < AMOUNT>), <TO_ADDRESS_HEX> is the Solana recipient address as 128 hex characters (64 bytes), <NETWORK_OUT> is the destination network ID, <NONCE> is a unique order nonce.
-qsboverridelock <NONCE> <TO_ADDRESS_HEX> <RELAYER_FEE>
Override a previously locked order. <NONCE> is the nonce of the locked order, <TO_ADDRESS_HEX> is the new Solana recipient address (128 hex chars), <RELAYER_FEE> is the new relayer fee.
-qsbunlock <ORDER_DATA> <NUM_SIGNATURES> <SIGNATURES>
Unlock funds from Solana (requires oracle signatures). This is a complex operation - use invokecontractprocedure for full control.
-qsbtransferadmin <NEW_ADMIN_IDENTITY>
Transfer admin role to a new identity. Admin only.
-qsbeditoraclethreshold <THRESHOLD>
Set oracle threshold percentage (1-100). Admin only.
-qsbaddrole <ACCOUNT_IDENTITY> <ROLE>
Add role to an account. <ROLE> is 1 for Oracle or 2 for Pauser. Admin only.
-qsbremoverole <ACCOUNT_IDENTITY> <ROLE>
Remove role from an account. <ROLE> is 1 for Oracle or 2 for Pauser. Admin only.
-qsbpause
Pause the QSB contract. Admin or Pauser only.
-qsbunpause
Unpause the QSB contract. Admin or Pauser only.
-qsbeditfeeparameters <PROTOCOL_FEE_RECIPIENT> <ORACLE_FEE_RECIPIENT> <BPS_FEE> <PROTOCOL_FEE>
Edit fee parameters. <PROTOCOL_FEE_RECIPIENT> and <ORACLE_FEE_RECIPIENT> are identities (use empty string "" to skip), <BPS_FEE> is basis points (0-10000), <PROTOCOL_FEE> is percentage (0-100). Admin only.
-qsbgetconfig
Get QSB configuration (admin, fee recipients, fees, oracle parameters, paused state).
-qsbisoracle <ACCOUNT_IDENTITY>
Check if an account has Oracle role in QSB.
-qsbispauser <ACCOUNT_IDENTITY>
Check if an account has Pauser role in QSB.
-qsbgetlockedorder <NONCE>
Get information about a locked order by nonce.
-qsbisorderfilled <ORDER_HASH_HEX>
Check if an order hash has already been filled in QSB (64 hex chars).

[TESTING COMMANDS]
-testqpifunctionsoutput
Expand Down
169 changes: 169 additions & 0 deletions argparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,38 @@ void print_help()
printf("\t-qbondgetcfa\n");
printf("\t\tGet list of commission free addresses.\n");

printf("\n[QSB (QUBIC SOLANA BRIDGE) COMMANDS]\n");
printf("\t-qsblock <AMOUNT> <RELAYER_FEE> <TO_ADDRESS_HEX> <NETWORK_OUT> <NONCE>\n");
printf("\t\tLock QU to bridge to Solana. <AMOUNT> is the amount to lock, <RELAYER_FEE> is the fee for relayer (must be < AMOUNT>), <TO_ADDRESS_HEX> is the Solana recipient address as 128 hex characters (64 bytes), <NETWORK_OUT> is the destination network ID, <NONCE> is a unique order nonce.\n");
printf("\t-qsboverridelock <NONCE> <TO_ADDRESS_HEX> <RELAYER_FEE>\n");
printf("\t\tOverride a previously locked order. <NONCE> is the nonce of the locked order, <TO_ADDRESS_HEX> is the new Solana recipient address (128 hex chars), <RELAYER_FEE> is the new relayer fee.\n");
printf("\t-qsbunlock <ORDER_DATA> <NUM_SIGNATURES> <SIGNATURES>\n");
printf("\t\tUnlock funds from Solana (requires oracle signatures). This is a complex operation - use invokecontractprocedure for full control.\n");
printf("\t-qsbtransferadmin <NEW_ADMIN_IDENTITY>\n");
printf("\t\tTransfer admin role to a new identity. Admin only.\n");
printf("\t-qsbeditoraclethreshold <THRESHOLD>\n");
printf("\t\tSet oracle threshold percentage (1-100). Admin only.\n");
printf("\t-qsbaddrole <ACCOUNT_IDENTITY> <ROLE>\n");
printf("\t\tAdd role to an account. <ROLE> is 1 for Oracle or 2 for Pauser. Admin only.\n");
printf("\t-qsbremoverole <ACCOUNT_IDENTITY> <ROLE>\n");
printf("\t\tRemove role from an account. <ROLE> is 1 for Oracle or 2 for Pauser. Admin only.\n");
printf("\t-qsbpause\n");
printf("\t\tPause the QSB contract. Admin or Pauser only.\n");
printf("\t-qsbunpause\n");
printf("\t\tUnpause the QSB contract. Admin or Pauser only.\n");
printf("\t-qsbeditfeeparameters <PROTOCOL_FEE_RECIPIENT> <ORACLE_FEE_RECIPIENT> <BPS_FEE> <PROTOCOL_FEE>\n");
printf("\t\tEdit fee parameters. <PROTOCOL_FEE_RECIPIENT> and <ORACLE_FEE_RECIPIENT> are identities (use empty string \"\" to skip), <BPS_FEE> is basis points (0-10000), <PROTOCOL_FEE> is percentage (0-100). Admin only.\n");
printf("\t-qsbgetconfig\n");
printf("\t\tGet QSB configuration (admin, fee recipients, fees, oracle parameters, paused state).\n");
printf("\t-qsbisoracle <ACCOUNT_IDENTITY>\n");
printf("\t\tCheck if an account has Oracle role in QSB.\n");
printf("\t-qsbispauser <ACCOUNT_IDENTITY>\n");
printf("\t\tCheck if an account has Pauser role in QSB.\n");
printf("\t-qsbgetlockedorder <NONCE>\n");
printf("\t\tGet information about a locked order by nonce.\n");
printf("\t-qsbisorderfilled <ORDER_HASH_HEX>\n");
printf("\t\tCheck if an order hash has already been filled in QSB (64 hex chars).\n");

printf("\n[TESTING COMMANDS]\n");
printf("\t-testqpifunctionsoutput\n");
printf("\t\tTest that output of qpi functions matches TickData and quorum tick votes for 15 ticks in the future (as specified by scheduletick offset). Requires the TESTEXA SC to be enabled.\n");
Expand Down Expand Up @@ -554,6 +586,8 @@ static uint32_t getContractIndex(const char* str, bool enableTestContracts)
idx = 17;
else if (strcasecmp(str, "QIP") == 0)
idx = 18;
else if (strcasecmp(str, "QSB") == 0)
idx = 20;
else
{
unsigned int contractCount = CONTRACT_COUNT;
Expand Down Expand Up @@ -2677,6 +2711,141 @@ void parseArgument(int argc, char** argv)
break;
}

/*****************************************
***** QSB COMMANDS *****
*****************************************/

if (strcmp(argv[i], "-qsblock") == 0)
{
CHECK_NUMBER_OF_PARAMETERS(5)
g_cmd = QSB_LOCK_CMD;
g_qsb_amount = charToNumber(argv[i + 1]);
g_qsb_relayerFee = charToNumber(argv[i + 2]);
g_qsb_toAddressHex = argv[i + 3];
g_qsb_networkOut = (uint32_t)charToNumber(argv[i + 4]);
g_qsb_nonce = (uint32_t)charToNumber(argv[i + 5]);
i += 6;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsboverridelock") == 0)
{
CHECK_NUMBER_OF_PARAMETERS(3)
g_cmd = QSB_OVERRIDE_LOCK_CMD;
g_qsb_nonce = (uint32_t)charToNumber(argv[i + 1]);
g_qsb_toAddressHex = argv[i + 2];
g_qsb_relayerFee = charToNumber(argv[i + 3]);
i += 4;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbtransferadmin") == 0)
{
CHECK_NUMBER_OF_PARAMETERS(1)
g_cmd = QSB_TRANSFER_ADMIN_CMD;
g_qsb_newAdminIdentity = argv[i + 1];
i += 2;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbeditoraclethreshold") == 0)
{
CHECK_NUMBER_OF_PARAMETERS(1)
g_cmd = QSB_EDIT_ORACLE_THRESHOLD_CMD;
g_qsb_oracleThreshold = (uint8_t)charToNumber(argv[i + 1]);
i += 2;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbaddrole") == 0)
{
CHECK_NUMBER_OF_PARAMETERS(2)
g_cmd = QSB_ADD_ROLE_CMD;
g_qsb_accountIdentity = argv[i + 1];
g_qsb_role = (uint8_t)charToNumber(argv[i + 2]);
i += 3;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbremoverole") == 0)
{
CHECK_NUMBER_OF_PARAMETERS(2)
g_cmd = QSB_REMOVE_ROLE_CMD;
g_qsb_accountIdentity = argv[i + 1];
g_qsb_role = (uint8_t)charToNumber(argv[i + 2]);
i += 3;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbpause") == 0)
{
g_cmd = QSB_PAUSE_CMD;
i++;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbunpause") == 0)
{
g_cmd = QSB_UNPAUSE_CMD;
i++;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbeditfeeparameters") == 0)
{
CHECK_NUMBER_OF_PARAMETERS(4)
g_cmd = QSB_EDIT_FEE_PARAMETERS_CMD;
g_qsb_protocolFeeRecipientIdentity = argv[i + 1];
g_qsb_oracleFeeRecipientIdentity = argv[i + 2];
g_qsb_bpsFee = (uint32_t)charToNumber(argv[i + 3]);
g_qsb_protocolFee = (uint32_t)charToNumber(argv[i + 4]);
i += 5;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbgetconfig") == 0)
{
g_cmd = QSB_GET_CONFIG_CMD;
i += 1;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbisoracle") == 0)
{
CHECK_NUMBER_OF_PARAMETERS(1)
g_cmd = QSB_IS_ORACLE_CMD;
g_qsb_viewIdentity = argv[i + 1];
i += 2;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbispauser") == 0)
{
CHECK_NUMBER_OF_PARAMETERS(1)
g_cmd = QSB_IS_PAUSER_CMD;
g_qsb_viewIdentity = argv[i + 1];
i += 2;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbgetlockedorder") == 0)
{
CHECK_NUMBER_OF_PARAMETERS(1)
g_cmd = QSB_GET_LOCKED_ORDER_CMD;
g_qsb_viewNonce = (uint32_t)charToNumber(argv[i + 1]);
i += 2;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbisorderfilled") == 0)
{
CHECK_NUMBER_OF_PARAMETERS(1)
g_cmd = QSB_IS_ORDER_FILLED_CMD;
g_qsb_orderHashHex = argv[i + 1];
i += 2;
CHECK_OVER_PARAMETERS
break;
}

/*****************************************
***** SHAREHOLDER PROPOSAL COMMANDS *****
Expand Down
8 changes: 8 additions & 0 deletions connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "nostromo.h"
#include "qutil.h"
#include "qbond.h"
#include "qsb.h"

#define DEFAULT_TIMEOUT_MSEC 1000

Expand Down Expand Up @@ -410,3 +411,10 @@ template GetCurrentResult_output QubicConnection::receivePacketWithHeaderAs<GetC
template GetPollsByCreator_output QubicConnection::receivePacketWithHeaderAs<GetPollsByCreator_output>();
template GetCurrentPollId_output QubicConnection::receivePacketWithHeaderAs<GetCurrentPollId_output>();
template GetPollInfo_output QubicConnection::receivePacketWithHeaderAs<GetPollInfo_output>();

// QSB
template QSB_GetConfig_output QubicConnection::receivePacketWithHeaderAs<QSB_GetConfig_output>();
template QSB_IsOracle_output QubicConnection::receivePacketWithHeaderAs<QSB_IsOracle_output>();
template QSB_IsPauser_output QubicConnection::receivePacketWithHeaderAs<QSB_IsPauser_output>();
template QSB_GetLockedOrder_output QubicConnection::receivePacketWithHeaderAs<QSB_GetLockedOrder_output>();
template QSB_IsOrderFilled_output QubicConnection::receivePacketWithHeaderAs<QSB_IsOrderFilled_output>();
18 changes: 18 additions & 0 deletions global.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,21 @@ int64_t g_qbond_mbondPrice = 0;
int64_t g_qbond_burnAmount = 0;
char* g_qbond_owner = nullptr;
bool g_qbond_updateCFAOperation = false;

// qsb
uint64_t g_qsb_amount = 0;
uint64_t g_qsb_relayerFee = 0;
char* g_qsb_toAddressHex = nullptr;
uint32_t g_qsb_networkOut = 0;
uint32_t g_qsb_nonce = 0;
char* g_qsb_newAdminIdentity = nullptr;
uint8_t g_qsb_oracleThreshold = 0;
char* g_qsb_accountIdentity = nullptr;
uint8_t g_qsb_role = 0;
char* g_qsb_protocolFeeRecipientIdentity = nullptr;
char* g_qsb_oracleFeeRecipientIdentity = nullptr;
uint32_t g_qsb_bpsFee = 0;
uint32_t g_qsb_protocolFee = 0;
char* g_qsb_viewIdentity = nullptr;
uint32_t g_qsb_viewNonce = 0;
char* g_qsb_orderHashHex = nullptr;
Loading