Skip to content

feat(sdk-coin-near): added fungible token transfer builder #6203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025

Conversation

ravibitgo
Copy link
Contributor

@ravibitgo ravibitgo commented May 28, 2025

PR Summary

This PR introduces the FungibleTokenTransferBuilder class, responsible for constructing fungible token transfer transactions on NEAR.

In addition to this new feature, a major upgrade has been made to the near-api-js package, moving from version 0.x.x to 5.x.x.

New Feature:

  • Added FungibleTokenTransferBuilder to handle fungible token transaction creation.

Dependency Upgrade:

  • Upgraded near-api-js from 0.x.x to 5.x.x.

Required Legacy Code Changes Due to API Upgrade:

  • All amount values (e.g., deposit, gas) have been updated from BN to native BigInt.

  • Transaction signatures now support multiple key types. Direct access to signature data like this._nearSignedTransaction.signature.data is no longer valid; logic has been updated accordingly.

  • Public keys are now returned in raw format. Instead of this._nearTransaction.publicKey.toString(), we now derive a human-readable public key using this._nearSignedTransaction.signature.ed25519Signature.data via Uint8Array.

  • The nearAPI.transactions.SCHEMA structure has changed. NEAR has introduced multiple schemas, requiring updates to serialization/deserialization logic.

  • After deserializing a raw transaction, Action objects must now be constructed manually. They are no longer directly accessible from the deserialized transaction.

Ticket: COIN-4148

@ravibitgo ravibitgo force-pushed the COIN-4148 branch 2 times, most recently from 58a8aa3 to 6270567 Compare May 28, 2025 10:21
@ravibitgo ravibitgo force-pushed the COIN-4148 branch 5 times, most recently from 55221ac to 7c37206 Compare June 10, 2025 05:50
@ravibitgo ravibitgo requested a review from gianchandania June 10, 2025 06:33
const factory = new TransactionBuilderFactory(coins.get(coinNameTest));
const factoryProd = new TransactionBuilderFactory(coins.get(coinName));
const gas = '125000000000000';
const deposit = '1';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is deposit for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is needed to verify that owner (someone with FullAccess access key) doing the transaction. You can only do payable calls if you have FullAccess

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this present in any of the other builders, if not why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Staking uses this but they have setter named amount.
So in any functionCall action we have to attach a small deposit (yocto Near). Since in staking this deposit itself is used as the staking amount so we use the setter amount (if you see the implementation, we set this amount as deposit inside contractCallWrapper). But for fungible token transfer, the ft amount is different & deposit amount is different.
That is why we have separate setters (amount and deposit) respectively sets the ft amount & deposit amount

import BigNumber from 'bignumber.js';
import * as NearAPI from 'near-api-js';

import { BuildTransactionError, TransactionType } from '@bitgo/sdk-core';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

external imports should be on top

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it is on top,
External Libraries > Bitgo SDK Packages > Internal project imports

@ravibitgo ravibitgo marked this pull request as ready for review June 10, 2025 11:31
@ravibitgo ravibitgo requested review from a team as code owners June 10, 2025 11:31
Copy link
Contributor

@lokesh-bitgo lokesh-bitgo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved based on CODEOWNERS, coins related changes.

@ravibitgo ravibitgo merged commit 858eecd into master Jun 11, 2025
16 checks passed
@ravibitgo ravibitgo deleted the COIN-4148 branch June 11, 2025 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants