@getpara/ethers-v6-integration 2.0.0-dev.1 → 2.0.0-dev.2

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.
@@ -0,0 +1,154 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
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
+ };
38
+ var ethersSigner_exports = {};
39
+ __export(ethersSigner_exports, {
40
+ ParaEthersSigner: () => ParaEthersSigner
41
+ });
42
+ module.exports = __toCommonJS(ethersSigner_exports);
43
+ var import_ethers = require("ethers");
44
+ var import_core_sdk = require("@getpara/core-sdk");
45
+ class ParaEthersSigner extends import_ethers.ethers.AbstractSigner {
46
+ /**
47
+ * Signs a message.
48
+ *
49
+ * @param para - the ParaCore instance
50
+ * @param provider - the ethers provider to use. If not present, will use the default ethers.Provider.
51
+ * @param walletId - optional wallet ID to use. If not present, will use the first wallet found.
52
+ * @param messageSigningTimeoutMs - optional timeout in milliseconds. If not present, defaults to 30 seconds.
53
+ **/
54
+ constructor(para, provider, walletId, messageSigningTimeoutMs) {
55
+ super(provider);
56
+ this.currentWalletId = para.findWalletId(walletId, { type: ["EVM"] });
57
+ this.para = para;
58
+ this.messageSigningTimeoutMs = messageSigningTimeoutMs;
59
+ }
60
+ getAddress() {
61
+ return __async(this, null, function* () {
62
+ return this.para.wallets[this.currentWalletId].address;
63
+ });
64
+ }
65
+ connect(provider) {
66
+ return new ParaEthersSigner(this.para, provider, this.currentWalletId);
67
+ }
68
+ /**
69
+ * Signs a message.
70
+ *
71
+ * @param message - the message to be signed
72
+ **/
73
+ signMessage(message) {
74
+ return __async(this, null, function* () {
75
+ const hashedMessage = import_ethers.ethers.hashMessage(message);
76
+ const base64HashedMessage = (0, import_core_sdk.hexStringToBase64)(hashedMessage);
77
+ const res = yield this.para.signMessage({
78
+ walletId: this.currentWalletId,
79
+ messageBase64: base64HashedMessage,
80
+ timeoutMs: this.messageSigningTimeoutMs
81
+ });
82
+ const signature = res.signature;
83
+ return `0x${signature}`;
84
+ });
85
+ }
86
+ validateTx(tx) {
87
+ return __async(this, null, function* () {
88
+ const { to, from } = yield import_ethers.ethers.resolveProperties({
89
+ to: tx.to ? import_ethers.ethers.resolveAddress(tx.to, this.provider) : void 0,
90
+ from: tx.from ? import_ethers.ethers.resolveAddress(tx.from, this.provider) : void 0
91
+ });
92
+ if (to) {
93
+ tx.to = to;
94
+ }
95
+ if (from) {
96
+ tx.from = from;
97
+ }
98
+ if (tx.from) {
99
+ import_ethers.ethers.assertArgument(
100
+ import_ethers.ethers.getAddress(tx.from).toLowerCase() === (yield this.getAddress()).toLowerCase(),
101
+ "transaction from address mismatch",
102
+ "tx.from",
103
+ tx.from
104
+ );
105
+ delete tx.from;
106
+ }
107
+ return import_ethers.ethers.Transaction.from(tx);
108
+ });
109
+ }
110
+ signTransaction(tx) {
111
+ return __async(this, null, function* () {
112
+ const txObj = yield this.validateTx(tx);
113
+ txObj.signature = {
114
+ r: "0x0",
115
+ s: "0x0",
116
+ v: 0
117
+ };
118
+ const res = yield this.para.signTransaction({
119
+ walletId: this.currentWalletId,
120
+ rlpEncodedTxBase64: (0, import_core_sdk.hexStringToBase64)(txObj.serialized),
121
+ chainId: `${txObj.chainId}`
122
+ });
123
+ const signature = res.signature;
124
+ const btx = import_ethers.ethers.Transaction.from(tx);
125
+ btx.signature = `0x${signature}`;
126
+ return btx.serialized;
127
+ });
128
+ }
129
+ signTypedData(domain, types, value) {
130
+ return __async(this, null, function* () {
131
+ const populated = yield import_ethers.ethers.TypedDataEncoder.resolveNames(domain, types, value, (name) => __async(this, null, function* () {
132
+ import_ethers.ethers.assert(this.provider != null, "cannot resolve ENS names without a provider", "UNSUPPORTED_OPERATION", {
133
+ operation: "resolveName",
134
+ info: { name }
135
+ });
136
+ const address = yield this.provider.resolveName(name);
137
+ import_ethers.ethers.assert(address != null, "unconfigured ENS name", "UNCONFIGURED_NAME", {
138
+ value: name
139
+ });
140
+ return address;
141
+ }));
142
+ const res = yield this.para.signMessage({
143
+ walletId: this.currentWalletId,
144
+ messageBase64: (0, import_core_sdk.hexStringToBase64)(import_ethers.ethers.TypedDataEncoder.hash(populated.domain, types, populated.value))
145
+ });
146
+ const signature = res.signature;
147
+ return `0x${signature}`;
148
+ });
149
+ }
150
+ }
151
+ // Annotate the CommonJS export names for ESM import in node:
152
+ 0 && (module.exports = {
153
+ ParaEthersSigner
154
+ });
package/dist/cjs/index.js CHANGED
@@ -2,10 +2,6 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
5
  var __copyProps = (to, from, except, desc) => {
10
6
  if (from && typeof from === "object" || typeof from === "function") {
11
7
  for (let key of __getOwnPropNames(from))
@@ -14,145 +10,14 @@ var __copyProps = (to, from, except, desc) => {
14
10
  }
15
11
  return to;
16
12
  };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
14
  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
- };
38
-
39
- // src/index.ts
40
15
  var src_exports = {};
