-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import { Builder } from "../boc/Builder" | ||
Check failure on line 1 in generated.ts GitHub Actions / build (14.x)
Check failure on line 1 in generated.ts GitHub Actions / build (16.x)
Check failure on line 1 in generated.ts GitHub Actions / build (18.x)
|
||
import { Slice } from "../boc/Slice" | ||
Check failure on line 2 in generated.ts GitHub Actions / build (14.x)
Check failure on line 2 in generated.ts GitHub Actions / build (16.x)
Check failure on line 2 in generated.ts GitHub Actions / build (18.x)
|
||
export type X = { | ||
a: number; | ||
b: number; | ||
}; | ||
export function loadX(slice: Slice): X { | ||
return { | ||
a: slice.loadUint(32), | ||
b: slice.loadUint(32) | ||
}; | ||
} | ||
export function storeX(x: X): Builder { | ||
return (builder: Builder) => { | ||
builder.storeUint(x.a, 32); | ||
builder.storeUint(x.b, 32); | ||
}; | ||
} | ||
export type Bool = Bool_bool_false | Bool_bool_true; | ||
export type Bool_bool_false = { | ||
a: number; | ||
b: number; | ||
c: number; | ||
}; | ||
export type Bool_bool_true = { | ||
b: number; | ||
}; | ||
export function loadBool(slice: Slice): Bool { | ||
Check failure on line 28 in generated.ts GitHub Actions / build (14.x)
Check failure on line 28 in generated.ts GitHub Actions / build (16.x)
Check failure on line 28 in generated.ts GitHub Actions / build (18.x)
|
||
if (slice.preloadUint(1) == 0b0) { | ||
return { | ||
a: slice.loadUint(32), | ||
b: slice.loadUint(7), | ||
c: slice.loadUint(32) | ||
}; | ||
}; | ||
if (slice.preloadUint(1) == 0b1) { | ||
return { | ||
b: slice.loadUint(32) | ||
}; | ||
}; | ||
} | ||
export function storeBool(bool: Bool): Builder { | ||
if (bool instanceof Bool_bool_false) { | ||
Check failure on line 43 in generated.ts GitHub Actions / build (14.x)
Check failure on line 43 in generated.ts GitHub Actions / build (16.x)
Check failure on line 43 in generated.ts GitHub Actions / build (18.x)
|
||
return (builder: Builder) => { | ||
builder.storeUint(bool.a, 32); | ||
Check failure on line 45 in generated.ts GitHub Actions / build (14.x)
Check failure on line 45 in generated.ts GitHub Actions / build (16.x)
Check failure on line 45 in generated.ts GitHub Actions / build (18.x)
|
||
builder.storeUint(bool.b, 7); | ||
builder.storeUint(bool.c, 32); | ||
Check failure on line 47 in generated.ts GitHub Actions / build (14.x)
Check failure on line 47 in generated.ts GitHub Actions / build (16.x)
Check failure on line 47 in generated.ts GitHub Actions / build (18.x)
|
||
}; | ||
}; | ||
if (bool instanceof Bool_bool_true) { | ||
Check failure on line 50 in generated.ts GitHub Actions / build (14.x)
Check failure on line 50 in generated.ts GitHub Actions / build (16.x)
Check failure on line 50 in generated.ts GitHub Actions / build (18.x)
|
||
return (builder: Builder) => { | ||
builder.storeUint(bool.b, 32); | ||
}; | ||
}; | ||
} | ||
export type Y = { | ||
y: number; | ||
}; | ||
export function loadY(slice: Slice): Y { | ||
return { | ||
y: slice.loadUint(5) | ||
}; | ||
} | ||
export function storeY(y: Y): Builder { | ||
return (builder: Builder) => { | ||
builder.storeUint(y.y, 5); | ||
}; | ||
} | ||
export type C = { | ||
y: Y; | ||
c: number; | ||
}; | ||
export function loadC(slice: Slice): C { | ||
return { | ||
y: loadY(slice), | ||
c: slice.loadUint(32) | ||
}; | ||
} | ||
export function storeC(c: C): Builder { | ||
return (builder: Builder) => { | ||
storeY(c.y)(builder); | ||
builder.storeUint(c.c, 32); | ||
}; | ||
} | ||
export type D = { | ||
y: Y; | ||
c: number; | ||
}; | ||
export function loadD(slice: Slice): D { | ||
return { | ||
y: loadY(slice), | ||
c: slice.loadUint(32) | ||
}; | ||
} | ||
export function storeD(d: D): Builder { | ||
return (builder: Builder) => { | ||
storeY(d.y)(builder); | ||
builder.storeUint(d.c, 32); | ||
}; | ||
} | ||
export type Maybe<TheType> = { | ||
value: TheType; | ||
}; | ||
export function loadMaybe<TheType>(slice: Slice, loadTheType: (slice: Slice) => TheType): Maybe<TheType> { | ||
return { | ||
value: loadTheType(slice) | ||
}; | ||
} | ||
export function storeMaybe<TheType>(maybe: Maybe<TheType>, storeTheType: (theType: TheType) => (builder: Builder) => void): Builder { | ||
return (builder: Builder) => { | ||
storeTheType(maybe.value)(builder); | ||
}; | ||
} | ||
export type TheJust = { | ||
x: Maybe; | ||
Check failure on line 115 in generated.ts GitHub Actions / build (14.x)
Check failure on line 115 in generated.ts GitHub Actions / build (16.x)
Check failure on line 115 in generated.ts GitHub Actions / build (18.x)
|
||
}; | ||
export function loadTheJust(slice: Slice): TheJust { | ||
return { | ||
x: loadMaybe(slice) | ||
Check failure on line 119 in generated.ts GitHub Actions / build (14.x)
Check failure on line 119 in generated.ts GitHub Actions / build (16.x)
Check failure on line 119 in generated.ts GitHub Actions / build (18.x)
|
||
}; | ||
} | ||
export function storeTheJust(theJust: TheJust): Builder { | ||
return (builder: Builder) => { | ||
storeMaybe(theJust.x)(builder); | ||
Check failure on line 124 in generated.ts GitHub Actions / build (14.x)
Check failure on line 124 in generated.ts GitHub Actions / build (16.x)
Check failure on line 124 in generated.ts GitHub Actions / build (18.x)
|
||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
export type Maybe<TheType> = { | ||
value: TheType; | ||
}; | ||
|
||
export function loadMaybe<TheType>(slice: Slice, loadTheType: (slice: Slice) => TheType): Maybe<TheType> { | ||
return { | ||
value: loadTheType(slice) | ||
}; | ||
} | ||
|
||
export function storeMaybe<TheType>(maybe: Maybe<TheType>, storeSubType: (TheType: TheType) => ((builder: Builder) => void)): Builder { | ||
return (builder: Builder) => { | ||
storeSubType(maybe.value)(builder); | ||
}; | ||
} | ||
|
||
export type TheJust = { | ||
x: Maybe<number> | ||
}; | ||
|
||
function loadTheNumber(slice: Slice): number { | ||
return slice.loadUint(32); | ||
} | ||
|
||
function storeTheNumber(n: number): ((builder: Builder) => void) { | ||
return (builder: Builder) => { | ||
builder.storeUint(n, 32); | ||
} | ||
} | ||
|
||
export function loadTheJust(slice: Slice): TheJust { | ||
return { | ||
x: loadMaybe<number>(slice, loadTheNumber) | ||
}; | ||
} | ||
export function storeTheJust(theJust: TheJust): Builder { | ||
return (builder: Builder) => { | ||
storeMaybe<number>(theJust.x, storeTheNumber)(builder); | ||
}; | ||
} |