-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cosmwasm msgs #158
Merged
Merged
Add cosmwasm msgs #158
Changes from 41 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
a272a3c
Add missing dep
abefernan 02b4f74
Add new types
abefernan 0327a36
Add execute details
abefernan 630156c
Add execute form
abefernan 910726f
Add instantiate details
abefernan 19ad69e
Add instantiate form
abefernan 8e8cb71
Add instantiate2 details
abefernan b3076b6
Add instantiate2 form
abefernan 8ffb2a7
Switch new forms and details
abefernan 9d46c88
Fix typos
abefernan 97d8c56
Fix remove error
abefernan 7ebb8f3
Add migrate types
abefernan 3d4f9de
Add migrate details
abefernan fad870c
Add migrate form
abefernan cc1fbc2
Merge branch 'master' into feat/add-cw-msgs
abefernan c60c395
Adapt to useChains hook
abefernan 726bde7
Add jsoneditor dep
abefernan a8acfa4
Add JsonEditor component
abefernan 089383a
Use JsonEditor in MsgExecuteContractForm
abefernan edc1c61
Use JsonEditor in MsgInstantiateContractForm
abefernan 1185857
Use JsonEditor in MsgInstantiateContract2Form
abefernan fd60bd5
Remove unneded dep from useEffect
abefernan 5cc4d50
Use JsonEditor in MsgMigrateContractForm
abefernan 5bee548
Remove "any" type. Use Mode type
abefernan eb02c72
Use lossy option
abefernan 70366ab
Use readonly JsonEditor to view msgs
abefernan ff805e3
Format msg properly for sending
abefernan fa77bc3
Add label validation to instantiate
abefernan 7a3d341
Set options in signing client
abefernan 7d261f5
Merge branch 'master' into feat/add-cw-msgs
abefernan b0a3483
Add macroCoinToMicroCoin helper
abefernan 379b993
Add tests for macroCoinToMicroCoin
abefernan bb1f131
Fix ChainInfo type import
abefernan 7cc9818
Use macroCoinToMicroCoin in MsgSend and CW msgs
abefernan 37beb3d
Use lockfile v3 with node 18 and npm 9
abefernan 33c874a
Merge branch 'master' into feat/add-cw-msgs
abefernan 2a1b6e8
Add amount checks back to instantiate msgs
abefernan 4fe6d79
Reorder form fields for migrate
abefernan 3bae106
Update cosmjs
abefernan 3c63c41
Merge branch 'master' into feat/add-cw-msgs
abefernan 5c6bf37
Update lockfile
abefernan 0f71ff5
Remove fix msg from details
abefernan faa7a24
Use salt as hex
abefernan 3d8e462
Add parseError instead of lossy
abefernan f62fa05
Return undefined msgContentUtf8Array
abefernan d6c1686
Remove fix msg. Use hex salt
abefernan d49baa2
Check empty salt
abefernan 62be9d6
Avoid sending form with JSON errors
abefernan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
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,64 @@ | ||
import { fromUtf8 } from "@cosmjs/encoding"; | ||
import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx"; | ||
import dynamic from "next/dynamic"; | ||
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(); | ||
|
||
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> | ||
<li> | ||
<JsonEditor readOnly content={{ json: JSON.parse(fromUtf8(msgValue.msg, true)) }} /> | ||
</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; | ||
} | ||
`}</style> | ||
</> | ||
); | ||
}; | ||
|
||
export default TxMsgExecuteContractDetails; |
84 changes: 84 additions & 0 deletions
84
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,84 @@ | ||||||
import { fromUtf8 } from "@cosmjs/encoding"; | ||||||
import { MsgInstantiateContract2 } from "cosmjs-types/cosmwasm/wasm/v1/tx"; | ||||||
import dynamic from "next/dynamic"; | ||||||
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(); | ||||||
|
||||||
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>Fix msg:</label> | ||||||
<div>{msgValue.fixMsg ? "Yes" : "No"}</div> | ||||||
</li> | ||||||
<li> | ||||||
<label>Salt:</label> | ||||||
<div>{fromUtf8(msgValue.salt, true)}</div> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be non-printable. I'd show it as hex.
Suggested change
|
||||||
</li> | ||||||
<li> | ||||||
<label>Funds:</label> | ||||||
<div>{printableCoins(msgValue.funds, chain)}</div> | ||||||
</li> | ||||||
<li> | ||||||
<JsonEditor readOnly content={{ json: JSON.parse(fromUtf8(msgValue.msg, true)) }} /> | ||||||
</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; | ||||||
} | ||||||
`}</style> | ||||||
</> | ||||||
); | ||||||
}; | ||||||
|
||||||
export default TxMsgInstantiateContract2Details; |
76 changes: 76 additions & 0 deletions
76
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,76 @@ | ||
import { fromUtf8 } from "@cosmjs/encoding"; | ||
import { MsgInstantiateContract } from "cosmjs-types/cosmwasm/wasm/v1/tx"; | ||
import dynamic from "next/dynamic"; | ||
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(); | ||
|
||
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> | ||
<li> | ||
<JsonEditor readOnly content={{ json: JSON.parse(fromUtf8(msgValue.msg, true)) }} /> | ||
</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; | ||
} | ||
`}</style> | ||
</> | ||
); | ||
}; | ||
|
||
export default TxMsgInstantiateContractDetails; |
58 changes: 58 additions & 0 deletions
58
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,58 @@ | ||
import { fromUtf8 } from "@cosmjs/encoding"; | ||
import { MsgMigrateContract } from "cosmjs-types/cosmwasm/wasm/v1/tx"; | ||
import dynamic from "next/dynamic"; | ||
import HashView from "../HashView"; | ||
|
||
const JsonEditor = dynamic(() => import("../../inputs/JsonEditor"), { ssr: false }); | ||
|
||
interface TxMsgMigrateContractDetailsProps { | ||
readonly msgValue: MsgMigrateContract; | ||
} | ||
|
||
const TxMsgMigrateContractDetails = ({ msgValue }: TxMsgMigrateContractDetailsProps) => ( | ||
<> | ||
<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> | ||
<li> | ||
<JsonEditor readOnly content={{ json: JSON.parse(fromUtf8(msgValue.msg, true)) }} /> | ||
</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; | ||
} | ||
`}</style> | ||
</> | ||
); | ||
|
||
export default TxMsgMigrateContractDetails; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What's the reason for using lossy mode (
true
) here? I think if the contents of the variable is not valid UTF-8, something went wrong and we should throw.