Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

#### xrpl

- Adds `PermissionedDomain` ledger entry type (XLS-80d).

## [v0.1.11]

### BREAKING CHANGES
Expand Down
5 changes: 5 additions & 0 deletions xrpl/ledger-entry-types/ledger_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
OfferEntry EntryType = "Offer"
OracleEntry EntryType = "Oracle"
PayChannelEntry EntryType = "PayChannel"
PermissionedDomainEntry EntryType = "PermissionedDomain"
RippleStateEntry EntryType = "RippleState"
SignerListEntry EntryType = "SignerList"
TicketEntry EntryType = "Ticket"
Expand Down Expand Up @@ -84,6 +85,8 @@ func EmptyLedgerObject(t string) (Object, error) {
return &Oracle{}, nil
case PayChannelEntry:
return &PayChannel{}, nil
case PermissionedDomainEntry:
return &PermissionedDomain{}, nil
case RippleStateEntry:
return &RippleState{}, nil
case SignerListEntry:
Expand Down Expand Up @@ -147,6 +150,8 @@ func UnmarshalLedgerObject(data []byte) (Object, error) {
o = &Oracle{}
case PayChannelEntry:
o = &PayChannel{}
case PermissionedDomainEntry:
o = &PermissionedDomain{}
case RippleStateEntry:
o = &RippleState{}
case SignerListEntry:
Expand Down
81 changes: 81 additions & 0 deletions xrpl/ledger-entry-types/permissioned_domain.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package ledger

import "github.com/Peersyst/xrpl-go/xrpl/transaction/types"

// A PermissionedDomain ledger entry describes a single permissioned domain instance.
// You can create a permissioned domain by sending a PermissionedDomainSet transaction.
//
// ```json
//
// {
// "LedgerEntryType": "PermissionedDomain",
// "Fee": "10",
// "Flags": 0,
// "Owner": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
// "OwnerNode": "0000000000000000",
// "Sequence": 390,
// "AcceptedCredentials": [
// {
// "Credential": {
// "Issuer": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
// "CredentialType": "6D795F63726564656E7469616C"
// }
// }
// ],
// "PreviousTxnID": "E7E3F2BBAAF48CF893896E48DC4A02BDA0C747B198D5AE18BC3D7567EE64B904",
// "PreviousTxnLgrSeq": 8734523,
// "index": "3DFA1DDEA27AF7E466DE395CCB16158E07ECA6BC4EB5580F75EBD39DE833645F"
// }
//
// ```

type PermissionedDomain struct {
// The unique ID for this ledger entry.
// In JSON, this field is represented with different names depending on the context and API method.
// (Note, even though this is specified as "optional" in the code, every ledger entry should have one unless it's legacy data from very early in the XRP Ledger's history.)
Index types.Hash256 `json:"index,omitempty"`
// The value 0x0082, mapped to the string PermissionedDomain, indicates that this is a PermissionedDomain ledger entry.
LedgerEntryType EntryType
// Fee is the transaction cost, in drops of XRP, that was paid by the
// PermissionedDomainSet transaction which created or most recently modified
// this PermissionedDomain ledger entry.
Fee types.XRPCurrencyAmount
// Set of bit-flags for this ledger entry.
Flags uint32
// The address of the account that owns this domain.
Owner types.Address
// A hint indicating which page of the owner directory links to this entry,
// in case the directory consists of multiple pages.
OwnerNode string
// The Sequence value of the transaction that created this entry.
Sequence uint32
// A list of 1 to 10 Credential objects that grant access to this domain.
// The array is stored sorted by issuer.
AcceptedCredentials types.AuthorizeCredentialList
// The identifying hash of the transaction that most recently modified this entry.
PreviousTxnID types.Hash256
// The index of the ledger that contains the transaction that most recently modified this object.
PreviousTxnLgrSeq uint32
}

func (*PermissionedDomain) EntryType() EntryType {
return PermissionedDomainEntry
}

func (p *PermissionedDomain) Flatten() FlatLedgerObject {
flattened := make(FlatLedgerObject)
if p.Index.String() != "" {
flattened["index"] = p.Index.String()
}
flattened["LedgerEntryType"] = p.LedgerEntryType
flattened["Fee"] = p.Fee.Flatten()
flattened["Flags"] = p.Flags
flattened["Owner"] = p.Owner.String()
flattened["OwnerNode"] = p.OwnerNode
flattened["Sequence"] = p.Sequence
flattened["AcceptedCredentials"] = p.AcceptedCredentials.Flatten()
flattened["PreviousTxnID"] = p.PreviousTxnID.String()
flattened["PreviousTxnLgrSeq"] = p.PreviousTxnLgrSeq

return flattened
}
129 changes: 129 additions & 0 deletions xrpl/ledger-entry-types/permissioned_domain_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package ledger

import (
"testing"

"github.com/Peersyst/xrpl-go/xrpl/testutil"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
"github.com/stretchr/testify/require"
)

func TestPermissionedDomain_EntryType(t *testing.T) {
permissionedDomain := &PermissionedDomain{}
require.Equal(t, permissionedDomain.EntryType(), PermissionedDomainEntry)
}

func TestPermissionedDomain(t *testing.T) {

tests := []struct {
name string
permissionedDomain *PermissionedDomain
expected string
}{
{
name: "pass - valid PermissionedDomain",
permissionedDomain: &PermissionedDomain{
Index: types.Hash256("3DFA1DDEA27AF7E466DE395CCB16158E07ECA6BC4EB5580F75EBD39DE833645F"),
LedgerEntryType: PermissionedDomainEntry,
Fee: types.XRPCurrencyAmount(10),
Flags: 0,
Owner: types.Address("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn"),
OwnerNode: "0000000000000000",
Sequence: 390,
AcceptedCredentials: types.AuthorizeCredentialList{
{
Credential: types.Credential{
Issuer: types.Address("ra5nK24KXen9AHvsdFTKHSANinZseWnPcX"),
CredentialType: types.CredentialType("6D795F63726564656E7469616C"),
},
},
},
PreviousTxnID: types.Hash256("E7E3F2BBAAF48CF893896E48DC4A02BDA0C747B198D5AE18BC3D7567EE64B904"),
PreviousTxnLgrSeq: 8734523,
},
expected: `{
"index": "3DFA1DDEA27AF7E466DE395CCB16158E07ECA6BC4EB5580F75EBD39DE833645F",
"LedgerEntryType": "PermissionedDomain",
"Fee": "10",
"Flags": 0,
"Owner": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"OwnerNode": "0000000000000000",
"Sequence": 390,
"AcceptedCredentials": [
{
"Credential": {
"Issuer": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
"CredentialType": "6D795F63726564656E7469616C"
}
}
],
"PreviousTxnID": "E7E3F2BBAAF48CF893896E48DC4A02BDA0C747B198D5AE18BC3D7567EE64B904",
"PreviousTxnLgrSeq": 8734523
}`,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
if err := testutil.SerializeAndDeserialize(t, test.permissionedDomain, test.expected); err != nil {
t.Error(err)
}
})
}
}

func TestPermissionedDomain_Flatten(t *testing.T) {
tests := []struct {
name string
permissionedDomain *PermissionedDomain
expected string
}{
{
name: "pass - valid PermissionedDomain",
permissionedDomain: &PermissionedDomain{
Index: types.Hash256("3DFA1DDEA27AF7E466DE395CCB16158E07ECA6BC4EB5580F75EBD39DE833645F"),
LedgerEntryType: PermissionedDomainEntry,
Fee: types.XRPCurrencyAmount(10),
Flags: 0,
Owner: types.Address("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn"),
OwnerNode: "0000000000000000",
Sequence: 390,
AcceptedCredentials: types.AuthorizeCredentialList{
{
Credential: types.Credential{
Issuer: types.Address("ra5nK24KXen9AHvsdFTKHSANinZseWnPcX"),
CredentialType: types.CredentialType("6D795F63726564656E7469616C"),
},
},
},
PreviousTxnID: types.Hash256("E7E3F2BBAAF48CF893896E48DC4A02BDA0C747B198D5AE18BC3D7567EE64B904"),
PreviousTxnLgrSeq: 8734523,
},
expected: `{
"index": "3DFA1DDEA27AF7E466DE395CCB16158E07ECA6BC4EB5580F75EBD39DE833645F",
"LedgerEntryType": "PermissionedDomain",
"Fee": "10",
"Flags": 0,
"Owner": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"OwnerNode": "0000000000000000",
"Sequence": 390,
"AcceptedCredentials": [
{
"Credential": {
"Issuer": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
"CredentialType": "6D795F63726564656E7469616C"
}
}
],
"PreviousTxnID": "E7E3F2BBAAF48CF893896E48DC4A02BDA0C747B198D5AE18BC3D7567EE64B904",
"PreviousTxnLgrSeq": 8734523
}`,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
if err := testutil.CompareFlattenAndExpected(test.permissionedDomain.Flatten(), []byte(test.expected)); err != nil {
t.Error(err)
}
})
}
}
7 changes: 0 additions & 7 deletions xrpl/rpc/types/client_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,3 @@ type SubmitOptions struct {
Wallet *wallet.Wallet
FailHard bool
}

type SubmitBatchOptions struct {
Autofill bool
Wallet *wallet.Wallet
FailHard bool
NSigners uint64
}
7 changes: 0 additions & 7 deletions xrpl/websocket/types/client_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,3 @@ type SubmitOptions struct {
Wallet *wallet.Wallet
FailHard bool
}

type SubmitBatchOptions struct {
Autofill bool
Wallet *wallet.Wallet
FailHard bool
NSigners uint64
}