mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
85 lines
1.7 KiB
TypeScript
85 lines
1.7 KiB
TypeScript
import { Coin } from "@cosmjs/amino";
|
|
import { toBase64, toUtf8 } from "@cosmjs/encoding";
|
|
|
|
// types auto-generated by wasm.glass and cleaned up manually
|
|
export type HandleMsg =
|
|
| {
|
|
reflectmsg: {
|
|
msgs: (
|
|
| {
|
|
send: {
|
|
amount: Coin[];
|
|
from_address: string;
|
|
to_address: string;
|
|
};
|
|
}
|
|
| {
|
|
contract: {
|
|
contract_addr: string;
|
|
// this had to be changed - is Base64 encoded string
|
|
msg: string;
|
|
send: Coin[] | null;
|
|
};
|
|
}
|
|
| {
|
|
opaque: {
|
|
// this had to be changed - is Base64 encoded string
|
|
data: string;
|
|
};
|
|
}
|
|
)[];
|
|
};
|
|
}
|
|
| {
|
|
changeowner: {
|
|
owner: string;
|
|
};
|
|
};
|
|
|
|
export interface InitMsg {}
|
|
|
|
export interface OwnerResponse {
|
|
owner: string;
|
|
}
|
|
|
|
export type QueryMsg = {
|
|
owner: {};
|
|
};
|
|
|
|
export interface State {
|
|
// base64 encoded CanonicalAddress
|
|
owner: string;
|
|
}
|
|
|
|
/*** END auto-gen ****/
|
|
|
|
const base64Msg = (msg: object): string => toBase64(toUtf8(JSON.stringify(msg)));
|
|
|
|
const sendMsg = (from_address: string, to_address: string, amount: Coin[]) => {
|
|
return {
|
|
send: {
|
|
from_address,
|
|
to_address,
|
|
amount,
|
|
},
|
|
};
|
|
};
|
|
|
|
const contractMsg = (contract_addr: string, msg: object, amount?: Coin[]) => {
|
|
return {
|
|
contract: {
|
|
contract_addr,
|
|
msg: base64Msg(msg),
|
|
send: amount || null,
|
|
},
|
|
};
|
|
};
|
|
|
|
const opaqueMsg = (data: object) => {
|
|
return {
|
|
opaque: {
|
|
data: base64Msg(data),
|
|
},
|
|
};
|
|
};
|