@avalabs/bitcoin-module
Advanced tools
Comparing version 0.0.0-feat-bootstrap-btc-module-20240717115114 to 0.0.0-feat-btc-get-network-fee-20240717131505
# @avalabs/bitcoin-module | ||
## 0.0.0-feat-bootstrap-btc-module-20240717115114 | ||
## 0.0.0-feat-btc-get-network-fee-20240717131505 | ||
### Patch Changes | ||
- e8cd879: feat: created bitcoin module | ||
- d3bb6e1: feat: created bitcoin module | ||
- @avalabs/vm-module-types@0.0.0-feat-btc-get-network-fee-20240717131505 |
import * as _metamask_rpc_errors from '@metamask/rpc-errors'; | ||
import { Module, Manifest, Network, NetworkFees, GetTransactionHistory, RpcRequest } from '@avalabs/vm-module-types'; | ||
import { Module, Environment, 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): Promise<NetworkFees>; | ||
getNetworkFee(network: Network): Promise<NetworkFees>; | ||
getTransactionHistory(_: GetTransactionHistory): Promise<{ | ||
@@ -10,0 +14,0 @@ transactions: never[]; |
@@ -1,8 +0,9 @@ | ||
import { parseManifest } from '@avalabs/vm-module-types'; | ||
import { parseManifest, Environment } from '@avalabs/vm-module-types'; | ||
import { rpcErrors } from '@metamask/rpc-errors'; | ||
import { BitcoinProvider } from '@avalabs/wallets-sdk'; | ||
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:"60",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`)}}}}; | ||
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; | ||
export { s as BitcoinModule }; | ||
export { u as BitcoinModule }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@avalabs/bitcoin-module", | ||
"version": "0.0.0-feat-bootstrap-btc-module-20240717115114", | ||
"version": "0.0.0-feat-btc-get-network-fee-20240717131505", | ||
"main": "dist/index.cjs", | ||
@@ -9,3 +9,3 @@ "module": "dist/index.js", | ||
"dependencies": { | ||
"@avalabs/vm-module-types": "0.0.13", | ||
"@avalabs/vm-module-types": "0.0.0-feat-btc-get-network-fee-20240717131505", | ||
"@avalabs/wallets-sdk": "2.8.0-alpha.188", | ||
@@ -20,3 +20,4 @@ "@metamask/rpc-errors": "6.3.0" | ||
"@internal/tsup-config": "0.0.1", | ||
"eslint-config-custom": "0.0.3" | ||
"@internal/utils": "0.0.0-feat-btc-get-network-fee-20240717131505", | ||
"eslint-config-custom": "0.0.1" | ||
}, | ||
@@ -23,0 +24,0 @@ "scripts": { |
@@ -8,9 +8,19 @@ 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> { | ||
@@ -29,15 +39,8 @@ return Promise.resolve('Bitcoin address'); | ||
getNetworkFee(_: Network): Promise<NetworkFees> { | ||
return Promise.resolve({ | ||
baseFee: 1n, | ||
low: { | ||
maxFeePerGas: 1n, | ||
}, | ||
medium: { | ||
maxFeePerGas: 2n, | ||
}, | ||
high: { | ||
maxFeePerGas: 4n, | ||
}, | ||
isFixedFee: false, | ||
getNetworkFee(network: Network): Promise<NetworkFees> { | ||
const { isTestnet } = network; | ||
return getNetworkFee({ | ||
isTestnet: Boolean(isTestnet), | ||
proxyApiUrl: this.#proxyApiUrl, | ||
}); | ||
@@ -44,0 +47,0 @@ } |
@@ -5,5 +5,11 @@ { | ||
"outDir": "./dist", | ||
"declaration": false, | ||
"incremental": false // Need to turn off because of tsup dts | ||
}, | ||
"include": ["src"] | ||
"include": ["src"], | ||
"references": [ | ||
{ | ||
"path": "../../packages-internal/utils/tsconfig.json" | ||
} | ||
] | ||
} |
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
28307
21
219
7
3
3
+ Added@avalabs/vm-module-types@0.0.0-feat-btc-get-network-fee-20240717131505(transitive)
- Removed@avalabs/vm-module-types@0.0.13(transitive)
Updated@avalabs/vm-module-types@0.0.0-feat-btc-get-network-fee-20240717131505