diff --git a/.proto/smart_contracts.proto b/.proto/smart_contracts.proto index e4473ad..2188ac5 100644 --- a/.proto/smart_contracts.proto +++ b/.proto/smart_contracts.proto @@ -1,225 +1,59 @@ -syntax = "proto3"; +syntax = "proto3"; -option csharp_namespace = "Swisschain.Sirius.Api.ApiContract.SmartContracts"; +option csharp_namespace = "Swisschain.Sirius.Api.ApiContract.V2.SmartContracts"; import "common.proto"; -import "smart_contracts.common.proto"; import "smart_connect.data_model.proto"; -import "smart_connect.metamodel.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; +import "smart_contracts.common.proto"; import "google/protobuf/wrappers.proto"; +import "google/protobuf/timestamp.proto"; -package swisschain.sirius.api.smart_contracts; - -service SmartContracts { - rpc Search (SmartContractSearchRequest) returns (SmartContractSearchResponse); - rpc GetCode (SmartContractGetCodeRequest) returns (SmartContractGetCodeResponse); - rpc Deploy (SmartContractDeployRequest) returns (SmartContractDeployResponse); - rpc Parse (SmartContractParseRequest) returns (SmartContractParseResponse); - rpc Estimate (SmartContractEstimateRequest) returns (SmartContractEstimateResponse); - rpc GetUpdates (SmartContractGetUpdatesRequest) returns (stream SmartContractGetUpdatesResponse); -} - -// Search - -message SmartContractSearchRequest { - google.protobuf.Int64Value smart_contract_id = 1; - google.protobuf.StringValue name = 2; - google.protobuf.StringValue address = 3; - google.protobuf.StringValue creator_address = 4; - google.protobuf.StringValue blockchain_id = 5; - google.protobuf.Int64Value broker_account_id = 6; - repeated SmartContractState state = 7; - api.common.PaginationInt64 pagination = 8; -} - -message SmartContractSearchResponse { - oneof result { - SmartContractSearchResponseBody body = 1; - api.common.ErrorResponseBody error = 2; - } -} - -message SmartContractSearchResponseBody { - api.common.PaginatedInt64Response pagination = 1; - repeated SmartContract items = 2; -} - -message SmartContract { - int64 id = 1; - string blockchain_id = 2; - string blockchain_name = 3; - string name = 4; - google.protobuf.StringValue address = 5; - SmartContractAddingWay adding_way = 6; - google.protobuf.Int64Value deployer_broker_account_id = 7; - google.protobuf.StringValue deployer_broker_account_name = 8; - google.protobuf.Int64Value deployer_broker_account_details_id = 9; - string creator_address = 10; - smart_contracts.common.Payment payment = 11; - repeated smart_connect.data_model.Argument arguments = 12; - SmartContractState state = 13; - api.common.TransactionInfo transaction_info = 14; - SmartContractDeploymentContext contract_deployment_context = 15; - google.protobuf.Int64Value deployment_operation_id = 16; - api.common.ValidatorContext validator_context = 17; - int64 sequence = 18; - smart_contracts.common.SmartContractError error = 19; - google.protobuf.Timestamp created_at = 20; - google.protobuf.Timestamp updated_at = 21; - repeated swisschain.sirius.api.common.Fee expectedFees = 24; - repeated swisschain.sirius.api.common.Fee actualFees = 25; -} - -// GetCode - -message SmartContractGetCodeRequest { - int64 smart_contract_id = 1; -} - -message SmartContractGetCodeResponse { - oneof result { - SmartContractGetCodeResponseBody body = 1; - api.common.ErrorResponseBody error = 2; - } -} - -message SmartContractGetCodeResponseBody { - bytes code = 1; -} - -// Deploy - -message SmartContractDeployRequest { - string request_id = 1; - string document = 2; - string signature = 3; - bytes code = 4; -} - -message SmartContractDeployResponse { - oneof result { - SmartContractDeployResponseBody body = 1; - api.common.ErrorResponseBody error = 2; - } -} - -message SmartContractDeployResponseBody { - SmartContract smart_contract = 1; -} - -// Parse - -message SmartContractParseRequest { - string blockchain_id = 1; - bytes code = 2; -} - -message SmartContractParseResponse { - oneof result { - SmartContractParseResponseBody body = 1; - api.common.ErrorResponseBody error = 2; - } -} - -message SmartContractParseResponseBody { - smart_connect.metamodel.SmartContractInfo metamodel = 1; -} - -// Estimate - -message SmartContractEstimateRequest { - string request_id = 1; - bytes code = 2; - string blockchain_id = 3; - int64 broker_account_id = 4; - repeated smart_connect.data_model.Argument arguments = 5; - smart_contracts.common.Payment payment = 6; -} - -message SmartContractEstimateResponse { - oneof body { - SmartContractEstimateResponseBody result = 1; - api.common.ErrorResponseBody error = 2; - } -} - -message SmartContractEstimateResponseBody { - api.common.Fee fee = 1; -} - -// GetUpdates +package swisschain.sirius.api.v2.smart_contracts; -message SmartContractGetUpdatesRequest { - google.protobuf.Int64Value smart_contract_id = 1; - google.protobuf.StringValue address = 2; - google.protobuf.StringValue blockchain_id = 3; - google.protobuf.Int64Value deployer_broker_account_id = 4; - NullableSmartContractState state = 5; - google.protobuf.Int64Value cursor = 6; - google.protobuf.StringValue stream_id = 7; +service SmartContractService { + rpc Invoke (SmartContractInvokeRequest) returns (SmartContractInvokeResponse); } -message SmartContractGetUpdatesResponse { - repeated SmartContractUpdate items = 1; +// Invoke +message SmartContractInvokeRequest { + string idempotency_id = 1; + SmartContractInvocationDocument document = 2; + bytes signature = 3; + int64 smart_contract_id = 4; + string name = 5; } -message SmartContractUpdate { - int64 id = 1; - int64 smart_contract_id = 2; - string blockchain_id = 3; - string blockchain_name = 4; - string name = 5; - google.protobuf.StringValue address = 6; - SmartContractAddingWay adding_way = 7; - google.protobuf.Int64Value deployer_broker_account_id = 8; - google.protobuf.StringValue deployer_broker_account_name = 9; - google.protobuf.Int64Value deployer_broker_account_details_id = 10; - string creator_address = 11; - smart_contracts.common.Payment payment = 12; - repeated smart_connect.data_model.Argument arguments = 13; - SmartContractState state = 14; - api.common.TransactionShortInfo transaction_info = 15; - SmartContractDeploymentContext contract_deployment_context = 16; - google.protobuf.Int64Value deployment_operation_id = 17; - api.common.ValidatorContext validator_context = 18; - int64 sequence = 19; - smart_contracts.common.SmartContractError error = 20; - google.protobuf.Timestamp created_at = 21; - google.protobuf.Timestamp updated_at = 22; +message SmartContractInvocationDocument { + int64 broker_account_id = 1; + string method_name = 2; + google.protobuf.StringValue method_address = 3; + repeated swisschain.sirius.api.smart_connect.data_model.Argument arguments = 4; + swisschain.sirius.api.smart_contracts.common.Payment payment = 5; + google.protobuf.StringValue reference_id = 6; + map properties = 7; } -// Common - -enum SmartContractState { - PROCESSING = 0; - VALIDATING = 1; - SIGNING = 2; - SENT = 3; - ON_CHAIN = 4; - COMPLETED = 5; - FAILED = 6; - REJECTED = 7; - OUT_OF_GAS = 8; +message SmartContractInvokeResponse { + oneof kind { + SmartContractInvokePayload payload = 1; + SmartContractInvokeError error = 2; + } } -message NullableSmartContractState { - oneof kind { - google.protobuf.NullValue null = 1; - SmartContractState state = 2; - } +message SmartContractInvokePayload { + int64 id = 1; } -enum SmartContractAddingWay { - DEPLOYMENT = 0; - REGISTRATION = 1; -} +message SmartContractInvokeError { + enum ErrorCode { + UNKNOWN = 0; + INVALID_PARAMETERS = 1; + DOMAIN_PROBLEM = 2; + TECHNICAL_PROBLEM = 3; + NOT_AUTHORIZED = 4; + NOT_ENOUGH_BALANCE = 5; + } -message SmartContractDeploymentContext { - google.protobuf.StringValue reference_id = 1; - string document = 2; - string signature = 3; - string code_hash = 4; - api.common.RequestContext request_context = 5; + ErrorCode code = 1; + string message = 2; } diff --git a/.proto/withdrawals.proto b/.proto/withdrawals.proto index 120abff..8c43c7f 100644 --- a/.proto/withdrawals.proto +++ b/.proto/withdrawals.proto @@ -1,236 +1,62 @@ syntax = "proto3"; -option csharp_namespace = "Swisschain.Sirius.Api.ApiContract.Withdrawal"; +option csharp_namespace = "Swisschain.Sirius.Api.ApiContract.V2.Withdrawals"; -import "aml.proto"; import "common.proto"; -import "google/protobuf/timestamp.proto"; import "google/protobuf/wrappers.proto"; -package swisschain.sirius.api.withdrawals; +package swisschain.sirius.api.v2.withdrawals; -service Withdrawals { - rpc Search (WithdrawalSearchRequest) returns (WithdrawalSearchResponse); +service WithdrawalService { rpc Execute (WithdrawalExecuteRequest) returns (WithdrawalExecuteResponse); - rpc GetUpdates (WithdrawalUpdateSearchRequest) returns (stream WithdrawalUpdateArrayResponse); - rpc Estimate(WithdrawalEstimateRequest) returns (EstimateTransactionResponse); } -// Search - -message WithdrawalSearchRequest { - google.protobuf.Int64Value id = 1; - google.protobuf.Int64Value broker_account_id = 2; - google.protobuf.Int64Value account_id = 3; - google.protobuf.Int64Value asset_id = 4; - google.protobuf.StringValue blockchain_id = 5; - repeated WithdrawalState state = 6; - google.protobuf.StringValue transaction_id = 7; - repeated WithdrawalErrorCode error_code = 8; - google.protobuf.Int64Value operation_id = 9; - google.protobuf.StringValue destination_address = 10; - google.protobuf.StringValue destination_tag = 11; - swisschain.sirius.api.common.NullableTagType destination_tag_type = 12; - swisschain.sirius.api.common.PaginationInt64 pagination = 13; - google.protobuf.StringValue account_reference_id = 14; - google.protobuf.Int64Value user_id = 15; - google.protobuf.StringValue user_native_id = 16; -} - -message WithdrawalSearchResponse { - oneof result { - WithdrawalSearchResponseBody body = 1; - swisschain.sirius.api.common.ErrorResponseBody error = 2; - } -} - -message WithdrawalSearchResponseBody { - swisschain.sirius.api.common.PaginatedInt64Response pagination = 1; - repeated WithdrawalResponse items = 2; -} - -// Execute - message WithdrawalExecuteRequest { - string request_id = 1; - // JSON: version; brokerAccountId; accountId; assetId; amount; destinationDetails; accountReferenceId; withdrawalReferenceId; userNativeId - string document = 2; - string signature = 3; -} - -message WithdrawalExecuteResponse { - oneof result { - WithdrawalExecuteResponseBody body = 1; - WithdrawalExecuteErrorResponseBody error = 2; - } -} - -message WithdrawalExecuteResponseBody { - WithdrawalResponse withdrawal = 1; -} - -message WithdrawalExecuteErrorResponseBody { - - enum ErrorCode { - UNKNOWN = 0; - INVALID_PARAMETERS = 1; - IS_NOT_AUTHORIZED = 2; - NOT_FOUND = 3; - NOT_ENOUGH_BALANCE = 4; - INVALID_ADDRESS = 5; - AMOUNT_IS_TOO_LOW = 6; - } - - ErrorCode error_code = 1; - string error_message = 2; -} - -// GetUpdates - -message WithdrawalUpdateSearchRequest { - google.protobuf.Int64Value withdrawal_id = 1; - google.protobuf.Int64Value broker_account_id = 2; - google.protobuf.Int64Value account_id = 3; - google.protobuf.Int64Value asset_id = 4; - google.protobuf.StringValue blockchain_id = 5; - repeated WithdrawalState state = 6; - google.protobuf.StringValue transaction_id = 7; - repeated WithdrawalErrorCode error_code = 8; - google.protobuf.Int64Value operation_id = 9; - google.protobuf.StringValue destination_address = 10; - google.protobuf.StringValue destination_tag = 11; - swisschain.sirius.api.common.NullableTagType destination_tag_type = 12; - google.protobuf.Int64Value withdrawal_update_id = 13; - google.protobuf.Int64Value cursor = 14; - google.protobuf.StringValue account_reference_id = 15; - google.protobuf.Int64Value user_id = 16; - google.protobuf.StringValue user_native_id = 17; - google.protobuf.StringValue stream_id = 18; + string idempotency_id = 1; + WithdrawalDocument document = 2; + bytes signature = 3; } -message WithdrawalUpdateArrayResponse { - repeated WithdrawalUpdateResponse items = 1; -} - -message WithdrawalUpdateResponse { - int64 withdrawal_update_id = 1; - WithdrawalResponse withdrawal = 2; -} - -// Common - -enum WithdrawalState { - PROCESSING = 0; - EXECUTING = 1; - SENT = 2; - COMPLETED = 3; - FAILED = 4; - POLICY_VALIDATION = 5; - SIGNING = 6; - REJECTED = 7; - AML_VALIDATION = 8; - AML_FAILED = 9; - AML_REVIEWED = 10; - NOTIFYING_AML = 11; - REFUNDED = 12; - AML_FAILURE_ACCEPTING = 13; - ON_CHAIN = 14; - ESTIMATING = 15; - OUT_OF_GAS = 16; +message WithdrawalDocument { + map properties = 1; + int64 asset_id = 2; + int64 broker_account_id = 3; + DestinationDetails destination_details = 4; + swisschain.sirius.api.common.BigDecimal amount = 5; + swisschain.sirius.api.common.FeePayer fee_payer = 6; } message DestinationDetails { - string address = 1; - google.protobuf.StringValue tag = 2; - swisschain.sirius.api.common.NullableTagType tag_type = 3; + string address = 1; + DestinationTag destination_tag = 2; } -enum WithdrawalErrorCode { - NOT_ENOUGH_BALANCE = 0; - INVALID_DESTINATION_ADDRESS = 1; - DESTINATION_TAG_REQUIRED = 2; - TECHNICAL_PROBLEM = 3; - VALIDATION_REJECTED = 4; - SIGNING_REJECTED = 5; - AMOUNT_IS_TOO_SMALL = 6; - FEE_LIMIT_EXCEEDED = 7; - TRANSACTION_EXPIRED = 8; - FEE_TOO_LOW = 9; - INVALID_PARAMETERS = 10; -} - -message WithdrawalError { - WithdrawalErrorCode code = 1; - string message = 2; +message DestinationTag { + google.protobuf.StringValue value = 2; + swisschain.sirius.api.common.TagType type = 3; } -message WithdrawalResponse { - int64 id = 1; - int64 broker_account_id = 2; - string broker_account_name = 3; - swisschain.sirius.api.common.BrokerAccountDetails broker_account_details = 4; - google.protobuf.Int64Value account_id = 5; - google.protobuf.StringValue account_reference_id = 7; - int64 asset_id = 8; - - google.protobuf.StringValue asset_address = 10; - swisschain.sirius.api.common.BigDecimal amount = 11; - string blockchain_id = 12; - string blockchain_name = 13; - repeated swisschain.sirius.api.common.Fee actualFees = 14; - DestinationDetails destination_details = 15; - WithdrawalState state = 16; - swisschain.sirius.api.common.TransactionInfo transaction_info = 17; - WithdrawalError error = 18; - google.protobuf.Int64Value operation_id = 19; - int64 required_confirmations_count = 20; - TransferContext transfer_context = 21; - ValidatorContext validator_context = 22; - google.protobuf.Timestamp created_at = 23; - google.protobuf.Timestamp updated_at = 24; - google.protobuf.Int64Value user_id = 25; - google.protobuf.StringValue user_native_id = 26; - swisschain.sirius.api.aml.AmlChecks aml_checks = 27; - repeated swisschain.sirius.api.common.Fee expectedFees = 28; - swisschain.sirius.api.common.FeePayer fee_payer = 29; -} - -message TransferContext { - google.protobuf.StringValue account_reference_id = 1; - google.protobuf.StringValue withdrawal_reference_id = 2; - google.protobuf.StringValue document = 3; - google.protobuf.StringValue signature = 4; - RequestContext request_context = 5; -} - -message RequestContext { - google.protobuf.StringValue user_id = 1; - google.protobuf.StringValue api_key_id = 2; - google.protobuf.StringValue ip = 3; - google.protobuf.Timestamp timestamp = 4; -} - -message ValidatorContext { - google.protobuf.StringValue document = 1; - google.protobuf.StringValue signature = 2; +message WithdrawalExecuteResponse { + oneof result { + WithdrawalExecutePayload payload = 1; + WithdrawalExecuteError error = 2; + } } -message WithdrawalEstimateRequest { - string request_id = 1; - int64 broker_account_id = 2; - int64 asset_id = 3; - swisschain.sirius.api.common.BigDecimal amount = 4; - DestinationDetails destination_details = 5; - swisschain.sirius.api.common.FeePayer fee_payer = 6; +message WithdrawalExecutePayload { + int64 id = 1; } -message EstimateTransactionResponse { - oneof body { - EstimateTransactionResponseBody result = 1; - swisschain.sirius.api.common.ErrorResponseBody error = 2; +message WithdrawalExecuteError { + enum ErrorCode { + UNKNOWN = 0; + INVALID_PARAMETERS = 1; + DOMAIN_PROBLEM = 2; + TECHNICAL_PROBLEM = 3; + NOT_AUTHORIZED = 4; + NOT_ENOUGH_BALANCE = 5; } -} -message EstimateTransactionResponseBody { - swisschain.sirius.api.common.Fee fee = 1; + ErrorCode code = 1; + string message = 2; } \ No newline at end of file