@avalabs/bitcoin-module
Advanced tools
Comparing version 0.0.0-CP-8870-20240723180655 to 0.0.0-all-eth-20240726134614
# @avalabs/bitcoin-module | ||
## 0.0.0-CP-8870-20240723180655 | ||
## 0.0.0-all-eth-20240726134614 | ||
### Patch Changes | ||
- Updated dependencies [a33ae38] | ||
- @avalabs/vm-module-types@0.0.0-CP-8870-20240723180655 | ||
- @avalabs/vm-module-types@0.0.0-all-eth-20240726134614 | ||
## 0.0.19 | ||
### Patch Changes | ||
- Updated dependencies [5af458b] | ||
- @avalabs/vm-module-types@0.0.19 | ||
## 0.0.18 | ||
### Patch Changes | ||
- @avalabs/vm-module-types@0.0.18 | ||
## 0.0.17 | ||
### Patch Changes | ||
- Updated dependencies [3590edf] | ||
- @avalabs/vm-module-types@0.0.17 | ||
## 0.0.16 | ||
@@ -11,0 +30,0 @@ |
import * as _metamask_rpc_errors from '@metamask/rpc-errors'; | ||
import * as _avalabs_vm_module_types_dist_transaction_history from '@avalabs/vm-module-types/dist/transaction-history'; | ||
import { Module, Environment, Manifest, Network, NetworkFees, GetTransactionHistory, RpcRequest } from '@avalabs/vm-module-types'; | ||
@@ -13,4 +14,4 @@ | ||
getNetworkFee(network: Network): Promise<NetworkFees>; | ||
getTransactionHistory(_: GetTransactionHistory): Promise<{ | ||
transactions: never[]; | ||
getTransactionHistory({ address, network }: GetTransactionHistory): Promise<{ | ||
transactions: _avalabs_vm_module_types_dist_transaction_history.Transaction[]; | ||
}>; | ||
@@ -17,0 +18,0 @@ getTokens(_: Network): Promise<never[]>; |
@@ -1,9 +0,9 @@ | ||
import { parseManifest, Environment } from '@avalabs/vm-module-types'; | ||
import { parseManifest, Environment, TokenType, TransactionType } 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 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; | ||
var m=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var p=(e,t,r)=>(m(e,t,"read from private field"),r?r.call(e):t.get(e)),d=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r);},l=(e,t,r,s)=>(m(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);var T={glacierApiUrl:"https://glacier-api.avax.network",proxyApiUrl:"https://proxy-api.avax.network"},x={glacierApiUrl:"https://glacier-api-dev.avax.network",proxyApiUrl:"https://proxy-api-dev.avax.network"},g=e=>{switch(e){case Environment.PRODUCTION:return T;case Environment.DEV:return x}};var v={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 a=({isTestnet:e,proxyApiUrl:t})=>new BitcoinProvider(!e,void 0,`${t}/proxy/nownodes/${e?"btcbook-testnet":"btcbook"}`,`${t}/proxy/nownodes/${e?"btc-testnet":"btc"}`,process.env.GLACIER_API_KEY?{token:process.env.GLACIER_API_KEY}:{});async function u({isTestnet:e,proxyApiUrl:t}){let r=a({isTestnet:e,proxyApiUrl:t}),{high:s,low:i,medium:o}=await r.getFeeRates();return {low:{maxFeePerGas:BigInt(i)},medium:{maxFeePerGas:BigInt(o)},high:{maxFeePerGas:BigInt(s)},isFixedFee:!1}}var k=(e,{address:t,network:r})=>{let{explorerUrl:s,isTestnet:i,networkToken:o}=r,c=e.addresses[0]??"";return {chainId:r.chainId.toString(),explorerLink:`${s}/${i?"btc-testnet":"btc"}/tx/${e.hash}`,from:e.isSender?t:c,gasUsed:e.fee.toString(),hash:e.hash,isContractCall:!1,isIncoming:!e.isSender,isOutgoing:e.isSender,isSender:e.isSender,timestamp:e.receivedTime*1e3,to:e.isSender?c:t,tokens:[{amount:(Math.abs(e.amount)/10**o.decimals).toString(),decimal:o.decimals.toString(),name:o.name,symbol:o.symbol,type:TokenType.NATIVE}],txType:e.isSender?TransactionType.SEND:TransactionType.RECEIVE}};var w=async({address:e,network:t,proxyApiUrl:r})=>(await a({isTestnet:!!t.isTestnet,proxyApiUrl:r}).getTxHistory(e)).map(o=>k(o,{address:e,network:t}));var n,h=class{constructor({environment:t}){d(this,n,void 0);let{proxyApiUrl:r}=g(t);l(this,n,r);}getAddress(){return Promise.resolve("Bitcoin address")}getBalances(){return Promise.resolve({})}getManifest(){let t=parseManifest(v);return t.success?t.data:void 0}getNetworkFee(t){return u({isTestnet:!!t.isTestnet,proxyApiUrl:p(this,n)})}async getTransactionHistory({address:t,network:r}){return {transactions:await w({address:t,network:r,proxyApiUrl:p(this,n)})}}getTokens(t){return Promise.resolve([])}async onRpcRequest(t,r){switch(t.method){default:return {error:rpcErrors.methodNotSupported(`Method ${t.method} not supported`)}}}};n=new WeakMap; | ||
export { g as BitcoinModule }; | ||
export { h as BitcoinModule }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@avalabs/bitcoin-module", | ||
"version": "0.0.0-CP-8870-20240723180655", | ||
"version": "0.0.0-all-eth-20240726134614", | ||
"main": "dist/index.cjs", | ||
@@ -9,3 +9,3 @@ "module": "dist/index.js", | ||
"dependencies": { | ||
"@avalabs/vm-module-types": "0.0.0-CP-8870-20240723180655", | ||
"@avalabs/vm-module-types": "0.0.0-all-eth-20240726134614", | ||
"@avalabs/wallets-sdk": "2.8.0-alpha.188", | ||
@@ -20,3 +20,3 @@ "@metamask/rpc-errors": "6.3.0" | ||
"@internal/tsup-config": "0.0.1", | ||
"@internal/utils": "0.0.0-CP-8870-20240723180655", | ||
"@internal/utils": "0.0.3", | ||
"eslint-config-custom": "0.0.1" | ||
@@ -23,0 +23,0 @@ }, |
@@ -16,2 +16,3 @@ import type { | ||
import { getNetworkFee } from './handlers/get-network-fee'; | ||
import { getTransactionHistory } from './handlers/get-transaction-history'; | ||
@@ -46,4 +47,10 @@ export class BitcoinModule implements Module { | ||
getTransactionHistory(_: GetTransactionHistory) { | ||
return Promise.resolve({ transactions: [] }); | ||
async getTransactionHistory({ address, network }: GetTransactionHistory) { | ||
return { | ||
transactions: await getTransactionHistory({ | ||
address, | ||
network, | ||
proxyApiUrl: this.#proxyApiUrl, | ||
}), | ||
}; | ||
} | ||
@@ -50,0 +57,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
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
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
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
49809
31
608
+ Added@avalabs/vm-module-types@0.0.0-all-eth-20240726134614(transitive)
- Removed@avalabs/vm-module-types@0.0.0-CP-8870-20240723180655(transitive)
Updated@avalabs/vm-module-types@0.0.0-all-eth-20240726134614