datai-sdk 1.0.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/@graphprotocol/graph-ts/README.md +13 -0
- package/@graphprotocol/graph-ts/chain/arweave.ts +82 -0
- package/@graphprotocol/graph-ts/chain/cosmos.ts +426 -0
- package/@graphprotocol/graph-ts/chain/ethereum.ts +727 -0
- package/@graphprotocol/graph-ts/chain/near.ts +420 -0
- package/@graphprotocol/graph-ts/chain/starknet.ts +39 -0
- package/@graphprotocol/graph-ts/common/collections.ts +495 -0
- package/@graphprotocol/graph-ts/common/conversion.ts +3 -0
- package/@graphprotocol/graph-ts/common/datasource.ts +41 -0
- package/@graphprotocol/graph-ts/common/eager_offset.ts +42 -0
- package/@graphprotocol/graph-ts/common/json.ts +28 -0
- package/@graphprotocol/graph-ts/common/numbers.ts +407 -0
- package/@graphprotocol/graph-ts/common/value.ts +585 -0
- package/@graphprotocol/graph-ts/global/global.ts +4 -0
- package/@graphprotocol/graph-ts/helper-functions.ts +79 -0
- package/@graphprotocol/graph-ts/index.ts +156 -0
- package/@graphprotocol/graph-ts/package.json +3 -0
- package/@graphprotocol/graph-ts/tsconfig.json +4 -0
- package/@graphprotocol/graph-ts/types/tsconfig.base.json +3 -0
- package/API/index.ts +1 -0
- package/API/v1/activePositions/ActivePositionsResult.ts +147 -0
- package/API/v1/activePositions/TokenBalance.ts +25 -0
- package/API/v1/activePositions/activePositions.ts +37 -0
- package/API/v1/bigDecimal/BigDecimalPb.ts +40 -0
- package/API/v1/bigDecimal/bigDecimal.ts +75 -0
- package/API/v1/bigInt/bigInt.ts +123 -0
- package/API/v1/crypto/crypto.ts +16 -0
- package/API/v1/ethereum/SmartContractCallPb.ts +84 -0
- package/API/v1/ethereum/ValuePb.ts +113 -0
- package/API/v1/ethereum/ValuesPb.ts +39 -0
- package/API/v1/ethereum/ethereum.ts +76 -0
- package/API/v1/index.ts +10 -0
- package/API/v1/log/log.ts +18 -0
- package/API/v1/proto/activePositions/ActivePositionsResultPb.ts +139 -0
- package/API/v1/proto/activePositions/TokenBalancePb.ts +69 -0
- package/API/v1/proto/bigDecimal/BigDecimalPb.ts +56 -0
- package/API/v1/proto/ethereum/SmartContractCallPb.ts +102 -0
- package/API/v1/proto/ethereum/ValueKindPb.ts +17 -0
- package/API/v1/proto/ethereum/ValuePb.ts +96 -0
- package/API/v1/proto/ethereum/ValuesPb.ts +53 -0
- package/API/v1/proto/google/protobuf/Any.ts +56 -0
- package/API/v1/proto/google/protobuf/Timestamp.ts +56 -0
- package/API/v1/proto/store/EntitiesPb.ts +53 -0
- package/API/v1/proto/store/EntityPb.ts +99 -0
- package/API/v1/proto/store/EntityWithMetaPb.ts +75 -0
- package/API/v1/proto/store/ValueKindPb.ts +17 -0
- package/API/v1/proto/store/ValuePb.ts +132 -0
- package/API/v1/proto/store/ValuesPb.ts +53 -0
- package/API/v1/proto/watcher/WatcherResultPb.ts +62 -0
- package/API/v1/store/EntitiesPb.ts +39 -0
- package/API/v1/store/EntityPb.ts +75 -0
- package/API/v1/store/ValuePb.ts +154 -0
- package/API/v1/store/ValuesPb.ts +39 -0
- package/API/v1/store/store.ts +78 -0
- package/API/v1/typeConversion/typeConversion.ts +57 -0
- package/API/v1/watcher/WatcherInput.ts +9 -0
- package/API/v1/watcher/watcher.ts +33 -0
- package/index.ts +5 -0
- package/package.json +11 -0
- package/utils/constants.ts +16 -0
- package/utils/mathUtils.ts +77 -0
- package/utils/pdk.ts +171 -0
- package/utils/subgraphUtils.ts +27 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Code is NOT generated
|
|
2
|
+
// but the generated code from proto folder was used as reference
|
|
3
|
+
// it is done this way to directly encode/decode into graph-ts types
|
|
4
|
+
|
|
5
|
+
import { Writer, Reader } from 'as-proto/assembly'
|
|
6
|
+
import { ethereum, Address } from '@graphprotocol/graph-ts/'
|
|
7
|
+
import { ValuesPb } from './ValuesPb'
|
|
8
|
+
|
|
9
|
+
export namespace SmartContractCallPb {
|
|
10
|
+
export function encode(
|
|
11
|
+
message: ethereum.SmartContractCall,
|
|
12
|
+
writer: Writer
|
|
13
|
+
): void {
|
|
14
|
+
writer.uint32(10)
|
|
15
|
+
writer.string(message.contractName)
|
|
16
|
+
|
|
17
|
+
writer.uint32(18)
|
|
18
|
+
writer.bytes(message.contractAddress)
|
|
19
|
+
|
|
20
|
+
writer.uint32(26)
|
|
21
|
+
writer.string(message.functionName)
|
|
22
|
+
|
|
23
|
+
writer.uint32(34)
|
|
24
|
+
writer.string(message.functionSignature)
|
|
25
|
+
|
|
26
|
+
const functionParams = message.functionParams
|
|
27
|
+
if (functionParams !== null) {
|
|
28
|
+
writer.uint32(42)
|
|
29
|
+
writer.fork()
|
|
30
|
+
ValuesPb.encode(functionParams, writer)
|
|
31
|
+
writer.ldelim()
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function decode(
|
|
36
|
+
reader: Reader,
|
|
37
|
+
length: i32
|
|
38
|
+
): ethereum.SmartContractCall {
|
|
39
|
+
const end: usize = length < 0 ? reader.end : reader.ptr + length
|
|
40
|
+
|
|
41
|
+
let contractName: string | null = null
|
|
42
|
+
let contractAddress: Address | null = null
|
|
43
|
+
let functionName: string | null = null
|
|
44
|
+
let functionSignature: string | null = null
|
|
45
|
+
let functionParams: Array<ethereum.Value> | null = null
|
|
46
|
+
|
|
47
|
+
while (reader.ptr < end) {
|
|
48
|
+
const tag = reader.uint32()
|
|
49
|
+
switch (tag >>> 3) {
|
|
50
|
+
case 1:
|
|
51
|
+
contractName = reader.string()
|
|
52
|
+
break
|
|
53
|
+
|
|
54
|
+
case 2:
|
|
55
|
+
contractAddress = changetype<Address>(reader.bytes())
|
|
56
|
+
break
|
|
57
|
+
|
|
58
|
+
case 3:
|
|
59
|
+
functionName = reader.string()
|
|
60
|
+
break
|
|
61
|
+
|
|
62
|
+
case 4:
|
|
63
|
+
functionSignature = reader.string()
|
|
64
|
+
break
|
|
65
|
+
|
|
66
|
+
case 5:
|
|
67
|
+
functionParams = ValuesPb.decode(reader, reader.uint32())
|
|
68
|
+
break
|
|
69
|
+
|
|
70
|
+
default:
|
|
71
|
+
reader.skipType(tag & 7)
|
|
72
|
+
break
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return new ethereum.SmartContractCall(
|
|
77
|
+
contractName!,
|
|
78
|
+
contractAddress!,
|
|
79
|
+
functionName!,
|
|
80
|
+
functionSignature!,
|
|
81
|
+
functionParams!
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Code is NOT generated
|
|
2
|
+
// but the generated code from proto folder was used as reference
|
|
3
|
+
// it is done this way to directly encode/decode into graph-ts types
|
|
4
|
+
|
|
5
|
+
import { Writer, Reader } from 'as-proto/assembly'
|
|
6
|
+
import { Bytes, BigInt, Address, ethereum } from '@graphprotocol/graph-ts/'
|
|
7
|
+
import { ValuesPb } from './ValuesPb'
|
|
8
|
+
|
|
9
|
+
export namespace ValuePb {
|
|
10
|
+
export function encode(message: ethereum.Value, writer: Writer): void {
|
|
11
|
+
writer.uint32(8)
|
|
12
|
+
writer.int32(message.kind)
|
|
13
|
+
|
|
14
|
+
switch (message.kind) {
|
|
15
|
+
case ethereum.ValueKind.ADDRESS:
|
|
16
|
+
case ethereum.ValueKind.FIXED_BYTES:
|
|
17
|
+
case ethereum.ValueKind.BYTES:
|
|
18
|
+
case ethereum.ValueKind.INT:
|
|
19
|
+
case ethereum.ValueKind.UINT:
|
|
20
|
+
writer.uint32(818)
|
|
21
|
+
writer.bytes(changetype<Bytes>(message.data as u32))
|
|
22
|
+
break
|
|
23
|
+
|
|
24
|
+
case ethereum.ValueKind.BOOL:
|
|
25
|
+
writer.uint32(840)
|
|
26
|
+
writer.bool(message.toBoolean())
|
|
27
|
+
break
|
|
28
|
+
|
|
29
|
+
case ethereum.ValueKind.STRING:
|
|
30
|
+
writer.uint32(850)
|
|
31
|
+
writer.string(message.toString())
|
|
32
|
+
break
|
|
33
|
+
|
|
34
|
+
case ethereum.ValueKind.FIXED_ARRAY:
|
|
35
|
+
case ethereum.ValueKind.ARRAY:
|
|
36
|
+
case ethereum.ValueKind.TUPLE:
|
|
37
|
+
const arrayData = changetype<Array<ethereum.Value>>(message.data as u32)
|
|
38
|
+
if (arrayData !== null) {
|
|
39
|
+
writer.uint32(866)
|
|
40
|
+
writer.fork()
|
|
41
|
+
ValuesPb.encode(arrayData, writer)
|
|
42
|
+
writer.ldelim()
|
|
43
|
+
}
|
|
44
|
+
break
|
|
45
|
+
|
|
46
|
+
default:
|
|
47
|
+
throw new Error('Encoding unsupported ethereum value kind')
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function decode(reader: Reader, length: i32): ethereum.Value {
|
|
52
|
+
const end: usize = length < 0 ? reader.end : reader.ptr + length
|
|
53
|
+
let kind: ethereum.ValueKind = 0
|
|
54
|
+
let bytesData: Uint8Array = new Uint8Array(0)
|
|
55
|
+
let boolData: bool = false
|
|
56
|
+
let stringData: string = ''
|
|
57
|
+
let arrayData: ethereum.Value[] | null = null
|
|
58
|
+
|
|
59
|
+
while (reader.ptr < end) {
|
|
60
|
+
const tag = reader.uint32()
|
|
61
|
+
switch (tag >>> 3) {
|
|
62
|
+
case 1:
|
|
63
|
+
kind = reader.int32()
|
|
64
|
+
break
|
|
65
|
+
|
|
66
|
+
case 102:
|
|
67
|
+
bytesData = reader.bytes()
|
|
68
|
+
break
|
|
69
|
+
|
|
70
|
+
case 105:
|
|
71
|
+
boolData = reader.bool()
|
|
72
|
+
break
|
|
73
|
+
|
|
74
|
+
case 106:
|
|
75
|
+
stringData = reader.string()
|
|
76
|
+
break
|
|
77
|
+
|
|
78
|
+
case 108:
|
|
79
|
+
arrayData = ValuesPb.decode(reader, reader.uint32())
|
|
80
|
+
break
|
|
81
|
+
|
|
82
|
+
default:
|
|
83
|
+
reader.skipType(tag & 7)
|
|
84
|
+
break
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
switch (kind) {
|
|
89
|
+
case ethereum.ValueKind.ADDRESS:
|
|
90
|
+
return ethereum.Value.fromAddress(changetype<Address>(bytesData))
|
|
91
|
+
case ethereum.ValueKind.FIXED_BYTES:
|
|
92
|
+
return ethereum.Value.fromFixedBytes(changetype<Bytes>(bytesData))
|
|
93
|
+
case ethereum.ValueKind.BYTES:
|
|
94
|
+
return ethereum.Value.fromBytes(changetype<Bytes>(bytesData))
|
|
95
|
+
case ethereum.ValueKind.INT:
|
|
96
|
+
return ethereum.Value.fromSignedBigInt(changetype<BigInt>(bytesData))
|
|
97
|
+
case ethereum.ValueKind.UINT:
|
|
98
|
+
return ethereum.Value.fromUnsignedBigInt(changetype<BigInt>(bytesData))
|
|
99
|
+
case ethereum.ValueKind.BOOL:
|
|
100
|
+
return ethereum.Value.fromBoolean(boolData == 1)
|
|
101
|
+
case ethereum.ValueKind.STRING:
|
|
102
|
+
return ethereum.Value.fromString(stringData)
|
|
103
|
+
case ethereum.ValueKind.FIXED_ARRAY:
|
|
104
|
+
return ethereum.Value.fromFixedSizedArray(arrayData!)
|
|
105
|
+
case ethereum.ValueKind.ARRAY:
|
|
106
|
+
return ethereum.Value.fromArray(arrayData!)
|
|
107
|
+
case ethereum.ValueKind.TUPLE:
|
|
108
|
+
return ethereum.Value.fromTuple(changetype<ethereum.Tuple>(arrayData!))
|
|
109
|
+
default:
|
|
110
|
+
throw new Error(`Unsupported kind ${kind}`)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Code is NOT generated
|
|
2
|
+
// but the generated code from proto folder was used as reference
|
|
3
|
+
// it is done this way to directly encode/decode into graph-ts types
|
|
4
|
+
|
|
5
|
+
import { Writer, Reader } from 'as-proto/assembly'
|
|
6
|
+
import { ValuePb } from './ValuePb'
|
|
7
|
+
import { ethereum } from '@graphprotocol/graph-ts/'
|
|
8
|
+
|
|
9
|
+
export namespace ValuesPb {
|
|
10
|
+
export function encode(message: Array<ethereum.Value>, writer: Writer): void {
|
|
11
|
+
const values = message
|
|
12
|
+
for (let i: i32 = 0; i < values.length; ++i) {
|
|
13
|
+
writer.uint32(10)
|
|
14
|
+
writer.fork()
|
|
15
|
+
ValuePb.encode(values[i], writer)
|
|
16
|
+
writer.ldelim()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function decode(reader: Reader, length: i32): Array<ethereum.Value> {
|
|
21
|
+
const end: usize = length < 0 ? reader.end : reader.ptr + length
|
|
22
|
+
const message = new Array<ethereum.Value>()
|
|
23
|
+
|
|
24
|
+
while (reader.ptr < end) {
|
|
25
|
+
const tag = reader.uint32()
|
|
26
|
+
switch (tag >>> 3) {
|
|
27
|
+
case 1:
|
|
28
|
+
message.push(ValuePb.decode(reader, reader.uint32()))
|
|
29
|
+
break
|
|
30
|
+
|
|
31
|
+
default:
|
|
32
|
+
reader.skipType(tag & 7)
|
|
33
|
+
break
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return message
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ethereum as ethereumBase,
|
|
3
|
+
Address,
|
|
4
|
+
BigInt,
|
|
5
|
+
Bytes
|
|
6
|
+
} from '@graphprotocol/graph-ts/'
|
|
7
|
+
import { SmartContractCallPb } from './SmartContractCallPb'
|
|
8
|
+
import { ValuesPb } from './ValuesPb'
|
|
9
|
+
import { ValuePb } from './ValuePb'
|
|
10
|
+
import {
|
|
11
|
+
findUint8ArrayOrNull,
|
|
12
|
+
storeString,
|
|
13
|
+
storeUint8Array,
|
|
14
|
+
storeProtobuf,
|
|
15
|
+
findProtobuOrNull
|
|
16
|
+
} from '../../../utils/pdk'
|
|
17
|
+
|
|
18
|
+
/** Host Ethereum interface */
|
|
19
|
+
export declare namespace ethereum {
|
|
20
|
+
function hostCall(call: u64): u64
|
|
21
|
+
function hostGetBalance(address: u64): u64
|
|
22
|
+
function hostEncode(token: u64): u64
|
|
23
|
+
function hostDecode(types: u64, data: u64): u64
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export namespace ethereum {
|
|
27
|
+
export function call(
|
|
28
|
+
call: ethereumBase.SmartContractCall
|
|
29
|
+
): Array<ethereumBase.Value> | null {
|
|
30
|
+
const callMem = storeProtobuf(call, SmartContractCallPb.encode)
|
|
31
|
+
const resultOffset = ethereum.hostCall(callMem.offset)
|
|
32
|
+
callMem.free()
|
|
33
|
+
return findProtobuOrNull<Array<ethereumBase.Value>>(
|
|
34
|
+
resultOffset,
|
|
35
|
+
ValuesPb.decode
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function getBalance(address: Address): BigInt {
|
|
40
|
+
const addressMem = storeUint8Array(address)
|
|
41
|
+
const resultOffset = ethereum.hostGetBalance(addressMem.offset)
|
|
42
|
+
addressMem.free()
|
|
43
|
+
const result = findUint8ArrayOrNull(resultOffset)
|
|
44
|
+
|
|
45
|
+
if (result == null) {
|
|
46
|
+
return BigInt.zero()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return changetype<BigInt>(result)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function encode(token: ethereumBase.Value): Bytes | null {
|
|
53
|
+
const tokenMem = storeProtobuf(token, ValuePb.encode)
|
|
54
|
+
const resultOffset = ethereum.hostEncode(tokenMem.offset)
|
|
55
|
+
tokenMem.free()
|
|
56
|
+
const resultMsg = findUint8ArrayOrNull(resultOffset)
|
|
57
|
+
|
|
58
|
+
if (resultMsg == null) {
|
|
59
|
+
return null
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return changetype<Bytes>(resultMsg)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function decode(
|
|
66
|
+
types: string,
|
|
67
|
+
data: Bytes
|
|
68
|
+
): ethereumBase.Value | null {
|
|
69
|
+
const typesMem = storeString(types)
|
|
70
|
+
const dataMem = storeUint8Array(data)
|
|
71
|
+
const resultOffset = ethereum.hostDecode(typesMem.offset, dataMem.offset)
|
|
72
|
+
typesMem.free()
|
|
73
|
+
dataMem.free()
|
|
74
|
+
return findProtobuOrNull<ethereumBase.Value>(resultOffset, ValuePb.decode)
|
|
75
|
+
}
|
|
76
|
+
}
|
package/API/v1/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './activePositions/activePositions'
|
|
2
|
+
export * from './activePositions/ActivePositionsResult'
|
|
3
|
+
export * from './store/store'
|
|
4
|
+
export * from './log/log'
|
|
5
|
+
export * from './ethereum/ethereum'
|
|
6
|
+
export * from './bigInt/bigInt'
|
|
7
|
+
export * from './bigDecimal/bigDecimal'
|
|
8
|
+
export * from './typeConversion/typeConversion'
|
|
9
|
+
export * from './crypto/crypto'
|
|
10
|
+
export * from './watcher/watcher'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LogLevel } from '@extism/as-pdk'
|
|
2
|
+
import { safeLog } from '../../../utils/pdk'
|
|
3
|
+
|
|
4
|
+
// Host interface for logging
|
|
5
|
+
export namespace log {
|
|
6
|
+
const levelsMap = [
|
|
7
|
+
LogLevel.Error,
|
|
8
|
+
LogLevel.Error,
|
|
9
|
+
LogLevel.Warn,
|
|
10
|
+
LogLevel.Info,
|
|
11
|
+
LogLevel.Debug
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
// Host export for logging, providing basic logging functionality
|
|
15
|
+
export function log(level: u32, msg: string): void {
|
|
16
|
+
safeLog(levelsMap[level], msg)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Code generated by protoc-gen-as. DO NOT EDIT.
|
|
2
|
+
// Versions:
|
|
3
|
+
// protoc-gen-as v1.3.0
|
|
4
|
+
// protoc v3.21.12
|
|
5
|
+
|
|
6
|
+
import { Writer, Reader, Protobuf } from 'as-proto/assembly'
|
|
7
|
+
import { TokenBalancePb } from './TokenBalancePb'
|
|
8
|
+
import { Timestamp } from '../google/protobuf/Timestamp'
|
|
9
|
+
|
|
10
|
+
export class ActivePositionsResultPb {
|
|
11
|
+
static encode(message: ActivePositionsResultPb, writer: Writer): void {
|
|
12
|
+
const supplyTokens = message.supplyTokens
|
|
13
|
+
for (let i: i32 = 0; i < supplyTokens.length; ++i) {
|
|
14
|
+
writer.uint32(10)
|
|
15
|
+
writer.fork()
|
|
16
|
+
TokenBalancePb.encode(supplyTokens[i], writer)
|
|
17
|
+
writer.ldelim()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const borrowTokens = message.borrowTokens
|
|
21
|
+
for (let i: i32 = 0; i < borrowTokens.length; ++i) {
|
|
22
|
+
writer.uint32(18)
|
|
23
|
+
writer.fork()
|
|
24
|
+
TokenBalancePb.encode(borrowTokens[i], writer)
|
|
25
|
+
writer.ldelim()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const rewardTokens = message.rewardTokens
|
|
29
|
+
for (let i: i32 = 0; i < rewardTokens.length; ++i) {
|
|
30
|
+
writer.uint32(26)
|
|
31
|
+
writer.fork()
|
|
32
|
+
TokenBalancePb.encode(rewardTokens[i], writer)
|
|
33
|
+
writer.ldelim()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const positionToken = message.positionToken
|
|
37
|
+
if (positionToken !== null) {
|
|
38
|
+
writer.uint32(34)
|
|
39
|
+
writer.fork()
|
|
40
|
+
TokenBalancePb.encode(positionToken, writer)
|
|
41
|
+
writer.ldelim()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const unlockTimestamp = message.unlockTimestamp
|
|
45
|
+
if (unlockTimestamp !== null) {
|
|
46
|
+
writer.uint32(42)
|
|
47
|
+
writer.fork()
|
|
48
|
+
Timestamp.encode(unlockTimestamp, writer)
|
|
49
|
+
writer.ldelim()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
writer.uint32(50)
|
|
53
|
+
writer.bytes(message.poolAddressBytes)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static decode(reader: Reader, length: i32): ActivePositionsResultPb {
|
|
57
|
+
const end: usize = length < 0 ? reader.end : reader.ptr + length
|
|
58
|
+
const message = new ActivePositionsResultPb()
|
|
59
|
+
|
|
60
|
+
while (reader.ptr < end) {
|
|
61
|
+
const tag = reader.uint32()
|
|
62
|
+
switch (tag >>> 3) {
|
|
63
|
+
case 1:
|
|
64
|
+
message.supplyTokens.push(
|
|
65
|
+
TokenBalancePb.decode(reader, reader.uint32())
|
|
66
|
+
)
|
|
67
|
+
break
|
|
68
|
+
|
|
69
|
+
case 2:
|
|
70
|
+
message.borrowTokens.push(
|
|
71
|
+
TokenBalancePb.decode(reader, reader.uint32())
|
|
72
|
+
)
|
|
73
|
+
break
|
|
74
|
+
|
|
75
|
+
case 3:
|
|
76
|
+
message.rewardTokens.push(
|
|
77
|
+
TokenBalancePb.decode(reader, reader.uint32())
|
|
78
|
+
)
|
|
79
|
+
break
|
|
80
|
+
|
|
81
|
+
case 4:
|
|
82
|
+
message.positionToken = TokenBalancePb.decode(reader, reader.uint32())
|
|
83
|
+
break
|
|
84
|
+
|
|
85
|
+
case 5:
|
|
86
|
+
message.unlockTimestamp = Timestamp.decode(reader, reader.uint32())
|
|
87
|
+
break
|
|
88
|
+
|
|
89
|
+
case 6:
|
|
90
|
+
message.poolAddressBytes = reader.bytes()
|
|
91
|
+
break
|
|
92
|
+
|
|
93
|
+
default:
|
|
94
|
+
reader.skipType(tag & 7)
|
|
95
|
+
break
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return message
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
supplyTokens: Array<TokenBalancePb>
|
|
103
|
+
borrowTokens: Array<TokenBalancePb>
|
|
104
|
+
rewardTokens: Array<TokenBalancePb>
|
|
105
|
+
positionToken: TokenBalancePb | null
|
|
106
|
+
unlockTimestamp: Timestamp | null
|
|
107
|
+
poolAddressBytes: Uint8Array
|
|
108
|
+
|
|
109
|
+
constructor(
|
|
110
|
+
supplyTokens: Array<TokenBalancePb> = [],
|
|
111
|
+
borrowTokens: Array<TokenBalancePb> = [],
|
|
112
|
+
rewardTokens: Array<TokenBalancePb> = [],
|
|
113
|
+
positionToken: TokenBalancePb | null = null,
|
|
114
|
+
unlockTimestamp: Timestamp | null = null,
|
|
115
|
+
poolAddressBytes: Uint8Array = new Uint8Array(0)
|
|
116
|
+
) {
|
|
117
|
+
this.supplyTokens = supplyTokens
|
|
118
|
+
this.borrowTokens = borrowTokens
|
|
119
|
+
this.rewardTokens = rewardTokens
|
|
120
|
+
this.positionToken = positionToken
|
|
121
|
+
this.unlockTimestamp = unlockTimestamp
|
|
122
|
+
this.poolAddressBytes = poolAddressBytes
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function encodeActivePositionsResultPb(
|
|
127
|
+
message: ActivePositionsResultPb
|
|
128
|
+
): Uint8Array {
|
|
129
|
+
return Protobuf.encode(message, ActivePositionsResultPb.encode)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function decodeActivePositionsResultPb(
|
|
133
|
+
buffer: Uint8Array
|
|
134
|
+
): ActivePositionsResultPb {
|
|
135
|
+
return Protobuf.decode<ActivePositionsResultPb>(
|
|
136
|
+
buffer,
|
|
137
|
+
ActivePositionsResultPb.decode
|
|
138
|
+
)
|
|
139
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Code generated by protoc-gen-as. DO NOT EDIT.
|
|
2
|
+
// Versions:
|
|
3
|
+
// protoc-gen-as v1.3.0
|
|
4
|
+
// protoc v3.21.12
|
|
5
|
+
|
|
6
|
+
import { Writer, Reader, Protobuf } from 'as-proto/assembly'
|
|
7
|
+
|
|
8
|
+
export class TokenBalancePb {
|
|
9
|
+
static encode(message: TokenBalancePb, writer: Writer): void {
|
|
10
|
+
writer.uint32(10)
|
|
11
|
+
writer.bytes(message.tokenAddressBytes)
|
|
12
|
+
|
|
13
|
+
writer.uint32(18)
|
|
14
|
+
writer.bytes(message.tokenIdBytes)
|
|
15
|
+
|
|
16
|
+
writer.uint32(26)
|
|
17
|
+
writer.bytes(message.balanceBytes)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static decode(reader: Reader, length: i32): TokenBalancePb {
|
|
21
|
+
const end: usize = length < 0 ? reader.end : reader.ptr + length
|
|
22
|
+
const message = new TokenBalancePb()
|
|
23
|
+
|
|
24
|
+
while (reader.ptr < end) {
|
|
25
|
+
const tag = reader.uint32()
|
|
26
|
+
switch (tag >>> 3) {
|
|
27
|
+
case 1:
|
|
28
|
+
message.tokenAddressBytes = reader.bytes()
|
|
29
|
+
break
|
|
30
|
+
|
|
31
|
+
case 2:
|
|
32
|
+
message.tokenIdBytes = reader.bytes()
|
|
33
|
+
break
|
|
34
|
+
|
|
35
|
+
case 3:
|
|
36
|
+
message.balanceBytes = reader.bytes()
|
|
37
|
+
break
|
|
38
|
+
|
|
39
|
+
default:
|
|
40
|
+
reader.skipType(tag & 7)
|
|
41
|
+
break
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return message
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
tokenAddressBytes: Uint8Array
|
|
49
|
+
tokenIdBytes: Uint8Array
|
|
50
|
+
balanceBytes: Uint8Array
|
|
51
|
+
|
|
52
|
+
constructor(
|
|
53
|
+
tokenAddressBytes: Uint8Array = new Uint8Array(0),
|
|
54
|
+
tokenIdBytes: Uint8Array = new Uint8Array(0),
|
|
55
|
+
balanceBytes: Uint8Array = new Uint8Array(0)
|
|
56
|
+
) {
|
|
57
|
+
this.tokenAddressBytes = tokenAddressBytes
|
|
58
|
+
this.tokenIdBytes = tokenIdBytes
|
|
59
|
+
this.balanceBytes = balanceBytes
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function encodeTokenBalancePb(message: TokenBalancePb): Uint8Array {
|
|
64
|
+
return Protobuf.encode(message, TokenBalancePb.encode)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function decodeTokenBalancePb(buffer: Uint8Array): TokenBalancePb {
|
|
68
|
+
return Protobuf.decode<TokenBalancePb>(buffer, TokenBalancePb.decode)
|
|
69
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Code generated by protoc-gen-as. DO NOT EDIT.
|
|
2
|
+
// Versions:
|
|
3
|
+
// protoc-gen-as v1.3.0
|
|
4
|
+
// protoc v3.21.12
|
|
5
|
+
|
|
6
|
+
import { Writer, Reader, Protobuf } from 'as-proto/assembly'
|
|
7
|
+
|
|
8
|
+
export class BigDecimalPb {
|
|
9
|
+
static encode(message: BigDecimalPb, writer: Writer): void {
|
|
10
|
+
writer.uint32(10)
|
|
11
|
+
writer.bytes(message.digits)
|
|
12
|
+
|
|
13
|
+
writer.uint32(16)
|
|
14
|
+
writer.int32(message.exp)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static decode(reader: Reader, length: i32): BigDecimalPb {
|
|
18
|
+
const end: usize = length < 0 ? reader.end : reader.ptr + length
|
|
19
|
+
const message = new BigDecimalPb()
|
|
20
|
+
|
|
21
|
+
while (reader.ptr < end) {
|
|
22
|
+
const tag = reader.uint32()
|
|
23
|
+
switch (tag >>> 3) {
|
|
24
|
+
case 1:
|
|
25
|
+
message.digits = reader.bytes()
|
|
26
|
+
break
|
|
27
|
+
|
|
28
|
+
case 2:
|
|
29
|
+
message.exp = reader.int32()
|
|
30
|
+
break
|
|
31
|
+
|
|
32
|
+
default:
|
|
33
|
+
reader.skipType(tag & 7)
|
|
34
|
+
break
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return message
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
digits: Uint8Array
|
|
42
|
+
exp: i32
|
|
43
|
+
|
|
44
|
+
constructor(digits: Uint8Array = new Uint8Array(0), exp: i32 = 0) {
|
|
45
|
+
this.digits = digits
|
|
46
|
+
this.exp = exp
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function encodeBigDecimalPb(message: BigDecimalPb): Uint8Array {
|
|
51
|
+
return Protobuf.encode(message, BigDecimalPb.encode)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function decodeBigDecimalPb(buffer: Uint8Array): BigDecimalPb {
|
|
55
|
+
return Protobuf.decode<BigDecimalPb>(buffer, BigDecimalPb.decode)
|
|
56
|
+
}
|