@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 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
- async getAddress() {
45
- return this.para.wallets[this.currentWalletId].address;
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
- async signMessage(message) {
56
- const hashedMessage = import_ethers.ethers.hashMessage(message);
57
- const base64HashedMessage = (0, import_core_sdk.hexStringToBase64)(hashedMessage);
58
- const res = await this.para.signMessage({
59
- walletId: this.currentWalletId,
60
- messageBase64: base64HashedMessage,
61
- timeoutMs: this.messageSigningTimeoutMs
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
- async validateTx(tx) {
67
- const { to, from } = await import_ethers.ethers.resolveProperties({
68
- to: tx.to ? import_ethers.ethers.resolveAddress(tx.to, this.provider) : void 0,
69
- from: tx.from ? import_ethers.ethers.resolveAddress(tx.from, this.provider) : void 0
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
- async signTransaction(tx) {
89
- const txObj = await this.validateTx(tx);
90
- txObj.signature = {
91
- r: "0x0",
92
- s: "0x0",
93
- v: 0
94
- };
95
- const res = await this.para.signTransaction({
96
- walletId: this.currentWalletId,
97
- rlpEncodedTxBase64: (0, import_core_sdk.hexStringToBase64)(txObj.serialized),
98
- chainId: `${txObj.chainId}`
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
- async signTypedData(domain, types, value) {
106
- const populated = await import_ethers.ethers.TypedDataEncoder.resolveNames(domain, types, value, async (name) => {
107
- import_ethers.ethers.assert(this.provider != null, "cannot resolve ENS names without a provider", "UNSUPPORTED_OPERATION", {
108
- operation: "resolveName",
109
- info: { name }
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 address = await this.provider.resolveName(name);
112
- import_ethers.ethers.assert(address != null, "unconfigured ENS name", "UNCONFIGURED_NAME", {
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:
Binary file
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
- async getAddress() {
20
- return this.para.wallets[this.currentWalletId].address;
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
- async signMessage(message) {
31
- const hashedMessage = ethers.hashMessage(message);
32
- const base64HashedMessage = hexStringToBase64(hashedMessage);
33
- const res = await this.para.signMessage({
34
- walletId: this.currentWalletId,
35
- messageBase64: base64HashedMessage,
36
- timeoutMs: this.messageSigningTimeoutMs
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
- async validateTx(tx) {
42
- const { to, from } = await ethers.resolveProperties({
43
- to: tx.to ? ethers.resolveAddress(tx.to, this.provider) : void 0,
44
- from: tx.from ? ethers.resolveAddress(tx.from, this.provider) : void 0
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
- async signTransaction(tx) {
64
- const txObj = await this.validateTx(tx);
65
- txObj.signature = {
66
- r: "0x0",
67
- s: "0x0",
68
- v: 0
69
- };
70
- const res = await this.para.signTransaction({
71
- walletId: this.currentWalletId,
72
- rlpEncodedTxBase64: hexStringToBase64(txObj.serialized),
73
- chainId: `${txObj.chainId}`
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
- async signTypedData(domain, types, value) {
81
- const populated = await ethers.TypedDataEncoder.resolveNames(domain, types, value, async (name) => {
82
- ethers.assert(this.provider != null, "cannot resolve ENS names without a provider", "UNSUPPORTED_OPERATION", {
83
- operation: "resolveName",
84
- info: { name }
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 address = await this.provider.resolveName(name);
87
- ethers.assert(address != null, "unconfigured ENS name", "UNCONFIGURED_NAME", {
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 {
Binary file
Binary file
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@getpara/ethers-v6-integration",
3
- "version": "1.5.0",
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.0"
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": "0e3c1401b4f1da60b288cdde7695077c9bcbc48f"
37
+ "gitHead": "f77e0f5e162a1672219b01dbf7c06a3baadd2f35"
38
38
  }