@bitgo-beta/abstract-cosmos 0.0.0-semantic-release-managed
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/.eslintignore +5 -0
- package/.mocharc.yml +8 -0
- package/CHANGELOG.md +1056 -0
- package/LICENSE +191 -0
- package/README.md +1 -0
- package/dist/resources/MsgCompiled.d.ts +1212 -0
- package/dist/resources/MsgCompiled.js +2761 -0
- package/dist/src/cosmosCoin.d.ts +196 -0
- package/dist/src/cosmosCoin.d.ts.map +1 -0
- package/dist/src/cosmosCoin.js +718 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +21 -0
- package/dist/src/lib/ContractCallBuilder.d.ts +13 -0
- package/dist/src/lib/ContractCallBuilder.d.ts.map +1 -0
- package/dist/src/lib/ContractCallBuilder.js +61 -0
- package/dist/src/lib/StakingActivateBuilder.d.ts +13 -0
- package/dist/src/lib/StakingActivateBuilder.d.ts.map +1 -0
- package/dist/src/lib/StakingActivateBuilder.js +61 -0
- package/dist/src/lib/StakingDeactivateBuilder.d.ts +13 -0
- package/dist/src/lib/StakingDeactivateBuilder.d.ts.map +1 -0
- package/dist/src/lib/StakingDeactivateBuilder.js +61 -0
- package/dist/src/lib/StakingRedelegateBuilder.d.ts +13 -0
- package/dist/src/lib/StakingRedelegateBuilder.d.ts.map +1 -0
- package/dist/src/lib/StakingRedelegateBuilder.js +61 -0
- package/dist/src/lib/StakingWithdrawRewardsBuilder.d.ts +13 -0
- package/dist/src/lib/StakingWithdrawRewardsBuilder.d.ts.map +1 -0
- package/dist/src/lib/StakingWithdrawRewardsBuilder.js +61 -0
- package/dist/src/lib/constants.d.ts +11 -0
- package/dist/src/lib/constants.d.ts.map +1 -0
- package/dist/src/lib/constants.js +14 -0
- package/dist/src/lib/iface.d.ts +109 -0
- package/dist/src/lib/iface.d.ts.map +1 -0
- package/dist/src/lib/iface.js +20 -0
- package/dist/src/lib/index.d.ts +14 -0
- package/dist/src/lib/index.d.ts.map +1 -0
- package/dist/src/lib/index.js +63 -0
- package/dist/src/lib/keyPair.d.ts +18 -0
- package/dist/src/lib/keyPair.d.ts.map +1 -0
- package/dist/src/lib/keyPair.js +51 -0
- package/dist/src/lib/transaction.d.ts +64 -0
- package/dist/src/lib/transaction.d.ts.map +1 -0
- package/dist/src/lib/transaction.js +333 -0
- package/dist/src/lib/transactionBuilder.d.ts +86 -0
- package/dist/src/lib/transactionBuilder.d.ts.map +1 -0
- package/dist/src/lib/transactionBuilder.js +181 -0
- package/dist/src/lib/transferBuilder.d.ts +13 -0
- package/dist/src/lib/transferBuilder.d.ts.map +1 -0
- package/dist/src/lib/transferBuilder.js +61 -0
- package/dist/src/lib/utils.d.ts +351 -0
- package/dist/src/lib/utils.d.ts.map +1 -0
- package/dist/src/lib/utils.js +856 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +60 -0
- package/resources/MsgCompiled.d.ts +1212 -0
- package/resources/MsgCompiled.js +2761 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { AuditDecryptedKeyParams, BaseCoin, BitGoBase, ExplanationResult, KeyPair, MPCAlgorithm, MultisigType, ParsedTransaction, ParseTransactionOptions, SignedTransaction, SignTransactionOptions, VerifyAddressOptions, VerifyTransactionOptions } from '@bitgo-beta/sdk-core';
|
|
2
|
+
import { BaseCoin as StaticsBaseCoin, CoinFamily } from '@bitgo-beta/statics';
|
|
3
|
+
import { Coin } from '@cosmjs/stargate';
|
|
4
|
+
import { Buffer } from 'buffer';
|
|
5
|
+
import { Hash } from 'crypto';
|
|
6
|
+
import * as request from 'superagent';
|
|
7
|
+
import { CosmosKeyPair, CosmosLikeCoinRecoveryOutput, CosmosTransaction, GasAmountDetails, RecoveryOptions, CosmosTransactionBuilder, KeyShares } from './lib';
|
|
8
|
+
/**
|
|
9
|
+
* Cosmos accounts support memo Id based addresses
|
|
10
|
+
*/
|
|
11
|
+
interface AddressDetails {
|
|
12
|
+
address: string;
|
|
13
|
+
memoId?: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
export declare class CosmosCoin<CustomMessage = never> extends BaseCoin {
|
|
16
|
+
protected readonly _staticsCoin: Readonly<StaticsBaseCoin>;
|
|
17
|
+
protected constructor(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>);
|
|
18
|
+
static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>): BaseCoin;
|
|
19
|
+
/**
|
|
20
|
+
* Creates an instance of TransactionBuilderFactory for the coin specific sdk
|
|
21
|
+
*/
|
|
22
|
+
getBuilder(): any;
|
|
23
|
+
/** @inheritDoc **/
|
|
24
|
+
getBaseFactor(): string | number;
|
|
25
|
+
/** @inheritDoc **/
|
|
26
|
+
getChain(): string;
|
|
27
|
+
/** @inheritDoc **/
|
|
28
|
+
getFamily(): CoinFamily;
|
|
29
|
+
/** @inheritDoc **/
|
|
30
|
+
getFullName(): string;
|
|
31
|
+
/** @inheritDoc */
|
|
32
|
+
supportsTss(): boolean;
|
|
33
|
+
/** inherited doc */
|
|
34
|
+
getDefaultMultisigType(): MultisigType;
|
|
35
|
+
/** @inheritDoc **/
|
|
36
|
+
getMPCAlgorithm(): MPCAlgorithm;
|
|
37
|
+
/** @inheritDoc **/
|
|
38
|
+
isValidPub(pub: string): boolean;
|
|
39
|
+
/** @inheritDoc **/
|
|
40
|
+
isValidPrv(prv: string): boolean;
|
|
41
|
+
isValidAddress(address: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Builds a funds recovery transaction without BitGo
|
|
44
|
+
* @param {RecoveryOptions} params parameters needed to construct and
|
|
45
|
+
* (maybe) sign the transaction
|
|
46
|
+
*
|
|
47
|
+
* @returns {CosmosLikeCoinRecoveryOutput} the serialized transaction hex string and index
|
|
48
|
+
* of the address being swept
|
|
49
|
+
*/
|
|
50
|
+
recover(params: RecoveryOptions): Promise<CosmosLikeCoinRecoveryOutput>;
|
|
51
|
+
/**
|
|
52
|
+
* Validates the recovery parameters
|
|
53
|
+
*/
|
|
54
|
+
private validateRecoveryParams;
|
|
55
|
+
/**
|
|
56
|
+
* Checks if this is an unsigned sweep operation
|
|
57
|
+
*/
|
|
58
|
+
private isUnsignedSweep;
|
|
59
|
+
/**
|
|
60
|
+
* Gets sender details including address, public key and key shares
|
|
61
|
+
*/
|
|
62
|
+
private getSenderDetails;
|
|
63
|
+
/**
|
|
64
|
+
* Gets key shares from recovery parameters
|
|
65
|
+
*/
|
|
66
|
+
private getKeyShares;
|
|
67
|
+
/**
|
|
68
|
+
* Processes account balances and validates sufficient funds
|
|
69
|
+
*/
|
|
70
|
+
private processBalances;
|
|
71
|
+
/**
|
|
72
|
+
* Builds transaction messages for all balances
|
|
73
|
+
*/
|
|
74
|
+
private buildTransactionMessages;
|
|
75
|
+
/**
|
|
76
|
+
* Builds and signs the transaction
|
|
77
|
+
*/
|
|
78
|
+
private buildAndSignTransaction;
|
|
79
|
+
/**
|
|
80
|
+
* Signs the transaction with MPC
|
|
81
|
+
*/
|
|
82
|
+
/**
|
|
83
|
+
* Signs the transaction using MPC (Multi-Party Computation)
|
|
84
|
+
* @param unsignedTransaction The unsigned transaction to sign
|
|
85
|
+
* @param txnBuilder The transaction builder instance
|
|
86
|
+
* @param keyShares The key shares for MPC signing
|
|
87
|
+
* @param publicKey The public key for verification
|
|
88
|
+
* @returns The signed transaction output
|
|
89
|
+
* @throws Error if validation fails or signing process encounters an error
|
|
90
|
+
*/
|
|
91
|
+
protected signTransactionWithMpc(unsignedTransaction: CosmosTransaction<CustomMessage>, txnBuilder: CosmosTransactionBuilder, keyShares: KeyShares, publicKey: string): Promise<CosmosLikeCoinRecoveryOutput>;
|
|
92
|
+
/**
|
|
93
|
+
* Builds a redelegate transaction
|
|
94
|
+
* @param {RecoveryOptions} params parameters needed to construct and
|
|
95
|
+
* (maybe) sign the transaction
|
|
96
|
+
*
|
|
97
|
+
* @returns {CosmosLikeCoinRecoveryOutput} the serialized transaction hex string
|
|
98
|
+
*/
|
|
99
|
+
redelegate(params: RecoveryOptions & {
|
|
100
|
+
validatorSrcAddress: string;
|
|
101
|
+
validatorDstAddress: string;
|
|
102
|
+
amountToRedelegate: string;
|
|
103
|
+
}): Promise<CosmosLikeCoinRecoveryOutput>;
|
|
104
|
+
/** @inheritDoc **/
|
|
105
|
+
verifyTransaction(params: VerifyTransactionOptions): Promise<boolean>;
|
|
106
|
+
/** @inheritDoc **/
|
|
107
|
+
explainTransaction(options: {
|
|
108
|
+
txHex: string;
|
|
109
|
+
}): Promise<ExplanationResult>;
|
|
110
|
+
/**
|
|
111
|
+
* Sign a transaction with a single private key
|
|
112
|
+
* @param params parameters in the form of { txPrebuild: {txHex}, prv }
|
|
113
|
+
* @returns signed transaction in the form of { txHex }
|
|
114
|
+
*/
|
|
115
|
+
signTransaction(params: SignTransactionOptions & {
|
|
116
|
+
txPrebuild: {
|
|
117
|
+
txHex: string;
|
|
118
|
+
};
|
|
119
|
+
prv: string;
|
|
120
|
+
}): Promise<SignedTransaction>;
|
|
121
|
+
/** @inheritDoc **/
|
|
122
|
+
parseTransaction(params: ParseTransactionOptions & {
|
|
123
|
+
txHex: string;
|
|
124
|
+
}): Promise<ParsedTransaction>;
|
|
125
|
+
/**
|
|
126
|
+
* Get the public node url from the Environments constant we have defined
|
|
127
|
+
*/
|
|
128
|
+
protected getPublicNodeUrl(): string;
|
|
129
|
+
/**
|
|
130
|
+
* Get account number from public node
|
|
131
|
+
*/
|
|
132
|
+
protected getAccountFromNode(senderAddress: string): Promise<request.Response>;
|
|
133
|
+
/**
|
|
134
|
+
* Get balance from public node
|
|
135
|
+
*/
|
|
136
|
+
protected getBalanceFromNode(senderAddress: string): Promise<request.Response>;
|
|
137
|
+
/**
|
|
138
|
+
* Get chain id from public node
|
|
139
|
+
*/
|
|
140
|
+
protected getChainIdFromNode(): Promise<request.Response>;
|
|
141
|
+
/**
|
|
142
|
+
* Helper to fetch account balance
|
|
143
|
+
*/
|
|
144
|
+
protected getAccountBalance(senderAddress: string): Promise<Coin[]>;
|
|
145
|
+
/**
|
|
146
|
+
* Helper to fetch chainId
|
|
147
|
+
*/
|
|
148
|
+
protected getChainId(): Promise<string>;
|
|
149
|
+
/**
|
|
150
|
+
* Helper to fetch account number
|
|
151
|
+
*/
|
|
152
|
+
protected getAccountDetails(senderAddress: string): Promise<string[]>;
|
|
153
|
+
/** @inheritDoc **/
|
|
154
|
+
generateKeyPair(seed?: Buffer): KeyPair;
|
|
155
|
+
/**
|
|
156
|
+
* Retrieves the address from a public key.
|
|
157
|
+
* @param {string} pubKey - The public key.
|
|
158
|
+
* @returns {string} The corresponding address.
|
|
159
|
+
*/
|
|
160
|
+
getAddressFromPublicKey(pubKey: string): string;
|
|
161
|
+
/** @inheritDoc **/
|
|
162
|
+
isWalletAddress(params: VerifyAddressOptions): Promise<boolean>;
|
|
163
|
+
/** @inheritDoc **/
|
|
164
|
+
getHashFunction(): Hash;
|
|
165
|
+
/**
|
|
166
|
+
* Process address into address and memo id
|
|
167
|
+
*
|
|
168
|
+
* @param address the address
|
|
169
|
+
* @returns object containing address and memo id
|
|
170
|
+
*/
|
|
171
|
+
getAddressDetails(address: string): AddressDetails;
|
|
172
|
+
/**
|
|
173
|
+
* Return boolean indicating whether a memo id is valid
|
|
174
|
+
*
|
|
175
|
+
* @param memoId memo id
|
|
176
|
+
* @returns true if memo id is valid
|
|
177
|
+
*/
|
|
178
|
+
isValidMemoId(memoId: string): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Helper method to return the respective coin's base unit
|
|
181
|
+
*/
|
|
182
|
+
getDenomination(): string;
|
|
183
|
+
/**
|
|
184
|
+
* Helper method to fetch gas amount details for respective coin
|
|
185
|
+
*/
|
|
186
|
+
getGasAmountDetails(): GasAmountDetails;
|
|
187
|
+
/**
|
|
188
|
+
* Helper method to get key pair for individual coin
|
|
189
|
+
* @param publicKey
|
|
190
|
+
*/
|
|
191
|
+
getKeyPair(publicKey: string): CosmosKeyPair;
|
|
192
|
+
/** @inheritDoc **/
|
|
193
|
+
auditDecryptedKey({ multiSigType, publicKey, prv }: AuditDecryptedKeyParams): void;
|
|
194
|
+
}
|
|
195
|
+
export {};
|
|
196
|
+
//# sourceMappingURL=cosmosCoin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cosmosCoin.d.ts","sourceRoot":"","sources":["../../src/cosmosCoin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,QAAQ,EAER,SAAS,EAGT,iBAAiB,EAGjB,OAAO,EACP,YAAY,EACZ,YAAY,EAEZ,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EAEjB,sBAAsB,EAGtB,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE9E,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAc,IAAI,EAAe,MAAM,QAAQ,CAAC;AAGvD,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC,OAAO,EACL,aAAa,EACb,4BAA4B,EAC5B,iBAAiB,EAEjB,gBAAgB,EAChB,eAAe,EAGf,wBAAwB,EACxB,SAAS,EAGV,MAAM,OAAO,CAAC;AAKf;;GAEG;AACH,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AASD,qBAAa,UAAU,CAAC,aAAa,GAAG,KAAK,CAAE,SAAQ,QAAQ;IAC7D,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;IAC3D,SAAS,aAAa,KAAK,EAAE,SAAS,EAAE,WAAW,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC;IAU/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