@avalabs/core-wallets-sdk 3.1.0-alpha.47 → 3.1.0-alpha.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +16 -110
- package/esm/Avalanche/models.d.ts +3 -2
- package/esm/Avalanche/providers/AbstractProvider.js +1 -1
- package/esm/Avalanche/utils/addSignaturesToAvalancheTx.js +1 -1
- package/esm/Avalanche/utils/convertGlacierUtxo.d.ts +2 -1
- package/esm/Avalanche/utils/convertGlacierUtxo.js +1 -1
- package/esm/Avalanche/utils/createAvalancheEvmUnsignedTx.d.ts +1 -1
- package/esm/Avalanche/utils/createAvalancheEvmUnsignedTx.js +1 -1
- package/esm/Avalanche/utils/createAvalancheUnsignedTx.d.ts +1 -1
- package/esm/Avalanche/utils/createAvalancheUnsignedTx.js +1 -1
- package/esm/Avalanche/utils/getAssetBalance.d.ts +2 -1
- package/esm/Avalanche/utils/getChainAliasByChainId.js +1 -1
- package/esm/Avalanche/utils/getStakedAssetBalance.d.ts +2 -1
- package/esm/Avalanche/utils/getTxOutputAddresses.js +1 -1
- package/esm/Avalanche/utils/getUtxosByTxFromGlacier.js +1 -1
- package/esm/Avalanche/utils/parseAvalancheTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseAddPermissionlessDelegatorTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseAddPermissionlessValidatorTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseAddSubnetValidorTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseBaseTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseConvertSubnetToL1Tx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseCreateChainTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseCreateSubnetTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseDisableL1ValidatorTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseExportTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseImportTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseIncreaseL1ValidatorBalanceTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseRegisterL1ValidatorTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseRemoveSubnetValidatorTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseSetL1ValidatorWeightTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseTransferSubnetOwnershipTx.js +1 -1
- package/esm/Avalanche/utils/parsers/utils/chainIdToVm.js +1 -1
- package/esm/Avalanche/utils/populateCredential.js +1 -1
- package/esm/Avalanche/utils/txSizeLimits.js +1 -1
- package/esm/Avalanche/wallets/AddressWallet.js +1 -1
- package/esm/Avalanche/wallets/SimpleSigner.js +1 -1
- package/esm/Avalanche/wallets/StaticSigner.js +1 -1
- package/esm/Avalanche/wallets/TxBuilderTypes.d.ts +1 -1
- package/esm/Avalanche/wallets/WalletAbstract.js +1 -1
- package/esm/Avalanche/wallets/WalletVoid.js +1 -1
- package/esm/Avalanche/wallets/ledger/LedgerSigner.js +1 -1
- package/esm/Avalanche/wallets/ledger/SimpleLedgerSigner.js +1 -1
- package/esm/Avalanche/wallets/ledger/models.d.ts +1 -1
- package/esm/Avalanche/wallets/legacy/LedgerWallet.js +1 -1
- package/esm/Avalanche/wallets/legacy/MnemonicWallet.js +1 -1
- package/esm/Avalanche/wallets/legacy/MnemonicWalletVoid.js +1 -1
- package/esm/Avalanche/wallets/models.d.ts +1 -1
- package/esm/BitcoinVM/index.d.ts +5 -0
- package/esm/BitcoinVM/index.js +1 -0
- package/esm/BitcoinVM/models.d.ts +1 -1
- package/esm/BitcoinVM/utils/getBech32AddressFromXPub.js +1 -1
- package/esm/BitcoinVM/wallets/BitcoinWallet.js +1 -1
- package/esm/BitcoinVM/wallets/BitcoinWalletLedger.js +1 -1
- package/esm/BitcoinVM/wallets/models.d.ts +1 -1
- package/esm/EVM/LedgerSigner.js +1 -1
- package/esm/EVM/utils/blockPolling.js +1 -1
- package/esm/EVM/utils/getWalletFromMnemonic.js +1 -1
- package/esm/SolanaVM/utils/solanaProvider.d.ts +2 -1
- package/esm/SolanaVM/utils/transferSol.js +1 -1
- package/esm/SolanaVM/utils/transferToken.d.ts +4 -2
- package/esm/SolanaVM/utils/transferToken.js +1 -1
- package/esm/SolanaVM/wallets/SolanaLedgerSigner.js +1 -1
- package/esm/abis/erc20.abi.js +1 -0
- package/esm/index.d.ts +20 -20
- package/esm/index.js +1 -1
- package/package.json +17 -7
- package/dist/index.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as t,avmSerial as
|
|
1
|
+
import{pvmSerial as t,avmSerial as a,evmSerial as o}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";import s from"./utils/chainIdToVm.js";import{getTransferableInputAmount as r}from"./utils/getTransferableAmount.js";var m=m=>t.isImportTx(m)||a.isImportTx(m)||o.isImportTx(m)?o.isImportTx(m)?({feeData:t,assetId:a})=>({type:e.Import,chain:m.getVM(),source:s(m.sourceChain.value()),amount:r(m.importedInputs,a),...t}):({feeData:t,assetId:a})=>({type:e.Import,chain:m.getVM(),source:s(m.sourceChain.value()),amount:r(m.ins,a),...t}):null;export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";
|
|
1
|
+
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";var 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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";
|
|
1
|
+
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";var l=l=>a.isRegisterL1ValidatorTx(l)?({feeData:a})=>({type:e.RegisterL1Validator,chain:l.getVM(),balance:l.balance.value(),...a}):null;export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as
|
|
1
|
+
import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as a}from"../../models.js";var t=t=>e.isRemoveSubnetValidatorTx(t)?({feeData:e})=>({type:a.RemoveSubnetValidator,chain:t.getVM(),nodeID:t.nodeId.toString(),subnetID:t.getSubnetID().value(),...e}):null;export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as t}from"../../models.js";
|
|
1
|
+
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as t}from"../../models.js";var e=e=>a.isSetL1ValidatorWeightTx(e)?({feeData:a})=>({type:t.SetL1ValidatorWeight,chain:e.getVM(),...a}):null;export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as
|
|
1
|
+
import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as r}from"../../models.js";var t=t=>e.isTransferSubnetOwnershipTx(t)?({feeData:e,provider:a})=>({type:r.TransferSubnetOwnership,chain:t.getVM(),subnetID:t.subnetID.value(),threshold:t.getSubnetOwners().threshold.value(),controlKeys:t.getSubnetOwners().addrs.map((e=>`P-${e.toString(a.getHrp())}`)),...e}):null;export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"
|
|
1
|
+
import"../../../providers/AbstractProvider.js";import"@avalabs/avalanchejs";import{MainnetContext as c,FujiContext as a,DevnetContext as i}from"../../../providers/constants.js";import"@avalabs/core-chains-sdk";var r=r=>{if([c.xBlockchainID,a.xBlockchainID,i.xBlockchainID].includes(r))return"AVM";if([c.pBlockchainID,a.pBlockchainID,i.pBlockchainID].includes(r))return"PVM";if([c.cBlockchainID,a.cBlockchainID,i.cBlockchainID].includes(r))return"EVM";throw new Error("Unknown chain id. Failed to get alias.")};export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{utils as e,secp256k1 as r,Signature as t}from"@avalabs/avalanchejs";import{sha256 as o}from"@noble/hashes/sha256";const{bufferToHex:n,packTx:s}=e,{publicKeyBytesToAddress:i,recoverPublicKey:a}=r,c=new t(new Uint8Array(Array(65).fill(0))),d=(e,r)=>{const t=Math.max(...e);if(!isFinite(t))throw new Error("Error while adding placeholder signatures for the provided indices.");const d=new Array(t+1).fill(c);if(!r)return d;const{unsignedTx:f,credentialIndex:l}=r,g=f.getCredentials()[l];if(!g)return d;const h=s(f.getTx()),u=o(h),p=c.toString();for(const e of g.toJSON()){if(e.toString()===p)continue;const r=a(u,e.toBytes()),t={toHex:()=>n(i(r))},o=f.addressMaps.getSigIndicesForAddress(t,!1)??[];for(const r of o)r[0]===l&&(d[r[1]]=e)}return d};export{c as emptySignature,d as populateCredential};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{utils as e}from"@avalabs/avalanchejs";import{getUnixNow as t}from"./getUnixNow.js";import{binarySearch as o}from"../../utils/binarySearch.js";import{sortUTXOsByAmountDescending as s,
|
|
1
|
+
import{utils as e}from"@avalabs/avalanchejs";import{getUnixNow as t}from"./getUnixNow.js";import{binarySearch as o}from"../../utils/binarySearch.js";import{sortUTXOsByAmountDescending as s,sortUTXOsStaking as r,sortUTXOsByAmountAscending as n}from"./sortUTXOs.js";const{getUtxoInfo:d}=e;var a=(e=>(e.ExportP="ExportP",e.ImportP="ImportP",e.AddPermissionlessValidator="AddPermissionlessValidator",e.AddPermissionlessDelegator="AddPermissionlessDelegator",e.BaseP="BaseP",e.ConsolidateP="ConsolidateP",e))(a||{});const i="NodeID-8TArWpFgH3sazEH8qP4gUjtGtFMvjw1aR",u="11111111111111111111111111111111LpoYY",c=(e,t)=>e.reduce(((e,t)=>e+d(t).amount),BigInt(0))-t,l={BaseP:{sortFunction:s,unsignedTxBuilder:(t,o,s)=>{const r=t.getProvider().getContext();return t.baseTX({utxoSet:new e.UtxoSet(o),chain:"P",toAddress:t.getCurrentAddress("P"),amountsPerAsset:{[r.avaxAssetID]:c(o,r.baseTxFee)},feeState:s})}},ConsolidateP:{sortFunction:n,unsignedTxBuilder:(t,o,s)=>{const r=t.getProvider().getContext();return t.consolidateP({utxoSet:new e.UtxoSet(o),amount:c(o,r.baseTxFee),feeState:s})}},AddPermissionlessValidator:{sortFunction:r,unsignedTxBuilder:(o,s,r)=>o.addPermissionlessValidator({utxoSet:new e.UtxoSet(s),nodeId:i,start:t(),end:t()+BigInt(1e3),weight:c(s,o.getProvider().getContext().baseTxFee),subnetId:u,shares:5,feeState:r,fromAddresses:void 0,rewardAddresses:void 0,delegatorRewardAddresses:void 0,publicKey:Buffer.from(e.hexToBuffer("0x8f95423f7142d00a48e1014a3de8d28907d420dc33b3052a6dee03a3f2941a393c2351e354704ca66a3fc29870282e15")),signature:Buffer.from(e.hexToBuffer("0x86a3ab4c45cfe31cae34c1d06f212434ac71b1be6cfe046c80c162e057614a94a5bc9f1ded1a7029deb0ba4ca7c9b71411e293438691be79c2dbf19d1ca7c3eadb9c756246fc5de5b7b89511c7d7302ae051d9e03d7991138299b5ed6a570a98"))})},AddPermissionlessDelegator:{sortFunction:r,unsignedTxBuilder:(o,s,r)=>o.addPermissionlessDelegator({utxoSet:new e.UtxoSet(s),nodeId:i,start:t(),end:t()+BigInt(1e3),weight:c(s,o.getProvider().getContext().baseTxFee),subnetId:u,feeState:r})},ExportP:{sortFunction:s,unsignedTxBuilder:(t,o,s)=>t.exportP({amount:c(o,t.getProvider().getContext().baseTxFee),utxoSet:new e.UtxoSet(o),destination:"X",feeState:s})},ImportP:{sortFunction:s,unsignedTxBuilder:(t,o,s)=>t.importP({utxoSet:new e.UtxoSet(o),sourceChain:"X",feeState:s})}},x=65536;function f({wallet:e,utxos:s,sizeSupportedTx:r,limit:n=65536,feeState:a}){const{sortFunction:i,unsignedTxBuilder:u}=l[r],c=t(),x=i(s.filter((e=>{const{locktime:t,stakeableLocktime:o}=d(e);return t<c&&(o<c||("AddPermissionlessDelegator"===r||"AddPermissionlessValidator"===r))}))),f=o(x,(t=>{try{return function(e){const t=e.getInputUtxos().reduce(((e,t)=>e+(8+65*d(t).threshold)),0);return 6+e.toBytes().length+t}(u(e,t,a))}catch(e){return console.log("Unable to estimate size of utxos",{e:e,utxos:t.map(d)}),n+1}}),n);return-1===f?[]:x.slice(0,f+1)}export{x as P_CHAIN_TX_SIZE_LIMIT,a as SizeSupportedTx,f as getMaximumUtxoSet};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{WalletAbstract as s}from"./WalletAbstract.js";import"
|
|
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"@avalabs/core-chains-sdk";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,a,i,d){if(super(d),this.addressC=s,this.addressCoreEth=t,this.xpAddresses=a,this.xpChangeAddress=i,a.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(a.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(i)}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};
|
|
@@ -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
|
|
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{getAddressDerivationPath as n}from"../../utils/getAddressDerivationPath.js";import"hdkey";import{DerivationPath as o}from"../../EVM/constants.js";import"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";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"@avalabs/core-chains-sdk";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'/0'");const d=c.derivePath(n(t,o.BIP44,"EVM"));this.signerNodeEVM=d,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 s=this.getAdditionalKeys(t,!1);if("AVM"===e){const e=this.getAdditionalKeys(i,!0);return[r.privateKey,...s,...e]}if("PVM"===e)return[r.privateKey,...s]}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/${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),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{
|
|
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"@avalabs/core-chains-sdk";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:v}=e,{addChecksum:c}=t;class u 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),v=m.derivePath(t);if(!l.privateKey||!v.privateKey)throw new Error("Failed to generate private keys.");return new u(l.privateKey,v.privateKey,r)}async signMessage(i){const e=o(i.message),t=this.getSigningKey(i.chain);return Buffer.from(c(await v(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{u as StaticSigner};
|
|
@@ -176,4 +176,4 @@ type TransferSubnetOwnershipTx = {
|
|
|
176
176
|
locktime?: bigint;
|
|
177
177
|
};
|
|
178
178
|
|
|
179
|
-
export { AddPermissionlessDelegator, AddPermissionlessValidator, AddSubnetValidator, BaseTx, ConsolidateP, ConvertSubnetToL1, CreateChain, CreateSubnet, DisableL1Validator, ExportP, ImportP, IncreaseL1ValidatorBalance, RegisterL1Validator, RemoveSubnetValidator, SetL1ValidatorWeight, TransferSubnetOwnershipTx };
|
|
179
|
+
export type { AddPermissionlessDelegator, AddPermissionlessValidator, AddSubnetValidator, BaseTx, ConsolidateP, ConvertSubnetToL1, CreateChain, CreateSubnet, DisableL1Validator, ExportP, ImportP, IncreaseL1ValidatorBalance, RegisterL1Validator, RemoveSubnetValidator, SetL1ValidatorWeight, TransferSubnetOwnershipTx };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{TransferableOutput as e,avm as s,pvm as t,evm as r,pvmSerial as d,utils as n,PChainOwner as o,L1Validator as i,networkIDs as a}from"@avalabs/avalanchejs";import"../utils/populateCredential.js";import"@avalabs/glacier-sdk";import{strip0x as m}from"@avalabs/core-utils-sdk";import"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"bip32";import{getUTXOsForAddresses as h}from"../utils/getAllUTXOs.js";import{getStakeForAddresses as g}from"../utils/getStakeForAddresses.js";import"bip39";import"xss";import{sortUTXOsByAmount as u,sortUTXOsByAmountAscending as A,sortUTXOsStaking as c}from"../utils/sortUTXOs.js";import"bip32-path";import{assertFeeStateProvided as p}from"../../utils/assertFeeStateProvided.js";const{parse:f,hexToBuffer:x}=n;class l{constructor(e){this.provider=e}setProvider(e){this.provider=e}getProvider(){return this.provider}async getUTXOs(e){const s=this.provider.getApi(e);return h(this.getAddresses(e),s)}async getStake(){const e=this.provider.getApiP();return g(this.getAddresses("P"),e)}async getAtomicUTXOs(e,s){if(e===s)throw new Error("Chain can not be the same as source chain.");const t=this.provider.getApi(e),r=this.provider.getChainID(s);return h(this.getAddresses(e),t,{sourceChain:r,addresses:[]})}async getNonce(){const e=this.getAddressEVM();return await this.provider.evmRpc.getTransactionCount(e)}exportX(t,r,d,n){n=n||this.getCurrentAddress(d);const o=f(n)[2],i=this.provider.getAvaxID(),a=e.fromNative(i,t,[o]),m=u(r.getUTXOs(),!0),h=this.provider.getChainID(d),g=this.getAddresses("X").map((e=>f(e)[2])),A=f(this.getChangeAddress("X"))[2];return s.newExportTx(this.provider.getContext(),h,g,m,[a],{threshold:1,changeAddresses:[A]})}importP({utxoSet:e,sourceChain:s,toAddress:r,threshold:d,feeState:n,locktime:o}){const i=this.provider.getChainID(s),a=this.getAddresses("P").map((e=>f(e)[2]));f(this.getChangeAddress("P"))[2],r=r||this.getCurrentAddress("P");const m=f(r)[2],h=e.getUTXOs();return p(n),t.newImportTx({fromAddressesBytes:a,utxos:h,toAddressesBytes:[m],sourceChainId:i,threshold:d,feeState:n,locktime:o},this.provider.getContext())}importX(e,t,r){const d=this.provider.getChainID(t),n=this.getAddresses("X").map((e=>f(e)[2])),o=f(this.getChangeAddress("X"))[2];r=r||this.getCurrentAddress("X");const i=f(r)[2];return s.newImportTx(this.provider.getContext(),d,e.getUTXOs(),[i],n,{changeAddresses:[o]})}importC(e,s,t,d,n){const o=this.provider.getChainID(s),i=this.getAddresses("C").map((e=>f(e)[2]));n=n||this.getAddressEVM();const a=Buffer.from(m(n),"hex");return r.newImportTxFromBaseFee(this.provider.getContext(),a,i,e.getUTXOs(),o,t,d)}exportC(e,s,t,d,n){const o=x(this.getAddressEVM()),i=this.provider.getChainID(s);n=n||this.getCurrentAddress(s);const a=f(n)[2],m=d/BigInt(1e9);return r.newExportTxFromBaseFee(this.provider.getContext(),m,e,i,o,[a],t)}exportP({amount:s,utxoSet:r,destination:d,feeState:n,toAddress:o}){o=o||this.getCurrentAddress(d);const i=f(o)[2],a=this.provider.getAvaxID(),m=e.fromNative(a,s,[i]),h=u(r.getUTXOs(),!0),g=this.provider.getChainID(d),A=this.getAddresses("P").map((e=>f(e)[2])),c=f(this.getChangeAddress("P"))[2];return p(n),t.newExportTx({changeAddressesBytes:[c],fromAddressesBytes:A,utxos:h,outputs:[m],destinationChainId:g,feeState:n},this.provider.getContext())}consolidateP({utxoSet:s,amount:r,feeState:d,toAddress:n,options:o}){const i=A(s.getUTXOs());n=n??this.getCurrentAddress("P");const a=f(n)[2],m=this.provider.getContext(),h=[e.fromNative(m.avaxAssetID,r,[a])],g=this.getAddresses("P").map((e=>f(e)[2])),u=f(this.getChangeAddress("P"))[2],c=o?.changeAddresses??[u];return p(d),t.newBaseTx({changeAddressesBytes:c,fromAddressesBytes:g,utxos:i,outputs:h,minIssuanceTime:o?.minIssuanceTime,memo:o?.memo,feeState:d},m)}baseTX({utxoSet:r,chain:d,toAddress:n,amountsPerAsset:o,feeState:i,options:a,fromAddresses:m}){const[h,g,A]=f(n);if(h!==d||g!==this.provider.getHrp())throw new Error(`Invalid recipient address "${n}"`);const c=Object.entries(o).map((([s,t])=>e.fromNative(s,t,[A]))),x=u(r.getUTXOs(),!0),l=(m??this.getAddresses(d)).map((e=>f(e)[2])),I=f(this.getChangeAddress("P"))[2],T=a?.changeAddresses??[I];return"X"===d?s.newBaseTx(this.provider.getContext(),l,x,c,a):(p(i),t.newBaseTx({changeAddressesBytes:T,fromAddressesBytes:l,utxos:x,outputs:c,minIssuanceTime:a?.minIssuanceTime,memo:a?.memo,feeState:i},this.provider.getContext()))}convertSubnetToL1({utxoSet:e,chainId:s,subnetId:r,subnetAuth:a,feeState:m,address:h,validators:g,options:A,fromAddresses:c}){const p=(c??this.getAddresses("P")).map((e=>f(e)[2])),x=f(this.getChangeAddress("P"))[2],l=A?.changeAddresses??[x],I=g.map((({nodeId:e,pubKey:s,signature:t,balance:r,weight:a,deactivationOwner:m,remainingBalanceOwner:h})=>{const g=new d.ProofOfPossession(Uint8Array.from(n.hexToBuffer(s)),Uint8Array.from(n.hexToBuffer(t))),u=o.fromNative(h.addresses.map((e=>f(e)[2])),h.threshold??1),A=o.fromNative(m.addresses.map((e=>f(e)[2])),m.threshold??1);return i.fromNative(e,a,r,g,u,A)}));return t.newConvertSubnetToL1Tx({changeAddressesBytes:l,validators:I,fromAddressesBytes:p,address:f(h)[2],chainId:s,subnetId:r,subnetAuth:a,feeState:m,utxos:u(e.getUTXOs(),!0)},this.provider.getContext())}registerL1Validator({utxoSet:e,balance:s,signature:r,message:d,feeState:o,fromAddresses:i,options:a}){const m=(i??this.getAddresses("P")).map((e=>f(e)[2])),h=f(this.getChangeAddress("P"))[2],g=a?.changeAddresses??[h];return t.newRegisterL1ValidatorTx({utxos:u(e.getUTXOs(),!0),balance:s,blsSignature:Uint8Array.from(n.hexToBuffer(r)),changeAddressesBytes:g,feeState:o,fromAddressesBytes:m,memo:a?.memo,message:Uint8Array.from(n.hexToBuffer(d)),minIssuanceTime:a?.minIssuanceTime},this.provider.getContext())}setL1ValidatorWeight({utxoSet:e,feeState:s,message:r,options:d,fromAddresses:o}){const i=(o??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],m=d?.changeAddresses??[a];return t.newSetL1ValidatorWeightTx({utxos:u(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:s,fromAddressesBytes:i,memo:d?.memo,message:Uint8Array.from(n.hexToBuffer(r)),minIssuanceTime:d?.minIssuanceTime},this.provider.getContext())}disableL1Validator({utxoSet:e,feeState:s,options:r,fromAddresses:d,disableAuth:n,validationId:o}){const i=(d??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],m=r?.changeAddresses??[a];return t.newDisableL1ValidatorTx({disableAuth:n,validationId:o,utxos:u(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:s,fromAddressesBytes:i,memo:r?.memo,minIssuanceTime:r?.minIssuanceTime},this.provider.getContext())}increaseL1ValidatorBalance({utxoSet:e,feeState:s,options:r,fromAddresses:d,balance:n,validationId:o}){const i=(d??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],m=r?.changeAddresses??[a];return t.newIncreaseL1ValidatorBalanceTx({balance:n,validationId:o,utxos:u(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:s,fromAddressesBytes:i,memo:r?.memo,minIssuanceTime:r?.minIssuanceTime},this.provider.getContext())}createBlockchain({utxoSet:e,subnetId:s,chainName:r,vmID:d,fxIds:n,genesisData:o,subnetAuth:i,feeState:a,options:m,fromAddresses:h}){const g=u(e.getUTXOs(),!0),A=(h??this.getAddresses("P")).map((e=>f(e)[2])),c=f(this.getChangeAddress("P"))[2],x=m?.changeAddresses??[c];return p(a),t.newCreateChainTx({chainName:r,feeState:a,fromAddressesBytes:A,fxIds:n,genesisData:o,subnetAuth:i,subnetId:s,utxos:g,vmId:d,changeAddressesBytes:x},this.provider.getContext())}createSubnet({utxoSet:e,rewardAddresses:s,feeState:r,fromAddresses:d,options:n,threshold:o,locktime:i}){const a=u(e.getUTXOs(),!0),m=(d??this.getAddresses("P")).map((e=>f(e)[2])),h=f(this.getChangeAddress("P"))[2],g=n?.changeAddresses??[h],A=s.map((e=>f(e)[2]));return p(r),t.newCreateSubnetTx({fromAddressesBytes:m,changeAddressesBytes:g,utxos:a,minIssuanceTime:n?.minIssuanceTime,memo:n?.memo,feeState:r,threshold:o,locktime:i,subnetOwners:A},this.provider.getContext())}addSubnetValidator({utxoSet:e,nodeId:s,start:r,end:d,weight:n,subnetId:o,subnetAuth:i,feeState:a,fromAddresses:m,options:h}){const g=u(e.getUTXOs(),!0),A=(m??this.getAddresses("P")).map((e=>f(e)[2])),c=f(this.getChangeAddress("P"))[2],x=h?.changeAddresses??[c];return p(a),t.newAddSubnetValidatorTx({changeAddressesBytes:x,fromAddressesBytes:A,utxos:g,minIssuanceTime:h?.minIssuanceTime,memo:h?.memo,nodeId:s,start:r,end:d,weight:n,subnetId:o,subnetAuth:i,feeState:a},this.provider.getContext())}addPermissionlessValidator({utxoSet:e,nodeId:s,start:r,end:d,weight:n,subnetId:o,shares:i,feeState:m,fromAddresses:h,rewardAddresses:g,delegatorRewardAddresses:u,publicKey:A,signature:x,options:l,threshold:I,locktime:T,stakingAssetId:v}){const C=c(e.getUTXOs()),S=(h??this.getAddresses("P")).map((e=>f(e)[2])),b=(g??[this.getCurrentAddress("P")]).map((e=>f(e)[2])),w=(u??[this.getCurrentAddress("P")]).map((e=>f(e)[2]));if(!(o!==a.PrimaryNetworkID.toString()||A&&x))throw new Error("Must provide public key and signature for primary subnet.");const P=f(this.getChangeAddress("P"))[2],B=l?.changeAddresses??[P];return p(m),t.newAddPermissionlessValidatorTx({fromAddressesBytes:S,delegatorRewardsOwner:w,utxos:C,minIssuanceTime:l?.minIssuanceTime,memo:l?.memo,changeAddressesBytes:B,nodeId:s,start:r,end:d,weight:n,subnetId:o,shares:i,feeState:m,publicKey:A,rewardAddresses:b,signature:x,locktime:T,threshold:I,stakingAssetId:v},this.provider.getContext())}addPermissionlessDelegator({utxoSet:e,nodeId:s,start:r,end:d,weight:n,subnetId:o,fromAddresses:i,rewardAddresses:a,options:m,locktime:h,feeState:g,threshold:u,stakingAssetId:A}){const x=c(e.getUTXOs()),l=(i??this.getAddresses("P")).map((e=>f(e)[2])),I=(a??[this.getCurrentAddress("P")]).map((e=>f(e)[2])),T=f(this.getChangeAddress("P"))[2],v=m?.changeAddresses??[T];return p(g),t.newAddPermissionlessDelegatorTx({fromAddressesBytes:l,utxos:x,minIssuanceTime:m?.minIssuanceTime,memo:m?.memo,changeAddressesBytes:v,nodeId:s,start:r,end:d,weight:n,subnetId:o,rewardAddresses:I,locktime:h,stakingAssetId:A,threshold:u,feeState:g},this.provider.getContext())}removeSubnetValidator({utxoSet:e,nodeId:s,subnetId:r,subnetAuth:d,fromAddresses:n,feeState:o,options:i}){const a=u(e.getUTXOs(),!0),m=(n??this.getAddresses("P")).map((e=>f(e)[2])),h=f(this.getChangeAddress("P"))[2],g=i?.changeAddresses??[h];return p(o),t.newRemoveSubnetValidatorTx({changeAddressesBytes:g,fromAddressesBytes:m,utxos:a,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,nodeId:s,subnetId:r,subnetAuth:d,feeState:o},this.provider.getContext())}transferSubnetOwnershipTx({utxoSet:e,subnetId:s,subnetAuth:r,subnetOwners:d,feeState:n,fromAddresses:o,options:i,threshold:a,locktime:m}){const h=u(e.getUTXOs(),!0),g=(o??this.getAddresses("P")).map((e=>f(e)[2])),A=f(this.getChangeAddress("P"))[2],c=i?.changeAddresses??[A],x=d.map((e=>f(e)[2]));return p(n),t.newTransferSubnetOwnershipTx({changeAddressesBytes:c,fromAddressesBytes:g,utxos:h,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,subnetId:s,subnetAuth:r,subnetOwners:x,feeState:n,threshold:a,locktime:m},this.provider.getContext())}}export{l as WalletAbstract};
|
|
1
|
+
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"@avalabs/core-chains-sdk";import{utils as s,TransferableOutput as t,avm as r,pvm as d,evm as n,pvmSerial as o,PChainOwner as i,L1Validator as a,networkIDs as m}from"@avalabs/avalanchejs";import{getStakeForAddresses as h}from"../utils/getStakeForAddresses.js";import"../utils/getUtxosByTxFromGlacier.js";import"bip39";import"../utils/parseAvalancheTx.js";import"../utils/populateCredential.js";import{sortUTXOsByAmount as g,sortUTXOsByAmountAscending as u,sortUTXOsStaking as A}from"../utils/sortUTXOs.js";import"../utils/txSizeLimits.js";import"bip32-path";import{strip0x as c}from"@avalabs/core-utils-sdk";import{assertFeeStateProvided as p}from"../../utils/assertFeeStateProvided.js";const{parse:f,hexToBuffer:x}=s;class l{constructor(e){this.provider=e}setProvider(e){this.provider=e}getProvider(){return this.provider}async getUTXOs(s){const t=this.provider.getApi(s);return e(this.getAddresses(s),t)}async getStake(){const e=this.provider.getApiP();return h(this.getAddresses("P"),e)}async getAtomicUTXOs(s,t){if(s===t)throw new Error("Chain can not be the same as source chain.");const r=this.provider.getApi(s),d=this.provider.getChainID(t);return e(this.getAddresses(s),r,{sourceChain:d,addresses:[]})}async getNonce(){const e=this.getAddressEVM();return await this.provider.evmRpc.getTransactionCount(e)}exportX(e,s,d,n){n=n||this.getCurrentAddress(d);const o=f(n)[2],i=this.provider.getAvaxID(),a=t.fromNative(i,e,[o]),m=g(s.getUTXOs(),!0),h=this.provider.getChainID(d),u=this.getAddresses("X").map((e=>f(e)[2])),A=f(this.getChangeAddress("X"))[2];return r.newExportTx(this.provider.getContext(),h,u,m,[a],{threshold:1,changeAddresses:[A]})}importP({utxoSet:e,sourceChain:s,toAddress:t,threshold:r,feeState:n,locktime:o}){const i=this.provider.getChainID(s),a=this.getAddresses("P").map((e=>f(e)[2]));f(this.getChangeAddress("P"))[2],t=t||this.getCurrentAddress("P");const m=f(t)[2],h=e.getUTXOs();return p(n),d.newImportTx({fromAddressesBytes:a,utxos:h,toAddressesBytes:[m],sourceChainId:i,threshold:r,feeState:n,locktime:o},this.provider.getContext())}importX(e,s,t){const d=this.provider.getChainID(s),n=this.getAddresses("X").map((e=>f(e)[2])),o=f(this.getChangeAddress("X"))[2];t=t||this.getCurrentAddress("X");const i=f(t)[2];return r.newImportTx(this.provider.getContext(),d,e.getUTXOs(),[i],n,{changeAddresses:[o]})}importC(e,s,t,r,d){const o=this.provider.getChainID(s),i=this.getAddresses("C").map((e=>f(e)[2]));d=d||this.getAddressEVM();const a=Buffer.from(c(d),"hex");return n.newImportTxFromBaseFee(this.provider.getContext(),a,i,e.getUTXOs(),o,t,r)}exportC(e,s,t,r,d){const o=x(this.getAddressEVM()),i=this.provider.getChainID(s);d=d||this.getCurrentAddress(s);const a=f(d)[2],m=r/BigInt(1e9);return n.newExportTxFromBaseFee(this.provider.getContext(),m,e,i,o,[a],t)}exportP({amount:e,utxoSet:s,destination:r,feeState:n,toAddress:o}){o=o||this.getCurrentAddress(r);const i=f(o)[2],a=this.provider.getAvaxID(),m=t.fromNative(a,e,[i]),h=g(s.getUTXOs(),!0),u=this.provider.getChainID(r),A=this.getAddresses("P").map((e=>f(e)[2])),c=f(this.getChangeAddress("P"))[2];return p(n),d.newExportTx({changeAddressesBytes:[c],fromAddressesBytes:A,utxos:h,outputs:[m],destinationChainId:u,feeState:n},this.provider.getContext())}consolidateP({utxoSet:e,amount:s,feeState:r,toAddress:n,options:o}){const i=u(e.getUTXOs());n=n??this.getCurrentAddress("P");const a=f(n)[2],m=this.provider.getContext(),h=[t.fromNative(m.avaxAssetID,s,[a])],g=this.getAddresses("P").map((e=>f(e)[2])),A=f(this.getChangeAddress("P"))[2],c=o?.changeAddresses??[A];return p(r),d.newBaseTx({changeAddressesBytes:c,fromAddressesBytes:g,utxos:i,outputs:h,minIssuanceTime:o?.minIssuanceTime,memo:o?.memo,feeState:r},m)}baseTX({utxoSet:e,chain:s,toAddress:n,amountsPerAsset:o,feeState:i,options:a,fromAddresses:m}){const[h,u,A]=f(n);if(h!==s||u!==this.provider.getHrp())throw new Error(`Invalid recipient address "${n}"`);const c=Object.entries(o).map((([e,s])=>t.fromNative(e,s,[A]))),x=g(e.getUTXOs(),!0),l=(m??this.getAddresses(s)).map((e=>f(e)[2])),T=f(this.getChangeAddress("P"))[2],I=a?.changeAddresses??[T];return"X"===s?r.newBaseTx(this.provider.getContext(),l,x,c,a):(p(i),d.newBaseTx({changeAddressesBytes:I,fromAddressesBytes:l,utxos:x,outputs:c,minIssuanceTime:a?.minIssuanceTime,memo:a?.memo,feeState:i},this.provider.getContext()))}convertSubnetToL1({utxoSet:e,chainId:t,subnetId:r,subnetAuth:n,feeState:m,address:h,validators:u,options:A,fromAddresses:c}){const p=(c??this.getAddresses("P")).map((e=>f(e)[2])),x=f(this.getChangeAddress("P"))[2],l=A?.changeAddresses??[x],T=u.map((({nodeId:e,pubKey:t,signature:r,balance:d,weight:n,deactivationOwner:m,remainingBalanceOwner:h})=>{const g=new o.ProofOfPossession(Uint8Array.from(s.hexToBuffer(t)),Uint8Array.from(s.hexToBuffer(r))),u=i.fromNative(h.addresses.map((e=>f(e)[2])),h.threshold??1),A=i.fromNative(m.addresses.map((e=>f(e)[2])),m.threshold??1);return a.fromNative(e,n,d,g,u,A)}));return d.newConvertSubnetToL1Tx({changeAddressesBytes:l,validators:T,fromAddressesBytes:p,address:f(h)[2],chainId:t,subnetId:r,subnetAuth:n,feeState:m,utxos:g(e.getUTXOs(),!0)},this.provider.getContext())}registerL1Validator({utxoSet:e,balance:t,signature:r,message:n,feeState:o,fromAddresses:i,options:a}){const m=(i??this.getAddresses("P")).map((e=>f(e)[2])),h=f(this.getChangeAddress("P"))[2],u=a?.changeAddresses??[h];return d.newRegisterL1ValidatorTx({utxos:g(e.getUTXOs(),!0),balance:t,blsSignature:Uint8Array.from(s.hexToBuffer(r)),changeAddressesBytes:u,feeState:o,fromAddressesBytes:m,memo:a?.memo,message:Uint8Array.from(s.hexToBuffer(n)),minIssuanceTime:a?.minIssuanceTime},this.provider.getContext())}setL1ValidatorWeight({utxoSet:e,feeState:t,message:r,options:n,fromAddresses:o}){const i=(o??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],m=n?.changeAddresses??[a];return d.newSetL1ValidatorWeightTx({utxos:g(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:t,fromAddressesBytes:i,memo:n?.memo,message:Uint8Array.from(s.hexToBuffer(r)),minIssuanceTime:n?.minIssuanceTime},this.provider.getContext())}disableL1Validator({utxoSet:e,feeState:s,options:t,fromAddresses:r,disableAuth:n,validationId:o}){const i=(r??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],m=t?.changeAddresses??[a];return d.newDisableL1ValidatorTx({disableAuth:n,validationId:o,utxos:g(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:s,fromAddressesBytes:i,memo:t?.memo,minIssuanceTime:t?.minIssuanceTime},this.provider.getContext())}increaseL1ValidatorBalance({utxoSet:e,feeState:s,options:t,fromAddresses:r,balance:n,validationId:o}){const i=(r??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],m=t?.changeAddresses??[a];return d.newIncreaseL1ValidatorBalanceTx({balance:n,validationId:o,utxos:g(e.getUTXOs(),!0),changeAddressesBytes:m,feeState:s,fromAddressesBytes:i,memo:t?.memo,minIssuanceTime:t?.minIssuanceTime},this.provider.getContext())}createBlockchain({utxoSet:e,subnetId:s,chainName:t,vmID:r,fxIds:n,genesisData:o,subnetAuth:i,feeState:a,options:m,fromAddresses:h}){const u=g(e.getUTXOs(),!0),A=(h??this.getAddresses("P")).map((e=>f(e)[2])),c=f(this.getChangeAddress("P"))[2],x=m?.changeAddresses??[c];return p(a),d.newCreateChainTx({chainName:t,feeState:a,fromAddressesBytes:A,fxIds:n,genesisData:o,subnetAuth:i,subnetId:s,utxos:u,vmId:r,changeAddressesBytes:x},this.provider.getContext())}createSubnet({utxoSet:e,rewardAddresses:s,feeState:t,fromAddresses:r,options:n,threshold:o,locktime:i}){const a=g(e.getUTXOs(),!0),m=(r??this.getAddresses("P")).map((e=>f(e)[2])),h=f(this.getChangeAddress("P"))[2],u=n?.changeAddresses??[h],A=s.map((e=>f(e)[2]));return p(t),d.newCreateSubnetTx({fromAddressesBytes:m,changeAddressesBytes:u,utxos:a,minIssuanceTime:n?.minIssuanceTime,memo:n?.memo,feeState:t,threshold:o,locktime:i,subnetOwners:A},this.provider.getContext())}addSubnetValidator({utxoSet:e,nodeId:s,start:t,end:r,weight:n,subnetId:o,subnetAuth:i,feeState:a,fromAddresses:m,options:h}){const u=g(e.getUTXOs(),!0),A=(m??this.getAddresses("P")).map((e=>f(e)[2])),c=f(this.getChangeAddress("P"))[2],x=h?.changeAddresses??[c];return p(a),d.newAddSubnetValidatorTx({changeAddressesBytes:x,fromAddressesBytes:A,utxos:u,minIssuanceTime:h?.minIssuanceTime,memo:h?.memo,nodeId:s,start:t,end:r,weight:n,subnetId:o,subnetAuth:i,feeState:a},this.provider.getContext())}addPermissionlessValidator({utxoSet:e,nodeId:s,start:t,end:r,weight:n,subnetId:o,shares:i,feeState:a,fromAddresses:h,rewardAddresses:g,delegatorRewardAddresses:u,publicKey:c,signature:x,options:l,threshold:T,locktime:I,stakingAssetId:v}){const C=A(e.getUTXOs()),S=(h??this.getAddresses("P")).map((e=>f(e)[2])),b=(g??[this.getCurrentAddress("P")]).map((e=>f(e)[2])),w=(u??[this.getCurrentAddress("P")]).map((e=>f(e)[2]));if(!(o!==m.PrimaryNetworkID.toString()||c&&x))throw new Error("Must provide public key and signature for primary subnet.");const P=f(this.getChangeAddress("P"))[2],B=l?.changeAddresses??[P];return p(a),d.newAddPermissionlessValidatorTx({fromAddressesBytes:S,delegatorRewardsOwner:w,utxos:C,minIssuanceTime:l?.minIssuanceTime,memo:l?.memo,changeAddressesBytes:B,nodeId:s,start:t,end:r,weight:n,subnetId:o,shares:i,feeState:a,publicKey:c,rewardAddresses:b,signature:x,locktime:I,threshold:T,stakingAssetId:v},this.provider.getContext())}addPermissionlessDelegator({utxoSet:e,nodeId:s,start:t,end:r,weight:n,subnetId:o,fromAddresses:i,rewardAddresses:a,options:m,locktime:h,feeState:g,threshold:u,stakingAssetId:c}){const x=A(e.getUTXOs()),l=(i??this.getAddresses("P")).map((e=>f(e)[2])),T=(a??[this.getCurrentAddress("P")]).map((e=>f(e)[2])),I=f(this.getChangeAddress("P"))[2],v=m?.changeAddresses??[I];return p(g),d.newAddPermissionlessDelegatorTx({fromAddressesBytes:l,utxos:x,minIssuanceTime:m?.minIssuanceTime,memo:m?.memo,changeAddressesBytes:v,nodeId:s,start:t,end:r,weight:n,subnetId:o,rewardAddresses:T,locktime:h,stakingAssetId:c,threshold:u,feeState:g},this.provider.getContext())}removeSubnetValidator({utxoSet:e,nodeId:s,subnetId:t,subnetAuth:r,fromAddresses:n,feeState:o,options:i}){const a=g(e.getUTXOs(),!0),m=(n??this.getAddresses("P")).map((e=>f(e)[2])),h=f(this.getChangeAddress("P"))[2],u=i?.changeAddresses??[h];return p(o),d.newRemoveSubnetValidatorTx({changeAddressesBytes:u,fromAddressesBytes:m,utxos:a,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,nodeId:s,subnetId:t,subnetAuth:r,feeState:o},this.provider.getContext())}transferSubnetOwnershipTx({utxoSet:e,subnetId:s,subnetAuth:t,subnetOwners:r,feeState:n,fromAddresses:o,options:i,threshold:a,locktime:m}){const h=g(e.getUTXOs(),!0),u=(o??this.getAddresses("P")).map((e=>f(e)[2])),A=f(this.getChangeAddress("P"))[2],c=i?.changeAddresses??[A],x=r.map((e=>f(e)[2]));return p(n),d.newTransferSubnetOwnershipTx({changeAddressesBytes:c,fromAddressesBytes:u,utxos:h,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,subnetId:s,subnetAuth:t,subnetOwners:x,feeState:n,threshold:a,locktime:m},this.provider.getContext())}}export{l as WalletAbstract};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{WalletAbstract as
|
|
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"@avalabs/core-chains-sdk";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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{WalletVoid as
|
|
1
|
+
import{WalletVoid as t}from"../WalletVoid.js";import{isObsidianApp as r}from"./isObsidianApp.js";import{ZondaxProvider as e}from"./ZondaxProvider.js";import i from"bip32-path";import o from"@ledgerhq/hw-app-eth";import{utils as s}from"@avalabs/avalanchejs";import"../../utils/addSignaturesToAvalancheTx.js";import"../../utils/convertGlacierUtxo.js";import"../../utils/createAvalancheEvmUnsignedTx.js";import"../../utils/createAvalancheUnsignedTx.js";import"create-hash";import"bip32";import"../../utils/getAssetBalance.js";import"@avalabs/core-chains-sdk";import"../../utils/getUtxosByTxFromGlacier.js";import"bip39";import"../../utils/parseAvalancheTx.js";import"../../utils/populateCredential.js";import"../../utils/txSizeLimits.js";import{verifyDerivationPath as a}from"../../utils/verifyDerivationPath.js";import{SigningKey as n}from"ethers";const{strip0x:p}=s;class u extends t{constructor(t,r,e,i,o){const p=s.strip0x(n.computePublicKey(t,!0)),u=s.strip0x(n.computePublicKey(e,!0));if(super(Buffer.from(p,"hex"),Buffer.from(u,"hex"),o),this.pathXP=r,this.pathC=i,!a(r)||!a(i))throw new Error("Invalid path configuration.")}static async fromTransport(t,e,i,s){if(await r(t))throw new Error("Ledger app not supported. Must be version >= 0.6.0");if(!a(e)||!a(i))throw new Error("Invalid path configuration.");const h=new o(t),c=await h.getAddress(i,!1),f=await h.getAddress(e,!1),l=Buffer.from(p(c.publicKey),"hex"),m=Buffer.from(p(f.publicKey),"hex"),g=Buffer.from(p(n.computePublicKey(l,!0)),"hex"),d=Buffer.from(p(n.computePublicKey(m,!0)),"hex");return new u(d,e,g,i,s)}async signMessage(t){throw new Error("not implemented")}getFullSignerPath(t){return"C"===t?this.pathC:this.pathXP}getPartialSignerPath(t){return this.getFullSignerPath(t).split("/").slice(4).join("/")}getAccountPath(t){return this.getFullSignerPath(t).split("/").slice(0,4).join("/")}async signTx(t){if(!t.transport)throw new Error("Ledger transport not provided");const r=t.tx,e=r.getVM(),i=Buffer.from(r.toBytes()),o="EVM"===e?"C":"X";return(await this.signTxBuffer({buffer:i,chain:o,transport:t.transport})).forEach((t=>{r.addSignature(t)})),r}async signTxBuffer(t){if(!t.transport)throw new Error("Ledger transport not provided");const r=i.fromString(this.getAccountPath(t.chain)),o=i.fromString(this.getPartialSignerPath(t.chain));return[...(await e.signTx(t.transport,t.buffer,r,[o],[o])).signatures.values()]}}export{u as LedgerSigner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{utils as t,EVMUnsignedTx as r,UnsignedTx as e}from"@avalabs/avalanchejs";import s from"bip32-path";import{getTxOutputAddresses as i}from"../../utils/getTxOutputAddresses.js";import{ZondaxProvider as n}from"./ZondaxProvider.js";import{fromBase58 as o}from"bip32";import"../../utils/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"@avalabs/core-chains-sdk";import"../../utils/getUtxosByTxFromGlacier.js";import"bip39";import"../../utils/parseAvalancheTx.js";import"../../utils/populateCredential.js";import"../../utils/txSizeLimits.js";const{parse:c}=t;class g{constructor(t,r,e){this.activeAccountIndex=t,this.provider=r,e&&(this.accountNode=o(e))}accountNode;reSerializeTx(t,s){return t instanceof r||"C"===s?r.fromJSON(JSON.stringify(t.toJSON())):e.fromJSON(JSON.stringify(t.toJSON()))}getChainAlias(t){return"EVM"===t.getVM()?"C":"X"}getAccountPath(t){switch(t){case"X":case"P":return"m/44'/9000'/0'";case"C":return"m/44'/60'/0'"}}getAddressOfPath(t,r){if(!this.accountNode)return null;const{publicKey:e}=this.accountNode.derivePath(t),s=this.provider.getAddress(e,r);return Buffer.from(c(s)[2]).toString("hex")}getAddressPathMap(t){const{tx:r,externalIndices:e,internalIndices:s}=t,i=this.getChainAlias(r),n=`0/${this.activeAccountIndex}`,o=new Map;if("C"===i||!this.accountNode)return o;const a=[n,...(e??[]).map((t=>`0/${t}`)),...(s??[]).map((t=>`1/${t}`))];for(const t of a){const r=this.getAddressOfPath(t,i);r&&o.set(r,t)}return o}getAddressBipPaths(t,r){return 0===r.size?[s.fromString(`0/${this.activeAccountIndex}`)]:t.reduce(((t,e)=>{const i=r.get(Buffer.from(e).toString("hex"));return i&&t.push(s.fromString(i)),t}),[])}async signTx(t){if(!t.transport)throw new Error("Ledger transport not provided");const r=this.getChainAlias(t.tx),e=this.reSerializeTx(t.tx,r),s=Buffer.from(e.toBytes()),n=this.getAddressPathMap(t),o=this.getAddressBipPaths(e.getAddresses(),n),a=this.getAddressBipPaths([...i(e)],n);return(await this.signTxBuffer({buffer:s,chain:r,transport:t.transport,signers:o,change:a})).forEach((t=>{e.addSignature(t)})),e}async signTxBuffer(t){if(!t.transport)throw new Error("Ledger transport not provided");if(!t.signers)throw new Error("Signers not provided");const r=t.change||[],e=s.fromString(this.getAccountPath(t.chain));return[...(await n.signTx(t.transport,t.buffer,e,t.signers,r)).signatures.values()]}async signMessage(t){if(!t.transport||!t.message)throw new Error("Unable to sign message. Incomplete or invalid request.");const r=t.signer||s.fromString(`0/${this.activeAccountIndex}`);if(2!=r.toPathArray().length)throw new Error("Given signer path must have a depth of 2. Ex. 0/0, 0/1");const e=a(t.message),i=(await n.signHash(t.transport,e,s.fromString(this.getAccountPath(t.chain)),[r])).signatures.get(r.toString(!0));if(!i)throw new Error("Failed to sign message.");return i}}export{g as SimpleLedgerSigner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MnemonicWalletVoid as r}from"./MnemonicWalletVoid.js";import{getAppEth as t}from"../../../EVM/utils/getAppEth.js";import{SigningKey as e}from"ethers";import{getAddressDerivationPath as s}from"../../../utils/getAddressDerivationPath.js";import{utils as
|
|
1
|
+
import{MnemonicWalletVoid as r}from"./MnemonicWalletVoid.js";import{getAppEth as t}from"../../../EVM/utils/getAppEth.js";import{SigningKey as e}from"ethers";import{getAddressDerivationPath as s}from"../../../utils/getAddressDerivationPath.js";import{utils as i}from"@avalabs/avalanchejs";import"hdkey";import{DerivationPath as n}from"../../../EVM/constants.js";import{fromPublicKey as o}from"bip32";import"bip39";import"bitcoinjs-lib";import{strip0x as a}from"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";import d from"bip32-path";import{isObsidianApp as p}from"../ledger/isObsidianApp.js";import{ZondaxProvider as f}from"../ledger/ZondaxProvider.js";import{getTxOutputAddresses as m}from"../../utils/getTxOutputAddresses.js";const{parse:c}=i;class g extends r{constructor(r,t,e){super(r,t,e)}getAdditionalAddressesByIndices(r,t,e){return"C"===e?[]:r.map((r=>{const s=this.getAddressAtIndex(r,t,e),[,,i]=c(s);return Buffer.from(i).toString("hex")}))}static async fromTransport(r,i){if(await p(r))throw new Error("Unsupported ledger app version. Must be >= 0.6.0");const d=t(r),m=await f.getXPUB(r,g.getAccountPath("X")),c=o(m.pubKey,m.chainCode),h=s(0,n.BIP44,"EVM"),u=await d.getAddress(h,!1),l=e.computePublicKey(Buffer.from(u.publicKey,"hex"),!0),w=Buffer.from(a(l),"hex");return new g(c.toBase58(),w,i)}static getAccountPath(r){switch(r){case"P":case"X":return"m/44'/9000'/0'";case"C":return"m/44'/60'/0'"}}async signMessage(r){throw new Error("not implemented")}filterOwnedAddresses(r,t,e){const s=this.getInternalRawAddresses().map((r=>r.toString("hex"))),i=this.getExternalRawAddresses().map((r=>r.toString("hex"))),n=new Set([...s,...e??[]]),o=new Set([...i,...t??[]]),a=new Set;return r.forEach((r=>{const t=r.toString("hex");if(n.has(t)){const r=[...n].indexOf(t);a.add(`1/${r}`)}else if(o.has(t)){const r=[...o].indexOf(t);a.add(`0/${r}`)}})),a}async signTx(r){if(!r.transport)throw new Error("Ledger transport not provided");const{tx:t,externalIndices:e,internalIndices:s}=r,i=t.getVM(),n=Buffer.from(t.toBytes()),o="EVM"===i?"C":"X",a=t.getAddresses().map((r=>Buffer.from(r))),p=this.getAdditionalAddressesByIndices(e??[],!1,o),f=this.getAdditionalAddressesByIndices(s??[],!0,o),c=[...this.filterOwnedAddresses(a,p,f).values()].map((r=>d.fromString(r))),g=[...m(t)].map((r=>Buffer.from(r))),h=[...this.filterOwnedAddresses(g).values()].map((r=>d.fromString(r)));return(await this.signTxBuffer({buffer:n,chain:o,transport:r.transport,signers:c,change:h})).forEach((r=>{t.addSignature(r)})),t}async signTxBuffer(r){if(!r.transport)throw new Error("Ledger transport not provided");if(!r.signers)throw new Error("Signers not provided");const t=r.change||[],e=d.fromString(g.getAccountPath(r.chain));return[...(await f.signTx(r.transport,r.buffer,e,r.signers,t)).signatures.values()]}}export{g as LedgerWallet};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MnemonicWalletVoid as e}from"./MnemonicWalletVoid.js";import{
|
|
1
|
+
import{MnemonicWalletVoid as e}from"./MnemonicWalletVoid.js";import{utils as t,addTxSignatures as r}from"@avalabs/avalanchejs";import{validateMnemonic as i,mnemonicToSeedSync as n}from"bip39";import{fromBase58 as o,fromSeed as s}from"bip32";import"@ledgerhq/hw-app-eth";import{SigningKey as a}from"ethers";import{getAddressDerivationPath as c}from"../../../utils/getAddressDerivationPath.js";import"hdkey";import{DerivationPath as h}from"../../../EVM/constants.js";import"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";const{strip0x:p}=t;class v extends e{constructor(e,t,r){const i=o(e).neutered(),n=new a(t),s=Buffer.from(p(n.compressedPublicKey),"hex");super(i.toBase58(),s,r),this.evmPrivKey=t,this.accountNode=o(e)}accountNode;static fromMnemonic(e,t){if(!i(e))throw new Error("Invalid mnemonic phrase.");const r=n(e),o=s(r),a=o.derivePath("m/44'/9000'/0'"),p=o.derivePath(c(0,h.BIP44,"EVM"));if(!p.privateKey)throw new Error("Unable to derive EVM private key.");return new v(a.toBase58(),p.privateKey,t)}async signTx(e){const t=this.getSigningKeys(e);return await r({unsignedTx:e.tx,privateKeys:t}),e.tx}getExternalPrivateKeys(e){const t=[];for(let e=0;e<=this.externalIndex;e++){const r=this.accountNode.derivePath(`0/${e}`);if(!r.privateKey)throw new Error("Unable to get private key.");t.push(r.privateKey)}const r=(e??[]).reduce(((e,t)=>{if(t>this.externalIndex){const r=this.accountNode.derivePath(`0/${t}`);if(!r.privateKey)throw new Error("Unable to get private key.");e.push(r.privateKey)}return e}),[]);return[...t,...r]}getInternalPrivateKeys(e){const t=[];for(let e=0;e<=this.internalIndex;e++){const r=this.accountNode.derivePath(`1/${e}`);if(!r.privateKey)throw new Error("Unable to get private key.");t.push(r.privateKey)}const r=(e??[]).reduce(((e,t)=>{if(t>this.internalIndex){const r=this.accountNode.derivePath(`1/${t}`);if(!r.privateKey)throw new Error("Unable to get private key.");e.push(r.privateKey)}return e}),[]);return[...t,...r]}getSigningKeys(e){const{tx:t,externalIndices:r,internalIndices:i}=e,n=t.getVM();return"AVM"===n?[...this.getInternalPrivateKeys(i),...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")}}export{v as MnemonicWallet};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fromBase58 as e,fromSeed as t}from"bip32";import{validateMnemonic as r,mnemonicToSeedSync as s}from"bip39";import{WalletVoid as n}from"../WalletVoid.js";import{WalletAbstract as d}from"../WalletAbstract.js";import"@ledgerhq/hw-app-eth";import"ethers";import{getAddressDerivationPath as i}from"../../../utils/getAddressDerivationPath.js";import{utils as a}from"@avalabs/avalanchejs";import"hdkey";import
|
|
1
|
+
import{fromBase58 as e,fromSeed as t}from"bip32";import{validateMnemonic as r,mnemonicToSeedSync as s}from"bip39";import{WalletVoid as n}from"../WalletVoid.js";import{WalletAbstract as d}from"../WalletAbstract.js";import"@ledgerhq/hw-app-eth";import"ethers";import{getAddressDerivationPath as i}from"../../../utils/getAddressDerivationPath.js";import{utils as a}from"@avalabs/avalanchejs";import"hdkey";import{DerivationPath as o}from"../../../EVM/constants.js";import"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";const{parse:h}=a;class l extends d{constructor(t,r,s){super(s),this.avmXpub=t,this.accountNode=e(t),this.evmWallet=new n(r,r,s)}accountNode;evmWallet;externalIndex=0;internalIndex=0;pubkeyCache={};static fromMnemonic(e,n){if(!r(e))throw new Error("Invalid mnemonic phrase.");const d=s(e),a=t(d),h=a.derivePath("m/44'/9000'/0'").neutered(),m=a.derivePath(i(0,o.BIP44,"EVM")).neutered();return new l(h.toBase58(),m.publicKey,n)}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(h(e)[2])))}getExternalRawAddresses(){return this.getExternalAddresses("X").map((e=>Buffer.from(h(e)[2])))}getRawAddressC(){return Buffer.from(h(this.getCurrentAddress("C"))[2])}}export{l as MnemonicWalletVoid};
|
|
@@ -32,4 +32,4 @@ interface LedgerGetXpubResponse {
|
|
|
32
32
|
chain_code: Buffer;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export { LedgerGetXpubResponse, SignMessageRequest, SignTxBufferRequest, SignTxRequest, Signer };
|
|
35
|
+
export type { LedgerGetXpubResponse, SignMessageRequest, SignTxBufferRequest, SignTxRequest, Signer };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{networks as r}from"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import"coinselect";import"@ledgerhq/hw-app-eth";import"ethers";import"@solana/kit";import"@solana-program/system";import"@solana-program/token";import"@ledgerhq/hw-app-solana";import"bip39";import"@noble/curves/ed25519";import"@scure/base";import"micro-key-producer/slip10.js";import"@avalabs/avalanchejs";import"hdkey";import"bip32";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";import"ledger-bitcoin";import"@ledgerhq/hw-app-btc/lib/bip32";const o=r;export{o as BtcNetworks};
|
|
@@ -74,4 +74,4 @@ interface BitcoinTx {
|
|
|
74
74
|
}[];
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
export { BitcoinHistoryTx, BitcoinInputUTXO, BitcoinInputUTXOWithOptionalScript, BitcoinLedgerInputUTXO, BitcoinOutputUTXO, BitcoinTx };
|
|
77
|
+
export type { BitcoinHistoryTx, BitcoinInputUTXO, BitcoinInputUTXOWithOptionalScript, BitcoinLedgerInputUTXO, BitcoinOutputUTXO, BitcoinTx };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"@ledgerhq/hw-app-eth";import"ethers";import"@solana/kit";import"@solana-program/system";import"@solana-program/token";import"@ledgerhq/hw-app-solana";import"bip39";import"@noble/curves/ed25519";import"@scure/base";import"micro-key-producer/slip10.js";import"@avalabs/avalanchejs";import"hdkey";import"
|
|
1
|
+
import"@ledgerhq/hw-app-eth";import"ethers";import"@solana/kit";import"@solana-program/system";import"@solana-program/token";import"@ledgerhq/hw-app-solana";import"bip39";import"@noble/curves/ed25519";import"@scure/base";import"micro-key-producer/slip10.js";import"@avalabs/avalanchejs";import"hdkey";import"bip32";import{getAddressPublicKeyFromXPub as r}from"../../EVM/utils/getAddressPublicKeyFromXPub.js";import{getBech32Address as o}from"./getBech32Address.js";import"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";function t(t,e,p){const i=r(t,e);return o(i,p)}export{t as getBech32AddressFromXPub};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ECPair as t}from"bitcoinjs-lib";import{BitcoinWalletAbstract as r}from"./BitcoinWalletAbstract.js";import{createPsbt as e}from"../utils/createPsbt.js";import"coinselect";import"@ledgerhq/hw-app-eth";import"ethers";import{getAddressDerivationPath as i}from"../../utils/getAddressDerivationPath.js";import"@avalabs/avalanchejs";import"hdkey";import
|
|
1
|
+
import{ECPair as t}from"bitcoinjs-lib";import{BitcoinWalletAbstract as r}from"./BitcoinWalletAbstract.js";import{createPsbt as e}from"../utils/createPsbt.js";import"coinselect";import"@ledgerhq/hw-app-eth";import"ethers";import{getAddressDerivationPath as i}from"../../utils/getAddressDerivationPath.js";import"@avalabs/avalanchejs";import"hdkey";import{DerivationPath as o}from"../../EVM/constants.js";import{fromSeed as s}from"bip32";import{validateMnemonic as n,mnemonicToSeed as a}from"bip39";import"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";import"ledger-bitcoin";import"@ledgerhq/hw-app-btc/lib/bip32";class p extends r{keypair;constructor(r,e){const i=t.fromPrivateKey(r);super(i.publicKey,e),this.keypair=i}static async fromMnemonic(t,r,e,m=o.BIP44){if(r<0)throw new Error("Account index must be >= 0");if(!n(t))throw new Error("Invalid mnemonic phrase.");const l=await a(t),c=s(l),h=i(r,m,"EVM"),f=c.derivePath(h);if(!f.privateKey)throw new Error("Unable to derive private key from the given mnemonic.");return new p(f.privateKey,e)}signTx(t,r){const i=e(t,r,this.provider.getNetwork());return Promise.resolve(this.signPsbt(i))}static fromEthersWallet(t,r){const e=t.privateKey;if(!e)throw new Error("Unable to get private key from ethers wallet.");const i=Buffer.from(e.substring(2),"hex");return new p(i,r)}signPsbt(t){return t.signAllInputs(this.keypair),t.validateSignaturesOfAllInputs(),t.finalizeAllInputs(),t.extractTransaction()}}export{p as BitcoinWallet};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BitcoinWalletAbstract as t}from"./BitcoinWalletAbstract.js";import r from"ledger-bitcoin";import"bitcoinjs-lib";import"coinselect";import"@ledgerhq/hw-app-eth";import"ethers";import"@solana/kit";import"@solana-program/system";import"@solana-program/token";import"@ledgerhq/hw-app-solana";import"bip39";import"@noble/curves/ed25519";import"@scure/base";import"micro-key-producer/slip10.js";import"@avalabs/avalanchejs";import"hdkey";import"
|
|
1
|
+
import{BitcoinWalletAbstract as t}from"./BitcoinWalletAbstract.js";import r from"ledger-bitcoin";import"bitcoinjs-lib";import"coinselect";import"@ledgerhq/hw-app-eth";import"ethers";import"@solana/kit";import"@solana-program/system";import"@solana-program/token";import"@ledgerhq/hw-app-solana";import"bip39";import"@noble/curves/ed25519";import"@scure/base";import"micro-key-producer/slip10.js";import"@avalabs/avalanchejs";import"hdkey";import"bip32";import"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";import{createPSBTV2 as i}from"../utils/createPSBTV2.js";import{psbt2ToPsbt0 as a}from"../utils/psbt2ToPsbt0.js";class e extends t{constructor(t,r,i,a,e){super(t,i),this.derivationPath=r,this.transport=a,this.walletPolicyDetails=e}setTransport(t){this.transport=t}async signTx(t,e){const o=function(t){return new r(t)}(this.transport),s=this.ecPair.publicKey,p=this.provider.getNetwork(),n=await o.getMasterFingerprint(),l=i(t,e,p,Buffer.from(n,"hex"),s,this.derivationPath),{policy:m,hmac:c}=this.walletPolicyDetails,h=await o.signPsbt(l,m,c),u=a(l,p,s,this.derivationPath);if(h.forEach((t=>{const[r,i]=t;u.updateInput(r,{partialSig:[{signature:i.signature,pubkey:i.pubkey}]})})),!u.validateSignaturesOfAllInputs())throw new Error("Failed to validate signatures");return u.finalizeAllInputs(),u.extractTransaction()}}export{e as BitcoinLedgerWallet};
|
package/esm/EVM/LedgerSigner.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AbstractSigner as t,defineProperties as s,getAddress as i,toUtf8Bytes as e,hexlify as r,Signature as a,Transaction as n,TypedDataEncoder as o}from"ethers";import{getAppEth as h}from"./utils/getAppEth.js";import{getAddressDerivationPath as p}from"../utils/getAddressDerivationPath.js";import"@avalabs/avalanchejs";import"hdkey";import"
|
|
1
|
+
import{AbstractSigner as t,defineProperties as s,getAddress as i,toUtf8Bytes as e,hexlify as r,Signature as a,Transaction as n,TypedDataEncoder as o}from"ethers";import{getAppEth as h}from"./utils/getAppEth.js";import{getAddressDerivationPath as p}from"../utils/getAddressDerivationPath.js";import"@avalabs/avalanchejs";import"hdkey";import"bip32";import"bip39";import"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import{TransportStatusError as c,StatusCodes as d}from"@ledgerhq/hw-transport";import{TypedDataUtils as m,SignTypedDataVersion as g}from"@metamask/eth-sig-util";class l extends t{type="default";path;provider=null;accountIndex;derivationSpec;transport;_eth;constructor(t=0,i,e,r){super(),this.path=p(t,e,"EVM"),this.accountIndex=t,this.transport=i,this.derivationSpec=e,this._eth=h(i),s(this,{path:this.path,type:"default",provider:r??null})}setTransport(t){this._eth=h(t),this.transport=t}async getAddress(){const t=await this._eth.getAddress(this.path);return i(t.address)}async signMessage(t){"string"==typeof t&&(t=e(t));const s=r(t).substring(2),i=await this._eth.signPersonalMessage(this.path,s);return i.r="0x"+i.r,i.s="0x"+i.s,a.from(i).serialized}async signTransaction(t){const s=await this.populateTransaction(t);delete s.from;const i=n.from(s),e=i.unsignedSerialized,r=await this._eth.signTransaction(this.path,e.slice(2),null);return i.signature={v:BigInt("0x"+r.v),r:"0x"+r.r,s:"0x"+r.s},i.serialized}connect(t){return new l(this.accountIndex,this.transport,this.derivationSpec,t)}async signTypedData(t,s,i){const{EIP712Domain:e,...r}=s,n=o.getPrimaryType(r);try{const e=await this._eth.signEIP712Message(this.path,{domain:{name:t.name||void 0,chainId:t.chainId?Number(t.chainId):void 0,version:t.version||void 0,verifyingContract:t.verifyingContract||void 0,salt:t.salt?.toString()||void 0},types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],...s},primaryType:n,message:i});return e.r="0x"+e.r,e.s="0x"+e.s,a.from(e).serialized}catch(e){if(e instanceof c&&e.statusCode===d.INS_NOT_SUPPORTED){const e=m.hashStruct(n,i,s,g.V4),r=m.hashStruct("EIP712Domain",t,s,g.V4),o=await this._eth.signEIP712HashedMessage(this.path,r.toString("hex"),e.toString("hex"));return o.r="0x"+o.r,o.s="0x"+o.s,a.from(o).serialized}throw e}}}export{l as LedgerSigner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"
|
|
1
|
+
import e from"../../abis/erc20.abi.js";import{Interface as a}from"ethers";const o=async(e,a,o,s)=>{const n=new Set(e.map((e=>e.toLowerCase()))),c=new Set(a.map((e=>e.toLowerCase()))),f=async e=>{const a=await o.getBlock(e,!0);a?.prefetchedTransactions.forEach((function(e){e.to&&c.has(e.to.toLowerCase())&&t(e,n)?s(e,{type:"erc20",contractAddress:e.to}):r(e,n)&&s(e,{type:"native"})}))},i=await o.on("block",f);return{unsubscribe:()=>i.off("block",f)}},r=(e,a)=>a.has(e.from.toLowerCase())||a.has((e.to??"").toLowerCase()),t=(o,r)=>{const t=new a(e).parseTransaction({data:o.data,value:o.value});if(r.has(o.from.toLowerCase()))return!0;if("transfer"===t?.name)return r.has(t.args[0]?.toLowerCase());if("transferFrom"===t?.name){const e=r.has(t.args[0]?.toLowerCase()),a=r.has(t.args[1]?.toLowerCase());return e||a}return!1};export{t as isERC20Transfer,r as isNativeTxn,o as onBalanceChange};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{HDNodeWallet as r,Mnemonic as e}from"ethers";import{getAddressDerivationPath as t}from"../../utils/getAddressDerivationPath.js";import"@avalabs/avalanchejs";import"@ledgerhq/hw-app-eth";import"hdkey";
|
|
1
|
+
import{HDNodeWallet as r,Mnemonic as e}from"ethers";import{getAddressDerivationPath as t}from"../../utils/getAddressDerivationPath.js";import"@avalabs/avalanchejs";import"@ledgerhq/hw-app-eth";import"hdkey";function o(o,a,i){if(!(a>=0&&a%1==0))throw new Error("Account index must be an integer greater than or equal to 0.");return r.fromMnemonic(e.fromPhrase(o),t(a,i,"EVM"))}export{o as getWalletFromMnemonic};
|
|
@@ -7,4 +7,5 @@ declare const getSolanaProvider: ({ isTestnet, rpcUrl, }: {
|
|
|
7
7
|
rpcUrl: string;
|
|
8
8
|
}) => _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)>;
|
|
9
9
|
|
|
10
|
-
export {
|
|
10
|
+
export { getSolanaProvider, isSolanaProvider };
|
|
11
|
+
export type { SolanaProvider };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{address as o,createNoopSigner as t,pipe as a,createTransactionMessage as r,setTransactionMessageLifetimeUsingBlockhash as s,setTransactionMessageFeePayer as n,appendTransactionMessageInstructions as e}from"@solana/kit";import{getTransferSolInstruction as m}from"@solana-program/system";const i=async({from:i,to:c,amount:p,provider:u})=>{const{value:l}=await u.getLatestBlockhash().send(),d=[m({source:t(o(i)),destination:o(c),amount:p})];return a(r({version:0}),(o=>s(l,o)),(t=>n(o(i),t)),(o=>e(d,o)))};export{i as transferSol};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import * as _solana_kit from '@solana/kit';
|
|
2
|
+
import { IInstruction } from '@solana/kit';
|
|
2
3
|
import { SolanaProvider } from './solanaProvider.js';
|
|
3
4
|
|
|
4
|
-
declare const transferToken: ({ from, to, mint, amount, provider, }: {
|
|
5
|
+
declare const transferToken: ({ from, to, mint, amount, decimals, provider, }: {
|
|
5
6
|
from: string;
|
|
6
7
|
to: string;
|
|
7
8
|
mint: string;
|
|
8
9
|
amount: bigint;
|
|
10
|
+
decimals: number;
|
|
9
11
|
provider: SolanaProvider;
|
|
10
12
|
}) => Promise<_solana_kit.ITransactionMessageWithFeePayer<string> & Omit<_solana_kit.TransactionMessageWithBlockhashLifetime & Readonly<{
|
|
11
|
-
instructions: readonly
|
|
13
|
+
instructions: readonly IInstruction<string, readonly (_solana_kit.IAccountLookupMeta<string, string> | _solana_kit.IAccountMeta<string>)[]>[];
|
|
12
14
|
version: 0;
|
|
13
15
|
}>, "feePayer">>;
|
|
14
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{address as t,createNoopSigner as
|
|
1
|
+
import{address as t,createNoopSigner as a,pipe as o,createTransactionMessage as n,setTransactionMessageLifetimeUsingBlockhash as e,setTransactionMessageFeePayer as r,appendTransactionMessageInstructions as i}from"@solana/kit";import{findAssociatedTokenPda as s,TOKEN_PROGRAM_ADDRESS as m,getCreateAssociatedTokenIdempotentInstruction as c,getTransferCheckedInstruction as u}from"@solana-program/token";const p=async({from:p,to:w,mint:d,amount:l,decimals:g,provider:h})=>{const[k]=await s({mint:t(d),owner:t(p),tokenProgram:m}),[f]=await s({mint:t(d),owner:t(w),tokenProgram:m}),v=await h.getAccountInfo(f,{encoding:"base64"}).send(),y=[];v.value||y.push(await c({payer:a(t(p)),mint:t(d),owner:t(w),ata:f})),y.push(u({amount:l,authority:a(t(p)),decimals:g,mint:t(d),destination:f,source:k}));const{value:P}=await h.getLatestBlockhash().send();return o(n({version:0}),(t=>e(P,t)),(a=>r(t(p),a)),(t=>i(y,t)))};export{p as transferToken};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{base58 as r}from"@scure/base";import t from"@ledgerhq/hw-app-solana";import{compileTransaction as a,address as s,assertIsSignature as i,getBase64EncodedWireTransaction as e}from"@solana/kit";import{deserializeTransactionMessage as o}from"../utils/deserializeSolanaTx.js";import"@solana-program/system";import"@solana-program/token";import{getSolanaDerivationPath as n}from"../utils/derivationPath.js";class m{#r;#t;constructor(r,t){this.#r=n(r,!1),this.#t=t}async signTx(n,m){const d=await o(n,m),{signatures:p,messageBytes:u}=a(d),
|
|
1
|
+
import{base58 as r}from"@scure/base";import t from"@ledgerhq/hw-app-solana";import{compileTransaction as a,address as s,assertIsSignature as i,getBase64EncodedWireTransaction as e}from"@solana/kit";import{deserializeTransactionMessage as o}from"../utils/deserializeSolanaTx.js";import"@solana-program/system";import"@solana-program/token";import{getSolanaDerivationPath as n}from"../utils/derivationPath.js";class m{#r;#t;constructor(r,t){this.#r=n(r,!1),this.#t=t}async signTx(n,m){const d=await o(n,m),{signatures:p,messageBytes:u,...g}=a(d),h=new t(this.#t),{address:c}=await h.getAddress(this.#r),f=s(r.encode(Uint8Array.from(c)));if(!this.#a(f,p))return n;const{signature:l}=await h.signTransaction(this.#r,Buffer.from(u)),y=r.encode(Uint8Array.from(l));return i(y),e({...g,messageBytes:u,signatures:{...p,[f]:r.decode(y)}})}#a(r,t){return r in t&&!t[r]}}export{m as SolanaLedgerSigner};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=[{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"}];export{e as default};
|
package/esm/index.d.ts
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { BitcoinProviderAbstract } from './BitcoinVM/providers/BitcoinProviderAbstract.js';
|
|
3
|
-
export { BitcoinProvider } from './BitcoinVM/providers/BitcoinProvider.js';
|
|
4
|
-
export { addEncodedSigToPsbt } from './BitcoinVM/utils/addEncodedSigToPsbt.js';
|
|
5
|
-
export { createPsbt } from './BitcoinVM/utils/createPsbt.js';
|
|
6
|
-
export { createTransferTx } from './BitcoinVM/utils/createTransferTx.js';
|
|
7
|
-
export { formatAddressForNetworkBech32 } from './BitcoinVM/utils/formatAddressForNetworkBech32.js';
|
|
8
|
-
export { getBech32Address } from './BitcoinVM/utils/getBech32Address.js';
|
|
9
|
-
export { getBech32AddressFromXPub } from './BitcoinVM/utils/getBech32AddressFromXPub.js';
|
|
10
|
-
export { getMaxTransferAmount } from './BitcoinVM/utils/getMaxTransferAmount.js';
|
|
11
|
-
export { selectUtxos } from './BitcoinVM/utils/selectUtxos.js';
|
|
12
|
-
export { createWalletPolicy } from './BitcoinVM/utils/createWalletPolicy.js';
|
|
13
|
-
export { createPSBTV2 } from './BitcoinVM/utils/createPSBTV2.js';
|
|
14
|
-
export { psbt2ToPsbt0 } from './BitcoinVM/utils/psbt2ToPsbt0.js';
|
|
15
|
-
export { getTransferTxDetails } from './BitcoinVM/utils/getTransferTxDetails.js';
|
|
16
|
-
export { BitcoinWalletAbstract } from './BitcoinVM/wallets/BitcoinWalletAbstract.js';
|
|
17
|
-
export { BitcoinWallet } from './BitcoinVM/wallets/BitcoinWallet.js';
|
|
18
|
-
export { BitcoinLedgerWallet } from './BitcoinVM/wallets/BitcoinWalletLedger.js';
|
|
19
|
-
export { BitcoinWalletVoid } from './BitcoinVM/wallets/BitcoinWalletVoid.js';
|
|
20
|
-
export { networks as BtcNetworks } from 'bitcoinjs-lib';
|
|
1
|
+
export { BtcNetworks } from './BitcoinVM/index.js';
|
|
21
2
|
export { getAppEth } from './EVM/utils/getAppEth.js';
|
|
22
3
|
export { getVoidSigner } from './EVM/utils/getVoidSigner.js';
|
|
23
4
|
export { getWalletFromMnemonic } from './EVM/utils/getWalletFromMnemonic.js';
|
|
@@ -51,3 +32,22 @@ export { getSolanaDerivationPath } from './SolanaVM/utils/derivationPath.js';
|
|
|
51
32
|
export { getSolanaPublicKeyFromLedger } from './SolanaVM/utils/getSolanaPublicKeyFromLedger.js';
|
|
52
33
|
export { SolanaSigner } from './SolanaVM/wallets/SolanaSigner.js';
|
|
53
34
|
export { SolanaLedgerSigner } from './SolanaVM/wallets/SolanaLedgerSigner.js';
|
|
35
|
+
export { BitcoinHistoryTx, BitcoinInputUTXO, BitcoinInputUTXOWithOptionalScript, BitcoinLedgerInputUTXO, BitcoinOutputUTXO, BitcoinTx } from './BitcoinVM/models.js';
|
|
36
|
+
export { BitcoinProviderAbstract } from './BitcoinVM/providers/BitcoinProviderAbstract.js';
|
|
37
|
+
export { BitcoinProvider } from './BitcoinVM/providers/BitcoinProvider.js';
|
|
38
|
+
export { addEncodedSigToPsbt } from './BitcoinVM/utils/addEncodedSigToPsbt.js';
|
|
39
|
+
export { createPsbt } from './BitcoinVM/utils/createPsbt.js';
|
|
40
|
+
export { createTransferTx } from './BitcoinVM/utils/createTransferTx.js';
|
|
41
|
+
export { formatAddressForNetworkBech32 } from './BitcoinVM/utils/formatAddressForNetworkBech32.js';
|
|
42
|
+
export { getBech32Address } from './BitcoinVM/utils/getBech32Address.js';
|
|
43
|
+
export { getBech32AddressFromXPub } from './BitcoinVM/utils/getBech32AddressFromXPub.js';
|
|
44
|
+
export { getMaxTransferAmount } from './BitcoinVM/utils/getMaxTransferAmount.js';
|
|
45
|
+
export { selectUtxos } from './BitcoinVM/utils/selectUtxos.js';
|
|
46
|
+
export { createWalletPolicy } from './BitcoinVM/utils/createWalletPolicy.js';
|
|
47
|
+
export { createPSBTV2 } from './BitcoinVM/utils/createPSBTV2.js';
|
|
48
|
+
export { psbt2ToPsbt0 } from './BitcoinVM/utils/psbt2ToPsbt0.js';
|
|
49
|
+
export { getTransferTxDetails } from './BitcoinVM/utils/getTransferTxDetails.js';
|
|
50
|
+
export { BitcoinWalletAbstract } from './BitcoinVM/wallets/BitcoinWalletAbstract.js';
|
|
51
|
+
export { BitcoinWallet } from './BitcoinVM/wallets/BitcoinWallet.js';
|
|
52
|
+
export { BitcoinLedgerWallet } from './BitcoinVM/wallets/BitcoinWalletLedger.js';
|
|
53
|
+
export { BitcoinWalletVoid } from './BitcoinVM/wallets/BitcoinWalletVoid.js';
|
package/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{BtcNetworks}from"./BitcoinVM/index.js";export{getAppEth}from"./EVM/utils/getAppEth.js";export{getVoidSigner}from"./EVM/utils/getVoidSigner.js";export{getWalletFromMnemonic}from"./EVM/utils/getWalletFromMnemonic.js";export{isERC20Transfer,isNativeTxn,onBalanceChange}from"./EVM/utils/blockPolling.js";export{JsonRpcBatchInternal}from"./EVM/utils/jsonRpcBatchProvider.js";export{getAddressPrivateKeyFromXPriv}from"./EVM/utils/getAddressPrivateKeyFromXPriv.js";export{getAddressPublicKeyFromXPub}from"./EVM/utils/getAddressPublicKeyFromXPub.js";export{getAddressFromXPub}from"./EVM/utils/getAddressFromXPub.js";export{getXpubFromMnemonic}from"./EVM/utils/getXpubFromMnemonic.js";export{getEvmAddressFromPubKey}from"./EVM/utils/getEvmAddressFromPubKey.js";export{getBtcAddressFromPubKey}from"./EVM/utils/getBtcAddressFromPubKey.js";export{DerivationPath,ETH_ACCOUNT_PATH,ETH_COIN_PATH}from"./EVM/constants.js";export{LedgerSigner}from"./EVM/LedgerSigner.js";import*as e from"./Avalanche/index.js";export{e as Avalanche};export{getAddressDerivationPath}from"./utils/getAddressDerivationPath.js";export{getPublicKeyFromPrivateKey}from"./utils/getPublicKeyFromPrivateKey.js";export{getPubKeyFromTransport}from"./utils/getPubKeyFromTransport.js";export{getLedgerExtendedPublicKey}from"./utils/getLedgerExtendedPublicKey.js";export{omitUndefinedKeys}from"./utils/omitUndefinedKeys.js";export{getLedgerAppInfo}from"./utils/getLedgerAppInfo.js";export{openLedgerApp}from"./utils/openLedgerApp.js";export{quitLedgerApp}from"./utils/quitLedgerApp.js";export{compileSolanaTx}from"./SolanaVM/utils/compileSolanaTx.js";export{deserializeTransactionMessage}from"./SolanaVM/utils/deserializeSolanaTx.js";export{serializeSolanaTx}from"./SolanaVM/utils/serializeSolanaTx.js";export{getSolanaProvider,isSolanaProvider}from"./SolanaVM/utils/solanaProvider.js";export{transferSol}from"./SolanaVM/utils/transferSol.js";export{transferToken}from"./SolanaVM/utils/transferToken.js";export{getSolanaDerivationPath}from"./SolanaVM/utils/derivationPath.js";export{getSolanaPublicKeyFromLedger}from"./SolanaVM/utils/getSolanaPublicKeyFromLedger.js";export{SolanaSigner}from"./SolanaVM/wallets/SolanaSigner.js";export{SolanaLedgerSigner}from"./SolanaVM/wallets/SolanaLedgerSigner.js";export{BitcoinProviderAbstract}from"./BitcoinVM/providers/BitcoinProviderAbstract.js";export{BitcoinProvider}from"./BitcoinVM/providers/BitcoinProvider.js";export{addEncodedSigToPsbt}from"./BitcoinVM/utils/addEncodedSigToPsbt.js";export{createPsbt}from"./BitcoinVM/utils/createPsbt.js";export{createTransferTx}from"./BitcoinVM/utils/createTransferTx.js";export{formatAddressForNetworkBech32}from"./BitcoinVM/utils/formatAddressForNetworkBech32.js";export{getBech32Address}from"./BitcoinVM/utils/getBech32Address.js";export{getBech32AddressFromXPub}from"./BitcoinVM/utils/getBech32AddressFromXPub.js";export{getMaxTransferAmount}from"./BitcoinVM/utils/getMaxTransferAmount.js";export{selectUtxos}from"./BitcoinVM/utils/selectUtxos.js";export{createWalletPolicy}from"./BitcoinVM/utils/createWalletPolicy.js";export{createPSBTV2}from"./BitcoinVM/utils/createPSBTV2.js";export{psbt2ToPsbt0}from"./BitcoinVM/utils/psbt2ToPsbt0.js";export{getTransferTxDetails}from"./BitcoinVM/utils/getTransferTxDetails.js";export{BitcoinWalletAbstract}from"./BitcoinVM/wallets/BitcoinWalletAbstract.js";export{BitcoinWallet}from"./BitcoinVM/wallets/BitcoinWallet.js";export{BitcoinLedgerWallet}from"./BitcoinVM/wallets/BitcoinWalletLedger.js";export{BitcoinWalletVoid}from"./BitcoinVM/wallets/BitcoinWalletVoid.js";
|