fix(refactor): rename prepareTicket to prepareTicketCreate (https://github.com/ripple/ripple-lib/pull/1324#discussion_r519027049)

This commit is contained in:
Javi
2020-11-08 09:53:17 +01:00
parent c985838cdd
commit 1c1a3fa583
13 changed files with 23 additions and 23 deletions

View File

@@ -78,7 +78,7 @@
- [prepareCheckCreate](#preparecheckcreate) - [prepareCheckCreate](#preparecheckcreate)
- [prepareCheckCancel](#preparecheckcancel) - [prepareCheckCancel](#preparecheckcancel)
- [prepareCheckCash](#preparecheckcash) - [prepareCheckCash](#preparecheckcash)
- [prepareTicket](#prepareticket) - [prepareTicketCreate](#prepareticketcreate)
- [sign](#sign) - [sign](#sign)
- [combine](#combine) - [combine](#combine)
- [submit](#submit) - [submit](#submit)
@@ -338,7 +338,7 @@ Executing a transaction with `RippleAPI` requires the following four steps:
* [prepareCheckCreate](#preparecheckcreate) * [prepareCheckCreate](#preparecheckcreate)
* [prepareCheckCancel](#preparecheckcancel) * [prepareCheckCancel](#preparecheckcancel)
* [prepareCheckCash](#preparecheckcash) * [prepareCheckCash](#preparecheckcash)
* [prepareTicket](#prepareticket) * [prepareTicketCreate](#prepareticketcreate)
2. [Sign](#sign) - Cryptographically sign the transaction locally and save the [transaction ID](#transaction-id). Signing is how the owner of an account authorizes a transaction to take place. For multisignature transactions, the `signedTransaction` fields returned by `sign` must be collected and passed to the [combine](#combine) method. 2. [Sign](#sign) - Cryptographically sign the transaction locally and save the [transaction ID](#transaction-id). Signing is how the owner of an account authorizes a transaction to take place. For multisignature transactions, the `signedTransaction` fields returned by `sign` must be collected and passed to the [combine](#combine) method.
3. [Submit](#submit) - Submit the transaction to the connected server. 3. [Submit](#submit) - Submit the transaction to the connected server.
4. Verify - Verify that the transaction got validated by querying with [getTransaction](#gettransaction). This is necessary because transactions may fail even if they were successfully submitted. 4. Verify - Verify that the transaction got validated by querying with [getTransaction](#gettransaction). This is necessary because transactions may fail even if they were successfully submitted.
@@ -5461,9 +5461,9 @@ return api.prepareCheckCash(address, checkCash).then(prepared =>
``` ```
## prepareTicket ## prepareTicketCreate
`prepareTicket(address: string, ticketCount: number, instructions: object): Promise<object>` `prepareTicketCreate(address: string, ticketCount: number, instructions: object): Promise<object>`
Prepare a ticket transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit). Prepare a ticket transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
@@ -5497,7 +5497,7 @@ instructions | object | The instructions for how to execute the transaction afte
```javascript ```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59'; const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
return api.prepareTicket(address, 2).then(prepared => { return api.prepareTicketCreate(address, 2).then(prepared => {
/* ... */ /* ... */
}).catch(error => { }).catch(error => {
/* ... as with all prepare* methods, use a Promise catch block to handle errors ... */ /* ... as with all prepare* methods, use a Promise catch block to handle errors ... */

View File

@@ -22,7 +22,7 @@ function fail(message) {
api.connect().then(() => { api.connect().then(() => {
console.log('Connected...'); console.log('Connected...');
return api.prepareTicket(address, numberOfTickets, instructions).then(prepared => { return api.prepareTicketCreate(address, numberOfTickets, instructions).then(prepared => {
console.log('Ticket transaction prepared...'); console.log('Ticket transaction prepared...');
const {signedTransaction} = api.sign(prepared.txJSON, secret); const {signedTransaction} = api.sign(prepared.txJSON, secret);
console.log('Ticket transaction signed...'); console.log('Ticket transaction signed...');

View File

@@ -49,7 +49,7 @@
<%- include('prepareCheckCreate.md.ejs') %> <%- include('prepareCheckCreate.md.ejs') %>
<%- include('prepareCheckCancel.md.ejs') %> <%- include('prepareCheckCancel.md.ejs') %>
<%- include('prepareCheckCash.md.ejs') %> <%- include('prepareCheckCash.md.ejs') %>
<%- include('prepareTicket.md.ejs') %> <%- include('prepareTicketCreate.md.ejs') %>
<%- include('sign.md.ejs') %> <%- include('sign.md.ejs') %>
<%- include('combine.md.ejs') %> <%- include('combine.md.ejs') %>
<%- include('submit.md.ejs') %> <%- include('submit.md.ejs') %>

View File

@@ -1,12 +1,12 @@
## prepareTicket ## prepareTicketCreate
`prepareTicket(address: string, ticketCount: number, instructions: object): Promise<object>` `prepareTicketCreate(address: string, ticketCount: number, instructions: object): Promise<object>`
Prepare a ticket transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit). Prepare a ticket transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters ### Parameters
<%- renderSchema("input/prepare-ticket.json") %> <%- renderSchema("input/prepare-ticket-create.json") %>
### Return Value ### Return Value
@@ -22,11 +22,11 @@ All "prepare*" methods have the same return type.
```javascript ```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59'; const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
return api.prepareTicket(address, 2).then(prepared => { return api.prepareTicketCreate(address, 2).then(prepared => {
/* ... */ /* ... */
}).catch(error => { }).catch(error => {
/* ... as with all prepare* methods, use a Promise catch block to handle errors ... */ /* ... as with all prepare* methods, use a Promise catch block to handle errors ... */
}) })
``` ```
<%- renderFixture("responses/prepare-ticket.json") %> <%- renderFixture("responses/prepare-ticket-create.json") %>

View File

@@ -38,7 +38,7 @@ Executing a transaction with `RippleAPI` requires the following four steps:
* [prepareCheckCreate](#preparecheckcreate) * [prepareCheckCreate](#preparecheckcreate)
* [prepareCheckCancel](#preparecheckcancel) * [prepareCheckCancel](#preparecheckcancel)
* [prepareCheckCash](#preparecheckcash) * [prepareCheckCash](#preparecheckcash)
* [prepareTicket](#prepareticket) * [prepareTicketCreate](#prepareticketcreate)
2. [Sign](#sign) - Cryptographically sign the transaction locally and save the [transaction ID](#transaction-id). Signing is how the owner of an account authorizes a transaction to take place. For multisignature transactions, the `signedTransaction` fields returned by `sign` must be collected and passed to the [combine](#combine) method. 2. [Sign](#sign) - Cryptographically sign the transaction locally and save the [transaction ID](#transaction-id). Signing is how the owner of an account authorizes a transaction to take place. For multisignature transactions, the `signedTransaction` fields returned by `sign` must be collected and passed to the [combine](#combine) method.
3. [Submit](#submit) - Submit the transaction to the connected server. 3. [Submit](#submit) - Submit the transaction to the connected server.
4. Verify - Verify that the transaction got validated by querying with [getTransaction](#gettransaction). This is necessary because transactions may fail even if they were successfully submitted. 4. Verify - Verify that the transaction got validated by querying with [getTransaction](#gettransaction). This is necessary because transactions may fail even if they were successfully submitted.

View File

@@ -43,7 +43,7 @@ import prepareCheckCreate from './transaction/check-create'
import prepareCheckCancel from './transaction/check-cancel' import prepareCheckCancel from './transaction/check-cancel'
import prepareCheckCash from './transaction/check-cash' import prepareCheckCash from './transaction/check-cash'
import prepareSettings from './transaction/settings' import prepareSettings from './transaction/settings'
import prepareTicket from './transaction/ticket' import prepareTicketCreate from './transaction/ticket'
import sign from './transaction/sign' import sign from './transaction/sign'
import combine from './transaction/combine' import combine from './transaction/combine'
import submit from './transaction/submit' import submit from './transaction/submit'
@@ -396,7 +396,7 @@ class RippleAPI extends EventEmitter {
prepareCheckCreate = prepareCheckCreate prepareCheckCreate = prepareCheckCreate
prepareCheckCash = prepareCheckCash prepareCheckCash = prepareCheckCash
prepareCheckCancel = prepareCheckCancel prepareCheckCancel = prepareCheckCancel
prepareTicket = prepareTicket prepareTicketCreate = prepareTicketCreate
prepareSettings = prepareSettings prepareSettings = prepareSettings
sign = sign sign = sign
combine = combine combine = combine

View File

@@ -116,7 +116,7 @@ function loadSchemas() {
require('./schemas/input/prepare-check-create.json'), require('./schemas/input/prepare-check-create.json'),
require('./schemas/input/prepare-check-cash.json'), require('./schemas/input/prepare-check-cash.json'),
require('./schemas/input/prepare-check-cancel.json'), require('./schemas/input/prepare-check-cancel.json'),
require('./schemas/input/prepare-ticket.json'), require('./schemas/input/prepare-ticket-create.json'),
require('./schemas/input/compute-ledger-hash.json'), require('./schemas/input/compute-ledger-hash.json'),
require('./schemas/input/sign.json'), require('./schemas/input/sign.json'),
require('./schemas/input/submit.json'), require('./schemas/input/submit.json'),

View File

@@ -132,7 +132,7 @@ export const prepareCheckCancel = _.partial(
'prepareCheckCancelParameters' 'prepareCheckCancelParameters'
) )
export const prepareTicket = _.partial( export const prepareTicketCreate = _.partial(
schemaValidate, schemaValidate,
'prepareTicketParameters' 'prepareTicketParameters'
) )

View File

@@ -27,14 +27,14 @@ function createTicketTransaction(
return txJSON return txJSON
} }
function prepareTicket( function prepareTicketCreate(
this: RippleAPI, this: RippleAPI,
address: string, address: string,
ticketCount: number, ticketCount: number,
instructions: Instructions = {} instructions: Instructions = {}
): Promise<Prepare> { ): Promise<Prepare> {
try { try {
validate.prepareTicket({address, ticketCount, instructions}) validate.prepareTicketCreate({address, ticketCount, instructions})
const txJSON = createTicketTransaction(address, ticketCount) const txJSON = createTicketTransaction(address, ticketCount)
return utils.prepareTransaction(txJSON, this, instructions) return utils.prepareTransaction(txJSON, this, instructions)
} catch (e) { } catch (e) {
@@ -42,4 +42,4 @@ function prepareTicket(
} }
} }
export default prepareTicket export default prepareTicketCreate

View File

@@ -31,7 +31,7 @@ export default <TestSuite>{
fee: '0.000012' fee: '0.000012'
} }
} }
const response = await api.prepareTicket(address, 2) const response = await api.prepareTicketCreate(address, 2)
assertResultMatch(response, expected, 'prepare') assertResultMatch(response, expected, 'prepare')
}, },
@@ -50,7 +50,7 @@ export default <TestSuite>{
ticketSequence: 23, ticketSequence: 23,
fee: '0.000012' fee: '0.000012'
} }
const response = await api.prepareTicket(address, 1, instructions) const response = await api.prepareTicketCreate(address, 1, instructions)
assertResultMatch(response, expected, 'prepare') assertResultMatch(response, expected, 'prepare')
} }
} }

View File

@@ -351,7 +351,7 @@ describe('integration tests', function () {
it('ticket', function () { it('ticket', function () {
return this.api.getLedgerVersion().then((ledgerVersion) => { return this.api.getLedgerVersion().then((ledgerVersion) => {
return this.api return this.api
.prepareTicket(address, 1, instructions) .prepareTicketCreate(address, 1, instructions)
.then((prepared) => .then((prepared) =>
testTransaction(this, 'ticket', ledgerVersion, prepared) testTransaction(this, 'ticket', ledgerVersion, prepared)
) )