Skip to content
Merged
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
4 changes: 2 additions & 2 deletions api/src/main/java/com/getcode/model/chat/MessageContent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,9 @@ sealed interface MessageContent {
proto: MessageContentV1,
): MessageContent? {
return when (proto.typeCase) {
ChatServiceV1.Content.TypeCase.LOCALIZED -> Localized(
ChatServiceV1.Content.TypeCase.SERVER_LOCALIZED -> Localized(
isFromSelf = false,
value = proto.localized.keyOrText
value = proto.serverLocalized.keyOrText
)

ChatServiceV1.Content.TypeCase.EXCHANGE_DATA -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ class TransactionRepository @Inject constructor(

expected?.diff(produced)
}
TransactionService.ErrorDetails.TypeCase.INTENT_DENIED -> {
errors.add("Denied: ${error.intentDenied.reason.name}")
TransactionService.ErrorDetails.TypeCase.DENIED -> {
errors.add("Denied: ${error.denied.reason}")
}
else -> Unit
}
Expand Down Expand Up @@ -765,8 +765,8 @@ sealed class ErrorSubmitIntent(val value: Int) {
return when (proto.code) {
SubmitIntentResponse.Error.Code.DENIED -> {
val reasons = proto.errorDetailsList.mapNotNull {
if (!it.hasIntentDenied()) return@mapNotNull null
DeniedReason.fromValue(it.intentDenied.reasonValue)
if (!it.hasDenied()) return@mapNotNull null
DeniedReason.fromValue(it.denied.codeValue)
}

Denied(reasons)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ private suspend fun TransactionRepository.submit(intent: SwapIntent): Result<Swa

expected?.diff(produced)
}
TransactionService.ErrorDetails.TypeCase.INTENT_DENIED -> {
errors.add("Denied: ${error.intentDenied.reason.name}")
TransactionService.ErrorDetails.TypeCase.DENIED -> {
errors.add("Denied: ${error.denied.reason}")
}
else -> Unit
}
Expand Down
38 changes: 38 additions & 0 deletions scripts/fetch-protos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

root=$(pwd)
REPO_URL="https://github.com/code-payments/code-protobuf-api"
COMMIT_SHA=$1
TEMP_DIR=$(mktemp -d)
DEST_DIR="service/protos/src/main/proto"

# Clone the repository
git clone "$REPO_URL" "$TEMP_DIR"

# Change to the cloned repository directory
cd "$TEMP_DIR" || exit

# If a commit SHA is provided, checkout that commit
if [ -n "$COMMIT_SHA" ]; then
git checkout "$COMMIT_SHA"
else
git checkout main
fi

# Create the destination directory if it doesn't exist
mkdir -p "../../$DEST_DIR"

# Copy proto files
if [ -d "proto" ]; then
rsync -av --exclude='buf*' proto/ "${root}/$DEST_DIR/"
echo "Proto files copied successfully."
else
echo "Error: 'proto' directory not found in the repository."
exit 1
fi

# Clean up: remove the temporary directory
cd ../..
rm -rf "$TEMP_DIR"

sh "${root}"/scripts/strip-proto-validation.sh
43 changes: 43 additions & 0 deletions scripts/strip-proto-validation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#
# For all .proto files, strip the validation parameters & replace inline
#

root=$(pwd)

# 1. hack: first add a couple newlines after all "];"
find "${root}"/service/protos/src/main/proto -name "*.proto" -type f -exec sh -c "awk '{gsub(/];/, \"];\n\n\"); print}' {} > tmp && mv tmp {}" \;

# 2. strip everything between square brackets [...] ignoring lines starting with //
find "${root}"/service/protos/src/main/proto -name "*.proto" -type f -exec sh -c "awk '!/^[[:space:]]*\/\// {gsub(/ \[.*\]/, \"\");} {print}' {} > tmp && mv tmp {}" \;

find "${root}"/service/protos/src/main/proto -name "*.proto" -type f | while read -r file; do
awk '
BEGIN { in_repeated = 0; buffer = "" }
{
if ($0 ~ /^[[:space:]]*(repeated|bytes|[A-Za-z0-9_]+).*=.*\[/) {
in_repeated = 1
buffer = $0
} else if (in_repeated) {
buffer = buffer " " $0
}

if (in_repeated && $0 ~ /;/) {
gsub(/\[.*\]/, "", buffer)
print buffer
in_repeated = 0
buffer = ""
} else if (!in_repeated && $0 !~ /^[[:space:]]*option[[:space:]]*\(validate\.required\)[[:space:]]*=[[:space:]]*true;/) {
print $0
}
}
' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
done

# 3. add a newline after all trailing } brackets
#find "${root}"/service/protos/src/main/proto -name "*.proto" -type f -exec sh -c "awk '{gsub(/}/, \"}\n\"); print}' {} > tmp && mv tmp {}" \;

# 4. strip validate import statement
find "${root}"/service/protos/src/main/proto -name "*.proto" -type f -exec sh -c "awk -v RS='' '{gsub(/import \"validate\/validate.proto\";/, \"\"); print}' {} > tmp && mv tmp {}" \;

# 5. add a newline after all trailing } brackets
#find "${root}"/service/protos/src/main/proto -name "*.proto" -type f -exec sh -c "awk '{gsub(/}/, \"}\n\"); print}' {} > tmp && mv tmp {}" \;
4 changes: 0 additions & 4 deletions service/protos/src/main/proto/badge/v1/badge_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ service Badge {
// ResetBadgeCount resets an owner account's app icon badge count back to zero
rpc ResetBadgeCount(ResetBadgeCountRequest) returns (ResetBadgeCountResponse);
}

message ResetBadgeCountRequest {
// The owner account to clear badge count
common.v1.SolanaAccountId owner = 1;
Expand All @@ -17,12 +16,9 @@ message ResetBadgeCountRequest {
// mechanism to the RPC.
common.v1.Signature signature = 2;
}

message ResetBadgeCountResponse {
Result result = 1;
enum Result {
OK = 0;
}

}

Loading