-
Notifications
You must be signed in to change notification settings - Fork 92
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 all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
776bb7d
feat: create pay before persist request flow
aimen74 d53c930
Merge branch 'master' of github.com:RequestNetwork/requestNetwork int…
aimen74 fc5e671
feat: add preparePaymentRequest
aimen74 4c41cdf
feat: add requestPayment to `createRequest` return
aimen74 e9d51c7
docs: document `persistRequest` method
aimen74 c2ec1c2
test: add creation and persistance tests for in-memory requests
aimen74 399217c
test: update transactiom-manager tests to check only relavant parts o…
aimen74 12631ac
test: updating request-client tests to check object containing simila…
aimen74 dee30bd
Merge branch 'master' into 1380-pay-before-persist
MantisClone a32f05c
Merge branch 'master' of github.com:RequestNetwork/requestNetwork int…
aimen74 0964179
Merge branch '1380-pay-before-persist' of github.com:RequestNetwork/r…
aimen74 6dffdfd
refactor: merge in memory variables into one object `inMemoryInfo`
aimen74 d3d9368
test: move `spyPersistTransaction` back to beforeEach
aimen74 a56c1aa
Merge branch 'master' of github.com:RequestNetwork/requestNetwork int…
aimen74 af2afa8
test: add logs to failing test
aimen74 186b163
test: add more logs to test
aimen74 8e91696
test: revert skip persistence
aimen74 613e6c3
test: add persistence back
aimen74 10ed848
test: add more logs to failing test
aimen74 638d730
test: increase failAtCall
aimen74 d4b611f
test: increase timeout
aimen74 0900c53
test: uncomment workflows
aimen74 91f0cc6
test: lower fail at call
aimen74 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
aimen74 915b0a1
feat: emit confirmation on no-persist-http-data-access
aimen74 cf5884d
test: fix `in-memory request` tests
aimen74 8f50530
test: revert test changes
aimen74 e2dac67
fix: fix test
aimen74 55ec0b4
test: move in-memory reuqests to their own file
aimen74 8027739
test: move spyPersistTransatction to before all
aimen74 c3b08ad
refactor: update error message to be more clear
aimen74 11b3121
clarify error message
MantisClone ab44ab4
fix: skipPersistence doc
MantisClone 7b71180
test: update test with updated error message
aimen74 a5d9668
fix: fix typo
aimen74 422e9e0
refactor: move `preparePaymentRequest` to the bottom of file
aimen74 3ccf360
refactor: rename `preparePaymentRequest` and `paymentRequest`
aimen74 157530f
chore: remove await from mockServer.close
aimen74 487dffe
chore: add warning to useMockStorage about overriding skipPersistence
aimen74 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.
MantisClone marked this conversation as 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.