-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0fda7b5
commit 757e8a4
Showing
92 changed files
with
19,976 additions
and
5,864 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import { BaseContract } from './base-contract' | ||
import { NoImplementation } from './impl/errors' | ||
import { LogicSig } from './logic-sig' | ||
import { bytes, uint64 } from './primitives' | ||
import { Account } from './reference' | ||
import { ConstructorFor, DeliberateAny } from './typescript-helpers' | ||
|
||
/** | ||
* Provides compiled programs and state allocation values for a Contract. Created by calling `compile(ExampleContractType)` | ||
*/ | ||
export type CompiledContract = { | ||
/** | ||
* Approval program pages for a contract, after template variables have been replaced and compiled to AVM bytecode | ||
*/ | ||
approvalProgram: [bytes, bytes] | ||
/** | ||
* Clear state program pages for a contract, after template variables have been replaced and compiled to AVM bytecode | ||
*/ | ||
clearStateProgram: [bytes, bytes] | ||
/** | ||
* By default, provides extra program pages required based on approval and clear state program size, can be overridden when calling `compile(ExampleContractType, { extraProgramPages: ... })` | ||
*/ | ||
extraProgramPages: uint64 | ||
/** | ||
* By default, provides global num uints based on contract state totals, can be overridden when calling `compile(ExampleContractType, { globalUints: ... })` | ||
*/ | ||
globalUints: uint64 | ||
/** | ||
* By default, provides global num bytes based on contract state totals, can be overridden when calling `compile(ExampleContractType, { globalBytes: ... })` | ||
*/ | ||
globalBytes: uint64 | ||
/** | ||
* By default, provides local num uints based on contract state totals, can be overridden when calling `compile(ExampleContractType, { localUints: ... })` | ||
*/ | ||
localUints: uint64 | ||
/** | ||
* By default, provides local num bytes based on contract state totals, can be overridden when calling `compile(ExampleContractType, { localBytes: ... })` | ||
*/ | ||
localBytes: uint64 | ||
} | ||
|
||
/** | ||
* Provides account for a Logic Signature. Created by calling `compile(LogicSigType)` | ||
*/ | ||
export type CompiledLogicSig = { | ||
/** | ||
* Address of a logic sig program, after template variables have been replaced and compiled to AVM bytecode | ||
*/ | ||
account: Account | ||
} | ||
|
||
/** | ||
* Options for compiling a contract | ||
*/ | ||
type CompileContractOptions = { | ||
/** | ||
* Number of extra program pages, defaults to minimum required for contract | ||
*/ | ||
extraProgramPages?: uint64 | ||
/** | ||
* Number of global uint64s, defaults to value defined for contract | ||
*/ | ||
globalUints?: uint64 | ||
/** | ||
* Number of global bytes, defaults to value defined for contract | ||
*/ | ||
globalBytes?: uint64 | ||
/** | ||
* Number of local uint64s, defaults to value defined for contract | ||
*/ | ||
localUints?: uint64 | ||
/** | ||
* Number of local bytes, defaults to value defined for contract | ||
*/ | ||
localBytes?: uint64 | ||
/** | ||
* Template variables to substitute into the contract, key should be without the prefix, must evaluate to a compile time constant | ||
* and match the type of the template var declaration | ||
*/ | ||
templateVars?: Record<string, DeliberateAny> | ||
/** | ||
* Prefix to add to provided template vars, defaults to the prefix supplied on command line (which defaults to TMPL_) | ||
*/ | ||
templateVarsPrefix?: string | ||
} | ||
|
||
/** | ||
* Options for compiling a logic signature | ||
*/ | ||
type CompileLogicSigOptions = { | ||
/** | ||
* Template variables to substitute into the contract, key should be without the prefix, must evaluate to a compile time constant | ||
* and match the type of the template var declaration | ||
*/ | ||
templateVars?: Record<string, DeliberateAny> | ||
/** | ||
* Prefix to add to provided template vars, defaults to the prefix supplied on command line (which defaults to TMPL_) | ||
*/ | ||
templateVarsPrefix?: string | ||
} | ||
|
||
/** | ||
* Compile a contract and return the resulting byte code for approval and clear state programs. | ||
* @param contract The contract class to compile | ||
* @param options Options for compiling the contract | ||
*/ | ||
export function compile(contract: ConstructorFor<BaseContract>, options?: CompileContractOptions): CompiledContract | ||
/** | ||
* Compile a logic signature and return an account ready for signing transactions. | ||
* @param logicSig The logic sig class to compile | ||
* @param options Options for compiling the logic sig | ||
*/ | ||
export function compile(logicSig: ConstructorFor<LogicSig>, options?: CompileLogicSigOptions): CompiledLogicSig | ||
export function compile(artefact: ConstructorFor<BaseContract> | ConstructorFor<LogicSig>): CompiledLogicSig | CompiledContract { | ||
throw new NoImplementation() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { NoImplementation } from './impl/errors' | ||
import { uint64, Uint64Compat } from './primitives' | ||
|
||
export class MutableArray<TItem> { | ||
constructor(...items: TItem[]) {} | ||
|
||
/** | ||
* Returns the current length of this array | ||
*/ | ||
get length(): uint64 { | ||
throw new NoImplementation() | ||
} | ||
|
||
/** | ||
* Returns the item at the given index. | ||
* Negative indexes are taken from the end. | ||
* @param index The index of the item to retrieve | ||
*/ | ||
at(index: Uint64Compat): TItem { | ||
throw new NoImplementation() | ||
} | ||
|
||
/** | ||
* Create a new Dynamic array with all items from this array | ||
*/ | ||
slice(): MutableArray<TItem> | ||
/** | ||
* Create a new MutableArray with all items up till `end`. | ||
* Negative indexes are taken from the end. | ||
* @param end An index in which to stop copying items. | ||
*/ | ||
slice(end: Uint64Compat): MutableArray<TItem> | ||
/** | ||
* Create a new MutableArray with items from `start`, up until `end` | ||
* Negative indexes are taken from the end. | ||
* @param start An index in which to start copying items. | ||
* @param end An index in which to stop copying items | ||
*/ | ||
slice(start: Uint64Compat, end: Uint64Compat): MutableArray<TItem> | ||
slice(start?: Uint64Compat, end?: Uint64Compat): MutableArray<TItem> { | ||
throw new NoImplementation() | ||
} | ||
|
||
/** | ||
* Returns an iterator for the items in this array | ||
*/ | ||
[Symbol.iterator](): IterableIterator<TItem> { | ||
throw new NoImplementation() | ||
} | ||
|
||
/** | ||
* Returns an iterator for a tuple of the indexes and items in this array | ||
*/ | ||
entries(): IterableIterator<readonly [uint64, TItem]> { | ||
throw new NoImplementation() | ||
} | ||
|
||
/** | ||
* Returns an iterator for the indexes in this array | ||
*/ | ||
keys(): IterableIterator<uint64> { | ||
throw new NoImplementation() | ||
} | ||
|
||
/** | ||
* Get or set the item at the specified index. | ||
* Negative indexes are not supported | ||
*/ | ||
[index: uint64]: TItem | ||
|
||
/** | ||
* Push a number of items into this array | ||
* @param items The items to be added to this array | ||
*/ | ||
push(...items: TItem[]): void { | ||
throw new NoImplementation() | ||
} | ||
|
||
/** | ||
* Pop a single item from this array | ||
*/ | ||
pop(): TItem { | ||
throw new NoImplementation() | ||
} | ||
|
||
copy(): MutableArray<TItem> { | ||
throw new NoImplementation() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { NoImplementation } from './impl/errors' | ||
|
||
export function TemplateVar<T>(variableName: string, prefix = 'TMPL_'): T { | ||
throw new Error('TODO') | ||
throw NoImplementation | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.