mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 11:45:49 +00:00
Merge pull request #628 from clark800/remove-regular-key
Support removing RegularKey
This commit is contained in:
@@ -77,8 +77,11 @@
|
||||
"description": "TODO"
|
||||
},
|
||||
"regularKey": {
|
||||
"$ref": "address",
|
||||
"description": "The public key of a new keypair, to use as the regular key to this account, as a base-58-encoded string in the same format as an account address."
|
||||
"oneOf": [
|
||||
{"$ref": "address"},
|
||||
{"type": "null"}
|
||||
],
|
||||
"description": "The public key of a new keypair, to use as the regular key to this account, as a base-58-encoded string in the same format as an account address. Use `null` to remove the regular key."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* @flow */
|
||||
'use strict';
|
||||
const _ = require('lodash');
|
||||
const assert = require('assert');
|
||||
const BigNumber = require('bignumber.js');
|
||||
const utils = require('./utils');
|
||||
@@ -71,12 +72,15 @@ function convertTransferRate(transferRate: number | string): number | string {
|
||||
|
||||
function createSettingsTransaction(account: string, settings: Settings
|
||||
): Object {
|
||||
if (settings.regularKey) {
|
||||
return {
|
||||
if (settings.regularKey !== undefined) {
|
||||
const removeRegularKey = {
|
||||
TransactionType: 'SetRegularKey',
|
||||
Account: account,
|
||||
RegularKey: settings.regularKey
|
||||
Account: account
|
||||
};
|
||||
if (settings.regularKey === null) {
|
||||
return removeRegularKey;
|
||||
}
|
||||
return _.assign({}, removeRegularKey, {RegularKey: settings.regularKey});
|
||||
}
|
||||
|
||||
const txJSON: Object = {
|
||||
|
||||
@@ -119,6 +119,13 @@ describe('RippleAPI', function() {
|
||||
_.partial(checkResult, responses.prepareSettings.regularKey, 'prepare'));
|
||||
});
|
||||
|
||||
it('prepareSettings - remove regularKey', function() {
|
||||
const regularKey = {regularKey: null};
|
||||
return this.api.prepareSettings(address, regularKey, instructions).then(
|
||||
_.partial(checkResult, responses.prepareSettings.removeRegularKey,
|
||||
'prepare'));
|
||||
});
|
||||
|
||||
it('prepareSettings - flag set', function() {
|
||||
const settings = {requireDestinationTag: true};
|
||||
return this.api.prepareSettings(address, settings, instructions).then(
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"accepted": true,
|
||||
"stateHash": "D9ABF622DA26EEEE48203085D4BC23B0F77DC6F8724AC33D975DA3CA492D2E44",
|
||||
"closeTime": "2015-08-12T01:01:10.000Z",
|
||||
"parentCloseTime": "2015-08-12T01:01:00.000Z",
|
||||
|
||||
1
test/fixtures/responses/index.js
vendored
1
test/fixtures/responses/index.js
vendored
@@ -51,6 +51,7 @@ module.exports = {
|
||||
},
|
||||
prepareSettings: {
|
||||
regularKey: require('./prepare-settings-regular-key.json'),
|
||||
removeRegularKey: require('./prepare-settings-remove-regular-key.json'),
|
||||
flags: require('./prepare-settings.json'),
|
||||
flagSet: require('./prepare-settings-flag-set.json'),
|
||||
flagClear: require('./prepare-settings-flag-clear.json'),
|
||||
|
||||
8
test/fixtures/responses/prepare-settings-remove-regular-key.json
vendored
Normal file
8
test/fixtures/responses/prepare-settings-remove-regular-key.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"txJSON": "{\"Flags\":2147483648,\"TransactionType\":\"SetRegularKey\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"instructions": {
|
||||
"fee": "0.000012",
|
||||
"sequence": 23,
|
||||
"maxLedgerVersion": 8820051
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user