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 | MultiKeySignature.serialize | serialize(serializer: Serializer): void {
// Note: we should not need to serialize the vector length, as it can be derived from the bitmap
serializer.serializeVector(this.signatures);
serializer.serializeBytes(this.bitmap);
} | // region Serializable | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/multiKey.ts#L278-L282 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1PublicKey.constructor | constructor(hexInput: HexInput) {
super();
const hex = Hex.fromHexInput(hexInput);
if (hex.toUint8Array().length !== Secp256k1PublicKey.LENGTH) {
throw new Error(`PublicKey length should be ${Secp256k1PublicKey.LENGTH}`);
}
this.key = hex;
} | /**
* Create a new PublicKey instance from a Uint8Array or String.
*
* @param hexInput A HexInput (string or Uint8Array)
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L33-L41 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1PublicKey.verifySignature | verifySignature(args: VerifySignatureArgs): boolean {
const { message, signature } = args;
if (!(signature instanceof Secp256k1Signature)) {
return false;
}
const messageToVerify = convertSigningMessage(message);
const messageBytes = Hex.fromHexInput(messageToVerify).toUint8Array();
const ... | /**
* Verifies a Secp256k1 signature against the public key
*
* Note signatures are validated to be canonical as a malleability check
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L49-L59 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1PublicKey.serialize | serialize(serializer: Serializer): void {
serializer.serializeBytes(this.key.toUint8Array());
} | // region Serializable | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L69-L71 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1PublicKey.isPublicKey | static isPublicKey(publicKey: PublicKey): publicKey is Secp256k1PublicKey {
return publicKey instanceof Secp256k1PublicKey;
} | /**
* @deprecated use `instanceof Secp256k1PublicKey` instead
* @param publicKey
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L84-L86 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1PrivateKey.constructor | constructor(hexInput: HexInput) {
super();
const privateKeyHex = Hex.fromHexInput(hexInput);
if (privateKeyHex.toUint8Array().length !== Secp256k1PrivateKey.LENGTH) {
throw new Error(`PrivateKey length should be ${Secp256k1PrivateKey.LENGTH}`);
}
this.key = privateKeyHex;
} | /**
* Create a new PrivateKey instance from a Uint8Array or String.
*
* @param hexInput A HexInput (string or Uint8Array)
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L111-L120 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1PrivateKey.generate | static generate(): Secp256k1PrivateKey {
const hexInput = secp256k1.utils.randomPrivateKey();
return new Secp256k1PrivateKey(hexInput);
} | /**
* Generate a new random private key.
*
* @returns Secp256k1PrivateKey
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L127-L130 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1PrivateKey.fromDerivationPath | static fromDerivationPath(path: string, mnemonics: string): Secp256k1PrivateKey {
if (!isValidBIP44Path(path)) {
throw new Error(`Invalid derivation path ${path}`);
}
return Secp256k1PrivateKey.fromDerivationPathInner(path, mnemonicToSeed(mnemonics));
} | /**
* Derives a private key from a mnemonic seed phrase.
*
* @param path the BIP44 path
* @param mnemonics the mnemonic seed phrase
*
* @returns The generated key
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L140-L145 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1PrivateKey.fromDerivationPathInner | private static fromDerivationPathInner(path: string, seed: Uint8Array): Secp256k1PrivateKey {
const { privateKey } = HDKey.fromMasterSeed(seed).derive(path);
// library returns privateKey as Uint8Array | null
if (privateKey === null) {
throw new Error("Invalid key");
}
return new Secp256k1Pri... | /**
* A private inner function so we can separate from the main fromDerivationPath() method
* to add tests to verify we create the keys correctly.
*
* @param path the BIP44 path
* @param seed the seed phrase created by the mnemonics
*
* @returns The generated key
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L156-L164 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1PrivateKey.sign | sign(message: HexInput): Secp256k1Signature {
const messageToSign = convertSigningMessage(message);
const messageBytes = Hex.fromHexInput(messageToSign);
const messageHashBytes = sha3_256(messageBytes.toUint8Array());
const signature = secp256k1.sign(messageHashBytes, this.key.toUint8Array(), { lowS: tr... | /**
* Sign the given message with the private key.
*
* Note: signatures are canonical, and non-malleable
*
* @param message a message as a string or Uint8Array
* @returns Signature
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L178-L184 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1PrivateKey.publicKey | publicKey(): Secp256k1PublicKey {
const bytes = secp256k1.getPublicKey(this.key.toUint8Array(), false);
return new Secp256k1PublicKey(bytes);
} | /**
* Derive the Secp256k1PublicKey from this private key.
*
* @returns Secp256k1PublicKey
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L191-L194 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1PrivateKey.toUint8Array | toUint8Array(): Uint8Array {
return this.key.toUint8Array();
} | /**
* Get the private key in bytes (Uint8Array).
*
* @returns
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L61-L63 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1PrivateKey.toString | toString(): string {
return this.key.toString();
} | /**
* Get the private key as a hex string with the 0x prefix.
*
* @returns string representation of the private key
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L210-L212 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1PrivateKey.serialize | serialize(serializer: Serializer): void {
serializer.serializeBytes(this.toUint8Array());
} | // region Serializable | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L218-L220 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1PrivateKey.isPrivateKey | static isPrivateKey(privateKey: PrivateKey): privateKey is Secp256k1PrivateKey {
return privateKey instanceof Secp256k1PrivateKey;
} | /**
* @deprecated use `instanceof Secp256k1PrivateKey` instead
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L232-L234 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1Signature.constructor | constructor(hexInput: HexInput) {
super();
const data = Hex.fromHexInput(hexInput);
if (data.toUint8Array().length !== Secp256k1Signature.LENGTH) {
throw new Error(
`Signature length should be ${Secp256k1Signature.LENGTH}, received ${data.toUint8Array().length}`,
);
}
this.data =... | /**
* Create a new Signature instance from a Uint8Array or String.
*
* @param hexInput A HexInput (string or Uint8Array)
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L259-L268 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1Signature.toUint8Array | toUint8Array(): Uint8Array {
return this.data.toUint8Array();
} | // region Signature | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L274-L276 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Secp256k1Signature.serialize | serialize(serializer: Serializer): void {
serializer.serializeBytes(this.data.toUint8Array());
} | // region Serializable | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/secp256k1.ts#L282-L284 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | AnyPublicKey.constructor | constructor(publicKey: PublicKey) {
super();
this.publicKey = publicKey;
if (publicKey instanceof Ed25519PublicKey) {
this.variant = AnyPublicKeyVariant.Ed25519;
} else if (publicKey instanceof Secp256k1PublicKey) {
this.variant = AnyPublicKeyVariant.Secp256k1;
} else {
throw new E... | // region Constructors | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/singleKey.ts#L30-L40 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | AnyPublicKey.verifySignature | verifySignature(args: VerifySignatureArgs): boolean {
const { message, signature } = args;
if (!(signature instanceof AnySignature)) {
return false;
}
return this.publicKey.verifySignature({
message,
signature: signature.signature,
});
} | // region AccountPublicKey | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/singleKey.ts#L46-L56 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | AnyPublicKey.serialize | serialize(serializer: Serializer): void {
serializer.serializeU32AsUleb128(this.variant);
this.publicKey.serialize(serializer);
} | // region Serializable | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/singleKey.ts#L73-L76 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | AnyPublicKey.isPublicKey | static isPublicKey(publicKey: AccountPublicKey): publicKey is AnyPublicKey {
return publicKey instanceof AnyPublicKey;
} | /**
* @deprecated use `instanceof AnyPublicKey` instead.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/singleKey.ts#L99-L101 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | AnyPublicKey.isEd25519 | isEd25519(): boolean {
return this.publicKey instanceof Ed25519PublicKey;
} | /**
* @deprecated use `publicKey instanceof Ed25519PublicKey` instead.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/singleKey.ts#L106-L108 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | AnyPublicKey.isSecp256k1PublicKey | isSecp256k1PublicKey(): boolean {
return this.publicKey instanceof Secp256k1PublicKey;
} | /**
* @deprecated use `publicKey instanceof Secp256k1PublicKey` instead.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/singleKey.ts#L113-L115 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | AnySignature.constructor | constructor(signature: Signature) {
super();
this.signature = signature;
if (signature instanceof Ed25519Signature) {
this.variant = AnySignatureVariant.Ed25519;
} else if (signature instanceof Secp256k1Signature) {
this.variant = AnySignatureVariant.Secp256k1;
} else {
throw new ... | // region Constructors | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/singleKey.ts#L133-L144 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | AnySignature.toUint8Array | toUint8Array() {
return this.bcsToBytes();
} | // region AccountSignature | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/singleKey.ts#L65-L67 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | AnySignature.serialize | serialize(serializer: Serializer): void {
serializer.serializeU32AsUleb128(this.variant);
this.signature.serialize(serializer);
} | // region Serializable | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/core/crypto/singleKey.ts#L158-L161 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | ModuleId.constructor | constructor(address: AccountAddress, name: Identifier) {
super();
this.address = address;
this.name = name;
} | /**
* Full name of a module.
* @param address The account address. e.g "0x1"
* @param name The module name under the "address". e.g "coin"
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/instances/moduleId.ts#L24-L28 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | ModuleId.fromStr | static fromStr(moduleId: MoveModuleId): ModuleId {
const parts = moduleId.split("::");
if (parts.length !== 2) {
throw new Error("Invalid module id.");
}
return new ModuleId(AccountAddress.fromString(parts[0]), new Identifier(parts[1]));
} | /**
* Converts a string literal to a ModuleId
* @param moduleId String literal in format "account_address::module_name", e.g. "0x1::coin"
* @returns ModuleId
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/instances/moduleId.ts#L35-L41 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | MultiAgentTransaction.constructor | constructor(
rawTransaction: RawTransaction,
secondarySignerAddresses: AccountAddress[],
feePayerAddress?: AccountAddress,
) {
super();
this.rawTransaction = rawTransaction;
this.feePayerAddress = feePayerAddress;
this.secondarySignerAddresses = secondarySignerAddresses;
} | /**
* SimpleTransaction represents a simple transaction type of a single signer that
* can be submitted to Aptos chain for execution.
*
* SimpleTransaction metadata contains the Raw Transaction and an optional
* sponsor Account Address to pay the gas fees.
*
* @param rawTransaction The Raw Tranasac... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/instances/multiAgentTransaction.ts#L31-L40 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | RawTransaction.constructor | constructor(
sender: AccountAddress,
sequence_number: bigint,
payload: TransactionPayload,
max_gas_amount: bigint,
gas_unit_price: bigint,
expiration_timestamp_secs: bigint,
chain_id: ChainId,
) {
super();
this.sender = sender;
this.sequence_number = sequence_numb... | /**
* RawTransactions contain the metadata and payloads that can be submitted to Aptos chain for execution.
* RawTransactions must be signed before Aptos chain can execute them.
*
* @param sender The sender Account Address
* @param sequence_number Sequence number of this transaction. This must match the ... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/instances/rawTransaction.ts#L46-L63 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | SignedTransaction.constructor | constructor(raw_txn: RawTransaction, authenticator: TransactionAuthenticator) {
super();
this.raw_txn = raw_txn;
this.authenticator = authenticator;
} | /**
* A SignedTransaction consists of a raw transaction and an authenticator. The authenticator
* contains a client's public key and the signature of the raw transaction.
*
* @see {@link https://aptos.dev/integration/creating-a-signed-transaction | Creating a Signed Transaction}
*
* @param... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/instances/signedTransaction.ts#L27-L31 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | SimpleTransaction.constructor | constructor(rawTransaction: RawTransaction, feePayerAddress?: AccountAddress) {
super();
this.rawTransaction = rawTransaction;
this.feePayerAddress = feePayerAddress;
} | /**
* SimpleTransaction represents a simple transaction type of a single signer that
* can be submitted to Aptos chain for execution.
*
* SimpleTransaction metadata contains the Raw Transaction and an optional
* sponsor Account Address to pay the gas fees.
*
* @param rawTransaction The Raw Tranasac... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/instances/simpleTransaction.ts#L33-L37 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | EntryFunction.constructor | constructor(
module_name: ModuleId,
function_name: Identifier,
type_args: Array<TypeTag>,
args: Array<EntryFunctionArgument>,
) {
this.module_name = module_name;
this.function_name = function_name;
this.type_args = type_args;
this.args = args;
} | /**
* Contains the payload to run a function within a module.
* @param module_name Fully qualified module name in format "account_address::module_name" e.g. "0x1::coin"
* @param function_name The function name. e.g "transfer"
* @param type_args Type arguments that move function requires.
*
* @example
... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/instances/transactionPayload.ts#L174-L184 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | EntryFunction.build | static build(
module_id: MoveModuleId,
function_name: string,
type_args: Array<TypeTag>,
args: Array<EntryFunctionArgument>,
): EntryFunction {
return new EntryFunction(ModuleId.fromStr(module_id), new Identifier(function_name), type_args, args);
} | /**
* A helper function to build a EntryFunction payload from raw primitive values
*
* @param module_id Fully qualified module name in format "AccountAddress::module_id" e.g. "0x1::coin"
* @param function_name Function name
* @param type_args Type arguments that move function requires.
*
* @example... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/instances/transactionPayload.ts#L207-L214 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | EntryFunction.deserialize | static deserialize(deserializer: Deserializer): EntryFunction {
const module_name = ModuleId.deserialize(deserializer);
const function_name = Identifier.deserialize(deserializer);
const type_args = deserializer.deserializeVector(TypeTag);
const length = deserializer.deserializeUleb128AsU32();
const... | /**
* Deserializes an entry function payload with the arguments represented as EntryFunctionBytes instances.
* @see EntryFunctionBytes
*
* NOTE: When you deserialize an EntryFunction payload with this method, the entry function
* arguments are populated into the deserialized instance as type-agnostic, ra... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/instances/transactionPayload.ts#L244-L259 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Script.constructor | constructor(bytecode: Uint8Array, type_args: Array<TypeTag>, args: Array<ScriptFunctionArgument>) {
this.bytecode = bytecode;
this.type_args = type_args;
this.args = args;
} | /**
* Scripts contain the Move bytecodes payload that can be submitted to Aptos chain for execution.
*
* @param bytecode The move module bytecode
* @param type_args The type arguments that the bytecode function requires.
*
* @example
* A coin transfer function has one type argument "CoinType".
*... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/instances/transactionPayload.ts#L300-L304 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | MultiSig.constructor | constructor(multisig_address: AccountAddress, transaction_payload?: MultiSigTransactionPayload) {
this.multisig_address = multisig_address;
this.transaction_payload = transaction_payload;
} | /**
* Contains the payload to run a multi-sig account transaction.
*
* @param multisig_address The multi-sig account address the transaction will be executed as.
*
* @param transaction_payload The payload of the multi-sig transaction. This is optional when executing a multi-sig
* transaction whose pa... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/instances/transactionPayload.ts#L347-L350 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | MultiSigTransactionPayload.constructor | constructor(transaction_payload: EntryFunction) {
super();
this.transaction_payload = transaction_payload;
} | /**
* Contains the payload to run a multi-sig account transaction.
*
* @param transaction_payload The payload of the multi-sig transaction.
* This can only be EntryFunction for now but,
* Script might be supported in the future.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/instances/transactionPayload.ts#L393-L396 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | parseArg | function parseArg(
arg: SimpleEntryFunctionArgumentTypes,
param: TypeTag,
position: number,
genericTypeParams: Array<TypeTag>,
): EntryFunctionArgumentTypes {
if (param.isBool()) {
if (isBool(arg)) {
return new Bool(arg);
}
if (isString(arg)) {
if (arg... | /**
* Parses a non-BCS encoded argument into a BCS encoded argument recursively
* @param arg
* @param param
* @param position
* @param genericTypeParams
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/transactionBuilder/remoteAbi.ts#L137-L267 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | checkType | function checkType(param: TypeTag, arg: EntryFunctionArgumentTypes, position: number) {
if (param.isBool()) {
if (isBcsBool(arg)) {
return;
}
throwTypeMismatch("Bool", position);
}
if (param.isAddress()) {
if (isBcsAddress(arg)) {
return;
}
... | /**
* Checks that the type of an already BCS encoded argument matches the ABI
* @param param
* @param arg
* @param position
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/transactionBuilder/remoteAbi.ts#L275-L364 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | generateTransactionPayloadScript | function generateTransactionPayloadScript(args: InputScriptData) {
return new TransactionPayloadScript(
new Script(Hex.fromHexInput(args.bytecode).toUint8Array(), args.typeArguments ?? [], args.functionArguments),
);
} | // export async function generateViewFunctionPayload(args: InputViewFunctionDataWithRemoteABI): Promise<EntryFunction> { | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/transactionBuilder/transactionBuilder.ts#L217-L221 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | fetchAbi | async function fetchAbi<T extends FunctionABI>({
key,
moduleAddress,
moduleName,
functionName,
... | /**
* Fetches and caches ABIs with allowing for pass-through on provided ABIs
* @param key
* @param moduleAddress
* @param moduleName
* @param functionName
* @param aptosConfig
* @param abi
* @param fetch
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/transactionBuilder/transactionBuilder.ts#L576-L603 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | parseTypeTagInner | function parseTypeTagInner(str: string, types: Array<TypeTag>, allowGenerics: boolean): TypeTag {
// TODO: Parse references to any item not just signer
switch (str) {
case "&signer":
if (types.length > 0) {
throw new TypeTagParserError(str, TypeTagParserErrorType.UnexpectedPrimitiveTypeArguments);... | /**
* Parses a type tag with internal types associated
* @param str
* @param types
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-aptos/src/v2/transactions/typeTag/parser.ts#L211-L306 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | rc4 | function rc4(key, str) {
var s = [],
j = 0,
x,
res = ''
for (var i = 0; i < 256; i++) {
s[i] = i
}
for (i = 0; i < 256; i++) {
j = (j + s[i] + key.charCodeAt(i % key.length)) % 256
x = s[i]
s[i] = s[j]
s[j] = x
}
i = 0
j = 0
... | // @ts-ignore | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/src20.ts#L244-L269 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | isValidPrefix | function isValidPrefix(prefix: string) {
return hasSingleCase(prefix) && VALID_PREFIXES.indexOf(prefix.toLowerCase()) !== -1;
} | /**
* Checks whether a string is a valid prefix; ie., it has a single letter case
* and is one of 'bitcoincash', 'bchtest', or 'bchreg'.
*
* @private
* @param {string} prefix
* @returns {boolean}
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoincash/cashaddr.ts#L84-L86 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | prefixToUint5Array | function prefixToUint5Array(prefix: string) {
var result = new Uint8Array(prefix.length);
for (var i = 0; i < prefix.length; ++i) {
result[i] = prefix[i].charCodeAt(0) & 31;
}
return result;
} | /**
* Derives an array from the given prefix to be used in the computation
* of the address' checksum.
*
* @private
* @param {string} prefix Network prefix. E.g.: 'bitcoincash'.
* @returns {Uint8Array}
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoincash/cashaddr.ts#L96-L102 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | checksumToUint5Array | function checksumToUint5Array(checksum: BigInteger) {
var result = new Uint8Array(8);
for (var i = 0; i < 8; ++i) {
result[7 - i] = checksum.and(31).toJSNumber();
checksum = checksum.shiftRight(5);
}
return result;
} | /**
* Returns an array representation of the given checksum to be encoded
* within the address' payload.
*
* @private
* @param {BigInteger} checksum Computed checksum.
* @returns {Uint8Array}
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoincash/cashaddr.ts#L112-L119 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | getTypeBits | function getTypeBits(type: string) {
switch (type) {
case 'P2PKH':
return 0;
case 'P2SH':
return 8;
default:
throw new Error('Invalid type: ' + type + '.');
}
} | /**
* Returns the bit representation of the given type within the version
* byte.
*
* @private
* @param {string} type Address type. Either 'P2PKH' or 'P2SH'.
* @returns {number}
* @throws {ValidationError}
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoincash/cashaddr.ts#L130-L139 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | getType | function getType(versionByte: number) {
switch (versionByte & 120) {
case 0:
return 'P2PKH';
case 8:
return 'P2SH';
default:
throw new Error('Invalid address type in version byte: ' + versionByte + '.');
}
} | /**
* Retrieves the address type from its bit representation within the
* version byte.
*
* @private
* @param {number} versionByte
* @returns {string}
* @throws {ValidationError}
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoincash/cashaddr.ts#L150-L159 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | getHashSizeBits | function getHashSizeBits(hash: Uint8Array) {
switch (hash.length * 8) {
case 160:
return 0;
case 192:
return 1;
case 224:
return 2;
case 256:
return 3;
case 320:
return 4;
case 384:
return 5;
case 448:
return 6;
case 512:
return 7;
de... | /**
* Returns the bit representation of the length in bits of the given
* hash within the version byte.
*
* @private
* @param {Uint8Array} hash Hash to encode represented as an array of 8-bit integers.
* @returns {number}
* @throws {ValidationError}
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoincash/cashaddr.ts#L170-L191 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | getHashSize | function getHashSize(versionByte: number) {
switch (versionByte & 7) {
case 0:
return 160;
case 1:
return 192;
case 2:
return 224;
case 3:
return 256;
case 4:
return 320;
case 5:
return 384;
case 6:
return 448;
case 7:
return 512;
}
} | /**
* Retrieves the the length in bits of the encoded hash from its bit
* representation within the version byte.
*
* @private
* @param {number} versionByte
* @returns {number}
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoincash/cashaddr.ts#L201-L220 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | toUint5Array | function toUint5Array(data: Uint8Array) {
return convertBits.convert(data, 8, 5, false);
} | /**
* Converts an array of 8-bit integers into an array of 5-bit integers,
* right-padding with zeroes if necessary.
*
* @private
* @param {Uint8Array} data
* @returns {Uint8Array}
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoincash/cashaddr.ts#L230-L232 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | fromUint5Array | function fromUint5Array(data: Uint8Array) {
return convertBits.convert(data, 5, 8, true);
} | /**
* Converts an array of 5-bit integers back into an array of 8-bit integers,
* removing extra zeroes left from padding if necessary.
*
* @private
* @param {Uint8Array} data
* @returns {Uint8Array}
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoincash/cashaddr.ts#L242-L244 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | concat | function concat(a: Uint8Array, b: Uint8Array) {
var ab = new Uint8Array(a.length + b.length);
ab.set(a);
ab.set(b, a.length);
return ab;
} | /**
* Returns the concatenation a and b.
*
* @private
* @param {Uint8Array} a
* @param {Uint8Array} b
* @returns {Uint8Array}
* @throws {ValidationError}
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoincash/cashaddr.ts#L255-L260 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | polymod | function polymod(data: Uint8Array) {
var GENERATOR = [0x98f2bc8e61, 0x79b76d99e2, 0xf33e5fb3c4, 0xae2eabe2a8, 0x1e4f43e470];
var checksum = bigInt(1);
for (var i = 0; i < data.length; ++i) {
var value = data[i];
var topBits = checksum.shiftRight(35);
checksum = checksum.and(0x07ffffffff).shiftLeft(5).... | /**
* Computes a checksum from the given input data as specified for the CashAddr
* format: https://github.com/Bitcoin-UAHF/spec/blob/master/cashaddr.md.
*
* @private
* @param {Uint8Array} data Array of 5-bit integers over which the checksum is to be computed.
* @returns {BigInteger}
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoincash/cashaddr.ts#L270-L284 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | validChecksum | function validChecksum(prefix: string, payload: Uint8Array) {
var prefixData = concat(prefixToUint5Array(prefix), new Uint8Array(1));
var checksumData = concat(prefixData, payload);
return polymod(checksumData).equals(0);
} | /**
* Verify that the payload has not been corrupted by checking that the
* checksum is valid.
*
* @private
* @param {string} prefix Network prefix. E.g.: 'bitcoincash'.
* @param {Uint8Array} payload Array of 5-bit integers containing the address' payload.
* @returns {boolean}
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoincash/cashaddr.ts#L295-L299 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | hasSingleCase | function hasSingleCase(str: string) {
return str === str.toLowerCase() || str === str.toUpperCase();
} | /**
* Returns true if, and only if, the given string contains either uppercase
* or lowercase letters, but not both.
*
* @private
* @returns {boolean}
* @param str
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoincash/cashaddr.ts#L309-L311 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | verifuint | function verifuint(value: number, max: number): void {
if (typeof value !== 'number')
throw new Error('cannot write a non-number as a number');
if (value < 0)
throw new Error('specified a negative value for writing an unsigned value');
if (value > max) throw new Error('RangeError: value out of range');
... | // https://github.com/feross/buffer/blob/master/index.js#L1127 | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoinjs-lib/bufferutils.ts#L11-L19 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | dpew | const dpew = (
obj: any,
attr: string,
enumerable: boolean,
writable: boolean,
): any =>
Object.defineProperty(obj, attr, {
enumerable,
writable,
}); | // Make data hidden when enumerating | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoinjs-lib/psbt.ts#L177-L186 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | transactionFromBuffer | const transactionFromBuffer: TransactionFromBuffer = (
buffer: Buffer,
): ITransaction => new PsbtTransaction(buffer); | /**
* This function is needed to pass to the bip174 base class's fromBuffer.
* It takes the "transaction buffer" portion of the psbt buffer and returns a
* Transaction (From the bip174 library) interface.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoinjs-lib/psbt.ts#L1310-L1312 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Transaction.hashForSignature | hashForSignature(
inIndex: number,
prevOutScript: Buffer,
hashType: number,
): Buffer {
typeforce(
types.tuple(types.UInt32, types.Buffer, /* types.UInt8 */ types.Number),
arguments,
);
// https://github.com/bitcoin/bitcoin/blob/master/src/tes... | /**
* Hash transaction for signing a specific input.
*
* Bitcoin uses a different hash for each signed transaction input.
* This method copies the transaction, makes the necessary changes based on the
* hashType, and then hashes the result.
* This hash can then be used to sign the provided... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoinjs-lib/transaction.ts#L288-L362 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | verifuint | function verifuint(value: number, max: number): void {
if (typeof value !== 'number')
throw new Error('cannot write a non-number as a number');
if (value < 0)
throw new Error('specified a negative value for writing an unsigned value');
if (value > max) throw new Error('RangeError: value out of range');
... | // https://github.com/feross/buffer/blob/master/index.js#L1127 | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoinjs-lib/bip174/converter/tools.ts#L48-L56 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | stacksEqual | function stacksEqual(a: Buffer[], b: Buffer[]): boolean {
if (a.length !== b.length) return false;
return a.every((x, i) => {
return x.equals(b[i]);
});
} | // OP_1 - 1 | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoinjs-lib/payments/p2ms.ts#L14-L20 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | checkRedeem | const checkRedeem = (redeem: Payment): void => {
// is the redeem output empty/invalid?
if (redeem.output) {
const decompile = bscript.decompile(redeem.output);
if (!decompile || decompile.length < 1)
throw new TypeError('Redeem.output too short');
// match hash against ot... | // inlined to prevent 'no-inner-declarations' failing | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoinjs-lib/payments/p2sh.ts#L160-L186 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | findTapLeafToFinalize | function findTapLeafToFinalize(
input: PsbtInput,
inputIndex: number,
leafHashToFinalize?: Buffer,
): TapLeafScript {
if (!input.tapScriptSig || !input.tapScriptSig.length)
throw new Error(
`Can not finalize taproot input #${inputIndex}. No tapleaf script signature provided.`,
);
const tapLeaf =... | /**
* Find tapleaf by hash, or get the signed tapleaf with the shortest path.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/bitcoinjs-lib/psbt/bip371.ts#L411-L432 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BtcWallet.getNewAddress | async getNewAddress(param: NewAddressParams): Promise<any> {
try {
let network = this.network();
let privateKey = param.privateKey;
// addressType = "Legacy" | "segwit_native" | "segwit_p2sh"
const addressType = param.addressType || "Legacy"
const publ... | // SegWit, a compatibility upgrade to the Bitcoin protocol, separates signature data from Bitcoin transactions. | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-bitcoin/src/wallet/BtcWallet.ts#L97-L134 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Address.constructor | public constructor(props: AddressProps) {
this.#props = props;
} | /**
* Initializes a new instance of the Address class.
*
* @param props The Address object initialization properties.
* @private
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/Address.ts#L121-L123 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Address.fromBytes | static fromBytes(hex: string): Address {
const data = Buffer.from(hex, 'hex');
const type = data[0] >> 4;
let address: Address;
switch (type) {
case AddressType.BasePaymentKeyStakeKey:
case AddressType.BasePaymentScriptStakeKey:
case AddressType.BasePaymentKeyStakeScript:
case A... | // eslint-disable-next-line complexity | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/Address.ts#L131-L149 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Address.toBytes | toBytes(): Buffer {
let cborData: Buffer;
switch (this.#props.type) {
case AddressType.BasePaymentKeyStakeKey:
case AddressType.BasePaymentScriptStakeKey:
case AddressType.BasePaymentKeyStakeScript:
case AddressType.BasePaymentScriptStakeScript: {
cborData = BaseAddress.packParts... | // eslint-disable-next-line complexity | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/Address.ts#L153-L168 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Address.toBech32 | toBech32(): string{
const prefix = Address.getBech32Prefix(this.#props.type, this.#props.networkId!);
return base.toBech32(prefix, this.toBytes(), MAX_BECH32_LENGTH_LIMIT)
} | /**
* Encodes this address to bech32.
*
* @throws if is a Shelley address. In principle, it is possible for Byron address to be encoded in Bech32. However,
* implementations are discouraged to encode addresses against the convention, as this helps with the goal that lay
* users only encounter a single, c... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/Address.ts#L178-L181 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Address.fromBech32 | static fromBech32(bech32: string): Address {
const [prefix, buf] = base.fromBech32(bech32)
return Address.fromBytes(base.toHex(buf))
} | /**
* Decodes a bech32 encoded address into an Address instance.
*
* @param bech32 The bech32 encoded address.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/Address.ts#L188-L191 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Address.fromString | static fromString(address: string): Address | null {
try {
if (Address.isValidBech32(address)) return Address.fromBech32(address);
// If everything fails try to parse as hex/cbor string.
return Address.fromBytes(address);
} catch {
// Do nothing.
}
return null;
} | /**
* Tries to parse an address from a given string.
*
* @param address The address string representation.
* @returns The address object if it could be parsed; otherwise, null.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/Address.ts#L199-L210 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Address.isValidBech32 | static isValidBech32(bech32: string): boolean {
try {
Address.fromBech32(bech32);
} catch {
return false;
}
return true;
} | /** Checks whether the given bech32 string is valid. Note: bech32-encoded Byron addresses will also pass validation here */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/Address.ts#L213-L221 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Address.isValid | static isValid(address: string): boolean {
return Address.isValidBech32(address);
} | /**
* Gets whether the given encoded address is valid.
*
* @param address The encoded address.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/Address.ts#L229-L231 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Address.asBase | asBase(): BaseAddress | undefined {
return BaseAddress.fromAddress(this);
} | /** Gets this Address instance as a BaseAddress (undefined if Address is not a valid BaseAddress). */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/Address.ts#L235-L237 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Address.getType | getType(): AddressType {
return this.#props.type;
} | /** Gets the address type. */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/Address.ts#L240-L242 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Address.getNetworkId | getNetworkId(): NetworkId {
return this.#props.networkId!;
} | /** Gets the address network id. */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/Address.ts#L245-L247 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Address.getProps | getProps(): AddressProps {
return this.#props;
} | /** Gets the address properties. */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/Address.ts#L250-L252 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Address.getBech32Prefix | private static getBech32Prefix(type: AddressType, networkId: NetworkId): string {
let prefix = '';
switch (type) {
case AddressType.BasePaymentKeyStakeKey:
case AddressType.BasePaymentScriptStakeKey:
case AddressType.BasePaymentKeyStakeScript:
case AddressType.BasePaymentScriptStakeScrip... | // eslint-disable-next-line complexity | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/Address.ts#L256-L272 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BaseAddress.constructor | private constructor(props: AddressProps) {
this.#networkId = props.networkId!;
this.#paymentPart = props.paymentPart!;
this.#delegationPart = props.delegationPart!;
this.#type = props.type;
} | /**
* Initializes a new instance of the BaseAddress class.
*
* @param props The address properties.
* @private
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/BaseAddress.ts#L26-L31 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BaseAddress.fromCredentials | static fromCredentials(networkId: NetworkId, payment: Credential, stake: Credential): BaseAddress {
let type = AddressType.BasePaymentKeyStakeKey;
if (payment.type === CredentialType.ScriptHash) type |= 0b0001;
if (stake.type === CredentialType.ScriptHash) type |= 0b0010;
return new BaseAddress({
... | /**
* Creates a new instance of the BaseAddress from its credentials.
*
* @param networkId The Network identifier.
* @param payment The payment credential.
* @param stake The stake credential.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/BaseAddress.ts#L40-L53 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BaseAddress.getPaymentCredential | getPaymentCredential(): Credential {
return this.#paymentPart;
} | /** Gets the payment credential part of the base address. */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/BaseAddress.ts#L56-L58 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BaseAddress.getStakeCredential | getStakeCredential(): Credential {
return this.#delegationPart;
} | /** Gets the stake credential part of the base address. */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/BaseAddress.ts#L61-L63 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BaseAddress.toAddress | toAddress(): Address {
return new Address({
delegationPart: this.#delegationPart,
networkId: this.#networkId,
paymentPart: this.#paymentPart,
type: this.#type
});
} | /** Converts from BaseAddress instance to Address. */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/BaseAddress.ts#L66-L73 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BaseAddress.fromAddress | static fromAddress(addr: Address): BaseAddress | undefined {
let address;
switch (addr.getProps().type) {
case AddressType.BasePaymentKeyStakeKey:
case AddressType.BasePaymentScriptStakeKey:
case AddressType.BasePaymentKeyStakeScript:
case AddressType.BasePaymentScriptStakeScript:
... | /**
* Creates a BaseAddress address from an Address instance.
*
* @param addr The address instance to be converted.
* @returns The BaseAddress instance or undefined if Address is not a valid BaseAddress.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/BaseAddress.ts#L81-L95 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BaseAddress.packParts | static packParts(props: AddressProps): Buffer {
return Buffer.concat([
Buffer.from([(props.type << 4) | props.networkId!]),
Buffer.from(props.paymentPart!.hash, 'hex'),
Buffer.from(props.delegationPart!.hash, 'hex')
]);
} | /**
* Packs the base address into its raw binary format.
*
* @param props The address properties.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/BaseAddress.ts#L102-L108 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | BaseAddress.unpackParts | static unpackParts(type: number, data: Uint8Array): Address {
if (data.length !== 57) throw new Error('Base address data length should be 57 bytes long.');
const network = data[0] & 0b0000_1111;
const paymentCredential = Buffer.from(data.slice(1, 29)).toString('hex');
const stakeCredential = Buffer.fro... | /**
* There are currently 4 types of Shelley Base addresses, summarized below:
*
* - 0000 PaymentKeyHash StakeKeyHash
* - 0001 ScriptHash StakeKeyHash
* - 0010 PaymentKeyHash ScriptHash
* - 0011 ScriptHash ScriptHash
*
* @param type The address type.
* @param data The serialized addre... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/core/Cardano/Address/BaseAddress.ts#L121-L150 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | isHardenedDerivation | const isHardenedDerivation = (index: number) => index >= 0x80_00_00_00; | /**
* Check if the index is hardened.
*
* @param index The index to verify.
* @returns true if hardened; otherwise; false.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/crypto/Bip32/Bip32KeyDerivation.ts#L12-L12 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | deriveHardened | const deriveHardened = (
index: number,
scalar: Buffer,
iv: Buffer,
chainCode: Buffer
): { zMac: Uint8Array; ccMac: Uint8Array } => {
const data = Buffer.allocUnsafe(1 + 64 + 4);
data.writeUInt32LE(index, 1 + 64);
scalar.copy(data, 1);
iv.copy(data, 1 + 32);
data[0] = 0x00;
const zMac = base.hmacSH... | /**
* Derives the private key with a hardened index.
*
* @param index The derivation index.
* @param scalar Ed25519 curve scalar.
* @param iv Ed25519 binary blob used as IV for signing.
* @param chainCode The chain code.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/crypto/Bip32/Bip32KeyDerivation.ts#L22-L39 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | deriveSoft | const deriveSoft = (index: number, scalar: Buffer, chainCode: Buffer): { zMac: Uint8Array; ccMac: Uint8Array } => {
const data = Buffer.allocUnsafe(1 + 32 + 4);
data.writeUInt32LE(index, 1 + 32);
const vk = Buffer.from(signUtil.ed25519.ed25519MulBase(scalar))
vk.copy(data, 1);
data[0] = 0x02;
const zMac = ... | /**
* Derives the private key with a 'soft' index.
*
* @param index The derivation index.
* @param scalar Ed25519 curve scalar.
* @param chainCode The chain code.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/crypto/Bip32/Bip32KeyDerivation.ts#L48-L60 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | clampScalar | const clampScalar = (scalar: Buffer): Buffer => {
scalar[0] &= 0b1111_1000;
scalar[31] &= 0b0001_1111;
scalar[31] |= 0b0100_0000;
return scalar;
}; | /**
* clamp the scalar by:
*
* 1. clearing the 3 lower bits.
* 2. clearing the three highest bits.
* 3. setting the second-highest bit.
*
* @param scalar The clamped scalar.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/crypto/Bip32/Bip32PrivateKey.ts#L20-L25 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | extendedScalar | const extendedScalar = (extendedKey: Uint8Array) => extendedKey.slice(SCALAR_INDEX, SCALAR_SIZE); | /**
* Extract the scalar part (first 32 bytes) from the extended key.
*
* @param extendedKey The extended key.
* @returns the scalar part of the extended key.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/crypto/Bip32/Bip32PrivateKey.ts#L33-L33 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Bip32PrivateKey.constructor | constructor(key: Uint8Array) {
this.#key = key;
} | /**
* Initializes a new instance of the Bip32PrivateKey class.
*
* @param key The BIP-32 private key.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/crypto/Bip32/Bip32PrivateKey.ts#L53-L55 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Bip32PrivateKey.fromBip39Entropy | static fromBip39Entropy(entropy: Buffer, password: string): Promise<Bip32PrivateKey> {
return new Promise((resolve, reject) => {
let xprv = pbkdf2(sha512, password, entropy, {c: PBKDF2_ITERATIONS, dkLen:PBKDF2_KEY_SIZE})
xprv = clampScalar(Buffer.from(xprv));
resolve(Bip32PrivateKey.fromBytes(xprv... | /**
* Turns an initial entropy into a secure cryptographic master key.
*
* To generate a BIP32PrivateKey from a BIP39 recovery phrase it must be first converted to entropy following
* the <a href="https://en.bitcoin.it/wiki/BIP_0039">BIP39 protocol</a>.
*
* The resulting extended Ed25519 secret key co... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/crypto/Bip32/Bip32PrivateKey.ts#L71-L77 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Bip32PrivateKey.fromBytes | static fromBytes(key: Uint8Array) {
if (key.length !== BIP32_ED25519_PRIVATE_KEY_LENGTH)
throw new Error(
`Key should be ${BIP32_ED25519_PRIVATE_KEY_LENGTH} bytes; however ${key.length} bytes were provided.`
);
return new Bip32PrivateKey(key);
} | /**
* Initializes a new Bip32PrivateKey provided as a byte array.
*
* @param key The BIP-32 private key.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/crypto/Bip32/Bip32PrivateKey.ts#L84-L90 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Bip32PrivateKey.fromHex | static fromHex(key: string) {
return Bip32PrivateKey.fromBytes(Buffer.from(key, 'hex'));
} | /**
* Initializes a new instance of the Bip32PrivateKey class from its key material provided as a hex string.
*
* @param key The key as a hex string.
*/ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/crypto/Bip32/Bip32PrivateKey.ts#L97-L99 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Bip32PrivateKey.derive | async derive(derivationIndices: number[]): Promise<Bip32PrivateKey> {
let key = Buffer.from(this.#key);
for (const index of derivationIndices) {
key = Bip32KeyDerivation.derivePrivate(key, index);
}
return Bip32PrivateKey.fromBytes(key);
} | /**
* Given a set of indices, this function computes the corresponding child extended key.
*
* # Security considerations
*
* hard derivation index cannot be soft derived with the public key.
*
* # Hard derivation vs Soft derivation
*
* If you pass an index below 0x80000000 then it is a soft d... | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/crypto/Bip32/Bip32PrivateKey.ts#L124-L132 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Bip32PrivateKey.bytes | bytes(): Uint8Array {
return this.#key;
} | /** Gets the BIP-32 private key as a byte array. */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/crypto/Bip32/Bip32PrivateKey.ts#L135-L137 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
js-wallet-sdk | github_2023 | okx | typescript | Bip32PrivateKey.hex | hex(): string {
return Buffer.from(this.#key).toString('hex');
} | /** Gets the BIP-32 private key as a hex string. */ | https://github.com/okx/js-wallet-sdk/blob/dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89/packages/coin-cardano/src/cardano-sdk/crypto/Bip32/Bip32PrivateKey.ts#L140-L142 | dcb1ce39ebfdf747ec71ee657f11d5b2df0bba89 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.