/** Fadroma. Copyright (C) 2023 Hack.bg. License: GNU AGPLv3 or custom.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see . **/
import { Logged, Console } from "./core.dist";
import type { Into } from "./core.dist";
import { Contract } from "./chain.dist";
import type { Connection, ChainId, Label, Message, Address, TxHash } from "./chain.dist";
import * as Token from "./token.dist";
import type * as Store from "./store.dist";
import type { CodeHash, Compiler } from "./program.browser.dist";
import { SourceCode, RustSourceCode, CompiledCode } from "./program.dist";
/** A code ID, identifying uploaded code on a chain. */
export type CodeId = string;
/** The name of a deployment unit. Used to generate contract label. */
export type Name = string;
export declare class ContractCode extends Logged {
source?: SourceCode;
compiler?: Compiler;
compiled?: CompiledCode;
uploader?: Connection | Address;
uploaded?: UploadedCode;
deployer?: Connection | Address;
constructor(properties?: Partial);
/** Compile this contract, unless a valid binary is present and a rebuild is not requested. */
compile({ compiler, rebuild, ...buildOptions }?: {
compiler?: Compiler;
rebuild?: boolean;
}): Promise[1] & {
codeHash: CodeHash;
}>;
/** Upload this contract, unless a valid upload is present and a rebuild is not requested. */
upload({ compiler, rebuild, uploader, reupload, ...uploadOptions }?: Parameters[0] & Parameters[1] & {
uploader?: Address | {
upload: Connection["upload"];
};
reupload?: boolean;
}): Promise;
}
/** An object representing the contract's binary uploaded to a given chain. */
export declare class UploadedCode {
/** Code hash uniquely identifying the compiled code. */
codeHash?: CodeHash;
/** ID of chain on which this contract is uploaded. */
chainId?: ChainId;
/** Code ID representing the identity of the contract's code on a specific chain. */
codeId?: CodeId;
/** TXID of transaction that performed the upload. */
uploadTx?: TxHash;
/** address of agent that performed the upload. */
uploadBy?: Address | Connection;
/** address of agent that performed the upload. */
uploadGas?: string | number;
constructor(properties?: Partial);
get [Symbol.toStringTag](): string;
serialize(): {
codeHash?: CodeHash;
chainId?: ChainId;
codeId?: CodeId;
uploadTx?: TxHash;
uploadBy?: Address;
uploadGas?: string | number;
uploadInfo?: string;
[key: string]: unknown;
};
get canInstantiate(): boolean;
get canInstantiateInfo(): string | undefined;
}
/** A contract that is part of a deploment.
* - needed for deployment-wide deduplication
* - generates structured label */
export declare class DeploymentUnit extends ContractCode {
/** Name of this unit. */
name?: string;
/** Deployment to which this unit belongs. */
deployment?: Deployment;
/** Code hash uniquely identifying the compiled code. */
codeHash?: CodeHash;
/** Code ID representing the identity of the contract's code on a specific chain. */
chainId?: ChainId;
/** Code ID representing the identity of the contract's code on a specific chain. */
codeId?: CodeId;
constructor(properties?: ConstructorParameters[0] & Partial);
serialize(): {
name: string;
codeHash: string;
chainId: string;
codeId: string;
};
}
export declare class ContractTemplate extends DeploymentUnit {
readonly isTemplate = true;
/** Create a new instance of this contract. */
contract(name: Name, parameters?: Partial): ContractInstance;
/** Create multiple instances of this contract. */
contracts(instanceParameters?: Record[1]>): Record;
}
export declare class ContractInstance extends DeploymentUnit {
readonly isTemplate = false;
/** Full label of the instance. Unique for a given chain. */
label?: Label;
/** Address of this contract instance. Unique per chain. */
address?: Address;
/** Contents of init message. */
initMsg?: Into;
/** Address of agent that performed the init tx. */
initBy?: Address | Connection;
/** Native tokens to send to the new contract. */
initSend?: Token.ICoin[];
/** Fee to use for init. */
initFee?: unknown;
/** Instantiation memo. */
initMemo?: string;
/** ID of transaction that performed the init. */
initTx?: TxHash;
/** Contents of init message. */
initGas?: unknown;
constructor(properties?: ConstructorParameters[0] & Partial);
deploy({ deployer, redeploy, uploader, reupload, compiler, rebuild, ...initOptions }?: Parameters[0] & Parameters[1] & {
deployer?: Address | {
instantiate: Connection["instantiate"];
};
redeploy?: boolean;
}): Promise;
serialize(): {
label: string;
address: string;
initMsg: Into;
initBy: string | Connection;
initSend: Token.ICoin[];
initFee: unknown;
initMemo: string;
initTx: string;
initGas: unknown;
name: string;
codeHash: string;
chainId: string;
codeId: string;
};
/** Returns a client to this contract instance. */
connect(agent?: Connection): Contract;
isValid(): this is ContractInstance & {
address: Address;
};
}
export type DeploymentState = Partial>;
/** A collection of contracts. */
export declare class Deployment extends Map {
log: Console;
name: string;
static fromSnapshot({ name, units }: DeploymentState): Deployment;
constructor(properties?: Partial);
serialize(): {
name: string;
units: {
[k: string]: DeploymentUnit;
};
};
set(name: string, unit: DeploymentUnit): this;
/** Define a template, representing code that can be compiled
* and uploaded, but will not be automatically instantiated.
* This can then be used to define multiple instances of
* the same code. */
template(name: string, properties?: (({
language: 'rust';
} & Partial) | ({
language?: undefined;
} & Partial)) & Partial & Partial): ContractTemplate;
/** Define a contract that will be automatically compiled, uploaded,
* and instantiated as part of this deployment. */
contract(name: string, properties?: (({
language: 'rust';
} & Partial) | ({
language?: undefined;
} & Partial)) & Partial & Partial & Partial): ContractInstance;
addContract(...args: Parameters): this;
addContracts(...args: Parameters): this;
build({ units, ...options }?: Parameters[0] & {
units?: Name[];
}): Promise>;
upload({ units, ...options }?: Parameters[0] & {
units?: Name[];
uploadStore?: Store.UploadStore;
}): Promise>;
deploy({ units, ...options }?: Parameters[0] & {
units?: Name[];
deployStore?: Store.DeployStore;
}): Promise>;
}
//# sourceMappingURL=deploy.d.ts.map