datai-sdk 1.0.1 → 1.0.3
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/chain/ethereum.ts +1 -1
- package/@graphprotocol/graph-ts/common/conversion.ts +1 -1
- package/@graphprotocol/graph-ts/common/numbers.ts +1 -1
- package/@graphprotocol/graph-ts/index.ts +2 -2
- package/API/v1/proto/activePositions/ActivePositionsResultPb.ts +62 -65
- package/API/v1/proto/activePositions/TokenBalancePb.ts +27 -27
- package/API/v1/proto/bigDecimal/BigDecimalPb.ts +21 -21
- package/API/v1/proto/ethereum/SmartContractCallPb.ts +46 -46
- package/API/v1/proto/ethereum/ValueKindPb.ts +1 -1
- package/API/v1/proto/ethereum/ValuePb.ts +45 -45
- package/API/v1/proto/ethereum/ValuesPb.ts +19 -19
- package/API/v1/proto/google/protobuf/Any.ts +22 -22
- package/API/v1/proto/google/protobuf/Timestamp.ts +21 -21
- package/API/v1/proto/store/EntitiesPb.ts +19 -19
- package/API/v1/proto/store/EntityPb.ts +41 -41
- package/API/v1/proto/store/EntityWithMetaPb.ts +32 -32
- package/API/v1/proto/store/ValueKindPb.ts +1 -1
- package/API/v1/proto/store/ValuePb.ts +67 -67
- package/API/v1/proto/store/ValuesPb.ts +19 -19
- package/API/v1/proto/watcher/WatcherResultPb.ts +26 -26
- package/README.md +11 -0
- package/index.ts +5 -5
- package/package.json +5 -3
- package/postinstall-script.js +34 -0
- package/utils/subgraphUtils.ts +2 -0
|
@@ -3,108 +3,108 @@
|
|
|
3
3
|
// protoc-gen-as v1.3.0
|
|
4
4
|
// protoc v3.21.12
|
|
5
5
|
|
|
6
|
-
import { Writer, Reader, Protobuf } from
|
|
7
|
-
import { BigDecimalPb } from
|
|
8
|
-
import { ValuesPb } from
|
|
9
|
-
import { ValueKindPb } from
|
|
6
|
+
import { Writer, Reader, Protobuf } from 'as-proto/assembly'
|
|
7
|
+
import { BigDecimalPb } from '../bigDecimal/BigDecimalPb'
|
|
8
|
+
import { ValuesPb } from './ValuesPb'
|
|
9
|
+
import { ValueKindPb } from './ValueKindPb'
|
|
10
10
|
|
|
11
11
|
export class ValuePb {
|
|
12
12
|
static encode(message: ValuePb, writer: Writer): void {
|
|
13
|
-
writer.uint32(8)
|
|
14
|
-
writer.int32(message.kind)
|
|
13
|
+
writer.uint32(8)
|
|
14
|
+
writer.int32(message.kind)
|
|
15
15
|
|
|
16
|
-
writer.uint32(802)
|
|
17
|
-
writer.string(message.stringData)
|
|
16
|
+
writer.uint32(802)
|
|
17
|
+
writer.string(message.stringData)
|
|
18
18
|
|
|
19
|
-
writer.uint32(808)
|
|
20
|
-
writer.int32(message.intData)
|
|
19
|
+
writer.uint32(808)
|
|
20
|
+
writer.int32(message.intData)
|
|
21
21
|
|
|
22
|
-
const bigdecimalData = message.bigdecimalData
|
|
22
|
+
const bigdecimalData = message.bigdecimalData
|
|
23
23
|
if (bigdecimalData !== null) {
|
|
24
|
-
writer.uint32(818)
|
|
25
|
-
writer.fork()
|
|
26
|
-
BigDecimalPb.encode(bigdecimalData, writer)
|
|
27
|
-
writer.ldelim()
|
|
24
|
+
writer.uint32(818)
|
|
25
|
+
writer.fork()
|
|
26
|
+
BigDecimalPb.encode(bigdecimalData, writer)
|
|
27
|
+
writer.ldelim()
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
writer.uint32(824)
|
|
31
|
-
writer.bool(message.boolData)
|
|
30
|
+
writer.uint32(824)
|
|
31
|
+
writer.bool(message.boolData)
|
|
32
32
|
|
|
33
|
-
const arrayData = message.arrayData
|
|
33
|
+
const arrayData = message.arrayData
|
|
34
34
|
if (arrayData !== null) {
|
|
35
|
-
writer.uint32(834)
|
|
36
|
-
writer.fork()
|
|
37
|
-
ValuesPb.encode(arrayData, writer)
|
|
38
|
-
writer.ldelim()
|
|
35
|
+
writer.uint32(834)
|
|
36
|
+
writer.fork()
|
|
37
|
+
ValuesPb.encode(arrayData, writer)
|
|
38
|
+
writer.ldelim()
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
writer.uint32(850)
|
|
42
|
-
writer.bytes(message.bytesData)
|
|
41
|
+
writer.uint32(850)
|
|
42
|
+
writer.bytes(message.bytesData)
|
|
43
43
|
|
|
44
|
-
writer.uint32(864)
|
|
45
|
-
writer.int64(message.int8Data)
|
|
44
|
+
writer.uint32(864)
|
|
45
|
+
writer.int64(message.int8Data)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
static decode(reader: Reader, length: i32): ValuePb {
|
|
49
|
-
const end: usize = length < 0 ? reader.end : reader.ptr + length
|
|
50
|
-
const message = new ValuePb()
|
|
49
|
+
const end: usize = length < 0 ? reader.end : reader.ptr + length
|
|
50
|
+
const message = new ValuePb()
|
|
51
51
|
|
|
52
52
|
while (reader.ptr < end) {
|
|
53
|
-
const tag = reader.uint32()
|
|
53
|
+
const tag = reader.uint32()
|
|
54
54
|
switch (tag >>> 3) {
|
|
55
55
|
case 1:
|
|
56
|
-
message.kind = reader.int32()
|
|
57
|
-
break
|
|
56
|
+
message.kind = reader.int32()
|
|
57
|
+
break
|
|
58
58
|
|
|
59
59
|
case 100:
|
|
60
|
-
message.stringData = reader.string()
|
|
61
|
-
break
|
|
60
|
+
message.stringData = reader.string()
|
|
61
|
+
break
|
|
62
62
|
|
|
63
63
|
case 101:
|
|
64
|
-
message.intData = reader.int32()
|
|
65
|
-
break
|
|
64
|
+
message.intData = reader.int32()
|
|
65
|
+
break
|
|
66
66
|
|
|
67
67
|
case 102:
|
|
68
|
-
message.bigdecimalData = BigDecimalPb.decode(reader, reader.uint32())
|
|
69
|
-
break
|
|
68
|
+
message.bigdecimalData = BigDecimalPb.decode(reader, reader.uint32())
|
|
69
|
+
break
|
|
70
70
|
|
|
71
71
|
case 103:
|
|
72
|
-
message.boolData = reader.bool()
|
|
73
|
-
break
|
|
72
|
+
message.boolData = reader.bool()
|
|
73
|
+
break
|
|
74
74
|
|
|
75
75
|
case 104:
|
|
76
|
-
message.arrayData = ValuesPb.decode(reader, reader.uint32())
|
|
77
|
-
break
|
|
76
|
+
message.arrayData = ValuesPb.decode(reader, reader.uint32())
|
|
77
|
+
break
|
|
78
78
|
|
|
79
79
|
case 106:
|
|
80
|
-
message.bytesData = reader.bytes()
|
|
81
|
-
break
|
|
80
|
+
message.bytesData = reader.bytes()
|
|
81
|
+
break
|
|
82
82
|
|
|
83
83
|
case 108:
|
|
84
|
-
message.int8Data = reader.int64()
|
|
85
|
-
break
|
|
84
|
+
message.int8Data = reader.int64()
|
|
85
|
+
break
|
|
86
86
|
|
|
87
87
|
default:
|
|
88
|
-
reader.skipType(tag & 7)
|
|
89
|
-
break
|
|
88
|
+
reader.skipType(tag & 7)
|
|
89
|
+
break
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
return message
|
|
93
|
+
return message
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
kind: ValueKindPb
|
|
97
|
-
stringData: string
|
|
98
|
-
intData: i32
|
|
99
|
-
bigdecimalData: BigDecimalPb | null
|
|
100
|
-
boolData: bool
|
|
101
|
-
arrayData: ValuesPb | null
|
|
102
|
-
bytesData: Uint8Array
|
|
103
|
-
int8Data: i64
|
|
96
|
+
kind: ValueKindPb
|
|
97
|
+
stringData: string
|
|
98
|
+
intData: i32
|
|
99
|
+
bigdecimalData: BigDecimalPb | null
|
|
100
|
+
boolData: bool
|
|
101
|
+
arrayData: ValuesPb | null
|
|
102
|
+
bytesData: Uint8Array
|
|
103
|
+
int8Data: i64
|
|
104
104
|
|
|
105
105
|
constructor(
|
|
106
106
|
kind: ValueKindPb = 0,
|
|
107
|
-
stringData: string =
|
|
107
|
+
stringData: string = '',
|
|
108
108
|
intData: i32 = 0,
|
|
109
109
|
bigdecimalData: BigDecimalPb | null = null,
|
|
110
110
|
boolData: bool = false,
|
|
@@ -112,21 +112,21 @@ export class ValuePb {
|
|
|
112
112
|
bytesData: Uint8Array = new Uint8Array(0),
|
|
113
113
|
int8Data: i64 = 0
|
|
114
114
|
) {
|
|
115
|
-
this.kind = kind
|
|
116
|
-
this.stringData = stringData
|
|
117
|
-
this.intData = intData
|
|
118
|
-
this.bigdecimalData = bigdecimalData
|
|
119
|
-
this.boolData = boolData
|
|
120
|
-
this.arrayData = arrayData
|
|
121
|
-
this.bytesData = bytesData
|
|
122
|
-
this.int8Data = int8Data
|
|
115
|
+
this.kind = kind
|
|
116
|
+
this.stringData = stringData
|
|
117
|
+
this.intData = intData
|
|
118
|
+
this.bigdecimalData = bigdecimalData
|
|
119
|
+
this.boolData = boolData
|
|
120
|
+
this.arrayData = arrayData
|
|
121
|
+
this.bytesData = bytesData
|
|
122
|
+
this.int8Data = int8Data
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
export function encodeValuePb(message: ValuePb): Uint8Array {
|
|
127
|
-
return Protobuf.encode(message, ValuePb.encode)
|
|
127
|
+
return Protobuf.encode(message, ValuePb.encode)
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
export function decodeValuePb(buffer: Uint8Array): ValuePb {
|
|
131
|
-
return Protobuf.decode<ValuePb>(buffer, ValuePb.decode)
|
|
131
|
+
return Protobuf.decode<ValuePb>(buffer, ValuePb.decode)
|
|
132
132
|
}
|
|
@@ -3,51 +3,51 @@
|
|
|
3
3
|
// protoc-gen-as v1.3.0
|
|
4
4
|
// protoc v3.21.12
|
|
5
5
|
|
|
6
|
-
import { Writer, Reader, Protobuf } from
|
|
7
|
-
import { ValuePb } from
|
|
6
|
+
import { Writer, Reader, Protobuf } from 'as-proto/assembly'
|
|
7
|
+
import { ValuePb } from './ValuePb'
|
|
8
8
|
|
|
9
9
|
export class ValuesPb {
|
|
10
10
|
static encode(message: ValuesPb, writer: Writer): void {
|
|
11
|
-
const values = message.values
|
|
11
|
+
const values = message.values
|
|
12
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()
|
|
13
|
+
writer.uint32(10)
|
|
14
|
+
writer.fork()
|
|
15
|
+
ValuePb.encode(values[i], writer)
|
|
16
|
+
writer.ldelim()
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
static decode(reader: Reader, length: i32): ValuesPb {
|
|
21
|
-
const end: usize = length < 0 ? reader.end : reader.ptr + length
|
|
22
|
-
const message = new ValuesPb()
|
|
21
|
+
const end: usize = length < 0 ? reader.end : reader.ptr + length
|
|
22
|
+
const message = new ValuesPb()
|
|
23
23
|
|
|
24
24
|
while (reader.ptr < end) {
|
|
25
|
-
const tag = reader.uint32()
|
|
25
|
+
const tag = reader.uint32()
|
|
26
26
|
switch (tag >>> 3) {
|
|
27
27
|
case 1:
|
|
28
|
-
message.values.push(ValuePb.decode(reader, reader.uint32()))
|
|
29
|
-
break
|
|
28
|
+
message.values.push(ValuePb.decode(reader, reader.uint32()))
|
|
29
|
+
break
|
|
30
30
|
|
|
31
31
|
default:
|
|
32
|
-
reader.skipType(tag & 7)
|
|
33
|
-
break
|
|
32
|
+
reader.skipType(tag & 7)
|
|
33
|
+
break
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
return message
|
|
37
|
+
return message
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
values: Array<ValuePb
|
|
40
|
+
values: Array<ValuePb>
|
|
41
41
|
|
|
42
42
|
constructor(values: Array<ValuePb> = []) {
|
|
43
|
-
this.values = values
|
|
43
|
+
this.values = values
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export function encodeValuesPb(message: ValuesPb): Uint8Array {
|
|
48
|
-
return Protobuf.encode(message, ValuesPb.encode)
|
|
48
|
+
return Protobuf.encode(message, ValuesPb.encode)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export function decodeValuesPb(buffer: Uint8Array): ValuesPb {
|
|
52
|
-
return Protobuf.decode<ValuesPb>(buffer, ValuesPb.decode)
|
|
52
|
+
return Protobuf.decode<ValuesPb>(buffer, ValuesPb.decode)
|
|
53
53
|
}
|
|
@@ -3,60 +3,60 @@
|
|
|
3
3
|
// protoc-gen-as v1.3.0
|
|
4
4
|
// protoc v3.21.12
|
|
5
5
|
|
|
6
|
-
import { Writer, Reader, Protobuf } from
|
|
7
|
-
import { Any } from
|
|
6
|
+
import { Writer, Reader, Protobuf } from 'as-proto/assembly'
|
|
7
|
+
import { Any } from '../google/protobuf/Any'
|
|
8
8
|
|
|
9
9
|
export class WatcherResultPb {
|
|
10
10
|
static encode(message: WatcherResultPb, writer: Writer): void {
|
|
11
|
-
writer.uint32(10)
|
|
12
|
-
writer.string(message.updateTrigger)
|
|
11
|
+
writer.uint32(10)
|
|
12
|
+
writer.string(message.updateTrigger)
|
|
13
13
|
|
|
14
|
-
const payload = message.payload
|
|
14
|
+
const payload = message.payload
|
|
15
15
|
if (payload !== null) {
|
|
16
|
-
writer.uint32(18)
|
|
17
|
-
writer.fork()
|
|
18
|
-
Any.encode(payload, writer)
|
|
19
|
-
writer.ldelim()
|
|
16
|
+
writer.uint32(18)
|
|
17
|
+
writer.fork()
|
|
18
|
+
Any.encode(payload, writer)
|
|
19
|
+
writer.ldelim()
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
static decode(reader: Reader, length: i32): WatcherResultPb {
|
|
24
|
-
const end: usize = length < 0 ? reader.end : reader.ptr + length
|
|
25
|
-
const message = new WatcherResultPb()
|
|
24
|
+
const end: usize = length < 0 ? reader.end : reader.ptr + length
|
|
25
|
+
const message = new WatcherResultPb()
|
|
26
26
|
|
|
27
27
|
while (reader.ptr < end) {
|
|
28
|
-
const tag = reader.uint32()
|
|
28
|
+
const tag = reader.uint32()
|
|
29
29
|
switch (tag >>> 3) {
|
|
30
30
|
case 1:
|
|
31
|
-
message.updateTrigger = reader.string()
|
|
32
|
-
break
|
|
31
|
+
message.updateTrigger = reader.string()
|
|
32
|
+
break
|
|
33
33
|
|
|
34
34
|
case 2:
|
|
35
|
-
message.payload = Any.decode(reader, reader.uint32())
|
|
36
|
-
break
|
|
35
|
+
message.payload = Any.decode(reader, reader.uint32())
|
|
36
|
+
break
|
|
37
37
|
|
|
38
38
|
default:
|
|
39
|
-
reader.skipType(tag & 7)
|
|
40
|
-
break
|
|
39
|
+
reader.skipType(tag & 7)
|
|
40
|
+
break
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
return message
|
|
44
|
+
return message
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
updateTrigger: string
|
|
48
|
-
payload: Any | null
|
|
47
|
+
updateTrigger: string
|
|
48
|
+
payload: Any | null
|
|
49
49
|
|
|
50
|
-
constructor(updateTrigger: string =
|
|
51
|
-
this.updateTrigger = updateTrigger
|
|
52
|
-
this.payload = payload
|
|
50
|
+
constructor(updateTrigger: string = '', payload: Any | null = null) {
|
|
51
|
+
this.updateTrigger = updateTrigger
|
|
52
|
+
this.payload = payload
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export function encodeWatcherResultPb(message: WatcherResultPb): Uint8Array {
|
|
57
|
-
return Protobuf.encode(message, WatcherResultPb.encode)
|
|
57
|
+
return Protobuf.encode(message, WatcherResultPb.encode)
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export function decodeWatcherResultPb(buffer: Uint8Array): WatcherResultPb {
|
|
61
|
-
return Protobuf.decode<WatcherResultPb>(buffer, WatcherResultPb.decode)
|
|
61
|
+
return Protobuf.decode<WatcherResultPb>(buffer, WatcherResultPb.decode)
|
|
62
62
|
}
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Description
|
|
2
|
+
|
|
3
|
+
This is the datai-sdk npm package which contains libraries for utilities like constants, math utilities and scripts to compile or deploy subgraphs. This SDK is a tool to be used in a context of building a projection within the Datai Network.
|
|
4
|
+
|
|
5
|
+
# Utils
|
|
6
|
+
|
|
7
|
+
This contains many utility libraries which will help developers to build their projections smoothly. To put some example, it includes some math utils like square-root, power operations or transform bytes to address.
|
|
8
|
+
|
|
9
|
+
# API
|
|
10
|
+
|
|
11
|
+
It includes classes which are used to build a projection, being useful for both subgraph and watcher.
|
package/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from "./utils/constants";
|
|
2
|
+
export * from "./utils/mathUtils";
|
|
3
|
+
export * from "./utils/pdk";
|
|
4
|
+
export * from "./utils/subgraphUtils";
|
|
5
|
+
export * from "./API";
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "datai-sdk",
|
|
3
3
|
"main": "index.ts",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"description": "Datai SDK which has useful libraries to help building projections",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"postinstall": "node postinstall-script.js"
|
|
8
|
+
},
|
|
6
9
|
"dependencies": {
|
|
7
10
|
"@extism/as-pdk": "^1.0.0",
|
|
8
|
-
"as-proto": "^1.3.0"
|
|
9
|
-
"@graphprotocol/graph-ts": "^0.34.0"
|
|
11
|
+
"as-proto": "^1.3.0"
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
// Define the source and destination paths
|
|
5
|
+
const sourceFolder = path.resolve(__dirname, "@graphprotocol");
|
|
6
|
+
const destinationFolder = path.resolve(
|
|
7
|
+
__dirname,
|
|
8
|
+
"node_modules/@graphprotocol"
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
// Check if the source folder exists
|
|
12
|
+
if (!fs.existsSync(sourceFolder)) {
|
|
13
|
+
console.error(`Source folder "${sourceFolder}" does not exist.`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Create node_modules folder if it doesn't exist
|
|
18
|
+
const nodeModulesPath = path.resolve(__dirname, "node_modules");
|
|
19
|
+
if (!fs.existsSync(nodeModulesPath)) {
|
|
20
|
+
fs.mkdirSync(nodeModulesPath);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Check if the destination folder already exists
|
|
24
|
+
if (fs.existsSync(destinationFolder)) {
|
|
25
|
+
console.log(
|
|
26
|
+
`Destination folder "${destinationFolder}" already exists. Removing it...`
|
|
27
|
+
);
|
|
28
|
+
fs.rmSync(destinationFolder, { recursive: true, force: true });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Move the source folder to node_modules
|
|
32
|
+
fs.renameSync(sourceFolder, destinationFolder);
|
|
33
|
+
|
|
34
|
+
console.log(`Folder "${sourceFolder}" moved to "${destinationFolder}".`);
|
package/utils/subgraphUtils.ts
CHANGED
|
@@ -13,12 +13,14 @@ export function registerUser(userId: string): void {
|
|
|
13
13
|
|
|
14
14
|
export function ensureUpdateTrigger(
|
|
15
15
|
userPositionId: string,
|
|
16
|
+
user: string,
|
|
16
17
|
updateTriggerId: string = watcher.SCHEDULE_DEFAULT
|
|
17
18
|
): bool {
|
|
18
19
|
const updateTrigger = store.get('PositionUpdateTrigger', userPositionId)
|
|
19
20
|
if (updateTrigger == null) {
|
|
20
21
|
const updateTrigger = new Entity()
|
|
21
22
|
updateTrigger.setString('id', userPositionId)
|
|
23
|
+
updateTrigger.setString('user', user)
|
|
22
24
|
updateTrigger.setString('updateTrigger', updateTriggerId)
|
|
23
25
|
store.set('PositionUpdateTrigger', userPositionId, updateTrigger)
|
|
24
26
|
return false
|