Skip to content

Commit

Permalink
Merge branch 'main' into feature/TRA-312-update-margin-mode-when-data…
Browse files Browse the repository at this point in the history
…-comes-in

# Conflicts:
#	build.gradle.kts
#	src/commonMain/kotlin/exchange.dydx.abacus/calculator/TradeInputCalculator.kt
#	v4_abacus.podspec
  • Loading branch information
ruixhuang committed Jun 3, 2024
2 parents f810340 + 7eb2bd4 commit b98a8f1
Show file tree
Hide file tree
Showing 76 changed files with 2,613 additions and 1,569 deletions.
114 changes: 100 additions & 14 deletions .github/workflows/bump_version.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,117 @@
name: Bump version on PR merge
name: Bump version
on:
pull_request:
branches:
- main
types: closed
pull_request_target:
types: [opened, synchronize, reopened]

permissions:
contents: write

jobs:
update_version:
if: github.event.pull_request.merged == true
#if: github.event.pull_request.merged == true
runs-on: macos-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
# Fetch full depth, otherwise the last step overwrites the last commit's parent, essentially removing the graph.
fetch-depth: 0
token: ${{ secrets.BOT_PAT }}
ref: ${{ github.head_ref }}

- name: Run bump_version_gh_action.sh
- name: Bump version if needed
id: bump-version
run: |
bash ./bump_version_gh_action.sh
- name: Amend the last commit
set +e
vercomp () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
return 1
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
return 2
fi
done
return 0
}
# Defining a temporary directory for cloning
TMP_DIR=$(mktemp -d)
curl https://raw.githubusercontent.com/dydxprotocol/v4-abacus/main/build.gradle.kts > $TMP_DIR/build.gradle.kts
# search for the first line that starts with "version" in build.gradle.kts
# get the value in the quotes
VERSION=$(grep "^version = " build.gradle.kts | sed -n 's/version = "\(.*\)"/\1/p')

REPO_VERSION=$(grep "^version = " $TMP_DIR/build.gradle.kts | sed -n 's/version = "\(.*\)"/\1/p')

# call the version comparison function

vercomp $REPO_VERSION $VERSION
case $? in
0) SHOULD_BUMP=true ;;
1) SHOULD_BUMP=true ;;
2) SHOULD_BUMP=false ;;
esac

if [ $SHOULD_BUMP == false ]; then
echo "Repo version < PR version... No need to bump."
echo "bump_version_ret=-1" >> $GITHUB_OUTPUT
exit 0
fi

# increment the version number
NEW_VERSION=$(echo $VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')

#if NEW_VERSION is not empty, replace the version in build.gradle.kts
if [ -n "$NEW_VERSION" ]; then
sed -i '' "s/version = \"$VERSION\"/version = \"$NEW_VERSION\"/" build.gradle.kts
echo "Version bumped to $NEW_VERSION"
fi
echo "bump_version_ret=0" >> $GITHUB_OUTPUT

- name: Import bot's GPG key for signing commits
id: import-gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.BOT_GPG_PASSPHRASE }}
#git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true

- name: Sign commit and push changes
run: |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "${GITHUB_ACTOR}"
git commit -a --amend --no-edit
git push --force-with-lease
echo "Complete"
if [[ "${{ steps.bump-version.outputs.bump_version_ret }}" == "0" ]]; then
git config --global user.email ${{ steps.import-gpg.outputs.name }}
git config --global user.name ${{ steps.import-gpg.outputs.email }}
git commit -S -m "Bump version" build.gradle.kts
git push
fi
env:
# GITHUB_TOKEN: ${{ secrets.BOT_PAT }}
GIT_AUTHOR_NAME: ${{ steps.import-gpg.outputs.name }}
GIT_AUTHOR_EMAIL: ${{ steps.import-gpg.outputs.email }}
GIT_COMMITTER_NAME: ${{ steps.import-gpg.outputs.name }}
GIT_COMMITTER_EMAIL: ${{ steps.import-gpg.outputs.email }}
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ allprojects {
}

