@cowprotocol/sdk-viem-adapter 0.3.1-beta.0 → 0.3.2

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/index.d.mts CHANGED
@@ -46,7 +46,8 @@ declare class ViemUtils implements AdapterUtils {
46
46
  getCreate2Address(from: Address, salt: Hex, bytecodeHash: Hex): `0x${string}`;
47
47
  hexConcat(items: ReadonlyArray<Hex | number[]>): string;
48
48
  formatBytes32String(text: string): string;
49
- keccak256(data: Hex): string;
49
+ keccak256(data: Hex): `0x${string}`;
50
+ sha256(data: Hex): Hex;
50
51
  private bytesToHex;
51
52
  private padBytes;
52
53
  hexZeroPad(value: Hex, length: number): string;
@@ -55,6 +56,7 @@ declare class ViemUtils implements AdapterUtils {
55
56
  solidityPack(types: string[], values: ContractValue[]): string;
56
57
  hashTypedData(domain: TypedDataDomain, types: Record<string, unknown>, data: Record<string, unknown>): string;
57
58
  getChecksumAddress(address: Address): Address;
59
+ recoverAddress(hash: Hex, signature: Hex): Promise<Hex>;
58
60
  encodeAbi(types: {
59
61
  type: string;
60
62
  name: string;
@@ -81,13 +83,7 @@ declare class ViemUtils implements AdapterUtils {
81
83
  name: string;
82
84
  type: string;
83
85
  }>>, value: Record<string, unknown>, signature: `0x${string}`): Promise<`0x${string}`>;
84
- encodeFunction(abi: Array<{
85
- name: string;
86
- inputs: Array<{
87
- type: string;
88
- }>;
89
- type: string;
90
- }>, functionName: string, args: ContractValue[]): string;
86
+ encodeFunction(abi: Abi, functionName: string, args: ContractValue[]): string;
91
87
  decodeFunctionData(abi: Array<{
92
88
  name: string;
93
89
  inputs: Array<{
package/dist/index.d.ts CHANGED
@@ -46,7 +46,8 @@ declare class ViemUtils implements AdapterUtils {
46
46
  getCreate2Address(from: Address, salt: Hex, bytecodeHash: Hex): `0x${string}`;
47
47
  hexConcat(items: ReadonlyArray<Hex | number[]>): string;
48
48
  formatBytes32String(text: string): string;
49
- keccak256(data: Hex): string;
49
+ keccak256(data: Hex): `0x${string}`;
50
+ sha256(data: Hex): Hex;
50
51
  private bytesToHex;
51
52
  private padBytes;
52
53
  hexZeroPad(value: Hex, length: number): string;
@@ -55,6 +56,7 @@ declare class ViemUtils implements AdapterUtils {
55
56
  solidityPack(types: string[], values: ContractValue[]): string;
56
57
  hashTypedData(domain: TypedDataDomain, types: Record<string, unknown>, data: Record<string, unknown>): string;
57
58
  getChecksumAddress(address: Address): Address;
59
+ recoverAddress(hash: Hex, signature: Hex): Promise<Hex>;
58
60
  encodeAbi(types: {
59
61
  type: string;
60
62
  name: string;
@@ -81,13 +83,7 @@ declare class ViemUtils implements AdapterUtils {
81
83
  name: string;
82
84
  type: string;
83
85
  }>>, value: Record<string, unknown>, signature: `0x${string}`): Promise<`0x${string}`>;
84
- encodeFunction(abi: Array<{
85
- name: string;
86
- inputs: Array<{
87
- type: string;
88
- }>;
89
- type: string;
90
- }>, functionName: string, args: ContractValue[]): string;
86
+ encodeFunction(abi: Abi, functionName: string, args: ContractValue[]): string;
91
87
  decodeFunctionData(abi: Array<{
92
88
  name: string;
93
89
  inputs: Array<{
package/dist/index.js CHANGED
@@ -282,6 +282,9 @@ var ViemUtils = class {
282
282
  keccak256(data) {
283
283
  return (0, import_viem2.keccak256)(data);
284
284
  }
285
+ sha256(data) {
286
+ return (0, import_viem2.sha256)(data);
287
+ }
285
288
  bytesToHex(bytes) {
286
289
  return `0x${Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("")}`;
287
290
  }
@@ -320,6 +323,9 @@ var ViemUtils = class {
320
323
  getChecksumAddress(address) {
321
324
  return (0, import_viem2.getAddress)(address);
322
325
  }
326
+ recoverAddress(hash, signature) {
327
+ return (0, import_viem2.recoverAddress)({ hash, signature });
328
+ }
323
329
  encodeAbi(types, values) {
324
330
  if (typeof types[0] === "string") {
325
331
  return (0, import_viem2.encodeAbiParameters)(
@@ -335,7 +341,7 @@ var ViemUtils = class {
335
341
  return (0, import_viem2.decodeAbiParameters)(types, data);
336
342
  }
337
343
  id(text) {
338
- return (0, import_viem2.keccak256)((0, import_viem2.stringToHex)(text));
344
+ return (0, import_viem2.keccak256)((0, import_viem2.toBytes)(text));
339
345
  }
340
346
  toBigIntish(value) {
341
347
  if (typeof value === "number")
@@ -605,6 +611,8 @@ var ViemSignerAdapter = class extends import_sdk_common3.AbstractSigner {
605
611
  confirmations
606
612
  });
607
613
  return {
614
+ from: receipt.from,
615
+ to: receipt.to,
608
616
  transactionHash: receipt.transactionHash,
609
617
  blockNumber: BigInt(receipt.blockNumber),
610
618
  blockHash: receipt.blockHash,
package/dist/index.mjs CHANGED
@@ -30,7 +30,6 @@ import {
30
30
  getAddress,
31
31
  encodeAbiParameters,
32
32
  decodeAbiParameters as decodeAbiParameters2,
33
- stringToHex,
34
33
  hexToBigInt,
35
34
  slice,
36
35
  parseAbi as parseAbi2,
@@ -44,7 +43,10 @@ import {
44
43
  isAddress,
45
44
  isHex,
46
45
  parseUnits,
47
- sliceHex
46
+ sliceHex,
47
+ toBytes,
48
+ sha256,
49
+ recoverAddress
48
50
  } from "viem";
49
51
 
50
52
  // src/ViemInterfaceWrapper.ts
@@ -303,6 +305,9 @@ var ViemUtils = class {
303
305
  keccak256(data) {
304
306
  return keccak256(data);
305
307
  }
308
+ sha256(data) {
309
+ return sha256(data);
310
+ }
306
311
  bytesToHex(bytes) {
307
312
  return `0x${Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("")}`;
308
313
  }
@@ -341,6 +346,9 @@ var ViemUtils = class {
341
346
  getChecksumAddress(address) {
342
347
  return getAddress(address);
343
348
  }
349
+ recoverAddress(hash, signature) {
350
+ return recoverAddress({ hash, signature });
351
+ }
344
352
  encodeAbi(types, values) {
345
353
  if (typeof types[0] === "string") {
346
354
  return encodeAbiParameters(
@@ -356,7 +364,7 @@ var ViemUtils = class {
356
364
  return decodeAbiParameters2(types, data);
357
365
  }
358
366
  id(text) {
359
- return keccak256(stringToHex(text));
367
+ return keccak256(toBytes(text));
360
368
  }
361
369
  toBigIntish(value) {
362
370
  if (typeof value === "number")
@@ -629,6 +637,8 @@ var ViemSignerAdapter = class extends AbstractSigner {
629
637
  confirmations
630
638
  });
631
639
  return {
640
+ from: receipt.from,
641
+ to: receipt.to,
632
642
  transactionHash: receipt.transactionHash,
633
643
  blockNumber: BigInt(receipt.blockNumber),
634
644
  blockHash: receipt.blockHash,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/sdk-viem-adapter",
3
- "version": "0.3.1-beta.0",
3
+ "version": "0.3.2",
4
4
  "description": "Viem adapter for CoW Protocol SDK",
5
5
  "main": "dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -13,7 +13,7 @@
13
13
  "access": "public"
14
14
  },
15
15
  "dependencies": {
16
- "@cowprotocol/sdk-common": "0.5.0-beta.0"
16
+ "@cowprotocol/sdk-common": "0.5.1"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "viem": "^2.28.4"