@cityofzion/bs-ethereum 1.1.0 → 1.2.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.
Files changed (41) hide show
  1. package/dist/BSEthereum.d.ts +3 -2
  2. package/dist/BSEthereum.js +27 -7
  3. package/dist/BitqueryBDSEthereum.d.ts +1 -2
  4. package/dist/BitqueryBDSEthereum.js +27 -12
  5. package/dist/BitqueryEDSEthereum.d.ts +1 -2
  6. package/dist/BitqueryEDSEthereum.js +20 -5
  7. package/dist/GhostMarketNDSEthereum.d.ts +1 -1
  8. package/dist/GhostMarketNDSEthereum.js +17 -3
  9. package/dist/LedgerServiceEthereum.d.ts +4 -2
  10. package/dist/LedgerServiceEthereum.js +13 -5
  11. package/dist/RpcBDSEthereum.d.ts +1 -1
  12. package/dist/RpcBDSEthereum.js +21 -7
  13. package/package.json +5 -2
  14. package/.eslintignore +0 -13
  15. package/.eslintrc.cjs +0 -22
  16. package/.rush/temp/operation/build/all.log +0 -1
  17. package/.rush/temp/operation/build/state.json +0 -3
  18. package/.rush/temp/package-deps_build.json +0 -30
  19. package/.rush/temp/shrinkwrap-deps.json +0 -531
  20. package/CHANGELOG.json +0 -126
  21. package/CHANGELOG.md +0 -68
  22. package/bs-ethereum.build.log +0 -1
  23. package/jest.config.ts +0 -13
  24. package/jest.setup.ts +0 -1
  25. package/src/BSEthereum.ts +0 -208
  26. package/src/BitqueryBDSEthereum.ts +0 -231
  27. package/src/BitqueryEDSEthereum.ts +0 -67
  28. package/src/GhostMarketNDSEthereum.ts +0 -125
  29. package/src/LedgerServiceEthereum.ts +0 -44
  30. package/src/RpcBDSEthereum.ts +0 -88
  31. package/src/__tests__/BSEthereum.spec.ts +0 -172
  32. package/src/__tests__/BitqueryBDSEthereum.spec.ts +0 -106
  33. package/src/__tests__/BitqueryEDSEthereum.spec.ts +0 -55
  34. package/src/__tests__/GhostMarketNDSEthereum.spec.ts +0 -49
  35. package/src/__tests__/RpcBDSEthereum.spec.ts +0 -62
  36. package/src/assets/tokens/common.json +0 -8
  37. package/src/constants.ts +0 -36
  38. package/src/graphql.ts +0 -288
  39. package/src/index.ts +0 -6
  40. package/tsconfig.build.json +0 -4
  41. package/tsconfig.json +0 -15
