Skip to content

Commit 6de6848

Browse files
Merge branch 'v0.1.x' of https://github.com/Peersyst/xrpl-go into v0.1.x
2 parents afd8eec + a9be8d0 commit 6de6848

File tree

7 files changed

+223
-14
lines changed

7 files changed

+223
-14
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Added
11+
12+
#### xrpl
13+
14+
- Adds `PermissionedDomain` ledger entry type (XLS-80d).
15+
816
## [v0.1.11]
917

1018
### BREAKING CHANGES

docs/static/img/favicon.ico

11.5 KB
Binary file not shown.

xrpl/ledger-entry-types/ledger_object.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const (
2727
OfferEntry EntryType = "Offer"
2828
OracleEntry EntryType = "Oracle"
2929
PayChannelEntry EntryType = "PayChannel"
30+
PermissionedDomainEntry EntryType = "PermissionedDomain"
3031
RippleStateEntry EntryType = "RippleState"
3132
SignerListEntry EntryType = "SignerList"
3233
TicketEntry EntryType = "Ticket"
@@ -84,6 +85,8 @@ func EmptyLedgerObject(t string) (Object, error) {
8485
return &Oracle{}, nil
8586
case PayChannelEntry:
8687
return &PayChannel{}, nil
88+
case PermissionedDomainEntry:
89+
return &PermissionedDomain{}, nil
8790
case RippleStateEntry:
8891
return &RippleState{}, nil
8992
case SignerListEntry:
@@ -147,6 +150,8 @@ func UnmarshalLedgerObject(data []byte) (Object, error) {
147150
o = &Oracle{}
148151
case PayChannelEntry:
149152
o = &PayChannel{}
153+
case PermissionedDomainEntry:
154+
o = &PermissionedDomain{}
150155
case RippleStateEntry:
151156
o = &RippleState{}
152157
case SignerListEntry:
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package ledger
2+
3+
import "github.com/Peersyst/xrpl-go/xrpl/transaction/types"
4+
5+
// A PermissionedDomain ledger entry describes a single permissioned domain instance.
6+
// You can create a permissioned domain by sending a PermissionedDomainSet transaction.
7+
//
8+
// ```json
9+
//
10+
// {
11+
// "LedgerEntryType": "PermissionedDomain",
12+
// "Fee": "10",
13+
// "Flags": 0,
14+
// "Owner": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
15+
// "OwnerNode": "0000000000000000",
16+
// "Sequence": 390,
17+
// "AcceptedCredentials": [
18+
// {
19+
// "Credential": {
20+
// "Issuer": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
21+
// "CredentialType": "6D795F63726564656E7469616C"
22+
// }
23+
// }
24+
// ],
25+
// "PreviousTxnID": "E7E3F2BBAAF48CF893896E48DC4A02BDA0C747B198D5AE18BC3D7567EE64B904",
26+
// "PreviousTxnLgrSeq": 8734523,
27+
// "index": "3DFA1DDEA27AF7E466DE395CCB16158E07ECA6BC4EB5580F75EBD39DE833645F"
28+
// }
29+
//
30+
// ```
31+
32+
type PermissionedDomain struct {
33+
// The unique ID for this ledger entry.
34+
// In JSON, this field is represented with different names depending on the context and API method.
35+
// (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.)
36+
Index types.Hash256 `json:"index,omitempty"`
37+
// The value 0x0082, mapped to the string PermissionedDomain, indicates that this is a PermissionedDomain ledger entry.
38+
LedgerEntryType EntryType
39+
// Fee is the transaction cost, in drops of XRP, that was paid by the
40+
// PermissionedDomainSet transaction which created or most recently modified
41+
// this PermissionedDomain ledger entry.
42+
Fee types.XRPCurrencyAmount
43+
// Set of bit-flags for this ledger entry.
44+
Flags uint32
45+
// The address of the account that owns this domain.
46+
Owner types.Address
47+
// A hint indicating which page of the owner directory links to this entry,
48+
// in case the directory consists of multiple pages.
49+
OwnerNode string
50+
// The Sequence value of the transaction that created this entry.
51+
Sequence uint32
52+
// A list of 1 to 10 Credential objects that grant access to this domain.
53+
// The array is stored sorted by issuer.
54+
AcceptedCredentials types.AuthorizeCredentialList
55+
// The identifying hash of the transaction that most recently modified this entry.
56+
PreviousTxnID types.Hash256
57+
// The index of the ledger that contains the transaction that most recently modified this object.
58+
PreviousTxnLgrSeq uint32
59+
}
60+
61+
func (*PermissionedDomain) EntryType() EntryType {
62+
return PermissionedDomainEntry
63+
}
64+
65+
func (p *PermissionedDomain) Flatten() FlatLedgerObject {
66+
flattened := make(FlatLedgerObject)
67+
if p.Index.String() != "" {
68+
flattened["index"] = p.Index.String()
69+
}
70+
flattened["LedgerEntryType"] = p.LedgerEntryType
71+
flattened["Fee"] = p.Fee.Flatten()
72+
flattened["Flags"] = p.Flags
73+
flattened["Owner"] = p.Owner.String()
74+
flattened["OwnerNode"] = p.OwnerNode
75+
flattened["Sequence"] = p.Sequence
76+
flattened["AcceptedCredentials"] = p.AcceptedCredentials.Flatten()
77+
flattened["PreviousTxnID"] = p.PreviousTxnID.String()
78+
flattened["PreviousTxnLgrSeq"] = p.PreviousTxnLgrSeq
79+
80+
return flattened
81+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
package ledger
2+
3+
import (
4+
"testing"
5+
6+
"github.com/Peersyst/xrpl-go/xrpl/testutil"
7+
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
8+
"github.com/stretchr/testify/require"
9+
)
10+
11+
func TestPermissionedDomain_EntryType(t *testing.T) {
12+
permissionedDomain := &PermissionedDomain{}
13+
require.Equal(t, permissionedDomain.EntryType(), PermissionedDomainEntry)
14+
}
15+
16+
func TestPermissionedDomain(t *testing.T) {
17+
18+
tests := []struct {
19+
name string
20+
permissionedDomain *PermissionedDomain
21+
expected string
22+
}{
23+
{
24+
name: "pass - valid PermissionedDomain",
25+
permissionedDomain: &PermissionedDomain{
26+
Index: types.Hash256("3DFA1DDEA27AF7E466DE395CCB16158E07ECA6BC4EB5580F75EBD39DE833645F"),
27+
LedgerEntryType: PermissionedDomainEntry,
28+
Fee: types.XRPCurrencyAmount(10),
29+
Flags: 0,
30+
Owner: types.Address("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn"),
31+
OwnerNode: "0000000000000000",
32+
Sequence: 390,
33+
AcceptedCredentials: types.AuthorizeCredentialList{
34+
{
35+
Credential: types.Credential{
36+
Issuer: types.Address("ra5nK24KXen9AHvsdFTKHSANinZseWnPcX"),
37+
CredentialType: types.CredentialType("6D795F63726564656E7469616C"),
38+
},
39+
},
40+
},
41+
PreviousTxnID: types.Hash256("E7E3F2BBAAF48CF893896E48DC4A02BDA0C747B198D5AE18BC3D7567EE64B904"),
42+
PreviousTxnLgrSeq: 8734523,
43+
},
44+
expected: `{
45+
"index": "3DFA1DDEA27AF7E466DE395CCB16158E07ECA6BC4EB5580F75EBD39DE833645F",
46+
"LedgerEntryType": "PermissionedDomain",
47+
"Fee": "10",
48+
"Flags": 0,
49+
"Owner": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
50+
"OwnerNode": "0000000000000000",
51+
"Sequence": 390,
52+
"AcceptedCredentials": [
53+
{
54+
"Credential": {
55+
"Issuer": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
56+
"CredentialType": "6D795F63726564656E7469616C"
57+
}
58+
}
59+
],
60+
"PreviousTxnID": "E7E3F2BBAAF48CF893896E48DC4A02BDA0C747B198D5AE18BC3D7567EE64B904",
61+
"PreviousTxnLgrSeq": 8734523
62+
}`,
63+
},
64+
}
65+
for _, test := range tests {
66+
t.Run(test.name, func(t *testing.T) {
67+
if err := testutil.SerializeAndDeserialize(t, test.permissionedDomain, test.expected); err != nil {
68+
t.Error(err)
69+
}
70+
})
71+
}
72+
}
73+
74+
func TestPermissionedDomain_Flatten(t *testing.T) {
75+
tests := []struct {
76+
name string
77+
permissionedDomain *PermissionedDomain
78+
expected string
79+
}{
80+
{
81+
name: "pass - valid PermissionedDomain",
82+
permissionedDomain: &PermissionedDomain{
83+
Index: types.Hash256("3DFA1DDEA27AF7E466DE395CCB16158E07ECA6BC4EB5580F75EBD39DE833645F"),
84+
LedgerEntryType: PermissionedDomainEntry,
85+
Fee: types.XRPCurrencyAmount(10),
86+
Flags: 0,
87+
Owner: types.Address("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn"),
88+
OwnerNode: "0000000000000000",
89+
Sequence: 390,
90+
AcceptedCredentials: types.AuthorizeCredentialList{
91+
{
92+
Credential: types.Credential{
93+
Issuer: types.Address("ra5nK24KXen9AHvsdFTKHSANinZseWnPcX"),
94+
CredentialType: types.CredentialType("6D795F63726564656E7469616C"),
95+
},
96+
},
97+
},
98+
PreviousTxnID: types.Hash256("E7E3F2BBAAF48CF893896E48DC4A02BDA0C747B198D5AE18BC3D7567EE64B904"),
99+
PreviousTxnLgrSeq: 8734523,
100+
},
101+
expected: `{
102+
"index": "3DFA1DDEA27AF7E466DE395CCB16158E07ECA6BC4EB5580F75EBD39DE833645F",
103+
"LedgerEntryType": "PermissionedDomain",
104+
"Fee": "10",
105+
"Flags": 0,
106+
"Owner": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
107+
"OwnerNode": "0000000000000000",
108+
"Sequence": 390,
109+
"AcceptedCredentials": [
110+
{
111+
"Credential": {
112+
"Issuer": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
113+
"CredentialType": "6D795F63726564656E7469616C"
114+
}
115+
}
116+
],
117+
"PreviousTxnID": "E7E3F2BBAAF48CF893896E48DC4A02BDA0C747B198D5AE18BC3D7567EE64B904",
118+
"PreviousTxnLgrSeq": 8734523
119+
}`,
120+
},
121+
}
122+
for _, test := range tests {
123+
t.Run(test.name, func(t *testing.T) {
124+
if err := testutil.CompareFlattenAndExpected(test.permissionedDomain.Flatten(), []byte(test.expected)); err != nil {
125+
t.Error(err)
126+
}
127+
})
128+
}
129+
}

xrpl/rpc/types/client_options.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,3 @@ type SubmitOptions struct {
99
Wallet *wallet.Wallet
1010
FailHard bool
1111
}
12-
13-
type SubmitBatchOptions struct {
14-
Autofill bool
15-
Wallet *wallet.Wallet
16-
FailHard bool
17-
NSigners uint64
18-
}

xrpl/websocket/types/client_options.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,3 @@ type SubmitOptions struct {
99
Wallet *wallet.Wallet
1010
FailHard bool
1111
}
12-
13-
type SubmitBatchOptions struct {
14-
Autofill bool
15-
Wallet *wallet.Wallet
16-
FailHard bool
17-
NSigners uint64
18-
}

0 commit comments

Comments
 (0)