-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from cosmos/feat/add-cw-msgs
Add cosmwasm msgs
- Loading branch information
Showing
21 changed files
with
1,800 additions
and
31 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
components/dataViews/TransactionInfo/TxMsgExecuteContractDetails.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { fromUtf8 } from "@cosmjs/encoding"; | ||
import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx"; | ||
import dynamic from "next/dynamic"; | ||
import { useState } from "react"; | ||
import { JSONValue } from "vanilla-jsoneditor"; | ||
import { useChains } from "../../../context/ChainsContext"; | ||
import { printableCoins } from "../../../lib/displayHelpers"; | ||
import HashView from "../HashView"; | ||
|
||
const JsonEditor = dynamic(() => import("../../inputs/JsonEditor"), { ssr: false }); | ||
|
||
interface TxMsgExecuteContractDetailsProps { | ||
readonly msgValue: MsgExecuteContract; | ||
} | ||
|
||
const TxMsgExecuteContractDetails = ({ msgValue }: TxMsgExecuteContractDetailsProps) => { | ||
const { chain } = useChains(); | ||
const [parseError, setParseError] = useState(""); | ||
|
||
const json: JSONValue = (() => { | ||
if (parseError) { | ||
return {}; | ||
} | ||
|
||
try { | ||
return JSON.parse(fromUtf8(msgValue.msg)); | ||
} catch (e) { | ||
setParseError(e instanceof Error ? e.message : "Failed to decode UTF-8 msg"); | ||
return {}; | ||
} | ||
})(); | ||
|
||
return ( | ||
<> | ||
<li> | ||
<h3>MsgExecuteContract</h3> | ||
</li> | ||
<li> | ||
<label>Contract:</label> | ||
<div title={msgValue.contract}> | ||
<HashView hash={msgValue.contract} /> | ||
</div> | ||
</li> | ||
<li> | ||
<label>Funds:</label> | ||
<div>{printableCoins(msgValue.funds, chain)}</div> | ||
</li> | ||
{parseError ? ( | ||
<li className="parse-error"> | ||
<p>{parseError}</p> | ||
</li> | ||
) : ( | ||
<li> | ||
<JsonEditor readOnly content={{ json }} /> | ||
</li> | ||
)} | ||
<style jsx>{` | ||
li:not(:has(h3)) { | ||
background: rgba(255, 255, 255, 0.03); | ||
padding: 6px 10px; | ||
border-radius: 8px; | ||
display: flex; | ||
align-items: center; | ||
} | ||
li + li:nth-child(2) { | ||
margin-top: 25px; | ||
} | ||
li + li { | ||
margin-top: 10px; | ||
} | ||
li div { | ||
padding: 3px 6px; | ||
} | ||
label { | ||
font-size: 12px; | ||
background: rgba(255, 255, 255, 0.1); | ||
padding: 3px 6px; | ||
border-radius: 5px; | ||
display: block; | ||
} | ||
.parse-error p { | ||
max-width: 550px; | ||
color: red; | ||
font-size: 16px; | ||
line-height: 1.4; | ||
} | ||
`}</style> | ||
</> | ||
); | ||
}; | ||
|
||
export default TxMsgExecuteContractDetails; |
108 changes: 108 additions & 0 deletions
108
components/dataViews/TransactionInfo/TxMsgInstantiateContract2Details.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { fromUtf8, toHex } from "@cosmjs/encoding"; | ||
import { MsgInstantiateContract2 } from "cosmjs-types/cosmwasm/wasm/v1/tx"; | ||
import dynamic from "next/dynamic"; | ||
import { useState } from "react"; | ||
import { JSONValue } from "vanilla-jsoneditor"; | ||
import { useChains } from "../../../context/ChainsContext"; | ||
import { printableCoins } from "../../../lib/displayHelpers"; | ||
import HashView from "../HashView"; | ||
|
||
const JsonEditor = dynamic(() => import("../../inputs/JsonEditor"), { ssr: false }); | ||
|
||
interface TxMsgInstantiateContract2DetailsProps { | ||
readonly msgValue: MsgInstantiateContract2; | ||
} | ||
|
||
const TxMsgInstantiateContract2Details = ({ msgValue }: TxMsgInstantiateContract2DetailsProps) => { | ||
const { chain } = useChains(); | ||
const [parseError, setParseError] = useState(""); | ||
|
||
const json: JSONValue = (() => { | ||
if (parseError) { | ||
return {}; | ||
} | ||
|
||
try { | ||
return JSON.parse(fromUtf8(msgValue.msg)); | ||
} catch (e) { | ||
setParseError(e instanceof Error ? e.message : "Failed to decode UTF-8 msg"); | ||
return {}; | ||
} | ||
})(); | ||
|
||
return ( | ||
<> | ||
<li> | ||
<h3>MsgInstantiateContract2</h3> | ||
</li> | ||
<li> | ||
<label>Code ID:</label> | ||
<div>{msgValue.codeId.toString()}</div> | ||
</li> | ||
<li> | ||
<label>Label:</label> | ||
<div>{msgValue.label || "None"}</div> | ||
</li> | ||
<li> | ||
<label>Admin:</label> | ||
{msgValue.admin ? ( | ||
<div title={msgValue.admin}> | ||
<HashView hash={msgValue.admin} /> | ||
</div> | ||
) : ( | ||
<div>None</div> | ||
)} | ||
</li> | ||
<li> | ||
<label>Salt:</label> | ||
<div>{toHex(msgValue.salt)}</div> | ||
</li> | ||
<li> | ||
<label>Funds:</label> | ||
<div>{printableCoins(msgValue.funds, chain)}</div> | ||
</li> | ||
{parseError ? ( | ||
<li className="parse-error"> | ||
<p>{parseError}</p> | ||
</li> | ||
) : ( | ||
<li> | ||
<JsonEditor readOnly content={{ json }} /> | ||
</li> | ||
)} | ||
<style jsx>{` | ||
li:not(:has(h3)) { | ||
background: rgba(255, 255, 255, 0.03); | ||
padding: 6px 10px; | ||
border-radius: 8px; | ||
display: flex; | ||
align-items: center; | ||
} | ||
li + li:nth-child(2) { | ||
margin-top: 25px; | ||
} | ||
li + li { | ||
margin-top: 10px; | ||
} | ||
li div { | ||
padding: 3px 6px; | ||
} | ||
label { | ||
font-size: 12px; | ||
background: rgba(255, 255, 255, 0.1); | ||
padding: 3px 6px; | ||
border-radius: 5px; | ||
display: block; | ||
} | ||
.parse-error p { | ||
max-width: 550px; | ||
color: red; | ||
font-size: 16px; | ||
line-height: 1.4; | ||
} | ||
`}</style> | ||
</> | ||
); | ||
}; | ||
|
||
export default TxMsgInstantiateContract2Details; |
104 changes: 104 additions & 0 deletions
104
components/dataViews/TransactionInfo/TxMsgInstantiateContractDetails.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import { fromUtf8 } from "@cosmjs/encoding"; | ||
import { MsgInstantiateContract } from "cosmjs-types/cosmwasm/wasm/v1/tx"; | ||
import dynamic from "next/dynamic"; | ||
import { useState } from "react"; | ||
import { JSONValue } from "vanilla-jsoneditor"; | ||
import { useChains } from "../../../context/ChainsContext"; | ||
import { printableCoins } from "../../../lib/displayHelpers"; | ||
import HashView from "../HashView"; | ||
|
||
const JsonEditor = dynamic(() => import("../../inputs/JsonEditor"), { ssr: false }); | ||
|
||
interface TxMsgInstantiateContractDetailsProps { | ||
readonly msgValue: MsgInstantiateContract; | ||
} | ||
|
||
const TxMsgInstantiateContractDetails = ({ msgValue }: TxMsgInstantiateContractDetailsProps) => { | ||
const { chain } = useChains(); | ||
const [parseError, setParseError] = useState(""); | ||
|
||
const json: JSONValue = (() => { | ||
if (parseError) { | ||
return {}; | ||
} | ||
|
||
try { | ||
return JSON.parse(fromUtf8(msgValue.msg)); | ||
} catch (e) { | ||
setParseError(e instanceof Error ? e.message : "Failed to decode UTF-8 msg"); | ||
return {}; | ||
} | ||
})(); | ||
|
||
return ( | ||
<> | ||
<li> | ||
<h3>MsgInstantiateContract</h3> | ||
</li> | ||
<li> | ||
<label>Code ID:</label> | ||
<div>{msgValue.codeId.toString()}</div> | ||
</li> | ||
<li> | ||
<label>Label:</label> | ||
<div>{msgValue.label || "None"}</div> | ||
</li> | ||
<li> | ||
<label>Admin:</label> | ||
{msgValue.admin ? ( | ||
<div title={msgValue.admin}> | ||
<HashView hash={msgValue.admin} /> | ||
</div> | ||
) : ( | ||
<div>None</div> | ||
)} | ||
</li> | ||
<li> | ||
<label>Funds:</label> | ||
<div>{printableCoins(msgValue.funds, chain)}</div> | ||
</li> | ||
{parseError ? ( | ||
<li className="parse-error"> | ||
<p>{parseError}</p> | ||
</li> | ||
) : ( | ||
<li> | ||
<JsonEditor readOnly content={{ json }} /> | ||
</li> | ||
)} | ||
<style jsx>{` | ||
li:not(:has(h3)) { | ||
background: rgba(255, 255, 255, 0.03); | ||
padding: 6px 10px; | ||
border-radius: 8px; | ||
display: flex; | ||
align-items: center; | ||
} | ||
li + li:nth-child(2) { | ||
margin-top: 25px; | ||
} | ||
li + li { | ||
margin-top: 10px; | ||
} | ||
li div { | ||
padding: 3px 6px; | ||
} | ||
label { | ||
font-size: 12px; | ||
background: rgba(255, 255, 255, 0.1); | ||
padding: 3px 6px; | ||
border-radius: 5px; | ||
display: block; | ||
} | ||
.parse-error p { | ||
max-width: 550px; | ||
color: red; | ||
font-size: 16px; | ||
line-height: 1.4; | ||
} | ||
`}</style> | ||
</> | ||
); | ||
}; | ||
|
||
export default TxMsgInstantiateContractDetails; |
89 changes: 89 additions & 0 deletions
89
components/dataViews/TransactionInfo/TxMsgMigrateContractDetails.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { fromUtf8 } from "@cosmjs/encoding"; | ||
import { MsgMigrateContract } from "cosmjs-types/cosmwasm/wasm/v1/tx"; | ||
import dynamic from "next/dynamic"; | ||
import { useState } from "react"; | ||
import { JSONValue } from "vanilla-jsoneditor"; | ||
import HashView from "../HashView"; | ||
|
||
const JsonEditor = dynamic(() => import("../../inputs/JsonEditor"), { ssr: false }); | ||
|
||
interface TxMsgMigrateContractDetailsProps { | ||
readonly msgValue: MsgMigrateContract; | ||
} | ||
|
||
const TxMsgMigrateContractDetails = ({ msgValue }: TxMsgMigrateContractDetailsProps) => { | ||
const [parseError, setParseError] = useState(""); | ||
|
||
const json: JSONValue = (() => { | ||
if (parseError) { | ||
return {}; | ||
} | ||
|
||
try { | ||
return JSON.parse(fromUtf8(msgValue.msg)); | ||
} catch (e) { | ||
setParseError(e instanceof Error ? e.message : "Failed to decode UTF-8 msg"); | ||
return {}; | ||
} | ||
})(); | ||
|
||
return ( | ||
<> | ||
<li> | ||
<h3>MsgMigrateContract</h3> | ||
</li> | ||
<li> | ||
<label>Contract:</label> | ||
<div title={msgValue.contract}> | ||
<HashView hash={msgValue.contract} /> | ||
</div> | ||
</li> | ||
<li> | ||
<label>Code ID:</label> | ||
<div>{msgValue.codeId.toString()}</div> | ||
</li> | ||
{parseError ? ( | ||
<li className="parse-error"> | ||
<p>{parseError}</p> | ||
</li> | ||
) : ( | ||
<li> | ||
<JsonEditor readOnly content={{ json }} /> | ||
</li> | ||
)} | ||
<style jsx>{` | ||
li:not(:has(h3)) { | ||
background: rgba(255, 255, 255, 0.03); | ||
padding: 6px 10px; | ||
border-radius: 8px; | ||
display: flex; | ||
align-items: center; | ||
} | ||
li + li:nth-child(2) { | ||
margin-top: 25px; | ||
} | ||
li + li { | ||
margin-top: 10px; | ||
} | ||
li div { | ||
padding: 3px 6px; | ||
} | ||
label { | ||
font-size: 12px; | ||
background: rgba(255, 255, 255, 0.1); | ||
padding: 3px 6px; | ||
border-radius: 5px; | ||
display: block; | ||
} | ||
.parse-error p { | ||
max-width: 550px; | ||
color: red; | ||
font-size: 16px; | ||
line-height: 1.4; | ||
} | ||
`}</style> | ||
</> | ||
); | ||
}; | ||
|
||
export default TxMsgMigrateContractDetails; |
Oops, something went wrong.
1f07721
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
cosmos-multisig-ui – ./
cosmos-multisig-ui-interchain.vercel.app
cosmos-multisig-ui-git-master-interchain.vercel.app
cosmos-multisig-ui-kohl.vercel.app