@avalabs/core-wallets-sdk 2.8.0-alpha.197
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/LICENSE +9 -0
- package/README.md +9 -0
- package/dist/index.d.ts +1794 -0
- package/dist/index.js +1 -0
- package/esm/Avalanche/index.d.ts +41 -0
- package/esm/Avalanche/index.js +1 -0
- package/esm/Avalanche/models.d.ts +173 -0
- package/esm/Avalanche/models.js +1 -0
- package/esm/Avalanche/providers/AbstractProvider.d.ts +39 -0
- package/esm/Avalanche/providers/AbstractProvider.js +1 -0
- package/esm/Avalanche/providers/JsonRpcProvider.d.ts +11 -0
- package/esm/Avalanche/providers/JsonRpcProvider.js +1 -0
- package/esm/Avalanche/providers/constants.d.ts +12 -0
- package/esm/Avalanche/providers/constants.js +1 -0
- package/esm/Avalanche/utils/addSignaturesToAvalancheTx.d.ts +16 -0
- package/esm/Avalanche/utils/addSignaturesToAvalancheTx.js +1 -0
- package/esm/Avalanche/utils/convertGlacierUtxo.d.ts +7 -0
- package/esm/Avalanche/utils/convertGlacierUtxo.js +1 -0
- package/esm/Avalanche/utils/createAvalancheEvmUnsignedTx.d.ts +11 -0
- package/esm/Avalanche/utils/createAvalancheEvmUnsignedTx.js +1 -0
- package/esm/Avalanche/utils/createAvalancheUnsignedTx.d.ts +13 -0
- package/esm/Avalanche/utils/createAvalancheUnsignedTx.js +1 -0
- package/esm/Avalanche/utils/digestMessage.d.ts +3 -0
- package/esm/Avalanche/utils/digestMessage.js +1 -0
- package/esm/Avalanche/utils/getAddressFromXpub.d.ts +14 -0
- package/esm/Avalanche/utils/getAddressFromXpub.js +1 -0
- package/esm/Avalanche/utils/getAddressPublicKeyFromXpub.d.ts +9 -0
- package/esm/Avalanche/utils/getAddressPublicKeyFromXpub.js +1 -0
- package/esm/Avalanche/utils/getAllUTXOs.d.ts +17 -0
- package/esm/Avalanche/utils/getAllUTXOs.js +1 -0
- package/esm/Avalanche/utils/getAssetBalance.d.ts +29 -0
- package/esm/Avalanche/utils/getAssetBalance.js +1 -0
- package/esm/Avalanche/utils/getChainAliasByChainId.js +1 -0
- package/esm/Avalanche/utils/getPchainUnixNow.d.ts +6 -0
- package/esm/Avalanche/utils/getPchainUnixNow.js +1 -0
- package/esm/Avalanche/utils/getStakeForAddresses.d.ts +5 -0
- package/esm/Avalanche/utils/getStakeForAddresses.js +1 -0
- package/esm/Avalanche/utils/getStakedAssetBalance.d.ts +16 -0
- package/esm/Avalanche/utils/getStakedAssetBalance.js +1 -0
- package/esm/Avalanche/utils/getTxOutputAddresses.js +1 -0
- package/esm/Avalanche/utils/getUnixNow.d.ts +6 -0
- package/esm/Avalanche/utils/getUnixNow.js +1 -0
- package/esm/Avalanche/utils/getUtxoInfo.d.ts +13 -0
- package/esm/Avalanche/utils/getUtxoInfo.js +1 -0
- package/esm/Avalanche/utils/getUtxosByTxFromGlacier.d.ts +13 -0
- package/esm/Avalanche/utils/getUtxosByTxFromGlacier.js +1 -0
- package/esm/Avalanche/utils/getVmByChainAlias.d.ts +3 -0
- package/esm/Avalanche/utils/getVmByChainAlias.js +1 -0
- package/esm/Avalanche/utils/getXpubFromMnemonic.d.ts +7 -0
- package/esm/Avalanche/utils/getXpubFromMnemonic.js +1 -0
- package/esm/Avalanche/utils/handleSubnetAuth.js +1 -0
- package/esm/Avalanche/utils/isBech32Address.d.ts +8 -0
- package/esm/Avalanche/utils/isBech32Address.js +1 -0
- package/esm/Avalanche/utils/parseAvalancheTx.d.ts +10 -0
- package/esm/Avalanche/utils/parseAvalancheTx.js +1 -0
- package/esm/Avalanche/utils/parsers/index.js +1 -0
- package/esm/Avalanche/utils/parsers/parseAddDelegatorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseAddPermissionlessDelegatorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseAddPermissionlessValidatorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseAddSubnetValidorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseAddValidatorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseBaseTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseCreateChainTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseCreateSubnetTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseExportTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseImportTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseRemoveSubnetValidatorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseTransferSubnetOwnershipTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseTransformSubnetTx.js +1 -0
- package/esm/Avalanche/utils/parsers/utils/chainIdToVm.js +1 -0
- package/esm/Avalanche/utils/parsers/utils/getTransferableAmount.js +1 -0
- package/esm/Avalanche/utils/populateCredential.d.ts +9 -0
- package/esm/Avalanche/utils/populateCredential.js +1 -0
- package/esm/Avalanche/utils/signedTxToHex.d.ts +5 -0
- package/esm/Avalanche/utils/signedTxToHex.js +1 -0
- package/esm/Avalanche/utils/sortUTXOs.d.ts +14 -0
- package/esm/Avalanche/utils/sortUTXOs.js +1 -0
- package/esm/Avalanche/utils/txSizeLimits.d.ts +34 -0
- package/esm/Avalanche/utils/txSizeLimits.js +1 -0
- package/esm/Avalanche/utils/verifyDerivationPath.d.ts +7 -0
- package/esm/Avalanche/utils/verifyDerivationPath.js +1 -0
- package/esm/Avalanche/wallets/AddressWallet.d.ts +45 -0
- package/esm/Avalanche/wallets/AddressWallet.js +1 -0
- package/esm/Avalanche/wallets/SimpleSigner.d.ts +62 -0
- package/esm/Avalanche/wallets/SimpleSigner.js +1 -0
- package/esm/Avalanche/wallets/StaticSigner.d.ts +39 -0
- package/esm/Avalanche/wallets/StaticSigner.js +1 -0
- package/esm/Avalanche/wallets/WalletAbstract.d.ts +131 -0
- package/esm/Avalanche/wallets/WalletAbstract.js +1 -0
- package/esm/Avalanche/wallets/WalletVoid.d.ts +40 -0
- package/esm/Avalanche/wallets/WalletVoid.js +1 -0
- package/esm/Avalanche/wallets/ledger/LedgerSigner.d.ts +49 -0
- package/esm/Avalanche/wallets/ledger/LedgerSigner.js +1 -0
- package/esm/Avalanche/wallets/ledger/SimpleLedgerSigner.d.ts +32 -0
- package/esm/Avalanche/wallets/ledger/SimpleLedgerSigner.js +1 -0
- package/esm/Avalanche/wallets/ledger/ZondaxProvider.js +1 -0
- package/esm/Avalanche/wallets/ledger/constants.js +1 -0
- package/esm/Avalanche/wallets/ledger/getLedgerProvider.d.ts +10 -0
- package/esm/Avalanche/wallets/ledger/getLedgerProvider.js +1 -0
- package/esm/Avalanche/wallets/ledger/isObsidianApp.d.ts +5 -0
- package/esm/Avalanche/wallets/ledger/isObsidianApp.js +1 -0
- package/esm/Avalanche/wallets/ledger/models.d.ts +37 -0
- package/esm/Avalanche/wallets/legacy/LedgerWallet.d.ts +41 -0
- package/esm/Avalanche/wallets/legacy/LedgerWallet.js +1 -0
- package/esm/Avalanche/wallets/legacy/MnemonicWallet.d.ts +30 -0
- package/esm/Avalanche/wallets/legacy/MnemonicWallet.js +1 -0
- package/esm/Avalanche/wallets/legacy/MnemonicWalletVoid.d.ts +83 -0
- package/esm/Avalanche/wallets/legacy/MnemonicWalletVoid.js +1 -0
- package/esm/Avalanche/wallets/models.d.ts +35 -0
- package/esm/BitcoinVM/models.d.ts +77 -0
- package/esm/BitcoinVM/providers/BitcoinProvider.d.ts +42 -0
- package/esm/BitcoinVM/providers/BitcoinProvider.js +1 -0
- package/esm/BitcoinVM/providers/BitcoinProviderAbstract.d.ts +63 -0
- package/esm/BitcoinVM/providers/BitcoinProviderAbstract.js +1 -0
- package/esm/BitcoinVM/providers/models.js +1 -0
- package/esm/BitcoinVM/providers/utils/parseAddressFullTx.js +1 -0
- package/esm/BitcoinVM/utils/addEncodedSigToPsbt.d.ts +5 -0
- package/esm/BitcoinVM/utils/addEncodedSigToPsbt.js +1 -0
- package/esm/BitcoinVM/utils/createPSBTV2.d.ts +10 -0
- package/esm/BitcoinVM/utils/createPSBTV2.js +1 -0
- package/esm/BitcoinVM/utils/createPsbt.d.ts +12 -0
- package/esm/BitcoinVM/utils/createPsbt.js +1 -0
- package/esm/BitcoinVM/utils/createTransferTx.d.ts +20 -0
- package/esm/BitcoinVM/utils/createTransferTx.js +1 -0
- package/esm/BitcoinVM/utils/createWalletPolicy.d.ts +5 -0
- package/esm/BitcoinVM/utils/createWalletPolicy.js +1 -0
- package/esm/BitcoinVM/utils/filterDuplicateUTXOs.js +1 -0
- package/esm/BitcoinVM/utils/formatAddressForNetworkBech32.d.ts +10 -0
- package/esm/BitcoinVM/utils/formatAddressForNetworkBech32.js +1 -0
- package/esm/BitcoinVM/utils/getBech32Address.d.ts +10 -0
- package/esm/BitcoinVM/utils/getBech32Address.js +1 -0
- package/esm/BitcoinVM/utils/getBech32AddressFromXPub.d.ts +11 -0
- package/esm/BitcoinVM/utils/getBech32AddressFromXPub.js +1 -0
- package/esm/BitcoinVM/utils/getMaxTransferAmount.d.ts +13 -0
- package/esm/BitcoinVM/utils/getMaxTransferAmount.js +1 -0
- package/esm/BitcoinVM/utils/getTransferTxDetails.d.ts +17 -0
- package/esm/BitcoinVM/utils/getTransferTxDetails.js +1 -0
- package/esm/BitcoinVM/utils/psbt2ToPsbt0.d.ts +15 -0
- package/esm/BitcoinVM/utils/psbt2ToPsbt0.js +1 -0
- package/esm/BitcoinVM/utils/selectUtxos.d.ts +22 -0
- package/esm/BitcoinVM/utils/selectUtxos.js +1 -0
- package/esm/BitcoinVM/utils/sumUTXOs.js +1 -0
- package/esm/BitcoinVM/wallets/BitcoinWallet.d.ts +44 -0
- package/esm/BitcoinVM/wallets/BitcoinWallet.js +1 -0
- package/esm/BitcoinVM/wallets/BitcoinWalletAbstract.d.ts +72 -0
- package/esm/BitcoinVM/wallets/BitcoinWalletAbstract.js +1 -0
- package/esm/BitcoinVM/wallets/BitcoinWalletLedger.d.ts +34 -0
- package/esm/BitcoinVM/wallets/BitcoinWalletLedger.js +1 -0
- package/esm/BitcoinVM/wallets/BitcoinWalletVoid.d.ts +12 -0
- package/esm/BitcoinVM/wallets/BitcoinWalletVoid.js +1 -0
- package/esm/BitcoinVM/wallets/models.d.ts +8 -0
- package/esm/EVM/LedgerSigner.d.ts +23 -0
- package/esm/EVM/LedgerSigner.js +1 -0
- package/esm/EVM/constants.d.ts +8 -0
- package/esm/EVM/constants.js +1 -0
- package/esm/EVM/utils/blockPolling.d.ts +12 -0
- package/esm/EVM/utils/blockPolling.js +1 -0
- package/esm/EVM/utils/getAddressFromXPub.d.ts +9 -0
- package/esm/EVM/utils/getAddressFromXPub.js +1 -0
- package/esm/EVM/utils/getAddressPrivateKeyFromXPriv.d.ts +9 -0
- package/esm/EVM/utils/getAddressPrivateKeyFromXPriv.js +1 -0
- package/esm/EVM/utils/getAddressPublicKeyFromXPub.d.ts +9 -0
- package/esm/EVM/utils/getAddressPublicKeyFromXPub.js +1 -0
- package/esm/EVM/utils/getAppEth.d.ts +10 -0
- package/esm/EVM/utils/getAppEth.js +1 -0
- package/esm/EVM/utils/getBtcAddressFromPubKey.d.ts +10 -0
- package/esm/EVM/utils/getBtcAddressFromPubKey.js +1 -0
- package/esm/EVM/utils/getEvmAddressFromPubKey.d.ts +3 -0
- package/esm/EVM/utils/getEvmAddressFromPubKey.js +1 -0
- package/esm/EVM/utils/getVoidSigner.d.ts +10 -0
- package/esm/EVM/utils/getVoidSigner.js +1 -0
- package/esm/EVM/utils/getWalletFromMnemonic.d.ts +13 -0
- package/esm/EVM/utils/getWalletFromMnemonic.js +1 -0
- package/esm/EVM/utils/getXpubFromMnemonic.d.ts +7 -0
- package/esm/EVM/utils/getXpubFromMnemonic.js +1 -0
- package/esm/EVM/utils/jsonRpcBatchProvider.d.ts +31 -0
- package/esm/EVM/utils/jsonRpcBatchProvider.js +1 -0
- package/esm/EVM/utils/multicallABI.js +1 -0
- package/esm/index.d.ts +43 -0
- package/esm/index.js +1 -0
- package/esm/utils/binarySearch.js +1 -0
- package/esm/utils/getAddressDerivationPath.d.ts +11 -0
- package/esm/utils/getAddressDerivationPath.js +1 -0
- package/esm/utils/getLedgerAppInfo.d.ts +13 -0
- package/esm/utils/getLedgerAppInfo.js +1 -0
- package/esm/utils/getLedgerExtendedPublicKey.d.ts +12 -0
- package/esm/utils/getLedgerExtendedPublicKey.js +1 -0
- package/esm/utils/getPubKeyFromTransport.d.ts +7 -0
- package/esm/utils/getPubKeyFromTransport.js +1 -0
- package/esm/utils/getPublicKeyFromPrivateKey.d.ts +8 -0
- package/esm/utils/getPublicKeyFromPrivateKey.js +1 -0
- package/esm/utils/omitUndefinedKeys.d.ts +3 -0
- package/esm/utils/omitUndefinedKeys.js +1 -0
- package/esm/utils/openLedgerApp.d.ts +9 -0
- package/esm/utils/openLedgerApp.js +1 -0
- package/esm/utils/quitLedgerApp.d.ts +10 -0
- package/esm/utils/quitLedgerApp.js +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AbstractSigner, Provider, BytesLike, TransactionRequest, TypedDataDomain, TypedDataField } from 'ethers';
|
|
2
|
+
import Eth from '@ledgerhq/hw-app-eth';
|
|
3
|
+
import Transport from '@ledgerhq/hw-transport';
|
|
4
|
+
import { DerivationPath } from './constants.js';
|
|
5
|
+
|
|
6
|
+
declare class LedgerSigner extends AbstractSigner {
|
|
7
|
+
readonly type: string;
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly provider: Provider | null;
|
|
10
|
+
readonly accountIndex: number;
|
|
11
|
+
readonly derivationSpec: DerivationPath;
|
|
12
|
+
transport: Transport;
|
|
13
|
+
_eth: Eth;
|
|
14
|
+
constructor(accountIndex: number | undefined, transport: Transport, derivationSpec: DerivationPath, provider?: Provider);
|
|
15
|
+
setTransport(t: Transport): void;
|
|
16
|
+
getAddress(): Promise<string>;
|
|
17
|
+
signMessage(message: BytesLike | string): Promise<string>;
|
|
18
|
+
signTransaction(transaction: TransactionRequest): Promise<string>;
|
|
19
|
+
connect(provider: Provider): LedgerSigner;
|
|
20
|
+
signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { LedgerSigner };
|
|
@@ -0,0 +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"buffer";import"@openzeppelin/contracts/build/contracts/ERC20.json";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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e="m/44'/60'",r=`${e}/0'`;var i=(e=>(e.BIP44="bip44",e.LedgerLive="ledger_live",e))(i||{});export{i as DerivationPath,r as ETH_ACCOUNT_PATH,e as ETH_COIN_PATH};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Provider, TransactionResponse } from 'ethers';
|
|
2
|
+
|
|
3
|
+
declare const onBalanceChange: (walletAddresses: string[], erc20Addresses: string[], provider: Provider, callback: (txn: TransactionResponse, eventData: {
|
|
4
|
+
type: 'native' | 'erc20';
|
|
5
|
+
contractAddress?: string;
|
|
6
|
+
}) => void) => Promise<{
|
|
7
|
+
unsubscribe: () => Promise<Provider>;
|
|
8
|
+
}>;
|
|
9
|
+
declare const isNativeTxn: (txn: TransactionResponse, walletAddressSet: Set<string>) => boolean;
|
|
10
|
+
declare const isERC20Transfer: (txn: TransactionResponse, walletAddressSet: Set<string>) => boolean;
|
|
11
|
+
|
|
12
|
+
export { isERC20Transfer, isNativeTxn, onBalanceChange };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"@openzeppelin/contracts/build/contracts/ERC20.json";import{Interface as o}from"ethers";const t=async(e,o,t,s)=>{const n=new Set(e.map((e=>e.toLowerCase()))),c=new Set(o.map((e=>e.toLowerCase()))),i=async e=>{const o=await t.getBlock(e,!0);o?.prefetchedTransactions.forEach((function(e){e.to&&c.has(e.to.toLowerCase())&&r(e,n)?s(e,{type:"erc20",contractAddress:e.to}):a(e,n)&&s(e,{type:"native"})}))},f=await t.on("block",i);return{unsubscribe:()=>f.off("block",i)}},a=(e,o)=>o.has(e.from.toLowerCase())||o.has((e.to??"").toLowerCase()),r=(t,a)=>{const r=new o(e.abi).parseTransaction({data:t.data,value:t.value});if(a.has(t.from.toLowerCase()))return!0;if("transfer"===r?.name)return a.has(r.args[0]?.toLowerCase());if("transferFrom"===r?.name){const e=a.has(r.args[0]?.toLowerCase()),o=a.has(r.args[1]?.toLowerCase());return e||o}return!1};export{r as isERC20Transfer,a as isNativeTxn,t as onBalanceChange};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the address given a XPUB and account index.
|
|
3
|
+
* @returns Address of path `m/44'/60'/0'/0/n` where n is the index
|
|
4
|
+
* @param xpub XPUB for m/44'/60'/0'
|
|
5
|
+
* @param index Account index to get the address of.
|
|
6
|
+
*/
|
|
7
|
+
declare function getAddressFromXPub(xpub: string, index: number): string;
|
|
8
|
+
|
|
9
|
+
export { getAddressFromXPub };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{computeAddress as r}from"ethers";import{getAddressPublicKeyFromXPub as t}from"./getAddressPublicKeyFromXPub.js";function o(o,e){const i=t(o,e);return r(`0x${i.toString("hex")}`)}export{o as getAddressFromXPub};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the public key for an address given the account extended pubic key.
|
|
3
|
+
* @param xpriv Extended private key for m/44'/60'/0'
|
|
4
|
+
* @param accountIndex Index of the address
|
|
5
|
+
* @returns Public key for m/44'/60'/0'/0/n where `n` is the address index
|
|
6
|
+
*/
|
|
7
|
+
declare function getAddressPrivateKeyFromXPriv(xpriv: string, accountIndex: number): Buffer;
|
|
8
|
+
|
|
9
|
+
export { getAddressPrivateKeyFromXPriv };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fromBase58 as e}from"bip32";function r(r,t){const i=e(r).derivePath(`0/${t}`);if(!i.privateKey)throw new Error("Unable to derive private key.");return i.privateKey}export{r as getAddressPrivateKeyFromXPriv};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the public key for an address given the account extended pubic key.
|
|
3
|
+
* @param xpub Extended public key for m/44'/60'/0'
|
|
4
|
+
* @param accountIndex Index of the address
|
|
5
|
+
* @returns Public key for m/44'/60'/0'/0/n where `n` is the address index
|
|
6
|
+
*/
|
|
7
|
+
declare function getAddressPublicKeyFromXPub(xpub: string, accountIndex: number): Buffer;
|
|
8
|
+
|
|
9
|
+
export { getAddressPublicKeyFromXPub };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fromBase58 as r}from"bip32";function e(e,i){return r(e).derivePath(`0/${i}`).publicKey}export{e as getAddressPublicKeyFromXPub};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"@ledgerhq/hw-app-eth";function r(r){return new e(r,"w0w")}export{r as getAppEth};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Network } from 'bitcoinjs-lib';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Given a public key, return the Bech32 bitcoin address.
|
|
5
|
+
* @param pubKey
|
|
6
|
+
* @param network BTC network to use for the address
|
|
7
|
+
*/
|
|
8
|
+
declare function getBtcAddressFromPubKey(pubKey: Buffer, network: Network): string;
|
|
9
|
+
|
|
10
|
+
export { getBtcAddressFromPubKey };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getBech32Address as r}from"../../BitcoinVM/utils/getBech32Address.js";import{strip0x as o}from"@avalabs/core-utils-sdk";import{SigningKey as t}from"ethers";function e(e,i){const s=o(t.computePublicKey(e,!0)),m=Buffer.from(s,"hex");return r(m,i)}export{e as getBtcAddressFromPubKey};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{computeAddress as r}from"ethers";function t(t){return r(`0x${t.toString("hex")}`)}export{t as getEvmAddressFromPubKey};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Provider, VoidSigner } from 'ethers';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns a readonly, void signer class from ethers.
|
|
5
|
+
* @param address
|
|
6
|
+
* @param provider
|
|
7
|
+
*/
|
|
8
|
+
declare function getVoidSigner(address: string, provider?: Provider): VoidSigner;
|
|
9
|
+
|
|
10
|
+
export { getVoidSigner };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{VoidSigner as r}from"ethers";function e(e,t){return new r(e,t)}export{e as getVoidSigner};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HDNodeWallet } from 'ethers';
|
|
2
|
+
import { DerivationPath } from '../constants.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns a wallet instance given a mnemonic and the account index.
|
|
6
|
+
* @remarks Uses the fixed
|
|
7
|
+
* @param mnemonic
|
|
8
|
+
* @param accountIndex
|
|
9
|
+
* @param pathSpec Either BIP44 or Ledger Live
|
|
10
|
+
*/
|
|
11
|
+
declare function getWalletFromMnemonic(mnemonic: string, accountIndex: number, pathSpec: DerivationPath): HDNodeWallet;
|
|
12
|
+
|
|
13
|
+
export { getWalletFromMnemonic };
|
|
@@ -0,0 +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";import"buffer";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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fromSeed as r}from"bip32";import{ETH_ACCOUNT_PATH as o}from"../constants.js";import{validateMnemonic as t,mnemonicToSeed as n}from"bip39";async function e(e){if(!t(e))throw new Error("Invalid mnemonic phrase.");const i=await n(e);return r(i).derivePath(o).neutered().toBase58()}export{e as getXpubFromMnemonic};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { JsonRpcProvider, FetchRequest, Network, Contract } from 'ethers';
|
|
2
|
+
|
|
3
|
+
type PendingBatch = null | Array<{
|
|
4
|
+
request: {
|
|
5
|
+
method: string;
|
|
6
|
+
params: Array<any>;
|
|
7
|
+
id: number;
|
|
8
|
+
jsonrpc: '2.0';
|
|
9
|
+
};
|
|
10
|
+
resolve: (result: any) => void;
|
|
11
|
+
reject: (error: Error) => void;
|
|
12
|
+
}>;
|
|
13
|
+
declare class JsonRpcBatchInternal extends JsonRpcProvider {
|
|
14
|
+
#private;
|
|
15
|
+
private url?;
|
|
16
|
+
constructor(config: {
|
|
17
|
+
maxCalls: number;
|
|
18
|
+
multiContractAddress?: string;
|
|
19
|
+
} | number, urlOrFetchRequest?: string | FetchRequest, network?: Network);
|
|
20
|
+
_pendingBatchAggregator: NodeJS.Timer | null;
|
|
21
|
+
_pendingBatch: PendingBatch;
|
|
22
|
+
_maxCalls: number;
|
|
23
|
+
_parentProvider?: JsonRpcProvider;
|
|
24
|
+
_multicallContract?: Contract;
|
|
25
|
+
send(method: string, params: Array<any>): Promise<any>;
|
|
26
|
+
flush: () => void;
|
|
27
|
+
batchSend: (batch: PendingBatch) => Promise<any>;
|
|
28
|
+
batchSendMultiCall: (batch: PendingBatch) => Promise<any>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { JsonRpcBatchInternal };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"./multicallABI.js";import{JsonRpcProvider as e,FetchRequest as r,Contract as s}from"ethers";class a extends e{url;constructor(a,n,l){super(n,l,{staticNetwork:l}),this.#t="string"==typeof n?new r(n):void 0===n?new r("http://localhost:8545"):n.clone(),this.url=this.#t.url,this._maxCalls="number"==typeof a?a:a.maxCalls,"number"!=typeof a&&a?.multiContractAddress&&(this._parentProvider=new e(this.#t,l,{staticNetwork:l}),this._multicallContract=new s(a.multiContractAddress,t,this._parentProvider),this._maxCalls=62)}#t;#e=1;_pendingBatchAggregator=null;_pendingBatch=[];_maxCalls;_parentProvider;_multicallContract;send(t,e){if("eth_call"!==t)return super.send(t,e);const r={method:t,params:e,id:this.#e++,jsonrpc:"2.0"};null==this._pendingBatch&&(this._pendingBatch=[]);const s={request:r,resolve:null,reject:null},a=new Promise(((t,e)=>{s.resolve=t,s.reject=e}));return this._pendingBatch.push(s),this._pendingBatchAggregator||(this._pendingBatchAggregator=setTimeout(this.flush,10)),a}flush=()=>{const t=this._pendingBatch?.slice(0,this._maxCalls)??[];!this._pendingBatch||this._pendingBatch?.length<=this._maxCalls?(this._pendingBatch=null,this._pendingBatchAggregator=null):(this._pendingBatch.splice(0,this._maxCalls),setTimeout(this.flush,10));(this._multicallContract?this.batchSendMultiCall:this.batchSend)(t).then((e=>{t?.forEach(((t,r)=>{const s=e[r];if(s.error){const e=new Error(s.error.message);e.code=s.error.code,e.data=s.error.data,t.reject(e)}else t.resolve(s.result)}))})).catch((e=>{t?.forEach((t=>{t.reject(e)}))}))};batchSend=async t=>{const e=t?.map((t=>t.request));if(!this.url||!e)throw new Error("No url");const r=this.#t.clone();r.body=e;return(await r.send()).bodyJson};batchSendMultiCall=async t=>{const e=t.map((t=>({callData:t.request.params[0].data,target:t.request.params[0].to})));return(await this._multicallContract.aggregate(e))[1].map((t=>({result:t})))}}export{a as JsonRpcBatchInternal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=[{inputs:[{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall.Call[]",name:"calls",type:"tuple[]"}],name:"aggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes[]",name:"returnData",type:"bytes[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"}],name:"getBlockHash",outputs:[{internalType:"bytes32",name:"blockHash",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockCoinbase",outputs:[{internalType:"address",name:"coinbase",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockDifficulty",outputs:[{internalType:"uint256",name:"difficulty",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockGasLimit",outputs:[{internalType:"uint256",name:"gaslimit",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockTimestamp",outputs:[{internalType:"uint256",name:"timestamp",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"addr",type:"address"}],name:"getEthBalance",outputs:[{internalType:"uint256",name:"balance",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLastBlockHash",outputs:[{internalType:"bytes32",name:"blockHash",type:"bytes32"}],stateMutability:"view",type:"function"}];export{t as default};
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export { BitcoinHistoryTx, BitcoinInputUTXO, BitcoinInputUTXOWithOptionalScript, BitcoinLedgerInputUTXO, BitcoinOutputUTXO, BitcoinTx } from './BitcoinVM/models.js';
|
|
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';
|
|
21
|
+
export { getAppEth } from './EVM/utils/getAppEth.js';
|
|
22
|
+
export { getVoidSigner } from './EVM/utils/getVoidSigner.js';
|
|
23
|
+
export { getWalletFromMnemonic } from './EVM/utils/getWalletFromMnemonic.js';
|
|
24
|
+
export { isERC20Transfer, isNativeTxn, onBalanceChange } from './EVM/utils/blockPolling.js';
|
|
25
|
+
export { JsonRpcBatchInternal } from './EVM/utils/jsonRpcBatchProvider.js';
|
|
26
|
+
export { getAddressPrivateKeyFromXPriv } from './EVM/utils/getAddressPrivateKeyFromXPriv.js';
|
|
27
|
+
export { getAddressPublicKeyFromXPub } from './EVM/utils/getAddressPublicKeyFromXPub.js';
|
|
28
|
+
export { getAddressFromXPub } from './EVM/utils/getAddressFromXPub.js';
|
|
29
|
+
export { getXpubFromMnemonic } from './EVM/utils/getXpubFromMnemonic.js';
|
|
30
|
+
export { getEvmAddressFromPubKey } from './EVM/utils/getEvmAddressFromPubKey.js';
|
|
31
|
+
export { getBtcAddressFromPubKey } from './EVM/utils/getBtcAddressFromPubKey.js';
|
|
32
|
+
export { DerivationPath, ETH_ACCOUNT_PATH, ETH_COIN_PATH } from './EVM/constants.js';
|
|
33
|
+
export { LedgerSigner } from './EVM/LedgerSigner.js';
|
|
34
|
+
import * as index from './Avalanche/index.js';
|
|
35
|
+
export { index as Avalanche };
|
|
36
|
+
export { getAddressDerivationPath } from './utils/getAddressDerivationPath.js';
|
|
37
|
+
export { getPublicKeyFromPrivateKey } from './utils/getPublicKeyFromPrivateKey.js';
|
|
38
|
+
export { getPubKeyFromTransport } from './utils/getPubKeyFromTransport.js';
|
|
39
|
+
export { getLedgerExtendedPublicKey } from './utils/getLedgerExtendedPublicKey.js';
|
|
40
|
+
export { omitUndefinedKeys } from './utils/omitUndefinedKeys.js';
|
|
41
|
+
export { getLedgerAppInfo } from './utils/getLedgerAppInfo.js';
|
|
42
|
+
export { openLedgerApp } from './utils/openLedgerApp.js';
|
|
43
|
+
export { quitLedgerApp } from './utils/quitLedgerApp.js';
|
package/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{BitcoinProviderAbstract}from"./BitcoinVM/providers/BitcoinProviderAbstract.js";export{BitcoinProvider}from"./BitcoinVM/providers/BitcoinProvider.js";export{addEncodedSigToPsbt}from"./BitcoinVM/utils/addEncodedSigToPsbt.js";export{createPsbt}from"./BitcoinVM/utils/createPsbt.js";export{createTransferTx}from"./BitcoinVM/utils/createTransferTx.js";export{formatAddressForNetworkBech32}from"./BitcoinVM/utils/formatAddressForNetworkBech32.js";export{getBech32Address}from"./BitcoinVM/utils/getBech32Address.js";export{getBech32AddressFromXPub}from"./BitcoinVM/utils/getBech32AddressFromXPub.js";export{getMaxTransferAmount}from"./BitcoinVM/utils/getMaxTransferAmount.js";export{selectUtxos}from"./BitcoinVM/utils/selectUtxos.js";export{createWalletPolicy}from"./BitcoinVM/utils/createWalletPolicy.js";export{createPSBTV2}from"./BitcoinVM/utils/createPSBTV2.js";export{psbt2ToPsbt0}from"./BitcoinVM/utils/psbt2ToPsbt0.js";export{getTransferTxDetails}from"./BitcoinVM/utils/getTransferTxDetails.js";export{BitcoinWalletAbstract}from"./BitcoinVM/wallets/BitcoinWalletAbstract.js";export{BitcoinWallet}from"./BitcoinVM/wallets/BitcoinWallet.js";export{BitcoinLedgerWallet}from"./BitcoinVM/wallets/BitcoinWalletLedger.js";export{BitcoinWalletVoid}from"./BitcoinVM/wallets/BitcoinWalletVoid.js";export{networks as BtcNetworks}from"bitcoinjs-lib";export{getAppEth}from"./EVM/utils/getAppEth.js";export{getVoidSigner}from"./EVM/utils/getVoidSigner.js";export{getWalletFromMnemonic}from"./EVM/utils/getWalletFromMnemonic.js";export{isERC20Transfer,isNativeTxn,onBalanceChange}from"./EVM/utils/blockPolling.js";export{JsonRpcBatchInternal}from"./EVM/utils/jsonRpcBatchProvider.js";export{getAddressPrivateKeyFromXPriv}from"./EVM/utils/getAddressPrivateKeyFromXPriv.js";export{getAddressPublicKeyFromXPub}from"./EVM/utils/getAddressPublicKeyFromXPub.js";export{getAddressFromXPub}from"./EVM/utils/getAddressFromXPub.js";export{getXpubFromMnemonic}from"./EVM/utils/getXpubFromMnemonic.js";export{getEvmAddressFromPubKey}from"./EVM/utils/getEvmAddressFromPubKey.js";export{getBtcAddressFromPubKey}from"./EVM/utils/getBtcAddressFromPubKey.js";export{DerivationPath,ETH_ACCOUNT_PATH,ETH_COIN_PATH}from"./EVM/constants.js";export{LedgerSigner}from"./EVM/LedgerSigner.js";import*as e from"./Avalanche/index.js";export{e as Avalanche};export{getAddressDerivationPath}from"./utils/getAddressDerivationPath.js";export{getPublicKeyFromPrivateKey}from"./utils/getPublicKeyFromPrivateKey.js";export{getPubKeyFromTransport}from"./utils/getPubKeyFromTransport.js";export{getLedgerExtendedPublicKey}from"./utils/getLedgerExtendedPublicKey.js";export{omitUndefinedKeys}from"./utils/omitUndefinedKeys.js";export{getLedgerAppInfo}from"./utils/getLedgerAppInfo.js";export{openLedgerApp}from"./utils/openLedgerApp.js";export{quitLedgerApp}from"./utils/quitLedgerApp.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(t,e,r){let n=0,o=t.length-1;if(e(t)<=r)return o;let l=-1;for(;n<=o;){const f=Math.floor((n+o)/2);e(t.slice(0,f+1))<=r?(l=f,n=f+1):o=f-1}return l}export{t as binarySearch};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DerivationPath } from '../EVM/constants.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get the derivation path used by wallet addresses
|
|
5
|
+
* @param addressIndex Which index is the address on
|
|
6
|
+
* @param pathSpec BIP44 vs LedgerLive
|
|
7
|
+
* @param vm Which VM is this address on. Coin index changes between Avalanche and EVM
|
|
8
|
+
*/
|
|
9
|
+
declare function getAddressDerivationPath(addressIndex: number, pathSpec: DerivationPath, vm: 'EVM' | 'AVM' | 'PVM'): string;
|
|
10
|
+
|
|
11
|
+
export { getAddressDerivationPath };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DerivationPath as n}from"../EVM/constants.js";function t(t,o,r){if(t<0)throw new Error("Account index can not be less than 0.");const c="EVM"===r?"60":"9000";return o==n.BIP44?`m/44'/${c}'/0'/0/${t}`:`m/44'/${c}'/${t}'/0/0`}export{t as getAddressDerivationPath};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Transport from '@ledgerhq/hw-transport';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get application name and version.
|
|
5
|
+
* @see https://developers.ledger.com/docs/transport/open-close-info-on-apps/#get-information
|
|
6
|
+
* @param transport
|
|
7
|
+
*/
|
|
8
|
+
declare function getLedgerAppInfo(transport: Transport): Promise<{
|
|
9
|
+
applicationName: string;
|
|
10
|
+
version: string;
|
|
11
|
+
}>;
|
|
12
|
+
|
|
13
|
+
export { getLedgerAppInfo };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function a(a){const n=await a.send(176,1,0,0),r=n.readUInt8(1),t=n.readUInt8(2+r),i=n.subarray(2,2+r),s=n.subarray(2+r+1,2+r+1+t);return{applicationName:i.toString("ascii"),version:s.toString("ascii")}}export{a as getLedgerAppInfo};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Transport from '@ledgerhq/hw-transport';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns an extended public key for address derivation.
|
|
5
|
+
* @remarks Returns the extended public key for the given `path` (`m/44'/60'/0'` by default). This key can be used to derive addresses.
|
|
6
|
+
* @param transport
|
|
7
|
+
* @param display
|
|
8
|
+
* @param path
|
|
9
|
+
*/
|
|
10
|
+
declare function getLedgerExtendedPublicKey(transport: Transport, display?: boolean, path?: string): Promise<string>;
|
|
11
|
+
|
|
12
|
+
export { getLedgerExtendedPublicKey };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getAppEth as e}from"../EVM/utils/getAppEth.js";import o from"hdkey";import{Buffer as t}from"buffer";import{ETH_ACCOUNT_PATH as r}from"../EVM/constants.js";async function i(i,n=!1,m){const p=e(i),c=await p.getAddress(m??r,n,!0),f=new o;return f.publicKey=t.from(c.publicKey,"hex"),f.chainCode=t.from(c.chainCode,"hex"),f.publicExtendedKey}export{i as getLedgerExtendedPublicKey};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Transport from '@ledgerhq/hw-transport';
|
|
2
|
+
import { DerivationPath } from '../EVM/constants.js';
|
|
3
|
+
import { VM } from '@avalabs/avalanchejs';
|
|
4
|
+
|
|
5
|
+
declare function getPubKeyFromTransport(t: Transport, accountIndex: number, pathType: DerivationPath, vm?: VM): Promise<Buffer>;
|
|
6
|
+
|
|
7
|
+
export { getPubKeyFromTransport };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getAppEth as t}from"../EVM/utils/getAppEth.js";import{getAddressDerivationPath as r}from"./getAddressDerivationPath.js";async function e(e,o,s,i="EVM"){const f=t(e),n=r(o,s,i),p=await f.getAddress(n,!1,!1);return Buffer.from(p.publicKey,"hex")}export{e as getPubKeyFromTransport};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the public key from a given private key.
|
|
3
|
+
* @param {(string | Buffer)} privateKey - The string or (hex encoded) byte sequence representation of the private key
|
|
4
|
+
* @throws Will throw an error for invalid private keys
|
|
5
|
+
*/
|
|
6
|
+
declare function getPublicKeyFromPrivateKey(privateKey: string | Buffer): Buffer;
|
|
7
|
+
|
|
8
|
+
export { getPublicKeyFromPrivateKey };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{secp256k1 as f}from"@avalabs/avalanchejs";function r(r){const e=Buffer.isBuffer(r)?r:Buffer.from(r,"hex");try{return Buffer.from(f.getPublicKey(e))}finally{e.fill(0)}}export{r as getPublicKeyFromPrivateKey};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return Object.keys(e).reduce(((r,t)=>(void 0!==e[t]&&(r[t]=e[t]),r)),{})}export{e as omitUndefinedKeys};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Transport from '@ledgerhq/hw-transport';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Open a given application on the connected Hardware Wallet, based on its ASCII name. If successfully processed, it triggers a specific display on the product’s screen, asking the user for a confirmation before actually opening the application.
|
|
5
|
+
* @see https://developers.ledger.com/docs/transport/open-close-info-on-apps/#open-application
|
|
6
|
+
*/
|
|
7
|
+
declare function openLedgerApp(transport: Transport, applicationName: string): Promise<boolean>;
|
|
8
|
+
|
|
9
|
+
export { openLedgerApp };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function r(r,e){try{return(await r.send(224,216,0,0,Buffer.from(e,"ascii"))).equals(Buffer.from([144,0]))}catch(r){return!1}}export{r as openLedgerApp};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Transport from '@ledgerhq/hw-transport';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Quit the current ledger app.
|
|
5
|
+
* @see https://developers.ledger.com/docs/transport/open-close-info-on-apps/#quit-application
|
|
6
|
+
* @param transport
|
|
7
|
+
*/
|
|
8
|
+
declare function quitLedgerApp(transport: Transport): Promise<Buffer>;
|
|
9
|
+
|
|
10
|
+
export { quitLedgerApp };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function n(n){return await n.send(176,167,0,0)}export{n as quitLedgerApp};
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@avalabs/core-wallets-sdk",
|
|
3
|
+
"version": "2.8.0-alpha.197",
|
|
4
|
+
"license": "Limited Ecosystem License",
|
|
5
|
+
"private": false,
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "esm/index.js",
|
|
8
|
+
"typings": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"esm"
|
|
12
|
+
],
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "restricted"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"start": "rollup -c --watch",
|
|
19
|
+
"build": "rollup -c",
|
|
20
|
+
"lint": "eslint --fix -c ./.eslintrc.js \"src/**/*.ts*\"",
|
|
21
|
+
"test": "jest",
|
|
22
|
+
"test:path": "jest --watch --testPathPattern",
|
|
23
|
+
"test:watch": "jest --watch"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@babel/preset-env": "7.22.20",
|
|
27
|
+
"@types/create-hash": "1.2.2",
|
|
28
|
+
"@types/hdkey": "2.0.1",
|
|
29
|
+
"@types/jest": "29.5.12",
|
|
30
|
+
"babel-jest": "29.7.0",
|
|
31
|
+
"ethers": "6.7.1",
|
|
32
|
+
"jest": "29.7.0",
|
|
33
|
+
"ts-jest": "29.1.2"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@avalabs/avalanchejs": "4.0.5",
|
|
37
|
+
"@avalabs/chains-sdk": "2.8.0-alpha.197",
|
|
38
|
+
"@avalabs/glacier-sdk": "2.8.0-alpha.197",
|
|
39
|
+
"@avalabs/hw-app-avalanche": "0.14.1",
|
|
40
|
+
"@ledgerhq/hw-app-btc": "10.2.4",
|
|
41
|
+
"@ledgerhq/hw-app-eth": "6.36.1",
|
|
42
|
+
"@ledgerhq/hw-transport": "6.30.6",
|
|
43
|
+
"@metamask/eth-sig-util": "7.0.2",
|
|
44
|
+
"@openzeppelin/contracts": "4.9.6",
|
|
45
|
+
"bip32": "2.0.6",
|
|
46
|
+
"bip32-path": "0.4.2",
|
|
47
|
+
"bip39": "3.0.4",
|
|
48
|
+
"bitcoinjs-lib": "5.2.0",
|
|
49
|
+
"coinselect": "3.1.13",
|
|
50
|
+
"create-hash": "1.2.0",
|
|
51
|
+
"hdkey": "2.0.1",
|
|
52
|
+
"ledger-bitcoin": "0.2.3",
|
|
53
|
+
"xss": "1.0.14"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"ethers": "^6.7.1"
|
|
57
|
+
}
|
|
58
|
+
}
|