Merge pull request #831 from cosmos/806-instantiate-options-funds
Rename InstantiateOptions.transferAmount -> .funds
This commit is contained in:
commit
97e3d56136
@ -18,6 +18,12 @@ and this project adheres to
|
||||
|
||||
### Changed
|
||||
|
||||
- @cosmjs/cosmwasm-launchpad: The `transferAmount` property on
|
||||
`InstantiateOptions` (accepted as a parameter to
|
||||
`SigningCosmWasmClient.instantiate`) has been renamed to `funds`.
|
||||
- @cosmjs/cosmwasm-stargate: The `transferAmount` property on
|
||||
`InstantiateOptions` (accepted as a parameter to
|
||||
`SigningCosmWasmClient.instantiate`) has been renamed to `funds`.
|
||||
- @cosmjs/tendermint-rpc: Make `tendermint34.Header.lastBlockId` and
|
||||
`tendermint34.Block.lastCommit` optional to better handle the case of height 1
|
||||
where there is no previous block.
|
||||
|
||||
@ -311,7 +311,7 @@ describe("SigningCosmWasmClient", () => {
|
||||
"My cool label",
|
||||
{
|
||||
memo: "Let's see if the memo is used",
|
||||
transferAmount: funds,
|
||||
funds: funds,
|
||||
},
|
||||
);
|
||||
|
||||
@ -491,7 +491,7 @@ describe("SigningCosmWasmClient", () => {
|
||||
},
|
||||
"amazing random contract",
|
||||
{
|
||||
transferAmount: funds,
|
||||
funds: funds,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@ -108,10 +108,8 @@ export interface InstantiateOptions {
|
||||
* created and before the instantiation message is executed by the contract.
|
||||
*
|
||||
* Only native tokens are supported.
|
||||
*
|
||||
* TODO: Rename to `funds` for consistency (https://github.com/cosmos/cosmjs/issues/806)
|
||||
*/
|
||||
readonly transferAmount?: readonly Coin[];
|
||||
readonly funds?: readonly Coin[];
|
||||
/**
|
||||
* A bech32 encoded address of an admin account.
|
||||
* Caution: an admin has the privilege to upgrade a contract. If this is not desired, do not set this value.
|
||||
@ -238,7 +236,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
code_id: new Uint53(codeId).toString(),
|
||||
label: label,
|
||||
init_msg: msg,
|
||||
init_funds: options.transferAmount || [],
|
||||
init_funds: options.funds || [],
|
||||
admin: options.admin,
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { Secp256k1HdWallet } from "@cosmjs/amino";
|
||||
import { UploadMeta } from "@cosmjs/cosmwasm-launchpad";
|
||||
import { sha256 } from "@cosmjs/crypto";
|
||||
import { toHex } from "@cosmjs/encoding";
|
||||
import { decodeTxRaw, DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing";
|
||||
@ -25,7 +24,7 @@ import pako from "pako";
|
||||
import protobuf from "protobufjs/minimal";
|
||||
|
||||
import { MsgStoreCodeEncodeObject } from "./encodeobjects";
|
||||
import { SigningCosmWasmClient } from "./signingcosmwasmclient";
|
||||
import { SigningCosmWasmClient, UploadMeta } from "./signingcosmwasmclient";
|
||||
import {
|
||||
alice,
|
||||
getHackatom,
|
||||
@ -273,7 +272,7 @@ describe("SigningCosmWasmClient", () => {
|
||||
"My cool label",
|
||||
{
|
||||
memo: "Let's see if the memo is used",
|
||||
transferAmount: funds,
|
||||
funds: funds,
|
||||
},
|
||||
);
|
||||
const wasmClient = await makeWasmClient(wasmd.endpoint);
|
||||
@ -454,7 +453,7 @@ describe("SigningCosmWasmClient", () => {
|
||||
},
|
||||
"amazing random contract",
|
||||
{
|
||||
transferAmount: funds,
|
||||
funds: funds,
|
||||
},
|
||||
);
|
||||
// execute
|
||||
|
||||
@ -1,15 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { encodeSecp256k1Pubkey, makeSignDoc as makeSignDocAmino } from "@cosmjs/amino";
|
||||
import {
|
||||
ChangeAdminResult,
|
||||
ExecuteResult,
|
||||
InstantiateOptions,
|
||||
InstantiateResult,
|
||||
isValidBuilder,
|
||||
MigrateResult,
|
||||
UploadMeta,
|
||||
UploadResult,
|
||||
} from "@cosmjs/cosmwasm-launchpad";
|
||||
import { isValidBuilder } from "@cosmjs/cosmwasm-launchpad";
|
||||
import { sha256 } from "@cosmjs/crypto";
|
||||
import { fromBase64, toHex, toUtf8 } from "@cosmjs/encoding";
|
||||
import { Int53, Uint53 } from "@cosmjs/math";
|
||||
@ -72,18 +63,6 @@ import {
|
||||
MsgUpdateAdminEncodeObject,
|
||||
} from "./encodeobjects";
|
||||
|
||||
// Those types can be copied over to allow them to evolve independently of @cosmjs/cosmwasm-launchpad.
|
||||
// For now just re-export them such that they can be imported via @cosmjs/cosmwasm-stargate.
|
||||
export {
|
||||
ChangeAdminResult, // returned by SigningCosmWasmClient.updateAdmin/SigningCosmWasmClient.clearAdmin
|
||||
ExecuteResult, // returned by SigningCosmWasmClient.execute
|
||||
InstantiateOptions, // argument type of SigningCosmWasmClient.instantiate
|
||||
InstantiateResult, // returned by SigningCosmWasmClient.instantiate
|
||||
MigrateResult, // returned by SigningCosmWasmClient.migrate
|
||||
UploadMeta, // argument type of SigningCosmWasmClient.upload
|
||||
UploadResult, // returned by SigningCosmWasmClient.upload
|
||||
};
|
||||
|
||||
/**
|
||||
* These fees are used by the higher level methods of SigningCosmWasmClient
|
||||
*/
|
||||
@ -114,6 +93,88 @@ export const defaultGasLimits: GasLimits<CosmWasmFeeTable> = {
|
||||
changeAdmin: 80_000,
|
||||
};
|
||||
|
||||
export interface UploadMeta {
|
||||
/**
|
||||
* An URL to a .tar.gz archive of the source code of the contract, which can be used to reproducibly build the Wasm bytecode.
|
||||
*
|
||||
* @see https://github.com/CosmWasm/cosmwasm-verify
|
||||
*/
|
||||
readonly source?: string;
|
||||
/**
|
||||
* A docker image (including version) to reproducibly build the Wasm bytecode from the source code.
|
||||
*
|
||||
* @example ```cosmwasm/rust-optimizer:0.8.0```
|
||||
* @see https://github.com/CosmWasm/cosmwasm-verify
|
||||
*/
|
||||
readonly builder?: string;
|
||||
}
|
||||
|
||||
export interface UploadResult {
|
||||
/** Size of the original wasm code in bytes */
|
||||
readonly originalSize: number;
|
||||
/** A hex encoded sha256 checksum of the original wasm code (that is stored on chain) */
|
||||
readonly originalChecksum: string;
|
||||
/** Size of the compressed wasm code in bytes */
|
||||
readonly compressedSize: number;
|
||||
/** A hex encoded sha256 checksum of the compressed wasm code (that stored in the transaction) */
|
||||
readonly compressedChecksum: string;
|
||||
/** The ID of the code asigned by the chain */
|
||||
readonly codeId: number;
|
||||
readonly logs: readonly logs.Log[];
|
||||
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
|
||||
readonly transactionHash: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The options of an .instantiate() call.
|
||||
* All properties are optional.
|
||||
*/
|
||||
export interface InstantiateOptions {
|
||||
readonly memo?: string;
|
||||
/**
|
||||
* The funds that are transferred from the sender to the newly created contract.
|
||||
* The funds are transferred as part of the message execution after the contract address is
|
||||
* created and before the instantiation message is executed by the contract.
|
||||
*
|
||||
* Only native tokens are supported.
|
||||
*/
|
||||
readonly funds?: readonly Coin[];
|
||||
/**
|
||||
* A bech32 encoded address of an admin account.
|
||||
* Caution: an admin has the privilege to upgrade a contract. If this is not desired, do not set this value.
|
||||
*/
|
||||
readonly admin?: string;
|
||||
}
|
||||
|
||||
export interface InstantiateResult {
|
||||
/** The address of the newly instantiated contract */
|
||||
readonly contractAddress: string;
|
||||
readonly logs: readonly logs.Log[];
|
||||
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
|
||||
readonly transactionHash: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Result type of updateAdmin and clearAdmin
|
||||
*/
|
||||
export interface ChangeAdminResult {
|
||||
readonly logs: readonly logs.Log[];
|
||||
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
|
||||
readonly transactionHash: string;
|
||||
}
|
||||
|
||||
export interface MigrateResult {
|
||||
readonly logs: readonly logs.Log[];
|
||||
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
|
||||
readonly transactionHash: string;
|
||||
}
|
||||
|
||||
export interface ExecuteResult {
|
||||
readonly logs: readonly logs.Log[];
|
||||
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
|
||||
readonly transactionHash: string;
|
||||
}
|
||||
|
||||
function createBroadcastTxErrorMessage(result: BroadcastTxFailure): string {
|
||||
return `Error when broadcasting tx ${result.transactionHash} at height ${result.height}. Code: ${result.code}; Raw log: ${result.rawLog}`;
|
||||
}
|
||||
@ -245,7 +306,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
codeId: Long.fromString(new Uint53(codeId).toString()),
|
||||
label: label,
|
||||
initMsg: toUtf8(JSON.stringify(msg)),
|
||||
funds: [...(options.transferAmount || [])],
|
||||
funds: [...(options.funds || [])],
|
||||
admin: options.admin,
|
||||
}),
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user