example-js-sdk 0.0.6 → 0.0.7
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/README.md +134 -52
- package/lib/OrbixSDK.d.ts +145 -0
- package/lib/{CarbonSDK.js → OrbixSDK.js} +52 -52
- package/lib/clients/ETHClient.d.ts +10 -10
- package/lib/clients/ETHClient.js +4 -4
- package/lib/clients/{CarbonQueryClient.d.ts → OrbixQueryClient.d.ts} +4 -4
- package/lib/clients/{CarbonQueryClient.js → OrbixQueryClient.js} +2 -2
- package/lib/clients/TokenClient.d.ts +26 -26
- package/lib/clients/TokenClient.js +5 -5
- package/lib/clients/index.d.ts +1 -1
- package/lib/clients/index.js +3 -3
- package/lib/codec/index.d.ts +1 -1
- package/lib/codec/index.js +253 -253
- package/lib/constant/eip712.d.ts +1 -1
- package/lib/constant/eip712.js +3 -3
- package/lib/constant/generic.d.ts +1 -1
- package/lib/constant/generic.js +2 -2
- package/lib/constant/ibc.d.ts +0 -1
- package/lib/constant/ibc.js +0 -32
- package/lib/constant/network.d.ts +2 -2
- package/lib/constant/network.js +3 -3
- package/lib/constant/node.js +2 -74
- package/lib/constant/web3Config.d.ts +5 -5
- package/lib/constant/web3Config.js +18 -22
- package/lib/index.d.ts +3 -3
- package/lib/index.js +7 -7
- package/lib/insights/balance.d.ts +2 -2
- package/lib/modules/admin.d.ts +23 -23
- package/lib/modules/admin.js +43 -43
- package/lib/modules/alliance.d.ts +6 -6
- package/lib/modules/alliance.js +5 -5
- package/lib/modules/bank.d.ts +2 -2
- package/lib/modules/bank.js +1 -1
- package/lib/modules/base.d.ts +4 -4
- package/lib/modules/bridge.d.ts +3 -3
- package/lib/modules/bridge.js +5 -5
- package/lib/modules/broker.d.ts +3 -3
- package/lib/modules/broker.js +2 -2
- package/lib/modules/coin.d.ts +8 -8
- package/lib/modules/coin.js +7 -7
- package/lib/modules/evm.d.ts +2 -2
- package/lib/modules/evm.js +1 -1
- package/lib/modules/evmmerge.d.ts +2 -2
- package/lib/modules/evmmerge.js +3 -3
- package/lib/modules/gov.d.ts +4 -4
- package/lib/modules/gov.js +3 -3
- package/lib/modules/grant.d.ts +4 -4
- package/lib/modules/grant.js +6 -6
- package/lib/modules/ibc.d.ts +3 -3
- package/lib/modules/ibc.js +2 -2
- package/lib/modules/leverage.d.ts +3 -3
- package/lib/modules/leverage.js +2 -2
- package/lib/modules/market.d.ts +15 -15
- package/lib/modules/market.js +7 -7
- package/lib/modules/order.d.ts +8 -8
- package/lib/modules/order.js +7 -7
- package/lib/modules/perpspool.d.ts +14 -14
- package/lib/modules/perpspool.js +23 -23
- package/lib/modules/position.d.ts +3 -3
- package/lib/modules/position.js +2 -2
- package/lib/modules/staking.d.ts +6 -6
- package/lib/modules/subaccount.d.ts +4 -4
- package/lib/modules/subaccount.js +3 -3
- package/lib/provider/amino/types/admin.js +12 -12
- package/lib/provider/amino/types/bank.js +2 -2
- package/lib/provider/amino/types/bridge.js +3 -3
- package/lib/provider/amino/types/broker.js +2 -2
- package/lib/provider/amino/types/coin.js +5 -5
- package/lib/provider/amino/types/evm.js +2 -2
- package/lib/provider/amino/types/evmmerge.js +2 -2
- package/lib/provider/amino/types/feemarket.js +2 -2
- package/lib/provider/amino/types/gov.js +17 -17
- package/lib/provider/amino/types/grant.js +6 -6
- package/lib/provider/amino/types/group.js +4 -4
- package/lib/provider/amino/types/ibc.js +2 -2
- package/lib/provider/amino/types/leverage.js +2 -2
- package/lib/provider/amino/types/market.js +7 -7
- package/lib/provider/amino/types/order.js +5 -5
- package/lib/provider/amino/types/perpspool.js +11 -11
- package/lib/provider/amino/types/position.js +2 -2
- package/lib/provider/amino/types/staking.js +5 -5
- package/lib/provider/amino/types/subaccount.js +4 -4
- package/lib/provider/keplr/KeplrAccount.d.ts +3 -3
- package/lib/provider/keplr/KeplrAccount.js +8 -8
- package/lib/provider/leap/LeapAccount.d.ts +3 -3
- package/lib/provider/leap/LeapAccount.js +7 -7
- package/lib/provider/metamask/MetaMask.d.ts +8 -8
- package/lib/provider/metamask/MetaMask.js +17 -17
- package/lib/provider/rainbowKit/RainbowKitAccount.d.ts +7 -7
- package/lib/provider/rainbowKit/RainbowKitAccount.js +12 -12
- package/lib/provider/sdk/SDKProvider.d.ts +4 -4
- package/lib/util/alliance.js +1 -1
- package/lib/util/blockchain.d.ts +5 -5
- package/lib/util/blockchain.js +11 -11
- package/lib/util/eip712.d.ts +2 -2
- package/lib/util/eip712.js +1 -1
- package/lib/util/ethermint.d.ts +4 -4
- package/lib/util/ethermint.js +1 -1
- package/lib/util/external.d.ts +2 -2
- package/lib/util/gov.js +16 -16
- package/lib/util/index.d.ts +1 -1
- package/lib/util/index.js +2 -2
- package/lib/util/legacyEIP712.js +1 -1
- package/lib/util/network.d.ts +1 -1
- package/lib/util/network.js +7 -7
- package/lib/util/provider.js +1 -1
- package/lib/util/tx.d.ts +3 -3
- package/lib/util/tx.js +9 -9
- package/lib/wallet/{CarbonSigner.d.ts → OrbixSigner.d.ts} +19 -19
- package/lib/wallet/{CarbonSigner.js → OrbixSigner.js} +19 -19
- package/lib/wallet/{CarbonSigningClient.d.ts → OrbixSigningClient.d.ts} +3 -3
- package/lib/wallet/{CarbonSigningClient.js → OrbixSigningClient.js} +9 -9
- package/lib/wallet/{CarbonWallet.d.ts → OrbixWallet.d.ts} +38 -38
- package/lib/wallet/{CarbonWallet.js → OrbixWallet.js} +39 -39
- package/lib/wallet/index.d.ts +2 -2
- package/lib/wallet/index.js +2 -2
- package/package.json +1 -1
- package/lib/CarbonSDK.d.ts +0 -145
- /package/lib/codec/{carbon-models.d.ts → orbix-models.d.ts} +0 -0
- /package/lib/codec/{carbon-models.js → orbix-models.js} +0 -0
package/lib/util/gov.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.decodeContent = exports.emptyProposal = exports.ProposalTypes = void 0;
|
|
4
|
-
const
|
|
4
|
+
const OrbixSDK_1 = require("../OrbixSDK");
|
|
5
5
|
const codec_1 = require("../codec");
|
|
6
6
|
const tx_1 = require("../codec/Mememax/orbix/fee/tx");
|
|
7
7
|
const distribution_1 = require("../codec/cosmos/distribution/v1beta1/distribution");
|
|
@@ -81,7 +81,7 @@ const decodeContent = (content) => {
|
|
|
81
81
|
}
|
|
82
82
|
let url = content.typeUrl;
|
|
83
83
|
let value = content.value;
|
|
84
|
-
if (url ==
|
|
84
|
+
if (url == OrbixSDK_1.OrbixTx.Types.MsgGovExecLegacyContent) {
|
|
85
85
|
// wrapper msg for legacy prop, actual proposal is nested within this
|
|
86
86
|
const wrapperMsg = tx_3.MsgExecLegacyContent.decode(content.value);
|
|
87
87
|
url = wrapperMsg.content.typeUrl;
|
|
@@ -116,12 +116,12 @@ const decodeContent = (content) => {
|
|
|
116
116
|
case ProposalTypes.CreateToken:
|
|
117
117
|
return {
|
|
118
118
|
typeUrl: url,
|
|
119
|
-
value:
|
|
119
|
+
value: OrbixSDK_1.Orbix.Coin.CreateTokenProposal.decode(value),
|
|
120
120
|
};
|
|
121
121
|
case ProposalTypes.UpdateMarket:
|
|
122
122
|
return {
|
|
123
123
|
typeUrl: url,
|
|
124
|
-
value:
|
|
124
|
+
value: OrbixSDK_1.Orbix.Market.UpdateMarketProposal.decode(value),
|
|
125
125
|
};
|
|
126
126
|
case ProposalTypes.ClientUpdateProposal:
|
|
127
127
|
return {
|
|
@@ -131,33 +131,33 @@ const decodeContent = (content) => {
|
|
|
131
131
|
case ProposalTypes.CreateAlliance:
|
|
132
132
|
return {
|
|
133
133
|
typeUrl: url,
|
|
134
|
-
value:
|
|
134
|
+
value: OrbixSDK_1.Orbix.Alliance.MsgCreateAllianceProposal.decode(value),
|
|
135
135
|
};
|
|
136
136
|
case ProposalTypes.UpdateAlliance:
|
|
137
137
|
return {
|
|
138
138
|
typeUrl: url,
|
|
139
|
-
value:
|
|
139
|
+
value: OrbixSDK_1.Orbix.Alliance.MsgUpdateAllianceProposal.decode(value),
|
|
140
140
|
};
|
|
141
141
|
case ProposalTypes.DeleteAlliance:
|
|
142
142
|
return {
|
|
143
143
|
typeUrl: url,
|
|
144
|
-
value:
|
|
144
|
+
value: OrbixSDK_1.Orbix.Alliance.MsgDeleteAllianceProposal.decode(value),
|
|
145
145
|
};
|
|
146
146
|
// update with new proposal messages
|
|
147
147
|
case ProposalTypes.SetMsgGasCostV2:
|
|
148
148
|
return {
|
|
149
149
|
typeUrl: url,
|
|
150
|
-
value:
|
|
150
|
+
value: OrbixSDK_1.Orbix.Fee.MsgSetGasCost.decode(value),
|
|
151
151
|
};
|
|
152
152
|
case ProposalTypes.SetMinGasPriceV2:
|
|
153
153
|
return {
|
|
154
154
|
typeUrl: url,
|
|
155
|
-
value:
|
|
155
|
+
value: OrbixSDK_1.Orbix.Fee.MsgSetMinGasPrice.decode(value),
|
|
156
156
|
};
|
|
157
157
|
case ProposalTypes.RemoveMsgGasCostV2:
|
|
158
158
|
return {
|
|
159
159
|
typeUrl: url,
|
|
160
|
-
value:
|
|
160
|
+
value: OrbixSDK_1.Orbix.Fee.MsgRemoveGasCost.decode(value),
|
|
161
161
|
};
|
|
162
162
|
case ProposalTypes.RemoveMinGasPriceV2:
|
|
163
163
|
return {
|
|
@@ -182,32 +182,32 @@ const decodeContent = (content) => {
|
|
|
182
182
|
case ProposalTypes.CreateAllianceV2:
|
|
183
183
|
return {
|
|
184
184
|
typeUrl: url,
|
|
185
|
-
value:
|
|
185
|
+
value: OrbixSDK_1.Orbix.Alliance.MsgCreateAlliance.decode(value),
|
|
186
186
|
};
|
|
187
187
|
case ProposalTypes.UpdateAllianceV2:
|
|
188
188
|
return {
|
|
189
189
|
typeUrl: url,
|
|
190
|
-
value:
|
|
190
|
+
value: OrbixSDK_1.Orbix.Alliance.MsgUpdateAlliance.decode(value),
|
|
191
191
|
};
|
|
192
192
|
case ProposalTypes.DeleteAllianceV2:
|
|
193
193
|
return {
|
|
194
194
|
typeUrl: url,
|
|
195
|
-
value:
|
|
195
|
+
value: OrbixSDK_1.Orbix.Alliance.MsgDeleteAlliance.decode(value),
|
|
196
196
|
};
|
|
197
197
|
case ProposalTypes.UpdateMarketV2:
|
|
198
198
|
return {
|
|
199
199
|
typeUrl: url,
|
|
200
|
-
value:
|
|
200
|
+
value: OrbixSDK_1.Orbix.Market.MsgUpdateMarket.decode(value),
|
|
201
201
|
};
|
|
202
202
|
case ProposalTypes.SettlementPriceV2:
|
|
203
203
|
return {
|
|
204
204
|
typeUrl: url,
|
|
205
|
-
value:
|
|
205
|
+
value: OrbixSDK_1.Orbix.Pricing.MsgUpdateSettlementPrice.decode(value),
|
|
206
206
|
};
|
|
207
207
|
case ProposalTypes.CreateOracleV2:
|
|
208
208
|
return {
|
|
209
209
|
typeUrl: url,
|
|
210
|
-
value:
|
|
210
|
+
value: OrbixSDK_1.Orbix.Oracle.MsgCreateOracle.decode(value),
|
|
211
211
|
};
|
|
212
212
|
case codec_1.TxTypes.MsgAuthUpdateParams:
|
|
213
213
|
return {
|
package/lib/util/index.d.ts
CHANGED
|
@@ -15,6 +15,6 @@ export * as NetworkUtils from "./network";
|
|
|
15
15
|
export * as NumberUtils from "./number";
|
|
16
16
|
export * as TokenUtils from "./token";
|
|
17
17
|
export * as TransferUtils from "./transferfees";
|
|
18
|
-
export * as
|
|
18
|
+
export * as OrbixTx from "./tx";
|
|
19
19
|
export * as TypeUtils from "./type";
|
|
20
20
|
export * as BytesUtils from "./bytes";
|
package/lib/util/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.BytesUtils = exports.TypeUtils = exports.
|
|
36
|
+
exports.BytesUtils = exports.TypeUtils = exports.OrbixTx = exports.TransferUtils = exports.TokenUtils = exports.NumberUtils = exports.NetworkUtils = exports.MessageUtils = exports.IBCUtils = exports.GrantUtils = exports.GovUtils = exports.GenericUtils = exports.FetchUtils = exports.ExternalUtils = exports.EvmUtils = exports.BlockchainUtils = exports.AuthUtils = exports.APIUtils = exports.AllianceUtils = exports.AddressUtils = void 0;
|
|
37
37
|
exports.AddressUtils = __importStar(require("./address"));
|
|
38
38
|
exports.AllianceUtils = __importStar(require("./alliance"));
|
|
39
39
|
exports.APIUtils = __importStar(require("./api"));
|
|
@@ -51,6 +51,6 @@ exports.NetworkUtils = __importStar(require("./network"));
|
|
|
51
51
|
exports.NumberUtils = __importStar(require("./number"));
|
|
52
52
|
exports.TokenUtils = __importStar(require("./token"));
|
|
53
53
|
exports.TransferUtils = __importStar(require("./transferfees"));
|
|
54
|
-
exports.
|
|
54
|
+
exports.OrbixTx = __importStar(require("./tx"));
|
|
55
55
|
exports.TypeUtils = __importStar(require("./type"));
|
|
56
56
|
exports.BytesUtils = __importStar(require("./bytes"));
|
package/lib/util/legacyEIP712.js
CHANGED
|
@@ -93,7 +93,7 @@ function legacyConstructEIP712Tx(doc) {
|
|
|
93
93
|
const eip712Tx = {
|
|
94
94
|
types: getTypes(AminoTypesMap_1.default.fromAmino(msg).typeUrl, msg.value),
|
|
95
95
|
primaryType: "Tx",
|
|
96
|
-
domain: { ...eip712_1.
|
|
96
|
+
domain: { ...eip712_1.DEFAULT_ORBIX_DOMAIN_FIELDS, chainId: (0, ethermint_1.parseChainId)(doc.chain_id) },
|
|
97
97
|
message: doc,
|
|
98
98
|
};
|
|
99
99
|
return eip712Tx;
|
package/lib/util/network.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ import { Network } from "../constant";
|
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
8
|
export declare const parseNetwork: (network: string, defaultNetwork?: Network | null) => Network | null;
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const orbixNetworkFromChainId: (parsedEvmChainId: string) => Network;
|
package/lib/util/network.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.orbixNetworkFromChainId = exports.parseNetwork = void 0;
|
|
4
4
|
const constant_1 = require("../constant");
|
|
5
5
|
const index_1 = require("../index");
|
|
6
6
|
const ethermint_1 = require("./ethermint");
|
|
@@ -28,12 +28,12 @@ const parseNetwork = (network, defaultNetwork = constant_1.DEFAULT_NETWORK) => {
|
|
|
28
28
|
return defaultNetwork;
|
|
29
29
|
};
|
|
30
30
|
exports.parseNetwork = parseNetwork;
|
|
31
|
-
const
|
|
31
|
+
const orbixNetworkFromChainId = (parsedEvmChainId) => {
|
|
32
32
|
switch (parsedEvmChainId) {
|
|
33
|
-
case (0, ethermint_1.parseChainId)(constant_1.
|
|
34
|
-
case (0, ethermint_1.parseChainId)(constant_1.
|
|
35
|
-
case (0, ethermint_1.parseChainId)(constant_1.
|
|
36
|
-
default: return index_1.
|
|
33
|
+
case (0, ethermint_1.parseChainId)(constant_1.OrbixEvmChainIDs[index_1.OrbixSDK.Network.LocalHost]): return index_1.OrbixSDK.Network.LocalHost;
|
|
34
|
+
case (0, ethermint_1.parseChainId)(constant_1.OrbixEvmChainIDs[index_1.OrbixSDK.Network.DevNet]): return index_1.OrbixSDK.Network.DevNet;
|
|
35
|
+
case (0, ethermint_1.parseChainId)(constant_1.OrbixEvmChainIDs[index_1.OrbixSDK.Network.TestNet]): return index_1.OrbixSDK.Network.TestNet;
|
|
36
|
+
default: return index_1.OrbixSDK.Network.MainNet;
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
exports.
|
|
39
|
+
exports.orbixNetworkFromChainId = orbixNetworkFromChainId;
|
package/lib/util/provider.js
CHANGED
|
@@ -7,6 +7,6 @@ async function signTransactionWrapper(signTxTask) {
|
|
|
7
7
|
return await signTxTask();
|
|
8
8
|
}
|
|
9
9
|
catch (err) {
|
|
10
|
-
throw new tx_1.
|
|
10
|
+
throw new tx_1.OrbixCustomError(err.message, tx_1.ErrorType.SIGNATURE_REJECTION);
|
|
11
11
|
}
|
|
12
12
|
}
|
package/lib/util/tx.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare enum BroadcastTxMode {
|
|
|
17
17
|
BroadcastTxAsync = "async",
|
|
18
18
|
BroadcastTxBlock = "block"
|
|
19
19
|
}
|
|
20
|
-
export interface
|
|
20
|
+
export interface OrbixSignerData extends SignerData {
|
|
21
21
|
timeoutHeight?: number;
|
|
22
22
|
evmChainId?: string;
|
|
23
23
|
}
|
|
@@ -28,7 +28,7 @@ export interface SignTxOpts {
|
|
|
28
28
|
memo?: string;
|
|
29
29
|
sequence?: number;
|
|
30
30
|
accountNumber?: number;
|
|
31
|
-
explicitSignerData?: Partial<
|
|
31
|
+
explicitSignerData?: Partial<OrbixSignerData>;
|
|
32
32
|
processMsgs?: ProcessMsgsCallback;
|
|
33
33
|
triggerMerge?: boolean;
|
|
34
34
|
}
|
|
@@ -58,7 +58,7 @@ export declare enum ErrorType {
|
|
|
58
58
|
BROADCAST_FAIL = "broadcast_fail",
|
|
59
59
|
BLOCK_FAIL = "block_fail"
|
|
60
60
|
}
|
|
61
|
-
export declare class
|
|
61
|
+
export declare class OrbixCustomError extends Error {
|
|
62
62
|
readonly type?: ErrorType;
|
|
63
63
|
readonly data?: any;
|
|
64
64
|
constructor(msg: string, type?: ErrorType, data?: any);
|
package/lib/util/tx.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.isLibMsg = exports.useSignDirectForMetamask = exports.TxGasCostTypeMap = exports.TxMinGasPriceTypeDefaultKey = exports.TxGasCostTypeDefaultKey = exports.DEFAULT_SIGN_OPTS = exports.Types = exports.
|
|
36
|
+
exports.isLibMsg = exports.useSignDirectForMetamask = exports.TxGasCostTypeMap = exports.TxMinGasPriceTypeDefaultKey = exports.TxGasCostTypeDefaultKey = exports.DEFAULT_SIGN_OPTS = exports.Types = exports.OrbixCustomError = exports.ErrorType = exports.BroadcastTxMode = exports.getSender = exports.decode = void 0;
|
|
37
37
|
const codec_1 = require("../codec");
|
|
38
38
|
const CosmosModels = __importStar(require("../codec/cosmos-models"));
|
|
39
39
|
const constant_1 = require("../constant");
|
|
@@ -81,12 +81,12 @@ const decode = (bytes) => {
|
|
|
81
81
|
if (!bytes)
|
|
82
82
|
return bytes;
|
|
83
83
|
const decodedTx = CosmosModels.Tx.Tx.decode((0, bytes_1.toUint8Array)(bytes));
|
|
84
|
-
const
|
|
84
|
+
const orbixTx = { ...decodedTx, body: undefined };
|
|
85
85
|
if (decodedTx.body) {
|
|
86
|
-
|
|
86
|
+
orbixTx.body = { ...decodedTx.body, messages: [] };
|
|
87
87
|
for (const message of decodedTx.body.messages) {
|
|
88
88
|
try {
|
|
89
|
-
|
|
89
|
+
orbixTx.body.messages.push({
|
|
90
90
|
typeUrl: message.typeUrl,
|
|
91
91
|
value: decodeNestedMsg(codec_1.registry.decode(message)),
|
|
92
92
|
});
|
|
@@ -94,14 +94,14 @@ const decode = (bytes) => {
|
|
|
94
94
|
catch (error) {
|
|
95
95
|
console.error(`failed to decode tx message: ${message?.typeUrl}`);
|
|
96
96
|
console.error(error);
|
|
97
|
-
|
|
97
|
+
orbixTx.body.messages.push(message);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
else {
|
|
102
|
-
delete
|
|
102
|
+
delete orbixTx.body;
|
|
103
103
|
}
|
|
104
|
-
return
|
|
104
|
+
return orbixTx;
|
|
105
105
|
};
|
|
106
106
|
exports.decode = decode;
|
|
107
107
|
const getSender = (decodedTx, opts) => {
|
|
@@ -125,14 +125,14 @@ var ErrorType;
|
|
|
125
125
|
ErrorType["BROADCAST_FAIL"] = "broadcast_fail";
|
|
126
126
|
ErrorType["BLOCK_FAIL"] = "block_fail";
|
|
127
127
|
})(ErrorType || (exports.ErrorType = ErrorType = {}));
|
|
128
|
-
class
|
|
128
|
+
class OrbixCustomError extends Error {
|
|
129
129
|
constructor(msg, type, data) {
|
|
130
130
|
super(msg);
|
|
131
131
|
this.type = type;
|
|
132
132
|
this.data = data;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
exports.
|
|
135
|
+
exports.OrbixCustomError = OrbixCustomError;
|
|
136
136
|
exports.Types = codec_1.TxTypes;
|
|
137
137
|
exports.DEFAULT_SIGN_OPTS = {
|
|
138
138
|
fee: constant_1.DEFAULT_FEE,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import OrbixSDK from "../OrbixSDK";
|
|
2
2
|
import { SignDoc } from "cosmjs-types/cosmos/tx/v1beta1/tx";
|
|
3
3
|
import { CosmosLedger } from "../provider";
|
|
4
4
|
import { AminoSignResponse, OfflineAminoSigner, Secp256k1Wallet, StdSignDoc } from "@cosmjs/amino";
|
|
5
5
|
import { AccountData, DirectSecp256k1Wallet, DirectSignResponse, OfflineDirectSigner, OfflineSigner } from "@cosmjs/proto-signing";
|
|
6
6
|
import { ethers } from "ethers";
|
|
7
|
-
export declare enum
|
|
7
|
+
export declare enum OrbixSignerTypes {
|
|
8
8
|
Ledger = 0,
|
|
9
9
|
PrivateKey = 1,
|
|
10
10
|
BrowserInjected = 2,
|
|
11
11
|
PublicKey = 3
|
|
12
12
|
}
|
|
13
13
|
export interface EvmSigner {
|
|
14
|
-
readonly sendEvmTransaction: (api:
|
|
14
|
+
readonly sendEvmTransaction: (api: OrbixSDK, req: ethers.providers.TransactionRequest) => Promise<string>;
|
|
15
15
|
}
|
|
16
16
|
export interface ArbitraryMessageSigner {
|
|
17
17
|
readonly signMessage: (address: string, message: string) => Promise<string>;
|
|
@@ -20,22 +20,22 @@ export interface EIP712Signer extends EvmSigner {
|
|
|
20
20
|
legacyEip712SignMode: boolean;
|
|
21
21
|
readonly signLegacyEip712: (signerAddress: string, signDoc: StdSignDoc) => Promise<LegacyEIP712AminoSignResponse>;
|
|
22
22
|
}
|
|
23
|
-
export type
|
|
24
|
-
export type
|
|
25
|
-
export type
|
|
26
|
-
type:
|
|
23
|
+
export type OrbixSigner = DirectOrbixSigner | AminoOrbixSigner | OrbixEIP712Signer;
|
|
24
|
+
export type OrbixEIP712Signer = (DirectOrbixSigner | AminoOrbixSigner) & EIP712Signer & ArbitraryMessageSigner;
|
|
25
|
+
export type DirectOrbixSigner = OfflineDirectSigner & EvmSigner & ArbitraryMessageSigner & {
|
|
26
|
+
type: OrbixSignerTypes;
|
|
27
27
|
};
|
|
28
|
-
export type
|
|
29
|
-
type:
|
|
28
|
+
export type AminoOrbixSigner = OfflineAminoSigner & EvmSigner & ArbitraryMessageSigner & {
|
|
29
|
+
type: OrbixSignerTypes;
|
|
30
30
|
};
|
|
31
31
|
export type LegacyEIP712AminoSignResponse = AminoSignResponse & {
|
|
32
32
|
feePayer: string;
|
|
33
33
|
};
|
|
34
|
-
export declare function
|
|
35
|
-
export declare class
|
|
34
|
+
export declare function isOrbixEIP712Signer(signer: OfflineSigner): boolean;
|
|
35
|
+
export declare class OrbixPrivateKeySigner implements DirectOrbixSigner, AminoOrbixSigner {
|
|
36
36
|
readonly privateKey: Uint8Array;
|
|
37
37
|
readonly prefix: string;
|
|
38
|
-
type:
|
|
38
|
+
type: OrbixSignerTypes;
|
|
39
39
|
wallet?: DirectSecp256k1Wallet;
|
|
40
40
|
aminoWallet?: Secp256k1Wallet;
|
|
41
41
|
constructor(privateKey: Uint8Array, prefix: string);
|
|
@@ -44,24 +44,24 @@ export declare class CarbonPrivateKeySigner implements DirectCarbonSigner, Amino
|
|
|
44
44
|
getAccounts(): Promise<readonly AccountData[]>;
|
|
45
45
|
signAmino(signerAddress: string, signDoc: StdSignDoc): Promise<AminoSignResponse>;
|
|
46
46
|
signDirect(signerAddress: string, signDoc: SignDoc): Promise<DirectSignResponse>;
|
|
47
|
-
sendEvmTransaction(api:
|
|
47
|
+
sendEvmTransaction(api: OrbixSDK, req: ethers.providers.TransactionRequest): Promise<string>;
|
|
48
48
|
signMessage(address: string, message: string): Promise<string>;
|
|
49
49
|
}
|
|
50
|
-
export declare class
|
|
51
|
-
type:
|
|
50
|
+
export declare class OrbixNonSigner implements DirectOrbixSigner {
|
|
51
|
+
type: OrbixSignerTypes;
|
|
52
52
|
getAccounts(): Promise<readonly AccountData[]>;
|
|
53
53
|
signDirect(): Promise<DirectSignResponse>;
|
|
54
|
-
sendEvmTransaction(api:
|
|
54
|
+
sendEvmTransaction(api: OrbixSDK, req: ethers.providers.TransactionRequest): Promise<string>;
|
|
55
55
|
signMessage(address: string, message: string): Promise<string>;
|
|
56
56
|
}
|
|
57
|
-
export declare class
|
|
57
|
+
export declare class OrbixLedgerSigner implements AminoOrbixSigner {
|
|
58
58
|
readonly ledger: CosmosLedger;
|
|
59
|
-
type:
|
|
59
|
+
type: OrbixSignerTypes;
|
|
60
60
|
account?: AccountData;
|
|
61
61
|
retrieveAccount(): Promise<AccountData>;
|
|
62
62
|
getAccounts(): Promise<readonly AccountData[]>;
|
|
63
63
|
signAmino(_: string, doc: StdSignDoc): Promise<AminoSignResponse>;
|
|
64
|
-
sendEvmTransaction(api:
|
|
64
|
+
sendEvmTransaction(api: OrbixSDK, req: ethers.providers.TransactionRequest): Promise<string>;
|
|
65
65
|
signMessage(_: string, message: string): Promise<string>;
|
|
66
66
|
constructor(ledger: CosmosLedger);
|
|
67
67
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.OrbixLedgerSigner = exports.OrbixNonSigner = exports.OrbixPrivateKeySigner = exports.OrbixSignerTypes = void 0;
|
|
4
|
+
exports.isOrbixEIP712Signer = isOrbixEIP712Signer;
|
|
5
5
|
const constant_1 = require("../constant");
|
|
6
6
|
const ethermint_1 = require("../util/ethermint");
|
|
7
7
|
const generic_1 = require("../util/generic");
|
|
@@ -9,21 +9,21 @@ const message_1 = require("../util/message");
|
|
|
9
9
|
const amino_1 = require("@cosmjs/amino");
|
|
10
10
|
const proto_signing_1 = require("@cosmjs/proto-signing");
|
|
11
11
|
const ethers_1 = require("ethers");
|
|
12
|
-
var
|
|
13
|
-
(function (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})(
|
|
19
|
-
function
|
|
12
|
+
var OrbixSignerTypes;
|
|
13
|
+
(function (OrbixSignerTypes) {
|
|
14
|
+
OrbixSignerTypes[OrbixSignerTypes["Ledger"] = 0] = "Ledger";
|
|
15
|
+
OrbixSignerTypes[OrbixSignerTypes["PrivateKey"] = 1] = "PrivateKey";
|
|
16
|
+
OrbixSignerTypes[OrbixSignerTypes["BrowserInjected"] = 2] = "BrowserInjected";
|
|
17
|
+
OrbixSignerTypes[OrbixSignerTypes["PublicKey"] = 3] = "PublicKey";
|
|
18
|
+
})(OrbixSignerTypes || (exports.OrbixSignerTypes = OrbixSignerTypes = {}));
|
|
19
|
+
function isOrbixEIP712Signer(signer) {
|
|
20
20
|
return signer.signLegacyEip712 !== undefined;
|
|
21
21
|
}
|
|
22
|
-
class
|
|
22
|
+
class OrbixPrivateKeySigner {
|
|
23
23
|
constructor(privateKey, prefix) {
|
|
24
24
|
this.privateKey = privateKey;
|
|
25
25
|
this.prefix = prefix;
|
|
26
|
-
this.type =
|
|
26
|
+
this.type = OrbixSignerTypes.PrivateKey;
|
|
27
27
|
}
|
|
28
28
|
async initWallet() {
|
|
29
29
|
if (!this.wallet)
|
|
@@ -63,10 +63,10 @@ class CarbonPrivateKeySigner {
|
|
|
63
63
|
return Buffer.from(signedDoc.signature.signature, 'base64').toString('hex');
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
exports.
|
|
67
|
-
class
|
|
66
|
+
exports.OrbixPrivateKeySigner = OrbixPrivateKeySigner;
|
|
67
|
+
class OrbixNonSigner {
|
|
68
68
|
constructor() {
|
|
69
|
-
this.type =
|
|
69
|
+
this.type = OrbixSignerTypes.PublicKey;
|
|
70
70
|
}
|
|
71
71
|
async getAccounts() {
|
|
72
72
|
throw new Error("signing not available");
|
|
@@ -81,9 +81,9 @@ class CarbonNonSigner {
|
|
|
81
81
|
throw new Error("signing not available");
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
exports.
|
|
84
|
+
exports.OrbixNonSigner = OrbixNonSigner;
|
|
85
85
|
// Uses amino because ledger does not work with protobuf yet
|
|
86
|
-
class
|
|
86
|
+
class OrbixLedgerSigner {
|
|
87
87
|
async retrieveAccount() {
|
|
88
88
|
if (!this.account) {
|
|
89
89
|
const address = await this.ledger.getCosmosAddress();
|
|
@@ -125,7 +125,7 @@ class CarbonLedgerSigner {
|
|
|
125
125
|
}
|
|
126
126
|
constructor(ledger) {
|
|
127
127
|
this.ledger = ledger;
|
|
128
|
-
this.type =
|
|
128
|
+
this.type = OrbixSignerTypes.Ledger;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
exports.
|
|
131
|
+
exports.OrbixLedgerSigner = OrbixLedgerSigner;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TxRaw } from "../codec/cosmos/tx/v1beta1/tx";
|
|
2
|
-
import {
|
|
2
|
+
import { OrbixSignerData } from "../util/tx";
|
|
3
3
|
import { AminoMsg } from "@cosmjs/amino";
|
|
4
4
|
import { EncodeObject, OfflineSigner, Registry } from "@cosmjs/proto-signing";
|
|
5
5
|
import { AminoTypes, GasPrice, SigningStargateClientOptions, StargateClient, StdFee } from "@cosmjs/stargate";
|
|
@@ -14,7 +14,7 @@ export interface StdSignDoc {
|
|
|
14
14
|
readonly timeout_height: string;
|
|
15
15
|
}
|
|
16
16
|
export declare function makeSignDocAmino(msgs: readonly AminoMsg[], fee: StdFee, chainId: string, memo: string | undefined, accountNumber: number | string, sequence: number | string, timeoutHeight?: number | string): StdSignDoc;
|
|
17
|
-
export declare class
|
|
17
|
+
export declare class OrbixSigningClient extends StargateClient {
|
|
18
18
|
readonly signer: OfflineSigner;
|
|
19
19
|
readonly options: SigningStargateClientOptions;
|
|
20
20
|
readonly registry: Registry;
|
|
@@ -34,7 +34,7 @@ export declare class CarbonSigningClient extends StargateClient {
|
|
|
34
34
|
* from the chain. This is needed when signing for a multisig account, but it also allows for offline signing
|
|
35
35
|
* (See the SigningStargateClient.offline constructor).
|
|
36
36
|
*/
|
|
37
|
-
sign(signerAddress: string, messages: readonly EncodeObject[], fee: StdFee, memo: string, signerData:
|
|
37
|
+
sign(signerAddress: string, messages: readonly EncodeObject[], fee: StdFee, memo: string, signerData: OrbixSignerData, granterAddress?: string): Promise<TxRaw>;
|
|
38
38
|
private signDirect;
|
|
39
39
|
private signAmino;
|
|
40
40
|
private signLegacyEip712;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.OrbixSigningClient = void 0;
|
|
7
7
|
exports.makeSignDocAmino = makeSignDocAmino;
|
|
8
8
|
const codec_1 = require("../codec");
|
|
9
9
|
const tx_1 = require("../codec/cosmos/tx/v1beta1/tx");
|
|
@@ -17,7 +17,7 @@ const proto_signing_1 = require("@cosmjs/proto-signing");
|
|
|
17
17
|
const stargate_1 = require("@cosmjs/stargate");
|
|
18
18
|
const long_1 = __importDefault(require("long"));
|
|
19
19
|
const provider_1 = require("../provider");
|
|
20
|
-
const
|
|
20
|
+
const OrbixSigner_1 = require("./OrbixSigner");
|
|
21
21
|
// Added SignMode enum from cosmjs-types to resolve build error
|
|
22
22
|
var SignMode;
|
|
23
23
|
(function (SignMode) {
|
|
@@ -56,7 +56,7 @@ function makeSignDocAmino(msgs, fee, chainId, memo, accountNumber, sequence, tim
|
|
|
56
56
|
timeout_height: timeoutHeightStr,
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
class
|
|
59
|
+
class OrbixSigningClient extends stargate_1.StargateClient {
|
|
60
60
|
constructor(tmClient, signer, options = {}) {
|
|
61
61
|
super(tmClient, options);
|
|
62
62
|
this.signer = signer;
|
|
@@ -81,7 +81,7 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
81
81
|
* (See the SigningStargateClient.offline constructor).
|
|
82
82
|
*/
|
|
83
83
|
async sign(signerAddress, messages, fee, memo, signerData, granterAddress) {
|
|
84
|
-
if ((0,
|
|
84
|
+
if ((0, OrbixSigner_1.isOrbixEIP712Signer)(this.signer)) {
|
|
85
85
|
if (this.signer.legacyEip712SignMode) {
|
|
86
86
|
return this.signLegacyEip712(signerAddress, messages, fee, memo, signerData);
|
|
87
87
|
}
|
|
@@ -100,11 +100,11 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
100
100
|
async signDirect(signerAddress, messages, fee, memo, { accountNumber, sequence, chainId, timeoutHeight }, granterAddress) {
|
|
101
101
|
const signer = this.signer;
|
|
102
102
|
const accountFromSigner = (await this.signer.getAccounts()).find((account) => account.address === signerAddress);
|
|
103
|
-
if (!(0,
|
|
103
|
+
if (!(0, OrbixSigner_1.isOrbixEIP712Signer)(this.signer) && !accountFromSigner) {
|
|
104
104
|
throw new Error("Failed to retrieve account from signer");
|
|
105
105
|
}
|
|
106
106
|
const pubKeyBz = accountFromSigner ? accountFromSigner.pubkey : (await this.signer.getAccounts())[0].pubkey;
|
|
107
|
-
const pubkey = (0,
|
|
107
|
+
const pubkey = (0, OrbixSigner_1.isOrbixEIP712Signer)(this.signer) ? (0, ethermint_1.encodeAnyEthSecp256k1PubKey)(pubKeyBz) : (0, proto_signing_1.encodePubkey)((0, amino_1.encodeSecp256k1Pubkey)(pubKeyBz));
|
|
108
108
|
const txBodyEncodeObject = {
|
|
109
109
|
typeUrl: "/cosmos.tx.v1beta1.TxBody",
|
|
110
110
|
value: {
|
|
@@ -129,11 +129,11 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
129
129
|
async signAmino(signerAddress, messages, fee, memo, { accountNumber, sequence, chainId, timeoutHeight }, granterAddress) {
|
|
130
130
|
const signer = this.signer;
|
|
131
131
|
const accountFromSigner = (await this.signer.getAccounts()).find((account) => account.address === signerAddress);
|
|
132
|
-
if (!(0,
|
|
132
|
+
if (!(0, OrbixSigner_1.isOrbixEIP712Signer)(this.signer) && !accountFromSigner) {
|
|
133
133
|
throw new Error("Failed to retrieve account from signer");
|
|
134
134
|
}
|
|
135
135
|
const pubKeyBz = accountFromSigner ? accountFromSigner.pubkey : (await this.signer.getAccounts())[0].pubkey;
|
|
136
|
-
const pubkey = (0,
|
|
136
|
+
const pubkey = (0, OrbixSigner_1.isOrbixEIP712Signer)(this.signer) ? (0, ethermint_1.encodeAnyEthSecp256k1PubKey)(pubKeyBz) : (0, proto_signing_1.encodePubkey)((0, amino_1.encodeSecp256k1Pubkey)(pubKeyBz));
|
|
137
137
|
const signMode = SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
|
|
138
138
|
const msgs = messages.map((msg) => this.aminoTypes.toAmino(msg));
|
|
139
139
|
const signDoc = makeSignDocAmino(msgs, fee, chainId, memo, accountNumber, sequence, timeoutHeight ?? 0);
|
|
@@ -198,4 +198,4 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
exports.
|
|
201
|
+
exports.OrbixSigningClient = OrbixSigningClient;
|