Upgrade guide from v2 to v3

How to upgrade our JS SDK to new major version

v3 changelog

Here is the high level changelog of the v3:

  • The Kiln class now exposes a type safe HTTP client that exposes all Kiln Connect endpoints available. The client is generated from our OpenAPI specs. The OpenAPI typescript schema is also exposed so you can benefit from all type definitions. The schema and SDK will be updated frequently with newly added endpoints.

  • The fireblocks raw signing feature is now under the fireblocks service exposed by the Kiln class. A sign method is available for all protocols we support.

Upgrade from 2.X to 3.X

Update your dependencies:

bun i @kilnfi/sdk@latest

Update calls to use the http client instead of specific protocol object.

2.X:

const k = new Kiln({
  testnet: true,
  apiToken: 'kiln_xxx',
});

const vault: Integration = {
  provider: 'fireblocks',
  fireblocksApiKey: 'YOUR_API_USER_KEY', // your fireblocks API user key
  fireblocksSecretKey: apiSecret, // your fireblocks private key (generated with your CSR file and your API user)
  vaultId: 7 // your fireblocks vault id
};

...
const tx = await k.near.craftStakeTx(
      'account_id',
      'wallet',
      'pool_id',
      0.1,
    );
const txSigned = await k.near.sign(vault, tx);

3.X:

const k = new Kiln({
  baseUrl: 'https://api.testnet.kiln.fi',
  apiToken: 'kiln_xxx',
});

const vault: Integration = {
  provider: 'fireblocks',
  fireblocksApiKey: 'YOUR_API_USER_KEY', // your fireblocks API user key
  fireblocksSecretKey: apiSecret, // your fireblocks private key (generated with your CSR file and your API user)
  vaultId: 7 // your fireblocks vault id
};

const tx = await k.client.POST(
      '/v1/near/transaction/stake',
      {
        body: {
          account_id: 'account_id',
          wallet: 'wallet',
          pool_id: 'pool_id',
          amount_yocto: '1000000000000000000000000',
        }
      }
    );

const signResponse = await k.fireblocks.signNearTx(vault, tx.data.data, "NEAR_TEST");

const broadcastedTx = await k.client.POST("/v1/near/transaction/broadcast", {
      body: {
        signed_tx_serialized: signResponse.signed_tx.data.signed_tx_serialized,
      }
    });

Last updated