@keplr-wallet/hooks 0.10.0 → 0.10.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/build/sign-doc/amount.d.ts +2 -1
- package/build/sign-doc/amount.js +30 -26
- package/build/sign-doc/amount.js.map +1 -1
- package/build/sign-doc/index.js +10 -13
- package/build/sign-doc/index.js.map +1 -1
- package/package.json +12 -11
- package/src/sign-doc/amount.ts +42 -34
- package/src/sign-doc/index.ts +15 -14
|
@@ -3,6 +3,7 @@ import { ChainGetter, CoinPrimitive, CosmosMsgOpts, IAccountStore } from "@keplr
|
|
|
3
3
|
import { AppCurrency } from "@keplr-wallet/types";
|
|
4
4
|
import { SignDocHelper } from "./index";
|
|
5
5
|
import { Msg } from "@cosmjs/launchpad";
|
|
6
|
+
import { AnyWithUnpacked } from "@keplr-wallet/cosmos";
|
|
6
7
|
export declare type AccountStore = IAccountStore<{
|
|
7
8
|
cosmos: {
|
|
8
9
|
readonly msgOpts: CosmosMsgOpts;
|
|
@@ -25,7 +26,7 @@ export declare class SignDocAmountConfig extends TxChainSetter implements IAmoun
|
|
|
25
26
|
amount: string;
|
|
26
27
|
denom: string;
|
|
27
28
|
};
|
|
28
|
-
protected computeAmountInProtoMsgs(msgs:
|
|
29
|
+
protected computeAmountInProtoMsgs(msgs: AnyWithUnpacked[]): {
|
|
29
30
|
amount: string;
|
|
30
31
|
denom: string;
|
|
31
32
|
};
|
package/build/sign-doc/amount.js
CHANGED
|
@@ -115,35 +115,39 @@ class SignDocAmountConfig extends tx_1.TxChainSetter {
|
|
|
115
115
|
const amount = new unit_1.Coin(this.sendCurrency.coinMinimalDenom, new unit_1.Int(0));
|
|
116
116
|
for (const msg of msgs) {
|
|
117
117
|
try {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
for (const amountInMsg of sendMsg.amount) {
|
|
128
|
-
if (amountInMsg.denom === amount.denom && amountInMsg.amount) {
|
|
129
|
-
amount.amount = amount.amount.add(new unit_1.Int(amountInMsg.amount));
|
|
118
|
+
if (!(msg instanceof cosmos_1.UnknownMessage) && "unpacked" in msg) {
|
|
119
|
+
switch (msg.typeUrl) {
|
|
120
|
+
case "/cosmos.bank.v1beta1.MsgSend": {
|
|
121
|
+
const sendMsg = msg.unpacked;
|
|
122
|
+
if (sendMsg.fromAddress && sendMsg.fromAddress !== this.sender) {
|
|
123
|
+
return {
|
|
124
|
+
amount: "0",
|
|
125
|
+
denom: this.sendCurrency.coinMinimalDenom,
|
|
126
|
+
};
|
|
130
127
|
}
|
|
128
|
+
for (const amountInMsg of sendMsg.amount) {
|
|
129
|
+
if (amountInMsg.denom === amount.denom && amountInMsg.amount) {
|
|
130
|
+
amount.amount = amount.amount.add(new unit_1.Int(amountInMsg.amount));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
break;
|
|
131
134
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
135
|
+
case "/cosmos.staking.v1beta1.MsgDelegate": {
|
|
136
|
+
const delegateMsg = msg.unpacked;
|
|
137
|
+
if (delegateMsg.delegatorAddress &&
|
|
138
|
+
delegateMsg.delegatorAddress !== this.sender) {
|
|
139
|
+
return {
|
|
140
|
+
amount: "0",
|
|
141
|
+
denom: this.sendCurrency.coinMinimalDenom,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (((_a = delegateMsg.amount) === null || _a === void 0 ? void 0 : _a.denom) === amount.denom &&
|
|
145
|
+
delegateMsg.amount.amount) {
|
|
146
|
+
amount.amount = amount.amount.add(new unit_1.Int(delegateMsg.amount.amount));
|
|
147
|
+
}
|
|
148
|
+
break;
|
|
145
149
|
}
|
|
146
|
-
|
|
150
|
+
}
|
|
147
151
|
}
|
|
148
152
|
}
|
|
149
153
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../src/sign-doc/amount.ts"],"names":[],"mappings":";;;;;;;;;AAAA,8BAAqD;AAQrD,+BAAoE;AACpE,6CAA2D;AAE3D,iCAAiC;AACjC,2CAAwC;
|
|
1
|
+
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../src/sign-doc/amount.ts"],"names":[],"mappings":";;;;;;;;;AAAA,8BAAqD;AAQrD,+BAAoE;AACpE,6CAA2D;AAE3D,iCAAiC;AACjC,2CAAwC;AAIxC,iDAAuE;AAQvE,gGAAgG;AAChG,8BAA8B;AAC9B,6GAA6G;AAC7G,MAAa,mBACX,SAAQ,kBAAa;IAWrB,YACE,WAAwB,EACL,YAA0B,EAC7C,cAAsB,EACtB,MAAc;QAEd,KAAK,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAJhB,iBAAY,GAAZ,YAAY,CAAc;QAVrC,kBAAa,GAAmB,SAAS,CAAC;QAM1C,yBAAoB,GAAY,KAAK,CAAC;QAoDhD,uBAAkB,GAAG,uBAAU,CAC7B,GAAkB,EAAE;;YAClB,IACE,IAAI,CAAC,mBAAmB;gBACxB,QAAC,IAAI,CAAC,aAAa,0CAAE,cAAc,CAAA;gBACnC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,EACzC;gBACA,OAAO;oBACL,MAAM,EAAE,GAAG;oBACX,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,gBAAgB;iBAC1C,CAAC;aACH;YAED,IAAI,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,KAAK,OAAO,EAAE;gBACtD,OAAO,IAAI,CAAC,wBAAwB,CAClC,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,CACpD,CAAC;aACH;iBAAM;gB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ACP,OAAO;IACT,CAAC;IAED,eAAe;QACb,OAAO;IACT,CAAC;IAGD,sBAAsB,CAAC,IAAa;QAClC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;IACnC,CAAC;IAED,IAAI,mBAAmB;QACrB,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;CACF;AAlPC;IADC,iBAAU,CAAC,GAAG;0DACqC;AAGpD;IADC,iBAAU;oDACe;AAG1B;IADC,iBAAU;iEACqC;AAgBhD;IADC,aAAM;2DAGN;AAGD;IADC,eAAQ;iDAQR;AAgBD;IADC,aAAM;oDAGN;AAuLD;IADC,aAAM;iEAGN;AAjPH,kDAsPC;AAEM,MAAM,sBAAsB,GAAG,CACpC,WAAwB,EACxB,YAA0B,EAC1B,OAAe,EACf,MAAc,EACd,EAAE;IACF,MAAM,CAAC,MAAM,CAAC,GAAG,gBAAQ,CACvB,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAC,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,CAC1E,CAAC;IACF,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzB,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAEzB,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAbW,QAAA,sBAAsB,0BAajC"}
|
package/build/sign-doc/index.js
CHANGED
|
@@ -15,15 +15,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
15
15
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
16
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
17
|
};
|
|
18
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
-
};
|
|
21
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
19
|
exports.useSignDocHelper = exports.SignDocHelper = void 0;
|
|
23
20
|
const mobx_1 = require("mobx");
|
|
24
21
|
const react_1 = require("react");
|
|
25
22
|
const cosmos_1 = require("@keplr-wallet/cosmos");
|
|
26
|
-
const
|
|
23
|
+
const tx_1 = require("@keplr-wallet/proto-types/cosmos/tx/v1beta1/tx");
|
|
27
24
|
__exportStar(require("./amount"), exports);
|
|
28
25
|
class SignDocHelper {
|
|
29
26
|
constructor(feeConfig, memoConfig) {
|
|
@@ -33,7 +30,7 @@ class SignDocHelper {
|
|
|
33
30
|
mobx_1.makeObservable(this);
|
|
34
31
|
}
|
|
35
32
|
get signDocWrapper() {
|
|
36
|
-
var _a, _b
|
|
33
|
+
var _a, _b;
|
|
37
34
|
if (!this._signDocWrapper) {
|
|
38
35
|
return undefined;
|
|
39
36
|
}
|
|
@@ -49,25 +46,25 @@ class SignDocHelper {
|
|
|
49
46
|
return cosmos_1.SignDocWrapper.fromAminoSignDoc(signDoc);
|
|
50
47
|
}
|
|
51
48
|
const protoSignDoc = this._signDocWrapper.protoSignDoc;
|
|
52
|
-
const fee =
|
|
53
|
-
gasLimit:
|
|
49
|
+
const fee = tx_1.Fee.fromPartial({
|
|
50
|
+
gasLimit: stdFee.gas,
|
|
54
51
|
amount: stdFee.amount.map((fee) => {
|
|
55
52
|
return {
|
|
56
53
|
amount: fee.amount,
|
|
57
54
|
denom: fee.denom,
|
|
58
55
|
};
|
|
59
56
|
}),
|
|
60
|
-
granter: (
|
|
61
|
-
payer: (
|
|
57
|
+
granter: (_a = protoSignDoc.authInfo.fee) === null || _a === void 0 ? void 0 : _a.granter,
|
|
58
|
+
payer: (_b = protoSignDoc.authInfo.fee) === null || _b === void 0 ? void 0 : _b.payer,
|
|
62
59
|
});
|
|
63
|
-
const newSignDoc =
|
|
64
|
-
bodyBytes:
|
|
60
|
+
const newSignDoc = Object.assign(Object.assign({}, protoSignDoc.signDoc), {
|
|
61
|
+
bodyBytes: tx_1.TxBody.encode(Object.assign(Object.assign({}, protoSignDoc.txBody), {
|
|
65
62
|
memo: this.memoConfig.memo,
|
|
66
63
|
})).finish(),
|
|
67
|
-
authInfoBytes:
|
|
64
|
+
authInfoBytes: tx_1.AuthInfo.encode(Object.assign(Object.assign({}, protoSignDoc.authInfo), {
|
|
68
65
|
fee,
|
|
69
66
|
})).finish(),
|
|
70
|
-
})
|
|
67
|
+
});
|
|
71
68
|
return cosmos_1.SignDocWrapper.fromDirectSignDoc(newSignDoc);
|
|
72
69
|
}
|
|
73
70
|
get signDocJson() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sign-doc/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sign-doc/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,+BAAoE;AACpE,iCAAiC;AAEjC,iDAAsD;AACtD,uEAKwD;AAExD,2CAAyB;AAEzB,MAAa,aAAa;IAIxB,YACqB,SAAqB,EACrB,UAAuB;QADvB,cAAS,GAAT,SAAS,CAAY;QACrB,eAAU,GAAV,UAAU,CAAa;QAJlC,oBAAe,GAAoB,SAAS,CAAC;QAMrD,qBAAc,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAGD,IAAI,cAAc;;QAChB,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACzB,OAAO,SAAS,CAAC;SAClB;QAED,iCAAiC;QACjC,oCAAoC;QACpC,0DAA0D;QAC1D,IAAI,IAAI,CAAC,eAAe,CAAC,cAAc,EAAE;YACvC,OAAO,IAAI,CAAC,eAAe,CAAC;SAC7B;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;QAEzC,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,KAAK,OAAO,EAAE;YACzC,MAAM,OAAO,mCACR,IAAI,CAAC,eAAe,CAAC,YAAY,KACpC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,IAAI,CAAC,U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E,CAAC;SAClD;IACH,CAAC;IAGD,iBAAiB,CAAC,OAAmC;QACnD,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;IACjC,CAAC;CACF;AArFC;IADC,iBAAU,CAAC,GAAG;sDACwC;AAUvD;IADC,eAAQ;mDAyDR;AAGD;IADC,eAAQ;gDAWR;AAGD;IADC,aAAM;sDAGN;AAtFH,sCAuFC;AAEM,MAAM,gBAAgB,GAAG,CAC9B,SAAqB,EACrB,UAAuB,EACvB,EAAE;IACF,MAAM,CAAC,MAAM,CAAC,GAAG,gBAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IAE1E,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAPW,QAAA,gBAAgB,oBAO3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keplr-wallet/hooks",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"author": "chainapsis",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,15 +21,16 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@cosmjs/launchpad": "^0.24.0-alpha.25",
|
|
24
|
-
"@keplr-wallet/background": "0.10.
|
|
25
|
-
"@keplr-wallet/common": "0.10.
|
|
26
|
-
"@keplr-wallet/cosmos": "0.10.
|
|
27
|
-
"@keplr-wallet/crypto": "0.10.
|
|
28
|
-
"@keplr-wallet/ens": "0.10.
|
|
29
|
-
"@keplr-wallet/popup": "0.10.
|
|
30
|
-
"@keplr-wallet/
|
|
31
|
-
"@keplr-wallet/
|
|
32
|
-
"@keplr-wallet/
|
|
24
|
+
"@keplr-wallet/background": "0.10.1",
|
|
25
|
+
"@keplr-wallet/common": "0.10.1",
|
|
26
|
+
"@keplr-wallet/cosmos": "0.10.1",
|
|
27
|
+
"@keplr-wallet/crypto": "0.10.1",
|
|
28
|
+
"@keplr-wallet/ens": "0.10.1",
|
|
29
|
+
"@keplr-wallet/popup": "0.10.1",
|
|
30
|
+
"@keplr-wallet/proto-types": "0.10.1",
|
|
31
|
+
"@keplr-wallet/stores": "0.10.1",
|
|
32
|
+
"@keplr-wallet/types": "0.10.1",
|
|
33
|
+
"@keplr-wallet/unit": "0.10.1",
|
|
33
34
|
"long": "^4.0.0",
|
|
34
35
|
"mobx": "^6.1.7",
|
|
35
36
|
"mobx-utils": "^6.0.3",
|
|
@@ -37,5 +38,5 @@
|
|
|
37
38
|
"react-router": "^5.1.2",
|
|
38
39
|
"utility-types": "^3.10.0"
|
|
39
40
|
},
|
|
40
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "fe8b77605d5158bdb50ec8233dd698ad6e2e4f57"
|
|
41
42
|
}
|
package/src/sign-doc/amount.ts
CHANGED
|
@@ -12,7 +12,9 @@ import { SignDocHelper } from "./index";
|
|
|
12
12
|
import { useState } from "react";
|
|
13
13
|
import { computedFn } from "mobx-utils";
|
|
14
14
|
import { Msg } from "@cosmjs/launchpad";
|
|
15
|
-
import {
|
|
15
|
+
import { MsgSend } from "@keplr-wallet/proto-types/cosmos/bank/v1beta1/tx";
|
|
16
|
+
import { MsgDelegate } from "@keplr-wallet/proto-types/cosmos/staking/v1beta1/tx";
|
|
17
|
+
import { AnyWithUnpacked, UnknownMessage } from "@keplr-wallet/cosmos";
|
|
16
18
|
|
|
17
19
|
export type AccountStore = IAccountStore<{
|
|
18
20
|
cosmos: {
|
|
@@ -168,46 +170,52 @@ export class SignDocAmountConfig
|
|
|
168
170
|
};
|
|
169
171
|
}
|
|
170
172
|
|
|
171
|
-
protected computeAmountInProtoMsgs(msgs:
|
|
173
|
+
protected computeAmountInProtoMsgs(msgs: AnyWithUnpacked[]) {
|
|
172
174
|
const amount = new Coin(this.sendCurrency.coinMinimalDenom, new Int(0));
|
|
173
175
|
|
|
174
176
|
for (const msg of msgs) {
|
|
175
177
|
try {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
for (const amountInMsg of sendMsg.amount) {
|
|
186
|
-
if (amountInMsg.denom === amount.denom && amountInMsg.amount) {
|
|
187
|
-
amount.amount = amount.amount.add(new Int(amountInMsg.amount));
|
|
178
|
+
if (!(msg instanceof UnknownMessage) && "unpacked" in msg) {
|
|
179
|
+
switch (msg.typeUrl) {
|
|
180
|
+
case "/cosmos.bank.v1beta1.MsgSend": {
|
|
181
|
+
const sendMsg = msg.unpacked as MsgSend;
|
|
182
|
+
if (sendMsg.fromAddress && sendMsg.fromAddress !== this.sender) {
|
|
183
|
+
return {
|
|
184
|
+
amount: "0",
|
|
185
|
+
denom: this.sendCurrency.coinMinimalDenom,
|
|
186
|
+
};
|
|
188
187
|
}
|
|
188
|
+
for (const amountInMsg of sendMsg.amount) {
|
|
189
|
+
if (amountInMsg.denom === amount.denom && amountInMsg.amount) {
|
|
190
|
+
amount.amount = amount.amount.add(
|
|
191
|
+
new Int(amountInMsg.amount)
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
break;
|
|
189
196
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
197
|
+
case "/cosmos.staking.v1beta1.MsgDelegate": {
|
|
198
|
+
const delegateMsg = msg.unpacked as MsgDelegate;
|
|
199
|
+
if (
|
|
200
|
+
delegateMsg.delegatorAddress &&
|
|
201
|
+
delegateMsg.delegatorAddress !== this.sender
|
|
202
|
+
) {
|
|
203
|
+
return {
|
|
204
|
+
amount: "0",
|
|
205
|
+
denom: this.sendCurrency.coinMinimalDenom,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
if (
|
|
209
|
+
delegateMsg.amount?.denom === amount.denom &&
|
|
210
|
+
delegateMsg.amount.amount
|
|
211
|
+
) {
|
|
212
|
+
amount.amount = amount.amount.add(
|
|
213
|
+
new Int(delegateMsg.amount.amount)
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
break;
|
|
209
217
|
}
|
|
210
|
-
|
|
218
|
+
}
|
|
211
219
|
}
|
|
212
220
|
} catch (e) {
|
|
213
221
|
console.log(
|
package/src/sign-doc/index.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { action, computed, makeObservable, observable } from "mobx";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { IFeeConfig, IMemoConfig } from "../tx";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
4
|
+
import { SignDocWrapper } from "@keplr-wallet/cosmos";
|
|
5
|
+
import {
|
|
6
|
+
SignDoc,
|
|
7
|
+
TxBody,
|
|
8
|
+
AuthInfo,
|
|
9
|
+
Fee,
|
|
10
|
+
} from "@keplr-wallet/proto-types/cosmos/tx/v1beta1/tx";
|
|
6
11
|
|
|
7
12
|
export * from "./amount";
|
|
8
13
|
|
|
@@ -43,39 +48,35 @@ export class SignDocHelper {
|
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
const protoSignDoc = this._signDocWrapper.protoSignDoc;
|
|
46
|
-
const fee =
|
|
47
|
-
gasLimit:
|
|
51
|
+
const fee = Fee.fromPartial({
|
|
52
|
+
gasLimit: stdFee.gas,
|
|
48
53
|
amount: stdFee.amount.map((fee) => {
|
|
49
54
|
return {
|
|
50
55
|
amount: fee.amount,
|
|
51
56
|
denom: fee.denom,
|
|
52
57
|
};
|
|
53
58
|
}),
|
|
54
|
-
granter: protoSignDoc.authInfo.fee?.granter
|
|
55
|
-
|
|
56
|
-
: null,
|
|
57
|
-
payer: protoSignDoc.authInfo.fee?.payer
|
|
58
|
-
? protoSignDoc.authInfo.fee?.granter
|
|
59
|
-
: null,
|
|
59
|
+
granter: protoSignDoc.authInfo.fee?.granter,
|
|
60
|
+
payer: protoSignDoc.authInfo.fee?.payer,
|
|
60
61
|
});
|
|
61
62
|
|
|
62
|
-
const newSignDoc =
|
|
63
|
+
const newSignDoc: SignDoc = {
|
|
63
64
|
...protoSignDoc.signDoc,
|
|
64
65
|
...{
|
|
65
|
-
bodyBytes:
|
|
66
|
+
bodyBytes: TxBody.encode({
|
|
66
67
|
...protoSignDoc.txBody,
|
|
67
68
|
...{
|
|
68
69
|
memo: this.memoConfig.memo,
|
|
69
70
|
},
|
|
70
71
|
}).finish(),
|
|
71
|
-
authInfoBytes:
|
|
72
|
+
authInfoBytes: AuthInfo.encode({
|
|
72
73
|
...protoSignDoc.authInfo,
|
|
73
74
|
...{
|
|
74
75
|
fee,
|
|
75
76
|
},
|
|
76
77
|
}).finish(),
|
|
77
78
|
},
|
|
78
|
-
}
|
|
79
|
+
};
|
|
79
80
|
|
|
80
81
|
return SignDocWrapper.fromDirectSignDoc(newSignDoc);
|
|
81
82
|
}
|