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

Fix parity between local blockchain and network APIs #1422

Merged
merged 63 commits into from
Feb 21, 2024
Merged
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
9fe48d7
refactor(mina.ts, mina-instance.ts): rename TransactionId interface t…
MartinMinkov Feb 7, 2024
1655306
refactor(fetch.ts): add generic type support to FetchResponse and rel…
MartinMinkov Feb 8, 2024
168a546
feat(fetch.ts, mina.ts): add missing properties to PendingTransaction
MartinMinkov Feb 8, 2024
a48ec9a
feat(fetch.ts): add type for `lastBlockQuery`
MartinMinkov Feb 8, 2024
25bd926
feat(fetch.ts): add type for `lastBlockQueryFailure`
MartinMinkov Feb 8, 2024
d105637
feat(fetch.ts): add response type for 'transactionStatus'
MartinMinkov Feb 8, 2024
82c4913
refactor(fetch.ts): remove temporary fix for fetching event/action da…
MartinMinkov Feb 8, 2024
e77dd4f
feat(fetch.ts): add type for 'getActions'
MartinMinkov Feb 8, 2024
fa4208c
refactor(graphql.ts): add a graphql module under mina dir
MartinMinkov Feb 8, 2024
c861ff7
feat(mina.ts): add IncludedTransaction type to handle transactions th…
MartinMinkov Feb 8, 2024
4a9af9d
feat(mina.ts): modify wait function to return IncludedTransaction
MartinMinkov Feb 8, 2024
89d2bcc
refactor(mina.ts): simplify transaction status polling logic
MartinMinkov Feb 8, 2024
50a7e5c
fix(run_live.ts): change types from Mina.TransactionId to Mina.Pendin…
MartinMinkov Feb 8, 2024
08ab94f
feat(mina.ts): add IncludedTransaction to exports to allow access to …
MartinMinkov Feb 8, 2024
9f6a8b4
refactor(mina.ts): simplify IncludedTransaction type definition using…
MartinMinkov Feb 8, 2024
cd3808e
feat(mina.ts): add sendOrThrowIfError method to Transaction type
MartinMinkov Feb 12, 2024
2329353
feat(mina.ts): add RejectedTransaction type and waitOrThrowIfError
MartinMinkov Feb 12, 2024
6e49d78
feat(mina.ts): add RejectedTransaction to exports
MartinMinkov Feb 12, 2024
baa33d3
fix(mina.ts): throw error when transaction is rejected to handle tran…
MartinMinkov Feb 12, 2024
a9de01e
Merge branch 'main' into feat/transaction-flow-txn-type
MartinMinkov Feb 12, 2024
63999a5
Merge branch 'main' into feat/transaction-flow-txn-type
MartinMinkov Feb 13, 2024
b06cfcf
refactor(graphql.ts): rename import from 'account_update.js' to 'acco…
MartinMinkov Feb 13, 2024
8cf9baf
refactor(fetch.ts, account.ts, graphql.ts): move FetchedAccount type …
MartinMinkov Feb 13, 2024
4060d89
feat(fetch.ts, graphql.ts): add GenesisConstants type to handle genes…
MartinMinkov Feb 14, 2024
f3906d2
feat(fetch.ts, graphql.ts): add fetchCurrentSlot function and Current…
MartinMinkov Feb 14, 2024
bc35163
feat(tests): add transaction-flow test suite for zkApp
MartinMinkov Feb 15, 2024
d0e3043
feat(run-ci-live-tests.sh): add transaction-flow test to CI live test…
MartinMinkov Feb 15, 2024
cff8b4d
feat(mina.ts): use 'hashZkAppCommand' to hash transaction
MartinMinkov Feb 16, 2024
06ecf3e
feat(submodule): update mina to b9ed54 and o1js-bindings to 4c847f
MartinMinkov Feb 16, 2024
ec34710
refactor(fetch.ts, graphql.ts): move removeJsonQuotes function from f…
MartinMinkov Feb 16, 2024
166a501
refactor(transaction-flow.ts): replace let with const for immutability
MartinMinkov Feb 16, 2024
0a3f4a0
refactor(fetch.unit-test.ts): replace Fetch.removeJsonQuotes with rem…
MartinMinkov Feb 16, 2024
f1ec38f
refactor(graphql.ts): modify import statements
MartinMinkov Feb 16, 2024
6b4c68c
refactor(fetch.ts): rename 'txnId' to 'transactionHash'
MartinMinkov Feb 17, 2024
1ede894
refactor(mina.ts): improve error handling and transaction status chec…
MartinMinkov Feb 17, 2024
76574c2
refactor(transaction-flow.ts): modify tests to test throwing methods
MartinMinkov Feb 17, 2024
9b78cc0
refactor(fetch.ts): simplify failureReason mapping in checkZkappTrans…
MartinMinkov Feb 19, 2024
23b32ec
refactor(errors.ts): improve error handling for fee payer and account…
MartinMinkov Feb 19, 2024
aac4e34
refactor(mina.ts): simplify error handling in sendOrThrowIfError, Loc…
MartinMinkov Feb 19, 2024
111bae1
refactor(precondition.test.ts, token.test.ts): replace send() with se…
MartinMinkov Feb 19, 2024
9c214e5
refactor(transaction-flow.ts): remove outdated comments about current…
MartinMinkov Feb 19, 2024
023d31d
feat(mina.ts): add detailed comments for PendingTransaction, Included…
MartinMinkov Feb 19, 2024
671c35e
docs(mina.ts): update comments for better clarity and add examples
MartinMinkov Feb 19, 2024
c8d1d14
style(mina.ts): remove unnecessary comment lines
MartinMinkov Feb 19, 2024
78f96f7
Merge branch 'main' into feat/transaction-flow-txn-type
MartinMinkov Feb 19, 2024
9ca996b
refactor: replace 'send' method with 'sendOrThrowIfError' in dex/run.…
MartinMinkov Feb 19, 2024
d2322e0
refactor(run.ts): replace send() with sendOrThrowIfError() for better…
MartinMinkov Feb 19, 2024
88fa9e2
feat(mina.ts): add error handling for JSON parsing in LocalBlockchain…
MartinMinkov Feb 19, 2024
c4aefd4
fix(run.ts): correct function call syntax for sendOrThrowIfError method
MartinMinkov Feb 20, 2024
9747048
refactor(transaction): move transaction implementations to new module
MartinMinkov Feb 20, 2024
62eade2
feat(local-blockchain): seperate local-blockchain into it's own module
MartinMinkov Feb 20, 2024
1aa462b
refactor(mina.ts): move transaction validation functions to separate …
MartinMinkov Feb 21, 2024
cdad58f
refactor(mina.ts, local-blockchain.ts, transaction.ts): change hash m…
MartinMinkov Feb 21, 2024
0fdac18
refactor(errors.ts): simplify error handling logic by removing accoun…
MartinMinkov Feb 21, 2024
f1ffe88
feat(local-blockchain.ts): add error handling for rejected transactions
MartinMinkov Feb 21, 2024
b13b3e8
chore(bindings): update bindings submodule to a7ade
MartinMinkov Feb 21, 2024
463768a
refactor(transaction-flow.ts): replace try-catch block with assert.re…
MartinMinkov Feb 21, 2024
2551979
Merge branch 'main' into feat/transaction-flow-txn-type
MartinMinkov Feb 21, 2024
638f42a
refactor(mina.ts, transaction.ts): move transaction function from min…
MartinMinkov Feb 21, 2024
e12d29e
refactor(run-live.ts): replace hash() method with hash property for b…
MartinMinkov Feb 21, 2024
39645aa
docs(CHANGELOG.md): update changelog with recent fixes and changes
MartinMinkov Feb 21, 2024
5ea85ac
refactor(mina.ts, mina-instance.ts): move function definitions from m…
MartinMinkov Feb 21, 2024
069921c
docs(CHANGELOG.md): move transaction changes to 'Breaking changes' se…
MartinMinkov Feb 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/lib/mina/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ function invalidTransactionError(
let errorMessages = [];
let rawErrors = JSON.stringify(errors);
let n = transaction.accountUpdates.length;
let accountUpdateErrors = errors.slice(1, n + 1);

// Check if the number of errors match the number of account updates. If there are more, then the fee payer has an error.
// We do this check because the fee payer error is not included in network transaction errors and is always present (even if empty) in the local transaction errors.
if (accountUpdateErrors.length === n) {
let errorsForFeePayer = errors[0];
if (errors.length > n) {
let errorsForFeePayer = errors.shift() ?? [];
Copy link
Collaborator

Choose a reason for hiding this comment

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

damn I always mix up shift and unshift

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not the best naming imo :P

for (let [error] of errorsForFeePayer) {
let message = ErrorHandlers[error as keyof typeof ErrorHandlers]?.({
transaction,
Expand All @@ -78,8 +77,8 @@ function invalidTransactionError(
}
}

for (let i = 0; i < accountUpdateErrors.length; i++) {
let errorsForUpdate = accountUpdateErrors[i];
for (let i = 0; i < errors.length; i++) {
let errorsForUpdate = errors[i];
for (let [error] of errorsForUpdate) {
let message = ErrorHandlers[error as keyof typeof ErrorHandlers]?.({
transaction,
Expand Down