@avalabs/core-wallets-sdk 3.1.0-canary.49a66d7.0 → 3.1.0-canary.4bb44cd.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +166 -44
- package/dist/index.js +1 -1
- package/esm/Avalanche/index.d.ts +2 -3
- package/esm/Avalanche/index.js +1 -1
- package/esm/Avalanche/models.d.ts +42 -3
- package/esm/Avalanche/models.js +1 -1
- package/esm/Avalanche/providers/AbstractProvider.d.ts +5 -6
- package/esm/Avalanche/providers/AbstractProvider.js +1 -1
- package/esm/Avalanche/providers/JsonRpcProvider.d.ts +1 -0
- package/esm/Avalanche/providers/JsonRpcProvider.js +1 -1
- package/esm/Avalanche/providers/constants.d.ts +2 -1
- package/esm/Avalanche/providers/constants.js +1 -1
- package/esm/Avalanche/providers/platformFeeConfig.js +1 -1
- package/esm/Avalanche/utils/appendDisableAuthAddressMaps.js +1 -0
- package/esm/Avalanche/utils/convertGlacierUtxo.d.ts +2 -2
- package/esm/Avalanche/utils/createAvalancheUnsignedTx.js +1 -1
- package/esm/Avalanche/utils/getAssetBalance.js +1 -1
- package/esm/Avalanche/utils/getChainAliasByChainId.js +1 -1
- package/esm/Avalanche/utils/getUtxosByTxFromGlacier.d.ts +3 -2
- package/esm/Avalanche/utils/getUtxosByTxFromGlacier.js +1 -1
- package/esm/Avalanche/utils/handleSubnetAuth.js +1 -1
- package/esm/Avalanche/utils/orderBy.js +1 -0
- package/esm/Avalanche/utils/parseAvalancheTx.d.ts +7 -1
- package/esm/Avalanche/utils/parseAvalancheTx.js +1 -1
- package/esm/Avalanche/utils/parsers/index.js +1 -1
- package/esm/Avalanche/utils/parsers/parseConvertSubnetToL1Tx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseDisableL1ValidatorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseIncreaseL1ValidatorBalanceTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseRegisterL1ValidatorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseSetL1ValidatorWeightTx.js +1 -0
- package/esm/Avalanche/utils/parsers/utils/chainIdToVm.js +1 -1
- package/esm/Avalanche/utils/sortUTXOs.d.ts +5 -4
- package/esm/Avalanche/utils/sortUTXOs.js +1 -1
- package/esm/Avalanche/utils/txSizeLimits.d.ts +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 +70 -1
- package/esm/Avalanche/wallets/WalletAbstract.d.ts +7 -9
- 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/BitcoinVM/providers/BitcoinProvider.d.ts +3 -3
- package/esm/BitcoinVM/providers/BitcoinProvider.js +1 -1
- package/package.json +6 -6
- package/esm/Avalanche/utils/getUtxoInfo.d.ts +0 -13
- package/esm/Avalanche/utils/getUtxoInfo.js +0 -1
- package/esm/Avalanche/utils/parsers/parseAddDelegatorTx.js +0 -1
- package/esm/Avalanche/utils/parsers/parseAddValidatorTx.js +0 -1
- package/esm/Avalanche/utils/parsers/parseTransformSubnetTx.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Common as e}from"@avalabs/avalanchejs";const t={weights:e.createDimensions({bandwidth:1,dbRead:
|
|
1
|
+
import{Common as e}from"@avalabs/avalanchejs";const t={weights:e.createDimensions({bandwidth:1,dbRead:1e3,dbWrite:1e3,compute:4}),maxCapacity:BigInt(1e6),maxPerSecond:BigInt(1e5),targetPerSecond:BigInt(5e4),minPrice:BigInt(1),excessConversionConstant:BigInt(2164043)};export{t as platformFeeConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{utils as a}from"@avalabs/avalanchejs";async function e(e,r,t){try{const{deactivationOwner:s}=await t.getApiP().getL1Validator(r.validationId.toString()),i=r.getDisableAuth().values(),n=s.addresses.reduce(((a,e,r)=>(i.includes(r)&&a.push([e,r]),a)),[]);return e.push(new a.AddressMap(n)),e}catch(a){throw new Error(`Error while preparing disableAuth data: ${a.message}`)}}export{e as appendDisableAuthAddressMaps};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Utxo as Utxo$1, TransferOutput, pvmSerial } from '@avalabs/avalanchejs';
|
|
2
|
-
import { Utxo, PChainUtxo } from '@avalabs/glacier-sdk';
|
|
2
|
+
import { Utxo, PChainUtxo, Network } from '@avalabs/glacier-sdk';
|
|
3
3
|
|
|
4
4
|
type GlacierOutput = Utxo | PChainUtxo;
|
|
5
|
-
declare const convertGlacierUtxo: (glacierUtxo: GlacierOutput,
|
|
5
|
+
declare const convertGlacierUtxo: (glacierUtxo: GlacierOutput, network: Network) => Utxo$1<TransferOutput | pvmSerial.StakeableLockOut<TransferOutput>>;
|
|
6
6
|
|
|
7
7
|
export { GlacierOutput, convertGlacierUtxo };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsignedTx as r,utils as
|
|
1
|
+
import{UnsignedTx as e,pvmSerial as r,utils as a}from"@avalabs/avalanchejs";import{isSubnetTx as t,handleSubnetAuth as s}from"./handleSubnetAuth.js";import{appendDisableAuthAddressMaps as n}from"./appendDisableAuthAddressMaps.js";const{getTransferableInputsByTx:o,AddressMaps:i}=a,d=async({tx:a,fromAddressBytes:d,provider:p,credentials:l,utxos:u})=>{const f=o(a);let m=i.fromTransferableInputs(f,u,BigInt(Math.floor((new Date).getTime()/1e3)),d);if(t(a))try{const r=await s({tx:a,provider:p,addressMaps:m});return new e(a,u,r,l)}catch(e){throw new Error(`Error while preparing subnet authorization data: ${e.message}`)}else r.isDisableL1ValidatorTx(a)&&(m=await n(m,a,p));return new e(a,u,m,l)};export{d as createAvalancheUnsignedTx,d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{utils as t}from"@avalabs/avalanchejs";import{getUnixNow as e}from"./getUnixNow.js";const{getUtxoInfo:a}=t;function o(t,o){const l=t.getAssetDict()[o],i={locked:BigInt(0),available:BigInt(0),multisig:BigInt(0),lockedStakeable:BigInt(0),total:BigInt(0)};if(!l)return i;const n=l.getUTXOs(),c=e();return n.forEach((t=>{const e=a(t);i[e.threshold>1?"multisig":e.locktime>c?"locked":e.stakeableLocktime>c?"lockedStakeable":"available"]+=e.amount})),i.total=i.locked+i.lockedStakeable+i.multisig+i.available,i}export{o as getAssetBalance};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"@avalabs/avalanchejs";import"@avalabs/core-utils-sdk";import"ethers";import{FujiContext as
|
|
1
|
+
import{Network as r}from"@avalabs/glacier-sdk";import"@avalabs/avalanchejs";import"@avalabs/core-utils-sdk";import"ethers";import{DevnetContext as a,FujiContext as o,MainnetContext as i}from"../providers/constants.js";import"@avalabs/core-chains-sdk";const n=(n,s)=>{const t=s===r.FUJI,c=s===r.DEVNET,{cBlockchainID:e,xBlockchainID:l,pBlockchainID:p}=c?a:t?o:i;if(e===n)return"C";if(l===n)return"X";if(p===n)return"P";throw new Error(`Unknown chainId "${n}"`)};export{n as getChainAliasByChainId};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import * as _avalabs_avalanchejs_dist_serializable_common_types from '@avalabs/avalanchejs/dist/serializable/common/types';
|
|
2
|
+
import { Network } from '@avalabs/glacier-sdk';
|
|
2
3
|
import { Utxo } from '@avalabs/avalanchejs';
|
|
3
4
|
import { ChainIDAlias } from '../models.js';
|
|
4
5
|
|
|
5
6
|
type Params = {
|
|
6
7
|
transactionHex: string;
|
|
7
8
|
chainAlias: ChainIDAlias;
|
|
8
|
-
|
|
9
|
+
network: Network;
|
|
9
10
|
url: string;
|
|
10
11
|
token?: string;
|
|
11
12
|
headers?: Record<string, string>;
|
|
12
13
|
};
|
|
13
|
-
declare const getUtxosByTxFromGlacier: ({ transactionHex, chainAlias,
|
|
14
|
+
declare const getUtxosByTxFromGlacier: ({ transactionHex, chainAlias, network, url, token, headers, }: Params) => Promise<Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[]>;
|
|
14
15
|
|
|
15
16
|
export { getUtxosByTxFromGlacier };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Glacier as t,
|
|
1
|
+
import{Glacier as t,BlockchainId as r}from"@avalabs/glacier-sdk";import{evmSerial as o,utils as e,avmSerial as n,pvmSerial as a,PVM as i,AVM as s,EVM as x}from"@avalabs/avalanchejs";import{getVmByChainAlias as c}from"./getVmByChainAlias.js";import{convertGlacierUtxo as u}from"./convertGlacierUtxo.js";const{getTransferableInputsByTx:I,hexToBuffer:p,unpackWithManager:f}=e,h=async({transactionHex:e,chainAlias:h,network:l,url:m,token:d,headers:w})=>{const D=c(h),g=p(e),T=f(D,g);if(o.isExportTx(T))return[];const E=(t=>{if(o.isImportTx(t)||n.isImportTx(t)||a.isImportTx(t))return t.sourceChain.toString();const e=t.getVM();switch(e){case x:return r.C_CHAIN;case s:return r.X_CHAIN;case i:return r.P_CHAIN;default:throw new Error(`Unable to get chain for VM type "${e}"`)}})(T),H=I(T),b=new t({BASE:m,TOKEN:d,HEADERS:w}),k=[...new Set(H.map((t=>t.utxoID.txID.toString())))],A=await Promise.all(k.map((t=>b.primaryNetworkTransactions.getTxByHash({blockchainId:E,network:l,txHash:t}))));return H.reduce(((t,r)=>{const o=A.find((t=>t.txHash===r.utxoID.txID.toString()));if(!o)throw new Error(`Unable to find parent tx "${r.utxoID.txID.toString()}"`);const e=o.emittedUtxos.find((t=>t.utxoId===r.utxoID.ID()));if(!e)throw new Error(`Unable to find UTXO "${r.utxoID.ID()}" at index "${r.utxoID.outputIdx.value()}"`);const n=u(e,l);return t.push(n),t}),[])};export{h as getUtxosByTxFromGlacier};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as e,utils as s}from"@avalabs/avalanchejs";const t
|
|
1
|
+
import{pvmSerial as e,OutputOwners as t,utils as s}from"@avalabs/avalanchejs";const a=t=>e.isCreateChainTx(t)||e.isAddSubnetValidatorTx(t)||e.isRemoveSubnetValidatorTx(t)||e.isTransformSubnetTx(t)||e.isTransferSubnetOwnershipTx(t)||e.isConvertSubnetToL1Tx(t),r=async({tx:e,provider:a,addressMaps:r})=>{const n=e.getSubnetAuth().values(),i=await a.getApiP().getSubnet({subnetID:e.getSubnetID().value()}),u=t.fromNative(i.controlKeys.map((e=>s.parse(e)[2])),BigInt(i.locktime),Number(i.threshold)).addrs.reduce(((e,t,s)=>(n.includes(s)&&e.push([t,s]),e)),[]);return r.push(new s.AddressMap(u)),r};export{r as handleSubnetAuth,a as isSubnetTx};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(r,t,n){return[...r].sort(((r,e)=>{for(let o=0;o<t.length;o++){const u=t[o];if(r[u]>e[u])return"asc"===n?1:-1;if(r[u]<e[u])return"asc"===n?-1:1}return 0}))}export{r as orderBy};
|
|
@@ -2,9 +2,15 @@ import { Common } from '@avalabs/avalanchejs';
|
|
|
2
2
|
import { Tx } from '../models.js';
|
|
3
3
|
import { JsonRpcProvider } from '../providers/JsonRpcProvider.js';
|
|
4
4
|
|
|
5
|
+
type ParseOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Tolerance percentage range where the burned amount is considered valid.
|
|
8
|
+
*/
|
|
9
|
+
feeTolerance?: number;
|
|
10
|
+
};
|
|
5
11
|
/**
|
|
6
12
|
* Returns human readable data from a given a transaction buffer,
|
|
7
13
|
*/
|
|
8
|
-
declare function parseAvalancheTx(unsignedTx: Common.UnsignedTx, provider: JsonRpcProvider, currentAddress: string): Promise<Tx>;
|
|
14
|
+
declare function parseAvalancheTx(unsignedTx: Common.UnsignedTx, provider: JsonRpcProvider, currentAddress: string, { feeTolerance }?: ParseOptions): Promise<Tx>;
|
|
9
15
|
|
|
10
16
|
export { parseAvalancheTx };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{evmSerial as t,utils as e}from"@avalabs/avalanchejs";import{TxType as n}from"../models.js";import a from"./parsers/index.js";const{getBurnedAmountByTx:r,getOutputAmounts:o,getInputAmounts:s,validateBurnedAmount:
|
|
1
|
+
import{evmSerial as t,utils as e}from"@avalabs/avalanchejs";import{TxType as n}from"../models.js";import a from"./parsers/index.js";const{getBurnedAmountByTx:r,getOutputAmounts:o,getInputAmounts:s,validateBurnedAmount:i}=e;async function u(e,u,g,{feeTolerance:x=50}={}){try{const n=u.getContext(),c=e.getTx(),p=(t=>{for(const e of Object.values(a)){const n=e(t);if(null!==n)return n}throw new Error("no parser found for tx")})(c),d=r(c,n),A=o(c),l=s(c).get(n.avaxAssetID)??BigInt(0),m=d.get(n.avaxAssetID)??BigInt(0),I=A.get(n.avaxAssetID)??BigInt(0);let v,f=BigInt(0);t.isImportExportTx(c)?f=await u.getApiC().getBaseFee()/BigInt(1e9):"PVM"===c.vm&&(v=u.getUpgradesInfo(),f=await u.getApiP().getFeeState().then((t=>t.price)).catch((()=>BigInt(0))));const{isValid:B,txFee:w}=i({unsignedTx:e,context:n,burnedAmount:m,baseFee:f,feeTolerance:x});return await p({feeData:{totalAvaxBurned:m,totalAvaxOutput:I,totalAvaxInput:l,isValidAvaxBurnedAmount:B,txFee:w},assetId:n.avaxAssetID,provider:u,currentAddress:g})}catch(t){return{type:n.Unknown}}}export{u as parseAvalancheTx};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"./
|
|
1
|
+
import r from"./parseCreateSubnetTx.js";import e from"./parseCreateChainTx.js";import a from"./parseAddSubnetValidorTx.js";import s from"./parseImportTx.js";import o from"./parseExportTx.js";import t from"./parseBaseTx.js";import p from"./parseAddPermissionlessValidatorTx.js";import i from"./parseAddPermissionlessDelegatorTx.js";import m from"./parseRemoveSubnetValidatorTx.js";import x from"./parseTransferSubnetOwnershipTx.js";import T from"./parseConvertSubnetToL1Tx.js";import d from"./parseRegisterL1ValidatorTx.js";import n from"./parseSetL1ValidatorWeightTx.js";import l from"./parseDisableL1ValidatorTx.js";import f from"./parseIncreaseL1ValidatorBalanceTx.js";var j={parseCreateSubnetTx:r,parseCreateChainTx:e,parseAddSubnetValidatorTx:a,parseRemoveSubnetValidatorTx:m,parseImportTx:s,parseExportTx:o,parseBaseTx:t,parseAddPermissionlessValidatorTx:p,parseAddPermissionlessDelegatorTx:i,parseTransferSubnetOwnershipTx:x,parseConvertSubnetTx:T,parseRegisterL1ValidatorTx:d,parseIncreaseL1ValidatorBalanceTx:f,parseSetL1ValidatorWeightTx:n,parseDisableL1ValidatorTx:l};export{j as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pvmSerial as e,Address as a,NodeId as n}from"@avalabs/avalanchejs";import{TxType as t}from"../../models.js";const r=r=>e.isConvertSubnetToL1Tx(r)?({feeData:e,provider:o})=>{const s=o.getHrp(),i=e=>`P-${e.toString(s)}`;return{type:t.ConvertSubnetToL1,chain:r.getVM(),managerAddress:i(a.fromHex(r.address.toString("hex"))),validators:r.validators.map((e=>({nodeId:n.fromHex(e.nodeId.toString("hex")).toString(),stake:e.weight.value(),balance:e.balance.value(),remainingBalanceOwners:e.remainingBalanceOwner.addresses.map(i),deactivationOwners:e.deactivationOwner.addresses.map(i)}))),chainID:r.chainID.value(),subnetID:r.subnetID.value(),...e}}:null;export{r as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as t}from"../../models.js";const i=i=>a.isDisableL1ValidatorTx(i)?({feeData:a})=>({type:t.DisableL1Validator,chain:i.getVM(),validationId:i.validationId.toString(),...a}):null;export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";const l=l=>a.isIncreaseL1ValidatorBalanceTx(l)?({feeData:a})=>({type:e.IncreaseL1ValidatorBalance,chain:l.getVM(),balance:l.balance.value(),validationId:l.validationId.toString(),...a}):null;export{l as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";const t=t=>a.isRegisterL1ValidatorTx(t)?({feeData:a})=>({type:e.RegisterL1Validator,chain:t.getVM(),balance:t.balance.value(),...a}):null;export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as t}from"../../models.js";const e=e=>a.isSetL1ValidatorWeightTx(e)?({feeData:a})=>({type:t.SetL1ValidatorWeight,chain:e.getVM(),...a}):null;export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"@avalabs/avalanchejs";import"@avalabs/core-utils-sdk";import"ethers";import{MainnetContext as
|
|
1
|
+
import"@avalabs/avalanchejs";import"@avalabs/core-utils-sdk";import"ethers";import{MainnetContext as c,FujiContext as a,DevnetContext as i}from"../../../providers/constants.js";import"@avalabs/core-chains-sdk";const n=n=>{if([c.xBlockchainID,a.xBlockchainID,i.xBlockchainID].includes(n))return"AVM";if([c.pBlockchainID,a.pBlockchainID,i.pBlockchainID].includes(n))return"PVM";if([c.cBlockchainID,a.cBlockchainID,i.cBlockchainID].includes(n))return"EVM";throw new Error("Unknown chain id. Failed to get alias.")};export{n as default};
|
|
@@ -3,12 +3,13 @@ import { Utxo } from '@avalabs/avalanchejs';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The UTXOs will be sorted in the following order.
|
|
6
|
-
* 1-
|
|
7
|
-
* 2-
|
|
6
|
+
* 1- Highest value unlocked UTXO (for fees)
|
|
7
|
+
* 2- LockedStakeable UTXOs with the highest locktime to lowest
|
|
8
|
+
* 3- Rest of the unlocked UTXOs highest to lowest
|
|
8
9
|
* @remark Does not check for locked UTXOs
|
|
9
10
|
*/
|
|
10
|
-
declare function sortUTXOsStaking(utxos: Utxo[]): Utxo
|
|
11
|
-
declare function sortUTXOsByAmount(utxos: Utxo[], isDescending: boolean): Utxo
|
|
11
|
+
declare function sortUTXOsStaking(utxos: Utxo[]): Utxo[];
|
|
12
|
+
declare function sortUTXOsByAmount(utxos: Utxo[], isDescending: boolean): Utxo[];
|
|
12
13
|
declare const sortUTXOsByAmountDescending: (utxos: Utxo[]) => Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[];
|
|
13
14
|
declare const sortUTXOsByAmountAscending: (utxos: Utxo[]) => Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[];
|
|
14
15
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{utils as t}from"@avalabs/avalanchejs";
|
|
1
|
+
import{utils as t}from"@avalabs/avalanchejs";import{getUnixNow as o}from"./getUnixNow.js";import{orderBy as e}from"./orderBy.js";function a(a){const m=o(),n=a.map((o=>({utxo:o,...t.getUtxoInfo(o)}))),r=n.filter((t=>t.stakeableLocktime<=m)),s=n.filter((t=>t.stakeableLocktime>m)),c=e(r,["amount"],"desc"),i=e(s,["stakeableLocktime","amount"],"desc"),[u,...f]=c;return[...u?[u]:[],...i,...f].map((t=>t.utxo))}function m(o,a){const m=o.map((o=>({utxo:o,...t.getUtxoInfo(o)})));return e(m,["amount"],a?"desc":"asc").map((t=>t.utxo))}const n=t=>m(t,!0),r=t=>m(t,!1);export{m as sortUTXOsByAmount,r as sortUTXOsByAmountAscending,n as sortUTXOsByAmountDescending,a as sortUTXOsStaking};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{utils as e}from"@avalabs/avalanchejs";import{
|
|
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,sortUTXOsByAmountAscending as r,sortUTXOsStaking as n}from"./sortUTXOs.js";const{getUtxoInfo:d}=e;var a=(e=>(e.ExportP="ExportP",e.ImportP="ImportP",e.AddPermissionlessValidator="AddPermissionlessValidator",e.AddPermissionlessDelegator="AddPermissionlessDelegator",e.BaseP="BaseP",e.ConsolidateP="ConsolidateP",e))(a||{});const i="NodeID-8TArWpFgH3sazEH8qP4gUjtGtFMvjw1aR",u="11111111111111111111111111111111LpoYY",c=(e,t)=>e.reduce(((e,t)=>e+d(t).amount),BigInt(0))-t,l={BaseP:{sortFunction:s,unsignedTxBuilder:(t,o,s)=>{const r=t.getProvider().getContext();return t.baseTX({utxoSet:new e.UtxoSet(o),chain:"P",toAddress:t.getCurrentAddress("P"),amountsPerAsset:{[r.avaxAssetID]:c(o,r.baseTxFee)},feeState:s})}},ConsolidateP:{sortFunction:r,unsignedTxBuilder:(t,o,s)=>{const r=t.getProvider().getContext();return t.consolidateP({utxoSet:new e.UtxoSet(o),amount:c(o,r.baseTxFee),feeState:s})}},AddPermissionlessValidator:{sortFunction:n,unsignedTxBuilder:(o,s,r)=>o.addPermissionlessValidator({utxoSet:new e.UtxoSet(s),nodeId:i,start:t(),end:t()+BigInt(1e3),weight:c(s,o.getProvider().getContext().baseTxFee),subnetId:u,shares:5,feeState:r,fromAddresses:void 0,rewardAddresses:void 0,delegatorRewardAddresses:void 0,publicKey:Buffer.from(e.hexToBuffer("0x8f95423f7142d00a48e1014a3de8d28907d420dc33b3052a6dee03a3f2941a393c2351e354704ca66a3fc29870282e15")),signature:Buffer.from(e.hexToBuffer("0x86a3ab4c45cfe31cae34c1d06f212434ac71b1be6cfe046c80c162e057614a94a5bc9f1ded1a7029deb0ba4ca7c9b71411e293438691be79c2dbf19d1ca7c3eadb9c756246fc5de5b7b89511c7d7302ae051d9e03d7991138299b5ed6a570a98"))})},AddPermissionlessDelegator:{sortFunction:n,unsignedTxBuilder:(o,s,r)=>o.addPermissionlessDelegator({utxoSet:new e.UtxoSet(s),nodeId:i,start:t(),end:t()+BigInt(1e3),weight:c(s,o.getProvider().getContext().baseTxFee),subnetId:u,feeState:r})},ExportP:{sortFunction:s,unsignedTxBuilder:(t,o,s)=>t.exportP({amount:c(o,t.getProvider().getContext().baseTxFee),utxoSet:new e.UtxoSet(o),destination:"X",feeState:s})},ImportP:{sortFunction:s,unsignedTxBuilder:(t,o,s)=>t.importP({utxoSet:new e.UtxoSet(o),sourceChain:"X",feeState:s})}},x=65536;function f({wallet:e,utxos:s,sizeSupportedTx:r,limit:n=65536,feeState:a}){const{sortFunction:i,unsignedTxBuilder:u}=l[r],c=t(),x=i(s.filter((e=>{const{locktime:t,stakeableLocktime:o}=d(e);return t<c&&(o<c||("AddPermissionlessDelegator"===r||"AddPermissionlessValidator"===r))}))),f=o(x,(t=>{try{return function(e){const t=e.getInputUtxos().reduce(((e,t)=>e+(8+65*d(t).threshold)),0);return 6+e.toBytes().length+t}(u(e,t,a))}catch(e){return console.log("Unable to estimate size of utxos",{e:e,utxos:t.map(d)}),n+1}}),n);return-1===f?[]:x.slice(0,f+1)}export{x as P_CHAIN_TX_SIZE_LIMIT,a as SizeSupportedTx,f as getMaximumUtxoSet};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{WalletAbstract as s}from"./WalletAbstract.js";import"@avalabs/avalanchejs";import"../utils/populateCredential.js";import"@avalabs/core-utils-sdk";import{isAddress as e}from"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"bip32";import"
|
|
1
|
+
import{WalletAbstract as s}from"./WalletAbstract.js";import"@avalabs/avalanchejs";import"../utils/populateCredential.js";import"@avalabs/glacier-sdk";import"@avalabs/core-utils-sdk";import{isAddress as e}from"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"bip32";import"bip39";import{isBech32Address as r}from"../utils/isBech32Address.js";import"xss";import"bip32-path";class t extends s{constructor(s,t,a,d,i){if(super(i),this.addressC=s,this.addressCoreEth=t,this.xpAddresses=a,this.xpChangeAddress=d,a.length<1)throw new Error("Must have at least 1 xp address.");if(!e(s))throw new Error("Not a valid C-Chain (EVM) address");if(a.some((s=>!r(s,!1))))throw new Error("Given addresses must be valid avalanche bech32 addresses without the chain alias prefix");if(!r(t,!1))throw new Error("Given CoreEth address must be valid avalanche bech32 addresses without the chain alias prefix");this.setChangeAddress(d)}setChangeAddress(s){if(!r(s,!1))throw new Error("Given address must be valid avalanche bech32 addresses without the chain alias prefix");this.xpChangeAddress=s}getAddressEVM(){return this.addressC}getAddresses(s){return("C"===s?[this.addressCoreEth]:this.xpAddresses).map((e=>this.provider.formatAddress(e,s)))}getChangeAddress(s){const e="C"===s?this.addressCoreEth:this.xpChangeAddress;return this.provider.formatAddress(e,s)}getCurrentAddress(s){const e="C"===s?this.addressCoreEth:this.xpAddresses[0];return this.provider.formatAddress(e,s)}}export{t as AddressWallet};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{addTxSignatures as e,secp256k1 as t}from"@avalabs/avalanchejs";import{fromSeed as i}from"bip32";import{validateMnemonic as r,mnemonicToSeedSync as n}from"bip39";import"@ledgerhq/hw-app-eth";import"ethers";import{getAddressDerivationPath as o}from"../../utils/getAddressDerivationPath.js";import"hdkey";import"buffer";import{DerivationPath as s}from"../../EVM/constants.js";import"@openzeppelin/contracts/build/contracts/ERC20.json";import"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";import"../utils/populateCredential.js";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import{digestMessage as a}from"../utils/digestMessage.js";import"
|
|
1
|
+
import{addTxSignatures as e,secp256k1 as t}from"@avalabs/avalanchejs";import{fromSeed as i}from"bip32";import{validateMnemonic as r,mnemonicToSeedSync as n}from"bip39";import"@ledgerhq/hw-app-eth";import"ethers";import{getAddressDerivationPath as o}from"../../utils/getAddressDerivationPath.js";import"hdkey";import"buffer";import{DerivationPath as s}from"../../EVM/constants.js";import"@openzeppelin/contracts/build/contracts/ERC20.json";import"bitcoinjs-lib";import"@avalabs/core-utils-sdk";import"@ledgerhq/hw-transport";import"@metamask/eth-sig-util";import"../utils/populateCredential.js";import"@avalabs/glacier-sdk";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import{digestMessage as a}from"../utils/digestMessage.js";import"xss";import"bip32-path";class c{accountNodeXP;signerNodeEVM;activeAccountIndex;constructor(e,t){if(!r(e))throw new Error("Invalid mnemonic phrase.");if(t<0||t%1!=0)throw new Error("Invalid account index.");const a=n(e),c=i(a);this.accountNodeXP=c.derivePath("m/44'/9000'/0'");const p=c.derivePath(o(t,s.BIP44,"EVM"));this.signerNodeEVM=p,this.activeAccountIndex=t}getAdditionalKeys(e,t){return[...new Set(e??[])].reduce(((e,i)=>{const r=this.accountNodeXP.derivePath(`${t?1:0}/${i}`);if(!r.privateKey)throw new Error("Unable to get private key.");return e.push(r.privateKey),e}),[])}getSigningKeys(e,t,i){if("EVM"===e){if(!this.signerNodeEVM.privateKey)throw new Error("Unable to derive EVM private key.");return[this.signerNodeEVM.privateKey]}const r=this.accountNodeXP.derivePath(`0/${this.activeAccountIndex}`);if(!r.privateKey)throw new Error("Unable to derive X/P private key.");const n=this.getAdditionalKeys(t,!1);if("AVM"===e){const e=this.getAdditionalKeys(i,!0);return[r.privateKey,...n,...e]}if("PVM"===e)return[r.privateKey,...n]}async signTx(t){const{tx:i,externalIndices:r,internalIndices:n}=t,o=i.getVM(),s=this.getSigningKeys(o,r,n);if(!s?.length)throw new Error("Unable to sign transaction: signing keys are missing.");return await e({unsignedTx:i,privateKeys:s}),t.tx}async signTxBuffer(e){throw new Error("Not implemented")}getActiveAccountNode(e){switch(e){case"X":case"P":return this.accountNodeXP.derivePath(`0/${this.activeAccountIndex}`);case"C":return this.signerNodeEVM}}async signMessage(e){const i=this.getActiveAccountNode(e.chain);if(!i.privateKey)throw Error("Unable to sign message, key not found.");const r=a(e.message),n=await t.signHash(r,i.privateKey);return Buffer.from(n)}}export{c as SimpleSigner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{WalletVoid as i}from"./WalletVoid.js";import{addTxSignatures as r,secp256k1 as e,utils as t}from"@avalabs/avalanchejs";import{validateMnemonic as s,mnemonicToSeedSync as a}from"bip39";import{fromSeed as o}from"bip32";import{digestMessage as n}from"../utils/digestMessage.js";import"../utils/populateCredential.js";import"@avalabs/core-utils-sdk";import"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"
|
|
1
|
+
import{WalletVoid as i}from"./WalletVoid.js";import{addTxSignatures as r,secp256k1 as e,utils as t}from"@avalabs/avalanchejs";import{validateMnemonic as s,mnemonicToSeedSync as a}from"bip39";import{fromSeed as o}from"bip32";import{digestMessage as n}from"../utils/digestMessage.js";import"../utils/populateCredential.js";import"@avalabs/glacier-sdk";import"@avalabs/core-utils-sdk";import"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"xss";import{verifyDerivationPath as p}from"../utils/verifyDerivationPath.js";const{getPublicKey:m,sign:v,signHash:f}=e,{addChecksum:h}=t;class c extends i{privKeyXP;privKeyC;constructor(i,r,e){super(Buffer.from(m(i)),Buffer.from(m(r)),e),this.privKeyXP=i,this.privKeyC=r}static fromMnemonic(i,r,e,t){if(!s(i))throw new Error("Invalid mnemonic phrase.");if(!p(e)||!p(r))throw new Error("Not valid derivation path. Make sure it is a valid BIP44 path starting with m/");const n=a(i),m=o(n),v=m.derivePath(r),f=m.derivePath(e);if(!v.privateKey||!f.privateKey)throw new Error("Failed to generate private keys.");return new c(v.privateKey,f.privateKey,t)}async signMessage(i){const r=n(i.message),e=this.getSigningKey(i.chain);return Buffer.from(h(await f(r,e)))}getSigningKey(i){return"C"===i?this.privKeyC:this.privKeyXP}async signTx(i){return await r({unsignedTx:i.tx,privateKeys:[this.privKeyC,this.privKeyXP]}),i.tx}async signTxBuffer(i){const r=this.getSigningKey(i.chain);return[Buffer.from(await v(i.buffer,r))]}}export{c as StaticSigner};
|
|
@@ -40,6 +40,75 @@ type CreateSubnet = {
|
|
|
40
40
|
threshold?: number;
|
|
41
41
|
locktime?: bigint;
|
|
42
42
|
};
|
|
43
|
+
type CreateChain = {
|
|
44
|
+
utxoSet: utils.UtxoSet;
|
|
45
|
+
subnetId: string;
|
|
46
|
+
chainName: string;
|
|
47
|
+
vmID: string;
|
|
48
|
+
fxIds: string[];
|
|
49
|
+
genesisData: Record<string, unknown>;
|
|
50
|
+
subnetAuth: number[];
|
|
51
|
+
feeState?: pvm.FeeState;
|
|
52
|
+
options?: Common.SpendOptions;
|
|
53
|
+
fromAddresses?: string[];
|
|
54
|
+
};
|
|
55
|
+
type ConvertSubnetToL1 = {
|
|
56
|
+
utxoSet: utils.UtxoSet;
|
|
57
|
+
address: string;
|
|
58
|
+
chainId: string;
|
|
59
|
+
subnetId: string;
|
|
60
|
+
subnetAuth: number[];
|
|
61
|
+
options?: Common.SpendOptions;
|
|
62
|
+
feeState: pvm.FeeState;
|
|
63
|
+
fromAddresses?: string[];
|
|
64
|
+
validators: {
|
|
65
|
+
nodeId: string;
|
|
66
|
+
weight: bigint;
|
|
67
|
+
balance: bigint;
|
|
68
|
+
pubKey: string;
|
|
69
|
+
signature: string;
|
|
70
|
+
remainingBalanceOwner: {
|
|
71
|
+
addresses: string[];
|
|
72
|
+
threshold?: number;
|
|
73
|
+
};
|
|
74
|
+
deactivationOwner: {
|
|
75
|
+
addresses: string[];
|
|
76
|
+
threshold?: number;
|
|
77
|
+
};
|
|
78
|
+
}[];
|
|
79
|
+
};
|
|
80
|
+
type RegisterL1Validator = {
|
|
81
|
+
utxoSet: utils.UtxoSet;
|
|
82
|
+
balance: bigint;
|
|
83
|
+
signature: string;
|
|
84
|
+
feeState: pvm.FeeState;
|
|
85
|
+
message: string;
|
|
86
|
+
options?: Common.SpendOptions;
|
|
87
|
+
fromAddresses?: string[];
|
|
88
|
+
};
|
|
89
|
+
type SetL1ValidatorWeight = {
|
|
90
|
+
utxoSet: utils.UtxoSet;
|
|
91
|
+
feeState: pvm.FeeState;
|
|
92
|
+
message: string;
|
|
93
|
+
options?: Common.SpendOptions;
|
|
94
|
+
fromAddresses?: string[];
|
|
95
|
+
};
|
|
96
|
+
type DisableL1Validator = {
|
|
97
|
+
utxoSet: utils.UtxoSet;
|
|
98
|
+
feeState: pvm.FeeState;
|
|
99
|
+
disableAuth: number[];
|
|
100
|
+
validationId: string;
|
|
101
|
+
options?: Common.SpendOptions;
|
|
102
|
+
fromAddresses?: string[];
|
|
103
|
+
};
|
|
104
|
+
type IncreaseL1ValidatorBalance = {
|
|
105
|
+
utxoSet: utils.UtxoSet;
|
|
106
|
+
feeState: pvm.FeeState;
|
|
107
|
+
balance: bigint;
|
|
108
|
+
validationId: string;
|
|
109
|
+
options?: Common.SpendOptions;
|
|
110
|
+
fromAddresses?: string[];
|
|
111
|
+
};
|
|
43
112
|
type AddSubnetValidator = {
|
|
44
113
|
utxoSet: utils.UtxoSet;
|
|
45
114
|
nodeId: string;
|
|
@@ -107,4 +176,4 @@ type TransferSubnetOwnershipTx = {
|
|
|
107
176
|
locktime?: bigint;
|
|
108
177
|
};
|
|
109
178
|
|
|
110
|
-
export { AddPermissionlessDelegator, AddPermissionlessValidator, AddSubnetValidator, BaseTx, ConsolidateP, CreateSubnet, ExportP, ImportP, RemoveSubnetValidator, TransferSubnetOwnershipTx };
|
|
179
|
+
export { AddPermissionlessDelegator, AddPermissionlessValidator, AddSubnetValidator, BaseTx, ConsolidateP, ConvertSubnetToL1, CreateChain, CreateSubnet, DisableL1Validator, ExportP, ImportP, IncreaseL1ValidatorBalance, RegisterL1Validator, RemoveSubnetValidator, SetL1ValidatorWeight, TransferSubnetOwnershipTx };
|
|
@@ -2,7 +2,7 @@ import * as _avalabs_avalanchejs from '@avalabs/avalanchejs';
|
|
|
2
2
|
import { utils, pvm, Common } from '@avalabs/avalanchejs';
|
|
3
3
|
import { AbstractProvider } from '../providers/AbstractProvider.js';
|
|
4
4
|
import { ChainIDAlias } from '../models.js';
|
|
5
|
-
import { ImportP, ExportP, ConsolidateP, BaseTx, CreateSubnet, AddSubnetValidator, AddPermissionlessValidator, AddPermissionlessDelegator, RemoveSubnetValidator, TransferSubnetOwnershipTx } from './TxBuilderTypes.js';
|
|
5
|
+
import { ImportP, ExportP, ConsolidateP, BaseTx, ConvertSubnetToL1, RegisterL1Validator, SetL1ValidatorWeight, DisableL1Validator, IncreaseL1ValidatorBalance, CreateChain, CreateSubnet, AddSubnetValidator, AddPermissionlessValidator, AddPermissionlessDelegator, RemoveSubnetValidator, TransferSubnetOwnershipTx } from './TxBuilderTypes.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* An abstract class that that is shared by all wallet classes.
|
|
@@ -82,15 +82,14 @@ declare abstract class WalletAbstract {
|
|
|
82
82
|
* @param toAddress
|
|
83
83
|
*/
|
|
84
84
|
exportP({ amount, utxoSet, destination, feeState, toAddress }: ExportP): Common.UnsignedTx;
|
|
85
|
-
addValidator(utxos: utils.UtxoSet, nodeId: string, stakeAmount: bigint, startDate: bigint, endDate: bigint, delegationFee: number, config?: {
|
|
86
|
-
rewardAddress?: string;
|
|
87
|
-
}): Common.UnsignedTx;
|
|
88
|
-
addDelegator(utxos: utils.UtxoSet, nodeId: string, stakeAmount: bigint, startDate: bigint, endDate: bigint, config?: {
|
|
89
|
-
rewardAddress?: string;
|
|
90
|
-
}): Common.UnsignedTx;
|
|
91
85
|
consolidateP({ utxoSet, amount, feeState, toAddress, options, }: ConsolidateP): Common.UnsignedTx;
|
|
92
86
|
baseTX({ utxoSet, chain, toAddress, amountsPerAsset, feeState, options, fromAddresses, }: BaseTx): Common.UnsignedTx;
|
|
93
|
-
|
|
87
|
+
convertSubnetToL1({ utxoSet, chainId, subnetId, subnetAuth, feeState, address, validators, options, fromAddresses, }: ConvertSubnetToL1): Common.UnsignedTx;
|
|
88
|
+
registerL1Validator({ utxoSet, balance, signature, message, feeState, fromAddresses, options, }: RegisterL1Validator): Common.UnsignedTx;
|
|
89
|
+
setL1ValidatorWeight({ utxoSet, feeState, message, options, fromAddresses, }: SetL1ValidatorWeight): Common.UnsignedTx;
|
|
90
|
+
disableL1Validator({ utxoSet, feeState, options, fromAddresses, disableAuth, validationId, }: DisableL1Validator): Common.UnsignedTx;
|
|
91
|
+
increaseL1ValidatorBalance({ utxoSet, feeState, options, fromAddresses, balance, validationId, }: IncreaseL1ValidatorBalance): Common.UnsignedTx;
|
|
92
|
+
createBlockchain({ utxoSet, subnetId, chainName, vmID, fxIds, genesisData, subnetAuth, feeState, options, fromAddresses, }: CreateChain): Common.UnsignedTx;
|
|
94
93
|
createSubnet({ utxoSet, rewardAddresses, feeState, fromAddresses, options, threshold, locktime, }: CreateSubnet): Common.UnsignedTx;
|
|
95
94
|
addSubnetValidator({ utxoSet, nodeId, start, end, weight, subnetId, subnetAuth, feeState, fromAddresses, options, }: AddSubnetValidator): Common.UnsignedTx;
|
|
96
95
|
/**
|
|
@@ -125,7 +124,6 @@ declare abstract class WalletAbstract {
|
|
|
125
124
|
addPermissionlessDelegator({ utxoSet, nodeId, start, end, weight, subnetId, fromAddresses, rewardAddresses, options, locktime, feeState, threshold, stakingAssetId, }: AddPermissionlessDelegator): Common.UnsignedTx;
|
|
126
125
|
removeSubnetValidator({ utxoSet, nodeId, subnetId, subnetAuth, fromAddresses, feeState, options, }: RemoveSubnetValidator): Common.UnsignedTx;
|
|
127
126
|
transferSubnetOwnershipTx({ utxoSet, subnetId, subnetAuth, subnetOwners, feeState, fromAddresses, options, threshold, locktime, }: TransferSubnetOwnershipTx): Common.UnsignedTx;
|
|
128
|
-
transformSubnetTx(utxoSet: utils.UtxoSet, subnetId: string, assetId: string, initialSupply: bigint, maximumSupply: bigint, minConsumptionRate: bigint, maxConsumptionRate: bigint, minValidatorStake: bigint, maxValidatorStake: bigint, minStakeDuration: number, maxStakeDuration: number, minDelegationFee: number, minDelegatorStake: number, maxValidatorWeightFactor: number, uptimeRequirement: number, subnetAuth: number[], fromAddresses?: string[], options?: Common.SpendOptions): Common.UnsignedTx;
|
|
129
127
|
protected constructor(provider: AbstractProvider);
|
|
130
128
|
}
|
|
131
129
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{TransferableOutput as e,avm as t,pvm as s,evm as r,networkIDs as d,utils as i}from"@avalabs/avalanchejs";import"../utils/populateCredential.js";import{strip0x as o}from"@avalabs/core-utils-sdk";import"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"bip32";import{getUTXOsForAddresses as n}from"../utils/getAllUTXOs.js";import{getStakeForAddresses as a}from"../utils/getStakeForAddresses.js";import"@avalabs/glacier-sdk";import"bip39";import"xss";import{sortUTXOsByAmount as h,sortUTXOsStaking as m,sortUTXOsByAmountAscending as g}from"../utils/sortUTXOs.js";import"bip32-path";import{assertFeeStateProvided as p}from"../../utils/assertFeeStateProvided.js";const{parse:u,hexToBuffer:A}=i,c=new Error("Tx type is not supported post-etna");class x{constructor(e){this.provider=e}setProvider(e){this.provider=e}getProvider(){return this.provider}async getUTXOs(e){const t=this.provider.getApi(e);return n(this.getAddresses(e),t)}async getStake(){const e=this.provider.getApiP();return a(this.getAddresses("P"),e)}async getAtomicUTXOs(e,t){if(e===t)throw new Error("Chain can not be the same as source chain.");const s=this.provider.getApi(e),r=this.provider.getChainID(t);return n(this.getAddresses(e),s,{sourceChain:r,addresses:[]})}async getNonce(){const e=this.getAddressEVM();return await this.provider.evmRpc.getTransactionCount(e)}exportX(s,r,d,i){i=i||this.getCurrentAddress(d);const o=u(i)[2],n=this.provider.getAvaxID(),a=e.fromNative(n,s,[o]),m=h(r.getUTXOs(),!0),g=this.provider.getChainID(d),p=this.getAddresses("X").map((e=>u(e)[2])),A=u(this.getChangeAddress("X"))[2];return t.newExportTx(this.provider.getContext(),g,p,m,[a],{threshold:1,changeAddresses:[A]})}importP({utxoSet:e,sourceChain:t,toAddress:r,threshold:d,feeState:i,locktime:o}){const n=this.provider.getChainID(t),a=this.getAddresses("P").map((e=>u(e)[2])),h=u(this.getChangeAddress("P"))[2];r=r||this.getCurrentAddress("P");const m=u(r)[2],g=e.getUTXOs();if(this.provider.isEtnaEnabled()){if(!i)throw new Error("feeState parameter is required post E-upgrade");return s.e.newImportTx({fromAddressesBytes:a,utxos:g,toAddressesBytes:[m],sourceChainId:n,threshold:d,feeState:i,locktime:o},this.provider.getContext())}return s.newImportTx(this.provider.getContext(),n,g,[m],a,{changeAddresses:[h]})}importX(e,s,r){const d=this.provider.getChainID(s),i=this.getAddresses("X").map((e=>u(e)[2])),o=u(this.getChangeAddress("X"))[2];r=r||this.getCurrentAddress("X");const n=u(r)[2];return t.newImportTx(this.provider.getContext(),d,e.getUTXOs(),[n],i,{changeAddresses:[o]})}importC(e,t,s,d,i){const n=this.provider.getChainID(t),a=this.getAddresses("C").map((e=>u(e)[2]));i=i||this.getAddressEVM();const h=Buffer.from(o(i),"hex");return r.newImportTxFromBaseFee(this.provider.getContext(),h,a,e.getUTXOs(),n,s,d)}exportC(e,t,s,d,i){const o=A(this.getAddressEVM()),n=this.provider.getChainID(t);i=i||this.getCurrentAddress(t);const a=u(i)[2],h=d/BigInt(1e9);return r.newExportTxFromBaseFee(this.provider.getContext(),h,e,n,o,[a],s)}exportP({amount:t,utxoSet:r,destination:d,feeState:i,toAddress:o}){o=o||this.getCurrentAddress(d);const n=u(o)[2],a=this.provider.getAvaxID(),m=e.fromNative(a,t,[n]),g=h(r.getUTXOs(),!0),A=this.provider.getChainID(d),c=this.getAddresses("P").map((e=>u(e)[2])),x=u(this.getChangeAddress("P"))[2];return this.provider.isEtnaEnabled()?(p(i),s.e.newExportTx({fromAddressesBytes:c,utxos:g,outputs:[m],destinationChainId:A,feeState:i},this.provider.getContext())):s.newExportTx(this.provider.getContext(),A,c,g,[m],{changeAddresses:[x]})}addValidator(e,t,r,d,i,o,n){const a=m(e.getUTXOs()),h=this.getAddresses("P").map((e=>u(e)[2])),g=n?.rewardAddress||this.getCurrentAddress("P"),p=u(g)[2],A=u(this.getChangeAddress("P"))[2];if(this.provider.isEtnaEnabled())throw c;return s.newAddValidatorTx(this.provider.getContext(),a,h,t,d,i,r,[p],o,{changeAddresses:[A]})}addDelegator(e,t,r,d,i,o){const n=m(e.getUTXOs()),a=this.getAddresses("P").map((e=>u(e)[2])),h=o?.rewardAddress||this.getCurrentAddress("P"),g=u(h)[2],p=u(this.getChangeAddress("P"))[2];if(this.provider.isEtnaEnabled())throw c;return s.newAddDelegatorTx(this.provider.getContext(),n,a,t,d,i,r,[g],{changeAddresses:[p]})}consolidateP({utxoSet:t,amount:r,feeState:d,toAddress:i,options:o}){const n=g(t.getUTXOs());i=i??this.getCurrentAddress("P");const a=u(i)[2],h=this.provider.getContext(),m=[e.fromNative(h.avaxAssetID,r,[a])],A=this.getAddresses("P").map((e=>u(e)[2]));return this.provider.isEtnaEnabled()?(p(d),s.e.newBaseTx({fromAddressesBytes:A,utxos:n,outputs:m,minIssuanceTime:o?.minIssuanceTime,memo:o?.memo,feeState:d},h)):s.newBaseTx(this.provider.getContext(),A,n,m,o)}baseTX({utxoSet:r,chain:d,toAddress:i,amountsPerAsset:o,feeState:n,options:a,fromAddresses:m}){const[g,A,c]=u(i);if(g!==d||A!==this.provider.getHrp())throw new Error(`Invalid recipient address "${i}"`);const x=Object.entries(o).map((([t,s])=>e.fromNative(t,s,[c]))),v=h(r.getUTXOs(),!0),l=(m??this.getAddresses(d)).map((e=>u(e)[2]));return"X"===d?t.newBaseTx(this.provider.getContext(),l,v,x,a):this.provider.isEtnaEnabled()?(p(n),s.e.newBaseTx({fromAddressesBytes:l,utxos:v,outputs:x,minIssuanceTime:a?.minIssuanceTime,memo:a?.memo,feeState:n},this.provider.getContext())):s.newBaseTx(this.provider.getContext(),l,v,x,a)}createBlockchain(e,t,r,d,i,o,n,a,m){const g=h(e.getUTXOs(),!0),p=(m??this.getAddresses("P")).map((e=>u(e)[2]));if(this.provider.isEtnaEnabled())throw c;return s.newCreateBlockchainTx(this.provider.getContext(),g,p,t,r,d,i,o,n,a)}createSubnet({utxoSet:e,rewardAddresses:t,feeState:r,fromAddresses:d,options:i,threshold:o,locktime:n}){const a=h(e.getUTXOs(),!0),m=(d??this.getAddresses("P")).map((e=>u(e)[2])),g=t.map((e=>u(e)[2]));return this.provider.isEtnaEnabled()?(p(r),s.e.newCreateSubnetTx({fromAddressesBytes:m,utxos:a,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,feeState:r,threshold:o,locktime:n,subnetOwners:g},this.provider.getContext())):s.newCreateSubnetTx(this.provider.getContext(),a,m,g,i,o??1,n??BigInt(0))}addSubnetValidator({utxoSet:e,nodeId:t,start:r,end:d,weight:i,subnetId:o,subnetAuth:n,feeState:a,fromAddresses:m,options:g}){const A=h(e.getUTXOs(),!0),c=(m??this.getAddresses("P")).map((e=>u(e)[2]));return this.provider.isEtnaEnabled()?(p(a),s.e.newAddSubnetValidatorTx({fromAddressesBytes:c,utxos:A,minIssuanceTime:g?.minIssuanceTime,memo:g?.memo,nodeId:t,start:r,end:d,weight:i,subnetId:o,subnetAuth:n,feeState:a},this.provider.getContext())):s.newAddSubnetValidatorTx(this.provider.getContext(),A,c,t,r,d,i,o,n,g)}addPermissionlessValidator({utxoSet:e,nodeId:t,start:r,end:i,weight:o,subnetId:n,shares:a,feeState:h,fromAddresses:g,rewardAddresses:A,delegatorRewardAddresses:c,publicKey:x,signature:v,options:l,threshold:T,locktime:f,stakingAssetId:C}){const w=m(e.getUTXOs()),b=(g??this.getAddresses("P")).map((e=>u(e)[2])),I=(A??[this.getCurrentAddress("P")]).map((e=>u(e)[2])),S=(c??[this.getCurrentAddress("P")]).map((e=>u(e)[2]));if(!(n!==d.PrimaryNetworkID.toString()||x&&v))throw new Error("Must provide public key and signature for primary subnet.");const P=u(this.getChangeAddress("P"))[2];if(this.provider.isEtnaEnabled())return p(h),s.e.newAddPermissionlessValidatorTx({fromAddressesBytes:b,delegatorRewardsOwner:S,utxos:w,minIssuanceTime:l?.minIssuanceTime,memo:l?.memo,changeAddressesBytes:l?.changeAddresses?l.changeAddresses:[P],nodeId:t,start:r,end:i,weight:o,subnetId:n,shares:a,feeState:h,publicKey:x,rewardAddresses:I,signature:v,locktime:f,threshold:T,stakingAssetId:C},this.provider.getContext());const E={changeAddresses:[P],...l??{}};return s.newAddPermissionlessValidatorTx(this.provider.getContext(),w,b,t,n,r,i,o,I,S,a,E,void 0,void 0,x,v)}addPermissionlessDelegator({utxoSet:e,nodeId:t,start:r,end:d,weight:i,subnetId:o,fromAddresses:n,rewardAddresses:a,options:h,locktime:g,feeState:A,threshold:c,stakingAssetId:x}){const v=m(e.getUTXOs()),l=(n??this.getAddresses("P")).map((e=>u(e)[2])),T=(a??[this.getCurrentAddress("P")]).map((e=>u(e)[2])),f=u(this.getChangeAddress("P"))[2];if(this.provider.isEtnaEnabled())return p(A),s.e.newAddPermissionlessDelegatorTx({fromAddressesBytes:l,utxos:v,minIssuanceTime:h?.minIssuanceTime,memo:h?.memo,changeAddressesBytes:h?.changeAddresses?h.changeAddresses:[f],nodeId:t,start:r,end:d,weight:i,subnetId:o,rewardAddresses:T,locktime:g,stakingAssetId:x,threshold:c,feeState:A},this.provider.getContext());const C={changeAddresses:[f],...h??{}};return s.newAddPermissionlessDelegatorTx(this.provider.getContext(),v,l,t,o,r,d,i,T,C,void 0,void 0)}removeSubnetValidator({utxoSet:e,nodeId:t,subnetId:r,subnetAuth:d,fromAddresses:i,feeState:o,options:n}){const a=h(e.getUTXOs(),!0),m=(i??this.getAddresses("P")).map((e=>u(e)[2]));return this.provider.isEtnaEnabled()?(p(o),s.e.newRemoveSubnetValidatorTx({fromAddressesBytes:m,utxos:a,minIssuanceTime:n?.minIssuanceTime,memo:n?.memo,nodeId:t,subnetId:r,subnetAuth:d,feeState:o},this.provider.getContext())):s.newRemoveSubnetValidatorTx(this.provider.getContext(),a,m,t,r,d,n)}transferSubnetOwnershipTx({utxoSet:e,subnetId:t,subnetAuth:r,subnetOwners:d,feeState:i,fromAddresses:o,options:n,threshold:a,locktime:m}){const g=h(e.getUTXOs(),!0),A=(o??this.getAddresses("P")).map((e=>u(e)[2])),c=d.map((e=>u(e)[2]));return this.provider.isEtnaEnabled()?(p(i),s.e.newTransferSubnetOwnershipTx({fromAddressesBytes:A,utxos:g,minIssuanceTime:n?.minIssuanceTime,memo:n?.memo,subnetId:t,subnetAuth:r,subnetOwners:c,feeState:i,threshold:a,locktime:m},this.provider.getContext())):s.newTransferSubnetOwnershipTx(this.provider.getContext(),g,A,t,r,c,n,a??1,m??BigInt(0))}transformSubnetTx(e,t,r,d,i,o,n,a,m,g,p,A,x,v,l,T,f,C){const w=h(e.getUTXOs(),!0),b=(f??this.getAddresses("P")).map((e=>u(e)[2]));if(this.provider.isEtnaEnabled())throw c;return s.newTransformSubnetTx(this.provider.getContext(),w,b,t,r,d,i,o,n,a,m,g,p,A,x,v,l,T,C)}}export{x as WalletAbstract};
|
|
1
|
+
import{TransferableOutput as e,avm as s,pvm as t,evm as r,pvmSerial as d,utils as o,PChainOwner as n,L1Validator as i,networkIDs as a}from"@avalabs/avalanchejs";import"../utils/populateCredential.js";import"@avalabs/glacier-sdk";import{strip0x as h}from"@avalabs/core-utils-sdk";import"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"bip32";import{getUTXOsForAddresses as m}from"../utils/getAllUTXOs.js";import{getStakeForAddresses as g}from"../utils/getStakeForAddresses.js";import"bip39";import"xss";import{sortUTXOsByAmount as u,sortUTXOsByAmountAscending as p,sortUTXOsStaking as A}from"../utils/sortUTXOs.js";import"bip32-path";import{assertFeeStateProvided as c}from"../../utils/assertFeeStateProvided.js";const{parse:f,hexToBuffer:x}=o;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 m(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 m(this.getAddresses(e),t,{sourceChain:r,addresses:[]})}async getNonce(){const e=this.getAddressEVM();return await this.provider.evmRpc.getTransactionCount(e)}exportX(t,r,d,o){o=o||this.getCurrentAddress(d);const n=f(o)[2],i=this.provider.getAvaxID(),a=e.fromNative(i,t,[n]),h=u(r.getUTXOs(),!0),m=this.provider.getChainID(d),g=this.getAddresses("X").map((e=>f(e)[2])),p=f(this.getChangeAddress("X"))[2];return s.newExportTx(this.provider.getContext(),m,g,h,[a],{threshold:1,changeAddresses:[p]})}importP({utxoSet:e,sourceChain:s,toAddress:r,threshold:d,feeState:o,locktime:n}){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 h=f(r)[2],m=e.getUTXOs();return c(o),t.newImportTx({fromAddressesBytes:a,utxos:m,toAddressesBytes:[h],sourceChainId:i,threshold:d,feeState:o,locktime:n},this.provider.getContext())}importX(e,t,r){const d=this.provider.getChainID(t),o=this.getAddresses("X").map((e=>f(e)[2])),n=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],o,{changeAddresses:[n]})}importC(e,s,t,d,o){const n=this.provider.getChainID(s),i=this.getAddresses("C").map((e=>f(e)[2]));o=o||this.getAddressEVM();const a=Buffer.from(h(o),"hex");return r.newImportTxFromBaseFee(this.provider.getContext(),a,i,e.getUTXOs(),n,t,d)}exportC(e,s,t,d,o){const n=x(this.getAddressEVM()),i=this.provider.getChainID(s);o=o||this.getCurrentAddress(s);const a=f(o)[2],h=d/BigInt(1e9);return r.newExportTxFromBaseFee(this.provider.getContext(),h,e,i,n,[a],t)}exportP({amount:s,utxoSet:r,destination:d,feeState:o,toAddress:n}){n=n||this.getCurrentAddress(d);const i=f(n)[2],a=this.provider.getAvaxID(),h=e.fromNative(a,s,[i]),m=u(r.getUTXOs(),!0),g=this.provider.getChainID(d),p=this.getAddresses("P").map((e=>f(e)[2])),A=f(this.getChangeAddress("P"))[2];return c(o),t.newExportTx({changeAddressesBytes:[A],fromAddressesBytes:p,utxos:m,outputs:[h],destinationChainId:g,feeState:o},this.provider.getContext())}consolidateP({utxoSet:s,amount:r,feeState:d,toAddress:o,options:n}){const i=p(s.getUTXOs());o=o??this.getCurrentAddress("P");const a=f(o)[2],h=this.provider.getContext(),m=[e.fromNative(h.avaxAssetID,r,[a])],g=this.getAddresses("P").map((e=>f(e)[2])),u=f(this.getChangeAddress("P"))[2],A=n?.changeAddresses??[u];return c(d),t.newBaseTx({changeAddressesBytes:A,fromAddressesBytes:g,utxos:i,outputs:m,minIssuanceTime:n?.minIssuanceTime,memo:n?.memo,feeState:d},h)}baseTX({utxoSet:r,chain:d,toAddress:o,amountsPerAsset:n,feeState:i,options:a,fromAddresses:h}){const[m,g,p]=f(o);if(m!==d||g!==this.provider.getHrp())throw new Error(`Invalid recipient address "${o}"`);const A=Object.entries(n).map((([s,t])=>e.fromNative(s,t,[p]))),x=u(r.getUTXOs(),!0),l=(h??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,A,a):(c(i),t.newBaseTx({changeAddressesBytes:T,fromAddressesBytes:l,utxos:x,outputs:A,minIssuanceTime:a?.minIssuanceTime,memo:a?.memo,feeState:i},this.provider.getContext()))}convertSubnetToL1({utxoSet:e,chainId:s,subnetId:r,subnetAuth:a,feeState:h,address:m,validators:g,options:p,fromAddresses:A}){if(!this.provider.isEtnaEnabled())throw new Error("Not supported prior to E-upgrade");const c=(A??this.getAddresses("P")).map((e=>f(e)[2])),x=f(this.getChangeAddress("P"))[2],l=p?.changeAddresses??[x],I=g.map((({nodeId:e,pubKey:s,signature:t,balance:r,weight:a,deactivationOwner:h,remainingBalanceOwner:m})=>{const g=new d.ProofOfPossession(Uint8Array.from(o.hexToBuffer(s)),Uint8Array.from(o.hexToBuffer(t))),u=n.fromNative(m.addresses.map((e=>f(e)[2])),m.threshold??1),p=n.fromNative(h.addresses.map((e=>f(e)[2])),h.threshold??1);return i.fromNative(e,a,r,g,u,p)}));return t.newConvertSubnetToL1Tx({changeAddressesBytes:l,validators:I,fromAddressesBytes:c,address:f(m)[2],chainId:s,subnetId:r,subnetAuth:a,feeState:h,utxos:u(e.getUTXOs(),!0)},this.provider.getContext())}registerL1Validator({utxoSet:e,balance:s,signature:r,message:d,feeState:n,fromAddresses:i,options:a}){if(!this.provider.isEtnaEnabled())throw new Error("Not supported prior to E-upgrade");const h=(i??this.getAddresses("P")).map((e=>f(e)[2])),m=f(this.getChangeAddress("P"))[2],g=a?.changeAddresses??[m];return t.newRegisterL1ValidatorTx({utxos:u(e.getUTXOs(),!0),balance:s,blsSignature:Uint8Array.from(o.hexToBuffer(r)),changeAddressesBytes:g,feeState:n,fromAddressesBytes:h,memo:a?.memo,message:Uint8Array.from(o.hexToBuffer(d)),minIssuanceTime:a?.minIssuanceTime},this.provider.getContext())}setL1ValidatorWeight({utxoSet:e,feeState:s,message:r,options:d,fromAddresses:n}){if(!this.provider.isEtnaEnabled())throw new Error("Not supported prior to E-upgrade");const i=(n??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],h=d?.changeAddresses??[a];return t.newSetL1ValidatorWeightTx({utxos:u(e.getUTXOs(),!0),changeAddressesBytes:h,feeState:s,fromAddressesBytes:i,memo:d?.memo,message:Uint8Array.from(o.hexToBuffer(r)),minIssuanceTime:d?.minIssuanceTime},this.provider.getContext())}disableL1Validator({utxoSet:e,feeState:s,options:r,fromAddresses:d,disableAuth:o,validationId:n}){if(!this.provider.isEtnaEnabled())throw new Error("Not supported prior to E-upgrade");const i=(d??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],h=r?.changeAddresses??[a];return t.newDisableL1ValidatorTx({disableAuth:o,validationId:n,utxos:u(e.getUTXOs(),!0),changeAddressesBytes:h,feeState:s,fromAddressesBytes:i,memo:r?.memo,minIssuanceTime:r?.minIssuanceTime},this.provider.getContext())}increaseL1ValidatorBalance({utxoSet:e,feeState:s,options:r,fromAddresses:d,balance:o,validationId:n}){if(!this.provider.isEtnaEnabled())throw new Error("Not supported prior to E-upgrade");const i=(d??this.getAddresses("P")).map((e=>f(e)[2])),a=f(this.getChangeAddress("P"))[2],h=r?.changeAddresses??[a];return t.newIncreaseL1ValidatorBalanceTx({balance:o,validationId:n,utxos:u(e.getUTXOs(),!0),changeAddressesBytes:h,feeState:s,fromAddressesBytes:i,memo:r?.memo,minIssuanceTime:r?.minIssuanceTime},this.provider.getContext())}createBlockchain({utxoSet:e,subnetId:s,chainName:r,vmID:d,fxIds:o,genesisData:n,subnetAuth:i,feeState:a,options:h,fromAddresses:m}){const g=u(e.getUTXOs(),!0),p=(m??this.getAddresses("P")).map((e=>f(e)[2])),A=f(this.getChangeAddress("P"))[2],x=h?.changeAddresses??[A];return c(a),t.newCreateChainTx({chainName:r,feeState:a,fromAddressesBytes:p,fxIds:o,genesisData:n,subnetAuth:i,subnetId:s,utxos:g,vmId:d,changeAddressesBytes:x},this.provider.getContext())}createSubnet({utxoSet:e,rewardAddresses:s,feeState:r,fromAddresses:d,options:o,threshold:n,locktime:i}){const a=u(e.getUTXOs(),!0),h=(d??this.getAddresses("P")).map((e=>f(e)[2])),m=f(this.getChangeAddress("P"))[2],g=o?.changeAddresses??[m],p=s.map((e=>f(e)[2]));return c(r),t.newCreateSubnetTx({fromAddressesBytes:h,changeAddressesBytes:g,utxos:a,minIssuanceTime:o?.minIssuanceTime,memo:o?.memo,feeState:r,threshold:n,locktime:i,subnetOwners:p},this.provider.getContext())}addSubnetValidator({utxoSet:e,nodeId:s,start:r,end:d,weight:o,subnetId:n,subnetAuth:i,feeState:a,fromAddresses:h,options:m}){const g=u(e.getUTXOs(),!0),p=(h??this.getAddresses("P")).map((e=>f(e)[2])),A=f(this.getChangeAddress("P"))[2],x=m?.changeAddresses??[A];return c(a),t.newAddSubnetValidatorTx({changeAddressesBytes:x,fromAddressesBytes:p,utxos:g,minIssuanceTime:m?.minIssuanceTime,memo:m?.memo,nodeId:s,start:r,end:d,weight:o,subnetId:n,subnetAuth:i,feeState:a},this.provider.getContext())}addPermissionlessValidator({utxoSet:e,nodeId:s,start:r,end:d,weight:o,subnetId:n,shares:i,feeState:h,fromAddresses:m,rewardAddresses:g,delegatorRewardAddresses:u,publicKey:p,signature:x,options:l,threshold:I,locktime:T,stakingAssetId:v}){const C=A(e.getUTXOs()),b=(m??this.getAddresses("P")).map((e=>f(e)[2])),S=(g??[this.getCurrentAddress("P")]).map((e=>f(e)[2])),w=(u??[this.getCurrentAddress("P")]).map((e=>f(e)[2]));if(!(n!==a.PrimaryNetworkID.toString()||p&&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 c(h),t.newAddPermissionlessValidatorTx({fromAddressesBytes:b,delegatorRewardsOwner:w,utxos:C,minIssuanceTime:l?.minIssuanceTime,memo:l?.memo,changeAddressesBytes:B,nodeId:s,start:r,end:d,weight:o,subnetId:n,shares:i,feeState:h,publicKey:p,rewardAddresses:S,signature:x,locktime:T,threshold:I,stakingAssetId:v},this.provider.getContext())}addPermissionlessDelegator({utxoSet:e,nodeId:s,start:r,end:d,weight:o,subnetId:n,fromAddresses:i,rewardAddresses:a,options:h,locktime:m,feeState:g,threshold:u,stakingAssetId:p}){const x=A(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=h?.changeAddresses??[T];return c(g),t.newAddPermissionlessDelegatorTx({fromAddressesBytes:l,utxos:x,minIssuanceTime:h?.minIssuanceTime,memo:h?.memo,changeAddressesBytes:v,nodeId:s,start:r,end:d,weight:o,subnetId:n,rewardAddresses:I,locktime:m,stakingAssetId:p,threshold:u,feeState:g},this.provider.getContext())}removeSubnetValidator({utxoSet:e,nodeId:s,subnetId:r,subnetAuth:d,fromAddresses:o,feeState:n,options:i}){const a=u(e.getUTXOs(),!0),h=(o??this.getAddresses("P")).map((e=>f(e)[2])),m=f(this.getChangeAddress("P"))[2],g=i?.changeAddresses??[m];return c(n),t.newRemoveSubnetValidatorTx({changeAddressesBytes:g,fromAddressesBytes:h,utxos:a,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,nodeId:s,subnetId:r,subnetAuth:d,feeState:n},this.provider.getContext())}transferSubnetOwnershipTx({utxoSet:e,subnetId:s,subnetAuth:r,subnetOwners:d,feeState:o,fromAddresses:n,options:i,threshold:a,locktime:h}){const m=u(e.getUTXOs(),!0),g=(n??this.getAddresses("P")).map((e=>f(e)[2])),p=f(this.getChangeAddress("P"))[2],A=i?.changeAddresses??[p],x=d.map((e=>f(e)[2]));return c(o),t.newTransferSubnetOwnershipTx({changeAddressesBytes:A,fromAddressesBytes:g,utxos:m,minIssuanceTime:i?.minIssuanceTime,memo:i?.memo,subnetId:s,subnetAuth:r,subnetOwners:x,feeState:o,threshold:a,locktime:h},this.provider.getContext())}}export{l as WalletAbstract};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{WalletAbstract as e}from"./WalletAbstract.js";import{fromSeed as r}from"bip32";import{validateMnemonic as t,mnemonicToSeedSync as s}from"bip39";import{strip0x as i}from"@avalabs/core-utils-sdk";import"@avalabs/avalanchejs";import"../utils/populateCredential.js";import{SigningKey as o,computeAddress as a}from"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"
|
|
1
|
+
import{WalletAbstract as e}from"./WalletAbstract.js";import{fromSeed as r}from"bip32";import{validateMnemonic as t,mnemonicToSeedSync as s}from"bip39";import{strip0x as i}from"@avalabs/core-utils-sdk";import"@avalabs/avalanchejs";import"../utils/populateCredential.js";import"@avalabs/glacier-sdk";import{SigningKey as o,computeAddress as a}from"ethers";import"../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"xss";import{verifyDerivationPath as p}from"../utils/verifyDerivationPath.js";class n extends e{constructor(e,r,t){if(super(t),this.pubkeyXP=e,this.pubkeyC=r,33!==r.length||33!==e.length)throw new Error("Public key must be 33 byte compressed public key")}static fromPublicKey(e,r,t){const s=i(o.computePublicKey(e,!0)),a=i(o.computePublicKey(r,!0)),p=Buffer.from(s,"hex"),u=Buffer.from(a,"hex");return new n(p,u,t)}static fromMnemonic(e,i,o,a){if(!t(e))throw new Error("Invalid mnemonic phrase.");if(!p(o)||!p(i))throw new Error("Not valid derivation path. Make sure it is a valid BIP44 path starting with m/");const u=s(e),d=r(u),m=d.derivePath(o),h=d.derivePath(i);return n.fromPublicKey(h.publicKey,m.publicKey,a)}getAddress(e){const r="C"===e?this.pubkeyC:this.pubkeyXP;return this.provider.getAddress(r,e)}getAddressEVM(){return a(`0x${this.pubkeyC.toString("hex")}`)}getAddresses(e){return[this.getAddress(e)]}getChangeAddress(e){return this.getAddress(e)}getCurrentAddress(e){return this.getAddress(e)}}export{n as WalletVoid};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{WalletVoid as r}from"../WalletVoid.js";import{isObsidianApp as t}from"./isObsidianApp.js";import{ZondaxProvider as e}from"./ZondaxProvider.js";import i from"bip32-path";import o from"@ledgerhq/hw-app-eth";import{utils as a}from"@avalabs/avalanchejs";import"../../utils/populateCredential.js";import"@avalabs/core-utils-sdk";import{SigningKey as s}from"ethers";import"../../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"bip32";import"
|
|
1
|
+
import{WalletVoid as r}from"../WalletVoid.js";import{isObsidianApp as t}from"./isObsidianApp.js";import{ZondaxProvider as e}from"./ZondaxProvider.js";import i from"bip32-path";import o from"@ledgerhq/hw-app-eth";import{utils as a}from"@avalabs/avalanchejs";import"../../utils/populateCredential.js";import"@avalabs/glacier-sdk";import"@avalabs/core-utils-sdk";import{SigningKey as s}from"ethers";import"../../providers/constants.js";import"@avalabs/core-chains-sdk";import"create-hash";import"bip32";import"bip39";import"xss";import{verifyDerivationPath as n}from"../../utils/verifyDerivationPath.js";const{strip0x:p}=a;class f extends r{constructor(r,t,e,i,o){const p=a.strip0x(s.computePublicKey(r,!0)),f=a.strip0x(s.computePublicKey(e,!0));if(super(Buffer.from(p,"hex"),Buffer.from(f,"hex"),o),this.pathXP=t,this.pathC=i,!n(t)||!n(i))throw new Error("Invalid path configuration.")}static async fromTransport(r,e,i,a){if(await t(r))throw new Error("Ledger app not supported. Must be version >= 0.6.0");if(!n(e)||!n(i))throw new Error("Invalid path configuration.");const h=new o(r),u=await h.getAddress(i,!1),c=await h.getAddress(e,!1),m=Buffer.from(p(u.publicKey),"hex"),l=Buffer.from(p(c.publicKey),"hex"),g=Buffer.from(p(s.computePublicKey(m,!0)),"hex"),d=Buffer.from(p(s.computePublicKey(l,!0)),"hex");return new f(d,e,g,i,a)}async signMessage(r){throw new Error("not implemented")}getFullSignerPath(r){return"C"===r?this.pathC:this.pathXP}getPartialSignerPath(r){return this.getFullSignerPath(r).split("/").slice(4).join("/")}getAccountPath(r){return this.getFullSignerPath(r).split("/").slice(0,4).join("/")}async signTx(r){if(!r.transport)throw new Error("Ledger transport not provided");const t=r.tx,e=t.getVM(),i=Buffer.from(t.toBytes()),o="EVM"===e?"C":"X";return(await this.signTxBuffer({buffer:i,chain:o,transport:r.transport})).forEach((r=>{t.addSignature(r)})),t}async signTxBuffer(r){if(!r.transport)throw new Error("Ledger transport not provided");const t=i.fromString(this.getAccountPath(r.chain)),o=i.fromString(this.getPartialSignerPath(r.chain));return[...(await e.signTx(r.transport,r.buffer,t,[o],[o])).signatures.values()]}}export{f as LedgerSigner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EVMUnsignedTx as t,UnsignedTx as r,utils as e}from"@avalabs/avalanchejs";import s from"bip32-path";import{getTxOutputAddresses as i}from"../../utils/getTxOutputAddresses.js";import{ZondaxProvider as n}from"./ZondaxProvider.js";import{fromBase58 as o}from"bip32";import"../../utils/populateCredential.js";import"@avalabs/core-utils-sdk";import"ethers";import"../../providers/constants.js";import"@avalabs/core-chains-sdk";import{digestMessage as a}from"../../utils/digestMessage.js";import"
|
|
1
|
+
import{EVMUnsignedTx as t,UnsignedTx as r,utils as e}from"@avalabs/avalanchejs";import s from"bip32-path";import{getTxOutputAddresses as i}from"../../utils/getTxOutputAddresses.js";import{ZondaxProvider as n}from"./ZondaxProvider.js";import{fromBase58 as o}from"bip32";import"../../utils/populateCredential.js";import"@avalabs/glacier-sdk";import"@avalabs/core-utils-sdk";import"ethers";import"../../providers/constants.js";import"@avalabs/core-chains-sdk";import{digestMessage as a}from"../../utils/digestMessage.js";import"bip39";import"xss";const{parse:c}=e;class h{constructor(t,r,e){this.activeAccountIndex=t,this.provider=r,e&&(this.accountNode=o(e))}accountNode;reSerializeTx(e,s){return e instanceof t||"C"===s?t.fromJSON(JSON.stringify(e.toJSON())):r.fromJSON(JSON.stringify(e.toJSON()))}getChainAlias(t){return"EVM"===t.getVM()?"C":"X"}getAccountPath(t){switch(t){case"X":case"P":return"m/44'/9000'/0'";case"C":return"m/44'/60'/0'"}}getAddressOfPath(t,r){if(!this.accountNode)return null;const{publicKey:e}=this.accountNode.derivePath(t),s=this.provider.getAddress(e,r);return Buffer.from(c(s)[2]).toString("hex")}getAddressPathMap(t){const{tx:r,externalIndices:e,internalIndices:s}=t,i=this.getChainAlias(r),n=`0/${this.activeAccountIndex}`,o=new Map;if("C"===i||!this.accountNode)return o;const a=[n,...(e??[]).map((t=>`0/${t}`)),...(s??[]).map((t=>`1/${t}`))];for(const t of a){const r=this.getAddressOfPath(t,i);r&&o.set(r,t)}return o}getAddressBipPaths(t,r){return 0===r.size?[s.fromString(`0/${this.activeAccountIndex}`)]:t.reduce(((t,e)=>{const i=r.get(Buffer.from(e).toString("hex"));return i&&t.push(s.fromString(i)),t}),[])}async signTx(t){if(!t.transport)throw new Error("Ledger transport not provided");const r=this.getChainAlias(t.tx),e=this.reSerializeTx(t.tx,r),s=Buffer.from(e.toBytes()),n=this.getAddressPathMap(t),o=this.getAddressBipPaths(e.getAddresses(),n),a=this.getAddressBipPaths([...i(e)],n);return(await this.signTxBuffer({buffer:s,chain:r,transport:t.transport,signers:o,change:a})).forEach((t=>{e.addSignature(t)})),e}async signTxBuffer(t){if(!t.transport)throw new Error("Ledger transport not provided");if(!t.signers)throw new Error("Signers not provided");const r=t.change||[],e=s.fromString(this.getAccountPath(t.chain));return[...(await n.signTx(t.transport,t.buffer,e,t.signers,r)).signatures.values()]}async signMessage(t){if(!t.transport||!t.message)throw new Error("Unable to sign message. Incomplete or invalid request.");const r=t.signer||s.fromString(`0/${this.activeAccountIndex}`);if(2!=r.toPathArray().length)throw new Error("Given signer path must have a depth of 2. Ex. 0/0, 0/1");const e=a(t.message),i=(await n.signHash(t.transport,e,s.fromString(this.getAccountPath(t.chain)),[r])).signatures.get(r.toString(!0));if(!i)throw new Error("Failed to sign message.");return i}}export{h as SimpleLedgerSigner};
|
|
@@ -8,12 +8,12 @@ declare class BitcoinProvider extends BitcoinProviderAbstract {
|
|
|
8
8
|
private readonly extraParams?;
|
|
9
9
|
constructor(isMainnet?: boolean, apiKey?: string, explorerUrl?: string, nodeUrl?: string, extraParams?: Record<string, string> | undefined);
|
|
10
10
|
getTxHex(txHash: string): Promise<string>;
|
|
11
|
-
getUTXOs(address: string, withScripts?: boolean): Promise<{
|
|
11
|
+
getUTXOs(address: string, withScripts?: boolean, skipBatch?: boolean): Promise<{
|
|
12
12
|
confirmed: BitcoinInputUTXOWithOptionalScript[];
|
|
13
13
|
unconfirmed: BitcoinInputUTXOWithOptionalScript[];
|
|
14
14
|
}>;
|
|
15
15
|
getAddressFromScript(script: string): Promise<string>;
|
|
16
|
-
getScriptsForUtxos(utxos: BitcoinInputUTXOWithOptionalScript[]): Promise<BitcoinInputUTXO[]>;
|
|
16
|
+
getScriptsForUtxos(utxos: BitcoinInputUTXOWithOptionalScript[], skipBatch?: boolean): Promise<BitcoinInputUTXO[]>;
|
|
17
17
|
private _parseUtxo;
|
|
18
18
|
getBalances(address: string): Promise<{
|
|
19
19
|
available: bigint;
|
|
@@ -21,7 +21,7 @@ declare class BitcoinProvider extends BitcoinProviderAbstract {
|
|
|
21
21
|
final: bigint;
|
|
22
22
|
}>;
|
|
23
23
|
getChainHeight(): Promise<number>;
|
|
24
|
-
getFeeRates(): Promise<{
|
|
24
|
+
getFeeRates(skipBatch?: boolean): Promise<{
|
|
25
25
|
low: number;
|
|
26
26
|
medium: number;
|
|
27
27
|
high: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BitcoinProviderAbstract as t}from"./BitcoinProviderAbstract.js";import{networks as e}from"bitcoinjs-lib";import{HttpClient as a}from"@avalabs/core-utils-sdk";import{URL_EXPLORER_MAINNET as s,URL_EXPLORER_TESTNET as r,URL_NODE_MAINNET as i,URL_NODE_TESTNET as n}from"./models.js";import{parseAddressFullTx as o}from"./utils/parseAddressFullTx.js";class l extends t{constructor(t=!0,e,o,l,c){super(),this.isMainnet=t,this.extraParams=c;const m=e?{headers:{"api-key":e}}:{},p=t?s:r;this.#t=new a(o||p,m);const d=t?i:n;this.#e=new a(l||d,m)}#t;#e;async#a(t){return this.isMainnet?(await Promise.all(t.map((t=>this.#e.post("",t,{},this.extraParams))))).flat():this.#e.post("",t,{},this.extraParams)}async getTxHex(t){return(await this.#t.post(`/api/v2/tx/${t}`,{},{},this.extraParams)).hex}async getUTXOs(t,e=!0){const
|
|
1
|
+
import{BitcoinProviderAbstract as t}from"./BitcoinProviderAbstract.js";import{networks as e}from"bitcoinjs-lib";import{HttpClient as a}from"@avalabs/core-utils-sdk";import{URL_EXPLORER_MAINNET as s,URL_EXPLORER_TESTNET as r,URL_NODE_MAINNET as i,URL_NODE_TESTNET as n}from"./models.js";import{parseAddressFullTx as o}from"./utils/parseAddressFullTx.js";class l extends t{constructor(t=!0,e,o,l,c){super(),this.isMainnet=t,this.extraParams=c;const m=e?{headers:{"api-key":e}}:{},p=t?s:r;this.#t=new a(o||p,m);const d=t?i:n;this.#e=new a(l||d,m)}#t;#e;async#a(t,e){return this.isMainnet||e?(await Promise.all(t.map((t=>this.#e.post("",t,{},this.extraParams))))).flat():this.#e.post("",t,{},this.extraParams)}async getTxHex(t){return(await this.#t.post(`/api/v2/tx/${t}`,{},{},this.extraParams)).hex}async getUTXOs(t,e=!0,a){const s=await this.#t.post(`/api/v2/utxo/${t}`,{},{},this.extraParams);if(!s?.length)return{confirmed:[],unconfirmed:[]};const r=s.map(this._parseUtxo),i=t=>({confirmed:t.filter((t=>t.confirmations>0)),unconfirmed:t.filter((t=>0===t.confirmations))});if(!e)return i(r);return i(await this.getScriptsForUtxos(r,a))}async getAddressFromScript(t){const e=await this.#e.post("",{jsonrpc:"2.0",id:`decode-script-${t}`,method:"decodescript",params:[t]},{},this.extraParams);if(e.result)return e.result.address;throw new Error(`Unable to resolve address for script: ${t}. ${e.error.message}`)}async getScriptsForUtxos(t,e){const[a,s]=t.reduce((([t,e],a)=>a.script?[[...t,a],e]:[t,[...e,a]]),[[],[]]),r=s.map(((t,e)=>({jsonrpc:"2.0",method:"gettxout",params:[t.txHash,t.index],id:`${e}`}))),i=r.length?(await this.#a(r,e)).sort(((t,e)=>Number(t.id)-Number(e.id))):[];return[...a,...s.map(((t,e)=>({...t,script:i[e]?.result?.scriptPubKey.hex})))]}_parseUtxo(t){return{...t,txHash:t.txid,index:t.vout,value:Number(t.value),blockHeight:t.height,script:t.script,confirmations:t.confirmations}}async getBalances(t){const e=await this.#t.post(`/api/v2/address/${t}`,{},{},this.extraParams);return{available:BigInt(e.balance),pending:BigInt(e.unconfirmedBalance),final:BigInt(e.balance)+BigInt(e.unconfirmedBalance)}}async getChainHeight(){return(await this.#e.post("",{jsonrpc:"2.0",id:"nownodes",method:"getblockcount",params:[]},{},this.extraParams)).result}async getFeeRates(t){const e={jsonrpc:"2.0",method:"estimatesmartfee"},a=await this.#a([{...e,id:"1",params:[1]},{...e,id:"2",params:[3]},{...e,id:"3",params:[6]}],t).then((t=>t.sort(((t,e)=>Number(t.id)-Number(e.id))).map((t=>1e8*(t.result?.feerate??0)))));return{high:Math.ceil(a[0]/1024)||1,medium:Math.ceil(a[1]/1024)||1,low:Math.ceil(a[2]/1024)||1}}getNetwork(){return this.isMainnet?e.bitcoin:e.testnet}async issueRawTx(t){return await this.#e.post("",{jsonrpc:"2.0",id:"nownodes",method:"sendrawtransaction",params:[t]},{},this.extraParams).then((t=>t.result))}async getTransaction(t){const e=await this.#t.post(`/api/v2/tx/${t}`,{},{},this.extraParams);return{block:e.blockHeight,fees:Number(e.fees),confirmations:e.confirmations,amount:Number(e.value),hash:e.txid,addresses:Array.from(new Set([...e.vin.map((t=>t.addresses||[])).flat(),...e.vout.map((t=>t.addresses||[])).flat()])),blockTime:e.blockTime,inputs:[...e.vin.map((t=>({...t,value:Number(t.value)})))],outputs:[...e.vout.map((t=>({...t,value:Number(t.value)})))]}}async getTxHistory(t){const e=await this.#t.post(`/api/v2/address/${t}`,{},{},this.extraParams);return await Promise.allSettled(e.txids?.slice(0,25).map((async e=>{try{const a=await this.#t.post(`/api/v2/tx/${e}`,{},{},this.extraParams);return o(t,a)}catch(t){console.log(`Unable to parse full tx ${e}.`)}}))).then((t=>t.map((t=>"fulfilled"===t.status&&t.value?t.value:void 0)).filter((t=>void 0!==t))))}async waitForTx(t,{maxAttempts:e=20,attempt:a=1,pollInterval:s=500}={}){try{return await this.getTransaction(t)}catch(r){if(a>=e)throw r;return await new Promise((t=>setTimeout(t,s))),this.waitForTx(t,{maxAttempts:e,attempt:a+1,pollInterval:s})}}}export{l as BitcoinProvider};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avalabs/core-wallets-sdk",
|
|
3
|
-
"version": "3.1.0-canary.
|
|
3
|
+
"version": "3.1.0-canary.4bb44cd.0+4bb44cd",
|
|
4
4
|
"license": "Limited Ecosystem License",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"ts-jest": "29.1.2"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@avalabs/avalanchejs": "4.
|
|
34
|
-
"@avalabs/core-chains-sdk": "3.1.0-canary.
|
|
35
|
-
"@avalabs/glacier-sdk": "3.1.0-canary.
|
|
33
|
+
"@avalabs/avalanchejs": "4.2.0-alpha.1",
|
|
34
|
+
"@avalabs/core-chains-sdk": "3.1.0-canary.4bb44cd.0+4bb44cd",
|
|
35
|
+
"@avalabs/glacier-sdk": "3.1.0-canary.4bb44cd.0+4bb44cd",
|
|
36
36
|
"@avalabs/hw-app-avalanche": "0.14.1",
|
|
37
37
|
"@ledgerhq/hw-app-btc": "10.2.4",
|
|
38
38
|
"@ledgerhq/hw-app-eth": "6.36.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@openzeppelin/contracts": "4.9.6",
|
|
42
42
|
"bip32": "2.0.6",
|
|
43
43
|
"bip32-path": "0.4.2",
|
|
44
|
-
"bip39": "3.0
|
|
44
|
+
"bip39": "3.1.0",
|
|
45
45
|
"bitcoinjs-lib": "5.2.0",
|
|
46
46
|
"coinselect": "3.1.13",
|
|
47
47
|
"create-hash": "1.2.0",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"ethers": "^6.7.1"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "4bb44cdf8eb3aa9aba72fa37d3462a0bff474fa3"
|
|
56
56
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Utxo } from '@avalabs/avalanchejs';
|
|
2
|
-
|
|
3
|
-
type UtxoInfo = {
|
|
4
|
-
utxoId: string;
|
|
5
|
-
assetId: string;
|
|
6
|
-
locktime: bigint;
|
|
7
|
-
stakeableLocktime: bigint;
|
|
8
|
-
threshold: number;
|
|
9
|
-
amount: bigint;
|
|
10
|
-
};
|
|
11
|
-
declare const getUtxoInfo: (utxo: Utxo) => UtxoInfo;
|
|
12
|
-
|
|
13
|
-
export { UtxoInfo, getUtxoInfo };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{utils as t}from"@avalabs/avalanchejs";const{isStakeableLockOut:e,isTransferOut:a}=t,o=t=>{const o=t.output,s=t.getOutputOwners();return{utxoId:t.ID(),assetId:t.getAssetId(),amount:a(o)||e(o)?o.amount():BigInt(0),locktime:s.locktime.value(),stakeableLocktime:e(o)?o.getStakeableLocktime():BigInt(0),threshold:s.threshold.value()}};export{o as getUtxoInfo};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as a}from"../../models.js";import{getTransferableOutputAmount as t}from"./utils/getTransferableAmount.js";const r=r=>e.isAddDelegatorTx(r)?({feeData:e,assetId:s})=>({type:a.AddDelegator,chain:r.getVM(),stake:t(r.stake,s),stakeOuts:r.stake,rewardOwner:r.getRewardsOwner(),nodeID:r.validator.nodeId.value(),start:r.validator.startTime.value().toString(),end:r.validator.endTime.value().toString(),...e}):null;export{r as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";import{getTransferableOutputAmount as t}from"./utils/getTransferableAmount.js";const r=r=>a.isAddValidatorTx(r)?({feeData:a,assetId:s})=>({type:e.AddValidator,chain:r.getVM(),nodeID:r.validator.nodeId.value(),delegationFee:r.shares.value(),stake:t(r.stake,s),stakeOuts:r.stake,start:r.validator.startTime.value().toString(),end:r.validator.endTime.value().toString(),rewardOwner:r.getRewardsOwner(),...a}):null;export{r as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{pvmSerial as a}from"@avalabs/avalanchejs";import{TxType as e}from"../../models.js";const t=t=>a.isTransformSubnetTx(t)?({feeData:a})=>({type:e.TransformSubnet,chain:t.getVM(),subnetID:t.subnetID.toString(),assetID:t.assetId.toString(),initialSupply:t.initialSupply.value(),maximumSupply:t.maximumSupply.value(),minConsumptionRate:t.minConsumptionRate.value(),maxConsumptionRate:t.maxConsumptionRate.value(),minValidatorStake:t.minValidatorStake.value(),maxValidatorStake:t.maxValidatorStake.value(),minStakeDuration:t.minStakeDuration.value(),maxStakeDuration:t.maxStakeDuration.value(),minDelegationFee:t.minDelegationFee.value(),minDelegatorStake:t.minDelegatorStake.value(),maxValidatorWeightFactor:Number(t.maxValidatorWeightFactor.toJSON()),uptimeRequirement:t.uptimeRequirement.value(),...a}):null;export{t as default};
|