Skip to content

Commit

Permalink
Merge pull request #4 from metaloop-world/client-signer
Browse files Browse the repository at this point in the history
update apis
  • Loading branch information
lxjhk authored Jan 22, 2024
2 parents 8827caf + 8d786df commit ec32643
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 107 deletions.
57 changes: 28 additions & 29 deletions .github/workflows/syncrepo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,33 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Pushes to another repository
run: |
SOURCE_DIRECTORY="$(pwd)" # Source directory path
DESTINATION_USERNAME="mpcvault" # Destination GitHub username
DESTINATION_REPOSITORY="mpcvaultapis" # Destination repository name
TARGET_BRANCH="main" # Target branch in the destination repository
USER_EMAIL="[email protected]"
USER_NAME="lxjhk"
git rm -r --cached .
git reset --hard
# Set user information
git config --global user.email "$USER_EMAIL"
git config --global user.name "$USER_NAME"
git config --unset http.https://github.com/.extraheader
GIT_CMD_REPOSITORY="https://$USER_NAME:${{ secrets.MPCVAULT_EXTERN_SYNC_GITHUB_TOKEN }}@github.com/$DESTINATION_USERNAME/$DESTINATION_REPOSITORY.git"
{
git clone --single-branch --depth 1 --branch "$TARGET_BRANCH" "$GIT_CMD_REPOSITORY"
} || {
echo "::error::Could not clone the destination repository. Command:"
echo "::error::git clone --single-branch --branch $TARGET_BRANCH $GIT_CMD_REPOSITORY"
exit 1
}
git remote remove origin
git remote add origin $GIT_CMD_REPOSITORY
git push -f origin main
SOURCE_DIRECTORY="$(pwd)" # Source directory path
DESTINATION_USERNAME="mpcvault" # Destination GitHub username
DESTINATION_REPOSITORY="mpcvaultapis" # Destination repository name
TARGET_BRANCH="main" # Target branch in the destination repository
USER_EMAIL="[email protected]"
USER_NAME="lxjhk"
git rm -r --cached .
git reset --hard
# Set user information
git config --global user.email "$USER_EMAIL"
git config --global user.name "$USER_NAME"
git config --unset http.https://github.com/.extraheader
GIT_CMD_REPOSITORY="https://$USER_NAME:${{ secrets.MPCVAULT_EXTERN_SYNC_GITHUB_TOKEN }}@github.com/$DESTINATION_USERNAME/$DESTINATION_REPOSITORY.git"
{
git clone --single-branch --depth 1 --branch "$TARGET_BRANCH" "$GIT_CMD_REPOSITORY"
} || {
echo "::error::Could not clone the destination repository. Command:"
echo "::error::git clone --single-branch --branch $TARGET_BRANCH $GIT_CMD_REPOSITORY"
exit 1
}
git remote remove origin
git remote add origin $GIT_CMD_REPOSITORY
git push -f origin main
165 changes: 124 additions & 41 deletions mpcvault/platform/v1/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ syntax = "proto3";
package mpcvault.platform.v1;

import "google/protobuf/wrappers.proto";
import "mpcvault/rpc/v1/status.proto";
import "mpcvault/platform/v1/error.proto";

option go_package = "go.mpcvault.com/genproto/mpcvaultapis/platform/v1;platform";
option java_multiple_files = true;
Expand All @@ -26,13 +26,14 @@ option java_package = "com.mpcvault.platform.v1";


