-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LIVE-2853] Fix claim reward cosmos (#1121)
- Loading branch information
1 parent
df76dd2
commit b4be83a
Showing
7 changed files
with
292 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@ledgerhq/live-common": minor | ||
--- | ||
|
||
Fix cosmos claim reward operations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: "[Bot] 'Cosmos on Phosphore'" | ||
on: | ||
push: | ||
branches: | ||
- feat/cosmos | ||
|
||
concurrency: | ||
group: bot-seed6-cosmos | ||
|
||
jobs: | ||
start-runner: | ||
name: "start ec2 instance (Linux)" | ||
if: ${{ always() }} | ||
uses: ledgerhq/actions/.github/workflows/start-linux-runner.yml@main | ||
secrets: | ||
CI_BOT_TOKEN: ${{ secrets.CI_BOT_TOKEN }} | ||
|
||
stop-runner: | ||
name: "stop ec2 instance (Linux)" | ||
needs: [start-runner, run-bot] | ||
uses: ledgerhq/actions/.github/workflows/stop-linux-runner.yml@main | ||
if: ${{ always() }} | ||
with: | ||
label: ${{ needs.start-runner.outputs.label }} | ||
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }} | ||
secrets: | ||
CI_BOT_TOKEN: ${{ secrets.CI_BOT_TOKEN }} | ||
|
||
run-bot: | ||
runs-on: ${{ needs.start-runner.outputs.label }} | ||
needs: [start-runner] | ||
steps: | ||
- name: prepare runner | ||
run: | | ||
sudo growpart /dev/nvme0n1 1 | ||
sudo resize2fs /dev/nvme0n1p1 | ||
- uses: actions/checkout@v3 | ||
- name: Retrieving coin apps | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ledger-live-bot | ||
repository: LedgerHQ/coin-apps | ||
token: ${{ secrets.GH_PAT }} | ||
path: coin-apps | ||
- uses: ./tools/actions/composites/bot | ||
id: bot | ||
timeout-minutes: 120 | ||
with: | ||
SEED: ${{ secrets.SEED6 }} | ||
SLACK_API_TOKEN: ${{secrets.SLACK_API_TOKEN}} | ||
SLACK_ICON_EMOJI: ":bot-seed6:" | ||
SLACK_CHANNEL: ci-atom-ll | ||
BOT_FILTER_FAMILY: cosmos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
type Message = { | ||
type: string; | ||
attributes: { [key: string]: any }; | ||
}; | ||
|
||
export const getMainMessage = (messages: Message[]): Message => { | ||
const messagePriorities: string[] = [ | ||
"withdraw_rewards", | ||
"unbond", | ||
"redelegate", | ||
"delegate", | ||
"transfer", | ||
]; | ||
const sortedTypes = messages | ||
.filter((m) => messagePriorities.includes(m.type)) | ||
.sort( | ||
(a, b) => | ||
messagePriorities.indexOf(a.type) - messagePriorities.indexOf(b.type) | ||
); | ||
return sortedTypes[0]; | ||
}; |
63 changes: 63 additions & 0 deletions
63
libs/ledger-live-common/src/families/cosmos/helpers.unit.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { getMainMessage } from "./helpers"; | ||
|
||
describe("getMainMessage", () => { | ||
it("should return reward message with delegate and reward messages (claim rewards, compound)", () => { | ||
const exec = getMainMessage([ | ||
{ | ||
type: "delegate", | ||
attributes: {}, | ||
}, | ||
{ | ||
type: "withdraw_rewards", | ||
attributes: {}, | ||
}, | ||
]); | ||
expect(exec.type).toEqual("withdraw_rewards"); | ||
}); | ||
|
||
it("should return unbond message with unbound and transfer messages", () => { | ||
expect( | ||
getMainMessage([ | ||
{ | ||
type: "unbond", | ||
attributes: {}, | ||
}, | ||
{ | ||
type: "transfer", | ||
attributes: {}, | ||
}, | ||
]).type | ||
).toEqual("unbond"); | ||
}); | ||
|
||
it("should return first transfer message with multiple transfer messages", () => { | ||
const firstTransfer = { | ||
type: "transfer", | ||
attributes: {}, | ||
}; | ||
expect( | ||
getMainMessage([ | ||
firstTransfer, | ||
{ | ||
type: "transfer", | ||
attributes: {}, | ||
}, | ||
]) | ||
).toEqual(firstTransfer); | ||
}); | ||
|
||
it("should return redelegate message with delegate/redelegate messages", () => { | ||
expect( | ||
getMainMessage([ | ||
{ | ||
type: "delegate", | ||
attributes: {}, | ||
}, | ||
{ | ||
type: "redelegate", | ||
attributes: {}, | ||
}, | ||
]).type | ||
).toEqual("redelegate"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
b4be83a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⏲ 10min 32s ✅ 4 txs ❌ 2 txs⚠️ 1 specs ($51.57) for [Bot] Ethereum on Staging
1 critical spec errors
Spec Polygon failed!
❌ 2 mutation errors
Portfolio ($51.57) – Details of the 5 currencies
Performance ⏲ 10min 32s
Time spent for each spec: (total across mutations)
b4be83a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⏲ 22min 38s ✅ 80 txs ❌ 5 txs⚠️ 3 specs ($340.40) for [Bot] 'Phosphore'
3 critical spec errors
Spec ZCash failed!
Spec cardano failed!
Spec Solana failed!
❌ 5 mutation errors
Portfolio ($340.40) – Details of the 43 currencies
Performance ⏲ 22min 38s
Time spent for each spec: (total across mutations)
b4be83a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⏲ 5min 32s ✅ 35 txs ❌ 4 txs⚠️ 1 specs ($56.21) for [Bot] Bitcoin on Staging
1 critical spec errors
Spec ZCash failed!
❌ 4 mutation errors
Portfolio ($56.21) – Details of the 17 currencies
Performance ⏲ 5min 32s
Time spent for each spec: (total across mutations)