@sentio/sdk 1.7.18 → 1.7.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/lib/builtin/erc20/index.d.ts +1 -1
- package/lib/builtin/erc20/index.js +1 -1
- package/lib/builtin/erc20/index.js.map +1 -1
- package/lib/builtin/erc20/test-utils.d.ts +2 -1
- package/lib/builtin/erc20/test-utils.js +14 -3
- package/lib/builtin/erc20/test-utils.js.map +1 -1
- package/lib/builtin/erc20bytes/index.d.ts +2 -0
- package/lib/builtin/erc20bytes/index.js +22 -0
- package/lib/builtin/erc20bytes/index.js.map +1 -0
- package/lib/builtin/erc20bytes/test-utils.d.ts +4 -0
- package/lib/builtin/erc20bytes/test-utils.js +35 -0
- package/lib/builtin/erc20bytes/test-utils.js.map +1 -0
- package/lib/builtin/internal/ERC20.d.ts +307 -0
- package/lib/builtin/internal/{Weth9.js → ERC20.js} +1 -1
- package/lib/builtin/internal/ERC20.js.map +1 -0
- package/lib/builtin/internal/{Erc20.d.ts → ERC20Bytes.d.ts} +62 -46
- package/lib/builtin/internal/ERC20Bytes.js +3 -0
- package/lib/builtin/internal/ERC20Bytes.js.map +1 -0
- package/lib/builtin/internal/{Weth9.d.ts → WETH9.d.ts} +3 -3
- package/lib/builtin/internal/{Erc20.js → WETH9.js} +1 -1
- package/lib/builtin/internal/{Weth9.js.map → WETH9.js.map} +1 -1
- package/lib/builtin/internal/erc20_processor.d.ts +28 -16
- package/lib/builtin/internal/erc20_processor.js +168 -32
- package/lib/builtin/internal/erc20_processor.js.map +1 -1
- package/lib/builtin/internal/erc20bytes_processor.d.ts +42 -0
- package/lib/builtin/internal/erc20bytes_processor.js +271 -0
- package/lib/builtin/internal/erc20bytes_processor.js.map +1 -0
- package/lib/builtin/internal/factories/ERC20Bytes__factory.d.ts +48 -0
- package/lib/builtin/internal/factories/{Erc20__factory.js → ERC20Bytes__factory.js} +127 -89
- package/lib/builtin/internal/factories/ERC20Bytes__factory.js.map +1 -0
- package/lib/builtin/internal/factories/{Erc20__factory.d.ts → ERC20__factory.d.ts} +12 -5
- package/lib/builtin/internal/factories/ERC20__factory.js +404 -0
- package/lib/builtin/internal/factories/ERC20__factory.js.map +1 -0
- package/lib/builtin/internal/factories/{Weth9__factory.d.ts → WETH9__factory.d.ts} +4 -4
- package/lib/builtin/internal/factories/{Weth9__factory.js → WETH9__factory.js} +4 -4
- package/lib/builtin/internal/factories/{Weth9__factory.js.map → WETH9__factory.js.map} +1 -1
- package/lib/builtin/internal/factories/index.d.ts +3 -2
- package/lib/builtin/internal/factories/index.js +7 -5
- package/lib/builtin/internal/factories/index.js.map +1 -1
- package/lib/builtin/internal/index.d.ts +6 -4
- package/lib/builtin/internal/index.js +7 -5
- package/lib/builtin/internal/index.js.map +1 -1
- package/lib/builtin/internal/weth9_processor.d.ts +20 -20
- package/lib/builtin/internal/weth9_processor.js +36 -36
- package/lib/builtin/internal/weth9_processor.js.map +1 -1
- package/lib/builtin/weth9/index.d.ts +1 -1
- package/lib/builtin/weth9/index.js +1 -1
- package/lib/builtin/weth9/index.js.map +1 -1
- package/lib/builtin/weth9/test-utils.js +4 -4
- package/lib/builtin/weth9/test-utils.js.map +1 -1
- package/lib/error.d.ts +5 -0
- package/lib/error.js +6 -4
- package/lib/error.js.map +1 -1
- package/lib/generic-processor.d.ts +3 -3
- package/lib/generic-processor.js +8 -11
- package/lib/generic-processor.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/meter.d.ts +1 -0
- package/lib/meter.js +7 -1
- package/lib/meter.js.map +1 -1
- package/lib/meter.test.d.ts +1 -0
- package/lib/meter.test.js +16 -0
- package/lib/meter.test.js.map +1 -0
- package/lib/numberish.js.map +1 -1
- package/lib/test/erc20-template.js +3 -3
- package/lib/test/erc20-template.js.map +1 -1
- package/lib/test/erc20.js +8 -8
- package/lib/test/erc20.js.map +1 -1
- package/lib/test/erc20.test.js +3 -3
- package/lib/test/erc20.test.js.map +1 -1
- package/lib/utils/convert.d.ts +3 -1
- package/lib/utils/convert.js +19 -1
- package/lib/utils/convert.js.map +1 -1
- package/lib/utils/erc20.d.ts +9 -0
- package/lib/utils/erc20.js +51 -0
- package/lib/utils/erc20.js.map +1 -0
- package/lib/utils/erc20.test.d.ts +1 -0
- package/lib/utils/erc20.test.js +28 -0
- package/lib/utils/erc20.test.js.map +1 -0
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +5 -1
- package/lib/utils/index.js.map +1 -1
- package/package.json +3 -3
- package/src/abis/ERC20.json +174 -0
- package/src/abis/{erc20.json → ERC20Bytes.json} +124 -86
- package/src/abis/{weth9.json → WETH9.json} +0 -0
- package/src/builtin/erc20/index.ts +1 -1
- package/src/builtin/erc20/test-utils.ts +25 -3
- package/src/builtin/erc20bytes/index.ts +6 -0
- package/src/builtin/erc20bytes/test-utils.ts +53 -0
- package/src/builtin/internal/ERC20.ts +679 -0
- package/src/builtin/internal/{Erc20.ts → ERC20Bytes.ts} +138 -110
- package/src/builtin/internal/{Weth9.ts → WETH9.ts} +3 -3
- package/src/builtin/internal/erc20_processor.ts +188 -44
- package/src/builtin/internal/erc20bytes_processor.ts +362 -0
- package/src/builtin/internal/factories/{Erc20__factory.ts → ERC20Bytes__factory.ts} +132 -91
- package/src/builtin/internal/factories/ERC20__factory.ts +404 -0
- package/src/builtin/internal/factories/{Weth9__factory.ts → WETH9__factory.ts} +6 -6
- package/src/builtin/internal/factories/index.ts +3 -2
- package/src/builtin/internal/index.ts +6 -4
- package/src/builtin/internal/weth9_processor.ts +52 -52
- package/src/builtin/weth9/index.ts +1 -1
- package/src/builtin/weth9/test-utils.ts +5 -5
- package/src/error.ts +6 -4
- package/src/generic-processor.ts +8 -11
- package/src/index.ts +1 -0
- package/src/meter.test.ts +16 -0
- package/src/meter.ts +7 -0
- package/src/numberish.ts +2 -1
- package/src/test/erc20-template.ts +4 -4
- package/src/test/erc20.test.ts +3 -3
- package/src/test/erc20.ts +9 -9
- package/src/utils/convert.ts +21 -1
- package/src/utils/erc20.test.ts +31 -0
- package/src/utils/erc20.ts +60 -0
- package/src/utils/index.ts +2 -1
- package/lib/builtin/internal/Erc20.js.map +0 -1
- package/lib/builtin/internal/factories/Erc20__factory.js.map +0 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
import { Log } from "@ethersproject/providers";
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
getWETH9Contract,
|
|
7
7
|
ApprovalEventObject,
|
|
8
8
|
TransferEventObject,
|
|
9
9
|
DepositEventObject,
|
|
@@ -24,7 +24,7 @@ export function mockApprovalLog(
|
|
|
24
24
|
contractAddress: string,
|
|
25
25
|
event: ApprovalEventObject
|
|
26
26
|
): Log {
|
|
27
|
-
const contract =
|
|
27
|
+
const contract = getWETH9Contract(contractAddress);
|
|
28
28
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
29
29
|
contract.rawContract.interface.getEvent("Approval"),
|
|
30
30
|
Object.values(event)
|
|
@@ -41,7 +41,7 @@ export function mockTransferLog(
|
|
|
41
41
|
contractAddress: string,
|
|
42
42
|
event: TransferEventObject
|
|
43
43
|
): Log {
|
|
44
|
-
const contract =
|
|
44
|
+
const contract = getWETH9Contract(contractAddress);
|
|
45
45
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
46
46
|
contract.rawContract.interface.getEvent("Transfer"),
|
|
47
47
|
Object.values(event)
|
|
@@ -58,7 +58,7 @@ export function mockDepositLog(
|
|
|
58
58
|
contractAddress: string,
|
|
59
59
|
event: DepositEventObject
|
|
60
60
|
): Log {
|
|
61
|
-
const contract =
|
|
61
|
+
const contract = getWETH9Contract(contractAddress);
|
|
62
62
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
63
63
|
contract.rawContract.interface.getEvent("Deposit"),
|
|
64
64
|
Object.values(event)
|
|
@@ -75,7 +75,7 @@ export function mockWithdrawalLog(
|
|
|
75
75
|
contractAddress: string,
|
|
76
76
|
event: WithdrawalEventObject
|
|
77
77
|
): Log {
|
|
78
|
-
const contract =
|
|
78
|
+
const contract = getWETH9Contract(contractAddress);
|
|
79
79
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
80
80
|
contract.rawContract.interface.getEvent("Withdrawal"),
|
|
81
81
|
Object.values(event)
|
package/src/error.ts
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
import { Context } from './context'
|
|
3
3
|
import { errors } from 'ethers'
|
|
4
4
|
|
|
5
|
-
class EthersError extends Error {
|
|
6
|
-
|
|
5
|
+
export class EthersError extends Error {
|
|
6
|
+
e: Error
|
|
7
|
+
|
|
8
|
+
constructor(message: string, e: Error) {
|
|
7
9
|
super(message)
|
|
8
|
-
this.stack = stack
|
|
10
|
+
this.stack = e.stack
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
toString() {
|
|
@@ -29,7 +31,7 @@ export function transformEtherError(e: Error, ctx: Context<any, any> | undefined
|
|
|
29
31
|
msg = "jsonrpc eth_call return '0x' (likely contract not existed): " + JSON.stringify(e)
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
|
-
return new EthersError(msg, e
|
|
34
|
+
return new EthersError(msg, e)
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
if (e instanceof EthersError) {
|
package/src/generic-processor.ts
CHANGED
|
@@ -9,30 +9,27 @@ export class GenericProcessor extends BaseProcessor<
|
|
|
9
9
|
BaseContract,
|
|
10
10
|
BoundContractView<BaseContract, ContractView<BaseContract>>
|
|
11
11
|
> {
|
|
12
|
-
|
|
13
|
-
constructor(
|
|
12
|
+
eventABI: string[]
|
|
13
|
+
constructor(eventABI: string[], options: BindOptions) {
|
|
14
14
|
super(options)
|
|
15
|
-
this.
|
|
15
|
+
this.eventABI = eventABI
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
protected CreateBoundContractView(): BoundContractView<BaseContract, ContractView<BaseContract>> {
|
|
19
|
-
const contract = new BaseContract(this.config.address, this.
|
|
19
|
+
const contract = new BaseContract(this.config.address, this.eventABI, getProvider(this.config.network))
|
|
20
20
|
return new BoundContractView(new ContractView<BaseContract>(contract))
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
public static bind(
|
|
23
|
+
public static bind(eventABI: string[] | string, options: BindOptions): GenericProcessor {
|
|
24
24
|
const AbiName = 'Generic'
|
|
25
|
-
if (!Array.isArray(
|
|
26
|
-
|
|
25
|
+
if (!Array.isArray(eventABI)) {
|
|
26
|
+
eventABI = [eventABI]
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
// let processor = getProcessor(AbiName, options) as GenericProcessor;
|
|
30
|
-
// if (!processor) {
|
|
31
29
|
const finalOptions = Object.assign({}, options)
|
|
32
30
|
finalOptions.name = getContractName(AbiName, options.name, options.address, options.network)
|
|
33
|
-
const processor = new GenericProcessor(
|
|
31
|
+
const processor = new GenericProcessor(eventABI, finalOptions)
|
|
34
32
|
addProcessor(AbiName, options, processor)
|
|
35
|
-
// }
|
|
36
33
|
return processor
|
|
37
34
|
}
|
|
38
35
|
}
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { BindOptions, SolanaBindOptions } from './bind-options'
|
|
|
11
11
|
export { transformEtherError } from './error'
|
|
12
12
|
export { ProcessorState } from './processor-state'
|
|
13
13
|
export { BigNumber as BigDecimal } from 'bignumber.js'
|
|
14
|
+
export { EthersError } from './error'
|
|
14
15
|
|
|
15
16
|
export { getProcessor, addProcessor, getContractByABI, addContractByABI, getContractName } from './binds'
|
|
16
17
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { expect } from 'chai'
|
|
2
|
+
import { normalizeName } from './meter'
|
|
3
|
+
|
|
4
|
+
describe('meter tests', () => {
|
|
5
|
+
test('test normalization ', async () => {
|
|
6
|
+
expect(normalizeName('abc') === 'abc')
|
|
7
|
+
expect(normalizeName('a-b-c') === 'a-b-c')
|
|
8
|
+
expect(normalizeName('_a-B-1.') === '_a-B-1.')
|
|
9
|
+
|
|
10
|
+
expect(normalizeName('a/b\\c\n') === 'abc')
|
|
11
|
+
expect(normalizeName('abc abc') === 'abc_abc')
|
|
12
|
+
expect(normalizeName('*&~') === '___')
|
|
13
|
+
|
|
14
|
+
expect(normalizeName('x'.repeat(200)).length === 100)
|
|
15
|
+
})
|
|
16
|
+
})
|
package/src/meter.ts
CHANGED
|
@@ -3,7 +3,14 @@ import { Context, EthContext, SolanaContext } from './context'
|
|
|
3
3
|
import { toMetricValue, Numberish } from './numberish'
|
|
4
4
|
import Long from 'long'
|
|
5
5
|
|
|
6
|
+
export function normalizeName(name: string) {
|
|
7
|
+
const regex = new RegExp('![_.a-zA-Z0-9]')
|
|
8
|
+
return name.slice(0, 100).replace(regex, '_')
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
function GetRecordMetaData(ctx: EthContext | SolanaContext, name: string, labels: Labels): RecordMetaData {
|
|
12
|
+
name = normalizeName(name)
|
|
13
|
+
|
|
7
14
|
if (ctx instanceof Context) {
|
|
8
15
|
if (ctx.log) {
|
|
9
16
|
return {
|
package/src/numberish.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { BigInteger, MetricValue } from './gen/processor/protos/processor'
|
|
|
3
3
|
import { BigDecimal } from '.'
|
|
4
4
|
import { BN } from '@project-serum/anchor'
|
|
5
5
|
|
|
6
|
-
export type Numberish = number | BigNumber | bigint | BigDecimal
|
|
6
|
+
export type Numberish = number | BigNumber | bigint | BigDecimal
|
|
7
7
|
|
|
8
8
|
export function toMetricValue(value: Numberish): MetricValue {
|
|
9
9
|
if (value instanceof BigNumber) {
|
|
@@ -38,6 +38,7 @@ export function toMetricValue(value: Numberish): MetricValue {
|
|
|
38
38
|
doubleValue: Number(value),
|
|
39
39
|
})
|
|
40
40
|
}
|
|
41
|
+
|
|
41
42
|
function bigDecimalToBigInteger(a: BigDecimal): BigInteger {
|
|
42
43
|
const negative = a.isNegative()
|
|
43
44
|
if (negative) {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ERC20Processor, ERC20ProcessorTemplate } from '../builtin/erc20'
|
|
2
2
|
|
|
3
|
-
export const filter =
|
|
3
|
+
export const filter = ERC20Processor.filters.Transfer(
|
|
4
4
|
'0x0000000000000000000000000000000000000000',
|
|
5
5
|
'0xb329e39ebefd16f40d38f07643652ce17ca5bac1'
|
|
6
6
|
)
|
|
7
7
|
|
|
8
|
-
const processorTemplate = new
|
|
8
|
+
const processorTemplate = new ERC20ProcessorTemplate().onTransfer(async function (event, ctx) {
|
|
9
9
|
console.log('')
|
|
10
10
|
})
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
ERC20Processor.bind({
|
|
13
13
|
address: '0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9',
|
|
14
14
|
network: 1,
|
|
15
15
|
name: 'x2y2',
|
package/src/test/erc20.test.ts
CHANGED
|
@@ -21,10 +21,10 @@ describe('Test Basic Examples', () => {
|
|
|
21
21
|
expect(config.contractConfigs).length(5)
|
|
22
22
|
|
|
23
23
|
// check auto rename
|
|
24
|
-
expect(config.contractConfigs?.[2].contract?.name).equals('
|
|
25
|
-
expect(config.contractConfigs?.[3].contract?.name).equals('
|
|
24
|
+
expect(config.contractConfigs?.[2].contract?.name).equals('ERC20')
|
|
25
|
+
expect(config.contractConfigs?.[3].contract?.name).equals('ERC20_1')
|
|
26
26
|
// same as above because only differ in parameters
|
|
27
|
-
expect(config.contractConfigs?.[4].contract?.name).equals('
|
|
27
|
+
expect(config.contractConfigs?.[4].contract?.name).equals('ERC20_1')
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
test('Check block dispatch', async () => {
|
package/src/test/erc20.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ERC20Processor, ERC20ProcessorTemplate } from '../builtin/erc20'
|
|
2
2
|
|
|
3
|
-
export const filter =
|
|
3
|
+
export const filter = ERC20Processor.filters.Transfer(
|
|
4
4
|
'0x0000000000000000000000000000000000000000',
|
|
5
5
|
'0xb329e39ebefd16f40d38f07643652ce17ca5bac1'
|
|
6
6
|
)
|
|
7
7
|
|
|
8
|
-
const processorTemplate = new
|
|
8
|
+
const processorTemplate = new ERC20ProcessorTemplate().onTransfer(async function (event, ctx) {
|
|
9
9
|
console.log('')
|
|
10
10
|
})
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
ERC20Processor.bind({
|
|
13
13
|
address: '0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9',
|
|
14
14
|
// network: 1,
|
|
15
15
|
name: 'x2y2',
|
|
@@ -24,7 +24,7 @@ Erc20Processor.bind({
|
|
|
24
24
|
ctx.meter.Gauge('g1').record(10, { k: 'v' })
|
|
25
25
|
})
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
ERC20Processor.bind({ address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', network: 56, name: 'usdc' })
|
|
28
28
|
.onTransfer(async function (event, ctx) {
|
|
29
29
|
ctx.meter.Counter('c2').add(2)
|
|
30
30
|
}, filter)
|
|
@@ -33,11 +33,11 @@ Erc20Processor.bind({ address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', net
|
|
|
33
33
|
})
|
|
34
34
|
// .startBlock(14201940)
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
ERC20Processor.bind({ address: 'xxxx', network: 56 })
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
ERC20Processor.bind({ address: 'yyyy', network: 1 })
|
|
39
|
+
ERC20Processor.bind({ address: 'yyyy', network: 1 })
|
|
40
|
+
ERC20Processor.bind({ address: 'yyyy', network: 1, startBlock: 21 })
|
|
41
41
|
|
|
42
42
|
// const template = Erc20Processor.template
|
|
43
43
|
// .onTransfer(async function (event, ctx) {
|
package/src/utils/convert.ts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
import { BigNumber } from 'ethers'
|
|
2
|
-
import { BigDecimal } from '@sentio/sdk'
|
|
2
|
+
import { BigDecimal, MetricValue } from '@sentio/sdk'
|
|
3
|
+
import { Numberish } from '../numberish'
|
|
3
4
|
|
|
4
5
|
export function toBigDecimal(n: BigNumber) {
|
|
5
6
|
return new BigDecimal(n.toString())
|
|
6
7
|
}
|
|
8
|
+
|
|
9
|
+
export function metricValueToNumberish(v: MetricValue): Numberish {
|
|
10
|
+
if (v.doubleValue) {
|
|
11
|
+
return v.doubleValue
|
|
12
|
+
}
|
|
13
|
+
if (v.bigInteger) {
|
|
14
|
+
const bn = BigNumber.from(v.bigInteger.data)
|
|
15
|
+
if (v.bigInteger.negative) {
|
|
16
|
+
return BigNumber.from(0).sub(bn)
|
|
17
|
+
}
|
|
18
|
+
return bn
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (v.bigDecimal) {
|
|
22
|
+
return new BigDecimal(v.bigDecimal)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
throw Error("MetricValue doesn't contain any of possible value")
|
|
26
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ProcessorState, setProvider } from '@sentio/sdk'
|
|
2
|
+
import { getERC20TokenInfo } from './erc20'
|
|
3
|
+
|
|
4
|
+
describe('erc20 tests', () => {
|
|
5
|
+
beforeAll(async () => {
|
|
6
|
+
global.PROCESSOR_STATE = new ProcessorState()
|
|
7
|
+
|
|
8
|
+
setProvider({
|
|
9
|
+
'1': {
|
|
10
|
+
ChainID: '1',
|
|
11
|
+
Https: ['https://eth-mainnet.alchemyapi.io/v2/Gk024pFA-64RaEPIawL40n__1esXJFb2'], // Use env
|
|
12
|
+
},
|
|
13
|
+
})
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test('test bytes32', async () => {
|
|
17
|
+
const info = await getERC20TokenInfo('0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2')
|
|
18
|
+
|
|
19
|
+
expect(info.decimal).toEqual(18)
|
|
20
|
+
expect(info.symbol).toEqual('MKR')
|
|
21
|
+
expect(info.name).toEqual('Maker')
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
test('test normal', async () => {
|
|
25
|
+
const info = await getERC20TokenInfo('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48')
|
|
26
|
+
|
|
27
|
+
expect(info.decimal).toEqual(6)
|
|
28
|
+
expect(info.symbol).toEqual('USDC')
|
|
29
|
+
expect(info.name).toEqual('USD Coin')
|
|
30
|
+
})
|
|
31
|
+
})
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { BigNumber } from '@ethersproject/bignumber'
|
|
2
|
+
|
|
3
|
+
import { transformEtherError } from '../error'
|
|
4
|
+
import { getERC20Contract } from '../builtin/erc20'
|
|
5
|
+
import { getERC20BytesContract } from '../builtin/internal/erc20bytes_processor'
|
|
6
|
+
import { BigDecimal } from '@sentio/sdk'
|
|
7
|
+
import { toBigDecimal } from './convert'
|
|
8
|
+
import { utils } from 'ethers'
|
|
9
|
+
|
|
10
|
+
export interface TokenInfo {
|
|
11
|
+
symbol: string
|
|
12
|
+
name: string
|
|
13
|
+
decimal: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const TOKEN_INFOS = new Map<string, TokenInfo>()
|
|
17
|
+
|
|
18
|
+
export async function getERC20TokenInfo(tokenAddress: string, chainId = 1): Promise<TokenInfo> {
|
|
19
|
+
const key = chainId + tokenAddress
|
|
20
|
+
const res = TOKEN_INFOS.get(key)
|
|
21
|
+
if (res) {
|
|
22
|
+
return res
|
|
23
|
+
}
|
|
24
|
+
const contract = getERC20Contract(tokenAddress, chainId)
|
|
25
|
+
const bytesContract = getERC20BytesContract(tokenAddress, chainId)
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
// TODO maybe not do try catch, just do raw call the parse results
|
|
29
|
+
let name = ''
|
|
30
|
+
try {
|
|
31
|
+
name = await contract.name()
|
|
32
|
+
} catch (e) {
|
|
33
|
+
name = utils.parseBytes32String(await bytesContract.name())
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let symbol = ''
|
|
37
|
+
try {
|
|
38
|
+
symbol = await contract.symbol()
|
|
39
|
+
} catch (e) {
|
|
40
|
+
symbol = utils.parseBytes32String(await bytesContract.symbol())
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const decimal = await contract.decimals()
|
|
44
|
+
const info = { name, symbol, decimal }
|
|
45
|
+
TOKEN_INFOS.set(key, info)
|
|
46
|
+
return info
|
|
47
|
+
} catch (e) {
|
|
48
|
+
throw transformEtherError(e, undefined)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function getER20NormalizedAmount(
|
|
53
|
+
tokenAddress: string,
|
|
54
|
+
amount: BigNumber,
|
|
55
|
+
chainId: number
|
|
56
|
+
): Promise<BigDecimal> {
|
|
57
|
+
const tokenInfo = await getERC20TokenInfo(tokenAddress, chainId)
|
|
58
|
+
const divider = new BigDecimal(10).pow(tokenInfo.decimal)
|
|
59
|
+
return toBigDecimal(amount).dividedBy(divider)
|
|
60
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Erc20.js","sourceRoot":"","sources":["../../../src/builtin/internal/Erc20.ts"],"names":[],"mappings":"","sourcesContent":["/* Autogenerated file. Do not edit manually. */\n/* tslint:disable */\n/* eslint-disable */\nimport type {\n BaseContract,\n BigNumber,\n BigNumberish,\n BytesLike,\n CallOverrides,\n ContractTransaction,\n Overrides,\n PopulatedTransaction,\n Signer,\n utils,\n} from \"ethers\";\nimport type {\n FunctionFragment,\n Result,\n EventFragment,\n} from \"@ethersproject/abi\";\nimport type { Listener, Provider } from \"@ethersproject/providers\";\nimport type {\n TypedEventFilter,\n TypedEvent,\n TypedListener,\n OnEvent,\n PromiseOrValue,\n} from \"./common\";\n\nexport interface Erc20Interface extends utils.Interface {\n functions: {\n \"allowance(address,address)\": FunctionFragment;\n \"approve(address,uint256)\": FunctionFragment;\n \"balanceOf(address)\": FunctionFragment;\n \"decimals()\": FunctionFragment;\n \"totalSupply()\": FunctionFragment;\n \"transfer(address,uint256)\": FunctionFragment;\n \"transferFrom(address,address,uint256)\": FunctionFragment;\n };\n\n getFunction(\n nameOrSignatureOrTopic:\n | \"allowance\"\n | \"approve\"\n | \"balanceOf\"\n | \"decimals\"\n | \"totalSupply\"\n | \"transfer\"\n | \"transferFrom\"\n ): FunctionFragment;\n\n encodeFunctionData(\n functionFragment: \"allowance\",\n values: [PromiseOrValue<string>, PromiseOrValue<string>]\n ): string;\n encodeFunctionData(\n functionFragment: \"approve\",\n values: [PromiseOrValue<string>, PromiseOrValue<BigNumberish>]\n ): string;\n encodeFunctionData(\n functionFragment: \"balanceOf\",\n values: [PromiseOrValue<string>]\n ): string;\n encodeFunctionData(functionFragment: \"decimals\", values?: undefined): string;\n encodeFunctionData(\n functionFragment: \"totalSupply\",\n values?: undefined\n ): string;\n encodeFunctionData(\n functionFragment: \"transfer\",\n values: [PromiseOrValue<string>, PromiseOrValue<BigNumberish>]\n ): string;\n encodeFunctionData(\n functionFragment: \"transferFrom\",\n values: [\n PromiseOrValue<string>,\n PromiseOrValue<string>,\n PromiseOrValue<BigNumberish>\n ]\n ): string;\n\n decodeFunctionResult(functionFragment: \"allowance\", data: BytesLike): Result;\n decodeFunctionResult(functionFragment: \"approve\", data: BytesLike): Result;\n decodeFunctionResult(functionFragment: \"balanceOf\", data: BytesLike): Result;\n decodeFunctionResult(functionFragment: \"decimals\", data: BytesLike): Result;\n decodeFunctionResult(\n functionFragment: \"totalSupply\",\n data: BytesLike\n ): Result;\n decodeFunctionResult(functionFragment: \"transfer\", data: BytesLike): Result;\n decodeFunctionResult(\n functionFragment: \"transferFrom\",\n data: BytesLike\n ): Result;\n\n events: {\n \"Approval(address,address,uint256)\": EventFragment;\n \"Transfer(address,address,uint256)\": EventFragment;\n };\n\n getEvent(nameOrSignatureOrTopic: \"Approval\"): EventFragment;\n getEvent(nameOrSignatureOrTopic: \"Transfer\"): EventFragment;\n}\n\nexport interface ApprovalEventObject {\n owner: string;\n spender: string;\n value: BigNumber;\n}\nexport type ApprovalEvent = TypedEvent<\n [string, string, BigNumber],\n ApprovalEventObject\n>;\n\nexport type ApprovalEventFilter = TypedEventFilter<ApprovalEvent>;\n\nexport interface TransferEventObject {\n from: string;\n to: string;\n value: BigNumber;\n}\nexport type TransferEvent = TypedEvent<\n [string, string, BigNumber],\n TransferEventObject\n>;\n\nexport type TransferEventFilter = TypedEventFilter<TransferEvent>;\n\nexport interface Erc20 extends BaseContract {\n connect(signerOrProvider: Signer | Provider | string): this;\n attach(addressOrName: string): this;\n deployed(): Promise<this>;\n\n interface: Erc20Interface;\n\n queryFilter<TEvent extends TypedEvent>(\n event: TypedEventFilter<TEvent>,\n fromBlockOrBlockhash?: string | number | undefined,\n toBlock?: string | number | undefined\n ): Promise<Array<TEvent>>;\n\n listeners<TEvent extends TypedEvent>(\n eventFilter?: TypedEventFilter<TEvent>\n ): Array<TypedListener<TEvent>>;\n listeners(eventName?: string): Array<Listener>;\n removeAllListeners<TEvent extends TypedEvent>(\n eventFilter: TypedEventFilter<TEvent>\n ): this;\n removeAllListeners(eventName?: string): this;\n off: OnEvent<this>;\n on: OnEvent<this>;\n once: OnEvent<this>;\n removeListener: OnEvent<this>;\n\n functions: {\n allowance(\n owner: PromiseOrValue<string>,\n spender: PromiseOrValue<string>,\n overrides?: CallOverrides\n ): Promise<[BigNumber]>;\n\n approve(\n spender: PromiseOrValue<string>,\n amount: PromiseOrValue<BigNumberish>,\n overrides?: Overrides & { from?: PromiseOrValue<string> }\n ): Promise<ContractTransaction>;\n\n balanceOf(\n account: PromiseOrValue<string>,\n overrides?: CallOverrides\n ): Promise<[BigNumber]>;\n\n decimals(overrides?: CallOverrides): Promise<[number]>;\n\n totalSupply(overrides?: CallOverrides): Promise<[BigNumber]>;\n\n transfer(\n to: PromiseOrValue<string>,\n amount: PromiseOrValue<BigNumberish>,\n overrides?: Overrides & { from?: PromiseOrValue<string> }\n ): Promise<ContractTransaction>;\n\n transferFrom(\n from: PromiseOrValue<string>,\n to: PromiseOrValue<string>,\n amount: PromiseOrValue<BigNumberish>,\n overrides?: Overrides & { from?: PromiseOrValue<string> }\n ): Promise<ContractTransaction>;\n };\n\n allowance(\n owner: PromiseOrValue<string>,\n spender: PromiseOrValue<string>,\n overrides?: CallOverrides\n ): Promise<BigNumber>;\n\n approve(\n spender: PromiseOrValue<string>,\n amount: PromiseOrValue<BigNumberish>,\n overrides?: Overrides & { from?: PromiseOrValue<string> }\n ): Promise<ContractTransaction>;\n\n balanceOf(\n account: PromiseOrValue<string>,\n overrides?: CallOverrides\n ): Promise<BigNumber>;\n\n decimals(overrides?: CallOverrides): Promise<number>;\n\n totalSupply(overrides?: CallOverrides): Promise<BigNumber>;\n\n transfer(\n to: PromiseOrValue<string>,\n amount: PromiseOrValue<BigNumberish>,\n overrides?: Overrides & { from?: PromiseOrValue<string> }\n ): Promise<ContractTransaction>;\n\n transferFrom(\n from: PromiseOrValue<string>,\n to: PromiseOrValue<string>,\n amount: PromiseOrValue<BigNumberish>,\n overrides?: Overrides & { from?: PromiseOrValue<string> }\n ): Promise<ContractTransaction>;\n\n callStatic: {\n allowance(\n owner: PromiseOrValue<string>,\n spender: PromiseOrValue<string>,\n overrides?: CallOverrides\n ): Promise<BigNumber>;\n\n approve(\n spender: PromiseOrValue<string>,\n amount: PromiseOrValue<BigNumberish>,\n overrides?: CallOverrides\n ): Promise<boolean>;\n\n balanceOf(\n account: PromiseOrValue<string>,\n overrides?: CallOverrides\n ): Promise<BigNumber>;\n\n decimals(overrides?: CallOverrides): Promise<number>;\n\n totalSupply(overrides?: CallOverrides): Promise<BigNumber>;\n\n transfer(\n to: PromiseOrValue<string>,\n amount: PromiseOrValue<BigNumberish>,\n overrides?: CallOverrides\n ): Promise<boolean>;\n\n transferFrom(\n from: PromiseOrValue<string>,\n to: PromiseOrValue<string>,\n amount: PromiseOrValue<BigNumberish>,\n overrides?: CallOverrides\n ): Promise<boolean>;\n };\n\n filters: {\n \"Approval(address,address,uint256)\"(\n owner?: PromiseOrValue<string> | null,\n spender?: PromiseOrValue<string> | null,\n value?: null\n ): ApprovalEventFilter;\n Approval(\n owner?: PromiseOrValue<string> | null,\n spender?: PromiseOrValue<string> | null,\n value?: null\n ): ApprovalEventFilter;\n\n \"Transfer(address,address,uint256)\"(\n from?: PromiseOrValue<string> | null,\n to?: PromiseOrValue<string> | null,\n value?: null\n ): TransferEventFilter;\n Transfer(\n from?: PromiseOrValue<string> | null,\n to?: PromiseOrValue<string> | null,\n value?: null\n ): TransferEventFilter;\n };\n\n estimateGas: {\n allowance(\n owner: PromiseOrValue<string>,\n spender: PromiseOrValue<string>,\n overrides?: CallOverrides\n ): Promise<BigNumber>;\n\n approve(\n spender: PromiseOrValue<string>,\n amount: PromiseOrValue<BigNumberish>,\n overrides?: Overrides & { from?: PromiseOrValue<string> }\n ): Promise<BigNumber>;\n\n balanceOf(\n account: PromiseOrValue<string>,\n overrides?: CallOverrides\n ): Promise<BigNumber>;\n\n decimals(overrides?: CallOverrides): Promise<BigNumber>;\n\n totalSupply(overrides?: CallOverrides): Promise<BigNumber>;\n\n transfer(\n to: PromiseOrValue<string>,\n amount: PromiseOrValue<BigNumberish>,\n overrides?: Overrides & { from?: PromiseOrValue<string> }\n ): Promise<BigNumber>;\n\n transferFrom(\n from: PromiseOrValue<string>,\n to: PromiseOrValue<string>,\n amount: PromiseOrValue<BigNumberish>,\n overrides?: Overrides & { from?: PromiseOrValue<string> }\n ): Promise<BigNumber>;\n };\n\n populateTransaction: {\n allowance(\n owner: PromiseOrValue<string>,\n spender: PromiseOrValue<string>,\n overrides?: CallOverrides\n ): Promise<PopulatedTransaction>;\n\n approve(\n spender: PromiseOrValue<string>,\n amount: PromiseOrValue<BigNumberish>,\n overrides?: Overrides & { from?: PromiseOrValue<string> }\n ): Promise<PopulatedTransaction>;\n\n balanceOf(\n account: PromiseOrValue<string>,\n overrides?: CallOverrides\n ): Promise<PopulatedTransaction>;\n\n decimals(overrides?: CallOverrides): Promise<PopulatedTransaction>;\n\n totalSupply(overrides?: CallOverrides): Promise<PopulatedTransaction>;\n\n transfer(\n to: PromiseOrValue<string>,\n amount: PromiseOrValue<BigNumberish>,\n overrides?: Overrides & { from?: PromiseOrValue<string> }\n ): Promise<PopulatedTransaction>;\n\n transferFrom(\n from: PromiseOrValue<string>,\n to: PromiseOrValue<string>,\n amount: PromiseOrValue<BigNumberish>,\n overrides?: Overrides & { from?: PromiseOrValue<string> }\n ): Promise<PopulatedTransaction>;\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Erc20__factory.js","sourceRoot":"","sources":["../../../../src/builtin/internal/factories/Erc20__factory.ts"],"names":[],"mappings":"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","sourcesContent":["/* Autogenerated file. Do not edit manually. */\n/* tslint:disable */\n/* eslint-disable */\n\nimport { Contract, Signer, utils } from \"ethers\";\nimport type { Provider } from \"@ethersproject/providers\";\nimport type { Erc20, Erc20Interface } from \"../Erc20\";\n\nconst _abi = [\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n internalType: \"address\",\n name: \"owner\",\n type: \"address\",\n },\n {\n indexed: true,\n internalType: \"address\",\n name: \"spender\",\n type: \"address\",\n },\n {\n indexed: false,\n internalType: \"uint256\",\n name: \"value\",\n type: \"uint256\",\n },\n ],\n name: \"Approval\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n internalType: \"address\",\n name: \"from\",\n type: \"address\",\n },\n {\n indexed: true,\n internalType: \"address\",\n name: \"to\",\n type: \"address\",\n },\n {\n indexed: false,\n internalType: \"uint256\",\n name: \"value\",\n type: \"uint256\",\n },\n ],\n name: \"Transfer\",\n type: \"event\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"owner\",\n type: \"address\",\n },\n {\n internalType: \"address\",\n name: \"spender\",\n type: \"address\",\n },\n ],\n name: \"allowance\",\n outputs: [\n {\n internalType: \"uint256\",\n name: \"\",\n type: \"uint256\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"spender\",\n type: \"address\",\n },\n {\n internalType: \"uint256\",\n name: \"amount\",\n type: \"uint256\",\n },\n ],\n name: \"approve\",\n outputs: [\n {\n internalType: \"bool\",\n name: \"\",\n type: \"bool\",\n },\n ],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"account\",\n type: \"address\",\n },\n ],\n name: \"balanceOf\",\n outputs: [\n {\n internalType: \"uint256\",\n name: \"\",\n type: \"uint256\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"decimals\",\n outputs: [\n {\n internalType: \"uint8\",\n name: \"\",\n type: \"uint8\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"totalSupply\",\n outputs: [\n {\n internalType: \"uint256\",\n name: \"\",\n type: \"uint256\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"to\",\n type: \"address\",\n },\n {\n internalType: \"uint256\",\n name: \"amount\",\n type: \"uint256\",\n },\n ],\n name: \"transfer\",\n outputs: [\n {\n internalType: \"bool\",\n name: \"\",\n type: \"bool\",\n },\n ],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"from\",\n type: \"address\",\n },\n {\n internalType: \"address\",\n name: \"to\",\n type: \"address\",\n },\n {\n internalType: \"uint256\",\n name: \"amount\",\n type: \"uint256\",\n },\n ],\n name: \"transferFrom\",\n outputs: [\n {\n internalType: \"bool\",\n name: \"\",\n type: \"bool\",\n },\n ],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n];\n\nexport class Erc20__factory {\n static readonly abi = _abi;\n static createInterface(): Erc20Interface {\n return new utils.Interface(_abi) as Erc20Interface;\n }\n static connect(address: string, signerOrProvider: Signer | Provider): Erc20 {\n return new Contract(address, _abi, signerOrProvider) as Erc20;\n }\n}\n"]}
|