Skip to content

Commit

Permalink
Merge pull request #33 from Assassyn/fix/active-key-operation-stoped-…
Browse files Browse the repository at this point in the history
…working

Fix/active key operation stopped working
  • Loading branch information
Assassyn committed Jun 2, 2023
2 parents bc26e0f + b17b764 commit a6aa860
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trigger:
pool:
vmImage: ubuntu-latest

name: 0.9.0-$(Rev:r)
name: 0.9.1-$(Rev:r)

stages:
- stage: BuildAndTest
Expand Down
20 changes: 12 additions & 8 deletions src/Functional.UniversalBot.Hive/Hive.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ open System

type HiveUrl = string

[<Literal>]
let useActiveKey = true

[<Literal>]
let usePostingKey = true

let private setToUserNameWhenTrue username isTrue =
match isTrue with
| true -> [| username |]
Expand All @@ -18,12 +24,6 @@ let private createCustomJson username activeKey postingKey methodName json =
required_auths = setToUserNameWhenTrue username activeKey,
required_posting_auths = setToUserNameWhenTrue username postingKey)

let createCustomJsonActiveKey username methodName json =
createCustomJson username true false methodName json

let createCustomJsonPostingKey username methodName json =
createCustomJson username false true methodName json

let brodcastTransactions hiveUrl operations key =
let hive = new CHived(new HttpClient(), hiveUrl)
operations
Expand All @@ -33,6 +33,10 @@ let brodcastTransactions hiveUrl operations key =
System.Threading.Thread.Sleep (3 |> TimeSpan.FromSeconds)
transactionId)

let buildCustomJson username method payload =
let buildActiveKeyedCustomJson username method payload =
let json = System.Text.Json.JsonSerializer.Serialize (payload)
createCustomJson username useActiveKey (not usePostingKey) method json

let buildPostingKeyedCustomJson username method payload =
let json = System.Text.Json.JsonSerializer.Serialize (payload)
createCustomJsonPostingKey username method json
createCustomJson username (not useActiveKey) usePostingKey method json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let private scheduleTokenToPoolTransfer username tokenPair baseQuantity quoteQua
maxSlippage = "1"
maxDeviation = "0"
|}
|> buildCustomJson username "ssc-mainnet-hive"
|> buildActiveKeyedCustomJson username "ssc-mainnet-hive"
|> scheduleActiveOperation ModuleName tokenPair

let action hive hiveEngineUrl tokenPair leftAmountCalculator rightAmountCalculator username (entity: PipelineProcessData<UniversalHiveBotResutls>) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let action tokenSymbol delegateTo amountCalcualtor username (entity: PipelinePro
if tokenBalance > 0M
then
bindCustomJson "tokens" "delegate" {|``to`` = delegateTo;symbol = tokenSymbol;quantity = String.asString tokenBalance|}
|> buildCustomJson username "ssc-mainnet-hive"
|> buildActiveKeyedCustomJson username "ssc-mainnet-hive"
|> scheduleActiveOperation ModuleName tokenSymbol
|> withResult entity
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let action hive hiveEngineUrl tokenSymbol amountCalcualtor username (entity: Pip
then
let tokenPrice = getTokenPrice hiveEngineUrl tokenSymbol amountToSell
bindCustomJson "market" "sell" {| symbol = tokenSymbol; quantity = String.asString amountToSell; price = String.asString tokenPrice; |}
|> buildCustomJson username "ssc-mainnet-hive"
|> buildActiveKeyedCustomJson username "ssc-mainnet-hive"
|> scheduleActiveOperation ModuleName tokenSymbol
|> withResult entity
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let action tokenSymbol amountCalcualtor username (entity: PipelineProcessData<Un
if tokenBalance > 0M
then
bindCustomJson "tokens" "stake" {| ``to`` = username;symbol = tokenSymbol;quantity = String.asString tokenBalance|}
|> buildCustomJson username "ssc-mainnet-hive"
|> buildActiveKeyedCustomJson username "ssc-mainnet-hive"
|> scheduleActiveOperation ModuleName tokenSymbol
|> withResult entity
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let action hive hiveEngineUrl tokenPair tokenSymbol maxSlippage amountToSwapCalc
if amountToSwap > 0M
then
bindCustomJson "marketpools" "swapTokens" {| tokenPair = tokenPair; tokenSymbol = tokenSymbol; tokenAmount = String.asString amountToSwap; tradeType = "exactInput"; maxSlippage = maxSlippage |}
|> buildCustomJson username "ssc-mainnet-hive"
|> buildActiveKeyedCustomJson username "ssc-mainnet-hive"
|> scheduleActiveOperation ModuleName tokenSymbol
|> withResult entity
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let action tokenSymbol transferTo amountCalcualtor memo username (entity: Pipeli
if tokenBalance > 0M
then
bindCustomJson "tokens" "transfer" {| ``to`` = transferTo;symbol = tokenSymbol;quantity = String.asString tokenBalance; memo = memo|}
|> buildCustomJson username "ssc-mainnet-hive"
|> buildActiveKeyedCustomJson username "ssc-mainnet-hive"
|> scheduleActiveOperation ModuleName tokenSymbol
|> withResult entity
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let action tokenSymbol undelegateFrom amountCalcualtor username (entity: Pipelin
if tokenBalance > 0M
then
bindCustomJson "tokens" "undelegate" {|from = undelegateFrom;symbol = tokenSymbol;quantity = String.asStringWithPrecision tokenBalance|}
|> buildCustomJson username "ssc-mainnet-hive"
|> buildActiveKeyedCustomJson username "ssc-mainnet-hive"
|> scheduleActiveOperation ModuleName tokenSymbol
|> withResult entity
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let action tokenSymbol amountCalcualtor username (entity: PipelineProcessData<Un
if tokenBalance > 0M
then
bindCustomJson "tokens" "unstake" {|symbol = tokenSymbol;quantity = String.asString tokenBalance|}
|> buildCustomJson username "ssc-mainnet-hive"
|> buildActiveKeyedCustomJson username "ssc-mainnet-hive"
|> scheduleActiveOperation ModuleName tokenSymbol
|> withResult entity
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let action amountCalcualtor username (entity: PipelineProcessData<UniversalHiveB
if scrapBalance > 0M
then
{| ``tx-hash`` = String.generateRandomString 22;amount = String.asString scrapBalance |}
|> buildCustomJson username "terracore_claim"
|> buildPostingKeyedCustomJson username "terracore_claim"
|> schedulePostingOperation ModuleName tokenSymbol
|> withResult entity
else
Expand Down

0 comments on commit a6aa860

Please sign in to comment.