@atomiqlabs/chain-starknet 7.0.8 → 7.0.10
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/dist/starknet/StarknetInitializer.js +1 -1
- package/dist/starknet/contract/modules/StarknetContractEvents.js +2 -2
- package/dist/utils/Utils.js +2 -7
- package/package.json +1 -1
- package/src/starknet/StarknetInitializer.ts +1 -1
- package/src/starknet/contract/modules/StarknetContractEvents.ts +2 -2
- package/src/utils/Utils.ts +1 -6
|
@@ -45,7 +45,7 @@ function initializeStarknet(options, bitcoinRpc, network) {
|
|
|
45
45
|
let wsChannel;
|
|
46
46
|
if (options.wsUrl != null)
|
|
47
47
|
wsChannel = typeof (options.wsUrl) === "string" ?
|
|
48
|
-
new starknet_1.WebSocketChannel({ nodeUrl: options.wsUrl
|
|
48
|
+
new starknet_1.WebSocketChannel({ nodeUrl: options.wsUrl }) :
|
|
49
49
|
options.wsUrl;
|
|
50
50
|
const Fees = options.fees ?? new StarknetFees_1.StarknetFees(provider);
|
|
51
51
|
const chainId = options.chainId ??
|
|
@@ -36,10 +36,10 @@ class StarknetContractEvents extends StarknetEvents_1.StarknetEvents {
|
|
|
36
36
|
filterArray.push(events.map(name => {
|
|
37
37
|
const arr = name.split(":");
|
|
38
38
|
const eventName = arr[arr.length - 1];
|
|
39
|
-
return (0, Utils_1.toHex)(starknet_1.hash.starknetKeccak(eventName));
|
|
39
|
+
return (0, Utils_1.toHex)(starknet_1.hash.starknetKeccak(eventName), 0);
|
|
40
40
|
}));
|
|
41
41
|
if (keys != null)
|
|
42
|
-
keys.forEach(key => filterArray.push(key == null ? [] : Array.isArray(key) ? key : [key]));
|
|
42
|
+
keys.forEach(key => filterArray.push(key == null ? [] : Array.isArray(key) ? key.map(k => (0, Utils_1.toHex)(k, 0)) : [(0, Utils_1.toHex)(key, 0)]));
|
|
43
43
|
return filterArray;
|
|
44
44
|
}
|
|
45
45
|
/**
|
package/dist/utils/Utils.js
CHANGED
|
@@ -76,14 +76,9 @@ exports.tryWithRetries = tryWithRetries;
|
|
|
76
76
|
function toHex(value, length = 64) {
|
|
77
77
|
if (value == null)
|
|
78
78
|
return null;
|
|
79
|
+
if (typeof (value) === "string")
|
|
80
|
+
value = BigInt(value);
|
|
79
81
|
switch (typeof (value)) {
|
|
80
|
-
case "string":
|
|
81
|
-
if (value.startsWith("0x")) {
|
|
82
|
-
return "0x" + value.slice(2).padStart(length, "0").toLowerCase();
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
return "0x" + BigInt(value).toString(16).padStart(length, "0");
|
|
86
|
-
}
|
|
87
82
|
case "number":
|
|
88
83
|
case "bigint":
|
|
89
84
|
return "0x" + value.toString(16).padStart(length, "0");
|
package/package.json
CHANGED
|
@@ -72,7 +72,7 @@ export function initializeStarknet(
|
|
|
72
72
|
options.rpcUrl;
|
|
73
73
|
let wsChannel: WebSocketChannel;
|
|
74
74
|
if(options.wsUrl!=null) wsChannel = typeof(options.wsUrl)==="string" ?
|
|
75
|
-
new WebSocketChannel({nodeUrl: options.wsUrl
|
|
75
|
+
new WebSocketChannel({nodeUrl: options.wsUrl}) :
|
|
76
76
|
options.wsUrl;
|
|
77
77
|
|
|
78
78
|
const Fees = options.fees ?? new StarknetFees(provider);
|
|
@@ -57,9 +57,9 @@ export class StarknetContractEvents<TAbi extends Abi> extends StarknetEvents {
|
|
|
57
57
|
filterArray.push(events.map(name => {
|
|
58
58
|
const arr = name.split(":");
|
|
59
59
|
const eventName = arr[arr.length-1];
|
|
60
|
-
return toHex(hash.starknetKeccak(eventName))
|
|
60
|
+
return toHex(hash.starknetKeccak(eventName), 0)
|
|
61
61
|
}));
|
|
62
|
-
if(keys!=null) keys.forEach(key => filterArray.push(key==null ? [] : Array.isArray(key) ? key : [key]));
|
|
62
|
+
if(keys!=null) keys.forEach(key => filterArray.push(key==null ? [] : Array.isArray(key) ? key.map(k => toHex(k, 0)) : [toHex(key, 0)]));
|
|
63
63
|
return filterArray;
|
|
64
64
|
}
|
|
65
65
|
|
package/src/utils/Utils.ts
CHANGED
|
@@ -87,13 +87,8 @@ export async function tryWithRetries<T>(func: () => Promise<T>, retryPolicy?: {
|
|
|
87
87
|
|
|
88
88
|
export function toHex(value: number | bigint | string | Buffer, length: number = 64): string {
|
|
89
89
|
if(value==null) return null;
|
|
90
|
+
if(typeof(value)==="string") value = BigInt(value);
|
|
90
91
|
switch(typeof(value)) {
|
|
91
|
-
case "string":
|
|
92
|
-
if(value.startsWith("0x")) {
|
|
93
|
-
return "0x"+value.slice(2).padStart(length, "0").toLowerCase();
|
|
94
|
-
} else {
|
|
95
|
-
return "0x"+BigInt(value).toString(16).padStart(length, "0");
|
|
96
|
-
}
|
|
97
92
|
case "number":
|
|
98
93
|
case "bigint":
|
|
99
94
|
return "0x"+value.toString(16).padStart(length, "0");
|