41
- __export(src_exports, {
42
- ParaEthersSigner: () => ParaEthersSigner
43
- });
44
16
  module.exports = __toCommonJS(src_exports);
45
-
46
- // src/ethersSigner.ts
47
- var import_ethers = require("ethers");
48
- var import_core_sdk = require("@getpara/core-sdk");
49
- var ParaEthersSigner = class _ParaEthersSigner extends import_ethers.ethers.AbstractSigner {
50
- /**
51
- * Signs a message.
52
- *
53
- * @param para - the ParaCore instance
54
- * @param provider - the ethers provider to use. If not present, will use the default ethers.Provider.
55
- * @param walletId - optional wallet ID to use. If not present, will use the first wallet found.
56
- * @param messageSigningTimeoutMs - optional timeout in milliseconds. If not present, defaults to 30 seconds.
57
- **/
58
- constructor(para, provider, walletId, messageSigningTimeoutMs) {
59
- super(provider);
60
- this.currentWalletId = para.findWalletId(walletId, { type: ["EVM"] });
61
- this.para = para;
62
- this.messageSigningTimeoutMs = messageSigningTimeoutMs;
63
- }
64
- getAddress() {
65
- return __async(this, null, function* () {
66
- return this.para.wallets[this.currentWalletId].address;
67
- });
68
- }
69
- connect(provider) {
70
- return new _ParaEthersSigner(this.para, provider, this.currentWalletId);
71
- }
72
- /**
73
- * Signs a message.
74
- *
75
- * @param message - the message to be signed
76
- **/
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}`;
88
- });
89
- }
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);
112
- });
113
- }
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;
131
- });
132
- }
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))
149
- });
150
- const signature = res.signature;
151
- return `0x${signature}`;
152
- });
153
- }
154
- };
17
+ __reExport(src_exports, require("./ethersSigner.js"), module.exports);
18
+ __reExport(src_exports, require("./utils.js"), module.exports);
155
19
  // Annotate the CommonJS export names for ESM import in node:
156
20
  0 && (module.exports = {
157
- ParaEthersSigner
21
+ ...require("./ethersSigner.js"),
22
+ ...require("./utils.js")
158
23
  });
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,68 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
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
+ };
38
+ var utils_exports = {};
39
+ __export(utils_exports, {
40
+ createTestTransaction: () => createTestTransaction
41
+ });
42
+ module.exports = __toCommonJS(utils_exports);
43
+ var import_ethers = require("ethers");
44
+ function createTestTransaction(para, walletId) {
45
+ return __async(this, null, function* () {
46
+ walletId = para.findWalletId(walletId, { type: ["EVM"] });
47
+ const wallet = para.wallets[walletId];
48
+ const provider = new import_ethers.ethers.JsonRpcProvider("https://eth-sepolia.g.alchemy.com/v2/FPFN1k9stEKGzGNnoIveEuEhuDygTisx");
49
+ const address = para.getDisplayAddress(wallet.id, { addressType: "EVM" });
50
+ const eip1559Fees = yield provider.getFeeData();
51
+ const nonce = wallet.address ? yield provider.getTransactionCount(address) : void 0;
52
+ return import_ethers.ethers.Transaction.from({
53
+ to: address,
54
+ value: import_ethers.ethers.parseUnits("0.01", "ether"),
55
+ chainId: "11155111",
56
+ type: 2,
57
+ nonce,
58
+ gasLimit: 1e5,
59
+ gasPrice: eip1559Fees.gasPrice,
60
+ maxFeePerGas: eip1559Fees.maxFeePerGas,
61
+ maxPriorityFeePerGas: eip1559Fees.maxPriorityFeePerGas
62
+ });
63
+ });
64
+ }
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ createTestTransaction
68
+ });
@@ -0,0 +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
+
22
+ export {
23
+ __async
24
+ };
@@ -0,0 +1,114 @@
1
+ import {
2
+ __async
3
+ } from "./chunk-4AFQP74Z.js";
4
+ import { ethers } from "ethers";
5
+ import { hexStringToBase64 } from "@getpara/core-sdk";
6
+ class ParaEthersSigner extends ethers.AbstractSigner {
7
+ /**
8
+ * Signs a message.
9
+ *
10
+ * @param para - the ParaCore instance
11
+ * @param provider - the ethers provider to use. If not present, will use the default ethers.Provider.
12
+ * @param walletId - optional wallet ID to use. If not present, will use the first wallet found.
13
+ * @param messageSigningTimeoutMs - optional timeout in milliseconds. If not present, defaults to 30 seconds.
14
+ **/
15
+ constructor(para, provider, walletId, messageSigningTimeoutMs) {
16
+ super(provider);
17
+ this.currentWalletId = para.findWalletId(walletId, { type: ["EVM"] });
18
+ this.para = para;
19
+ this.messageSigningTimeoutMs = messageSigningTimeoutMs;
20
+ }
21
+ getAddress() {
22
+ return __async(this, null, function* () {
23
+ return this.para.wallets[this.currentWalletId].address;
24
+ });
25
+ }
26
+ connect(provider) {
27
+ return new ParaEthersSigner(this.para, provider, this.currentWalletId);
28
+ }
29
+ /**
30
+ * Signs a message.
31
+ *
32
+ * @param message - the message to be signed
33
+ **/
34
+ signMessage(message) {
35
+ return __async(this, null, function* () {
36
+ const hashedMessage = ethers.hashMessage(message);
37
+ const base64HashedMessage = hexStringToBase64(hashedMessage);
38
+ const res = yield this.para.signMessage({
39
+ walletId: this.currentWalletId,
40
+ messageBase64: base64HashedMessage,
41
+ timeoutMs: this.messageSigningTimeoutMs
42
+ });
43
+ const signature = res.signature;
44
+ return `0x${signature}`;
45
+ });
46
+ }
47
+ validateTx(tx) {
48
+ return __async(this, null, function* () {
49
+ const { to, from } = yield ethers.resolveProperties({
50
+ to: tx.to ? ethers.resolveAddress(tx.to, this.provider) : void 0,
51
+ from: tx.from ? ethers.resolveAddress(tx.from, this.provider) : void 0
52
+ });
53
+ if (to) {
54
+ tx.to = to;
55
+ }
56
+ if (from) {
57
+ tx.from = from;
58
+ }
59
+ if (tx.from) {
60
+ ethers.assertArgument(
61
+ ethers.getAddress(tx.from).toLowerCase() === (yield this.getAddress()).toLowerCase(),
62
+ "transaction from address mismatch",
63
+ "tx.from",
64
+ tx.from
65
+ );
66
+ delete tx.from;
67
+ }
68
+ return ethers.Transaction.from(tx);
69
+ });
70
+ }
71
+ signTransaction(tx) {
72
+ return __async(this, null, function* () {
73
+ const txObj = yield this.validateTx(tx);
74
+ txObj.signature = {
75
+ r: "0x0",
76
+ s: "0x0",
77
+ v: 0
78
+ };
79
+ const res = yield this.para.signTransaction({
80
+ walletId: this.currentWalletId,
81
+ rlpEncodedTxBase64: hexStringToBase64(txObj.serialized),
82
+ chainId: `${txObj.chainId}`
83
+ });
84
+ const signature = res.signature;
85
+ const btx = ethers.Transaction.from(tx);
86
+ btx.signature = `0x${signature}`;
87
+ return btx.serialized;
88
+ });
89
+ }
90
+ signTypedData(domain, types, value) {
91
+ return __async(this, null, function* () {
92
+ const populated = yield ethers.TypedDataEncoder.resolveNames(domain, types, value, (name) => __async(this, null, function* () {
93
+ ethers.assert(this.provider != null, "cannot resolve ENS names without a provider", "UNSUPPORTED_OPERATION", {
94
+ operation: "resolveName",
95
+ info: { name }
96
+ });
97
+ const address = yield this.provider.resolveName(name);
98
+ ethers.assert(address != null, "unconfigured ENS name", "UNCONFIGURED_NAME", {
99
+ value: name
100
+ });
101
+ return address;
102
+ }));
103
+ const res = yield this.para.signMessage({
104
+ walletId: this.currentWalletId,
105
+ messageBase64: hexStringToBase64(ethers.TypedDataEncoder.hash(populated.domain, types, populated.value))
106
+ });
107
+ const signature = res.signature;
108
+ return `0x${signature}`;
109
+ });
110
+ }
111
+ }
112
+ export {
113
+ ParaEthersSigner
114
+ };
package/dist/esm/index.js CHANGED
@@ -1,133 +1,2 @@
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
-
22
- // src/ethersSigner.ts
23
- import { ethers } from "ethers";
24
- import { hexStringToBase64 } from "@getpara/core-sdk";
25
- var ParaEthersSigner = class _ParaEthersSigner extends ethers.AbstractSigner {
26
- /**
27
- * Signs a message.
28
- *
29
- * @param para - the ParaCore instance
30
- * @param provider - the ethers provider to use. If not present, will use the default ethers.Provider.
31
- * @param walletId - optional wallet ID to use. If not present, will use the first wallet found.
32
- * @param messageSigningTimeoutMs - optional timeout in milliseconds. If not present, defaults to 30 seconds.
33
- **/
34
- constructor(para, provider, walletId, messageSigningTimeoutMs) {
35
- super(provider);
36
- this.currentWalletId = para.findWalletId(walletId, { type: ["EVM"] });
37
- this.para = para;
38
- this.messageSigningTimeoutMs = messageSigningTimeoutMs;
39
- }
40
- getAddress() {
41
- return __async(this, null, function* () {
42
- return this.para.wallets[this.currentWalletId].address;
43
- });
44
- }
45
- connect(provider) {
46
- return new _ParaEthersSigner(this.para, provider, this.currentWalletId);
47
- }
48
- /**
49
- * Signs a message.
50
- *
51
- * @param message - the message to be signed
52
- **/
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}`;
64
- });
65
- }
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);
88
- });
89
- }
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;
107
- });
108
- }
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))
125
- });
126
- const signature = res.signature;
127
- return `0x${signature}`;
128
- });
129
- }
130
- };
131
- export {
132
- ParaEthersSigner
133
- };
1
+ export * from "./ethersSigner.js";
2
+ export * from "./utils.js";
@@ -0,0 +1,4 @@
1
+ {
2
+ "type": "module",
3
+ "sideEffects": false
4
+ }
@@ -0,0 +1,28 @@
1
+ import {
2
+ __async
3
+ } from "./chunk-4AFQP74Z.js";
4
+ import { ethers } from "ethers";
5
+ function createTestTransaction(para, walletId) {
6
+ return __async(this, null, function* () {
7
+ walletId = para.findWalletId(walletId, { type: ["EVM"] });
8
+ const wallet = para.wallets[walletId];
9
+ const provider = new ethers.JsonRpcProvider("https://eth-sepolia.g.alchemy.com/v2/FPFN1k9stEKGzGNnoIveEuEhuDygTisx");
10
+ const address = para.getDisplayAddress(wallet.id, { addressType: "EVM" });
11
+ const eip1559Fees = yield provider.getFeeData();
12
+ const nonce = wallet.address ? yield provider.getTransactionCount(address) : void 0;
13
+ return ethers.Transaction.from({
14
+ to: address,
15
+ value: ethers.parseUnits("0.01", "ether"),
16
+ chainId: "11155111",
17
+ type: 2,
18
+ nonce,
19
+ gasLimit: 1e5,
20
+ gasPrice: eip1559Fees.gasPrice,
21
+ maxFeePerGas: eip1559Fees.maxFeePerGas,
22
+ maxPriorityFeePerGas: eip1559Fees.maxPriorityFeePerGas
23
+ });
24
+ });
25
+ }
26
+ export {
27
+ createTestTransaction
28
+ };
@@ -1 +1,2 @@
1
1
  export * from './ethersSigner.js';
