1 line
3.9 KiB
JavaScript
1 line
3.9 KiB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[201],{345:function(t,e,n){"use strict";n.r(e);var s=n(46),a=Object(s.a)({},function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[n("h1",{attrs:{id:"functions"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#functions","aria-hidden":"true"}},[t._v("#")]),t._v(" Functions")]),t._v(" "),n("p",[n("a",{attrs:{id:"hextobn"}})]),t._v(" "),n("h2",{attrs:{id:"hextobn"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#hextobn","aria-hidden":"true"}},[t._v("#")]),t._v(" hexToBn")]),t._v(" "),n("p",[t._v("▸ "),n("strong",[t._v("hexToBn")]),t._v("(value?: "),n("em",[n("code",[t._v("string")]),t._v(" | "),n("code",[t._v("number")]),t._v(" | "),n("code",[t._v("null")])]),t._v(", options?: "),n("em",[n("router-link",{attrs:{to:"/util/interfaces/_types_.tobnoptions.html"}},[t._v("ToBnOptions")]),t._v(" | "),n("code",[t._v("boolean")])],1),t._v("): "),n("code",[t._v("BN")])]),t._v(" "),n("p",[n("em",[t._v("Defined in "),n("a",{attrs:{href:"https://github.com/polkadot-js/common/blob/4b1681d/packages/util/src/hex/toBn.ts#L35",target:"_blank",rel:"noopener noreferrer"}},[t._v("hex/toBn.ts:35"),n("OutboundLink")],1)])]),t._v(" "),n("p",[n("em",[n("strong",[t._v("name")])]),t._v(": hexToBn")]),t._v(" "),n("p",[n("em",[n("strong",[t._v("summary")])]),t._v(": Creates a BN.js bignumber object from a hex string.")]),t._v(" "),n("p",[n("em",[n("strong",[t._v("description")])]),t._v(": "),n("code",[t._v("null")]),t._v(" inputs returns a "),n("code",[t._v("BN(0)")]),t._v(" result. Hex input values return the actual value converted to a BN. Anything that is not a hex string (including the "),n("code",[t._v("0x")]),t._v(" prefix) throws an error.")]),t._v(" "),n("p",[n("em",[n("strong",[t._v("example")])]),t._v(":")]),t._v(" "),n("div",{staticClass:"language-javascript line-numbers-mode"},[n("pre",{pre:!0,attrs:{class:"language-javascript"}},[n("code",[n("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" "),n("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v(" hexToBn "),n("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),n("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),n("span",{pre:!0,attrs:{class:"token string"}},[t._v("'@polkadot/util'")]),n("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n"),n("span",{pre:!0,attrs:{class:"token function"}},[t._v("hexToBn")]),n("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),n("span",{pre:!0,attrs:{class:"token string"}},[t._v("'0x123480001f'")]),n("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),n("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v(" "),n("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// => BN(0x123480001f)")]),t._v("\n")])]),t._v(" "),n("div",{staticClass:"line-numbers-wrapper"},[n("span",{staticClass:"line-number"},[t._v("1")]),n("br"),n("span",{staticClass:"line-number"},[t._v("2")]),n("br"),n("span",{staticClass:"line-number"},[t._v("3")]),n("br")])]),n("p",[n("strong",[t._v("Parameters:")])]),t._v(" "),n("table",[n("thead",[n("tr",[n("th",[t._v("Name")]),t._v(" "),n("th",[t._v("Type")]),t._v(" "),n("th",[t._v("Default value")])])]),t._v(" "),n("tbody",[n("tr",[n("td",[n("code",[t._v("Optional")]),t._v(" value")]),t._v(" "),n("td",[n("code",[t._v("string")]),t._v(" | "),n("code",[t._v("number")]),t._v(" | "),n("code",[t._v("null")])]),t._v(" "),n("td",[t._v("-")])]),t._v(" "),n("tr",[n("td",[n("code",[t._v("Default value")]),t._v(" options")]),t._v(" "),n("td",[n("router-link",{attrs:{to:"/util/interfaces/_types_.tobnoptions.html"}},[t._v("ToBnOptions")]),t._v(" | "),n("code",[t._v("boolean")])],1),t._v(" "),n("td",[t._v("{ isLe: false, isNegative: false }")])])])]),t._v(" "),n("p",[n("strong",[t._v("Returns:")]),t._v(" "),n("code",[t._v("BN")])]),t._v(" "),n("hr")])},[],!1,null,null,null);e.default=a.exports}}]); |