Skip to content

Commit 38a17e0

Browse files
feat: Support RAW tx for Solana (#444)
1 parent 08c8e41 commit 38a17e0

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

.changeset/two-camels-hear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ledgerhq/wallet-api-core": minor
3+
---
4+
5+
Support RAW tx for Solana

packages/core/src/families/solana/serializer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ export function serializeSolanaTransaction({
66
family,
77
model,
88
recipient,
9+
raw,
910
}: SolanaTransaction): RawSolanaTransaction {
1011
return {
1112
amount: amount.toString(),
1213
family,
1314
model: JSON.stringify(model),
1415
recipient,
16+
raw,
1517
};
1618
}
1719

@@ -20,12 +22,14 @@ export function deserializeSolanaTransaction({
2022
amount,
2123
model,
2224
recipient,
25+
raw,
2326
}: RawSolanaTransaction): SolanaTransaction {
2427
return {
2528
amount: new BigNumber(amount),
2629
family,
2730
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2831
model: JSON.parse(model),
2932
recipient,
33+
raw,
3034
};
3135
}

packages/core/src/families/solana/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ export type TransactionModel = { commandDescriptor?: CommandDescriptor } & (
201201
export type SolanaTransaction = TransactionCommon & {
202202
readonly family: RawSolanaTransaction["family"];
203203
model: TransactionModel;
204+
// base64-encoded serialized transaction
205+
raw?: string;
204206
};
205207

206208
export type RawSolanaTransaction = z.infer<typeof schemaRawSolanaTransaction>;

packages/core/src/families/solana/validation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ import { schemaFamilies, schemaTransactionCommon } from "../common";
44
export const schemaRawSolanaTransaction = schemaTransactionCommon.extend({
55
family: z.literal(schemaFamilies.enum.solana),
66
model: z.string(),
7+
raw: z.optional(z.string()),
78
});

packages/core/tests/serializers.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,7 @@ describe("serializers.ts", () => {
759759
memo: "test",
760760
},
761761
},
762+
raw: "any random value",
762763
};
763764
const serializedTransaction = serializeTransaction(transaction);
764765

@@ -767,6 +768,7 @@ describe("serializers.ts", () => {
767768
amount: "100",
768769
recipient: "recipient",
769770
model: '{"kind":"transfer","uiState":{"memo":"test"}}',
771+
raw: "any random value",
770772
});
771773
});
772774

@@ -1537,6 +1539,7 @@ describe("serializers.ts", () => {
15371539
amount: "100",
15381540
recipient: "recipient",
15391541
model: '{"kind":"transfer","uiState":{"memo":"test"}}',
1542+
raw: "any random value",
15401543
};
15411544

15421545
const transaction = deserializeTransaction(serializedTransaction);
@@ -1551,6 +1554,7 @@ describe("serializers.ts", () => {
15511554
memo: "test",
15521555
},
15531556
},
1557+
raw: "any random value",
15541558
});
15551559
});
15561560

0 commit comments

Comments
 (0)