-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Use file input in payForBlobs CLI to allow to submit multiple b…
…lobs (#2856) Close [#2434](#2434) ## Changes made - Add blobJson proto type define how user can submit blob in file - Add file path as argument input for `payForBlob` command - Add `parseSubmitBlobs` to parse content from the file to array of defined `blobJSON`. Each blobJSON contain a namespaceID and blob in hex encoded format ( can modify what the user can put in the file later on, this need further conversation on this ) - Modifed the `broadcastPFB` func to accept multiple blobs instead <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. --> ## Testing test the command with single-node script running and got this result ( thanks @sontrinh16 for providing the test result ) ![image](https://github.com/celestiaorg/celestia-app/assets/145053932/720d6ccd-3bcc-4ac3-999d-90cc844cfad4) using the test_blob.json file contain: `{ "Blobs": [ { "namespaceId": "0x00010203040506070809", "blob": "0x48656c6c6f2c20576f726c6421" }, { "namespaceId": "0x00010203040506070809", "blob": "0x48656c6c6f2c20576f726c6421" } ] }` ## Checklist <!-- Please complete the checklist to ensure that the PR is ready to be reviewed. IMPORTANT: PRs should be left in Draft until the below checklist is completed. --> - [ ] New and updated code has appropriate documentation - [x] New and updated code has new and/or updated testing - [x] Required CI checks are passing - [x] Visual proof for any user facing features like CLI or documentation updates - [x] Linked issues closed with keywords --------- Co-authored-by: sontrinh16 <trinhleson2000@gmail.com> Co-authored-by: sontrinh16 <48055119+sontrinh16@users.noreply.github.com> Co-authored-by: Rootul P <rootulp@gmail.com>
- Loading branch information
1 parent
4e966f9
commit 4d08a7f
Showing
3 changed files
with
207 additions
and
27 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package cli | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
) | ||
|
||
// Define the raw content from the file input. | ||
type blobs struct { | ||
Blobs []blobJSON | ||
} | ||
|
||
type blobJSON struct { | ||
NamespaceID string | ||
Blob string | ||
} | ||
|
||
func parseSubmitBlobs(path string) ([]blobJSON, error) { | ||
var rawBlobs blobs | ||
|
||
content, err := os.ReadFile(path) | ||
if err != nil { | ||
return []blobJSON{}, err | ||
} | ||
|
||
err = json.Unmarshal(content, &rawBlobs) | ||
if err != nil { | ||
return []blobJSON{}, err | ||
} | ||
|
||
return rawBlobs.Blobs, err | ||
} |
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