Skip to content

Commit

Permalink
Merge branch 'interledger:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinsMunene authored Dec 11, 2024
2 parents a9c7234 + cc9ef41 commit a458568
Show file tree
Hide file tree
Showing 36 changed files with 475 additions and 113 deletions.
36 changes: 33 additions & 3 deletions .github/workflows/node-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ jobs:
push: false
platforms: ${{ matrix.platform.arch }}
file: packages/${{ matrix.package }}/Dockerfile.prod
tags: ghcr.io/${{ github.repository_owner }}/rafiki-${{ matrix.package }}:${{ needs.version-generator.outputs.version }}
tags: ghcr.io/${{ github.repository_owner }}/rafiki-${{ matrix.package }}-${{ matrix.platform.name }}:${{ needs.version-generator.outputs.version }}
outputs: type=docker,dest=/tmp/${{ github.sha }}-${{ matrix.package }}-${{ matrix.platform.name }}-${{ needs.version-generator.outputs.version }}.tar
- name: Save docker image to cache
uses: actions/cache@v4
Expand All @@ -291,6 +291,7 @@ jobs:
- backend
- frontend
steps:
- uses: actions/checkout@v4
- name: Fetch docker image from cache
uses: actions/cache/restore@v4
with:
Expand Down Expand Up @@ -326,6 +327,7 @@ jobs:
- backend
- frontend
steps:
- uses: actions/checkout@v4
- name: Fetch docker image from cache
uses: actions/cache/restore@v4
with:
Expand Down Expand Up @@ -380,11 +382,38 @@ jobs:
run: docker images
- name: Push to registry
run: |
docker push ghcr.io/${{ github.repository_owner }}/rafiki-${{ matrix.package }}:${{ needs.version-generator.outputs.version }}
docker push ghcr.io/${{ github.repository_owner }}/rafiki-${{ matrix.package }}-${{ matrix.platform.name }}:${{ needs.version-generator.outputs.version }}
push-manifest:
name: Push multi-arch manifest list
needs: [version-generator, push]
runs-on: ubuntu-latest
if: needs.version-generator.outputs.dockerPush == 'true'
strategy:
matrix:
package:
- auth
- backend
- frontend
steps:
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list
run: |
docker manifest create ghcr.io/${{ github.repository_owner }}/rafiki-${{ matrix.package }}:${{ needs.version-generator.outputs.version }} \
--amend ghcr.io/${{ github.repository_owner }}/rafiki-${{ matrix.package }}-amd64:${{ needs.version-generator.outputs.version }} \
--amend ghcr.io/${{ github.repository_owner }}/rafiki-${{ matrix.package }}-arm64:${{ needs.version-generator.outputs.version }}
- name: Push manifest list
run: |
docker manifest push ghcr.io/${{ github.repository_owner }}/rafiki-${{ matrix.package }}:${{ needs.version-generator.outputs.version }}
generate-release:
runs-on: ubuntu-latest
needs: [push, version-generator]
needs: [push-manifest, version-generator]
if: needs.version-generator.outputs.generateRelease == 'true'
steps:
- name: Checkout Code
Expand All @@ -395,6 +424,7 @@ jobs:
with:
token: ${{ github.token }}
tag: ${{ needs.version-generator.outputs.version }}
includeRefIssues: false
- name: Create Release
uses: ncipollo/release-action@v1.14.0
with:
Expand Down
2 changes: 2 additions & 0 deletions .grype.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore:
- vulnerability: GHSA-3xgq-45jj-v275
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ build
**/styles/*.css
.docusaurus
.cache-loader
packages/documentation/**
.astro
1 change: 1 addition & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CVE-2024-21538 exp:2024-12-31
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ body:graphql {
transferType
ledger
createdAt
state
expiresAt
}
credits {
id
Expand All @@ -30,6 +32,8 @@ body:graphql {
transferType
ledger
createdAt
state
expiresAt
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions localenv/mock-account-servicing-entity/generated/graphql.ts

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

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"license": "Apache-2.0",
"repository": "https://github.com/interledger/rafiki",
"engines": {
"pnpm": "^8.15.4",
"pnpm": "^8.15.9",
"node": "20"
},
"packageManager": "pnpm@8.15.5",
"packageManager": "pnpm@8.15.9",
"scripts": {
"preinstall": "npx only-allow pnpm",
"lint": "eslint --max-warnings=0 --fix .",
Expand Down Expand Up @@ -78,7 +78,8 @@
"tar@<6.2.1": ">=6.2.1",
"braces@<3.0.3": ">=3.0.3",
"@grpc/grpc-js@>=1.10.0 <1.10.9": ">=1.10.9",
"dset@<3.1.4": ">=3.1.4"
"dset@<3.1.4": ">=3.1.4",
"cross-spawn@>=7.0.0 <7.0.5": ">=7.0.5"
}
}
}
35 changes: 35 additions & 0 deletions packages/backend/src/accounting/tigerbeetle/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,41 @@ describe('TigerBeetle Accounting Service', (): void => {
expect(transferDebit.expiresAt).toBeUndefined()
})

test('Returns expiry date correctly', async (): Promise<void> => {
const receivingAccount = await accountFactory.build()
const balances = [BigInt(100), BigInt(100)]
const accounts = await Promise.all(
balances.map(async (balance) => {
return await accountFactory.build({
balance,
asset: receivingAccount.asset
})
})
)
const timeout = 10
await Promise.all(
accounts.map(async (account, i) => {
const transfer = await accountingService.createTransfer({
sourceAccount: account,
sourceAmount: BigInt(10 * (i + 1)),
destinationAccount: receivingAccount,
timeout: timeout
})
assert.ok(!isTransferError(transfer))
await transfer.post()
})
)
const transfer = await accountingService.getAccountTransfers(
receivingAccount.id
)
expect(transfer.credits).not.toHaveLength(0)
const timestamp = transfer.credits[0].timestamp
const expiresAtTime = transfer.credits[0].expiresAt?.getTime()
expect(expiresAtTime).toBe(
new Date(Number(timestamp) + timeout * 1000).getTime()
)
})

test('Returns undefined for nonexistent account', async (): Promise<void> => {
await expect(
accountingService.getTotalReceived(uuid())
Expand Down
15 changes: 14 additions & 1 deletion packages/backend/src/accounting/tigerbeetle/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ export function tbTransferToLedgerTransfer(
transferRef: fromTigerBeetleId(tbTransfer.user_data_128),
type: transferTypeFromCode(tbTransfer.code),
state: state,
ledger: tbTransfer.ledger
ledger: tbTransfer.ledger,
expiresAt: expiresAtFromTimestampAndTimeout(
tbTransfer.timestamp,
tbTransfer.timeout
)
}
}

function expiresAtFromTimestampAndTimeout(
timestamp: bigint,
timeout: number
): Date | undefined {
return timeout
? new Date(Number(timestamp / 1_000_000n) + timeout * 1000)
: undefined
}
57 changes: 57 additions & 0 deletions packages/backend/src/graphql/generated/graphql.schema.json

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

16 changes: 16 additions & 0 deletions packages/backend/src/graphql/generated/graphql.ts

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

Loading

0 comments on commit a458568

Please sign in to comment.