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

Support nested vector in explorer #681

Merged
merged 5 commits into from
May 2, 2024
Merged

Support nested vector in explorer #681

merged 5 commits into from
May 2, 2024

Conversation

BriungRi
Copy link
Contributor

@BriungRi BriungRi commented Mar 1, 2024

Use JSON.parse to handle parsing [] arguments.

Previously, [[abc]] would be parsed as ["[abc]"], but really, it should be [["abc"]]`.

The noteworthy change here is that quotes must now be used for literals. E.g. [0xabc] used to be acceptable but now must be specified as ["0xabc"]

Copy link
Collaborator

@kent-white kent-white left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logs, otherwise this looks good :)

@@ -287,6 +288,7 @@ function RunContractForm({
} else return arg;
}),
};
console.log(payload);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logss

@@ -277,6 +277,7 @@ function RunContractForm({
const type = fnParams[i];
if (type.includes("vector")) {
// when it's a vector<u8>, we support both hex and javascript array format
console.log(type, arg);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove console.log?

src/utils.ts Outdated
Comment on lines 188 to 190
if (isArrayStr(trimmed)) {
inside = trimmed.slice(1, -1);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this doing?

Can we put a comment above it?

src/utils.ts Outdated
if (result[0] === "[" && result[result.length - 1] === "]") {
result = result.slice(1, -1);
// Also works nested [[1, 2], [3, 4]] to [["1", "2"], ["3", "4"]]
// TODO: Need to type this recursively
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this recursive now?

src/utils.ts Outdated
Comment on lines 195 to 205
const innerArrayStrs = [];
let build = "";
for (let i = 0; i < inside.length; i++) {
if (inside[i] === "]") {
innerArrayStrs.push(build);
build = "";
} else {
build += inside[i];
}
}
return innerArrayStrs.map(deserializeVector);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code will have the bracket at the beginning?

But, I guess you call it recursively?

I think this misses, can we make a unit test, I suspect that:

[[blah,blah],[blah,blah]]

Will get to:

[blah, blah], [blah, blah]

Then

innerArrayStrs.push('[blah, blah')
innerArrayStrs.push(',[blah, blah')

Then do that recursively which will return two items

'[blah', 'blah'
'','[blah', 'blah'

Copy link

netlify bot commented Mar 1, 2024

Deploy Preview for aptos-explorer ready!

Name Link
🔨 Latest commit bad9db7
🔍 Latest deploy log https://app.netlify.com/sites/aptos-explorer/deploys/6633e0f5e48c5200083bd9b8
😎 Deploy Preview https://deploy-preview-681--aptos-explorer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Alexzander-Stone Alexzander-Stone merged commit be80b2b into main May 2, 2024
7 checks passed
@Alexzander-Stone Alexzander-Stone deleted the bl/nested-arr branch May 2, 2024 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants