@avalabs/core-wallets-sdk 3.1.0-alpha.2 → 3.1.0-alpha.21
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 +333 -48
- package/dist/index.js +1 -1
- package/esm/Avalanche/index.d.ts +2 -2
- package/esm/Avalanche/index.js +1 -1
- package/esm/Avalanche/models.d.ts +44 -5
- package/esm/Avalanche/models.js +1 -1
- package/esm/Avalanche/providers/AbstractProvider.d.ts +9 -2
- package/esm/Avalanche/providers/AbstractProvider.js +1 -1
- package/esm/Avalanche/providers/JsonRpcProvider.d.ts +5 -3
- package/esm/Avalanche/providers/JsonRpcProvider.js +1 -1
- package/esm/Avalanche/providers/constants.d.ts +20 -1
- package/esm/Avalanche/providers/constants.js +1 -1
- package/esm/Avalanche/providers/platformFeeConfig.js +1 -0
- package/esm/Avalanche/utils/convertGlacierUtxo.d.ts +3 -3
- package/esm/Avalanche/utils/createAvalancheUnsignedTx.js +1 -1
- package/esm/Avalanche/utils/getChainAliasByChainId.js +1 -1
- package/esm/Avalanche/utils/getPchainUnixNow.js +1 -1
- package/esm/Avalanche/utils/getUtxosByTxFromGlacier.d.ts +5 -2
- package/esm/Avalanche/utils/getUtxosByTxFromGlacier.js +1 -1
- package/esm/Avalanche/utils/handleSubnetAuth.js +1 -1
- 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/parseAddPermissionlessDelegatorTx.js +1 -1
- package/esm/Avalanche/utils/parsers/parseAddPermissionlessValidatorTx.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/txSizeLimits.d.ts +9 -2
- 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 +179 -0
- package/esm/Avalanche/wallets/WalletAbstract.d.ts +24 -18
- 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 +4 -3
- package/esm/BitcoinVM/providers/BitcoinProvider.js +1 -1
- package/esm/BitcoinVM/providers/BitcoinProviderAbstract.d.ts +1 -0
- package/esm/utils/assertFeeStateProvided.js +1 -0
- package/package.json +5 -5
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as _avalabs_avalanchejs_dist_vms_pvm from '@avalabs/avalanchejs/dist/vms/pvm';
|
|
1
2
|
import { Context } from '@avalabs/avalanchejs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -8,5 +9,23 @@ declare const MainnetContext: Context.Context;
|
|
|
8
9
|
* Avalanche Fuji testnet context
|
|
9
10
|
*/
|
|
10
11
|
declare const FujiContext: Context.Context;
|
|
12
|
+
declare const DevnetContext: {
|
|
13
|
+
addPrimaryNetworkDelegatorFee: bigint;
|
|
14
|
+
addPrimaryNetworkValidatorFee: bigint;
|
|
15
|
+
addSubnetDelegatorFee: bigint;
|
|
16
|
+
addSubnetValidatorFee: bigint;
|
|
17
|
+
avaxAssetID: string;
|
|
18
|
+
baseTxFee: bigint;
|
|
19
|
+
cBlockchainID: string;
|
|
20
|
+
createAssetTxFee: bigint;
|
|
21
|
+
createBlockchainTxFee: bigint;
|
|
22
|
+
createSubnetTxFee: bigint;
|
|
23
|
+
hrp: string;
|
|
24
|
+
networkID: number;
|
|
25
|
+
pBlockchainID: string;
|
|
26
|
+
transformSubnetTxFee: bigint;
|
|
27
|
+
xBlockchainID: string;
|
|
28
|
+
platformFeeConfig: _avalabs_avalanchejs_dist_vms_pvm.FeeConfig;
|
|
29
|
+
};
|
|
11
30
|
|
|
12
|
-
export { FujiContext, MainnetContext };
|
|
31
|
+
export { DevnetContext, FujiContext, MainnetContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
import{platformFeeConfig as e}from"./platformFeeConfig.js";const t={xBlockchainID:"2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM",pBlockchainID:"11111111111111111111111111111111LpoYY",cBlockchainID:"2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5",avaxAssetID:"FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z",baseTxFee:BigInt(1e6),createAssetTxFee:BigInt(1e7),createSubnetTxFee:BigInt(1e9),transformSubnetTxFee:BigInt(1e10),createBlockchainTxFee:BigInt(1e9),addPrimaryNetworkValidatorFee:BigInt(0),addPrimaryNetworkDelegatorFee:BigInt(0),addSubnetValidatorFee:BigInt(1e6),addSubnetDelegatorFee:BigInt(1e6),networkID:1,hrp:"avax",platformFeeConfig:e},a={xBlockchainID:"2JVSBoinj9C2J33VntvzYtVJNZdN2NKiwwKjcumHUWEb5DbBrm",pBlockchainID:"11111111111111111111111111111111LpoYY",cBlockchainID:"yH8D7ThNJkxmtkuv2jgBa4P1Rn3Qpr4pPr7QYNfcdoS6k6HWp",avaxAssetID:"U8iRqJoiJm8xZHAacmvYyZVwqQx6uDNtQeP3CQ6fcgQk3JqnK",baseTxFee:BigInt(1e6),createAssetTxFee:BigInt(1e7),createSubnetTxFee:BigInt(1e8),transformSubnetTxFee:BigInt(1e9),createBlockchainTxFee:BigInt(1e8),addPrimaryNetworkValidatorFee:BigInt(0),addPrimaryNetworkDelegatorFee:BigInt(0),addSubnetValidatorFee:BigInt(1e6),addSubnetDelegatorFee:BigInt(1e6),networkID:5,hrp:"fuji",platformFeeConfig:e},n={addPrimaryNetworkDelegatorFee:0n,addPrimaryNetworkValidatorFee:0n,addSubnetDelegatorFee:1000000n,addSubnetValidatorFee:1000000n,avaxAssetID:"22jjRVdyTJiAEtcZciAVR8bTFyVDUVoo1T3o5PiDspQSZ2maXR",baseTxFee:1000000n,cBlockchainID:"vV3cui1DsEPC3nLCGH9rorwo8s6BYxM2Hz4QFE5gEYjwTqAu",createAssetTxFee:1000000n,createBlockchainTxFee:100000000n,createSubnetTxFee:100000000n,hrp:"custom",networkID:76,pBlockchainID:"11111111111111111111111111111111LpoYY",transformSubnetTxFee:100000000n,xBlockchainID:"2piQ2AVHCjnduiWXsSY15DtbVuwHE2cwMHYnEXHsLL73BBkdbV",platformFeeConfig:e};export{n as DevnetContext,a as FujiContext,t as MainnetContext};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Utxo as Utxo$1 } from '@avalabs/avalanchejs';
|
|
2
|
-
import { Utxo, PChainUtxo } from '@avalabs/glacier-sdk';
|
|
1
|
+
import { Utxo as Utxo$1, TransferOutput, pvmSerial } from '@avalabs/avalanchejs';
|
|
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";const{getTransferableInputsByTx:n,AddressMaps:i}=a,o=async({tx:o,fromAddressBytes:d,provider:l,credentials:u,utxos:p})=>{const h=n(o),c=i.fromTransferableInputs(h,p,BigInt(Math.floor((new Date).getTime()/1e3)),d);if(t(o))try{const r=await s({tx:o,provider:l,addressMaps:c});return new e(o,p,r,u)}catch(e){throw new Error(`Error while preparing subnet authorization data: ${e.message}`)}else if(r.isDisableL1ValidatorTx(o))try{const{deactivationOwner:e}=await l.getApiP().getL1Validator(o.validationId.toString()),r=o.getDisableAuth().values(),t=e.addresses.reduce(((e,a,t)=>(r.includes(t)&&e.push([a,t]),e)),[]);c.push(new a.AddressMap(t))}catch(e){throw new Error(`Error while preparing subnet authorization data: ${e.message}`)}return new e(o,p,c,u)};export{o as createAvalancheUnsignedTx,o as default};
|
|
@@ -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 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{AVALANCHE_XP_TEST_NETWORK as a,AVALANCHE_XP_NETWORK as t}from"@avalabs/core-chains-sdk";import{pvm as e}from"@avalabs/avalanchejs";async function r(r){const i=r?a.rpcUrl:t.rpcUrl,n=await new e.PVMApi(i).getTimestamp(),o=new Date(n.timestamp),m=Math.floor(o.getTime()/1e3);return BigInt(m)}export{r as getPchainUnixNow};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import * as _avalabs_avalanchejs_dist_serializable_common_types from '@avalabs/avalanchejs/dist/serializable/common/types';
|
|
2
|
+
import { Network } from '@avalabs/glacier-sdk';
|
|
1
3
|
import { Utxo } from '@avalabs/avalanchejs';
|
|
2
4
|
import { ChainIDAlias } from '../models.js';
|
|
3
5
|
|
|
4
6
|
type Params = {
|
|
5
7
|
transactionHex: string;
|
|
6
8
|
chainAlias: ChainIDAlias;
|
|
7
|
-
|
|
9
|
+
network: Network;
|
|
8
10
|
url: string;
|
|
9
11
|
token?: string;
|
|
12
|
+
headers?: Record<string, string>;
|
|
10
13
|
};
|
|
11
|
-
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>[]>;
|
|
12
15
|
|
|
13
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};
|
|
@@ -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:u}=e;async function i(e,i,x){try{const n=i.getContext(),
|
|
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:u}=e;async function i(e,i,g,{feeTolerance:x=50}={}){try{const n=i.getContext(),p=e.getTx(),c=(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")})(p),d=r(p,n),A=o(p),I=s(p).get(n.avaxAssetID)??BigInt(0),l=d.get(n.avaxAssetID)??BigInt(0),m=A.get(n.avaxAssetID)??BigInt(0);let f,v=BigInt(0);t.isImportExportTx(p)?v=await i.getApiC().getBaseFee()/BigInt(1e9):"PVM"===p.vm&&(f=i.getUpgradesInfo(),v=await i.getApiP().getFeeState().then((t=>t.price)).catch((()=>BigInt(0))));const{isValid:B,txFee:w}=u({upgradesInfo:f,unsignedTx:e,context:n,burnedAmount:l,baseFee:v,feeTolerance:x});return await c({feeData:{totalAvaxBurned:l,totalAvaxOutput:m,totalAvaxInput:I,isValidAvaxBurnedAmount:B,txFee:w},assetId:n.avaxAssetID,provider:i,currentAddress:g})}catch(t){return{type:n.Unknown}}}export{i as parseAvalancheTx};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"./parseAddValidatorTx.js";import e from"./parseAddDelegatorTx.js";import
|
|
1
|
+
import r from"./parseAddValidatorTx.js";import e from"./parseAddDelegatorTx.js";import a from"./parseCreateSubnetTx.js";import s from"./parseCreateChainTx.js";import o from"./parseAddSubnetValidorTx.js";import t from"./parseImportTx.js";import p from"./parseExportTx.js";import i from"./parseBaseTx.js";import m from"./parseAddPermissionlessValidatorTx.js";import T from"./parseAddPermissionlessDelegatorTx.js";import x from"./parseRemoveSubnetValidatorTx.js";import d from"./parseTransformSubnetTx.js";import n from"./parseTransferSubnetOwnershipTx.js";import l from"./parseConvertSubnetToL1Tx.js";import f from"./parseRegisterL1ValidatorTx.js";import j from"./parseSetL1ValidatorWeightTx.js";import V from"./parseDisableL1ValidatorTx.js";import b from"./parseIncreaseL1ValidatorBalanceTx.js";var S={parseAddValidatorTx:r,parseAddDelegatorTx:e,parseCreateSubnetTx:a,parseCreateChainTx:s,parseAddSubnetValidatorTx:o,parseRemoveSubnetValidatorTx:x,parseImportTx:t,parseExportTx:p,parseBaseTx:i,parseAddPermissionlessValidatorTx:m,parseAddPermissionlessDelegatorTx:T,parseTransformSubnetTx:d,parseTransferSubnetOwnershipTx:n,parseConvertSubnetTx:l,parseRegisterL1ValidatorTx:f,parseIncreaseL1ValidatorBalanceTx:b,parseSetL1ValidatorWeightTx:j,parseDisableL1ValidatorTx:V};export{S as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as a}from"../../models.js";const t=t=>e.isAddPermissionlessDelegatorTx(t)?({feeData:e
|
|
1
|
+
import{pvmSerial as e}from"@avalabs/avalanchejs";import{TxType as a}from"../../models.js";const t=t=>e.isAddPermissionlessDelegatorTx(t)?({feeData:e})=>({type:a.AddPermissionlessDelegator,chain:t.getVM(),stake:t.subnetValidator.validator.weight.value(),nodeID:t.subnetValidator.validator.nodeId.value(),start:t.subnetValidator.validator.startTime.value().toString(),end:t.subnetValidator.validator.endTime.value().toString(),subnetID:t.subnetValidator.subnetId.value(),stakeOuts:t.stake,delegatorRewardsOwner:t.getDelegatorRewardsOwner(),...e}):null;export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pvmSerial as e,utils as a}from"@avalabs/avalanchejs";import{TxType as
|
|
1
|
+
import{pvmSerial as e,utils as a}from"@avalabs/avalanchejs";import{TxType as r}from"../../models.js";const t=t=>{if(!e.isAddPermissionlessValidatorTx(t))return null;let s,i;return e.isSigner(t.signer)&&(i=a.bufferToHex(t.signer.proof.publicKey),s=a.bufferToHex(t.signer.proof.signature)),({feeData:e})=>({type:r.AddPermissionlessValidator,chain:t.getVM(),stake:t.subnetValidator.validator.weight.value(),nodeID:t.subnetValidator.validator.nodeId.value(),start:t.subnetValidator.validator.startTime.value().toString(),end:t.subnetValidator.validator.endTime.value().toString(),subnetID:t.subnetValidator.subnetId.value(),delegationFee:t.shares.value(),stakeOuts:t.stake,rewardOwner:t.getValidatorRewardsOwner(),delegationRewardOwner:t.getDelegatorRewardsOwner(),signer:t.signer,publicKey:i,signature:s,...e})};export{t 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};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as _avalabs_avalanchejs_dist_serializable_common_types from '@avalabs/avalanchejs/dist/serializable/common/types';
|
|
1
2
|
import { Utxo } from '@avalabs/avalanchejs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -6,9 +7,9 @@ import { Utxo } from '@avalabs/avalanchejs';
|
|
|
6
7
|
* 2- Highest value UTXOs to lowest
|
|
7
8
|
* @remark Does not check for locked UTXOs
|
|
8
9
|
*/
|
|
9
|
-
declare function sortUTXOsStaking(utxos: Utxo[]): Utxo[];
|
|
10
|
-
declare function sortUTXOsByAmount(utxos: Utxo[], isDescending: boolean): Utxo[];
|
|
11
|
-
declare const sortUTXOsByAmountDescending: (utxos: Utxo[]) => Utxo[];
|
|
12
|
-
declare const sortUTXOsByAmountAscending: (utxos: Utxo[]) => Utxo[];
|
|
10
|
+
declare function sortUTXOsStaking(utxos: Utxo[]): Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[];
|
|
11
|
+
declare function sortUTXOsByAmount(utxos: Utxo[], isDescending: boolean): Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[];
|
|
12
|
+
declare const sortUTXOsByAmountDescending: (utxos: Utxo[]) => Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[];
|
|
13
|
+
declare const sortUTXOsByAmountAscending: (utxos: Utxo[]) => Utxo<_avalabs_avalanchejs_dist_serializable_common_types.Serializable>[];
|
|
13
14
|
|
|
14
15
|
export { sortUTXOsByAmount, sortUTXOsByAmountAscending, sortUTXOsByAmountDescending, sortUTXOsStaking };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Utxo } from '@avalabs/avalanchejs';
|
|
1
|
+
import { Utxo, pvm } from '@avalabs/avalanchejs';
|
|
2
2
|
import { WalletAbstract } from 'Avalanche/wallets';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -25,8 +25,15 @@ declare const P_CHAIN_TX_SIZE_LIMIT = 65536;
|
|
|
25
25
|
* @param utxos - list of UTXOs to be consumed by the transaction.
|
|
26
26
|
* @param sizeSupportedTx - one of the supported transaction types
|
|
27
27
|
* @param limit - optional - byte size limit, defaults to 64kb.
|
|
28
|
+
* @param feeState - current fee state on the chain
|
|
28
29
|
* @returns the largest prefix of sorted `utxos` before hitting the size limit. If no such prefix exists, then an empty array.
|
|
29
30
|
*/
|
|
30
|
-
declare function getMaximumUtxoSet(wallet
|
|
31
|
+
declare function getMaximumUtxoSet({ wallet, utxos, sizeSupportedTx, limit, feeState, }: {
|
|
32
|
+
wallet: WalletAbstract;
|
|
33
|
+
utxos: Utxo[];
|
|
34
|
+
sizeSupportedTx: SizeSupportedTx;
|
|
35
|
+
limit?: number;
|
|
36
|
+
feeState?: pvm.FeeState;
|
|
37
|
+
}): Utxo[];
|
|
31
38
|
|
|
32
39
|
export { P_CHAIN_TX_SIZE_LIMIT, SizeSupportedTx, getMaximumUtxoSet };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{utils as e}from"@avalabs/avalanchejs";import{getUtxoInfo as t}from"./getUtxoInfo.js";import{getUnixNow as o}from"./getUnixNow.js";import{binarySearch as
|
|
1
|
+
import{utils as e}from"@avalabs/avalanchejs";import{getUtxoInfo as t}from"./getUtxoInfo.js";import{getUnixNow as o}from"./getUnixNow.js";import{binarySearch as s}from"../../utils/binarySearch.js";import{sortUTXOsByAmountDescending as r,sortUTXOsByAmountAscending as n,sortUTXOsStaking as d}from"./sortUTXOs.js";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,o)=>e.reduce(((e,o)=>e+t(o).amount),BigInt(0))-o,l={BaseP:{sortFunction:r,unsignedTxBuilder:(t,o,s)=>{const r=t.getProvider().getContext();return t.baseTX({utxoSet:new e.UtxoSet(o),chain:"P",toAddress:t.getCurrentAddress("P"),amountsPerAsset:{[r.avaxAssetID]:c(o,r.baseTxFee)},feeState:s})}},ConsolidateP:{sortFunction:n,unsignedTxBuilder:(t,o,s)=>{const r=t.getProvider().getContext();return t.consolidateP({utxoSet:new e.UtxoSet(o),amount:c(o,r.baseTxFee),feeState:s})}},AddPermissionlessValidator:{sortFunction:d,unsignedTxBuilder:(t,s,r)=>t.addPermissionlessValidator({utxoSet:new e.UtxoSet(s),nodeId:i,start:o(),end:o()+BigInt(1e3),weight:c(s,t.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:d,unsignedTxBuilder:(t,s,r)=>t.addPermissionlessDelegator({utxoSet:new e.UtxoSet(s),nodeId:i,start:o(),end:o()+BigInt(1e3),weight:c(s,t.getProvider().getContext().baseTxFee),subnetId:u,feeState:r})},ExportP:{sortFunction:r,unsignedTxBuilder:(t,o,s)=>t.exportP({amount:c(o,t.getProvider().getContext().baseTxFee),utxoSet:new e.UtxoSet(o),destination:"X",feeState:s})},ImportP:{sortFunction:r,unsignedTxBuilder:(t,o,s)=>t.importP({utxoSet:new e.UtxoSet(o),sourceChain:"X",feeState:s})}},x=65536;function f({wallet:e,utxos:r,sizeSupportedTx:n,limit:d=65536,feeState:a}){const{sortFunction:i,unsignedTxBuilder:u}=l[n],c=o(),x=i(r.filter((e=>{const{locktime:o,stakeableLocktime:s}=t(e);return o<c&&(s<c||("AddPermissionlessDelegator"===n||"AddPermissionlessValidator"===n))}))),f=s(x,(o=>{try{return function(e){const o=e.getInputUtxos().reduce(((e,o)=>e+(8+65*t(o).threshold)),0);return 6+e.toBytes().length+o}(u(e,o,a))}catch(e){return console.log("Unable to estimate size of utxos",{e:e,utxos:o.map(t)}),d+1}}),d);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};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { utils, pvm, Common } from '@avalabs/avalanchejs';
|
|
2
|
+
|
|
3
|
+
type BaseTx = {
|
|
4
|
+
utxoSet: utils.UtxoSet;
|
|
5
|
+
chain: 'X' | 'P';
|
|
6
|
+
toAddress: string;
|
|
7
|
+
amountsPerAsset: Record<string, bigint>;
|
|
8
|
+
feeState?: pvm.FeeState;
|
|
9
|
+
options?: Common.SpendOptions;
|
|
10
|
+
fromAddresses?: string[];
|
|
11
|
+
};
|
|
12
|
+
type ImportP = {
|
|
13
|
+
utxoSet: utils.UtxoSet;
|
|
14
|
+
sourceChain: 'X' | 'C';
|
|
15
|
+
toAddress?: string;
|
|
16
|
+
threshold?: number;
|
|
17
|
+
feeState?: pvm.FeeState;
|
|
18
|
+
locktime?: bigint;
|
|
19
|
+
};
|
|
20
|
+
type ExportP = {
|
|
21
|
+
amount: bigint;
|
|
22
|
+
utxoSet: utils.UtxoSet;
|
|
23
|
+
destination: 'X' | 'C';
|
|
24
|
+
feeState?: pvm.FeeState;
|
|
25
|
+
toAddress?: string;
|
|
26
|
+
};
|
|
27
|
+
type ConsolidateP = {
|
|
28
|
+
utxoSet: utils.UtxoSet;
|
|
29
|
+
amount: bigint;
|
|
30
|
+
feeState?: pvm.FeeState;
|
|
31
|
+
toAddress?: string;
|
|
32
|
+
options?: Common.SpendOptions;
|
|
33
|
+
};
|
|
34
|
+
type CreateSubnet = {
|
|
35
|
+
utxoSet: utils.UtxoSet;
|
|
36
|
+
rewardAddresses: string[];
|
|
37
|
+
feeState?: pvm.FeeState;
|
|
38
|
+
fromAddresses?: string[];
|
|
39
|
+
options?: Common.SpendOptions;
|
|
40
|
+
threshold?: number;
|
|
41
|
+
locktime?: bigint;
|
|
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
|
+
};
|
|
112
|
+
type AddSubnetValidator = {
|
|
113
|
+
utxoSet: utils.UtxoSet;
|
|
114
|
+
nodeId: string;
|
|
115
|
+
start: bigint;
|
|
116
|
+
end: bigint;
|
|
117
|
+
weight: bigint;
|
|
118
|
+
subnetId: string;
|
|
119
|
+
subnetAuth: number[];
|
|
120
|
+
feeState?: pvm.FeeState;
|
|
121
|
+
fromAddresses?: string[];
|
|
122
|
+
options?: Common.SpendOptions;
|
|
123
|
+
};
|
|
124
|
+
type AddPermissionlessValidator = {
|
|
125
|
+
utxoSet: utils.UtxoSet;
|
|
126
|
+
nodeId: string;
|
|
127
|
+
start: bigint;
|
|
128
|
+
end: bigint;
|
|
129
|
+
weight: bigint;
|
|
130
|
+
subnetId: string;
|
|
131
|
+
shares: number;
|
|
132
|
+
fromAddresses?: string[];
|
|
133
|
+
rewardAddresses?: string[];
|
|
134
|
+
delegatorRewardAddresses?: string[];
|
|
135
|
+
publicKey?: Buffer;
|
|
136
|
+
signature?: Buffer;
|
|
137
|
+
options?: Common.SpendOptions;
|
|
138
|
+
stakingAssetId?: string;
|
|
139
|
+
locktime?: bigint;
|
|
140
|
+
threshold?: number;
|
|
141
|
+
feeState?: pvm.FeeState;
|
|
142
|
+
};
|
|
143
|
+
type AddPermissionlessDelegator = {
|
|
144
|
+
utxoSet: utils.UtxoSet;
|
|
145
|
+
nodeId: string;
|
|
146
|
+
start: bigint;
|
|
147
|
+
end: bigint;
|
|
148
|
+
weight: bigint;
|
|
149
|
+
subnetId: string;
|
|
150
|
+
fromAddresses?: string[];
|
|
151
|
+
rewardAddresses?: string[];
|
|
152
|
+
options?: Common.SpendOptions;
|
|
153
|
+
locktime?: bigint;
|
|
154
|
+
feeState?: pvm.FeeState;
|
|
155
|
+
stakingAssetId?: string;
|
|
156
|
+
threshold?: number;
|
|
157
|
+
};
|
|
158
|
+
type RemoveSubnetValidator = {
|
|
159
|
+
utxoSet: utils.UtxoSet;
|
|
160
|
+
nodeId: string;
|
|
161
|
+
subnetId: string;
|
|
162
|
+
subnetAuth: number[];
|
|
163
|
+
feeState?: pvm.FeeState;
|
|
164
|
+
fromAddresses?: string[];
|
|
165
|
+
options?: Common.SpendOptions;
|
|
166
|
+
};
|
|
167
|
+
type TransferSubnetOwnershipTx = {
|
|
168
|
+
utxoSet: utils.UtxoSet;
|
|
169
|
+
subnetId: string;
|
|
170
|
+
subnetAuth: number[];
|
|
171
|
+
subnetOwners: string[];
|
|
172
|
+
feeState?: pvm.FeeState;
|
|
173
|
+
fromAddresses?: string[];
|
|
174
|
+
options?: Common.SpendOptions;
|
|
175
|
+
threshold?: number;
|
|
176
|
+
locktime?: bigint;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export { AddPermissionlessDelegator, AddPermissionlessValidator, AddSubnetValidator, BaseTx, ConsolidateP, ConvertSubnetToL1, CreateChain, CreateSubnet, DisableL1Validator, ExportP, ImportP, IncreaseL1ValidatorBalance, RegisterL1Validator, RemoveSubnetValidator, SetL1ValidatorWeight, TransferSubnetOwnershipTx };
|
|
@@ -2,6 +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, ConvertSubnetToL1, RegisterL1Validator, SetL1ValidatorWeight, DisableL1Validator, IncreaseL1ValidatorBalance, CreateChain, CreateSubnet, AddSubnetValidator, AddPermissionlessValidator, AddPermissionlessDelegator, RemoveSubnetValidator, TransferSubnetOwnershipTx } from './TxBuilderTypes.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* An abstract class that that is shared by all wallet classes.
|
|
@@ -48,8 +49,12 @@ declare abstract class WalletAbstract {
|
|
|
48
49
|
* @param source What is the source chain of the atomic UTXOs
|
|
49
50
|
*/
|
|
50
51
|
getAtomicUTXOs(chain: ChainIDAlias, source: ChainIDAlias): Promise<utils.UtxoSet>;
|
|
52
|
+
/**
|
|
53
|
+
* Get the nonce of this wallet's C chain address
|
|
54
|
+
*/
|
|
55
|
+
getNonce(): Promise<number>;
|
|
51
56
|
exportX(amount: bigint, utxoSet: utils.UtxoSet, destination: 'P' | 'C', toAddress?: string): Common.UnsignedTx;
|
|
52
|
-
importP(
|
|
57
|
+
importP({ utxoSet, sourceChain, toAddress, threshold, feeState, locktime, }: ImportP): Common.UnsignedTx;
|
|
53
58
|
importX(utxos: utils.UtxoSet, sourceChain: 'P' | 'C', toAddress?: string): Common.UnsignedTx;
|
|
54
59
|
/**
|
|
55
60
|
*
|
|
@@ -69,10 +74,6 @@ declare abstract class WalletAbstract {
|
|
|
69
74
|
* @param toAddress
|
|
70
75
|
*/
|
|
71
76
|
exportC(amount: bigint, destination: 'X' | 'P', nonce: bigint, baseFee: bigint, toAddress?: string): _avalabs_avalanchejs.EVMUnsignedTx;
|
|
72
|
-
/**
|
|
73
|
-
* Get the nonce of this wallet's C chain address
|
|
74
|
-
*/
|
|
75
|
-
getNonce(): Promise<number>;
|
|
76
77
|
/**
|
|
77
78
|
* Export the given amount of AVAX from the P chain. Export fee is automatically added.
|
|
78
79
|
* @param amount
|
|
@@ -80,18 +81,23 @@ declare abstract class WalletAbstract {
|
|
|
80
81
|
* @param destination
|
|
81
82
|
* @param toAddress
|
|
82
83
|
*/
|
|
83
|
-
exportP(amount
|
|
84
|
-
addValidator(utxos: utils.UtxoSet,
|
|
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?: {
|
|
85
86
|
rewardAddress?: string;
|
|
86
87
|
}): Common.UnsignedTx;
|
|
87
|
-
addDelegator(utxos: utils.UtxoSet,
|
|
88
|
+
addDelegator(utxos: utils.UtxoSet, nodeId: string, stakeAmount: bigint, startDate: bigint, endDate: bigint, config?: {
|
|
88
89
|
rewardAddress?: string;
|
|
89
90
|
}): Common.UnsignedTx;
|
|
90
|
-
consolidateP(utxoSet
|
|
91
|
-
baseTX(utxoSet
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
consolidateP({ utxoSet, amount, feeState, toAddress, options, }: ConsolidateP): Common.UnsignedTx;
|
|
92
|
+
baseTX({ utxoSet, chain, toAddress, amountsPerAsset, feeState, options, fromAddresses, }: BaseTx): Common.UnsignedTx;
|
|
93
|
+
convertSubnetToL1({ utxoSet, chainId, subnetId, subnetAuth, feeState, address, validators, options, fromAddresses, }: ConvertSubnetToL1): Common.UnsignedTx;
|
|
94
|
+
registerL1Validator({ utxoSet, balance, signature, message, feeState, fromAddresses, options, }: RegisterL1Validator): Common.UnsignedTx;
|
|
95
|
+
setL1ValidatorWeight({ utxoSet, feeState, message, options, fromAddresses, }: SetL1ValidatorWeight): Common.UnsignedTx;
|
|
96
|
+
disableL1Validator({ utxoSet, feeState, options, fromAddresses, disableAuth, validationId, }: DisableL1Validator): Common.UnsignedTx;
|
|
97
|
+
increaseL1ValidatorBalance({ utxoSet, feeState, options, fromAddresses, balance, validationId, }: IncreaseL1ValidatorBalance): Common.UnsignedTx;
|
|
98
|
+
createBlockchain({ utxoSet, subnetId, chainName, vmID, fxIds, genesisData, subnetAuth, feeState, options, fromAddresses, }: CreateChain): Common.UnsignedTx;
|
|
99
|
+
createSubnet({ utxoSet, rewardAddresses, feeState, fromAddresses, options, threshold, locktime, }: CreateSubnet): Common.UnsignedTx;
|
|
100
|
+
addSubnetValidator({ utxoSet, nodeId, start, end, weight, subnetId, subnetAuth, feeState, fromAddresses, options, }: AddSubnetValidator): Common.UnsignedTx;
|
|
95
101
|
/**
|
|
96
102
|
*
|
|
97
103
|
* @param utxoSet The transaction will be constructed from these UTXOs.
|
|
@@ -108,7 +114,7 @@ declare abstract class WalletAbstract {
|
|
|
108
114
|
* @param signature the BLS signature, If the subnet is the primary network. Can be found in the Node on startup.
|
|
109
115
|
* @param options
|
|
110
116
|
*/
|
|
111
|
-
addPermissionlessValidator(utxoSet
|
|
117
|
+
addPermissionlessValidator({ utxoSet, nodeId, start, end, weight, subnetId, shares, feeState, fromAddresses, rewardAddresses, delegatorRewardAddresses, publicKey, signature, options, threshold, locktime, stakingAssetId, }: AddPermissionlessValidator): Common.UnsignedTx;
|
|
112
118
|
/**
|
|
113
119
|
*
|
|
114
120
|
* @param utxoSet The transaction will be constructed from these UTXOs.
|
|
@@ -121,10 +127,10 @@ declare abstract class WalletAbstract {
|
|
|
121
127
|
* @param rewardAddresses Will use active address if not provided. Given addresses will share the reward UTXO.
|
|
122
128
|
* @param options
|
|
123
129
|
*/
|
|
124
|
-
addPermissionlessDelegator(utxoSet
|
|
125
|
-
removeSubnetValidator(utxoSet
|
|
126
|
-
transferSubnetOwnershipTx(utxoSet
|
|
127
|
-
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:
|
|
130
|
+
addPermissionlessDelegator({ utxoSet, nodeId, start, end, weight, subnetId, fromAddresses, rewardAddresses, options, locktime, feeState, threshold, stakingAssetId, }: AddPermissionlessDelegator): Common.UnsignedTx;
|
|
131
|
+
removeSubnetValidator({ utxoSet, nodeId, subnetId, subnetAuth, fromAddresses, feeState, options, }: RemoveSubnetValidator): Common.UnsignedTx;
|
|
132
|
+
transferSubnetOwnershipTx({ utxoSet, subnetId, subnetAuth, subnetOwners, feeState, fromAddresses, options, threshold, locktime, }: TransferSubnetOwnershipTx): Common.UnsignedTx;
|
|
133
|
+
transformSubnetTx(utxoSet: utils.UtxoSet, subnetId: string, assetId: string, initialSupply: bigint, maximumSupply: bigint, minConsumptionRate: bigint, maxConsumptionRate: bigint, minValidatorStake: bigint, maxValidatorStake: bigint, minStakeDuration: number, maxStakeDuration: number, minDelegationFee: number, minDelegatorStake: bigint, maxValidatorWeightFactor: number, uptimeRequirement: number, subnetAuth: number[], fromAddresses?: string[], options?: Common.SpendOptions): Common.UnsignedTx;
|
|
128
134
|
protected constructor(provider: AbstractProvider);
|
|
129
135
|
}
|
|
130
136
|
|