11import { Kiln , KILN_VALIDATORS } from '../src/kiln.ts' ;
22import type { FireblocksIntegration } from '../src/fireblocks.ts' ;
33import { loadEnv } from './env.ts' ;
4- import { parseUnits } from " viem" ;
4+ import { parseUnits } from ' viem' ;
55
66const { kilnApiKey, kilnAccountId, kilnApiUrl, fireblocksApiKey, fireblocksApiSecret, fireblocksVaultId } =
77 await loadEnv ( ) ;
@@ -20,15 +20,31 @@ const vault: FireblocksIntegration = {
2020 vaultId : fireblocksVaultId ,
2121} ;
2222
23+ //
24+ // Get the wallet address from Fireblocks
25+ //
26+ const fireblocksWallet = (
27+ await k . fireblocks . getSdk ( vault ) . vaults . getVaultAccountAssetAddressesPaginated ( {
28+ vaultAccountId : vault . vaultId ,
29+ assetId : 'NEAR' ,
30+ limit : 1 ,
31+ } )
32+ ) . data . addresses ?. [ 0 ] . address ;
33+
34+ if ( ! fireblocksWallet ) {
35+ console . log ( 'Failed to get fireblocks wallet' ) ;
36+ process . exit ( 0 ) ;
37+ }
38+
2339//
2440// Craft the transaction
2541//
2642console . log ( 'Crafting transaction...' ) ;
2743const txRequest = await k . client . POST ( '/near/transaction/stake' , {
2844 body : {
2945 account_id : kilnAccountId ,
30- wallet : 'c36b1a5da2e60d1fd5d3a6b46f7399eb26571457f3272f3c978bc9527ad2335f' ,
31- pool_id : KILN_VALIDATORS . NEAR . testnet . KILN ,
46+ wallet : fireblocksWallet ,
47+ pool_id : KILN_VALIDATORS . NEAR . mainnet . KILN ,
3248 amount_yocto : parseUnits ( '0.1' , 24 ) . toString ( ) ,
3349 } ,
3450} ) ;
@@ -47,7 +63,7 @@ console.log('Signing transaction...');
4763const signRequest = await ( async ( ) => {
4864 try {
4965 // @ts -ignore
50- return await k . fireblocks . signNearTx ( vault , txRequest . data . data , "NEAR_TEST" ) ;
66+ return await k . fireblocks . signNearTx ( vault , txRequest . data . data , 'NEAR' ) ;
5167 } catch ( err ) {
5268 console . log ( 'Failed to sign transaction:' , err ) ;
5369 process . exit ( 1 ) ;
0 commit comments