feat(connect): add support for StellarClaimClaimableBalanceOp.

This commit is contained in:
overcat
2024-02-16 15:38:28 +08:00
committed by martin
parent 213043748a
commit 51a3e294d3
8 changed files with 88 additions and 0 deletions

View File

@@ -1005,6 +1005,44 @@ export const transformTransactionInputs = [
},
},
},
{
description: 'claim claimable balance operation',
path: "m/44'/148'/0'",
tx: (() => {
const op = Operation.claimClaimableBalance({
balanceId:
'00000000178826fbfe339e1f5c53417c6fedfe2c05e8bec14303143ec46b38981b09c3f9',
});
return build_tx(
DEFAULT_SOURCE,
DEFAULT_SEQUENCE,
DEFAULT_FEE,
DEFAULT_NETWORK,
DEFAULT_TIMEBOUNDS,
DEFAULT_MEMO,
op,
);
})(),
result: {
networkPassphrase: 'Public Global Stellar Network ; September 2015',
path: "m/44'/148'/0'",
transaction: {
fee: 100,
memo: { text: 'trezor stellar', type: 1 },
operations: [
{
type: 'claimClaimableBalance',
balanceId:
'00000000178826fbfe339e1f5c53417c6fedfe2c05e8bec14303143ec46b38981b09c3f9',
},
],
sequence: '103420918407103889',
source: 'GBRF6PKZYP4J4WI2A3NF4CGF23SL34GRKA5LTQZCQFEUT2YJDZO2COXH',
timebounds: { maxTime: 1700000000, minTime: 1600000000 },
},
},
},
{
description: 'none memo',
path: "m/44'/148'/0'",

View File

@@ -127,6 +127,12 @@ const transformOperation = (op: any) => {
weight: op.signer_weight,
},
};
case 'StellarClaimClaimableBalanceOp':
return {
type: 'claimClaimableBalance',
source: op.source_account,
balanceId: op.balance_id,
};
default:
return [];
}
@@ -159,6 +165,8 @@ const legacyResultsMap: Record<string, LegacyResult[]> = {
payload: false,
},
],
// newly added message in 2.6.5
StellarClaimClaimableBalanceOp: [{ rules: ['<2.6.5'], payload: false }],
};
export default {

View File

@@ -200,6 +200,12 @@ const transformOperation = (op: StellarOperation): StellarOperationMessage | und
source_account: op.source,
bump_to: op.bumpTo,
};
case 'claimClaimableBalance':
return {
type: 'StellarClaimClaimableBalanceOp',
source_account: op.source,
balance_id: op.balanceId,
};
// no default
}

View File

@@ -324,6 +324,11 @@ export const stellarSignTransaction = async (api: TrezorConnect) => {
assetCode: 'XLM',
authorize: true,
},
{
type: 'claimClaimableBalance',
balanceId:
'00000000178826fbfe339e1f5c53417c6fedfe2c05e8bec14303143ec46b38981b09c3f9',
},
],
},
});

View File

@@ -170,6 +170,15 @@ export const StellarInflationOperation = Type.Object({
source: Type.Optional(Type.String()), // Proto: "source_account"
});
export type StellarClaimClaimableBalanceOperation = Static<
typeof StellarClaimClaimableBalanceOperation
>;
export const StellarClaimClaimableBalanceOperation = Type.Object({
type: Type.Literal('claimClaimableBalance'), // Proto: "StellarClaimClaimableBalanceOp"
source: Type.Optional(Type.String()), // Proto: "source_account"
balanceId: Type.String(), // Proto: "balance_id"
});
export type StellarOperation = Static<typeof StellarOperation>;
export const StellarOperation = Type.Union([
StellarCreateAccountOperation,
@@ -186,6 +195,7 @@ export const StellarOperation = Type.Union([
StellarInflationOperation,
StellarManageDataOperation,
StellarBumpSequenceOperation,
StellarClaimClaimableBalanceOperation,
]);
export type StellarTransaction = Static<typeof StellarTransaction>;
@@ -304,4 +314,10 @@ export const StellarOperationMessage = Type.Union([
}),
PROTO.StellarBumpSequenceOp,
]),
Type.Intersect([
Type.Object({
type: Type.Literal('StellarClaimClaimableBalanceOp'),
}),
PROTO.StellarClaimClaimableBalanceOp,
]),
]);

View File

@@ -2185,6 +2185,12 @@ export type StellarBumpSequenceOp = {
bump_to: UintType;
};
// StellarClaimClaimableBalanceOp
export type StellarClaimClaimableBalanceOp = {
source_account?: string;
balance_id: string;
};
// StellarSignedTx
export type StellarSignedTx = {
public_key: string;
@@ -2577,6 +2583,7 @@ export type MessageType = {
StellarAccountMergeOp: StellarAccountMergeOp;
StellarManageDataOp: StellarManageDataOp;
StellarBumpSequenceOp: StellarBumpSequenceOp;
StellarClaimClaimableBalanceOp: StellarClaimClaimableBalanceOp;
StellarSignedTx: StellarSignedTx;
TezosGetAddress: TezosGetAddress;
TezosAddress: TezosAddress;

View File

@@ -2301,6 +2301,12 @@ source_account: Type.Optional(Type.String()),
bump_to: Type.Uint()
})
export type StellarClaimClaimableBalanceOp = Static<typeof StellarClaimClaimableBalanceOp>
export const StellarClaimClaimableBalanceOp = Type.Object({
source_account: Type.Optional(Type.String()),
balance_id: Type.String()
})
export type StellarSignedTx = Static<typeof StellarSignedTx>
export const StellarSignedTx = Type.Object({
public_key: Type.String(),
@@ -2708,6 +2714,7 @@ StellarAllowTrustOp: StellarAllowTrustOp,
StellarAccountMergeOp: StellarAccountMergeOp,
StellarManageDataOp: StellarManageDataOp,
StellarBumpSequenceOp: StellarBumpSequenceOp,
StellarClaimClaimableBalanceOp: StellarClaimClaimableBalanceOp,
StellarSignedTx: StellarSignedTx,
TezosGetAddress: TezosGetAddress,
TezosAddress: TezosAddress,

View File

@@ -68,6 +68,7 @@ const messages = {
MessageType_StellarAccountMergeOp: 218,
MessageType_StellarManageDataOp: 220,
MessageType_StellarBumpSequenceOp: 221,
MessageType_StellarClaimClaimableBalanceOp: 225,
MessageType_StellarSignedTx: 230,
},
},