@avalabs/core-wallets-sdk 3.1.0-alpha.9 → 3.1.0-alpha.91-canary.8cdb0a6d

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 (134) hide show
  1. package/dist/index.cjs +1 -0
  2. package/dist/index.d.ts +435 -185
  3. package/esm/Avalanche/index.d.ts +5 -4
  4. package/esm/Avalanche/index.js +1 -1
  5. package/esm/Avalanche/models.d.ts +71 -4
  6. package/esm/Avalanche/models.js +1 -1
  7. package/esm/Avalanche/providers/AbstractProvider.d.ts +4 -14
  8. package/esm/Avalanche/providers/AbstractProvider.js +1 -1
  9. package/esm/Avalanche/providers/JsonRpcProvider.d.ts +4 -4
  10. package/esm/Avalanche/providers/JsonRpcProvider.js +1 -1
  11. package/esm/Avalanche/providers/constants.d.ts +2 -1
  12. package/esm/Avalanche/providers/constants.js +1 -1
  13. package/esm/Avalanche/providers/platformFeeConfig.js +1 -1
  14. package/esm/Avalanche/utils/addSignaturesToAvalancheTx.js +1 -1
  15. package/esm/Avalanche/utils/appendAutoRenewedValidatorConfigAddressMaps.js +1 -0
  16. package/esm/Avalanche/utils/appendDisableAuthAddressMaps.js +1 -0
  17. package/esm/Avalanche/utils/convertGlacierUtxo.d.ts +4 -3
  18. package/esm/Avalanche/utils/convertGlacierUtxo.js +1 -1
  19. package/esm/Avalanche/utils/createAvalancheEvmUnsignedTx.d.ts +3 -2
  20. package/esm/Avalanche/utils/createAvalancheEvmUnsignedTx.js +1 -1
  21. package/esm/Avalanche/utils/createAvalancheUnsignedTx.d.ts +1 -1
  22. package/esm/Avalanche/utils/createAvalancheUnsignedTx.js +1 -1
  23. package/esm/Avalanche/utils/getAssetBalance.d.ts +2 -1
  24. package/esm/Avalanche/utils/getAssetBalance.js +1 -1
  25. package/esm/Avalanche/utils/getAvalancheDerivationPath.d.ts +3 -0
  26. package/esm/Avalanche/utils/getAvalancheDerivationPath.js +1 -0
  27. package/esm/Avalanche/utils/getChainAliasByChainId.js +1 -1
  28. package/esm/Avalanche/utils/getPchainUnixNow.d.ts +3 -1
  29. package/esm/Avalanche/utils/getPchainUnixNow.js +1 -1
  30. package/esm/Avalanche/utils/getStakedAssetBalance.d.ts +2 -1
  31. package/esm/Avalanche/utils/getTxOutputAddresses.js +1 -1
  32. package/esm/Avalanche/utils/getUtxosByTxFromGlacier.d.ts +3 -2
  33. package/esm/Avalanche/utils/getUtxosByTxFromGlacier.js +1 -1
  34. package/esm/Avalanche/utils/getVmByChainAlias.d.ts +1 -1
  35. package/esm/Avalanche/utils/getXpubFromMnemonic.d.ts +1 -1
  36. package/esm/Avalanche/utils/getXpubFromMnemonic.js +1 -1
  37. package/esm/Avalanche/utils/handleSubnetAuth.js +1 -1
  38. package/esm/Avalanche/utils/orderBy.js +1 -0
  39. package/esm/Avalanche/utils/parseAvalancheTx.d.ts +12 -1
  40. package/esm/Avalanche/utils/parseAvalancheTx.js +1 -1
  41. package/esm/Avalanche/utils/parsers/index.js +1 -1
  42. package/esm/Avalanche/utils/parsers/parseAddAutoRenewedValidatorTx.js +1 -0
  43. package/esm/Avalanche/utils/parsers/parseAddPermissionlessDelegatorTx.js +1 -1
  44. package/esm/Avalanche/utils/parsers/parseAddPermissionlessValidatorTx.js +1 -1
  45. package/esm/Avalanche/utils/parsers/parseAddSubnetValidorTx.js +1 -1
  46. package/esm/Avalanche/utils/parsers/parseBaseTx.js +1 -1
  47. package/esm/Avalanche/utils/parsers/parseConvertSubnetToL1Tx.js +1 -0
  48. package/esm/Avalanche/utils/parsers/parseCreateChainTx.js +1 -1
  49. package/esm/Avalanche/utils/parsers/parseCreateSubnetTx.js +1 -1
  50. package/esm/Avalanche/utils/parsers/parseDisableL1ValidatorTx.js +1 -0
  51. package/esm/Avalanche/utils/parsers/parseExportTx.js +1 -1
  52. package/esm/Avalanche/utils/parsers/parseImportTx.js +1 -1
  53. package/esm/Avalanche/utils/parsers/parseIncreaseL1ValidatorBalanceTx.js +1 -0
  54. package/esm/Avalanche/utils/parsers/parseRegisterL1ValidatorTx.js +1 -0
  55. package/esm/Avalanche/utils/parsers/parseRemoveSubnetValidatorTx.js +1 -1
  56. package/esm/Avalanche/utils/parsers/parseSetAutoRenewedValidatorConfigTx.js +1 -0
  57. package/esm/Avalanche/utils/parsers/parseSetL1ValidatorWeightTx.js +1 -0
  58. package/esm/Avalanche/utils/parsers/parseTransferSubnetOwnershipTx.js +1 -1
  59. package/esm/Avalanche/utils/parsers/utils/chainIdToVm.js +1 -1
  60. package/esm/Avalanche/utils/populateCredential.js +1 -1
  61. package/esm/Avalanche/utils/sortUTXOs.d.ts +5 -4
  62. package/esm/Avalanche/utils/sortUTXOs.js +1 -1
  63. package/esm/Avalanche/utils/txSizeLimits.d.ts +2 -2
  64. package/esm/Avalanche/utils/txSizeLimits.js +1 -1
  65. package/esm/Avalanche/wallets/AddressWallet.js +1 -1
  66. package/esm/Avalanche/wallets/SimpleSigner.d.ts +1 -1
  67. package/esm/Avalanche/wallets/SimpleSigner.js +1 -1
  68. package/esm/Avalanche/wallets/StaticSigner.js +1 -1
  69. package/esm/Avalanche/wallets/TxBuilderTypes.d.ts +139 -10
  70. package/esm/Avalanche/wallets/WalletAbstract.d.ts +23 -27
  71. package/esm/Avalanche/wallets/WalletAbstract.js +1 -1
  72. package/esm/Avalanche/wallets/WalletVoid.js +1 -1
  73. package/esm/Avalanche/wallets/ledger/LedgerLiveSigner.d.ts +16 -0
  74. package/esm/Avalanche/wallets/ledger/LedgerLiveSigner.js +1 -0
  75. package/esm/Avalanche/wallets/ledger/LedgerSigner.js +1 -1
  76. package/esm/Avalanche/wallets/ledger/SimpleLedgerSigner.d.ts +4 -2
  77. package/esm/Avalanche/wallets/ledger/SimpleLedgerSigner.js +1 -1
  78. package/esm/Avalanche/wallets/ledger/models.d.ts +1 -1
  79. package/esm/Avalanche/wallets/legacy/LedgerWallet.js +1 -1
  80. package/esm/Avalanche/wallets/legacy/MnemonicWallet.js +1 -1
  81. package/esm/Avalanche/wallets/legacy/MnemonicWalletVoid.js +1 -1
  82. package/esm/Avalanche/wallets/models.d.ts +1 -1
  83. package/esm/BitcoinVM/index.d.ts +5 -0
  84. package/esm/BitcoinVM/index.js +1 -0
  85. package/esm/BitcoinVM/models.d.ts +1 -1
  86. package/esm/BitcoinVM/providers/BitcoinProvider.d.ts +3 -3
  87. package/esm/BitcoinVM/providers/BitcoinProvider.js +1 -1
  88. package/esm/BitcoinVM/utils/getBech32AddressFromXPub.js +1 -1
  89. package/esm/BitcoinVM/wallets/BitcoinWallet.js +1 -1
  90. package/esm/BitcoinVM/wallets/BitcoinWalletLedger.js +1 -1
  91. package/esm/BitcoinVM/wallets/models.d.ts +1 -1
  92. package/esm/EVM/LedgerSigner.js +1 -1
  93. package/esm/EVM/utils/blockPolling.js +1 -1
  94. package/esm/EVM/utils/getEvmDerivationPath.d.ts +5 -0
  95. package/esm/EVM/utils/getEvmDerivationPath.js +1 -0
  96. package/esm/EVM/utils/getWalletFromMnemonic.js +1 -1
  97. package/esm/SolanaVM/utils/compileSolanaTx.d.ts +9 -0
  98. package/esm/SolanaVM/utils/compileSolanaTx.js +1 -0
  99. package/esm/SolanaVM/utils/derivationPath.d.ts +3 -0
  100. package/esm/SolanaVM/utils/derivationPath.js +1 -0
  101. package/esm/SolanaVM/utils/deserializeSolanaTx.d.ts +6 -0
  102. package/esm/SolanaVM/utils/deserializeSolanaTx.js +1 -0
  103. package/esm/SolanaVM/utils/getSolanaPublicKeyFromLedger.d.ts +5 -0
  104. package/esm/SolanaVM/utils/getSolanaPublicKeyFromLedger.js +1 -0
  105. package/esm/SolanaVM/utils/maybeGetAssociatedTokenAccount.d.ts +40 -0
  106. package/esm/SolanaVM/utils/maybeGetAssociatedTokenAccount.js +1 -0
  107. package/esm/SolanaVM/utils/resolveTokenProgramForMint.d.ts +13 -0
  108. package/esm/SolanaVM/utils/resolveTokenProgramForMint.js +1 -0
  109. package/esm/SolanaVM/utils/serializeSolanaTx.d.ts +6 -0
  110. package/esm/SolanaVM/utils/serializeSolanaTx.js +1 -0
  111. package/esm/SolanaVM/utils/solanaProvider.d.ts +11 -0
  112. package/esm/SolanaVM/utils/solanaProvider.js +1 -0
  113. package/esm/SolanaVM/utils/transferSol.d.ts +14 -0
  114. package/esm/SolanaVM/utils/transferSol.js +1 -0
  115. package/esm/SolanaVM/utils/transferToken.d.ts +17 -0
  116. package/esm/SolanaVM/utils/transferToken.js +1 -0
  117. package/esm/SolanaVM/wallets/SolanaLedgerSigner.d.ts +10 -0
  118. package/esm/SolanaVM/wallets/SolanaLedgerSigner.js +1 -0
  119. package/esm/SolanaVM/wallets/SolanaSigner.d.ts +20 -0
  120. package/esm/SolanaVM/wallets/SolanaSigner.js +1 -0
  121. package/esm/abis/erc20.abi.js +1 -0
  122. package/esm/index.d.ts +33 -20
  123. package/esm/index.js +1 -1
  124. package/esm/utils/assertFeeStateProvided.js +1 -0
  125. package/esm/utils/getAddressDerivationPath.d.ts +8 -2
  126. package/esm/utils/getAddressDerivationPath.js +1 -1
  127. package/esm/utils/getPubKeyFromTransport.js +1 -1
  128. package/package.json +36 -13
  129. package/dist/index.js +0 -1
  130. package/esm/Avalanche/utils/getUtxoInfo.d.ts +0 -13
  131. package/esm/Avalanche/utils/getUtxoInfo.js +0 -1
  132. package/esm/Avalanche/utils/parsers/parseAddDelegatorTx.js +0 -1
  133. package/esm/Avalanche/utils/parsers/parseAddValidatorTx.js +0 -1
  134. package/esm/Avalanche/utils/parsers/parseTransformSubnetTx.js +0 -1
