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 | BCS.registerStructType | public registerStructType(
typeName: TypeName,
fields: StructTypeDefinition
): BCS {
// When an Object is passed, we register it under a new key and store it
// in the registered type system. This way we allow nested inline definitions.
for (let key in fields) {
let internalName = this.tempK... | /**
* Safe method to register a custom Move struct. The first argument is a name of the
* struct which is only used on the FrontEnd and has no affect on serialization results,
* and the second is a struct description passed as an Object.
*
* The description object MUST have the same order on all of the p... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/bcs/index.ts#L1032-L1202 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BCS.registerEnumType | public registerEnumType(
typeName: TypeName,
variants: EnumTypeDefinition
): BCS {
// When an Object is passed, we register it under a new key and store it
// in the registered type system. This way we allow nested inline definitions.
for (let key in variants) {
let internalName = this.tempK... | /**
* Safe method to register custom enum type where each invariant holds the value of another type.
* @example
* bcs.registerStructType('Coin', { value: 'u64' });
* bcs.registerEnumType('MyEnum', {
* single: 'Coin',
* multi: 'vector<Coin>',
* empty: null
* });
*
* console.log(
* bc... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/bcs/index.ts#L1226-L1350 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BCS.getTypeInterface | public getTypeInterface(type: string): TypeInterface {
let typeInterface = this.types.get(type);
// Special case - string means an alias.
// Goes through the alias chain and tracks recursion.
if (typeof typeInterface === "string") {
let chain: string[] = [];
while (typeof typeInterface === ... | /**
* Get a set of encoders/decoders for specific type.
* Mainly used to define custom type de/serialization logic.
*
* @param type
* @returns {TypeInterface}
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/bcs/index.ts#L1358-L1383 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BCS.parseTypeName | public parseTypeName(name: TypeName): {
name: string;
params: TypeName[];
} {
if (Array.isArray(name)) {
let [typeName, ...params] = name;
return { name: typeName, params };
}
if (typeof name !== "string") {
throw new Error(`Illegal type passed as a name of the type: ${name}`);
... | /**
* Parse a type name and get the type's generics.
* @example
* let { typeName, typeParams } = parseTypeName('Option<Coin<SUI>>');
* // typeName: Option
* // typeParams: [ 'Coin<SUI>' ]
*
* @param name Name of the type to process
* @returns Object with typeName and typeParams listed as Array
... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/bcs/index.ts#L1395-L1430 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TransactionBlock.is | static is(obj: unknown): obj is TransactionBlock {
return (
!!obj &&
typeof obj === 'object' &&
(obj as any)[TRANSACTION_BRAND] === true
);
} | /** Returns `true` if the object is an instance of the Transaction builder class. */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/builder/TransactionBlock.ts#L108-L114 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TransactionBlock.fromKind | static fromKind(serialized: string | Uint8Array) {
const tx = new TransactionBlock();
tx.#blockData = TransactionBlockDataBuilder.fromKindBytes(
typeof serialized === 'string' ? fromB64(serialized) : serialized,
);
return tx;
} | /**
* Converts from a serialize transaction kind (built with `build({ onlyTransactionKind: true })`) to a `Transaction` class.
* Supports either a byte array, or base64-encoded bytes.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/builder/TransactionBlock.ts#L120-L128 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TransactionBlock.from | static from(serialized: string | Uint8Array) {
const tx = new TransactionBlock();
// Check for bytes:
if (typeof serialized !== 'string' || !serialized.startsWith('{')) {
tx.#blockData = TransactionBlockDataBuilder.fromBytes(
typeof serialized === 'string' ? fromB64(serialized) : serialized,
... | /**
* Converts from a serialized transaction format to a `Transaction` class.
* There are two supported serialized formats:
* - A string returned from `Transaction#serialize`. The serialized format must be compatible, or it will throw an error.
* - A byte array (or base64-encoded bytes) containing BCS trans... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/builder/TransactionBlock.ts#L136-L151 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TransactionBlock.Transactions | static get Transactions() {
return Transactions;
} | /** A helper to retrieve the Transaction builder `Transactions` */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/builder/TransactionBlock.ts#L154-L156 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TransactionBlock.Inputs | static get Inputs() {
return Inputs;
} | /** A helper to retrieve the Transaction builder `Inputs` */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/builder/TransactionBlock.ts#L159-L161 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TransactionBlock.setSenderIfNotSet | setSenderIfNotSet(sender: string) {
if (!this.#blockData.sender) {
this.#blockData.sender = sender;
}
} | /**
* Sets the sender only if it has not already been set.
* This is useful for sponsored transaction flows where the sender may not be the same as the signer address.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/builder/TransactionBlock.ts#L170-L174 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TransactionBlock.blockData | get blockData() {
return this.#blockData.snapshot();
} | /** Get a snapshot of the transaction data, in JSON form: */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/builder/TransactionBlock.ts#L200-L202 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TransactionBlock.gas | get gas(): TransactionArgument {
return { kind: 'GasCoin' };
} | /** Returns an argument for the gas coin, to be used in a transaction. */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/builder/TransactionBlock.ts#L217-L219 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TransactionBlock.object | object(value: ObjectId | ObjectCallArg) {
const id = getIdFromCallArg(value);
// deduplicate
const inserted = this.#blockData.inputs.find(
(i) => i.type === 'object' && id === getIdFromCallArg(i.value),
);
return inserted ?? this.#input('object', value);
} | /**
* Add a new object input to the transaction.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/builder/TransactionBlock.ts#L249-L256 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TransactionBlock.pure | pure(
/**
* The pure value that will be used as the input value. If this is a Uint8Array, then the value
* is assumed to be raw bytes, and will be used directly.
*/
value: unknown,
/**
* The BCS type to serialize the value into. If not provided, the type will automatically be determined
... | /**
* Add a new non-object input to the transaction.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/builder/TransactionBlock.ts#L261-L282 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TransactionBlock.add | add(transaction: TransactionType) {
const index = this.#blockData.transactions.push(transaction);
return createTransactionResult(index - 1);
} | /** Add a transaction to the transaction block. */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/builder/TransactionBlock.ts#L285-L288 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TransactionBlock.splitCoins | splitCoins(...args: Parameters<(typeof Transactions)['SplitCoins']>) {
return this.add(Transactions.SplitCoins(...args));
} | // Method shorthands: | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/builder/TransactionBlock.ts#L292-L294 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TransactionBlock.serialize | serialize() {
return JSON.stringify(this.#blockData.snapshot());
} | /**
* Serialize the transaction to a string so that it can be sent to a separate context.
* This is different from `build` in that it does not serialize to BCS bytes, and instead
* uses a separate format that is unique to the transaction builder. This allows
* us to serialize partially-complete transactions... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/builder/TransactionBlock.ts#L325-L327 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TransactionBlock.build | async build({
onlyTransactionKind,
}: BuildOptions = {}): Promise<Uint8Array> {
await this.#prepare({ onlyTransactionKind });
return this.#blockData.build({ onlyTransactionKind });
} | /** Build the transaction to BCS bytes. */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/builder/TransactionBlock.ts#L330-L335 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TransactionBlock.getDigest | async getDigest({
}: {
} = {}): Promise<string> {
await this.#prepare({ });
return this.#blockData.getDigest();
} | /** Derive transaction digest */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/builder/TransactionBlock.ts#L338-L343 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TransactionBlockDataBuilder.getDigestFromBytes | static getDigestFromBytes(bytes: Uint8Array) {
const hash = hashTypedData('TransactionData', bytes);
return toB58(hash);
} | /**
* Generate transaction digest.
*
* @param bytes BCS serialized transaction data
* @returns transaction digest.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/builder/TransactionBlockData.ts#L154-L157 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Ed25519Keypair.constructor | constructor(keypair: Ed25519KeypairData) {
this.keypair = keypair;
} | /**
* Create a new Ed25519 keypair instance.
* Generate random keypair if no {@link Ed25519Keypair} is provided.
*
* @param keypair Ed25519 keypair
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/cryptography/ed25519-keypair.ts#L32-L34 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Ed25519Keypair.getKeyScheme | getKeyScheme(): SignatureScheme {
return 'ED25519';
} | /**
* Get the key scheme of the keypair ED25519
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/cryptography/ed25519-keypair.ts#L39-L41 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Ed25519Keypair.fromSecretKey | static fromSecretKey(secretKey: Uint8Array, options?: { skipValidation?: boolean }): Ed25519Keypair {
const secretKeyLength = secretKey.length;
if (secretKeyLength != 64) {
// Many users actually wanted to invoke fromSeed(seed: Uint8Array), especially when reading from keystore.
if (secretKeyLength ... | /**
* Create a Ed25519 keypair from a raw secret key byte array.
*
* This method should only be used to recreate a keypair from a previously
* generated secret key.
*
* @throws error if the provided secret key is invalid and validation is not skipped.
*
* @param secretKey secret key byte array
... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/cryptography/ed25519-keypair.ts#L54-L76 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Ed25519Keypair.fromSeed | static fromSeed(seed: Uint8Array): Ed25519Keypair {
const seedLength = seed.length;
if (seedLength != 32) {
throw new Error(`Wrong seed size. Expected 32 bytes, got ${seedLength}.`);
}
return new Ed25519Keypair( signUtil.ed25519.fromSeed(seed));
} | /**
* Generate an Ed25519 keypair from a 32 byte seed.
*
* @param seed seed byte array
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/cryptography/ed25519-keypair.ts#L83-L89 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Ed25519Keypair.getPublicKey | getPublicKey(): Ed25519PublicKey {
return new Ed25519PublicKey(this.keypair.publicKey);
} | /**
* The public key for this Ed25519 keypair
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/cryptography/ed25519-keypair.ts#L94-L96 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Ed25519Keypair.signData | signData(data: Uint8Array): Uint8Array {
return signUtil.ed25519.sign(data, this.keypair.secretKey)
} | /**
* Return the signature for the provided data using Ed25519.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/cryptography/ed25519-keypair.ts#L101-L103 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Ed25519PublicKey.constructor | constructor(value: PublicKeyInitData) {
if (typeof value === 'string') {
this.data = fromB64(value);
} else if (value instanceof Uint8Array) {
this.data = value;
} else {
this.data = Uint8Array.from(value);
}
if (this.data.length !== PUBLIC_KEY_SIZE) {
throw new Error(
... | /**
* Create a new Ed25519PublicKey object
* @param value ed25519 public key as buffer or base-64 encoded string
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/cryptography/ed25519-publickey.ts#L22-L36 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Ed25519PublicKey.equals | equals(publicKey: Ed25519PublicKey): boolean {
return bytesEqual(this.toBytes(), publicKey.toBytes());
} | /**
* Checks if two Ed25519 public keys are equal
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/cryptography/ed25519-publickey.ts#L41-L43 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Ed25519PublicKey.toBase64 | toBase64(): string {
return toB64(this.toBytes());
} | /**
* Return the base-64 representation of the Ed25519 public key
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/cryptography/ed25519-publickey.ts#L48-L50 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Ed25519PublicKey.toBytes | toBytes(): Uint8Array {
return this.data;
} | /**
* Return the byte array representation of the Ed25519 public key
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/cryptography/ed25519-publickey.ts#L55-L57 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Ed25519PublicKey.toString | toString(): string {
return this.toBase64();
} | /**
* Return the base-64 representation of the Ed25519 public key
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/cryptography/ed25519-publickey.ts#L62-L64 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Ed25519PublicKey.toSuiAddress | toSuiAddress(): string {
let tmp = new Uint8Array(PUBLIC_KEY_SIZE + 1);
tmp.set([SIGNATURE_SCHEME_TO_FLAG['ED25519']]);
tmp.set(this.toBytes(), 1);
// Each hex char represents half a byte, hence hex address doubles the length
return normalizeSuiAddress(
base.toHex(base.blake2b(tmp, { dkLen: 32... | /**
* Return the Sui address associated with this Ed25519 public key
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/cryptography/ed25519-publickey.ts#L69-L77 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Coin.sortByBalance | static sortByBalance(coins: CoinStruct[]): CoinStruct[] {
return [...coins].sort((a, b) =>
Coin.getBalanceFromCoinStruct(a) < Coin.getBalanceFromCoinStruct(b)
? -1
: Coin.getBalanceFromCoinStruct(a) > Coin.getBalanceFromCoinStruct(b)
? 1
: 0,
);
} | /**
* Sort coin by balance in an ascending order
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-sui/src/framework/framework.ts#L110-L118 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TonWallet.getDerivedPath | async getDerivedPath(param: GetDerivedPathParam): Promise<any> {
return `m/44'/607'/${param.index}'`;
} | // derive path of okx | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/TonWallet.ts#L149-L151 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TonWallet.signMultiTransactionForNFT | async signMultiTransactionForNFT(param: SignTxParams) {
const data = param.data as SignMultiTransactionForNFTParams;
const nftAddresses = data.nftAddresses;
const messages = nftAddresses.map((nftAddress, index) => {
const nft = data.nfts?.[index];
const isNotcoinBurn = nf... | // todo do test | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/TonWallet.ts#L412-L429 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TonWallet.buildNotcoinVoucherExchange | async buildNotcoinVoucherExchange(params: BuildNotcoinVoucherExchangeParams) {
const payload = buildNotcoinVoucherExchange(params.fromNFTAddress, params.nftAddress, params.nftIndex)
return Promise.resolve(payload.toBoc().toString('base64'));
} | // todo do test | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/TonWallet.ts#L432-L435 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | TonWallet.buildNftTransferPayload | async buildNftTransferPayload(params: BuildNftTransferPayloadParams) {
const payload = buildNftTransferPayload(params.fromNFTAddress, params.nftAddress, params.comment)
return Promise.resolve(payload.toBoc().toString('base64'));
} | // todo do test | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/TonWallet.ts#L438-L441 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | VenomWallet.signTransaction | async signTransaction(param: SignTxParams): Promise<any> {
try {
return venomTransfer(param.data as TxData, param.privateKey);
} catch (e) {
return Promise.reject(SignTxError);
}
} | // todo do test | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/TonWallet.ts#L458-L464 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitBuilder.length | get length() {
return this._length;
} | /**
* Current number of bits written
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitBuilder.ts#L30-L32 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitBuilder.writeBit | writeBit(value: boolean | number) {
// Check overflow
let n = this._length;
if (n > this._buffer.length * 8) {
throw new Error("BitBuilder overflow");
}
// Set bit
if ((typeof value === 'boolean' && value === true) || (typeof value === 'number' && value > 0)... | /**
* Write a single bit
* @param value bit to write, true or positive number for 1, false or zero or negative for 0
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitBuilder.ts#L38-L53 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitBuilder.writeBits | writeBits(src: BitString) {
for (let i = 0; i < src.length; i++) {
this.writeBit(src.at(i));
}
} | /**
* Copy bits from BitString
* @param src source bits
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitBuilder.ts#L59-L63 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitBuilder.writeBuffer | writeBuffer(src: Buffer) {
// Special case for aligned offsets
if (this._length % 8 === 0) {
if (this._length + src.length * 8 > this._buffer.length * 8) {
throw new Error("BitBuilder overflow");
}
src.copy(this._buffer, this._length / 8);
... | /**
* Write bits from buffer
* @param src source buffer
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitBuilder.ts#L69-L83 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitBuilder.writeUint | writeUint(value: bigint | number, bits: number) {
if (bits < 0 || !Number.isSafeInteger(bits)) {
throw Error(`invalid bit length. Got ${bits}`);
}
const v = BigInt(value);
if (bits === 0) {
if (v !== 0n) {
throw Error(`value is not zero for ${bit... | /**
* Write uint value
* @param value value as bigint or number
* @param bits number of bits to write
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitBuilder.ts#L90-L140 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitBuilder.writeInt | writeInt(value: bigint | number, bits: number) {
let v = BigInt(value);
if (bits < 0 || !Number.isSafeInteger(bits)) {
throw Error(`invalid bit length. Got ${bits}`);
}
// Corner case for zero bits
if (bits === 0) {
if (value !== 0n) {
thr... | /**
* Write int value
* @param value value as bigint or number
* @param bits number of bits to write
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitBuilder.ts#L147-L188 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitBuilder.writeVarUint | writeVarUint(value: number | bigint, bits: number) {
let v = BigInt(value);
if (bits < 0 || !Number.isSafeInteger(bits)) {
throw Error(`invalid bit length. Got ${bits}`);
}
if (v < 0) {
throw Error(`value is negative. Got ${value}`);
}
// Corner c... | /**
* Wrtie var uint value, used for serializing coins
* @param value value to write as bigint or number
* @param bits header bits to write size
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitBuilder.ts#L195-L220 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitBuilder.writeVarInt | writeVarInt(value: number | bigint, bits: number) {
let v = BigInt(value);
if (bits < 0 || !Number.isSafeInteger(bits)) {
throw Error(`invalid bit length. Got ${bits}`);
}
// Corner case for zero
if (v === 0n) {
// Write zero size
this.writeUi... | /**
* Wrtie var int value, used for serializing coins
* @param value value to write as bigint or number
* @param bits header bits to write size
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitBuilder.ts#L227-L250 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitBuilder.writeCoins | writeCoins(amount: number | bigint) {
this.writeVarUint(amount, 4);
} | /**
* Write coins in var uint format
* @param amount amount to write
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitBuilder.ts#L256-L258 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitBuilder.writeAddress | writeAddress(address: Maybe<Address | ExternalAddress>) {
// Is empty address
if (address === null || address === undefined) {
this.writeUint(0, 2); // Empty address
return;
}
// Is Internal Address
if (Address.isAddress(address)) {
this.writ... | /**
* Write address
* @param address write address or address external
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitBuilder.ts#L264-L291 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitBuilder.build | build() {
return new BitString(this._buffer, 0, this._length);
} | /**
* Build BitString
* @returns result bit string
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitBuilder.ts#L297-L299 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitBuilder.buffer | buffer() {
if (this._length % 8 !== 0) {
throw new Error("BitBuilder buffer is not byte aligned");
}
return this._buffer.subarray(0, this._length / 8);
} | /**
* Build into Buffer
* @returns result buffer
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitBuilder.ts#L305-L310 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.offset | get offset() {
return this._offset;
} | /**
* Offset in source bit string
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L30-L32 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.remaining | get remaining() {
return this._bits.length - this._offset;
} | /**
* Number of bits remaining
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L37-L39 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.skip | skip(bits: number) {
if (bits < 0 || this._offset + bits > this._bits.length) {
throw new Error(`Index ${this._offset + bits} is out of bounds`);
}
this._offset += bits;
} | /**
* Skip bits
* @param bits number of bits to skip
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L45-L50 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.reset | reset() {
if (this._checkpoints.length > 0) {
this._offset = this._checkpoints.pop()!;
} else {
this._offset = 0;
}
} | /**
* Reset to the beginning or latest checkpoint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L55-L61 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.save | save() {
this._checkpoints.push(this._offset);
} | /**
* Save checkpoint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L66-L68 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadBit | loadBit(): boolean {
let r = this._bits.at(this._offset);
this._offset++;
return r;
} | /**
* Load a single bit
* @returns true if the bit is set, false otherwise
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L74-L78 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.preloadBit | preloadBit() {
return this._bits.at(this._offset);
} | /**
* Preload bit
* @returns true if the bit is set, false otherwise
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L84-L86 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadBits | loadBits(bits: number) {
let r = this._bits.substring(this._offset, bits);
this._offset += bits;
return r;
} | /**
* Load bit string
* @param bits number of bits to read
* @returns new bitstring
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L93-L97 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.preloadBits | preloadBits(bits: number) {
return this._bits.substring(this._offset, bits);
} | /**
* Preload bit string
* @param bits number of bits to read
* @returns new bitstring
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L104-L106 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadBuffer | loadBuffer(bytes: number) {
let buf = this._preloadBuffer(bytes, this._offset);
this._offset += bytes * 8;
return buf;
} | /**
* Load buffer
* @param bytes number of bytes
* @returns new buffer
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L113-L117 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.preloadBuffer | preloadBuffer(bytes: number) {
return this._preloadBuffer(bytes, this._offset);
} | /**
* Preload buffer
* @param bytes number of bytes
* @returns new buffer
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L124-L126 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadUint | loadUint(bits: number): number {
return Number(this.loadUintBig(bits));
} | /**
* Load uint value
* @param bits uint bits
* @returns read value as number
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L133-L135 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadUintBig | loadUintBig(bits: number): bigint {
let loaded = this.preloadUintBig(bits);
this._offset += bits;
return loaded;
} | /**
* Load uint value as bigint
* @param bits uint bits
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L142-L146 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.preloadUint | preloadUint(bits: number): number {
return Number(this._preloadUint(bits, this._offset));
} | /**
* Preload uint value
* @param bits uint bits
* @returns read value as number
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L153-L155 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.preloadUintBig | preloadUintBig(bits: number): bigint {
return this._preloadUint(bits, this._offset);
} | /**
* Preload uint value as bigint
* @param bits uint bits
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L162-L164 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadInt | loadInt(bits: number): number {
let res = this._preloadInt(bits, this._offset);
this._offset += bits;
return Number(res);
} | /**
* Load int value
* @param bits int bits
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L171-L175 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadIntBig | loadIntBig(bits: number): bigint {
let res = this._preloadInt(bits, this._offset);
this._offset += bits;
return res;
} | /**
* Load int value as bigint
* @param bits int bits
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L182-L186 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.preloadInt | preloadInt(bits: number): number {
return Number(this._preloadInt(bits, this._offset));
} | /**
* Preload int value
* @param bits int bits
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L193-L195 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.preloadIntBig | preloadIntBig(bits: number): bigint {
return this._preloadInt(bits, this._offset);
} | /**
* Preload int value
* @param bits int bits
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L202-L204 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadVarUint | loadVarUint(bits: number): number {
let size = Number(this.loadUint(bits));
return Number(this.loadUintBig(size * 8));
} | /**
* Load varuint value
* @param bits number of bits to read the size
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L211-L214 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadVarUintBig | loadVarUintBig(bits: number): bigint {
let size = Number(this.loadUint(bits));
return this.loadUintBig(size * 8);
} | /**
* Load varuint value
* @param bits number of bits to read the size
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L221-L224 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.preloadVarUint | preloadVarUint(bits: number): number {
let size = Number(this._preloadUint(bits, this._offset));
return Number(this._preloadUint(size * 8, this._offset + bits));
} | /**
* Preload varuint value
* @param bits number of bits to read the size
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L231-L234 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.preloadVarUintBig | preloadVarUintBig(bits: number): bigint {
let size = Number(this._preloadUint(bits, this._offset));
return this._preloadUint(size * 8, this._offset + bits);
} | /**
* Preload varuint value
* @param bits number of bits to read the size
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L241-L244 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadVarInt | loadVarInt(bits: number): number {
let size = Number(this.loadUint(bits));
return Number(this.loadIntBig(size * 8));
} | /**
* Load varint value
* @param bits number of bits to read the size
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L251-L254 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadVarIntBig | loadVarIntBig(bits: number): bigint {
let size = Number(this.loadUint(bits));
return this.loadIntBig(size * 8);
} | /**
* Load varint value
* @param bits number of bits to read the size
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L261-L264 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.preloadVarInt | preloadVarInt(bits: number): number {
let size = Number(this._preloadUint(bits, this._offset));
return Number(this._preloadInt(size * 8, this._offset + bits));
} | /**
* Preload varint value
* @param bits number of bits to read the size
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L271-L274 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.preloadVarIntBig | preloadVarIntBig(bits: number): bigint {
let size = Number(this._preloadUint(bits, this._offset));
return this._preloadInt(size * 8, this._offset + bits);
} | /**
* Preload varint value
* @param bits number of bits to read the size
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L281-L284 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadCoins | loadCoins() {
return this.loadVarUintBig(4);
} | /**
* Load coins value
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L290-L292 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.preloadCoins | preloadCoins() {
return this.preloadVarUintBig(4);
} | /**
* Preload coins value
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L298-L300 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadAddress | loadAddress() {
let type = Number(this._preloadUint(2, this._offset));
if (type === 2) {
return this._loadInternalAddress();
} else {
throw new Error("Invalid address: " + type);
}
} | /**
* Load Address
* @returns Address
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L306-L313 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadMaybeAddress | loadMaybeAddress() {
let type = Number(this._preloadUint(2, this._offset));
if (type === 0) {
this._offset += 2;
return null;
} else if (type === 2) {
return this._loadInternalAddress();
} else {
throw new Error("Invalid address");
... | /**
* Load internal address
* @returns Address or null
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L319-L329 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadExternalAddress | loadExternalAddress() {
let type = Number(this._preloadUint(2, this._offset));
if (type === 1) {
return this._loadExternalAddress();
} else {
throw new Error("Invalid address");
}
} | /**
* Load external address
* @returns ExternalAddress
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L335-L342 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadMaybeExternalAddress | loadMaybeExternalAddress() {
let type = Number(this._preloadUint(2, this._offset));
if (type === 0) {
this._offset += 2;
return null;
} else if (type === 1) {
return this._loadExternalAddress();
} else {
throw new Error("Invalid address");
... | /**
* Load external address
* @returns ExternalAddress or null
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L348-L358 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadAddressAny | loadAddressAny() {
let type = Number(this._preloadUint(2, this._offset));
if (type === 0) {
this._offset += 2;
return null;
} else if (type === 2) {
return this._loadInternalAddress();
} else if (type === 1) {
return this._loadExternalAddre... | /**
* Read address of any type
* @returns Address or ExternalAddress or null
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L364-L378 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.loadPaddedBits | loadPaddedBits(bits: number) {
// Check that number of bits is byte alligned
if (bits % 8 !== 0) {
throw new Error("Invalid number of bits");
}
// Skip padding
let length = bits;
while (true) {
if (this._bits.at(this._offset + length - 1)) {
... | /**
* Load bit string that was padded to make it byte alligned. Used in BOC serialization
* @param bytes number of bytes to read
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L384-L406 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader.clone | clone() {
return new BitReader(this._bits, this._offset);
} | /**
* Clone BitReader
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L411-L413 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader._preloadInt | private _preloadInt(bits: number, offset: number): bigint {
if (bits == 0) {
return 0n;
}
let sign = this._bits.at(offset);
let res = 0n;
for (let i = 0; i < bits - 1; i++) {
if (this._bits.at(offset + 1 + i)) {
res += 1n << BigInt(bits - i... | /**
* Preload int from specific offset
* @param bits bits to preload
* @param offset offset to start from
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L421-L436 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitReader._preloadUint | private _preloadUint(bits: number, offset: number): bigint {
if (bits == 0) {
return 0n;
}
let res = 0n;
for (let i = 0; i < bits; i++) {
if (this._bits.at(offset + i)) {
res += 1n << BigInt(bits - i - 1);
}
}
return res... | /**
* Preload uint from specific offset
* @param bits bits to preload
* @param offset offset to start from
* @returns read value as bigint
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitReader.ts#L444-L455 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitString.isBitString | static isBitString(src: unknown): src is BitString {
return src instanceof BitString;
} | /**
* Checks if supplied object is BitString
* @param src is unknow object
* @returns true if object is BitString and false otherwise
**/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitString.ts#L32-L34 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitString.constructor | constructor(data: Buffer, offset: number, length: number) {
// Check bounds
if (length < 0) {
throw new Error(`Length ${length} is out of bounds`);
}
this._length = length;
this._data = data;
this._offset = offset;
} | /**
* Constructing BitString from a buffer
* @param data data that contains the bitstring data. NOTE: We are expecting this buffer to be NOT modified
* @param offset offset in bits from the start of the buffer
* @param length length of the bitstring in bits
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitString.ts#L41-L51 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitString.length | get length() {
return this._length;
} | /**
* Returns the length of the bitstring
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitString.ts#L56-L58 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitString.at | at(index: number) {
// Check bounds
if (index >= this._length) {
throw new Error(`Index ${index} > ${this._length} is out of bounds`);
}
if (index < 0) {
throw new Error(`Index ${index} < 0 is out of bounds`);
}
// Calculcate offsets
let ... | /**
* Returns the bit at the specified index
* @param index index of the bit
* @throws Error if index is out of bounds
* @returns true if the bit is set, false otherwise
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitString.ts#L66-L82 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitString.substring | substring(offset: number, length: number) {
// Check offset
if (offset > this._length) {
throw new Error(`Offset(${offset}) > ${this._length} is out of bounds`);
}
if (offset < 0) {
throw new Error(`Offset(${offset}) < 0 is out of bounds`);
}
... | /**
* Get a subscring of the bitstring
* @param offset
* @param length
* @returns
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitString.ts#L90-L111 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitString.subbuffer | subbuffer(offset: number, length: number) {
// Check offset
if (offset > this._length) {
throw new Error(`Offset ${offset} is out of bounds`);
}
if (offset < 0) {
throw new Error(`Offset ${offset} is out of bounds`);
}
if (offset + length > this._... | /**
* Try to get a buffer from the bitstring without allocations
* @param offset offset in bits
* @param length length in bits
* @returns buffer if the bitstring is aligned to bytes, null otherwise
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitString.ts#L119-L144 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitString.equals | equals(b: BitString) {
if (this._length !== b._length) {
return false;
}
for (let i = 0; i < this._length; i++) {
if (this.at(i) !== b.at(i)) {
return false;
}
}
return true;
} | /**
* Checks for equality
* @param b other bitstring
* @returns true if the bitstrings are equal, false otherwise
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitString.ts#L151-L161 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BitString.toString | toString(): string {
const padded = bitsToPaddedBuffer(this);
if (this._length % 4 === 0) {
const s = padded.subarray(0, Math.ceil(this._length / 8)).toString('hex').toUpperCase();
if (this._length % 8 === 0) {
return s;
} else {
retur... | /**
* Format to canonical string
* @returns formatted bits as a string
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/BitString.ts#L167-L185 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Builder.bits | get bits() {
return this._bits.length;
} | /**
* Bits written so far
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/Builder.ts#L43-L45 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Builder.refs | get refs() {
return this._refs.length;
} | /**
* References written so far
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/Builder.ts#L50-L52 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Builder.availableBits | get availableBits() {
return 1023 - this.bits;
} | /**
* Available bits
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/Builder.ts#L57-L59 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Builder.availableRefs | get availableRefs() {
return 4 - this.refs;
} | /**
* Available references
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-ton/src/ton-core/boc/Builder.ts#L64-L66 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.