-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create pay before persist request flow
- Loading branch information
1 parent
422fff4
commit 776bb7d
Showing
5 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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
45 changes: 45 additions & 0 deletions
45
packages/request-client.js/src/no-confirm-http-data-access.ts
This file contains 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,45 @@ | ||
import HttpDataAccess, { NodeConnectionConfig } from './http-data-access'; | ||
import { ClientTypes, DataAccessTypes, StorageTypes } from '@requestnetwork/types'; | ||
import { EventEmitter } from 'events'; | ||
|
||
export class NoConfirmHttpDataAccess 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, | ||
); | ||
|
||
return result; | ||
} | ||
} |
This file contains 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