From 7fdf68c49df58c4b7b9466c6e16293b749314fc2 Mon Sep 17 00:00:00 2001 From: Wietse Wind Date: Thu, 1 Sep 2022 22:47:51 +0200 Subject: [PATCH 01/54] Update LICENSE --- LICENSE | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/LICENSE b/LICENSE index 7fd370b97..826b507f3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,13 +1,13 @@ CUSTOM (dual) License (!) -Copyright (c) 2019 XRPL Labs OU +Copyright (c) 2019 The Integrators B.V. (XRPL Labs) -> If in doubt about / questions regarding XUMM licenses: please contact XRPL Labs: w@xrpl-labs.com +> If in doubt about / questions regarding Xumm licenses: please contact XRPL Labs: w@xrpl-labs.com # For public / commercial / beta use ### Eg. XRPL forks, public projects, etc. -Permission required by XRPL Labs OU (EE) / The Integrators BV (NL). +Permission required by XRPL Labs (The Integrators BV (NL)). Please contact w@xrpl-labs.com with a project description. A license may be granted (free of charge or paid) depending on the project & target audience. @@ -15,11 +15,9 @@ Please contact w@xrpl-labs.com with a project description. A license may be gran ### Eg. Educational, research (non commercial, non public) Permission is hereby granted to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +of this software and associated documentation files (the "Software"), +including the rights to use, modify, merge and publish for personal AND +non commercial use. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. From 7877c5dca9be3904379fb900c07546136178b5c9 Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Tue, 19 Dec 2023 11:52:25 +0100 Subject: [PATCH 02/54] fix: crash when sending `txDetails` command from xApp --- src/screens/Modal/XAppBrowser/XAppBrowserModal.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/screens/Modal/XAppBrowser/XAppBrowserModal.tsx b/src/screens/Modal/XAppBrowser/XAppBrowserModal.tsx index 9c0eeb161..9866502df 100644 --- a/src/screens/Modal/XAppBrowser/XAppBrowserModal.tsx +++ b/src/screens/Modal/XAppBrowser/XAppBrowserModal.tsx @@ -408,6 +408,8 @@ class XAppBrowserModal extends Component { }; openTxDetails = async (data: { tx: string; account: string }) => { + const { network } = this.state; + const hash = get(data, 'tx', undefined); const address = get(data, 'account', undefined); @@ -427,7 +429,7 @@ class XAppBrowserModal extends Component { } setTimeout(() => { - Navigator.showModal(AppScreens.Transaction.Details, { hash, account, asModal: true }); + Navigator.showModal(AppScreens.Modal.TransactionLoader, { hash, account, network: network.key }); }, delay); }; From dc3e616dc3d5b40ee4a365aced38a6baf6bde2b0 Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Tue, 19 Dec 2023 11:52:59 +0100 Subject: [PATCH 03/54] fix: TransactionDetails screen header size when shown as modal --- src/components/General/Header/Header.tsx | 11 +++++++++-- src/components/General/Header/styles.ts | 4 +--- src/screens/Events/Details/DetailsView.tsx | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/General/Header/Header.tsx b/src/components/General/Header/Header.tsx index ba3bcf6be..3aeb0f835 100644 --- a/src/components/General/Header/Header.tsx +++ b/src/components/General/Header/Header.tsx @@ -126,7 +126,7 @@ const Children = ({ /* Component ==================================================================== */ class Header extends PureComponent { - static Height = AppSizes.heightPercentageToDP(9) + (Platform.OS === 'ios' ? AppSizes.statusBarHeight : 0); + static Height = AppSizes.heightPercentageToDP(9); static defaultProps = { placement: 'center', @@ -152,7 +152,14 @@ class Header extends PureComponent { this.props; return ( - + {leftComponent} diff --git a/src/components/General/Header/styles.ts b/src/components/General/Header/styles.ts index fda627c74..4867b727e 100644 --- a/src/components/General/Header/styles.ts +++ b/src/components/General/Header/styles.ts @@ -6,15 +6,13 @@ import { AppStyles, AppSizes } from '@theme'; const styles = StyleService.create({ container: { paddingHorizontal: 20, - paddingTop: Platform.OS === 'ios' ? AppSizes.statusBarHeight : 0, + marginTop: Platform.select({ ios: AppSizes.statusBarHeight, default: 0 }), flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', zIndex: 99999, - height: AppSizes.heightPercentageToDP(9) + (Platform.OS === 'ios' ? AppSizes.statusBarHeight : 0), backgroundColor: '$background', }, - fixedContainer: { flex: 3, }, diff --git a/src/screens/Events/Details/DetailsView.tsx b/src/screens/Events/Details/DetailsView.tsx index 4916abe19..5159665cf 100644 --- a/src/screens/Events/Details/DetailsView.tsx +++ b/src/screens/Events/Details/DetailsView.tsx @@ -1534,7 +1534,7 @@ class TransactionDetailsView extends Component { onPress: this.showMenu, }} // eslint-disable-next-line react-native/no-inline-styles - containerStyle={asModal && { paddingTop: 0 }} + containerStyle={asModal && { marginTop: 0 }} /> {scamAlert && ( From eb82fcb35e73117a0d19f68918bf6119ef27e49b Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Tue, 19 Dec 2023 12:23:28 +0100 Subject: [PATCH 04/54] fix: xApp store list placeholder color --- .../Modules/XAppStore/AppsList/AppItem/styles.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Modules/XAppStore/AppsList/AppItem/styles.tsx b/src/components/Modules/XAppStore/AppsList/AppItem/styles.tsx index 4dd6af631..872ea0faa 100644 --- a/src/components/Modules/XAppStore/AppsList/AppItem/styles.tsx +++ b/src/components/Modules/XAppStore/AppsList/AppItem/styles.tsx @@ -15,8 +15,8 @@ const styles = StyleService.create({ color: '$textPrimary', }, appTitlePlaceholder: { - color: '$light', - backgroundColor: '$light', + color: StyleService.select({ dark: '$darkGrey', light: '$light' }), + backgroundColor: StyleService.select({ dark: '$darkGrey', light: '$light' }), }, appIcon: { width: '80%', @@ -24,7 +24,7 @@ const styles = StyleService.create({ borderRadius: 10, }, appIconPlaceholder: { - backgroundColor: '$silver', + backgroundColor: StyleService.select({ dark: '$darkGrey', light: '$silver' }), }, titleContainer: { flex: 1, From 6de117bec9943705763c1469c21da283ed6c9ee2 Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Tue, 19 Dec 2023 12:37:02 +0100 Subject: [PATCH 05/54] fix(android): checkAppUpdate is not resolving if failed --- android/app/src/main/java/libs/common/AppUpdateModule.java | 3 +++ src/services/AppService.ts | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/java/libs/common/AppUpdateModule.java b/android/app/src/main/java/libs/common/AppUpdateModule.java index 0731076bc..f2f7e6393 100644 --- a/android/app/src/main/java/libs/common/AppUpdateModule.java +++ b/android/app/src/main/java/libs/common/AppUpdateModule.java @@ -105,6 +105,9 @@ public void checkUpdate(Promise promise) { promise.resolve(false); } }); + appUpdateInfoTask.addOnFailureListener( + promise::reject + ); } catch (Exception e) { promise.reject(e); } diff --git a/src/services/AppService.ts b/src/services/AppService.ts index f8766163e..78eb49bb8 100644 --- a/src/services/AppService.ts +++ b/src/services/AppService.ts @@ -56,7 +56,7 @@ class AppService extends EventEmitter { this.prevAppState = undefined; this.currentAppState = AppStateStatus.Active; - this.logger = LoggerService.createLogger('AppState'); + this.logger = LoggerService.createLogger('AppService'); } initialize = () => { @@ -131,7 +131,8 @@ class AppService extends EventEmitter { ); } }) - .catch(() => { + .catch((error) => { + this.logger.warn('checkAppUpdate', error); // ignore }); }; From 6c67cf579c3681cadc8fb60f61ac8310981461fb Mon Sep 17 00:00:00 2001 From: tequ Date: Thu, 21 Dec 2023 16:52:22 +0900 Subject: [PATCH 06/54] [JA] fix submittingToLedger translation --- src/locale/translations/ja.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/locale/translations/ja.json b/src/locale/translations/ja.json index 0cc793e8e..1d8921d36 100644 --- a/src/locale/translations/ja.json +++ b/src/locale/translations/ja.json @@ -981,7 +981,7 @@ "somethingWentWrong": "問題が発生しました!", "resultCopiedToClipboard": "結果をクリップボードにコピーしました", "txIdCopiedToClipboard": "トランザクションIDがクリップボードにコピーされました", - "submittingToLedger": "%{network}レジャーへトランザクションを送信中", + "submittingToLedger": "%{network}へトランザクションを送信中", "sendingFrom": "から送信しています", "enterDescription": "説明を入力してください", "enterPublicMemo": "公開メモを入力してください(オプション)", @@ -1276,4 +1276,4 @@ ], "abbr": "ja" } -} \ No newline at end of file +} From 3d794e43c5630ce74306fb1143f18e095eb9f33d Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Thu, 21 Dec 2023 12:36:09 +0100 Subject: [PATCH 07/54] fix: NetworkService validation checks for server_definitions response --- src/services/NetworkService.ts | 81 ++++-- src/services/__tests__/NetworkService.test.ts | 259 +++++++++++++----- 2 files changed, 245 insertions(+), 95 deletions(-) diff --git a/src/services/NetworkService.ts b/src/services/NetworkService.ts index 8d712bc3d..f4f660bee 100644 --- a/src/services/NetworkService.ts +++ b/src/services/NetworkService.ts @@ -2,6 +2,7 @@ * Network service */ +import { isPlainObject, isArray, isString } from 'lodash'; import { v4 as uuidv4 } from 'uuid'; import EventEmitter from 'events'; import Realm from 'realm'; @@ -452,44 +453,64 @@ class NetworkService extends EventEmitter { /** * Updates the network definitions and persists them to the `NetworkRepository`. */ - updateNetworkDefinitions = () => { - // include definitions hash if exist in the request - const request = { - command: 'server_definitions', - }; + updateNetworkDefinitions = async () => { + try { + // include definitions hash if exist in the request + const request = { command: 'server_definitions' }; - let definitionsHash = ''; + let definitionsHash = ''; - if (this.network.definitions) { - definitionsHash = this.network.definitions.hash as string; - Object.assign(request, { hash: definitionsHash }); - } + if (this.network.definitions) { + definitionsHash = this.network.definitions.hash as string; + Object.assign(request, { hash: definitionsHash }); + } - this.send(request) - .then(async (resp: any) => { - // an error happened - if ('error' in resp) { - // ignore - return; - } + const definitionsResp = await this.send(request); - // nothing has been changed - if (resp?.hash === definitionsHash) { - return; + // validate the response + if (typeof definitionsResp !== 'object' || 'error' in definitionsResp || !('hash' in definitionsResp)) { + this.logger.warn('server_definitions got invalid response:', definitionsResp); + return; + } + + // nothing has been changed + if (definitionsResp.hash === definitionsHash) { + return; + } + + // validate the response + const respValidation = { + TYPES: isPlainObject, + TRANSACTION_RESULTS: isPlainObject, + TRANSACTION_TYPES: isPlainObject, + LEDGER_ENTRY_TYPES: isPlainObject, + FIELDS: isArray, + hash: isString, + } as { [key: string]: (value?: any) => boolean }; + + const definitions = {}; + + for (const key in respValidation) { + if (Object.prototype.hasOwnProperty.call(respValidation, key)) { + // validate + if (respValidation[key](definitionsResp[key]) === false) { + this.logger.warn('server_definitions got invalid format:', definitionsResp); + return; + } + // set the key + Object.assign(definitions, { [key]: definitionsResp[key] }); } + } - // remove unnecessary fields - delete resp.__command; - delete resp.__replyMs; + this.logger.debug(`Updating network [${this.network.networkId}] definitions ${definitionsResp.hash} `); - NetworkRepository.update({ - id: this.network.id, - definitionsString: JSON.stringify(resp), - }); - }) - .catch((error: any) => { - this.logger.error(error); + NetworkRepository.update({ + id: this.network.id, + definitionsString: JSON.stringify(definitions), }); + } catch (error: any) { + this.logger.error('updateNetworkDefinitions: ', error); + } }; /** diff --git a/src/services/__tests__/NetworkService.test.ts b/src/services/__tests__/NetworkService.test.ts index f1dd73999..6e2f115e1 100644 --- a/src/services/__tests__/NetworkService.test.ts +++ b/src/services/__tests__/NetworkService.test.ts @@ -1,3 +1,5 @@ +import NetworkRepository from '@store/repositories/network'; + import NetworkService from '../NetworkService'; import * as FeeUtils from '@common/utils/fee'; @@ -19,89 +21,216 @@ describe('NetworkService', () => { }); }); - describe('Not Hooks enabled network', () => { - let isFeatureEnabledSpy: any; - let prepareTxForHookFeeSpy: any; - - beforeAll(() => { - // set the network as normal network without hooks amendment - isFeatureEnabledSpy = jest - .spyOn(networkService.network, 'isFeatureEnabled') - .mockImplementation(() => false); - isFeatureEnabledSpy = jest.spyOn(networkService.network, 'isFeatureEnabled').mockImplementation(() => true); - prepareTxForHookFeeSpy = jest.spyOn(FeeUtils, 'PrepareTxForHookFee').mockImplementation(() => 'SIGNED_TX'); + describe('Update network definitions', () => { + it('updates network definitions correctly', async () => { + const returnedResponse = { + TYPES: {}, + TRANSACTION_RESULTS: {}, + TRANSACTION_TYPES: {}, + LEDGER_ENTRY_TYPES: {}, + // @ts-ignore + FIELDS: [], + hash: 'SOME_HASH', + }; + + const spy0 = jest.spyOn(networkService, 'send').mockImplementation(() => Promise.resolve(returnedResponse)); + const spy1 = jest.spyOn(NetworkRepository, 'update'); + + await networkService.updateNetworkDefinitions(); + + expect(spy0).toHaveBeenCalledWith({ command: 'server_definitions' }); + expect(spy1).toHaveBeenCalledWith({ + id: undefined, + definitionsString: JSON.stringify(returnedResponse), + }); + + spy0.mockRestore(); + spy1.mockRestore(); }); - afterAll(() => { - isFeatureEnabledSpy.mockRestore(); - prepareTxForHookFeeSpy.mockRestore(); + it('warns on invalid response', async () => { + const invalidResponses = [{ error: 'some error' }, 'invalid resp', {}]; + + // eslint-disable-next-line guard-for-in + for (const resp of invalidResponses) { + const spy0 = jest.spyOn(networkService, 'send').mockImplementation(() => Promise.resolve(resp)); + // @ts-ignore + const spy1 = jest.spyOn(NetworkService.logger, 'warn'); + const spy2 = jest.spyOn(NetworkRepository, 'update'); + + await networkService.updateNetworkDefinitions(); + + expect(spy0).toHaveBeenCalledWith({ command: 'server_definitions' }); + expect(spy1).toHaveBeenCalledWith('server_definitions got invalid response:', resp); + expect(spy2).not.toHaveBeenCalled(); + + spy0.mockRestore(); + spy1.mockRestore(); + } }); - it('should return right calculated available fees', async () => { - // normal network fees - const spy0 = jest.spyOn(networkService, 'send').mockImplementation(() => - Promise.resolve({ - drops: { base_fee: '15' }, - }), - ); - - const availableFees = await networkService.getAvailableNetworkFee({}); - - expect(availableFees).toStrictEqual({ - availableFees: [ - { type: 'LOW', value: '15' }, - { type: 'MEDIUM', value: '20' }, - { type: 'HIGH', value: '30' }, - ], - feeHooks: 0, - suggested: 'LOW', + it('returns early when hash has not changed', async () => { + const returnedResponse = { + TYPES: {}, + TRANSACTION_RESULTS: {}, + TRANSACTION_TYPES: {}, + LEDGER_ENTRY_TYPES: {}, + // @ts-ignore + FIELDS: [], + hash: 'SOME_HASH', + }; + + const spy0 = jest.spyOn(networkService, 'send').mockImplementation(() => Promise.resolve(returnedResponse)); + const spy1 = jest.spyOn(NetworkRepository, 'update'); + + // @ts-ignore + jest.replaceProperty(networkService, 'network', { + definitions: { + hash: 'SOME_HASH', + }, + isFeatureEnabled: jest.fn(), }); + await networkService.updateNetworkDefinitions(); + + expect(spy0).toHaveBeenCalledWith({ command: 'server_definitions', hash: 'SOME_HASH' }); + expect(spy1).toHaveBeenCalledTimes(0); + spy0.mockRestore(); + spy1.mockRestore(); }); - }); - describe('Hooks enabled network', () => { - let isFeatureEnabledSpy: any; - let prepareTxForHookFeeSpy: any; + it('validates the response object', async () => { + const returnedResponse = { + TYPES: 'should be object', + TRANSACTION_RESULTS: {}, + TRANSACTION_TYPES: {}, + LEDGER_ENTRY_TYPES: {}, + // @ts-ignore + FIELDS: [], + hash: 'SOME_HASH', + }; + + // @ts-ignore + jest.replaceProperty(networkService, 'network', { + definitions: undefined, + isFeatureEnabled: jest.fn(), + }); + + const spy0 = jest.spyOn(networkService, 'send').mockImplementation(() => Promise.resolve(returnedResponse)); + const spy1 = jest.spyOn(NetworkRepository, 'update'); + // @ts-ignore + const spy2 = jest.spyOn(NetworkService.logger, 'warn'); - beforeAll(() => { - // set the network as hook enabled network - isFeatureEnabledSpy = jest.spyOn(networkService.network, 'isFeatureEnabled').mockImplementation(() => true); - prepareTxForHookFeeSpy = jest.spyOn(FeeUtils, 'PrepareTxForHookFee').mockImplementation(() => 'SIGNED_TX'); + await networkService.updateNetworkDefinitions(); + + expect(spy0).toHaveBeenCalledWith({ command: 'server_definitions' }); + expect(spy1).not.toHaveBeenCalled(); + expect(spy2).toHaveBeenCalledWith('server_definitions got invalid format:', returnedResponse); + + spy0.mockRestore(); + spy1.mockRestore(); + spy2.mockRestore(); }); - afterAll(() => { - isFeatureEnabledSpy.mockRestore(); - prepareTxForHookFeeSpy.mockRestore(); + afterEach(() => { + jest.clearAllMocks(); }); + }); - it('should return right calculated available fees', async () => { - // normal network fees - const spy0 = jest.spyOn(networkService, 'send').mockImplementation(() => - Promise.resolve({ - drops: { - base_fee: 6176, - }, - fee_hooks_feeunits: 6186, - }), - ); - - const availableFees = await networkService.getAvailableNetworkFee({ - TransactionType: 'Payment', + describe('Calculate fee', () => { + describe('Not Hooks enabled network', () => { + let isFeatureEnabledSpy: any; + let prepareTxForHookFeeSpy: any; + + beforeAll(() => { + // set the network as normal network without hooks amendment + isFeatureEnabledSpy = jest + .spyOn(networkService.network, 'isFeatureEnabled') + .mockImplementation(() => false); + isFeatureEnabledSpy = jest + .spyOn(networkService.network, 'isFeatureEnabled') + .mockImplementation(() => true); + prepareTxForHookFeeSpy = jest + .spyOn(FeeUtils, 'PrepareTxForHookFee') + .mockImplementation(() => 'SIGNED_TX'); }); - expect(availableFees).toStrictEqual({ - availableFees: [ - { type: 'LOW', value: '6176' }, - { type: 'MEDIUM', value: '7500' }, - { type: 'HIGH', value: '11000' }, - ], - feeHooks: 10, - suggested: 'LOW', + afterAll(() => { + isFeatureEnabledSpy.mockRestore(); + prepareTxForHookFeeSpy.mockRestore(); }); - spy0.mockRestore(); + it('should return right calculated available fees', async () => { + // normal network fees + const spy0 = jest.spyOn(networkService, 'send').mockImplementation(() => + Promise.resolve({ + drops: { base_fee: '15' }, + }), + ); + + const availableFees = await networkService.getAvailableNetworkFee({}); + + expect(availableFees).toStrictEqual({ + availableFees: [ + { type: 'LOW', value: '15' }, + { type: 'MEDIUM', value: '20' }, + { type: 'HIGH', value: '30' }, + ], + feeHooks: 0, + suggested: 'LOW', + }); + + spy0.mockRestore(); + }); + }); + + describe('Hooks enabled network', () => { + let isFeatureEnabledSpy: any; + let prepareTxForHookFeeSpy: any; + + beforeAll(() => { + // set the network as hook enabled network + isFeatureEnabledSpy = jest + .spyOn(networkService.network, 'isFeatureEnabled') + .mockImplementation(() => true); + prepareTxForHookFeeSpy = jest + .spyOn(FeeUtils, 'PrepareTxForHookFee') + .mockImplementation(() => 'SIGNED_TX'); + }); + + afterAll(() => { + isFeatureEnabledSpy.mockRestore(); + prepareTxForHookFeeSpy.mockRestore(); + }); + + it('should return right calculated available fees', async () => { + // normal network fees + const spy0 = jest.spyOn(networkService, 'send').mockImplementation(() => + Promise.resolve({ + drops: { + base_fee: 6176, + }, + fee_hooks_feeunits: 6186, + }), + ); + + const availableFees = await networkService.getAvailableNetworkFee({ + TransactionType: 'Payment', + }); + + expect(availableFees).toStrictEqual({ + availableFees: [ + { type: 'LOW', value: '6176' }, + { type: 'MEDIUM', value: '7500' }, + { type: 'HIGH', value: '11000' }, + ], + feeHooks: 10, + suggested: 'LOW', + }); + + spy0.mockRestore(); + }); }); }); }); From 75031c62b0a6920e949952646445ce7379d3e511 Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Thu, 21 Dec 2023 15:08:03 +0100 Subject: [PATCH 08/54] fix: crash on share link for ledger objects --- .../libs/ledger/objects/BaseLedgerObject.ts | 8 -------- src/common/utils/codec.ts | 12 +++++------ src/screens/Events/Details/DetailsView.tsx | 20 +++++++++++++------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/common/libs/ledger/objects/BaseLedgerObject.ts b/src/common/libs/ledger/objects/BaseLedgerObject.ts index 11e895138..266a75cda 100644 --- a/src/common/libs/ledger/objects/BaseLedgerObject.ts +++ b/src/common/libs/ledger/objects/BaseLedgerObject.ts @@ -3,10 +3,6 @@ */ import { get, has, set, isUndefined } from 'lodash'; -import { EncodeCTID } from '@common/utils/codec'; - -import NetworkService from '@services/NetworkService'; - import { Account } from '@common/libs/ledger/parser/types'; import Flag from '@common/libs/ledger/parser/common/flag'; @@ -21,10 +17,6 @@ class BaseLedgerObject { this.object = object; } - get CTID(): string { - return EncodeCTID(this.Sequence, this.Index, NetworkService.getNetworkId()); - } - get Account(): Account { const source = get(this, ['object', 'Account'], undefined); const sourceTag = get(this, ['object', 'SourceTag'], undefined); diff --git a/src/common/utils/codec.ts b/src/common/utils/codec.ts index 8c46fc83c..a497c6d27 100644 --- a/src/common/utils/codec.ts +++ b/src/common/utils/codec.ts @@ -119,24 +119,24 @@ const DecodeNFTokenID = (nfTokenID: string) => { */ const EncodeCTID = (ledgerSeq: number, txnIndex: number, networkId: number): string => { if (typeof ledgerSeq !== 'number') { - throw new Error('ledgerSeq must be a number.'); + throw new Error(`ledgerSeq must be a number got ${typeof ledgerSeq}.`); } if (ledgerSeq > 0xfffffff || ledgerSeq < 0) { - throw new Error('ledgerSeq must not be greater than 268435455 or less than 0.'); + throw new Error(`ledgerSeq must not be greater than 268435455 or less than 0, got ${ledgerSeq}.`); } if (typeof txnIndex !== 'number') { - throw new Error('txnIndex must be a number.'); + throw new Error(`txnIndex must be a number got ${txnIndex}.`); } if (txnIndex > 0xffff || txnIndex < 0) { - throw new Error('txnIndex must not be greater than 65535 or less than 0.'); + throw new Error(`txnIndex must not be greater than 65535 or less than 0, got ${txnIndex}`); } if (typeof networkId !== 'number') { - throw new Error('networkId must be a number.'); + throw new Error(`networkId must be a number got ${typeof networkId}.`); } if (networkId > 0xffff || networkId < 0) { - throw new Error('networkId must not be greater than 65535 or less than 0.'); + throw new Error(`networkId must not be greater than 65535 or less than 0, got ${networkId}`); } // @ts-ignore diff --git a/src/screens/Events/Details/DetailsView.tsx b/src/screens/Events/Details/DetailsView.tsx index 5159665cf..3763386b4 100644 --- a/src/screens/Events/Details/DetailsView.tsx +++ b/src/screens/Events/Details/DetailsView.tsx @@ -158,7 +158,13 @@ class TransactionDetailsView extends Component { getTransactionLink = () => { const { tx } = this.props; - return GetTransactionLink(tx.CTID); + + // only base transactions have CTID + if (tx instanceof BaseTransaction) { + return GetTransactionLink(tx.CTID); + } + + return '#'; }; shareTxLink = () => { @@ -1518,7 +1524,7 @@ class TransactionDetailsView extends Component { }; render() { - const { asModal } = this.props; + const { tx, asModal } = this.props; const { scamAlert } = this.state; return ( @@ -1529,10 +1535,12 @@ class TransactionDetailsView extends Component { onPress: this.close, }} centerComponent={{ text: Localize.t('events.transactionDetails') }} - rightComponent={{ - icon: 'IconMoreHorizontal', - onPress: this.showMenu, - }} + rightComponent={ + tx instanceof BaseTransaction && { + icon: 'IconMoreHorizontal', + onPress: this.showMenu, + } + } // eslint-disable-next-line react-native/no-inline-styles containerStyle={asModal && { marginTop: 0 }} /> From ee2e856a38f79e94a8021bedb55c2aedbdb8f5ea Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Thu, 21 Dec 2023 15:12:27 +0100 Subject: [PATCH 09/54] fix: AccountList check datastore object is valid --- src/screens/Account/List/AccountsListView.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/screens/Account/List/AccountsListView.tsx b/src/screens/Account/List/AccountsListView.tsx index 3cb13d872..4295cca8d 100644 --- a/src/screens/Account/List/AccountsListView.tsx +++ b/src/screens/Account/List/AccountsListView.tsx @@ -127,6 +127,10 @@ class AccountListView extends Component { onItemPress = (account: AccountModel) => { const { reorderEnabled } = this.state; + if (!account?.isValid()) { + return; + } + if (!reorderEnabled) { Navigator.push(AppScreens.Account.Edit.Settings, { account }); } @@ -148,6 +152,7 @@ class AccountListView extends Component { this.setState({ dataSource: data, }); + for (let i = 0; i < data.length; i++) { if (data[i].address) { AccountRepository.update({ @@ -166,8 +171,8 @@ class AccountListView extends Component { }); }; - itemKeyExtractor = (item: AccountModel) => { - return `account-${item.address}`; + itemKeyExtractor = (item: AccountModel, index: number) => { + return item?.isValid() ? `account-${item.address}` : `account-${index}`; }; renderItem = ({ item }: { item: AccountModel }) => { From a455895d56fb1553ed8570a425781dfb2d8c3b58 Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Thu, 21 Dec 2023 15:15:40 +0100 Subject: [PATCH 10/54] fix: account setting change password button misalignment --- src/screens/Account/Edit/AccountSettingsView.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/screens/Account/Edit/AccountSettingsView.tsx b/src/screens/Account/Edit/AccountSettingsView.tsx index bfc883213..a721fc534 100644 --- a/src/screens/Account/Edit/AccountSettingsView.tsx +++ b/src/screens/Account/Edit/AccountSettingsView.tsx @@ -379,7 +379,6 @@ class AccountSettingsView extends Component { : account.encryptionLevel} - {/* Change passphrase */} {account.encryptionLevel === EncryptionLevels.Passphrase && ( { onPress={this.showChangePassphrase} > {Localize.t('account.changePassword')} + + )} From 5f51a4e014e090d80f88090315772cb562a1fbea Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Tue, 2 Jan 2024 11:18:54 +0100 Subject: [PATCH 11/54] fix: events list is not updating when switching account --- src/screens/Events/EventsView.tsx | 55 ++++++++++++++++++++----------- src/store/repositories/core.ts | 3 +- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/screens/Events/EventsView.tsx b/src/screens/Events/EventsView.tsx index 058a60e60..a5ce53c63 100644 --- a/src/screens/Events/EventsView.tsx +++ b/src/screens/Events/EventsView.tsx @@ -94,6 +94,7 @@ class EventsView extends Component { static screenName = AppScreens.TabBar.Events; private forceReload: boolean; + private isScreenVisible: boolean; private navigationListener: EventSubscription; static options() { @@ -123,11 +124,13 @@ class EventsView extends Component { }; this.forceReload = false; + this.isScreenVisible = false; } shouldComponentUpdate(nextProps: Props, nextState: State) { const { dataSource, account, isLoading, canLoadMore, isLoadingMore, filters } = this.state; const { timestamp } = this.props; + return ( !isEqual(nextState.dataSource, dataSource) || !isEqual(nextState.isLoading, isLoading) || @@ -140,28 +143,25 @@ class EventsView extends Component { } componentDidAppear() { + // keep track of screen visibility + this.isScreenVisible = true; + + // check if we need to reload the screen if (this.forceReload) { // set the flag to false this.forceReload = false; - // reset everything and load transaction - this.setState( - { - account: CoreRepository.getDefaultAccount(), - dataSource: [], - transactions: [], - plannedTransactions: [], - lastMarker: undefined, - canLoadMore: true, - }, - this.updateDataSource, - ); + // reload the state + this.reloadState(); } } - componentDidMount() { - const { account } = this.state; + componentDidDisappear() { + // keep track of screen visibility + this.isScreenVisible = false; + } + componentDidMount() { // componentDidDisappear event this.navigationListener = Navigation.events().bindComponent(this); @@ -175,11 +175,7 @@ class EventsView extends Component { AppService.on('appStateChange', this.onAppStateChange); // update data source after component mount - InteractionManager.runAfterInteractions(() => { - if (account?.isValid()) { - this.updateDataSource(); - } - }); + InteractionManager.runAfterInteractions(this.updateDataSource); } componentWillUnmount() { @@ -194,10 +190,31 @@ class EventsView extends Component { } } + reloadState = () => { + // reset everything and load transaction + this.setState( + { + account: CoreRepository.getDefaultAccount(), + dataSource: [], + transactions: [], + plannedTransactions: [], + lastMarker: undefined, + canLoadMore: true, + }, + this.updateDataSource, + ); + }; + onCoreSettingsUpdate = (_coreSettings: CoreModel, changes: Partial) => { // force reload if network or default account changed if (has(changes, 'network') || has(changes, 'account')) { this.forceReload = true; + + // in some cases account can be switched when event list is visible, + // we need to force reload without relying on componentDidAppear event + if (this.isScreenVisible) { + InteractionManager.runAfterInteractions(this.reloadState); + } } }; diff --git a/src/store/repositories/core.ts b/src/store/repositories/core.ts index 85adc5d67..bc3749cf2 100644 --- a/src/store/repositories/core.ts +++ b/src/store/repositories/core.ts @@ -40,9 +40,8 @@ class CoreRepository extends BaseRepository { if (current) { this.safeWrite(() => { assign(current, settings); - - this.emit('updateSettings', current, settings); }); + this.emit('updateSettings', current, settings); } else { this.create(settings); } From a8f503014341647254fbfd5053d076b0a6e0e359 Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Tue, 2 Jan 2024 11:55:12 +0100 Subject: [PATCH 12/54] feat: add events list search base on TrustSet currency and issuer --- src/screens/Events/EventsView.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/screens/Events/EventsView.tsx b/src/screens/Events/EventsView.tsx index a5ce53c63..135b179dc 100644 --- a/src/screens/Events/EventsView.tsx +++ b/src/screens/Events/EventsView.tsx @@ -698,12 +698,12 @@ class EventsView extends Component { keys: [ 'Account.address', 'Account.tag', - 'Account.name', 'Destination.address', - 'Destination.name', 'Destination.tag', 'Amount.value', 'Amount.currency', + 'Currency', // TrustSet currency + 'Issuer', // TrustSet issuer 'Hash', ], shouldSort: false, @@ -716,9 +716,7 @@ class EventsView extends Component { keys: [ 'Account.address', 'Account.tag', - 'Account.name', 'Destination.address', - 'Destination.name', 'Destination.tag', 'Amount.value', 'Amount.currency', From 0652aedb04700ff3dd940e56ee1bca6766f62cf1 Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Tue, 2 Jan 2024 15:54:08 +0100 Subject: [PATCH 13/54] fix: show HookReturnString message when receiving tecHOOK_REJECTED --- .../parser/__tests__/fixtures/meta.json | 45 ++++++++++ .../libs/ledger/parser/__tests__/meta.test.ts | 12 +++ src/common/libs/ledger/parser/meta.ts | 89 ++++++++++--------- src/common/libs/ledger/parser/types.ts | 10 ++- .../transactions/genuine/BaseTransaction.ts | 42 +++++++-- .../genuine/TrustSet/TrustSetInfo.ts | 5 +- .../genuine/__tests__/offerCreate.test.ts | 16 ++-- .../genuine/__tests__/payment.test.ts | 6 +- src/common/libs/ledger/types.ts | 15 ++++ .../EventsList/EventListItems/Transaction.tsx | 4 +- src/locale/en.json | 7 +- src/locale/translations/af.json | 7 +- src/locale/translations/ar.json | 7 +- src/locale/translations/bg.json | 7 +- src/locale/translations/bn-BD.json | 7 +- src/locale/translations/ca.json | 7 +- src/locale/translations/cs.json | 7 +- src/locale/translations/da.json | 7 +- src/locale/translations/de.json | 7 +- src/locale/translations/el.json | 7 +- src/locale/translations/en-AU.json | 7 +- src/locale/translations/es-419.json | 7 +- src/locale/translations/es.json | 7 +- src/locale/translations/et.json | 7 +- src/locale/translations/eu.json | 7 +- src/locale/translations/fi.json | 7 +- src/locale/translations/fil.json | 7 +- src/locale/translations/fr.json | 7 +- src/locale/translations/gl-ES.json | 7 +- src/locale/translations/gu.json | 7 +- src/locale/translations/he.json | 7 +- src/locale/translations/hi-IN.json | 7 +- src/locale/translations/hr.json | 7 +- src/locale/translations/ht.json | 7 +- src/locale/translations/hu.json | 7 +- src/locale/translations/id.json | 7 +- src/locale/translations/it.json | 7 +- src/locale/translations/ja.json | 9 +- src/locale/translations/ka.json | 7 +- src/locale/translations/kk.json | 7 +- src/locale/translations/kn.json | 7 +- src/locale/translations/ko.json | 7 +- src/locale/translations/lt.json | 7 +- src/locale/translations/lv.json | 7 +- src/locale/translations/ml.json | 7 +- src/locale/translations/mr.json | 7 +- src/locale/translations/nl.json | 7 +- src/locale/translations/no-NO.json | 7 +- src/locale/translations/pa.json | 7 +- src/locale/translations/pl.json | 7 +- src/locale/translations/pt-BR.json | 7 +- src/locale/translations/pt.json | 7 +- src/locale/translations/ro.json | 7 +- src/locale/translations/ru.json | 7 +- src/locale/translations/sd.json | 7 +- src/locale/translations/sk.json | 7 +- src/locale/translations/sl.json | 7 +- src/locale/translations/sr.json | 7 +- src/locale/translations/sv.json | 7 +- src/locale/translations/sw.json | 7 +- src/locale/translations/ta-IN.json | 7 +- src/locale/translations/te-IN.json | 7 +- src/locale/translations/tr.json | 7 +- src/locale/translations/uk.json | 7 +- src/locale/translations/ur.json | 7 +- src/locale/translations/uz.json | 7 +- src/locale/translations/vi.json | 7 +- src/locale/translations/zh-TW.json | 7 +- src/locale/translations/zh.json | 7 +- src/screens/Events/Details/DetailsView.tsx | 8 +- .../Steps/Result/ResultStep.tsx | 41 +++++---- 71 files changed, 450 insertions(+), 258 deletions(-) create mode 100644 src/common/libs/ledger/parser/__tests__/fixtures/meta.json create mode 100644 src/common/libs/ledger/parser/__tests__/meta.test.ts diff --git a/src/common/libs/ledger/parser/__tests__/fixtures/meta.json b/src/common/libs/ledger/parser/__tests__/fixtures/meta.json new file mode 100644 index 000000000..fa555f25c --- /dev/null +++ b/src/common/libs/ledger/parser/__tests__/fixtures/meta.json @@ -0,0 +1,45 @@ +{ + "withHookExecutions": { + "AffectedNodes": [ + { + "ModifiedNode": { + "FinalFields": { + "Account": "rrrrrrrrrrrrrrrrrrrrrhoLvTp", + "AccountIndex": "1", + "Balance": "19999991348", + "Flags": 0, + "OwnerCount": 1, + "RewardAccumulator": "0", + "RewardLgrFirst": 41, + "RewardLgrLast": 41, + "RewardTime": 749750487, + "Sequence": 13 + }, + "LedgerEntryType": "AccountRoot", + "LedgerIndex": "92FA6A9FC8EA6018D5D16532D7795C91BFB0831355BDFDA177E86C8BF997985F", + "PreviousFields": { + "Balance": "19999999988", + "Sequence": 12 + } + } + } + ], + "HookExecutions": [ + { + "HookExecution": { + "HookAccount": "rrrrrrrrrrrrrrrrrrrrBZbvji", + "HookEmitCount": 0, + "HookExecutionIndex": 0, + "HookHash": "610F33B8EBF7EC795F822A454FB852156AEFE50BE0CB8326338A81CD74801864", + "HookInstructionCount": "98", + "HookResult": 3, + "HookReturnCode": "94", + "HookReturnString": "5265776172643A2050617373696E67207265776172642073657475702074786E00", + "HookStateChangeCount": 1 + } + } + ], + "TransactionIndex": 0, + "TransactionResult": "tesSUCCESS" + } +} diff --git a/src/common/libs/ledger/parser/__tests__/meta.test.ts b/src/common/libs/ledger/parser/__tests__/meta.test.ts new file mode 100644 index 000000000..87763d109 --- /dev/null +++ b/src/common/libs/ledger/parser/__tests__/meta.test.ts @@ -0,0 +1,12 @@ +import Meta from '../meta'; + +import metaFixtures from './fixtures/meta.json'; + +describe('Meta Parser', () => { + it('Should get hooks executions', () => { + const instance = new Meta(metaFixtures.withHookExecutions); + expect(instance.parseHookExecutions()).toMatchObject( + metaFixtures.withHookExecutions.HookExecutions.map((e) => e.HookExecution), + ); + }); +}); diff --git a/src/common/libs/ledger/parser/meta.ts b/src/common/libs/ledger/parser/meta.ts index 721ada0c5..57de0459d 100644 --- a/src/common/libs/ledger/parser/meta.ts +++ b/src/common/libs/ledger/parser/meta.ts @@ -5,31 +5,41 @@ import { compact, find, flatMap, flatten, groupBy, has, get, isEmpty, map, mapVa import NetworkService from '@services/NetworkService'; /* Types ==================================================================== */ -import { BalanceChangeType, OfferStatus, OwnerCountChangeType, ClaimRewardStatus } from './types'; +import { BalanceChangeType, OfferStatus, OwnerCountChangeType, OperationActions } from './types'; +import { HookExecution } from '../types'; /* Class ==================================================================== */ class Meta { nodes: any[]; + hookExecutions: HookExecution[]; constructor(meta: any) { - if (!meta.AffectedNodes) { - this.nodes = []; - } - this.nodes = meta.AffectedNodes?.map(this.normalizeNode) || []; + this.nodes = + meta?.AffectedNodes?.map((affectedNode: any) => { + const diffType = Object.keys(affectedNode)[0]; + const node = affectedNode[diffType]; + return { + ...node, + diffType, + entryType: node.LedgerEntryType, + ledgerIndex: node.LedgerIndex, + newFields: node.NewFields || {}, + finalFields: node.FinalFields || {}, + previousFields: node.PreviousFields || {}, + }; + }) || []; + + this.hookExecutions = meta?.HookExecutions?.map((execution: any) => execution.HookExecution) || []; } - private normalizeNode = (affectedNode: any) => { - const diffType = Object.keys(affectedNode)[0]; - const node = affectedNode[diffType]; - return { - ...node, - diffType, - entryType: node.LedgerEntryType, - ledgerIndex: node.LedgerIndex, - newFields: node.NewFields || {}, - finalFields: node.FinalFields || {}, - previousFields: node.PreviousFields || {}, - }; + private getOperationAction = (value: BigNumber): OperationActions => { + if (value.isGreaterThan(0)) { + return OperationActions.INC; + } + if (value.isLessThan(0)) { + return OperationActions.DEC; + } + return OperationActions.INC; }; private combineChanges = (group: any) => { @@ -37,16 +47,15 @@ class Meta { groupBy(group, (node) => [node.balance.action, node.balance.currency]), (changes) => { const change = changes[0].balance; - // must of the case this applies + // in most of the case's this applies if (changes.length === 1) { return change; } // in some case's like applied path multiple of same currency can be transferred - // so we need to combine the values with out considering the issuer + // we need to combine the values without considering the issuer return { currency: change.currency, issuer: change.issuer, - // @ts-ignore value: BigNumber.sum(...flatMap(changes, 'balance.value')) .decimalPlaces(8) .toString(10), @@ -104,7 +113,7 @@ class Meta { return { address: node.finalFields.Account || node.newFields.Account, value: valueNumber.absoluteValue().toNumber(), - action: valueNumber.isNegative() ? 'DEC' : 'INC', + action: this.getOperationAction(valueNumber), }; }; @@ -120,9 +129,11 @@ class Meta { return { address: node.finalFields.Account || node.newFields.Account, balance: { + // @ts-ignore + issuer: undefined, currency: NetworkService.getNativeAsset(), value: valueNumber.absoluteValue().dividedBy(1000000.0).decimalPlaces(8).toString(10), - action: valueNumber.isNegative() ? 'DEC' : 'INC', + action: this.getOperationAction(valueNumber), }, }; }; @@ -136,7 +147,7 @@ class Meta { issuer: quantity.address, currency: quantity.balance.currency, value: negatedBalance.absoluteValue().decimalPlaces(8).toString(10), - action: negatedBalance.isNegative() ? 'DEC' : 'INC', + action: this.getOperationAction(negatedBalance), }, }; }; @@ -162,7 +173,7 @@ class Meta { issuer: fields.HighLimit.issuer, currency: fields.Balance.currency, value: value.absoluteValue().decimalPlaces(8).toString(10), - action: value.isNegative() ? 'DEC' : 'INC', + action: this.getOperationAction(value), }, }; @@ -234,7 +245,6 @@ class Meta { return []; }); - // @ts-ignore return this.groupByAddress(compact(flatten(values))); }; @@ -260,24 +270,21 @@ class Meta { return compact(values); }; - // TODO: fix me - parseClaimRewardStatus = (): ClaimRewardStatus => { - // if there is an emitted transaction from "ADDRESS_ONE", it means the reward has been claimed - const ADDRESS_ONE = 'rrrrrrrrrrrrrrrrrrrrBZbvji'; - - const emittedTx = find(this.nodes, (node) => { - return ( - node.entryType === 'EmittedTxn' && - get(node, 'newFields.EmittedTxn.Account') === ADDRESS_ONE && - get(node, 'newFields.EmittedTxn.TransactionType') === 'GenesisMint' - ); - }); - - if (emittedTx) { - return ClaimRewardStatus.OptIn; + parseHookExecutions = (): HookExecution[] => { + // if hook executions already in the meta return + if (this.hookExecutions) { + return this.hookExecutions; } - return ClaimRewardStatus.OptOut; + // calculate from created nodes + const executions = this.nodes.map((node) => { + if (node.diffType === 'CreatedNode' && node.entryType === 'EmittedTxn') { + return node.CreatedNode.NewFields.EmittedTxn; + } + return undefined; + }); + + return compact(executions); }; } diff --git a/src/common/libs/ledger/parser/types.ts b/src/common/libs/ledger/parser/types.ts index c2a85c9c4..7b743cc28 100644 --- a/src/common/libs/ledger/parser/types.ts +++ b/src/common/libs/ledger/parser/types.ts @@ -1,6 +1,12 @@ /** * Meta data types */ + +export enum OperationActions { + DEC, + INC, +} + export enum OfferStatus { CREATED = 'CREATED', PARTIALLY_FILLED = 'PARTIALLY_FILLED', @@ -16,13 +22,13 @@ export enum ClaimRewardStatus { } export interface BalanceChangeType extends AmountType { - action: 'DEC' | 'INC'; + action: OperationActions; } export interface OwnerCountChangeType { address: string; value: number; - action: string; + action: OperationActions; } /** diff --git a/src/common/libs/ledger/transactions/genuine/BaseTransaction.ts b/src/common/libs/ledger/transactions/genuine/BaseTransaction.ts index 1e49cebd2..31e45e5df 100644 --- a/src/common/libs/ledger/transactions/genuine/BaseTransaction.ts +++ b/src/common/libs/ledger/transactions/genuine/BaseTransaction.ts @@ -31,7 +31,14 @@ import Flag from '@common/libs/ledger/parser/common/flag'; import Memo from '@common/libs/ledger/parser/common/memo'; /* Types ==================================================================== */ -import { Account, AmountType, MemoType, Signer, TransactionResult } from '@common/libs/ledger/parser/types'; +import { + Account, + AmountType, + MemoType, + OperationActions, + Signer, + TransactionResult, +} from '@common/libs/ledger/parser/types'; import { StringTypeCheck } from '@common/utils/string'; /* Class ==================================================================== */ @@ -44,6 +51,8 @@ class BaseTransaction { private verifyResult?: VerifyResultType; private isAborted: boolean; private isSubmitted: boolean; + + private hookExecutions: any[]; private balanceChanges: Map; private ownerCountChanges: Map; @@ -376,16 +385,19 @@ class BaseTransaction { const balanceChanges = get(new Meta(this.meta).parseBalanceChanges(), owner); // if cross currency remove fee from changes - if (size(filter(balanceChanges, { action: 'DEC' })) > 1) { - const decreaseNative = find(balanceChanges, { action: 'DEC', currency: NetworkService.getNativeAsset() }); + if (size(filter(balanceChanges, { action: OperationActions.DEC })) > 1) { + const decreaseNative = find(balanceChanges, { + action: OperationActions.DEC, + currency: NetworkService.getNativeAsset(), + }); if (decreaseNative.value === this.Fee) { - remove(balanceChanges, { action: 'DEC', currency: NetworkService.getNativeAsset() }); + remove(balanceChanges, { action: OperationActions.DEC, currency: NetworkService.getNativeAsset() }); } } const changes = { - sent: find(balanceChanges, (o) => o.action === 'DEC'), - received: find(balanceChanges, (o) => o.action === 'INC'), + sent: find(balanceChanges, (o) => o.action === OperationActions.DEC), + received: find(balanceChanges, (o) => o.action === OperationActions.INC), } as { sent: AmountType; received: AmountType }; // remove fee from transaction owner balance changes @@ -449,6 +461,24 @@ class BaseTransaction { return ownerChanges; } + /** + * get transaction hook executions + * @returns changes + */ + HookExecutions() { + // if value is already set return + if (this.hookExecutions) { + return this.hookExecutions; + } + + const hookExecutions = new Meta(this.meta).parseHookExecutions(); + + // memorize hook executions + this.hookExecutions = hookExecutions; + + return hookExecutions; + } + /** * check if transaction is a Pseudo transaction * @returns boolean diff --git a/src/common/libs/ledger/transactions/genuine/TrustSet/TrustSetInfo.ts b/src/common/libs/ledger/transactions/genuine/TrustSet/TrustSetInfo.ts index 6cb944102..d00f49875 100644 --- a/src/common/libs/ledger/transactions/genuine/TrustSet/TrustSetInfo.ts +++ b/src/common/libs/ledger/transactions/genuine/TrustSet/TrustSetInfo.ts @@ -5,6 +5,7 @@ import { NormalizeCurrencyCode } from '@common/utils/amount'; import Localize from '@locale'; import TrustSet from './TrustSetClass'; +import { OperationActions } from '@common/libs/ledger/parser/types'; /* Descriptor ==================================================================== */ const TrustSetInfo = { @@ -18,7 +19,7 @@ const TrustSetInfo = { } const ownerCountChange = tx.OwnerCountChange(account.address); if (ownerCountChange) { - if (ownerCountChange.action === 'INC') { + if (ownerCountChange.action === OperationActions.INC) { return Localize.t('events.addedATrustLine'); } return Localize.t('events.removedATrustLine'); @@ -29,7 +30,7 @@ const TrustSetInfo = { getDescription: (tx: TrustSet, account: AccountModel): string => { const ownerCountChange = tx.OwnerCountChange(account.address); - if (ownerCountChange && ownerCountChange.action === 'DEC') { + if (ownerCountChange && ownerCountChange.action === OperationActions.DEC) { return Localize.t('events.itRemovedTrustLineCurrencyTo', { currency: NormalizeCurrencyCode(tx.Currency), issuer: tx.Issuer, diff --git a/src/common/libs/ledger/transactions/genuine/__tests__/offerCreate.test.ts b/src/common/libs/ledger/transactions/genuine/__tests__/offerCreate.test.ts index b70efa56e..0f4804d58 100644 --- a/src/common/libs/ledger/transactions/genuine/__tests__/offerCreate.test.ts +++ b/src/common/libs/ledger/transactions/genuine/__tests__/offerCreate.test.ts @@ -10,6 +10,7 @@ import { OfferCreate, OfferCreateInfo } from '../OfferCreate'; import offerCreateTemplates from './fixtures/OfferCreateTx.json'; import { NormalizeCurrencyCode } from '../../../../../utils/amount'; +import { OperationActions } from '../../../parser/types'; jest.mock('@services/NetworkService'); @@ -37,7 +38,7 @@ describe('OfferCreate tx', () => { value: '0.012136', }); expect(instance.TakerPaid()).toStrictEqual({ - action: 'INC', + action: OperationActions.INC, currency: 'BTC', issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', value: '0.01257026', @@ -47,7 +48,8 @@ describe('OfferCreate tx', () => { value: '500', }); expect(instance.TakerGot()).toStrictEqual({ - action: 'DEC', + issuer: undefined, + action: OperationActions.DEC, currency: 'XRP', value: '500', }); @@ -67,7 +69,8 @@ describe('OfferCreate tx', () => { value: '484.553386', }); expect(instance.TakerPaid()).toStrictEqual({ - action: 'INC', + issuer: undefined, + action: OperationActions.INC, currency: 'XRP', value: '501.44754', }); @@ -77,7 +80,7 @@ describe('OfferCreate tx', () => { value: '0.01257', }); expect(instance.TakerGot()).toStrictEqual({ - action: 'DEC', + action: OperationActions.DEC, currency: 'BTC', issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', value: '0.01257026', @@ -137,7 +140,7 @@ describe('OfferCreate tx', () => { value: '100', }); expect(instance.TakerGot('rwietsevLFg8XSmG3bEZzFein1g8RBqWDZ')).toStrictEqual({ - action: 'DEC', + action: OperationActions.DEC, currency: '534F4C4F00000000000000000000000000000000', issuer: 'rsoLo2S1kiGeCcn6hCUXVrCpGMWLrRrLZz', value: '38.46538462', @@ -148,7 +151,8 @@ describe('OfferCreate tx', () => { value: '38.076', }); expect(instance.TakerPaid('rwietsevLFg8XSmG3bEZzFein1g8RBqWDZ')).toStrictEqual({ - action: 'INC', + issuer: undefined, + action: OperationActions.INC, currency: 'XRP', value: '100', }); diff --git a/src/common/libs/ledger/transactions/genuine/__tests__/payment.test.ts b/src/common/libs/ledger/transactions/genuine/__tests__/payment.test.ts index 9e2aac95e..38aa61361 100644 --- a/src/common/libs/ledger/transactions/genuine/__tests__/payment.test.ts +++ b/src/common/libs/ledger/transactions/genuine/__tests__/payment.test.ts @@ -9,6 +9,7 @@ import { Payment, PaymentInfo, PaymentValidation } from '../Payment'; import paymentTemplate from './fixtures/PaymentTx.json'; import { NormalizeCurrencyCode } from '../../../../../utils/amount'; +import { OperationActions } from '../../../parser/types'; jest.mock('@services/NetworkService'); @@ -43,12 +44,13 @@ describe('Payment tx', () => { expect(instance.BalanceChange()).toStrictEqual({ received: { - action: 'INC', + action: OperationActions.INC, currency: 'XRP', + issuer: undefined, value: '0.999988', }, sent: { - action: 'DEC', + action: OperationActions.DEC, currency: 'USD', issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', value: '1.23905437', diff --git a/src/common/libs/ledger/types.ts b/src/common/libs/ledger/types.ts index b63e0f545..b493992f8 100644 --- a/src/common/libs/ledger/types.ts +++ b/src/common/libs/ledger/types.ts @@ -437,3 +437,18 @@ export interface GenesisMintsType Destination: string; }; }> {} + +/** + * Hook executions + */ +export interface HookExecution { + HookAccount: string; + HookEmitCount: number; + HookExecutionIndex: number; + HookHash: string; + HookInstructionCount: string; + HookResult: number; + HookReturnCode: number; + HookReturnString: string; + HookStateChangeCount: number; +} diff --git a/src/components/Modules/EventsList/EventListItems/Transaction.tsx b/src/components/Modules/EventsList/EventListItems/Transaction.tsx index a259cbfa7..baf2a9799 100644 --- a/src/components/Modules/EventsList/EventListItems/Transaction.tsx +++ b/src/components/Modules/EventsList/EventListItems/Transaction.tsx @@ -5,7 +5,7 @@ import { isEmpty, isEqual } from 'lodash'; import { ExplainerFactory } from '@common/libs/ledger/factory'; import { TransactionTypes } from '@common/libs/ledger/types'; import { Transactions } from '@common/libs/ledger/transactions/types'; -import { OfferStatus } from '@common/libs/ledger/parser/types'; +import { OfferStatus, OperationActions } from '@common/libs/ledger/parser/types'; import { AccountModel } from '@store/models'; @@ -220,7 +220,7 @@ class TransactionItem extends Component { if (changes) { return ( diff --git a/src/locale/en.json b/src/locale/en.json index 308f8ac38..2a2b6f239 100644 --- a/src/locale/en.json +++ b/src/locale/en.json @@ -1111,13 +1111,14 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService":"Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits":"Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs":"Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs":"Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" } } diff --git a/src/locale/translations/af.json b/src/locale/translations/af.json index 0e1abf992..c4a32517f 100644 --- a/src/locale/translations/af.json +++ b/src/locale/translations/af.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/ar.json b/src/locale/translations/ar.json index 886f72b45..757fa398f 100644 --- a/src/locale/translations/ar.json +++ b/src/locale/translations/ar.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/bg.json b/src/locale/translations/bg.json index cdddf7152..1a57140aa 100644 --- a/src/locale/translations/bg.json +++ b/src/locale/translations/bg.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/bn-BD.json b/src/locale/translations/bn-BD.json index 5af45c613..e1efab23b 100644 --- a/src/locale/translations/bn-BD.json +++ b/src/locale/translations/bn-BD.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/ca.json b/src/locale/translations/ca.json index e59fe5c07..2e4dc8ba4 100644 --- a/src/locale/translations/ca.json +++ b/src/locale/translations/ca.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/cs.json b/src/locale/translations/cs.json index d606ed926..12ad592bf 100644 --- a/src/locale/translations/cs.json +++ b/src/locale/translations/cs.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/da.json b/src/locale/translations/da.json index f5005e5f8..7c18cbe58 100644 --- a/src/locale/translations/da.json +++ b/src/locale/translations/da.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/de.json b/src/locale/translations/de.json index ec8621895..362be356a 100644 --- a/src/locale/translations/de.json +++ b/src/locale/translations/de.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/el.json b/src/locale/translations/el.json index 150de9f59..65aeeb308 100644 --- a/src/locale/translations/el.json +++ b/src/locale/translations/el.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "longDateFormat": { diff --git a/src/locale/translations/en-AU.json b/src/locale/translations/en-AU.json index bb3f6a37d..92fcc1849 100644 --- a/src/locale/translations/en-AU.json +++ b/src/locale/translations/en-AU.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/es-419.json b/src/locale/translations/es-419.json index 169226431..ae5b17845 100644 --- a/src/locale/translations/es-419.json +++ b/src/locale/translations/es-419.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/es.json b/src/locale/translations/es.json index ba4c66dfc..aa78fe468 100644 --- a/src/locale/translations/es.json +++ b/src/locale/translations/es.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/et.json b/src/locale/translations/et.json index b721dd38a..0ff82ba85 100644 --- a/src/locale/translations/et.json +++ b/src/locale/translations/et.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/eu.json b/src/locale/translations/eu.json index c9fc9a7dc..1e07e1fed 100644 --- a/src/locale/translations/eu.json +++ b/src/locale/translations/eu.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/fi.json b/src/locale/translations/fi.json index 0691d8308..6f72dffa3 100644 --- a/src/locale/translations/fi.json +++ b/src/locale/translations/fi.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/fil.json b/src/locale/translations/fil.json index 61918c87a..573708503 100644 --- a/src/locale/translations/fil.json +++ b/src/locale/translations/fil.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/fr.json b/src/locale/translations/fr.json index f30febde4..675fa5d87 100644 --- a/src/locale/translations/fr.json +++ b/src/locale/translations/fr.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/gl-ES.json b/src/locale/translations/gl-ES.json index 3f6cbb36f..0ea8afc93 100644 --- a/src/locale/translations/gl-ES.json +++ b/src/locale/translations/gl-ES.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/gu.json b/src/locale/translations/gu.json index 2156b319b..178b28a81 100644 --- a/src/locale/translations/gu.json +++ b/src/locale/translations/gu.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/he.json b/src/locale/translations/he.json index 184c67705..c4a64f23b 100644 --- a/src/locale/translations/he.json +++ b/src/locale/translations/he.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/hi-IN.json b/src/locale/translations/hi-IN.json index 37b3e502a..217120087 100644 --- a/src/locale/translations/hi-IN.json +++ b/src/locale/translations/hi-IN.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/hr.json b/src/locale/translations/hr.json index 765f861c3..1509fea00 100644 --- a/src/locale/translations/hr.json +++ b/src/locale/translations/hr.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/ht.json b/src/locale/translations/ht.json index 968217623..d6c513d89 100644 --- a/src/locale/translations/ht.json +++ b/src/locale/translations/ht.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/hu.json b/src/locale/translations/hu.json index 5d6be4f60..35b32ce52 100644 --- a/src/locale/translations/hu.json +++ b/src/locale/translations/hu.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/id.json b/src/locale/translations/id.json index 55e5aef5a..8a6d78a58 100644 --- a/src/locale/translations/id.json +++ b/src/locale/translations/id.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/it.json b/src/locale/translations/it.json index 44dea8ee5..43000cede 100644 --- a/src/locale/translations/it.json +++ b/src/locale/translations/it.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/ja.json b/src/locale/translations/ja.json index 1d8921d36..b83785617 100644 --- a/src/locale/translations/ja.json +++ b/src/locale/translations/ja.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { @@ -1276,4 +1277,4 @@ ], "abbr": "ja" } -} +} \ No newline at end of file diff --git a/src/locale/translations/ka.json b/src/locale/translations/ka.json index 15bdfa37d..1a00d3c00 100644 --- a/src/locale/translations/ka.json +++ b/src/locale/translations/ka.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/kk.json b/src/locale/translations/kk.json index 7a35f1f89..3bc404085 100644 --- a/src/locale/translations/kk.json +++ b/src/locale/translations/kk.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/kn.json b/src/locale/translations/kn.json index aa999e73e..897f123f6 100644 --- a/src/locale/translations/kn.json +++ b/src/locale/translations/kn.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/ko.json b/src/locale/translations/ko.json index 5e042f59b..d3c04d7bb 100644 --- a/src/locale/translations/ko.json +++ b/src/locale/translations/ko.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/lt.json b/src/locale/translations/lt.json index 3e063c056..18dbe60d6 100644 --- a/src/locale/translations/lt.json +++ b/src/locale/translations/lt.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/lv.json b/src/locale/translations/lv.json index a1e6ceb89..ae0c97299 100644 --- a/src/locale/translations/lv.json +++ b/src/locale/translations/lv.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/ml.json b/src/locale/translations/ml.json index f2c760bd7..46d042de6 100644 --- a/src/locale/translations/ml.json +++ b/src/locale/translations/ml.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/mr.json b/src/locale/translations/mr.json index 8f2958b68..b6a11eb90 100644 --- a/src/locale/translations/mr.json +++ b/src/locale/translations/mr.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/nl.json b/src/locale/translations/nl.json index 43f7e1e83..fc60c4137 100644 --- a/src/locale/translations/nl.json +++ b/src/locale/translations/nl.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/no-NO.json b/src/locale/translations/no-NO.json index 12e3956e6..568573f3f 100644 --- a/src/locale/translations/no-NO.json +++ b/src/locale/translations/no-NO.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/pa.json b/src/locale/translations/pa.json index a23c73fc3..732941a8e 100644 --- a/src/locale/translations/pa.json +++ b/src/locale/translations/pa.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/pl.json b/src/locale/translations/pl.json index a062f71bd..2a5083640 100644 --- a/src/locale/translations/pl.json +++ b/src/locale/translations/pl.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/pt-BR.json b/src/locale/translations/pt-BR.json index 1764b7960..70a1f15fe 100644 --- a/src/locale/translations/pt-BR.json +++ b/src/locale/translations/pt-BR.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/pt.json b/src/locale/translations/pt.json index af9eacc7f..23daed323 100644 --- a/src/locale/translations/pt.json +++ b/src/locale/translations/pt.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/ro.json b/src/locale/translations/ro.json index 30ea7dfa8..670a64673 100644 --- a/src/locale/translations/ro.json +++ b/src/locale/translations/ro.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/ru.json b/src/locale/translations/ru.json index b1ce3879f..ff9816fc0 100644 --- a/src/locale/translations/ru.json +++ b/src/locale/translations/ru.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/sd.json b/src/locale/translations/sd.json index 452e57de0..b5d924663 100644 --- a/src/locale/translations/sd.json +++ b/src/locale/translations/sd.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/sk.json b/src/locale/translations/sk.json index 169749131..99ca3c616 100644 --- a/src/locale/translations/sk.json +++ b/src/locale/translations/sk.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/sl.json b/src/locale/translations/sl.json index bb1e4baf4..419ac0478 100644 --- a/src/locale/translations/sl.json +++ b/src/locale/translations/sl.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/sr.json b/src/locale/translations/sr.json index 59a2cd210..79acfba53 100644 --- a/src/locale/translations/sr.json +++ b/src/locale/translations/sr.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/sv.json b/src/locale/translations/sv.json index 255ee22cc..b0eb1b458 100644 --- a/src/locale/translations/sv.json +++ b/src/locale/translations/sv.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/sw.json b/src/locale/translations/sw.json index 33d06bbaa..395452dd6 100644 --- a/src/locale/translations/sw.json +++ b/src/locale/translations/sw.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/ta-IN.json b/src/locale/translations/ta-IN.json index d7a6a7d2b..77a13cf5e 100644 --- a/src/locale/translations/ta-IN.json +++ b/src/locale/translations/ta-IN.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/te-IN.json b/src/locale/translations/te-IN.json index 22c014fb2..595da1f18 100644 --- a/src/locale/translations/te-IN.json +++ b/src/locale/translations/te-IN.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/tr.json b/src/locale/translations/tr.json index e80dd04ac..fab220be6 100644 --- a/src/locale/translations/tr.json +++ b/src/locale/translations/tr.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/uk.json b/src/locale/translations/uk.json index dea7d229b..494dbb53d 100644 --- a/src/locale/translations/uk.json +++ b/src/locale/translations/uk.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/ur.json b/src/locale/translations/ur.json index f485356be..430930e64 100644 --- a/src/locale/translations/ur.json +++ b/src/locale/translations/ur.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/uz.json b/src/locale/translations/uz.json index cfce04c9d..9e86077c4 100644 --- a/src/locale/translations/uz.json +++ b/src/locale/translations/uz.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/vi.json b/src/locale/translations/vi.json index eae2bfae6..8cc489ec9 100644 --- a/src/locale/translations/vi.json +++ b/src/locale/translations/vi.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/zh-TW.json b/src/locale/translations/zh-TW.json index 4065f0bdb..05a35f341 100644 --- a/src/locale/translations/zh-TW.json +++ b/src/locale/translations/zh-TW.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/locale/translations/zh.json b/src/locale/translations/zh.json index 76ae50e84..c23d7fffb 100644 --- a/src/locale/translations/zh.json +++ b/src/locale/translations/zh.json @@ -1111,14 +1111,15 @@ "theIssuerCanBurnThisToken": "Note: The issuer can burn this token.", "payloadForceNetworkError": "This payload is not available on the network you are connected with", "pleaseSwitchToNetworkAndTryAgain": "Please switch to %{network} and try again", - "pathDryError": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", - "tecPartialError": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", "blobCopiedToClipboard": "Blob copied to clipboard" }, "errors": { "unableToLoadTermOfService": "Oops! Unable to Retrieve Terms of Service", "unableToLoadCredits": "Oops! Unable to Retrieve Credits", - "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs" + "unableToLoadChangeLogs": "Oops! Unable to Retrieve Change Logs", + "tecPATH_DRY": "The transaction didn't work because funds couldn't be moved between the two accounts, or could not be moved at the requested exchange rate.\n\nThis might be because the two accounts involved don't have a connection (TrustLine) that allows them to exchange money with each other, or the transaction didn't work because there wasn't enough money available to move between the two accounts.", + "tecPATH_PARTIAL": "The transaction didn't go through because there weren't enough tokens available to send the complete amount at the requested exchange rate between the two accounts.", + "tecHOOK_REJECTED": "Rejected by hook on sending or receiving account.\n\n%{hookReturnString}" }, "moment": { "calendar": { diff --git a/src/screens/Events/Details/DetailsView.tsx b/src/screens/Events/Details/DetailsView.tsx index 3763386b4..7e313589d 100644 --- a/src/screens/Events/Details/DetailsView.tsx +++ b/src/screens/Events/Details/DetailsView.tsx @@ -22,7 +22,7 @@ import { Transactions } from '@common/libs/ledger/transactions/types'; import { BaseLedgerObject } from '@common/libs/ledger/objects'; import { LedgerObjects } from '@common/libs/ledger/objects/types'; -import { OfferStatus } from '@common/libs/ledger/parser/types'; +import { OfferStatus, OperationActions } from '@common/libs/ledger/parser/types'; import { ExplainerFactory } from '@common/libs/ledger/factory'; import { txFlags } from '@common/libs/ledger/parser/common/flags/txFlags'; @@ -523,7 +523,7 @@ class TransactionDetailsView extends Component { changes = { address: account.address, value: 1, - action: 'INC', + action: OperationActions.INC, }; } else if (tx instanceof BaseTransaction && typeof tx.OwnerCountChange === 'function') { changes = tx.OwnerCountChange(account.address); @@ -537,7 +537,7 @@ class TransactionDetailsView extends Component { @@ -546,7 +546,7 @@ class TransactionDetailsView extends Component { - {changes.action === 'INC' + {changes.action === OperationActions.INC ? Localize.t('events.thisTransactionIncreaseAccountReserve', { ownerReserve: Number(changes.value) * NetworkService.getNetworkReserve().OwnerReserve, nativeAsset: NetworkService.getNativeAsset(), diff --git a/src/screens/Modal/ReviewTransaction/Steps/Result/ResultStep.tsx b/src/screens/Modal/ReviewTransaction/Steps/Result/ResultStep.tsx index 87c2ecb55..41003f40e 100644 --- a/src/screens/Modal/ReviewTransaction/Steps/Result/ResultStep.tsx +++ b/src/screens/Modal/ReviewTransaction/Steps/Result/ResultStep.tsx @@ -1,7 +1,7 @@ /** * Payload Result Screen */ - +import { get } from 'lodash'; import React, { Component, Fragment } from 'react'; import { SafeAreaView, View, Text, Image, ScrollView } from 'react-native'; @@ -20,6 +20,8 @@ import { AppStyles, AppColors } from '@theme'; import styles from './styles'; import { StepsContext } from '../../Context'; +import { HexEncoding } from '@common/utils/string'; + /* types ==================================================================== */ export interface Props {} @@ -43,17 +45,25 @@ class ResultStep extends Component { getNormalizedErrorMessage = () => { const { transaction } = this.context; - // @ts-ignore - if (transaction.TransactionResult?.code === 'tecPATH_PARTIAL') { - return Localize.t('payload.tecPartialError'); - } - // @ts-ignore - if (transaction.TransactionResult?.code === 'tecPATH_DRY') { - return Localize.t('payload.pathDryError'); + // this will never happen as Pseudo transactions never submits to the network + if (transaction instanceof BasePseudoTransaction) { + return 'Pseudo transactions should never submit to the network!'; } - // @ts-ignore - return transaction.TransactionResult?.message || 'No Description'; + switch (transaction.TransactionResult?.code) { + case 'tecPATH_PARTIAL': + return Localize.t('errors.tecPATH_PARTIAL'); + case 'tecPATH_DRY': + return Localize.t('errors.tecPATH_DRY'); + case 'tecHOOK_REJECTED': { + const returnStringHex = get(transaction.HookExecutions(), '[0].HookReturnString', ''); + return Localize.t('errors.tecHOOK_REJECTED', { + hookReturnString: returnStringHex ? HexEncoding.toString(returnStringHex) : '', + }); + } + default: + return transaction.TransactionResult?.message || 'No Description'; + } }; renderSuccess = () => { @@ -93,6 +103,11 @@ class ResultStep extends Component { const { transaction, onFinish } = this.context; const { closeButtonLabel } = this.state; + if (transaction instanceof BasePseudoTransaction) { + console.warn('Pseudo transactions should never submit to the network!'); + return null; + } + return ( @@ -107,7 +122,6 @@ class ResultStep extends Component { {Localize.t('global.code')}: - {/* @ts-ignore */} {transaction.TransactionResult?.code} @@ -117,10 +131,7 @@ class ResultStep extends Component { - - {/* @ts-ignore */} - {this.getNormalizedErrorMessage()} - + {this.getNormalizedErrorMessage()} From 46627cdccb4e7338bc2c99d21e5c40b7711d3588 Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Tue, 2 Jan 2024 15:54:28 +0100 Subject: [PATCH 14/54] chore: refactor --- src/services/__tests__/NetworkService.test.ts | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/services/__tests__/NetworkService.test.ts b/src/services/__tests__/NetworkService.test.ts index 6e2f115e1..51c65d70c 100644 --- a/src/services/__tests__/NetworkService.test.ts +++ b/src/services/__tests__/NetworkService.test.ts @@ -7,6 +7,21 @@ import * as FeeUtils from '@common/utils/fee'; describe('NetworkService', () => { const networkService = NetworkService; + beforeAll(() => { + const logFn = console.warn; + jest.spyOn(console, 'warn').mockImplementation((...args) => { + if (typeof args[0] === 'string' && args[0].match(/server_definitions got invalid/)) { + return; + } + + logFn(...args); + }); + }); + + afterAll(() => { + jest.clearAllMocks(); + }); + it('should properly initialize', async () => { const coreSettings = { network: { baseReserve: 10, ownerReserve: 2, isFeatureEnabled: () => {}, definitions: {} }, @@ -30,17 +45,23 @@ describe('NetworkService', () => { LEDGER_ENTRY_TYPES: {}, // @ts-ignore FIELDS: [], - hash: 'SOME_HASH', + hash: 'DEFINITIONS_HASH', }; + jest.replaceProperty(networkService, 'network', { + // @ts-ignore + id: 'object_id', + networkId: 1337, + }); + const spy0 = jest.spyOn(networkService, 'send').mockImplementation(() => Promise.resolve(returnedResponse)); - const spy1 = jest.spyOn(NetworkRepository, 'update'); + const spy1 = jest.spyOn(NetworkRepository, 'update').mockImplementation(jest.fn()); await networkService.updateNetworkDefinitions(); expect(spy0).toHaveBeenCalledWith({ command: 'server_definitions' }); expect(spy1).toHaveBeenCalledWith({ - id: undefined, + id: 'object_id', definitionsString: JSON.stringify(returnedResponse), }); From cacd42180061f6ec5d7327b3fe7f97de02244666 Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Wed, 3 Jan 2024 11:23:43 +0100 Subject: [PATCH 15/54] fix: unable to sign a transaction if regularKey account imported as readonly --- src/screens/Overlay/Vault/VaultModal.tsx | 29 +++++++++++++++--------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/screens/Overlay/Vault/VaultModal.tsx b/src/screens/Overlay/Vault/VaultModal.tsx index 826766494..f325d4841 100644 --- a/src/screens/Overlay/Vault/VaultModal.tsx +++ b/src/screens/Overlay/Vault/VaultModal.tsx @@ -89,11 +89,13 @@ class VaultModal extends Component { const signers: AccountModel[] = []; let preferredSigner; - // check if we can sign the transaction with provided account + // check if we can sign the transaction // account is Readonly and no RegularKey is set - // NOTE: we shouldn't allow user to reach to this point but we are double-checking + // NOTE: we shouldn't allow user to reach to this point but let's double-check if (account.accessLevel === AccessLevels.Readonly && !account.regularKey) { - throw new Error('Unable to sign the transaction with provided account'); + throw new Error( + 'Unable to sign the transaction with provided account, readonly and no regular key available', + ); } // by default include the provided account if full access @@ -102,7 +104,7 @@ class VaultModal extends Component { preferredSigner = account; } - // if regular key is set to the account then we check if we should include it in the list of signer + // if regular key is set to the account then we check if we should include it in the list of signers if (account.regularKey) { // check if regular key account is imported in the app const regularKeyAccount = AccountRepository.findOne({ address: account.regularKey }); @@ -113,19 +115,24 @@ class VaultModal extends Component { } if (regularKeyAccount) { - // Regular key exist but it's not imported as full access - if (regularKeyAccount.accessLevel !== AccessLevels.Full) { + // Regular key exist, but it's not imported as full access and account is not full access + if ( + account.accessLevel !== AccessLevels.Full && + regularKeyAccount.accessLevel !== AccessLevels.Full + ) { throw new Error( Localize.t('account.regularKeyAccountForThisAccountDoesNotImportedWithSignAccess'), ); } - // everything is find we can sign with the regular key beside the main account - signers.push(regularKeyAccount); + if (regularKeyAccount.accessLevel === AccessLevels.Full) { + // everything is find we can sign with the regular also + signers.push(regularKeyAccount); - // if Master key is disabled on the main account set the preferred Signer to regular key - if (account.flags?.disableMasterKey || account.accessLevel === AccessLevels.Readonly) { - preferredSigner = regularKeyAccount; + // if Master key is disabled on the main account set the preferred Signer to regular key + if (account.flags?.disableMasterKey || account.accessLevel === AccessLevels.Readonly) { + preferredSigner = regularKeyAccount; + } } } } From 154caca88912b8e81edb8e2920a05b85df6f9a90 Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Tue, 9 Jan 2024 13:52:01 +0100 Subject: [PATCH 16/54] fix: use only two decimal places when showing balance in rate --- .../Modules/AssetsList/Tokens/NativeItem/NativeItem.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/Modules/AssetsList/Tokens/NativeItem/NativeItem.tsx b/src/components/Modules/AssetsList/Tokens/NativeItem/NativeItem.tsx index e2c32e68b..003fa795b 100644 --- a/src/components/Modules/AssetsList/Tokens/NativeItem/NativeItem.tsx +++ b/src/components/Modules/AssetsList/Tokens/NativeItem/NativeItem.tsx @@ -17,6 +17,7 @@ import Localize from '@locale'; import { AppStyles, AppSizes } from '@theme'; import styles from './styles'; +import BigNumber from 'bignumber.js'; /* Types ==================================================================== */ interface Props { @@ -178,7 +179,7 @@ class NativeItem extends Component { let prefix: any; if (showFiatRate && fiatRate) { - balance = Number(availableBalance) * Number(fiatRate.rate); + balance = new BigNumber(availableBalance).multipliedBy(fiatRate.rate).decimalPlaces(2).toNumber(); prefix = `${fiatRate.symbol} `; } else { balance = availableBalance; @@ -226,7 +227,7 @@ class NativeItem extends Component { const accountReserve = CalculateTotalReserve(account); if (showFiatRate && fiatRate) { - totalReserve = Number(accountReserve) * Number(fiatRate.rate); + totalReserve = new BigNumber(accountReserve).multipliedBy(fiatRate.rate).decimalPlaces(2).toNumber(); prefix = `${fiatRate.symbol} `; } else { totalReserve = accountReserve; From bb9adbc6cb562201b7fde24c511c4fc2fcccc836 Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Mon, 18 Mar 2024 11:33:25 +0100 Subject: [PATCH 17/54] chore: v2.8.0 --- Gemfile.lock | 43 ++++++++++++++--------------- android/app/build.gradle | 4 ++- android/build.gradle | 24 ---------------- ios/Podfile.lock | 2 +- ios/Xaman.xcodeproj/project.pbxproj | 8 +++--- package.json | 2 +- 6 files changed, 30 insertions(+), 53 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1b1fd3d2e..bef8bd2f1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,28 +3,27 @@ GEM specs: CFPropertyList (3.0.6) rexml - activesupport (6.1.7.2) + activesupport (7.0.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.1) + addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) algoliasearch (1.27.5) httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) atomos (0.1.3) claide (1.1.0) - cocoapods (1.11.3) + cocoapods (1.14.3) addressable (~> 2.8) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.11.3) + cocoapods-core (= 1.14.3) cocoapods-deintegrate (>= 1.0.3, < 2.0) - cocoapods-downloader (>= 1.4.0, < 2.0) + cocoapods-downloader (>= 2.1, < 3.0) cocoapods-plugins (>= 1.0.0, < 2.0) cocoapods-search (>= 1.0.0, < 2.0) - cocoapods-trunk (>= 1.4.0, < 2.0) + cocoapods-trunk (>= 1.6.0, < 2.0) cocoapods-try (>= 1.1.0, < 2.0) colored2 (~> 3.1) escape (~> 0.0.4) @@ -32,10 +31,10 @@ GEM gh_inspector (~> 1.0) molinillo (~> 0.8.0) nap (~> 1.0) - ruby-macho (>= 1.0, < 3.0) - xcodeproj (>= 1.21.0, < 2.0) - cocoapods-core (1.11.3) - activesupport (>= 5.0, < 7) + ruby-macho (>= 2.3.0, < 3.0) + xcodeproj (>= 1.23.0, < 2.0) + cocoapods-core (1.14.3) + activesupport (>= 5.0, < 8) addressable (~> 2.8) algoliasearch (~> 1.0) concurrent-ruby (~> 1.1) @@ -45,7 +44,7 @@ GEM public_suffix (~> 4.0) typhoeus (~> 1.0) cocoapods-deintegrate (1.0.5) - cocoapods-downloader (1.6.3) + cocoapods-downloader (2.1) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.1) @@ -54,44 +53,44 @@ GEM netrc (~> 0.11) cocoapods-try (1.2.0) colored2 (3.1.2) - concurrent-ruby (1.2.0) + concurrent-ruby (1.2.2) escape (0.0.4) ethon (0.16.0) ffi (>= 1.15.0) - ffi (1.15.5) + ffi (1.16.3) fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) httpclient (2.8.3) - i18n (1.12.0) + i18n (1.14.1) concurrent-ruby (~> 1.0) - json (2.6.3) - minitest (5.17.0) + json (2.7.1) + minitest (5.20.0) molinillo (0.8.0) nanaimo (0.3.0) nap (1.1.0) netrc (0.11.0) public_suffix (4.0.7) - rexml (3.2.5) + rexml (3.2.6) ruby-macho (2.5.1) - typhoeus (1.4.0) + typhoeus (1.4.1) ethon (>= 0.9.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - xcodeproj (1.22.0) + xcodeproj (1.23.0) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) nanaimo (~> 0.3.0) rexml (~> 3.2.4) - zeitwerk (2.6.7) PLATFORMS ruby DEPENDENCIES - cocoapods (>= 1.11.3) + activesupport (>= 6.1.7.3, < 7.1.0) + cocoapods (~> 1.13) RUBY VERSION ruby 2.7.6p219 diff --git a/android/app/build.gradle b/android/app/build.gradle index 63e9792b9..98fad7130 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -5,6 +5,8 @@ apply plugin: "com.google.firebase.crashlytics" import com.android.build.OutputFile +canonicalVersionName = "2.8.0" +canonicalVersionCode = 30_003 /** * This is the configuration block to customize your React Native Android app. @@ -110,7 +112,7 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion missingDimensionStrategy 'react-native-camera', 'mlkit' - versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch * 10 + buildNumber + versionCode canonicalVersionCode versionName "${versionMajor}.${versionMinor}.${versionPatch}" testBuildType System.getProperty('testBuildType', 'debug') testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' diff --git a/android/build.gradle b/android/build.gradle index c996f3833..7107f39b8 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -48,27 +48,3 @@ allprojects { } } - - -subprojects { subproject -> - ext { - def npmVersion = getNpmVersionArray() - versionMajor = npmVersion[0] - versionMinor = npmVersion[1] - versionPatch = npmVersion[2] - buildNumber = 16 - } -} - - - -def getNpmVersion() { - def inputFile = new File("../package.json") - def packageJson = new JsonSlurper().parseText(inputFile.text) - return packageJson["version"] -} - -def getNpmVersionArray() { // major [0], minor [1], patch [2] - def (major, minor, patch) = getNpmVersion().tokenize('.') - return [Integer.parseInt(major), Integer.parseInt(minor), Integer.parseInt(patch)] as int[] -} diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 3465d93b2..8313f39a2 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -832,4 +832,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 349fd765463969a28397aadfc81d7ef7073399e5 -COCOAPODS: 1.11.3 +COCOAPODS: 1.14.3 diff --git a/ios/Xaman.xcodeproj/project.pbxproj b/ios/Xaman.xcodeproj/project.pbxproj index 61b3cb0bd..83124ae62 100644 --- a/ios/Xaman.xcodeproj/project.pbxproj +++ b/ios/Xaman.xcodeproj/project.pbxproj @@ -1106,7 +1106,7 @@ CODE_SIGN_ENTITLEMENTS = Xaman/Xaman.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 16; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = LK5BBJNJZ6; ENABLE_BITCODE = NO; "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; @@ -1117,7 +1117,7 @@ INFOPLIST_FILE = Xaman/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 2.6.0; + MARKETING_VERSION = 2.8.0; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -1142,13 +1142,13 @@ CODE_SIGN_ENTITLEMENTS = Xaman/Xaman.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 16; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = LK5BBJNJZ6; "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; INFOPLIST_FILE = Xaman/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 2.6.0; + MARKETING_VERSION = 2.8.0; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", diff --git a/package.json b/package.json index 8b1618419..b24294901 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xaman", - "version": "2.6.0", + "version": "2.8.0", "license": "SEE LICENSE IN ", "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", From 25c22518635a8e93aa6ff6070f93ad58294f2483 Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Tue, 9 Jan 2024 14:49:55 +0100 Subject: [PATCH 18/54] chore: import external libraries from xrpl-accountlib --- package-lock.json | 78 ++----------------- package.json | 4 +- src/common/utils/codec.ts | 13 ++-- .../AddressBook/Add/AddContactView.tsx | 7 +- .../AddressBook/Edit/EditContactView.tsx | 7 +- src/services/NetworkService.ts | 5 +- 6 files changed, 21 insertions(+), 93 deletions(-) diff --git a/package-lock.json b/package-lock.json index 486e8b78f..c8e180fb9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "xaman", - "version": "2.6.0", + "version": "2.8.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "xaman", - "version": "2.6.0", + "version": "2.8.0", "hasInstallScript": true, "license": "SEE LICENSE IN ", "dependencies": { @@ -28,11 +28,9 @@ "react-native-interactable": "2.0.1", "react-native-navigation": "7.37.0", "realm": "12.3.1", - "ripple-binary-codec": "npm:xrpl-binary-codec-prerelease@7.0.1", "tangem-sdk-react-native": "2.3.1", "uuid": "9.0.1", - "xrpl-accountlib": "3.2.1", - "xrpl-client": "2.3.1", + "xrpl-accountlib": "3.2.8", "xrpl-orderbook-reader": "0.4.0", "xumm-string-decode": "0.6.2" }, @@ -17049,70 +17047,6 @@ "node": ">= 10" } }, - "node_modules/ripple-binary-codec": { - "name": "xrpl-binary-codec-prerelease", - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/xrpl-binary-codec-prerelease/-/xrpl-binary-codec-prerelease-7.0.1.tgz", - "integrity": "sha512-IOIWUTkCyeYWReT6hn/2ONMpk0FNk1mltqQjpl7n2cfCuxJwSxwk+J4fi5s0cExNJSFT1aUhRSgDQLOtCBo2hQ==", - "dependencies": { - "assert": "^2.0.0", - "big-integer": "^1.6.48", - "buffer": "6.0.3", - "create-hash": "^1.2.0", - "decimal.js": "^10.2.0", - "ripple-address-codec": "^4.3.1" - }, - "engines": { - "node": ">= 10" - } - }, - "node_modules/ripple-binary-codec/node_modules/assert": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/assert/-/assert-2.1.0.tgz", - "integrity": "sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw==", - "dependencies": { - "call-bind": "^1.0.2", - "is-nan": "^1.3.2", - "object-is": "^1.1.5", - "object.assign": "^4.1.4", - "util": "^0.12.5" - } - }, - "node_modules/ripple-binary-codec/node_modules/buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, - "node_modules/ripple-binary-codec/node_modules/util": { - "version": "0.12.5", - "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", - "integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==", - "dependencies": { - "inherits": "^2.0.3", - "is-arguments": "^1.0.4", - "is-generator-function": "^1.0.7", - "is-typed-array": "^1.1.3", - "which-typed-array": "^1.1.2" - } - }, "node_modules/ripple-keypairs": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/ripple-keypairs/-/ripple-keypairs-1.3.1.tgz", @@ -19412,9 +19346,9 @@ } }, "node_modules/xrpl-accountlib": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/xrpl-accountlib/-/xrpl-accountlib-3.2.1.tgz", - "integrity": "sha512-6jFuzuc7N6tTj0xImpzEaYihWNgtzeBGyRVIjwlBHq5GU6w2BwQZbrLWdJds7CJOGgrDNouWfAT8C2ES5w0lqA==", + "version": "3.2.8", + "resolved": "https://registry.npmjs.org/xrpl-accountlib/-/xrpl-accountlib-3.2.8.tgz", + "integrity": "sha512-gIwyAkAzda66NBusRAU2/e2RQpopYtjY0Uk7TfZzsahAnj9ZAw2/IGm0we2CA834kgOjaK4VpKsg/doaV5LsKg==", "dependencies": { "assert": "^2.0.0", "bip32": "^2.0.6", diff --git a/package.json b/package.json index b24294901..fef4b492a 100644 --- a/package.json +++ b/package.json @@ -32,11 +32,9 @@ "react-native-interactable": "2.0.1", "react-native-navigation": "7.37.0", "realm": "12.3.1", - "ripple-binary-codec": "npm:xrpl-binary-codec-prerelease@7.0.1", "tangem-sdk-react-native": "2.3.1", "uuid": "9.0.1", - "xrpl-accountlib": "3.2.1", - "xrpl-client": "2.3.1", + "xrpl-accountlib": "3.2.8", "xrpl-orderbook-reader": "0.4.0", "xumm-string-decode": "0.6.2" }, diff --git a/src/common/utils/codec.ts b/src/common/utils/codec.ts index a497c6d27..d207bb4c9 100644 --- a/src/common/utils/codec.ts +++ b/src/common/utils/codec.ts @@ -1,6 +1,5 @@ import BigNumber from 'bignumber.js'; -import { utils as AccountLibUtils } from 'xrpl-accountlib'; -import { xAddressToClassicAddress, decodeAccountID, encodeAccountID } from 'ripple-address-codec'; +import { utils as AccountLibUtils, libraries } from 'xrpl-accountlib'; import { XrplDestination } from 'xumm-string-decode'; import { HexEncoding } from '@common/utils/string'; @@ -15,7 +14,7 @@ const EncodeLedgerIndex = (account: string, sequence: number) => { let sequenceHex = sequence.toString(16); if (sequenceHex.length > 8) return false; sequenceHex = '0'.repeat(8 - sequenceHex.length) + sequenceHex; - const payloadHex = `006F${decodeAccountID(account).toString('hex')}${sequenceHex}`; + const payloadHex = `006F${libraries.rippleAddressCodec.decodeAccountID(account).toString('hex')}${sequenceHex}`; return HexEncoding.toHex(AccountLibUtils.hash(payloadHex)).toUpperCase(); }; @@ -25,7 +24,7 @@ const EncodeLedgerIndex = (account: string, sequence: number) => { * @returns decoded account id */ const DecodeAccountId = (account: string): string => { - const decodedAccount = decodeAccountID(account); + const decodedAccount = libraries.rippleAddressCodec.decodeAccountID(account); return HexEncoding.toHex(decodedAccount).toUpperCase(); }; @@ -45,7 +44,7 @@ const EncodeNFTokenID = ( transferFee: number, tokenTaxon: number, ): string => { - const issuer = decodeAccountID(account); + const issuer = libraries.rippleAddressCodec.decodeAccountID(account); const unscrambleTaxon = new BigNumber(384160001) .multipliedBy(tokenSequence) @@ -104,7 +103,7 @@ const DecodeNFTokenID = (nfTokenID: string) => { NFTokenID: nfTokenID, Flags: new BigNumber(nfTokenID.substring(0, 4), 16).toNumber(), TransferFee: new BigNumber(nfTokenID.substring(4, 8), 16).toNumber(), - Issuer: encodeAccountID(Buffer.from(nfTokenID.substring(8, 48), 'hex')), + Issuer: libraries.rippleAddressCodec.encodeAccountID(Buffer.from(nfTokenID.substring(8, 48), 'hex')), Taxon: taxon, Sequence: sequence, }; @@ -174,7 +173,7 @@ const NormalizeDestination = (destination: XrplDestination): XrplDestination & { // decode if it's x address if (destination.to.startsWith('X')) { try { - const decoded = xAddressToClassicAddress(destination.to); + const decoded = libraries.rippleAddressCodec.xAddressToClassicAddress(destination.to); to = decoded.classicAddress; tag = Number(decoded.tag); diff --git a/src/screens/Settings/AddressBook/Add/AddContactView.tsx b/src/screens/Settings/AddressBook/Add/AddContactView.tsx index 89cfde796..292270b56 100644 --- a/src/screens/Settings/AddressBook/Add/AddContactView.tsx +++ b/src/screens/Settings/AddressBook/Add/AddContactView.tsx @@ -7,8 +7,7 @@ import React, { Component } from 'react'; import { View, Text, Alert, Keyboard } from 'react-native'; import { StringType, XrplDestination } from 'xumm-string-decode'; -import * as AccountLib from 'xrpl-accountlib'; -import { xAddressToClassicAddress } from 'ripple-address-codec'; +import { libraries } from 'xrpl-accountlib'; import { NormalizeDestination } from '@common/utils/codec'; import { getAccountName, getPayIdInfo } from '@common/helpers/resolver'; @@ -111,7 +110,7 @@ class AddContactView extends Component { return; } - if (!AccountLib.utils.isValidAddress(address)) { + if (!libraries.rippleAddressCodec.isValidClassicAddress(address)) { Alert.alert(Localize.t('global.invalidAddress')); return; } @@ -170,7 +169,7 @@ class AddContactView extends Component { // decode if it's x address if (address && address.startsWith('X')) { try { - const decoded = xAddressToClassicAddress(address); + const decoded = libraries.rippleAddressCodec.xAddressToClassicAddress(address); if (decoded) { this.setState({ address: decoded.classicAddress, diff --git a/src/screens/Settings/AddressBook/Edit/EditContactView.tsx b/src/screens/Settings/AddressBook/Edit/EditContactView.tsx index 345bab8ba..119a9d8d6 100644 --- a/src/screens/Settings/AddressBook/Edit/EditContactView.tsx +++ b/src/screens/Settings/AddressBook/Edit/EditContactView.tsx @@ -6,8 +6,7 @@ import React, { Component } from 'react'; import { View, Text, Alert, Keyboard, Platform, Share } from 'react-native'; import { StringType } from 'xumm-string-decode'; -import * as AccountLib from 'xrpl-accountlib'; -import { xAddressToClassicAddress } from 'ripple-address-codec'; +import { libraries } from 'xrpl-accountlib'; import { StyleService } from '@services'; @@ -112,7 +111,7 @@ class EditContactView extends Component { return; } - if (!AccountLib.utils.isValidAddress(address)) { + if (!libraries.rippleAddressCodec.isValidClassicAddress(address)) { Alert.alert(Localize.t('global.invalidAddress')); return; } @@ -198,7 +197,7 @@ class EditContactView extends Component { // decode if it's x address if (address && address.startsWith('X')) { try { - const decoded = xAddressToClassicAddress(address); + const decoded = libraries.rippleAddressCodec.xAddressToClassicAddress(address); if (decoded) { this.setState({ address: decoded.classicAddress, diff --git a/src/services/NetworkService.ts b/src/services/NetworkService.ts index f4f660bee..e8bc34110 100644 --- a/src/services/NetworkService.ts +++ b/src/services/NetworkService.ts @@ -9,8 +9,7 @@ import Realm from 'realm'; import { Platform } from 'react-native'; -import { XrplDefinitions, DefinitionsData } from 'xrpl-accountlib'; -import DEFAULT_DEFINITIONS from 'ripple-binary-codec/dist/enums/definitions.json'; +import { XrplDefinitions, DefinitionsData, binary } from 'xrpl-accountlib'; import { ServerInfoResponse, XrplClient } from 'xrpl-client'; @@ -252,7 +251,7 @@ class NetworkService extends EventEmitter { return new XrplDefinitions(this.network.definitions); } - return new XrplDefinitions(DEFAULT_DEFINITIONS); + return new XrplDefinitions(binary.DEFAULT_DEFINITIONS); }; /** From 743eaea2eed839180b20e41881f3bff40f44fa21 Mon Sep 17 00:00:00 2001 From: tequ Date: Tue, 30 Jan 2024 10:14:14 +0100 Subject: [PATCH 19/54] [JA] update Japanese translations --- src/locale/translations/ja.json | 233 ++++++++++++++++---------------- 1 file changed, 117 insertions(+), 116 deletions(-) diff --git a/src/locale/translations/ja.json b/src/locale/translations/ja.json index b83785617..adda2c2ef 100644 --- a/src/locale/translations/ja.json +++ b/src/locale/translations/ja.json @@ -114,7 +114,7 @@ "hour": "時間", "hours": "時間", "day": "日", - "days": "days", + "days": "日", "week": "週", "autoLock": "自動ロック", "suggested": "推奨", @@ -123,7 +123,7 @@ "high": "高", "or": "または", "to": "宛先", - "add": "Add", + "add": "追加", "edit": "編集", "switch": "切り替える", "apply": "適用する", @@ -161,7 +161,7 @@ "reserve": "準備金", "password": "パスワード", "passcode": "パスコード", - "accessCode": "Access code", + "accessCode": "アクセスコード", "longTap": "ロングタップ", "sequence": "Sequence", "offerSequence": "オファーシーケンス", @@ -204,12 +204,12 @@ "tokenOffers": "トークン・オファー", "sellOffer": "販売オファー", "buyOffer": "購入オファー", - "brokerFee": "Broker fee", + "brokerFee": "ブローカー手数料", "reviewTransaction": "取引を確認", "important": "重要", "sign": "署名", "signWith": "署名方法の選択", - "payWith": "Pay with", + "payWith": "支払い方法", "signIn": "サインイン", "signInAs": "サインインで使用する名義を選択", "signAs": "署名に用いるアカウントを選択", @@ -261,6 +261,7 @@ "unableOpenReturnURL": "URLを開くことができません!", "noAccountConfigured": "アカウントが設定されていません", "pleaseAddAccountToSignTheTransaction": "取引に署名するためにアカウントを追加してください", + "pleaseAddAccountToAccessXApp": "xAppを利用するにはアカウントを追加してください。", "noSpendableAccountIsAvailableForSendingPayment": "送金するための十分な残高がありません。", "doNotRemindMe": "再通知しない", "invalidPayload": "無効なペイロード", @@ -288,19 +289,19 @@ "noNameFound": "名前が見つかりません", "readMoreInTheFAQ": "FAQで詳細を確認する", "whatsNew": "新着情報", - "pushErrorPermissionMessage": "プッシュ通知を登録できません。必要な通知権限を付与するには、システム設定に移動し、[XUMM]> [通知]が有効になっていることを確認してください。", + "pushErrorPermissionMessage": "プッシュ通知を登録できません。必要な通知権限を付与するには、システム設定に移動し、[Xaman]> [通知]が有効になっていることを確認してください。", "UnableToRegisterPushNotifications": "プッシュ通知を登録できません", "readMore": "続きを読む", - "readLess": "続きを読む", + "readLess": "閉じる", "enterPasscode": "パスコードを入力してください", "today": "今日", "yesterday": "昨日", "change": "チェンジ", "looksGood": "良さそう", - "incorrectPassword": "パスワードが間違っている", + "incorrectPassword": "パスワードが間違っています", "incorrectPasscode": "パスコードが間違っています", - "thePasswordYouEnteredIsIncorrectExplain": "入力されたパスワードが間違っています。 トランザクションに署名するには、正しいパスワードを入力する必要があります。 このパスワードは、 XUMMに署名したいアカウントを追加したときに入力したものです。", - "thePasscodeYouEnteredIsIncorrectExplain": "入力したパスコードが間違っています。トランザクションに署名するには、正しいパスコードを入力する必要があります。このパスコードは、XUMMを最初にセットアップしたときに入力したものです。", + "thePasswordYouEnteredIsIncorrectExplain": "入力されたパスワードが間違っています。トランザクションに署名するには、正しいパスワードを入力する必要があります。このパスワードは、Xamanに署名したいアカウントを追加したときに入力したものです。", + "thePasscodeYouEnteredIsIncorrectExplain": "入力したパスコードが間違っています。トランザクションに署名するには、正しいパスコードを入力する必要があります。このパスコードは、Xamanを最初にセットアップしたときに入力したものです。", "troubleshoot": "トラブルシューティング", "tryAgain": "もう一度お試しください", "all": "すべて", @@ -311,11 +312,11 @@ "signRequest": "署名リクエスト", "openForDetails": "詳細はこちら", "scanAQRCode": "QRコードのスキャン", - "unableToLoadXApp": "xAppをロードできません!", + "unableToLoadXApp": "xAppを読み込むことができません!", "requestWithAmount": "金額を指定したリクエスト", - "openXApp": "xApp を開く", - "quitXApp": "xApp の終了", - "quitApp": "Quit App", + "openXApp": "xAppを開く", + "quitXApp": "xAppを終了", + "quitApp": "Appを終了", "reallySmallAmount": "ごく少量", "about": "について", "default": "デフォルト", @@ -326,21 +327,21 @@ "moreInfo": "詳細情報", "loading": "読み込み中", "verify": "検証", - "deposit": "Deposit", - "withdraw": "Withdraw", - "permission": "Permission", - "grants": "Grants", - "website": "Website", - "privacyPolicy": "Privacy policy", - "termsAndConditions": "Terms & conditions", - "support": "Support", + "deposit": "入金", + "withdraw": "出金", + "permission": "許可", + "grants": "権限", + "website": "Webサイト", + "privacyPolicy": "プライバシーポリシー", + "termsAndConditions": "利用規約", + "support": "サポート", "nfts": "NFT", - "xAppWantsToOpenURLNotice": "'%{xapp}' xApp はURLを開く必要があります。\r\n\r\n%{url}", + "xAppWantsToOpenURLNotice": "'%{xapp}' xAppがURLを開こうとしています。\r\n\r\n%{url}", "createPaymentRequestLink": "支払要求リンクの作成", "transactionFeeIsNotSet": "取引手数料が設定されていません。取引手数料が設定されるまでお待ちいただき、再試行してください!", "unableToSetAccountSequence": "アカウント・シーケンスを設定できません。インターネットに接続されていることを確認してください。", "unableToGetLastClosedLedger": "最後に閉じたレジャーを取得できません。インターネットに接続されているか確認してください。", - "unableToOpenUrl": "Unable to open URL: %{url}", + "unableToOpenUrl": "URLを開くことができません: %{url}", "networks": "ネットワーク", "network": "ネットワーク", "networkId": "ネットワークID", @@ -355,17 +356,17 @@ "hookFeeNotice": "注記: トランザクション手数料には、フック手数料%{hookFee} %{nativeAsset}が含まれています。", "unableToLoadNetworkFee": "ネットワーク手数料を取得することができません!", "encrypting": "暗号化しています...", - "stillWorkingOnIt": "Still working on it", + "stillWorkingOnIt": "準備中", "doNotCloseTheApp": "Xamanを閉じないでください\r\nデバイスをロックしないでください", - "switchNetwork": "Switch network", - "theme": "Theme" + "switchNetwork": "ネットワークの切り替え", + "theme": "テーマ" }, "onboarding": { "slideOne_title": "XRPレジャーでの\r\n支払いと\r\n支払いリクエスト", "slideTwo_title": "ユーザーフレンドリーなアクセス", "slideTwo_desc": "全権モードまたは読み取り専用で、複数のアカウントを追加します。全権アカウントでトランザクションを送信し、リクエストに署名します。", "slideThree_title": "セキュリティ第一主義", - "slideThree_desc": "XummアプリケーションとXummプラットフォームは、セキュリティを最優先に作成されています。秘密鍵は決して他では入力しないでください。また、あなたが保有し信頼できるデバイス以外からトランザクションへの署名は行わないでください。", + "slideThree_desc": "Xamanアプリケーションとプラットフォームは、セキュリティを最優先に作成されています。秘密鍵は決して他では入力しないでください。また、あなたが保有し信頼できるデバイス以外からトランザクションへの署名は行わないでください。", "slideFour_title": "送受信", "slideFour_desc": "XRPやその他の信頼できる資産(IOU)の送受信も可能です。" }, @@ -409,8 +410,8 @@ "whenYouChangeYourPhoneExplain": "新しいデバイスでXamanを使用する際には、以前に作成したアカウントのシークレットキーを再度入力する必要があります。", "IWillKeepMySecretsSafeSoICanReEnterThemIfIGetANewPhone": "アカウントのシークレットキーはオフラインで安全に保管し、新しいデバイスを手に入れたときに再入力できるようにしておきます。", "questionsAndSupport": "お問い合わせ・サポート", - "questionsAndSupportExplain": "また、ご不明な点がございましたら、お気軽にお問い合わせください。私たちのFAQとサポートチャンネルはここで見つけることができます: https://support.xumm.app.\r\n\r\nご注意:このチャンネルは、XUMMサポートのための唯一の信頼できるチャンネルです。", - "IOnlyTrustAnswersFromXamanSupportTeam": "https://support.xumm.app の Xaman サポートチームからの回答を信用します。", + "questionsAndSupportExplain": "ご不明な点がございましたら、お気軽にお問い合わせください。疑問がある場合は、決して操作を続行せず、まずサポートチームに確認してください。\r\n\r\nよくある質問とヘルプセンターは、https://support.xumm.app から確認できます。\n\nアプリ内から、\"Xaman Support\" xAppを使用してサポートを受けることもできます。SNSのサポートは利用しないでください。", + "IOnlyTrustAnswersFromXamanSupportTeam": "https://support.xumm.app のXamanサポートチームからの回答を信用します。", "pleaseReadTheTextAboveCarefully": "上記の文章をよくお読みください" }, "home": { @@ -422,9 +423,9 @@ "shareAccount": "アカウントアドレスを共有", "addressBalance": "アドレスと残高:", "addAccount": "アカウント追加", - "whatAreOtherAssets": "他の資産とは何ですか?", + "whatAreOtherAssets": "他の資産(%{nativeAsset}以外)とは何ですか?", "otherAssets": "その他の資産", - "youDonNotHaveOtherAssets": "他に資産はありません", + "youDonNotHaveOtherAssets": "他に資産(%{nativeAsset}以外)はありません", "youDonNotHaveNFTokens": "NFTを保有していません", "activateYourAccount": "アカウントを有効化", "howActivateMyAccount": "アカウントを有効化するには", @@ -435,11 +436,11 @@ "openSignRequest": "署名リクエストを開く", "sendPaymentTo": "に支払う", "selfIssued": "自己発行", - "shareReadonlyAccountWarning": "この読み取り専用アカウントのキーを所有していますか?それとも、あなたの取引所アカウントですか?", + "shareReadonlyAccountWarning": "この読み取り専用アカウントのキーを所有していますか?それとも、利用している取引所のアカウントですか?", "iOwnTheKeys": "キーを持っている", "exchangeAccount": "取引所アカウント", - "exchangeAccountReadonlyExplain": "取引所アカウントに直接入金することはできません。これを行うには、宛先タグが必要です。 取引所から宛先タグを入手し、手動で入金してください。", - "viewMoreXApps": "その他のxAppsを見る" + "exchangeAccountReadonlyExplain": "取引所アカウントに直接入金することはできません。入金するには、宛先タグが必要です。取引所から宛先タグを入手し、手動で入金してください。", + "viewMoreXApps": "他のxAppsを見る" }, "events": { "eventTypeAll": "全て", @@ -508,9 +509,9 @@ "acceptNFTOffer": "NFTオファーの受け入れ", "setHooks": "Hookの設定", "claimReward": "報酬の請求", - "claimRewardOptOut": "Claim Reward (Opt Out)", + "claimRewardOptOut": "報酬の請求(オプトアウト)", "invoke": "Invoke", - "import": "Import", + "import": "インポート", "canNotFetchTransactions": "アカウントのトランザクションを取得できません!", "canNotFetchSignRequests": "アカウントのサインリクエストを取得できません!", "unableToLoadTheTransaction": "トランザクションをロードできません。インターネットに接続されていることを確認してください!", @@ -519,7 +520,7 @@ "newPayment": "新規支払い", "openWithExplorer": "%{explorer}で開く", "openInExplorer": "エクスプローラで開く", - "showMemo": "メモを表示する", + "showMemo": "メモを表示", "throughOfferBy": "による提供を通じて", "plannedOn": "計画中", "transactionId": "トランザクション ID", @@ -620,21 +621,21 @@ "sellMyNFT": "所有NFTの売却", "thisOfferCanOnlyBeAcceptedByThirdParty": "このオファーには、第三者(ブローカーなど)が送信先として設定されています。この第三者のアカウントのみがオファーを受け入れることができます。", "myBalanceAndReserve": "残高と準備金を確認", - "transactionDetailsDifferentNetworkError": "This transaction is not valid on the network you are connected with.\n\nPlease switch to %{network} and try again.", - "fetchingTransactionFromNetwork": "Fetching transaction from network", + "transactionDetailsDifferentNetworkError": "このトランザクションは、接続中のネットワークでは有効ではありません。\n\n%{network}に切り替えてもう一度お試しください。", + "fetchingTransactionFromNetwork": "ネットワークからトランザクションを取得しています", "unableToLoadExplainer": "Unable to load the explainer", - "uriTokenBurnExplain": "The transaction will burn URI token with ID %{tokenID}", - "uriTokenBuyExplain": "%{address} paid %{amount} %{currency} in order to receive an URI token with ID %{tokenID}", - "invokeExplain": "The transaction will invoke hooks in account %{destination}", - "invokeInitiatorExplain": "The initiator of this transaction is %{address}", - "theTransactionHasADestination": "The transaction Destination address is: %{destination}", - "theURIForThisTokenIs": "The URI for this token is %{uri}", - "theTokenHasADigest": "The token has a digest: %{digest}", - "uriTokenMintAmount": "The minter of this token has set the initial selling price to %{value} %{currency}.", - "uriTokenDestinationExplain": "This token can only be purchased by %{address}", - "uriTokenSellOfferExplain": "%{address} offered to sell URI token with ID %{uriToken} in order to receive %{value} %{currency}", - "thisURITokenOfferMayOnlyBeAcceptedBy": "This offer may only be accepted by %{address}", - "theTransactionWillCancelURITokenOffer": "The transaction will cancel %{address}'s sell offer for URI token with ID %{tokenId}", + "uriTokenBurnExplain": "トランザクションはID %{tokenID} のURIトークンをバーンします。", + "uriTokenBuyExplain": "%{address}は%{amount} %{currency}を支払い、ID %{tokenID} のURIトークンを受け取りました。", + "invokeExplain": "トランザクションは、アカウント %{destination} のHookを呼び出します。", + "invokeInitiatorExplain": "トランザクションの作成者は%{address}です。", + "theTransactionHasADestination": "トランザクションの宛先アドレスは%{destination}です。", + "theURIForThisTokenIs": "このトークンのURIは%{uri}です。", + "theTokenHasADigest": "このトークンのdigestは%{digest}です。", + "uriTokenMintAmount": "このトークンの発行者は、最初の販売価格を%{value} %{currency}に設定しました。", + "uriTokenDestinationExplain": "このトークンは、%{address}のみが購入できます。", + "uriTokenSellOfferExplain": "%{address}は、%{value} %{currency}でURIトークン(%{uriToken})の販売を提示しました。", + "thisURITokenOfferMayOnlyBeAcceptedBy": "このオファーは、%{address}のみが受け入れることができます。", + "theTransactionWillCancelURITokenOffer": "このトランザクションでは、%{address}のURIトークン(%{tokenId})の売却オファーはキャンセルされます。", "importTransactionExplain": "This is an Import transaction", "theIssuerIs": "The issuer address set to ${issuer}", "claimRewardExplain": "This is a claim reward transaction", @@ -647,8 +648,8 @@ "ourSuggestions": "おすすめ", "all": "全て", "theXAppLoaderHasNotBeenResolved": "The xApp loader has not yet been resolved", - "theXAppHasNotBeenFullyLoaded": "The xApp has not been fully loaded (yet). If you run into trouble using this xApp, please contact the xApp developer", - "forceShowXApp": "Force show xApp", + "theXAppHasNotBeenFullyLoaded": "xAppはまだ完全に読み込まれていません。このxAppの利用に問題が生じた場合は、xAppの開発者に連絡してください。", + "forceShowXApp": "xAppを強制的に表示する", "contactDeveloper": "開発者に問い合わせる", "unableToFetchXAppInfo": "xApp情報を取得できません!", "developedBy": "開発者:", @@ -658,8 +659,8 @@ "donateToTheCreator": "開発者を支援する", "chooseAmount": "支援金額を選択", "aboutThisXApp": "このxAppについて", - "xAppSupportNetworkError": "This xApp is not available on the network you are connected with", - "switchToSupportedNetworks": "Please switch to one of the supported networks below" + "xAppSupportNetworkError": "このxAppは、接続中のネットワークでは利用できません。", + "switchToSupportedNetworks": "以下の対応ネットワークのいずれかに切り替えてください。" }, "settings": { "generalSettings": "一般", @@ -685,8 +686,8 @@ "releaseInformation": "リリース情報", "termsAndConditions": "利用規約", "credits": "クレジット", - "nodeChangeWarning": "%{from}から%{to}に切り替えています 。アカウントを使用したり、アカウントの履歴を表示したりできない場合があります。", - "networkChangeAccountDetailsWarning": "Note: by switching from %{from} to %{to}. You may be unable to use your account or view your account history!", + "nodeChangeWarning": "%{from}から%{to}に切り替えています。アカウントを使用したり、アカウントの履歴を表示したりできない場合があります。", + "networkChangeAccountDetailsWarning": "注意:%{from}から%{to}に切り替えるとアカウントが使用できなくなったり、アカウントの履歴が表示されなくなる場合があります!", "nodeList": "ノードリスト", "addNode": "ノードの追加", "enterURL": "URLを入力してください", @@ -729,7 +730,7 @@ "accessDuration": "期間", "accessGranted": "権限付与日", "seeAddress": "rアドレスの取得", - "sendPushNotifications": "(Xummアプリを通じた)プッシュ通知の送信", + "sendPushNotifications": "(Xamanアプリを通じた)プッシュ通知の送信", "accessBalances": "残高の取得", "signOnYourBehalf": "代理の署名", "developerInformation": "開発者情報", @@ -739,28 +740,28 @@ "noAuthorizedThirdPartyApp": "許可されたサードパーティアプリはありません!", "onceYouAuthorizedAppYouWillSeeItHere": "アクセスを許可したサードパーティアプリがここに表示されます。", "networkList": "ネットワーク一覧", - "addedNetwork": "Added network", - "removeNetwork": "Removed network", - "addedNode": "Added node", - "removedNode": "Removed node", - "changedProperty": "Property changed", - "unableToDeleteNodeWhenConnectedToNetwork": "このネットワークに接続中のノードは削除できません!", - "developerModeEnabledWarning": "Enabling Developer Mode may reduce certain security functions. Proceed with utmost caution, and only enable it if you comprehend the potential consequences.", - "disablingDeveloperMode": "Disabling Developer Mode", - "disableDeveloperModeRevertNetworkWarning": "Please note that this action will revert your selected network from '%{currentNetwork}' to the '%{defaultNetwork}'. Are you sure you want to proceed?", - "blockingTakingScreenShotsIsDisabled": "Developer mode is active, Screenshot capture protection is temporarily disabled.", - "syncRailsRemoveNetworkWarning": "Applying this sync will disconnect you from the current network (%{currentNetwork}). Please switch to a different network and try again.", - "syncRailsRemoveNodeWarning": "By applying this sync, the current node (%{connectedNode}) to which you are currently connected will be removed. Please select a new default node for this network and try again.", - "deletingNodeWillRemoveTheNetwork": "This is the sole node for this network. Removing this node will also delete the network. Do you wish to proceed?", - "networkRailsSyncCompleted": "Network Rails syncing has been successfully completed.", - "networkRailsAreAlreadyUpdateToDate": "Network rails are already up to date", - "networkRailsSuccessfullyUpdated": "Network rails have been successfully updated", - "networkSettings": "Network settings", - "changeDefaultNodeInfo": "Tap on any node in the list to set it as your preferred default node for the network.", - "networkHaveOnlyOneNodeAsDefault": "This network has only one node, which is already set as the default.", - "networkUpdates": "Network updates", - "everythingIsUpdateToDate": "Everything is up-to-date", - "networkAreUpdateToDate": "There are no added or changes for network settings at the moment." + "addedNetwork": "追加したネットワーク", + "removeNetwork": "削除したネットワーク", + "addedNode": "追加したノード", + "removedNode": "削除してノード", + "changedProperty": "プロパティの変更", + "unableToDeleteNodeWhenConnectedToNetwork": "接続中のノードを削除できません。ネットワークを切り替えてもう一度やり直してください!", + "developerModeEnabledWarning": "開発者モードを有効にすると、特定のセキュリティ機能が低下する可能性があります。細心の注意を払い、潜在的な影響を十分に理解した上で有効にしてください。", + "disablingDeveloperMode": "開発者モードを無効化", + "disableDeveloperModeRevertNetworkWarning": "この操作は、選択したネットワークを'%{currentNetwork}'から'%{defaultNetwork}'に戻すものであることに注意してください。続行してもよろしいですか?", + "blockingTakingScreenShotsIsDisabled": "開発者モードが有効な場合、スクリーンショットのキャプチャ防止機能は一時的に無効になります。", + "syncRailsRemoveNetworkWarning": "この同期を適用すると、現在のネットワーク(%{currentNetwork})から切断されます。別のネットワークに切り替えてもう一度お試しください。", + "syncRailsRemoveNodeWarning": "この同期を適用すると、現在接続しているノード(%{connectedNode})が削除されます。このネットワークの新しいデフォルトノードを選択してもう一度お試しください。", + "deletingNodeWillRemoveTheNetwork": "このネットワークの唯一のノードです。このノードを削除すると、ネットワークも削除されます。続行しますか?", + "networkRailsSyncCompleted": "ネットワーク情報の同期が正常に完了しました。", + "networkRailsAreAlreadyUpdateToDate": "ネットワーク情報は最新です。", + "networkRailsSuccessfullyUpdated": "ネットワーク情報が正常に更新されました。", + "networkSettings": "ネットワーク設定", + "changeDefaultNodeInfo": "リスト内の任意のノードをタップして、そのノードをネットワークの優先デフォルトノードとして設定します。", + "networkHaveOnlyOneNodeAsDefault": "このネットワークにはノードは1つしかなく、デフォルトとして設定済みです。", + "networkUpdates": "ネットワークの更新情報", + "everythingIsUpdateToDate": "全て最新です", + "networkAreUpdateToDate": "現在、ネットワーク設定の追加や変更はありません。" }, "account": { "addAccount": "アカウントを追加", @@ -805,7 +806,7 @@ "confirmNumbersOfRow": "%{row}行目を確認してください", "pleaseRepeatTheNumbers": "数字を入力してください", "pleaseWriteDownAllNumbers": "すべての数字を書き留めてください", - "goBackClearTheInput": "本当に戻りますか? \n(セキュリティ上の理由により、入力内容はクリアされます)", + "goBackClearTheInput": "本当に戻りますか?\n(セキュリティ上の理由により、入力内容はクリアされます)", "goBackRefillTheInput": "本当に戻りますか?\r\n(セキュリティ上の理由により、全ての項目を再度入力する必要があります)", "accountType": "アカウントの種類", "secretType": "シークレットタイプ", @@ -817,9 +818,9 @@ "tangemCardEmptyGenerateWalletAlert": "Tangemカードには、まだXRP Ledgerアカウントが含まれていません。このカードを使用するには、アカウントがカードによって生成される必要があります。", "generateAccount": "アカウントの作成", "cardSecurity": "カードセキュリティ", - "tangemLongTapExplain": "このメカニズムは、カードに対する近接攻撃を再保護します。これにより、コマンドの逆行と Excel の間の遅延が強制的に行われます。", + "tangemLongTapExplain": "この機能は、第三者の接近からカードを保護するもので、コマンドの受信と実行の間に遅延時間を設定します。", "tangemPasscodeExplain": "カード状態の変更を変更するコマンドを実行する前に、パスコードを入力する必要があります。", - "tangemAccessCodeExplain": "Before the execution of any command, you will have to enter the access code.", + "tangemAccessCodeExplain": "コマンドを実行する前に、アクセスコードを入力する必要があります。", "cardSecuritySuccessfullyChangedTo": "カードのセキュリティが %{security} に変更されました。", "cardId": "カード ID", "tangemNFCNotSupportedDeviceAlert": "Tangemカードを使用するには、NFC機能が必要です。利用中のスマートフォンはNFCに対応していないようです。", @@ -836,7 +837,7 @@ "familySeedDesc": "sXXX1234XXX...のような文字列", "mnemonic": "ニーモニック", "scanFromQR": "QRコードをスキャン", - "mnemonicDesc": "12、16、または24語に基づく", + "mnemonicDesc": "12、16、または24語の文字列", "readOnlyAccount": "読み取り専用アカウント", "pleaseProvideAccountAddress": "アカウントアドレスを入力してください(「r」で始まります)", "pleaseEnterYourAddress": "アドレスを入力してください", @@ -872,16 +873,16 @@ "downgradingAccessLevelWarningPhysical": "アクセスレベルをダウングレードしようとしています。本当によろしいですか?", "removeTrustLineWarning": "この通貨をアカウントから削除します。この操作は元に戻せません。よろしいですか?", "unavailableChangeSecurityLevel": "現在、セキュリティレベルの変更はできません", - "accountRemoveWarning": "ご使用のアカウントは Xaman から完全に削除されます。よろしいですか ?", - "accountMaxLabelLengthError": "アカウント名は16文字未満にしてください!", - "accountLabelCannotBeMoreThan": "Account label cannot be more than 64 characters!", + "accountRemoveWarning": "ご使用のアカウントはXamanから完全に削除されます。よろしいですか?", + "accountMaxLabelLengthError": "アカウント名は64文字未満にしてください!", + "accountLabelCannotBeMoreThan": "アカウントラベルは64文字以上にはできません!", "accountTrustLines": "アカウントトラストライン", "youDoNotHaveAnyTrustLine": "トラストラインはありません", "yourAccountIsNotActivated": "アカウントが有効化されていません!", "selectedAccountIsNotActivatedPleaseChooseAnotherOne": "選択したアカウントは有効化されていません。このトランザクションに署名するには、有効化されたアカウントを選択する必要があります!", "accountAlreadyExist": "このアカウントは既に使われています", - "importingSecretAccountExist": "The account secret that you have entered belongs to this r-address and has already been imported into Xaman as a full access account.\n\n%{address}", - "upgradeAccountSecretIsNotMatch": "入力されたシークレットは別のrアドレスに属しています。レギュラーキーをインポートしたい場合は、[新しいアカウントをインポート]してください。そうでない場合は、[キャンセル]してエントリを確認してください。", + "importingSecretAccountExist": "入力したアカウントシークレットは、次のrアドレスに紐づいており、全権アカウントとしてXamanにインポート済みです。\n\n%{address}", + "upgradeAccountSecretIsNotMatch": "入力されたシークレットは別のrアドレスに紐づいています。レギュラーキーをインポートしたい場合は、[新しいアカウントをインポート]してください。そうでない場合は、[キャンセル]してエントリを確認してください。", "toTheseExistingAccounts": "これ/これらの既存のアカウントに", "masterKeyForThisAccountDisableRegularKeyNotFound": "このアカウントのマスターキーは無効になっており、レギュラーキーアカウントはアカウントリストにありません!", "regularKeyAccountForThisAccountDoesNotImportedWithSignAccess": "このアカウントのレギュラーキーは、サインアクセスでインポートされませんでした!", @@ -910,30 +911,30 @@ "unableToCheckAccountNFTs": "アカウントのNFTを確認できません。XRP Ledgerノードに接続していることを確認してください。", "unableToFetchLedgerSequence": "現在のLedgerシーケンスを取得できません。XRP Ledgerノードに接続されていることを確認してください。", "unableGetDestinationAccountInfo": "宛先のアカウント情報を取得できません。XRPレジャーのノードに接続していることを確認してください。", - "unableGetAccountInfo": "Unable to fetch account info, please make sure you are connected to the XRP ledger node", + "unableGetAccountInfo": "アカウント情報を取得できません。XRP Ledgerノードに接続されていることを確認してください。", "destinationAccountIsNotActivated": "宛先のアカウントは有効化されていません。XRPレジャー上で入金されているアカウントである必要があります。", "destinationAddressRequiredDestinationTag": "宛先アドレスには宛先タグが必要です", "destinationAccountAndSourceCannotBeSame": "送金先と送金元のアカウントを同じにすることはできません。", - "accountGenerateActivationExplain": "アカウントを有効化する必要があります。有効化するには、最初に%{baseReserve} XRP以上の入金が必要です。", + "accountGenerateActivationExplain": "アカウントを有効化する必要があります。有効化するには、最初に%{baseReserve} %{nativeAsset}以上の入金が必要です。", "accountImportActivationExplain": "XRPレジャーに新規アカウントをインポートしました。アカウントを有効化する必要があります。有効化するには、最初に%{baseReserve} %{nativeAsset}以上の入金を行う必要があります。", - "accountActivateReserveExplain": "アカウントに預け入れられた最初の%{baseReserve} %{nativeAsset}は使用できません。この%{baseReserve} XRPはアカウントを有効化し、レジャーへの手数料を支払うため使用されます。", + "accountActivateReserveExplain": "アカウントに預け入れられた最初の%{baseReserve} %{nativeAsset}は使用できません。この準備金はアカウントを有効化し、レジャーへの手数料を支払うため使用されます。", "accountReserveNotShownExplain": "準備金分の%{nativeAsset}は残高として表示されませんが、ホーム画面の残高の右にある[残高詳細]ボタンで確認できます。", "thisAddressAppearsToBeExchangeAddress": "このアドレスは取引所アドレスのようですが、続行してもよろしいですか?\r\n取引所の入庫アドレスとして指定されているアドレスでない場合、送信しないでください。", "accountDestroyWarning": "アカウントは完全に削除されます。よろしいですか?", "destroyAccount": "このアカウントを削除する", "importTangemCard": "Tengemカードをインポートする", "unableToHideAllAccountsError": "このアカウントを非表示にできません。少なくとも1つのアカウントが表示されている必要があります。", - "unableToHideDefaultAccountError": "Unable to hide this default account. Change default account and try again.", + "unableToHideDefaultAccountError": "デフォルトアカウントを非表示にできません。デフォルトアカウントを変更して再度お試しください。", "tapAndHoldToReorder": "項目を長押しすることで順位を好きに並び替えすることができます。", - "importSecret": "インポートシークレット", + "importSecret": "シークレットのインポート", "toTurnYourSecretIntoXrplLedgerAccountPleaseEnterYourSecret": "XRP Ledgerアカウントを開設する場合は、シークレットキーを入力してください。", "enterSecret": "シークレットを入力する", "yourChainAddressWas": "あなたの%{chain}アドレスは:", "yourXRPLedgerAccountIsGoingToBe": "あなたのXRP Ledgerアカウントは:", "importSecretWithoutChecksumWarning": "続行すると、シークレットナンバーからXRP Ledgerアカウントをインポートすることになります。シークレットナンバーの生成は、あなた自身の責任で行ってください。サイコロなどを使ったオフラインの方法で生成することをお勧めします。シークレットナンバーを作成した後は、必ず保管してください(金属製の刻印やメモなど)。\r\n自分が何をしているのか分かっている場合にのみ、作業を進めてください。", - "tangemCardPasscodeSetWarning": "カードにパスコードを追加すると、紛失 (および検出 ) カードの場合の資金の安全性が向上しますが、パスコードを覚えていない場合は、お客様の資金が INACCESSIBLE および CAN *NOT* BE RECOVERED になることを認識することが重要です。\n\nカードにパスコードを追加しても本当によろしいですか ?", - "tangemCardAccessCodeSetWarning": "While adding a access code to your card improves the safety of your funds in case of a lost (and found) card, it is important to realize that your funds will be INACCESSIBLE and CAN *NOT* BE RECOVERED (by anyone) if you don't remember your access code.\r\n\r\nAre you really sure you want to add a access code to your card?", - "thereAreAccountsEligibleToSign": "There are %{signersCount} accounts eligible to sign. Which one do you want to sign with?", + "tangemCardPasscodeSetWarning": "カードにパスコードを追加すると、カードを紛失したの場合の資金の安全性が向上しますが、パスコードを忘れた場合、お客様の資金が *アクセス不能* および *復元不可能* になることをご認識ください。\n\nカードにパスコードを追加しても本当によろしいですか?", + "tangemCardAccessCodeSetWarning": "カードにアクセスコードを追加すると、カードを紛失したの場合の資金の安全性が向上しますが、アクセスコードを忘れた場合、お客様の資金が *アクセス不能* および *復元不可能* になることをご認識ください。\n\nカードにアクセスコードを追加しても本当によろしいですか?", + "thereAreAccountsEligibleToSign": "署名可能なアカウントが%{signersCount}個あります。署名したいアカウントを選択してください。", "mainAccount": "メインアカウント", "backupAccount": "レギュラーキー(バックアップアカウント)", "verifyTangemCard": "Tangemカードを確認する", @@ -941,18 +942,18 @@ "signatureVerificationExplain": "Tamgemカードが正しく動作し、取引に署名できることを確認するため、カードによって生成された取引署名を検証するために署名ルーチンを1回実行します。", "yourXRPLedgerAccountWillNotBeTouched": "ご使用のXRP Ledgerアカウントと資金に触れることはありません。", "unableToVerifyTheSignature": "署名を検証できません。", - "newEncryptionMethodAvailable": "New encryption method available!", - "checkWhichAccountsNeedBetterEncryption": "Check which accounts need better encryption", - "updateEncryption": "Update encryption", - "whyUseThisNewEncryptionMethod": "Why use this new encryption method?", - "newEncryptionExplain": "Our encryption & security is enhanced to new standards AES512 GCM. You should encrypt your account with this new method to be extra safe. Although you are already safe, it can't hurt to upgrade to the new standards.", - "doNotTurnOffYourPhoneOrQuiteWhileMigration": "Don't turn off your phone or quit the app while doing the encryption.", - "unableToFetchAccountNFTokens": "Unable to fetch the account NFT's. Please make sure you are connected to the XRP Ledger node." + "newEncryptionMethodAvailable": "新しい暗号化方式が利用可能になりました!", + "checkWhichAccountsNeedBetterEncryption": "暗号化方式の強化が必要なアカウントの確認", + "updateEncryption": "暗号化方式の更新", + "whyUseThisNewEncryptionMethod": "なぜ新しい暗号化方式を使うのですか?", + "newEncryptionExplain": "私たちの暗号化方式とセキュリティは、新しい規格であるAES512 GCMへと改善されています。より安全にご利用いただくために、この新しい方法でアカウントを暗号化する必要があります。すでに安全ではありますが、新しい規格にアップグレードして損はありません。", + "doNotTurnOffYourPhoneOrQuiteWhileMigration": "暗号化中にデバイスの電源を切ったり、アプリを終了したりしないでください。", + "unableToFetchAccountNFTokens": "アカウントのNFTを取得できません。XRP Ledgerノードに接続していることを確認してください。" }, "send": { "amountIsBiggerThanYourSpend": "利用可能残高が不足しています。(利用可能残高: %{spendable})", "theMaxAmountYouCanSendIs": "送金可能金額は %{spendable} %{currency} です", - "theMaxAmountYouCanSendWithFee": "の発行者%{currency}転送料金を請求します。最大送金できる金額(振込手数料を考慮)は%{spendable}%{currency}", + "theMaxAmountYouCanSendWithFee": "%{currency}の発行者は送金手数料を設定しています。最大送金できる金額(送金手数料を考慮)は%{spendable}%{currency}です。", "insufficientBalanceSpendableBalance": "残高不足、支出可能な残高: %{spendable} %{currency}", "trustLineIsFrozenByIssuer": "Your Trust Line for the requested asset (%{currency}) has been frozen by the issuer. Please contact the issuer of the asset.", "balanceIsNotEnoughForFee": "残高が不足しています(手数料: %{fee})", @@ -984,7 +985,7 @@ "submittingToLedger": "%{network}へトランザクションを送信中", "sendingFrom": "から送信しています", "enterDescription": "説明を入力してください", - "enterPublicMemo": "公開メモを入力してください(オプション)", + "enterPublicMemo": "公開メモを入力してください(任意)", "enterDestinationTag": "宛先タグを入力してください", "pleaseEnterTheDestinationTag": "宛先タグを入力してください", "invalidDestinationTag": "QRコードに有効な宛先タグが含まれていません。読み取ったQRコードを確認して、もう一度やり直してください。", @@ -1031,9 +1032,9 @@ "restrictingConfigurationDetected": "コンフィギュレーションの制限を検出", "moreInfoAndFix": "詳細情報および修正", "addingTrustLineWarning": "XRPL Labs / Xamanは、いかなるトークンやトークン発行者も推奨していません。トークン発行者を信頼する場合にのみ手続きを行ってください。\r\nトークン(TrustLine)に関する質問や問題が発生した場合には、トークン発行者に連絡する必要があります。\r\n\r\nご自身のリスクでお進みください。", - "trustLineIsAlreadyExist": "このトークンはすでに存在しています。同じトークンを再度追加することはできません。", - "issuerAddressCopiedToClipboard": "Issuer address copied to the clipboard", - "unableToLoadListOfTokens": "Unable to load the list of tokens!" + "trustLineIsAlreadyExist": "このトークンはすでに存在しています。同じトークンを追加することはできません。", + "issuerAddressCopiedToClipboard": "発行者アドレスがクリップボードへコピーされました", + "unableToLoadListOfTokens": "トークンのリストを取得できません!" }, "exchange": { "exchanging": "両替中", @@ -1044,7 +1045,7 @@ "liquidityIsNotEnough": "十分な流動性がないため、現在両替できません。", "liquidityIsNotSoMuch": "流動性が低い状態です。引き続きご利用いただけますが、最良のレートが得られない可能性があります。", "theMaxAmountYouCanExchangeIs": "両替可能な最大金額は %{spendable} %{currency} です", - "exchangeByThirdPartyMessage": "要求された価格レベルで実行するオファーを作成する場合は、サードパーティのXaman対応XRPツールキットアプリケーションを使用して指値注文を作成できます。", + "exchangeByThirdPartyMessage": "指定価格で約定するオファーを作成する場合は、Xaman対応のサードパーティアプリケーションを使用して指値注文を作成できます。", "requestedLiquidityNotAvailable": "この金額で両替することはできません。分散型取引所で利用できるオファーが十分ではありません。", "reverseLiquidityNotAvailable": "この金額を両替することはできません。分散型取引所でのオファーがないため、元に戻すことはできません。", "maxSpreadExceeded": "オファーの販売と購入の価格差が大きすぎます。", @@ -1059,7 +1060,7 @@ "scan": { "aimAtTheCode": "QRコードをスキャンする", "pleaseScanAccountAddress": "%{nativeAsset}アドレスのQRコードをスキャンしてください", - "scannedQRIsNotAccountAddress": "スキャンしたQRコードは%{nativeAsset}アドレスコードではありません!", + "scannedQRIsNotAccountAddress": "スキャンしたQRコードは%{nativeAsset}アドレスではありません!", "theClipboardDataIsNotContainAccountAddress": "クリップボードデータに有効な%{nativeAsset}アドレスが含まれていません!", "scannedQRIsNotXamanPayload": "スキャンしたQRコードはXamanペイロードではありません!", "theClipboardDataIsNotContainXamanPayload": "クリップボードデータに、有効なXamanペイロードが含まれていません!", @@ -1086,15 +1087,15 @@ "unexpectedErrorOccurred": "予期しないエラーが発生しました、参照%{reference}", "unexpectedPayloadErrorOccurred": "ペイロードは無効であり、自動的に拒否されます。", "whatDoYouWantToDo": "何をしたいですか?", - "willIgnoreTheRequestAndClose": "リクエストを無視して閉じます。", - "willRejectTheSignRequest": "署名リクエストを拒否します", + "willIgnoreTheRequestAndClose": "リクエストを無視して閉じる", + "willRejectTheSignRequest": "署名リクエストを拒否する", "payingWithNativeAssetExchangeRate": "%{nativeRoundedUp} %{nativeAsset}で支払う。\n為替レート:〜 %{exchangeRate}", "notEnoughLiquidityToSendThisPayment": "この支払いを送るのに十分な流動性がありません。", "unableToCheckAssetConversion": "アセットの変換を確認できません。XRPLノードに接続していることを確認してください", "unableToGetNetworkFee": "ネットワーク手数料を取得できません。XRPLノードに接続していることを確認してください", "checkCanOnlyCashByCheckDestination": "チェックは、チェックの宛先アカウントが読み取り/書き込み(またはレギュラーキー)モードのXamanに存在する場合にのみ現金化できます。", "unableToGetCheckObject": "チェックオブジェクトを取得できません。XRPLノードに接続していることを確認してください", - "checkObjectDoesNotExist": "チェックオブジェクトを取得できません。チェックがXRPL Ledgerに存在することを確認してください。", + "checkObjectDoesNotExist": "チェックオブジェクトを取得できません。チェックがXRP Ledgerに存在することを確認してください。", "insufficientCashAmount": "不十分な金額、現金化可能な金額:%{amount}%{currency}", "nonExpiredCheckCanOnlyCancelByCreatedAccount": "(有効期限が切れていない)チェックは、それを作成したアカウントまたは宛先アカウントによってのみキャンセルできます。", "accountDeleteExchangeSupportWarning": "注: XRP Ledgerアカウントを削除し、残りの残高を取引所に送信する場合は、宛先の取引所が'AccountDelete'トランザクションを使用した入金をサポートfしていることを確認してください。すべての取引所が対応しているわけではありません。この場合、取引所のサポートチームに連絡して、お客様の口座に資金を入金してもらう必要があります。", @@ -1277,4 +1278,4 @@ ], "abbr": "ja" } -} \ No newline at end of file +} From ee4d88e9ac288a25f4e1e677b31e8591ab1d9752 Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Fri, 2 Feb 2024 10:57:11 +0100 Subject: [PATCH 20/54] chore: bump xrpl-accountlib --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index c8e180fb9..ad9ecd3f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,7 @@ "realm": "12.3.1", "tangem-sdk-react-native": "2.3.1", "uuid": "9.0.1", - "xrpl-accountlib": "3.2.8", + "xrpl-accountlib": "3.2.9", "xrpl-orderbook-reader": "0.4.0", "xumm-string-decode": "0.6.2" }, @@ -19346,9 +19346,9 @@ } }, "node_modules/xrpl-accountlib": { - "version": "3.2.8", - "resolved": "https://registry.npmjs.org/xrpl-accountlib/-/xrpl-accountlib-3.2.8.tgz", - "integrity": "sha512-gIwyAkAzda66NBusRAU2/e2RQpopYtjY0Uk7TfZzsahAnj9ZAw2/IGm0we2CA834kgOjaK4VpKsg/doaV5LsKg==", + "version": "3.2.9", + "resolved": "https://registry.npmjs.org/xrpl-accountlib/-/xrpl-accountlib-3.2.9.tgz", + "integrity": "sha512-jg6I18LzL3jXKPhEdos958PcVW/XLB2eaaZTM06WlVqgxCyNs9G2GEDl+xrqAWopzy1WcCR0/hF/4cmTCHytag==", "dependencies": { "assert": "^2.0.0", "bip32": "^2.0.6", diff --git a/package.json b/package.json index fef4b492a..1d88c61ad 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "realm": "12.3.1", "tangem-sdk-react-native": "2.3.1", "uuid": "9.0.1", - "xrpl-accountlib": "3.2.8", + "xrpl-accountlib": "3.2.9", "xrpl-orderbook-reader": "0.4.0", "xumm-string-decode": "0.6.2" }, From 830f94eb387ef453fc396deb2f9568bb8a0387a5 Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Fri, 2 Feb 2024 12:30:47 +0100 Subject: [PATCH 21/54] fix(android): quick fix for webview crash --- src/components/General/WebView/styles.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/General/WebView/styles.ts b/src/components/General/WebView/styles.ts index 3c95bcf50..956282e9e 100644 --- a/src/components/General/WebView/styles.ts +++ b/src/components/General/WebView/styles.ts @@ -9,6 +9,7 @@ export default StyleService.create({ }, webView: { backgroundColor: '$background', + opacity: 0.99, }, loadingStyle: { zIndex: 999999, From 183a44864a07a086fd4d1575da4948a59dc0e9f2 Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Fri, 2 Feb 2024 12:45:27 +0100 Subject: [PATCH 22/54] fix: small transaction details issues --- .../genuine/CheckCreate/CheckCreateInfo.ts | 10 ++++++---- .../genuine/EscrowCreate/EscrowCreateInfo.ts | 7 +++++-- .../NFTokenCreateOffer/NFTokenCreateOfferInfo.ts | 7 ++++--- .../genuine/NFTokenMint/NFTokenMintInfo.ts | 6 ++++-- .../transactions/genuine/Payment/PaymentInfo.ts | 12 ++++++++---- .../PaymentChannelCreateInfo.ts | 15 ++++++++------- 6 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/common/libs/ledger/transactions/genuine/CheckCreate/CheckCreateInfo.ts b/src/common/libs/ledger/transactions/genuine/CheckCreate/CheckCreateInfo.ts index b35dc8e66..4f66c3751 100644 --- a/src/common/libs/ledger/transactions/genuine/CheckCreate/CheckCreateInfo.ts +++ b/src/common/libs/ledger/transactions/genuine/CheckCreate/CheckCreateInfo.ts @@ -1,9 +1,10 @@ +import { isUndefined } from 'lodash'; +import Localize from '@locale'; + import { AccountModel } from '@store/models'; import { NormalizeCurrencyCode } from '@common/utils/amount'; -import Localize from '@locale'; - import CheckCreate from './CheckCreateClass'; /* Descriptor ==================================================================== */ @@ -18,11 +19,12 @@ const CheckCreateInfo = { destination: tx.Destination.address, }); - if (tx.Account.tag) { + if (!isUndefined(tx.Account?.tag)) { content += '\n'; content += Localize.t('events.theCheckHasASourceTag', { tag: tx.Account.tag }); } - if (tx.Destination.tag) { + + if (!isUndefined(tx.Destination.tag)) { content += '\n'; content += Localize.t('events.theCheckHasADestinationTag', { tag: tx.Destination.tag }); } diff --git a/src/common/libs/ledger/transactions/genuine/EscrowCreate/EscrowCreateInfo.ts b/src/common/libs/ledger/transactions/genuine/EscrowCreate/EscrowCreateInfo.ts index a4cbdf1e6..56046508b 100644 --- a/src/common/libs/ledger/transactions/genuine/EscrowCreate/EscrowCreateInfo.ts +++ b/src/common/libs/ledger/transactions/genuine/EscrowCreate/EscrowCreateInfo.ts @@ -1,8 +1,10 @@ +import { isUndefined } from 'lodash'; import moment from 'moment-timezone'; -import { AccountModel } from '@store/models'; import Localize from '@locale'; +import { AccountModel } from '@store/models'; + import EscrowCreate from './EscrowCreateClass'; /* Descriptor ==================================================================== */ @@ -16,7 +18,8 @@ const EscrowCreateInfo = { account: tx.Account.address, destination: tx.Destination.address, }); - if (tx.Destination.tag) { + + if (!isUndefined(tx.Destination.tag)) { content += '\n'; content += Localize.t('events.theEscrowHasADestinationTag', { tag: tx.Destination.tag }); content += ' '; diff --git a/src/common/libs/ledger/transactions/genuine/NFTokenCreateOffer/NFTokenCreateOfferInfo.ts b/src/common/libs/ledger/transactions/genuine/NFTokenCreateOffer/NFTokenCreateOfferInfo.ts index 04f0b3cf3..ad648e5d0 100644 --- a/src/common/libs/ledger/transactions/genuine/NFTokenCreateOffer/NFTokenCreateOfferInfo.ts +++ b/src/common/libs/ledger/transactions/genuine/NFTokenCreateOffer/NFTokenCreateOfferInfo.ts @@ -7,6 +7,7 @@ import { NormalizeCurrencyCode } from '@common/utils/amount'; import Localize from '@locale'; import NFTokenCreateOffer from './NFTokenCreateOfferClass'; +import { isUndefined } from 'lodash'; /* Descriptor ==================================================================== */ const NFTokenCreateOfferInfo = { @@ -17,7 +18,7 @@ const NFTokenCreateOfferInfo = { getDescription: (tx: NFTokenCreateOffer): string => { let content = ''; - if (tx.Flags.SellToken) { + if (tx.Flags?.SellToken) { content += Localize.t('events.nftOfferSellExplain', { address: tx.Account.address, tokenID: tx.NFTokenID, @@ -33,12 +34,12 @@ const NFTokenCreateOfferInfo = { }); } - if (tx.Owner) { + if (!isUndefined(tx.Owner)) { content += '\n'; content += Localize.t('events.theNftOwnerIs', { address: tx.Owner }); } - if (tx.Destination) { + if (!isUndefined(tx.Destination?.address)) { content += '\n'; content += Localize.t('events.thisNftOfferMayOnlyBeAcceptedBy', { address: tx.Destination.address }); } diff --git a/src/common/libs/ledger/transactions/genuine/NFTokenMint/NFTokenMintInfo.ts b/src/common/libs/ledger/transactions/genuine/NFTokenMint/NFTokenMintInfo.ts index 852b37f17..80e5a05c0 100644 --- a/src/common/libs/ledger/transactions/genuine/NFTokenMint/NFTokenMintInfo.ts +++ b/src/common/libs/ledger/transactions/genuine/NFTokenMint/NFTokenMintInfo.ts @@ -1,3 +1,5 @@ +import { isUndefined } from 'lodash'; + import Localize from '@locale'; import NFTokenMint from './NFTokenMintClass'; @@ -13,12 +15,12 @@ const NFTokenMintInfo = { content += Localize.t('events.theTokenIdIs', { tokenID: tx.NFTokenID }); - if (typeof tx.TransferFee === 'number') { + if (!isUndefined(tx.TransferFee)) { content += '\n'; content += Localize.t('events.theTokenHasATransferFee', { transferFee: tx.TransferFee }); } - if (typeof tx.NFTokenTaxon === 'number') { + if (!isUndefined(tx.NFTokenTaxon)) { content += '\n'; content += Localize.t('events.theTokenTaxonForThisTokenIs', { taxon: tx.NFTokenTaxon }); } diff --git a/src/common/libs/ledger/transactions/genuine/Payment/PaymentInfo.ts b/src/common/libs/ledger/transactions/genuine/Payment/PaymentInfo.ts index a57ff1ffa..ec3969eda 100644 --- a/src/common/libs/ledger/transactions/genuine/Payment/PaymentInfo.ts +++ b/src/common/libs/ledger/transactions/genuine/Payment/PaymentInfo.ts @@ -1,9 +1,11 @@ +import { isUndefined } from 'lodash'; + +import Localize from '@locale'; + import { AccountModel } from '@store/models'; import { NormalizeCurrencyCode } from '@common/utils/amount'; -import Localize from '@locale'; - import Payment from './PaymentClass'; /* Descriptor ==================================================================== */ @@ -25,11 +27,13 @@ const PaymentInfo = { getDescription: (tx: Payment): string => { let content = ''; - if (tx.Account.tag) { + + if (!isUndefined(tx.Account?.tag)) { content += Localize.t('events.thePaymentHasASourceTag', { tag: tx.Account.tag }); content += ' \n'; } - if (tx.Destination.tag) { + + if (!isUndefined(tx.Destination?.tag)) { content += Localize.t('events.thePaymentHasADestinationTag', { tag: tx.Destination.tag }); content += ' \n'; } diff --git a/src/common/libs/ledger/transactions/genuine/PaymentChannelCreate/PaymentChannelCreateInfo.ts b/src/common/libs/ledger/transactions/genuine/PaymentChannelCreate/PaymentChannelCreateInfo.ts index c650987c9..f7d6a72d1 100644 --- a/src/common/libs/ledger/transactions/genuine/PaymentChannelCreate/PaymentChannelCreateInfo.ts +++ b/src/common/libs/ledger/transactions/genuine/PaymentChannelCreate/PaymentChannelCreateInfo.ts @@ -1,11 +1,12 @@ +import { isUndefined } from 'lodash'; import moment from 'moment-timezone'; +import Localize from '@locale'; + import { AccountModel } from '@store/models'; import { LedgerObjectTypes, TransactionTypes } from '@common/libs/ledger/types'; -import Localize from '@locale'; - import PaymentChannelCreate from './PaymentChannelCreateClass'; /* Descriptor ==================================================================== */ @@ -43,24 +44,24 @@ const PaymentChannelCreateInfo = { content += '\n'; } - if (tx.Account.tag !== undefined) { + if (!isUndefined(tx.Account?.tag)) { content += Localize.t('events.theASourceTagIs', { tag: tx.Account.tag }); content += ' \n'; } - if (tx.Destination.tag !== undefined) { + if (!isUndefined(tx.Destination?.tag)) { content += Localize.t('events.theDestinationTagIs', { tag: tx.Destination.tag }); content += ' \n'; } // @ts-ignore - if (tx.Type === LedgerObjectTypes.PayChannel && tx.Expiration) { + if (tx.Type === LedgerEntryTypes.PayChannel && tx.Expiration) { // @ts-ignore - content += Localize.t('events.theChannelExpiresAt', { cancelAfter: tx.Expiration }); + content += Localize.t('events.theChannelExpiresAt', { expiration: moment(tx.Expiration).format('LLLL') }); content += ' \n'; } - if (tx.SettleDelay) { + if (!isUndefined(tx.SettleDelay)) { content += Localize.t('events.theChannelHasASettlementDelay', { delay: tx.SettleDelay }); content += ' \n'; } From 2eff7ee4cedf5b2ff589d908165cc81193ef997d Mon Sep 17 00:00:00 2001 From: N3TC4T Date: Tue, 9 Jan 2024 12:22:37 +0100 Subject: [PATCH 23/54] chore: better typing definitions --- src/common/helpers/resolver.ts | 15 +- src/common/libs/ledger/factory/explainer.ts | 6 +- src/common/libs/ledger/factory/object.ts | 4 +- src/common/libs/ledger/factory/transaction.ts | 21 +- src/common/libs/ledger/factory/validation.ts | 2 +- .../libs/ledger/objects/BaseLedgerObject.ts | 7 +- .../libs/ledger/objects/Check/CheckClass.ts | 4 +- .../libs/ledger/objects/Escrow/EscrowClass.ts | 4 +- .../objects/NFTokenOffer/NFTokenOfferClass.ts | 4 +- .../libs/ledger/objects/Offer/OfferClass.ts | 4 +- .../objects/PayChannel/PayChannelClass.ts | 4 +- .../libs/ledger/objects/Ticket/TicketClass.ts | 4 +- .../ledger/parser/common/flags/objectFlags.ts | 3 + src/common/libs/ledger/parser/entry.ts | 12 +- src/common/libs/ledger/parser/meta.ts | 2 +- src/common/libs/ledger/parser/types.ts | 47 +- src/common/libs/ledger/pathFinding.ts | 49 ++- .../AccountDelete/AccountDeleteClass.ts | 5 +- .../AccountDelete/AccountDeleteValidation.ts | 8 +- .../genuine/AccountSet/AccountSetClass.ts | 5 +- .../transactions/genuine/BaseTransaction.ts | 26 +- .../genuine/CheckCancel/CheckCancelClass.ts | 6 +- .../genuine/CheckCash/CheckCashClass.ts | 5 +- .../genuine/CheckCreate/CheckCreateClass.ts | 5 +- .../CheckCreate/CheckCreateValidation.ts | 5 +- .../genuine/ClaimReward/ClaimRewardClass.ts | 7 +- .../DepositPreauth/DepositPreauthClass.ts | 5 +- .../EnableAmendment/EnableAmendmentClass.ts | 8 +- .../genuine/EscrowCancel/EscrowCancelClass.ts | 5 +- .../genuine/EscrowCreate/EscrowCreateClass.ts | 9 +- .../genuine/EscrowFinish/EscrowFinishClass.ts | 5 +- .../genuine/GenesisMint/GenesisMintClass.ts | 5 +- .../genuine/Import/ImportClass.ts | 5 +- .../genuine/Invoke/InvokeClass.ts | 5 +- .../NFTokenAcceptOfferClass.ts | 9 +- .../genuine/NFTokenBurn/NFTokenBurnClass.ts | 5 +- .../NFTokenCancelOfferClass.ts | 6 +- .../NFTokenCreateOfferClass.ts | 10 +- .../genuine/NFTokenMint/NFTokenMintClass.ts | 5 +- .../genuine/OfferCancel/OfferCancelClass.ts | 5 +- .../genuine/OfferCreate/OfferCreateClass.ts | 8 +- .../genuine/Payment/PaymentClass.ts | 25 +- .../genuine/Payment/PaymentValidation.ts | 10 +- .../PaymentChannelClaimClass.ts | 5 +- .../PaymentChannelCreateClass.ts | 5 +- .../PaymentChannelCreateInfo.ts | 4 +- .../PaymentChannelFundClass.ts | 5 +- .../genuine/SetHook/SetHookClass.ts | 5 +- .../SetRegularKey/SetRegularKeyClass.ts | 5 +- .../SignerListSet/SignerListSetClass.ts | 5 +- .../genuine/TicketCreate/TicketCreateClass.ts | 5 +- .../genuine/TrustSet/TrustSetClass.ts | 6 +- .../genuine/URITokenBurn/URITokenBurnClass.ts | 5 +- .../genuine/URITokenBuy/URITokenBuyClass.ts | 9 +- .../URITokenCancelSellOfferClass.ts | 5 +- .../URITokenCreateSellOfferClass.ts | 9 +- .../genuine/URITokenMint/URITokenMintClass.ts | 9 +- .../ledger/transactions/pseudo/BasePseudo.ts | 23 +- .../PaymentChannelAuthorizeClass.ts | 5 +- .../transactions/pseudo/SignIn/SignInClass.ts | 5 +- src/common/libs/ledger/types.ts | 407 ----------------- src/common/libs/ledger/types/common/index.ts | 177 ++++++++ src/common/libs/ledger/types/enums.ts | 68 +++ src/common/libs/ledger/types/ledger/AMM.ts | 76 ++++ .../libs/ledger/types/ledger/AccountRoot.ts | 80 ++++ .../libs/ledger/types/ledger/Amendments.ts | 38 ++ .../ledger/types/ledger/BaseLedgerEntry.ts | 30 ++ src/common/libs/ledger/types/ledger/Check.ts | 69 +++ .../ledger/types/ledger/DepositPreauth.ts | 24 + .../libs/ledger/types/ledger/DirectoryNode.ts | 45 ++ src/common/libs/ledger/types/ledger/Escrow.ts | 63 +++ .../libs/ledger/types/ledger/FeeSettings.ts | 44 ++ src/common/libs/ledger/types/ledger/Ledger.ts | 65 +++ .../libs/ledger/types/ledger/LedgerEntry.ts | 53 +++ .../libs/ledger/types/ledger/LedgerHashes.ts | 23 + .../libs/ledger/types/ledger/NFTokenOffer.ts | 13 + .../libs/ledger/types/ledger/NFTokenPage.ts | 15 + .../libs/ledger/types/ledger/NegativeUNL.ts | 27 ++ src/common/libs/ledger/types/ledger/Offer.ts | 41 ++ .../libs/ledger/types/ledger/PayChannel.ts | 96 ++++ .../libs/ledger/types/ledger/RippleState.ts | 77 ++++ .../libs/ledger/types/ledger/SignerList.ts | 40 ++ src/common/libs/ledger/types/ledger/Ticket.ts | 25 ++ src/common/libs/ledger/types/ledger/index.ts | 48 ++ .../ledger/types/methods/accountChannels.ts | 89 ++++ .../ledger/types/methods/accountCurrencies.ts | 41 ++ .../libs/ledger/types/methods/accountInfo.ts | 180 ++++++++ .../libs/ledger/types/methods/accountLines.ts | 137 ++++++ .../libs/ledger/types/methods/accountNFTs.ts | 70 +++ .../ledger/types/methods/accountObjects.ts | 88 ++++ .../ledger/types/methods/accountOffers.ts | 96 ++++ .../libs/ledger/types/methods/accountTx.ts | 108 +++++ .../libs/ledger/types/methods/ammInfo.ts | 147 +++++++ .../libs/ledger/types/methods/baseMethod.ts | 38 ++ .../libs/ledger/types/methods/bookOffers.ts | 94 ++++ .../ledger/types/methods/channelVerify.ts | 39 ++ .../ledger/types/methods/depositAuthorized.ts | 52 +++ src/common/libs/ledger/types/methods/fee.ts | 94 ++++ .../ledger/types/methods/gatewayBalances.ts | 81 ++++ src/common/libs/ledger/types/methods/index.ts | 302 +++++++++++++ .../libs/ledger/types/methods/ledger.ts | 122 ++++++ .../libs/ledger/types/methods/ledgerClosed.ts | 30 ++ .../ledger/types/methods/ledgerCurrent.ts | 29 ++ .../libs/ledger/types/methods/ledgerData.ts | 77 ++++ .../libs/ledger/types/methods/ledgerEntry.ts | 181 ++++++++ .../libs/ledger/types/methods/manifest.ts | 52 +++ .../libs/ledger/types/methods/nftBuyOffers.ts | 33 ++ .../ledger/types/methods/nftSellOffers.ts | 33 ++ .../ledger/types/methods/norippleCheck.ts | 79 ++++ .../libs/ledger/types/methods/pathFind.ts | 113 +++++ src/common/libs/ledger/types/methods/ping.ts | 22 + .../libs/ledger/types/methods/random.ts | 21 + .../ledger/types/methods/serverDefinitions.ts | 57 +++ .../libs/ledger/types/methods/serverInfo.ts | 257 +++++++++++ .../libs/ledger/types/methods/serverState.ts | 75 ++++ .../libs/ledger/types/methods/submit.ts | 90 ++++ .../ledger/types/methods/submitMultisigned.ts | 48 ++ .../libs/ledger/types/methods/subscribe.ts | 412 ++++++++++++++++++ .../ledger/types/methods/transactionEntry.ts | 43 ++ src/common/libs/ledger/types/methods/tx.ts | 77 ++++ .../libs/ledger/types/methods/unsubscribe.ts | 47 ++ .../libs/ledger/types/transaction/common.ts | 83 ++++ .../libs/ledger/types/transaction/index.ts | 2 + .../libs/ledger/types/transaction/metadata.ts | 41 ++ src/common/libs/payload/digest/codec.ts | 16 +- src/common/libs/payload/digest/digest.ts | 6 +- src/common/libs/payload/digest/serialize.ts | 8 +- src/common/libs/payload/object.ts | 5 +- src/common/libs/payload/types.ts | 12 +- src/common/utils/fee.ts | 4 +- .../AssetsList/NFTokens/NFTokensList.tsx | 2 +- .../EventListItems/LedgerObject.tsx | 14 +- .../EventsList/EventListItems/Transaction.tsx | 2 +- .../PaymentOptionItem/PaymentOptionItem.tsx | 15 +- .../PaymentOptionsPicker.tsx | 43 +- src/screens/Events/Details/DetailsView.tsx | 59 +-- src/screens/Events/EventsView.tsx | 123 ++++-- src/screens/Exchange/ExchangeView.tsx | 16 +- .../ReviewTransaction/ReviewTransaction.tsx | 3 +- .../Steps/Preflight/PreflightStep.tsx | 2 +- .../Steps/Review/ReviewStep.tsx | 2 +- .../Steps/Review/Templates/Global.tsx | 2 +- .../Steps/Review/Templates/Payment.tsx | 6 +- .../Review/Templates/PaymentChannelClaim.tsx | 26 +- .../Review/Templates/objects/NFTokenOffer.tsx | 8 +- .../TransactionLoaderModal.tsx | 15 +- .../Overlay/AddToken/AddTokenModal.tsx | 14 +- .../ExplainBalance/ExplainBalanceModal.tsx | 18 +- .../Overlay/TokenSettings/TokenSettings.tsx | 21 +- src/services/AccountService.ts | 57 ++- src/services/AppService.ts | 4 +- src/services/BackendService.ts | 11 +- src/services/LedgerService.ts | 357 ++++++++------- src/services/NetworkService.ts | 90 ++-- src/store/repositories/currency.ts | 6 +- tsconfig.json | 2 +- .../@veriff/react-native-sdk/index.d.ts | 0 .../react-native/index.d.ts | 0 .../rippled-ws-client/index.d.ts | 0 .../xaman-backend/index.d.ts | 0 .../xumm-string-decode/index.d.ts | 0 161 files changed, 5751 insertions(+), 1051 deletions(-) create mode 100644 src/common/libs/ledger/types/common/index.ts create mode 100644 src/common/libs/ledger/types/enums.ts create mode 100644 src/common/libs/ledger/types/ledger/AMM.ts create mode 100644 src/common/libs/ledger/types/ledger/AccountRoot.ts create mode 100644 src/common/libs/ledger/types/ledger/Amendments.ts create mode 100644 src/common/libs/ledger/types/ledger/BaseLedgerEntry.ts create mode 100644 src/common/libs/ledger/types/ledger/Check.ts create mode 100644 src/common/libs/ledger/types/ledger/DepositPreauth.ts create mode 100644 src/common/libs/ledger/types/ledger/DirectoryNode.ts create mode 100644 src/common/libs/ledger/types/ledger/Escrow.ts create mode 100644 src/common/libs/ledger/types/ledger/FeeSettings.ts create mode 100644 src/common/libs/ledger/types/ledger/Ledger.ts create mode 100644 src/common/libs/ledger/types/ledger/LedgerEntry.ts create mode 100644 src/common/libs/ledger/types/ledger/LedgerHashes.ts create mode 100644 src/common/libs/ledger/types/ledger/NFTokenOffer.ts create mode 100644 src/common/libs/ledger/types/ledger/NFTokenPage.ts create mode 100644 src/common/libs/ledger/types/ledger/NegativeUNL.ts create mode 100644 src/common/libs/ledger/types/ledger/Offer.ts create mode 100644 src/common/libs/ledger/types/ledger/PayChannel.ts create mode 100644 src/common/libs/ledger/types/ledger/RippleState.ts create mode 100644 src/common/libs/ledger/types/ledger/SignerList.ts create mode 100644 src/common/libs/ledger/types/ledger/Ticket.ts create mode 100644 src/common/libs/ledger/types/ledger/index.ts create mode 100644 src/common/libs/ledger/types/methods/accountChannels.ts create mode 100644 src/common/libs/ledger/types/methods/accountCurrencies.ts create mode 100644 src/common/libs/ledger/types/methods/accountInfo.ts create mode 100644 src/common/libs/ledger/types/methods/accountLines.ts create mode 100644 src/common/libs/ledger/types/methods/accountNFTs.ts create mode 100644 src/common/libs/ledger/types/methods/accountObjects.ts create mode 100644 src/common/libs/ledger/types/methods/accountOffers.ts create mode 100644 src/common/libs/ledger/types/methods/accountTx.ts create mode 100644 src/common/libs/ledger/types/methods/ammInfo.ts create mode 100644 src/common/libs/ledger/types/methods/baseMethod.ts create mode 100644 src/common/libs/ledger/types/methods/bookOffers.ts create mode 100644 src/common/libs/ledger/types/methods/channelVerify.ts create mode 100644 src/common/libs/ledger/types/methods/depositAuthorized.ts create mode 100644 src/common/libs/ledger/types/methods/fee.ts create mode 100644 src/common/libs/ledger/types/methods/gatewayBalances.ts create mode 100644 src/common/libs/ledger/types/methods/index.ts create mode 100644 src/common/libs/ledger/types/methods/ledger.ts create mode 100644 src/common/libs/ledger/types/methods/ledgerClosed.ts create mode 100644 src/common/libs/ledger/types/methods/ledgerCurrent.ts create mode 100644 src/common/libs/ledger/types/methods/ledgerData.ts create mode 100644 src/common/libs/ledger/types/methods/ledgerEntry.ts create mode 100644 src/common/libs/ledger/types/methods/manifest.ts create mode 100644 src/common/libs/ledger/types/methods/nftBuyOffers.ts create mode 100644 src/common/libs/ledger/types/methods/nftSellOffers.ts create mode 100644 src/common/libs/ledger/types/methods/norippleCheck.ts create mode 100644 src/common/libs/ledger/types/methods/pathFind.ts create mode 100644 src/common/libs/ledger/types/methods/ping.ts create mode 100644 src/common/libs/ledger/types/methods/random.ts create mode 100644 src/common/libs/ledger/types/methods/serverDefinitions.ts create mode 100644 src/common/libs/ledger/types/methods/serverInfo.ts create mode 100644 src/common/libs/ledger/types/methods/serverState.ts create mode 100644 src/common/libs/ledger/types/methods/submit.ts create mode 100644 src/common/libs/ledger/types/methods/submitMultisigned.ts create mode 100644 src/common/libs/ledger/types/methods/subscribe.ts create mode 100644 src/common/libs/ledger/types/methods/transactionEntry.ts create mode 100644 src/common/libs/ledger/types/methods/tx.ts create mode 100644 src/common/libs/ledger/types/methods/unsubscribe.ts create mode 100644 src/common/libs/ledger/types/transaction/common.ts create mode 100644 src/common/libs/ledger/types/transaction/index.ts create mode 100644 src/common/libs/ledger/types/transaction/metadata.ts rename {src/typings => typings}/@veriff/react-native-sdk/index.d.ts (100%) rename {src/typings => typings}/react-native/index.d.ts (100%) rename {src/typings => typings}/rippled-ws-client/index.d.ts (100%) rename {src/typings => typings}/xaman-backend/index.d.ts (100%) rename {src/typings => typings}/xumm-string-decode/index.d.ts (100%) diff --git a/src/common/helpers/resolver.ts b/src/common/helpers/resolver.ts index b6bdfa332..9ec150869 100644 --- a/src/common/helpers/resolver.ts +++ b/src/common/helpers/resolver.ts @@ -133,7 +133,7 @@ const getAccountInfo = (address: string): Promise => { const accountInfo = await LedgerService.getAccountInfo(address); // account doesn't exist, no need to check account risk - if (has(accountInfo, 'error')) { + if ('error' in accountInfo) { if (get(accountInfo, 'error') === 'actNotFound') { resolve(assign(info, { exist: false })); return; @@ -174,13 +174,14 @@ const getAccountInfo = (address: string): Promise => { assign(info, { requireDestinationTag: true, possibleExchange: true }); } else { // scan the most recent transactions of the account for the destination tags - const accountTXS = await LedgerService.getTransactions(address, undefined, 200); + const transactionsResp = await LedgerService.getTransactions(address, undefined, 200); if ( - typeof accountTXS.transactions !== 'undefined' && - accountTXS.transactions && - accountTXS.transactions.length > 0 + !('error' in transactionsResp) && + typeof transactionsResp.transactions !== 'undefined' && + transactionsResp.transactions && + transactionsResp.transactions.length > 0 ) { - const incomingTXS = accountTXS.transactions.filter((tx) => { + const incomingTXS = transactionsResp.transactions.filter((tx) => { return tx.tx.Destination === address; }); @@ -192,7 +193,7 @@ const getAccountInfo = (address: string): Promise => { ); }).length; - const senders = accountTXS.transactions.map((tx) => { + const senders = transactionsResp.transactions.map((tx) => { return tx.tx.Account || ''; }); diff --git a/src/common/libs/ledger/factory/explainer.ts b/src/common/libs/ledger/factory/explainer.ts index 73a14f68b..9bd9fe171 100644 --- a/src/common/libs/ledger/factory/explainer.ts +++ b/src/common/libs/ledger/factory/explainer.ts @@ -7,7 +7,7 @@ import * as PseudoTransactions from '@common/libs/ledger/transactions/pseudo'; import * as LedgerObjects from '@common/libs/ledger/objects'; /* Types ==================================================================== */ -import { LedgerObjectTypes, PseudoTransactionTypes, TransactionTypes } from '@common/libs/ledger/types'; +import { LedgerEntryTypes, PseudoTransactionTypes, TransactionTypes } from '@common/libs/ledger/types/enums'; import { PseudoTransactions as PseudoTransactionsType, @@ -25,7 +25,7 @@ type ExplainerType = { /* Module ==================================================================== */ const ExplainerFactory = { fromType: ( - type: TransactionTypes | PseudoTransactionTypes | LedgerObjectTypes, + type: TransactionTypes | PseudoTransactionTypes | LedgerEntryTypes, ): ExplainerType => { let explainer; @@ -39,7 +39,7 @@ const ExplainerFactory = { explainer = get(PseudoTransactions, `${type}Info`, undefined); break; // Ledger object - case type in LedgerObjectTypes: + case type in LedgerEntryTypes: explainer = get(LedgerObjects, `${type}Info`, undefined); break; default: diff --git a/src/common/libs/ledger/factory/object.ts b/src/common/libs/ledger/factory/object.ts index 889046658..9c00737f9 100644 --- a/src/common/libs/ledger/factory/object.ts +++ b/src/common/libs/ledger/factory/object.ts @@ -4,14 +4,14 @@ import * as LedgerObjects from '@common/libs/ledger/objects'; /* Types ==================================================================== */ import { LedgerObjects as LedgerObjectsType } from '@common/libs/ledger/objects/types'; -import { LedgerEntriesTypes } from '@common/libs/ledger/types'; +import { LedgerEntry } from '@common/libs/ledger/types/ledger'; /* Module ==================================================================== */ const LedgerObjectFactory = { /* Parse ledger entry to LedgerObject instance */ - fromLedger: (object: LedgerEntriesTypes): LedgerObjectsType => { + fromLedger: (object: LedgerEntry): LedgerObjectsType => { // get ledger entry type const type = get(object, 'LedgerEntryType'); diff --git a/src/common/libs/ledger/factory/transaction.ts b/src/common/libs/ledger/factory/transaction.ts index 0c969d9ba..3f227aa3f 100644 --- a/src/common/libs/ledger/factory/transaction.ts +++ b/src/common/libs/ledger/factory/transaction.ts @@ -4,12 +4,13 @@ import * as Transactions from '@common/libs/ledger/transactions/genuine'; import * as PseudoTransactions from '@common/libs/ledger/transactions/pseudo'; /* Types ==================================================================== */ -import { LedgerTransactionType, PseudoTransactionTypes, TransactionJSONType } from '@common/libs/ledger/types'; - import { Transactions as TransactionsType, PseudoTransactions as PseudoTransactionsType, } from '@common/libs/ledger/transactions/types'; +import { TransactionJson } from '@common/libs/ledger/types/transaction'; +import { PseudoTransactionTypes } from '@common/libs/ledger/types/enums'; +import { AccountTxTransaction } from '@common/libs/ledger/types/methods'; /* Module ==================================================================== */ const TransactionFactory = { @@ -17,12 +18,12 @@ const TransactionFactory = { * Returns a pseudo transaction based on the given type. * * @function - * @param {TransactionJSONType} json - The JSON representation of the transaction. + * @param {TransactionJson} json - The JSON representation of the transaction. * @param {PseudoTransactionTypes} type - The type of pseudo transaction to generate. * @returns {PseudoTransactionsType} Returns an instance of the appropriate pseudo transaction. * @throws {Error} Throws an error if the pseudo transaction type is unsupported. */ - getPseudoTransaction: (json: TransactionJSONType, type: PseudoTransactionTypes): PseudoTransactionsType => { + getPseudoTransaction: (json: TransactionJson, type: PseudoTransactionTypes): PseudoTransactionsType => { switch (type) { case PseudoTransactionTypes.SignIn: return new PseudoTransactions.SignIn(json); @@ -37,12 +38,12 @@ const TransactionFactory = { * Returns a transaction based on the given transaction JSON. * * @function - * @param {TransactionJSONType} transaction - The JSON representation of the transaction. + * @param {TransactionJson} transaction - The JSON representation of the transaction. * @param {any} [meta] - Optional metadata associated with the transaction. * @returns {TransactionsType} Returns an instance of the appropriate transaction. * @throws {Error} Throws an error if the transaction type is unsupported. */ - getTransaction: (transaction: TransactionJSONType, meta?: any): TransactionsType => { + getTransaction: (transaction: TransactionJson, meta?: any): TransactionsType => { // get the transaction type const type = get(transaction, 'TransactionType', undefined); // get transaction class @@ -59,11 +60,11 @@ const TransactionFactory = { * Parses a LEDGER transaction and returns a Transaction instance. * * @function - * @param {LedgerTransactionType} item - The ledger transaction to parse. + * @param {TransactionJson} item - The ledger transaction to parse. * @returns {TransactionsType} Returns an instance of the corresponding transaction. * @throws {Error} Throws an error if the provided item is not a valid Ledger transaction type. */ - fromLedger: (item: LedgerTransactionType): TransactionsType => { + fromLedger: (item: AccountTxTransaction): TransactionsType => { if (!has(item, 'tx') || !has(item, 'meta')) { throw new Error('Provided item is not a valid Ledger transaction type!'); } @@ -76,10 +77,10 @@ const TransactionFactory = { * Parses a JSON transaction and returns a Transaction instance. * * @function - * @param {TransactionJSONType} item - The JSON representation of the transaction to parse. + * @param {TransactionJson} item - The JSON representation of the transaction to parse. * @returns {TransactionsType} Returns an instance of the corresponding transaction. */ - fromJson: (item: TransactionJSONType): TransactionsType => { + fromJson: (item: TransactionJson): TransactionsType => { return TransactionFactory.getTransaction(item); }, }; diff --git a/src/common/libs/ledger/factory/validation.ts b/src/common/libs/ledger/factory/validation.ts index 8b5e3eeca..c82cf34a8 100644 --- a/src/common/libs/ledger/factory/validation.ts +++ b/src/common/libs/ledger/factory/validation.ts @@ -6,7 +6,7 @@ import * as Transactions from '@common/libs/ledger/transactions/genuine'; import * as PseudoTransactions from '@common/libs/ledger/transactions/pseudo'; /* Types ==================================================================== */ -import { PseudoTransactionTypes, TransactionTypes } from '@common/libs/ledger/types'; +import { PseudoTransactionTypes, TransactionTypes } from '@common/libs/ledger/types/enums'; import { Transactions as TransactionsType, diff --git a/src/common/libs/ledger/objects/BaseLedgerObject.ts b/src/common/libs/ledger/objects/BaseLedgerObject.ts index 266a75cda..dcac062ac 100644 --- a/src/common/libs/ledger/objects/BaseLedgerObject.ts +++ b/src/common/libs/ledger/objects/BaseLedgerObject.ts @@ -6,14 +6,13 @@ import { get, has, set, isUndefined } from 'lodash'; import { Account } from '@common/libs/ledger/parser/types'; import Flag from '@common/libs/ledger/parser/common/flag'; -/* Types ==================================================================== */ -import { LedgerEntriesTypes } from '@common/libs/ledger/types'; +import { LedgerEntry } from '@common/libs/ledger/types/ledger'; /* Class ==================================================================== */ class BaseLedgerObject { - protected object: LedgerEntriesTypes; + protected object: LedgerEntry; - constructor(object?: LedgerEntriesTypes) { + constructor(object?: LedgerEntry) { this.object = object; } diff --git a/src/common/libs/ledger/objects/Check/CheckClass.ts b/src/common/libs/ledger/objects/Check/CheckClass.ts index 3b26d941d..f96f8df95 100644 --- a/src/common/libs/ledger/objects/Check/CheckClass.ts +++ b/src/common/libs/ledger/objects/Check/CheckClass.ts @@ -10,11 +10,11 @@ import BaseLedgerObject from '@common/libs/ledger/objects/BaseLedgerObject'; /* Types ==================================================================== */ import { AmountType, Destination } from '@common/libs/ledger/parser/types'; -import { LedgerObjectTypes } from '@common/libs/ledger/types'; +import { LedgerEntryTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class Check extends BaseLedgerObject { - public static Type = LedgerObjectTypes.Check as const; + public static Type = LedgerEntryTypes.Check as const; public readonly Type = Check.Type; constructor(object?: any) { diff --git a/src/common/libs/ledger/objects/Escrow/EscrowClass.ts b/src/common/libs/ledger/objects/Escrow/EscrowClass.ts index 732ee2924..b9b920209 100644 --- a/src/common/libs/ledger/objects/Escrow/EscrowClass.ts +++ b/src/common/libs/ledger/objects/Escrow/EscrowClass.ts @@ -9,11 +9,11 @@ import LedgerDate from '@common/libs/ledger/parser/common/date'; /* Types ==================================================================== */ import { AmountType, Destination } from '@common/libs/ledger/parser/types'; -import { LedgerObjectTypes } from '@common/libs/ledger/types'; +import { LedgerEntryTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class Escrow extends BaseLedgerObject { - public static Type = LedgerObjectTypes.Escrow as const; + public static Type = LedgerEntryTypes.Escrow as const; public readonly Type = Escrow.Type; constructor(object?: any) { diff --git a/src/common/libs/ledger/objects/NFTokenOffer/NFTokenOfferClass.ts b/src/common/libs/ledger/objects/NFTokenOffer/NFTokenOfferClass.ts index 0c767e834..7651786dc 100644 --- a/src/common/libs/ledger/objects/NFTokenOffer/NFTokenOfferClass.ts +++ b/src/common/libs/ledger/objects/NFTokenOffer/NFTokenOfferClass.ts @@ -9,11 +9,11 @@ import BaseLedgerObject from '@common/libs/ledger/objects/BaseLedgerObject'; /* Types ==================================================================== */ import { AmountType, Destination } from '@common/libs/ledger/parser/types'; -import { LedgerObjectTypes } from '@common/libs/ledger/types'; +import { LedgerEntryTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class NFTokenOffer extends BaseLedgerObject { - public static Type = LedgerObjectTypes.NFTokenOffer as const; + public static Type = LedgerEntryTypes.NFTokenOffer as const; public readonly Type = NFTokenOffer.Type; constructor(object?: any) { diff --git a/src/common/libs/ledger/objects/Offer/OfferClass.ts b/src/common/libs/ledger/objects/Offer/OfferClass.ts index df2a19516..9ad0c8656 100644 --- a/src/common/libs/ledger/objects/Offer/OfferClass.ts +++ b/src/common/libs/ledger/objects/Offer/OfferClass.ts @@ -9,11 +9,11 @@ import BaseLedgerObject from '@common/libs/ledger/objects/BaseLedgerObject'; /* Types ==================================================================== */ import { AmountType } from '@common/libs/ledger/parser/types'; -import { LedgerObjectTypes } from '@common/libs/ledger/types'; +import { LedgerEntryTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class Offer extends BaseLedgerObject { - public static Type = LedgerObjectTypes.Offer as const; + public static Type = LedgerEntryTypes.Offer as const; public readonly Type = Offer.Type; constructor(object: any) { diff --git a/src/common/libs/ledger/objects/PayChannel/PayChannelClass.ts b/src/common/libs/ledger/objects/PayChannel/PayChannelClass.ts index 292f52e9f..31d0a4aa6 100644 --- a/src/common/libs/ledger/objects/PayChannel/PayChannelClass.ts +++ b/src/common/libs/ledger/objects/PayChannel/PayChannelClass.ts @@ -10,11 +10,11 @@ import BaseLedgerObject from '@common/libs/ledger/objects/BaseLedgerObject'; /* Types ==================================================================== */ import { AmountType, Destination } from '@common/libs/ledger/parser/types'; -import { LedgerObjectTypes } from '@common/libs/ledger/types'; +import { LedgerEntryTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class PayChannel extends BaseLedgerObject { - public static Type = LedgerObjectTypes.PayChannel as const; + public static Type = LedgerEntryTypes.PayChannel as const; public readonly Type = PayChannel.Type; constructor(object?: any) { diff --git a/src/common/libs/ledger/objects/Ticket/TicketClass.ts b/src/common/libs/ledger/objects/Ticket/TicketClass.ts index 3dddec3a8..7d399760f 100644 --- a/src/common/libs/ledger/objects/Ticket/TicketClass.ts +++ b/src/common/libs/ledger/objects/Ticket/TicketClass.ts @@ -3,11 +3,11 @@ import { get } from 'lodash'; import BaseLedgerObject from '@common/libs/ledger/objects/BaseLedgerObject'; /* Types ==================================================================== */ -import { LedgerObjectTypes } from '@common/libs/ledger/types'; +import { LedgerEntryTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class Ticket extends BaseLedgerObject { - public static Type = LedgerObjectTypes.Ticket as const; + public static Type = LedgerEntryTypes.Ticket as const; public readonly Type = Ticket.Type; constructor(object?: any) { diff --git a/src/common/libs/ledger/parser/common/flags/objectFlags.ts b/src/common/libs/ledger/parser/common/flags/objectFlags.ts index e9cc332ec..c9b49c0a5 100644 --- a/src/common/libs/ledger/parser/common/flags/objectFlags.ts +++ b/src/common/libs/ledger/parser/common/flags/objectFlags.ts @@ -8,6 +8,9 @@ const LedgerObjectFlags = { lsfLowNoRipple: 0x00100000, lsfHighNoRipple: 0x00200000, }, + SignerList: { + lsfOneOwnerCount: 0x00010000, + }, }; export { LedgerObjectFlags }; diff --git a/src/common/libs/ledger/parser/entry.ts b/src/common/libs/ledger/parser/entry.ts index 3d2f5e1c3..ce8058d07 100644 --- a/src/common/libs/ledger/parser/entry.ts +++ b/src/common/libs/ledger/parser/entry.ts @@ -1,7 +1,11 @@ -import { LedgerTrustline, RippleStateLedgerEntry } from '@common/libs/ledger/types'; import { LedgerObjectFlags } from '@common/libs/ledger/parser/common/flags/objectFlags'; -const RippleStateToTrustLine = (ledgerEntry: RippleStateLedgerEntry, account: string): LedgerTrustline => { +/* Types ==================================================================== */ +import { RippleState } from '@common/libs/ledger/types/ledger'; +import { AccountLinesTrustline } from '@common/libs/ledger/types/methods'; + +/* Parser ==================================================================== */ +const RippleStateToTrustLine = (ledgerEntry: RippleState, account: string): AccountLinesTrustline => { const parties = [ledgerEntry.HighLimit, ledgerEntry.LowLimit]; const [self, counterparty] = ledgerEntry.HighLimit.issuer === account ? parties : parties.reverse(); @@ -27,7 +31,9 @@ const RippleStateToTrustLine = (ledgerEntry: RippleStateLedgerEntry, account: st limit_peer: counterparty.value, no_ripple, no_ripple_peer, - } as LedgerTrustline; + quality_in: 0, + quality_out: 0, + }; }; export { RippleStateToTrustLine }; diff --git a/src/common/libs/ledger/parser/meta.ts b/src/common/libs/ledger/parser/meta.ts index 57de0459d..c0e1eae0c 100644 --- a/src/common/libs/ledger/parser/meta.ts +++ b/src/common/libs/ledger/parser/meta.ts @@ -6,7 +6,7 @@ import NetworkService from '@services/NetworkService'; /* Types ==================================================================== */ import { BalanceChangeType, OfferStatus, OwnerCountChangeType, OperationActions } from './types'; -import { HookExecution } from '../types'; +import { HookExecution } from '../types/common'; /* Class ==================================================================== */ class Meta { diff --git a/src/common/libs/ledger/parser/types.ts b/src/common/libs/ledger/parser/types.ts index 7b743cc28..3d191a7f6 100644 --- a/src/common/libs/ledger/parser/types.ts +++ b/src/common/libs/ledger/parser/types.ts @@ -1,7 +1,3 @@ -/** - * Meta data types - */ - export enum OperationActions { DEC, INC, @@ -21,6 +17,12 @@ export enum ClaimRewardStatus { OptOut = 'OptOut', } +export interface AmountType { + value: string; + currency: string; + issuer?: string; +} + export interface BalanceChangeType extends AmountType { action: OperationActions; } @@ -31,15 +33,6 @@ export interface OwnerCountChangeType { action: OperationActions; } -/** - * Ledger and transaction types - */ -export interface AmountType extends Issuer { - value: string; -} - -export type LedgerAmount = string | AmountType; - /** * Specification of which currency the account taking the offer would pay/ * receive, as an object with currency and issuer fields (omit issuer for native asset). @@ -50,34 +43,6 @@ export interface TakerRequestAmount { issuer?: string; } -/** - * A currency-counterparty pair, or just currency if it's native currency. - */ -export interface Issuer { - currency: string; - issuer?: string; - counterparty?: string; -} - -/** - * Trustline Transaction schema from rippled - */ -export interface Trustline { - account: string; - balance: string; - currency: string; - limit: string; - limit_peer: string; - quality_in: number; - quality_out: number; - no_ripple?: boolean; - no_ripple_peer?: boolean; - freeze?: boolean; - freeze_peer?: boolean; - authorized?: boolean; - peer_authorized?: boolean; -} - /** * Transaction Memo format */ diff --git a/src/common/libs/ledger/pathFinding.ts b/src/common/libs/ledger/pathFinding.ts index 6e8fd8b53..ae5ae5d36 100644 --- a/src/common/libs/ledger/pathFinding.ts +++ b/src/common/libs/ledger/pathFinding.ts @@ -1,15 +1,14 @@ /* synchronous path_finding */ - import EventEmitter from 'events'; import { flatMap } from 'lodash'; import { v4 as uuidv4 } from 'uuid'; import { NetworkService } from '@services'; -import { PathOption, RipplePathFindResponse } from '@common/libs/ledger/types'; -import { LedgerAmount } from '@common/libs/ledger/parser/types'; +import { PathFindPathOption, PathFindRequest, PathFindResponse } from '@common/libs/ledger/types/methods'; +import { AmountType } from '@common/libs/ledger/parser/types'; /* Types ==================================================================== */ declare interface LedgerPathFinding { @@ -19,11 +18,11 @@ declare interface LedgerPathFinding { } type PaymentOptions = { - [key: string]: PathOption; + [key: string]: PathFindPathOption; }; type RequestPromise = { - resolver: (value: PathOption[] | PromiseLike) => void; + resolver: (value: PathFindPathOption[] | PromiseLike) => void; rejecter: (reason?: any) => void; }; @@ -51,7 +50,11 @@ class LedgerPathFinding extends EventEmitter { this.paymentOptions = {}; } - private handlePathFindEvent = (result: { alternatives: PathOption[]; id: string; full_reply?: boolean }) => { + private handlePathFindEvent = (result: { + alternatives: PathFindPathOption[]; + id: string; + full_reply?: boolean; + }) => { const { id, alternatives, full_reply } = result; if (!alternatives) { @@ -77,7 +80,7 @@ class LedgerPathFinding extends EventEmitter { NetworkService.offEvent('path', this.handlePathFindEvent); }; - private handlePathOptions = (options: PathOption[], shouldResolve?: boolean) => { + private handlePathOptions = (options: PathFindPathOption[], shouldResolve?: boolean) => { options.forEach((option) => { const { source_amount } = option; @@ -135,31 +138,37 @@ class LedgerPathFinding extends EventEmitter { }, RESOLVE_AFTER_SECS); }; - request = (amount: LedgerAmount, source: string, destination: string): Promise => { + request = (amount: AmountType, source: string, destination: string): Promise => { return new Promise((resolve, reject) => { // generate request id this.requestId = uuidv4(); // send socket request - NetworkService.send({ + NetworkService.send({ id: this.requestId, command: 'path_find', subcommand: 'create', source_account: source, destination_account: destination, destination_amount: amount, - }) - .then((response: RipplePathFindResponse) => { - const { id, result, error } = response; + } as PathFindRequest) + .then((response) => { + if ('error' in response) { + reject(response.error); + return; + } - // request is canceled - if (id !== this.requestId) { - reject(new Error('Request has been canceled and invalidated')); + const { id, result } = response; + + // no result + if (!result) { + reject(new Error('Request returned empty result')); return; } - if (error || !result) { - reject(error); + // request is canceled + if (id !== this.requestId) { + reject(new Error('Request has been canceled and invalidated')); return; } @@ -179,8 +188,8 @@ class LedgerPathFinding extends EventEmitter { // wait for result from event and resolve after couple of seconds this.startResolveTimeout(); }) - .catch((e: any) => { - reject(e); + .catch((error: Error) => { + reject(error); }); }); }; @@ -208,7 +217,7 @@ class LedgerPathFinding extends EventEmitter { this.unsubscribePathFind(); // close the request - NetworkService.send({ + NetworkService.send({ id: this.requestId, command: 'path_find', subcommand: 'close', diff --git a/src/common/libs/ledger/transactions/genuine/AccountDelete/AccountDeleteClass.ts b/src/common/libs/ledger/transactions/genuine/AccountDelete/AccountDeleteClass.ts index 8003f2e10..e8c5908b7 100644 --- a/src/common/libs/ledger/transactions/genuine/AccountDelete/AccountDeleteClass.ts +++ b/src/common/libs/ledger/transactions/genuine/AccountDelete/AccountDeleteClass.ts @@ -8,14 +8,15 @@ import { Destination, AmountType } from '@common/libs/ledger/parser/types'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class AccountDelete extends BaseTransaction { public static Type = TransactionTypes.AccountDelete as const; public readonly Type = AccountDelete.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: any) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/AccountDelete/AccountDeleteValidation.ts b/src/common/libs/ledger/transactions/genuine/AccountDelete/AccountDeleteValidation.ts index 88de19480..980cf4eb7 100644 --- a/src/common/libs/ledger/transactions/genuine/AccountDelete/AccountDeleteValidation.ts +++ b/src/common/libs/ledger/transactions/genuine/AccountDelete/AccountDeleteValidation.ts @@ -1,5 +1,3 @@ -import { has } from 'lodash'; - import LedgerService from '@services/LedgerService'; import Localize from '@locale'; @@ -56,14 +54,14 @@ const AccountDeleteValidation = (tx: AccountDelete): Promise => { // check if destination exist or required destination tag flag is set try { - const destinationAccountInfo = await LedgerService.getAccountInfo(tx.Destination.address); + const resp = await LedgerService.getAccountInfo(tx.Destination.address); - if (!destinationAccountInfo || has(destinationAccountInfo, 'error')) { + if ('error' in resp) { reject(new Error(Localize.t('account.destinationAccountIsNotActivated'))); return; } - const { account_flags } = destinationAccountInfo; + const { account_flags } = resp; if (account_flags?.requireDestinationTag && tx.Destination.tag === undefined) { reject(new Error(Localize.t('account.destinationAddressRequiredDestinationTag'))); diff --git a/src/common/libs/ledger/transactions/genuine/AccountSet/AccountSetClass.ts b/src/common/libs/ledger/transactions/genuine/AccountSet/AccountSetClass.ts index f5d1f73c7..2635bcef4 100644 --- a/src/common/libs/ledger/transactions/genuine/AccountSet/AccountSetClass.ts +++ b/src/common/libs/ledger/transactions/genuine/AccountSet/AccountSetClass.ts @@ -12,14 +12,15 @@ import Flag from '@common/libs/ledger/parser/common/flag'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class AccountSet extends BaseTransaction { public static Type = TransactionTypes.AccountSet as const; public readonly Type = AccountSet.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/BaseTransaction.ts b/src/common/libs/ledger/transactions/genuine/BaseTransaction.ts index 31e45e5df..185fb42f3 100644 --- a/src/common/libs/ledger/transactions/genuine/BaseTransaction.ts +++ b/src/common/libs/ledger/transactions/genuine/BaseTransaction.ts @@ -15,14 +15,9 @@ import { AppScreens } from '@common/constants'; import { Navigator } from '@common/helpers/navigator'; import { EncodeCTID } from '@common/utils/codec'; +import { StringTypeCheck } from '@common/utils/string'; -import { - SignedObjectType, - SubmitResultType, - TransactionJSONType, - TransactionTypes, - VerifyResultType, -} from '@common/libs/ledger/types'; +import { SignedObjectType, SubmitResultType, VerifyResultType } from '@common/libs/ledger/types'; import Meta from '@common/libs/ledger/parser/meta'; import LedgerDate from '@common/libs/ledger/parser/common/date'; @@ -39,12 +34,13 @@ import { Signer, TransactionResult, } from '@common/libs/ledger/parser/types'; -import { StringTypeCheck } from '@common/utils/string'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class BaseTransaction { - protected tx: TransactionJSONType; - protected meta: any; + protected tx: TransactionJson; + protected meta: TransactionMetadata; protected fields: string[]; private submitResult?: SubmitResultType; @@ -61,13 +57,10 @@ class BaseTransaction { public SignMethod: 'PIN' | 'BIOMETRIC' | 'PASSPHRASE' | 'TANGEM' | 'OTHER'; public SignerAccount: any; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { if (!isUndefined(tx)) { this.tx = tx; this.meta = meta; - } else { - this.tx = {}; - this.meta = {}; } this.fields = [ @@ -625,7 +618,7 @@ class BaseTransaction { } // serialize transaction object to rippled tx json - get Json(): TransactionJSONType { + get Json(): TransactionJson { // shallow copy const tx = { ...this.tx }; Object.getOwnPropertyNames(this.tx).forEach((k: string) => { @@ -674,7 +667,8 @@ class BaseTransaction { } get Signers(): Array { - const signers = get(this, ['tx', 'Signers']) as any; + const signers = get(this, ['tx', 'Signers']); + return flatMap(signers, (item) => { return { account: item.Signer.Account, diff --git a/src/common/libs/ledger/transactions/genuine/CheckCancel/CheckCancelClass.ts b/src/common/libs/ledger/transactions/genuine/CheckCancel/CheckCancelClass.ts index 365b0d38e..a0a31b31a 100644 --- a/src/common/libs/ledger/transactions/genuine/CheckCancel/CheckCancelClass.ts +++ b/src/common/libs/ledger/transactions/genuine/CheckCancel/CheckCancelClass.ts @@ -1,19 +1,19 @@ import moment from 'moment-timezone'; - import { set, get, isUndefined } from 'lodash'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; import { CheckCreate } from '@common/libs/ledger/transactions/genuine/CheckCreate'; /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class CheckCancel extends BaseTransaction { public static Type = TransactionTypes.CheckCancel as const; public readonly Type = CheckCancel.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/CheckCash/CheckCashClass.ts b/src/common/libs/ledger/transactions/genuine/CheckCash/CheckCashClass.ts index e23b75da9..e40bcc503 100644 --- a/src/common/libs/ledger/transactions/genuine/CheckCash/CheckCashClass.ts +++ b/src/common/libs/ledger/transactions/genuine/CheckCash/CheckCashClass.ts @@ -10,14 +10,15 @@ import Amount from '@common/libs/ledger/parser/common/amount'; /* Types ==================================================================== */ import { AmountType } from '@common/libs/ledger/parser/types'; -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class CheckCash extends BaseTransaction { public static Type = TransactionTypes.CheckCash as const; public readonly Type = CheckCash.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/CheckCreate/CheckCreateClass.ts b/src/common/libs/ledger/transactions/genuine/CheckCreate/CheckCreateClass.ts index a1aa25dc5..21db000d6 100644 --- a/src/common/libs/ledger/transactions/genuine/CheckCreate/CheckCreateClass.ts +++ b/src/common/libs/ledger/transactions/genuine/CheckCreate/CheckCreateClass.ts @@ -10,14 +10,15 @@ import LedgerDate from '@common/libs/ledger/parser/common/date'; /* Types ==================================================================== */ import { AmountType, Destination } from '@common/libs/ledger/parser/types'; -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class CheckCreate extends BaseTransaction { public static Type = TransactionTypes.CheckCreate as const; public readonly Type = CheckCreate.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/CheckCreate/CheckCreateValidation.ts b/src/common/libs/ledger/transactions/genuine/CheckCreate/CheckCreateValidation.ts index 39fa54686..329913a3d 100644 --- a/src/common/libs/ledger/transactions/genuine/CheckCreate/CheckCreateValidation.ts +++ b/src/common/libs/ledger/transactions/genuine/CheckCreate/CheckCreateValidation.ts @@ -43,7 +43,10 @@ const CheckCreateValidation = (tx: CheckCreate): Promise => { } } else { // get TrustLine from ledger - const line = await LedgerService.getFilteredAccountLine(tx.Account.address, tx.SendMax); + const line = await LedgerService.getFilteredAccountLine(tx.Account.address, { + issuer: tx.SendMax.issuer, + currency: tx.SendMax.currency, + }); // check if line exist if (line && Number(tx.SendMax.value) > Number(line.balance)) { diff --git a/src/common/libs/ledger/transactions/genuine/ClaimReward/ClaimRewardClass.ts b/src/common/libs/ledger/transactions/genuine/ClaimReward/ClaimRewardClass.ts index 14d3b1fb5..9b32964d1 100644 --- a/src/common/libs/ledger/transactions/genuine/ClaimReward/ClaimRewardClass.ts +++ b/src/common/libs/ledger/transactions/genuine/ClaimReward/ClaimRewardClass.ts @@ -3,17 +3,16 @@ import { get, isUndefined } from 'lodash'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; import { ClaimRewardStatus } from '@common/libs/ledger/parser/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class ClaimReward extends BaseTransaction { public static Type = TransactionTypes.ClaimReward as const; public readonly Type = ClaimReward.Type; - private cachedClaimStatus: ClaimRewardStatus | undefined; - - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/DepositPreauth/DepositPreauthClass.ts b/src/common/libs/ledger/transactions/genuine/DepositPreauth/DepositPreauthClass.ts index 13069e0cc..c4efefb0a 100644 --- a/src/common/libs/ledger/transactions/genuine/DepositPreauth/DepositPreauthClass.ts +++ b/src/common/libs/ledger/transactions/genuine/DepositPreauth/DepositPreauthClass.ts @@ -3,14 +3,15 @@ import { get, isUndefined } from 'lodash'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class DepositPreauth extends BaseTransaction { public static Type = TransactionTypes.DepositPreauth as const; public readonly Type = DepositPreauth.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/EnableAmendment/EnableAmendmentClass.ts b/src/common/libs/ledger/transactions/genuine/EnableAmendment/EnableAmendmentClass.ts index 73ec8afc3..f3ef1f22b 100644 --- a/src/common/libs/ledger/transactions/genuine/EnableAmendment/EnableAmendmentClass.ts +++ b/src/common/libs/ledger/transactions/genuine/EnableAmendment/EnableAmendmentClass.ts @@ -1,15 +1,17 @@ +import { get } from 'lodash'; + import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; -import { get } from 'lodash'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class EnableAmendment extends BaseTransaction { public static Type = TransactionTypes.EnableAmendment as const; public readonly Type = EnableAmendment.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); this.fields = this.fields.concat(['Amendment']); diff --git a/src/common/libs/ledger/transactions/genuine/EscrowCancel/EscrowCancelClass.ts b/src/common/libs/ledger/transactions/genuine/EscrowCancel/EscrowCancelClass.ts index 04b9e9ade..d4d73abf3 100644 --- a/src/common/libs/ledger/transactions/genuine/EscrowCancel/EscrowCancelClass.ts +++ b/src/common/libs/ledger/transactions/genuine/EscrowCancel/EscrowCancelClass.ts @@ -3,14 +3,15 @@ import { set, get, isUndefined } from 'lodash'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class EscrowCancel extends BaseTransaction { public static Type = TransactionTypes.EscrowCancel as const; public readonly Type = EscrowCancel.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/EscrowCreate/EscrowCreateClass.ts b/src/common/libs/ledger/transactions/genuine/EscrowCreate/EscrowCreateClass.ts index e4640cec4..34bb93111 100644 --- a/src/common/libs/ledger/transactions/genuine/EscrowCreate/EscrowCreateClass.ts +++ b/src/common/libs/ledger/transactions/genuine/EscrowCreate/EscrowCreateClass.ts @@ -1,5 +1,5 @@ import { has, get, set, isUndefined, isNumber, toInteger } from 'lodash'; -import * as AccountLib from 'xrpl-accountlib'; +import { utils as AccountLibUtils } from 'xrpl-accountlib'; import NetworkService from '@services/NetworkService'; @@ -10,14 +10,15 @@ import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransa /* Types ==================================================================== */ import { AmountType, Destination } from '@common/libs/ledger/parser/types'; -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class EscrowCreate extends BaseTransaction { public static Type = TransactionTypes.EscrowCreate as const; public readonly Type = EscrowCreate.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set @@ -68,7 +69,7 @@ class EscrowCreate extends BaseTransaction { set Destination(destination: Destination) { if (has(destination, 'address')) { - if (!AccountLib.utils.isValidAddress(destination.address)) { + if (!AccountLibUtils.isValidAddress(destination.address)) { throw new Error(`${destination.address} is not a valid Address`); } set(this, 'tx.Destination', destination.address); diff --git a/src/common/libs/ledger/transactions/genuine/EscrowFinish/EscrowFinishClass.ts b/src/common/libs/ledger/transactions/genuine/EscrowFinish/EscrowFinishClass.ts index d08547a5f..f6389573c 100644 --- a/src/common/libs/ledger/transactions/genuine/EscrowFinish/EscrowFinishClass.ts +++ b/src/common/libs/ledger/transactions/genuine/EscrowFinish/EscrowFinishClass.ts @@ -8,14 +8,15 @@ import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransa /* Types ==================================================================== */ import { AmountType, Destination } from '@common/libs/ledger/parser/types'; -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class EscrowFinish extends BaseTransaction { public static Type = TransactionTypes.EscrowFinish as const; public readonly Type = EscrowFinish.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/GenesisMint/GenesisMintClass.ts b/src/common/libs/ledger/transactions/genuine/GenesisMint/GenesisMintClass.ts index ad00ed7b3..33cb4a17e 100644 --- a/src/common/libs/ledger/transactions/genuine/GenesisMint/GenesisMintClass.ts +++ b/src/common/libs/ledger/transactions/genuine/GenesisMint/GenesisMintClass.ts @@ -2,14 +2,15 @@ import { get } from 'lodash'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ -import { TransactionTypes, TransactionJSONType } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class GenesisMint extends BaseTransaction { public static Type = TransactionTypes.GenesisMint as const; public readonly Type = GenesisMint.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); this.fields = this.fields.concat(['GenesisMints']); diff --git a/src/common/libs/ledger/transactions/genuine/Import/ImportClass.ts b/src/common/libs/ledger/transactions/genuine/Import/ImportClass.ts index be3ed8abb..288ac0407 100644 --- a/src/common/libs/ledger/transactions/genuine/Import/ImportClass.ts +++ b/src/common/libs/ledger/transactions/genuine/Import/ImportClass.ts @@ -3,14 +3,15 @@ import { get, isUndefined } from 'lodash'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class Import extends BaseTransaction { public static Type = TransactionTypes.Import as const; public readonly Type = Import.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/Invoke/InvokeClass.ts b/src/common/libs/ledger/transactions/genuine/Invoke/InvokeClass.ts index 6dcbfce69..6db88bf9c 100644 --- a/src/common/libs/ledger/transactions/genuine/Invoke/InvokeClass.ts +++ b/src/common/libs/ledger/transactions/genuine/Invoke/InvokeClass.ts @@ -4,14 +4,15 @@ import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransa /* Types ==================================================================== */ import { Destination } from '@common/libs/ledger/parser/types'; -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class Invoke extends BaseTransaction { public static Type = TransactionTypes.Invoke as const; public readonly Type = Invoke.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/NFTokenAcceptOffer/NFTokenAcceptOfferClass.ts b/src/common/libs/ledger/transactions/genuine/NFTokenAcceptOffer/NFTokenAcceptOfferClass.ts index c39f2d6a1..8ab9ce50a 100644 --- a/src/common/libs/ledger/transactions/genuine/NFTokenAcceptOffer/NFTokenAcceptOfferClass.ts +++ b/src/common/libs/ledger/transactions/genuine/NFTokenAcceptOffer/NFTokenAcceptOfferClass.ts @@ -9,14 +9,15 @@ import { NFTokenCreateOffer } from '@common/libs/ledger/transactions/genuine/NFT /* Types ==================================================================== */ import { AmountType } from '@common/libs/ledger/parser/types'; -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class NFTokenAcceptOffer extends BaseTransaction { public static Type = TransactionTypes.NFTokenAcceptOffer as const; public readonly Type = NFTokenAcceptOffer.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set @@ -61,9 +62,7 @@ class NFTokenAcceptOffer extends BaseTransaction { } get NFTokenBrokerFee(): AmountType { - let brokerFee = undefined as AmountType; - - brokerFee = get(this, ['tx', 'NFTokenBrokerFee']); + const brokerFee = get(this, ['tx', 'NFTokenBrokerFee']); if (isUndefined(brokerFee)) return undefined; diff --git a/src/common/libs/ledger/transactions/genuine/NFTokenBurn/NFTokenBurnClass.ts b/src/common/libs/ledger/transactions/genuine/NFTokenBurn/NFTokenBurnClass.ts index b4bfb9d2a..ac74099bc 100644 --- a/src/common/libs/ledger/transactions/genuine/NFTokenBurn/NFTokenBurnClass.ts +++ b/src/common/libs/ledger/transactions/genuine/NFTokenBurn/NFTokenBurnClass.ts @@ -3,14 +3,15 @@ import { get, isUndefined } from 'lodash'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class NFTokenBurn extends BaseTransaction { public static Type = TransactionTypes.NFTokenBurn as const; public readonly Type = NFTokenBurn.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: any) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/NFTokenCancelOffer/NFTokenCancelOfferClass.ts b/src/common/libs/ledger/transactions/genuine/NFTokenCancelOffer/NFTokenCancelOfferClass.ts index ff1a9ea01..7e0b973ce 100644 --- a/src/common/libs/ledger/transactions/genuine/NFTokenCancelOffer/NFTokenCancelOfferClass.ts +++ b/src/common/libs/ledger/transactions/genuine/NFTokenCancelOffer/NFTokenCancelOfferClass.ts @@ -3,15 +3,15 @@ import { get, isUndefined } from 'lodash'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; -/* Class ==================================================================== */ /* Class ==================================================================== */ class NFTokenCancelOffer extends BaseTransaction { public static Type = TransactionTypes.NFTokenCancelOffer as const; public readonly Type = NFTokenCancelOffer.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/NFTokenCreateOffer/NFTokenCreateOfferClass.ts b/src/common/libs/ledger/transactions/genuine/NFTokenCreateOffer/NFTokenCreateOfferClass.ts index 502bc9e4b..fe3004038 100644 --- a/src/common/libs/ledger/transactions/genuine/NFTokenCreateOffer/NFTokenCreateOfferClass.ts +++ b/src/common/libs/ledger/transactions/genuine/NFTokenCreateOffer/NFTokenCreateOfferClass.ts @@ -9,14 +9,15 @@ import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransa /* Types ==================================================================== */ import { Destination, AmountType } from '@common/libs/ledger/parser/types'; -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class NFTokenCreateOffer extends BaseTransaction { public static Type = TransactionTypes.NFTokenCreateOffer as const; public readonly Type = NFTokenCreateOffer.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set @@ -27,11 +28,8 @@ class NFTokenCreateOffer extends BaseTransaction { this.fields = this.fields.concat(['Amount', 'Destination', 'Expiration', 'Owner', 'NFTokenID']); } - // @ts-ignore get Amount(): AmountType { - let amount = undefined as AmountType; - - amount = get(this, ['tx', 'Amount']); + const amount = get(this, ['tx', 'Amount']); if (isUndefined(amount)) return undefined; diff --git a/src/common/libs/ledger/transactions/genuine/NFTokenMint/NFTokenMintClass.ts b/src/common/libs/ledger/transactions/genuine/NFTokenMint/NFTokenMintClass.ts index 4aff6be6e..a372938cc 100644 --- a/src/common/libs/ledger/transactions/genuine/NFTokenMint/NFTokenMintClass.ts +++ b/src/common/libs/ledger/transactions/genuine/NFTokenMint/NFTokenMintClass.ts @@ -7,14 +7,15 @@ import { EncodeNFTokenID } from '@common/utils/codec'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class NFTokenMint extends BaseTransaction { public static Type = TransactionTypes.NFTokenMint as const; public readonly Type = NFTokenMint.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/OfferCancel/OfferCancelClass.ts b/src/common/libs/ledger/transactions/genuine/OfferCancel/OfferCancelClass.ts index d9037e548..1e39eff6b 100644 --- a/src/common/libs/ledger/transactions/genuine/OfferCancel/OfferCancelClass.ts +++ b/src/common/libs/ledger/transactions/genuine/OfferCancel/OfferCancelClass.ts @@ -4,14 +4,15 @@ import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransa /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class OfferCancel extends BaseTransaction { public static Type = TransactionTypes.OfferCancel as const; public readonly Type = OfferCancel.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/OfferCreate/OfferCreateClass.ts b/src/common/libs/ledger/transactions/genuine/OfferCreate/OfferCreateClass.ts index 3d6cb4ddc..12975522e 100644 --- a/src/common/libs/ledger/transactions/genuine/OfferCreate/OfferCreateClass.ts +++ b/src/common/libs/ledger/transactions/genuine/OfferCreate/OfferCreateClass.ts @@ -6,12 +6,14 @@ import Amount from '@common/libs/ledger/parser/common/amount'; import LedgerDate from '@common/libs/ledger/parser/common/date'; import Meta from '@common/libs/ledger/parser/meta'; +import { EncodeLedgerIndex } from '@common/utils/codec'; + import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ import { OfferStatus, AmountType } from '@common/libs/ledger/parser/types'; -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; -import { EncodeLedgerIndex } from '@common/utils/codec'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class OfferCreate extends BaseTransaction { @@ -20,7 +22,7 @@ class OfferCreate extends BaseTransaction { private offerStatus: OfferStatus; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/Payment/PaymentClass.ts b/src/common/libs/ledger/transactions/genuine/Payment/PaymentClass.ts index d0b848b0f..4ef32e79e 100644 --- a/src/common/libs/ledger/transactions/genuine/Payment/PaymentClass.ts +++ b/src/common/libs/ledger/transactions/genuine/Payment/PaymentClass.ts @@ -8,15 +8,16 @@ import Amount from '@common/libs/ledger/parser/common/amount'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ -import { LedgerAmount, Destination, AmountType } from '@common/libs/ledger/parser/types'; -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { Destination, AmountType } from '@common/libs/ledger/parser/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class Payment extends BaseTransaction { public static Type = TransactionTypes.Payment as const; public readonly Type = Payment.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set @@ -71,7 +72,7 @@ class Payment extends BaseTransaction { } get DeliveredAmount(): AmountType { - let deliveredAmount = undefined as AmountType; + let deliveredAmount: any | 'unavailable'; if (has(this, ['meta', 'DeliveredAmount'])) { deliveredAmount = get(this, ['meta', 'DeliveredAmount']); @@ -80,8 +81,7 @@ class Payment extends BaseTransaction { } // the delivered_amount will be unavailable in old transactions - // @ts-ignore - if (deliveredAmount === 'unavailable') { + if (deliveredAmount === 'unavailable' || deliveredAmount === null) { deliveredAmount = undefined; } @@ -101,11 +101,8 @@ class Payment extends BaseTransaction { }; } - // @ts-ignore get Amount(): AmountType { - let amount = undefined as AmountType; - - amount = get(this, ['tx', 'Amount']); + const amount = get(this, ['tx', 'Amount']); if (isUndefined(amount)) return undefined; @@ -123,8 +120,7 @@ class Payment extends BaseTransaction { }; } - // @ts-ignore - set Amount(input: LedgerAmount) { + set Amount(input: AmountType | string) { // native currency if (typeof input === 'string') { set(this, 'tx.Amount', new Amount(input, false).nativeToDrops()); @@ -161,11 +157,12 @@ class Payment extends BaseTransaction { }; } - set SendMax(input: LedgerAmount) { + set SendMax(input: AmountType | string) { if (typeof input === 'undefined') { set(this, 'tx.SendMax', undefined); return; } + // native currency if (typeof input === 'string') { set(this, 'tx.SendMax', new Amount(input, false).nativeToDrops()); @@ -180,7 +177,7 @@ class Payment extends BaseTransaction { } } - set DeliverMin(input: AmountType | undefined) { + set DeliverMin(input: AmountType | string) { if (typeof input === 'undefined') { set(this, 'tx.DeliverMin', undefined); return; diff --git a/src/common/libs/ledger/transactions/genuine/Payment/PaymentValidation.ts b/src/common/libs/ledger/transactions/genuine/Payment/PaymentValidation.ts index e19d8428d..2833121d6 100644 --- a/src/common/libs/ledger/transactions/genuine/Payment/PaymentValidation.ts +++ b/src/common/libs/ledger/transactions/genuine/Payment/PaymentValidation.ts @@ -29,7 +29,10 @@ const PaymentValidation = (tx: Payment): Promise => { // ===== check if recipient have proper TrustLine when delivering IOU ===== // Note: ignore if sending to the issuer if (tx.Amount.currency !== NetworkService.getNativeAsset() && tx.Amount.issuer !== tx.Destination.address) { - const destinationLine = await LedgerService.getFilteredAccountLine(tx.Destination.address, tx.Amount); + const destinationLine = await LedgerService.getFilteredAccountLine(tx.Destination.address, { + issuer: tx.Amount.issuer, + currency: tx.Amount.currency, + }); if ( !destinationLine || @@ -86,7 +89,10 @@ const PaymentValidation = (tx: Payment): Promise => { // sender is not issuer if (IOUAmount.issuer !== tx.Account.address) { // check IOU balance - const sourceLine = await LedgerService.getFilteredAccountLine(tx.Account.address, IOUAmount); + const sourceLine = await LedgerService.getFilteredAccountLine(tx.Account.address, { + issuer: IOUAmount.issuer, + currency: IOUAmount.currency, + }); // TODO: show proper error message if (!sourceLine) { diff --git a/src/common/libs/ledger/transactions/genuine/PaymentChannelClaim/PaymentChannelClaimClass.ts b/src/common/libs/ledger/transactions/genuine/PaymentChannelClaim/PaymentChannelClaimClass.ts index ec5aa5ac2..fe760e6d6 100644 --- a/src/common/libs/ledger/transactions/genuine/PaymentChannelClaim/PaymentChannelClaimClass.ts +++ b/src/common/libs/ledger/transactions/genuine/PaymentChannelClaim/PaymentChannelClaimClass.ts @@ -8,14 +8,15 @@ import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransa /* Types ==================================================================== */ import { AmountType } from '@common/libs/ledger/parser/types'; -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class PaymentChannelClaim extends BaseTransaction { public static Type = TransactionTypes.PaymentChannelClaim as const; public readonly Type = PaymentChannelClaim.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/PaymentChannelCreate/PaymentChannelCreateClass.ts b/src/common/libs/ledger/transactions/genuine/PaymentChannelCreate/PaymentChannelCreateClass.ts index 2fa738c23..f2837ab81 100644 --- a/src/common/libs/ledger/transactions/genuine/PaymentChannelCreate/PaymentChannelCreateClass.ts +++ b/src/common/libs/ledger/transactions/genuine/PaymentChannelCreate/PaymentChannelCreateClass.ts @@ -9,14 +9,15 @@ import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransa /* Types ==================================================================== */ import { Destination, AmountType } from '@common/libs/ledger/parser/types'; -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class PaymentChannelCreate extends BaseTransaction { public static Type = TransactionTypes.PaymentChannelCreate as const; public readonly Type = PaymentChannelCreate.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/PaymentChannelCreate/PaymentChannelCreateInfo.ts b/src/common/libs/ledger/transactions/genuine/PaymentChannelCreate/PaymentChannelCreateInfo.ts index f7d6a72d1..7ae240910 100644 --- a/src/common/libs/ledger/transactions/genuine/PaymentChannelCreate/PaymentChannelCreateInfo.ts +++ b/src/common/libs/ledger/transactions/genuine/PaymentChannelCreate/PaymentChannelCreateInfo.ts @@ -5,7 +5,7 @@ import Localize from '@locale'; import { AccountModel } from '@store/models'; -import { LedgerObjectTypes, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionTypes, LedgerEntryTypes } from '@common/libs/ledger/types/enums'; import PaymentChannelCreate from './PaymentChannelCreateClass'; @@ -32,7 +32,7 @@ const PaymentChannelCreateInfo = { content += Localize.t('events.theChannelIdIs', { // @ts-ignore - channel: tx.Type === LedgerObjectTypes.PayChannel ? tx.Index : tx.ChannelID, + channel: tx.Type === LedgerEntryTypes.PayChannel ? tx.Index : tx.ChannelID, }); content += '\n'; diff --git a/src/common/libs/ledger/transactions/genuine/PaymentChannelFund/PaymentChannelFundClass.ts b/src/common/libs/ledger/transactions/genuine/PaymentChannelFund/PaymentChannelFundClass.ts index 824294c14..1d3fb4f39 100644 --- a/src/common/libs/ledger/transactions/genuine/PaymentChannelFund/PaymentChannelFundClass.ts +++ b/src/common/libs/ledger/transactions/genuine/PaymentChannelFund/PaymentChannelFundClass.ts @@ -9,14 +9,15 @@ import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransa /* Types ==================================================================== */ import { AmountType } from '@common/libs/ledger/parser/types'; -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class PaymentChannelFund extends BaseTransaction { public static Type = TransactionTypes.PaymentChannelFund as const; public readonly Type = PaymentChannelFund.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/SetHook/SetHookClass.ts b/src/common/libs/ledger/transactions/genuine/SetHook/SetHookClass.ts index 6986cb87f..2ba8b9f6d 100644 --- a/src/common/libs/ledger/transactions/genuine/SetHook/SetHookClass.ts +++ b/src/common/libs/ledger/transactions/genuine/SetHook/SetHookClass.ts @@ -3,14 +3,15 @@ import { get, isUndefined } from 'lodash'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class SetHook extends BaseTransaction { public static Type = TransactionTypes.SetHook as const; public readonly Type = SetHook.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/SetRegularKey/SetRegularKeyClass.ts b/src/common/libs/ledger/transactions/genuine/SetRegularKey/SetRegularKeyClass.ts index 87645dbc3..60e264bb9 100644 --- a/src/common/libs/ledger/transactions/genuine/SetRegularKey/SetRegularKeyClass.ts +++ b/src/common/libs/ledger/transactions/genuine/SetRegularKey/SetRegularKeyClass.ts @@ -3,14 +3,15 @@ import { get, isUndefined } from 'lodash'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class SetRegularKey extends BaseTransaction { public static Type = TransactionTypes.SetRegularKey as const; public readonly Type = SetRegularKey.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/SignerListSet/SignerListSetClass.ts b/src/common/libs/ledger/transactions/genuine/SignerListSet/SignerListSetClass.ts index fa3727e3b..3a919ec10 100644 --- a/src/common/libs/ledger/transactions/genuine/SignerListSet/SignerListSetClass.ts +++ b/src/common/libs/ledger/transactions/genuine/SignerListSet/SignerListSetClass.ts @@ -4,14 +4,15 @@ import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransa /* Types ==================================================================== */ import { SignerEntry } from '@common/libs/ledger/parser/types'; -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class SignerListSet extends BaseTransaction { public static Type = TransactionTypes.SignerListSet as const; public readonly Type = SignerListSet.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/TicketCreate/TicketCreateClass.ts b/src/common/libs/ledger/transactions/genuine/TicketCreate/TicketCreateClass.ts index ac1818981..48dad4a93 100644 --- a/src/common/libs/ledger/transactions/genuine/TicketCreate/TicketCreateClass.ts +++ b/src/common/libs/ledger/transactions/genuine/TicketCreate/TicketCreateClass.ts @@ -6,14 +6,15 @@ import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransa /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class TicketCreate extends BaseTransaction { public static Type = TransactionTypes.TicketCreate as const; public readonly Type = TicketCreate.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/TrustSet/TrustSetClass.ts b/src/common/libs/ledger/transactions/genuine/TrustSet/TrustSetClass.ts index b61116852..1faf9a5db 100644 --- a/src/common/libs/ledger/transactions/genuine/TrustSet/TrustSetClass.ts +++ b/src/common/libs/ledger/transactions/genuine/TrustSet/TrustSetClass.ts @@ -3,15 +3,15 @@ import { set, get, isUndefined, toNumber } from 'lodash'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ - -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class TrustSet extends BaseTransaction { public static Type = TransactionTypes.TrustSet as const; public readonly Type = TrustSet.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/URITokenBurn/URITokenBurnClass.ts b/src/common/libs/ledger/transactions/genuine/URITokenBurn/URITokenBurnClass.ts index 0ce0f429d..b37b4361e 100644 --- a/src/common/libs/ledger/transactions/genuine/URITokenBurn/URITokenBurnClass.ts +++ b/src/common/libs/ledger/transactions/genuine/URITokenBurn/URITokenBurnClass.ts @@ -3,14 +3,15 @@ import { get, isUndefined } from 'lodash'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class URITokenBurn extends BaseTransaction { public static Type = TransactionTypes.URITokenBurn as const; public readonly Type = URITokenBurn.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/URITokenBuy/URITokenBuyClass.ts b/src/common/libs/ledger/transactions/genuine/URITokenBuy/URITokenBuyClass.ts index 69bc2b9ff..511d2fbe2 100644 --- a/src/common/libs/ledger/transactions/genuine/URITokenBuy/URITokenBuyClass.ts +++ b/src/common/libs/ledger/transactions/genuine/URITokenBuy/URITokenBuyClass.ts @@ -8,14 +8,15 @@ import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransa /* Types ==================================================================== */ import { AmountType } from '@common/libs/ledger/parser/types'; -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class URITokenBuy extends BaseTransaction { public static Type = TransactionTypes.URITokenBuy as const; public readonly Type = URITokenBuy.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set @@ -31,9 +32,7 @@ class URITokenBuy extends BaseTransaction { } get Amount(): AmountType { - let amount = undefined as AmountType; - - amount = get(this, ['tx', 'Amount']); + const amount = get(this, ['tx', 'Amount']); if (isUndefined(amount)) return undefined; diff --git a/src/common/libs/ledger/transactions/genuine/URITokenCancelSellOffer/URITokenCancelSellOfferClass.ts b/src/common/libs/ledger/transactions/genuine/URITokenCancelSellOffer/URITokenCancelSellOfferClass.ts index 972e676f4..2555c38dd 100644 --- a/src/common/libs/ledger/transactions/genuine/URITokenCancelSellOffer/URITokenCancelSellOfferClass.ts +++ b/src/common/libs/ledger/transactions/genuine/URITokenCancelSellOffer/URITokenCancelSellOfferClass.ts @@ -3,14 +3,15 @@ import { get, isUndefined } from 'lodash'; import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransaction'; /* Types ==================================================================== */ -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class URITokenCancelSellOffer extends BaseTransaction { public static Type = TransactionTypes.URITokenCancelSellOffer as const; public readonly Type = URITokenCancelSellOffer.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/genuine/URITokenCreateSellOffer/URITokenCreateSellOfferClass.ts b/src/common/libs/ledger/transactions/genuine/URITokenCreateSellOffer/URITokenCreateSellOfferClass.ts index 3ea2525c3..151776694 100644 --- a/src/common/libs/ledger/transactions/genuine/URITokenCreateSellOffer/URITokenCreateSellOfferClass.ts +++ b/src/common/libs/ledger/transactions/genuine/URITokenCreateSellOffer/URITokenCreateSellOfferClass.ts @@ -8,14 +8,15 @@ import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransa /* Types ==================================================================== */ import { AmountType, Destination } from '@common/libs/ledger/parser/types'; -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class URITokenCreateSellOffer extends BaseTransaction { public static Type = TransactionTypes.URITokenCreateSellOffer as const; public readonly Type = URITokenCreateSellOffer.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set @@ -31,9 +32,7 @@ class URITokenCreateSellOffer extends BaseTransaction { } get Amount(): AmountType { - let amount = undefined as AmountType; - - amount = get(this, ['tx', 'Amount']); + const amount = get(this, ['tx', 'Amount']); if (isUndefined(amount)) return undefined; diff --git a/src/common/libs/ledger/transactions/genuine/URITokenMint/URITokenMintClass.ts b/src/common/libs/ledger/transactions/genuine/URITokenMint/URITokenMintClass.ts index a023cef30..4e46afc1e 100644 --- a/src/common/libs/ledger/transactions/genuine/URITokenMint/URITokenMintClass.ts +++ b/src/common/libs/ledger/transactions/genuine/URITokenMint/URITokenMintClass.ts @@ -8,14 +8,15 @@ import BaseTransaction from '@common/libs/ledger/transactions/genuine/BaseTransa /* Types ==================================================================== */ import { AmountType, Destination } from '@common/libs/ledger/parser/types'; -import { TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson, TransactionMetadata } from '@common/libs/ledger/types/transaction'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class URITokenMint extends BaseTransaction { public static Type = TransactionTypes.URITokenMint as const; public readonly Type = URITokenMint.Type; - constructor(tx?: TransactionJSONType, meta?: any) { + constructor(tx?: TransactionJson, meta?: TransactionMetadata) { super(tx, meta); // set transaction type if not set @@ -35,9 +36,7 @@ class URITokenMint extends BaseTransaction { } get Amount(): AmountType { - let amount = undefined as AmountType; - - amount = get(this, ['tx', 'Amount']); + const amount = get(this, ['tx', 'Amount']); if (isUndefined(amount)) return undefined; diff --git a/src/common/libs/ledger/transactions/pseudo/BasePseudo.ts b/src/common/libs/ledger/transactions/pseudo/BasePseudo.ts index 5315a2224..2a10e1f55 100644 --- a/src/common/libs/ledger/transactions/pseudo/BasePseudo.ts +++ b/src/common/libs/ledger/transactions/pseudo/BasePseudo.ts @@ -9,15 +9,16 @@ import { AccountModel } from '@store/models'; import { AppScreens } from '@common/constants'; import { Navigator } from '@common/helpers/navigator'; -import { PseudoTransactionTypes, SignedObjectType, TransactionJSONType } from '@common/libs/ledger/types'; - import Memo from '@common/libs/ledger/parser/common/memo'; /* Types ==================================================================== */ -import { Account, MemoType } from '@common/libs/ledger/parser/types'; +import { Account, MemoType, Signer } from '@common/libs/ledger/parser/types'; +import { TransactionJson } from '@common/libs/ledger/types/transaction'; +import { SignedObjectType } from '@common/libs/ledger/types'; +import { PseudoTransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class BasePseudoTransaction { - protected tx: TransactionJSONType; + protected tx: TransactionJson; protected fields: string[]; private isAborted: boolean; @@ -27,7 +28,7 @@ class BasePseudoTransaction { public SignMethod: 'PIN' | 'BIOMETRIC' | 'PASSPHRASE' | 'TANGEM' | 'OTHER'; public SignerAccount: any; - constructor(tx?: TransactionJSONType) { + constructor(tx?: TransactionJson) { if (!isUndefined(tx)) { this.tx = tx; } @@ -194,7 +195,7 @@ class BasePseudoTransaction { } // serialize transaction object to rippled tx json - get Json(): TransactionJSONType { + get Json(): TransactionJson { // shallow copy const tx = { ...this.tx }; Object.getOwnPropertyNames(this.tx).forEach((k: string) => { @@ -206,11 +207,15 @@ class BasePseudoTransaction { return tx; } - get Signers(): Array { + get Signers(): Array { const signers = get(this, ['tx', 'Signers']); - return flatMap(signers, (e) => { - return { account: e.Signer.Account, signature: e.Signer.TxnSignature, pubKey: e.Signer.SigningPubKey }; + return flatMap(signers, (item) => { + return { + account: item.Signer.Account, + signature: item.Signer.TxnSignature, + pubKey: item.Signer.SigningPubKey, + }; }); } diff --git a/src/common/libs/ledger/transactions/pseudo/PaymentChannelAuthorize/PaymentChannelAuthorizeClass.ts b/src/common/libs/ledger/transactions/pseudo/PaymentChannelAuthorize/PaymentChannelAuthorizeClass.ts index fb1e7fbbe..06d962109 100644 --- a/src/common/libs/ledger/transactions/pseudo/PaymentChannelAuthorize/PaymentChannelAuthorizeClass.ts +++ b/src/common/libs/ledger/transactions/pseudo/PaymentChannelAuthorize/PaymentChannelAuthorizeClass.ts @@ -8,14 +8,15 @@ import BasePseudoTransaction from '@common/libs/ledger/transactions/pseudo/BaseP /* Types ==================================================================== */ import { AmountType } from '@common/libs/ledger/parser/types'; -import { PseudoTransactionTypes, TransactionJSONType } from '@common/libs/ledger/types'; +import { TransactionJson } from '@common/libs/ledger/types/transaction'; +import { PseudoTransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class PaymentChannelAuthorize extends BasePseudoTransaction { public static Type = PseudoTransactionTypes.PaymentChannelAuthorize as const; public readonly Type = PaymentChannelAuthorize.Type; - constructor(tx?: TransactionJSONType) { + constructor(tx?: TransactionJson) { super(tx); // set transaction type if not set diff --git a/src/common/libs/ledger/transactions/pseudo/SignIn/SignInClass.ts b/src/common/libs/ledger/transactions/pseudo/SignIn/SignInClass.ts index 46eed0bb9..1df0edd95 100644 --- a/src/common/libs/ledger/transactions/pseudo/SignIn/SignInClass.ts +++ b/src/common/libs/ledger/transactions/pseudo/SignIn/SignInClass.ts @@ -3,14 +3,15 @@ import { isUndefined } from 'lodash'; import BasePseudoTransaction from '@common/libs/ledger/transactions/pseudo/BasePseudo'; /* Types ==================================================================== */ -import { PseudoTransactionTypes, TransactionJSONType } from '@common/libs/ledger/types'; +import { TransactionJson } from '@common/libs/ledger/types/transaction'; +import { PseudoTransactionTypes } from '@common/libs/ledger/types/enums'; /* Class ==================================================================== */ class SignIn extends BasePseudoTransaction { public static Type = PseudoTransactionTypes.SignIn as const; public readonly Type = SignIn.Type; - constructor(tx?: TransactionJSONType) { + constructor(tx?: TransactionJson) { super(tx); // set transaction type if not set diff --git a/src/common/libs/ledger/types.ts b/src/common/libs/ledger/types.ts index b493992f8..cc9d370d9 100644 --- a/src/common/libs/ledger/types.ts +++ b/src/common/libs/ledger/types.ts @@ -1,86 +1,3 @@ -import { AmountType, LedgerAmount } from './parser/types'; - -export enum TransactionTypes { - Payment = 'Payment', - TrustSet = 'TrustSet', - AccountDelete = 'AccountDelete', - AccountSet = 'AccountSet', - OfferCreate = 'OfferCreate', - OfferCancel = 'OfferCancel', - EscrowCreate = 'EscrowCreate', - EscrowCancel = 'EscrowCancel', - EscrowFinish = 'EscrowFinish', - SetRegularKey = 'SetRegularKey', - SignerListSet = 'SignerListSet', - DepositPreauth = 'DepositPreauth', - CheckCreate = 'CheckCreate', - CheckCash = 'CheckCash', - CheckCancel = 'CheckCancel', - TicketCreate = 'TicketCreate', - PaymentChannelCreate = 'PaymentChannelCreate', - PaymentChannelClaim = 'PaymentChannelClaim', - PaymentChannelFund = 'PaymentChannelFund', - NFTokenMint = 'NFTokenMint', - NFTokenBurn = 'NFTokenBurn', - NFTokenCreateOffer = 'NFTokenCreateOffer', - NFTokenAcceptOffer = 'NFTokenAcceptOffer', - NFTokenCancelOffer = 'NFTokenCancelOffer', - SetHook = 'SetHook', - ClaimReward = 'ClaimReward', - Invoke = 'Invoke', - Import = 'Import', - URITokenMint = 'URITokenMint', - URITokenBurn = 'URITokenBurn', - URITokenBuy = 'URITokenBuy', - URITokenCreateSellOffer = 'URITokenCreateSellOffer', - URITokenCancelSellOffer = 'URITokenCancelSellOffer', - GenesisMint = 'GenesisMint', - EnableAmendment = 'EnableAmendment', -} - -export enum PseudoTransactionTypes { - SignIn = 'SignIn', - PaymentChannelAuthorize = 'PaymentChannelAuthorize', -} - -export enum LedgerObjectTypes { - Check = 'Check', - Escrow = 'Escrow', - NFTokenOffer = 'NFTokenOffer', - Offer = 'Offer', - Ticket = 'Ticket', - PayChannel = 'PayChannel', -} - -/** - * TX Json Transaction Type - */ -export type TransactionJSONType = { - Account?: string; - TransactionType?: string; - Memos?: { Memo: { MemoType?: string; MemoData?: string; MemoFormat?: string } }[]; - Flags?: number; - Fulfillment?: string; - LastLedgerSequence?: number; - [Field: string]: string | number | Array | undefined | object | boolean; -}; - -/** - * Ledger Transaction schema from rippled - */ -export interface LedgerTransactionType { - engine_result?: string; - engine_result_code?: number; - engine_result_message?: string; - ledger_hash?: string; - ledger_index?: number; - status?: string; - tx?: TransactionJSONType; - meta?: any; - - [key: string]: any; -} - /** * Transaction Signed Type */ @@ -118,315 +35,6 @@ export type VerifyResultType = { transaction?: any; }; -/** - * Ledger marker - */ -export type LedgerMarker = { - ledger: number; - seq: number; -}; - -/** - * Ledger balance - */ -export interface Balance { - currency: string; - value: string; -} - -/** - * Ledger account root - */ -export interface AccountRoot { - Account: string; - Balance: string; - Flags: number; - OwnerCount: number; - PreviousTxnID: string; - PreviousTxnLgrSeq: number; - Sequence: number; - AccountTxnID?: string; - Domain?: string; - EmailHash?: string; - MessageKey?: string; - RegularKey?: string; - TicketCount?: number; - TickSize?: number; - TransferRate?: number; -} - -/** - * Ledger trustline type - */ -export interface LedgerTrustline { - account: string; - balance: string; - currency: string; - limit: string; - limit_peer: string; - quality_in: number; - quality_out: number; - no_ripple?: boolean; - no_ripple_peer?: boolean; - authorized?: boolean; - peer_authorized?: boolean; - freeze?: boolean; - freeze_peer?: boolean; - obligation?: boolean; -} - -/** - * Ledger nft type - */ -export interface LedgerNFToken { - Flags: number; - Issuer: string; - NFTokenID: string; - NFTokenTaxon: number; - TransferFee: number; - URI: string; - nft_serial: number; -} - -/** - * Extra info for network responses - */ -export interface BaseResponse { - networkId: number; -} - -/** - * Ledger Account tx ledger response - */ -export interface AccountTxResponse extends BaseResponse { - account: string; - ledger_index_max: number; - ledger_index_min: number; - limit: number; - marker: LedgerMarker; - transactions: Array; -} - -/** - * Ledger account_lines response - */ -export interface AccountLinesResponse extends BaseResponse { - account: string; - lines: LedgerTrustline[]; - ledger_current_index?: number; - ledger_index?: number; - ledger_hash?: string; - marker?: string; -} - -export interface AccountNFTsResponse extends BaseResponse { - account: string; - account_nfts: LedgerNFToken[]; - ledger_hash?: string; - ledger_index?: number; - marker?: string; -} - -/** - * Ledger gateway_balances response - */ -export interface GatewayBalancesResponse extends BaseResponse { - account: string; - obligations?: { [currency: string]: string }; - balances?: { [address: string]: Balance[] }; - assets?: { [address: string]: Balance[] }; - ledger_hash?: string; - ledger_current_index?: number; - ledger_index?: number; -} - -/** - * Ledger account_info response - */ -export interface AccountInfoResponse extends BaseResponse { - account_data: AccountRoot; - account_flags?: { [key: string]: boolean }; - signer_lists?: any; - ledger_current_index?: number; - ledger_index?: number; - validated?: boolean; - error?: string; -} - -/** - * Ledger account_objects response - */ -export interface AccountObjectsResponse extends BaseResponse { - account: string; - account_objects: LedgerEntriesTypes[]; - ledger_hash?: string; - ledger_index?: number; - ledger_current_index?: number; - limit?: number; - marker?: string; - validated?: boolean; - error?: string; -} - -/** - * Ledger fee command response - */ -interface FeeResponseDrops { - minimum_fee: string; - median_fee: string; - open_ledger_fee: string; -} - -export interface FeeResponse { - current_queue_size: string; - max_queue_size: string; - drops: FeeResponseDrops; -} - -/** - * Ledger ledger_entry command response - */ -export interface LedgerEntryResponse extends BaseResponse { - index: string; - ledger_current_index: number; - node?: LedgerEntriesTypes; - validated?: boolean; -} - -export type LedgerEntriesTypes = - | OfferLedgerEntry - | EscrowLedgerEntry - | CheckLedgerEntry - | RippleStateLedgerEntry - | NFTokenOfferLedgerEntry; - -/** - * Ledger objects Entries - */ -export interface OfferLedgerEntry { - LedgerEntryType: 'Offer'; - Flags: number; - Account: string; - Sequence: number; - TakerPays: AmountType; - TakerGets: AmountType; - BookDirectory: string; - BookNode: string; - OwnerNode: string; - PreviousTxnID: string; - PreviousTxnLgrSeq: number; - Expiration?: number; -} - -/** - * Escrow leger entry - */ -export interface EscrowLedgerEntry { - LedgerEntryType: 'Escrow'; - Account: string; - Destination: string; - Amount: string; - Condition?: string; - CancelAfter?: number; - FinishAfter?: number; - Flags: number; - SourceTag?: number; - DestinationTag?: number; - OwnerNode: string; - DestinationNode?: string; - PreviousTxnID: string; - PreviousTxnLgrSeq: number; -} - -/** - * Check leger entry - */ -export interface CheckLedgerEntry { - LedgerEntryType: 'Check'; - Account: string; - Destination: string; - Flags: 0; - OwnerNode: string; - PreviousTxnID: string; - PreviousTxnLgrSeq: number; - SendMax: string | object; - Sequence: number; - DestinationNode: string; - DestinationTag: number; - Expiration: number; - InvoiceID: string; - SourceTag: number; -} - -/** - * Ripple state leger entry - */ -export interface RippleStateLedgerEntry { - LedgerEntryType: 'RippleState'; - Flags: number; - Balance: AmountType; - LowLimit: AmountType; - HighLimit: AmountType; - PreviousTxnID: string; - PreviousTxnLgrSeq: number; - LowNode?: string; - HighNode?: string; - LowQualityIn?: number; - LowQualityOut?: number; - HighQualityIn?: number; - HighQualityOut?: number; -} - -/** - * NFTokenOffer leger entry - */ -export interface NFTokenOfferLedgerEntry { - LedgerEntryType: 'NFTokenOffer'; - Owner: string; - Destination: string; - Amount: AmountType; - NFTokenID: string; - Expiration?: number; - Flags: number; - OwnerNode: string; - NFTokenOfferNode: string; - PreviousTxnID: string; - PreviousTxnLgrSeq: number; -} - -/** - * Path finding - */ -interface PathStep { - account?: string; - currency?: string; - issuer?: string; - type?: number; -} - -export type Path = PathStep[]; - -export interface PathOption { - paths_computed: Path[]; - source_amount: LedgerAmount; -} - -export interface RipplePathFindResponse extends BaseResponse { - id?: any; - error?: string; - result: { - id?: number | string; - alternatives: PathOption[]; - destination_account: string; - destination_currencies: string[]; - destination_amount: LedgerAmount; - full_reply?: boolean; - ledger_current_index?: number; - source_account: string; - validated: boolean; - }; -} - /** * GenesisMints type */ @@ -437,18 +45,3 @@ export interface GenesisMintsType Destination: string; }; }> {} - -/** - * Hook executions - */ -export interface HookExecution { - HookAccount: string; - HookEmitCount: number; - HookExecutionIndex: number; - HookHash: string; - HookInstructionCount: string; - HookResult: number; - HookReturnCode: number; - HookReturnString: string; - HookStateChangeCount: number; -} diff --git a/src/common/libs/ledger/types/common/index.ts b/src/common/libs/ledger/types/common/index.ts new file mode 100644 index 000000000..5c7834ad7 --- /dev/null +++ b/src/common/libs/ledger/types/common/index.ts @@ -0,0 +1,177 @@ +export type LedgerIndex = number | ('validated' | 'closed' | 'current'); + +export interface NativeCurrency { + currency: string; + issuer: never; +} + +export interface IssuedCurrency { + currency: string; + issuer: string; +} + +export type Currency = IssuedCurrency | NativeCurrency; + +export interface IssuedCurrencyAmount extends IssuedCurrency { + value: string; +} + +export type Amount = IssuedCurrencyAmount | string; + +export interface Balance { + currency: string; + issuer?: string; + value: string; +} + +export interface Signer { + Signer: { + Account: string; + TxnSignature: string; + SigningPubKey: string; + }; +} + +export interface Memo { + Memo: { + MemoData?: string; + MemoType?: string; + MemoFormat?: string; + }; +} + +export type StreamType = + | 'consensus' + | 'ledger' + | 'manifests' + | 'peer_status' + | 'transactions' + | 'transactions_proposed' + | 'server' + | 'validations'; + +export interface PathStep { + account?: string; + currency?: string; + issuer?: string; + type?: number; +} + +export type Path = PathStep[]; + +export type LedgerMarker = { + ledger: number; + seq: number; +}; + +/** + * The object that describes the signer in SignerEntries. + */ +export interface SignerEntry { + /** + * The object that describes the signer in SignerEntries. + */ + SignerEntry: { + /** + * An XRP Ledger address whose signature contributes to the multi-signature. + * It does not need to be a funded address in the ledger. + */ + Account: string; + /** + * The weight of a signature from this signer. + * A multi-signature is only valid if the sum weight of the signatures provided meets + * or exceeds the signer list's SignerQuorum value. + */ + SignerWeight: number; + /** + * An arbitrary 256-bit (32-byte) field that can be used to identify the signer, which + * may be useful for smart contracts, or for identifying who controls a key in a large + * organization. + */ + WalletLocator?: string; + }; +} + +/** + * This information is added to Transactions in request responses, but is not part + * of the canonical Transaction information on ledger. These fields are denoted with + * lowercase letters to indicate this in the rippled responses. + */ +export interface ResponseOnlyTxInfo { + /** + * The date/time when this transaction was included in a validated ledger. + */ + date?: number; + /** + * An identifying hash value unique to this transaction, as a hex string. + */ + hash?: string; + /** + * The sequence number of the ledger that included this transaction. + */ + ledger_index?: number; + /** + * @deprecated Alias for ledger_index. + */ + inLedger?: number; +} + +/** + * One offer that might be returned from either an {@link NFTBuyOffersRequest} + * or an {@link NFTSellOffersRequest}. + * + * @category Responses + */ +export interface NFTOffer { + amount: Amount; + flags: number; + nft_offer_index: string; + owner: string; + destination?: string; + expiration?: number; +} + +/** + * One NFToken that might be returned from an {@link NFTInfoResponse} + * + * @category Responses + */ +export interface NFToken { + nft_id: string; + ledger_index: number; + owner: string; + is_burned: boolean; + flags: number; + transfer_fee: number; + issuer: string; + nft_taxon: number; + nft_serial: number; + uri: string; +} + +export interface AuthAccount { + AuthAccount: { + Account: string; + }; +} + +/** + * Hook executions + */ +export interface HookExecution { + HookAccount: string; + HookEmitCount: number; + HookExecutionIndex: number; + HookHash: string; + HookInstructionCount: string; + HookResult: number; + HookReturnCode: number; + HookReturnString: string; + HookStateChangeCount: number; +} + +export interface HookEmission { + EmittedTxnID: string; + HookAccount: string; + HookHash: string; +} diff --git a/src/common/libs/ledger/types/enums.ts b/src/common/libs/ledger/types/enums.ts new file mode 100644 index 000000000..e96ebf0e8 --- /dev/null +++ b/src/common/libs/ledger/types/enums.ts @@ -0,0 +1,68 @@ +/** + * transaction types + */ +export enum TransactionTypes { + Payment = 'Payment', + TrustSet = 'TrustSet', + AccountDelete = 'AccountDelete', + AccountSet = 'AccountSet', + OfferCreate = 'OfferCreate', + OfferCancel = 'OfferCancel', + EscrowCreate = 'EscrowCreate', + EscrowCancel = 'EscrowCancel', + EscrowFinish = 'EscrowFinish', + SetRegularKey = 'SetRegularKey', + SignerListSet = 'SignerListSet', + DepositPreauth = 'DepositPreauth', + CheckCreate = 'CheckCreate', + CheckCash = 'CheckCash', + CheckCancel = 'CheckCancel', + TicketCreate = 'TicketCreate', + PaymentChannelCreate = 'PaymentChannelCreate', + PaymentChannelClaim = 'PaymentChannelClaim', + PaymentChannelFund = 'PaymentChannelFund', + NFTokenMint = 'NFTokenMint', + NFTokenBurn = 'NFTokenBurn', + NFTokenCreateOffer = 'NFTokenCreateOffer', + NFTokenAcceptOffer = 'NFTokenAcceptOffer', + NFTokenCancelOffer = 'NFTokenCancelOffer', + SetHook = 'SetHook', + ClaimReward = 'ClaimReward', + Invoke = 'Invoke', + Import = 'Import', + URITokenMint = 'URITokenMint', + URITokenBurn = 'URITokenBurn', + URITokenBuy = 'URITokenBuy', + URITokenCreateSellOffer = 'URITokenCreateSellOffer', + URITokenCancelSellOffer = 'URITokenCancelSellOffer', + GenesisMint = 'GenesisMint', + EnableAmendment = 'EnableAmendment', +} + +/** + * Pseudo transaction types + */ +export enum PseudoTransactionTypes { + SignIn = 'SignIn', + PaymentChannelAuthorize = 'PaymentChannelAuthorize', +} + +export enum LedgerEntryTypes { + AccountRoot = 'AccountRoot', + Amendments = 'Amendments', + AMM = 'AMM', + Check = 'Check', + DepositPreauth = 'DepositPreauth', + DirectoryNode = 'DirectoryNode', + Escrow = 'Escrow', + FeeSettings = 'FeeSettings', + LedgerHashes = 'LedgerHashes', + NegativeUNL = 'NegativeUNL', + NFTokenOffer = 'NFTokenOffer', + NFTokenPage = 'NFTokenPage', + Offer = 'Offer', + Ticket = 'Ticket', + PayChannel = 'PayChannel', + RippleState = 'RippleState', + SignerList = 'SignerList', +} diff --git a/src/common/libs/ledger/types/ledger/AMM.ts b/src/common/libs/ledger/types/ledger/AMM.ts new file mode 100644 index 000000000..3b740bc65 --- /dev/null +++ b/src/common/libs/ledger/types/ledger/AMM.ts @@ -0,0 +1,76 @@ +import { AuthAccount, Currency, IssuedCurrencyAmount } from '../common'; + +import { BaseLedgerEntry, MissingPreviousTxnID } from './BaseLedgerEntry'; + +export interface VoteSlot { + VoteEntry: { + Account: string; + TradingFee: number; + VoteWeight: number; + }; +} + +/** + * The AMM object type describes a single Automated Market Maker (AMM) instance. + * + * @category Ledger Entries + */ +export default interface AMM extends BaseLedgerEntry, MissingPreviousTxnID { + /** + * The address of the special account that holds this AMM's assets. + */ + Account: string; + /** + * The definition for one of the two assets this AMM holds. + */ + Asset: Currency; + /** + * The definition for the other asset this AMM holds. + */ + Asset2: Currency; + /** + * Details of the current owner of the auction slot. + */ + AuctionSlot?: { + /** + * The current owner of this auction slot. + */ + Account: string; + /** + * A list of authorized accounts to trade at the discounted fee for this AMM instance. + */ + AuthAccounts?: AuthAccount[]; + /** + * The trading fee to be charged to the auction owner, in the same format as TradingFee. + */ + DiscountedFee: number; + /** + * The time when this slot expires, in seconds since the Ripple Epoch. + */ + Expiration: number; + /** + * The amount the auction owner paid to win this slot, in LP Tokens. + */ + Price: IssuedCurrencyAmount; + }; + /** + * The total outstanding balance of liquidity provider tokens from this AMM instance. + * The holders of these tokens can vote on the AMM's trading fee in proportion to their holdings, + * or redeem the tokens for a share of the AMM's assets which grows with the trading fees collected. + */ + LPTokenBalance: Currency; + /** + * The percentage fee to be charged for trades against this AMM instance, in units of 1/100,000. + * The maximum value is 1000, for a 1% fee. + */ + TradingFee: number; + /** + * A list of vote objects, representing votes on the pool's trading fee. + */ + VoteSlots?: VoteSlot[]; + /** + * A bit-map of boolean flags. No flags are defined for the AMM object + * type, so this value is always 0. + */ + Flags: 0; +} diff --git a/src/common/libs/ledger/types/ledger/AccountRoot.ts b/src/common/libs/ledger/types/ledger/AccountRoot.ts new file mode 100644 index 000000000..9dbe1851f --- /dev/null +++ b/src/common/libs/ledger/types/ledger/AccountRoot.ts @@ -0,0 +1,80 @@ +import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'; + +/** + * The AccountRoot object type describes a single account, its settings, and + * XRP balance. + * + * @category Ledger Entries + */ +export default interface AccountRoot extends BaseLedgerEntry, HasPreviousTxnID { + /** The identifying (classic) address of this account. */ + Account: string; + /** The account's current XRP balance in drops, represented as a string. */ + Balance: string; + /** A bit-map of boolean flags enabled for this account. */ + Flags: number; + /** + * The number of objects this account owns in the ledger, which contributes + * to its owner reserve. + */ + OwnerCount: number; + /** The sequence number of the next valid transaction for this account. */ + Sequence: number; + /** + * The identifying hash of the transaction most recently sent by this + * account. This field must be enabled to use the AccountTxnID transaction + * field. To enable it, send an AccountSet transaction with the. + * `asfAccountTxnID` flag enabled. + */ + AccountTxnID?: string; + /** + * The ledger entry ID of the corresponding AMM ledger entry. + * Set during account creation; cannot be modified. + * If present, indicates that this is a special AMM AccountRoot; always omitted on non-AMM accounts. + */ + AMMID?: string; + /** + * A domain associated with this account. In JSON, this is the hexadecimal + * for the ASCII representation of the domain. + */ + Domain?: string; + /** The md5 hash of an email address. */ + EmailHash?: string; + /** + * A public key that may be used to send encrypted messages to this account + * in JSON, uses hexadecimal. + */ + MessageKey?: string; + /** + * The address of a key pair that can be used to sign transactions for this + * account instead of the master key. Use a SetRegularKey transaction to + * change this value. + */ + RegularKey?: string; + /** + * How many Tickets this account owns in the ledger. This is updated + * automatically to ensure that the account stays within the hard limit of 250. + * Tickets at a time. + */ + TicketCount?: number; + /** + * How many significant digits to use for exchange rates of Offers involving + * currencies issued by this address. Valid values are 3 to 15, inclusive. + */ + TickSize?: number; + /** + * A transfer fee to charge other users for sending currency issued by this + * account to each other. + */ + TransferRate?: string; + /** An arbitrary 256-bit value that users can set. */ + WalletLocator?: string; + /** Total NFTokens this account's issued that have been burned. */ + BurnedNFTokens?: number; + /** The sequence that the account first minted an NFToken */ + FirstNFTSequence: number; + /** Total NFTokens have been minted by and on behalf of this account. */ + MintedNFTokens?: number; + /** Another account that can mint NFTokens on behalf of this account. */ + NFTokenMinter?: string; +} diff --git a/src/common/libs/ledger/types/ledger/Amendments.ts b/src/common/libs/ledger/types/ledger/Amendments.ts new file mode 100644 index 000000000..33ae7e9f6 --- /dev/null +++ b/src/common/libs/ledger/types/ledger/Amendments.ts @@ -0,0 +1,38 @@ +import { BaseLedgerEntry, MissingPreviousTxnID } from './BaseLedgerEntry'; + +export interface Majority { + Majority: { + /** The Amendment ID of the pending amendment. */ + Amendment: string; + /** + * The `close_time` field of the ledger version where this amendment most + * recently gained a majority. + */ + CloseTime: number; + }; +} + +/** + * The Amendments object type contains a list of Amendments that are currently + * active. + * + * @category Ledger Entries + */ +export default interface Amendments extends BaseLedgerEntry, MissingPreviousTxnID { + /** + * Array of 256-bit amendment IDs for all currently-enabled amendments. If + * omitted, there are no enabled amendments. + */ + Amendments?: string[]; + /** + * Array of objects describing the status of amendments that have majority + * support but are not yet enabled. If omitted, there are no pending + * amendments with majority support. + */ + Majorities?: Majority[]; + /** + * A bit-map of boolean flags. No flags are defined for the Amendments object + * type, so this value is always 0. + */ + Flags: 0; +} diff --git a/src/common/libs/ledger/types/ledger/BaseLedgerEntry.ts b/src/common/libs/ledger/types/ledger/BaseLedgerEntry.ts new file mode 100644 index 000000000..9f1be0c9a --- /dev/null +++ b/src/common/libs/ledger/types/ledger/BaseLedgerEntry.ts @@ -0,0 +1,30 @@ +import { LedgerEntryTypes } from '@common/libs/ledger/types/enums'; + +export interface BaseLedgerEntry { + LedgerEntryType: LedgerEntryTypes; + index: string; +} + +export interface HasPreviousTxnID { + /** + * The identifying hash of the transaction that most recently modified this + * object. + */ + PreviousTxnID: string; + /** + * The index of the ledger that contains the transaction that most recently + * modified this object. + */ + PreviousTxnLgrSeq: number; +} + +export interface MissingPreviousTxnID { + /** + * This field is missing on this object but is present on most other returned objects. + */ + PreviousTxnID: never; + /** + * This field is missing on this object but is present on most other returned objects. + */ + PreviousTxnLgrSeq: never; +} diff --git a/src/common/libs/ledger/types/ledger/Check.ts b/src/common/libs/ledger/types/ledger/Check.ts new file mode 100644 index 000000000..2854ecebf --- /dev/null +++ b/src/common/libs/ledger/types/ledger/Check.ts @@ -0,0 +1,69 @@ +import { Amount } from '../common'; + +import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'; + +/** + * A Check object describes a check, similar to a paper personal check, which + * can be cashed by its destination to get money from its sender. + * + * @category Ledger Entries + */ +export default interface Check extends BaseLedgerEntry, HasPreviousTxnID { + /** The sender of the Check. Cashing the Check debits this address's balance. */ + Account: string; + /** + * The intended recipient of the Check. Only this address can cash the Check, + * using a CheckCash transaction. + */ + Destination: string; + /** + * A bit-map of boolean flags. No flags are defined for Checks, so this value + * is always 0. + */ + Flags: 0; + /** + * A hint indicating which page of the sender's owner directory links to this + * object, in case the directory consists of multiple pages. + */ + OwnerNode: string; + /** + * The identifying hash of the transaction that most recently modified this + * object. + */ + PreviousTxnID: string; + /** + * The index of the ledger that contains the transaction that most recently + * modified this object. + */ + PreviousTxnLgrSeq: number; + /** + * The maximum amount of currency this Check can debit the sender. If the + * Check is successfully cashed, the destination is credited in the same + * currency for up to this amount. + */ + SendMax: Amount; + /** The sequence number of the CheckCreate transaction that created this check. */ + Sequence: number; + /** + * A hint indicating which page of the destination's owner directory links to + * this object, in case the directory consists of multiple pages. + */ + DestinationNode?: string; + /** + * An arbitrary tag to further specify the destination for this Check, such + * as a hosted recipient at the destination address. + */ + DestinationTag?: number; + /** Indicates the time after which this Check is considered expired. */ + Expiration?: number; + /** + * Arbitrary 256-bit hash provided by the sender as a specific reason or + * identifier for this Check. + */ + InvoiceID?: string; + /** + * An arbitrary tag to further specify the source for this Check, such as a + * hosted recipient at the sender's address. + */ + SourceTag?: number; +} diff --git a/src/common/libs/ledger/types/ledger/DepositPreauth.ts b/src/common/libs/ledger/types/ledger/DepositPreauth.ts new file mode 100644 index 000000000..03bba5a59 --- /dev/null +++ b/src/common/libs/ledger/types/ledger/DepositPreauth.ts @@ -0,0 +1,24 @@ +import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'; + +/** + * A DepositPreauth object tracks a preauthorization from one account to + * another. DepositPreauth transactions create these objects. + * + * @category Ledger Entries + */ +export default interface DepositPreauth extends BaseLedgerEntry, HasPreviousTxnID { + /** The account that granted the preauthorization. */ + Account: string; + /** The account that received the preauthorization. */ + Authorize: string; + /** + * A bit-map of boolean flags. No flags are defined for DepositPreauth + * objects, so this value is always 0. + */ + Flags: 0; + /** + * A hint indicating which page of the sender's owner directory links to this + * object, in case the directory consists of multiple pages. + */ + OwnerNode: string; +} diff --git a/src/common/libs/ledger/types/ledger/DirectoryNode.ts b/src/common/libs/ledger/types/ledger/DirectoryNode.ts new file mode 100644 index 000000000..f8046d949 --- /dev/null +++ b/src/common/libs/ledger/types/ledger/DirectoryNode.ts @@ -0,0 +1,45 @@ +import { BaseLedgerEntry, MissingPreviousTxnID } from './BaseLedgerEntry'; + +/** + * The DirectoryNode object type provides a list of links to other objects in + * the ledger's state tree. + * + * @category Ledger Entries + */ +export default interface DirectoryNode extends BaseLedgerEntry, MissingPreviousTxnID { + /** + * A bit-map of boolean flags enabled for this directory. Currently, the + * protocol defines no flags for DirectoryNode objects. + */ + Flags: number; + /** The ID of root object for this directory. */ + RootIndex: string; + /** The contents of this Directory: an array of IDs of other objects. */ + Indexes: string[]; + /** + * If this Directory consists of multiple pages, this ID links to the next + * object in the chain, wrapping around at the end. + */ + IndexNext?: number; + /** + * If this Directory consists of multiple pages, this ID links to the + * previous object in the chain, wrapping around at the beginning. + */ + IndexPrevious?: number; + /** The address of the account that owns the objects in this directory. */ + Owner?: string; + /** + * The currency code of the TakerPays amount from the offers in this + * directory. + */ + TakerPaysCurrency?: string; + /** The issuer of the TakerPays amount from the offers in this directory. */ + TakerPaysIssuer?: string; + /** + * The currency code of the TakerGets amount from the offers in this + * directory. + */ + TakerGetsCurrency?: string; + /** The issuer of the TakerGets amount from the offers in this directory. */ + TakerGetsIssuer?: string; +} diff --git a/src/common/libs/ledger/types/ledger/Escrow.ts b/src/common/libs/ledger/types/ledger/Escrow.ts new file mode 100644 index 000000000..665e809db --- /dev/null +++ b/src/common/libs/ledger/types/ledger/Escrow.ts @@ -0,0 +1,63 @@ +import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'; + +/** + * The Escrow object type represents a held payment of XRP waiting to be + * executed or canceled. + * + * @category Ledger Entries + */ +export default interface Escrow extends BaseLedgerEntry, HasPreviousTxnID { + /** + * The address of the owner (sender) of this held payment. This is the + * account that provided the XRP, and gets it back if the held payment is + * canceled. + */ + Account: string; + /** + * The destination address where the XRP is paid if the held payment is + * successful. + */ + Destination: string; + /** The amount of XRP, in drops, to be delivered by the held payment. */ + Amount: string; + /** + * A PREIMAGE-SHA-256 crypto-condition, as hexadecimal. If present, the + * EscrowFinish transaction must contain a fulfillment that satisfies this + * condition. + */ + Condition?: string; + /** + * The time after which this Escrow is considered expired. + */ + CancelAfter?: number; + /** + * The time, in seconds, since the Ripple Epoch, after which this held payment + * can be finished. Any EscrowFinish transaction before this time fails. + */ + FinishAfter?: number; + /** + * A bit-map of boolean flags. No flags are defined for the Escrow type, so + * this value is always 0. + */ + Flags: number; + /** + * An arbitrary tag to further specify the source for this held payment, such + * as a hosted recipient at the owner's address. + */ + SourceTag?: number; + /** + * An arbitrary tag to further specify the destination for this held payment, + * such as a hosted recipient at the destination address. + */ + DestinationTag?: number; + /** + * A hint indicating which page of the owner directory links to this object, + * in case the directory consists of multiple pages. + */ + OwnerNode: string; + /** + * A hint indicating which page of the destination's owner directory links to + * this object, in case the directory consists of multiple pages. + */ + DestinationNode?: string; +} diff --git a/src/common/libs/ledger/types/ledger/FeeSettings.ts b/src/common/libs/ledger/types/ledger/FeeSettings.ts new file mode 100644 index 000000000..8531ceb80 --- /dev/null +++ b/src/common/libs/ledger/types/ledger/FeeSettings.ts @@ -0,0 +1,44 @@ +import { BaseLedgerEntry, MissingPreviousTxnID } from './BaseLedgerEntry'; + +export interface FeeSettingsPreAmendmentFields { + /** The transaction cost of the "reference transaction" in drops of XRP as hexadecimal. */ + BaseFee: string; + /** The BaseFee translated into "fee units". */ + ReferenceFeeUnits: number; + /** The base reserve for an account in the XRP Ledger, as drops of XRP. */ + ReserveBase: number; + /** The incremental owner reserve for owning objects, as drops of XRP. */ + ReserveIncrement: number; +} + +export interface FeeSettingsPostAmendmentFields { + /** The transaction cost of the "reference transaction" in drops of XRP as hexadecimal. */ + BaseFeeDrops: string; + /** The base reserve for an account in the XRP Ledger, as drops of XRP. */ + ReserveBaseDrops: string; + /** The incremental owner reserve for owning objects, as drops of XRP. */ + ReserveIncrementDrops: string; +} + +export interface FeeSettingsBase extends BaseLedgerEntry, MissingPreviousTxnID { + /** + * A bit-map of boolean flags for this object. No flags are defined for this type. + */ + Flags: 0; +} + +/** + * The FeeSettings object type contains the current base transaction cost and + * reserve amounts as determined by fee voting. + * + * The fields will be based on the status of the `XRPFees` amendment. + * - Before: {@link FeeSettingsPreAmendmentFields} + * - After: {@link FeeSettingsPostAmendmentFields} + * + * @interface + * + * @category Ledger Entries + */ +type FeeSettings = FeeSettingsBase & (FeeSettingsPreAmendmentFields | FeeSettingsPostAmendmentFields); + +export default FeeSettings; diff --git a/src/common/libs/ledger/types/ledger/Ledger.ts b/src/common/libs/ledger/types/ledger/Ledger.ts new file mode 100644 index 000000000..95baf0634 --- /dev/null +++ b/src/common/libs/ledger/types/ledger/Ledger.ts @@ -0,0 +1,65 @@ +import { TransactionJson, TransactionMetadata } from '../transaction'; + +import { LedgerEntry } from './LedgerEntry'; + +/** + * A ledger is a block of transactions and shared state data. It has a unique + * header that describes its contents using cryptographic hashes. + * + * @category Ledger Entries + */ +export default interface Ledger { + /** The SHA-512Half of this ledger's state tree information. */ + account_hash: string; + /** All the state information in this ledger. */ + accountState?: LedgerEntry[]; + /** A bit-map of flags relating to the closing of this ledger. */ + close_flags: number; + /** + * The approximate time this ledger version closed, as the number of seconds + * since the Ripple Epoch of 2000-01-01 00:00:00. This value is rounded based + * on the close_time_resolution. + */ + close_time: number; + /** + * The approximate time this ledger was closed, in human-readable format. + * Always uses the UTC time zone. + */ + close_time_human: string; + /** + * An integer in the range [2,120] indicating the maximum number of seconds + * by which the close_time could be rounded. + */ + close_time_resolution: number; + /** Whether or not this ledger has been closed. */ + closed: boolean; + /** + * The SHA-512Half of this ledger version. This serves as a unique identifier + * for this ledger and all its contents. + */ + ledger_hash: string; + /** + * The ledger index of the ledger. Some API methods display this as a quoted + * integer; some display it as a native JSON number. + */ + ledger_index: string; + /** The approximate time at which the previous ledger was closed. */ + parent_close_time: number; + /** + * Unique identifying hash of the ledger that came immediately before this + * one. + */ + parent_hash: string; + /** Total number of XRP drops in the network, as a quoted integer. */ + total_coins: string; + /** Hash of the transaction information included in this ledger, as hex. */ + transaction_hash: string; + /** + * Transactions applied in this ledger version. By default, members are the + * transactions' identifying Hash strings. If the request specified expand as + * true, members are full representations of the transactions instead, in + * either JSON or binary depending on whether the request specified binary + * as true. + */ + transactions?: Array; +} diff --git a/src/common/libs/ledger/types/ledger/LedgerEntry.ts b/src/common/libs/ledger/types/ledger/LedgerEntry.ts new file mode 100644 index 000000000..620d9bd35 --- /dev/null +++ b/src/common/libs/ledger/types/ledger/LedgerEntry.ts @@ -0,0 +1,53 @@ +import AccountRoot from './AccountRoot'; +import Amendments from './Amendments'; +import AMM from './AMM'; +import Check from './Check'; +import DepositPreauth from './DepositPreauth'; +import DirectoryNode from './DirectoryNode'; +import Escrow from './Escrow'; +import FeeSettings from './FeeSettings'; +import LedgerHashes from './LedgerHashes'; +import NegativeUNL from './NegativeUNL'; +import Offer from './Offer'; +import PayChannel from './PayChannel'; +import RippleState from './RippleState'; +import SignerList from './SignerList'; +import Ticket from './Ticket'; + +type LedgerEntry = + | AccountRoot + | Amendments + | AMM + | Check + | DepositPreauth + | DirectoryNode + | Escrow + | FeeSettings + | LedgerHashes + | NegativeUNL + | Offer + | PayChannel + | RippleState + | SignerList + | Ticket; + +type LedgerEntryFilter = + | 'account' + | 'amendments' + | 'amm' + | 'check' + | 'deposit_preauth' + | 'did' + | 'directory' + | 'escrow' + | 'fee' + | 'hashes' + | 'nft_offer' + | 'nft_page' + | 'offer' + | 'payment_channel' + | 'signer_list' + | 'state' + | 'ticket'; + +export { LedgerEntry, LedgerEntryFilter }; diff --git a/src/common/libs/ledger/types/ledger/LedgerHashes.ts b/src/common/libs/ledger/types/ledger/LedgerHashes.ts new file mode 100644 index 000000000..e4f90bc3e --- /dev/null +++ b/src/common/libs/ledger/types/ledger/LedgerHashes.ts @@ -0,0 +1,23 @@ +import { BaseLedgerEntry, MissingPreviousTxnID } from './BaseLedgerEntry'; + +/** + * The LedgerHashes objects exist to make it possible to look up a previous + * ledger's hash with only the current ledger version and at most one lookup of + * a previous ledger version. + * + * @category Ledger Entries + */ +export default interface LedgerHashes extends BaseLedgerEntry, MissingPreviousTxnID { + /** The Ledger Index of the last entry in this object's Hashes array. */ + LastLedgerSequence?: number; + /** + * An array of up to 256 ledger hashes. The contents depend on which sub-type + * of LedgerHashes object this is. + */ + Hashes: string[]; + /** + * A bit-map of boolean flags for this object. No flags are defined for this + * type. + */ + Flags: number; +} diff --git a/src/common/libs/ledger/types/ledger/NFTokenOffer.ts b/src/common/libs/ledger/types/ledger/NFTokenOffer.ts new file mode 100644 index 000000000..83e4d637b --- /dev/null +++ b/src/common/libs/ledger/types/ledger/NFTokenOffer.ts @@ -0,0 +1,13 @@ +import { Amount } from '../common'; + +import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'; + +export interface NFTokenOffer extends BaseLedgerEntry, HasPreviousTxnID { + Amount: Amount; + Destination?: string; + Expiration: number; + Flags: number; + NFTokenOfferNode?: string; + Owner: string; + OwnerNode?: string; +} diff --git a/src/common/libs/ledger/types/ledger/NFTokenPage.ts b/src/common/libs/ledger/types/ledger/NFTokenPage.ts new file mode 100644 index 000000000..7b1fe2b60 --- /dev/null +++ b/src/common/libs/ledger/types/ledger/NFTokenPage.ts @@ -0,0 +1,15 @@ +import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'; + +export interface NFTokenPage extends BaseLedgerEntry, HasPreviousTxnID { + NextPageMin?: string; + NFTokens: { + NFToken: { + Flags: number; + Issuer: string; + NFTokenID: string; + NFTokenTaxon: number; + URI?: string; + }; + }[]; + PreviousPageMin?: string; +} diff --git a/src/common/libs/ledger/types/ledger/NegativeUNL.ts b/src/common/libs/ledger/types/ledger/NegativeUNL.ts new file mode 100644 index 000000000..b9566d7be --- /dev/null +++ b/src/common/libs/ledger/types/ledger/NegativeUNL.ts @@ -0,0 +1,27 @@ +import { BaseLedgerEntry, MissingPreviousTxnID } from './BaseLedgerEntry'; + +/** + * The NegativeUNL object type contains the current status of the Negative UNL, + * a list of trusted validators currently believed to be offline. + * + * @category Ledger Entries + */ +export default interface NegativeUNL extends BaseLedgerEntry, MissingPreviousTxnID { + /** + * A list of trusted validators that are currently disabled. + */ + DisabledValidators?: Array<{ + FirstLedgerSequence: number; + PublicKey: string; + }>; + /** + * The public key of a trusted validator that is scheduled to be disabled in + * the next flag ledger. + */ + ValidatorToDisable?: string; + /** + * The public key of a trusted validator in the Negative UNL that is + * scheduled to be re-enabled in the next flag ledger. + */ + ValidatorToReEnable?: string; +} diff --git a/src/common/libs/ledger/types/ledger/Offer.ts b/src/common/libs/ledger/types/ledger/Offer.ts new file mode 100644 index 000000000..c444b32f6 --- /dev/null +++ b/src/common/libs/ledger/types/ledger/Offer.ts @@ -0,0 +1,41 @@ +import { Amount } from '../common'; + +import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'; + +export default interface Offer extends BaseLedgerEntry, HasPreviousTxnID { + /** A bit-map of boolean flags enabled for this Offer. */ + Flags: number; + /** The address of the account that placed this Offer. */ + Account: string; + /** + * The Sequence value of the OfferCreate transaction that created this Offer + * object. Used in combination with the Account to identify this Offer. + */ + Sequence: number; + /** The remaining amount and type of currency requested by the Offer creator. */ + TakerPays: Amount; + /** + * The remaining amount and type of currency being provided by the Offer + * creator. + */ + TakerGets: Amount; + /** The ID of the Offer Directory that links to this Offer. */ + BookDirectory: string; + /** + * A hint indicating which page of the Offer Directory links to this object, + * in case the directory consists of multiple pages. + */ + BookNode: string; + /** + * A hint indicating which page of the Owner Directory links to this object, + * in case the directory consists of multiple pages. + */ + OwnerNode: string; + /** The time this Offer expires, in seconds since the Ripple Epoch. */ + Expiration?: number; +} + +export enum OfferFlags { + lsfPassive = 0x00010000, + lsfSell = 0x00020000, +} diff --git a/src/common/libs/ledger/types/ledger/PayChannel.ts b/src/common/libs/ledger/types/ledger/PayChannel.ts new file mode 100644 index 000000000..776151814 --- /dev/null +++ b/src/common/libs/ledger/types/ledger/PayChannel.ts @@ -0,0 +1,96 @@ +import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'; + +/** + * The PayChannel object type represents a payment channel. Payment channels + * enable small, rapid off-ledger payments of XRP that can be later reconciled + * with the consensus ledger. A payment channel holds a balance of XRP that can + * only be paid out to a specific destination address until the channel is + * closed. + * + * @category Ledger Entries + */ +export default interface PayChannel extends BaseLedgerEntry, HasPreviousTxnID { + /** + * The source address that owns this payment channel. This comes from the + * sending address of the transaction that created the channel. + */ + Account: string; + /** + * The destination address for this payment channel. While the payment + * channel is open, this address is the only one that can receive XRP from the + * channel. This comes from the Destination field of the transaction that + * created the channel. + */ + Destination: string; + /** + * Total XRP, in drops, that has been allocated to this channel. This + * includes XRP that has been paid to the destination address. This is + * initially set by the transaction that created the channel and can be + * increased if the source address sends a PaymentChannelFund transaction. + */ + Amount: string; + /** + * Total XRP, in drops, already paid out by the channel. The difference + * between this value and the Amount field is how much XRP can still be paid + * to the destination address with PaymentChannelClaim transactions. If the + * channel closes, the remaining difference is returned to the source address. + */ + Balance: string; + /** + * Public key, in hexadecimal, of the key pair that can be used to sign + * claims against this channel. This can be any valid secp256k1 or Ed25519 + * public key. This is set by the transaction that created the channel and + * must match the public key used in claims against the channel. The channel + * source address can also send XRP from this channel to the destination + * without signed claims. + */ + PublicKey: string; + /** + * Number of seconds the source address must wait to close the channel if + * it still has any XRP in it. Smaller values mean that the destination + * address has less time to redeem any outstanding claims after the source + * address requests to close the channel. Can be any value that fits in a + * 32-bit unsigned integer (0 to 2^32-1). This is set by the transaction that + * creates the channel. + */ + SettleDelay: number; + /** + * A hint indicating which page of the source address's owner directory links + * to this object, in case the directory consists of multiple pages. + */ + OwnerNode: string; + /** + * A bit-map of boolean flags enabled for this payment channel. Currently, + * the protocol defines no flags for PayChannel objects. + */ + Flags: number; + /** + * The mutable expiration time for this payment channel, in seconds since the + * Ripple Epoch. The channel is expired if this value is present and smaller + * than the previous ledger's close_time field. See Setting Channel Expiration + * for more details. + */ + Expiration?: number; + /** + * The immutable expiration time for this payment channel, in seconds since + * the Ripple Epoch. This channel is expired if this value is present and + * smaller than the previous ledger's close_time field. This is optionally + * set by the transaction that created the channel, and cannot be changed. + */ + CancelAfter?: number; + /** + * An arbitrary tag to further specify the source for this payment channel + * useful for specifying a hosted recipient at the owner's address. + */ + SourceTag?: number; + /** + * An arbitrary tag to further specify the destination for this payment + * channel, such as a hosted recipient at the destination address. + */ + DestinationTag?: number; + /** + * A hint indicating which page of the destination's owner directory links to + * this object, in case the directory consists of multiple pages. + */ + DestinationNode?: string; +} diff --git a/src/common/libs/ledger/types/ledger/RippleState.ts b/src/common/libs/ledger/types/ledger/RippleState.ts new file mode 100644 index 000000000..b8d2593d2 --- /dev/null +++ b/src/common/libs/ledger/types/ledger/RippleState.ts @@ -0,0 +1,77 @@ +import { IssuedCurrencyAmount } from '../common'; + +import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'; + +/** + * The RippleState object type connects two accounts in a single currency. + * + * @category Ledger Entries + */ +export default interface RippleState extends BaseLedgerEntry, HasPreviousTxnID { + /** A bit-map of boolean options enabled for this object. */ + Flags: number; + /** + * The balance of the trust line, from the perspective of the low account. A + * negative balance indicates that the low account has issued currency to the + * high account. The issuer is always the neutral value ACCOUNT_ONE. + */ + Balance: IssuedCurrencyAmount; + /** + * The limit that the low account has set on the trust line. The issuer is + * the address of the low account that set this limit. + */ + LowLimit: IssuedCurrencyAmount; + /** + * The limit that the high account has set on the trust line. The issuer is + * the address of the high account that set this limit. + */ + HighLimit: IssuedCurrencyAmount; + /** + * A hint indicating which page of the low account's owner directory links to + * this object, in case the directory consists of multiple pages. + */ + LowNode?: string; + /** + * A hint indicating which page of the high account's owner directory links + * to this object, in case the directory consists of multiple pages. + */ + HighNode?: string; + /** + * The inbound quality set by the low account, as an integer in the implied + * ratio LowQualityIn:1,000,000,000. As a special case, the value 0 is + * equivalent to 1 billion, or face value. + */ + LowQualityIn?: number; + /** + * The outbound quality set by the low account, as an integer in the implied + * ratio LowQualityOut:1,000,000,000. As a special case, the value 0 is + * equivalent to 1 billion, or face value. + */ + LowQualityOut?: number; + /** + * The inbound quality set by the high account, as an integer in the implied + * ratio HighQualityIn:1,000,000,000. As a special case, the value 0 is + * equivalent to 1 billion, or face value. + */ + HighQualityIn?: number; + /** + * The outbound quality set by the high account, as an integer in the implied + * ratio HighQualityOut:1,000,000,000. As a special case, the value 0 is + * equivalent to 1 billion, or face value. + */ + HighQualityOut?: number; +} + +export enum RippleStateFlags { + // True, if entry counts toward reserve. + lsfLowReserve = 0x00010000, + lsfHighReserve = 0x00020000, + lsfLowAuth = 0x00040000, + lsfHighAuth = 0x00080000, + lsfLowNoRipple = 0x00100000, + lsfHighNoRipple = 0x00200000, + // True, low side has set freeze flag + lsfLowFreeze = 0x00400000, + // True, high side has set freeze flag + lsfHighFreeze = 0x00800000, +} diff --git a/src/common/libs/ledger/types/ledger/SignerList.ts b/src/common/libs/ledger/types/ledger/SignerList.ts new file mode 100644 index 000000000..4cd853096 --- /dev/null +++ b/src/common/libs/ledger/types/ledger/SignerList.ts @@ -0,0 +1,40 @@ +import { SignerEntry } from '../common'; + +import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'; + +/** + * The SignerList object type represents a list of parties that, as a group, + * are authorized to sign a transaction in place of an individual account. You + * can create, replace, or remove a signer list using a SignerListSet + * transaction. + * + * @category Ledger Entries + */ +export default interface SignerList extends BaseLedgerEntry, HasPreviousTxnID { + /** + * A bit-map of Boolean flags enabled for this signer list. For more + * information, see SignerList Flags. + */ + Flags: number; + /** + * A hint indicating which page of the owner directory links to this object, + * in case the directory consists of multiple pages. + */ + OwnerNode: string; + /** + * An array of Signer Entry objects representing the parties who are part of + * this signer list. + */ + SignerEntries: SignerEntry[]; + /** + * An ID for this signer list. Currently always set to 0. If a future + * amendment allows multiple signer lists for an account, this may change. + */ + SignerListID: number; + /** + * A target number for signer weights. To produce a valid signature for the + * owner of this SignerList, the signers must provide valid signatures whose + * weights sum to this value or more. + */ + SignerQuorum: number; +} diff --git a/src/common/libs/ledger/types/ledger/Ticket.ts b/src/common/libs/ledger/types/ledger/Ticket.ts new file mode 100644 index 000000000..045b55c41 --- /dev/null +++ b/src/common/libs/ledger/types/ledger/Ticket.ts @@ -0,0 +1,25 @@ +import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'; + +/** + * The Ticket object type represents a Ticket, which tracks an account sequence + * number that has been set aside for future use. You can create new tickets + * with a TicketCreate transaction. + * + * @category Ledger Entries + */ +export default interface Ticket extends BaseLedgerEntry, HasPreviousTxnID { + /** The account that owns this Ticket. */ + Account: string; + /** + * A bit-map of Boolean flags enabled for this Ticket. Currently, there are + * no flags defined for Tickets. + */ + Flags: number; + /** + * A hint indicating which page of the owner directory links to this object, + * in case the directory consists of multiple pages. + */ + OwnerNode: string; + /** The Sequence Number this Ticket sets aside. */ + TicketSequence: number; +} diff --git a/src/common/libs/ledger/types/ledger/index.ts b/src/common/libs/ledger/types/ledger/index.ts new file mode 100644 index 000000000..0c8b0a393 --- /dev/null +++ b/src/common/libs/ledger/types/ledger/index.ts @@ -0,0 +1,48 @@ +import AccountRoot from './AccountRoot'; +import Amendments, { Majority } from './Amendments'; +import AMM, { VoteSlot } from './AMM'; +import Check from './Check'; +import DepositPreauth from './DepositPreauth'; +import DirectoryNode from './DirectoryNode'; +import Escrow from './Escrow'; +import FeeSettings, { FeeSettingsPreAmendmentFields, FeeSettingsPostAmendmentFields } from './FeeSettings'; +import Ledger from './Ledger'; +import { LedgerEntry, LedgerEntryFilter } from './LedgerEntry'; +import LedgerHashes from './LedgerHashes'; +import NegativeUNL from './NegativeUNL'; +import { NFTokenOffer } from './NFTokenOffer'; +import { NFTokenPage } from './NFTokenPage'; +import Offer, { OfferFlags } from './Offer'; +import PayChannel from './PayChannel'; +import RippleState, { RippleStateFlags } from './RippleState'; +import SignerList from './SignerList'; +import Ticket from './Ticket'; + +export { + AccountRoot, + Amendments, + AMM, + Check, + DepositPreauth, + DirectoryNode, + Escrow, + FeeSettings, + FeeSettingsPreAmendmentFields, + FeeSettingsPostAmendmentFields, + Ledger, + LedgerEntryFilter, + LedgerEntry, + LedgerHashes, + Majority, + NegativeUNL, + NFTokenOffer, + NFTokenPage, + Offer, + OfferFlags, + PayChannel, + RippleState, + RippleStateFlags, + SignerList, + Ticket, + VoteSlot, +}; diff --git a/src/common/libs/ledger/types/methods/accountChannels.ts b/src/common/libs/ledger/types/methods/accountChannels.ts new file mode 100644 index 000000000..89b832950 --- /dev/null +++ b/src/common/libs/ledger/types/methods/accountChannels.ts @@ -0,0 +1,89 @@ +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +export interface Channel { + account: string; + amount: string; + balance: string; + channel_id: string; + destination_account: string; + settle_delay: number; + public_key?: string; + public_key_hex?: string; + expiration?: number; + cancel_after?: number; + source_tab?: number; + destination_tag?: number; +} + +/** + * The account_channels method returns information about an account's Payment + * Channels. This includes only channels where the specified account is the + * channel's source, not the destination. (A channel's "source" and "owner" are + * the same.) All information retrieved is relative to a particular version of + * the ledger. Returns an {@link AccountChannelsResponse}. + * + * @category Requests + */ +export interface AccountChannelsRequest extends BaseRequest, LookupByLedgerRequest { + command: 'account_channels'; + /** + * The unique identifier of an account, typically the account's address. The + * request returns channels where this account is the channel's owner/source. + * + */ + account: string; + /** + * The unique identifier of an account, typically the account's address. If + * provided, filter results to payment channels whose destination is this + * account. + */ + destination_account?: string; + /** + * Limit the number of transactions to retrieve. Cannot be less than 10 or + * more than 400. The default is 200. + */ + limit?: number; + /** + * Value from a previous paginated response. Resume retrieving data where + * that response left off. + */ + marker?: unknown; +} + +/** + * The expected response from an {@link AccountChannelsRequest}. + * + * @category Responses + */ +export interface AccountChannelsResponse extends BaseResponse { + /** + * The address of the source/owner of the payment channels. This + * corresponds to the account field of the request. + */ + account: string; + /** Payment channels owned by this account. */ + channels: Channel[]; + /** + * The identifying hash of the ledger version used to generate this + * response. + */ + ledger_hash: string; + /** The ledger index of the ledger version used to generate this response. */ + ledger_index: number; + /** + * If true, the information in this response comes from a validated ledger + * version. Otherwise, the information is subject to change. + */ + validated?: boolean; + /** + * The limit to how many channel objects were actually returned by this + * request. + */ + limit?: number; + /** + * Server-defined value for pagination. Pass this to the next call to + * resume getting results where this call left off. Omitted when there are + * no additional pages after this one. + */ + marker?: unknown; +} diff --git a/src/common/libs/ledger/types/methods/accountCurrencies.ts b/src/common/libs/ledger/types/methods/accountCurrencies.ts new file mode 100644 index 000000000..6812a388f --- /dev/null +++ b/src/common/libs/ledger/types/methods/accountCurrencies.ts @@ -0,0 +1,41 @@ +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +/** + * The `account_currencies` command retrieves a list of currencies that an + * account can send or receive, based on its trust lines. Expects an + * {@link AccountCurrenciesResponse}. + * + * @category Requests + */ +export interface AccountCurrenciesRequest extends BaseRequest, LookupByLedgerRequest { + command: 'account_currencies'; + /** A unique identifier for the account, most commonly the account's address. */ + account: string; + /** + * If true, then the account field only accepts a public key or XRP Ledger + * address. Otherwise, account can be a secret or passphrase (not + * recommended). The default is false. + */ + strict?: boolean; +} + +/** + * The expected response from an {@link AccountCurrenciesRequest}. + * + * @category Responses + */ +export interface AccountCurrenciesResponse extends BaseResponse { + /** + * The identifying hash of the ledger version used to retrieve this data, + * as hex. + */ + ledger_hash?: string; + /** The ledger index of the ledger version used to retrieve this data. */ + ledger_index: number; + /** Array of Currency Codes for currencies that this account can receive. */ + receive_currencies: string[]; + /** Array of Currency Codes for currencies that this account can send. */ + send_currencies: string[]; + /** If true, this data comes from a validated ledger. */ + validated: boolean; +} diff --git a/src/common/libs/ledger/types/methods/accountInfo.ts b/src/common/libs/ledger/types/methods/accountInfo.ts new file mode 100644 index 000000000..ee5515bf0 --- /dev/null +++ b/src/common/libs/ledger/types/methods/accountInfo.ts @@ -0,0 +1,180 @@ +import { AccountRoot, SignerList } from '../ledger'; + +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +/** + * The `account_info` command retrieves information about an account, its + * activity, and its XRP balance. All information retrieved is relative to a + * particular version of the ledger. Returns an {@link AccountInfoResponse}. + * + * @category Requests + */ +export interface AccountInfoRequest extends BaseRequest, LookupByLedgerRequest { + command: 'account_info'; + /** A unique identifier for the account, most commonly the account's address. */ + account: string; + /** + * Whether to get info about this account's queued transactions. Can only be + * used when querying for the data from the current open ledger. Not available + * from servers in Reporting Mode. + */ + queue?: boolean; + /** + * Request SignerList objects associated with this account. + */ + signer_lists?: boolean; + /** + * If true, then the account field only accepts a public key or XRP Ledger + * address. Otherwise, account can be a secret or passphrase (not + * recommended). The default is false. + */ + strict?: boolean; +} + +export interface AccountQueueTransaction { + /** + * Whether this transaction changes this address's ways of authorizing + * transactions. + */ + auth_change: boolean; + /** The Transaction Cost of this transaction, in drops of XRP. */ + fee: string; + /** + * The transaction cost of this transaction, relative to the minimum cost for + * this type of transaction, in fee levels. + */ + fee_level: string; + /** The maximum amount of XRP, in drops, this transaction could send or destroy. */ + max_spend_drops: string; + /** The Sequence Number of this transaction. */ + seq: number; +} + +export interface AccountQueueData { + /** Number of queued transactions from this address. */ + txn_count: number; + /** + * Whether a transaction in the queue changes this address's ways of + * authorizing transactions. If true, this address can queue no further + * transactions until that transaction has been executed or dropped from the + * queue. + */ + auth_change_queued?: boolean; + /** The lowest Sequence Number among transactions queued by this address. */ + lowest_sequence?: number; + /** The highest Sequence Number among transactions queued by this address. */ + highest_sequence?: number; + /** + * Integer amount of drops of XRP that could be debited from this address if + * every transaction in the queue consumes the maximum amount of XRP possible. + */ + max_spend_drops_total?: string; + /** Information about each queued transaction from this address. */ + transactions?: AccountQueueTransaction[]; +} + +export interface AccountInfoAccountFlags { + /** + * Enable rippling on this address's trust lines by default. Required for issuing addresses; discouraged for others. + */ + defaultRipple: boolean; + /** + * This account can only receive funds from transactions it sends, and from preauthorized accounts. + * (It has DepositAuth enabled.) + */ + depositAuth: boolean; + /** + * Disallows use of the master key to sign transactions for this account. + */ + disableMasterKey: boolean; + /** + * Disallow incoming Checks from other accounts. + */ + disallowIncomingCheck?: boolean; + /** + * Disallow incoming NFTOffers from other accounts. Part of the DisallowIncoming amendment. + */ + disallowIncomingNFTokenOffer?: boolean; + /** + * Disallow incoming PayChannels from other accounts. Part of the DisallowIncoming amendment. + */ + disallowIncomingPayChan?: boolean; + /** + * Disallow incoming Trustlines from other accounts. Part of the DisallowIncoming amendment. + */ + disallowIncomingTrustline?: boolean; + /** + * Client applications should not send XRP to this account. Not enforced by rippled. + */ + disallowIncomingXRP: boolean; + /** + * All assets issued by this address are frozen. + */ + globalFreeze: boolean; + /** + * This address cannot freeze trust lines connected to it. Once enabled, cannot be disabled. + */ + noFreeze: boolean; + /** + * The account has used its free SetRegularKey transaction. + */ + passwordSpent: boolean; + /** + * This account must individually approve other users for those users to hold this account's issued currencies. + */ + requireAuthorization: boolean; + /** + * Requires incoming payments to specify a Destination Tag. + */ + requireDestinationTag: boolean; + /** + * This address can claw back issued IOUs. Once enabled, cannot be disabled. + */ + allowTrustLineClawback: boolean; +} + +/** + * Response expected from an {@link AccountInfoRequest}. + * + * @category Responses + */ +export interface AccountInfoResponse extends BaseResponse { + /** + * The AccountRoot ledger object with this account's information, as stored + * in the ledger. + * If requested, also includes Array of SignerList ledger objects + * associated with this account for Multi-Signing. Since an account can own + * at most one SignerList, this array must have exactly one member if it is + * present. + */ + account_data: AccountRoot & { signer_lists?: SignerList[] }; + + /** + * A map of account flags parsed out. This will only be available for rippled nodes 1.11.0 and higher. + */ + account_flags?: AccountInfoAccountFlags; + /** + * The ledger index of the current in-progress ledger, which was used when + * retrieving this information. + */ + ledger_current_index?: number; + /** + * The ledger index of the ledger version used when retrieving this + * information. The information does not contain any changes from ledger + * versions newer than this one. + */ + ledger_index?: number; + /** + * Information about queued transactions sent by this account. This + * information describes the state of the local rippled server, which may be + * different from other servers in the peer-to-peer XRP Ledger network. Some + * fields may be omitted because the values are calculated "lazily" by the + * queuing mechanism. + */ + queue_data?: AccountQueueData; + /** + * True if this data is from a validated ledger version; if omitted or set + * to false, this data is not final. + */ + validated?: boolean; +} diff --git a/src/common/libs/ledger/types/methods/accountLines.ts b/src/common/libs/ledger/types/methods/accountLines.ts new file mode 100644 index 000000000..2198301b9 --- /dev/null +++ b/src/common/libs/ledger/types/methods/accountLines.ts @@ -0,0 +1,137 @@ +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +export interface AccountLinesTrustline { + /** The unique Address of the counterparty to this trust line. */ + account: string; + /** + * Representation of the numeric balance currently held against this line. A + * positive balance means that the perspective account holds value; a negative + * Balance means that the perspective account owes value. + */ + balance: string; + /** A Currency Code identifying what currency this trust line can hold. */ + currency: string; + /** + * The maximum amount of the given currency that this account is willing to + * owe the peer account. + */ + limit: string; + /** + * The maximum amount of currency that the issuer account is willing to owe + * the perspective account. + */ + limit_peer: string; + /** + * Rate at which the account values incoming balances on this trust line, as + * a ratio of this value per 1 billion units. (For example, a value of 500 + * million represents a 0.5:1 ratio.) As a special case, 0 is treated as a + * 1:1 ratio. + */ + quality_in: number; + /** + * Rate at which the account values outgoing balances on this trust line, as + * a ratio of this value per 1 billion units. (For example, a value of 500 + * million represents a 0.5:1 ratio.) As a special case, 0 is treated as a 1:1 + * ratio. + */ + quality_out: number; + /** + * If true, this account has enabled the No Ripple flag for this trust line. + * If present and false, this account has disabled the No Ripple flag, but, + * because the account also has the Default Ripple flag enabled, that is not + * considered the default state. If omitted, the account has the No Ripple + * flag disabled for this trust line and Default Ripple disabled. + */ + no_ripple?: boolean; + /** + * If true, the peer account has enabled the No Ripple flag for this trust + * line. If present and false, this account has disabled the No Ripple flag, + * but, because the account also has the Default Ripple flag enabled, that is + * not considered the default state. If omitted, the account has the No Ripple + * flag disabled for this trust line and Default Ripple disabled. + */ + no_ripple_peer?: boolean; + /** If true, this account has authorized this trust line. The default is false. */ + authorized?: boolean; + /** If true, the peer account has authorized this trust line. The default is false. */ + peer_authorized?: boolean; + /** If true, this account has frozen this trust line. The default is false. */ + freeze?: boolean; + /** + * If true, the peer account has frozen this trust line. The default is + * false. + */ + freeze_peer?: boolean; + /** + * self added + */ + obligation?: boolean; +} + +/** + * The account_lines method returns information about an account's trust lines, + * including balances in all non-XRP currencies and assets. All information + * retrieved is relative to a particular version of the ledger. Expects an + * {@link AccountLinesResponse}. + * + * @category Requests + */ +export interface AccountLinesRequest extends BaseRequest, LookupByLedgerRequest { + command: 'account_lines'; + /** A unique identifier for the account, most commonly the account's Address. */ + account: string; + /** + * The Address of a second account. If provided, show only lines of trust + * connecting the two accounts. + */ + peer?: string; + /** + * Limit the number of trust lines to retrieve. The server is not required to + * honor this value. Must be within the inclusive range 10 to 400. + */ + limit?: number; + /** + * Value from a previous paginated response. Resume retrieving data where + * that response left off. + */ + marker?: unknown; +} + +/** + * Response expected from an {@link AccountLinesRequest}. + * + * @category Responses + */ +export interface AccountLinesResponse extends BaseResponse { + /** + * Unique Address of the account this request corresponds to. This is the + * "perspective account" for purpose of the trust lines. + */ + account: string; + /** + * Array of trust line objects. If the number of trust lines is large, only + * returns up to the limit at a time. + */ + lines: AccountLinesTrustline[]; + /** + * The ledger index of the current open ledger, which was used when + * retrieving this information. + */ + ledger_current_index?: number; + /** + * The ledger index of the ledger version that was used when retrieving + * this data. + */ + ledger_index?: number; + /** + * The identifying hash the ledger version that was used when retrieving + * this data. + */ + ledger_hash?: string; + /** + * Server-defined value indicating the response is paginated. Pass this to + * the next call to resume where this call left off. Omitted when there are + * No additional pages after this one. + */ + marker?: unknown; +} diff --git a/src/common/libs/ledger/types/methods/accountNFTs.ts b/src/common/libs/ledger/types/methods/accountNFTs.ts new file mode 100644 index 000000000..9e5e3d0f5 --- /dev/null +++ b/src/common/libs/ledger/types/methods/accountNFTs.ts @@ -0,0 +1,70 @@ +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +/** + * The `account_nfts` method retrieves all of the NFTs currently owned by the + * specified account. + * + * @category Requests + */ +export interface AccountNFTsRequest extends BaseRequest, LookupByLedgerRequest { + command: 'account_nfts'; + /** + * The unique identifier of an account, typically the account's address. The + * request returns NFTs owned by this account. + */ + account: string; + /** + * Limit the number of NFTokens to retrieve. + */ + limit?: number; + /** + * Value from a previous paginated response. Resume retrieving data where + * that response left off. + */ + marker?: unknown; +} + +/** + * One NFToken that might be returned from an {@link AccountNFTsRequest}. + * + * @category Responses + */ +export interface AccountNFToken { + Flags: number; + Issuer: string; + NFTokenID: string; + NFTokenTaxon: number; + URI?: string; + nft_serial: number; +} + +/** + * Response expected from an {@link AccountNFTsRequest}. + * + * @category Responses + */ +export interface AccountNFTsResponse extends BaseResponse { + /** + * The account requested. + */ + account: string; + /** + * A list of NFTs owned by the specified account. + */ + account_nfts: AccountNFToken[]; + /** + * The ledger index of the current open ledger, which was used when + * retrieving this information. + */ + ledger_current_index: number; + /** If true, this data comes from a validated ledger. */ + validated: boolean; + /** + * Server-defined value indicating the response is paginated. Pass this to + * the next call to resume where this call left off. Omitted when there are + * No additional pages after this one. + */ + marker?: string; + /** The limit that was used to fulfill this request. */ + limit?: number; +} diff --git a/src/common/libs/ledger/types/methods/accountObjects.ts b/src/common/libs/ledger/types/methods/accountObjects.ts new file mode 100644 index 000000000..a5c7b7c0c --- /dev/null +++ b/src/common/libs/ledger/types/methods/accountObjects.ts @@ -0,0 +1,88 @@ +import { Amendments, FeeSettings, LedgerHashes } from '../ledger'; +import { LedgerEntry, LedgerEntryFilter } from '../ledger/LedgerEntry'; + +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +export type AccountObjectType = Exclude; +/** + * The account_objects command returns the raw ledger format for all objects + * owned by an account. For a higher-level view of an account's trust lines and + * balances, see the account_lines method instead. Expects a response in the + * form of an {@link AccountObjectsResponse}. + * + * @category Requests + */ +export interface AccountObjectsRequest extends BaseRequest, LookupByLedgerRequest { + command: 'account_objects'; + /** A unique identifier for the account, most commonly the account's address. */ + account: string; + /** + * If included, filter results to include only this type of ledger object. + */ + type?: AccountObjectType; + /** + * If true, the response only includes objects that would block this account + * from being deleted. The default is false. + */ + deletion_blockers_only?: boolean; + /** + * The maximum number of objects to include in the results. Must be within + * the inclusive range 10 to 400 on non-admin connections. The default is 200. + */ + limit?: number; + /** + * Value from a previous paginated response. Resume retrieving data where + * that response left off. + */ + marker?: unknown; +} + +/** + * Account Objects can be a Check, a DepositPreauth, an Escrow, an Offer, a + * PayChannel, a SignerList, a Ticket, or a RippleState. + */ +export type AccountObject = Exclude; + +/** + * Response expected from an {@link AccountObjectsRequest}. + * + * @category Responses + */ +export interface AccountObjectsResponse extends BaseResponse { + /** Unique Address of the account this request corresponds to. */ + account: string; + /** + * Array of objects owned by this account. Each object is in its raw + * ledger format. + */ + account_objects: AccountObject[]; + /** + * The identifying hash of the ledger that was used to generate this + * response. + */ + ledger_hash?: string; + /** + * The ledger index of the ledger version that was used to generate this + * response. + */ + ledger_index?: number; + /** + * The ledger index of the current in-progress ledger version, which was + * used to generate this response. + */ + ledger_current_index?: number; + /** The limit that was used in this request, if any. */ + limit?: number; + /** + * Server-defined value indicating the response is paginated. Pass this to + * the next call to resume where this call left off. Omitted when there are + * no additional pages after this one. + */ + marker?: string; + /** + * If included and set to true, the information in this response comes from + * a validated ledger version. Otherwise, the information is subject to + * change. + */ + validated?: boolean; +} diff --git a/src/common/libs/ledger/types/methods/accountOffers.ts b/src/common/libs/ledger/types/methods/accountOffers.ts new file mode 100644 index 000000000..d521b8a1a --- /dev/null +++ b/src/common/libs/ledger/types/methods/accountOffers.ts @@ -0,0 +1,96 @@ +import { Amount } from '../common'; + +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +/** + * The account_offers method retrieves a list of offers made by a given account + * that are outstanding as of a particular ledger version. Expects a response in + * the form of a {@link AccountOffersResponse}. + * + * @category Requests + */ +export interface AccountOffersRequest extends BaseRequest, LookupByLedgerRequest { + command: 'account_offers'; + /** A unique identifier for the account, most commonly the account's Address. */ + account: string; + /** + * Limit the number of transactions to retrieve. The server is not required + * to honor this value. Must be within the inclusive range 10 to 400. + */ + limit?: number; + /** + * Value from a previous paginated response. Resume retrieving data where + * that response left off. + */ + marker?: unknown; + /** + * If true, then the account field only accepts a public key or XRP Ledger + * address. Otherwise, account can be a secret or passphrase (not + * recommended). The default is false. + */ + strict?: boolean; +} + +export interface AccountOffer { + /** Options set for this offer entry as bit-flags. */ + flags: number; + /** Sequence number of the transaction that created this entry. */ + seq: number; + /** + * The amount the account placing this Offer receives. + */ + taker_gets: Amount; + /** + * The amount the account placing this Offer pays. + */ + taker_pays: Amount; + /** + * The exchange rate of the Offer, as the ratio of the original taker_pays + * divided by the original taker_gets. When executing offers, the offer with + * the most favorable (lowest) quality is consumed first; offers with the same + * quality are executed from oldest to newest. + */ + quality: string; + /** + * A time after which this offer is considered unfunded, as the number of + * seconds since the Ripple Epoch. See also: Offer Expiration. + */ + expiration?: number; +} + +/** + * Response expected from an {@link AccountOffersRequest}. + * + * @category Responses + */ +export interface AccountOffersResponse extends BaseResponse { + /** Unique Address identifying the account that made the offers. */ + account: string; + /** + * Array of objects, where each object represents an offer made by this + * account that is outstanding as of the requested ledger version. If the + * number of offers is large, only returns up to limit at a time. + */ + offers?: AccountOffer[]; + /** + * The ledger index of the current in-progress ledger version, which was + * used when retrieving this data. + */ + ledger_current_index?: number; + /** + * The ledger index of the ledger version that was used when retrieving + * this data, as requested. + */ + ledger_index?: number; + /** + * The identifying hash of the ledger version that was used when retrieving + * this data. + */ + ledger_hash?: string; + /** + * Server-defined value indicating the response is paginated. Pass this to + * the next call to resume where this call left off. Omitted when there are + * no pages of information after this one. + */ + marker?: unknown; +} diff --git a/src/common/libs/ledger/types/methods/accountTx.ts b/src/common/libs/ledger/types/methods/accountTx.ts new file mode 100644 index 000000000..d2cb42b05 --- /dev/null +++ b/src/common/libs/ledger/types/methods/accountTx.ts @@ -0,0 +1,108 @@ +import { LedgerMarker, ResponseOnlyTxInfo } from '../common'; + +import { TransactionJson, TransactionMetadata } from '../transaction'; + +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +/** + * The account_tx method retrieves a list of transactions that involved the + * specified account. Expects a response in the form of a {@link + * AccountTxResponse}. + * + * @category Requests + */ +export interface AccountTxRequest extends BaseRequest, LookupByLedgerRequest { + command: 'account_tx'; + /** A unique identifier for the account, most commonly the account's address. */ + account: string; + /** + * Use to specify the earliest ledger to include transactions from. A value + * of -1 instructs the server to use the earliest validated ledger version + * available. + */ + ledger_index_min?: number; + /** + * Use to specify the most recent ledger to include transactions from. A + * value of -1 instructs the server to use the most recent validated ledger + * version available. + */ + ledger_index_max?: number; + /** + * If true, return transactions as hex strings instead of JSON. The default is + * false. + */ + binary?: boolean; + /** + * If true, returns values indexed with the oldest ledger first. Otherwise, + * the results are indexed with the newest ledger first. + */ + forward?: boolean; + /** + * Default varies. Limit the number of transactions to retrieve. The server + * is not required to honor this value. + */ + limit?: number; + /** + * Value from a previous paginated response. Resume retrieving data where + * that response left off. This value is stable even if there is a change in + * the server's range of available ledgers. + */ + marker?: unknown; +} + +export interface AccountTxTransaction { + /** The ledger index of the ledger version that included this transaction. */ + ledger_index: number; + /** + * If binary is True, then this is a hex string of the transaction metadata. + * Otherwise, the transaction metadata is included in JSON format. + */ + meta: string | TransactionMetadata; + /** JSON object defining the transaction. */ + tx?: TransactionJson & ResponseOnlyTxInfo; + /** Unique hashed String representing the transaction. */ + tx_blob?: string; + /** + * Whether or not the transaction is included in a validated ledger. Any + * transaction not yet in a validated ledger is subject to change. + */ + validated: boolean; +} + +/** + * Expected response from an {@link AccountTxRequest}. + * + * @category Responses + */ +export interface AccountTxResponse extends BaseResponse { + /** Unique Address identifying the related account. */ + account: string; + /** + * The ledger index of the earliest ledger actually searched for + * transactions. + */ + ledger_index_min: number; + /** + * The ledger index of the most recent ledger actually searched for + * transactions. + */ + ledger_index_max: number; + /** The limit value used in the request. */ + limit: number; + /** + * Server-defined value indicating the response is paginated. Pass this + * to the next call to resume where this call left off. + */ + marker?: LedgerMarker; + /** + * Array of transactions matching the request's criteria, as explained + * below. + */ + transactions: AccountTxTransaction[]; + /** + * If included and set to true, the information in this response comes from + * a validated ledger version. Otherwise, the information is subject to + * change. + */ + validated?: boolean; +} diff --git a/src/common/libs/ledger/types/methods/ammInfo.ts b/src/common/libs/ledger/types/methods/ammInfo.ts new file mode 100644 index 000000000..fd8ccc3d9 --- /dev/null +++ b/src/common/libs/ledger/types/methods/ammInfo.ts @@ -0,0 +1,147 @@ +import { Amount, Currency, IssuedCurrencyAmount } from '../common'; + +import { BaseRequest, BaseResponse } from './baseMethod'; + +/** + * The `amm_info` method gets information about an Automated Market Maker (AMM) instance. + * Returns an {@link AMMInfoResponse}. + * + * @category Requests + */ +export interface AMMInfoRequest extends BaseRequest { + command: 'amm_info'; + + /** + * The address of the AMM Account to look up. + */ + amm_account?: string; + + /** + * One of the assets of the AMM pool to look up. + */ + asset?: Currency; + + /** + * The other asset of the AMM pool. + */ + asset2?: Currency; +} + +/** + * Response expected from an {@link AMMInfoRequest}. + * + * @category Responses + */ +export interface AMMInfoResponse extends BaseResponse { + amm: { + /** + * The address of the AMM Account. + */ + account: string; + + /** + * The total amount of one asset in the AMM's pool. + * (Note: This could be asset or asset2 from the request) + */ + amount: Amount; + + /** + * The total amount of the other asset in the AMM's pool. + * (Note: This could be asset or asset2 from the request) + */ + amount2: Amount; + + /** + * (Omitted for XRP) If true, the amount currency is currently frozen for asset. + */ + asset_frozen?: boolean; + + /** + * (Omitted for XRP) If true, the amount currency is currently frozen for asset2. + */ + asset2_frozen?: boolean; + + /** + * (May be omitted) An Auction Slot Object describing the current auction slot holder, if there is one. + */ + auction_slot?: { + /** + * The address of the account that owns the auction slot. + */ + account: string; + + /** + * A list of additional accounts that the auction slot holder has designated as being eligible + * of the discounted trading fee. + * Each member of this array is an object with one field, account. + */ + auth_accounts: Array<{ + account: string; + }>; + + /** + * The discounted trading fee that applies to the auction slot holder, and any eligible accounts + * when trading against this AMM. + * This is always 0. + */ + discounted_fee: number; + + /** + * The ISO 8601 UTC timestamp after which this auction slot expires. + * After expired, the auction slot does not apply (but the data can remain in the ledger + * until another transaction replaces it or cleans it up). + */ + expiration: string; + + /** + * The amount, in LP Tokens, that the auction slot holder paid to win the auction slot. + * This affects the price to outbid the current slot holder. + */ + price: IssuedCurrencyAmount; + + /** + * The current 72-minute time interval this auction slot is in, from 0 to 19. + * The auction slot expires after 24 hours (20 intervals of 72 minutes) + */ + time_interval: number; + }; + + /** + * The total amount of this AMM's LP Tokens outstanding. + */ + lp_token: IssuedCurrencyAmount; + + /** + * The AMM's current trading fee, in units of 1/100,000; a value of 1 is equivalent to a 0.001% fee. + */ + trading_fee: number; + + /** + * (May be omitted) The current votes for the AMM's trading fee, as Vote Slot Objects. + */ + vote_slots?: Array<{ + account: string; + trading_fee: number; + vote_weight: number; + }>; + }; + + /** + * The identifying hash of the ledger that was used to generate this + * response. + */ + ledger_hash?: string; + + /** + * The ledger index of the ledger version that was used to generate this + * response. + */ + ledger_index?: number; + + /** + * If included and set to true, the information in this response comes from + * a validated ledger version. Otherwise, the information is subject to + * change. + */ + validated?: boolean; +} diff --git a/src/common/libs/ledger/types/methods/baseMethod.ts b/src/common/libs/ledger/types/methods/baseMethod.ts new file mode 100644 index 000000000..4269e13b6 --- /dev/null +++ b/src/common/libs/ledger/types/methods/baseMethod.ts @@ -0,0 +1,38 @@ +import { LedgerIndex } from '../common'; + +import type { Request } from '.'; + +export interface BaseRequest { + [x: string]: unknown; + id?: string; + command: string; + api_version?: number; +} + +export interface LookupByLedgerRequest { + ledger_hash?: string; + ledger_index?: LedgerIndex; +} + +export interface ResponseWarning { + id: number; + message: string; + details?: { [key: string]: string }; +} + +export interface BaseResponse { + id: string; + __replyMs: number; + __command: any; + __networkId: number; + inLedger: any; +} + +export interface ErrorResponse extends BaseResponse { + status: 'error'; + type: 'response' | string; + error: string; + error_code?: string; + error_message?: string; + request: Request; +} diff --git a/src/common/libs/ledger/types/methods/bookOffers.ts b/src/common/libs/ledger/types/methods/bookOffers.ts new file mode 100644 index 000000000..e2b6cd982 --- /dev/null +++ b/src/common/libs/ledger/types/methods/bookOffers.ts @@ -0,0 +1,94 @@ +import { Amount } from '../common'; +import { Offer } from '../ledger'; + +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +export interface BookOfferCurrency { + currency: string; + issuer?: string; +} + +/** + * The book_offers method retrieves a list of offers, also known as the order. + * Book, between two currencies. Returns an {@link BookOffersResponse}. + * + * @category Requests + */ +export interface BookOffersRequest extends BaseRequest, LookupByLedgerRequest { + command: 'book_offers'; + /** + * If provided, the server does not provide more than this many offers in the + * results. The total number of results returned may be fewer than the limit, + * because the server omits unfunded offers. + */ + limit?: number; + /** + * The Address of an account to use as a perspective. Unfunded offers placed + * by this account are always included in the response. + */ + taker?: string; + /** + * Specification of which currency the account taking the offer would + * receive, as an object with currency and issuer fields (omit issuer for + * XRP), like currency amounts. + */ + taker_gets: BookOfferCurrency; + /** + * Specification of which currency the account taking the offer would pay, as + * an object with currency and issuer fields (omit issuer for XRP), like + * currency amounts. + */ + taker_pays: BookOfferCurrency; +} + +export interface BookOffer extends Offer { + /** + * Amount of the TakerGets currency the side placing the offer has available + * to be traded. (XRP is represented as drops; any other currency is + * represented as a decimal value.) If a trader has multiple offers in the + * same book, only the highest-ranked offer includes this field. + */ + owner_funds?: string; + /** + * The maximum amount of currency that the taker can get, given the funding + * status of the offer. + */ + taker_gets_funded?: Amount; + /** + * The maximum amount of currency that the taker would pay, given the funding + * status of the offer. + */ + taker_pays_funded?: Amount; + /** + * The exchange rate, as the ratio taker_pays divided by taker_gets. For + * fairness, offers that have the same quality are automatically taken + * first-in, first-out. + */ + quality?: string; +} + +/** + * Expected response from a {@link BookOffersRequest}. + * + * @category Responses + */ +export interface BookOffersResponse extends BaseResponse { + /** + * The ledger index of the current in-progress ledger version, which was + * used to retrieve this information. + */ + ledger_current_index?: number; + /** + * The ledger index of the ledger version that was used when retrieving + * this data, as requested. + */ + ledger_index?: number; + /** + * The identifying hash of the ledger version that was used when retrieving + * this data, as requested. + */ + ledger_hash?: string; + /** Array of offer objects, each of which has the fields of an Offer object. */ + offers: BookOffer[]; + validated?: boolean; +} diff --git a/src/common/libs/ledger/types/methods/channelVerify.ts b/src/common/libs/ledger/types/methods/channelVerify.ts new file mode 100644 index 000000000..c8d61e6ea --- /dev/null +++ b/src/common/libs/ledger/types/methods/channelVerify.ts @@ -0,0 +1,39 @@ +import { BaseRequest, BaseResponse } from './baseMethod'; + +/** + * The `channel_verify` method checks the validity of a signature that can be + * used to redeem a specific amount of XRP from a payment channel. Expects a + * response in the form of a {@link ChannelVerifyResponse}. + * + * @category Requests + */ +export interface ChannelVerifyRequest extends BaseRequest { + command: 'channel_verify'; + /** The amount of XRP, in drops, the provided signature authorizes. */ + amount: string; + /** + * The Channel ID of the channel that provides the XRP. This is a + * 64-character hexadecimal string. + */ + channel_id: string; + /** + * The public key of the channel and the key pair that was used to create the + * signature, in hexadecimal or the XRP Ledger's base58 format. + */ + public_key: string; + /** The signature to verify, in hexadecimal. */ + signature: string; +} + +/** + * Response expected from an {@link ChannelVerifyRequest}. + * + * @category Responses + */ +export interface ChannelVerifyResponse extends BaseResponse { + /** + * If true, the signature is valid for the stated amount, channel, and + * public key. + */ + signature_verified: boolean; +} diff --git a/src/common/libs/ledger/types/methods/depositAuthorized.ts b/src/common/libs/ledger/types/methods/depositAuthorized.ts new file mode 100644 index 000000000..1e1cec295 --- /dev/null +++ b/src/common/libs/ledger/types/methods/depositAuthorized.ts @@ -0,0 +1,52 @@ +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +/** + * The deposit_authorized command indicates whether one account is authorized to + * send payments directly to another. Expects a response in the form of a {@link + * DepositAuthorizedResponse}. + * + * @category Requests + */ +export interface DepositAuthorizedRequest extends BaseRequest, LookupByLedgerRequest { + command: 'deposit_authorized'; + /** The sender of a possible payment. */ + source_account: string; + /** The recipient of a possible payment. */ + destination_account: string; +} + +/** + * Expected response from a {@link DepositAuthorizedRequest}. + * + * @category Responses + */ +export interface DepositAuthorizedResponse extends BaseResponse { + /** + * Whether the specified source account is authorized to send payments + * directly to the destination account. If true, either the destination + * account does not require Deposit Authorization or the source account is + * preauthorized. + */ + deposit_authorized: boolean; + /** The destination account specified in the request. */ + destination_account: string; + /** + * The identifying hash of the ledger that was used to generate this + * Response. + */ + ledger_hash?: string; + /** + * The ledger index of the ledger version that was used to generate this + * Response. + */ + ledger_index?: number; + /** + * The ledger index of the current in-progress ledger version, which was + * used to generate this response. + */ + ledger_current_index?: number; + /** The source account specified in the request. */ + source_account: string; + /** If true, the information comes from a validated ledger version. */ + validated?: boolean; +} diff --git a/src/common/libs/ledger/types/methods/fee.ts b/src/common/libs/ledger/types/methods/fee.ts new file mode 100644 index 000000000..4990d3d8a --- /dev/null +++ b/src/common/libs/ledger/types/methods/fee.ts @@ -0,0 +1,94 @@ +import { BaseRequest, BaseResponse } from './baseMethod'; + +/** + * The `fee` command reports the current state of the open-ledger requirements + * for the transaction cost. This requires the FeeEscalation amendment to be + * enabled. Expects a response in the form of a {@link FeeResponse}. + * + * @example + * ```ts + * const feeRequest: FeeRequest = { + * command: 'fee' + * } + * ``` + * + * @category Requests + */ +export interface FeeRequest extends BaseRequest { + command: 'fee'; +} + +/** + * Response expected from a {@link FeeRequest}. + * + * @category Responses + */ +export interface FeeResponse extends BaseResponse { + /** Number of transactions provisionally included in the in-progress ledger. */ + current_ledger_size: string; + /** Number of transactions currently queued for the next ledger. */ + current_queue_size: string; + drops: { + /** + * The transaction cost required for a reference transaction to be + * included in a ledger under minimum load, represented in drops of XRP. + */ + base_fee: string; + /** + * An approximation of the median transaction cost among transactions. + * Included in the previous validated ledger, represented in drops of XRP. + */ + median_fee: string; + /** + * The minimum transaction cost for a reference transaction to be queued + * for a later ledger, represented in drops of XRP. If greater than + * base_fee, the transaction queue is full. + */ + minimum_fee: string; + /** + * The minimum transaction cost that a reference transaction must pay to + * be included in the current open ledger, represented in drops of XRP. + */ + open_ledger_fee: string; + }; + /** + * The approximate number of transactions expected to be included in the + * current ledger. This is based on the number of transactions in the + * previous ledger. + */ + expected_ledger_size: string; + /** The Ledger Index of the current open ledger these stats describe. */ + ledger_current_index: number; + levels: { + /** + * The median transaction cost among transactions in the previous + * validated ledger, represented in fee levels. + */ + median_level: string; + /** + * The minimum transaction cost required to be queued for a future + * ledger, represented in fee levels. + */ + minimum_level: string; + /** + * The minimum transaction cost required to be included in the current + * open ledger, represented in fee levels. + */ + open_ledger_level: string; + /** + * The equivalent of the minimum transaction cost, represented in fee + * levels. + */ + reference_level: string; + }; + /** + * The maximum number of transactions that the transaction queue can + * currently hold. + */ + max_queue_size: string; + + /** + * Fee hooks units + */ + fee_hooks_feeunits: string; +} diff --git a/src/common/libs/ledger/types/methods/gatewayBalances.ts b/src/common/libs/ledger/types/methods/gatewayBalances.ts new file mode 100644 index 000000000..9c6594bbd --- /dev/null +++ b/src/common/libs/ledger/types/methods/gatewayBalances.ts @@ -0,0 +1,81 @@ +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +/** + * The gateway_balances command calculates the total balances issued by a given + * account, optionally excluding amounts held by operational addresses. Expects + * a response in the form of a {@link GatewayBalancesResponse}. + * + * @example + * ```ts + * const gatewayBalances: GatewayBalanceRequest = { + * "id": "example_gateway_balances_1", + * "command": "gateway_balances", + * "account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", + * "strict": true, + * "hotwallet": ["rKm4uWpg9tfwbVSeATv4KxDe6mpE9yPkgJ","ra7JkEzrgeKHdzKgo4EUUVBnxggY4z37kt"], + * "ledger_index": "validated" + * } + * ``` + * + * @category Requests + */ +export interface GatewayBalancesRequest extends BaseRequest, LookupByLedgerRequest { + command: 'gateway_balances'; + /** The Address to check. This should be the issuing address. */ + account: string; + /** + * If true, only accept an address or public key for the account parameter. + * Defaults to false. + */ + strict?: boolean; + /** + * An operational address to exclude from the balances issued, or an array of + * Such addresses. + */ + hotwallet?: string | string[]; +} + +export interface GatewayBalance { + currency: string; + value: string; +} + +/** + * Expected response from a {@link GatewayBalancesRequest}. + * + * @category Responses + */ +export interface GatewayBalancesResponse extends BaseResponse { + /** The address of the account that issued the balances. */ + account: string; + /** + * Total amounts issued to addresses not excluded, as a map of currencies + * to the total value issued. + */ + obligations?: { [currency: string]: string }; + /** + * Amounts issued to the hotwallet addresses from the request. The keys are + * addresses and the values are arrays of currency amounts they hold. + */ + balances?: { [address: string]: GatewayBalance[] }; + /** + * Total amounts held that are issued by others. In the recommended + * configuration, the issuing address should have none. + */ + assets?: { [address: string]: GatewayBalance[] }; + /** + * The identifying hash of the ledger version that was used to generate + * this response. + */ + ledger_hash?: string; + /** + * The ledger index of the ledger version that was used to generate this + * response. + */ + ledger_current_index?: number; + /** + * The ledger index of the current in-progress ledger version, which was + * used to retrieve this information. + */ + ledger_index?: number; +} diff --git a/src/common/libs/ledger/types/methods/index.ts b/src/common/libs/ledger/types/methods/index.ts new file mode 100644 index 000000000..29890b774 --- /dev/null +++ b/src/common/libs/ledger/types/methods/index.ts @@ -0,0 +1,302 @@ +import { AccountChannelsRequest, AccountChannelsResponse, Channel } from './accountChannels'; +import { AccountCurrenciesRequest, AccountCurrenciesResponse } from './accountCurrencies'; +import { AccountInfoRequest, AccountInfoResponse, AccountQueueData, AccountQueueTransaction } from './accountInfo'; +import { AccountLinesRequest, AccountLinesResponse, AccountLinesTrustline } from './accountLines'; +import { AccountNFToken, AccountNFTsRequest, AccountNFTsResponse } from './accountNFTs'; +import { AccountObject, AccountObjectsRequest, AccountObjectsResponse, AccountObjectType } from './accountObjects'; +import { AccountOffer, AccountOffersRequest, AccountOffersResponse } from './accountOffers'; +import { AccountTxRequest, AccountTxResponse, AccountTxTransaction } from './accountTx'; +import { AMMInfoRequest, AMMInfoResponse } from './ammInfo'; +import { BaseRequest, BaseResponse, ErrorResponse, ResponseWarning } from './baseMethod'; +import { BookOffersRequest, BookOffer, BookOffersResponse, BookOfferCurrency } from './bookOffers'; +import { ChannelVerifyRequest, ChannelVerifyResponse } from './channelVerify'; +import { DepositAuthorizedRequest, DepositAuthorizedResponse } from './depositAuthorized'; +import { FeeRequest, FeeResponse } from './fee'; +import { GatewayBalance, GatewayBalancesRequest, GatewayBalancesResponse } from './gatewayBalances'; +import { + LedgerBinary, + LedgerModifiedOfferCreateTransaction, + LedgerQueueData, + LedgerRequest, + LedgerResponse, +} from './ledger'; +import { LedgerClosedRequest, LedgerClosedResponse } from './ledgerClosed'; +import { LedgerCurrentRequest, LedgerCurrentResponse } from './ledgerCurrent'; +import { + LedgerDataBinaryLedgerEntry, + LedgerDataLabeledLedgerEntry, + LedgerDataLedgerState, + LedgerDataRequest, + LedgerDataResponse, +} from './ledgerData'; +import { LedgerEntryRequest, LedgerEntryResponse } from './ledgerEntry'; +import { ManifestRequest, ManifestResponse } from './manifest'; +import { NFTBuyOffersRequest, NFTBuyOffersResponse } from './nftBuyOffers'; +import { NFTSellOffersRequest, NFTSellOffersResponse } from './nftSellOffers'; +import { NoRippleCheckRequest, NoRippleCheckResponse } from './norippleCheck'; +import { + PathFindRequest, + PathFindCloseRequest, + PathFindCreateRequest, + PathFindStatusRequest, + PathFindResponse, + PathFindPathOption, +} from './pathFind'; +import { PingRequest, PingResponse } from './ping'; +import { RandomRequest, RandomResponse } from './random'; +import { ServerDefinitionsRequest, ServerDefinitionsResponse } from './serverDefinitions'; +import { + JobType, + ServerInfoRequest, + ServerInfoResponse, + ServerState, + StateAccounting, + StateAccountingFinal, +} from './serverInfo'; +import { ServerStateRequest, ServerStateResponse } from './serverState'; +import { SubmitRequest, SubmitResponse } from './submit'; +import { SubmitMultisignedRequest, SubmitMultisignedResponse } from './submitMultisigned'; +import { + BooksSnapshot, + ConsensusStream, + LedgerStream, + LedgerStreamResponse, + OrderBookStream, + PathFindStream, + PeerStatusStream, + Stream, + SubscribeBook, + SubscribeRequest, + SubscribeResponse, + TransactionStream, + ValidationStream, +} from './subscribe'; +import { TransactionEntryRequest, TransactionEntryResponse } from './transactionEntry'; +import { TxRequest, TxResponse } from './tx'; +import { UnsubscribeBook, UnsubscribeRequest, UnsubscribeResponse } from './unsubscribe'; +/** + * @category Requests + */ +type Request = + // account methods + | AccountChannelsRequest + | AccountCurrenciesRequest + | AccountInfoRequest + | AccountLinesRequest + | AccountNFTsRequest + | AccountObjectsRequest + | AccountOffersRequest + | AccountTxRequest + | GatewayBalancesRequest + | NoRippleCheckRequest + // ledger methods + | LedgerRequest + | LedgerClosedRequest + | LedgerCurrentRequest + | LedgerDataRequest + | LedgerEntryRequest + // transaction methods + | SubmitRequest + | SubmitMultisignedRequest + | TransactionEntryRequest + | TxRequest + // path and order book methods + | BookOffersRequest + | DepositAuthorizedRequest + | PathFindRequest + // payment channel methods + | ChannelVerifyRequest + // subscription methods + | SubscribeRequest + | UnsubscribeRequest + // server info methods + | FeeRequest + | ManifestRequest + | ServerDefinitionsRequest + | ServerInfoRequest + | ServerStateRequest + // utility methods + | PingRequest + | RandomRequest + // NFT methods + | NFTBuyOffersRequest + | NFTSellOffersRequest + // AMM methods + | AMMInfoRequest; + +/** + * @category Responses + */ +type Response = + // account methods + | AccountChannelsResponse + | AccountCurrenciesResponse + | AccountInfoResponse + | AccountLinesResponse + | AccountNFTsResponse + | AccountObjectsResponse + | AccountOffersResponse + | AccountTxResponse + | GatewayBalancesResponse + | NoRippleCheckResponse + // ledger methods + | LedgerResponse + | LedgerClosedResponse + | LedgerCurrentResponse + | LedgerDataResponse + | LedgerEntryResponse + // transaction methods + | SubmitResponse + | SubmitMultisignedResponse + | TransactionEntryResponse + | TxResponse + // path and order book methods + | BookOffersResponse + | DepositAuthorizedResponse + | PathFindResponse + // payment channel methods + | ChannelVerifyResponse + // subscription methods + | SubscribeResponse + | UnsubscribeResponse + // server info methods + | FeeResponse + | ManifestResponse + | ServerDefinitionsResponse + | ServerInfoResponse + | ServerStateResponse + // utility methods + | PingResponse + | RandomResponse + // NFT methods + | NFTBuyOffersResponse + | NFTSellOffersResponse + // AMM methods + | AMMInfoResponse; + +export { + BaseRequest, + BaseResponse, + Request, + Response, + ResponseWarning, + // account methods with types + Channel, + AccountChannelsRequest, + AccountChannelsResponse, + AccountCurrenciesRequest, + AccountCurrenciesResponse, + AccountInfoRequest, + AccountInfoResponse, + AccountQueueData, + AccountQueueTransaction, + AccountLinesRequest, + AccountLinesResponse, + AccountLinesTrustline, + AccountNFToken, + AccountNFTsRequest, + AccountNFTsResponse, + AccountObject, + AccountObjectType, + AccountObjectsRequest, + AccountObjectsResponse, + AccountOffer, + AccountOffersRequest, + AccountOffersResponse, + AccountTxRequest, + AccountTxResponse, + AccountTxTransaction, + GatewayBalance, + GatewayBalancesRequest, + GatewayBalancesResponse, + NoRippleCheckRequest, + NoRippleCheckResponse, + // ledger methods + LedgerRequest, + LedgerResponse, + LedgerQueueData, + LedgerBinary, + LedgerModifiedOfferCreateTransaction, + LedgerClosedRequest, + LedgerClosedResponse, + LedgerCurrentRequest, + LedgerCurrentResponse, + LedgerDataRequest, + LedgerDataLabeledLedgerEntry, + LedgerDataBinaryLedgerEntry, + LedgerDataResponse, + LedgerDataLedgerState, + LedgerEntryRequest, + LedgerEntryResponse, + // transaction methods with types + SubmitRequest, + SubmitResponse, + SubmitMultisignedRequest, + SubmitMultisignedResponse, + TransactionEntryRequest, + TransactionEntryResponse, + TxRequest, + TxResponse, + // path and order book methods with types + BookOffersRequest, + BookOffer, + BookOfferCurrency, + BookOffersResponse, + DepositAuthorizedRequest, + DepositAuthorizedResponse, + PathFindRequest, + PathFindCreateRequest, + PathFindCloseRequest, + PathFindPathOption, + PathFindStatusRequest, + PathFindResponse, + // payment channel methods + ChannelVerifyRequest, + ChannelVerifyResponse, + // Subscribe methods/streams with types + SubscribeRequest, + SubscribeResponse, + SubscribeBook, + Stream, + BooksSnapshot, + LedgerStream, + LedgerStreamResponse, + ValidationStream, + TransactionStream, + PathFindStream, + PeerStatusStream, + OrderBookStream, + ConsensusStream, + UnsubscribeRequest, + UnsubscribeResponse, + UnsubscribeBook, + // server info methods with types + FeeRequest, + FeeResponse, + ManifestRequest, + ManifestResponse, + ServerDefinitionsRequest, + ServerDefinitionsResponse, + ServerInfoRequest, + ServerInfoResponse, + ServerStateRequest, + ServerStateResponse, + JobType, + ServerState, + StateAccountingFinal, + StateAccounting, + // utility methods + PingRequest, + PingResponse, + RandomRequest, + RandomResponse, + ErrorResponse, + // NFT methods + NFTBuyOffersRequest, + NFTBuyOffersResponse, + NFTSellOffersRequest, + NFTSellOffersResponse, + // AMM methods + AMMInfoRequest, + AMMInfoResponse, +}; diff --git a/src/common/libs/ledger/types/methods/ledger.ts b/src/common/libs/ledger/types/methods/ledger.ts new file mode 100644 index 000000000..d961ae7f1 --- /dev/null +++ b/src/common/libs/ledger/types/methods/ledger.ts @@ -0,0 +1,122 @@ +import { Ledger, LedgerEntryFilter } from '../ledger'; +import { TransactionMetadata } from '../transaction/metadata'; + +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +/** + * Retrieve information about the public ledger. Expects a response in the form + * of a {@link LedgerResponse}. + * + * @example + * ```ts + * const ledger: LedgerRequest = { + * "id": 14, + * "command": "ledger", + * "ledger_index": "validated", + * "full": false, + * "accounts": false, + * "transactions": false, + * "expand": false, + * "owner_funds": false + * } + * ``` + * + * @category Requests + */ +export interface LedgerRequest extends BaseRequest, LookupByLedgerRequest { + command: 'ledger'; + /** + * Admin required If true, return full information on the entire ledger. + * Ignored if you did not specify a ledger version. Defaults to false. + */ + full?: boolean; + /** + * Admin required. If true, return information on accounts in the ledger. + * Ignored if you did not specify a ledger version. Defaults to false. + */ + accounts?: boolean; + /** + * If true, return information on transactions in the specified ledger + * version. Defaults to false. Ignored if you did not specify a ledger + * version. + */ + transactions?: any; + /** + * Provide full JSON-formatted information for transaction/account + * information instead of only hashes. Defaults to false. Ignored unless you + * request transactions, accounts, or both. + */ + expand?: boolean; + /** + * If true, include owner_funds field in the metadata of OfferCreate + * transactions in the response. Defaults to false. Ignored unless + * transactions are included and expand is true. + */ + owner_funds?: boolean; + /** + * If true, and transactions and expand are both also true, return + * transaction information in binary format (hexadecimal string) instead of + * JSON format. + */ + binary?: boolean; + /** + * If true, and the command is requesting the current ledger, includes an + * array of queued transactions in the results. + */ + queue?: boolean; + /** + * If included, filter results to include only this type of ledger object. + */ + type?: LedgerEntryFilter; +} + +/** + * Special case transaction definition when the request contains `owner_funds: true`. + */ +export interface LedgerModifiedOfferCreateTransaction { + transaction: any; + metadata: TransactionMetadata & { owner_funds: string }; +} + +export interface LedgerQueueData { + account: string; + tx: any | LedgerModifiedOfferCreateTransaction | { tx_blob: string }; + retries_remaining: number; + preflight_result: string; + last_result?: string; + auth_change?: boolean; + fee?: string; + fee_level?: string; + max_spend_drops?: string; +} + +export interface LedgerBinary extends Omit, 'accountState'> { + accountState?: string[]; + transactions?: string[]; +} + +/** + * Response expected from a {@link LedgerRequest}. + * + * @category Responses + */ +export interface LedgerResponse extends BaseResponse { + /** The complete header data of this {@link Ledger}. */ + ledger: Ledger | LedgerBinary; + /** Unique identifying hash of the entire ledger. */ + ledger_hash: string; + /** The Ledger Index of this ledger. */ + ledger_index: number; + /** + * If true, this is a validated ledger version. If omitted or set to false, + * this ledger's data is not final. + */ + queue_data?: Array; + /** + * Array of objects describing queued transactions, in the same order as + * the queue. If the request specified expand as true, members contain full + * representations of the transactions, in either JSON or binary depending + * on whether the request specified binary as true. + */ + validated?: boolean; +} diff --git a/src/common/libs/ledger/types/methods/ledgerClosed.ts b/src/common/libs/ledger/types/methods/ledgerClosed.ts new file mode 100644 index 000000000..7ac3c8fd9 --- /dev/null +++ b/src/common/libs/ledger/types/methods/ledgerClosed.ts @@ -0,0 +1,30 @@ +import { BaseRequest, BaseResponse } from './baseMethod'; + +/** + * The ledger_closed method returns the unique identifiers of the most recently + * closed ledger. Expects a response in the form of a {@link + * LedgerClosedResponse}. + * + * @example + * * + * ```ts + * const ledgerClosed: LedgerClosedRequest = { + * "command": "ledger_closed" + * } + * ``` + * + * @category Requests + */ +export interface LedgerClosedRequest extends BaseRequest { + command: 'ledger_closed'; +} + +/** + * The response expected from a {@link LedgerClosedRequest}. + * + * @category Responses + */ +export interface LedgerClosedResponse extends BaseResponse { + ledger_hash: string; + ledger_index: number; +} diff --git a/src/common/libs/ledger/types/methods/ledgerCurrent.ts b/src/common/libs/ledger/types/methods/ledgerCurrent.ts new file mode 100644 index 000000000..2d466c52e --- /dev/null +++ b/src/common/libs/ledger/types/methods/ledgerCurrent.ts @@ -0,0 +1,29 @@ +import { BaseRequest, BaseResponse } from './baseMethod'; + +/** + * The ledger_current method returns the unique identifiers of the current + * in-progress ledger. Expects a response in the form of a {@link + * LedgerCurrentResponse}. + * + * @example + * ```ts + * const ledgerCurrent: LedgerCurrentRequest = { + * "command": "ledger_current" + * } + * ``` + * + * @category Requests + */ +export interface LedgerCurrentRequest extends BaseRequest { + command: 'ledger_current'; +} + +/** + * Response expected from a {@link LedgerCurrentRequest}. + * + * @category Responses + */ +export interface LedgerCurrentResponse extends BaseResponse { + /** The ledger index of this ledger version. */ + ledger_current_index: number; +} diff --git a/src/common/libs/ledger/types/methods/ledgerData.ts b/src/common/libs/ledger/types/methods/ledgerData.ts new file mode 100644 index 000000000..88831c644 --- /dev/null +++ b/src/common/libs/ledger/types/methods/ledgerData.ts @@ -0,0 +1,77 @@ +import { LedgerEntry, LedgerEntryFilter } from '../ledger'; + +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +/** + * The `ledger_data` method retrieves contents of the specified ledger. You can + * iterate through several calls to retrieve the entire contents of a single + * ledger version. + * + * @example + * ```ts + * const ledgerData: LedgerDataRequest = { + * "id": 2, + * "ledger_hash": "842B57C1CC0613299A686D3E9F310EC0422C84D3911E5056389AA7E5808A93C8", + * "command": "ledger_data", + * "limit": 5, + * "binary": true + * } + * ``` + * + * @category Requests + */ +export interface LedgerDataRequest extends BaseRequest, LookupByLedgerRequest { + command: 'ledger_data'; + /** + * If set to true, return ledger objects as hashed hex strings instead of + * JSON. + */ + binary?: boolean; + /** + * Limit the number of ledger objects to retrieve. The server is not required + * to honor this value. + */ + limit?: number; + /** + * Value from a previous paginated response. Resume retrieving data where + * that response left off. + */ + marker?: unknown; + /** + * If included, filter results to include only this type of ledger object. + */ + type?: LedgerEntryFilter; +} + +export type LedgerDataLabeledLedgerEntry = { + ledgerEntryType: string; +} & LedgerEntry; + +export interface LedgerDataBinaryLedgerEntry { + data: string; +} + +export type LedgerDataLedgerState = { index: string } & (LedgerDataBinaryLedgerEntry | LedgerDataLabeledLedgerEntry); + +/** + * The response expected from a {@link LedgerDataRequest}. + * + * @category Responses + */ +export interface LedgerDataResponse extends BaseResponse { + /** The ledger index of this ledger version. */ + ledger_index: number; + /** Unique identifying hash of this ledger version. */ + ledger_hash: string; + /** + * Array of JSON objects containing data from the ledger's state tree, + * as defined below. + */ + state: LedgerDataLedgerState[]; + /** + * Server-defined value indicating the response is paginated. Pass this to + * the next call to resume where this call left off. + */ + marker?: unknown; + validated?: boolean; +} diff --git a/src/common/libs/ledger/types/methods/ledgerEntry.ts b/src/common/libs/ledger/types/methods/ledgerEntry.ts new file mode 100644 index 000000000..7d7cc7bb3 --- /dev/null +++ b/src/common/libs/ledger/types/methods/ledgerEntry.ts @@ -0,0 +1,181 @@ +import { LedgerEntry } from '../ledger'; + +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +/** + * The `ledger_entry` method returns a single ledger object from the XRP Ledger + * in its raw format. Expects a response in the form of a {@link + * LedgerEntryResponse}. + * + * @example + * ```ts + * const ledgerEntry: LedgerEntryRequest = { + * command: "ledger_entry", + * ledger_index: 60102302, + * index: "7DB0788C020F02780A673DC74757F23823FA3014C1866E72CC4CD8B226CD6EF4" + * } + * ``` + * + * @category Requests + */ +export interface LedgerEntryRequest extends BaseRequest, LookupByLedgerRequest { + command: 'ledger_entry'; + /** + * Retrieve an Automated Market Maker (AMM) object from the ledger. + * This is similar to amm_info method, but the ledger_entry version returns only the ledger entry as stored. + */ + amm?: { + asset: { + currency: string; + issuer?: string; + }; + asset2: { + currency: string; + issuer?: string; + }; + }; + + /** + * If true, return the requested ledger object's contents as a hex string in + * the XRP Ledger's binary format. Otherwise, return data in JSON format. The + * default is false. + */ + binary?: boolean; + + /* + * Only one of the following properties should be defined in a single request + * https://xrpl.org/ledger_entry.html. + * + * Retrieve any type of ledger object by its unique ID. + */ + index?: string; + + /** + * Retrieve an AccountRoot object by its address. This is roughly equivalent + * to the an {@link AccountInfoRequest}. + */ + account_root?: string; + + /** The object ID of a Check object to retrieve. */ + check?: string; + + /** + * Specify a DepositPreauth object to retrieve. If a string, must be the + * object ID of the DepositPreauth object, as hexadecimal. If an object, + * requires owner and authorized sub-fields. + */ + deposit_preauth?: + | { + /** The account that provided the preauthorization. */ + owner: string; + /** The account that received the preauthorization. */ + authorized: string; + } + | string; + + /** + * Specify a DID object to retrieve. If a string, must be the + * object ID of the DID object, as hexadecimal, or the account ID. + */ + did?: string; + + /** + * The DirectoryNode to retrieve. If a string, must be the object ID of the + * directory, as hexadecimal. If an object, requires either `dir_root` o + * Owner as a sub-field, plus optionally a `sub_index` sub-field. + */ + directory?: + | { + /** If provided, jumps to a later "page" of the DirectoryNode. */ + sub_index?: number; + /** Unique index identifying the directory to retrieve, as a hex string. */ + dir_root?: string; + /** Unique address of the account associated with this directory. */ + owner?: string; + } + | string; + + /** + * The Escrow object to retrieve. If a string, must be the object ID of the + * escrow, as hexadecimal. If an object, requires owner and seq sub-fields. + */ + escrow?: + | { + /** The owner (sender) of the Escrow object. */ + owner: string; + /** Sequence Number of the transaction that created the Escrow object. */ + seq: number; + } + | string; + + /** + * The Offer object to retrieve. If a string, interpret as the unique object + * ID to the Offer. If an object, requires the sub-fields `account` and `seq` + * to uniquely identify the offer. + */ + offer?: + | { + /** The account that placed the offer. */ + account: string; + /** Sequence Number of the transaction that created the Offer object. */ + seq: number; + } + | string; + + /** The object ID of a PayChannel object to retrieve. */ + payment_channel?: string; + + /** + * Object specifying the RippleState (trust line) object to retrieve. The + * accounts and currency sub-fields are required to uniquely specify the + * rippleState entry to retrieve. + */ + ripple_state?: { + /** + * 2-length array of account Addresses, defining the two accounts linked by + * this RippleState object. + */ + accounts: string[]; + /** Currency Code of the RippleState object to retrieve. */ + currency: string; + }; + + /** + * The Ticket object to retrieve. If a string, must be the object ID of the + * Ticket, as hexadecimal. If an object, the `owner` and `ticket_sequence` + * sub-fields are required to uniquely specify the Ticket entry. + */ + ticket?: + | { + /** The owner of the Ticket object. */ + owner: string; + /** The Ticket Sequence number of the Ticket entry to retrieve. */ + ticket_sequence: number; + } + | string; + + /** + * Must be the object ID of the NFToken page, as hexadecimal + */ + nft_page?: string; +} + +/** + * Response expected from a {@link LedgerEntryRequest}. + * + * @category Responses + */ +export interface LedgerEntryResponse extends BaseResponse { + /** The unique ID of this ledger object. */ + index: string; + /** The ledger index of the ledger that was used when retrieving this data. */ + ledger_current_index: number; + /** + * Object containing the data of this ledger object, according to the + * ledger format. + */ + node?: T; + /** The binary representation of the ledger object, as hexadecimal. */ + node_binary?: string; + validated?: boolean; +} diff --git a/src/common/libs/ledger/types/methods/manifest.ts b/src/common/libs/ledger/types/methods/manifest.ts new file mode 100644 index 000000000..3ffc1685f --- /dev/null +++ b/src/common/libs/ledger/types/methods/manifest.ts @@ -0,0 +1,52 @@ +import { BaseRequest, BaseResponse } from './baseMethod'; + +/** + * The `manifest` method reports the current "manifest" information for a given + * validator public key. The "manifest" is the public portion of that + * validator's configured token. Expects a response in the form of a {@link + * ManifestResponse}. + * + * @example + * ```ts + * const manifest: ManifestRequest = { + * "command": "manifest", + * "public_key": "nHUFE9prPXPrHcG3SkwP1UzAQbSphqyQkQK9ATXLZsfkezhhda3p" + * } + * ``` + * + * @category Requests + */ +export interface ManifestRequest extends BaseRequest { + command: 'manifest'; + /** + * The base58-encoded public key of the validator to look up. This can be the + * master public key or ephemeral public key. + */ + public_key: string; +} + +/** + * Response expected from a {@link ManifestRequest}. + * + * @category Responses + */ +export interface ManifestResponse extends BaseResponse { + /** + * The data contained in this manifest. Omitted if the server does not have + * A manifest for the public_key from the request. + */ + details?: { + domain: string; + ephemeral_key: string; + master_key: string; + seq: number; + }; + /** + * The full manifest data in base64 format. This data is serialized to + * binary before being base64-encoded. Omitted if the server does not have a + * manifest for the public_key from the request. + */ + manifest?: string; + /** The public_key from the request. */ + requested: string; +} diff --git a/src/common/libs/ledger/types/methods/nftBuyOffers.ts b/src/common/libs/ledger/types/methods/nftBuyOffers.ts new file mode 100644 index 000000000..2705cfb51 --- /dev/null +++ b/src/common/libs/ledger/types/methods/nftBuyOffers.ts @@ -0,0 +1,33 @@ +import { NFTOffer } from '../common'; + +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +/** + * The `nft_buy_offers` method retrieves all of buy offers for the specified + * NFToken. + * + * @category Requests + */ +export interface NFTBuyOffersRequest extends BaseRequest, LookupByLedgerRequest { + command: 'nft_buy_offers'; + /** + * The unique identifier of an NFToken. The request returns buy offers for this NFToken. + */ + nft_id: string; +} + +/** + * Response expected from an {@link NFTBuyOffersRequest}. + * + * @category Responses + */ +export interface NFTBuyOffersResponse extends BaseResponse { + /** + * A list of buy offers for the specified NFToken. + */ + offers: NFTOffer[]; + /** + * The token ID of the NFToken to which these offers pertain. + */ + nft_id: string; +} diff --git a/src/common/libs/ledger/types/methods/nftSellOffers.ts b/src/common/libs/ledger/types/methods/nftSellOffers.ts new file mode 100644 index 000000000..c290f96b1 --- /dev/null +++ b/src/common/libs/ledger/types/methods/nftSellOffers.ts @@ -0,0 +1,33 @@ +import { NFTOffer } from '../common'; + +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +/** + * The `nft_sell_offers` method retrieves all of sell offers for the specified + * NFToken. + * + * @category Requests + */ +export interface NFTSellOffersRequest extends BaseRequest, LookupByLedgerRequest { + command: 'nft_sell_offers'; + /** + * The unique identifier of an NFToken. The request returns sell offers for this NFToken. + */ + nft_id: string; +} + +/** + * Response expected from an {@link NFTSellOffersRequest}. + * + * @category Responses + */ +export interface NFTSellOffersResponse extends BaseResponse { + /** + * A list of sell offers for the specified NFToken. + */ + offers: NFTOffer[]; + /** + * The token ID of the NFToken to which these offers pertain. + */ + nft_id: string; +} diff --git a/src/common/libs/ledger/types/methods/norippleCheck.ts b/src/common/libs/ledger/types/methods/norippleCheck.ts new file mode 100644 index 000000000..71eb77ec7 --- /dev/null +++ b/src/common/libs/ledger/types/methods/norippleCheck.ts @@ -0,0 +1,79 @@ +import { LedgerIndex, ResponseOnlyTxInfo } from '../common'; + +import { BaseRequest, BaseResponse } from './baseMethod'; + +/** + * The `noripple_check` command provides a quick way to check the status of th + * default ripple field for an account and the No Ripple flag of its trust + * lines, compared with the recommended settings. Expects a response in the form + * of an {@link NoRippleCheckResponse}. + * + * @example + * ```ts + * const noRipple: NoRippleCheckRequest = { + * "id": 0, + * "command": "noripple_check", + * "account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", + * "role": "gateway", + * "ledger_index": "current", + * "limit": 2, + * "transactions": true + * } + * ``` + * + * @category Requests + */ +export interface NoRippleCheckRequest extends BaseRequest { + command: 'noripple_check'; + /** A unique identifier for the account, most commonly the account's address. */ + account: string; + /** + * Whether the address refers to a gateway or user. Recommendations depend on + * the role of the account. Issuers must have Default Ripple enabled and must + * disable No Ripple on all trust lines. Users should have Default Ripple + * disabled, and should enable No Ripple on all trust lines. + */ + role: 'gateway' | 'user'; + /** + * If true, include an array of suggested transactions, as JSON objects, + * that you can sign and submit to fix the problems. Defaults to false. + */ + transactions?: boolean; + /** + * The maximum number of trust line problems to include in the results. + * Defaults to 300. + */ + limit?: number; + /** A 20-byte hex string for the ledger version to use. */ + ledger_hash?: string; + /** + * The ledger index of the ledger to use, or a shortcut string to choose a + * ledger automatically. + */ + ledger_index?: LedgerIndex; +} + +/** + * Response expected by a {@link NoRippleCheckRequest}. + * + * @category Responses + */ +export interface NoRippleCheckResponse extends BaseResponse { + /** The ledger index of the ledger used to calculate these results. */ + ledger_current_index: number; + /** + * Array of strings with human-readable descriptions of the problems. + * This includes up to one entry if the account's Default Ripple setting is + * not as recommended, plus up to limit entries for trust lines whose no + * ripple setting is not as recommended. + */ + problems: string[]; + /** + * If the request specified transactions as true, this is an array of JSON + * objects, each of which is the JSON form of a transaction that should fix + * one of the described problems. The length of this array is the same as + * the problems array, and each entry is intended to fix the problem + * described at the same index into that array. + */ + transactions: Array; +} diff --git a/src/common/libs/ledger/types/methods/pathFind.ts b/src/common/libs/ledger/types/methods/pathFind.ts new file mode 100644 index 000000000..135cfa34f --- /dev/null +++ b/src/common/libs/ledger/types/methods/pathFind.ts @@ -0,0 +1,113 @@ +import { Amount, Path } from '../common'; + +import { BaseRequest, BaseResponse } from './baseMethod'; + +interface BasePathFindRequest extends BaseRequest { + command: 'path_find'; + subcommand: string; +} + +/** Start sending pathfinding information. */ +export interface PathFindCreateRequest extends BasePathFindRequest { + subcommand: 'create'; + /** + * Unique address of the account to find a path from. In other words, the. + * Account that would be sending a payment. + */ + source_account: string; + /** Unique address of the account to find a path to. */ + destination_account: string; + /** + * Currency Amount that the destination account would receive in a + * transaction. + */ + destination_amount: Amount; + /** Currency amount that would be spent in the transaction. */ + send_max?: Amount; + /** + * Array of arrays of objects, representing payment paths to check. You can + * use this to keep updated on changes to particular paths you already know + * about, or to check the overall cost to make a payment along a certain path. + */ + paths?: Path[]; +} + +/** Stop sending pathfinding information. */ +export interface PathFindCloseRequest extends BasePathFindRequest { + subcommand: 'close'; +} + +/** Get the information of the currently-open pathfinding request. */ +export interface PathFindStatusRequest extends BasePathFindRequest { + subcommand: 'status'; +} + +/** + * The `path_find` method searches for a path along which a transaction can + * possibly be made, and periodically sends updates when the path changes over + * time. For a simpler version that is supported by JSON-RPC, see the + * `ripple_path_find` method. + * + * @category Requests + */ +export type PathFindRequest = PathFindCreateRequest | PathFindCloseRequest | PathFindStatusRequest; + +export interface PathFindPathOption { + /** Array of arrays of objects defining payment paths. */ + paths_computed: Path[]; + /** + * Currency Amount that the source would have to send along this path for the. + * Destination to receive the desired amount. + */ + source_amount: Amount; + /** + * Destination Amount that the destination would receive along this path. + * If the `send_max` field is set, this field will be set. + */ + destination_amount?: Amount; +} + +/** + * Response expected from a {@link PathFindRequest}. + * + * @category Responses + */ +export interface PathFindResponse extends BaseResponse { + result: { + /** + * Array of objects with suggested paths to take, as described below. If + * empty, then no paths were found connecting the source and destination + * accounts. + */ + alternatives: PathFindPathOption[]; + /** Unique address of the account that would receive a transaction. */ + destination_account: string; + /** Currency amount provided in the WebSocket request. */ + destination_amount: Amount; + /** Unique address that would send a transaction. */ + source_account: string; + /** + * If false, this is the result of an incomplete search. A later reply + * may have a better path. If true, then this is the best path found. (It is + * still theoretically possible that a better path could exist, but rippled + * won't find it.) Until you close the pathfinding request, rippled. + * Continues to send updates each time a new ledger closes. + */ + full_reply: boolean; + /** + * The ID provided in the WebSocket request is included again at this + * level. + */ + id?: number | string; + /** + * The value true indicates this reply is in response to a path_find close + * command. + */ + closed?: true; + /** + * The value true indicates this reply is in response to a `path_find` + * status command. + */ + status?: true; + }; +} diff --git a/src/common/libs/ledger/types/methods/ping.ts b/src/common/libs/ledger/types/methods/ping.ts new file mode 100644 index 000000000..e322f77c2 --- /dev/null +++ b/src/common/libs/ledger/types/methods/ping.ts @@ -0,0 +1,22 @@ +import type { BaseRequest, BaseResponse } from './baseMethod'; + +/** + * The ping command returns an acknowledgement, so that clients can test the + * connection status and latency. Expects a response in the form of a {@link + * PingResponse}. + * + * @category Requests + */ +export interface PingRequest extends BaseRequest { + command: 'ping'; +} + +/** + * Response expected from a {@link PingRequest}. + * + * @category Responses + */ +export interface PingResponse extends BaseResponse { + role?: string; + unlimited?: boolean; +} diff --git a/src/common/libs/ledger/types/methods/random.ts b/src/common/libs/ledger/types/methods/random.ts new file mode 100644 index 000000000..0d5a1ac23 --- /dev/null +++ b/src/common/libs/ledger/types/methods/random.ts @@ -0,0 +1,21 @@ +import { BaseRequest, BaseResponse } from './baseMethod'; + +/** + * The random command provides a random number to be used as a source of + * entropy for random number generation by clients. Expects a response in the + * form of a {@link RandomResponse}. + * + * @category Requests + */ +export interface RandomRequest extends BaseRequest { + command: 'random'; +} + +/** + * Response expected from a {@link RandomRequest}. + * + * @category Responses + */ +export interface RandomResponse extends BaseResponse { + random: string; +} diff --git a/src/common/libs/ledger/types/methods/serverDefinitions.ts b/src/common/libs/ledger/types/methods/serverDefinitions.ts new file mode 100644 index 000000000..41942d714 --- /dev/null +++ b/src/common/libs/ledger/types/methods/serverDefinitions.ts @@ -0,0 +1,57 @@ +import { BaseRequest, BaseResponse } from './baseMethod'; + +/** + * The `server_definitions` method retrieves information about the definition + * enums available in this rippled node. Expects a response in the form of a + * {@link ServerDefinitionsResponse}. + * + * @category Requests + */ +export interface ServerDefinitionsRequest extends BaseRequest { + command: 'server_definitions'; + /** + * The hash of a `server_definitions` response. + */ + hash?: string; +} + +/** + * Response expected from an {@link ServerDefinitionsRequest}. + * + * @category Responses + */ +export interface ServerDefinitionsResponse extends BaseResponse { + [key: string]: + | number + | string + | Array< + [ + string, + { + nth: number; + isVLEncoded: boolean; + isSerialized: boolean; + isSigningField: boolean; + type: string; + }, + ] + > + | Record; + hash: string; + FIELDS?: Array< + [ + string, + { + nth: number; + isVLEncoded: boolean; + isSerialized: boolean; + isSigningField: boolean; + type: string; + }, + ] + >; + LEDGER_ENTRY_TYPES?: Record; + TRANSACTION_RESULTS?: Record; + TRANSACTION_TYPES?: Record; + TYPES?: Record; +} diff --git a/src/common/libs/ledger/types/methods/serverInfo.ts b/src/common/libs/ledger/types/methods/serverInfo.ts new file mode 100644 index 000000000..6bbfcb2b4 --- /dev/null +++ b/src/common/libs/ledger/types/methods/serverInfo.ts @@ -0,0 +1,257 @@ +import { BaseRequest, BaseResponse } from './baseMethod'; + +/** + * The `server_info` command asks the server for a human-readable version of + * various information about the rippled server being queried. Expects a + * response in the form of a {@link ServerInfoResponse}. + * + * @category Requests + */ +export interface ServerInfoRequest extends BaseRequest { + command: 'server_info'; +} + +export type ServerState = 'disconnected' | 'connected' | 'syncing' | 'tracking' | 'full' | 'validating' | 'proposing'; + +export interface StateAccounting { + duration_us: string; + transitions: string; +} + +export interface JobType { + job_type: string; + per_second: number; + peak_time?: number; + avg_time?: number; + in_progress?: number; +} + +export type protocol = 'http' | 'https' | 'grpc' | 'peer' | 'ws' | 'ws2' | 'wss' | 'wss2'; + +export interface ServerPort { + port: string; + /** The values in protocol are sorted in alphabetical order */ + protocol: protocol[]; +} + +// The states for validating and proposing do not exist in the field state_accounting +// See https://github.com/XRPLF/rippled/blob/develop/src/ripple/app/misc/NetworkOPs.cpp#L4545 +// https://github.com/XRPLF/rippled/blob/develop/src/ripple/app/misc/NetworkOPs.h#L66 +export type StateAccountingFinal = Record, StateAccounting>; + +/** + * Response expected from a {@link ServerInfoRequest}. + * + * @category Responses + */ +export interface ServerInfoResponse extends BaseResponse { + info: { + /** + * If true, this server is amendment blocked. If the server is not + * amendment blocked, the response omits this field. + */ + amendment_blocked?: boolean; + /** The version number of the running rippled version. */ + build_version: string; + /** + * Information on the most recently closed ledger that has not been + * validated by consensus. If the most recently validated ledger is + * available, the response omits this field and includes + * `validated_ledger` instead. The member fields are the same as the. + * `validated_ledger` field. + */ + closed_ledger?: { + age: number; + base_fee_xrp: number; + hash: string; + reserve_base_xrp: number; + reserve_inc_xrp: number; + seq: number; + }; + /** + * Range expression indicating the sequence numbers of the ledger + * versions the local rippled has in its database. + */ + complete_ledgers: string; + /** + * On an admin request, returns the hostname of the server running the + * rippled instance; otherwise, returns a single RFC-1751 word based on + * the node public key. + */ + hostid: string; + /** + * Amount of time spent waiting for I/O operations, in milliseconds. If + * this number is not very, very low, then the rippled server is probably + * having serious load issues. + */ + io_latency_ms: number; + /** + * The number of times (since starting up) that this server has had over + * 250 transactions waiting to be processed at once. A large number here + * may mean that your server is unable to handle the transaction load of + * the XRP Ledger network. + */ + jq_trans_overflow: string; + /** + * Information about the last time the server closed a ledger, including + * the amount of time it took to reach a consensus and the number of + * trusted validators participating. + */ + last_close: { + /** + * The amount of time it took to reach a consensus on the most recently + * validated ledger version, in seconds. + */ + converge_time_s: number; + /** + * How many trusted validators the server considered (including itself, + * if configured as a validator) in the consensus process for the most + * recently validated ledger version. + */ + proposers: number; + }; + /** + * (Admin only) Detailed information about the current load state of the + * server. + */ + load?: { + /** + * (Admin only) Information about the rate of different types of jobs + * the server is doing and how much time it spends on each. + */ + job_types: JobType[]; + /** (Admin only) The number of threads in the server's main job pool. */ + threads: number; + }; + /** + * The load-scaled open ledger transaction cost the server is currently + * enforcing, as a multiplier on the base transaction cost. For example, + * at 1000 load factor and a reference transaction cost of 10 drops of + * XRP, the load-scaled transaction cost is 10,000 drops (0.01 XRP). The + * load factor is determined by the highest of the individual server's + * load factor, the cluster's load factor, the open ledger cost and the + * overall network's load factor. + */ + load_factor?: number; + /** + * The network id of the server. + */ + network_id?: number; + /** + * Current multiplier to the transaction cost based on + * load to this server. + */ + load_factor_local?: number; + /** + * Current multiplier to the transaction cost being used by the rest of + * the network. + */ + load_factor_net?: number; + /** + * Current multiplier to the transaction cost based on load to servers + * in this cluster. + */ + load_factor_cluster?: number; + /** + * The current multiplier to the transaction cost that a transaction must + * pay to get into the open ledger. + */ + load_factor_fee_escalation?: number; + /** + * The current multiplier to the transaction cost that a transaction must + * pay to get into the queue, if the queue is full. + */ + load_factor_fee_queue?: number; + /** + * The load factor the server is enforcing, not including the open ledger + * cost. + */ + load_factor_server?: number; + /** + * The number of peer connections which were severed. + */ + peer_disconnects?: string; + /** + * The number of peer connections which were severed due to excess resource consumption. + */ + peer_disconnects_resources?: string; + network_ledger?: 'waiting'; + /** How many other rippled servers this one is currently connected to. */ + peers: number; + /** + * What Websocket/RPC ports rippled is listening on. + */ + ports: ServerPort[]; + /** + * Public key used to verify this server for peer-to-peer communications. + * This node key pair is automatically generated by the server the first + * time it starts up. (If deleted, the server can create a new pair of + * Keys.). + */ + pubkey_node: string; + /** Public key used by this node to sign ledger validations. */ + pubkey_validator?: string; + /** + * A string indicating to what extent the server is participating in the + * network. + */ + server_state: ServerState; + /** + * The number of consecutive microseconds the server has been in the + * current state. + */ + server_state_duration_us: string; + /** + * A map of various server states with information about the time the + * server spends in each. This can be useful for tracking the long-term + * health of your server's connectivity to the network. + */ + state_accounting: StateAccountingFinal; + /** The current time in UTC, according to the server's clock. */ + time: string; + /** Number of consecutive seconds that the server has been operational. */ + uptime: number; + /** Information about the most recent fully-validated ledger. */ + validated_ledger?: { + /** The time since the ledger was closed, in seconds. */ + age: number; + /** + * Base fee, in XRP. This may be represented in scientific notation. + * Such as 1e-05 for 0.00005. + */ + base_fee_xrp: number; + /** Unique hash for the ledger, as hexadecimal. */ + hash: string; + /** + * Minimum amount of XRP (not drops) necessary for every account to. + * Keep in reserve . + */ + reserve_base_xrp: number; + /** + * Amount of XRP (not drops) added to the account reserve for each + * object an account owns in the ledger. + */ + reserve_inc_xrp: number; + /** The ledger index of the latest validated ledger. */ + seq: number; + }; + /** + * Minimum number of trusted validations required to validate a ledger + * version. Some circumstances may cause the server to require more + * validations. + */ + validation_quorum: number; + /** + * Either the human readable time, in UTC, when the current validator + * list will expire, the string unknown if the server has yet to load a + * published validator list or the string never if the server uses a + * static validator list. + */ + validator_list_expires?: string; + validator_list?: { + count: number; + expiration: 'never' | 'unknown' | string; + status: 'active' | 'expired' | 'unknown'; + }; + }; +} diff --git a/src/common/libs/ledger/types/methods/serverState.ts b/src/common/libs/ledger/types/methods/serverState.ts new file mode 100644 index 000000000..497297819 --- /dev/null +++ b/src/common/libs/ledger/types/methods/serverState.ts @@ -0,0 +1,75 @@ +import { BaseRequest, BaseResponse } from './baseMethod'; +import { JobType, ServerState, StateAccountingFinal } from './serverInfo'; + +/** + * The `server_state` command asks the server for various machine-readable + * information about the rippled server's current state. The response is almost + * the same as the server_info method, but uses units that are easier to process + * instead of easier to read. + * + * @category Requests + */ +export interface ServerStateRequest extends BaseRequest { + command: 'server_state'; +} + +/** + * Response expected from a {@link ServerStateRequest}. + * + * @category Responses + */ +export interface ServerStateResponse extends BaseResponse { + state: { + amendment_blocked?: boolean; + build_version: string; + complete_ledgers: string; + closed_ledger?: { + age: number; + base_fee: number; + hash: string; + reserve_base: number; + reserve_inc: number; + seq: number; + }; + io_latency_ms: number; + jq_trans_overflow: string; + last_close: { + // coverage_time_s only exists for `server_info` requests. `server_state` is a "non human" api request, + // therefore the type is coverage_time + // See https://github.com/XRPLF/rippled/blob/83faf43140e27e5d6d6779eaa0ffb75c33d98029/src/ripple/app/misc/NetworkOPs.cpp#L2458 + converge_time: number; + proposers: number; + }; + load?: { + job_types: JobType[]; + threads: number; + }; + load_base: number; + load_factor: number; + load_factor_fee_escalation?: number; + load_factor_fee_queue?: number; + load_factor_fee_reference?: number; + load_factor_server?: number; + peer_disconnects?: string; + peer_disconnects_resources?: string; + peers: number; + pubkey_node: string; + pubkey_validator?: string; + server_state: ServerState; + server_state_duration_us: string; + state_accounting: StateAccountingFinal; + time: string; + uptime: number; + validated_ledger?: { + age?: number; + base_fee: number; + close_time: number; + hash: string; + reserve_base: number; + reserve_inc: number; + seq: number; + }; + validation_quorum: number; + validator_list_expires?: number; + }; +} diff --git a/src/common/libs/ledger/types/methods/submit.ts b/src/common/libs/ledger/types/methods/submit.ts new file mode 100644 index 000000000..9ba522f14 --- /dev/null +++ b/src/common/libs/ledger/types/methods/submit.ts @@ -0,0 +1,90 @@ +import { BaseRequest, BaseResponse } from './baseMethod'; + +/** + * The submit method applies a transaction and sends it to the network to be + * confirmed and included in future ledgers. Expects a response in the form of a + * {@link SubmitResponse}. + * + * @category Requests + */ +export interface SubmitRequest extends BaseRequest { + command: 'submit'; + /** The complete transaction in hex string format. */ + tx_blob: string; + /** + * If true, and the transaction fails locally, do not retry or relay the + * transaction to other servers. The default is false. + */ + fail_hard?: boolean; +} + +/** + * Response expected from a {@link SubmitRequest}. + * + * @category Responses + */ +export interface SubmitResponse extends BaseResponse { + /** + * Text result code indicating the preliminary result of the transaction, + * for example `tesSUCCESS`. + */ + engine_result: string; + /** Numeric version of the result code. */ + engine_result_code: number; + /** Human-readable explanation of the transaction's preliminary result. */ + engine_result_message: string; + /** The complete transaction in hex string format. */ + tx_blob: string; + /** The complete transaction in JSON format. */ + tx_json: any & { hash?: string }; + /** + * The value true indicates that the transaction was applied, queued, + * broadcast, or kept for later. The value `false` indicates that none of + * those happened, so the transaction cannot possibly succeed as long as you + * do not submit it again and have not already submitted it another time. + */ + accepted: boolean; + /** + * The next Sequence Number available for the sending account after all + * pending and queued transactions. + */ + account_sequence_available: number; + /** + * The next Sequence number for the sending account after all transactions + * that have been provisionally applied, but not transactions in the queue. + */ + account_sequence_next: number; + /** + * The value true indicates that this transaction was applied to the open + * ledger. In this case, the transaction is likely, but not guaranteed, to + * be validated in the next ledger version. + */ + applied: boolean; + /** + * The value true indicates this transaction was broadcast to peer servers + * in the peer-to-peer XRP Ledger network. + */ + broadcast: boolean; + /** + * The value true indicates that the transaction was kept to be retried + * later. + */ + kept: boolean; + /** + * The value true indicates the transaction was put in the Transaction + * Queue, which means it is likely to be included in a future ledger + * version. + */ + queued: boolean; + /** + * The current open ledger cost before processing this transaction + * transactions with a lower cost are likely to be queued. + */ + open_ledger_cost: string; + /** + * The ledger index of the newest validated ledger at the time of + * submission. This provides a lower bound on the ledger versions that the + * transaction can appear in as a result of this request. + */ + validated_ledger_index: number; +} diff --git a/src/common/libs/ledger/types/methods/submitMultisigned.ts b/src/common/libs/ledger/types/methods/submitMultisigned.ts new file mode 100644 index 000000000..f07654174 --- /dev/null +++ b/src/common/libs/ledger/types/methods/submitMultisigned.ts @@ -0,0 +1,48 @@ +import { BaseRequest, BaseResponse } from './baseMethod'; +import { TransactionJson } from '../transaction'; + +/** + * The `submit_multisigned` command applies a multi-signed transaction and sends + * it to the network to be included in future ledgers. Expects a response in the + * form of a {@link SubmitMultisignedRequest}. + * + * @category Requests + */ +export interface SubmitMultisignedRequest extends BaseRequest { + command: 'submit_multisigned'; + /** + * Transaction in JSON format with an array of Signers. To be successful, the + * weights of the signatures must be equal or higher than the quorum of the. + * {@link Transaction Type/SignerList}. + */ + tx_json: any; + /** + * If true, and the transaction fails locally, do not retry or relay the + * transaction to other servers. + */ + fail_hard?: boolean; +} + +/** + * Response expected from a {@link SubmitMultisignedRequest}. + * + * @category Responses + */ +export interface SubmitMultisignedResponse extends BaseResponse { + /** + * Code indicating the preliminary result of the transaction, for example. + * `tesSUCCESS` . + */ + engine_result: string; + /** + * Numeric code indicating the preliminary result of the transaction, + * directly correlated to `engine_result`. + */ + engine_result_code: number; + /** Human-readable explanation of the preliminary transaction result. */ + engine_result_message: string; + /** The complete transaction in hex string format. */ + tx_blob: string; + /** The complete transaction in JSON format. */ + tx_json: TransactionJson & { hash?: string }; +} diff --git a/src/common/libs/ledger/types/methods/subscribe.ts b/src/common/libs/ledger/types/methods/subscribe.ts new file mode 100644 index 000000000..f30cd8ca0 --- /dev/null +++ b/src/common/libs/ledger/types/methods/subscribe.ts @@ -0,0 +1,412 @@ +import type { Amount, Currency, Path, StreamType, ResponseOnlyTxInfo } from '../common'; +import { Offer } from '../ledger'; +import { TransactionMetadata } from '../transaction'; + +import type { BaseRequest, BaseResponse } from './baseMethod'; + +export interface SubscribeBook { + /** + * Specification of which currency the account taking the Offer would + * receive, as a currency object with no amount. + */ + taker_gets: Currency; + /** + * Specification of which currency the account taking the Offer would pay, as + * a currency object with no amount. + */ + taker_pays: Currency; + /** + * Unique account address to use as a perspective for viewing offers, in the. + * XRP Ledger's base58 format. + */ + taker: string; + /** + * If true, return the current state of the order book once when you + * subscribe before sending updates. The default is false. + */ + snapshot?: boolean; + /** If true, return both sides of the order book. The default is false. */ + both?: boolean; +} + +/** + * The subscribe method requests periodic notifications from the server when + * certain events happen. Expects a response in the form of a + * {@link SubscribeResponse}. + * + * @category Requests + */ +export interface SubscribeRequest extends BaseRequest { + command: 'subscribe'; + /** Array of string names of generic streams to subscribe to. */ + streams?: StreamType[]; + /** + * Array with the unique addresses of accounts to monitor for validated + * transactions. The addresses must be in the XRP Ledger's base58 format. + * The server sends a notification for any transaction that affects at least + * one of these accounts. + */ + accounts?: string[]; + /** Like accounts, but include transactions that are not yet finalized. */ + accounts_proposed?: string[]; + /** + * Array of objects defining order books to monitor for updates, as detailed + * Below. + */ + books?: SubscribeBook[]; + /** + * URL where the server sends a JSON-RPC callbacks for each event. + * Admin-only. + */ + url?: string; + /** Username to provide for basic authentication at the callback URL. */ + url_username?: string; + /** Password to provide for basic authentication at the callback URL. */ + url_password?: string; +} + +export type BooksSnapshot = Offer[]; + +/** + * Response expected from a {@link SubscribeRequest}. + * + * @category Responses + */ +export interface SubscribeResponse extends BaseResponse, LedgerStreamResponse, BooksSnapshot {} + +interface BaseStream { + type: string; +} + +/** + * The `ledger` stream only sends `ledgerClosed` messages when the consensus + * process declares a new validated ledger. The message identifies the ledger + * And provides some information about its contents. + * + * @category Streams + */ +export interface LedgerStream extends BaseStream { + type: 'ledgerClosed'; + /** + * The reference transaction cost as of this ledger version, in drops of XRP. + * If this ledger version includes a SetFee pseudo-transaction the new. + * Transaction cost applies starting with the following ledger version. + */ + fee_base: number; + /** The reference transaction cost in "fee units". This is not returned after the SetFees amendment is enabled. */ + fee_ref?: number; + /** The identifying hash of the ledger version that was closed. */ + ledger_hash: string; + /** The ledger index of the ledger that was closed. */ + ledger_index: number; + /** The time this ledger was closed, in seconds since the Ripple Epoch. */ + ledger_time: number; + /** + * The minimum reserve, in drops of XRP, that is required for an account. If + * this ledger version includes a SetFee pseudo-transaction the new base reserve + * applies starting with the following ledger version. + */ + reserve_base: number; + /** + * The owner reserve for each object an account owns in the ledger, in drops + * of XRP. If the ledger includes a SetFee pseudo-transaction the new owner + * reserve applies after this ledger. + */ + reserve_inc: number; + /** Number of new transactions included in this ledger version. */ + txn_count: number; + /** + * Range of ledgers that the server has available. This may be a disjoint + * sequence such as 24900901-24900984,24901116-24901158. This field is not + * returned if the server is not connected to the network, or if it is + * connected but has not yet obtained a ledger from the network. + */ + validated_ledgers?: string; +} + +/** + * This response mirrors the LedgerStream, except it does NOT include the 'type' nor 'txn_count' fields. + */ +export interface LedgerStreamResponse { + /** + * The reference transaction cost as of this ledger version, in drops of XRP. + * If this ledger version includes a SetFee pseudo-transaction the new. + * Transaction cost applies starting with the following ledger version. + */ + fee_base: number; + /** The reference transaction cost in "fee units". This is not returned after the SetFees amendment is enabled. */ + fee_ref?: number; + /** The identifying hash of the ledger version that was closed. */ + ledger_hash: string; + /** The ledger index of the ledger that was closed. */ + ledger_index: number; + /** The time this ledger was closed, in seconds since the Ripple Epoch. */ + ledger_time: number; + /** + * The minimum reserve, in drops of XRP, that is required for an account. If + * this ledger version includes a SetFee pseudo-transaction the new base reserve + * applies starting with the following ledger version. + */ + reserve_base: number; + /** + * The owner reserve for each object an account owns in the ledger, in drops + * of XRP. If the ledger includes a SetFee pseudo-transaction the new owner + * reserve applies after this ledger. + */ + reserve_inc: number; + /** + * Range of ledgers that the server has available. This may be a disjoint + * sequence such as 24900901-24900984,24901116-24901158. This field is not + * returned if the server is not connected to the network, or if it is + * connected but has not yet obtained a ledger from the network. + */ + validated_ledgers?: string; +} + +/** + * The validations stream sends messages whenever it receives validation + * messages, also called validation votes, regardless of whether or not the + * validation message is from a trusted validator. + * + * @category Streams + */ +export interface ValidationStream extends BaseStream { + type: 'validationReceived'; + /** + * The value validationReceived indicates this is from the validations + * Stream. + */ + amendments?: string[]; + /** The amendments this server wants to be added to the protocol. */ + base_fee?: number; + /** + * An arbitrary value chosen by the server at startup. + * + * If the same validation key pair signs validations with different cookies + * concurrently, that usually indicates that multiple servers are incorrectly + * configured to use the same validation key pair. + */ + cookie?: string; + /** + * The contents of the validation message in its canonical binary form + */ + data?: string; + /** + * The unscaled transaction cost (reference_fee value) this server wants to + * set by Fee voting. + */ + flags: number; + /** + * Bit-mask of flags added to this validation message. The flag 0x80000000 + * indicates that the validation signature is fully-canonical. The flag + * 0x00000001 indicates that this is a full validation; otherwise it's a + * partial validation. Partial validations are not meant to vote for any + * particular ledger. A partial validation indicates that the validator is + * still online but not keeping up with consensus. + */ + full: boolean; + /** + * If true, this is a full validation. Otherwise, this is a partial + * validation. Partial validations are not meant to vote for any particular + * ledger. A partial validation indicates that the validator is still online + * but not keeping up with consensus. + */ + ledger_hash: string; + /** The ledger index of the proposed ledger. */ + ledger_index: string; + /** + * The local load-scaled transaction cost this validator is currently + * enforcing, in fee units. + */ + load_fee?: number; + /** + * The validator's master public key, if the validator is using a validator + * token, in the XRP Ledger's base58 format. + */ + master_key?: string; + /** + * The minimum reserve requirement (`account_reserve` value) this validator + * wants to set by fee voting. + */ + reserve_base?: number; + /** + * The increment in the reserve requirement (owner_reserve value) this + * validator wants to set by fee voting. + */ + reserve_inc?: number; + /** The signature that the validator used to sign its vote for this ledger. */ + signature: string; + /** When this validation vote was signed, in seconds since the Ripple Epoch. */ + signing_time: number; + /** + * The public key from the key-pair that the validator used to sign the + * message, in the XRP Ledger's base58 format. This identifies the validator + * sending the message and can also be used to verify the signature. If the + * validator is using a token, this is an ephemeral public key. + */ + validation_public_key: string; +} + +/** + * Many subscriptions result in messages about transactions. + * + * @category Streams + */ +export interface TransactionStream extends BaseStream { + status: string; + type: 'transaction'; + /** String Transaction result code. */ + engine_result: string; + /** Numeric transaction response code, if applicable. */ + engine_result_code: number; + /** Human-readable explanation for the transaction response. */ + engine_result_message: string; + /** + * The ledger index of the current in-progress ledger version for which this + * transaction is currently proposed. + */ + ledger_current_index?: number; + /** The identifying hash of the ledger version that includes this transaction. */ + ledger_hash?: string; + /** The ledger index of the ledger version that includes this transaction. */ + ledger_index?: number; + /** + * The transaction metadata, which shows the exact outcome of the transaction + * in detail. + */ + meta?: TransactionMetadata; + /** The definition of the transaction in JSON format. */ + transaction: any & ResponseOnlyTxInfo; + /** + * If true, this transaction is included in a validated ledger and its + * outcome is final. Responses from the transaction stream should always be + * validated. + */ + validated?: boolean; + warnings?: Array<{ id: number; message: string }>; +} + +/** + * The admin-only `peer_status` stream reports a large amount of information on + * the activities of other rippled servers to which this server is connected, in + * particular their status in the consensus process. + * + * @category Streams + */ +export interface PeerStatusStream extends BaseStream { + type: 'peerStatusChange'; + /** + * The type of event that prompted this message. See Peer Status Events for + * possible values. + */ + action: 'CLOSING_LEDGER' | 'ACCEPTED_LEDGER' | 'SWITCHED_LEDGER' | 'LOST_SYNC'; + /** The time this event occurred, in seconds since the Ripple Epoch. */ + date: number; + /** The identifying Hash of a ledger version to which this message pertains. */ + ledger_hash?: string; + /** The Ledger Index of a ledger version to which this message pertains. */ + ledger_index?: number; + /** The largest Ledger Index the peer has currently available. */ + ledger_index_max?: number; + /** The smallest Ledger Index the peer has currently available. */ + ledger_index_min?: number; +} + +/** + * When you subscribe to one or more order books with the `books` field, you + * get back any transactions that affect those order books. Has the same format + * as a {@link TransactionStream} but the transaction can have a `owner_funds` + * field. + * + * @category Streams + */ +export interface OrderBookStream extends BaseStream { + status: string; + type: 'transaction'; + engine_result: string; + engine_result_code: number; + engine_result_message: string; + ledger_current_index?: number; + ledger_hash?: string; + ledger_index?: number; + meta: TransactionMetadata; + transaction: any & { + /** + * This number measures the number of seconds since the "Ripple Epoch" of January 1, 2000 (00:00 UTC) + */ + date?: number; + /** + * Every signed transaction has a unique "hash" that identifies it. + * The transaction hash can be used to look up its final status, which may serve as a "proof of payment" + */ + hash?: string; + }; + validated: boolean; +} + +/** + * The consensus stream sends consensusPhase messages when the consensus + * process changes phase. The message contains the new phase of consensus the + * server is in. + * + * @category Streams + */ +export interface ConsensusStream extends BaseStream { + type: 'consensusPhase'; + /** + * The new consensus phase the server is in. Possible values are open, + * establish, and accepted. + */ + consensus: 'open' | 'establish' | 'accepted'; +} + +/** + * The path_find method searches for a path along which a transaction can + * possibly be made, and periodically sends updates when the path changes over + * time. + * + * @category Streams + */ +export interface PathFindStream extends BaseStream { + type: 'path_find'; + /** Unique address that would send a transaction. */ + source_account: string; + /** Unique address of the account that would receive a transaction. */ + destination_account: string; + /** Currency Amount that the destination would receive in a transaction. */ + destination_amount: Amount; + /** + * If false, this is the result of an incomplete search. A later reply may + * have a better path. If true, then this is the best path found. (It is still + * theoretically possible that a better path could exist, but rippled won't + * find it.) Until you close the pathfinding request, rippled continues to + * send updates each time a new ledger closes. + */ + full_reply: boolean; + /** The ID provided in the WebSocket request is included again at this level. */ + id: number | string; + /** Currency Amount that would be spent in the transaction. */ + send_max?: Amount; + /** + * Array of objects with suggested paths to take. If empty, then no paths + * were found connecting the source and destination accounts. + */ + alternatives: + | [] + | { + paths_computed: Path[]; + source_amount: Amount; + }; +} + +/** + * @category Streams + */ +export type Stream = + | LedgerStream + | ValidationStream + | TransactionStream + | PathFindStream + | PeerStatusStream + | OrderBookStream + | ConsensusStream; diff --git a/src/common/libs/ledger/types/methods/transactionEntry.ts b/src/common/libs/ledger/types/methods/transactionEntry.ts new file mode 100644 index 000000000..8dd017652 --- /dev/null +++ b/src/common/libs/ledger/types/methods/transactionEntry.ts @@ -0,0 +1,43 @@ +import { ResponseOnlyTxInfo } from '../common'; +import { TransactionJson, TransactionMetadata } from '../transaction'; + +import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'; + +/** + * The `transaction_entry` method retrieves information on a single transaction + * from a specific ledger version. Expects a response in the form of a + * {@link TransactionEntryResponse}. + * + * @category Requests + */ +export interface TransactionEntryRequest extends BaseRequest, LookupByLedgerRequest { + command: 'transaction_entry'; + + /** Unique hash of the transaction you are looking up. */ + tx_hash: string; +} + +/** + * Response expected from a {@link TransactionEntryRequest}. + * + * @category Responses + */ +export interface TransactionEntryResponse extends BaseResponse { + /** + * The identifying hash of the ledger version the transaction was found in; + * this is the same as the one from the request. + */ + ledger_hash: string; + /** + * The ledger index of the ledger version the transaction was found in; + * this is the same as the one from the request. + */ + ledger_index: number; + /** + * The transaction metadata, which shows the exact results of the + * transaction in detail. + */ + metadata: TransactionMetadata; + /** JSON representation of the Transaction object. */ + tx_json: TransactionJson & ResponseOnlyTxInfo; +} diff --git a/src/common/libs/ledger/types/methods/tx.ts b/src/common/libs/ledger/types/methods/tx.ts new file mode 100644 index 000000000..60b5e54fa --- /dev/null +++ b/src/common/libs/ledger/types/methods/tx.ts @@ -0,0 +1,77 @@ +import { TransactionJson } from '../transaction/common'; +import { TransactionMetadata } from '../transaction/metadata'; + +import { BaseRequest, BaseResponse } from './baseMethod'; + +/** + * The tx method retrieves information on a single transaction, by its + * identifying hash. Expects a response in the form of a {@link TxResponse}. + * + * @category Requests + */ +export interface TxRequest extends BaseRequest { + command: 'tx'; + /** + * The transaction hash to look up. Exactly one of `transaction` or `ctid` must be specified for a TxRequest. + */ + transaction?: string; + /** + * The Concise Transaction ID to look up. Exactly one of `transaction` or `ctid` must be specified for a TxRequest. + */ + ctid?: string; + /** + * If true, return transaction data and metadata as binary serialized to + * hexadecimal strings. If false, return transaction data and metadata as. + * JSON. The default is false. + */ + binary?: boolean; + /** + * Use this with max_ledger to specify a range of up to 1000 ledger indexes, + * starting with this ledger (inclusive). If the server cannot find the + * transaction, it confirms whether it was able to search all the ledgers in + * this range. + */ + min_ledger?: number; + /** + * Use this with min_ledger to specify a range of up to 1000 ledger indexes, + * ending with this ledger (inclusive). If the server cannot find the + * transaction, it confirms whether it was able to search all the ledgers in + * the requested range. + */ + max_ledger?: number; +} + +/** + * Response expected from a {@link TxRequest}. + * + * @category Responses + */ +export interface TxResponse extends TransactionJson, BaseResponse { + /** The SHA-512 hash of the transaction. */ + hash: string; + /** + * The Concise Transaction Identifier of the transaction (16-byte hex string) + */ + ctid?: string; + /** The ledger index of the ledger that includes this transaction. */ + ledger_index: number; + /** Transaction metadata, which describes the results of the transaction. */ + + meta: TransactionMetadata; + /** + * If true, this data comes from a validated ledger version; if omitted or. + * Set to false, this data is not final. + */ + validated: boolean; + /** + * This number measures the number of seconds since the "Ripple Epoch" of January 1, 2000 (00:00 UTC) + */ + date?: number; + /** + * If true, the server was able to search all of the specified ledger + * versions, and the transaction was in none of them. If false, the server did + * not have all of the specified ledger versions available, so it is not sure. + * If one of them might contain the transaction. + */ + searched_all?: boolean; +} diff --git a/src/common/libs/ledger/types/methods/unsubscribe.ts b/src/common/libs/ledger/types/methods/unsubscribe.ts new file mode 100644 index 000000000..618d9996b --- /dev/null +++ b/src/common/libs/ledger/types/methods/unsubscribe.ts @@ -0,0 +1,47 @@ +import { Currency, StreamType } from '../common'; + +import type { BaseRequest, BaseResponse } from './baseMethod'; + +export interface UnsubscribeBook { + taker_gets: Currency; + taker_pays: Currency; + both?: boolean; +} + +/** + * The unsubscribe command tells the server to stop sending messages for a + * particular subscription or set of subscriptions. Expects a response in the + * form of an {@link UnsubscribeResponse}. + * + * @category Requests + */ +export interface UnsubscribeRequest extends BaseRequest { + command: 'unsubscribe'; + /** + * Array of string names of generic streams to unsubscribe from, including. + * Ledger, server, transactions, and transactions_proposed. + */ + streams?: StreamType[]; + /** + * Array of unique account addresses to stop receiving updates for, in the. + * XRP Ledger's base58 format. + */ + accounts?: string[]; + /** + * Like accounts, but for accounts_proposed subscriptions that included + * not-yet-validated transactions. + */ + accounts_proposed?: string[]; + /** + * Array of objects defining order books to unsubscribe from, as explained + * below. + */ + books?: UnsubscribeBook[]; +} + +/** + * Response expected from a {@link UnsubscribeRequest}. + * + * @category Responses + */ +export interface UnsubscribeResponse extends BaseResponse {} diff --git a/src/common/libs/ledger/types/transaction/common.ts b/src/common/libs/ledger/types/transaction/common.ts new file mode 100644 index 000000000..8a24bd3b0 --- /dev/null +++ b/src/common/libs/ledger/types/transaction/common.ts @@ -0,0 +1,83 @@ +import { Memo, Signer } from '../common'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; + +/** + * Every transaction has the same set of common fields. + */ +export interface TransactionJson { + /** The unique address of the transaction sender. */ + Account: string; + /** + * The type of transaction. Valid types include: `Payment`, `OfferCreate`, + * `TrustSet`, and many others. + */ + TransactionType: TransactionTypes; + /** + * Integer amount of XRP, in drops, to be destroyed as a cost for + * distributing this transaction to the network. Some transaction types have + * different minimum requirements. + */ + Fee?: string; + /** + * The sequence number of the account sending the transaction. A transaction + * is only valid if the Sequence number is exactly 1 greater than the previous + * transaction from the same account. The special case 0 means the transaction + * is using a Ticket instead. + */ + Sequence?: number; + /** + * Hash value identifying another transaction. If provided, this transaction + * is only valid if the sending account's previously-sent transaction matches + * the provided hash. + */ + AccountTxnID?: string; + /** Set of bit-flags for this transaction. */ + Flags?: number; + /** + * Highest ledger index this transaction can appear in. Specifying this field + * places a strict upper limit on how long the transaction can wait to be + * validated or rejected. + */ + LastLedgerSequence?: number; + /** + * Additional arbitrary information used to identify this transaction. + */ + Memos?: Memo[]; + /** + * Array of objects that represent a multi-signature which authorizes this + * transaction. + */ + Signers?: Signer[]; + /** + * Arbitrary integer used to identify the reason for this payment, or a sender + * on whose behalf this transaction is made. Conventionally, a refund should + * specify the initial payment's SourceTag as the refund payment's + * DestinationTag. + */ + SourceTag?: number; + /** + * Hex representation of the public key that corresponds to the private key + * used to sign this transaction. If an empty string, indicates a + * multi-signature is present in the Signers field instead. + */ + SigningPubKey?: string; + /** + * The sequence number of the ticket to use in place of a Sequence number. If + * this is provided, Sequence must be 0. Cannot be used with AccountTxnID. + */ + TicketSequence?: number; + /** + * The signature that verifies this transaction as originating from the + * account it says it is from. + */ + TxnSignature?: string; + /** + * The network id of the transaction. + */ + NetworkID?: number; + + /** + * Rest of fields + */ + [Field: string]: string | number | Array | undefined | object | boolean; +} diff --git a/src/common/libs/ledger/types/transaction/index.ts b/src/common/libs/ledger/types/transaction/index.ts new file mode 100644 index 000000000..00b1fa712 --- /dev/null +++ b/src/common/libs/ledger/types/transaction/index.ts @@ -0,0 +1,2 @@ +export * from './metadata'; +export * from './common'; diff --git a/src/common/libs/ledger/types/transaction/metadata.ts b/src/common/libs/ledger/types/transaction/metadata.ts new file mode 100644 index 000000000..e01a89986 --- /dev/null +++ b/src/common/libs/ledger/types/transaction/metadata.ts @@ -0,0 +1,41 @@ +import { Amount, HookExecution, HookEmission } from '../common'; + +export interface CreatedNode { + CreatedNode: { + LedgerEntryType: string; + LedgerIndex: string; + NewFields: { [field: string]: unknown }; + }; +} + +export interface ModifiedNode { + ModifiedNode: { + LedgerEntryType: string; + LedgerIndex: string; + FinalFields?: { [field: string]: unknown }; + PreviousFields?: { [field: string]: unknown }; + PreviousTxnID?: string; + PreviousTxnLgrSeq?: number; + }; +} + +export interface DeletedNode { + DeletedNode: { + LedgerEntryType: string; + LedgerIndex: string; + FinalFields: { [field: string]: unknown }; + }; +} + +export type Node = CreatedNode | ModifiedNode | DeletedNode; + +export interface TransactionMetadata { + AffectedNodes: Node[]; + DeliveredAmount?: Amount; + // "unavailable" possible for transactions before 2014-01-20 + delivered_amount?: Amount | 'unavailable'; + TransactionIndex: number; + TransactionResult: string; + HookExecutions?: HookExecution[]; + HookEmissions?: HookEmission[]; +} diff --git a/src/common/libs/payload/digest/codec.ts b/src/common/libs/payload/digest/codec.ts index 562fc2883..d1106fb6c 100644 --- a/src/common/libs/payload/digest/codec.ts +++ b/src/common/libs/payload/digest/codec.ts @@ -3,13 +3,17 @@ */ import { mapKeys } from 'lodash'; -import * as AccountLib from 'xrpl-accountlib'; +import { binary as AccountLibBinary } from 'xrpl-accountlib'; import { GetDeviceUniqueId } from '@common/helpers/device'; import { SHA1 } from '@common/libs/crypto'; -import { PseudoTransactionTypes, TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; import Digest from './digest'; + +/* Types ==================================================================== */ +import { TransactionJson } from '@common/libs/ledger/types/transaction'; +import { PseudoTransactionTypes, TransactionTypes } from '@common/libs/ledger/types/enums'; + /* Class ==================================================================== */ class DigestCodecWithSHA1 extends Digest { /** @@ -21,18 +25,18 @@ class DigestCodecWithSHA1 extends Digest { /** * Calculate the digest using SHA-1 algorithm and binary codec. * - * @param {TransactionJSONType} request_json - Transaction JSON data to be hashed. + * @param {TransactionJson} request_json - Transaction JSON data to be hashed. * @param {TransactionTypes | PseudoTransactionTypes} tx_type - The type of transaction. * @returns {Promise} A promise that resolves with the SHA-1 hash and codec. * @deprecated SHA-1 is a deprecated and insecure hashing algorithm. Use a more secure hashing method. */ static digest = ( - request_json: TransactionJSONType, + request_json: TransactionJson, tx_type: TransactionTypes | PseudoTransactionTypes, ): Promise => { return new Promise((resolve, reject) => { let hashEncodingMethod = 'encode'; - let normalizedRequestJson = request_json; + let normalizedRequestJson: Object = request_json; // if it's the pseudo PaymentChannelAuthorize we need // 1) use encodeForSigningClaim method for encoding @@ -44,7 +48,7 @@ class DigestCodecWithSHA1 extends Digest { // calculate checksum // @ts-ignore - const checksum = AccountLib.binary[hashEncodingMethod](normalizedRequestJson); + const checksum = AccountLibBinary[hashEncodingMethod](normalizedRequestJson); // calculate digest SHA1{checksum}+{deviceId} const deviceId = GetDeviceUniqueId(); diff --git a/src/common/libs/payload/digest/digest.ts b/src/common/libs/payload/digest/digest.ts index c9259f62f..b10fc443a 100644 --- a/src/common/libs/payload/digest/digest.ts +++ b/src/common/libs/payload/digest/digest.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ - -import { PseudoTransactionTypes, TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson } from '@common/libs/ledger/types/transaction'; +import { PseudoTransactionTypes, TransactionTypes } from '@common/libs/ledger/types/enums'; /** * Abstract Class Digest. @@ -15,7 +15,7 @@ abstract class Digest { } static digest = ( - request_json: TransactionJSONType, + request_json: TransactionJson, tx_type?: TransactionTypes | PseudoTransactionTypes, ): Promise => { throw new Error('Method digest() must be implemented.'); diff --git a/src/common/libs/payload/digest/serialize.ts b/src/common/libs/payload/digest/serialize.ts index ac3196393..309cfb294 100644 --- a/src/common/libs/payload/digest/serialize.ts +++ b/src/common/libs/payload/digest/serialize.ts @@ -4,10 +4,12 @@ import { GetDeviceUniqueId } from '@common/helpers/device'; import { SHA1 } from '@common/libs/crypto'; -import { TransactionJSONType } from '@common/libs/ledger/types'; import Digest from './digest'; +/* Types ==================================================================== */ +import { TransactionJson } from '@common/libs/ledger/types/transaction'; + /* Class ==================================================================== */ class DigestSerializeWithSHA1 extends Digest { /** @@ -45,11 +47,11 @@ class DigestSerializeWithSHA1 extends Digest { /** * Calculate the digest of a serialized object using the SHA-1 algorithm. * - * @param {TransactionJSONType} request_json - The JSON data to be serialized and hashed. + * @param {TransactionJson} request_json - The JSON data to be serialized and hashed. * @returns {Promise} A promise that resolves with the SHA-1 hash. * @throws {Error} Throws an error if the input data is not a valid object. */ - static digest = (request_json: TransactionJSONType): Promise => { + static digest = (request_json: TransactionJson): Promise => { return new Promise((resolve, reject) => { if (typeof request_json !== 'object' || !request_json) { reject(new Error('digest `request_json` should be valid object!')); diff --git a/src/common/libs/payload/object.ts b/src/common/libs/payload/object.ts index 207387b13..35161cacc 100644 --- a/src/common/libs/payload/object.ts +++ b/src/common/libs/payload/object.ts @@ -7,7 +7,8 @@ import { TransactionFactory } from '@common/libs/ledger/factory'; import Localize from '@locale'; -import { PseudoTransactionTypes, TransactionJSONType, TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionJson } from '@common/libs/ledger/types/transaction'; +import { PseudoTransactionTypes, TransactionTypes } from '@common/libs/ledger/types/enums'; import { PseudoTransactions, Transactions } from '@common/libs/ledger/transactions/types'; import { ApplicationType, @@ -69,7 +70,7 @@ export class Payload { * @param TxJson Ledger format TXJson * @param message */ - static build(TxJson: TransactionJSONType, message?: string): Payload { + static build(TxJson: TransactionJson, message?: string): Payload { const instance = new Payload(); // force the signer accounts if account is set in transaction diff --git a/src/common/libs/payload/types.ts b/src/common/libs/payload/types.ts index bec5b1d59..d16a2ea12 100644 --- a/src/common/libs/payload/types.ts +++ b/src/common/libs/payload/types.ts @@ -1,10 +1,6 @@ -import { - TransactionJSONType, - SubmitResultType, - SignedObjectType, - TransactionTypes, - PseudoTransactionTypes, -} from '../ledger/types'; +import { SubmitResultType, SignedObjectType } from '../ledger/types'; +import { PseudoTransactionTypes, TransactionTypes } from '@common/libs/ledger/types/enums'; +import { TransactionJson } from '@common/libs/ledger/types/transaction'; export interface PayloadType { meta: MetaType; @@ -48,7 +44,7 @@ export interface PayloadReferenceType { tx_type: TransactionTypes | PseudoTransactionTypes; tx_destination?: string; tx_destination_tag?: any; - request_json: TransactionJSONType; + request_json: TransactionJson; created_at?: string; expires_at?: string; hash?: string; diff --git a/src/common/utils/fee.ts b/src/common/utils/fee.ts index 8a36721b0..8e5b5e56e 100644 --- a/src/common/utils/fee.ts +++ b/src/common/utils/fee.ts @@ -52,8 +52,8 @@ const PrepareTxForHookFee = (txJson: any, definitions: any): string => { * @returns object */ const NormalizeFeeDataSet = (feeDataSet: { - drops: { base_fee: number }; - fee_hooks_feeunits: number; + drops: { base_fee: string }; + fee_hooks_feeunits: string; }): { availableFees: { type: 'LOW' | 'MEDIUM' | 'HIGH'; diff --git a/src/components/Modules/AssetsList/NFTokens/NFTokensList.tsx b/src/components/Modules/AssetsList/NFTokens/NFTokensList.tsx index 354d2918d..697d14e8c 100644 --- a/src/components/Modules/AssetsList/NFTokens/NFTokensList.tsx +++ b/src/components/Modules/AssetsList/NFTokens/NFTokensList.tsx @@ -9,7 +9,7 @@ import { Navigator } from '@common/helpers/navigator'; import { AppConfig, AppScreens } from '@common/constants'; import { Toast } from '@common/helpers/interface'; -import { TransactionTypes } from '@common/libs/ledger/types'; +import { TransactionTypes } from '@common/libs/ledger/types/enums'; import { AccountModel } from '@store/models'; diff --git a/src/components/Modules/EventsList/EventListItems/LedgerObject.tsx b/src/components/Modules/EventsList/EventListItems/LedgerObject.tsx index 20fb5e107..a7083a182 100644 --- a/src/components/Modules/EventsList/EventListItems/LedgerObject.tsx +++ b/src/components/Modules/EventsList/EventListItems/LedgerObject.tsx @@ -7,7 +7,7 @@ import { AccountModel } from '@store/models'; import { AppScreens } from '@common/constants'; import { LedgerObjects } from '@common/libs/ledger/objects/types'; -import { LedgerObjectTypes } from '@common/libs/ledger/types'; +import { LedgerEntryTypes } from '@common/libs/ledger/types/enums'; import { ExplainerFactory } from '@common/libs/ledger/factory'; import { Navigator } from '@common/helpers/navigator'; @@ -159,13 +159,13 @@ class LedgerObjectItem extends Component { const { recipientDetails } = this.state; const { item } = this.props; - if (item.Type === LedgerObjectTypes.Offer) { + if (item.Type === LedgerEntryTypes.Offer) { return `${Localize.formatNumber(NormalizeAmount(item.TakerGets.value))} ${NormalizeCurrencyCode( item.TakerGets.currency, )}/${NormalizeCurrencyCode(item.TakerPays.currency)}`; } - if (item.Type === LedgerObjectTypes.NFTokenOffer) { + if (item.Type === LedgerEntryTypes.NFTokenOffer) { return item.NFTokenID; } @@ -178,7 +178,7 @@ class LedgerObjectItem extends Component { renderRightPanel = () => { const { item, account } = this.props; - if (item.Type === LedgerObjectTypes.Escrow) { + if (item.Type === LedgerEntryTypes.Escrow) { const incoming = item.Destination?.address === account.address; return ( { ); } - if (item.Type === LedgerObjectTypes.Check) { + if (item.Type === LedgerEntryTypes.Check) { return ( { ); } - if (item.Type === LedgerObjectTypes.Offer) { + if (item.Type === LedgerEntryTypes.Offer) { return ( { ); } - if (item.Type === LedgerObjectTypes.NFTokenOffer) { + if (item.Type === LedgerEntryTypes.NFTokenOffer) { return ( void; + onPress?: (item: PathFindPathOption) => void; } /* Component ==================================================================== */ @@ -107,7 +108,7 @@ class PaymentOptionItem extends Component { } }; - renderNative = (item: PathOption) => { + renderNative = (item: PathFindPathOption) => { const { source_amount } = item; if (typeof source_amount !== 'string') { @@ -131,7 +132,7 @@ class PaymentOptionItem extends Component { ); }; - renderIOU = (item: PathOption) => { + renderIOU = (item: PathFindPathOption) => { const { amount } = this.props; const { source_amount, paths_computed } = item; @@ -146,8 +147,8 @@ class PaymentOptionItem extends Component { if (Array.isArray(paths_computed) && paths_computed.length === 0 && typeof amount === 'object') { issuer = amount.issuer; } else { - const typeOneStep = find(flatMap(paths_computed), (o) => { - return o.type === 1; + const typeOneStep = find(flatMap(paths_computed), (computed) => { + return computed.type === 1; }); if (typeOneStep) { diff --git a/src/components/Modules/PaymentOptionsPicker/PaymentOptionsPicker.tsx b/src/components/Modules/PaymentOptionsPicker/PaymentOptionsPicker.tsx index 2141051c0..35c02b2b5 100644 --- a/src/components/Modules/PaymentOptionsPicker/PaymentOptionsPicker.tsx +++ b/src/components/Modules/PaymentOptionsPicker/PaymentOptionsPicker.tsx @@ -5,18 +5,18 @@ import { View, ViewStyle, InteractionManager } from 'react-native'; import LedgerService from '@services/LedgerService'; import NetworkService from '@services//NetworkService'; -import { AmountType } from '@common/libs/ledger/parser/types'; - import { Button, InfoMessage } from '@components/General'; import { PaymentOptionItem } from '@components/Modules/PaymentOptionsPicker/PaymentOptionItem'; import { Amount } from '@common/libs/ledger/parser/common'; -import { PathOption } from '@common/libs/ledger/types'; +import { PathFindPathOption } from '@common/libs/ledger/types/methods'; + import LedgerPathFinding from '@common/libs/ledger/pathFinding'; import Locale from '@locale'; import styles from './styles'; +import { AmountType } from '@common/libs/ledger/parser/types'; /* Types ==================================================================== */ interface Props { @@ -26,13 +26,13 @@ interface Props { containerStyle?: ViewStyle; onLoad?: () => void; onLoadEnd?: () => void; - onSelect?: (item: PathOption) => void; + onSelect?: (item: PathFindPathOption) => void; } interface State { - paymentOptions: PathOption[]; - localOption: PathOption; - selectedItem: PathOption; + paymentOptions: PathFindPathOption[]; + localOption: PathFindPathOption; + selectedItem: PathFindPathOption; isLoading: boolean; isExpired: boolean; } @@ -140,7 +140,7 @@ class PaymentOptionsPicker extends Component { // eslint-disable-next-line no-async-promise-executor return new Promise(async (resolve) => { - let localOption = undefined as PathOption; + let localOption = undefined as PathFindPathOption; try { // paying native currency @@ -156,7 +156,10 @@ class PaymentOptionsPicker extends Component { // eslint-disable-next-line no-lonely-if if (amount.issuer !== source) { // source is not the issuer - const sourceLine = await LedgerService.getFilteredAccountLine(source, amount); + const sourceLine = await LedgerService.getFilteredAccountLine(source, { + issuer: amount.issuer, + currency: amount.currency, + }); // can pay the amount if ( @@ -183,11 +186,25 @@ class PaymentOptionsPicker extends Component { }; } } else { - localOption = { source_amount: amount, paths_computed: [] }; + localOption = { + source_amount: { + issuer: amount.issuer, + currency: amount.currency, + value: amount.value, + }, + paths_computed: [], + }; } } } else { - localOption = { source_amount: amount, paths_computed: [] }; + localOption = { + source_amount: { + issuer: amount.issuer, + currency: amount.currency, + value: amount.value, + }, + paths_computed: [], + }; } } } catch { @@ -250,7 +267,7 @@ class PaymentOptionsPicker extends Component { }); }; - onItemSelect = (item: PathOption) => { + onItemSelect = (item: PathFindPathOption) => { const { onSelect } = this.props; const { selectedItem } = this.state; @@ -271,7 +288,7 @@ class PaymentOptionsPicker extends Component { } }; - renderItem = (item: PathOption, index: number): React.ReactElement => { + renderItem = (item: PathFindPathOption, index: number): React.ReactElement => { const { amount } = this.props; const { selectedItem } = this.state; diff --git a/src/screens/Events/Details/DetailsView.tsx b/src/screens/Events/Details/DetailsView.tsx index 7e313589d..b7144e51c 100644 --- a/src/screens/Events/Details/DetailsView.tsx +++ b/src/screens/Events/Details/DetailsView.tsx @@ -15,7 +15,7 @@ import { AccountModel } from '@store/models'; import { Payload, XAppOrigin } from '@common/libs/payload'; -import { LedgerObjectTypes, TransactionTypes } from '@common/libs/ledger/types'; +import { LedgerEntryTypes, TransactionTypes } from '@common/libs/ledger/types/enums'; import { BaseTransaction } from '@common/libs/ledger/transactions'; import { Transactions } from '@common/libs/ledger/transactions/types'; @@ -50,6 +50,7 @@ import Localize from '@locale'; // style import { AppStyles } from '@theme'; import styles from './styles'; +import { TransactionJson } from '@common/libs/ledger/types/transaction'; /* types ==================================================================== */ export interface Props { @@ -313,7 +314,7 @@ class TransactionDetailsView extends Component { return; } - let transaction = {}; + let transaction: TransactionJson; switch (type) { case 'OfferCancel': @@ -346,7 +347,7 @@ class TransactionDetailsView extends Component { } break; case 'CheckCancel': - if (tx.Type === LedgerObjectTypes.Check) { + if (tx.Type === LedgerEntryTypes.Check) { Object.assign(transaction, { TransactionType: 'CheckCancel', CheckID: tx.Index, @@ -354,7 +355,7 @@ class TransactionDetailsView extends Component { } break; case 'CheckCash': - if (tx.Type === LedgerObjectTypes.Check) { + if (tx.Type === LedgerEntryTypes.Check) { Object.assign(transaction, { TransactionType: 'CheckCash', CheckID: tx.Index, @@ -376,7 +377,7 @@ class TransactionDetailsView extends Component { }); break; case 'CancelTicket': - if (tx.Type === LedgerObjectTypes.Ticket) { + if (tx.Type === LedgerEntryTypes.Ticket) { Object.assign(transaction, { TransactionType: 'AccountSet', Sequence: 0, @@ -394,7 +395,7 @@ class TransactionDetailsView extends Component { Object.assign(transaction, { Account: account.address }); // generate payload - const payload = await Payload.build(transaction); + const payload = Payload.build(transaction); Navigator.showModal( AppScreens.Modal.ReviewTransaction, @@ -517,7 +518,7 @@ class TransactionDetailsView extends Component { // ledger objects always have reserve change increase if (tx instanceof BaseLedgerObject) { // ignore for incoming NFTokenOffers - if (tx.Type === LedgerObjectTypes.NFTokenOffer && tx.Owner !== account.address) { + if (tx.Type === LedgerEntryTypes.NFTokenOffer && tx.Owner !== account.address) { return null; } changes = { @@ -597,7 +598,7 @@ class TransactionDetailsView extends Component { !( tx.Type === TransactionTypes.Payment || tx.Type === TransactionTypes.CheckCreate || - tx.Type === LedgerObjectTypes.Check + tx.Type === LedgerEntryTypes.Check ) || isUndefined(tx.InvoiceID) ) { @@ -701,11 +702,11 @@ class TransactionDetailsView extends Component { if (tx instanceof BaseLedgerObject) { if ( [ - LedgerObjectTypes.Offer, - LedgerObjectTypes.NFTokenOffer, - LedgerObjectTypes.Check, - LedgerObjectTypes.Ticket, - LedgerObjectTypes.PayChannel, + LedgerEntryTypes.Offer, + LedgerEntryTypes.NFTokenOffer, + LedgerEntryTypes.Check, + LedgerEntryTypes.Ticket, + LedgerEntryTypes.PayChannel, ].includes(tx.Type) ) { badgeType = 'open'; @@ -718,7 +719,7 @@ class TransactionDetailsView extends Component { let date; - if (tx.Type !== LedgerObjectTypes.Ticket) { + if (tx.Type !== LedgerEntryTypes.Ticket) { date = moment(tx.Date).format('LLLL'); } @@ -803,7 +804,7 @@ class TransactionDetailsView extends Component { break; } case TransactionTypes.EscrowCreate: - case LedgerObjectTypes.Escrow: + case LedgerEntryTypes.Escrow: Object.assign(props, { color: tx.Account.address === account.address ? styles.orangeColor : styles.naturalColor, prefix: tx.Account.address === account.address ? '-' : '', @@ -825,7 +826,7 @@ class TransactionDetailsView extends Component { }); break; case TransactionTypes.CheckCreate: - case LedgerObjectTypes.Check: + case LedgerEntryTypes.Check: Object.assign(props, { color: styles.naturalColor, value: tx.SendMax.value, @@ -866,7 +867,7 @@ class TransactionDetailsView extends Component { } break; - case LedgerObjectTypes.Offer: + case LedgerEntryTypes.Offer: Object.assign(props, { color: styles.naturalColor, icon: 'IconCornerRightDown', @@ -894,7 +895,7 @@ class TransactionDetailsView extends Component { } break; } - case LedgerObjectTypes.NFTokenOffer: { + case LedgerEntryTypes.NFTokenOffer: { let icon; if (tx.Owner !== account.address) { icon = tx.Flags.SellToken ? 'IconCornerRightUp' : 'IconCornerRightDown'; @@ -968,7 +969,7 @@ class TransactionDetailsView extends Component { } break; } - case LedgerObjectTypes.PayChannel: + case LedgerEntryTypes.PayChannel: break; default: shouldShowAmount = false; @@ -979,7 +980,7 @@ class TransactionDetailsView extends Component { return null; } - if (tx.Type === TransactionTypes.OfferCreate || tx.Type === LedgerObjectTypes.Offer) { + if (tx.Type === TransactionTypes.OfferCreate || tx.Type === LedgerEntryTypes.Offer) { let takerGets; if ( @@ -1092,7 +1093,7 @@ class TransactionDetailsView extends Component { } if ( - tx.Type === LedgerObjectTypes.NFTokenOffer || + tx.Type === LedgerEntryTypes.NFTokenOffer || tx.Type === TransactionTypes.NFTokenCreateOffer || tx.Type === TransactionTypes.NFTokenAcceptOffer ) { @@ -1123,7 +1124,7 @@ class TransactionDetailsView extends Component { ); } - if (tx.Type === LedgerObjectTypes.PayChannel) { + if (tx.Type === LedgerEntryTypes.PayChannel) { return ( {Localize.t('events.payChannelAmount')} @@ -1205,14 +1206,14 @@ class TransactionDetailsView extends Component { }); } break; - case LedgerObjectTypes.Offer: + case LedgerEntryTypes.Offer: actionButtons.push({ label: Localize.t('events.cancelOffer'), type: 'OfferCancel', secondary: true, }); break; - case LedgerObjectTypes.NFTokenOffer: + case LedgerEntryTypes.NFTokenOffer: if (tx.Owner === account.address) { actionButtons.push({ label: Localize.t('events.cancelOffer'), @@ -1235,7 +1236,7 @@ class TransactionDetailsView extends Component { } } break; - case LedgerObjectTypes.Escrow: + case LedgerEntryTypes.Escrow: if (tx.isExpired) { actionButtons.push({ label: Localize.t('events.cancelEscrow'), @@ -1253,7 +1254,7 @@ class TransactionDetailsView extends Component { } break; - case LedgerObjectTypes.Check: + case LedgerEntryTypes.Check: if (tx.Destination.address === account.address && !tx.isExpired) { actionButtons.push({ label: Localize.t('events.cashCheck'), @@ -1269,7 +1270,7 @@ class TransactionDetailsView extends Component { }); } break; - case LedgerObjectTypes.Ticket: + case LedgerEntryTypes.Ticket: actionButtons.push({ label: Localize.t('events.cancelTicket'), type: 'CancelTicket', @@ -1307,7 +1308,7 @@ class TransactionDetailsView extends Component { const warnings = [] as Array; - if (tx.Type === LedgerObjectTypes.NFTokenOffer) { + if (tx.Type === LedgerEntryTypes.NFTokenOffer) { // incoming offer with destination set other than if (tx.Owner !== account.address && tx.Destination && tx.Destination.address !== account.address) { warnings.push(Localize.t('events.thisOfferCanOnlyBeAcceptedByThirdParty')); @@ -1389,7 +1390,7 @@ class TransactionDetailsView extends Component { } } - if (tx.Type === LedgerObjectTypes.NFTokenOffer) { + if (tx.Type === LedgerEntryTypes.NFTokenOffer) { if (tx.Owner === account.address) { from = { address: account.address, diff --git a/src/screens/Events/EventsView.tsx b/src/screens/Events/EventsView.tsx index 135b179dc..32433916b 100644 --- a/src/screens/Events/EventsView.tsx +++ b/src/screens/Events/EventsView.tsx @@ -32,13 +32,16 @@ import { Navigator } from '@common/helpers/navigator'; // Parses import { LedgerObjectFactory, TransactionFactory } from '@common/libs/ledger/factory'; -import { LedgerEntriesTypes, LedgerMarker, LedgerObjectTypes, TransactionTypes } from '@common/libs/ledger/types'; -import { Transactions } from '@common/libs/ledger/transactions/types'; +import { TransactionTypes, LedgerEntryTypes } from '@common/libs/ledger/types/enums'; import { NFTokenOffer } from '@common/libs/ledger/objects'; -import { LedgerObjects } from '@common/libs/ledger/objects/types'; import { Payload } from '@common/libs/payload'; // types +import { LedgerObjects } from '@common/libs/ledger/objects/types'; +import { LedgerMarker } from '@common/libs/ledger/types/common'; +import { Transactions } from '@common/libs/ledger/transactions/types'; +import { LedgerEntry } from '@common/libs/ledger/types/ledger'; + import { FilterProps } from '@screens/Modal/FilterEvents/EventsFilterView'; // Services @@ -56,6 +59,8 @@ import { AppStateStatus } from '@services/AppService'; import { Button, Header, SearchBar, SegmentButton } from '@components/General'; import { EventsFilterChip, EventsList } from '@components/Modules'; +import { DataSourceItem, DataSourceItemType } from '@components/Modules/EventsList/EventsList'; + // Locale import Localize from '@locale'; @@ -80,7 +85,7 @@ export interface State { transactions: Array; plannedTransactions: Array; pendingRequests: Array; - dataSource: Array; + dataSource: Array; } enum DataSourceType { @@ -245,18 +250,39 @@ class EventsView extends Component { } }; + formatDate = (date: string) => { + const momentDate = moment(date); + const reference = moment(); + + if (momentDate.isSame(reference, 'day')) { + return Localize.t('global.today'); + } + if (momentDate.isSame(reference.subtract(1, 'days'), 'day')) { + return Localize.t('global.yesterday'); + } + + // same year, don't show year + if (momentDate.isSame(reference, 'year')) { + return momentDate.format('DD MMM'); + } + + return momentDate.format('DD MMM, Y'); + }; + fetchPlannedObjects = async ( account: string, type: string, marker?: string, - combined = [] as LedgerEntriesTypes[], - ): Promise => { + combined = [] as LedgerEntry[], + ): Promise => { return LedgerService.getAccountObjects(account, { type, marker }).then((resp) => { - const { error, account_objects, marker: _marker } = resp; // account is not found - if (error && error === 'actNotFound') { + if ('error' in resp) { return []; } + + const { account_objects, marker: _marker } = resp; + if (_marker && _marker !== marker) { return this.fetchPlannedObjects(account, type, _marker, account_objects.concat(combined)); } @@ -277,7 +303,7 @@ class EventsView extends Component { // account objects we are interested in const objectTypes = ['check', 'escrow', 'offer', 'nft_offer', 'ticket', 'payment_channel']; - let objects = [] as LedgerEntriesTypes[]; + let objects = [] as LedgerEntry[]; objectTypes .reduce(async (accumulator, type) => { @@ -338,6 +364,11 @@ class EventsView extends Component { LedgerService.getTransactions(account.address, loadMore && lastMarker, 50) .then((resp) => { + if ('error' in resp) { + resolve([]); + return; + } + const { transactions: txResp, marker } = resp; let canLoadMore = true; @@ -347,10 +378,15 @@ class EventsView extends Component { canLoadMore = false; } - let parsedList = filter(flatMap(txResp, TransactionFactory.fromLedger), (t) => { - return t?.TransactionResult?.success; + // only success transactions + const tesSuccessTransactions = filter(txResp, (transaction) => { + return ( + typeof transaction.meta === 'object' && transaction?.meta.TransactionResult === 'tesSUCCESS' + ); }); + let parsedList = flatMap(tesSuccessTransactions, (item) => TransactionFactory.fromLedger(item)); + if (loadMore) { parsedList = uniqBy([...transactions, ...parsedList], 'Hash'); } @@ -360,6 +396,7 @@ class EventsView extends Component { }); }) .catch(() => { + // TODO: BETTER ERROR HANDLING AND ONLY SHOW WHEN SCREEN IS VISIBLE Toast(Localize.t('events.canNotFetchTransactions')); resolve([]); }); @@ -385,7 +422,7 @@ class EventsView extends Component { } }; - buildDataSource = (transactions: any, pendingRequests: any, plannedTransactions?: any) => { + buildDataSource = (transactions: any, pendingRequests: any, plannedTransactions?: any): Array => { const { sectionIndex } = this.state; if (isEmpty(pendingRequests) && isEmpty(transactions) && isEmpty(plannedTransactions)) { @@ -395,38 +432,38 @@ class EventsView extends Component { let items = [] as any; if (sectionIndex === 1) { - const open = orderBy( + const openItems = orderBy( filter(plannedTransactions, (p) => [ - LedgerObjectTypes.Offer, - LedgerObjectTypes.NFTokenOffer, - LedgerObjectTypes.Check, - LedgerObjectTypes.Ticket, - LedgerObjectTypes.PayChannel, + LedgerEntryTypes.Offer, + LedgerEntryTypes.NFTokenOffer, + LedgerEntryTypes.Check, + LedgerEntryTypes.Ticket, + LedgerEntryTypes.PayChannel, ].includes(p.Type), ), ['Date'], ); - const planned = orderBy(filter(plannedTransactions, { Type: LedgerObjectTypes.Escrow }), ['Date']); + const plannedItems = orderBy(filter(plannedTransactions, { Type: LedgerEntryTypes.Escrow }), ['Date']); const dataSource = []; - if (!isEmpty(open)) { - dataSource.push({ - title: 'Open', - type: 'string', - data: open, - }); + if (!isEmpty(openItems)) { + dataSource.push({ data: Localize.t('events.eventTypeOpen'), type: DataSourceItemType.SectionHeader }); + map(openItems, (item) => dataSource.push({ data: item, type: DataSourceItemType.RowItem })); } - if (!isEmpty(planned)) { - dataSource.push({ title: Localize.t('events.plannedOn'), type: 'string', data: [] }); - const grouped = groupBy(planned, (item) => { + if (!isEmpty(plannedItems)) { + dataSource.push({ data: Localize.t('events.plannedOn'), type: DataSourceItemType.SectionHeader }); + const grouped = groupBy(plannedItems, (item) => { return moment(item.Date).format('YYYY-MM-DD'); }); map(grouped, (v, k) => { - dataSource.push({ title: k, data: v, type: 'date' }); + dataSource.push({ data: this.formatDate(k), type: DataSourceItemType.SectionHeader }); + map(v, (item) => { + dataSource.push({ data: item, type: DataSourceItemType.RowItem }); + }); }); } @@ -441,14 +478,18 @@ class EventsView extends Component { // group items by month name and then get the name for each month const grouped = groupBy(items, (item) => moment(item.Date).format('YYYY-MM-DD')); - const dataSource = [] as any; + const dataSource: DataSourceItem[] = []; map(grouped, (v, k) => { - dataSource.push({ title: k, data: v, type: 'date' }); + dataSource.push({ data: this.formatDate(k), type: DataSourceItemType.SectionHeader }); + map(v, (item) => { + dataSource.push({ data: item, type: DataSourceItemType.RowItem }); + }); }); + return dataSource; // sort by date - return orderBy(dataSource, ['title'], ['desc']); + // const sorted = orderBy(dataSource, ['title'], ['desc']); }; updateDataSource = async (include?: DataSourceType[]) => { @@ -552,15 +593,15 @@ class EventsView extends Component { TransactionTypes.EscrowCancel, TransactionTypes.EscrowCreate, TransactionTypes.EscrowFinish, - LedgerObjectTypes.Escrow, + LedgerEntryTypes.Escrow, ]; break; case 'Offer': includeTypes = [ TransactionTypes.OfferCancel, TransactionTypes.OfferCreate, - LedgerObjectTypes.Offer, - LedgerObjectTypes.NFTokenOffer, + LedgerEntryTypes.Offer, + LedgerEntryTypes.NFTokenOffer, ]; break; case 'Check': @@ -568,7 +609,7 @@ class EventsView extends Component { TransactionTypes.CheckCancel, TransactionTypes.CheckCreate, TransactionTypes.CheckCash, - LedgerObjectTypes.Check, + LedgerEntryTypes.Check, ]; break; case 'NFT': @@ -578,7 +619,7 @@ class EventsView extends Component { TransactionTypes.NFTokenCreateOffer, TransactionTypes.NFTokenAcceptOffer, TransactionTypes.NFTokenCancelOffer, - LedgerObjectTypes.NFTokenOffer, + LedgerEntryTypes.NFTokenOffer, ]; break; case 'Other': @@ -597,7 +638,7 @@ class EventsView extends Component { TransactionTypes.NFTokenCancelOffer, TransactionTypes.NFTokenCreateOffer, TransactionTypes.NFTokenMint, - LedgerObjectTypes.Ticket, + LedgerEntryTypes.Ticket, ]; break; default: @@ -800,13 +841,13 @@ class EventsView extends Component { imageStyle={AppStyles.BackgroundShapes} style={[AppStyles.contentContainer, AppStyles.padding]} > - - {Localize.t('events.emptyEventsNoAccount')} + + {Localize.t('events.emptyEventsNoAccount')}