@@ -0,0 +1 @@
1
+ import{pvmSerial as e,NodeId as a}from"@avalabs/avalanchejs";import{TxType as n}from"../../models.js";var t=t=>e.isConvertSubnetToL1Tx(t)?({feeData:e,provider:r})=>{const s=r.getHrp(),o=e=>`P-${e.toString(s)}`;return{type:n.ConvertSubnetToL1,chain:t.getVM(),managerAddress:`0x${t.address.toString("hex")}`,validators:t.validators.map((e=>({nodeId:a.fromHex(e.nodeId.toString("hex")).toString(),stake:e.weight.value(),balance:e.balance.value(),remainingBalanceOwners:e.remainingBalanceOwner.addresses.map(o),deactivationOwners:e.deactivationOwner.addresses.map(o)}))),chainID:t.chainID.value(),subnetID:t.subnetID.value(),...e}}:null;export{t as default};
@@ -1 +1 @@
1
- import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";const t=t=>a.isCreateChainTx(t)?({feeData:a})=>({type:e.CreateChain,chain:t.getVM(),subnetID:t.getSubnetID().value(),chainName:t.chainName.value(),chainID:t.getBlockchainId(),vmID:t.vmID.value(),fxIDs:t.fxIds.map((a=>a.value())),genesisData:t.genesisData.toString(),...a}):null;export{t as default};
1
+ import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";var t=t=>a.isCreateChainTx(t)?({feeData:a})=>({type:e.CreateChain,chain:t.getVM(),subnetID:t.getSubnetID().value(),chainName:t.chainName.value(),chainID:t.getBlockchainId(),vmID:t.vmID.value(),fxIDs:t.fxIds.map((a=>a.value())),genesisData:t.genesisData.toString(),...a}):null;export{t as default};
@@ -1 +1 @@
1
- import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as t}from"../../models.js";const r=r=>e.isCreateSubnetTx(r)?({feeData:e,provider:a})=>({type:t.CreateSubnet,chain:r.getVM(),threshold:r.getSubnetOwners().threshold.value(),controlKeys:r.getSubnetOwners().addrs.map((e=>`P-${e.toString(a.getHrp())}`)),...e}):null;export{r as default};
1
+ import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as t}from"../../models.js";var r=r=>e.isCreateSubnetTx(r)?({feeData:e,provider:a})=>({type:t.CreateSubnet,chain:r.getVM(),threshold:r.getSubnetOwners().threshold.value(),controlKeys:r.getSubnetOwners().addrs.map((e=>`P-${e.toString(a.getHrp())}`)),...e}):null;export{r as default};
@@ -0,0 +1 @@
1
+ import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as i}from"../../models.js";var t=t=>a.isDisableL1ValidatorTx(t)?({feeData:a})=>({type:i.DisableL1Validator,chain:t.getVM(),validationId:t.validationId.toString(),...a}):null;export{t as default};
@@ -1 +1 @@
1
- import{pvmSerial as t,avmSerial as o,evmSerial as a}from"@avalabs/avalanchejs";import{TxType as s}from"../../models.js";import e from"./utils/chainIdToVm.js";import{getTransferableOutputAmount as i}from"./utils/getTransferableAmount.js";const n=n=>t.isExportTx(n)||o.isExportTx(n)||a.isExportTx(n)?a.isExportTx(n)?({feeData:t,assetId:o})=>({type:s.Export,chain:n.getVM(),destination:e(n.destinationChain.toString()),amount:i(n.exportedOutputs,o),...t}):({feeData:t,assetId:o})=>({type:s.Export,chain:n.getVM(),destination:e(n.destination.value()),amount:i(n.outs,o),...t}):null;export{n as default};
1
+ import{pvmSerial as t,avmSerial as a,evmSerial as o}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";import s from"./utils/chainIdToVm.js";import{getTransferableOutputAmount as i}from"./utils/getTransferableAmount.js";var r=r=>t.isExportTx(r)||a.isExportTx(r)||o.isExportTx(r)?o.isExportTx(r)?({feeData:t,assetId:a})=>({type:e.Export,chain:r.getVM(),destination:s(r.destinationChain.toString()),amount:i(r.exportedOutputs,a),...t}):({feeData:t,assetId:a})=>({type:e.Export,chain:r.getVM(),destination:s(r.destination.value()),amount:i(r.outs,a),...t}):null;export{r as default};
@@ -1 +1 @@
1
- import{pvmSerial as t,avmSerial as o,evmSerial as a}from"@avalabs/avalanchejs";import{TxType as s}from"../../models.js";import e from"./utils/chainIdToVm.js";import{getTransferableInputAmount as r}from"./utils/getTransferableAmount.js";const m=m=>t.isImportTx(m)||o.isImportTx(m)||a.isImportTx(m)?a.isImportTx(m)?({feeData:t,assetId:o})=>({type:s.Import,chain:m.getVM(),source:e(m.sourceChain.value()),amount:r(m.importedInputs,o),...t}):({feeData:t,assetId:o})=>({type:s.Import,chain:m.getVM(),source:e(m.sourceChain.value()),amount:r(m.ins,o),...t}):null;export{m as default};
1
+ import{pvmSerial as t,avmSerial as a,evmSerial as o}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";import s from"./utils/chainIdToVm.js";import{getTransferableInputAmount as r}from"./utils/getTransferableAmount.js";var m=m=>t.isImportTx(m)||a.isImportTx(m)||o.isImportTx(m)?o.isImportTx(m)?({feeData:t,assetId:a})=>({type:e.Import,chain:m.getVM(),source:s(m.sourceChain.value()),amount:r(m.importedInputs,a),...t}):({feeData:t,assetId:a})=>({type:e.Import,chain:m.getVM(),source:s(m.sourceChain.value()),amount:r(m.ins,a),...t}):null;export{m as default};
@@ -0,0 +1 @@
1
+ import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";var l=l=>a.isIncreaseL1ValidatorBalanceTx(l)?({feeData:a})=>({type:e.IncreaseL1ValidatorBalance,chain:l.getVM(),balance:l.balance.value(),validationId:l.validationId.toString(),...a}):null;export{l as default};
@@ -0,0 +1 @@
1
+ import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";var l=l=>a.isRegisterL1ValidatorTx(l)?({feeData:a})=>({type:e.RegisterL1Validator,chain:l.getVM(),balance:l.balance.value(),...a}):null;export{l as default};
@@ -1 +1 @@
1
- import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as t}from"../../models.js";const a=a=>e.isRemoveSubnetValidatorTx(a)?({feeData:e})=>({type:t.RemoveSubnetValidator,chain:a.getVM(),nodeID:a.nodeId.toString(),subnetID:a.getSubnetID().value(),...e}):null;export{a as default};
1
+ import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as a}from"../../models.js";var t=t=>e.isRemoveSubnetValidatorTx(t)?({feeData:e})=>({type:a.RemoveSubnetValidator,chain:t.getVM(),nodeID:t.nodeId.toString(),subnetID:t.getSubnetID().value(),...e}):null;export{t as default};
@@ -0,0 +1 @@
1
+ import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";var o=o=>a.isSetAutoRenewedValidatorConfigTx(o)?({feeData:a})=>({type:e.SetAutoRenewedValidatorConfig,chain:o.getVM(),txId:o.txId.value(),autoCompoundRewardShares:o.autoCompoundRewardShares.value(),period:o.period.value(),...a}):null;export{o as default};
@@ -0,0 +1 @@
1
+ import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as t}from"../../models.js";var e=e=>a.isSetL1ValidatorWeightTx(e)?({feeData:a})=>({type:t.SetL1ValidatorWeight,chain:e.getVM(),...a}):null;export{e as default};
@@ -1 +1 @@
1
- import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as t}from"../../models.js";const r=r=>e.isTransferSubnetOwnershipTx(r)?({feeData:e,provider:s})=>({type:t.TransferSubnetOwnership,chain:r.getVM(),subnetID:r.subnetID.value(),threshold:r.getSubnetOwners().threshold.value(),controlKeys:r.getSubnetOwners().addrs.map((e=>`P-${e.toString(s.getHrp())}`)),...e}):null;export{r as default};
1
+ import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as r}from"../../models.js";var t=t=>e.isTransferSubnetOwnershipTx(t)?({feeData:e,provider:a})=>({type:r.TransferSubnetOwnership,chain:t.getVM(),subnetID:t.subnetID.value(),threshold:t.getSubnetOwners().threshold.value(),controlKeys:t.getSubnetOwners().addrs.map((e=>`P-${e.toString(a.getHrp())}`)),...e}):null;export{t as default};
@@ -1 +1 @@
1
- import"@avalabs/avalanchejs";import"@avalabs/core-utils-sdk";import"ethers";import{MainnetContext as a,FujiContext as c}from"../../../providers/constants.js";import"@avalabs/core-chains-sdk";const i=i=>{if([a.xBlockchainID,c.xBlockchainID].includes(i))return"AVM";if([a.pBlockchainID,c.pBlockchainID].includes(i))return"PVM";if([a.cBlockchainID,c.cBlockchainID].includes(i))return"EVM";throw new Error("Unknown chain id. Failed to get alias.")};export{i as default};
1
+ import"../../../providers/AbstractProvider.js";import"@avalabs/avalanchejs";import{MainnetContext as c,FujiContext as a,DevnetContext as i}from"../../../providers/constants.js";import"@avalabs/core-chains-sdk";var r=r=>{if([c.xBlockchainID,a.xBlockchainID,i.xBlockchainID].includes(r))return"AVM";if([c.pBlockchainID,a.pBlockchainID,i.pBlockchainID].includes(r))return"PVM";if([c.cBlockchainID,a.cBlockchainID,i.cBlockchainID].includes(r))return"EVM";throw new Error("Unknown chain id. Failed to get alias.")};export{r as default};
@@ -1 +1 @@
1
- import{Signature as e,utils as r,secp256k1 as t}from"@avalabs/avalanchejs";import{sha256 as o}from"@noble/hashes/sha256";const{bufferToHex:n,packTx:s}=r,{publicKeyBytesToAddress:i,recoverPublicKey:a}=t,c=new e(new Uint8Array(Array(65).fill(0))),d=(e,r)=>{const t=Math.max(...e);if(!isFinite(t))throw new Error("Error while adding placeholder signatures for the provided indices.");const d=new Array(t+1).fill(c);if(!r)return d;const{unsignedTx:f,credentialIndex:l}=r,g=f.getCredentials()[l];if(!g)return d;const h=s(f.getTx()),u=o(h),p=c.toString();for(const e of g.toJSON()){if(e.toString()===p)continue;const r=a(u,e.toBytes()),t={toHex:()=>n(i(r))},o=f.addressMaps.getSigIndicesForAddress(t,!1)??[];for(const r of o)r[0]===l&&(d[r[1]]=e)}return d};export{c as emptySignature,d as populateCredential};
1
+ import{utils as e,secp256k1 as r,Signature as t}from"@avalabs/avalanchejs";import{sha256 as o}from"@noble/hashes/sha256";const{bufferToHex:n,packTx:s}=e,{publicKeyBytesToAddress:i,recoverPublicKey:a}=r,c=new t(new Uint8Array(Array(65).fill(0))),d=(e,r)=>{const t=Math.max(...e);if(!isFinite(t))throw new Error("Error while adding placeholder signatures for the provided indices.");const d=new Array(t+1).fill(c);if(!r)return d;const{unsignedTx:f,credentialIndex:l}=r,g=f.getCredentials()[l];if(!g)return d;const h=s(f.getTx()),u=o(h),p=c.toString();for(const e of g.toJSON()){if(e.toString()===p)continue;const r=a(u,e.toBytes()),t={toHex:()=>n(i(r))},o=f.addressMaps.getSigIndicesForAddress(t,!1)??[];for(const r of o)r[0]===l&&(d[r[1]]=e)}return d};export{c as emptySignature,d as populateCredential};
@@ -3,12 +3,13 @@ import { Utxo } from '@avalabs/avalanchejs';
3
3
 
4
4
  /**
5
5
  * The UTXOs will be sorted in the following order.
6
- * 1- LockedStakeable UTXOs with the highest locktime to lowest
7
- * 2- Highest value UTXOs to lowest
6
+ * 1- Highest value unlocked UTXO (for fees)
7
+ * 2- LockedStakeable UTXOs with the highest locktime to lowest
8
+ * 3- Rest of the unlocked UTXOs highest to lowest
8
9
  * @remark Does not check for locked UTXOs
9
10
  */
10
- declare function sortUTXOsStaking(utxos: Utxo[]): Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[];
11
- declare function sortUTXOsByAmount(utxos: Utxo[], isDescending: boolean): Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[];
11
+ declare function sortUTXOsStaking(utxos: Utxo[]): Utxo[];
12
+ declare function sortUTXOsByAmount(utxos: Utxo[], isDescending: boolean): Utxo[];
12
13
  declare const sortUTXOsByAmountDescending: (utxos: Utxo[]) => Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[];
13
14
  declare const sortUTXOsByAmountAscending: (utxos: Utxo[]) => Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[];
14
15
 
@@ -1 +1 @@
1
- import{utils as t}from"@avalabs/avalanchejs";const{isStakeableLockOut:n,isTransferOut:u}=t;function e(t){return t.sort(((t,e)=>{const r=t.output,o=e.output,a=n(r),i=n(o);if(a&&!i)return-1;if(i&&!a)return 1;if(n(r)&&n(o)){const t=r.getStakeableLocktime(),n=o.getStakeableLocktime();if(t<n)return 1;if(t>n)return-1}else if(u(r)&&u(o)){if(r.amount()>o.amount())return-1;if(r.amount()<o.amount())return 1}return 0}))}function r(t,e){return t.sort(((t,r)=>{const o=t.output,a=r.output;let i=BigInt(0);(u(o)||n(o))&&(i=o.amount());let s=BigInt(0);(u(a)||n(a))&&(s=a.amount());const c=e?s-i:i-s;return c>0?1:c<0?-1:0}))}const o=t=>r(t,!0),a=t=>r(t,!1);export{r as sortUTXOsByAmount,a as sortUTXOsByAmountAscending,o as sortUTXOsByAmountDescending,e as sortUTXOsStaking};
1
+ import{utils as t}from"@avalabs/avalanchejs";import{getUnixNow as o}from"./getUnixNow.js";import{orderBy as e}from"./orderBy.js";function a(a){const m=o(),n=a.map((o=>({utxo:o,...t.getUtxoInfo(o)}))),r=n.filter((t=>t.stakeableLocktime<=m)),s=n.filter((t=>t.stakeableLocktime>m)),c=e(r,["amount"],"desc"),i=e(s,["stakeableLocktime","amount"],"desc"),[u,...f]=c;return[...u?[u]:[],...i,...f].map((t=>t.utxo))}function m(o,a){const m=o.map((o=>({utxo:o,...t.getUtxoInfo(o)})));return e(m,["amount"],a?"desc":"asc").map((t=>t.utxo))}const n=t=>m(t,!0),r=t=>m(t,!1);export{m as sortUTXOsByAmount,r as sortUTXOsByAmountAscending,n as sortUTXOsByAmountDescending,a as sortUTXOsStaking};
@@ -1,5 +1,5 @@
1
1
  import { Utxo, pvm } from '@avalabs/avalanchejs';
