@avalabs/core-wallets-sdk 3.1.0-canary.a0ef572.0 → 3.1.0-canary.a1461ba.0
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 -1
- package/dist/index.d.ts +90 -11
- package/esm/Avalanche/index.d.ts +1 -1
- package/esm/Avalanche/index.js +1 -1
- package/esm/Avalanche/models.d.ts +35 -3
- package/esm/Avalanche/models.js +1 -1
- package/esm/Avalanche/providers/JsonRpcProvider.d.ts +3 -3
- package/esm/Avalanche/providers/JsonRpcProvider.js +1 -1
- package/esm/Avalanche/utils/appendAutoRenewedValidatorConfigAddressMaps.js +1 -0
- package/esm/Avalanche/utils/createAvalancheUnsignedTx.js +1 -1
- package/esm/Avalanche/utils/parseAvalancheTx.js +1 -1
- package/esm/Avalanche/utils/parsers/index.js +1 -1
- package/esm/Avalanche/utils/parsers/parseAddAutoRenewedValidatorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseRewardAutoRenewedValidatorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseSetAutoRenewedValidatorConfigTx.js +1 -0
- package/esm/Avalanche/wallets/SimpleSigner.js +1 -1
- package/esm/Avalanche/wallets/TxBuilderTypes.d.ts +29 -1
- package/esm/Avalanche/wallets/WalletAbstract.d.ts +3 -1
- package/esm/Avalanche/wallets/WalletAbstract.js +1 -1
- package/esm/Avalanche/wallets/legacy/MnemonicWallet.js +1 -1
- package/esm/BitcoinVM/index.js +1 -1
- package/esm/SolanaVM/utils/maybeGetAssociatedTokenAccount.d.ts +6 -3
- package/esm/SolanaVM/utils/maybeGetAssociatedTokenAccount.js +1 -1
- package/esm/SolanaVM/utils/resolveTokenProgramForMint.d.ts +13 -0
- package/esm/SolanaVM/utils/resolveTokenProgramForMint.js +1 -0
- package/esm/SolanaVM/utils/transferToken.js +1 -1
- package/esm/SolanaVM/wallets/SolanaLedgerSigner.js +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -1
- package/esm/utils/getAddressDerivationPath.js +1 -1
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { BIP32Interface } from 'bip32';
|
|
|
12
12
|
import { Utxo as Utxo$1, PChainUtxo, Network as Network$2 } from '@avalabs/glacier-sdk';
|
|
13
13
|
import * as _avalabs_avalanchejs_dist_serializable_common_types from '@avalabs/avalanchejs/dist/serializable/common/types';
|
|
14
14
|
import * as _solana_kit from '@solana/kit';
|
|
15
|
-
import { CompilableTransactionMessage, Transaction as Transaction$2, IInstruction } from '@solana/kit';
|
|
15
|
+
import { CompilableTransactionMessage, Transaction as Transaction$2, IInstruction, Address } from '@solana/kit';
|
|
16
16
|
import { Transaction } from '@ledgerhq/hw-app-btc/lib/types';
|
|
17
17
|
import { WalletPolicy, PsbtV2 } from 'ledger-bitcoin';
|
|
18
18
|
|
|
@@ -567,7 +567,7 @@ type ChainIDAlias = 'X' | 'P' | 'C';
|
|
|
567
567
|
/**
|
|
568
568
|
* Types for parsed transaction
|
|
569
569
|
*/
|
|
570
|
-
type Tx = AddValidatorTx | AddDelegatorTx | ExportTx | ImportTx | BaseTx$1 | CreateSubnetTx | CreateChainTx | AddSubnetValidatorTx | RemoveSubnetValidatorTx | AddPermissionlessValidatorTx | AddPermissionlessDelegatorTx | TransformSubnetTx | TransferSubnetOwnershipTx$1 | ConvertSubnetToL1Tx | RegisterL1ValidatorTx | SetL1ValidatorWeightTx | DisableL1ValidatorTx | IncreaseL1ValidatorBalanceTx | UnknownTx;
|
|
570
|
+
type Tx = AddValidatorTx | AddDelegatorTx | ExportTx | ImportTx | BaseTx$1 | CreateSubnetTx | CreateChainTx | AddSubnetValidatorTx | RemoveSubnetValidatorTx | AddPermissionlessValidatorTx | AddPermissionlessDelegatorTx | TransformSubnetTx | TransferSubnetOwnershipTx$1 | ConvertSubnetToL1Tx | RegisterL1ValidatorTx | SetL1ValidatorWeightTx | DisableL1ValidatorTx | IncreaseL1ValidatorBalanceTx | AddAutoRenewedValidatorTx | SetAutoRenewedValidatorConfigTx | RewardAutoRenewedValidatorTx | UnknownTx;
|
|
571
571
|
interface FeeData {
|
|
572
572
|
totalAvaxBurned: bigint;
|
|
573
573
|
totalAvaxOutput: bigint;
|
|
@@ -593,6 +593,9 @@ declare enum TxType {
|
|
|
593
593
|
SetL1ValidatorWeight = "set_l1_validator_weight",
|
|
594
594
|
IncreaseL1ValidatorBalance = "increase_l1_validator_balance",
|
|
595
595
|
DisableL1Validator = "disable_l1_validator",
|
|
596
|
+
AddAutoRenewedValidator = "add_auto_renewed_validator",
|
|
597
|
+
SetAutoRenewedValidatorConfig = "set_auto_renewed_validator_config",
|
|
598
|
+
RewardAutoRenewedValidator = "reward_auto_renewed_validator",
|
|
596
599
|
AddSubnetValidator = "add_subnet_validator",
|
|
597
600
|
RemoveSubnetValidator = "remove_subnet_validator",
|
|
598
601
|
AddPermissionlessValidator = "add_permissionless_validator",
|
|
@@ -700,6 +703,32 @@ interface DisableL1ValidatorTx extends TxBase {
|
|
|
700
703
|
type: TxType.DisableL1Validator;
|
|
701
704
|
validationId: string;
|
|
702
705
|
}
|
|
706
|
+
interface AddAutoRenewedValidatorTx extends TxBase {
|
|
707
|
+
type: TxType.AddAutoRenewedValidator;
|
|
708
|
+
nodeID: string;
|
|
709
|
+
stake: bigint;
|
|
710
|
+
stakeOuts: readonly TransferableOutput[];
|
|
711
|
+
rewardOwner: OutputOwners;
|
|
712
|
+
delegationRewardOwner: OutputOwners;
|
|
713
|
+
owner: OutputOwners;
|
|
714
|
+
delegationFee: number;
|
|
715
|
+
weight: bigint;
|
|
716
|
+
autoCompoundRewardShares: number;
|
|
717
|
+
period: bigint;
|
|
718
|
+
signer: pvmSerial.Signer | pvmSerial.SignerEmpty;
|
|
719
|
+
publicKey: undefined | string;
|
|
720
|
+
signature: undefined | string;
|
|
721
|
+
}
|
|
722
|
+
interface SetAutoRenewedValidatorConfigTx extends TxBase {
|
|
723
|
+
type: TxType.SetAutoRenewedValidatorConfig;
|
|
724
|
+
txId: string;
|
|
725
|
+
autoCompoundRewardShares: number;
|
|
726
|
+
period: bigint;
|
|
727
|
+
}
|
|
728
|
+
interface RewardAutoRenewedValidatorTx extends TxBase {
|
|
729
|
+
type: TxType.RewardAutoRenewedValidator;
|
|
730
|
+
txId: string;
|
|
731
|
+
}
|
|
703
732
|
interface AddPermissionlessValidatorTx extends TxBase {
|
|
704
733
|
type: TxType.AddPermissionlessValidator;
|
|
705
734
|
nodeID: string;
|
|
@@ -772,6 +801,9 @@ declare function isAddPermissionlessValidatorTx(tx: Tx): tx is AddPermissionless
|
|
|
772
801
|
declare function isAddPermissionlessDelegatorTx(tx: Tx): tx is AddPermissionlessDelegatorTx;
|
|
773
802
|
declare function isTransformSubnetTx(tx: Tx): tx is TransformSubnetTx;
|
|
774
803
|
declare function isTransferSubnetOwnershipTx(tx: Tx): tx is TransferSubnetOwnershipTx$1;
|
|
804
|
+
declare function isAddAutoRenewedValidatorTx(tx: Tx): tx is AddAutoRenewedValidatorTx;
|
|
805
|
+
declare function isSetAutoRenewedValidatorConfigTx(tx: Tx): tx is SetAutoRenewedValidatorConfigTx;
|
|
806
|
+
declare function isRewardAutoRenewedValidatorTx(tx: Tx): tx is RewardAutoRenewedValidatorTx;
|
|
775
807
|
|
|
776
808
|
declare class AbstractProvider {
|
|
777
809
|
protected baseUrl: string;
|
|
@@ -808,9 +840,9 @@ declare class AbstractProvider {
|
|
|
808
840
|
declare class JsonRpcProvider extends AbstractProvider {
|
|
809
841
|
constructor(baseUrl: string, context: Context.Context, fetchOptions?: RequestInit);
|
|
810
842
|
static fromBaseURL(url: string): Promise<JsonRpcProvider>;
|
|
811
|
-
static getDefaultMainnetProvider(): JsonRpcProvider;
|
|
812
|
-
static getDefaultFujiProvider(): JsonRpcProvider;
|
|
813
|
-
static getDefaultDevnetProvider(): JsonRpcProvider;
|
|
843
|
+
static getDefaultMainnetProvider(fetchOptions?: RequestInit): JsonRpcProvider;
|
|
844
|
+
static getDefaultFujiProvider(fetchOptions?: RequestInit): JsonRpcProvider;
|
|
845
|
+
static getDefaultDevnetProvider(fetchOptions?: RequestInit): JsonRpcProvider;
|
|
814
846
|
}
|
|
815
847
|
|
|
816
848
|
/**
|
|
@@ -987,6 +1019,34 @@ type RemoveSubnetValidator = {
|
|
|
987
1019
|
fromAddresses?: string[];
|
|
988
1020
|
options?: Common.SpendOptions;
|
|
989
1021
|
};
|
|
1022
|
+
type AddAutoRenewedValidator = {
|
|
1023
|
+
utxoSet: utils.UtxoSet;
|
|
1024
|
+
nodeId: string;
|
|
1025
|
+
weight: bigint;
|
|
1026
|
+
shares: number;
|
|
1027
|
+
feeState: pvm.FeeState;
|
|
1028
|
+
fromAddresses?: string[];
|
|
1029
|
+
rewardAddresses?: string[];
|
|
1030
|
+
delegatorRewardAddresses?: string[];
|
|
1031
|
+
ownerAddresses?: string[];
|
|
1032
|
+
publicKey?: Buffer;
|
|
1033
|
+
signature?: Buffer;
|
|
1034
|
+
autoCompoundRewardShares: number;
|
|
1035
|
+
period: bigint;
|
|
1036
|
+
options?: Common.SpendOptions;
|
|
1037
|
+
locktime?: bigint;
|
|
1038
|
+
threshold?: number;
|
|
1039
|
+
};
|
|
1040
|
+
type SetAutoRenewedValidatorConfig = {
|
|
1041
|
+
utxoSet: utils.UtxoSet;
|
|
1042
|
+
feeState: pvm.FeeState;
|
|
1043
|
+
validatorTxId: string;
|
|
1044
|
+
auth: number[];
|
|
1045
|
+
autoCompoundRewardShares: number;
|
|
1046
|
+
period: bigint;
|
|
1047
|
+
fromAddresses?: string[];
|
|
1048
|
+
options?: Common.SpendOptions;
|
|
1049
|
+
};
|
|
990
1050
|
type TransferSubnetOwnershipTx = {
|
|
991
1051
|
utxoSet: utils.UtxoSet;
|
|
992
1052
|
subnetId: string;
|
|
@@ -1080,6 +1140,8 @@ declare abstract class WalletAbstract {
|
|
|
1080
1140
|
setL1ValidatorWeight({ utxoSet, feeState, message, options, fromAddresses, }: SetL1ValidatorWeight): Common.UnsignedTx;
|
|
1081
1141
|
disableL1Validator({ utxoSet, feeState, options, fromAddresses, disableAuth, validationId, }: DisableL1Validator): Common.UnsignedTx;
|
|
1082
1142
|
increaseL1ValidatorBalance({ utxoSet, feeState, options, fromAddresses, balance, validationId, }: IncreaseL1ValidatorBalance): Common.UnsignedTx;
|
|
1143
|
+
addAutoRenewedValidator({ utxoSet, nodeId, weight, shares, feeState, fromAddresses, rewardAddresses, delegatorRewardAddresses, ownerAddresses, publicKey, signature, autoCompoundRewardShares, period, options, locktime, threshold, }: AddAutoRenewedValidator): Common.UnsignedTx;
|
|
1144
|
+
setAutoRenewedValidatorConfig({ utxoSet, feeState, validatorTxId, auth, autoCompoundRewardShares, period, fromAddresses, options, }: SetAutoRenewedValidatorConfig): Common.UnsignedTx;
|
|
1083
1145
|
createBlockchain({ utxoSet, subnetId, chainName, vmID, fxIds, genesisData, subnetAuth, feeState, options, fromAddresses, }: CreateChain): Common.UnsignedTx;
|
|
1084
1146
|
createSubnet({ utxoSet, rewardAddresses, feeState, fromAddresses, options, threshold, locktime, }: CreateSubnet): Common.UnsignedTx;
|
|
1085
1147
|
addSubnetValidator({ utxoSet, nodeId, start, end, weight, subnetId, subnetAuth, feeState, fromAddresses, options, }: AddSubnetValidator): Common.UnsignedTx;
|
|
@@ -1788,6 +1850,7 @@ declare const getAvalancheDerivationPath: (accountIndex: number, withRoot?: bool
|
|
|
1788
1850
|
|
|
1789
1851
|
type index_AbstractProvider = AbstractProvider;
|
|
1790
1852
|
declare const index_AbstractProvider: typeof AbstractProvider;
|
|
1853
|
+
type index_AddAutoRenewedValidatorTx = AddAutoRenewedValidatorTx;
|
|
1791
1854
|
type index_AddDelegatorTx = AddDelegatorTx;
|
|
1792
1855
|
type index_AddPermissionlessDelegatorTx = AddPermissionlessDelegatorTx;
|
|
1793
1856
|
type index_AddPermissionlessValidatorTx = AddPermissionlessValidatorTx;
|
|
@@ -1827,6 +1890,8 @@ declare const index_P_CHAIN_TX_SIZE_LIMIT: typeof P_CHAIN_TX_SIZE_LIMIT;
|
|
|
1827
1890
|
type index_ParseOptions = ParseOptions;
|
|
1828
1891
|
type index_RegisterL1ValidatorTx = RegisterL1ValidatorTx;
|
|
1829
1892
|
type index_RemoveSubnetValidatorTx = RemoveSubnetValidatorTx;
|
|
1893
|
+
type index_RewardAutoRenewedValidatorTx = RewardAutoRenewedValidatorTx;
|
|
1894
|
+
type index_SetAutoRenewedValidatorConfigTx = SetAutoRenewedValidatorConfigTx;
|
|
1830
1895
|
type index_SetL1ValidatorWeightTx = SetL1ValidatorWeightTx;
|
|
1831
1896
|
type index_SignMessageRequest = SignMessageRequest;
|
|
1832
1897
|
type index_SignTxBufferRequest = SignTxBufferRequest;
|
|
@@ -1871,6 +1936,7 @@ declare const index_getUnixNow: typeof getUnixNow;
|
|
|
1871
1936
|
declare const index_getUtxosByTxFromGlacier: typeof getUtxosByTxFromGlacier;
|
|
1872
1937
|
declare const index_getVmByChainAlias: typeof getVmByChainAlias;
|
|
1873
1938
|
declare const index_getXpubFromMnemonic: typeof getXpubFromMnemonic;
|
|
1939
|
+
declare const index_isAddAutoRenewedValidatorTx: typeof isAddAutoRenewedValidatorTx;
|
|
1874
1940
|
declare const index_isAddDelegatorTx: typeof isAddDelegatorTx;
|
|
1875
1941
|
declare const index_isAddPermissionlessDelegatorTx: typeof isAddPermissionlessDelegatorTx;
|
|
1876
1942
|
declare const index_isAddPermissionlessValidatorTx: typeof isAddPermissionlessValidatorTx;
|
|
@@ -1888,6 +1954,8 @@ declare const index_isIncreaseL1ValidatorBalance: typeof isIncreaseL1ValidatorBa
|
|
|
1888
1954
|
declare const index_isObsidianApp: typeof isObsidianApp;
|
|
1889
1955
|
declare const index_isRegisterL1ValidatorTx: typeof isRegisterL1ValidatorTx;
|
|
1890
1956
|
declare const index_isRemoveSubnetValidatorTx: typeof isRemoveSubnetValidatorTx;
|
|
1957
|
+
declare const index_isRewardAutoRenewedValidatorTx: typeof isRewardAutoRenewedValidatorTx;
|
|
1958
|
+
declare const index_isSetAutoRenewedValidatorConfigTx: typeof isSetAutoRenewedValidatorConfigTx;
|
|
1891
1959
|
declare const index_isSetL1ValidatorWeightTx: typeof isSetL1ValidatorWeightTx;
|
|
1892
1960
|
declare const index_isTransferSubnetOwnershipTx: typeof isTransferSubnetOwnershipTx;
|
|
1893
1961
|
declare const index_isTransformSubnetTx: typeof isTransformSubnetTx;
|
|
@@ -1900,8 +1968,8 @@ declare const index_sortUTXOsByAmountDescending: typeof sortUTXOsByAmountDescend
|
|
|
1900
1968
|
declare const index_sortUTXOsStaking: typeof sortUTXOsStaking;
|
|
1901
1969
|
declare const index_verifyDerivationPath: typeof verifyDerivationPath;
|
|
1902
1970
|
declare namespace index {
|
|
1903
|
-
export { index_AbstractProvider as AbstractProvider, index_AddressWallet as AddressWallet, index_DevnetContext as DevnetContext, index_FujiContext as FujiContext, index_JsonRpcProvider as JsonRpcProvider, index_LedgerLiveSigner as LedgerLiveSigner, index_LedgerSigner as LedgerSigner, index_LedgerWallet as LedgerWallet, index_MainnetContext as MainnetContext, index_MnemonicWallet as MnemonicWallet, index_MnemonicWalletVoid as MnemonicWalletVoid, index_P_CHAIN_TX_SIZE_LIMIT as P_CHAIN_TX_SIZE_LIMIT, index_SimpleLedgerSigner as SimpleLedgerSigner, index_SimpleSigner as SimpleSigner, index_SizeSupportedTx as SizeSupportedTx, index_StaticSigner as StaticSigner, index_TxType as TxType, index_WalletAbstract as WalletAbstract, index_WalletVoid as WalletVoid, index_addSignaturesToAvalancheTx as addSignaturesToAvalancheTx, index_convertGlacierUtxo as convertGlacierUtxo, index_createAvalancheEvmUnsignedTx as createAvalancheEvmUnsignedTx, index_createAvalancheUnsignedTx as createAvalancheUnsignedTx, index_digestMessage as digestMessage, index_emptySignature as emptySignature, index_getAddressFromXpub as getAddressFromXpub, index_getAddressPublicKeyFromXpub as getAddressPublicKeyFromXpub, index_getAssetBalance as getAssetBalance, index_getAvalancheDerivationPath as getAvalancheDerivationPath, index_getLedgerProvider as getLedgerProvider, index_getMaximumUtxoSet as getMaximumUtxoSet, index_getPaginatedUTXOs as getPaginatedUTXOs, index_getPchainUnixNow as getPchainUnixNow, index_getStakeForAddresses as getStakeForAddresses, index_getStakedAssetBalance as getStakedAssetBalance, index_getUTXOsForAddresses as getUTXOsForAddresses, index_getUnixNow as getUnixNow, index_getUtxosByTxFromGlacier as getUtxosByTxFromGlacier, index_getVmByChainAlias as getVmByChainAlias, index_getXpubFromMnemonic as getXpubFromMnemonic, index_isAddDelegatorTx as isAddDelegatorTx, index_isAddPermissionlessDelegatorTx as isAddPermissionlessDelegatorTx, index_isAddPermissionlessValidatorTx as isAddPermissionlessValidatorTx, index_isAddSubnetValidatorTx as isAddSubnetValidatorTx, index_isAddValidatorTx as isAddValidatorTx, index_isBaseTx as isBaseTx, index_isBech32Address as isBech32Address, index_isConvertSubnetToL1Tx as isConvertSubnetToL1Tx, index_isCreateChainTx as isCreateChainTx, index_isCreateSubnetTx as isCreateSubnetTx, index_isDisableL1ValidatorTx as isDisableL1ValidatorTx, index_isExportTx as isExportTx, index_isImportTx as isImportTx, index_isIncreaseL1ValidatorBalance as isIncreaseL1ValidatorBalance, index_isObsidianApp as isObsidianApp, index_isRegisterL1ValidatorTx as isRegisterL1ValidatorTx, index_isRemoveSubnetValidatorTx as isRemoveSubnetValidatorTx, index_isSetL1ValidatorWeightTx as isSetL1ValidatorWeightTx, index_isTransferSubnetOwnershipTx as isTransferSubnetOwnershipTx, index_isTransformSubnetTx as isTransformSubnetTx, index_parseAvalancheTx as parseAvalancheTx, index_populateCredential as populateCredential, index_signedTxToHex as signedTxToHex, index_sortUTXOsByAmount as sortUTXOsByAmount, index_sortUTXOsByAmountAscending as sortUTXOsByAmountAscending, index_sortUTXOsByAmountDescending as sortUTXOsByAmountDescending, index_sortUTXOsStaking as sortUTXOsStaking, index_verifyDerivationPath as verifyDerivationPath };
|
|
1904
|
-
export type { index_AddDelegatorTx as AddDelegatorTx, index_AddPermissionlessDelegatorTx as AddPermissionlessDelegatorTx, index_AddPermissionlessValidatorTx as AddPermissionlessValidatorTx, index_AddSubnetValidatorTx as AddSubnetValidatorTx, index_AddValidatorTx as AddValidatorTx, BaseTx$1 as BaseTx, index_ChainIDAlias as ChainIDAlias, index_ConvertSubnetToL1Tx as ConvertSubnetToL1Tx, index_CreateChainTx as CreateChainTx, index_CreateSubnetTx as CreateSubnetTx, index_DisableL1ValidatorTx as DisableL1ValidatorTx, index_ExportTx as ExportTx, index_FeeData as FeeData, index_GetAvaxBalanceDict as GetAvaxBalanceDict, index_GetStakedAvaxBalanceDict as GetStakedAvaxBalanceDict, index_GlacierOutput as GlacierOutput, index_ImportTx as ImportTx, index_IncreaseL1ValidatorBalanceTx as IncreaseL1ValidatorBalanceTx, index_LedgerGetXpubResponse as LedgerGetXpubResponse, index_ParseOptions as ParseOptions, index_RegisterL1ValidatorTx as RegisterL1ValidatorTx, index_RemoveSubnetValidatorTx as RemoveSubnetValidatorTx, index_SetL1ValidatorWeightTx as SetL1ValidatorWeightTx, index_SignMessageRequest as SignMessageRequest, index_SignTxBufferRequest as SignTxBufferRequest, index_SignTxRequest as SignTxRequest, index_Signer as Signer, TransferSubnetOwnershipTx$1 as TransferSubnetOwnershipTx, index_TransformSubnetTx as TransformSubnetTx, index_Tx as Tx, index_TxBase as TxBase, index_UnknownTx as UnknownTx };
|
|
1971
|
+
export { index_AbstractProvider as AbstractProvider, index_AddressWallet as AddressWallet, index_DevnetContext as DevnetContext, index_FujiContext as FujiContext, index_JsonRpcProvider as JsonRpcProvider, index_LedgerLiveSigner as LedgerLiveSigner, index_LedgerSigner as LedgerSigner, index_LedgerWallet as LedgerWallet, index_MainnetContext as MainnetContext, index_MnemonicWallet as MnemonicWallet, index_MnemonicWalletVoid as MnemonicWalletVoid, index_P_CHAIN_TX_SIZE_LIMIT as P_CHAIN_TX_SIZE_LIMIT, index_SimpleLedgerSigner as SimpleLedgerSigner, index_SimpleSigner as SimpleSigner, index_SizeSupportedTx as SizeSupportedTx, index_StaticSigner as StaticSigner, index_TxType as TxType, index_WalletAbstract as WalletAbstract, index_WalletVoid as WalletVoid, index_addSignaturesToAvalancheTx as addSignaturesToAvalancheTx, index_convertGlacierUtxo as convertGlacierUtxo, index_createAvalancheEvmUnsignedTx as createAvalancheEvmUnsignedTx, index_createAvalancheUnsignedTx as createAvalancheUnsignedTx, index_digestMessage as digestMessage, index_emptySignature as emptySignature, index_getAddressFromXpub as getAddressFromXpub, index_getAddressPublicKeyFromXpub as getAddressPublicKeyFromXpub, index_getAssetBalance as getAssetBalance, index_getAvalancheDerivationPath as getAvalancheDerivationPath, index_getLedgerProvider as getLedgerProvider, index_getMaximumUtxoSet as getMaximumUtxoSet, index_getPaginatedUTXOs as getPaginatedUTXOs, index_getPchainUnixNow as getPchainUnixNow, index_getStakeForAddresses as getStakeForAddresses, index_getStakedAssetBalance as getStakedAssetBalance, index_getUTXOsForAddresses as getUTXOsForAddresses, index_getUnixNow as getUnixNow, index_getUtxosByTxFromGlacier as getUtxosByTxFromGlacier, index_getVmByChainAlias as getVmByChainAlias, index_getXpubFromMnemonic as getXpubFromMnemonic, index_isAddAutoRenewedValidatorTx as isAddAutoRenewedValidatorTx, index_isAddDelegatorTx as isAddDelegatorTx, index_isAddPermissionlessDelegatorTx as isAddPermissionlessDelegatorTx, index_isAddPermissionlessValidatorTx as isAddPermissionlessValidatorTx, index_isAddSubnetValidatorTx as isAddSubnetValidatorTx, index_isAddValidatorTx as isAddValidatorTx, index_isBaseTx as isBaseTx, index_isBech32Address as isBech32Address, index_isConvertSubnetToL1Tx as isConvertSubnetToL1Tx, index_isCreateChainTx as isCreateChainTx, index_isCreateSubnetTx as isCreateSubnetTx, index_isDisableL1ValidatorTx as isDisableL1ValidatorTx, index_isExportTx as isExportTx, index_isImportTx as isImportTx, index_isIncreaseL1ValidatorBalance as isIncreaseL1ValidatorBalance, index_isObsidianApp as isObsidianApp, index_isRegisterL1ValidatorTx as isRegisterL1ValidatorTx, index_isRemoveSubnetValidatorTx as isRemoveSubnetValidatorTx, index_isRewardAutoRenewedValidatorTx as isRewardAutoRenewedValidatorTx, index_isSetAutoRenewedValidatorConfigTx as isSetAutoRenewedValidatorConfigTx, index_isSetL1ValidatorWeightTx as isSetL1ValidatorWeightTx, index_isTransferSubnetOwnershipTx as isTransferSubnetOwnershipTx, index_isTransformSubnetTx as isTransformSubnetTx, index_parseAvalancheTx as parseAvalancheTx, index_populateCredential as populateCredential, index_signedTxToHex as signedTxToHex, index_sortUTXOsByAmount as sortUTXOsByAmount, index_sortUTXOsByAmountAscending as sortUTXOsByAmountAscending, index_sortUTXOsByAmountDescending as sortUTXOsByAmountDescending, index_sortUTXOsStaking as sortUTXOsStaking, index_verifyDerivationPath as verifyDerivationPath };
|
|
1972
|
+
export type { index_AddAutoRenewedValidatorTx as AddAutoRenewedValidatorTx, index_AddDelegatorTx as AddDelegatorTx, index_AddPermissionlessDelegatorTx as AddPermissionlessDelegatorTx, index_AddPermissionlessValidatorTx as AddPermissionlessValidatorTx, index_AddSubnetValidatorTx as AddSubnetValidatorTx, index_AddValidatorTx as AddValidatorTx, BaseTx$1 as BaseTx, index_ChainIDAlias as ChainIDAlias, index_ConvertSubnetToL1Tx as ConvertSubnetToL1Tx, index_CreateChainTx as CreateChainTx, index_CreateSubnetTx as CreateSubnetTx, index_DisableL1ValidatorTx as DisableL1ValidatorTx, index_ExportTx as ExportTx, index_FeeData as FeeData, index_GetAvaxBalanceDict as GetAvaxBalanceDict, index_GetStakedAvaxBalanceDict as GetStakedAvaxBalanceDict, index_GlacierOutput as GlacierOutput, index_ImportTx as ImportTx, index_IncreaseL1ValidatorBalanceTx as IncreaseL1ValidatorBalanceTx, index_LedgerGetXpubResponse as LedgerGetXpubResponse, index_ParseOptions as ParseOptions, index_RegisterL1ValidatorTx as RegisterL1ValidatorTx, index_RemoveSubnetValidatorTx as RemoveSubnetValidatorTx, index_RewardAutoRenewedValidatorTx as RewardAutoRenewedValidatorTx, index_SetAutoRenewedValidatorConfigTx as SetAutoRenewedValidatorConfigTx, index_SetL1ValidatorWeightTx as SetL1ValidatorWeightTx, index_SignMessageRequest as SignMessageRequest, index_SignTxBufferRequest as SignTxBufferRequest, index_SignTxRequest as SignTxRequest, index_Signer as Signer, TransferSubnetOwnershipTx$1 as TransferSubnetOwnershipTx, index_TransformSubnetTx as TransformSubnetTx, index_Tx as Tx, index_TxBase as TxBase, index_UnknownTx as UnknownTx };
|
|
1905
1973
|
}
|
|
1906
1974
|
|
|
1907
1975
|
type DerivationPathOptions = {
|
|
@@ -2011,14 +2079,16 @@ declare const getSolanaPublicKeyFromLedger: (accountIndex: number, transport: Tr
|
|
|
2011
2079
|
* @param mint - The mint address of the token.
|
|
2012
2080
|
* @param owner - The public key of the wallet owner.
|
|
2013
2081
|
* @param provider - An instance of SolanaProvider to interact with the Solana blockchain.
|
|
2082
|
+
* @param tokenProgram - SPL Token program id for this mint (legacy or Token-2022). If omitted, it is resolved via RPC.
|
|
2014
2083
|
* @returns { ataAddress: string; exists: boolean; info: SolanaAccountInfo } - The ATA address, a boolean indicating if it exists, and the account info if it does.
|
|
2015
2084
|
*/
|
|
2016
|
-
declare const maybeGetAssociatedTokenAccount: ({ mint, owner, provider, }: {
|
|
2085
|
+
declare const maybeGetAssociatedTokenAccount: ({ mint, owner, provider, tokenProgram: tokenProgramOverride, }: {
|
|
2017
2086
|
mint: string;
|
|
2018
2087
|
owner: string;
|
|
2019
2088
|
provider: SolanaProvider;
|
|
2089
|
+
tokenProgram?: Address<string> | undefined;
|
|
2020
2090
|
}) => Promise<{
|
|
2021
|
-
address:
|
|
2091
|
+
address: Address<string>;
|
|
2022
2092
|
exists: boolean;
|
|
2023
2093
|
info: Readonly<{
|
|
2024
2094
|
context: Readonly<{
|
|
@@ -2027,7 +2097,7 @@ declare const maybeGetAssociatedTokenAccount: ({ mint, owner, provider, }: {
|
|
|
2027
2097
|
value: (Readonly<{
|
|
2028
2098
|
executable: boolean;
|
|
2029
2099
|
lamports: _solana_kit.Lamports;
|
|
2030
|
-
owner:
|
|
2100
|
+
owner: Address<string>;
|
|
2031
2101
|
rentEpoch: bigint;
|
|
2032
2102
|
space: bigint;
|
|
2033
2103
|
}> & Readonly<{
|
|
@@ -2036,6 +2106,15 @@ declare const maybeGetAssociatedTokenAccount: ({ mint, owner, provider, }: {
|
|
|
2036
2106
|
}>;
|
|
2037
2107
|
}>;
|
|
2038
2108
|
|
|
2109
|
+
/**
|
|
2110
|
+
* Loads the mint account and returns the SPL Token program that owns it
|
|
2111
|
+
* (legacy Tokenkeg... or Token-2022 TokenzQd...).
|
|
2112
|
+
*/
|
|
2113
|
+
declare const resolveTokenProgramForMint: ({ mint, provider, }: {
|
|
2114
|
+
mint: string;
|
|
2115
|
+
provider: SolanaProvider;
|
|
2116
|
+
}) => Promise<Address>;
|
|
2117
|
+
|
|
2039
2118
|
declare class SolanaSigner {
|
|
2040
2119
|
#private;
|
|
2041
2120
|
constructor(privateKey: Buffer);
|
|
@@ -2059,5 +2138,5 @@ declare class SolanaLedgerSigner {
|
|
|
2059
2138
|
signTx(base64EncodedTx: string, provider: SolanaProvider): Promise<string>;
|
|
2060
2139
|
}
|
|
2061
2140
|
|
|
2062
|
-
export { index as Avalanche, BitcoinLedgerWallet, BitcoinProvider, BitcoinProviderAbstract, BitcoinWallet, BitcoinWalletAbstract, BitcoinWalletVoid, BtcNetworks, DerivationPath, ETH_ACCOUNT_PATH, ETH_COIN_PATH, JsonRpcBatchInternal, LedgerSigner$1 as LedgerSigner, SolanaLedgerSigner, SolanaSigner, addEncodedSigToPsbt, compileSolanaTx, createPSBTV2, createPsbt, createTransferTx, createWalletPolicy, deserializeTransactionMessage, formatAddressForNetworkBech32, getAddressDerivationPath, getAddressFromXPub, getAddressPrivateKeyFromXPriv, getAddressPublicKeyFromXPub, getAppEth, getBech32Address, getBech32AddressFromXPub, getBtcAddressFromPubKey, getEVMDerivationPath, getEvmAddressFromPubKey, getLedgerAppInfo, getLedgerExtendedPublicKey, getMaxTransferAmount, getPubKeyFromTransport, getPublicKeyFromPrivateKey, getSolanaDerivationPath, getSolanaProvider, getSolanaPublicKeyFromLedger, getTransferTxDetails, getVoidSigner, getWalletFromMnemonic, getXpubFromMnemonic$1 as getXpubFromMnemonic, isERC20Transfer, isNativeTxn, isSolanaProvider, maybeGetAssociatedTokenAccount, omitUndefinedKeys, onBalanceChange, openLedgerApp, psbt2ToPsbt0, quitLedgerApp, selectUtxos, serializeSolanaTx, transferSol, transferToken };
|
|
2141
|
+
export { index as Avalanche, BitcoinLedgerWallet, BitcoinProvider, BitcoinProviderAbstract, BitcoinWallet, BitcoinWalletAbstract, BitcoinWalletVoid, BtcNetworks, DerivationPath, ETH_ACCOUNT_PATH, ETH_COIN_PATH, JsonRpcBatchInternal, LedgerSigner$1 as LedgerSigner, SolanaLedgerSigner, SolanaSigner, addEncodedSigToPsbt, compileSolanaTx, createPSBTV2, createPsbt, createTransferTx, createWalletPolicy, deserializeTransactionMessage, formatAddressForNetworkBech32, getAddressDerivationPath, getAddressFromXPub, getAddressPrivateKeyFromXPriv, getAddressPublicKeyFromXPub, getAppEth, getBech32Address, getBech32AddressFromXPub, getBtcAddressFromPubKey, getEVMDerivationPath, getEvmAddressFromPubKey, getLedgerAppInfo, getLedgerExtendedPublicKey, getMaxTransferAmount, getPubKeyFromTransport, getPublicKeyFromPrivateKey, getSolanaDerivationPath, getSolanaProvider, getSolanaPublicKeyFromLedger, getTransferTxDetails, getVoidSigner, getWalletFromMnemonic, getXpubFromMnemonic$1 as getXpubFromMnemonic, isERC20Transfer, isNativeTxn, isSolanaProvider, maybeGetAssociatedTokenAccount, omitUndefinedKeys, onBalanceChange, openLedgerApp, psbt2ToPsbt0, quitLedgerApp, resolveTokenProgramForMint, selectUtxos, serializeSolanaTx, transferSol, transferToken };
|
|
2063
2142
|
export type { BitcoinHistoryTx, BitcoinInputUTXO, BitcoinInputUTXOWithOptionalScript, BitcoinLedgerInputUTXO, BitcoinOutputUTXO, BitcoinTx, SolanaProvider };
|
package/esm/Avalanche/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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';
|
|
1
|
+
export { AddAutoRenewedValidatorTx, AddDelegatorTx, AddPermissionlessDelegatorTx, AddPermissionlessValidatorTx, AddSubnetValidatorTx, AddValidatorTx, BaseTx, ChainIDAlias, ConvertSubnetToL1Tx, CreateChainTx, CreateSubnetTx, DisableL1ValidatorTx, ExportTx, FeeData, ImportTx, IncreaseL1ValidatorBalanceTx, RegisterL1ValidatorTx, RemoveSubnetValidatorTx, RewardAutoRenewedValidatorTx, SetAutoRenewedValidatorConfigTx, SetL1ValidatorWeightTx, TransferSubnetOwnershipTx, TransformSubnetTx, Tx, TxBase, TxType, UnknownTx, isAddAutoRenewedValidatorTx, isAddDelegatorTx, isAddPermissionlessDelegatorTx, isAddPermissionlessValidatorTx, isAddSubnetValidatorTx, isAddValidatorTx, isBaseTx, isConvertSubnetToL1Tx, isCreateChainTx, isCreateSubnetTx, isDisableL1ValidatorTx, isExportTx, isImportTx, isIncreaseL1ValidatorBalance, isRegisterL1ValidatorTx, isRemoveSubnetValidatorTx, isRewardAutoRenewedValidatorTx, isSetAutoRenewedValidatorConfigTx, 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';
|
package/esm/Avalanche/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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{LedgerLiveSigner}from"./wallets/ledger/LedgerLiveSigner.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";export{getAvalancheDerivationPath}from"./utils/getAvalancheDerivationPath.js";
|
|
1
|
+
export{TxType,isAddAutoRenewedValidatorTx,isAddDelegatorTx,isAddPermissionlessDelegatorTx,isAddPermissionlessValidatorTx,isAddSubnetValidatorTx,isAddValidatorTx,isBaseTx,isConvertSubnetToL1Tx,isCreateChainTx,isCreateSubnetTx,isDisableL1ValidatorTx,isExportTx,isImportTx,isIncreaseL1ValidatorBalance,isRegisterL1ValidatorTx,isRemoveSubnetValidatorTx,isRewardAutoRenewedValidatorTx,isSetAutoRenewedValidatorConfigTx,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{LedgerLiveSigner}from"./wallets/ledger/LedgerLiveSigner.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";export{getAvalancheDerivationPath}from"./utils/getAvalancheDerivationPath.js";
|
|
@@ -4,7 +4,7 @@ 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 | ConvertSubnetToL1Tx | RegisterL1ValidatorTx | SetL1ValidatorWeightTx | DisableL1ValidatorTx | IncreaseL1ValidatorBalanceTx | UnknownTx;
|
|
7
|
+
type Tx = AddValidatorTx | AddDelegatorTx | ExportTx | ImportTx | BaseTx | CreateSubnetTx | CreateChainTx | AddSubnetValidatorTx | RemoveSubnetValidatorTx | AddPermissionlessValidatorTx | AddPermissionlessDelegatorTx | TransformSubnetTx | TransferSubnetOwnershipTx | ConvertSubnetToL1Tx | RegisterL1ValidatorTx | SetL1ValidatorWeightTx | DisableL1ValidatorTx | IncreaseL1ValidatorBalanceTx | AddAutoRenewedValidatorTx | SetAutoRenewedValidatorConfigTx | RewardAutoRenewedValidatorTx | UnknownTx;
|
|
8
8
|
interface FeeData {
|
|
9
9
|
totalAvaxBurned: bigint;
|
|
10
10
|
totalAvaxOutput: bigint;
|
|
@@ -30,6 +30,9 @@ declare enum TxType {
|
|
|
30
30
|
SetL1ValidatorWeight = "set_l1_validator_weight",
|
|
31
31
|
IncreaseL1ValidatorBalance = "increase_l1_validator_balance",
|
|
32
32
|
DisableL1Validator = "disable_l1_validator",
|
|
33
|
+
AddAutoRenewedValidator = "add_auto_renewed_validator",
|
|
34
|
+
SetAutoRenewedValidatorConfig = "set_auto_renewed_validator_config",
|
|
35
|
+
RewardAutoRenewedValidator = "reward_auto_renewed_validator",
|
|
33
36
|
AddSubnetValidator = "add_subnet_validator",
|
|
34
37
|
RemoveSubnetValidator = "remove_subnet_validator",
|
|
35
38
|
AddPermissionlessValidator = "add_permissionless_validator",
|
|
@@ -137,6 +140,32 @@ interface DisableL1ValidatorTx extends TxBase {
|
|
|
137
140
|
type: TxType.DisableL1Validator;
|
|
138
141
|
validationId: string;
|
|
139
142
|
}
|
|
143
|
+
interface AddAutoRenewedValidatorTx extends TxBase {
|
|
144
|
+
type: TxType.AddAutoRenewedValidator;
|
|
145
|
+
nodeID: string;
|
|
146
|
+
stake: bigint;
|
|
147
|
+
stakeOuts: readonly TransferableOutput[];
|
|
148
|
+
rewardOwner: OutputOwners;
|
|
149
|
+
delegationRewardOwner: OutputOwners;
|
|
150
|
+
owner: OutputOwners;
|
|
151
|
+
delegationFee: number;
|
|
152
|
+
weight: bigint;
|
|
153
|
+
autoCompoundRewardShares: number;
|
|
154
|
+
period: bigint;
|
|
155
|
+
signer: pvmSerial.Signer | pvmSerial.SignerEmpty;
|
|
156
|
+
publicKey: undefined | string;
|
|
157
|
+
signature: undefined | string;
|
|
158
|
+
}
|
|
159
|
+
interface SetAutoRenewedValidatorConfigTx extends TxBase {
|
|
160
|
+
type: TxType.SetAutoRenewedValidatorConfig;
|
|
161
|
+
txId: string;
|
|
162
|
+
autoCompoundRewardShares: number;
|
|
163
|
+
period: bigint;
|
|
164
|
+
}
|
|
165
|
+
interface RewardAutoRenewedValidatorTx extends TxBase {
|
|
166
|
+
type: TxType.RewardAutoRenewedValidator;
|
|
167
|
+
txId: string;
|
|
168
|
+
}
|
|
140
169
|
interface AddPermissionlessValidatorTx extends TxBase {
|
|
141
170
|
type: TxType.AddPermissionlessValidator;
|
|
142
171
|
nodeID: string;
|
|
@@ -209,6 +238,9 @@ declare function isAddPermissionlessValidatorTx(tx: Tx): tx is AddPermissionless
|
|
|
209
238
|
declare function isAddPermissionlessDelegatorTx(tx: Tx): tx is AddPermissionlessDelegatorTx;
|
|
210
239
|
declare function isTransformSubnetTx(tx: Tx): tx is TransformSubnetTx;
|
|
211
240
|
declare function isTransferSubnetOwnershipTx(tx: Tx): tx is TransferSubnetOwnershipTx;
|
|
241
|
+
declare function isAddAutoRenewedValidatorTx(tx: Tx): tx is AddAutoRenewedValidatorTx;
|
|
242
|
+
declare function isSetAutoRenewedValidatorConfigTx(tx: Tx): tx is SetAutoRenewedValidatorConfigTx;
|
|
243
|
+
declare function isRewardAutoRenewedValidatorTx(tx: Tx): tx is RewardAutoRenewedValidatorTx;
|
|
212
244
|
|
|
213
|
-
export { TxType, isAddDelegatorTx, isAddPermissionlessDelegatorTx, isAddPermissionlessValidatorTx, isAddSubnetValidatorTx, isAddValidatorTx, isBaseTx, isConvertSubnetToL1Tx, isCreateChainTx, isCreateSubnetTx, isDisableL1ValidatorTx, isExportTx, isImportTx, isIncreaseL1ValidatorBalance, isRegisterL1ValidatorTx, isRemoveSubnetValidatorTx, isSetL1ValidatorWeightTx, isTransferSubnetOwnershipTx, isTransformSubnetTx };
|
|
214
|
-
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 };
|
|
245
|
+
export { TxType, isAddAutoRenewedValidatorTx, isAddDelegatorTx, isAddPermissionlessDelegatorTx, isAddPermissionlessValidatorTx, isAddSubnetValidatorTx, isAddValidatorTx, isBaseTx, isConvertSubnetToL1Tx, isCreateChainTx, isCreateSubnetTx, isDisableL1ValidatorTx, isExportTx, isImportTx, isIncreaseL1ValidatorBalance, isRegisterL1ValidatorTx, isRemoveSubnetValidatorTx, isRewardAutoRenewedValidatorTx, isSetAutoRenewedValidatorConfigTx, isSetL1ValidatorWeightTx, isTransferSubnetOwnershipTx, isTransformSubnetTx };
|
|
246
|
+
export type { AddAutoRenewedValidatorTx, AddDelegatorTx, AddPermissionlessDelegatorTx, AddPermissionlessValidatorTx, AddSubnetValidatorTx, AddValidatorTx, BaseTx, ChainIDAlias, ConvertSubnetToL1Tx, CreateChainTx, CreateSubnetTx, DisableL1ValidatorTx, ExportTx, FeeData, ImportTx, IncreaseL1ValidatorBalanceTx, RegisterL1ValidatorTx, RemoveSubnetValidatorTx, RewardAutoRenewedValidatorTx, SetAutoRenewedValidatorConfigTx, 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.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
|
|
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.AddAutoRenewedValidator="add_auto_renewed_validator",e.SetAutoRenewedValidatorConfig="set_auto_renewed_validator_config",e.RewardAutoRenewedValidator="reward_auto_renewed_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 _(e){return"set_l1_validator_weight"===e.type}function u(e){return"disable_l1_validator"===e.type}function l(e){return"increase_l1_validator_balance"===e.type}function s(e){return"create_subnet"===e.type}function c(e){return"create_chain"===e.type}function p(e){return"add_subnet_validator"===e.type}function f(e){return"remove_subnet_validator"===e.type}function v(e){return"add_permissionless_validator"===e.type}function b(e){return"add_permissionless_delegator"===e.type}function y(e){return"transform_subnet"===e.type}function w(e){return"transfer_subnet_ownership"===e.type}function g(e){return"add_auto_renewed_validator"===e.type}function m(e){return"set_auto_renewed_validator_config"===e.type}function V(e){return"reward_auto_renewed_validator"===e.type}export{e as TxType,g as isAddAutoRenewedValidatorTx,r as isAddDelegatorTx,b as isAddPermissionlessDelegatorTx,v as isAddPermissionlessValidatorTx,p as isAddSubnetValidatorTx,t as isAddValidatorTx,o as isBaseTx,i as isConvertSubnetToL1Tx,c as isCreateChainTx,s as isCreateSubnetTx,u as isDisableL1ValidatorTx,n as isExportTx,a as isImportTx,l as isIncreaseL1ValidatorBalance,d as isRegisterL1ValidatorTx,f as isRemoveSubnetValidatorTx,V as isRewardAutoRenewedValidatorTx,m as isSetAutoRenewedValidatorConfigTx,_ as isSetL1ValidatorWeightTx,w as isTransferSubnetOwnershipTx,y as isTransformSubnetTx};
|
|
@@ -4,9 +4,9 @@ import { Context } from '@avalabs/avalanchejs';
|
|
|
4
4
|
declare class JsonRpcProvider extends AbstractProvider {
|
|
5
5
|
constructor(baseUrl: string, context: Context.Context, fetchOptions?: RequestInit);
|
|
6
6
|
static fromBaseURL(url: string): Promise<JsonRpcProvider>;
|
|
7
|
-
static getDefaultMainnetProvider(): JsonRpcProvider;
|
|
8
|
-
static getDefaultFujiProvider(): JsonRpcProvider;
|
|
9
|
-
static getDefaultDevnetProvider(): JsonRpcProvider;
|
|
7
|
+
static getDefaultMainnetProvider(fetchOptions?: RequestInit): JsonRpcProvider;
|
|
8
|
+
static getDefaultFujiProvider(fetchOptions?: RequestInit): JsonRpcProvider;
|
|
9
|
+
static getDefaultDevnetProvider(fetchOptions?: RequestInit): JsonRpcProvider;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export { JsonRpcProvider };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AbstractProvider as r}from"./AbstractProvider.js";import{Context as t}from"@avalabs/avalanchejs";import{MainnetContext as e,FujiContext as a,DevnetContext as n}from"./constants.js";import{AVALANCHE_XP_NETWORK as s,AVALANCHE_XP_TEST_NETWORK as o,AVALANCHE_P_DEV_NETWORK as c}from"@avalabs/core-chains-sdk";class i extends r{constructor(r,t,e){super(r,t,e)}static async fromBaseURL(r){const e=await t.getContextFromURI(r);try{return new i(r,e)}catch{return new i(r,e)}}static getDefaultMainnetProvider(){return new i(s.rpcUrl,e)}static getDefaultFujiProvider(){return new i(o.rpcUrl,a)}static getDefaultDevnetProvider(){return new i(c.rpcUrl,n)}}export{i as JsonRpcProvider};
|
|
1
|
+
import{AbstractProvider as r}from"./AbstractProvider.js";import{Context as t}from"@avalabs/avalanchejs";import{MainnetContext as e,FujiContext as a,DevnetContext as n}from"./constants.js";import{AVALANCHE_XP_NETWORK as s,AVALANCHE_XP_TEST_NETWORK as o,AVALANCHE_P_DEV_NETWORK as c}from"@avalabs/core-chains-sdk";class i extends r{constructor(r,t,e){super(r,t,e)}static async fromBaseURL(r){const e=await t.getContextFromURI(r);try{return new i(r,e)}catch{return new i(r,e)}}static getDefaultMainnetProvider(r){return new i(s.rpcUrl,e,r)}static getDefaultFujiProvider(r){return new i(o.rpcUrl,a,r)}static getDefaultDevnetProvider(r){return new i(c.rpcUrl,n,r)}}export{i as JsonRpcProvider};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pvmSerial as e,utils as a}from"@avalabs/avalanchejs";async function r(r,t,n){try{const d=(await n.getApiP().getTx({txID:t.txId.value()})).unsignedTx;if(!e.isAddAutoRenewedValidatorTx(d))throw new Error("Referenced validator transaction is not an AddAutoRenewedValidatorTx");const o=d.getOwner().addrs,s=t.getAuth().values(),i=o.reduce(((e,a,r)=>(s.includes(r)&&e.push([a,r]),e)),[]);return r.push(new a.AddressMap(i)),r}catch(e){throw new Error(`Error while preparing auto-renewed validator config auth data: ${e.message}`)}}export{r as appendAutoRenewedValidatorConfigAddressMaps};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{utils as e,UnsignedTx as
|
|
1
|
+
import{utils as e,UnsignedTx as a,pvmSerial as r}from"@avalabs/avalanchejs";import{isSubnetTx as t,handleSubnetAuth as s}from"./handleSubnetAuth.js";import{appendDisableAuthAddressMaps as o}from"./appendDisableAuthAddressMaps.js";import{appendAutoRenewedValidatorConfigAddressMaps as n}from"./appendAutoRenewedValidatorConfigAddressMaps.js";const{getTransferableInputsByTx:i,AddressMaps:d}=e,p=async({tx:e,fromAddressBytes:p,provider:l,credentials:f,utxos:u})=>{const m=i(e);let w=d.fromTransferableInputs(m,u,BigInt(Math.floor((new Date).getTime()/1e3)),p);if(t(e))try{const r=await s({tx:e,provider:l,addressMaps:w});return new a(e,u,r,f)}catch(e){throw new Error(`Error while preparing subnet authorization data: ${e.message}`)}else r.isDisableL1ValidatorTx(e)?w=await o(w,e,l):r.isSetAutoRenewedValidatorConfigTx(e)&&(w=await n(w,e,l));return new a(e,u,w,f)};var l=p;export{p as createAvalancheUnsignedTx,l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{utils as t,evmSerial as e}from"@avalabs/avalanchejs";import
|
|
1
|
+
import{utils as t,evmSerial as e}from"@avalabs/avalanchejs";import a from"./parsers/index.js";const{getBurnedAmountByTx:n,getOutputAmounts:o,getInputAmounts:s,validateBurnedAmount:r}=t;async function i(t,i,u,{feeTolerance:x=50,baseFee:g}={}){const A=i.getContext(),c=t.getTx(),d=(t=>{for(const e of Object.values(a)){const a=e(t);if(null!==a)return a}throw new Error("no parser found for tx")})(c),p=n(c,A),v=o(c),l=s(c).get(A.avaxAssetID)??BigInt(0),I=p.get(A.avaxAssetID)??BigInt(0),m=v.get(A.avaxAssetID)??BigInt(0);let f=g;void 0===f&&(f=0n,e.isImportExportTx(c)?(f=await i.getApiC().getBaseFee()/BigInt(1e9),0n===f&&(f=1n)):"PVM"===c.vm&&(f=await i.getApiP().getFeeState().then((t=>t.price)).catch((()=>BigInt(0)))));const{isValid:B,txFee:F}=r({unsignedTx:t,context:A,burnedAmount:I,baseFee:f,feeTolerance:x});return await d({feeData:{totalAvaxBurned:I,totalAvaxOutput:m,totalAvaxInput:l,isValidAvaxBurnedAmount:B,txFee:F,baseFee:f},assetId:A.avaxAssetID,provider:i,currentAddress:u})}export{i as parseAvalancheTx};
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 d from"./parseRemoveSubnetValidatorTx.js";import m from"./parseTransferSubnetOwnershipTx.js";import x from"./parseConvertSubnetToL1Tx.js";import T from"./parseRegisterL1ValidatorTx.js";import n from"./parseSetL1ValidatorWeightTx.js";import l from"./parseDisableL1ValidatorTx.js";import f from"./parseIncreaseL1ValidatorBalanceTx.js";import V from"./parseAddAutoRenewedValidatorTx.js";import j from"./parseSetAutoRenewedValidatorConfigTx.js";import u from"./parseRewardAutoRenewedValidatorTx.js";var A={parseCreateSubnetTx:r,parseCreateChainTx:e,parseAddSubnetValidatorTx:a,parseRemoveSubnetValidatorTx:d,parseImportTx:s,parseExportTx:o,parseBaseTx:t,parseAddPermissionlessValidatorTx:p,parseAddPermissionlessDelegatorTx:i,parseTransferSubnetOwnershipTx:m,parseConvertSubnetTx:x,parseRegisterL1ValidatorTx:T,parseIncreaseL1ValidatorBalanceTx:f,parseSetL1ValidatorWeightTx:n,parseDisableL1ValidatorTx:l,parseAddAutoRenewedValidatorTx:V,parseSetAutoRenewedValidatorConfigTx:j,parseRewardAutoRenewedValidatorTx:u};export{A as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pvmSerial as e,utils as r}from"@avalabs/avalanchejs";import{TxType as a}from"../../models.js";var t=t=>{if(!e.isAddAutoRenewedValidatorTx(t))return null;let o,n;return e.isSigner(t.signer)&&(n=r.bufferToHex(t.signer.proof.publicKey),o=r.bufferToHex(t.signer.proof.signature)),({feeData:e})=>({type:a.AddAutoRenewedValidator,chain:t.getVM(),nodeID:t.nodeId.value(),stake:t.weight.value(),stakeOuts:t.stake,rewardOwner:t.getValidatorRewardsOwner(),delegationRewardOwner:t.getDelegatorRewardsOwner(),owner:t.getOwner(),delegationFee:t.shares.value(),weight:t.weight.value(),autoCompoundRewardShares:t.autoCompoundRewardShares.value(),period:t.period.value(),signer:t.signer,publicKey:n,signature:o,...e})};export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";var t=t=>a.isRewardAutoRenewedValidatorTx(t)?({feeData:a})=>({type:e.RewardAutoRenewedValidator,chain:t.getVM(),txId:t.txId.value(),...a}):null;export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";var o=o=>a.isSetAutoRenewedValidatorConfigTx(o)?({feeData:a})=>({type:e.SetAutoRenewedValidatorConfig,chain:o.getVM(),txId:o.txId.value(),autoCompoundRewardShares:o.autoCompoundRewardShares.value(),period:o.period.value(),...a}):null;export{o as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{addTxSignatures as e,secp256k1 as t}from"@avalabs/avalanchejs";import{fromSeed as i}from"bip32";import{validateMnemonic as r,mnemonicToSeedSync as s}from"bip39";import"@ledgerhq/hw-app-eth";import"ethers";import{DerivationPath as n}from"../../EVM/constants.js";import"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";import{getAddressDerivationPath as o}from"../../utils/getAddressDerivationPath.js";import"hdkey";import"../utils/addSignaturesToAvalancheTx.js";import"../utils/convertGlacierUtxo.js";import"../utils/createAvalancheEvmUnsignedTx.js";import"../utils/createAvalancheUnsignedTx.js";import{digestMessage as a}from"../utils/digestMessage.js";import"../utils/getAssetBalance.js";import"../utils/getUtxosByTxFromGlacier.js";import"../utils/parseAvalancheTx.js";import"../utils/populateCredential.js";import"../utils/txSizeLimits.js";import"bip32-path";class c{accountNodeXP;signerNodeEVM;activeAccountIndex;constructor(e,t){if(!r(e))throw new Error("Invalid mnemonic phrase.");if(t<0||t%1!=0)throw new Error("Invalid account index.");const a=s(e),c=i(a);this.accountNodeXP=c.derivePath(`m/44'/9000'/${t}'`);const p=c.derivePath(o(t,"EVM",{pathSpec:n.BIP44}));this.signerNodeEVM=p,this.activeAccountIndex=t}getAdditionalKeys(e,t){return[...new Set(e??[])].reduce(((e,i)=>{const r=this.accountNodeXP.derivePath(`${t?1:0}/${i}`);if(!r.privateKey)throw new Error("Unable to get private key.");return e.push(r.privateKey),e}),[])}getSigningKeys(e,t,i){if("EVM"===e){if(!this.signerNodeEVM.privateKey)throw new Error("Unable to derive EVM private key.");return[this.signerNodeEVM.privateKey]}const r=this.accountNodeXP.derivePath("0/0");if(!r.privateKey)throw new Error("Unable to derive X/P private key.");const s=this.getAdditionalKeys(t,!1)
|
|
1
|
+
import{addTxSignatures as e,secp256k1 as t}from"@avalabs/avalanchejs";import{fromSeed as i}from"bip32";import{validateMnemonic as r,mnemonicToSeedSync as s}from"bip39";import"@ledgerhq/hw-app-eth";import"ethers";import{DerivationPath as n}from"../../EVM/constants.js";import"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";import{getAddressDerivationPath as o}from"../../utils/getAddressDerivationPath.js";import"hdkey";import"../utils/addSignaturesToAvalancheTx.js";import"../utils/convertGlacierUtxo.js";import"../utils/createAvalancheEvmUnsignedTx.js";import"../utils/createAvalancheUnsignedTx.js";import{digestMessage as a}from"../utils/digestMessage.js";import"../utils/getAssetBalance.js";import"../utils/getUtxosByTxFromGlacier.js";import"../utils/parseAvalancheTx.js";import"../utils/populateCredential.js";import"../utils/txSizeLimits.js";import"bip32-path";class c{accountNodeXP;signerNodeEVM;activeAccountIndex;constructor(e,t){if(!r(e))throw new Error("Invalid mnemonic phrase.");if(t<0||t%1!=0)throw new Error("Invalid account index.");const a=s(e),c=i(a);this.accountNodeXP=c.derivePath(`m/44'/9000'/${t}'`);const p=c.derivePath(o(t,"EVM",{pathSpec:n.BIP44}));this.signerNodeEVM=p,this.activeAccountIndex=t}getAdditionalKeys(e,t){return[...new Set(e??[])].reduce(((e,i)=>{const r=this.accountNodeXP.derivePath(`${t?1:0}/${i}`);if(!r.privateKey)throw new Error("Unable to get private key.");return e.push(r.privateKey),e}),[])}getSigningKeys(e,t,i){if("EVM"===e){if(!this.signerNodeEVM.privateKey)throw new Error("Unable to derive EVM private key.");return[this.signerNodeEVM.privateKey]}const r=this.accountNodeXP.derivePath("0/0");if(!r.privateKey)throw new Error("Unable to derive X/P private key.");const s=this.getAdditionalKeys(t,!1),n=this.getAdditionalKeys(i,!0);return[r.privateKey,...s,...n]}async signTx(t){const{tx:i,externalIndices:r,internalIndices:s}=t,n=i.getVM(),o=this.getSigningKeys(n,r,s);if(!o?.length)throw new Error("Unable to sign transaction: signing keys are missing.");return await e({unsignedTx:i,privateKeys:o}),t.tx}async signTxBuffer(e){throw new Error("Not implemented")}getActiveAccountNode(e){switch(e){case"X":case"P":return this.accountNodeXP.derivePath("0/0");case"C":return this.signerNodeEVM}}async signMessage(e){const i=this.getActiveAccountNode(e.chain);if(!i.privateKey)throw Error("Unable to sign message, key not found.");const r=a(e.message),s=await t.signHash(r,i.privateKey);return Buffer.from(s)}}export{c as SimpleSigner};
|
|
@@ -164,6 +164,34 @@ type RemoveSubnetValidator = {
|
|
|
164
164
|
fromAddresses?: string[];
|
|
165
165
|
options?: Common.SpendOptions;
|
|
166
166
|
};
|
|
167
|
+
type AddAutoRenewedValidator = {
|
|
168
|
+
utxoSet: utils.UtxoSet;
|
|
169
|
+
nodeId: string;
|
|
170
|
+
weight: bigint;
|
|
171
|
+
shares: number;
|
|
172
|
+
feeState: pvm.FeeState;
|
|
173
|
+
fromAddresses?: string[];
|
|
174
|
+
rewardAddresses?: string[];
|
|
175
|
+
delegatorRewardAddresses?: string[];
|
|
176
|
+
ownerAddresses?: string[];
|
|
177
|
+
publicKey?: Buffer;
|
|
178
|
+
signature?: Buffer;
|
|
179
|
+
autoCompoundRewardShares: number;
|
|
180
|
+
period: bigint;
|
|
181
|
+
options?: Common.SpendOptions;
|
|
182
|
+
locktime?: bigint;
|
|
183
|
+
threshold?: number;
|
|
184
|
+
};
|
|
185
|
+
type SetAutoRenewedValidatorConfig = {
|
|
186
|
+
utxoSet: utils.UtxoSet;
|
|
187
|
+
feeState: pvm.FeeState;
|
|
188
|
+
validatorTxId: string;
|
|
189
|
+
auth: number[];
|
|
190
|
+
autoCompoundRewardShares: number;
|
|
191
|
+
period: bigint;
|
|
192
|
+
fromAddresses?: string[];
|
|
193
|
+
options?: Common.SpendOptions;
|
|
194
|
+
};
|
|
167
195
|
type TransferSubnetOwnershipTx = {
|
|
168
196
|
utxoSet: utils.UtxoSet;
|
|
169
197
|
subnetId: string;
|
|
@@ -176,4 +204,4 @@ type TransferSubnetOwnershipTx = {
|
|
|
176
204
|
locktime?: bigint;
|
|
177
205
|
};
|
|
178
206
|
|
|
179
|
-
export type { AddPermissionlessDelegator, AddPermissionlessValidator, AddSubnetValidator, BaseTx, ConsolidateP, ConvertSubnetToL1, CreateChain, CreateSubnet, DisableL1Validator, ExportP, ImportP, IncreaseL1ValidatorBalance, RegisterL1Validator, RemoveSubnetValidator, SetL1ValidatorWeight, TransferSubnetOwnershipTx };
|
|
207
|
+
export type { AddAutoRenewedValidator, AddPermissionlessDelegator, AddPermissionlessValidator, AddSubnetValidator, BaseTx, ConsolidateP, ConvertSubnetToL1, CreateChain, CreateSubnet, DisableL1Validator, ExportP, ImportP, IncreaseL1ValidatorBalance, RegisterL1Validator, RemoveSubnetValidator, SetAutoRenewedValidatorConfig, SetL1ValidatorWeight, TransferSubnetOwnershipTx };
|
|
@@ -2,7 +2,7 @@ import * as _avalabs_avalanchejs from '@avalabs/avalanchejs';
|
|
|
2
2
|
import { utils, pvm, Common } from '@avalabs/avalanchejs';
|
|
3
3
|
import { AbstractProvider } from '../providers/AbstractProvider.js';
|
|
4
4
|
import { ChainIDAlias } from '../models.js';
|
|
5
|
-
import { ImportP, ExportP, ConsolidateP, BaseTx, ConvertSubnetToL1, RegisterL1Validator, SetL1ValidatorWeight, DisableL1Validator, IncreaseL1ValidatorBalance, CreateChain, CreateSubnet, AddSubnetValidator, AddPermissionlessValidator, AddPermissionlessDelegator, RemoveSubnetValidator, TransferSubnetOwnershipTx } from './TxBuilderTypes.js';
|
|
5
|
+
import { ImportP, ExportP, ConsolidateP, BaseTx, ConvertSubnetToL1, RegisterL1Validator, SetL1ValidatorWeight, DisableL1Validator, IncreaseL1ValidatorBalance, AddAutoRenewedValidator, SetAutoRenewedValidatorConfig, CreateChain, CreateSubnet, AddSubnetValidator, AddPermissionlessValidator, AddPermissionlessDelegator, RemoveSubnetValidator, TransferSubnetOwnershipTx } from './TxBuilderTypes.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* An abstract class that that is shared by all wallet classes.
|
|
@@ -85,6 +85,8 @@ declare abstract class WalletAbstract {
|
|
|
85
85
|
setL1ValidatorWeight({ utxoSet, feeState, message, options, fromAddresses, }: SetL1ValidatorWeight): Common.UnsignedTx;
|
|
86
86
|
disableL1Validator({ utxoSet, feeState, options, fromAddresses, disableAuth, validationId, }: DisableL1Validator): Common.UnsignedTx;
|
|
87
87
|
increaseL1ValidatorBalance({ utxoSet, feeState, options, fromAddresses, balance, validationId, }: IncreaseL1ValidatorBalance): Common.UnsignedTx;
|
|
88
|
+
addAutoRenewedValidator({ utxoSet, nodeId, weight, shares, feeState, fromAddresses, rewardAddresses, delegatorRewardAddresses, ownerAddresses, publicKey, signature, autoCompoundRewardShares, period, options, locktime, threshold, }: AddAutoRenewedValidator): Common.UnsignedTx;
|
|
89
|
+
setAutoRenewedValidatorConfig({ utxoSet, feeState, validatorTxId, auth, autoCompoundRewardShares, period, fromAddresses, options, }: SetAutoRenewedValidatorConfig): Common.UnsignedTx;
|
|
88
90
|
createBlockchain({ utxoSet, subnetId, chainName, vmID, fxIds, genesisData, subnetAuth, feeState, options, fromAddresses, }: CreateChain): Common.UnsignedTx;
|
|
89
91
|
createSubnet({ utxoSet, rewardAddresses, feeState, fromAddresses, options, threshold, locktime, }: CreateSubnet): Common.UnsignedTx;
|
|
90
92
|
addSubnetValidator({ utxoSet, nodeId, start, end, weight, subnetId, subnetAuth, feeState, fromAddresses, options, }: AddSubnetValidator): Common.UnsignedTx;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../utils/addSignaturesToAvalancheTx.js";import"../utils/convertGlacierUtxo.js";import"../utils/createAvalancheEvmUnsignedTx.js";import"../utils/createAvalancheUnsignedTx.js";import"create-hash";import"bip32";import{getUTXOsForAddresses as e}from"../utils/getAllUTXOs.js";import"../utils/getAssetBalance.js";import{utils as s,TransferableOutput as t,avm as r,pvm as d,evm as n,pvmSerial as o,PChainOwner as i,L1Validator as a,networkIDs as m}from"@avalabs/avalanchejs";import{getStakeForAddresses as h}from"../utils/getStakeForAddresses.js";import"../utils/getUtxosByTxFromGlacier.js";import"bip39";import"../utils/parseAvalancheTx.js";import"../utils/populateCredential.js";import{sortUTXOsByAmount as g,sortUTXOsByAmountAscending as u,sortUTXOsStaking as A}from"../utils/sortUTXOs.js";import"../utils/txSizeLimits.js";import"bip32-path";import{strip0x as c}from"@avalabs/core-utils-sdk";import{assertFeeStateProvided as p}from"../../utils/assertFeeStateProvided.js";const{parse:f,hexToBuffer:x}=s;class l{constructor(e){this.provider=e}setProvider(e){this.provider=e}getProvider(){return this.provider}async getUTXOs(s){const t=this.provider.getApi(s);return e(this.getAddresses(s),t)}async getStake(){const e=this.provider.getApiP();return h(this.getAddresses("P"),e)}async getAtomicUTXOs(s,t){if(s===t)throw new Error("Chain can not be the same as source chain.");const r=this.provider.getApi(s),d=this.provider.getChainID(t);return e(this.getAddresses(s),r,{sourceChain:d,addresses:[]})}exportX(e,s,d,n){n=n||this.getCurrentAddress(d);const o=f(n)[2],i=this.provider.getAvaxID(),a=t.fromNative(i,e,[o]),m=g(s.getUTXOs(),!0),h=this.provider.getChainID(d),u=this.getAddresses("X").map((e=>f(e)[2])),A=f(this.getChangeAddress("X"))[2];return r.newExportTx(this.provider.getContext(),h,u,m,[a],{threshold:1,changeAddresses:[A]})}importP({utxoSet:e,sourceChain:s,toAddress:t,threshold:r,feeState:n,locktime:o}){const i=this.provider.getChainID(s),a=this.getAddresses("P").map((e=>f(e)[2]));f(this.getChangeAddress("P"))[2],t=t||this.getCurrentAddress("P");const m=f(t)[2],h=e.getUTXOs();return p(n),d.newImportTx({fromAddressesBytes:a,utxos:h,toAddressesBytes:[m],sourceChainId:i,threshold:r,feeState:n,locktime:o},this.provider.getContext())}importX(e,s,t){const d=this.provider.getChainID(s),n=this.getAddresses("X").map((e=>f(e)[2])),o=f(this.getChangeAddress("X"))[2];t=t||this.getCurrentAddress("X");const i=f(t)[2];return r.newImportTx(this.provider.getContext(),d,e.getUTXOs(),[i],n,{changeAddresses:[o]})}importC(e,s,t,r,d){const o=this.provider.getChainID(s),i=this.getAddresses("C").map((e=>f(e)[2]));d=d||this.getAddressEVM();const a=Buffer.from(c(d),"hex");return n.newImportTxFromBaseFee(this.provider.getContext(),a,i,e.getUTXOs(),o,t,r)}exportC(e,s,t,r,d){const o=x(this.getAddressEVM()),i=this.provider.getChainID(s);d=d||this.getCurrentAddress(s);const a=f(d)[2],m=r/BigInt(1e9);return n.newExportTxFromBaseFee(this.provider.getContext(),m,e,i,o,[a],t)}exportP({amount:e,utxoSet:s,destination:r,feeState:n,toAddress:o}){o=o||this.getCurrentAddress(r);const i=f(o)[2],a=this.provider.getAvaxID(),m=t.fromNative(a,e,[i]),h=g(s.getUTXOs(),!0),u=this.provider.getChainID(r),A=this.getAddresses("P").map((e=>f(e)[2])),c=f(this.getChangeAddress("P"))[2];return p(n),d.newExportTx({changeAddressesBytes:[c],fromAddressesBytes:A,utxos:h,outputs:[m],destinationChainId:u,feeState:n},this.provider.getContext())}consolidateP({utxoSet:e,amount:s,feeState:r,toAddress:n,options:o}){const i=u(e.getUTXOs());n=n??this.getCurrentAddress("P");const a=f(n)[2],m=this.provider.getContext(),h=[t.fromNative(m.avaxAssetID,s,[a])],g=this.getAddresses("P").map((e=>f(e)[2])),A=f(this.getChangeAddress("P"))[2],c=o?.changeAddresses??[A];return p(r),d.newBaseTx({changeAddressesBytes:c,fromAddressesBytes:g,utxos:i,outputs:h,minIssuanceTime:o?.minIssuanceTime,memo:o?.memo,feeState:r},m)}baseTX({utxoSet:e,chain:s,toAddress:n,amountsPerAsset:o,feeState:i,options:a,fromAddresses:m}){const[h,u,A]=f(n);if(h!==s||u!==this.provider.getHrp())throw new Error(`Invalid recipient address "${n}"`);const c=Object.entries(o).map((([e,s])=>t.fromNative(e,s,[A]))),x=g(e.getUTXOs(),!0),l=(m??this.getAddresses(s)).map((e=>f(e)[2])),T=f(this.getChangeAddress("P"))[2],I=a?.changeAddresses??[T];return"X"===s?r.newBaseTx(this.provider.getContext(),l,x,c,a):(p(i),d.newBaseTx({changeAddressesBytes:I,fromAddressesBytes:l,utxos:x,outputs:c,minIssuanceTime:a?.minIssuanceTime,memo:a?.memo,feeState:i},this.provider.getContext()))}convertSubnetToL1({utxoSet:e,chainId:t,subnetId:r,subnetAuth:n,feeState:m,address:h,validators:u,options:A,fromAddresses:c}){const p=(c??this.getAddresses("P")).map((e=>f(e)[2])),x=f(this.getChangeAddress("P"))[2],l=A?.changeAddresses??[x],T=u.map((({nodeId:e,pubKey:t,signature:r,balance:d,weight:n,deactivationOwner:m,remainingBalanceOwner:h})=>{const g=new o.ProofOfPossession(Uint8Array.from(s.hexToBuffer(t)),Uint8Array.from(s.hexToBuffer(r))),u=i.fromNative(h.addresses.map((e=>f(e)[2])),h.threshold??1),A=i.fromNative(m.addresses.map((e=>f(e)[2])),m.threshold??1);return a.fromNative(e,n,d,g,u,A)}));return d.newConvertSubnetToL1Tx({changeAddressesBytes:l,validators:T,fromAddressesBytes:p,address:f(h)[2],chainId:t,subnetId:r,subnetAuth:n,feeState:m,utxos:g(e.getUTXOs(),!0)},this.provider.getContext())}registerL1Validator({utxoSet:e,balance:t,signature:r,message:n,feeState:o,fromAddresses:i,options:a}){const m=(i??this.getAddresses("P")).map((e=>f(e)[2])),h=f(this.getChangeAddress("P"))[2],u=a?.changeAddresses??[h];return d.newRegisterL1ValidatorTx({utxos:g(e.getUTXOs(),!0),balance:t,blsSignature:Uint8Array.from(s.hexToBuffer(r)),changeAddressesBytes:u,feeState:o,fromAddressesBytes:m,memo:a?.memo,message:Uint8Array.from(s.hexToBuffer(n)),minIssuanceTime:a?.minIssuanceTime},this.provider.getContext())}setL1ValidatorWeight({utxoSet:e,feeState:t,message:r,options:n,fromAddresses:o}){const i=(o??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],m=n?.changeAddresses??[a];return d.newSetL1ValidatorWeightTx({utxos:g(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:t,fromAddressesBytes:i,memo:n?.memo,message:Uint8Array.from(s.hexToBuffer(r)),minIssuanceTime:n?.minIssuanceTime},this.provider.getContext())}disableL1Validator({utxoSet:e,feeState:s,options:t,fromAddresses:r,disableAuth:n,validationId:o}){const i=(r??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],m=t?.changeAddresses??[a];return d.newDisableL1ValidatorTx({disableAuth:n,validationId:o,utxos:g(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:s,fromAddressesBytes:i,memo:t?.memo,minIssuanceTime:t?.minIssuanceTime},this.provider.getContext())}increaseL1ValidatorBalance({utxoSet:e,feeState:s,options:t,fromAddresses:r,balance:n,validationId:o}){const i=(r??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],m=t?.changeAddresses??[a];return d.newIncreaseL1ValidatorBalanceTx({balance:n,validationId:o,utxos:g(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:s,fromAddressesBytes:i,memo:t?.memo,minIssuanceTime:t?.minIssuanceTime},this.provider.getContext())}createBlockchain({utxoSet:e,subnetId:s,chainName:t,vmID:r,fxIds:n,genesisData:o,subnetAuth:i,feeState:a,options:m,fromAddresses:h}){const u=g(e.getUTXOs(),!0),A=(h??this.getAddresses("P")).map((e=>f(e)[2])),c=f(this.getChangeAddress("P"))[2],x=m?.changeAddresses??[c];return p(a),d.newCreateChainTx({chainName:t,feeState:a,fromAddressesBytes:A,fxIds:n,genesisData:o,subnetAuth:i,subnetId:s,utxos:u,vmId:r,changeAddressesBytes:x},this.provider.getContext())}createSubnet({utxoSet:e,rewardAddresses:s,feeState:t,fromAddresses:r,options:n,threshold:o,locktime:i}){const a=g(e.getUTXOs(),!0),m=(r??this.getAddresses("P")).map((e=>f(e)[2])),h=f(this.getChangeAddress("P"))[2],u=n?.changeAddresses??[h],A=s.map((e=>f(e)[2]));return p(t),d.newCreateSubnetTx({fromAddressesBytes:m,changeAddressesBytes:u,utxos:a,minIssuanceTime:n?.minIssuanceTime,memo:n?.memo,feeState:t,threshold:o,locktime:i,subnetOwners:A},this.provider.getContext())}addSubnetValidator({utxoSet:e,nodeId:s,start:t,end:r,weight:n,subnetId:o,subnetAuth:i,feeState:a,fromAddresses:m,options:h}){const u=g(e.getUTXOs(),!0),A=(m??this.getAddresses("P")).map((e=>f(e)[2])),c=f(this.getChangeAddress("P"))[2],x=h?.changeAddresses??[c];return p(a),d.newAddSubnetValidatorTx({changeAddressesBytes:x,fromAddressesBytes:A,utxos:u,minIssuanceTime:h?.minIssuanceTime,memo:h?.memo,nodeId:s,start:t,end:r,weight:n,subnetId:o,subnetAuth:i,feeState:a},this.provider.getContext())}addPermissionlessValidator({utxoSet:e,nodeId:s,start:t,end:r,weight:n,subnetId:o,shares:i,feeState:a,fromAddresses:h,rewardAddresses:g,delegatorRewardAddresses:u,publicKey:c,signature:x,options:l,threshold:T,locktime:I,stakingAssetId:v}){const C=A(e.getUTXOs()),S=(h??this.getAddresses("P")).map((e=>f(e)[2])),b=(g??[this.getCurrentAddress("P")]).map((e=>f(e)[2])),P=(u??[this.getCurrentAddress("P")]).map((e=>f(e)[2]));if(!(o!==m.PrimaryNetworkID.toString()||c&&x))throw new Error("Must provide public key and signature for primary subnet.");const w=f(this.getChangeAddress("P"))[2],B=l?.changeAddresses??[w];return p(a),d.newAddPermissionlessValidatorTx({fromAddressesBytes:S,delegatorRewardsOwner:P,utxos:C,minIssuanceTime:l?.minIssuanceTime,memo:l?.memo,changeAddressesBytes:B,nodeId:s,start:t,end:r,weight:n,subnetId:o,shares:i,feeState:a,publicKey:c,rewardAddresses:b,signature:x,locktime:I,threshold:T,stakingAssetId:v},this.provider.getContext())}addPermissionlessDelegator({utxoSet:e,nodeId:s,start:t,end:r,weight:n,subnetId:o,fromAddresses:i,rewardAddresses:a,options:m,locktime:h,feeState:g,threshold:u,stakingAssetId:c}){const x=A(e.getUTXOs()),l=(i??this.getAddresses("P")).map((e=>f(e)[2])),T=(a??[this.getCurrentAddress("P")]).map((e=>f(e)[2])),I=f(this.getChangeAddress("P"))[2],v=m?.changeAddresses??[I];return p(g),d.newAddPermissionlessDelegatorTx({fromAddressesBytes:l,utxos:x,minIssuanceTime:m?.minIssuanceTime,memo:m?.memo,changeAddressesBytes:v,nodeId:s,start:t,end:r,weight:n,subnetId:o,rewardAddresses:T,locktime:h,stakingAssetId:c,threshold:u,feeState:g},this.provider.getContext())}removeSubnetValidator({utxoSet:e,nodeId:s,subnetId:t,subnetAuth:r,fromAddresses:n,feeState:o,options:i}){const a=g(e.getUTXOs(),!0),m=(n??this.getAddresses("P")).map((e=>f(e)[2])),h=f(this.getChangeAddress("P"))[2],u=i?.changeAddresses??[h];return p(o),d.newRemoveSubnetValidatorTx({changeAddressesBytes:u,fromAddressesBytes:m,utxos:a,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,nodeId:s,subnetId:t,subnetAuth:r,feeState:o},this.provider.getContext())}transferSubnetOwnershipTx({utxoSet:e,subnetId:s,subnetAuth:t,subnetOwners:r,feeState:n,fromAddresses:o,options:i,threshold:a,locktime:m}){const h=g(e.getUTXOs(),!0),u=(o??this.getAddresses("P")).map((e=>f(e)[2])),A=f(this.getChangeAddress("P"))[2],c=i?.changeAddresses??[A],x=r.map((e=>f(e)[2]));return p(n),d.newTransferSubnetOwnershipTx({changeAddressesBytes:c,fromAddressesBytes:u,utxos:h,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,subnetId:s,subnetAuth:t,subnetOwners:x,feeState:n,threshold:a,locktime:m},this.provider.getContext())}}export{l as WalletAbstract};
|
|
1
|
+
import"../utils/addSignaturesToAvalancheTx.js";import"../utils/convertGlacierUtxo.js";import"../utils/createAvalancheEvmUnsignedTx.js";import"../utils/createAvalancheUnsignedTx.js";import"create-hash";import"bip32";import{getUTXOsForAddresses as e}from"../utils/getAllUTXOs.js";import"../utils/getAssetBalance.js";import{utils as s,TransferableOutput as t,avm as r,pvm as d,evm as o,pvmSerial as n,PChainOwner as i,L1Validator as a,networkIDs as m}from"@avalabs/avalanchejs";import{getStakeForAddresses as h}from"../utils/getStakeForAddresses.js";import"../utils/getUtxosByTxFromGlacier.js";import"bip39";import"../utils/parseAvalancheTx.js";import"../utils/populateCredential.js";import{sortUTXOsByAmount as g,sortUTXOsByAmountAscending as u,sortUTXOsStaking as A}from"../utils/sortUTXOs.js";import"../utils/txSizeLimits.js";import"bip32-path";import{strip0x as c}from"@avalabs/core-utils-sdk";import{assertFeeStateProvided as p}from"../../utils/assertFeeStateProvided.js";const{parse:f,hexToBuffer:l}=s;class x{constructor(e){this.provider=e}setProvider(e){this.provider=e}getProvider(){return this.provider}async getUTXOs(s){const t=this.provider.getApi(s);return e(this.getAddresses(s),t)}async getStake(){const e=this.provider.getApiP();return h(this.getAddresses("P"),e)}async getAtomicUTXOs(s,t){if(s===t)throw new Error("Chain can not be the same as source chain.");const r=this.provider.getApi(s),d=this.provider.getChainID(t);return e(this.getAddresses(s),r,{sourceChain:d,addresses:[]})}exportX(e,s,d,o){o=o||this.getCurrentAddress(d);const n=f(o)[2],i=this.provider.getAvaxID(),a=t.fromNative(i,e,[n]),m=g(s.getUTXOs(),!0),h=this.provider.getChainID(d),u=this.getAddresses("X").map((e=>f(e)[2])),A=f(this.getChangeAddress("X"))[2];return r.newExportTx(this.provider.getContext(),h,u,m,[a],{threshold:1,changeAddresses:[A]})}importP({utxoSet:e,sourceChain:s,toAddress:t,threshold:r,feeState:o,locktime:n}){const i=this.provider.getChainID(s),a=this.getAddresses("P").map((e=>f(e)[2]));f(this.getChangeAddress("P"))[2],t=t||this.getCurrentAddress("P");const m=f(t)[2],h=e.getUTXOs();return p(o),d.newImportTx({fromAddressesBytes:a,utxos:h,toAddressesBytes:[m],sourceChainId:i,threshold:r,feeState:o,locktime:n},this.provider.getContext())}importX(e,s,t){const d=this.provider.getChainID(s),o=this.getAddresses("X").map((e=>f(e)[2])),n=f(this.getChangeAddress("X"))[2];t=t||this.getCurrentAddress("X");const i=f(t)[2];return r.newImportTx(this.provider.getContext(),d,e.getUTXOs(),[i],o,{changeAddresses:[n]})}importC(e,s,t,r,d){const n=this.provider.getChainID(s),i=this.getAddresses("C").map((e=>f(e)[2]));d=d||this.getAddressEVM();const a=Buffer.from(c(d),"hex");return o.newImportTxFromBaseFee(this.provider.getContext(),a,i,e.getUTXOs(),n,t,r)}exportC(e,s,t,r,d){const n=l(this.getAddressEVM()),i=this.provider.getChainID(s);d=d||this.getCurrentAddress(s);const a=f(d)[2],m=r/BigInt(1e9);return o.newExportTxFromBaseFee(this.provider.getContext(),m,e,i,n,[a],t)}exportP({amount:e,utxoSet:s,destination:r,feeState:o,toAddress:n}){n=n||this.getCurrentAddress(r);const i=f(n)[2],a=this.provider.getAvaxID(),m=t.fromNative(a,e,[i]),h=g(s.getUTXOs(),!0),u=this.provider.getChainID(r),A=this.getAddresses("P").map((e=>f(e)[2])),c=f(this.getChangeAddress("P"))[2];return p(o),d.newExportTx({changeAddressesBytes:[c],fromAddressesBytes:A,utxos:h,outputs:[m],destinationChainId:u,feeState:o},this.provider.getContext())}consolidateP({utxoSet:e,amount:s,feeState:r,toAddress:o,options:n}){const i=u(e.getUTXOs());o=o??this.getCurrentAddress("P");const a=f(o)[2],m=this.provider.getContext(),h=[t.fromNative(m.avaxAssetID,s,[a])],g=this.getAddresses("P").map((e=>f(e)[2])),A=f(this.getChangeAddress("P"))[2],c=n?.changeAddresses??[A];return p(r),d.newBaseTx({changeAddressesBytes:c,fromAddressesBytes:g,utxos:i,outputs:h,minIssuanceTime:n?.minIssuanceTime,memo:n?.memo,feeState:r},m)}baseTX({utxoSet:e,chain:s,toAddress:o,amountsPerAsset:n,feeState:i,options:a,fromAddresses:m}){const[h,u,A]=f(o);if(h!==s||u!==this.provider.getHrp())throw new Error(`Invalid recipient address "${o}"`);const c=Object.entries(n).map((([e,s])=>t.fromNative(e,s,[A]))),l=g(e.getUTXOs(),!0),x=(m??this.getAddresses(s)).map((e=>f(e)[2])),T=f(this.getChangeAddress("P"))[2],I=a?.changeAddresses??[T];return"X"===s?r.newBaseTx(this.provider.getContext(),x,l,c,a):(p(i),d.newBaseTx({changeAddressesBytes:I,fromAddressesBytes:x,utxos:l,outputs:c,minIssuanceTime:a?.minIssuanceTime,memo:a?.memo,feeState:i},this.provider.getContext()))}convertSubnetToL1({utxoSet:e,chainId:t,subnetId:r,subnetAuth:o,feeState:m,address:h,validators:u,options:A,fromAddresses:c}){const p=(c??this.getAddresses("P")).map((e=>f(e)[2])),l=f(this.getChangeAddress("P"))[2],x=A?.changeAddresses??[l],T=u.map((({nodeId:e,pubKey:t,signature:r,balance:d,weight:o,deactivationOwner:m,remainingBalanceOwner:h})=>{const g=new n.ProofOfPossession(Uint8Array.from(s.hexToBuffer(t)),Uint8Array.from(s.hexToBuffer(r))),u=i.fromNative(h.addresses.map((e=>f(e)[2])),h.threshold??1),A=i.fromNative(m.addresses.map((e=>f(e)[2])),m.threshold??1);return a.fromNative(e,o,d,g,u,A)}));return d.newConvertSubnetToL1Tx({changeAddressesBytes:x,validators:T,fromAddressesBytes:p,address:f(h)[2],chainId:t,subnetId:r,subnetAuth:o,feeState:m,utxos:g(e.getUTXOs(),!0)},this.provider.getContext())}registerL1Validator({utxoSet:e,balance:t,signature:r,message:o,feeState:n,fromAddresses:i,options:a}){const m=(i??this.getAddresses("P")).map((e=>f(e)[2])),h=f(this.getChangeAddress("P"))[2],u=a?.changeAddresses??[h];return d.newRegisterL1ValidatorTx({utxos:g(e.getUTXOs(),!0),balance:t,blsSignature:Uint8Array.from(s.hexToBuffer(r)),changeAddressesBytes:u,feeState:n,fromAddressesBytes:m,memo:a?.memo,message:Uint8Array.from(s.hexToBuffer(o)),minIssuanceTime:a?.minIssuanceTime},this.provider.getContext())}setL1ValidatorWeight({utxoSet:e,feeState:t,message:r,options:o,fromAddresses:n}){const i=(n??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],m=o?.changeAddresses??[a];return d.newSetL1ValidatorWeightTx({utxos:g(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:t,fromAddressesBytes:i,memo:o?.memo,message:Uint8Array.from(s.hexToBuffer(r)),minIssuanceTime:o?.minIssuanceTime},this.provider.getContext())}disableL1Validator({utxoSet:e,feeState:s,options:t,fromAddresses:r,disableAuth:o,validationId:n}){const i=(r??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],m=t?.changeAddresses??[a];return d.newDisableL1ValidatorTx({disableAuth:o,validationId:n,utxos:g(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:s,fromAddressesBytes:i,memo:t?.memo,minIssuanceTime:t?.minIssuanceTime},this.provider.getContext())}increaseL1ValidatorBalance({utxoSet:e,feeState:s,options:t,fromAddresses:r,balance:o,validationId:n}){const i=(r??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],m=t?.changeAddresses??[a];return d.newIncreaseL1ValidatorBalanceTx({balance:o,validationId:n,utxos:g(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:s,fromAddressesBytes:i,memo:t?.memo,minIssuanceTime:t?.minIssuanceTime},this.provider.getContext())}addAutoRenewedValidator({utxoSet:e,nodeId:s,weight:t,shares:r,feeState:o,fromAddresses:n,rewardAddresses:i,delegatorRewardAddresses:a,ownerAddresses:m,publicKey:h,signature:g,autoCompoundRewardShares:u,period:c,options:p,locktime:l,threshold:x}){const T=A(e.getUTXOs()),I=(n??this.getAddresses("P")).map((e=>f(e)[2])),C=(i??[this.getCurrentAddress("P")]).map((e=>f(e)[2])),v=(a??[this.getCurrentAddress("P")]).map((e=>f(e)[2])),S=(m??[this.getCurrentAddress("P")]).map((e=>f(e)[2])),w=f(this.getChangeAddress("P"))[2],b=p?.changeAddresses??[w];return d.newAddAutoRenewedValidatorTx({fromAddressesBytes:I,delegatorRewardsOwner:v,utxos:T,minIssuanceTime:p?.minIssuanceTime,memo:p?.memo,changeAddressesBytes:b,nodeId:s,weight:t,shares:r,feeState:o,publicKey:h,rewardAddresses:C,signature:g,locktime:l,threshold:x,ownerAddresses:S,autoCompoundRewardShares:u,period:c},this.provider.getContext())}setAutoRenewedValidatorConfig({utxoSet:e,feeState:s,validatorTxId:t,auth:r,autoCompoundRewardShares:o,period:n,fromAddresses:i,options:a}){const m=(i??this.getAddresses("P")).map((e=>f(e)[2])),h=f(this.getChangeAddress("P"))[2],u=a?.changeAddresses??[h];return d.newSetAutoRenewedValidatorConfigTx({utxos:g(e.getUTXOs(),!0),changeAddressesBytes:u,feeState:s,fromAddressesBytes:m,memo:a?.memo,minIssuanceTime:a?.minIssuanceTime,validatorTxId:t,auth:r,autoCompoundRewardShares:o,period:n},this.provider.getContext())}createBlockchain({utxoSet:e,subnetId:s,chainName:t,vmID:r,fxIds:o,genesisData:n,subnetAuth:i,feeState:a,options:m,fromAddresses:h}){const u=g(e.getUTXOs(),!0),A=(h??this.getAddresses("P")).map((e=>f(e)[2])),c=f(this.getChangeAddress("P"))[2],l=m?.changeAddresses??[c];return p(a),d.newCreateChainTx({chainName:t,feeState:a,fromAddressesBytes:A,fxIds:o,genesisData:n,subnetAuth:i,subnetId:s,utxos:u,vmId:r,changeAddressesBytes:l},this.provider.getContext())}createSubnet({utxoSet:e,rewardAddresses:s,feeState:t,fromAddresses:r,options:o,threshold:n,locktime:i}){const a=g(e.getUTXOs(),!0),m=(r??this.getAddresses("P")).map((e=>f(e)[2])),h=f(this.getChangeAddress("P"))[2],u=o?.changeAddresses??[h],A=s.map((e=>f(e)[2]));return p(t),d.newCreateSubnetTx({fromAddressesBytes:m,changeAddressesBytes:u,utxos:a,minIssuanceTime:o?.minIssuanceTime,memo:o?.memo,feeState:t,threshold:n,locktime:i,subnetOwners:A},this.provider.getContext())}addSubnetValidator({utxoSet:e,nodeId:s,start:t,end:r,weight:o,subnetId:n,subnetAuth:i,feeState:a,fromAddresses:m,options:h}){const u=g(e.getUTXOs(),!0),A=(m??this.getAddresses("P")).map((e=>f(e)[2])),c=f(this.getChangeAddress("P"))[2],l=h?.changeAddresses??[c];return p(a),d.newAddSubnetValidatorTx({changeAddressesBytes:l,fromAddressesBytes:A,utxos:u,minIssuanceTime:h?.minIssuanceTime,memo:h?.memo,nodeId:s,start:t,end:r,weight:o,subnetId:n,subnetAuth:i,feeState:a},this.provider.getContext())}addPermissionlessValidator({utxoSet:e,nodeId:s,start:t,end:r,weight:o,subnetId:n,shares:i,feeState:a,fromAddresses:h,rewardAddresses:g,delegatorRewardAddresses:u,publicKey:c,signature:l,options:x,threshold:T,locktime:I,stakingAssetId:C}){const v=A(e.getUTXOs()),S=(h??this.getAddresses("P")).map((e=>f(e)[2])),w=(g??[this.getCurrentAddress("P")]).map((e=>f(e)[2])),b=(u??[this.getCurrentAddress("P")]).map((e=>f(e)[2]));if(!(n!==m.PrimaryNetworkID.toString()||c&&l))throw new Error("Must provide public key and signature for primary subnet.");const P=f(this.getChangeAddress("P"))[2],B=x?.changeAddresses??[P];return p(a),d.newAddPermissionlessValidatorTx({fromAddressesBytes:S,delegatorRewardsOwner:b,utxos:v,minIssuanceTime:x?.minIssuanceTime,memo:x?.memo,changeAddressesBytes:B,nodeId:s,start:t,end:r,weight:o,subnetId:n,shares:i,feeState:a,publicKey:c,rewardAddresses:w,signature:l,locktime:I,threshold:T,stakingAssetId:C},this.provider.getContext())}addPermissionlessDelegator({utxoSet:e,nodeId:s,start:t,end:r,weight:o,subnetId:n,fromAddresses:i,rewardAddresses:a,options:m,locktime:h,feeState:g,threshold:u,stakingAssetId:c}){const l=A(e.getUTXOs()),x=(i??this.getAddresses("P")).map((e=>f(e)[2])),T=(a??[this.getCurrentAddress("P")]).map((e=>f(e)[2])),I=f(this.getChangeAddress("P"))[2],C=m?.changeAddresses??[I];return p(g),d.newAddPermissionlessDelegatorTx({fromAddressesBytes:x,utxos:l,minIssuanceTime:m?.minIssuanceTime,memo:m?.memo,changeAddressesBytes:C,nodeId:s,start:t,end:r,weight:o,subnetId:n,rewardAddresses:T,locktime:h,stakingAssetId:c,threshold:u,feeState:g},this.provider.getContext())}removeSubnetValidator({utxoSet:e,nodeId:s,subnetId:t,subnetAuth:r,fromAddresses:o,feeState:n,options:i}){const a=g(e.getUTXOs(),!0),m=(o??this.getAddresses("P")).map((e=>f(e)[2])),h=f(this.getChangeAddress("P"))[2],u=i?.changeAddresses??[h];return p(n),d.newRemoveSubnetValidatorTx({changeAddressesBytes:u,fromAddressesBytes:m,utxos:a,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,nodeId:s,subnetId:t,subnetAuth:r,feeState:n},this.provider.getContext())}transferSubnetOwnershipTx({utxoSet:e,subnetId:s,subnetAuth:t,subnetOwners:r,feeState:o,fromAddresses:n,options:i,threshold:a,locktime:m}){const h=g(e.getUTXOs(),!0),u=(n??this.getAddresses("P")).map((e=>f(e)[2])),A=f(this.getChangeAddress("P"))[2],c=i?.changeAddresses??[A],l=r.map((e=>f(e)[2]));return p(o),d.newTransferSubnetOwnershipTx({changeAddressesBytes:c,fromAddressesBytes:u,utxos:h,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,subnetId:s,subnetAuth:t,subnetOwners:l,feeState:o,threshold:a,locktime:m},this.provider.getContext())}}export{x as WalletAbstract};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MnemonicWalletVoid as e}from"./MnemonicWalletVoid.js";import{utils as t,addTxSignatures as r}from"@avalabs/avalanchejs";import{validateMnemonic as i,mnemonicToSeedSync as n}from"bip39";import{fromBase58 as o,fromSeed as s}from"bip32";import"@ledgerhq/hw-app-eth";import{SigningKey as a}from"ethers";import{DerivationPath as p}from"../../../EVM/constants.js";import"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";import{getAddressDerivationPath as c}from"../../../utils/getAddressDerivationPath.js";import"hdkey";const{strip0x:h}=t;class
|
|
1
|
+
import{MnemonicWalletVoid as e}from"./MnemonicWalletVoid.js";import{utils as t,addTxSignatures as r}from"@avalabs/avalanchejs";import{validateMnemonic as i,mnemonicToSeedSync as n}from"bip39";import{fromBase58 as o,fromSeed as s}from"bip32";import"@ledgerhq/hw-app-eth";import{SigningKey as a}from"ethers";import{DerivationPath as p}from"../../../EVM/constants.js";import"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";import{getAddressDerivationPath as c}from"../../../utils/getAddressDerivationPath.js";import"hdkey";const{strip0x:h}=t;class m extends e{constructor(e,t,r){const i=o(e).neutered(),n=new a(t),s=Buffer.from(h(n.compressedPublicKey),"hex");super(i.toBase58(),s,r),this.evmPrivKey=t,this.accountNode=o(e)}accountNode;static fromMnemonic(e,t){if(!i(e))throw new Error("Invalid mnemonic phrase.");const r=n(e),o=s(r),a=o.derivePath("m/44'/9000'/0'"),h=o.derivePath(c(0,"EVM",{pathSpec:p.BIP44}));if(!h.privateKey)throw new Error("Unable to derive EVM private key.");return new m(a.toBase58(),h.privateKey,t)}async signTx(e){const t=this.getSigningKeys(e);return await r({unsignedTx:e.tx,privateKeys:t}),e.tx}getExternalPrivateKeys(e){const t=[];for(let e=0;e<=this.externalIndex;e++){const r=this.accountNode.derivePath(`0/${e}`);if(!r.privateKey)throw new Error("Unable to get private key.");t.push(r.privateKey)}const r=(e??[]).reduce(((e,t)=>{if(t>this.externalIndex){const r=this.accountNode.derivePath(`0/${t}`);if(!r.privateKey)throw new Error("Unable to get private key.");e.push(r.privateKey)}return e}),[]);return[...t,...r]}getInternalPrivateKeys(e){const t=[];for(let e=0;e<=this.internalIndex;e++){const r=this.accountNode.derivePath(`1/${e}`);if(!r.privateKey)throw new Error("Unable to get private key.");t.push(r.privateKey)}const r=(e??[]).reduce(((e,t)=>{if(t>this.internalIndex){const r=this.accountNode.derivePath(`1/${t}`);if(!r.privateKey)throw new Error("Unable to get private key.");e.push(r.privateKey)}return e}),[]);return[...t,...r]}getSigningKeys(e){const{tx:t,externalIndices:r,internalIndices:i}=e;return"EVM"===t.getVM()?[this.evmPrivKey]:[...this.getInternalPrivateKeys(i),...this.getExternalPrivateKeys(r)]}async signTxBuffer(e){throw new Error("not implemented")}async signMessage(e){throw new Error("not implemented")}}export{m as MnemonicWallet};
|
package/esm/BitcoinVM/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{networks as a}from"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import"coinselect";import"@ledgerhq/hw-app-eth";import"ethers";import"bip32";import"bip39";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";import"ledger-bitcoin";import"@ledgerhq/hw-app-btc/lib/bip32";import"../Avalanche/wallets/WalletAbstract.js";import"../Avalanche/utils/addSignaturesToAvalancheTx.js";import"../Avalanche/utils/convertGlacierUtxo.js";import"../Avalanche/utils/createAvalancheEvmUnsignedTx.js";import"../Avalanche/utils/createAvalancheUnsignedTx.js";import"create-hash";import"@avalabs/avalanchejs";import"../Avalanche/utils/getAssetBalance.js";import"../Avalanche/utils/getUtxosByTxFromGlacier.js";import"../Avalanche/utils/parseAvalancheTx.js";import"../Avalanche/utils/populateCredential.js";import"../Avalanche/utils/txSizeLimits.js";import"bip32-path";import"@avalabs/hw-app-avalanche";import"../Avalanche/wallets/legacy/MnemonicWalletVoid.js";import"../Avalanche/wallets/legacy/LedgerWallet.js";import"../Avalanche/wallets/legacy/MnemonicWallet.js";import"../Avalanche/wallets/StaticSigner.js";import"../Avalanche/wallets/ledger/LedgerSigner.js";import"../Avalanche/wallets/ledger/SimpleLedgerSigner.js";import"../Avalanche/providers/AbstractProvider.js";import"../Avalanche/providers/constants.js";import"@avalabs/core-chains-sdk";import"@solana/kit";import"@solana-program/system";import"@solana-program/token";import"@ledgerhq/hw-app-solana";import"@noble/curves/ed25519";import"@scure/base";import"micro-key-producer/slip10.js";import"hdkey";const e=a;export{e as BtcNetworks};
|
|
1
|
+
import{networks as a}from"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import"coinselect";import"@ledgerhq/hw-app-eth";import"ethers";import"bip32";import"bip39";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";import"ledger-bitcoin";import"@ledgerhq/hw-app-btc/lib/bip32";import"../Avalanche/wallets/WalletAbstract.js";import"../Avalanche/utils/addSignaturesToAvalancheTx.js";import"../Avalanche/utils/convertGlacierUtxo.js";import"../Avalanche/utils/createAvalancheEvmUnsignedTx.js";import"../Avalanche/utils/createAvalancheUnsignedTx.js";import"create-hash";import"@avalabs/avalanchejs";import"../Avalanche/utils/getAssetBalance.js";import"../Avalanche/utils/getUtxosByTxFromGlacier.js";import"../Avalanche/utils/parseAvalancheTx.js";import"../Avalanche/utils/populateCredential.js";import"../Avalanche/utils/txSizeLimits.js";import"bip32-path";import"@avalabs/hw-app-avalanche";import"../Avalanche/wallets/legacy/MnemonicWalletVoid.js";import"../Avalanche/wallets/legacy/LedgerWallet.js";import"../Avalanche/wallets/legacy/MnemonicWallet.js";import"../Avalanche/wallets/StaticSigner.js";import"../Avalanche/wallets/ledger/LedgerSigner.js";import"../Avalanche/wallets/ledger/SimpleLedgerSigner.js";import"../Avalanche/providers/AbstractProvider.js";import"../Avalanche/providers/constants.js";import"@avalabs/core-chains-sdk";import"@solana/kit";import"@solana-program/system";import"@solana-program/token";import"@solana-program/token-2022";import"@ledgerhq/hw-app-solana";import"@noble/curves/ed25519";import"@scure/base";import"micro-key-producer/slip10.js";import"hdkey";const e=a;export{e as BtcNetworks};
|