diff --git a/.github/workflows/npm_publish.yml b/.github/workflows/npm_publish.yml index b84eb41..84f4672 100644 --- a/.github/workflows/npm_publish.yml +++ b/.github/workflows/npm_publish.yml @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..42269ae --- /dev/null +++ b/.github/workflows/tests.yml @@ -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 \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 346a844..7242dba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@blend-capital/blend-sdk", - "version": "2.1.0", + "version": "2.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@blend-capital/blend-sdk", - "version": "2.1.0", + "version": "2.1.1", "license": "MIT", "dependencies": { "@stellar/stellar-sdk": "12.3.0", diff --git a/package.json b/package.json index ac37a33..b82e360 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/backstop/backstop_pool.ts b/src/backstop/backstop_pool.ts index 07379d1..ced30e7 100644 --- a/src/backstop/backstop_pool.ts +++ b/src/backstop/backstop_pool.ts @@ -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; @@ -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( diff --git a/src/backstop/backstop_user_types.ts b/src/backstop/backstop_user_types.ts index e640169..d4d4fbe 100644 --- a/src/backstop/backstop_user_types.ts +++ b/src/backstop/backstop_user_types.ts @@ -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); @@ -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); } }