@dfns/lib-viem 0.6.3-rc.1 → 0.6.4-alpha.1

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 (3) hide show
  1. package/index.d.ts +4 -0
  2. package/index.js +14 -0
  3. package/package.json +3 -3
package/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { DfnsApiClient } from '@dfns/sdk';
2
2
  import { Address, GetTransactionType, Hash, SerializeTransactionFn, SignableMessage, TransactionSerializable, TransactionSerialized, TypedData, TypedDataDefinition } from 'viem';
3
3
  import { IsNarrowable } from 'viem/_types/types/utils';
4
+ import { SignAuthorizationParameters, SignAuthorizationReturnType } from 'viem/accounts';
5
+ type To = 'object' | 'bytes' | 'hex';
4
6
  export type DfnsWalletOptions = {
5
7
  walletId: string;
6
8
  dfnsClient: DfnsApiClient;
@@ -23,4 +25,6 @@ export declare class DfnsWallet {
23
25
  serializer?: serializer | undefined;
24
26
  } | undefined): Promise<IsNarrowable<TransactionSerialized<GetTransactionType<transaction>>, Hash> extends true ? TransactionSerialized<GetTransactionType<transaction>> : Hash>;
25
27
  signTypedData<const typedData extends TypedData | Record<string, unknown>, primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData>(typedDataDefinition: TypedDataDefinition<typedData, primaryType>): Promise<Hash>;
28
+ experimental_signAuthorization<to extends To = 'object'>(parameters: SignAuthorizationParameters<to>): Promise<SignAuthorizationReturnType<to>>;
26
29
  }
30
+ export {};
package/index.js CHANGED
@@ -4,6 +4,7 @@ exports.DfnsWallet = void 0;
4
4
  const sdk_1 = require("@dfns/sdk");
5
5
  const viem_1 = require("viem");
6
6
  const accounts_1 = require("viem/accounts");
7
+ const experimental_1 = require("viem/experimental");
7
8
  const assertSigned = (res) => {
8
9
  if (res.status === 'Failed') {
9
10
  throw new sdk_1.DfnsError(-1, 'signing failed', res);
@@ -39,6 +40,7 @@ class DfnsWallet {
39
40
  this.signMessage = this.signMessage.bind(this);
40
41
  this.signTransaction = this.signTransaction.bind(this);
41
42
  this.signTypedData = this.signTypedData.bind(this);
43
+ this.experimental_signAuthorization = this.experimental_signAuthorization.bind(this);
42
44
  }
43
45
  static async init(options) {
44
46
  const { walletId, dfnsClient } = options;
@@ -106,5 +108,17 @@ class DfnsWallet {
106
108
  const signature = await this.signHash(hash);
107
109
  return (0, viem_1.signatureToHex)(signature);
108
110
  }
111
+ async experimental_signAuthorization(parameters) {
112
+ const { contractAddress, chainId, nonce, to = 'object', } = parameters;
113
+ const signature = await this.signHash((0, experimental_1.hashAuthorization)({ contractAddress, chainId, nonce }));
114
+ if (to === 'object')
115
+ return {
116
+ contractAddress,
117
+ chainId,
118
+ nonce,
119
+ ...signature,
120
+ };
121
+ return signature;
122
+ }
109
123
  }
110
124
  exports.DfnsWallet = DfnsWallet;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@dfns/lib-viem",
3
- "version": "0.6.3-rc.1",
3
+ "version": "0.6.4-alpha.1",
4
4
  "peerDependencies": {
5
- "viem": "^2.0.0",
6
- "@dfns/sdk": "0.6.3-rc.1"
5
+ "viem": "2.23.2",
6
+ "@dfns/sdk": "0.6.4"
7
7
  },
8
8
  "dependencies": {
9
9
  "buffer": "6.0.3",