Skip to content

Commit

Permalink
Include signers in getSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonianb committed Oct 11, 2017
1 parent f42dafd commit 2a90f9b
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 9 deletions.
13 changes: 7 additions & 6 deletions src/ledger/parse/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ function parseFields(data: Object): Object {
settings.regularKey = data.RegularKey
}

// TODO: this isn't implemented in rippled yet, may have to change this later
if (data.SignerQuorum || data.SignerEntries) {
// Since an account can own at most one SignerList,
// this array must have exactly one member if it is present.
if (data.signer_lists && data.signer_lists.length === 1) {
settings.signers = {}
if (data.SignerQuorum) {
settings.signers.threshold = data.SignerQuorum
if (data.signer_lists[0].SignerQuorum) {
settings.signers.threshold = data.signer_lists[0].SignerQuorum
}
if (data.SignerEntries) {
settings.signers.weights = _.map(data.SignerEntries, entry => {
if (data.signer_lists[0].SignerEntries) {
settings.signers.weights = _.map(data.signer_lists[0].SignerEntries, entry => {
return {
address: entry.SignerEntry.Account,
weight: entry.SignerEntry.SignerWeight
Expand Down
3 changes: 2 additions & 1 deletion src/ledger/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ function getSettings(address: string, options: SettingsOptions = {}
const request = {
command: 'account_info',
account: address,
ledger_index: options.ledgerVersion || 'validated'
ledger_index: options.ledgerVersion || 'validated',
signer_lists: true
}

return this.connection.request(request).then(formatSettings)
Expand Down
17 changes: 16 additions & 1 deletion test/fixtures/responses/get-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,20 @@
"disallowIncomingXRP": true,
"emailHash": "23463B99B62A72F26ED677CC556C44E8",
"domain": "example.com",
"transferRate": 1.002
"transferRate": 1.002,
"signers": {
"threshold": 3,
"weights": [
{
"address": "rpHit3GvUR1VSGh2PXcaaZKEEUnCVxWU2i",
"weight": 1
}, {
"address": "rN4oCm1c6BQz6nru83H52FBSpNbC9VQcRc",
"weight": 1
}, {
"address": "rJ8KhCi67VgbapiKCQN3r1ZA6BMUxUvvnD",
"weight": 1
}
]
}
}
31 changes: 30 additions & 1 deletion test/fixtures/rippled/account-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,36 @@
"TransferRate": 1002000000,
"WalletLocator": "00000000000000000000000000000000000000000000000000000000DEADBEEF",
"index": "396400950EA27EB5710C0D5BE1D2B4689139F168AC5D07C13B8140EC3F82AE71",
"urlgravatar": "http://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8"
"urlgravatar": "http://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8",
"signer_lists": [
{
"Flags": 0,
"LedgerEntryType": "SignerList",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "D2707DE50E1244B2C2AAEBC78C82A19ABAE0599D29362C16F1B8458EB65CCFE4",
"PreviousTxnLgrSeq": 3131157,
"SignerEntries": [
{
"SignerEntry": {
"Account": "rpHit3GvUR1VSGh2PXcaaZKEEUnCVxWU2i",
"SignerWeight": 1
}
}, {
"SignerEntry": {
"Account": "rN4oCm1c6BQz6nru83H52FBSpNbC9VQcRc",
"SignerWeight": 1
}
}, {
"SignerEntry": {
"Account": "rJ8KhCi67VgbapiKCQN3r1ZA6BMUxUvvnD",
"SignerWeight": 1
}
}],
"SignerListID": 0,
"SignerQuorum": 3,
"index": "5A9373E02D1DEF7EC9204DEB4819BA42D6AA6BCD878DC8C853062E9DD9708D11"
}
]
},
"ledger_index": 9592219
}
Expand Down

0 comments on commit 2a90f9b

Please sign in to comment.