Skip to content

Commit 90bf3a7

Browse files
jaskpmroz22
authored andcommitted
feat(connect): Add tag 258 support
1 parent ab003ce commit 90bf3a7

File tree

6 files changed

+99
-0
lines changed

6 files changed

+99
-0
lines changed

docs/packages/connect/methods/cardanoSignTransaction.md

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const result = await TrezorConnect.cardanoSignTransaction(params);
3636
- `derivationType`_optional_ `CardanoDerivationType` enum. Determines used derivation type. Default is set to ICARUS_TREZOR=2.
3737
- `includeNetworkId`_optional_ `Boolean`. Determines whether `networkId` should be explicitly serialized into the transaction body. Default is `false`.
3838
- `chunkify`_optional_ `boolean` determines if recipient address will be displayed in chunks of 4 characters. Default is set to `false`
39+
- `tagCborSets` - _optional_ `boolean` determines if CBOR arrays intended to be sets will be encoded with tag 258. Default is set to `false`
3940

4041
### CardanoTxSigningMode
4142

packages/connect-explorer/src/pages/methods/cardano/cardanoSignTransaction.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export const paramDescriptions = {
5353
'Determines whether `networkId` should be explicitly serialized into the transaction body. Default is `false`.',
5454
chunkify:
5555
'determines if recipient address will be displayed in chunks of 4 characters. Default is set to `false`',
56+
tagCborSets:
57+
'determines if CBOR arrays intended to be sets will be encoded with tag 258. Default is set to `false`',
5658
};
5759

5860
## Cardano: Sign transaction

packages/connect/e2e/__fixtures__/cardanoSignTransaction.ts

