Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity types refactor & remove store/storage modules #137

Merged
merged 11 commits into from
Feb 28, 2024
3 changes: 1 addition & 2 deletions apps/armory/src/__test__/fixture/price.fixture.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { AssetType, Namespace, Prices } from '@narval/policy-engine-shared'
import { AssetType, Namespace, Prices, assetIdSchema } from '@narval/policy-engine-shared'
import { sample } from 'lodash'
import { times } from 'lodash/fp'
import { z } from 'zod'
import { Fixture, Generator } from 'zod-fixture'
import { CHAINS, FIAT_ID_USD } from '../../armory.constant'
import { Price } from '../../shared/core/type/price.type'
import { assetIdSchema } from '../../shared/schema/caip.schema'
import { generateAddress, generateSupportedChainId } from './shared.fixture'

export const fiatIdSchema = z.custom<`fiat:${string}`>((value) => {
Expand Down
4 changes: 1 addition & 3 deletions apps/armory/src/__test__/fixture/shared.fixture.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { faker } from '@faker-js/faker'
import { Address, getAddress } from '@narval/policy-engine-shared'
import { Address, addressSchema, getAddress, hexSchema } from '@narval/policy-engine-shared'
import { sample } from 'lodash/fp'
import { Generator } from 'zod-fixture'
import { CHAINS } from '../../armory.constant'
import { ChainId } from '../../shared/core/lib/chains.lib'
import { addressSchema } from '../../shared/schema/address.schema'
import { chainIdSchema } from '../../shared/schema/chain-id.schema'
import { hexSchema } from '../../shared/schema/hex.schema'

export const hexGenerator = Generator({
schema: hexSchema,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { addressSchema } from '@narval/policy-engine-shared'
import { z } from 'zod'
import { Fixture } from 'zod-fixture'
import { generatePrice } from '../../__test__/fixture/price.fixture'
import { Transfer } from '../../shared/core/type/transfer-tracking.type'
import { addressSchema } from '../../shared/schema/address.schema'
import { chainIdSchema } from '../../shared/schema/chain-id.schema'
import { addressGenerator, chainIdGenerator } from './shared.fixture'

Expand Down
4 changes: 1 addition & 3 deletions apps/armory/src/armory.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { APP_INTERCEPTOR } from '@nestjs/core'
import { load } from './armory.config'
import { OrchestrationModule } from './orchestration/orchestration.module'
import { QueueModule } from './shared/module/queue/queue.module'
import { StoreModule } from './store/store.module'
import { TransferTrackingModule } from './transfer-tracking/transfer-tracking.module'

@Module({
Expand All @@ -15,8 +14,7 @@ import { TransferTrackingModule } from './transfer-tracking/transfer-tracking.mo
}),
QueueModule.forRoot(),
OrchestrationModule,
TransferTrackingModule,
StoreModule
TransferTrackingModule
],
providers: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class AuthorizationRequestService {
private priceService: PriceService,
private feedService: FeedService,
private clusterService: ClusterService
) {}
) { }

async create(input: CreateAuthorizationRequest): Promise<AuthorizationRequest> {
const now = new Date()
Expand Down Expand Up @@ -103,7 +103,7 @@ export class AuthorizationRequestService {
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
async complete(id: string) {}
async complete(id: string) { }

async evaluate(input: AuthorizationRequest): Promise<AuthorizationRequest> {
if (input.status === AuthorizationRequestStatus.PROCESSING) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { addressSchema, hexSchema } from '@narval/policy-engine-shared'
import { z } from 'zod'
import { addressSchema } from '../../../shared/schema/address.schema'
import { chainIdSchema } from '../../../shared/schema/chain-id.schema'
import { hexSchema } from '../../../shared/schema/hex.schema'

export const accessListSchema = z.object({
address: addressSchema,
Expand Down
128 changes: 0 additions & 128 deletions apps/armory/src/shared/module/persistence/schema/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -119,131 +119,3 @@ model Feed {

@@map("feed")
}

//
// Store Module
//

model OrganizationEntity {
uid String @id

@@map("organization_entity")
}

// TODO (@wcalderipe, 12/02/24): Evaluate the location of this model. The
// Identity Provider (IdP) seems the right place.
model AuthCredentialEntity {
orgId String @map("org_id")

uid String @id
pubKey String @map("pub_key")
alg String
userId String @map("user_id")

@@map("auth_credential_entity")
}

model UserEntity {
orgId String @map("org_id")

uid String @id
role String

wallets UserWalletEntity[]
groups UserGroupMemberEntity[]

@@map("user_entity")
}

model UserGroupEntity {
orgId String @map("org_id")

uid String @id

members UserGroupMemberEntity[]

@@map("user_group_entity")
}

model UserGroupMemberEntity {
userId String @map("user_uid")
groupId String @map("user_group_uid")

user UserEntity @relation(fields: [userId], references: [uid], onDelete: Cascade, onUpdate: Cascade)
group UserGroupEntity @relation(fields: [groupId], references: [uid], onDelete: Cascade, onUpdate: Cascade)

@@id([userId, groupId])
@@map("user_group_member_entity")
}

model WalletEntity {
orgId String @map("org_id")

uid String @id
address String
accountType String @map("account_type")
/// Chain ID is only needed for chain-specific wallets (smart accounts).
chainId Int? @map("chain_id")

groups WalletGroupMemberEntity[]
users UserWalletEntity[]

@@map("wallet_entity")
}

model WalletGroupEntity {
orgId String @map("org_id")

uid String @id

members WalletGroupMemberEntity[]

@@map("wallet_group_entity")
}

model WalletGroupMemberEntity {
walletId String @map("wallet_uid")
groupId String @map("wallet_group_uid")

wallet WalletEntity @relation(fields: [walletId], references: [uid], onDelete: Cascade, onUpdate: Cascade)
group WalletGroupEntity @relation(fields: [groupId], references: [uid], onDelete: Cascade, onUpdate: Cascade)

@@id([walletId, groupId])
@@map("wallet_group_member_entity")
}

model UserWalletEntity {
orgId String @map("org_id")

userId String @map("user_id")
walletId String @map("wallet_id")

wallet WalletEntity @relation(fields: [walletId], references: [uid], onDelete: Cascade, onUpdate: Cascade)
user UserEntity @relation(fields: [userId], references: [uid], onDelete: Cascade, onUpdate: Cascade)

@@id([userId, walletId])
@@map("user_wallet_entity")
}

model AddressBookAccountEntity {
orgId String @map("org_id")

uid String @id
address String
chainId Int @map("chain_id")
classification String

@@map("address_book_account_entity")
}

model TokenEntity {
orgId String @map("org_id")

uid String @id
address String
symbol String
chainId Int @map("chain_id")
decimals Int

@@map("token_entity")
}
2 changes: 1 addition & 1 deletion apps/armory/src/shared/module/persistence/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const prisma = new PrismaClient()

const orgs: Organization[] = [
{
id: FIXTURE.ORGANIZATION.uid,
id: FIXTURE.ORGANIZATION.id,
name: 'Dev',
createdAt: now,
updatedAt: now
Expand Down
44 changes: 0 additions & 44 deletions apps/armory/src/shared/schema/caip.schema.ts

This file was deleted.

104 changes: 0 additions & 104 deletions apps/armory/src/store/entity/__test__/e2e/address-book.spec.ts

This file was deleted.

Loading
Loading