@socket.tech/dl-common 1.0.4-test.7 → 1.0.4-test.9

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.
@@ -21,12 +21,12 @@ export declare class SocketSigner extends SocketRelaySigner {
21
21
  readonly sequential: boolean;
22
22
  readonly isCritical: boolean;
23
23
  readonly metadata: object;
24
- readonly safeWrapperContract: Contract | undefined;
24
+ readonly safeWrapperContract: Contract;
25
+ readonly address: string;
25
26
  constructor(provider: Provider, chainId: number, safeAddress: string, safeWrapperAddress: string, relayUrl: string, relayerAPIKey: string, signingWallet?: Wallet | undefined, useSafe?: boolean, useEOA?: boolean, sequential?: boolean, isCritical?: boolean, metadata?: object);
26
27
  setSigningWallet(signingWallet: Wallet): SocketRelaySigner;
27
28
  setSafeWrapperAddress(safeWrapperAddress: string): SocketRelaySigner;
28
29
  setSafeAddress(safeAddress: string): SocketRelaySigner;
29
30
  getAddress(): Promise<string>;
30
- address(): Promise<string>;
31
31
  sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse>;
32
32
  }
@@ -50,7 +50,12 @@ class SocketSigner extends relaySigner_1.SocketRelaySigner {
50
50
  this.sequential = sequential;
51
51
  this.isCritical = isCritical;
52
52
  this.metadata = metadata;
53
- if (this.safeWrapperAddress.length !== 0)
53
+ this.address =
54
+ this.signingWallet != null
55
+ ? this.signingWallet.address
56
+ : "0x5367Efc17020Aa1CF0943bA7eD17f1D3e4c7d7EE";
57
+ if (this.safeWrapperAddress.length !== 0 ||
58
+ this.safeWrapperAddress !== ethers_1.constants.AddressZero)
54
59
  this.safeWrapperContract = new ethers_1.Contract(this.safeWrapperAddress, MultiSigWrapper_json_1.default, this.provider);
55
60
  }
56
61
  setSigningWallet(signingWallet) {
@@ -64,22 +69,23 @@ class SocketSigner extends relaySigner_1.SocketRelaySigner {
64
69
  }
65
70
  async getAddress() {
66
71
  if (this.signingWallet != null)
67
- return await this.signingWallet.getAddress();
72
+ return this.signingWallet.address;
68
73
  return await super.getAddress();
69
74
  }
70
- async address() {
71
- return await this.getAddress();
72
- }
73
75
  async sendTransaction(transaction) {
74
76
  var _a, _b;
75
77
  if (this.useSafe) {
76
- if (this.safeAddress.length === 0 || this.safeAddress === ethers_1.constants.AddressZero)
78
+ if (this.safeAddress.length === 0 ||
79
+ this.safeAddress === ethers_1.constants.AddressZero)
77
80
  throw new Error("safeAddress not provided");
78
81
  if (this.safeWrapperContract == null)
79
82
  throw new Error("safe wrapper not provided");
80
83
  if (this.signingWallet == null)
81
84
  throw new Error("signingWallet not provided");
82
- const nonce = await this.safeWrapperContract.getNonce();
85
+ const signerAddress = await this.getAddress();
86
+ let nonce = await this.safeWrapperContract.lastNonce(signerAddress);
87
+ if (Number(nonce) !== 0)
88
+ nonce = Number(nonce) + 1;
83
89
  const contractData = {
84
90
  to: transaction.to,
85
91
  value: (_a = transaction.value) !== null && _a !== void 0 ? _a : 0,
@@ -94,14 +100,13 @@ class SocketSigner extends relaySigner_1.SocketRelaySigner {
94
100
  };
95
101
  const signature = await this.signingWallet._signTypedData({ verifyingContract: this.safeAddress, chainId: this.chainId }, exports.EIP712_SAFE_TX_TYPE, contractData);
96
102
  // update to & data
97
- transaction.data =
98
- this.safeWrapperContract.interface.encodeFunctionData("storeOrRelaySignatures", [
99
- contractData.to,
100
- nonce,
101
- contractData.value,
102
- contractData.data,
103
- signature,
104
- ]);
103
+ transaction.data = this.safeWrapperContract.interface.encodeFunctionData("storeOrRelaySignatures", [
104
+ contractData.to,
105
+ nonce,
106
+ contractData.value,
107
+ contractData.data,
108
+ signature,
109
+ ]);
105
110
  transaction.to = this.safeWrapperAddress;
106
111
  }
107
112
  if (this.useEOA) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socket.tech/dl-common",
3
- "version": "1.0.4-test.7",
3
+ "version": "1.0.4-test.9",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "description": "common utilities for socket data layer.",
@@ -52,7 +52,7 @@
52
52
  "@aws-sdk/client-sqs": "^3.421.0",
53
53
  "@ethersproject/providers": "^5.7.2",
54
54
  "@smithy/smithy-client": "^3.1.5",
55
- "@socket.tech/dl-core": "^2.17.0-test.0",
55
+ "@socket.tech/dl-core": "^2.17.0-test.1",
56
56
  "@socket.tech/ll-common": "^0.0.19",
57
57
  "async-redis": "^2.0.0",
58
58
  "aws-kms-ethers-signer": "^0.1.3",