@avalabs/bitcoin-module
Advanced tools
Comparing version 0.0.0-feat-btc-get-network-fee-20240717131505 to 0.0.0-updateManifestJson-20240717164506
# @avalabs/bitcoin-module | ||
## 0.0.0-feat-btc-get-network-fee-20240717131505 | ||
## 0.0.0-updateManifestJson-20240717164506 | ||
### Patch Changes | ||
- d3bb6e1: feat: created bitcoin module | ||
- @avalabs/vm-module-types@0.0.0-feat-btc-get-network-fee-20240717131505 | ||
- de9824c: feat: created bitcoin module | ||
- @avalabs/vm-module-types@0.0.0-updateManifestJson-20240717164506 |
import * as _metamask_rpc_errors from '@metamask/rpc-errors'; | ||
import { Module, Environment, Manifest, Network, NetworkFees, GetTransactionHistory, RpcRequest } from '@avalabs/vm-module-types'; | ||
import { Module, Manifest, Network, NetworkFees, GetTransactionHistory, RpcRequest } from '@avalabs/vm-module-types'; | ||
declare class BitcoinModule implements Module { | ||
#private; | ||
constructor({ environment }: { | ||
environment: Environment; | ||
}); | ||
getAddress(): Promise<string>; | ||
getBalances(): Promise<string>; | ||
getManifest(): Manifest | undefined; | ||
getNetworkFee(network: Network): Promise<NetworkFees>; | ||
getNetworkFee(_: Network): Promise<NetworkFees>; | ||
getTransactionHistory(_: GetTransactionHistory): Promise<{ | ||
@@ -14,0 +10,0 @@ transactions: never[]; |
@@ -1,9 +0,8 @@ | ||
import { parseManifest, Environment } from '@avalabs/vm-module-types'; | ||
import { parseManifest } from '@avalabs/vm-module-types'; | ||
import { rpcErrors } from '@metamask/rpc-errors'; | ||
import { BitcoinProvider } from '@avalabs/wallets-sdk'; | ||
var n=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var i=(r,e,t)=>(n(r,e,"read from private field"),t?t.call(r):e.get(r)),a=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t);},p=(r,e,t,s)=>(n(r,e,"write to private field"),s?s.call(r,t):e.set(r,t),t);var f={glacierApiUrl:"https://glacier-api.avax.network",proxyApiUrl:"https://proxy-api.avax.network"},k={glacierApiUrl:"https://glacier-api-dev.avax.network",proxyApiUrl:"https://proxy-api-dev.avax.network"},c=r=>{switch(r){case Environment.PRODUCTION:return f;case Environment.DEV:return k}};var d={name:"Bitcoin",description:"",version:"0.0.1",sources:{module:{checksum:"",location:{npm:{filePath:"dist/bundle.js",packageName:"@avalabs/bitcoin-module",registry:"https://registry.npmjs.org"}}},provider:{checksum:"",location:{npm:{filePath:"dist/provider.js",packageName:"@avalabs/bitcoin-module",registry:"https://registry.npmjs.org"}}}},network:{chainIds:["bip122:000000000019d6689c085ae165831e93","bip122:000000000933ea01ad0ee984209779ba"],namespaces:["bip122"]},cointype:"60",permissions:{rpc:{dapps:!0,methods:["bitcoin_sendTransaction"]}},manifestVersion:"0.0"};var l=process.env.GLACIER_API_KEY,v=({isTestnet:r,proxyApiUrl:e})=>new BitcoinProvider(!r,void 0,`${e}/proxy/nownodes/${r?"btcbook-testnet":"btcbook"}`,`${e}/proxy/nownodes/${r?"btc-testnet":"btc"}`,l?{token:l}:{});async function g({isTestnet:r,proxyApiUrl:e}){let t=v({isTestnet:r,proxyApiUrl:e}),{high:s,low:y,medium:x}=await t.getFeeRates();return {low:{maxFeePerGas:BigInt(y)},medium:{maxFeePerGas:BigInt(x)},high:{maxFeePerGas:BigInt(s)},isFixedFee:!1}}var o,u=class{constructor({environment:e}){a(this,o,void 0);let{proxyApiUrl:t}=c(e);p(this,o,t);}getAddress(){return Promise.resolve("Bitcoin address")}getBalances(){return Promise.resolve("Bitcoin balances")}getManifest(){let e=parseManifest(d);return e.success?e.data:void 0}getNetworkFee(e){let{isTestnet:t}=e;return g({isTestnet:!!t,proxyApiUrl:i(this,o)})}getTransactionHistory(e){return Promise.resolve({transactions:[]})}getTokens(e){return Promise.resolve([])}async onRpcRequest(e,t){switch(e.method){default:return {error:rpcErrors.methodNotSupported(`Method ${e.method} not supported`)}}}};o=new WeakMap; | ||
var r={name:"Bitcoin",description:"",version:"0.0.1",sources:{module:{checksum:"",location:{npm:{filePath:"dist/bundle.js",packageName:"@avalabs/bitcoin-module",registry:"https://registry.npmjs.org"}}},provider:{checksum:"",location:{npm:{filePath:"dist/provider.js",packageName:"@avalabs/bitcoin-module",registry:"https://registry.npmjs.org"}}}},network:{chainIds:["bip122:000000000019d6689c085ae165831e93","bip122:000000000933ea01ad0ee984209779ba"],namespaces:["bip122"]},cointype:"0",permissions:{rpc:{dapps:!0,methods:["bitcoin_sendTransaction"]}},manifestVersion:"0.0"};var s=class{getAddress(){return Promise.resolve("Bitcoin address")}getBalances(){return Promise.resolve("Bitcoin balances")}getManifest(){let e=parseManifest(r);return e.success?e.data:void 0}getNetworkFee(e){return Promise.resolve({baseFee:1n,low:{maxFeePerGas:1n},medium:{maxFeePerGas:2n},high:{maxFeePerGas:4n},isFixedFee:!1})}getTransactionHistory(e){return Promise.resolve({transactions:[]})}getTokens(e){return Promise.resolve([])}async onRpcRequest(e,a){switch(e.method){default:return {error:rpcErrors.methodNotSupported(`Method ${e.method} not supported`)}}}}; | ||
export { u as BitcoinModule }; | ||
export { s as BitcoinModule }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.js.map |
@@ -31,3 +31,3 @@ { | ||
}, | ||
"cointype": "60", | ||
"cointype": "0", | ||
"permissions": { | ||
@@ -34,0 +34,0 @@ "rpc": { |
{ | ||
"name": "@avalabs/bitcoin-module", | ||
"version": "0.0.0-feat-btc-get-network-fee-20240717131505", | ||
"version": "0.0.0-updateManifestJson-20240717164506", | ||
"main": "dist/index.cjs", | ||
@@ -9,3 +9,3 @@ "module": "dist/index.js", | ||
"dependencies": { | ||
"@avalabs/vm-module-types": "0.0.0-feat-btc-get-network-fee-20240717131505", | ||
"@avalabs/vm-module-types": "0.0.0-updateManifestJson-20240717164506", | ||
"@avalabs/wallets-sdk": "2.8.0-alpha.188", | ||
@@ -20,3 +20,2 @@ "@metamask/rpc-errors": "6.3.0" | ||
"@internal/tsup-config": "0.0.1", | ||
"@internal/utils": "0.0.0-feat-btc-get-network-fee-20240717131505", | ||
"eslint-config-custom": "0.0.1" | ||
@@ -23,0 +22,0 @@ }, |
@@ -8,19 +8,9 @@ import type { | ||
Network, | ||
Environment, | ||
} from '@avalabs/vm-module-types'; | ||
import { parseManifest } from '@avalabs/vm-module-types'; | ||
import { rpcErrors } from '@metamask/rpc-errors'; | ||
import { getEnv } from '@internal/utils/src/utils/env'; | ||
import ManifestJson from '../manifest.json'; | ||
import { getNetworkFee } from './handlers/get-network-fee/get-network-fee'; | ||
export class BitcoinModule implements Module { | ||
#proxyApiUrl: string; | ||
constructor({ environment }: { environment: Environment }) { | ||
const { proxyApiUrl } = getEnv(environment); | ||
this.#proxyApiUrl = proxyApiUrl; | ||
} | ||
getAddress(): Promise<string> { | ||
@@ -39,8 +29,15 @@ return Promise.resolve('Bitcoin address'); | ||
getNetworkFee(network: Network): Promise<NetworkFees> { | ||
const { isTestnet } = network; | ||
return getNetworkFee({ | ||
isTestnet: Boolean(isTestnet), | ||
proxyApiUrl: this.#proxyApiUrl, | ||
getNetworkFee(_: Network): Promise<NetworkFees> { | ||
return Promise.resolve({ | ||
baseFee: 1n, | ||
low: { | ||
maxFeePerGas: 1n, | ||
}, | ||
medium: { | ||
maxFeePerGas: 2n, | ||
}, | ||
high: { | ||
maxFeePerGas: 4n, | ||
}, | ||
isFixedFee: false, | ||
}); | ||
@@ -47,0 +44,0 @@ } |
@@ -5,11 +5,5 @@ { | ||
"outDir": "./dist", | ||
"declaration": false, | ||
"incremental": false // Need to turn off because of tsup dts | ||
}, | ||
"include": ["src"], | ||
"references": [ | ||
{ | ||
"path": "../../packages-internal/utils/tsconfig.json" | ||
} | ||
] | ||
"include": ["src"] | ||
} |
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
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
6
2
1
16776
19
153