repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
js-wallet-sdk
github_2023
okx
typescript
AccessListEIP2930Transaction.raw
raw(): AccessListEIP2930ValuesArray { return [ bnToUnpaddedBuffer(this.chainId), bnToUnpaddedBuffer(this.nonce), bnToUnpaddedBuffer(this.gasPrice), bnToUnpaddedBuffer(this.gasLimit), this.to !== undefined ? this.to.buf : Buffer.from([]), bnToUnpaddedBuffer(this.value), this...
/** * Returns a Buffer Array of the raw Buffers of the EIP-2930 transaction, in order. * * Format: `[chainId, nonce, gasPrice, gasLimit, to, value, data, accessList, * signatureYParity (v), signatureR (r), signatureS (s)]` * * * For an unsigned tx this method uses the empty Buffer values for the ...
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/eip2930Transaction.ts#L171-L185
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
AccessListEIP2930Transaction.serialize
serialize(): Buffer { const base = this.raw() return Buffer.concat([TRANSACTION_TYPE_BUFFER, rlp.encode(base as any)]) }
/** * Returns the serialized encoding of the EIP-2930 transaction. * * Format: `0x01 || rlp([chainId, nonce, gasPrice, gasLimit, to, value, data, accessList, * signatureYParity (v), signatureR (r), signatureS (s)])` * * Note that in contrast to the legacy tx serialization format this is not * valid...
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/eip2930Transaction.ts#L197-L200
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
AccessListEIP2930Transaction.getMessageToSign
getMessageToSign(hashMessage = true): Buffer { const base = this.raw().slice(0, 8) const message = Buffer.concat([TRANSACTION_TYPE_BUFFER, rlp.encode(base as any)]) if (hashMessage) { return keccak256(message) } else { return message } }
/** * Returns the serialized unsigned tx (hashed or raw), which can be used * to sign the transaction (e.g. for sending to a hardware wallet). * * Note: in contrast to the legacy tx the raw message format is already * serialized and doesn't need to be RLP encoded any more. * * ```javascript * co...
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/eip2930Transaction.ts#L215-L223
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
AccessListEIP2930Transaction.hash
public hash(): Buffer { if (!this.isSigned()) { const msg = this._errorMsg('Cannot call hash method if transaction is not signed') throw new Error(msg) } return keccak256(this.serialize()) }
/** * Computes a sha3-256 hash of the serialized tx. * * This method can only be used for signed txs (it throws otherwise). * Use {@link AccessListEIP2930Transaction.getMessageToSign} to get a tx hash for the purpose of signing. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/eip2930Transaction.ts#L231-L237
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
AccessListEIP2930Transaction.toJSON
toJSON(): JsonTx { const accessListJSON = AccessLists.getAccessListJSON(this.accessList) return { chainId: bnToHex(this.chainId), nonce: bnToHex(this.nonce), gasPrice: bnToHex(this.gasPrice), gasLimit: bnToHex(this.gasLimit), to: this.to !== undefined ? this.to.toString() : undefi...
/** * Returns an object with the JSON representation of the transaction */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/eip2930Transaction.ts#L277-L293
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
AccessListEIP2930Transaction.errorStr
public errorStr() { let errorStr = this._getSharedErrorPostfix() // Keep ? for this.accessList since this otherwise causes Hardhat E2E tests to fail errorStr += ` gasPrice=${this.gasPrice} accessListCount=${this.accessList?.length ?? 0}` return errorStr }
/** * Return a compact error string representation of the object */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/eip2930Transaction.ts#L298-L303
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
AccessListEIP2930Transaction._errorMsg
protected _errorMsg(msg: string) { return `${msg} (${this.errorStr()})` }
/** * Internal helper function to create an annotated error message * * @param msg Base error message * @hidden */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/eip2930Transaction.ts#L311-L313
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Transaction.fromTxData
public static fromTxData(txData: TxData) { return new Transaction(txData) }
/** * Instantiate a transaction from a data dictionary. * * Format: { nonce, gasPrice, gasLimit, to, value, data, v, r, s } * * Notes: * - All parameters are optional and have some basic default values */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/legacyTransaction.ts#L41-L43
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Transaction.fromSerializedTx
public static fromSerializedTx(serialized: Buffer, chainId?: number) { const values = rlp.decode(serialized) if (!Array.isArray(values)) { throw new Error('Invalid serialized tx input. Must be array') } return this.fromValuesArray(values, chainId) }
/** * Instantiate a transaction from the serialized tx. * * Format: `rlp([nonce, gasPrice, gasLimit, to, value, data, v, r, s])` */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/legacyTransaction.ts#L50-L58
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Transaction.fromValuesArray
public static fromValuesArray(values: TxValuesArray, chainId?: number) { // If length is not 6, it has length 9. If v/r/s are empty Buffers, it is still an unsigned transaction // This happens if you get the RLP data from `raw()` if (values.length !== 6 && values.length !== 9) { throw new Error( ...
/** * Create a transaction from a values array. * * Format: `[nonce, gasPrice, gasLimit, to, value, data, v, r, s]` */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/legacyTransaction.ts#L65-L92
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Transaction.constructor
public constructor(txData: TxData) { super({ ...txData, type: TRANSACTION_TYPE }) this.gasPrice = new BN(toBuffer(txData.gasPrice === '' ? '0x' : txData.gasPrice)) this.chainId = new BN(toBuffer(txData.chainId === '' ? '0x' : txData.chainId)) if (this.gasPrice.mul(this.gasLimit).gt(MAX_INTEGER)) { ...
/** * This constructor takes the values, validates them, assigns them and freezes the object. * * It is not recommended to use this constructor directly. Instead use * the static factory methods to assist in creating a Transaction object from * varying data types. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/legacyTransaction.ts#L101-L112
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Transaction.raw
raw(): TxValuesArray { return [ bnToUnpaddedBuffer(this.nonce), bnToUnpaddedBuffer(this.gasPrice), bnToUnpaddedBuffer(this.gasLimit), this.to !== undefined ? this.to.buf : Buffer.from([]), bnToUnpaddedBuffer(this.value), this.data, this.v !== undefined ? bnToUnpaddedBuffer(...
/** * Returns a Buffer Array of the raw Buffers of the legacy transaction, in order. * * Format: `[nonce, gasPrice, gasLimit, to, value, data, v, r, s]` * * For legacy txs this is also the correct format to add transactions * to a block with {@link Block.fromValuesArray} (use the `serialize()` method ...
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/legacyTransaction.ts#L127-L139
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Transaction.serialize
serialize(): Buffer { return rlp.encode(this.raw()) }
/** * Returns the serialized encoding of the legacy transaction. * * Format: `rlp([nonce, gasPrice, gasLimit, to, value, data, v, r, s])` * * For an unsigned tx this method uses the empty Buffer values for the * signature parameters `v`, `r` and `s` for encoding. For an EIP-155 compliant * represen...
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/legacyTransaction.ts#L150-L152
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Transaction.hash
hash(): Buffer { // In contrast to the tx type transaction implementations the `hash()` function // for the legacy tx does not throw if the tx is not signed. // This has been considered for inclusion but lead to unexpected backwards // compatibility problems (no concrete reference found, needs validatio...
/** * Computes a sha3-256 hash of the serialized tx. * * This method can only be used for signed txs (it throws otherwise). * Use {@link Transaction.getMessageToSign} to get a tx hash for the purpose of signing. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/legacyTransaction.ts#L202-L218
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Transaction._processSignature
protected _processSignature(v: number, r: Buffer, s: Buffer) { const vBN = new BN(2 * this.chainId.toNumber() + v + 8) return Transaction.fromTxData( { nonce: this.nonce, gasPrice: this.gasPrice, gasLimit: this.gasLimit, to: this.to, value: this.value, data:...
/** * Process the v, r, s values from the `sign` method of the base transaction. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/legacyTransaction.ts#L223-L239
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Transaction.toJSON
toJSON(): JsonTx { return { nonce: bnToHex(this.nonce), gasPrice: bnToHex(this.gasPrice), gasLimit: bnToHex(this.gasLimit), to: this.to !== undefined ? this.to.toString() : undefined, value: bnToHex(this.value), data: '0x' + this.data.toString('hex'), v: this.v !== undefine...
/** * Returns an object with the JSON representation of the transaction. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/legacyTransaction.ts#L261-L273
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Transaction.errorStr
public errorStr() { let errorStr = this._getSharedErrorPostfix() errorStr += ` gasPrice=${this.gasPrice}` return errorStr }
/** * Return a compact error string representation of the object */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/legacyTransaction.ts#L278-L282
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Transaction._errorMsg
protected _errorMsg(msg: string) { return `${msg} (${this.errorStr()})` }
/** * Internal helper function to create an annotated error message * * @param msg Base error message * @hidden */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/legacyTransaction.ts#L290-L292
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
TransactionFactory.fromTxData
public static fromTxData(txData: TxData | AccessListEIP2930TxData | FeeMarketEIP1559TxData): TypedTransaction { if (!('type' in txData) || txData.type === undefined) { // Assume legacy transaction return Transaction.fromTxData(<TxData>txData) } else { const txType = new BN(toBuffer(txData.type...
/** * Create a transaction from a `txData` object * * @param txData - The transaction data. The `type` field will determine which transaction type is returned (if undefined, creates a legacy transaction) * @param txOptions - Options to pass on to the constructor of the transaction */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/transactionFactory.ts#L26-L42
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
TransactionFactory.fromSerializedData
public static fromSerializedData(data: Buffer, chainId?: number): TypedTransaction { if (data[0] <= 0x7f) { // Determine the type. let EIP: number switch (data[0]) { case 1: EIP = 2930 break case 2: EIP = 1559 break default: ...
/** * This method tries to decode serialized data. * * @param data - The data Buffer * @param chainId */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-tx/transactionFactory.ts#L50-L73
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Address.zero
static zero(): Address { return new Address(zeros(20)) }
/** * Returns the zero address. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-util/address.ts#L28-L30
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Address.fromString
static fromString(str: string): Address { assert(isValidAddress(str), 'Invalid address') return new Address(toBuffer(str)) }
/** * Returns an Address object from a hex-encoded string. * @param str - Hex-encoded address */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-util/address.ts#L36-L39
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Address.fromPublicKey
static fromPublicKey(pubKey: Buffer): Address { assert(Buffer.isBuffer(pubKey), 'Public key should be Buffer') const buf = pubToAddress(pubKey) return new Address(buf) }
/** * Returns an address for a given public key. * @param pubKey The two points of an uncompressed key */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-util/address.ts#L45-L49
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Address.fromPrivateKey
static fromPrivateKey(privateKey: Buffer): Address { assert(Buffer.isBuffer(privateKey), 'Private key should be Buffer') const buf = privateToAddress(privateKey) return new Address(buf) }
/** * Returns an address for a given private key. * @param privateKey A private key must be 256 bits wide */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-util/address.ts#L55-L59
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Address.equals
equals(address: Address): boolean { return this.buf.equals(address.buf) }
/** * Is address equal to another. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-util/address.ts#L64-L66
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Address.isZero
isZero(): boolean { return this.equals(Address.zero()) }
/** * Is address zero. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-util/address.ts#L71-L73
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Address.toString
toString(): string { return '0x' + this.buf.toString('hex') }
/** * Returns hex encoding of address. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-util/address.ts#L78-L80
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Address.toBuffer
toBuffer(): Buffer { return Buffer.from(this.buf) }
/** * Returns Buffer representation of address. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-util/address.ts#L85-L87
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
safeParseInt
function safeParseInt(v: string, base: number): number { if (v[0] === '0' && v[1] === '0') { throw new Error('invalid RLP: extra zeros') } return parseInt(v, base) }
/** * Parse integers. Check if there is no leading zeros * @param v The value to parse * @param base The base to parse the integer into */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-util/rlp.ts#L48-L54
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
_decode
function _decode(input: Buffer): Decoded { let length, llength, data, innerRemainder, d const decoded = [] const firstByte = input[0] if (firstByte <= 0x7f) { // a single byte whose value is in the [0x00, 0x7f] range, that byte is its own RLP encoding. return { data: input.s...
/** Decode an input with RLP */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-util/rlp.ts#L125-L214
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
intToHex
function intToHex(integer: number | bigint): string { if (integer < 0) { throw new Error('Invalid integer as argument, must be unsigned!') } const hex = integer.toString(16) return hex.length % 2 ? `0${hex}` : hex }
/** Transform an integer into its hexadecimal value */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-util/rlp.ts#L230-L236
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
padToEven
function padToEven(a: string): string { return a.length % 2 ? `0${a}` : a }
/** Pad a string to be even */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-util/rlp.ts#L239-L241
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
intToBuffer
function intToBuffer(integer: number | bigint): Buffer { const hex = intToHex(integer) return Buffer.from(hex, 'hex') }
/** Transform an integer into a Buffer */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-util/rlp.ts#L244-L247
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
toBuffer
function toBuffer(v: Input): Buffer { if (!Buffer.isBuffer(v)) { if (typeof v === 'string') { if (isHexPrefixed(v)) { return Buffer.from(padToEven(stripHexPrefix(v)), 'hex') } else { return Buffer.from(v) } } else if (typeof v === '...
/** Transform anything into a Buffer */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ethereum/src/sdk/ethereumjs-util/rlp.ts#L250-L276
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
KaspaWallet.signTransaction
async signTransaction(param: SignTxParams): Promise<any> { try { return Promise.resolve(transfer(param.data, param.privateKey)); } catch (e) { return Promise.reject(SignTxError); } }
// }
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-kaspa/src/KaspaWallet.ts#L50-L56
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
signTransactionObject
async function signTransactionObject(transaction: Transaction, privateKeyHex: string): Promise<[Uint8Array, SignedTransaction]> { const message = serialize(SCHEMA, transaction) const hash = base.sha256(message) const privateKey = base.fromHex(privateKeyHex) const s = signUtil.ed25519.sign(hash, privateKey) co...
/** * Signs a given transaction from an account with given keys, applied to the given network * @param transaction The Transaction object to sign * @param privateKeyHex */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-near/src/transaction.ts#L254-L264
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
CryptTextParams.constructor
public constructor( public readonly type: nipOpType, public readonly pubkey: string, public readonly text: string, ) { }
/** * Constructs a CryptTextParams instance. * @param type * @param pubkey * @param text */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-nostrassets/src/NostrAssetsWallet.ts#L35-L40
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
checkAddressChecksum
function checkAddressChecksum (decoded: Uint8Array): [boolean, number, number, number] { const ss58Length = (decoded[0] & 0b0100_0000) ? 2 : 1; const ss58Decoded = ss58Length === 1 ? decoded[0] : ((decoded[0] & 0b0011_1111) << 2) | (decoded[1] >> 6) | ((decoded[1] & 0b0011_1111) << 8); // 3...
// validate address
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-polkadot/src/address.ts#L23-L42
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
hexToBn
function hexToBn (value?: string | null, options: ToBnOptions | boolean = {}): BN { if (!value || value === '0x') { return new BN(0); } // For hex, default to BE const { isLe, isNegative } = objectSpread<ToBnOptions>( { isLe: false, isNegative: false }, isBoolean(options) ...
/** @deprecated Use hexToBn (value?: string | null, options?: ToBnOptions) */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-polkadot/src/bn.ts#L62-L82
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
UnSignedTxToString
function UnSignedTxToString(unSignedTx: UnSignedTx): string { const bufferList = [] bufferList.push(unSignedTx.Method) bufferList.push(unSignedTx.Era) bufferList.push(unSignedTx.Nonce) bufferList.push(unSignedTx.Tip) bufferList.push(unSignedTx.SpecVersion) bufferList.push(unSignedTx.TxVersio...
// serialize unsigned structure
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-polkadot/src/tx.ts#L117-L128
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
GreedyCount.isCount
isCount(): boolean { return true; }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L482-L484
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
GreedyCount.decode
decode(b: Uint8Array, offset = 0): number { checkUint8Array(b); const rem = b.length - offset; return Math.floor(rem / this.elementSpan); }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L487-L491
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
GreedyCount.encode
encode(src: number, b: Uint8Array, offset?: number): number { return 0; }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L494-L496
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
OffsetLayout.isCount
isCount(): boolean { return ((this.layout instanceof UInt) || (this.layout instanceof UIntBE)); }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L546-L549
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
OffsetLayout.decode
decode(b: Uint8Array, offset = 0): number { return this.layout.decode(b, offset + this.offset); }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L552-L554
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
OffsetLayout.encode
encode(src: number, b: Uint8Array, offset = 0): number { return this.layout.encode(src, b, offset + this.offset); }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L557-L559
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
UInt.decode
decode(b: Uint8Array, offset = 0): number { return uint8ArrayToBuffer(b).readUIntLE(offset, this.span); }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L587-L589
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
UInt.encode
encode(src: number, b: Uint8Array, offset = 0): number { uint8ArrayToBuffer(b).writeUIntLE(src, offset, this.span); return this.span; }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L592-L595
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
UIntBE.decode
decode(b: Uint8Array, offset = 0): number { return uint8ArrayToBuffer(b).readUIntBE(offset, this.span); }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L623-L625
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
UIntBE.encode
encode(src: number, b: Uint8Array, offset = 0): number { uint8ArrayToBuffer(b).writeUIntBE(src, offset, this.span); return this.span; }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L628-L631
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Int.decode
decode(b: Uint8Array, offset = 0): number { return uint8ArrayToBuffer(b).readIntLE(offset, this.span); }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L659-L661
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Int.encode
encode(src: number, b: Uint8Array, offset = 0): number { uint8ArrayToBuffer(b).writeIntLE(src, offset, this.span); return this.span; }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L664-L667
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
IntBE.decode
decode(b: Uint8Array, offset = 0): number { return uint8ArrayToBuffer(b).readIntBE(offset, this.span); }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L695-L697
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
IntBE.encode
encode(src: number, b: Uint8Array, offset = 0): number { uint8ArrayToBuffer(b).writeIntBE(src, offset, this.span); return this.span; }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L700-L703
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
divmodInt64
function divmodInt64(src: number): { hi32: number; lo32: number; } { const hi32 = Math.floor(src / V2E32); const lo32 = src - (hi32 * V2E32); return {hi32, lo32}; }
/* True modulus high and low 32-bit words, where low word is always * non-negative. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L710-L714
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
roundedInt64
function roundedInt64(hi32: number, lo32: number): number { return hi32 * V2E32 + lo32; }
/* Reconstruct Number from quotient and non-negative remainder */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L716-L718
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
NearUInt64.decode
decode(b: Uint8Array, offset = 0): number { const buffer = uint8ArrayToBuffer(b); const lo32 = buffer.readUInt32LE(offset); const hi32 = buffer.readUInt32LE(offset + 4); return roundedInt64(hi32, lo32); }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L737-L742
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
NearUInt64.encode
encode(src: number, b: Uint8Array, offset = 0): number { const split = divmodInt64(src); const buffer = uint8ArrayToBuffer(b); buffer.writeUInt32LE(split.lo32, offset); buffer.writeUInt32LE(split.hi32, offset + 4); return 8; }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L745-L751
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
NearUInt64BE.decode
decode(b: Uint8Array, offset = 0): number { const buffer = uint8ArrayToBuffer(b); const hi32 = buffer.readUInt32BE(offset); const lo32 = buffer.readUInt32BE(offset + 4); return roundedInt64(hi32, lo32); }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L771-L776
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
NearUInt64BE.encode
encode(src: number, b: Uint8Array, offset = 0): number { const split = divmodInt64(src); const buffer = uint8ArrayToBuffer(b); buffer.writeUInt32BE(split.hi32, offset); buffer.writeUInt32BE(split.lo32, offset + 4); return 8; }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L779-L785
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
NearInt64.decode
decode(b: Uint8Array, offset = 0): number { const buffer = uint8ArrayToBuffer(b); const lo32 = buffer.readUInt32LE(offset); const hi32 = buffer.readInt32LE(offset + 4); return roundedInt64(hi32, lo32); }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L805-L810
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
NearInt64.encode
encode(src: number, b: Uint8Array, offset = 0): number { const split = divmodInt64(src); const buffer = uint8ArrayToBuffer(b); buffer.writeUInt32LE(split.lo32, offset); buffer.writeInt32LE(split.hi32, offset + 4); return 8; }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L813-L819
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
NearInt64BE.decode
decode(b: Uint8Array, offset = 0): number { const buffer = uint8ArrayToBuffer(b); const hi32 = buffer.readInt32BE(offset); const lo32 = buffer.readUInt32BE(offset + 4); return roundedInt64(hi32, lo32); }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L839-L844
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
NearInt64BE.encode
encode(src: number, b: Uint8Array, offset = 0): number { const split = divmodInt64(src); const buffer = uint8ArrayToBuffer(b); buffer.writeInt32BE(split.hi32, offset); buffer.writeUInt32BE(split.lo32, offset + 4); return 8; }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L847-L853
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Float.decode
decode(b: Uint8Array, offset = 0): number { return uint8ArrayToBuffer(b).readFloatLE(offset); }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L872-L874
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Float.encode
encode(src: number, b: Uint8Array, offset = 0): number { uint8ArrayToBuffer(b).writeFloatLE(src, offset); return 4; }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L877-L880
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
FloatBE.decode
decode(b: Uint8Array, offset = 0): number { return uint8ArrayToBuffer(b).readFloatBE(offset); }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L899-L901
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
FloatBE.encode
encode(src: number, b: Uint8Array, offset = 0): number { uint8ArrayToBuffer(b).writeFloatBE(src, offset); return 4; }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L904-L907
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Double.decode
decode(b: Uint8Array, offset = 0): number { return uint8ArrayToBuffer(b).readDoubleLE(offset); }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L926-L928
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Double.encode
encode(src: number, b: Uint8Array, offset = 0): number { uint8ArrayToBuffer(b).writeDoubleLE(src, offset); return 8; }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L931-L934
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
DoubleBE.decode
decode(b: Uint8Array, offset = 0): number { return uint8ArrayToBuffer(b).readDoubleBE(offset); }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L953-L955
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
DoubleBE.encode
encode(src: number, b: Uint8Array, offset = 0): number { uint8ArrayToBuffer(b).writeDoubleBE(src, offset); return 8; }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L958-L961
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Sequence.getSpan
getSpan(b: Uint8Array, offset = 0): number { if (0 <= this.span) { return this.span; } let span = 0; let count = this.count; if (count instanceof ExternalLayout) { count = count.decode(b, offset); } if (0 < this.elementLayout.span) { ...
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1014-L1033
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Sequence.decode
decode(b: Uint8Array, offset = 0): T[] { const rv: T[] = []; let i = 0; let count = this.count; if (count instanceof ExternalLayout) { count = count.decode(b, offset); } while (i < count) { rv.push(this.elementLayout.decode(b, offset)); ...
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1036-L1049
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Sequence.encode
encode(src: T[], b: Uint8Array, offset = 0): number { const elo = this.elementLayout; const span: number = src.reduce((span, v) => { return span + elo.encode(v, b, offset + span); }, 0); if (this.count instanceof ExternalLayout) { this.count.encode(src.length, b, ...
/** Implement {@link Layout#encode|encode} for {@link Sequence}. * * **NOTE** If `src` is shorter than {@link Sequence#count|count} then * the unused space in the buffer is left unchanged. If `src` is * longer than {@link Sequence#count|count} the unneeded elements are * ignored. * *...
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1061-L1070
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Structure.getSpan
getSpan(b: Uint8Array, offset = 0): number { if (0 <= this.span) { return this.span; } let span = 0; try { span = this.fields.reduce((span, fd) => { const fsp = fd.getSpan(b, offset); offset += fsp; return span + fsp...
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1161-L1176
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Structure.decode
decode(b: Uint8Array, offset = 0): T { checkUint8Array(b); const dest = this.makeDestinationObject() as T; for (const fd of this.fields) { if (undefined !== fd.property) { dest[fd.property as keyof T] = fd.decode(b, offset); } offset += fd.getS...
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1179-L1193
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Structure.encode
encode(src: T, b: Uint8Array, offset = 0): number { const firstOffset = offset; let lastOffset = 0; let lastWrote = 0; for (const fd of this.fields) { let span = fd.span; lastWrote = (0 < span) ? span : 0; if (undefined !== fd.property) { ...
/** Implement {@link Layout#encode|encode} for {@link Structure}. * * If `src` is missing a property for a member with a defined {@link * Layout#property|property} the corresponding region of the buffer is * left unmodified. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1200-L1226
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Structure.fromArray
fromArray(values: any[]): LayoutObject { const dest = this.makeDestinationObject(); for (const fd of this.fields) { if ((undefined !== fd.property) && (0 < values.length)) { dest[fd.property] = values.shift(); } } return dest; }
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1229-L1238
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Structure.offsetOf
offsetOf(property: string): number | undefined { if ('string' !== typeof property) { throw new TypeError('property must be string'); } let offset = 0; for (const fd of this.fields) { if (fd.property === property) { return offset; } ...
/** * Get the offset of a structure member. * * @param {String} property - the structure member of interest. * * @return {Number} - the offset in bytes to the start of `property` * within the structure, or undefined if `property` is not a field * within the structure. If the property...
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1271-L1287
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
UnionDiscriminator.decode
decode(b?: Uint8Array, offset?: number): T { throw new Error('UnionDiscriminator is abstract'); }
/** Analog to {@link Layout#decode|Layout decode} for union discriminators. * * The implementation of this method need not reference the buffer if * variant information is available through other means. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1318-L1320
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
UnionDiscriminator.encode
encode(src: T, b: Uint8Array, offset?: number): number { throw new Error('UnionDiscriminator is abstract'); }
/** Analog to {@link Layout#decode|Layout encode} for union discriminators. * * The implementation of this method need not store the value if * variant information is maintained through other means. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1326-L1328
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
UnionLayoutDiscriminator.decode
decode(b: Uint8Array, offset?: number): number { return this.layout.decode(b, offset); }
/** Delegate decoding to {@link UnionLayoutDiscriminator#layout|layout}. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1364-L1366
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
UnionLayoutDiscriminator.encode
encode(src: number, b: Uint8Array, offset?: number): number { return this.layout.encode(src, b, offset); }
/** Delegate encoding to {@link UnionLayoutDiscriminator#layout|layout}. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1369-L1371
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Union.getSpan
getSpan(b: Uint8Array, offset = 0): number { if (0 <= this.span) { return this.span; } /* Default layouts always have non-negative span, so we don't have * one and we have to recognize the variant which will in turn * determine the span. */ const vlo = this....
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1571-L1583
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Union.defaultGetSourceVariant
defaultGetSourceVariant(src: LayoutObject): VariantLayout | undefined { if (Object.prototype.hasOwnProperty.call(src, this.discriminator.property)) { if (this.defaultLayout && this.defaultLayout.property && Object.prototype.hasOwnProperty.call(src, this.defaultLayout.property)) { ...
/** * Method to infer a registered Union variant compatible with `src`. * * The first satisfied rule in the following sequence defines the * return value: * * If `src` has properties matching the Union discriminator and * the default layout, `undefined` is returned regardless of the ...
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1614-L1635
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Union.decode
decode(b: Uint8Array, offset = 0): LayoutObject { let dest: LayoutObject; const dlo = this.discriminator; const discr = dlo.decode(b, offset); const clo = this.registry[discr]; if (undefined === clo) { const defaultLayout = this.defaultLayout; let contentO...
/** Implement {@link Layout#decode|decode} for {@link Union}. * * If the variant is {@link Union#addVariant|registered} the return * value is an instance of that variant, with no explicit * discriminator. Otherwise the {@link Union#defaultLayout|default * layout} is used to decode the content. *...
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1643-L1663
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Union.encode
encode(src: LayoutObject, b: Uint8Array, offset = 0): number { const vlo = this.getSourceVariant(src); if (undefined === vlo) { const dlo = this.discriminator; // this.defaultLayout is not undefined when vlo is undefined // eslint-disable-next-line @typescript-eslint/...
/** Implement {@link Layout#encode|encode} for {@link Union}. * * This API assumes the `src` object is consistent with the union's * {@link Union#defaultLayout|default layout}. To encode variants * use the appropriate variant-specific {@link VariantLayout#encode} * method. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1671-L1688
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Union.addVariant
addVariant(variant: number, layout: Layout<LayoutObject>, property: string): VariantLayout { const rv = new VariantLayout(this, variant, layout, property); this.registry[variant] = rv; return rv; }
/** Register a new variant structure within a union. The newly * created variant is returned. * * @param {Number} variant - initializer for {@link * VariantLayout#variant|variant}. * * @param {Layout} layout - initializer for {@link * VariantLayout#layout|layout}. * *...
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1703-L1707
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
Union.getVariant
getVariant(vb: Uint8Array | number, offset = 0): VariantLayout | undefined { let variant: number; if (vb instanceof Uint8Array) { variant = this.discriminator.decode(vb, offset); } else { variant = vb; } return this.registry[variant]; }
/** * Get the layout associated with a registered variant. * * If `vb` does not produce a registered variant the function returns * `undefined`. * * @param {(Number|Uint8Array)} vb - either the variant number, or a * buffer from which the discriminator is to be read. * * @pa...
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1723-L1731
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
VariantLayout.getSpan
getSpan(b: Uint8Array, offset = 0): number { if (0 <= this.span) { /* Will be equal to the containing union span if that is not * variable. */ return this.span; } let contentOffset = 0; if (this.union.usesPrefixDiscriminator) { contentOffs...
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1820-L1836
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
VariantLayout.decode
decode(b: Uint8Array, offset = 0): LayoutObject { const dest = this.makeDestinationObject(); if (this !== this.union.getVariant(b, offset)) { throw new Error('variant mismatch'); } let contentOffset = 0; if (this.union.usesPrefixDiscriminator) { contentOff...
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1839-L1856
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
VariantLayout.encode
encode(src: LayoutObject, b: Uint8Array, offset = 0): number { let contentOffset = 0; if (this.union.usesPrefixDiscriminator) { contentOffset = (this.union.discriminator as UnionLayoutDiscriminator).layout.span; } if (this.layout && (!Object.prototype.hasOwnProper...
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1859-L1879
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
VariantLayout.fromArray
fromArray(values: any[]): LayoutObject | undefined { if (this.layout) { return this.layout.fromArray(values); } return undefined; }
/** Delegate {@link Layout#fromArray|fromArray} to {@link * VariantLayout#layout|layout}. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1883-L1888
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
fixBitwiseResult
function fixBitwiseResult(v: number): number { if (0 > v) { v += 0x100000000; } return v; }
/** JavaScript chose to define bitwise operations as operating on * signed 32-bit values in 2's complement form, meaning any integer * with bit 31 set is going to look negative. For right shifts that's * not a problem, because `>>>` is a logical shift, but for every * other bitwise operator we have to compensate f...
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1897-L1902
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
BitStructure.decode
decode(b: Uint8Array, offset = 0): LayoutObject { const dest = this.makeDestinationObject(); const value = this.word.decode(b, offset); this._packedSetValue(value); for (const fd of this.fields) { if (undefined !== fd.property) { dest[fd.property] = fd.decode(...
/** @override */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L1993-L2003
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
BitStructure.encode
encode(src: LayoutObject, b: Uint8Array, offset = 0): number { const value = this.word.decode(b, offset); this._packedSetValue(value); for (const fd of this.fields) { if (undefined !== fd.property) { const fv = src[fd.property]; if (undefined !== fv) {...
/** Implement {@link Layout#encode|encode} for {@link BitStructure}. * * If `src` is missing a property for a member with a defined {@link * Layout#property|property} the corresponding region of the packed * value is left unmodified. Unused bits are also left unmodified. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L2010-L2022
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
BitStructure.addField
addField(bits: number, property: string): BitField { const bf = new BitField(this, bits, property); this.fields.push(bf); return bf; }
/** Register a new bitfield with a containing bit structure. The * resulting bitfield is returned. * * @param {Number} bits - initializer for {@link BitField#bits|bits}. * * @param {string} property - initializer for {@link * Layout#property|property}. * * @return {BitField} ...
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L2033-L2037
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
BitStructure.addBoolean
addBoolean(property: string): Boolean { // This is my Boolean, not the Javascript one. const bf = new Boolean(this, property); this.fields.push(bf); return bf; }
// eslint-disable-next-line @typescript-eslint/ban-types
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L2048-L2053
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89
js-wallet-sdk
github_2023
okx
typescript
BitStructure.fieldFor
fieldFor(property: string): BitField | undefined { if ('string' !== typeof property) { throw new TypeError('property must be string'); } for (const fd of this.fields) { if (fd.property === property) { return fd; } } return undef...
/** * Get access to the bit field for a given property. * * @param {String} property - the bit field of interest. * * @return {BitField} - the field associated with `property`, or * undefined if there is no such property. */
https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-solana/src/sdk/buffer-layout/layout.ts#L2063-L2073
dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89