- 
                Notifications
    You must be signed in to change notification settings 
- Fork 44
refactor: move proof retrieval from DAPI to Drive ABCI #2535
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 4 commits
      Commits
    
    
            Show all changes
          
          
            10 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      31de61a
              
                refactor: move proof retrival to Drive ABCI
              
              
                shumkov 548ea2e
              
                chore: update dapi-gprc, drive-aci and dapi
              
              
                shumkov 234172f
              
                fix: dapi is failing with proto errors
              
              
                shumkov 83e5052
              
                fix: sdk tests data fails
              
              
                shumkov 511d736
              
                test: remove outdated tests
              
              
                shumkov f141ca4
              
                fix: invalid path
              
              
                shumkov 752569b
              
                test: remove dangling test
              
              
                shumkov 590b106
              
                test: update tests in dapi and drive abci
              
              
                shumkov 7e542cb
              
                fix: internal error if deserialization failed
              
              
                shumkov 2b6fbac
              
                refactor: remove unused import
              
              
                shumkov 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
      
      Oops, something went wrong.
      
    
  
  
    
      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 | 
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| src/core/*/ | ||
| src/platform/*/ | ||
| src/drive/*/ | 
  
    
      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
    
  
  
    
              
        
          
  
    
      
          
            111 changes: 111 additions & 0 deletions
          
          111 
        
  packages/dapi-grpc/clients/drive/v0/nodejs/DrivePromiseClient.js
  
  
      
      
   
        
      
      
    
  
    
      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,111 @@ | ||
| const grpc = require('@grpc/grpc-js'); | ||
| const { promisify } = require('util'); | ||
|  | ||
| const { | ||
| convertObjectToMetadata, | ||
| utils: { | ||
| isObject, | ||
| }, | ||
| client: { | ||
| interceptors: { | ||
| jsonToProtobufInterceptorFactory, | ||
| }, | ||
| converters: { | ||
| jsonToProtobufFactory, | ||
| protobufToJsonFactory, | ||
| }, | ||
| }, | ||
| } = require('@dashevo/grpc-common'); | ||
|  | ||
| const { URL } = require('url'); | ||
| const { | ||
| org: { | ||
| dash: { | ||
| platform: { | ||
| drive: { | ||
| v0: { | ||
| GetProofsRequest: PBJSGetProofsRequest, | ||
| GetProofsResponse: PBJSGetProofsResponse, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } = require('./drive_pbjs'); | ||
|  | ||
| const { | ||
| GetProofsResponse: ProtocGetProofsResponse, | ||
| } = require('./drive_protoc'); | ||
|  | ||
| const getDriveDefinition = require('../../../../lib/getDriveDefinition'); | ||
|  | ||
| const DriveNodeJSClient = getDriveDefinition(0); | ||
|  | ||
| class DrivePromiseClient { | ||
| /** | ||
| * @param {string} hostname | ||
| * @param {?Object} credentials | ||
| * @param {?Object} options | ||
| */ | ||
| constructor(hostname, credentials, options = {}) { | ||
| if (credentials !== undefined) { | ||
| throw new Error('"credentials" option is not supported yet'); | ||
| } | ||
|  | ||
| const url = new URL(hostname); | ||
| const { protocol, host: strippedHostname } = url; | ||
|  | ||
| // See this issue https://github.com/nodejs/node/issues/3176 | ||
| // eslint-disable-next-line no-param-reassign | ||
| credentials = protocol.replace(':', '') === 'https' ? grpc.credentials.createSsl() : grpc.credentials.createInsecure(); | ||
|  | ||
| this.client = new DriveNodeJSClient(strippedHostname, credentials, options); | ||
|  | ||
| this.client.getProofs = promisify( | ||
| this.client.getProofs.bind(this.client), | ||
| ); | ||
|  | ||
| this.protocolVersion = undefined; | ||
| } | ||
|  | ||
| /** | ||
| * | ||
| * @param {!GetProofsRequest} request | ||
| * @param {?Object<string, string>} metadata | ||
| * @param {CallOptions} [options={}] | ||
| * @returns {Promise<!GetProofsResponse>} | ||
| */ | ||
| getProofs(request, metadata = {}, options = {}) { | ||
| if (!isObject(metadata)) { | ||
| throw new Error('metadata must be an object'); | ||
| } | ||
|  | ||
| return this.client.getProofs( | ||
| request, | ||
| convertObjectToMetadata(metadata), | ||
| { | ||
| interceptors: [ | ||
| jsonToProtobufInterceptorFactory( | ||
| jsonToProtobufFactory( | ||
| ProtocGetProofsResponse, | ||
| PBJSGetProofsResponse, | ||
| ), | ||
| protobufToJsonFactory( | ||
| PBJSGetProofsRequest, | ||
| ), | ||
| ), | ||
| ], | ||
| ...options, | ||
| }, | ||
| ); | ||
| } | ||
|  | ||
| /** | ||
| * @param {string} protocolVersion | ||
| */ | ||
| setProtocolVersion(protocolVersion) { | ||
| this.setProtocolVersion = protocolVersion; | ||
| } | ||
| } | ||
|  | ||
| module.exports = DrivePromiseClient; | ||
      
      Oops, something went wrong.
        
    
  
      
      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.