2
+ export * from './utils.js';
@@ -0,0 +1,10 @@
1
+ import ParaCore from '@getpara/core-sdk';
2
+ import { ethers } from 'ethers';
3
+ /**
4
+ * Creates a Sepolia test transaction to sign and validate that your Para application is properly working.
5
+ * The transaction, if broadcast, simply sends 0.01 ETH from the wallet back to itself.
6
+ * @param {ParaCore} para your Para instance
7
+ * @param {string} walletId the EVM wallet ID to use.
8
+ * @returns {Promise<ethers.Transaction>} the generated transaction.
9
+ */
10
+ export declare function createTestTransaction(para: ParaCore, walletId?: string): Promise<ethers.Transaction>;
package/package.json CHANGED
@@ -1,38 +1,38 @@
1
1
  {
2
2
  "name": "@getpara/ethers-v6-integration",
3
- "version": "2.0.0-dev.1",
4
- "main": "dist/cjs/index.js",
5
- "module": "dist/esm/index.js",
6
- "types": "dist/types/index.d.ts",
7
- "typings": "dist/types/index.d.ts",
8
- "sideEffects": false,
3
+ "version": "2.0.0-dev.2",
9
4
  "dependencies": {
10
- "@getpara/core-sdk": "2.0.0-dev.1"
11
- },
12
- "scripts": {
13
- "build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types",
14
- "old-build": "yarn build:cjs && yarn build:esm && yarn build:types",
15
- "build:cjs": "rm -rf dist/cjs && tsc --module commonjs --outDir dist/cjs && printf '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
16
- "build:esm": "rm -rf dist/esm && tsc --module es6 --outDir dist/esm && printf '{\"type\":\"module\",\"sideEffects\":false}' > dist/esm/package.json",
17
- "build:types": "rm -rf dist/types && tsc --module es6 --declarationDir dist/types --emitDeclarationOnly --declaration"
5
+ "@getpara/core-sdk": "2.0.0-dev.2"
18
6
  },
19
7
  "devDependencies": {
20
- "ethers": "6.x",
21
- "typescript": "5.1.6"
8
+ "ethers": "^6.13.5",
9
+ "typescript": "^5.8.3"
22
10
  },
23
- "peerDependencies": {
24
- "ethers": "6.x"
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/types/index.d.ts",
14
+ "import": "./dist/esm/index.js",
15
+ "require": "./dist/cjs/index.js"
16
+ }
25
17
  },
