@getpara/ethers-v5-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 = {};
@@ -51,61 +71,71 @@ var ParaEthersV5Signer = class _ParaEthersV5Signer extends import_ethers.ethers.
51
71
  }
52
72
  return id;
53
73
  }
54
- async getAddress() {
55
- const walletId = this.getCurrentWalletId();
56
- if (!walletId) {
57
- throw new Error("no wallet available");
58
- }
59
- return this.para.wallets[walletId].address;
74
+ getAddress() {
75
+ return __async(this, null, function* () {
76
+ const walletId = this.getCurrentWalletId();
77
+ if (!walletId) {
78
+ throw new Error("no wallet available");
79
+ }
80
+ return this.para.wallets[walletId].address;
81
+ });
60
82
  }
61
83
  connect(provider) {
62
84
  return new _ParaEthersV5Signer(this.para, provider, this.currentWalletId);
63
85
  }
64
- async signMessage(message) {
65
- const hashedMessage = import_ethers.ethers.utils.hashMessage(message);
66
- const base64HashedMessage = (0, import_core_sdk.hexStringToBase64)(hashedMessage);
67
- const res = await this.para.signMessage({ walletId: this.getCurrentWalletId(), messageBase64: base64HashedMessage });
68
- const signature = res.signature;
69
- return `0x${signature}`;
86
+ signMessage(message) {
87
+ return __async(this, null, function* () {
88
+ const hashedMessage = import_ethers.ethers.utils.hashMessage(message);
89
+ const base64HashedMessage = (0, import_core_sdk.hexStringToBase64)(hashedMessage);
90
+ const res = yield this.para.signMessage({ walletId: this.getCurrentWalletId(), messageBase64: base64HashedMessage });
91
+ const signature = res.signature;
92
+ return `0x${signature}`;
93
+ });
70
94
  }
71
- async signTransaction(tx) {
72
- return (0, import_utils.resolveProperties)(tx).then(async (tx2) => {
73
- if (tx2.from != null) {
74
- if ((await this.getAddress()).toLowerCase() !== import_ethers.ethers.utils.getAddress(tx2.from).toLowerCase()) {
75
- throw new Error("transaction from address mismatch");
95
+ signTransaction(tx) {
96
+ return __async(this, null, function* () {
97
+ return (0, import_utils.resolveProperties)(tx).then((tx2) => __async(this, null, function* () {
98
+ if (tx2.from != null) {
99
+ if ((yield this.getAddress()).toLowerCase() !== import_ethers.ethers.utils.getAddress(tx2.from).toLowerCase()) {
100
+ throw new Error("transaction from address mismatch");
101
+ }
102
+ delete tx2.from;
76
103
  }
77
- delete tx2.from;
78
- }
79
- let txObj = tx2;
80
- txObj.r = "0x0";
81
- txObj.s = "0x0";
82
- txObj.v = 0;
83
- const serializedTx = (0, import_utils.serializeTransaction)(txObj);
84
- const message = (0, import_core_sdk.hexStringToBase64)((0, import_utils.keccak256)(serializedTx));
85
- const signature = await this.signMessage(message);
86
- return (0, import_utils.serializeTransaction)(txObj, signature);
104
+ let txObj = tx2;
105
+ txObj.r = "0x0";
106
+ txObj.s = "0x0";
107
+ txObj.v = 0;
108
+ const serializedTx = (0, import_utils.serializeTransaction)(txObj);
109
+ const message = (0, import_core_sdk.hexStringToBase64)((0, import_utils.keccak256)(serializedTx));
110
+ const signature = yield this.signMessage(message);
111
+ return (0, import_utils.serializeTransaction)(txObj, signature);
112
+ }));
87
113
  });
88
114
  }
89
- async signTypedData(domain, types, value) {
90
- const populated = await import_hash._TypedDataEncoder.resolveNames(domain, types, value, async (name) => {
91
- if (!this.provider) {
92
- throw new Error("cannot resolve ENS names without a provider");
93
- }
94
- const address = await this.provider.resolveName(name);
95
- if (!address) {
96
- throw new Error("unconfigured ENS name");
97
- }
98
- return address;
99
- });
100
- const res = await this.para.signMessage({
101
- walletId: this.getCurrentWalletId(),
102
- messageBase64: (0, import_core_sdk.hexStringToBase64)(import_hash._TypedDataEncoder.hash(populated.domain, types, populated.value))
115
+ signTypedData(domain, types, value) {
116
+ return __async(this, null, function* () {
117
+ const populated = yield import_hash._TypedDataEncoder.resolveNames(domain, types, value, (name) => __async(this, null, function* () {
118
+ if (!this.provider) {
119
+ throw new Error("cannot resolve ENS names without a provider");
120
+ }
121
+ const address = yield this.provider.resolveName(name);
122
+ if (!address) {
123
+ throw new Error("unconfigured ENS name");
124
+ }
125
+ return address;
126
+ }));
127
+ const res = yield this.para.signMessage({
128
+ walletId: this.getCurrentWalletId(),
129
+ messageBase64: (0, import_core_sdk.hexStringToBase64)(import_hash._TypedDataEncoder.hash(populated.domain, types, populated.value))
130
+ });
131
+ const signature = res.signature;
132
+ return `0x${signature}`;
103
133
  });
104
- const signature = res.signature;
105
- return `0x${signature}`;
106
134
  }
107
- async _signTypedData(domain, types, value) {
108
- return this.signTypedData(domain, types, value);
135
+ _signTypedData(domain, types, value) {
136
+ return __async(this, null, function* () {
137
+ return this.signTypedData(domain, types, value);
138
+ });
109
139
  }
110
140
  };
111
141
  // 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 { _TypedDataEncoder } from "@ethersproject/hash";
@@ -26,61 +47,71 @@ var ParaEthersV5Signer = class _ParaEthersV5Signer extends ethers.Signer {
26
47
  }
27
48
  return id;
28
49
  }
29
- async getAddress() {
30
- const walletId = this.getCurrentWalletId();
31
- if (!walletId) {
32
- throw new Error("no wallet available");
33
- }
34
- return this.para.wallets[walletId].address;
50
+ getAddress() {
51
+ return __async(this, null, function* () {
52
+ const walletId = this.getCurrentWalletId();
53
+ if (!walletId) {
54
+ throw new Error("no wallet available");
55
+ }
56
+ return this.para.wallets[walletId].address;
57
+ });
35
58
  }
36
59
  connect(provider) {
37
60
  return new _ParaEthersV5Signer(this.para, provider, this.currentWalletId);
38
61
  }
39
- async signMessage(message) {
40
- const hashedMessage = ethers.utils.hashMessage(message);
41
- const base64HashedMessage = hexStringToBase64(hashedMessage);
42
- const res = await this.para.signMessage({ walletId: this.getCurrentWalletId(), messageBase64: base64HashedMessage });
43
- const signature = res.signature;
44
- return `0x${signature}`;
62
+ signMessage(message) {
63
+ return __async(this, null, function* () {
64
+ const hashedMessage = ethers.utils.hashMessage(message);
65
+ const base64HashedMessage = hexStringToBase64(hashedMessage);
66
+ const res = yield this.para.signMessage({ walletId: this.getCurrentWalletId(), messageBase64: base64HashedMessage });
67
+ const signature = res.signature;
68
+ return `0x${signature}`;
69
+ });
45
70
  }
46
- async signTransaction(tx) {
47
- return resolveProperties(tx).then(async (tx2) => {
48
- if (tx2.from != null) {
49
- if ((await this.getAddress()).toLowerCase() !== ethers.utils.getAddress(tx2.from).toLowerCase()) {
50
- throw new Error("transaction from address mismatch");
71
+ signTransaction(tx) {
72
+ return __async(this, null, function* () {
73
+ return resolveProperties(tx).then((tx2) => __async(this, null, function* () {
74
+ if (tx2.from != null) {
75
+ if ((yield this.getAddress()).toLowerCase() !== ethers.utils.getAddress(tx2.from).toLowerCase()) {
76
+ throw new Error("transaction from address mismatch");
77
+ }
78
+ delete tx2.from;
51
79
  }
52
- delete tx2.from;
53
- }
54
- let txObj = tx2;
55
- txObj.r = "0x0";
56
- txObj.s = "0x0";
57
- txObj.v = 0;
58
- const serializedTx = serializeTransaction(txObj);
59
- const message = hexStringToBase64(keccak256(serializedTx));
60
- const signature = await this.signMessage(message);
61
- return serializeTransaction(txObj, signature);
80
+ let txObj = tx2;
81
+ txObj.r = "0x0";
82
+ txObj.s = "0x0";
83
+ txObj.v = 0;
84
+ const serializedTx = serializeTransaction(txObj);
85
+ const message = hexStringToBase64(keccak256(serializedTx));
86
+ const signature = yield this.signMessage(message);
87
+ return serializeTransaction(txObj, signature);
88
+ }));
62
89
  });
63
90
  }
64
- async signTypedData(domain, types, value) {
65
- const populated = await _TypedDataEncoder.resolveNames(domain, types, value, async (name) => {
66
- if (!this.provider) {
67
- throw new Error("cannot resolve ENS names without a provider");
68
- }
69
- const address = await this.provider.resolveName(name);
70
- if (!address) {
71
- throw new Error("unconfigured ENS name");
72
- }
73
- return address;
74
- });
75
- const res = await this.para.signMessage({
76
- walletId: this.getCurrentWalletId(),
77
- messageBase64: hexStringToBase64(_TypedDataEncoder.hash(populated.domain, types, populated.value))
91
+ signTypedData(domain, types, value) {
92
+ return __async(this, null, function* () {
93
+ const populated = yield _TypedDataEncoder.resolveNames(domain, types, value, (name) => __async(this, null, function* () {
94
+ if (!this.provider) {
95
+ throw new Error("cannot resolve ENS names without a provider");
96
+ }
97
+ const address = yield this.provider.resolveName(name);
98
+ if (!address) {
99
+ throw new Error("unconfigured ENS name");
100
+ }
101
+ return address;
102
+ }));
103
+ const res = yield this.para.signMessage({
104
+ walletId: this.getCurrentWalletId(),
105
+ messageBase64: hexStringToBase64(_TypedDataEncoder.hash(populated.domain, types, populated.value))
106
+ });
107
+ const signature = res.signature;
108
+ return `0x${signature}`;
78
109
  });
79
- const signature = res.signature;
80
- return `0x${signature}`;
81
110
  }
82
- async _signTypedData(domain, types, value) {
83
- return this.signTypedData(domain, types, value);
111
+ _signTypedData(domain, types, value) {
112
+ return __async(this, null, function* () {
113
+ return this.signTypedData(domain, types, value);
114
+ });
84
115
  }
85
116
  };
86
117
  export {
Binary file
Binary file
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@getpara/ethers-v5-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
  "ethers": "^5.7.2"
12
12
  },
13
13
  "scripts": {
@@ -31,5 +31,5 @@
31
31
  "types": "./dist/types/index.d.ts"
32
32
  }
33
33
  },
34
- "gitHead": "0e3c1401b4f1da60b288cdde7695077c9bcbc48f"
34
+ "gitHead": "f77e0f5e162a1672219b01dbf7c06a3baadd2f35"
35
35
  }