@socket.tech/dl-common 1.0.4-test.3 → 1.0.4-test.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/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);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider";
|
|
2
|
-
import { Deferrable } from "@ethersproject/properties";
|
|
1
|
+
import { type Provider, type TransactionRequest, type TransactionResponse } from "@ethersproject/abstract-provider";
|
|
2
|
+
import { type Deferrable } from "@ethersproject/properties";
|
|
3
3
|
import { SocketRelaySigner } from "../relaySigner";
|
|
4
|
-
import { Contract, Wallet } from "ethers";
|
|
4
|
+
import { Contract, type Wallet } from "ethers";
|
|
5
5
|
export declare const EIP712_SAFE_TX_TYPE: {
|
|
6
6
|
SafeTx: {
|
|
7
7
|
type: string;
|
|
@@ -15,17 +15,18 @@ export declare class SocketSigner extends SocketRelaySigner {
|
|
|
15
15
|
readonly safeWrapperAddress: string;
|
|
16
16
|
readonly relayUrl: string;
|
|
17
17
|
readonly relayerAPIKey: string;
|
|
18
|
-
readonly signingWallet
|
|
18
|
+
readonly signingWallet?: Wallet | undefined;
|
|
19
19
|
readonly useSafe: boolean;
|
|
20
20
|
readonly useEOA: boolean;
|
|
21
21
|
readonly sequential: boolean;
|
|
22
22
|
readonly isCritical: boolean;
|
|
23
23
|
readonly metadata: object;
|
|
24
|
-
readonly safeWrapperContract: Contract;
|
|
25
|
-
constructor(provider: Provider, chainId: number, safeAddress: string, safeWrapperAddress: string, relayUrl: string, relayerAPIKey: string, signingWallet
|
|
24
|
+
readonly safeWrapperContract: Contract | undefined;
|
|
25
|
+
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
26
|
setSigningWallet(signingWallet: Wallet): SocketRelaySigner;
|
|
27
27
|
setSafeWrapperAddress(safeWrapperAddress: string): SocketRelaySigner;
|
|
28
28
|
setSafeAddress(safeAddress: string): SocketRelaySigner;
|
|
29
29
|
getAddress(): Promise<string>;
|
|
30
|
+
address(): Promise<string>;
|
|
30
31
|
sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse>;
|
|
31
32
|
}
|
|
@@ -50,7 +50,8 @@ class SocketSigner extends relaySigner_1.SocketRelaySigner {
|
|
|
50
50
|
this.sequential = sequential;
|
|
51
51
|
this.isCritical = isCritical;
|
|
52
52
|
this.metadata = metadata;
|
|
53
|
-
|
|
53
|
+
if (this.safeWrapperAddress.length !== 0)
|
|
54
|
+
this.safeWrapperContract = new ethers_1.Contract(this.safeWrapperAddress, MultiSigWrapper_json_1.default, this.provider);
|
|
54
55
|
}
|
|
55
56
|
setSigningWallet(signingWallet) {
|
|
56
57
|
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);
|
|
@@ -62,55 +63,53 @@ class SocketSigner extends relaySigner_1.SocketRelaySigner {
|
|
|
62
63
|
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);
|
|
63
64
|
}
|
|
64
65
|
async getAddress() {
|
|
65
|
-
if (this.
|
|
66
|
+
if (this.signingWallet != null)
|
|
66
67
|
return await this.signingWallet.getAddress();
|
|
67
|
-
return super.getAddress();
|
|
68
|
+
return await super.getAddress();
|
|
69
|
+
}
|
|
70
|
+
async address() {
|
|
71
|
+
return await this.getAddress();
|
|
68
72
|
}
|
|
69
73
|
async sendTransaction(transaction) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
74
|
+
var _a, _b;
|
|
75
|
+
if (this.useSafe) {
|
|
76
|
+
if (this.safeAddress.length === 0 || this.safeAddress === ethers_1.constants.AddressZero)
|
|
77
|
+
throw new Error("safeAddress not provided");
|
|
78
|
+
if (this.safeWrapperContract == null)
|
|
79
|
+
throw new Error("safe wrapper not provided");
|
|
80
|
+
if (this.signingWallet == null)
|
|
81
|
+
throw new Error("signingWallet not provided");
|
|
82
|
+
const nonce = await this.safeWrapperContract.getNonce();
|
|
83
|
+
const contractData = {
|
|
84
|
+
to: transaction.to,
|
|
85
|
+
value: (_a = transaction.value) !== null && _a !== void 0 ? _a : 0,
|
|
86
|
+
data: (_b = transaction.data) !== null && _b !== void 0 ? _b : "0x",
|
|
87
|
+
operation: 0,
|
|
88
|
+
safeTxGas: 0,
|
|
89
|
+
baseGas: 0,
|
|
90
|
+
gasPrice: 0,
|
|
91
|
+
gasToken: ethers_1.constants.AddressZero,
|
|
92
|
+
refundReceiver: ethers_1.constants.AddressZero,
|
|
93
|
+
nonce,
|
|
94
|
+
};
|
|
95
|
+
const signature = await this.signingWallet._signTypedData({ verifyingContract: this.safeAddress, chainId: this.chainId }, exports.EIP712_SAFE_TX_TYPE, contractData);
|
|
96
|
+
// update to & data
|
|
97
|
+
transaction.data =
|
|
98
|
+
this.safeWrapperContract.interface.encodeFunctionData("storeOrRelaySignatures", [
|
|
99
|
+
contractData.to,
|
|
90
100
|
nonce,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
contractData.to,
|
|
97
|
-
nonce,
|
|
98
|
-
contractData.value,
|
|
99
|
-
contractData.data,
|
|
100
|
-
signature,
|
|
101
|
-
]);
|
|
102
|
-
transaction.to = this.safeWrapperAddress;
|
|
103
|
-
}
|
|
104
|
-
if (this.useEOA) {
|
|
105
|
-
if (!this.signingWallet)
|
|
106
|
-
throw new Error("signingWallet not provided");
|
|
107
|
-
return this.signingWallet.sendTransaction(transaction);
|
|
108
|
-
}
|
|
109
|
-
return super.sendTransaction(transaction);
|
|
101
|
+
contractData.value,
|
|
102
|
+
contractData.data,
|
|
103
|
+
signature,
|
|
104
|
+
]);
|
|
105
|
+
transaction.to = this.safeWrapperAddress;
|
|
110
106
|
}
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
if (this.useEOA) {
|
|
108
|
+
if (this.signingWallet == null)
|
|
109
|
+
throw new Error("signingWallet not provided");
|
|
110
|
+
return await this.signingWallet.sendTransaction(transaction);
|
|
113
111
|
}
|
|
112
|
+
return await super.sendTransaction(transaction);
|
|
114
113
|
}
|
|
115
114
|
}
|
|
116
115
|
exports.SocketSigner = SocketSigner;
|