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

Remove legacy queries from KREAd frontend #126

Closed
wants to merge 43 commits into from

Conversation

Jorge-Lopes
Copy link

@Jorge-Lopes Jorge-Lopes commented Apr 4, 2024

Description

The purpose of this PR is to update the KREAd frontend code to use the JSON API instead of the deprecated RPC method to query the Vstorage.

With this in mind, it was necessary to update the @agoric/rpc and @agoric/web-components packages, and the respective imported functions being used by KREAd.

Changes made to original code:

  • At commit 0c62574 the packages mentioned above are updated to the latest version.
  • At commit 92a3c78
    • the fetchChainInfo function is updated to return the api along with the rpc and chainName
    • the connectAgoric function is updated to pass the rpc as argument to makeAgoricWalletConnection
    • the startWatching function is updated to pass the api as argument to makeAgoricChainStorageWatcher
  • At commit 5ec93d7 on all calls of the watchLatest method of chainStorageWatcher, the onError argument was removed, since it is no longer expected.

Note: these changes were tested against the current version running in production (1f281a8) and it displayed the expected behaviour.

Related Issues

Fixes the following issues:

Checklist

Make sure all items are checked before submitting the pull request. Remove any items that are not applicable.

privilegemendes and others added 30 commits October 12, 2023 09:54
- [x] Fixed connect-wallet issue on the activate wallet page
- [x] Removed blur filter from the character detail section in the
landing page

