@avalabs/core-wallets-sdk 3.1.0-canary.de1a809.0 → 3.1.0-canary.deafb4f.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/index.cjs +1 -0
  2. package/dist/index.d.ts +95 -163
  3. package/esm/Avalanche/index.d.ts +0 -1
  4. package/esm/Avalanche/index.js +1 -1
  5. package/esm/Avalanche/models.d.ts +3 -2
  6. package/esm/Avalanche/providers/AbstractProvider.d.ts +2 -5
  7. package/esm/Avalanche/providers/AbstractProvider.js +1 -1
  8. package/esm/Avalanche/providers/JsonRpcProvider.d.ts +4 -5
  9. package/esm/Avalanche/providers/JsonRpcProvider.js +1 -1
  10. package/esm/Avalanche/providers/constants.d.ts +1 -19
  11. package/esm/Avalanche/providers/constants.js +1 -1
  12. package/esm/Avalanche/utils/addSignaturesToAvalancheTx.js +1 -1
  13. package/esm/Avalanche/utils/convertGlacierUtxo.d.ts +2 -1
  14. package/esm/Avalanche/utils/convertGlacierUtxo.js +1 -1
  15. package/esm/Avalanche/utils/createAvalancheEvmUnsignedTx.d.ts +1 -1
  16. package/esm/Avalanche/utils/createAvalancheEvmUnsignedTx.js +1 -1
  17. package/esm/Avalanche/utils/createAvalancheUnsignedTx.d.ts +1 -1
  18. package/esm/Avalanche/utils/createAvalancheUnsignedTx.js +1 -1
  19. package/esm/Avalanche/utils/getAssetBalance.d.ts +2 -1
  20. package/esm/Avalanche/utils/getAssetBalance.js +1 -1
  21. package/esm/Avalanche/utils/getChainAliasByChainId.js +1 -1
  22. package/esm/Avalanche/utils/getStakedAssetBalance.d.ts +2 -1
  23. package/esm/Avalanche/utils/getTxOutputAddresses.js +1 -1
  24. package/esm/Avalanche/utils/getUtxosByTxFromGlacier.js +1 -1
  25. package/esm/Avalanche/utils/orderBy.js +1 -0
  26. package/esm/Avalanche/utils/parseAvalancheTx.js +1 -1
  27. package/esm/Avalanche/utils/parsers/index.js +1 -1
  28. package/esm/Avalanche/utils/parsers/parseAddPermissionlessDelegatorTx.js +1 -1
  29. package/esm/Avalanche/utils/parsers/parseAddPermissionlessValidatorTx.js +1 -1
  30. package/esm/Avalanche/utils/parsers/parseAddSubnetValidorTx.js +1 -1
  31. package/esm/Avalanche/utils/parsers/parseBaseTx.js +1 -1
  32. package/esm/Avalanche/utils/parsers/parseConvertSubnetToL1Tx.js +1 -1
  33. package/esm/Avalanche/utils/parsers/parseCreateChainTx.js +1 -1
  34. package/esm/Avalanche/utils/parsers/parseCreateSubnetTx.js +1 -1
  35. package/esm/Avalanche/utils/parsers/parseDisableL1ValidatorTx.js +1 -1
  36. package/esm/Avalanche/utils/parsers/parseExportTx.js +1 -1
  37. package/esm/Avalanche/utils/parsers/parseImportTx.js +1 -1
  38. package/esm/Avalanche/utils/parsers/parseIncreaseL1ValidatorBalanceTx.js +1 -1
  39. package/esm/Avalanche/utils/parsers/parseRegisterL1ValidatorTx.js +1 -1
  40. package/esm/Avalanche/utils/parsers/parseRemoveSubnetValidatorTx.js +1 -1
  41. package/esm/Avalanche/utils/parsers/parseSetL1ValidatorWeightTx.js +1 -1
  42. package/esm/Avalanche/utils/parsers/parseTransferSubnetOwnershipTx.js +1 -1
  43. package/esm/Avalanche/utils/parsers/utils/chainIdToVm.js +1 -1
  44. package/esm/Avalanche/utils/populateCredential.js +1 -1
  45. package/esm/Avalanche/utils/sortUTXOs.d.ts +5 -4
  46. package/esm/Avalanche/utils/sortUTXOs.js +1 -1
  47. package/esm/Avalanche/utils/txSizeLimits.d.ts +1 -1
  48. package/esm/Avalanche/utils/txSizeLimits.js +1 -1
  49. package/esm/Avalanche/wallets/AddressWallet.js +1 -1
  50. package/esm/Avalanche/wallets/SimpleSigner.js +1 -1
  51. package/esm/Avalanche/wallets/StaticSigner.js +1 -1
  52. package/esm/Avalanche/wallets/TxBuilderTypes.d.ts +1 -1
  53. package/esm/Avalanche/wallets/WalletAbstract.d.ts +0 -7
  54. package/esm/Avalanche/wallets/WalletAbstract.js +1 -1
  55. package/esm/Avalanche/wallets/WalletVoid.js +1 -1
  56. package/esm/Avalanche/wallets/ledger/LedgerSigner.js +1 -1
  57. package/esm/Avalanche/wallets/ledger/SimpleLedgerSigner.js +1 -1
  58. package/esm/Avalanche/wallets/ledger/models.d.ts +1 -1
  59. package/esm/Avalanche/wallets/legacy/LedgerWallet.js +1 -1
  60. package/esm/Avalanche/wallets/legacy/MnemonicWallet.js +1 -1
  61. package/esm/Avalanche/wallets/legacy/MnemonicWalletVoid.js +1 -1
  62. package/esm/Avalanche/wallets/models.d.ts +1 -1
  63. package/esm/BitcoinVM/index.d.ts +5 -0
  64. package/esm/BitcoinVM/index.js +1 -0
  65. package/esm/BitcoinVM/models.d.ts +1 -1
  66. package/esm/BitcoinVM/providers/BitcoinProvider.js +1 -1
  67. package/esm/BitcoinVM/utils/getBech32AddressFromXPub.js +1 -1
  68. package/esm/BitcoinVM/wallets/BitcoinWallet.js +1 -1
  69. package/esm/BitcoinVM/wallets/BitcoinWalletLedger.js +1 -1
  70. package/esm/BitcoinVM/wallets/models.d.ts +1 -1
  71. package/esm/EVM/LedgerSigner.js +1 -1
  72. package/esm/EVM/utils/blockPolling.js +1 -1
  73. package/esm/EVM/utils/getWalletFromMnemonic.js +1 -1
  74. package/esm/SolanaVM/utils/compileSolanaTx.d.ts +9 -0
  75. package/esm/SolanaVM/utils/compileSolanaTx.js +1 -0
  76. package/esm/SolanaVM/utils/derivationPath.d.ts +3 -0
  77. package/esm/SolanaVM/utils/derivationPath.js +1 -0
  78. package/esm/SolanaVM/utils/deserializeSolanaTx.d.ts +6 -0
  79. package/esm/SolanaVM/utils/deserializeSolanaTx.js +1 -0
  80. package/esm/SolanaVM/utils/getSolanaPublicKeyFromLedger.d.ts +5 -0
  81. package/esm/SolanaVM/utils/getSolanaPublicKeyFromLedger.js +1 -0
  82. package/esm/SolanaVM/utils/serializeSolanaTx.d.ts +6 -0
  83. package/esm/SolanaVM/utils/serializeSolanaTx.js +1 -0
  84. package/esm/SolanaVM/utils/solanaProvider.d.ts +11 -0
  85. package/esm/SolanaVM/utils/solanaProvider.js +1 -0
  86. package/esm/SolanaVM/utils/transferSol.d.ts +14 -0
  87. package/esm/SolanaVM/utils/transferSol.js +1 -0
  88. package/esm/SolanaVM/utils/transferToken.d.ts +17 -0
  89. package/esm/SolanaVM/utils/transferToken.js +1 -0
  90. package/esm/SolanaVM/wallets/SolanaLedgerSigner.d.ts +10 -0
  91. package/esm/SolanaVM/wallets/SolanaLedgerSigner.js +1 -0
  92. package/esm/SolanaVM/wallets/SolanaSigner.d.ts +20 -0
  93. package/esm/SolanaVM/wallets/SolanaSigner.js +1 -0
  94. package/esm/abis/erc20.abi.js +1 -0
  95. package/esm/index.d.ts +30 -20
  96. package/esm/index.js +1 -1
  97. package/esm/utils/getAddressDerivationPath.d.ts +4 -1
  98. package/esm/utils/getAddressDerivationPath.js +1 -1
  99. package/package.json +26 -9
  100. package/dist/index.js +0 -1
  101. package/esm/Avalanche/utils/getUtxoInfo.d.ts +0 -13
  102. package/esm/Avalanche/utils/getUtxoInfo.js +0 -1
  103. package/esm/Avalanche/utils/parsers/parseAddDelegatorTx.js +0 -1
  104. package/esm/Avalanche/utils/parsers/parseAddValidatorTx.js +0 -1
  105. package/esm/Avalanche/utils/parsers/parseTransformSubnetTx.js +0 -1
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e=require("bitcoinjs-lib"),t=require("@avalabs/core-utils-sdk"),r=require("coinselect"),s=require("@ledgerhq/hw-app-eth"),n=require("ethers"),a=require("@solana/kit"),i=require("@solana-program/system"),o=require("@solana-program/token"),d=require("@ledgerhq/hw-app-solana"),u=require("bip39"),c=require("@noble/curves/ed25519"),l=require("@scure/base"),p=require("micro-key-producer/slip10.js"),h=require("@avalabs/avalanchejs"),g=require("hdkey"),m=require("bip32"),f=require("@ledgerhq/hw-transport"),x=require("@metamask/eth-sig-util"),v=require("ledger-bitcoin"),y=require("@ledgerhq/hw-app-btc/lib/bip32"),w=require("@noble/hashes/sha256"),b=require("@avalabs/glacier-sdk"),A=require("@avalabs/core-chains-sdk"),T=require("create-hash"),I=require("xss"),S=require("bip32-path"),P=require("@avalabs/hw-app-avalanche"),B=require("buffer");function C(e){return e.reduce(((e,t)=>e+t.value),0)}class k{async getUtxoBalance(e,t=!0){const r=await this.getUTXOs(e,t);return{balance:C(r.confirmed),balanceUnconfirmed:C(r.unconfirmed),utxos:r.confirmed,utxosUnconfirmed:r.unconfirmed}}}function E(t,r,s){const n=new e.Psbt({network:s});return t.forEach((e=>{n.addInput({hash:e.txHash,index:e.index,witnessUtxo:{script:Buffer.from(e.script,"hex"),value:e.value}})})),r.forEach((e=>{n.addOutput({value:e.value,address:e.address})})),n}function D(e,t,s,n,a){const i=[{address:e,value:s}],{inputs:o,outputs:d,fee:u}=r(a,i,n);if(!o||!d)return{fee:u};const c=[d[0]],l=d[1];return l&&c.push({address:t,value:l.value}),{inputs:o,outputs:c,fee:u}}function M(e){const t=[];return e.filter((e=>{const r=e.txHash+e.index.toString();return!t.includes(r)&&(t.push(r),!0)}))}function V(e,t,r,s,n,a){const i=D(e,t,r,s,M(n));return i.inputs?{...i,psbt:E(i.inputs,i.outputs,a)}:(console.log("Unable to construct transaction, fee needed: ",i.fee),i)}function K(t,r){return e.payments.p2wpkh({pubkey:t,network:r}).address}function U(e){return new s(e,"w0w")}const O=(e,t)=>{const r=a.getTransactionDecoder().decode(a.getBase64Encoder().encode(e)),s=a.getCompiledTransactionMessageDecoder().decode(r.messageBytes);return a.decompileTransactionMessageFetchingLookupTables(s,t)},N=Symbol(),_=(e,t=!0)=>`${t?"m/":""}44'/501'/${e}'/0'`;class L{#e;#t;constructor(e){this.#e=Uint8Array.from(e),this.#t=a.address(l.base58.encode(c.ed25519.getPublicKey(this.#e)))}static fromMnemonic(e,t){const r=u.mnemonicToSeedSync(e),s=p.fromMasterSeed(Uint8Array.from(r)).derive(`m/44'/501'/${t}'/0'`);return new L(Buffer.from(s.privateKey))}#r(e){try{return a.getCompiledTransactionMessageDecoder().decode(e),!0}catch{return!1}}async signMessage(e){const t=l.base64.decode(e);if(this.#r(t))throw new Error("Cannot use signMessage() to sign transactions!");return l.base64.encode(c.ed25519.sign(t,this.#e))}async signTx(e,t){const r=await O(e,t),{signatures:s,messageBytes:n,...i}=a.compileTransaction(r);if(!this.#s(s))return e;const o=l.base58.encode(c.ed25519.sign(Uint8Array.from(n),this.#e));return a.assertIsSignature(o),a.getBase64EncodedWireTransaction({...i,messageBytes:n,signatures:{...s,[this.#t]:l.base58.decode(o)}})}#s(e){return this.#t in e&&!e[this.#t]}}const X="m/44'/60'",F=`${X}/0'`;var H=(e=>(e.BIP44="bip44",e.LedgerLive="ledger_live",e))(H||{});function R(e,t,r,s=!0){if(e<0)throw new Error("Account index can not be less than 0.");if("SVM"===r)return _(e,s);const n="EVM"===r?"60":"9000";return t==H.BIP44?`m/44'/${n}'/0'/0/${e}`:`m/44'/${n}'/${e}'/0/0`}var $=[{inputs:[{internalType:"string",name:"name_",type:"string"},{internalType:"string",name:"symbol_",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"subtractedValue",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}];const q=(e,t)=>t.has(e.from.toLowerCase())||t.has((e.to??"").toLowerCase()),W=(e,t)=>{const r=new n.Interface($).parseTransaction({data:e.data,value:e.value});if(t.has(e.from.toLowerCase()))return!0;if("transfer"===r?.name)return t.has(r.args[0]?.toLowerCase());if("transferFrom"===r?.name){const e=t.has(r.args[0]?.toLowerCase()),s=t.has(r.args[1]?.toLowerCase());return e||s}return!1};var j=[{inputs:[{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall.Call[]",name:"calls",type:"tuple[]"}],name:"aggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes[]",name:"returnData",type:"bytes[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"}],name:"getBlockHash",outputs:[{internalType:"bytes32",name:"blockHash",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockCoinbase",outputs:[{internalType:"address",name:"coinbase",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockDifficulty",outputs:[{internalType:"uint256",name:"difficulty",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockGasLimit",outputs:[{internalType:"uint256",name:"gaslimit",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockTimestamp",outputs:[{internalType:"uint256",name:"timestamp",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"addr",type:"address"}],name:"getEthBalance",outputs:[{internalType:"uint256",name:"balance",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLastBlockHash",outputs:[{internalType:"bytes32",name:"blockHash",type:"bytes32"}],stateMutability:"view",type:"function"}];class J extends n.JsonRpcProvider{url;constructor(e,t,r){super(t,r,{staticNetwork:r}),this.#n="string"==typeof t?new n.FetchRequest(t):void 0===t?new n.FetchRequest("http://localhost:8545"):t.clone(),this.url=this.#n.url,this._maxCalls="number"==typeof e?e:e.maxCalls,"number"!=typeof e&&e?.multiContractAddress&&(this._parentProvider=new n.JsonRpcProvider(this.#n,r,{staticNetwork:r}),this._multicallContract=new n.Contract(e.multiContractAddress,j,this._parentProvider),this._maxCalls=62)}#n;#a=1;_pendingBatchAggregator=null;_pendingBatch=[];_maxCalls;_parentProvider;_multicallContract;send(e,t){if("eth_call"!==e)return super.send(e,t);const r={method:e,params:t,id:this.#a++,jsonrpc:"2.0"};null==this._pendingBatch&&(this._pendingBatch=[]);const s={request:r,resolve:null,reject:null},n=new Promise(((e,t)=>{s.resolve=e,s.reject=t}));return this._pendingBatch.push(s),this._pendingBatchAggregator||(this._pendingBatchAggregator=setTimeout(this.flush,10)),n}flush=()=>{const e=this._pendingBatch?.slice(0,this._maxCalls)??[];!this._pendingBatch||this._pendingBatch?.length<=this._maxCalls?(this._pendingBatch=null,this._pendingBatchAggregator=null):(this._pendingBatch.splice(0,this._maxCalls),setTimeout(this.flush,10));(this._multicallContract?this.batchSendMultiCall:this.batchSend)(e).then((t=>{e?.forEach(((e,r)=>{const s=t[r];if(s.error){const t=new Error(s.error.message);t.code=s.error.code,t.data=s.error.data,e.reject(t)}else e.resolve(s.result)}))})).catch((t=>{e?.forEach((e=>{e.reject(t)}))}))};batchSend=async e=>{const t=e?.map((e=>e.request));if(!this.url||!t)throw new Error("No url");const r=this.#n.clone();r.body=t;return(await r.send()).bodyJson};batchSendMultiCall=async e=>{const t=e.map((e=>({callData:e.request.params[0].data,target:e.request.params[0].to})));return(await this._multicallContract.aggregate(t))[1].map((e=>({result:e})))}}function z(e,t){return m.fromBase58(e).derivePath(`0/${t}`).publicKey}let G=class e extends n.AbstractSigner{type="default";path;provider=null;accountIndex;derivationSpec;transport;_eth;constructor(e=0,t,r,s){super(),this.path=R(e,r,"EVM"),this.accountIndex=e,this.transport=t,this.derivationSpec=r,this._eth=U(t),n.defineProperties(this,{path:this.path,type:"default",provider:s??null})}setTransport(e){this._eth=U(e),this.transport=e}async getAddress(){const e=await this._eth.getAddress(this.path);return n.getAddress(e.address)}async signMessage(e){"string"==typeof e&&(e=n.toUtf8Bytes(e));const t=n.hexlify(e).substring(2),r=await this._eth.signPersonalMessage(this.path,t);return r.r="0x"+r.r,r.s="0x"+r.s,n.Signature.from(r).serialized}async signTransaction(e){const t=await this.populateTransaction(e);delete t.from;const r=n.Transaction.from(t),s=r.unsignedSerialized,a=await this._eth.signTransaction(this.path,s.slice(2),null);return r.signature={v:BigInt("0x"+a.v),r:"0x"+a.r,s:"0x"+a.s},r.serialized}connect(t){return new e(this.accountIndex,this.transport,this.derivationSpec,t)}async signTypedData(e,t,r){const{EIP712Domain:s,...a}=t,i=n.TypedDataEncoder.getPrimaryType(a);try{const s=await this._eth.signEIP712Message(this.path,{domain:{name:e.name||void 0,chainId:e.chainId?Number(e.chainId):void 0,version:e.version||void 0,verifyingContract:e.verifyingContract||void 0,salt:e.salt?.toString()||void 0},types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],...t},primaryType:i,message:r});return s.r="0x"+s.r,s.s="0x"+s.s,n.Signature.from(s).serialized}catch(s){if(s instanceof f.TransportStatusError&&s.statusCode===f.StatusCodes.INS_NOT_SUPPORTED){const s=x.TypedDataUtils.hashStruct(i,r,t,x.SignTypedDataVersion.V4),a=x.TypedDataUtils.hashStruct("EIP712Domain",e,t,x.SignTypedDataVersion.V4),o=await this._eth.signEIP712HashedMessage(this.path,a.toString("hex"),s.toString("hex"));return o.r="0x"+o.r,o.s="0x"+o.s,n.Signature.from(o).serialized}throw s}}};function Y(t,r,s,n,a,i){const o=new v.PsbtV2;return o.setGlobalPsbtVersion(2),o.setGlobalTxVersion(2),o.setGlobalInputCount(t.length),o.setGlobalOutputCount(r.length),t.forEach(((e,t)=>{if(!e.txHex)throw new Error("Input tx hex is not given");o.setInputPreviousTxId(t,Buffer.from(e.txHash,"hex").reverse()),o.setInputOutputIndex(t,e.index),o.setInputNonWitnessUtxo(t,Buffer.from(e.txHex,"hex")),o.setInputWitnessUtxo(t,e.value,Buffer.from(e.script,"hex")),o.setInputBip32Derivation(t,a,n,y.pathStringToArray(i))})),r.forEach(((t,r)=>{const n=e.address.toOutputScript(t.address,s);o.setOutputAmount(r,t.value),o.setOutputScript(r,n)})),o}function Q(t,r,s,n){const a=new e.Psbt({network:r}),i=t.getGlobalInputCount(),o=t.getGlobalOutputCount();for(let e=0;e<i;e++){const r=t.getInputWitnessUtxo(e),i=t.getInputBip32Derivation(e,s);a.addInput({nonWitnessUtxo:t.getInputNonWitnessUtxo(e),witnessUtxo:r?{value:r.amount,script:r.scriptPubKey}:void 0,hash:t.getInputPreviousTxid(e),index:t.getInputOutputIndex(e),bip32Derivation:i?[{path:n,pubkey:s,masterFingerprint:i.masterFingerprint}]:void 0})}for(let s=0;s<o;s++)a.addOutput({value:t.getOutputAmount(s),address:e.address.fromOutputScript(t.getOutputScript(s),r)});return a}class Z{constructor(t,r){this.pubkey=t,this.provider=r;try{this.ecPair=e.ECPair.fromPublicKey(t)}catch(e){throw new Error("Not a valid public key.")}}ecPair;getAddressP2PKH(){return e.payments.p2pkh({pubkey:this.ecPair.publicKey,network:this.provider.getNetwork()}).address}getAddressBech32(){return K(this.ecPair.publicKey,this.provider.getNetwork())}async getUTXOs(){return this.provider.getUTXOs(this.getAddressBech32(),!0)}async getBalances(){return this.provider.getBalances(this.getAddressBech32())}async getUtxoBalance(){return this.provider.getUtxoBalance(this.getAddressBech32())}connect(e){this.provider=e}getProvider(){return this.provider}getPublicKey(){return this.ecPair.publicKey}createTransferTx(e,t,r,s){return V(e,this.getAddressBech32(),t,r,s,this.provider.getNetwork())}}class ee extends Z{keypair;constructor(t,r){const s=e.ECPair.fromPrivateKey(t);super(s.publicKey,r),this.keypair=s}static async fromMnemonic(e,t,r,s=H.BIP44){if(t<0)throw new Error("Account index must be >= 0");if(!u.validateMnemonic(e))throw new Error("Invalid mnemonic phrase.");const n=await u.mnemonicToSeed(e),a=m.fromSeed(n),i=R(t,s,"EVM"),o=a.derivePath(i);if(!o.privateKey)throw new Error("Unable to derive private key from the given mnemonic.");return new ee(o.privateKey,r)}signTx(e,t){const r=E(e,t,this.provider.getNetwork());return Promise.resolve(this.signPsbt(r))}static fromEthersWallet(e,t){const r=e.privateKey;if(!r)throw new Error("Unable to get private key from ethers wallet.");const s=Buffer.from(r.substring(2),"hex");return new ee(s,t)}signPsbt(e){return e.signAllInputs(this.keypair),e.validateSignaturesOfAllInputs(),e.finalizeAllInputs(),e.extractTransaction()}}const te=e.networks;var re=(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))(re||{});const se=e=>{switch(e){case"C":return h.EVM;case"X":return h.AVM;case"P":return h.PVM;default:throw new Error(`Unable to get VM type for chain "${e}"`)}};const{getTransferableInputsByTx:ne,AddressMaps:ae}=h.utils,ie=async({tx:e,fromAddressBytes:t,provider:r,credentials:s,utxos:n})=>{const a=ne(e);let i=ae.fromTransferableInputs(a,n,BigInt(Math.floor((new Date).getTime()/1e3)),t);if((e=>h.pvmSerial.isCreateChainTx(e)||h.pvmSerial.isAddSubnetValidatorTx(e)||h.pvmSerial.isRemoveSubnetValidatorTx(e)||h.pvmSerial.isTransformSubnetTx(e)||h.pvmSerial.isTransferSubnetOwnershipTx(e)||h.pvmSerial.isConvertSubnetToL1Tx(e))(e))try{const t=await(async({tx:e,provider:t,addressMaps:r})=>{const s=e.getSubnetAuth().values(),n=await t.getApiP().getSubnet({subnetID:e.getSubnetID().value()}),a=h.OutputOwners.fromNative(n.controlKeys.map((e=>h.utils.parse(e)[2])),BigInt(n.locktime),Number(n.threshold)).addrs.reduce(((e,t,r)=>(s.includes(r)&&e.push([t,r]),e)),[]);return r.push(new h.utils.AddressMap(a)),r})({tx:e,provider:r,addressMaps:i});return new h.UnsignedTx(e,n,t,s)}catch(e){throw new Error(`Error while preparing subnet authorization data: ${e.message}`)}else h.pvmSerial.isDisableL1ValidatorTx(e)&&(i=await async function(e,t,r){try{const{deactivationOwner:s}=await r.getApiP().getL1Validator(t.validationId.toString()),n=t.getDisableAuth().values(),a=s.addresses.reduce(((e,t,r)=>(n.includes(r)&&e.push([t,r]),e)),[]);return e.push(new h.utils.AddressMap(a)),e}catch(e){throw new Error(`Error while preparing disableAuth data: ${e.message}`)}}(i,e,r));return new h.UnsignedTx(e,n,i,s)},{bufferToHex:oe,packTx:de}=h.utils,{publicKeyBytesToAddress:ue,recoverPublicKey:ce}=h.secp256k1,le=new h.Signature(new Uint8Array(Array(65).fill(0))),pe=(e,t)=>{const r=Math.max(...e);if(!isFinite(r))throw new Error("Error while adding placeholder signatures for the provided indices.");const s=new Array(r+1).fill(le);if(!t)return s;const{unsignedTx:n,credentialIndex:a}=t,i=n.getCredentials()[a];if(!i)return s;const o=de(n.getTx()),d=w.sha256(o),u=le.toString();for(const e of i.toJSON()){if(e.toString()===u)continue;const t=ce(d,e.toBytes()),r={toHex:()=>oe(ue(t))},i=n.addressMaps.getSigIndicesForAddress(r,!1)??[];for(const t of i)t[0]===a&&(s[t[1]]=e)}return s};function he(e){return h.utils.bufferToHex(h.utils.addChecksum(e.toBytes()))}const{getManagerForVM:ge,hexToBuffer:me,unpackWithManager:fe}=h.utils,xe=async({transactionHex:e,chainAlias:t,provider:r,utxos:s})=>{const n=se(t);if(n===h.EVM)throw new Error("EVM transactions are not supported");const a=me(e),i=fe(n,a),o=await(async({tx:e,txBytes:t,provider:r,vm:s,utxos:n})=>{try{const a=ge(s).unpack(t,h.avaxSerial.SignedTx),i=await ie({tx:e,utxos:n,provider:r,credentials:a.getCredentials()});return e.getSigIndices().map(((e,t)=>new h.Credential(pe(e,{unsignedTx:i,credentialIndex:t}))))}catch(t){return e.getSigIndices().map((e=>new h.Credential(pe(e))))}})({tx:i,txBytes:a,provider:r,vm:n,utxos:s});return ie({tx:i,provider:r,credentials:o,utxos:s})},{parseBech32:ve,format:ye}=h.utils,{publicKeyBytesToAddress:we}=h.secp256k1;class be{constructor(e,t){this.baseUrl=e,this.context=t;const r=`${e}/ext/bc/C/rpc`;this.evmRpc=new n.JsonRpcProvider(r)}evmRpc;async getEvmFeeData(){return this.evmRpc.getFeeData()}getContext(){return this.context}getChainID(e){switch(e){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 h.networkIDs.getHRP(this.getNetworkID())}getApiX(){return new h.avm.AVMApi(this.baseUrl)}getApiP(){return new h.pvm.PVMApi(this.baseUrl)}getApiC(){return new h.evm.EVMApi(this.baseUrl)}getInfo(){return new h.info.InfoApi(this.baseUrl)}getApi(e){switch(e){case"X":return this.getApiX();case"P":return this.getApiP();case"C":return this.getApiC()}}getAvaxID(){return this.getContext().avaxAssetID}getAddress(e,r){const s=t.strip0x(n.SigningKey.computePublicKey(e,!0)),a=Buffer.from(s,"hex"),i=we(a);return ye(r,this.getHrp(),i)}getAddressFromBuffer(e,t){return ye(t,this.getHrp(),e)}formatAddress(e,t){const[,r]=ve(e);return ye(t,this.getHrp(),r)}getApiByVM(e){switch(e){case"AVM":return this.getApiX();case"PVM":return this.getApiP();case"EVM":return this.getApiC()}}getApiByChainID(e){switch(e){case this.context.xBlockchainID:return this.getApiX();case this.context.pBlockchainID:return this.getApiP();case this.context.cBlockchainID:return this.getApiC()}}async issueTx(e){const t=e.unsignedTx.getVM(),r=he(e);return this.issueTxHex(r,t)}async issueTxHex(e,t){return this.getApiByVM(t).issueTx({tx:e})}async waitForTransaction(e,t,r=6e4){const s=this.getApiByVM(t),n=Date.now();return new Promise(((t,a)=>{const i=async()=>{let o;switch(r&&n+r<Date.now()&&a(new Error("Timeout")),o=s instanceof h.evm.EVMApi?await s.getAtomicTxStatus(e):await s.getTxStatus({txID:e,includeReason:!0}),o.status){case"Accepted":case"Committed":return void t({success:!0});case"Dropped":case"Rejected":return void t({success:!1});default:setTimeout((()=>{i()}),1e3)}};i()}))}}const Ae={weights:h.Common.createDimensions({bandwidth:1,dbRead:1e3,dbWrite:1e3,compute:4}),maxCapacity:BigInt(1e6),maxPerSecond:BigInt(1e5),targetPerSecond:BigInt(5e4),minPrice:BigInt(1),excessConversionConstant:BigInt(2164043)},Te={xBlockchainID:"2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM",pBlockchainID:"11111111111111111111111111111111LpoYY",cBlockchainID:"2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5",avaxAssetID:"FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z",baseTxFee:BigInt(1e6),createAssetTxFee:BigInt(1e7),networkID:1,hrp:"avax",platformFeeConfig:Ae},Ie={xBlockchainID:"2JVSBoinj9C2J33VntvzYtVJNZdN2NKiwwKjcumHUWEb5DbBrm",pBlockchainID:"11111111111111111111111111111111LpoYY",cBlockchainID:"yH8D7ThNJkxmtkuv2jgBa4P1Rn3Qpr4pPr7QYNfcdoS6k6HWp",avaxAssetID:"U8iRqJoiJm8xZHAacmvYyZVwqQx6uDNtQeP3CQ6fcgQk3JqnK",baseTxFee:BigInt(1e6),createAssetTxFee:BigInt(1e7),networkID:5,hrp:"fuji",platformFeeConfig:Ae},Se={xBlockchainID:"2piQ2AVHCjnduiWXsSY15DtbVuwHE2cwMHYnEXHsLL73BBkdbV",pBlockchainID:"11111111111111111111111111111111LpoYY",cBlockchainID:"vV3cui1DsEPC3nLCGH9rorwo8s6BYxM2Hz4QFE5gEYjwTqAu",avaxAssetID:"22jjRVdyTJiAEtcZciAVR8bTFyVDUVoo1T3o5PiDspQSZ2maXR",baseTxFee:1000000n,createAssetTxFee:1000000n,networkID:76,hrp:"custom",platformFeeConfig:Ae};class Pe extends be{constructor(e,t){super(e,t)}static async fromBaseURL(e){const t=await h.Context.getContextFromURI(e);try{await new h.info.InfoApi(e).getUpgradesInfo();return new Pe(e,t)}catch{return new Pe(e,t)}}static getDefaultMainnetProvider(){return new Pe(A.AVALANCHE_XP_NETWORK.rpcUrl,Te)}static getDefaultFujiProvider(){return new Pe(A.AVALANCHE_XP_TEST_NETWORK.rpcUrl,Ie)}static getDefaultDevnetProvider(){return new Pe(A.AVALANCHE_P_DEV_NETWORK.rpcUrl,Se)}}const{bytesCompare:Be,parseBech32:Ce}=h.utils,ke=(e,t)=>"P"===t,Ee=(e,t,r)=>{const s=ke(0,t)?e.amount:e.asset?.amount;return new h.TransferOutput(new h.BigIntPr(BigInt(s)),h.OutputOwners.fromNative(e.addresses.map((e=>Ce(e)[1])).sort(Be),BigInt(r??0),e.threshold))},De=(e,t)=>{const r=((e,t)=>{const r=t===b.Network.FUJI,{cBlockchainID:s,xBlockchainID:n,pBlockchainID:a}=r?Ie:Te;if(s===e)return"C";if(n===e)return"X";if(a===e)return"P";throw new Error(`Unknown chainId "${e}"`)})(e.createdOnChainId,t),s=ke(0,r)?e.txHash:e.creationTxHash,n=ke(0,r)?e.assetId:e.asset?.assetId;return new h.Utxo(h.avaxSerial.UTXOID.fromNative(s,Number(e.outputIndex)),h.Id.fromString(n),((e,t)=>ke(0,t)?e.stakeableLocktime?new h.pvmSerial.StakeableLockOut(new h.BigIntPr(BigInt(e.stakeableLocktime??0)),Ee(e,t,e.platformLocktime??0)):Ee(e,t,e.platformLocktime):Ee(e,t,e.locktime))(e,r))},{unpackWithManager:Me,parse:Ve,bufferToHex:Ke,AddressMaps:Ue,AddressMap:Oe}=h.utils;function Ne(e){const t=Buffer.from(e,"utf8"),r=Buffer.alloc(4);r.writeUInt32BE(t.length,0);const s=Buffer.from(`Avalanche Signed Message:\n${r}${e}`,"utf8");return T("sha256").update(s).digest()}const _e=1024,Le=1024;async function Xe(e,t,r){const s=e.slice(0,_e),n=e.slice(_e),a=await Fe(t,{...r,addresses:s});if(n.length){const s=await Xe(n,t,{...r,addresses:e});return a.merge(s)}return a}async function Fe(e,t){if(t.addresses.length>_e)throw new Error(`Can not get UTXOs for more than ${_e} addresses.`);const{endIndex:r,utxos:s}=await e.getUTXOs(t),n=new h.utils.UtxoSet(s);if(s.length>=Le){const s=await Fe(e,{...t,startIndex:r});return n.merge(s)}return n}function He(){return BigInt(Math.floor(Date.now()/1e3))}const{getUtxoInfo:Re}=h.utils;async function $e(e,t){const r=e.slice(0,256),s=e.slice(256),n=await t.getStake({addresses:r});if(s.length){const e=await $e(s,t);return{staked:n.staked+e.staked,stakedOutputs:[...n.stakedOutputs,...e.stakedOutputs]}}return n}const{getTransferableInputsByTx:qe,hexToBuffer:We,unpackWithManager:je}=h.utils;function Je(e,t=!0){try{if(t){const[t]=h.utils.parse(e);if(!["X","P","C"].includes(t))return!1}else h.utils.parseBech32(e);return!0}catch(e){return!1}}const ze=e=>{if([Te.xBlockchainID,Ie.xBlockchainID,Se.xBlockchainID].includes(e))return"AVM";if([Te.pBlockchainID,Ie.pBlockchainID,Se.pBlockchainID].includes(e))return"PVM";if([Te.cBlockchainID,Ie.cBlockchainID,Se.cBlockchainID].includes(e))return"EVM";throw new Error("Unknown chain id. Failed to get alias.")},Ge=(e,t)=>e.reduce(((e,r)=>r.assetId.toString()!==t?e:e+r.output.amount()),BigInt(0)),Ye=(e,t)=>e.reduce(((e,r)=>r.assetId.toString()!==t?e:e+r.input.amount()),BigInt(0));var Qe={parseCreateSubnetTx:e=>h.pvmSerial.isCreateSubnetTx(e)?({feeData:t,provider:r})=>({type:re.CreateSubnet,chain:e.getVM(),threshold:e.getSubnetOwners().threshold.value(),controlKeys:e.getSubnetOwners().addrs.map((e=>`P-${e.toString(r.getHrp())}`)),...t}):null,parseCreateChainTx:e=>h.pvmSerial.isCreateChainTx(e)?({feeData:t})=>({type:re.CreateChain,chain:e.getVM(),subnetID:e.getSubnetID().value(),chainName:e.chainName.value(),chainID:e.getBlockchainId(),vmID:e.vmID.value(),fxIDs:e.fxIds.map((e=>e.value())),genesisData:e.genesisData.toString(),...t}):null,parseAddSubnetValidatorTx:e=>h.pvmSerial.isAddSubnetValidatorTx(e)?({feeData:t})=>({type:re.AddSubnetValidator,chain:e.getVM(),stake:e.subnetValidator.validator.weight.value(),nodeID:e.subnetValidator.validator.nodeId.value(),start:e.subnetValidator.validator.startTime.value().toString(),end:e.subnetValidator.validator.endTime.value().toString(),subnetID:e.getSubnetID().value(),...t}):null,parseRemoveSubnetValidatorTx:e=>h.pvmSerial.isRemoveSubnetValidatorTx(e)?({feeData:t})=>({type:re.RemoveSubnetValidator,chain:e.getVM(),nodeID:e.nodeId.toString(),subnetID:e.getSubnetID().value(),...t}):null,parseImportTx:e=>h.pvmSerial.isImportTx(e)||h.avmSerial.isImportTx(e)||h.evmSerial.isImportTx(e)?h.evmSerial.isImportTx(e)?({feeData:t,assetId:r})=>({type:re.Import,chain:e.getVM(),source:ze(e.sourceChain.value()),amount:Ye(e.importedInputs,r),...t}):({feeData:t,assetId:r})=>({type:re.Import,chain:e.getVM(),source:ze(e.sourceChain.value()),amount:Ye(e.ins,r),...t}):null,parseExportTx:e=>h.pvmSerial.isExportTx(e)||h.avmSerial.isExportTx(e)||h.evmSerial.isExportTx(e)?h.evmSerial.isExportTx(e)?({feeData:t,assetId:r})=>({type:re.Export,chain:e.getVM(),destination:ze(e.destinationChain.toString()),amount:Ge(e.exportedOutputs,r),...t}):({feeData:t,assetId:r})=>({type:re.Export,chain:e.getVM(),destination:ze(e.destination.value()),amount:Ge(e.outs,r),...t}):null,parseBaseTx:e=>h.avmSerial.isAvmBaseTx(e)||h.pvmSerial.isPvmBaseTx(e)?async({feeData:t,currentAddress:r,provider:s})=>{const n=e.baseTx,a=await(async(e,t)=>{const r=e.baseTx,s=new Set;if(r.outputs.forEach((e=>{s.add(e.assetId.value())})),h.avmSerial.isAvmBaseTx(e)){const e=await Promise.all([...s.values()].map((e=>t.getApiX().getAssetDescription(e))));return r.outputs.reduce(((r,n)=>{if(n.output instanceof h.TransferOutput){const a=n.assetId.value(),i=[...s.values()].indexOf(a),o=e[i],d=n.output.outputOwners.addrs.map((e=>`X-${e.toString(t.getContext().hrp)}`));return[...r,{assetId:a,amount:n.output.amount(),locktime:n.output.getLocktime(),threshold:BigInt(n.output.getThreshold()),assetDescription:o,owners:d,isAvax:t.getContext().avaxAssetID===a}]}return r}),[])}return r.outputs.reduce(((e,r)=>{if(r.output instanceof h.TransferOutput){const s=r.assetId.value(),n=r.output.outputOwners.addrs.map((e=>`P-${e.toString(t.getContext().hrp)}`));return[...e,{assetId:s,amount:r.output.amount(),locktime:r.output.getLocktime(),threshold:BigInt(r.output.getThreshold()),owners:n,isAvax:t.getContext().avaxAssetID===s}]}return e}),[])})(e,s),i=He(),o=a.filter((e=>!(1===e.owners.length&&e.owners[0]===r&&e.locktime<=i)));return{type:re.Base,chain:e.getVM(),outputs:o,memo:I(Buffer.from(n.memo.toBytes()).toString("utf-8",4)),...t}}:null,parseAddPermissionlessValidatorTx:e=>{if(!h.pvmSerial.isAddPermissionlessValidatorTx(e))return null;let t,r;return h.pvmSerial.isSigner(e.signer)&&(r=h.utils.bufferToHex(e.signer.proof.publicKey),t=h.utils.bufferToHex(e.signer.proof.signature)),({feeData:s})=>({type:re.AddPermissionlessValidator,chain:e.getVM(),stake:e.subnetValidator.validator.weight.value(),nodeID:e.subnetValidator.validator.nodeId.value(),start:e.subnetValidator.validator.startTime.value().toString(),end:e.subnetValidator.validator.endTime.value().toString(),subnetID:e.subnetValidator.subnetId.value(),delegationFee:e.shares.value(),stakeOuts:e.stake,rewardOwner:e.getValidatorRewardsOwner(),delegationRewardOwner:e.getDelegatorRewardsOwner(),signer:e.signer,publicKey:r,signature:t,...s})},parseAddPermissionlessDelegatorTx:e=>h.pvmSerial.isAddPermissionlessDelegatorTx(e)?({feeData:t})=>({type:re.AddPermissionlessDelegator,chain:e.getVM(),stake:e.subnetValidator.validator.weight.value(),nodeID:e.subnetValidator.validator.nodeId.value(),start:e.subnetValidator.validator.startTime.value().toString(),end:e.subnetValidator.validator.endTime.value().toString(),subnetID:e.subnetValidator.subnetId.value(),stakeOuts:e.stake,delegatorRewardsOwner:e.getDelegatorRewardsOwner(),...t}):null,parseTransferSubnetOwnershipTx:e=>h.pvmSerial.isTransferSubnetOwnershipTx(e)?({feeData:t,provider:r})=>({type:re.TransferSubnetOwnership,chain:e.getVM(),subnetID:e.subnetID.value(),threshold:e.getSubnetOwners().threshold.value(),controlKeys:e.getSubnetOwners().addrs.map((e=>`P-${e.toString(r.getHrp())}`)),...t}):null,parseConvertSubnetTx:e=>h.pvmSerial.isConvertSubnetToL1Tx(e)?({feeData:t,provider:r})=>{const s=r.getHrp(),n=e=>`P-${e.toString(s)}`;return{type:re.ConvertSubnetToL1,chain:e.getVM(),managerAddress:n(h.Address.fromHex(e.address.toString("hex"))),validators:e.validators.map((e=>({nodeId:h.NodeId.fromHex(e.nodeId.toString("hex")).toString(),stake:e.weight.value(),balance:e.balance.value(),remainingBalanceOwners:e.remainingBalanceOwner.addresses.map(n),deactivationOwners:e.deactivationOwner.addresses.map(n)}))),chainID:e.chainID.value(),subnetID:e.subnetID.value(),...t}}:null,parseRegisterL1ValidatorTx:e=>h.pvmSerial.isRegisterL1ValidatorTx(e)?({feeData:t})=>({type:re.RegisterL1Validator,chain:e.getVM(),balance:e.balance.value(),...t}):null,parseIncreaseL1ValidatorBalanceTx:e=>h.pvmSerial.isIncreaseL1ValidatorBalanceTx(e)?({feeData:t})=>({type:re.IncreaseL1ValidatorBalance,chain:e.getVM(),balance:e.balance.value(),validationId:e.validationId.toString(),...t}):null,parseSetL1ValidatorWeightTx:e=>h.pvmSerial.isSetL1ValidatorWeightTx(e)?({feeData:t})=>({type:re.SetL1ValidatorWeight,chain:e.getVM(),...t}):null,parseDisableL1ValidatorTx:e=>h.pvmSerial.isDisableL1ValidatorTx(e)?({feeData:t})=>({type:re.DisableL1Validator,chain:e.getVM(),validationId:e.validationId.toString(),...t}):null};const{getBurnedAmountByTx:Ze,getOutputAmounts:et,getInputAmounts:tt,validateBurnedAmount:rt}=h.utils;function st(e,t,r){return[...e].sort(((e,s)=>{for(let n=0;n<t.length;n++){const a=t[n];if(e[a]>s[a])return"asc"===r?1:-1;if(e[a]<s[a])return"asc"===r?-1:1}return 0}))}function nt(e){const t=He(),r=e.map((e=>({utxo:e,...h.utils.getUtxoInfo(e)}))),s=r.filter((e=>e.stakeableLocktime<=t)),n=r.filter((e=>e.stakeableLocktime>t)),a=st(s,["amount"],"desc"),i=st(n,["stakeableLocktime","amount"],"desc"),[o,...d]=a;return[...o?[o]:[],...i,...d].map((e=>e.utxo))}function at(e,t){return st(e.map((e=>({utxo:e,...h.utils.getUtxoInfo(e)}))),["amount"],t?"desc":"asc").map((e=>e.utxo))}const it=e=>at(e,!0),ot=e=>at(e,!1);const{getUtxoInfo:dt}=h.utils;var ut=(e=>(e.ExportP="ExportP",e.ImportP="ImportP",e.AddPermissionlessValidator="AddPermissionlessValidator",e.AddPermissionlessDelegator="AddPermissionlessDelegator",e.BaseP="BaseP",e.ConsolidateP="ConsolidateP",e))(ut||{});const ct="NodeID-8TArWpFgH3sazEH8qP4gUjtGtFMvjw1aR",lt="11111111111111111111111111111111LpoYY",pt=(e,t)=>e.reduce(((e,t)=>e+dt(t).amount),BigInt(0))-t,ht={BaseP:{sortFunction:it,unsignedTxBuilder:(e,t,r)=>{const s=e.getProvider().getContext();return e.baseTX({utxoSet:new h.utils.UtxoSet(t),chain:"P",toAddress:e.getCurrentAddress("P"),amountsPerAsset:{[s.avaxAssetID]:pt(t,s.baseTxFee)},feeState:r})}},ConsolidateP:{sortFunction:ot,unsignedTxBuilder:(e,t,r)=>{const s=e.getProvider().getContext();return e.consolidateP({utxoSet:new h.utils.UtxoSet(t),amount:pt(t,s.baseTxFee),feeState:r})}},AddPermissionlessValidator:{sortFunction:nt,unsignedTxBuilder:(e,t,r)=>e.addPermissionlessValidator({utxoSet:new h.utils.UtxoSet(t),nodeId:ct,start:He(),end:He()+BigInt(1e3),weight:pt(t,e.getProvider().getContext().baseTxFee),subnetId:lt,shares:5,feeState:r,fromAddresses:void 0,rewardAddresses:void 0,delegatorRewardAddresses:void 0,publicKey:Buffer.from(h.utils.hexToBuffer("0x8f95423f7142d00a48e1014a3de8d28907d420dc33b3052a6dee03a3f2941a393c2351e354704ca66a3fc29870282e15")),signature:Buffer.from(h.utils.hexToBuffer("0x86a3ab4c45cfe31cae34c1d06f212434ac71b1be6cfe046c80c162e057614a94a5bc9f1ded1a7029deb0ba4ca7c9b71411e293438691be79c2dbf19d1ca7c3eadb9c756246fc5de5b7b89511c7d7302ae051d9e03d7991138299b5ed6a570a98"))})},AddPermissionlessDelegator:{sortFunction:nt,unsignedTxBuilder:(e,t,r)=>e.addPermissionlessDelegator({utxoSet:new h.utils.UtxoSet(t),nodeId:ct,start:He(),end:He()+BigInt(1e3),weight:pt(t,e.getProvider().getContext().baseTxFee),subnetId:lt,feeState:r})},ExportP:{sortFunction:it,unsignedTxBuilder:(e,t,r)=>e.exportP({amount:pt(t,e.getProvider().getContext().baseTxFee),utxoSet:new h.utils.UtxoSet(t),destination:"X",feeState:r})},ImportP:{sortFunction:it,unsignedTxBuilder:(e,t,r)=>e.importP({utxoSet:new h.utils.UtxoSet(t),sourceChain:"X",feeState:r})}};function gt(e){return S.validateString(e,!0)&&6===e.split("/").length}function mt(e){if("object"!=typeof e||!e)throw new Error("feeState parameter is required post E-upgrade")}const{parse:ft,hexToBuffer:xt}=h.utils;class vt{constructor(e){this.provider=e}setProvider(e){this.provider=e}getProvider(){return this.provider}async getUTXOs(e){const t=this.provider.getApi(e);return Xe(this.getAddresses(e),t)}async getStake(){const e=this.provider.getApiP();return $e(this.getAddresses("P"),e)}async getAtomicUTXOs(e,t){if(e===t)throw new Error("Chain can not be the same as source chain.");const r=this.provider.getApi(e),s=this.provider.getChainID(t);return Xe(this.getAddresses(e),r,{sourceChain:s,addresses:[]})}async getNonce(){const e=this.getAddressEVM();return await this.provider.evmRpc.getTransactionCount(e)}exportX(e,t,r,s){s=s||this.getCurrentAddress(r);const n=ft(s)[2],a=this.provider.getAvaxID(),i=h.TransferableOutput.fromNative(a,e,[n]),o=at(t.getUTXOs(),!0),d=this.provider.getChainID(r),u=this.getAddresses("X").map((e=>ft(e)[2])),c=ft(this.getChangeAddress("X"))[2];return h.avm.newExportTx(this.provider.getContext(),d,u,o,[i],{threshold:1,changeAddresses:[c]})}importP({utxoSet:e,sourceChain:t,toAddress:r,threshold:s,feeState:n,locktime:a}){const i=this.provider.getChainID(t),o=this.getAddresses("P").map((e=>ft(e)[2]));ft(this.getChangeAddress("P"))[2],r=r||this.getCurrentAddress("P");const d=ft(r)[2],u=e.getUTXOs();return mt(n),h.pvm.newImportTx({fromAddressesBytes:o,utxos:u,toAddressesBytes:[d],sourceChainId:i,threshold:s,feeState:n,locktime:a},this.provider.getContext())}importX(e,t,r){const s=this.provider.getChainID(t),n=this.getAddresses("X").map((e=>ft(e)[2])),a=ft(this.getChangeAddress("X"))[2];r=r||this.getCurrentAddress("X");const i=ft(r)[2];return h.avm.newImportTx(this.provider.getContext(),s,e.getUTXOs(),[i],n,{changeAddresses:[a]})}importC(e,r,s,n,a){const i=this.provider.getChainID(r),o=this.getAddresses("C").map((e=>ft(e)[2]));a=a||this.getAddressEVM();const d=Buffer.from(t.strip0x(a),"hex");return h.evm.newImportTxFromBaseFee(this.provider.getContext(),d,o,e.getUTXOs(),i,s,n)}exportC(e,t,r,s,n){const a=xt(this.getAddressEVM()),i=this.provider.getChainID(t);n=n||this.getCurrentAddress(t);const o=ft(n)[2],d=s/BigInt(1e9);return h.evm.newExportTxFromBaseFee(this.provider.getContext(),d,e,i,a,[o],r)}exportP({amount:e,utxoSet:t,destination:r,feeState:s,toAddress:n}){n=n||this.getCurrentAddress(r);const a=ft(n)[2],i=this.provider.getAvaxID(),o=h.TransferableOutput.fromNative(i,e,[a]),d=at(t.getUTXOs(),!0),u=this.provider.getChainID(r),c=this.getAddresses("P").map((e=>ft(e)[2])),l=ft(this.getChangeAddress("P"))[2];return mt(s),h.pvm.newExportTx({changeAddressesBytes:[l],fromAddressesBytes:c,utxos:d,outputs:[o],destinationChainId:u,feeState:s},this.provider.getContext())}consolidateP({utxoSet:e,amount:t,feeState:r,toAddress:s,options:n}){const a=ot(e.getUTXOs());s=s??this.getCurrentAddress("P");const i=ft(s)[2],o=this.provider.getContext(),d=[h.TransferableOutput.fromNative(o.avaxAssetID,t,[i])],u=this.getAddresses("P").map((e=>ft(e)[2])),c=ft(this.getChangeAddress("P"))[2],l=n?.changeAddresses??[c];return mt(r),h.pvm.newBaseTx({changeAddressesBytes:l,fromAddressesBytes:u,utxos:a,outputs:d,minIssuanceTime:n?.minIssuanceTime,memo:n?.memo,feeState:r},o)}baseTX({utxoSet:e,chain:t,toAddress:r,amountsPerAsset:s,feeState:n,options:a,fromAddresses:i}){const[o,d,u]=ft(r);if(o!==t||d!==this.provider.getHrp())throw new Error(`Invalid recipient address "${r}"`);const c=Object.entries(s).map((([e,t])=>h.TransferableOutput.fromNative(e,t,[u]))),l=at(e.getUTXOs(),!0),p=(i??this.getAddresses(t)).map((e=>ft(e)[2])),g=ft(this.getChangeAddress("P"))[2],m=a?.changeAddresses??[g];return"X"===t?h.avm.newBaseTx(this.provider.getContext(),p,l,c,a):(mt(n),h.pvm.newBaseTx({changeAddressesBytes:m,fromAddressesBytes:p,utxos:l,outputs:c,minIssuanceTime:a?.minIssuanceTime,memo:a?.memo,feeState:n},this.provider.getContext()))}convertSubnetToL1({utxoSet:e,chainId:t,subnetId:r,subnetAuth:s,feeState:n,address:a,validators:i,options:o,fromAddresses:d}){const u=(d??this.getAddresses("P")).map((e=>ft(e)[2])),c=ft(this.getChangeAddress("P"))[2],l=o?.changeAddresses??[c],p=i.map((({nodeId:e,pubKey:t,signature:r,balance:s,weight:n,deactivationOwner:a,remainingBalanceOwner:i})=>{const o=new h.pvmSerial.ProofOfPossession(Uint8Array.from(h.utils.hexToBuffer(t)),Uint8Array.from(h.utils.hexToBuffer(r))),d=h.PChainOwner.fromNative(i.addresses.map((e=>ft(e)[2])),i.threshold??1),u=h.PChainOwner.fromNative(a.addresses.map((e=>ft(e)[2])),a.threshold??1);return h.L1Validator.fromNative(e,n,s,o,d,u)}));return h.pvm.newConvertSubnetToL1Tx({changeAddressesBytes:l,validators:p,fromAddressesBytes:u,address:ft(a)[2],chainId:t,subnetId:r,subnetAuth:s,feeState:n,utxos:at(e.getUTXOs(),!0)},this.provider.getContext())}registerL1Validator({utxoSet:e,balance:t,signature:r,message:s,feeState:n,fromAddresses:a,options:i}){const o=(a??this.getAddresses("P")).map((e=>ft(e)[2])),d=ft(this.getChangeAddress("P"))[2],u=i?.changeAddresses??[d];return h.pvm.newRegisterL1ValidatorTx({utxos:at(e.getUTXOs(),!0),balance:t,blsSignature:Uint8Array.from(h.utils.hexToBuffer(r)),changeAddressesBytes:u,feeState:n,fromAddressesBytes:o,memo:i?.memo,message:Uint8Array.from(h.utils.hexToBuffer(s)),minIssuanceTime:i?.minIssuanceTime},this.provider.getContext())}setL1ValidatorWeight({utxoSet:e,feeState:t,message:r,options:s,fromAddresses:n}){const a=(n??this.getAddresses("P")).map((e=>ft(e)[2])),i=ft(this.getChangeAddress("P"))[2],o=s?.changeAddresses??[i];return h.pvm.newSetL1ValidatorWeightTx({utxos:at(e.getUTXOs(),!0),changeAddressesBytes:o,feeState:t,fromAddressesBytes:a,memo:s?.memo,message:Uint8Array.from(h.utils.hexToBuffer(r)),minIssuanceTime:s?.minIssuanceTime},this.provider.getContext())}disableL1Validator({utxoSet:e,feeState:t,options:r,fromAddresses:s,disableAuth:n,validationId:a}){const i=(s??this.getAddresses("P")).map((e=>ft(e)[2])),o=ft(this.getChangeAddress("P"))[2],d=r?.changeAddresses??[o];return h.pvm.newDisableL1ValidatorTx({disableAuth:n,validationId:a,utxos:at(e.getUTXOs(),!0),changeAddressesBytes:d,feeState:t,fromAddressesBytes:i,memo:r?.memo,minIssuanceTime:r?.minIssuanceTime},this.provider.getContext())}increaseL1ValidatorBalance({utxoSet:e,feeState:t,options:r,fromAddresses:s,balance:n,validationId:a}){const i=(s??this.getAddresses("P")).map((e=>ft(e)[2])),o=ft(this.getChangeAddress("P"))[2],d=r?.changeAddresses??[o];return h.pvm.newIncreaseL1ValidatorBalanceTx({balance:n,validationId:a,utxos:at(e.getUTXOs(),!0),changeAddressesBytes:d,feeState:t,fromAddressesBytes:i,memo:r?.memo,minIssuanceTime:r?.minIssuanceTime},this.provider.getContext())}createBlockchain({utxoSet:e,subnetId:t,chainName:r,vmID:s,fxIds:n,genesisData:a,subnetAuth:i,feeState:o,options:d,fromAddresses:u}){const c=at(e.getUTXOs(),!0),l=(u??this.getAddresses("P")).map((e=>ft(e)[2])),p=ft(this.getChangeAddress("P"))[2],g=d?.changeAddresses??[p];return mt(o),h.pvm.newCreateChainTx({chainName:r,feeState:o,fromAddressesBytes:l,fxIds:n,genesisData:a,subnetAuth:i,subnetId:t,utxos:c,vmId:s,changeAddressesBytes:g},this.provider.getContext())}createSubnet({utxoSet:e,rewardAddresses:t,feeState:r,fromAddresses:s,options:n,threshold:a,locktime:i}){const o=at(e.getUTXOs(),!0),d=(s??this.getAddresses("P")).map((e=>ft(e)[2])),u=ft(this.getChangeAddress("P"))[2],c=n?.changeAddresses??[u],l=t.map((e=>ft(e)[2]));return mt(r),h.pvm.newCreateSubnetTx({fromAddressesBytes:d,changeAddressesBytes:c,utxos:o,minIssuanceTime:n?.minIssuanceTime,memo:n?.memo,feeState:r,threshold:a,locktime:i,subnetOwners:l},this.provider.getContext())}addSubnetValidator({utxoSet:e,nodeId:t,start:r,end:s,weight:n,subnetId:a,subnetAuth:i,feeState:o,fromAddresses:d,options:u}){const c=at(e.getUTXOs(),!0),l=(d??this.getAddresses("P")).map((e=>ft(e)[2])),p=ft(this.getChangeAddress("P"))[2],g=u?.changeAddresses??[p];return mt(o),h.pvm.newAddSubnetValidatorTx({changeAddressesBytes:g,fromAddressesBytes:l,utxos:c,minIssuanceTime:u?.minIssuanceTime,memo:u?.memo,nodeId:t,start:r,end:s,weight:n,subnetId:a,subnetAuth:i,feeState:o},this.provider.getContext())}addPermissionlessValidator({utxoSet:e,nodeId:t,start:r,end:s,weight:n,subnetId:a,shares:i,feeState:o,fromAddresses:d,rewardAddresses:u,delegatorRewardAddresses:c,publicKey:l,signature:p,options:g,threshold:m,locktime:f,stakingAssetId:x}){const v=nt(e.getUTXOs()),y=(d??this.getAddresses("P")).map((e=>ft(e)[2])),w=(u??[this.getCurrentAddress("P")]).map((e=>ft(e)[2])),b=(c??[this.getCurrentAddress("P")]).map((e=>ft(e)[2]));if(!(a!==h.networkIDs.PrimaryNetworkID.toString()||l&&p))throw new Error("Must provide public key and signature for primary subnet.");const A=ft(this.getChangeAddress("P"))[2],T=g?.changeAddresses??[A];return mt(o),h.pvm.newAddPermissionlessValidatorTx({fromAddressesBytes:y,delegatorRewardsOwner:b,utxos:v,minIssuanceTime:g?.minIssuanceTime,memo:g?.memo,changeAddressesBytes:T,nodeId:t,start:r,end:s,weight:n,subnetId:a,shares:i,feeState:o,publicKey:l,rewardAddresses:w,signature:p,locktime:f,threshold:m,stakingAssetId:x},this.provider.getContext())}addPermissionlessDelegator({utxoSet:e,nodeId:t,start:r,end:s,weight:n,subnetId:a,fromAddresses:i,rewardAddresses:o,options:d,locktime:u,feeState:c,threshold:l,stakingAssetId:p}){const g=nt(e.getUTXOs()),m=(i??this.getAddresses("P")).map((e=>ft(e)[2])),f=(o??[this.getCurrentAddress("P")]).map((e=>ft(e)[2])),x=ft(this.getChangeAddress("P"))[2],v=d?.changeAddresses??[x];return mt(c),h.pvm.newAddPermissionlessDelegatorTx({fromAddressesBytes:m,utxos:g,minIssuanceTime:d?.minIssuanceTime,memo:d?.memo,changeAddressesBytes:v,nodeId:t,start:r,end:s,weight:n,subnetId:a,rewardAddresses:f,locktime:u,stakingAssetId:p,threshold:l,feeState:c},this.provider.getContext())}removeSubnetValidator({utxoSet:e,nodeId:t,subnetId:r,subnetAuth:s,fromAddresses:n,feeState:a,options:i}){const o=at(e.getUTXOs(),!0),d=(n??this.getAddresses("P")).map((e=>ft(e)[2])),u=ft(this.getChangeAddress("P"))[2],c=i?.changeAddresses??[u];return mt(a),h.pvm.newRemoveSubnetValidatorTx({changeAddressesBytes:c,fromAddressesBytes:d,utxos:o,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,nodeId:t,subnetId:r,subnetAuth:s,feeState:a},this.provider.getContext())}transferSubnetOwnershipTx({utxoSet:e,subnetId:t,subnetAuth:r,subnetOwners:s,feeState:n,fromAddresses:a,options:i,threshold:o,locktime:d}){const u=at(e.getUTXOs(),!0),c=(a??this.getAddresses("P")).map((e=>ft(e)[2])),l=ft(this.getChangeAddress("P"))[2],p=i?.changeAddresses??[l],g=s.map((e=>ft(e)[2]));return mt(n),h.pvm.newTransferSubnetOwnershipTx({changeAddressesBytes:p,fromAddressesBytes:c,utxos:u,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,subnetId:t,subnetAuth:r,subnetOwners:g,feeState:n,threshold:o,locktime:d},this.provider.getContext())}}class yt extends vt{constructor(e,t,r){if(super(r),this.pubkeyXP=e,this.pubkeyC=t,33!==t.length||33!==e.length)throw new Error("Public key must be 33 byte compressed public key")}static fromPublicKey(e,r,s){const a=t.strip0x(n.SigningKey.computePublicKey(e,!0)),i=t.strip0x(n.SigningKey.computePublicKey(r,!0)),o=Buffer.from(a,"hex"),d=Buffer.from(i,"hex");return new yt(o,d,s)}static fromMnemonic(e,t,r,s){if(!u.validateMnemonic(e))throw new Error("Invalid mnemonic phrase.");if(!gt(r)||!gt(t))throw new Error("Not valid derivation path. Make sure it is a valid BIP44 path starting with m/");const n=u.mnemonicToSeedSync(e),a=m.fromSeed(n),i=a.derivePath(r),o=a.derivePath(t);return yt.fromPublicKey(o.publicKey,i.publicKey,s)}getAddress(e){const t="C"===e?this.pubkeyC:this.pubkeyXP;return this.provider.getAddress(t,e)}getAddressEVM(){return n.computeAddress(`0x${this.pubkeyC.toString("hex")}`)}getAddresses(e){return[this.getAddress(e)]}getChangeAddress(e){return this.getAddress(e)}getCurrentAddress(e){return this.getAddress(e)}}const wt={type:"zondax",getApp:e=>new P(e),async getVersion(e){const t=this.getApp(e);return(await t.getAppInfo()).appVersion},async getAddress(e,t,r={show:!1,hrp:"avax"}){const s=this.getApp(e);return{publicKey:(await s.getAddressAndPubKey(t.toString(),r.show,r.hrp)).publicKey}},async getXPUB(e,t){const r=this.getApp(e),s=await r.getExtendedPubKey(t,!1);return{pubKey:s.publicKey,chainCode:s.chain_code}},async signHash(e,t,r,s){const n=this.getApp(e),a=s.map((e=>e.toString(!0))),i=await n.signHash(r.toString(),a,t),o=i.signatures||new Map;return{hash:i.hash||Buffer.from(""),signatures:o}},async signTx(e,t,r,s,n){const a=this.getApp(e),i=s.map((e=>e.toString(!0))),o=n?.map((e=>e.toString(!0)))||[],d=await a.sign(r.toString(),i,t,o),u=d.signatures||new Map;return{...d,signatures:u}}};async function bt(e){return!(await wt.getVersion(e)>="0.6.0")}const{parse:At}=h.utils;class Tt extends vt{constructor(e,t,r){super(r),this.avmXpub=e,this.accountNode=m.fromBase58(e),this.evmWallet=new yt(t,t,r)}accountNode;evmWallet;externalIndex=0;internalIndex=0;pubkeyCache={};static fromMnemonic(e,t){if(!u.validateMnemonic(e))throw new Error("Invalid mnemonic phrase.");const r=u.mnemonicToSeedSync(e),s=m.fromSeed(r),n=s.derivePath("m/44'/9000'/0'").neutered(),a=s.derivePath(R(0,H.BIP44,"EVM")).neutered();return new Tt(n.toBase58(),a.publicKey,t)}setExternalIndex(e){if(e<0)throw new Error("Index must be >= 0");this.externalIndex=e}setInternalIndex(e){if(e<0)throw new Error("Index must be >= 0");this.internalIndex=e}getPubKeyAtIndex(e,t=!1){if(e<0)throw new Error("Index must be >= 0");const r=`${t?1:0}/${e}`,s=this.pubkeyCache[r];if(s)return s;const{publicKey:n}=this.accountNode.derivePath(r);return this.pubkeyCache[r]=n,n}getAddressAtIndex(e,t=!1,r){const s=this.getPubKeyAtIndex(e,t);return this.provider.getAddress(s,r)}getExternalAddresses(e){const t=[];for(let r=0;r<=this.externalIndex;r++)t.push(this.getAddressAtIndex(r,!1,e));return t}getInternalAddresses(e){const t=[];for(let r=0;r<=this.internalIndex;r++)t.push(this.getAddressAtIndex(r,!0,e));return t}getAddresses(e){return"C"===e?[this.getCurrentAddress("C")]:"P"===e?[...this.getExternalAddresses(e)]:[...this.getInternalAddresses(e),...this.getExternalAddresses(e)]}getChangeAddress(e){return"C"===e?this.evmWallet.getAddress("C"):"P"===e?this.getAddressAtIndex(this.externalIndex,!1,"P"):this.getAddressAtIndex(this.internalIndex,!0,e)}getCurrentAddress(e){return"C"===e?this.evmWallet.getAddress("C"):this.getAddressAtIndex(this.externalIndex,!1,e)}incrementIndex(e){e?this.externalIndex++:this.internalIndex++}getAddressEVM(){return this.evmWallet.getAddressEVM()}getActiveIndices(){return{external:this.externalIndex,internal:this.internalIndex}}getInternalRawAddresses(){return this.getInternalAddresses("X").map((e=>Buffer.from(At(e)[2])))}getExternalRawAddresses(){return this.getExternalAddresses("X").map((e=>Buffer.from(At(e)[2])))}getRawAddressC(){return Buffer.from(At(this.getCurrentAddress("C"))[2])}}const{isTransferOut:It,isStakeableLockOut:St}=h.utils;function Pt(e){const t=e.output;return It(t)||St(t)?t.getOwners():[]}function Bt(e){const t=e.getTx();return h.avmSerial.isExportTx(t)||h.pvmSerial.isExportTx(t)?new Set(t.outs.map(Pt).flat()):h.evmSerial.isExportTx(t)?new Set(t.exportedOutputs.map(Pt).flat()):new Set((t.baseTx?.outputs??[]).map(Pt).flat())}const{parse:Ct}=h.utils;class kt extends Tt{constructor(e,t,r){super(e,t,r)}getAdditionalAddressesByIndices(e,t,r){return"C"===r?[]:e.map((e=>{const s=this.getAddressAtIndex(e,t,r),[,,n]=Ct(s);return Buffer.from(n).toString("hex")}))}static async fromTransport(e,r){if(await bt(e))throw new Error("Unsupported ledger app version. Must be >= 0.6.0");const s=U(e),a=await wt.getXPUB(e,kt.getAccountPath("X")),i=m.fromPublicKey(a.pubKey,a.chainCode),o=R(0,H.BIP44,"EVM"),d=await s.getAddress(o,!1),u=n.SigningKey.computePublicKey(Buffer.from(d.publicKey,"hex"),!0),c=Buffer.from(t.strip0x(u),"hex");return new kt(i.toBase58(),c,r)}static getAccountPath(e){switch(e){case"P":case"X":return"m/44'/9000'/0'";case"C":return"m/44'/60'/0'"}}async signMessage(e){throw new Error("not implemented")}filterOwnedAddresses(e,t,r){const s=this.getInternalRawAddresses().map((e=>e.toString("hex"))),n=this.getExternalRawAddresses().map((e=>e.toString("hex"))),a=new Set([...s,...r??[]]),i=new Set([...n,...t??[]]),o=new Set;return e.forEach((e=>{const t=e.toString("hex");if(a.has(t)){const e=[...a].indexOf(t);o.add(`1/${e}`)}else if(i.has(t)){const e=[...i].indexOf(t);o.add(`0/${e}`)}})),o}async signTx(e){if(!e.transport)throw new Error("Ledger transport not provided");const{tx:t,externalIndices:r,internalIndices:s}=e,n=t.getVM(),a=Buffer.from(t.toBytes()),i="EVM"===n?"C":"X",o=t.getAddresses().map((e=>Buffer.from(e))),d=this.getAdditionalAddressesByIndices(r??[],!1,i),u=this.getAdditionalAddressesByIndices(s??[],!0,i),c=[...this.filterOwnedAddresses(o,d,u).values()].map((e=>S.fromString(e))),l=[...Bt(t)].map((e=>Buffer.from(e))),p=[...this.filterOwnedAddresses(l).values()].map((e=>S.fromString(e)));return(await this.signTxBuffer({buffer:a,chain:i,transport:e.transport,signers:c,change:p})).forEach((e=>{t.addSignature(e)})),t}async signTxBuffer(e){if(!e.transport)throw new Error("Ledger transport not provided");if(!e.signers)throw new Error("Signers not provided");const t=e.change||[],r=S.fromString(kt.getAccountPath(e.chain));return[...(await wt.signTx(e.transport,e.buffer,r,e.signers,t)).signatures.values()]}}const{strip0x:Et}=h.utils;class Dt extends Tt{constructor(e,t,r){const s=m.fromBase58(e).neutered(),a=new n.SigningKey(t),i=Buffer.from(Et(a.compressedPublicKey),"hex");super(s.toBase58(),i,r),this.evmPrivKey=t,this.accountNode=m.fromBase58(e)}accountNode;static fromMnemonic(e,t){if(!u.validateMnemonic(e))throw new Error("Invalid mnemonic phrase.");const r=u.mnemonicToSeedSync(e),s=m.fromSeed(r),n=s.derivePath("m/44'/9000'/0'"),a=s.derivePath(R(0,H.BIP44,"EVM"));if(!a.privateKey)throw new Error("Unable to derive EVM private key.");return new Dt(n.toBase58(),a.privateKey,t)}async signTx(e){const t=this.getSigningKeys(e);return await h.addTxSignatures({unsignedTx:e.tx,privateKeys:t}),e.tx}getExternalPrivateKeys(e){const t=[];for(let e=0;e<=this.externalIndex;e++){const r=this.accountNode.derivePath(`0/${e}`);if(!r.privateKey)throw new Error("Unable to get private key.");t.push(r.privateKey)}const r=(e??[]).reduce(((e,t)=>{if(t>this.externalIndex){const r=this.accountNode.derivePath(`0/${t}`);if(!r.privateKey)throw new Error("Unable to get private key.");e.push(r.privateKey)}return e}),[]);return[...t,...r]}getInternalPrivateKeys(e){const t=[];for(let e=0;e<=this.internalIndex;e++){const r=this.accountNode.derivePath(`1/${e}`);if(!r.privateKey)throw new Error("Unable to get private key.");t.push(r.privateKey)}const r=(e??[]).reduce(((e,t)=>{if(t>this.internalIndex){const r=this.accountNode.derivePath(`1/${t}`);if(!r.privateKey)throw new Error("Unable to get private key.");e.push(r.privateKey)}return e}),[]);return[...t,...r]}getSigningKeys(e){const{tx:t,externalIndices:r,internalIndices:s}=e,n=t.getVM();return"AVM"===n?[...this.getInternalPrivateKeys(s),...this.getExternalPrivateKeys(r)]:"PVM"===n?this.getExternalPrivateKeys(r):[this.evmPrivKey]}async signTxBuffer(e){throw new Error("not implemented")}async signMessage(e){throw new Error("not implemented")}}const{getPublicKey:Mt,sign:Vt,signHash:Kt}=h.secp256k1,{addChecksum:Ut}=h.utils;class Ot extends yt{privKeyXP;privKeyC;constructor(e,t,r){super(Buffer.from(Mt(e)),Buffer.from(Mt(t)),r),this.privKeyXP=e,this.privKeyC=t}static fromMnemonic(e,t,r,s){if(!u.validateMnemonic(e))throw new Error("Invalid mnemonic phrase.");if(!gt(r)||!gt(t))throw new Error("Not valid derivation path. Make sure it is a valid BIP44 path starting with m/");const n=u.mnemonicToSeedSync(e),a=m.fromSeed(n),i=a.derivePath(t),o=a.derivePath(r);if(!i.privateKey||!o.privateKey)throw new Error("Failed to generate private keys.");return new Ot(i.privateKey,o.privateKey,s)}async signMessage(e){const t=Ne(e.message),r=this.getSigningKey(e.chain);return Buffer.from(Ut(await Kt(t,r)))}getSigningKey(e){return"C"===e?this.privKeyC:this.privKeyXP}async signTx(e){return await h.addTxSignatures({unsignedTx:e.tx,privateKeys:[this.privKeyC,this.privKeyXP]}),e.tx}async signTxBuffer(e){const t=this.getSigningKey(e.chain);return[Buffer.from(await Vt(e.buffer,t))]}}const{strip0x:Nt}=h.utils;class _t extends yt{constructor(e,t,r,s,a){const i=h.utils.strip0x(n.SigningKey.computePublicKey(e,!0)),o=h.utils.strip0x(n.SigningKey.computePublicKey(r,!0));if(super(Buffer.from(i,"hex"),Buffer.from(o,"hex"),a),this.pathXP=t,this.pathC=s,!gt(t)||!gt(s))throw new Error("Invalid path configuration.")}static async fromTransport(e,t,r,a){if(await bt(e))throw new Error("Ledger app not supported. Must be version >= 0.6.0");if(!gt(t)||!gt(r))throw new Error("Invalid path configuration.");const i=new s(e),o=await i.getAddress(r,!1),d=await i.getAddress(t,!1),u=Buffer.from(Nt(o.publicKey),"hex"),c=Buffer.from(Nt(d.publicKey),"hex"),l=Buffer.from(Nt(n.SigningKey.computePublicKey(u,!0)),"hex"),p=Buffer.from(Nt(n.SigningKey.computePublicKey(c,!0)),"hex");return new _t(p,t,l,r,a)}async signMessage(e){throw new Error("not implemented")}getFullSignerPath(e){return"C"===e?this.pathC:this.pathXP}getPartialSignerPath(e){return this.getFullSignerPath(e).split("/").slice(4).join("/")}getAccountPath(e){return this.getFullSignerPath(e).split("/").slice(0,4).join("/")}async signTx(e){if(!e.transport)throw new Error("Ledger transport not provided");const t=e.tx,r=t.getVM(),s=Buffer.from(t.toBytes()),n="EVM"===r?"C":"X";return(await this.signTxBuffer({buffer:s,chain:n,transport:e.transport})).forEach((e=>{t.addSignature(e)})),t}async signTxBuffer(e){if(!e.transport)throw new Error("Ledger transport not provided");const t=S.fromString(this.getAccountPath(e.chain)),r=S.fromString(this.getPartialSignerPath(e.chain));return[...(await wt.signTx(e.transport,e.buffer,t,[r],[r])).signatures.values()]}}const{parse:Lt}=h.utils;var Xt=Object.freeze({__proto__:null,AbstractProvider:be,AddressWallet:class extends vt{constructor(e,t,r,s,a){if(super(a),this.addressC=e,this.addressCoreEth=t,this.xpAddresses=r,this.xpChangeAddress=s,r.length<1)throw new Error("Must have at least 1 xp address.");if(!n.isAddress(e))throw new Error("Not a valid C-Chain (EVM) address");if(r.some((e=>!Je(e,!1))))throw new Error("Given addresses must be valid avalanche bech32 addresses without the chain alias prefix");if(!Je(t,!1))throw new Error("Given CoreEth address must be valid avalanche bech32 addresses without the chain alias prefix");this.setChangeAddress(s)}setChangeAddress(e){if(!Je(e,!1))throw new Error("Given address must be valid avalanche bech32 addresses without the chain alias prefix");this.xpChangeAddress=e}getAddressEVM(){return this.addressC}getAddresses(e){return("C"===e?[this.addressCoreEth]:this.xpAddresses).map((t=>this.provider.formatAddress(t,e)))}getChangeAddress(e){const t="C"===e?this.addressCoreEth:this.xpChangeAddress;return this.provider.formatAddress(t,e)}getCurrentAddress(e){const t="C"===e?this.addressCoreEth:this.xpAddresses[0];return this.provider.formatAddress(t,e)}},DevnetContext:Se,FujiContext:Ie,JsonRpcProvider:Pe,LedgerSigner:_t,LedgerWallet:kt,MainnetContext:Te,MnemonicWallet:Dt,MnemonicWalletVoid:Tt,P_CHAIN_TX_SIZE_LIMIT:65536,SimpleLedgerSigner:class{constructor(e,t,r){this.activeAccountIndex=e,this.provider=t,r&&(this.accountNode=m.fromBase58(r))}accountNode;reSerializeTx(e,t){return e instanceof h.EVMUnsignedTx||"C"===t?h.EVMUnsignedTx.fromJSON(JSON.stringify(e.toJSON())):h.UnsignedTx.fromJSON(JSON.stringify(e.toJSON()))}getChainAlias(e){return"EVM"===e.getVM()?"C":"X"}getAccountPath(e){switch(e){case"X":case"P":return"m/44'/9000'/0'";case"C":return"m/44'/60'/0'"}}getAddressOfPath(e,t){if(!this.accountNode)return null;const{publicKey:r}=this.accountNode.derivePath(e),s=this.provider.getAddress(r,t);return Buffer.from(Lt(s)[2]).toString("hex")}getAddressPathMap(e){const{tx:t,externalIndices:r,internalIndices:s}=e,n=this.getChainAlias(t),a=`0/${this.activeAccountIndex}`,i=new Map;if("C"===n||!this.accountNode)return i;const o=(r??[]).map((e=>`0/${e}`)),d=(s??[]).map((e=>`1/${e}`)),u=[a,...o,...d];for(const e of u){const t=this.getAddressOfPath(e,n);t&&i.set(t,e)}return i}getAddressBipPaths(e,t){return 0===t.size?[S.fromString(`0/${this.activeAccountIndex}`)]:e.reduce(((e,r)=>{const s=t.get(Buffer.from(r).toString("hex"));return s&&e.push(S.fromString(s)),e}),[])}async signTx(e){if(!e.transport)throw new Error("Ledger transport not provided");const t=this.getChainAlias(e.tx),r=this.reSerializeTx(e.tx,t),s=Buffer.from(r.toBytes()),n=this.getAddressPathMap(e),a=this.getAddressBipPaths(r.getAddresses(),n),i=this.getAddressBipPaths([...Bt(r)],n);return(await this.signTxBuffer({buffer:s,chain:t,transport:e.transport,signers:a,change:i})).forEach((e=>{r.addSignature(e)})),r}async signTxBuffer(e){if(!e.transport)throw new Error("Ledger transport not provided");if(!e.signers)throw new Error("Signers not provided");const t=e.change||[],r=S.fromString(this.getAccountPath(e.chain));return[...(await wt.signTx(e.transport,e.buffer,r,e.signers,t)).signatures.values()]}async signMessage(e){if(!e.transport||!e.message)throw new Error("Unable to sign message. Incomplete or invalid request.");const t=e.signer||S.fromString(`0/${this.activeAccountIndex}`);if(2!=t.toPathArray().length)throw new Error("Given signer path must have a depth of 2. Ex. 0/0, 0/1");const r=Ne(e.message),s=(await wt.signHash(e.transport,r,S.fromString(this.getAccountPath(e.chain)),[t])).signatures.get(t.toString(!0));if(!s)throw new Error("Failed to sign message.");return s}},SimpleSigner:class{accountNodeXP;signerNodeEVM;activeAccountIndex;constructor(e,t){if(!u.validateMnemonic(e))throw new Error("Invalid mnemonic phrase.");if(t<0||t%1!=0)throw new Error("Invalid account index.");const r=u.mnemonicToSeedSync(e),s=m.fromSeed(r);this.accountNodeXP=s.derivePath("m/44'/9000'/0'");const n=s.derivePath(R(t,H.BIP44,"EVM"));this.signerNodeEVM=n,this.activeAccountIndex=t}getAdditionalKeys(e,t){return[...new Set(e??[])].reduce(((e,r)=>{const s=this.accountNodeXP.derivePath(`${t?1:0}/${r}`);if(!s.privateKey)throw new Error("Unable to get private key.");return e.push(s.privateKey),e}),[])}getSigningKeys(e,t,r){if("EVM"===e){if(!this.signerNodeEVM.privateKey)throw new Error("Unable to derive EVM private key.");return[this.signerNodeEVM.privateKey]}const s=this.accountNodeXP.derivePath(`0/${this.activeAccountIndex}`);if(!s.privateKey)throw new Error("Unable to derive X/P private key.");const n=this.getAdditionalKeys(t,!1);if("AVM"===e){const e=this.getAdditionalKeys(r,!0);return[s.privateKey,...n,...e]}if("PVM"===e)return[s.privateKey,...n]}async signTx(e){const{tx:t,externalIndices:r,internalIndices:s}=e,n=t.getVM(),a=this.getSigningKeys(n,r,s);if(!a?.length)throw new Error("Unable to sign transaction: signing keys are missing.");return await h.addTxSignatures({unsignedTx:t,privateKeys:a}),e.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 t=this.getActiveAccountNode(e.chain);if(!t.privateKey)throw Error("Unable to sign message, key not found.");const r=Ne(e.message),s=await h.secp256k1.signHash(r,t.privateKey);return Buffer.from(s)}},SizeSupportedTx:ut,StaticSigner:Ot,TxType:re,WalletAbstract:vt,WalletVoid:yt,addSignaturesToAvalancheTx:async({transactionHex:e,signatures:t,chainAlias:r,provider:s,utxos:n})=>{if(!t.length)throw new Error("signatures were not provided");const a=await xe({transactionHex:e,chainAlias:r,provider:s,utxos:n});await Promise.all(t.map((e=>a.addSignature(e))));const i=a.getCredentials(),o=a.getSigIndices().reduce(((e,t,r)=>{const s=t.map((e=>{const t=i[r]?.toJSON()[e];if(!t)throw new Error(`Failed to sign [${r}, ${e}]`);return t}));return e.push(new h.Credential(s)),e}),[]),d=new h.UnsignedTx(a.getTx(),a.getInputUtxos(),a.addressMaps,o);return{signedTxHex:he(new h.avaxSerial.SignedTx(a.getTx(),o)),hasAllSignatures:d.hasAllSignatures()}},convertGlacierUtxo:De,createAvalancheEvmUnsignedTx:async({txBytes:e,fromAddress:t,vm:r,utxos:s})=>{const n=Me(r,e),a=Ve(t)[2],i=Ke(a);if(h.evmSerial.isExportTx(n))return new h.EVMUnsignedTx(n,[],new Ue([Oe.fromJSON([[i,0]])]));if(h.evmSerial.isImportTx(n)){const e=Ue.fromTransferableInputs(n.importedInputs,s,BigInt(Math.floor((new Date).getTime()/1e3)),[a]);return new h.UnsignedTx(n,s,e)}throw new Error("Unsupported transaction type")},createAvalancheUnsignedTx:ie,digestMessage:Ne,emptySignature:le,getAddressFromXpub:function(e,t,r,s,n=!1){if(t<0)throw new Error("Account index must be >= 0");const a=n?"1":"0",i=m.fromBase58(e).derivePath(`${a}/${t}`).publicKey;return r.getAddress(i,s)},getAddressPublicKeyFromXpub:function(e,t){if(t<0)throw new Error("Account index must be >= 0");return m.fromBase58(e).derivePath(`0/${t}`).publicKey},getAssetBalance:function(e,t){const r=e.getAssetDict()[t],s={locked:BigInt(0),available:BigInt(0),multisig:BigInt(0),lockedStakeable:BigInt(0),total:BigInt(0)};if(!r)return s;const n=r.getUTXOs(),a=He();return n.forEach((e=>{const t=Re(e);s[t.threshold>1?"multisig":t.locktime>a?"locked":t.stakeableLocktime>a?"lockedStakeable":"available"]+=t.amount})),s.total=s.locked+s.lockedStakeable+s.multisig+s.available,s},getLedgerProvider:async function(e){return wt},getMaximumUtxoSet:function({wallet:e,utxos:t,sizeSupportedTx:r,limit:s=65536,feeState:n}){const{sortFunction:a,unsignedTxBuilder:i}=ht[r],o=He(),d=a(t.filter((e=>{const{locktime:t,stakeableLocktime:s}=dt(e);return t<o&&(s<o||("AddPermissionlessDelegator"===r||"AddPermissionlessValidator"===r))}))),u=function(e,t,r){let s=0,n=e.length-1;if(t(e)<=r)return n;let a=-1;for(;s<=n;){const i=Math.floor((s+n)/2);t(e.slice(0,i+1))<=r?(a=i,s=i+1):n=i-1}return a}(d,(t=>{try{return function(e){const t=e.getInputUtxos().reduce(((e,t)=>e+(8+65*dt(t).threshold)),0);return 6+e.toBytes().length+t}(i(e,t,n))}catch(e){return console.log("Unable to estimate size of utxos",{e:e,utxos:t.map(dt)}),s+1}}),s);return-1===u?[]:d.slice(0,u+1)},getPaginatedUTXOs:Fe,getPchainUnixNow:async function(e){const t=e?A.AVALANCHE_XP_TEST_NETWORK.rpcUrl:A.AVALANCHE_XP_NETWORK.rpcUrl,r=await new h.pvm.PVMApi(t).getTimestamp(),s=new Date(r.timestamp),n=Math.floor(s.getTime()/1e3);return BigInt(n)},getStakeForAddresses:$e,getStakedAssetBalance:function(e){const{stakedOutputs:t}=e,r={unlockedStaked:BigInt(0),lockedStaked:BigInt(0),total:BigInt(0)};return t.forEach((e=>{r[h.utils.isStakeableLockOut(e)?"lockedStaked":"unlockedStaked"]+=e.amount()})),r.total=r.lockedStaked+r.unlockedStaked,r},getUTXOsForAddresses:Xe,getUnixNow:He,getUtxosByTxFromGlacier:async({transactionHex:e,chainAlias:t,network:r,url:s,token:n,headers:a})=>{const i=se(t),o=We(e),d=je(i,o);if(h.evmSerial.isExportTx(d))return[];const u=(e=>{if(h.evmSerial.isImportTx(e)||h.avmSerial.isImportTx(e)||h.pvmSerial.isImportTx(e))return e.sourceChain.toString();const t=e.getVM();switch(t){case h.EVM:return b.BlockchainId.C_CHAIN;case h.AVM:return b.BlockchainId.X_CHAIN;case h.PVM:return b.BlockchainId.P_CHAIN;default:throw new Error(`Unable to get chain for VM type "${t}"`)}})(d),c=qe(d),l=new b.Glacier({BASE:s,TOKEN:n,HEADERS:a}),p=[...new Set(c.map((e=>e.utxoID.txID.toString())))],g=await Promise.all(p.map((e=>l.primaryNetworkTransactions.getTxByHash({blockchainId:u,network:r,txHash:e}))));return c.reduce(((e,t)=>{const s=g.find((e=>e.txHash===t.utxoID.txID.toString()));if(!s)throw new Error(`Unable to find parent tx "${t.utxoID.txID.toString()}"`);const n=s.emittedUtxos.find((e=>e.utxoId===t.utxoID.ID()));if(!n)throw new Error(`Unable to find UTXO "${t.utxoID.ID()}" at index "${t.utxoID.outputIdx.value()}"`);const a=De(n,r);return e.push(a),e}),[])},getVmByChainAlias:se,getXpubFromMnemonic:function(e){if(!u.validateMnemonic(e))throw new Error("Invalid mnemonic phrase.");const t=u.mnemonicToSeedSync(e);return m.fromSeed(t).derivePath("44'/9000'/0'").neutered().toBase58()},isAddDelegatorTx:function(e){return"add_delegator"===e.type},isAddPermissionlessDelegatorTx:function(e){return"add_permissionless_delegator"===e.type},isAddPermissionlessValidatorTx:function(e){return"add_permissionless_validator"===e.type},isAddSubnetValidatorTx:function(e){return"add_subnet_validator"===e.type},isAddValidatorTx:function(e){return"add_validator"===e.type},isBaseTx:function(e){return"base"===e.type},isBech32Address:Je,isConvertSubnetToL1Tx:function(e){return"convert_subnet_to_l1"===e.type},isCreateChainTx:function(e){return"create_chain"===e.type},isCreateSubnetTx:function(e){return"create_subnet"===e.type},isDisableL1ValidatorTx:function(e){return"disable_l1_validator"===e.type},isExportTx:function(e){return"export"===e.type},isImportTx:function(e){return"import"===e.type},isIncreaseL1ValidatorBalance:function(e){return"increase_l1_validator_balance"===e.type},isObsidianApp:bt,isRegisterL1ValidatorTx:function(e){return"register_l1_validator"===e.type},isRemoveSubnetValidatorTx:function(e){return"remove_subnet_validator"===e.type},isSetL1ValidatorWeightTx:function(e){return"set_l1_validator_weight"===e.type},isTransferSubnetOwnershipTx:function(e){return"transfer_subnet_ownership"===e.type},isTransformSubnetTx:function(e){return"transform_subnet"===e.type},parseAvalancheTx:async function(e,t,r,{feeTolerance:s=50}={}){try{const n=t.getContext(),a=e.getTx(),i=(e=>{for(const t of Object.values(Qe)){const r=t(e);if(null!==r)return r}throw new Error("no parser found for tx")})(a),o=Ze(a,n),d=et(a),u=tt(a).get(n.avaxAssetID)??BigInt(0),c=o.get(n.avaxAssetID)??BigInt(0),l=d.get(n.avaxAssetID)??BigInt(0);let p=BigInt(0);h.evmSerial.isImportExportTx(a)?(p=await t.getApiC().getBaseFee()/BigInt(1e9),0n===p&&(p=1n)):"PVM"===a.vm&&(p=await t.getApiP().getFeeState().then((e=>e.price)).catch((()=>BigInt(0))));const{isValid:g,txFee:m}=rt({unsignedTx:e,context:n,burnedAmount:c,baseFee:p,feeTolerance:s});return await i({feeData:{totalAvaxBurned:c,totalAvaxOutput:l,totalAvaxInput:u,isValidAvaxBurnedAmount:g,txFee:m},assetId:n.avaxAssetID,provider:t,currentAddress:r})}catch(e){return{type:re.Unknown}}},populateCredential:pe,signedTxToHex:he,sortUTXOsByAmount:at,sortUTXOsByAmountAscending:ot,sortUTXOsByAmountDescending:it,sortUTXOsStaking:nt,verifyDerivationPath:gt});exports.Avalanche=Xt,exports.BitcoinLedgerWallet=class extends Z{constructor(e,t,r,s,n){super(e,r),this.derivationPath=t,this.transport=s,this.walletPolicyDetails=n}setTransport(e){this.transport=e}async signTx(e,t){const r=function(e){return new v(e)}(this.transport),s=this.ecPair.publicKey,n=this.provider.getNetwork(),a=await r.getMasterFingerprint(),i=Y(e,t,n,Buffer.from(a,"hex"),s,this.derivationPath),{policy:o,hmac:d}=this.walletPolicyDetails,u=await r.signPsbt(i,o,d),c=Q(i,n,s,this.derivationPath);if(u.forEach((e=>{const[t,r]=e;c.updateInput(t,{partialSig:[{signature:r.signature,pubkey:r.pubkey}]})})),!c.validateSignaturesOfAllInputs())throw new Error("Failed to validate signatures");return c.finalizeAllInputs(),c.extractTransaction()}},exports.BitcoinProvider=class extends k{constructor(e=!0,r,s,n,a){super(),this.isMainnet=e,this.extraParams=a;const i=r?{headers:{"api-key":r}}:{},o=e?"https://btcbook.nownodes.io":"https://btcbook-testnet.nownodes.io";this.#i=new t.HttpClient(s||o,i);const d=e?"https://btc.nownodes.io":"https://btc-testnet.nownodes.io";this.#o=new t.HttpClient(n||d,i)}#i;#o;async#d(e,t){return this.isMainnet||t?(await Promise.all(e.map((e=>this.#o.post("",e,{},this.extraParams))))).flat():this.#o.post("",e,{},this.extraParams)}async getTxHex(e){return(await this.#i.post(`/api/v2/tx/${e}`,{},{},this.extraParams)).hex}async getUTXOs(e,t=!0,r){const s=await this.#i.post(`/api/v2/utxo/${e}`,{},{},this.extraParams);if(!s?.length)return{confirmed:[],unconfirmed:[]};const n=s.map(this._parseUtxo),a=e=>({confirmed:e.filter((e=>e.confirmations>0)),unconfirmed:e.filter((e=>0===e.confirmations))});if(!t)return a(n);return a(await this.getScriptsForUtxos(n,r))}async getAddressFromScript(e){const t=await this.#o.post("",{jsonrpc:"2.0",id:`decode-script-${e}`,method:"decodescript",params:[e]},{},this.extraParams);if(t.result)return t.result.address;throw new Error(`Unable to resolve address for script: ${e}. ${t.error.message}`)}async getScriptsForUtxos(e,t){const[r,s]=e.reduce((([e,t],r)=>r.script?[[...e,r],t]:[e,[...t,r]]),[[],[]]),n=s.map(((e,t)=>({jsonrpc:"2.0",method:"gettxout",params:[e.txHash,e.index],id:`${t}`}))),a=n.length?(await this.#d(n,t)).sort(((e,t)=>Number(e.id)-Number(t.id))):[];return[...r,...s.map(((e,t)=>({...e,script:a[t]?.result?.scriptPubKey.hex})))]}_parseUtxo(e){return{...e,txHash:e.txid,index:e.vout,value:Number(e.value),blockHeight:e.height,script:e.script,confirmations:e.confirmations}}async getBalances(e){const t=await this.#i.post(`/api/v2/address/${e}`,{},{},this.extraParams);return{available:BigInt(t.balance),pending:BigInt(t.unconfirmedBalance),final:BigInt(t.balance)+BigInt(t.unconfirmedBalance)}}async getChainHeight(){return(await this.#o.post("",{jsonrpc:"2.0",id:"nownodes",method:"getblockcount",params:[]},{},this.extraParams)).result}async getFeeRates(e){const t={jsonrpc:"2.0",method:"estimatesmartfee"},r=await this.#d([{...t,id:"1",params:[1]},{...t,id:"2",params:[3]},{...t,id:"3",params:[6]}],e).then((e=>e.sort(((e,t)=>Number(e.id)-Number(t.id))).map((e=>1e8*(e.result?.feerate??0)))));return{high:Math.ceil(r[0]/1024)||1,medium:Math.ceil(r[1]/1024)||1,low:Math.ceil(r[2]/1024)||1}}getNetwork(){return this.isMainnet?e.networks.bitcoin:e.networks.testnet}async issueRawTx(e){return await this.#o.post("",{jsonrpc:"2.0",id:"nownodes",method:"sendrawtransaction",params:[e]},{},this.extraParams).then((e=>e.result))}async getTransaction(e){const t=await this.#i.post(`/api/v2/tx/${e}`,{},{},this.extraParams);return{block:t.blockHeight,fees:Number(t.fees),confirmations:t.confirmations,amount:Number(t.value),hash:t.txid,addresses:Array.from(new Set([...t.vin.map((e=>e.addresses||[])).flat(),...t.vout.map((e=>e.addresses||[])).flat()])),blockTime:t.blockTime,inputs:[...t.vin.map((e=>({...e,value:Number(e.value)})))],outputs:[...t.vout.map((e=>({...e,value:Number(e.value)})))]}}async getTxHistory(e){const t=await this.#i.post(`/api/v2/address/${e}`,{},{},this.extraParams),r=t.txids?.slice(0,25)??[];return await Promise.allSettled(r.map((async t=>{try{const r=await this.#i.post(`/api/v2/tx/${t}`,{},{},this.extraParams);return function(e,t){const r=t.vin.filter((t=>t.addresses?.includes(e))),s=t.vout.filter((t=>t.addresses?.includes(e))),n=t.vin.filter((t=>!t.addresses?.includes(e))),a=t.vout.filter((t=>!t.addresses?.includes(e))),i=r.reduce(((e,t)=>e+BigInt(t.value)),0n),o=s.reduce(((e,t)=>e+BigInt(t.value)),0n),d=i>o;let u=o-i;d&&(u+=BigInt(t.fees));const c=n.map((e=>e.addresses||[])).flat(),l=a.map((e=>e.addresses||[])).flat(),p=d?l:c,h=p.filter(((e,t)=>p.indexOf(e)===t)),g=s.filter((e=>(e.addresses?.length||0)>1)).length>0;return{addresses:h,isSender:d,block:t.blockHeight,fee:Number(t.fees),confirmations:t.confirmations,amount:Number(u),hash:t.txid,containsMultisig:g,receivedTime:t.blockTime,confirmedTime:t.confirmations>0?t.blockTime:void 0}}(e,r)}catch(e){console.log(`Unable to parse full tx ${t}.`)}}))).then((e=>e.map((e=>"fulfilled"===e.status&&e.value?e.value:void 0)).filter((e=>void 0!==e))))}async waitForTx(e,{maxAttempts:t=20,attempt:r=1,pollInterval:s=500}={}){try{return await this.getTransaction(e)}catch(n){if(r>=t)throw n;return await new Promise((e=>setTimeout(e,s))),this.waitForTx(e,{maxAttempts:t,attempt:r+1,pollInterval:s})}}},exports.BitcoinProviderAbstract=k,exports.BitcoinWallet=ee,exports.BitcoinWalletAbstract=Z,exports.BitcoinWalletVoid=class extends Z{constructor(e,t){super(e,t)}signTx(e){throw new Error("Void wallets can not sign.")}},exports.BtcNetworks=te,exports.DerivationPath=H,exports.ETH_ACCOUNT_PATH=F,exports.ETH_COIN_PATH=X,exports.JsonRpcBatchInternal=J,exports.LedgerSigner=G,exports.SolanaLedgerSigner=class{#u;#c;constructor(e,t){this.#u=_(e,!1),this.#c=t}async signTx(e,t){const r=await O(e,t),{signatures:s,messageBytes:n,...i}=a.compileTransaction(r),o=new d(this.#c),{address:u}=await o.getAddress(this.#u),c=a.address(l.base58.encode(Uint8Array.from(u)));if(!this.#s(c,s))return e;const{signature:p}=await o.signTransaction(this.#u,Buffer.from(n)),h=l.base58.encode(Uint8Array.from(p));return a.assertIsSignature(h),a.getBase64EncodedWireTransaction({...i,messageBytes:n,signatures:{...s,[c]:l.base58.decode(h)}})}#s(e,t){return e in t&&!t[e]}},exports.SolanaSigner=L,exports.addEncodedSigToPsbt=function(e,t,r,s){const n=[{pubkey:t,signature:e}];r.updateInput(s,{partialSig:n})},exports.compileSolanaTx=e=>a.compileTransaction(e),exports.createPSBTV2=Y,exports.createPsbt=E,exports.createTransferTx=V,exports.createWalletPolicy=function(e,t,r,s){const n=new v.DefaultWalletPolicy("wpkh(@0/**)",`[${e}/44'/60'/${t}']${r}`);return new v.WalletPolicy(s,"wpkh(@0/**)",n.keys)},exports.deserializeTransactionMessage=O,exports.formatAddressForNetworkBech32=function(t,r){const s=e.address.fromBech32(t);return e.address.toBech32(s.data,s.version,r.bech32)},exports.getAddressDerivationPath=R,exports.getAddressFromXPub=function(e,t){const r=z(e,t);return n.computeAddress(`0x${r.toString("hex")}`)},exports.getAddressPrivateKeyFromXPriv=function(e,t){const r=m.fromBase58(e).derivePath(`0/${t}`);if(!r.privateKey)throw new Error("Unable to derive private key.");return r.privateKey},exports.getAddressPublicKeyFromXPub=z,exports.getAppEth=U,exports.getBech32Address=K,exports.getBech32AddressFromXPub=function(e,t,r){return K(z(e,t),r)},exports.getBtcAddressFromPubKey=function(e,r){const s=t.strip0x(n.SigningKey.computePublicKey(e,!0));return K(Buffer.from(s,"hex"),r)},exports.getEvmAddressFromPubKey=function(e){return n.computeAddress(`0x${e.toString("hex")}`)},exports.getLedgerAppInfo=async function(e){const t=await e.send(176,1,0,0),r=t.readUInt8(1),s=t.readUInt8(2+r),n=t.subarray(2,2+r),a=t.subarray(2+r+1,2+r+1+s);return{applicationName:n.toString("ascii"),version:a.toString("ascii")}},exports.getLedgerExtendedPublicKey=async function(e,t=!1,r){const s=U(e),n=await s.getAddress(r??F,t,!0),a=new g;return a.publicKey=B.Buffer.from(n.publicKey,"hex"),a.chainCode=B.Buffer.from(n.chainCode,"hex"),a.publicExtendedKey},exports.getMaxTransferAmount=function(e,t,r,s){const n=C(e);if(!n)return 0;const{fee:a}=D(t,r,n,s,e);return n-a},exports.getPubKeyFromTransport=async function(e,t,r,s="EVM"){const n=U(e),a=R(t,r,s),i=await n.getAddress(a,!1,!1);return Buffer.from(i.publicKey,"hex")},exports.getPublicKeyFromPrivateKey=function(e){const t=Buffer.isBuffer(e)?e:Buffer.from(e,"hex");try{return Buffer.from(h.secp256k1.getPublicKey(t))}finally{t.fill(0)}},exports.getSolanaDerivationPath=_,exports.getSolanaProvider=({isTestnet:e,rpcUrl:t})=>{const r=a.createSolanaRpc(e?a.devnet(t):a.mainnet(t));return new Proxy(r,{get:(e,t,r)=>t===N||("then"===t||"catch"===t||"finally"===t?e:Reflect.get(e,t,r))})},exports.getSolanaPublicKeyFromLedger=async(e,t)=>{const r=new d(t),{address:s}=await r.getAddress(_(e,!1));return s},exports.getTransferTxDetails=function(e,t,r,s,n){const a=D(e,t,r,s,M(n));return a.inputs||console.log("Unable to construct transaction, fee needed: ",a.fee),a},exports.getVoidSigner=function(e,t){return new n.VoidSigner(e,t)},exports.getWalletFromMnemonic=function(e,t,r){if(!(t>=0&&t%1==0))throw new Error("Account index must be an integer greater than or equal to 0.");return n.HDNodeWallet.fromMnemonic(n.Mnemonic.fromPhrase(e),R(t,r,"EVM"))},exports.getXpubFromMnemonic=async function(e){if(!u.validateMnemonic(e))throw new Error("Invalid mnemonic phrase.");const t=await u.mnemonicToSeed(e);return m.fromSeed(t).derivePath(F).neutered().toBase58()},exports.isERC20Transfer=W,exports.isNativeTxn=q,exports.isSolanaProvider=e=>!(!e||"object"!=typeof e)&&!0===e[N],exports.omitUndefinedKeys=function(e){return Object.keys(e).reduce(((t,r)=>(void 0!==e[r]&&(t[r]=e[r]),t)),{})},exports.onBalanceChange=async(e,t,r,s)=>{const n=new Set(e.map((e=>e.toLowerCase()))),a=new Set(t.map((e=>e.toLowerCase()))),i=async e=>{const t=await r.getBlock(e,!0);t?.prefetchedTransactions.forEach((function(e){e.to&&a.has(e.to.toLowerCase())&&W(e,n)?s(e,{type:"erc20",contractAddress:e.to}):q(e,n)&&s(e,{type:"native"})}))},o=await r.on("block",i);return{unsubscribe:()=>o.off("block",i)}},exports.openLedgerApp=async function(e,t){try{return(await e.send(224,216,0,0,Buffer.from(t,"ascii"))).equals(Buffer.from([144,0]))}catch(e){return!1}},exports.psbt2ToPsbt0=Q,exports.quitLedgerApp=async function(e){return await e.send(176,167,0,0)},exports.selectUtxos=D,exports.serializeSolanaTx=e=>a.getBase64EncodedWireTransaction(e),exports.transferSol=async({from:e,to:t,amount:r,provider:s})=>{const{value:n}=await s.getLatestBlockhash().send(),o=[i.getTransferSolInstruction({source:a.createNoopSigner(a.address(e)),destination:a.address(t),amount:r})];return a.pipe(a.createTransactionMessage({version:0}),(e=>a.setTransactionMessageLifetimeUsingBlockhash(n,e)),(t=>a.setTransactionMessageFeePayer(a.address(e),t)),(e=>a.appendTransactionMessageInstructions(o,e)))},exports.transferToken=async({from:e,to:t,mint:r,amount:s,decimals:n,provider:i})=>{const[d]=await o.findAssociatedTokenPda({mint:a.address(r),owner:a.address(e),tokenProgram:o.TOKEN_PROGRAM_ADDRESS}),[u]=await o.findAssociatedTokenPda({mint:a.address(r),owner:a.address(t),tokenProgram:o.TOKEN_PROGRAM_ADDRESS}),c=await i.getAccountInfo(u,{encoding:"base64"}).send(),l=[];c.value||l.push(await o.getCreateAssociatedTokenIdempotentInstruction({payer:a.createNoopSigner(a.address(e)),mint:a.address(r),owner:a.address(t),ata:u})),l.push(o.getTransferCheckedInstruction({amount:s,authority:a.createNoopSigner(a.address(e)),decimals:n,mint:a.address(r),destination:u,source:d}));const{value:p}=await i.getLatestBlockhash().send();return a.pipe(a.createTransactionMessage({version:0}),(e=>a.setTransactionMessageLifetimeUsingBlockhash(p,e)),(t=>a.setTransactionMessageFeePayer(a.address(e),t)),(e=>a.appendTransactionMessageInstructions(l,e)))};
package/dist/index.d.ts CHANGED
@@ -1,23 +1,21 @@
1
- import { Transaction } from '@ledgerhq/hw-app-btc/lib/types';
2
1
  import * as bitcoinjs_lib from 'bitcoinjs-lib';
3
- import { Network, Psbt, ECPairInterface, Transaction as Transaction$1 } from 'bitcoinjs-lib';
4
- export { networks as BtcNetworks } from 'bitcoinjs-lib';
5
- import { WalletPolicy, PsbtV2 } from 'ledger-bitcoin';
2
+ import { Network, Psbt, ECPairInterface, Transaction as Transaction$1, networks } from 'bitcoinjs-lib';
3
+ import Eth from '@ledgerhq/hw-app-eth';
4
+ import Transport from '@ledgerhq/hw-transport';
6
5
  import * as ethers from 'ethers';
7
6
  import { Provider, VoidSigner, HDNodeWallet, TransactionResponse, JsonRpcProvider as JsonRpcProvider$1, FetchRequest, Network as Network$1, Contract, AbstractSigner, BytesLike, TransactionRequest, TypedDataDomain, TypedDataField } from 'ethers';
8
- import Transport from '@ledgerhq/hw-transport';
9
- import Eth from '@ledgerhq/hw-app-eth';
10
7
  import * as _avalabs_avalanchejs from '@avalabs/avalanchejs';
11
- import { VM, Common, OutputOwners, TransferableOutput, pvmSerial, Context, info, avm, pvm, evm, avaxSerial, utils, UnsignedTx, EVMUnsignedTx, Utxo, TransferOutput, Credential, Signature } from '@avalabs/avalanchejs';
8
+ import { VM, OutputOwners, TransferableOutput, Common, pvmSerial, Context, avm, pvm, evm, info, avaxSerial, utils, UnsignedTx, EVMUnsignedTx, Utxo, TransferOutput, Credential, Signature } from '@avalabs/avalanchejs';
12
9
  import * as _avalabs_avalanchejs_dist_vms_common from '@avalabs/avalanchejs/dist/vms/common';
13
10
  import { Bip32Path } from 'bip32-path';
14
11
  import AppZondax, { ResponseBase } from '@avalabs/hw-app-avalanche';
15
12
  import { BIP32Interface } from 'bip32';
16
- import { GetUpgradesInfoResponse } from '@avalabs/avalanchejs/dist/info/model';
17
- import * as _avalabs_avalanchejs_dist_vms_pvm from '@avalabs/avalanchejs/dist/vms/pvm';
18
13
  import { Utxo as Utxo$1, PChainUtxo, Network as Network$2 } from '@avalabs/glacier-sdk';
19
14
  import * as _avalabs_avalanchejs_dist_serializable_common_types from '@avalabs/avalanchejs/dist/serializable/common/types';
20
- import { WalletAbstract as WalletAbstract$1 } from 'Avalanche/wallets';
15
+ import * as _solana_kit from '@solana/kit';
16
+ import { CompilableTransactionMessage, Transaction as Transaction$2, IInstruction } from '@solana/kit';
17
+ import { Transaction } from '@ledgerhq/hw-app-btc/lib/types';
18
+ import { WalletPolicy, PsbtV2 } from 'ledger-bitcoin';
21
19
 
22
20
  /**
23
21
  * Custom Bitcoin UTXO interface.
@@ -562,6 +560,8 @@ declare class BitcoinWalletVoid extends BitcoinWalletAbstract {
562
560
  signTx(tx: any): any;
563
561
  }
564
562
 
563
+ declare const BtcNetworks: typeof networks;
564
+
565
565
  type ChainIDAlias = 'X' | 'P' | 'C';
566
566
  /**
567
567
  * Types for parsed transaction
@@ -774,16 +774,13 @@ declare function isTransferSubnetOwnershipTx(tx: Tx): tx is TransferSubnetOwners
774
774
  declare class AbstractProvider {
775
775
  protected baseUrl: string;
776
776
  protected context: Context.Context;
777
- protected upgradesInfo?: info.GetUpgradesInfoResponse | undefined;
778
777
  evmRpc: JsonRpcProvider$1;
779
- constructor(baseUrl: string, context: Context.Context, upgradesInfo?: info.GetUpgradesInfoResponse | undefined);
778
+ constructor(baseUrl: string, context: Context.Context);
780
779
  /**
781
780
  * @link https://docs.ethers.io/v5/api/providers/provider/#Provider-getFeeData
782
781
  */
783
782
  getEvmFeeData(): Promise<ethers.FeeData>;
784
783
  getContext(): Context.Context;
785
- isEtnaEnabled(): boolean;
786
- getUpgradesInfo(): info.GetUpgradesInfoResponse | undefined;
787
784
  getChainID(chainAlias: ChainIDAlias): string;
788
785
  getNetworkID(): number;
789
786
  getHrp(): string;
@@ -811,11 +808,11 @@ declare class AbstractProvider {
811
808
  }
812
809
 
813
810
  declare class JsonRpcProvider extends AbstractProvider {
814
- constructor(baseUrl: string, context: Context.Context, upgradesInfo?: GetUpgradesInfoResponse);
811
+ constructor(baseUrl: string, context: Context.Context);
815
812
  static fromBaseURL(url: string): Promise<JsonRpcProvider>;
816
- static getDefaultMainnetProvider(upgradesInfo?: GetUpgradesInfoResponse): JsonRpcProvider;
817
- static getDefaultFujiProvider(upgradesInfo?: GetUpgradesInfoResponse): JsonRpcProvider;
818
- static getDefaultDevnetProvider(upgradesInfo?: GetUpgradesInfoResponse): JsonRpcProvider;
813
+ static getDefaultMainnetProvider(): JsonRpcProvider;
814
+ static getDefaultFujiProvider(): JsonRpcProvider;
815
+ static getDefaultDevnetProvider(): JsonRpcProvider;
819
816
  }
820
817
 
821
818
  /**
@@ -826,24 +823,7 @@ declare const MainnetContext: Context.Context;
826
823
  * Avalanche Fuji testnet context
827
824
  */
828
825
  declare const FujiContext: Context.Context;
829
- declare const DevnetContext: {
830
- addPrimaryNetworkDelegatorFee: bigint;
831
- addPrimaryNetworkValidatorFee: bigint;
832
- addSubnetDelegatorFee: bigint;
833
- addSubnetValidatorFee: bigint;
834
- avaxAssetID: string;
835
- baseTxFee: bigint;
836
- cBlockchainID: string;
837
- createAssetTxFee: bigint;
838
- createBlockchainTxFee: bigint;
839
- createSubnetTxFee: bigint;
840
- hrp: string;
841
- networkID: number;
842
- pBlockchainID: string;
843
- transformSubnetTxFee: bigint;
844
- xBlockchainID: string;
845
- platformFeeConfig: _avalabs_avalanchejs_dist_vms_pvm.FeeConfig;
846
- };
826
+ declare const DevnetContext: Context.Context;
847
827
 
848
828
  type BaseTx = {
849
829
  utxoSet: utils.UtxoSet;
@@ -1099,12 +1079,6 @@ declare abstract class WalletAbstract {
1099
1079
  * @param toAddress
1100
1080
  */
1101
1081
  exportP({ amount, utxoSet, destination, feeState, toAddress }: ExportP): Common.UnsignedTx;
1102
- addValidator(utxos: utils.UtxoSet, nodeId: string, stakeAmount: bigint, startDate: bigint, endDate: bigint, delegationFee: number, config?: {
1103
- rewardAddress?: string;
1104
- }): Common.UnsignedTx;
1105
- addDelegator(utxos: utils.UtxoSet, nodeId: string, stakeAmount: bigint, startDate: bigint, endDate: bigint, config?: {
1106
- rewardAddress?: string;
1107
- }): Common.UnsignedTx;
1108
1082
  consolidateP({ utxoSet, amount, feeState, toAddress, options, }: ConsolidateP): Common.UnsignedTx;
1109
1083
  baseTX({ utxoSet, chain, toAddress, amountsPerAsset, feeState, options, fromAddresses, }: BaseTx): Common.UnsignedTx;
1110
1084
  convertSubnetToL1({ utxoSet, chainId, subnetId, subnetAuth, feeState, address, validators, options, fromAddresses, }: ConvertSubnetToL1): Common.UnsignedTx;
@@ -1147,7 +1121,6 @@ declare abstract class WalletAbstract {
1147
1121
  addPermissionlessDelegator({ utxoSet, nodeId, start, end, weight, subnetId, fromAddresses, rewardAddresses, options, locktime, feeState, threshold, stakingAssetId, }: AddPermissionlessDelegator): Common.UnsignedTx;
1148
1122
  removeSubnetValidator({ utxoSet, nodeId, subnetId, subnetAuth, fromAddresses, feeState, options, }: RemoveSubnetValidator): Common.UnsignedTx;
1149
1123
  transferSubnetOwnershipTx({ utxoSet, subnetId, subnetAuth, subnetOwners, feeState, fromAddresses, options, threshold, locktime, }: TransferSubnetOwnershipTx): Common.UnsignedTx;
1150
- 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: bigint, maxValidatorWeightFactor: number, uptimeRequirement: number, subnetAuth: number[], fromAddresses?: string[], options?: Common.SpendOptions): Common.UnsignedTx;
1151
1124
  protected constructor(provider: AbstractProvider);
1152
1125
  }
1153
1126
 
@@ -1702,16 +1675,6 @@ declare function getStakeForAddresses(addresses: string[], api: pvm.PVMApi): Pro
1702
1675
  */
1703
1676
  declare function getUnixNow(): bigint;
1704
1677
 
1705
- type UtxoInfo = {
1706
- utxoId: string;
1707
- assetId: string;
1708
- locktime: bigint;
1709
- stakeableLocktime: bigint;
1710
- threshold: number;
1711
- amount: bigint;
1712
- };
1713
- declare const getUtxoInfo: (utxo: Utxo) => UtxoInfo;
1714
-
1715
1678
  type Params = {
1716
1679
  transactionHex: string;
1717
1680
  chainAlias: ChainIDAlias;
@@ -1758,12 +1721,13 @@ declare function signedTxToHex(signedTx: avaxSerial.SignedTx): string;
1758
1721
 
1759
1722
  /**
1760
1723
  * The UTXOs will be sorted in the following order.
1761
- * 1- LockedStakeable UTXOs with the highest locktime to lowest
1762
- * 2- Highest value UTXOs to lowest
1724
+ * 1- Highest value unlocked UTXO (for fees)
1725
+ * 2- LockedStakeable UTXOs with the highest locktime to lowest
1726
+ * 3- Rest of the unlocked UTXOs highest to lowest
1763
1727
  * @remark Does not check for locked UTXOs
1764
1728
  */
1765
- declare function sortUTXOsStaking(utxos: Utxo[]): Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[];
1766
- declare function sortUTXOsByAmount(utxos: Utxo[], isDescending: boolean): Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[];
1729
+ declare function sortUTXOsStaking(utxos: Utxo[]): Utxo[];
1730
+ declare function sortUTXOsByAmount(utxos: Utxo[], isDescending: boolean): Utxo[];
1767
1731
  declare const sortUTXOsByAmountDescending: (utxos: Utxo[]) => Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[];
1768
1732
  declare const sortUTXOsByAmountAscending: (utxos: Utxo[]) => Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[];
1769
1733
 
@@ -1795,7 +1759,7 @@ declare const P_CHAIN_TX_SIZE_LIMIT = 65536;
1795
1759
  * @returns the largest prefix of sorted `utxos` before hitting the size limit. If no such prefix exists, then an empty array.
1796
1760
  */
1797
1761
  declare function getMaximumUtxoSet({ wallet, utxos, sizeSupportedTx, limit, feeState, }: {
1798
- wallet: WalletAbstract$1;
1762
+ wallet: WalletAbstract;
1799
1763
  utxos: Utxo[];
1800
1764
  sizeSupportedTx: SizeSupportedTx;
1801
1765
  limit?: number;
@@ -1865,7 +1829,6 @@ type index_TxBase = TxBase;
1865
1829
  type index_TxType = TxType;
1866
1830
  declare const index_TxType: typeof TxType;
1867
1831
  type index_UnknownTx = UnknownTx;
1868
- type index_UtxoInfo = UtxoInfo;
1869
1832
  type index_WalletAbstract = WalletAbstract;
1870
1833
  declare const index_WalletAbstract: typeof WalletAbstract;
1871
1834
  type index_WalletVoid = WalletVoid;
@@ -1887,7 +1850,6 @@ declare const index_getStakeForAddresses: typeof getStakeForAddresses;
1887
1850
  declare const index_getStakedAssetBalance: typeof getStakedAssetBalance;
1888
1851
  declare const index_getUTXOsForAddresses: typeof getUTXOsForAddresses;
1889
1852
  declare const index_getUnixNow: typeof getUnixNow;
1890
- declare const index_getUtxoInfo: typeof getUtxoInfo;
1891
1853
  declare const index_getUtxosByTxFromGlacier: typeof getUtxosByTxFromGlacier;
1892
1854
  declare const index_getVmByChainAlias: typeof getVmByChainAlias;
1893
1855
  declare const index_getXpubFromMnemonic: typeof getXpubFromMnemonic;
@@ -1920,107 +1882,8 @@ declare const index_sortUTXOsByAmountDescending: typeof sortUTXOsByAmountDescend
1920
1882
  declare const index_sortUTXOsStaking: typeof sortUTXOsStaking;
1921
1883
  declare const index_verifyDerivationPath: typeof verifyDerivationPath;
1922
1884
  declare namespace index {
1923
- export {
1924
- index_AbstractProvider as AbstractProvider,
1925
- index_AddDelegatorTx as AddDelegatorTx,
1926
- index_AddPermissionlessDelegatorTx as AddPermissionlessDelegatorTx,
1927
- index_AddPermissionlessValidatorTx as AddPermissionlessValidatorTx,
1928
- index_AddSubnetValidatorTx as AddSubnetValidatorTx,
1929
- index_AddValidatorTx as AddValidatorTx,
1930
- index_AddressWallet as AddressWallet,
1931
- BaseTx$1 as BaseTx,
1932
- index_ChainIDAlias as ChainIDAlias,
1933
- index_ConvertSubnetToL1Tx as ConvertSubnetToL1Tx,
1934
- index_CreateChainTx as CreateChainTx,
1935
- index_CreateSubnetTx as CreateSubnetTx,
1936
- index_DevnetContext as DevnetContext,
1937
- index_DisableL1ValidatorTx as DisableL1ValidatorTx,
1938
- index_ExportTx as ExportTx,
1939
- index_FeeData as FeeData,
1940
- index_FujiContext as FujiContext,
1941
- index_GetAvaxBalanceDict as GetAvaxBalanceDict,
1942
- index_GetStakedAvaxBalanceDict as GetStakedAvaxBalanceDict,
1943
- index_GlacierOutput as GlacierOutput,
1944
- index_ImportTx as ImportTx,
1945
- index_IncreaseL1ValidatorBalanceTx as IncreaseL1ValidatorBalanceTx,
1946
- index_JsonRpcProvider as JsonRpcProvider,
1947
- index_LedgerGetXpubResponse as LedgerGetXpubResponse,
1948
- index_LedgerSigner as LedgerSigner,
1949
- index_LedgerWallet as LedgerWallet,
1950
- index_MainnetContext as MainnetContext,
1951
- index_MnemonicWallet as MnemonicWallet,
1952
- index_MnemonicWalletVoid as MnemonicWalletVoid,
1953
- index_P_CHAIN_TX_SIZE_LIMIT as P_CHAIN_TX_SIZE_LIMIT,
1954
- index_RegisterL1ValidatorTx as RegisterL1ValidatorTx,
1955
- index_RemoveSubnetValidatorTx as RemoveSubnetValidatorTx,
1956
- index_SetL1ValidatorWeightTx as SetL1ValidatorWeightTx,
1957
- index_SignMessageRequest as SignMessageRequest,
1958
- index_SignTxBufferRequest as SignTxBufferRequest,
1959
- index_SignTxRequest as SignTxRequest,
1960
- index_Signer as Signer,
1961
- index_SimpleLedgerSigner as SimpleLedgerSigner,
1962
- index_SimpleSigner as SimpleSigner,
1963
- index_SizeSupportedTx as SizeSupportedTx,
1964
- index_StaticSigner as StaticSigner,
1965
- TransferSubnetOwnershipTx$1 as TransferSubnetOwnershipTx,
1966
- index_TransformSubnetTx as TransformSubnetTx,
1967
- index_Tx as Tx,
1968
- index_TxBase as TxBase,
1969
- index_TxType as TxType,
1970
- index_UnknownTx as UnknownTx,
1971
- index_UtxoInfo as UtxoInfo,
1972
- index_WalletAbstract as WalletAbstract,
1973
- index_WalletVoid as WalletVoid,
1974
- index_addSignaturesToAvalancheTx as addSignaturesToAvalancheTx,
1975
- index_convertGlacierUtxo as convertGlacierUtxo,
1976
- index_createAvalancheEvmUnsignedTx as createAvalancheEvmUnsignedTx,
1977
- index_createAvalancheUnsignedTx as createAvalancheUnsignedTx,
1978
- index_digestMessage as digestMessage,
1979
- index_emptySignature as emptySignature,
1980
- index_getAddressFromXpub as getAddressFromXpub,
1981
- index_getAddressPublicKeyFromXpub as getAddressPublicKeyFromXpub,
1982
- index_getAssetBalance as getAssetBalance,
1983
- index_getLedgerProvider as getLedgerProvider,
1984
- index_getMaximumUtxoSet as getMaximumUtxoSet,
1985
- index_getPaginatedUTXOs as getPaginatedUTXOs,
1986
- index_getPchainUnixNow as getPchainUnixNow,
1987
- index_getStakeForAddresses as getStakeForAddresses,
1988
- index_getStakedAssetBalance as getStakedAssetBalance,
1989
- index_getUTXOsForAddresses as getUTXOsForAddresses,
1990
- index_getUnixNow as getUnixNow,
1991
- index_getUtxoInfo as getUtxoInfo,
1992
- index_getUtxosByTxFromGlacier as getUtxosByTxFromGlacier,
1993
- index_getVmByChainAlias as getVmByChainAlias,
1994
- index_getXpubFromMnemonic as getXpubFromMnemonic,
1995
- index_isAddDelegatorTx as isAddDelegatorTx,
1996
- index_isAddPermissionlessDelegatorTx as isAddPermissionlessDelegatorTx,
1997
- index_isAddPermissionlessValidatorTx as isAddPermissionlessValidatorTx,
1998
- index_isAddSubnetValidatorTx as isAddSubnetValidatorTx,
1999
- index_isAddValidatorTx as isAddValidatorTx,
2000
- index_isBaseTx as isBaseTx,
2001
- index_isBech32Address as isBech32Address,
2002
- index_isConvertSubnetToL1Tx as isConvertSubnetToL1Tx,
2003
- index_isCreateChainTx as isCreateChainTx,
2004
- index_isCreateSubnetTx as isCreateSubnetTx,
2005
- index_isDisableL1ValidatorTx as isDisableL1ValidatorTx,
2006
- index_isExportTx as isExportTx,
2007
- index_isImportTx as isImportTx,
2008
- index_isIncreaseL1ValidatorBalance as isIncreaseL1ValidatorBalance,
2009
- index_isObsidianApp as isObsidianApp,
2010
- index_isRegisterL1ValidatorTx as isRegisterL1ValidatorTx,
2011
- index_isRemoveSubnetValidatorTx as isRemoveSubnetValidatorTx,
2012
- index_isSetL1ValidatorWeightTx as isSetL1ValidatorWeightTx,
2013
- index_isTransferSubnetOwnershipTx as isTransferSubnetOwnershipTx,
2014
- index_isTransformSubnetTx as isTransformSubnetTx,
2015
- index_parseAvalancheTx as parseAvalancheTx,
2016
- index_populateCredential as populateCredential,
2017
- index_signedTxToHex as signedTxToHex,
2018
- index_sortUTXOsByAmount as sortUTXOsByAmount,
2019
- index_sortUTXOsByAmountAscending as sortUTXOsByAmountAscending,
2020
- index_sortUTXOsByAmountDescending as sortUTXOsByAmountDescending,
2021
- index_sortUTXOsStaking as sortUTXOsStaking,
2022
- index_verifyDerivationPath as verifyDerivationPath,
2023
- };
1885
+ export { index_AbstractProvider as AbstractProvider, index_AddressWallet as AddressWallet, index_DevnetContext as DevnetContext, index_FujiContext as FujiContext, index_JsonRpcProvider as JsonRpcProvider, index_LedgerSigner as LedgerSigner, index_LedgerWallet as LedgerWallet, index_MainnetContext as MainnetContext, index_MnemonicWallet as MnemonicWallet, index_MnemonicWalletVoid as MnemonicWalletVoid, index_P_CHAIN_TX_SIZE_LIMIT as P_CHAIN_TX_SIZE_LIMIT, index_SimpleLedgerSigner as SimpleLedgerSigner, index_SimpleSigner as SimpleSigner, index_SizeSupportedTx as SizeSupportedTx, index_StaticSigner as StaticSigner, index_TxType as TxType, index_WalletAbstract as WalletAbstract, index_WalletVoid as WalletVoid, index_addSignaturesToAvalancheTx as addSignaturesToAvalancheTx, index_convertGlacierUtxo as convertGlacierUtxo, index_createAvalancheEvmUnsignedTx as createAvalancheEvmUnsignedTx, index_createAvalancheUnsignedTx as createAvalancheUnsignedTx, index_digestMessage as digestMessage, index_emptySignature as emptySignature, index_getAddressFromXpub as getAddressFromXpub, index_getAddressPublicKeyFromXpub as getAddressPublicKeyFromXpub, index_getAssetBalance as getAssetBalance, index_getLedgerProvider as getLedgerProvider, index_getMaximumUtxoSet as getMaximumUtxoSet, index_getPaginatedUTXOs as getPaginatedUTXOs, index_getPchainUnixNow as getPchainUnixNow, index_getStakeForAddresses as getStakeForAddresses, index_getStakedAssetBalance as getStakedAssetBalance, index_getUTXOsForAddresses as getUTXOsForAddresses, index_getUnixNow as getUnixNow, index_getUtxosByTxFromGlacier as getUtxosByTxFromGlacier, index_getVmByChainAlias as getVmByChainAlias, index_getXpubFromMnemonic as getXpubFromMnemonic, index_isAddDelegatorTx as isAddDelegatorTx, index_isAddPermissionlessDelegatorTx as isAddPermissionlessDelegatorTx, index_isAddPermissionlessValidatorTx as isAddPermissionlessValidatorTx, index_isAddSubnetValidatorTx as isAddSubnetValidatorTx, index_isAddValidatorTx as isAddValidatorTx, index_isBaseTx as isBaseTx, index_isBech32Address as isBech32Address, index_isConvertSubnetToL1Tx as isConvertSubnetToL1Tx, index_isCreateChainTx as isCreateChainTx, index_isCreateSubnetTx as isCreateSubnetTx, index_isDisableL1ValidatorTx as isDisableL1ValidatorTx, index_isExportTx as isExportTx, index_isImportTx as isImportTx, index_isIncreaseL1ValidatorBalance as isIncreaseL1ValidatorBalance, index_isObsidianApp as isObsidianApp, index_isRegisterL1ValidatorTx as isRegisterL1ValidatorTx, index_isRemoveSubnetValidatorTx as isRemoveSubnetValidatorTx, index_isSetL1ValidatorWeightTx as isSetL1ValidatorWeightTx, index_isTransferSubnetOwnershipTx as isTransferSubnetOwnershipTx, index_isTransformSubnetTx as isTransformSubnetTx, index_parseAvalancheTx as parseAvalancheTx, index_populateCredential as populateCredential, index_signedTxToHex as signedTxToHex, index_sortUTXOsByAmount as sortUTXOsByAmount, index_sortUTXOsByAmountAscending as sortUTXOsByAmountAscending, index_sortUTXOsByAmountDescending as sortUTXOsByAmountDescending, index_sortUTXOsStaking as sortUTXOsStaking, index_verifyDerivationPath as verifyDerivationPath };
1886
+ export type { index_AddDelegatorTx as AddDelegatorTx, index_AddPermissionlessDelegatorTx as AddPermissionlessDelegatorTx, index_AddPermissionlessValidatorTx as AddPermissionlessValidatorTx, index_AddSubnetValidatorTx as AddSubnetValidatorTx, index_AddValidatorTx as AddValidatorTx, BaseTx$1 as BaseTx, index_ChainIDAlias as ChainIDAlias, index_ConvertSubnetToL1Tx as ConvertSubnetToL1Tx, index_CreateChainTx as CreateChainTx, index_CreateSubnetTx as CreateSubnetTx, index_DisableL1ValidatorTx as DisableL1ValidatorTx, index_ExportTx as ExportTx, index_FeeData as FeeData, index_GetAvaxBalanceDict as GetAvaxBalanceDict, index_GetStakedAvaxBalanceDict as GetStakedAvaxBalanceDict, index_GlacierOutput as GlacierOutput, index_ImportTx as ImportTx, index_IncreaseL1ValidatorBalanceTx as IncreaseL1ValidatorBalanceTx, index_LedgerGetXpubResponse as LedgerGetXpubResponse, index_RegisterL1ValidatorTx as RegisterL1ValidatorTx, index_RemoveSubnetValidatorTx as RemoveSubnetValidatorTx, index_SetL1ValidatorWeightTx as SetL1ValidatorWeightTx, index_SignMessageRequest as SignMessageRequest, index_SignTxBufferRequest as SignTxBufferRequest, index_SignTxRequest as SignTxRequest, index_Signer as Signer, TransferSubnetOwnershipTx$1 as TransferSubnetOwnershipTx, index_TransformSubnetTx as TransformSubnetTx, index_Tx as Tx, index_TxBase as TxBase, index_UnknownTx as UnknownTx };
2024
1887
  }
2025
1888
 
2026
1889
  /**
@@ -2028,8 +1891,11 @@ declare namespace index {
2028
1891
  * @param addressIndex Which index is the address on
2029
1892
  * @param pathSpec BIP44 vs LedgerLive
2030
1893
  * @param vm Which VM is this address on. Coin index changes between Avalanche and EVM
1894
+ * @param withRoot If false, skips the "m/" prefix. Needed for Solana Ledger app.
2031
1895
  */
2032
- declare function getAddressDerivationPath(addressIndex: number, pathSpec: DerivationPath, vm: 'EVM' | 'AVM' | 'PVM'): string;
1896
+ declare function getAddressDerivationPath(addressIndex: number, pathSpec: DerivationPath, // Irrelevant for Solana
1897
+ vm: 'SVM', withRoot?: boolean): string;
1898
+ declare function getAddressDerivationPath(addressIndex: number, pathSpec: DerivationPath, vm: 'EVM' | 'AVM' | 'PVM', withRoot?: never): string;
2033
1899
 
2034
1900
  /**
2035
1901
  * Get the public key from a given private key.
@@ -2074,4 +1940,70 @@ declare function openLedgerApp(transport: Transport, applicationName: string): P
2074
1940
  */
2075
1941
  declare function quitLedgerApp(transport: Transport): Promise<Buffer>;
2076
1942
 
2077
- export { index as Avalanche, BitcoinHistoryTx, BitcoinInputUTXO, BitcoinInputUTXOWithOptionalScript, BitcoinLedgerInputUTXO, BitcoinLedgerWallet, BitcoinOutputUTXO, BitcoinProvider, BitcoinProviderAbstract, BitcoinTx, BitcoinWallet, BitcoinWalletAbstract, BitcoinWalletVoid, DerivationPath, ETH_ACCOUNT_PATH, ETH_COIN_PATH, JsonRpcBatchInternal, LedgerSigner$1 as LedgerSigner, addEncodedSigToPsbt, createPSBTV2, createPsbt, createTransferTx, createWalletPolicy, formatAddressForNetworkBech32, getAddressDerivationPath, getAddressFromXPub, getAddressPrivateKeyFromXPriv, getAddressPublicKeyFromXPub, getAppEth, getBech32Address, getBech32AddressFromXPub, getBtcAddressFromPubKey, getEvmAddressFromPubKey, getLedgerAppInfo, getLedgerExtendedPublicKey, getMaxTransferAmount, getPubKeyFromTransport, getPublicKeyFromPrivateKey, getTransferTxDetails, getVoidSigner, getWalletFromMnemonic, getXpubFromMnemonic$1 as getXpubFromMnemonic, isERC20Transfer, isNativeTxn, omitUndefinedKeys, onBalanceChange, openLedgerApp, psbt2ToPsbt0, quitLedgerApp, selectUtxos };
1943
+ declare const compileSolanaTx: (compilableTx: CompilableTransactionMessage) => Readonly<Readonly<{
1944
+ messageBytes: _solana_kit.TransactionMessageBytes;
1945
+ signatures: _solana_kit.SignaturesMap;
1946
+ }> & _solana_kit.TransactionWithLifetime>;
1947
+
1948
+ type SolanaProvider = ReturnType<typeof getSolanaProvider>;
1949
+ declare const isSolanaProvider: (something: unknown) => something is _solana_kit.RpcDevnet<(_solana_kit.GetAccountInfoApi & _solana_kit.GetBalanceApi & _solana_kit.GetBlockApi & _solana_kit.GetBlockCommitmentApi & _solana_kit.GetBlockHeightApi & _solana_kit.GetBlockProductionApi & _solana_kit.GetBlocksApi & _solana_kit.GetBlocksWithLimitApi & _solana_kit.GetBlockTimeApi & _solana_kit.GetClusterNodesApi & _solana_kit.GetEpochInfoApi & _solana_kit.GetEpochScheduleApi & _solana_kit.GetFeeForMessageApi & _solana_kit.GetFirstAvailableBlockApi & _solana_kit.GetGenesisHashApi & _solana_kit.GetHealthApi & _solana_kit.GetHighestSnapshotSlotApi & _solana_kit.GetIdentityApi & _solana_kit.GetInflationGovernorApi & _solana_kit.GetInflationRateApi & _solana_kit.GetInflationRewardApi & _solana_kit.GetLargestAccountsApi & _solana_kit.GetLatestBlockhashApi & _solana_kit.GetLeaderScheduleApi & _solana_kit.GetMaxRetransmitSlotApi & _solana_kit.GetMaxShredInsertSlotApi & _solana_kit.GetMinimumBalanceForRentExemptionApi & _solana_kit.GetMultipleAccountsApi & _solana_kit.GetProgramAccountsApi & _solana_kit.GetRecentPerformanceSamplesApi & _solana_kit.GetRecentPrioritizationFeesApi & _solana_kit.GetSignaturesForAddressApi & _solana_kit.GetSignatureStatusesApi & _solana_kit.GetSlotApi & _solana_kit.GetSlotLeaderApi & _solana_kit.GetSlotLeadersApi & _solana_kit.GetStakeMinimumDelegationApi & _solana_kit.GetSupplyApi & _solana_kit.GetTokenAccountBalanceApi & _solana_kit.GetTokenAccountsByDelegateApi & _solana_kit.GetTokenAccountsByOwnerApi & _solana_kit.GetTokenLargestAccountsApi & _solana_kit.GetTokenSupplyApi & _solana_kit.GetTransactionApi & _solana_kit.GetTransactionCountApi & _solana_kit.GetVersionApi & _solana_kit.GetVoteAccountsApi & _solana_kit.IsBlockhashValidApi & _solana_kit.MinimumLedgerSlotApi & _solana_kit.SendTransactionApi & _solana_kit.SimulateTransactionApi) | (_solana_kit.RequestAirdropApi & _solana_kit.GetAccountInfoApi & _solana_kit.GetBalanceApi & _solana_kit.GetBlockApi & _solana_kit.GetBlockCommitmentApi & _solana_kit.GetBlockHeightApi & _solana_kit.GetBlockProductionApi & _solana_kit.GetBlocksApi & _solana_kit.GetBlocksWithLimitApi & _solana_kit.GetBlockTimeApi & _solana_kit.GetClusterNodesApi & _solana_kit.GetEpochInfoApi & _solana_kit.GetEpochScheduleApi & _solana_kit.GetFeeForMessageApi & _solana_kit.GetFirstAvailableBlockApi & _solana_kit.GetGenesisHashApi & _solana_kit.GetHealthApi & _solana_kit.GetHighestSnapshotSlotApi & _solana_kit.GetIdentityApi & _solana_kit.GetInflationGovernorApi & _solana_kit.GetInflationRateApi & _solana_kit.GetInflationRewardApi & _solana_kit.GetLargestAccountsApi & _solana_kit.GetLatestBlockhashApi & _solana_kit.GetLeaderScheduleApi & _solana_kit.GetMaxRetransmitSlotApi & _solana_kit.GetMaxShredInsertSlotApi & _solana_kit.GetMinimumBalanceForRentExemptionApi & _solana_kit.GetMultipleAccountsApi & _solana_kit.GetProgramAccountsApi & _solana_kit.GetRecentPerformanceSamplesApi & _solana_kit.GetRecentPrioritizationFeesApi & _solana_kit.GetSignaturesForAddressApi & _solana_kit.GetSignatureStatusesApi & _solana_kit.GetSlotApi & _solana_kit.GetSlotLeaderApi & _solana_kit.GetSlotLeadersApi & _solana_kit.GetStakeMinimumDelegationApi & _solana_kit.GetSupplyApi & _solana_kit.GetTokenAccountBalanceApi & _solana_kit.GetTokenAccountsByDelegateApi & _solana_kit.GetTokenAccountsByOwnerApi & _solana_kit.GetTokenLargestAccountsApi & _solana_kit.GetTokenSupplyApi & _solana_kit.GetTransactionApi & _solana_kit.GetTransactionCountApi & _solana_kit.GetVersionApi & _solana_kit.GetVoteAccountsApi & _solana_kit.IsBlockhashValidApi & _solana_kit.MinimumLedgerSlotApi & _solana_kit.SendTransactionApi & _solana_kit.SimulateTransactionApi)> | _solana_kit.RpcMainnet<(_solana_kit.GetAccountInfoApi & _solana_kit.GetBalanceApi & _solana_kit.GetBlockApi & _solana_kit.GetBlockCommitmentApi & _solana_kit.GetBlockHeightApi & _solana_kit.GetBlockProductionApi & _solana_kit.GetBlocksApi & _solana_kit.GetBlocksWithLimitApi & _solana_kit.GetBlockTimeApi & _solana_kit.GetClusterNodesApi & _solana_kit.GetEpochInfoApi & _solana_kit.GetEpochScheduleApi & _solana_kit.GetFeeForMessageApi & _solana_kit.GetFirstAvailableBlockApi & _solana_kit.GetGenesisHashApi & _solana_kit.GetHealthApi & _solana_kit.GetHighestSnapshotSlotApi & _solana_kit.GetIdentityApi & _solana_kit.GetInflationGovernorApi & _solana_kit.GetInflationRateApi & _solana_kit.GetInflationRewardApi & _solana_kit.GetLargestAccountsApi & _solana_kit.GetLatestBlockhashApi & _solana_kit.GetLeaderScheduleApi & _solana_kit.GetMaxRetransmitSlotApi & _solana_kit.GetMaxShredInsertSlotApi & _solana_kit.GetMinimumBalanceForRentExemptionApi & _solana_kit.GetMultipleAccountsApi & _solana_kit.GetProgramAccountsApi & _solana_kit.GetRecentPerformanceSamplesApi & _solana_kit.GetRecentPrioritizationFeesApi & _solana_kit.GetSignaturesForAddressApi & _solana_kit.GetSignatureStatusesApi & _solana_kit.GetSlotApi & _solana_kit.GetSlotLeaderApi & _solana_kit.GetSlotLeadersApi & _solana_kit.GetStakeMinimumDelegationApi & _solana_kit.GetSupplyApi & _solana_kit.GetTokenAccountBalanceApi & _solana_kit.GetTokenAccountsByDelegateApi & _solana_kit.GetTokenAccountsByOwnerApi & _solana_kit.GetTokenLargestAccountsApi & _solana_kit.GetTokenSupplyApi & _solana_kit.GetTransactionApi & _solana_kit.GetTransactionCountApi & _solana_kit.GetVersionApi & _solana_kit.GetVoteAccountsApi & _solana_kit.IsBlockhashValidApi & _solana_kit.MinimumLedgerSlotApi & _solana_kit.SendTransactionApi & _solana_kit.SimulateTransactionApi) | (_solana_kit.RequestAirdropApi & _solana_kit.GetAccountInfoApi & _solana_kit.GetBalanceApi & _solana_kit.GetBlockApi & _solana_kit.GetBlockCommitmentApi & _solana_kit.GetBlockHeightApi & _solana_kit.GetBlockProductionApi & _solana_kit.GetBlocksApi & _solana_kit.GetBlocksWithLimitApi & _solana_kit.GetBlockTimeApi & _solana_kit.GetClusterNodesApi & _solana_kit.GetEpochInfoApi & _solana_kit.GetEpochScheduleApi & _solana_kit.GetFeeForMessageApi & _solana_kit.GetFirstAvailableBlockApi & _solana_kit.GetGenesisHashApi & _solana_kit.GetHealthApi & _solana_kit.GetHighestSnapshotSlotApi & _solana_kit.GetIdentityApi & _solana_kit.GetInflationGovernorApi & _solana_kit.GetInflationRateApi & _solana_kit.GetInflationRewardApi & _solana_kit.GetLargestAccountsApi & _solana_kit.GetLatestBlockhashApi & _solana_kit.GetLeaderScheduleApi & _solana_kit.GetMaxRetransmitSlotApi & _solana_kit.GetMaxShredInsertSlotApi & _solana_kit.GetMinimumBalanceForRentExemptionApi & _solana_kit.GetMultipleAccountsApi & _solana_kit.GetProgramAccountsApi & _solana_kit.GetRecentPerformanceSamplesApi & _solana_kit.GetRecentPrioritizationFeesApi & _solana_kit.GetSignaturesForAddressApi & _solana_kit.GetSignatureStatusesApi & _solana_kit.GetSlotApi & _solana_kit.GetSlotLeaderApi & _solana_kit.GetSlotLeadersApi & _solana_kit.GetStakeMinimumDelegationApi & _solana_kit.GetSupplyApi & _solana_kit.GetTokenAccountBalanceApi & _solana_kit.GetTokenAccountsByDelegateApi & _solana_kit.GetTokenAccountsByOwnerApi & _solana_kit.GetTokenLargestAccountsApi & _solana_kit.GetTokenSupplyApi & _solana_kit.GetTransactionApi & _solana_kit.GetTransactionCountApi & _solana_kit.GetVersionApi & _solana_kit.GetVoteAccountsApi & _solana_kit.IsBlockhashValidApi & _solana_kit.MinimumLedgerSlotApi & _solana_kit.SendTransactionApi & _solana_kit.SimulateTransactionApi)>;
1950
+ declare const getSolanaProvider: ({ isTestnet, rpcUrl, }: {
1951
+ isTestnet: boolean;
1952
+ rpcUrl: string;
1953
+ }) => _solana_kit.RpcDevnet<(_solana_kit.GetAccountInfoApi & _solana_kit.GetBalanceApi & _solana_kit.GetBlockApi & _solana_kit.GetBlockCommitmentApi & _solana_kit.GetBlockHeightApi & _solana_kit.GetBlockProductionApi & _solana_kit.GetBlocksApi & _solana_kit.GetBlocksWithLimitApi & _solana_kit.GetBlockTimeApi & _solana_kit.GetClusterNodesApi & _solana_kit.GetEpochInfoApi & _solana_kit.GetEpochScheduleApi & _solana_kit.GetFeeForMessageApi & _solana_kit.GetFirstAvailableBlockApi & _solana_kit.GetGenesisHashApi & _solana_kit.GetHealthApi & _solana_kit.GetHighestSnapshotSlotApi & _solana_kit.GetIdentityApi & _solana_kit.GetInflationGovernorApi & _solana_kit.GetInflationRateApi & _solana_kit.GetInflationRewardApi & _solana_kit.GetLargestAccountsApi & _solana_kit.GetLatestBlockhashApi & _solana_kit.GetLeaderScheduleApi & _solana_kit.GetMaxRetransmitSlotApi & _solana_kit.GetMaxShredInsertSlotApi & _solana_kit.GetMinimumBalanceForRentExemptionApi & _solana_kit.GetMultipleAccountsApi & _solana_kit.GetProgramAccountsApi & _solana_kit.GetRecentPerformanceSamplesApi & _solana_kit.GetRecentPrioritizationFeesApi & _solana_kit.GetSignaturesForAddressApi & _solana_kit.GetSignatureStatusesApi & _solana_kit.GetSlotApi & _solana_kit.GetSlotLeaderApi & _solana_kit.GetSlotLeadersApi & _solana_kit.GetStakeMinimumDelegationApi & _solana_kit.GetSupplyApi & _solana_kit.GetTokenAccountBalanceApi & _solana_kit.GetTokenAccountsByDelegateApi & _solana_kit.GetTokenAccountsByOwnerApi & _solana_kit.GetTokenLargestAccountsApi & _solana_kit.GetTokenSupplyApi & _solana_kit.GetTransactionApi & _solana_kit.GetTransactionCountApi & _solana_kit.GetVersionApi & _solana_kit.GetVoteAccountsApi & _solana_kit.IsBlockhashValidApi & _solana_kit.MinimumLedgerSlotApi & _solana_kit.SendTransactionApi & _solana_kit.SimulateTransactionApi) | (_solana_kit.RequestAirdropApi & _solana_kit.GetAccountInfoApi & _solana_kit.GetBalanceApi & _solana_kit.GetBlockApi & _solana_kit.GetBlockCommitmentApi & _solana_kit.GetBlockHeightApi & _solana_kit.GetBlockProductionApi & _solana_kit.GetBlocksApi & _solana_kit.GetBlocksWithLimitApi & _solana_kit.GetBlockTimeApi & _solana_kit.GetClusterNodesApi & _solana_kit.GetEpochInfoApi & _solana_kit.GetEpochScheduleApi & _solana_kit.GetFeeForMessageApi & _solana_kit.GetFirstAvailableBlockApi & _solana_kit.GetGenesisHashApi & _solana_kit.GetHealthApi & _solana_kit.GetHighestSnapshotSlotApi & _solana_kit.GetIdentityApi & _solana_kit.GetInflationGovernorApi & _solana_kit.GetInflationRateApi & _solana_kit.GetInflationRewardApi & _solana_kit.GetLargestAccountsApi & _solana_kit.GetLatestBlockhashApi & _solana_kit.GetLeaderScheduleApi & _solana_kit.GetMaxRetransmitSlotApi & _solana_kit.GetMaxShredInsertSlotApi & _solana_kit.GetMinimumBalanceForRentExemptionApi & _solana_kit.GetMultipleAccountsApi & _solana_kit.GetProgramAccountsApi & _solana_kit.GetRecentPerformanceSamplesApi & _solana_kit.GetRecentPrioritizationFeesApi & _solana_kit.GetSignaturesForAddressApi & _solana_kit.GetSignatureStatusesApi & _solana_kit.GetSlotApi & _solana_kit.GetSlotLeaderApi & _solana_kit.GetSlotLeadersApi & _solana_kit.GetStakeMinimumDelegationApi & _solana_kit.GetSupplyApi & _solana_kit.GetTokenAccountBalanceApi & _solana_kit.GetTokenAccountsByDelegateApi & _solana_kit.GetTokenAccountsByOwnerApi & _solana_kit.GetTokenLargestAccountsApi & _solana_kit.GetTokenSupplyApi & _solana_kit.GetTransactionApi & _solana_kit.GetTransactionCountApi & _solana_kit.GetVersionApi & _solana_kit.GetVoteAccountsApi & _solana_kit.IsBlockhashValidApi & _solana_kit.MinimumLedgerSlotApi & _solana_kit.SendTransactionApi & _solana_kit.SimulateTransactionApi)> | _solana_kit.RpcMainnet<(_solana_kit.GetAccountInfoApi & _solana_kit.GetBalanceApi & _solana_kit.GetBlockApi & _solana_kit.GetBlockCommitmentApi & _solana_kit.GetBlockHeightApi & _solana_kit.GetBlockProductionApi & _solana_kit.GetBlocksApi & _solana_kit.GetBlocksWithLimitApi & _solana_kit.GetBlockTimeApi & _solana_kit.GetClusterNodesApi & _solana_kit.GetEpochInfoApi & _solana_kit.GetEpochScheduleApi & _solana_kit.GetFeeForMessageApi & _solana_kit.GetFirstAvailableBlockApi & _solana_kit.GetGenesisHashApi & _solana_kit.GetHealthApi & _solana_kit.GetHighestSnapshotSlotApi & _solana_kit.GetIdentityApi & _solana_kit.GetInflationGovernorApi & _solana_kit.GetInflationRateApi & _solana_kit.GetInflationRewardApi & _solana_kit.GetLargestAccountsApi & _solana_kit.GetLatestBlockhashApi & _solana_kit.GetLeaderScheduleApi & _solana_kit.GetMaxRetransmitSlotApi & _solana_kit.GetMaxShredInsertSlotApi & _solana_kit.GetMinimumBalanceForRentExemptionApi & _solana_kit.GetMultipleAccountsApi & _solana_kit.GetProgramAccountsApi & _solana_kit.GetRecentPerformanceSamplesApi & _solana_kit.GetRecentPrioritizationFeesApi & _solana_kit.GetSignaturesForAddressApi & _solana_kit.GetSignatureStatusesApi & _solana_kit.GetSlotApi & _solana_kit.GetSlotLeaderApi & _solana_kit.GetSlotLeadersApi & _solana_kit.GetStakeMinimumDelegationApi & _solana_kit.GetSupplyApi & _solana_kit.GetTokenAccountBalanceApi & _solana_kit.GetTokenAccountsByDelegateApi & _solana_kit.GetTokenAccountsByOwnerApi & _solana_kit.GetTokenLargestAccountsApi & _solana_kit.GetTokenSupplyApi & _solana_kit.GetTransactionApi & _solana_kit.GetTransactionCountApi & _solana_kit.GetVersionApi & _solana_kit.GetVoteAccountsApi & _solana_kit.IsBlockhashValidApi & _solana_kit.MinimumLedgerSlotApi & _solana_kit.SendTransactionApi & _solana_kit.SimulateTransactionApi) | (_solana_kit.RequestAirdropApi & _solana_kit.GetAccountInfoApi & _solana_kit.GetBalanceApi & _solana_kit.GetBlockApi & _solana_kit.GetBlockCommitmentApi & _solana_kit.GetBlockHeightApi & _solana_kit.GetBlockProductionApi & _solana_kit.GetBlocksApi & _solana_kit.GetBlocksWithLimitApi & _solana_kit.GetBlockTimeApi & _solana_kit.GetClusterNodesApi & _solana_kit.GetEpochInfoApi & _solana_kit.GetEpochScheduleApi & _solana_kit.GetFeeForMessageApi & _solana_kit.GetFirstAvailableBlockApi & _solana_kit.GetGenesisHashApi & _solana_kit.GetHealthApi & _solana_kit.GetHighestSnapshotSlotApi & _solana_kit.GetIdentityApi & _solana_kit.GetInflationGovernorApi & _solana_kit.GetInflationRateApi & _solana_kit.GetInflationRewardApi & _solana_kit.GetLargestAccountsApi & _solana_kit.GetLatestBlockhashApi & _solana_kit.GetLeaderScheduleApi & _solana_kit.GetMaxRetransmitSlotApi & _solana_kit.GetMaxShredInsertSlotApi & _solana_kit.GetMinimumBalanceForRentExemptionApi & _solana_kit.GetMultipleAccountsApi & _solana_kit.GetProgramAccountsApi & _solana_kit.GetRecentPerformanceSamplesApi & _solana_kit.GetRecentPrioritizationFeesApi & _solana_kit.GetSignaturesForAddressApi & _solana_kit.GetSignatureStatusesApi & _solana_kit.GetSlotApi & _solana_kit.GetSlotLeaderApi & _solana_kit.GetSlotLeadersApi & _solana_kit.GetStakeMinimumDelegationApi & _solana_kit.GetSupplyApi & _solana_kit.GetTokenAccountBalanceApi & _solana_kit.GetTokenAccountsByDelegateApi & _solana_kit.GetTokenAccountsByOwnerApi & _solana_kit.GetTokenLargestAccountsApi & _solana_kit.GetTokenSupplyApi & _solana_kit.GetTransactionApi & _solana_kit.GetTransactionCountApi & _solana_kit.GetVersionApi & _solana_kit.GetVoteAccountsApi & _solana_kit.IsBlockhashValidApi & _solana_kit.MinimumLedgerSlotApi & _solana_kit.SendTransactionApi & _solana_kit.SimulateTransactionApi)>;
1954
+
1955
+ declare const deserializeTransactionMessage: (payload: string, prov: SolanaProvider) => Promise<_solana_kit.CompilableTransactionMessage<_solana_kit.TransactionVersion, _solana_kit.IInstruction<string, readonly (_solana_kit.IAccountLookupMeta<string, string> | _solana_kit.IAccountMeta<string>)[]>>>;
1956
+
1957
+ declare const serializeSolanaTx: (tx: Transaction$2) => _solana_kit.Base64EncodedWireTransaction;
1958
+
1959
+ declare const transferSol: ({ from, to, amount, provider, }: {
1960
+ from: string;
1961
+ to: string;
1962
+ amount: bigint;
1963
+ provider: SolanaProvider;
1964
+ }) => Promise<_solana_kit.ITransactionMessageWithFeePayer<string> & Omit<_solana_kit.TransactionMessageWithBlockhashLifetime & Readonly<{
1965
+ instructions: readonly _solana_kit.IInstruction<string, readonly (_solana_kit.IAccountLookupMeta<string, string> | _solana_kit.IAccountMeta<string>)[]>[];
1966
+ version: 0;
1967
+ }>, "feePayer">>;
1968
+
1969
+ declare const transferToken: ({ from, to, mint, amount, decimals, provider, }: {
1970
+ from: string;
1971
+ to: string;
1972
+ mint: string;
1973
+ amount: bigint;
1974
+ decimals: number;
1975
+ provider: SolanaProvider;
1976
+ }) => Promise<_solana_kit.ITransactionMessageWithFeePayer<string> & Omit<_solana_kit.TransactionMessageWithBlockhashLifetime & Readonly<{
1977
+ instructions: readonly IInstruction<string, readonly (_solana_kit.IAccountLookupMeta<string, string> | _solana_kit.IAccountMeta<string>)[]>[];
1978
+ version: 0;
1979
+ }>, "feePayer">>;
1980
+
1981
+ declare const getSolanaDerivationPath: (accountIndex: number, withRoot?: boolean) => string;
1982
+
1983
+ declare const getSolanaPublicKeyFromLedger: (accountIndex: number, transport: Transport) => Promise<Buffer>;
1984
+
1985
+ declare class SolanaSigner {
1986
+ #private;
1987
+ constructor(privateKey: Buffer);
1988
+ static fromMnemonic(mnemonic: string, accountIndex: number): SolanaSigner;
1989
+ /**
1990
+ * @param message Base-64 encoded message bytes
1991
+ * @returns Base-64 encoded signature
1992
+ */
1993
+ signMessage(message: string): Promise<string>;
1994
+ /**
1995
+ * @param base64EncodedTx Base-64 encoded transaction
1996
+ * @param provider SolanaProvider
1997
+ * @returns
1998
+ */
1999
+ signTx(base64EncodedTx: string, provider: SolanaProvider): Promise<string>;
2000
+ }
2001
+
2002
+ declare class SolanaLedgerSigner {
2003
+ #private;
2004
+ constructor(accountIndex: number, transport: Transport);
2005
+ signTx(base64EncodedTx: string, provider: SolanaProvider): Promise<string>;
2006
+ }
2007
+
2008
+ export { index as Avalanche, BitcoinLedgerWallet, BitcoinProvider, BitcoinProviderAbstract, BitcoinWallet, BitcoinWalletAbstract, BitcoinWalletVoid, BtcNetworks, DerivationPath, ETH_ACCOUNT_PATH, ETH_COIN_PATH, JsonRpcBatchInternal, LedgerSigner$1 as LedgerSigner, SolanaLedgerSigner, SolanaSigner, addEncodedSigToPsbt, compileSolanaTx, createPSBTV2, createPsbt, createTransferTx, createWalletPolicy, deserializeTransactionMessage, formatAddressForNetworkBech32, getAddressDerivationPath, getAddressFromXPub, getAddressPrivateKeyFromXPriv, getAddressPublicKeyFromXPub, getAppEth, getBech32Address, getBech32AddressFromXPub, getBtcAddressFromPubKey, getEvmAddressFromPubKey, getLedgerAppInfo, getLedgerExtendedPublicKey, getMaxTransferAmount, getPubKeyFromTransport, getPublicKeyFromPrivateKey, getSolanaDerivationPath, getSolanaProvider, getSolanaPublicKeyFromLedger, getTransferTxDetails, getVoidSigner, getWalletFromMnemonic, getXpubFromMnemonic$1 as getXpubFromMnemonic, isERC20Transfer, isNativeTxn, isSolanaProvider, omitUndefinedKeys, onBalanceChange, openLedgerApp, psbt2ToPsbt0, quitLedgerApp, selectUtxos, serializeSolanaTx, transferSol, transferToken };
2009
+ export type { BitcoinHistoryTx, BitcoinInputUTXO, BitcoinInputUTXOWithOptionalScript, BitcoinLedgerInputUTXO, BitcoinOutputUTXO, BitcoinTx, SolanaProvider };