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

Release / 4.19.100 #3141

Merged
merged 148 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
801ef51
use WasmScope for getDifferenceAfterTx
neuodev Feb 9, 2023
846807c
Use WasmScope for catalyst.test.js
neuodev Feb 9, 2023
f00cdd7
Use WasmScope for scramblePaperAdaMnemonic
neuodev Feb 9, 2023
6ed45f2
Use WasmScope for palet.js file
neuodev Feb 9, 2023
b95d4d5
Merge branch 'develop' into Ahmed/wasm-scope-1
neuodev Feb 9, 2023
f5b1b42
Use WasmScope for verify.js module
neuodev Feb 12, 2023
1422dbd
Merge branch 'Ahmed/wasm-scope-1' of https://github.com/Emurgo/yoroi-…
neuodev Feb 12, 2023
e1454f0
Migrate paperWallet.js to use WasmScope
neuodev Feb 12, 2023
9198773
Migrate bridge/utils.js to use WasmScope
neuodev Feb 12, 2023
51ff8a4
Hide staking page for non reward wallet
neuodev Feb 13, 2023
4267724
Redirect the user to the Tx page if the selected wallet is not a rewa…
neuodev Feb 13, 2023
b9e5c21
Fix switching to the wrong route
neuodev Feb 13, 2023
1f0ab48
flow fixes
vsubhuman Feb 13, 2023
b3f78d0
Merge pull request #3119 from Emurgo/Ahmed/staking-crash
vsubhuman Feb 13, 2023
c5c564a
Merge branch 'develop' into Ahmed/wasm-scope-1
neuodev Feb 14, 2023
9300498
Use WasmScope in hashMapper.js and keyRepository.js
neuodev Feb 14, 2023
575e521
Merge pull request #3122 from Emurgo/production
vsubhuman Feb 15, 2023
e610ec3
Merge branch 'develop' into Ahmed/wasm-scope-1
vsubhuman Feb 15, 2023
12e7b3c
chore: update GitHub workflow to lint the branch name and to make a c…
neuodev Feb 15, 2023
b21afee
unnecessary export removed
vsubhuman Feb 15, 2023
609ba7f
refactor: use WasScope in delegationUtils.js file
neuodev Feb 15, 2023
4eaa4fa
Fix flow
neuodev Feb 15, 2023
f205c02
Merge branch 'Ahmed/wasm-scope-1' of https://github.com/Emurgo/yoroi-…
neuodev Feb 15, 2023
125b3af
Merge pull request #3111 from Emurgo/Ahmed/wasm-scope-1
vsubhuman Feb 15, 2023
ef9d046
Merge branch 'develop' into Ahmed/wasm-scope-2
vsubhuman Feb 15, 2023
dca3f5f
removed unused import
vsubhuman Feb 15, 2023
4062b5d
Merge pull request #3118 from Emurgo/Ahmed/wasm-scope-2
vsubhuman Feb 16, 2023
7efea81
Merge branch 'develop' into fix/YOEXT-517/jira-script
vsubhuman Feb 16, 2023
b89dede
Use WasmScope in VerifyAddressDialog.js file
neuodev Feb 16, 2023
95f5416
Merge branch 'develop' into refactor/YOEXT-518/wasm-scope-4
neuodev Feb 16, 2023
c25154c
Use WasmScope in Transaction.js/TransactionRevamp.js files
neuodev Feb 16, 2023
34dcbab
Use WasmScope to get the spending key
neuodev Feb 16, 2023
adf06b6
Refactor createAuthEntry
neuodev Feb 16, 2023
9383015
Fix the isJormungandrAddress function return true for all calls
neuodev Feb 17, 2023
512573e
Merge pull request #3121 from Emurgo/fix/YOEXT-517/jira-script
vsubhuman Feb 21, 2023
2c1a45e
Adapt to LedgerJs 6.0.0
yushih Feb 22, 2023
a523c64
add new theme cloning modern one
nistadev Feb 22, 2023
ef6879d
Merge branch 'develop' of github.com:Emurgo/yoroi-frontend into feat/…
nistadev Feb 22, 2023
3b39fe0
Merge branch 'develop' into yushi/YOEXT-530/ledgerjs-6.0.0
vsubhuman Feb 28, 2023
35ef9c0
Merge pull request #3127 from Emurgo/yushi/YOEXT-530/ledgerjs-6.0.0
vsubhuman Feb 28, 2023
1be10f7
unused await removed
vsubhuman Mar 6, 2023
5d9e4e8
yoroi-lib update
vsubhuman Mar 6, 2023
80a7039
Merge remote-tracking branch 'origin/develop' into ruslan/collateral-fix
vsubhuman Mar 6, 2023
03b355b
added collecting indexedDB on every test
Nebyt Mar 6, 2023
2550562
misprint
Nebyt Mar 6, 2023
b9ed61a
Ledger wallet connector signTx() API
yushih Mar 5, 2023
af926e3
ledger wallet getting collaterals support
yushih Mar 7, 2023
837cdab
added collecting db info from FF
Nebyt Mar 7, 2023
f58d46c
refactor & bug fix & lint
yushih Mar 7, 2023
5ec381d
add translations
yushih Mar 7, 2023
14b01eb
Merge branch 'develop' into feat/YOEXT-520/create-new-theme
neuodev Mar 8, 2023
c4db387
Merge pull request #3135 from Emurgo/test/YOEXT-122/indexedDB_collecting
vsubhuman Mar 9, 2023
18449cb
Merge pull request #3128 from Emurgo/feat/YOEXT-520/create-new-theme
vsubhuman Mar 9, 2023
cd52cfd
Merge branch 'develop' into ruslan/collateral-fix
neuodev Mar 9, 2023
fd295a8
ledger sign input data hash
yushih Mar 14, 2023
c5d8736
Trezor wallet connector API support
yushih Mar 14, 2023
4d35c53
workaround for buggy Mint.to_js_value()
yushih Mar 15, 2023
ea8f062
cardano-example supports assets in input utxo
yushih Mar 15, 2023
5e19732
Merge branch 'develop' into fix/YOEXT-522/receiving-page-crash
vsubhuman Mar 16, 2023
906b308
Merge pull request #3124 from Emurgo/fix/YOEXT-522/receiving-page-crash
vsubhuman Mar 16, 2023
495794f
Merge remote-tracking branch 'origin/develop' into refactor/YOEXT-518…
vsubhuman Mar 16, 2023
26f3afe
Merge remote-tracking branch 'origin/develop' into yushi/hw-wallet-co…
vsubhuman Mar 16, 2023
1347f74
added missign return
vsubhuman Mar 17, 2023
39fd234
package-lock update
vsubhuman Mar 17, 2023
b59365d
Merge pull request #3123 from Emurgo/refactor/YOEXT-518/wasm-scope-4
vsubhuman Mar 17, 2023
b181f00
Merge remote-tracking branch 'origin/develop' into yushi/hw-wallet-co…
vsubhuman Mar 17, 2023
cf55146
eslint fixes
vsubhuman Mar 17, 2023
f30519c
eslint fixes
vsubhuman Mar 17, 2023
056e5ba
Merge pull request #3136 from Emurgo/yushi/hw-wallet-connector-1
vsubhuman Mar 17, 2023
817f9e7
Merge branch 'develop' into ruslan/collateral-fix
vsubhuman Mar 17, 2023
b7b613c
eslint fixes
vsubhuman Mar 17, 2023
043e7e0
Merge pull request #3133 from Emurgo/ruslan/collateral-fix
vsubhuman Mar 17, 2023
43e8d1e
Version bump: 4.19.100
vsubhuman Mar 17, 2023
1138508
bump trezor-connect version
yushih Mar 16, 2023
936dd9c
lint
yushih Mar 16, 2023
c978a4c
connector should merge witness set
yushih Mar 17, 2023
0e9ca32
handle requiredSigners
yushih Mar 17, 2023
895e3b5
improve cardano-example dapp
yushih Mar 20, 2023
8aed9ac
fix trezor wallet data sign error message
yushih Mar 20, 2023
33e309f
fix Trezor ttl handling
yushih Mar 21, 2023
88546d3
fix Trezor sign tx
yushih Mar 21, 2023
864f77f
fix Trezor collateral API
yushih Mar 21, 2023
7634441
remove "hardware wallet unsupported" text
yushih Mar 21, 2023
7c3f3ab
show error message when connecting to hw wallet with auth
yushih Mar 22, 2023
e5e62f0
refactor for conciseness
yushih Mar 22, 2023
82e0a31
hide trezor wallet from connector
yushih Mar 23, 2023
014b266
Revert "hide trezor wallet from connector"
yushih Mar 24, 2023
b8e38e1
unused adresses API doesn't apply cutoff and only returns base addresses
yushih Mar 27, 2023
e7a7cda
Merge branch 'release/4.19.100' into yushi/hw-wallet-connector-2
vsubhuman Mar 27, 2023
950ac26
Merge pull request #3143 from Emurgo/yushi/hw-wallet-connector-2
vsubhuman Mar 27, 2023
06f05c1
fix collateral API error return value
yushih Mar 27, 2023
7e57059
change error return value
yushih Mar 28, 2023
c613bf4
fix requester URL in sign confirmation page
yushih Mar 28, 2023
5be3bab
fix: free 'wasmAddr' pointer when it is no longer used
neuodev Mar 29, 2023
34e9e09
Merge branch 'release/4.19.100' into Ahmed/YOEXT-548/null-rust-pointer
vsubhuman Mar 30, 2023
48b52df
Merge pull request #3147 from Emurgo/Ahmed/YOEXT-548/null-rust-pointer
vsubhuman Mar 30, 2023
cfbd3ea
Merge branch 'release/4.19.100' into yushi/YOEXT-533/collateral-fixes
vsubhuman Mar 30, 2023
fc84022
New translations en-US.json (Hungarian)
stackchain Mar 30, 2023
93aa256
New translations en-US.json (Vietnamese)
stackchain Mar 30, 2023
3c6e428
New translations en-US.md (fr-FR)
stackchain Mar 30, 2023
c313251
New translations en-US.md (Spanish)
stackchain Mar 30, 2023
761eadc
New translations en-US.md (Czech)
stackchain Mar 30, 2023
83c8994
New translations en-US.md (de-DE)
stackchain Mar 30, 2023
15b0f46
New translations en-US.md (Greek)
stackchain Mar 30, 2023
aa03fa0
New translations en-US.md (Hungarian)
stackchain Mar 30, 2023
b672d24
New translations en-US.md (Italian)
stackchain Mar 30, 2023
755a171
New translations en-US.md (ja-JP)
stackchain Mar 30, 2023
f46f779
New translations en-US.md (ko-KR)
stackchain Mar 30, 2023
148eaaf
New translations en-US.md (Dutch)
stackchain Mar 30, 2023
7ecfde1
New translations en-US.md (ru-RU)
stackchain Mar 30, 2023
d84d3bb
New translations en-US.md (Slovak)
stackchain Mar 30, 2023
49cec42
New translations en-US.md (Turkish)
stackchain Mar 30, 2023
94fbcd9
New translations en-US.md (zh-Hans)
stackchain Mar 30, 2023
0a278ea
New translations en-US.md (zh-Hant)
stackchain Mar 30, 2023
d182a28
New translations en-US.md (Vietnamese)
stackchain Mar 30, 2023
48ea4e6
New translations en-US.md (Portuguese, Brazilian)
stackchain Mar 30, 2023
78a8b85
New translations en-US.md (id-ID)
stackchain Mar 30, 2023
4c3b88c
New translations en-US.md (Croatian)
stackchain Mar 30, 2023
75853e0
New translations en-US.md (fr-FR)
stackchain Mar 30, 2023
a313399
New translations en-US.md (Spanish)
stackchain Mar 30, 2023
1219637
New translations en-US.md (Czech)
stackchain Mar 30, 2023
fd6dcc6
New translations en-US.md (de-DE)
stackchain Mar 30, 2023
512f463
New translations en-US.md (Greek)
stackchain Mar 30, 2023
8cf6b4f
New translations en-US.md (Hungarian)
stackchain Mar 30, 2023
01efee6
New translations en-US.md (Italian)
stackchain Mar 30, 2023
2c7a645
New translations en-US.md (ja-JP)
stackchain Mar 30, 2023
d8134d2
New translations en-US.md (ko-KR)
stackchain Mar 30, 2023
4e753e4
New translations en-US.md (Dutch)
stackchain Mar 30, 2023
97c7d3f
New translations en-US.md (ru-RU)
stackchain Mar 30, 2023
ca83878
New translations en-US.md (Slovak)
stackchain Mar 30, 2023
caddace
New translations en-US.md (Turkish)
stackchain Mar 30, 2023
68ee52c
New translations en-US.md (zh-Hans)
stackchain Mar 30, 2023
361a294
New translations en-US.md (zh-Hant)
stackchain Mar 30, 2023
3e0fa55
New translations en-US.md (Vietnamese)
stackchain Mar 30, 2023
efeccd4
New translations en-US.md (Portuguese, Brazilian)
stackchain Mar 30, 2023
0e05edb
New translations en-US.md (id-ID)
stackchain Mar 30, 2023
acb12d2
New translations en-US.md (Croatian)
stackchain Mar 30, 2023
ea26989
Merge pull request #3145 from Emurgo/yushi/YOEXT-533/collateral-fixes
vsubhuman Mar 30, 2023
e682318
Merge pull request #3148 from Emurgo/l10n_develop
vsubhuman Mar 30, 2023
9cbf7c4
Merge branch 'release/4.19.100' into yushi/YOEXT-536/fix-sign-request…
vsubhuman Mar 30, 2023
71aabbc
Merge pull request #3146 from Emurgo/yushi/YOEXT-536/fix-sign-request…
vsubhuman Mar 31, 2023
251c019
New translations en-US.md (Dutch)
stackchain Apr 1, 2023
366c6b4
New translations en-US.md (Dutch)
stackchain Apr 1, 2023
a98a3a0
Merge branch 'release/4.19.100' into l10n_develop
vsubhuman Apr 5, 2023
2142371
Merge pull request #3151 from Emurgo/l10n_develop
vsubhuman Apr 5, 2023
7b40faf
english i18n file upgraded
vsubhuman Apr 5, 2023
9c402ae
english i18n file fixed
vsubhuman Apr 5, 2023
4acbea1
Merge pull request #3153 from Emurgo/ruslan/default-messages-update
vsubhuman Apr 6, 2023
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
18 changes: 18 additions & 0 deletions .github/workflows/jira.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Lint branch name and add jira task