2
- import { WalletAbstract } from 'Avalanche/wallets';
2
+ import { WalletAbstract } from '../wallets/WalletAbstract.js';
3
3
 
4
4
  /**
5
5
  * The list of transaction types supported by `getMaximumUtxoSet`.
@@ -33,7 +33,7 @@ declare function getMaximumUtxoSet({ wallet, utxos, sizeSupportedTx, limit, feeS
33
33
  utxos: Utxo[];
34
34
  sizeSupportedTx: SizeSupportedTx;
35
35
  limit?: number;
36
- feeState: pvm.FeeState;
36
+ feeState?: pvm.FeeState;
37
37
  }): Utxo[];
38
38
 
39
39
  export { P_CHAIN_TX_SIZE_LIMIT, SizeSupportedTx, getMaximumUtxoSet };
@@ -1 +1 @@
1
- import{utils as e}from"@avalabs/avalanchejs";import{getUtxoInfo as t}from"./getUtxoInfo.js";import{getUnixNow as o}from"./getUnixNow.js";import{binarySearch as r}from"../../utils/binarySearch.js";import{sortUTXOsByAmountDescending as s,sortUTXOsByAmountAscending as d,sortUTXOsStaking as a}from"./sortUTXOs.js";var n=(e=>(e.ExportP="ExportP",e.ImportP="ImportP",e.AddPermissionlessValidator="AddPermissionlessValidator",e.AddPermissionlessDelegator="AddPermissionlessDelegator",e.BaseP="BaseP",e.ConsolidateP="ConsolidateP",e))(n||{});const i="NodeID-8TArWpFgH3sazEH8qP4gUjtGtFMvjw1aR",u="11111111111111111111111111111111LpoYY",c=(e,o)=>e.reduce(((e,o)=>e+t(o).amount),BigInt(0))-o,l={BaseP:{sortFunction:s,unsignedTxBuilder:(t,o,r)=>{const s=t.getProvider().getContext();return t.baseTX({utxoSet:new e.UtxoSet(o),chain:"P",toAddress:t.getCurrentAddress("P"),amountsPerAsset:{[s.avaxAssetID]:c(o,s.baseTxFee)},feeState:r})}},ConsolidateP:{sortFunction:d,unsignedTxBuilder:(t,o,r)=>{const s=t.getProvider().getContext();return t.consolidateP({utxoSet:new e.UtxoSet(o),amount:c(o,s.baseTxFee),feeState:r})}},AddPermissionlessValidator:{sortFunction:a,unsignedTxBuilder:(t,r,s)=>t.addPermissionlessValidator({utxoSet:new e.UtxoSet(r),nodeId:i,start:o(),end:o()+BigInt(1e3),weight:c(r,t.getProvider().getContext().addPrimaryNetworkValidatorFee),subnetId:u,shares:5,feeState:s,fromAddresses:void 0,rewardAddresses:void 0,delegatorRewardAddresses:void 0,publicKey:Buffer.from(e.hexToBuffer("0x8f95423f7142d00a48e1014a3de8d28907d420dc33b3052a6dee03a3f2941a393c2351e354704ca66a3fc29870282e15")),signature:Buffer.from(e.hexToBuffer("0x86a3ab4c45cfe31cae34c1d06f212434ac71b1be6cfe046c80c162e057614a94a5bc9f1ded1a7029deb0ba4ca7c9b71411e293438691be79c2dbf19d1ca7c3eadb9c756246fc5de5b7b89511c7d7302ae051d9e03d7991138299b5ed6a570a98"))})},AddPermissionlessDelegator:{sortFunction:a,unsignedTxBuilder:(t,r,s)=>t.addPermissionlessDelegator({utxoSet:new e.UtxoSet(r),nodeId:i,start:o(),end:o()+BigInt(1e3),weight:c(r,t.getProvider().getContext().addPrimaryNetworkDelegatorFee),subnetId:u,feeState:s})},ExportP:{sortFunction:s,unsignedTxBuilder:(t,o,r)=>t.exportP({amount:c(o,t.getProvider().getContext().baseTxFee),utxoSet:new e.UtxoSet(o),destination:"X",feeState:r})},ImportP:{sortFunction:s,unsignedTxBuilder:(t,o,r)=>t.importP({utxoSet:new e.UtxoSet(o),sourceChain:"X",feeState:r})}},x=65536;function f({wallet:e,utxos:s,sizeSupportedTx:d,limit:a=65536,feeState:n}){const{sortFunction:i,unsignedTxBuilder:u}=l[d],c=o(),x=i(s.filter((e=>{const{locktime:o,stakeableLocktime:r}=t(e);return o<c&&(r<c||("AddPermissionlessDelegator"===d||"AddPermissionlessValidator"===d))}))),f=r(x,(o=>{try{return function(e){const o=e.getInputUtxos().reduce(((e,o)=>e+(8+65*t(o).threshold)),0);return 6+e.toBytes().length+o}(u(e,o,n))}catch(e){return console.log("Unable to estimate size of utxos",{e:e,utxos:o.map(t)}),a+1}}),a);return-1===f?[]:x.slice(0,f+1)}export{x as P_CHAIN_TX_SIZE_LIMIT,n as SizeSupportedTx,f as getMaximumUtxoSet};
1
+ import{utils as e,Common as t}from"@avalabs/avalanchejs";import{getUnixNow as o}from"./getUnixNow.js";import{binarySearch as s}from"../../utils/binarySearch.js";import{sortUTXOsByAmountDescending as r,sortUTXOsStaking as n,sortUTXOsByAmountAscending as d}from"./sortUTXOs.js";const{getUtxoInfo:i}=e;var a=(e=>(e.ExportP="ExportP",e.ImportP="ImportP",e.AddPermissionlessValidator="AddPermissionlessValidator",e.AddPermissionlessDelegator="AddPermissionlessDelegator",e.BaseP="BaseP",e.ConsolidateP="ConsolidateP",e))(a||{});const u="NodeID-8TArWpFgH3sazEH8qP4gUjtGtFMvjw1aR",c="11111111111111111111111111111111LpoYY",l=(e,t)=>e.reduce(((e,t)=>e+i(t).amount),BigInt(0))-t,x={BaseP:{sortFunction:r,unsignedTxBuilder:(t,o,s)=>{const r=t.getProvider().getContext();return t.baseTX({utxoSet:new e.UtxoSet(o),chain:"P",toAddress:t.getCurrentAddress("P"),amountsPerAsset:{[r.avaxAssetID]:l(o,r.baseTxFee)},feeState:s})}},ConsolidateP:{sortFunction:d,unsignedTxBuilder:(t,o,s)=>{const r=t.getProvider().getContext();return t.consolidateP({utxoSet:new e.UtxoSet(o),amount:l(o,r.baseTxFee),feeState:s})}},AddPermissionlessValidator:{sortFunction:n,unsignedTxBuilder:(t,s,r)=>t.addPermissionlessValidator({utxoSet:new e.UtxoSet(s),nodeId:u,start:o(),end:o()+BigInt(1e3),weight:l(s,t.getProvider().getContext().baseTxFee),subnetId:c,shares:5,feeState:r,fromAddresses:void 0,rewardAddresses:void 0,delegatorRewardAddresses:void 0,publicKey:Buffer.from(e.hexToBuffer("0x8f95423f7142d00a48e1014a3de8d28907d420dc33b3052a6dee03a3f2941a393c2351e354704ca66a3fc29870282e15")),signature:Buffer.from(e.hexToBuffer("0x86a3ab4c45cfe31cae34c1d06f212434ac71b1be6cfe046c80c162e057614a94a5bc9f1ded1a7029deb0ba4ca7c9b71411e293438691be79c2dbf19d1ca7c3eadb9c756246fc5de5b7b89511c7d7302ae051d9e03d7991138299b5ed6a570a98"))})},AddPermissionlessDelegator:{sortFunction:n,unsignedTxBuilder:(t,s,r)=>t.addPermissionlessDelegator({utxoSet:new e.UtxoSet(s),nodeId:u,start:o(),end:o()+BigInt(1e3),weight:l(s,t.getProvider().getContext().baseTxFee),subnetId:c,feeState:r})},ExportP:{sortFunction:r,unsignedTxBuilder:(o,s,r)=>{const n=o.getProvider().getContext(),d=function({numberIns:e=1},o){const s=t.createDimensions({bandwidth:161*e+254,dbRead:e,dbWrite:2+e,compute:200*e});return t.dimensionsToGas(s,o)}({numberIns:s.length},n.platformFeeConfig.weights),i=r?d*r.price:n.baseTxFee;return o.exportP({amount:l(s,i),utxoSet:new e.UtxoSet(s),destination:"X",feeState:r})}},ImportP:{sortFunction:r,unsignedTxBuilder:(t,o,s)=>t.importP({utxoSet:new e.UtxoSet(o),sourceChain:"X",feeState:s})}},f=65536;function g({wallet:e,utxos:t,sizeSupportedTx:r,limit:n=65536,feeState:d}){const{sortFunction:a,unsignedTxBuilder:u}=x[r],c=o(),l=a(t.filter((e=>{const{locktime:t,stakeableLocktime:o}=i(e);return t<c&&(o<c||("AddPermissionlessDelegator"===r||"AddPermissionlessValidator"===r))}))),f=s(l,(t=>{try{return function(e){const t=e.getInputUtxos().reduce(((e,t)=>e+(8+65*i(t).threshold)),0);return 6+e.toBytes().length+t}(u(e,t,d))}catch(e){return console.log("Unable to estimate size of utxos",{e:e,utxos:t.map(i)}),n+1}}),n);return-1===f?[]:l.slice(0,f+1)}export{f as P_CHAIN_TX_SIZE_LIMIT,a as SizeSupportedTx,g as getMaximumUtxoSet};
@@ -1 +1 @@
1
- import{WalletAbstract as s}from"./WalletAbstract.js";import"@avalabs/avalanchejs";import"../utils/populateCredential.js";import"@avalabs/core-utils-sdk";import{isAddress as e}from"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"bip32";import"@avalabs/glacier-sdk";import"bip39";import{isBech32Address as r}from"../utils/isBech32Address.js";import"xss";import"bip32-path";class t extends s{constructor(s,t,a,d,i){if(super(i),this.addressC=s,this.addressCoreEth=t,this.xpAddresses=a,this.xpChangeAddress=d,a.length<1)throw new Error("Must have at least 1 xp address.");if(!e(s))throw new Error("Not a valid C-Chain (EVM) address");if(a.some((s=>!r(s,!1))))throw new Error("Given addresses must be valid avalanche bech32 addresses without the chain alias prefix");if(!r(t,!1))throw new Error("Given CoreEth address must be valid avalanche bech32 addresses without the chain alias prefix");this.setChangeAddress(d)}setChangeAddress(s){if(!r(s,!1))throw new Error("Given address must be valid avalanche bech32 addresses without the chain alias prefix");this.xpChangeAddress=s}getAddressEVM(){return this.addressC}getAddresses(s){return("C"===s?[this.addressCoreEth]:this.xpAddresses).map((e=>this.provider.formatAddress(e,s)))}getChangeAddress(s){const e="C"===s?this.addressCoreEth:this.xpChangeAddress;return this.provider.formatAddress(e,s)}getCurrentAddress(s){const e="C"===s?this.addressCoreEth:this.xpAddresses[0];return this.provider.formatAddress(e,s)}}export{t as AddressWallet};
1
+ import{WalletAbstract as s}from"./WalletAbstract.js";import"../utils/addSignaturesToAvalancheTx.js";import"../utils/convertGlacierUtxo.js";import"../utils/createAvalancheEvmUnsignedTx.js";import"../utils/createAvalancheUnsignedTx.js";import"create-hash";import"bip32";import"@avalabs/avalanchejs";import"../utils/getAssetBalance.js";import"../utils/getUtxosByTxFromGlacier.js";import"bip39";import{isBech32Address as e}from"../utils/isBech32Address.js";import"../utils/parseAvalancheTx.js";import"../utils/populateCredential.js";import"../utils/txSizeLimits.js";import"bip32-path";import{isAddress as r}from"ethers";class t extends s{constructor(s,t,i,a,d){if(super(d),this.addressC=s,this.addressCoreEth=t,this.xpAddresses=i,this.xpChangeAddress=a,i.length<1)throw new Error("Must have at least 1 xp address.");if(!r(s))throw new Error("Not a valid C-Chain (EVM) address");if(i.some((s=>!e(s,!1))))throw new Error("Given addresses must be valid avalanche bech32 addresses without the chain alias prefix");if(!e(t,!1))throw new Error("Given CoreEth address must be valid avalanche bech32 addresses without the chain alias prefix");this.setChangeAddress(a)}setChangeAddress(s){if(!e(s,!1))throw new Error("Given address must be valid avalanche bech32 addresses without the chain alias prefix");this.xpChangeAddress=s}getAddressEVM(){return this.addressC}getAddresses(s){return("C"===s?[this.addressCoreEth]:this.xpAddresses).map((e=>this.provider.formatAddress(e,s)))}getChangeAddress(s){const e="C"===s?this.addressCoreEth:this.xpChangeAddress;return this.provider.formatAddress(e,s)}getCurrentAddress(s){const e="C"===s?this.addressCoreEth:this.xpAddresses[0];return this.provider.formatAddress(e,s)}}export{t as AddressWallet};
@@ -10,7 +10,7 @@ import { Signer, SignTxRequest, SignTxBufferRequest, SignMessageRequest } from '
10
10
  */