group = "exchange.dydx.abacus"
version = "1.7.34"
version = "1.7.49"

repositories {
google()
Expand Down
14 changes: 0 additions & 14 deletions bump_version_gh_action.sh

This file was deleted.

2 changes: 1 addition & 1 deletion detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ complexity:
LargeClass:
threshold: 1000 # up from 600
LongMethod:
threshold: 100 # up from 60
active: false
TooManyFunctions:
active: false
NestedBlockDepth:
Expand Down
2 changes: 1 addition & 1 deletion docs/Account.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ Order status

## timeInForce

Time in force, GTT (Good Til Time), IOC (Immediate or Cancel) or FOK (Fill or Kill)
Time in force, GTT (Good Til Time) or IOC (Immediate or Cancel)

## marketId

Expand Down
79 changes: 77 additions & 2 deletions docs/Input/TransferInput.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ data class TransferInput(
&emsp;val fee: Double?,
&emsp;val chain: String?,
&emsp;val address: String?,
&emsp;val memo: String?,
&emsp;val depositOptions: DepositInputOptions?,
&emsp;val withdrawalOptions: WithdrawalInputOptions?,
&emsp;val transferOutOptions: TransferOutInputOptions?,
&emsp;val summary: TransferInputSummary?,
&emsp;val resources: TransferInputResources?,
&emsp;val requestPayload: TransferInputRequestPayload?
Expand Down Expand Up @@ -39,10 +42,22 @@ Selected chain to perform the transfer

Selected token address of the chain to perform the transfer

## memo

Memo for transfer

## depositOptions

structure of [DepositInputOptions](#DepositInputOptions)

## withdrawalOptions

structure of [WithdrawalInputOptions](#WithdrawalInputOptions)

## transferOutOptions

structure of [TransferOutInputOptions](#TransferOutInputOptions)

## summary

structure of [TransferInputSummary](#TransferInputSummary)
Expand Down Expand Up @@ -80,6 +95,66 @@ UX should let the user choose whether to use fast speed

Option of assets to choose from

# WithdrawalInputOptions

data class DepositInputOptions(
&emsp;val needsSize: Boolean?,
&emsp;val needsAddress: Boolean?,
&emsp;val needsFastSpeed: Boolean?,
&emsp;val exchanges: Array<SelectionOption>?
&emsp;val chains: Array<SelectionOption>?
&emsp;val assets: Array<SelectionOption>?
)

## needsSize

UX should let user enter the size

## needsAddress

UX should let user enter a wallet address

## needsFastSpeed

UX should let the user choose whether to use fast speed

## exchanges

Option of exchanges to choose from

## chains

Option of chains to choose from

## assets

Option of assets to choose from

# TransferOutInputOptions

data class TransferOutInputOptions(
&emsp;val needsSize: Boolean?,
&emsp;val needsAddress: Boolean?,
&emsp;val chains: Array<SelectionOption>?,
&emsp;val assets: Array<SelectionOption>?
)

## needsSize

UX should let user enter the size

## needsAddress

UX should let user enter a wallet address

## chains

Option of chains to choose from

## assets

Option of assets to choose from

# TransferInputSummary

data class TransferInputSummary(
Expand All @@ -102,7 +177,7 @@ Whether the transfer transaction can be filled

# TransferInputResources

The chain and token resources of the selected chain and its associated tokens. Use the chainId
The chain and token resources of the selected chain and its associated tokens. Use the chainId
and token address of the key to the maps, respectively, to get the resource.

data class TransferInputResources(
Expand Down Expand Up @@ -147,4 +222,4 @@ data class TransferInputRequestPayload(
&emsp;val gasPrice: String?,
&emsp;val maxFeePerGas: String?,
&emsp;val maxPriorityFeePerGas: String?
)
)
Loading

0 comments on commit b98a8f1

Please sign in to comment.