From 1eee2262d95f2669783a235e262c3e19d69fe35c Mon Sep 17 00:00:00 2001 From: AbstractFruitFactory Date: Mon, 28 Jun 2021 11:06:02 +0100 Subject: [PATCH 1/2] fix --- packages/account/test/signingKey.test.ts | 2 +- .../application/src/api/json-rpc/_types.ts | 1 + .../src/api/json-rpc/responseHandlers.ts | 64 ++++++++++--------- packages/application/src/api/radixCoreAPI.ts | 1 + packages/application/src/radix.ts | 1 - packages/crypto/src/encryption/message.ts | 8 ++- .../ledgerNano.test.integration.ts | 2 +- .../radix.test.integration.ts | 2 +- packages/tx-parser/src/instruction.ts | 12 ++-- packages/tx-parser/src/reAddress.ts | 2 +- packages/tx-parser/src/substate.ts | 2 +- packages/tx-parser/src/substateId.ts | 2 +- packages/tx-parser/src/txSignature.ts | 2 +- 13 files changed, 55 insertions(+), 46 deletions(-) diff --git a/packages/account/test/signingKey.test.ts b/packages/account/test/signingKey.test.ts index 981db351..4ad85609 100644 --- a/packages/account/test/signingKey.test.ts +++ b/packages/account/test/signingKey.test.ts @@ -209,7 +209,7 @@ describe('signingKey_type', () => { signHash: (hashedMessage: Buffer): Observable => { return signingKeyLocalHD.signHash(hashedMessage) }, - sign: (_) => { + sign: _ => { throw new Error('not implemented') }, } diff --git a/packages/application/src/api/json-rpc/_types.ts b/packages/application/src/api/json-rpc/_types.ts index 694c1731..0e828bc7 100644 --- a/packages/application/src/api/json-rpc/_types.ts +++ b/packages/application/src/api/json-rpc/_types.ts @@ -202,6 +202,7 @@ export namespace BuildTransactionEndpoint { } )[] feePayer: string + disableResourceAllocationAndDestroy: boolean message?: string } diff --git a/packages/application/src/api/json-rpc/responseHandlers.ts b/packages/application/src/api/json-rpc/responseHandlers.ts index 3c09ce2d..3d7cb63e 100644 --- a/packages/application/src/api/json-rpc/responseHandlers.ts +++ b/packages/application/src/api/json-rpc/responseHandlers.ts @@ -144,11 +144,13 @@ export const handleTransactionHistoryResponse = ( ...tx, message: tx.message ? Message.isPlaintext(tx.message) - ? Message.plaintextToString(Buffer.from(tx.message, 'hex')) + ? Message.plaintextToString( + Buffer.from(tx.message, 'hex'), + ) : tx.message - : undefined - })) - }) + : undefined, + })), + }), ) export const handleLookupTXResponse = ( @@ -164,9 +166,11 @@ export const handleLookupTXResponse = ( ...decoded, message: decoded.message ? Message.isPlaintext(decoded.message) - ? Message.plaintextToString(Buffer.from(decoded.message, 'hex')) + ? Message.plaintextToString( + Buffer.from(decoded.message, 'hex'), + ) : decoded.message - : undefined + : undefined, }), ) @@ -277,16 +281,16 @@ export const handleTransactionStatusResponse = ( isRPCRequestFailureResponse(json) ? err([new Error(json.failure)]) : JSONDecoding.withDecoders(transactionIdentifierDecoder('txID')) - .create< - TransactionStatusEndpoint.Response, - TransactionStatusEndpoint.DecodedResponse - >()(json) - .andThen(decoded => - hasRequiredProps('transactionStatus', decoded, [ - 'txID', - 'status', - ]), - ) + .create< + TransactionStatusEndpoint.Response, + TransactionStatusEndpoint.DecodedResponse + >()(json) + .andThen(decoded => + hasRequiredProps('transactionStatus', decoded, [ + 'txID', + 'status', + ]), + ) export const handleNetworkTxThroughputResponse = ( json: NetworkTransactionThroughputEndpoint.Response, @@ -329,13 +333,13 @@ export const handleFinalizeTransactionResponse = ( isRPCRequestFailureResponse(json) ? err([new Error(json.failure)]) : JSONDecoding.withDecoders(transactionIdentifierDecoder('txID')) - .create< - FinalizeTransactionEndpoint.Response, - FinalizeTransactionEndpoint.DecodedResponse - >()(json) - .andThen(decoded => - hasRequiredProps('finalizeTransaction', decoded, ['txID']), - ) + .create< + FinalizeTransactionEndpoint.Response, + FinalizeTransactionEndpoint.DecodedResponse + >()(json) + .andThen(decoded => + hasRequiredProps('finalizeTransaction', decoded, ['txID']), + ) export const handleSubmitTransactionResponse = ( json: SubmitTransactionEndpoint.Response, @@ -343,10 +347,10 @@ export const handleSubmitTransactionResponse = ( isRPCRequestFailureResponse(json) ? err([new Error(json.failure)]) : JSONDecoding.withDecoders(transactionIdentifierDecoder('txID')) - .create< - SubmitTransactionEndpoint.Response, - SubmitTransactionEndpoint.DecodedResponse - >()(json) - .andThen(decoded => - hasRequiredProps('submitTransaction', decoded, ['txID']), - ) + .create< + SubmitTransactionEndpoint.Response, + SubmitTransactionEndpoint.DecodedResponse + >()(json) + .andThen(decoded => + hasRequiredProps('submitTransaction', decoded, ['txID']), + ) diff --git a/packages/application/src/api/radixCoreAPI.ts b/packages/application/src/api/radixCoreAPI.ts index c4ea955d..eb242caf 100644 --- a/packages/application/src/api/radixCoreAPI.ts +++ b/packages/application/src/api/radixCoreAPI.ts @@ -148,6 +148,7 @@ export const radixCoreAPI = (node: NodeT, api: NodeAPI) => { }, ), feePayer: from.toString(), + disableResourceAllocationAndDestroy: true, message: transactionIntent.message ? transactionIntent.message.toString('hex') : undefined, diff --git a/packages/application/src/radix.ts b/packages/application/src/radix.ts index a961f2da..6e0cdc0c 100644 --- a/packages/application/src/radix.ts +++ b/packages/application/src/radix.ts @@ -464,7 +464,6 @@ const create = ( transactionIntent, account, ]): Observable => { - const nonXRDHRPsOfRRIsInTx: string[] = transactionIntent.actions .filter(a => a.type === ActionType.TOKEN_TRANSFER) .map(a => a as TransferTokensAction) diff --git a/packages/crypto/src/encryption/message.ts b/packages/crypto/src/encryption/message.ts index 2c413d2a..e3ab4b54 100644 --- a/packages/crypto/src/encryption/message.ts +++ b/packages/crypto/src/encryption/message.ts @@ -26,9 +26,11 @@ const minLengthEncryptedMessage = const maxLengthOfCipherTextOfSealedMsg = maxLengthEncryptedMessage - minLengthEncryptedMessage -const isPlaintext = (rawHex: string) => parseInt(rawHex.slice(0, 2)) === MessageType.PLAINTEXT +const isPlaintext = (rawHex: string) => + parseInt(rawHex.slice(0, 2)) === MessageType.PLAINTEXT -const isEncrypted = (rawHex: string) => parseInt(rawHex.slice(0, 2)) === MessageType.ENCRYPTED +const isEncrypted = (rawHex: string) => + parseInt(rawHex.slice(0, 2)) === MessageType.ENCRYPTED const __validateEncryptedMessageMaxLength: ( buffer: Buffer, @@ -148,5 +150,5 @@ export const Message = { fromBuffer, plaintextToString, isPlaintext, - isEncrypted + isEncrypted, } diff --git a/packages/hardware-ledger/test/physical-devices/ledgerNano.test.integration.ts b/packages/hardware-ledger/test/physical-devices/ledgerNano.test.integration.ts index 9d6a2261..336c495c 100644 --- a/packages/hardware-ledger/test/physical-devices/ledgerNano.test.integration.ts +++ b/packages/hardware-ledger/test/physical-devices/ledgerNano.test.integration.ts @@ -320,4 +320,4 @@ describe('hw_ledger_integration', () => { ) }, 40_000) }) -*/ \ No newline at end of file +*/ diff --git a/packages/hardware-ledger/test/physical-devices/radix.test.integration.ts b/packages/hardware-ledger/test/physical-devices/radix.test.integration.ts index dd2f052e..cac020d7 100644 --- a/packages/hardware-ledger/test/physical-devices/radix.test.integration.ts +++ b/packages/hardware-ledger/test/physical-devices/radix.test.integration.ts @@ -111,4 +111,4 @@ describe('radix_hw_ledger', () => { ) }, 20_000) }) -*/ \ No newline at end of file +*/ diff --git a/packages/tx-parser/src/instruction.ts b/packages/tx-parser/src/instruction.ts index a8bf74f7..e4e75df2 100644 --- a/packages/tx-parser/src/instruction.ts +++ b/packages/tx-parser/src/instruction.ts @@ -32,7 +32,7 @@ const parseFromBufferReader = ( .readNextBuffer(1) .map(b => ({ insBuf: b, - instructionType: b.readUInt8() as InstructionType, + instructionType: b.readUInt8(0) as InstructionType, })) .andThen( (ii): Result => { @@ -124,7 +124,9 @@ const parseFromBufferReader = ( case InstructionType.LDOWN: return bufferReader.readNextBuffer(4).map( (substateIndexBytes): Ins_LDOWN => { - const substateIndex = substateIndexBytes.readUInt32BE() + const substateIndex = substateIndexBytes.readUInt32BE( + 0, + ) return { substateIndex, instructionType, @@ -167,7 +169,7 @@ const parseFromBufferReader = ( case InstructionType.DOWNALL: return bufferReader .readNextBuffer(1) - .map(b => b.readUInt8() as Byte) + .map(b => b.readUInt8(0) as Byte) .map( (classId: Byte): Ins_DOWNALL => ({ instructionType, @@ -205,8 +207,8 @@ const parseFromBufferReader = ( .map(resList => { const versionBuf = resList[0] const flagBuf = resList[1] - const version = versionBuf.readUInt8() as Byte - const flag = flagBuf.readUInt8() as Byte + const version = versionBuf.readUInt8(0) as Byte + const flag = flagBuf.readUInt8(0) as Byte const buffer = Buffer.concat([ versionBuf, flagBuf, diff --git a/packages/tx-parser/src/reAddress.ts b/packages/tx-parser/src/reAddress.ts index d173a520..6f8988e3 100644 --- a/packages/tx-parser/src/reAddress.ts +++ b/packages/tx-parser/src/reAddress.ts @@ -18,7 +18,7 @@ const fromBufferReader = ( .readNextBuffer(1) .map(b => ({ reAddressTypeBuf: b, - reAddressType: b.readUInt8() as REAddressType, + reAddressType: b.readUInt8(0) as REAddressType, })) .andThen( (aa): Result => { diff --git a/packages/tx-parser/src/substate.ts b/packages/tx-parser/src/substate.ts index 41b38fb7..a76770bb 100644 --- a/packages/tx-parser/src/substate.ts +++ b/packages/tx-parser/src/substate.ts @@ -11,7 +11,7 @@ const parseFromBufferReader = ( ): Result => bufferReader .readNextBuffer(1) - .map(b => b.readUInt8()) + .map(b => b.readUInt8(0)) .map(n => n as SubStateType) .andThen( (substateType: SubStateType): Result => { diff --git a/packages/tx-parser/src/substateId.ts b/packages/tx-parser/src/substateId.ts index db113322..2223d0cb 100644 --- a/packages/tx-parser/src/substateId.ts +++ b/packages/tx-parser/src/substateId.ts @@ -11,7 +11,7 @@ const parseFromBufferReader = ( bufferReader.readNextBuffer(4), ]).map(resList => { const hash = resList[0] - const index = resList[1].readUInt32BE() + const index = resList[1].readUInt32BE(0) const buffer = Buffer.concat([resList[0], resList[1]]) diff --git a/packages/tx-parser/src/txSignature.ts b/packages/tx-parser/src/txSignature.ts index a671d530..4d261b23 100644 --- a/packages/tx-parser/src/txSignature.ts +++ b/packages/tx-parser/src/txSignature.ts @@ -11,7 +11,7 @@ const fromBufferReader = (bufferReader: BufferReaderT): Result => bufferReader.readNextBuffer(32), ]) .map(resList => { - const v = resList[0].readUInt8() as Byte + const v = resList[0].readUInt8(0) as Byte const uint256FromBuffer = (b: unknown): UInt256 => { const hex = (b as Buffer).toString('hex') From 1e55da075909d18949abff53d832cee3148e3881 Mon Sep 17 00:00:00 2001 From: AbstractFruitFactory Date: Mon, 28 Jun 2021 11:07:16 +0100 Subject: [PATCH 2/2] optional --- packages/application/src/api/json-rpc/_types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/application/src/api/json-rpc/_types.ts b/packages/application/src/api/json-rpc/_types.ts index 0e828bc7..35e9338c 100644 --- a/packages/application/src/api/json-rpc/_types.ts +++ b/packages/application/src/api/json-rpc/_types.ts @@ -202,7 +202,7 @@ export namespace BuildTransactionEndpoint { } )[] feePayer: string - disableResourceAllocationAndDestroy: boolean + disableResourceAllocationAndDestroy?: boolean message?: string }