@sentio/sdk 1.7.21 → 1.8.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/lib/gen/processor/protos/processor.d.ts +80 -16
- package/lib/gen/processor/protos/processor.js +236 -19
- package/lib/gen/processor/protos/processor.js.map +1 -1
- package/lib/meter.js +1 -1
- package/lib/meter.js.map +1 -1
- package/lib/processor-runner.js +0 -2
- package/lib/processor-runner.js.map +1 -1
- package/lib/service.d.ts +2 -1
- package/lib/service.js +6 -1
- package/lib/service.js.map +1 -1
- package/lib/test/index.d.ts +1 -0
- package/lib/test/index.js +3 -1
- package/lib/test/index.js.map +1 -1
- package/lib/test/test-processor-server.d.ts +2 -1
- package/lib/test/test-processor-server.js +3 -0
- package/lib/test/test-processor-server.js.map +1 -1
- package/lib/test/test-provider.d.ts +1 -0
- package/lib/test/test-provider.js +25 -0
- package/lib/test/test-provider.js.map +1 -0
- package/lib/utils/chainmap.js +3 -3
- package/lib/utils/chainmap.js.map +1 -1
- package/lib/utils/erc20.d.ts +6 -1
- package/lib/utils/erc20.js +12 -1
- package/lib/utils/erc20.js.map +1 -1
- package/lib/utils/erc20.test.js +6 -11
- package/lib/utils/erc20.test.js.map +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +3 -1
- package/lib/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/gen/processor/protos/processor.ts +327 -32
- package/src/meter.ts +1 -1
- package/src/processor-runner.ts +0 -3
- package/src/service.ts +9 -1
- package/src/test/index.ts +1 -0
- package/src/test/test-processor-server.ts +6 -0
- package/src/test/test-provider.ts +25 -0
- package/src/utils/chainmap.ts +3 -3
- package/src/utils/erc20.test.ts +7 -12
- package/src/utils/erc20.ts +8 -2
- package/src/utils/index.ts +1 -1
package/src/utils/erc20.test.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import { ProcessorState
|
|
1
|
+
import { ProcessorState } from '@sentio/sdk'
|
|
2
2
|
import { getERC20TokenInfo } from './erc20'
|
|
3
|
+
import { loadTestProvidersFromEnv } from '../test'
|
|
3
4
|
|
|
4
5
|
describe('erc20 tests', () => {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
global.PROCESSOR_STATE = new ProcessorState()
|
|
7
|
+
const haveProviders = loadTestProvidersFromEnv('1')
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
'1': {
|
|
10
|
-
ChainID: '1',
|
|
11
|
-
Https: ['https://eth-mainnet.alchemyapi.io/v2/Gk024pFA-64RaEPIawL40n__1esXJFb2'], // Use env
|
|
12
|
-
},
|
|
13
|
-
})
|
|
14
|
-
})
|
|
9
|
+
const testIf = haveProviders ? test : test.skip
|
|
15
10
|
|
|
16
|
-
|
|
11
|
+
testIf('test bytes32', async () => {
|
|
17
12
|
const info = await getERC20TokenInfo('0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2')
|
|
18
13
|
|
|
19
14
|
expect(info.decimal).toEqual(18)
|
|
@@ -21,7 +16,7 @@ describe('erc20 tests', () => {
|
|
|
21
16
|
expect(info.name).toEqual('Maker')
|
|
22
17
|
})
|
|
23
18
|
|
|
24
|
-
|
|
19
|
+
testIf('test normal', async () => {
|
|
25
20
|
const info = await getERC20TokenInfo('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48')
|
|
26
21
|
|
|
27
22
|
expect(info.decimal).toEqual(6)
|
package/src/utils/erc20.ts
CHANGED
|
@@ -7,12 +7,18 @@ import { BigDecimal } from '@sentio/sdk'
|
|
|
7
7
|
import { toBigDecimal } from './convert'
|
|
8
8
|
import { utils } from 'ethers'
|
|
9
9
|
|
|
10
|
-
export
|
|
10
|
+
export class TokenInfo {
|
|
11
11
|
symbol: string
|
|
12
12
|
name: string
|
|
13
13
|
decimal: number
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
export const NATIVE_ETH = {
|
|
17
|
+
symbol: 'ETH',
|
|
18
|
+
decimal: 18,
|
|
19
|
+
name: 'Native ETH',
|
|
20
|
+
}
|
|
21
|
+
|
|
16
22
|
const TOKEN_INFOS = new Map<string, TokenInfo>()
|
|
17
23
|
|
|
18
24
|
export async function getERC20TokenInfo(tokenAddress: string, chainId = 1): Promise<TokenInfo> {
|
|
@@ -41,7 +47,7 @@ export async function getERC20TokenInfo(tokenAddress: string, chainId = 1): Prom
|
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
const decimal = await contract.decimals()
|
|
44
|
-
const info = { name, symbol, decimal }
|
|
50
|
+
const info: TokenInfo = { name, symbol, decimal }
|
|
45
51
|
TOKEN_INFOS.set(key, info)
|
|
46
52
|
return info
|
|
47
53
|
} catch (e) {
|
package/src/utils/index.ts
CHANGED