-
Notifications
You must be signed in to change notification settings - Fork 91
feat: Create new data access to allow for in-memory transactions. #1386
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
Merged
Merged
Changes from 46 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
776bb7d
feat: create pay before persist request flow
aimensahnoun d53c930
Merge branch 'master' of github.com:RequestNetwork/requestNetwork int…
aimensahnoun fc5e671
feat: add preparePaymentRequest
aimensahnoun 4c41cdf
feat: add requestPayment to `createRequest` return
aimensahnoun e9d51c7
docs: document `persistRequest` method
aimensahnoun c2ec1c2
test: add creation and persistance tests for in-memory requests
aimensahnoun 399217c
test: update transactiom-manager tests to check only relavant parts o…
aimensahnoun 12631ac
test: updating request-client tests to check object containing simila…
aimensahnoun dee30bd
Merge branch 'master' into 1380-pay-before-persist
MantisClone a32f05c
Merge branch 'master' of github.com:RequestNetwork/requestNetwork int…
aimensahnoun 0964179
Merge branch '1380-pay-before-persist' of github.com:RequestNetwork/r…
aimensahnoun 6dffdfd
refactor: merge in memory variables into one object `inMemoryInfo`
aimensahnoun d3d9368
test: move `spyPersistTransaction` back to beforeEach
aimensahnoun a56c1aa
Merge branch 'master' of github.com:RequestNetwork/requestNetwork int…
aimensahnoun af2afa8
test: add logs to failing test
aimensahnoun 186b163
test: add more logs to test
aimensahnoun 8e91696
test: revert skip persistence
aimensahnoun 613e6c3
test: add persistence back
aimensahnoun 10ed848
test: add more logs to failing test
aimensahnoun 638d730
test: increase failAtCall
aimensahnoun d4b611f
test: increase timeout
aimensahnoun 0900c53
test: uncomment workflows
aimensahnoun 91f0cc6
test: lower fail at call
aimensahnoun 3dc465c
Revert to fail at call 6
MantisClone 6df24aa
Revert debug log messages and extended timeout
MantisClone 7ec1197
Throw error on unhandled request
MantisClone 6b3513b
Add debug logging related to msw server
MantisClone 8027e49
Print as strings
MantisClone 0f0fe60
Fix debug logs
MantisClone 6172c07
Try resetting handlers after each test
MantisClone ffc7559
Remove debug logs. Call `resetHandlers()` afterEach test
MantisClone e45294e
feat: skip refreshing if `skipePersistence` is active
aimensahnoun 915b0a1
feat: emit confirmation on no-persist-http-data-access
aimensahnoun cf5884d
test: fix `in-memory request` tests
aimensahnoun 8f50530
test: revert test changes
aimensahnoun e2dac67
fix: fix test
aimensahnoun 55ec0b4
test: move in-memory reuqests to their own file
aimensahnoun 8027739
test: move spyPersistTransatction to before all
aimensahnoun c3b08ad
refactor: update error message to be more clear
aimensahnoun 11b3121
clarify error message
MantisClone ab44ab4
fix: skipPersistence doc
MantisClone 7b71180
test: update test with updated error message
aimensahnoun a5d9668
fix: fix typo
aimensahnoun 422e9e0
refactor: move `preparePaymentRequest` to the bottom of file
aimensahnoun 3ccf360
refactor: rename `preparePaymentRequest` and `paymentRequest`
aimensahnoun 157530f
chore: remove await from mockServer.close
aimensahnoun 487dffe
chore: add warning to useMockStorage about overriding skipPersistence
aimensahnoun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/request-client.js/src/no-persist-http-data-access.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import HttpDataAccess, { NodeConnectionConfig } from './http-data-access'; | ||
| import { ClientTypes, DataAccessTypes, StorageTypes } from '@requestnetwork/types'; | ||
| import { EventEmitter } from 'events'; | ||
MantisClone marked this conversation as resolved.
Show resolved
Hide resolved
MantisClone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export class NoPersistHttpDataAccess extends HttpDataAccess { | ||
| constructor( | ||
| { | ||
| httpConfig, | ||
| nodeConnectionConfig, | ||
| }: { | ||
| httpConfig?: Partial<ClientTypes.IHttpDataAccessConfig>; | ||
| nodeConnectionConfig?: Partial<NodeConnectionConfig>; | ||
| } = { | ||
| httpConfig: {}, | ||
| nodeConnectionConfig: {}, | ||
| }, | ||
| ) { | ||
| super({ httpConfig, nodeConnectionConfig }); | ||
| } | ||
|
|
||
| async persistTransaction( | ||
| transactionData: DataAccessTypes.ITransaction, | ||
| channelId: string, | ||
| topics?: string[], | ||
| ): Promise<DataAccessTypes.IReturnPersistTransaction> { | ||
| const data: DataAccessTypes.IReturnPersistTransactionRaw = { | ||
| meta: { | ||
| topics: topics || [], | ||
| transactionStorageLocation: '', | ||
| storageMeta: { | ||
| state: StorageTypes.ContentState.PENDING, | ||
| timestamp: Date.now() / 1000, | ||
| }, | ||
| }, | ||
| result: {}, | ||
| }; | ||
|
|
||
| const result: DataAccessTypes.IReturnPersistTransaction = Object.assign( | ||
| new EventEmitter() as DataAccessTypes.PersistTransactionEmitter, | ||
| data, | ||
| ); | ||
|
|
||
| // Emit confirmation instantly since data is not going to be persisted | ||
| result.emit('confirmed', result); | ||
|
|
||
| return result; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.