@airgap/coinlib-core
Version:
The @airgap/coinlib-core is a protocol agnostic library to prepare, sign and broadcast cryptocurrency transactions.
380 lines (379 loc) • 16.6 kB
TypeScript
import Long from 'long';
import _m0 from 'protobufjs/minimal.js';
interface Any {
/**
* A URL/resource name that uniquely identifies the type of the serialized
* protocol buffer message. This string must contain at least
* one "/" character. The last segment of the URL's path must represent
* the fully qualified name of the type (as in
* `path/google.protobuf.Duration`). The name should be in a canonical form
* (e.g., leading "." is not accepted).
*
* In practice, teams usually precompile into the binary all types that they
* expect it to use in the context of Any. However, for URLs which use the
* scheme `http`, `https`, or no scheme, one can optionally set up a type
* server that maps type URLs to message definitions as follows:
*
* * If no scheme is provided, `https` is assumed.
* * An HTTP GET on the URL must yield a [google.protobuf.Type][]
* value in binary format, or produce an error.
* * Applications are allowed to cache lookup results based on the
* URL, or have them precompiled into a binary to avoid any
* lookup. Therefore, binary compatibility needs to be preserved
* on changes to types. (Use versioned type names to manage
* breaking changes.)
*
* Note: this functionality is not currently available in the official
* protobuf release, and it is not used for type URLs beginning with
* type.googleapis.com.
*
* Schemes other than `http`, `https` (or the empty scheme) might be
* used with implementation specific semantics.
*/
typeUrl: string;
/** Must be a valid serialized protocol buffer of the above specified type. */
value: Uint8Array;
}
interface ModeInfo_Single {
/** mode is the signing mode of the single signer */
mode: number;
}
interface ModeInfo {
/** single represents a single signer */
single?: ModeInfo_Single | undefined;
}
interface Coin {
denom: string;
amount: string;
}
export interface EncodeObject {
readonly typeUrl: string;
readonly value: any;
}
interface StdFee {
readonly amount: readonly Coin[];
readonly gas: string;
}
interface Pubkey {
readonly type: string;
readonly value: any;
}
interface StdSignature {
readonly pub_key: Pubkey;
readonly signature: string;
}
interface Fee {
/** amount is the amount of coins to be paid as a fee */
amount: Coin[];
/**
* gas_limit is the maximum gas that can be used in transaction processing
* before an out of gas error occurs
*/
gasLimit: Long;
/**
* if unset, the first signer is responsible for paying the fees. If set, the specified account must pay the fees.
* the payer must be a tx signer (and thus have signed this field in AuthInfo).
* setting this field does *not* change the ordering of required signers for the transaction.
*/
payer: string;
/**
* if set, the fee payer (either the first signer or the value of the payer field) requests that a fee grant be used
* to pay fees instead of the fee payer's own balance. If an appropriate fee grant does not exist or the chain does
* not support fee grants, this will fail
*/
granter: string;
}
interface SignerInfo {
/**
* public_key is the public key of the signer. It is optional for accounts
* that already exist in state. If unset, the verifier can use the required \
* signer address for this position and lookup the public key.
*/
publicKey?: Any;
/**
* mode_info describes the signing mode of the signer and is a nested
* structure to support nested multisig pubKey's
*/
modeInfo?: ModeInfo;
/**
* sequence is the sequence of the account, which describes the
* number of committed transactions signed by a given address. It is used to
* prevent replay attacks.
*/
sequence: Long;
}
declare const ModeInfo_Single: {
encode(message: ModeInfo_Single, writer?: _m0.Writer): _m0.Writer;
decode(input: _m0.Reader | Uint8Array, length?: number): ModeInfo_Single;
fromJSON(object: any): ModeInfo_Single;
toJSON(message: ModeInfo_Single): unknown;
fromPartial<I extends {
mode?: number | undefined;
} & {
mode?: number | undefined;
} & Record<Exclude<keyof I, "mode">, never>>(object: I): ModeInfo_Single;
};
declare const ModeInfo: {
encode(message: ModeInfo, writer?: _m0.Writer): _m0.Writer;
decode(input: _m0.Reader | Uint8Array, length?: number): ModeInfo;
fromJSON(object: any): ModeInfo;
toJSON(message: ModeInfo): unknown;
fromPartial<I extends {
single?: {
mode?: number | undefined;
} | undefined;
} & {
single?: ({
mode?: number | undefined;
} & {
mode?: number | undefined;
} & Record<Exclude<keyof I["single"], "mode">, never>) | undefined;
} & Record<Exclude<keyof I, "single">, never>>(object: I): ModeInfo;
};
declare const SignerInfo: {
encode(message: SignerInfo, writer?: _m0.Writer): _m0.Writer;
decode(input: _m0.Reader | Uint8Array, length?: number): SignerInfo;
fromJSON(object: any): SignerInfo;
toJSON(message: SignerInfo): unknown;
fromPartial<I extends {
publicKey?: {
typeUrl?: string | undefined;
value?: Uint8Array | undefined;
} | undefined;
modeInfo?: {
single?: {
mode?: number | undefined;
} | undefined;
} | undefined;
sequence?: string | number | Long | undefined;
} & {
publicKey?: ({
typeUrl?: string | undefined;
value?: Uint8Array | undefined;
} & {
typeUrl?: string | undefined;
value?: Uint8Array | undefined;
} & Record<Exclude<keyof I["publicKey"], keyof Any>, never>) | undefined;
modeInfo?: ({
single?: {
mode?: number | undefined;
} | undefined;
} & {
single?: ({
mode?: number | undefined;
} & {
mode?: number | undefined;
} & Record<Exclude<keyof I["modeInfo"]["single"], "mode">, never>) | undefined;
} & Record<Exclude<keyof I["modeInfo"], "single">, never>) | undefined;
sequence?: string | number | (Long & {
high: number;
low: number;
unsigned: boolean;
add: (addend: string | number | Long) => Long;
and: (other: string | number | Long) => Long;
compare: (other: string | number | Long) => number;
comp: (other: string | number | Long) => number;
divide: (divisor: string | number | Long) => Long;
div: (divisor: string | number | Long) => Long;
equals: (other: string | number | Long) => boolean;
eq: (other: string | number | Long) => boolean;
getHighBits: () => number;
getHighBitsUnsigned: () => number;
getLowBits: () => number;
getLowBitsUnsigned: () => number;
getNumBitsAbs: () => number;
greaterThan: (other: string | number | Long) => boolean;
gt: (other: string | number | Long) => boolean;
greaterThanOrEqual: (other: string | number | Long) => boolean;
gte: (other: string | number | Long) => boolean;
ge: (other: string | number | Long) => boolean;
isEven: () => boolean;
isNegative: () => boolean;
isOdd: () => boolean;
isPositive: () => boolean;
isZero: () => boolean;
eqz: () => boolean;
lessThan: (other: string | number | Long) => boolean;
lt: (other: string | number | Long) => boolean;
lessThanOrEqual: (other: string | number | Long) => boolean;
lte: (other: string | number | Long) => boolean;
le: (other: string | number | Long) => boolean;
modulo: (other: string | number | Long) => Long;
mod: (other: string | number | Long) => Long;
rem: (other: string | number | Long) => Long;
multiply: (multiplier: string | number | Long) => Long;
mul: (multiplier: string | number | Long) => Long;
negate: () => Long;
neg: () => Long;
not: () => Long;
countLeadingZeros: () => number;
clz: () => number;
countTrailingZeros: () => number;
ctz: () => number;
notEquals: (other: string | number | Long) => boolean;
neq: (other: string | number | Long) => boolean;
ne: (other: string | number | Long) => boolean;
or: (other: string | number | Long) => Long;
shiftLeft: (numBits: number | Long) => Long;
shl: (numBits: number | Long) => Long;
shiftRight: (numBits: number | Long) => Long;
shr: (numBits: number | Long) => Long;
shiftRightUnsigned: (numBits: number | Long) => Long;
shru: (numBits: number | Long) => Long;
shr_u: (numBits: number | Long) => Long;
rotateLeft: (numBits: number | Long) => Long;
rotl: (numBits: number | Long) => Long;
rotateRight: (numBits: number | Long) => Long;
rotr: (numBits: number | Long) => Long;
subtract: (subtrahend: string | number | Long) => Long;
sub: (subtrahend: string | number | Long) => Long;
toInt: () => number;
toNumber: () => number;
toBytes: (le?: boolean | undefined) => number[];
toBytesLE: () => number[];
toBytesBE: () => number[];
toSigned: () => Long;
toString: (radix?: number | undefined) => string;
toUnsigned: () => Long;
xor: (other: string | number | Long) => Long;
} & Record<Exclude<keyof I["sequence"], keyof Long>, never>) | undefined;
} & Record<Exclude<keyof I, keyof SignerInfo>, never>>(object: I): SignerInfo;
};
declare const Coin: {
encode(message: Coin, writer?: _m0.Writer): _m0.Writer;
decode(input: _m0.Reader | Uint8Array, length?: number): Coin;
fromJSON(object: any): Coin;
toJSON(message: Coin): unknown;
fromPartial<I extends {
denom?: string | undefined;
amount?: string | undefined;
} & {
denom?: string | undefined;
amount?: string | undefined;
} & Record<Exclude<keyof I, keyof Coin>, never>>(object: I): Coin;
};
declare const Fee: {
encode(message: Fee, writer?: _m0.Writer): _m0.Writer;
decode(input: _m0.Reader | Uint8Array, length?: number): Fee;
fromJSON(object: any): Fee;
toJSON(message: Fee): unknown;
fromPartial<I extends {
amount?: {
denom?: string | undefined;
amount?: string | undefined;
}[] | undefined;
gasLimit?: string | number | Long | undefined;
payer?: string | undefined;
granter?: string | undefined;
} & {
amount?: ({
denom?: string | undefined;
amount?: string | undefined;
}[] & ({
denom?: string | undefined;
amount?: string | undefined;
} & {
denom?: string | undefined;
amount?: string | undefined;
} & Record<Exclude<keyof I["amount"][number], keyof Coin>, never>)[] & Record<Exclude<keyof I["amount"], keyof {
denom?: string | undefined;
amount?: string | undefined;
}[]>, never>) | undefined;
gasLimit?: string | number | (Long & {
high: number;
low: number;
unsigned: boolean;
add: (addend: string | number | Long) => Long;
and: (other: string | number | Long) => Long;
compare: (other: string | number | Long) => number;
comp: (other: string | number | Long) => number;
divide: (divisor: string | number | Long) => Long;
div: (divisor: string | number | Long) => Long;
equals: (other: string | number | Long) => boolean;
eq: (other: string | number | Long) => boolean;
getHighBits: () => number;
getHighBitsUnsigned: () => number;
getLowBits: () => number;
getLowBitsUnsigned: () => number;
getNumBitsAbs: () => number;
greaterThan: (other: string | number | Long) => boolean;
gt: (other: string | number | Long) => boolean;
greaterThanOrEqual: (other: string | number | Long) => boolean;
gte: (other: string | number | Long) => boolean;
ge: (other: string | number | Long) => boolean;
isEven: () => boolean;
isNegative: () => boolean;
isOdd: () => boolean;
isPositive: () => boolean;
isZero: () => boolean;
eqz: () => boolean;
lessThan: (other: string | number | Long) => boolean;
lt: (other: string | number | Long) => boolean;
lessThanOrEqual: (other: string | number | Long) => boolean;
lte: (other: string | number | Long) => boolean;
le: (other: string | number | Long) => boolean;
modulo: (other: string | number | Long) => Long;
mod: (other: string | number | Long) => Long;
rem: (other: string | number | Long) => Long;
multiply: (multiplier: string | number | Long) => Long;
mul: (multiplier: string | number | Long) => Long;
negate: () => Long;
neg: () => Long;
not: () => Long;
countLeadingZeros: () => number;
clz: () => number;
countTrailingZeros: () => number;
ctz: () => number;
notEquals: (other: string | number | Long) => boolean;
neq: (other: string | number | Long) => boolean;
ne: (other: string | number | Long) => boolean;
or: (other: string | number | Long) => Long;
shiftLeft: (numBits: number | Long) => Long;
shl: (numBits: number | Long) => Long;
shiftRight: (numBits: number | Long) => Long;
shr: (numBits: number | Long) => Long;
shiftRightUnsigned: (numBits: number | Long) => Long;
shru: (numBits: number | Long) => Long;
shr_u: (numBits: number | Long) => Long;
rotateLeft: (numBits: number | Long) => Long;
rotl: (numBits: number | Long) => Long;
rotateRight: (numBits: number | Long) => Long;
rotr: (numBits: number | Long) => Long;
subtract: (subtrahend: string | number | Long) => Long;
sub: (subtrahend: string | number | Long) => Long;
toInt: () => number;
toNumber: () => number;
toBytes: (le?: boolean | undefined) => number[];
toBytesLE: () => number[];
toBytesBE: () => number[];
toSigned: () => Long;
toString: (radix?: number | undefined) => string;
toUnsigned: () => Long;
xor: (other: string | number | Long) => Long;
} & Record<Exclude<keyof I["gasLimit"], keyof Long>, never>) | undefined;
payer?: string | undefined;
granter?: string | undefined;
} & Record<Exclude<keyof I, keyof Fee>, never>>(object: I): Fee;
};
declare const Any: {
encode(message: Any, writer?: _m0.Writer): _m0.Writer;
decode(input: _m0.Reader | Uint8Array, length?: number): Any;
fromJSON(object: any): Any;
toJSON(message: Any): unknown;
fromPartial<I extends {
typeUrl?: string | undefined;
value?: Uint8Array | undefined;
} & {
typeUrl?: string | undefined;
value?: Uint8Array | undefined;
} & Record<Exclude<keyof I, keyof Any>, never>>(object: I): Any;
};
export declare const prepareSignBytes: (txBodyEncodeObject: EncodeObject, fee: StdFee, pubKey: Uint8Array, sequence: number, chainId: string, accountNumber: number) => Promise<Uint8Array>;
export declare const encodeTxBytes: (txBodyEncodeObject: EncodeObject, fee: StdFee, pubKey: Uint8Array, sequence: number, signature: StdSignature, chainId: string, accountNumber: number) => Promise<Uint8Array>;
export declare const decodeTxBytes: (bytes: Uint8Array) => Promise<{
messages: EncodeObject[];
memo: string;
fee: Fee | undefined;
signerInfos: SignerInfo[];
}>;
export {};