-
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
e03b9af
commit 62a08d6
Showing
67 changed files
with
13,116 additions
and
8,206 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,8 +1,76 @@ | ||
import { Contract } from './arc4' | ||
import { uint64 } from './primitives' | ||
import { ConstructorFor } from './typescript-helpers' | ||
|
||
export abstract class BaseContract { | ||
public abstract approvalProgram(): boolean | uint64 | ||
public clearStateProgram(): boolean | uint64 { | ||
return true | ||
} | ||
} | ||
|
||
type NumberRange = { from: number; to: number } | ||
|
||
/** | ||
* Options class to manually define the total amount of global and local state contract will use. | ||
* | ||
* This is not required when all state is assigned to `this.`, but is required if a | ||
* contract dynamically interacts with state via `AppGlobal.getBytes` etc, or if you want | ||
* to reserve additional state storage for future contract updates, since the Algorand protocol | ||
* doesn't allow increasing them after creation. | ||
*/ | ||
type StateTotals = { | ||
globalUints?: number | ||
globalBytes?: number | ||
localUints?: number | ||
localBytes?: number | ||
} | ||
|
||
type ContractOptions = { | ||
/** | ||
* Determines which AVM version to use, this affects what operations are supported. | ||
* Defaults to value provided supplied on command line (which defaults to current mainnet version) | ||
*/ | ||
avmVersion?: 10 | 11 | ||
|
||
/** | ||
* Override the name of the logic signature when generating build artifacts. | ||
* Defaults to the class name | ||
*/ | ||
name?: string | ||
/** | ||
* Allows you to mark a slot ID or range of slot IDs as "off limits" to Puya. | ||
* These slot ID(s) will never be written to or otherwise manipulating by the compiler itself. | ||
* This is particularly useful in combination with `op.gload_bytes` / `op.gload_uint64` | ||
* which lets a contract in a group transaction read from the scratch slots of another contract | ||
* that occurs earlier in the transaction group. | ||
* | ||
* In the case of inheritance, scratch slots reserved become cumulative. It is not an error | ||
* to have overlapping ranges or values either, so if a base class contract reserves slots | ||
* 0-5 inclusive and the derived contract reserves 5-10 inclusive, then within the derived | ||
* contract all slots 0-10 will be marked as reserved. | ||
*/ | ||
scratchSlots?: Array<number | NumberRange> | ||
/** | ||
* Allows defining what values should be used for global and local uint and bytes storage | ||
* values when creating a contract. Used when outputting ARC-32 application.json schemas. | ||
* | ||
* If let unspecified, the totals will be determined by the compiler based on state | ||
* variables assigned to `this`. | ||
* | ||
* This setting is not inherited, and only applies to the exact `Contract` it is specified | ||
* on. If a base class does specify this setting, and a derived class does not, a warning | ||
* will be emitted for the derived class. To resolve this warning, `state_totals` must be | ||
* specified. An empty object may be provided in order to indicate that this contract should | ||
* revert to the default behaviour | ||
*/ | ||
stateTotals?: StateTotals | ||
} | ||
|
||
/** | ||
* The contract decorator can be used to specify additional configuration options for a smart contract | ||
* @param options An object containing the configuration options | ||
*/ | ||
export function contract(options: ContractOptions) { | ||
return <TContract extends Contract>(contract: ConstructorFor<TContract>) => contract | ||
} |
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 |
---|---|---|
@@ -1,5 +1,30 @@ | ||
import { uint64 } from './primitives' | ||
import { ConstructorFor } from './typescript-helpers' | ||
|
||
export abstract class LogicSig { | ||
abstract program(): boolean | uint64 | ||
} | ||
|
||
/** | ||
* Defines optional configuration for a logic signature | ||
*/ | ||
type LogicSigOptions = { | ||
/** | ||
* Determines which AVM version to use, this affects what operations are supported. | ||
* Defaults to value provided supplied on command line (which defaults to current mainnet version) | ||
*/ | ||
avmVersion?: 10 | 11 | ||
/** | ||
* Override the name of the logic signature when generating build artifacts. | ||
* Defaults to the class name | ||
*/ | ||
name?: string | ||
} | ||
|
||
/** | ||
* The logicsig decorator can be used to specify additional configuration options for a logic signature | ||
* @param options An object containing the configuration options | ||
*/ | ||
export function logicsig(options: LogicSigOptions) { | ||
return <TLogicSig extends LogicSig>(logicSig: ConstructorFor<TLogicSig>) => logicSig | ||
} |
Oops, something went wrong.