@exodus/bitcoin-plugin 1.6.18 → 1.6.20-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/bitcoin-plugin",
3
- "version": "1.6.18",
3
+ "version": "1.6.20-alpha.0",
4
4
  "description": "Exodus bitcoin-plugin",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "@exodus/asset-lib": "^4.0.0",
22
22
  "@exodus/basic-utils": "^2.1.0",
23
- "@exodus/bitcoin-api": "^2.7.5",
23
+ "@exodus/bitcoin-api": "^2.7.6",
24
24
  "@exodus/bitcoin-lib": "^2.2.11",
25
25
  "@exodus/models": "^11.0.0",
26
26
  "@exodus/text-encoding-utf8": "^1.0.2",
@@ -29,5 +29,5 @@
29
29
  "devDependencies": {
30
30
  "@exodus/nfts-proxy": "^2.10.1"
31
31
  },
32
- "gitHead": "1a85a74d96022bbe186506c21bafbb02b6e1e533"
32
+ "gitHead": "6299c7b13d69a6e7e9a5153458fd33c8d2456050"
33
33
  }
@@ -106,6 +106,7 @@ export const createBitcoinAssetFactory = ({ asset, apiUrl: defaultApiUrl, coinIn
106
106
  const baseGetBalances = getBalancesFactory({
107
107
  feeData,
108
108
  getSpendableBalance: baseFeeResolver.getSpendableBalance,
109
+ ordinalsEnabled,
109
110
  })
110
111
 
111
112
  const brc20Client = brc20Enabled ? brc20ApiClientFactory() : undefined
@@ -41,12 +41,12 @@ export const brc20ApiClientFactory = ({
41
41
 
42
42
  const getOwnerTickBalances = async ({ address }) => {
43
43
  assert(address, 'address is required')
44
- return request(`/v2/ord/btc/brc20/owner_balances/${encodeURIComponent(address)}`)
44
+ return request(`/v2/ord/brc20/balances/${encodeURIComponent(address)}`)
45
45
  }
46
46
 
47
47
  const getTickerInfo = async ({ tick }) => {
48
48
  assert(tick, 'tick is required')
49
- return request(`/v2/ord/btc/brc20/tick_infos/${encodeURIComponent(tick)}`)
49
+ return request(`/v2/ord/brc20/tokens/${encodeURIComponent(tick)}`)
50
50
  }
51
51
 
52
52
  const getTickerInfoByDeployInscriptionId = async ({ deployInscriptionId }) => {
@@ -56,48 +56,50 @@ export const brc20ApiClientFactory = ({
56
56
  )
57
57
  }
58
58
 
59
- const removeNullUndefined = (obj) =>
60
- Object.fromEntries(Object.entries(obj).filter(([_, v]) => v !== undefined))
61
-
62
59
  const paginatedTransactionHistory = async (queryParams) => {
63
- const resolvedQueryParams = removeNullUndefined(queryParams)
60
+ const address = queryParams.address
61
+ assert(address, 'address is required')
64
62
  const events = []
65
63
  const limit = queryParams.limit || 40
66
64
  let offset = queryParams.offset || 0
67
65
  let response
68
66
  do {
69
- response = await request('/v2/ord/btc/brc20/events', {
70
- ...resolvedQueryParams,
67
+ response = await request(`/v2/ord/brc20/history/${encodeURIComponent(address)}`, {
71
68
  limit,
72
69
  offset,
73
70
  })
74
71
  offset = offset + limit
75
- events.push(...response.events)
72
+ events.push(...response.results)
76
73
  } while (offset < response.total)
77
74
 
78
- return events
79
- }
75
+ // remap to previous event shape that later logic expects
76
+ return events.map((event) => {
77
+ const brc20OwnerAvailableBalance = Number(event.available_balance)
78
+ const brc20OwnerTransferBalance = Number(event.transferrable_balance)
79
+ assert(!isNaN(brc20OwnerAvailableBalance))
80
+ assert(!isNaN(brc20OwnerTransferBalance))
80
81
 
81
- const getTokenTransactionHistory = ({
82
- tick,
83
- owner,
84
- brc20Op,
85
- showInvalid,
86
- transactionIds,
87
- limit,
88
- offset,
89
- }) => {
90
- return paginatedTransactionHistory({
91
- tick,
92
- owner,
93
- brc20Op,
94
- showInvalid,
95
- transactionIds,
96
- limit,
97
- offset,
82
+ return {
83
+ brc20Tick: event.ticker,
84
+ inscriptionId: event.inscription_id,
85
+ inscriptionNumber: event.inscription_number,
86
+ txId: event.tx_id,
87
+ createdAt: new Date(event.block_time).toISOString(),
88
+ owner: address,
89
+ transferFrom: event.from,
90
+ transferTo: event.to,
91
+ brc20Op: event.type,
92
+ brc20Amt: event.amount,
93
+ brc20OwnerAvailableBalance, // todo use NUs for adding these
94
+ brc20OwnerTransferBalance, // todo use NUs for adding these
95
+ }
98
96
  })
99
97
  }
100
98
 
99
+ const getTokenTransactionHistory = ({ ticker, offset, limit, address }) => {
100
+ return paginatedTransactionHistory({ ticker, offset, limit, address })
101
+ }
102
+
101
103
  return {
102
104
  setUrl,
103
105
  getOwnerTickBalances,
@@ -6,8 +6,8 @@ const toTxLog = ({ historyItem, baseAsset, asset }) => {
6
6
 
7
7
  const isSend = historyItem.brc20Op === 'send'
8
8
  const isReceive = historyItem.brc20Op === 'receive'
9
- const isMint = historyItem.brc20Op === 'mint'
10
- const isTransfer = historyItem.brc20Op === 'transfer'
9
+ const isMint = historyItem.brc20Op === 'inscribe-mint'
10
+ const isTransfer = historyItem.brc20Op === 'inscribe-transfer'
11
11
 
12
12
  const data = { operation: historyItem.brc20Op }
13
13
  return {
@@ -72,7 +72,7 @@ export const reloadBrc20TokenBalances = async ({
72
72
  const brc20History = (
73
73
  await Promise.all(
74
74
  addresses.map(async (address) => {
75
- const tokensHistoryList = await brc20Client.getTokenTransactionHistory({ owner: address })
75
+ const tokensHistoryList = await brc20Client.getTokenTransactionHistory({ address })
76
76
  return (
77
77
  await Promise.all(
78
78
  tokensHistoryList.map(async (token) => {
@@ -107,7 +107,7 @@ export const reloadBrc20TokenBalances = async ({
107
107
  .map((event) => event.inscriptionId)
108
108
 
109
109
  const transferableList = events
110
- .filter((event) => event.brc20Op === 'transfer')
110
+ .filter((event) => event.brc20Op === 'inscribe-transfer')
111
111
  .map((event) => {
112
112
  return {
113
113
  inscriptionId: event.inscriptionId,
@@ -11,7 +11,7 @@ export const tickInscriptionIdIndexerFactory = ({ brc20Client }) => {
11
11
 
12
12
  const loadDeployInscriptionId = async (brc20Tick) => {
13
13
  const response = await brc20Client.getTickerInfo({ tick: brc20Tick })
14
- const deployInscriptionId = response[0].inscriptionId
14
+ const deployInscriptionId = response.token.id
15
15
  save({ deployInscriptionId, brc20Tick })
16
16
  return deployInscriptionId
17
17
  }