Skip to content

Commit

Permalink
Bump bump ic-js (#3332)
Browse files Browse the repository at this point in the history
# Motivation

Bump ic-js which was updated with last did files of the CMC, ledger and
index canisters.

# Changes

- bump lib
- update anonymize function to leverage new `approve` type.

# Notes

No particular test added for `approve` and `spender` fields because
those are related to ICRC-2 which NNS dapp does not implement yet in any
features.
  • Loading branch information
peterpeterparker authored Sep 18, 2023
1 parent 0a74aed commit 63e81ea
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 57 deletions.
96 changes: 48 additions & 48 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/src/lib/utils/anonymize.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ const anonymizeSnsTransaction = async (
burn: await anonymizeTransfer(tx.burn as TransferOpt),
mint: await anonymizeTransfer(tx.mint as TransferOpt),
transfer: await anonymizeTransfer(tx.transfer as TransferOpt),
approve: await anonymizeTransfer(tx.approve as TransferOpt),
};
};

Expand Down
17 changes: 8 additions & 9 deletions frontend/src/lib/utils/sns-ledger.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,38 @@ export const ledgerErrorToToastError = ({
substitutions?: I18nSubstitutions;
} => {
if (err instanceof IcrcTransferError) {
const error: IcrcTransferError = err;
if ("GenericError" in error.errorType) {
if ("GenericError" in err.errorType) {
return {
labelKey: "error.transaction_error",
err: new Error(error.errorType.GenericError.message),
err: new Error(err.errorType.GenericError.message),
};
}
if ("TemporarilyUnavailable" in error.errorType) {
if ("TemporarilyUnavailable" in err.errorType) {
return {
labelKey: "error__sns.ledger_temporarily_unavailable",
};
}
if ("Duplicate" in error.errorType) {
if ("Duplicate" in err.errorType) {
return {
labelKey: "error__sns.ledger_duplicate",
};
}
if ("BadFee" in error.errorType) {
if ("BadFee" in err.errorType) {
return {
labelKey: "error__sns.ledger_bad_fee",
};
}
if ("CreatedInFuture" in error.errorType) {
if ("CreatedInFuture" in err.errorType) {
return {
labelKey: "error__sns.ledger_created_future",
};
}
if ("TooOld" in error.errorType) {
if ("TooOld" in err.errorType) {
return {
labelKey: "error__sns.ledger_too_old",
};
}
if ("InsufficientFunds" in error.errorType) {
if ("InsufficientFunds" in err.errorType) {
return {
labelKey: "error__sns.ledger_insufficient_funds",
};
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/tests/mocks/icrc-transactions.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ export const createIcrcTransactionWithId = ({
created_at_time: [BigInt(123)],
amount: BigInt(33),
fee: [BigInt(1)],
spender: [],
},
],
approve: [],
},
});

Expand All @@ -52,8 +54,10 @@ const mockIcrcTransactionTransfer: IcrcTransaction = {
created_at_time: [BigInt(123)],
amount: BigInt(33),
fee: [BigInt(1)],
spender: [],
},
],
approve: [],
};

export const mockIcrcTransactionBurn: IcrcTransaction = {
Expand All @@ -65,10 +69,12 @@ export const mockIcrcTransactionBurn: IcrcTransaction = {
from: fakeAccount,
memo: [],
created_at_time: [BigInt(123)],
spender: [],
},
],
mint: [],
transfer: [],
approve: [],
};

export const mockIcrcTransactionMint: IcrcTransaction = {
Expand All @@ -84,6 +90,7 @@ export const mockIcrcTransactionMint: IcrcTransaction = {
},
],
transfer: [],
approve: [],
};

export const mockIcrcTransactionWithId: IcrcTransactionWithId = {
Expand Down

0 comments on commit 63e81ea

Please sign in to comment.