service PlatformAPI {
// CreateSigningRequest creates a signing request for the given transaction.
// CreateSigningRequest creates a signing request. The signing request can be completed using the MPCVault mobile app or using the API client signer.
rpc CreateSigningRequest (CreateSigningRequestRequest) returns (CreateSigningRequestResponse);

// RejectSigningRequest rejects a signing request.
// RejectSigningRequest rejects a signing request. Once a signing request is rejected, it cannot be re-opened.
rpc RejectSigningRequest (RejectSigningRequestRequest) returns (RejectSigningRequestResponse);

// GetSigningRequestDetails returns the details of a signing request.
// It will contain the signing request status and the transaction hash if the signing request was completed.
rpc GetSigningRequestDetails (GetSigningRequestDetailsRequest) returns (GetSigningRequestDetailsResponse);

// CreateBatchPayment creates a batch payment.
Expand All @@ -44,64 +45,132 @@ service PlatformAPI {
// CreateWallet creates a wallet.
rpc CreateWallet (CreateWalletRequest) returns (CreateWalletResponse);

// SignSigningRequest sign a signing request.
rpc SignSigningRequest (SignSigningRequestRequest) returns (SignSigningRequestResponse);
// ExecuteSigningRequests sign a signing request.
rpc ExecuteSigningRequests (ExecuteSigningRequestsRequest) returns (ExecuteSigningRequestsResponse);
}

message CreateWalletRequest {
// vault_uuid is the UUID of the vault to create the wallet in.
// You can find it in the settings page of your vault on the web.
string vault_uuid = 1;
string client_signer_public_key = 2;
AddressFormat address_format = 3;
// callback_client_signer_public_key is the public key of the api client signer.
// It is used to identify the call back.
string callback_client_signer_public_key = 2;
// network_type is the type of the network.
NetworkType network_type = 3;
// (optional) ref is the unique identifier for the wallet.
string ref = 4;
}
enum AddressFormat {
ADDRESS_FORMAT_UNKNOWN = 0;
ADDRESS_FORMAT_EVM = 1;
ADDRESS_FORMAT_BITCOIN = 2;
ADDRESS_FORMAT_TRON = 3;
ADDRESS_FORMAT_APTOS = 4;
ADDRESS_FORMAT_SUI = 5;
ADDRESS_FORMAT_SOLANA = 6;
enum NetworkType {
NETWORK_TYPE_UNKNOWN = 0;
NETWORK_TYPE_EVM = 1;
NETWORK_TYPE_BITCOIN = 2;
NETWORK_TYPE_TRON = 3;
NETWORK_TYPE_APTOS = 4;
NETWORK_TYPE_SUI = 5;
NETWORK_TYPE_SOLANA = 6;
}
enum KeyType {
KEY_TYPE_UNSPECIFIED = 0;
KEY_TYPE_ECC_SECP256K1 = 1;
KEY_TYPE_ECC_ED25519 = 2;
}
message Wallet {
// vault_uuid is the UUID of the vault that the wallet is in.
string vault_uuid = 1;
string client_signer_public_key = 2;
// callback_client_signer_public_key is the public key of the api client signer.
string callback_client_signer_public_key = 2;
// key_type is the type of the key in the wallet.
KeyType key_type = 3;
// key_path is the path of the key in the wallet.
string key_path = 4;
string public_key = 5;
AddressFormat address_format = 6;
// public_key is the public key of the wallet.
bytes public_key = 5;
// network_type is the type of the network.
NetworkType network_type = 6;
// address is the address of the wallet.
string address = 7;
// ref is unique identifier for the wallet.
string ref = 8;
}
message CreateWalletResponse {
Wallet details = 1;
mpcvault.rpc.v1.Status error = 2;
Error error = 2;
}

message SignSigningRequestRequest {
message ExecuteSigningRequestsRequest {
// uuid is the UUID of the signing request.
// Currently only signing requests created by wallets created by the API are supported.
string uuid = 1;
}
message SignSigningRequestError {
enum ErrorCode {
// Enum unspecified.
ERROR_CODE_UNSPECIFIED = 0;
// Insufficient funds
ERROR_CODE_INSUFFICIENT_FUNDS = 1;
// Denied
ERROR_CODE_ALREADY_DENIED = 2;
}
ErrorCode error_code = 1;
string message = 2;
}
message SignSigningRequestResponse {
mpcvault.rpc.v1.Status error = 1;
message ExecuteSigningRequestsResponse {
Error error = 1;
// tx_hash is the hash of the transaction, only set if status is STATUS_SUCCEEDED.
string tx_hash = 2;
// signatures is the signatures of the raw message, only set if status is STATUS_SUCCEEDED.
SignatureContainer signatures = 3;
}

message SignatureContainer {
message SignResponse {
oneof signature {
ECDSASignature ecdsa_signature = 1;
// Ed25519 signatures are 64 bytes long, sig = R_bytes || s_bytes
// R_bytes is the canonical 32-byte encoding of v, according to RFC 8032, Section 5.1.2
bytes eddsa_signature = 2;
}
}
message ECDSASignature {
string R = 1;
string S = 2;
string V = 3;
}
repeated SignResponse signatures = 1;
}

message EVMMessage {
enum Type {
TYPE_UNSPECIFIED = 0;
TYPE_PERSONAL_SIGN = 1;
TYPE_SIGN_TYPED_DATA = 2;
}
uint64 chain_id = 1;
string from = 2;
Type type = 3;
bytes content = 4;
}

message AptosMessage {
enum Type {
TYPE_UNSPECIFIED = 0;
TYPE_DEFAULT = 1;
}
message Message {
google.protobuf.StringValue address = 1;
google.protobuf.StringValue application = 2;
google.protobuf.Int64Value chain_id = 3;
string message = 4;
string nonce = 5;
}
string from = 1;
Type type = 2;
Message content = 3;
}

message SolanaMessage {
enum Type {
TYPE_UNSPECIFIED = 0;
TYPE_DEFAULT = 1;
}
string from = 1;
Type type = 2;
bytes content = 3;
}

message RawMessage {
string from = 1;
// content is the raw message content.
bytes content = 2;
}

// EVMGas is the gas fee settings for an EVM transaction.
Expand Down Expand Up @@ -314,24 +383,32 @@ message CreateSigningRequestRequest {
SuiSendCustom sui_send_custom = 13;
SolanaSendNative solana_send_native = 14;
SolanaSendSPLToken solana_send_spl_token = 15;
EVMMessage evm_message = 16;
AptosMessage aptos_message = 17;
SolanaMessage solana_message = 18;
RawMessage raw_message = 19;
}
// notes is the transaction notes for the signing request.
google.protobuf.StringValue notes = 1000;
// vault_uuid is the UUID of the vault that will sign the transaction.
// If it is from an api wallet, it must.
google.protobuf.StringValue vault_uuid = 1001;
google.protobuf.StringValue client_signer_public_key = 1002;
// callback_client_signer_public_key is the public key of the api client signer.
// If it is from an api wallet, it must.
google.protobuf.StringValue callback_client_signer_public_key = 1002;
}

message CreateSigningRequestResponse {
SigningRequest signing_request = 1;
mpcvault.rpc.v1.Status error = 2;
Error error = 2;
}

message RejectSigningRequestRequest {
string uuid = 1;
}

message RejectSigningRequestResponse {
mpcvault.rpc.v1.Status error = 1;
Error error = 1;
}

message GetSigningRequestDetailsRequest {
Expand All @@ -340,7 +417,7 @@ message GetSigningRequestDetailsRequest {

message GetSigningRequestDetailsResponse {
SigningRequest signing_request = 1;
mpcvault.rpc.v1.Status error = 2;
Error error = 2;
}

message SigningRequest {
Expand Down Expand Up @@ -377,9 +454,15 @@ message SigningRequest {
SolanaSendNative solana_send_native = 19;
SolanaSendSPLToken solana_send_spl_token = 20;
CreateWalletRequest create_wallet = 21;
EVMMessage evm_message = 22;
AptosMessage aptos_message = 23;
SolanaMessage solana_message = 24;
RawMessage raw_message = 25;
}
// If it is from an api wallet, it must.
google.protobuf.StringValue vault_uuid = 1000;
google.protobuf.StringValue client_signer_public_key = 1001;
// If it is from an api wallet, it must.
google.protobuf.StringValue callback_client_signer_public_key = 1001;
}

message BatchPaymentRecipient {
Expand Down Expand Up @@ -430,7 +513,7 @@ message CreateBatchPaymentRequest {

message CreateBatchPaymentResponse {
BatchPayment batch_payment = 1;
mpcvault.rpc.v1.Status error = 2;
Error error = 2;
}

message GetBatchPaymentDetailsRequest {
Expand All @@ -439,7 +522,7 @@ message GetBatchPaymentDetailsRequest {

message GetBatchPaymentDetailsResponse {
BatchPayment batch_payment = 1;
mpcvault.rpc.v1.Status error = 2;
Error error = 2;
}

message BatchPayment {
Expand Down
34 changes: 25 additions & 9 deletions mpcvault/platform/v1/error.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,30 @@ option java_multiple_files = true;
option java_outer_classname = "ServiceErrorProto";
option java_package = "com.mpcvault.platform.v1";


message ServiceError {
enum ErrorCode {
ERROR_CODE_UNSPECIFIED = 0;
ERROR_CODE_ORG_SUBSCRIBED_PLAN_LIMIT_EXCEED = 1;
ERROR_CODE_ORG_SUBSCRIBED_PLAN_EXPIRED = 2;
ERROR_CODE_ORG_SUBSCRIBED_PLAN_NOT_SUPPORT = 3;
message Error {
string message = 1;
oneof ErrorCode {
ServiceErrorCode service_error_code = 2;
ExecuteSigningRequestsErrorCode execute_signing_requests_error_code = 3;
}
ErrorCode error_code = 1;
string message = 2;
}

enum ServiceErrorCode {
// Enum unspecified.
SERVICE_ERROR_CODE_UNSPECIFIED = 0;
// Organization subscribed plan limit exceed
SERVICE_ERROR_CODE_ORG_SUBSCRIBED_PLAN_LIMIT_EXCEED = 1;
// Organization subscribed plan expired
SERVICE_ERROR_CODE_ORG_SUBSCRIBED_PLAN_EXPIRED = 2;
// Organization subscribed plan not support
SERVICE_ERROR_CODE_ORG_SUBSCRIBED_PLAN_NOT_SUPPORT = 3;
}

enum ExecuteSigningRequestsErrorCode {
// Enum unspecified.
EXECUTE_SIGNING_REQUESTS_ERROR_CODE_UNSPECIFIED = 0;
// Insufficient funds
EXECUTE_SIGNING_REQUESTS_ERROR_CODE_INSUFFICIENT_FUNDS = 1;
// Denied
EXECUTE_SIGNING_REQUESTS_ERROR_CODE_ALREADY_DENIED = 2;
}
Loading

0 comments on commit ec32643

Please sign in to comment.