-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e677bb
commit 0f8ef40
Showing
8 changed files
with
221 additions
and
0 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,55 @@ | ||
package clio | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/xyield/xrpl-go/model/client/common" | ||
) | ||
|
||
type LedgerRequest struct { | ||
LedgerHash common.LedgerHash `json:"ledger_hash"` | ||
LedgerIndex common.LedgerSpecifier `json:"ledger_index"` | ||
Transactions bool `json:"transactions"` | ||
Expand bool `json:"expand"` | ||
OwnerFunds bool `json:"owner_funds"` | ||
Binary bool `json:"binary"` | ||
Queue bool `json:"queue"` | ||
Diff bool `json:"diff"` | ||
} | ||
|
||
func (*LedgerRequest) Method() string { | ||
return "ledger" | ||
} | ||
|
||
func (r *LedgerRequest) UnmarshalJSON(data []byte) error { | ||
type lrHelper struct { | ||
LedgerHash common.LedgerHash `json:"ledger_hash"` | ||
LedgerIndex json.RawMessage `json:"ledger_index"` | ||
Transactions bool `json:"transactions"` | ||
Expand bool `json:"expand"` | ||
OwnerFunds bool `json:"owner_funds"` | ||
Binary bool `json:"binary"` | ||
Queue bool `json:"queue"` | ||
Diff bool `json:"diff"` | ||
} | ||
var h lrHelper | ||
err := json.Unmarshal(data, &h) | ||
if err != nil { | ||
return err | ||
} | ||
*r = LedgerRequest{ | ||
LedgerHash: h.LedgerHash, | ||
Transactions: h.Transactions, | ||
Expand: h.Expand, | ||
OwnerFunds: h.OwnerFunds, | ||
Binary: h.Binary, | ||
Queue: h.Queue, | ||
Diff: h.Diff, | ||
} | ||
r.LedgerIndex, err = common.UnmarshalLedgerSpecifier(data) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
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,86 @@ | ||
package clio | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/xyield/xrpl-go/model/client/common" | ||
"github.com/xyield/xrpl-go/model/ledger" | ||
"github.com/xyield/xrpl-go/model/transactions" | ||
"github.com/xyield/xrpl-go/model/transactions/types" | ||
) | ||
|
||
type LedgerResponse struct { | ||
Ledger ClioLedger `json:"ledger"` | ||
} | ||
|
||
type ClioLedger struct { | ||
AccountHash string `json:"account_hash"` | ||
AccountState []ledger.LedgerObject `json:"accountState,omitempty"` | ||
CloseFlags int `json:"close_flags"` | ||
CloseTime uint `json:"close_time"` | ||
CloseTimeHuman string `json:"close_time_human"` | ||
CloseTimeResolution int `json:"close_time_resolution"` | ||
Closed bool `json:"closed"` | ||
LedgerHash common.LedgerHash `json:"ledger_hash"` | ||
LedgerIndex string `json:"ledger_index"` | ||
ParentCloseTime uint `json:"parent_close_time"` | ||
ParentHash string `json:"parent_hash"` | ||
TotalCoins types.XRPCurrencyAmount `json:"total_coins"` | ||
TransactionHash string `json:"transaction_hash"` | ||
Transactions []transactions.Tx `json:"transactions"` | ||
} | ||
|
||
func (l *ClioLedger) UnmarshalJSON(data []byte) error { | ||
type clHelper struct { | ||
AccountHash string `json:"account_hash"` | ||
AccountState []json.RawMessage `json:"accountState,omitempty"` | ||
CloseFlags int `json:"close_flags"` | ||
CloseTime uint `json:"close_time"` | ||
CloseTimeHuman string `json:"close_time_human"` | ||
CloseTimeResolution int `json:"close_time_resolution"` | ||
Closed bool `json:"closed"` | ||
LedgerHash common.LedgerHash `json:"ledger_hash"` | ||
LedgerIndex string `json:"ledger_index"` | ||
ParentCloseTime uint `json:"parent_close_time"` | ||
ParentHash string `json:"parent_hash"` | ||
TotalCoins types.XRPCurrencyAmount `json:"total_coins"` | ||
TransactionHash string `json:"transaction_hash"` | ||
Transactions []json.RawMessage `json:"transactions"` | ||
} | ||
var h clHelper | ||
err := json.Unmarshal(data, &h) | ||
if err != nil { | ||
return err | ||
} | ||
*l = ClioLedger{ | ||
AccountHash: h.AccountHash, | ||
CloseFlags: h.CloseFlags, | ||
CloseTime: h.CloseTime, | ||
CloseTimeHuman: h.CloseTimeHuman, | ||
Closed: h.Closed, | ||
LedgerHash: h.LedgerHash, | ||
LedgerIndex: h.LedgerIndex, | ||
ParentCloseTime: h.ParentCloseTime, | ||
ParentHash: h.ParentHash, | ||
TotalCoins: h.TotalCoins, | ||
TransactionHash: h.TransactionHash, | ||
} | ||
|
||
for _, state := range h.AccountState { | ||
obj, err := ledger.UnmarshalLedgerObject(state) | ||
if err != nil { | ||
return err | ||
} | ||
l.AccountState = append(l.AccountState, obj) | ||
} | ||
|
||
for _, tx := range h.Transactions { | ||
tx, err := transactions.UnmarshalTx(tx) | ||
if err != nil { | ||
return err | ||
} | ||
l.Transactions = append(l.Transactions, tx) | ||
} | ||
|
||
return nil | ||
} |
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,37 @@ | ||
package clio | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/xyield/xrpl-go/model/client/common" | ||
"github.com/xyield/xrpl-go/model/transactions/types" | ||
) | ||
|
||
type NFTInfoRequest struct { | ||
NFTokenID types.NFTokenID `json:"nft_id"` | ||
LedgerHash common.LedgerHash `json:"ledger_hash,omitempty"` | ||
LedgerIndex common.LedgerSpecifier `json:"ledger_index,omitempty"` | ||
} | ||
|
||
func (*NFTInfoRequest) Method() string { | ||
return "nft_info" | ||
} | ||
|
||
func (r *NFTInfoRequest) UnmarshalJSON(data []byte) error { | ||
type nirHelper struct { | ||
NFTokenID types.NFTokenID `json:"nft_id"` | ||
LedgerHash common.LedgerHash `json:"ledger_hash,omitempty"` | ||
LedgerIndex json.RawMessage `json:"ledger_index,omitempty"` | ||
} | ||
var h nirHelper | ||
err := json.Unmarshal(data, &h) | ||
if err != nil { | ||
return err | ||
} | ||
*r = NFTInfoRequest{ | ||
NFTokenID: h.NFTokenID, | ||
LedgerHash: h.LedgerHash, | ||
} | ||
r.LedgerIndex, err = common.UnmarshalLedgerSpecifier(h.LedgerIndex) | ||
return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package clio | ||
|
||
import ( | ||
"github.com/xyield/xrpl-go/model/client/common" | ||
"github.com/xyield/xrpl-go/model/transactions/types" | ||
) | ||
|
||
type NFTInfoResponse struct { | ||
NFTokenID types.NFTokenID `json:"nft_id"` | ||
LedgerIndex common.LedgerIndex `json:"ledger_index"` | ||
Owner types.Address `json:"owner"` | ||
IsBurned bool `json:"is_burned"` | ||
Flags uint `json:"flags"` | ||
TransferFee uint `json:"transfer_fee"` | ||
Issuer types.Address `json:"issuer"` | ||
NFTokenTaxon uint `json:"nft_taxon"` | ||
NFTokenSequence uint `json:"nft_sequence"` | ||
URI types.NFTokenURI `json:"uri,omitempty"` | ||
} |
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,7 @@ | ||
package utility | ||
|
||
type PingRequest struct{} | ||
|
||
func (*PingRequest) Method() string { | ||
return "ping" | ||
} |
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 @@ | ||
package utility | ||
|
||
type PingResponse struct{} |
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,7 @@ | ||
package utility | ||
|
||
type RandomRequest struct{} | ||
|
||
func (*RandomRequest) Method() string { | ||
return "random" | ||
} |
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,7 @@ | ||
package utility | ||
|
||
import "github.com/xyield/xrpl-go/binary-codec/types" | ||
|
||
type RandomResponse struct { | ||
Random types.Hash256 `json:"random"` | ||
} |