+87
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ export default {
660660
protocolMagic: PROTOCOL_MAGICS.mainnet,
661661
networkId: NETWORK_IDS.mainnet,
662662
signingMode: CardanoTxSigningMode.ORDINARY_TRANSACTION,
663+
tagCborSets: false,
663664
},
664665
result: {
665666
hash: 'e200b2c91f3493a1f3b9cfc8b6c141f70181741025e53941e9d57d22b1470c5c',
@@ -684,6 +685,42 @@ export default {
684685
legacyResults: [legacyResults.beforeConway],
685686
},
686687

688+
{
689+
description: 'signStakeRegistrationConwayWith258TaggedSets',
690+
params: {
691+
inputs: [SAMPLE_INPUTS.shelley_input],
692+
outputs: [SAMPLE_OUTPUTS.simple_shelley_output],
693+
fee: FEE,
694+
ttl: TTL,
695+
certificates: [SAMPLE_CERTIFICATES.stake_registration_conway],
696+
protocolMagic: PROTOCOL_MAGICS.mainnet,
697+
networkId: NETWORK_IDS.mainnet,
698+
signingMode: CardanoTxSigningMode.ORDINARY_TRANSACTION,
699+
tagCborSets: true,
700+
},
701+
result: {
702+
hash: '5e27f8fba938603411452a8cb373462fb64305539573b7a9edc9155be5cd6473',
703+
witnesses: [
704+
{
705+
type: 1,
706+
pubKey: '5d010cf16fdeff40955633d6c565f3844a288a24967cf6b76acbeb271b4f13c1',
707+
signature:
708+
'13c136487d8048ab7bbb081a324aa6b999e0b3237f956503b5446a4c409ec1062091b82e9e5459dee7ab0ba67ed874692d788872c8bbdb5ad4a3975c465fea09',
709+
chainCode: null,
710+
},
711+
{
712+
type: 1,
713+
pubKey: 'bc65be1b0b9d7531778a1317c2aa6de936963c3f9ac7d5ee9e9eda25e0c97c5e',
714+
signature:
715+
'f0674db7194d8e04d7df416af8ad9dcf1b1203ca4b78f14c1e394d47418c8f7e95fd41a8f01c43eeeb39df6264359c865a41621fc1e6b540819b25c7c4df5803',
716+
chainCode: null,
717+
},
718+
],
719+
auxiliaryDataSupplement: undefined,
720+
},
721+
legacyResults: [legacyResults.beforeConway],
722+
},
723+
687724
{
688725
description: 'signStakeRegistrationNoOutputs',
689726
params: {
@@ -2424,6 +2461,56 @@ export default {
24242461
},
24252462
},
24262463

2464+
{
2465+
description: 'plutusWithRequiredSignersAndReferenceInputAnd258TaggedSets',
2466+
params: {
2467+
inputs: [SAMPLE_INPUTS.shelley_input],
2468+
outputs: [SAMPLE_OUTPUTS.simple_shelley_output],
2469+
fee: FEE,
2470+
ttl: TTL,
2471+
protocolMagic: PROTOCOL_MAGICS.mainnet,
2472+
networkId: NETWORK_IDS.mainnet,
2473+
signingMode: CardanoTxSigningMode.PLUTUS_TRANSACTION,
2474+
scriptDataHash: SCRIPT_DATA_HASH,
2475+
collateralInputs: [SAMPLE_INPUTS.shelley_input_2],
2476+
requiredSigners: [
2477+
{ keyPath: "m/1852'/1815'/0'/0/0" },
2478+
{ keyPath: "m/1854'/1815'/0'/0/0" },
2479+
{ keyHash: '3a7f09d3df4cf66a7399c2b05bfa234d5a29560c311fc5db4c490711' },
2480+
],
2481+
referenceInput: [SAMPLE_INPUTS.plutus_input],
2482+
tagCborSets: true,
2483+
},
2484+
result: {
2485+
hash: 'eee852948723773f059bbbc9f4378473e339a62ec518ac3aeb8ecdf27abf8581',
2486+
witnesses: [
2487+
{
2488+
type: 1,
2489+
pubKey: '5d010cf16fdeff40955633d6c565f3844a288a24967cf6b76acbeb271b4f13c1',
2490+
signature:
2491+
'ccf25b4926d4ea953f9330196f881ec6974b3979a05fd679e846eb0fd90f5e5d64cdba51fad9354a50343a29c09dfda8177fd1717ca8d105c9d923a31071b909',
2492+
chainCode: null,
2493+
},
2494+
{
2495+
type: 1,
2496+
pubKey: '36a8ef21d5b98fdf23a27325cf643deaac35e912c835e35037f23d1061ae5b16',
2497+
signature:
2498+
'39231ff0df125987c5a7583f307d74d3bdcb9702baafc8588aa16002d19d595725da64518603bb0617bfba851fe96f0cf75c19d75b0749443e09fdc8aebb4603',
2499+
chainCode: null,
2500+
},
2501+
{
2502+
type: 1,
2503+
pubKey: 'b10be5c0d11ad8292bbe69e220ca0cfbe154610b3041a8e72f9d515c226ab3b1',
2504+
signature:
2505+
'e78e5a21c07ed5f613d01d20f9684a3b807b30ca211f69a2a0391ab3137d3b1260c51bdf08079e213e2487f3b8c36d6b42d7d15733113cf725ca3f162f030001',
2506+
chainCode: null,
2507+
},
2508+
],
2509+
auxiliaryDataSupplement: undefined,
2510+
},
2511+
legacyResults: [legacyResults.beforeConway],
2512+
},
2513+
24272514
{
24282515
description: 'plutusWithManyWitnesses',
24292516
params: {

packages/connect/src/api/cardano/api/cardanoSignTransaction.ts

+7
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export type CardanoSignTransactionParams = {
6565
additionalWitnessRequests: Path[];
6666
derivationType: PROTO.CardanoDerivationType;
6767
includeNetworkId?: boolean;
68+
tagCborSets?: boolean;
6869
unsignedTx?: { body: string; hash: string };
6970
testnet?: boolean;
7071
chunkify?: boolean;
@@ -223,6 +224,7 @@ export default class CardanoSignTransaction extends AbstractMethod<
223224
? payload.derivationType
224225
: PROTO.CardanoDerivationType.ICARUS_TREZOR,
225226
includeNetworkId: payload.includeNetworkId,
227+
tagCborSets: payload.tagCborSets,
226228
unsignedTx: 'unsignedTx' in payload ? payload.unsignedTx : undefined,
227229
testnet: 'testnet' in payload ? payload.testnet : undefined,
228230
chunkify: typeof payload.chunkify === 'boolean' ? payload.chunkify : false,
@@ -258,6 +260,10 @@ export default class CardanoSignTransaction extends AbstractMethod<
258260
this._ensureFeatureIsSupported('Conway');
259261
}
260262
});
263+
264+
if (params.tagCborSets) {
265+
this._ensureFeatureIsSupported('Conway');
266+
}
261267
}
262268

263269
async _sign_tx(): Promise<CardanoSignedTxData> {
@@ -288,6 +294,7 @@ export default class CardanoSignTransaction extends AbstractMethod<
288294
derivation_type: this.params.derivationType,
289295
include_network_id: this.params.includeNetworkId,
290296
chunkify: this.params.chunkify,
297+
tag_cbor_sets: this.params.tagCborSets,
291298
};
292299

293300
// init

packages/connect/src/types/api/__tests__/cardano.ts

+1
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ export const cardanoSignTransaction = async (api: TrezorConnect) => {
401401
networkId: 0,
402402
signingMode: CardanoTxSigningMode.ORDINARY_TRANSACTION,
403403
includeNetworkId: false,
404+
tagCborSets: false,
404405
});
405406

406407
if (sign.success) {

packages/connect/src/types/api/cardano/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ export const CardanoSignTransaction = Type.Object({
262262
derivationType: Type.Optional(PROTO.EnumCardanoDerivationType),
263263
includeNetworkId: Type.Optional(Type.Boolean()),
264264
chunkify: Type.Optional(Type.Boolean()),
265+
tagCborSets: Type.Optional(Type.Boolean()),
265266
});
266267

267268
export type CardanoSignTransactionExtended = Static<typeof CardanoSignTransactionExtended>;

0 commit comments

Comments
 (0)