-
Notifications
You must be signed in to change notification settings - Fork 295
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
Conversation
58a8aa3
to
6270567
Compare
modules/sdk-coin-near/test/unit/transactionBuilder/fungibleTokenTransferBuilder.ts
Outdated
Show resolved
Hide resolved
modules/sdk-coin-near/test/unit/transactionBuilder/fungibleTokenTransferBuilder.ts
Outdated
Show resolved
Hide resolved
modules/sdk-coin-near/test/unit/transactionBuilder/fungibleTokenTransferBuilder.ts
Show resolved
Hide resolved
55221ac
to
7c37206
Compare
const factory = new TransactionBuilderFactory(coins.get(coinNameTest)); | ||
const factoryProd = new TransactionBuilderFactory(coins.get(coinName)); | ||
const gas = '125000000000000'; | ||
const deposit = '1'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is deposit for?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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.
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 version0.x.x
to5.x.x
.New Feature:
FungibleTokenTransferBuilder
to handle fungible token transaction creation.Dependency Upgrade:
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 t
his._nearTransaction.publicKey.toString()
, we now derive a human-readable public key usingthis._nearSignedTransaction.signature.ed25519Signature.data
viaUint8Array
.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