diff --git a/packages/xrpl/HISTORY.md b/packages/xrpl/HISTORY.md index 0bd75163..7dde0e0d 100644 --- a/packages/xrpl/HISTORY.md +++ b/packages/xrpl/HISTORY.md @@ -10,6 +10,9 @@ Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xr * Fixed `ServerState.transitions` typing, it is now a string instead of a number. (Only used in return from `server_state` request) * Added `destination_amount` to `PathOption` which is returned as part of a `path_find` request +### Removed +* RPCs and utils related to the old sidechain design + ## 2.7.0 (2023-03-08) ### Fixed diff --git a/packages/xrpl/src/models/methods/federatorInfo.ts b/packages/xrpl/src/models/methods/federatorInfo.ts deleted file mode 100644 index bae462ab..00000000 --- a/packages/xrpl/src/models/methods/federatorInfo.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { BaseRequest, BaseResponse } from './baseMethod' - -/** - * The `federator_info` command asks the federator for information - * about the door account and other bridge-related information. This - * method only exists on sidechain federators. Expects a response in - * the form of a {@link FederatorInfoResponse}. - * - * @category Requests - */ -export interface FederatorInfoRequest extends BaseRequest { - command: 'federator_info' -} - -/** - * Response expected from a {@link FederatorInfoRequest}. - * - * @category Responses - */ -export interface FederatorInfoResponse extends BaseResponse { - result: { - info: { - mainchain: { - door_status: { - initialized: boolean - status: 'open' | 'opening' | 'closed' | 'closing' - } - last_transaction_sent_seq: number - listener_info: { - state: 'syncing' | 'normal' - } - pending_transactions: Array<{ - amount: string - destination_account: string - signatures: Array<{ - public_key: string - seq: number - }> - }> - sequence: number - tickets: { - initialized: boolean - tickets: Array<{ - status: 'taken' | 'available' - ticket_seq: number - }> - } - } - public_key: string - sidechain: { - door_status: { - initialized: boolean - status: 'open' | 'opening' | 'closed' | 'closing' - } - last_transaction_sent_seq: number - listener_info: { - state: 'syncing' | 'normal' - } - pending_transactions: Array<{ - amount: string - destination_account: string - signatures: Array<{ - public_key: string - seq: number - }> - }> - sequence: number - tickets: { - initialized: boolean - tickets: Array<{ - status: 'taken' | 'available' - ticket_seq: number - }> - } - } - } - } -} diff --git a/packages/xrpl/src/models/methods/index.ts b/packages/xrpl/src/models/methods/index.ts index 7c5aee39..4a3296ff 100644 --- a/packages/xrpl/src/models/methods/index.ts +++ b/packages/xrpl/src/models/methods/index.ts @@ -23,7 +23,6 @@ import { DepositAuthorizedRequest, DepositAuthorizedResponse, } from './depositAuthorized' -import { FederatorInfoRequest, FederatorInfoResponse } from './federatorInfo' import { FeeRequest, FeeResponse } from './fee' import { GatewayBalancesRequest, @@ -121,8 +120,6 @@ type Request = // NFT methods | NFTBuyOffersRequest | NFTSellOffersRequest - // sidechain methods - | FederatorInfoRequest /** * @category Responses @@ -171,8 +168,6 @@ type Response = // NFT methods | NFTBuyOffersResponse | NFTSellOffersResponse - // sidechain methods - | FederatorInfoResponse export { Request, @@ -268,7 +263,4 @@ export { NFTBuyOffersResponse, NFTSellOffersRequest, NFTSellOffersResponse, - // sidechain methods - FederatorInfoRequest, - FederatorInfoResponse, } diff --git a/packages/xrpl/src/utils/createCrossChainPayment.ts b/packages/xrpl/src/utils/createCrossChainPayment.ts deleted file mode 100644 index 6091ea51..00000000 --- a/packages/xrpl/src/utils/createCrossChainPayment.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { XrplError } from '../errors' -import { Payment } from '../models' -import { Memo } from '../models/common' - -import { convertStringToHex } from './stringConversion' - -/** - * Creates a cross-chain payment transaction. - * - * @param payment - The initial payment transaction. If the transaction is - * signed, then it will need to be re-signed. There must be no more than 2 - * memos, since one memo is used for the sidechain destination account. The - * destination must be the sidechain's door account. - * @param destAccount - the destination account on the sidechain. - * @returns A cross-chain payment transaction, where the mainchain door account - * is the `Destination` and the destination account on the sidechain is encoded - * in the memos. - * @throws XrplError - if there are more than 2 memos. - * @category Utilities - */ -export default function createCrossChainPayment( - payment: Payment, - destAccount: string, -): Payment { - const destAccountHex = convertStringToHex(destAccount) - const destAccountMemo: Memo = { Memo: { MemoData: destAccountHex } } - - const memos = payment.Memos ?? [] - if (memos.length > 2) { - throw new XrplError( - 'Cannot have more than 2 memos in a cross-chain transaction.', - ) - } - const newMemos = [destAccountMemo, ...memos] - - const newPayment = { ...payment, Memos: newMemos } - delete newPayment.TxnSignature - - return newPayment -} diff --git a/packages/xrpl/src/utils/index.ts b/packages/xrpl/src/utils/index.ts index 299b27a7..06fdb390 100644 --- a/packages/xrpl/src/utils/index.ts +++ b/packages/xrpl/src/utils/index.ts @@ -22,7 +22,6 @@ import { Response } from '../models/methods' import { PaymentChannelClaim } from '../models/transactions/paymentChannelClaim' import { Transaction } from '../models/transactions/transaction' -import createCrossChainPayment from './createCrossChainPayment' import { deriveKeypair, deriveAddress, deriveXAddress } from './derive' import getBalanceChanges from './getBalanceChanges' import getNFTokenID from './getNFTokenID' @@ -220,6 +219,5 @@ export { encodeForSigning, encodeForSigningClaim, getNFTokenID, - createCrossChainPayment, parseNFTokenID, } diff --git a/packages/xrpl/test/utils/createCrossChainPayment.test.ts b/packages/xrpl/test/utils/createCrossChainPayment.test.ts deleted file mode 100644 index 8d8f1848..00000000 --- a/packages/xrpl/test/utils/createCrossChainPayment.test.ts +++ /dev/null @@ -1,124 +0,0 @@ -import { assert } from 'chai' - -import { createCrossChainPayment, convertStringToHex, Payment } from '../../src' - -describe('createCrossChainPayment', function () { - it('successful xchain payment creation', function () { - const payment: Payment = { - TransactionType: 'Payment', - Account: 'rRandom', - Destination: 'rRandom2', - Amount: '3489303', - } - const sidechainAccount = 'rSidechain' - - const expectedPayment = { - ...payment, - Memos: [ - { - Memo: { - MemoData: convertStringToHex(sidechainAccount), - }, - }, - ], - } - - const resultPayment = createCrossChainPayment(payment, sidechainAccount) - assert.deepEqual(resultPayment, expectedPayment) - - // ensure that the original object wasn't modified - assert.notDeepEqual(resultPayment, payment) - }) - - it('successful xchain payment creation with memo', function () { - const memo = { - Memo: { - MemoData: 'deadbeef', - }, - } - const payment: Payment = { - TransactionType: 'Payment', - Account: 'rRandom', - Destination: 'rRandom2', - Amount: '3489303', - Memos: [memo], - } - const sidechainAccount = 'rSidechain' - - const expectedPayment = { - ...payment, - Memos: [ - { - Memo: { - MemoData: convertStringToHex(sidechainAccount), - }, - }, - memo, - ], - } - - const resultPayment = createCrossChainPayment(payment, sidechainAccount) - assert.deepEqual(resultPayment, expectedPayment) - - // ensure that the original object wasn't modified - assert.notDeepEqual(resultPayment, payment) - }) - - it('removes TxnSignature', function () { - const payment: Payment = { - TransactionType: 'Payment', - Account: 'rRandom', - Destination: 'rRandom2', - Amount: '3489303', - TxnSignature: 'asodfiuaosdfuaosd', - } - const sidechainAccount = 'rSidechain' - - const expectedPayment = { - ...payment, - Memos: [ - { - Memo: { - MemoData: convertStringToHex(sidechainAccount), - }, - }, - ], - } - delete expectedPayment.TxnSignature - - const resultPayment = createCrossChainPayment(payment, sidechainAccount) - assert.deepEqual(resultPayment, expectedPayment) - - // ensure that the original object wasn't modified - assert.notDeepEqual(resultPayment, payment) - }) - - it('fails with 3 memos', function () { - const payment: Payment = { - TransactionType: 'Payment', - Account: 'rRandom', - Destination: 'rRandom2', - Amount: '3489303', - Memos: [ - { - Memo: { - MemoData: '2934723843ace', - }, - }, - { - Memo: { - MemoData: '2934723843ace', - }, - }, - { - Memo: { - MemoData: '2934723843ace', - }, - }, - ], - } - assert.throws(() => { - createCrossChainPayment(payment, 'rSidechain') - }, /Cannot have more than 2 memos/u) - }) -})