26
18
  "files": [
27
19
  "dist",
28
20
  "package.json"
29
21
  ],
30
- "exports": {
31
- ".": {
32
- "import": "./dist/esm/index.js",
33
- "require": "./dist/cjs/index.js",
34
- "types": "./dist/types/index.d.ts"
35
- }
22
+ "gitHead": "77d818539daa181c839a40f0ad5362af4058844e",
23
+ "main": "dist/cjs/index.js",
24
+ "module": "dist/esm/index.js",
25
+ "peerDependencies": {
26
+ "ethers": "6.x"
36
27
  },
37
- "gitHead": "426e843bd6084fb2e5f30ab87b02c79fc2f52832"
28
+ "scripts": {
29
+ "build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types",
30
+ "build:cjs": "rm -rf dist/cjs && tsc --module commonjs --outDir dist/cjs && printf '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
31
+ "build:esm": "rm -rf dist/esm && tsc --module es6 --outDir dist/esm && printf '{\"type\":\"module\",\"sideEffects\":false}' > dist/esm/package.json",
32
+ "build:types": "rm -rf dist/types && tsc --module es6 --declarationDir dist/types --emitDeclarationOnly --declaration",
33
+ "old-build": "yarn build:cjs && yarn build:esm && yarn build:types"
34
+ },
35
+ "sideEffects": false,
36
+ "types": "dist/types/index.d.ts",
37
+ "typings": "dist/types/index.d.ts"
38
38
  }
Binary file
Binary file
Binary file
Binary file