gridplus-sdk
Advanced tools
Comparing version 0.8.3 to 0.8.4
{ | ||
"name": "gridplus-sdk", | ||
"version": "0.8.3", | ||
"version": "0.8.4", | ||
"description": "SDK to interact with GridPlus Lattice1 device", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -132,2 +132,4 @@ // Utils for Ethereum transactions. This is effecitvely a shim of ethereumjs-util, which | ||
throw new Error('EIP1559 transactions must include `maxFeePerGas`'); | ||
if (data.maxPriorityFeePerGas > data.maxFeePerGas) | ||
throw new Error('maxPriorityFeePerGas must be <= maxFeePerGas'); | ||
maxPriorityFeePerGasBytes = ensureHexBuffer(data.maxPriorityFeePerGas); | ||
@@ -256,17 +258,18 @@ rawTx.push(maxPriorityFeePerGasBytes); | ||
let prehash = null; | ||
if (dataBytes && dataBytes.length > MAX_BASE_DATA_SZ) { | ||
// Create the buffer, prefix with chainId (if needed) and add data slice | ||
const dataSz = dataBytes.length || 0; | ||
const chainIdExtraSz = chainIdBufSz > 0 ? chainIdBufSz + 1 : 0; | ||
const dataToCopy = Buffer.alloc(dataSz + chainIdExtraSz); | ||
if (chainIdExtraSz > 0) { | ||
dataToCopy.writeUInt8(chainIdBufSz, 0); | ||
chainIdBuf.copy(dataToCopy, 1); | ||
} | ||
dataBytes.copy(dataToCopy, chainIdExtraSz); | ||
if (dataSz > MAX_BASE_DATA_SZ) { | ||
// Determine sizes and run through sanity checks | ||
const chainIdExtraSz = chainIdBufSz > 0 ? chainIdBufSz + 1 : 0; | ||
const totalSz = dataBytes.length + chainIdExtraSz; | ||
const totalSz = dataSz + chainIdExtraSz; | ||
const maxSzAllowed = MAX_BASE_DATA_SZ + (extraDataMaxFrames * extraDataFrameSz); | ||
// Copy the data into a tmp buffer. Account for larger chain ID sizes if applicable. | ||
const dataToCopy = Buffer.alloc(dataBytes.length + chainIdExtraSz) | ||
if (chainIdExtraSz > 0) { | ||
dataToCopy.writeUInt8(chainIdBufSz, 0); | ||
chainIdBuf.copy(dataToCopy, 1); | ||
dataBytes.copy(dataToCopy, chainIdExtraSz); | ||
} else { | ||
dataBytes.copy(dataToCopy, 0); | ||
} | ||
if (prehashAllowed && totalSz > maxSzAllowed) { | ||
@@ -273,0 +276,0 @@ // If this payload is too large to send, but the Lattice allows a prehashed message, do that |
111853
2539