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

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.20-alpha.0",
3
+ "version": "1.6.21",
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.6",
23
+ "@exodus/bitcoin-api": "^2.7.8",
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": "6299c7b13d69a6e7e9a5153458fd33c8d2456050"
32
+ "gitHead": "bcd735ed4e9775e3436257966d80fc524c1fa312"
33
33
  }
@@ -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/brc20/balances/${encodeURIComponent(address)}`)
44
+ return request(`/v2/ord/btc/brc20/owner_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/brc20/tokens/${encodeURIComponent(tick)}`)
49
+ return request(`/v2/ord/btc/brc20/tick_infos/${encodeURIComponent(tick)}`)
50
50
  }
51
51
 
52
52
  const getTickerInfoByDeployInscriptionId = async ({ deployInscriptionId }) => {
@@ -56,48 +56,46 @@ export const brc20ApiClientFactory = ({
56
56
  )
57
57
  }
58
58
 
59
+ const removeNullUndefined = (obj) =>
60
+ Object.fromEntries(Object.entries(obj).filter(([_, v]) => v !== undefined))
61
+
59
62
  const paginatedTransactionHistory = async (queryParams) => {
60
- const address = queryParams.address
61
- assert(address, 'address is required')
63
+ const resolvedQueryParams = removeNullUndefined(queryParams)
62
64
  const events = []
63
65
  const limit = queryParams.limit || 40
64
66
  let offset = queryParams.offset || 0
65
67
  let response
66
68
  do {
67
- response = await request(`/v2/ord/brc20/history/${encodeURIComponent(address)}`, {
69
+ response = await request('/v2/ord/btc/brc20/events', {
70
+ ...resolvedQueryParams,
68
71
  limit,
69
72
  offset,
70
73
  })
71
74
  offset = offset + limit
72
- events.push(...response.results)
75
+ events.push(...response.events)
73
76
  } while (offset < response.total)
74
77
 
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))
81
-
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
- }
96
- })
78
+ return events
97
79
  }
98
80
 
99
- const getTokenTransactionHistory = ({ ticker, offset, limit, address }) => {
100
- return paginatedTransactionHistory({ ticker, offset, limit, address })
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,
98
+ })
101
99
  }
102
100
 
103
101
  return {
@@ -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 === 'inscribe-mint'
10
- const isTransfer = historyItem.brc20Op === 'inscribe-transfer'
9
+ const isMint = historyItem.brc20Op === 'mint'
10
+ const isTransfer = historyItem.brc20Op === '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({ address })
75
+ const tokensHistoryList = await brc20Client.getTokenTransactionHistory({ owner: 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 === 'inscribe-transfer')
110
+ .filter((event) => event.brc20Op === '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.token.id
14
+ const deployInscriptionId = response[0].inscriptionId
15
15
  save({ deployInscriptionId, brc20Tick })
16
16
  return deployInscriptionId
17
17
  }