Skip to content

Commit

Permalink
Fix build and add CI step for verifying build (#57)
Browse files Browse the repository at this point in the history
* Add more data to borrow tx

* Fix conversions

* More fixes

* Remove import

* ci: build job to CI

* fix: invalid var names

* ci: job name
  • Loading branch information
hieronx authored Sep 10, 2023
1 parent 7f36f6a commit 4601a99
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,30 @@ concurrency:
cancel-in-progress: true

jobs:
build:
name: 'Check Build'
runs-on: ubuntu-latest
env:
SUBQL_INDEXER_VERSION: v1.21.1
SUBQL_QUERY_VERSION: v1.11.0
CHAIN_ID: development
steps:
- name: Check out repo's default branch
uses: actions/checkout@v3
- name: Generate new project.yaml
run: yq ". *= load(\"chains/$CHAIN_ID.yaml\")" chains/base.yaml > project.yaml
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: npm
- name: Setup Yarn
run: yarn install --frozen-lockfile
- name: Codegen
run: yarn codegen
- name: Build
run: yarn build

lint:
name: 'Run Linter'
runs-on: ubuntu-latest
Expand Down
8 changes: 4 additions & 4 deletions src/mappings/handlers/loansHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ async function _handleLoanBorrowed(event: SubstrateEvent<LoanBorrowedEvent>): Pr

export const handleLoanRepaid = errorHandler(_handleLoanRepaid)
async function _handleLoanRepaid(event: SubstrateEvent<LoanRepaidEvent>) {
const [poolId, loanId, { principal, interestAmount, unscheduledAmount }] = event.event.data
const [poolId, loanId, { principal, interest, unscheduled }] = event.event.data
const principalAmount = principal.isInternal
? principal.asInternal
: principal.asExternal.quantity.mul(principal.asExternal.settlementPrice)
const amount = principalAmount.add(interestAmount).add(unscheduledAmount).toString()
const amount = principalAmount.add(interest).add(unscheduled).toString()

logger.info(`Loan repaid event for pool: ${poolId.toString()} amount: ${amount.toString()}`)

Expand All @@ -149,8 +149,8 @@ async function _handleLoanRepaid(event: SubstrateEvent<LoanRepaidEvent>) {
timestamp: event.block.timestamp,
amount: BigInt(amount),
principalAmount: BigInt(principalAmount.toString()),
interestAmount: BigInt(interestAmount.toString()),
unscheduledAmount: BigInt(unscheduledAmount.toString()),
interestAmount: BigInt(interest.toString()),
unscheduledAmount: BigInt(unscheduled.toString()),
quantity: principal.isExternal ? BigInt(principal.asExternal.quantity.toString()) : null,
settlementPrice: principal.isExternal ? BigInt(principal.asExternal.settlementPrice.toString()) : null,
})
Expand Down

0 comments on commit 4601a99

Please sign in to comment.