Skip to content

Commit

Permalink
bump trezor-connect version and adapt to API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yushih committed Jul 29, 2021
1 parent 02fe904 commit 7b0c4b4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
Expand Up @@ -103,34 +103,31 @@ export async function createTrezorSignTxPayload(
)
};

const metadata = signRequest.metadata;
request = metadata === undefined
? request
: {
...request,
metadata: Buffer.from(metadata.to_bytes()).toString('hex')
};

if (signRequest.trezorTCatalystRegistrationTxSignData) {
const { votingPublicKey, nonce } = signRequest.trezorTCatalystRegistrationTxSignData;
request = {
...request,
auxiliaryData: {
catalystRegistrationParameters: {
votingPublicKey,
votingPublicKey: votingPublicKey.replace(/^0x/, ''),
stakingPath: getStakingKeyPath(),
rewardAddressParameters: {
addressType: ADDRESS_TYPE.Reward,
stakingPath: getStakingKeyPath(),
path: getStakingKeyPath(),
},
nonce,
nonce: String(nonce),
},
}
};
} else {
const metadata = signRequest.metadata;
request = metadata === undefined
? request
: {
...request,
auxiliaryData: { blob: Buffer.from(metadata.to_bytes()).toString('hex') }
};
}
// trezor-connect v8.1.26 doesn't support auxiliaryData. When it does, we
// can remove the next line:
// $FlowFixMe[prop-missing]
return request;
}

Expand Down
18 changes: 15 additions & 3 deletions packages/yoroi-extension/features/mock-trezor-connect/index.js
Expand Up @@ -404,9 +404,9 @@ class MockTrezorConnect {
body.set_certs(certs);
}

const metadata = request.metadata != null
const metadata = request.auxiliaryData?.blob != null
? RustModule.WalletV4.TransactionMetadata.from_bytes(
Buffer.from(request.metadata, 'hex')
Buffer.from(request.auxiliaryData.blob, 'hex')
)
: undefined;
if (metadata != null) {
Expand Down Expand Up @@ -535,7 +535,19 @@ class MockTrezorConnect {
fw_vendor: (null: any),
fw_vendor_keys: (null: any),
unfinished_backup: false,
no_backup: false
no_backup: false,
recovery_mode: false,
backup_type: null,
sd_card_present: false,
sd_protection: false,
wipe_code_protection: false,
session_id: null,
passphrase_always_on_device: false,
safety_checks: null,
auto_lock_delay_ms: 0,
display_rotation: 0,
experimental_features: false,
unlocked: false,
}
}: KnownDevice)
}));
Expand Down
6 changes: 3 additions & 3 deletions packages/yoroi-extension/package-lock.json

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

2 changes: 1 addition & 1 deletion packages/yoroi-extension/package.json
Expand Up @@ -212,7 +212,7 @@
"semver": "7.3.4",
"stream-browserify": "3.0.0",
"tinycolor2": "1.4.2",
"trezor-connect": "8.1.26",
"trezor-connect": "8.1.29",
"ua-parser-js": "0.7.24",
"unorm": "1.6.0",
"validator": "13.5.2"
Expand Down

0 comments on commit 7b0c4b4

Please sign in to comment.