Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Farseen/011 more stuff #21

Merged
merged 4 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions conway-cddl/yaml/custom/bigint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ CSLBigInt:
return new CSLBigInt(res);
}

pow(other: CSLBigInt): CSLBigInt {
let res = this.toJsValue() ** other.toJsValue();
pow(other: number): CSLBigInt {
let res = this.toJsValue() ** BigInt(other);
return new CSLBigInt(res);
}

Expand Down
20 changes: 0 additions & 20 deletions conway-cddl/yaml/custom/pointer.yaml

This file was deleted.

26 changes: 1 addition & 25 deletions csl-types/cardano-data-lite.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export declare class CSLBigInt {
add(other: CSLBigInt): CSLBigInt;
sub(other: CSLBigInt): CSLBigInt;
mul(other: CSLBigInt): CSLBigInt;
pow(other: CSLBigInt): CSLBigInt;
pow(other: number): CSLBigInt;
div_floor(other: CSLBigInt): CSLBigInt;
div_ceil(other: CSLBigInt): CSLBigInt;
abs(): CSLBigInt;
Expand Down Expand Up @@ -1898,30 +1898,6 @@ export declare class PlutusScripts {
to_hex(): string;
clone(): PlutusScripts;
}
export declare class Pointer {
private _slot_bignum;
private _tx_index_bignum;
private _cert_index_bignum;
constructor(slot_bignum: BigNum, tx_index_bignum: BigNum, cert_index_bignum: BigNum);
static new(slot_bignum: BigNum, tx_index_bignum: BigNum, cert_index_bignum: BigNum): Pointer;
slot_bignum(): BigNum;
set_slot_bignum(slot_bignum: BigNum): void;
tx_index_bignum(): BigNum;
set_tx_index_bignum(tx_index_bignum: BigNum): void;
cert_index_bignum(): BigNum;
set_cert_index_bignum(cert_index_bignum: BigNum): void;
static deserialize(reader: CBORReader): Pointer;
serialize(writer: CBORWriter): void;
free(): void;
static from_bytes(data: Uint8Array): Pointer;
static from_hex(hex_str: string): Pointer;
to_bytes(): Uint8Array;
to_hex(): string;
clone(): Pointer;
slot(): number;
tx_index(): number;
cert_index(): number;
}
export declare class PoolMetadata {
private _url;
private _pool_metadata_hash;
Expand Down
114 changes: 2 additions & 112 deletions src/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1538,8 +1538,8 @@ export class CSLBigInt {
return new CSLBigInt(res);
}

pow(other: CSLBigInt): CSLBigInt {
let res = this.toJsValue() ** other.toJsValue();
pow(other: number): CSLBigInt {
let res = this.toJsValue() ** BigInt(other);
return new CSLBigInt(res);
}

Expand Down Expand Up @@ -8638,116 +8638,6 @@ export class PlutusScripts {
}
}

export class Pointer {
private _slot_bignum: BigNum;
private _tx_index_bignum: BigNum;
private _cert_index_bignum: BigNum;

constructor(
slot_bignum: BigNum,
tx_index_bignum: BigNum,
cert_index_bignum: BigNum,
) {
this._slot_bignum = slot_bignum;
this._tx_index_bignum = tx_index_bignum;
this._cert_index_bignum = cert_index_bignum;
}

static new(
slot_bignum: BigNum,
tx_index_bignum: BigNum,
cert_index_bignum: BigNum,
) {
return new Pointer(slot_bignum, tx_index_bignum, cert_index_bignum);
}

slot_bignum(): BigNum {
return this._slot_bignum;
}

set_slot_bignum(slot_bignum: BigNum): void {
this._slot_bignum = slot_bignum;
}

tx_index_bignum(): BigNum {
return this._tx_index_bignum;
}

set_tx_index_bignum(tx_index_bignum: BigNum): void {
this._tx_index_bignum = tx_index_bignum;
}

cert_index_bignum(): BigNum {
return this._cert_index_bignum;
}

set_cert_index_bignum(cert_index_bignum: BigNum): void {
this._cert_index_bignum = cert_index_bignum;
}

static deserialize(reader: CBORReader): Pointer {
let len = reader.readArrayTag();

if (len != null && len < 3) {
throw new Error(
"Insufficient number of fields in record. Expected 3. Received " + len,
);
}

let slot_bignum = BigNum.deserialize(reader);

let tx_index_bignum = BigNum.deserialize(reader);

let cert_index_bignum = BigNum.deserialize(reader);

return new Pointer(slot_bignum, tx_index_bignum, cert_index_bignum);
}

serialize(writer: CBORWriter): void {
writer.writeArrayTag(3);

this._slot_bignum.serialize(writer);
this._tx_index_bignum.serialize(writer);
this._cert_index_bignum.serialize(writer);
}

// no-op
free(): void {}

static from_bytes(data: Uint8Array): Pointer {
let reader = new CBORReader(data);
return Pointer.deserialize(reader);
}

static from_hex(hex_str: string): Pointer {
return Pointer.from_bytes(hexToBytes(hex_str));
}

to_bytes(): Uint8Array {
let writer = new CBORWriter();
this.serialize(writer);
return writer.getBytes();
}

to_hex(): string {
return bytesToHex(this.to_bytes());
}

clone(): Pointer {
return Pointer.from_bytes(this.to_bytes());
}

slot(): number {
return Number(this._slot_bignum);
}
tx_index(): number {
return Number(this._tx_index_bignum);
}
cert_index(): number {
return Number(this._cert_index_bignum);
}
}

export class PoolMetadata {
private _url: URL;
private _pool_metadata_hash: PoolMetadataHash;
Expand Down
2 changes: 1 addition & 1 deletion tests/api/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ describe("API coverage tests", () => {
})
})
describe("Compare each CDL class/method to its CSL counterpart", () => {
test.each(compareToCslTests)("($n) Comparing CDL's $class . $comparedToMethod.name to CSL's", (params) => {
test.each(compareToCslTests)("($n) Comparing CDL's $class​.$comparedToMethod.name to CSL's", (params) => {
compareToClass(cdlClassesMap, params.class, params.comparedToMethod);
})
});
Expand Down
12 changes: 11 additions & 1 deletion tests/class-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
"as_reg_cert",
"as_unreg_cert"
],
"PlutusScript": ["hash"]
"PlutusScript": [
"hash",
"new_v2",
"new_v3",
"new_with_version",
"from_bytes_v2",
"from_bytes_v3",
"from_bytes_with_version",
"from_hex_with_version",
"language_version"
]
}
}
Loading