@getpara/ethers-v6-integration 1.5.0 → 1.5.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.
- package/dist/cjs/index.js +92 -62
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/esm/index.js +93 -62
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -15,6 +15,26 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __async = (__this, __arguments, generator) => {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
var fulfilled = (value) => {
|
|
21
|
+
try {
|
|
22
|
+
step(generator.next(value));
|
|
23
|
+
} catch (e) {
|
|
24
|
+
reject(e);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var rejected = (value) => {
|
|
28
|
+
try {
|
|
29
|
+
step(generator.throw(value));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
reject(e);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
35
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
36
|
+
});
|
|
37
|
+
};
|
|
18
38
|
|
|
19
39
|
// src/index.ts
|
|
20
40
|
var src_exports = {};
|
|
@@ -41,8 +61,10 @@ var ParaEthersSigner = class _ParaEthersSigner extends import_ethers.ethers.Abst
|
|
|
41
61
|
this.para = para;
|
|
42
62
|
this.messageSigningTimeoutMs = messageSigningTimeoutMs;
|
|
43
63
|
}
|
|
44
|
-
|
|
45
|
-
return this
|
|
64
|
+
getAddress() {
|
|
65
|
+
return __async(this, null, function* () {
|
|
66
|
+
return this.para.wallets[this.currentWalletId].address;
|
|
67
|
+
});
|
|
46
68
|
}
|
|
47
69
|
connect(provider) {
|
|
48
70
|
return new _ParaEthersSigner(this.para, provider, this.currentWalletId);
|
|
@@ -52,74 +74,82 @@ var ParaEthersSigner = class _ParaEthersSigner extends import_ethers.ethers.Abst
|
|
|
52
74
|
*
|
|
53
75
|
* @param message - the message to be signed
|
|
54
76
|
**/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
77
|
+
signMessage(message) {
|
|
78
|
+
return __async(this, null, function* () {
|
|
79
|
+
const hashedMessage = import_ethers.ethers.hashMessage(message);
|
|
80
|
+
const base64HashedMessage = (0, import_core_sdk.hexStringToBase64)(hashedMessage);
|
|
81
|
+
const res = yield this.para.signMessage({
|
|
82
|
+
walletId: this.currentWalletId,
|
|
83
|
+
messageBase64: base64HashedMessage,
|
|
84
|
+
timeoutMs: this.messageSigningTimeoutMs
|
|
85
|
+
});
|
|
86
|
+
const signature = res.signature;
|
|
87
|
+
return `0x${signature}`;
|
|
62
88
|
});
|
|
63
|
-
const signature = res.signature;
|
|
64
|
-
return `0x${signature}`;
|
|
65
89
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
90
|
+
validateTx(tx) {
|
|
91
|
+
return __async(this, null, function* () {
|
|
92
|
+
const { to, from } = yield import_ethers.ethers.resolveProperties({
|
|
93
|
+
to: tx.to ? import_ethers.ethers.resolveAddress(tx.to, this.provider) : void 0,
|
|
94
|
+
from: tx.from ? import_ethers.ethers.resolveAddress(tx.from, this.provider) : void 0
|
|
95
|
+
});
|
|
96
|
+
if (to) {
|
|
97
|
+
tx.to = to;
|
|
98
|
+
}
|
|
99
|
+
if (from) {
|
|
100
|
+
tx.from = from;
|
|
101
|
+
}
|
|
102
|
+
if (tx.from) {
|
|
103
|
+
import_ethers.ethers.assertArgument(
|
|
104
|
+
import_ethers.ethers.getAddress(tx.from).toLowerCase() === (yield this.getAddress()).toLowerCase(),
|
|
105
|
+
"transaction from address mismatch",
|
|
106
|
+
"tx.from",
|
|
107
|
+
tx.from
|
|
108
|
+
);
|
|
109
|
+
delete tx.from;
|
|
110
|
+
}
|
|
111
|
+
return import_ethers.ethers.Transaction.from(tx);
|
|
70
112
|
});
|
|
71
|
-
if (to) {
|
|
72
|
-
tx.to = to;
|
|
73
|
-
}
|
|
74
|
-
if (from) {
|
|
75
|
-
tx.from = from;
|
|
76
|
-
}
|
|
77
|
-
if (tx.from) {
|
|
78
|
-
import_ethers.ethers.assertArgument(
|
|
79
|
-
import_ethers.ethers.getAddress(tx.from).toLowerCase() === (await this.getAddress()).toLowerCase(),
|
|
80
|
-
"transaction from address mismatch",
|
|
81
|
-
"tx.from",
|
|
82
|
-
tx.from
|
|
83
|
-
);
|
|
84
|
-
delete tx.from;
|
|
85
|
-
}
|
|
86
|
-
return import_ethers.ethers.Transaction.from(tx);
|
|
87
113
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
114
|
+
signTransaction(tx) {
|
|
115
|
+
return __async(this, null, function* () {
|
|
116
|
+
const txObj = yield this.validateTx(tx);
|
|
117
|
+
txObj.signature = {
|
|
118
|
+
r: "0x0",
|
|
119
|
+
s: "0x0",
|
|
120
|
+
v: 0
|
|
121
|
+
};
|
|
122
|
+
const res = yield this.para.signTransaction({
|
|
123
|
+
walletId: this.currentWalletId,
|
|
124
|
+
rlpEncodedTxBase64: (0, import_core_sdk.hexStringToBase64)(txObj.serialized),
|
|
125
|
+
chainId: `${txObj.chainId}`
|
|
126
|
+
});
|
|
127
|
+
const signature = res.signature;
|
|
128
|
+
const btx = import_ethers.ethers.Transaction.from(tx);
|
|
129
|
+
btx.signature = `0x${signature}`;
|
|
130
|
+
return btx.serialized;
|
|
99
131
|
});
|
|
100
|
-
const signature = res.signature;
|
|
101
|
-
const btx = import_ethers.ethers.Transaction.from(tx);
|
|
102
|
-
btx.signature = `0x${signature}`;
|
|
103
|
-
return btx.serialized;
|
|
104
132
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
import_ethers.ethers.
|
|
108
|
-
|
|
109
|
-
|
|
133
|
+
signTypedData(domain, types, value) {
|
|
134
|
+
return __async(this, null, function* () {
|
|
135
|
+
const populated = yield import_ethers.ethers.TypedDataEncoder.resolveNames(domain, types, value, (name) => __async(this, null, function* () {
|
|
136
|
+
import_ethers.ethers.assert(this.provider != null, "cannot resolve ENS names without a provider", "UNSUPPORTED_OPERATION", {
|
|
137
|
+
operation: "resolveName",
|
|
138
|
+
info: { name }
|
|
139
|
+
});
|
|
140
|
+
const address = yield this.provider.resolveName(name);
|
|
141
|
+
import_ethers.ethers.assert(address != null, "unconfigured ENS name", "UNCONFIGURED_NAME", {
|
|
142
|
+
value: name
|
|
143
|
+
});
|
|
144
|
+
return address;
|
|
145
|
+
}));
|
|
146
|
+
const res = yield this.para.signMessage({
|
|
147
|
+
walletId: this.currentWalletId,
|
|
148
|
+
messageBase64: (0, import_core_sdk.hexStringToBase64)(import_ethers.ethers.TypedDataEncoder.hash(populated.domain, types, populated.value))
|
|
110
149
|
});
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
value: name
|
|
114
|
-
});
|
|
115
|
-
return address;
|
|
116
|
-
});
|
|
117
|
-
const res = await this.para.signMessage({
|
|
118
|
-
walletId: this.currentWalletId,
|
|
119
|
-
messageBase64: (0, import_core_sdk.hexStringToBase64)(import_ethers.ethers.TypedDataEncoder.hash(populated.domain, types, populated.value))
|
|
150
|
+
const signature = res.signature;
|
|
151
|
+
return `0x${signature}`;
|
|
120
152
|
});
|
|
121
|
-
const signature = res.signature;
|
|
122
|
-
return `0x${signature}`;
|
|
123
153
|
}
|
|
124
154
|
};
|
|
125
155
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/cjs/index.js.br
CHANGED
|
Binary file
|
package/dist/cjs/index.js.gz
CHANGED
|
Binary file
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
1
22
|
// src/ethersSigner.ts
|
|
2
23
|
import { ethers } from "ethers";
|
|
3
24
|
import { hexStringToBase64 } from "@getpara/core-sdk";
|
|
@@ -16,8 +37,10 @@ var ParaEthersSigner = class _ParaEthersSigner extends ethers.AbstractSigner {
|
|
|
16
37
|
this.para = para;
|
|
17
38
|
this.messageSigningTimeoutMs = messageSigningTimeoutMs;
|
|
18
39
|
}
|
|
19
|
-
|
|
20
|
-
return this
|
|
40
|
+
getAddress() {
|
|
41
|
+
return __async(this, null, function* () {
|
|
42
|
+
return this.para.wallets[this.currentWalletId].address;
|
|
43
|
+
});
|
|
21
44
|
}
|
|
22
45
|
connect(provider) {
|
|
23
46
|
return new _ParaEthersSigner(this.para, provider, this.currentWalletId);
|
|
@@ -27,74 +50,82 @@ var ParaEthersSigner = class _ParaEthersSigner extends ethers.AbstractSigner {
|
|
|
27
50
|
*
|
|
28
51
|
* @param message - the message to be signed
|
|
29
52
|
**/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
53
|
+
signMessage(message) {
|
|
54
|
+
return __async(this, null, function* () {
|
|
55
|
+
const hashedMessage = ethers.hashMessage(message);
|
|
56
|
+
const base64HashedMessage = hexStringToBase64(hashedMessage);
|
|
57
|
+
const res = yield this.para.signMessage({
|
|
58
|
+
walletId: this.currentWalletId,
|
|
59
|
+
messageBase64: base64HashedMessage,
|
|
60
|
+
timeoutMs: this.messageSigningTimeoutMs
|
|
61
|
+
});
|
|
62
|
+
const signature = res.signature;
|
|
63
|
+
return `0x${signature}`;
|
|
37
64
|
});
|
|
38
|
-
const signature = res.signature;
|
|
39
|
-
return `0x${signature}`;
|
|
40
65
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
66
|
+
validateTx(tx) {
|
|
67
|
+
return __async(this, null, function* () {
|
|
68
|
+
const { to, from } = yield ethers.resolveProperties({
|
|
69
|
+
to: tx.to ? ethers.resolveAddress(tx.to, this.provider) : void 0,
|
|
70
|
+
from: tx.from ? ethers.resolveAddress(tx.from, this.provider) : void 0
|
|
71
|
+
});
|
|
72
|
+
if (to) {
|
|
73
|
+
tx.to = to;
|
|
74
|
+
}
|
|
75
|
+
if (from) {
|
|
76
|
+
tx.from = from;
|
|
77
|
+
}
|
|
78
|
+
if (tx.from) {
|
|
79
|
+
ethers.assertArgument(
|
|
80
|
+
ethers.getAddress(tx.from).toLowerCase() === (yield this.getAddress()).toLowerCase(),
|
|
81
|
+
"transaction from address mismatch",
|
|
82
|
+
"tx.from",
|
|
83
|
+
tx.from
|
|
84
|
+
);
|
|
85
|
+
delete tx.from;
|
|
86
|
+
}
|
|
87
|
+
return ethers.Transaction.from(tx);
|
|
45
88
|
});
|
|
46
|
-
if (to) {
|
|
47
|
-
tx.to = to;
|
|
48
|
-
}
|
|
49
|
-
if (from) {
|
|
50
|
-
tx.from = from;
|
|
51
|
-
}
|
|
52
|
-
if (tx.from) {
|
|
53
|
-
ethers.assertArgument(
|
|
54
|
-
ethers.getAddress(tx.from).toLowerCase() === (await this.getAddress()).toLowerCase(),
|
|
55
|
-
"transaction from address mismatch",
|
|
56
|
-
"tx.from",
|
|
57
|
-
tx.from
|
|
58
|
-
);
|
|
59
|
-
delete tx.from;
|
|
60
|
-
}
|
|
61
|
-
return ethers.Transaction.from(tx);
|
|
62
89
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
90
|
+
signTransaction(tx) {
|
|
91
|
+
return __async(this, null, function* () {
|
|
92
|
+
const txObj = yield this.validateTx(tx);
|
|
93
|
+
txObj.signature = {
|
|
94
|
+
r: "0x0",
|
|
95
|
+
s: "0x0",
|
|
96
|
+
v: 0
|
|
97
|
+
};
|
|
98
|
+
const res = yield this.para.signTransaction({
|
|
99
|
+
walletId: this.currentWalletId,
|
|
100
|
+
rlpEncodedTxBase64: hexStringToBase64(txObj.serialized),
|
|
101
|
+
chainId: `${txObj.chainId}`
|
|
102
|
+
});
|
|
103
|
+
const signature = res.signature;
|
|
104
|
+
const btx = ethers.Transaction.from(tx);
|
|
105
|
+
btx.signature = `0x${signature}`;
|
|
106
|
+
return btx.serialized;
|
|
74
107
|
});
|
|
75
|
-
const signature = res.signature;
|
|
76
|
-
const btx = ethers.Transaction.from(tx);
|
|
77
|
-
btx.signature = `0x${signature}`;
|
|
78
|
-
return btx.serialized;
|
|
79
108
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
ethers.
|
|
83
|
-
|
|
84
|
-
|
|
109
|
+
signTypedData(domain, types, value) {
|
|
110
|
+
return __async(this, null, function* () {
|
|
111
|
+
const populated = yield ethers.TypedDataEncoder.resolveNames(domain, types, value, (name) => __async(this, null, function* () {
|
|
112
|
+
ethers.assert(this.provider != null, "cannot resolve ENS names without a provider", "UNSUPPORTED_OPERATION", {
|
|
113
|
+
operation: "resolveName",
|
|
114
|
+
info: { name }
|
|
115
|
+
});
|
|
116
|
+
const address = yield this.provider.resolveName(name);
|
|
117
|
+
ethers.assert(address != null, "unconfigured ENS name", "UNCONFIGURED_NAME", {
|
|
118
|
+
value: name
|
|
119
|
+
});
|
|
120
|
+
return address;
|
|
121
|
+
}));
|
|
122
|
+
const res = yield this.para.signMessage({
|
|
123
|
+
walletId: this.currentWalletId,
|
|
124
|
+
messageBase64: hexStringToBase64(ethers.TypedDataEncoder.hash(populated.domain, types, populated.value))
|
|
85
125
|
});
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
value: name
|
|
89
|
-
});
|
|
90
|
-
return address;
|
|
91
|
-
});
|
|
92
|
-
const res = await this.para.signMessage({
|
|
93
|
-
walletId: this.currentWalletId,
|
|
94
|
-
messageBase64: hexStringToBase64(ethers.TypedDataEncoder.hash(populated.domain, types, populated.value))
|
|
126
|
+
const signature = res.signature;
|
|
127
|
+
return `0x${signature}`;
|
|
95
128
|
});
|
|
96
|
-
const signature = res.signature;
|
|
97
|
-
return `0x${signature}`;
|
|
98
129
|
}
|
|
99
130
|
};
|
|
100
131
|
export {
|
package/dist/esm/index.js.br
CHANGED
|
Binary file
|
package/dist/esm/index.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/ethers-v6-integration",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
7
7
|
"typings": "dist/types/index.d.ts",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@getpara/core-sdk": "1.5.
|
|
10
|
+
"@getpara/core-sdk": "1.5.1"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"types": "./dist/types/index.d.ts"
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "f77e0f5e162a1672219b01dbf7c06a3baadd2f35"
|
|
38
38
|
}
|