package/CHANGELOG.json DELETED
@@ -1,126 +0,0 @@
1
- {
2
- "name": "@cityofzion/bs-ethereum",
3
- "entries": [
4
- {
5
- "version": "1.1.0",
6
- "tag": "@cityofzion/bs-ethereum_v1.1.0",
7
- "date": "Thu, 04 Apr 2024 19:52:20 GMT",
8
- "comments": {
9
- "minor": [
10
- {
11
- "comment": "Add ledger support"
12
- }
13
- ],
14
- "patch": [
15
- {
16
- "comment": "Change Goerli to Sepolia and call RPC using testnet instead of Bitquery"
17
- }
18
- ],
19
- "dependency": [
20
- {
21
- "comment": "Updating dependency \"@cityofzion/blockchain-service\" to `0.10.0`"
22
- }
23
- ]
24
- }
25
- },
26
- {
27
- "version": "1.0.4",
28
- "tag": "@cityofzion/bs-ethereum_v1.0.4",
29
- "date": "Mon, 04 Mar 2024 21:53:09 GMT",
30
- "comments": {
31
- "patch": [
32
- {
33
- "comment": "fix wrong calculated fee"
34
- }
35
- ]
36
- }
37
- },
38
- {
39
- "version": "1.0.3",
40
- "tag": "@cityofzion/bs-ethereum_v1.0.3",
41
- "date": "Wed, 28 Feb 2024 17:43:01 GMT",
42
- "comments": {
43
- "patch": [
44
- {
45
- "comment": "Add creator infomations in nft methods return"
46
- }
47
- ],
48
- "dependency": [
49
- {
50
- "comment": "Updating dependency \"@cityofzion/blockchain-service\" to `0.9.1`"
51
- }
52
- ]
53
- }
54
- },
55
- {
56
- "version": "1.0.2",
57
- "tag": "@cityofzion/bs-ethereum_v1.0.2",
58
- "date": "Tue, 27 Feb 2024 20:29:09 GMT",
59
- "comments": {
60
- "patch": [
61
- {
62
- "comment": "Remove the mining wait in the transfer method to avoid long promises that take time to resolve."
63
- }
64
- ]
65
- }
66
- },
67
- {
68
- "version": "1.0.1",
69
- "tag": "@cityofzion/bs-ethereum_v1.0.1",
70
- "date": "Thu, 22 Feb 2024 16:49:56 GMT",
71
- "comments": {
72
- "patch": [
73
- {
74
- "comment": "Fix getTokenPrices that is returning a wrong price for ETH token address"
75
- }
76
- ]
77
- }
78
- },
79
- {
80
- "version": "1.0.0",
81
- "tag": "@cityofzion/bs-ethereum_v1.0.0",
82
- "date": "Fri, 16 Feb 2024 16:13:22 GMT",
83
- "comments": {
84
- "major": [
85
- {
86
- "comment": "Change bitquery providers to receive apiKey on class initialization"
87
- }
88
- ]
89
- }
90
- },
91
- {
92
- "version": "0.9.1",
93
- "tag": "@cityofzion/bs-ethereum_v0.9.1",
94
- "date": "Tue, 30 Jan 2024 18:26:00 GMT",
95
- "comments": {
96
- "patch": [
97
- {
98
- "comment": "Fixed bug with repeated ETH token in getBalance method"
99
- }
100
- ]
101
- }
102
- },
103
- {
104
- "version": "0.9.0",
105
- "tag": "@cityofzion/bs-ethereum_v0.9.0",
106
- "date": "Tue, 05 Dec 2023 18:42:10 GMT",
107
- "comments": {
108
- "minor": [
109
- {
110
- "comment": "Inserted within the TokenPricesResponse type the token hash"
111
- }
112
- ],
113
- "patch": [
114
- {
115
- "comment": "Fixed issue with the getBalance method that returned negative numbers and the wrong ETH value"
116
- }
117
- ],
118
- "dependency": [
119
- {
120
- "comment": "Updating dependency \"@cityofzion/blockchain-service\" to `0.9.0`"
121
- }
122
- ]
123
- }
124
- }
125
- ]
126
- }
package/CHANGELOG.md DELETED
@@ -1,68 +0,0 @@
1
- # Change Log - @cityofzion/bs-ethereum
2
-
3
- This log was last generated on Thu, 04 Apr 2024 19:52:20 GMT and should not be manually modified.
4
-
5
- ## 1.1.0
6
- Thu, 04 Apr 2024 19:52:20 GMT
7
-
8
- ### Minor changes
9
-
10
- - Add ledger support
11
-
12
- ### Patches
13
-
14
- - Change Goerli to Sepolia and call RPC using testnet instead of Bitquery
15
-
16
- ## 1.0.4
17
- Mon, 04 Mar 2024 21:53:09 GMT
18
-
19
- ### Patches
20
-
21
- - fix wrong calculated fee
22
-
23
- ## 1.0.3
24
- Wed, 28 Feb 2024 17:43:01 GMT
25
-
26
- ### Patches
27
-
28
- - Add creator infomations in nft methods return
29
-
30
- ## 1.0.2
31
- Tue, 27 Feb 2024 20:29:09 GMT
32
-
33
- ### Patches
34
-
35
- - Remove the mining wait in the transfer method to avoid long promises that take time to resolve.
36
-
37
- ## 1.0.1
38
- Thu, 22 Feb 2024 16:49:56 GMT
39
-
40
- ### Patches
41
-
42
- - Fix getTokenPrices that is returning a wrong price for ETH token address
43
-
44
- ## 1.0.0
45
- Fri, 16 Feb 2024 16:13:22 GMT
46
-
47
- ### Breaking changes
48
-
49
- - Change bitquery providers to receive apiKey on class initialization
50
-
51
- ## 0.9.1
52
- Tue, 30 Jan 2024 18:26:00 GMT
53
-
54
- ### Patches
55
-
56
- - Fixed bug with repeated ETH token in getBalance method
57
-
58
- ## 0.9.0
59
- Tue, 05 Dec 2023 18:42:10 GMT
60
-
61
- ### Minor changes
62
-
63
- - Inserted within the TokenPricesResponse type the token hash
64
-
65
- ### Patches
66
-
67
- - Fixed issue with the getBalance method that returned negative numbers and the wrong ETH value
68
-
@@ -1 +0,0 @@
1
- Invoking: tsc --project tsconfig.build.json
package/jest.config.ts DELETED
@@ -1,13 +0,0 @@
1
- import { JestConfigWithTsJest } from 'ts-jest'
2
- const config: JestConfigWithTsJest = {
3
- preset: 'ts-jest',
4
- testEnvironment: 'node',
5
- clearMocks: true,
6
- verbose: true,
7
- bail: true,
8
- testMatch: ['<rootDir>/**/*.spec.ts'],
9
- setupFiles: ['<rootDir>/jest.setup.ts'],
10
- detectOpenHandles: true,
11
- }
12
-
13
- export default config
package/jest.setup.ts DELETED
@@ -1 +0,0 @@
1
- import 'dotenv/config'
package/src/BSEthereum.ts DELETED
@@ -1,208 +0,0 @@
1
- import {
2
- Account,
3
- AccountWithDerivationPath,
4
- BSCalculableFee,
5
- BSWithLedger,
6
- BSWithNameService,
7
- BSWithNft,
8
- BlockchainDataService,
9
- BlockchainService,
10
- ExchangeDataService,
11
- Network,
12
- NftDataService,
13
- PartialBy,
14
- Token,
15
- TransferParam,
16
- } from '@cityofzion/blockchain-service'
17
- import { ethers } from 'ethers'
18
- import * as ethersJsonWallets from '@ethersproject/json-wallets'
19
- import * as ethersBytes from '@ethersproject/bytes'
20
- import * as ethersBigNumber from '@ethersproject/bignumber'
21
- import { DEFAULT_URL_BY_NETWORK_TYPE, DERIVATION_PATH, NATIVE_ASSETS, TOKENS } from './constants'
22
- import { BitqueryEDSEthereum } from './BitqueryEDSEthereum'
23
- import { GhostMarketNDSEthereum } from './GhostMarketNDSEthereum'
24
- import { RpcBDSEthereum } from './RpcBDSEthereum'
25
- import { BitqueryBDSEthereum } from './BitqueryBDSEthereum'
26
- import { LedgerServiceEthereum } from './LedgerServiceEthereum'
27
- export class BSEthereum<BSCustomName extends string = string>
28
- implements BlockchainService, BSWithNft, BSWithNameService, BSCalculableFee, BSWithLedger
29
- {
30
- readonly blockchainName: BSCustomName
31
- readonly feeToken: Token
32
- readonly derivationPath: string
33
- private readonly bitqueryApiKey: string
34
-
35
- blockchainDataService!: BlockchainDataService
36
- exchangeDataService!: ExchangeDataService
37
- ledgerService: LedgerServiceEthereum = new LedgerServiceEthereum()
38
- tokens: Token[]
39
- nftDataService!: NftDataService
40
- network!: Network
41
-
42
- constructor(blockchainName: BSCustomName, network: PartialBy<Network, 'url'>, bitqueryApiKey: string) {
43
- this.blockchainName = blockchainName
44
- this.derivationPath = DERIVATION_PATH
45
- this.tokens = TOKENS[network.type]
46
- this.bitqueryApiKey = bitqueryApiKey
47
-
48
- this.feeToken = this.tokens.find(token => token.symbol === 'ETH')!
49
- this.setNetwork(network)
50
- }
51
-
52
- setNetwork(param: PartialBy<Network, 'url'>) {
53
- const network = {
54
- type: param.type,
55
- url: param.url ?? DEFAULT_URL_BY_NETWORK_TYPE[param.type],
56
- }
57
- this.network = network
58
-
59
- if (network.type !== 'mainnet') {
60
- this.blockchainDataService = new RpcBDSEthereum(network)
61
- } else {
62
- this.blockchainDataService = new BitqueryBDSEthereum(network, this.bitqueryApiKey)
63
- }
64
-
65
- this.exchangeDataService = new BitqueryEDSEthereum(network.type, this.bitqueryApiKey)
66
- this.nftDataService = new GhostMarketNDSEthereum(network.type)
67
- }
68
-
69
- validateAddress(address: string): boolean {
70
- return ethers.utils.isAddress(address)
71
- }
72
-
73
- validateEncrypted(json: string): boolean {
74
- return ethersJsonWallets.isCrowdsaleWallet(json) || ethersJsonWallets.isKeystoreWallet(json)
75
- }
76
-
77
- validateKey(key: string): boolean {
78
- try {
79
- if (!key.startsWith('0x')) {
80
- key = '0x' + key
81
- }
82
- if (ethersBytes.hexDataLength(key) !== 32) return false
83
-
84
- return true
85
- } catch (error) {
86
- return false
87
- }
88
- }
89
-
90
- validateNameServiceDomainFormat(domainName: string): boolean {
91
- if (!domainName.endsWith('.eth')) return false
92
- return true
93
- }
94
-
95
- generateAccountFromMnemonic(mnemonic: string[] | string, index: number): AccountWithDerivationPath {
96
- const path = this.derivationPath.replace('?', index.toString())
97
- const wallet = ethers.Wallet.fromMnemonic(Array.isArray(mnemonic) ? mnemonic.join(' ') : mnemonic, path)
98
-
99
- return {
100
- address: wallet.address,
101
- key: wallet.privateKey,
102
- type: 'privateKey',
103
- derivationPath: path,
104
- }
105
- }
106
-
107
- generateAccountFromKey(key: string): Account {
108
- const wallet = new ethers.Wallet(key)
109
-
110
- return {
111
- address: wallet.address,
112
- key,
113
- type: 'privateKey',
114
- }
115
- }
116
-
117
- generateAccountFromPublicKey(publicKey: string): Account {
118
- const address = ethers.utils.computeAddress(publicKey)
119
- return {
120
- address,
121
- key: publicKey,
122
- type: 'publicKey',
123
- }
124
- }
125
-
126
- async decrypt(json: string, password: string): Promise<Account> {
127
- const wallet = await ethers.Wallet.fromEncryptedJson(json, password)
128
- return {
129
- address: wallet.address,
130
- key: wallet.privateKey,
131
- type: 'privateKey',
132
- }
133
- }
134
-
135
- async encrypt(key: string, password: string): Promise<string> {
136
- const wallet = new ethers.Wallet(key)
137
- return wallet.encrypt(password)
138
- }
139
-
140
- async transfer(param: TransferParam): Promise<string> {
141
- const provider = new ethers.providers.JsonRpcProvider(this.network.url)
142
-
143
- const signTransactionFunction = param.isLedger
144
- ? await this.ledgerService.getSignTransactionFunction(param.ledgerTransport)
145
- : new ethers.Wallet(param.senderAccount.key, provider).signTransaction
146
-
147
- const decimals = param.intent.tokenDecimals ?? 18
148
- const amount = ethersBigNumber.parseFixed(param.intent.amount, decimals)
149
-
150
- let transactionParams: ethers.utils.Deferrable<ethers.providers.TransactionRequest>
151
-
152
- const isNative = NATIVE_ASSETS.some(asset => asset.hash === param.intent.tokenHash)
153
- if (isNative) {
154
- transactionParams = {
155
- to: param.intent.receiverAddress,
156
- value: amount,
157
- }
158
- } else {
159
- const contract = new ethers.Contract(param.intent.tokenHash, [
160
- 'function transfer(address to, uint amount) returns (bool)',
161
- ])
162
- transactionParams = await contract.populateTransaction.transfer(param.intent.receiverAddress, amount)
163
- }
164
-
165
- const voidSigner = new ethers.VoidSigner(param.senderAccount.address, provider)
166
- const transaction = await voidSigner.populateTransaction(transactionParams)
167
-
168
- const signedTransaction = await signTransactionFunction(transaction)
169
- const transactionResponse = await provider.sendTransaction(signedTransaction)
170
- return transactionResponse.hash
171
- }
172
-
173
- async calculateTransferFee({ intent }: TransferParam): Promise<string> {
174
- const provider = new ethers.providers.JsonRpcProvider(this.network.url)
175
-
176
- const gasPrice = await provider.getGasPrice()
177
-
178
- let estimated: ethers.BigNumber
179
-
180
- const isNative = NATIVE_ASSETS.some(asset => asset.hash === intent.tokenHash)
181
- const decimals = intent.tokenDecimals ?? 18
182
- const amount = ethersBigNumber.parseFixed(intent.amount, decimals)
183
-
184
- if (!isNative) {
185
- const contract = new ethers.Contract(
186
- intent.tokenHash,
187
- ['function transfer(address to, uint amount) returns (bool)'],
188
- provider
189
- )
190
-
191
- estimated = await contract.estimateGas.transfer(intent.receiverAddress, amount)
192
- } else {
193
- estimated = await provider.estimateGas({
194
- to: intent.receiverAddress,
195
- value: amount,
196
- })
197
- }
198
-
199
- return ethers.utils.formatEther(gasPrice.mul(estimated))
200
- }
201
-
202
- async resolveNameServiceDomain(domainName: string): Promise<string> {
203
- const provider = new ethers.providers.JsonRpcProvider(this.network.url)
204
- const address = await provider.resolveName(domainName)
205
- if (!address) throw new Error('No address found for domain name')
206
- return address
207
- }
208
- }
@@ -1,231 +0,0 @@
1
- import {
2
- BalanceResponse,
3
- ContractResponse,
4
- NetworkType,
5
- Token,
6
- TransactionsByAddressParams,
7
- TransactionsByAddressResponse,
8
- TransactionResponse,
9
- TransactionTransferAsset,
10
- TransactionTransferNft,
11
- Network,
12
- } from '@cityofzion/blockchain-service'
13
- import { Client, fetchExchange } from '@urql/core'
14
- import fetch from 'node-fetch'
15
- import { BITQUERY_NETWORK_BY_NETWORK_TYPE, BITQUERY_URL, NATIVE_ASSETS, TOKENS } from './constants'
16
- import {
17
- BitqueryTransaction,
18
- bitqueryGetBalanceQuery,
19
- bitqueryGetTokenInfoQuery,
20
- bitqueryGetTransactionQuery,
21
- bitqueryGetTransactionsByAddressQuery,
22
- } from './graphql'
23
- import { RpcBDSEthereum } from './RpcBDSEthereum'
24
-
25
- export class BitqueryBDSEthereum extends RpcBDSEthereum {
26
- private readonly client: Client
27
- private readonly networkType: Exclude<NetworkType, 'custom'>
28
-
29
- maxTimeToConfirmTransactionInMs: number = 1000 * 60 * 8
30
-
31
- constructor(network: Network, apiKey: string) {
32
- super(network)
33
-
34
- if (network.type === 'custom') throw new Error('Custom network not supported')
35
- this.networkType = network.type
36
-
37
- this.client = new Client({
38
- url: BITQUERY_URL,
39
- exchanges: [fetchExchange],
40
- fetch,
41
- fetchOptions: {
42
- headers: {
43
- 'X-API-KEY': apiKey,
44
- },
45
- },
46
- })
47
- }
48
-
49
- async getTransaction(hash: string): Promise<TransactionResponse> {
50
- const result = await this.client
51
- .query(bitqueryGetTransactionQuery, {
52
- hash,
53
- network: BITQUERY_NETWORK_BY_NETWORK_TYPE[this.networkType],
54
- })
55
- .toPromise()
56
- if (result.error) throw new Error(result.error.message)
57
- if (!result.data || !result.data.ethereum.transfers.length) throw new Error('Transaction not found')
58
-
59
- const transfers = result.data.ethereum.transfers.map(this.parseTransactionTransfer)
60
-
61
- const {
62
- block: {
63
- height,
64
- timestamp: { unixtime },
65
- },
66
- transaction: { gasValue, hash: transactionHash },
67
- } = result.data.ethereum.transfers[0]
68
-
69
- return {
70
- block: height,
71
- time: unixtime,
72
- hash: transactionHash,
73
- fee: String(gasValue),
74
- transfers,
75
- notifications: [],
76
- }
77
- }
78
-
79
- async getTransactionsByAddress({
80
- address,
81
- page = 1,
82
- }: TransactionsByAddressParams): Promise<TransactionsByAddressResponse> {
83
- const limit = 10
84
- const offset = limit * (page - 1)
85
-
86
- const result = await this.client
87
- .query(bitqueryGetTransactionsByAddressQuery, {
88
- address,
89
- limit,
90
- offset,
91
- network: BITQUERY_NETWORK_BY_NETWORK_TYPE[this.networkType],
92
- })
93
- .toPromise()
94
-
95
- if (result.error) throw new Error(result.error.message)
96
- if (!result.data) throw new Error('Address does not have transactions')
97
-
98
- const totalCount =
99
- (result.data.ethereum.sentCount[0].count ?? 0) + (result.data.ethereum.receiverCount[0].count ?? 0)
100
- const mixedTransfers = [...(result?.data?.ethereum?.sent ?? []), ...(result?.data?.ethereum?.received ?? [])]
101
-
102
- const transactions = new Map<string, TransactionResponse>()
103
-
104
- mixedTransfers.forEach(transfer => {
105
- const transactionTransfer = this.parseTransactionTransfer(transfer)
106
-
107
- const existingTransaction = transactions.get(transfer.transaction.hash)
108
- if (existingTransaction) {
109
- existingTransaction.transfers.push(transactionTransfer)
110
- return
111
- }
112
-
113
- transactions.set(transfer.transaction.hash, {
114
- block: transfer.block.height,
115
- hash: transfer.transaction.hash,
116
- time: transfer.block.timestamp.unixtime,
117
- fee: String(transfer.transaction.gasValue),
118
- transfers: [transactionTransfer],
119
- notifications: [],
120
- })
121
- })
122
-
123
- return {
124
- totalCount,
125
- limit: limit * 2,
126
- transactions: Array.from(transactions.values()),
127
- }
128
- }
129
-
130
- async getContract(): Promise<ContractResponse> {
131
- throw new Error("Bitquery doesn't support contract info")
132
- }
133
-
134
- async getTokenInfo(hash: string): Promise<Token> {
135
- const localToken = TOKENS[this.networkType].find(token => token.hash === hash)
136
- if (localToken) return localToken
137
-
138
- const result = await this.client
139
- .query(bitqueryGetTokenInfoQuery, {
140
- hash,
141
- network: BITQUERY_NETWORK_BY_NETWORK_TYPE[this.networkType],
142
- })
143
- .toPromise()
144
-
145
- if (result.error) throw new Error(result.error.message)
146
- if (!result.data || result.data.ethereum.smartContractCalls.length <= 0) throw new Error('Token not found')
147
-
148
- const {
149
- address: { address },
150
- currency: { decimals, name, symbol, tokenType },
151
- } = result.data.ethereum.smartContractCalls[0].smartContract
152
-
153
- if (tokenType !== 'ERC20') throw new Error('Token is not ERC20')
154
-
155
- return {
156
- hash: address,
157
- name,
158
- symbol,
159
- decimals,
160
- }
161
- }
162
-
163
- async getBalance(address: string): Promise<BalanceResponse[]> {
164
- const result = await this.client
165
- .query(bitqueryGetBalanceQuery, {
166
- address,
167
- network: BITQUERY_NETWORK_BY_NETWORK_TYPE[this.networkType],
168
- })
169
- .toPromise()
170
-
171
- if (result.error) throw new Error(result.error.message)
172
- const data = result.data?.ethereum.address[0].balances ?? []
173
- const ethBalance = result.data?.ethereum.address[0].balance ?? 0
174
- const ethToken = NATIVE_ASSETS.find(asset => asset.symbol === 'ETH')!
175
-
176
- const balances: BalanceResponse[] = [
177
- {
178
- amount: ethBalance.toString(),
179
- token: ethToken,
180
- },
181
- ]
182
-
183
- data.forEach(({ value, currency: { address, decimals, name, symbol } }) => {
184
- if (value < 0 || address === ethToken.hash) return
185
-
186
- balances.push({
187
- amount: value.toString(),
188
- token: {
189
- hash: address,
190
- symbol,
191
- name,
192
- decimals,
193
- },
194
- })
195
- })
196
-
197
- return balances
198
- }
199
-
200
- private parseTransactionTransfer({
201
- amount,
202
- currency: { tokenType, address, decimals, name, symbol },
203
- entityId,
204
- sender,
205
- receiver,
206
- }: BitqueryTransaction): TransactionTransferAsset | TransactionTransferNft {
207
- if (tokenType === 'ERC721') {
208
- return {
209
- from: sender.address,
210
- to: receiver.address,
211
- tokenId: entityId,
212
- contractHash: address,
213
- type: 'nft',
214
- }
215
- }
216
-
217
- return {
218
- from: sender.address,
219
- to: receiver.address,
220
- contractHash: address,
221
- amount: amount.toString(),
222
- token: {
223
- decimals: decimals,
224
- hash: address,
225
- name: name,
226
- symbol: symbol,
227
- },
228
- type: 'token',
229
- }
230
- }
231
- }