11
11
  declare class SimpleSigner implements Signer {
12
12
  /**
13
- * Node for `m/44'/9000'/0'`
13
+ * Node for `m/44'/9000'/n'`
14
14
  * @private {BIP32Interface}
15
15
  */
16
16
  private accountNodeXP;
@@ -1 +1 @@
1
- import{addTxSignatures as e,secp256k1 as t}from"@avalabs/avalanchejs";import{fromSeed as i}from"bip32";import{validateMnemonic as r,mnemonicToSeedSync as n}from"bip39";import"@ledgerhq/hw-app-eth";import"ethers";import{getAddressDerivationPath as o}from"../../utils/getAddressDerivationPath.js";import"hdkey";import"buffer";import{DerivationPath as s}from"../../EVM/constants.js";import"@openzeppelin/contracts/build/contracts/ERC20.json";import"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";import"../utils/populateCredential.js";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import{digestMessage as a}from"../utils/digestMessage.js";import"@avalabs/glacier-sdk";import"xss";import"bip32-path";class c{accountNodeXP;signerNodeEVM;activeAccountIndex;constructor(e,t){if(!r(e))throw new Error("Invalid mnemonic phrase.");if(t<0||t%1!=0)throw new Error("Invalid account index.");const a=n(e),c=i(a);this.accountNodeXP=c.derivePath("m/44'/9000'/0'");const p=c.derivePath(o(t,s.BIP44,"EVM"));this.signerNodeEVM=p,this.activeAccountIndex=t}getAdditionalKeys(e,t){return[...new Set(e??[])].reduce(((e,i)=>{const r=this.accountNodeXP.derivePath(`${t?1:0}/${i}`);if(!r.privateKey)throw new Error("Unable to get private key.");return e.push(r.privateKey),e}),[])}getSigningKeys(e,t,i){if("EVM"===e){if(!this.signerNodeEVM.privateKey)throw new Error("Unable to derive EVM private key.");return[this.signerNodeEVM.privateKey]}const r=this.accountNodeXP.derivePath(`0/${this.activeAccountIndex}`);if(!r.privateKey)throw new Error("Unable to derive X/P private key.");const n=this.getAdditionalKeys(t,!1);if("AVM"===e){const e=this.getAdditionalKeys(i,!0);return[r.privateKey,...n,...e]}if("PVM"===e)return[r.privateKey,...n]}async signTx(t){const{tx:i,externalIndices:r,internalIndices:n}=t,o=i.getVM(),s=this.getSigningKeys(o,r,n);if(!s?.length)throw new Error("Unable to sign transaction: signing keys are missing.");return await e({unsignedTx:i,privateKeys:s}),t.tx}async signTxBuffer(e){throw new Error("Not implemented")}getActiveAccountNode(e){switch(e){case"X":case"P":return this.accountNodeXP.derivePath(`0/${this.activeAccountIndex}`);case"C":return this.signerNodeEVM}}async signMessage(e){const i=this.getActiveAccountNode(e.chain);if(!i.privateKey)throw Error("Unable to sign message, key not found.");const r=a(e.message),n=await t.signHash(r,i.privateKey);return Buffer.from(n)}}export{c as SimpleSigner};
1
+ import{addTxSignatures as e,secp256k1 as t}from"@avalabs/avalanchejs";import{fromSeed as i}from"bip32";import{validateMnemonic as r,mnemonicToSeedSync as s}from"bip39";import"@ledgerhq/hw-app-eth";import"ethers";import{DerivationPath as n}from"../../EVM/constants.js";import"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";import{getAddressDerivationPath as o}from"../../utils/getAddressDerivationPath.js";import"hdkey";import"../utils/addSignaturesToAvalancheTx.js";import"../utils/convertGlacierUtxo.js";import"../utils/createAvalancheEvmUnsignedTx.js";import"../utils/createAvalancheUnsignedTx.js";import{digestMessage as a}from"../utils/digestMessage.js";import"../utils/getAssetBalance.js";import"../utils/getUtxosByTxFromGlacier.js";import"../utils/parseAvalancheTx.js";import"../utils/populateCredential.js";import"../utils/txSizeLimits.js";import"bip32-path";class c{accountNodeXP;signerNodeEVM;activeAccountIndex;constructor(e,t){if(!r(e))throw new Error("Invalid mnemonic phrase.");if(t<0||t%1!=0)throw new Error("Invalid account index.");const a=s(e),c=i(a);this.accountNodeXP=c.derivePath(`m/44'/9000'/${t}'`);const p=c.derivePath(o(t,"EVM",{pathSpec:n.BIP44}));this.signerNodeEVM=p,this.activeAccountIndex=t}getAdditionalKeys(e,t){return[...new Set(e??[])].reduce(((e,i)=>{const r=this.accountNodeXP.derivePath(`${t?1:0}/${i}`);if(!r.privateKey)throw new Error("Unable to get private key.");return e.push(r.privateKey),e}),[])}getSigningKeys(e,t,i){if("EVM"===e){if(!this.signerNodeEVM.privateKey)throw new Error("Unable to derive EVM private key.");return[this.signerNodeEVM.privateKey]}const r=this.accountNodeXP.derivePath("0/0");if(!r.privateKey)throw new Error("Unable to derive X/P private key.");const s=this.getAdditionalKeys(t,!1),n=this.getAdditionalKeys(i,!0);return[r.privateKey,...s,...n]}async signTx(t){const{tx:i,externalIndices:r,internalIndices:s}=t,n=i.getVM(),o=this.getSigningKeys(n,r,s);if(!o?.length)throw new Error("Unable to sign transaction: signing keys are missing.");return await e({unsignedTx:i,privateKeys:o}),t.tx}async signTxBuffer(e){throw new Error("Not implemented")}getActiveAccountNode(e){switch(e){case"X":case"P":return this.accountNodeXP.derivePath("0/0");case"C":return this.signerNodeEVM}}async signMessage(e){const i=this.getActiveAccountNode(e.chain);if(!i.privateKey)throw Error("Unable to sign message, key not found.");const r=a(e.message),s=await t.signHash(r,i.privateKey);return Buffer.from(s)}}export{c as SimpleSigner};
@@ -1 +1 @@
1
- import{WalletVoid as i}from"./WalletVoid.js";import{addTxSignatures as r,secp256k1 as e,utils as t}from"@avalabs/avalanchejs";import{validateMnemonic as s,mnemonicToSeedSync as a}from"bip39";import{fromSeed as o}from"bip32";import{digestMessage as n}from"../utils/digestMessage.js";import"../utils/populateCredential.js";import"@avalabs/core-utils-sdk";import"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"@avalabs/glacier-sdk";import"xss";import{verifyDerivationPath as p}from"../utils/verifyDerivationPath.js";const{getPublicKey:m,sign:v,signHash:f}=e,{addChecksum:h}=t;class c extends i{privKeyXP;privKeyC;constructor(i,r,e){super(Buffer.from(m(i)),Buffer.from(m(r)),e),this.privKeyXP=i,this.privKeyC=r}static fromMnemonic(i,r,e,t){if(!s(i))throw new Error("Invalid mnemonic phrase.");if(!p(e)||!p(r))throw new Error("Not valid derivation path. Make sure it is a valid BIP44 path starting with m/");const n=a(i),m=o(n),v=m.derivePath(r),f=m.derivePath(e);if(!v.privateKey||!f.privateKey)throw new Error("Failed to generate private keys.");return new c(v.privateKey,f.privateKey,t)}async signMessage(i){const r=n(i.message),e=this.getSigningKey(i.chain);return Buffer.from(h(await f(r,e)))}getSigningKey(i){return"C"===i?this.privKeyC:this.privKeyXP}async signTx(i){return await r({unsignedTx:i.tx,privateKeys:[this.privKeyC,this.privKeyXP]}),i.tx}async signTxBuffer(i){const r=this.getSigningKey(i.chain);return[Buffer.from(await v(i.buffer,r))]}}export{c as StaticSigner};
1
+ import{WalletVoid as i}from"./WalletVoid.js";import{secp256k1 as e,utils as t,addTxSignatures as r}from"@avalabs/avalanchejs";import{validateMnemonic as s,mnemonicToSeedSync as a}from"bip39";import{fromSeed as n}from"bip32";import{digestMessage as o}from"../utils/digestMessage.js";import"../utils/addSignaturesToAvalancheTx.js";import"../utils/convertGlacierUtxo.js";import"../utils/createAvalancheEvmUnsignedTx.js";import"../utils/createAvalancheUnsignedTx.js";import"../utils/getAssetBalance.js";import"../utils/getUtxosByTxFromGlacier.js";import"../utils/parseAvalancheTx.js";import"../utils/populateCredential.js";import"../utils/txSizeLimits.js";import{verifyDerivationPath as p}from"../utils/verifyDerivationPath.js";const{getPublicKey:m,sign:l,signHash:u}=e,{addChecksum:v}=t;class c extends i{privKeyXP;privKeyC;constructor(i,e,t){super(Buffer.from(m(i)),Buffer.from(m(e)),t),this.privKeyXP=i,this.privKeyC=e}static fromMnemonic(i,e,t,r){if(!s(i))throw new Error("Invalid mnemonic phrase.");if(!p(t)||!p(e))throw new Error("Not valid derivation path. Make sure it is a valid BIP44 path starting with m/");const o=a(i),m=n(o),l=m.derivePath(e),u=m.derivePath(t);if(!l.privateKey||!u.privateKey)throw new Error("Failed to generate private keys.");return new c(l.privateKey,u.privateKey,r)}async signMessage(i){const e=o(i.message),t=this.getSigningKey(i.chain);return Buffer.from(v(await u(e,t)))}getSigningKey(i){return"C"===i?this.privKeyC:this.privKeyXP}async signTx(i){return await r({unsignedTx:i.tx,privateKeys:[this.privKeyC,this.privKeyXP]}),i.tx}async signTxBuffer(i){const e=this.getSigningKey(i.chain);return[Buffer.from(await l(i.buffer,e))]}}export{c as StaticSigner};
@@ -5,7 +5,7 @@ type BaseTx = {
5
5
  chain: 'X' | 'P';
6
6
  toAddress: string;
7
7
  amountsPerAsset: Record<string, bigint>;
8
- feeState: pvm.FeeState;
8
+ feeState?: pvm.FeeState;
9
9
  options?: Common.SpendOptions;
10
10
  fromAddresses?: string[];
11
11
  };
@@ -14,32 +14,101 @@ type ImportP = {
14
14
  sourceChain: 'X' | 'C';
15
15
  toAddress?: string;
16
16
  threshold?: number;
17
- feeState: pvm.FeeState;
17
+ feeState?: pvm.FeeState;
18
18
  locktime?: bigint;
19
19
  };
20
20
  type ExportP = {
21
21
  amount: bigint;
22
22
  utxoSet: utils.UtxoSet;
23
23
  destination: 'X' | 'C';
24
- feeState: pvm.FeeState;
24
+ feeState?: pvm.FeeState;
25
25
  toAddress?: string;
26
26
  };
27
27
  type ConsolidateP = {
28
28
  utxoSet: utils.UtxoSet;
29
29
  amount: bigint;
30
- feeState: pvm.FeeState;
30
+ feeState?: pvm.FeeState;
31
31
  toAddress?: string;
32
32
  options?: Common.SpendOptions;
33
33
  };
34
34
  type CreateSubnet = {
35
35
  utxoSet: utils.UtxoSet;
36
36
  rewardAddresses: string[];
37
- feeState: pvm.FeeState;
37
+ feeState?: pvm.FeeState;
38
38
  fromAddresses?: string[];
39
39
  options?: Common.SpendOptions;
40
40
  threshold?: number;
41
41
  locktime?: bigint;
42
42
  };
43
+ type CreateChain = {
44
+ utxoSet: utils.UtxoSet;
45
+ subnetId: string;
46
+ chainName: string;
47
+ vmID: string;
48
+ fxIds: string[];
49
+ genesisData: Record<string, unknown>;
50
+ subnetAuth: number[];
51
+ feeState?: pvm.FeeState;
52
+ options?: Common.SpendOptions;
53
+ fromAddresses?: string[];
54
+ };
55
+ type ConvertSubnetToL1 = {
56
+ utxoSet: utils.UtxoSet;
57
+ address: string;
58
+ chainId: string;
59
+ subnetId: string;
60
+ subnetAuth: number[];
61
+ options?: Common.SpendOptions;
62
+ feeState: pvm.FeeState;
63
+ fromAddresses?: string[];
64
+ validators: {
65
+ nodeId: string;
66
+ weight: bigint;
67
+ balance: bigint;
68
+ pubKey: string;
69
+ signature: string;
70
+ remainingBalanceOwner: {
71
+ addresses: string[];
72
+ threshold?: number;
73
+ };
74
+ deactivationOwner: {
75
+ addresses: string[];
76
+ threshold?: number;
77
+ };
78
+ }[];
79
+ };
80
+ type RegisterL1Validator = {
81
+ utxoSet: utils.UtxoSet;
82
+ balance: bigint;
83
+ signature: string;
84
+ feeState: pvm.FeeState;
85
+ message: string;
86
+ options?: Common.SpendOptions;
87
+ fromAddresses?: string[];
88
+ };
89
+ type SetL1ValidatorWeight = {
90
+ utxoSet: utils.UtxoSet;
91
+ feeState: pvm.FeeState;
92
+ message: string;
93
+ options?: Common.SpendOptions;
94
+ fromAddresses?: string[];
95
+ };
96
+ type DisableL1Validator = {
97
+ utxoSet: utils.UtxoSet;
98
+ feeState: pvm.FeeState;
99
+ disableAuth: number[];
100
+ validationId: string;
101
+ options?: Common.SpendOptions;
102
+ fromAddresses?: string[];
103
+ };
104
+ type IncreaseL1ValidatorBalance = {
105
+ utxoSet: utils.UtxoSet;
106
+ feeState: pvm.FeeState;
107
+ balance: bigint;
108
+ validationId: string;
109
+ options?: Common.SpendOptions;
110
+ fromAddresses?: string[];
111
+ };
43
112
  type AddSubnetValidator = {
44
113
  utxoSet: utils.UtxoSet;
45
114
  nodeId: string;
@@ -48,7 +117,7 @@ type AddSubnetValidator = {
48
117
  weight: bigint;
49
118
  subnetId: string;
50
119
  subnetAuth: number[];
51
- feeState: pvm.FeeState;
120
+ feeState?: pvm.FeeState;
52
121
  fromAddresses?: string[];
53
122
  options?: Common.SpendOptions;
54
123
  };
@@ -69,7 +138,7 @@ type AddPermissionlessValidator = {
69
138
  stakingAssetId?: string;
70
139
  locktime?: bigint;
71
140
  threshold?: number;
72
- feeState: pvm.FeeState;
141
+ feeState?: pvm.FeeState;
73
142
  };
74
143
  type AddPermissionlessDelegator = {
75
144
  utxoSet: utils.UtxoSet;
@@ -82,16 +151,76 @@ type AddPermissionlessDelegator = {
82
151
  rewardAddresses?: string[];
83
152
  options?: Common.SpendOptions;
84
153
  locktime?: bigint;
85
- feeState: pvm.FeeState;
154
+ feeState?: pvm.FeeState;
86
155
  stakingAssetId?: string;
87
156
  threshold?: number;
157
+ /**
158
+ * Optional outputs to bundle atomically with the delegation. Each entry
159
+ * produces an additional transferable output on the resulting tx,
160
+ * created at delegation submission time (distinct from the reward
161
+ * output, which P-Chain emits later when the delegation ends).
162
+ *
163
+ * Note: the per-output `threshold` / `locktime` below configure that
164
+ * specific output's OutputOwners. They are independent from the
165
+ * top-level `threshold` / `locktime` on this type, which apply to the
166
+ * delegation **reward** output. Most consumers can omit both pairs.
167
+ *
168
+ * - `addresses` are the **co-owners** of the output (P-Chain bech32, e.g.
169
+ * `P-fuji1...` / `P-avax1...`); parsed to raw bytes internally. Pass
170
+ * a single-element array for the common single-recipient case;
171
+ * multiple addresses combined with `threshold` describe a multisig
172
+ * recipient.
173
+ * - `assetId` defaults to AVAX when omitted. To use a non-AVAX asset
174
+ * (e.g. a custom subnet's staking asset), pass its assetId — the
175
+ * caller's UTXO set must contain enough UTXOs of that asset to fund
176
+ * the output.
177
+ * - `threshold` is the number of signatures required to spend the
178
+ * output; defaults to 1 (any one of `addresses`).
179
+ * - `locktime` (unix seconds) locks the output until that time; defaults
180
+ * to 0 (immediately spendable).
181
+ */
182
+ additionalOutputs?: readonly {
183
+ addresses: readonly string[];
184
+ amount: bigint;
185
+ assetId?: string;
186
+ threshold?: number;
187
+ locktime?: bigint;
188
+ }[];
88
189
  };
89
190
  type RemoveSubnetValidator = {
90
191
  utxoSet: utils.UtxoSet;
91
192
  nodeId: string;
92
193
  subnetId: string;
93
194
  subnetAuth: number[];
195
+ feeState?: pvm.FeeState;
196
+ fromAddresses?: string[];
197
+ options?: Common.SpendOptions;
198
+ };
199
+ type AddAutoRenewedValidator = {
200
+ utxoSet: utils.UtxoSet;
201
+ nodeId: string;
202
+ weight: bigint;
203
+ shares: number;
204
+ feeState: pvm.FeeState;
205
+ fromAddresses?: string[];
206
+ rewardAddresses?: string[];
207
+ delegatorRewardAddresses?: string[];
208
+ ownerAddresses?: string[];
209
+ publicKey: Buffer;
210
+ signature: Buffer;
211
+ autoCompoundRewardShares: number;
212
+ period: bigint;
213
+ options?: Common.SpendOptions;
214
+ locktime?: bigint;
215
+ threshold?: number;
216
+ };
217
+ type SetAutoRenewedValidatorConfig = {
218
+ utxoSet: utils.UtxoSet;
94
219
  feeState: pvm.FeeState;
220
+ validatorTxId: string;
221
+ auth: number[];
222
+ autoCompoundRewardShares: number;
223
+ period: bigint;
95
224
  fromAddresses?: string[];
96
225
  options?: Common.SpendOptions;
97
226
  };
@@ -100,11 +229,11 @@ type TransferSubnetOwnershipTx = {
100
229
  subnetId: string;
101
230
  subnetAuth: number[];
102
231
  subnetOwners: string[];
103
- feeState: pvm.FeeState;
232
+ feeState?: pvm.FeeState;
104
233
  fromAddresses?: string[];
105
234
  options?: Common.SpendOptions;
106
235
  threshold?: number;
107
236
  locktime?: bigint;
108
237
  };
109
238
 
110
- export { AddPermissionlessDelegator, AddPermissionlessValidator, AddSubnetValidator, BaseTx, ConsolidateP, CreateSubnet, ExportP, ImportP, RemoveSubnetValidator, TransferSubnetOwnershipTx };
239
+ export type { AddAutoRenewedValidator, AddPermissionlessDelegator, AddPermissionlessValidator, AddSubnetValidator, BaseTx, ConsolidateP, ConvertSubnetToL1, CreateChain, CreateSubnet, DisableL1Validator, ExportP, ImportP, IncreaseL1ValidatorBalance, RegisterL1Validator, RemoveSubnetValidator, SetAutoRenewedValidatorConfig, SetL1ValidatorWeight, TransferSubnetOwnershipTx };
@@ -1,8 +1,8 @@
1
1
  import * as _avalabs_avalanchejs from '@avalabs/avalanchejs';
2
- import { utils, pvm, Common } from '@avalabs/avalanchejs';
2
+ import { utils, pvm } from '@avalabs/avalanchejs';
3
3
  import { AbstractProvider } from '../providers/AbstractProvider.js';
4
4
  import { ChainIDAlias } from '../models.js';
5
- import { ImportP, ExportP, ConsolidateP, BaseTx, CreateSubnet, AddSubnetValidator, AddPermissionlessValidator, AddPermissionlessDelegator, RemoveSubnetValidator, TransferSubnetOwnershipTx } from './TxBuilderTypes.js';
5
+ import { ImportP, ExportP, ConsolidateP, BaseTx, ConvertSubnetToL1, RegisterL1Validator, SetL1ValidatorWeight, DisableL1Validator, IncreaseL1ValidatorBalance, AddAutoRenewedValidator, SetAutoRenewedValidatorConfig, CreateChain, CreateSubnet, AddSubnetValidator, AddPermissionlessValidator, AddPermissionlessDelegator, RemoveSubnetValidator, TransferSubnetOwnershipTx } from './TxBuilderTypes.js';
6
6
 
7
7
  /**
8
8
  * An abstract class that that is shared by all wallet classes.
@@ -49,13 +49,9 @@ declare abstract class WalletAbstract {
49
49
  * @param source What is the source chain of the atomic UTXOs
50
50
  */
51
51
  getAtomicUTXOs(chain: ChainIDAlias, source: ChainIDAlias): Promise<utils.UtxoSet>;
52
- /**
53
- * Get the nonce of this wallet's C chain address
54
- */
55
- getNonce(): Promise<number>;
56
- exportX(amount: bigint, utxoSet: utils.UtxoSet, destination: 'P' | 'C', toAddress?: string): Common.UnsignedTx;
57
- importP({ utxoSet, sourceChain, toAddress, threshold, feeState, locktime, }: ImportP): Common.UnsignedTx;
58
- importX(utxos: utils.UtxoSet, sourceChain: 'P' | 'C', toAddress?: string): Common.UnsignedTx;
52
+ exportX(amount: bigint, utxoSet: utils.UtxoSet, destination: 'P' | 'C', toAddress?: string): _avalabs_avalanchejs.UnsignedTx;
53
+ importP({ utxoSet, sourceChain, toAddress, threshold, feeState, locktime, }: ImportP): _avalabs_avalanchejs.UnsignedTx;
54
+ importX(utxos: utils.UtxoSet, sourceChain: 'P' | 'C', toAddress?: string): _avalabs_avalanchejs.UnsignedTx;
59
55
  /**
60
56
  *
61
57
  * @param utxos
@@ -64,7 +60,7 @@ declare abstract class WalletAbstract {
64
60
  * @param feeAssetId
65
61
  * @param toAddress Must be hex EVM address.
66
62
  */
67
- importC(utxos: utils.UtxoSet, sourceChain: 'P' | 'X', baseFee: bigint, feeAssetId?: string, toAddress?: string): Common.UnsignedTx;
63
+ importC(utxos: utils.UtxoSet, sourceChain: 'P' | 'X', baseFee: bigint, feeAssetId?: string, toAddress?: string): _avalabs_avalanchejs.UnsignedTx;
68
64
  /**
69
65
  *
70
66
  * @param amount
@@ -81,18 +77,19 @@ declare abstract class WalletAbstract {
81
77
  * @param destination
82
78
  * @param toAddress
83
79
  */
84
- exportP({ amount, utxoSet, destination, feeState, toAddress }: ExportP): Common.UnsignedTx;
85
- addValidator(utxos: utils.UtxoSet, nodeId: string, stakeAmount: bigint, startDate: bigint, endDate: bigint, delegationFee: number, config?: {
86
- rewardAddress?: string;
87
- }): Common.UnsignedTx;
88
- addDelegator(utxos: utils.UtxoSet, nodeId: string, stakeAmount: bigint, startDate: bigint, endDate: bigint, config?: {
89
- rewardAddress?: string;
90
- }): Common.UnsignedTx;
91
- consolidateP({ utxoSet, amount, feeState, toAddress, options, }: ConsolidateP): Common.UnsignedTx;
92
- baseTX({ utxoSet, chain, toAddress, amountsPerAsset, feeState, options, fromAddresses, }: BaseTx): Common.UnsignedTx;
93
- createBlockchain(utxoSet: utils.UtxoSet, subnetId: string, chainName: string, vmID: string, fxIds: string[], genesisData: Record<string, unknown>, subnetAuth: number[], options?: Common.SpendOptions, fromAddresses?: string[]): Common.UnsignedTx;
94
- createSubnet({ utxoSet, rewardAddresses, feeState, fromAddresses, options, threshold, locktime, }: CreateSubnet): Common.UnsignedTx;
95
- addSubnetValidator({ utxoSet, nodeId, start, end, weight, subnetId, subnetAuth, feeState, fromAddresses, options, }: AddSubnetValidator): Common.UnsignedTx;
80
+ exportP({ amount, utxoSet, destination, feeState, toAddress }: ExportP): _avalabs_avalanchejs.UnsignedTx;
81
+ consolidateP({ utxoSet, amount, feeState, toAddress, options, }: ConsolidateP): _avalabs_avalanchejs.UnsignedTx;
82
+ baseTX({ utxoSet, chain, toAddress, amountsPerAsset, feeState, options, fromAddresses, }: BaseTx): _avalabs_avalanchejs.UnsignedTx;
83
+ convertSubnetToL1({ utxoSet, chainId, subnetId, subnetAuth, feeState, address, validators, options, fromAddresses, }: ConvertSubnetToL1): _avalabs_avalanchejs.UnsignedTx;
84
+ registerL1Validator({ utxoSet, balance, signature, message, feeState, fromAddresses, options, }: RegisterL1Validator): _avalabs_avalanchejs.UnsignedTx;
85
+ setL1ValidatorWeight({ utxoSet, feeState, message, options, fromAddresses, }: SetL1ValidatorWeight): _avalabs_avalanchejs.UnsignedTx;
86
+ disableL1Validator({ utxoSet, feeState, options, fromAddresses, disableAuth, validationId, }: DisableL1Validator): _avalabs_avalanchejs.UnsignedTx;
87
+ increaseL1ValidatorBalance({ utxoSet, feeState, options, fromAddresses, balance, validationId, }: IncreaseL1ValidatorBalance): _avalabs_avalanchejs.UnsignedTx;
88
+ addAutoRenewedValidator({ utxoSet, nodeId, weight, shares, feeState, fromAddresses, rewardAddresses, delegatorRewardAddresses, ownerAddresses, publicKey, signature, autoCompoundRewardShares, period, options, locktime, threshold, }: AddAutoRenewedValidator): _avalabs_avalanchejs.UnsignedTx;
89
+ setAutoRenewedValidatorConfig({ utxoSet, feeState, validatorTxId, auth, autoCompoundRewardShares, period, fromAddresses, options, }: SetAutoRenewedValidatorConfig): _avalabs_avalanchejs.UnsignedTx;
90
+ createBlockchain({ utxoSet, subnetId, chainName, vmID, fxIds, genesisData, subnetAuth, feeState, options, fromAddresses, }: CreateChain): _avalabs_avalanchejs.UnsignedTx;
91
+ createSubnet({ utxoSet, rewardAddresses, feeState, fromAddresses, options, threshold, locktime, }: CreateSubnet): _avalabs_avalanchejs.UnsignedTx;
92
+ addSubnetValidator({ utxoSet, nodeId, start, end, weight, subnetId, subnetAuth, feeState, fromAddresses, options, }: AddSubnetValidator): _avalabs_avalanchejs.UnsignedTx;
96
93
  /**
97
94
  *
98
95
  * @param utxoSet The transaction will be constructed from these UTXOs.
@@ -109,7 +106,7 @@ declare abstract class WalletAbstract {
109
106
  * @param signature the BLS signature, If the subnet is the primary network. Can be found in the Node on startup.
110
107
  * @param options
111
108
  */
112
- addPermissionlessValidator({ utxoSet, nodeId, start, end, weight, subnetId, shares, feeState, fromAddresses, rewardAddresses, delegatorRewardAddresses, publicKey, signature, options, threshold, locktime, stakingAssetId, }: AddPermissionlessValidator): Common.UnsignedTx;
109
+ addPermissionlessValidator({ utxoSet, nodeId, start, end, weight, subnetId, shares, feeState, fromAddresses, rewardAddresses, delegatorRewardAddresses, publicKey, signature, options, threshold, locktime, stakingAssetId, }: AddPermissionlessValidator): _avalabs_avalanchejs.UnsignedTx;
113
110
  /**
114
111
  *
115
112
  * @param utxoSet The transaction will be constructed from these UTXOs.
@@ -122,10 +119,9 @@ declare abstract class WalletAbstract {
122
119
  * @param rewardAddresses Will use active address if not provided. Given addresses will share the reward UTXO.
123
120
  * @param options
124
121
  */
125
- addPermissionlessDelegator({ utxoSet, nodeId, start, end, weight, subnetId, fromAddresses, rewardAddresses, options, locktime, feeState, threshold, stakingAssetId, }: AddPermissionlessDelegator): Common.UnsignedTx;
126
- removeSubnetValidator({ utxoSet, nodeId, subnetId, subnetAuth, fromAddresses, feeState, options, }: RemoveSubnetValidator): Common.UnsignedTx;
127
- transferSubnetOwnershipTx({ utxoSet, subnetId, subnetAuth, subnetOwners, feeState, fromAddresses, options, threshold, locktime, }: TransferSubnetOwnershipTx): Common.UnsignedTx;
128
- transformSubnetTx(utxoSet: utils.UtxoSet, subnetId: string, assetId: string, initialSupply: bigint, maximumSupply: bigint, minConsumptionRate: bigint, maxConsumptionRate: bigint, minValidatorStake: bigint, maxValidatorStake: bigint, minStakeDuration: number, maxStakeDuration: number, minDelegationFee: number, minDelegatorStake: number, maxValidatorWeightFactor: number, uptimeRequirement: number, subnetAuth: number[], fromAddresses?: string[], options?: Common.SpendOptions): Common.UnsignedTx;
122
+ addPermissionlessDelegator({ utxoSet, nodeId, start, end, weight, subnetId, fromAddresses, rewardAddresses, options, locktime, feeState, threshold, stakingAssetId, additionalOutputs, }: AddPermissionlessDelegator): _avalabs_avalanchejs.UnsignedTx;
123
+ removeSubnetValidator({ utxoSet, nodeId, subnetId, subnetAuth, fromAddresses, feeState, options, }: RemoveSubnetValidator): _avalabs_avalanchejs.UnsignedTx;
124
+ transferSubnetOwnershipTx({ utxoSet, subnetId, subnetAuth, subnetOwners, feeState, fromAddresses, options, threshold, locktime, }: TransferSubnetOwnershipTx): _avalabs_avalanchejs.UnsignedTx;
129
125
  protected constructor(provider: AbstractProvider);
130
126
  }
131
127
 
@@ -1 +1 @@
1
- import{TransferableOutput as e,avm as t,pvm as s,evm as r,networkIDs as d,utils as i}from"@avalabs/avalanchejs";import"../utils/populateCredential.js";import{strip0x as o}from"@avalabs/core-utils-sdk";import"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"bip32";import{getUTXOsForAddresses as n}from"../utils/getAllUTXOs.js";import{getStakeForAddresses as a}from"../utils/getStakeForAddresses.js";import"@avalabs/glacier-sdk";import"bip39";import"xss";import{sortUTXOsByAmount as h,sortUTXOsStaking as m,sortUTXOsByAmountAscending as g}from"../utils/sortUTXOs.js";import"bip32-path";const{parse:p,hexToBuffer:u}=i,A=new Error("Tx type is not supported post-etna");class c{constructor(e){this.provider=e}setProvider(e){this.provider=e}getProvider(){return this.provider}async getUTXOs(e){const t=this.provider.getApi(e);return n(this.getAddresses(e),t)}async getStake(){const e=this.provider.getApiP();return a(this.getAddresses("P"),e)}async getAtomicUTXOs(e,t){if(e===t)throw new Error("Chain can not be the same as source chain.");const s=this.provider.getApi(e),r=this.provider.getChainID(t);return n(this.getAddresses(e),s,{sourceChain:r,addresses:[]})}async getNonce(){const e=this.getAddressEVM();return await this.provider.evmRpc.getTransactionCount(e)}exportX(s,r,d,i){i=i||this.getCurrentAddress(d);const o=p(i)[2],n=this.provider.getAvaxID(),a=e.fromNative(n,s,[o]),m=h(r.getUTXOs(),!0),g=this.provider.getChainID(d),u=this.getAddresses("X").map((e=>p(e)[2])),A=p(this.getChangeAddress("X"))[2];return t.newExportTx(this.provider.getContext(),g,u,m,[a],{threshold:1,changeAddresses:[A]})}importP({utxoSet:e,sourceChain:t,toAddress:r,threshold:d,feeState:i,locktime:o}){const n=this.provider.getChainID(t),a=this.getAddresses("P").map((e=>p(e)[2])),h=p(this.getChangeAddress("P"))[2];r=r||this.getCurrentAddress("P");const m=p(r)[2],g=e.getUTXOs();return this.provider.isEtnaEnabled()?s.e.newImportTx({fromAddressesBytes:a,utxos:g,toAddressesBytes:[m],sourceChainId:n,threshold:d,feeState:i,locktime:o},this.provider.getContext()):s.newImportTx(this.provider.getContext(),n,g,[m],a,{changeAddresses:[h]})}importX(e,s,r){const d=this.provider.getChainID(s),i=this.getAddresses("X").map((e=>p(e)[2])),o=p(this.getChangeAddress("X"))[2];r=r||this.getCurrentAddress("X");const n=p(r)[2];return t.newImportTx(this.provider.getContext(),d,e.getUTXOs(),[n],i,{changeAddresses:[o]})}importC(e,t,s,d,i){const n=this.provider.getChainID(t),a=this.getAddresses("C").map((e=>p(e)[2]));i=i||this.getAddressEVM();const h=Buffer.from(o(i),"hex");return r.newImportTxFromBaseFee(this.provider.getContext(),h,a,e.getUTXOs(),n,s,d)}exportC(e,t,s,d,i){const o=u(this.getAddressEVM()),n=this.provider.getChainID(t);i=i||this.getCurrentAddress(t);const a=p(i)[2],h=d/BigInt(1e9);return r.newExportTxFromBaseFee(this.provider.getContext(),h,e,n,o,[a],s)}exportP({amount:t,utxoSet:r,destination:d,feeState:i,toAddress:o}){o=o||this.getCurrentAddress(d);const n=p(o)[2],a=this.provider.getAvaxID(),m=e.fromNative(a,t,[n]),g=h(r.getUTXOs(),!0),u=this.provider.getChainID(d),A=this.getAddresses("P").map((e=>p(e)[2])),c=p(this.getChangeAddress("P"))[2];return this.provider.isEtnaEnabled()?s.e.newExportTx({fromAddressesBytes:A,utxos:g,outputs:[m],destinationChainId:u,feeState:i},this.provider.getContext()):s.newExportTx(this.provider.getContext(),u,A,g,[m],{changeAddresses:[c]})}addValidator(e,t,r,d,i,o,n){const a=m(e.getUTXOs()),h=this.getAddresses("P").map((e=>p(e)[2])),g=n?.rewardAddress||this.getCurrentAddress("P"),u=p(g)[2],c=p(this.getChangeAddress("P"))[2];if(this.provider.isEtnaEnabled())throw A;return s.newAddValidatorTx(this.provider.getContext(),a,h,t,d,i,r,[u],o,{changeAddresses:[c]})}addDelegator(e,t,r,d,i,o){const n=m(e.getUTXOs()),a=this.getAddresses("P").map((e=>p(e)[2])),h=o?.rewardAddress||this.getCurrentAddress("P"),g=p(h)[2],u=p(this.getChangeAddress("P"))[2];if(this.provider.isEtnaEnabled())throw A;return s.newAddDelegatorTx(this.provider.getContext(),n,a,t,d,i,r,[g],{changeAddresses:[u]})}consolidateP({utxoSet:t,amount:r,feeState:d,toAddress:i,options:o}){const n=g(t.getUTXOs());i=i??this.getCurrentAddress("P");const a=p(i)[2],h=this.provider.getContext(),m=[e.fromNative(h.avaxAssetID,r,[a])],u=this.getAddresses("P").map((e=>p(e)[2]));return this.provider.isEtnaEnabled()?s.e.newBaseTx({fromAddressesBytes:u,utxos:n,outputs:m,minIssuanceTime:o?.minIssuanceTime,memo:o?.memo,feeState:d},h):s.newBaseTx(this.provider.getContext(),u,n,m,o)}baseTX({utxoSet:r,chain:d,toAddress:i,amountsPerAsset:o,feeState:n,options:a,fromAddresses:m}){const[g,u,A]=p(i);if(g!==d||u!==this.provider.getHrp())throw new Error(`Invalid recipient address "${i}"`);const c=Object.entries(o).map((([t,s])=>e.fromNative(t,s,[A]))),x=h(r.getUTXOs(),!0),v=(m??this.getAddresses(d)).map((e=>p(e)[2]));return"X"===d?t.newBaseTx(this.provider.getContext(),v,x,c,a):this.provider.isEtnaEnabled()?s.e.newBaseTx({fromAddressesBytes:v,utxos:x,outputs:c,minIssuanceTime:a?.minIssuanceTime,memo:a?.memo,feeState:n},this.provider.getContext()):s.newBaseTx(this.provider.getContext(),v,x,c,a)}createBlockchain(e,t,r,d,i,o,n,a,m){const g=h(e.getUTXOs(),!0),u=(m??this.getAddresses("P")).map((e=>p(e)[2]));if(this.provider.isEtnaEnabled())throw A;return s.newCreateBlockchainTx(this.provider.getContext(),g,u,t,r,d,i,o,n,a)}createSubnet({utxoSet:e,rewardAddresses:t,feeState:r,fromAddresses:d,options:i,threshold:o,locktime:n}){const a=h(e.getUTXOs(),!0),m=(d??this.getAddresses("P")).map((e=>p(e)[2])),g=t.map((e=>p(e)[2]));return this.provider.isEtnaEnabled()?s.e.newCreateSubnetTx({fromAddressesBytes:m,utxos:a,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,feeState:r,threshold:o,locktime:n,subnetOwners:g},this.provider.getContext()):s.newCreateSubnetTx(this.provider.getContext(),a,m,g,i,o??1,n??BigInt(0))}addSubnetValidator({utxoSet:e,nodeId:t,start:r,end:d,weight:i,subnetId:o,subnetAuth:n,feeState:a,fromAddresses:m,options:g}){const u=h(e.getUTXOs(),!0),A=(m??this.getAddresses("P")).map((e=>p(e)[2]));return this.provider.isEtnaEnabled()?s.e.newAddSubnetValidatorTx({fromAddressesBytes:A,utxos:u,minIssuanceTime:g?.minIssuanceTime,memo:g?.memo,nodeId:t,start:r,end:d,weight:i,subnetId:o,subnetAuth:n,feeState:a},this.provider.getContext()):s.newAddSubnetValidatorTx(this.provider.getContext(),u,A,t,r,d,i,o,n,g)}addPermissionlessValidator({utxoSet:e,nodeId:t,start:r,end:i,weight:o,subnetId:n,shares:a,feeState:h,fromAddresses:g,rewardAddresses:u,delegatorRewardAddresses:A,publicKey:c,signature:x,options:v,threshold:l,locktime:T,stakingAssetId:C}){const f=m(e.getUTXOs()),w=(g??this.getAddresses("P")).map((e=>p(e)[2])),b=(u??[this.getCurrentAddress("P")]).map((e=>p(e)[2])),I=(A??[this.getCurrentAddress("P")]).map((e=>p(e)[2]));if(!(n!==d.PrimaryNetworkID.toString()||c&&x))throw new Error("Must provide public key and signature for primary subnet.");const S=p(this.getChangeAddress("P"))[2];if(this.provider.isEtnaEnabled())return s.e.newAddPermissionlessValidatorTx({fromAddressesBytes:w,delegatorRewardsOwner:I,utxos:f,minIssuanceTime:v?.minIssuanceTime,memo:v?.memo,changeAddressesBytes:v?.changeAddresses?v.changeAddresses:[S],nodeId:t,start:r,end:i,weight:o,subnetId:n,shares:a,feeState:h,publicKey:c,rewardAddresses:b,signature:x,locktime:T,threshold:l,stakingAssetId:C},this.provider.getContext());const P={changeAddresses:[S],...v??{}};return s.newAddPermissionlessValidatorTx(this.provider.getContext(),f,w,t,n,r,i,o,b,I,a,P,void 0,void 0,c,x)}addPermissionlessDelegator({utxoSet:e,nodeId:t,start:r,end:d,weight:i,subnetId:o,fromAddresses:n,rewardAddresses:a,options:h,locktime:g,feeState:u,threshold:A,stakingAssetId:c}){const x=m(e.getUTXOs()),v=(n??this.getAddresses("P")).map((e=>p(e)[2])),l=(a??[this.getCurrentAddress("P")]).map((e=>p(e)[2])),T=p(this.getChangeAddress("P"))[2];if(this.provider.isEtnaEnabled())return s.e.newAddPermissionlessDelegatorTx({fromAddressesBytes:v,utxos:x,minIssuanceTime:h?.minIssuanceTime,memo:h?.memo,changeAddressesBytes:h?.changeAddresses?h.changeAddresses:[T],nodeId:t,start:r,end:d,weight:i,subnetId:o,rewardAddresses:l,locktime:g,stakingAssetId:c,threshold:A,feeState:u},this.provider.getContext());const C={changeAddresses:[T],...h??{}};return s.newAddPermissionlessDelegatorTx(this.provider.getContext(),x,v,t,o,r,d,i,l,C,void 0,void 0)}removeSubnetValidator({utxoSet:e,nodeId:t,subnetId:r,subnetAuth:d,fromAddresses:i,feeState:o,options:n}){const a=h(e.getUTXOs(),!0),m=(i??this.getAddresses("P")).map((e=>p(e)[2]));return this.provider.isEtnaEnabled()?s.e.newRemoveSubnetValidatorTx({fromAddressesBytes:m,utxos:a,minIssuanceTime:n?.minIssuanceTime,memo:n?.memo,nodeId:t,subnetId:r,subnetAuth:d,feeState:o},this.provider.getContext()):s.newRemoveSubnetValidatorTx(this.provider.getContext(),a,m,t,r,d,n)}transferSubnetOwnershipTx({utxoSet:e,subnetId:t,subnetAuth:r,subnetOwners:d,feeState:i,fromAddresses:o,options:n,threshold:a,locktime:m}){const g=h(e.getUTXOs(),!0),u=(o??this.getAddresses("P")).map((e=>p(e)[2])),A=d.map((e=>p(e)[2]));return this.provider.isEtnaEnabled()?s.e.newTransferSubnetOwnershipTx({fromAddressesBytes:u,utxos:g,minIssuanceTime:n?.minIssuanceTime,memo:n?.memo,subnetId:t,subnetAuth:r,subnetOwners:A,feeState:i,threshold:a,locktime:m},this.provider.getContext()):s.newTransferSubnetOwnershipTx(this.provider.getContext(),g,u,t,r,A,n,a??1,m??BigInt(0))}transformSubnetTx(e,t,r,d,i,o,n,a,m,g,u,c,x,v,l,T,C,f){const w=h(e.getUTXOs(),!0),b=(C??this.getAddresses("P")).map((e=>p(e)[2]));if(this.provider.isEtnaEnabled())throw A;return s.newTransformSubnetTx(this.provider.getContext(),w,b,t,r,d,i,o,n,a,m,g,u,c,x,v,l,T,f)}}export{c as WalletAbstract};
1
+ import"../utils/addSignaturesToAvalancheTx.js";import"../utils/convertGlacierUtxo.js";import"../utils/createAvalancheEvmUnsignedTx.js";import"../utils/createAvalancheUnsignedTx.js";import"create-hash";import"bip32";import{getUTXOsForAddresses as e}from"../utils/getAllUTXOs.js";import"../utils/getAssetBalance.js";import{utils as s,TransferableOutput as t,avm as r,pvm as d,evm as o,pvmSerial as n,PChainOwner as i,L1Validator as a,networkIDs as m}from"@avalabs/avalanchejs";import{getStakeForAddresses as h}from"../utils/getStakeForAddresses.js";import"../utils/getUtxosByTxFromGlacier.js";import"bip39";import"../utils/parseAvalancheTx.js";import"../utils/populateCredential.js";import{sortUTXOsByAmount as u,sortUTXOsByAmountAscending as g,sortUTXOsStaking as A}from"../utils/sortUTXOs.js";import"../utils/txSizeLimits.js";import"bip32-path";import{strip0x as c}from"@avalabs/core-utils-sdk";import{assertFeeStateProvided as p}from"../../utils/assertFeeStateProvided.js";const{parse:l,hexToBuffer:f}=s;class x{constructor(e){this.provider=e}setProvider(e){this.provider=e}getProvider(){return this.provider}async getUTXOs(s){const t=this.provider.getApi(s);return e(this.getAddresses(s),t)}async getStake(){const e=this.provider.getApiP();return h(this.getAddresses("P"),e)}async getAtomicUTXOs(s,t){if(s===t)throw new Error("Chain can not be the same as source chain.");const r=this.provider.getApi(s),d=this.provider.getChainID(t);return e(this.getAddresses(s),r,{sourceChain:d,addresses:[]})}exportX(e,s,d,o){o=o||this.getCurrentAddress(d);const n=l(o)[2],i=this.provider.getAvaxID(),a=t.fromNative(i,e,[n]),m=u(s.getUTXOs(),!0),h=this.provider.getChainID(d),g=this.getAddresses("X").map((e=>l(e)[2])),A=l(this.getChangeAddress("X"))[2];return r.newExportTx(this.provider.getContext(),h,g,m,[a],{threshold:1,changeAddresses:[A]})}importP({utxoSet:e,sourceChain:s,toAddress:t,threshold:r,feeState:o,locktime:n}){const i=this.provider.getChainID(s),a=this.getAddresses("P").map((e=>l(e)[2]));l(this.getChangeAddress("P"))[2],t=t||this.getCurrentAddress("P");const m=l(t)[2],h=e.getUTXOs();return p(o),d.newImportTx({fromAddressesBytes:a,utxos:h,toAddressesBytes:[m],sourceChainId:i,threshold:r,feeState:o,locktime:n},this.provider.getContext())}importX(e,s,t){const d=this.provider.getChainID(s),o=this.getAddresses("X").map((e=>l(e)[2])),n=l(this.getChangeAddress("X"))[2];t=t||this.getCurrentAddress("X");const i=l(t)[2];return r.newImportTx(this.provider.getContext(),d,e.getUTXOs(),[i],o,{changeAddresses:[n]})}importC(e,s,t,r,d){const n=this.provider.getChainID(s),i=this.getAddresses("C").map((e=>l(e)[2]));d=d||this.getAddressEVM();const a=Buffer.from(c(d),"hex");return o.newImportTxFromBaseFee(this.provider.getContext(),a,i,e.getUTXOs(),n,t,r)}exportC(e,s,t,r,d){const n=f(this.getAddressEVM()),i=this.provider.getChainID(s);d=d||this.getCurrentAddress(s);const a=l(d)[2],m=r/BigInt(1e9);return o.newExportTxFromBaseFee(this.provider.getContext(),m,e,i,n,[a],t)}exportP({amount:e,utxoSet:s,destination:r,feeState:o,toAddress:n}){n=n||this.getCurrentAddress(r);const i=l(n)[2],a=this.provider.getAvaxID(),m=t.fromNative(a,e,[i]),h=u(s.getUTXOs(),!0),g=this.provider.getChainID(r),A=this.getAddresses("P").map((e=>l(e)[2])),c=l(this.getChangeAddress("P"))[2];return p(o),d.newExportTx({changeAddressesBytes:[c],fromAddressesBytes:A,utxos:h,outputs:[m],destinationChainId:g,feeState:o},this.provider.getContext())}consolidateP({utxoSet:e,amount:s,feeState:r,toAddress:o,options:n}){const i=g(e.getUTXOs());o=o??this.getCurrentAddress("P");const a=l(o)[2],m=this.provider.getContext(),h=[t.fromNative(m.avaxAssetID,s,[a])],u=this.getAddresses("P").map((e=>l(e)[2])),A=l(this.getChangeAddress("P"))[2],c=n?.changeAddresses??[A];return p(r),d.newBaseTx({changeAddressesBytes:c,fromAddressesBytes:u,utxos:i,outputs:h,minIssuanceTime:n?.minIssuanceTime,memo:n?.memo,feeState:r},m)}baseTX({utxoSet:e,chain:s,toAddress:o,amountsPerAsset:n,feeState:i,options:a,fromAddresses:m}){const[h,g,A]=l(o);if(h!==s||g!==this.provider.getHrp())throw new Error(`Invalid recipient address "${o}"`);const c=Object.entries(n).map((([e,s])=>t.fromNative(e,s,[A]))),f=u(e.getUTXOs(),!0),x=(m??this.getAddresses(s)).map((e=>l(e)[2])),T=l(this.getChangeAddress("P"))[2],I=a?.changeAddresses??[T];return"X"===s?r.newBaseTx(this.provider.getContext(),x,f,c,a):(p(i),d.newBaseTx({changeAddressesBytes:I,fromAddressesBytes:x,utxos:f,outputs:c,minIssuanceTime:a?.minIssuanceTime,memo:a?.memo,feeState:i},this.provider.getContext()))}convertSubnetToL1({utxoSet:e,chainId:t,subnetId:r,subnetAuth:o,feeState:m,address:h,validators:g,options:A,fromAddresses:c}){const p=(c??this.getAddresses("P")).map((e=>l(e)[2])),f=l(this.getChangeAddress("P"))[2],x=A?.changeAddresses??[f],T=g.map((({nodeId:e,pubKey:t,signature:r,balance:d,weight:o,deactivationOwner:m,remainingBalanceOwner:h})=>{const u=new n.ProofOfPossession(Uint8Array.from(s.hexToBuffer(t)),Uint8Array.from(s.hexToBuffer(r))),g=i.fromNative(h.addresses.map((e=>l(e)[2])),h.threshold??1),A=i.fromNative(m.addresses.map((e=>l(e)[2])),m.threshold??1);return a.fromNative(e,o,d,u,g,A)}));return d.newConvertSubnetToL1Tx({changeAddressesBytes:x,validators:T,fromAddressesBytes:p,address:l(h)[2],chainId:t,subnetId:r,subnetAuth:o,feeState:m,utxos:u(e.getUTXOs(),!0)},this.provider.getContext())}registerL1Validator({utxoSet:e,balance:t,signature:r,message:o,feeState:n,fromAddresses:i,options:a}){const m=(i??this.getAddresses("P")).map((e=>l(e)[2])),h=l(this.getChangeAddress("P"))[2],g=a?.changeAddresses??[h];return d.newRegisterL1ValidatorTx({utxos:u(e.getUTXOs(),!0),balance:t,blsSignature:Uint8Array.from(s.hexToBuffer(r)),changeAddressesBytes:g,feeState:n,fromAddressesBytes:m,memo:a?.memo,message:Uint8Array.from(s.hexToBuffer(o)),minIssuanceTime:a?.minIssuanceTime},this.provider.getContext())}setL1ValidatorWeight({utxoSet:e,feeState:t,message:r,options:o,fromAddresses:n}){const i=(n??this.getAddresses("P")).map((e=>l(e)[2])),a=l(this.getChangeAddress("P"))[2],m=o?.changeAddresses??[a];return d.newSetL1ValidatorWeightTx({utxos:u(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:t,fromAddressesBytes:i,memo:o?.memo,message:Uint8Array.from(s.hexToBuffer(r)),minIssuanceTime:o?.minIssuanceTime},this.provider.getContext())}disableL1Validator({utxoSet:e,feeState:s,options:t,fromAddresses:r,disableAuth:o,validationId:n}){const i=(r??this.getAddresses("P")).map((e=>l(e)[2])),a=l(this.getChangeAddress("P"))[2],m=t?.changeAddresses??[a];return d.newDisableL1ValidatorTx({disableAuth:o,validationId:n,utxos:u(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:s,fromAddressesBytes:i,memo:t?.memo,minIssuanceTime:t?.minIssuanceTime},this.provider.getContext())}increaseL1ValidatorBalance({utxoSet:e,feeState:s,options:t,fromAddresses:r,balance:o,validationId:n}){const i=(r??this.getAddresses("P")).map((e=>l(e)[2])),a=l(this.getChangeAddress("P"))[2],m=t?.changeAddresses??[a];return d.newIncreaseL1ValidatorBalanceTx({balance:o,validationId:n,utxos:u(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:s,fromAddressesBytes:i,memo:t?.memo,minIssuanceTime:t?.minIssuanceTime},this.provider.getContext())}addAutoRenewedValidator({utxoSet:e,nodeId:s,weight:t,shares:r,feeState:o,fromAddresses:n,rewardAddresses:i,delegatorRewardAddresses:a,ownerAddresses:m,publicKey:h,signature:u,autoCompoundRewardShares:g,period:c,options:p,locktime:f,threshold:x}){const T=A(e.getUTXOs()),I=(n??this.getAddresses("P")).map((e=>l(e)[2])),C=(i??[this.getCurrentAddress("P")]).map((e=>l(e)[2])),v=(a??[this.getCurrentAddress("P")]).map((e=>l(e)[2])),S=(m??[this.getCurrentAddress("P")]).map((e=>l(e)[2])),w=l(this.getChangeAddress("P"))[2],b=p?.changeAddresses??[w];return d.newAddAutoRenewedValidatorTx({fromAddressesBytes:I,delegatorRewardsOwner:v,utxos:T,minIssuanceTime:p?.minIssuanceTime,memo:p?.memo,changeAddressesBytes:b,nodeId:s,weight:t,shares:r,feeState:o,publicKey:h,rewardAddresses:C,signature:u,locktime:f,threshold:x,ownerAddresses:S,autoCompoundRewardShares:g,period:c},this.provider.getContext())}setAutoRenewedValidatorConfig({utxoSet:e,feeState:s,validatorTxId:t,auth:r,autoCompoundRewardShares:o,period:n,fromAddresses:i,options:a}){const m=(i??this.getAddresses("P")).map((e=>l(e)[2])),h=l(this.getChangeAddress("P"))[2],g=a?.changeAddresses??[h];return d.newSetAutoRenewedValidatorConfigTx({utxos:u(e.getUTXOs(),!0),changeAddressesBytes:g,feeState:s,fromAddressesBytes:m,memo:a?.memo,minIssuanceTime:a?.minIssuanceTime,validatorTxId:t,auth:r,autoCompoundRewardShares:o,period:n},this.provider.getContext())}createBlockchain({utxoSet:e,subnetId:s,chainName:t,vmID:r,fxIds:o,genesisData:n,subnetAuth:i,feeState:a,options:m,fromAddresses:h}){const g=u(e.getUTXOs(),!0),A=(h??this.getAddresses("P")).map((e=>l(e)[2])),c=l(this.getChangeAddress("P"))[2],f=m?.changeAddresses??[c];return p(a),d.newCreateChainTx({chainName:t,feeState:a,fromAddressesBytes:A,fxIds:o,genesisData:n,subnetAuth:i,subnetId:s,utxos:g,vmId:r,changeAddressesBytes:f},this.provider.getContext())}createSubnet({utxoSet:e,rewardAddresses:s,feeState:t,fromAddresses:r,options:o,threshold:n,locktime:i}){const a=u(e.getUTXOs(),!0),m=(r??this.getAddresses("P")).map((e=>l(e)[2])),h=l(this.getChangeAddress("P"))[2],g=o?.changeAddresses??[h],A=s.map((e=>l(e)[2]));return p(t),d.newCreateSubnetTx({fromAddressesBytes:m,changeAddressesBytes:g,utxos:a,minIssuanceTime:o?.minIssuanceTime,memo:o?.memo,feeState:t,threshold:n,locktime:i,subnetOwners:A},this.provider.getContext())}addSubnetValidator({utxoSet:e,nodeId:s,start:t,end:r,weight:o,subnetId:n,subnetAuth:i,feeState:a,fromAddresses:m,options:h}){const g=u(e.getUTXOs(),!0),A=(m??this.getAddresses("P")).map((e=>l(e)[2])),c=l(this.getChangeAddress("P"))[2],f=h?.changeAddresses??[c];return p(a),d.newAddSubnetValidatorTx({changeAddressesBytes:f,fromAddressesBytes:A,utxos:g,minIssuanceTime:h?.minIssuanceTime,memo:h?.memo,nodeId:s,start:t,end:r,weight:o,subnetId:n,subnetAuth:i,feeState:a},this.provider.getContext())}addPermissionlessValidator({utxoSet:e,nodeId:s,start:t,end:r,weight:o,subnetId:n,shares:i,feeState:a,fromAddresses:h,rewardAddresses:u,delegatorRewardAddresses:g,publicKey:c,signature:f,options:x,threshold:T,locktime:I,stakingAssetId:C}){const v=A(e.getUTXOs()),S=(h??this.getAddresses("P")).map((e=>l(e)[2])),w=(u??[this.getCurrentAddress("P")]).map((e=>l(e)[2])),b=(g??[this.getCurrentAddress("P")]).map((e=>l(e)[2]));if(!(n!==m.PrimaryNetworkID.toString()||c&&f))throw new Error("Must provide public key and signature for primary subnet.");const P=l(this.getChangeAddress("P"))[2],B=x?.changeAddresses??[P];return p(a),d.newAddPermissionlessValidatorTx({fromAddressesBytes:S,delegatorRewardsOwner:b,utxos:v,minIssuanceTime:x?.minIssuanceTime,memo:x?.memo,changeAddressesBytes:B,nodeId:s,start:t,end:r,weight:o,subnetId:n,shares:i,feeState:a,publicKey:c,rewardAddresses:w,signature:f,locktime:I,threshold:T,stakingAssetId:C},this.provider.getContext())}addPermissionlessDelegator({utxoSet:e,nodeId:s,start:r,end:o,weight:n,subnetId:i,fromAddresses:a,rewardAddresses:m,options:h,locktime:u,feeState:g,threshold:c,stakingAssetId:f,additionalOutputs:x}){const T=A(e.getUTXOs()),I=(a??this.getAddresses("P")).map((e=>l(e)[2])),C=(m??[this.getCurrentAddress("P")]).map((e=>l(e)[2])),v=l(this.getChangeAddress("P"))[2],S=h?.changeAddresses??[v],w=this.provider.getContext();return p(g),d.newAddPermissionlessDelegatorTx({fromAddressesBytes:I,utxos:T,minIssuanceTime:h?.minIssuanceTime,memo:h?.memo,changeAddressesBytes:S,nodeId:s,start:r,end:o,weight:n,subnetId:i,rewardAddresses:C,locktime:u,stakingAssetId:f,threshold:c,feeState:g,additionalOutputs:x?.map((e=>t.fromNative(e.assetId??w.avaxAssetID,e.amount,e.addresses.map((e=>l(e)[2])),e.locktime,e.threshold)))},w)}removeSubnetValidator({utxoSet:e,nodeId:s,subnetId:t,subnetAuth:r,fromAddresses:o,feeState:n,options:i}){const a=u(e.getUTXOs(),!0),m=(o??this.getAddresses("P")).map((e=>l(e)[2])),h=l(this.getChangeAddress("P"))[2],g=i?.changeAddresses??[h];return p(n),d.newRemoveSubnetValidatorTx({changeAddressesBytes:g,fromAddressesBytes:m,utxos:a,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,nodeId:s,subnetId:t,subnetAuth:r,feeState:n},this.provider.getContext())}transferSubnetOwnershipTx({utxoSet:e,subnetId:s,subnetAuth:t,subnetOwners:r,feeState:o,fromAddresses:n,options:i,threshold:a,locktime:m}){const h=u(e.getUTXOs(),!0),g=(n??this.getAddresses("P")).map((e=>l(e)[2])),A=l(this.getChangeAddress("P"))[2],c=i?.changeAddresses??[A],f=r.map((e=>l(e)[2]));return p(o),d.newTransferSubnetOwnershipTx({changeAddressesBytes:c,fromAddressesBytes:g,utxos:h,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,subnetId:s,subnetAuth:t,subnetOwners:f,feeState:o,threshold:a,locktime:m},this.provider.getContext())}}export{x as WalletAbstract};
@@ -1 +1 @@
1
- import{WalletAbstract as e}from"./WalletAbstract.js";import{fromSeed as r}from"bip32";import{validateMnemonic as t,mnemonicToSeedSync as s}from"bip39";import{strip0x as i}from"@avalabs/core-utils-sdk";import"@avalabs/avalanchejs";import"../utils/populateCredential.js";import{SigningKey as o,computeAddress as a}from"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"@avalabs/glacier-sdk";import"xss";import{verifyDerivationPath as p}from"../utils/verifyDerivationPath.js";class n extends e{constructor(e,r,t){if(super(t),this.pubkeyXP=e,this.pubkeyC=r,33!==r.length||33!==e.length)throw new Error("Public key must be 33 byte compressed public key")}static fromPublicKey(e,r,t){const s=i(o.computePublicKey(e,!0)),a=i(o.computePublicKey(r,!0)),p=Buffer.from(s,"hex"),u=Buffer.from(a,"hex");return new n(p,u,t)}static fromMnemonic(e,i,o,a){if(!t(e))throw new Error("Invalid mnemonic phrase.");if(!p(o)||!p(i))throw new Error("Not valid derivation path. Make sure it is a valid BIP44 path starting with m/");const u=s(e),d=r(u),m=d.derivePath(o),h=d.derivePath(i);return n.fromPublicKey(h.publicKey,m.publicKey,a)}getAddress(e){const r="C"===e?this.pubkeyC:this.pubkeyXP;return this.provider.getAddress(r,e)}getAddressEVM(){return a(`0x${this.pubkeyC.toString("hex")}`)}getAddresses(e){return[this.getAddress(e)]}getChangeAddress(e){return this.getAddress(e)}getCurrentAddress(e){return this.getAddress(e)}}export{n as WalletVoid};
1
+ import{WalletAbstract as t}from"./WalletAbstract.js";import{fromSeed as e}from"bip32";import{validateMnemonic as r,mnemonicToSeedSync as s}from"bip39";import{strip0x as i}from"@avalabs/core-utils-sdk";import"../utils/addSignaturesToAvalancheTx.js";import"../utils/convertGlacierUtxo.js";import"../utils/createAvalancheEvmUnsignedTx.js";import"../utils/createAvalancheUnsignedTx.js";import"create-hash";import"@avalabs/avalanchejs";import"../utils/getAssetBalance.js";import"../utils/getUtxosByTxFromGlacier.js";import"../utils/parseAvalancheTx.js";import"../utils/populateCredential.js";import"../utils/txSizeLimits.js";import{verifyDerivationPath as o}from"../utils/verifyDerivationPath.js";import{SigningKey as a,computeAddress as n}from"ethers";class u extends t{constructor(t,e,r){if(super(r),this.pubkeyXP=t,this.pubkeyC=e,33!==e.length||33!==t.length)throw new Error("Public key must be 33 byte compressed public key")}static fromPublicKey(t,e,r){const s=i(a.computePublicKey(t,!0)),o=i(a.computePublicKey(e,!0)),n=Buffer.from(s,"hex"),l=Buffer.from(o,"hex");return new u(n,l,r)}static fromMnemonic(t,i,a,n){if(!r(t))throw new Error("Invalid mnemonic phrase.");if(!o(a)||!o(i))throw new Error("Not valid derivation path. Make sure it is a valid BIP44 path starting with m/");const l=s(t),m=e(l),p=m.derivePath(a),c=m.derivePath(i);return u.fromPublicKey(c.publicKey,p.publicKey,n)}getAddress(t){const e="C"===t?this.pubkeyC:this.pubkeyXP;return this.provider.getAddress(e,t)}getAddressEVM(){return n(`0x${this.pubkeyC.toString("hex")}`)}getAddresses(t){return[this.getAddress(t)]}getChangeAddress(t){return this.getAddress(t)}getCurrentAddress(t){return this.getAddress(t)}}export{u as WalletVoid};
@@ -0,0 +1,16 @@
1
+ import { UnsignedTx } from '@avalabs/avalanchejs';
2
+ import { Signer, SignMessageRequest, SignTxRequest, SignTxBufferRequest } from '../models.js';
3
+
4
+ /**
5
+ * Ledger signer that can use multiple LedgerLive derivation paths for signing transactions.
6
+ */
7
+ declare class LedgerLiveSigner implements Signer {
8
+ #private;
9
+ private accountIndices;
10
+ constructor(accountIndices: number[]);
11
+ signMessage(request: SignMessageRequest): Promise<Buffer>;
12
+ signTx(txRequest: SignTxRequest): Promise<UnsignedTx>;
13
+ signTxBuffer(txRequest: SignTxBufferRequest): Promise<Buffer[]>;
14
+ }
15
+
16
+ export { LedgerLiveSigner };