-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from FogMeta/main
New: support to import deals using `Boost`
- Loading branch information
Showing
20 changed files
with
3,227 additions
and
132 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "extern/filecoin-ffi"] | ||
path = extern/filecoin-ffi | ||
url = https://github.com/filecoin-project/filecoin-ffi.git |
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
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,87 @@ | ||
package hql | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"github.com/Khan/genqlient/graphql" | ||
"net/http" | ||
"swan-provider/common/hql/gen" | ||
) | ||
|
||
type Client struct { | ||
hqlClient graphql.Client | ||
} | ||
|
||
func NewClient(endpoint string) (*Client, error) { | ||
if endpoint == "" || len(endpoint) == 0 { | ||
return nil, errors.New("graphql url is required") | ||
} | ||
client := graphql.NewClient(endpoint, http.DefaultClient) | ||
return &Client{client}, nil | ||
} | ||
|
||
func (c Client) GetDealByUuid(dealUuid string) (*gen.DealResponse, error) { | ||
return gen.Deal(context.TODO(), c.hqlClient, dealUuid) | ||
} | ||
|
||
var Checkpoint = map[string]string{ | ||
"Accepted": "Accepted", | ||
"Transferred": "Transferred", | ||
"Published": "Published", | ||
"PublishConfirmed": "PublishConfirmed", | ||
"AddedPiece": "AddedPiece", | ||
"IndexedAndAnnounced": "IndexedAndAnnounced", | ||
"Complete": "Complete", | ||
} | ||
|
||
func DealStatus(checkpoint, err string) string { | ||
switch checkpoint { | ||
case "Accepted": | ||
return "StorageDealWaitingForData" | ||
case "Transferred": | ||
fallthrough | ||
case "Published": | ||
fallthrough | ||
case "PublishConfirmed": | ||
return "StorageDealAwaitingPreCommit" | ||
case "AddedPiece": | ||
fallthrough | ||
case "IndexedAndAnnounced": | ||
return "StorageDealSealing" | ||
case "Complete": | ||
switch err { | ||
case "": | ||
return "StorageDealActive" | ||
case "Cancelled": | ||
return "StorageDealNotFound" | ||
} | ||
return "StorageDealError" | ||
} | ||
return "StorageDealNotFound" | ||
} | ||
|
||
func Message(checkpoint, err string) string { | ||
switch checkpoint { | ||
case "Accepted": | ||
return "Awaiting Offline Data Import" | ||
case "Transferred": | ||
return "Ready to Publish" | ||
case "Published": | ||
return "Awaiting Publish Confirmation" | ||
case "PublishConfirmed": | ||
return "Adding to Sector" | ||
case "AddedPiece": | ||
fallthrough | ||
case "IndexedAndAnnounced": | ||
return "sealing" | ||
case "Complete": | ||
switch err { | ||
case "": | ||
return "Complete" | ||
case "Cancelled": | ||
return "Cancelled" | ||
} | ||
return "Error: " + err | ||
} | ||
return "unknow" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,6 @@ | ||
package gen | ||
|
||
type ChainDealID struct { | ||
TypeName string `json:"__typename"` | ||
Value string `json:"n"` | ||
} |
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,14 @@ | ||
query Deal($uuid: ID!){ | ||
deal(id: $uuid) { | ||
ID | ||
ProviderAddress | ||
PieceCid | ||
IsVerified | ||
SignedProposalCid | ||
InboundFilePath | ||
ChainDealID | ||
Checkpoint | ||
Err | ||
Message | ||
} | ||
} |
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,11 @@ | ||
# Default genqlient config; for full documentation see: | ||
# https://github.com/Khan/genqlient/blob/main/docs/genqlient.yaml | ||
schema: schema.graphql | ||
operations: | ||
- genqlient.graphql | ||
generated: gen/generated.go | ||
package: gen | ||
context_type: context.Context | ||
bindings: | ||
Uint64: | ||
type: swan-provider/common/gen.ChainDealID |
Oops, something went wrong.