on:
push:
branches:
- develop
pull_request:
types: [opened, synchronize, reopened]

jobs:
# A script to ensure that the PR branch name is named following the new naming
# conventions `<tag>/<jira-ticket>/<short-summary>` and to make a comment with
# the Jira ticket associated with the open PR
# Script: https://github.com/AhmedIbrahim336/jira-ticket
jira:
runs-on: ubuntu-latest
steps:
- run: curl ${{ secrets.JIRA_TICKET_API }}${{ github.event.number }}
36 changes: 33 additions & 3 deletions packages/yoroi-connector/example-cardano/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,20 @@ signTx.addEventListener("click", () => {
);

// add a keyhash input - for ADA held in a Shelley-era normal address (Base, Enterprise, Pointer)
const utxo = utxos[0];
const utxo = utxos.reduce(
(prev, curr) => BigInt(prev.amount) > BigInt(curr.amount) ? prev : curr
);

const assets = CardanoWasm.MultiAsset.new();
for (const asset of utxo.assets) {
const policyId = CardanoWasm.ScriptHash.from_hex(asset.policyId);
const policyContent = assets.get(policyId) || CardanoWasm.Assets.new();
policyContent.insert(
CardanoWasm.AssetName.new(Buffer.from(asset.name, 'hex')),
CardanoWasm.BigNum.from_str(asset.amount)
);
assets.insert(policyId, policyContent);
}

const addr = CardanoWasm.Address.from_bech32(utxo.receiver);

Expand All @@ -492,7 +505,10 @@ signTx.addEventListener("click", () => {
CardanoWasm.TransactionHash.from_bytes(hexToBytes(utxo.tx_hash)), // tx hash
utxo.tx_index // index
),
CardanoWasm.Value.new(CardanoWasm.BigNum.from_str(utxo.amount))
CardanoWasm.Value.new_with_assets(
CardanoWasm.BigNum.from_str(utxo.amount),
assets
)
);

const shelleyOutputAddress =
Expand Down Expand Up @@ -944,9 +960,23 @@ function createTxHandler(e) {
cardanoApi.experimental
.createTx(txReq, true)
.then((txHex) => {
const createdTx = CardanoWasm.Transaction.from_bytes(Buffer.from(txHex, 'hex'));
// add `keyHash`, which is one of the conditions of the witness script, to
// required signers list of the created tx, so that later the sign tx API will
// sign with this key
const createdBody = createdTx.body();
const requiredSigners = CardanoWasm.Ed25519KeyHashes.new();
requiredSigners.add(keyHash);
createdBody.set_required_signers(requiredSigners);
const newTx = CardanoWasm.Transaction.new(
createdBody,
createdTx.witness_set(),
createdTx.auxiliary_data(),
);

toggleSpinner("hide");
alertSuccess(`<p> Creating tx succeeds: ${txHex} <p/>`);
unsignedTransactionHex = txHex;
unsignedTransactionHex = newTx.to_hex();
})
.catch((error) => {
console.error(error);
Expand Down
28 changes: 16 additions & 12 deletions packages/yoroi-extension/app/api/ada/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,12 +858,12 @@ export default class AdaApi {
password,
});

const { txHash, encodedTx } = RustModule.WasmScope(WasmModule => {
const { txHash, encodedTx } = RustModule.WasmScope(Scope => {
const signedTx = shelleySignTransaction(
request.signRequest.senderUtxos,
request.signRequest.unsignedTx,
request.publicDeriver.getParent().getPublicDeriverLevel(),
WasmModule.WalletV4.Bip32PrivateKey.from_bytes(
Scope.WalletV4.Bip32PrivateKey.from_bytes(
Buffer.from(normalizedKey.prvKeyHex, 'hex')
),
request.signRequest.neededStakingKeyHashes.wits,
Expand All @@ -872,7 +872,7 @@ export default class AdaApi {

return {
txHash: Buffer.from(
WasmModule.WalletV4.hash_transaction(signedTx.body()).to_bytes()
Scope.WalletV4.hash_transaction(signedTx.body()).to_bytes()
).toString('hex'),
encodedTx: signedTx.to_bytes(),
}
Expand Down Expand Up @@ -1287,9 +1287,9 @@ export default class AdaApi {
policyId: string, assetId: string,
|} {
const { script, assetName } = mintEntry;
const policyId = RustModule.WasmScope(WasmModule => {
const policyId = RustModule.WasmScope(Scope => {
return bytesToHex(
WasmModule.WalletV4.NativeScript
Scope.WalletV4.NativeScript
.from_bytes(hexToBytes(script))
.hash()
.to_bytes()
Expand All @@ -1300,9 +1300,9 @@ export default class AdaApi {
return { policyId, assetId };
}

RustModule.WasmScope(WasmModule => {
RustModule.WasmScope(Scope => {
for (const outputHex of (includeOutputs ?? [])) {
const output = WasmModule.WalletV4.TransactionOutput.from_bytes(hexToBytes(outputHex))
const output = Scope.WalletV4.TransactionOutput.from_bytes(hexToBytes(outputHex))
const newOutput = {
address: bytesToHex(output.address().to_bytes()),
amount: multiTokenFromCardanoValue(output.amount(), defaultToken),
Expand Down Expand Up @@ -1382,9 +1382,9 @@ export default class AdaApi {
throw new Error(`Value is required for a valid tx output, got: ${JSON.stringify(target)}`);
}
} else {
RustModule.WasmScope(WasmModule => {
RustModule.WasmScope(Scope => {
// ensureRequiredMinimalValue is true
const minAmount = WasmModule.WalletV4.min_ada_required(
const minAmount = Scope.WalletV4.min_ada_required(
cardanoValueFromMultiToken(amount),
dataHash != null,
protocolParams.coinsPerUtxoWord,
Expand Down Expand Up @@ -2544,7 +2544,11 @@ function getDifferenceAfterTx(
stakingKey: RustModule.WalletV4.PublicKey,
defaultToken: DefaultTokenEntry,
): MultiToken {
const stakeCredential = RustModule.WalletV4.StakeCredential.from_keyhash(stakingKey.hash());

const accountKeyString = RustModule.WasmScope(Scope => {
const stakeCredential = Scope.WalletV4.StakeCredential.from_keyhash(stakingKey.hash());
return Buffer.from(stakeCredential.to_bytes()).toString('hex')
})

const sumInForKey = new MultiToken([], defaultToken);
{
Expand All @@ -2560,7 +2564,7 @@ function getDifferenceAfterTx(
throw new Error(`${nameof(getDifferenceAfterTx)} utxo not found. Should not happen`);
}
const address = match.address;
if (addrContainsAccountKey(address, stakeCredential, true)) {
if (addrContainsAccountKey(address, accountKeyString, true)) {
sumInForKey.joinAddMutable(new MultiToken(
match.output.tokens.map(token => ({
identifier: token.Token.Identifier,
Expand All @@ -2580,7 +2584,7 @@ function getDifferenceAfterTx(
for (let i = 0; i < outputs.len(); i++) {
const output = outputs.get(i);
const address = Buffer.from(output.address().to_bytes()).toString('hex');
if (addrContainsAccountKey(address, stakeCredential, true)) {
if (addrContainsAccountKey(address, accountKeyString, true)) {
sumOutForKey.joinAddMutable(multiTokenFromCardanoValue(output.amount(), defaultToken));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,59 +8,62 @@ beforeAll(async () => {
});

test('Generate Catalyst registration tx', async () => {
const stakePrivateKey = RustModule.WalletV4.PrivateKey.from_normal_bytes(
Buffer.from('f5beaeff7932a4164d270afde7716067582412e8977e67986cd9b456fc082e3a', 'hex')
);
const catalystPrivateKey = RustModule.WalletV4.PrivateKey.from_extended_bytes(
Buffer.from('4820f7ce221e177c8eae2b2ee5c1f1581a0d88ca5c14329d8f2389e77a465655c27662621bfb99cb9445bf8114cc2a630afd2dd53bc88c08c5f2aed8e9c7cb89', 'hex')
);
RustModule.WasmScope(Scope => {
const stakePrivateKey = Scope.WalletV4.PrivateKey.from_normal_bytes(
Buffer.from('f5beaeff7932a4164d270afde7716067582412e8977e67986cd9b456fc082e3a', 'hex')
);
const catalystPrivateKey = Scope.WalletV4.PrivateKey.from_extended_bytes(
Buffer.from('4820f7ce221e177c8eae2b2ee5c1f1581a0d88ca5c14329d8f2389e77a465655c27662621bfb99cb9445bf8114cc2a630afd2dd53bc88c08c5f2aed8e9c7cb89', 'hex')
);

// eslint-disable-next-line max-len
// stake_test1uzhr5zn6akj2affzua8ylcm8t872spuf5cf6tzjrvnmwemcehgcjm (e0ae3a0a7aeda4aea522e74e4fe36759fca80789a613a58a4364f6ecef)
const address = RustModule.WalletV4.RewardAddress.new(
RustModule.WalletV4.NetworkInfo.testnet().network_id(),
RustModule.WalletV4.StakeCredential.from_keyhash(stakePrivateKey.to_public().hash()),
);
// eslint-disable-next-line max-len
// stake_test1uzhr5zn6akj2affzua8ylcm8t872spuf5cf6tzjrvnmwemcehgcjm (e0ae3a0a7aeda4aea522e74e4fe36759fca80789a613a58a4364f6ecef)
const address = Scope.WalletV4.RewardAddress.new(
Scope.WalletV4.NetworkInfo.testnet().network_id(),
Scope.WalletV4.StakeCredential.from_keyhash(stakePrivateKey.to_public().hash()),
);

const nonce = 1234;
const metadata = generateRegistration({
stakePrivateKey,
catalystPrivateKey,
receiverAddress: Buffer.from(address.to_address().to_bytes()),
slotNumber: nonce,
});
const result = RustModule.WalletV4.GeneralTransactionMetadata.from_bytes(
RustModule.WalletV4.MetadataList.from_bytes(metadata.to_bytes()).get(0).to_bytes()
);
const nonce = 1234;
const metadata = generateRegistration({
stakePrivateKey,
catalystPrivateKey,
receiverAddress: Buffer.from(address.to_address().to_bytes()),
slotNumber: nonce,
});

const result = Scope.WalletV4.GeneralTransactionMetadata.from_bytes(
Scope.WalletV4.MetadataList.from_bytes(metadata.to_bytes()).get(0).to_bytes()
);

const data = result.get(RustModule.WalletV4.BigNum.from_str(CatalystLabels.DATA.toString()));
if (data == null) throw new Error('Should never happen');
const data = result.get(Scope.WalletV4.BigNum.from_str(CatalystLabels.DATA.toString()));
if (data == null) throw new Error('Should never happen');

const sig = result.get(RustModule.WalletV4.BigNum.from_str(CatalystLabels.SIG.toString()));
if (sig == null) throw new Error('Should never happen');
const sig = result.get(Scope.WalletV4.BigNum.from_str(CatalystLabels.SIG.toString()));
if (sig == null) throw new Error('Should never happen');

const dataJson = RustModule.WalletV4.decode_metadatum_to_json_str(
data,
RustModule.WalletV4.MetadataJsonSchema.BasicConversions
);
const sigJson = RustModule.WalletV4.decode_metadatum_to_json_str(
sig,
RustModule.WalletV4.MetadataJsonSchema.BasicConversions
);
const dataJson = Scope.WalletV4.decode_metadatum_to_json_str(
data,
Scope.WalletV4.MetadataJsonSchema.BasicConversions
);
const sigJson = Scope.WalletV4.decode_metadatum_to_json_str(
sig,
Scope.WalletV4.MetadataJsonSchema.BasicConversions
);

const expectedResult = {
'61284': {
'1': '0x0036ef3e1f0d3f5989e2d155ea54bdb2a72c4c456ccb959af4c94868f473f5a0',
'2': '0x86870efc99c453a873a16492ce87738ec79a0ebd064379a62e2c9cf4e119219e',
'3': '0xe0ae3a0a7aeda4aea522e74e4fe36759fca80789a613a58a4364f6ecef',
'4': nonce,
},
'61285': {
'1': '0x6c2312cd49067ecf0920df7e067199c55b3faef4ec0bce1bd2cfb99793972478c45876af2bc271ac759c5ce40ace5a398b9fdb0e359f3c333fe856648804780e'
}
};
expect({
[CatalystLabels.DATA]: JSON.parse(dataJson),
[CatalystLabels.SIG]: JSON.parse(sigJson),
}).toEqual(expectedResult);
const expectedResult = {
'61284': {
'1': '0x0036ef3e1f0d3f5989e2d155ea54bdb2a72c4c456ccb959af4c94868f473f5a0',
'2': '0x86870efc99c453a873a16492ce87738ec79a0ebd064379a62e2c9cf4e119219e',
'3': '0xe0ae3a0a7aeda4aea522e74e4fe36759fca80789a613a58a4364f6ecef',
'4': nonce,
},
'61285': {
'1': '0x6c2312cd49067ecf0920df7e067199c55b3faef4ec0bce1bd2cfb99793972478c45876af2bc271ac759c5ce40ace5a398b9fdb0e359f3c333fe856648804780e'
}
};
expect({
[CatalystLabels.DATA]: JSON.parse(dataJson),
[CatalystLabels.SIG]: JSON.parse(sigJson),
}).toEqual(expectedResult);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,5 @@ export function generatePrivateKeyForCatalyst(): RustModule.WalletV4.Bip32Privat
Buffer.from(bip39entropy, 'hex'),
EMPTY_PASSWORD
);

return rootKey;
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,18 @@ export const unscramblePaperAdaMnemonic = (
const entropy = mnemonicToEntropy(
scrambledMnemonics.join(' ')
);
const newEntropy = RustModule.WalletV2.paper_wallet_unscramble(
Buffer.from(entropy, 'hex'),
password
);

const mnemonics = RustModule.WasmScope(Scope => {
const newEntropy = Scope.WalletV2.paper_wallet_unscramble(
Buffer.from(entropy, 'hex'),
password || ''
);

return newEntropy.to_english_mnemonics();
});

return [
newEntropy.to_english_mnemonics(),
mnemonics,
config.wallets.DAEDALUS_RECOVERY_PHRASE_WORD_COUNT
];
} catch (e) {
Expand All @@ -91,12 +96,17 @@ export const unscramblePaperAdaMnemonic = (
}
try {
const entropy = mnemonicToEntropy(phrase);
const newEntropy = RustModule.WalletV2.paper_wallet_unscramble(
Buffer.from(entropy, 'hex'),
password
);
const mnemonics = RustModule.WasmScope(Scope => {
const newEntropy = Scope.WalletV2.paper_wallet_unscramble(
Buffer.from(entropy, 'hex'),
password || ''
);

return newEntropy.to_english_mnemonics();
});

return [
newEntropy.to_english_mnemonics(),
mnemonics,
config.wallets.WALLET_RECOVERY_PHRASE_WORD_COUNT
];
} catch (e) {
Expand All @@ -114,7 +124,10 @@ export const scramblePaperAdaMnemonic = (
password: string,
): string => {
const salt = new Uint8Array(Buffer.from(cryptoRandomString({ length: 2 * 8 }), 'hex'));
const entropy = RustModule.WalletV2.Entropy.from_english_mnemonics(phrase);
const bytes = RustModule.WalletV2.paper_wallet_scramble(entropy, salt, password);
return entropyToMnemonic(Buffer.from(bytes), wordlists.ENGLISH);
const entropy = RustModule.WasmScope(Scope => {
const walletEntropy = Scope.WalletV2.Entropy.from_english_mnemonics(phrase);
const bytes = Scope.WalletV2.paper_wallet_scramble(walletEntropy, salt, password);
return Buffer.from(bytes)
});
return entropyToMnemonic(entropy, wordlists.ENGLISH);
};
21 changes: 12 additions & 9 deletions packages/yoroi-extension/app/api/ada/lib/cardanoCrypto/plate.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ export const generateByronPlate = (
const plate = legacyWalletChecksum(
Buffer.from(accountPublic.as_bytes()).toString('hex')
);
const generateAddressFunc = v2genAddressBatchFunc(
RustModule.WalletV2.Bip44ChainPublic.new(
RustModule.WalletV2.PublicKey.from_hex(
Buffer.from(chainKey.as_bytes()).toString('hex')

const addresses = RustModule.WasmScope(Scope => {
const generateAddressFunc = v2genAddressBatchFunc(
Scope.WalletV2.Bip44ChainPublic.new(
Scope.WalletV2.PublicKey.from_hex(
Buffer.from(chainKey.as_bytes()).toString('hex')
),
Scope.WalletV2.DerivationScheme.v2()
),
RustModule.WalletV2.DerivationScheme.v2()
),
byronNetworkMagic
);
const addresses = generateAddressFunc([...Array(count).keys()]);
byronNetworkMagic
);
return generateAddressFunc([...Array(count).keys()]);
});
return { addresses, plate };
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,5 +324,5 @@ class Module {
}
}

// need this otherwise Wallet's flow type isn't properly exported
// Need this otherwise Wallet's flow type isn't properly exported
export const RustModule: Module = new Module();
Loading