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: walletconnect dependencies and component working #3

Open
wants to merge 31 commits into
base: master
Choose a base branch
from

Conversation

andreabadesso
Copy link
Collaborator

@andreabadesso andreabadesso commented Aug 25, 2024

Acceptance Criteria

  • We should have a complete implementation of the bet demo, working with wallet connect

@andreabadesso andreabadesso self-assigned this Aug 25, 2024
@andreabadesso andreabadesso added the enhancement New feature or request label Aug 25, 2024
@andreabadesso andreabadesso requested review from alexruzenhack and removed request for pedroferreira1 August 26, 2024 19:45
@andreabadesso andreabadesso changed the base branch from feat/ui to master September 26, 2024 16:23
@andreabadesso andreabadesso requested review from pedroferreira1 and removed request for alexruzenhack September 26, 2024 16:26
@andreabadesso andreabadesso requested review from alexruzenhack and pedroferreira1 and removed request for pedroferreira1 and alexruzenhack October 7, 2024 15:45
Comment on lines +21 to +22
} catch (e) {
}

Choose a reason for hiding this comment

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

[question] It is ok to have a silent error here? Shouldn't it be interesting to have at least an error log?

Comment on lines +9 to +15
hathorRpc: IHathorRpc,
title: string,
description: string,
oracleType: string,
oracle: string,
timestamp: number,
token: string,

Choose a reason for hiding this comment

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

[question] There is any validation requirement here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, but we're validating the input in the form

throw new Error('No timestamp received in transaction');
}

await createNanoContractTx(nanoContract, title, description, oracleType, oracle, timestamp, nanoContract.timestamp);

Choose a reason for hiding this comment

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

[question] This method can throw, right? What the user see when this method throws?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops, this file shouldn't exist, removed

timestamp: Date,
}[]>([]);
const [bet, setBet] = useState<null | { amount: number, bet: string }>(null);
const [error, setError] = useState<boolean>(false);

Choose a reason for hiding this comment

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

[question] You don't need to show any feedback message to the user?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We definitely could improve the error handling here, but it was not a requirement for this first release

}, [getFirstAddress, hathorRpc, connect, nanoContract ]);

const onConnect = useCallback((e: React.MouseEvent<HTMLElement>) => {
e.preventDefault();

Choose a reason for hiding this comment

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

question: Why to prevent the default behavior?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The default behavior would be to submit the form, which is something we don't want

Comment on lines +114 to +122
useEffect(() => {
(async () => {
const client = getClient();

await _subscribeToEvents(client);
await _checkPersistedState(client);
setClient(client);
})();
}, [_subscribeToEvents, _checkPersistedState]);

Choose a reason for hiding this comment

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

question [blocking]: If the dependencies change we need to clean the previous subscriptions, right? If so, this cleaning is lacking right now.

Comment on lines +29 to +31
if (response.status !== 200) {
throw new Error('Error creating nano contract.');
}

Choose a reason for hiding this comment

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

question: Isn't it interesting to have a log here to inform the response status at least?

Comment on lines +3 to +46
interface Tx {
hash: string;
nonce: string;
timestamp: number;
version: number;
weight: number;
signal_bits: number;
parents: string[];
inputs: any[];
outputs: any[];
tokens: any[];
nc_id: string;
nc_blueprint_id: string;
nc_method: string;
nc_args: string;
nc_pubkey: string;
raw: string;
}

interface Meta {
hash: string;
spent_outputs: any[];
received_by: any[];
children: string[];
conflict_with: any[];
voided_by: any[];
twins: any[];
accumulated_weight: number;
score: number;
height: number;
min_height: number;
feature_activation_bit_counts: any | null;
first_block: string;
validation: string;
nc_block_root_id: any | null;
first_block_height: number;
}

interface ResponseObject {
success: boolean;
tx: Tx;
meta: Meta;
spent_outputs: any;
}

Choose a reason for hiding this comment

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

suggestion [not-blocking]: Extract it to a type file. The type file can be for the whole context of /lib/api.

Comment on lines +17 to +35
export interface NanoContract {
id: string;
timestamp: number;
title: string;
oracleType: string;
oracle: string;
description?: string;
createdAt: number;
}

export interface DynamoNanoContract {
id: AttributeValue;
timestamp: AttributeValue;
title: AttributeValue;
oracleType: AttributeValue;
oracle: AttributeValue;
description?: AttributeValue;
createdAt: AttributeValue;
}

Choose a reason for hiding this comment

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

suggestion [non-blocking]: Maybe it would be good to extract it to a type file as well. But it depends if we can use the interfaces without use the methods.

Choose a reason for hiding this comment

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

question: why do we need this code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is loaded in the create nano contract success screen to represent the code of the created nano contract

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

3 participants