@shapeshiftoss/hdwallet-keepkey 1.55.2 → 1.55.4-alpha.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/adapter.js +93 -148
- package/dist/adapter.js.map +1 -1
- package/dist/binance.js +96 -136
- package/dist/binance.js.map +1 -1
- package/dist/bitcoin.js +257 -324
- package/dist/bitcoin.js.map +1 -1
- package/dist/bnbencoding.d.ts +0 -1
- package/dist/bnbencoding.d.ts.map +1 -1
- package/dist/bnbencoding.js +9 -41
- package/dist/bnbencoding.js.map +1 -1
- package/dist/cosmos.js +158 -207
- package/dist/cosmos.js.map +1 -1
- package/dist/eos.js +108 -153
- package/dist/eos.js.map +1 -1
- package/dist/ethereum.js +189 -243
- package/dist/ethereum.js.map +1 -1
- package/dist/index.js +5 -21
- package/dist/index.js.map +1 -1
- package/dist/keepkey.d.ts +0 -1
- package/dist/keepkey.d.ts.map +1 -1
- package/dist/keepkey.js +444 -582
- package/dist/keepkey.js.map +1 -1
- package/dist/osmosis.js +211 -260
- package/dist/osmosis.js.map +1 -1
- package/dist/ripple.js +52 -97
- package/dist/ripple.js.map +1 -1
- package/dist/thorchain.js +114 -163
- package/dist/thorchain.js.map +1 -1
- package/dist/transport.js +220 -278
- package/dist/transport.js.map +1 -1
- package/dist/typeRegistry.js +12 -41
- package/dist/typeRegistry.js.map +1 -1
- package/dist/utils.js +7 -37
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
package/dist/ripple.js
CHANGED
|
@@ -1,112 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.rippleGetAddress = exports.rippleSignTx = exports.rippleGetAccountPaths = void 0;
|
|
39
|
-
const Messages = __importStar(require("@keepkey/device-protocol/lib/messages_pb"));
|
|
40
|
-
const RippleMessages = __importStar(require("@keepkey/device-protocol/lib/messages-ripple_pb"));
|
|
41
|
-
const core = __importStar(require("@shapeshiftoss/hdwallet-core"));
|
|
42
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
43
|
-
function rippleGetAccountPaths(msg) {
|
|
1
|
+
import * as Messages from "@keepkey/device-protocol/lib/messages_pb";
|
|
2
|
+
import * as RippleMessages from "@keepkey/device-protocol/lib/messages-ripple_pb";
|
|
3
|
+
import * as core from "@shapeshiftoss/hdwallet-core";
|
|
4
|
+
import _ from "lodash";
|
|
5
|
+
export function rippleGetAccountPaths(msg) {
|
|
44
6
|
return [
|
|
45
7
|
{
|
|
46
8
|
addressNList: [0x80000000 + 44, 0x80000000 + core.slip44ByCoin("Ripple"), 0x80000000 + msg.accountIdx, 0, 0],
|
|
47
9
|
},
|
|
48
10
|
];
|
|
49
11
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
payment.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (m.value.amount.length !== 1) {
|
|
72
|
-
throw new Error("ripple: Multiple amounts per msg not supported");
|
|
73
|
-
}
|
|
74
|
-
const denom = m.value.amount[0].denom;
|
|
75
|
-
if (denom !== "drop") {
|
|
76
|
-
throw new Error("ripple: Unsupported denomination: " + denom);
|
|
77
|
-
}
|
|
12
|
+
export async function rippleSignTx(transport, msg) {
|
|
13
|
+
return transport.lockDuring(async () => {
|
|
14
|
+
const signTx = new RippleMessages.RippleSignTx();
|
|
15
|
+
signTx.setAddressNList(msg.addressNList);
|
|
16
|
+
signTx.setFee(parseInt(msg.tx.value.fee.amount[0].amount));
|
|
17
|
+
signTx.setSequence(parseInt(msg.sequence));
|
|
18
|
+
signTx.setLastLedgerSequence(parseInt(msg.lastLedgerSequence));
|
|
19
|
+
const payment = new RippleMessages.RipplePayment();
|
|
20
|
+
payment.setAmount(parseInt(msg.payment.amount));
|
|
21
|
+
payment.setDestination(msg.payment.destination);
|
|
22
|
+
if (msg.payment.destinationTag !== undefined)
|
|
23
|
+
payment.setDestinationTag(parseInt(msg.payment.destinationTag));
|
|
24
|
+
signTx.setPayment(payment);
|
|
25
|
+
const resp = await transport.call(Messages.MessageType.MESSAGETYPE_RIPPLESIGNTX, signTx, {
|
|
26
|
+
msgTimeout: core.LONG_TIMEOUT,
|
|
27
|
+
omitLock: true,
|
|
28
|
+
});
|
|
29
|
+
for (const m of msg.tx.value.msg) {
|
|
30
|
+
if (m.type === "ripple-sdk/MsgSend") {
|
|
31
|
+
if (m.value.amount.length !== 1) {
|
|
32
|
+
throw new Error("ripple: Multiple amounts per msg not supported");
|
|
78
33
|
}
|
|
79
|
-
|
|
80
|
-
|
|
34
|
+
const denom = m.value.amount[0].denom;
|
|
35
|
+
if (denom !== "drop") {
|
|
36
|
+
throw new Error("ripple: Unsupported denomination: " + denom);
|
|
81
37
|
}
|
|
82
38
|
}
|
|
83
|
-
|
|
84
|
-
throw new Error(`ripple:
|
|
39
|
+
else {
|
|
40
|
+
throw new Error(`ripple: Message ${m.type} is not yet supported`);
|
|
85
41
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
42
|
+
}
|
|
43
|
+
if (resp.message_enum !== Messages.MessageType.MESSAGETYPE_RIPPLESIGNEDTX) {
|
|
44
|
+
throw new Error(`ripple: unexpected response ${resp.message_type}`);
|
|
45
|
+
}
|
|
46
|
+
const signedTx = resp.proto;
|
|
47
|
+
const signed = _.cloneDeep(msg.tx);
|
|
48
|
+
signed.value.signatures = [
|
|
49
|
+
{
|
|
50
|
+
serializedTx: signedTx.getSerializedTx_asB64(),
|
|
51
|
+
signature: signedTx.getSignature_asB64(),
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
return signed;
|
|
96
55
|
});
|
|
97
56
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const response = yield transport.call(Messages.MessageType.MESSAGETYPE_RIPPLEGETADDRESS, getAddr, {
|
|
105
|
-
msgTimeout: core.LONG_TIMEOUT,
|
|
106
|
-
});
|
|
107
|
-
const rippleAddress = response.proto;
|
|
108
|
-
return core.mustBeDefined(rippleAddress.getAddress());
|
|
57
|
+
export async function rippleGetAddress(transport, msg) {
|
|
58
|
+
const getAddr = new RippleMessages.RippleGetAddress();
|
|
59
|
+
getAddr.setAddressNList(msg.addressNList);
|
|
60
|
+
getAddr.setShowDisplay(msg.showDisplay !== false);
|
|
61
|
+
const response = await transport.call(Messages.MessageType.MESSAGETYPE_RIPPLEGETADDRESS, getAddr, {
|
|
62
|
+
msgTimeout: core.LONG_TIMEOUT,
|
|
109
63
|
});
|
|
64
|
+
const rippleAddress = response.proto;
|
|
65
|
+
return core.mustBeDefined(rippleAddress.getAddress());
|
|
110
66
|
}
|
|
111
|
-
exports.rippleGetAddress = rippleGetAddress;
|
|
112
67
|
//# sourceMappingURL=ripple.js.map
|
package/dist/ripple.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ripple.js","sourceRoot":"","sources":["../src/ripple.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ripple.js","sourceRoot":"","sources":["../src/ripple.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,0CAA0C,CAAC;AACrE,OAAO,KAAK,cAAc,MAAM,iDAAiD,CAAC;AAClF,OAAO,KAAK,IAAI,MAAM,8BAA8B,CAAC;AACrD,OAAO,CAAC,MAAM,QAAQ,CAAC;AAIvB,MAAM,UAAU,qBAAqB,CAAC,GAA+B;IACnE,OAAO;QACL;YACE,YAAY,EAAE,CAAC,UAAU,GAAG,EAAE,EAAE,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,GAAG,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,CAAC,gBAAgB,EAAE,CAAC;IACtD,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC1C,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,4BAA4B,EAAE,OAAO,EAAE;QAChG,UAAU,EAAE,IAAI,CAAC,YAAY;KAC9B,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAqC,CAAC;IACrE,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC,CAAC;AACxD,CAAC"}
|
package/dist/thorchain.js
CHANGED
|
@@ -1,181 +1,132 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.thorchainSignTx = exports.thorchainGetAddress = exports.thorchainGetAccountPaths = void 0;
|
|
39
|
-
const Messages = __importStar(require("@keepkey/device-protocol/lib/messages_pb"));
|
|
40
|
-
const ThorchainMessages = __importStar(require("@keepkey/device-protocol/lib/messages-thorchain_pb"));
|
|
41
|
-
const core = __importStar(require("@shapeshiftoss/hdwallet-core"));
|
|
42
|
-
const bs58check_1 = __importDefault(require("bs58check"));
|
|
43
|
-
const p_lazy_1 = __importDefault(require("p-lazy"));
|
|
44
|
-
const protoTxBuilder = p_lazy_1.default.from(() => Promise.resolve().then(() => __importStar(require("@shapeshiftoss/proto-tx-builder"))));
|
|
45
|
-
function thorchainGetAccountPaths(msg) {
|
|
1
|
+
import * as Messages from "@keepkey/device-protocol/lib/messages_pb";
|
|
2
|
+
import * as ThorchainMessages from "@keepkey/device-protocol/lib/messages-thorchain_pb";
|
|
3
|
+
import * as core from "@shapeshiftoss/hdwallet-core";
|
|
4
|
+
import bs58check from "bs58check";
|
|
5
|
+
import PLazy from "p-lazy";
|
|
6
|
+
const protoTxBuilder = PLazy.from(() => import("@shapeshiftoss/proto-tx-builder"));
|
|
7
|
+
export function thorchainGetAccountPaths(msg) {
|
|
46
8
|
return [
|
|
47
9
|
{
|
|
48
10
|
addressNList: [0x80000000 + 44, 0x80000000 + core.slip44ByCoin("Thorchain"), 0x80000000 + msg.accountIdx, 0, 0],
|
|
49
11
|
},
|
|
50
12
|
];
|
|
51
13
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
getAddr.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const response = yield transport.call(Messages.MessageType.MESSAGETYPE_THORCHAINGETADDRESS, getAddr, {
|
|
61
|
-
msgTimeout: core.LONG_TIMEOUT,
|
|
62
|
-
});
|
|
63
|
-
const thorchainAddress = response.proto;
|
|
64
|
-
return core.mustBeDefined(thorchainAddress.getAddress());
|
|
14
|
+
export async function thorchainGetAddress(transport, msg) {
|
|
15
|
+
const getAddr = new ThorchainMessages.ThorchainGetAddress();
|
|
16
|
+
getAddr.setAddressNList(msg.addressNList);
|
|
17
|
+
getAddr.setShowDisplay(msg.showDisplay !== false);
|
|
18
|
+
if (msg.testnet !== undefined)
|
|
19
|
+
getAddr.setTestnet(msg.testnet);
|
|
20
|
+
const response = await transport.call(Messages.MessageType.MESSAGETYPE_THORCHAINGETADDRESS, getAddr, {
|
|
21
|
+
msgTimeout: core.LONG_TIMEOUT,
|
|
65
22
|
});
|
|
23
|
+
const thorchainAddress = response.proto;
|
|
24
|
+
return core.mustBeDefined(thorchainAddress.getAddress());
|
|
66
25
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
26
|
+
export async function thorchainSignTx(transport, msg) {
|
|
27
|
+
const address = await thorchainGetAddress(transport, { addressNList: msg.addressNList });
|
|
28
|
+
const getPublicKeyMsg = new Messages.GetPublicKey();
|
|
29
|
+
getPublicKeyMsg.setAddressNList(msg.addressNList);
|
|
30
|
+
getPublicKeyMsg.setEcdsaCurveName("secp256k1");
|
|
31
|
+
const response = await transport.call(Messages.MessageType.MESSAGETYPE_GETPUBLICKEY, getPublicKeyMsg, {
|
|
32
|
+
msgTimeout: core.DEFAULT_TIMEOUT,
|
|
33
|
+
});
|
|
34
|
+
const pubkeyMsg = response.proto;
|
|
35
|
+
const pubkey = bs58check.decode(core.mustBeDefined(pubkeyMsg.getXpub())).slice(45);
|
|
36
|
+
return transport.lockDuring(async () => {
|
|
37
|
+
const signTx = new ThorchainMessages.ThorchainSignTx();
|
|
38
|
+
signTx.setAddressNList(msg.addressNList);
|
|
39
|
+
signTx.setAccountNumber(msg.account_number);
|
|
40
|
+
signTx.setChainId(msg.chain_id);
|
|
41
|
+
signTx.setFeeAmount(parseInt(msg.tx.fee.amount[0].amount));
|
|
42
|
+
signTx.setGas(parseInt(msg.tx.fee.gas));
|
|
43
|
+
signTx.setSequence(msg.sequence);
|
|
44
|
+
if (msg.tx.memo !== undefined)
|
|
45
|
+
signTx.setMemo(msg.tx.memo);
|
|
46
|
+
signTx.setMsgCount(1);
|
|
47
|
+
let resp = await transport.call(Messages.MessageType.MESSAGETYPE_THORCHAINSIGNTX, signTx, {
|
|
48
|
+
msgTimeout: core.LONG_TIMEOUT,
|
|
49
|
+
omitLock: true,
|
|
76
50
|
});
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
signTx.setGas(parseInt(msg.tx.fee.gas));
|
|
86
|
-
signTx.setSequence(msg.sequence);
|
|
87
|
-
if (msg.tx.memo !== undefined)
|
|
88
|
-
signTx.setMemo(msg.tx.memo);
|
|
89
|
-
signTx.setMsgCount(1);
|
|
90
|
-
let resp = yield transport.call(Messages.MessageType.MESSAGETYPE_THORCHAINSIGNTX, signTx, {
|
|
91
|
-
msgTimeout: core.LONG_TIMEOUT,
|
|
92
|
-
omitLock: true,
|
|
93
|
-
});
|
|
94
|
-
for (const m of msg.tx.msg) {
|
|
95
|
-
if (resp.message_enum !== Messages.MessageType.MESSAGETYPE_THORCHAINMSGREQUEST) {
|
|
96
|
-
throw new Error(`THORChain: unexpected response ${resp.message_type}`);
|
|
51
|
+
for (const m of msg.tx.msg) {
|
|
52
|
+
if (resp.message_enum !== Messages.MessageType.MESSAGETYPE_THORCHAINMSGREQUEST) {
|
|
53
|
+
throw new Error(`THORChain: unexpected response ${resp.message_type}`);
|
|
54
|
+
}
|
|
55
|
+
let ack;
|
|
56
|
+
if (m.type === "thorchain/MsgSend") {
|
|
57
|
+
if (m.value.amount.length !== 1) {
|
|
58
|
+
throw new Error("THORChain: Multiple amounts per MsgSend not supported");
|
|
97
59
|
}
|
|
98
|
-
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
throw new Error("THORChain: Multiple amounts per MsgSend not supported");
|
|
102
|
-
}
|
|
103
|
-
const denom = m.value.amount[0].denom;
|
|
104
|
-
if (denom !== "rune") {
|
|
105
|
-
throw new Error("THORChain: Unsupported denomination: " + denom);
|
|
106
|
-
}
|
|
107
|
-
const send = new ThorchainMessages.ThorchainMsgSend();
|
|
108
|
-
send.setFromAddress(m.value.from_address);
|
|
109
|
-
send.setToAddress(m.value.to_address);
|
|
110
|
-
send.setAmount(m.value.amount[0].amount);
|
|
111
|
-
ack = new ThorchainMessages.ThorchainMsgAck();
|
|
112
|
-
ack.setSend(send);
|
|
60
|
+
const denom = m.value.amount[0].denom;
|
|
61
|
+
if (denom !== "rune") {
|
|
62
|
+
throw new Error("THORChain: Unsupported denomination: " + denom);
|
|
113
63
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
deposit.setAmount(m.value.coins[0].amount);
|
|
125
|
-
deposit.setMemo(m.value.memo);
|
|
126
|
-
deposit.setSigner(m.value.signer);
|
|
127
|
-
ack = new ThorchainMessages.ThorchainMsgAck();
|
|
128
|
-
ack.setDeposit(deposit);
|
|
64
|
+
const send = new ThorchainMessages.ThorchainMsgSend();
|
|
65
|
+
send.setFromAddress(m.value.from_address);
|
|
66
|
+
send.setToAddress(m.value.to_address);
|
|
67
|
+
send.setAmount(m.value.amount[0].amount);
|
|
68
|
+
ack = new ThorchainMessages.ThorchainMsgAck();
|
|
69
|
+
ack.setSend(send);
|
|
70
|
+
}
|
|
71
|
+
else if (m.type === "thorchain/MsgDeposit") {
|
|
72
|
+
if (m.value.coins.length !== 1) {
|
|
73
|
+
throw new Error("THORChain: Multiple amounts per MsgDeposit not supported");
|
|
129
74
|
}
|
|
130
|
-
|
|
131
|
-
|
|
75
|
+
const coinAsset = m.value.coins[0].asset;
|
|
76
|
+
if (coinAsset !== "THOR.RUNE") {
|
|
77
|
+
throw new Error("THORChain: Unsupported coin asset: " + coinAsset);
|
|
132
78
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
79
|
+
const deposit = new ThorchainMessages.ThorchainMsgDeposit();
|
|
80
|
+
deposit.setAsset(m.value.coins[0].asset);
|
|
81
|
+
deposit.setAmount(m.value.coins[0].amount);
|
|
82
|
+
deposit.setMemo(m.value.memo);
|
|
83
|
+
deposit.setSigner(m.value.signer);
|
|
84
|
+
ack = new ThorchainMessages.ThorchainMsgAck();
|
|
85
|
+
ack.setDeposit(deposit);
|
|
137
86
|
}
|
|
138
|
-
|
|
139
|
-
throw new Error(`THORChain:
|
|
87
|
+
else {
|
|
88
|
+
throw new Error(`THORChain: Message ${m.type} is not yet supported`);
|
|
140
89
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
90
|
+
resp = await transport.call(Messages.MessageType.MESSAGETYPE_THORCHAINMSGACK, ack, {
|
|
91
|
+
msgTimeout: core.LONG_TIMEOUT,
|
|
92
|
+
omitLock: true,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (resp.message_enum !== Messages.MessageType.MESSAGETYPE_THORCHAINSIGNEDTX) {
|
|
96
|
+
throw new Error(`THORChain: unexpected response ${resp.message_type}`);
|
|
97
|
+
}
|
|
98
|
+
const signedTx = resp.proto;
|
|
99
|
+
const offlineSigner = {
|
|
100
|
+
async getAccounts() {
|
|
101
|
+
return [
|
|
102
|
+
{
|
|
103
|
+
address,
|
|
104
|
+
algo: "secp256k1",
|
|
105
|
+
pubkey,
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
},
|
|
109
|
+
async signAmino(signerAddress, signDoc) {
|
|
110
|
+
if (signerAddress !== address)
|
|
111
|
+
throw new Error("expected signerAddress to match address");
|
|
112
|
+
return {
|
|
113
|
+
signed: signDoc,
|
|
114
|
+
signature: {
|
|
115
|
+
pub_key: {
|
|
116
|
+
type: "tendermint/PubKeySecp256k1",
|
|
117
|
+
value: signedTx.getPublicKey_asB64(),
|
|
118
|
+
},
|
|
119
|
+
signature: signedTx.getSignature_asB64(),
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
const signerData = {
|
|
125
|
+
sequence: Number(msg.sequence),
|
|
126
|
+
accountNumber: Number(msg.account_number),
|
|
127
|
+
chainId: msg.chain_id,
|
|
128
|
+
};
|
|
129
|
+
return (await protoTxBuilder).sign(address, msg.tx, offlineSigner, signerData, "thor");
|
|
178
130
|
});
|
|
179
131
|
}
|
|
180
|
-
exports.thorchainSignTx = thorchainSignTx;
|
|
181
132
|
//# sourceMappingURL=thorchain.js.map
|
package/dist/thorchain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thorchain.js","sourceRoot":"","sources":["../src/thorchain.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"thorchain.js","sourceRoot":"","sources":["../src/thorchain.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,0CAA0C,CAAC;AACrE,OAAO,KAAK,iBAAiB,MAAM,oDAAoD,CAAC;AACxF,OAAO,KAAK,IAAI,MAAM,8BAA8B,CAAC;AACrD,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,MAAM,QAAQ,CAAC;AAI3B,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,iCAAiC,CAAC,CAAC,CAAC;AAEnF,MAAM,UAAU,wBAAwB,CAAC,GAAkC;IACzE,OAAO;QACL;YACE,YAAY,EAAE,CAAC,UAAU,GAAG,EAAE,EAAE,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC;SAChH;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,SAAoB,EACpB,GAAmD;IAEnD,MAAM,OAAO,GAAG,IAAI,iBAAiB,CAAC,mBAAmB,EAAE,CAAC;IAC5D,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC1C,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC;IAClD,IAAI,GAAG,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC/D,MAAM,QAAQ,G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