@sentio/sdk 2.60.0-rc.15 → 2.60.0-rc.17
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.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"handler-register.d.ts","sourceRoot":"","sources":["../../src/core/handler-register.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE9C,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,aAAa,CAAC,CAAA;
|
1
|
+
{"version":3,"file":"handler-register.d.ts","sourceRoot":"","sources":["../../src/core/handler-register.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE9C,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,aAAa,CAAC,CAAA;AAqCxE,qBAAa,eAAe;IAC1B,OAAO,CAAC,cAAc,CAAyC;IAC/D,OAAO,CAAC,QAAQ,CAAuC;IAEvD;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM;IAmBrE;;OAEG;IACH,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe;IAQ3C,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI;CAiB/B"}
|
@@ -2,8 +2,24 @@ import { ServerError, Status } from 'nice-grpc';
|
|
2
2
|
import { ChainId } from '@sentio/chain';
|
3
3
|
const chainToNumber = new Map();
|
4
4
|
const numberToChain = new Map();
|
5
|
+
const generateHash = (s) => {
|
6
|
+
let hash = 0;
|
7
|
+
for (const char of s) {
|
8
|
+
hash = (hash << 5) - hash + char.charCodeAt(0);
|
9
|
+
hash |= 0; // Constrain to 32bit integer
|
10
|
+
}
|
11
|
+
return Math.abs(hash);
|
12
|
+
};
|
5
13
|
for (const chainId of Object.values(ChainId)) {
|
6
|
-
|
14
|
+
let num = parseInt(chainId);
|
15
|
+
if (isNaN(num)) {
|
16
|
+
// If the chainId is not a number, generate a hash
|
17
|
+
num = generateHash(chainId);
|
18
|
+
}
|
19
|
+
if (numberToChain.has(num)) {
|
20
|
+
// If the number is already used for another chain, throw an error, this should not happen
|
21
|
+
throw new Error(`Chain ID ${chainId}'s number ${num} conflicts with existing chain ID ${numberToChain.get(num)}`);
|
22
|
+
}
|
7
23
|
chainToNumber.set(chainId, num);
|
8
24
|
numberToChain.set(num, chainId);
|
9
25
|
}
|
@@ -19,7 +35,7 @@ export class HandlerRegister {
|
|
19
35
|
const chainNum = chainToNumber.get(chainId) || 0;
|
20
36
|
const entries = this.handlerByChain.get(chainNum) || [];
|
21
37
|
const len = entries.length;
|
22
|
-
const id = chainNum * MAX_HANDLER_PER_CHAIN + len + 1;
|
38
|
+
const id = chainNum * MAX_HANDLER_PER_CHAIN + len + 1;
|
23
39
|
const entry = {
|
24
40
|
id,
|
25
41
|
handler,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"handler-register.js","sourceRoot":"","sources":["../../src/core/handler-register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAWvC,MAAM,aAAa,GAAwB,IAAI,GAAG,EAAE,CAAA;AACpD,MAAM,aAAa,GAAwB,IAAI,GAAG,EAAE,CAAA;AAEpD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAC7C,
|
1
|
+
{"version":3,"file":"handler-register.js","sourceRoot":"","sources":["../../src/core/handler-register.ts"],"names":[],"mappings":"AA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AAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;gBACvD,IAAI,aAAa,EAAE,CAAC;oBAClB,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;wBAClC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;oBAChC,CAAC;gBACH,CAAC;gBACD,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YACtC,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAA;YAC3B,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;QACvB,CAAC;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/sdk",
|
3
|
-
"version": "2.60.0-rc.
|
3
|
+
"version": "2.60.0-rc.17",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -66,7 +66,7 @@
|
|
66
66
|
"@sentio/abi-wan-kanabi": "2.2.2-1",
|
67
67
|
"@sentio/api": "1.0.2",
|
68
68
|
"@sentio/bigdecimal": "9.1.1-patch.3",
|
69
|
-
"@sentio/chain": "~3.
|
69
|
+
"@sentio/chain": "~3.3.0",
|
70
70
|
"@sentio/ethers-v6": "^1.0.29",
|
71
71
|
"@solana/web3.js": "1.98.2",
|
72
72
|
"@typemove/aptos": "~1.10.0",
|
@@ -97,8 +97,8 @@
|
|
97
97
|
"typechain": "^8.3.2",
|
98
98
|
"utility-types": "^3.11.0",
|
99
99
|
"yaml": "^2.3.4",
|
100
|
-
"@sentio/protos": "2.60.0-rc.
|
101
|
-
"@sentio/runtime": "^2.60.0-rc.
|
100
|
+
"@sentio/protos": "2.60.0-rc.17",
|
101
|
+
"@sentio/runtime": "^2.60.0-rc.17"
|
102
102
|
},
|
103
103
|
"peerDependencies": {
|
104
104
|
"@sentio/tsup": "^8.3.5-rc.1"
|
@@ -13,8 +13,26 @@ interface HandlerEntry {
|
|
13
13
|
const chainToNumber: Map<string, number> = new Map()
|
14
14
|
const numberToChain: Map<number, string> = new Map()
|
15
15
|
|
16
|
+
const generateHash = (s: string) => {
|
17
|
+
let hash = 0
|
18
|
+
for (const char of s) {
|
19
|
+
hash = (hash << 5) - hash + char.charCodeAt(0)
|
20
|
+
hash |= 0 // Constrain to 32bit integer
|
21
|
+
}
|
22
|
+
return Math.abs(hash)
|
23
|
+
}
|
24
|
+
|
16
25
|
for (const chainId of Object.values(ChainId)) {
|
17
|
-
|
26
|
+
let num = parseInt(chainId)
|
27
|
+
if (isNaN(num)) {
|
28
|
+
// If the chainId is not a number, generate a hash
|
29
|
+
num = generateHash(chainId)
|
30
|
+
}
|
31
|
+
|
32
|
+
if (numberToChain.has(num)) {
|
33
|
+
// If the number is already used for another chain, throw an error, this should not happen
|
34
|
+
throw new Error(`Chain ID ${chainId}'s number ${num} conflicts with existing chain ID ${numberToChain.get(num)}`)
|
35
|
+
}
|
18
36
|
chainToNumber.set(chainId, num)
|
19
37
|
numberToChain.set(num, chainId)
|
20
38
|
}
|
@@ -34,7 +52,7 @@ export class HandlerRegister {
|
|
34
52
|
const entries = this.handlerByChain.get(chainNum) || []
|
35
53
|
|
36
54
|
const len = entries.length
|
37
|
-
const id = chainNum * MAX_HANDLER_PER_CHAIN + len + 1
|
55
|
+
const id = chainNum * MAX_HANDLER_PER_CHAIN + len + 1
|
38
56
|
|
39
57
|
const entry: HandlerEntry = {
|
40
58
|
id,
|