Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

missing param for hw sign #149

Merged
merged 2 commits into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/account/test/signingKey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ describe('signingKey_type', () => {
signHash: (hashedMessage: Buffer): Observable<SignatureT> => {
return signingKeyLocalHD.signHash(hashedMessage)
},
sign: (_) => {
sign: _ => {
throw new Error('not implemented')
},
}
Expand Down
1 change: 1 addition & 0 deletions packages/application/src/api/json-rpc/_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export namespace BuildTransactionEndpoint {
}
)[]
feePayer: string
disableResourceAllocationAndDestroy?: boolean
message?: string
}

Expand Down
64 changes: 34 additions & 30 deletions packages/application/src/api/json-rpc/responseHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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,
}),
)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -329,24 +333,24 @@ 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,
): Result<SubmitTransactionEndpoint.DecodedResponse, Error[]> =>
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']),
)
1 change: 1 addition & 0 deletions packages/application/src/api/radixCoreAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export const radixCoreAPI = (node: NodeT, api: NodeAPI) => {
},
),
feePayer: from.toString(),
disableResourceAllocationAndDestroy: true,
message: transactionIntent.message
? transactionIntent.message.toString('hex')
: undefined,
Expand Down
1 change: 0 additions & 1 deletion packages/application/src/radix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@ const create = (
transactionIntent,
account,
]): Observable<SignedTransaction> => {

const nonXRDHRPsOfRRIsInTx: string[] = transactionIntent.actions
.filter(a => a.type === ActionType.TOKEN_TRANSFER)
.map(a => a as TransferTokensAction)
Expand Down
8 changes: 5 additions & 3 deletions packages/crypto/src/encryption/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -148,5 +150,5 @@ export const Message = {
fromBuffer,
plaintextToString,
isPlaintext,
isEncrypted
isEncrypted,
}
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,4 @@ describe('hw_ledger_integration', () => {
)
}, 40_000)
})
*/
*/
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ describe('radix_hw_ledger', () => {
)
}, 20_000)
})
*/
*/
12 changes: 7 additions & 5 deletions packages/tx-parser/src/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<InstructionT, Error> => {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/tx-parser/src/reAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<REAddressT, Error> => {
Expand Down
2 changes: 1 addition & 1 deletion packages/tx-parser/src/substate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const parseFromBufferReader = (
): Result<SubstateT, Error> =>
bufferReader
.readNextBuffer(1)
.map(b => b.readUInt8())
.map(b => b.readUInt8(0))
.map(n => n as SubStateType)
.andThen(
(substateType: SubStateType): Result<SubstateT, Error> => {
Expand Down
2 changes: 1 addition & 1 deletion packages/tx-parser/src/substateId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]])

Expand Down
2 changes: 1 addition & 1 deletion packages/tx-parser/src/txSignature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const fromBufferReader = (bufferReader: BufferReaderT): Result<TXSig, Error> =>
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')
Expand Down