Skip to content

Commit

Permalink
Merge pull request #73 from blend-capital/load-empty-backstop
Browse files Browse the repository at this point in the history
Load empty backstop
  • Loading branch information
mootz12 authored Oct 29, 2024
2 parents a4e811d + 8cb8e11 commit d7b0e77
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 14 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/npm_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run build
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Tests

on:
push:
branches: [ main ]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Run tests
run: npm run test
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blend-capital/blend-sdk",
"version": "2.1.0",
"version": "2.1.1",
"description": "Javascript SDK for the Blend Protocol",
"type": "module",
"scripts": {
Expand Down
5 changes: 1 addition & 4 deletions src/backstop/backstop_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class BackstopPool {

let emission_config: EmissionConfig | undefined;
let emission_data: EmissionData | undefined;
let poolBalance: PoolBalance | undefined;
let poolBalance = new PoolBalance(BigInt(0), BigInt(0), BigInt(0));
let toGulpEmissions = BigInt(0);
for (const entry of backstopPoolDataEntries.entries) {
const ledgerData = entry.val;
Expand All @@ -62,9 +62,6 @@ export class BackstopPool {
}
}

if (poolBalance == undefined) {
throw new Error('Error: Unable to load backstop pool data');
}
let emissions: Emissions | undefined;
if (emission_config != undefined && emission_data != undefined) {
emissions = new Emissions(
Expand Down
6 changes: 2 additions & 4 deletions src/backstop/backstop_user_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class UserBalance {
throw Error('UserBalance contract data value is not a map');
}

let shares: bigint | undefined;
let shares = BigInt(0);
const q4w: Q4W[] = [];
let unlockedQ4W = BigInt(0);
let totalQ4W = BigInt(0);
Expand Down Expand Up @@ -93,9 +93,7 @@ export class UserBalance {
throw Error(`Invalid backstop UserBalance key: should not contain ${key}`);
}
}
if (shares == undefined) {
throw Error("Invalid UserBalance: should contain 'shares'");
}

return new UserBalance(shares, q4w, unlockedQ4W, totalQ4W);
}
}
Expand Down

0 comments on commit d7b0e77

Please sign in to comment.