diff --git a/agent/agent-base.ts b/agent/agent-base.ts index 16fcc54e762..be9b61784be 100644 --- a/agent/agent-base.ts +++ b/agent/agent-base.ts @@ -318,22 +318,23 @@ class AgentConsole extends Console { const len = Math.max(40, Object.keys(contracts).reduce((x,r)=>Math.max(x,r.length),0)) const count = Object.values(contracts).length if (count <= 0) return this.info(`${name} is an empty deployment`) - this.info(`${bold(String(count))} contract(s) in deployment ${bold(name)}:`) - this.br() + this.info() + this.info(`${bold(String(count))} unit(s) in deployment ${bold(name)}:`) for (const name of Object.keys(contracts).sort()) { + this.info() this.receipt(name, contracts[name], len) - this.br() } + this.info() return this } receipt (name: string, receipt?: any, len?: number) { let { address, codeHash, codeId, crate, repository } = receipt || {} - this.info(`name: ${bold(name || gray('(no name)')) }`) - this.info(`addr: ${bold(address || gray('(no address)')) }`) - this.info(`hash: ${bold(codeHash || gray('(no code hash)'))}`) - this.info(`code: ${bold(codeId) || gray('(no code id)') }`) - this.info(`repo: ${bold(repository || gray('(no repo)')) }`) - this.info(`crate: ${bold(crate || gray('(no crate)')) }`) + this.info(` ${bold(name || gray('(no name)')) }`) + this.info(` addr: ${bold(address || gray('(no address)')) }`) + this.info(` hash: ${bold(codeHash || gray('(no code hash)'))}`) + this.info(` code: ${bold(codeId) || gray('(no code id)') }`) + this.info(` repo: ${bold(repository || gray('(no repo)')) }`) + this.info(` crate: ${bold(crate || gray('(no crate)')) }`) return this } } diff --git a/agent/agent-batch.ts b/agent/agent-batch.ts index 8608ce5d0e7..8923f9cf332 100644 --- a/agent/agent-batch.ts +++ b/agent/agent-batch.ts @@ -2,7 +2,7 @@ import { Error, Console, into } from './agent-base' import type { Class, Message, CodeId, Address, Name, Into, ICoin, Many, CodeHash } from './agent-base' -import type { Agent, ExecOpts } from './agent-chain' +import type { Agent } from './agent-chain' import { ContractInstance } from './agent-contract' /** A constructor for a Batch subclass. */ @@ -58,18 +58,19 @@ export abstract class Batch implements BatchAgent { } /** Either submit or save the batch. */ - async run (opts: ExecOpts|string = "", save: boolean = false): Promise { - this.log(save ? 'Saving' : 'Submitting') - if (typeof opts === 'string') opts = { memo: opts } - const { memo = '' } = opts ?? {} + async run (options: Partial<{ + memo: string, + save: boolean + }> = {}): Promise { + this.log(options.save ? 'Saving' : 'Submitting') if (this.depth > 0) { this.log.warn('Unnesting batch. Depth:', --this.depth) this.depth-- return null as any // result ignored - } else if (save) { - return this.save(memo) + } else if (options.save) { + return this.save(options.memo) } else { - return this.submit(memo) + return this.submit(options.memo) } } @@ -183,8 +184,8 @@ export abstract class Batch implements BatchAgent { /** Add an exec message to the batch. */ async execute ( contract: Address|{ address: Address, codeHash?: CodeHash }, - msg: Message, - { send }: ExecOpts = {} + message: Message, + options: Parameters[2] = {} ): Promise { let address: Address let codeHash: CodeHash|undefined = undefined @@ -194,7 +195,15 @@ export abstract class Batch implements BatchAgent { address = contract.address codeHash = contract.codeHash } - this.add({ exec: { sender: this.address, contract: address, codeHash, msg, funds: send } }) + this.add({ + exec: { + sender: this.address, + contract: address, + codeHash, + msg: message, + funds: options.execSend + } + }) return this } /** Queries are disallowed in the middle of a batch because @@ -255,11 +264,15 @@ export abstract class Batch implements BatchAgent { throw new Error.Invalid.Batching("query balance") } /** Disallowed in batch - do it beforehand or afterwards. */ - async send (to: Address, amounts: ICoin[], opts?: ExecOpts): Promise { + async send ( + recipient: Address, amounts: ICoin[], options?: Parameters[2] + ): Promise { throw new Error.Invalid.Batching("send") } /** Disallowed in batch - do it beforehand or afterwards. */ - async sendMany (outputs: [Address, ICoin[]][], opts?: ExecOpts): Promise { + async sendMany ( + outputs: [Address, ICoin[]][], options?: Parameters[1] + ): Promise { throw new Error.Invalid.Batching("send") } /** Nested batches are "flattened": trying to create a batch diff --git a/agent/agent-chain.ts b/agent/agent-chain.ts index 1409a1d637a..9172a24c553 100644 --- a/agent/agent-chain.ts +++ b/agent/agent-chain.ts @@ -341,41 +341,39 @@ export interface AgentClass extends Class = (this.constructor as AgentClass).Batch - /** The default Batch class used by this Agent. */ static Batch: BatchClass // populated below constructor (options: Partial = {}) { this.chain = options.chain ?? this.chain - this.name = options.name ?? this.name - this.fees = options.fees ?? this.fees - this.address = options.address ?? this.address + this.name = options.name ?? this.name + this.fees = options.fees ?? this.fees + this.address = options.address ?? this.address hideProperties(this, 'chain', 'address', 'log', 'Batch') } get [Symbol.toStringTag]() { - return `${this.address} @ ${this.chain?.id}${this.mnemonic ? ' (*)' : ''}` + return `${this.address} @ ${this.chain?.id}` + } + + /** The wallet's mnemonic (write-only). */ + get mnemonic (): Promise { + throw new Error('mnemonic is write-only') + } + + set mnemonic (mnemonic: string) { } /** Complete the asynchronous initialization of this Agent. */ @@ -443,10 +441,10 @@ export abstract class Agent { } /** Send native tokens to 1 recipient. */ - abstract send (to: Address, amounts: ICoin[], opts?: ExecOpts): Promise + abstract send (to: Address, amounts: ICoin[], opts?: unknown): Promise /** Send native tokens to multiple recipients. */ - abstract sendMany (outputs: [Address, ICoin[]][], opts?: ExecOpts): Promise + abstract sendMany (outputs: [Address, ICoin[]][], opts?: unknown): Promise /** Upload a contract's code, generating a new code id/hash pair. */ async upload ( @@ -500,14 +498,15 @@ export abstract class Agent { /** Upload multiple contracts. */ async uploadMany ( - codes: Many>, + codes: Many>, options: Parameters[1] ) { return mapAsync(codes, code => this.upload(code, options)) } protected abstract doUpload ( - data: Uint8Array, options: Parameters[1] + data: Uint8Array, + options: Parameters[1] ): Promise> /** Create a new smart contract from a code id, label and init message. @@ -531,7 +530,6 @@ export abstract class Agent { if (!contract.codeId) { throw new Error.Missing.CodeId() } - console.log({contract, options}, !!options.label) if (!options.label) { throw new Error.Missing.Label() } @@ -623,7 +621,11 @@ export abstract class Agent { async execute ( contract: Address|Partial, message: Message, - options?: ExecOpts + options?: { + execFee?: IFee + execSend?: ICoin[] + execMemo?: string + } ): Promise { if (typeof contract === 'string') contract = new ContractInstance({ address: contract }) if (!contract.address) throw new Error("agent.execute: no contract address") @@ -636,15 +638,15 @@ export abstract class Agent { protected abstract doExecute ( contract: { address: Address }, message: Message, - options?: ExecOpts + options: Parameters[2] ): Promise /** Query a contract on the chain. */ query ( contract: Address|{ address: Address, codeHash?: CodeHash }, - msg: Message + message: Message ): Promise { - return assertChain(this).query(contract, msg) + return assertChain(this).query(contract, message) } /** Execute a transaction batch. @@ -653,7 +655,6 @@ export abstract class Agent { batch (cb?: BatchCallback): B { return new this.Batch(this, cb as BatchCallback) as unknown as B } - } /** Default fees for the main operations that an Agent can perform. */ @@ -663,15 +664,3 @@ export interface AgentFees { init?: IFee exec?: IFee } - -/** Options for a compute transaction. */ -export interface ExecOpts { - /** The maximum fee. */ - fee?: IFee - /** A list of native tokens to send alongside the transaction. */ - send?: ICoin[] - /** A transaction memo. */ - memo?: string - /** Allow extra options. */ - [k: string]: unknown -} diff --git a/agent/agent-contract.ts b/agent/agent-contract.ts index 6c50ccfe780..c5a7a51da22 100644 --- a/agent/agent-contract.ts +++ b/agent/agent-contract.ts @@ -23,7 +23,7 @@ import type { Into, Name, ICoin, IFee, Label, Class, Address, CodeId, CodeHash, TxHash, Message } from './agent-base' import type { - Agent, Chain, ChainId, ChainMode, ExecOpts + Agent, Chain, ChainId, ChainMode, } from './agent-chain' import type { Builder, UploadStore, DeployStore @@ -59,11 +59,12 @@ assign.allowed = { 'buildInfo', 'codeHash', 'codePath', 'codeData' ] as Array, ContractUpload: [ - 'deployment', 'chainId', 'codeId', 'uploadTx', 'uploadBy', 'uploadGas', 'uploadInfo', + 'deployment', 'chainId', + 'codeId', 'uploadTx', 'uploadBy', 'uploadGas', 'uploadInfo', ] as Array, ContractInstance: [ - 'name', 'prefix', 'suffix', 'label', 'address', - 'initMsg', 'initBy', 'initFunds', 'initFee', 'initMemo', 'initTx', 'initGas' + 'codeId', 'codeHash', 'label', 'address', 'initMsg', + 'initBy', 'initFunds', 'initFee', 'initMemo', 'initTx', 'initGas' ] as Array, Deployment: [ 'name' @@ -123,11 +124,11 @@ export class SourceCode { export class CompiledCode { buildInfo?: string /** Code hash uniquely identifying the compiled code. */ - codeHash?: CodeHash + codeHash?: CodeHash /** Location of the compiled code. */ - codePath?: string|URL + codePath?: string|URL /** The compiled code. */ - codeData?: Uint8Array + codeData?: Uint8Array constructor (properties: Partial = {}) { assign(this, properties, assign.allowed['CompiledCode']) @@ -199,6 +200,8 @@ export class ContractUpload { uploadGas?: string|number /** extra info */ uploadInfo?: string + /** Code hash uniquely identifying the compiled code. */ + codeHash?: CodeHash constructor (properties: Partial = {}) { assign(this, properties, assign.allowed['ContractUpload']) @@ -244,12 +247,10 @@ export class ContractUpload { } export class ContractInstance { - /** Part of label. */ - name?: Name - /** Part of label. */ - prefix?: Name - /** Part of label. */ - suffix?: Name + /** Code ID representing the identity of the contract's code on a specific chain. */ + codeId?: CodeId + /** Code hash uniquely identifying the compiled code. */ + codeHash?: CodeHash /** Full label of the instance. Unique for a given Chain. */ label?: Label /** Address of this contract instance. Unique per chain. */ @@ -588,14 +589,18 @@ export class ContractClient { } /** Execute a transaction on the specified contract as the specified Agent. */ - execute (msg: Message, opt: ExecOpts = {}): Promise { + execute (message: Message, options: Parameters[2] = {}): Promise { if (!this.agent) { throw new Error.Missing.Agent(this.constructor?.name) } if (!this.contract.address) { throw new Error.Missing.Address() } - return this.agent.execute(this.contract as ContractInstance & { address: Address }, msg, opt) + return this.agent.execute( + this.contract as ContractInstance & { address: Address }, + message, + options + ) } } diff --git a/agent/agent-stub.ts b/agent/agent-stub.ts index 2e56a23190d..9f07599376d 100644 --- a/agent/agent-stub.ts +++ b/agent/agent-stub.ts @@ -1,7 +1,6 @@ import type { Address, CodeHash, Message, CodeId, ICoin, Label } from './agent-base' import { Chain, Agent } from './agent-chain' import { Batch } from './agent-batch' -import type { ExecOpts } from './agent-chain' import { ContractUpload, ContractInstance } from './agent-contract' export class StubChain extends Chain { @@ -54,12 +53,12 @@ export class StubAgent extends Agent { } /** Stub implementation of sending native token. */ - send (to: Address, amounts: ICoin[], opts?: ExecOpts): Promise { + send (to: Address, amounts: ICoin[], opts?: never): Promise { return Promise.resolve() } /** Stub implementation of batch send. */ - sendMany (outputs: [Address, ICoin[]][], opts?: ExecOpts): Promise { + sendMany (outputs: [Address, ICoin[]][], opts?: never): Promise { return Promise.resolve() } @@ -97,7 +96,7 @@ export class StubAgent extends Agent { protected doExecute ( contract: { address: Address, codeHash: CodeHash }, message: Message, - options?: ExecOpts + options?: never ): Promise { return Promise.resolve({}) } diff --git a/agent/agent-token.ts b/agent/agent-token.ts index 51e28064fe6..098c03aea76 100644 --- a/agent/agent-token.ts +++ b/agent/agent-token.ts @@ -84,7 +84,7 @@ export class Pair { /** An amount of a fungible token. */ export class Amount { constructor (public token: TokenFungible, public amount: Uint128) {} - /** Pass this to 'send' field of ExecOpts. */ + /** Pass this to send, initSend, execSend */ get asNativeBalance (): ICoin[] { if (this.token.isNative()) return [new Coin(this.amount, this.token.denom)] return [] @@ -94,11 +94,15 @@ export class Amount { /** A pair of token amounts. */ export class Swap { constructor (readonly a: Amount, readonly b: Amount) {} - /** Pass this to 'send' field of ExecOpts */ + /** Pass this to send, initSend, execSend */ get asNativeBalance (): ICoin[] { let result: ICoin[] = [] - if (this.a.token.isNative()) result = [...result, ...this.a.asNativeBalance] - if (this.b.token.isNative()) result = [...result, ...this.b.asNativeBalance] + if (this.a.token.isNative()) { + result = [...result, ...this.a.asNativeBalance] + } + if (this.b.token.isNative()) { + result = [...result, ...this.b.asNativeBalance] + } return result } } diff --git a/connect/cw/cw-base.ts b/connect/cw/cw-base.ts index 4109b3e73d5..a94b9b38087 100644 --- a/connect/cw/cw-base.ts +++ b/connect/cw/cw-base.ts @@ -10,10 +10,7 @@ import { ContractInstance } from '@fadroma/agent' -import type { - Address, Message, ExecOpts, CodeId, CodeHash, - ContractTemplate, Label -} from '@fadroma/agent' +import type { Address, Message, CodeId, CodeHash, ContractUpload, Label } from '@fadroma/agent' import { CosmWasmClient, SigningCosmWasmClient, serializeSignDoc } from '@hackbg/cosmjs-esm' import type { logs, OfflineSigner as Signer, Block, StdFee } from '@hackbg/cosmjs-esm' @@ -192,16 +189,23 @@ class CWAgent extends Agent { } /** Stargate implementation of sending native token. */ - send (to: Address, amounts: ICoin[], opts?: ExecOpts): Promise { + send ( + recipient: Address, + amounts: ICoin[], + options?: Parameters[2] + ): Promise { throw new Error('not implemented') } /** Stargate implementation of batch send. */ - sendMany (outputs: [Address, ICoin[]][], opts?: ExecOpts): Promise { + sendMany ( + outputs: [Address, ICoin[]][], + options?: Parameters[1] + ): Promise { throw new Error('not implemented') } - protected async doUpload (data: Uint8Array): Promise> { + protected async doUpload (data: Uint8Array): Promise> { const { api } = await this.ready if (!this.address) throw new Error.Missing.Address() const result = await api.upload( @@ -219,45 +223,31 @@ class CWAgent extends Agent { /** Instantiate a contract via CosmJS Stargate. */ protected async doInstantiate ( - codeId: CodeId, - options: { - label: Label, - initMsg: Message, - initFee?: StdFee|'auto', - initFunds?: ICoin[], - initMemo?: string, - codeHash?: CodeHash - } + codeId: CodeId, + options: Parameters[1] ): Promise> { const { api } = await this.ready - const { initFee, initFunds, initMemo } = options - const result = await api.instantiate( this.address!, Number(codeId), options.initMsg, options.label, options.initFee || 'auto', - { - funds: initFunds, - admin: this.address, - memo: options.initMemo - } + { admin: this.address, funds: options.initFunds, memo: options.initMemo } ) - return { codeId, - codeHash: options.codeHash, - label: options.label, - initMsg: options.initMsg, - chainId: assertChain(this).id, - address: result.contractAddress, - initTx: result.transactionHash, - initGas: result.gasUsed, - initBy: this.address, - initFee, - initFunds, - initMemo + codeHash: options.codeHash, + label: options.label, + initMsg: options.initMsg, + chainId: assertChain(this).id, + address: result.contractAddress, + initTx: result.transactionHash, + initGas: result.gasUsed, + initBy: this.address, + initFee: options.initFee || 'auto', + initFunds: options.initFunds, + initMemo: options.initMemo } } @@ -265,12 +255,23 @@ class CWAgent extends Agent { protected async doExecute ( contract: { address: Address }, message: Message, - options: ExecOpts = {} + options: Parameters[2] = {} ): Promise { const { api } = await this.ready if (!this.address) throw new CWError("agent.execute: no agent address") - const { send, memo, fee = this.fees?.exec || 'auto' } = options - return await api.execute(this.address, contract.address, message, fee, memo, send) + const { + execSend, + execMemo, + execFee = this.fees?.exec || 'auto' + } = options + return await api.execute( + this.address, + contract.address, + message, + execFee, + execMemo, + execSend + ) } /** Query a contract. */ diff --git a/connect/scrt/scrt-chain.ts b/connect/scrt/scrt-chain.ts index 422133a1c93..3ff4430fb95 100644 --- a/connect/scrt/scrt-chain.ts +++ b/connect/scrt/scrt-chain.ts @@ -15,13 +15,13 @@ import * as Mocknet from './scrt-mocknet' import { Agent, into, base64, bip39, bip39EN, bold, Chain, Fee, Batch, assertChain, - ContractTemplate, ContractInstance, + ContractUpload, ContractInstance, bindChainSupport } from '@fadroma/agent' import type { AgentClass, AgentFees, ChainClass, Uint128, BatchClass, ContractClient, - ExecOpts, ICoin, Message, Name, Address, TxHash, ChainId, CodeId, CodeHash, Label, + ICoin, Message, Name, Address, TxHash, ChainId, CodeId, CodeHash, Label, } from '@fadroma/agent' /** Represents a Secret Network API endpoint. */ @@ -405,7 +405,7 @@ class ScrtAgent extends Agent { } /** Upload a WASM binary. */ - protected async doUpload (data: Uint8Array): Promise> { + protected async doUpload (data: Uint8Array): Promise> { const { api, address } = await this.ready const request = { sender: address!, wasm_byte_code: data, source: "", builder: "" } const gasLimit = Number(this.fees.upload?.amount[0].amount) || undefined @@ -444,14 +444,7 @@ class ScrtAgent extends Agent { protected async doInstantiate ( codeId: CodeId, - options: { - codeHash: CodeHash, - label: Label, - initMsg: Message, - initFee?: ICoin[]|'auto', - initFunds?: ICoin[], - initMemo?: string, - } + options: Parameters[1] ): Promise> { const { api } = await this.ready if (!this.address) throw new Error("Agent has no address") @@ -494,7 +487,7 @@ class ScrtAgent extends Agent { protected async doExecute ( contract: { address: Address, codeHash: CodeHash }, message: Message, - options?: ExecOpts + options?: Parameters[2] ): Promise { const { api, address } = await this.ready const tx = { @@ -502,10 +495,10 @@ class ScrtAgent extends Agent { contract_address: contract.address, code_hash: contract.codeHash, msg: message as Record, - sentFunds: options?.send + sentFunds: options?.execSend } const txOpts = { - gasLimit: Number(options?.fee?.gas) || undefined + gasLimit: Number(options?.execFee?.gas) || undefined } if (this.simulateForGas) { this.log.info('Simulating transaction...') diff --git a/connect/scrt/scrt-mocknet.ts b/connect/scrt/scrt-mocknet.ts index 2b6c84834f9..d6112065029 100644 --- a/connect/scrt/scrt-mocknet.ts +++ b/connect/scrt/scrt-mocknet.ts @@ -19,7 +19,7 @@ **/ import type { - AgentClass, Uint128, BatchClass, ExecOpts, + AgentClass, Uint128, BatchClass, Address, CodeHash, ChainId, CodeId, Message, Label, Into } from '@fadroma/agent' @@ -28,7 +28,7 @@ import { randomBech32, sha256, base16, bech32, brailleDump, Error as BaseError, Console as BaseConsole, bold, colors, into, Chain, ChainMode, Agent, Batch, assertChain, - ContractInstance, ContractTemplate + ContractInstance, ContractUpload } from '@fadroma/agent' import * as secp256k1 from '@noble/secp256k1' @@ -304,13 +304,13 @@ class MocknetAgent extends Agent { } /** Upload a binary to the mocknet. */ - protected async doUpload (wasm: Uint8Array): Promise { - return new ContractTemplate(await this.chain.upload(wasm)) + protected async doUpload (wasm: Uint8Array): Promise { + return new ContractUpload(await this.chain.upload(wasm)) } /** Instantiate a contract on the mocknet. */ protected async doInstantiate ( - codeId: CodeId|Partial, + codeId: CodeId|Partial, options: { initMsg: Into } @@ -331,7 +331,7 @@ class MocknetAgent extends Agent { protected async doExecute ( contract: { address: Address }, message: Message, - options: ExecOpts = {} + options?: Parameters[2] ): Promise { return await this.chain.execute( this.address, diff --git a/connect/scrt/scrt.test.ts b/connect/scrt/scrt.test.ts index cf62aaa0491..943cba7238d 100644 --- a/connect/scrt/scrt.test.ts +++ b/connect/scrt/scrt.test.ts @@ -33,6 +33,7 @@ async function testScrtChain () { assert.ok(await chain.fetchLimits()) const alice = await chain.getAgent({ name: 'Alice' }).ready assert.ok(alice.address) + console.log({alice}) assert.ok((alice as Scrt.Agent).api instanceof SecretJS.SecretNetworkClient) const bob = await chain.getAgent({ name: 'Bob' }).ready //assert(alice.wallet instanceof SecretJS.Wallet) diff --git a/ops/project.ts b/ops/project.ts index c3dfd81e5c6..33b22b61800 100644 --- a/ops/project.ts +++ b/ops/project.ts @@ -2,7 +2,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . **/ import { - Console, Error, ContractTemplate, ContractInstance, Deployment, + Console, Error, ContractUpload, ContractInstance, Deployment, bold, timestamp, } from '@fadroma/connect' import type { @@ -31,7 +31,7 @@ const console = new Console(`@hackbg/fadroma ${version}`) export type ProjectOptions = Omit, 'root'|'templates'|'uploadStore'|'deployStore'> & { root?: OpaqueDirectory|string, - templates?: Record> + templates?: Record> uploadStore?: string|UploadStore deployStore?: string|DeployStore } @@ -146,12 +146,12 @@ export class Project extends CommandContext { this.log.info('Contract checksums at: ', bold(this.dirs.wasm.shortPath)) const templates = Object.entries(this.templates??{}) if (templates.length > 0) { - this.log.info('ContractTemplates in project:') + this.log.info('ContractUploads in project:') for (const [name, {repository,revision,workspace,crate,features}] of templates) { this.log.info('-', name)//, repository, revision, workspace, crate, features) } } else { - this.log.info('ContractTemplates in project: (none)') + this.log.info('ContractUploads in project: (none)') } this.log.br() this.log.info('Chain type: ', bold(chain?.constructor.name)) @@ -231,7 +231,7 @@ export class Project extends CommandContext { * Build templates with missing artifacts if sources are available. */ upload = this.command( 'upload', 'upload the project or specific contracts from it', - async (...names: string[]): Promise => { + async (...names: string[]): Promise => { let sources: Partial[] = await this.getSources(names) if (this.builder) sources = await this.builder.buildMany(sources) const options = { uploadStore: this.uploadStore, reupload: false } @@ -240,7 +240,7 @@ export class Project extends CommandContext { reupload = this.command( 'reupload', 'reupload the project or specific contracts from it', - async (...names: string[]): Promise => { + async (...names: string[]): Promise => { let sources: Partial[] = await this.getSources(names) if (this.builder) sources = await this.builder.buildMany(sources) const options = { uploadStore: this.uploadStore, reupload: true } @@ -260,7 +260,7 @@ export class Project extends CommandContext { const sources = names.map(name=>this.getTemplate(name)).filter((template, i)=>{ if (!template) this.log.warn(`No such template in project: ${names[i]}`) return !!template - }) as ContractTemplate[] + }) as ContractUpload[] if (sources.length < 1) { this.log.warn('Nothing to upload.') return [] @@ -343,7 +343,7 @@ export class Project extends CommandContext { * @returns Deployment|null */ getDeployment ( name?: string, - templates: Record> = {}, + templates: Record> = {}, contracts: Record> = {}, ): InstanceType { if (!name) { @@ -395,17 +395,17 @@ export class Project extends CommandContext { return crates } - getTemplate (name: string): ContractTemplate { - return this.templates[name] as ContractTemplate + getTemplate (name: string): ContractUpload { + return this.templates[name] as ContractUpload } setTemplate ( - name: string, value: string|Partial - ): ContractTemplate { + name: string, value: string|Partial + ): ContractUpload { const defaults = { workspace: this.root.path, revision: 'HEAD' } return this.templates[name] = - (typeof value === 'string') ? new ContractTemplate({ ...defaults, crate: value }) : - (value instanceof ContractTemplate) ? value : new ContractTemplate({ ...defaults, ...value }) + (typeof value === 'string') ? new ContractUpload({ ...defaults, crate: value }) : + (value instanceof ContractUpload) ? value : new ContractUpload({ ...defaults, ...value }) } /** @returns Boolean whether the project (as defined by fadroma.yml in root) exists */