@avalabs/core-wallets-sdk 3.1.0-alpha.5 → 3.1.0-alpha.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +371 -157
- package/esm/Avalanche/index.d.ts +2 -3
- package/esm/Avalanche/index.js +1 -1
- package/esm/Avalanche/models.d.ts +46 -6
- package/esm/Avalanche/models.js +1 -1
- package/esm/Avalanche/providers/AbstractProvider.d.ts +2 -1
- package/esm/Avalanche/providers/AbstractProvider.js +1 -1
- package/esm/Avalanche/providers/JsonRpcProvider.d.ts +1 -0
- package/esm/Avalanche/providers/JsonRpcProvider.js +1 -1
- package/esm/Avalanche/providers/constants.d.ts +2 -1
- package/esm/Avalanche/providers/constants.js +1 -1
- package/esm/Avalanche/providers/platformFeeConfig.js +1 -0
- package/esm/Avalanche/utils/addSignaturesToAvalancheTx.js +1 -1
- package/esm/Avalanche/utils/appendDisableAuthAddressMaps.js +1 -0
- package/esm/Avalanche/utils/convertGlacierUtxo.d.ts +5 -4
- package/esm/Avalanche/utils/convertGlacierUtxo.js +1 -1
- package/esm/Avalanche/utils/createAvalancheEvmUnsignedTx.d.ts +1 -1
- package/esm/Avalanche/utils/createAvalancheEvmUnsignedTx.js +1 -1
- package/esm/Avalanche/utils/createAvalancheUnsignedTx.d.ts +1 -1
- package/esm/Avalanche/utils/createAvalancheUnsignedTx.js +1 -1
- package/esm/Avalanche/utils/getAssetBalance.d.ts +2 -1
- package/esm/Avalanche/utils/getAssetBalance.js +1 -1
- package/esm/Avalanche/utils/getChainAliasByChainId.js +1 -1
- package/esm/Avalanche/utils/getPchainUnixNow.js +1 -1
- package/esm/Avalanche/utils/getStakedAssetBalance.d.ts +2 -1
- package/esm/Avalanche/utils/getTxOutputAddresses.js +1 -1
- package/esm/Avalanche/utils/getUtxosByTxFromGlacier.d.ts +5 -2
- package/esm/Avalanche/utils/getUtxosByTxFromGlacier.js +1 -1
- package/esm/Avalanche/utils/handleSubnetAuth.js +1 -1
- package/esm/Avalanche/utils/orderBy.js +1 -0
- package/esm/Avalanche/utils/parseAvalancheTx.d.ts +7 -1
- package/esm/Avalanche/utils/parseAvalancheTx.js +1 -1
- package/esm/Avalanche/utils/parsers/index.js +1 -1
- package/esm/Avalanche/utils/parsers/parseAddPermissionlessDelegatorTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseAddPermissionlessValidatorTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseAddSubnetValidorTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseBaseTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseConvertSubnetToL1Tx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseCreateChainTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseCreateSubnetTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseDisableL1ValidatorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseExportTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseImportTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseIncreaseL1ValidatorBalanceTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseRegisterL1ValidatorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseRemoveSubnetValidatorTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseSetL1ValidatorWeightTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseTransferSubnetOwnershipTx.js +1 -1
- package/esm/Avalanche/utils/parsers/utils/chainIdToVm.js +1 -1
- package/esm/Avalanche/utils/populateCredential.js +1 -1
- package/esm/Avalanche/utils/sortUTXOs.d.ts +6 -4
- package/esm/Avalanche/utils/sortUTXOs.js +1 -1
- package/esm/Avalanche/utils/txSizeLimits.d.ts +10 -3
- package/esm/Avalanche/utils/txSizeLimits.js +1 -1
- package/esm/Avalanche/wallets/AddressWallet.js +1 -1
- package/esm/Avalanche/wallets/SimpleSigner.js +1 -1
- package/esm/Avalanche/wallets/StaticSigner.js +1 -1
- package/esm/Avalanche/wallets/TxBuilderTypes.d.ts +179 -0
- package/esm/Avalanche/wallets/WalletAbstract.d.ts +21 -22
- package/esm/Avalanche/wallets/WalletAbstract.js +1 -1
- package/esm/Avalanche/wallets/WalletVoid.js +1 -1
- package/esm/Avalanche/wallets/ledger/LedgerSigner.js +1 -1
- package/esm/Avalanche/wallets/ledger/SimpleLedgerSigner.js +1 -1
- package/esm/Avalanche/wallets/ledger/models.d.ts +1 -1
- package/esm/Avalanche/wallets/legacy/LedgerWallet.js +1 -1
- package/esm/Avalanche/wallets/legacy/MnemonicWallet.js +1 -1
- package/esm/Avalanche/wallets/legacy/MnemonicWalletVoid.js +1 -1
- package/esm/Avalanche/wallets/models.d.ts +1 -1
- package/esm/BitcoinVM/index.d.ts +5 -0
- package/esm/BitcoinVM/index.js +1 -0
- package/esm/BitcoinVM/models.d.ts +1 -1
- package/esm/BitcoinVM/providers/BitcoinProvider.d.ts +4 -3
- package/esm/BitcoinVM/providers/BitcoinProvider.js +1 -1
- package/esm/BitcoinVM/providers/BitcoinProviderAbstract.d.ts +1 -0
- package/esm/BitcoinVM/utils/getBech32AddressFromXPub.js +1 -1
- package/esm/BitcoinVM/wallets/BitcoinWallet.js +1 -1
- package/esm/BitcoinVM/wallets/BitcoinWalletLedger.js +1 -1
- package/esm/BitcoinVM/wallets/models.d.ts +1 -1
- package/esm/EVM/LedgerSigner.js +1 -1
- package/esm/EVM/utils/blockPolling.js +1 -1
- package/esm/EVM/utils/getWalletFromMnemonic.js +1 -1
- package/esm/SolanaVM/utils/compileSolanaTx.d.ts +9 -0
- package/esm/SolanaVM/utils/compileSolanaTx.js +1 -0
- package/esm/SolanaVM/utils/derivationPath.d.ts +3 -0
- package/esm/SolanaVM/utils/derivationPath.js +1 -0
- package/esm/SolanaVM/utils/deserializeSolanaTx.d.ts +6 -0
- package/esm/SolanaVM/utils/deserializeSolanaTx.js +1 -0
- package/esm/SolanaVM/utils/getSolanaPublicKeyFromLedger.d.ts +5 -0
- package/esm/SolanaVM/utils/getSolanaPublicKeyFromLedger.js +1 -0
- package/esm/SolanaVM/utils/serializeSolanaTx.d.ts +6 -0
- package/esm/SolanaVM/utils/serializeSolanaTx.js +1 -0
- package/esm/SolanaVM/utils/solanaProvider.d.ts +11 -0
- package/esm/SolanaVM/utils/solanaProvider.js +1 -0
- package/esm/SolanaVM/utils/transferSol.d.ts +14 -0
- package/esm/SolanaVM/utils/transferSol.js +1 -0
- package/esm/SolanaVM/utils/transferToken.d.ts +17 -0
- package/esm/SolanaVM/utils/transferToken.js +1 -0
- package/esm/SolanaVM/wallets/SolanaLedgerSigner.d.ts +10 -0
- package/esm/SolanaVM/wallets/SolanaLedgerSigner.js +1 -0
- package/esm/SolanaVM/wallets/SolanaSigner.d.ts +20 -0
- package/esm/SolanaVM/wallets/SolanaSigner.js +1 -0
- package/esm/abis/erc20.abi.js +1 -0
- package/esm/index.d.ts +30 -20
- package/esm/index.js +1 -1
- package/esm/utils/assertFeeStateProvided.js +1 -0
- package/esm/utils/getAddressDerivationPath.d.ts +4 -1
- package/esm/utils/getAddressDerivationPath.js +1 -1
- package/package.json +26 -9
- package/dist/index.js +0 -1
- package/esm/Avalanche/utils/getUtxoInfo.d.ts +0 -13
- package/esm/Avalanche/utils/getUtxoInfo.js +0 -1
- package/esm/Avalanche/utils/parsers/parseAddDelegatorTx.js +0 -1
- package/esm/Avalanche/utils/parsers/parseAddValidatorTx.js +0 -1
- package/esm/Avalanche/utils/parsers/parseTransformSubnetTx.js +0 -1
package/esm/Avalanche/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AddDelegatorTx, AddPermissionlessDelegatorTx, AddPermissionlessValidatorTx, AddSubnetValidatorTx, AddValidatorTx, BaseTx, ChainIDAlias, CreateChainTx, CreateSubnetTx, ExportTx, FeeData, ImportTx, RemoveSubnetValidatorTx, TransferSubnetOwnershipTx, TransformSubnetTx, Tx, TxBase, TxType, UnknownTx, isAddDelegatorTx, isAddPermissionlessDelegatorTx, isAddPermissionlessValidatorTx, isAddSubnetValidatorTx, isAddValidatorTx, isBaseTx, isCreateChainTx, isCreateSubnetTx, isExportTx, isImportTx, isRemoveSubnetValidatorTx, isTransferSubnetOwnershipTx, isTransformSubnetTx } from './models.js';
|
|
1
|
+
export { AddDelegatorTx, AddPermissionlessDelegatorTx, AddPermissionlessValidatorTx, AddSubnetValidatorTx, AddValidatorTx, BaseTx, ChainIDAlias, ConvertSubnetToL1Tx, CreateChainTx, CreateSubnetTx, DisableL1ValidatorTx, ExportTx, FeeData, ImportTx, IncreaseL1ValidatorBalanceTx, RegisterL1ValidatorTx, RemoveSubnetValidatorTx, SetL1ValidatorWeightTx, TransferSubnetOwnershipTx, TransformSubnetTx, Tx, TxBase, TxType, UnknownTx, isAddDelegatorTx, isAddPermissionlessDelegatorTx, isAddPermissionlessValidatorTx, isAddSubnetValidatorTx, isAddValidatorTx, isBaseTx, isConvertSubnetToL1Tx, isCreateChainTx, isCreateSubnetTx, isDisableL1ValidatorTx, isExportTx, isImportTx, isIncreaseL1ValidatorBalance, isRegisterL1ValidatorTx, isRemoveSubnetValidatorTx, isSetL1ValidatorWeightTx, isTransferSubnetOwnershipTx, isTransformSubnetTx } from './models.js';
|
|
2
2
|
export { WalletAbstract } from './wallets/WalletAbstract.js';
|
|
3
3
|
export { WalletVoid } from './wallets/WalletVoid.js';
|
|
4
4
|
export { isObsidianApp } from './wallets/ledger/isObsidianApp.js';
|
|
@@ -14,7 +14,7 @@ export { SimpleLedgerSigner } from './wallets/ledger/SimpleLedgerSigner.js';
|
|
|
14
14
|
export { LedgerGetXpubResponse, SignMessageRequest, SignTxBufferRequest, SignTxRequest, Signer } from './wallets/models.js';
|
|
15
15
|
export { AbstractProvider } from './providers/AbstractProvider.js';
|
|
16
16
|
export { JsonRpcProvider } from './providers/JsonRpcProvider.js';
|
|
17
|
-
export { FujiContext, MainnetContext } from './providers/constants.js';
|
|
17
|
+
export { DevnetContext, FujiContext, MainnetContext } from './providers/constants.js';
|
|
18
18
|
export { default as addSignaturesToAvalancheTx } from './utils/addSignaturesToAvalancheTx.js';
|
|
19
19
|
export { GlacierOutput, convertGlacierUtxo } from './utils/convertGlacierUtxo.js';
|
|
20
20
|
export { createAvalancheEvmUnsignedTx } from './utils/createAvalancheEvmUnsignedTx.js';
|
|
@@ -28,7 +28,6 @@ export { getPchainUnixNow } from './utils/getPchainUnixNow.js';
|
|
|
28
28
|
export { GetStakedAvaxBalanceDict, getStakedAssetBalance } from './utils/getStakedAssetBalance.js';
|
|
29
29
|
export { getStakeForAddresses } from './utils/getStakeForAddresses.js';
|
|
30
30
|
export { getUnixNow } from './utils/getUnixNow.js';
|
|
31
|
-
export { UtxoInfo, getUtxoInfo } from './utils/getUtxoInfo.js';
|
|
32
31
|
export { getUtxosByTxFromGlacier } from './utils/getUtxosByTxFromGlacier.js';
|
|
33
32
|
export { getVmByChainAlias } from './utils/getVmByChainAlias.js';
|
|
34
33
|
export { getXpubFromMnemonic } from './utils/getXpubFromMnemonic.js';
|
package/esm/Avalanche/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{TxType,isAddDelegatorTx,isAddPermissionlessDelegatorTx,isAddPermissionlessValidatorTx,isAddSubnetValidatorTx,isAddValidatorTx,isBaseTx,isCreateChainTx,isCreateSubnetTx,isExportTx,isImportTx,isRemoveSubnetValidatorTx,isTransferSubnetOwnershipTx,isTransformSubnetTx}from"./models.js";export{WalletAbstract}from"./wallets/WalletAbstract.js";export{WalletVoid}from"./wallets/WalletVoid.js";export{isObsidianApp}from"./wallets/ledger/isObsidianApp.js";export{getLedgerProvider}from"./wallets/ledger/getLedgerProvider.js";export{AddressWallet}from"./wallets/AddressWallet.js";export{MnemonicWalletVoid}from"./wallets/legacy/MnemonicWalletVoid.js";export{LedgerWallet}from"./wallets/legacy/LedgerWallet.js";export{MnemonicWallet}from"./wallets/legacy/MnemonicWallet.js";export{StaticSigner}from"./wallets/StaticSigner.js";export{SimpleSigner}from"./wallets/SimpleSigner.js";export{LedgerSigner}from"./wallets/ledger/LedgerSigner.js";export{SimpleLedgerSigner}from"./wallets/ledger/SimpleLedgerSigner.js";export{AbstractProvider}from"./providers/AbstractProvider.js";export{JsonRpcProvider}from"./providers/JsonRpcProvider.js";export{FujiContext,MainnetContext}from"./providers/constants.js";export{addSignaturesToAvalancheTx}from"./utils/addSignaturesToAvalancheTx.js";export{convertGlacierUtxo}from"./utils/convertGlacierUtxo.js";export{createAvalancheEvmUnsignedTx}from"./utils/createAvalancheEvmUnsignedTx.js";export{createAvalancheUnsignedTx}from"./utils/createAvalancheUnsignedTx.js";export{digestMessage}from"./utils/digestMessage.js";export{getAddressFromXpub}from"./utils/getAddressFromXpub.js";export{getAddressPublicKeyFromXpub}from"./utils/getAddressPublicKeyFromXpub.js";export{getPaginatedUTXOs,getUTXOsForAddresses}from"./utils/getAllUTXOs.js";export{getAssetBalance}from"./utils/getAssetBalance.js";export{getPchainUnixNow}from"./utils/getPchainUnixNow.js";export{getStakedAssetBalance}from"./utils/getStakedAssetBalance.js";export{getStakeForAddresses}from"./utils/getStakeForAddresses.js";export{getUnixNow}from"./utils/getUnixNow.js";export{
|
|
1
|
+
export{TxType,isAddDelegatorTx,isAddPermissionlessDelegatorTx,isAddPermissionlessValidatorTx,isAddSubnetValidatorTx,isAddValidatorTx,isBaseTx,isConvertSubnetToL1Tx,isCreateChainTx,isCreateSubnetTx,isDisableL1ValidatorTx,isExportTx,isImportTx,isIncreaseL1ValidatorBalance,isRegisterL1ValidatorTx,isRemoveSubnetValidatorTx,isSetL1ValidatorWeightTx,isTransferSubnetOwnershipTx,isTransformSubnetTx}from"./models.js";export{WalletAbstract}from"./wallets/WalletAbstract.js";export{WalletVoid}from"./wallets/WalletVoid.js";export{isObsidianApp}from"./wallets/ledger/isObsidianApp.js";export{getLedgerProvider}from"./wallets/ledger/getLedgerProvider.js";export{AddressWallet}from"./wallets/AddressWallet.js";export{MnemonicWalletVoid}from"./wallets/legacy/MnemonicWalletVoid.js";export{LedgerWallet}from"./wallets/legacy/LedgerWallet.js";export{MnemonicWallet}from"./wallets/legacy/MnemonicWallet.js";export{StaticSigner}from"./wallets/StaticSigner.js";export{SimpleSigner}from"./wallets/SimpleSigner.js";export{LedgerSigner}from"./wallets/ledger/LedgerSigner.js";export{SimpleLedgerSigner}from"./wallets/ledger/SimpleLedgerSigner.js";export{AbstractProvider}from"./providers/AbstractProvider.js";export{JsonRpcProvider}from"./providers/JsonRpcProvider.js";export{DevnetContext,FujiContext,MainnetContext}from"./providers/constants.js";export{addSignaturesToAvalancheTx}from"./utils/addSignaturesToAvalancheTx.js";export{convertGlacierUtxo}from"./utils/convertGlacierUtxo.js";export{createAvalancheEvmUnsignedTx}from"./utils/createAvalancheEvmUnsignedTx.js";export{createAvalancheUnsignedTx}from"./utils/createAvalancheUnsignedTx.js";export{digestMessage}from"./utils/digestMessage.js";export{getAddressFromXpub}from"./utils/getAddressFromXpub.js";export{getAddressPublicKeyFromXpub}from"./utils/getAddressPublicKeyFromXpub.js";export{getPaginatedUTXOs,getUTXOsForAddresses}from"./utils/getAllUTXOs.js";export{getAssetBalance}from"./utils/getAssetBalance.js";export{getPchainUnixNow}from"./utils/getPchainUnixNow.js";export{getStakedAssetBalance}from"./utils/getStakedAssetBalance.js";export{getStakeForAddresses}from"./utils/getStakeForAddresses.js";export{getUnixNow}from"./utils/getUnixNow.js";export{getUtxosByTxFromGlacier}from"./utils/getUtxosByTxFromGlacier.js";export{getVmByChainAlias}from"./utils/getVmByChainAlias.js";export{getXpubFromMnemonic}from"./utils/getXpubFromMnemonic.js";export{isBech32Address}from"./utils/isBech32Address.js";export{parseAvalancheTx}from"./utils/parseAvalancheTx.js";export{emptySignature,populateCredential}from"./utils/populateCredential.js";export{signedTxToHex}from"./utils/signedTxToHex.js";export{sortUTXOsByAmount,sortUTXOsByAmountAscending,sortUTXOsByAmountDescending,sortUTXOsStaking}from"./utils/sortUTXOs.js";export{P_CHAIN_TX_SIZE_LIMIT,SizeSupportedTx,getMaximumUtxoSet}from"./utils/txSizeLimits.js";export{verifyDerivationPath}from"./utils/verifyDerivationPath.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { VM,
|
|
1
|
+
import { VM, OutputOwners, TransferableOutput, Common, pvmSerial } from '@avalabs/avalanchejs';
|
|
2
2
|
|
|
3
3
|
type ChainIDAlias = 'X' | 'P' | 'C';
|
|
4
4
|
/**
|
|
5
5
|
* Types for parsed transaction
|
|
6
6
|
*/
|
|
7
|
-
type Tx = AddValidatorTx | AddDelegatorTx | ExportTx | ImportTx | BaseTx | CreateSubnetTx | CreateChainTx | AddSubnetValidatorTx | RemoveSubnetValidatorTx | AddPermissionlessValidatorTx | AddPermissionlessDelegatorTx | TransformSubnetTx | TransferSubnetOwnershipTx | UnknownTx;
|
|
7
|
+
type Tx = AddValidatorTx | AddDelegatorTx | ExportTx | ImportTx | BaseTx | CreateSubnetTx | CreateChainTx | AddSubnetValidatorTx | RemoveSubnetValidatorTx | AddPermissionlessValidatorTx | AddPermissionlessDelegatorTx | TransformSubnetTx | TransferSubnetOwnershipTx | ConvertSubnetToL1Tx | RegisterL1ValidatorTx | SetL1ValidatorWeightTx | DisableL1ValidatorTx | IncreaseL1ValidatorBalanceTx | UnknownTx;
|
|
8
8
|
interface FeeData {
|
|
9
9
|
totalAvaxBurned: bigint;
|
|
10
10
|
totalAvaxOutput: bigint;
|
|
@@ -24,6 +24,11 @@ declare enum TxType {
|
|
|
24
24
|
Import = "import",
|
|
25
25
|
CreateSubnet = "create_subnet",
|
|
26
26
|
CreateChain = "create_chain",
|
|
27
|
+
ConvertSubnetToL1 = "convert_subnet_to_l1",
|
|
28
|
+
RegisterL1Validator = "register_l1_validator",
|
|
29
|
+
SetL1ValidatorWeight = "set_l1_validator_weight",
|
|
30
|
+
IncreaseL1ValidatorBalance = "increase_l1_validator_balance",
|
|
31
|
+
DisableL1Validator = "disable_l1_validator",
|
|
27
32
|
AddSubnetValidator = "add_subnet_validator",
|
|
28
33
|
RemoveSubnetValidator = "remove_subnet_validator",
|
|
29
34
|
AddPermissionlessValidator = "add_permissionless_validator",
|
|
@@ -102,6 +107,35 @@ interface RemoveSubnetValidatorTx extends TxBase {
|
|
|
102
107
|
nodeID: string;
|
|
103
108
|
subnetID: string;
|
|
104
109
|
}
|
|
110
|
+
interface ConvertSubnetToL1Tx extends TxBase {
|
|
111
|
+
type: TxType.ConvertSubnetToL1;
|
|
112
|
+
managerAddress: string;
|
|
113
|
+
validators: {
|
|
114
|
+
nodeId: string;
|
|
115
|
+
stake: bigint;
|
|
116
|
+
balance: bigint;
|
|
117
|
+
remainingBalanceOwners: string[];
|
|
118
|
+
deactivationOwners: string[];
|
|
119
|
+
}[];
|
|
120
|
+
subnetID: string;
|
|
121
|
+
chainID: string;
|
|
122
|
+
}
|
|
123
|
+
interface RegisterL1ValidatorTx extends TxBase {
|
|
124
|
+
type: TxType.RegisterL1Validator;
|
|
125
|
+
balance: bigint;
|
|
126
|
+
}
|
|
127
|
+
interface SetL1ValidatorWeightTx extends TxBase {
|
|
128
|
+
type: TxType.SetL1ValidatorWeight;
|
|
129
|
+
}
|
|
130
|
+
interface IncreaseL1ValidatorBalanceTx extends TxBase {
|
|
131
|
+
type: TxType.IncreaseL1ValidatorBalance;
|
|
132
|
+
balance: bigint;
|
|
133
|
+
validationId: string;
|
|
134
|
+
}
|
|
135
|
+
interface DisableL1ValidatorTx extends TxBase {
|
|
136
|
+
type: TxType.DisableL1Validator;
|
|
137
|
+
validationId: string;
|
|
138
|
+
}
|
|
105
139
|
interface AddPermissionlessValidatorTx extends TxBase {
|
|
106
140
|
type: TxType.AddPermissionlessValidator;
|
|
107
141
|
nodeID: string;
|
|
@@ -111,7 +145,7 @@ interface AddPermissionlessValidatorTx extends TxBase {
|
|
|
111
145
|
rewardOwner: OutputOwners;
|
|
112
146
|
delegationRewardOwner: OutputOwners;
|
|
113
147
|
stake: bigint;
|
|
114
|
-
stakeOuts: TransferableOutput[];
|
|
148
|
+
stakeOuts: readonly TransferableOutput[];
|
|
115
149
|
subnetID: string;
|
|
116
150
|
publicKey: undefined | string;
|
|
117
151
|
signature: undefined | string;
|
|
@@ -125,7 +159,7 @@ interface AddPermissionlessDelegatorTx extends TxBase {
|
|
|
125
159
|
stake: bigint;
|
|
126
160
|
subnetID: string;
|
|
127
161
|
delegatorRewardsOwner: OutputOwners;
|
|
128
|
-
stakeOuts: TransferableOutput[];
|
|
162
|
+
stakeOuts: readonly TransferableOutput[];
|
|
129
163
|
}
|
|
130
164
|
interface TransformSubnetTx extends TxBase {
|
|
131
165
|
type: TxType.TransformSubnet;
|
|
@@ -140,7 +174,7 @@ interface TransformSubnetTx extends TxBase {
|
|
|
140
174
|
minStakeDuration: number;
|
|
141
175
|
maxStakeDuration: number;
|
|
142
176
|
minDelegationFee: number;
|
|
143
|
-
minDelegatorStake:
|
|
177
|
+
minDelegatorStake: bigint;
|
|
144
178
|
maxValidatorWeightFactor: number;
|
|
145
179
|
uptimeRequirement: number;
|
|
146
180
|
}
|
|
@@ -161,6 +195,11 @@ declare function isAddDelegatorTx(tx: Tx): tx is AddDelegatorTx;
|
|
|
161
195
|
declare function isExportTx(tx: Tx): tx is ExportTx;
|
|
162
196
|
declare function isImportTx(tx: Tx): tx is ImportTx;
|
|
163
197
|
declare function isBaseTx(tx: Tx): tx is BaseTx;
|
|
198
|
+
declare function isConvertSubnetToL1Tx(tx: Tx): tx is ConvertSubnetToL1Tx;
|
|
199
|
+
declare function isRegisterL1ValidatorTx(tx: Tx): tx is RegisterL1ValidatorTx;
|
|
200
|
+
declare function isSetL1ValidatorWeightTx(tx: Tx): tx is SetL1ValidatorWeightTx;
|
|
201
|
+
declare function isDisableL1ValidatorTx(tx: Tx): tx is DisableL1ValidatorTx;
|
|
202
|
+
declare function isIncreaseL1ValidatorBalance(tx: Tx): tx is IncreaseL1ValidatorBalanceTx;
|
|
164
203
|
declare function isCreateSubnetTx(tx: Tx): tx is CreateSubnetTx;
|
|
165
204
|
declare function isCreateChainTx(tx: Tx): tx is CreateChainTx;
|
|
166
205
|
declare function isAddSubnetValidatorTx(tx: Tx): tx is AddSubnetValidatorTx;
|
|
@@ -170,4 +209,5 @@ declare function isAddPermissionlessDelegatorTx(tx: Tx): tx is AddPermissionless
|
|
|
170
209
|
declare function isTransformSubnetTx(tx: Tx): tx is TransformSubnetTx;
|
|
171
210
|
declare function isTransferSubnetOwnershipTx(tx: Tx): tx is TransferSubnetOwnershipTx;
|
|
172
211
|
|
|
173
|
-
export {
|
|
212
|
+
export { TxType, isAddDelegatorTx, isAddPermissionlessDelegatorTx, isAddPermissionlessValidatorTx, isAddSubnetValidatorTx, isAddValidatorTx, isBaseTx, isConvertSubnetToL1Tx, isCreateChainTx, isCreateSubnetTx, isDisableL1ValidatorTx, isExportTx, isImportTx, isIncreaseL1ValidatorBalance, isRegisterL1ValidatorTx, isRemoveSubnetValidatorTx, isSetL1ValidatorWeightTx, isTransferSubnetOwnershipTx, isTransformSubnetTx };
|
|
213
|
+
export type { AddDelegatorTx, AddPermissionlessDelegatorTx, AddPermissionlessValidatorTx, AddSubnetValidatorTx, AddValidatorTx, BaseTx, ChainIDAlias, ConvertSubnetToL1Tx, CreateChainTx, CreateSubnetTx, DisableL1ValidatorTx, ExportTx, FeeData, ImportTx, IncreaseL1ValidatorBalanceTx, RegisterL1ValidatorTx, RemoveSubnetValidatorTx, SetL1ValidatorWeightTx, TransferSubnetOwnershipTx, TransformSubnetTx, Tx, TxBase, UnknownTx };
|
package/esm/Avalanche/models.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=(e=>(e.Base="base",e.AddValidator="add_validator",e.AddDelegator="add_delegator",e.Export="export",e.Import="import",e.CreateSubnet="create_subnet",e.CreateChain="create_chain",e.AddSubnetValidator="add_subnet_validator",e.RemoveSubnetValidator="remove_subnet_validator",e.AddPermissionlessValidator="add_permissionless_validator",e.AddPermissionlessDelegator="add_permissionless_delegator",e.TransformSubnet="transform_subnet",e.TransferSubnetOwnership="transfer_subnet_ownership",e.Unknown="unknown",e))(e||{});function t(e){return"add_validator"===e.type}function r(e){return"add_delegator"===e.type}function n(e){return"export"===e.type}function a(e){return"import"===e.type}function o(e){return"base"===e.type}function d(e){return"
|
|
1
|
+
var e=(e=>(e.Base="base",e.AddValidator="add_validator",e.AddDelegator="add_delegator",e.Export="export",e.Import="import",e.CreateSubnet="create_subnet",e.CreateChain="create_chain",e.ConvertSubnetToL1="convert_subnet_to_l1",e.RegisterL1Validator="register_l1_validator",e.SetL1ValidatorWeight="set_l1_validator_weight",e.IncreaseL1ValidatorBalance="increase_l1_validator_balance",e.DisableL1Validator="disable_l1_validator",e.AddSubnetValidator="add_subnet_validator",e.RemoveSubnetValidator="remove_subnet_validator",e.AddPermissionlessValidator="add_permissionless_validator",e.AddPermissionlessDelegator="add_permissionless_delegator",e.TransformSubnet="transform_subnet",e.TransferSubnetOwnership="transfer_subnet_ownership",e.Unknown="unknown",e))(e||{});function t(e){return"add_validator"===e.type}function r(e){return"add_delegator"===e.type}function n(e){return"export"===e.type}function a(e){return"import"===e.type}function o(e){return"base"===e.type}function i(e){return"convert_subnet_to_l1"===e.type}function d(e){return"register_l1_validator"===e.type}function s(e){return"set_l1_validator_weight"===e.type}function _(e){return"disable_l1_validator"===e.type}function u(e){return"increase_l1_validator_balance"===e.type}function l(e){return"create_subnet"===e.type}function c(e){return"create_chain"===e.type}function p(e){return"add_subnet_validator"===e.type}function b(e){return"remove_subnet_validator"===e.type}function f(e){return"add_permissionless_validator"===e.type}function v(e){return"add_permissionless_delegator"===e.type}function y(e){return"transform_subnet"===e.type}function m(e){return"transfer_subnet_ownership"===e.type}export{e as TxType,r as isAddDelegatorTx,v as isAddPermissionlessDelegatorTx,f as isAddPermissionlessValidatorTx,p as isAddSubnetValidatorTx,t as isAddValidatorTx,o as isBaseTx,i as isConvertSubnetToL1Tx,c as isCreateChainTx,l as isCreateSubnetTx,_ as isDisableL1ValidatorTx,n as isExportTx,a as isImportTx,u as isIncreaseL1ValidatorBalance,d as isRegisterL1ValidatorTx,b as isRemoveSubnetValidatorTx,s as isSetL1ValidatorWeightTx,m as isTransferSubnetOwnershipTx,y as isTransformSubnetTx};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _avalabs_avalanchejs_dist_vms_common from '@avalabs/avalanchejs/dist/vms/common';
|
|
2
2
|
import * as ethers from 'ethers';
|
|
3
3
|
import { JsonRpcProvider } from 'ethers';
|
|
4
|
-
import { Context, avm, pvm, evm, VM, avaxSerial } from '@avalabs/avalanchejs';
|
|
4
|
+
import { Context, avm, pvm, evm, info, VM, avaxSerial } from '@avalabs/avalanchejs';
|
|
5
5
|
import { ChainIDAlias } from '../models.js';
|
|
6
6
|
|
|
7
7
|
declare class AbstractProvider {
|
|
@@ -20,6 +20,7 @@ declare class AbstractProvider {
|
|
|
20
20
|
getApiX(): avm.AVMApi;
|
|
21
21
|
getApiP(): pvm.PVMApi;
|
|
22
22
|
getApiC(): evm.EVMApi;
|
|
23
|
+
getInfo(): info.InfoApi;
|
|
23
24
|
getApi(chain: ChainIDAlias): avm.AVMApi | pvm.PVMApi | evm.EVMApi;
|
|
24
25
|
getAvaxID(): string;
|
|
25
26
|
getAddress(publicKey: Buffer, chain: ChainIDAlias): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{utils as t,secp256k1 as e,networkIDs as s,avm as r,pvm as i,evm as n,info as c}from"@avalabs/avalanchejs";import{strip0x as a}from"@avalabs/core-utils-sdk";import{signedTxToHex as o}from"../utils/signedTxToHex.js";import{JsonRpcProvider as u,SigningKey as h}from"ethers";const{parseBech32:p,format:g}=t,{publicKeyBytesToAddress:A}=e;class x{constructor(t,e){this.baseUrl=t,this.context=e;const s=`${t}/ext/bc/C/rpc`;this.evmRpc=new u(s)}evmRpc;async getEvmFeeData(){return this.evmRpc.getFeeData()}getContext(){return this.context}getChainID(t){switch(t){case"X":return this.context.xBlockchainID;case"P":return this.context.pBlockchainID;case"C":return this.context.cBlockchainID}}getNetworkID(){return this.context.networkID}getHrp(){return s.getHRP(this.getNetworkID())}getApiX(){return new r.AVMApi(this.baseUrl)}getApiP(){return new i.PVMApi(this.baseUrl)}getApiC(){return new n.EVMApi(this.baseUrl)}getInfo(){return new c.InfoApi(this.baseUrl)}getApi(t){switch(t){case"X":return this.getApiX();case"P":return this.getApiP();case"C":return this.getApiC()}}getAvaxID(){return this.getContext().avaxAssetID}getAddress(t,e){const s=a(h.computePublicKey(t,!0)),r=Buffer.from(s,"hex"),i=A(r);return g(e,this.getHrp(),i)}getAddressFromBuffer(t,e){return g(e,this.getHrp(),t)}formatAddress(t,e){const[,s]=p(t);return g(e,this.getHrp(),s)}getApiByVM(t){switch(t){case"AVM":return this.getApiX();case"PVM":return this.getApiP();case"EVM":return this.getApiC()}}getApiByChainID(t){switch(t){case this.context.xBlockchainID:return this.getApiX();case this.context.pBlockchainID:return this.getApiP();case this.context.cBlockchainID:return this.getApiC()}}async issueTx(t){const e=t.unsignedTx.getVM(),s=o(t);return this.issueTxHex(s,e)}async issueTxHex(t,e){return this.getApiByVM(e).issueTx({tx:t})}async waitForTransaction(t,e,s=6e4){const r=this.getApiByVM(e),i=Date.now();return new Promise(((e,c)=>{const a=async()=>{let o;switch(s&&i+s<Date.now()&&c(new Error("Timeout")),o=r instanceof n.EVMApi?await r.getAtomicTxStatus(t):await r.getTxStatus({txID:t,includeReason:!0}),o.status){case"Accepted":case"Committed":return void e({success:!0});case"Dropped":case"Rejected":return void e({success:!1});default:setTimeout((()=>{a()}),1e3)}};a()}))}}export{x as AbstractProvider};
|
|
@@ -6,6 +6,7 @@ declare class JsonRpcProvider extends AbstractProvider {
|
|
|
6
6
|
static fromBaseURL(url: string): Promise<JsonRpcProvider>;
|
|
7
7
|
static getDefaultMainnetProvider(): JsonRpcProvider;
|
|
8
8
|
static getDefaultFujiProvider(): JsonRpcProvider;
|
|
9
|
+
static getDefaultDevnetProvider(): JsonRpcProvider;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export { JsonRpcProvider };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AbstractProvider as r}from"./AbstractProvider.js";import{Context as t}from"@avalabs/avalanchejs";import{MainnetContext as a,FujiContext as
|
|
1
|
+
import{AbstractProvider as r}from"./AbstractProvider.js";import{Context as t,info as e}from"@avalabs/avalanchejs";import{MainnetContext as a,FujiContext as n,DevnetContext as o}from"./constants.js";import{AVALANCHE_XP_NETWORK as s,AVALANCHE_XP_TEST_NETWORK as c,AVALANCHE_P_DEV_NETWORK as i}from"@avalabs/core-chains-sdk";class p extends r{constructor(r,t){super(r,t)}static async fromBaseURL(r){const a=await t.getContextFromURI(r);try{await new e.InfoApi(r).getUpgradesInfo();return new p(r,a)}catch{return new p(r,a)}}static getDefaultMainnetProvider(){return new p(s.rpcUrl,a)}static getDefaultFujiProvider(){return new p(c.rpcUrl,n)}static getDefaultDevnetProvider(){return new p(i.rpcUrl,o)}}export{p as JsonRpcProvider};
|
|
@@ -8,5 +8,6 @@ declare const MainnetContext: Context.Context;
|
|
|
8
8
|
* Avalanche Fuji testnet context
|
|
9
9
|
*/
|
|
10
10
|
declare const FujiContext: Context.Context;
|
|
11
|
+
declare const DevnetContext: Context.Context;
|
|
11
12
|
|
|
12
|
-
export { FujiContext, MainnetContext };
|
|
13
|
+
export { DevnetContext, FujiContext, MainnetContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
import{platformFeeConfig as e}from"./platformFeeConfig.js";const o={xBlockchainID:"2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM",pBlockchainID:"11111111111111111111111111111111LpoYY",cBlockchainID:"2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5",avaxAssetID:"FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z",baseTxFee:BigInt(1e6),createAssetTxFee:BigInt(1e7),networkID:1,hrp:"avax",platformFeeConfig:e},c={xBlockchainID:"2JVSBoinj9C2J33VntvzYtVJNZdN2NKiwwKjcumHUWEb5DbBrm",pBlockchainID:"11111111111111111111111111111111LpoYY",cBlockchainID:"yH8D7ThNJkxmtkuv2jgBa4P1Rn3Qpr4pPr7QYNfcdoS6k6HWp",avaxAssetID:"U8iRqJoiJm8xZHAacmvYyZVwqQx6uDNtQeP3CQ6fcgQk3JqnK",baseTxFee:BigInt(1e6),createAssetTxFee:BigInt(1e7),networkID:5,hrp:"fuji",platformFeeConfig:e},n={xBlockchainID:"2piQ2AVHCjnduiWXsSY15DtbVuwHE2cwMHYnEXHsLL73BBkdbV",pBlockchainID:"11111111111111111111111111111111LpoYY",cBlockchainID:"vV3cui1DsEPC3nLCGH9rorwo8s6BYxM2Hz4QFE5gEYjwTqAu",avaxAssetID:"22jjRVdyTJiAEtcZciAVR8bTFyVDUVoo1T3o5PiDspQSZ2maXR",baseTxFee:1000000n,createAssetTxFee:1000000n,networkID:76,hrp:"custom",platformFeeConfig:e};export{n as DevnetContext,c as FujiContext,o as MainnetContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Common as e}from"@avalabs/avalanchejs";const t={weights:e.createDimensions({bandwidth:1,dbRead:1e3,dbWrite:1e3,compute:4}),maxCapacity:BigInt(1e6),maxPerSecond:BigInt(1e5),targetPerSecond:BigInt(5e4),minPrice:BigInt(1),excessConversionConstant:BigInt(2164043)};export{t as platformFeeConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getVmByChainAlias as e}from"./getVmByChainAlias.js";import{
|
|
1
|
+
import{getVmByChainAlias as e}from"./getVmByChainAlias.js";import{utils as t,Credential as r,UnsignedTx as n,avaxSerial as a,EVM as s}from"@avalabs/avalanchejs";import i from"./createAvalancheUnsignedTx.js";import{populateCredential as o}from"./populateCredential.js";import{signedTxToHex as c}from"./signedTxToHex.js";const{getManagerForVM:d,hexToBuffer:x,unpackWithManager:g}=t,p=async({transactionHex:t,chainAlias:n,provider:c,utxos:p})=>{const u=e(n);if(u===s)throw new Error("EVM transactions are not supported");const l=x(t),m=g(u,l),h=await(async({tx:e,txBytes:t,provider:n,vm:s,utxos:c})=>{try{const x=d(s).unpack(t,a.SignedTx),g=await i({tx:e,utxos:c,provider:n,credentials:x.getCredentials()});return e.getSigIndices().map(((e,t)=>new r(o(e,{unsignedTx:g,credentialIndex:t}))))}catch(t){return e.getSigIndices().map((e=>new r(o(e))))}})({tx:m,txBytes:l,provider:c,vm:u,utxos:p});return i({tx:m,provider:c,credentials:h,utxos:p})},u=async({transactionHex:e,signatures:t,chainAlias:s,provider:i,utxos:o})=>{if(!t.length)throw new Error("signatures were not provided");const d=await p({transactionHex:e,chainAlias:s,provider:i,utxos:o});await Promise.all(t.map((e=>d.addSignature(e))));const x=d.getCredentials(),g=d.getSigIndices().reduce(((e,t,n)=>{const a=t.map((e=>{const t=x[n]?.toJSON()[e];if(!t)throw new Error(`Failed to sign [${n}, ${e}]`);return t}));return e.push(new r(a)),e}),[]),u=new n(d.getTx(),d.getInputUtxos(),d.addressMaps,g),l=new a.SignedTx(d.getTx(),g);return{signedTxHex:c(l),hasAllSignatures:u.hasAllSignatures()}};export{u as addSignaturesToAvalancheTx};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{utils as a}from"@avalabs/avalanchejs";async function e(e,r,t){try{const{deactivationOwner:s}=await t.getApiP().getL1Validator(r.validationId.toString()),i=r.getDisableAuth().values(),n=s.addresses.reduce(((a,e,r)=>(i.includes(r)&&a.push([e,r]),a)),[]);return e.push(new a.AddressMap(n)),e}catch(a){throw new Error(`Error while preparing disableAuth data: ${a.message}`)}}export{e as appendDisableAuthAddressMaps};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Utxo as Utxo$1 } from '@avalabs/avalanchejs';
|
|
2
|
-
import { Utxo, PChainUtxo } from '@avalabs/glacier-sdk';
|
|
1
|
+
import { Utxo as Utxo$1, TransferOutput, pvmSerial } from '@avalabs/avalanchejs';
|
|
2
|
+
import { Utxo, PChainUtxo, Network } from '@avalabs/glacier-sdk';
|
|
3
3
|
|
|
4
4
|
type GlacierOutput = Utxo | PChainUtxo;
|
|
5
|
-
declare const convertGlacierUtxo: (glacierUtxo: GlacierOutput,
|
|
5
|
+
declare const convertGlacierUtxo: (glacierUtxo: GlacierOutput, network: Network) => Utxo$1<TransferOutput | pvmSerial.StakeableLockOut<TransferOutput>>;
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export { convertGlacierUtxo };
|
|
8
|
+
export type { GlacierOutput };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{utils as t,Utxo as e,avaxSerial as a,Id as o,pvmSerial as s,BigIntPr as n,TransferOutput as r,OutputOwners as m}from"@avalabs/avalanchejs";import{getChainAliasByChainId as i}from"./getChainAliasByChainId.js";const{bytesCompare:c,parseBech32:l}=t,d=(t,e)=>"P"===e,h=(t,e,a)=>{const o=d(0,e)?t.amount:t.asset?.amount;return new r(new n(BigInt(o)),m.fromNative(t.addresses.map((t=>l(t)[1])).sort(c),BigInt(a??0),t.threshold))},k=(t,r)=>{const m=i(t.createdOnChainId,r),c=d(0,m)?t.txHash:t.creationTxHash,l=d(0,m)?t.assetId:t.asset?.assetId;return new e(a.UTXOID.fromNative(c,Number(t.outputIndex)),o.fromString(l),((t,e)=>d(0,e)?t.stakeableLocktime?new s.StakeableLockOut(new n(BigInt(t.stakeableLocktime??0)),h(t,e,t.platformLocktime??0)):h(t,e,t.platformLocktime):h(t,e,t.locktime))(t,m))};export{k as convertGlacierUtxo};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{utils as r,evmSerial as e,EVMUnsignedTx as t,UnsignedTx as s}from"@avalabs/avalanchejs";const{unpackWithManager:n,parse:o,bufferToHex:a,AddressMaps:p,AddressMap:f}=r,i=async({txBytes:r,fromAddress:i,vm:m,utxos:d})=>{const u=n(m,r),c=o(i)[2],x=a(c);if(e.isExportTx(u))return new t(u,[],new p([f.fromJSON([[x,0]])]));if(e.isImportTx(u)){const r=p.fromTransferableInputs(u.importedInputs,d,BigInt(Math.floor((new Date).getTime()/1e3)),[c]);return new s(u,d,r)}throw new Error("Unsupported transaction type")};export{i as createAvalancheEvmUnsignedTx};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsignedTx as r,
|
|
1
|
+
import{utils as e,UnsignedTx as r,pvmSerial as a}from"@avalabs/avalanchejs";import{isSubnetTx as t,handleSubnetAuth as s}from"./handleSubnetAuth.js";import{appendDisableAuthAddressMaps as n}from"./appendDisableAuthAddressMaps.js";const{getTransferableInputsByTx:o,AddressMaps:i}=e,d=async({tx:e,fromAddressBytes:d,provider:p,credentials:l,utxos:u})=>{const f=o(e);let m=i.fromTransferableInputs(f,u,BigInt(Math.floor((new Date).getTime()/1e3)),d);if(t(e))try{const a=await s({tx:e,provider:p,addressMaps:m});return new r(e,u,a,l)}catch(e){throw new Error(`Error while preparing subnet authorization data: ${e.message}`)}else a.isDisableL1ValidatorTx(e)&&(m=await n(m,e,p));return new r(e,u,m,l)};var p=d;export{d as createAvalancheUnsignedTx,p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{utils as t}from"@avalabs/avalanchejs";import{getUnixNow as e}from"./getUnixNow.js";const{getUtxoInfo:a}=t;function o(t,o){const l=t.getAssetDict()[o],i={locked:BigInt(0),available:BigInt(0),multisig:BigInt(0),lockedStakeable:BigInt(0),total:BigInt(0)};if(!l)return i;const n=l.getUTXOs(),c=e();return n.forEach((t=>{const e=a(t);i[e.threshold>1?"multisig":e.locktime>c?"locked":e.stakeableLocktime>c?"lockedStakeable":"available"]+=e.amount})),i.total=i.locked+i.lockedStakeable+i.multisig+i.available,i}export{o as getAssetBalance};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"@avalabs/
|
|
1
|
+
import{Network as r}from"@avalabs/glacier-sdk";import"../providers/AbstractProvider.js";import"@avalabs/avalanchejs";import{FujiContext as o,MainnetContext as a}from"../providers/constants.js";import"@avalabs/core-chains-sdk";const i=(i,n)=>{const c=n===r.FUJI,{cBlockchainID:s,xBlockchainID:t,pBlockchainID:e}=c?o:a;if(s===i)return"C";if(t===i)return"X";if(e===i)return"P";throw new Error(`Unknown chainId "${i}"`)};export{i as getChainAliasByChainId};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{AVALANCHE_XP_TEST_NETWORK as a,AVALANCHE_XP_NETWORK as t}from"@avalabs/core-chains-sdk";import{pvm as e}from"@avalabs/avalanchejs";async function r(r){const i=r?a.rpcUrl:t.rpcUrl,n=await new e.PVMApi(i).getTimestamp(),o=new Date(n.timestamp),m=Math.floor(o.getTime()/1e3);return BigInt(m)}export{r as getPchainUnixNow};
|
|
@@ -13,4 +13,5 @@ interface GetStakedAvaxBalanceDict {
|
|
|
13
13
|
}
|
|
14
14
|
declare function getStakedAssetBalance(stakeResponse: pvm.GetStakeResponse): GetStakedAvaxBalanceDict;
|
|
15
15
|
|
|
16
|
-
export {
|
|
16
|
+
export { getStakedAssetBalance };
|
|
17
|
+
export type { GetStakedAvaxBalanceDict };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{utils as t,avmSerial as e,pvmSerial as a,evmSerial as o}from"@avalabs/avalanchejs";const{isTransferOut:s,isStakeableLockOut:n}=t;function r(t){const e=t.output;return s(e)||n(e)?e.getOwners():[]}function u(t){const s=t.getTx();return e.isExportTx(s)||a.isExportTx(s)?new Set(s.outs.map(r).flat()):o.isExportTx(s)?new Set(s.exportedOutputs.map(r).flat()):new Set((s.baseTx?.outputs??[]).map(r).flat())}export{r as getOutputAddresses,u as getTxOutputAddresses};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import * as _avalabs_avalanchejs_dist_serializable_common_types from '@avalabs/avalanchejs/dist/serializable/common/types';
|
|
2
|
+
import { Network } from '@avalabs/glacier-sdk';
|
|
1
3
|
import { Utxo } from '@avalabs/avalanchejs';
|
|
2
4
|
import { ChainIDAlias } from '../models.js';
|
|
3
5
|
|
|
4
6
|
type Params = {
|
|
5
7
|
transactionHex: string;
|
|
6
8
|
chainAlias: ChainIDAlias;
|
|
7
|
-
|
|
9
|
+
network: Network;
|
|
8
10
|
url: string;
|
|
9
11
|
token?: string;
|
|
12
|
+
headers?: Record<string, string>;
|
|
10
13
|
};
|
|
11
|
-
declare const getUtxosByTxFromGlacier: ({ transactionHex, chainAlias,
|
|
14
|
+
declare const getUtxosByTxFromGlacier: ({ transactionHex, chainAlias, network, url, token, headers, }: Params) => Promise<Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[]>;
|
|
12
15
|
|
|
13
16
|
export { getUtxosByTxFromGlacier };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Glacier as t,
|
|
1
|
+
import{Glacier as t,BlockchainId as r}from"@avalabs/glacier-sdk";import{utils as o,evmSerial as e,avmSerial as n,pvmSerial as a,PVM as i,AVM as s,EVM as x}from"@avalabs/avalanchejs";import{getVmByChainAlias as c}from"./getVmByChainAlias.js";import{convertGlacierUtxo as u}from"./convertGlacierUtxo.js";const{getTransferableInputsByTx:I,hexToBuffer:p,unpackWithManager:f}=o,h=async({transactionHex:o,chainAlias:h,network:l,url:m,token:d,headers:w})=>{const D=c(h),g=p(o),T=f(D,g);if(e.isExportTx(T))return[];const E=(t=>{if(e.isImportTx(t)||n.isImportTx(t)||a.isImportTx(t))return t.sourceChain.toString();const o=t.getVM();switch(o){case x:return r.C_CHAIN;case s:return r.X_CHAIN;case i:return r.P_CHAIN;default:throw new Error(`Unable to get chain for VM type "${o}"`)}})(T),H=I(T),b=new t({BASE:m,TOKEN:d,HEADERS:w}),k=[...new Set(H.map((t=>t.utxoID.txID.toString())))],A=await Promise.all(k.map((t=>b.primaryNetworkTransactions.getTxByHash({blockchainId:E,network:l,txHash:t}))));return H.reduce(((t,r)=>{const o=A.find((t=>t.txHash===r.utxoID.txID.toString()));if(!o)throw new Error(`Unable to find parent tx "${r.utxoID.txID.toString()}"`);const e=o.emittedUtxos.find((t=>t.utxoId===r.utxoID.ID()));if(!e)throw new Error(`Unable to find UTXO "${r.utxoID.ID()}" at index "${r.utxoID.outputIdx.value()}"`);const n=u(e,l);return t.push(n),t}),[])};export{h as getUtxosByTxFromGlacier};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as e,utils as s}from"@avalabs/avalanchejs";const t
|
|
1
|
+
import{pvmSerial as e,OutputOwners as t,utils as s}from"@avalabs/avalanchejs";const a=t=>e.isCreateChainTx(t)||e.isAddSubnetValidatorTx(t)||e.isRemoveSubnetValidatorTx(t)||e.isTransformSubnetTx(t)||e.isTransferSubnetOwnershipTx(t)||e.isConvertSubnetToL1Tx(t),r=async({tx:e,provider:a,addressMaps:r})=>{const n=e.getSubnetAuth().values(),i=await a.getApiP().getSubnet({subnetID:e.getSubnetID().value()}),u=t.fromNative(i.controlKeys.map((e=>s.parse(e)[2])),BigInt(i.locktime),Number(i.threshold)).addrs.reduce(((e,t,s)=>(n.includes(s)&&e.push([t,s]),e)),[]);return r.push(new s.AddressMap(u)),r};export{r as handleSubnetAuth,a as isSubnetTx};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(r,t,n){return[...r].sort(((r,e)=>{for(let o=0;o<t.length;o++){const u=t[o];if(r[u]>e[u])return"asc"===n?1:-1;if(r[u]<e[u])return"asc"===n?-1:1}return 0}))}export{r as orderBy};
|
|
@@ -2,9 +2,15 @@ import { Common } from '@avalabs/avalanchejs';
|
|
|
2
2
|
import { Tx } from '../models.js';
|
|
3
3
|
import { JsonRpcProvider } from '../providers/JsonRpcProvider.js';
|
|
4
4
|
|
|
5
|
+
type ParseOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Tolerance percentage range where the burned amount is considered valid.
|
|
8
|
+
*/
|
|
9
|
+
feeTolerance?: number;
|
|
10
|
+
};
|
|
5
11
|
/**
|
|
6
12
|
* Returns human readable data from a given a transaction buffer,
|
|
7
13
|
*/
|
|
8
|
-
declare function parseAvalancheTx(unsignedTx: Common.UnsignedTx, provider: JsonRpcProvider, currentAddress: string): Promise<Tx>;
|
|
14
|
+
declare function parseAvalancheTx(unsignedTx: Common.UnsignedTx, provider: JsonRpcProvider, currentAddress: string, { feeTolerance }?: ParseOptions): Promise<Tx>;
|
|
9
15
|
|
|
10
16
|
export { parseAvalancheTx };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{utils as t,evmSerial as e}from"@avalabs/avalanchejs";import{TxType as n}from"../models.js";import a from"./parsers/index.js";const{getBurnedAmountByTx:r,getOutputAmounts:o,getInputAmounts:s,validateBurnedAmount:i}=t;async function u(t,u,x,{feeTolerance:g=50}={}){try{const n=u.getContext(),c=t.getTx(),p=(t=>{for(const e of Object.values(a)){const n=e(t);if(null!==n)return n}throw new Error("no parser found for tx")})(c),A=r(c,n),d=o(c),l=s(c).get(n.avaxAssetID)??BigInt(0),m=A.get(n.avaxAssetID)??BigInt(0),v=d.get(n.avaxAssetID)??BigInt(0);let I=BigInt(0);e.isImportExportTx(c)?(I=await u.getApiC().getBaseFee()/BigInt(1e9),0n===I&&(I=1n)):"PVM"===c.vm&&(I=await u.getApiP().getFeeState().then((t=>t.price)).catch((()=>BigInt(0))));const{isValid:f,txFee:B}=i({unsignedTx:t,context:n,burnedAmount:m,baseFee:I,feeTolerance:g});return await p({feeData:{totalAvaxBurned:m,totalAvaxOutput:v,totalAvaxInput:l,isValidAvaxBurnedAmount:f,txFee:B},assetId:n.avaxAssetID,provider:u,currentAddress:x})}catch(t){return{type:n.Unknown}}}export{u as parseAvalancheTx};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"./
|
|
1
|
+
import r from"./parseCreateSubnetTx.js";import e from"./parseCreateChainTx.js";import a from"./parseAddSubnetValidorTx.js";import s from"./parseImportTx.js";import o from"./parseExportTx.js";import t from"./parseBaseTx.js";import p from"./parseAddPermissionlessValidatorTx.js";import i from"./parseAddPermissionlessDelegatorTx.js";import m from"./parseRemoveSubnetValidatorTx.js";import x from"./parseTransferSubnetOwnershipTx.js";import T from"./parseConvertSubnetToL1Tx.js";import d from"./parseRegisterL1ValidatorTx.js";import n from"./parseSetL1ValidatorWeightTx.js";import l from"./parseDisableL1ValidatorTx.js";import f from"./parseIncreaseL1ValidatorBalanceTx.js";var j={parseCreateSubnetTx:r,parseCreateChainTx:e,parseAddSubnetValidatorTx:a,parseRemoveSubnetValidatorTx:m,parseImportTx:s,parseExportTx:o,parseBaseTx:t,parseAddPermissionlessValidatorTx:p,parseAddPermissionlessDelegatorTx:i,parseTransferSubnetOwnershipTx:x,parseConvertSubnetTx:T,parseRegisterL1ValidatorTx:d,parseIncreaseL1ValidatorBalanceTx:f,parseSetL1ValidatorWeightTx:n,parseDisableL1ValidatorTx:l};export{j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as a}from"../../models.js";
|
|
1
|
+
import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as a}from"../../models.js";var t=t=>e.isAddPermissionlessDelegatorTx(t)?({feeData:e})=>({type:a.AddPermissionlessDelegator,chain:t.getVM(),stake:t.subnetValidator.validator.weight.value(),nodeID:t.subnetValidator.validator.nodeId.value(),start:t.subnetValidator.validator.startTime.value().toString(),end:t.subnetValidator.validator.endTime.value().toString(),subnetID:t.subnetValidator.subnetId.value(),stakeOuts:t.stake,delegatorRewardsOwner:t.getDelegatorRewardsOwner(),...e}):null;export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as e,utils as a}from"@avalabs/avalanchejs";import{TxType as
|
|
1
|
+
import{pvmSerial as e,utils as a}from"@avalabs/avalanchejs";import{TxType as r}from"../../models.js";var t=t=>{if(!e.isAddPermissionlessValidatorTx(t))return null;let i,s;return e.isSigner(t.signer)&&(s=a.bufferToHex(t.signer.proof.publicKey),i=a.bufferToHex(t.signer.proof.signature)),({feeData:e})=>({type:r.AddPermissionlessValidator,chain:t.getVM(),stake:t.subnetValidator.validator.weight.value(),nodeID:t.subnetValidator.validator.nodeId.value(),start:t.subnetValidator.validator.startTime.value().toString(),end:t.subnetValidator.validator.endTime.value().toString(),subnetID:t.subnetValidator.subnetId.value(),delegationFee:t.shares.value(),stakeOuts:t.stake,rewardOwner:t.getValidatorRewardsOwner(),delegationRewardOwner:t.getDelegatorRewardsOwner(),signer:t.signer,publicKey:s,signature:i,...e})};export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as t}from"../../models.js";
|
|
1
|
+
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as t}from"../../models.js";var e=e=>a.isAddSubnetValidatorTx(e)?({feeData:a})=>({type:t.AddSubnetValidator,chain:e.getVM(),stake:e.subnetValidator.validator.weight.value(),nodeID:e.subnetValidator.validator.nodeId.value(),start:e.subnetValidator.validator.startTime.value().toString(),end:e.subnetValidator.validator.endTime.value().toString(),subnetID:e.getSubnetID().value(),...a}):null;export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{avmSerial as t,pvmSerial as e,TransferOutput as s}from"@avalabs/avalanchejs";import o from"xss";import{TxType as
|
|
1
|
+
import{avmSerial as t,pvmSerial as e,TransferOutput as s}from"@avalabs/avalanchejs";import o from"xss";import{TxType as a}from"../../models.js";import{getUnixNow as r}from"../getUnixNow.js";var u=u=>t.isAvmBaseTx(u)||e.isPvmBaseTx(u)?async({feeData:e,currentAddress:n,provider:i})=>{const p=u.baseTx,m=await(async(e,o)=>{const a=e.baseTx,r=new Set;if(a.outputs.forEach((t=>{r.add(t.assetId.value())})),t.isAvmBaseTx(e)){const t=await Promise.all([...r.values()].map((t=>o.getApiX().getAssetDescription(t))));return a.outputs.reduce(((e,a)=>{if(a.output instanceof s){const s=a.assetId.value(),u=[...r.values()].indexOf(s),n=t[u],i=a.output.outputOwners.addrs.map((t=>`X-${t.toString(o.getContext().hrp)}`));return[...e,{assetId:s,amount:a.output.amount(),locktime:a.output.getLocktime(),threshold:BigInt(a.output.getThreshold()),assetDescription:n,owners:i,isAvax:o.getContext().avaxAssetID===s}]}return e}),[])}return a.outputs.reduce(((t,e)=>{if(e.output instanceof s){const s=e.assetId.value(),a=e.output.outputOwners.addrs.map((t=>`P-${t.toString(o.getContext().hrp)}`));return[...t,{assetId:s,amount:e.output.amount(),locktime:e.output.getLocktime(),threshold:BigInt(e.output.getThreshold()),owners:a,isAvax:o.getContext().avaxAssetID===s}]}return t}),[])})(u,i),d=r(),c=m.filter((t=>!(1===t.owners.length&&t.owners[0]===n&&t.locktime<=d)));return{type:a.Base,chain:u.getVM(),outputs:c,memo:o(Buffer.from(p.memo.toBytes()).toString("utf-8",4)),...e}}:null;export{u as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pvmSerial as e,NodeId as a,Address as n}from"@avalabs/avalanchejs";import{TxType as r}from"../../models.js";var t=t=>e.isConvertSubnetToL1Tx(t)?({feeData:e,provider:o})=>{const s=o.getHrp(),i=e=>`P-${e.toString(s)}`;return{type:r.ConvertSubnetToL1,chain:t.getVM(),managerAddress:i(n.fromHex(t.address.toString("hex"))),validators:t.validators.map((e=>({nodeId:a.fromHex(e.nodeId.toString("hex")).toString(),stake:e.weight.value(),balance:e.balance.value(),remainingBalanceOwners:e.remainingBalanceOwner.addresses.map(i),deactivationOwners:e.deactivationOwner.addresses.map(i)}))),chainID:t.chainID.value(),subnetID:t.subnetID.value(),...e}}:null;export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";
|
|
1
|
+
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";var t=t=>a.isCreateChainTx(t)?({feeData:a})=>({type:e.CreateChain,chain:t.getVM(),subnetID:t.getSubnetID().value(),chainName:t.chainName.value(),chainID:t.getBlockchainId(),vmID:t.vmID.value(),fxIDs:t.fxIds.map((a=>a.value())),genesisData:t.genesisData.toString(),...a}):null;export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as t}from"../../models.js";
|
|
1
|
+
import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as t}from"../../models.js";var r=r=>e.isCreateSubnetTx(r)?({feeData:e,provider:a})=>({type:t.CreateSubnet,chain:r.getVM(),threshold:r.getSubnetOwners().threshold.value(),controlKeys:r.getSubnetOwners().addrs.map((e=>`P-${e.toString(a.getHrp())}`)),...e}):null;export{r as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as i}from"../../models.js";var t=t=>a.isDisableL1ValidatorTx(t)?({feeData:a})=>({type:i.DisableL1Validator,chain:t.getVM(),validationId:t.validationId.toString(),...a}):null;export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as t,avmSerial as
|
|
1
|
+
import{pvmSerial as t,avmSerial as a,evmSerial as o}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";import s from"./utils/chainIdToVm.js";import{getTransferableOutputAmount as i}from"./utils/getTransferableAmount.js";var r=r=>t.isExportTx(r)||a.isExportTx(r)||o.isExportTx(r)?o.isExportTx(r)?({feeData:t,assetId:a})=>({type:e.Export,chain:r.getVM(),destination:s(r.destinationChain.toString()),amount:i(r.exportedOutputs,a),...t}):({feeData:t,assetId:a})=>({type:e.Export,chain:r.getVM(),destination:s(r.destination.value()),amount:i(r.outs,a),...t}):null;export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as t,avmSerial as
|
|
1
|
+
import{pvmSerial as t,avmSerial as a,evmSerial as o}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";import s from"./utils/chainIdToVm.js";import{getTransferableInputAmount as r}from"./utils/getTransferableAmount.js";var m=m=>t.isImportTx(m)||a.isImportTx(m)||o.isImportTx(m)?o.isImportTx(m)?({feeData:t,assetId:a})=>({type:e.Import,chain:m.getVM(),source:s(m.sourceChain.value()),amount:r(m.importedInputs,a),...t}):({feeData:t,assetId:a})=>({type:e.Import,chain:m.getVM(),source:s(m.sourceChain.value()),amount:r(m.ins,a),...t}):null;export{m as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";var l=l=>a.isIncreaseL1ValidatorBalanceTx(l)?({feeData:a})=>({type:e.IncreaseL1ValidatorBalance,chain:l.getVM(),balance:l.balance.value(),validationId:l.validationId.toString(),...a}):null;export{l as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";var l=l=>a.isRegisterL1ValidatorTx(l)?({feeData:a})=>({type:e.RegisterL1Validator,chain:l.getVM(),balance:l.balance.value(),...a}):null;export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as
|
|
1
|
+
import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as a}from"../../models.js";var t=t=>e.isRemoveSubnetValidatorTx(t)?({feeData:e})=>({type:a.RemoveSubnetValidator,chain:t.getVM(),nodeID:t.nodeId.toString(),subnetID:t.getSubnetID().value(),...e}):null;export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as t}from"../../models.js";var e=e=>a.isSetL1ValidatorWeightTx(e)?({feeData:a})=>({type:t.SetL1ValidatorWeight,chain:e.getVM(),...a}):null;export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as
|
|
1
|
+
import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as r}from"../../models.js";var t=t=>e.isTransferSubnetOwnershipTx(t)?({feeData:e,provider:a})=>({type:r.TransferSubnetOwnership,chain:t.getVM(),subnetID:t.subnetID.value(),threshold:t.getSubnetOwners().threshold.value(),controlKeys:t.getSubnetOwners().addrs.map((e=>`P-${e.toString(a.getHrp())}`)),...e}):null;export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"
|
|
1
|
+
import"../../../providers/AbstractProvider.js";import"@avalabs/avalanchejs";import{MainnetContext as c,FujiContext as a,DevnetContext as i}from"../../../providers/constants.js";import"@avalabs/core-chains-sdk";var r=r=>{if([c.xBlockchainID,a.xBlockchainID,i.xBlockchainID].includes(r))return"AVM";if([c.pBlockchainID,a.pBlockchainID,i.pBlockchainID].includes(r))return"PVM";if([c.cBlockchainID,a.cBlockchainID,i.cBlockchainID].includes(r))return"EVM";throw new Error("Unknown chain id. Failed to get alias.")};export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{utils as e,secp256k1 as r,Signature as t}from"@avalabs/avalanchejs";import{sha256 as o}from"@noble/hashes/sha256";const{bufferToHex:n,packTx:s}=e,{publicKeyBytesToAddress:i,recoverPublicKey:a}=r,c=new t(new Uint8Array(Array(65).fill(0))),d=(e,r)=>{const t=Math.max(...e);if(!isFinite(t))throw new Error("Error while adding placeholder signatures for the provided indices.");const d=new Array(t+1).fill(c);if(!r)return d;const{unsignedTx:f,credentialIndex:l}=r,g=f.getCredentials()[l];if(!g)return d;const h=s(f.getTx()),u=o(h),p=c.toString();for(const e of g.toJSON()){if(e.toString()===p)continue;const r=a(u,e.toBytes()),t={toHex:()=>n(i(r))},o=f.addressMaps.getSigIndicesForAddress(t,!1)??[];for(const r of o)r[0]===l&&(d[r[1]]=e)}return d};export{c as emptySignature,d as populateCredential};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
import * as _avalabs_avalanchejs_dist_serializable_common_types from '@avalabs/avalanchejs/dist/serializable/common/types';
|
|
1
2
|
import { Utxo } from '@avalabs/avalanchejs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* The UTXOs will be sorted in the following order.
|
|
5
|
-
* 1-
|
|
6
|
-
* 2-
|
|
6
|
+
* 1- Highest value unlocked UTXO (for fees)
|
|
7
|
+
* 2- LockedStakeable UTXOs with the highest locktime to lowest
|
|
8
|
+
* 3- Rest of the unlocked UTXOs highest to lowest
|
|
7
9
|
* @remark Does not check for locked UTXOs
|
|
8
10
|
*/
|
|
9
11
|
declare function sortUTXOsStaking(utxos: Utxo[]): Utxo[];
|
|
10
12
|
declare function sortUTXOsByAmount(utxos: Utxo[], isDescending: boolean): Utxo[];
|
|
11
|
-
declare const sortUTXOsByAmountDescending: (utxos: Utxo[]) => Utxo[];
|
|
12
|
-
declare const sortUTXOsByAmountAscending: (utxos: Utxo[]) => Utxo[];
|
|
13
|
+
declare const sortUTXOsByAmountDescending: (utxos: Utxo[]) => Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[];
|
|
14
|
+
declare const sortUTXOsByAmountAscending: (utxos: Utxo[]) => Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[];
|
|
13
15
|
|
|
14
16
|
export { sortUTXOsByAmount, sortUTXOsByAmountAscending, sortUTXOsByAmountDescending, sortUTXOsStaking };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{utils as t}from"@avalabs/avalanchejs";
|
|
1
|
+
import{utils as t}from"@avalabs/avalanchejs";import{getUnixNow as o}from"./getUnixNow.js";import{orderBy as e}from"./orderBy.js";function a(a){const m=o(),n=a.map((o=>({utxo:o,...t.getUtxoInfo(o)}))),r=n.filter((t=>t.stakeableLocktime<=m)),s=n.filter((t=>t.stakeableLocktime>m)),c=e(r,["amount"],"desc"),i=e(s,["stakeableLocktime","amount"],"desc"),[u,...f]=c;return[...u?[u]:[],...i,...f].map((t=>t.utxo))}function m(o,a){const m=o.map((o=>({utxo:o,...t.getUtxoInfo(o)})));return e(m,["amount"],a?"desc":"asc").map((t=>t.utxo))}const n=t=>m(t,!0),r=t=>m(t,!1);export{m as sortUTXOsByAmount,r as sortUTXOsByAmountAscending,n as sortUTXOsByAmountDescending,a as sortUTXOsStaking};
|