@avalabs/core-wallets-sdk
Advanced tools
Comparing version
@@ -1,2 +0,2 @@ | ||
export { AddDelegatorTx, AddPermissionlessDelegatorTx, AddPermissionlessValidatorTx, AddSubnetValidatorTx, AddValidatorTx, BaseTx, ChainIDAlias, CreateChainTx, CreateSubnetTx, ExportTx, FeeData, ImportTx, RemoveSubnetValidatorTx, TransferSubnetOwnershipTx, TransformSubnetTx, Tx, TxBase, TxType, UnknownTx, isAddDelegatorTx, isAddPermissionlessDelegatorTx, isAddPermissionlessValidatorTx, isAddSubnetValidatorTx, isAddValidatorTx, isBaseTx, isCreateChainTx, isCreateSubnetTx, isExportTx, isImportTx, isRemoveSubnetValidatorTx, isTransferSubnetOwnershipTx, isTransformSubnetTx } from './models.js'; | ||
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'; | ||
export { WalletAbstract } from './wallets/WalletAbstract.js'; | ||
@@ -17,3 +17,3 @@ export { WalletVoid } from './wallets/WalletVoid.js'; | ||
export { JsonRpcProvider } from './providers/JsonRpcProvider.js'; | ||
export { FujiContext, MainnetContext } from './providers/constants.js'; | ||
export { DevnetContext, FujiContext, MainnetContext } from './providers/constants.js'; | ||
export { default as addSignaturesToAvalancheTx } from './utils/addSignaturesToAvalancheTx.js'; | ||
@@ -32,3 +32,2 @@ export { GlacierOutput, convertGlacierUtxo } from './utils/convertGlacierUtxo.js'; | ||
export { getUnixNow } from './utils/getUnixNow.js'; | ||
export { UtxoInfo, getUtxoInfo } from './utils/getUtxoInfo.js'; | ||
export { getUtxosByTxFromGlacier } from './utils/getUtxosByTxFromGlacier.js'; | ||
@@ -35,0 +34,0 @@ export { getVmByChainAlias } from './utils/getVmByChainAlias.js'; |
@@ -1,1 +0,1 @@ | ||
export{TxType,isAddDelegatorTx,isAddPermissionlessDelegatorTx,isAddPermissionlessValidatorTx,isAddSubnetValidatorTx,isAddValidatorTx,isBaseTx,isCreateChainTx,isCreateSubnetTx,isExportTx,isImportTx,isRemoveSubnetValidatorTx,isTransferSubnetOwnershipTx,isTransformSubnetTx}from"./models.js";export{WalletAbstract}from"./wallets/WalletAbstract.js";export{WalletVoid}from"./wallets/WalletVoid.js";export{isObsidianApp}from"./wallets/ledger/isObsidianApp.js";export{getLedgerProvider}from"./wallets/ledger/getLedgerProvider.js";export{AddressWallet}from"./wallets/AddressWallet.js";export{MnemonicWalletVoid}from"./wallets/legacy/MnemonicWalletVoid.js";export{LedgerWallet}from"./wallets/legacy/LedgerWallet.js";export{MnemonicWallet}from"./wallets/legacy/MnemonicWallet.js";export{StaticSigner}from"./wallets/StaticSigner.js";export{SimpleSigner}from"./wallets/SimpleSigner.js";export{LedgerSigner}from"./wallets/ledger/LedgerSigner.js";export{SimpleLedgerSigner}from"./wallets/ledger/SimpleLedgerSigner.js";export{AbstractProvider}from"./providers/AbstractProvider.js";export{JsonRpcProvider}from"./providers/JsonRpcProvider.js";export{FujiContext,MainnetContext}from"./providers/constants.js";export{addSignaturesToAvalancheTx}from"./utils/addSignaturesToAvalancheTx.js";export{convertGlacierUtxo}from"./utils/convertGlacierUtxo.js";export{createAvalancheEvmUnsignedTx}from"./utils/createAvalancheEvmUnsignedTx.js";export{createAvalancheUnsignedTx}from"./utils/createAvalancheUnsignedTx.js";export{digestMessage}from"./utils/digestMessage.js";export{getAddressFromXpub}from"./utils/getAddressFromXpub.js";export{getAddressPublicKeyFromXpub}from"./utils/getAddressPublicKeyFromXpub.js";export{getPaginatedUTXOs,getUTXOsForAddresses}from"./utils/getAllUTXOs.js";export{getAssetBalance}from"./utils/getAssetBalance.js";export{getPchainUnixNow}from"./utils/getPchainUnixNow.js";export{getStakedAssetBalance}from"./utils/getStakedAssetBalance.js";export{getStakeForAddresses}from"./utils/getStakeForAddresses.js";export{getUnixNow}from"./utils/getUnixNow.js";export{getUtxoInfo}from"./utils/getUtxoInfo.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{TxType,isAddDelegatorTx,isAddPermissionlessDelegatorTx,isAddPermissionlessValidatorTx,isAddSubnetValidatorTx,isAddValidatorTx,isBaseTx,isConvertSubnetToL1Tx,isCreateChainTx,isCreateSubnetTx,isDisableL1ValidatorTx,isExportTx,isImportTx,isIncreaseL1ValidatorBalance,isRegisterL1ValidatorTx,isRemoveSubnetValidatorTx,isSetL1ValidatorWeightTx,isTransferSubnetOwnershipTx,isTransformSubnetTx}from"./models.js";export{WalletAbstract}from"./wallets/WalletAbstract.js";export{WalletVoid}from"./wallets/WalletVoid.js";export{isObsidianApp}from"./wallets/ledger/isObsidianApp.js";export{getLedgerProvider}from"./wallets/ledger/getLedgerProvider.js";export{AddressWallet}from"./wallets/AddressWallet.js";export{MnemonicWalletVoid}from"./wallets/legacy/MnemonicWalletVoid.js";export{LedgerWallet}from"./wallets/legacy/LedgerWallet.js";export{MnemonicWallet}from"./wallets/legacy/MnemonicWallet.js";export{StaticSigner}from"./wallets/StaticSigner.js";export{SimpleSigner}from"./wallets/SimpleSigner.js";export{LedgerSigner}from"./wallets/ledger/LedgerSigner.js";export{SimpleLedgerSigner}from"./wallets/ledger/SimpleLedgerSigner.js";export{AbstractProvider}from"./providers/AbstractProvider.js";export{JsonRpcProvider}from"./providers/JsonRpcProvider.js";export{DevnetContext,FujiContext,MainnetContext}from"./providers/constants.js";export{addSignaturesToAvalancheTx}from"./utils/addSignaturesToAvalancheTx.js";export{convertGlacierUtxo}from"./utils/convertGlacierUtxo.js";export{createAvalancheEvmUnsignedTx}from"./utils/createAvalancheEvmUnsignedTx.js";export{createAvalancheUnsignedTx}from"./utils/createAvalancheUnsignedTx.js";export{digestMessage}from"./utils/digestMessage.js";export{getAddressFromXpub}from"./utils/getAddressFromXpub.js";export{getAddressPublicKeyFromXpub}from"./utils/getAddressPublicKeyFromXpub.js";export{getPaginatedUTXOs,getUTXOsForAddresses}from"./utils/getAllUTXOs.js";export{getAssetBalance}from"./utils/getAssetBalance.js";export{getPchainUnixNow}from"./utils/getPchainUnixNow.js";export{getStakedAssetBalance}from"./utils/getStakedAssetBalance.js";export{getStakeForAddresses}from"./utils/getStakeForAddresses.js";export{getUnixNow}from"./utils/getUnixNow.js";export{getUtxosByTxFromGlacier}from"./utils/getUtxosByTxFromGlacier.js";export{getVmByChainAlias}from"./utils/getVmByChainAlias.js";export{getXpubFromMnemonic}from"./utils/getXpubFromMnemonic.js";export{isBech32Address}from"./utils/isBech32Address.js";export{parseAvalancheTx}from"./utils/parseAvalancheTx.js";export{emptySignature,populateCredential}from"./utils/populateCredential.js";export{signedTxToHex}from"./utils/signedTxToHex.js";export{sortUTXOsByAmount,sortUTXOsByAmountAscending,sortUTXOsByAmountDescending,sortUTXOsStaking}from"./utils/sortUTXOs.js";export{P_CHAIN_TX_SIZE_LIMIT,SizeSupportedTx,getMaximumUtxoSet}from"./utils/txSizeLimits.js";export{verifyDerivationPath}from"./utils/verifyDerivationPath.js"; |
@@ -7,3 +7,3 @@ import { VM, Common, OutputOwners, TransferableOutput, pvmSerial } from '@avalabs/avalanchejs'; | ||
*/ | ||
type Tx = AddValidatorTx | AddDelegatorTx | ExportTx | ImportTx | BaseTx | CreateSubnetTx | CreateChainTx | AddSubnetValidatorTx | RemoveSubnetValidatorTx | AddPermissionlessValidatorTx | AddPermissionlessDelegatorTx | TransformSubnetTx | TransferSubnetOwnershipTx | UnknownTx; | ||
type Tx = AddValidatorTx | AddDelegatorTx | ExportTx | ImportTx | BaseTx | CreateSubnetTx | CreateChainTx | AddSubnetValidatorTx | RemoveSubnetValidatorTx | AddPermissionlessValidatorTx | AddPermissionlessDelegatorTx | TransformSubnetTx | TransferSubnetOwnershipTx | ConvertSubnetToL1Tx | RegisterL1ValidatorTx | SetL1ValidatorWeightTx | DisableL1ValidatorTx | IncreaseL1ValidatorBalanceTx | UnknownTx; | ||
interface FeeData { | ||
@@ -28,2 +28,7 @@ totalAvaxBurned: bigint; | ||
CreateChain = "create_chain", | ||
ConvertSubnetToL1 = "convert_subnet_to_l1", | ||
RegisterL1Validator = "register_l1_validator", | ||
SetL1ValidatorWeight = "set_l1_validator_weight", | ||
IncreaseL1ValidatorBalance = "increase_l1_validator_balance", | ||
DisableL1Validator = "disable_l1_validator", | ||
AddSubnetValidator = "add_subnet_validator", | ||
@@ -107,2 +112,31 @@ RemoveSubnetValidator = "remove_subnet_validator", | ||
} | ||
interface ConvertSubnetToL1Tx extends TxBase { | ||
type: TxType.ConvertSubnetToL1; | ||
managerAddress: string; | ||
validators: { | ||
nodeId: string; | ||
stake: bigint; | ||
balance: bigint; | ||
remainingBalanceOwners: string[]; | ||
deactivationOwners: string[]; | ||
}[]; | ||
subnetID: string; | ||
chainID: string; | ||
} | ||
interface RegisterL1ValidatorTx extends TxBase { | ||
type: TxType.RegisterL1Validator; | ||
balance: bigint; | ||
} | ||
interface SetL1ValidatorWeightTx extends TxBase { | ||
type: TxType.SetL1ValidatorWeight; | ||
} | ||
interface IncreaseL1ValidatorBalanceTx extends TxBase { | ||
type: TxType.IncreaseL1ValidatorBalance; | ||
balance: bigint; | ||
validationId: string; | ||
} | ||
interface DisableL1ValidatorTx extends TxBase { | ||
type: TxType.DisableL1Validator; | ||
validationId: string; | ||
} | ||
interface AddPermissionlessValidatorTx extends TxBase { | ||
@@ -146,3 +180,3 @@ type: TxType.AddPermissionlessValidator; | ||
minDelegationFee: number; | ||
minDelegatorStake: number; | ||
minDelegatorStake: bigint; | ||
maxValidatorWeightFactor: number; | ||
@@ -168,2 +202,7 @@ uptimeRequirement: number; | ||
declare function isBaseTx(tx: Tx): tx is BaseTx; | ||
declare function isConvertSubnetToL1Tx(tx: Tx): tx is ConvertSubnetToL1Tx; | ||
declare function isRegisterL1ValidatorTx(tx: Tx): tx is RegisterL1ValidatorTx; | ||
declare function isSetL1ValidatorWeightTx(tx: Tx): tx is SetL1ValidatorWeightTx; | ||
declare function isDisableL1ValidatorTx(tx: Tx): tx is DisableL1ValidatorTx; | ||
declare function isIncreaseL1ValidatorBalance(tx: Tx): tx is IncreaseL1ValidatorBalanceTx; | ||
declare function isCreateSubnetTx(tx: Tx): tx is CreateSubnetTx; | ||
@@ -178,2 +217,2 @@ declare function isCreateChainTx(tx: Tx): tx is CreateChainTx; | ||
export { AddDelegatorTx, AddPermissionlessDelegatorTx, AddPermissionlessValidatorTx, AddSubnetValidatorTx, AddValidatorTx, BaseTx, ChainIDAlias, CreateChainTx, CreateSubnetTx, ExportTx, FeeData, ImportTx, RemoveSubnetValidatorTx, TransferSubnetOwnershipTx, TransformSubnetTx, Tx, TxBase, TxType, UnknownTx, isAddDelegatorTx, isAddPermissionlessDelegatorTx, isAddPermissionlessValidatorTx, isAddSubnetValidatorTx, isAddValidatorTx, isBaseTx, isCreateChainTx, isCreateSubnetTx, isExportTx, isImportTx, isRemoveSubnetValidatorTx, isTransferSubnetOwnershipTx, isTransformSubnetTx }; | ||
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 }; |
@@ -1,1 +0,1 @@ | ||
var e=(e=>(e.Base="base",e.AddValidator="add_validator",e.AddDelegator="add_delegator",e.Export="export",e.Import="import",e.CreateSubnet="create_subnet",e.CreateChain="create_chain",e.AddSubnetValidator="add_subnet_validator",e.RemoveSubnetValidator="remove_subnet_validator",e.AddPermissionlessValidator="add_permissionless_validator",e.AddPermissionlessDelegator="add_permissionless_delegator",e.TransformSubnet="transform_subnet",e.TransferSubnetOwnership="transfer_subnet_ownership",e.Unknown="unknown",e))(e||{});function t(e){return"add_validator"===e.type}function r(e){return"add_delegator"===e.type}function n(e){return"export"===e.type}function a(e){return"import"===e.type}function o(e){return"base"===e.type}function d(e){return"create_subnet"===e.type}function s(e){return"create_chain"===e.type}function i(e){return"add_subnet_validator"===e.type}function u(e){return"remove_subnet_validator"===e.type}function _(e){return"add_permissionless_validator"===e.type}function p(e){return"add_permissionless_delegator"===e.type}function l(e){return"transform_subnet"===e.type}function c(e){return"transfer_subnet_ownership"===e.type}export{e as TxType,r as isAddDelegatorTx,p as isAddPermissionlessDelegatorTx,_ as isAddPermissionlessValidatorTx,i as isAddSubnetValidatorTx,t as isAddValidatorTx,o as isBaseTx,s as isCreateChainTx,d as isCreateSubnetTx,n as isExportTx,a as isImportTx,u as isRemoveSubnetValidatorTx,c as isTransferSubnetOwnershipTx,l as isTransformSubnetTx}; | ||
var e=(e=>(e.Base="base",e.AddValidator="add_validator",e.AddDelegator="add_delegator",e.Export="export",e.Import="import",e.CreateSubnet="create_subnet",e.CreateChain="create_chain",e.ConvertSubnetToL1="convert_subnet_to_l1",e.RegisterL1Validator="register_l1_validator",e.SetL1ValidatorWeight="set_l1_validator_weight",e.IncreaseL1ValidatorBalance="increase_l1_validator_balance",e.DisableL1Validator="disable_l1_validator",e.AddSubnetValidator="add_subnet_validator",e.RemoveSubnetValidator="remove_subnet_validator",e.AddPermissionlessValidator="add_permissionless_validator",e.AddPermissionlessDelegator="add_permissionless_delegator",e.TransformSubnet="transform_subnet",e.TransferSubnetOwnership="transfer_subnet_ownership",e.Unknown="unknown",e))(e||{});function t(e){return"add_validator"===e.type}function r(e){return"add_delegator"===e.type}function n(e){return"export"===e.type}function a(e){return"import"===e.type}function o(e){return"base"===e.type}function i(e){return"convert_subnet_to_l1"===e.type}function d(e){return"register_l1_validator"===e.type}function s(e){return"set_l1_validator_weight"===e.type}function _(e){return"disable_l1_validator"===e.type}function u(e){return"increase_l1_validator_balance"===e.type}function l(e){return"create_subnet"===e.type}function c(e){return"create_chain"===e.type}function p(e){return"add_subnet_validator"===e.type}function b(e){return"remove_subnet_validator"===e.type}function f(e){return"add_permissionless_validator"===e.type}function v(e){return"add_permissionless_delegator"===e.type}function y(e){return"transform_subnet"===e.type}function m(e){return"transfer_subnet_ownership"===e.type}export{e as TxType,r as isAddDelegatorTx,v as isAddPermissionlessDelegatorTx,f as isAddPermissionlessValidatorTx,p as isAddSubnetValidatorTx,t as isAddValidatorTx,o as isBaseTx,i as isConvertSubnetToL1Tx,c as isCreateChainTx,l as isCreateSubnetTx,_ as isDisableL1ValidatorTx,n as isExportTx,a as isImportTx,u as isIncreaseL1ValidatorBalance,d as isRegisterL1ValidatorTx,b as isRemoveSubnetValidatorTx,s as isSetL1ValidatorWeightTx,m as isTransferSubnetOwnershipTx,y as isTransformSubnetTx}; |
import * as _avalabs_avalanchejs_dist_vms_common from '@avalabs/avalanchejs/dist/vms/common'; | ||
import * as ethers from 'ethers'; | ||
import { JsonRpcProvider } from 'ethers'; | ||
import { Context, avm, pvm, evm, Info, VM, avaxSerial } from '@avalabs/avalanchejs'; | ||
import { Context, avm, pvm, evm, info, VM, avaxSerial } from '@avalabs/avalanchejs'; | ||
import { ChainIDAlias } from '../models.js'; | ||
import { GetUpgradesInfoResponse } from '@avalabs/avalanchejs/dist/info/model'; | ||
@@ -11,5 +10,4 @@ declare class AbstractProvider { | ||
protected context: Context.Context; | ||
protected upgradesInfo?: GetUpgradesInfoResponse | undefined; | ||
evmRpc: JsonRpcProvider; | ||
constructor(baseUrl: string, context: Context.Context, upgradesInfo?: GetUpgradesInfoResponse | undefined); | ||
constructor(baseUrl: string, context: Context.Context); | ||
/** | ||
@@ -20,4 +18,2 @@ * @link https://docs.ethers.io/v5/api/providers/provider/#Provider-getFeeData | ||
getContext(): Context.Context; | ||
isEtnaEnabled(): boolean; | ||
getUpgradesInfo(): GetUpgradesInfoResponse | undefined; | ||
getChainID(chainAlias: ChainIDAlias): string; | ||
@@ -29,3 +25,3 @@ getNetworkID(): number; | ||
getApiC(): evm.EVMApi; | ||
getInfo(): Info; | ||
getInfo(): info.InfoApi; | ||
getApi(chain: ChainIDAlias): avm.AVMApi | pvm.PVMApi | evm.EVMApi; | ||
@@ -32,0 +28,0 @@ getAvaxID(): string; |
@@ -1,1 +0,1 @@ | ||
import{utils as t,networkIDs as e,avm as s,pvm as r,evm as i,Info as n,secp256k1 as c}from"@avalabs/avalanchejs";import{strip0x as a}from"@avalabs/core-utils-sdk";import{signedTxToHex as o}from"../utils/signedTxToHex.js";import{JsonRpcProvider as u,SigningKey as h}from"ethers";const{parseBech32:p,format:g}=t,{publicKeyBytesToAddress:x}=c;class A{constructor(t,e,s){this.baseUrl=t,this.context=e,this.upgradesInfo=s;const r=`${t}/ext/bc/C/rpc`;this.evmRpc=new u(r)}evmRpc;async getEvmFeeData(){return this.evmRpc.getFeeData()}getContext(){return this.context}isEtnaEnabled(){return!!this.upgradesInfo&&t.isEtnaEnabled(this.upgradesInfo)}getUpgradesInfo(){return this.upgradesInfo}getChainID(t){switch(t){case"X":return this.context.xBlockchainID;case"P":return this.context.pBlockchainID;case"C":return this.context.cBlockchainID}}getNetworkID(){return this.context.networkID}getHrp(){return e.getHRP(this.getNetworkID())}getApiX(){return new s.AVMApi(this.baseUrl)}getApiP(){return new r.PVMApi(this.baseUrl)}getApiC(){return new i.EVMApi(this.baseUrl)}getInfo(){return new n(this.baseUrl)}getApi(t){switch(t){case"X":return this.getApiX();case"P":return this.getApiP();case"C":return this.getApiC()}}getAvaxID(){return this.getContext().avaxAssetID}getAddress(t,e){const s=a(h.computePublicKey(t,!0)),r=Buffer.from(s,"hex"),i=x(r);return g(e,this.getHrp(),i)}getAddressFromBuffer(t,e){return g(e,this.getHrp(),t)}formatAddress(t,e){const[,s]=p(t);return g(e,this.getHrp(),s)}getApiByVM(t){switch(t){case"AVM":return this.getApiX();case"PVM":return this.getApiP();case"EVM":return this.getApiC()}}getApiByChainID(t){switch(t){case this.context.xBlockchainID:return this.getApiX();case this.context.pBlockchainID:return this.getApiP();case this.context.cBlockchainID:return this.getApiC()}}async issueTx(t){const e=t.unsignedTx.getVM(),s=o(t);return this.issueTxHex(s,e)}async issueTxHex(t,e){return this.getApiByVM(e).issueTx({tx:t})}async waitForTransaction(t,e,s=6e4){const r=this.getApiByVM(e),n=Date.now();return new Promise(((e,c)=>{const a=async()=>{let o;switch(s&&n+s<Date.now()&&c(new Error("Timeout")),o=r instanceof i.EVMApi?await r.getAtomicTxStatus(t):await r.getTxStatus({txID:t,includeReason:!0}),o.status){case"Accepted":case"Committed":return void e({success:!0});case"Dropped":case"Rejected":return void e({success:!1});default:setTimeout((()=>{a()}),1e3)}};a()}))}}export{A as AbstractProvider}; | ||
import{networkIDs as t,avm as e,pvm as s,evm as r,info as i,utils as n,secp256k1 as c}from"@avalabs/avalanchejs";import{strip0x as a}from"@avalabs/core-utils-sdk";import{signedTxToHex as o}from"../utils/signedTxToHex.js";import{JsonRpcProvider as u,SigningKey as h}from"ethers";const{parseBech32:p,format:g}=n,{publicKeyBytesToAddress:A}=c;class x{constructor(t,e){this.baseUrl=t,this.context=e;const s=`${t}/ext/bc/C/rpc`;this.evmRpc=new u(s)}evmRpc;async getEvmFeeData(){return this.evmRpc.getFeeData()}getContext(){return this.context}getChainID(t){switch(t){case"X":return this.context.xBlockchainID;case"P":return this.context.pBlockchainID;case"C":return this.context.cBlockchainID}}getNetworkID(){return this.context.networkID}getHrp(){return t.getHRP(this.getNetworkID())}getApiX(){return new e.AVMApi(this.baseUrl)}getApiP(){return new s.PVMApi(this.baseUrl)}getApiC(){return new r.EVMApi(this.baseUrl)}getInfo(){return new i.InfoApi(this.baseUrl)}getApi(t){switch(t){case"X":return this.getApiX();case"P":return this.getApiP();case"C":return this.getApiC()}}getAvaxID(){return this.getContext().avaxAssetID}getAddress(t,e){const s=a(h.computePublicKey(t,!0)),r=Buffer.from(s,"hex"),i=A(r);return g(e,this.getHrp(),i)}getAddressFromBuffer(t,e){return g(e,this.getHrp(),t)}formatAddress(t,e){const[,s]=p(t);return g(e,this.getHrp(),s)}getApiByVM(t){switch(t){case"AVM":return this.getApiX();case"PVM":return this.getApiP();case"EVM":return this.getApiC()}}getApiByChainID(t){switch(t){case this.context.xBlockchainID:return this.getApiX();case this.context.pBlockchainID:return this.getApiP();case this.context.cBlockchainID:return this.getApiC()}}async issueTx(t){const e=t.unsignedTx.getVM(),s=o(t);return this.issueTxHex(s,e)}async issueTxHex(t,e){return this.getApiByVM(e).issueTx({tx:t})}async waitForTransaction(t,e,s=6e4){const i=this.getApiByVM(e),n=Date.now();return new Promise(((e,c)=>{const a=async()=>{let o;switch(s&&n+s<Date.now()&&c(new Error("Timeout")),o=i instanceof r.EVMApi?await i.getAtomicTxStatus(t):await i.getTxStatus({txID:t,includeReason:!0}),o.status){case"Accepted":case"Committed":return void e({success:!0});case"Dropped":case"Rejected":return void e({success:!1});default:setTimeout((()=>{a()}),1e3)}};a()}))}}export{x as AbstractProvider}; |
@@ -11,3 +11,4 @@ import { Context } from '@avalabs/avalanchejs'; | ||
declare const FujiContext: Context.Context; | ||
declare const DevnetContext: Context.Context; | ||
export { FujiContext, MainnetContext }; | ||
export { DevnetContext, FujiContext, MainnetContext }; |
@@ -1,1 +0,1 @@ | ||
import{platformFeeConfig as e}from"./platformFeeConfig.js";const t={xBlockchainID:"2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM",pBlockchainID:"11111111111111111111111111111111LpoYY",cBlockchainID:"2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5",avaxAssetID:"FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z",baseTxFee:BigInt(1e6),createAssetTxFee:BigInt(1e7),createSubnetTxFee:BigInt(1e9),transformSubnetTxFee:BigInt(1e10),createBlockchainTxFee:BigInt(1e9),addPrimaryNetworkValidatorFee:BigInt(0),addPrimaryNetworkDelegatorFee:BigInt(0),addSubnetValidatorFee:BigInt(1e6),addSubnetDelegatorFee:BigInt(1e6),networkID:1,hrp:"avax",platformFeeConfig:e},a={xBlockchainID:"2JVSBoinj9C2J33VntvzYtVJNZdN2NKiwwKjcumHUWEb5DbBrm",pBlockchainID:"11111111111111111111111111111111LpoYY",cBlockchainID:"yH8D7ThNJkxmtkuv2jgBa4P1Rn3Qpr4pPr7QYNfcdoS6k6HWp",avaxAssetID:"U8iRqJoiJm8xZHAacmvYyZVwqQx6uDNtQeP3CQ6fcgQk3JqnK",baseTxFee:BigInt(1e6),createAssetTxFee:BigInt(1e7),createSubnetTxFee:BigInt(1e8),transformSubnetTxFee:BigInt(1e9),createBlockchainTxFee:BigInt(1e8),addPrimaryNetworkValidatorFee:BigInt(0),addPrimaryNetworkDelegatorFee:BigInt(0),addSubnetValidatorFee:BigInt(1e6),addSubnetDelegatorFee:BigInt(1e6),networkID:5,hrp:"fuji",platformFeeConfig:e};export{a as FujiContext,t as MainnetContext}; | ||
import{platformFeeConfig as e}from"./platformFeeConfig.js";const o={xBlockchainID:"2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM",pBlockchainID:"11111111111111111111111111111111LpoYY",cBlockchainID:"2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5",avaxAssetID:"FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z",baseTxFee:BigInt(1e6),createAssetTxFee:BigInt(1e7),networkID:1,hrp:"avax",platformFeeConfig:e},c={xBlockchainID:"2JVSBoinj9C2J33VntvzYtVJNZdN2NKiwwKjcumHUWEb5DbBrm",pBlockchainID:"11111111111111111111111111111111LpoYY",cBlockchainID:"yH8D7ThNJkxmtkuv2jgBa4P1Rn3Qpr4pPr7QYNfcdoS6k6HWp",avaxAssetID:"U8iRqJoiJm8xZHAacmvYyZVwqQx6uDNtQeP3CQ6fcgQk3JqnK",baseTxFee:BigInt(1e6),createAssetTxFee:BigInt(1e7),networkID:5,hrp:"fuji",platformFeeConfig:e},n={xBlockchainID:"2piQ2AVHCjnduiWXsSY15DtbVuwHE2cwMHYnEXHsLL73BBkdbV",pBlockchainID:"11111111111111111111111111111111LpoYY",cBlockchainID:"vV3cui1DsEPC3nLCGH9rorwo8s6BYxM2Hz4QFE5gEYjwTqAu",avaxAssetID:"22jjRVdyTJiAEtcZciAVR8bTFyVDUVoo1T3o5PiDspQSZ2maXR",baseTxFee:1000000n,createAssetTxFee:1000000n,networkID:76,hrp:"custom",platformFeeConfig:e};export{n as DevnetContext,c as FujiContext,o as MainnetContext}; |
import { AbstractProvider } from './AbstractProvider.js'; | ||
import { Context } from '@avalabs/avalanchejs'; | ||
import { GetUpgradesInfoResponse } from '@avalabs/avalanchejs/dist/info/model'; | ||
declare class JsonRpcProvider extends AbstractProvider { | ||
constructor(baseUrl: string, context: Context.Context, upgradesInfo?: GetUpgradesInfoResponse); | ||
constructor(baseUrl: string, context: Context.Context); | ||
static fromBaseURL(url: string): Promise<JsonRpcProvider>; | ||
static getDefaultMainnetProvider(upgradesInfo?: GetUpgradesInfoResponse): JsonRpcProvider; | ||
static getDefaultFujiProvider(upgradesInfo?: GetUpgradesInfoResponse): JsonRpcProvider; | ||
static getDefaultMainnetProvider(): JsonRpcProvider; | ||
static getDefaultFujiProvider(): JsonRpcProvider; | ||
static getDefaultDevnetProvider(): JsonRpcProvider; | ||
} | ||
export { JsonRpcProvider }; |
@@ -1,1 +0,1 @@ | ||
import{AbstractProvider as t}from"./AbstractProvider.js";import{Context as r,Info as e}from"@avalabs/avalanchejs";import{MainnetContext as a,FujiContext as s}from"./constants.js";import{AVALANCHE_XP_NETWORK as n,AVALANCHE_XP_TEST_NETWORK as o}from"@avalabs/core-chains-sdk";class c extends t{constructor(t,r,e){super(t,r,e)}static async fromBaseURL(t){const a=await r.getContextFromURI(t);try{const r=await new e(t).getUpgradesInfo();return new c(t,a,r)}catch{return new c(t,a)}}static getDefaultMainnetProvider(t){return new c(n.rpcUrl,a,t)}static getDefaultFujiProvider(t){return new c(o.rpcUrl,s,t)}}export{c as JsonRpcProvider}; | ||
import{AbstractProvider as r}from"./AbstractProvider.js";import{Context as t,info as e}from"@avalabs/avalanchejs";import{MainnetContext as a,FujiContext as n,DevnetContext as o}from"./constants.js";import{AVALANCHE_XP_NETWORK as s,AVALANCHE_XP_TEST_NETWORK as c,AVALANCHE_P_DEV_NETWORK as i}from"@avalabs/core-chains-sdk";class p extends r{constructor(r,t){super(r,t)}static async fromBaseURL(r){const a=await t.getContextFromURI(r);try{await new e.InfoApi(r).getUpgradesInfo();return new p(r,a)}catch{return new p(r,a)}}static getDefaultMainnetProvider(){return new p(s.rpcUrl,a)}static getDefaultFujiProvider(){return new p(c.rpcUrl,n)}static getDefaultDevnetProvider(){return new p(i.rpcUrl,o)}}export{p as JsonRpcProvider}; |
@@ -1,1 +0,1 @@ | ||
import{Common as e}from"@avalabs/avalanchejs";const t={weights:e.createDimensions({bandwidth:1,dbRead:1,dbWrite:1,compute:1}),maxCapacity:BigInt(1e6),maxPerSecond:BigInt(25e4),targetPerSecond:BigInt(125e3),minPrice:BigInt(1),excessConversionConstant:BigInt(5410106)};export{t as platformFeeConfig}; | ||
import{Common as e}from"@avalabs/avalanchejs";const t={weights:e.createDimensions({bandwidth:1,dbRead:1e3,dbWrite:1e3,compute:4}),maxCapacity:BigInt(1e6),maxPerSecond:BigInt(1e5),targetPerSecond:BigInt(5e4),minPrice:BigInt(1),excessConversionConstant:BigInt(2164043)};export{t as platformFeeConfig}; |
import { Utxo as Utxo$1, TransferOutput, pvmSerial } from '@avalabs/avalanchejs'; | ||
import { Utxo, PChainUtxo } from '@avalabs/glacier-sdk'; | ||
import { Utxo, PChainUtxo, Network } from '@avalabs/glacier-sdk'; | ||
type GlacierOutput = Utxo | PChainUtxo; | ||
declare const convertGlacierUtxo: (glacierUtxo: GlacierOutput, isTestnet: boolean) => Utxo$1<TransferOutput | pvmSerial.StakeableLockOut<TransferOutput>>; | ||
declare const convertGlacierUtxo: (glacierUtxo: GlacierOutput, network: Network) => Utxo$1<TransferOutput | pvmSerial.StakeableLockOut<TransferOutput>>; | ||
export { GlacierOutput, convertGlacierUtxo }; |
@@ -1,1 +0,1 @@ | ||
import{UnsignedTx as r,utils as e}from"@avalabs/avalanchejs";import{isSubnetTx as t,handleSubnetAuth as a}from"./handleSubnetAuth.js";const{getTransferableInputsByTx:s,AddressMaps:n}=e,o=async({tx:e,fromAddressBytes:o,provider:i,credentials:d,utxos:p})=>{const u=s(e),f=n.fromTransferableInputs(u,p,BigInt(Math.floor((new Date).getTime()/1e3)),o);if(t(e))try{const t=await a({tx:e,provider:i,addressMaps:f});return new r(e,p,t,d)}catch(r){throw new Error(`Error while preparing subnet authorization data: ${r.message}`)}return new r(e,p,f,d)};export{o as createAvalancheUnsignedTx,o as default}; | ||
import{UnsignedTx as e,pvmSerial as r,utils as a}from"@avalabs/avalanchejs";import{isSubnetTx as t,handleSubnetAuth as s}from"./handleSubnetAuth.js";import{appendDisableAuthAddressMaps as n}from"./appendDisableAuthAddressMaps.js";const{getTransferableInputsByTx:o,AddressMaps:i}=a,d=async({tx:a,fromAddressBytes:d,provider:p,credentials:l,utxos:u})=>{const f=o(a);let m=i.fromTransferableInputs(f,u,BigInt(Math.floor((new Date).getTime()/1e3)),d);if(t(a))try{const r=await s({tx:a,provider:p,addressMaps:m});return new e(a,u,r,l)}catch(e){throw new Error(`Error while preparing subnet authorization data: ${e.message}`)}else r.isDisableL1ValidatorTx(a)&&(m=await n(m,a,p));return new e(a,u,m,l)};export{d as createAvalancheUnsignedTx,d as default}; |
@@ -1,1 +0,1 @@ | ||
import{getUnixNow as t}from"./getUnixNow.js";import{getUtxoInfo as e}from"./getUtxoInfo.js";function o(o,l){const i=o.getAssetDict()[l],a={locked:BigInt(0),available:BigInt(0),multisig:BigInt(0),lockedStakeable:BigInt(0),total:BigInt(0)};if(!i)return a;const n=i.getUTXOs(),c=t();return n.forEach((t=>{const o=e(t);a[o.threshold>1?"multisig":o.locktime>c?"locked":o.stakeableLocktime>c?"lockedStakeable":"available"]+=o.amount})),a.total=a.locked+a.lockedStakeable+a.multisig+a.available,a}export{o as getAssetBalance}; | ||
import{utils as t}from"@avalabs/avalanchejs";import{getUnixNow as e}from"./getUnixNow.js";const{getUtxoInfo:a}=t;function o(t,o){const l=t.getAssetDict()[o],i={locked:BigInt(0),available:BigInt(0),multisig:BigInt(0),lockedStakeable:BigInt(0),total:BigInt(0)};if(!l)return i;const n=l.getUTXOs(),c=e();return n.forEach((t=>{const e=a(t);i[e.threshold>1?"multisig":e.locktime>c?"locked":e.stakeableLocktime>c?"lockedStakeable":"available"]+=e.amount})),i.total=i.locked+i.lockedStakeable+i.multisig+i.available,i}export{o as getAssetBalance}; |
@@ -1,1 +0,1 @@ | ||
import"@avalabs/avalanchejs";import"@avalabs/core-utils-sdk";import"ethers";import{FujiContext as r,MainnetContext as o}from"../providers/constants.js";import"@avalabs/core-chains-sdk";const a=(a,n)=>{const{cBlockchainID:t,xBlockchainID:c,pBlockchainID:i}=n?r:o;if(t===a)return"C";if(c===a)return"X";if(i===a)return"P";throw new Error(`Unknown chainId "${a}"`)};export{a as getChainAliasByChainId}; | ||
import{Network as r}from"@avalabs/glacier-sdk";import"@avalabs/avalanchejs";import"@avalabs/core-utils-sdk";import"ethers";import{FujiContext as a,MainnetContext as o}from"../providers/constants.js";import"@avalabs/core-chains-sdk";const i=(i,n)=>{const s=n===r.FUJI,{cBlockchainID:t,xBlockchainID:c,pBlockchainID:e}=s?a:o;if(t===i)return"C";if(c===i)return"X";if(e===i)return"P";throw new Error(`Unknown chainId "${i}"`)};export{i as getChainAliasByChainId}; |
import * as _avalabs_avalanchejs_dist_serializable_common_types from '@avalabs/avalanchejs/dist/serializable/common/types'; | ||
import { Network } from '@avalabs/glacier-sdk'; | ||
import { Utxo } from '@avalabs/avalanchejs'; | ||
@@ -8,3 +9,3 @@ import { ChainIDAlias } from '../models.js'; | ||
chainAlias: ChainIDAlias; | ||
isTestnet: boolean; | ||
network: Network; | ||
url: string; | ||
@@ -14,4 +15,4 @@ token?: string; | ||
}; | ||
declare const getUtxosByTxFromGlacier: ({ transactionHex, chainAlias, isTestnet, url, token, headers, }: Params) => Promise<Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[]>; | ||
declare const getUtxosByTxFromGlacier: ({ transactionHex, chainAlias, network, url, token, headers, }: Params) => Promise<Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[]>; | ||
export { getUtxosByTxFromGlacier }; |
@@ -1,1 +0,1 @@ | ||
import{Glacier as t,Network as r,BlockchainId as o}from"@avalabs/glacier-sdk";import{evmSerial as e,utils as n,avmSerial as a,pvmSerial as i,PVM as s,AVM as x,EVM as c}from"@avalabs/avalanchejs";import{getVmByChainAlias as u}from"./getVmByChainAlias.js";import{convertGlacierUtxo as I}from"./convertGlacierUtxo.js";const{getTransferableInputsByTx:p,hexToBuffer:f,unpackWithManager:h}=n,l=async({transactionHex:n,chainAlias:l,isTestnet:m,url:d,token:T,headers:w})=>{const D=u(l),g=f(n),E=h(D,g);if(e.isExportTx(E))return[];const A=(t=>{if(e.isImportTx(t)||a.isImportTx(t)||i.isImportTx(t))return t.sourceChain.toString();const r=t.getVM();switch(r){case c:return o.C_CHAIN;case x:return o.X_CHAIN;case s:return o.P_CHAIN;default:throw new Error(`Unable to get chain for VM type "${r}"`)}})(E),H=p(E),b=new t({BASE:d,TOKEN:T,HEADERS:w}),N=m?r.FUJI:r.MAINNET,S=[...new Set(H.map((t=>t.utxoID.txID.toString())))],U=await Promise.all(S.map((t=>b.primaryNetworkTransactions.getTxByHash({blockchainId:A,network:N,txHash:t}))));return H.reduce(((t,r)=>{const o=U.find((t=>t.txHash===r.utxoID.txID.toString()));if(!o)throw new Error(`Unable to find parent tx "${r.utxoID.txID.toString()}"`);const e=o.emittedUtxos.find((t=>t.utxoId===r.utxoID.ID()));if(!e)throw new Error(`Unable to find UTXO "${r.utxoID.ID()}" at index "${r.utxoID.outputIdx.value()}"`);const n=I(e,m);return t.push(n),t}),[])};export{l as getUtxosByTxFromGlacier}; | ||
import{Glacier as t,BlockchainId as r}from"@avalabs/glacier-sdk";import{evmSerial as o,utils as e,avmSerial as n,pvmSerial as a,PVM as i,AVM as s,EVM as x}from"@avalabs/avalanchejs";import{getVmByChainAlias as c}from"./getVmByChainAlias.js";import{convertGlacierUtxo as u}from"./convertGlacierUtxo.js";const{getTransferableInputsByTx:I,hexToBuffer:p,unpackWithManager:f}=e,h=async({transactionHex:e,chainAlias:h,network:l,url:m,token:d,headers:w})=>{const D=c(h),g=p(e),T=f(D,g);if(o.isExportTx(T))return[];const E=(t=>{if(o.isImportTx(t)||n.isImportTx(t)||a.isImportTx(t))return t.sourceChain.toString();const e=t.getVM();switch(e){case x:return r.C_CHAIN;case s:return r.X_CHAIN;case i:return r.P_CHAIN;default:throw new Error(`Unable to get chain for VM type "${e}"`)}})(T),H=I(T),b=new t({BASE:m,TOKEN:d,HEADERS:w}),k=[...new Set(H.map((t=>t.utxoID.txID.toString())))],A=await Promise.all(k.map((t=>b.primaryNetworkTransactions.getTxByHash({blockchainId:E,network:l,txHash:t}))));return H.reduce(((t,r)=>{const o=A.find((t=>t.txHash===r.utxoID.txID.toString()));if(!o)throw new Error(`Unable to find parent tx "${r.utxoID.txID.toString()}"`);const e=o.emittedUtxos.find((t=>t.utxoId===r.utxoID.ID()));if(!e)throw new Error(`Unable to find UTXO "${r.utxoID.ID()}" at index "${r.utxoID.outputIdx.value()}"`);const n=u(e,l);return t.push(n),t}),[])};export{h as getUtxosByTxFromGlacier}; |
@@ -1,1 +0,1 @@ | ||
import{pvmSerial as e,utils as s}from"@avalabs/avalanchejs";const t=s=>e.isCreateChainTx(s)||e.isAddSubnetValidatorTx(s)||e.isRemoveSubnetValidatorTx(s)||e.isTransformSubnetTx(s)||e.isTransferSubnetOwnershipTx(s),a=async({tx:e,provider:t,addressMaps:a})=>{const n=e.getSubnetAuth().values(),r=(await t.getApiP().getTx({txID:e.getSubnetID().value()})).unsignedTx.getSubnetOwners().addrs.reduce(((e,s,t)=>(n.includes(t)&&e.push([s,t]),e)),[]);return a.push(new s.AddressMap(r)),a};export{a as handleSubnetAuth,t as isSubnetTx}; | ||
import{pvmSerial as e,OutputOwners as t,utils as s}from"@avalabs/avalanchejs";const a=t=>e.isCreateChainTx(t)||e.isAddSubnetValidatorTx(t)||e.isRemoveSubnetValidatorTx(t)||e.isTransformSubnetTx(t)||e.isTransferSubnetOwnershipTx(t)||e.isConvertSubnetToL1Tx(t),r=async({tx:e,provider:a,addressMaps:r})=>{const n=e.getSubnetAuth().values(),i=await a.getApiP().getSubnet({subnetID:e.getSubnetID().value()}),u=t.fromNative(i.controlKeys.map((e=>s.parse(e)[2])),BigInt(i.locktime),Number(i.threshold)).addrs.reduce(((e,t,s)=>(n.includes(s)&&e.push([t,s]),e)),[]);return r.push(new s.AddressMap(u)),r};export{r as handleSubnetAuth,a as isSubnetTx}; |
@@ -5,7 +5,13 @@ import { Common } from '@avalabs/avalanchejs'; | ||
type ParseOptions = { | ||
/** | ||
* Tolerance percentage range where the burned amount is considered valid. | ||
*/ | ||
feeTolerance?: number; | ||
}; | ||
/** | ||
* Returns human readable data from a given a transaction buffer, | ||
*/ | ||
declare function parseAvalancheTx(unsignedTx: Common.UnsignedTx, provider: JsonRpcProvider, currentAddress: string): Promise<Tx>; | ||
declare function parseAvalancheTx(unsignedTx: Common.UnsignedTx, provider: JsonRpcProvider, currentAddress: string, { feeTolerance }?: ParseOptions): Promise<Tx>; | ||
export { parseAvalancheTx }; |
@@ -1,1 +0,1 @@ | ||
import{evmSerial as t,utils as e}from"@avalabs/avalanchejs";import{TxType as n}from"../models.js";import a from"./parsers/index.js";const{getBurnedAmountByTx:r,getOutputAmounts:o,getInputAmounts:s,validateBurnedAmount:u}=e;async function i(e,i,g){try{const n=i.getContext(),x=e.getTx(),p=(t=>{for(const e of Object.values(a)){const n=e(t);if(null!==n)return n}throw new Error("no parser found for tx")})(x),d=r(x),c=o(x),A=s(x).get(n.avaxAssetID)??BigInt(0),I=d.get(n.avaxAssetID)??BigInt(0),m=c.get(n.avaxAssetID)??BigInt(0);let l,v=BigInt(0);t.isImportExportTx(x)?v=await i.getApiC().getBaseFee()/BigInt(1e9):"PVM"===x.vm&&(l=i.getUpgradesInfo(),v=await i.getApiP().getFeeState().then((t=>t.price)).catch((()=>BigInt(0))));const{isValid:f,txFee:B}=u({upgradesInfo:l,unsignedTx:e,context:n,burnedAmount:I,baseFee:v,feeTolerance:50});return await p({feeData:{totalAvaxBurned:I,totalAvaxOutput:m,totalAvaxInput:A,isValidAvaxBurnedAmount:f,txFee:B},assetId:n.avaxAssetID,provider:i,currentAddress:g})}catch(t){return{type:n.Unknown}}}export{i as parseAvalancheTx}; | ||
import{evmSerial as t,utils as e}from"@avalabs/avalanchejs";import{TxType as n}from"../models.js";import a from"./parsers/index.js";const{getBurnedAmountByTx:r,getOutputAmounts:o,getInputAmounts:s,validateBurnedAmount:i}=e;async function u(e,u,x,{feeTolerance:g=50}={}){try{const n=u.getContext(),c=e.getTx(),p=(t=>{for(const e of Object.values(a)){const n=e(t);if(null!==n)return n}throw new Error("no parser found for tx")})(c),A=r(c,n),d=o(c),l=s(c).get(n.avaxAssetID)??BigInt(0),m=A.get(n.avaxAssetID)??BigInt(0),v=d.get(n.avaxAssetID)??BigInt(0);let I=BigInt(0);t.isImportExportTx(c)?(I=await u.getApiC().getBaseFee()/BigInt(1e9),0n===I&&(I=1n)):"PVM"===c.vm&&(I=await u.getApiP().getFeeState().then((t=>t.price)).catch((()=>BigInt(0))));const{isValid:f,txFee:B}=i({unsignedTx:e,context:n,burnedAmount:m,baseFee:I,feeTolerance:g});return await p({feeData:{totalAvaxBurned:m,totalAvaxOutput:v,totalAvaxInput:l,isValidAvaxBurnedAmount:f,txFee:B},assetId:n.avaxAssetID,provider:u,currentAddress:x})}catch(t){return{type:n.Unknown}}}export{u as parseAvalancheTx}; |
@@ -1,1 +0,1 @@ | ||
import r from"./parseAddValidatorTx.js";import e from"./parseAddDelegatorTx.js";import s from"./parseCreateSubnetTx.js";import a from"./parseCreateChainTx.js";import o from"./parseAddSubnetValidorTx.js";import p from"./parseImportTx.js";import t from"./parseExportTx.js";import m from"./parseBaseTx.js";import i from"./parseAddPermissionlessValidatorTx.js";import T from"./parseAddPermissionlessDelegatorTx.js";import d from"./parseRemoveSubnetValidatorTx.js";import x from"./parseTransformSubnetTx.js";import n from"./parseTransferSubnetOwnershipTx.js";var f={parseAddValidatorTx:r,parseAddDelegatorTx:e,parseCreateSubnetTx:s,parseCreateChainTx:a,parseAddSubnetValidatorTx:o,parseRemoveSubnetValidatorTx:d,parseImportTx:p,parseExportTx:t,parseBaseTx:m,parseAddPermissionlessValidatorTx:i,parseAddPermissionlessDelegatorTx:T,parseTransformSubnetTx:x,parseTransferSubnetOwnershipTx:n};export{f as default}; | ||
import r from"./parseCreateSubnetTx.js";import e from"./parseCreateChainTx.js";import a from"./parseAddSubnetValidorTx.js";import s from"./parseImportTx.js";import o from"./parseExportTx.js";import t from"./parseBaseTx.js";import p from"./parseAddPermissionlessValidatorTx.js";import i from"./parseAddPermissionlessDelegatorTx.js";import m from"./parseRemoveSubnetValidatorTx.js";import x from"./parseTransferSubnetOwnershipTx.js";import T from"./parseConvertSubnetToL1Tx.js";import d from"./parseRegisterL1ValidatorTx.js";import n from"./parseSetL1ValidatorWeightTx.js";import l from"./parseDisableL1ValidatorTx.js";import f from"./parseIncreaseL1ValidatorBalanceTx.js";var j={parseCreateSubnetTx:r,parseCreateChainTx:e,parseAddSubnetValidatorTx:a,parseRemoveSubnetValidatorTx:m,parseImportTx:s,parseExportTx:o,parseBaseTx:t,parseAddPermissionlessValidatorTx:p,parseAddPermissionlessDelegatorTx:i,parseTransferSubnetOwnershipTx:x,parseConvertSubnetTx:T,parseRegisterL1ValidatorTx:d,parseIncreaseL1ValidatorBalanceTx:f,parseSetL1ValidatorWeightTx:n,parseDisableL1ValidatorTx:l};export{j as default}; |
@@ -1,1 +0,1 @@ | ||
import"@avalabs/avalanchejs";import"@avalabs/core-utils-sdk";import"ethers";import{MainnetContext as a,FujiContext as c}from"../../../providers/constants.js";import"@avalabs/core-chains-sdk";const i=i=>{if([a.xBlockchainID,c.xBlockchainID].includes(i))return"AVM";if([a.pBlockchainID,c.pBlockchainID].includes(i))return"PVM";if([a.cBlockchainID,c.cBlockchainID].includes(i))return"EVM";throw new Error("Unknown chain id. Failed to get alias.")};export{i as default}; | ||
import"@avalabs/avalanchejs";import"@avalabs/core-utils-sdk";import"ethers";import{MainnetContext as c,FujiContext as a,DevnetContext as i}from"../../../providers/constants.js";import"@avalabs/core-chains-sdk";const n=n=>{if([c.xBlockchainID,a.xBlockchainID,i.xBlockchainID].includes(n))return"AVM";if([c.pBlockchainID,a.pBlockchainID,i.pBlockchainID].includes(n))return"PVM";if([c.cBlockchainID,a.cBlockchainID,i.cBlockchainID].includes(n))return"EVM";throw new Error("Unknown chain id. Failed to get alias.")};export{n as default}; |
@@ -6,8 +6,9 @@ import * as _avalabs_avalanchejs_dist_serializable_common_types from '@avalabs/avalanchejs/dist/serializable/common/types'; | ||
* The UTXOs will be sorted in the following order. | ||
* 1- LockedStakeable UTXOs with the highest locktime to lowest | ||
* 2- Highest value UTXOs to lowest | ||
* 1- Highest value unlocked UTXO (for fees) | ||
* 2- LockedStakeable UTXOs with the highest locktime to lowest | ||
* 3- Rest of the unlocked UTXOs highest to lowest | ||
* @remark Does not check for locked UTXOs | ||
*/ | ||
declare function sortUTXOsStaking(utxos: Utxo[]): Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[]; | ||
declare function sortUTXOsByAmount(utxos: Utxo[], isDescending: boolean): Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[]; | ||
declare function sortUTXOsStaking(utxos: Utxo[]): Utxo[]; | ||
declare function sortUTXOsByAmount(utxos: Utxo[], isDescending: boolean): Utxo[]; | ||
declare const sortUTXOsByAmountDescending: (utxos: Utxo[]) => Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[]; | ||
@@ -14,0 +15,0 @@ declare const sortUTXOsByAmountAscending: (utxos: Utxo[]) => Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[]; |
@@ -1,1 +0,1 @@ | ||
import{utils as t}from"@avalabs/avalanchejs";const{isStakeableLockOut:n,isTransferOut:u}=t;function e(t){return t.sort(((t,e)=>{const r=t.output,o=e.output,a=n(r),i=n(o);if(a&&!i)return-1;if(i&&!a)return 1;if(n(r)&&n(o)){const t=r.getStakeableLocktime(),n=o.getStakeableLocktime();if(t<n)return 1;if(t>n)return-1}else if(u(r)&&u(o)){if(r.amount()>o.amount())return-1;if(r.amount()<o.amount())return 1}return 0}))}function r(t,e){return t.sort(((t,r)=>{const o=t.output,a=r.output;let i=BigInt(0);(u(o)||n(o))&&(i=o.amount());let s=BigInt(0);(u(a)||n(a))&&(s=a.amount());const c=e?s-i:i-s;return c>0?1:c<0?-1:0}))}const o=t=>r(t,!0),a=t=>r(t,!1);export{r as sortUTXOsByAmount,a as sortUTXOsByAmountAscending,o as sortUTXOsByAmountDescending,e as sortUTXOsStaking}; | ||
import{utils as t}from"@avalabs/avalanchejs";import{getUnixNow as o}from"./getUnixNow.js";import{orderBy as e}from"./orderBy.js";function a(a){const m=o(),n=a.map((o=>({utxo:o,...t.getUtxoInfo(o)}))),r=n.filter((t=>t.stakeableLocktime<=m)),s=n.filter((t=>t.stakeableLocktime>m)),c=e(r,["amount"],"desc"),i=e(s,["stakeableLocktime","amount"],"desc"),[u,...f]=c;return[...u?[u]:[],...i,...f].map((t=>t.utxo))}function m(o,a){const m=o.map((o=>({utxo:o,...t.getUtxoInfo(o)})));return e(m,["amount"],a?"desc":"asc").map((t=>t.utxo))}const n=t=>m(t,!0),r=t=>m(t,!1);export{m as sortUTXOsByAmount,r as sortUTXOsByAmountAscending,n as sortUTXOsByAmountDescending,a as sortUTXOsStaking}; |
import { Utxo, pvm } from '@avalabs/avalanchejs'; | ||
import { WalletAbstract } from 'Avalanche/wallets'; | ||
import { WalletAbstract } from '../wallets/WalletAbstract.js'; | ||
@@ -36,5 +36,5 @@ /** | ||
limit?: number; | ||
feeState: pvm.FeeState; | ||
feeState?: pvm.FeeState; | ||
}): Utxo[]; | ||
export { P_CHAIN_TX_SIZE_LIMIT, SizeSupportedTx, getMaximumUtxoSet }; |
@@ -1,1 +0,1 @@ | ||
import{utils as e}from"@avalabs/avalanchejs";import{getUtxoInfo as t}from"./getUtxoInfo.js";import{getUnixNow as o}from"./getUnixNow.js";import{binarySearch as r}from"../../utils/binarySearch.js";import{sortUTXOsByAmountDescending as s,sortUTXOsByAmountAscending as d,sortUTXOsStaking as a}from"./sortUTXOs.js";var n=(e=>(e.ExportP="ExportP",e.ImportP="ImportP",e.AddPermissionlessValidator="AddPermissionlessValidator",e.AddPermissionlessDelegator="AddPermissionlessDelegator",e.BaseP="BaseP",e.ConsolidateP="ConsolidateP",e))(n||{});const i="NodeID-8TArWpFgH3sazEH8qP4gUjtGtFMvjw1aR",u="11111111111111111111111111111111LpoYY",c=(e,o)=>e.reduce(((e,o)=>e+t(o).amount),BigInt(0))-o,l={BaseP:{sortFunction:s,unsignedTxBuilder:(t,o,r)=>{const s=t.getProvider().getContext();return t.baseTX({utxoSet:new e.UtxoSet(o),chain:"P",toAddress:t.getCurrentAddress("P"),amountsPerAsset:{[s.avaxAssetID]:c(o,s.baseTxFee)},feeState:r})}},ConsolidateP:{sortFunction:d,unsignedTxBuilder:(t,o,r)=>{const s=t.getProvider().getContext();return t.consolidateP({utxoSet:new e.UtxoSet(o),amount:c(o,s.baseTxFee),feeState:r})}},AddPermissionlessValidator:{sortFunction:a,unsignedTxBuilder:(t,r,s)=>t.addPermissionlessValidator({utxoSet:new e.UtxoSet(r),nodeId:i,start:o(),end:o()+BigInt(1e3),weight:c(r,t.getProvider().getContext().addPrimaryNetworkValidatorFee),subnetId:u,shares:5,feeState:s,fromAddresses:void 0,rewardAddresses:void 0,delegatorRewardAddresses:void 0,publicKey:Buffer.from(e.hexToBuffer("0x8f95423f7142d00a48e1014a3de8d28907d420dc33b3052a6dee03a3f2941a393c2351e354704ca66a3fc29870282e15")),signature:Buffer.from(e.hexToBuffer("0x86a3ab4c45cfe31cae34c1d06f212434ac71b1be6cfe046c80c162e057614a94a5bc9f1ded1a7029deb0ba4ca7c9b71411e293438691be79c2dbf19d1ca7c3eadb9c756246fc5de5b7b89511c7d7302ae051d9e03d7991138299b5ed6a570a98"))})},AddPermissionlessDelegator:{sortFunction:a,unsignedTxBuilder:(t,r,s)=>t.addPermissionlessDelegator({utxoSet:new e.UtxoSet(r),nodeId:i,start:o(),end:o()+BigInt(1e3),weight:c(r,t.getProvider().getContext().addPrimaryNetworkDelegatorFee),subnetId:u,feeState:s})},ExportP:{sortFunction:s,unsignedTxBuilder:(t,o,r)=>t.exportP({amount:c(o,t.getProvider().getContext().baseTxFee),utxoSet:new e.UtxoSet(o),destination:"X",feeState:r})},ImportP:{sortFunction:s,unsignedTxBuilder:(t,o,r)=>t.importP({utxoSet:new e.UtxoSet(o),sourceChain:"X",feeState:r})}},x=65536;function f({wallet:e,utxos:s,sizeSupportedTx:d,limit:a=65536,feeState:n}){const{sortFunction:i,unsignedTxBuilder:u}=l[d],c=o(),x=i(s.filter((e=>{const{locktime:o,stakeableLocktime:r}=t(e);return o<c&&(r<c||("AddPermissionlessDelegator"===d||"AddPermissionlessValidator"===d))}))),f=r(x,(o=>{try{return function(e){const o=e.getInputUtxos().reduce(((e,o)=>e+(8+65*t(o).threshold)),0);return 6+e.toBytes().length+o}(u(e,o,n))}catch(e){return console.log("Unable to estimate size of utxos",{e:e,utxos:o.map(t)}),a+1}}),a);return-1===f?[]:x.slice(0,f+1)}export{x as P_CHAIN_TX_SIZE_LIMIT,n as SizeSupportedTx,f as getMaximumUtxoSet}; | ||
import{utils as e}from"@avalabs/avalanchejs";import{getUnixNow as t}from"./getUnixNow.js";import{binarySearch as o}from"../../utils/binarySearch.js";import{sortUTXOsByAmountDescending as s,sortUTXOsByAmountAscending as r,sortUTXOsStaking as n}from"./sortUTXOs.js";const{getUtxoInfo:d}=e;var a=(e=>(e.ExportP="ExportP",e.ImportP="ImportP",e.AddPermissionlessValidator="AddPermissionlessValidator",e.AddPermissionlessDelegator="AddPermissionlessDelegator",e.BaseP="BaseP",e.ConsolidateP="ConsolidateP",e))(a||{});const i="NodeID-8TArWpFgH3sazEH8qP4gUjtGtFMvjw1aR",u="11111111111111111111111111111111LpoYY",c=(e,t)=>e.reduce(((e,t)=>e+d(t).amount),BigInt(0))-t,l={BaseP:{sortFunction:s,unsignedTxBuilder:(t,o,s)=>{const r=t.getProvider().getContext();return t.baseTX({utxoSet:new e.UtxoSet(o),chain:"P",toAddress:t.getCurrentAddress("P"),amountsPerAsset:{[r.avaxAssetID]:c(o,r.baseTxFee)},feeState:s})}},ConsolidateP:{sortFunction:r,unsignedTxBuilder:(t,o,s)=>{const r=t.getProvider().getContext();return t.consolidateP({utxoSet:new e.UtxoSet(o),amount:c(o,r.baseTxFee),feeState:s})}},AddPermissionlessValidator:{sortFunction:n,unsignedTxBuilder:(o,s,r)=>o.addPermissionlessValidator({utxoSet:new e.UtxoSet(s),nodeId:i,start:t(),end:t()+BigInt(1e3),weight:c(s,o.getProvider().getContext().baseTxFee),subnetId:u,shares:5,feeState:r,fromAddresses:void 0,rewardAddresses:void 0,delegatorRewardAddresses:void 0,publicKey:Buffer.from(e.hexToBuffer("0x8f95423f7142d00a48e1014a3de8d28907d420dc33b3052a6dee03a3f2941a393c2351e354704ca66a3fc29870282e15")),signature:Buffer.from(e.hexToBuffer("0x86a3ab4c45cfe31cae34c1d06f212434ac71b1be6cfe046c80c162e057614a94a5bc9f1ded1a7029deb0ba4ca7c9b71411e293438691be79c2dbf19d1ca7c3eadb9c756246fc5de5b7b89511c7d7302ae051d9e03d7991138299b5ed6a570a98"))})},AddPermissionlessDelegator:{sortFunction:n,unsignedTxBuilder:(o,s,r)=>o.addPermissionlessDelegator({utxoSet:new e.UtxoSet(s),nodeId:i,start:t(),end:t()+BigInt(1e3),weight:c(s,o.getProvider().getContext().baseTxFee),subnetId:u,feeState:r})},ExportP:{sortFunction:s,unsignedTxBuilder:(t,o,s)=>t.exportP({amount:c(o,t.getProvider().getContext().baseTxFee),utxoSet:new e.UtxoSet(o),destination:"X",feeState:s})},ImportP:{sortFunction:s,unsignedTxBuilder:(t,o,s)=>t.importP({utxoSet:new e.UtxoSet(o),sourceChain:"X",feeState:s})}},x=65536;function f({wallet:e,utxos:s,sizeSupportedTx:r,limit:n=65536,feeState:a}){const{sortFunction:i,unsignedTxBuilder:u}=l[r],c=t(),x=i(s.filter((e=>{const{locktime:t,stakeableLocktime:o}=d(e);return t<c&&(o<c||("AddPermissionlessDelegator"===r||"AddPermissionlessValidator"===r))}))),f=o(x,(t=>{try{return function(e){const t=e.getInputUtxos().reduce(((e,t)=>e+(8+65*d(t).threshold)),0);return 6+e.toBytes().length+t}(u(e,t,a))}catch(e){return console.log("Unable to estimate size of utxos",{e:e,utxos:t.map(d)}),n+1}}),n);return-1===f?[]:x.slice(0,f+1)}export{x as P_CHAIN_TX_SIZE_LIMIT,a as SizeSupportedTx,f as getMaximumUtxoSet}; |
@@ -1,1 +0,1 @@ | ||
import{WalletAbstract as s}from"./WalletAbstract.js";import"@avalabs/avalanchejs";import"../utils/populateCredential.js";import"@avalabs/core-utils-sdk";import{isAddress as e}from"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"bip32";import"@avalabs/glacier-sdk";import"bip39";import{isBech32Address as r}from"../utils/isBech32Address.js";import"xss";import"bip32-path";class t extends s{constructor(s,t,a,d,i){if(super(i),this.addressC=s,this.addressCoreEth=t,this.xpAddresses=a,this.xpChangeAddress=d,a.length<1)throw new Error("Must have at least 1 xp address.");if(!e(s))throw new Error("Not a valid C-Chain (EVM) address");if(a.some((s=>!r(s,!1))))throw new Error("Given addresses must be valid avalanche bech32 addresses without the chain alias prefix");if(!r(t,!1))throw new Error("Given CoreEth address must be valid avalanche bech32 addresses without the chain alias prefix");this.setChangeAddress(d)}setChangeAddress(s){if(!r(s,!1))throw new Error("Given address must be valid avalanche bech32 addresses without the chain alias prefix");this.xpChangeAddress=s}getAddressEVM(){return this.addressC}getAddresses(s){return("C"===s?[this.addressCoreEth]:this.xpAddresses).map((e=>this.provider.formatAddress(e,s)))}getChangeAddress(s){const e="C"===s?this.addressCoreEth:this.xpChangeAddress;return this.provider.formatAddress(e,s)}getCurrentAddress(s){const e="C"===s?this.addressCoreEth:this.xpAddresses[0];return this.provider.formatAddress(e,s)}}export{t as AddressWallet}; | ||
import{WalletAbstract as s}from"./WalletAbstract.js";import"@avalabs/avalanchejs";import"../utils/populateCredential.js";import"@avalabs/glacier-sdk";import"@avalabs/core-utils-sdk";import{isAddress as e}from"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"bip32";import"bip39";import{isBech32Address as r}from"../utils/isBech32Address.js";import"xss";import"bip32-path";class t extends s{constructor(s,t,a,d,i){if(super(i),this.addressC=s,this.addressCoreEth=t,this.xpAddresses=a,this.xpChangeAddress=d,a.length<1)throw new Error("Must have at least 1 xp address.");if(!e(s))throw new Error("Not a valid C-Chain (EVM) address");if(a.some((s=>!r(s,!1))))throw new Error("Given addresses must be valid avalanche bech32 addresses without the chain alias prefix");if(!r(t,!1))throw new Error("Given CoreEth address must be valid avalanche bech32 addresses without the chain alias prefix");this.setChangeAddress(d)}setChangeAddress(s){if(!r(s,!1))throw new Error("Given address must be valid avalanche bech32 addresses without the chain alias prefix");this.xpChangeAddress=s}getAddressEVM(){return this.addressC}getAddresses(s){return("C"===s?[this.addressCoreEth]:this.xpAddresses).map((e=>this.provider.formatAddress(e,s)))}getChangeAddress(s){const e="C"===s?this.addressCoreEth:this.xpChangeAddress;return this.provider.formatAddress(e,s)}getCurrentAddress(s){const e="C"===s?this.addressCoreEth:this.xpAddresses[0];return this.provider.formatAddress(e,s)}}export{t as AddressWallet}; |
@@ -1,1 +0,1 @@ | ||
import{WalletVoid as r}from"../WalletVoid.js";import{isObsidianApp as t}from"./isObsidianApp.js";import{ZondaxProvider as e}from"./ZondaxProvider.js";import i from"bip32-path";import o from"@ledgerhq/hw-app-eth";import{utils as a}from"@avalabs/avalanchejs";import"../../utils/populateCredential.js";import"@avalabs/core-utils-sdk";import{SigningKey as s}from"ethers";import"../../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"bip32";import"@avalabs/glacier-sdk";import"bip39";import"xss";import{verifyDerivationPath as n}from"../../utils/verifyDerivationPath.js";const{strip0x:p}=a;class f extends r{constructor(r,t,e,i,o){const p=a.strip0x(s.computePublicKey(r,!0)),f=a.strip0x(s.computePublicKey(e,!0));if(super(Buffer.from(p,"hex"),Buffer.from(f,"hex"),o),this.pathXP=t,this.pathC=i,!n(t)||!n(i))throw new Error("Invalid path configuration.")}static async fromTransport(r,e,i,a){if(await t(r))throw new Error("Ledger app not supported. Must be version >= 0.6.0");if(!n(e)||!n(i))throw new Error("Invalid path configuration.");const h=new o(r),u=await h.getAddress(i,!1),c=await h.getAddress(e,!1),m=Buffer.from(p(u.publicKey),"hex"),l=Buffer.from(p(c.publicKey),"hex"),g=Buffer.from(p(s.computePublicKey(m,!0)),"hex"),d=Buffer.from(p(s.computePublicKey(l,!0)),"hex");return new f(d,e,g,i,a)}async signMessage(r){throw new Error("not implemented")}getFullSignerPath(r){return"C"===r?this.pathC:this.pathXP}getPartialSignerPath(r){return this.getFullSignerPath(r).split("/").slice(4).join("/")}getAccountPath(r){return this.getFullSignerPath(r).split("/").slice(0,4).join("/")}async signTx(r){if(!r.transport)throw new Error("Ledger transport not provided");const t=r.tx,e=t.getVM(),i=Buffer.from(t.toBytes()),o="EVM"===e?"C":"X";return(await this.signTxBuffer({buffer:i,chain:o,transport:r.transport})).forEach((r=>{t.addSignature(r)})),t}async signTxBuffer(r){if(!r.transport)throw new Error("Ledger transport not provided");const t=i.fromString(this.getAccountPath(r.chain)),o=i.fromString(this.getPartialSignerPath(r.chain));return[...(await e.signTx(r.transport,r.buffer,t,[o],[o])).signatures.values()]}}export{f as LedgerSigner}; | ||
import{WalletVoid as r}from"../WalletVoid.js";import{isObsidianApp as t}from"./isObsidianApp.js";import{ZondaxProvider as e}from"./ZondaxProvider.js";import i from"bip32-path";import o from"@ledgerhq/hw-app-eth";import{utils as a}from"@avalabs/avalanchejs";import"../../utils/populateCredential.js";import"@avalabs/glacier-sdk";import"@avalabs/core-utils-sdk";import{SigningKey as s}from"ethers";import"../../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"bip32";import"bip39";import"xss";import{verifyDerivationPath as n}from"../../utils/verifyDerivationPath.js";const{strip0x:p}=a;class f extends r{constructor(r,t,e,i,o){const p=a.strip0x(s.computePublicKey(r,!0)),f=a.strip0x(s.computePublicKey(e,!0));if(super(Buffer.from(p,"hex"),Buffer.from(f,"hex"),o),this.pathXP=t,this.pathC=i,!n(t)||!n(i))throw new Error("Invalid path configuration.")}static async fromTransport(r,e,i,a){if(await t(r))throw new Error("Ledger app not supported. Must be version >= 0.6.0");if(!n(e)||!n(i))throw new Error("Invalid path configuration.");const h=new o(r),u=await h.getAddress(i,!1),c=await h.getAddress(e,!1),m=Buffer.from(p(u.publicKey),"hex"),l=Buffer.from(p(c.publicKey),"hex"),g=Buffer.from(p(s.computePublicKey(m,!0)),"hex"),d=Buffer.from(p(s.computePublicKey(l,!0)),"hex");return new f(d,e,g,i,a)}async signMessage(r){throw new Error("not implemented")}getFullSignerPath(r){return"C"===r?this.pathC:this.pathXP}getPartialSignerPath(r){return this.getFullSignerPath(r).split("/").slice(4).join("/")}getAccountPath(r){return this.getFullSignerPath(r).split("/").slice(0,4).join("/")}async signTx(r){if(!r.transport)throw new Error("Ledger transport not provided");const t=r.tx,e=t.getVM(),i=Buffer.from(t.toBytes()),o="EVM"===e?"C":"X";return(await this.signTxBuffer({buffer:i,chain:o,transport:r.transport})).forEach((r=>{t.addSignature(r)})),t}async signTxBuffer(r){if(!r.transport)throw new Error("Ledger transport not provided");const t=i.fromString(this.getAccountPath(r.chain)),o=i.fromString(this.getPartialSignerPath(r.chain));return[...(await e.signTx(r.transport,r.buffer,t,[o],[o])).signatures.values()]}}export{f as LedgerSigner}; |
@@ -1,1 +0,1 @@ | ||
import{EVMUnsignedTx as t,UnsignedTx as r,utils as e}from"@avalabs/avalanchejs";import s from"bip32-path";import{getTxOutputAddresses as i}from"../../utils/getTxOutputAddresses.js";import{ZondaxProvider as n}from"./ZondaxProvider.js";import{fromBase58 as o}from"bip32";import"../../utils/populateCredential.js";import"@avalabs/core-utils-sdk";import"ethers";import"../../providers/constants.js";import"@avalabs/core-chains-sdk";import{digestMessage as a}from"../../utils/digestMessage.js";import"@avalabs/glacier-sdk";import"bip39";import"xss";const{parse:c}=e;class h{constructor(t,r,e){this.activeAccountIndex=t,this.provider=r,e&&(this.accountNode=o(e))}accountNode;reSerializeTx(e,s){return e instanceof t||"C"===s?t.fromJSON(JSON.stringify(e.toJSON())):r.fromJSON(JSON.stringify(e.toJSON()))}getChainAlias(t){return"EVM"===t.getVM()?"C":"X"}getAccountPath(t){switch(t){case"X":case"P":return"m/44'/9000'/0'";case"C":return"m/44'/60'/0'"}}getAddressOfPath(t,r){if(!this.accountNode)return null;const{publicKey:e}=this.accountNode.derivePath(t),s=this.provider.getAddress(e,r);return Buffer.from(c(s)[2]).toString("hex")}getAddressPathMap(t){const{tx:r,externalIndices:e,internalIndices:s}=t,i=this.getChainAlias(r),n=`0/${this.activeAccountIndex}`,o=new Map;if("C"===i||!this.accountNode)return o;const a=[n,...(e??[]).map((t=>`0/${t}`)),...(s??[]).map((t=>`1/${t}`))];for(const t of a){const r=this.getAddressOfPath(t,i);r&&o.set(r,t)}return o}getAddressBipPaths(t,r){return 0===r.size?[s.fromString(`0/${this.activeAccountIndex}`)]:t.reduce(((t,e)=>{const i=r.get(Buffer.from(e).toString("hex"));return i&&t.push(s.fromString(i)),t}),[])}async signTx(t){if(!t.transport)throw new Error("Ledger transport not provided");const r=this.getChainAlias(t.tx),e=this.reSerializeTx(t.tx,r),s=Buffer.from(e.toBytes()),n=this.getAddressPathMap(t),o=this.getAddressBipPaths(e.getAddresses(),n),a=this.getAddressBipPaths([...i(e)],n);return(await this.signTxBuffer({buffer:s,chain:r,transport:t.transport,signers:o,change:a})).forEach((t=>{e.addSignature(t)})),e}async signTxBuffer(t){if(!t.transport)throw new Error("Ledger transport not provided");if(!t.signers)throw new Error("Signers not provided");const r=t.change||[],e=s.fromString(this.getAccountPath(t.chain));return[...(await n.signTx(t.transport,t.buffer,e,t.signers,r)).signatures.values()]}async signMessage(t){if(!t.transport||!t.message)throw new Error("Unable to sign message. Incomplete or invalid request.");const r=t.signer||s.fromString(`0/${this.activeAccountIndex}`);if(2!=r.toPathArray().length)throw new Error("Given signer path must have a depth of 2. Ex. 0/0, 0/1");const e=a(t.message),i=(await n.signHash(t.transport,e,s.fromString(this.getAccountPath(t.chain)),[r])).signatures.get(r.toString(!0));if(!i)throw new Error("Failed to sign message.");return i}}export{h as SimpleLedgerSigner}; | ||
import{EVMUnsignedTx as t,UnsignedTx as r,utils as e}from"@avalabs/avalanchejs";import s from"bip32-path";import{getTxOutputAddresses as i}from"../../utils/getTxOutputAddresses.js";import{ZondaxProvider as n}from"./ZondaxProvider.js";import{fromBase58 as o}from"bip32";import"../../utils/populateCredential.js";import"@avalabs/glacier-sdk";import"@avalabs/core-utils-sdk";import"ethers";import"../../providers/constants.js";import"@avalabs/core-chains-sdk";import{digestMessage as a}from"../../utils/digestMessage.js";import"bip39";import"xss";const{parse:c}=e;class h{constructor(t,r,e){this.activeAccountIndex=t,this.provider=r,e&&(this.accountNode=o(e))}accountNode;reSerializeTx(e,s){return e instanceof t||"C"===s?t.fromJSON(JSON.stringify(e.toJSON())):r.fromJSON(JSON.stringify(e.toJSON()))}getChainAlias(t){return"EVM"===t.getVM()?"C":"X"}getAccountPath(t){switch(t){case"X":case"P":return"m/44'/9000'/0'";case"C":return"m/44'/60'/0'"}}getAddressOfPath(t,r){if(!this.accountNode)return null;const{publicKey:e}=this.accountNode.derivePath(t),s=this.provider.getAddress(e,r);return Buffer.from(c(s)[2]).toString("hex")}getAddressPathMap(t){const{tx:r,externalIndices:e,internalIndices:s}=t,i=this.getChainAlias(r),n=`0/${this.activeAccountIndex}`,o=new Map;if("C"===i||!this.accountNode)return o;const a=[n,...(e??[]).map((t=>`0/${t}`)),...(s??[]).map((t=>`1/${t}`))];for(const t of a){const r=this.getAddressOfPath(t,i);r&&o.set(r,t)}return o}getAddressBipPaths(t,r){return 0===r.size?[s.fromString(`0/${this.activeAccountIndex}`)]:t.reduce(((t,e)=>{const i=r.get(Buffer.from(e).toString("hex"));return i&&t.push(s.fromString(i)),t}),[])}async signTx(t){if(!t.transport)throw new Error("Ledger transport not provided");const r=this.getChainAlias(t.tx),e=this.reSerializeTx(t.tx,r),s=Buffer.from(e.toBytes()),n=this.getAddressPathMap(t),o=this.getAddressBipPaths(e.getAddresses(),n),a=this.getAddressBipPaths([...i(e)],n);return(await this.signTxBuffer({buffer:s,chain:r,transport:t.transport,signers:o,change:a})).forEach((t=>{e.addSignature(t)})),e}async signTxBuffer(t){if(!t.transport)throw new Error("Ledger transport not provided");if(!t.signers)throw new Error("Signers not provided");const r=t.change||[],e=s.fromString(this.getAccountPath(t.chain));return[...(await n.signTx(t.transport,t.buffer,e,t.signers,r)).signatures.values()]}async signMessage(t){if(!t.transport||!t.message)throw new Error("Unable to sign message. Incomplete or invalid request.");const r=t.signer||s.fromString(`0/${this.activeAccountIndex}`);if(2!=r.toPathArray().length)throw new Error("Given signer path must have a depth of 2. Ex. 0/0, 0/1");const e=a(t.message),i=(await n.signHash(t.transport,e,s.fromString(this.getAccountPath(t.chain)),[r])).signatures.get(r.toString(!0));if(!i)throw new Error("Failed to sign message.");return i}}export{h as SimpleLedgerSigner}; |
@@ -1,1 +0,1 @@ | ||
import{addTxSignatures as e,secp256k1 as t}from"@avalabs/avalanchejs";import{fromSeed as i}from"bip32";import{validateMnemonic as r,mnemonicToSeedSync as n}from"bip39";import"@ledgerhq/hw-app-eth";import"ethers";import{getAddressDerivationPath as o}from"../../utils/getAddressDerivationPath.js";import"hdkey";import"buffer";import{DerivationPath as s}from"../../EVM/constants.js";import"@openzeppelin/contracts/build/contracts/ERC20.json";import"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";import"../utils/populateCredential.js";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import{digestMessage as a}from"../utils/digestMessage.js";import"@avalabs/glacier-sdk";import"xss";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=n(e),c=i(a);this.accountNodeXP=c.derivePath("m/44'/9000'/0'");const p=c.derivePath(o(t,s.BIP44,"EVM"));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/${this.activeAccountIndex}`);if(!r.privateKey)throw new Error("Unable to derive X/P private key.");const n=this.getAdditionalKeys(t,!1);if("AVM"===e){const e=this.getAdditionalKeys(i,!0);return[r.privateKey,...n,...e]}if("PVM"===e)return[r.privateKey,...n]}async signTx(t){const{tx:i,externalIndices:r,internalIndices:n}=t,o=i.getVM(),s=this.getSigningKeys(o,r,n);if(!s?.length)throw new Error("Unable to sign transaction: signing keys are missing.");return await e({unsignedTx:i,privateKeys:s}),t.tx}async signTxBuffer(e){throw new Error("Not implemented")}getActiveAccountNode(e){switch(e){case"X":case"P":return this.accountNodeXP.derivePath(`0/${this.activeAccountIndex}`);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),n=await t.signHash(r,i.privateKey);return Buffer.from(n)}}export{c as SimpleSigner}; | ||
import{addTxSignatures as e,secp256k1 as t}from"@avalabs/avalanchejs";import{fromSeed as i}from"bip32";import{validateMnemonic as r,mnemonicToSeedSync as n}from"bip39";import"@ledgerhq/hw-app-eth";import"ethers";import{getAddressDerivationPath as o}from"../../utils/getAddressDerivationPath.js";import"hdkey";import"buffer";import{DerivationPath as s}from"../../EVM/constants.js";import"@openzeppelin/contracts/build/contracts/ERC20.json";import"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";import"../utils/populateCredential.js";import"@avalabs/glacier-sdk";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import{digestMessage as a}from"../utils/digestMessage.js";import"xss";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=n(e),c=i(a);this.accountNodeXP=c.derivePath("m/44'/9000'/0'");const p=c.derivePath(o(t,s.BIP44,"EVM"));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/${this.activeAccountIndex}`);if(!r.privateKey)throw new Error("Unable to derive X/P private key.");const n=this.getAdditionalKeys(t,!1);if("AVM"===e){const e=this.getAdditionalKeys(i,!0);return[r.privateKey,...n,...e]}if("PVM"===e)return[r.privateKey,...n]}async signTx(t){const{tx:i,externalIndices:r,internalIndices:n}=t,o=i.getVM(),s=this.getSigningKeys(o,r,n);if(!s?.length)throw new Error("Unable to sign transaction: signing keys are missing.");return await e({unsignedTx:i,privateKeys:s}),t.tx}async signTxBuffer(e){throw new Error("Not implemented")}getActiveAccountNode(e){switch(e){case"X":case"P":return this.accountNodeXP.derivePath(`0/${this.activeAccountIndex}`);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),n=await t.signHash(r,i.privateKey);return Buffer.from(n)}}export{c as SimpleSigner}; |
@@ -1,1 +0,1 @@ | ||
import{WalletVoid as i}from"./WalletVoid.js";import{addTxSignatures as r,secp256k1 as e,utils as t}from"@avalabs/avalanchejs";import{validateMnemonic as s,mnemonicToSeedSync as a}from"bip39";import{fromSeed as o}from"bip32";import{digestMessage as n}from"../utils/digestMessage.js";import"../utils/populateCredential.js";import"@avalabs/core-utils-sdk";import"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"@avalabs/glacier-sdk";import"xss";import{verifyDerivationPath as p}from"../utils/verifyDerivationPath.js";const{getPublicKey:m,sign:v,signHash:f}=e,{addChecksum:h}=t;class c extends i{privKeyXP;privKeyC;constructor(i,r,e){super(Buffer.from(m(i)),Buffer.from(m(r)),e),this.privKeyXP=i,this.privKeyC=r}static fromMnemonic(i,r,e,t){if(!s(i))throw new Error("Invalid mnemonic phrase.");if(!p(e)||!p(r))throw new Error("Not valid derivation path. Make sure it is a valid BIP44 path starting with m/");const n=a(i),m=o(n),v=m.derivePath(r),f=m.derivePath(e);if(!v.privateKey||!f.privateKey)throw new Error("Failed to generate private keys.");return new c(v.privateKey,f.privateKey,t)}async signMessage(i){const r=n(i.message),e=this.getSigningKey(i.chain);return Buffer.from(h(await f(r,e)))}getSigningKey(i){return"C"===i?this.privKeyC:this.privKeyXP}async signTx(i){return await r({unsignedTx:i.tx,privateKeys:[this.privKeyC,this.privKeyXP]}),i.tx}async signTxBuffer(i){const r=this.getSigningKey(i.chain);return[Buffer.from(await v(i.buffer,r))]}}export{c as StaticSigner}; | ||
import{WalletVoid as i}from"./WalletVoid.js";import{addTxSignatures as r,secp256k1 as e,utils as t}from"@avalabs/avalanchejs";import{validateMnemonic as s,mnemonicToSeedSync as a}from"bip39";import{fromSeed as o}from"bip32";import{digestMessage as n}from"../utils/digestMessage.js";import"../utils/populateCredential.js";import"@avalabs/glacier-sdk";import"@avalabs/core-utils-sdk";import"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"xss";import{verifyDerivationPath as p}from"../utils/verifyDerivationPath.js";const{getPublicKey:m,sign:v,signHash:f}=e,{addChecksum:h}=t;class c extends i{privKeyXP;privKeyC;constructor(i,r,e){super(Buffer.from(m(i)),Buffer.from(m(r)),e),this.privKeyXP=i,this.privKeyC=r}static fromMnemonic(i,r,e,t){if(!s(i))throw new Error("Invalid mnemonic phrase.");if(!p(e)||!p(r))throw new Error("Not valid derivation path. Make sure it is a valid BIP44 path starting with m/");const n=a(i),m=o(n),v=m.derivePath(r),f=m.derivePath(e);if(!v.privateKey||!f.privateKey)throw new Error("Failed to generate private keys.");return new c(v.privateKey,f.privateKey,t)}async signMessage(i){const r=n(i.message),e=this.getSigningKey(i.chain);return Buffer.from(h(await f(r,e)))}getSigningKey(i){return"C"===i?this.privKeyC:this.privKeyXP}async signTx(i){return await r({unsignedTx:i.tx,privateKeys:[this.privKeyC,this.privKeyXP]}),i.tx}async signTxBuffer(i){const r=this.getSigningKey(i.chain);return[Buffer.from(await v(i.buffer,r))]}}export{c as StaticSigner}; |
@@ -43,2 +43,71 @@ import { utils, pvm, Common } from '@avalabs/avalanchejs'; | ||
}; | ||
type CreateChain = { | ||
utxoSet: utils.UtxoSet; | ||
subnetId: string; | ||
chainName: string; | ||
vmID: string; | ||
fxIds: string[]; | ||
genesisData: Record<string, unknown>; | ||
subnetAuth: number[]; | ||
feeState?: pvm.FeeState; | ||
options?: Common.SpendOptions; | ||
fromAddresses?: string[]; | ||
}; | ||
type ConvertSubnetToL1 = { | ||
utxoSet: utils.UtxoSet; | ||
address: string; | ||
chainId: string; | ||
subnetId: string; | ||
subnetAuth: number[]; | ||
options?: Common.SpendOptions; | ||
feeState: pvm.FeeState; | ||
fromAddresses?: string[]; | ||
validators: { | ||
nodeId: string; | ||
weight: bigint; | ||
balance: bigint; | ||
pubKey: string; | ||
signature: string; | ||
remainingBalanceOwner: { | ||
addresses: string[]; | ||
threshold?: number; | ||
}; | ||
deactivationOwner: { | ||
addresses: string[]; | ||
threshold?: number; | ||
}; | ||
}[]; | ||
}; | ||
type RegisterL1Validator = { | ||
utxoSet: utils.UtxoSet; | ||
balance: bigint; | ||
signature: string; | ||
feeState: pvm.FeeState; | ||
message: string; | ||
options?: Common.SpendOptions; | ||
fromAddresses?: string[]; | ||
}; | ||
type SetL1ValidatorWeight = { | ||
utxoSet: utils.UtxoSet; | ||
feeState: pvm.FeeState; | ||
message: string; | ||
options?: Common.SpendOptions; | ||
fromAddresses?: string[]; | ||
}; | ||
type DisableL1Validator = { | ||
utxoSet: utils.UtxoSet; | ||
feeState: pvm.FeeState; | ||
disableAuth: number[]; | ||
validationId: string; | ||
options?: Common.SpendOptions; | ||
fromAddresses?: string[]; | ||
}; | ||
type IncreaseL1ValidatorBalance = { | ||
utxoSet: utils.UtxoSet; | ||
feeState: pvm.FeeState; | ||
balance: bigint; | ||
validationId: string; | ||
options?: Common.SpendOptions; | ||
fromAddresses?: string[]; | ||
}; | ||
type AddSubnetValidator = { | ||
@@ -111,2 +180,2 @@ utxoSet: utils.UtxoSet; | ||
export { AddPermissionlessDelegator, AddPermissionlessValidator, AddSubnetValidator, BaseTx, ConsolidateP, CreateSubnet, ExportP, ImportP, RemoveSubnetValidator, TransferSubnetOwnershipTx }; | ||
export { AddPermissionlessDelegator, AddPermissionlessValidator, AddSubnetValidator, BaseTx, ConsolidateP, ConvertSubnetToL1, CreateChain, CreateSubnet, DisableL1Validator, ExportP, ImportP, IncreaseL1ValidatorBalance, RegisterL1Validator, RemoveSubnetValidator, SetL1ValidatorWeight, TransferSubnetOwnershipTx }; |
@@ -5,3 +5,3 @@ import * as _avalabs_avalanchejs from '@avalabs/avalanchejs'; | ||
import { ChainIDAlias } from '../models.js'; | ||
import { ImportP, ExportP, ConsolidateP, BaseTx, CreateSubnet, AddSubnetValidator, AddPermissionlessValidator, AddPermissionlessDelegator, RemoveSubnetValidator, TransferSubnetOwnershipTx } from './TxBuilderTypes.js'; | ||
import { ImportP, ExportP, ConsolidateP, BaseTx, ConvertSubnetToL1, RegisterL1Validator, SetL1ValidatorWeight, DisableL1Validator, IncreaseL1ValidatorBalance, CreateChain, CreateSubnet, AddSubnetValidator, AddPermissionlessValidator, AddPermissionlessDelegator, RemoveSubnetValidator, TransferSubnetOwnershipTx } from './TxBuilderTypes.js'; | ||
@@ -86,11 +86,10 @@ /** | ||
exportP({ amount, utxoSet, destination, feeState, toAddress }: ExportP): Common.UnsignedTx; | ||
addValidator(utxos: utils.UtxoSet, nodeId: string, stakeAmount: bigint, startDate: bigint, endDate: bigint, delegationFee: number, config?: { | ||
rewardAddress?: string; | ||
}): Common.UnsignedTx; | ||
addDelegator(utxos: utils.UtxoSet, nodeId: string, stakeAmount: bigint, startDate: bigint, endDate: bigint, config?: { | ||
rewardAddress?: string; | ||
}): Common.UnsignedTx; | ||
consolidateP({ utxoSet, amount, feeState, toAddress, options, }: ConsolidateP): Common.UnsignedTx; | ||
baseTX({ utxoSet, chain, toAddress, amountsPerAsset, feeState, options, fromAddresses, }: BaseTx): Common.UnsignedTx; | ||
createBlockchain(utxoSet: utils.UtxoSet, subnetId: string, chainName: string, vmID: string, fxIds: string[], genesisData: Record<string, unknown>, subnetAuth: number[], options?: Common.SpendOptions, fromAddresses?: string[]): Common.UnsignedTx; | ||
convertSubnetToL1({ utxoSet, chainId, subnetId, subnetAuth, feeState, address, validators, options, fromAddresses, }: ConvertSubnetToL1): Common.UnsignedTx; | ||
registerL1Validator({ utxoSet, balance, signature, message, feeState, fromAddresses, options, }: RegisterL1Validator): Common.UnsignedTx; | ||
setL1ValidatorWeight({ utxoSet, feeState, message, options, fromAddresses, }: SetL1ValidatorWeight): Common.UnsignedTx; | ||
disableL1Validator({ utxoSet, feeState, options, fromAddresses, disableAuth, validationId, }: DisableL1Validator): Common.UnsignedTx; | ||
increaseL1ValidatorBalance({ utxoSet, feeState, options, fromAddresses, balance, validationId, }: IncreaseL1ValidatorBalance): Common.UnsignedTx; | ||
createBlockchain({ utxoSet, subnetId, chainName, vmID, fxIds, genesisData, subnetAuth, feeState, options, fromAddresses, }: CreateChain): Common.UnsignedTx; | ||
createSubnet({ utxoSet, rewardAddresses, feeState, fromAddresses, options, threshold, locktime, }: CreateSubnet): Common.UnsignedTx; | ||
@@ -130,3 +129,2 @@ addSubnetValidator({ utxoSet, nodeId, start, end, weight, subnetId, subnetAuth, feeState, fromAddresses, options, }: AddSubnetValidator): Common.UnsignedTx; | ||
transferSubnetOwnershipTx({ utxoSet, subnetId, subnetAuth, subnetOwners, feeState, fromAddresses, options, threshold, locktime, }: TransferSubnetOwnershipTx): Common.UnsignedTx; | ||
transformSubnetTx(utxoSet: utils.UtxoSet, subnetId: string, assetId: string, initialSupply: bigint, maximumSupply: bigint, minConsumptionRate: bigint, maxConsumptionRate: bigint, minValidatorStake: bigint, maxValidatorStake: bigint, minStakeDuration: number, maxStakeDuration: number, minDelegationFee: number, minDelegatorStake: number, maxValidatorWeightFactor: number, uptimeRequirement: number, subnetAuth: number[], fromAddresses?: string[], options?: Common.SpendOptions): Common.UnsignedTx; | ||
protected constructor(provider: AbstractProvider); | ||
@@ -133,0 +131,0 @@ } |
@@ -1,1 +0,1 @@ | ||
import{TransferableOutput as e,avm as t,pvm as s,evm as r,networkIDs as d,utils as i}from"@avalabs/avalanchejs";import"../utils/populateCredential.js";import{strip0x as o}from"@avalabs/core-utils-sdk";import"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"bip32";import{getUTXOsForAddresses as n}from"../utils/getAllUTXOs.js";import{getStakeForAddresses as a}from"../utils/getStakeForAddresses.js";import"@avalabs/glacier-sdk";import"bip39";import"xss";import{sortUTXOsByAmount as h,sortUTXOsStaking as m,sortUTXOsByAmountAscending as g}from"../utils/sortUTXOs.js";import"bip32-path";import{assertFeeStateProvided as p}from"../../utils/assertFeeStateProvided.js";const{parse:u,hexToBuffer:A}=i,c=new Error("Tx type is not supported post-etna");class x{constructor(e){this.provider=e}setProvider(e){this.provider=e}getProvider(){return this.provider}async getUTXOs(e){const t=this.provider.getApi(e);return n(this.getAddresses(e),t)}async getStake(){const e=this.provider.getApiP();return a(this.getAddresses("P"),e)}async getAtomicUTXOs(e,t){if(e===t)throw new Error("Chain can not be the same as source chain.");const s=this.provider.getApi(e),r=this.provider.getChainID(t);return n(this.getAddresses(e),s,{sourceChain:r,addresses:[]})}async getNonce(){const e=this.getAddressEVM();return await this.provider.evmRpc.getTransactionCount(e)}exportX(s,r,d,i){i=i||this.getCurrentAddress(d);const o=u(i)[2],n=this.provider.getAvaxID(),a=e.fromNative(n,s,[o]),m=h(r.getUTXOs(),!0),g=this.provider.getChainID(d),p=this.getAddresses("X").map((e=>u(e)[2])),A=u(this.getChangeAddress("X"))[2];return t.newExportTx(this.provider.getContext(),g,p,m,[a],{threshold:1,changeAddresses:[A]})}importP({utxoSet:e,sourceChain:t,toAddress:r,threshold:d,feeState:i,locktime:o}){const n=this.provider.getChainID(t),a=this.getAddresses("P").map((e=>u(e)[2])),h=u(this.getChangeAddress("P"))[2];r=r||this.getCurrentAddress("P");const m=u(r)[2],g=e.getUTXOs();if(this.provider.isEtnaEnabled()){if(!i)throw new Error("feeState parameter is required post E-upgrade");return s.e.newImportTx({fromAddressesBytes:a,utxos:g,toAddressesBytes:[m],sourceChainId:n,threshold:d,feeState:i,locktime:o},this.provider.getContext())}return s.newImportTx(this.provider.getContext(),n,g,[m],a,{changeAddresses:[h]})}importX(e,s,r){const d=this.provider.getChainID(s),i=this.getAddresses("X").map((e=>u(e)[2])),o=u(this.getChangeAddress("X"))[2];r=r||this.getCurrentAddress("X");const n=u(r)[2];return t.newImportTx(this.provider.getContext(),d,e.getUTXOs(),[n],i,{changeAddresses:[o]})}importC(e,t,s,d,i){const n=this.provider.getChainID(t),a=this.getAddresses("C").map((e=>u(e)[2]));i=i||this.getAddressEVM();const h=Buffer.from(o(i),"hex");return r.newImportTxFromBaseFee(this.provider.getContext(),h,a,e.getUTXOs(),n,s,d)}exportC(e,t,s,d,i){const o=A(this.getAddressEVM()),n=this.provider.getChainID(t);i=i||this.getCurrentAddress(t);const a=u(i)[2],h=d/BigInt(1e9);return r.newExportTxFromBaseFee(this.provider.getContext(),h,e,n,o,[a],s)}exportP({amount:t,utxoSet:r,destination:d,feeState:i,toAddress:o}){o=o||this.getCurrentAddress(d);const n=u(o)[2],a=this.provider.getAvaxID(),m=e.fromNative(a,t,[n]),g=h(r.getUTXOs(),!0),A=this.provider.getChainID(d),c=this.getAddresses("P").map((e=>u(e)[2])),x=u(this.getChangeAddress("P"))[2];return this.provider.isEtnaEnabled()?(p(i),s.e.newExportTx({fromAddressesBytes:c,utxos:g,outputs:[m],destinationChainId:A,feeState:i},this.provider.getContext())):s.newExportTx(this.provider.getContext(),A,c,g,[m],{changeAddresses:[x]})}addValidator(e,t,r,d,i,o,n){const a=m(e.getUTXOs()),h=this.getAddresses("P").map((e=>u(e)[2])),g=n?.rewardAddress||this.getCurrentAddress("P"),p=u(g)[2],A=u(this.getChangeAddress("P"))[2];if(this.provider.isEtnaEnabled())throw c;return s.newAddValidatorTx(this.provider.getContext(),a,h,t,d,i,r,[p],o,{changeAddresses:[A]})}addDelegator(e,t,r,d,i,o){const n=m(e.getUTXOs()),a=this.getAddresses("P").map((e=>u(e)[2])),h=o?.rewardAddress||this.getCurrentAddress("P"),g=u(h)[2],p=u(this.getChangeAddress("P"))[2];if(this.provider.isEtnaEnabled())throw c;return s.newAddDelegatorTx(this.provider.getContext(),n,a,t,d,i,r,[g],{changeAddresses:[p]})}consolidateP({utxoSet:t,amount:r,feeState:d,toAddress:i,options:o}){const n=g(t.getUTXOs());i=i??this.getCurrentAddress("P");const a=u(i)[2],h=this.provider.getContext(),m=[e.fromNative(h.avaxAssetID,r,[a])],A=this.getAddresses("P").map((e=>u(e)[2]));return this.provider.isEtnaEnabled()?(p(d),s.e.newBaseTx({fromAddressesBytes:A,utxos:n,outputs:m,minIssuanceTime:o?.minIssuanceTime,memo:o?.memo,feeState:d},h)):s.newBaseTx(this.provider.getContext(),A,n,m,o)}baseTX({utxoSet:r,chain:d,toAddress:i,amountsPerAsset:o,feeState:n,options:a,fromAddresses:m}){const[g,A,c]=u(i);if(g!==d||A!==this.provider.getHrp())throw new Error(`Invalid recipient address "${i}"`);const x=Object.entries(o).map((([t,s])=>e.fromNative(t,s,[c]))),v=h(r.getUTXOs(),!0),l=(m??this.getAddresses(d)).map((e=>u(e)[2]));return"X"===d?t.newBaseTx(this.provider.getContext(),l,v,x,a):this.provider.isEtnaEnabled()?(p(n),s.e.newBaseTx({fromAddressesBytes:l,utxos:v,outputs:x,minIssuanceTime:a?.minIssuanceTime,memo:a?.memo,feeState:n},this.provider.getContext())):s.newBaseTx(this.provider.getContext(),l,v,x,a)}createBlockchain(e,t,r,d,i,o,n,a,m){const g=h(e.getUTXOs(),!0),p=(m??this.getAddresses("P")).map((e=>u(e)[2]));if(this.provider.isEtnaEnabled())throw c;return s.newCreateBlockchainTx(this.provider.getContext(),g,p,t,r,d,i,o,n,a)}createSubnet({utxoSet:e,rewardAddresses:t,feeState:r,fromAddresses:d,options:i,threshold:o,locktime:n}){const a=h(e.getUTXOs(),!0),m=(d??this.getAddresses("P")).map((e=>u(e)[2])),g=t.map((e=>u(e)[2]));return this.provider.isEtnaEnabled()?(p(r),s.e.newCreateSubnetTx({fromAddressesBytes:m,utxos:a,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,feeState:r,threshold:o,locktime:n,subnetOwners:g},this.provider.getContext())):s.newCreateSubnetTx(this.provider.getContext(),a,m,g,i,o??1,n??BigInt(0))}addSubnetValidator({utxoSet:e,nodeId:t,start:r,end:d,weight:i,subnetId:o,subnetAuth:n,feeState:a,fromAddresses:m,options:g}){const A=h(e.getUTXOs(),!0),c=(m??this.getAddresses("P")).map((e=>u(e)[2]));return this.provider.isEtnaEnabled()?(p(a),s.e.newAddSubnetValidatorTx({fromAddressesBytes:c,utxos:A,minIssuanceTime:g?.minIssuanceTime,memo:g?.memo,nodeId:t,start:r,end:d,weight:i,subnetId:o,subnetAuth:n,feeState:a},this.provider.getContext())):s.newAddSubnetValidatorTx(this.provider.getContext(),A,c,t,r,d,i,o,n,g)}addPermissionlessValidator({utxoSet:e,nodeId:t,start:r,end:i,weight:o,subnetId:n,shares:a,feeState:h,fromAddresses:g,rewardAddresses:A,delegatorRewardAddresses:c,publicKey:x,signature:v,options:l,threshold:T,locktime:f,stakingAssetId:C}){const w=m(e.getUTXOs()),b=(g??this.getAddresses("P")).map((e=>u(e)[2])),I=(A??[this.getCurrentAddress("P")]).map((e=>u(e)[2])),S=(c??[this.getCurrentAddress("P")]).map((e=>u(e)[2]));if(!(n!==d.PrimaryNetworkID.toString()||x&&v))throw new Error("Must provide public key and signature for primary subnet.");const P=u(this.getChangeAddress("P"))[2];if(this.provider.isEtnaEnabled())return p(h),s.e.newAddPermissionlessValidatorTx({fromAddressesBytes:b,delegatorRewardsOwner:S,utxos:w,minIssuanceTime:l?.minIssuanceTime,memo:l?.memo,changeAddressesBytes:l?.changeAddresses?l.changeAddresses:[P],nodeId:t,start:r,end:i,weight:o,subnetId:n,shares:a,feeState:h,publicKey:x,rewardAddresses:I,signature:v,locktime:f,threshold:T,stakingAssetId:C},this.provider.getContext());const E={changeAddresses:[P],...l??{}};return s.newAddPermissionlessValidatorTx(this.provider.getContext(),w,b,t,n,r,i,o,I,S,a,E,void 0,void 0,x,v)}addPermissionlessDelegator({utxoSet:e,nodeId:t,start:r,end:d,weight:i,subnetId:o,fromAddresses:n,rewardAddresses:a,options:h,locktime:g,feeState:A,threshold:c,stakingAssetId:x}){const v=m(e.getUTXOs()),l=(n??this.getAddresses("P")).map((e=>u(e)[2])),T=(a??[this.getCurrentAddress("P")]).map((e=>u(e)[2])),f=u(this.getChangeAddress("P"))[2];if(this.provider.isEtnaEnabled())return p(A),s.e.newAddPermissionlessDelegatorTx({fromAddressesBytes:l,utxos:v,minIssuanceTime:h?.minIssuanceTime,memo:h?.memo,changeAddressesBytes:h?.changeAddresses?h.changeAddresses:[f],nodeId:t,start:r,end:d,weight:i,subnetId:o,rewardAddresses:T,locktime:g,stakingAssetId:x,threshold:c,feeState:A},this.provider.getContext());const C={changeAddresses:[f],...h??{}};return s.newAddPermissionlessDelegatorTx(this.provider.getContext(),v,l,t,o,r,d,i,T,C,void 0,void 0)}removeSubnetValidator({utxoSet:e,nodeId:t,subnetId:r,subnetAuth:d,fromAddresses:i,feeState:o,options:n}){const a=h(e.getUTXOs(),!0),m=(i??this.getAddresses("P")).map((e=>u(e)[2]));return this.provider.isEtnaEnabled()?(p(o),s.e.newRemoveSubnetValidatorTx({fromAddressesBytes:m,utxos:a,minIssuanceTime:n?.minIssuanceTime,memo:n?.memo,nodeId:t,subnetId:r,subnetAuth:d,feeState:o},this.provider.getContext())):s.newRemoveSubnetValidatorTx(this.provider.getContext(),a,m,t,r,d,n)}transferSubnetOwnershipTx({utxoSet:e,subnetId:t,subnetAuth:r,subnetOwners:d,feeState:i,fromAddresses:o,options:n,threshold:a,locktime:m}){const g=h(e.getUTXOs(),!0),A=(o??this.getAddresses("P")).map((e=>u(e)[2])),c=d.map((e=>u(e)[2]));return this.provider.isEtnaEnabled()?(p(i),s.e.newTransferSubnetOwnershipTx({fromAddressesBytes:A,utxos:g,minIssuanceTime:n?.minIssuanceTime,memo:n?.memo,subnetId:t,subnetAuth:r,subnetOwners:c,feeState:i,threshold:a,locktime:m},this.provider.getContext())):s.newTransferSubnetOwnershipTx(this.provider.getContext(),g,A,t,r,c,n,a??1,m??BigInt(0))}transformSubnetTx(e,t,r,d,i,o,n,a,m,g,p,A,x,v,l,T,f,C){const w=h(e.getUTXOs(),!0),b=(f??this.getAddresses("P")).map((e=>u(e)[2]));if(this.provider.isEtnaEnabled())throw c;return s.newTransformSubnetTx(this.provider.getContext(),w,b,t,r,d,i,o,n,a,m,g,p,A,x,v,l,T,C)}}export{x as WalletAbstract}; | ||
import{TransferableOutput as e,avm as s,pvm as t,evm as r,pvmSerial as d,utils as n,PChainOwner as o,L1Validator as i,networkIDs as a}from"@avalabs/avalanchejs";import"../utils/populateCredential.js";import"@avalabs/glacier-sdk";import{strip0x as m}from"@avalabs/core-utils-sdk";import"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"bip32";import{getUTXOsForAddresses as h}from"../utils/getAllUTXOs.js";import{getStakeForAddresses as g}from"../utils/getStakeForAddresses.js";import"bip39";import"xss";import{sortUTXOsByAmount as u,sortUTXOsByAmountAscending as A,sortUTXOsStaking as c}from"../utils/sortUTXOs.js";import"bip32-path";import{assertFeeStateProvided as p}from"../../utils/assertFeeStateProvided.js";const{parse:f,hexToBuffer:x}=n;class l{constructor(e){this.provider=e}setProvider(e){this.provider=e}getProvider(){return this.provider}async getUTXOs(e){const s=this.provider.getApi(e);return h(this.getAddresses(e),s)}async getStake(){const e=this.provider.getApiP();return g(this.getAddresses("P"),e)}async getAtomicUTXOs(e,s){if(e===s)throw new Error("Chain can not be the same as source chain.");const t=this.provider.getApi(e),r=this.provider.getChainID(s);return h(this.getAddresses(e),t,{sourceChain:r,addresses:[]})}async getNonce(){const e=this.getAddressEVM();return await this.provider.evmRpc.getTransactionCount(e)}exportX(t,r,d,n){n=n||this.getCurrentAddress(d);const o=f(n)[2],i=this.provider.getAvaxID(),a=e.fromNative(i,t,[o]),m=u(r.getUTXOs(),!0),h=this.provider.getChainID(d),g=this.getAddresses("X").map((e=>f(e)[2])),A=f(this.getChangeAddress("X"))[2];return s.newExportTx(this.provider.getContext(),h,g,m,[a],{threshold:1,changeAddresses:[A]})}importP({utxoSet:e,sourceChain:s,toAddress:r,threshold:d,feeState:n,locktime:o}){const i=this.provider.getChainID(s),a=this.getAddresses("P").map((e=>f(e)[2]));f(this.getChangeAddress("P"))[2],r=r||this.getCurrentAddress("P");const m=f(r)[2],h=e.getUTXOs();return p(n),t.newImportTx({fromAddressesBytes:a,utxos:h,toAddressesBytes:[m],sourceChainId:i,threshold:d,feeState:n,locktime:o},this.provider.getContext())}importX(e,t,r){const d=this.provider.getChainID(t),n=this.getAddresses("X").map((e=>f(e)[2])),o=f(this.getChangeAddress("X"))[2];r=r||this.getCurrentAddress("X");const i=f(r)[2];return s.newImportTx(this.provider.getContext(),d,e.getUTXOs(),[i],n,{changeAddresses:[o]})}importC(e,s,t,d,n){const o=this.provider.getChainID(s),i=this.getAddresses("C").map((e=>f(e)[2]));n=n||this.getAddressEVM();const a=Buffer.from(m(n),"hex");return r.newImportTxFromBaseFee(this.provider.getContext(),a,i,e.getUTXOs(),o,t,d)}exportC(e,s,t,d,n){const o=x(this.getAddressEVM()),i=this.provider.getChainID(s);n=n||this.getCurrentAddress(s);const a=f(n)[2],m=d/BigInt(1e9);return r.newExportTxFromBaseFee(this.provider.getContext(),m,e,i,o,[a],t)}exportP({amount:s,utxoSet:r,destination:d,feeState:n,toAddress:o}){o=o||this.getCurrentAddress(d);const i=f(o)[2],a=this.provider.getAvaxID(),m=e.fromNative(a,s,[i]),h=u(r.getUTXOs(),!0),g=this.provider.getChainID(d),A=this.getAddresses("P").map((e=>f(e)[2])),c=f(this.getChangeAddress("P"))[2];return p(n),t.newExportTx({changeAddressesBytes:[c],fromAddressesBytes:A,utxos:h,outputs:[m],destinationChainId:g,feeState:n},this.provider.getContext())}consolidateP({utxoSet:s,amount:r,feeState:d,toAddress:n,options:o}){const i=A(s.getUTXOs());n=n??this.getCurrentAddress("P");const a=f(n)[2],m=this.provider.getContext(),h=[e.fromNative(m.avaxAssetID,r,[a])],g=this.getAddresses("P").map((e=>f(e)[2])),u=f(this.getChangeAddress("P"))[2],c=o?.changeAddresses??[u];return p(d),t.newBaseTx({changeAddressesBytes:c,fromAddressesBytes:g,utxos:i,outputs:h,minIssuanceTime:o?.minIssuanceTime,memo:o?.memo,feeState:d},m)}baseTX({utxoSet:r,chain:d,toAddress:n,amountsPerAsset:o,feeState:i,options:a,fromAddresses:m}){const[h,g,A]=f(n);if(h!==d||g!==this.provider.getHrp())throw new Error(`Invalid recipient address "${n}"`);const c=Object.entries(o).map((([s,t])=>e.fromNative(s,t,[A]))),x=u(r.getUTXOs(),!0),l=(m??this.getAddresses(d)).map((e=>f(e)[2])),I=f(this.getChangeAddress("P"))[2],T=a?.changeAddresses??[I];return"X"===d?s.newBaseTx(this.provider.getContext(),l,x,c,a):(p(i),t.newBaseTx({changeAddressesBytes:T,fromAddressesBytes:l,utxos:x,outputs:c,minIssuanceTime:a?.minIssuanceTime,memo:a?.memo,feeState:i},this.provider.getContext()))}convertSubnetToL1({utxoSet:e,chainId:s,subnetId:r,subnetAuth:a,feeState:m,address:h,validators:g,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],I=g.map((({nodeId:e,pubKey:s,signature:t,balance:r,weight:a,deactivationOwner:m,remainingBalanceOwner:h})=>{const g=new d.ProofOfPossession(Uint8Array.from(n.hexToBuffer(s)),Uint8Array.from(n.hexToBuffer(t))),u=o.fromNative(h.addresses.map((e=>f(e)[2])),h.threshold??1),A=o.fromNative(m.addresses.map((e=>f(e)[2])),m.threshold??1);return i.fromNative(e,a,r,g,u,A)}));return t.newConvertSubnetToL1Tx({changeAddressesBytes:l,validators:I,fromAddressesBytes:p,address:f(h)[2],chainId:s,subnetId:r,subnetAuth:a,feeState:m,utxos:u(e.getUTXOs(),!0)},this.provider.getContext())}registerL1Validator({utxoSet:e,balance:s,signature:r,message:d,feeState:o,fromAddresses:i,options:a}){const m=(i??this.getAddresses("P")).map((e=>f(e)[2])),h=f(this.getChangeAddress("P"))[2],g=a?.changeAddresses??[h];return t.newRegisterL1ValidatorTx({utxos:u(e.getUTXOs(),!0),balance:s,blsSignature:Uint8Array.from(n.hexToBuffer(r)),changeAddressesBytes:g,feeState:o,fromAddressesBytes:m,memo:a?.memo,message:Uint8Array.from(n.hexToBuffer(d)),minIssuanceTime:a?.minIssuanceTime},this.provider.getContext())}setL1ValidatorWeight({utxoSet:e,feeState:s,message:r,options:d,fromAddresses:o}){const i=(o??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],m=d?.changeAddresses??[a];return t.newSetL1ValidatorWeightTx({utxos:u(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:s,fromAddressesBytes:i,memo:d?.memo,message:Uint8Array.from(n.hexToBuffer(r)),minIssuanceTime:d?.minIssuanceTime},this.provider.getContext())}disableL1Validator({utxoSet:e,feeState:s,options:r,fromAddresses:d,disableAuth:n,validationId:o}){const i=(d??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],m=r?.changeAddresses??[a];return t.newDisableL1ValidatorTx({disableAuth:n,validationId:o,utxos:u(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:s,fromAddressesBytes:i,memo:r?.memo,minIssuanceTime:r?.minIssuanceTime},this.provider.getContext())}increaseL1ValidatorBalance({utxoSet:e,feeState:s,options:r,fromAddresses:d,balance:n,validationId:o}){const i=(d??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],m=r?.changeAddresses??[a];return t.newIncreaseL1ValidatorBalanceTx({balance:n,validationId:o,utxos:u(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:s,fromAddressesBytes:i,memo:r?.memo,minIssuanceTime:r?.minIssuanceTime},this.provider.getContext())}createBlockchain({utxoSet:e,subnetId:s,chainName:r,vmID:d,fxIds:n,genesisData:o,subnetAuth:i,feeState:a,options:m,fromAddresses:h}){const g=u(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),t.newCreateChainTx({chainName:r,feeState:a,fromAddressesBytes:A,fxIds:n,genesisData:o,subnetAuth:i,subnetId:s,utxos:g,vmId:d,changeAddressesBytes:x},this.provider.getContext())}createSubnet({utxoSet:e,rewardAddresses:s,feeState:r,fromAddresses:d,options:n,threshold:o,locktime:i}){const a=u(e.getUTXOs(),!0),m=(d??this.getAddresses("P")).map((e=>f(e)[2])),h=f(this.getChangeAddress("P"))[2],g=n?.changeAddresses??[h],A=s.map((e=>f(e)[2]));return p(r),t.newCreateSubnetTx({fromAddressesBytes:m,changeAddressesBytes:g,utxos:a,minIssuanceTime:n?.minIssuanceTime,memo:n?.memo,feeState:r,threshold:o,locktime:i,subnetOwners:A},this.provider.getContext())}addSubnetValidator({utxoSet:e,nodeId:s,start:r,end:d,weight:n,subnetId:o,subnetAuth:i,feeState:a,fromAddresses:m,options:h}){const g=u(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),t.newAddSubnetValidatorTx({changeAddressesBytes:x,fromAddressesBytes:A,utxos:g,minIssuanceTime:h?.minIssuanceTime,memo:h?.memo,nodeId:s,start:r,end:d,weight:n,subnetId:o,subnetAuth:i,feeState:a},this.provider.getContext())}addPermissionlessValidator({utxoSet:e,nodeId:s,start:r,end:d,weight:n,subnetId:o,shares:i,feeState:m,fromAddresses:h,rewardAddresses:g,delegatorRewardAddresses:u,publicKey:A,signature:x,options:l,threshold:I,locktime:T,stakingAssetId:v}){const C=c(e.getUTXOs()),S=(h??this.getAddresses("P")).map((e=>f(e)[2])),b=(g??[this.getCurrentAddress("P")]).map((e=>f(e)[2])),w=(u??[this.getCurrentAddress("P")]).map((e=>f(e)[2]));if(!(o!==a.PrimaryNetworkID.toString()||A&&x))throw new Error("Must provide public key and signature for primary subnet.");const P=f(this.getChangeAddress("P"))[2],B=l?.changeAddresses??[P];return p(m),t.newAddPermissionlessValidatorTx({fromAddressesBytes:S,delegatorRewardsOwner:w,utxos:C,minIssuanceTime:l?.minIssuanceTime,memo:l?.memo,changeAddressesBytes:B,nodeId:s,start:r,end:d,weight:n,subnetId:o,shares:i,feeState:m,publicKey:A,rewardAddresses:b,signature:x,locktime:T,threshold:I,stakingAssetId:v},this.provider.getContext())}addPermissionlessDelegator({utxoSet:e,nodeId:s,start:r,end:d,weight:n,subnetId:o,fromAddresses:i,rewardAddresses:a,options:m,locktime:h,feeState:g,threshold:u,stakingAssetId:A}){const x=c(e.getUTXOs()),l=(i??this.getAddresses("P")).map((e=>f(e)[2])),I=(a??[this.getCurrentAddress("P")]).map((e=>f(e)[2])),T=f(this.getChangeAddress("P"))[2],v=m?.changeAddresses??[T];return p(g),t.newAddPermissionlessDelegatorTx({fromAddressesBytes:l,utxos:x,minIssuanceTime:m?.minIssuanceTime,memo:m?.memo,changeAddressesBytes:v,nodeId:s,start:r,end:d,weight:n,subnetId:o,rewardAddresses:I,locktime:h,stakingAssetId:A,threshold:u,feeState:g},this.provider.getContext())}removeSubnetValidator({utxoSet:e,nodeId:s,subnetId:r,subnetAuth:d,fromAddresses:n,feeState:o,options:i}){const a=u(e.getUTXOs(),!0),m=(n??this.getAddresses("P")).map((e=>f(e)[2])),h=f(this.getChangeAddress("P"))[2],g=i?.changeAddresses??[h];return p(o),t.newRemoveSubnetValidatorTx({changeAddressesBytes:g,fromAddressesBytes:m,utxos:a,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,nodeId:s,subnetId:r,subnetAuth:d,feeState:o},this.provider.getContext())}transferSubnetOwnershipTx({utxoSet:e,subnetId:s,subnetAuth:r,subnetOwners:d,feeState:n,fromAddresses:o,options:i,threshold:a,locktime:m}){const h=u(e.getUTXOs(),!0),g=(o??this.getAddresses("P")).map((e=>f(e)[2])),A=f(this.getChangeAddress("P"))[2],c=i?.changeAddresses??[A],x=d.map((e=>f(e)[2]));return p(n),t.newTransferSubnetOwnershipTx({changeAddressesBytes:c,fromAddressesBytes:g,utxos:h,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,subnetId:s,subnetAuth:r,subnetOwners:x,feeState:n,threshold:a,locktime:m},this.provider.getContext())}}export{l as WalletAbstract}; |
@@ -1,1 +0,1 @@ | ||
import{WalletAbstract as e}from"./WalletAbstract.js";import{fromSeed as r}from"bip32";import{validateMnemonic as t,mnemonicToSeedSync as s}from"bip39";import{strip0x as i}from"@avalabs/core-utils-sdk";import"@avalabs/avalanchejs";import"../utils/populateCredential.js";import{SigningKey as o,computeAddress as a}from"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"@avalabs/glacier-sdk";import"xss";import{verifyDerivationPath as p}from"../utils/verifyDerivationPath.js";class n extends e{constructor(e,r,t){if(super(t),this.pubkeyXP=e,this.pubkeyC=r,33!==r.length||33!==e.length)throw new Error("Public key must be 33 byte compressed public key")}static fromPublicKey(e,r,t){const s=i(o.computePublicKey(e,!0)),a=i(o.computePublicKey(r,!0)),p=Buffer.from(s,"hex"),u=Buffer.from(a,"hex");return new n(p,u,t)}static fromMnemonic(e,i,o,a){if(!t(e))throw new Error("Invalid mnemonic phrase.");if(!p(o)||!p(i))throw new Error("Not valid derivation path. Make sure it is a valid BIP44 path starting with m/");const u=s(e),d=r(u),m=d.derivePath(o),h=d.derivePath(i);return n.fromPublicKey(h.publicKey,m.publicKey,a)}getAddress(e){const r="C"===e?this.pubkeyC:this.pubkeyXP;return this.provider.getAddress(r,e)}getAddressEVM(){return a(`0x${this.pubkeyC.toString("hex")}`)}getAddresses(e){return[this.getAddress(e)]}getChangeAddress(e){return this.getAddress(e)}getCurrentAddress(e){return this.getAddress(e)}}export{n as WalletVoid}; | ||
import{WalletAbstract as e}from"./WalletAbstract.js";import{fromSeed as r}from"bip32";import{validateMnemonic as t,mnemonicToSeedSync as s}from"bip39";import{strip0x as i}from"@avalabs/core-utils-sdk";import"@avalabs/avalanchejs";import"../utils/populateCredential.js";import"@avalabs/glacier-sdk";import{SigningKey as o,computeAddress as a}from"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"xss";import{verifyDerivationPath as p}from"../utils/verifyDerivationPath.js";class n extends e{constructor(e,r,t){if(super(t),this.pubkeyXP=e,this.pubkeyC=r,33!==r.length||33!==e.length)throw new Error("Public key must be 33 byte compressed public key")}static fromPublicKey(e,r,t){const s=i(o.computePublicKey(e,!0)),a=i(o.computePublicKey(r,!0)),p=Buffer.from(s,"hex"),u=Buffer.from(a,"hex");return new n(p,u,t)}static fromMnemonic(e,i,o,a){if(!t(e))throw new Error("Invalid mnemonic phrase.");if(!p(o)||!p(i))throw new Error("Not valid derivation path. Make sure it is a valid BIP44 path starting with m/");const u=s(e),d=r(u),m=d.derivePath(o),h=d.derivePath(i);return n.fromPublicKey(h.publicKey,m.publicKey,a)}getAddress(e){const r="C"===e?this.pubkeyC:this.pubkeyXP;return this.provider.getAddress(r,e)}getAddressEVM(){return a(`0x${this.pubkeyC.toString("hex")}`)}getAddresses(e){return[this.getAddress(e)]}getChangeAddress(e){return this.getAddress(e)}getCurrentAddress(e){return this.getAddress(e)}}export{n as WalletVoid}; |
@@ -11,3 +11,3 @@ import { BitcoinProviderAbstract } from './BitcoinProviderAbstract.js'; | ||
getTxHex(txHash: string): Promise<string>; | ||
getUTXOs(address: string, withScripts?: boolean): Promise<{ | ||
getUTXOs(address: string, withScripts?: boolean, skipBatch?: boolean): Promise<{ | ||
confirmed: BitcoinInputUTXOWithOptionalScript[]; | ||
@@ -17,3 +17,3 @@ unconfirmed: BitcoinInputUTXOWithOptionalScript[]; | ||
getAddressFromScript(script: string): Promise<string>; | ||
getScriptsForUtxos(utxos: BitcoinInputUTXOWithOptionalScript[]): Promise<BitcoinInputUTXO[]>; | ||
getScriptsForUtxos(utxos: BitcoinInputUTXOWithOptionalScript[], skipBatch?: boolean): Promise<BitcoinInputUTXO[]>; | ||
private _parseUtxo; | ||
@@ -26,3 +26,3 @@ getBalances(address: string): Promise<{ | ||
getChainHeight(): Promise<number>; | ||
getFeeRates(): Promise<{ | ||
getFeeRates(skipBatch?: boolean): Promise<{ | ||
low: number; | ||
@@ -29,0 +29,0 @@ medium: number; |
@@ -1,1 +0,1 @@ | ||
import{BitcoinProviderAbstract as t}from"./BitcoinProviderAbstract.js";import{networks as e}from"bitcoinjs-lib";import{HttpClient as a}from"@avalabs/core-utils-sdk";import{URL_EXPLORER_MAINNET as s,URL_EXPLORER_TESTNET as r,URL_NODE_MAINNET as i,URL_NODE_TESTNET as n}from"./models.js";import{parseAddressFullTx as o}from"./utils/parseAddressFullTx.js";class l extends t{constructor(t=!0,e,o,l,c){super(),this.isMainnet=t,this.extraParams=c;const m=e?{headers:{"api-key":e}}:{},p=t?s:r;this.#t=new a(o||p,m);const d=t?i:n;this.#e=new a(l||d,m)}#t;#e;async#a(t){return this.isMainnet?(await Promise.all(t.map((t=>this.#e.post("",t,{},this.extraParams))))).flat():this.#e.post("",t,{},this.extraParams)}async getTxHex(t){return(await this.#t.post(`/api/v2/tx/${t}`,{},{},this.extraParams)).hex}async getUTXOs(t,e=!0){const a=await this.#t.post(`/api/v2/utxo/${t}`,{},{},this.extraParams);if(!a?.length)return{confirmed:[],unconfirmed:[]};const s=a.map(this._parseUtxo),r=t=>({confirmed:t.filter((t=>t.confirmations>0)),unconfirmed:t.filter((t=>0===t.confirmations))});if(!e)return r(s);return r(await this.getScriptsForUtxos(s))}async getAddressFromScript(t){const e=await this.#e.post("",{jsonrpc:"2.0",id:`decode-script-${t}`,method:"decodescript",params:[t]},{},this.extraParams);if(e.result)return e.result.address;throw new Error(`Unable to resolve address for script: ${t}. ${e.error.message}`)}async getScriptsForUtxos(t){const[e,a]=t.reduce((([t,e],a)=>a.script?[[...t,a],e]:[t,[...e,a]]),[[],[]]),s=a.map(((t,e)=>({jsonrpc:"2.0",method:"gettxout",params:[t.txHash,t.index],id:`${e}`}))),r=s.length?(await this.#a(s)).sort(((t,e)=>Number(t.id)-Number(e.id))):[];return[...e,...a.map(((t,e)=>({...t,script:r[e]?.result?.scriptPubKey.hex})))]}_parseUtxo(t){return{...t,txHash:t.txid,index:t.vout,value:Number(t.value),blockHeight:t.height,script:t.script,confirmations:t.confirmations}}async getBalances(t){const e=await this.#t.post(`/api/v2/address/${t}`,{},{},this.extraParams);return{available:BigInt(e.balance),pending:BigInt(e.unconfirmedBalance),final:BigInt(e.balance)+BigInt(e.unconfirmedBalance)}}async getChainHeight(){return(await this.#e.post("",{jsonrpc:"2.0",id:"nownodes",method:"getblockcount",params:[]},{},this.extraParams)).result}async getFeeRates(){const t={jsonrpc:"2.0",method:"estimatesmartfee"},e=await this.#a([{...t,id:"1",params:[1]},{...t,id:"2",params:[3]},{...t,id:"3",params:[6]}]).then((t=>t.sort(((t,e)=>Number(t.id)-Number(e.id))).map((t=>1e8*(t.result?.feerate??0)))));return{high:Math.ceil(e[0]/1024)||1,medium:Math.ceil(e[1]/1024)||1,low:Math.ceil(e[2]/1024)||1}}getNetwork(){return this.isMainnet?e.bitcoin:e.testnet}async issueRawTx(t){return await this.#e.post("",{jsonrpc:"2.0",id:"nownodes",method:"sendrawtransaction",params:[t]},{},this.extraParams).then((t=>t.result))}async getTransaction(t){const e=await this.#t.post(`/api/v2/tx/${t}`,{},{},this.extraParams);return{block:e.blockHeight,fees:Number(e.fees),confirmations:e.confirmations,amount:Number(e.value),hash:e.txid,addresses:Array.from(new Set([...e.vin.map((t=>t.addresses||[])).flat(),...e.vout.map((t=>t.addresses||[])).flat()])),blockTime:e.blockTime,inputs:[...e.vin.map((t=>({...t,value:Number(t.value)})))],outputs:[...e.vout.map((t=>({...t,value:Number(t.value)})))]}}async getTxHistory(t){const e=await this.#t.post(`/api/v2/address/${t}`,{},{},this.extraParams);return await Promise.allSettled(e.txids?.slice(0,25).map((async e=>{try{const a=await this.#t.post(`/api/v2/tx/${e}`,{},{},this.extraParams);return o(t,a)}catch(t){console.log(`Unable to parse full tx ${e}.`)}}))).then((t=>t.map((t=>"fulfilled"===t.status&&t.value?t.value:void 0)).filter((t=>void 0!==t))))}async waitForTx(t,{maxAttempts:e=20,attempt:a=1,pollInterval:s=500}={}){try{return await this.getTransaction(t)}catch(r){if(a>=e)throw r;return await new Promise((t=>setTimeout(t,s))),this.waitForTx(t,{maxAttempts:e,attempt:a+1,pollInterval:s})}}}export{l as BitcoinProvider}; | ||
import{BitcoinProviderAbstract as t}from"./BitcoinProviderAbstract.js";import{networks as e}from"bitcoinjs-lib";import{HttpClient as a}from"@avalabs/core-utils-sdk";import{URL_EXPLORER_MAINNET as s,URL_EXPLORER_TESTNET as r,URL_NODE_MAINNET as i,URL_NODE_TESTNET as n}from"./models.js";import{parseAddressFullTx as o}from"./utils/parseAddressFullTx.js";class l extends t{constructor(t=!0,e,o,l,c){super(),this.isMainnet=t,this.extraParams=c;const m=e?{headers:{"api-key":e}}:{},p=t?s:r;this.#t=new a(o||p,m);const d=t?i:n;this.#e=new a(l||d,m)}#t;#e;async#a(t,e){return this.isMainnet||e?(await Promise.all(t.map((t=>this.#e.post("",t,{},this.extraParams))))).flat():this.#e.post("",t,{},this.extraParams)}async getTxHex(t){return(await this.#t.post(`/api/v2/tx/${t}`,{},{},this.extraParams)).hex}async getUTXOs(t,e=!0,a){const s=await this.#t.post(`/api/v2/utxo/${t}`,{},{},this.extraParams);if(!s?.length)return{confirmed:[],unconfirmed:[]};const r=s.map(this._parseUtxo),i=t=>({confirmed:t.filter((t=>t.confirmations>0)),unconfirmed:t.filter((t=>0===t.confirmations))});if(!e)return i(r);return i(await this.getScriptsForUtxos(r,a))}async getAddressFromScript(t){const e=await this.#e.post("",{jsonrpc:"2.0",id:`decode-script-${t}`,method:"decodescript",params:[t]},{},this.extraParams);if(e.result)return e.result.address;throw new Error(`Unable to resolve address for script: ${t}. ${e.error.message}`)}async getScriptsForUtxos(t,e){const[a,s]=t.reduce((([t,e],a)=>a.script?[[...t,a],e]:[t,[...e,a]]),[[],[]]),r=s.map(((t,e)=>({jsonrpc:"2.0",method:"gettxout",params:[t.txHash,t.index],id:`${e}`}))),i=r.length?(await this.#a(r,e)).sort(((t,e)=>Number(t.id)-Number(e.id))):[];return[...a,...s.map(((t,e)=>({...t,script:i[e]?.result?.scriptPubKey.hex})))]}_parseUtxo(t){return{...t,txHash:t.txid,index:t.vout,value:Number(t.value),blockHeight:t.height,script:t.script,confirmations:t.confirmations}}async getBalances(t){const e=await this.#t.post(`/api/v2/address/${t}`,{},{},this.extraParams);return{available:BigInt(e.balance),pending:BigInt(e.unconfirmedBalance),final:BigInt(e.balance)+BigInt(e.unconfirmedBalance)}}async getChainHeight(){return(await this.#e.post("",{jsonrpc:"2.0",id:"nownodes",method:"getblockcount",params:[]},{},this.extraParams)).result}async getFeeRates(t){const e={jsonrpc:"2.0",method:"estimatesmartfee"},a=await this.#a([{...e,id:"1",params:[1]},{...e,id:"2",params:[3]},{...e,id:"3",params:[6]}],t).then((t=>t.sort(((t,e)=>Number(t.id)-Number(e.id))).map((t=>1e8*(t.result?.feerate??0)))));return{high:Math.ceil(a[0]/1024)||1,medium:Math.ceil(a[1]/1024)||1,low:Math.ceil(a[2]/1024)||1}}getNetwork(){return this.isMainnet?e.bitcoin:e.testnet}async issueRawTx(t){return await this.#e.post("",{jsonrpc:"2.0",id:"nownodes",method:"sendrawtransaction",params:[t]},{},this.extraParams).then((t=>t.result))}async getTransaction(t){const e=await this.#t.post(`/api/v2/tx/${t}`,{},{},this.extraParams);return{block:e.blockHeight,fees:Number(e.fees),confirmations:e.confirmations,amount:Number(e.value),hash:e.txid,addresses:Array.from(new Set([...e.vin.map((t=>t.addresses||[])).flat(),...e.vout.map((t=>t.addresses||[])).flat()])),blockTime:e.blockTime,inputs:[...e.vin.map((t=>({...t,value:Number(t.value)})))],outputs:[...e.vout.map((t=>({...t,value:Number(t.value)})))]}}async getTxHistory(t){const e=await this.#t.post(`/api/v2/address/${t}`,{},{},this.extraParams);return await Promise.allSettled(e.txids?.slice(0,25).map((async e=>{try{const a=await this.#t.post(`/api/v2/tx/${e}`,{},{},this.extraParams);return o(t,a)}catch(t){console.log(`Unable to parse full tx ${e}.`)}}))).then((t=>t.map((t=>"fulfilled"===t.status&&t.value?t.value:void 0)).filter((t=>void 0!==t))))}async waitForTx(t,{maxAttempts:e=20,attempt:a=1,pollInterval:s=500}={}){try{return await this.getTransaction(t)}catch(r){if(a>=e)throw r;return await new Promise((t=>setTimeout(t,s))),this.waitForTx(t,{maxAttempts:e,attempt:a+1,pollInterval:s})}}}export{l as BitcoinProvider}; |
@@ -44,1 +44,11 @@ export { BitcoinHistoryTx, BitcoinInputUTXO, BitcoinInputUTXOWithOptionalScript, BitcoinLedgerInputUTXO, BitcoinOutputUTXO, BitcoinTx } from './BitcoinVM/models.js'; | ||
export { quitLedgerApp } from './utils/quitLedgerApp.js'; | ||
export { compileSolanaTx } from './SolanaVM/utils/compileSolanaTx.js'; | ||
export { deserializeTransactionMessage } from './SolanaVM/utils/deserializeSolanaTx.js'; | ||
export { serializeSolanaTx } from './SolanaVM/utils/serializeSolanaTx.js'; | ||
export { SolanaProvider, getSolanaProvider, isSolanaProvider } from './SolanaVM/utils/solanaProvider.js'; | ||
export { transferSol } from './SolanaVM/utils/transferSol.js'; | ||
export { transferToken } from './SolanaVM/utils/transferToken.js'; | ||
export { getSolanaDerivationPath } from './SolanaVM/utils/derivationPath.js'; | ||
export { getSolanaPublicKeyFromLedger } from './SolanaVM/utils/getSolanaPublicKeyFromLedger.js'; | ||
export { SolanaSigner } from './SolanaVM/wallets/SolanaSigner.js'; | ||
export { SolanaLedgerSigner } from './SolanaVM/wallets/SolanaLedgerSigner.js'; |
@@ -1,1 +0,1 @@ | ||
export{BitcoinProviderAbstract}from"./BitcoinVM/providers/BitcoinProviderAbstract.js";export{BitcoinProvider}from"./BitcoinVM/providers/BitcoinProvider.js";export{addEncodedSigToPsbt}from"./BitcoinVM/utils/addEncodedSigToPsbt.js";export{createPsbt}from"./BitcoinVM/utils/createPsbt.js";export{createTransferTx}from"./BitcoinVM/utils/createTransferTx.js";export{formatAddressForNetworkBech32}from"./BitcoinVM/utils/formatAddressForNetworkBech32.js";export{getBech32Address}from"./BitcoinVM/utils/getBech32Address.js";export{getBech32AddressFromXPub}from"./BitcoinVM/utils/getBech32AddressFromXPub.js";export{getMaxTransferAmount}from"./BitcoinVM/utils/getMaxTransferAmount.js";export{selectUtxos}from"./BitcoinVM/utils/selectUtxos.js";export{createWalletPolicy}from"./BitcoinVM/utils/createWalletPolicy.js";export{createPSBTV2}from"./BitcoinVM/utils/createPSBTV2.js";export{psbt2ToPsbt0}from"./BitcoinVM/utils/psbt2ToPsbt0.js";export{getTransferTxDetails}from"./BitcoinVM/utils/getTransferTxDetails.js";export{BitcoinWalletAbstract}from"./BitcoinVM/wallets/BitcoinWalletAbstract.js";export{BitcoinWallet}from"./BitcoinVM/wallets/BitcoinWallet.js";export{BitcoinLedgerWallet}from"./BitcoinVM/wallets/BitcoinWalletLedger.js";export{BitcoinWalletVoid}from"./BitcoinVM/wallets/BitcoinWalletVoid.js";export{networks as BtcNetworks}from"bitcoinjs-lib";export{getAppEth}from"./EVM/utils/getAppEth.js";export{getVoidSigner}from"./EVM/utils/getVoidSigner.js";export{getWalletFromMnemonic}from"./EVM/utils/getWalletFromMnemonic.js";export{isERC20Transfer,isNativeTxn,onBalanceChange}from"./EVM/utils/blockPolling.js";export{JsonRpcBatchInternal}from"./EVM/utils/jsonRpcBatchProvider.js";export{getAddressPrivateKeyFromXPriv}from"./EVM/utils/getAddressPrivateKeyFromXPriv.js";export{getAddressPublicKeyFromXPub}from"./EVM/utils/getAddressPublicKeyFromXPub.js";export{getAddressFromXPub}from"./EVM/utils/getAddressFromXPub.js";export{getXpubFromMnemonic}from"./EVM/utils/getXpubFromMnemonic.js";export{getEvmAddressFromPubKey}from"./EVM/utils/getEvmAddressFromPubKey.js";export{getBtcAddressFromPubKey}from"./EVM/utils/getBtcAddressFromPubKey.js";export{DerivationPath,ETH_ACCOUNT_PATH,ETH_COIN_PATH}from"./EVM/constants.js";export{LedgerSigner}from"./EVM/LedgerSigner.js";import*as e from"./Avalanche/index.js";export{e as Avalanche};export{getAddressDerivationPath}from"./utils/getAddressDerivationPath.js";export{getPublicKeyFromPrivateKey}from"./utils/getPublicKeyFromPrivateKey.js";export{getPubKeyFromTransport}from"./utils/getPubKeyFromTransport.js";export{getLedgerExtendedPublicKey}from"./utils/getLedgerExtendedPublicKey.js";export{omitUndefinedKeys}from"./utils/omitUndefinedKeys.js";export{getLedgerAppInfo}from"./utils/getLedgerAppInfo.js";export{openLedgerApp}from"./utils/openLedgerApp.js";export{quitLedgerApp}from"./utils/quitLedgerApp.js"; | ||
export{BitcoinProviderAbstract}from"./BitcoinVM/providers/BitcoinProviderAbstract.js";export{BitcoinProvider}from"./BitcoinVM/providers/BitcoinProvider.js";export{addEncodedSigToPsbt}from"./BitcoinVM/utils/addEncodedSigToPsbt.js";export{createPsbt}from"./BitcoinVM/utils/createPsbt.js";export{createTransferTx}from"./BitcoinVM/utils/createTransferTx.js";export{formatAddressForNetworkBech32}from"./BitcoinVM/utils/formatAddressForNetworkBech32.js";export{getBech32Address}from"./BitcoinVM/utils/getBech32Address.js";export{getBech32AddressFromXPub}from"./BitcoinVM/utils/getBech32AddressFromXPub.js";export{getMaxTransferAmount}from"./BitcoinVM/utils/getMaxTransferAmount.js";export{selectUtxos}from"./BitcoinVM/utils/selectUtxos.js";export{createWalletPolicy}from"./BitcoinVM/utils/createWalletPolicy.js";export{createPSBTV2}from"./BitcoinVM/utils/createPSBTV2.js";export{psbt2ToPsbt0}from"./BitcoinVM/utils/psbt2ToPsbt0.js";export{getTransferTxDetails}from"./BitcoinVM/utils/getTransferTxDetails.js";export{BitcoinWalletAbstract}from"./BitcoinVM/wallets/BitcoinWalletAbstract.js";export{BitcoinWallet}from"./BitcoinVM/wallets/BitcoinWallet.js";export{BitcoinLedgerWallet}from"./BitcoinVM/wallets/BitcoinWalletLedger.js";export{BitcoinWalletVoid}from"./BitcoinVM/wallets/BitcoinWalletVoid.js";export{networks as BtcNetworks}from"bitcoinjs-lib";export{getAppEth}from"./EVM/utils/getAppEth.js";export{getVoidSigner}from"./EVM/utils/getVoidSigner.js";export{getWalletFromMnemonic}from"./EVM/utils/getWalletFromMnemonic.js";export{isERC20Transfer,isNativeTxn,onBalanceChange}from"./EVM/utils/blockPolling.js";export{JsonRpcBatchInternal}from"./EVM/utils/jsonRpcBatchProvider.js";export{getAddressPrivateKeyFromXPriv}from"./EVM/utils/getAddressPrivateKeyFromXPriv.js";export{getAddressPublicKeyFromXPub}from"./EVM/utils/getAddressPublicKeyFromXPub.js";export{getAddressFromXPub}from"./EVM/utils/getAddressFromXPub.js";export{getXpubFromMnemonic}from"./EVM/utils/getXpubFromMnemonic.js";export{getEvmAddressFromPubKey}from"./EVM/utils/getEvmAddressFromPubKey.js";export{getBtcAddressFromPubKey}from"./EVM/utils/getBtcAddressFromPubKey.js";export{DerivationPath,ETH_ACCOUNT_PATH,ETH_COIN_PATH}from"./EVM/constants.js";export{LedgerSigner}from"./EVM/LedgerSigner.js";import*as e from"./Avalanche/index.js";export{e as Avalanche};export{getAddressDerivationPath}from"./utils/getAddressDerivationPath.js";export{getPublicKeyFromPrivateKey}from"./utils/getPublicKeyFromPrivateKey.js";export{getPubKeyFromTransport}from"./utils/getPubKeyFromTransport.js";export{getLedgerExtendedPublicKey}from"./utils/getLedgerExtendedPublicKey.js";export{omitUndefinedKeys}from"./utils/omitUndefinedKeys.js";export{getLedgerAppInfo}from"./utils/getLedgerAppInfo.js";export{openLedgerApp}from"./utils/openLedgerApp.js";export{quitLedgerApp}from"./utils/quitLedgerApp.js";export{compileSolanaTx}from"./SolanaVM/utils/compileSolanaTx.js";export{deserializeTransactionMessage}from"./SolanaVM/utils/deserializeSolanaTx.js";export{serializeSolanaTx}from"./SolanaVM/utils/serializeSolanaTx.js";export{getSolanaProvider,isSolanaProvider}from"./SolanaVM/utils/solanaProvider.js";export{transferSol}from"./SolanaVM/utils/transferSol.js";export{transferToken}from"./SolanaVM/utils/transferToken.js";export{getSolanaDerivationPath}from"./SolanaVM/utils/derivationPath.js";export{getSolanaPublicKeyFromLedger}from"./SolanaVM/utils/getSolanaPublicKeyFromLedger.js";export{SolanaSigner}from"./SolanaVM/wallets/SolanaSigner.js";export{SolanaLedgerSigner}from"./SolanaVM/wallets/SolanaLedgerSigner.js"; |
@@ -9,4 +9,4 @@ import { DerivationPath } from '../EVM/constants.js'; | ||
*/ | ||
declare function getAddressDerivationPath(addressIndex: number, pathSpec: DerivationPath, vm: 'EVM' | 'AVM' | 'PVM'): string; | ||
declare function getAddressDerivationPath(addressIndex: number, pathSpec: DerivationPath, vm: 'EVM' | 'AVM' | 'PVM' | 'SVM'): string; | ||
export { getAddressDerivationPath }; |
@@ -1,1 +0,1 @@ | ||
import{DerivationPath as n}from"../EVM/constants.js";function t(t,o,r){if(t<0)throw new Error("Account index can not be less than 0.");const c="EVM"===r?"60":"9000";return o==n.BIP44?`m/44'/${c}'/0'/0/${t}`:`m/44'/${c}'/${t}'/0/0`}export{t as getAddressDerivationPath}; | ||
import{DerivationPath as n}from"../EVM/constants.js";function t(t,r,o){if(t<0)throw new Error("Account index can not be less than 0.");if("SVM"===o)return`m/44'/501'/${t}'/0'`;const e="EVM"===o?"60":"9000";return r==n.BIP44?`m/44'/${e}'/0'/0/${t}`:`m/44'/${e}'/${t}'/0/0`}export{t as getAddressDerivationPath}; |
{ | ||
"name": "@avalabs/core-wallets-sdk", | ||
"version": "3.1.0-canary.805b421.0+805b421", | ||
"version": "3.1.0-canary.8477dec.0+8477dec", | ||
"license": "Limited Ecosystem License", | ||
@@ -33,14 +33,20 @@ "private": false, | ||
"dependencies": { | ||
"@avalabs/avalanchejs": "4.1.0-alpha.7", | ||
"@avalabs/core-chains-sdk": "3.1.0-canary.805b421.0+805b421", | ||
"@avalabs/glacier-sdk": "3.1.0-canary.805b421.0+805b421", | ||
"@avalabs/avalanchejs": "4.2.0-alpha.1", | ||
"@avalabs/core-chains-sdk": "3.1.0-canary.8477dec.0+8477dec", | ||
"@avalabs/glacier-sdk": "3.1.0-canary.8477dec.0+8477dec", | ||
"@avalabs/hw-app-avalanche": "0.14.1", | ||
"@ledgerhq/hw-app-btc": "10.2.4", | ||
"@ledgerhq/hw-app-eth": "6.36.1", | ||
"@ledgerhq/hw-app-solana": "7.2.4", | ||
"@ledgerhq/hw-transport": "6.30.6", | ||
"@metamask/eth-sig-util": "7.0.2", | ||
"@noble/curves": "1.6.0", | ||
"@openzeppelin/contracts": "4.9.6", | ||
"@scure/base": "1.2.4", | ||
"@solana-program/system": "0.7.0", | ||
"@solana-program/token": "0.5.1", | ||
"@solana/kit": "2.1.0", | ||
"bip32": "2.0.6", | ||
"bip32-path": "0.4.2", | ||
"bip39": "3.0.4", | ||
"bip39": "3.1.0", | ||
"bitcoinjs-lib": "5.2.0", | ||
@@ -51,2 +57,3 @@ "coinselect": "3.1.13", | ||
"ledger-bitcoin": "0.2.3", | ||
"micro-key-producer": "0.7.5", | ||
"xss": "1.0.14" | ||
@@ -57,3 +64,3 @@ }, | ||
}, | ||
"gitHead": "805b421e5a0252ad3180f7ba6b0a20dc083cd2bc" | ||
"gitHead": "8477dec6060f79f99f42e5094dcbb3b50ac53665" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
382399
17.41%223
10.95%4977
11.49%26
36.84%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
Updated
Updated