Skip to content

Commit

Permalink
fix(frontend): Update signer declarations (#2602)
Browse files Browse the repository at this point in the history
# Motivation

Signer release was updated but not its declarations. This leads to CI
failing one step.

# Changes

* All changes are consequence of `npm run generate`.

# Tests

This fixes the declarations CI check.
  • Loading branch information
lmuntaner authored Oct 1, 2024
1 parent 1ab5b9d commit 24b52bf
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 13 deletions.
20 changes: 19 additions & 1 deletion src/declarations/signer/signer.did
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,16 @@ type InitArg = record {
type Outpoint = record { txid : blob; vout : nat32 };
type PatronPaysIcrc2Tokens = record { ledger : principal; patron : Account };
type PaymentError = variant {
LedgerWithdrawFromError : record {
error : WithdrawFromError;
ledger : principal;
};
LedgerUnreachable : CallerPaysIcrc2Tokens;
LedgerTransferFromError : record {
error : TransferFromError;
ledger : principal;
};
UnsupportedPaymentType;
LedgerError : record { error : WithdrawFromError; ledger : principal };
InsufficientFunds : record { needed : nat64; available : nat64 };
};
type PaymentType = variant {
Expand Down Expand Up @@ -139,6 +146,17 @@ type SignWithEcdsaArgument = record {
message_hash : blob;
};
type SignWithEcdsaResponse = record { signature : blob };
type TransferFromError = variant {
GenericError : record { message : text; error_code : nat };
TemporarilyUnavailable;
InsufficientAllowance : record { allowance : nat };
BadBurn : record { min_burn_amount : nat };
Duplicate : record { duplicate_of : nat };
BadFee : record { expected_fee : nat };
CreatedInFuture : record { ledger_time : nat64 };
TooOld;
InsufficientFunds : record { balance : nat };
};
type Utxo = record { height : nat32; value : nat64; outpoint : Outpoint };
type WithdrawFromError = variant {
GenericError : record { message : text; error_code : nat };
Expand Down
25 changes: 24 additions & 1 deletion src/declarations/signer/signer.did.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,20 @@ export interface PatronPaysIcrc2Tokens {
patron: Account;
}
export type PaymentError =
| {
LedgerWithdrawFromError: {
error: WithdrawFromError;
ledger: Principal;
};
}
| { LedgerUnreachable: CallerPaysIcrc2Tokens }
| {
LedgerTransferFromError: {
error: TransferFromError;
ledger: Principal;
};
}
| { UnsupportedPaymentType: null }
| { LedgerError: { error: WithdrawFromError; ledger: Principal } }
| { InsufficientFunds: { needed: bigint; available: bigint } };
export type PaymentType =
| { PatronPaysIcrc2Tokens: PatronPaysIcrc2Tokens }
Expand Down Expand Up @@ -156,6 +167,18 @@ export interface SignWithEcdsaArgument {
export interface SignWithEcdsaResponse {
signature: Uint8Array | number[];
}
export type TransferFromError =
| {
GenericError: { message: string; error_code: bigint };
}
| { TemporarilyUnavailable: null }
| { InsufficientAllowance: { allowance: bigint } }
| { BadBurn: { min_burn_amount: bigint } }
| { Duplicate: { duplicate_of: bigint } }
| { BadFee: { expected_fee: bigint } }
| { CreatedInFuture: { ledger_time: bigint } }
| { TooOld: null }
| { InsufficientFunds: { balance: bigint } };
export interface Utxo {
height: number;
value: bigint;
Expand Down
24 changes: 21 additions & 3 deletions src/declarations/signer/signer.factory.certified.did.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,31 @@ export const idlFactory = ({ IDL }) => {
}),
InsufficientFunds: IDL.Record({ balance: IDL.Nat })
});
const TransferFromError = IDL.Variant({
GenericError: IDL.Record({
message: IDL.Text,
error_code: IDL.Nat
}),
TemporarilyUnavailable: IDL.Null,
InsufficientAllowance: IDL.Record({ allowance: IDL.Nat }),
BadBurn: IDL.Record({ min_burn_amount: IDL.Nat }),
Duplicate: IDL.Record({ duplicate_of: IDL.Nat }),
BadFee: IDL.Record({ expected_fee: IDL.Nat }),
CreatedInFuture: IDL.Record({ ledger_time: IDL.Nat64 }),
TooOld: IDL.Null,
InsufficientFunds: IDL.Record({ balance: IDL.Nat })
});
const PaymentError = IDL.Variant({
LedgerUnreachable: CallerPaysIcrc2Tokens,
UnsupportedPaymentType: IDL.Null,
LedgerError: IDL.Record({
LedgerWithdrawFromError: IDL.Record({
error: WithdrawFromError,
ledger: IDL.Principal
}),
LedgerUnreachable: CallerPaysIcrc2Tokens,
LedgerTransferFromError: IDL.Record({
error: TransferFromError,
ledger: IDL.Principal
}),
UnsupportedPaymentType: IDL.Null,
InsufficientFunds: IDL.Record({
needed: IDL.Nat64,
available: IDL.Nat64
Expand Down
24 changes: 21 additions & 3 deletions src/declarations/signer/signer.factory.did.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,31 @@ export const idlFactory = ({ IDL }) => {
}),
InsufficientFunds: IDL.Record({ balance: IDL.Nat })
});
const TransferFromError = IDL.Variant({
GenericError: IDL.Record({
message: IDL.Text,
error_code: IDL.Nat
}),
TemporarilyUnavailable: IDL.Null,
InsufficientAllowance: IDL.Record({ allowance: IDL.Nat }),
BadBurn: IDL.Record({ min_burn_amount: IDL.Nat }),
Duplicate: IDL.Record({ duplicate_of: IDL.Nat }),
BadFee: IDL.Record({ expected_fee: IDL.Nat }),
CreatedInFuture: IDL.Record({ ledger_time: IDL.Nat64 }),
TooOld: IDL.Null,
InsufficientFunds: IDL.Record({ balance: IDL.Nat })
});
const PaymentError = IDL.Variant({
LedgerUnreachable: CallerPaysIcrc2Tokens,
UnsupportedPaymentType: IDL.Null,
LedgerError: IDL.Record({
LedgerWithdrawFromError: IDL.Record({
error: WithdrawFromError,
ledger: IDL.Principal
}),
LedgerUnreachable: CallerPaysIcrc2Tokens,
LedgerTransferFromError: IDL.Record({
error: TransferFromError,
ledger: IDL.Principal
}),
UnsupportedPaymentType: IDL.Null,
InsufficientFunds: IDL.Record({
needed: IDL.Nat64,
available: IDL.Nat64
Expand Down
12 changes: 7 additions & 5 deletions src/frontend/src/lib/canisters/signer.errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import type { GetAddressError, PaymentError } from '$declarations/signer/signer.

export class SignerCanisterPaymentError extends Error {
constructor(response: PaymentError) {
if ('LedgerUnreachable' in response) {
super(`Ledger unreachable ${response.LedgerUnreachable.ledger}`);
} else if ('UnsupportedPaymentType' in response) {
if ('UnsupportedPaymentType' in response) {
super('Unsupported payment type');
} else if ('LedgerError' in response) {
super(`Ledger error: ${JSON.stringify(response.LedgerError.error)}`);
} else if ('LedgerWithdrawFromError' in response) {
super(`Ledger error: ${JSON.stringify(response.LedgerWithdrawFromError.error)}`);
} else if ('LedgerUnreachable' in response) {
super(`Ledger unreachable: ${JSON.stringify(response.LedgerUnreachable)}`);
} else if ('LedgerTransferFromError' in response) {
super(`Ledger error: ${JSON.stringify(response.LedgerTransferFromError)}`);
} else if ('InsufficientFunds' in response) {
super(
`Insufficient funds needed ${response.InsufficientFunds.needed} but available ${response.InsufficientFunds.available}`
Expand Down

0 comments on commit 24b52bf

Please sign in to comment.