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(nami): add bech32 encoding fallback for nami mode #1486

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Changes from all commits
Commits
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
25 changes: 20 additions & 5 deletions packages/nami/src/adapters/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,26 @@
Wallet.Crypto.Hash28ByteBase16 | undefined,
Wallet.Crypto.Hash28ByteBase16 | undefined,
] => {
const addr = Wallet.Cardano.Address.fromBech32(address);
return [
addr.getProps().paymentPart?.hash,
addr.getProps().delegationPart?.hash,
];
try {
const addr = Wallet.Cardano.Address.fromBech32(address);
return [
addr.getProps().paymentPart?.hash,
addr.getProps().delegationPart?.hash,
];
} catch (error) {
// try casting as byron address
try {
const addr = Wallet.Cardano.Address.fromBase58(address);
return [
addr.getProps().paymentPart?.hash,
addr.getProps().delegationPart?.hash,
];
} catch (error) {
console.error(error);
}
console.error(error);
return [undefined, undefined];
}
};

const matchesAnyCredential = (
Expand Down Expand Up @@ -173,7 +188,7 @@
const amounts: Amount[] = [];

while (inputs.length > 0) {
const input = inputs.pop()!;

Check warning on line 191 in packages/nami/src/adapters/transactions.ts

View workflow job for this annotation

GitHub Actions / Prepare

Forbidden non-null assertion
const outputIndex = outputs.findIndex(amount => amount.unit === input.unit);
let qty;

Expand Down
Loading