UNPKG

@privy-io/js-sdk-core

Version:

Vanilla JS client for the Privy Auth API

2 lines (1 loc) 683 B
"use strict";var e=require("../../utils/encodings.js");function t(t){if("number"==typeof t||"bigint"==typeof t){return`0x${BigInt(t).toString(16)}`}if("string"==typeof t)return e.isHexEncoded(t)?t:e.bytesToHex(e.utf8ToBytes(t))}exports.toWalletApiUnsignedEthTransaction=function(i){return{from:i.from,to:i.to??void 0,nonce:t(i.nonce),chain_id:t(i.chainId),data:function(t){if(void 0!==t)return"string"==typeof t?e.isHexEncoded(t)?t:e.bytesToHex(e.utf8ToBytes(t)):e.bytesToHex(Buffer.from(Uint8Array.from(t)))}(i.data),value:t(i.value),type:i.type,gas_limit:t(i.gasLimit),gas_price:t(i.gasPrice),max_fee_per_gas:t(i.maxFeePerGas),max_priority_fee_per_gas:t(i.maxPriorityFeePerGas)}};