anymal-protocol 1.0.113 → 1.0.115

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.
@@ -0,0 +1,93 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/helpers/CryptoUtils.tsx
9
+ import { ec as EC } from "elliptic";
10
+ var ec = new EC("secp256k1");
11
+ var Network = /* @__PURE__ */ ((Network2) => {
12
+ Network2["Testnet"] = "testnet";
13
+ Network2["Localnet"] = "localnet";
14
+ return Network2;
15
+ })(Network || {});
16
+ var NETWORK_HOSTS = {
17
+ ["testnet" /* Testnet */]: "https://dev-db.petastic.com",
18
+ ["localnet" /* Localnet */]: "http://host.docker.internal:9181"
19
+ };
20
+ function loadExistingSecp256k1PrivateKey(hexKey) {
21
+ if (!hexKey) {
22
+ throw new Error("Private key hex must be provided");
23
+ }
24
+ return ec.keyFromPrivate(hexKey, "hex");
25
+ }
26
+ function serializePublicKeyCompressed(keyPair) {
27
+ return keyPair.getPublic(true, "hex");
28
+ }
29
+ function base64url(input) {
30
+ let buf;
31
+ if (typeof input === "string") buf = Buffer.from(input);
32
+ else if (input instanceof ArrayBuffer) buf = Buffer.from(input);
33
+ else buf = input;
34
+ return buf.toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
35
+ }
36
+ function sha256HashNode(data) {
37
+ const { createHash } = __require("crypto");
38
+ return createHash("sha256").update(data).digest();
39
+ }
40
+ async function hashInput(data) {
41
+ if (typeof window !== "undefined" && window.crypto?.subtle) {
42
+ const encoder = new TextEncoder();
43
+ const encoded = encoder.encode(data);
44
+ const hashBuffer = await window.crypto.subtle.digest("SHA-256", encoded);
45
+ return Buffer.from(hashBuffer);
46
+ } else {
47
+ return sha256HashNode(data);
48
+ }
49
+ }
50
+ async function generateJWT(sub, aud, keyPair, expiresInSeconds = 24 * 60 * 60) {
51
+ const iat = Math.floor(Date.now() / 1e3);
52
+ const exp = iat + expiresInSeconds;
53
+ const header = { alg: "ES256", typ: "JWT" };
54
+ const payload = { sub, aud, iat, exp };
55
+ const encodedHeader = base64url(JSON.stringify(header));
56
+ const encodedPayload = base64url(JSON.stringify(payload));
57
+ const signingInput = `${encodedHeader}.${encodedPayload}`;
58
+ const hash = await hashInput(signingInput);
59
+ const signature = keyPair.sign(hash, { canonical: true });
60
+ const rBuf = signature.r.toArrayLike(Buffer, "be", 32);
61
+ const sBuf = signature.s.toArrayLike(Buffer, "be", 32);
62
+ const rawSig = Buffer.concat([rBuf, sBuf]);
63
+ const encodedSig = base64url(rawSig);
64
+ return `${signingInput}.${encodedSig}`;
65
+ }
66
+ async function createAuthEnvelope(privateKeyHex, network = "testnet" /* Testnet */, options) {
67
+ const keyPair = loadExistingSecp256k1PrivateKey(privateKeyHex);
68
+ const publicKey = serializePublicKeyCompressed(keyPair);
69
+ const host = NETWORK_HOSTS[network];
70
+ if (!host) {
71
+ throw new Error(`Unsupported network: ${network}`);
72
+ }
73
+ const token = await generateJWT(publicKey, host, keyPair, options?.expiresInSeconds);
74
+ return { publicKey, token };
75
+ }
76
+ async function generateAppSignature(privateKeyHex, clientId, redirectUri, state) {
77
+ const keyPair = loadExistingSecp256k1PrivateKey(privateKeyHex);
78
+ const message = `${clientId}:${redirectUri}:${state}`;
79
+ const hash = await hashInput(message);
80
+ const signatureDER = keyPair.sign(hash, { canonical: true }).toDER();
81
+ return Buffer.from(signatureDER).toString("hex");
82
+ }
83
+
84
+ export {
85
+ __require,
86
+ Network,
87
+ NETWORK_HOSTS,
88
+ loadExistingSecp256k1PrivateKey,
89
+ serializePublicKeyCompressed,
90
+ generateJWT,
91
+ createAuthEnvelope,
92
+ generateAppSignature
93
+ };
@@ -0,0 +1,93 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/helpers/CryptoUtils.tsx
9
+ import { ec as EC } from "elliptic";
10
+ var ec = new EC("secp256k1");
11
+ var Network = /* @__PURE__ */ ((Network2) => {
12
+ Network2["Testnet"] = "testnet";
13
+ Network2["Localnet"] = "localnet";
14
+ return Network2;
15
+ })(Network || {});
16
+ var NETWORK_HOSTS = {
17
+ ["testnet" /* Testnet */]: "https://dev-db.petastic.com",
18
+ ["localnet" /* Localnet */]: "http://docker.host.internal:9181"
19
+ };
20
+ function loadExistingSecp256k1PrivateKey(hexKey) {
21
+ if (!hexKey) {
22
+ throw new Error("Private key hex must be provided");
23
+ }
24
+ return ec.keyFromPrivate(hexKey, "hex");
25
+ }
26
+ function serializePublicKeyCompressed(keyPair) {
27
+ return keyPair.getPublic(true, "hex");
28
+ }
29
+ function base64url(input) {
30
+ let buf;
31
+ if (typeof input === "string") buf = Buffer.from(input);
32
+ else if (input instanceof ArrayBuffer) buf = Buffer.from(input);
33
+ else buf = input;
34
+ return buf.toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
35
+ }
36
+ function sha256HashNode(data) {
37
+ const { createHash } = __require("crypto");
38
+ return createHash("sha256").update(data).digest();
39
+ }
40
+ async function hashInput(data) {
41
+ if (typeof window !== "undefined" && window.crypto?.subtle) {
42
+ const encoder = new TextEncoder();
43
+ const encoded = encoder.encode(data);
44
+ const hashBuffer = await window.crypto.subtle.digest("SHA-256", encoded);
45
+ return Buffer.from(hashBuffer);
46
+ } else {
47
+ return sha256HashNode(data);
48
+ }
49
+ }
50
+ async function generateJWT(sub, aud, keyPair, expiresInSeconds = 24 * 60 * 60) {
51
+ const iat = Math.floor(Date.now() / 1e3);
52
+ const exp = iat + expiresInSeconds;
53
+ const header = { alg: "ES256", typ: "JWT" };
54
+ const payload = { sub, aud, iat, exp };
55
+ const encodedHeader = base64url(JSON.stringify(header));
56
+ const encodedPayload = base64url(JSON.stringify(payload));
57
+ const signingInput = `${encodedHeader}.${encodedPayload}`;
58
+ const hash = await hashInput(signingInput);
59
+ const signature = keyPair.sign(hash, { canonical: true });
60
+ const rBuf = signature.r.toArrayLike(Buffer, "be", 32);
61
+ const sBuf = signature.s.toArrayLike(Buffer, "be", 32);
62
+ const rawSig = Buffer.concat([rBuf, sBuf]);
63
+ const encodedSig = base64url(rawSig);
64
+ return `${signingInput}.${encodedSig}`;
65
+ }
66
+ async function createAuthEnvelope(privateKeyHex, network = "testnet" /* Testnet */, options) {
67
+ const keyPair = loadExistingSecp256k1PrivateKey(privateKeyHex);
68
+ const publicKey = serializePublicKeyCompressed(keyPair);
69
+ const host = NETWORK_HOSTS[network];
70
+ if (!host) {
71
+ throw new Error(`Unsupported network: ${network}`);
72
+ }
73
+ const token = await generateJWT(publicKey, host, keyPair, options?.expiresInSeconds);
74
+ return { publicKey, token };
75
+ }
76
+ async function generateAppSignature(privateKeyHex, clientId, redirectUri, state) {
77
+ const keyPair = loadExistingSecp256k1PrivateKey(privateKeyHex);
78
+ const message = `${clientId}:${redirectUri}:${state}`;
79
+ const hash = await hashInput(message);
80
+ const signatureDER = keyPair.sign(hash, { canonical: true }).toDER();
81
+ return Buffer.from(signatureDER).toString("hex");
82
+ }
83
+
84
+ export {
85
+ __require,
86
+ Network,
87
+ NETWORK_HOSTS,
88
+ loadExistingSecp256k1PrivateKey,
89
+ serializePublicKeyCompressed,
90
+ generateJWT,
91
+ createAuthEnvelope,
92
+ generateAppSignature
93
+ };
@@ -0,0 +1,91 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/helpers/CryptoUtils.tsx
9
+ import { ec as EC } from "elliptic";
10
+ var ec = new EC("secp256k1");
11
+ var Network = /* @__PURE__ */ ((Network2) => {
12
+ Network2["Testnet"] = "testnet";
13
+ return Network2;
14
+ })(Network || {});
15
+ var NETWORK_HOSTS = {
16
+ ["testnet" /* Testnet */]: "https://dev-db.petastic.com"
17
+ };
18
+ function loadExistingSecp256k1PrivateKey(hexKey) {
19
+ if (!hexKey) {
20
+ throw new Error("Private key hex must be provided");
21
+ }
22
+ return ec.keyFromPrivate(hexKey, "hex");
23
+ }
24
+ function serializePublicKeyCompressed(keyPair) {
25
+ return keyPair.getPublic(true, "hex");
26
+ }
27
+ function base64url(input) {
28
+ let buf;
29
+ if (typeof input === "string") buf = Buffer.from(input);
30
+ else if (input instanceof ArrayBuffer) buf = Buffer.from(input);
31
+ else buf = input;
32
+ return buf.toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
33
+ }
34
+ function sha256HashNode(data) {
35
+ const { createHash } = __require("crypto");
36
+ return createHash("sha256").update(data).digest();
37
+ }
38
+ async function hashInput(data) {
39
+ if (typeof window !== "undefined" && window.crypto?.subtle) {
40
+ const encoder = new TextEncoder();
41
+ const encoded = encoder.encode(data);
42
+ const hashBuffer = await window.crypto.subtle.digest("SHA-256", encoded);
43
+ return Buffer.from(hashBuffer);
44
+ } else {
45
+ return sha256HashNode(data);
46
+ }
47
+ }
48
+ async function generateJWT(sub, aud, keyPair, expiresInSeconds = 24 * 60 * 60) {
49
+ const iat = Math.floor(Date.now() / 1e3);
50
+ const exp = iat + expiresInSeconds;
51
+ const header = { alg: "ES256", typ: "JWT" };
52
+ const payload = { sub, aud, iat, exp };
53
+ const encodedHeader = base64url(JSON.stringify(header));
54
+ const encodedPayload = base64url(JSON.stringify(payload));
55
+ const signingInput = `${encodedHeader}.${encodedPayload}`;
56
+ const hash = await hashInput(signingInput);
57
+ const signature = keyPair.sign(hash, { canonical: true });
58
+ const rBuf = signature.r.toArrayLike(Buffer, "be", 32);
59
+ const sBuf = signature.s.toArrayLike(Buffer, "be", 32);
60
+ const rawSig = Buffer.concat([rBuf, sBuf]);
61
+ const encodedSig = base64url(rawSig);
62
+ return `${signingInput}.${encodedSig}`;
63
+ }
64
+ async function createAuthEnvelope(privateKeyHex, network = "testnet" /* Testnet */, options) {
65
+ const keyPair = loadExistingSecp256k1PrivateKey(privateKeyHex);
66
+ const publicKey = serializePublicKeyCompressed(keyPair);
67
+ const host = NETWORK_HOSTS[network];
68
+ if (!host) {
69
+ throw new Error(`Unsupported network: ${network}`);
70
+ }
71
+ const token = await generateJWT(publicKey, host, keyPair, options?.expiresInSeconds);
72
+ return { publicKey, token };
73
+ }
74
+ async function generateAppSignature(privateKeyHex, clientId, redirectUri, state) {
75
+ const keyPair = loadExistingSecp256k1PrivateKey(privateKeyHex);
76
+ const message = `${clientId}:${redirectUri}:${state}`;
77
+ const hash = await hashInput(message);
78
+ const signatureDER = keyPair.sign(hash, { canonical: true }).toDER();
79
+ return Buffer.from(signatureDER).toString("hex");
80
+ }
81
+
82
+ export {
83
+ __require,
84
+ Network,
85
+ NETWORK_HOSTS,
86
+ loadExistingSecp256k1PrivateKey,
87
+ serializePublicKeyCompressed,
88
+ generateJWT,
89
+ createAuthEnvelope,
90
+ generateAppSignature
91
+ };
@@ -0,0 +1,93 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/helpers/CryptoUtils.tsx
9
+ import { ec as EC } from "elliptic";
10
+ var ec = new EC("secp256k1");
11
+ var Network = /* @__PURE__ */ ((Network2) => {
12
+ Network2["Testnet"] = "testnet";
13
+ Network2["Localnet"] = "localnet";
14
+ return Network2;
15
+ })(Network || {});
16
+ var NETWORK_HOSTS = {
17
+ ["testnet" /* Testnet */]: "dev-db.petastic.com",
18
+ ["localnet" /* Localnet */]: "host.docker.internal:9181"
19
+ };
20
+ function loadExistingSecp256k1PrivateKey(hexKey) {
21
+ if (!hexKey) {
22
+ throw new Error("Private key hex must be provided");
23
+ }
24
+ return ec.keyFromPrivate(hexKey, "hex");
25
+ }
26
+ function serializePublicKeyCompressed(keyPair) {
27
+ return keyPair.getPublic(true, "hex");
28
+ }
29
+ function base64url(input) {
30
+ let buf;
31
+ if (typeof input === "string") buf = Buffer.from(input);
32
+ else if (input instanceof ArrayBuffer) buf = Buffer.from(input);
33
+ else buf = input;
34
+ return buf.toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
35
+ }
36
+ function sha256HashNode(data) {
37
+ const { createHash } = __require("crypto");
38
+ return createHash("sha256").update(data).digest();
39
+ }
40
+ async function hashInput(data) {
41
+ if (typeof window !== "undefined" && window.crypto?.subtle) {
42
+ const encoder = new TextEncoder();
43
+ const encoded = encoder.encode(data);
44
+ const hashBuffer = await window.crypto.subtle.digest("SHA-256", encoded);
45
+ return Buffer.from(hashBuffer);
46
+ } else {
47
+ return sha256HashNode(data);
48
+ }
49
+ }
50
+ async function generateJWT(sub, aud, keyPair, expiresInSeconds = 24 * 60 * 60) {
51
+ const iat = Math.floor(Date.now() / 1e3);
52
+ const exp = iat + expiresInSeconds;
53
+ const header = { alg: "ES256", typ: "JWT" };
54
+ const payload = { sub, aud, iat, exp };
55
+ const encodedHeader = base64url(JSON.stringify(header));
56
+ const encodedPayload = base64url(JSON.stringify(payload));
57
+ const signingInput = `${encodedHeader}.${encodedPayload}`;
58
+ const hash = await hashInput(signingInput);
59
+ const signature = keyPair.sign(hash, { canonical: true });
60
+ const rBuf = signature.r.toArrayLike(Buffer, "be", 32);
61
+ const sBuf = signature.s.toArrayLike(Buffer, "be", 32);
62
+ const rawSig = Buffer.concat([rBuf, sBuf]);
63
+ const encodedSig = base64url(rawSig);
64
+ return `${signingInput}.${encodedSig}`;
65
+ }
66
+ async function createAuthEnvelope(privateKeyHex, network = "testnet" /* Testnet */, options) {
67
+ const keyPair = loadExistingSecp256k1PrivateKey(privateKeyHex);
68
+ const publicKey = serializePublicKeyCompressed(keyPair);
69
+ const host = NETWORK_HOSTS[network];
70
+ if (!host) {
71
+ throw new Error(`Unsupported network: ${network}`);
72
+ }
73
+ const token = await generateJWT(publicKey, host, keyPair, options?.expiresInSeconds);
74
+ return { publicKey, token };
75
+ }
76
+ async function generateAppSignature(privateKeyHex, clientId, redirectUri, state) {
77
+ const keyPair = loadExistingSecp256k1PrivateKey(privateKeyHex);
78
+ const message = `${clientId}:${redirectUri}:${state}`;
79
+ const hash = await hashInput(message);
80
+ const signatureDER = keyPair.sign(hash, { canonical: true }).toDER();
81
+ return Buffer.from(signatureDER).toString("hex");
82
+ }
83
+
84
+ export {
85
+ __require,
86
+ Network,
87
+ NETWORK_HOSTS,
88
+ loadExistingSecp256k1PrivateKey,
89
+ serializePublicKeyCompressed,
90
+ generateJWT,
91
+ createAuthEnvelope,
92
+ generateAppSignature
93
+ };
@@ -0,0 +1,93 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/helpers/CryptoUtils.tsx
9
+ import { ec as EC } from "elliptic";
10
+ var ec = new EC("secp256k1");
11
+ var Network = /* @__PURE__ */ ((Network2) => {
12
+ Network2["Testnet"] = "testnet";
13
+ Network2["Localnet"] = "localnet";
14
+ return Network2;
15
+ })(Network || {});
16
+ var NETWORK_HOSTS = {
17
+ ["testnet" /* Testnet */]: "https://dev-db.petastic.com",
18
+ ["localnet" /* Localnet */]: "host.docker.internal:9181"
19
+ };
20
+ function loadExistingSecp256k1PrivateKey(hexKey) {
21
+ if (!hexKey) {
22
+ throw new Error("Private key hex must be provided");
23
+ }
24
+ return ec.keyFromPrivate(hexKey, "hex");
25
+ }
26
+ function serializePublicKeyCompressed(keyPair) {
27
+ return keyPair.getPublic(true, "hex");
28
+ }
29
+ function base64url(input) {
30
+ let buf;
31
+ if (typeof input === "string") buf = Buffer.from(input);
32
+ else if (input instanceof ArrayBuffer) buf = Buffer.from(input);
33
+ else buf = input;
34
+ return buf.toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
35
+ }
36
+ function sha256HashNode(data) {
37
+ const { createHash } = __require("crypto");
38
+ return createHash("sha256").update(data).digest();
39
+ }
40
+ async function hashInput(data) {
41
+ if (typeof window !== "undefined" && window.crypto?.subtle) {
42
+ const encoder = new TextEncoder();
43
+ const encoded = encoder.encode(data);
44
+ const hashBuffer = await window.crypto.subtle.digest("SHA-256", encoded);
45
+ return Buffer.from(hashBuffer);
46
+ } else {
47
+ return sha256HashNode(data);
48
+ }
49
+ }
50
+ async function generateJWT(sub, aud, keyPair, expiresInSeconds = 24 * 60 * 60) {
51
+ const iat = Math.floor(Date.now() / 1e3);
52
+ const exp = iat + expiresInSeconds;
53
+ const header = { alg: "ES256", typ: "JWT" };
54
+ const payload = { sub, aud, iat, exp };
55
+ const encodedHeader = base64url(JSON.stringify(header));
56
+ const encodedPayload = base64url(JSON.stringify(payload));
57
+ const signingInput = `${encodedHeader}.${encodedPayload}`;
58
+ const hash = await hashInput(signingInput);
59
+ const signature = keyPair.sign(hash, { canonical: true });
60
+ const rBuf = signature.r.toArrayLike(Buffer, "be", 32);
61
+ const sBuf = signature.s.toArrayLike(Buffer, "be", 32);
62
+ const rawSig = Buffer.concat([rBuf, sBuf]);
63
+ const encodedSig = base64url(rawSig);
64
+ return `${signingInput}.${encodedSig}`;
65
+ }
66
+ async function createAuthEnvelope(privateKeyHex, network = "testnet" /* Testnet */, options) {
67
+ const keyPair = loadExistingSecp256k1PrivateKey(privateKeyHex);
68
+ const publicKey = serializePublicKeyCompressed(keyPair);
69
+ const host = NETWORK_HOSTS[network];
70
+ if (!host) {
71
+ throw new Error(`Unsupported network: ${network}`);
72
+ }
73
+ const token = await generateJWT(publicKey, host, keyPair, options?.expiresInSeconds);
74
+ return { publicKey, token };
75
+ }
76
+ async function generateAppSignature(privateKeyHex, clientId, redirectUri, state) {
77
+ const keyPair = loadExistingSecp256k1PrivateKey(privateKeyHex);
78
+ const message = `${clientId}:${redirectUri}:${state}`;
79
+ const hash = await hashInput(message);
80
+ const signatureDER = keyPair.sign(hash, { canonical: true }).toDER();
81
+ return Buffer.from(signatureDER).toString("hex");
82
+ }
83
+
84
+ export {
85
+ __require,
86
+ Network,
87
+ NETWORK_HOSTS,
88
+ loadExistingSecp256k1PrivateKey,
89
+ serializePublicKeyCompressed,
90
+ generateJWT,
91
+ createAuthEnvelope,
92
+ generateAppSignature
93
+ };
package/dist/index.js CHANGED
@@ -1266,6 +1266,44 @@ var ORGANIZATION_IMPL_ABI = [
1266
1266
 
1267
1267
  // src/utils/anymals/useMintAnymalNFT.ts
1268
1268
  var import_react10 = require("react");
1269
+
1270
+ // src/helpers/GasEstimateHelper.tsx
1271
+ function applyBundlerGasEstimator(account, bundlerClient, options) {
1272
+ const {
1273
+ callGasMultiplier = 1.2,
1274
+ verificationGasMultiplier = 1.2,
1275
+ preVerificationGasMultiplier = 2,
1276
+ debug = true
1277
+ } = options || {};
1278
+ account.userOperation = {
1279
+ estimateGas: async (userOp) => {
1280
+ const estimate = await bundlerClient.estimateUserOperationGas(userOp);
1281
+ const paddedCallGasLimit = BigInt(
1282
+ estimate.callGasLimit * BigInt(Math.ceil(callGasMultiplier * 100)) / 100n
1283
+ );
1284
+ const paddedVerificationGasLimit = BigInt(
1285
+ estimate.verificationGasLimit * BigInt(Math.ceil(verificationGasMultiplier * 100)) / 100n
1286
+ );
1287
+ const paddedPreVerificationGas = BigInt(
1288
+ estimate.preVerificationGas * BigInt(Math.ceil(preVerificationGasMultiplier * 100)) / 100n
1289
+ );
1290
+ if (debug) {
1291
+ console.log("\u{1F4E6} Bundler Gas Estimates:");
1292
+ console.log(" callGasLimit:", paddedCallGasLimit.toString());
1293
+ console.log(" verificationGasLimit:", paddedVerificationGasLimit.toString());
1294
+ console.log(" preVerificationGas:", paddedPreVerificationGas.toString());
1295
+ }
1296
+ return {
1297
+ ...estimate,
1298
+ callGasLimit: paddedCallGasLimit,
1299
+ verificationGasLimit: paddedVerificationGasLimit,
1300
+ preVerificationGas: paddedPreVerificationGas
1301
+ };
1302
+ }
1303
+ };
1304
+ }
1305
+
1306
+ // src/utils/anymals/useMintAnymalNFT.ts
1269
1307
  function useMintAnymalNFT() {
1270
1308
  return (0, import_react10.useCallback)(
1271
1309
  async (pid, nftId, anymalTxId, dbAuthToken, validationContractAddress, smartAccount, bundlerClient) => {
@@ -1286,6 +1324,7 @@ function useMintAnymalNFT() {
1286
1324
  anymalTxId
1287
1325
  ]
1288
1326
  });
1327
+ applyBundlerGasEstimator(smartAccount, bundlerClient);
1289
1328
  const userOpHash = await bundlerClient.sendUserOperation({
1290
1329
  account: smartAccount,
1291
1330
  calls: [
@@ -1294,7 +1333,7 @@ function useMintAnymalNFT() {
1294
1333
  data: callData
1295
1334
  }
1296
1335
  ],
1297
- maxPriorityFeePerGas: (0, import_viem.parseGwei)("0.001")
1336
+ maxPriorityFeePerGas: (0, import_viem.parseGwei)("0.003")
1298
1337
  });
1299
1338
  await bundlerClient.waitForUserOperationReceipt({
1300
1339
  hash: userOpHash,
@@ -1714,6 +1753,7 @@ function useProcessPartialKibblePayment() {
1714
1753
  functionName: "partialPay",
1715
1754
  args
1716
1755
  });
1756
+ applyBundlerGasEstimator(smartAccount, bundlerClient);
1717
1757
  const userOpHash = await bundlerClient.sendUserOperation({
1718
1758
  account: smartAccount,
1719
1759
  calls: [
@@ -1722,7 +1762,7 @@ function useProcessPartialKibblePayment() {
1722
1762
  data: callData
1723
1763
  }
1724
1764
  ],
1725
- maxPriorityFeePerGas: (0, import_viem2.parseGwei)("0.001")
1765
+ maxPriorityFeePerGas: (0, import_viem2.parseGwei)("0.003")
1726
1766
  });
1727
1767
  const receipt = await bundlerClient.waitForUserOperationReceipt({
1728
1768
  hash: userOpHash,
@@ -1759,6 +1799,7 @@ function useApproveKibbleToken() {
1759
1799
  // amount to approve
1760
1800
  ]
1761
1801
  });
1802
+ applyBundlerGasEstimator(smartAccount, bundlerClient);
1762
1803
  const userOpHash = await bundlerClient.sendUserOperation({
1763
1804
  account: smartAccount,
1764
1805
  calls: [
@@ -1767,7 +1808,7 @@ function useApproveKibbleToken() {
1767
1808
  data: callData
1768
1809
  }
1769
1810
  ],
1770
- maxPriorityFeePerGas: (0, import_viem3.parseGwei)("0.001")
1811
+ maxPriorityFeePerGas: (0, import_viem3.parseGwei)("0.003")
1771
1812
  // maxFeePerGas: parseGwei("0.01"),
1772
1813
  });
1773
1814
  await bundlerClient.waitForUserOperationReceipt({
@@ -1820,6 +1861,7 @@ function useCreateOrganizationBase() {
1820
1861
  functionName: "createOrganizationProxy",
1821
1862
  args: [ownerAddress, orgName, orgPid]
1822
1863
  });
1864
+ applyBundlerGasEstimator(adminSmartAccount, bundlerClient);
1823
1865
  const userOpHash = await bundlerClient.sendUserOperation({
1824
1866
  account: adminSmartAccount,
1825
1867
  calls: [
@@ -1828,9 +1870,7 @@ function useCreateOrganizationBase() {
1828
1870
  data: callData
1829
1871
  }
1830
1872
  ],
1831
- maxPriorityFeePerGas: (0, import_viem4.parseGwei)("0.001")
1832
- // Low priority fee
1833
- // maxFeePerGas: parseGwei("0.15"), // Max fee cap -- keeps rising at random
1873
+ paymaster: true
1834
1874
  });
1835
1875
  const txReceipt = await bundlerClient.waitForUserOperationReceipt({
1836
1876
  hash: userOpHash,
@@ -1873,7 +1913,7 @@ function useCreateOrganizationBase() {
1873
1913
  const errorMessage = error instanceof Error ? error.message : "An unknown error occurred.";
1874
1914
  return {
1875
1915
  success: false,
1876
- message: `Error processing organization: ${errorMessage}`
1916
+ message: `Error processing organization here: ${errorMessage}`
1877
1917
  };
1878
1918
  }
1879
1919
  },
@@ -1904,6 +1944,7 @@ function useApproveOrgPartialPayment() {
1904
1944
  functionName: "executeCall",
1905
1945
  args: [kibbleTokenAddress, approveCalldata]
1906
1946
  });
1947
+ applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
1907
1948
  const userOpApproveHash = await bundlerClient.sendUserOperation({
1908
1949
  account: managerSmartAccount,
1909
1950
  calls: [
@@ -1912,14 +1953,19 @@ function useApproveOrgPartialPayment() {
1912
1953
  data: executeApproveCalldata
1913
1954
  }
1914
1955
  ],
1915
- maxPriorityFeePerGas: (0, import_viem5.parseGwei)("0.001")
1956
+ maxPriorityFeePerGas: (0, import_viem5.parseGwei)("0.003")
1916
1957
  // maxFeePerGas: parseGwei("0.01"),
1917
1958
  });
1918
- await bundlerClient.waitForUserOperationReceipt({ hash: userOpApproveHash });
1959
+ await bundlerClient.waitForUserOperationReceipt({
1960
+ hash: userOpApproveHash
1961
+ });
1919
1962
  return { success: true, message: "Approval processed successfully." };
1920
1963
  } catch (error) {
1921
1964
  const errorMessage = error instanceof Error ? error.message : "An unknown error occurred.";
1922
- return { success: false, message: `Error processing approval: ${errorMessage}` };
1965
+ return {
1966
+ success: false,
1967
+ message: `Error processing approval: ${errorMessage}`
1968
+ };
1923
1969
  }
1924
1970
  },
1925
1971
  []
@@ -1958,6 +2004,7 @@ function useProcessOrgPartialKibblePayment() {
1958
2004
  functionName: "executeCall",
1959
2005
  args: [partialPaymentModuleAddress, partialPayCalldata]
1960
2006
  });
2007
+ applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
1961
2008
  const userOpPartialPayHash = await bundlerClient.sendUserOperation({
1962
2009
  account: managerSmartAccount,
1963
2010
  calls: [
@@ -1966,7 +2013,7 @@ function useProcessOrgPartialKibblePayment() {
1966
2013
  data: executePartialPayCalldata
1967
2014
  }
1968
2015
  ],
1969
- maxPriorityFeePerGas: (0, import_viem6.parseGwei)("0.001")
2016
+ maxPriorityFeePerGas: (0, import_viem6.parseGwei)("0.003")
1970
2017
  // maxFeePerGas: parseGwei("0.01"),
1971
2018
  });
1972
2019
  const receipt = await bundlerClient.waitForUserOperationReceipt({
@@ -2421,6 +2468,7 @@ function useClaimActionReward() {
2421
2468
  functionName: "claimByIndex",
2422
2469
  args: [actionId, claimIndex]
2423
2470
  });
2471
+ applyBundlerGasEstimator(smartAccount, bundlerClient);
2424
2472
  const userOpHash = await bundlerClient.sendUserOperation({
2425
2473
  account: smartAccount,
2426
2474
  calls: [
@@ -2429,7 +2477,7 @@ function useClaimActionReward() {
2429
2477
  data: callData
2430
2478
  }
2431
2479
  ],
2432
- maxPriorityFeePerGas: (0, import_viem9.parseGwei)("0.001")
2480
+ maxPriorityFeePerGas: (0, import_viem9.parseGwei)("0.003")
2433
2481
  });
2434
2482
  await bundlerClient.waitForUserOperationReceipt({
2435
2483
  hash: userOpHash,
@@ -2464,6 +2512,7 @@ function useClaimOrgActionReward() {
2464
2512
  functionName: "executeCall",
2465
2513
  args: [rewardableActionContractAddress, claimCallData]
2466
2514
  });
2515
+ applyBundlerGasEstimator(smartAccount, bundlerClient);
2467
2516
  const userOpHash = await bundlerClient.sendUserOperation({
2468
2517
  account: smartAccount,
2469
2518
  calls: [
@@ -2472,7 +2521,7 @@ function useClaimOrgActionReward() {
2472
2521
  data: executeClaimCalldata
2473
2522
  }
2474
2523
  ],
2475
- maxPriorityFeePerGas: (0, import_viem10.parseGwei)("0.001")
2524
+ maxPriorityFeePerGas: (0, import_viem10.parseGwei)("0.003")
2476
2525
  });
2477
2526
  await bundlerClient.waitForUserOperationReceipt({
2478
2527
  hash: userOpHash,
package/dist/index.mjs CHANGED
@@ -1203,6 +1203,44 @@ var ORGANIZATION_IMPL_ABI = [
1203
1203
 
1204
1204
  // src/utils/anymals/useMintAnymalNFT.ts
1205
1205
  import { useCallback as useCallback10 } from "react";
1206
+
1207
+ // src/helpers/GasEstimateHelper.tsx
1208
+ function applyBundlerGasEstimator(account, bundlerClient, options) {
1209
+ const {
1210
+ callGasMultiplier = 1.2,
1211
+ verificationGasMultiplier = 1.2,
1212
+ preVerificationGasMultiplier = 2,
1213
+ debug = true
1214
+ } = options || {};
1215
+ account.userOperation = {
1216
+ estimateGas: async (userOp) => {
1217
+ const estimate = await bundlerClient.estimateUserOperationGas(userOp);
1218
+ const paddedCallGasLimit = BigInt(
1219
+ estimate.callGasLimit * BigInt(Math.ceil(callGasMultiplier * 100)) / 100n
1220
+ );
1221
+ const paddedVerificationGasLimit = BigInt(
1222
+ estimate.verificationGasLimit * BigInt(Math.ceil(verificationGasMultiplier * 100)) / 100n
1223
+ );
1224
+ const paddedPreVerificationGas = BigInt(
1225
+ estimate.preVerificationGas * BigInt(Math.ceil(preVerificationGasMultiplier * 100)) / 100n
1226
+ );
1227
+ if (debug) {
1228
+ console.log("\u{1F4E6} Bundler Gas Estimates:");
1229
+ console.log(" callGasLimit:", paddedCallGasLimit.toString());
1230
+ console.log(" verificationGasLimit:", paddedVerificationGasLimit.toString());
1231
+ console.log(" preVerificationGas:", paddedPreVerificationGas.toString());
1232
+ }
1233
+ return {
1234
+ ...estimate,
1235
+ callGasLimit: paddedCallGasLimit,
1236
+ verificationGasLimit: paddedVerificationGasLimit,
1237
+ preVerificationGas: paddedPreVerificationGas
1238
+ };
1239
+ }
1240
+ };
1241
+ }
1242
+
1243
+ // src/utils/anymals/useMintAnymalNFT.ts
1206
1244
  function useMintAnymalNFT() {
1207
1245
  return useCallback10(
1208
1246
  async (pid, nftId, anymalTxId, dbAuthToken, validationContractAddress, smartAccount, bundlerClient) => {
@@ -1223,6 +1261,7 @@ function useMintAnymalNFT() {
1223
1261
  anymalTxId
1224
1262
  ]
1225
1263
  });
1264
+ applyBundlerGasEstimator(smartAccount, bundlerClient);
1226
1265
  const userOpHash = await bundlerClient.sendUserOperation({
1227
1266
  account: smartAccount,
1228
1267
  calls: [
@@ -1231,7 +1270,7 @@ function useMintAnymalNFT() {
1231
1270
  data: callData
1232
1271
  }
1233
1272
  ],
1234
- maxPriorityFeePerGas: parseGwei("0.001")
1273
+ maxPriorityFeePerGas: parseGwei("0.003")
1235
1274
  });
1236
1275
  await bundlerClient.waitForUserOperationReceipt({
1237
1276
  hash: userOpHash,
@@ -1651,6 +1690,7 @@ function useProcessPartialKibblePayment() {
1651
1690
  functionName: "partialPay",
1652
1691
  args
1653
1692
  });
1693
+ applyBundlerGasEstimator(smartAccount, bundlerClient);
1654
1694
  const userOpHash = await bundlerClient.sendUserOperation({
1655
1695
  account: smartAccount,
1656
1696
  calls: [
@@ -1659,7 +1699,7 @@ function useProcessPartialKibblePayment() {
1659
1699
  data: callData
1660
1700
  }
1661
1701
  ],
1662
- maxPriorityFeePerGas: parseGwei2("0.001")
1702
+ maxPriorityFeePerGas: parseGwei2("0.003")
1663
1703
  });
1664
1704
  const receipt = await bundlerClient.waitForUserOperationReceipt({
1665
1705
  hash: userOpHash,
@@ -1696,6 +1736,7 @@ function useApproveKibbleToken() {
1696
1736
  // amount to approve
1697
1737
  ]
1698
1738
  });
1739
+ applyBundlerGasEstimator(smartAccount, bundlerClient);
1699
1740
  const userOpHash = await bundlerClient.sendUserOperation({
1700
1741
  account: smartAccount,
1701
1742
  calls: [
@@ -1704,7 +1745,7 @@ function useApproveKibbleToken() {
1704
1745
  data: callData
1705
1746
  }
1706
1747
  ],
1707
- maxPriorityFeePerGas: parseGwei3("0.001")
1748
+ maxPriorityFeePerGas: parseGwei3("0.003")
1708
1749
  // maxFeePerGas: parseGwei("0.01"),
1709
1750
  });
1710
1751
  await bundlerClient.waitForUserOperationReceipt({
@@ -1730,7 +1771,7 @@ function useApproveKibbleToken() {
1730
1771
 
1731
1772
  // src/utils/organization/useCreateOrganizationBase.ts
1732
1773
  import { useCallback as useCallback19 } from "react";
1733
- import { decodeEventLog, encodeFunctionData as encodeFunctionData4, parseGwei as parseGwei4 } from "viem";
1774
+ import { decodeEventLog, encodeFunctionData as encodeFunctionData4 } from "viem";
1734
1775
  function useCreateOrganizationBase() {
1735
1776
  return useCallback19(
1736
1777
  /**
@@ -1757,6 +1798,7 @@ function useCreateOrganizationBase() {
1757
1798
  functionName: "createOrganizationProxy",
1758
1799
  args: [ownerAddress, orgName, orgPid]
1759
1800
  });
1801
+ applyBundlerGasEstimator(adminSmartAccount, bundlerClient);
1760
1802
  const userOpHash = await bundlerClient.sendUserOperation({
1761
1803
  account: adminSmartAccount,
1762
1804
  calls: [
@@ -1765,9 +1807,7 @@ function useCreateOrganizationBase() {
1765
1807
  data: callData
1766
1808
  }
1767
1809
  ],
1768
- maxPriorityFeePerGas: parseGwei4("0.001")
1769
- // Low priority fee
1770
- // maxFeePerGas: parseGwei("0.15"), // Max fee cap -- keeps rising at random
1810
+ paymaster: true
1771
1811
  });
1772
1812
  const txReceipt = await bundlerClient.waitForUserOperationReceipt({
1773
1813
  hash: userOpHash,
@@ -1810,7 +1850,7 @@ function useCreateOrganizationBase() {
1810
1850
  const errorMessage = error instanceof Error ? error.message : "An unknown error occurred.";
1811
1851
  return {
1812
1852
  success: false,
1813
- message: `Error processing organization: ${errorMessage}`
1853
+ message: `Error processing organization here: ${errorMessage}`
1814
1854
  };
1815
1855
  }
1816
1856
  },
@@ -1841,6 +1881,7 @@ function useApproveOrgPartialPayment() {
1841
1881
  functionName: "executeCall",
1842
1882
  args: [kibbleTokenAddress, approveCalldata]
1843
1883
  });
1884
+ applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
1844
1885
  const userOpApproveHash = await bundlerClient.sendUserOperation({
1845
1886
  account: managerSmartAccount,
1846
1887
  calls: [
@@ -1849,14 +1890,19 @@ function useApproveOrgPartialPayment() {
1849
1890
  data: executeApproveCalldata
1850
1891
  }
1851
1892
  ],
1852
- maxPriorityFeePerGas: parseGwei5("0.001")
1893
+ maxPriorityFeePerGas: parseGwei5("0.003")
1853
1894
  // maxFeePerGas: parseGwei("0.01"),
1854
1895
  });
1855
- await bundlerClient.waitForUserOperationReceipt({ hash: userOpApproveHash });
1896
+ await bundlerClient.waitForUserOperationReceipt({
1897
+ hash: userOpApproveHash
1898
+ });
1856
1899
  return { success: true, message: "Approval processed successfully." };
1857
1900
  } catch (error) {
1858
1901
  const errorMessage = error instanceof Error ? error.message : "An unknown error occurred.";
1859
- return { success: false, message: `Error processing approval: ${errorMessage}` };
1902
+ return {
1903
+ success: false,
1904
+ message: `Error processing approval: ${errorMessage}`
1905
+ };
1860
1906
  }
1861
1907
  },
1862
1908
  []
@@ -1895,6 +1941,7 @@ function useProcessOrgPartialKibblePayment() {
1895
1941
  functionName: "executeCall",
1896
1942
  args: [partialPaymentModuleAddress, partialPayCalldata]
1897
1943
  });
1944
+ applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
1898
1945
  const userOpPartialPayHash = await bundlerClient.sendUserOperation({
1899
1946
  account: managerSmartAccount,
1900
1947
  calls: [
@@ -1903,7 +1950,7 @@ function useProcessOrgPartialKibblePayment() {
1903
1950
  data: executePartialPayCalldata
1904
1951
  }
1905
1952
  ],
1906
- maxPriorityFeePerGas: parseGwei6("0.001")
1953
+ maxPriorityFeePerGas: parseGwei6("0.003")
1907
1954
  // maxFeePerGas: parseGwei("0.01"),
1908
1955
  });
1909
1956
  const receipt = await bundlerClient.waitForUserOperationReceipt({
@@ -2278,6 +2325,7 @@ function useClaimActionReward() {
2278
2325
  functionName: "claimByIndex",
2279
2326
  args: [actionId, claimIndex]
2280
2327
  });
2328
+ applyBundlerGasEstimator(smartAccount, bundlerClient);
2281
2329
  const userOpHash = await bundlerClient.sendUserOperation({
2282
2330
  account: smartAccount,
2283
2331
  calls: [
@@ -2286,7 +2334,7 @@ function useClaimActionReward() {
2286
2334
  data: callData
2287
2335
  }
2288
2336
  ],
2289
- maxPriorityFeePerGas: parseGwei7("0.001")
2337
+ maxPriorityFeePerGas: parseGwei7("0.003")
2290
2338
  });
2291
2339
  await bundlerClient.waitForUserOperationReceipt({
2292
2340
  hash: userOpHash,
@@ -2321,6 +2369,7 @@ function useClaimOrgActionReward() {
2321
2369
  functionName: "executeCall",
2322
2370
  args: [rewardableActionContractAddress, claimCallData]
2323
2371
  });
2372
+ applyBundlerGasEstimator(smartAccount, bundlerClient);
2324
2373
  const userOpHash = await bundlerClient.sendUserOperation({
2325
2374
  account: smartAccount,
2326
2375
  calls: [
@@ -2329,7 +2378,7 @@ function useClaimOrgActionReward() {
2329
2378
  data: executeClaimCalldata
2330
2379
  }
2331
2380
  ],
2332
- maxPriorityFeePerGas: parseGwei8("0.001")
2381
+ maxPriorityFeePerGas: parseGwei8("0.003")
2333
2382
  });
2334
2383
  await bundlerClient.waitForUserOperationReceipt({
2335
2384
  hash: userOpHash,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anymal-protocol",
3
- "version": "1.0.113",
3
+ "version": "1.0.115",
4
4
  "description": "A React/TypeScript-based utility library for reusable functions and hooks inside of the Anymal Ecosystem.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {