@phala/pink-env
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -6,6 +6,100 @@ /** Bytes represented in Uint8Array or hex string */ | ||
}; | ||
declare const _opaqueBrand: unique symbol; | ||
/** | ||
* Represents a registry of types. | ||
* @typedef TypeRegistry | ||
*/ | ||
export declare type TypeRegistry = { | ||
[_opaqueBrand]: "TypeRegistry"; | ||
}; | ||
/** | ||
* Represents a SCALE encoder. | ||
* @typedef ScaleEncoder | ||
*/ | ||
export declare type ScaleEncoder = { | ||
[_opaqueBrand]: "ScaleEncoder"; | ||
}; | ||
/** | ||
* Represents a SCALE decoder. | ||
* @typedef ScaleDecoder | ||
*/ | ||
export declare type ScaleDecoder = { | ||
[_opaqueBrand]: "ScaleDecoder"; | ||
}; | ||
/** | ||
* Represents a SCALE codec for encoding and decoding data. | ||
* @interface ScaleCodec | ||
*/ | ||
export interface ScaleCodec { | ||
/** | ||
* Parses a multi-line string representing types and returns a TypeRegistry. | ||
* @function parseTypes | ||
* @param {string} types - A string representing types. | ||
* @returns {TypeRegistry} - A TypeRegistry containing the parsed types. | ||
* @example | ||
* const typesString = ` | ||
* #bool | ||
* <Ok:2,Err:3> | ||
* () | ||
* <CouldNotReadInput::1> | ||
* `; | ||
* const typeRegistry = parseTypes(typesString); | ||
*/ | ||
parseTypes(types: string): TypeRegistry; | ||
/** | ||
* Creates a SCALE encoder for encoding tuple values. | ||
* @function createTupleEncoder | ||
* @param {number[]} typeIds - An array of type IDs. | ||
* @param {TypeRegistry} typeRegistry - A TypeRegistry containing the types to be encoded. | ||
* @returns {ScaleEncoder} - A ScaleEncoder for encoding tuple values. | ||
*/ | ||
createTupleEncoder(typeIds: number[], typeRegistry: TypeRegistry): ScaleEncoder; | ||
/** | ||
* Creates a SCALE encoder for a specific type ID. | ||
* @function createEncoderForTypeId | ||
* @param {number} typeId - The type ID for which to create the encoder. | ||
* @param {TypeRegistry} typeRegistry - A TypeRegistry containing the types to be encoded. | ||
* @returns {ScaleEncoder} - A ScaleEncoder for encoding values of the specified type ID. | ||
*/ | ||
createEncoderForTypeId(typeId: number, typeRegistry: TypeRegistry): ScaleEncoder; | ||
/** | ||
* Creates a SCALE decoder for decoding tuple values. | ||
* @function createTupleDecoder | ||
* @param {number[]} typeIds - An array of type IDs. | ||
* @param {TypeRegistry} typeRegistry - A TypeRegistry containing the types to be decoded. | ||
* @returns {ScaleDecoder} - A ScaleDecoder for decoding tuple values. | ||
*/ | ||
createTupleDecoder(typeIds: number[], typeRegistry: TypeRegistry): ScaleDecoder; | ||
/** | ||
* Creates a SCALE decoder for a specific type ID. | ||
* @function createDecoderForTypeId | ||
* @param {number} typeId - The type ID for which to create the decoder. | ||
* @param {TypeRegistry} typeRegistry - A TypeRegistry containing the types to be decoded. | ||
* @returns {ScaleDecoder} - A ScaleDecoder for decoding values of the specified type ID. | ||
*/ | ||
createDecoderForTypeId(typeId: number, typeRegistry: TypeRegistry): ScaleDecoder; | ||
/** | ||
* Encodes a value using the provided SCALE encoder. | ||
* @function encode | ||
* @param {*} value - The value to be encoded. | ||
* @param {ScaleEncoder} encoder - The ScaleEncoder to use for encoding the value. | ||
* @returns {Uint8Array} - The encoded value as a Uint8Array. | ||
*/ | ||
encode(value: any, encoder: ScaleEncoder): Uint8Array; | ||
/** | ||
* Decodes a value from a Uint8Array using the provided SCALE decoder. | ||
* @function decode | ||
* @param {Uint8Array} bytes - The bytes to be decoded. | ||
* @param {ScaleDecoder} decoder - The ScaleDecoder to use for decoding the bytes. | ||
* @returns {*} - The decoded value | ||
*/ | ||
decode(bytes: Uint8Array, decoder: ScaleDecoder): any; | ||
} | ||
declare global { | ||
/** The input arguments passed to the contract eval */ | ||
var scriptArgs: string[]; | ||
/** The extension object for pink contract */ | ||
/** | ||
* The extension object for pink contract. | ||
* @typedef pink | ||
*/ | ||
var pink: { | ||
@@ -19,2 +113,3 @@ /** | ||
* @param {Bytes} args.input - The input arguments for the contract call, encoded in scale. | ||
* @param {boolean} args.allowReentry - A flag indicating whether reentry to this contract is allowed. Defaults to false. | ||
* @return {Uint8Array} - The result of the contract call. | ||
@@ -28,16 +123,5 @@ */ | ||
input: Bytes; | ||
allowReentry?: boolean; | ||
}): Uint8Array; | ||
/** | ||
* Invokes a delegate call on a contract code by a code hash. | ||
* @param {Bytes} args.codeHash - The code hash of the contract to delegate to. | ||
* @param {number} args.selector - The selector of the ink message to be called. | ||
* @param {Bytes} args.input - The input arguments for the delegate call, encoded in scale. | ||
* @return {Uint8Array} - The result of the delegate call. | ||
*/ | ||
invokeContractDelegate(args: { | ||
codeHash: Bytes; | ||
selector: number; | ||
input: Bytes; | ||
}): Uint8Array; | ||
/** | ||
* This function sends an HTTP request and returns the response as either a Uint8Array or a string. | ||
@@ -67,4 +151,10 @@ * @param {string} args.url - The URL to send the request to. | ||
}; | ||
/** | ||
* The SCALE codec object for encoding and decoding data. | ||
* @typedef SCALE | ||
* @type {ScaleCodec} | ||
*/ | ||
SCALE: ScaleCodec; | ||
}; | ||
} | ||
export {}; |
{ | ||
"name": "@phala/pink-env", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "The js environment accessing of Phala's Phat contract.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
140
src/index.ts
@@ -6,6 +6,123 @@ /** Bytes represented in Uint8Array or hex string */ | ||
declare const _opaqueBrand: unique symbol; | ||
/** | ||
* Represents a registry of types. | ||
* @typedef TypeRegistry | ||
*/ | ||
export type TypeRegistry = { | ||
[_opaqueBrand]: "TypeRegistry"; | ||
}; | ||
/** | ||
* Represents a SCALE encoder. | ||
* @typedef ScaleEncoder | ||
*/ | ||
export type ScaleEncoder = { | ||
[_opaqueBrand]: "ScaleEncoder"; | ||
}; | ||
/** | ||
* Represents a SCALE decoder. | ||
* @typedef ScaleDecoder | ||
*/ | ||
export type ScaleDecoder = { | ||
[_opaqueBrand]: "ScaleDecoder"; | ||
}; | ||
/** | ||
* Represents a SCALE codec for encoding and decoding data. | ||
* @interface ScaleCodec | ||
*/ | ||
export interface ScaleCodec { | ||
/** | ||
* Parses a multi-line string representing types and returns a TypeRegistry. | ||
* @function parseTypes | ||
* @param {string} types - A string representing types. | ||
* @returns {TypeRegistry} - A TypeRegistry containing the parsed types. | ||
* @example | ||
* const typesString = ` | ||
* #bool | ||
* <Ok:2,Err:3> | ||
* () | ||
* <CouldNotReadInput::1> | ||
* `; | ||
* const typeRegistry = parseTypes(typesString); | ||
*/ | ||
parseTypes(types: string): TypeRegistry; | ||
/** | ||
* Creates a SCALE encoder for encoding tuple values. | ||
* @function createTupleEncoder | ||
* @param {number[]} typeIds - An array of type IDs. | ||
* @param {TypeRegistry} typeRegistry - A TypeRegistry containing the types to be encoded. | ||
* @returns {ScaleEncoder} - A ScaleEncoder for encoding tuple values. | ||
*/ | ||
createTupleEncoder( | ||
typeIds: number[], | ||
typeRegistry: TypeRegistry | ||
): ScaleEncoder; | ||
/** | ||
* Creates a SCALE encoder for a specific type ID. | ||
* @function createEncoderForTypeId | ||
* @param {number} typeId - The type ID for which to create the encoder. | ||
* @param {TypeRegistry} typeRegistry - A TypeRegistry containing the types to be encoded. | ||
* @returns {ScaleEncoder} - A ScaleEncoder for encoding values of the specified type ID. | ||
*/ | ||
createEncoderForTypeId( | ||
typeId: number, | ||
typeRegistry: TypeRegistry | ||
): ScaleEncoder; | ||
/** | ||
* Creates a SCALE decoder for decoding tuple values. | ||
* @function createTupleDecoder | ||
* @param {number[]} typeIds - An array of type IDs. | ||
* @param {TypeRegistry} typeRegistry - A TypeRegistry containing the types to be decoded. | ||
* @returns {ScaleDecoder} - A ScaleDecoder for decoding tuple values. | ||
*/ | ||
createTupleDecoder( | ||
typeIds: number[], | ||
typeRegistry: TypeRegistry | ||
): ScaleDecoder; | ||
/** | ||
* Creates a SCALE decoder for a specific type ID. | ||
* @function createDecoderForTypeId | ||
* @param {number} typeId - The type ID for which to create the decoder. | ||
* @param {TypeRegistry} typeRegistry - A TypeRegistry containing the types to be decoded. | ||
* @returns {ScaleDecoder} - A ScaleDecoder for decoding values of the specified type ID. | ||
*/ | ||
createDecoderForTypeId( | ||
typeId: number, | ||
typeRegistry: TypeRegistry | ||
): ScaleDecoder; | ||
/** | ||
* Encodes a value using the provided SCALE encoder. | ||
* @function encode | ||
* @param {*} value - The value to be encoded. | ||
* @param {ScaleEncoder} encoder - The ScaleEncoder to use for encoding the value. | ||
* @returns {Uint8Array} - The encoded value as a Uint8Array. | ||
*/ | ||
encode(value: any, encoder: ScaleEncoder): Uint8Array; | ||
/** | ||
* Decodes a value from a Uint8Array using the provided SCALE decoder. | ||
* @function decode | ||
* @param {Uint8Array} bytes - The bytes to be decoded. | ||
* @param {ScaleDecoder} decoder - The ScaleDecoder to use for decoding the bytes. | ||
* @returns {*} - The decoded value | ||
*/ | ||
decode(bytes: Uint8Array, decoder: ScaleDecoder): any; | ||
} | ||
declare global { | ||
/** The input arguments passed to the contract eval */ | ||
var scriptArgs: string[]; | ||
/** The extension object for pink contract */ | ||
/** | ||
* The extension object for pink contract. | ||
* @typedef pink | ||
*/ | ||
var pink: { | ||
@@ -19,2 +136,3 @@ /** | ||
* @param {Bytes} args.input - The input arguments for the contract call, encoded in scale. | ||
* @param {boolean} args.allowReentry - A flag indicating whether reentry to this contract is allowed. Defaults to false. | ||
* @return {Uint8Array} - The result of the contract call. | ||
@@ -28,16 +146,5 @@ */ | ||
input: Bytes; | ||
allowReentry?: boolean; | ||
}): Uint8Array; | ||
/** | ||
* Invokes a delegate call on a contract code by a code hash. | ||
* @param {Bytes} args.codeHash - The code hash of the contract to delegate to. | ||
* @param {number} args.selector - The selector of the ink message to be called. | ||
* @param {Bytes} args.input - The input arguments for the delegate call, encoded in scale. | ||
* @return {Uint8Array} - The result of the delegate call. | ||
*/ | ||
invokeContractDelegate(args: { | ||
codeHash: Bytes; | ||
selector: number; | ||
input: Bytes; | ||
}): Uint8Array; | ||
/** | ||
* This function sends an HTTP request and returns the response as either a Uint8Array or a string. | ||
@@ -67,4 +174,11 @@ * @param {string} args.url - The URL to send the request to. | ||
}; | ||
/** | ||
* The SCALE codec object for encoding and decoding data. | ||
* @typedef SCALE | ||
* @type {ScaleCodec} | ||
*/ | ||
SCALE: ScaleCodec; | ||
}; | ||
} | ||
export {}; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
13963
340
1