GitHubAppDocsPlayground
  • Preparing search index...
  • The search index is not available
CCC Docs
  • CCC Docs
  • @ckb-ccc core
  • index
  • ccc
  • mol
  • codec

Function codec

  • codec<Encodable, TypeLike, Decoded, Type, ConstructorType>(codec): ((Constructor: ConstructorType) => ConstructorType)
  • A class decorator to add methods implementation on the Entity.Base class

    Type Parameters

    • Encodable
    • TypeLike
    • Decoded
    • Type extends object
    • ConstructorType extends Constructor<Type> & {
          from(decoded: TypeLike): Type;
          byteLength?: number;
          encode(encodable: TypeLike): ccc.Bytes;
          decode(bytesLike: BytesLike): TypeLike;
          fromBytes(bytes: BytesLike): Type;
      }

    Parameters

    • codec: Codec<Encodable, Decoded>

    Returns ((Constructor: ConstructorType) => ConstructorType)

      • (Constructor): ConstructorType
      • Parameters

        • Constructor: ConstructorType

        Returns ConstructorType

    Example

    @mol.codec(
    mol.table({
    codeHash: mol.Byte32,
    hashType: HashTypeCodec,
    args: mol.Bytes,
    }),
    )
    export class Script extends mol.Entity.Base<ScriptLike, Script>() {
    from(scriptLike: ScriptLike): Script {}
    }
    • Defined in molecule/entity.ts:155

Settings

Member Visibility
GitHubAppDocsPlayground
CCC Docs
  • Loading...

Generated using TypeDoc