![image](https://github.com/Kryha/KREAd/assets/20317699/0c970360-4829-4da8-80eb-28116d93e7ae)
- [x] removed item counters from category mode

![image](https://github.com/Kryha/KREAd/assets/20317699/570bad0f-ee75-447e-9ede-292a778585df)
- [x] removed all mobile ui ( moved to mobile branch)

---------

Co-authored-by: Axel Verheul <[email protected]>
This PR introduces GitHub Actions pipelines into the Kread Frontend
repository's workflow, enabling automated deployment to both the
Emerynet and Mainnet environments.

-  PR -> develop (requires approver) -> Deploys to Emerynet on PR closed
- develop -> PR -> main (requires approver from CODEOWNERS) -> Deploys
to Mainnet on PR closed
 
 CODEOWNERS:
- @carlos-kryha 
- @WietzeSlagman

---------

Co-authored-by: Xabier Almazor <[email protected]>
Co-authored-by: Xabier Almazor <[email protected]>
Co-authored-by: Wietze <[email protected]>
Co-authored-by: CARLOS TRIGO <[email protected]>
Co-authored-by: Xabier Almazor Telek <[email protected]>
Fixes issue Kryha#35. 

This PR makes the button clickable instead of the text.

Co-authored-by: Nick Koster <[email protected]>
This enebles us to exclude certain category/rarity combinations from the
item shop. Currently excluding legendary hair items due to Kryha#53
- [x] cleaned up item-shop data 
- [x] added const for filtering out by `[[Category, Rarity[]]]`
- [x] implemented filters in item-shop
- [x] update view

---------

Co-authored-by: Xabier Almazor <[email protected]>
Co-authored-by: Xabier Almazor <[email protected]>
Co-authored-by: Wietze <[email protected]>
Co-authored-by: Xabier Almazor Telek <[email protected]>
Co-authored-by: Pandelis Symeonidis <[email protected]>
Co-authored-by: Axel Verheul <[email protected]>
Co-authored-by: Pandelis Symeonidis <[email protected]>
Add spread operator to array to fix error

Co-authored-by: Pandelis Symeonidis <[email protected]>
Fixed marketplaceAverageLevel metric. For items, this metric was being
calculated incorrectly. This lead to specific cases where the metric
might become a negative value after updating. This would violate the
typeguard of the metric which expects it to be greater or equal than 0
and an error would be thrown. This means the buy item flow would not
complete hence why the item would still remain in the market state.

Fixes 2 bugs:
1. Kryha#61 
2. Kryha#53

Co-authored-by: Pandelis Symeonidis <[email protected]>
- Fixed the placement of confirm and previous buttons in sell modal (for
items and characters). Wrapped the buttons in wrapper and made the step
components a bit smaller so the buttons can fit nicely at the bottom.
- Removed padding from some arrow icons in the button so they show up
properly
 
closes Kryha#64

Co-authored-by: Pandelis Symeonidis <[email protected]>
…ryha#67)

Switch to MAIN interaction mode when clicking the sell button in the
character-mode.

closes Kryha#65

Co-authored-by: Pandelis Symeonidis <[email protected]>
Removed all the .yarn cache files from git; so they are no longer
tracked; now it should be ignored like specified in the gitignore

Co-authored-by: Axel Verheul <[email protected]>
- Removed the `X` tag from error messages in the contract. This ensures
the error message is also returned to the makeOffer call. Now we can
match on the error message and display an appropriate error to the user.

closes Kryha#68

Co-authored-by: Pandelis Symeonidis <[email protected]>
### Description
Since we are no longer tracking `frontend/.yarn/`, and
[yarnrc.yml](https://github.com/Kryha/KREAd/blob/develop/frontend/.yarnrc.yml)
points to it, yarn breaks.

Coincidentally, [yarn 4](https://yarnpkg.com/blog/release/4.0) just
landed and it seems to solve the issue with Corepack:
> "...we used to recommend using the
[yarnPath](https://yarnpkg.com/configuration/yarnrc#yarnPath) setting
pointing to a checked-in binary, but this pattern increased friction
more than we liked - many people didn't like the idea of adding a binary
to their repository, however small. We listened, and worked conjointely
with Node.js on a project called
[Corepack](https://nodejs.org/api/corepack.html). Corepack is a tool
shipped with Node.js 16+ that will automatically select the right
package manager version to run depending on the project you're working
on"

### Acceptance Criteria
- [x] yarn does not depend on `/frontend/.yarn` 
- [x] QAd
Co-authored-by: Xabier <[email protected]>
Co-authored-by: Xabier Almazor <[email protected]>
- [x] Pricing selector for items adjusts based on min and max prices
- [x] Pricing selector for character adjusts based on min and max prices
This pull request introduces a new feature to the useNetworkConfig
custom hook, providing users with a UI select button to toggle between
different available networks.

<img width="208" alt="image"
src="https://github.com/Kryha/KREAd/assets/20317699/5c43e2da-2681-4a91-99cb-4cc281606e4a">

- [x] Network Selector available on the footer
- [x] Hot reload functionality (no need to refresh the page) 

Additional Update:
- [x] Added missing dependency to for metrics data in the shop
Branch including all frontend changes implemented in the last sprint,
once
[QA](https://docs.google.com/spreadsheets/d/1bBJhr73o4W2rd3oYNpK_xET_3m6kNYYbeaDvMKIRQRM/edit#gid=0)
is done we can PR to prod

---------

Co-authored-by: Pandelis Symeonidis <[email protected]>
This PR introduces a build step pre-check on GitHub actions that will be
triggered every time a new PR against develop is created.

How it
works:


1. Dev opens PR to develop
2. Skaffold build is triggered
3. If new modifications are done to the PR while its open step 2 is
re-triggered
4. After PR is merged the normal pipeline gets executed
(build+push+deploy)
5. You can't get your PR merged if the pre-check pipeline isn't green,
so it needs to finish first

To achieve this:
- New pipeline kread-skaffold-precheck.yml
- Branch protection rule at repo level

---------

Co-authored-by: Synthetics <[email protected]>
QA surfaced several problems with the price filter components:

- [x] Slider input is not usable with ranges > ~1000, since the steps
are too big to find specific numbers
> Fix: removed slider input component, added todo with potential
solutions, and adjusted wrapper ui
- [x] Min/max input components missing `value` property
> Fix: added value property
- [x] Price metrics affected by price filters
> Fix: calculate price metrics using full market instead of filtered
- [x] Min/max input used uIST, while all prices show IST
> Fix: refactor filters to use IST
- [x] Clear all does not clear price filter
> Fix: refactor reset mechanism to work with clear all feature

---------

Co-authored-by: Pandelis Symeonidis <[email protected]>
Rename .yaml filename inside mainnet pipeline.

Co-authored-by: Synthetics <[email protected]>
This PR includes improved typing. Some key things that are now typed:
- contract state
- recorderKits
- proposal
Added new test setup based on
[test-fluxAggregator-service-upgrade.js](https://github.com/Agoric/agoric-sdk/blob/master/packages/inter-protocol/test/swingsetTests/fluxAggregator/test-fluxAggregator-service-upgrade.js)

- Moved old unit tests over to this setup 
  - market tests
  - minting tests
  - inventory tests
  - market metrics tests
  - governance tests
- Added null-upgrade test
- changed `index.js` contract method from `start` to `prepare` to allow
contract upgrades
- Added vStorage assertions to all test files
Addresses the following dependabot alerts:
Kryha#41 - Upgrade SES to `^0.16` 
Kryha#88 - Upgraded axios to `^1.6`
Kryha#80 - No fix included, this is a subdependency of `crypto-browserify`
which is currently on its latest version. Can be tracked
[here](browserify/crypto-browserify#206)
Kryha#62 - No fix included: all node modules within `/agoric` are imported
from `@agoric` or `@endo`, so keeping up with their releases is all we
can do. Issue can be tracked
[here](Kryha#62)
KREAd is designed to keep character names unique, but the frontend
applies text-transformations (capitalizes first letter) to character
names. Since names are case-sensitive, this can lead to confusion when
displaying character names that differ only in casing (eg Test vs test).
This pr removes text-transformation css in components that display
character names.

---------

Co-authored-by: Privilege Mendes <[email protected]>
Co-authored-by: Axel Verheul <[email protected]>
Co-authored-by: Xabier <[email protected]>
Co-authored-by: Xabier Almazor <[email protected]>
Co-authored-by: Xabier Almazor <[email protected]>
Co-authored-by: Wietze <[email protected]>
Co-authored-by: Xabier Almazor Telek <[email protected]>
Co-authored-by: Nick K <[email protected]>
Co-authored-by: Nick Koster <[email protected]>
Co-authored-by: Pandelis Symeonidis <[email protected]>
Co-authored-by: Pandelis Symeonidis <[email protected]>
Co-authored-by: MangoDream1 <[email protected]>
Co-authored-by: Synthetics <[email protected]>
Co-authored-by: Synthetics <[email protected]>
…a#99)

We have been trying to keep up with releases of agoric-sdk's master
branch when developing locally, however, Agoric has recommended using
the `release-mainnet1B` branch instead. This change results in all tests
passing having checked-out `release-mainnet1B`
Added a CONTRIBUTING.md page with information on how to raise issues for
bug reports or feature requests and steps on how to create a PR.

Added templates for:
- Creating an issue for reporting bugs
- Creating an issue for requesting a feature
- Creating a PR

The issue templates are made using github forms
(https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-issue-forms)
and are hence written in yaml.

The PR template is written in markdown as github forms are not supported
for PR templates yet.

Fixes Kryha#91
Kryha#100)

This PR includes a fix for the PR template:

Moved the pull_request_template.md to the .github folder as having it in
a PULL_REQUEST_TEMPLATE folder requires the use of the `template` query
parameter to access the correct template. The use of the
PULL_REQUEST_TEMPLATE folder would be valid if we had multiple PR
templates. Currently we have only one so putting it directly into the
.github directory allows github to set it as the default template
automatically.

More information can be found here:
https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository
## Description
In this PR:

Created a new pattern for creating offer callbacks that get passed the
the wallet's `makeOffer` function. The pattern defined in
`contract-callbacks.ts` allows developers to define their callback
functions in the view components themselves. Also, having passed the
callback from the view component to the hooks you are able to overwrite
the callback and add common logic to them (see for example
`sevice/character.ts` `useBuyCharacter` hook).

```
interface MakeOfferCallback {
  accepted?: (args?: any) => void, // offer was successful
  refunded?: (args?: any) => void, // strangely seems to behave the same way as accepted
  error?: (args?: any) => void, // offer failed
  seated?: (args?: any) => void, // returned exclusively by the KREAd sell method, likely has to do with the offer being long-lived
  settled?: (args?: any) => void, // gets called when a response is received, regardless of the status
  setIsLoading?: React.Dispatch<React.SetStateAction<boolean>> 
};
```

You can now implement this interface in a view component passing it
callbacks for specific cases (error, accepted, etc). This object is
passed from the view to the hook. There common functionality can be
added to the callback by doing so:

```
{
          ...callback,
          accepted: () => {
            if (callback.accepted) callback.accepted();
            // common functionality 
          },
        },
```

This object is then passed to the service functions where it is passed
through the `formOfferResultCallback` function that generates the
complete callback that the agoric `makeOffer` function expects.

## Checklist

Make sure all items are checked before submitting the pull request.
Remove any items that are not applicable.

- [x] I have used agoric's linter on my code
(Agoric/agoric-sdk#8274)
- [x] I have updated the documentation to reflect the changes (if
applicable).
- [x] I have added/updated unit tests to cover the changes.
- [x] All existing tests pass.
- [x] The PR title is clear and concise.
- [x] Are there changes in the /fronted folder? Make sure `cd frontend
&& yarn build` runs successfully.;

---------

Co-authored-by: CARLOS TRIGO <[email protected]>
carlos-kryha and others added 13 commits December 7, 2023 09:47
## Description

Add basic documentation, currently not very structured and with many
`TODOs`. Merging this so that we have a starting reference for further
documentation efforts.

## Checklist

Make sure all items are checked before submitting the pull request.
Remove any items that are not applicable.

- [x] I have used agoric's linter on my code
(Agoric/agoric-sdk#8274)
- [x] I have updated the documentation to reflect the changes (if
applicable).
- [x] I have added/updated unit tests to cover the changes.
- [x] All existing tests pass.
- [x] The PR title is clear and concise.
- [x] Are there changes in the /fronted folder? Make sure `cd frontend
&& yarn build` runs successfully.;

---------

Co-authored-by: Wietze <[email protected]>
Co-authored-by: Pandelis Symeonidis <[email protected]>
Co-authored-by: Pandelis Symeonidis <[email protected]>
## Description

Adjusted the onboarding screen to be mobile friendly.
Adjusted the connect-wallet page to be mobile friendly including error
toasts and kado pop up.
Adjusted the privacy screen to be mobile friendly.

Closes Kryha#110 

## Screenshots (if applicable)


https://github.com/Kryha/KREAd/assets/54764628/f7f28943-f611-4eb1-b6c6-f33e0f33da1b

## Checklist

Make sure all items are checked before submitting the pull request.
Remove any items that are not applicable.

- [x] The PR title is clear and concise.
- [x] Are there changes in the /fronted folder? Make sure `cd frontend
&& yarn build` runs successfully.;

---------

Co-authored-by: CARLOS TRIGO <[email protected]>
## Description

Adjusts routes based on `useIsMobile()` hook, if mobile is detected all
paths except `onboarding, connectWallet, character, createCharacter`
will redirect to `<MobileNotAvailable />`. This pr includes UI
components for the `character` and `createCharacter` routes.

## Related Issues
Kryha#108

## Screenshots (if applicable)


https://github.com/Kryha/KREAd/assets/97608823/ad674348-7cf8-4a1c-b191-44ffba25cfe3

## Checklist

Make sure all items are checked before submitting the pull request.
Remove any items that are not applicable.

- [x] The PR title is clear and concise.
- [x] Are there changes in the /fronted folder? Make sure `cd frontend
&& yarn build` runs successfully.;

## Additional Comments

Currently having issues connecting the Keplr app to Emerynet, so this PR
is purely UI and routing changes
## Description

This PR fixes the issue with publishing the kread bundles. To fix it
`agoric published` has been replaced by the `installBundles` script in
the `agoric/contract/scripts/` folder. The script connects to the chain
using Cosmos StargateClient library and sends a transaction to the
correct endpoint with the bundle as payload. This is along the lines of
what happens under the hood of `agoric publish` as well but for some
reason that seems to be broken currently.

For funding the gas fees of the transaction, the same account is used
that funds the transactions to publish the committee bundles and sends
proposals for the kread-committee and kread.

Also, in this PR:
- Added some extra steps to `make kread-committee` (and no-build
version) that fetches the address that is to be funded from the
`AGORIC_SDK_PATH/packages/cosmic-swingset/t1/8000/` folder and funds it.
This way we no longer need to run `kread-committee`, copy the logged
address and fund it.
- Reverted back to the old folder structure where the contract code
lives in `src` instead of the versioned folder structere.

## Related Issues

Fixes Kryha#111 

## Checklist

Make sure all items are checked before submitting the pull request.
Remove any items that are not applicable.

- [x] I have used agoric's linter on my code
(Agoric/agoric-sdk#8274)
- [x] I have updated the documentation to reflect the changes (if
applicable).
- [x] I have added/updated unit tests to cover the changes.
- [x] All existing tests pass.
## Description

Add Apache 2.0 license using github license templates tool
## Description

Removed unused code and addressed outdated/irrelevant todos
## Description
Recent Chrome upgrades (version 122.0.6261.69) seem to cause issues when
rendering pages that use outdated `@endo` packages. Bumping `@endo`
packages to their most recent versions solves the issue

Fixes Kryha#117
### Description
Review frontend error handling for the mint flow and ensure the frontend
does not get "stuck" when minting a character

### Validation and error handling
The mint flow starts with the "Create character" input form, which takes
a string as input (to pick a character name) and performs the following
validation (showing errors when present):
1. Name adheres to the guidelines set on contract (special characters,
length requirements, etc)
2. Name is unique
3. User has enough IST available to mint

If no validation errors are present, the `mint` button is enabled.
Pressing mint will form the mint proposal based on the input and trigger
Agoric's `addOffer` method, which also accepts a callback set up to
track offer updates.

Should anything error out in the process of forming and executing
`addOffer` the error will be caught and a generic error will be
displayed to the user.

If addOffer is triggered correctly, the following `offerStatus` updates
are handled:

1. `seated`: indicates the offer was successfully parsed by the
contract? (I couldn't find documentation around this, so this definition
is from experience). We start a timer which will display an error to the
user in case no further offer updates are received within 30s (typically
the mint offer returns the "success" status within 10s of it being
seated)
2. `error`: indicates an error occurred while minting. A generic error
is displayed prompting the user to try again
3. `accepted`: indicates mint call was successful. We clear the timer
set to error if the call takes too long. We do not yet give the user
confirmation, as we want to wait until the new character is accessible
from the user's wallet

Finally, we have a useEffect in the create-character component that
listens for updates in the user's wallet and shows confirmation to the
user once the newly minted character is correctly parsed by KREAd's
frontend
## Description
Merging main onto develop as a pre-req for Kryha#120

---------

Co-authored-by: Privilege Mendes <[email protected]>
Co-authored-by: Axel Verheul <[email protected]>
Co-authored-by: Xabier <[email protected]>
Co-authored-by: Xabier Almazor <[email protected]>
Co-authored-by: Xabier Almazor <[email protected]>
Co-authored-by: Wietze <[email protected]>
Co-authored-by: Xabier Almazor Telek <[email protected]>
Co-authored-by: Nick K <[email protected]>
Co-authored-by: Nick Koster <[email protected]>
Co-authored-by: Pandelis Symeonidis <[email protected]>
Co-authored-by: Pandelis Symeonidis <[email protected]>
Co-authored-by: MangoDream1 <[email protected]>
Co-authored-by: Synthetics <[email protected]>
Co-authored-by: Synthetics <[email protected]>
@Jorge-Lopes Jorge-Lopes closed this Apr 4, 2024
@Jorge-Lopes Jorge-Lopes deleted the jorge/4-fix-legacy-queries branch April 4, 2024 14:59
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.

8 participants