Skip to content
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

Feat #297 Support default values from rich contract data #349

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
309b5b0
Support default values from rich contract data
rulfo71 Sep 26, 2022
dea9b12
Merge remote-tracking branch 'upstream/develop' into default-values-f…
rulfo71 Sep 26, 2022
23c4d5d
update snapshots
rulfo71 Sep 26, 2022
376bf6e
fix case default value is 0.0 on numericalInput
rulfo71 Sep 27, 2022
5137289
update snapshots
rulfo71 Sep 27, 2022
0cb3781
Merge remote-tracking branch 'upstream/develop' into default-values-f…
rulfo71 Sep 30, 2022
b5d950c
show unlock icon if param has defaultValue
rulfo71 Oct 3, 2022
e8be4e3
fix name setDisabledState
rulfo71 Oct 10, 2022
efe036d
remove unlock icon when clicked
rulfo71 Oct 23, 2022
6dc20c7
fix voting functions on actions had the same name
rulfo71 Oct 23, 2022
14a4a22
added tests
rulfo71 Oct 24, 2022
559949c
change tests on addressInput to IconRight
rulfo71 Oct 25, 2022
93c7738
Merge remote-tracking branch 'upstream/develop' into default-values-f…
rulfo71 Oct 25, 2022
cea2448
updated richContracts.json
rulfo71 Oct 31, 2022
b66db43
updated richContracts.json
rulfo71 Oct 31, 2022
70cd0ea
using function title instead of function name because name may be rep…
rulfo71 Oct 31, 2022
006af36
update description on richContracts
rulfo71 Nov 1, 2022
1be9c5a
update templateLiteral on richContracts
rulfo71 Nov 1, 2022
c7ab8be
support more than one action on an external contract
rulfo71 Nov 3, 2022
1d72b2d
Merge remote-tracking branch 'upstream/develop' into default-values-f…
rulfo71 Nov 7, 2022
8ff96a8
update richContracts.json
rulfo71 Nov 7, 2022
03427cf
fix network address on richContract json was repeated
rulfo71 Nov 9, 2022
8e1f86b
Merge remote-tracking branch 'upstream/develop' into default-values-f…
rulfo71 Nov 10, 2022
631f11d
fix on getting richContracts from ens
rulfo71 Nov 11, 2022
5f2695c
add validation for bytes32
rulfo71 Nov 17, 2022
a2890ac
shorten proposalId on action
rulfo71 Nov 17, 2022
eb0d868
change name of variable for consistency
rulfo71 Nov 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions richContracts.json
Expand Up @@ -59,7 +59,7 @@
"tags": ["DXgov", "Guilds", "permissions"],
"networks": {
"5": "0x885b28d6b93087623483af5e5f7362bd6d8a0a6b",
"1337": "0x0000000000000000000000000000000000000000"
"1337": "0x885b28d6b93087623483af5e5f7362bd6d8a0a6b"
},
"functions": [
{
Expand Down Expand Up @@ -97,7 +97,7 @@
"1": "0x332B8C9734b4097dE50f302F7D9F273FFdB45B84",
"5": "0xC284e9F6aBc7c65C277244895CAae401e643E4b6",
"100": "0xDA309aDF1c84242Bb446F7CDBa96B570E901D4CF",
"1337": "0x0000000000000000000000000000000000000000"
"1337": "0x332B8C9734b4097dE50f302F7D9F273FFdB45B84"
},
"functions": [
{
Expand Down Expand Up @@ -175,7 +175,7 @@
"title": "Voter",
"defaultValue": "0x99Fa013188d5f1dB6836Ee8805Ef37BE70ff10BE",
"description": "The guild's address"
}
}
],
"shortDescription": "Votes on a proposal with the guild's power",
"longDescription": "Creates a mirror proposal to use this guild's power to vote on a DXdao proposal. Care needs to be taken to finish this proposal before the DXdao proposal finishes.",
Expand Down Expand Up @@ -304,3 +304,4 @@
]
}
]

Expand Up @@ -126,6 +126,18 @@ exports[`ERC20TransferEditor Should match snapshot 1`] = `
padding: 0;
}

.c10 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
cursor: pointer;
}

.c1 {
display: -webkit-box;
display: -webkit-flex;
Expand Down Expand Up @@ -163,18 +175,6 @@ exports[`ERC20TransferEditor Should match snapshot 1`] = `
align-items: stretch;
}

.c10 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
cursor: pointer;
}

.c11 {
margin-right: 1rem;
}
Expand Down Expand Up @@ -211,7 +211,7 @@ exports[`ERC20TransferEditor Should match snapshot 1`] = `
</div>
</div>
<input
aria-label="recipient address input"
aria-label="address input"
class="c8"
data-testid="address input"
name="recipient-address"
Expand Down Expand Up @@ -276,6 +276,7 @@ exports[`ERC20TransferEditor Should match snapshot 1`] = `
class="c5"
/>
<input
aria-label="numerical input"
autocomplete="off"
autocorrect="off"
class="c8"
Expand All @@ -291,7 +292,38 @@ exports[`ERC20TransferEditor Should match snapshot 1`] = `
/>
<div
class="c9"
/>
>
<div
aria-label="clear number"
class="c0 c10"
data-testid="clear number"
>
<svg
fill="none"
height="18"
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
viewBox="0 0 24 24"
width="18"
xmlns="http://www.w3.org/2000/svg"
>
<line
x1="18"
x2="6"
y1="6"
y2="18"
/>
<line
x1="6"
x2="18"
y1="6"
y2="18"
/>
</svg>
</div>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -486,6 +518,18 @@ exports[`ERC20TransferEditor Should match snapshot with an address without ENS n
padding: 0;
}

.c10 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
cursor: pointer;
}

.c1 {
display: -webkit-box;
display: -webkit-flex;
Expand Down Expand Up @@ -523,18 +567,6 @@ exports[`ERC20TransferEditor Should match snapshot with an address without ENS n
align-items: stretch;
}

.c10 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
cursor: pointer;
}

.c11 {
margin-right: 1rem;
}
Expand Down Expand Up @@ -571,7 +603,7 @@ exports[`ERC20TransferEditor Should match snapshot with an address without ENS n
</div>
</div>
<input
aria-label="recipient address input"
aria-label="address input"
class="c8"
data-testid="address input"
name="recipient-address"
Expand Down Expand Up @@ -636,6 +668,7 @@ exports[`ERC20TransferEditor Should match snapshot with an address without ENS n
class="c5"
/>
<input
aria-label="numerical input"
autocomplete="off"
autocorrect="off"
class="c8"
Expand All @@ -651,7 +684,38 @@ exports[`ERC20TransferEditor Should match snapshot with an address without ENS n
/>
<div
class="c9"
/>
>
<div
aria-label="clear number"
class="c0 c10"
data-testid="clear number"
>
<svg
fill="none"
height="18"
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
viewBox="0 0 24 24"
width="18"
xmlns="http://www.w3.org/2000/svg"
>
<line
x1="18"
x2="6"
y1="6"
y2="18"
/>
<line
x1="6"
x2="18"
y1="6"
y2="18"
/>
</svg>
</div>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -721,7 +785,7 @@ exports[`ERC20TransferEditor Should match snapshot with an address without ENS n
`;

exports[`ERC20TransferEditor Should match snapshot with default values 1`] = `
.c9 {
.c10 {
display: -webkit-inline-box;
display: -webkit-inline-flex;
display: -ms-inline-flexbox;
Expand All @@ -747,17 +811,17 @@ exports[`ERC20TransferEditor Should match snapshot with default values 1`] = `
margin: 1rem 0 0;
}

.c9:disabled {
.c10:disabled {
color: initial;
opacity: 0.4;
cursor: auto;
}

.c9:hover:enabled {
.c10:hover:enabled {
border-color: #fff;
}

.c9:active:enabled {
.c10:active:enabled {
border: 1px solid #303338;
}

Expand Down Expand Up @@ -835,6 +899,18 @@ exports[`ERC20TransferEditor Should match snapshot with default values 1`] = `
padding: 0;
}

.c8 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
cursor: pointer;
}

.c1 {
display: -webkit-box;
display: -webkit-flex;
Expand Down Expand Up @@ -872,7 +948,7 @@ exports[`ERC20TransferEditor Should match snapshot with default values 1`] = `
align-items: stretch;
}

.c8 {
.c9 {
margin-right: 1rem;
}

Expand Down Expand Up @@ -900,7 +976,7 @@ exports[`ERC20TransferEditor Should match snapshot with default values 1`] = `
<div />
</div>
<input
aria-label="recipient address input"
aria-label="address input"
class="c6"
data-testid="address input"
name="recipient-address"
Expand Down Expand Up @@ -934,6 +1010,7 @@ exports[`ERC20TransferEditor Should match snapshot with default values 1`] = `
class="c5"
/>
<input
aria-label="numerical input"
autocomplete="off"
autocorrect="off"
class="c6"
Expand All @@ -949,12 +1026,43 @@ exports[`ERC20TransferEditor Should match snapshot with default values 1`] = `
/>
<div
class="c7"
/>
>
<div
aria-label="clear number"
class="c0 c8"
data-testid="clear number"
>
<svg
fill="none"
height="18"
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
viewBox="0 0 24 24"
width="18"
xmlns="http://www.w3.org/2000/svg"
>
<line
x1="18"
x2="6"
y1="6"
y2="18"
/>
<line
x1="6"
x2="18"
y1="6"
y2="18"
/>
</svg>
</div>
</div>
</div>
</div>
</div>
<div
class="c0 c8"
class="c0 c9"
/>
<div
class="c0 c1"
Expand Down Expand Up @@ -1006,7 +1114,7 @@ exports[`ERC20TransferEditor Should match snapshot with default values 1`] = `
</div>
</div>
<button
class="c9"
class="c10"
data-testid="submit-erc20transfer"
type="submit"
>
Expand Down
Expand Up @@ -32,9 +32,13 @@ const GenericCallInfoLine: React.FC<ActionViewProps> = ({
);
const { functionData } = useRichContractData(decodedCall);

function getStringForParam(type: string, value: any) {
function getReadableStringForParam(type: string, value: any, name: string) {
if (!type || !value) return null;

if (name === 'proposalId') {
return `${value.substring(0, 6)}...${value.substring(value.length - 4)}`;
}

if (type.startsWith('uint') || type.startsWith('int')) {
return BigNumber.from(value).toString();
}
Expand All @@ -47,7 +51,11 @@ const GenericCallInfoLine: React.FC<ActionViewProps> = ({
return functionData.params
.map(param => ({
...param,
value: getStringForParam(param.type, decodedCall.args[param.name]),
value: getReadableStringForParam(
param.type,
decodedCall.args[param.name],
param.name
),
}))
.concat(getTokenInfoParsedParams(tokenInfo));
}, [functionData, decodedCall, tokenInfo]);
Expand Down