as-contract-runtime
Advanced tools
Comparing version 0.0.1 to 0.1.0
@@ -1,18 +0,45 @@ | ||
/** | ||
* All Rights Reserved by Patract Labs. | ||
* @author liangqin.fan@gmail.com | ||
*/ | ||
type Ptr = ArrayBuffer; | ||
type SizeT = u32; | ||
type ReturnCode = u32; | ||
// tslint:disable-next-line:no-namespace | ||
// export declare declare namespace env { | ||
/// Every error that can be returned to a contract when it calls any of the host functions. | ||
/// | ||
/// # Note | ||
/// | ||
/// This enum can be extended in the future: New codes can be added but existing codes | ||
/// will not be changed or removed. This means that any contract **must not** exhaustively | ||
/// match return codes. Instead, contracts should prepare for unknown variants and deal with | ||
/// those errors gracefuly in order to be forward compatible. | ||
enum ReturnCode { | ||
/// API call successful. | ||
Success = 0, | ||
/// The called function trapped and has its state changes reverted. | ||
/// In this case no output buffer is returned. | ||
CalleeTrapped = 1, | ||
/// The called function ran to completion but decided to revert its state. | ||
/// An output buffer is returned when one was supplied. | ||
CalleeReverted = 2, | ||
/// The passed key does not exist in storage. | ||
KeyNotFound = 3, | ||
/// Transfer failed because it would have brought the sender's total balance below the | ||
/// subsistence threshold. | ||
BelowSubsistenceThreshold = 4, | ||
/// Transfer failed for other reasons. Most probably reserved or locked balance of the | ||
/// sender prevents the transfer. | ||
TransferFailed = 5, | ||
/// The newly created contract is below the subsistence threshold after executing | ||
/// its constructor. | ||
NewContractNotFunded = 6, | ||
/// No code could be found at the supplied code hash. | ||
CodeNotFound = 7, | ||
/// The contract that was called is either no contract at all (a plain account) | ||
/// or is a tombstone. | ||
NotCallable = 8, | ||
} | ||
// Set the value specified by the given key in the storage. | ||
export declare function seal_set_storage( | ||
keyPtr: Ptr, | ||
valuePtr: Ptr, | ||
valueSize: SizeT | ||
): void; | ||
keyPtr: Ptr, | ||
valuePtr: Ptr, | ||
valueSize: SizeT | ||
): void; | ||
@@ -24,14 +51,14 @@ // Clear the value under the given key in the storage. | ||
export declare function seal_get_storage( | ||
keyPtr: Ptr, | ||
outPtr: Ptr, | ||
outSizePtr: Ptr | ||
): ReturnCode; | ||
keyPtr: Ptr, | ||
outPtr: Ptr, | ||
outSizePtr: Ptr | ||
): ReturnCode; | ||
// Transfer some value to another account. | ||
export declare function seal_transfer( | ||
accountPtr: Ptr, | ||
accountSize: SizeT, | ||
valuePtr: Ptr, | ||
valueSize: SizeT | ||
): ReturnCode; | ||
accountPtr: Ptr, | ||
accountSize: SizeT, | ||
valuePtr: Ptr, | ||
valueSize: SizeT | ||
): ReturnCode; | ||
@@ -70,12 +97,12 @@ // Make a call to another contract. | ||
export declare function seal_call( | ||
calleePtr: Ptr, | ||
calleeSize: SizeT, | ||
gas: u64, | ||
valuePtr: Ptr, | ||
valueSize: SizeT, | ||
inputDataPtr: Ptr, | ||
inputDataSize: SizeT, | ||
outputPtr: Ptr, | ||
outputLenPtr: Ptr | ||
): ReturnCode; | ||
calleePtr: Ptr, | ||
calleeSize: SizeT, | ||
gas: u64, | ||
valuePtr: Ptr, | ||
valueSize: SizeT, | ||
inputDataPtr: Ptr, | ||
inputDataSize: SizeT, | ||
outputPtr: Ptr, | ||
outputLenPtr: Ptr | ||
): ReturnCode; | ||
@@ -128,14 +155,14 @@ // Instantiate a contract with the specified code hash. | ||
export declare function seal_instantiate( | ||
codeHashPtr: Ptr, | ||
codeHashSize: SizeT, | ||
gas: u64, | ||
valuePtr: Ptr, | ||
valueSize: SizeT, | ||
inputDataPtr: Ptr, | ||
inputDataSize: SizeT, | ||
addressPtr: Ptr, | ||
addressLenPtr: Ptr, | ||
outputPtr: Ptr, | ||
outputLenPtr: Ptr | ||
): ReturnCode; | ||
codeHashPtr: Ptr, | ||
codeHashSize: SizeT, | ||
gas: u64, | ||
valuePtr: Ptr, | ||
valueSize: SizeT, | ||
inputDataPtr: Ptr, | ||
inputDataSize: SizeT, | ||
addressPtr: Ptr, | ||
addressLenPtr: Ptr, | ||
outputPtr: Ptr, | ||
outputLenPtr: Ptr | ||
): ReturnCode; | ||
@@ -156,5 +183,5 @@ // Remove the calling account and transfer remaining balance. | ||
export declare function seal_terminate( | ||
beneficiaryPtr: Ptr, | ||
beneficiarySize: SizeT | ||
): void; | ||
beneficiaryPtr: Ptr, | ||
beneficiarySize: SizeT | ||
): void; | ||
@@ -166,5 +193,5 @@ // Read message's input from host. | ||
// | ||
// This export declare function never retuns as it stops execution of the caller. | ||
// This function never returns as it stops execution of the caller. | ||
// This is the only way to return a data buffer to the caller. Returning from | ||
// execution without calling this export declare function is equivalent to calling: | ||
// execution without calling this function is equivalent to calling: | ||
// ``` | ||
@@ -183,5 +210,6 @@ // seal_return(0, 0, 0); | ||
export declare function seal_return( | ||
flags: u32, | ||
dataPtr: Ptr, | ||
dataSize: SizeT): void; | ||
flags: u32, | ||
dataPtr: Ptr, | ||
dataSize: SizeT | ||
): void; | ||
@@ -222,5 +250,6 @@ // Stores the address of the caller into the supplied buffer. | ||
export declare function seal_weight_to_fee( | ||
gas: u64, | ||
outPtr: Ptr, | ||
outLenPtr: Ptr): void; | ||
gas: u64, | ||
outPtr: Ptr, | ||
outLenPtr: Ptr | ||
): void; | ||
// Stores the amount of gas left into the supplied buffer. | ||
@@ -234,5 +263,3 @@ // | ||
// The data is encoded as Gas. | ||
export declare function seal_gas_left( | ||
outPtr: Ptr, | ||
outLenPtr: Ptr): void; | ||
export declare function seal_gas_left(outPtr: Ptr, outLenPtr: Ptr): void; | ||
@@ -247,5 +274,3 @@ // Stores the balance of the current account into the supplied buffer. | ||
// The data is encoded as T::Balance. | ||
export declare function seal_balance( | ||
outPtr: Ptr, | ||
outLenPtr: Ptr): void; | ||
export declare function seal_balance(outPtr: Ptr, outLenPtr: Ptr): void; | ||
@@ -261,4 +286,5 @@ // Stores the value transferred along with this call or as endowment into the supplied buffer. | ||
export declare function seal_value_transferred( | ||
outPtr: Ptr, | ||
outLenPtr: Ptr): void; | ||
outPtr: Ptr, | ||
outLenPtr: Ptr | ||
): void; | ||
@@ -274,6 +300,7 @@ // Stores a random number for the current block and the given subject into the supplied buffer. | ||
export declare function seal_random( | ||
subjectPtr: Ptr, | ||
subjectSize: SizeT, | ||
outPtr: Ptr, | ||
outLenPtr: Ptr): void; | ||
subjectPtr: Ptr, | ||
subjectSize: SizeT, | ||
outPtr: Ptr, | ||
outLenPtr: Ptr | ||
): void; | ||
@@ -286,5 +313,3 @@ // Load the latest block timestamp into the supplied buffer | ||
// space at `outPtr` is less than the size of the value a trap is triggered. | ||
export declare function seal_now( | ||
outPtr: Ptr, | ||
outLenPtr: Ptr): void; | ||
export declare function seal_now(outPtr: Ptr, outLenPtr: Ptr): void; | ||
@@ -294,5 +319,3 @@ // Stores the minimum balance (a.k.a. existential deposit) into the supplied buffer. | ||
// The data is encoded as T::Balance. | ||
export declare function seal_minimum_balance( | ||
outPtr: Ptr, | ||
outLenPtr: Ptr): void; | ||
export declare function seal_minimum_balance(outPtr: Ptr, outLenPtr: Ptr): void; | ||
@@ -315,4 +338,5 @@ // Stores the tombstone deposit into the supplied buffer. | ||
export declare function seal_tombstone_deposit( | ||
outPtr: Ptr, | ||
outLenPtr: Ptr): void; | ||
outPtr: Ptr, | ||
outLenPtr: Ptr | ||
): void; | ||
@@ -346,11 +370,11 @@ // Try to restore the given destination contract sacrificing the caller. | ||
export declare function seal_restore_to( | ||
destPtr: Ptr, | ||
destSize: SizeT, | ||
codeHashPtr: Ptr, | ||
codeHashSize: SizeT, | ||
rentAllowancePtr: Ptr, | ||
rentAllowanceSize: SizeT, | ||
deltaPtr: Ptr, | ||
deltaCount: SizeT | ||
): void; | ||
destPtr: Ptr, | ||
destSize: SizeT, | ||
codeHashPtr: Ptr, | ||
codeHashSize: SizeT, | ||
rentAllowancePtr: Ptr, | ||
rentAllowanceSize: SizeT, | ||
deltaPtr: Ptr, | ||
deltaCount: SizeT | ||
): void; | ||
@@ -366,6 +390,7 @@ // Deposit a contract event with the data buffer and optional list of topics. There is a limit | ||
export declare function seal_deposit_event( | ||
topicsPtr: Ptr, | ||
topicsLen: SizeT, | ||
dataPtr: Ptr, | ||
dataLen: SizeT): void; | ||
topicsPtr: Ptr, | ||
topicsLen: SizeT, | ||
dataPtr: Ptr, | ||
dataLen: SizeT | ||
): void; | ||
@@ -378,4 +403,5 @@ // Set rent allowance of the contract | ||
export declare function seal_set_rent_allowance( | ||
valuePtr: Ptr, | ||
valueLen: SizeT): void; | ||
valuePtr: Ptr, | ||
valueLen: SizeT | ||
): void; | ||
@@ -390,5 +416,3 @@ // Stores the rent allowance into the supplied buffer. | ||
// The data is encoded as T::Balance. | ||
export declare function seal_rent_allowance( | ||
outPtr: Ptr, | ||
outLenPtr: Ptr): void; | ||
export declare function seal_rent_allowance(outPtr: Ptr, outLenPtr: Ptr): void; | ||
@@ -398,5 +422,3 @@ // Prints utf8 encoded string from the data buffer. | ||
// This export declare function may be removed at any time, superseded by a more general contract debugging feature. | ||
export declare function seal_println( | ||
strPtr: Ptr, | ||
strLen: SizeT): void; | ||
export declare function seal_println(strPtr: Ptr, strLen: SizeT): void; | ||
@@ -409,5 +431,3 @@ // Stores the current block number of the current contract into the supplied buffer. | ||
// space at `outPtr` is less than the size of the value a trap is triggered. | ||
export declare function seal_block_number( | ||
outPtr: Ptr, | ||
outLenPtr: Ptr): void; | ||
export declare function seal_block_number(outPtr: Ptr, outLenPtr: Ptr): void; | ||
@@ -435,5 +455,6 @@ // Computes the SHA2 256-bit hash on the given input buffer. | ||
export declare function seal_hash_sha2_256( | ||
inputPtr: Ptr, | ||
inputSize: SizeT, | ||
outputPtr: Ptr): void; | ||
inputPtr: Ptr, | ||
inputSize: SizeT, | ||
outputPtr: Ptr | ||
): void; | ||
@@ -461,5 +482,6 @@ // Computes the KECCAK 256-bit hash on the given input buffer. | ||
export declare function seal_hash_keccak_256( | ||
inputPtr: Ptr, | ||
inputSize: SizeT, | ||
outputPtr: Ptr): void; | ||
inputPtr: Ptr, | ||
inputSize: SizeT, | ||
outputPtr: Ptr | ||
): void; | ||
@@ -487,5 +509,6 @@ // Computes the BLAKE2 256-bit hash on the given input buffer. | ||
export declare function seal_hash_blake2_256( | ||
inputPtr: Ptr, | ||
inputSize: SizeT, | ||
outputPtr: Ptr): void; | ||
inputPtr: Ptr, | ||
inputSize: SizeT, | ||
outputPtr: Ptr | ||
): void; | ||
@@ -513,4 +536,24 @@ // Computes the BLAKE2 128-bit hash on the given input buffer. | ||
export declare function seal_hash_blake2_128( | ||
inputPtr: Ptr, | ||
inputSize: SizeT, | ||
outputPtr: Ptr): void; | ||
inputPtr: Ptr, | ||
inputSize: SizeT, | ||
outputPtr: Ptr | ||
): void; | ||
// Call into the chain extension provided by the chain if any. | ||
// | ||
// Handling of the input values is up to the specific chain extension and so is the | ||
// return value. The extension can decide to use the inputs as primitive inputs or as | ||
// in/out arguments by interpreting them as pointers. Any caller of this function | ||
// must therefore coordinate with the chain that it targets. | ||
// | ||
// # Note | ||
// | ||
// If no chain extension exists the contract will trap with the `NoChainExtension` | ||
// module error. | ||
export declare function seal_call_chain_extension( | ||
func_id: u32, | ||
input_ptr: Ptr, | ||
input_len: u32, | ||
output_ptr: Ptr, | ||
output_len_ptr: Ptr | ||
): u32; |
{ | ||
"name": "as-contract-runtime", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "", | ||
@@ -8,5 +8,6 @@ "author": "yjhmelody <yjh465402634@gmail.com>", | ||
"main": "./assembly/index.ts", | ||
"keywords": ["substrate", "blockchain", "wasm", "smart-contract", "assemblyscript", "runtime"], | ||
"scripts": { | ||
"lint": "eslint .", | ||
"build": "asc ./assembly --noEmit" | ||
"check": "asc ./assembly --noEmit --measure" | ||
}, | ||
@@ -13,0 +14,0 @@ "devDependencies": { |
# as-contract-runtime | ||
Substrate smart contract runtime env. |
31533
709
4