@layerzerolabs/onesig-core 0.0.6 → 0.0.8

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.
Files changed (2) hide show
  1. package/dist/index.js +13 -9
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -75,14 +76,16 @@ function encodeLeafHeader({ targetOneSigAddress, oneSigId, nonce }) {
75
76
  if (targetOneSigAddress.byteLength !== 32) {
76
77
  throw new Error("Contract address must be 32 bytes");
77
78
  }
78
- const storage = Buffer.alloc(97);
79
+ const storage = Buffer.alloc(49);
79
80
  storage[0] = 1;
80
- const idStr = oneSigId.toString(16).padStart(64, "0");
81
- const nonceStr = nonce.toString(16).padStart(64, "0");
81
+ const idStr = oneSigId.toString(16).padStart(16, "0");
82
+ const nonceStr = nonce.toString(16).padStart(16, "0");
82
83
  for (let i = 0; i < 32; i++) {
83
- storage[i + 1] = readByteFromHex(idStr, i);
84
- storage[i + 33] = targetOneSigAddress[i];
85
- storage[i + 65] = readByteFromHex(nonceStr, i);
84
+ if (i < 8) {
85
+ storage[i + 1] = readByteFromHex(idStr, i);
86
+ storage[i + 41] = readByteFromHex(nonceStr, i);
87
+ }
88
+ storage[i + 9] = targetOneSigAddress[i];
86
89
  }
87
90
  return storage;
88
91
  }
@@ -99,7 +102,7 @@ function encodeLeaf(gen, index) {
99
102
  }),
100
103
  gen.encodeCalls(leaf.calls)
101
104
  ]);
102
- return import_ethers.ethers.utils.keccak256(leafData);
105
+ return import_ethers.ethers.utils.keccak256(import_ethers.ethers.utils.keccak256(leafData));
103
106
  }
104
107
  function makeOneSigTree(input) {
105
108
  const encodedLeafs = [];
@@ -182,7 +185,7 @@ var _Signature = class _Signature {
182
185
  return signature.get();
183
186
  });
184
187
  let orderedSignatures;
185
- if (!sortMethod) {
188
+ if (sortMethod === false) {
186
189
  orderedSignatures = signatureBuffers;
187
190
  } else {
188
191
  let addresses;
@@ -206,7 +209,8 @@ var _Signature = class _Signature {
206
209
  });
207
210
  orderedSignatures = indexMapping.map((index) => signatureBuffers[index]);
208
211
  }
209
- return new this(Buffer.concat(orderedSignatures));
212
+ const combined = Buffer.concat(orderedSignatures);
213
+ return new this(combined);
210
214
  }
211
215
  };
212
216
  _value = new WeakMap();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@layerzerolabs/onesig-core",
3
- "version": "0.0.6",
4
- "license": "MIT",
3
+ "version": "0.0.8",
4
+ "license": "GPL-3.0-only",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
@@ -11,6 +11,7 @@
11
11
  "./package.json": "./package.json"
12
12
  },
13
13
  "main": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
14
15
  "files": [
15
16
  "dist/**/*"
16
17
  ],