@avalabs/bitcoin-module
Advanced tools
Comparing version 0.0.0-testGetBalance-20240722173538 to 0.0.0-testgetbalances-20240722175742
# @avalabs/bitcoin-module | ||
## 0.0.0-testGetBalance-20240722173538 | ||
## 0.0.0-testgetbalances-20240722175742 | ||
### Patch Changes | ||
- Updated dependencies [e3c98c9] | ||
- @avalabs/vm-module-types@0.0.0-testgetbalances-20240722175742 | ||
## 0.0.16 | ||
### Patch Changes | ||
- de9824c: feat: created bitcoin module | ||
- @avalabs/vm-module-types@0.0.0-testGetBalance-20240722173538 | ||
- Updated dependencies [bc48457] | ||
- @avalabs/vm-module-types@0.0.16 |
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>; | ||
getBalances(): Promise<{}>; | ||
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:"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`)}}}}; | ||
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 y={glacierApiUrl:"https://glacier-api.avax.network",proxyApiUrl:"https://proxy-api.avax.network"},f={glacierApiUrl:"https://glacier-api-dev.avax.network",proxyApiUrl:"https://proxy-api-dev.avax.network"},c=r=>{switch(r){case Environment.PRODUCTION:return y;case Environment.DEV:return f}};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:"0",permissions:{rpc:{dapps:!0,methods:["bitcoin_sendTransaction"]}},manifestVersion:"0.0"};var l=({isTestnet:r,proxyApiUrl:e})=>new BitcoinProvider(!r,void 0,`${e}/proxy/nownodes/${r?"btcbook-testnet":"btcbook"}`,`${e}/proxy/nownodes/${r?"btc-testnet":"btc"}`,process.env.GLACIER_API_KEY?{token:process.env.GLACIER_API_KEY}:{});async function v({isTestnet:r,proxyApiUrl:e}){let t=l({isTestnet:r,proxyApiUrl:e}),{high:s,low:u,medium:x}=await t.getFeeRates();return {low:{maxFeePerGas:BigInt(u)},medium:{maxFeePerGas:BigInt(x)},high:{maxFeePerGas:BigInt(s)},isFixedFee:!1}}var o,g=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({})}getManifest(){let e=parseManifest(d);return e.success?e.data:void 0}getNetworkFee(e){return v({isTestnet:!!e.isTestnet,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 { g as BitcoinModule }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@avalabs/bitcoin-module", | ||
"version": "0.0.0-testGetBalance-20240722173538", | ||
"version": "0.0.0-testgetbalances-20240722175742", | ||
"main": "dist/index.cjs", | ||
@@ -9,3 +9,3 @@ "module": "dist/index.js", | ||
"dependencies": { | ||
"@avalabs/vm-module-types": "0.0.0-testGetBalance-20240722173538", | ||
"@avalabs/vm-module-types": "0.0.0-testgetbalances-20240722175742", | ||
"@avalabs/wallets-sdk": "2.8.0-alpha.188", | ||
@@ -20,2 +20,3 @@ "@metamask/rpc-errors": "6.3.0" | ||
"@internal/tsup-config": "0.0.1", | ||
"@internal/utils": "0.0.0-testgetbalances-20240722175742", | ||
"eslint-config-custom": "0.0.1" | ||
@@ -22,0 +23,0 @@ }, |
@@ -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 './env'; | ||
import ManifestJson from '../manifest.json'; | ||
import { getNetworkFee } from './handlers/get-network-fee'; | ||
export class BitcoinModule implements Module { | ||
#proxyApiUrl: string; | ||
constructor({ environment }: { environment: Environment }) { | ||
const { proxyApiUrl } = getEnv(environment); | ||
this.#proxyApiUrl = proxyApiUrl; | ||
} | ||
getAddress(): Promise<string> { | ||
@@ -21,3 +31,3 @@ return Promise.resolve('Bitcoin address'); | ||
getBalances() { | ||
return Promise.resolve('Bitcoin balances'); | ||
return Promise.resolve({}); | ||
} | ||
@@ -30,15 +40,6 @@ | ||
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> { | ||
return getNetworkFee({ | ||
isTestnet: Boolean(network.isTestnet), | ||
proxyApiUrl: this.#proxyApiUrl, | ||
}); | ||
@@ -45,0 +46,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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
32870
26
360
7
3
5
+ Added@avalabs/vm-module-types@0.0.0-testgetbalances-20240722175742(transitive)
- Removed@avalabs/vm-module-types@0.0.0-testGetBalance-20240722173538(transitive)
Updated@avalabs/vm-module-types@0.0.0-testgetbalances-20240722175742