@socket.tech/dl-common 1.0.4 → 1.0.5
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/constants/types.d.ts +11 -1
- package/dist/constants/types.js +9 -1
- package/dist/index.js +14 -30
- package/dist/models/message.d.ts +6 -1
- package/dist/models/message.js +11 -1
- package/dist/models/packet.d.ts +0 -1
- package/dist/models/packet.js +0 -1
- package/dist/utils/dataStructHelper.js +2 -2
- package/dist/utils/idUtils.js +2 -2
- package/dist/utils/s3Service.js +4 -3
- package/dist/utils/signer/address.d.ts +0 -1
- package/dist/utils/signer/asn1-parser.d.ts +0 -1
- package/dist/utils/signer/asn1-parser.js +2 -3
- package/dist/utils/signer/crypto.d.ts +0 -1
- package/dist/utils/signer/crypto.js +3 -4
- package/dist/utils/signer/kms-signer.d.ts +0 -1
- package/dist/utils/signer/signature.d.ts +0 -1
- package/dist/utils/signer/signer.d.ts +0 -1
- package/dist/utils/signer/socketSigner.d.ts +32 -0
- package/dist/utils/signer/socketSigner.js +121 -0
- package/package.json +3 -3
|
@@ -27,6 +27,13 @@ export declare const ErrorReasons: {
|
|
|
27
27
|
INBOUND_FAILURE: string;
|
|
28
28
|
LOW_GAS_LIMIT: string;
|
|
29
29
|
};
|
|
30
|
+
export declare enum SigPendingReason {
|
|
31
|
+
INVALID_MESSAGE_OUTBOUND_TX = "INVALID_MESSAGE_OUTBOUND_TX",
|
|
32
|
+
MISSING_SEAL_EVENT = "MISSING_SEAL_EVENT",
|
|
33
|
+
PENDING_CONFIRMATIONS = "PENDING_CONFIRMATIONS",
|
|
34
|
+
INALID_SEAL_TX = "INALID_SEAL_TX",
|
|
35
|
+
NO = "NO"
|
|
36
|
+
}
|
|
30
37
|
export declare class ServerError {
|
|
31
38
|
code: Omit<StatusCodes, StatusCodes.SUCCESS>;
|
|
32
39
|
message?: string;
|
|
@@ -97,6 +104,8 @@ export interface AttestRequest {
|
|
|
97
104
|
packetId: string;
|
|
98
105
|
root: string;
|
|
99
106
|
proposalCount: number;
|
|
107
|
+
outboundTxHash: string;
|
|
108
|
+
sealTxHash: string;
|
|
100
109
|
}
|
|
101
110
|
export interface AttestSuccess {
|
|
102
111
|
proposalValid: true;
|
|
@@ -110,7 +119,8 @@ export interface AttestFailure {
|
|
|
110
119
|
proposalValid: false;
|
|
111
120
|
packetId: string;
|
|
112
121
|
proposalCount: number;
|
|
113
|
-
|
|
122
|
+
tripReason: TripReason;
|
|
123
|
+
sigPendingReason: SigPendingReason;
|
|
114
124
|
}
|
|
115
125
|
export type AttestResponse = AttestSuccess | AttestFailure;
|
|
116
126
|
export type MessageData = {
|
package/dist/constants/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InternalServerError = exports.BadRequestError = exports.ServerError = exports.ErrorReasons = exports.RelayerAPIStatus = exports.InboundStatus = void 0;
|
|
3
|
+
exports.InternalServerError = exports.BadRequestError = exports.ServerError = exports.SigPendingReason = exports.ErrorReasons = exports.RelayerAPIStatus = exports.InboundStatus = void 0;
|
|
4
4
|
const enums_1 = require("./enums");
|
|
5
5
|
var InboundStatus;
|
|
6
6
|
(function (InboundStatus) {
|
|
@@ -23,6 +23,14 @@ exports.ErrorReasons = {
|
|
|
23
23
|
INBOUND_FAILURE: "INBOUND_FAILURE",
|
|
24
24
|
LOW_GAS_LIMIT: "LOW_GAS_LIMIT",
|
|
25
25
|
};
|
|
26
|
+
var SigPendingReason;
|
|
27
|
+
(function (SigPendingReason) {
|
|
28
|
+
SigPendingReason["INVALID_MESSAGE_OUTBOUND_TX"] = "INVALID_MESSAGE_OUTBOUND_TX";
|
|
29
|
+
SigPendingReason["MISSING_SEAL_EVENT"] = "MISSING_SEAL_EVENT";
|
|
30
|
+
SigPendingReason["PENDING_CONFIRMATIONS"] = "PENDING_CONFIRMATIONS";
|
|
31
|
+
SigPendingReason["INALID_SEAL_TX"] = "INALID_SEAL_TX";
|
|
32
|
+
SigPendingReason["NO"] = "NO";
|
|
33
|
+
})(SigPendingReason || (exports.SigPendingReason = SigPendingReason = {}));
|
|
26
34
|
class ServerError {
|
|
27
35
|
constructor(code, message) {
|
|
28
36
|
this.code = code;
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
};
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
32
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
17
|
__exportStar(require("./models"), exports);
|
|
34
18
|
__exportStar(require("./services"), exports);
|
package/dist/models/message.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export declare class Message extends Model {
|
|
|
42
42
|
executeSignature: string;
|
|
43
43
|
executeMsgGasLimit: string;
|
|
44
44
|
executeRelayStatus: ExecutionRelayStatus;
|
|
45
|
+
executeData: string;
|
|
45
46
|
}
|
|
46
47
|
export declare const MessageModel: {
|
|
47
48
|
id: {
|
|
@@ -60,6 +61,10 @@ export declare const MessageModel: {
|
|
|
60
61
|
destPlug: {
|
|
61
62
|
type: DataTypes.StringDataTypeConstructor;
|
|
62
63
|
};
|
|
64
|
+
executeData: {
|
|
65
|
+
type: DataTypes.TextDataTypeConstructor;
|
|
66
|
+
defaultValue: string;
|
|
67
|
+
};
|
|
63
68
|
messageId: {
|
|
64
69
|
type: DataTypes.StringDataTypeConstructor;
|
|
65
70
|
primaryKey: boolean;
|
|
@@ -159,7 +164,7 @@ export declare const MessageModel: {
|
|
|
159
164
|
defaultValue: boolean;
|
|
160
165
|
};
|
|
161
166
|
inboundRevertString: {
|
|
162
|
-
type: DataTypes.
|
|
167
|
+
type: DataTypes.TextDataTypeConstructor;
|
|
163
168
|
defaultValue: string;
|
|
164
169
|
};
|
|
165
170
|
};
|
package/dist/models/message.js
CHANGED
|
@@ -31,6 +31,10 @@ exports.MessageModel = {
|
|
|
31
31
|
destPlug: {
|
|
32
32
|
type: sequelize_1.DataTypes.STRING,
|
|
33
33
|
},
|
|
34
|
+
executeData: {
|
|
35
|
+
type: sequelize_1.DataTypes.TEXT,
|
|
36
|
+
defaultValue: "",
|
|
37
|
+
},
|
|
34
38
|
messageId: {
|
|
35
39
|
type: sequelize_1.DataTypes.STRING,
|
|
36
40
|
primaryKey: true,
|
|
@@ -130,7 +134,7 @@ exports.MessageModel = {
|
|
|
130
134
|
defaultValue: false,
|
|
131
135
|
},
|
|
132
136
|
inboundRevertString: {
|
|
133
|
-
type: sequelize_1.DataTypes.
|
|
137
|
+
type: sequelize_1.DataTypes.TEXT,
|
|
134
138
|
defaultValue: "",
|
|
135
139
|
},
|
|
136
140
|
};
|
|
@@ -168,6 +172,12 @@ function processStrings(message) {
|
|
|
168
172
|
}
|
|
169
173
|
if (message.rootHash)
|
|
170
174
|
message.rootHash = (0, utils_1.toLowerCase)(message.rootHash);
|
|
175
|
+
if (message.payload)
|
|
176
|
+
message.payload = message.payload.slice(0, 10004);
|
|
177
|
+
if (message.inboundRevertString)
|
|
178
|
+
message.inboundRevertString = message.inboundRevertString.slice(0, 1000);
|
|
179
|
+
if (message.executeData)
|
|
180
|
+
message.executeData = message.executeData.slice(0, 5000);
|
|
171
181
|
return message;
|
|
172
182
|
}
|
|
173
183
|
const addMessageHooks = () => {
|
package/dist/models/packet.d.ts
CHANGED
|
@@ -29,7 +29,6 @@ export declare enum AttestRelayStatus {
|
|
|
29
29
|
export declare enum TripReason {
|
|
30
30
|
SWITCHBOARD_MISMATCHED = "SWITCHBOARD_MISMATCHED",
|
|
31
31
|
ROOT_MISMATCHED = "ROOT_MISMATCHED",
|
|
32
|
-
MISSING_SEAL = "MISSING_SEAL",
|
|
33
32
|
NO = "NO"
|
|
34
33
|
}
|
|
35
34
|
export declare class Packet extends Model {
|
package/dist/models/packet.js
CHANGED
|
@@ -38,7 +38,6 @@ var TripReason;
|
|
|
38
38
|
(function (TripReason) {
|
|
39
39
|
TripReason["SWITCHBOARD_MISMATCHED"] = "SWITCHBOARD_MISMATCHED";
|
|
40
40
|
TripReason["ROOT_MISMATCHED"] = "ROOT_MISMATCHED";
|
|
41
|
-
TripReason["MISSING_SEAL"] = "MISSING_SEAL";
|
|
42
41
|
TripReason["NO"] = "NO";
|
|
43
42
|
})(TripReason || (exports.TripReason = TripReason = {}));
|
|
44
43
|
class Packet extends sequelize_1.Model {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MAX_PAYLOAD_SIZE = void 0;
|
|
4
|
+
exports.chunks = chunks;
|
|
4
5
|
exports.MAX_PAYLOAD_SIZE = 10 * 1024; // max is 24.5 kb, left some buffer for function and batch encoding
|
|
5
6
|
function* chunks(arr, n) {
|
|
6
7
|
for (let i = 0; i < arr.length; i += n) {
|
|
7
8
|
yield arr.slice(i, i + n);
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
|
-
exports.chunks = chunks;
|
package/dist/utils/idUtils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.packPacketId = exports.unpackMessageId = exports.unpackPacketId = void 0;
|
|
4
|
+
exports.encodePacketId = encodePacketId;
|
|
4
5
|
const ethers_1 = require("ethers");
|
|
5
6
|
const address_1 = require("./address");
|
|
6
7
|
const utils_1 = require("ethers/lib/utils");
|
|
@@ -47,4 +48,3 @@ function encodePacketId(chainSlug, capacitorAddress, packetCount) {
|
|
|
47
48
|
const resultHex = encodedValue.toString(16).padStart(64, "0");
|
|
48
49
|
return "0x" + resultHex;
|
|
49
50
|
}
|
|
50
|
-
exports.encodePacketId = encodePacketId;
|
package/dist/utils/s3Service.js
CHANGED
|
@@ -35,9 +35,10 @@ const getFileFromS3 = async (bucket, filePath) => {
|
|
|
35
35
|
};
|
|
36
36
|
exports.getFileFromS3 = getFileFromS3;
|
|
37
37
|
const getS3Config = async (deploymentMode, region = "us-east-1", account = __1.Accounts.dl) => {
|
|
38
|
-
const S3_BUCKET_NAME = deploymentMode
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const S3_BUCKET_NAME = deploymentMode === dl_core_1.DeploymentMode.SURGE ||
|
|
39
|
+
deploymentMode == dl_core_1.DeploymentMode.PROD
|
|
40
|
+
? `socket-${account}-prod`
|
|
41
|
+
: `socket-ll-${deploymentMode}`;
|
|
41
42
|
const S3_RPC_CONFIG_FILE_PATH = deploymentMode + "RpcConfig.json";
|
|
42
43
|
(0, exports.initS3Client)(region);
|
|
43
44
|
return await (0, exports.getFileFromS3)(S3_BUCKET_NAME, S3_RPC_CONFIG_FILE_PATH);
|
|
@@ -23,7 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.parsePublicKey = parsePublicKey;
|
|
27
|
+
exports.parseSignature = parseSignature;
|
|
27
28
|
const asn1js = __importStar(require("asn1js"));
|
|
28
29
|
function toArrayBuffer(buffer) {
|
|
29
30
|
const ab = new ArrayBuffer(buffer.length);
|
|
@@ -47,7 +48,6 @@ function parsePublicKey(buf) {
|
|
|
47
48
|
const value = values[1];
|
|
48
49
|
return Buffer.from(value.valueBlock.valueHex.slice(1));
|
|
49
50
|
}
|
|
50
|
-
exports.parsePublicKey = parsePublicKey;
|
|
51
51
|
/**
|
|
52
52
|
* Parse signature from the given signature.
|
|
53
53
|
* @param buf The buffer of the signature which following ASN.1 format.
|
|
@@ -77,4 +77,3 @@ function parseSignature(buf) {
|
|
|
77
77
|
});
|
|
78
78
|
return { r, s };
|
|
79
79
|
}
|
|
80
|
-
exports.parseSignature = parseSignature;
|
|
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.removeHexadecimalPrefix = removeHexadecimalPrefix;
|
|
7
|
+
exports.addHexadecimalPrefix = addHexadecimalPrefix;
|
|
8
|
+
exports.recover = recover;
|
|
7
9
|
const secp256k1_1 = __importDefault(require("secp256k1"));
|
|
8
10
|
function removeHexadecimalPrefix(x) {
|
|
9
11
|
if (x.startsWith("0x")) {
|
|
@@ -11,14 +13,12 @@ function removeHexadecimalPrefix(x) {
|
|
|
11
13
|
}
|
|
12
14
|
return x;
|
|
13
15
|
}
|
|
14
|
-
exports.removeHexadecimalPrefix = removeHexadecimalPrefix;
|
|
15
16
|
function addHexadecimalPrefix(x) {
|
|
16
17
|
if (x.startsWith("0x")) {
|
|
17
18
|
return x;
|
|
18
19
|
}
|
|
19
20
|
return `0x${x}`;
|
|
20
21
|
}
|
|
21
|
-
exports.addHexadecimalPrefix = addHexadecimalPrefix;
|
|
22
22
|
function recover(digest, r, s, v) {
|
|
23
23
|
if (r.length !== 32) {
|
|
24
24
|
throw new Error("invalid signature length");
|
|
@@ -31,4 +31,3 @@ function recover(digest, r, s, v) {
|
|
|
31
31
|
.slice(1);
|
|
32
32
|
return Buffer.from(publicKey);
|
|
33
33
|
}
|
|
34
|
-
exports.recover = recover;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Provider, type TransactionRequest, type TransactionResponse } from "@ethersproject/abstract-provider";
|
|
2
|
+
import { type Deferrable } from "@ethersproject/properties";
|
|
3
|
+
import { SocketRelaySigner } from "../relaySigner";
|
|
4
|
+
import { Contract, type Wallet } from "ethers";
|
|
5
|
+
export declare const EIP712_SAFE_TX_TYPE: {
|
|
6
|
+
SafeTx: {
|
|
7
|
+
type: string;
|
|
8
|
+
name: string;
|
|
9
|
+
}[];
|
|
10
|
+
};
|
|
11
|
+
export declare class SocketSigner extends SocketRelaySigner {
|
|
12
|
+
readonly provider: Provider;
|
|
13
|
+
readonly chainId: number;
|
|
14
|
+
readonly safeAddress: string;
|
|
15
|
+
readonly safeWrapperAddress: string;
|
|
16
|
+
readonly relayUrl: string;
|
|
17
|
+
readonly relayerAPIKey: string;
|
|
18
|
+
readonly signingWallet?: Wallet | undefined;
|
|
19
|
+
readonly useSafe: boolean;
|
|
20
|
+
readonly useEOA: boolean;
|
|
21
|
+
readonly sequential: boolean;
|
|
22
|
+
readonly isCritical: boolean;
|
|
23
|
+
readonly metadata: object;
|
|
24
|
+
readonly safeWrapperContract: Contract;
|
|
25
|
+
readonly address: string;
|
|
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);
|
|
27
|
+
setSigningWallet(signingWallet: Wallet): SocketRelaySigner;
|
|
28
|
+
setSafeWrapperAddress(safeWrapperAddress: string): SocketRelaySigner;
|
|
29
|
+
setSafeAddress(safeAddress: string): SocketRelaySigner;
|
|
30
|
+
getAddress(): Promise<string>;
|
|
31
|
+
sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SocketSigner = exports.EIP712_SAFE_TX_TYPE = void 0;
|
|
7
|
+
const relaySigner_1 = require("../relaySigner");
|
|
8
|
+
const ethers_1 = require("ethers");
|
|
9
|
+
const MultiSigWrapper_json_1 = __importDefault(require("@socket.tech/dl-core/artifacts/abi/MultiSigWrapper.json"));
|
|
10
|
+
exports.EIP712_SAFE_TX_TYPE = {
|
|
11
|
+
// "SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)"
|
|
12
|
+
SafeTx: [
|
|
13
|
+
{ type: "address", name: "to" },
|
|
14
|
+
{ type: "uint256", name: "value" },
|
|
15
|
+
{ type: "bytes", name: "data" },
|
|
16
|
+
{ type: "uint8", name: "operation" },
|
|
17
|
+
{ type: "uint256", name: "safeTxGas" },
|
|
18
|
+
{ type: "uint256", name: "baseGas" },
|
|
19
|
+
{ type: "uint256", name: "gasPrice" },
|
|
20
|
+
{ type: "address", name: "gasToken" },
|
|
21
|
+
{ type: "address", name: "refundReceiver" },
|
|
22
|
+
{ type: "uint256", name: "nonce" },
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
class SocketSigner extends relaySigner_1.SocketRelaySigner {
|
|
26
|
+
constructor(provider, chainId,
|
|
27
|
+
// address of safe
|
|
28
|
+
safeAddress,
|
|
29
|
+
// address of safe wrapper to store sign
|
|
30
|
+
safeWrapperAddress, relayUrl, relayerAPIKey,
|
|
31
|
+
// wallet for signing safe hash data
|
|
32
|
+
signingWallet,
|
|
33
|
+
// if you want to relay tx to wrapper
|
|
34
|
+
useSafe = false,
|
|
35
|
+
// if you want to relay tx using EOA, otherwise it will use relayer
|
|
36
|
+
useEOA = false, sequential = false,
|
|
37
|
+
// if isCritical is set to true, will try multiple relayers
|
|
38
|
+
// to get the transaction included
|
|
39
|
+
isCritical = false, metadata = {}) {
|
|
40
|
+
super(provider, chainId, relayUrl, relayerAPIKey, sequential, isCritical, metadata);
|
|
41
|
+
this.provider = provider;
|
|
42
|
+
this.chainId = chainId;
|
|
43
|
+
this.safeAddress = safeAddress;
|
|
44
|
+
this.safeWrapperAddress = safeWrapperAddress;
|
|
45
|
+
this.relayUrl = relayUrl;
|
|
46
|
+
this.relayerAPIKey = relayerAPIKey;
|
|
47
|
+
this.signingWallet = signingWallet;
|
|
48
|
+
this.useSafe = useSafe;
|
|
49
|
+
this.useEOA = useEOA;
|
|
50
|
+
this.sequential = sequential;
|
|
51
|
+
this.isCritical = isCritical;
|
|
52
|
+
this.metadata = metadata;
|
|
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)
|
|
59
|
+
this.safeWrapperContract = new ethers_1.Contract(this.safeWrapperAddress, MultiSigWrapper_json_1.default, this.provider);
|
|
60
|
+
}
|
|
61
|
+
setSigningWallet(signingWallet) {
|
|
62
|
+
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);
|
|
63
|
+
}
|
|
64
|
+
setSafeWrapperAddress(safeWrapperAddress) {
|
|
65
|
+
return new SocketSigner(this.provider, this.chainId, this.safeAddress, safeWrapperAddress, this.relayUrl, this.relayerAPIKey, this.signingWallet, this.useSafe, this.useEOA, this.sequential, this.isCritical, this.metadata);
|
|
66
|
+
}
|
|
67
|
+
setSafeAddress(safeAddress) {
|
|
68
|
+
return new SocketSigner(this.provider, this.chainId, safeAddress, this.safeWrapperAddress, this.relayUrl, this.relayerAPIKey, this.signingWallet, this.useSafe, this.useEOA, this.sequential, this.isCritical, this.metadata);
|
|
69
|
+
}
|
|
70
|
+
async getAddress() {
|
|
71
|
+
if (this.signingWallet != null)
|
|
72
|
+
return this.signingWallet.address;
|
|
73
|
+
return await super.getAddress();
|
|
74
|
+
}
|
|
75
|
+
async sendTransaction(transaction) {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
if (this.useSafe) {
|
|
78
|
+
if (this.safeAddress.length === 0 ||
|
|
79
|
+
this.safeAddress === ethers_1.constants.AddressZero)
|
|
80
|
+
throw new Error("safeAddress not provided");
|
|
81
|
+
if (this.safeWrapperContract == null)
|
|
82
|
+
throw new Error("safe wrapper not provided");
|
|
83
|
+
if (this.signingWallet == null)
|
|
84
|
+
throw new Error("signingWallet not provided");
|
|
85
|
+
const signerAddress = await this.getAddress();
|
|
86
|
+
let nonce = await this.safeWrapperContract.lastNonce(signerAddress);
|
|
87
|
+
if (Number(nonce) !== 0)
|
|
88
|
+
nonce = Number(nonce) + 1;
|
|
89
|
+
const contractData = {
|
|
90
|
+
to: transaction.to,
|
|
91
|
+
value: (_a = transaction.value) !== null && _a !== void 0 ? _a : 0,
|
|
92
|
+
data: (_b = transaction.data) !== null && _b !== void 0 ? _b : "0x",
|
|
93
|
+
operation: 0,
|
|
94
|
+
safeTxGas: 0,
|
|
95
|
+
baseGas: 0,
|
|
96
|
+
gasPrice: 0,
|
|
97
|
+
gasToken: ethers_1.constants.AddressZero,
|
|
98
|
+
refundReceiver: ethers_1.constants.AddressZero,
|
|
99
|
+
nonce,
|
|
100
|
+
};
|
|
101
|
+
const signature = await this.signingWallet._signTypedData({ verifyingContract: this.safeAddress, chainId: this.chainId }, exports.EIP712_SAFE_TX_TYPE, contractData);
|
|
102
|
+
// update to & data
|
|
103
|
+
transaction.data = this.safeWrapperContract.interface.encodeFunctionData("storeOrRelaySignatures", [
|
|
104
|
+
this.signingWallet.address,
|
|
105
|
+
contractData.to,
|
|
106
|
+
nonce,
|
|
107
|
+
contractData.value,
|
|
108
|
+
contractData.data,
|
|
109
|
+
signature,
|
|
110
|
+
]);
|
|
111
|
+
transaction.to = this.safeWrapperAddress;
|
|
112
|
+
}
|
|
113
|
+
if (this.useEOA) {
|
|
114
|
+
if (this.signingWallet == null)
|
|
115
|
+
throw new Error("signingWallet not provided");
|
|
116
|
+
return await this.signingWallet.sendTransaction(transaction);
|
|
117
|
+
}
|
|
118
|
+
return await super.sendTransaction(transaction);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.SocketSigner = SocketSigner;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socket.tech/dl-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"description": "common utilities for socket data layer.",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"start": "serverless offline start --reloadHandler -s dev",
|
|
21
21
|
"start:dev": "serverless offline start -s dev",
|
|
22
|
-
"deploy": "npm run lint && npx sls deploy -s dev --verbose",
|
|
22
|
+
"deploy": "tsc && npm run lint && export AWS_PROFILE=lldev && npx sls deploy -s dev --verbose",
|
|
23
23
|
"deploy:prod": "tsc && npm run lint && export AWS_PROFILE=llprod && npx sls deploy -s prod --verbose",
|
|
24
24
|
"deploy:surge": "npx sls deploy -s surge --verbose",
|
|
25
25
|
"build": "tsc --project lib.tsconfig.json",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@aws-sdk/client-secrets-manager": "^3.433.0",
|
|
52
52
|
"@aws-sdk/client-sqs": "^3.421.0",
|
|
53
53
|
"@ethersproject/providers": "^5.7.2",
|
|
54
|
-
"@smithy/smithy-client": "^3.1.
|
|
54
|
+
"@smithy/smithy-client": "^3.1.5",
|
|
55
55
|
"@socket.tech/dl-core": "^2.7.0",
|
|
56
56
|
"@socket.tech/ll-common": "^0.0.19",
|
|
57
57
|
"async-redis": "^2.0.0",
|