Gathering detailed insights and metrics for @debridge-finance/solana-contracts-client
Gathering detailed insights and metrics for @debridge-finance/solana-contracts-client
npm install @debridge-finance/solana-contracts-client
Typescript
Module System
Node Version
NPM Version
52.8
Supply Chain
75.2
Quality
82.7
Maintenance
50
Vulnerability
76.1
License
Total Downloads
59,502
Last Day
91
Last Week
499
Last Month
2,955
Last Year
39,028
Minified
Minified + Gzipped
Latest Version
4.1.4
Package Id
@debridge-finance/solana-contracts-client@4.1.4
Unpacked Size
1.86 MB
Size
255.56 kB
File Count
191
NPM Version
10.8.2
Node Version
20.17.0
Publised On
02 Dec 2024
Cumulative downloads
Total Downloads
Last day
-49.2%
91
Compared to previous day
Last week
-53.4%
499
Compared to previous week
Last month
7.8%
2,955
Compared to previous month
Last year
103.2%
39,028
Compared to previous year
11
4
34
Since js doesn't support async constructors we have to initialize client object with const client = new DeBridgeSolanaClient()
and then wait until it initializes (await client.init()
) - loads program state, etc...
After initialization we can request data from blockchain and build transactions
We can't send native SOL tokens, we need to wrap them first into SPL-token form (SystemProgram.createAccount
+ SystemProgram.transfer
native sol to created account + TokenProgram.InitializeAccount
to convert system account into token account (SPL-wallet)). If we don't want to create new wallet we can call SystemProgram.transfer
and then TokenProgram.SyncNative
to convert transferred Sols into SPL-Sol
getAllWalletsWithBalances
chainSupportInfo
must exist and be in Supported
state, see getChainSupportInfoSafe
for detailsuseAssetFee
flag to true and check if bridgeFeeInfo exists using isBridgeFeeInfoInitialized
. If bridgeFeeInfo->assetChainFee not exists we can't pay fee with assets and we also can't init bridgeFeeInfo.keccak256(ext call data)
) and flags with 4th bit (8) set to send->submissionParamssend
instruction, else we need to pass speical no_discount account (but buildSendInstruction
calculates all the accounts under the hood). We also need to specify which wallet we want to use (user may have multiple wallets associated with same token mint), execution fee is a reward for automatic claim in target chainchainSupportInfo
must exist and be in Supported
state, see getChainSupportInfoSafe
for detailsgetBridgeByDeBridgeId
(deAssets are claimed via Send bridge, assets are claimed via Mint) and in Working state - if bridge doesn't exist we can't send tokens and we need to init bridge first (see bridge initialization->mint).isSubmissionUsed
storeConfirmations
instruction (one transaction can store up to 6 signatures) which can be built with buildStoreSignaturesTransaction
, this transactions can be signed and sent in a batch mode.checkClaimParams
- check if submission is not already claimed, check bridge balance, check chainSupportInfo and Bridge.claim
instruction built with buildClaimTransaction
after all signatures were saved - this can be checked with isTransactionConfirmed
or getConfirmationsCount
buildOptimalExecuteExternalCallTransaction
. This function tries to build tx with execution of as much as possible external instructions. Need to be called until external call is executed or fails to execute.Since solana's transaction size limit is 1232 bytes we can't store all external call data in single transaction, hence we need to split the data in chunks and send bunch of chunks in different transactions.
We need to call initExternalCallStorage
instruction (storageKey = external call shortcut - claim/extCallShortcut - send, external call length = external call data length, source chain id = source chain - claim/solana id - send) to allocate memory and fill first chunk. If external call data is larger than ~800 bytes, we need to initialize externall call storage and fill it with data calling extendExternalCallStorage
instruction buildExtendExternalCallStorageInstruction
.
Function prepareExtCallTransactions
splits data into chunks of optimal size and returns array of transactions to execute. First tx is initExternalCallStorage
, rest (optional) are extendExternalCallStorage
. initExternalCallStorage
allocates required memory space in blockchain and fills it with initial data chunk. Since we can't write data to not-yet-allocated memory we have to wait until first transaction is finalized and extCallStorage is allocated. After that we can send rest transactions in a batch mode and wait until Solana processes them. We can check if storage was filled correctly using isExtCallStorageCorrect
initializeSendBridge
instruction for SPL-token mint that we want to init - buildInitializeSendBridgeTransaction
.storeConfirmations
for deploy info, wait until confirmations are saved and then call initializeMintBridge
instruction - buildInitializeMintBridgeTransaction
Action | Initialized accounts | Updated Accounts | Closed Accounts | Comments |
---|---|---|---|---|
storeConfirmations | [confirmationStorage] | confirmationStorage | store signatures into confirmationStorage, account is created if not exists yet | |
initExternalCallStorage | externalCallStorage, externalCallMeta | allocate externall call storage, set externalCallMeta = accumulation | ||
updateExternalCallStorage | externalCallStorage, externalCallMeta | fill external call storage with data, set externalCallMeta = accumulation | ||
claim | submission, [stakingWallet], [payerWallet], [claimToWallet] | bridge, stakingWallet, payerWallet, claimToWallet | confirmationStorage | create submission account, close confirmation storage, set externalCallMeta state = execution , update bridge locked/minted amount, move funds to/from wallets |
executeExternalCall | externalCallMeta | externalCallStorage | set externalCallMeta = executed , close external call storage |
Action | Initialized accounts | Updated Accounts | Closed Accounts | Comments |
---|---|---|---|---|
storeConfirmations | [confirmationStorage] | confirmationStorage | store signatures into confirmationStorage, account is created if not exists yet | |
claim | submission, [stakingWallet], [payerWallet], [claimToWallet] | bridge, stakingWallet, payerWallet, claimToWallet | confirmationStorage | create submission account, close confirmation storage, update bridge locked/minted amount, move funds to/from wallets |
No vulnerabilities found.
No security vulnerabilities found.