@socket.tech/dl-common 1.0.4-test.10 → 1.0.4-test.11
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.js
CHANGED
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (
|
|
9
|
+
!desc ||
|
|
10
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
11
|
+
) {
|
|
12
|
+
desc = {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return m[k];
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}
|
|
21
|
+
: function (o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
});
|
|
25
|
+
var __exportStar =
|
|
26
|
+
(this && this.__exportStar) ||
|
|
27
|
+
function (m, exports) {
|
|
28
|
+
for (var p in m)
|
|
29
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
30
|
+
__createBinding(exports, m, p);
|
|
31
|
+
};
|
|
16
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
33
|
__exportStar(require("./models"), exports);
|
|
18
34
|
__exportStar(require("./services"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Provider, type TransactionRequest, type TransactionResponse } from "@ethersproject/abstract-provider";
|
|
2
2
|
import { type Deferrable } from "@ethersproject/properties";
|
|
3
3
|
import { SocketRelaySigner } from "../relaySigner";
|
|
4
|
-
import { Contract, type Wallet } from "ethers";
|
|
4
|
+
import { Contract, ethers, type Wallet } from "ethers";
|
|
5
5
|
export declare const EIP712_SAFE_TX_TYPE: {
|
|
6
6
|
SafeTx: {
|
|
7
7
|
type: string;
|
|
@@ -22,6 +22,7 @@ export declare class SocketSigner extends SocketRelaySigner {
|
|
|
22
22
|
readonly isCritical: boolean;
|
|
23
23
|
readonly metadata: object;
|
|
24
24
|
readonly safeWrapperContract: Contract;
|
|
25
|
+
readonly safeContract: Contract;
|
|
25
26
|
readonly address: string;
|
|
26
27
|
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);
|
|
27
28
|
setSigningWallet(signingWallet: Wallet): SocketRelaySigner;
|
|
@@ -29,4 +30,6 @@ export declare class SocketSigner extends SocketRelaySigner {
|
|
|
29
30
|
setSafeAddress(safeAddress: string): SocketRelaySigner;
|
|
30
31
|
getAddress(): Promise<string>;
|
|
31
32
|
sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse>;
|
|
33
|
+
signMessage(message: ethers.utils.Bytes | string): Promise<string>;
|
|
34
|
+
isTxHashSubmitted(transaction: Deferrable<TransactionRequest>): Promise<boolean>;
|
|
32
35
|
}
|
|
@@ -7,6 +7,8 @@ exports.SocketSigner = exports.EIP712_SAFE_TX_TYPE = void 0;
|
|
|
7
7
|
const relaySigner_1 = require("../relaySigner");
|
|
8
8
|
const ethers_1 = require("ethers");
|
|
9
9
|
const MultiSigWrapper_json_1 = __importDefault(require("@socket.tech/dl-core/artifacts/abi/MultiSigWrapper.json"));
|
|
10
|
+
const Safe_json_1 = __importDefault(require("@socket.tech/dl-core/artifacts/abi/Safe.json"));
|
|
11
|
+
const utils_1 = require("ethers/lib/utils");
|
|
10
12
|
exports.EIP712_SAFE_TX_TYPE = {
|
|
11
13
|
// "SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)"
|
|
12
14
|
SafeTx: [
|
|
@@ -57,6 +59,9 @@ class SocketSigner extends relaySigner_1.SocketRelaySigner {
|
|
|
57
59
|
if (this.safeWrapperAddress.length !== 0 ||
|
|
58
60
|
this.safeWrapperAddress !== ethers_1.constants.AddressZero)
|
|
59
61
|
this.safeWrapperContract = new ethers_1.Contract(this.safeWrapperAddress, MultiSigWrapper_json_1.default, this.provider);
|
|
62
|
+
if (this.safeAddress.length !== 0 ||
|
|
63
|
+
this.safeAddress !== ethers_1.constants.AddressZero)
|
|
64
|
+
this.safeContract = new ethers_1.Contract(this.safeAddress, Safe_json_1.default, this.provider);
|
|
60
65
|
}
|
|
61
66
|
setSigningWallet(signingWallet) {
|
|
62
67
|
return new SocketSigner(this.provider, this.chainId, this.safeAddress, this.safeWrapperAddress, this.relayUrl, this.relayerAPIKey, signingWallet, this.useSafe, this.useEOA, this.sequential, this.isCritical, this.metadata);
|
|
@@ -83,9 +88,15 @@ class SocketSigner extends relaySigner_1.SocketRelaySigner {
|
|
|
83
88
|
if (this.signingWallet == null)
|
|
84
89
|
throw new Error("signingWallet not provided");
|
|
85
90
|
const signerAddress = await this.getAddress();
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
const safeNonce = Number(await this.safeContract.nonce());
|
|
92
|
+
let nonce = Number(await this.safeWrapperContract.lastNonce(signerAddress));
|
|
93
|
+
if (safeNonce != 0) {
|
|
94
|
+
nonce = safeNonce > nonce ? safeNonce : nonce + 1;
|
|
95
|
+
}
|
|
96
|
+
else if (nonce !== 0)
|
|
97
|
+
nonce++;
|
|
98
|
+
if (await this.isTxHashSubmitted(transaction))
|
|
99
|
+
throw new Error("tx already submitted!");
|
|
89
100
|
const contractData = {
|
|
90
101
|
to: transaction.to,
|
|
91
102
|
value: (_a = transaction.value) !== null && _a !== void 0 ? _a : 0,
|
|
@@ -117,5 +128,19 @@ class SocketSigner extends relaySigner_1.SocketRelaySigner {
|
|
|
117
128
|
}
|
|
118
129
|
return await super.sendTransaction(transaction);
|
|
119
130
|
}
|
|
131
|
+
async signMessage(message) {
|
|
132
|
+
if (!this.signingWallet)
|
|
133
|
+
throw Error("No Signing Wallet found!");
|
|
134
|
+
return await this.signingWallet.signMessage(message);
|
|
135
|
+
}
|
|
136
|
+
async isTxHashSubmitted(transaction) {
|
|
137
|
+
var _a, _b;
|
|
138
|
+
if (!this.signingWallet)
|
|
139
|
+
throw Error("No Signing Wallet found!");
|
|
140
|
+
const dataHash = (0, utils_1.keccak256)(utils_1.defaultAbiCoder.encode(["address", "uint256", "bytes"], [transaction.to, (_a = transaction.value) !== null && _a !== void 0 ? _a : 0, (_b = transaction.data) !== null && _b !== void 0 ? _b : "0x"]));
|
|
141
|
+
const safeParams = await this.safeWrapperContract.safeParams(dataHash, this.signingWallet.address);
|
|
142
|
+
console.log(safeParams, "isTxSubmitted");
|
|
143
|
+
return safeParams[1] !== "0x";
|
|
144
|
+
}
|
|
120
145
|
}
|
|
121
146
|
exports.SocketSigner = SocketSigner;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socket.tech/dl-common",
|
|
3
|
-
"version": "1.0.4-test.
|
|
3
|
+
"version": "1.0.4-test.11",
|
|
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.
|
|
55
|
+
"@socket.tech/dl-core": "^2.17.0-test.3",
|
|
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",
|