Skip to content

Commit

Permalink
feat(dashboard): add blueprints tab to package entity
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidsowardx committed Sep 25, 2024
1 parent 30e488f commit 7c677bc
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
id: 'summary',
label: 'Summary'
},
{
id: 'blueprints',
label: 'Blueprints'
},
{
id: 'metadata',
label: 'Metadata'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script lang="ts">
import Row from '@components/info-box/Row.svelte'
import type { PageData } from './$types'
export let data: PageData
</script>

{#await data.promises.package then _package}
{#each _package.blueprints as blueprint}
<div class="card">
<h3>{blueprint.name}</h3>
{#each blueprint.methods as method}
<Row modifiers="no-capitalize" text={method.name} />
{/each}
</div>
{/each}
{/await}

<style lang="scss">
.card:not(:last-child) {
margin-bottom: 1rem;
}
</style>
6 changes: 6 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dependencies": {
"@floating-ui/dom": "^1.5.3",
"@radixdlt/babylon-gateway-api-sdk": "^1.5.0",
"@radixdlt/babylon-core-api-sdk": "^1.2.3",
"@radixdlt/radix-dapp-toolkit": "^2.1.0",
"@radixdlt/radix-engine-toolkit": "^1.0.5",
"@radixdlt/rola": "^2.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/core-sdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@radixdlt/babylon-core-api-sdk'
40 changes: 39 additions & 1 deletion packages/ui/src/api/utils/entities/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import type {
StateEntityDetailsResponsePackageDetails,
StateEntityDetailsVaultResponseItem
} from '@common/gateway-sdk'
import {
type BlueprintDefinition,
type BlueprintInterface,
ReceiverInfoReceiverEnum
} from '@common/core-sdk'
import { transformEntity, type _Entity } from '.'
import { pipe } from 'ramda'
import { createStandardMetadata } from '../metadata'
Expand All @@ -12,7 +17,27 @@ const standardMetadata = createStandardMetadata({
tags: 'StringArray'
})

export type Package = _Entity<'package', typeof standardMetadata>
export type PackageBlueprint = {
name: string
methods: {
name: string
}[]
}

export type Package = _Entity<'package', typeof standardMetadata> & {
blueprints: PackageBlueprint[]
}

const getSignature = (receiver: ReceiverInfoReceiverEnum | undefined) => {
switch (receiver) {
case ReceiverInfoReceiverEnum.SelfRef:
return '(&self, ..)'
case ReceiverInfoReceiverEnum.SelfRefMut:
return '(&mut self, ..)'
default:
return '(..)'
}
}

export let transformPackage: (
entity: StateEntityDetailsVaultResponseItem
Expand All @@ -24,6 +49,19 @@ export let transformPackage: (
>(standardMetadata),
(entity) => ({
...entity,
blueprints:
entity.details.blueprints?.items.map((blueprint) => {
const definition = blueprint.definition as BlueprintDefinition
const _interface = (definition as any).interface as BlueprintInterface
return {
name: blueprint.name,
methods: Object.entries(_interface.functions).map(([name, value]) => {
return {
name: `${name}${getSignature(value.receiver_info?.receiver)}`
}
})
}
}) || [],
type: 'package' as const
})
)
6 changes: 6 additions & 0 deletions packages/ui/src/components/info-box/Row.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,11 @@
margin-bottom: 1rem;
}
}
&.no-capitalize {
.label {
text-transform: none;
}
}
}
</style>

0 comments on commit 7c677bc

Please sign in to comment.