22 CreateTransactionResponse ,
33 FireblocksSDK ,
44 PeerType ,
5- SigningAlgorithm ,
65 TransactionArguments ,
76 TransactionOperation ,
87 TransactionResponse ,
@@ -47,7 +46,7 @@ export class FbSigner {
4746
4847 /**
4948 * Wait for given transaction to be completed
50- * @param fbTx: fireblocks transaction
49+ * @param fbTx fireblocks transaction
5150 * @private
5251 */
5352 protected async waitForTxCompletion ( fbTx : CreateTransactionResponse ) : Promise < TransactionResponse > {
@@ -76,19 +75,25 @@ export class FbSigner {
7675
7776 /**
7877 * Sign a transaction with fireblocks using Fireblocks raw message signing feature
79- * @param payloadToSign: transaction data in hexadecimal
80- * @param assetId: fireblocks asset id
81- * @param note: optional fireblocks custom note
78+ * @param payloadToSign transaction data in hexadecimal
79+ * @param assetId fireblocks asset id
80+ * @param note optional fireblocks custom note
8281 */
83- public async signWithFB ( payloadToSign : any , assetId : AssetId , note ?: string ) : Promise < TransactionResponse > {
82+ public async sign ( payloadToSign : any , assetId ? : AssetId , note ?: string ) : Promise < TransactionResponse > {
8483 try {
84+ const assetArgs = assetId
85+ ? {
86+ assetId,
87+ source : {
88+ type : PeerType . VAULT_ACCOUNT ,
89+ id : this . vaultId . toString ( ) ,
90+ } ,
91+ }
92+ : { } ;
93+
8594 const tx : TransactionArguments = {
86- assetId : assetId ,
95+ ... assetArgs ,
8796 operation : TransactionOperation . RAW ,
88- source : {
89- type : PeerType . VAULT_ACCOUNT ,
90- id : this . vaultId . toString ( ) ,
91- } ,
9297 note,
9398 extraParameters : payloadToSign ,
9499 } ;
@@ -101,52 +106,54 @@ export class FbSigner {
101106 }
102107
103108 /**
104- * Sign a generic transaction with fireblocks using Fireblocks raw message signing feature.
105- * @param payloadToSign: transaction data in hexadecimal
106- * @param derivationPath: derivation path of the token to sign
107- * @param algorithm: algorithm of the token to sign
108- * @param note: optional fireblocks custom note
109+ * Sign an EIP-712 Ethereum typed message with fireblocks
110+ * @param eip712message eip712message to sign
111+ * @param assetId fireblocks asset id
112+ * @param note optional fireblocks custom note
109113 */
110- public async signGenericWithFB (
111- payloadContent : string ,
112- derivationPath : number [ ] ,
113- algorithm : SigningAlgorithm ,
114+ public async signTypedMessage (
115+ eip712message : any ,
116+ assetId : "ETH" | "ETH_TEST3" | "ETH_TEST6" ,
114117 note ?: string ,
115118 ) : Promise < TransactionResponse > {
116119 try {
117- const payloadToSign = {
118- operation : TransactionOperation . RAW ,
120+ const tx : TransactionArguments = {
121+ assetId : assetId ,
122+ operation : TransactionOperation . TYPED_MESSAGE ,
123+ source : {
124+ type : PeerType . VAULT_ACCOUNT ,
125+ id : this . vaultId . toString ( ) ,
126+ } ,
119127 note,
120128 extraParameters : {
121129 rawMessageData : {
122130 messages : [
123131 {
124- content : payloadContent ,
125- derivationPath ,
132+ content : eip712message ,
133+ type : "EIP712" ,
126134 } ,
127135 ] ,
128- algorithm,
129136 } ,
130137 } ,
131138 } ;
132- const fbTx = await this . fireblocks . createTransaction ( payloadToSign ) ;
139+ const fbTx = await this . fireblocks . createTransaction ( tx ) ;
133140 return await this . waitForTxCompletion ( fbTx ) ;
134141 } catch ( err : any ) {
135142 console . log ( err ) ;
136- throw new Error ( "Fireblocks signer (signGenericWithFB ): " + err ) ;
143+ throw new Error ( "Fireblocks signer (signWithFB ): " + err ) ;
137144 }
138145 }
139146
140147 /**
141148 * Sign and broadcast a transaction with fireblocks using Fireblocks contract call feature
142- * @param payloadToSign: transaction data in hexadecimal
143- * @param assetId: fireblocks asset id
144- * @param note: optional fireblocks custom note
149+ * @param payloadToSign transaction data in hexadecimal
150+ * @param assetId fireblocks asset id
151+ * @param note optional fireblocks custom note
145152 * @param tx Ethereum transaction
146153 * @param destinationId Fireblocks destination id, this corresponds to the Fireblocks whitelisted contract address id
147154 * @param sendAmount send the amount in tx to smart contract
148155 */
149- public async signAndBroadcastWithFB (
156+ public async signAndBroadcastWith (
150157 payloadToSign : any ,
151158 assetId : AssetId ,
152159 tx : EthTx | MaticTx ,
0 commit comments