@getpara/cosmjs-v0-integration 1.4.4 → 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 = {};
@@ -46,7 +66,8 @@ var ParaCosmosSigner = class {
46
66
  this.messageSigningTimeoutMs = messageSigningTimeoutMs;
47
67
  }
48
68
  get currentWallet() {
49
- return this.para.wallets[this.currentWalletId] ?? (() => {
69
+ var _a;
70
+ return (_a = this.para.wallets[this.currentWalletId]) != null ? _a : (() => {
50
71
  throw new Error(`no valid Para wallet found`);
51
72
  })();
52
73
  }
@@ -58,66 +79,72 @@ var ParaCosmosSigner = class {
58
79
  get address() {
59
80
  return (0, import_core_sdk.getCosmosAddress)(this.currentWallet.publicKey, this.prefix);
60
81
  }
61
- async getAccounts() {
62
- return [
63
- {
64
- algo: "secp256k1",
65
- address: this.address,
66
- pubkey: this.publicKey
67
- }
68
- ];
82
+ getAccounts() {
83
+ return __async(this, null, function* () {
84
+ return [
85
+ {
86
+ algo: "secp256k1",
87
+ address: this.address,
88
+ pubkey: this.publicKey
89
+ }
90
+ ];
91
+ });
69
92
  }
70
93
  };
71
94
  var ParaProtoSigner = class extends ParaCosmosSigner {
72
- async signDirect(address, signDoc) {
73
- const signBytes = (0, import_proto_signing.makeSignBytes)(signDoc);
74
- if (address !== this.address) {
75
- throw new Error(`Address ${address} not found in wallet`);
76
- }
77
- const hashedMessage = (0, import_crypto.sha256)(signBytes);
78
- const signDocJson = import_tx.SignDoc.toJSON(signDoc);
79
- const signDocJsonStringified = JSON.stringify(signDocJson);
80
- const signDocJsonStringEncoded = btoa(signDocJsonStringified);
81
- const res = await this.para.signMessage({
82
- walletId: this.currentWallet.id,
83
- messageBase64: Buffer.from(hashedMessage.buffer).toString("base64"),
84
- timeoutMs: this.messageSigningTimeoutMs,
85
- cosmosSignDocBase64: signDocJsonStringEncoded
95
+ signDirect(address, signDoc) {
96
+ return __async(this, null, function* () {
97
+ const signBytes = (0, import_proto_signing.makeSignBytes)(signDoc);
98
+ if (address !== this.address) {
99
+ throw new Error(`Address ${address} not found in wallet`);
100
+ }
101
+ const hashedMessage = (0, import_crypto.sha256)(signBytes);
102
+ const signDocJson = import_tx.SignDoc.toJSON(signDoc);
103
+ const signDocJsonStringified = JSON.stringify(signDocJson);
104
+ const signDocJsonStringEncoded = btoa(signDocJsonStringified);
105
+ const res = yield this.para.signMessage({
106
+ walletId: this.currentWallet.id,
107
+ messageBase64: Buffer.from(hashedMessage.buffer).toString("base64"),
108
+ timeoutMs: this.messageSigningTimeoutMs,
109
+ cosmosSignDocBase64: signDocJsonStringEncoded
110
+ });
111
+ const signature = (0, import_core_sdk.hexToSignature)(`0x${res.signature}`);
112
+ const extendedSignature = new import_crypto.ExtendedSecp256k1Signature(
113
+ (0, import_core_sdk.hexToUint8Array)(signature.r),
114
+ (0, import_core_sdk.hexToUint8Array)(signature.s),
115
+ Number(signature.v)
116
+ );
117
+ const signatureBytes = new Uint8Array([...extendedSignature.r(32), ...extendedSignature.s(32)]);
118
+ return {
119
+ signed: signDoc,
120
+ signature: (0, import_amino.encodeSecp256k1Signature)(this.publicKey, signatureBytes)
121
+ };
86
122
  });
87
- const signature = (0, import_core_sdk.hexToSignature)(`0x${res.signature}`);
88
- const extendedSignature = new import_crypto.ExtendedSecp256k1Signature(
89
- (0, import_core_sdk.hexToUint8Array)(signature.r),
90
- (0, import_core_sdk.hexToUint8Array)(signature.s),
91
- Number(signature.v)
92
- );
93
- const signatureBytes = new Uint8Array([...extendedSignature.r(32), ...extendedSignature.s(32)]);
94
- return {
95
- signed: signDoc,
96
- signature: (0, import_amino.encodeSecp256k1Signature)(this.publicKey, signatureBytes)
97
- };
98
123
  }
99
124
  };
100
125
  var ParaAminoSigner = class extends ParaCosmosSigner {
101
- async signAmino(signerAddress, signDoc) {
102
- if (signerAddress !== this.address) {
103
- throw new Error(`Address ${signerAddress} not found in wallet`);
104
- }
105
- const hashedMessage = new import_crypto.Sha256((0, import_amino.serializeSignDoc)(signDoc)).digest();
106
- const res = await this.para.signMessage({
107
- walletId: this.currentWallet.id,
108
- messageBase64: Buffer.from(hashedMessage.buffer).toString("base64")
126
+ signAmino(signerAddress, signDoc) {
127
+ return __async(this, null, function* () {
128
+ if (signerAddress !== this.address) {
129
+ throw new Error(`Address ${signerAddress} not found in wallet`);
130
+ }
131
+ const hashedMessage = new import_crypto.Sha256((0, import_amino.serializeSignDoc)(signDoc)).digest();
132
+ const res = yield this.para.signMessage({
133
+ walletId: this.currentWallet.id,
134
+ messageBase64: Buffer.from(hashedMessage.buffer).toString("base64")
135
+ });
136
+ const signature = (0, import_core_sdk.hexToSignature)(`0x${res.signature}`);
137
+ const extendedSignature = new import_crypto.ExtendedSecp256k1Signature(
138
+ (0, import_core_sdk.hexToUint8Array)(signature.r),
139
+ (0, import_core_sdk.hexToUint8Array)(signature.s),
140
+ Number(signature.v)
141
+ );
142
+ const signatureBytes = new Uint8Array([...extendedSignature.r(32), ...extendedSignature.s(32)]);
143
+ return {
144
+ signed: signDoc,
145
+ signature: (0, import_amino.encodeSecp256k1Signature)(this.publicKey, signatureBytes)
146
+ };
109
147
  });
110
- const signature = (0, import_core_sdk.hexToSignature)(`0x${res.signature}`);
111
- const extendedSignature = new import_crypto.ExtendedSecp256k1Signature(
112
- (0, import_core_sdk.hexToUint8Array)(signature.r),
113
- (0, import_core_sdk.hexToUint8Array)(signature.s),
114
- Number(signature.v)
115
- );
116
- const signatureBytes = new Uint8Array([...extendedSignature.r(32), ...extendedSignature.s(32)]);
117
- return {
118
- signed: signDoc,
119
- signature: (0, import_amino.encodeSecp256k1Signature)(this.publicKey, signatureBytes)
120
- };
121
148
  }
122
149
  };
123
150
  // 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/cosmosSigners.ts
2
23
  import {
3
24
  encodeSecp256k1Signature,
@@ -27,7 +48,8 @@ var ParaCosmosSigner = class {
27
48
  this.messageSigningTimeoutMs = messageSigningTimeoutMs;
28
49
  }
29
50
  get currentWallet() {
30
- return this.para.wallets[this.currentWalletId] ?? (() => {
51
+ var _a;
52
+ return (_a = this.para.wallets[this.currentWalletId]) != null ? _a : (() => {
31
53
  throw new Error(`no valid Para wallet found`);
32
54
  })();
33
55
  }
@@ -39,66 +61,72 @@ var ParaCosmosSigner = class {
39
61
  get address() {
40
62
  return getCosmosAddress(this.currentWallet.publicKey, this.prefix);
41
63
  }
42
- async getAccounts() {
43
- return [
44
- {
45
- algo: "secp256k1",
46
- address: this.address,
47
- pubkey: this.publicKey
48
- }
49
- ];
64
+ getAccounts() {
65
+ return __async(this, null, function* () {
66
+ return [
67
+ {
68
+ algo: "secp256k1",
69
+ address: this.address,
70
+ pubkey: this.publicKey
71
+ }
72
+ ];
73
+ });
50
74
  }
51
75
  };
52
76
  var ParaProtoSigner = class extends ParaCosmosSigner {
53
- async signDirect(address, signDoc) {
54
- const signBytes = makeSignBytes(signDoc);
55
- if (address !== this.address) {
56
- throw new Error(`Address ${address} not found in wallet`);
57
- }
58
- const hashedMessage = sha256(signBytes);
59
- const signDocJson = SignDoc.toJSON(signDoc);
60
- const signDocJsonStringified = JSON.stringify(signDocJson);
61
- const signDocJsonStringEncoded = btoa(signDocJsonStringified);
62
- const res = await this.para.signMessage({
63
- walletId: this.currentWallet.id,
64
- messageBase64: Buffer.from(hashedMessage.buffer).toString("base64"),
65
- timeoutMs: this.messageSigningTimeoutMs,
66
- cosmosSignDocBase64: signDocJsonStringEncoded
77
+ signDirect(address, signDoc) {
78
+ return __async(this, null, function* () {
79
+ const signBytes = makeSignBytes(signDoc);
80
+ if (address !== this.address) {
81
+ throw new Error(`Address ${address} not found in wallet`);
82
+ }
83
+ const hashedMessage = sha256(signBytes);
84
+ const signDocJson = SignDoc.toJSON(signDoc);
85
+ const signDocJsonStringified = JSON.stringify(signDocJson);
86
+ const signDocJsonStringEncoded = btoa(signDocJsonStringified);
87
+ const res = yield this.para.signMessage({
88
+ walletId: this.currentWallet.id,
89
+ messageBase64: Buffer.from(hashedMessage.buffer).toString("base64"),
90
+ timeoutMs: this.messageSigningTimeoutMs,
91
+ cosmosSignDocBase64: signDocJsonStringEncoded
92
+ });
93
+ const signature = hexToSignature(`0x${res.signature}`);
94
+ const extendedSignature = new ExtendedSecp256k1Signature(
95
+ hexToUint8Array(signature.r),
96
+ hexToUint8Array(signature.s),
97
+ Number(signature.v)
98
+ );
99
+ const signatureBytes = new Uint8Array([...extendedSignature.r(32), ...extendedSignature.s(32)]);
100
+ return {
101
+ signed: signDoc,
102
+ signature: encodeSecp256k1Signature(this.publicKey, signatureBytes)
103
+ };
67
104
  });
68
- const signature = hexToSignature(`0x${res.signature}`);
69
- const extendedSignature = new ExtendedSecp256k1Signature(
70
- hexToUint8Array(signature.r),
71
- hexToUint8Array(signature.s),
72
- Number(signature.v)
73
- );
74
- const signatureBytes = new Uint8Array([...extendedSignature.r(32), ...extendedSignature.s(32)]);
75
- return {
76
- signed: signDoc,
77
- signature: encodeSecp256k1Signature(this.publicKey, signatureBytes)
78
- };
79
105
  }
80
106
  };
81
107
  var ParaAminoSigner = class extends ParaCosmosSigner {
82
- async signAmino(signerAddress, signDoc) {
83
- if (signerAddress !== this.address) {
84
- throw new Error(`Address ${signerAddress} not found in wallet`);
85
- }
86
- const hashedMessage = new Sha256(serializeSignDoc(signDoc)).digest();
87
- const res = await this.para.signMessage({
88
- walletId: this.currentWallet.id,
89
- messageBase64: Buffer.from(hashedMessage.buffer).toString("base64")
108
+ signAmino(signerAddress, signDoc) {
109
+ return __async(this, null, function* () {
110
+ if (signerAddress !== this.address) {
111
+ throw new Error(`Address ${signerAddress} not found in wallet`);
112
+ }
113
+ const hashedMessage = new Sha256(serializeSignDoc(signDoc)).digest();
114
+ const res = yield this.para.signMessage({
115
+ walletId: this.currentWallet.id,
116
+ messageBase64: Buffer.from(hashedMessage.buffer).toString("base64")
117
+ });
118
+ const signature = hexToSignature(`0x${res.signature}`);
119
+ const extendedSignature = new ExtendedSecp256k1Signature(
120
+ hexToUint8Array(signature.r),
121
+ hexToUint8Array(signature.s),
122
+ Number(signature.v)
123
+ );
124
+ const signatureBytes = new Uint8Array([...extendedSignature.r(32), ...extendedSignature.s(32)]);
125
+ return {
126
+ signed: signDoc,
127
+ signature: encodeSecp256k1Signature(this.publicKey, signatureBytes)
128
+ };
90
129
  });
91
- const signature = hexToSignature(`0x${res.signature}`);
92
- const extendedSignature = new ExtendedSecp256k1Signature(
93
- hexToUint8Array(signature.r),
94
- hexToUint8Array(signature.s),
95
- Number(signature.v)
96
- );
97
- const signatureBytes = new Uint8Array([...extendedSignature.r(32), ...extendedSignature.s(32)]);
98
- return {
99
- signed: signDoc,
100
- signature: encodeSecp256k1Signature(this.publicKey, signatureBytes)
101
- };
102
130
  }
103
131
  };
104
132
  export {
Binary file
Binary file
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@getpara/cosmjs-v0-integration",
3
- "version": "1.4.4",
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.4.4"
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",
@@ -32,5 +32,5 @@
32
32
  "dist",
33
33
  "package.json"
34
34
  ],
35
- "gitHead": "9a4086c4b352fff2143d3b931d288c5ebaf127fb"
35
+ "gitHead": "f77e0f5e162a1672219b01dbf7c06a3baadd2f35"
36
36
  }