Skip to content

Commit

Permalink
refactor: remove UCAN stream handler and insert deltas directly into …
Browse files Browse the repository at this point in the history
…space-diff table (#458)

This PR addresses the objectives outlined in the issue
storacha/project-tracking#304

Please refer to the issue for detailed context.

**TODO**:  
- [x] Remove `ucan-stream` (billing)
- [x] Insert space usage delta into the diff table in `register`  
- [x] Insert space usage delta into the diff table in `deregister`  
- [x] Use `TransactWriteItems` to ensure atomic write transactions  
- [x] Ensure tests are passing
  • Loading branch information
BravoNatalie authored Feb 11, 2025
1 parent 7b9d425 commit 3f5fdb3
Show file tree
Hide file tree
Showing 13 changed files with 310 additions and 753 deletions.
115 changes: 0 additions & 115 deletions billing/functions/ucan-stream.js

This file was deleted.

2 changes: 0 additions & 2 deletions billing/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,6 @@ export interface UcanWorkflowMessage<C extends Capabilities = Capabilities> exte
type: 'workflow'
}

export type UcanStreamMessage<C extends Capabilities = Capabilities> = UcanWorkflowMessage<C> | UcanReceiptMessage<C>

// Utility ////////////////////////////////////////////////////////////////////

export type ConsumerDID = DID
Expand Down
174 changes: 0 additions & 174 deletions billing/lib/ucan-stream.js

This file was deleted.

18 changes: 0 additions & 18 deletions billing/test/helpers/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,24 +148,6 @@ export const createStripeTestContext = async () => {
return { customerStore }
}

export const createUCANStreamTestContext = async () => {
await createAWSServices()

const spaceDiffTableName = await createTable(awsServices.dynamo.client, spaceDiffTableProps, 'space-diff-')
const spaceDiffStore = createSpaceDiffStore(awsServices.dynamo.client, { tableName: spaceDiffTableName })
const consumerTableName = await createTable(awsServices.dynamo.client, consumerTableProps, 'consumer-')
const consumerStore = {
...createConsumerStore(awsServices.dynamo.client, { tableName: consumerTableName }),
...createStorePutterClient(awsServices.dynamo.client, {
tableName: consumerTableName,
validate: validateConsumer, // assume test data is valid
encode: encodeConsumer
})
}

return { consumerStore, spaceDiffStore }
}

/**
* @returns {Promise<import('../lib/api.js').EgressTrafficTestContext>}
*/
Expand Down
4 changes: 0 additions & 4 deletions billing/test/lib.ucan-stream.spec.js

This file was deleted.

7 changes: 0 additions & 7 deletions billing/test/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ export interface StripeTestContext {
customerStore: CustomerStore
}

export interface UCANStreamTestContext {
spaceDiffStore: SpaceDiffStore
consumerStore: ConsumerStore & StorePutter<Consumer>
}


export interface EgressTrafficTestContext extends Context {
egressTrafficQueue: EgressTrafficQueue & QueueRemover<EgressTrafficData>
egressTrafficQueueUrl: string
Expand All @@ -74,7 +68,6 @@ export type TestContext =
& CustomerBillingQueueTestContext
& SpaceBillingQueueTestContext
& StripeTestContext
& UCANStreamTestContext
& EgressTrafficTestContext

/** QueueRemover can remove items from the head of the queue. */
Expand Down
Loading

0 comments on commit 3f5fdb3

Please sign in to comment.