Skip to content

Commit

Permalink
rlp zero fix (#53)
Browse files Browse the repository at this point in the history
* trim leading 00s in rlp serializer

* tighten syntax for anon fn call
  • Loading branch information
zeroXbrock authored Jul 3, 2024
1 parent be59d8d commit 328a9e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/chains/suave/serializers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import {
type TransactionSerializedSuave,
} from './types.js'

const safeHex = (hex: Hex): Hex => {
if (hex === '0x0' || hex === '0x00') {
const safeHex = (hex_: Hex): Hex => {
// trim leading 00s
const hex = hex_.replace(/^0x(00)+/, '0x') as Hex
if (hex === '0x0') {
return '0x'
} else if (hex.length % 2 !== 0) {
return `0x0${hex.slice(2)}`
Expand Down
13 changes: 5 additions & 8 deletions src/chains/suave/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,11 @@ function newSuaveWallet<TTransport extends Transport>(params: {

const sig = isEIP712
? await this.signEIP712ConfidentialRequest(ccRecord)
: await (async () => {
const signCcr = getSigningFunction(
client.transport,
params.privateKey,
params.jsonRpcAccount?.address,
)
return await signCcr(ccRecord)
})()
: await getSigningFunction(
client.transport,
params.privateKey,
params.jsonRpcAccount?.address,
)(ccRecord)

const { r, s, v } = formatSignature(sig)
return serializeConfidentialComputeRequest({
Expand Down

0 comments on commit 328a9e1

Please sign in to comment.