@avalabs/avalanche-module
Advanced tools
Comparing version 0.0.0-cp-8871-20240710150136 to 0.0.0-cp-8871-20240710230626
# @avalabs/avalanche-module | ||
## 0.0.0-cp-8871-20240710150136 | ||
## 0.0.0-cp-8871-20240710230626 | ||
@@ -9,2 +9,2 @@ ### Patch Changes | ||
- Updated dependencies [e73871d] | ||
- @avalabs/vm-module-types@0.0.0-cp-8871-20240710150136 | ||
- @avalabs/vm-module-types@0.0.0-cp-8871-20240710230626 |
@@ -6,6 +6,6 @@ import { parseManifest, TokenType } from '@avalabs/vm-module-types'; | ||
var v=(e,n,t)=>{if(!n.has(e))throw TypeError("Cannot "+t)};var I=(e,n,t)=>(v(e,n,"read from private field"),t?t.call(e):n.get(e)),N=(e,n,t)=>{if(n.has(e))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(e):n.set(e,t);},w=(e,n,t,a)=>(v(e,n,"write to private field"),a?a.call(e,t):n.set(e,t),t);var P={name:"AVM",description:"",version:"0.0.1",sources:{module:{checksum:"",location:{npm:{filePath:"dist/bundle.js",packageName:"@avalabs/avalanche-module",registry:"https://registry.npmjs.org"}}},provider:{checksum:"",location:{npm:{filePath:"dist/provider.js",packageName:"@avalabs/avalanche-module",registry:"https://registry.npmjs.org"}}}},network:{chainIds:["avax:2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM","avax:2JVSBoinj9C2J33VntvzYtVJNZdN2NKiwwKjcumHUWEb5DbBrm","avax:11111111111111111111111111111111LpoYY","avax:fuji-11111111111111111111111111111111LpoYY"],namespaces:["avax"]},cointype:"",permissions:{rpc:{dapps:!0,methods:["avalanche_sendTransaction","avalanche_*"]}},manifestVersion:"0.0"};var L=e=>e.chainInfo.chainName===PrimaryNetworkChainName.P_CHAIN,S=e=>e.chainInfo.chainName===PrimaryNetworkChainName.X_CHAIN;function x(e,n,t="tx"){return `${e}/${t}/${n}`}function h({amount:e,decimals:n}){return e===void 0?new l(0):new l(e/10**n)}function E(e,n,t,a,c,m){let s=new Set(e.consumedUtxos.flatMap(o=>o.addresses)||[]),u=new Set(e.emittedUtxos.flatMap(o=>o.addresses)||[]),r=G({tx:e,isTestnet:n,networkToken:a,froms:s}),i=D({tx:e,isTestnet:n,networkToken:a}),p=t.toLowerCase().startsWith("p-")?t.slice(2):t,d=s.has(p);return {hash:e.txHash,isContractCall:!1,isIncoming:!d,isOutgoing:d,from:[...s.values()].join(","),to:[...u.values()].join(","),isSender:d,timestamp:e.blockTimestamp*1e3,tokens:[{decimal:a.decimals.toString(),name:a.name,symbol:a.symbol,type:TokenType.NATIVE,amount:r.toString()}],gasUsed:i.toString(),explorerLink:x(c,e.txHash,"tx"),txType:e.txType,chainId:m.toString()}}function G({tx:e,isTestnet:n,networkToken:t,froms:a}){let c=["ImportTx","ExportTx"].includes(e.txType),m=e.txType==="BaseTx",s=e.emittedUtxos.filter(o=>o.asset.assetId===T(!!n)&&!o.addresses.some(g=>a.has(g))).reduce((o,g)=>o.add(g.asset.amount),new l(0)),u=e.value.find(o=>o.assetId===T(!!n))?.amount,r=s.gt(new l(0))?s:u?new l(u):new l(0)??new l(0),i=n?Avalanche.FujiContext.pBlockchainID:Avalanche.MainnetContext.pBlockchainID,p=e.emittedUtxos.filter(o=>o.asset.assetId===T(!!n)&&(e.txType==="ImportTx"&&o.consumedOnChainId===i||e.txType==="ExportTx"&&o.consumedOnChainId!==i)).reduce((o,g)=>o.add(g.amount),new l(0)),d=m?r:c?p:e.amountStaked.length===0?F(e.value,!!n):F(e.amountStaked,!!n);return h({amount:d?.toNumber(),decimals:t.decimals})}function D({tx:e,isTestnet:n,networkToken:t}){let a=e.amountBurned?.filter(c=>c.assetId===T(!!n)).reduce((c,m)=>c.add(m.amount),new l(0));return h({amount:a?.toNumber(),decimals:t.decimals})}function F(e,n){return e.filter(t=>t.assetId===T(n)).reduce((t,a)=>t.add(a.amount),new l(0))}function T(e){return e?Avalanche.FujiContext.avaxAssetID:Avalanche.MainnetContext.avaxAssetID}function H(e,n,t,a,c,m){let s=new Set(e.consumedUtxos.flatMap(o=>o.addresses)||[]),u=new Set(e.emittedUtxos.flatMap(o=>o.addresses)||[]),r=_({tx:e,isTestnet:n,networkToken:a}),i=J({isTestnet:n,tx:e,totalAmountCreated:r,networkToken:a}),p=t.toLowerCase().startsWith("x-")?t.slice(2):t,d=s.has(p);return {hash:e.txHash,isContractCall:!1,isIncoming:!d,isOutgoing:d,from:[...s.values()].join(","),to:[...u.values()].join(","),isSender:d,timestamp:e.timestamp*1e3,tokens:[{decimal:a.decimals.toString(),name:a.name,symbol:a.symbol,type:TokenType.NATIVE,amount:r.toString()}],gasUsed:i.toString(),explorerLink:x(c,e.txHash,"tx"),txType:e.txType,chainId:m.toString()}}function _({tx:e,isTestnet:n,networkToken:t}){let a=["ImportTx","ExportTx"].includes(e.txType),c=n?Avalanche.FujiContext.xBlockchainID:Avalanche.MainnetContext.xBlockchainID,m=e.emittedUtxos.filter(r=>r.asset.assetId===k(!!n)&&(e.txType==="ImportTx"&&r.consumedOnChainId===c||e.txType==="ExportTx"&&r.consumedOnChainId!==c)).reduce((r,i)=>r.add(i.asset.amount),new l(0)),s=e.amountCreated.filter(r=>r.assetId===k(!!n)).reduce((r,i)=>r.add(i.amount),new l(0));return h({amount:(a?m:s).toNumber(),decimals:t.decimals})}function J({isTestnet:e,tx:n,totalAmountCreated:t,networkToken:a}){let m=n.amountUnlocked.filter(s=>s.assetId===k(!!e)).reduce((s,u)=>s.add(u.amount),new l(0)).minus(t);return h({amount:m.toNumber(),decimals:a.decimals})}function k(e){return e?Avalanche.FujiContext.avaxAssetID:Avalanche.MainnetContext.avaxAssetID}var X=async({isTestnet:e,address:n,nextPageToken:t,offset:a,glacierApiUrl:c,networkToken:m,explorerUrl:s,chainId:u})=>{let i=await new Glacier({BASE:c}).primaryNetworkTransactions.listLatestPrimaryNetworkTransactions({addresses:n,blockchainId:W(n),network:e?Network.FUJI:Network.MAINNET,pageSize:a,pageToken:t,sortOrder:SortOrder.DESC}),p=[];return L(i)&&(p=i.transactions.map(d=>E(d,e,n,m,s,u))),S(i)&&(p=i.transactions.map(d=>H(d,e,n,m,s,u))),{transactions:p,nextPageToken:i.nextPageToken}},W=e=>e.split(",")[0]?.toLowerCase().startsWith("p-")?BlockchainId.P_CHAIN:BlockchainId.X_CHAIN;var f,j=class{constructor({glacierApiUrl:n}){N(this,f,void 0);w(this,f,n);}getAddress(){return Promise.resolve("Avalanche address")}getBalances(){return Promise.resolve("Avalanche balances")}getManifest(){let n=parseManifest(P);return n.success?n.data:void 0}getNetworkFee(n){return Promise.resolve({low:{maxPriorityFeePerGas:0n,maxFeePerGas:0n},medium:{maxPriorityFeePerGas:0n,maxFeePerGas:0n},high:{maxPriorityFeePerGas:0n,maxFeePerGas:0n},baseFee:0n})}getTokens(){return Promise.resolve([])}getTransactionHistory(n){return X({...n,glacierApiUrl:I(this,f)})}async onRpcRequest(n){switch(n.method){default:return {error:new Error(`Method ${n.method} not supported`)}}}};f=new WeakMap; | ||
var v=(e,n,t)=>{if(!n.has(e))throw TypeError("Cannot "+t)};var I=(e,n,t)=>(v(e,n,"read from private field"),t?t.call(e):n.get(e)),N=(e,n,t)=>{if(n.has(e))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(e):n.set(e,t);},w=(e,n,t,a)=>(v(e,n,"write to private field"),a?a.call(e,t):n.set(e,t),t);var P={name:"Avalanche",description:"",version:"0.0.1",sources:{module:{checksum:"",location:{npm:{filePath:"dist/bundle.js",packageName:"@avalabs/avalanche-module",registry:"https://registry.npmjs.org"}}},provider:{checksum:"",location:{npm:{filePath:"dist/provider.js",packageName:"@avalabs/avalanche-module",registry:"https://registry.npmjs.org"}}}},network:{chainIds:["avax:2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM","avaxfuji:2JVSBoinj9C2J33VntvzYtVJNZdN2NKiwwKjcumHUWEb5DbBrm","avax:11111111111111111111111111111111LpoYY","avaxfuji:11111111111111111111111111111111LpoYY"],namespaces:["avax","avaxfuji"]},cointype:"60",permissions:{rpc:{dapps:!0,methods:["avalanche_sendTransaction","avalanche_*"]}},manifestVersion:"0.0"};var L=e=>e.chainInfo.chainName===PrimaryNetworkChainName.P_CHAIN,S=e=>e.chainInfo.chainName===PrimaryNetworkChainName.X_CHAIN;function x(e,n,t="tx"){return `${e}/${t}/${n}`}function h({amount:e,decimals:n}){return e===void 0?new l(0):new l(e/10**n)}function j(e,n,t,a,c,m){let s=new Set(e.consumedUtxos.flatMap(o=>o.addresses)||[]),u=new Set(e.emittedUtxos.flatMap(o=>o.addresses)||[]),r=G({tx:e,isTestnet:n,networkToken:a,froms:s}),i=D({tx:e,isTestnet:n,networkToken:a}),p=t.toLowerCase().startsWith("p-")?t.slice(2):t,d=s.has(p);return {hash:e.txHash,isContractCall:!1,isIncoming:!d,isOutgoing:d,from:[...s.values()].join(","),to:[...u.values()].join(","),isSender:d,timestamp:e.blockTimestamp*1e3,tokens:[{decimal:a.decimals.toString(),name:a.name,symbol:a.symbol,type:TokenType.NATIVE,amount:r.toString()}],gasUsed:i.toString(),explorerLink:x(c,e.txHash,"tx"),txType:e.txType,chainId:m.toString()}}function G({tx:e,isTestnet:n,networkToken:t,froms:a}){let c=["ImportTx","ExportTx"].includes(e.txType),m=e.txType==="BaseTx",s=e.emittedUtxos.filter(o=>o.asset.assetId===T(!!n)&&!o.addresses.some(g=>a.has(g))).reduce((o,g)=>o.add(g.asset.amount),new l(0)),u=e.value.find(o=>o.assetId===T(!!n))?.amount,r=s.gt(new l(0))?s:u?new l(u):new l(0)??new l(0),i=n?Avalanche.FujiContext.pBlockchainID:Avalanche.MainnetContext.pBlockchainID,p=e.emittedUtxos.filter(o=>o.asset.assetId===T(!!n)&&(e.txType==="ImportTx"&&o.consumedOnChainId===i||e.txType==="ExportTx"&&o.consumedOnChainId!==i)).reduce((o,g)=>o.add(g.amount),new l(0)),d=m?r:c?p:e.amountStaked.length===0?F(e.value,!!n):F(e.amountStaked,!!n);return h({amount:d?.toNumber(),decimals:t.decimals})}function D({tx:e,isTestnet:n,networkToken:t}){let a=e.amountBurned?.filter(c=>c.assetId===T(!!n)).reduce((c,m)=>c.add(m.amount),new l(0));return h({amount:a?.toNumber(),decimals:t.decimals})}function F(e,n){return e.filter(t=>t.assetId===T(n)).reduce((t,a)=>t.add(a.amount),new l(0))}function T(e){return e?Avalanche.FujiContext.avaxAssetID:Avalanche.MainnetContext.avaxAssetID}function E(e,n,t,a,c,m){let s=new Set(e.consumedUtxos.flatMap(o=>o.addresses)||[]),u=new Set(e.emittedUtxos.flatMap(o=>o.addresses)||[]),r=_({tx:e,isTestnet:n,networkToken:a}),i=J({isTestnet:n,tx:e,totalAmountCreated:r,networkToken:a}),p=t.toLowerCase().startsWith("x-")?t.slice(2):t,d=s.has(p);return {hash:e.txHash,isContractCall:!1,isIncoming:!d,isOutgoing:d,from:[...s.values()].join(","),to:[...u.values()].join(","),isSender:d,timestamp:e.timestamp*1e3,tokens:[{decimal:a.decimals.toString(),name:a.name,symbol:a.symbol,type:TokenType.NATIVE,amount:r.toString()}],gasUsed:i.toString(),explorerLink:x(c,e.txHash,"tx"),txType:e.txType,chainId:m.toString()}}function _({tx:e,isTestnet:n,networkToken:t}){let a=["ImportTx","ExportTx"].includes(e.txType),c=n?Avalanche.FujiContext.xBlockchainID:Avalanche.MainnetContext.xBlockchainID,m=e.emittedUtxos.filter(r=>r.asset.assetId===k(!!n)&&(e.txType==="ImportTx"&&r.consumedOnChainId===c||e.txType==="ExportTx"&&r.consumedOnChainId!==c)).reduce((r,i)=>r.add(i.asset.amount),new l(0)),s=e.amountCreated.filter(r=>r.assetId===k(!!n)).reduce((r,i)=>r.add(i.amount),new l(0));return h({amount:(a?m:s).toNumber(),decimals:t.decimals})}function J({isTestnet:e,tx:n,totalAmountCreated:t,networkToken:a}){let m=n.amountUnlocked.filter(s=>s.assetId===k(!!e)).reduce((s,u)=>s.add(u.amount),new l(0)).minus(t);return h({amount:m.toNumber(),decimals:a.decimals})}function k(e){return e?Avalanche.FujiContext.avaxAssetID:Avalanche.MainnetContext.avaxAssetID}var M=async({isTestnet:e,address:n,nextPageToken:t,offset:a,glacierApiUrl:c,networkToken:m,explorerUrl:s,chainId:u})=>{let i=await new Glacier({BASE:c}).primaryNetworkTransactions.listLatestPrimaryNetworkTransactions({addresses:n,blockchainId:W(n),network:e?Network.FUJI:Network.MAINNET,pageSize:a,pageToken:t,sortOrder:SortOrder.DESC}),p=[];return L(i)&&(p=i.transactions.map(d=>j(d,e,n,m,s,u))),S(i)&&(p=i.transactions.map(d=>E(d,e,n,m,s,u))),{transactions:p,nextPageToken:i.nextPageToken}},W=e=>e.split(",")[0]?.toLowerCase().startsWith("p-")?BlockchainId.P_CHAIN:BlockchainId.X_CHAIN;var f,X=class{constructor({glacierApiUrl:n}){N(this,f,void 0);w(this,f,n);}getAddress(){return Promise.resolve("Avalanche address")}getBalances(){return Promise.resolve("Avalanche balances")}getManifest(){let n=parseManifest(P);return n.success?n.data:void 0}getNetworkFee(n){return Promise.resolve({low:{maxPriorityFeePerGas:0n,maxFeePerGas:0n},medium:{maxPriorityFeePerGas:0n,maxFeePerGas:0n},high:{maxPriorityFeePerGas:0n,maxFeePerGas:0n},baseFee:0n})}getTokens(){return Promise.resolve([])}getTransactionHistory(n){return M({...n,glacierApiUrl:I(this,f)})}async onRpcRequest(n){switch(n.method){default:return {error:new Error(`Method ${n.method} not supported`)}}}};f=new WeakMap; | ||
export { j as AvalancheModule }; | ||
export { X as AvalancheModule }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@avalabs/avalanche-module", | ||
"version": "0.0.0-cp-8871-20240710150136", | ||
"version": "0.0.0-cp-8871-20240710230626", | ||
"main": "dist/index.cjs", | ||
@@ -9,3 +9,3 @@ "module": "dist/index.js", | ||
"dependencies": { | ||
"@avalabs/vm-module-types": "0.0.0-cp-8871-20240710150136", | ||
"@avalabs/vm-module-types": "0.0.0-cp-8871-20240710230626", | ||
"@avalabs/utils-sdk": "v2.8.0-alpha.187", | ||
@@ -12,0 +12,0 @@ "@avalabs/chains-sdk": "v2.8.0-alpha.187", |
@@ -10,3 +10,3 @@ import type { | ||
import { parseManifest } from '@avalabs/vm-module-types'; | ||
import ManifestJson from './manifest.json'; | ||
import ManifestJson from '../manifest.json'; | ||
import { getTransactionHistory } from './handlers/get-transaction-history/get-transaction-history'; | ||
@@ -13,0 +13,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
75962
+ Added@avalabs/vm-module-types@0.0.0-cp-8871-20240710230626(transitive)
- Removed@avalabs/vm-module-types@0.0.0-cp-8871-20240710150136(transitive)
Updated@avalabs/vm-module-types@0.0.0-cp-8871-20240710230626